diff --git a/packages/frontend/assets/room/objects/iron-wood-shelf/iron-wood-shelf-h.glb b/packages/frontend/assets/room/objects/iron-wood-shelf/iron-wood-shelf-h.glb new file mode 100644 index 0000000000..04ba511e05 Binary files /dev/null and b/packages/frontend/assets/room/objects/iron-wood-shelf/iron-wood-shelf-h.glb differ diff --git a/packages/frontend/assets/room/objects/iron-wood-shelf/iron-wood-shelf-v.glb b/packages/frontend/assets/room/objects/iron-wood-shelf/iron-wood-shelf-v.glb new file mode 100644 index 0000000000..a031b08661 Binary files /dev/null and b/packages/frontend/assets/room/objects/iron-wood-shelf/iron-wood-shelf-v.glb differ diff --git a/packages/frontend/assets/room/objects/iron-wood-shelf/iron-wood-shelf.blend b/packages/frontend/assets/room/objects/iron-wood-shelf/iron-wood-shelf.blend new file mode 100644 index 0000000000..f854930035 Binary files /dev/null and b/packages/frontend/assets/room/objects/iron-wood-shelf/iron-wood-shelf.blend differ diff --git a/packages/frontend/src/utility/room/engine.ts b/packages/frontend/src/utility/room/engine.ts index 03ce83dc82..7ace83144f 100644 --- a/packages/frontend/src/utility/room/engine.ts +++ b/packages/frontend/src/utility/room/engine.ts @@ -308,6 +308,7 @@ class ModelManager { type ObjectDef = { id: string; name: string; + path?: string; options: { schema: OpSc; default: GetOptionsSchemaValues; @@ -1056,7 +1057,8 @@ export class RoomEngine { const root = new BABYLON.TransformNode(`object_${args.id}_${args.type}`, this.scene); - const loaderResult = await BABYLON.LoadAssetContainerAsync(`/client-assets/room/objects/${camelToKebab(args.type)}/${camelToKebab(args.type)}.glb`, this.scene); + const filePath = def.path != null ? `/client-assets/room/objects/${def.path}.glb` : `/client-assets/room/objects/${camelToKebab(args.type)}/${camelToKebab(args.type)}.glb`; + const loaderResult = await BABYLON.LoadAssetContainerAsync(filePath, this.scene); // babylonによって自動で追加される右手系変換用ノード const subRoot = loaderResult.meshes[0] as BABYLON.Mesh; @@ -1903,7 +1905,8 @@ export class RoomObjectPreviewEngine { const root = new BABYLON.Mesh(`object_${args.type}`, this.scene); - const loaderResult = await BABYLON.LoadAssetContainerAsync(`/client-assets/room/objects/${camelToKebab(args.type)}/${camelToKebab(args.type)}.glb`, this.scene); + const filePath = def.path != null ? `/client-assets/room/objects/${def.path}.glb` : `/client-assets/room/objects/${camelToKebab(args.type)}/${camelToKebab(args.type)}.glb`; + const loaderResult = await BABYLON.LoadAssetContainerAsync(filePath, this.scene); // babylonによって自動で追加される右手系変換用ノード const subRoot = loaderResult.meshes[0]; diff --git a/packages/frontend/src/utility/room/objects/ironWoodShelf.ts b/packages/frontend/src/utility/room/objects/ironWoodShelf.ts new file mode 100644 index 0000000000..3494b6bc61 --- /dev/null +++ b/packages/frontend/src/utility/room/objects/ironWoodShelf.ts @@ -0,0 +1,77 @@ +/* + * SPDX-FileCopyrightText: syuilo and misskey-project + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import * as BABYLON from '@babylonjs/core'; +import { defineObject } from '../engine.js'; + +export const ironWoodShelfH = defineObject({ + id: 'ironWoodShelfH', + name: 'ironWoodShelf H', + path: 'iron-wood-shelf/iron-wood-shelf-h', + options: { + schema: { + frameColor: { + type: 'color', + label: 'Frame color', + }, + }, + default: { + frameColor: [0.2, 0.2, 0.2], + }, + }, + placement: 'floor', + createInstance: ({ options, model }) => { + const frameMaterial = model.findMaterial('__X_FRAME__'); + + const applyFrameColor = () => { + const [r, g, b] = options.frameColor; + frameMaterial.albedoColor = new BABYLON.Color3(r, g, b); + }; + + applyFrameColor(); + + return { + onOptionsUpdated: ([k, v]) => { + applyFrameColor(); + }, + interactions: {}, + }; + }, +}); + +export const ironWoodShelfV = defineObject({ + id: 'ironWoodShelfV', + name: 'ironWoodShelf V', + path: 'iron-wood-shelf/iron-wood-shelf-v', + options: { + schema: { + frameColor: { + type: 'color', + label: 'Frame color', + }, + }, + default: { + frameColor: [0.2, 0.2, 0.2], + }, + }, + placement: 'floor', + createInstance: ({ options, model }) => { + const frameMaterial = model.findMaterial('__X_FRAME__'); + + const applyFrameColor = () => { + const [r, g, b] = options.frameColor; + frameMaterial.albedoColor = new BABYLON.Color3(r, g, b); + }; + + applyFrameColor(); + + return { + onOptionsUpdated: ([k, v]) => { + applyFrameColor(); + }, + interactions: {}, + }; + }, +});