emeraldengine 2.2.1 → 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.
Files changed (162) hide show
  1. package/README.md +2359 -968
  2. package/dist/types/index.d.ts +72 -32
  3. package/dist/types/src/Animator.d.ts +50 -0
  4. package/dist/types/{BitmapText.d.ts → src/BitmapText.d.ts} +19 -21
  5. package/dist/types/src/Camera.d.ts +122 -0
  6. package/dist/types/src/CameraController.d.ts +107 -0
  7. package/dist/types/src/CanvasText.d.ts +91 -0
  8. package/dist/types/src/CollisionLayers.d.ts +58 -0
  9. package/dist/types/{Color.d.ts → src/Color.d.ts} +5 -6
  10. package/dist/types/src/Coroutine.d.ts +111 -0
  11. package/dist/types/src/DebugOverlay.d.ts +86 -0
  12. package/dist/types/src/Drawable.d.ts +271 -0
  13. package/dist/types/src/Easing.d.ts +22 -0
  14. package/dist/types/src/Emerald.d.ts +420 -0
  15. package/dist/types/src/EmeraldDB.d.ts +159 -0
  16. package/dist/types/{FPSCounter.d.ts → src/FPSCounter.d.ts} +1 -3
  17. package/dist/types/src/GLUtils.d.ts +4 -0
  18. package/dist/types/{Instance.d.ts → src/Instance.d.ts} +37 -15
  19. package/dist/types/{InstancedTexture.d.ts → src/InstancedTexture.d.ts} +60 -23
  20. package/dist/types/src/Interpolator.d.ts +66 -0
  21. package/dist/types/src/Material.d.ts +87 -0
  22. package/dist/types/src/MathUtils.d.ts +80 -0
  23. package/dist/types/src/ParticleEmitter.d.ts +131 -0
  24. package/dist/types/{Physics.d.ts → src/Physics.d.ts} +88 -20
  25. package/dist/types/src/Pool.d.ts +53 -0
  26. package/dist/types/src/PostEffects.d.ts +68 -0
  27. package/dist/types/src/PostProcessor.d.ts +124 -0
  28. package/dist/types/src/RenderTarget.d.ts +56 -0
  29. package/dist/types/src/Scene.d.ts +62 -0
  30. package/dist/types/src/ScreenEffects.d.ts +111 -0
  31. package/dist/types/src/Serializer.d.ts +86 -0
  32. package/dist/types/src/Shaders.d.ts +2 -0
  33. package/dist/types/{Shapes.d.ts → src/Shapes.d.ts} +4 -6
  34. package/dist/types/src/SpatialGrid.d.ts +50 -0
  35. package/dist/types/src/SpriteBatch.d.ts +89 -0
  36. package/dist/types/src/StateMachine.d.ts +59 -0
  37. package/dist/types/src/Storage.d.ts +89 -0
  38. package/dist/types/{Texture.d.ts → src/Texture.d.ts} +3 -4
  39. package/dist/types/src/TextureAtlas.d.ts +55 -0
  40. package/dist/types/src/Tilemap.d.ts +91 -0
  41. package/dist/types/src/Time.d.ts +53 -0
  42. package/dist/types/src/Timer.d.ts +54 -0
  43. package/dist/types/src/Transform.d.ts +94 -0
  44. package/dist/types/src/Tween.d.ts +81 -0
  45. package/dist/types/src/UI.d.ts +121 -0
  46. package/dist/types/src/components/Behaviour.d.ts +71 -0
  47. package/dist/types/{components → src/components}/BoxCollider.d.ts +14 -14
  48. package/dist/types/src/components/BoxColliderDebug.d.ts +15 -0
  49. package/dist/types/{components → src/components}/CircleCollider.d.ts +14 -12
  50. package/dist/types/src/components/CircleColliderDebug.d.ts +15 -0
  51. package/dist/types/src/components/Collider.d.ts +96 -0
  52. package/dist/types/src/components/GameObject.d.ts +135 -0
  53. package/dist/types/src/components/RigidBody.d.ts +183 -0
  54. package/dist/types/src/importers/Aseprite.d.ts +79 -0
  55. package/dist/types/src/importers/TiledMap.d.ts +62 -0
  56. package/dist/types/{lights → src/lights}/DirectionalLight.d.ts +7 -9
  57. package/dist/types/{lights → src/lights}/PointLight.d.ts +6 -9
  58. package/dist/types/src/managers/AssetManager.d.ts +116 -0
  59. package/dist/types/src/managers/AudioManager.d.ts +259 -0
  60. package/dist/types/{managers → src/managers}/CameraManager.d.ts +8 -8
  61. package/dist/types/{managers → src/managers}/EventManager.d.ts +46 -32
  62. package/dist/types/src/managers/GLManager.d.ts +84 -0
  63. package/dist/types/src/managers/GLState.d.ts +37 -0
  64. package/dist/types/src/managers/IDManager.d.ts +31 -0
  65. package/dist/types/src/managers/InputManager.d.ts +290 -0
  66. package/dist/types/src/managers/NetworkManager.d.ts +93 -0
  67. package/dist/types/src/managers/RenderStats.d.ts +34 -0
  68. package/dist/types/src/managers/SceneManager.d.ts +44 -0
  69. package/dist/types/src/managers/ShaderManager.d.ts +55 -0
  70. package/dist/types/src/managers/TextureManager.d.ts +102 -0
  71. package/dist/types/src/particlesystem/Particle.d.ts +64 -0
  72. package/dist/types/{particlesystem → src/particlesystem}/ParticleSettings.d.ts +32 -24
  73. package/dist/types/{particlesystem → src/particlesystem}/Particles.d.ts +20 -12
  74. package/index.js +72 -0
  75. package/package.json +74 -60
  76. package/src/Animator.js +95 -0
  77. package/src/BitmapText.js +6 -5
  78. package/src/Camera.js +183 -0
  79. package/src/CameraController.js +192 -0
  80. package/src/CanvasText.js +281 -0
  81. package/src/CollisionLayers.js +86 -0
  82. package/src/Color.js +18 -18
  83. package/src/Coroutine.js +259 -0
  84. package/src/DebugOverlay.js +246 -0
  85. package/src/Drawable.js +842 -582
  86. package/src/Easing.js +57 -0
  87. package/src/Emerald.js +1150 -459
  88. package/src/EmeraldDB.js +328 -0
  89. package/src/FPSCounter.js +43 -43
  90. package/src/GLUtils.js +60 -67
  91. package/src/Instance.js +41 -5
  92. package/src/InstancedTexture.js +251 -118
  93. package/src/Interpolator.js +124 -0
  94. package/src/Material.js +202 -0
  95. package/src/MathUtils.js +133 -0
  96. package/src/ParticleEmitter.js +284 -0
  97. package/src/Physics.js +186 -5
  98. package/src/Pool.js +85 -0
  99. package/src/PostEffects.js +296 -0
  100. package/src/PostProcessor.js +304 -0
  101. package/src/RenderTarget.js +134 -0
  102. package/src/Scene.js +115 -83
  103. package/src/ScreenEffects.js +266 -0
  104. package/src/Serializer.js +131 -0
  105. package/src/Shaders.js +150 -165
  106. package/src/Shapes.js +118 -129
  107. package/src/SpatialGrid.js +111 -0
  108. package/src/SpriteBatch.js +299 -0
  109. package/src/StateMachine.js +82 -0
  110. package/src/Storage.js +175 -47
  111. package/src/Texture.js +58 -67
  112. package/src/TextureAtlas.js +96 -0
  113. package/src/Tilemap.js +274 -0
  114. package/src/Time.js +51 -6
  115. package/src/Timer.js +99 -0
  116. package/src/Transform.js +100 -7
  117. package/src/Tween.js +160 -0
  118. package/src/UI.js +394 -0
  119. package/src/components/Behaviour.js +90 -0
  120. package/src/components/BoxCollider.js +22 -3
  121. package/src/components/CircleCollider.js +19 -3
  122. package/src/components/CircleColliderDebug.js +24 -24
  123. package/src/components/Collider.js +140 -34
  124. package/src/components/GameObject.js +130 -21
  125. package/src/components/RigidBody.js +123 -2
  126. package/src/importers/Aseprite.js +142 -0
  127. package/src/importers/TiledMap.js +158 -0
  128. package/src/lights/DirectionalLight.js +6 -15
  129. package/src/lights/PointLight.js +4 -4
  130. package/src/managers/AssetManager.js +239 -0
  131. package/src/managers/AudioManager.js +565 -146
  132. package/src/managers/EventManager.js +488 -477
  133. package/src/managers/GLManager.js +57 -0
  134. package/src/managers/GLState.js +70 -0
  135. package/src/managers/IDManager.js +24 -2
  136. package/src/managers/InputManager.js +779 -0
  137. package/src/managers/NetworkManager.js +178 -0
  138. package/src/managers/RenderStats.js +34 -0
  139. package/src/managers/SceneManager.js +30 -0
  140. package/src/managers/ShaderManager.js +0 -2
  141. package/src/managers/TextureManager.js +218 -0
  142. package/src/particlesystem/Particle.js +82 -7
  143. package/src/particlesystem/ParticleSettings.js +21 -3
  144. package/src/particlesystem/Particles.js +80 -31
  145. package/dist/types/Drawable.d.ts +0 -157
  146. package/dist/types/Emerald.d.ts +0 -73
  147. package/dist/types/GLUtils.d.ts +0 -6
  148. package/dist/types/Scene.d.ts +0 -39
  149. package/dist/types/Shaders.d.ts +0 -4
  150. package/dist/types/Storage.d.ts +0 -46
  151. package/dist/types/Time.d.ts +0 -22
  152. package/dist/types/Transform.d.ts +0 -41
  153. package/dist/types/components/BoxColliderDebug.d.ts +0 -19
  154. package/dist/types/components/CircleColliderDebug.d.ts +0 -19
  155. package/dist/types/components/Collider.d.ts +0 -53
  156. package/dist/types/components/GameObject.d.ts +0 -72
  157. package/dist/types/components/RigidBody.d.ts +0 -104
  158. package/dist/types/managers/AudioManager.d.ts +0 -60
  159. package/dist/types/managers/GLManager.d.ts +0 -47
  160. package/dist/types/managers/IDManager.d.ts +0 -21
  161. package/dist/types/managers/SceneManager.d.ts +0 -22
  162. package/dist/types/particlesystem/Particle.d.ts +0 -42
