From 3873eb0cd761f31a2c584cd427063f69a9f1c4f8 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Fri, 3 Apr 2026 17:21:21 +0900 Subject: [PATCH] wip --- packages/frontend/src/utility/room/engine.ts | 11 ++++++++--- .../src/utility/room/objects/ceilingFanLight.ts | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/frontend/src/utility/room/engine.ts b/packages/frontend/src/utility/room/engine.ts index ed62a9acd3..a85fce2154 100644 --- a/packages/frontend/src/utility/room/engine.ts +++ b/packages/frontend/src/utility/room/engine.ts @@ -149,6 +149,7 @@ type GetOptionsSchemaValues = { class ModelManager { public root: BABYLON.Mesh; public bakedCallback: (() => void) | null = null; + public bakeExcludeMeshes: BABYLON.Mesh[] = []; private originalMeshes: BABYLON.Mesh[] = []; private bakedMeshes: BABYLON.Mesh[] = []; @@ -194,7 +195,7 @@ class ModelManager { } this.bakedMeshes = []; - const childMeshes = this.root.getChildMeshes().filter(m => m.isVisible && !m.name.includes('__TOP__') && !m.name.includes('__SIDE__') && !m.name.includes('__COLLISION__')); + const childMeshes = this.root.getChildMeshes().filter(m => !this.bakeExcludeMeshes.some(x => x === m) && m.isVisible && !m.name.includes('__TOP__') && !m.name.includes('__SIDE__') && !m.name.includes('__COLLISION__')); const _toMerge = [] as BABYLON.Mesh[]; for (const mesh of childMeshes) { @@ -246,7 +247,7 @@ class ModelManager { this.bakedMeshes = [merged]; - this.bakedCallback?.(this.bakedMeshes); + this.bakedCallback?.([...this.bakedMeshes, ...this.bakeExcludeMeshes]); } catch (err) { console.error('Failed to bake mesh for object', this.root.metadata?.objectType, err); } @@ -1051,6 +1052,8 @@ export class RoomEngine { } } } + + this.scene.addMesh(mesh); } }); @@ -1573,7 +1576,7 @@ export class RoomObjectPreviewEngine { const root = new BABYLON.Mesh(`object_${args.type}`, this.scene); - const loaderResult = await BABYLON.ImportMeshAsync(`/client-assets/room/objects/${camelToKebab(args.type)}/${camelToKebab(args.type)}.glb`, this.scene); + const loaderResult = await BABYLON.LoadAssetContainerAsync(`/client-assets/room/objects/${camelToKebab(args.type)}/${camelToKebab(args.type)}.glb`, this.scene); // babylonによって自動で追加される右手系変換用ノード const subRoot = loaderResult.meshes[0]; @@ -1628,6 +1631,8 @@ export class RoomObjectPreviewEngine { } } } + + this.scene.addMesh(mesh); } }), }); diff --git a/packages/frontend/src/utility/room/objects/ceilingFanLight.ts b/packages/frontend/src/utility/room/objects/ceilingFanLight.ts index 04cc829a0b..51466d0435 100644 --- a/packages/frontend/src/utility/room/objects/ceilingFanLight.ts +++ b/packages/frontend/src/utility/room/objects/ceilingFanLight.ts @@ -17,9 +17,11 @@ export const ceilingFanLight = defineObject({ receiveShadows: false, castShadows: false, createInstance: ({ scene, model }) => { + const rotor = model.findMesh('Rotor'); + model.bakeExcludeMeshes = [rotor, rotor.parent, ...rotor.getChildMeshes()]; + return { onInited: () => { - const rotor = model.findMesh('Rotor'); rotor.rotation = rotor.rotationQuaternion != null ? rotor.rotationQuaternion.toEulerAngles() : rotor.rotation; const anim = new BABYLON.Animation('', 'rotation.y', 60, BABYLON.Animation.ANIMATIONTYPE_FLOAT, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE); anim.setKeys([