1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-18 14:15:34 +02:00
This commit is contained in:
syuilo
2026-02-20 11:39:42 +09:00
parent 41d40f53cf
commit cdc9b47b78
8 changed files with 94 additions and 7 deletions

View File

@@ -13,7 +13,7 @@ export const tabletopDigitalClock = defineObject({
options: {
schema: {
bodyStyle: {
type: 'select',
type: 'enum',
label: 'Body Style',
enum: ['color', 'wood'],
},
@@ -37,7 +37,7 @@ export const tabletopDigitalClock = defineObject({
const [r, g, b] = options.bodyColor;
bodyMaterial.albedoColor = new BABYLON.Color3(r, g, b);
} else {
bodyMaterial.albedoTexture = room.scene.getTextureByName('tabletop_digital_clock_wood');
}
};

View File

@@ -0,0 +1,76 @@
/*
* 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 wallShelf = defineObject({
id: 'wallShelf',
name: 'Wall Shelf',
options: {
schema: {
style: {
type: 'enum',
label: 'Style',
enum: ['A', 'B'],
},
boardStyle: {
type: 'enum',
label: 'Board style',
enum: ['color', 'wood'],
},
boardColor: {
type: 'color',
label: 'Board color',
},
},
default: {
style: 'A',
boardStyle: 'wood',
boardColor: [1, 1, 1],
},
},
placement: 'side',
createInstance: ({ room, options, root }) => {
const applyStyle = () => {
const aMeshes = root.getChildMeshes().filter(m => m.name.includes('__X_VARIATION_A__'));
const bMeshes = root.getChildMeshes().filter(m => m.name.includes('__X_VARIATION_B__'));
for (const m of aMeshes) {
(m as BABYLON.Mesh).setEnabled(options.style === 'A');
}
for (const m of bMeshes) {
(m as BABYLON.Mesh).setEnabled(options.style === 'B');
}
};
applyStyle();
const bodyMesh = root.getChildMeshes().find(m => m.name.includes('__X_BOARD__')) as BABYLON.Mesh;
const bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
const bodyTexture = bodyMaterial.albedoTexture as BABYLON.Texture;
const applyBoardColor = () => {
const [r, g, b] = options.boardColor;
bodyMaterial.albedoColor = new BABYLON.Color3(r, g, b);
if (options.boardStyle === 'color') {
bodyMaterial.albedoTexture = null;
} else {
bodyMaterial.albedoTexture = bodyTexture;
}
};
applyBoardColor();
return {
onOptionsUpdated: ([k, v]) => {
applyStyle();
applyBoardColor();
},
interactions: {},
};
},
});