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.
Files changed (208) hide show
  1. package/README.md +2198 -968
  2. package/dist/types/index.d.ts +75 -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} +6 -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} +75 -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 +81 -0
  23. package/dist/types/src/ParticleEmitter.d.ts +131 -0
  24. package/dist/types/src/Physics.d.ts +337 -0
  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 +102 -0
  52. package/dist/types/src/components/GameObject.d.ts +135 -0
  53. package/dist/types/src/components/PolygonCollider.d.ts +33 -0
  54. package/dist/types/src/components/RigidBody.d.ts +456 -0
  55. package/dist/types/src/importers/Aseprite.d.ts +79 -0
  56. package/dist/types/src/importers/ForgeLevel.d.ts +97 -0
  57. package/dist/types/src/importers/TiledMap.d.ts +62 -0
  58. package/dist/types/{lights → src/lights}/DirectionalLight.d.ts +7 -9
  59. package/dist/types/{lights → src/lights}/PointLight.d.ts +6 -9
  60. package/dist/types/src/managers/AssetManager.d.ts +116 -0
  61. package/dist/types/src/managers/AudioManager.d.ts +259 -0
  62. package/dist/types/{managers → src/managers}/CameraManager.d.ts +8 -8
  63. package/dist/types/{managers → src/managers}/EventManager.d.ts +46 -32
  64. package/dist/types/src/managers/GLManager.d.ts +84 -0
  65. package/dist/types/src/managers/GLState.d.ts +37 -0
  66. package/dist/types/src/managers/Gamepad.d.ts +102 -0
  67. package/dist/types/src/managers/IDManager.d.ts +31 -0
  68. package/dist/types/src/managers/InputManager.d.ts +381 -0
  69. package/dist/types/src/managers/NetworkManager.d.ts +93 -0
  70. package/dist/types/src/managers/RenderStats.d.ts +34 -0
  71. package/dist/types/src/managers/SceneManager.d.ts +44 -0
  72. package/dist/types/src/managers/ShaderManager.d.ts +55 -0
  73. package/dist/types/src/managers/TextureManager.d.ts +102 -0
  74. package/dist/types/src/particlesystem/Particle.d.ts +64 -0
  75. package/dist/types/{particlesystem → src/particlesystem}/ParticleSettings.d.ts +32 -24
  76. package/dist/types/{particlesystem → src/particlesystem}/Particles.d.ts +20 -12
  77. package/dist/types/src/physics/AABB.d.ts +92 -0
  78. package/dist/types/src/physics/Body.d.ts +435 -0
  79. package/dist/types/src/physics/BodyType.d.ts +6 -0
  80. package/dist/types/src/physics/BroadPhase.d.ts +210 -0
  81. package/dist/types/src/physics/Collision.d.ts +102 -0
  82. package/dist/types/src/physics/Contact.d.ts +206 -0
  83. package/dist/types/src/physics/ContactSolver.d.ts +108 -0
  84. package/dist/types/src/physics/Distance.d.ts +54 -0
  85. package/dist/types/src/physics/DistanceJoint.d.ts +90 -0
  86. package/dist/types/src/physics/Fixture.d.ts +221 -0
  87. package/dist/types/src/physics/Island.d.ts +52 -0
  88. package/dist/types/src/physics/Joint.d.ts +59 -0
  89. package/dist/types/src/physics/Math2D.d.ts +371 -0
  90. package/dist/types/src/physics/RevoluteJoint.d.ts +119 -0
  91. package/dist/types/src/physics/Settings.d.ts +22 -0
  92. package/dist/types/src/physics/Shapes.d.ts +207 -0
  93. package/dist/types/src/physics/TimeOfImpact.d.ts +22 -0
  94. package/dist/types/src/physics/World.d.ts +274 -0
  95. package/dist/types/src/physics/index.d.ts +34 -0
  96. package/index.js +78 -0
  97. package/package.json +73 -60
  98. package/src/Animator.js +95 -0
  99. package/src/BitmapText.js +6 -5
  100. package/src/Camera.js +183 -0
  101. package/src/CameraController.js +192 -0
  102. package/src/CanvasText.js +281 -0
  103. package/src/CollisionLayers.js +86 -0
  104. package/src/Color.js +26 -18
  105. package/src/Coroutine.js +259 -0
  106. package/src/DebugOverlay.js +246 -0
  107. package/src/Drawable.js +842 -582
  108. package/src/Easing.js +57 -0
  109. package/src/Emerald.js +1150 -459
  110. package/src/EmeraldDB.js +328 -0
  111. package/src/FPSCounter.js +43 -43
  112. package/src/GLUtils.js +60 -67
  113. package/src/Instance.js +41 -5
  114. package/src/InstancedTexture.js +308 -127
  115. package/src/Interpolator.js +124 -0
  116. package/src/Material.js +202 -0
  117. package/src/MathUtils.js +134 -0
  118. package/src/ParticleEmitter.js +284 -0
  119. package/src/Physics.js +431 -40
  120. package/src/Pool.js +85 -0
  121. package/src/PostEffects.js +296 -0
  122. package/src/PostProcessor.js +304 -0
  123. package/src/RenderTarget.js +134 -0
  124. package/src/Scene.js +115 -83
  125. package/src/ScreenEffects.js +266 -0
  126. package/src/Serializer.js +131 -0
  127. package/src/Shaders.js +150 -165
  128. package/src/Shapes.js +118 -129
  129. package/src/SpatialGrid.js +111 -0
  130. package/src/SpriteBatch.js +299 -0
  131. package/src/StateMachine.js +82 -0
  132. package/src/Storage.js +175 -47
  133. package/src/Texture.js +58 -67
  134. package/src/TextureAtlas.js +96 -0
  135. package/src/Tilemap.js +274 -0
  136. package/src/Time.js +51 -6
  137. package/src/Timer.js +99 -0
  138. package/src/Transform.js +100 -7
  139. package/src/Tween.js +160 -0
  140. package/src/UI.js +394 -0
  141. package/src/components/Behaviour.js +90 -0
  142. package/src/components/BoxCollider.js +29 -12
  143. package/src/components/BoxColliderDebug.js +3 -4
  144. package/src/components/CircleCollider.js +26 -12
  145. package/src/components/CircleColliderDebug.js +25 -24
  146. package/src/components/Collider.js +150 -34
  147. package/src/components/GameObject.js +130 -21
  148. package/src/components/PolygonCollider.js +55 -0
  149. package/src/components/RigidBody.js +556 -8
  150. package/src/importers/Aseprite.js +142 -0
  151. package/src/importers/ForgeLevel.js +581 -0
  152. package/src/importers/TiledMap.js +158 -0
  153. package/src/lights/DirectionalLight.js +6 -15
  154. package/src/lights/PointLight.js +4 -4
  155. package/src/managers/AssetManager.js +239 -0
  156. package/src/managers/AudioManager.js +565 -146
  157. package/src/managers/EventManager.js +488 -477
  158. package/src/managers/GLManager.js +57 -0
  159. package/src/managers/GLState.js +70 -0
  160. package/src/managers/Gamepad.js +126 -0
  161. package/src/managers/IDManager.js +24 -2
  162. package/src/managers/InputManager.js +905 -0
  163. package/src/managers/NetworkManager.js +178 -0
  164. package/src/managers/RenderStats.js +34 -0
  165. package/src/managers/SceneManager.js +30 -0
  166. package/src/managers/ShaderManager.js +0 -2
  167. package/src/managers/TextureManager.js +218 -0
  168. package/src/particlesystem/Particle.js +82 -7
  169. package/src/particlesystem/ParticleSettings.js +21 -3
  170. package/src/particlesystem/Particles.js +80 -31
  171. package/src/physics/AABB.js +207 -0
  172. package/src/physics/Body.js +862 -0
  173. package/src/physics/BodyType.js +16 -0
  174. package/src/physics/BroadPhase.js +641 -0
  175. package/src/physics/Collision.js +534 -0
  176. package/src/physics/Contact.js +500 -0
  177. package/src/physics/ContactSolver.js +526 -0
  178. package/src/physics/Distance.js +403 -0
  179. package/src/physics/DistanceJoint.js +227 -0
  180. package/src/physics/Fixture.js +346 -0
  181. package/src/physics/Island.js +203 -0
  182. package/src/physics/Joint.js +78 -0
  183. package/src/physics/Math2D.js +573 -0
  184. package/src/physics/RevoluteJoint.js +278 -0
  185. package/src/physics/Settings.js +78 -0
  186. package/src/physics/Shapes.js +549 -0
  187. package/src/physics/TimeOfImpact.js +87 -0
  188. package/src/physics/World.js +731 -0
  189. package/src/physics/index.js +79 -0
  190. package/dist/types/Drawable.d.ts +0 -157
  191. package/dist/types/Emerald.d.ts +0 -73
  192. package/dist/types/GLUtils.d.ts +0 -6
  193. package/dist/types/Physics.d.ts +0 -139
  194. package/dist/types/Scene.d.ts +0 -39
  195. package/dist/types/Shaders.d.ts +0 -4
  196. package/dist/types/Storage.d.ts +0 -46
  197. package/dist/types/Time.d.ts +0 -22
  198. package/dist/types/Transform.d.ts +0 -41
  199. package/dist/types/components/BoxColliderDebug.d.ts +0 -19
  200. package/dist/types/components/CircleColliderDebug.d.ts +0 -19
  201. package/dist/types/components/Collider.d.ts +0 -53
  202. package/dist/types/components/GameObject.d.ts +0 -72
  203. package/dist/types/components/RigidBody.d.ts +0 -104
  204. package/dist/types/managers/AudioManager.d.ts +0 -60
  205. package/dist/types/managers/GLManager.d.ts +0 -47
  206. package/dist/types/managers/IDManager.d.ts +0 -21
  207. package/dist/types/managers/SceneManager.d.ts +0 -22
  208. package/dist/types/particlesystem/Particle.d.ts +0 -42
