mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-30 16:53:59 +02:00
rotation
This commit is contained in:
@@ -142,7 +142,7 @@ export class RoomEngine extends EventEmitter {
|
|||||||
forInstall: boolean;
|
forInstall: boolean;
|
||||||
mesh: BABYLON.TransformNode;
|
mesh: BABYLON.TransformNode;
|
||||||
originalDiffOfPosition: BABYLON.Vector3;
|
originalDiffOfPosition: BABYLON.Vector3;
|
||||||
originalDiffOfRotationY: number;
|
originalDiffOfRotation: BABYLON.Vector3;
|
||||||
distance: number;
|
distance: number;
|
||||||
rotation: number;
|
rotation: number;
|
||||||
ghost: BABYLON.AbstractMesh;
|
ghost: BABYLON.AbstractMesh;
|
||||||
@@ -497,7 +497,7 @@ export class RoomEngine extends EventEmitter {
|
|||||||
}
|
}
|
||||||
} else if (ev.code === 'KeyR') {
|
} else if (ev.code === 'KeyR') {
|
||||||
if (this.grabbingCtx != null) {
|
if (this.grabbingCtx != null) {
|
||||||
this.changeGrabbingRotationY(Math.PI / 8);
|
this.changeGrabbingRotation(Math.PI / 8);
|
||||||
}
|
}
|
||||||
} else if (ev.code === 'KeyQ') {
|
} else if (ev.code === 'KeyQ') {
|
||||||
if (this.isSitting) {
|
if (this.isSitting) {
|
||||||
@@ -660,7 +660,7 @@ export class RoomEngine extends EventEmitter {
|
|||||||
|
|
||||||
const dir = this.camera.getDirection(BABYLON.Axis.Z).scale(this.scene.useRightHandedSystem ? -1 : 1);
|
const dir = this.camera.getDirection(BABYLON.Axis.Z).scale(this.scene.useRightHandedSystem ? -1 : 1);
|
||||||
let newPos = this.camera.position.add(dir.scale(grabbing.distance)).add(grabbing.originalDiffOfPosition);
|
let newPos = this.camera.position.add(dir.scale(grabbing.distance)).add(grabbing.originalDiffOfPosition);
|
||||||
const newRotation = new BABYLON.Vector3(0, this.camera.rotation.y + grabbing.originalDiffOfRotationY + grabbing.rotation, 0);
|
const newRotation = new BABYLON.Vector3(0, this.camera.rotation.y + grabbing.originalDiffOfRotation.y + grabbing.rotation, 0);
|
||||||
grabbing.ghost.position = newPos.clone();
|
grabbing.ghost.position = newPos.clone();
|
||||||
grabbing.ghost.rotation = newRotation.clone();
|
grabbing.ghost.rotation = newRotation.clone();
|
||||||
|
|
||||||
@@ -690,6 +690,7 @@ export class RoomEngine extends EventEmitter {
|
|||||||
const pickedMeshNormal = hit.getNormal(true, true)!;
|
const pickedMeshNormal = hit.getNormal(true, true)!;
|
||||||
const targetRotationY = Math.atan2(pickedMeshNormal.x, pickedMeshNormal.z);
|
const targetRotationY = Math.atan2(pickedMeshNormal.x, pickedMeshNormal.z);
|
||||||
newRotation.y = targetRotationY;
|
newRotation.y = targetRotationY;
|
||||||
|
newRotation.z = grabbing.originalDiffOfRotation.z + grabbing.rotation;
|
||||||
newPos = hit.pickedPoint;
|
newPos = hit.pickedPoint;
|
||||||
stickyOtherObject = hit.pickedMesh.metadata?.objectId ?? null;
|
stickyOtherObject = hit.pickedMesh.metadata?.objectId ?? null;
|
||||||
|
|
||||||
@@ -1298,7 +1299,7 @@ export class RoomEngine extends EventEmitter {
|
|||||||
forInstall: false,
|
forInstall: false,
|
||||||
mesh: selectedObject,
|
mesh: selectedObject,
|
||||||
originalDiffOfPosition: selectedObject.position.subtract(this.camera.position.add(dir.scale(distance))),
|
originalDiffOfPosition: selectedObject.position.subtract(this.camera.position.add(dir.scale(distance))),
|
||||||
originalDiffOfRotationY: selectedObject.rotation.subtract(this.camera.rotation).y,
|
originalDiffOfRotation: selectedObject.rotation.subtract(this.camera.rotation),
|
||||||
distance: distance,
|
distance: distance,
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
ghost: ghost,
|
ghost: ghost,
|
||||||
@@ -1579,7 +1580,7 @@ export class RoomEngine extends EventEmitter {
|
|||||||
forInstall: true,
|
forInstall: true,
|
||||||
mesh: root,
|
mesh: root,
|
||||||
originalDiffOfPosition: new BABYLON.Vector3(0, 0, 0),
|
originalDiffOfPosition: new BABYLON.Vector3(0, 0, 0),
|
||||||
originalDiffOfRotationY: Math.PI,
|
originalDiffOfRotation: new BABYLON.Vector3(0, Math.PI, 0),
|
||||||
distance: distance,
|
distance: distance,
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
ghost: ghost,
|
ghost: ghost,
|
||||||
@@ -1760,7 +1761,7 @@ export class RoomEngine extends EventEmitter {
|
|||||||
if (this.grabbingCtx.distance < cm(5)) this.grabbingCtx.distance = cm(5);
|
if (this.grabbingCtx.distance < cm(5)) this.grabbingCtx.distance = cm(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
public changeGrabbingRotationY(delta: number) {
|
public changeGrabbingRotation(delta: number) {
|
||||||
if (this.grabbingCtx == null) return;
|
if (this.grabbingCtx == null) return;
|
||||||
this.grabbingCtx.rotation += delta;
|
this.grabbingCtx.rotation += delta;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user