emeraldengine 2.1.1 → 2.2.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.
Files changed (73) hide show
  1. package/dist/types/index.d.ts +30 -30
  2. package/index.js +30 -30
  3. package/package.json +61 -41
  4. package/src/Drawable.js +582 -0
  5. package/{imports → src}/Scene.js +5 -1
  6. package/{imports → src}/Time.js +4 -4
  7. package/{imports → src}/components/BoxCollider.js +4 -1
  8. package/{imports → src}/components/CircleCollider.js +8 -2
  9. package/{imports → src}/components/GameObject.js +2 -2
  10. package/{imports → src}/managers/CameraManager.js +9 -9
  11. package/{imports → src}/managers/GLManager.js +10 -10
  12. package/{imports → src}/managers/IDManager.js +6 -6
  13. package/{imports → src}/managers/SceneManager.js +4 -4
  14. package/imports/Drawable.js +0 -554
  15. /package/dist/types/{imports/BitmapText.d.ts → BitmapText.d.ts} +0 -0
  16. /package/dist/types/{imports/Color.d.ts → Color.d.ts} +0 -0
  17. /package/dist/types/{imports/Drawable.d.ts → Drawable.d.ts} +0 -0
  18. /package/dist/types/{imports/Emerald.d.ts → Emerald.d.ts} +0 -0
  19. /package/dist/types/{imports/FPSCounter.d.ts → FPSCounter.d.ts} +0 -0
  20. /package/dist/types/{imports/GLUtils.d.ts → GLUtils.d.ts} +0 -0
  21. /package/dist/types/{imports/Instance.d.ts → Instance.d.ts} +0 -0
  22. /package/dist/types/{imports/InstancedTexture.d.ts → InstancedTexture.d.ts} +0 -0
  23. /package/dist/types/{imports/Physics.d.ts → Physics.d.ts} +0 -0
  24. /package/dist/types/{imports/Scene.d.ts → Scene.d.ts} +0 -0
  25. /package/dist/types/{imports/Shaders.d.ts → Shaders.d.ts} +0 -0
  26. /package/dist/types/{imports/Shapes.d.ts → Shapes.d.ts} +0 -0
  27. /package/dist/types/{imports/Storage.d.ts → Storage.d.ts} +0 -0
  28. /package/dist/types/{imports/Texture.d.ts → Texture.d.ts} +0 -0
  29. /package/dist/types/{imports/Time.d.ts → Time.d.ts} +0 -0
  30. /package/dist/types/{imports/Transform.d.ts → Transform.d.ts} +0 -0
  31. /package/dist/types/{imports/components → components}/BoxCollider.d.ts +0 -0
  32. /package/dist/types/{imports/components → components}/BoxColliderDebug.d.ts +0 -0
  33. /package/dist/types/{imports/components → components}/CircleCollider.d.ts +0 -0
  34. /package/dist/types/{imports/components → components}/CircleColliderDebug.d.ts +0 -0
  35. /package/dist/types/{imports/components → components}/Collider.d.ts +0 -0
  36. /package/dist/types/{imports/components → components}/GameObject.d.ts +0 -0
  37. /package/dist/types/{imports/components → components}/RigidBody.d.ts +0 -0
  38. /package/dist/types/{imports/lights → lights}/DirectionalLight.d.ts +0 -0
  39. /package/dist/types/{imports/lights → lights}/PointLight.d.ts +0 -0
  40. /package/dist/types/{imports/managers → managers}/AudioManager.d.ts +0 -0
  41. /package/dist/types/{imports/managers → managers}/CameraManager.d.ts +0 -0
  42. /package/dist/types/{imports/managers → managers}/EventManager.d.ts +0 -0
  43. /package/dist/types/{imports/managers → managers}/GLManager.d.ts +0 -0
  44. /package/dist/types/{imports/managers → managers}/IDManager.d.ts +0 -0
  45. /package/dist/types/{imports/managers → managers}/SceneManager.d.ts +0 -0
  46. /package/dist/types/{imports/particlesystem → particlesystem}/Particle.d.ts +0 -0
  47. /package/dist/types/{imports/particlesystem → particlesystem}/ParticleSettings.d.ts +0 -0
  48. /package/dist/types/{imports/particlesystem → particlesystem}/Particles.d.ts +0 -0
  49. /package/{imports → src}/BitmapText.js +0 -0
  50. /package/{imports → src}/Color.js +0 -0
  51. /package/{imports → src}/Emerald.js +0 -0
  52. /package/{imports → src}/FPSCounter.js +0 -0
  53. /package/{imports → src}/GLUtils.js +0 -0
  54. /package/{imports → src}/Instance.js +0 -0
  55. /package/{imports → src}/InstancedTexture.js +0 -0
  56. /package/{imports → src}/Physics.js +0 -0
  57. /package/{imports → src}/Shaders.js +0 -0
  58. /package/{imports → src}/Shapes.js +0 -0
  59. /package/{imports → src}/Storage.js +0 -0
  60. /package/{imports → src}/Texture.js +0 -0
  61. /package/{imports → src}/Transform.js +0 -0
  62. /package/{imports → src}/components/BoxColliderDebug.js +0 -0
  63. /package/{imports → src}/components/CircleColliderDebug.js +0 -0
  64. /package/{imports → src}/components/Collider.js +0 -0
  65. /package/{imports → src}/components/RigidBody.js +0 -0
  66. /package/{imports → src}/lights/DirectionalLight.js +0 -0
  67. /package/{imports → src}/lights/PointLight.js +0 -0
  68. /package/{imports → src}/managers/AudioManager.js +0 -0
  69. /package/{imports → src}/managers/EventManager.js +0 -0
  70. /package/{imports → src}/managers/ShaderManager.js +0 -0
  71. /package/{imports → src}/particlesystem/Particle.js +0 -0
  72. /package/{imports → src}/particlesystem/ParticleSettings.js +0 -0
  73. /package/{imports → src}/particlesystem/Particles.js +0 -0
