1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-21 16:55:33 +02:00
This commit is contained in:
syuilo
2026-02-22 14:24:57 +09:00
parent 20dc48f221
commit cdb8d86fbf
4 changed files with 42 additions and 6 deletions

View File

@@ -3,19 +3,55 @@
* SPDX-License-Identifier: AGPL-3.0-only * SPDX-License-Identifier: AGPL-3.0-only
*/ */
import * as BABYLON from '@babylonjs/core';
import { defineObject } from '../engine.js'; import { defineObject } from '../engine.js';
export const chair = defineObject({ export const chair = defineObject({
id: 'chair', id: 'chair',
name: 'Chair', name: 'Chair',
options: { options: {
schema: {}, schema: {
default: {}, primaryColor: {
type: 'color',
label: 'Primay Color',
},
secondaryColor: {
type: 'color',
label: 'Secondary Color',
},
},
default: {
primaryColor: [0.44, 0.6, 0],
secondaryColor: [0, 0, 0],
},
}, },
placement: 'floor', placement: 'floor',
isChair: true, isChair: true,
createInstance: () => { createInstance: ({ root, options }) => {
const primaryMesh = root.getChildMeshes().find(m => m.name.includes('__X_PRIMARY__')) as BABYLON.Mesh;
const primaryMaterial = primaryMesh.material as BABYLON.PBRMaterial;
const secondaryMesh = root.getChildMeshes().find(m => m.name.includes('__X_SECONDARY__')) as BABYLON.Mesh;
const secondaryMaterial = secondaryMesh.material as BABYLON.PBRMaterial;
const applyPrimaryColor = () => {
const [r, g, b] = options.primaryColor;
primaryMaterial.albedoColor = new BABYLON.Color3(r, g, b);
};
const applySecondaryColor = () => {
const [r, g, b] = options.secondaryColor;
secondaryMaterial.albedoColor = new BABYLON.Color3(r, g, b);
};
applyPrimaryColor();
applySecondaryColor();
return { return {
onOptionsUpdated: ([k, v]) => {
applyPrimaryColor();
applySecondaryColor();
},
interactions: {}, interactions: {},
}; };
}, },

View File

@@ -67,10 +67,10 @@ export const tabletopDigitalClock = defineObject({
const colonMeshes = root.getChildMeshes().filter(m => m.name.includes('__TIME_7SEG_COLON__')); const colonMeshes = root.getChildMeshes().filter(m => m.name.includes('__TIME_7SEG_COLON__'));
const applyBodyColor = () => { const bodyMesh = root.getChildMeshes().find(m => m.name.includes('__X_BODY__')) as BABYLON.Mesh;
const bodyMesh = root.getChildMeshes().find(m => m.name.includes('__X_BODY__')) as BABYLON.Mesh; const bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
const bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
const applyBodyColor = () => {
if (options.bodyStyle === 'color') { if (options.bodyStyle === 'color') {
const [r, g, b] = options.bodyColor; const [r, g, b] = options.bodyColor;
bodyMaterial.albedoColor = new BABYLON.Color3(r, g, b); bodyMaterial.albedoColor = new BABYLON.Color3(r, g, b);