From cb1d9c38df8e2df080e7acf9d28f3c4154b27c20 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Tue, 10 Feb 2026 11:40:25 +0900 Subject: [PATCH] Update engine.ts --- packages/frontend/src/utility/room/engine.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/frontend/src/utility/room/engine.ts b/packages/frontend/src/utility/room/engine.ts index 912e28cae6..1ff2f2a040 100644 --- a/packages/frontend/src/utility/room/engine.ts +++ b/packages/frontend/src/utility/room/engine.ts @@ -244,6 +244,7 @@ export class RoomEngine { private grabbing: { mesh: BABYLON.AbstractMesh; startOffset: BABYLON.Vector3; + startRotationY: number; startDistance: number; ghost: BABYLON.AbstractMesh; } | null = null; @@ -465,6 +466,7 @@ export class RoomEngine { const dir = this.camera.getDirection(BABYLON.Axis.Z); this.grabbing.ghost.position = this.camera.position.add(dir.scale(this.grabbing.startDistance)).add(this.grabbing.startOffset); + this.grabbing.ghost.rotation = new BABYLON.Vector3(0, this.camera.rotation.y + this.grabbing.startRotationY, 0); const stickyObjectIds = Array.from(this.def.objects.filter(o => o.sticky === this.grabbing.mesh.metadata.objectId)).map(o => o.id); @@ -529,6 +531,8 @@ export class RoomEngine { //this.grabbing.mesh.position.z = Math.min(Math.max(this.grabbing.position.z, -(this.ROOM_SIZE / 2)), (this.ROOM_SIZE / 2)); this.grabbing.mesh.position.y = y; + this.grabbing.mesh.rotation = this.grabbing.ghost.rotation.clone(); + const ray = new BABYLON.Ray(this.camera.position, this.camera.getDirection(BABYLON.Axis.Z), 1000/*cm*/); const hit = this.scene.pickWithRay(ray, (m) => m.name.startsWith('_COLLISION_WALL_'))!; if (hit.pickedMesh != null) { @@ -669,6 +673,7 @@ export class RoomEngine { this.grabbing = { mesh: highlightedObject, startOffset: highlightedObject.position.subtract(this.camera.position.add(this.camera.getDirection(BABYLON.Axis.Z).scale(startDistance))), + startRotationY: highlightedObject.rotation.subtract(this.camera.rotation).y, startDistance: startDistance, ghost: ghost, };