emeraldengine 2.2.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 -555
  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,420 @@
1
+ export default Emerald;
2
+ /**
3
+ * @class Emerald
4
+ * @description A class that represents the Emerald engine
5
+ * @param {HTMLCanvasElement} canvas - The canvas element
6
+ */
7
+ declare class Emerald {
8
+ constructor(canvas: any);
9
+ gl: any;
10
+ camera: Camera;
11
+ cameras: Camera[];
12
+ ambientLight: Vector3;
13
+ pointLights: any[];
14
+ directionalLights: any[];
15
+ debugLogged: boolean;
16
+ cullingEnabled: boolean;
17
+ /** @private */
18
+ private _drawOrder;
19
+ /** @private */
20
+ private _projection;
21
+ /** @private */
22
+ private _view;
23
+ /** @private */
24
+ private _identityView;
25
+ /** @private */
26
+ private _ambient;
27
+ /** @private */
28
+ private _lightPositions;
29
+ /** @private */
30
+ private _lightColors;
31
+ /** @private */
32
+ private _lightIntensities;
33
+ /** @private */
34
+ private _lightRadii;
35
+ /** @private */
36
+ private _dirLightPositions;
37
+ /** @private */
38
+ private _dirLightDirections;
39
+ /** @private */
40
+ private _dirLightColors;
41
+ /** @private */
42
+ private _dirLightIntensities;
43
+ /** @private */
44
+ private _dirLightWidths;
45
+ backgroundColor: {
46
+ r: number;
47
+ g: number;
48
+ b: number;
49
+ a: number;
50
+ };
51
+ postProcessor: PostProcessor;
52
+ /** @private */
53
+ private _sceneRT;
54
+ designResolution: {
55
+ width: number;
56
+ height: number;
57
+ mode: string;
58
+ };
59
+ /** @private */
60
+ private _paused;
61
+ /**
62
+ * @method _initProgram
63
+ * @description Compiles the standard shader program and caches every attrib
64
+ * and uniform location. Called from the constructor and again after a WebGL
65
+ * context loss is restored (all programs die with the context).
66
+ * @private
67
+ */
68
+ private _initProgram;
69
+ shaderProgram: any;
70
+ programInfo: {
71
+ program: any;
72
+ attribLocations: {
73
+ vertexPosition: any;
74
+ aTexCoord: any;
75
+ instanceMatrix: any;
76
+ instanceTexCoord0: any;
77
+ instanceTexCoord1: any;
78
+ instanceTexCoord2: any;
79
+ instanceTexCoord3: any;
80
+ instanceColor: any;
81
+ };
82
+ uniformLocations: {
83
+ projectionMatrix: any;
84
+ globalViewMatrix: any;
85
+ instancedModelViewMatrix: any;
86
+ uModelMatrix: any;
87
+ uInstancedModelMatrix: any;
88
+ uAmbientLightValues: any;
89
+ uSampler: any;
90
+ color: any;
91
+ useTexture: any;
92
+ useInstances: any;
93
+ useText: any;
94
+ useLighting: any;
95
+ uOpacity: any;
96
+ uLightPosition: any;
97
+ uLightColor: any;
98
+ uLightIntensity: any;
99
+ uLightRadius: any;
100
+ uActiveLights: any;
101
+ uDirLightPosition: any;
102
+ uDirLightDirection: any;
103
+ uDirLightColor: any;
104
+ uDirLightIntensity: any;
105
+ uDirLightWidth: any;
106
+ uActiveDirLights: any;
107
+ };
108
+ };
109
+ /**
110
+ * @method _bindContextGuards
111
+ * @description Installs webglcontextlost/restored handlers: on loss the
112
+ * default (context is gone for good) is prevented and rendering pauses; on
113
+ * restore every GPU resource is rebuilt and rendering resumes.
114
+ * @private
115
+ */
116
+ private _bindContextGuards;
117
+ /** @private */
118
+ private _contextLost;
119
+ /** @private */
120
+ private _contextLostHandlers;
121
+ /** @private */
122
+ private _contextRestoredHandlers;
123
+ /** @private */
124
+ private _onCtxLost;
125
+ /** @private */
126
+ private _onCtxRestored;
127
+ /**
128
+ * @method getRenderStats
129
+ * @description Render counters for the most recent completed frame:
130
+ * { drawCalls, quads, textureBinds }. DebugOverlay shows these automatically.
131
+ * @returns {{drawCalls:number, quads:number, textureBinds:number}}
132
+ */
133
+ getRenderStats(): {
134
+ drawCalls: number;
135
+ quads: number;
136
+ textureBinds: number;
137
+ };
138
+ /**
139
+ * @method onContextLost
140
+ * @description Registers a callback fired when the WebGL context is lost
141
+ * (e.g. to show a "please wait" overlay).
142
+ * @param {Function} cb
143
+ * @returns {Emerald} - this
144
+ */
145
+ onContextLost(cb: Function): Emerald;
146
+ /**
147
+ * @method onContextRestored
148
+ * @description Registers a callback fired after the context and all GPU
149
+ * resources have been rebuilt.
150
+ * @param {Function} cb
151
+ * @returns {Emerald} - this
152
+ */
153
+ onContextRestored(cb: Function): Emerald;
154
+ /**
155
+ * @method _restoreContext
156
+ * @description Rebuilds everything the GPU forgot: the standard program,
157
+ * cached textures (from the surviving image cache), every registered
158
+ * drawable's buffers, custom Materials, post-processing programs, and the
159
+ * scene render target. Runs on the webglcontextrestored event.
160
+ * @private
161
+ */
162
+ private _restoreContext;
163
+ /**
164
+ * @method setDesignResolution
165
+ * @description Makes the world render at a fixed design resolution that is
166
+ * scaled to fit any screen, so the game looks consistent across devices and
167
+ * aspect ratios. Modes:
168
+ * - "fit" letterbox: preserve aspect, whole design visible, bars on the sides
169
+ * - "fill" cover: preserve aspect, fill the screen, crop the overflow
170
+ * - "stretch" ignore aspect, stretch the design to the screen
171
+ * - "pixel" like "fit" but snapped to an integer scale for crisp pixel art
172
+ * Call this once (and again on orientation change if desired); it composes with
173
+ * `resize`. Use `screenToWorld` for correct picking under any mode.
174
+ * @param {number} width - Design width in world units
175
+ * @param {number} height - Design height in world units
176
+ * @param {string} [mode="fit"] - "fit" | "fill" | "stretch" | "pixel"
177
+ */
178
+ setDesignResolution(width: number, height: number, mode?: string): void;
179
+ /**
180
+ * @method clearDesignResolution
181
+ * @description Disables design-resolution scaling; the world reverts to using
182
+ * the canvas's CSS pixel size as world units.
183
+ */
184
+ clearDesignResolution(): void;
185
+ /**
186
+ * @method _viewportFor
187
+ * @description Computes the device-pixel GL viewport rect and the world-space
188
+ * extents (`worldW` x `worldH`) for a camera, honoring the active design
189
+ * resolution + fit mode. Without a design resolution it returns the camera's
190
+ * screen sub-rect at the canvas CSS size (legacy behavior).
191
+ * @private
192
+ */
193
+ private _viewportFor;
194
+ /**
195
+ * @method _clientToView
196
+ * @description Maps a client/CSS pixel coordinate to pre-camera view space
197
+ * (origin center, +Y up), honoring DPR, design resolution and fit mode
198
+ * (including letterbox offset). This is also the screen-space coordinate used
199
+ * for `screenSpace` objects. Camera transform is applied separately by
200
+ * `screenToWorld`.
201
+ * @private
202
+ * @returns {{x:number, y:number}}
203
+ */
204
+ private _clientToView;
205
+ /**
206
+ * @method screenToWorld
207
+ * @description Converts a client/CSS pixel coordinate (e.g. `event.clientX/Y`)
208
+ * to world space for a camera, accounting for device pixel ratio, the active
209
+ * design resolution + fit mode (including letterbox offset), and the camera's
210
+ * position / zoom / rotation. Use this for mouse picking instead of ad-hoc math.
211
+ * @param {number} clientX - Client X (relative to the viewport)
212
+ * @param {number} clientY - Client Y (relative to the viewport)
213
+ * @param {Camera} [camera] - The camera to unproject through (default primary)
214
+ * @returns {Vector2} - World-space position
215
+ */
216
+ screenToWorld(clientX: number, clientY: number, camera?: Camera): Vector2;
217
+ /**
218
+ * @method enablePostProcessing
219
+ * @description Turns on the post-processing pipeline (lazily creating the
220
+ * scene render target and processor). Add effects with addPostEffect.
221
+ * @returns {PostProcessor} - The processor (to add/remove effects)
222
+ */
223
+ enablePostProcessing(): PostProcessor;
224
+ /**
225
+ * @method disablePostProcessing
226
+ * @description Disables the pipeline (scene renders straight to the canvas).
227
+ */
228
+ disablePostProcessing(): void;
229
+ /**
230
+ * @method addPostEffect
231
+ * @description Appends a post-processing effect (enabling the pipeline if
232
+ * needed). See PostEffects for the built-ins.
233
+ * @param {PostEffect} effect
234
+ * @returns {Emerald} - this
235
+ */
236
+ addPostEffect(effect: PostEffect): Emerald;
237
+ /**
238
+ * @method removePostEffect
239
+ * @description Removes a previously added post-processing effect.
240
+ * @param {PostEffect} effect
241
+ * @returns {Emerald} - this
242
+ */
243
+ removePostEffect(effect: PostEffect): Emerald;
244
+ /**
245
+ * @method setAmbientLight
246
+ * @description Sets the ambient light for the scene
247
+ * @param {Vector3} vector3 - The ambient light color as a Vector3 instance
248
+ */
249
+ setAmbientLight(vector3: Vector3): void;
250
+ /**
251
+ * @method resize
252
+ * @description Resizes the canvas
253
+ * @param {number} width - The width of the canvas
254
+ * @param {number} height - The height of the canvas
255
+ * @param {number} [dpr] - Device pixel ratio override; defaults to
256
+ * `window.devicePixelRatio` (or 1 outside a browser)
257
+ */
258
+ resize(width: number, height: number, dpr?: number): void;
259
+ /**
260
+ * @method addPointLight
261
+ * @description Adds a point light to the scene
262
+ * @param {PointLight} pointLight - The point light to add
263
+ */
264
+ addPointLight(pointLight: PointLight): void;
265
+ /**
266
+ * @method addDirectionalLight
267
+ * @description Adds a directional light to the scene
268
+ * @param {DirectionalLight} directionalLight - The directional light to add
269
+ */
270
+ addDirectionalLight(directionalLight: DirectionalLight): void;
271
+ /**
272
+ * @method removeDirectionalLight
273
+ * @description Removes a directional light from the scene
274
+ * @param {DirectionalLight} directionalLight - The directional light to remove
275
+ */
276
+ removeDirectionalLight(directionalLight: DirectionalLight): void;
277
+ /**
278
+ * @method setBackgroundColor
279
+ * @description Sets the background color of the scene
280
+ * @param {Color} color - The background color
281
+ */
282
+ setBackgroundColor(color: Color): void;
283
+ /**
284
+ * @method run
285
+ * @description Starts an engine-owned game loop on requestAnimationFrame. Each
286
+ * frame it computes a delta time (clamped so a tab-switch stall can't produce
287
+ * a huge jump), optionally advances a fixed-timestep simulation, and calls
288
+ * your `update(dt, alpha)`. `alpha` is the 0..1 interpolation factor between
289
+ * the last and next fixed step (1 when no fixed step is configured), so you
290
+ * can render smoothly between simulation ticks.
291
+ *
292
+ * @param {Function} update - `(dt, alpha) => void`, called once per frame
293
+ * @param {Object} [options]
294
+ * @param {number} [options.maxDelta=0.25] - Max dt (seconds) per frame
295
+ * @param {number} [options.fixedStep=0] - Fixed simulation step in seconds
296
+ * (e.g. 1/60). 0 disables the fixed loop.
297
+ * @param {Function} [options.fixedUpdate] - `(step) => void`, called 0..N
298
+ * times per frame to advance the fixed-timestep simulation
299
+ * @param {number} [options.maxSubSteps=5] - Cap on fixed steps per frame
300
+ * @param {boolean} [options.pauseOnBlur=true] - Auto-pause when the tab is
301
+ * hidden/minimized (and on window blur if `pauseOnWindowBlur` is set)
302
+ * @param {boolean} [options.pauseOnWindowBlur=false] - Also pause on window blur
303
+ * @param {Function} [options.onPause] - Called when the loop pauses
304
+ * @param {Function} [options.onResume] - Called when the loop resumes
305
+ * @returns {Function} - A stop function (same as calling `stop()`)
306
+ */
307
+ run(update: Function, options?: {
308
+ maxDelta?: number;
309
+ fixedStep?: number;
310
+ fixedUpdate?: Function;
311
+ maxSubSteps?: number;
312
+ pauseOnBlur?: boolean;
313
+ pauseOnWindowBlur?: boolean;
314
+ onPause?: Function;
315
+ onResume?: Function;
316
+ }): Function;
317
+ /** @private */
318
+ private _running;
319
+ /** @private */
320
+ private _loopLastTime;
321
+ /** @private */
322
+ private _fixedAccumulator;
323
+ /** @private */
324
+ private _onPause;
325
+ /** @private */
326
+ private _onResume;
327
+ /** @private */
328
+ private _rafId;
329
+ /**
330
+ * @method stop
331
+ * @description Stops a loop previously started with run().
332
+ */
333
+ stop(): void;
334
+ /**
335
+ * @method pause
336
+ * @description Pauses the loop: `update`/`fixedUpdate` stop being called while
337
+ * the RAF keeps spinning. Time doesn't accumulate, so resuming produces no dt
338
+ * spike. Fires the `onPause` callback once.
339
+ */
340
+ pause(): void;
341
+ /**
342
+ * @method resume
343
+ * @description Resumes a paused loop and resyncs the clock so the first frame
344
+ * after resuming has ~0 dt. Fires the `onResume` callback once.
345
+ */
346
+ resume(): void;
347
+ /**
348
+ * @method _bindLifecycle
349
+ * @description Wires visibility/blur listeners that auto-pause the loop when
350
+ * the page is backgrounded, per the `run` options.
351
+ * @private
352
+ */
353
+ private _bindLifecycle;
354
+ /** @private */
355
+ private _onVisibility;
356
+ /** @private */
357
+ private _onWinBlur;
358
+ /** @private */
359
+ private _onWinFocus;
360
+ /**
361
+ * @method _unbindLifecycle
362
+ * @description Removes any listeners registered by `_bindLifecycle`.
363
+ * @private
364
+ */
365
+ private _unbindLifecycle;
366
+ /**
367
+ * @method drawScene
368
+ * @description Draws the scene
369
+ * @param {Scene} scene - The scene to draw
370
+ * @param {number} deltaTime - The delta time
371
+ */
372
+ drawScene(scene: Scene, deltaTime: number): void;
373
+ /**
374
+ * @method _renderCamera
375
+ * @description Renders the sorted draw order through a single camera into its
376
+ * viewport rectangle.
377
+ * @private
378
+ */
379
+ private _renderCamera;
380
+ /**
381
+ * @method addCamera
382
+ * @description Adds a camera to the render list (for split-screen, etc.).
383
+ * @param {Camera} camera - The camera to add
384
+ */
385
+ addCamera(camera: Camera): void;
386
+ /**
387
+ * @method removeCamera
388
+ * @description Removes a camera from the render list.
389
+ * @param {Camera} camera - The camera to remove
390
+ */
391
+ removeCamera(camera: Camera): void;
392
+ /**
393
+ * @method setCameras
394
+ * @description Replaces the camera list. The first camera becomes the primary
395
+ * `this.camera`.
396
+ * @param {Camera[]} cameras - The cameras to render
397
+ */
398
+ setCameras(cameras: Camera[]): void;
399
+ /**
400
+ * @method setCullingEnabled
401
+ * @description Enables or disables off-screen object culling.
402
+ * @param {boolean} enabled - Whether culling is enabled
403
+ */
404
+ setCullingEnabled(enabled: boolean): void;
405
+ /**
406
+ * @method _isVisible
407
+ * @description Conservative AABB visibility test against the view rectangle.
408
+ * Instanced objects (whose instances spread beyond the owner transform) and
409
+ * objects flagged `alwaysVisible` are never culled.
410
+ * @private
411
+ */
412
+ private _isVisible;
413
+ }
414
+ import Camera from "./Camera.js";
415
+ import { Vector3 } from "./Physics.js";
416
+ import PostProcessor from "./PostProcessor.js";
417
+ import { Vector2 } from "./Physics.js";
418
+ import PointLight from "./lights/PointLight.js";
419
+ import DirectionalLight from "./lights/DirectionalLight.js";
420
+ import Color from "./Color.js";
@@ -0,0 +1,159 @@
1
+ export default EmeraldDB;
2
+ /**
3
+ * @class EmeraldDB
4
+ * @description Async game-save storage on IndexedDB — the big-world companion
5
+ * to `Storage` (localStorage). Same versioned-envelope semantics (`{v,t,data}`
6
+ * with a `.bak` backup and forward migration), but with no ~5MB quota and no
7
+ * JSON round-trip: values are structured-cloned, so large nested world state
8
+ * (tile grids, inventories, NPC state) saves fast and loads intact, including
9
+ * Maps, Sets, Dates, and typed arrays.
10
+ *
11
+ * All methods are async. The database opens lazily on first use; call
12
+ * `configure()` first if you want a custom database/store name.
13
+ *
14
+ * @example
15
+ * // Save / load a world with schema migration:
16
+ * await EmeraldDB.save("world", world, { version: 3 });
17
+ * const world = await EmeraldDB.load("world", {
18
+ * version: 3,
19
+ * fallback: makeNewWorld(),
20
+ * migrate: (old, from) => upgradeWorld(old, from),
21
+ * });
22
+ *
23
+ * // Plain key/value (no envelope):
24
+ * await EmeraldDB.set("settings", { volume: 0.8 });
25
+ * const settings = await EmeraldDB.get("settings", {});
26
+ */
27
+ declare class EmeraldDB {
28
+ /**
29
+ * @method isSupported
30
+ * @description Whether IndexedDB exists in this environment.
31
+ * @returns {boolean}
32
+ */
33
+ static isSupported(): boolean;
34
+ /**
35
+ * @method configure
36
+ * @description Sets the database and object-store names. Call before the
37
+ * first read/write (once the database is open the names are fixed until
38
+ * `close()`).
39
+ * @param {Object} [options] - { name = "emerald-db", store = "kv" }
40
+ * @returns {EmeraldDB} - the class, for chaining
41
+ */
42
+ static configure(options?: any): EmeraldDB;
43
+ /**
44
+ * @method _open
45
+ * @description Lazily opens (and creates) the database. Shared promise so
46
+ * concurrent calls open once.
47
+ * @private
48
+ */
49
+ private static _open;
50
+ /**
51
+ * @method _tx
52
+ * @description Runs `fn(store)` inside a transaction and resolves with its
53
+ * request's result when the transaction completes.
54
+ * @private
55
+ */
56
+ private static _tx;
57
+ /**
58
+ * @method set
59
+ * @description Stores a value under a key (structured clone — objects, Maps,
60
+ * Sets, typed arrays all survive).
61
+ * @param {string} key
62
+ * @param {*} value
63
+ * @returns {Promise<void>}
64
+ */
65
+ static set(key: string, value: any): Promise<void>;
66
+ /**
67
+ * @method get
68
+ * @description Reads a value; resolves `fallback` when the key is missing.
69
+ * @param {string} key
70
+ * @param {*} [fallback=undefined]
71
+ * @returns {Promise<*>}
72
+ */
73
+ static get(key: string, fallback?: any): Promise<any>;
74
+ /**
75
+ * @method remove
76
+ * @description Deletes a key.
77
+ * @returns {Promise<void>}
78
+ */
79
+ static remove(key: any): Promise<void>;
80
+ /**
81
+ * @method keys
82
+ * @description Lists every key in the store.
83
+ * @returns {Promise<string[]>}
84
+ */
85
+ static keys(): Promise<string[]>;
86
+ /**
87
+ * @method clear
88
+ * @description Deletes everything in the store.
89
+ * @returns {Promise<void>}
90
+ */
91
+ static clear(): Promise<void>;
92
+ /**
93
+ * @method save
94
+ * @description Writes a versioned save: the payload is wrapped in a
95
+ * `{ v, t, data }` envelope and the previous value (if any) is mirrored to
96
+ * `key + ".bak"` in the same transaction, so a torn write can always recover.
97
+ * @param {string} key
98
+ * @param {*} data - Any structured-cloneable value
99
+ * @param {Object} [options] - { version = 1, backup = true }
100
+ * @returns {Promise<void>}
101
+ */
102
+ static save(key: string, data: any, options?: any): Promise<void>;
103
+ /**
104
+ * @method load
105
+ * @description Reads a versioned save. Falls back to the `.bak` mirror when
106
+ * the primary is missing/invalid, migrates old versions forward via
107
+ * `migrate(data, fromVersion)`, and (by default) rewrites migrated data in
108
+ * the new format.
109
+ * @param {string} key
110
+ * @param {Object} [options] - { version = 1, fallback = null, migrate, rewrite = true }
111
+ * @returns {Promise<*>}
112
+ */
113
+ static load(key: string, options?: any): Promise<any>;
114
+ /**
115
+ * @method hasSave
116
+ * @description Whether a versioned save (or its backup) exists.
117
+ * @returns {Promise<boolean>}
118
+ */
119
+ static hasSave(key: any): Promise<boolean>;
120
+ /**
121
+ * @method removeSave
122
+ * @description Deletes a versioned save AND its backup.
123
+ * @returns {Promise<void>}
124
+ */
125
+ static removeSave(key: any): Promise<void>;
126
+ /**
127
+ * @method importFromStorage
128
+ * @description Copies a save written by the localStorage `Storage` class
129
+ * into EmeraldDB (envelope preserved). Use once when upgrading an existing
130
+ * game to IndexedDB saves.
131
+ * @param {string} key
132
+ * @returns {Promise<boolean>} - true if something was imported
133
+ */
134
+ static importFromStorage(key: string): Promise<boolean>;
135
+ /**
136
+ * @method close
137
+ * @description Closes the database handle (reopens lazily on next use).
138
+ */
139
+ static close(): Promise<void>;
140
+ /**
141
+ * @method _asEnvelope
142
+ * @description Returns the value if it looks like a save envelope, else null.
143
+ * A plain (pre-versioning) object is wrapped as version 0 so it can migrate.
144
+ * @private
145
+ */
146
+ private static _asEnvelope;
147
+ /**
148
+ * @method _resolveEnvelope
149
+ * @description Pure envelope resolution shared by load(): applies fallback
150
+ * and forward migration. Exposed for tests.
151
+ * @private
152
+ */
153
+ private static _resolveEnvelope;
154
+ }
155
+ declare namespace EmeraldDB {
156
+ let _name: string;
157
+ let _store: string;
158
+ let _db: any;
159
+ }
@@ -1,3 +1,4 @@
1
+ export default FPSCounter;
1
2
  /**
2
3
  * @class FPSCounter
3
4
  * @description Represents a FPS counter
@@ -8,12 +9,9 @@ declare class FPSCounter {
8
9
  fps: number;
9
10
  fpsElement: HTMLDivElement;
10
11
  accumulatedTime: number;
11
- constructor();
12
12
  /**
13
13
  * @method update
14
14
  * @description Updates the FPS counter
15
15
  */
16
16
  update(): void;
17
17
  }
18
- export default FPSCounter;
19
- //# sourceMappingURL=FPSCounter.d.ts.map
@@ -0,0 +1,4 @@
1
+ export function initShaderProgram(gl: any, vShader: any, fShader: any): any;
2
+ export function loadShader(gl: any, type: any, source: any): any;
3
+ export function initVertexBuffer(gl: any, vertices: any): any;
4
+ export function initInstancedBuffer(gl: any, data: any, itemSize: any): any;