diff --git a/src/modules/entity/builders/ZoneEntityBuilder.ts b/src/modules/entity/builders/ZoneEntityBuilder.ts index b4d72cca..a2bbc6d4 100644 --- a/src/modules/entity/builders/ZoneEntityBuilder.ts +++ b/src/modules/entity/builders/ZoneEntityBuilder.ts @@ -19,8 +19,15 @@ export class ZoneEntityBuilder { const controller = new ZoneEntityController(zoneEntity); gameObject.addComponent(controller); - // Explicitly create the zone mesh after adding the controller - controller.createZoneMesh(); + // Log the zone entity properties before creating the mesh + console.log(`Building zone entity ${zoneEntity.id}`); + console.log(`Shape type: ${zoneEntity.shapeType}`); + console.log(`Compound shape URL: ${zoneEntity.compoundShapeURL}`); + + // Delay the mesh creation to ensure all properties are set + setTimeout(() => { + controller.createZoneMesh(); + }, 0); console.log(`Zone entity built for zone ${zoneEntity.id}`); console.log(`GameObject name: ${gameObject.name}`); diff --git a/src/modules/entity/components/controllers/ZoneEntityController.ts b/src/modules/entity/components/controllers/ZoneEntityController.ts index 665a69f5..180bd17c 100644 --- a/src/modules/entity/components/controllers/ZoneEntityController.ts +++ b/src/modules/entity/components/controllers/ZoneEntityController.ts @@ -419,4 +419,30 @@ export class ZoneEntityController extends EntityController { public get zoneMesh(): Mesh | null { return this._zoneMesh; } + + public activateZoneSettings(): void { + this._updateSkybox(); + this.updateAmbientLight(); + this.updateKeyLight(); + this.updateHaze(); + this._updateUserData(); + console.log(`Activated settings for zone ${this._zoneEntity.id}`); + } + + public deactivateZoneSettings(): void { + if (this._skybox) { + this._skybox.enable = false; + } + if (this._ambientLight) { + this._ambientLight.light?.setEnabled(false); + } + if (this._keyLight) { + this._keyLight.enable = false; + } + if (this._haze) { + this._haze.enable = false; + } + // Revert any user data changes if necessary + console.log(`Deactivated settings for zone ${this._zoneEntity.id}`); + } } \ No newline at end of file diff --git a/src/modules/scene/ZoneManager.ts b/src/modules/scene/ZoneManager.ts index 150034ec..6b8763c9 100644 --- a/src/modules/scene/ZoneManager.ts +++ b/src/modules/scene/ZoneManager.ts @@ -6,7 +6,7 @@ export class ZoneManager { private _scene: Scene; private _currentZone: ZoneEntityController | null = null; private _lastUpdateTime: number = 0; - private _updateInterval: number = 200; // Update every 500ms + private _updateInterval: number = 200; // Update every 200ms constructor(scene: Scene) { this._scene = scene; @@ -37,11 +37,14 @@ export class ZoneManager { if (newZone !== this._currentZone) { if (this._currentZone) { Log.debug(Log.types.ENTITIES, `Exiting zone: ${this._currentZone.id}`); + this._currentZone.deactivateZoneSettings(); } if (newZone) { Log.debug(Log.types.ENTITIES, `Entering zone: ${newZone.id}`); + newZone.activateZoneSettings(); } else { Log.debug(Log.types.ENTITIES, "Not in any zone"); + // Optionally, activate default scene settings here } this._currentZone = newZone; }