3d-spinner 0.9.2 → 0.9.4

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 (101) hide show
  1. package/README.md +66 -4
  2. package/dist/animation-label.d.ts +8 -0
  3. package/dist/animation-label.js +47 -0
  4. package/dist/animation.d.ts +2 -0
  5. package/dist/animations/charged-orb.d.ts +55 -0
  6. package/dist/animations/charged-orb.js +229 -0
  7. package/dist/animations/ghost-train.d.ts +72 -0
  8. package/dist/animations/ghost-train.js +247 -0
  9. package/dist/animations/grid-assembly.d.ts +70 -0
  10. package/dist/animations/grid-assembly.js +282 -0
  11. package/dist/animations/object-motion.d.ts +19 -7
  12. package/dist/animations/object-motion.js +38 -32
  13. package/dist/animations/particles.d.ts +110 -0
  14. package/dist/animations/particles.js +209 -0
  15. package/dist/animations/rocket-launch.d.ts +58 -0
  16. package/dist/animations/rocket-launch.js +375 -0
  17. package/dist/cjs/animations/charged-orb.cjs +1334 -0
  18. package/dist/cjs/animations/grid-assembly.cjs +1380 -0
  19. package/dist/cjs/animations/object-motion.cjs +124 -43
  20. package/dist/cjs/animations/particles.cjs +1940 -0
  21. package/dist/cjs/animations/spin.cjs +4 -3
  22. package/dist/cjs/composite-animation.cjs +58 -0
  23. package/dist/cjs/engines/little-3d-engine/little-3d-engine.cjs +143 -22
  24. package/dist/cjs/engines/little-3d-engine/loaders/obj.cjs +30 -1
  25. package/dist/cjs/engines/little-3d-engine/renderers/canvas2d-textured.cjs +345 -0
  26. package/dist/cjs/engines/little-3d-engine/renderers/webgl-textured.cjs +528 -0
  27. package/dist/cjs/engines/little-3d-engine/renderers/webgpu-textured.cjs +712 -0
  28. package/dist/cjs/prefabs/prefabs.cjs +3916 -0
  29. package/dist/composite-animation.d.ts +18 -0
  30. package/dist/composite-animation.js +39 -0
  31. package/dist/engines/little-3d-engine/little-3d-engine.d.ts +17 -12
  32. package/dist/engines/little-3d-engine/little-3d-engine.js +13 -8
  33. package/dist/engines/little-3d-engine/loaders/obj.d.ts +12 -4
  34. package/dist/engines/little-3d-engine/loaders/obj.js +44 -5
  35. package/dist/engines/little-3d-engine/renderer.d.ts +7 -1
  36. package/dist/engines/little-3d-engine/renderer.js +2 -0
  37. package/dist/engines/little-3d-engine/renderers/canvas2d-textured.d.ts +20 -0
  38. package/dist/engines/little-3d-engine/renderers/canvas2d-textured.js +135 -0
  39. package/dist/engines/little-3d-engine/renderers/textured-helpers.d.ts +9 -0
  40. package/dist/engines/little-3d-engine/renderers/textured-helpers.js +35 -0
  41. package/dist/engines/little-3d-engine/renderers/webgl-textured.d.ts +43 -0
  42. package/dist/engines/little-3d-engine/renderers/webgl-textured.js +211 -0
  43. package/dist/engines/little-3d-engine/renderers/webgpu-textured.d.ts +45 -0
  44. package/dist/engines/little-3d-engine/renderers/webgpu-textured.js +300 -0
  45. package/dist/engines/little-3d-engine/renderers/webgpu.d.ts +11 -6
  46. package/dist/engines/little-3d-engine/shapes/complex/plane.d.ts +3 -0
  47. package/dist/engines/little-3d-engine/shapes/complex/plane.js +33 -0
  48. package/dist/engines/little-3d-engine/shapes/{cube.d.ts → primitives/cube.d.ts} +1 -1
  49. package/dist/engines/little-3d-engine/shapes/{octahedron.d.ts → primitives/octahedron.d.ts} +1 -1
  50. package/dist/engines/little-3d-engine/shapes/{pyramid.d.ts → primitives/pyramid.d.ts} +1 -1
  51. package/dist/engines/little-3d-engine/shapes/primitives/quad.d.ts +9 -0
  52. package/dist/engines/little-3d-engine/shapes/primitives/quad.js +18 -0
  53. package/dist/engines/little-3d-engine/shapes/{cube-sphere.d.ts → primitives/spheres/cube-sphere.d.ts} +1 -1
  54. package/dist/engines/little-3d-engine/shapes/{icosphere.d.ts → primitives/spheres/icosphere.d.ts} +1 -1
  55. package/dist/engines/little-3d-engine/shapes/{icosphere.js → primitives/spheres/icosphere.js} +1 -1
  56. package/dist/engines/little-3d-engine/shapes/{octa-sphere.d.ts → primitives/spheres/octa-sphere.d.ts} +1 -1
  57. package/dist/engines/little-3d-engine/shapes/{octa-sphere.js → primitives/spheres/octa-sphere.js} +1 -1
  58. package/dist/engines/little-3d-engine/shapes/{uv-sphere.d.ts → primitives/spheres/uv-sphere.d.ts} +1 -1
  59. package/dist/engines/little-3d-engine/shapes/{tetrahedron.d.ts → primitives/tetrahedron.d.ts} +1 -1
  60. package/dist/engines/little-3d-engine/textures/dynamic/canvas-texture.d.ts +1 -0
  61. package/dist/engines/little-3d-engine/textures/dynamic/canvas-texture.js +8 -0
  62. package/dist/engines/little-3d-engine/textures/dynamic/shine.d.ts +2 -0
  63. package/dist/engines/little-3d-engine/textures/dynamic/shine.js +14 -0
  64. package/dist/engines/little-3d-engine/textures/dynamic/star.d.ts +14 -0
  65. package/dist/engines/little-3d-engine/textures/dynamic/star.js +31 -0
  66. package/dist/engines/little-3d-engine/textures/dynamic/streak.d.ts +5 -0
  67. package/dist/engines/little-3d-engine/textures/dynamic/streak.js +20 -0
  68. package/dist/index.d.ts +2 -1
  69. package/dist/prefabs/charged-orb.d.ts +17 -0
  70. package/dist/prefabs/charged-orb.js +37 -0
  71. package/dist/prefabs/crystal-comet.d.ts +4 -0
  72. package/dist/prefabs/crystal-comet.js +41 -0
  73. package/dist/prefabs/ghost-train.d.ts +10 -0
  74. package/dist/prefabs/ghost-train.js +37 -0
  75. package/dist/prefabs/grid-assembly.d.ts +13 -0
  76. package/dist/prefabs/grid-assembly.js +15 -0
  77. package/dist/prefabs/monochrome-streak.d.ts +4 -0
  78. package/dist/prefabs/monochrome-streak.js +25 -0
  79. package/dist/prefabs/plane-star-trail.d.ts +4 -0
  80. package/dist/prefabs/plane-star-trail.js +40 -0
  81. package/dist/prefabs/prefabs.d.ts +10 -0
  82. package/dist/prefabs/prefabs.js +9 -0
  83. package/dist/prefabs/pulsing-starfield.d.ts +4 -0
  84. package/dist/prefabs/pulsing-starfield.js +27 -0
  85. package/dist/prefabs/rocket-launch.d.ts +10 -0
  86. package/dist/prefabs/rocket-launch.js +16 -0
  87. package/dist/prefabs/spinner.d.ts +7 -0
  88. package/dist/prefabs/spinner.js +17 -0
  89. package/dist/prefabs/star-swarm.d.ts +4 -0
  90. package/dist/prefabs/star-swarm.js +27 -0
  91. package/dist/prefabs/types.d.ts +46 -0
  92. package/dist/prefabs/types.js +1 -0
  93. package/dist/umd/spinner.global.js +2407 -85
  94. package/dist/umd/spinner.global.min.js +60 -5
  95. package/package.json +43 -2
  96. /package/dist/engines/little-3d-engine/shapes/{cube.js → primitives/cube.js} +0 -0
  97. /package/dist/engines/little-3d-engine/shapes/{octahedron.js → primitives/octahedron.js} +0 -0
  98. /package/dist/engines/little-3d-engine/shapes/{pyramid.js → primitives/pyramid.js} +0 -0
  99. /package/dist/engines/little-3d-engine/shapes/{cube-sphere.js → primitives/spheres/cube-sphere.js} +0 -0
  100. /package/dist/engines/little-3d-engine/shapes/{uv-sphere.js → primitives/spheres/uv-sphere.js} +0 -0
  101. /package/dist/engines/little-3d-engine/shapes/{tetrahedron.js → primitives/tetrahedron.js} +0 -0
