emeraldengine 2.0.2 → 2.1.1
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/imports/Drawable.js +28 -24
- package/imports/InstancedTexture.js +24 -20
- package/package.json +2 -2
package/imports/Drawable.js
CHANGED
|
@@ -50,7 +50,7 @@ class Drawable {
|
|
|
50
50
|
this.texture = null;
|
|
51
51
|
this.useTexture = useTexture;
|
|
52
52
|
if (useTexture) {
|
|
53
|
-
this.initTexture().then(() => {});
|
|
53
|
+
this.initTexture().then(() => { });
|
|
54
54
|
}
|
|
55
55
|
this.frameWidth = frameWidth;
|
|
56
56
|
this.frameHeight = frameHeight;
|
|
@@ -73,7 +73,7 @@ class Drawable {
|
|
|
73
73
|
this.parentObject = null;
|
|
74
74
|
this.isActive = false;
|
|
75
75
|
this.isWireframe = false;
|
|
76
|
-
this.callbackFunction = () => {};
|
|
76
|
+
this.callbackFunction = () => { };
|
|
77
77
|
this.pixelart = pixelart;
|
|
78
78
|
this.useLighting = useLighting; // Default to true to maintain existing behavior
|
|
79
79
|
}
|
|
@@ -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
|
);
|
|
@@ -447,25 +451,25 @@ class Drawable {
|
|
|
447
451
|
// If mirrored change texLeft and texRight in places
|
|
448
452
|
const texCoords = this.mirrored
|
|
449
453
|
? new Float32Array([
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
454
|
+
texRight,
|
|
455
|
+
texBottom,
|
|
456
|
+
texLeft,
|
|
457
|
+
texBottom,
|
|
458
|
+
texRight,
|
|
459
|
+
texTop,
|
|
460
|
+
texLeft,
|
|
461
|
+
texTop,
|
|
462
|
+
])
|
|
459
463
|
: new Float32Array([
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
464
|
+
texLeft,
|
|
465
|
+
texBottom,
|
|
466
|
+
texRight,
|
|
467
|
+
texBottom,
|
|
468
|
+
texLeft,
|
|
469
|
+
texTop,
|
|
470
|
+
texRight,
|
|
471
|
+
texTop,
|
|
472
|
+
]);
|
|
469
473
|
// Update texture coordinate buffer
|
|
470
474
|
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.texCoordBuffer);
|
|
471
475
|
this.gl.bufferData(this.gl.ARRAY_BUFFER, texCoords, this.gl.STATIC_DRAW);
|
|
@@ -493,9 +497,9 @@ class Drawable {
|
|
|
493
497
|
vertexCount = this.vertices.length / 2;
|
|
494
498
|
}
|
|
495
499
|
|
|
496
|
-
if(this.isWireframe) {
|
|
500
|
+
if (this.isWireframe) {
|
|
497
501
|
// Fix the wireframe for square
|
|
498
|
-
if(this.vertices.length === 8) {
|
|
502
|
+
if (this.vertices.length === 8) {
|
|
499
503
|
let tempBuffer = this.gl.createBuffer();
|
|
500
504
|
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, tempBuffer);
|
|
501
505
|
|
|
@@ -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 = [
|
|
@@ -424,25 +428,25 @@ class InstancedTexture extends Drawable {
|
|
|
424
428
|
// Return texture coordinates (considering mirroring)
|
|
425
429
|
return this.mirrored
|
|
426
430
|
? [
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
431
|
+
texRight,
|
|
432
|
+
texBottom,
|
|
433
|
+
texLeft,
|
|
434
|
+
texBottom,
|
|
435
|
+
texRight,
|
|
436
|
+
texTop,
|
|
437
|
+
texLeft,
|
|
438
|
+
texTop,
|
|
439
|
+
]
|
|
436
440
|
: [
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
441
|
+
texLeft,
|
|
442
|
+
texBottom,
|
|
443
|
+
texRight,
|
|
444
|
+
texBottom,
|
|
445
|
+
texLeft,
|
|
446
|
+
texTop,
|
|
447
|
+
texRight,
|
|
448
|
+
texTop,
|
|
449
|
+
];
|
|
446
450
|
}
|
|
447
451
|
|
|
448
452
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "emeraldengine",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "2D graphics library for Web",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -39,4 +39,4 @@
|
|
|
39
39
|
"url": "git+https://github.com/vahan-gev/emeraldengine.git"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {}
|
|
42
|
-
}
|
|
42
|
+
}
|