Skip to content

Commit

Permalink
FirstPersonControls: Derive from Controls. (#1183)
Browse files Browse the repository at this point in the history
  • Loading branch information
Methuselah96 authored Aug 25, 2024
1 parent e4913f5 commit 9b2209d
Showing 1 changed file with 82 additions and 11 deletions.
93 changes: 82 additions & 11 deletions types/three/examples/jsm/controls/FirstPersonControls.d.ts
Original file line number Diff line number Diff line change
@@ -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 };

0 comments on commit 9b2209d

Please sign in to comment.