wallClock

This commit is contained in:
syuilo 2026-06-04 20:22:09 +09:00
commit ade652dd3e
7 changed files with 63 additions and 17 deletions

View file

@ -3969,6 +3969,8 @@ _miRoom:
wallClock: "壁掛け時計"
_wallClock:
frameMat: "フレームの素材"
faceMat: "文字盤の素材"
handsMat: "針の素材"
wallGlassPictureFrame: "ガラスの壁掛けフォトフレーム"
_wallGlassPictureFrame:
height: "高さ"

View file

@ -4,13 +4,13 @@
*/
import * as BABYLON from '@babylonjs/core/pure';
import { defineFuniture } from '../furniture.js';
import { wallClock_schema } from 'misskey-world/src/room/furnitures/wallClock.schema.js';
import { defineFuniture } from '../furniture.js';
export const wallClock = defineFuniture(wallClock_schema, {
createInstance: ({ sr, timer, options, model }) => {
const hourHand = model.findMesh('HandH');
const minuteHand = model.findMesh('HandM');
const hourHand = model.findMesh('__X_HAND_H__');
const minuteHand = model.findMesh('__X_HAND_M__');
const frameMaterial = model.findMaterial('__X_FRAME__');
@ -22,24 +22,46 @@ export const wallClock = defineFuniture(wallClock_schema, {
applyFrameMat();
const faceMaterial = model.findMaterial('__X_FACE__');
const applyFaceMat = () => {
faceMaterial.albedoColor = new BABYLON.Color3(options.faceMat.color[0], options.faceMat.color[1], options.faceMat.color[2]);
faceMaterial.roughness = options.faceMat.roughness;
faceMaterial.metallic = options.faceMat.metallic;
};
applyFaceMat();
const handsMaterial = model.findMaterial('__X_HAND__');
const applyHandsMat = () => {
handsMaterial.albedoColor = new BABYLON.Color3(options.handsMat.color[0], options.handsMat.color[1], options.handsMat.color[2]);
handsMaterial.roughness = options.handsMat.roughness;
handsMaterial.metallic = options.handsMat.metallic;
};
applyHandsMat();
model.bakeExcludeMeshes = [hourHand, minuteHand];
timer.setInterval(() => {
const now = new Date();
const hours = now.getHours() % 12;
const minutes = now.getMinutes();
const hAngle = -(hours / 12) * Math.PI * 2 - (minutes / 60) * (Math.PI * 2 / 12);
const mAngle = -(minutes / 60) * Math.PI * 2;
hourHand.rotation = new BABYLON.Vector3(0, 0, hAngle);
minuteHand.rotation = new BABYLON.Vector3(0, 0, mAngle);
sr.updateMesh([hourHand, minuteHand], false);
}, 1000);
return {
onInited: () => {
// TODO: 家具が撤去された後も呼ばれ続けるのをどうにかする
timer.setInterval(() => {
const now = new Date();
const hours = now.getHours() % 12;
const minutes = now.getMinutes();
const hAngle = -(hours / 12) * Math.PI * 2 - (minutes / 60) * (Math.PI * 2 / 12);
const mAngle = -(minutes / 60) * Math.PI * 2;
hourHand.rotation = new BABYLON.Vector3(0, 0, hAngle);
minuteHand.rotation = new BABYLON.Vector3(0, 0, mAngle);
sr.updateMesh([hourHand, minuteHand], false);
}, 1000);
},
onOptionsUpdated: ([k, v]) => {
applyFrameMat();
switch (k) {
case 'frameMat': applyFrameMat(); break;
case 'faceMat': applyFaceMat(); break;
case 'handsMat': applyHandsMat(); break;
}
},
interactions: {},
dispose: () => {},

View file

@ -13,5 +13,11 @@ export const wallClock_ui = defineFurnitureUi<typeof wallClock_schema>({
frameMat: {
label: i18n.ts._miRoom._furnitures._wallClock.frameMat,
},
faceMat: {
label: i18n.ts._miRoom._furnitures._wallClock.faceMat,
},
handsMat: {
label: i18n.ts._miRoom._furnitures._wallClock.handsMat,
},
},
});

View file

@ -14766,6 +14766,14 @@ export interface Locale extends ILocale {
*
*/
"frameMat": string;
/**
*
*/
"faceMat": string;
/**
*
*/
"handsMat": string;
};
/**
*

View file

@ -11,9 +11,17 @@ export const wallClock_schema = defineFurnitureSchema({
frameMat: {
type: 'material',
},
faceMat: {
type: 'material',
},
handsMat: {
type: 'material',
},
},
default: {
frameMat: { color: [0.71, 0.58, 0.39], roughness: 0.75, metallic: 0 },
faceMat: { color: [0.8, 0.8, 0.8], roughness: 0.5, metallic: 0 },
handsMat: { color: [0.033, 0.033, 0.033], roughness: 0.75, metallic: 0 },
},
},
placement: 'side',