From a77987ab287d31e494c63c2e2bb50833612a08a6 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Sun, 26 Apr 2026 13:58:33 +0900 Subject: [PATCH] Update engine.ts --- packages/frontend/src/world/room/engine.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/frontend/src/world/room/engine.ts b/packages/frontend/src/world/room/engine.ts index 780920bbb0..23cfedabf9 100644 --- a/packages/frontend/src/world/room/engine.ts +++ b/packages/frontend/src/world/room/engine.ts @@ -23,6 +23,8 @@ import type { HeyaManager, JapaneseHeyaOptions, SimpleHeyaOptions } from './heya import type { ObjectDef, RoomObjectInstance, RoomStateObject } from './object.js'; import { genId } from '@/utility/id.js'; import { deepClone } from '@/utility/clone.js'; +import { isTouchUsing } from '@/utility/touch.js'; +import { deviceKind } from '@/utility/device-kind.js'; const BAKE_TRANSFORM = false; // 実験的 const SNAPSHOT_RENDERING = true; // 実験的 @@ -287,8 +289,14 @@ export class RoomEngine extends EventEmitter { this.scene.collisionsEnabled = true; - this.camera = new BABYLON.UniversalCamera('camera', new BABYLON.Vector3(0, cm(130), cm(0)), this.scene); + const useVirtualJoystick = isTouchUsing && (deviceKind === 'smartphone' || deviceKind === 'tablet'); + + this.camera = useVirtualJoystick ? new BABYLON.VirtualJoysticksCamera('camera', new BABYLON.Vector3(0, cm(130), cm(0)), this.scene) : new BABYLON.UniversalCamera('camera', new BABYLON.Vector3(0, cm(130), cm(0)), this.scene); this.camera.attachControl(this.canvas); + if (useVirtualJoystick) { + (this.camera.inputs.attached.virtualJoystick as BABYLON.FreeCameraVirtualJoystickInput).getLeftJoystick().setJoystickSensibility(0.3); + (this.camera.inputs.attached.virtualJoystick as BABYLON.FreeCameraVirtualJoystickInput).getRightJoystick().setJoystickSensibility(0.025); + } this.camera.minZ = cm(1); this.camera.maxZ = RENDER_OUTDOOR_ENV ? cm(10000) : cm(1000); this.camera.fov = 1;