@@ -1,554 +0,0 @@
1
- import Color from "./Color.js";
2
- import { mat4, vec3, vec4 } from "gl-matrix";
3
- import IDManager from "./managers/IDManager.js";
4
-
5
- /**
6
- * @class Drawable
7
- * @description A class that represents a drawable object
8
- * @param {WebGLRenderingContext} gl - The WebGL rendering context
9
- * @param {Object} programInfo - The program information
10
- * @param {WebGLBuffer} verticesBuffer - The vertices buffer
11
- * @param {WebGLBuffer} texCoordBuffer - The texture coordinate buffer
12
- * @param {Array} vertices - The vertices of the object
13
- * @param {boolean} useTexture - Whether to use a texture
14
- * @param {string} texturePath - The path to the texture
15
- * @param {number} frameWidth - The width of the frame
16
- * @param {number} frameHeight - The height of the frame
17
- * @param {number} framesPerRow - The number of frames per row
18
- * @param {number} totalFrames - The total number of frames
19
- * @param {number} animationSpeed - The speed of the animation
20
- * @param {boolean} autoplay - Whether to autoplay the animation
21
- * @param {boolean} pixelart - Whether to use pixel art
22
- * @param {boolean} useLighting - Whether to use lighting
23
- */
24
- class Drawable {
25
- constructor(
26
- gl,
27
- programInfo,
28
- verticesBuffer,
29
- texCoordBuffer,
30
- vertices,
31
- useTexture,
32
- texturePath,
33
- frameWidth = 0,
34
- frameHeight = 0,
35
- framesPerRow = 1,
36
- totalFrames = 1,
37
- animationSpeed = 1000,
38
- autoplay = true,
39
- pixelart = false,
40
- useLighting = true
41
- ) {
42
- this.gl = gl;
43
- this.programInfo = programInfo;
44
- this.id = IDManager.generateUniqueID();
45
- this.verticesBuffer = verticesBuffer;
46
- this.texCoordBuffer = texCoordBuffer;
47
- this.vertices = vertices;
48
- this.color = vec4.fromValues(1.0, 1.0, 1.0, 1.0);
49
- this.texturePath = texturePath;
50
- this.texture = null;
51
- this.useTexture = useTexture;
52
- if (useTexture) {
53
- this.initTexture().then(() => { });
54
- }
55
- this.frameWidth = frameWidth;
56
- this.frameHeight = frameHeight;
57
- this.framesPerRow = framesPerRow;
58
- this.totalFrames = totalFrames;
59
- this.currentFrame = 0;
60
- this.animationSpeed = animationSpeed;
61
- this.lastFrameTime = 0;
62
- this.textureWidth = 0;
63
- this.textureHeight = 0;
64
- this.isPlaying = autoplay;
65
- this.playOnce = false;
66
- this.originalTexture = null;
67
- this.mirrored = false;
68
- this.animationType = "texturePath";
69
- this.currentAnimationArray = [];
70
- this.currentAnimationIndex = 0;
71
- this.shouldRevertAfterPlayingOnce = false;
72
- this.revertAnimation = [];
73
- this.parentObject = null;
74
- this.isActive = false;
75
- this.isWireframe = false;
76
- this.callbackFunction = () => { };
77
- this.pixelart = pixelart;
78
- this.useLighting = useLighting; // Default to true to maintain existing behavior
79
- }
80
-
81
- /**
82
- * @method setIsWireframe
83
- * @description Sets the wireframe mode
84
- * @param {boolean} bool - Whether to enable wireframe mode
85
- */
86
- setIsWireframe(bool) {
87
- this.isWireframe = bool;
88
- }
89
-
90
- /**
91
- * @method setUseLighting
92
- * @description Sets the lighting mode
93
- * @param {boolean} useLighting - Whether to enable lighting reaction
94
- */
95
- setUseLighting(useLighting) {
96
- this.useLighting = useLighting;
97
- }
98
-
99
- /**
100
- * @method setIsActive
101
- * @description Sets the active state
102
- * @param {boolean} bool - Whether to enable the active state
103
- */
104
- setIsActive(bool) {
105
- this.isActive = bool;
106
- }
107
-
108
- /**
109
- * @method setParent
110
- * @description Sets the parent object
111
- * @param {Object} parent - The parent object
112
- */
113
- setParent(parent) {
114
- this.parentObject = parent;
115
- }
116
-
117
- /**
118
- * @method getParent
119
- * @description Gets the parent object
120
- * @returns {Object} - The parent object
121
- */
122
- getParent() {
123
- return this.parentObject;
124
- }
125
-
126
- /**
127
- * @method setColor
128
- * @description Sets the color of the object
129
- * @param {Color} color - The color to set
130
- */
131
- setColor(color) {
132
- if (color instanceof Color) {
133
- vec4.set(
134
- this.color,
135
- color.r / 255,
136
- color.g / 255,
137
- color.b / 255,
138
- color.a / 255
139
- );
140
- } else {
141
- console.error("[Drawable.js] > color is not an instance of Color class.");
142
- }
143
- }
144
-
145
- /**
146
- * @method initTexture
147
- * @description Initializes the texture
148
- */
149
- async initTexture() {
150
- const image = await this.loadImage(this.texturePath);
151
- this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL, true);
152
-
153
- this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
154
-
155
- this.texture = this.gl.createTexture();
156
- this.gl.bindTexture(this.gl.TEXTURE_2D, this.texture);
157
- this.gl.texParameteri(
158
- this.gl.TEXTURE_2D,
159
- this.gl.TEXTURE_WRAP_S,
160
- this.gl.CLAMP_TO_EDGE
161
- );
162
- this.gl.texParameteri(
163
- this.gl.TEXTURE_2D,
164
- this.gl.TEXTURE_WRAP_T,
165
- this.gl.CLAMP_TO_EDGE
166
- );
167
- this.gl.texParameteri(
168
- this.gl.TEXTURE_2D,
169
- this.gl.TEXTURE_MIN_FILTER,
170
- this.pixelart ? this.gl.NEAREST : this.gl.LINEAR
171
- );
172
- this.gl.texParameteri(
173
- this.gl.TEXTURE_2D,
174
- this.gl.TEXTURE_MAG_FILTER,
175
- this.pixelart ? this.gl.NEAREST : this.gl.LINEAR
176
- );
177
- this.gl.texImage2D(
178
- this.gl.TEXTURE_2D,
179
- 0,
180
- this.gl.RGBA,
181
- this.gl.RGBA,
182
- this.gl.UNSIGNED_BYTE,
183
- image
184
- );
185
- this.textureWidth = image.width;
186
- this.textureHeight = image.height;
187
- this.originalTexture = this.texture;
188
- }
189
-
190
- /**
191
- * @method updateAnimation
192
- * @description Updates the animation
193
- * @param {number} currentTime - The current time
194
- */
195
- updateAnimation(currentTime) {
196
- if (
197
- this.totalFrames > 1 &&
198
- this.isPlaying &&
199
- currentTime - this.lastFrameTime > this.animationSpeed
200
- ) {
201
- if (this.animationType === "texturePath") {
202
- this.currentFrame = (this.currentFrame + 1) % this.totalFrames;
203
- } else if (this.animationType === "array") {
204
- this.currentFrame =
205
- this.currentAnimationArray[this.currentAnimationIndex];
206
- this.currentAnimationIndex++;
207
- if (this.currentAnimationIndex >= this.currentAnimationArray.length) {
208
- if (this.playOnce) {
209
- if (this.shouldRevertAfterPlayingOnce) {
210
- this.currentAnimationIndex = 0;
211
- this.currentAnimationArray = this.revertAnimation;
212
- } else {
213
- this.isPlaying = false;
214
- }
215
- this.playOnce = false;
216
- this.callbackFunction();
217
- } else {
218
- this.currentAnimationIndex = 0;
219
- }
220
- }
221
- }
222
- this.lastFrameTime = currentTime;
223
- }
224
- }
225
-
226
- /**
227
- * @method getAnimation
228
- * @description Gets the animation
229
- * @returns {Array} - The animation
230
- */
231
- getAnimation() {
232
- if (this.animationType === "texturePath") {
233
- return this.texturePath;
234
- } else if (this.animationType === "array") {
235
- return this.currentAnimationArray;
236
- }
237
- return null;
238
- }
239
-
240
- /**
241
- * @method playAnimation
242
- * @description Plays an animation
243
- * @param {Array} animation - The animation to play
244
- * @param {number} animationSpeed - The speed of the animation
245
- */
246
- playAnimation(animation, animationSpeed = 1000) {
247
- if (animation.length !== 0) {
248
- this.animationSpeed = animationSpeed;
249
- this.animationType = "array";
250
- this.currentAnimationArray = animation;
251
- this.currentAnimationIndex = 0;
252
- // Not tested
253
- // this.currentFrame = 0;
254
- this.isPlaying = true;
255
- this.playOnce = false;
256
- } else {
257
- console.error(
258
- "[Drawable.js] | [playAnimation] > Animation cannot be empty!"
259
- );
260
- }
261
- }
262
-
263
- /**
264
- * @method setFrame
265
- * @description Sets the frame
266
- * @param {number} frame - The frame to set
267
- */
268
- setFrame(frame) {
269
- this.currentFrame = frame;
270
- this.isPlaying = false;
271
- }
272
-
273
- /**
274
- * @method playAnimationOnce
275
- * @description Plays an animation once
276
- * @param {Array} animation - The animation to play
277
- * @param {Array} defaultAnimation - The default animation
278
- * @param {number} animationSpeed - The speed of the animation
279
- * @param {function} callbackFunction - The callback function
280
- */
281
- playAnimationOnce(
282
- animation,
283
- defaultAnimation = null,
284
- animationSpeed = 1000,
285
- callbackFunction = null
286
- ) {
287
- if (animation.length !== 0) {
288
- this.animationSpeed = animationSpeed;
289
- this.animationType = "array";
290
- this.currentAnimationArray = animation;
291
- this.currentAnimationIndex = 0;
292
- // Not tested
293
- // this.currentFrame = 0;
294
- this.isPlaying = true;
295
- this.playOnce = true;
296
- if (defaultAnimation !== null && defaultAnimation.length > 0) {
297
- this.shouldRevertAfterPlayingOnce = true;
298
- this.revertAnimation = defaultAnimation;
299
- } else {
300
- this.shouldRevertAfterPlayingOnce = false;
301
- this.revertAnimation = [];
302
- }
303
-
304
- if (callbackFunction) {
305
- this.callbackFunction = callbackFunction;
306
- }
307
- } else {
308
- console.error(
309
- "[Drawable.js] | [playAnimationOnce] > Animation cannot be empty!"
310
- );
311
- }
312
- }
313
-
314
- /**
315
- * @method stopAnimation
316
- * @description Stops the animation
317
- */
318
- stopAnimation() {
319
- this.currentFrame = 0;
320
- this.isPlaying = false;
321
- this.playOnce = false;
322
- this.texture = this.originalTexture;
323
- }
324
-
325
- /**
326
- * @method draw
327
- * @description Draws the object
328
- * @param {mat4} globalViewMatrix - The global view matrix
329
- * @param {WebGLUniformLocation} uniformLocation - The uniform location
330
- * @param {number} currentTime - The current time
331
- * @param {Object} objectTransform - The object transform
332
- */
333
- draw(globalViewMatrix, uniformLocation, currentTime, objectTransform) {
334
- let objectTransformMatrix = mat4.create();
335
- mat4.translate(
336
- objectTransformMatrix,
337
- objectTransformMatrix,
338
- vec3.fromValues(
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,
345
- objectTransform.position.z
346
- )
347
- );
348
- mat4.rotate(objectTransformMatrix, objectTransformMatrix, 0, [1, 0, 0]);
349
- mat4.rotate(objectTransformMatrix, objectTransformMatrix, 0, [0, 1, 0]);
350
- mat4.rotate(
351
- objectTransformMatrix,
352
- objectTransformMatrix,
353
- objectTransform.rotation,
354
- [0, 0, 1]
355
- );
356
-
357
- // The scale values here represent half-extents
358
- mat4.scale(
359
- objectTransformMatrix,
360
- objectTransformMatrix,
361
- vec3.fromValues(objectTransform.scale.x, objectTransform.scale.y, 1.0)
362
- );
363
-
364
- let finalTransformMatrix = mat4.create();
365
- mat4.mul(finalTransformMatrix, globalViewMatrix, objectTransformMatrix);
366
- this.gl.uniform1i(
367
- this.programInfo.uniformLocations.useTexture,
368
- this.useTexture
369
- );
370
- this.gl.uniform1i(this.programInfo.uniformLocations.useInstances, false);
371
-
372
- // Set lighting uniform
373
- this.gl.uniform1i(
374
- this.programInfo.uniformLocations.useLighting,
375
- this.useLighting
376
- );
377
-
378
- // Always set the color uniform for tinting
379
- this.gl.uniform4fv(this.programInfo.uniformLocations.color, this.color);
380
-
381
- // Set per-GameObject opacity if available (defaults to 1.0)
382
- const parentOpacity = this.parentObject && typeof this.parentObject.opacity === "number"
383
- ? this.parentObject.opacity
384
- : 1.0;
385
- if (this.programInfo.uniformLocations.uOpacity) {
386
- this.gl.uniform1f(this.programInfo.uniformLocations.uOpacity, parentOpacity);
387
- }
388
-
389
- this.gl.uniformMatrix4fv(
390
- uniformLocation,
391
- false,
392
- new Float32Array(finalTransformMatrix)
393
- );
394
-
395
- // Bind and set vertex position buffer
396
- this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.verticesBuffer);
397
- this.gl.vertexAttribPointer(
398
- this.programInfo.attribLocations.vertexPosition,
399
- 2,
400
- this.gl.FLOAT,
401
- false,
402
- 0,
403
- 0
404
- );
405
- this.gl.enableVertexAttribArray(
406
- this.programInfo.attribLocations.vertexPosition
407
- );
408
-
409
- // Bind and set texture coordinate buffer
410
- if (this.useTexture) {
411
- this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.texCoordBuffer);
412
- this.gl.vertexAttribPointer(
413
- this.programInfo.attribLocations.aTexCoord,
414
- 2,
415
- this.gl.FLOAT,
416
- false,
417
- 0,
418
- 0
419
- );
420
- this.gl.enableVertexAttribArray(
421
- this.programInfo.attribLocations.aTexCoord
422
- );
423
-
424
- if (this.texture) {
425
- this.gl.bindTexture(this.gl.TEXTURE_2D, this.texture);
426
- }
427
-
428
- this.updateAnimation(currentTime);
429
-
430
- let texLeft, texRight, texTop, texBottom;
431
-
432
- if (this.frameWidth > 0 && this.frameHeight > 0) {
433
- // Spritesheet animation
434
- const col = this.currentFrame % this.framesPerRow;
435
- const row = Math.floor(this.currentFrame / this.framesPerRow);
436
-
437
- texLeft = ((col + 1) * this.frameWidth) / this.textureWidth;
438
- texRight = (col * this.frameWidth) / this.textureWidth;
439
- texTop =
440
- (this.textureHeight - row * this.frameHeight - this.frameHeight) /
441
- this.textureHeight;
442
- texBottom =
443
- (this.textureHeight - row * this.frameHeight) / this.textureHeight;
444
- } else {
445
- // Static image
446
- texLeft = 1.0;
447
- texRight = 0.0;
448
- texTop = 0.0;
449
- texBottom = 1.0;
450
- }
451
- // If mirrored change texLeft and texRight in places
452
- const texCoords = this.mirrored
453
- ? new Float32Array([
454
- texRight,
455
- texBottom,
456
- texLeft,
457
- texBottom,
458
- texRight,
459
- texTop,
460
- texLeft,
461
- texTop,
462
- ])
463
- : new Float32Array([
464
- texLeft,
465
- texBottom,
466
- texRight,
467
- texBottom,
468
- texLeft,
469
- texTop,
470
- texRight,
471
- texTop,
472
- ]);
473
- // Update texture coordinate buffer
474
- this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.texCoordBuffer);
475
- this.gl.bufferData(this.gl.ARRAY_BUFFER, texCoords, this.gl.STATIC_DRAW);
476
- } else {
477
- // If not using texture, disable the texture attribute
478
- this.gl.disableVertexAttribArray(
479
- this.programInfo.attribLocations.aTexCoord
480
- );
481
- this.gl.bindTexture(this.gl.TEXTURE_2D, null);
482
- }
483
-
484
- let drawMode, vertexCount;
485
-
486
- if (this.vertices.length === 8) {
487
- // Square/Rectangle - Triangle strip
488
- drawMode = this.gl.TRIANGLE_STRIP;
489
- vertexCount = 4;
490
- } else if (this.vertices.length === 6) {
491
- // Triangle
492
- drawMode = this.gl.TRIANGLES;
493
- vertexCount = 3;
494
- } else {
495
- // Circle - Triangle fan
496
- drawMode = this.gl.TRIANGLE_FAN;
497
- vertexCount = this.vertices.length / 2;
498
- }
499
-
500
- if (this.isWireframe) {
501
- // Fix the wireframe for square
502
- if (this.vertices.length === 8) {
503
- let tempBuffer = this.gl.createBuffer();
504
- this.gl.bindBuffer(this.gl.ARRAY_BUFFER, tempBuffer);
505
-
506
- const rectOutline = new Float32Array([
507
- this.vertices[0],
508
- this.vertices[1], // Bottom-left (0)
509
- this.vertices[2],
510
- this.vertices[3], // Bottom-right (1)
511
- this.vertices[6],
512
- this.vertices[7], // Top-right (2)
513
- this.vertices[4],
514
- this.vertices[5], // Top-left (3)
515
- ]);
516
-
517
- this.gl.bufferData(
518
- this.gl.ARRAY_BUFFER,
519
- rectOutline,
520
- this.gl.STATIC_DRAW
521
- );
522
-
523
- this.gl.vertexAttribPointer(
524
- this.programInfo.attribLocations.vertexPosition,
525
- 2,
526
- this.gl.FLOAT,
527
- false,
528
- 0,
529
- 0
530
- );
531
-
532
- }
533
- drawMode = this.gl.LINE_LOOP;
534
- }
535
-
536
- this.gl.drawArrays(drawMode, 0, vertexCount);
537
- }
538
-
539
- /**
540
- * @method loadImage
541
- * @description Loads an image
542
- * @param {string} path - The path to the image
543
- * @returns {Promise} - The promise
544
- */
545
- loadImage = (path) =>
546
- new Promise((resolve, reject) => {
547
- const image = new Image();
548
- image.addEventListener("load", () => resolve(image));
549
- image.addEventListener("error", (err) => reject(err));
550
- image.src = path;
551
- });
552
- }
553
-
554
- export default Drawable;
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