1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-27 00:14:12 +02:00

Update tabletopDigitalClock.ts

This commit is contained in:
syuilo
2026-02-21 20:45:44 +09:00
parent 689c24c776
commit fcc36759f7

View File

@@ -21,30 +21,19 @@ export const tabletopDigitalClock = defineObject({
type: 'color', type: 'color',
label: 'Body Color', label: 'Body Color',
}, },
lcdColor: {
type: 'color',
label: 'LCD Color',
},
}, },
default: { default: {
bodyStyle: 'color', bodyStyle: 'color',
bodyColor: [0.45, 0.8, 0], bodyColor: [0.45, 0.8, 0],
lcdColor: [1, 1, 1],
}, },
}, },
placement: 'top', placement: 'top',
createInstance: ({ room, options, root }) => { createInstance: ({ room, options, root }) => {
const applyBodyColor = () => {
const bodyMesh = root.getChildMeshes().find(m => m.name.includes('__X_BODY__')) as BABYLON.Mesh;
const bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
if (options.bodyStyle === 'color') {
const [r, g, b] = options.bodyColor;
bodyMaterial.albedoColor = new BABYLON.Color3(r, g, b);
} else {
}
};
return {
onInited: () => {
applyBodyColor();
const segmentMeshes = { const segmentMeshes = {
'1a': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_1A__')), '1a': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_1A__')),
'1b': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_1B__')), '1b': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_1B__')),
@@ -78,6 +67,29 @@ 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 bodyMaterial = bodyMesh.material as BABYLON.PBRMaterial;
if (options.bodyStyle === 'color') {
const [r, g, b] = options.bodyColor;
bodyMaterial.albedoColor = new BABYLON.Color3(r, g, b);
} else {
}
};
const applyLcdColor = () => {
const mat = segmentMeshes['1a'].material as BABYLON.PBRMaterial;
const [r, g, b] = options.lcdColor;
mat.emissiveColor = new BABYLON.Color3(r, g, b);
};
return {
onInited: () => {
applyBodyColor();
applyLcdColor();
room.intervalIds.push(window.setInterval(() => { room.intervalIds.push(window.setInterval(() => {
const onMeshes = get7segMeshesOfCurrentTime(segmentMeshes); const onMeshes = get7segMeshesOfCurrentTime(segmentMeshes);
@@ -93,6 +105,8 @@ export const tabletopDigitalClock = defineObject({
onOptionsUpdated: ([k, v]) => { onOptionsUpdated: ([k, v]) => {
if (k === 'bodyColor') { if (k === 'bodyColor') {
applyBodyColor(); applyBodyColor();
} else if (k === 'lcdColor') {
applyLcdColor();
} }
}, },
interactions: {}, interactions: {},