@@ -1,72 +0,0 @@
1
- import { Vector2, Vector3 } from "../Physics";
2
- import Transform from "../Transform";
3
- import RigidBody from "./RigidBody";
4
- import { mat4 } from "gl-matrix";
5
- /**
6
- * @class GameObject
7
- * @param {string} name - The name of the game object
8
- * @param {Vector3} position - The position of the game object
9
- * @param {number} rotation - The rotation of the game object
10
- * @param {Vector2} scale - The scale of the game object
11
- */
12
- declare class GameObject {
13
- name: string;
14
- components: any[];
15
- id: string;
16
- isActive: boolean;
17
- transform: Transform;
18
- opacity: number;
19
- constructor(name: string, position?: Vector3, rotation?: number, scale?: Vector2);
20
- /**
21
- * @method addComponent
22
- * @description Adds a component to the game object
23
- * @param {Component} componentInstance - The component to add
24
- */
25
- addComponent(componentInstance: any): void;
26
- /**
27
- * @method removeComponent
28
- * @description Removes a component from the game object
29
- * @param {Component} component - The component to remove
30
- */
31
- removeComponent(component: any): void;
32
- /**
33
- * @method setIsActive
34
- * @description Sets the active state of the game object
35
- * @param {boolean} bool - The active state
36
- */
37
- setIsActive(bool: boolean): void;
38
- /**
39
- * @method setOpacity
40
- * @description Sets the opacity of the game object (0..1)
41
- * @param {number} value - The opacity value between 0 and 1
42
- */
43
- setOpacity(value: number): void;
44
- /**
45
- * @method getOpacity
46
- * @description Gets the opacity of the game object
47
- * @returns {number} - The opacity value between 0 and 1
48
- */
49
- getOpacity(): number;
50
- /**
51
- * @method getComponent
52
- * @description Returns a component from the game object
53
- * @param {Component} componentType - The type of component to return
54
- */
55
- getComponent(componentType: any): any;
56
- /**
57
- * @method getRigidBodyAtPosition
58
- * @description Returns the rigidbody at a position
59
- * @param {Vector2} position - The position to check
60
- */
61
- getRigidBodyAtPosition(position: Vector2): RigidBody | null;
62
- /**
63
- * @method draw
64
- * @description Draws the game object
65
- * @param {Matrix4} globalViewMatrix - The global view matrix
66
- * @param {WebGLUniformLocation} uniformLocation - The uniform location
67
- * @param {number} currentTime - The current time
68
- */
69
- draw(globalViewMatrix: mat4, uniformLocation: WebGLUniformLocation, currentTime: number): void;
70
- }
71
- export default GameObject;
72
- //# sourceMappingURL=GameObject.d.ts.map
@@ -1,104 +0,0 @@
1
- import * as planck from "planck";
2
- import { Physics, Vector2 } from "../Physics";
3
- import Collider from "./Collider";
4
- import GameObject from "./GameObject";
5
- /**
6
- * @class RigidBody
7
- * @param {Physics} physics - The physics engine
8
- * @param {string | "static" | "dynamic" | "kinematic"} type - The type of rigidbody
9
- * @param {Vector2} position - The position of the rigidbody
10
- * @param {boolean} fixedRotation - Whether the rigidbody is fixed rotation
11
- * @param {GameObject} parentObject - The parent object of the rigidbody
12
- * @param {Vector2} offset - The offset of the rigidbody
13
- */
14
- declare class RigidBody {
15
- physics: Physics;
16
- offset: Vector2;
17
- type: string;
18
- body: planck.Body;
19
- parentObject: GameObject | null;
20
- position: Vector2;
21
- collider: Collider | null;
22
- id: string;
23
- name: string;
24
- constructor(physics: Physics, type: string, position: Vector2, fixedRotation: boolean, parentObject?: GameObject | null, offset?: Vector2);
25
- /**
26
- * @method updatePosition
27
- * @description Updates the position of the rigidbody
28
- * @param {Vector2} position - The new position
29
- */
30
- updatePosition(position: Vector2): void;
31
- /**
32
- * @method getOffset
33
- * @description Returns the offset of the rigidbody
34
- * @returns {Vector2} - The offset of the rigidbody
35
- */
36
- getOffset(): Vector2;
37
- /**
38
- * @method setCollider
39
- * @description Sets the collider of the rigidbody
40
- * @param {Collider} collider - The collider to set
41
- */
42
- setCollider(collider: Collider): void;
43
- /**
44
- * @method setRotation
45
- * @description Sets the rotation of the rigidbody
46
- * @param {number} rotation - The new rotation
47
- */
48
- setRotation(rotation: number): void;
49
- /**
50
- * @method getPosition
51
- * @description Returns the position of the rigidbody
52
- * @returns {Vector2} - The position of the rigidbody
53
- */
54
- getPosition(): Vector2;
55
- /**
56
- * @method getAngle
57
- * @description Returns the angle of the rigidbody
58
- * @returns {number} - The angle of the rigidbody
59
- */
60
- getAngle(): number;
61
- /**
62
- * @method getCollider
63
- * @description Returns the collider of the rigidbody
64
- * @returns {Collider} - The collider of the rigidbody
65
- */
66
- getCollider(): Collider | null;
67
- /**
68
- * @method getBody
69
- * @description Returns the body of the rigidbody
70
- * @returns {planck.Body} - The body of the rigidbody
71
- */
72
- getBody(): planck.Body;
73
- /**
74
- * @method getPhysics
75
- * @description Returns the physics engine of the rigidbody
76
- * @returns {Physics} - The physics engine of the rigidbody
77
- */
78
- getPhysics(): Physics;
79
- /**
80
- * @method destroy
81
- * @description Destroys the rigidbody
82
- */
83
- destroy(): void;
84
- /**
85
- * @method detachCollider
86
- * @description Detaches a collider from the rigidbody
87
- * @param {Collider} collider - The collider to detach
88
- */
89
- detachCollider(collider: Collider): void;
90
- /**
91
- * @method setParent
92
- * @description Sets the parent object of the rigidbody
93
- * @param {GameObject} parent - The parent object to set
94
- */
95
- setParent(parent: GameObject): void;
96
- /**
97
- * @method getType
98
- * @description Returns the type of the rigidbody
99
- * @returns {string | "static" | "dynamic" | "kinematic"} - The type of the rigidbody
100
- */
101
- getType(): string;
102
- }
103
- export default RigidBody;
104
- //# sourceMappingURL=RigidBody.d.ts.map
@@ -1,60 +0,0 @@
1
- /**
2
- * @class AudioManager
3
- * @description Manages the audio for the game
4
- */
5
- declare class AudioManager {
6
- sounds: Map<string, {
7
- audio: HTMLAudioElement;
8
- id: string;
9
- playPromise: Promise<void> | null;
10
- }>;
11
- constructor();
12
- /**
13
- * @method add
14
- * @description Adds an audio file to the manager
15
- * @param {string} path - The path to the audio file
16
- * @param {string} name - The name of the audio file
17
- */
18
- add(path: string, name: string): boolean;
19
- /**
20
- * @method remove
21
- * @description Removes an audio file from the manager
22
- * @param {string} name - The name of the audio file
23
- */
24
- remove(name: string): boolean;
25
- /**
26
- * @method play
27
- * @description Plays an audio file
28
- * @param {string} name - The name of the audio file
29
- */
30
- play(name: string): Promise<boolean>;
31
- /**
32
- * @method stop
33
- * @description Stops an audio file
34
- * @param {string} name - The name of the audio file
35
- */
36
- stop(name: string): Promise<boolean>;
37
- /**
38
- * @method stopAll
39
- * @description Stops all audio files
40
- */
41
- stopAll(): Promise<void>;
42
- /**
43
- * @method playExclusive
44
- * @description Plays an audio file after stopping all other audio files
45
- * @param {string} name - The name of the audio file
46
- */
47
- playExclusive(name: string): Promise<boolean>;
48
- /**
49
- * @method getSound
50
- * @description Returns an audio file from the manager
51
- * @param {string} name - The name of the audio file
52
- */
53
- getSound(name: string): {
54
- audio: HTMLAudioElement;
55
- id: string;
56
- playPromise: Promise<void> | null;
57
- } | undefined;
58
- }
59
- export default AudioManager;
60
- //# sourceMappingURL=AudioManager.d.ts.map
@@ -1,47 +0,0 @@
1
- /**
2
- * @class GLManager
3
- * @description Manages the WebGL context for the game
4
- */
5
- declare class GLManager {
6
- static gl: WebGL2RenderingContext | null;
7
- static programInfo: any | null;
8
- static canvas: HTMLCanvasElement | null;
9
- /**
10
- * @method setGL
11
- * @description Sets the WebGL context
12
- * @param {WebGLRenderingContext} gl - The WebGL context
13
- */
14
- static setGL(gl: WebGL2RenderingContext): void;
15
- /**
16
- * @method setProgramInfo
17
- * @description Sets the program info
18
- * @param {Object} programInfo - The program info
19
- */
20
- static setProgramInfo(programInfo: any): void;
21
- /**
22
- * @method setCanvas
23
- * @description Sets the canvas
24
- * @param {HTMLCanvasElement} canvas - The canvas
25
- */
26
- static setCanvas(canvas: HTMLCanvasElement): void;
27
- /**
28
- * @method getGL
29
- * @description Returns the WebGL context
30
- * @returns {WebGLRenderingContext} - The WebGL context
31
- */
32
- static getGL(): WebGL2RenderingContext | null;
33
- /**
34
- * @method getProgramInfo
35
- * @description Returns the program info
36
- * @returns {Object} - The program info
37
- */
38
- static getProgramInfo(): any | null;
39
- /**
40
- * @method getCanvas
41
- * @description Returns the canvas
42
- * @returns {HTMLCanvasElement} - The canvas
43
- */
44
- static getCanvas(): HTMLCanvasElement | null;
45
- }
46
- export default GLManager;
47
- //# sourceMappingURL=GLManager.d.ts.map
@@ -1,21 +0,0 @@
1
- /**
2
- * @class IDManager
3
- * @description Manages the IDs for the game
4
- */
5
- declare class IDManager {
6
- static existingIDs: Set<string>;
7
- /**
8
- * @method generateID
9
- * @description Generates a random ID
10
- * @returns {string} - The random ID
11
- */
12
- static generateID(): string;
13
- /**
14
- * @method generateUniqueID
15
- * @description Generates a unique ID
16
- * @returns {string} - The unique ID
17
- */
18
- static generateUniqueID(): string;
19
- }
20
- export default IDManager;
21
- //# sourceMappingURL=IDManager.d.ts.map
@@ -1,22 +0,0 @@
1
- import Scene from "../Scene";
2
- /**
3
- * @class SceneManager
4
- * @description Manages the scene for the game
5
- */
6
- declare class SceneManager {
7
- static scene: Scene | null;
8
- /**
9
- * @method setScene
10
- * @description Sets the scene
11
- * @param {Scene} scene - The scene to set
12
- */
13
- static setScene(scene: Scene): void;
14
- /**
15
- * @method getScene
16
- * @description Returns the scene
17
- * @returns {Scene} - The scene
18
- */
19
- static getScene(): Scene | null;
20
- }
21
- export default SceneManager;
22
- //# sourceMappingURL=SceneManager.d.ts.map
@@ -1,42 +0,0 @@
1
- import Instance from "../Instance";
2
- import InstancedTexture from "../InstancedTexture";
3
- import { Vector2, Vector3 } from "../Physics";
4
- import ParticleSettings from "./ParticleSettings";
5
- /**
6
- * @class Particle
7
- * @description Represents a particle in the particle system
8
- * @param {InstancedTexture} instancedTexture - The instanced texture
9
- * @param {Vector3} position - The position of the particle
10
- * @param {number} rotation - The rotation of the particle
11
- * @param {Vector2} scale - The scale of the particle
12
- * @param {ParticleSettings} settings - The settings for the particle
13
- */
14
- declare class Particle {
15
- settings: ParticleSettings;
16
- lifetime: number;
17
- age: number;
18
- velocity: Vector2;
19
- gravity: Vector2;
20
- instance: Instance;
21
- instancedTexture: InstancedTexture;
22
- constructor(instancedTexture: InstancedTexture, position: Vector3, rotation: number, scale: Vector2, settings: ParticleSettings);
23
- /**
24
- * @method update
25
- * @description Updates the particle
26
- * @param {number} dt - The delta time
27
- */
28
- update(dt: number): void;
29
- /**
30
- * @method isAlive
31
- * @description Checks if the particle is alive
32
- * @returns {boolean} - True if the particle is alive
33
- */
34
- isAlive(): boolean;
35
- /**
36
- * @method destroy
37
- * @description Destroys the particle
38
- */
39
- destroy(): void;
40
- }
41
- export default Particle;
42
- //# sourceMappingURL=Particle.d.ts.map