diff --git a/src/camera.ts b/src/camera.ts index 5338a91..eb03e01 100644 --- a/src/camera.ts +++ b/src/camera.ts @@ -69,6 +69,8 @@ class Camera extends Element { sceneRadius = 5; + flySpeed = 5; + picker: Picker; workRenderTarget: RenderTarget; diff --git a/src/controllers.ts b/src/controllers.ts index a954c43..8b1ecec 100644 --- a/src/controllers.ts +++ b/src/controllers.ts @@ -192,7 +192,7 @@ class PointerController { const z = keys.ArrowDown - keys.ArrowUp; if (x || z) { - const factor = deltaTime * camera.distance * camera.sceneRadius * 20; + const factor = deltaTime * camera.flySpeed; const worldTransform = camera.entity.getWorldTransform(); const xAxis = worldTransform.getX().mulScalar(x * factor); const zAxis = worldTransform.getZ().mulScalar(z * factor); diff --git a/src/editor.ts b/src/editor.ts index 95b0927..eb0d6ff 100644 --- a/src/editor.ts +++ b/src/editor.ts @@ -474,6 +474,16 @@ const registerEditorEvents = (events: Events, editHistory: EditHistory, scene: S setSplatSize(value); }); + // camera fly speed + + const setFlySpeed = (value: number) => { + scene.camera.flySpeed = value; + }; + + events.on('camera.setFlySpeed', (value: number) => { + setFlySpeed(value); + }); + // outline selection let outlineSelection = false; diff --git a/src/ui/localization.ts b/src/ui/localization.ts index 51498a9..f0926bc 100644 --- a/src/ui/localization.ts +++ b/src/ui/localization.ts @@ -72,6 +72,7 @@ const localizeInit = () => { 'options.outline-selection': 'Umriss Selektion', 'options.show-grid': 'Raster anzeigen', 'options.show-bound': 'Objektbox anzeigen', + 'options.camera-fly-speed': 'Kamera Geschwindigkeit', // Camera panel 'camera': 'KAMERA POSEN', @@ -224,6 +225,7 @@ const localizeInit = () => { 'options.outline-selection': 'Outline Selection', 'options.show-grid': 'Show Grid', 'options.show-bound': 'Show Bound', + 'options.camera-fly-speed': 'Fly Speed', // Camera panel 'camera': 'CAMERA POSES', @@ -385,6 +387,7 @@ const localizeInit = () => { 'options.outline-selection': 'Contour de la sélection', 'options.show-grid': 'Afficher la grille', 'options.show-bound': 'Afficher limites', + 'options.camera-fly-speed': 'Vitesse de vol', // Camera panel 'camera': 'POSES DE LA CAMERA', @@ -537,6 +540,7 @@ const localizeInit = () => { 'options.outline-selection': '選択のアウトライン', 'options.show-grid': 'グリッド', 'options.show-bound': 'バウンディングボックス', + 'options.camera-fly-speed': 'カメラの移動速度', // Camera panel 'camera': 'カメラポーズ', @@ -689,6 +693,7 @@ const localizeInit = () => { 'options.outline-selection': '선택 윤곽선', 'options.show-grid': '그리드 표시', 'options.show-bound': '경계 표시', + 'options.camera-fly-speed': '카메라 이동 속도', // Camera panel 'camera': '카메라 포즈', @@ -841,6 +846,7 @@ const localizeInit = () => { 'options.outline-selection': '轮廓选择', 'options.show-grid': '显示网格', 'options.show-bound': '显示边界', + 'options.camera-fly-speed': '相机飞行速度', // Camera panel 'camera': '相机姿势', diff --git a/src/ui/view-panel.ts b/src/ui/view-panel.ts index 1f19f04..e12dcf8 100644 --- a/src/ui/view-panel.ts +++ b/src/ui/view-panel.ts @@ -151,6 +151,28 @@ class ViewPanel extends Container { centersSizeRow.append(centersSizeLabel); centersSizeRow.append(centersSizeSlider); + // camera fly speed + + const cameraFlySpeedRow = new Container({ + class: 'view-panel-row' + }); + + const cameraFlySpeedLabel = new Label({ + text: localize('options.camera-fly-speed'), + class: 'view-panel-row-label' + }); + + const cameraFlySpeedSlider = new SliderInput({ + class: 'view-panel-row-slider', + min: 0.1, + max: 30, + precision: 1, + value: 5 + }); + + cameraFlySpeedRow.append(cameraFlySpeedLabel); + cameraFlySpeedRow.append(cameraFlySpeedSlider); + // outline selection const outlineSelectionRow = new Container({ @@ -219,6 +241,7 @@ class ViewPanel extends Container { this.append(outlineSelectionRow); this.append(showGridRow); this.append(showBoundRow); + this.append(cameraFlySpeedRow); // handle panel visibility @@ -275,6 +298,16 @@ class ViewPanel extends Container { events.fire('camera.setMode', 'centers'); }); + // camera speed + + events.on('camera.flySpeed', (value: number) => { + cameraFlySpeedSlider.value = value; + }); + + cameraFlySpeedSlider.on('change', (value: number) => { + events.fire('camera.setFlySpeed', value); + }); + // outline selection events.on('view.outlineSelection', (value: boolean) => {