Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/com/Communication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ export class DIVECommunication {
let returnValue: Actions[Action]['RETURN'] = false;

switch (action) {
case 'START_RENDER': {
this.renderer.StartRenderer(this.scene, this.controller.object);
returnValue = true;
break;
}
case 'GET_ALL_SCENE_DATA': {
returnValue = this.getAllSceneData(
payload as Actions['GET_ALL_SCENE_DATA']['PAYLOAD'],
Expand Down
7 changes: 7 additions & 0 deletions src/com/__test__/Communication.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ jest.mock('../../toolbox/select/SelectTool', () => {
const mockRenderer = {
render: jest.fn(),
OnResize: jest.fn(),
StartRenderer: jest.fn(),
} as unknown as DIVERenderer;

const mockScene = {
Expand Down Expand Up @@ -288,6 +289,12 @@ describe('dive/communication/DIVECommunication', () => {
).not.toThrow();
});

it('should perform action START_RENDER', () => {
const success = testCom.PerformAction('START_RENDER');
expect(mockRenderer.StartRenderer).toHaveBeenCalledTimes(1);
expect(success).toBe(true);
});

it('should perform action ADD_OBJECT', () => {
const payload = {
entityType: 'light',
Expand Down
2 changes: 2 additions & 0 deletions src/com/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import START_RENDER from './renderer/startrender.ts';
import SET_BACKGROUND from './scene/setbackground.ts';
import RESET_CAMERA from './camera/resetcamera.ts';
import SET_CAMERA_LAYER from './camera/setcameralayer.ts';
Expand Down Expand Up @@ -28,6 +29,7 @@ import EXPORT_SCENE from './scene/exportscene.ts';
import LAUNCH_AR from './scene/launchar.ts';

export interface Actions {
START_RENDER: START_RENDER;
GET_ALL_SCENE_DATA: GET_ALL_SCENE_DATA;
GET_ALL_OBJECTS: GET_ALL_OBJECTS;
GET_OBJECTS: GET_OBJECTS;
Expand Down
5 changes: 5 additions & 0 deletions src/com/actions/renderer/startrender.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default interface START_RENDER {
DESCRIPTION: 'Starts the render process.';
PAYLOAD: undefined;
RETURN: boolean;
}
10 changes: 7 additions & 3 deletions src/dive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import pkgjson from '../package.json';

export type DIVESettings = {
autoResize: boolean;
autoStart: boolean;
displayAxes: boolean;
renderer: Partial<DIVERendererSettings>;
perspectiveCamera: Partial<DIVEPerspectiveCameraSettings>;
Expand All @@ -31,6 +32,7 @@ export type DIVESettings = {

export const DIVEDefaultSettings: DIVESettings = {
autoResize: true,
autoStart: true,
displayAxes: false,
renderer: DIVERendererDefaultSettings,
perspectiveCamera: DIVEPerspectiveCameraDefaultSettings,
Expand Down Expand Up @@ -266,9 +268,6 @@ export default class DIVE {
this.addResizeObserver();
}

// whene everything is done, start the renderer
this.renderer.StartRenderer(this.scene, this.perspectiveCamera);

// eslint-disable-next-line @typescript-eslint/no-explicit-any
(window as any).DIVE = {
PrintScene: () => {
Expand Down Expand Up @@ -307,6 +306,11 @@ export default class DIVE {
@@@@@@@ @@@@@@

`);

if (this._settings.autoStart) {
// when everything is done, start the renderer
this.renderer.StartRenderer(this.scene, this.perspectiveCamera);
}
}

public Dispose(): void {
Expand Down
4 changes: 1 addition & 3 deletions src/toolbox/Toolbox.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type DIVEOrbitControls from '../controls/OrbitControls.ts';
import { type DIVEScene } from '../scene/Scene.ts';
import { type DIVEBaseTool } from './BaseTool.ts';
import { type DIVESelectTool } from './select/SelectTool.ts';
import { DIVESelectTool } from './select/SelectTool.ts';

export type ToolType = 'select' | 'none';

Expand All @@ -22,8 +22,6 @@ export default class DIVEToolbox {
private _selectTool: DIVESelectTool | null;
public get selectTool(): DIVESelectTool {
if (!this._selectTool) {
const DIVESelectTool = require('./select/SelectTool.ts')
.DIVESelectTool as typeof import('./select/SelectTool.ts').DIVESelectTool;
this._selectTool = new DIVESelectTool(
this._scene,
this._controller,
Expand Down