@@ -0,0 +1,345 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __esm = (fn, res, err) => function __init() {
7
+ if (err) throw err[0];
8
+ try {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ } catch (e) {
11
+ throw err = [e], e;
12
+ }
13
+ };
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+
28
+ // src/engines/little-3d-engine/core/math.ts
29
+ function subtract(a, b) {
30
+ return { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z };
31
+ }
32
+ function cross(a, b) {
33
+ return {
34
+ x: a.y * b.z - a.z * b.y,
35
+ y: a.z * b.x - a.x * b.z,
36
+ z: a.x * b.y - a.y * b.x
37
+ };
38
+ }
39
+ function dot(a, b) {
40
+ return a.x * b.x + a.y * b.y + a.z * b.z;
41
+ }
42
+ function normalize(v) {
43
+ const length = Math.hypot(v.x, v.y, v.z);
44
+ if (length === 0) return { x: 0, y: 0, z: 0 };
45
+ return { x: v.x / length, y: v.y / length, z: v.z / length };
46
+ }
47
+ function transformPoint(m, p) {
48
+ const x = m[0] * p.x + m[4] * p.y + m[8] * p.z + m[12];
49
+ const y = m[1] * p.x + m[5] * p.y + m[9] * p.z + m[13];
50
+ const z = m[2] * p.x + m[6] * p.y + m[10] * p.z + m[14];
51
+ const w = m[3] * p.x + m[7] * p.y + m[11] * p.z + m[15] || 1;
52
+ return { x: x / w, y: y / w, z: z / w };
53
+ }
54
+ function transformAffine(m, p) {
55
+ return {
56
+ x: m[0] * p.x + m[4] * p.y + m[8] * p.z + m[12],
57
+ y: m[1] * p.x + m[5] * p.y + m[9] * p.z + m[13],
58
+ z: m[2] * p.x + m[6] * p.y + m[10] * p.z + m[14]
59
+ };
60
+ }
61
+ var init_math = __esm({
62
+ "src/engines/little-3d-engine/core/math.ts"() {
63
+ "use strict";
64
+ }
65
+ });
66
+
67
+ // src/engines/little-3d-engine/renderer.ts
68
+ function opacity(value, fallback) {
69
+ return Math.max(0, Math.min(1, value ?? fallback));
70
+ }
71
+ function resolveTwoSidedOpacity(transparency) {
72
+ const front = opacity(
73
+ transparency.frontOpacity ?? transparency.opacity,
74
+ DEFAULT_FRONT_OPACITY
75
+ );
76
+ const backFallback = transparency.opacity === void 0 ? DEFAULT_BACK_OPACITY : front * (2 / 3);
77
+ return {
78
+ front,
79
+ back: opacity(transparency.backOpacity, backFallback)
80
+ };
81
+ }
82
+ var DEFAULT_ONE_SIDED_OPACITY, DEFAULT_BACK_OPACITY, DEFAULT_FRONT_OPACITY;
83
+ var init_renderer = __esm({
84
+ "src/engines/little-3d-engine/renderer.ts"() {
85
+ "use strict";
86
+ DEFAULT_ONE_SIDED_OPACITY = 0.35;
87
+ DEFAULT_BACK_OPACITY = 0.84;
88
+ DEFAULT_FRONT_OPACITY = 0.56;
89
+ }
90
+ });
91
+
92
+ // src/engines/little-3d-engine/core/geometry.ts
93
+ function parseColor(color) {
94
+ const hex = color.trim().replace("#", "");
95
+ const full = hex.length === 3 ? hex.split("").map((c) => c + c).join("") : hex;
96
+ const n = parseInt(full, 16);
97
+ return [n >> 16 & 255, n >> 8 & 255, n & 255];
98
+ }
99
+ var init_geometry = __esm({
100
+ "src/engines/little-3d-engine/core/geometry.ts"() {
101
+ "use strict";
102
+ init_math();
103
+ }
104
+ });
105
+
106
+ // src/engines/little-3d-engine/core/light.ts
107
+ function clamp01(value) {
108
+ return Math.min(1, Math.max(0, value));
109
+ }
110
+ function shadeColor(normal, color, light) {
111
+ const lambert = Math.max(0, dot(normal, light.toLight));
112
+ const brightness = clamp01(light.ambient + light.intensity * lambert);
113
+ const [r, g, b] = parseColor(color);
114
+ return `rgb(${Math.round(r * brightness)}, ${Math.round(g * brightness)}, ${Math.round(
115
+ b * brightness
116
+ )})`;
117
+ }
118
+ var init_light = __esm({
119
+ "src/engines/little-3d-engine/core/light.ts"() {
120
+ "use strict";
121
+ init_math();
122
+ init_geometry();
123
+ }
124
+ });
125
+
126
+ // src/engines/little-3d-engine/renderers/canvas2d.ts
127
+ var Canvas2DRenderer;
128
+ var init_canvas2d = __esm({
129
+ "src/engines/little-3d-engine/renderers/canvas2d.ts"() {
130
+ "use strict";
131
+ init_light();
132
+ init_math();
133
+ init_renderer();
134
+ Canvas2DRenderer = class {
135
+ constructor(options = {}) {
136
+ this.options = options;
137
+ this.dpr = 1;
138
+ }
139
+ init(canvas) {
140
+ this.ctx = canvas.getContext("2d") ?? void 0;
141
+ }
142
+ resize(_cssWidth, _cssHeight, dpr) {
143
+ this.dpr = dpr;
144
+ this.ctx?.setTransform(dpr, 0, 0, dpr, 0, 0);
145
+ }
146
+ render(frame) {
147
+ const ctx = this.ctx;
148
+ if (!ctx) return;
149
+ if (this.options.background) {
150
+ ctx.fillStyle = this.options.background;
151
+ ctx.fillRect(0, 0, frame.width, frame.height);
152
+ } else {
153
+ ctx.clearRect(0, 0, frame.width, frame.height);
154
+ }
155
+ const polygons = [];
156
+ for (const item of frame.items) {
157
+ const world = item.mesh.vertices.map((v) => transformAffine(item.model, v));
158
+ const twoSidedOpacity = item.transparency?.mode === "two-sided" ? resolveTwoSidedOpacity(item.transparency) : void 0;
159
+ for (const face of item.mesh.faces) {
160
+ const a = world[face.indices[0]];
161
+ const b = world[face.indices[1]];
162
+ const c = world[face.indices[2]];
163
+ const normal = normalize(cross(subtract(b, a), subtract(c, a)));
164
+ const frontFacing = dot(normal, subtract(frame.eye, a)) > 0;
165
+ const transparency = item.transparency;
166
+ if (!frontFacing && transparency?.mode !== "two-sided") continue;
167
+ let faceOpacity = 1;
168
+ if (transparency?.mode === "one-sided") {
169
+ faceOpacity = opacity(transparency.opacity, DEFAULT_ONE_SIDED_OPACITY);
170
+ } else if (twoSidedOpacity) {
171
+ faceOpacity = frontFacing ? twoSidedOpacity.front : twoSidedOpacity.back;
172
+ }
173
+ const points = face.indices.map((i) => {
174
+ const ndc = transformPoint(frame.viewProjection, world[i]);
175
+ return {
176
+ x: (ndc.x * 0.5 + 0.5) * frame.width,
177
+ y: (1 - (ndc.y * 0.5 + 0.5)) * frame.height
178
+ };
179
+ });
180
+ let depth = 0;
181
+ for (const i of face.indices) {
182
+ const d = subtract(world[i], frame.eye);
183
+ depth += dot(d, d);
184
+ }
185
+ depth /= face.indices.length;
186
+ polygons.push({
187
+ points,
188
+ color: shadeColor(normal, face.color, frame.light),
189
+ depth,
190
+ opacity: faceOpacity
191
+ });
192
+ }
193
+ }
194
+ polygons.sort((p, q) => q.depth - p.depth);
195
+ for (const poly of polygons) {
196
+ if (poly.points.length < 3) continue;
197
+ ctx.beginPath();
198
+ ctx.moveTo(poly.points[0].x, poly.points[0].y);
199
+ for (let i = 1; i < poly.points.length; i++) {
200
+ ctx.lineTo(poly.points[i].x, poly.points[i].y);
201
+ }
202
+ ctx.closePath();
203
+ ctx.fillStyle = poly.color;
204
+ ctx.strokeStyle = poly.color;
205
+ ctx.lineWidth = 1;
206
+ ctx.globalAlpha = poly.opacity;
207
+ ctx.fill();
208
+ ctx.stroke();
209
+ }
210
+ ctx.globalAlpha = 1;
211
+ }
212
+ destroy() {
213
+ this.ctx = void 0;
214
+ }
215
+ };
216
+ }
217
+ });
218
+
219
+ // src/engines/little-3d-engine/renderers/canvas2d-textured.ts
220
+ var canvas2d_textured_exports = {};
221
+ __export(canvas2d_textured_exports, {
222
+ Canvas2DTexturedRenderer: () => Canvas2DTexturedRenderer
223
+ });
224
+ module.exports = __toCommonJS(canvas2d_textured_exports);
225
+ init_math();
226
+ init_renderer();
227
+ init_canvas2d();
228
+ function imageSize(source) {
229
+ if (source instanceof HTMLImageElement) {
230
+ return source.complete && source.naturalWidth > 0 ? { width: source.naturalWidth, height: source.naturalHeight } : void 0;
231
+ }
232
+ if (source instanceof HTMLVideoElement) {
233
+ return source.readyState >= 2 ? { width: source.videoWidth, height: source.videoHeight } : void 0;
234
+ }
235
+ if (source instanceof SVGImageElement) {
236
+ const width = source.width.baseVal.value;
237
+ const height = source.height.baseVal.value;
238
+ return width > 0 && height > 0 ? { width, height } : void 0;
239
+ }
240
+ if (typeof VideoFrame !== "undefined" && source instanceof VideoFrame) {
241
+ return { width: source.displayWidth, height: source.displayHeight };
242
+ }
243
+ const sized = source;
244
+ return sized.width > 0 && sized.height > 0 ? { width: sized.width, height: sized.height } : void 0;
245
+ }
246
+ function drawMappedTriangle(ctx, image, source, target) {
247
+ const [s0, s1, s2] = source;
248
+ const [d0, d1, d2] = target;
249
+ const determinant = s0.x * (s1.y - s2.y) + s1.x * (s2.y - s0.y) + s2.x * (s0.y - s1.y);
250
+ if (Math.abs(determinant) < 1e-8) return;
251
+ const a = (d0.x * (s1.y - s2.y) + d1.x * (s2.y - s0.y) + d2.x * (s0.y - s1.y)) / determinant;
252
+ const c = (d0.x * (s2.x - s1.x) + d1.x * (s0.x - s2.x) + d2.x * (s1.x - s0.x)) / determinant;
253
+ const e = (d0.x * (s1.x * s2.y - s2.x * s1.y) + d1.x * (s2.x * s0.y - s0.x * s2.y) + d2.x * (s0.x * s1.y - s1.x * s0.y)) / determinant;
254
+ const b = (d0.y * (s1.y - s2.y) + d1.y * (s2.y - s0.y) + d2.y * (s0.y - s1.y)) / determinant;
255
+ const d = (d0.y * (s2.x - s1.x) + d1.y * (s0.x - s2.x) + d2.y * (s1.x - s0.x)) / determinant;
256
+ const f = (d0.y * (s1.x * s2.y - s2.x * s1.y) + d1.y * (s2.x * s0.y - s0.x * s2.y) + d2.y * (s0.x * s1.y - s1.x * s0.y)) / determinant;
257
+ ctx.save();
258
+ ctx.beginPath();
259
+ ctx.moveTo(d0.x, d0.y);
260
+ ctx.lineTo(d1.x, d1.y);
261
+ ctx.lineTo(d2.x, d2.y);
262
+ ctx.closePath();
263
+ ctx.clip();
264
+ ctx.transform(a, b, c, d, e, f);
265
+ ctx.drawImage(image, 0, 0);
266
+ ctx.restore();
267
+ }
268
+ var Canvas2DTexturedRenderer = class {
269
+ constructor(options = {}) {
270
+ this.sources = /* @__PURE__ */ new Map();
271
+ this.loaded = /* @__PURE__ */ new Map();
272
+ this.dpr = 1;
273
+ this.inner = new Canvas2DRenderer(options);
274
+ }
275
+ /** Texture every instance of `mesh` with `source`. Call any time, also before init. */
276
+ setTexture(mesh, source) {
277
+ this.sources.set(mesh, source);
278
+ if (typeof source === "string" && !this.loaded.has(source)) {
279
+ const image = new Image();
280
+ image.src = source;
281
+ this.loaded.set(source, image);
282
+ }
283
+ }
284
+ init(canvas) {
285
+ this.inner.init(canvas);
286
+ this.ctx = canvas.getContext("2d") ?? void 0;
287
+ }
288
+ resize(cssWidth, cssHeight, dpr) {
289
+ this.dpr = dpr;
290
+ this.inner.resize(cssWidth, cssHeight, dpr);
291
+ }
292
+ drawable(mesh) {
293
+ const source = this.sources.get(mesh);
294
+ return typeof source === "string" ? this.loaded.get(source) : source;
295
+ }
296
+ render(frame) {
297
+ const plain = frame.items.filter((item) => {
298
+ if (!this.sources.has(item.mesh)) return true;
299
+ const source = this.drawable(item.mesh);
300
+ return !source || !imageSize(source);
301
+ });
302
+ this.inner.render({ ...frame, items: plain });
303
+ const ctx = this.ctx;
304
+ if (!ctx) return;
305
+ ctx.setTransform(this.dpr, 0, 0, this.dpr, 0, 0);
306
+ const tinted = /* @__PURE__ */ new Map();
307
+ for (const item of frame.items) {
308
+ const source = this.drawable(item.mesh);
309
+ if (!source) continue;
310
+ const size = imageSize(source);
311
+ if (!size) continue;
312
+ let image = tinted.get(item.mesh);
313
+ if (!image) {
314
+ image = document.createElement("canvas");
315
+ image.width = size.width;
316
+ image.height = size.height;
317
+ const tint = image.getContext("2d");
318
+ if (!tint) continue;
319
+ tint.drawImage(source, 0, 0, size.width, size.height);
320
+ tint.globalCompositeOperation = "source-in";
321
+ tint.fillStyle = item.mesh.faces[0]?.color ?? "#ffffff";
322
+ tint.fillRect(0, 0, size.width, size.height);
323
+ tinted.set(item.mesh, image);
324
+ }
325
+ const world = item.mesh.vertices.map((vertex) => transformAffine(item.model, vertex));
326
+ const projected = world.map((vertex) => {
327
+ const ndc = transformPoint(frame.viewProjection, vertex);
328
+ return { x: (ndc.x * 0.5 + 0.5) * frame.width, y: (1 - (ndc.y * 0.5 + 0.5)) * frame.height };
329
+ });
330
+ const face = item.mesh.faces[0];
331
+ if (!face || face.indices.length !== 4) continue;
332
+ const [a, b, c, d] = face.indices.map((index) => projected[index]);
333
+ ctx.globalAlpha = item.transparency?.mode === "one-sided" ? opacity(item.transparency.opacity, DEFAULT_ONE_SIDED_OPACITY) : 1;
334
+ drawMappedTriangle(ctx, image, [{ x: 0, y: size.height }, { x: size.width, y: size.height }, { x: size.width, y: 0 }], [a, b, c]);
335
+ drawMappedTriangle(ctx, image, [{ x: 0, y: size.height }, { x: size.width, y: 0 }, { x: 0, y: 0 }], [a, c, d]);
336
+ }
337
+ ctx.globalAlpha = 1;
338
+ }
339
+ destroy() {
340
+ this.inner.destroy();
341
+ this.ctx = void 0;
342
+ this.sources.clear();
343
+ this.loaded.clear();
344
+ }
345
+ };