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
@@ -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
+ }
@@ -0,0 +1,37 @@
1
+ export default GLState;
2
+ /**
3
+ * @class GLState
4
+ * @description Tiny redundant-uniform filter. The renderer sets the same handful
5
+ * of per-object uniforms (useTexture, useInstances, useLighting, color, opacity)
6
+ * for every object every frame; most calls repeat the previous value. These
7
+ * helpers skip the GL call when the value is unchanged. Keyed by uniform
8
+ * location, which is program-specific, so the cache is safe across objects.
9
+ */
10
+ declare class GLState {
11
+ /**
12
+ * @method reset
13
+ * @description Clears the cache. Called at the start of each frame so the
14
+ * first object always re-establishes state.
15
+ */
16
+ static reset(): void;
17
+ /**
18
+ * @method uniform1i
19
+ * @description Cached gl.uniform1i (accepts booleans, coerced like WebGL does).
20
+ */
21
+ static uniform1i(gl: any, location: any, value: any): void;
22
+ /**
23
+ * @method uniform1f
24
+ * @description Cached gl.uniform1f.
25
+ */
26
+ static uniform1f(gl: any, location: any, value: any): void;
27
+ /**
28
+ * @method uniform4fv
29
+ * @description Cached gl.uniform4fv (compares the four components).
30
+ */
31
+ static uniform4fv(gl: any, location: any, value: any): void;
32
+ }
33
+ declare namespace GLState {
34
+ let ints: Map<any, any>;
35
+ let floats: Map<any, any>;
36
+ let vec4s: Map<any, any>;
37
+ }
@@ -0,0 +1,31 @@
1
+ export default IDManager;
2
+ /**
3
+ * @class IDManager
4
+ * @description Manages the IDs for the game
5
+ */
6
+ declare class IDManager {
7
+ /**
8
+ * @method generateID
9
+ * @description Generates a random ID, preferring the collision-resistant
10
+ * crypto.randomUUID when available and falling back to a random string.
11
+ * @returns {string} - The random ID
12
+ */
13
+ static generateID(): string;
14
+ /**
15
+ * @method generateUniqueID
16
+ * @description Generates a unique ID
17
+ * @returns {string} - The unique ID
18
+ */
19
+ static generateUniqueID(): string;
20
+ /**
21
+ * @method release
22
+ * @description Releases a previously-generated ID so the global registry
23
+ * doesn't grow without bound. Call this when an object/instance is destroyed
24
+ * (e.g. particles removed from an InstancedTexture).
25
+ * @param {string} id - The ID to release
26
+ */
27
+ static release(id: string): void;
28
+ }
29
+ declare namespace IDManager {
30
+ let existingIDs: Set<any>;
31
+ }