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
@@ -1,32 +1,72 @@
1
- import Emerald from "./Emerald";
2
- import BitmapText from "./BitmapText";
3
- import Color from "./Color";
4
- import Drawable from "./Drawable";
5
- import FPSCounter from "./FPSCounter";
6
- import Instance from "./Instance";
7
- import InstancedTexture from "./InstancedTexture";
8
- import { Physics, Vector2, Vector3 } from "./Physics";
9
- import Scene from "./Scene";
10
- import { Square2D, Triangle2D, Circle2D } from "./Shapes";
11
- import Storage from "./Storage";
12
- import Texture from "./Texture";
13
- import Time from "./Time";
14
- import Transform from "./Transform";
15
- import Particle from "./particlesystem/Particle";
16
- import Particles from "./particlesystem/Particles";
17
- import ParticleSettings from "./particlesystem/ParticleSettings";
18
- import AudioManager from "./managers/AudioManager";
19
- import CameraManager from "./managers/CameraManager";
20
- import EventManager from "./managers/EventManager";
21
- import SceneManager from "./managers/SceneManager";
22
- import DirectionalLight from "./lights/DirectionalLight";
23
- import PointLight from "./lights/PointLight";
24
- import BoxCollider from "./components/BoxCollider";
25
- import BoxColliderDebug from "./components/BoxColliderDebug";
26
- import CircleCollider from "./components/CircleCollider";
27
- import CircleColliderDebug from "./components/CircleColliderDebug";
28
- import Collider from "./components/Collider";
29
- import GameObject from "./components/GameObject";
30
- import RigidBody from "./components/RigidBody";
31
- export { Emerald, BitmapText, Color, Drawable, FPSCounter, Instance, InstancedTexture, Physics, Vector2, Vector3, Scene, Square2D, Triangle2D, Circle2D, Storage, Texture, Time, Transform, Particle, Particles, ParticleSettings, AudioManager, CameraManager, EventManager, SceneManager, DirectionalLight, PointLight, BoxCollider, BoxColliderDebug, CircleCollider, CircleColliderDebug, Collider, GameObject, RigidBody, };
32
- //# sourceMappingURL=index.d.ts.map
1
+ import Emerald from "./src/Emerald.js";
2
+ import BitmapText from "./src/BitmapText.js";
3
+ import Color from "./src/Color.js";
4
+ import Drawable from "./src/Drawable.js";
5
+ import FPSCounter from "./src/FPSCounter.js";
6
+ import Instance from "./src/Instance.js";
7
+ import InstancedTexture from "./src/InstancedTexture.js";
8
+ import { Physics } from "./src/Physics.js";
9
+ import { Vector2 } from "./src/Physics.js";
10
+ import { Vector3 } from "./src/Physics.js";
11
+ import Scene from "./src/Scene.js";
12
+ import { Square2D } from "./src/Shapes.js";
13
+ import { Triangle2D } from "./src/Shapes.js";
14
+ import { Circle2D } from "./src/Shapes.js";
15
+ import Storage from "./src/Storage.js";
16
+ import EmeraldDB from "./src/EmeraldDB.js";
17
+ import Texture from "./src/Texture.js";
18
+ import Time from "./src/Time.js";
19
+ import Transform from "./src/Transform.js";
20
+ import MathUtils from "./src/MathUtils.js";
21
+ import Pool from "./src/Pool.js";
22
+ import Animator from "./src/Animator.js";
23
+ import Tilemap from "./src/Tilemap.js";
24
+ import CameraController from "./src/CameraController.js";
25
+ import Camera from "./src/Camera.js";
26
+ import Easing from "./src/Easing.js";
27
+ import Tween from "./src/Tween.js";
28
+ import Timer from "./src/Timer.js";
29
+ import StateMachine from "./src/StateMachine.js";
30
+ import SpatialGrid from "./src/SpatialGrid.js";
31
+ import TextureAtlas from "./src/TextureAtlas.js";
32
+ import CanvasText from "./src/CanvasText.js";
33
+ import DebugOverlay from "./src/DebugOverlay.js";
34
+ import Serializer from "./src/Serializer.js";
35
+ import Coroutine from "./src/Coroutine.js";
36
+ import Interpolator from "./src/Interpolator.js";
37
+ import ScreenEffects from "./src/ScreenEffects.js";
38
+ import SpriteBatch from "./src/SpriteBatch.js";
39
+ import ParticleEmitter from "./src/ParticleEmitter.js";
40
+ import CollisionLayers from "./src/CollisionLayers.js";
41
+ import TiledMap from "./src/importers/TiledMap.js";
42
+ import Aseprite from "./src/importers/Aseprite.js";
43
+ import RenderTarget from "./src/RenderTarget.js";
44
+ import RenderStats from "./src/managers/RenderStats.js";
45
+ import PostProcessor from "./src/PostProcessor.js";
46
+ import { PostEffect } from "./src/PostProcessor.js";
47
+ import PostEffects from "./src/PostEffects.js";
48
+ import { BloomEffect } from "./src/PostEffects.js";
49
+ import Material from "./src/Material.js";
50
+ import UI from "./src/UI.js";
51
+ import InputManager from "./src/managers/InputManager.js";
52
+ import Particle from "./src/particlesystem/Particle.js";
53
+ import Particles from "./src/particlesystem/Particles.js";
54
+ import ParticleSettings from "./src/particlesystem/ParticleSettings.js";
55
+ import AudioManager from "./src/managers/AudioManager.js";
56
+ import CameraManager from "./src/managers/CameraManager.js";
57
+ import EventManager from "./src/managers/EventManager.js";
58
+ import SceneManager from "./src/managers/SceneManager.js";
59
+ import TextureManager from "./src/managers/TextureManager.js";
60
+ import AssetManager from "./src/managers/AssetManager.js";
61
+ import NetworkManager from "./src/managers/NetworkManager.js";
62
+ import DirectionalLight from "./src/lights/DirectionalLight.js";
63
+ import PointLight from "./src/lights/PointLight.js";
64
+ import BoxCollider from "./src/components/BoxCollider.js";
65
+ import BoxColliderDebug from "./src/components/BoxColliderDebug.js";
66
+ import CircleCollider from "./src/components/CircleCollider.js";
67
+ import CircleColliderDebug from "./src/components/CircleColliderDebug.js";
68
+ import Collider from "./src/components/Collider.js";
69
+ import GameObject from "./src/components/GameObject.js";
70
+ import RigidBody from "./src/components/RigidBody.js";
71
+ import Behaviour from "./src/components/Behaviour.js";
72
+ export { Emerald, BitmapText, Color, Drawable, FPSCounter, Instance, InstancedTexture, Physics, Vector2, Vector3, Scene, Square2D, Triangle2D, Circle2D, Storage, EmeraldDB, Texture, Time, Transform, MathUtils, Pool, Animator, Tilemap, CameraController, Camera, Easing, Tween, Timer, StateMachine, SpatialGrid, TextureAtlas, CanvasText, DebugOverlay, Serializer, Coroutine, Interpolator, ScreenEffects, SpriteBatch, ParticleEmitter, CollisionLayers, TiledMap, Aseprite, RenderTarget, RenderStats, PostProcessor, PostEffect, PostEffects, BloomEffect, Material, UI, InputManager, Particle, Particles, ParticleSettings, AudioManager, CameraManager, EventManager, SceneManager, TextureManager, AssetManager, NetworkManager, DirectionalLight, PointLight, BoxCollider, BoxColliderDebug, CircleCollider, CircleColliderDebug, Collider, GameObject, RigidBody, Behaviour };
@@ -0,0 +1,50 @@
1
+ export default Animator;
2
+ /**
3
+ * @class Animator
4
+ * @description A component that manages named animation clips for a Texture (or
5
+ * any Drawable) on the same GameObject. Register clips once, then switch between
6
+ * them by name — handy for character states like idle/run/jump.
7
+ *
8
+ * @example
9
+ * const anim = new Animator();
10
+ * anim.addClip("idle", [0, 1, 2, 3], { speed: 150 });
11
+ * anim.addClip("jump", [8, 9], { speed: 100, loop: false });
12
+ * obj.addComponent(texture);
13
+ * obj.addComponent(anim);
14
+ * anim.play("idle");
15
+ */
16
+ declare class Animator extends Behaviour {
17
+ clips: Map<any, any>;
18
+ current: any;
19
+ drawable: any;
20
+ /**
21
+ * @method addClip
22
+ * @description Registers a named clip.
23
+ * @param {string} name - The clip name
24
+ * @param {number[]} frames - Frame indices to play
25
+ * @param {Object} [options] - { speed = 100, loop = true }
26
+ * @returns {Animator} - this
27
+ */
28
+ addClip(name: string, frames: number[], options?: any): Animator;
29
+ /** @private */
30
+ private _resolveDrawable;
31
+ /**
32
+ * @method play
33
+ * @description Plays a registered clip. No-op if it's already current.
34
+ * @param {string} name - The clip name
35
+ * @returns {Animator} - this
36
+ */
37
+ play(name: string): Animator;
38
+ /**
39
+ * @method stop
40
+ * @description Stops the current animation.
41
+ */
42
+ stop(): void;
43
+ /**
44
+ * @method getCurrent
45
+ * @description Returns the name of the currently playing clip (or null).
46
+ * @returns {string|null}
47
+ */
48
+ getCurrent(): string | null;
49
+ }
50
+ import Behaviour from "./components/Behaviour.js";
@@ -1,7 +1,4 @@
1
- import Color from "./Color";
2
- import GameObject from "./components/GameObject";
3
- import InstancedTexture from "./InstancedTexture";
4
- import { Vector3 } from "./Physics";
1
+ export default BitmapText;
5
2
  /**
6
3
  * BitmapText class for rendering text using a bitmap font texture
7
4
  * @param {string} text - The text to display
@@ -20,24 +17,24 @@ import { Vector3 } from "./Physics";
20
17
  * @param {boolean} useLighting - Whether the text should react to lighting (default: false)
21
18
  */