@@ -1,5 +1,4 @@
1
- import Color from "../Color";
2
- import { Vector2 } from "../Physics";
1
+ export default DirectionalLight;
3
2
  /**
4
3
  * @class DirectionalLight
5
4
  * @param {Vector2} position - The position of the light
@@ -9,12 +8,12 @@ import { Vector2 } from "../Physics";
9
8
  * @param {number} width - The width of the light
10
9
  */
11
10
  declare class DirectionalLight {
12
- position: Vector2;
11
+ constructor(position: any, direction: any, color: any, intensity: any, width: any);
12
+ position: any;
13
13
  direction: Vector2;
14
- color: Color;
15
- intensity: number;
16
- width: number;
17
- constructor(position: Vector2, direction: Vector2, color: Color, intensity: number, width: number);
14
+ color: any;
15
+ intensity: any;
16
+ width: any;
18
17
  /**
19
18
  * Calculate the light intensity at a given point
20
19
  * @param {Vector2} point - The point to calculate intensity for
@@ -22,5 +21,4 @@ declare class DirectionalLight {
22
21
  */
23
22
  getIntensityAtPoint(point: Vector2): number;
24
23
  }
25
- export default DirectionalLight;
26
- //# sourceMappingURL=DirectionalLight.d.ts.map
24
+ import { Vector2 } from "../Physics.js";
@@ -1,5 +1,4 @@
1
- import Color from "../Color";
2
- import { Vector2 } from "../Physics";
1
+ export default PointLight;
3
2
  /**
4
3
  * @class PointLight
5
4
  * @param {Vector2} position - The position of the light
@@ -8,11 +7,9 @@ import { Vector2 } from "../Physics";
8
7
  * @param {number} radius - The radius of the light
9
8
  */
