emeraldengine 2.2.1 → 3.1.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 +2198 -968
- package/dist/types/index.d.ts +75 -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} +6 -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} +75 -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 +81 -0
- package/dist/types/src/ParticleEmitter.d.ts +131 -0
- package/dist/types/src/Physics.d.ts +337 -0
- 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 +102 -0
- package/dist/types/src/components/GameObject.d.ts +135 -0
- package/dist/types/src/components/PolygonCollider.d.ts +33 -0
- package/dist/types/src/components/RigidBody.d.ts +456 -0
- package/dist/types/src/importers/Aseprite.d.ts +79 -0
- package/dist/types/src/importers/ForgeLevel.d.ts +97 -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/Gamepad.d.ts +102 -0
- package/dist/types/src/managers/IDManager.d.ts +31 -0
- package/dist/types/src/managers/InputManager.d.ts +381 -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/dist/types/src/physics/AABB.d.ts +92 -0
- package/dist/types/src/physics/Body.d.ts +435 -0
- package/dist/types/src/physics/BodyType.d.ts +6 -0
- package/dist/types/src/physics/BroadPhase.d.ts +210 -0
- package/dist/types/src/physics/Collision.d.ts +102 -0
- package/dist/types/src/physics/Contact.d.ts +206 -0
- package/dist/types/src/physics/ContactSolver.d.ts +108 -0
- package/dist/types/src/physics/Distance.d.ts +54 -0
- package/dist/types/src/physics/DistanceJoint.d.ts +90 -0
- package/dist/types/src/physics/Fixture.d.ts +221 -0
- package/dist/types/src/physics/Island.d.ts +52 -0
- package/dist/types/src/physics/Joint.d.ts +59 -0
- package/dist/types/src/physics/Math2D.d.ts +371 -0
- package/dist/types/src/physics/RevoluteJoint.d.ts +119 -0
- package/dist/types/src/physics/Settings.d.ts +22 -0
- package/dist/types/src/physics/Shapes.d.ts +207 -0
- package/dist/types/src/physics/TimeOfImpact.d.ts +22 -0
- package/dist/types/src/physics/World.d.ts +274 -0
- package/dist/types/src/physics/index.d.ts +34 -0
- package/index.js +78 -0
- package/package.json +73 -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 +26 -18
- package/src/Coroutine.js +259 -0
- package/src/DebugOverlay.js +246 -0
- package/src/Drawable.js +842 -582
- 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 +308 -127
- package/src/Interpolator.js +124 -0
- package/src/Material.js +202 -0
- package/src/MathUtils.js +134 -0
- package/src/ParticleEmitter.js +284 -0
- package/src/Physics.js +431 -40
- 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 +29 -12
- package/src/components/BoxColliderDebug.js +3 -4
- package/src/components/CircleCollider.js +26 -12
- package/src/components/CircleColliderDebug.js +25 -24
- package/src/components/Collider.js +150 -34
- package/src/components/GameObject.js +130 -21
- package/src/components/PolygonCollider.js +55 -0
- package/src/components/RigidBody.js +556 -8
- package/src/importers/Aseprite.js +142 -0
- package/src/importers/ForgeLevel.js +581 -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/Gamepad.js +126 -0
- package/src/managers/IDManager.js +24 -2
- package/src/managers/InputManager.js +905 -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/src/physics/AABB.js +207 -0
- package/src/physics/Body.js +862 -0
- package/src/physics/BodyType.js +16 -0
- package/src/physics/BroadPhase.js +641 -0
- package/src/physics/Collision.js +534 -0
- package/src/physics/Contact.js +500 -0
- package/src/physics/ContactSolver.js +526 -0
- package/src/physics/Distance.js +403 -0
- package/src/physics/DistanceJoint.js +227 -0
- package/src/physics/Fixture.js +346 -0
- package/src/physics/Island.js +203 -0
- package/src/physics/Joint.js +78 -0
- package/src/physics/Math2D.js +573 -0
- package/src/physics/RevoluteJoint.js +278 -0
- package/src/physics/Settings.js +78 -0
- package/src/physics/Shapes.js +549 -0
- package/src/physics/TimeOfImpact.js +87 -0
- package/src/physics/World.js +731 -0
- package/src/physics/index.js +79 -0
- 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/Physics.d.ts +0 -139
- 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,44 @@
|
|
|
1
|
+
export default SceneManager;
|
|
2
|
+
/**
|
|
3
|
+
* @class SceneManager
|
|
4
|
+
* @description Manages the scene for the game
|
|
5
|
+
*/
|
|
6
|
+
declare class SceneManager {
|
|
7
|
+
/**
|
|
8
|
+
* @method setScene
|
|
9
|
+
* @description Sets the scene
|
|
10
|
+
* @param {Scene} scene - The scene to set
|
|
11
|
+
*/
|
|
12
|
+
static setScene(scene: Scene): void;
|
|
13
|
+
/**
|
|
14
|
+
* @method getScene
|
|
15
|
+
* @description Returns the scene
|
|
16
|
+
* @returns {Scene} - The scene
|
|
17
|
+
*/
|
|
18
|
+
static getScene(): Scene;
|
|
19
|
+
/**
|
|
20
|
+
* @method transitionTo
|
|
21
|
+
* @description Switches the active scene, optionally behind a ScreenEffects
|
|
22
|
+
* fade. With `screenEffects` provided the screen fades out, the scene is
|
|
23
|
+
* swapped (and your optional `onSwap` runs) while covered, then fades back in.
|
|
24
|
+
* Without it the swap happens immediately.
|
|
25
|
+
*
|
|
26
|
+
* @param {Scene} scene - The scene to make active
|
|
27
|
+
* @param {Object} [options]
|
|
28
|
+
* @param {ScreenEffects} [options.screenEffects] - Effects layer to fade with
|
|
29
|
+
* @param {Function} [options.onSwap] - `(scene) => void|Promise`, run during
|
|
30
|
+
* the covered swap (e.g. (re)build the new scene's contents)
|
|
31
|
+
* @param {number} [options.duration] - Fade duration (seconds)
|
|
32
|
+
* @param {Color} [options.color] - Fade color
|
|
33
|
+
* @returns {Promise<Scene>} - Resolves with the new scene
|
|
34
|
+
*/
|
|
35
|
+
static transitionTo(scene: Scene, options?: {
|
|
36
|
+
screenEffects?: ScreenEffects;
|
|
37
|
+
onSwap?: Function;
|
|
38
|
+
duration?: number;
|
|
39
|
+
color?: Color;
|
|
40
|
+
}): Promise<Scene>;
|
|
41
|
+
}
|
|
42
|
+
declare namespace SceneManager {
|
|
43
|
+
let scene: any;
|
|
44
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class ShaderManager
|
|
3
|
+
* @description Manages the shaders for the game
|
|
4
|
+
*/
|
|
5
|
+
export class ShaderManager {
|
|
6
|
+
constructor(gl: any);
|
|
7
|
+
gl: any;
|
|
8
|
+
shaders: Map<any, any>;
|
|
9
|
+
activeShader: any;
|
|
10
|
+
/**
|
|
11
|
+
* @method createShader
|
|
12
|
+
* @description Creates a shader
|
|
13
|
+
* @param {string} name - The name of the shader
|
|
14
|
+
* @param {string} vertexSource - The vertex shader source
|
|
15
|
+
* @param {string} fragmentSource - The fragment shader source
|
|
16
|
+
*/
|
|
17
|
+
createShader(name: string, vertexSource: string, fragmentSource: string): {
|
|
18
|
+
program: any;
|
|
19
|
+
attribLocations: any;
|
|
20
|
+
uniformLocations: any;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* @method compileShader
|
|
24
|
+
* @description Compiles a shader
|
|
25
|
+
* @param {string} source - The shader source
|
|
26
|
+
* @param {number} type - The type of shader
|
|
27
|
+
*/
|
|
28
|
+
compileShader(source: string, type: number): any;
|
|
29
|
+
/**
|
|
30
|
+
* @method useShader
|
|
31
|
+
* @description Uses a shader
|
|
32
|
+
* @param {string} name - The name of the shader
|
|
33
|
+
*/
|
|
34
|
+
useShader(name: string): any;
|
|
35
|
+
/**
|
|
36
|
+
* @method getActiveShader
|
|
37
|
+
* @description Returns the active shader
|
|
38
|
+
* @returns {Object} - The active shader
|
|
39
|
+
*/
|
|
40
|
+
getActiveShader(): any;
|
|
41
|
+
/**
|
|
42
|
+
* @method getAttributeLocations
|
|
43
|
+
* @description Returns the attribute locations for a shader program
|
|
44
|
+
* @param {WebGLProgram} program - The shader program
|
|
45
|
+
* @returns {Object} - The attribute locations
|
|
46
|
+
*/
|
|
47
|
+
getAttributeLocations(program: WebGLProgram): any;
|
|
48
|
+
/**
|
|
49
|
+
* @method getUniformLocations
|
|
50
|
+
* @description Returns the uniform locations for a shader program
|
|
51
|
+
* @param {WebGLProgram} program - The shader program
|
|
52
|
+
* @returns {Object} - The uniform locations
|
|
53
|
+
*/
|
|
54
|
+
getUniformLocations(program: WebGLProgram): any;
|
|
55
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export default TextureManager;
|
|
2
|
+
/**
|
|
3
|
+
* @class TextureManager
|
|
4
|
+
* @description Caches loaded images and GL textures so that many drawables
|
|
5
|
+
* sharing the same texture path download and upload the image only once.
|
|
6
|
+
*
|
|
7
|
+
* Textures are immutable after upload in this engine, so the same GL texture
|
|
8
|
+
* object can safely be bound by any number of objects. The GL-texture cache is
|
|
9
|
+
* keyed by path *and* filter mode, because pixel-art (NEAREST) and smooth
|
|
10
|
+
* (LINEAR) sampling require separate texture objects.
|
|
11
|
+
*/
|
|
12
|
+
declare class TextureManager {
|
|
13
|
+
/**
|
|
14
|
+
* @method loadImage
|
|
15
|
+
* @description Loads (and caches) an HTMLImageElement for a given path.
|
|
16
|
+
* Concurrent requests for the same path share a single in-flight load.
|
|
17
|
+
* @param {string} path - The path (or data URL) of the image
|
|
18
|
+
* @returns {Promise<HTMLImageElement>} - The loaded image
|
|
19
|
+
*/
|
|
20
|
+
static loadImage(path: string): Promise<HTMLImageElement>;
|
|
21
|
+
/**
|
|
22
|
+
* @method getTexture
|
|
23
|
+
* @description Returns a cached GL texture for the given path, creating and
|
|
24
|
+
* uploading it on first request. Subsequent calls reuse the same texture.
|
|
25
|
+
* @param {string} path - The path (or data URL) of the texture
|
|
26
|
+
* @param {boolean} pixelart - Whether to sample with NEAREST (pixel art) filtering
|
|
27
|
+
* @returns {Promise<{texture: WebGLTexture, width: number, height: number}>}
|
|
28
|
+
*/
|
|
29
|
+
static getTexture(path: string, pixelart?: boolean): Promise<{
|
|
30
|
+
texture: WebGLTexture;
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* @method _upload
|
|
36
|
+
* @description Loads the image (via the shared image cache) and uploads it
|
|
37
|
+
* as a GL texture with the requested filtering.
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
private static _upload;
|
|
41
|
+
/**
|
|
42
|
+
* @method restoreAll
|
|
43
|
+
* @description Re-uploads every cached texture after a WebGL context loss.
|
|
44
|
+
* The image cache survives the loss, so this is upload-only (no network).
|
|
45
|
+
* Reference counts are untouched: they track logical ownership by
|
|
46
|
+
* drawables, which still exist.
|
|
47
|
+
*/
|
|
48
|
+
static restoreAll(): void;
|
|
49
|
+
/**
|
|
50
|
+
* @method preload
|
|
51
|
+
* @description Eagerly loads a list of texture paths so they are ready (and
|
|
52
|
+
* cached) before the first frame that needs them.
|
|
53
|
+
* @param {string[]} paths - The texture paths to preload
|
|
54
|
+
* @param {boolean} pixelart - Whether to use pixel-art filtering
|
|
55
|
+
* @returns {Promise<void>}
|
|
56
|
+
*/
|
|
57
|
+
static preload(paths: string[], pixelart?: boolean): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* @method has
|
|
60
|
+
* @description Checks whether a GL texture is already cached for a path
|
|
61
|
+
* @param {string} path - The texture path
|
|
62
|
+
* @param {boolean} pixelart - Whether the pixel-art variant is meant
|
|
63
|
+
* @returns {boolean}
|
|
64
|
+
*/
|
|
65
|
+
static has(path: string, pixelart?: boolean): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* @method retain
|
|
68
|
+
* @description Increments the reference count for a cached texture. Every
|
|
69
|
+
* Drawable that resolves a texture through getTexture() retains it; when the
|
|
70
|
+
* last user releases it, the GL texture is freed. Call retain/release in
|
|
71
|
+
* pairs (Drawable.dispose does the release for you).
|
|
72
|
+
* @param {string} path - The texture path
|
|
73
|
+
* @param {boolean} pixelart - Whether the pixel-art variant is meant
|
|
74
|
+
*/
|
|
75
|
+
static retain(path: string, pixelart?: boolean): void;
|
|
76
|
+
/**
|
|
77
|
+
* @method release
|
|
78
|
+
* @description Decrements a texture's reference count; when it reaches zero
|
|
79
|
+
* the GL texture is deleted and dropped from the cache (the CPU-side image
|
|
80
|
+
* cache is kept so a later reload is cheap).
|
|
81
|
+
* @param {string} path - The texture path
|
|
82
|
+
* @param {boolean} pixelart - Whether the pixel-art variant is meant
|
|
83
|
+
*/
|
|
84
|
+
static release(path: string, pixelart?: boolean): void;
|
|
85
|
+
/**
|
|
86
|
+
* @method refCount
|
|
87
|
+
* @description Current reference count for a texture (0 if uncached).
|
|
88
|
+
* @returns {number}
|
|
89
|
+
*/
|
|
90
|
+
static refCount(path: any, pixelart?: boolean): number;
|
|
91
|
+
/**
|
|
92
|
+
* @method clear
|
|
93
|
+
* @description Deletes all cached GL textures and clears the image cache.
|
|
94
|
+
* Useful when tearing down a context or freeing memory between levels.
|
|
95
|
+
*/
|
|
96
|
+
static clear(): void;
|
|
97
|
+
}
|
|
98
|
+
declare namespace TextureManager {
|
|
99
|
+
let images: Map<any, any>;
|
|
100
|
+
let textures: Map<any, any>;
|
|
101
|
+
let refs: Map<any, any>;
|
|
102
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export default Particle;
|
|
2
|
+
/**
|
|
3
|
+
* @class Particle
|
|
4
|
+
* @description Represents a particle in the particle system
|
|
5
|
+
* @param {InstancedTexture} instancedTexture - The instanced texture
|
|
6
|
+
* @param {Vector3} position - The position of the particle
|
|
7
|
+
* @param {number} rotation - The rotation of the particle
|
|
8
|
+
* @param {Vector2} scale - The scale of the particle
|
|
9
|
+
* @param {ParticleSettings} settings - The settings for the particle
|
|
10
|
+
*/
|
|
11
|
+
declare class Particle {
|
|
12
|
+
/** @private */
|
|
13
|
+
private static _normColor;
|
|
14
|
+
constructor(instancedTexture: any, position: any, rotation: any, scale: any, settings: any, velocity: any);
|
|
15
|
+
/**
|
|
16
|
+
* @method reset
|
|
17
|
+
* @description (Re)initializes the particle. Used by the pool so particle
|
|
18
|
+
* objects can be reused without allocating. `velocity` overrides
|
|
19
|
+
* settings.velocity when provided (avoids a ParticleSettings allocation per
|
|
20
|
+
* particle).
|
|
21
|
+
*/
|
|
22
|
+
reset(instancedTexture: any, position: any, rotation: any, scale: any, settings: any, velocity: any): void;
|
|
23
|
+
settings: any;
|
|
24
|
+
lifetime: any;
|
|
25
|
+
age: number;
|
|
26
|
+
velocity: {
|
|
27
|
+
x: any;
|
|
28
|
+
y: any;
|
|
29
|
+
};
|
|
30
|
+
gravity: {
|
|
31
|
+
x: any;
|
|
32
|
+
y: any;
|
|
33
|
+
};
|
|
34
|
+
instance: Instance;
|
|
35
|
+
/** @private */
|
|
36
|
+
private _baseScaleX;
|
|
37
|
+
/** @private */
|
|
38
|
+
private _baseScaleY;
|
|
39
|
+
/** @private */
|
|
40
|
+
private _colFrom;
|
|
41
|
+
/** @private */
|
|
42
|
+
private _colTo;
|
|
43
|
+
instancedTexture: any;
|
|
44
|
+
/** @private */
|
|
45
|
+
private _applyOverLife;
|
|
46
|
+
/**
|
|
47
|
+
* @method update
|
|
48
|
+
* @description Updates the particle
|
|
49
|
+
* @param {number} dt - The delta time
|
|
50
|
+
*/
|
|
51
|
+
update(dt: number): void;
|
|
52
|
+
/**
|
|
53
|
+
* @method isAlive
|
|
54
|
+
* @description Checks if the particle is alive
|
|
55
|
+
* @returns {boolean} - True if the particle is alive
|
|
56
|
+
*/
|
|
57
|
+
isAlive(): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* @method destroy
|
|
60
|
+
* @description Destroys the particle
|
|
61
|
+
*/
|
|
62
|
+
destroy(): void;
|
|
63
|
+
}
|
|
64
|
+
import Instance from "../Instance.js";
|
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
interface ParticleSettingsConfig {
|
|
3
|
-
lifetime?: number;
|
|
4
|
-
velocity?: Vector2;
|
|
5
|
-
gravity?: Vector2;
|
|
6
|
-
amount?: number;
|
|
7
|
-
direction?: Vector2;
|
|
8
|
-
spread?: number;
|
|
9
|
-
emissionRate?: number;
|
|
10
|
-
frame?: number;
|
|
11
|
-
offset?: number;
|
|
12
|
-
rotation?: number;
|
|
13
|
-
scale?: Vector2;
|
|
14
|
-
animation?: any;
|
|
15
|
-
}
|
|
1
|
+
export default ParticleSettings;
|
|
16
2
|
/**
|
|
17
3
|
* @class ParticleSettings
|
|
18
4
|
* @description Represents the settings for a particle system
|
|
@@ -30,6 +16,23 @@ interface ParticleSettingsConfig {
|
|
|
30
16
|
* @param {Array} animation - The animation of the particle
|
|
31
17
|
*/
|
|
32
18
|
declare class ParticleSettings {
|
|
19
|
+
constructor({ lifetime, velocity, gravity, amount, direction, spread, emissionRate, frame, offset, rotation, scale, animation, shape, shapeRadius, shapeSize, scaleOverLife, alphaOverLife, colorOverLife, rotationSpeed, drag, }?: {
|
|
20
|
+
lifetime?: number;
|
|
21
|
+
velocity?: Vector2;
|
|
22
|
+
gravity?: Vector2;
|
|
23
|
+
amount?: number;
|
|
24
|
+
direction?: Vector2;
|
|
25
|
+
spread?: number;
|
|
26
|
+
emissionRate?: number;
|
|
27
|
+
shape?: string;
|
|
28
|
+
shapeRadius?: number;
|
|
29
|
+
shapeSize?: Vector2;
|
|
30
|
+
scaleOverLife?: any;
|
|
31
|
+
alphaOverLife?: any;
|
|
32
|
+
colorOverLife?: any;
|
|
33
|
+
rotationSpeed?: number;
|
|
34
|
+
drag?: number;
|
|
35
|
+
});
|
|
33
36
|
lifetime: number;
|
|
34
37
|
velocity: Vector2;
|
|
35
38
|
gravity: Vector2;
|
|
@@ -37,13 +40,18 @@ declare class ParticleSettings {
|
|
|
37
40
|
direction: Vector2;
|
|
38
41
|
spread: number;
|
|
39
42
|
emissionRate: number;
|
|
40
|
-
frame
|
|
41
|
-
offset
|
|
42
|
-
rotation
|
|
43
|
-
scale
|
|
44
|
-
animation
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
frame: any;
|
|
44
|
+
offset: any;
|
|
45
|
+
rotation: any;
|
|
46
|
+
scale: any;
|
|
47
|
+
animation: any;
|
|
48
|
+
shape: string;
|
|
49
|
+
shapeRadius: number;
|
|
50
|
+
shapeSize: Vector2;
|
|
51
|
+
scaleOverLife: any;
|
|
52
|
+
alphaOverLife: any;
|
|
53
|
+
colorOverLife: any;
|
|
54
|
+
rotationSpeed: number;
|
|
55
|
+
drag: number;
|
|
47
56
|
}
|
|
48
|
-
|
|
49
|
-
//# sourceMappingURL=ParticleSettings.d.ts.map
|
|
57
|
+
import { Vector2 } from "../Physics.js";
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import GameObject from "../components/GameObject";
|
|
2
|
-
import InstancedTexture from "../InstancedTexture";
|
|
3
|
-
import { Vector2, Vector3 } from "../Physics";
|
|
4
|
-
import Particle from "./Particle";
|
|
5
|
-
import ParticleSettings from "./ParticleSettings";
|
|
6
1
|
/**
|
|
7
2
|
* @class Particles
|
|
8
3
|
* @description Represents a particle system
|
|
@@ -16,13 +11,14 @@ import ParticleSettings from "./ParticleSettings";
|
|
|
16
11
|
* @param {ParticleSettings} settings - The settings for the particle system
|
|
17
12
|
*/
|
|
18
13
|
export default class Particles {
|
|
14
|
+
constructor(name: any, texturePath: any, frameWidth: any, frameHeight: any, framesPerRow: any, totalFrames: any, duration?: number, settings?: any);
|
|
19
15
|
settings: ParticleSettings;
|
|
20
16
|
position: Vector3;
|
|
21
|
-
rotation:
|
|
22
|
-
scale:
|
|
23
|
-
particles:
|
|
17
|
+
rotation: any;
|
|
18
|
+
scale: any;
|
|
19
|
+
particles: any[];
|
|
24
20
|
duration: number;
|
|
25
|
-
offset:
|
|
21
|
+
offset: any;
|
|
26
22
|
elapsed: number;
|
|
27
23
|
active: boolean;
|
|
28
24
|
instanceCount: number;
|
|
@@ -31,14 +27,15 @@ export default class Particles {
|
|
|
31
27
|
stopped: boolean;
|
|
32
28
|
gameObject: GameObject;
|
|
33
29
|
instancedTexture: InstancedTexture;
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
/** @private */
|
|
31
|
+
private _pool;
|
|
36
32
|
/**
|
|
37
33
|
* @method play
|
|
38
34
|
* @description Plays the particle system
|
|
39
35
|
* @param {Vector3} newPosition - The position to play the particle system at
|
|
40
36
|
*/
|
|
41
37
|
play(newPosition: Vector3): void;
|
|
38
|
+
lastEmitPosition: Vector3;
|
|
42
39
|
/**
|
|
43
40
|
* @method emitParticles
|
|
44
41
|
* @description Emits particles
|
|
@@ -46,6 +43,14 @@ export default class Particles {
|
|
|
46
43
|
* @param {Vector3} position - The position to emit the particles at
|
|
47
44
|
*/
|
|
48
45
|
emitParticles(count: number, position: Vector3): void;
|
|
46
|
+
/**
|
|
47
|
+
* @method _spawnOffset
|
|
48
|
+
* @description Returns a spawn offset { x, y } from the emitter center based on
|
|
49
|
+
* the configured emitter shape.
|
|
50
|
+
* @param {number} finalAngle - The chosen emission angle (for the cone shape)
|
|
51
|
+
* @private
|
|
52
|
+
*/
|
|
53
|
+
private _spawnOffset;
|
|
49
54
|
/**
|
|
50
55
|
* @method update
|
|
51
56
|
* @description Updates the particle system
|
|
@@ -68,4 +73,7 @@ export default class Particles {
|
|
|
68
73
|
*/
|
|
69
74
|
reset(): void;
|
|
70
75
|
}
|
|
71
|
-
|
|
76
|
+
import ParticleSettings from "./ParticleSettings.js";
|
|
77
|
+
import { Vector3 } from "../Physics.js";
|
|
78
|
+
import GameObject from "../components/GameObject.js";
|
|
79
|
+
import InstancedTexture from "../InstancedTexture.js";
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export default AABB;
|
|
2
|
+
/**
|
|
3
|
+
* @class AABB
|
|
4
|
+
* @description An axis-aligned bounding box in physics space. Used by the
|
|
5
|
+
* broadphase to reject pairs long before any real collision maths runs.
|
|
6
|
+
*/
|
|
7
|
+
declare class AABB {
|
|
8
|
+
/**
|
|
9
|
+
* @method testOverlap
|
|
10
|
+
* @description True when two boxes overlap.
|
|
11
|
+
* @param {AABB} a
|
|
12
|
+
* @param {AABB} b
|
|
13
|
+
* @returns {boolean}
|
|
14
|
+
*/
|
|
15
|
+
static testOverlap(a: AABB, b: AABB): boolean;
|
|
16
|
+
constructor(lowerX?: number, lowerY?: number, upperX?: number, upperY?: number);
|
|
17
|
+
lowerBound: Vec2;
|
|
18
|
+
upperBound: Vec2;
|
|
19
|
+
/**
|
|
20
|
+
* @method set
|
|
21
|
+
* @description Sets all four bounds in place.
|
|
22
|
+
* @param {number} lx
|
|
23
|
+
* @param {number} ly
|
|
24
|
+
* @param {number} ux
|
|
25
|
+
* @param {number} uy
|
|
26
|
+
* @returns {AABB} - this
|
|
27
|
+
*/
|
|
28
|
+
set(lx: number, ly: number, ux: number, uy: number): AABB;
|
|
29
|
+
/**
|
|
30
|
+
* @method copy
|
|
31
|
+
* @description Copies another AABB.
|
|
32
|
+
* @param {AABB} other
|
|
33
|
+
* @returns {AABB} - this
|
|
34
|
+
*/
|
|
35
|
+
copy(other: AABB): AABB;
|
|
36
|
+
/**
|
|
37
|
+
* @method getCenter
|
|
38
|
+
* @description Returns the box center.
|
|
39
|
+
* @returns {Vec2}
|
|
40
|
+
*/
|
|
41
|
+
getCenter(): Vec2;
|
|
42
|
+
/**
|
|
43
|
+
* @method getExtents
|
|
44
|
+
* @description Returns the box half-extents.
|
|
45
|
+
* @returns {Vec2}
|
|
46
|
+
*/
|
|
47
|
+
getExtents(): Vec2;
|
|
48
|
+
/**
|
|
49
|
+
* @method getPerimeter
|
|
50
|
+
* @description Perimeter of the box, the cost function the AABB tree
|
|
51
|
+
* minimizes when choosing where to insert a leaf.
|
|
52
|
+
* @returns {number}
|
|
53
|
+
*/
|
|
54
|
+
getPerimeter(): number;
|
|
55
|
+
/**
|
|
56
|
+
* @method combine
|
|
57
|
+
* @description Sets this box to the union of two others.
|
|
58
|
+
* @param {AABB} a
|
|
59
|
+
* @param {AABB} b
|
|
60
|
+
* @returns {AABB} - this
|
|
61
|
+
*/
|
|
62
|
+
combine(a: AABB, b: AABB): AABB;
|
|
63
|
+
/**
|
|
64
|
+
* @method extend
|
|
65
|
+
* @description Grows the box by `amount` on every side.
|
|
66
|
+
* @param {number} amount
|
|
67
|
+
* @returns {AABB} - this
|
|
68
|
+
*/
|
|
69
|
+
extend(amount: number): AABB;
|
|
70
|
+
/**
|
|
71
|
+
* @method contains
|
|
72
|
+
* @description True when `other` lies entirely inside this box.
|
|
73
|
+
* @param {AABB} other
|
|
74
|
+
* @returns {boolean}
|
|
75
|
+
*/
|
|
76
|
+
contains(other: AABB): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* @method containsPoint
|
|
79
|
+
* @description True when a point lies inside this box.
|
|
80
|
+
* @param {Object} p - `{ x, y }`
|
|
81
|
+
* @returns {boolean}
|
|
82
|
+
*/
|
|
83
|
+
containsPoint(p: any): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* @method rayCast
|
|
86
|
+
* @description Slab test of a ray against this box.
|
|
87
|
+
* @param {Object} input - `{ p1, p2, maxFraction }`
|
|
88
|
+
* @returns {boolean} - True if the ray hits the box within maxFraction
|
|
89
|
+
*/
|
|
90
|
+
rayCast(input: any): boolean;
|
|
91
|
+
}
|
|
92
|
+
import { Vec2 } from "./Math2D.js";
|