emeraldengine 2.2.0 → 3.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 +2359 -968
- package/dist/types/index.d.ts +72 -32
- package/dist/types/src/Animator.d.ts +50 -0
- package/dist/types/{BitmapText.d.ts → src/BitmapText.d.ts} +19 -21
- package/dist/types/src/Camera.d.ts +122 -0
- package/dist/types/src/CameraController.d.ts +107 -0
- package/dist/types/src/CanvasText.d.ts +91 -0
- package/dist/types/src/CollisionLayers.d.ts +58 -0
- package/dist/types/{Color.d.ts → src/Color.d.ts} +5 -6
- package/dist/types/src/Coroutine.d.ts +111 -0
- package/dist/types/src/DebugOverlay.d.ts +86 -0
- package/dist/types/src/Drawable.d.ts +271 -0
- package/dist/types/src/Easing.d.ts +22 -0
- package/dist/types/src/Emerald.d.ts +420 -0
- package/dist/types/src/EmeraldDB.d.ts +159 -0
- package/dist/types/{FPSCounter.d.ts → src/FPSCounter.d.ts} +1 -3
- package/dist/types/src/GLUtils.d.ts +4 -0
- package/dist/types/{Instance.d.ts → src/Instance.d.ts} +37 -15
- package/dist/types/{InstancedTexture.d.ts → src/InstancedTexture.d.ts} +60 -23
- package/dist/types/src/Interpolator.d.ts +66 -0
- package/dist/types/src/Material.d.ts +87 -0
- package/dist/types/src/MathUtils.d.ts +80 -0
- package/dist/types/src/ParticleEmitter.d.ts +131 -0
- package/dist/types/{Physics.d.ts → src/Physics.d.ts} +88 -20
- package/dist/types/src/Pool.d.ts +53 -0
- package/dist/types/src/PostEffects.d.ts +68 -0
- package/dist/types/src/PostProcessor.d.ts +124 -0
- package/dist/types/src/RenderTarget.d.ts +56 -0
- package/dist/types/src/Scene.d.ts +62 -0
- package/dist/types/src/ScreenEffects.d.ts +111 -0
- package/dist/types/src/Serializer.d.ts +86 -0
- package/dist/types/src/Shaders.d.ts +2 -0
- package/dist/types/{Shapes.d.ts → src/Shapes.d.ts} +4 -6
- package/dist/types/src/SpatialGrid.d.ts +50 -0
- package/dist/types/src/SpriteBatch.d.ts +89 -0
- package/dist/types/src/StateMachine.d.ts +59 -0
- package/dist/types/src/Storage.d.ts +89 -0
- package/dist/types/{Texture.d.ts → src/Texture.d.ts} +3 -4
- package/dist/types/src/TextureAtlas.d.ts +55 -0
- package/dist/types/src/Tilemap.d.ts +91 -0
- package/dist/types/src/Time.d.ts +53 -0
- package/dist/types/src/Timer.d.ts +54 -0
- package/dist/types/src/Transform.d.ts +94 -0
- package/dist/types/src/Tween.d.ts +81 -0
- package/dist/types/src/UI.d.ts +121 -0
- package/dist/types/src/components/Behaviour.d.ts +71 -0
- package/dist/types/{components → src/components}/BoxCollider.d.ts +14 -14
- package/dist/types/src/components/BoxColliderDebug.d.ts +15 -0
- package/dist/types/{components → src/components}/CircleCollider.d.ts +14 -12
- package/dist/types/src/components/CircleColliderDebug.d.ts +15 -0
- package/dist/types/src/components/Collider.d.ts +96 -0
- package/dist/types/src/components/GameObject.d.ts +135 -0
- package/dist/types/src/components/RigidBody.d.ts +183 -0
- package/dist/types/src/importers/Aseprite.d.ts +79 -0
- package/dist/types/src/importers/TiledMap.d.ts +62 -0
- package/dist/types/{lights → src/lights}/DirectionalLight.d.ts +7 -9
- package/dist/types/{lights → src/lights}/PointLight.d.ts +6 -9
- package/dist/types/src/managers/AssetManager.d.ts +116 -0
- package/dist/types/src/managers/AudioManager.d.ts +259 -0
- package/dist/types/{managers → src/managers}/CameraManager.d.ts +8 -8
- package/dist/types/{managers → src/managers}/EventManager.d.ts +46 -32
- package/dist/types/src/managers/GLManager.d.ts +84 -0
- package/dist/types/src/managers/GLState.d.ts +37 -0
- package/dist/types/src/managers/IDManager.d.ts +31 -0
- package/dist/types/src/managers/InputManager.d.ts +290 -0
- package/dist/types/src/managers/NetworkManager.d.ts +93 -0
- package/dist/types/src/managers/RenderStats.d.ts +34 -0
- package/dist/types/src/managers/SceneManager.d.ts +44 -0
- package/dist/types/src/managers/ShaderManager.d.ts +55 -0
- package/dist/types/src/managers/TextureManager.d.ts +102 -0
- package/dist/types/src/particlesystem/Particle.d.ts +64 -0
- package/dist/types/{particlesystem → src/particlesystem}/ParticleSettings.d.ts +32 -24
- package/dist/types/{particlesystem → src/particlesystem}/Particles.d.ts +20 -12
- package/index.js +72 -0
- package/package.json +74 -60
- package/src/Animator.js +95 -0
- package/src/BitmapText.js +6 -5
- package/src/Camera.js +183 -0
- package/src/CameraController.js +192 -0
- package/src/CanvasText.js +281 -0
- package/src/CollisionLayers.js +86 -0
- package/src/Color.js +18 -18
- package/src/Coroutine.js +259 -0
- package/src/DebugOverlay.js +246 -0
- package/src/Drawable.js +842 -555
- package/src/Easing.js +57 -0
- package/src/Emerald.js +1150 -459
- package/src/EmeraldDB.js +328 -0
- package/src/FPSCounter.js +43 -43
- package/src/GLUtils.js +60 -67
- package/src/Instance.js +41 -5
- package/src/InstancedTexture.js +251 -118
- package/src/Interpolator.js +124 -0
- package/src/Material.js +202 -0
- package/src/MathUtils.js +133 -0
- package/src/ParticleEmitter.js +284 -0
- package/src/Physics.js +186 -5
- package/src/Pool.js +85 -0
- package/src/PostEffects.js +296 -0
- package/src/PostProcessor.js +304 -0
- package/src/RenderTarget.js +134 -0
- package/src/Scene.js +115 -83
- package/src/ScreenEffects.js +266 -0
- package/src/Serializer.js +131 -0
- package/src/Shaders.js +150 -165
- package/src/Shapes.js +118 -129
- package/src/SpatialGrid.js +111 -0
- package/src/SpriteBatch.js +299 -0
- package/src/StateMachine.js +82 -0
- package/src/Storage.js +175 -47
- package/src/Texture.js +58 -67
- package/src/TextureAtlas.js +96 -0
- package/src/Tilemap.js +274 -0
- package/src/Time.js +51 -6
- package/src/Timer.js +99 -0
- package/src/Transform.js +100 -7
- package/src/Tween.js +160 -0
- package/src/UI.js +394 -0
- package/src/components/Behaviour.js +90 -0
- package/src/components/BoxCollider.js +22 -3
- package/src/components/CircleCollider.js +19 -3
- package/src/components/CircleColliderDebug.js +24 -24
- package/src/components/Collider.js +140 -34
- package/src/components/GameObject.js +130 -21
- package/src/components/RigidBody.js +123 -2
- package/src/importers/Aseprite.js +142 -0
- package/src/importers/TiledMap.js +158 -0
- package/src/lights/DirectionalLight.js +6 -15
- package/src/lights/PointLight.js +4 -4
- package/src/managers/AssetManager.js +239 -0
- package/src/managers/AudioManager.js +565 -146
- package/src/managers/EventManager.js +488 -477
- package/src/managers/GLManager.js +57 -0
- package/src/managers/GLState.js +70 -0
- package/src/managers/IDManager.js +24 -2
- package/src/managers/InputManager.js +779 -0
- package/src/managers/NetworkManager.js +178 -0
- package/src/managers/RenderStats.js +34 -0
- package/src/managers/SceneManager.js +30 -0
- package/src/managers/ShaderManager.js +0 -2
- package/src/managers/TextureManager.js +218 -0
- package/src/particlesystem/Particle.js +82 -7
- package/src/particlesystem/ParticleSettings.js +21 -3
- package/src/particlesystem/Particles.js +80 -31
- package/dist/types/Drawable.d.ts +0 -157
- package/dist/types/Emerald.d.ts +0 -73
- package/dist/types/GLUtils.d.ts +0 -6
- package/dist/types/Scene.d.ts +0 -39
- package/dist/types/Shaders.d.ts +0 -4
- package/dist/types/Storage.d.ts +0 -46
- package/dist/types/Time.d.ts +0 -22
- package/dist/types/Transform.d.ts +0 -41
- package/dist/types/components/BoxColliderDebug.d.ts +0 -19
- package/dist/types/components/CircleColliderDebug.d.ts +0 -19
- package/dist/types/components/Collider.d.ts +0 -53
- package/dist/types/components/GameObject.d.ts +0 -72
- package/dist/types/components/RigidBody.d.ts +0 -104
- package/dist/types/managers/AudioManager.d.ts +0 -60
- package/dist/types/managers/GLManager.d.ts +0 -47
- package/dist/types/managers/IDManager.d.ts +0 -21
- package/dist/types/managers/SceneManager.d.ts +0 -22
- package/dist/types/particlesystem/Particle.d.ts +0 -42
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export default Timer;
|
|
2
|
+
/**
|
|
3
|
+
* @class Timer
|
|
4
|
+
* @description Schedules delayed and repeating callbacks measured in seconds.
|
|
5
|
+
* Driven by `Emerald.drawScene` with time-scaled delta, so timers honor
|
|
6
|
+
* pause/slow-mo. Each scheduler call returns a handle you can pass to `clear`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* Timer.after(2, () => spawnEnemy()); // once, after 2s
|
|
10
|
+
* Timer.every(0.5, () => tick(), 10); // 10 times, every 0.5s
|
|
11
|
+
* const h = Timer.every(1, () => poll()); // forever until cleared
|
|
12
|
+
* Timer.clear(h);
|
|
13
|
+
*/
|
|
14
|
+
declare class Timer {
|
|
15
|
+
/**
|
|
16
|
+
* @method after
|
|
17
|
+
* @description Runs a callback once after a delay.
|
|
18
|
+
* @param {number} seconds - Delay in seconds
|
|
19
|
+
* @param {Function} callback
|
|
20
|
+
* @returns {Object} - A handle for clear()
|
|
21
|
+
*/
|
|
22
|
+
static after(seconds: number, callback: Function): any;
|
|
23
|
+
/**
|
|
24
|
+
* @method every
|
|
25
|
+
* @description Runs a callback repeatedly on an interval.
|
|
26
|
+
* @param {number} seconds - Interval in seconds
|
|
27
|
+
* @param {Function} callback
|
|
28
|
+
* @param {number} [repeats] - Number of repeats (default Infinity)
|
|
29
|
+
* @returns {Object} - A handle for clear()
|
|
30
|
+
*/
|
|
31
|
+
static every(seconds: number, callback: Function, repeats?: number): any;
|
|
32
|
+
/** @private */
|
|
33
|
+
private static _add;
|
|
34
|
+
/**
|
|
35
|
+
* @method clear
|
|
36
|
+
* @description Cancels a scheduled timer by its handle.
|
|
37
|
+
* @param {Object} handle - The handle returned by after/every
|
|
38
|
+
*/
|
|
39
|
+
static clear(handle: any): void;
|
|
40
|
+
/**
|
|
41
|
+
* @method clearAll
|
|
42
|
+
* @description Cancels all timers.
|
|
43
|
+
*/
|
|
44
|
+
static clearAll(): void;
|
|
45
|
+
/**
|
|
46
|
+
* @method update
|
|
47
|
+
* @description Advances all timers. Driven by Emerald.drawScene.
|
|
48
|
+
* @param {number} dt - Seconds since the last frame
|
|
49
|
+
*/
|
|
50
|
+
static update(dt: number): void;
|
|
51
|
+
}
|
|
52
|
+
declare namespace Timer {
|
|
53
|
+
let entries: any[];
|
|
54
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export default Transform;
|
|
2
|
+
/**
|
|
3
|
+
* @class Transform
|
|
4
|
+
* @description Represents a transform with optional parent/child hierarchy.
|
|
5
|
+
* Local position/rotation/scale are composed up the parent chain to produce a
|
|
6
|
+
* world transform. Objects with no parent behave exactly as before (the world
|
|
7
|
+
* transform is the local transform), so existing code is unaffected.
|
|
8
|
+
* @param {Vector3} position - The local position
|
|
9
|
+
* @param {number} rotation - The local rotation (radians)
|
|
10
|
+
* @param {Vector2} scale - The local scale
|
|
11
|
+
*/
|
|
12
|
+
declare class Transform {
|
|
13
|
+
constructor(position: any, rotation: any, scale: any);
|
|
14
|
+
position: any;
|
|
15
|
+
rotation: any;
|
|
16
|
+
scale: any;
|
|
17
|
+
parent: any;
|
|
18
|
+
children: any[];
|
|
19
|
+
/** @private */
|
|
20
|
+
private _world;
|
|
21
|
+
/**
|
|
22
|
+
* @method setParent
|
|
23
|
+
* @description Sets (or clears) the parent transform, maintaining the
|
|
24
|
+
* children list on both sides.
|
|
25
|
+
* @param {Transform|null} parent - The parent transform, or null to detach
|
|
26
|
+
*/
|
|
27
|
+
setParent(parent: Transform | null): void;
|
|
28
|
+
/**
|
|
29
|
+
* @method getWorldParts
|
|
30
|
+
* @description Returns the composed world TRS as primitives. Composition is
|
|
31
|
+
* standard 2D: child local space is scaled and rotated by the parent.
|
|
32
|
+
* @returns {{px:number, py:number, pz:number, rot:number, sx:number, sy:number}}
|
|
33
|
+
*/
|
|
34
|
+
getWorldParts(): {
|
|
35
|
+
px: number;
|
|
36
|
+
py: number;
|
|
37
|
+
pz: number;
|
|
38
|
+
rot: number;
|
|
39
|
+
sx: number;
|
|
40
|
+
sy: number;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* @method getWorldTransform
|
|
44
|
+
* @description Returns a transform-shaped object ({position, rotation, scale})
|
|
45
|
+
* in world space. The returned object is reused between calls.
|
|
46
|
+
* @returns {{position:{x,y,z}, rotation:number, scale:{x,y}}}
|
|
47
|
+
*/
|
|
48
|
+
getWorldTransform(): {
|
|
49
|
+
position: {
|
|
50
|
+
x: any;
|
|
51
|
+
y: any;
|
|
52
|
+
z: any;
|
|
53
|
+
};
|
|
54
|
+
rotation: number;
|
|
55
|
+
scale: {
|
|
56
|
+
x: any;
|
|
57
|
+
y: any;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* @method getWorldPosition
|
|
62
|
+
* @description Returns the world-space position as a plain { x, y, z }.
|
|
63
|
+
*/
|
|
64
|
+
getWorldPosition(): {
|
|
65
|
+
x: number;
|
|
66
|
+
y: number;
|
|
67
|
+
z: number;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* @method equals
|
|
71
|
+
* @description Checks if the transform is equal to another transform
|
|
72
|
+
* @param {Transform} other - The other transform
|
|
73
|
+
* @returns {boolean} - True if the transform is equal to the other transform
|
|
74
|
+
*/
|
|
75
|
+
equals(other: Transform): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* @method getPosition
|
|
78
|
+
* @description Returns the local position of the transform
|
|
79
|
+
* @returns {Vector3} - The position of the transform
|
|
80
|
+
*/
|
|
81
|
+
getPosition(): Vector3;
|
|
82
|
+
/**
|
|
83
|
+
* @method getRotation
|
|
84
|
+
* @description Returns the local rotation of the transform
|
|
85
|
+
* @returns {number} - The rotation of the transform
|
|
86
|
+
*/
|
|
87
|
+
getRotation(): number;
|
|
88
|
+
/**
|
|
89
|
+
* @method getScale
|
|
90
|
+
* @description Returns the local scale of the transform
|
|
91
|
+
* @returns {Vector2} - The scale of the transform
|
|
92
|
+
*/
|
|
93
|
+
getScale(): Vector2;
|
|
94
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export default Tween;
|
|
2
|
+
/**
|
|
3
|
+
* @class Tween
|
|
4
|
+
* @description Animates numeric properties of a target object over time with
|
|
5
|
+
* easing. Tweens created via `Tween.to(...)` are auto-registered and advanced
|
|
6
|
+
* by `Emerald.drawScene` (using time-scaled delta), so they respect pause/slow-mo.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* Tween.to(sprite.transform.position, { x: 200, y: -50 }, 0.6, {
|
|
10
|
+
* easing: Easing.outBack,
|
|
11
|
+
* onComplete: () => console.log("done"),
|
|
12
|
+
* });
|
|
13
|
+
*/
|
|
14
|
+
declare class Tween {
|
|
15
|
+
/**
|
|
16
|
+
* @param {Object} target - The object whose numeric keys will be animated
|
|
17
|
+
* @param {Object} props - Map of key -> end value
|
|
18
|
+
* @param {number} duration - Duration in seconds
|
|
19
|
+
* @param {Object} [options] - { easing, delay, loop, yoyo, onUpdate, onComplete }
|
|
20
|
+
*/
|
|
21
|
+
constructor(target: any, props: any, duration: number, options?: any);
|
|
22
|
+
target: any;
|
|
23
|
+
props: any;
|
|
24
|
+
duration: number;
|
|
25
|
+
easing: any;
|
|
26
|
+
delay: any;
|
|
27
|
+
loop: boolean;
|
|
28
|
+
yoyo: boolean;
|
|
29
|
+
onUpdate: any;
|
|
30
|
+
onComplete: any;
|
|
31
|
+
elapsed: number;
|
|
32
|
+
started: boolean;
|
|
33
|
+
done: boolean;
|
|
34
|
+
from: {};
|
|
35
|
+
/** @private */
|
|
36
|
+
private _begin;
|
|
37
|
+
/**
|
|
38
|
+
* @method update
|
|
39
|
+
* @description Advances the tween. Returns false when finished.
|
|
40
|
+
* @param {number} dt - Seconds since the last update
|
|
41
|
+
* @returns {boolean} - Whether the tween is still active
|
|
42
|
+
*/
|
|
43
|
+
update(dt: number): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* @method then
|
|
46
|
+
* @description Chains a callback to run when the tween completes.
|
|
47
|
+
* @param {Function} callback
|
|
48
|
+
* @returns {Tween} - this
|
|
49
|
+
*/
|
|
50
|
+
then(callback: Function): Tween;
|
|
51
|
+
/**
|
|
52
|
+
* @method stop
|
|
53
|
+
* @description Stops the tween immediately (without firing onComplete).
|
|
54
|
+
*/
|
|
55
|
+
stop(): void;
|
|
56
|
+
}
|
|
57
|
+
declare namespace Tween {
|
|
58
|
+
let active: any[];
|
|
59
|
+
/**
|
|
60
|
+
* @method Tween.to
|
|
61
|
+
* @description Creates and registers a tween.
|
|
62
|
+
* @returns {Tween}
|
|
63
|
+
*/
|
|
64
|
+
function to(target: any, props: any, duration: any, options: any): Tween;
|
|
65
|
+
/**
|
|
66
|
+
* @method Tween.update
|
|
67
|
+
* @description Advances all active tweens. Driven by Emerald.drawScene.
|
|
68
|
+
* @param {number} dt - Seconds since the last frame
|
|
69
|
+
*/
|
|
70
|
+
function update(dt: number): void;
|
|
71
|
+
/**
|
|
72
|
+
* @method Tween.killOf
|
|
73
|
+
* @description Removes all tweens targeting the given object.
|
|
74
|
+
*/
|
|
75
|
+
function killOf(target: any): void;
|
|
76
|
+
/**
|
|
77
|
+
* @method Tween.killAll
|
|
78
|
+
* @description Removes every active tween.
|
|
79
|
+
*/
|
|
80
|
+
function killAll(): void;
|
|
81
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export default UI;
|
|
2
|
+
/**
|
|
3
|
+
* @class UI
|
|
4
|
+
* @description A small retained-mode UI toolkit rendered entirely with the
|
|
5
|
+
* engine (no DOM/HTML overlay): panels, labels, buttons and text fields, drawn
|
|
6
|
+
* as screen-space objects on a dedicated layer with their own pointer/keyboard
|
|
7
|
+
* hit-testing. Positions are in pixels from the viewport center (y up), or a
|
|
8
|
+
* `(viewW, viewH) => ({x, y})` function for responsive anchoring; call
|
|
9
|
+
* `relayout()` on resize.
|
|
10
|
+
*
|
|
11
|
+
* Pair it with a UI camera (see {@link UI.createCamera}) so the UI draws over
|
|
12
|
+
* the game and the game cameras ignore the UI layer.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const uiCam = UI.createCamera(); // onlyLayers = [UI layer]
|
|
16
|
+
* gameCamera.ignoreLayer(UI.LAYER);
|
|
17
|
+
* emerald.setCameras([gameCamera, uiCam]);
|
|
18
|
+
*
|
|
19
|
+
* const ui = new UI(scene, canvas);
|
|
20
|
+
* ui.label(() => ({ x: 0, y: 200 }), "PAUSED", { font: "700 48px sans-serif" });
|
|
21
|
+
* ui.button(() => ({ x: 0, y: 0 }), "Resume", 220, 56, { onClick: resume });
|
|
22
|
+
* // in the loop: ui.relayout() on resize; remove input via ui.destroy().
|
|
23
|
+
*/
|
|
24
|
+
declare class UI {
|
|
25
|
+
/**
|
|
26
|
+
* @method createCamera
|
|
27
|
+
* @description Returns a full-screen camera that renders only the UI layer,
|
|
28
|
+
* so UI draws over the game. Add it last in setCameras.
|
|
29
|
+
* @param {number} [layer] - The UI layer (defaults to UI.LAYER)
|
|
30
|
+
* @returns {Camera}
|
|
31
|
+
*/
|
|
32
|
+
static createCamera(layer?: number): Camera;
|
|
33
|
+
/**
|
|
34
|
+
* @param {Scene} scene - Scene to add UI objects to
|
|
35
|
+
* @param {HTMLCanvasElement} canvas - Canvas for pointer coordinates
|
|
36
|
+
* @param {Object} [options] - { layer = UI.LAYER, accent = [110,180,255] }
|
|
37
|
+
*/
|
|
38
|
+
constructor(scene: Scene, canvas: HTMLCanvasElement, options?: any);
|
|
39
|
+
scene: Scene;
|
|
40
|
+
canvas: HTMLCanvasElement;
|
|
41
|
+
layer: any;
|
|
42
|
+
accent: any;
|
|
43
|
+
elements: any[];
|
|
44
|
+
focused: any;
|
|
45
|
+
/** @private */
|
|
46
|
+
private _hover;
|
|
47
|
+
/** @private */
|
|
48
|
+
private _onMove;
|
|
49
|
+
/** @private */
|
|
50
|
+
private _onDown;
|
|
51
|
+
/** @private */
|
|
52
|
+
private _onKey;
|
|
53
|
+
/** @private */
|
|
54
|
+
private _resolvePos;
|
|
55
|
+
/**
|
|
56
|
+
* @method relayout
|
|
57
|
+
* @description Recomputes positions of all elements (call after a resize).
|
|
58
|
+
*/
|
|
59
|
+
relayout(): void;
|
|
60
|
+
/**
|
|
61
|
+
* @method panel
|
|
62
|
+
* @description Adds a rectangular panel.
|
|
63
|
+
* @returns {Object} - Element handle
|
|
64
|
+
*/
|
|
65
|
+
panel(pos: any, width: any, height: any, options?: {}): any;
|
|
66
|
+
/**
|
|
67
|
+
* @method dim
|
|
68
|
+
* @description Adds a full-screen dimmer (modal backdrop).
|
|
69
|
+
* @returns {Object} - Element handle
|
|
70
|
+
*/
|
|
71
|
+
dim(opacity?: number): any;
|
|
72
|
+
/**
|
|
73
|
+
* @method label
|
|
74
|
+
* @description Adds a text label.
|
|
75
|
+
* @returns {Object} - Element handle with setText(text)
|
|
76
|
+
*/
|
|
77
|
+
label(pos: any, text: any, options?: {}): any;
|
|
78
|
+
/**
|
|
79
|
+
* @method button
|
|
80
|
+
* @description Adds an interactive button (panel + centered label).
|
|
81
|
+
* @param {Object} [options] - { onClick, accent, font, color }
|
|
82
|
+
* @returns {Object} - Element handle with setText(text), setEnabled(bool)
|
|
83
|
+
*/
|
|
84
|
+
button(pos: any, text: any, width: any, height: any, options?: any): any;
|
|
85
|
+
/**
|
|
86
|
+
* @method textField
|
|
87
|
+
* @description Adds an editable single-line text field.
|
|
88
|
+
* @param {Object} [options] - { value, placeholder, onChange, maxLength, font }
|
|
89
|
+
* @returns {Object} - Element handle with getValue()/setValue(text)
|
|
90
|
+
*/
|
|
91
|
+
textField(pos: any, width: any, height: any, options?: any): any;
|
|
92
|
+
/** @private */
|
|
93
|
+
private _makeQuad;
|
|
94
|
+
/** @private */
|
|
95
|
+
private _register;
|
|
96
|
+
/** @private */
|
|
97
|
+
private _toScreen;
|
|
98
|
+
/** @private */
|
|
99
|
+
private _hitTest;
|
|
100
|
+
/**
|
|
101
|
+
* @method isOver
|
|
102
|
+
* @description Whether an interactive element is under the given page point —
|
|
103
|
+
* useful to suppress game clicks behind the UI.
|
|
104
|
+
*/
|
|
105
|
+
isOver(clientX: any, clientY: any): boolean;
|
|
106
|
+
/** @private */
|
|
107
|
+
private _handleMove;
|
|
108
|
+
/** @private */
|
|
109
|
+
private _handleDown;
|
|
110
|
+
/** @private */
|
|
111
|
+
private _handleKey;
|
|
112
|
+
/**
|
|
113
|
+
* @method destroy
|
|
114
|
+
* @description Removes all UI objects and detaches input listeners.
|
|
115
|
+
*/
|
|
116
|
+
destroy(): void;
|
|
117
|
+
}
|
|
118
|
+
declare namespace UI {
|
|
119
|
+
let LAYER: number;
|
|
120
|
+
}
|
|
121
|
+
import Camera from "./Camera.js";
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export default Behaviour;
|
|
2
|
+
/**
|
|
3
|
+
* @class Behaviour
|
|
4
|
+
* @description Base class for custom per-object game logic. Subclass it and
|
|
5
|
+
* override `start()` (called once, the first update after being added) and
|
|
6
|
+
* `update(deltaTime)` (called every frame the owner is active). Add it to a
|
|
7
|
+
* GameObject like any other component; it is ticked by `Scene.update(dt)` via
|
|
8
|
+
* `GameObject.update(dt)`.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* class Spinner extends Behaviour {
|
|
12
|
+
* start() { this.speed = 2; }
|
|
13
|
+
* update(dt) { this.gameObject.transform.rotation += this.speed * dt; }
|
|
14
|
+
* }
|
|
15
|
+
* obj.addComponent(new Spinner());
|
|
16
|
+
*/
|
|
17
|
+
declare class Behaviour {
|
|
18
|
+
id: string;
|
|
19
|
+
parentObject: any;
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
/** @private */
|
|
22
|
+
private _started;
|
|
23
|
+
/**
|
|
24
|
+
* @member gameObject
|
|
25
|
+
* @description Convenience accessor for the owning GameObject.
|
|
26
|
+
*/
|
|
27
|
+
get gameObject(): any;
|
|
28
|
+
/**
|
|
29
|
+
* @method setParent
|
|
30
|
+
* @description Sets the owning object. Called automatically by addComponent.
|
|
31
|
+
* @param {Object} parent - The owning GameObject (or Instance)
|
|
32
|
+
*/
|
|
33
|
+
setParent(parent: any): void;
|
|
34
|
+
/**
|
|
35
|
+
* @method getParent
|
|
36
|
+
* @description Returns the owning object
|
|
37
|
+
* @returns {Object} - The owning object
|
|
38
|
+
*/
|
|
39
|
+
getParent(): any;
|
|
40
|
+
/**
|
|
41
|
+
* @method start
|
|
42
|
+
* @description Called once before the first update. Override in subclasses.
|
|
43
|
+
*/
|
|
44
|
+
start(): void;
|
|
45
|
+
/**
|
|
46
|
+
* @method update
|
|
47
|
+
* @description Called every active frame. Override in subclasses.
|
|
48
|
+
* @param {number} deltaTime - Seconds since the previous frame (time-scaled)
|
|
49
|
+
*/
|
|
50
|
+
update(deltaTime: number): void;
|
|
51
|
+
/**
|
|
52
|
+
* @method onDestroy
|
|
53
|
+
* @description Called when the behaviour is removed. Override for cleanup.
|
|
54
|
+
*/
|
|
55
|
+
onDestroy(): void;
|
|
56
|
+
/**
|
|
57
|
+
* @method onCollisionEnter
|
|
58
|
+
* @description Called when the owner's body starts touching another. Requires
|
|
59
|
+
* the Physics world to be ticked. Override in subclasses.
|
|
60
|
+
* @param {Object} other - The other GameObject/Instance (or null)
|
|
61
|
+
* @param {Object} contact - The planck contact
|
|
62
|
+
*/
|
|
63
|
+
onCollisionEnter(other: any, contact: any): void;
|
|
64
|
+
/**
|
|
65
|
+
* @method onCollisionExit
|
|
66
|
+
* @description Called when the owner's body stops touching another.
|
|
67
|
+
* @param {Object} other - The other GameObject/Instance (or null)
|
|
68
|
+
* @param {Object} contact - The planck contact
|
|
69
|
+
*/
|
|
70
|
+
onCollisionExit(other: any, contact: any): void;
|
|
71
|
+
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import BoxColliderDebug from "./BoxColliderDebug";
|
|
3
|
-
import Collider from "./Collider";
|
|
4
|
-
import { Vector2 } from "../Physics";
|
|
5
|
-
import RigidBody from "./RigidBody";
|
|
6
|
-
import GameObject from "./GameObject";
|
|
1
|
+
export default BoxCollider;
|
|
7
2
|
/**
|
|
8
3
|
* @class BoxCollider
|
|
9
4
|
* @extends Collider
|
|
@@ -16,11 +11,16 @@ import GameObject from "./GameObject";
|
|
|
16
11
|
* @param {GameObject} parentObject - The parent object of the collider
|
|
17
12
|
*/
|
|
18
13
|
declare class BoxCollider extends Collider {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
constructor(rigidbody: any, fixtureSize: any, density: any, friction: any, restitution: any, isSensor?: boolean, parentObject?: any, filter?: any);
|
|
15
|
+
collider: any;
|
|
16
|
+
fixtureSize: any;
|
|
17
|
+
/**
|
|
18
|
+
* @method debugShape
|
|
19
|
+
* @description Lazily builds the debug visualization on first access, so a
|
|
20
|
+
* collider stays free of any GameObject/GL allocation until it is debugged.
|
|
21
|
+
* @returns {BoxColliderDebug} - The debug shape
|
|
22
|
+
*/
|
|
23
|
+
get debugShape(): BoxColliderDebug;
|
|
24
24
|
/**
|
|
25
25
|
* @method showDebugShape
|
|
26
26
|
* @description Shows the debug shape of the collider
|
|
@@ -35,7 +35,7 @@ declare class BoxCollider extends Collider {
|
|
|
35
35
|
* @method getFixtureSize
|
|
36
36
|
* @description Returns the size of the collider
|
|
37
37
|
*/
|
|
38
|
-
getFixtureSize():
|
|
38
|
+
getFixtureSize(): any;
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
import Collider from "./Collider.js";
|
|
41
|
+
import BoxColliderDebug from "./BoxColliderDebug.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default BoxColliderDebug;
|
|
2
|
+
/**
|
|
3
|
+
* @class BoxColliderDebug
|
|
4
|
+
* @param {Rigidbody} rigidbody - The rigidbody to attach the collider to
|
|
5
|
+
* @param {Color} color - The color of the collider
|
|
6
|
+
*/
|
|
7
|
+
declare class BoxColliderDebug {
|
|
8
|
+
constructor(rigidbody: any, color?: any);
|
|
9
|
+
rigidbody: any;
|
|
10
|
+
physics: any;
|
|
11
|
+
scale: any;
|
|
12
|
+
color: any;
|
|
13
|
+
gameObject: GameObject;
|
|
14
|
+
}
|
|
15
|
+
import GameObject from "./GameObject.js";
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import CircleColliderDebug from "./CircleColliderDebug";
|
|
3
|
-
import Collider from "./Collider";
|
|
4
|
-
import RigidBody from "./RigidBody";
|
|
1
|
+
export default CircleCollider;
|
|
5
2
|
/**
|
|
6
3
|
* @class CircleCollider
|
|
7
4
|
* @extends Collider
|
|
@@ -14,11 +11,16 @@ import RigidBody from "./RigidBody";
|
|
|
14
11
|
* @param {GameObject} parentObject - The parent object of the collider
|
|
15
12
|
*/
|
|
16
13
|
declare class CircleCollider extends Collider {
|
|
17
|
-
radius:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
constructor(rigidbody: any, radius: any, density: any, friction: any, restitution: any, isSensor?: boolean, parentObject?: any, filter?: any);
|
|
15
|
+
collider: any;
|
|
16
|
+
radius: any;
|
|
17
|
+
/**
|
|
18
|
+
* @method debugShape
|
|
19
|
+
* @description Lazily builds the debug visualization on first access, so a
|
|
20
|
+
* collider stays free of any GameObject/GL allocation until it is debugged.
|
|
21
|
+
* @returns {CircleColliderDebug} - The debug shape
|
|
22
|
+
*/
|
|
23
|
+
get debugShape(): CircleColliderDebug;
|
|
22
24
|
/**
|
|
23
25
|
* @method showDebugShape
|
|
24
26
|
* @description Shows the debug shape of the collider
|
|
@@ -33,7 +35,7 @@ declare class CircleCollider extends Collider {
|
|
|
33
35
|
* @method getRadius
|
|
34
36
|
* @description Returns the radius of the collider
|
|
35
37
|
*/
|
|
36
|
-
getRadius():
|
|
38
|
+
getRadius(): any;
|
|
37
39
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
import Collider from "./Collider.js";
|
|
41
|
+
import CircleColliderDebug from "./CircleColliderDebug.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default CircleColliderDebug;
|
|
2
|
+
/**
|
|
3
|
+
* @class CircleColliderDebug
|
|
4
|
+
* @param {Rigidbody} rigidbody - The rigidbody to attach the collider to
|
|
5
|
+
* @param {Color} color - The color of the collider
|
|
6
|
+
*/
|
|
7
|
+
declare class CircleColliderDebug {
|
|
8
|
+
constructor(rigidbody: any, color?: any);
|
|
9
|
+
rigidbody: any;
|
|
10
|
+
physics: any;
|
|
11
|
+
scale: any;
|
|
12
|
+
color: any;
|
|
13
|
+
gameObject: GameObject;
|
|
14
|
+
}
|
|
15
|
+
import GameObject from "./GameObject.js";
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export default Collider;
|
|
2
|
+
/**
|
|
3
|
+
* @class Collider
|
|
4
|
+
* @param {Rigidbody} rigidbody - The rigidbody to attach the collider to
|
|
5
|
+
* @param {boolean} isSensor - Whether the collider is a sensor
|
|
6
|
+
* @param {GameObject} parentObject - The parent object of the collider
|
|
7
|
+
*/
|
|
8
|
+
declare class Collider {
|
|
9
|
+
constructor(rigidbody: any, isSensor?: boolean, parentObject?: any);
|
|
10
|
+
rigidbody: any;
|
|
11
|
+
parentObject: any;
|
|
12
|
+
isSensor: boolean;
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
/** @private */
|
|
16
|
+
private _debugShape;
|
|
17
|
+
/**
|
|
18
|
+
* @method syncDebugShape
|
|
19
|
+
* @description Mirrors a transform onto the debug shape, but only if one has
|
|
20
|
+
* already been created. Never forces lazy creation.
|
|
21
|
+
* @param {Transform} transform - The source transform
|
|
22
|
+
*/
|
|
23
|
+
syncDebugShape(transform: Transform): void;
|
|
24
|
+
/**
|
|
25
|
+
* @method setFilter
|
|
26
|
+
* @description Sets the raw planck collision filter on this collider's
|
|
27
|
+
* fixture. Two fixtures collide only when each one's category bit is present
|
|
28
|
+
* in the other's mask. Subclasses must have created `this.collider`
|
|
29
|
+
* (the fixture) first.
|
|
30
|
+
* @param {Object} filter - { category, mask, group }
|
|
31
|
+
* @param {number} [filter.category=0x0001] - This fixture's category bits
|
|
32
|
+
* @param {number} [filter.mask=0xFFFF] - Bits this fixture collides with
|
|
33
|
+
* @param {number} [filter.group=0] - Group index (>0 always collide, <0 never)
|
|
34
|
+
* @returns {Collider} - this
|
|
35
|
+
*/
|
|
36
|
+
setFilter({ category, mask, group }?: {
|
|
37
|
+
category?: number;
|
|
38
|
+
mask?: number;
|
|
39
|
+
group?: number;
|
|
40
|
+
}): Collider;
|
|
41
|
+
/** @private */
|
|
42
|
+
private _filter;
|
|
43
|
+
/**
|
|
44
|
+
* @method setCategory
|
|
45
|
+
* @description Sets which named layer this collider belongs to (its category
|
|
46
|
+
* bits), preserving the current mask/group. See {@link CollisionLayers}.
|
|
47
|
+
* @param {string|number} layer - Layer name or raw category bits
|
|
48
|
+
* @returns {Collider} - this
|
|
49
|
+
*/
|
|
50
|
+
setCategory(layer: string | number): Collider;
|
|
51
|
+
/**
|
|
52
|
+
* @method setCollidesWith
|
|
53
|
+
* @description Sets which layers this collider can collide with (its mask),
|
|
54
|
+
* preserving the current category/group.
|
|
55
|
+
* @param {string|string[]|number} layers - Layer name(s) or raw mask bits
|
|
56
|
+
* @returns {Collider} - this
|
|
57
|
+
*/
|
|
58
|
+
setCollidesWith(layers: string | string[] | number): Collider;
|
|
59
|
+
/**
|
|
60
|
+
* @method getFilter
|
|
61
|
+
* @description Returns the last applied filter, or null if none was set.
|
|
62
|
+
* @returns {{category:number, mask:number, group:number}|null}
|
|
63
|
+
*/
|
|
64
|
+
getFilter(): {
|
|
65
|
+
category: number;
|
|
66
|
+
mask: number;
|
|
67
|
+
group: number;
|
|
68
|
+
} | null;
|
|
69
|
+
/**
|
|
70
|
+
* @method _applyFilterSpec
|
|
71
|
+
* @description Applies a friendly filter spec from a constructor, accepting
|
|
72
|
+
* layer names or raw bits. Spec: { category, collidesWith, group }.
|
|
73
|
+
* @private
|
|
74
|
+
*/
|
|
75
|
+
private _applyFilterSpec;
|
|
76
|
+
/**
|
|
77
|
+
* @method getRigidBody
|
|
78
|
+
* @description Returns the rigidbody of the collider
|
|
79
|
+
*/
|
|
80
|
+
getRigidBody(): any;
|
|
81
|
+
/**
|
|
82
|
+
* @method getCollider
|
|
83
|
+
* @description Returns the collider
|
|
84
|
+
*/
|
|
85
|
+
getCollider(): any;
|
|
86
|
+
/**
|
|
87
|
+
* @method setParent
|
|
88
|
+
* @description Sets the parent object of the collider
|
|
89
|
+
*/
|
|
90
|
+
setParent(parent: any): void;
|
|
91
|
+
/**
|
|
92
|
+
* @method getParent
|
|
93
|
+
* @description Returns the parent object of the collider
|
|
94
|
+
*/
|
|
95
|
+
getParent(): any;
|
|
96
|
+
}
|