10
9
  declare class PointLight {
11
- position: Vector2;
12
- color: Color;
13
- intensity: number;
14
- radius: number;
15
- constructor(position: Vector2, color: Color, intensity: number, radius: number);
10
+ constructor(position: any, color: any, intensity: any, radius: any);
11
+ position: any;
12
+ color: any;
13
+ intensity: any;
14
+ radius: any;
16
15
  }
17
- export default PointLight;
18
- //# sourceMappingURL=PointLight.d.ts.map
@@ -0,0 +1,116 @@
1
+ export default AssetManager;
2
+ /**
3
+ * @class AssetManager
4
+ * @description A general async loader for everything a game needs at startup:
5
+ * images/textures, audio, JSON, text, and web fonts. It deduplicates by key,
6
+ * reports aggregate progress (so you can drive a loading bar), and stores the
7
+ * resolved assets for synchronous lookup afterwards via `get(key)`.
8
+ *
9
+ * Textures are routed through TextureManager so the GL upload cache is shared
10
+ * with the rest of the engine.
11
+ *
12
+ * @example
13
+ * const assets = new AssetManager();
14
+ * assets.image("player", "player.png", { pixelart: true });
15
+ * assets.audio("jump", "jump.wav");
16
+ * assets.json("level1", "levels/1.json");
17
+ * assets.font("Press Start 2P", "fonts/press-start.woff2");
18
+ * assets.onProgress((loaded, total) => bar.set(loaded / total));
19
+ * await assets.load();
20
+ * const img = assets.get("player"); // HTMLImageElement
21
+ * const data = assets.get("level1"); // parsed JSON
22
+ */
23
+ declare class AssetManager {
24
+ /** @private */
25
+ private static _loadAudio;
26
+ /** @private */
27
+ private static _loadFont;
28
+ /** @private */
29
+ private _queue;
30
+ assets: Map<any, any>;
31
+ /** @private */
32
+ private _paths;
33
+ /** @private */
34
+ private _progressHandlers;
35
+ /** @private */
36
+ private _loaded;
37
+ /** @private */
38
+ private _total;
39
+ /**
40
+ * @method image
41
+ * @description Queues an image/texture. The GL texture is created lazily by
42
+ * the renderer; `get(key)` returns the HTMLImageElement.
43
+ */
44
+ image(key: any, path: any, options?: {}): this;
45
+ /**
46
+ * @method audio
47
+ * @description Queues an audio file (returns an HTMLAudioElement on get()).
48
+ */
49
+ audio(key: any, path: any): this;
50
+ /**
51
+ * @method json
52
+ * @description Queues a JSON file (parsed on get()).
53
+ */
54
+ json(key: any, path: any): this;
55
+ /**
56
+ * @method text
57
+ * @description Queues a plain-text file.
58
+ */
59
+ text(key: any, path: any): this;
60
+ /**
61
+ * @method font
62
+ * @description Queues a web font. `key` is the font-family name you will use
63
+ * in CSS/canvas; `path` is the font file URL.
64
+ */
65
+ font(key: any, path: any, descriptors?: {}): this;
66
+ /**
67
+ * @method onProgress
68
+ * @description Registers a callback invoked as (loaded, total) after each
69
+ * asset resolves.
70
+ */
71
+ onProgress(handler: any): this;
72
+ /**
73
+ * @method progress
74
+ * @returns {number} - Fraction loaded in [0, 1] (1 when nothing is queued).
75
+ */
76
+ progress(): number;
77
+ /**
78
+ * @method load
79
+ * @description Loads every queued asset, resolving when all are done. Failed
80
+ * assets reject the returned promise unless `continueOnError` is true, in
81
+ * which case they resolve to null and loading continues.
82
+ * @param {Object} [options] - { continueOnError = false }
83
+ * @returns {Promise<Map>} - The resolved assets map
84
+ */
85
+ load(options?: any): Promise<Map<any, any>>;
86
+ /** @private */
87
+ private _loadOne;
88
+ /**
89
+ * @method get
90
+ * @description Returns a previously loaded asset by key.
91
+ */
92
+ get(key: any): any;
93
+ /**
94
+ * @method has
95
+ * @returns {boolean} - Whether an asset has been loaded for the key.
96
+ */
97
+ has(key: any): boolean;
98
+ /**
99
+ * @method getTexture
100
+ * @description Convenience: returns the cached GL texture for an image asset
101
+ * that was queued with `image()`. Resolves once the upload completes.
102
+ * @param {string} key - The image asset key
103
+ * @returns {Promise<{texture: WebGLTexture, width: number, height: number}>}
104
+ */
105
+ getTexture(key: string): Promise<{
106
+ texture: WebGLTexture;
107
+ width: number;
108
+ height: number;
109
+ }>;
110
+ /**
111
+ * @method clear
112
+ * @description Forgets all loaded assets (does not free GL textures; use
113
+ * TextureManager.clear for that).
114
+ */
115
+ clear(): void;
116
+ }
@@ -0,0 +1,259 @@
1
+ export default AudioManager;
2
+ /**
3
+ * @class AudioManager
4
+ * @description Manages audio for the game with per-sound volume, looping,
5
+ * overlapping one-shot playback for sound effects, named mix buses
6
+ * (master / music / sfx and any custom bus) and volume fades / crossfades.
7
+ *
8
+ * Final playback volume for a sound is
9
+ * `masterVolume * busVolume(sound.bus) * sound.volume`, so an options menu can
10
+ * expose independent Music / SFX sliders that route through the buses.
11
+ *
12
+ * Fades are advanced by `update(dt)`. When `autoTick` is true (the default) and
13
+ * `requestAnimationFrame` exists, the manager drives its own fades and you do
14
+ * NOT need to call `update`. Pass `{ autoTick: false }` to advance fades
15
+ * manually (e.g. from your game loop or in tests).
16
+ *
17
+ * @param {Object} [options]
18
+ * @param {boolean} [options.autoTick=true] - Self-drive fades via requestAnimationFrame
19
+ */
20
+ declare class AudioManager {
21
+ constructor(options?: {});
22
+ sounds: Map<any, any>;
23
+ masterVolume: number;
24
+ buses: Map<string, number>;
25
+ defaultBus: string;
26
+ listener: {
27
+ x: number;
28
+ y: number;
29
+ };
30
+ refDistance: number;
31
+ maxDistance: number;
32
+ /** @private */
33
+ private _audioCtx;
34
+ /** @private */
35
+ private _fades;
36
+ autoTick: boolean;
37
+ /** @private */
38
+ private _tickId;
39
+ /** @private */
40
+ private _lastTick;
41
+ /**
42
+ * @method getBusVolume
43
+ * @description Returns the 0..1 volume of a named bus (1 if it doesn't exist).
44
+ * @param {string} bus - The bus name (e.g. "music", "sfx")
45
+ * @returns {number}
46
+ */
47
+ getBusVolume(bus: string): number;
48
+ /**
49
+ * @method setBusVolume
50
+ * @description Sets the volume (0..1) of a named bus, creating it if needed,
51
+ * and applies it immediately to any currently-playing tracked sounds on it.
52
+ * @param {string} bus - The bus name
53
+ * @param {number} volume - The volume (clamped to 0..1)
54
+ */
55
+ setBusVolume(bus: string, volume: number): void;
56
+ /**
57
+ * @method setSoundBus
58
+ * @description Routes a registered sound through a named bus.
59
+ * @param {string} name - The registered sound name
60
+ * @param {string} bus - The bus name
61
+ */
62
+ setSoundBus(name: string, bus: string): void;
63
+ /**
64
+ * @method _busVolumeFor
65
+ * @description Combined master * bus multiplier for a sound (before fade/per-sound volume).
66
+ * @private
67
+ */
68
+ private _busVolumeFor;
69
+ /**
70
+ * @method _effectiveVolume
71
+ * @description Final 0..1 volume for a tracked sound element.
72
+ * @private
73
+ */
74
+ private _effectiveVolume;
75
+ /**
76
+ * @method _applyLiveVolumes
77
+ * @description Re-applies the effective volume to the primary element of
78
+ * tracked sounds (optionally filtered to one bus). Overlapping one-shots are
79
+ * fire-and-forget and not retargeted.
80
+ * @private
81
+ */
82
+ private _applyLiveVolumes;
83
+ /**
84
+ * @method setListener
85
+ * @description Sets the world-space listener position (usually the camera or
86
+ * player) used by playSpatial.
87
+ * @param {number} x
88
+ * @param {number} y
89
+ */
90
+ setListener(x: number, y: number): void;
91
+ /**
92
+ * @method setSpatialRange
93
+ * @description Configures the distance attenuation model for playSpatial.
94
+ * @param {number} refDistance - Distance within which volume is full
95
+ * @param {number} maxDistance - Distance at/after which the sound is silent
96
+ */
97
+ setSpatialRange(refDistance: number, maxDistance: number): void;
98
+ /**
99
+ * @method computeSpatial
100
+ * @description Pure helper: returns { volume, pan } for a source at `position`
101
+ * relative to the current listener and distance model. `volume` is 0..1 (before
102
+ * master/per-sound multipliers), `pan` is -1 (left) .. 1 (right). Exposed for
103
+ * testing and custom routing.
104
+ * @param {{x:number,y:number}} position
105
+ * @returns {{volume:number, pan:number, distance:number}}
106
+ */
107
+ computeSpatial(position: {
108
+ x: number;
109
+ y: number;
110
+ }): {
111
+ volume: number;
112
+ pan: number;
113
+ distance: number;
114
+ };
115
+ /**
116
+ * @method playSpatial
117
+ * @description Plays a one-shot, overlapping copy of a sound positioned in the
118
+ * world: volume falls off with distance from the listener and the sound pans
119
+ * left/right. Uses Web Audio for true stereo panning when available, falling
120
+ * back to volume-only otherwise.
121
+ * @param {string} name - The registered sound name
122
+ * @param {{x:number,y:number}} position - World-space source position
123
+ * @returns {boolean} - Whether playback started
124
+ */
125
+ playSpatial(name: string, position: {
126
+ x: number;
127
+ y: number;
128
+ }): boolean;
129
+ /** @private */
130
+ private _getAudioContext;
131
+ /**
132
+ * @method add
133
+ * @description Adds an audio file to the manager
134
+ * @param {string} path - The path to the audio file
135
+ * @param {string} name - The name of the audio file
136
+ * @param {Object} [options] - { volume = 1, loop = false, bus = "sfx" }
137
+ */
138
+ add(path: string, name: string, options?: any): boolean;
139
+ /**
140
+ * @method remove
141
+ * @description Removes an audio file from the manager
142
+ * @param {string} name - The name of the audio file
143
+ */
144
+ remove(name: string): boolean;
145
+ /**
146
+ * @method setMasterVolume
147
+ * @description Sets the master volume applied to all sounds (0..1)
148
+ * @param {number} volume - The master volume
149
+ */
150
+ setMasterVolume(volume: number): void;
151
+ /**
152
+ * @method setVolume
153
+ * @description Sets the per-sound volume (0..1)
154
+ * @param {string} name - The name of the audio file
155
+ * @param {number} volume - The volume
156
+ */
157
+ setVolume(name: string, volume: number): void;
158
+ /**
159
+ * @method setLoop
160
+ * @description Sets whether a sound loops
161
+ * @param {string} name - The name of the audio file
162
+ * @param {boolean} loop - Whether to loop
163
+ */
164
+ setLoop(name: string, loop: boolean): void;
165
+ /**
166
+ * @method play
167
+ * @description Plays an audio file from the start
168
+ * @param {string} name - The name of the audio file
169
+ */
170
+ play(name: string): Promise<boolean>;
171
+ /**
172
+ * @method playOverlap
173
+ * @description Plays a one-shot copy of the sound that can overlap with other
174
+ * instances of the same sound (ideal for rapid sound effects). The cloned
175
+ * node is not tracked or interruptible.
176
+ * @param {string} name - The name of the audio file
177
+ */
178
+ playOverlap(name: string): boolean;
179
+ /**
180
+ * @method stop
181
+ * @description Stops an audio file
182
+ * @param {string} name - The name of the audio file
183
+ */
184
+ stop(name: string): Promise<boolean>;
185
+ /**
186
+ * @method stopAll
187
+ * @description Stops all audio files
188
+ */
189
+ stopAll(): Promise<void>;
190
+ /**
191
+ * @method playExclusive
192
+ * @description Plays an audio file after stopping all other audio files
193
+ * @param {string} name - The name of the audio file
194
+ */
195
+ playExclusive(name: string): Promise<boolean>;
196
+ /**
197
+ * @method fadeTo
198
+ * @description Smoothly fades a sound's volume multiplier to a target (0..1)
199
+ * over `duration` seconds. Starting playback first (e.g. `play(name)`) and
200
+ * fading from 0 gives a fade-in; fading to 0 then stopping gives a fade-out.
201
+ * @param {string} name - The registered sound name
202
+ * @param {number} target - Target multiplier (0..1)
203
+ * @param {number} duration - Fade time in seconds (<=0 applies instantly)
204
+ * @param {Function} [onDone] - Called when the fade completes
205
+ * @returns {boolean} - Whether the sound exists
206
+ */
207
+ fadeTo(name: string, target: number, duration: number, onDone?: Function): boolean;
208
+ /**
209
+ * @method fadeIn
210
+ * @description Convenience: sets the fade multiplier to 0, starts playback and
211
+ * fades up to full over `duration` seconds.
212
+ * @param {string} name - The registered sound name
213
+ * @param {number} duration - Fade time in seconds
214
+ */
215
+ fadeIn(name: string, duration: number): boolean;
216
+ /**
217
+ * @method fadeOut
218
+ * @description Fades a sound down to silence over `duration` seconds, then
219
+ * stops it (and resets its fade multiplier to 1 for next time).
220
+ * @param {string} name - The registered sound name
221
+ * @param {number} duration - Fade time in seconds
222
+ */
223
+ fadeOut(name: string, duration: number): boolean;
224
+ /**
225
+ * @method crossfade
226
+ * @description Fades `fromName` out while fading `toName` in over `duration`
227
+ * seconds (ideal for switching music tracks). Starts `toName` playing.
228
+ * @param {string} fromName - Track to fade out (may be null)
229
+ * @param {string} toName - Track to fade in
230
+ * @param {number} duration - Fade time in seconds
231
+ */
232
+ crossfade(fromName: string, toName: string, duration: number): void;
233
+ /**
234
+ * @method _removeFadesFor
235
+ * @description Cancels any in-flight fades for a sound name.
236
+ * @private
237
+ */
238
+ private _removeFadesFor;
239
+ /**
240
+ * @method update
241
+ * @description Advances active volume fades by `dt` seconds. Call this from
242
+ * your loop when the manager was created with `{ autoTick: false }`; otherwise
243
+ * the manager advances fades itself.
244
+ * @param {number} dt - Elapsed seconds since the last update
245
+ */
246
+ update(dt: number): void;
247
+ /**
248
+ * @method _maybeStartTicker
249
+ * @description Lazily starts the self-driven RAF ticker (browser + autoTick).
250
+ * @private
251
+ */
252
+ private _maybeStartTicker;
253
+ /**
254
+ * @method getSound
255
+ * @description Returns an audio file from the manager
256
+ * @param {string} name - The name of the audio file
257
+ */
258
+ getSound(name: string): any;
259
+ }
@@ -1,11 +1,9 @@
1
- import { Vector2 } from "../Physics";
1
+ export default CameraManager;
2
2
  /**
3
3
  * @class CameraManager
4
4
  * @description Manages the camera for the game
5
5
  */
