Skip to content

Commit

Permalink
deploy: be6f1ac
Browse files Browse the repository at this point in the history
  • Loading branch information
Byongho96 committed Dec 17, 2024
1 parent 90034b5 commit 21ebadd
Show file tree
Hide file tree
Showing 13 changed files with 5,458 additions and 0 deletions.
2,270 changes: 2,270 additions & 0 deletions dist/bundle.cjs.js

Large diffs are not rendered by default.

2,259 changes: 2,259 additions & 0 deletions dist/bundle.esm.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/bundle.esm.min.js

Large diffs are not rendered by default.

104 changes: 104 additions & 0 deletions dist/controls/FirstPersonKeyboardControls.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { Object3D } from 'three';
import { PhysicsControls, PhysicsOptions } from './base/PhysicsControls';
/**
* Actions that can be performed via keyboard input.
*/
type Actions = 'forward' | 'backward' | 'leftward' | 'rightward' | 'turnLeft' | 'turnRight' | 'turnUp' | 'turnDown' | 'jump' | 'accelerate';
/**
* Configuration for key mappings to actions.
*/
type ActionKeys = {
[K in Actions]?: string[];
};
/**
* Configuration options for camera control.
*/
type CameraOptions = {
enableZoom?: boolean;
zoomSpeed?: number;
};
/**
* Extended physics options specific to keyboard controls.
*/
type KeyboardPhysicsOptions = PhysicsOptions & {
eyeHeight?: number;
jumpForce?: number;
groundMoveSpeed?: number;
floatMoveSpeed?: number;
rotateSpeed?: number;
enableDiagonalMovement?: boolean;
enableAcceleration?: boolean;
accelerationFactor?: number;
};
type FirstPersonKeyboardControlsProps = {
object: Object3D;
domElement: HTMLElement | null;
worldObject: Object3D;
actionKeys?: ActionKeys;
physicsOptions?: KeyboardPhysicsOptions;
cameraOptions?: CameraOptions;
};
/**
* FirstPersonKeyboardControls class allows controlling a 3D object using the keyboard,
*/
declare class FirstPersonKeyboardControls extends PhysicsControls {
actionKeys: ActionKeys;
enableZoom: boolean;
zoomSpeed: number;
eyeHeight: number;
jumpForce: number;
groundMoveSpeed: number;
floatMoveSpeed: number;
rotateSpeed: number;
enableDiagonalMovement: boolean;
enableAcceleration: boolean;
accelerationFactor: number;
private _keyCount;
private _objectLocalDirection;
private _accumulatedDirection;
private _worldYDirection;
private onKeyDown;
private onKeyUp;
private onMouseWheel;
constructor({ object, domElement, worldObject, actionKeys, cameraOptions, physicsOptions, }: FirstPersonKeyboardControlsProps);
/**
* Retrieves the forward _objectWorldDirection vector of the object, ignoring the Y-axis.
* @returns A normalized Vector3 representing the forward _objectWorldDirection.
*/
private _getForwardVector;
/**
* Gets the side (right) direction vector based on the camera's orientation.
* @returns Normalized side vector.
*/
private _getSideVector;
private _accumulateDirection;
private _getMostRecentDirection;
/**
* Updates movement and rotation based on the current keyboard input.
* @param delta - The time delta for frame-independent movement.
*/
private updateControls;
/**
* Main update function that integrates controls, physics, camera, and animations.
* @param delta - The time delta for consistent updates.
*/
update(delta: number): void;
/**
* Connects the keyboard controls by adding event listeners.
*/
connect(): void;
/**
* Disconnects the keyboard controls by removing event listeners.
*/
disconnect(): void;
/**
* Disposes of the keyboard controls, cleaning up event listeners and animations.
*/
dispose(): void;
/** Handles keydown events, updating the key state. */
private _onKeyDown;
/** Handles keyup events, updating the key state. */
private _onKeyUp;
private _onMouseWheel;
}
export { FirstPersonKeyboardControls };
124 changes: 124 additions & 0 deletions dist/controls/FirstPersonMouseDragControls.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import { Object3D } from 'three';
import { PhysicsControls, PhysicsOptions } from './base/PhysicsControls';
/**
* Actions that can be performed via keyboard input.
*/
type Actions = 'forward' | 'backward' | 'leftward' | 'rightward' | 'jump' | 'accelerate';
/**
* Configuration for key mappings to actions.
*/
type ActionKeys = {
[K in Actions]?: string[];
};
/**
* Configuration options for camera control.
*/
type CameraOptions = {
enableZoom?: boolean;
zoomSpeed?: number;
};
/**
* Extended physics options specific to mouse drag controls.
*/
type MouseDragPhysicsOptions = PhysicsOptions & {
eyeHeight?: number;
jumpForce?: number;
groundMoveSpeed?: number;
floatMoveSpeed?: number;
rotateSpeed?: number;
enableDiagonalMovement?: boolean;
enableAcceleration?: boolean;
accelerationFactor?: number;
};
type FirstPersonMouseDragControlsProps = {
object: Object3D;
domElement: HTMLElement | null;
worldObject: Object3D;
actionKeys?: ActionKeys;
physicsOptions?: MouseDragPhysicsOptions;
cameraOptions?: CameraOptions;
};
/**
* FirstPersonMouseDragControls class allows controlling a 3D object using the mouse drag,
*/
declare class FirstPersonMouseDragControls extends PhysicsControls {
actionKeys: ActionKeys;
enableZoom: boolean;
zoomSpeed: number;
eyeHeight: number;
jumpForce: number;
groundMoveSpeed: number;
floatMoveSpeed: number;
rotateSpeed: number;
enableDiagonalMovement: boolean;
enableAcceleration: boolean;
accelerationFactor: number;
private _keyCount;
private _isMouseDown;
private _objectLocalDirection;
private _accumulatedDirection;
private _worldYDirection;
private onKeyDown;
private onKeyUp;
private onMouseDown;
private onMouseUp;
private onMouseMove;
private onMouseWheel;
/**
* Constructs a new FirstPersonMouseDragControls instance.
* @param object - The 3D object to control.
* @param domElement - The HTML element for event listeners (optional).
* @param worldObject - The world object used for physics collision.
* @param actionKeys - Key mappings for actions.
* @param cameraOptions - Configuration for the camera (optional).
* @param animationOptions - Configuration for animations (optional).
* @param physicsOptions - Physics configuration options (optional).
*/
constructor({ object, domElement, worldObject, actionKeys, cameraOptions, physicsOptions, }: FirstPersonMouseDragControlsProps);
/**
* Retrieves the forward _objectWorldDirection vector of the object, ignoring the Y-axis.
* @returns A normalized Vector3 representing the forward _objectWorldDirection.
*/
private _getForwardVector;
/**
* Gets the side (right) direction vector based on the camera's orientation.
* @returns Normalized side vector.
*/
private _getSideVector;
private _accumulateDirection;
private _getMostRecentDirection;
/**
* Updates movement based on physics and camera rotation.
* @param delta - The time delta for frame-independent movement.
*/
private updateControls;
/**
* Main update function that integrates controls, physics, camera, and animations.
* @param delta - The time delta for consistent updates.
*/
update(delta: number): void;
/**
* Connects the keyboard controls by adding event listeners.
*/
connect(): void;
/**
* Disconnects the keyboard controls by removing event listeners.
*/
disconnect(): void;
/**
* Disposes of the keyboard controls, cleaning up event listeners and animations.
*/
dispose(): void;
/** Handles keydown events, updating the key state. */
private _onKeyDown;
/** Handles keyup events, updating the key state. */
private _onKeyUp;
/** Handles mousedown events to set _isMouseDown flag. */
private _onMouseDown;
/** Handles mouseup events to reset _isMouseDown flag. */
private _onMouseUp;
/** Handles mousemove events to update camera angles when mouse is down. */
private _onMouseMove;
private _onMouseWheel;
}
export { FirstPersonMouseDragControls };
112 changes: 112 additions & 0 deletions dist/controls/FirstPersonPointerLockControls.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import { Object3D } from 'three';
import { PhysicsControls, PhysicsOptions } from './base/PhysicsControls';
/**
* Possible actions that can be mapped to keyboard inputs.
*/
type Actions = 'forward' | 'backward' | 'leftward' | 'rightward' | 'jump' | 'accelerate';
/**
* Configuration for key mappings to actions.
*/
type ActionKeys = {
[K in Actions]?: string[];
};
/**
* Configuration options for camera control.
*/
type CameraOptions = {
enableZoom?: boolean;
zoomSpeed?: number;
};
/**
* Extended physics options specific to pointer lock controls.
*/
type PointerLockPhysicsOptions = PhysicsOptions & {
eyeHeight?: number;
jumpForce?: number;
groundMoveSpeed?: number;
floatMoveSpeed?: number;
rotateSpeed?: number;
enableDiagonalMovement?: boolean;
enableAcceleration?: boolean;
accelerationFactor?: number;
};
type FirstPersonPointerLockControlsProps = {
object: Object3D;
domElement: HTMLElement | null;
worldObject: Object3D;
actionKeys?: ActionKeys;
physicsOptions?: PointerLockPhysicsOptions;
cameraOptions?: CameraOptions;
};
/**
* FirstPersonPointerLockControls class allows controlling a 3D object using the Pointer Lock API and mouse input.
*/
declare class FirstPersonPointerLockControls extends PhysicsControls {
actionKeys: ActionKeys;
enableZoom: boolean;
zoomSpeed: number;
eyeHeight: number;
jumpForce: number;
groundMoveSpeed: number;
floatMoveSpeed: number;
rotateSpeed: number;
enableDiagonalMovement: boolean;
enableAcceleration: boolean;
accelerationFactor: number;
private _keyCount;
private _objectLocalDirection;
private _accumulatedDirection;
private _worldYDirection;
private onKeyDown;
private onKeyUp;
private onMouseMove;
private onMouseDown;
private onMouseWheel;
constructor({ object, domElement, worldObject, actionKeys, cameraOptions, physicsOptions, }: FirstPersonPointerLockControlsProps);
/**
* Retrieves the forward _objectWorldDirection vector of the object, ignoring the Y-axis.
* @returns A normalized Vector3 representing the forward _objectWorldDirection.
*/
private _getForwardVector;
/**
* Gets the side (right) direction vector based on the camera's orientation.
* @returns Normalized side vector.
*/
private _getSideVector;
private _accumulateDirection;
private _getMostRecentDirection;
/**
* Updates movement based on physics and camera rotation.
* @param delta - The time delta for frame-independent movement.
*/
private updateControls;
/**
* Main update function that integrates controls, physics, and camera.
* @param delta - The time delta for consistent updates.
*/
update(delta: number): void;
/**
* Connects the pointer lock controls by adding event listeners.
*/
connect(): void;
/**
* Disconnects the pointer lock controls by removing event listeners.
*/
disconnect(): void;
/**
* Disposes of the pointer lock controls, cleaning up event listeners and animations.
*/
dispose(): void;
/** Handles keydown events, updating the key state. */
private _onKeyDown;
/** Handles keyup events, updating the key state. */
private _onKeyUp;
/**
* Requests pointer lock on the DOM element.
*/
private _onMouseDown;
/** Handles mousemove events to update camera angles with separate clamping for upward and downward movements. */
private _onMouseMove;
private _onMouseWheel;
}
export { FirstPersonPointerLockControls };
Loading

0 comments on commit 21ebadd

Please sign in to comment.