emeraldengine 2.2.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2198 -968
- package/dist/types/index.d.ts +75 -32
- package/dist/types/src/Animator.d.ts +50 -0
- package/dist/types/{BitmapText.d.ts → src/BitmapText.d.ts} +19 -21
- package/dist/types/src/Camera.d.ts +122 -0
- package/dist/types/src/CameraController.d.ts +107 -0
- package/dist/types/src/CanvasText.d.ts +91 -0
- package/dist/types/src/CollisionLayers.d.ts +58 -0
- package/dist/types/{Color.d.ts → src/Color.d.ts} +6 -6
- package/dist/types/src/Coroutine.d.ts +111 -0
- package/dist/types/src/DebugOverlay.d.ts +86 -0
- package/dist/types/src/Drawable.d.ts +271 -0
- package/dist/types/src/Easing.d.ts +22 -0
- package/dist/types/src/Emerald.d.ts +420 -0
- package/dist/types/src/EmeraldDB.d.ts +159 -0
- package/dist/types/{FPSCounter.d.ts → src/FPSCounter.d.ts} +1 -3
- package/dist/types/src/GLUtils.d.ts +4 -0
- package/dist/types/{Instance.d.ts → src/Instance.d.ts} +37 -15
- package/dist/types/{InstancedTexture.d.ts → src/InstancedTexture.d.ts} +75 -23
- package/dist/types/src/Interpolator.d.ts +66 -0
- package/dist/types/src/Material.d.ts +87 -0
- package/dist/types/src/MathUtils.d.ts +81 -0
- package/dist/types/src/ParticleEmitter.d.ts +131 -0
- package/dist/types/src/Physics.d.ts +337 -0
- package/dist/types/src/Pool.d.ts +53 -0
- package/dist/types/src/PostEffects.d.ts +68 -0
- package/dist/types/src/PostProcessor.d.ts +124 -0
- package/dist/types/src/RenderTarget.d.ts +56 -0
- package/dist/types/src/Scene.d.ts +62 -0
- package/dist/types/src/ScreenEffects.d.ts +111 -0
- package/dist/types/src/Serializer.d.ts +86 -0
- package/dist/types/src/Shaders.d.ts +2 -0
- package/dist/types/{Shapes.d.ts → src/Shapes.d.ts} +4 -6
- package/dist/types/src/SpatialGrid.d.ts +50 -0
- package/dist/types/src/SpriteBatch.d.ts +89 -0
- package/dist/types/src/StateMachine.d.ts +59 -0
- package/dist/types/src/Storage.d.ts +89 -0
- package/dist/types/{Texture.d.ts → src/Texture.d.ts} +3 -4
- package/dist/types/src/TextureAtlas.d.ts +55 -0
- package/dist/types/src/Tilemap.d.ts +91 -0
- package/dist/types/src/Time.d.ts +53 -0
- package/dist/types/src/Timer.d.ts +54 -0
- package/dist/types/src/Transform.d.ts +94 -0
- package/dist/types/src/Tween.d.ts +81 -0
- package/dist/types/src/UI.d.ts +121 -0
- package/dist/types/src/components/Behaviour.d.ts +71 -0
- package/dist/types/{components → src/components}/BoxCollider.d.ts +14 -14
- package/dist/types/src/components/BoxColliderDebug.d.ts +15 -0
- package/dist/types/{components → src/components}/CircleCollider.d.ts +14 -12
- package/dist/types/src/components/CircleColliderDebug.d.ts +15 -0
- package/dist/types/src/components/Collider.d.ts +102 -0
- package/dist/types/src/components/GameObject.d.ts +135 -0
- package/dist/types/src/components/PolygonCollider.d.ts +33 -0
- package/dist/types/src/components/RigidBody.d.ts +456 -0
- package/dist/types/src/importers/Aseprite.d.ts +79 -0
- package/dist/types/src/importers/ForgeLevel.d.ts +97 -0
- package/dist/types/src/importers/TiledMap.d.ts +62 -0
- package/dist/types/{lights → src/lights}/DirectionalLight.d.ts +7 -9
- package/dist/types/{lights → src/lights}/PointLight.d.ts +6 -9
- package/dist/types/src/managers/AssetManager.d.ts +116 -0
- package/dist/types/src/managers/AudioManager.d.ts +259 -0
- package/dist/types/{managers → src/managers}/CameraManager.d.ts +8 -8
- package/dist/types/{managers → src/managers}/EventManager.d.ts +46 -32
- package/dist/types/src/managers/GLManager.d.ts +84 -0
- package/dist/types/src/managers/GLState.d.ts +37 -0
- package/dist/types/src/managers/Gamepad.d.ts +102 -0
- package/dist/types/src/managers/IDManager.d.ts +31 -0
- package/dist/types/src/managers/InputManager.d.ts +381 -0
- package/dist/types/src/managers/NetworkManager.d.ts +93 -0
- package/dist/types/src/managers/RenderStats.d.ts +34 -0
- package/dist/types/src/managers/SceneManager.d.ts +44 -0
- package/dist/types/src/managers/ShaderManager.d.ts +55 -0
- package/dist/types/src/managers/TextureManager.d.ts +102 -0
- package/dist/types/src/particlesystem/Particle.d.ts +64 -0
- package/dist/types/{particlesystem → src/particlesystem}/ParticleSettings.d.ts +32 -24
- package/dist/types/{particlesystem → src/particlesystem}/Particles.d.ts +20 -12
- package/dist/types/src/physics/AABB.d.ts +92 -0
- package/dist/types/src/physics/Body.d.ts +435 -0
- package/dist/types/src/physics/BodyType.d.ts +6 -0
- package/dist/types/src/physics/BroadPhase.d.ts +210 -0
- package/dist/types/src/physics/Collision.d.ts +102 -0
- package/dist/types/src/physics/Contact.d.ts +206 -0
- package/dist/types/src/physics/ContactSolver.d.ts +108 -0
- package/dist/types/src/physics/Distance.d.ts +54 -0
- package/dist/types/src/physics/DistanceJoint.d.ts +90 -0
- package/dist/types/src/physics/Fixture.d.ts +221 -0
- package/dist/types/src/physics/Island.d.ts +52 -0
- package/dist/types/src/physics/Joint.d.ts +59 -0
- package/dist/types/src/physics/Math2D.d.ts +371 -0
- package/dist/types/src/physics/RevoluteJoint.d.ts +119 -0
- package/dist/types/src/physics/Settings.d.ts +22 -0
- package/dist/types/src/physics/Shapes.d.ts +207 -0
- package/dist/types/src/physics/TimeOfImpact.d.ts +22 -0
- package/dist/types/src/physics/World.d.ts +274 -0
- package/dist/types/src/physics/index.d.ts +34 -0
- package/index.js +78 -0
- package/package.json +73 -60
- package/src/Animator.js +95 -0
- package/src/BitmapText.js +6 -5
- package/src/Camera.js +183 -0
- package/src/CameraController.js +192 -0
- package/src/CanvasText.js +281 -0
- package/src/CollisionLayers.js +86 -0
- package/src/Color.js +26 -18
- package/src/Coroutine.js +259 -0
- package/src/DebugOverlay.js +246 -0
- package/src/Drawable.js +842 -582
- package/src/Easing.js +57 -0
- package/src/Emerald.js +1150 -459
- package/src/EmeraldDB.js +328 -0
- package/src/FPSCounter.js +43 -43
- package/src/GLUtils.js +60 -67
- package/src/Instance.js +41 -5
- package/src/InstancedTexture.js +308 -127
- package/src/Interpolator.js +124 -0
- package/src/Material.js +202 -0
- package/src/MathUtils.js +134 -0
- package/src/ParticleEmitter.js +284 -0
- package/src/Physics.js +431 -40
- package/src/Pool.js +85 -0
- package/src/PostEffects.js +296 -0
- package/src/PostProcessor.js +304 -0
- package/src/RenderTarget.js +134 -0
- package/src/Scene.js +115 -83
- package/src/ScreenEffects.js +266 -0
- package/src/Serializer.js +131 -0
- package/src/Shaders.js +150 -165
- package/src/Shapes.js +118 -129
- package/src/SpatialGrid.js +111 -0
- package/src/SpriteBatch.js +299 -0
- package/src/StateMachine.js +82 -0
- package/src/Storage.js +175 -47
- package/src/Texture.js +58 -67
- package/src/TextureAtlas.js +96 -0
- package/src/Tilemap.js +274 -0
- package/src/Time.js +51 -6
- package/src/Timer.js +99 -0
- package/src/Transform.js +100 -7
- package/src/Tween.js +160 -0
- package/src/UI.js +394 -0
- package/src/components/Behaviour.js +90 -0
- package/src/components/BoxCollider.js +29 -12
- package/src/components/BoxColliderDebug.js +3 -4
- package/src/components/CircleCollider.js +26 -12
- package/src/components/CircleColliderDebug.js +25 -24
- package/src/components/Collider.js +150 -34
- package/src/components/GameObject.js +130 -21
- package/src/components/PolygonCollider.js +55 -0
- package/src/components/RigidBody.js +556 -8
- package/src/importers/Aseprite.js +142 -0
- package/src/importers/ForgeLevel.js +581 -0
- package/src/importers/TiledMap.js +158 -0
- package/src/lights/DirectionalLight.js +6 -15
- package/src/lights/PointLight.js +4 -4
- package/src/managers/AssetManager.js +239 -0
- package/src/managers/AudioManager.js +565 -146
- package/src/managers/EventManager.js +488 -477
- package/src/managers/GLManager.js +57 -0
- package/src/managers/GLState.js +70 -0
- package/src/managers/Gamepad.js +126 -0
- package/src/managers/IDManager.js +24 -2
- package/src/managers/InputManager.js +905 -0
- package/src/managers/NetworkManager.js +178 -0
- package/src/managers/RenderStats.js +34 -0
- package/src/managers/SceneManager.js +30 -0
- package/src/managers/ShaderManager.js +0 -2
- package/src/managers/TextureManager.js +218 -0
- package/src/particlesystem/Particle.js +82 -7
- package/src/particlesystem/ParticleSettings.js +21 -3
- package/src/particlesystem/Particles.js +80 -31
- package/src/physics/AABB.js +207 -0
- package/src/physics/Body.js +862 -0
- package/src/physics/BodyType.js +16 -0
- package/src/physics/BroadPhase.js +641 -0
- package/src/physics/Collision.js +534 -0
- package/src/physics/Contact.js +500 -0
- package/src/physics/ContactSolver.js +526 -0
- package/src/physics/Distance.js +403 -0
- package/src/physics/DistanceJoint.js +227 -0
- package/src/physics/Fixture.js +346 -0
- package/src/physics/Island.js +203 -0
- package/src/physics/Joint.js +78 -0
- package/src/physics/Math2D.js +573 -0
- package/src/physics/RevoluteJoint.js +278 -0
- package/src/physics/Settings.js +78 -0
- package/src/physics/Shapes.js +549 -0
- package/src/physics/TimeOfImpact.js +87 -0
- package/src/physics/World.js +731 -0
- package/src/physics/index.js +79 -0
- package/dist/types/Drawable.d.ts +0 -157
- package/dist/types/Emerald.d.ts +0 -73
- package/dist/types/GLUtils.d.ts +0 -6
- package/dist/types/Physics.d.ts +0 -139
- package/dist/types/Scene.d.ts +0 -39
- package/dist/types/Shaders.d.ts +0 -4
- package/dist/types/Storage.d.ts +0 -46
- package/dist/types/Time.d.ts +0 -22
- package/dist/types/Transform.d.ts +0 -41
- package/dist/types/components/BoxColliderDebug.d.ts +0 -19
- package/dist/types/components/CircleColliderDebug.d.ts +0 -19
- package/dist/types/components/Collider.d.ts +0 -53
- package/dist/types/components/GameObject.d.ts +0 -72
- package/dist/types/components/RigidBody.d.ts +0 -104
- package/dist/types/managers/AudioManager.d.ts +0 -60
- package/dist/types/managers/GLManager.d.ts +0 -47
- package/dist/types/managers/IDManager.d.ts +0 -21
- package/dist/types/managers/SceneManager.d.ts +0 -22
- package/dist/types/particlesystem/Particle.d.ts +0 -42
package/dist/types/index.d.ts
CHANGED
|
@@ -1,32 +1,75 @@
|
|
|
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
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
import
|
|
31
|
-
|
|
32
|
-
|
|
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 ForgeLevel from "./src/importers/ForgeLevel.js";
|
|
44
|
+
import RenderTarget from "./src/RenderTarget.js";
|
|
45
|
+
import RenderStats from "./src/managers/RenderStats.js";
|
|
46
|
+
import PostProcessor from "./src/PostProcessor.js";
|
|
47
|
+
import { PostEffect } from "./src/PostProcessor.js";
|
|
48
|
+
import PostEffects from "./src/PostEffects.js";
|
|
49
|
+
import { BloomEffect } from "./src/PostEffects.js";
|
|
50
|
+
import Material from "./src/Material.js";
|
|
51
|
+
import UI from "./src/UI.js";
|
|
52
|
+
import InputManager from "./src/managers/InputManager.js";
|
|
53
|
+
import Gamepad from "./src/managers/Gamepad.js";
|
|
54
|
+
import Particle from "./src/particlesystem/Particle.js";
|
|
55
|
+
import Particles from "./src/particlesystem/Particles.js";
|
|
56
|
+
import ParticleSettings from "./src/particlesystem/ParticleSettings.js";
|
|
57
|
+
import AudioManager from "./src/managers/AudioManager.js";
|
|
58
|
+
import CameraManager from "./src/managers/CameraManager.js";
|
|
59
|
+
import EventManager from "./src/managers/EventManager.js";
|
|
60
|
+
import SceneManager from "./src/managers/SceneManager.js";
|
|
61
|
+
import TextureManager from "./src/managers/TextureManager.js";
|
|
62
|
+
import AssetManager from "./src/managers/AssetManager.js";
|
|
63
|
+
import NetworkManager from "./src/managers/NetworkManager.js";
|
|
64
|
+
import DirectionalLight from "./src/lights/DirectionalLight.js";
|
|
65
|
+
import PointLight from "./src/lights/PointLight.js";
|
|
66
|
+
import BoxCollider from "./src/components/BoxCollider.js";
|
|
67
|
+
import BoxColliderDebug from "./src/components/BoxColliderDebug.js";
|
|
68
|
+
import CircleCollider from "./src/components/CircleCollider.js";
|
|
69
|
+
import CircleColliderDebug from "./src/components/CircleColliderDebug.js";
|
|
70
|
+
import PolygonCollider from "./src/components/PolygonCollider.js";
|
|
71
|
+
import Collider from "./src/components/Collider.js";
|
|
72
|
+
import GameObject from "./src/components/GameObject.js";
|
|
73
|
+
import RigidBody from "./src/components/RigidBody.js";
|
|
74
|
+
import Behaviour from "./src/components/Behaviour.js";
|
|
75
|
+
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, ForgeLevel, RenderTarget, RenderStats, PostProcessor, PostEffect, PostEffects, BloomEffect, Material, UI, InputManager, Gamepad, Particle, Particles, ParticleSettings, AudioManager, CameraManager, EventManager, SceneManager, TextureManager, AssetManager, NetworkManager, DirectionalLight, PointLight, BoxCollider, BoxColliderDebug, CircleCollider, CircleColliderDebug, PolygonCollider, 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
|
-
|
|
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:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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:
|
|
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
|
-
|
|
79
|
-
|
|
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 the physics engine uses for collision filtering, so games can
|
|
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 (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,10 @@
|
|
|
7
8
|
* @param {number} a - The alpha value
|
|
8
9
|
*/
|
|
9
10
|
declare class Color {
|
|
10
|
-
|
|
11
|
-
g: number;
|
|
12
|
-
|
|
11
|
+
static fromHex(hex: any): Color;
|
|
12
|
+
constructor(r: any, g: any, b: any, a?: number);
|
|
13
|
+
r: any;
|
|
14
|
+
g: any;
|
|
15
|
+
b: any;
|
|
13
16
|
a: number;
|
|
14
|
-
constructor(r: number, g: number, b: number, a?: number);
|
|
15
17
|
}
|
|
16
|
-
export default Color;
|
|
17
|
-
//# sourceMappingURL=Color.d.ts.map
|