emeraldengine 2.1.0 → 2.2.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/dist/types/index.d.ts +30 -30
- package/index.js +30 -30
- package/package.json +60 -40
- package/{imports → src}/Drawable.js +16 -16
- package/{imports → src}/InstancedTexture.js +28 -29
- package/{imports → src}/Scene.js +5 -1
- package/{imports → src}/Time.js +4 -4
- package/{imports → src}/components/BoxCollider.js +4 -1
- package/{imports → src}/components/CircleCollider.js +8 -2
- package/{imports → src}/components/GameObject.js +2 -2
- package/{imports → src}/managers/CameraManager.js +9 -9
- package/{imports → src}/managers/GLManager.js +10 -10
- package/{imports → src}/managers/IDManager.js +6 -6
- package/{imports → src}/managers/SceneManager.js +4 -4
- /package/dist/types/{imports/BitmapText.d.ts → BitmapText.d.ts} +0 -0
- /package/dist/types/{imports/Color.d.ts → Color.d.ts} +0 -0
- /package/dist/types/{imports/Drawable.d.ts → Drawable.d.ts} +0 -0
- /package/dist/types/{imports/Emerald.d.ts → Emerald.d.ts} +0 -0
- /package/dist/types/{imports/FPSCounter.d.ts → FPSCounter.d.ts} +0 -0
- /package/dist/types/{imports/GLUtils.d.ts → GLUtils.d.ts} +0 -0
- /package/dist/types/{imports/Instance.d.ts → Instance.d.ts} +0 -0
- /package/dist/types/{imports/InstancedTexture.d.ts → InstancedTexture.d.ts} +0 -0
- /package/dist/types/{imports/Physics.d.ts → Physics.d.ts} +0 -0
- /package/dist/types/{imports/Scene.d.ts → Scene.d.ts} +0 -0
- /package/dist/types/{imports/Shaders.d.ts → Shaders.d.ts} +0 -0
- /package/dist/types/{imports/Shapes.d.ts → Shapes.d.ts} +0 -0
- /package/dist/types/{imports/Storage.d.ts → Storage.d.ts} +0 -0
- /package/dist/types/{imports/Texture.d.ts → Texture.d.ts} +0 -0
- /package/dist/types/{imports/Time.d.ts → Time.d.ts} +0 -0
- /package/dist/types/{imports/Transform.d.ts → Transform.d.ts} +0 -0
- /package/dist/types/{imports/components → components}/BoxCollider.d.ts +0 -0
- /package/dist/types/{imports/components → components}/BoxColliderDebug.d.ts +0 -0
- /package/dist/types/{imports/components → components}/CircleCollider.d.ts +0 -0
- /package/dist/types/{imports/components → components}/CircleColliderDebug.d.ts +0 -0
- /package/dist/types/{imports/components → components}/Collider.d.ts +0 -0
- /package/dist/types/{imports/components → components}/GameObject.d.ts +0 -0
- /package/dist/types/{imports/components → components}/RigidBody.d.ts +0 -0
- /package/dist/types/{imports/lights → lights}/DirectionalLight.d.ts +0 -0
- /package/dist/types/{imports/lights → lights}/PointLight.d.ts +0 -0
- /package/dist/types/{imports/managers → managers}/AudioManager.d.ts +0 -0
- /package/dist/types/{imports/managers → managers}/CameraManager.d.ts +0 -0
- /package/dist/types/{imports/managers → managers}/EventManager.d.ts +0 -0
- /package/dist/types/{imports/managers → managers}/GLManager.d.ts +0 -0
- /package/dist/types/{imports/managers → managers}/IDManager.d.ts +0 -0
- /package/dist/types/{imports/managers → managers}/SceneManager.d.ts +0 -0
- /package/dist/types/{imports/particlesystem → particlesystem}/Particle.d.ts +0 -0
- /package/dist/types/{imports/particlesystem → particlesystem}/ParticleSettings.d.ts +0 -0
- /package/dist/types/{imports/particlesystem → particlesystem}/Particles.d.ts +0 -0
- /package/{imports → src}/BitmapText.js +0 -0
- /package/{imports → src}/Color.js +0 -0
- /package/{imports → src}/Emerald.js +0 -0
- /package/{imports → src}/FPSCounter.js +0 -0
- /package/{imports → src}/GLUtils.js +0 -0
- /package/{imports → src}/Instance.js +0 -0
- /package/{imports → src}/Physics.js +0 -0
- /package/{imports → src}/Shaders.js +0 -0
- /package/{imports → src}/Shapes.js +0 -0
- /package/{imports → src}/Storage.js +0 -0
- /package/{imports → src}/Texture.js +0 -0
- /package/{imports → src}/Transform.js +0 -0
- /package/{imports → src}/components/BoxColliderDebug.js +0 -0
- /package/{imports → src}/components/CircleColliderDebug.js +0 -0
- /package/{imports → src}/components/Collider.js +0 -0
- /package/{imports → src}/components/RigidBody.js +0 -0
- /package/{imports → src}/lights/DirectionalLight.js +0 -0
- /package/{imports → src}/lights/PointLight.js +0 -0
- /package/{imports → src}/managers/AudioManager.js +0 -0
- /package/{imports → src}/managers/EventManager.js +0 -0
- /package/{imports → src}/managers/ShaderManager.js +0 -0
- /package/{imports → src}/particlesystem/Particle.js +0 -0
- /package/{imports → src}/particlesystem/ParticleSettings.js +0 -0
- /package/{imports → src}/particlesystem/Particles.js +0 -0
package/dist/types/index.d.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import Emerald from "./
|
|
2
|
-
import BitmapText from "./
|
|
3
|
-
import Color from "./
|
|
4
|
-
import Drawable from "./
|
|
5
|
-
import FPSCounter from "./
|
|
6
|
-
import Instance from "./
|
|
7
|
-
import InstancedTexture from "./
|
|
8
|
-
import { Physics, Vector2, Vector3 } from "./
|
|
9
|
-
import Scene from "./
|
|
10
|
-
import { Square2D, Triangle2D, Circle2D } from "./
|
|
11
|
-
import Storage from "./
|
|
12
|
-
import Texture from "./
|
|
13
|
-
import Time from "./
|
|
14
|
-
import Transform from "./
|
|
15
|
-
import Particle from "./
|
|
16
|
-
import Particles from "./
|
|
17
|
-
import ParticleSettings from "./
|
|
18
|
-
import AudioManager from "./
|
|
19
|
-
import CameraManager from "./
|
|
20
|
-
import EventManager from "./
|
|
21
|
-
import SceneManager from "./
|
|
22
|
-
import DirectionalLight from "./
|
|
23
|
-
import PointLight from "./
|
|
24
|
-
import BoxCollider from "./
|
|
25
|
-
import BoxColliderDebug from "./
|
|
26
|
-
import CircleCollider from "./
|
|
27
|
-
import CircleColliderDebug from "./
|
|
28
|
-
import Collider from "./
|
|
29
|
-
import GameObject from "./
|
|
30
|
-
import RigidBody from "./
|
|
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
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
32
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import Emerald from "./
|
|
2
|
-
import BitmapText from "./
|
|
3
|
-
import Color from "./
|
|
4
|
-
import Drawable from "./
|
|
5
|
-
import FPSCounter from "./
|
|
6
|
-
import Instance from "./
|
|
7
|
-
import InstancedTexture from "./
|
|
8
|
-
import { Physics, Vector2, Vector3 } from "./
|
|
9
|
-
import Scene from "./
|
|
10
|
-
import { Square2D, Triangle2D, Circle2D } from "./
|
|
11
|
-
import Storage from "./
|
|
12
|
-
import Texture from "./
|
|
13
|
-
import Time from "./
|
|
14
|
-
import Transform from "./
|
|
15
|
-
import Particle from "./
|
|
16
|
-
import Particles from "./
|
|
17
|
-
import ParticleSettings from "./
|
|
18
|
-
import AudioManager from "./
|
|
19
|
-
import CameraManager from "./
|
|
20
|
-
import EventManager from "./
|
|
21
|
-
import SceneManager from "./
|
|
22
|
-
import DirectionalLight from "./
|
|
23
|
-
import PointLight from "./
|
|
24
|
-
import BoxCollider from "./
|
|
25
|
-
import BoxColliderDebug from "./
|
|
26
|
-
import CircleCollider from "./
|
|
27
|
-
import CircleColliderDebug from "./
|
|
28
|
-
import Collider from "./
|
|
29
|
-
import GameObject from "./
|
|
30
|
-
import RigidBody from "./
|
|
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, Vector2, Vector3 } from "./src/Physics.js";
|
|
9
|
+
import Scene from "./src/Scene.js";
|
|
10
|
+
import { Square2D, Triangle2D, Circle2D } from "./src/Shapes.js";
|
|
11
|
+
import Storage from "./src/Storage.js";
|
|
12
|
+
import Texture from "./src/Texture.js";
|
|
13
|
+
import Time from "./src/Time.js";
|
|
14
|
+
import Transform from "./src/Transform.js";
|
|
15
|
+
import Particle from "./src/particlesystem/Particle.js";
|
|
16
|
+
import Particles from "./src/particlesystem/Particles.js";
|
|
17
|
+
import ParticleSettings from "./src/particlesystem/ParticleSettings.js";
|
|
18
|
+
import AudioManager from "./src/managers/AudioManager.js";
|
|
19
|
+
import CameraManager from "./src/managers/CameraManager.js";
|
|
20
|
+
import EventManager from "./src/managers/EventManager.js";
|
|
21
|
+
import SceneManager from "./src/managers/SceneManager.js";
|
|
22
|
+
import DirectionalLight from "./src/lights/DirectionalLight.js";
|
|
23
|
+
import PointLight from "./src/lights/PointLight.js";
|
|
24
|
+
import BoxCollider from "./src/components/BoxCollider.js";
|
|
25
|
+
import BoxColliderDebug from "./src/components/BoxColliderDebug.js";
|
|
26
|
+
import CircleCollider from "./src/components/CircleCollider.js";
|
|
27
|
+
import CircleColliderDebug from "./src/components/CircleColliderDebug.js";
|
|
28
|
+
import Collider from "./src/components/Collider.js";
|
|
29
|
+
import GameObject from "./src/components/GameObject.js";
|
|
30
|
+
import RigidBody from "./src/components/RigidBody.js";
|
|
31
31
|
|
|
32
32
|
export {
|
|
33
33
|
Emerald,
|
package/package.json
CHANGED
|
@@ -1,42 +1,62 @@
|
|
|
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
|
-
|
|
2
|
+
"name": "emeraldengine",
|
|
3
|
+
"version": "2.2.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
|
+
"devDependencies": {}
|
|
42
62
|
}
|
|
@@ -336,8 +336,12 @@ class Drawable {
|
|
|
336
336
|
objectTransformMatrix,
|
|
337
337
|
objectTransformMatrix,
|
|
338
338
|
vec3.fromValues(
|
|
339
|
-
|
|
340
|
-
|
|
339
|
+
this.pixelart
|
|
340
|
+
? Math.round(objectTransform.position.x)
|
|
341
|
+
: objectTransform.position.x,
|
|
342
|
+
this.pixelart
|
|
343
|
+
? Math.round(objectTransform.position.y)
|
|
344
|
+
: objectTransform.position.y,
|
|
341
345
|
objectTransform.position.z
|
|
342
346
|
)
|
|
343
347
|
);
|
|
@@ -430,18 +434,13 @@ class Drawable {
|
|
|
430
434
|
const col = this.currentFrame % this.framesPerRow;
|
|
431
435
|
const row = Math.floor(this.currentFrame / this.framesPerRow);
|
|
432
436
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
texLeft = ((col + 1) * this.frameWidth) / this.textureWidth - halfTexelWidth;
|
|
437
|
-
texRight = (col * this.frameWidth) / this.textureWidth + halfTexelWidth;
|
|
437
|
+
texLeft = ((col + 1) * this.frameWidth) / this.textureWidth;
|
|
438
|
+
texRight = (col * this.frameWidth) / this.textureWidth;
|
|
438
439
|
texTop =
|
|
439
440
|
(this.textureHeight - row * this.frameHeight - this.frameHeight) /
|
|
440
|
-
this.textureHeight
|
|
441
|
-
halfTexelHeight;
|
|
441
|
+
this.textureHeight;
|
|
442
442
|
texBottom =
|
|
443
|
-
(this.textureHeight - row * this.frameHeight) / this.textureHeight
|
|
444
|
-
halfTexelHeight;
|
|
443
|
+
(this.textureHeight - row * this.frameHeight) / this.textureHeight;
|
|
445
444
|
} else {
|
|
446
445
|
// Static image
|
|
447
446
|
texLeft = 1.0;
|
|
@@ -543,13 +542,14 @@ class Drawable {
|
|
|
543
542
|
* @param {string} path - The path to the image
|
|
544
543
|
* @returns {Promise} - The promise
|
|
545
544
|
*/
|
|
546
|
-
loadImage
|
|
547
|
-
new Promise((resolve, reject)
|
|
548
|
-
|
|
549
|
-
image.addEventListener("load", ()
|
|
550
|
-
image.addEventListener("error", (err)
|
|
545
|
+
loadImage(path) {
|
|
546
|
+
return new Promise(function (resolve, reject) {
|
|
547
|
+
var image = new Image();
|
|
548
|
+
image.addEventListener("load", function () { resolve(image); });
|
|
549
|
+
image.addEventListener("error", function (err) { reject(err); });
|
|
551
550
|
image.src = path;
|
|
552
551
|
});
|
|
552
|
+
}
|
|
553
553
|
}
|
|
554
554
|
|
|
555
555
|
export default Drawable;
|
|
@@ -198,8 +198,12 @@ class InstancedTexture extends Drawable {
|
|
|
198
198
|
if (index >= 0 && index < this.instanceCount) {
|
|
199
199
|
const matrix = mat4.create();
|
|
200
200
|
const position = [
|
|
201
|
-
this.
|
|
202
|
-
|
|
201
|
+
this.pixelart
|
|
202
|
+
? Math.round(this.instances[index].transform.position.x)
|
|
203
|
+
: this.instances[index].transform.position.x,
|
|
204
|
+
this.pixelart
|
|
205
|
+
? Math.round(this.instances[index].transform.position.y)
|
|
206
|
+
: this.instances[index].transform.position.y,
|
|
203
207
|
this.instances[index].transform.position.z,
|
|
204
208
|
];
|
|
205
209
|
const scale = [
|
|
@@ -406,18 +410,13 @@ class InstancedTexture extends Drawable {
|
|
|
406
410
|
const col = frame % this.framesPerRow;
|
|
407
411
|
const row = Math.floor(frame / this.framesPerRow);
|
|
408
412
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
texLeft = ((col + 1) * this.frameWidth) / this.textureWidth - halfTexelWidth;
|
|
413
|
-
texRight = (col * this.frameWidth) / this.textureWidth + halfTexelWidth;
|
|
413
|
+
texLeft = ((col + 1) * this.frameWidth) / this.textureWidth;
|
|
414
|
+
texRight = (col * this.frameWidth) / this.textureWidth;
|
|
414
415
|
texTop =
|
|
415
416
|
(this.textureHeight - row * this.frameHeight - this.frameHeight) /
|
|
416
|
-
|
|
417
|
-
halfTexelHeight;
|
|
417
|
+
this.textureHeight;
|
|
418
418
|
texBottom =
|
|
419
|
-
(this.textureHeight - row * this.frameHeight) / this.textureHeight
|
|
420
|
-
halfTexelHeight;
|
|
419
|
+
(this.textureHeight - row * this.frameHeight) / this.textureHeight;
|
|
421
420
|
} else {
|
|
422
421
|
// Static image
|
|
423
422
|
texLeft = 1.0;
|
|
@@ -429,25 +428,25 @@ class InstancedTexture extends Drawable {
|
|
|
429
428
|
// Return texture coordinates (considering mirroring)
|
|
430
429
|
return this.mirrored
|
|
431
430
|
? [
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
431
|
+
texRight,
|
|
432
|
+
texBottom,
|
|
433
|
+
texLeft,
|
|
434
|
+
texBottom,
|
|
435
|
+
texRight,
|
|
436
|
+
texTop,
|
|
437
|
+
texLeft,
|
|
438
|
+
texTop,
|
|
439
|
+
]
|
|
441
440
|
: [
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
441
|
+
texLeft,
|
|
442
|
+
texBottom,
|
|
443
|
+
texRight,
|
|
444
|
+
texBottom,
|
|
445
|
+
texLeft,
|
|
446
|
+
texTop,
|
|
447
|
+
texRight,
|
|
448
|
+
texTop,
|
|
449
|
+
];
|
|
451
450
|
}
|
|
452
451
|
|
|
453
452
|
/**
|
package/{imports → src}/Scene.js
RENAMED
|
@@ -35,7 +35,11 @@ class Scene {
|
|
|
35
35
|
throw new Error("Object is not a GameObject");
|
|
36
36
|
}
|
|
37
37
|
object.setIsActive(false);
|
|
38
|
-
this.objects = this.objects.filter((obj)
|
|
38
|
+
this.objects = this.objects.filter(function (obj) {
|
|
39
|
+
var objId = obj ? obj.id : undefined;
|
|
40
|
+
var targetId = object ? object.id : undefined;
|
|
41
|
+
return objId !== targetId;
|
|
42
|
+
});
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
/**
|
package/{imports → src}/Time.js
RENAMED
|
@@ -4,15 +4,13 @@
|
|
|
4
4
|
* @param {number} deltaTime - The delta time
|
|
5
5
|
*/
|
|
6
6
|
class Time {
|
|
7
|
-
static deltaTime = 0;
|
|
8
|
-
|
|
9
7
|
/**
|
|
10
8
|
* @method getDeltaTime
|
|
11
9
|
* @description Returns the delta time
|
|
12
10
|
* @returns {number} - The delta time
|
|
13
11
|
*/
|
|
14
12
|
static getDeltaTime() {
|
|
15
|
-
return
|
|
13
|
+
return Time.deltaTime;
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
/**
|
|
@@ -21,8 +19,10 @@ class Time {
|
|
|
21
19
|
* @param {number} deltaTime - The delta time
|
|
22
20
|
*/
|
|
23
21
|
static setDeltaTime(deltaTime) {
|
|
24
|
-
|
|
22
|
+
Time.deltaTime = deltaTime;
|
|
25
23
|
}
|
|
26
24
|
}
|
|
27
25
|
|
|
26
|
+
Time.deltaTime = 0;
|
|
27
|
+
|
|
28
28
|
export default Time;
|
|
@@ -44,7 +44,10 @@ class BoxCollider extends Collider {
|
|
|
44
44
|
* @description Shows the debug shape of the collider
|
|
45
45
|
*/
|
|
46
46
|
showDebugShape() {
|
|
47
|
-
SceneManager.getScene()
|
|
47
|
+
var scene = SceneManager.getScene();
|
|
48
|
+
if (scene) {
|
|
49
|
+
scene.add(this.debugShape.gameObject);
|
|
50
|
+
}
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
/**
|
|
@@ -44,7 +44,10 @@ class CircleCollider extends Collider {
|
|
|
44
44
|
* @description Shows the debug shape of the collider
|
|
45
45
|
*/
|
|
46
46
|
showDebugShape() {
|
|
47
|
-
SceneManager.getScene()
|
|
47
|
+
var scene = SceneManager.getScene();
|
|
48
|
+
if (scene) {
|
|
49
|
+
scene.add(this.debugShape.gameObject);
|
|
50
|
+
}
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
/**
|
|
@@ -52,7 +55,10 @@ class CircleCollider extends Collider {
|
|
|
52
55
|
* @description Hides the debug shape of the collider
|
|
53
56
|
*/
|
|
54
57
|
hideDebugShape() {
|
|
55
|
-
SceneManager.getScene()
|
|
58
|
+
var scene = SceneManager.getScene();
|
|
59
|
+
if (scene) {
|
|
60
|
+
scene.remove(this.debugShape.gameObject);
|
|
61
|
+
}
|
|
56
62
|
}
|
|
57
63
|
|
|
58
64
|
/**
|
|
@@ -49,7 +49,7 @@ class GameObject {
|
|
|
49
49
|
* @param {Component} component - The component to remove
|
|
50
50
|
*/
|
|
51
51
|
removeComponent(component) {
|
|
52
|
-
if(!component || !this.components.includes(component)) {
|
|
52
|
+
if (!component || !this.components.includes(component)) {
|
|
53
53
|
throw new Error(`Component ${component.name} not found in ${this.name}`);
|
|
54
54
|
}
|
|
55
55
|
if (component instanceof RigidBody) {
|
|
@@ -129,7 +129,7 @@ class GameObject {
|
|
|
129
129
|
const drawable = this.getComponent(Drawable);
|
|
130
130
|
const rigidBody = this.getComponent(RigidBody);
|
|
131
131
|
const collider = this.getComponent(Collider);
|
|
132
|
-
if (rigidBody && rigidBody
|
|
132
|
+
if (rigidBody && rigidBody.getType() === "dynamic") {
|
|
133
133
|
const updatedPos = rigidBody.getBody().getPosition();
|
|
134
134
|
const rigidBodyOffset = rigidBody.getOffset();
|
|
135
135
|
const physicsScale = rigidBody.getPhysics().getScale();
|
|
@@ -3,16 +3,13 @@
|
|
|
3
3
|
* @description Manages the camera for the game
|
|
4
4
|
*/
|
|
5
5
|
class CameraManager {
|
|
6
|
-
static camera = null;
|
|
7
|
-
static lastPosition = null;
|
|
8
|
-
|
|
9
6
|
/**
|
|
10
7
|
* @method setLastPosition
|
|
11
8
|
* @description Sets the last position of the camera
|
|
12
9
|
* @param {Vector2} position - The position to set
|
|
13
10
|
*/
|
|
14
11
|
static setLastPosition(position) {
|
|
15
|
-
|
|
12
|
+
CameraManager.lastPosition = position;
|
|
16
13
|
}
|
|
17
14
|
|
|
18
15
|
/**
|
|
@@ -21,8 +18,8 @@ class CameraManager {
|
|
|
21
18
|
* @returns {Vector2} - The last position of the camera
|
|
22
19
|
*/
|
|
23
20
|
static getLastPosition() {
|
|
24
|
-
if (
|
|
25
|
-
return
|
|
21
|
+
if (CameraManager.lastPosition) {
|
|
22
|
+
return CameraManager.lastPosition;
|
|
26
23
|
} else {
|
|
27
24
|
console.warn("Last position is not set.");
|
|
28
25
|
return null;
|
|
@@ -36,7 +33,7 @@ class CameraManager {
|
|
|
36
33
|
*/
|
|
37
34
|
static setCamera(camera) {
|
|
38
35
|
if (camera) {
|
|
39
|
-
|
|
36
|
+
CameraManager.camera = camera;
|
|
40
37
|
} else {
|
|
41
38
|
console.warn("Attempted to set camera to null or undefined.");
|
|
42
39
|
}
|
|
@@ -48,8 +45,8 @@ class CameraManager {
|
|
|
48
45
|
* @returns {Camera} - The camera for the game
|
|
49
46
|
*/
|
|
50
47
|
static getCamera() {
|
|
51
|
-
if (
|
|
52
|
-
return
|
|
48
|
+
if (CameraManager.camera) {
|
|
49
|
+
return CameraManager.camera;
|
|
53
50
|
} else {
|
|
54
51
|
console.warn("Camera is not set.");
|
|
55
52
|
return null;
|
|
@@ -57,4 +54,7 @@ class CameraManager {
|
|
|
57
54
|
}
|
|
58
55
|
}
|
|
59
56
|
|
|
57
|
+
CameraManager.camera = null;
|
|
58
|
+
CameraManager.lastPosition = null;
|
|
59
|
+
|
|
60
60
|
export default CameraManager;
|
|
@@ -3,17 +3,13 @@
|
|
|
3
3
|
* @description Manages the WebGL context for the game
|
|
4
4
|
*/
|
|
5
5
|
class GLManager {
|
|
6
|
-
static gl = null;
|
|
7
|
-
static programInfo = null;
|
|
8
|
-
static canvas = null;
|
|
9
|
-
|
|
10
6
|
/**
|
|
11
7
|
* @method setGL
|
|
12
8
|
* @description Sets the WebGL context
|
|
13
9
|
* @param {WebGLRenderingContext} gl - The WebGL context
|
|
14
10
|
*/
|
|
15
11
|
static setGL(gl) {
|
|
16
|
-
|
|
12
|
+
GLManager.gl = gl;
|
|
17
13
|
}
|
|
18
14
|
|
|
19
15
|
/**
|
|
@@ -22,7 +18,7 @@ class GLManager {
|
|
|
22
18
|
* @param {Object} programInfo - The program info
|
|
23
19
|
*/
|
|
24
20
|
static setProgramInfo(programInfo) {
|
|
25
|
-
|
|
21
|
+
GLManager.programInfo = programInfo;
|
|
26
22
|
}
|
|
27
23
|
|
|
28
24
|
/**
|
|
@@ -31,7 +27,7 @@ class GLManager {
|
|
|
31
27
|
* @param {HTMLCanvasElement} canvas - The canvas
|
|
32
28
|
*/
|
|
33
29
|
static setCanvas(canvas) {
|
|
34
|
-
|
|
30
|
+
GLManager.canvas = canvas;
|
|
35
31
|
}
|
|
36
32
|
|
|
37
33
|
/**
|
|
@@ -40,7 +36,7 @@ class GLManager {
|
|
|
40
36
|
* @returns {WebGLRenderingContext} - The WebGL context
|
|
41
37
|
*/
|
|
42
38
|
static getGL() {
|
|
43
|
-
return
|
|
39
|
+
return GLManager.gl;
|
|
44
40
|
}
|
|
45
41
|
|
|
46
42
|
/**
|
|
@@ -49,7 +45,7 @@ class GLManager {
|
|
|
49
45
|
* @returns {Object} - The program info
|
|
50
46
|
*/
|
|
51
47
|
static getProgramInfo() {
|
|
52
|
-
return
|
|
48
|
+
return GLManager.programInfo;
|
|
53
49
|
}
|
|
54
50
|
|
|
55
51
|
/**
|
|
@@ -58,8 +54,12 @@ class GLManager {
|
|
|
58
54
|
* @returns {HTMLCanvasElement} - The canvas
|
|
59
55
|
*/
|
|
60
56
|
static getCanvas() {
|
|
61
|
-
return
|
|
57
|
+
return GLManager.canvas;
|
|
62
58
|
}
|
|
63
59
|
}
|
|
64
60
|
|
|
61
|
+
GLManager.gl = null;
|
|
62
|
+
GLManager.programInfo = null;
|
|
63
|
+
GLManager.canvas = null;
|
|
64
|
+
|
|
65
65
|
export default GLManager;
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
* @description Manages the IDs for the game
|
|
4
4
|
*/
|
|
5
5
|
class IDManager {
|
|
6
|
-
static existingIDs = new Set();
|
|
7
|
-
|
|
8
6
|
/**
|
|
9
7
|
* @method generateID
|
|
10
8
|
* @description Generates a random ID
|
|
@@ -20,13 +18,15 @@ class IDManager {
|
|
|
20
18
|
* @returns {string} - The unique ID
|
|
21
19
|
*/
|
|
22
20
|
static generateUniqueID() {
|
|
23
|
-
|
|
21
|
+
var id;
|
|
24
22
|
do {
|
|
25
|
-
id =
|
|
26
|
-
} while (
|
|
27
|
-
|
|
23
|
+
id = IDManager.generateID();
|
|
24
|
+
} while (IDManager.existingIDs.has(id));
|
|
25
|
+
IDManager.existingIDs.add(id);
|
|
28
26
|
return id;
|
|
29
27
|
}
|
|
30
28
|
}
|
|
31
29
|
|
|
30
|
+
IDManager.existingIDs = new Set();
|
|
31
|
+
|
|
32
32
|
export default IDManager;
|
|
@@ -3,15 +3,13 @@
|
|
|
3
3
|
* @description Manages the scene for the game
|
|
4
4
|
*/
|
|
5
5
|
class SceneManager {
|
|
6
|
-
static scene = null;
|
|
7
|
-
|
|
8
6
|
/**
|
|
9
7
|
* @method setScene
|
|
10
8
|
* @description Sets the scene
|
|
11
9
|
* @param {Scene} scene - The scene to set
|
|
12
10
|
*/
|
|
13
11
|
static setScene(scene) {
|
|
14
|
-
|
|
12
|
+
SceneManager.scene = scene;
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
/**
|
|
@@ -20,8 +18,10 @@ class SceneManager {
|
|
|
20
18
|
* @returns {Scene} - The scene
|
|
21
19
|
*/
|
|
22
20
|
static getScene() {
|
|
23
|
-
return
|
|
21
|
+
return SceneManager.scene;
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
|
|
25
|
+
SceneManager.scene = null;
|
|
26
|
+
|
|
27
27
|
export default SceneManager;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|