22
19
  declare class BitmapText {
23
- text: string;
24
- texturePath: string;
25
- fontSize: number;
26
- color: Color;
27
- position: Vector3;
28
- rotation: number;
29
- letters: string;
30
- letterSpacing: number;
31
- frameWidth: number;
32
- frameHeight: number;
33
- framesPerRow: number;
34
- totalFrames: number;
35
- pixelArt: boolean;
20
+ constructor(text: any, texturePath: any, letters: any, letterSpacing: any, frameWidth: any, frameHeight: any, framesPerRow: any, totalFrames: any, pixelArt: any, fontSize: any, color: any, position: any, rotation: any, useLighting?: boolean);
21
+ text: any;
22
+ texturePath: any;
23
+ fontSize: any;
24
+ color: any;
25
+ position: any;
26
+ rotation: any;
27
+ letters: any;
28
+ letterSpacing: any;
29
+ frameWidth: any;
30
+ frameHeight: any;
31
+ framesPerRow: any;
32
+ totalFrames: any;
33
+ pixelArt: any;
36
34
  useLighting: boolean;
37
35
  gameObject: GameObject;
38
- letterDictionary: Record<string, number>;
36
+ letterDictionary: {};
39
37
  texture: InstancedTexture;
40
- constructor(text: string, texturePath: string, letters: string, letterSpacing: number, frameWidth: number, frameHeight: number, framesPerRow: number, totalFrames: number, pixelArt: boolean, fontSize: number, color: Color, position: Vector3, rotation: number, useLighting?: boolean);
41
38
  /**
42
39
  * @method setColor
43
40
  * @description Updates the color of the bitmap text
@@ -75,5 +72,6 @@ declare class BitmapText {
75
72
  */
76
73
  setLetterSpacing(letterSpacing: number): void;
77
74
  }
