UNPKG

@needle-tools/engine

Version:

Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in

29 lines 1.1 kB
import { FlyControls as ThreeFlyControls } from "three/examples/jsm/controls/FlyControls.js"; import { Camera } from "./Camera.js"; import { Behaviour, GameObject } from "./Component.js"; /** * @deprecated The FlyControls component is deprecated and will be removed in the future. */ export class FlyControls extends Behaviour { _controls = null; onEnable() { const cam = GameObject.getComponent(this.gameObject, Camera)?.threeCamera; if (!cam) { console.warn("FlyControls: Requires a Camera component on the same object as this component."); return; } this._controls = new ThreeFlyControls(cam, this.context.renderer.domElement); this._controls.rollSpeed = .5; this._controls.movementSpeed = 3; this._controls.dragToLook = true; } onDisable() { this._controls?.dispose(); this._controls = null; } update() { if (this._controls) this._controls.update(this.context.time.deltaTime); } } //# sourceMappingURL=FlyControls.js.map