6
6
  declare class CameraManager {
7
- static camera: any;
8
- static lastPosition: Vector2 | null;
9
7
  /**
10
8
  * @method setLastPosition
11
9
  * @description Sets the last position of the camera
@@ -17,19 +15,21 @@ declare class CameraManager {
17
15
  * @description Returns the last position of the camera
18
16
  * @returns {Vector2} - The last position of the camera
19
17
  */
20
- static getLastPosition(): Vector2 | null;
18
+ static getLastPosition(): Vector2;
21
19
  /**
22
20
  * @method setCamera
23
21
  * @description Sets the camera for the game
24
22
  * @param {Camera} camera - The camera to set
25
23
  */
26
- static setCamera(camera: any): void;
24
+ static setCamera(camera: Camera): void;
27
25
  /**
28
26
  * @method getCamera
29
27
  * @description Returns the camera for the game
30
28
  * @returns {Camera} - The camera for the game
31
29
  */
32
- static getCamera(): any | null;
30
+ static getCamera(): Camera;
31
+ }
32
+ declare namespace CameraManager {
33
+ let camera: any;
34
+ let lastPosition: any;
33
35
  }
34
- export default CameraManager;
35
- //# sourceMappingURL=CameraManager.d.ts.map
@@ -1,6 +1,4 @@
1
- import Scene from "../Scene";
2
- import GameObject from "../components/GameObject";
3
- import Instance from "../Instance";
1
+ export default EventManager;
4
2
  /**
5
3
  * @class EventManager
6
4
  * @description Manages the events for the game
@@ -9,38 +7,33 @@ import Instance from "../Instance";
9
7
  * @param {Camera} camera - The camera
10
8
  */