78
- export default BitmapText;
79
- //# sourceMappingURL=BitmapText.d.ts.map
75
+ import GameObject from "./components/GameObject.js";
76
+ import InstancedTexture from "./InstancedTexture.js";
77
+ import { Vector3 } from "./Physics.js";
@@ -0,0 +1,122 @@
1
+ export default Camera;
2
+ /**
3
+ * @class Camera
4
+ * @description A view into the scene with its own transform (position, zoom,
5
+ * rotation) and a viewport rectangle. Multiple cameras can be added to an
6
+ * Emerald instance to render split-screen or picture-in-picture. The viewport
7
+ * is expressed in normalized [0..1] coordinates with the origin at the
8
+ * bottom-left of the canvas (matching WebGL).
9
+ *
10
+ * Backward compatible with the previous inline camera: position is stored
11
+ * negated internally, and setPosition/getPosition/setZoom/getZoom behave the
12
+ * same, so EventManager and CameraController are unaffected.
13
+ *
14
+ * @example
15
+ * const left = new Camera({ viewport: { x: 0, y: 0, width: 0.5, height: 1 } });
16
+ * const right = new Camera({ viewport: { x: 0.5, y: 0, width: 0.5, height: 1 } });
17
+ * emerald.setCameras([left, right]);
18
+ */
19
+ declare class Camera {
20
+ constructor(options?: {});
21
+ transform: Transform;
22
+ viewport: {
23
+ x: any;
24
+ y: any;
25
+ width: any;
26
+ height: any;
27
+ };
28
+ active: boolean;
29
+ clearColor: any;
30
+ ignoreLayers: Set<any>;
31
+ onlyLayers: Set<any>;
32
+ excludeFromPost: boolean;
33
+ pixelSnap: boolean;
34
+ /**
35
+ * @method setPixelSnap
36
+ * @description When true, the camera's rendered position is rounded to whole
37
+ * screen pixels each frame (the stored position stays smooth). Use it for
38
+ * pixel-art games to eliminate sub-pixel shimmer and tile seams while a
39
+ * smooth-follow camera moves. Ignored while the camera is rotated.
40
+ * @param {boolean} snap
41
+ * @returns {Camera} - this
42
+ */
43
+ setPixelSnap(snap: boolean): Camera;
44
+ /**
45
+ * @method setExcludeFromPost
46
+ * @description When true, this camera renders straight to the screen AFTER the
47
+ * post-processing pass instead of into the post-processed scene buffer. Use it
48
+ * for HUD/UI cameras so effects like bloom don't affect the interface.
49
+ * @param {boolean} exclude
50
+ * @returns {Camera} - this
51
+ */
52
+ setExcludeFromPost(exclude: boolean): Camera;
53
+ /**
54
+ * @method setOnlyLayers
55
+ * @description Restricts the camera to rendering only the given layers (or
56
+ * pass null to clear the restriction).
57
+ * @param {number[]|null} layers
58
+ * @returns {Camera} - this
59
+ */
60
+ setOnlyLayers(layers: number[] | null): Camera;
61
+ /**
62
+ * @method setIgnoreLayers
63
+ * @description Replaces the set of layers this camera skips when rendering.
64
+ * @param {number[]} layers - Layer indices to ignore
65
+ * @returns {Camera} - this
66
+ */
67
+ setIgnoreLayers(layers: number[]): Camera;
68
+ /**
69
+ * @method ignoreLayer
70
+ * @description Adds a single layer to the ignore set.
71
+ * @param {number} layer
72
+ * @returns {Camera} - this
73
+ */
74
+ ignoreLayer(layer: number): Camera;
75
+ /**
76
+ * @method setPosition
77
+ * @description Sets the world-space center of the camera.
78
+ */
79
+ setPosition(x: any, y: any, z?: number): void;
80
+ /**
81
+ * @method getPosition
82
+ * @description Returns the world-space center of the camera.
83
+ */
84
+ getPosition(): {
85
+ x: number;
86
+ y: number;
87
+ z: number;
88
+ };
89
+ /**
90
+ * @method setZoom
91
+ * @description Sets the zoom (1 = default, >1 zooms in).
92
+ */
93
+ setZoom(zoom: any): void;
94
+ /**
95
+ * @method getZoom
96
+ * @returns {number}
97
+ */
98
+ getZoom(): number;
99
+ /**
100
+ * @method setRotation
101
+ * @description Sets the camera rotation in radians.
102
+ */
103
+ setRotation(radians: any): void;
104
+ /**
105
+ * @method getRotation
106
+ * @returns {number}
107
+ */
108
+ getRotation(): number;
109
+ /**
110
+ * @method setViewport
111
+ * @description Sets the normalized viewport rectangle (origin bottom-left).
112
+ * @returns {Camera} - this
113
+ */
114
+ setViewport(x: any, y: any, width: any, height: any): Camera;
115
+ /**
116
+ * @method setActive
117
+ * @description Enables/disables rendering of this camera.
118
+ * @returns {Camera} - this
119
+ */
120
+ setActive(active: any): Camera;
121
+ }
122
+ import Transform from "./Transform.js";
@@ -0,0 +1,107 @@
1
+ export default CameraController;
2
+ /**
3
+ * @class CameraController
4
+ * @description Drives an Emerald camera with follow, bounds clamping, zoom and
5
+ * screen shake. Construct it with `emerald.camera` and call `update(dt)` once
6
+ * per frame.
7
+ *
8
+ * @example
9
+ * const cam = new CameraController(emerald.camera);
10
+ * cam.follow(player.gameObject, 0.1).setBounds(-1000, -1000, 1000, 1000);
11
+ * // in the loop: cam.update(deltaTime);
12
+ */
13
+ declare class CameraController {
14
+ /**
15
+ * @param {Object} camera - The Emerald camera (e.g. emerald.camera)
16
+ */
17
+ constructor(camera: any);
18
+ camera: any;
19
+ target: any;
20
+ smoothing: number;
21
+ bounds: {
22
+ minX: any;
23
+ minY: any;
24
+ maxX: any;
25
+ maxY: any;
26
+ };
27
+ position: {
28
+ x: any;
29
+ y: any;
30
+ };
31
+ shakeIntensity: number;
32
+ shakeDuration: number;
33
+ shakeElapsed: number;
34
+ deadzone: {
35
+ x: number;
36
+ y: number;
37
+ };
38
+ /**
39
+ * @method setDeadzone
40
+ * @description Sets a centered follow deadzone. The camera only scrolls when
41
+ * the target moves outside this box, giving the player room to move without
42
+ * the camera reacting to every step. Pass 0/0 or null to disable.
43
+ * @param {number} halfWidth - Horizontal half-extent in world units
44
+ * @param {number} halfHeight - Vertical half-extent in world units
45
+ * @returns {CameraController} - this
46
+ */
47
+ setDeadzone(halfWidth: number, halfHeight: number): CameraController;
48
+ /**
49
+ * @method follow
50
+ * @description Follows a target each frame.
51
+ * @param {Object} target - GameObject/Instance (uses transform.position) or a { x, y }
52
+ * @param {number} smoothing - 0..1, higher snaps faster (1 = instant)
53
+ * @returns {CameraController} - this
54
+ */
55
+ follow(target: any, smoothing?: number): CameraController;
56
+ /**
57
+ * @method stopFollow
58
+ * @description Stops following the current target.
59
+ * @returns {CameraController} - this
60
+ */
61
+ stopFollow(): CameraController;
62
+ /**
63
+ * @method setBounds
64
+ * @description Clamps the camera center to a world-space rectangle.
65
+ * @returns {CameraController} - this
66
+ */
67
+ setBounds(minX: any, minY: any, maxX: any, maxY: any): CameraController;
68
+ /**
69
+ * @method clearBounds
70
+ * @description Removes bounds clamping.
71
+ * @returns {CameraController} - this
72
+ */
73
+ clearBounds(): CameraController;
74
+ /**
75
+ * @method setZoom
76
+ * @description Sets the camera zoom (1 = default, >1 zooms in).
77
+ * @returns {CameraController} - this
78
+ */
79
+ setZoom(zoom: any): CameraController;
80
+ /**
81
+ * @method getZoom
82
+ * @returns {number} - The current zoom
83
+ */
84
+ getZoom(): number;
85
+ /**
86
+ * @method setPosition
87
+ * @description Immediately moves the camera center.
88
+ * @returns {CameraController} - this
89
+ */
90
+ setPosition(x: any, y: any): CameraController;
91
+ /**
92
+ * @method shake
93
+ * @description Triggers a screen shake that decays over its duration.
94
+ * @param {number} intensity - Max offset in world units
95
+ * @param {number} duration - Duration in seconds
96
+ * @returns {CameraController} - this
97
+ */
98
+ shake(intensity: number, duration: number): CameraController;
99
+ /** @private */
100
+ private _targetPosition;
101
+ /**
102
+ * @method update
103
+ * @description Advances follow/shake and applies the result to the camera.
104
+ * @param {number} dt - Seconds since the last frame
105
+ */
106
+ update(dt: number): void;
107
+ }
@@ -0,0 +1,91 @@
1
+ export default CanvasText;
2
+ /**
3
+ * @class CanvasText
4
+ * @description Renders dynamic text using a system font by drawing to an
5
+ * offscreen 2D canvas and uploading it as a texture. Unlike BitmapText it needs
6
+ * no font sheet and supports any installed font. It's a Drawable component;
7
+ * `CanvasText.create()` returns a ready GameObject sized to the text.
8
+ *
9
+ * @example
10
+ * const label = CanvasText.create("Score: 0", {
11
+ * font: "bold 28px monospace", color: "#6ee7b7", screenSpace: true,
12
+ * });
13
+ * label.transform.position = new Vector3(-300, 260, 100);
14
+ * scene.add(label);
15
+ * label.getComponent(CanvasText).setText("Score: 120");
16
+ */
17
+ declare class CanvasText extends Drawable {
18
+ /**
19
+ * @method wrapText
20
+ * @description Pure helper that breaks `text` into rendered lines. Honors
21
+ * explicit `\n` line breaks and, when `maxWidth > 0`, greedily word-wraps each
22
+ * paragraph so no line measures wider than `maxWidth`. A single word longer
23
+ * than `maxWidth` is kept on its own line rather than being split.
24
+ * @param {(s:string)=>number} measure - Returns the pixel width of a string
25
+ * @param {string} text - The text to lay out
26
+ * @param {number} maxWidth - Wrap width in pixels (0 disables wrapping)
27
+ * @returns {string[]} - The lines to render top to bottom
28
+ */
29
+ static wrapText(measure: (s: string) => number, text: string, maxWidth: number): string[];
30
+ /**
31
+ * @method create
32
+ * @description Convenience factory returning a GameObject sized to the text.
33
+ * @param {string} text
34
+ * @param {Object} [options] - { name, position, screenSpace, font, color,
35
+ * maxWidth, align, lineHeight, padding }
36
+ * @returns {GameObject}
37
+ */
38
+ static create(text: string, options?: any): GameObject;
39
+ constructor(text: any, options?: {});
40
+ font: any;
41
+ fillStyle: any;
42
+ padding: any;
43
+ maxWidth: any;
44
+ align: any;
45
+ lineHeight: any;
46
+ /** @private */
47
+ private _canvas;
48
+ /** @private */
49
+ private _ctx;
50
+ useTexture: boolean;
51
+ width: number;
52
+ height: number;
53
+ /**
54
+ * @method setText
55
+ * @description Re-renders the text and re-uploads the texture. If attached to
56
+ * a GameObject, its scale is updated to match the new size.
57
+ * @param {string} text
58
+ */
59
+ setText(text: string): void;
60
+ text: string;
61
+ /**
62
+ * @method setMaxWidth
63
+ * @description Sets the wrap width in pixels (0 disables wrapping) and
64
+ * re-renders.
65
+ * @param {number} px
66
+ */
67
+ setMaxWidth(px: number): void;
68
+ /**
69
+ * @method setAlign
70
+ * @description Sets horizontal alignment ("left" | "center" | "right") and
71
+ * re-renders.
72
+ * @param {string} align
73
+ */
74
+ setAlign(align: string): void;
75
+ /**
76
+ * @method setColor
77
+ * @description Sets the text color (CSS color string) and re-renders.
78
+ * @param {string} cssColor
79
+ */
80
+ setColor(cssColor: string): void;
81
+ /**
82
+ * @method getSize
83
+ * @returns {{width:number, height:number}} - The canvas pixel size
84
+ */
85
+ getSize(): {
86
+ width: number;
87
+ height: number;
88
+ };
89
+ }
90
+ import Drawable from "./Drawable.js";
91
+ import GameObject from "./components/GameObject.js";
@@ -0,0 +1,58 @@
1
+ export default CollisionLayers;
2
+ declare class CollisionLayers {
3
+ /**
4
+ * @method define
5
+ * @description Registers one or more named layers (in order), assigning each
6
+ * the next free category bit. Re-defining an existing name returns its
7
+ * existing bit. Returns the bit of the last name passed.
8
+ * @param {...string} names
9
+ * @returns {number}
10
+ */
11
+ static define(...names: string[]): number;
12
+ /**
13
+ * @method bit
14
+ * @description Returns the category bit for a layer name, registering it on
15
+ * first use.
16
+ * @param {string} name
17
+ * @returns {number}
18
+ */
19
+ static bit(name: string): number;
20
+ /**
21
+ * @method mask
22
+ * @description Computes a combined mask from layer names. Accepts a single
23
+ * name, an array of names, a number (passed through), or "all"/null for
24
+ * "collide with everything".
25
+ * @param {string|string[]|number|null} layers
26
+ * @returns {number}
27
+ */
28
+ static mask(layers: string | string[] | number | null): number;
29
+ /**
30
+ * @method reset
31
+ * @description Clears all registered layers (mainly for tests).
32
+ */
33
+ static reset(): void;
34
+ }
35
+ declare namespace CollisionLayers {
36
+ export let _bits: Map<any, any>;
37
+ export let _next: number;
38
+ export { ALL_BITS as ALL };
39
+ }
40
+ /**
41
+ * @class CollisionLayers
42
+ * @description A small registry that maps human-readable layer names to the
43
+ * category bits planck uses for collision filtering, so games can say
44
+ * "players collide with ground and enemies, but not with each other" without
45
+ * juggling raw bitmasks.
46
+ *
47
+ * Two fixtures collide only if each one's category is in the other's mask, so
48
+ * filtering is symmetric by construction. Up to 16 distinct layers are
49
+ * supported (planck filter bits are 16-bit).
50
+ *
51
+ * @example
52
+ * CollisionLayers.define("ground", "player", "enemy", "pickup");
53
+ * playerCollider.setCategory("player");
54
+ * playerCollider.setCollidesWith(["ground", "enemy", "pickup"]);
55
+ * enemyCollider.setCategory("enemy");
56
+ * enemyCollider.setCollidesWith(["ground", "player"]); // enemies ignore each other
57
+ */
58
+ declare const ALL_BITS: 65535;
@@ -1,3 +1,4 @@
1
+ export default Color;
1
2
  /**
2
3
  * @class Color
3
4
  * @description Represents a color
@@ -7,11 +8,9 @@
7
8
  * @param {number} a - The alpha value
8
9
  */
9
10
  declare class Color {
10
- r: number;
11
- g: number;
12
- b: number;
11
+ constructor(r: any, g: any, b: any, a?: number);
12
+ r: any;
13
+ g: any;
14
+ b: any;
13
15
  a: number;
14
- constructor(r: number, g: number, b: number, a?: number);
15
16
  }
16
- export default Color;
17
- //# sourceMappingURL=Color.d.ts.map