mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-04-04 06:27:24 +02:00
feat: Improve camera synchronization and add null check for camera instance
This commit is contained in:
parent
8560c131eb
commit
d1d31da864
1 changed files with 6 additions and 9 deletions
|
|
@ -191,7 +191,7 @@ export class WebGL2LayerFrameworkClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
syncTransform(): void {
|
syncTransform(): void {
|
||||||
const camera = this.camera;
|
if (!this.camera) return;
|
||||||
const bounds = buildCameraBounds(
|
const bounds = buildCameraBounds(
|
||||||
viewX,
|
viewX,
|
||||||
viewY,
|
viewY,
|
||||||
|
|
@ -199,17 +199,14 @@ export class WebGL2LayerFrameworkClass {
|
||||||
graphWidth,
|
graphWidth,
|
||||||
graphHeight,
|
graphHeight,
|
||||||
);
|
);
|
||||||
camera.left = bounds.left;
|
this.camera.left = bounds.left;
|
||||||
camera.right = bounds.right;
|
this.camera.right = bounds.right;
|
||||||
camera.top = bounds.top;
|
this.camera.top = bounds.top;
|
||||||
camera.bottom = bounds.bottom;
|
this.camera.bottom = bounds.bottom;
|
||||||
camera.updateProjectionMatrix();
|
this.camera.updateProjectionMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
private subscribeD3Zoom(): void {
|
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());
|
viewbox.on("zoom.webgl", () => this.requestRender());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue