From b91409f5c65413dba807748a27c124b94422ddf8 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Thu, 2 Apr 2026 21:30:37 +0900 Subject: [PATCH] wip --- packages/frontend/src/utility/room/engine.ts | 6 +++--- .../frontend/src/utility/room/objects/allInOnePc.ts | 12 ++++++------ .../frontend/src/utility/room/objects/laptopPc.ts | 12 ++++++------ .../src/utility/room/objects/pictureFrame.ts | 12 ++++++------ packages/frontend/src/utility/room/objects/poster.ts | 12 ++++++------ .../src/utility/room/objects/tabletopPictureFrame.ts | 12 ++++++------ .../frontend/src/utility/room/objects/tapestry.ts | 12 ++++++------ 7 files changed, 39 insertions(+), 39 deletions(-) diff --git a/packages/frontend/src/utility/room/engine.ts b/packages/frontend/src/utility/room/engine.ts index 4bb382bbc0..3068eb8a09 100644 --- a/packages/frontend/src/utility/room/engine.ts +++ b/packages/frontend/src/utility/room/engine.ts @@ -271,7 +271,7 @@ type ObjectDef = { root: BABYLON.Mesh; options: Readonly>; model: ModelManager; - }) => RoomObjectInstance>; + }) => RoomObjectInstance> | Promise>>; // TODO: createInstanceをasyncにするのではなく、別にreadyみたいなものを返させる }; export function defineObject(def: ObjectDef): ObjectDef { @@ -1061,7 +1061,7 @@ export class RoomEngine { meshUpdated(meshes); }); - const objectInstance = def.createInstance({ + const objectInstance = await def.createInstance({ room: this, scene: this.scene, root, @@ -1640,7 +1640,7 @@ export class RoomObjectPreviewEngine { meshUpdated(loaderResult.meshes); - const objectInstance = def.createInstance({ + const objectInstance = await def.createInstance({ room: null, scene: this.scene, root, diff --git a/packages/frontend/src/utility/room/objects/allInOnePc.ts b/packages/frontend/src/utility/room/objects/allInOnePc.ts index 02c885f774..75dec9c540 100644 --- a/packages/frontend/src/utility/room/objects/allInOnePc.ts +++ b/packages/frontend/src/utility/room/objects/allInOnePc.ts @@ -46,7 +46,7 @@ export const allInOnePc = defineObject({ }, }, placement: 'top', - createInstance: ({ scene, options, model }) => { + createInstance: async ({ scene, options, model }) => { const screenMesh = model.findMesh('__X_SCREEN__'); const bodyMaterial = model.findMaterial('__X_BODY__'); @@ -70,7 +70,7 @@ export const allInOnePc = defineObject({ applyFit(); - const applyCustomPicture = () => { + const applyCustomPicture = () => new Promise((resolve) => { if (options.customPicture != null) { const tex = new BABYLON.Texture(options.customPicture, scene, false, false); tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE; @@ -79,17 +79,17 @@ export const allInOnePc = defineObject({ screenMaterial.emissiveTexture = tex; - applyFit(); - tex.onLoadObservable.addOnce(() => { applyFit(); + resolve(); }); } else { screenMaterial.emissiveTexture = null; + resolve(); } - }; + }); - applyCustomPicture(); + await applyCustomPicture(); const applyScreenBrightness = () => { const b = options.screenBrightness; diff --git a/packages/frontend/src/utility/room/objects/laptopPc.ts b/packages/frontend/src/utility/room/objects/laptopPc.ts index 5cf9f3f22e..93d1dcdc21 100644 --- a/packages/frontend/src/utility/room/objects/laptopPc.ts +++ b/packages/frontend/src/utility/room/objects/laptopPc.ts @@ -54,7 +54,7 @@ export const laptopPc = defineObject({ }, }, placement: 'top', - createInstance: ({ scene, options, model }) => { + createInstance: async ({ scene, options, model }) => { const screenMesh = model.findMesh('__X_SCREEN__'); const hutaNode = model.findTransformNode('__X_HUTA__'); @@ -79,7 +79,7 @@ export const laptopPc = defineObject({ applyFit(); - const applyCustomPicture = () => { + const applyCustomPicture = () => new Promise((resolve) => { if (options.customPicture != null) { const tex = new BABYLON.Texture(options.customPicture, scene, false, false); tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE; @@ -88,17 +88,17 @@ export const laptopPc = defineObject({ screenMaterial.emissiveTexture = tex; - applyFit(); - tex.onLoadObservable.addOnce(() => { applyFit(); + resolve(); }); } else { screenMaterial.emissiveTexture = null; + resolve(); } - }; + }); - applyCustomPicture(); + await applyCustomPicture(); const applyScreenBrightness = () => { const b = options.screenBrightness; diff --git a/packages/frontend/src/utility/room/objects/pictureFrame.ts b/packages/frontend/src/utility/room/objects/pictureFrame.ts index ec2c02de83..6c78ba4e0b 100644 --- a/packages/frontend/src/utility/room/objects/pictureFrame.ts +++ b/packages/frontend/src/utility/room/objects/pictureFrame.ts @@ -83,7 +83,7 @@ export const pictureFrame = defineObject({ }, }, placement: 'side', - createInstance: ({ scene, options, model }) => { + createInstance: async ({ scene, options, model }) => { const frameMesh = model.findMesh('__X_FRAME__'); frameMesh.rotationQuaternion = null; const matMesh = model.findMesh('__X_MAT__'); @@ -156,7 +156,7 @@ export const pictureFrame = defineObject({ applyDepth(); - const applyCustomPicture = () => { + const applyCustomPicture = () => new Promise((resolve) => { if (options.customPicture != null) { const tex = new BABYLON.Texture(options.customPicture, scene, false, false); tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE; @@ -165,18 +165,18 @@ export const pictureFrame = defineObject({ pictureMaterial.albedoColor = new BABYLON.Color3(1, 1, 1); pictureMaterial.albedoTexture = tex; - applyFit(); - tex.onLoadObservable.addOnce(() => { applyFit(); + resolve(); }); } else { pictureMaterial.albedoColor = new BABYLON.Color3(0.5, 0.5, 0.5); pictureMaterial.albedoTexture = null; + resolve(); } - }; + }); - applyCustomPicture(); + await applyCustomPicture(); const frameMaterial = model.findMaterial('__X_FRAME__'); diff --git a/packages/frontend/src/utility/room/objects/poster.ts b/packages/frontend/src/utility/room/objects/poster.ts index b8f63bda8a..81abfe2a4d 100644 --- a/packages/frontend/src/utility/room/objects/poster.ts +++ b/packages/frontend/src/utility/room/objects/poster.ts @@ -44,7 +44,7 @@ export const poster = defineObject({ }, }, placement: 'side', - createInstance: ({ scene, options, model }) => { + createInstance: async ({ scene, options, model }) => { const pictureMesh = model.findMesh('__X_PICTURE__'); pictureMesh.rotationQuaternion = null; @@ -84,7 +84,7 @@ export const poster = defineObject({ applySize(); - const applyCustomPicture = () => { + const applyCustomPicture = () => new Promise((resolve) => { if (options.customPicture != null) { const tex = new BABYLON.Texture(options.customPicture, scene, false, false); tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE; @@ -93,18 +93,18 @@ export const poster = defineObject({ pictureMaterial.albedoColor = new BABYLON.Color3(1, 1, 1); pictureMaterial.albedoTexture = tex; - applyFit(); - tex.onLoadObservable.addOnce(() => { applyFit(); + resolve(); }); } else { pictureMaterial.albedoColor = new BABYLON.Color3(0.5, 0.5, 0.5); pictureMaterial.albedoTexture = null; + resolve(); } - }; + }); - applyCustomPicture(); + await applyCustomPicture(); return { onInited: () => { diff --git a/packages/frontend/src/utility/room/objects/tabletopPictureFrame.ts b/packages/frontend/src/utility/room/objects/tabletopPictureFrame.ts index 43a289bd09..b6be55aaa1 100644 --- a/packages/frontend/src/utility/room/objects/tabletopPictureFrame.ts +++ b/packages/frontend/src/utility/room/objects/tabletopPictureFrame.ts @@ -83,7 +83,7 @@ export const tabletopPictureFrame = defineObject({ }, }, placement: 'top', - createInstance: ({ scene, options, model }) => { + createInstance: async ({ scene, options, model }) => { const frameMesh = model.findMesh('__X_FRAME__'); frameMesh.rotationQuaternion = null; const matMesh = model.findMesh('__X_MAT__'); @@ -161,7 +161,7 @@ export const tabletopPictureFrame = defineObject({ applyDepth(); - const applyCustomPicture = () => { + const applyCustomPicture = () => new Promise((resolve) => { if (options.customPicture != null) { const tex = new BABYLON.Texture(options.customPicture, scene, false, false); tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE; @@ -170,18 +170,18 @@ export const tabletopPictureFrame = defineObject({ pictureMaterial.albedoColor = new BABYLON.Color3(1, 1, 1); pictureMaterial.albedoTexture = tex; - applyFit(); - tex.onLoadObservable.addOnce(() => { applyFit(); + resolve(); }); } else { pictureMaterial.albedoColor = new BABYLON.Color3(0.5, 0.5, 0.5); pictureMaterial.albedoTexture = null; + resolve(); } - }; + }); - applyCustomPicture(); + await applyCustomPicture(); const frameMaterial = model.findMaterial('__X_FRAME__'); diff --git a/packages/frontend/src/utility/room/objects/tapestry.ts b/packages/frontend/src/utility/room/objects/tapestry.ts index dfb8e2a6ba..2fc846b9cd 100644 --- a/packages/frontend/src/utility/room/objects/tapestry.ts +++ b/packages/frontend/src/utility/room/objects/tapestry.ts @@ -44,7 +44,7 @@ export const tapestry = defineObject({ }, }, placement: 'side', - createInstance: ({ scene, options, model }) => { + createInstance: async ({ scene, options, model }) => { const pictureMesh = model.findMesh('__X_PICTURE__'); pictureMesh.rotationQuaternion = null; @@ -88,7 +88,7 @@ export const tapestry = defineObject({ applySize(); - const applyCustomPicture = () => { + const applyCustomPicture = () => new Promise((resolve) => { if (options.customPicture != null) { const tex = new BABYLON.Texture(options.customPicture, scene, false, false); tex.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE; @@ -97,18 +97,18 @@ export const tapestry = defineObject({ pictureMaterial.albedoColor = new BABYLON.Color3(1, 1, 1); pictureMaterial.albedoTexture = tex; - applyFit(); - tex.onLoadObservable.addOnce(() => { applyFit(); + resolve(); }); } else { pictureMaterial.albedoColor = new BABYLON.Color3(0.5, 0.5, 0.5); pictureMaterial.albedoTexture = null; + resolve(); } - }; + }); - applyCustomPicture(); + await applyCustomPicture(); return { onInited: () => {