toaimin-indie-engine 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/cli/bin.cjs +99 -0
- package/dist/audio/AudioBus.d.ts +30 -0
- package/dist/audio/AudioBus.d.ts.map +1 -0
- package/dist/audio/AudioMock.d.ts +112 -0
- package/dist/audio/AudioMock.d.ts.map +1 -0
- package/dist/audio/ProceduralAudio.d.ts +48 -0
- package/dist/audio/ProceduralAudio.d.ts.map +1 -0
- package/dist/audio/SoundManager.d.ts +73 -0
- package/dist/audio/SoundManager.d.ts.map +1 -0
- package/dist/audio/VoicePool.d.ts +26 -0
- package/dist/audio/VoicePool.d.ts.map +1 -0
- package/dist/audio/index.d.ts +7 -0
- package/dist/audio/index.d.ts.map +1 -0
- package/dist/audio/types.d.ts +87 -0
- package/dist/audio/types.d.ts.map +1 -0
- package/dist/core/EventEmitter.d.ts +64 -0
- package/dist/core/EventEmitter.d.ts.map +1 -0
- package/dist/core/Game.d.ts +248 -0
- package/dist/core/Game.d.ts.map +1 -0
- package/dist/core/GameLoop.d.ts +128 -0
- package/dist/core/GameLoop.d.ts.map +1 -0
- package/dist/core/Time.d.ts +73 -0
- package/dist/core/Time.d.ts.map +1 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/entity/Component.d.ts +31 -0
- package/dist/entity/Component.d.ts.map +1 -0
- package/dist/entity/Entity.d.ts +61 -0
- package/dist/entity/Entity.d.ts.map +1 -0
- package/dist/entity/EntityManager.d.ts +46 -0
- package/dist/entity/EntityManager.d.ts.map +1 -0
- package/dist/entity/components/ColliderComponent.d.ts +47 -0
- package/dist/entity/components/ColliderComponent.d.ts.map +1 -0
- package/dist/entity/components/RigidBodyComponent.d.ts +38 -0
- package/dist/entity/components/RigidBodyComponent.d.ts.map +1 -0
- package/dist/entity/components/ScriptComponent.d.ts +32 -0
- package/dist/entity/components/ScriptComponent.d.ts.map +1 -0
- package/dist/entity/components/ShapeComponent.d.ts +50 -0
- package/dist/entity/components/ShapeComponent.d.ts.map +1 -0
- package/dist/entity/components/SpriteComponent.d.ts +31 -0
- package/dist/entity/components/SpriteComponent.d.ts.map +1 -0
- package/dist/entity/components/index.d.ts +6 -0
- package/dist/entity/components/index.d.ts.map +1 -0
- package/dist/entity/index.d.ts +5 -0
- package/dist/entity/index.d.ts.map +1 -0
- package/dist/index.cjs +4 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6326 -0
- package/dist/index.js.map +1 -0
- package/dist/input/ActionMap.d.ts +91 -0
- package/dist/input/ActionMap.d.ts.map +1 -0
- package/dist/input/InputManager.d.ts +102 -0
- package/dist/input/InputManager.d.ts.map +1 -0
- package/dist/input/Pointer.d.ts +115 -0
- package/dist/input/Pointer.d.ts.map +1 -0
- package/dist/input/VirtualJoystick.d.ts +79 -0
- package/dist/input/VirtualJoystick.d.ts.map +1 -0
- package/dist/input/index.d.ts +5 -0
- package/dist/input/index.d.ts.map +1 -0
- package/dist/math/Circle.d.ts +39 -0
- package/dist/math/Circle.d.ts.map +1 -0
- package/dist/math/Color.d.ts +58 -0
- package/dist/math/Color.d.ts.map +1 -0
- package/dist/math/MathUtils.d.ts +82 -0
- package/dist/math/MathUtils.d.ts.map +1 -0
- package/dist/math/Matrix2D.d.ts +97 -0
- package/dist/math/Matrix2D.d.ts.map +1 -0
- package/dist/math/Rect.d.ts +54 -0
- package/dist/math/Rect.d.ts.map +1 -0
- package/dist/math/Transform2D.d.ts +47 -0
- package/dist/math/Transform2D.d.ts.map +1 -0
- package/dist/math/Vector2.d.ts +89 -0
- package/dist/math/Vector2.d.ts.map +1 -0
- package/dist/math/index.d.ts +8 -0
- package/dist/math/index.d.ts.map +1 -0
- package/dist/physics/BoxCollider2D.d.ts +38 -0
- package/dist/physics/BoxCollider2D.d.ts.map +1 -0
- package/dist/physics/CircleCollider2D.d.ts +27 -0
- package/dist/physics/CircleCollider2D.d.ts.map +1 -0
- package/dist/physics/Collider2D.d.ts +79 -0
- package/dist/physics/Collider2D.d.ts.map +1 -0
- package/dist/physics/CollisionFSM.d.ts +84 -0
- package/dist/physics/CollisionFSM.d.ts.map +1 -0
- package/dist/physics/ContactSolver.d.ts +58 -0
- package/dist/physics/ContactSolver.d.ts.map +1 -0
- package/dist/physics/Narrowphase.d.ts +25 -0
- package/dist/physics/Narrowphase.d.ts.map +1 -0
- package/dist/physics/PhysicsWorld2D.d.ts +75 -0
- package/dist/physics/PhysicsWorld2D.d.ts.map +1 -0
- package/dist/physics/Raycast.d.ts +38 -0
- package/dist/physics/Raycast.d.ts.map +1 -0
- package/dist/physics/RigidBody2D.d.ts +118 -0
- package/dist/physics/RigidBody2D.d.ts.map +1 -0
- package/dist/physics/SpatialGrid.d.ts +78 -0
- package/dist/physics/SpatialGrid.d.ts.map +1 -0
- package/dist/physics/index.d.ts +14 -0
- package/dist/physics/index.d.ts.map +1 -0
- package/dist/rendering/Animation.d.ts +62 -0
- package/dist/rendering/Animation.d.ts.map +1 -0
- package/dist/rendering/AssetLoader.d.ts +35 -0
- package/dist/rendering/AssetLoader.d.ts.map +1 -0
- package/dist/rendering/Camera2D.d.ts +109 -0
- package/dist/rendering/Camera2D.d.ts.map +1 -0
- package/dist/rendering/CanvasContext.d.ts +80 -0
- package/dist/rendering/CanvasContext.d.ts.map +1 -0
- package/dist/rendering/CanvasMock.d.ts +163 -0
- package/dist/rendering/CanvasMock.d.ts.map +1 -0
- package/dist/rendering/ParticleSystem.d.ts +103 -0
- package/dist/rendering/ParticleSystem.d.ts.map +1 -0
- package/dist/rendering/Renderer.d.ts +98 -0
- package/dist/rendering/Renderer.d.ts.map +1 -0
- package/dist/rendering/Shapes.d.ts +24 -0
- package/dist/rendering/Shapes.d.ts.map +1 -0
- package/dist/rendering/Sprite.d.ts +74 -0
- package/dist/rendering/Sprite.d.ts.map +1 -0
- package/dist/rendering/SpriteSheet.d.ts +22 -0
- package/dist/rendering/SpriteSheet.d.ts.map +1 -0
- package/dist/rendering/index.d.ts +11 -0
- package/dist/rendering/index.d.ts.map +1 -0
- package/dist/scene/Blackboard.d.ts +81 -0
- package/dist/scene/Blackboard.d.ts.map +1 -0
- package/dist/scene/Scene.d.ts +160 -0
- package/dist/scene/Scene.d.ts.map +1 -0
- package/dist/scene/SceneManager.d.ts +142 -0
- package/dist/scene/SceneManager.d.ts.map +1 -0
- package/dist/scene/SceneTransition.d.ts +118 -0
- package/dist/scene/SceneTransition.d.ts.map +1 -0
- package/dist/scene/index.d.ts +5 -0
- package/dist/scene/index.d.ts.map +1 -0
- package/dist/ui/UIAnchor.d.ts +31 -0
- package/dist/ui/UIAnchor.d.ts.map +1 -0
- package/dist/ui/UIButton.d.ts +48 -0
- package/dist/ui/UIButton.d.ts.map +1 -0
- package/dist/ui/UIElement.d.ts +108 -0
- package/dist/ui/UIElement.d.ts.map +1 -0
- package/dist/ui/UILabel.d.ts +54 -0
- package/dist/ui/UILabel.d.ts.map +1 -0
- package/dist/ui/UIManager.d.ts +41 -0
- package/dist/ui/UIManager.d.ts.map +1 -0
- package/dist/ui/UIPanel.d.ts +36 -0
- package/dist/ui/UIPanel.d.ts.map +1 -0
- package/dist/ui/UIProgressBar.d.ts +47 -0
- package/dist/ui/UIProgressBar.d.ts.map +1 -0
- package/dist/ui/index.d.ts +8 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Vector2 } from '../math/Vector2';
|
|
2
|
+
import type { InputManager } from './InputManager';
|
|
3
|
+
export interface Axis1DConfig {
|
|
4
|
+
/** Input code(s) that increase value towards +1.0 */
|
|
5
|
+
positive: string | string[];
|
|
6
|
+
/** Input code(s) that decrease value towards -1.0 */
|
|
7
|
+
negative: string | string[];
|
|
8
|
+
}
|
|
9
|
+
export interface Axis2DConfig {
|
|
10
|
+
/** Input code(s) moving Up (Screen Y: -1) */
|
|
11
|
+
up: string | string[];
|
|
12
|
+
/** Input code(s) moving Down (Screen Y: +1) */
|
|
13
|
+
down: string | string[];
|
|
14
|
+
/** Input code(s) moving Left (Screen X: -1) */
|
|
15
|
+
left: string | string[];
|
|
16
|
+
/** Input code(s) moving Right (Screen X: +1) */
|
|
17
|
+
right: string | string[];
|
|
18
|
+
/** Whether to blend/incorporate VirtualJoystick input. Default: true */
|
|
19
|
+
useJoystick?: boolean;
|
|
20
|
+
/** Whether to normalize diagonal vector to length <= 1.0. Default: true */
|
|
21
|
+
normalize?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface SerializedActionMap {
|
|
24
|
+
actions: Record<string, string[]>;
|
|
25
|
+
axes1D: Record<string, Axis1DConfig>;
|
|
26
|
+
axes2D: Record<string, Axis2DConfig>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Maps semantic actions and 1D/2D composite axes to physical keys, mouse buttons, and joystick.
|
|
30
|
+
*/
|
|
31
|
+
export declare class ActionMap {
|
|
32
|
+
private _input;
|
|
33
|
+
private _actions;
|
|
34
|
+
private _axes1D;
|
|
35
|
+
private _axes2D;
|
|
36
|
+
private _scratchVector;
|
|
37
|
+
constructor(input: InputManager);
|
|
38
|
+
/**
|
|
39
|
+
* Bind a semantic action to one or more physical input codes.
|
|
40
|
+
*/
|
|
41
|
+
bindAction(action: string, ...inputs: string[]): this;
|
|
42
|
+
/**
|
|
43
|
+
* Unbind an input code from an action, or unbind the entire action if input is omitted.
|
|
44
|
+
*/
|
|
45
|
+
unbindAction(action: string, input?: string): this;
|
|
46
|
+
/**
|
|
47
|
+
* Check if any input bound to this action is currently held down.
|
|
48
|
+
*/
|
|
49
|
+
isDown(action: string): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Check if any input bound to this action was just pressed this frame tick.
|
|
52
|
+
*/
|
|
53
|
+
isJustPressed(action: string): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Check if any input bound to this action was just released this frame tick.
|
|
56
|
+
*/
|
|
57
|
+
isJustReleased(action: string): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Bind a 1D scalar axis (e.g. 'horizontal') with positive and negative inputs.
|
|
60
|
+
*/
|
|
61
|
+
bindAxis1D(name: string, config: Axis1DConfig): this;
|
|
62
|
+
/**
|
|
63
|
+
* Unbind a 1D axis.
|
|
64
|
+
*/
|
|
65
|
+
unbindAxis1D(name: string): this;
|
|
66
|
+
/**
|
|
67
|
+
* Get 1D axis value in range [-1.0, 1.0].
|
|
68
|
+
*/
|
|
69
|
+
getAxis(name: string): number;
|
|
70
|
+
/**
|
|
71
|
+
* Bind a 2D vector axis (e.g. 'move') with directional inputs and joystick blending.
|
|
72
|
+
*/
|
|
73
|
+
bindAxis2D(name: string, config: Axis2DConfig): this;
|
|
74
|
+
/**
|
|
75
|
+
* Unbind a 2D axis.
|
|
76
|
+
*/
|
|
77
|
+
unbindAxis2D(name: string): this;
|
|
78
|
+
/**
|
|
79
|
+
* Get 2D direction vector with optional diagonal normalization and joystick blending.
|
|
80
|
+
* @param name Name of the 2D axis.
|
|
81
|
+
* @param out Optional Vector2 destination to prevent allocations.
|
|
82
|
+
*/
|
|
83
|
+
getVector(name: string, out?: Vector2): Vector2;
|
|
84
|
+
toJSON(): SerializedActionMap;
|
|
85
|
+
fromJSON(data: SerializedActionMap): this;
|
|
86
|
+
private _isInputDown;
|
|
87
|
+
private _isInputJustPressed;
|
|
88
|
+
private _isInputJustReleased;
|
|
89
|
+
private _parseMouseButton;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=ActionMap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionMap.d.ts","sourceRoot":"","sources":["../../src/input/ActionMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,WAAW,YAAY;IA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,MAAM,EAAE,MAAM,GAAG,OAAO;IAS7C;;OAEG;IACI,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAiB9C;;OAEG;IACI,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI;IAQ3D;;OAEG;IACI,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKvC;;OAEG;IACI,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IA8BpC;;OAEG;IACI,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI;IAY3D;;OAEG;IACI,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKvC;;;;OAIG;IACI,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,OAAO;IAiD/C,MAAM,IAAI,mBAAmB;IAa7B,QAAQ,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI;IAsBhD,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,mBAAmB;IAQ3B,OAAO,CAAC,oBAAoB;IAQ5B,OAAO,CAAC,iBAAiB;CAkB1B"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Pointer } from './Pointer';
|
|
2
|
+
import { VirtualJoystick, type VirtualJoystickOptions } from './VirtualJoystick';
|
|
3
|
+
import { ActionMap } from './ActionMap';
|
|
4
|
+
import { Vector2 } from '../math/Vector2';
|
|
5
|
+
export interface InputConfig {
|
|
6
|
+
/** DOM element to listen to for pointer/mouse/touch events. Defaults to null (headless safe) */
|
|
7
|
+
target?: HTMLElement | any;
|
|
8
|
+
/** Keys whose default browser behavior should be prevented (e.g. Space, Arrow keys) */
|
|
9
|
+
preventDefaultKeys?: string[];
|
|
10
|
+
/** Prevent default context menu on right click. Default: true */
|
|
11
|
+
preventContextMenu?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface TouchData {
|
|
14
|
+
id: number;
|
|
15
|
+
canvasPosition: Vector2;
|
|
16
|
+
screenPosition: Vector2;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Normalizes keyboard codes and common case-insensitive indie developer aliases.
|
|
20
|
+
*/
|
|
21
|
+
export declare function normalizeKeyCode(code: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Production-grade Unified Input Subsystem.
|
|
24
|
+
* Manages keyboard, pointer, multi-touch, virtual joystick, and semantic action mapping
|
|
25
|
+
* with frame-synchronized buffers and headless simulation capabilities.
|
|
26
|
+
*/
|
|
27
|
+
export declare class InputManager {
|
|
28
|
+
readonly pointer: Pointer;
|
|
29
|
+
readonly joystick: VirtualJoystick;
|
|
30
|
+
readonly actions: ActionMap;
|
|
31
|
+
private _target;
|
|
32
|
+
private _preventDefaultKeys;
|
|
33
|
+
private _preventContextMenu;
|
|
34
|
+
private _downKeys;
|
|
35
|
+
private _justPressedKeys;
|
|
36
|
+
private _justReleasedKeys;
|
|
37
|
+
private _pendingKeyEvents;
|
|
38
|
+
private _touches;
|
|
39
|
+
private _boundKeyDown;
|
|
40
|
+
private _boundKeyUp;
|
|
41
|
+
private _boundPointerDown;
|
|
42
|
+
private _boundPointerMove;
|
|
43
|
+
private _boundPointerUp;
|
|
44
|
+
private _boundPointerCancel;
|
|
45
|
+
private _boundWheel;
|
|
46
|
+
private _boundContextMenu;
|
|
47
|
+
private _boundBlur;
|
|
48
|
+
private _isAttached;
|
|
49
|
+
constructor(config?: InputConfig | HTMLElement | any);
|
|
50
|
+
/**
|
|
51
|
+
* Attach DOM event listeners to a canvas or window target.
|
|
52
|
+
* Safe to call in browser environments; no-op in headless Node.js.
|
|
53
|
+
*/
|
|
54
|
+
attach(target?: HTMLElement | any): void;
|
|
55
|
+
/**
|
|
56
|
+
* Detach all event listeners and unregister from DOM.
|
|
57
|
+
*/
|
|
58
|
+
detach(): void;
|
|
59
|
+
/**
|
|
60
|
+
* Called at the start of each frame tick before scene update.
|
|
61
|
+
* Flushes pending asynchronous DOM events into active frame state.
|
|
62
|
+
*/
|
|
63
|
+
update(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Called at the end of each frame tick after rendering.
|
|
66
|
+
* Clears transitions, resets click consumption and wheel deltas.
|
|
67
|
+
*/
|
|
68
|
+
lateUpdate(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Returns true if the key is currently held down.
|
|
71
|
+
*/
|
|
72
|
+
isDown(code: string): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Returns true if the key was pressed this frame tick.
|
|
75
|
+
*/
|
|
76
|
+
isJustPressed(code: string): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Returns true if the key was released this frame tick.
|
|
79
|
+
*/
|
|
80
|
+
isJustReleased(code: string): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Reset all keys, pointers, touches, and buffers.
|
|
83
|
+
*/
|
|
84
|
+
reset(): void;
|
|
85
|
+
simulateKeyDown(code: string): void;
|
|
86
|
+
simulateKeyUp(code: string): void;
|
|
87
|
+
simulateKeyPress(code: string): void;
|
|
88
|
+
simulatePointerDown(canvasX: number, canvasY: number, button?: number): void;
|
|
89
|
+
simulatePointerUp(canvasX: number, canvasY: number, button?: number): void;
|
|
90
|
+
simulatePointerMove(canvasX: number, canvasY: number): void;
|
|
91
|
+
simulateWheel(deltaX: number, deltaY: number): void;
|
|
92
|
+
simulateTouchStart(id: number, canvasX: number, canvasY: number): void;
|
|
93
|
+
simulateTouchMove(id: number, canvasX: number, canvasY: number): void;
|
|
94
|
+
simulateTouchEnd(id: number): void;
|
|
95
|
+
simulateBlur(): void;
|
|
96
|
+
/**
|
|
97
|
+
* Configure on-screen virtual joystick.
|
|
98
|
+
*/
|
|
99
|
+
setupVirtualJoystick(options?: VirtualJoystickOptions): void;
|
|
100
|
+
destroy(): void;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=InputManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InputMan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,EAAE,MAAM,GAAG,IAAI;IAWtE,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAWrE,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAMlC,YAAY,IAAI,IAAI;IAI3B;;OAEG;IACI,oBAAoB,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,IAAI;IAa5D,OAAO,IAAI,IAAI;CAIvB"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Vector2 } from '../math/Vector2';
|
|
2
|
+
/**
|
|
3
|
+
* Standard mouse and pointer button codes.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum MouseButton {
|
|
6
|
+
Primary = 0,// Left click
|
|
7
|
+
Middle = 1,// Scroll wheel click
|
|
8
|
+
Secondary = 2,// Right click
|
|
9
|
+
Back = 3,
|
|
10
|
+
Forward = 4
|
|
11
|
+
}
|
|
12
|
+
export type MouseButtonName = 'primary' | 'secondary' | 'middle' | 'left' | 'right';
|
|
13
|
+
/**
|
|
14
|
+
* Camera interface for decoupled world coordinate unprojection.
|
|
15
|
+
*/
|
|
16
|
+
export interface ICamera {
|
|
17
|
+
screenToWorld(screenPos: Vector2, out?: Vector2): Vector2;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Normalizes button identifiers (names or numbers) into standard button indices.
|
|
21
|
+
*/
|
|
22
|
+
export declare function normalizeButton(button?: MouseButtonName | number): number;
|
|
23
|
+
/**
|
|
24
|
+
* Tracks pointer / mouse state, coordinates, button transitions, and click consumption.
|
|
25
|
+
*/
|
|
26
|
+
export declare class Pointer {
|
|
27
|
+
/**
|
|
28
|
+
* UI Click consumption flag.
|
|
29
|
+
* UI elements set this to `true` when handling clicks.
|
|
30
|
+
* Game entities MUST verify `!pointer.consumed` before processing clicks.
|
|
31
|
+
*/
|
|
32
|
+
consumed: boolean;
|
|
33
|
+
/** Coordinates relative to browser client viewport */
|
|
34
|
+
readonly screenPosition: Vector2;
|
|
35
|
+
/** Coordinates mapped to canvas viewport resolution */
|
|
36
|
+
readonly canvasPosition: Vector2;
|
|
37
|
+
/** Previous frame canvas position */
|
|
38
|
+
readonly previousCanvasPosition: Vector2;
|
|
39
|
+
/** Canvas movement delta since previous frame (zero-allocation) */
|
|
40
|
+
readonly delta: Vector2;
|
|
41
|
+
/** Accumulated scroll wheel delta for current frame */
|
|
42
|
+
readonly wheelDelta: Vector2;
|
|
43
|
+
/** Active pointer device type */
|
|
44
|
+
pointerType: 'mouse' | 'touch' | 'pen';
|
|
45
|
+
/** Pointer identifier (from DOM PointerEvent) */
|
|
46
|
+
pointerId: number;
|
|
47
|
+
/** Whether the pointer is currently within the canvas bounds */
|
|
48
|
+
isInside: boolean;
|
|
49
|
+
private _downButtons;
|
|
50
|
+
private _justPressedButtons;
|
|
51
|
+
private _justReleasedButtons;
|
|
52
|
+
private _pendingDownButtons;
|
|
53
|
+
private _pendingUpButtons;
|
|
54
|
+
private _pendingWheelDelta;
|
|
55
|
+
private _worldScratch;
|
|
56
|
+
/**
|
|
57
|
+
* Check if a pointer/mouse button is currently held down.
|
|
58
|
+
*/
|
|
59
|
+
isDown(button?: MouseButtonName | number): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Check if a pointer/mouse button was pressed during this frame tick.
|
|
62
|
+
*/
|
|
63
|
+
isJustPressed(button?: MouseButtonName | number): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Check if a pointer/mouse button was released during this frame tick.
|
|
66
|
+
*/
|
|
67
|
+
isJustReleased(button?: MouseButtonName | number): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Absorb the click for this frame so lower-priority layers (game entities) ignore it.
|
|
70
|
+
*/
|
|
71
|
+
consume(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Check if the click has already been absorbed by a higher-priority layer (UI).
|
|
74
|
+
*/
|
|
75
|
+
isConsumed(): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Calculate world coordinates by unprojecting through the given Camera2D.
|
|
78
|
+
* @param camera Camera instance supporting screenToWorld.
|
|
79
|
+
* @param out Optional output Vector2 to avoid garbage collection.
|
|
80
|
+
*/
|
|
81
|
+
getWorldPosition(camera: ICamera, out?: Vector2): Vector2;
|
|
82
|
+
/** Convenience getter for canvas X */
|
|
83
|
+
get x(): number;
|
|
84
|
+
/** Convenience getter for canvas Y */
|
|
85
|
+
get y(): number;
|
|
86
|
+
/**
|
|
87
|
+
* Update screen and canvas positions with bounding client rect transformation.
|
|
88
|
+
*/
|
|
89
|
+
updatePositions(clientX: number, clientY: number, target: HTMLElement | any): void;
|
|
90
|
+
/**
|
|
91
|
+
* Record a pointer down event into pending buffer.
|
|
92
|
+
*/
|
|
93
|
+
recordDown(button: number): void;
|
|
94
|
+
/**
|
|
95
|
+
* Record a pointer up event into pending buffer.
|
|
96
|
+
*/
|
|
97
|
+
recordUp(button: number): void;
|
|
98
|
+
/**
|
|
99
|
+
* Accumulate wheel delta into pending buffer.
|
|
100
|
+
*/
|
|
101
|
+
recordWheel(deltaX: number, deltaY: number): void;
|
|
102
|
+
/**
|
|
103
|
+
* Frame update: promote pending DOM events to active frame state.
|
|
104
|
+
*/
|
|
105
|
+
update(): void;
|
|
106
|
+
/**
|
|
107
|
+
* Late update: clear transitions, wheel delta, and reset click consumption flag.
|
|
108
|
+
*/
|
|
109
|
+
lateUpdate(): void;
|
|
110
|
+
/**
|
|
111
|
+
* Full reset of pointer state.
|
|
112
|
+
*/
|
|
113
|
+
reset(): void;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=Pointer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pointer.d.ts","sourceRoot":"","sources":["../../src/input/Pointer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C;;GAEG;AACH,oBAAY,WAAW;IACrB,OAAO,IAAI,CAAI,aAAa;IAC5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D;;OAEG;IACI,aAAa,CAAC,MAAM,GAAE,eAAe,GAAG,MAAU,GAAG,OAAO;IAInE;;OAEG;IACI,cAAc,CAAC,MAAM,GAAE,eAAe,GAAG,MAAU,GAAG,OAAO;IAIpE;;OAEG;IACI,OAAO,IAAI,IAAI;IAItB;;OAEG;IACI,UAAU,IAAI,OAAO;IAI5B;;;;OAIG;IACI,gBAAgB,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,OAAO;IAIhE,sCAAsC;IACtC,IAAW,CAAC,IAAI,MAAM,CAErB;IAED,sCAAsC;IACtC,IAAW,CAAC,IAAI,MAAM,CAErB;IAED;;OAEG;IACI,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,GAAG,GAAG,IAAI;IAkBzF;;OAEG;IACI,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAIvC;;OAEG;IACI,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAIrC;;OAEG;IACI,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAKxD;;OAEG;IACI,MAAM,IAAI,IAAI;IA+BrB;;OAEG;IACI,UAAU,IAAI,IAAI;IAOzB;;OAEG;IACI,KAAK,IAAI,IAAI;CAWrB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Vector2 } from '../math/Vector2';
|
|
2
|
+
import { Rect } from '../math/Rect';
|
|
3
|
+
export type VirtualJoystickMode = 'fixed' | 'floating';
|
|
4
|
+
export interface VirtualJoystickOptions {
|
|
5
|
+
/** Mode: 'fixed' (constant anchor) or 'floating' (appears where touched). Default: 'floating' */
|
|
6
|
+
mode?: VirtualJoystickMode;
|
|
7
|
+
/** Anchor point when mode is 'fixed'. Default: (120, 480) */
|
|
8
|
+
basePosition?: Vector2;
|
|
9
|
+
/** Maximum stick displacement radius in pixels. Default: 60 */
|
|
10
|
+
radius?: number;
|
|
11
|
+
/** Normalized deadzone ratio in [0, 1]. Default: 0.15 */
|
|
12
|
+
deadzone?: number;
|
|
13
|
+
/** Optional bounding area on screen to trigger the joystick. Default: null (entire screen) */
|
|
14
|
+
touchArea?: Rect | null;
|
|
15
|
+
/** Initial visibility. Default: false for floating, true for fixed */
|
|
16
|
+
visible?: boolean;
|
|
17
|
+
/** Automatically hide when touch is released. Default: true for floating, false for fixed */
|
|
18
|
+
autoHide?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* On-screen touch joystick with deadzone, normalized 2D direction, and clamped magnitude.
|
|
22
|
+
*/
|
|
23
|
+
export declare class VirtualJoystick {
|
|
24
|
+
/** Center origin of the joystick base in canvas coordinates */
|
|
25
|
+
readonly basePosition: Vector2;
|
|
26
|
+
/** Current position of the draggable thumbstick handle */
|
|
27
|
+
readonly stickPosition: Vector2;
|
|
28
|
+
/** Normalized 2D direction vector scaled by deadzone-adjusted magnitude in [-1, 1] */
|
|
29
|
+
readonly value: Vector2;
|
|
30
|
+
/** Pure unit direction vector (length 1.0 or (0,0) within deadzone) */
|
|
31
|
+
readonly direction: Vector2;
|
|
32
|
+
/** Clamped and deadzone-adjusted scalar magnitude in [0, 1] */
|
|
33
|
+
magnitude: number;
|
|
34
|
+
/** Maximum physical displacement radius */
|
|
35
|
+
radius: number;
|
|
36
|
+
/** Normalized deadzone threshold */
|
|
37
|
+
deadzone: number;
|
|
38
|
+
/** Operational mode ('fixed' or 'floating') */
|
|
39
|
+
mode: VirtualJoystickMode;
|
|
40
|
+
/** Whether the joystick automatically hides on release */
|
|
41
|
+
autoHide: boolean;
|
|
42
|
+
/** Whether the joystick is currently visible */
|
|
43
|
+
visible: boolean;
|
|
44
|
+
/** Whether a finger/pointer is actively dragging the joystick */
|
|
45
|
+
isActive: boolean;
|
|
46
|
+
/** Pointer/touch identifier currently controlling the joystick */
|
|
47
|
+
activeTouchId: number | null;
|
|
48
|
+
/** Optional touch activation zone */
|
|
49
|
+
touchArea: Rect | null;
|
|
50
|
+
constructor(options?: VirtualJoystickOptions);
|
|
51
|
+
/**
|
|
52
|
+
* Handle touch start / pointer down.
|
|
53
|
+
* Returns true if this joystick claimed the touch.
|
|
54
|
+
*/
|
|
55
|
+
handleTouchStart(id: number, pos: Vector2): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Handle touch move / pointer move.
|
|
58
|
+
* Returns true if this touch belonged to the joystick.
|
|
59
|
+
*/
|
|
60
|
+
handleTouchMove(id: number, pos: Vector2): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Handle touch end / pointer up.
|
|
63
|
+
* Returns true if this touch belonged to the joystick.
|
|
64
|
+
*/
|
|
65
|
+
handleTouchEnd(id: number): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Internal kinematic calculation: clamp stick, apply deadzone, compute direction & magnitude.
|
|
68
|
+
*/
|
|
69
|
+
private _updateStick;
|
|
70
|
+
/**
|
|
71
|
+
* Optional Canvas2D debug rendering helper.
|
|
72
|
+
*/
|
|
73
|
+
render(context: CanvasRenderingContext2D | any): void;
|
|
74
|
+
/**
|
|
75
|
+
* Reset joystick to initial neutral state.
|
|
76
|
+
*/
|
|
77
|
+
reset(): void;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=VirtualJoystick.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VirtualJoystick.d.ts","sourceRoot":"","sources":["../../src/input/VirtualJoystick.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,UAAU,CAAC;AAEvD,MAAM,WAAW,sBAAsB;IACrC,iGAAiG;IACjG,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,6DAA6D;IAC7D,YAAY,CAAC,EAAE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AE,EAAE,MAAM,GAAG,OAAO;IAgB1C;;OAEG;IACH,OAAO,CAAC,YAAY;IAmCpB;;OAEG;IACI,MAAM,CAAC,OAAO,EAAE,wBAAwB,GAAG,GAAG,GAAG,IAAI;IA4B5D;;OAEG;IACI,KAAK,IAAI,IAAI;CAWrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/input/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Vector2 } from './Vector2';
|
|
2
|
+
import { Rect } from './Rect';
|
|
3
|
+
/**
|
|
4
|
+
* 2D Circle Primitive for collision testing and spatial queries.
|
|
5
|
+
*/
|
|
6
|
+
export declare class Circle {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
radius: number;
|
|
10
|
+
constructor(x?: number, y?: number, radius?: number);
|
|
11
|
+
set(x: number, y: number, radius: number): this;
|
|
12
|
+
copy(other: Circle): this;
|
|
13
|
+
clone(): Circle;
|
|
14
|
+
get center(): Vector2;
|
|
15
|
+
set center(v: Vector2);
|
|
16
|
+
get diameter(): number;
|
|
17
|
+
get area(): number;
|
|
18
|
+
get circumference(): number;
|
|
19
|
+
/**
|
|
20
|
+
* Tests whether point (x, y) is inside the circle.
|
|
21
|
+
*/
|
|
22
|
+
contains(x: number, y: number): boolean;
|
|
23
|
+
containsPoint(point: Vector2): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Tests whether this circle intersects with another circle.
|
|
26
|
+
*/
|
|
27
|
+
intersects(other: Circle): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Tests whether this circle intersects with an AABB Rect.
|
|
30
|
+
* Clamps circle center to rect boundary to find closest point.
|
|
31
|
+
*/
|
|
32
|
+
intersectsRect(rect: Rect): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Returns tight AABB bounding box enclosing this circle.
|
|
35
|
+
*/
|
|
36
|
+
getBoundingBox(out?: Rect): Rect;
|
|
37
|
+
offset(dx: number, dy: number): this;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=Circle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Circle.d.ts","sourceRoot":"","sources":["../../src/math/Circle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B;;GAEG;AACH,qBAAa,MAAM;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;gBAEV,CAAC,GAAE,MAAU,EAAE,CAAC,GAAE,MAAU,EAAE,MAAM,GAAE,MAAU;IAMrD,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAO/C,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIzB,KAAK,IAAI,MAAM;IAItB,IAAW,MAAM,IAAI,OAAO,CAE3B;IAED,IAAW,MAAM,CAAC,CAAC,EAAE,OAAO,EAG3B;IAED,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,aAAa,IAAI,MAAM,CAEjC;IAED;;OAEG;IACI,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO;IAMvC,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAI7C;;OAEG;IACI,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAQzC;;;OAGG;IACI,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAQ1C;;OAEG;IACI,cAAc,CAAC,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI;IAUhC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI;CAK5C"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Production-ready RGBA Color class with parsing for Hex, RGB, RGBA, and HSL,
|
|
3
|
+
* Canvas2D string generation, and color interpolation.
|
|
4
|
+
*/
|
|
5
|
+
export declare class Color {
|
|
6
|
+
r: number;
|
|
7
|
+
g: number;
|
|
8
|
+
b: number;
|
|
9
|
+
a: number;
|
|
10
|
+
constructor(r?: number, g?: number, b?: number, a?: number);
|
|
11
|
+
set(r: number, g: number, b: number, a?: number): this;
|
|
12
|
+
copy(other: Color): this;
|
|
13
|
+
clone(): Color;
|
|
14
|
+
get rNorm(): number;
|
|
15
|
+
get gNorm(): number;
|
|
16
|
+
get bNorm(): number;
|
|
17
|
+
setAlpha(a: number): this;
|
|
18
|
+
/**
|
|
19
|
+
* Parses hex string in formats:
|
|
20
|
+
* #RGB, #RGBA, #RRGGBB, #RRGGBBAA, 0xRGB, 0xRRGGBB, etc.
|
|
21
|
+
*/
|
|
22
|
+
static fromHex(hex: string): Color;
|
|
23
|
+
static fromRGB(r: number, g: number, b: number, a?: number): Color;
|
|
24
|
+
/**
|
|
25
|
+
* Converts HSL (h in [0, 360], s in [0, 1] or [0, 100], l in [0, 1] or [0, 100]) to Color.
|
|
26
|
+
*/
|
|
27
|
+
static fromHSL(h: number, s: number, l: number, a?: number): Color;
|
|
28
|
+
/**
|
|
29
|
+
* Universal parser for CSS strings: #hex, rgb(...), rgba(...), hsl(...), hsla(...), or named colors.
|
|
30
|
+
*/
|
|
31
|
+
static parse(colorStr: string): Color;
|
|
32
|
+
toRgbaString(): string;
|
|
33
|
+
toRgbString(): string;
|
|
34
|
+
toHexString(includeAlpha?: boolean): string;
|
|
35
|
+
toHsl(): {
|
|
36
|
+
h: number;
|
|
37
|
+
s: number;
|
|
38
|
+
l: number;
|
|
39
|
+
a: number;
|
|
40
|
+
};
|
|
41
|
+
toHslString(): string;
|
|
42
|
+
lerp(other: Color, t: number): Color;
|
|
43
|
+
lerpInPlace(other: Color, t: number): this;
|
|
44
|
+
equals(other: Color, epsilon?: number): boolean;
|
|
45
|
+
static readonly WHITE: Color;
|
|
46
|
+
static readonly BLACK: Color;
|
|
47
|
+
static readonly TRANSPARENT: Color;
|
|
48
|
+
static readonly RED: Color;
|
|
49
|
+
static readonly GREEN: Color;
|
|
50
|
+
static readonly BLUE: Color;
|
|
51
|
+
static readonly YELLOW: Color;
|
|
52
|
+
static readonly CYAN: Color;
|
|
53
|
+
static readonly MAGENTA: Color;
|
|
54
|
+
static readonly GRAY: Color;
|
|
55
|
+
static readonly ORANGE: Color;
|
|
56
|
+
static readonly PURPLE: Color;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=Color.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Color.d.ts","sourceRoot":"","sources":["../../src/math/Color.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,qBAAa,KAAK;IACT,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;gBAGf,CAAC,GAAE,MAAY,EACf,CAAC,GAAE,MAAY,EACf,CAAC,GAAE,MAAY,EACf,CAAC,GAAE,MAAY;IAQV,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,GAAE,MAAY,GAAG,IAAI;IAQ3D,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAIxB,KAAK,IAAI,KAAK;IAQrB,IAAW,KAAK,IAAI,MAAM,CAEzB;IAED,IAAW,KAAK,IAAI,MAAM,CAEzB;IAED,IAAW,KAAK,IAAI,MAAM,CAEzB;IAEM,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BAAuB,MAAM,QAAgC;CAC9D"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collection of performance-optimized mathematical helper functions,
|
|
3
|
+
* frame-rate independent dampening, angle wrapping, and interpolation.
|
|
4
|
+
*/
|
|
5
|
+
export declare class MathUtils {
|
|
6
|
+
static readonly EPSILON: number;
|
|
7
|
+
static readonly DEG_TO_RAD: number;
|
|
8
|
+
static readonly RAD_TO_DEG: number;
|
|
9
|
+
static readonly TWO_PI: number;
|
|
10
|
+
static readonly HALF_PI: number;
|
|
11
|
+
/**
|
|
12
|
+
* Clamps a value between a minimum and maximum threshold.
|
|
13
|
+
*/
|
|
14
|
+
static clamp(value: number, min: number, max: number): number;
|
|
15
|
+
/**
|
|
16
|
+
* Clamps a value between 0.0 and 1.0.
|
|
17
|
+
*/
|
|
18
|
+
static clamp01(value: number): number;
|
|
19
|
+
/**
|
|
20
|
+
* Standard linear interpolation between a and b by factor t.
|
|
21
|
+
*/
|
|
22
|
+
static lerp(a: number, b: number, t: number): number;
|
|
23
|
+
/**
|
|
24
|
+
* Inverse linear interpolation: computes t for value in [a, b].
|
|
25
|
+
*/
|
|
26
|
+
static inverseLerp(a: number, b: number, value: number): number;
|
|
27
|
+
/**
|
|
28
|
+
* Analytic frame-rate independent smoothing (exponential decay).
|
|
29
|
+
* Guarantees identical smoothing speed regardless of whether game runs at 60 FPS or 144 FPS.
|
|
30
|
+
*
|
|
31
|
+
* @param a Current value
|
|
32
|
+
* @param b Target value
|
|
33
|
+
* @param lambda Smoothing speed (higher = faster, typically 5 to 25)
|
|
34
|
+
* @param dt Delta time in seconds
|
|
35
|
+
*/
|
|
36
|
+
static damp(a: number, b: number, lambda: number, dt: number): number;
|
|
37
|
+
/**
|
|
38
|
+
* Converts degrees to radians.
|
|
39
|
+
*/
|
|
40
|
+
static degToRad(deg: number): number;
|
|
41
|
+
/**
|
|
42
|
+
* Converts radians to degrees.
|
|
43
|
+
*/
|
|
44
|
+
static radToDeg(rad: number): number;
|
|
45
|
+
/**
|
|
46
|
+
* Generates a random float in [min, max).
|
|
47
|
+
*/
|
|
48
|
+
static randomRange(min: number, max: number): number;
|
|
49
|
+
/**
|
|
50
|
+
* Generates a random integer in [min, max] (inclusive).
|
|
51
|
+
*/
|
|
52
|
+
static randomInt(min: number, max: number): number;
|
|
53
|
+
/**
|
|
54
|
+
* Picks a random element from an array.
|
|
55
|
+
*/
|
|
56
|
+
static randomChoice<T>(items: readonly T[]): T;
|
|
57
|
+
/**
|
|
58
|
+
* Tests whether two floating-point numbers are approximately equal within epsilon.
|
|
59
|
+
*/
|
|
60
|
+
static approximately(a: number, b: number, epsilon?: number): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Wraps value into the half-open interval [min, max).
|
|
63
|
+
* Useful for screen wrapping coordinates in toroidal 2D worlds (e.g. Asteroids).
|
|
64
|
+
*/
|
|
65
|
+
static wrap(value: number, min: number, max: number): number;
|
|
66
|
+
/**
|
|
67
|
+
* Normalizes an angle in radians into [-PI, PI).
|
|
68
|
+
*/
|
|
69
|
+
static normalizeAngle(radians: number): number;
|
|
70
|
+
/**
|
|
71
|
+
* Computes the shortest signed angular difference from angle 'from' to angle 'to' in radians.
|
|
72
|
+
* Useful for smooth turret or camera rotation towards a target.
|
|
73
|
+
*/
|
|
74
|
+
static angleDifference(from: number, to: number): number;
|
|
75
|
+
/**
|
|
76
|
+
* Smooth Hermite interpolation between edges.
|
|
77
|
+
* Guards against degenerate intervals (|max - min| < EPSILON) returning 1 or 0 instead of NaN.
|
|
78
|
+
*/
|
|
79
|
+
static smoothstep(min: number, max: number, value: number): number;
|
|
80
|
+
static sign(value: number): number;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=MathUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MathUtils.d.ts","sourceRoot":"","sources":["../../src/math/MathUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,SAAS;IACp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