From 9b2209dbd1866c749956659dcfa3c120ea25e73d Mon Sep 17 00:00:00 2001 From: Nathan Bierema Date: Sun, 25 Aug 2024 13:00:56 -0400 Subject: [PATCH] FirstPersonControls: Derive from Controls. (#1183) --- .../jsm/controls/FirstPersonControls.d.ts | 93 ++++++++++++++++--- 1 file changed, 82 insertions(+), 11 deletions(-) diff --git a/types/three/examples/jsm/controls/FirstPersonControls.d.ts b/types/three/examples/jsm/controls/FirstPersonControls.d.ts index 130b4bcf6..e85c978f7 100644 --- a/types/three/examples/jsm/controls/FirstPersonControls.d.ts +++ b/types/three/examples/jsm/controls/FirstPersonControls.d.ts @@ -1,31 +1,102 @@ import { Camera, Vector3 } from "three"; +import { Controls } from "./Controls.js"; -export class FirstPersonControls { - constructor(object: Camera, domElement?: HTMLElement); - - object: Camera; - domElement: HTMLElement | Document; - - enabled: boolean; +/** + * This class is an alternative implementation of {@link FlyControls}. + */ +declare class FirstPersonControls extends Controls<{}> { + /** + * The movement speed. Default is *1*. + */ movementSpeed: number; + + /** + * The look around speed. Default is `0.005`. + */ lookSpeed: number; + + /** + * Whether or not it's possible to vertically look around. Default is `true`. + */ lookVertical: boolean; + + /** + * Whether or not the camera is automatically moved forward. Default is `false`. + */ autoForward: boolean; + + /** + * Whether or not it's possible to look around. Default is `true`. + */ activeLook: boolean; + + /** + * Whether or not the camera's height influences the forward movement speed. Default is `false`. + * Use the properties {@link .heightCoef}, {@link .heightMin} and {@link .heightMax} for configuration + */ heightSpeed: boolean; + + /** + * Determines how much faster the camera moves when it's y-component is near {@link .heightMax}. Default is *1*. + */ heightCoef: number; + + /** + * Lower camera height limit used for movement speed adjustment. Default is *0*. + */ heightMin: number; + + /** + * Upper camera height limit used for movement speed adjustment. Default is *1*. + */ heightMax: number; + + /** + * Whether or not looking around is vertically constrained by [{@link .verticalMin}, {@link .verticalMax}]. Default + * is `false`. + */ constrainVertical: boolean; + + /** + * How far you can vertically look around, lower limit. Range is 0 to Math.PI radians. Default is *0*. + */ verticalMin: number; + + /** + * How far you can vertically look around, upper limit. Range is 0 to Math.PI radians. Default is `Math.PI`. + */ verticalMax: number; + + /** + * Whether or not the mouse is pressed down. Read-only property. + */ mouseDragOn: boolean; + /** + * Creates a new instance of {@link FirstPersonControls}. + * @param object The camera to be controlled. + * @param domElement The HTML element used for event listeners. + */ + constructor(object: Camera, domElement?: HTMLElement); + + /** + * Should be called if the application window is resized. + */ handleResize(): void; - lookAt(x: Vector3): this; - lookAt(x: number, y: number, z: number): this; + /** + * Ensures the controls orient the camera towards the defined target position. + * @param vector A vector representing the target position. + */ + lookAt(vector: Vector3): this; - update(delta: number): this; - dispose(): void; + /** + * Ensures the controls orient the camera towards the defined target position. + * @param x The x component of the world space position. + * @param y The y component of the world space position. + * @param z The z component of the world space position. + */ + lookAt(x: number, y: number, z: number): this; } + +export { FirstPersonControls };