mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-06-12 03:34:12 +02:00
timer
This commit is contained in:
@@ -14,7 +14,7 @@ import { registerBuiltInLoaders } from '@babylonjs/loaders/dynamic';
|
||||
import { BoundingBoxRenderer } from '@babylonjs/core/Rendering/boundingBoxRenderer';
|
||||
import { GridMaterial } from '@babylonjs/materials';
|
||||
import { EventEmitter } from 'eventemitter3';
|
||||
import { TIME_MAP, scaleMorph, HorizontalCameraKeyboardMoveInput, camelToKebab, cm, WORLD_SCALE, getMeshesBoundingBox } from '../utility.js';
|
||||
import { TIME_MAP, scaleMorph, HorizontalCameraKeyboardMoveInput, camelToKebab, cm, WORLD_SCALE, getMeshesBoundingBox, Timer } from '../utility.js';
|
||||
import { getObjectDef } from './object-defs.js';
|
||||
import { findMaterial, ModelManager, SYSTEM_MESH_NAMES } from './utility.js';
|
||||
import type { ObjectDef, RoomObjectInstance, RoomStateObject } from './object.js';
|
||||
@@ -137,8 +137,6 @@ export class RoomEngine extends EventEmitter<RoomEngineEvents> {
|
||||
private shadowGeneratorForRoomLight: BABYLON.ShadowGenerator;
|
||||
private shadowGeneratorForSunLight: BABYLON.ShadowGenerator;
|
||||
public camera: BABYLON.UniversalCamera;
|
||||
public intervalIds: number[] = [];
|
||||
public timeoutIds: number[] = [];
|
||||
public objectEntities: Map<string, {
|
||||
rootMesh: BABYLON.Mesh;
|
||||
instance: RoomObjectInstance<any>;
|
||||
@@ -207,6 +205,7 @@ export class RoomEngine extends EventEmitter<RoomEngineEvents> {
|
||||
private zGridPreviewPlane: BABYLON.Mesh;
|
||||
private selectionOutlineLayer: BABYLON.SelectionOutlineLayer;
|
||||
public sr: BABYLON.SnapshotRenderingHelper;
|
||||
public timer: Timer = new Timer();
|
||||
|
||||
private _isEditMode = false;
|
||||
get isEditMode() {
|
||||
@@ -1267,12 +1266,10 @@ export class RoomEngine extends EventEmitter<RoomEngineEvents> {
|
||||
},
|
||||
};
|
||||
|
||||
const intervalId = setInterval(() => {
|
||||
this.timer.setInterval(() => {
|
||||
this.handleGrabbing();
|
||||
}, 10);
|
||||
|
||||
this.intervalIds.push(intervalId);
|
||||
|
||||
this.playSfxUrl('/client-assets/room/sfx/grab.mp3', {
|
||||
volume: 1,
|
||||
playbackRate: 1,
|
||||
@@ -1479,12 +1476,10 @@ export class RoomEngine extends EventEmitter<RoomEngineEvents> {
|
||||
},
|
||||
};
|
||||
|
||||
const intervalId = setInterval(() => {
|
||||
this.timer.setInterval(() => {
|
||||
this.handleGrabbing();
|
||||
}, 10);
|
||||
|
||||
this.intervalIds.push(intervalId);
|
||||
|
||||
this.playSfxUrl('/client-assets/room/sfx/grab.mp3', {
|
||||
volume: 1,
|
||||
playbackRate: 1,
|
||||
@@ -1614,14 +1609,7 @@ export class RoomEngine extends EventEmitter<RoomEngineEvents> {
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
for (const id of this.intervalIds) {
|
||||
window.clearInterval(id);
|
||||
}
|
||||
for (const id of this.timeoutIds) {
|
||||
window.clearTimeout(id);
|
||||
}
|
||||
this.intervalIds = [];
|
||||
this.timeoutIds = [];
|
||||
this.timer.dispose();
|
||||
this.engine.dispose();
|
||||
this.disposed = true;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ export const tabletopDigitalClock = defineObject({
|
||||
applyBodyColor();
|
||||
applyLcdColor();
|
||||
|
||||
room.intervalIds.push(setInterval(() => {
|
||||
room.timer.setInterval(() => {
|
||||
const onMeshes = get7segMeshesOfCurrentTime(segmentMeshes);
|
||||
|
||||
for (const mesh of Object.values(segmentMeshes)) {
|
||||
@@ -118,7 +118,7 @@ export const tabletopDigitalClock = defineObject({
|
||||
}
|
||||
|
||||
room?.sr.updateMesh([...Object.values(segmentMeshes), ...colonMeshes]);
|
||||
}, 1000));
|
||||
}, 1000);
|
||||
},
|
||||
onOptionsUpdated: ([k, v]) => {
|
||||
if (k === 'bodyColor') {
|
||||
|
||||
@@ -39,7 +39,7 @@ export const wallClock = defineObject({
|
||||
|
||||
return {
|
||||
onInited: () => {
|
||||
room.intervalIds.push(setInterval(() => {
|
||||
room.timer.setInterval(() => {
|
||||
const now = new Date();
|
||||
const hours = now.getHours() % 12;
|
||||
const minutes = now.getMinutes();
|
||||
@@ -48,7 +48,7 @@ export const wallClock = defineObject({
|
||||
hourHand.rotation = new BABYLON.Vector3(0, 0, hAngle);
|
||||
minuteHand.rotation = new BABYLON.Vector3(0, 0, mAngle);
|
||||
room?.sr.updateMesh([hourHand, minuteHand]);
|
||||
}, 1000));
|
||||
}, 1000);
|
||||
},
|
||||
onOptionsUpdated: ([k, v]) => {
|
||||
applyFrameColor();
|
||||
|
||||
@@ -146,11 +146,9 @@ export function initTv(room: RoomEngine, screenMesh: BABYLON.Mesh) {
|
||||
uvs[uvIndexes[3] + 1] = dy;
|
||||
screenMesh.updateVerticesData(BABYLON.VertexBuffer.UVKind, uvs);
|
||||
|
||||
const timeoutId = window.setTimeout(() => {
|
||||
room.timeoutIds = room.timeoutIds.filter(id => id !== timeoutId);
|
||||
room.timer.setTimeout(() => {
|
||||
applyTvTexture((tlIndex + 1) % tvProgram.timeline.length);
|
||||
}, duration);
|
||||
room.timeoutIds.push(timeoutId);
|
||||
};
|
||||
|
||||
applyTvTexture(0);
|
||||
|
||||
Reference in New Issue
Block a user