From d5702fe98c0b45398cae15b6fae2e286a3619c17 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Tue, 31 Mar 2026 20:05:35 +0200 Subject: [PATCH] Refactor viewport update logic to use applyWorld method --- src/viewport-three/viewport-host.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/viewport-three/viewport-host.ts b/src/viewport-three/viewport-host.ts index 6a0baad6..d9d4dd60 100644 --- a/src/viewport-three/viewport-host.ts +++ b/src/viewport-three/viewport-host.ts @@ -203,12 +203,8 @@ export class ViewportHost { } updateWorld(world: WorldSettings) { - this.scene.background = null; - this.ambientLight.color.set(world.ambientLight.colorHex); - this.ambientLight.intensity = world.ambientLight.intensity; - this.sunLight.color.set(world.sunLight.colorHex); - this.sunLight.intensity = world.sunLight.intensity; - this.sunLight.position.set(world.sunLight.direction.x, world.sunLight.direction.y, world.sunLight.direction.z).normalize().multiplyScalar(18); + this.currentWorld = world; + this.applyWorld(); } updateDocument(document: SceneDocument, selection: EditorSelection) { @@ -223,6 +219,10 @@ export class ViewportHost { this.projectAssets = projectAssets; this.loadedModelAssets = loadedModelAssets; + if (this.currentWorld !== null) { + this.applyWorld(); + } + if (this.currentDocument !== null) { this.rebuildModelInstances(this.currentDocument, this.currentSelection); } @@ -285,6 +285,7 @@ export class ViewportHost { this.renderer.domElement.removeEventListener("pointerleave", this.handlePointerLeave); this.renderer.domElement.removeEventListener("wheel", this.handleWheel); this.renderer.domElement.removeEventListener("auxclick", this.handleAuxClick); + this.clearLocalLights(); this.clearBrushMeshes(); this.clearEntityMarkers(); this.boxCreatePreviewHandler = null;