Skip to content

Commit 4032f29

Browse files
committed
feat(core): implement manual mode in renderer
1 parent 0ffcd87 commit 4032f29

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@thatopen/components",
33
"description": "Collection of core functionalities to author BIM apps.",
4-
"version": "3.2.3",
4+
"version": "3.2.4",
55
"author": "That Open Company",
66
"contributors": [
77
"Antonio Gonzalez Viegas (https://github.com/agviegas)",

packages/core/src/core/Worlds/src/simple-renderer.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ import {
88
} from "../../Types";
99
import { Components } from "../../Components";
1010

11+
/**
12+
* The mode of the renderer. If MANUAL, the renderer will be updated on command. If AUTO, the renderer will render on every update tick.
13+
*/
14+
export enum RendererMode {
15+
MANUAL,
16+
AUTO,
17+
}
18+
1119
/**
1220
* A basic renderer capable of rendering [Objec3Ds](https://threejs.org/docs/#api/en/core/Object3D).
1321
*/
@@ -28,6 +36,16 @@ export class SimpleRenderer extends BaseRenderer {
2836
*/
2937
three: THREE.WebGLRenderer;
3038

39+
/**
40+
* The mode of the renderer. If MANUAL, the renderer will be updated manually. If AUTO, the renderer will render on every update tick.
41+
*/
42+
mode = RendererMode.AUTO;
43+
44+
/**
45+
* Whether the renderer needs to be updated. If true, the renderer will be updated on the next frame.
46+
*/
47+
needsUpdate = false;
48+
3149
protected _canvas: HTMLCanvasElement;
3250
protected _parameters?: Partial<THREE.WebGLRendererParameters>;
3351
protected _resizeObserver: ResizeObserver | null = null;
@@ -75,6 +93,12 @@ export class SimpleRenderer extends BaseRenderer {
7593
/** {@link Updateable.update} */
7694
update() {
7795
if (!this.enabled || !this.currentWorld) return;
96+
97+
if (this.mode === RendererMode.MANUAL && !this.needsUpdate) {
98+
return;
99+
}
100+
this.needsUpdate = false;
101+
78102
this.onBeforeUpdate.trigger(this);
79103
const scene = this.currentWorld.scene.three;
80104
const camera = this.currentWorld.camera.three;

0 commit comments

Comments
 (0)