From db9d0090b78cd5462f99c28e1314dbd44533a9b9 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Tue, 21 Apr 2026 11:47:58 +0900 Subject: [PATCH] clean up --- packages/frontend/src/world/engine.ts | 2 +- packages/frontend/src/world/room/engine.ts | 2 +- packages/frontend/src/world/utility.ts | 113 --------------------- 3 files changed, 2 insertions(+), 115 deletions(-) diff --git a/packages/frontend/src/world/engine.ts b/packages/frontend/src/world/engine.ts index ef98ea9b5a..663134e8cb 100644 --- a/packages/frontend/src/world/engine.ts +++ b/packages/frontend/src/world/engine.ts @@ -8,7 +8,7 @@ import { AxesViewer } from '@babylonjs/core/Debug/axesViewer'; import { registerBuiltInLoaders } from '@babylonjs/loaders/dynamic'; import { EventEmitter } from 'eventemitter3'; import tinycolor from 'tinycolor2'; -import { HorizontalCameraKeyboardMoveInput, RecyvlingTextGrid, Timer, WORLD_SCALE, camelToKebab, cm, createPlaneUvMapper, normalizeUvToSquare, randomRange } from './utility.js'; +import { RecyvlingTextGrid, Timer, WORLD_SCALE, camelToKebab, cm, createPlaneUvMapper, normalizeUvToSquare, randomRange } from './utility.js'; import { TIME_MAP } from './utility.js'; import { genId } from '@/utility/id.js'; import { deepClone } from '@/utility/clone.js'; diff --git a/packages/frontend/src/world/room/engine.ts b/packages/frontend/src/world/room/engine.ts index 18391cfe27..d9f8ba0a04 100644 --- a/packages/frontend/src/world/room/engine.ts +++ b/packages/frontend/src/world/room/engine.ts @@ -14,7 +14,7 @@ import { registerBuiltInLoaders } from '@babylonjs/loaders/dynamic'; import { BoundingBoxRenderer } from '@babylonjs/core/Rendering/boundingBoxRenderer'; import { GridMaterial } from '@babylonjs/materials'; import { EventEmitter } from 'eventemitter3'; -import { TIME_MAP, scaleMorph, HorizontalCameraKeyboardMoveInput, camelToKebab, cm, WORLD_SCALE, getMeshesBoundingBox, Timer } from '../utility.js'; +import { TIME_MAP, scaleMorph, camelToKebab, cm, WORLD_SCALE, getMeshesBoundingBox, Timer } from '../utility.js'; import { getObjectDef } from './object-defs.js'; import { findMaterial, ModelManager, SYSTEM_HEYA_MESH_NAMES, SYSTEM_MESH_NAMES } from './utility.js'; import { SimpleHeyaManager } from './heya.js'; diff --git a/packages/frontend/src/world/utility.ts b/packages/frontend/src/world/utility.ts index bef7de736a..49c5a2996d 100644 --- a/packages/frontend/src/world/utility.ts +++ b/packages/frontend/src/world/utility.ts @@ -38,119 +38,6 @@ export const TIME_MAP = { 23: 2, } as const; -export class HorizontalCameraKeyboardMoveInput extends BABYLON.BaseCameraPointersInput { - public camera: BABYLON.FreeCamera; - private engine: BABYLON.AbstractEngine; - private scene: BABYLON.Scene; - preShift = false; - codes = []; - codesUp = ['KeyW']; - codesDown = ['KeyS']; - codesLeft = ['KeyA']; - codesRight = ['KeyD']; - onCanvasBlurObserver = null; - onKeyboardObserver = null; - public canMove = true; - private moveSpeed = 0.1; - - constructor(camera: BABYLON.UniversalCamera, moveSpeed = 0.1) { - super(); - this.camera = camera; - this.scene = this.camera.getScene(); - this.engine = this.scene.getEngine(); - this.moveSpeed = moveSpeed; - } - - attachControl() { - if (this.onCanvasBlurObserver) { - return; - } - - this.onCanvasBlurObserver = this.engine.onCanvasBlurObservable.add(() => { - this.codes = []; - }); - - this.onKeyboardObserver = this.scene.onKeyboardObservable.add(({ event, type }) => { - const { code, shiftKey } = event; - this.preShift = shiftKey; - - if (type === BABYLON.KeyboardEventTypes.KEYDOWN) { - if (this.codesUp.indexOf(code) >= 0 || - this.codesDown.indexOf(code) >= 0 || - this.codesLeft.indexOf(code) >= 0 || - this.codesRight.indexOf(code) >= 0) { - const index = this.codes.findIndex(v => v.code === code); - if (index < 0) { // 存在しなかったら追加する - this.codes.push({ code }); - } - } - } else { - if (this.codesUp.indexOf(code) >= 0 || - this.codesDown.indexOf(code) >= 0 || - this.codesLeft.indexOf(code) >= 0 || - this.codesRight.indexOf(code) >= 0) { - const index = this.codes.findIndex(v => v.code === code); - if (index >= 0) { // 存在したら削除する - this.codes.splice(index, 1); - } - } - } - }); - } - - detachControl() { - this.codes = []; - - if (this.onKeyboardObserver) this.scene.onKeyboardObservable.remove(this.onKeyboardObserver); - if (this.onCanvasBlurObserver) this.engine.onCanvasBlurObservable.remove(this.onCanvasBlurObserver); - this.onKeyboardObserver = null; - this.onCanvasBlurObserver = null; - } - - checkInputs() { - if (!this.onKeyboardObserver) { - return; - } - for (let index = 0; index < this.codes.length; index++) { - const { code } = this.codes[index]; - - const local = new BABYLON.Vector3(); - if (this.codesLeft.indexOf(code) >= 0) { - local.x += -1; - } else if (this.codesUp.indexOf(code) >= 0) { - local.z += this.scene.useRightHandedSystem ? -1 : 1; - } else if (this.codesRight.indexOf(code) >= 0) { - local.x += 1; - } else if (this.codesDown.indexOf(code) >= 0) { - local.z += this.scene.useRightHandedSystem ? 1 : -1; - } - - if (local.length() === 0) { - continue; - } - - const dir = this.camera.getDirection(local.normalize()); - dir.y = 0; - dir.normalize(); - const dashFactor = this.preShift ? 3 : 1; - const moveSpeed = this.moveSpeed * this.scene.getAnimationRatio(); - const move = dir.scale(moveSpeed * dashFactor); - - if (this.canMove) { - this.camera.cameraDirection.addInPlace(move); - } - } - } - - getClassName() { - return 'HorizontalCameraKeyboardMoveInput'; - } - - getSimpleName() { - return 'horizontalkeyboard'; - } -} - const nanasegNumberMap = [ ['a', 'b', 'c', 'd', 'e', 'f'], // 0 ['b', 'c'], // 1