feat: Update SceneModule to manage camera state and viewport, refactor WebGL layer to utilize Scene methods

This commit is contained in:
Azgaar 2026-03-13 02:39:40 +01:00
parent 42557881bb
commit 52708e50c5
10 changed files with 128 additions and 26 deletions

View file

@ -26,6 +26,7 @@ export class WebGL2LayerClass {
init(): boolean {
const canvas = Scene.getCanvas();
const { graphWidth, graphHeight } = Scene.getViewport();
this.renderer = new WebGLRenderer({
canvas,
@ -53,15 +54,12 @@ export class WebGL2LayerClass {
private syncTransform() {
if (!this.camera) return;
const x = -viewX / scale;
const y = -viewY / scale;
const w = graphWidth / scale;
const h = graphHeight / scale;
const { bottom, left, right, top } = Scene.getCameraBounds();
this.camera.left = x;
this.camera.right = x + w;
this.camera.top = y;
this.camera.bottom = y + h;
this.camera.left = left;
this.camera.right = right;
this.camera.top = top;
this.camera.bottom = bottom;
this.camera.updateProjectionMatrix();
}