mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-22 10:34:13 +02:00
fix
This commit is contained in:
@@ -1090,6 +1090,7 @@ export class RoomEngine extends EventEmitter<RoomEngineEvents> {
|
|||||||
options: args.options,
|
options: args.options,
|
||||||
model,
|
model,
|
||||||
id: args.id,
|
id: args.id,
|
||||||
|
timer: this.timer, // TODO: 家具が撤去された後も動作し続けるのをどうにかする
|
||||||
stickyMarkerMeshUpdated: (mesh) => {
|
stickyMarkerMeshUpdated: (mesh) => {
|
||||||
// TODO
|
// TODO
|
||||||
//// stickyな子の位置を更新
|
//// stickyな子の位置を更新
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
import * as BABYLON from '@babylonjs/core';
|
import * as BABYLON from '@babylonjs/core';
|
||||||
import type { RoomEngine } from './engine.js';
|
import type { RoomEngine } from './engine.js';
|
||||||
import type { ModelManager } from './utility.js';
|
import type { ModelManager } from './utility.js';
|
||||||
|
import type { Timer } from '../utility.js';
|
||||||
|
|
||||||
// babylonのドメイン知識は持たない
|
// babylonのドメイン知識は持たない
|
||||||
export type RoomStateObject<Options = any> = {
|
export type RoomStateObject<Options = any> = {
|
||||||
@@ -105,6 +106,7 @@ export type ObjectDef<OpSc extends OptionsSchema = OptionsSchema> = {
|
|||||||
options: Readonly<GetOptionsSchemaValues<OpSc>>;
|
options: Readonly<GetOptionsSchemaValues<OpSc>>;
|
||||||
model: ModelManager;
|
model: ModelManager;
|
||||||
id: string;
|
id: string;
|
||||||
|
timer: Timer;
|
||||||
stickyMarkerMeshUpdated?: (mesh: BABYLON.Mesh) => void;
|
stickyMarkerMeshUpdated?: (mesh: BABYLON.Mesh) => void;
|
||||||
}) => RoomObjectInstance<GetOptionsSchemaValues<OpSc>> | Promise<RoomObjectInstance<GetOptionsSchemaValues<OpSc>>>; // TODO: createInstanceをasyncにするのではなく、別にreadyみたいなものを返させる
|
}) => RoomObjectInstance<GetOptionsSchemaValues<OpSc>> | Promise<RoomObjectInstance<GetOptionsSchemaValues<OpSc>>>; // TODO: createInstanceをasyncにするのではなく、別にreadyみたいなものを返させる
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export const tabletopDigitalClock = defineObject({
|
|||||||
},
|
},
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
hasCollisions: false,
|
hasCollisions: false,
|
||||||
createInstance: ({ root, room, options, model, scene }) => {
|
createInstance: ({ root, room, options, model, scene, timer }) => {
|
||||||
const light = new BABYLON.SpotLight('', new BABYLON.Vector3(0, cm(3), cm(1)), new BABYLON.Vector3(0, 0, 1), Math.PI / 1, 2, scene, room?.lightContainer != null);
|
const light = new BABYLON.SpotLight('', new BABYLON.Vector3(0, cm(3), cm(1)), new BABYLON.Vector3(0, 0, 1), Math.PI / 1, 2, scene, room?.lightContainer != null);
|
||||||
light.parent = root;
|
light.parent = root;
|
||||||
light.intensity = 0.01 * WORLD_SCALE * WORLD_SCALE;
|
light.intensity = 0.01 * WORLD_SCALE * WORLD_SCALE;
|
||||||
@@ -100,7 +100,8 @@ export const tabletopDigitalClock = defineObject({
|
|||||||
applyBodyColor();
|
applyBodyColor();
|
||||||
applyLcdColor();
|
applyLcdColor();
|
||||||
|
|
||||||
room.timer.setInterval(() => {
|
// TODO: 家具が撤去された後も呼ばれ続けるのをどうにかする
|
||||||
|
timer.setInterval(() => {
|
||||||
const onMeshes = get7segMeshesOfCurrentTime(segmentMeshes);
|
const onMeshes = get7segMeshesOfCurrentTime(segmentMeshes);
|
||||||
|
|
||||||
for (const mesh of Object.values(segmentMeshes)) {
|
for (const mesh of Object.values(segmentMeshes)) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export const wallClock = defineObject({
|
|||||||
},
|
},
|
||||||
placement: 'side',
|
placement: 'side',
|
||||||
hasCollisions: false,
|
hasCollisions: false,
|
||||||
createInstance: ({ room, root, options, model }) => {
|
createInstance: ({ room, timer, options, model }) => {
|
||||||
const hourHand = model.findMesh('HandH');
|
const hourHand = model.findMesh('HandH');
|
||||||
const minuteHand = model.findMesh('HandM');
|
const minuteHand = model.findMesh('HandM');
|
||||||
|
|
||||||
@@ -39,7 +39,8 @@ export const wallClock = defineObject({
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
onInited: () => {
|
onInited: () => {
|
||||||
room.timer.setInterval(() => {
|
// TODO: 家具が撤去された後も呼ばれ続けるのをどうにかする
|
||||||
|
timer.setInterval(() => {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const hours = now.getHours() % 12;
|
const hours = now.getHours() % 12;
|
||||||
const minutes = now.getMinutes();
|
const minutes = now.getMinutes();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
import * as BABYLON from '@babylonjs/core';
|
import * as BABYLON from '@babylonjs/core';
|
||||||
import { registerBuiltInLoaders } from '@babylonjs/loaders/dynamic.js';
|
import { registerBuiltInLoaders } from '@babylonjs/loaders/dynamic.js';
|
||||||
import { GridMaterial } from '@babylonjs/materials';
|
import { GridMaterial } from '@babylonjs/materials';
|
||||||
import { camelToKebab, WORLD_SCALE, cm, getMeshesBoundingBox } from '../utility.js';
|
import { camelToKebab, WORLD_SCALE, cm, getMeshesBoundingBox, Timer } from '../utility.js';
|
||||||
import { getObjectDef } from './object-defs.js';
|
import { getObjectDef } from './object-defs.js';
|
||||||
import { SYSTEM_MESH_NAMES, ModelManager } from './utility.js';
|
import { SYSTEM_MESH_NAMES, ModelManager } from './utility.js';
|
||||||
import type { RoomObjectInstance } from './object.js';
|
import type { RoomObjectInstance } from './object.js';
|
||||||
@@ -32,6 +32,7 @@ export class RoomObjectPreviewEngine {
|
|||||||
private envMapIndoor: BABYLON.CubeTexture;
|
private envMapIndoor: BABYLON.CubeTexture;
|
||||||
private roomLight: BABYLON.SpotLight;
|
private roomLight: BABYLON.SpotLight;
|
||||||
private zGridPreviewPlane: BABYLON.Mesh;
|
private zGridPreviewPlane: BABYLON.Mesh;
|
||||||
|
private timerForEachObject: Timer | null = null;
|
||||||
private fps = 60;
|
private fps = 60;
|
||||||
|
|
||||||
constructor(options: {
|
constructor(options: {
|
||||||
@@ -219,6 +220,11 @@ export class RoomObjectPreviewEngine {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.timerForEachObject != null) {
|
||||||
|
this.timerForEachObject.dispose();
|
||||||
|
}
|
||||||
|
this.timerForEachObject = new Timer();
|
||||||
|
|
||||||
const objectInstance = await def.createInstance({
|
const objectInstance = await def.createInstance({
|
||||||
room: null,
|
room: null,
|
||||||
scene: this.scene,
|
scene: this.scene,
|
||||||
@@ -226,6 +232,7 @@ export class RoomObjectPreviewEngine {
|
|||||||
options: args.options,
|
options: args.options,
|
||||||
model,
|
model,
|
||||||
id: args.id,
|
id: args.id,
|
||||||
|
timer: this.timerForEachObject,
|
||||||
});
|
});
|
||||||
|
|
||||||
objectInstance.onInited?.();
|
objectInstance.onInited?.();
|
||||||
@@ -245,6 +252,9 @@ export class RoomObjectPreviewEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public destroy() {
|
public destroy() {
|
||||||
|
if (this.timerForEachObject != null) {
|
||||||
|
this.timerForEachObject.dispose();
|
||||||
|
}
|
||||||
this.engine.dispose();
|
this.engine.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user