From d1d31da8642426d5def2f66fc59d398c5d5d1ac3 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Thu, 12 Mar 2026 18:35:57 +0100 Subject: [PATCH] feat: Improve camera synchronization and add null check for camera instance --- src/modules/webgl-layer-framework.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/modules/webgl-layer-framework.ts b/src/modules/webgl-layer-framework.ts index 1b992298..4732f065 100644 --- a/src/modules/webgl-layer-framework.ts +++ b/src/modules/webgl-layer-framework.ts @@ -191,7 +191,7 @@ export class WebGL2LayerFrameworkClass { } syncTransform(): void { - const camera = this.camera; + if (!this.camera) return; const bounds = buildCameraBounds( viewX, viewY, @@ -199,17 +199,14 @@ export class WebGL2LayerFrameworkClass { graphWidth, graphHeight, ); - camera.left = bounds.left; - camera.right = bounds.right; - camera.top = bounds.top; - camera.bottom = bounds.bottom; - camera.updateProjectionMatrix(); + this.camera.left = bounds.left; + this.camera.right = bounds.right; + this.camera.top = bounds.top; + this.camera.bottom = bounds.bottom; + this.camera.updateProjectionMatrix(); } private subscribeD3Zoom(): void { - // viewbox is declared as a global in src/types/global.ts (exposed by main.js). - // Guard for Node test env where it doesn't exist. - if (typeof viewbox === "undefined") return; viewbox.on("zoom.webgl", () => this.requestRender()); }