Skip to content

Commit 41b9428

Browse files
committed
refactor(soba/cameras): adjust perspective camera code
1 parent 13b80f5 commit 41b9428

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

libs/soba/cameras/src/lib/perspective-camera.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,19 @@ export class NgtsPerspectiveCamera {
7575
constructor() {
7676
extend({ PerspectiveCamera, Group });
7777

78+
effect((onCleanup) => {
79+
const makeDefault = this.makeDefault();
80+
if (!makeDefault) return;
81+
82+
const camera = this.cameraRef().nativeElement;
83+
const oldCam = this.store.snapshot.camera;
84+
this.store.update({ camera });
85+
onCleanup(() => this.store.update(() => ({ camera: oldCam })));
86+
});
87+
7888
effect(() => {
79-
this.cameraRef().nativeElement.updateProjectionMatrix();
89+
const camera = this.cameraRef().nativeElement;
90+
camera.updateProjectionMatrix();
8091
});
8192

8293
effect(() => {
@@ -91,15 +102,6 @@ export class NgtsPerspectiveCamera {
91102
camera.updateProjectionMatrix();
92103
});
93104

94-
effect((onCleanup) => {
95-
const makeDefault = this.makeDefault();
96-
if (!makeDefault) return;
97-
98-
const oldCam = this.store.snapshot.camera;
99-
this.store.update({ camera: this.cameraRef().nativeElement });
100-
onCleanup(() => this.store.update(() => ({ camera: oldCam })));
101-
});
102-
103105
let count = 0;
104106
let oldEnvMap: THREE.Color | THREE.Texture | null = null;
105107
injectBeforeRender(({ gl, scene }) => {

0 commit comments

Comments
 (0)