emeraldengine 2.2.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2359 -968
- package/dist/types/index.d.ts +72 -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} +5 -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} +60 -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 +80 -0
- package/dist/types/src/ParticleEmitter.d.ts +131 -0
- package/dist/types/{Physics.d.ts → src/Physics.d.ts} +88 -20
- 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 +96 -0
- package/dist/types/src/components/GameObject.d.ts +135 -0
- package/dist/types/src/components/RigidBody.d.ts +183 -0
- package/dist/types/src/importers/Aseprite.d.ts +79 -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/IDManager.d.ts +31 -0
- package/dist/types/src/managers/InputManager.d.ts +290 -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/index.js +72 -0
- package/package.json +74 -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 +18 -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 +251 -118
- package/src/Interpolator.js +124 -0
- package/src/Material.js +202 -0
- package/src/MathUtils.js +133 -0
- package/src/ParticleEmitter.js +284 -0
- package/src/Physics.js +186 -5
- 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 +22 -3
- package/src/components/CircleCollider.js +19 -3
- package/src/components/CircleColliderDebug.js +24 -24
- package/src/components/Collider.js +140 -34
- package/src/components/GameObject.js +130 -21
- package/src/components/RigidBody.js +123 -2
- package/src/importers/Aseprite.js +142 -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/IDManager.js +24 -2
- package/src/managers/InputManager.js +779 -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/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/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
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
interface ParticleSettingsConfig {
|
|
3
|
-
lifetime?: number;
|
|
4
|
-
velocity?: Vector2;
|
|
5
|
-
gravity?: Vector2;
|
|
6
|
-
amount?: number;
|
|
7
|
-
direction?: Vector2;
|
|
8
|
-
spread?: number;
|
|
9
|
-
emissionRate?: number;
|
|
10
|
-
frame?: number;
|
|
11
|
-
offset?: number;
|
|
12
|
-
rotation?: number;
|
|
13
|
-
scale?: Vector2;
|
|
14
|
-
animation?: any;
|
|
15
|
-
}
|
|
1
|
+
export default ParticleSettings;
|
|
16
2
|
/**
|
|
17
3
|
* @class ParticleSettings
|
|
18
4
|
* @description Represents the settings for a particle system
|
|
@@ -30,6 +16,23 @@ interface ParticleSettingsConfig {
|
|
|
30
16
|
* @param {Array} animation - The animation of the particle
|
|
31
17
|
*/
|
|
32
18
|
declare class ParticleSettings {
|
|
19
|
+
constructor({ lifetime, velocity, gravity, amount, direction, spread, emissionRate, frame, offset, rotation, scale, animation, shape, shapeRadius, shapeSize, scaleOverLife, alphaOverLife, colorOverLife, rotationSpeed, drag, }?: {
|
|
20
|
+
lifetime?: number;
|
|
21
|
+
velocity?: Vector2;
|
|
22
|
+
gravity?: Vector2;
|
|
23
|
+
amount?: number;
|
|
24
|
+
direction?: Vector2;
|
|
25
|
+
spread?: number;
|
|
26
|
+
emissionRate?: number;
|
|
27
|
+
shape?: string;
|
|
28
|
+
shapeRadius?: number;
|
|
29
|
+
shapeSize?: Vector2;
|
|
30
|
+
scaleOverLife?: any;
|
|
31
|
+
alphaOverLife?: any;
|
|
32
|
+
colorOverLife?: any;
|
|
33
|
+
rotationSpeed?: number;
|
|
34
|
+
drag?: number;
|
|
35
|
+
});
|
|
33
36
|
lifetime: number;
|
|
34
37
|
velocity: Vector2;
|
|
35
38
|
gravity: Vector2;
|
|
@@ -37,13 +40,18 @@ declare class ParticleSettings {
|
|
|
37
40
|
direction: Vector2;
|
|
38
41
|
spread: number;
|
|
39
42
|
emissionRate: number;
|
|
40
|
-
frame
|
|
41
|
-
offset
|
|
42
|
-
rotation
|
|
43
|
-
scale
|
|
44
|
-
animation
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
frame: any;
|
|
44
|
+
offset: any;
|
|
45
|
+
rotation: any;
|
|
46
|
+
scale: any;
|
|
47
|
+
animation: any;
|
|
48
|
+
shape: string;
|
|
49
|
+
shapeRadius: number;
|
|
50
|
+
shapeSize: Vector2;
|
|
51
|
+
scaleOverLife: any;
|
|
52
|
+
alphaOverLife: any;
|
|
53
|
+
colorOverLife: any;
|
|
54
|
+
rotationSpeed: number;
|
|
55
|
+
drag: number;
|
|
47
56
|
}
|
|
48
|
-
|
|
49
|
-
//# sourceMappingURL=ParticleSettings.d.ts.map
|
|
57
|
+
import { Vector2 } from "../Physics.js";
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import GameObject from "../components/GameObject";
|
|
2
|
-
import InstancedTexture from "../InstancedTexture";
|
|
3
|
-
import { Vector2, Vector3 } from "../Physics";
|
|
4
|
-
import Particle from "./Particle";
|
|
5
|
-
import ParticleSettings from "./ParticleSettings";
|
|
6
1
|
/**
|
|
7
2
|
* @class Particles
|
|
8
3
|
* @description Represents a particle system
|
|
@@ -16,13 +11,14 @@ import ParticleSettings from "./ParticleSettings";
|
|
|
16
11
|
* @param {ParticleSettings} settings - The settings for the particle system
|
|
17
12
|
*/
|
|
18
13
|
export default class Particles {
|
|
14
|
+
constructor(name: any, texturePath: any, frameWidth: any, frameHeight: any, framesPerRow: any, totalFrames: any, duration?: number, settings?: any);
|
|
19
15
|
settings: ParticleSettings;
|
|
20
16
|
position: Vector3;
|
|
21
|
-
rotation:
|
|
22
|
-
scale:
|
|
23
|
-
particles:
|
|
17
|
+
rotation: any;
|
|
18
|
+
scale: any;
|
|
19
|
+
particles: any[];
|
|
24
20
|
duration: number;
|
|
25
|
-
offset:
|
|
21
|
+
offset: any;
|
|
26
22
|
elapsed: number;
|
|
27
23
|
active: boolean;
|
|
28
24
|
instanceCount: number;
|
|
@@ -31,14 +27,15 @@ export default class Particles {
|
|
|
31
27
|
stopped: boolean;
|
|
32
28
|
gameObject: GameObject;
|
|
33
29
|
instancedTexture: InstancedTexture;
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
/** @private */
|
|
31
|
+
private _pool;
|
|
36
32
|
/**
|
|
37
33
|
* @method play
|
|
38
34
|
* @description Plays the particle system
|
|
39
35
|
* @param {Vector3} newPosition - The position to play the particle system at
|
|
40
36
|
*/
|
|
41
37
|
play(newPosition: Vector3): void;
|
|
38
|
+
lastEmitPosition: Vector3;
|
|
42
39
|
/**
|
|
43
40
|
* @method emitParticles
|
|
44
41
|
* @description Emits particles
|
|
@@ -46,6 +43,14 @@ export default class Particles {
|
|
|
46
43
|
* @param {Vector3} position - The position to emit the particles at
|
|
47
44
|
*/
|
|
48
45
|
emitParticles(count: number, position: Vector3): void;
|
|
46
|
+
/**
|
|
47
|
+
* @method _spawnOffset
|
|
48
|
+
* @description Returns a spawn offset { x, y } from the emitter center based on
|
|
49
|
+
* the configured emitter shape.
|
|
50
|
+
* @param {number} finalAngle - The chosen emission angle (for the cone shape)
|
|
51
|
+
* @private
|
|
52
|
+
*/
|
|
53
|
+
private _spawnOffset;
|
|
49
54
|
/**
|
|
50
55
|
* @method update
|
|
51
56
|
* @description Updates the particle system
|
|
@@ -68,4 +73,7 @@ export default class Particles {
|
|
|
68
73
|
*/
|
|
69
74
|
reset(): void;
|
|
70
75
|
}
|
|
71
|
-
|
|
76
|
+
import ParticleSettings from "./ParticleSettings.js";
|
|
77
|
+
import { Vector3 } from "../Physics.js";
|
|
78
|
+
import GameObject from "../components/GameObject.js";
|
|
79
|
+
import InstancedTexture from "../InstancedTexture.js";
|
package/index.js
CHANGED
|
@@ -9,9 +9,40 @@ import { Physics, Vector2, Vector3 } from "./src/Physics.js";
|
|
|
9
9
|
import Scene from "./src/Scene.js";
|
|
10
10
|
import { Square2D, Triangle2D, Circle2D } from "./src/Shapes.js";
|
|
11
11
|
import Storage from "./src/Storage.js";
|
|
12
|
+
import EmeraldDB from "./src/EmeraldDB.js";
|
|
12
13
|
import Texture from "./src/Texture.js";
|
|
13
14
|
import Time from "./src/Time.js";
|
|
14
15
|
import Transform from "./src/Transform.js";
|
|
16
|
+
import MathUtils from "./src/MathUtils.js";
|
|
17
|
+
import Pool from "./src/Pool.js";
|
|
18
|
+
import Animator from "./src/Animator.js";
|
|
19
|
+
import Tilemap from "./src/Tilemap.js";
|
|
20
|
+
import CameraController from "./src/CameraController.js";
|
|
21
|
+
import Camera from "./src/Camera.js";
|
|
22
|
+
import Easing from "./src/Easing.js";
|
|
23
|
+
import Tween from "./src/Tween.js";
|
|
24
|
+
import Timer from "./src/Timer.js";
|
|
25
|
+
import StateMachine from "./src/StateMachine.js";
|
|
26
|
+
import SpatialGrid from "./src/SpatialGrid.js";
|
|
27
|
+
import TextureAtlas from "./src/TextureAtlas.js";
|
|
28
|
+
import CanvasText from "./src/CanvasText.js";
|
|
29
|
+
import DebugOverlay from "./src/DebugOverlay.js";
|
|
30
|
+
import Serializer from "./src/Serializer.js";
|
|
31
|
+
import Coroutine from "./src/Coroutine.js";
|
|
32
|
+
import Interpolator from "./src/Interpolator.js";
|
|
33
|
+
import ScreenEffects from "./src/ScreenEffects.js";
|
|
34
|
+
import SpriteBatch from "./src/SpriteBatch.js";
|
|
35
|
+
import ParticleEmitter from "./src/ParticleEmitter.js";
|
|
36
|
+
import CollisionLayers from "./src/CollisionLayers.js";
|
|
37
|
+
import TiledMap from "./src/importers/TiledMap.js";
|
|
38
|
+
import Aseprite from "./src/importers/Aseprite.js";
|
|
39
|
+
import RenderTarget from "./src/RenderTarget.js";
|
|
40
|
+
import RenderStats from "./src/managers/RenderStats.js";
|
|
41
|
+
import PostProcessor, { PostEffect } from "./src/PostProcessor.js";
|
|
42
|
+
import PostEffects, { BloomEffect } from "./src/PostEffects.js";
|
|
43
|
+
import Material from "./src/Material.js";
|
|
44
|
+
import UI from "./src/UI.js";
|
|
45
|
+
import InputManager from "./src/managers/InputManager.js";
|
|
15
46
|
import Particle from "./src/particlesystem/Particle.js";
|
|
16
47
|
import Particles from "./src/particlesystem/Particles.js";
|
|
17
48
|
import ParticleSettings from "./src/particlesystem/ParticleSettings.js";
|
|
@@ -19,6 +50,9 @@ import AudioManager from "./src/managers/AudioManager.js";
|
|
|
19
50
|
import CameraManager from "./src/managers/CameraManager.js";
|
|
20
51
|
import EventManager from "./src/managers/EventManager.js";
|
|
21
52
|
import SceneManager from "./src/managers/SceneManager.js";
|
|
53
|
+
import TextureManager from "./src/managers/TextureManager.js";
|
|
54
|
+
import AssetManager from "./src/managers/AssetManager.js";
|
|
55
|
+
import NetworkManager from "./src/managers/NetworkManager.js";
|
|
22
56
|
import DirectionalLight from "./src/lights/DirectionalLight.js";
|
|
23
57
|
import PointLight from "./src/lights/PointLight.js";
|
|
24
58
|
import BoxCollider from "./src/components/BoxCollider.js";
|
|
@@ -28,6 +62,7 @@ import CircleColliderDebug from "./src/components/CircleColliderDebug.js";
|
|
|
28
62
|
import Collider from "./src/components/Collider.js";
|
|
29
63
|
import GameObject from "./src/components/GameObject.js";
|
|
30
64
|
import RigidBody from "./src/components/RigidBody.js";
|
|
65
|
+
import Behaviour from "./src/components/Behaviour.js";
|
|
31
66
|
|
|
32
67
|
export {
|
|
33
68
|
Emerald,
|
|
@@ -45,9 +80,42 @@ export {
|
|
|
45
80
|
Triangle2D,
|
|
46
81
|
Circle2D,
|
|
47
82
|
Storage,
|
|
83
|
+
EmeraldDB,
|
|
48
84
|
Texture,
|
|
49
85
|
Time,
|
|
50
86
|
Transform,
|
|
87
|
+
MathUtils,
|
|
88
|
+
Pool,
|
|
89
|
+
Animator,
|
|
90
|
+
Tilemap,
|
|
91
|
+
CameraController,
|
|
92
|
+
Camera,
|
|
93
|
+
Easing,
|
|
94
|
+
Tween,
|
|
95
|
+
Timer,
|
|
96
|
+
StateMachine,
|
|
97
|
+
SpatialGrid,
|
|
98
|
+
TextureAtlas,
|
|
99
|
+
CanvasText,
|
|
100
|
+
DebugOverlay,
|
|
101
|
+
Serializer,
|
|
102
|
+
Coroutine,
|
|
103
|
+
Interpolator,
|
|
104
|
+
ScreenEffects,
|
|
105
|
+
SpriteBatch,
|
|
106
|
+
ParticleEmitter,
|
|
107
|
+
CollisionLayers,
|
|
108
|
+
TiledMap,
|
|
109
|
+
Aseprite,
|
|
110
|
+
RenderTarget,
|
|
111
|
+
RenderStats,
|
|
112
|
+
PostProcessor,
|
|
113
|
+
PostEffect,
|
|
114
|
+
PostEffects,
|
|
115
|
+
BloomEffect,
|
|
116
|
+
Material,
|
|
117
|
+
UI,
|
|
118
|
+
InputManager,
|
|
51
119
|
Particle,
|
|
52
120
|
Particles,
|
|
53
121
|
ParticleSettings,
|
|
@@ -55,6 +123,9 @@ export {
|
|
|
55
123
|
CameraManager,
|
|
56
124
|
EventManager,
|
|
57
125
|
SceneManager,
|
|
126
|
+
TextureManager,
|
|
127
|
+
AssetManager,
|
|
128
|
+
NetworkManager,
|
|
58
129
|
DirectionalLight,
|
|
59
130
|
PointLight,
|
|
60
131
|
BoxCollider,
|
|
@@ -64,4 +135,5 @@ export {
|
|
|
64
135
|
Collider,
|
|
65
136
|
GameObject,
|
|
66
137
|
RigidBody,
|
|
138
|
+
Behaviour,
|
|
67
139
|
};
|
package/package.json
CHANGED
|
@@ -1,62 +1,76 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
2
|
+
"name": "emeraldengine",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "2D graphics library for Web",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"module": "index.js",
|
|
8
|
+
"types": "dist/types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
12
|
+
"import": "./index.js",
|
|
13
|
+
"default": "./index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"index.js",
|
|
18
|
+
"src",
|
|
19
|
+
"dist/types"
|
|
20
|
+
],
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=12.0.0"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"2D",
|
|
27
|
+
"graphics",
|
|
28
|
+
"game",
|
|
29
|
+
"engine",
|
|
30
|
+
"webgl",
|
|
31
|
+
"webgl2",
|
|
32
|
+
"canvas",
|
|
33
|
+
"gamedev",
|
|
34
|
+
"rendering",
|
|
35
|
+
"sprite",
|
|
36
|
+
"particle-system",
|
|
37
|
+
"physics"
|
|
38
|
+
],
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"gl-matrix": "^3.4.3",
|
|
41
|
+
"planck": "^1.4.2"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"colyseus.js": "^0.16.16"
|
|
45
|
+
},
|
|
46
|
+
"peerDependenciesMeta": {
|
|
47
|
+
"colyseus.js": {
|
|
48
|
+
"optional": true
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"author": "vahan-gev",
|
|
52
|
+
"license": "MIT",
|
|
53
|
+
"homepage": "https://github.com/vahan-gev/emeraldengine#readme",
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "https://github.com/vahan-gev/emeraldengine/issues"
|
|
56
|
+
},
|
|
57
|
+
"repository": {
|
|
58
|
+
"type": "git",
|
|
59
|
+
"url": "git+https://github.com/vahan-gev/emeraldengine.git"
|
|
60
|
+
},
|
|
61
|
+
"scripts": {
|
|
62
|
+
"test": "node --test test/*.test.mjs",
|
|
63
|
+
"types": "tsc -p tsconfig.json",
|
|
64
|
+
"prepublishOnly": "npm run types && npm test",
|
|
65
|
+
"format": "prettier --write \"src/**/*.js\" \"test/**/*.mjs\" index.js",
|
|
66
|
+
"format:check": "prettier --check \"src/**/*.js\" index.js"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@colyseus/schema": "^3.0.76",
|
|
70
|
+
"colyseus": "^0.16.5",
|
|
71
|
+
"colyseus.js": "^0.16.22",
|
|
72
|
+
"prettier": "^3.3.0",
|
|
73
|
+
"typescript": "^5.9.3",
|
|
74
|
+
"vite": "^5.4.0"
|
|
75
|
+
}
|
|
62
76
|
}
|
package/src/Animator.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import Behaviour from "./components/Behaviour.js";
|
|
2
|
+
import Drawable from "./Drawable.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @class Animator
|
|
6
|
+
* @description A component that manages named animation clips for a Texture (or
|
|
7
|
+
* any Drawable) on the same GameObject. Register clips once, then switch between
|
|
8
|
+
* them by name — handy for character states like idle/run/jump.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const anim = new Animator();
|
|
12
|
+
* anim.addClip("idle", [0, 1, 2, 3], { speed: 150 });
|
|
13
|
+
* anim.addClip("jump", [8, 9], { speed: 100, loop: false });
|
|
14
|
+
* obj.addComponent(texture);
|
|
15
|
+
* obj.addComponent(anim);
|
|
16
|
+
* anim.play("idle");
|
|
17
|
+
*/
|
|
18
|
+
class Animator extends Behaviour {
|
|
19
|
+
constructor() {
|
|
20
|
+
super();
|
|
21
|
+
this.clips = new Map();
|
|
22
|
+
this.current = null;
|
|
23
|
+
this.drawable = null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @method addClip
|
|
28
|
+
* @description Registers a named clip.
|
|
29
|
+
* @param {string} name - The clip name
|
|
30
|
+
* @param {number[]} frames - Frame indices to play
|
|
31
|
+
* @param {Object} [options] - { speed = 100, loop = true }
|
|
32
|
+
* @returns {Animator} - this
|
|
33
|
+
*/
|
|
34
|
+
addClip(name, frames, options = {}) {
|
|
35
|
+
const { speed = 100, loop = true } = options;
|
|
36
|
+
this.clips.set(name, { frames, speed, loop });
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
start() {
|
|
41
|
+
this._resolveDrawable();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** @private */
|
|
45
|
+
_resolveDrawable() {
|
|
46
|
+
if (!this.drawable && this.gameObject && this.gameObject.getComponent) {
|
|
47
|
+
this.drawable = this.gameObject.getComponent(Drawable);
|
|
48
|
+
}
|
|
49
|
+
return this.drawable;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @method play
|
|
54
|
+
* @description Plays a registered clip. No-op if it's already current.
|
|
55
|
+
* @param {string} name - The clip name
|
|
56
|
+
* @returns {Animator} - this
|
|
57
|
+
*/
|
|
58
|
+
play(name) {
|
|
59
|
+
if (this.current === name) return this;
|
|
60
|
+
const clip = this.clips.get(name);
|
|
61
|
+
const drawable = this._resolveDrawable();
|
|
62
|
+
if (!clip || !drawable) return this;
|
|
63
|
+
|
|
64
|
+
this.current = name;
|
|
65
|
+
if (clip.loop) {
|
|
66
|
+
drawable.playAnimation(clip.frames, clip.speed);
|
|
67
|
+
} else {
|
|
68
|
+
drawable.playAnimationOnce(clip.frames, null, clip.speed, () => {
|
|
69
|
+
if (this.current === name) this.current = null;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @method stop
|
|
77
|
+
* @description Stops the current animation.
|
|
78
|
+
*/
|
|
79
|
+
stop() {
|
|
80
|
+
const drawable = this._resolveDrawable();
|
|
81
|
+
if (drawable) drawable.stopAnimation();
|
|
82
|
+
this.current = null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @method getCurrent
|
|
87
|
+
* @description Returns the name of the currently playing clip (or null).
|
|
88
|
+
* @returns {string|null}
|
|
89
|
+
*/
|
|
90
|
+
getCurrent() {
|
|
91
|
+
return this.current;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export default Animator;
|
package/src/BitmapText.js
CHANGED
|
@@ -35,7 +35,7 @@ class BitmapText {
|
|
|
35
35
|
color,
|
|
36
36
|
position,
|
|
37
37
|
rotation,
|
|
38
|
-
useLighting = false
|
|
38
|
+
useLighting = false
|
|
39
39
|
) {
|
|
40
40
|
this.text = text;
|
|
41
41
|
this.texturePath = texturePath;
|
|
@@ -61,7 +61,6 @@ class BitmapText {
|
|
|
61
61
|
for (let i = 0; i < letters.length; i++) {
|
|
62
62
|
this.letterDictionary[letters[i]] = i;
|
|
63
63
|
}
|
|
64
|
-
// Initialize the bitmap font texture
|
|
65
64
|
this.texture = new InstancedTexture(
|
|
66
65
|
this.texturePath,
|
|
67
66
|
text.length,
|
|
@@ -75,14 +74,14 @@ class BitmapText {
|
|
|
75
74
|
this.useLighting
|
|
76
75
|
);
|
|
77
76
|
|
|
78
|
-
// Apply the color to the texture if provided
|
|
79
77
|
if (this.color) {
|
|
80
78
|
this.texture.setColor(this.color);
|
|
81
79
|
}
|
|
82
80
|
|
|
83
|
-
// Apply the lighting setting to the texture
|
|
84
81
|
this.texture.setUseLighting(this.useLighting);
|
|
85
82
|
|
|
83
|
+
this.texture.setStatic(true);
|
|
84
|
+
|
|
86
85
|
this.gameObject.addComponent(this.texture);
|
|
87
86
|
for (let i = 0; i < text.length; i++) {
|
|
88
87
|
const letter = text[i];
|
|
@@ -163,7 +162,6 @@ class BitmapText {
|
|
|
163
162
|
* @param {Vector3} position - The position to set
|
|
164
163
|
*/
|
|
165
164
|
setPosition(position) {
|
|
166
|
-
// Vector3
|
|
167
165
|
this.position = position;
|
|
168
166
|
this.gameObject.transform.position = position;
|
|
169
167
|
|
|
@@ -184,6 +182,7 @@ class BitmapText {
|
|
|
184
182
|
instanceIndex++;
|
|
185
183
|
}
|
|
186
184
|
}
|
|
185
|
+
this.texture.markDirty();
|
|
187
186
|
}
|
|
188
187
|
|
|
189
188
|
/**
|
|
@@ -212,6 +211,7 @@ class BitmapText {
|
|
|
212
211
|
instanceIndex++;
|
|
213
212
|
}
|
|
214
213
|
}
|
|
214
|
+
this.texture.markDirty();
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
/**
|
|
@@ -239,6 +239,7 @@ class BitmapText {
|
|
|
239
239
|
instanceIndex++;
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
+
this.texture.markDirty();
|
|
242
243
|
}
|
|
243
244
|
}
|
|
244
245
|
|