mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-06-04 19:24:12 +02:00
Update tabletopDigitalClock.ts
This commit is contained in:
@@ -21,30 +21,19 @@ export const tabletopDigitalClock = defineObject({
|
||||
type: 'color',
|
||||
label: 'Body Color',
|
||||
},
|
||||
lcdColor: {
|
||||
type: 'color',
|
||||
label: 'LCD Color',
|
||||
},
|
||||
},
|
||||
default: {
|
||||
bodyStyle: 'color',
|
||||
bodyColor: [0.45, 0.8, 0],
|
||||
lcdColor: [1, 1, 1],
|
||||
},
|
||||
},
|
||||
placement: 'top',
|
||||
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 = {
|
||||
'1a': root.getChildMeshes().find(m => m.name.includes('__TIME_7SEG_1A__')),
|
||||
'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 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(() => {
|
||||
const onMeshes = get7segMeshesOfCurrentTime(segmentMeshes);
|
||||
|
||||
@@ -93,6 +105,8 @@ export const tabletopDigitalClock = defineObject({
|
||||
onOptionsUpdated: ([k, v]) => {
|
||||
if (k === 'bodyColor') {
|
||||
applyBodyColor();
|
||||
} else if (k === 'lcdColor') {
|
||||
applyLcdColor();
|
||||
}
|
||||
},
|
||||
interactions: {},
|
||||
|
||||
Reference in New Issue
Block a user