mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-15 10:25:50 +02:00
wip
This commit is contained in:
@@ -1202,6 +1202,7 @@ export class RoomEngine extends EventEmitter {
|
||||
const dir = this.camera.getDirection(BABYLON.Axis.Z).scale(this.scene.useRightHandedSystem ? -1 : 1);
|
||||
|
||||
let sticky: string | null;
|
||||
let grabbingEnded = false;
|
||||
|
||||
this.grabbingCtx = {
|
||||
objectId: selectedObject.metadata.objectId,
|
||||
@@ -1218,6 +1219,7 @@ export class RoomEngine extends EventEmitter {
|
||||
sticky = info.sticky;
|
||||
},
|
||||
onCancel: () => {
|
||||
grabbingEnded = true;
|
||||
this.sr.disableSnapshotRendering();
|
||||
selectedObject.position = initialPosition.clone();
|
||||
selectedObject.rotation = initialRotation.clone();
|
||||
@@ -1236,6 +1238,7 @@ export class RoomEngine extends EventEmitter {
|
||||
this.sr.enableSnapshotRendering();
|
||||
},
|
||||
onDone: () => { // todo: sticky状態などを引数でもらうようにしたい
|
||||
grabbingEnded = true;
|
||||
this.putParticleSystem.emitter = selectedObject.position.clone();
|
||||
this.putParticleSystem.start();
|
||||
|
||||
@@ -1304,7 +1307,11 @@ export class RoomEngine extends EventEmitter {
|
||||
|
||||
this.sr.enableSnapshotRendering();
|
||||
|
||||
this.timer.setInterval(() => {
|
||||
const stopHandleGrabbing = this.timer.setInterval(() => {
|
||||
if (grabbingEnded) {
|
||||
stopHandleGrabbing();
|
||||
return;
|
||||
}
|
||||
this.handleGrabbing();
|
||||
}, 10);
|
||||
|
||||
@@ -1437,6 +1444,7 @@ export class RoomEngine extends EventEmitter {
|
||||
const ghost = this.createGhost(root);
|
||||
|
||||
let sticky: string | null;
|
||||
let grabbingEnded = false;
|
||||
|
||||
this.grabbingCtx = {
|
||||
objectId: id,
|
||||
@@ -1453,9 +1461,12 @@ export class RoomEngine extends EventEmitter {
|
||||
sticky = info.sticky;
|
||||
},
|
||||
onCancel: () => {
|
||||
grabbingEnded = true;
|
||||
// todo
|
||||
},
|
||||
onDone: () => { // todo: sticky状態などを引数でもらうようにしたい
|
||||
grabbingEnded = true;
|
||||
|
||||
if (def.hasCollisions) {
|
||||
enableObjectCollision(root.getChildMeshes());
|
||||
}
|
||||
@@ -1511,7 +1522,11 @@ export class RoomEngine extends EventEmitter {
|
||||
this.gridPlane.isVisible = true;
|
||||
this.sr.enableSnapshotRendering();
|
||||
|
||||
this.timer.setInterval(() => {
|
||||
const stopHandleGrabbing = this.timer.setInterval(() => {
|
||||
if (grabbingEnded) {
|
||||
stopHandleGrabbing();
|
||||
return;
|
||||
}
|
||||
this.handleGrabbing();
|
||||
}, 10);
|
||||
|
||||
|
||||
@@ -569,6 +569,7 @@ export class Timer {
|
||||
callback();
|
||||
}, ms);
|
||||
this.timeoutIds.push(id);
|
||||
return () => this.clearTimeout(id);
|
||||
}
|
||||
|
||||
public setInterval(callback: () => void, ms: number, signal?: AbortSignal) {
|
||||
@@ -578,10 +579,24 @@ export class Timer {
|
||||
this.intervalIds.push(id);
|
||||
if (signal != null) {
|
||||
signal.addEventListener('abort', () => {
|
||||
clearInterval(id);
|
||||
this.intervalIds = this.intervalIds.filter(i => i !== id);
|
||||
this.clearInterval(id);
|
||||
});
|
||||
}
|
||||
return () => this.clearInterval(id);
|
||||
}
|
||||
|
||||
private clearTimeout(id: number) {
|
||||
// workerで実行される可能性がある
|
||||
// eslint-disable-next-line no-restricted-globals
|
||||
clearTimeout(id);
|
||||
this.timeoutIds = this.timeoutIds.filter(i => i !== id);
|
||||
}
|
||||
|
||||
private clearInterval(id: number) {
|
||||
// workerで実行される可能性がある
|
||||
// eslint-disable-next-line no-restricted-globals
|
||||
clearInterval(id);
|
||||
this.intervalIds = this.intervalIds.filter(i => i !== id);
|
||||
}
|
||||
|
||||
public dispose() {
|
||||
|
||||
Reference in New Issue
Block a user