11
9
  declare class EventManager {
12
- scene: Scene;
10
+ constructor(canvas: any, scene: any, camera: any);
11
+ scene: any;
13
12
  camera: any;
14
- canvas: HTMLCanvasElement;
15
- keyDownListeners: Map<string, Set<Function>>;
16
- keyUpListeners: Map<string, Set<Function>>;
17
- clickListeners: Map<string, Set<Function>>;
18
- canvasWidth: number;
19
- canvasHeight: number;
20
- hoverListeners: Map<string, {
21
- enter: Set<Function>;
22
- leave: Set<Function>;
23
- }>;
24
- lastHoveredObject: GameObject | null;
25
- lastHoveredInstance: Instance | null;
26
- pressedKeys: Map<string, boolean>;
13
+ canvas: any;
14
+ keyDownListeners: Map<any, any>;
15
+ keyUpListeners: Map<any, any>;
16
+ clickListeners: Map<any, any>;
17
+ hoverListeners: Map<any, any>;
18
+ lastHoveredObject: any;
19
+ lastHoveredInstance: any;
20
+ pressedKeys: Map<any, any>;
27
21
  mousePosition: {
28
22
  x: number;
29
23
  y: number;
30
24
  };
25
+ boundHandleMouseMove: any;
26
+ boundHandleKeyDown: any;
27
+ boundHandleKeyUp: any;
28
+ boundHandleClick: any;
29
+ boundHandleMouseDown: any;
30
+ boundHandleMouseUp: any;
31
31
  isDragging: boolean;
32
32
  dragStartX: number;
33
33
  dragStartY: number;
34
- initialCameraX: number;
35
- initialCameraY: number;
34
+ initialCameraX: any;
35
+ initialCameraY: any;
36
36
  cameraWasMoved: boolean;
37
- boundHandleMouseMove: (event: MouseEvent) => void;
38
- boundHandleKeyDown: (event: KeyboardEvent) => void;
39
- boundHandleKeyUp: (event: KeyboardEvent) => void;
40
- boundHandleClick: (event: MouseEvent) => void;
41
- boundHandleMouseDown: (event: MouseEvent) => void;
42
- boundHandleMouseUp: (event: MouseEvent) => void;
43
- constructor(canvas: HTMLCanvasElement, scene: Scene, camera: any);
44
37
  /**
45
38
  * @method addKeyDown
46
39
  * @description Adds a key down event listener
@@ -95,6 +88,31 @@ declare class EventManager {
95
88
  * @param {function} func - The function to call when the object is clicked
96
89
  */
97
90
  addClickEvent(object: GameObject, func: Function): void;
91
+ /**
92
+ * @method screenToWorld
93
+ * @description Converts screen (client) coordinates to world coordinates,
94
+ * accounting for camera position, zoom, and CSS/backing pixel ratio.
95
+ * @param {number} clientX - The clientX of the pointer
96
+ * @param {number} clientY - The clientY of the pointer
97
+ * @returns {{x: number, y: number}} - The world-space coordinates
98
+ */
99
+ screenToWorld(clientX: number, clientY: number): {
100
+ x: number;
101
+ y: number;
102
+ };
103
+ /**
104
+ * @method getTopObjectAt
105
+ * @description Returns the topmost active object under a world-space point
106
+ * along with the instance hit (if the object is an InstancedTexture). Topmost
107
+ * means highest z, with later scene order breaking ties, matching draw order.
108
+ * @param {number} worldX - The world-space x coordinate
109
+ * @param {number} worldY - The world-space y coordinate
110
+ * @returns {{object: GameObject, instance: Instance|null}|null}
111
+ */
112
+ getTopObjectAt(worldX: number, worldY: number): {
113
+ object: GameObject;
114
+ instance: Instance | null;
115
+ } | null;
98
116
  /**
99
117
  * @method handleClick
100
118
  * @description Handles a click event
@@ -156,10 +174,7 @@ declare class EventManager {
156
174
  * @description Returns the mouse position
157
175
  * @returns {Object} - The mouse position
158
176
  */
159
- getMousePosition(): {
160
- x: number;
161
- y: number;
162
- };
177
+ getMousePosition(): any;
163
178
  /**
164
179
  * @method wasCameraMoved
165
180
  * @description Checks if the camera was moved
@@ -183,5 +198,4 @@ declare class EventManager {
183
198
  */
184
199
  clean(): void;
185
200
  }
