mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-29 23:25:01 +02:00
Update engine.ts
This commit is contained in:
@@ -242,6 +242,7 @@ export class RoomEngine {
|
|||||||
private intervalIds: number[] = [];
|
private intervalIds: number[] = [];
|
||||||
private objectMeshs: Map<string, BABYLON.AbstractMesh> = new Map();
|
private objectMeshs: Map<string, BABYLON.AbstractMesh> = new Map();
|
||||||
private grabbing: BABYLON.AbstractMesh | null = null;
|
private grabbing: BABYLON.AbstractMesh | null = null;
|
||||||
|
private grabbingStartOffset: BABYLON.Vector3 | null = null;
|
||||||
private grabbingStartDistance: number | null = null;
|
private grabbingStartDistance: number | null = null;
|
||||||
private grabbingGhost: BABYLON.AbstractMesh | null = null;
|
private grabbingGhost: BABYLON.AbstractMesh | null = null;
|
||||||
private highlightedObjectId: string | null = null;
|
private highlightedObjectId: string | null = null;
|
||||||
@@ -459,7 +460,7 @@ export class RoomEngine {
|
|||||||
|
|
||||||
private handleGrabbing() {
|
private handleGrabbing() {
|
||||||
const dir = this.camera.getDirection(BABYLON.Axis.Z);
|
const dir = this.camera.getDirection(BABYLON.Axis.Z);
|
||||||
this.grabbingGhost.position = this.camera.position.add(dir.scale(this.grabbingStartDistance));
|
this.grabbingGhost.position = this.camera.position.add(dir.scale(this.grabbingStartDistance)).add(this.grabbingStartOffset!);
|
||||||
|
|
||||||
const stickyObjectIds = Array.from(this.def.objects.filter(o => o.sticky === this.grabbing!.metadata.objectId)).map(o => o.id);
|
const stickyObjectIds = Array.from(this.def.objects.filter(o => o.sticky === this.grabbing!.metadata.objectId)).map(o => o.id);
|
||||||
|
|
||||||
@@ -630,6 +631,7 @@ export class RoomEngine {
|
|||||||
removeStickyParentRecursively(this.grabbing);
|
removeStickyParentRecursively(this.grabbing);
|
||||||
this.grabbing = null;
|
this.grabbing = null;
|
||||||
this.grabbingStartDistance = null;
|
this.grabbingStartDistance = null;
|
||||||
|
this.grabbingStartOffset = null;
|
||||||
if (this.grabbingGhost != null) {
|
if (this.grabbingGhost != null) {
|
||||||
this.grabbingGhost.dispose(false, true);
|
this.grabbingGhost.dispose(false, true);
|
||||||
this.grabbingGhost = null;
|
this.grabbingGhost = null;
|
||||||
@@ -638,8 +640,12 @@ export class RoomEngine {
|
|||||||
}
|
}
|
||||||
if (this.highlightedObjectId == null) return;
|
if (this.highlightedObjectId == null) return;
|
||||||
const highlightedObject = this.objectMeshs.get(this.highlightedObjectId)!;
|
const highlightedObject = this.objectMeshs.get(this.highlightedObjectId)!;
|
||||||
|
for (const om of highlightedObject.getChildMeshes()) {
|
||||||
|
om.renderOutline = false;
|
||||||
|
}
|
||||||
this.grabbing = highlightedObject;
|
this.grabbing = highlightedObject;
|
||||||
this.grabbingStartDistance = BABYLON.Vector3.Distance(this.camera.position, highlightedObject.position);
|
this.grabbingStartDistance = BABYLON.Vector3.Distance(this.camera.position, highlightedObject.position);
|
||||||
|
this.grabbingStartOffset = highlightedObject.position.subtract(this.camera.position.add(this.camera.getDirection(BABYLON.Axis.Z).scale(this.grabbingStartDistance)));
|
||||||
this.grabbingGhost = highlightedObject.clone('ghost', null, false);
|
this.grabbingGhost = highlightedObject.clone('ghost', null, false);
|
||||||
for (const m of this.grabbingGhost!.getChildMeshes()) {
|
for (const m of this.grabbingGhost!.getChildMeshes()) {
|
||||||
m.metadata = {};
|
m.metadata = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user