Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlyControls: Derive from Controls. #1182

Merged
merged 2 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion types/three/examples/jsm/controls/Controls.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ declare abstract class Controls<TEventMap extends {}> extends EventDispatcher<TE
/**
* Controls should implement this method if they have to update their internal state per simulation step.
*/
update(): void;
update(delta: number): void;
}

export { Controls };
47 changes: 36 additions & 11 deletions types/three/examples/jsm/controls/FlyControls.d.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,45 @@
import { Camera, EventDispatcher } from "three";
import { Camera } from "three";
import { Controls } from "./Controls.js";

export interface FlyControlsEventMap {
/**
* Fires when the camera has been transformed by the controls.
*/
change: {};
}

export class FlyControls extends EventDispatcher<FlyControlsEventMap> {
constructor(object: Camera, domElement?: HTMLElement);

autoForward: boolean;
domElement: HTMLElement | Document;
dragToLook: boolean;
enabled: boolean;
/**
* {@link FlyControls} enables a navigation similar to fly modes in DCC tools like Blender. You can arbitrarily
* transform the camera in 3D space without any limitations (e.g. focus on a specific target).
*/
declare class FlyControls extends Controls<FlyControlsEventMap> {
/**
* The movement speed. Default is `1`.
*/
movementSpeed: number;
object: Camera;

/**
* The rotation speed. Default is `0.005`.
*/
rollSpeed: number;

dispose(): void;
update(delta: number): void;
/**
* If set to `true`, you can only look around by performing a drag interaction. Default is `false`.
*/
dragToLook: boolean;

/**
* If set to `true`, the camera automatically moves forward (and does not stop) when initially translated. Default
* is `false`.
*/
autoForward: boolean;

/**
* Creates a new instance of {@link FlyControls}.
* @param object The camera to be controlled.
* @param domElement The HTML element used for event listeners.
*/
constructor(object: Camera, domElement?: HTMLElement | null);
}

export { FlyControls };
Loading