186
- export default EventManager;
187
- //# sourceMappingURL=EventManager.d.ts.map
201
+ import Scene from "../Scene.js";
@@ -0,0 +1,84 @@
1
+ export default GLManager;
2
+ /**
3
+ * @class GLManager
4
+ * @description Manages the WebGL context for the game
5
+ */
6
+ declare class GLManager {
7
+ /**
8
+ * @method setGL
9
+ * @description Sets the WebGL context
10
+ * @param {WebGLRenderingContext} gl - The WebGL context
11
+ */
12
+ static setGL(gl: WebGLRenderingContext): void;
13
+ /**
14
+ * @method setProgramInfo
15
+ * @description Sets the program info
16
+ * @param {Object} programInfo - The program info
17
+ */
18
+ static setProgramInfo(programInfo: any): void;
19
+ /**
20
+ * @method setCanvas
21
+ * @description Sets the canvas
22
+ * @param {HTMLCanvasElement} canvas - The canvas
23
+ */
24
+ static setCanvas(canvas: HTMLCanvasElement): void;
25
+ /**
26
+ * @method getGL
27
+ * @description Returns the WebGL context
28
+ * @returns {WebGLRenderingContext} - The WebGL context
29
+ */
30
+ static getGL(): WebGLRenderingContext;
31
+ /**
32
+ * @method getProgramInfo
33
+ * @description Returns the program info
34
+ * @returns {Object} - The program info
35
+ */
36
+ static getProgramInfo(): any;
37
+ /**
38
+ * @method getCanvas
39
+ * @description Returns the canvas
40
+ * @returns {HTMLCanvasElement} - The canvas
41
+ */
42
+ static getCanvas(): HTMLCanvasElement;
43
+ /**
44
+ * @method registerRestorable
45
+ * @description Registers an object holding GL resources (buffers, textures,
46
+ * programs) for re-creation after a WebGL context loss. The object must
47
+ * implement `_restoreGL()`. Drawables register themselves automatically and
48
+ * unregister on dispose().
49
+ * @param {Object} obj - An object with a _restoreGL() method
50
+ */
51
+ static registerRestorable(obj: any): void;
52
+ /**
53
+ * @method unregisterRestorable
54
+ * @description Removes an object from the context-restore registry.
55
+ */
56
+ static unregisterRestorable(obj: any): void;
57
+ /**
58
+ * @method restoreAll
59
+ * @description Calls _restoreGL() on every registered object. Invoked by
60
+ * Emerald after the context is restored and the default shaders/textures
61
+ * have been rebuilt.
62
+ */
63
+ static restoreAll(): void;
64
+ /**
65
+ * @method setProjection
66
+ * @description Stores the current camera's projection matrix so custom
67
+ * Materials (which use their own shader program) can upload it.
68
+ * @param {Float32Array} matrix - The projection matrix
69
+ */
70
+ static setProjection(matrix: Float32Array): void;
71
+ /**
72
+ * @method getProjection
73
+ * @description Returns the last projection matrix set by the renderer.
74
+ * @returns {Float32Array}
75
+ */
76
+ static getProjection(): Float32Array;
77
+ }
78
+ declare namespace GLManager {
79
+ let gl: any;
80
+ let programInfo: any;
81
+ let canvas: any;
82
+ let projection: any;
83
+ let restorables: Set<any>;
84
+ }