@vpmedia/phaser 1.120.0 → 1.121.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/index.js +499 -607
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation.d.ts.map +1 -1
- package/dist/phaser/core/animation_manager.d.ts.map +1 -1
- package/dist/phaser/core/animation_parser.d.ts +1 -1
- package/dist/phaser/core/array_set.d.ts.map +1 -1
- package/dist/phaser/core/callback.d.ts +12 -0
- package/dist/phaser/core/callback.d.ts.map +1 -0
- package/dist/phaser/core/device.d.ts +1 -5
- package/dist/phaser/core/device.d.ts.map +1 -1
- package/dist/phaser/core/dom.d.ts.map +1 -1
- package/dist/phaser/core/factory.d.ts +2 -1
- package/dist/phaser/core/factory.d.ts.map +1 -1
- package/dist/phaser/core/game.d.ts +3 -0
- package/dist/phaser/core/game.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts +11 -9
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_event.d.ts +1 -1
- package/dist/phaser/core/input_event.d.ts.map +1 -1
- package/dist/phaser/core/input_handler.d.ts.map +1 -1
- package/dist/phaser/core/input_mouse.d.ts.map +1 -1
- package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
- package/dist/phaser/core/input_pointer.d.ts +3 -2
- package/dist/phaser/core/input_pointer.d.ts.map +1 -1
- package/dist/phaser/core/input_touch.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts +5 -4
- package/dist/phaser/core/loader.d.ts.map +1 -1
- package/dist/phaser/core/scale_manager.d.ts +5 -4
- package/dist/phaser/core/scale_manager.d.ts.map +1 -1
- package/dist/phaser/core/scene_manager.d.ts.map +1 -1
- package/dist/phaser/core/signal.d.ts +14 -7
- package/dist/phaser/core/signal.d.ts.map +1 -1
- package/dist/phaser/core/signal_binding.d.ts +10 -10
- package/dist/phaser/core/signal_binding.d.ts.map +1 -1
- package/dist/phaser/core/sound.d.ts +3 -3
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/sound_manager.d.ts +9 -3
- package/dist/phaser/core/sound_manager.d.ts.map +1 -1
- package/dist/phaser/core/sound_sprite.d.ts +19 -7
- package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
- package/dist/phaser/core/timer.d.ts +5 -4
- package/dist/phaser/core/timer.d.ts.map +1 -1
- package/dist/phaser/core/timer_event.d.ts +3 -2
- package/dist/phaser/core/timer_event.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts +7 -6
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_data.d.ts +2 -1
- package/dist/phaser/core/tween_data.d.ts.map +1 -1
- package/dist/phaser/core/tween_easing.d.ts +31 -31
- package/dist/phaser/core/tween_manager.d.ts.map +1 -1
- package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
- package/dist/phaser/display/button.d.ts +2 -1
- package/dist/phaser/display/button.d.ts.map +1 -1
- package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
- package/dist/phaser/display/canvas/renderer.d.ts +1 -1
- package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
- package/dist/phaser/display/canvas/util.d.ts +2 -2
- package/dist/phaser/display/canvas/util.d.ts.map +1 -1
- package/dist/phaser/display/display_object.d.ts +8 -6
- package/dist/phaser/display/display_object.d.ts.map +1 -1
- package/dist/phaser/display/graphics.d.ts +7 -3
- package/dist/phaser/display/graphics.d.ts.map +1 -1
- package/dist/phaser/display/group.d.ts +1 -1
- package/dist/phaser/display/group.d.ts.map +1 -1
- package/dist/phaser/display/image.d.ts.map +1 -1
- package/dist/phaser/display/sprite_util.d.ts.map +1 -1
- package/dist/phaser/display/text.d.ts +5 -0
- package/dist/phaser/display/text.d.ts.map +1 -1
- package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
- package/dist/phaser/geom/polygon.d.ts +11 -5
- package/dist/phaser/geom/polygon.d.ts.map +1 -1
- package/dist/phaser/geom/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
- package/dist/phaser/util/math.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/phaser/core/animation.ts +1 -2
- package/src/phaser/core/animation_manager.ts +3 -11
- package/src/phaser/core/animation_parser.ts +2 -2
- package/src/phaser/core/array_set.ts +8 -10
- package/src/phaser/core/cache.ts +2 -2
- package/src/phaser/core/callback.ts +14 -0
- package/src/phaser/core/device.ts +24 -53
- package/src/phaser/core/device_util.ts +6 -6
- package/src/phaser/core/dom.ts +10 -7
- package/src/phaser/core/factory.ts +3 -2
- package/src/phaser/core/game.ts +4 -5
- package/src/phaser/core/input.ts +16 -12
- package/src/phaser/core/input_event.ts +1 -1
- package/src/phaser/core/input_handler.ts +21 -22
- package/src/phaser/core/input_mouse.ts +12 -17
- package/src/phaser/core/input_mspointer.ts +8 -11
- package/src/phaser/core/input_pointer.ts +22 -21
- package/src/phaser/core/input_touch.ts +16 -19
- package/src/phaser/core/loader.ts +75 -86
- package/src/phaser/core/loader_parser.ts +6 -6
- package/src/phaser/core/scale_manager.ts +34 -42
- package/src/phaser/core/scene_manager.ts +2 -1
- package/src/phaser/core/signal.ts +21 -13
- package/src/phaser/core/signal_binding.ts +20 -21
- package/src/phaser/core/sound.ts +9 -11
- package/src/phaser/core/sound_manager.ts +53 -47
- package/src/phaser/core/sound_sprite.ts +34 -21
- package/src/phaser/core/stage.ts +4 -4
- package/src/phaser/core/timer.ts +13 -30
- package/src/phaser/core/timer_event.ts +3 -2
- package/src/phaser/core/tween.ts +9 -8
- package/src/phaser/core/tween_data.ts +15 -41
- package/src/phaser/core/tween_easing.test.ts +35 -35
- package/src/phaser/core/tween_easing.ts +33 -33
- package/src/phaser/core/tween_manager.ts +77 -75
- package/src/phaser/display/bitmap_text.ts +7 -11
- package/src/phaser/display/button.ts +3 -2
- package/src/phaser/display/canvas/graphics.ts +7 -7
- package/src/phaser/display/canvas/pool.ts +5 -6
- package/src/phaser/display/canvas/renderer.ts +7 -4
- package/src/phaser/display/canvas/tinter.ts +9 -11
- package/src/phaser/display/canvas/util.test.ts +122 -0
- package/src/phaser/display/canvas/util.ts +34 -35
- package/src/phaser/display/display_object.ts +30 -43
- package/src/phaser/display/graphics.ts +30 -45
- package/src/phaser/display/group.ts +1 -1
- package/src/phaser/display/image.ts +9 -16
- package/src/phaser/display/sprite_util.ts +0 -1
- package/src/phaser/display/text.ts +27 -43
- package/src/phaser/display/webgl/base_texture.ts +3 -3
- package/src/phaser/display/webgl/earcut.ts +2 -3
- package/src/phaser/display/webgl/fast_sprite_batch.ts +1 -2
- package/src/phaser/display/webgl/filter_manager.ts +6 -18
- package/src/phaser/display/webgl/filter_texture.ts +3 -3
- package/src/phaser/display/webgl/graphics.ts +28 -38
- package/src/phaser/display/webgl/graphics_data.ts +0 -1
- package/src/phaser/display/webgl/render_texture.ts +4 -13
- package/src/phaser/display/webgl/renderer.ts +0 -1
- package/src/phaser/display/webgl/sprite_batch.ts +2 -9
- package/src/phaser/display/webgl/texture.ts +12 -15
- package/src/phaser/geom/point.ts +1 -1
- package/src/phaser/geom/polygon.test.ts +59 -0
- package/src/phaser/geom/polygon.ts +43 -45
- package/src/phaser/geom/rectangle.ts +3 -15
- package/src/phaser/geom/rounded_rectangle.ts +2 -4
- package/src/phaser/geom/util/point.ts +1 -1
- package/src/phaser/geom/util/rectangle.ts +2 -2
- package/src/phaser/util/math.ts +1 -5
package/dist/index.js
CHANGED
|
@@ -114,7 +114,7 @@ const TIME_SECOND = 1e3;
|
|
|
114
114
|
const distance$1 = (a, b, round = false) => {
|
|
115
115
|
const dx = a.x - b.x;
|
|
116
116
|
const dy = a.y - b.y;
|
|
117
|
-
const abDistance = Math.
|
|
117
|
+
const abDistance = Math.hypot(dx, dy);
|
|
118
118
|
return round ? Math.round(abDistance) : abDistance;
|
|
119
119
|
};
|
|
120
120
|
/**
|
|
@@ -347,7 +347,7 @@ var Point = class {
|
|
|
347
347
|
* @returns {number} The magnitude of the point.
|
|
348
348
|
*/
|
|
349
349
|
getMagnitude() {
|
|
350
|
-
return Math.
|
|
350
|
+
return Math.hypot(this.x, this.y);
|
|
351
351
|
}
|
|
352
352
|
/**
|
|
353
353
|
* Calculates the square of the magnitude (length) of this point from the origin.
|
|
@@ -1161,8 +1161,7 @@ var Rectangle = class {
|
|
|
1161
1161
|
* Sets the bottom coordinate of this rectangle.
|
|
1162
1162
|
*/
|
|
1163
1163
|
set bottom(value) {
|
|
1164
|
-
|
|
1165
|
-
else this.height = value - this.y;
|
|
1164
|
+
this.height = value <= this.y ? 0 : value - this.y;
|
|
1166
1165
|
}
|
|
1167
1166
|
/**
|
|
1168
1167
|
* Gets the bottom-left point of this rectangle.
|
|
@@ -1203,8 +1202,7 @@ var Rectangle = class {
|
|
|
1203
1202
|
* Sets the left coordinate of this rectangle.
|
|
1204
1203
|
*/
|
|
1205
1204
|
set left(value) {
|
|
1206
|
-
|
|
1207
|
-
else this.width = this.right - value;
|
|
1205
|
+
this.width = value >= this.right ? 0 : this.right - value;
|
|
1208
1206
|
this.x = value;
|
|
1209
1207
|
}
|
|
1210
1208
|
/**
|
|
@@ -1218,8 +1216,7 @@ var Rectangle = class {
|
|
|
1218
1216
|
* Sets the right coordinate of this rectangle.
|
|
1219
1217
|
*/
|
|
1220
1218
|
set right(value) {
|
|
1221
|
-
|
|
1222
|
-
else this.width = value - this.x;
|
|
1219
|
+
this.width = value <= this.x ? 0 : value - this.x;
|
|
1223
1220
|
}
|
|
1224
1221
|
/**
|
|
1225
1222
|
* Gets the volume (area) of this rectangle.
|
|
@@ -1371,11 +1368,7 @@ const linearInterpolation = (v, k) => {
|
|
|
1371
1368
|
return linear(v[i], v[i + 1 > m ? m : i + 1], f - i);
|
|
1372
1369
|
};
|
|
1373
1370
|
/** Calculates the distance between two points. */
|
|
1374
|
-
const distance = (x1, y1, x2, y2) =>
|
|
1375
|
-
const dx = x1 - x2;
|
|
1376
|
-
const dy = y1 - y2;
|
|
1377
|
-
return Math.sqrt(dx * dx + dy * dy);
|
|
1378
|
-
};
|
|
1371
|
+
const distance = (x1, y1, x2, y2) => Math.hypot(x1 - x2, y1 - y2);
|
|
1379
1372
|
/** Checks if two numbers are within a tolerance of each other. */
|
|
1380
1373
|
const within = (a, b, tolerance) => Math.abs(a - b) <= tolerance;
|
|
1381
1374
|
/** Creates a 32-bit color value from alpha, red, green, and blue components. */
|
|
@@ -1511,19 +1504,18 @@ const create$1 = (parent, width, height, skipPool = false) => {
|
|
|
1511
1504
|
if (parent === void 0) console.warn("Created CanvasPool element with undefined parent.");
|
|
1512
1505
|
const idx = getFirst();
|
|
1513
1506
|
const pool = getPool();
|
|
1514
|
-
let
|
|
1507
|
+
let entry;
|
|
1515
1508
|
if (idx === -1 || skipPool) {
|
|
1516
|
-
|
|
1509
|
+
entry = {
|
|
1517
1510
|
parent,
|
|
1518
1511
|
canvas: document.createElement("canvas")
|
|
1519
1512
|
};
|
|
1520
|
-
pool.push(
|
|
1521
|
-
canvas = container.canvas;
|
|
1513
|
+
pool.push(entry);
|
|
1522
1514
|
} else {
|
|
1523
|
-
|
|
1515
|
+
entry = pool[idx];
|
|
1524
1516
|
entry.parent = parent;
|
|
1525
|
-
canvas = entry.canvas;
|
|
1526
1517
|
}
|
|
1518
|
+
const { canvas } = entry;
|
|
1527
1519
|
if (width !== void 0) {
|
|
1528
1520
|
canvas.width = width;
|
|
1529
1521
|
canvas.height = height;
|
|
@@ -1540,7 +1532,8 @@ const create$1 = (parent, width, height, skipPool = false) => {
|
|
|
1540
1532
|
*/
|
|
1541
1533
|
const getTintedTexture = (sprite, color) => {
|
|
1542
1534
|
const canvas = sprite.tintedTexture ?? create$1("CanvasTinter", 1, 1);
|
|
1543
|
-
globalThis.PhaserRegistry.CANVAS_TINT_METHOD
|
|
1535
|
+
const tint = globalThis.PhaserRegistry.CANVAS_TINT_METHOD;
|
|
1536
|
+
tint(sprite.texture, color, canvas);
|
|
1544
1537
|
return canvas;
|
|
1545
1538
|
};
|
|
1546
1539
|
/**
|
|
@@ -1581,21 +1574,18 @@ const tintWithPerPixel = (texture, color, canvas) => {
|
|
|
1581
1574
|
canvas.height = crop.height;
|
|
1582
1575
|
context.globalCompositeOperation = "copy";
|
|
1583
1576
|
context.drawImage(texture.baseTexture.source, crop.x, crop.y, crop.width, crop.height, 0, 0, crop.width, crop.height);
|
|
1584
|
-
const
|
|
1585
|
-
const r = rgbValues[0];
|
|
1586
|
-
const g = rgbValues[1];
|
|
1587
|
-
const b = rgbValues[2];
|
|
1577
|
+
const [r, g, b] = hex2rgb(color);
|
|
1588
1578
|
const pixelData = context.getImageData(0, 0, crop.width, crop.height);
|
|
1589
1579
|
const pixels = pixelData.data;
|
|
1590
1580
|
for (let i = 0; i < pixels.length; i += 4) {
|
|
1591
|
-
pixels[i + 0]
|
|
1592
|
-
pixels[i + 1]
|
|
1593
|
-
pixels[i + 2]
|
|
1581
|
+
pixels[i + 0] *= r;
|
|
1582
|
+
pixels[i + 1] *= g;
|
|
1583
|
+
pixels[i + 2] *= b;
|
|
1594
1584
|
if (!globalThis.PhaserRegistry.CAN_CANVAS_HANDLE_ALPHA) {
|
|
1595
1585
|
const alpha = pixels[i + 3];
|
|
1596
|
-
pixels[i + 0]
|
|
1597
|
-
pixels[i + 1]
|
|
1598
|
-
pixels[i + 2]
|
|
1586
|
+
pixels[i + 0] /= 255 / alpha;
|
|
1587
|
+
pixels[i + 1] /= 255 / alpha;
|
|
1588
|
+
pixels[i + 2] /= 255 / alpha;
|
|
1599
1589
|
}
|
|
1600
1590
|
}
|
|
1601
1591
|
context.putImageData(pixelData, 0, 0);
|
|
@@ -1683,12 +1673,12 @@ const detectCapabilities = (game) => {
|
|
|
1683
1673
|
* @returns {HTMLCanvasElement} The created HTML canvas element.
|
|
1684
1674
|
*/
|
|
1685
1675
|
const create = (parent, width, height, id, skipPool) => {
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
const canvas = skipPool ? document.createElement("canvas") : create$1(parent,
|
|
1689
|
-
if (
|
|
1690
|
-
canvas.width =
|
|
1691
|
-
canvas.height =
|
|
1676
|
+
const canvasWidth = width || 256;
|
|
1677
|
+
const canvasHeight = height || 256;
|
|
1678
|
+
const canvas = skipPool ? document.createElement("canvas") : create$1(parent, canvasWidth, canvasHeight);
|
|
1679
|
+
if (id !== "") canvas.id = id;
|
|
1680
|
+
canvas.width = canvasWidth;
|
|
1681
|
+
canvas.height = canvasHeight;
|
|
1692
1682
|
canvas.style.display = "block";
|
|
1693
1683
|
return canvas;
|
|
1694
1684
|
};
|
|
@@ -1699,9 +1689,9 @@ const create = (parent, width, height, id, skipPool) => {
|
|
|
1699
1689
|
* @returns {HTMLCanvasElement} The modified canvas element.
|
|
1700
1690
|
*/
|
|
1701
1691
|
const setTouchAction = (canvas, value = "none") => {
|
|
1702
|
-
|
|
1703
|
-
canvas.style.setProperty("-ms-touch-action",
|
|
1704
|
-
canvas.style.setProperty("touch-action",
|
|
1692
|
+
const touchAction = value || "none";
|
|
1693
|
+
canvas.style.setProperty("-ms-touch-action", touchAction);
|
|
1694
|
+
canvas.style.setProperty("touch-action", touchAction);
|
|
1705
1695
|
return canvas;
|
|
1706
1696
|
};
|
|
1707
1697
|
/**
|
|
@@ -1711,13 +1701,13 @@ const setTouchAction = (canvas, value = "none") => {
|
|
|
1711
1701
|
* @returns {HTMLCanvasElement} The modified canvas element.
|
|
1712
1702
|
*/
|
|
1713
1703
|
const setUserSelect = (canvas, value = "none") => {
|
|
1714
|
-
|
|
1715
|
-
canvas.style.setProperty("-webkit-touch-callout",
|
|
1716
|
-
canvas.style.setProperty("-webkit-user-select",
|
|
1717
|
-
canvas.style.setProperty("-khtml-user-select",
|
|
1718
|
-
canvas.style.setProperty("-moz-user-select",
|
|
1719
|
-
canvas.style.setProperty("-ms-user-select",
|
|
1720
|
-
canvas.style.setProperty("user-select",
|
|
1704
|
+
const userSelect = value || "none";
|
|
1705
|
+
canvas.style.setProperty("-webkit-touch-callout", userSelect);
|
|
1706
|
+
canvas.style.setProperty("-webkit-user-select", userSelect);
|
|
1707
|
+
canvas.style.setProperty("-khtml-user-select", userSelect);
|
|
1708
|
+
canvas.style.setProperty("-moz-user-select", userSelect);
|
|
1709
|
+
canvas.style.setProperty("-ms-user-select", userSelect);
|
|
1710
|
+
canvas.style.setProperty("user-select", userSelect);
|
|
1721
1711
|
canvas.style.setProperty("-webkit-tap-highlight-color", "rgba(0, 0, 0, 0)");
|
|
1722
1712
|
return canvas;
|
|
1723
1713
|
};
|
|
@@ -1729,13 +1719,11 @@ const setUserSelect = (canvas, value = "none") => {
|
|
|
1729
1719
|
* @returns {HTMLCanvasElement} The added canvas element.
|
|
1730
1720
|
*/
|
|
1731
1721
|
const addToDOM = (canvas, parent, overflowHidden = true) => {
|
|
1732
|
-
let target;
|
|
1733
|
-
if (parent) {
|
|
1734
|
-
|
|
1735
|
-
else if (typeof parent === "object" && parent.nodeType === 1) target = parent;
|
|
1736
|
-
}
|
|
1722
|
+
let target = null;
|
|
1723
|
+
if (typeof parent === "string") target = document.querySelector(`#${CSS.escape(parent)}`);
|
|
1724
|
+
else if (parent?.nodeType === 1) target = parent;
|
|
1737
1725
|
target ??= document.body;
|
|
1738
|
-
if (overflowHidden
|
|
1726
|
+
if (overflowHidden) target.style.overflow = "hidden";
|
|
1739
1727
|
target.append(canvas);
|
|
1740
1728
|
return canvas;
|
|
1741
1729
|
};
|
|
@@ -1744,7 +1732,7 @@ const addToDOM = (canvas, parent, overflowHidden = true) => {
|
|
|
1744
1732
|
* @param {HTMLCanvasElement} canvas - The canvas element to remove.
|
|
1745
1733
|
*/
|
|
1746
1734
|
const removeFromDOM = (canvas) => {
|
|
1747
|
-
|
|
1735
|
+
canvas.remove();
|
|
1748
1736
|
};
|
|
1749
1737
|
/**
|
|
1750
1738
|
* Gets the smoothing prefix for a canvas rendering context.
|
|
@@ -1760,9 +1748,9 @@ const getSmoothingPrefix = (context) => {
|
|
|
1760
1748
|
"oI"
|
|
1761
1749
|
];
|
|
1762
1750
|
const smoothingFlags = context;
|
|
1763
|
-
for (
|
|
1764
|
-
const
|
|
1765
|
-
if (
|
|
1751
|
+
for (const vendor of VENDORS) {
|
|
1752
|
+
const flag = `${vendor}mageSmoothingEnabled`;
|
|
1753
|
+
if (smoothingFlags[flag]) return flag;
|
|
1766
1754
|
}
|
|
1767
1755
|
return null;
|
|
1768
1756
|
};
|
|
@@ -2065,9 +2053,9 @@ var DisplayObject = class {
|
|
|
2065
2053
|
/** @type {boolean} */
|
|
2066
2054
|
this.ignoreChildInput = false;
|
|
2067
2055
|
/** @type {string | null } */
|
|
2068
|
-
this.name
|
|
2056
|
+
this.name ??= null;
|
|
2069
2057
|
/** @type {object | null } */
|
|
2070
|
-
this.data
|
|
2058
|
+
this.data ??= null;
|
|
2071
2059
|
/** @type {Game } */
|
|
2072
2060
|
this.game = game;
|
|
2073
2061
|
}
|
|
@@ -2118,7 +2106,7 @@ var DisplayObject = class {
|
|
|
2118
2106
|
this.children.splice(index, 0, child);
|
|
2119
2107
|
return child;
|
|
2120
2108
|
}
|
|
2121
|
-
throw new Error(
|
|
2109
|
+
throw new Error(`addChildAt: index ${index} is out of bounds for ${this.children.length} children`);
|
|
2122
2110
|
}
|
|
2123
2111
|
/**
|
|
2124
2112
|
* Swaps the positions of two child display objects.
|
|
@@ -2261,7 +2249,7 @@ var DisplayObject = class {
|
|
|
2261
2249
|
wt.ty = tx * pt.b + ty * pt.d + pt.ty;
|
|
2262
2250
|
}
|
|
2263
2251
|
this.worldAlpha = this.alpha * p.worldAlpha;
|
|
2264
|
-
this.worldScale.setTo(this.scale.x * Math.
|
|
2252
|
+
this.worldScale.setTo(this.scale.x * Math.hypot(wt.a, wt.c), this.scale.y * Math.hypot(wt.b, wt.d));
|
|
2265
2253
|
this.worldRotation = Math.atan2(-wt.c, wt.d);
|
|
2266
2254
|
this.currentBounds = null;
|
|
2267
2255
|
if (this.transformCallback) this.transformCallback.call(this.transformCallbackContext, wt, pt);
|
|
@@ -2274,17 +2262,20 @@ var DisplayObject = class {
|
|
|
2274
2262
|
* @returns {Rectangle} The bounds rectangle of this display object.
|
|
2275
2263
|
*/
|
|
2276
2264
|
getBounds(targetCoordinateSpace) {
|
|
2277
|
-
const
|
|
2265
|
+
const candidate = targetCoordinateSpace;
|
|
2266
|
+
const isTargetCoordinateSpaceDisplayObject = Boolean(candidate?.contains);
|
|
2267
|
+
let target = this;
|
|
2278
2268
|
let isTargetCoordinateSpaceThisOrParent = true;
|
|
2279
|
-
if (
|
|
2280
|
-
|
|
2281
|
-
|
|
2269
|
+
if (isTargetCoordinateSpaceDisplayObject) {
|
|
2270
|
+
target = candidate;
|
|
2271
|
+
isTargetCoordinateSpaceThisOrParent = target.contains(this);
|
|
2272
|
+
}
|
|
2282
2273
|
let i;
|
|
2283
2274
|
let matrixCache;
|
|
2284
2275
|
if (isTargetCoordinateSpaceDisplayObject) {
|
|
2285
|
-
matrixCache =
|
|
2286
|
-
|
|
2287
|
-
for (i = 0; i <
|
|
2276
|
+
matrixCache = target.worldTransform;
|
|
2277
|
+
target.worldTransform = getIdentityMatrix();
|
|
2278
|
+
for (i = 0; i < target.children.length; i += 1) target.children[i].updateTransform();
|
|
2288
2279
|
}
|
|
2289
2280
|
let minX = Infinity;
|
|
2290
2281
|
let minY = Infinity;
|
|
@@ -2351,11 +2342,11 @@ var DisplayObject = class {
|
|
|
2351
2342
|
bounds.width = maxX - minX;
|
|
2352
2343
|
bounds.height = maxY - minY;
|
|
2353
2344
|
if (isTargetCoordinateSpaceDisplayObject) {
|
|
2354
|
-
|
|
2355
|
-
for (i = 0; i <
|
|
2345
|
+
target.worldTransform = matrixCache;
|
|
2346
|
+
for (i = 0; i < target.children.length; i += 1) target.children[i].updateTransform();
|
|
2356
2347
|
}
|
|
2357
2348
|
if (!isTargetCoordinateSpaceThisOrParent) {
|
|
2358
|
-
const targetCoordinateSpaceBounds =
|
|
2349
|
+
const targetCoordinateSpaceBounds = target.getBounds();
|
|
2359
2350
|
bounds.x -= targetCoordinateSpaceBounds.x;
|
|
2360
2351
|
bounds.y -= targetCoordinateSpaceBounds.y;
|
|
2361
2352
|
}
|
|
@@ -2486,8 +2477,7 @@ var DisplayObject = class {
|
|
|
2486
2477
|
*/
|
|
2487
2478
|
set width(value) {
|
|
2488
2479
|
const { width } = this.getLocalBounds();
|
|
2489
|
-
|
|
2490
|
-
else this.scale.x = 1;
|
|
2480
|
+
this.scale.x = width === 0 ? 1 : value / width;
|
|
2491
2481
|
this._width = value;
|
|
2492
2482
|
}
|
|
2493
2483
|
/**
|
|
@@ -2503,8 +2493,7 @@ var DisplayObject = class {
|
|
|
2503
2493
|
*/
|
|
2504
2494
|
set height(value) {
|
|
2505
2495
|
const { height } = this.getLocalBounds();
|
|
2506
|
-
|
|
2507
|
-
else this.scale.y = 1;
|
|
2496
|
+
this.scale.y = height === 0 ? 1 : value / height;
|
|
2508
2497
|
this._height = value;
|
|
2509
2498
|
}
|
|
2510
2499
|
/**
|
|
@@ -2703,10 +2692,9 @@ var SignalBinding = class {
|
|
|
2703
2692
|
*/
|
|
2704
2693
|
execute(paramsArr) {
|
|
2705
2694
|
let handlerReturn;
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
params =
|
|
2709
|
-
if (this._args) params = params.concat(this._args);
|
|
2695
|
+
if (this.active && this._listener) {
|
|
2696
|
+
let params = this.params ? [...this.params, ...paramsArr] : paramsArr;
|
|
2697
|
+
if (this._args) params = [...params, ...this._args];
|
|
2710
2698
|
handlerReturn = this._listener.apply(this.context, params);
|
|
2711
2699
|
this.callCount += 1;
|
|
2712
2700
|
if (this._isOnce) this.detach();
|
|
@@ -2752,9 +2740,9 @@ var SignalBinding = class {
|
|
|
2752
2740
|
* TBD.
|
|
2753
2741
|
*/
|
|
2754
2742
|
_destroy() {
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2743
|
+
this._signal = null;
|
|
2744
|
+
this._listener = null;
|
|
2745
|
+
this.context = null;
|
|
2758
2746
|
}
|
|
2759
2747
|
/**
|
|
2760
2748
|
* TBD.
|
|
@@ -2963,9 +2951,8 @@ var Signal = class {
|
|
|
2963
2951
|
* @returns {Function} A function that will dispatch the signal with the correct context.
|
|
2964
2952
|
*/
|
|
2965
2953
|
get boundDispatch() {
|
|
2966
|
-
const _this = this;
|
|
2967
2954
|
this._boundDispatch ??= (...rest) => {
|
|
2968
|
-
|
|
2955
|
+
this.dispatch(...rest);
|
|
2969
2956
|
};
|
|
2970
2957
|
return this._boundDispatch;
|
|
2971
2958
|
}
|
|
@@ -3025,8 +3012,7 @@ var Animation = class {
|
|
|
3025
3012
|
this._frameData = frameData;
|
|
3026
3013
|
/** @type {string} */
|
|
3027
3014
|
this.name = name;
|
|
3028
|
-
this._frames = [];
|
|
3029
|
-
this._frames = this._frames.concat(frames);
|
|
3015
|
+
this._frames = [...frames];
|
|
3030
3016
|
/** @type {number} */
|
|
3031
3017
|
this.delay = 1e3 / frameRate;
|
|
3032
3018
|
/** @type {boolean} */
|
|
@@ -3463,12 +3449,9 @@ var AnimationManager = class {
|
|
|
3463
3449
|
*/
|
|
3464
3450
|
add(name, frameList, frameRate = 60, loop = false, useNumericIndex) {
|
|
3465
3451
|
const frames = frameList ?? [];
|
|
3466
|
-
|
|
3467
|
-
if (frames && typeof frames[0] === "number") useNumericIndex = true;
|
|
3468
|
-
else useNumericIndex = false;
|
|
3469
|
-
}
|
|
3452
|
+
const numericIndex = useNumericIndex ?? typeof frames[0] === "number";
|
|
3470
3453
|
this._outputFrames = [];
|
|
3471
|
-
this._frameData.getFrameIndexes(frames,
|
|
3454
|
+
this._frameData.getFrameIndexes(frames, numericIndex, this._outputFrames);
|
|
3472
3455
|
this._anims[name] = new Animation(this.game, this.sprite, name, this._frameData, this._outputFrames, frameRate, loop);
|
|
3473
3456
|
this.currentAnim = this._anims[name];
|
|
3474
3457
|
if (this.sprite.tilingTexture) this.sprite.refreshTexture = true;
|
|
@@ -3481,12 +3464,9 @@ var AnimationManager = class {
|
|
|
3481
3464
|
* @returns {boolean} True if all frames are valid, false otherwise.
|
|
3482
3465
|
*/
|
|
3483
3466
|
validateFrames(frames, useNumericIndex = false) {
|
|
3484
|
-
for (
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
if (Number(frame) > this._frameData.total) return false;
|
|
3488
|
-
} else if (!this._frameData.checkFrameName(String(frame))) return false;
|
|
3489
|
-
}
|
|
3467
|
+
for (const frame of frames) if (useNumericIndex) {
|
|
3468
|
+
if (Number(frame) > this._frameData.total) return false;
|
|
3469
|
+
} else if (!this._frameData.checkFrameName(String(frame))) return false;
|
|
3490
3470
|
return true;
|
|
3491
3471
|
}
|
|
3492
3472
|
/**
|
|
@@ -3842,14 +3822,12 @@ var Texture = class Texture {
|
|
|
3842
3822
|
* @param {Rectangle | null | undefined} trim - The trim rectangle.
|
|
3843
3823
|
*/
|
|
3844
3824
|
constructor(baseTexture, frame = null, crop = null, trim = null) {
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
if (baseTexture instanceof Texture) baseTexture = baseTexture.baseTexture;
|
|
3850
|
-
this.baseTexture = baseTexture;
|
|
3825
|
+
this.noFrame = !frame;
|
|
3826
|
+
let textureFrame = frame ?? new Rectangle(0, 0, 1, 1);
|
|
3827
|
+
const source = baseTexture instanceof Texture ? baseTexture.baseTexture : baseTexture;
|
|
3828
|
+
this.baseTexture = source;
|
|
3851
3829
|
/** @type {Rectangle} */
|
|
3852
|
-
this.frame =
|
|
3830
|
+
this.frame = textureFrame;
|
|
3853
3831
|
/** @type {Rectangle | null | undefined} */
|
|
3854
3832
|
this.trim = trim;
|
|
3855
3833
|
/** @type {boolean} */
|
|
@@ -3868,9 +3846,9 @@ var Texture = class Texture {
|
|
|
3868
3846
|
this.height = 0;
|
|
3869
3847
|
/** @type {Rectangle} */
|
|
3870
3848
|
this.crop = crop ?? new Rectangle(0, 0, 1, 1);
|
|
3871
|
-
if (
|
|
3872
|
-
if (this.noFrame)
|
|
3873
|
-
this.setFrame(
|
|
3849
|
+
if (source.hasLoaded) {
|
|
3850
|
+
if (this.noFrame) textureFrame = new Rectangle(0, 0, source.width, source.height);
|
|
3851
|
+
this.setFrame(textureFrame);
|
|
3874
3852
|
}
|
|
3875
3853
|
}
|
|
3876
3854
|
/**
|
|
@@ -4040,25 +4018,23 @@ var Image$1 = class extends DisplayObject {
|
|
|
4040
4018
|
* @param {boolean} stopAnimation - Whether to stop the animation when changing textures.
|
|
4041
4019
|
*/
|
|
4042
4020
|
loadTexture(key, frame = 0, stopAnimation = true) {
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
} else frame = frame ?? 0;
|
|
4021
|
+
const isPendingAtlas = key === -1;
|
|
4022
|
+
const textureKey = isPendingAtlas ? frame ?? 0 : key;
|
|
4023
|
+
const textureFrame = isPendingAtlas ? 0 : frame ?? 0;
|
|
4047
4024
|
if (stopAnimation) this.animations.stop();
|
|
4048
|
-
this.key =
|
|
4025
|
+
this.key = textureKey;
|
|
4049
4026
|
this.customRender = false;
|
|
4050
4027
|
const { cache } = this.game;
|
|
4051
4028
|
const smoothed = !this.texture.baseTexture.scaleMode;
|
|
4052
4029
|
let setFrame = true;
|
|
4053
|
-
if (
|
|
4030
|
+
if (textureKey instanceof Texture) this.setTexture(textureKey);
|
|
4054
4031
|
else {
|
|
4055
|
-
const img = cache.getImage(
|
|
4032
|
+
const img = cache.getImage(textureKey ?? void 0, true);
|
|
4056
4033
|
if (img) {
|
|
4057
4034
|
this.key = img.key;
|
|
4058
4035
|
this.setTexture(new Texture(img.base));
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
setFrame = !this.animations.loadFrameData(img.frameData, frame);
|
|
4036
|
+
this.texture.baseTexture.skipRender = textureKey === "__default";
|
|
4037
|
+
setFrame = !this.animations.loadFrameData(img.frameData, textureFrame);
|
|
4062
4038
|
}
|
|
4063
4039
|
}
|
|
4064
4040
|
if (setFrame) this._frame = clone$5(this.texture.frame);
|
|
@@ -4359,11 +4335,11 @@ var BitmapText = class extends DisplayObject {
|
|
|
4359
4335
|
end = i === text.length - 1;
|
|
4360
4336
|
if (/(?:\r\n|\r|\n)/.test(text.charAt(i))) return {
|
|
4361
4337
|
width: w,
|
|
4362
|
-
text: text.
|
|
4338
|
+
text: text.slice(0, i),
|
|
4363
4339
|
end,
|
|
4364
4340
|
chars
|
|
4365
4341
|
};
|
|
4366
|
-
let charCode = text.
|
|
4342
|
+
let charCode = text.codePointAt(i) ?? 32;
|
|
4367
4343
|
let charData = data.chars[charCode];
|
|
4368
4344
|
let c = 0;
|
|
4369
4345
|
if (charData === void 0) {
|
|
@@ -4379,7 +4355,7 @@ var BitmapText = class extends DisplayObject {
|
|
|
4379
4355
|
c = (kerning + (charData.texture?.width ?? 0) + charData.xOffset) * scale;
|
|
4380
4356
|
if (maxWidth && w + c >= maxWidth && lastSpace > -1) return {
|
|
4381
4357
|
width: wrappedWidth || w,
|
|
4382
|
-
text: text.
|
|
4358
|
+
text: text.slice(0, lastSpace),
|
|
4383
4359
|
end,
|
|
4384
4360
|
chars
|
|
4385
4361
|
};
|
|
@@ -4408,8 +4384,7 @@ var BitmapText = class extends DisplayObject {
|
|
|
4408
4384
|
for (let i = 0; i < lines.length; i += 1) {
|
|
4409
4385
|
const line = lines[i];
|
|
4410
4386
|
let output = "";
|
|
4411
|
-
for (let c = 0; c < line.length; c += 1)
|
|
4412
|
-
else output = output.concat(replace);
|
|
4387
|
+
for (let c = 0; c < line.length; c += 1) output = output.concat(data.chars[line.codePointAt(c) ?? 32] ? line[c] : replace);
|
|
4413
4388
|
lines[i] = output;
|
|
4414
4389
|
}
|
|
4415
4390
|
return lines.join("\n");
|
|
@@ -4420,7 +4395,7 @@ var BitmapText = class extends DisplayObject {
|
|
|
4420
4395
|
updateText() {
|
|
4421
4396
|
const data = this._data?.font;
|
|
4422
4397
|
if (!data) return;
|
|
4423
|
-
let text = this
|
|
4398
|
+
let { text } = this;
|
|
4424
4399
|
const scale = this._fontSize / data.size;
|
|
4425
4400
|
const lines = [];
|
|
4426
4401
|
let y = 0;
|
|
@@ -4435,7 +4410,7 @@ var BitmapText = class extends DisplayObject {
|
|
|
4435
4410
|
if (line.width > this.textWidth) this.textWidth = line.width;
|
|
4436
4411
|
y += data.lineHeight * scale;
|
|
4437
4412
|
text = text.slice(line.text.length + 1);
|
|
4438
|
-
end = line
|
|
4413
|
+
({end} = line);
|
|
4439
4414
|
} while (!end);
|
|
4440
4415
|
this.textHeight = y;
|
|
4441
4416
|
let t = 0;
|
|
@@ -4446,7 +4421,7 @@ var BitmapText = class extends DisplayObject {
|
|
|
4446
4421
|
if (this._align === "right") align = this.textWidth - currentLine.width;
|
|
4447
4422
|
else if (this._align === "center") align = (this.textWidth - currentLine.width) / 2;
|
|
4448
4423
|
for (let c = 0; c < currentLine.text.length; c += 1) {
|
|
4449
|
-
let charCode = currentLine.text.
|
|
4424
|
+
let charCode = currentLine.text.codePointAt(c) ?? 32;
|
|
4450
4425
|
let charData = data.chars[charCode];
|
|
4451
4426
|
if (charData === void 0) {
|
|
4452
4427
|
charCode = 32;
|
|
@@ -4994,28 +4969,29 @@ var InputHandler = class {
|
|
|
4994
4969
|
*/
|
|
4995
4970
|
checkPixel(x, y, pointer) {
|
|
4996
4971
|
if (this.sprite.texture.baseTexture.source) {
|
|
4997
|
-
|
|
4972
|
+
let localX = x;
|
|
4973
|
+
let localY = y;
|
|
4974
|
+
if (localX === null || localY === null) {
|
|
4998
4975
|
this.game.input.getLocalPosition(this.sprite, pointer, this._tempPoint);
|
|
4999
|
-
x = this._tempPoint
|
|
5000
|
-
y = this._tempPoint.y;
|
|
4976
|
+
({x: localX, y: localY} = this._tempPoint);
|
|
5001
4977
|
}
|
|
5002
|
-
if (this.sprite.anchor.x !== 0)
|
|
5003
|
-
if (this.sprite.anchor.y !== 0)
|
|
5004
|
-
|
|
5005
|
-
|
|
4978
|
+
if (this.sprite.anchor.x !== 0) localX -= -this.sprite.texture.frame.width * this.sprite.anchor.x;
|
|
4979
|
+
if (this.sprite.anchor.y !== 0) localY -= -this.sprite.texture.frame.height * this.sprite.anchor.y;
|
|
4980
|
+
localX += this.sprite.texture.frame.x;
|
|
4981
|
+
localY += this.sprite.texture.frame.y;
|
|
5006
4982
|
if (this.sprite.texture.trim) {
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
if (
|
|
5010
|
-
this._dx =
|
|
5011
|
-
this._dy =
|
|
4983
|
+
localX -= this.sprite.texture.trim.x;
|
|
4984
|
+
localY -= this.sprite.texture.trim.y;
|
|
4985
|
+
if (localX < this.sprite.texture.crop.x || localX > this.sprite.texture.crop.right || localY < this.sprite.texture.crop.y || localY > this.sprite.texture.crop.bottom) {
|
|
4986
|
+
this._dx = localX;
|
|
4987
|
+
this._dy = localY;
|
|
5012
4988
|
return false;
|
|
5013
4989
|
}
|
|
5014
4990
|
}
|
|
5015
|
-
this._dx =
|
|
5016
|
-
this._dy =
|
|
4991
|
+
this._dx = localX;
|
|
4992
|
+
this._dy = localY;
|
|
5017
4993
|
this.game.input.hitContext.clearRect(0, 0, 1, 1);
|
|
5018
|
-
this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source,
|
|
4994
|
+
this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source, localX, localY, 1, 1, 0, 0, 1, 1);
|
|
5019
4995
|
if (this.game.input.hitContext.getImageData(0, 0, 1, 1).data[3] >= this.pixelPerfectAlpha) return true;
|
|
5020
4996
|
}
|
|
5021
4997
|
return false;
|
|
@@ -5128,9 +5104,7 @@ var InputHandler = class {
|
|
|
5128
5104
|
*/
|
|
5129
5105
|
dragTimeElapsed(pointer) {
|
|
5130
5106
|
this._dragTimePass = true;
|
|
5131
|
-
if (this._pendingDrag && this.sprite)
|
|
5132
|
-
if (this._dragDistancePass) this.startDrag(pointer);
|
|
5133
|
-
}
|
|
5107
|
+
if (this._pendingDrag && this.sprite && this._dragDistancePass) this.startDrag(pointer);
|
|
5134
5108
|
}
|
|
5135
5109
|
/**
|
|
5136
5110
|
* TBD.
|
|
@@ -6069,13 +6043,13 @@ var Polygon = class {
|
|
|
6069
6043
|
* @returns {number[]} An array of numbers representing the polygon's points.
|
|
6070
6044
|
*/
|
|
6071
6045
|
toNumberArray(output = []) {
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
output.push(
|
|
6046
|
+
const points = this._points;
|
|
6047
|
+
for (let i = 0; i < points.length; i += 1) {
|
|
6048
|
+
const point = points[i];
|
|
6049
|
+
if (typeof point === "number") {
|
|
6050
|
+
output.push(point, points[i + 1]);
|
|
6051
|
+
i += 1;
|
|
6052
|
+
} else if (point) output.push(point.x, point.y);
|
|
6079
6053
|
}
|
|
6080
6054
|
return output;
|
|
6081
6055
|
}
|
|
@@ -6103,19 +6077,22 @@ var Polygon = class {
|
|
|
6103
6077
|
*/
|
|
6104
6078
|
contains(x, y) {
|
|
6105
6079
|
let inside = false;
|
|
6106
|
-
if (this.flattened)
|
|
6107
|
-
const
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
const
|
|
6117
|
-
|
|
6118
|
-
|
|
6080
|
+
if (this.flattened) {
|
|
6081
|
+
const points = this._points;
|
|
6082
|
+
for (let i = -2, j = points.length - 2; (i += 2) < points.length; j = i) {
|
|
6083
|
+
const ix = points[i];
|
|
6084
|
+
const iy = points[i + 1];
|
|
6085
|
+
const jx = points[j];
|
|
6086
|
+
const jy = points[j + 1];
|
|
6087
|
+
if ((iy <= y && y < jy || jy <= y && y < iy) && x < (jx - ix) * (y - iy) / (jy - iy) + ix) inside = !inside;
|
|
6088
|
+
}
|
|
6089
|
+
} else {
|
|
6090
|
+
const points = this._points;
|
|
6091
|
+
for (let i = 0, j = points.length - 1; i < points.length; j = i, i += 1) {
|
|
6092
|
+
const { x: ix, y: iy } = points[i];
|
|
6093
|
+
const { x: jx, y: jy } = points[j];
|
|
6094
|
+
if ((iy <= y && y < jy || jy <= y && y < iy) && x < (jx - ix) * (y - iy) / (jy - iy) + ix) inside = !inside;
|
|
6095
|
+
}
|
|
6119
6096
|
}
|
|
6120
6097
|
return inside;
|
|
6121
6098
|
}
|
|
@@ -6126,18 +6103,20 @@ var Polygon = class {
|
|
|
6126
6103
|
*/
|
|
6127
6104
|
setTo(points) {
|
|
6128
6105
|
this.area = 0;
|
|
6129
|
-
|
|
6106
|
+
const vertices = [];
|
|
6107
|
+
this._points = vertices;
|
|
6130
6108
|
if (points) {
|
|
6131
6109
|
if (!Array.isArray(points)) console.error("[Polygon] setTo() error, input parameter is not an array", points);
|
|
6132
6110
|
let y0 = Number.MAX_VALUE;
|
|
6133
6111
|
for (let i = 0, len = points.length; i < len; i += 1) {
|
|
6112
|
+
const vertex = points[i];
|
|
6134
6113
|
let p;
|
|
6135
|
-
if (typeof
|
|
6136
|
-
p = new Point(
|
|
6114
|
+
if (typeof vertex === "number") {
|
|
6115
|
+
p = new Point(vertex, points[i + 1]);
|
|
6137
6116
|
i += 1;
|
|
6138
|
-
} else if (Array.isArray(
|
|
6139
|
-
else p = new Point(
|
|
6140
|
-
|
|
6117
|
+
} else if (Array.isArray(vertex)) p = new Point(vertex[0], vertex[1]);
|
|
6118
|
+
else p = new Point(vertex.x, vertex.y);
|
|
6119
|
+
vertices.push(p);
|
|
6141
6120
|
if (p.y < y0) y0 = p.y;
|
|
6142
6121
|
}
|
|
6143
6122
|
this.calculateArea(y0);
|
|
@@ -6150,16 +6129,12 @@ var Polygon = class {
|
|
|
6150
6129
|
* @returns {number} The area of this polygon.
|
|
6151
6130
|
*/
|
|
6152
6131
|
calculateArea(y0) {
|
|
6153
|
-
|
|
6154
|
-
let
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
if (i === len - 1) p2 = this._points[0];
|
|
6160
|
-
else p2 = this._points[i + 1];
|
|
6161
|
-
avgHeight = (p1.y - y0 + (p2.y - y0)) / 2;
|
|
6162
|
-
width = p1.x - p2.x;
|
|
6132
|
+
const points = this._points;
|
|
6133
|
+
for (let i = 0, len = points.length; i < len; i += 1) {
|
|
6134
|
+
const p1 = points[i];
|
|
6135
|
+
const p2 = i === len - 1 ? points[0] : points[i + 1];
|
|
6136
|
+
const avgHeight = (p1.y - y0 + (p2.y - y0)) / 2;
|
|
6137
|
+
const width = p1.x - p2.x;
|
|
6163
6138
|
this.area += avgHeight * width;
|
|
6164
6139
|
}
|
|
6165
6140
|
return this.area;
|
|
@@ -6175,11 +6150,10 @@ var Polygon = class {
|
|
|
6175
6150
|
* Sets the points of this polygon.
|
|
6176
6151
|
*/
|
|
6177
6152
|
set points(value) {
|
|
6178
|
-
if (value
|
|
6179
|
-
else {
|
|
6153
|
+
if (value === null) {
|
|
6180
6154
|
this.area = 0;
|
|
6181
6155
|
this._points = [];
|
|
6182
|
-
}
|
|
6156
|
+
} else this.setTo(value);
|
|
6183
6157
|
}
|
|
6184
6158
|
};
|
|
6185
6159
|
//#endregion
|
|
@@ -6232,9 +6206,7 @@ var RoundedRectangle = class {
|
|
|
6232
6206
|
*/
|
|
6233
6207
|
contains(x, y) {
|
|
6234
6208
|
if (this.width <= 0 || this.height <= 0) return false;
|
|
6235
|
-
if (x >= this.x && x <= this.x + this.width)
|
|
6236
|
-
if (y >= this.y && y <= this.y + this.height) return true;
|
|
6237
|
-
}
|
|
6209
|
+
if (x >= this.x && x <= this.x + this.width && y >= this.y && y <= this.y + this.height) return true;
|
|
6238
6210
|
return false;
|
|
6239
6211
|
}
|
|
6240
6212
|
/**
|
|
@@ -6329,7 +6301,7 @@ const renderGraphics$1 = (graphics, context) => {
|
|
|
6329
6301
|
context.lineWidth = data.lineWidth;
|
|
6330
6302
|
if (shape instanceof Polygon) {
|
|
6331
6303
|
context.beginPath();
|
|
6332
|
-
const
|
|
6304
|
+
const points = shape.points;
|
|
6333
6305
|
context.moveTo(points[0], points[1]);
|
|
6334
6306
|
for (let j = 1; j < points.length / 2; j += 1) context.lineTo(points[j * 2], points[j * 2 + 1]);
|
|
6335
6307
|
if (shape.closed) context.lineTo(points[0], points[1]);
|
|
@@ -6442,7 +6414,7 @@ const renderGraphicsMask = (graphics, context) => {
|
|
|
6442
6414
|
for (let i = 0; i < len; i += 1) {
|
|
6443
6415
|
const { shape } = graphics.graphicsData[i];
|
|
6444
6416
|
if (shape instanceof Polygon) {
|
|
6445
|
-
const
|
|
6417
|
+
const points = shape.points;
|
|
6446
6418
|
context.moveTo(points[0], points[1]);
|
|
6447
6419
|
for (let j = 1; j < points.length / 2; j += 1) context.lineTo(points[j * 2], points[j * 2 + 1]);
|
|
6448
6420
|
if (points[0] === points.at(-2) && points[1] === points.at(-1)) context.closePath();
|
|
@@ -7087,8 +7059,7 @@ function earcutLinked(ear, triangles, dim, minX, minY, size, pass) {
|
|
|
7087
7059
|
let prev;
|
|
7088
7060
|
let next;
|
|
7089
7061
|
while (ear.prev !== ear.next) {
|
|
7090
|
-
prev = ear
|
|
7091
|
-
next = ear.next;
|
|
7062
|
+
({prev, next} = ear);
|
|
7092
7063
|
if (size ? isEarHashed(ear, minX, minY, size) : isEar(ear)) {
|
|
7093
7064
|
triangles.push(prev.i / dim);
|
|
7094
7065
|
triangles.push(ear.i / dim);
|
|
@@ -7117,7 +7088,7 @@ function earcutLinked(ear, triangles, dim, minX, minY, size, pass) {
|
|
|
7117
7088
|
* @returns {object} The processed earcut data structure with triangulation information.
|
|
7118
7089
|
*/
|
|
7119
7090
|
function triangulate(data, holeIndices, dim = 2) {
|
|
7120
|
-
const hasHoles = holeIndices && holeIndices.length;
|
|
7091
|
+
const hasHoles = holeIndices !== null && holeIndices.length > 0;
|
|
7121
7092
|
const outerLen = hasHoles ? holeIndices[0] * dim : data.length;
|
|
7122
7093
|
let outerNode = linkedList(data, 0, outerLen, dim, true);
|
|
7123
7094
|
const triangles = [];
|
|
@@ -7307,7 +7278,7 @@ const buildLine = (graphicsData, webGLData) => {
|
|
|
7307
7278
|
p2y = points[3];
|
|
7308
7279
|
perpx = -(p1y - p2y);
|
|
7309
7280
|
perpy = p1x - p2x;
|
|
7310
|
-
dist = Math.
|
|
7281
|
+
dist = Math.hypot(perpx, perpy);
|
|
7311
7282
|
perpx /= dist;
|
|
7312
7283
|
perpy /= dist;
|
|
7313
7284
|
perpx *= width;
|
|
@@ -7323,14 +7294,14 @@ const buildLine = (graphicsData, webGLData) => {
|
|
|
7323
7294
|
p3y = points[(i + 1) * 2 + 1];
|
|
7324
7295
|
perpx = -(p1y - p2y);
|
|
7325
7296
|
perpy = p1x - p2x;
|
|
7326
|
-
dist = Math.
|
|
7297
|
+
dist = Math.hypot(perpx, perpy);
|
|
7327
7298
|
perpx /= dist;
|
|
7328
7299
|
perpy /= dist;
|
|
7329
7300
|
perpx *= width;
|
|
7330
7301
|
perpy *= width;
|
|
7331
7302
|
perp2x = -(p2y - p3y);
|
|
7332
7303
|
perp2y = p2x - p3x;
|
|
7333
|
-
dist = Math.
|
|
7304
|
+
dist = Math.hypot(perp2x, perp2y);
|
|
7334
7305
|
perp2x /= dist;
|
|
7335
7306
|
perp2y /= dist;
|
|
7336
7307
|
perp2x *= width;
|
|
@@ -7354,7 +7325,7 @@ const buildLine = (graphicsData, webGLData) => {
|
|
|
7354
7325
|
if (pdist > 19600) {
|
|
7355
7326
|
perp3x = perpx - perp2x;
|
|
7356
7327
|
perp3y = perpy - perp2y;
|
|
7357
|
-
dist = Math.
|
|
7328
|
+
dist = Math.hypot(perp3x, perp3y);
|
|
7358
7329
|
perp3x /= dist;
|
|
7359
7330
|
perp3y /= dist;
|
|
7360
7331
|
perp3x *= width;
|
|
@@ -7379,7 +7350,7 @@ const buildLine = (graphicsData, webGLData) => {
|
|
|
7379
7350
|
p2y = points[(length - 1) * 2 + 1];
|
|
7380
7351
|
perpx = -(p1y - p2y);
|
|
7381
7352
|
perpy = p1x - p2x;
|
|
7382
|
-
dist = Math.
|
|
7353
|
+
dist = Math.hypot(perpx, perpy);
|
|
7383
7354
|
perpx /= dist;
|
|
7384
7355
|
perpy /= dist;
|
|
7385
7356
|
perpx *= width;
|
|
@@ -7490,12 +7461,14 @@ const buildRoundedRectangle = (graphicsData, webGLData) => {
|
|
|
7490
7461
|
const { width } = rrectData;
|
|
7491
7462
|
const { height } = rrectData;
|
|
7492
7463
|
const { radius } = rrectData;
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7464
|
+
const recPoints = [
|
|
7465
|
+
x,
|
|
7466
|
+
y + radius,
|
|
7467
|
+
...quadraticBezierCurve(x, y + height - radius, x, y + height, x + radius, y + height),
|
|
7468
|
+
...quadraticBezierCurve(x + width - radius, y + height, x + width, y + height, x + width, y + height - radius),
|
|
7469
|
+
...quadraticBezierCurve(x + width, y + radius, x + width, y, x + width - radius, y),
|
|
7470
|
+
...quadraticBezierCurve(x + radius, y, x, y, x, y + radius)
|
|
7471
|
+
];
|
|
7499
7472
|
if (graphicsData.fill) {
|
|
7500
7473
|
const color = hex2rgb(graphicsData.fillColor ?? 0);
|
|
7501
7474
|
const alpha = graphicsData.fillAlpha;
|
|
@@ -7536,10 +7509,7 @@ const buildCircle = (graphicsData, webGLData) => {
|
|
|
7536
7509
|
if (circleData instanceof Circle) {
|
|
7537
7510
|
width = circleData.radius;
|
|
7538
7511
|
height = circleData.radius;
|
|
7539
|
-
} else {
|
|
7540
|
-
width = circleData.width;
|
|
7541
|
-
height = circleData.height;
|
|
7542
|
-
}
|
|
7512
|
+
} else ({width, height} = circleData);
|
|
7543
7513
|
const seg = Math.PI * 2 / 40;
|
|
7544
7514
|
if (graphicsData.fill) {
|
|
7545
7515
|
const color = hex2rgb(graphicsData.fillColor ?? 0);
|
|
@@ -7660,21 +7630,17 @@ const updateGraphics = (graphics, gl) => {
|
|
|
7660
7630
|
const data = graphics.graphicsData[i];
|
|
7661
7631
|
if (data.shape instanceof Polygon) {
|
|
7662
7632
|
data.points = [...data.shape.points];
|
|
7663
|
-
if (data.shape.closed)
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
if (data.points.length < stencilBufferLimit * 2) {
|
|
7669
|
-
webGLData = switchMode(webGL, 0);
|
|
7670
|
-
if (!buildPoly(data, webGLData)) {
|
|
7671
|
-
webGLData = switchMode(webGL, 1);
|
|
7672
|
-
buildComplexPoly(data, webGLData);
|
|
7673
|
-
}
|
|
7674
|
-
} else {
|
|
7633
|
+
if (data.shape.closed && (data.points[0] !== data.points.at(-2) || data.points[1] !== data.points.at(-1))) data.points.push(data.points[0], data.points[1]);
|
|
7634
|
+
if (data.fill && data.points.length >= stencilBufferLimit) {
|
|
7635
|
+
if (data.points.length < stencilBufferLimit * 2) {
|
|
7636
|
+
webGLData = switchMode(webGL, 0);
|
|
7637
|
+
if (!buildPoly(data, webGLData)) {
|
|
7675
7638
|
webGLData = switchMode(webGL, 1);
|
|
7676
7639
|
buildComplexPoly(data, webGLData);
|
|
7677
7640
|
}
|
|
7641
|
+
} else {
|
|
7642
|
+
webGLData = switchMode(webGL, 1);
|
|
7643
|
+
buildComplexPoly(data, webGLData);
|
|
7678
7644
|
}
|
|
7679
7645
|
}
|
|
7680
7646
|
if (data.lineWidth > 0) {
|
|
@@ -7706,8 +7672,8 @@ const renderGraphics = (graphics, renderSession) => {
|
|
|
7706
7672
|
if (graphics.dirty) updateGraphics(graphics, gl);
|
|
7707
7673
|
const webGL = graphics._webGL[gl.id];
|
|
7708
7674
|
if (!webGL) return;
|
|
7709
|
-
for (
|
|
7710
|
-
webGLData =
|
|
7675
|
+
for (const data of webGL.data) {
|
|
7676
|
+
webGLData = data;
|
|
7711
7677
|
if (webGLData.mode === 1) {
|
|
7712
7678
|
renderSession.stencilManager.pushStencil(graphics, webGLData, renderSession);
|
|
7713
7679
|
gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, (webGLData.indices.length - 4) * 2);
|
|
@@ -8113,12 +8079,10 @@ var Graphics = class extends DisplayObject {
|
|
|
8113
8079
|
this.filling = true;
|
|
8114
8080
|
this.fillColor = color || 0;
|
|
8115
8081
|
this.fillAlpha = alpha ?? 1;
|
|
8116
|
-
if (this.currentPath) {
|
|
8117
|
-
|
|
8118
|
-
|
|
8119
|
-
|
|
8120
|
-
this.currentPath.fillAlpha = this.fillAlpha;
|
|
8121
|
-
}
|
|
8082
|
+
if (this.currentPath && this.currentPath.shape.points.length <= 2) {
|
|
8083
|
+
this.currentPath.fill = this.filling;
|
|
8084
|
+
this.currentPath.fillColor = this.fillColor;
|
|
8085
|
+
this.currentPath.fillAlpha = this.fillAlpha;
|
|
8122
8086
|
}
|
|
8123
8087
|
return this;
|
|
8124
8088
|
}
|
|
@@ -8186,9 +8150,7 @@ var Graphics = class extends DisplayObject {
|
|
|
8186
8150
|
* @returns {Graphics} This Graphics object for chaining.
|
|
8187
8151
|
*/
|
|
8188
8152
|
drawPolygon(path) {
|
|
8189
|
-
|
|
8190
|
-
if (path instanceof Polygon) points = path.points;
|
|
8191
|
-
else points = path;
|
|
8153
|
+
const points = path instanceof Polygon ? path.points : path;
|
|
8192
8154
|
this.drawShape(new Polygon(points));
|
|
8193
8155
|
return this;
|
|
8194
8156
|
}
|
|
@@ -8367,9 +8329,7 @@ var Graphics = class extends DisplayObject {
|
|
|
8367
8329
|
containsPoint(point, tempPoint) {
|
|
8368
8330
|
this.worldTransform.applyInverse(point, tempPoint);
|
|
8369
8331
|
const { graphicsData } = this;
|
|
8370
|
-
for (const data of graphicsData) if (data.fill && data.shape)
|
|
8371
|
-
if (data.shape.contains(tempPoint.x, tempPoint.y)) return true;
|
|
8372
|
-
}
|
|
8332
|
+
for (const data of graphicsData) if (data.fill && data.shape?.contains(tempPoint.x, tempPoint.y)) return true;
|
|
8373
8333
|
return false;
|
|
8374
8334
|
}
|
|
8375
8335
|
/**
|
|
@@ -8381,15 +8341,13 @@ var Graphics = class extends DisplayObject {
|
|
|
8381
8341
|
let minY = Infinity;
|
|
8382
8342
|
let maxY = -Infinity;
|
|
8383
8343
|
if (this.graphicsData.length > 0) {
|
|
8384
|
-
let shape;
|
|
8385
8344
|
let points;
|
|
8386
8345
|
let x;
|
|
8387
8346
|
let y;
|
|
8388
8347
|
let w;
|
|
8389
8348
|
let h;
|
|
8390
8349
|
for (const data of this.graphicsData) {
|
|
8391
|
-
const { lineWidth } = data;
|
|
8392
|
-
shape = data.shape;
|
|
8350
|
+
const { lineWidth, shape } = data;
|
|
8393
8351
|
if (shape instanceof Rectangle || shape instanceof RoundedRectangle) {
|
|
8394
8352
|
x = shape.x - lineWidth / 2;
|
|
8395
8353
|
y = shape.y - lineWidth / 2;
|
|
@@ -8400,8 +8358,7 @@ var Graphics = class extends DisplayObject {
|
|
|
8400
8358
|
minY = y < minY ? y : minY;
|
|
8401
8359
|
maxY = y + h > maxY ? y + h : maxY;
|
|
8402
8360
|
} else if (shape instanceof Circle) {
|
|
8403
|
-
x = shape
|
|
8404
|
-
y = shape.y;
|
|
8361
|
+
({x, y} = shape);
|
|
8405
8362
|
w = shape.radius + lineWidth / 2;
|
|
8406
8363
|
h = shape.radius + lineWidth / 2;
|
|
8407
8364
|
minX = x - w < minX ? x - w : minX;
|
|
@@ -8409,8 +8366,7 @@ var Graphics = class extends DisplayObject {
|
|
|
8409
8366
|
minY = y - h < minY ? y - h : minY;
|
|
8410
8367
|
maxY = y + h > maxY ? y + h : maxY;
|
|
8411
8368
|
} else if (shape instanceof Ellipse) {
|
|
8412
|
-
x = shape
|
|
8413
|
-
y = shape.y;
|
|
8369
|
+
({x, y} = shape);
|
|
8414
8370
|
w = shape.width + lineWidth / 2;
|
|
8415
8371
|
h = shape.height + lineWidth / 2;
|
|
8416
8372
|
minX = x - w < minX ? x - w : minX;
|
|
@@ -8418,13 +8374,12 @@ var Graphics = class extends DisplayObject {
|
|
|
8418
8374
|
minY = y - h < minY ? y - h : minY;
|
|
8419
8375
|
maxY = y + h > maxY ? y + h : maxY;
|
|
8420
8376
|
} else {
|
|
8421
|
-
points = shape
|
|
8377
|
+
({points} = shape);
|
|
8422
8378
|
for (let j = 0; j < points.length; j += 1) {
|
|
8423
|
-
|
|
8424
|
-
|
|
8425
|
-
|
|
8426
|
-
|
|
8427
|
-
x = points[j];
|
|
8379
|
+
const vertex = points[j];
|
|
8380
|
+
if (vertex instanceof Point) ({x, y} = vertex);
|
|
8381
|
+
else {
|
|
8382
|
+
x = vertex;
|
|
8428
8383
|
y = points[j + 1];
|
|
8429
8384
|
if (j < points.length - 1) j += 1;
|
|
8430
8385
|
}
|
|
@@ -8497,9 +8452,7 @@ var Graphics = class extends DisplayObject {
|
|
|
8497
8452
|
* @returns {GraphicsData} The graphics data for the drawn shape.
|
|
8498
8453
|
*/
|
|
8499
8454
|
drawShape(shape) {
|
|
8500
|
-
if (this.currentPath)
|
|
8501
|
-
if (this.currentPath.shape.points.length <= 2) this.graphicsData.pop();
|
|
8502
|
-
}
|
|
8455
|
+
if (this.currentPath && this.currentPath.shape.points.length <= 2) this.graphicsData.pop();
|
|
8503
8456
|
this.currentPath = null;
|
|
8504
8457
|
let target = shape;
|
|
8505
8458
|
if (target instanceof Polygon) {
|
|
@@ -9021,8 +8974,7 @@ var Text = class extends Image$1 {
|
|
|
9021
8974
|
for (let i = 0; i < drawnLines; i += 1) {
|
|
9022
8975
|
if (tabs === 0) {
|
|
9023
8976
|
lineWidth = this.style.strokeThickness + this.padding.x;
|
|
9024
|
-
|
|
9025
|
-
else lineWidth += this.context.measureText(lines[i]).width;
|
|
8977
|
+
lineWidth += this.hasCharacterStyles() ? this.measureLine(lines[i]) : this.context.measureText(lines[i]).width;
|
|
9026
8978
|
if (this.style.wordWrap) lineWidth -= this.context.measureText(" ").width;
|
|
9027
8979
|
} else {
|
|
9028
8980
|
const line = lines[i].split(/(?:\t)/);
|
|
@@ -9030,15 +8982,12 @@ var Text = class extends Image$1 {
|
|
|
9030
8982
|
if (Array.isArray(tabs)) {
|
|
9031
8983
|
let tab = 0;
|
|
9032
8984
|
for (let c = 0; c < line.length; c += 1) {
|
|
9033
|
-
|
|
9034
|
-
if (this.colors.length > 0 || this.strokeColors.length > 0 || this.fontWeights.length > 0 || this.fontStyles.length > 0) section = this.measureLine(line[c]);
|
|
9035
|
-
else section = Math.ceil(this.context.measureText(line[c]).width);
|
|
8985
|
+
const section = this.hasCharacterStyles() ? this.measureLine(line[c]) : Math.ceil(this.context.measureText(line[c]).width);
|
|
9036
8986
|
if (c > 0) tab += tabs[c - 1];
|
|
9037
8987
|
lineWidth = tab + section;
|
|
9038
8988
|
}
|
|
9039
|
-
} else for (
|
|
9040
|
-
|
|
9041
|
-
else lineWidth += Math.ceil(this.context.measureText(line[c]).width);
|
|
8989
|
+
} else for (const section of line) {
|
|
8990
|
+
lineWidth += this.hasCharacterStyles() ? this.measureLine(section) : Math.ceil(this.context.measureText(section).width);
|
|
9042
8991
|
const diff = snapToCeil(lineWidth, tabs) - lineWidth;
|
|
9043
8992
|
lineWidth += diff;
|
|
9044
8993
|
}
|
|
@@ -9078,7 +9027,7 @@ var Text = class extends Image$1 {
|
|
|
9078
9027
|
linePositionX = Math.round(linePositionX);
|
|
9079
9028
|
linePositionY = Math.round(linePositionY);
|
|
9080
9029
|
}
|
|
9081
|
-
if (this.
|
|
9030
|
+
if (this.hasCharacterStyles()) this.updateLine(lines[i], linePositionX, linePositionY);
|
|
9082
9031
|
else {
|
|
9083
9032
|
if (this.style.stroke && this.style.strokeThickness) {
|
|
9084
9033
|
this.updateShadow(this.style.shadowStroke ?? false);
|
|
@@ -9114,11 +9063,11 @@ var Text = class extends Image$1 {
|
|
|
9114
9063
|
if (fill) this.context.fillText(text[c], snap, y);
|
|
9115
9064
|
else this.context.strokeText(text[c], snap, y);
|
|
9116
9065
|
}
|
|
9117
|
-
} else for (
|
|
9118
|
-
const section = Math.ceil(this.context.measureText(
|
|
9066
|
+
} else for (const part of text) {
|
|
9067
|
+
const section = Math.ceil(this.context.measureText(part).width);
|
|
9119
9068
|
snap = snapToCeil(x, tabs);
|
|
9120
|
-
if (fill) this.context.fillText(
|
|
9121
|
-
else this.context.strokeText(
|
|
9069
|
+
if (fill) this.context.fillText(part, snap, y);
|
|
9070
|
+
else this.context.strokeText(part, snap, y);
|
|
9122
9071
|
x = snap + section;
|
|
9123
9072
|
}
|
|
9124
9073
|
}
|
|
@@ -9140,6 +9089,13 @@ var Text = class extends Image$1 {
|
|
|
9140
9089
|
}
|
|
9141
9090
|
}
|
|
9142
9091
|
/**
|
|
9092
|
+
* Reports whether any per-character style has been set, which forces the slower per-glyph path.
|
|
9093
|
+
* @returns {boolean} True when a colour, weight or style has been assigned to a character.
|
|
9094
|
+
*/
|
|
9095
|
+
hasCharacterStyles() {
|
|
9096
|
+
return this.colors.length > 0 || this.strokeColors.length > 0 || this.fontWeights.length > 0 || this.fontStyles.length > 0;
|
|
9097
|
+
}
|
|
9098
|
+
/**
|
|
9143
9099
|
* Measures the width of a line of text.
|
|
9144
9100
|
* @param {string} line - The line of text to measure.
|
|
9145
9101
|
* @returns {number} The width of the line in pixels.
|
|
@@ -10288,7 +10244,7 @@ var CanvasRenderer = class {
|
|
|
10288
10244
|
* @param {boolean} removeView - Whether to remove the view from the DOM.
|
|
10289
10245
|
*/
|
|
10290
10246
|
destroy(removeView = true) {
|
|
10291
|
-
if (removeView
|
|
10247
|
+
if (removeView) this.view.remove();
|
|
10292
10248
|
}
|
|
10293
10249
|
/**
|
|
10294
10250
|
* Resizes the canvas to the specified dimensions.
|
|
@@ -11409,8 +11365,7 @@ var WebGLSpriteBatch = class {
|
|
|
11409
11365
|
let sprite;
|
|
11410
11366
|
for (let i = 0, j = this.currentBatchSize; i < j; i += 1) {
|
|
11411
11367
|
sprite = this.sprites[i];
|
|
11412
|
-
|
|
11413
|
-
else nextTexture = sprite.texture.baseTexture;
|
|
11368
|
+
nextTexture = sprite.tilingTexture ? sprite.tilingTexture.baseTexture : sprite.texture.baseTexture;
|
|
11414
11369
|
nextBlendMode = sprite.blendMode;
|
|
11415
11370
|
nextShader = sprite.shader ?? this.defaultShader;
|
|
11416
11371
|
blendSwap = currentBlendMode !== nextBlendMode;
|
|
@@ -12083,9 +12038,9 @@ const spriteSheet = (game, key, frameWidth, frameHeight, frameMax, margin, spaci
|
|
|
12083
12038
|
* @param {object} json - TBD.
|
|
12084
12039
|
* @returns {FrameData} TBD.
|
|
12085
12040
|
*/
|
|
12086
|
-
const
|
|
12041
|
+
const jsonDataHash = (game, json, _key) => {
|
|
12087
12042
|
if (!json.frames) {
|
|
12088
|
-
game.logger.warn("
|
|
12043
|
+
game.logger.warn("jsonDataHash: Invalid Texture Atlas JSON given, missing frames object", json);
|
|
12089
12044
|
return null;
|
|
12090
12045
|
}
|
|
12091
12046
|
const data = new FrameData();
|
|
@@ -12121,8 +12076,8 @@ const finalizeBitmapFont = (baseTexture, bitmapFontData) => {
|
|
|
12121
12076
|
* @returns {object} The parsed bitmap font data.
|
|
12122
12077
|
*/
|
|
12123
12078
|
const xmlBitmapFont = (xml, baseTexture, xSpacing, ySpacing) => {
|
|
12124
|
-
const info = xml.querySelectorAll("info")
|
|
12125
|
-
const common = xml.querySelectorAll("common")
|
|
12079
|
+
const [info] = xml.querySelectorAll("info");
|
|
12080
|
+
const [common] = xml.querySelectorAll("common");
|
|
12126
12081
|
const attr = (element, name) => Math.trunc(Number(element?.getAttribute(name)));
|
|
12127
12082
|
const data = {
|
|
12128
12083
|
font: info?.getAttribute("face") ?? "",
|
|
@@ -12161,7 +12116,7 @@ const jsonBitmapFont = (json, baseTexture, xSpacing, ySpacing) => {
|
|
|
12161
12116
|
lineHeight: Math.trunc(Number(json.font.common._lineHeight)) + ySpacing,
|
|
12162
12117
|
chars: {}
|
|
12163
12118
|
};
|
|
12164
|
-
json.font.chars.char
|
|
12119
|
+
for (const letter of json.font.chars.char) {
|
|
12165
12120
|
const charCode = Math.trunc(Number(letter["_id"]));
|
|
12166
12121
|
data.chars[charCode] = {
|
|
12167
12122
|
x: Math.trunc(Number(letter["_x"])),
|
|
@@ -12173,11 +12128,11 @@ const jsonBitmapFont = (json, baseTexture, xSpacing, ySpacing) => {
|
|
|
12173
12128
|
xAdvance: Math.trunc(Number(letter["_xadvance"])) + xSpacing,
|
|
12174
12129
|
kerning: {}
|
|
12175
12130
|
};
|
|
12176
|
-
}
|
|
12177
|
-
if (json.font.kernings && json.font.kernings.kerning) json.font.kernings.kerning
|
|
12131
|
+
}
|
|
12132
|
+
if (json.font.kernings && json.font.kernings.kerning) for (const kerning of json.font.kernings.kerning) {
|
|
12178
12133
|
const char = data.chars[Math.trunc(Number(kerning["_second"]))];
|
|
12179
12134
|
if (char) char.kerning[Math.trunc(Number(kerning["_first"]))] = Math.trunc(Number(kerning["_amount"]));
|
|
12180
|
-
}
|
|
12135
|
+
}
|
|
12181
12136
|
return finalizeBitmapFont(baseTexture, data);
|
|
12182
12137
|
};
|
|
12183
12138
|
var Cache = class {
|
|
@@ -12303,7 +12258,7 @@ var Cache = class {
|
|
|
12303
12258
|
url,
|
|
12304
12259
|
data,
|
|
12305
12260
|
base: new BaseTexture(data),
|
|
12306
|
-
frameData:
|
|
12261
|
+
frameData: jsonDataHash(this.game, atlasData, key)
|
|
12307
12262
|
};
|
|
12308
12263
|
this._cache.image[key] = obj;
|
|
12309
12264
|
this._resolveURL(url, obj);
|
|
@@ -12850,60 +12805,31 @@ var Cache = class {
|
|
|
12850
12805
|
};
|
|
12851
12806
|
//#endregion
|
|
12852
12807
|
//#region src/phaser/core/device.ts
|
|
12808
|
+
/** What the current device and browser can do, as probed at boot. */
|
|
12853
12809
|
var Device = class {
|
|
12854
12810
|
desktop = false;
|
|
12855
12811
|
iOS = false;
|
|
12856
12812
|
android = false;
|
|
12857
12813
|
chromeOS = false;
|
|
12858
12814
|
linux = false;
|
|
12859
|
-
macOS;
|
|
12860
|
-
windows;
|
|
12861
|
-
windowsPhone;
|
|
12862
|
-
canvas;
|
|
12863
|
-
touch;
|
|
12864
|
-
mspointer;
|
|
12865
|
-
wheelEvent;
|
|
12866
|
-
chrome;
|
|
12867
|
-
firefox;
|
|
12868
|
-
edge;
|
|
12869
|
-
safari;
|
|
12870
|
-
fullscreen;
|
|
12871
|
-
requestFullscreen;
|
|
12872
|
-
cancelFullscreen;
|
|
12873
|
-
fullscreenKeyboard;
|
|
12874
|
-
noAudioFormat;
|
|
12875
|
-
supportedAudioFormats;
|
|
12876
|
-
supportedImageFormats;
|
|
12877
|
-
/**
|
|
12878
|
-
* Creates a new Device instance.
|
|
12879
|
-
* This class provides information about the current device and browser capabilities.
|
|
12880
|
-
*/
|
|
12881
|
-
constructor() {
|
|
12882
|
-
this.macOS = false;
|
|
12883
|
-
this.windows = false;
|
|
12884
|
-
this.windowsPhone = false;
|
|
12885
|
-
this.canvas = false;
|
|
12886
|
-
this.touch = false;
|
|
12887
|
-
this.mspointer = false;
|
|
12888
|
-
this.wheelEvent = null;
|
|
12889
|
-
this.chrome = false;
|
|
12890
|
-
this.firefox = false;
|
|
12891
|
-
this.edge = false;
|
|
12892
|
-
this.safari = false;
|
|
12893
|
-
this.fullscreen = false;
|
|
12894
|
-
this.requestFullscreen = "";
|
|
12895
|
-
this.cancelFullscreen = "";
|
|
12896
|
-
this.fullscreenKeyboard = false;
|
|
12897
|
-
this.noAudioFormat = false;
|
|
12898
|
-
/**
|
|
12899
|
-
* @type {{[key: string]: boolean}}
|
|
12900
|
-
*/
|
|
12901
|
-
this.supportedAudioFormats = {};
|
|
12902
|
-
/**
|
|
12903
|
-
* @type {{[key: string]: boolean}}
|
|
12904
|
-
*/
|
|
12905
|
-
this.supportedImageFormats = {};
|
|
12906
|
-
}
|
|
12815
|
+
macOS = false;
|
|
12816
|
+
windows = false;
|
|
12817
|
+
windowsPhone = false;
|
|
12818
|
+
canvas = false;
|
|
12819
|
+
touch = false;
|
|
12820
|
+
mspointer = false;
|
|
12821
|
+
wheelEvent = null;
|
|
12822
|
+
chrome = false;
|
|
12823
|
+
firefox = false;
|
|
12824
|
+
edge = false;
|
|
12825
|
+
safari = false;
|
|
12826
|
+
fullscreen = false;
|
|
12827
|
+
requestFullscreen = "";
|
|
12828
|
+
cancelFullscreen = "";
|
|
12829
|
+
fullscreenKeyboard = false;
|
|
12830
|
+
noAudioFormat = false;
|
|
12831
|
+
supportedAudioFormats = {};
|
|
12832
|
+
supportedImageFormats = {};
|
|
12907
12833
|
};
|
|
12908
12834
|
//#endregion
|
|
12909
12835
|
//#region src/phaser/core/device_util.ts
|
|
@@ -13178,11 +13104,7 @@ var ArraySet = class {
|
|
|
13178
13104
|
* @param {object} value - TBD.
|
|
13179
13105
|
*/
|
|
13180
13106
|
setAll(key, value) {
|
|
13181
|
-
|
|
13182
|
-
while (i) {
|
|
13183
|
-
i -= 1;
|
|
13184
|
-
if (this.list[i]) this.list[i][key] = value;
|
|
13185
|
-
}
|
|
13107
|
+
for (const item of this.list) if (item) item[key] = value;
|
|
13186
13108
|
}
|
|
13187
13109
|
/**
|
|
13188
13110
|
* TBD.
|
|
@@ -13190,10 +13112,9 @@ var ArraySet = class {
|
|
|
13190
13112
|
* @param {...any} args - TBD.
|
|
13191
13113
|
*/
|
|
13192
13114
|
callAll(key, ...args) {
|
|
13193
|
-
let i = this.list.length;
|
|
13194
|
-
|
|
13195
|
-
|
|
13196
|
-
if (this.list[i] && this.list[i][key]) this.list[i][key].apply(this.list[i], args);
|
|
13115
|
+
for (let i = this.list.length - 1; i >= 0; i -= 1) {
|
|
13116
|
+
const item = this.list[i];
|
|
13117
|
+
if (item && item[key]) item[key](...args);
|
|
13197
13118
|
}
|
|
13198
13119
|
}
|
|
13199
13120
|
/**
|
|
@@ -13303,30 +13224,29 @@ var Mouse = class {
|
|
|
13303
13224
|
start() {
|
|
13304
13225
|
if (this.game.device.android && !this.game.device.chrome) return;
|
|
13305
13226
|
if (this._onMouseDown !== null) return;
|
|
13306
|
-
const scope = this;
|
|
13307
13227
|
this._onMouseDown = (event) => {
|
|
13308
|
-
|
|
13228
|
+
this.onMouseDown(event);
|
|
13309
13229
|
};
|
|
13310
13230
|
this._onMouseMove = (event) => {
|
|
13311
|
-
|
|
13231
|
+
this.onMouseMove(event);
|
|
13312
13232
|
};
|
|
13313
13233
|
this._onMouseUp = (event) => {
|
|
13314
|
-
|
|
13234
|
+
this.onMouseUp(event);
|
|
13315
13235
|
};
|
|
13316
13236
|
this._onMouseUpGlobal = (event) => {
|
|
13317
|
-
|
|
13237
|
+
this.onMouseUpGlobal(event);
|
|
13318
13238
|
};
|
|
13319
13239
|
this._onMouseOutGlobal = (event) => {
|
|
13320
|
-
|
|
13240
|
+
this.onMouseOutGlobal(event);
|
|
13321
13241
|
};
|
|
13322
13242
|
this._onMouseOut = (event) => {
|
|
13323
|
-
|
|
13243
|
+
this.onMouseOut(event);
|
|
13324
13244
|
};
|
|
13325
13245
|
this._onMouseOver = (event) => {
|
|
13326
|
-
|
|
13246
|
+
this.onMouseOver(event);
|
|
13327
13247
|
};
|
|
13328
13248
|
this._onMouseWheel = (event) => {
|
|
13329
|
-
|
|
13249
|
+
this.onMouseWheel(event);
|
|
13330
13250
|
};
|
|
13331
13251
|
const { canvas } = this.game;
|
|
13332
13252
|
canvas.addEventListener("mousedown", this._onMouseDown, true);
|
|
@@ -13350,9 +13270,7 @@ var Mouse = class {
|
|
|
13350
13270
|
if (this._onMouseOver) canvas.removeEventListener("mouseover", this._onMouseOver, true);
|
|
13351
13271
|
if (this._onMouseOut) canvas.removeEventListener("mouseout", this._onMouseOut, true);
|
|
13352
13272
|
const { wheelEvent } = this.game.device;
|
|
13353
|
-
if (wheelEvent)
|
|
13354
|
-
if (this._onMouseWheel) canvas.removeEventListener(wheelEvent, this._onMouseWheel, true);
|
|
13355
|
-
}
|
|
13273
|
+
if (wheelEvent && this._onMouseWheel) canvas.removeEventListener(wheelEvent, this._onMouseWheel, true);
|
|
13356
13274
|
if (this._onMouseUpGlobal) globalThis.removeEventListener("mouseup", this._onMouseUpGlobal, true);
|
|
13357
13275
|
if (this._onMouseOutGlobal) globalThis.removeEventListener("mouseout", this._onMouseOutGlobal, true);
|
|
13358
13276
|
}
|
|
@@ -13455,9 +13373,7 @@ var Mouse = class {
|
|
|
13455
13373
|
* @param {MouseEvent} event - TBD.
|
|
13456
13374
|
*/
|
|
13457
13375
|
eventPreventDefault(event) {
|
|
13458
|
-
if (this.capture)
|
|
13459
|
-
if (typeof event.cancelable !== "boolean" || event.cancelable) event.preventDefault();
|
|
13460
|
-
}
|
|
13376
|
+
if (this.capture && (typeof event.cancelable !== "boolean" || event.cancelable)) event.preventDefault();
|
|
13461
13377
|
}
|
|
13462
13378
|
};
|
|
13463
13379
|
//#endregion
|
|
@@ -13506,24 +13422,23 @@ var MSPointer = class {
|
|
|
13506
13422
|
*/
|
|
13507
13423
|
start() {
|
|
13508
13424
|
if (!this.game.device.mspointer || this._onMSPointerDown !== null) return;
|
|
13509
|
-
const scope = this;
|
|
13510
13425
|
this._onMSPointerDown = (event) => {
|
|
13511
|
-
|
|
13426
|
+
this.onPointerDown(event);
|
|
13512
13427
|
};
|
|
13513
13428
|
this._onMSPointerMove = (event) => {
|
|
13514
|
-
|
|
13429
|
+
this.onPointerMove(event);
|
|
13515
13430
|
};
|
|
13516
13431
|
this._onMSPointerUp = (event) => {
|
|
13517
|
-
|
|
13432
|
+
this.onPointerUp(event);
|
|
13518
13433
|
};
|
|
13519
13434
|
this._onMSPointerUpGlobal = (event) => {
|
|
13520
|
-
|
|
13435
|
+
this.onPointerUpGlobal(event);
|
|
13521
13436
|
};
|
|
13522
13437
|
this._onMSPointerOut = (event) => {
|
|
13523
|
-
|
|
13438
|
+
this.onPointerOut(event);
|
|
13524
13439
|
};
|
|
13525
13440
|
this._onMSPointerOver = (event) => {
|
|
13526
|
-
|
|
13441
|
+
this.onPointerOver(event);
|
|
13527
13442
|
};
|
|
13528
13443
|
const { canvas } = this.game;
|
|
13529
13444
|
canvas.addEventListener("MSPointerDown", this._onMSPointerDown, false);
|
|
@@ -13650,9 +13565,7 @@ var MSPointer = class {
|
|
|
13650
13565
|
* @param {Event} event - TBD.
|
|
13651
13566
|
*/
|
|
13652
13567
|
eventPreventDefault(event) {
|
|
13653
|
-
if (this.capture)
|
|
13654
|
-
if (typeof event.cancelable !== "boolean" || event.cancelable) event.preventDefault();
|
|
13655
|
-
}
|
|
13568
|
+
if (this.capture && (typeof event.cancelable !== "boolean" || event.cancelable)) event.preventDefault();
|
|
13656
13569
|
}
|
|
13657
13570
|
};
|
|
13658
13571
|
//#endregion
|
|
@@ -13910,13 +13823,11 @@ var Pointer = class {
|
|
|
13910
13823
|
}
|
|
13911
13824
|
currentNode = this.game.input.interactiveItems.first;
|
|
13912
13825
|
while (currentNode) {
|
|
13913
|
-
if (!currentNode.checked && currentNode.validForInput(highestInputPriorityID, highestRenderOrderID, true)) {
|
|
13914
|
-
|
|
13915
|
-
|
|
13916
|
-
|
|
13917
|
-
|
|
13918
|
-
this.interactiveCandidates.push(currentNode);
|
|
13919
|
-
}
|
|
13826
|
+
if (!currentNode.checked && currentNode.validForInput(highestInputPriorityID, highestRenderOrderID, true) && (fromClick && currentNode.checkPointerDown(this, false) || !fromClick && currentNode.checkPointerOver(this, false))) {
|
|
13827
|
+
highestRenderOrderID = currentNode.sprite.renderOrderID;
|
|
13828
|
+
highestInputPriorityID = currentNode.priorityID;
|
|
13829
|
+
candidateTarget = currentNode;
|
|
13830
|
+
this.interactiveCandidates.push(currentNode);
|
|
13920
13831
|
}
|
|
13921
13832
|
currentNode = this.game.input.interactiveItems.next;
|
|
13922
13833
|
}
|
|
@@ -13995,8 +13906,8 @@ var Pointer = class {
|
|
|
13995
13906
|
* @returns {boolean} TBD.
|
|
13996
13907
|
*/
|
|
13997
13908
|
justPressed(duration) {
|
|
13998
|
-
|
|
13999
|
-
return this.isDown && this.timeDown +
|
|
13909
|
+
const window = duration || this.game.input.justPressedRate;
|
|
13910
|
+
return this.isDown && this.timeDown + window > this.game.time.time;
|
|
14000
13911
|
}
|
|
14001
13912
|
/**
|
|
14002
13913
|
* TBD.
|
|
@@ -14004,8 +13915,8 @@ var Pointer = class {
|
|
|
14004
13915
|
* @returns {boolean} TBD.
|
|
14005
13916
|
*/
|
|
14006
13917
|
justReleased(duration) {
|
|
14007
|
-
|
|
14008
|
-
return this.isUp && this.timeUp +
|
|
13918
|
+
const window = duration || this.game.input.justReleasedRate;
|
|
13919
|
+
return this.isUp && this.timeUp + window > this.game.time.time;
|
|
14009
13920
|
}
|
|
14010
13921
|
/**
|
|
14011
13922
|
* TBD.
|
|
@@ -14016,7 +13927,7 @@ var Pointer = class {
|
|
|
14016
13927
|
*/
|
|
14017
13928
|
addClickTrampoline(name, callback, callbackContext, callbackArgs) {
|
|
14018
13929
|
if (!this.isDown) return;
|
|
14019
|
-
this._clickTrampolines
|
|
13930
|
+
this._clickTrampolines ??= [];
|
|
14020
13931
|
const trampolines = this._clickTrampolines;
|
|
14021
13932
|
for (let i = 0; i < trampolines.length; i += 1) if (trampolines[i].name === name) {
|
|
14022
13933
|
trampolines.splice(i, 1);
|
|
@@ -14136,24 +14047,23 @@ var Touch = class {
|
|
|
14136
14047
|
*/
|
|
14137
14048
|
start() {
|
|
14138
14049
|
if (!this.game.device.touch || this._onTouchStart !== null) return;
|
|
14139
|
-
const scope = this;
|
|
14140
14050
|
this._onTouchStart = (event) => {
|
|
14141
|
-
|
|
14051
|
+
this.onTouchStart(event);
|
|
14142
14052
|
};
|
|
14143
14053
|
this._onTouchMove = (event) => {
|
|
14144
|
-
|
|
14054
|
+
this.onTouchMove(event);
|
|
14145
14055
|
};
|
|
14146
14056
|
this._onTouchEnd = (event) => {
|
|
14147
|
-
|
|
14057
|
+
this.onTouchEnd(event);
|
|
14148
14058
|
};
|
|
14149
14059
|
this._onTouchEnter = (event) => {
|
|
14150
|
-
|
|
14060
|
+
this.onTouchEnter(event);
|
|
14151
14061
|
};
|
|
14152
14062
|
this._onTouchLeave = (event) => {
|
|
14153
|
-
|
|
14063
|
+
this.onTouchLeave(event);
|
|
14154
14064
|
};
|
|
14155
14065
|
this._onTouchCancel = (event) => {
|
|
14156
|
-
|
|
14066
|
+
this.onTouchCancel(event);
|
|
14157
14067
|
};
|
|
14158
14068
|
this.game.canvas.addEventListener("touchstart", this._onTouchStart, false);
|
|
14159
14069
|
this.game.canvas.addEventListener("touchmove", this._onTouchMove, false);
|
|
@@ -14193,7 +14103,7 @@ var Touch = class {
|
|
|
14193
14103
|
if (this.touchStartCallback) this.touchStartCallback.call(this.callbackContext, event);
|
|
14194
14104
|
this.eventPreventDefault(event);
|
|
14195
14105
|
const changed = event.changedTouches ?? [];
|
|
14196
|
-
for (
|
|
14106
|
+
for (const touch of changed) this.game.input.startPointer(touch);
|
|
14197
14107
|
}
|
|
14198
14108
|
/**
|
|
14199
14109
|
* TBD.
|
|
@@ -14205,7 +14115,7 @@ var Touch = class {
|
|
|
14205
14115
|
if (!this.game.input.enabled || !this.enabled) return;
|
|
14206
14116
|
this.eventPreventDefault(event);
|
|
14207
14117
|
const changed = event.changedTouches ?? [];
|
|
14208
|
-
for (
|
|
14118
|
+
for (const touch of changed) this.game.input.stopPointer(touch);
|
|
14209
14119
|
}
|
|
14210
14120
|
/**
|
|
14211
14121
|
* TBD.
|
|
@@ -14235,7 +14145,7 @@ var Touch = class {
|
|
|
14235
14145
|
if (this.touchMoveCallback) this.touchMoveCallback.call(this.callbackContext, event);
|
|
14236
14146
|
this.eventPreventDefault(event);
|
|
14237
14147
|
const changed = event.changedTouches ?? [];
|
|
14238
|
-
for (
|
|
14148
|
+
for (const touch of changed) this.game.input.updatePointer(touch);
|
|
14239
14149
|
}
|
|
14240
14150
|
/**
|
|
14241
14151
|
* TBD.
|
|
@@ -14246,16 +14156,14 @@ var Touch = class {
|
|
|
14246
14156
|
if (this.touchEndCallback) this.touchEndCallback.call(this.callbackContext, event);
|
|
14247
14157
|
this.eventPreventDefault(event);
|
|
14248
14158
|
const changed = event.changedTouches ?? [];
|
|
14249
|
-
for (
|
|
14159
|
+
for (const touch of changed) this.game.input.stopPointer(touch);
|
|
14250
14160
|
}
|
|
14251
14161
|
/**
|
|
14252
14162
|
* TBD.
|
|
14253
14163
|
* @param {TouchEvent} event - TBD.
|
|
14254
14164
|
*/
|
|
14255
14165
|
eventPreventDefault(event) {
|
|
14256
|
-
if (this.preventDefault)
|
|
14257
|
-
if (typeof event.cancelable !== "boolean" || event.cancelable) event.preventDefault();
|
|
14258
|
-
}
|
|
14166
|
+
if (this.preventDefault && (typeof event.cancelable !== "boolean" || event.cancelable)) event.preventDefault();
|
|
14259
14167
|
}
|
|
14260
14168
|
};
|
|
14261
14169
|
//#endregion
|
|
@@ -14395,8 +14303,9 @@ var Input = class {
|
|
|
14395
14303
|
if (this.game.device.mspointer) this.mspointer.start();
|
|
14396
14304
|
else if (this.game.device.touch) this.touch.start();
|
|
14397
14305
|
this.mousePointer.active = true;
|
|
14398
|
-
|
|
14399
|
-
|
|
14306
|
+
this._onClickTrampoline = () => {
|
|
14307
|
+
this.onClickTrampoline();
|
|
14308
|
+
};
|
|
14400
14309
|
this.game.canvas.addEventListener("click", this._onClickTrampoline, false);
|
|
14401
14310
|
}
|
|
14402
14311
|
/**
|
|
@@ -14408,7 +14317,7 @@ var Input = class {
|
|
|
14408
14317
|
else if (this.game.device.touch) this.touch.stop();
|
|
14409
14318
|
this.moveCallbacks = [];
|
|
14410
14319
|
remove(this);
|
|
14411
|
-
this.game.canvas.removeEventListener("click", this._onClickTrampoline);
|
|
14320
|
+
if (this._onClickTrampoline) this.game.canvas.removeEventListener("click", this._onClickTrampoline);
|
|
14412
14321
|
}
|
|
14413
14322
|
/**
|
|
14414
14323
|
* TBD.
|
|
@@ -14776,8 +14685,7 @@ var Loader = class {
|
|
|
14776
14685
|
height: sprite.height,
|
|
14777
14686
|
rect: null
|
|
14778
14687
|
};
|
|
14779
|
-
|
|
14780
|
-
else this.preloadSprite.rect = new Rectangle(0, 0, sprite.width, 1);
|
|
14688
|
+
this.preloadSprite.rect = direction === 0 ? new Rectangle(0, 0, 1, sprite.height) : new Rectangle(0, 0, sprite.width, 1);
|
|
14781
14689
|
sprite.crop(this.preloadSprite.rect);
|
|
14782
14690
|
sprite.visible = true;
|
|
14783
14691
|
}
|
|
@@ -15146,9 +15054,7 @@ var Loader = class {
|
|
|
15146
15054
|
*/
|
|
15147
15055
|
removeFile(type, key) {
|
|
15148
15056
|
const asset = this.getAsset(type, key);
|
|
15149
|
-
if (asset)
|
|
15150
|
-
if (!asset.file.loaded && !asset.file.loading) this._fileList.splice(asset.index, 1);
|
|
15151
|
-
}
|
|
15057
|
+
if (asset && !asset.file.loaded && !asset.file.loading) this._fileList.splice(asset.index, 1);
|
|
15152
15058
|
}
|
|
15153
15059
|
/**
|
|
15154
15060
|
* Removes all files from the file list.
|
|
@@ -15228,9 +15134,8 @@ var Loader = class {
|
|
|
15228
15134
|
if (this._processingHead >= this._fileList.length) this.finishedLoading();
|
|
15229
15135
|
else if (this._flightQueue.length === 0) {
|
|
15230
15136
|
this.game.logger.warn("Aborting: processing queue empty, loading may have stalled");
|
|
15231
|
-
const scope = this;
|
|
15232
15137
|
setTimeout(() => {
|
|
15233
|
-
|
|
15138
|
+
this.finishedLoading(true);
|
|
15234
15139
|
}, 2e3);
|
|
15235
15140
|
}
|
|
15236
15141
|
}
|
|
@@ -15359,29 +15264,27 @@ var Loader = class {
|
|
|
15359
15264
|
*/
|
|
15360
15265
|
loadImageTag(file) {
|
|
15361
15266
|
this.log("loadImageTag", file);
|
|
15362
|
-
const scope = this;
|
|
15363
15267
|
const image = new globalThis.Image();
|
|
15364
15268
|
file.data = image;
|
|
15365
|
-
image.
|
|
15269
|
+
image.dataset["key"] = file.key;
|
|
15366
15270
|
if (typeof this.crossOrigin === "string" && this.crossOrigin) image.crossOrigin = this.crossOrigin;
|
|
15367
|
-
|
|
15368
|
-
|
|
15369
|
-
|
|
15370
|
-
|
|
15371
|
-
|
|
15271
|
+
let settled = false;
|
|
15272
|
+
image.addEventListener("load", () => {
|
|
15273
|
+
if (!settled) {
|
|
15274
|
+
settled = true;
|
|
15275
|
+
this.fileComplete(file);
|
|
15372
15276
|
}
|
|
15373
|
-
};
|
|
15374
|
-
image.
|
|
15375
|
-
if (
|
|
15376
|
-
file.numRetry =
|
|
15377
|
-
|
|
15277
|
+
}, { once: true });
|
|
15278
|
+
image.addEventListener("error", () => {
|
|
15279
|
+
if (this.isUseRetry && (!file.numRetry || file.numRetry < this.maxRetry)) setTimeout(() => {
|
|
15280
|
+
file.numRetry = file.numRetry ? file.numRetry + 1 : 1;
|
|
15281
|
+
this.loadImageTag(file);
|
|
15378
15282
|
}, 1e3);
|
|
15379
|
-
else if (
|
|
15380
|
-
|
|
15381
|
-
|
|
15382
|
-
scope.fileError(file);
|
|
15283
|
+
else if (!settled) {
|
|
15284
|
+
settled = true;
|
|
15285
|
+
this.fileError(file);
|
|
15383
15286
|
}
|
|
15384
|
-
};
|
|
15287
|
+
});
|
|
15385
15288
|
const src = this.transformUrl(file.url, file);
|
|
15386
15289
|
if (src === false) {
|
|
15387
15290
|
this.fileError(file, null, "Could not resolve the file URL");
|
|
@@ -15403,7 +15306,6 @@ var Loader = class {
|
|
|
15403
15306
|
return;
|
|
15404
15307
|
}
|
|
15405
15308
|
this.log("xhrLoad", file);
|
|
15406
|
-
const scope = this;
|
|
15407
15309
|
const xhr = new XMLHttpRequest();
|
|
15408
15310
|
xhr.open("GET", url, true);
|
|
15409
15311
|
xhr.responseType = type;
|
|
@@ -15411,41 +15313,39 @@ var Loader = class {
|
|
|
15411
15313
|
if (requestedWith !== false && requestedWith !== void 0) xhr.setRequestHeader("X-Requested-With", requestedWith);
|
|
15412
15314
|
const acceptHeader = this.headers[file.type];
|
|
15413
15315
|
if (acceptHeader) xhr.setRequestHeader("Accept", acceptHeader);
|
|
15414
|
-
|
|
15415
|
-
|
|
15316
|
+
const handleError = onerror ?? this.fileError;
|
|
15317
|
+
const retry = () => {
|
|
15318
|
+
if (!this.isUseRetry || file.numRetry && file.numRetry >= this.maxRetry) return false;
|
|
15319
|
+
setTimeout(() => {
|
|
15320
|
+
file.numRetry = file.numRetry ? file.numRetry + 1 : 1;
|
|
15321
|
+
this.xhrLoad(file, url, type, onload, handleError);
|
|
15322
|
+
}, 1e3);
|
|
15323
|
+
return true;
|
|
15324
|
+
};
|
|
15325
|
+
const reportException = (error) => {
|
|
15326
|
+
const typedError = error instanceof Error ? error : new Error(String(error));
|
|
15327
|
+
if (this.hasLoaded) this.game.logger.fatal("Loader", { error: typedError });
|
|
15328
|
+
else this.asyncComplete(file, typedError.message || "Exception");
|
|
15329
|
+
};
|
|
15330
|
+
xhr.addEventListener("load", () => {
|
|
15416
15331
|
try {
|
|
15417
15332
|
if (xhr.readyState === 4 && xhr.status >= 400 && xhr.status <= 599) {
|
|
15418
|
-
if (
|
|
15419
|
-
|
|
15420
|
-
file.numRetry = !file.numRetry ? 1 : file.numRetry += 1;
|
|
15421
|
-
scope.xhrLoad(file, url, type, onload, onerror);
|
|
15422
|
-
}, 1e3);
|
|
15423
|
-
return null;
|
|
15424
|
-
}
|
|
15425
|
-
return onerror.call(scope, file, xhr);
|
|
15333
|
+
if (!retry()) handleError.call(this, file, xhr);
|
|
15334
|
+
return;
|
|
15426
15335
|
}
|
|
15427
|
-
|
|
15336
|
+
onload.call(this, file, xhr);
|
|
15428
15337
|
} catch (error) {
|
|
15429
|
-
|
|
15430
|
-
if (!scope.hasLoaded) scope.asyncComplete(file, typedError.message || "Exception");
|
|
15431
|
-
else scope.game.logger.fatal("Loader", { error: typedError });
|
|
15338
|
+
reportException(error);
|
|
15432
15339
|
}
|
|
15433
|
-
|
|
15434
|
-
|
|
15435
|
-
|
|
15436
|
-
|
|
15437
|
-
|
|
15438
|
-
scope.xhrLoad(file, url, type, onload, onerror);
|
|
15439
|
-
}, 1e3);
|
|
15440
|
-
else try {
|
|
15441
|
-
return onerror.call(scope, file, xhr);
|
|
15340
|
+
});
|
|
15341
|
+
xhr.addEventListener("error", () => {
|
|
15342
|
+
if (retry()) return;
|
|
15343
|
+
try {
|
|
15344
|
+
handleError.call(this, file, xhr);
|
|
15442
15345
|
} catch (error) {
|
|
15443
|
-
|
|
15444
|
-
if (!scope.hasLoaded) scope.asyncComplete(file, typedError.message || "Exception");
|
|
15445
|
-
else scope.game.logger.fatal("Loader", { error: typedError });
|
|
15346
|
+
reportException(error);
|
|
15446
15347
|
}
|
|
15447
|
-
|
|
15448
|
-
};
|
|
15348
|
+
});
|
|
15449
15349
|
file.requestObject = xhr;
|
|
15450
15350
|
file.requestUrl = url;
|
|
15451
15351
|
xhr.send();
|
|
@@ -15464,8 +15364,7 @@ var Loader = class {
|
|
|
15464
15364
|
getAudioURL(urls) {
|
|
15465
15365
|
if (this.game.sound.noAudio || this.game.device.noAudioFormat) return null;
|
|
15466
15366
|
const candidates = typeof urls === "string" ? [urls] : urls;
|
|
15467
|
-
for (
|
|
15468
|
-
const candidate = candidates[i];
|
|
15367
|
+
for (const candidate of candidates) {
|
|
15469
15368
|
let url;
|
|
15470
15369
|
let audioType = null;
|
|
15471
15370
|
if (typeof candidate !== "string") {
|
|
@@ -15495,7 +15394,7 @@ var Loader = class {
|
|
|
15495
15394
|
*/
|
|
15496
15395
|
fileError(file, xhr = null, reason = 0) {
|
|
15497
15396
|
if (!reason && xhr) reason = xhr.status;
|
|
15498
|
-
const message = `Error loading asset (${reason})`;
|
|
15397
|
+
const message = `Error loading asset (${String(reason)})`;
|
|
15499
15398
|
this.asyncComplete(file, message);
|
|
15500
15399
|
}
|
|
15501
15400
|
/**
|
|
@@ -15523,7 +15422,7 @@ var Loader = class {
|
|
|
15523
15422
|
else {
|
|
15524
15423
|
loadNext = false;
|
|
15525
15424
|
if (file.format === TEXTURE_ATLAS_JSON_HASH) this.xhrLoad(file, this.transformUrl(file.atlasURL, file), "text", this.jsonLoadComplete);
|
|
15526
|
-
else throw new Error(`Invalid Texture Atlas format: ${file.format}`);
|
|
15425
|
+
else throw new Error(`Invalid Texture Atlas format: ${String(file.format)}`);
|
|
15527
15426
|
}
|
|
15528
15427
|
break;
|
|
15529
15428
|
case "bitmapfont":
|
|
@@ -15634,11 +15533,14 @@ var Loader = class {
|
|
|
15634
15533
|
/**
|
|
15635
15534
|
* Logs a message to the console if logging is enabled.
|
|
15636
15535
|
* @param {string} message - The message to log.
|
|
15637
|
-
* @param {
|
|
15536
|
+
* @param {object} file - The file the message is about.
|
|
15638
15537
|
*/
|
|
15639
|
-
log(message,
|
|
15538
|
+
log(message, file) {
|
|
15640
15539
|
if (!this.isUseLog) return;
|
|
15641
|
-
this.game.logger.info(message,
|
|
15540
|
+
this.game.logger.info(message, {
|
|
15541
|
+
key: file.key,
|
|
15542
|
+
type: file.type
|
|
15543
|
+
});
|
|
15642
15544
|
}
|
|
15643
15545
|
/**
|
|
15644
15546
|
* Gets the number of files that have been loaded.
|
|
@@ -15890,15 +15792,15 @@ var DOM = class {
|
|
|
15890
15792
|
* @returns {Point} The offset position of the element.
|
|
15891
15793
|
*/
|
|
15892
15794
|
getOffset(element, point = null) {
|
|
15893
|
-
|
|
15795
|
+
const offset = point ?? new Point();
|
|
15894
15796
|
const box = element.getBoundingClientRect();
|
|
15895
15797
|
const scrollTop = this.scrollY;
|
|
15896
15798
|
const scrollLeft = this.scrollX;
|
|
15897
15799
|
const { clientTop } = document.documentElement;
|
|
15898
15800
|
const { clientLeft } = document.documentElement;
|
|
15899
|
-
|
|
15900
|
-
|
|
15901
|
-
return
|
|
15801
|
+
offset.x = box.left + scrollLeft - clientLeft;
|
|
15802
|
+
offset.y = box.top + scrollTop - clientTop;
|
|
15803
|
+
return offset;
|
|
15902
15804
|
}
|
|
15903
15805
|
/**
|
|
15904
15806
|
* Gets the bounding rectangle of an element with optional cushion.
|
|
@@ -15944,7 +15846,8 @@ var DOM = class {
|
|
|
15944
15846
|
const LANDSCAPE = "landscape-primary";
|
|
15945
15847
|
if (primaryFallback === "screen") return screen.height > screen.width ? PORTRAIT : LANDSCAPE;
|
|
15946
15848
|
else if (primaryFallback === "viewport") return this.visualBounds.height > this.visualBounds.width ? PORTRAIT : LANDSCAPE;
|
|
15947
|
-
|
|
15849
|
+
const { orientation: legacyOrientation } = globalThis;
|
|
15850
|
+
if (primaryFallback === "window.orientation" && typeof legacyOrientation === "number") return legacyOrientation === 0 || legacyOrientation === 180 ? PORTRAIT : LANDSCAPE;
|
|
15948
15851
|
else if (globalThis.matchMedia) {
|
|
15949
15852
|
if (globalThis.matchMedia("(orientation: portrait)").matches) return PORTRAIT;
|
|
15950
15853
|
else if (globalThis.matchMedia("(orientation: landscape)").matches) return LANDSCAPE;
|
|
@@ -16136,21 +16039,20 @@ var ScaleManager = class {
|
|
|
16136
16039
|
compat.orientationFallback = "";
|
|
16137
16040
|
compat.clickTrampoline = "";
|
|
16138
16041
|
}
|
|
16139
|
-
const scope = this;
|
|
16140
16042
|
this._orientationChange = (event) => {
|
|
16141
|
-
|
|
16043
|
+
this.orientationChange(event);
|
|
16142
16044
|
};
|
|
16143
16045
|
this._windowResize = (event) => {
|
|
16144
|
-
|
|
16046
|
+
this.windowResize(event);
|
|
16145
16047
|
};
|
|
16146
16048
|
globalThis.addEventListener("orientationchange", this._orientationChange, false);
|
|
16147
16049
|
window.addEventListener("resize", this._windowResize, false);
|
|
16148
16050
|
if (this.compatibility.supportsFullScreen) {
|
|
16149
16051
|
this._fullScreenChange = (event) => {
|
|
16150
|
-
|
|
16052
|
+
this.fullScreenChange(event);
|
|
16151
16053
|
};
|
|
16152
16054
|
this._fullScreenError = (event) => {
|
|
16153
|
-
|
|
16055
|
+
this.fullScreenError(event);
|
|
16154
16056
|
};
|
|
16155
16057
|
document.addEventListener("webkitfullscreenchange", this._fullScreenChange, false);
|
|
16156
16058
|
document.addEventListener("mozfullscreenchange", this._fullScreenChange, false);
|
|
@@ -16182,8 +16084,7 @@ var ScaleManager = class {
|
|
|
16182
16084
|
else this._pendingScaleMode = config.scaleMode;
|
|
16183
16085
|
}
|
|
16184
16086
|
if (config.fullScreenScaleMode !== void 0) this.fullScreenScaleMode = config.fullScreenScaleMode;
|
|
16185
|
-
|
|
16186
|
-
else this.fullScreenTarget = document.documentElement;
|
|
16087
|
+
this.fullScreenTarget = config.fullScreenTarget ?? document.documentElement;
|
|
16187
16088
|
}
|
|
16188
16089
|
/**
|
|
16189
16090
|
* TBD.
|
|
@@ -16194,7 +16095,7 @@ var ScaleManager = class {
|
|
|
16194
16095
|
let target;
|
|
16195
16096
|
const rect = new Rectangle();
|
|
16196
16097
|
if (this.game.parent !== "") {
|
|
16197
|
-
if (typeof this.game.parent === "string") target = document.
|
|
16098
|
+
if (typeof this.game.parent === "string") target = document.querySelector(`#${CSS.escape(this.game.parent)}`);
|
|
16198
16099
|
else if (this.game.parent && this.game.parent.nodeType === 1) target = this.game.parent;
|
|
16199
16100
|
}
|
|
16200
16101
|
if (!target) {
|
|
@@ -16441,8 +16342,8 @@ var ScaleManager = class {
|
|
|
16441
16342
|
this.width = Math.min(this.width, bounds.width);
|
|
16442
16343
|
this.height = Math.min(this.height, bounds.height);
|
|
16443
16344
|
}
|
|
16444
|
-
this.width
|
|
16445
|
-
this.height
|
|
16345
|
+
this.width = Math.trunc(this.width);
|
|
16346
|
+
this.height = Math.trunc(this.height);
|
|
16446
16347
|
this.reflowCanvas();
|
|
16447
16348
|
}
|
|
16448
16349
|
/**
|
|
@@ -16588,9 +16489,7 @@ var ScaleManager = class {
|
|
|
16588
16489
|
const bounds = this.getParentBounds(this._tempBounds);
|
|
16589
16490
|
const { width } = bounds;
|
|
16590
16491
|
const { height } = bounds;
|
|
16591
|
-
|
|
16592
|
-
if (expanding) multiplier = Math.max(height / this.game.height, width / this.game.width);
|
|
16593
|
-
else multiplier = Math.min(height / this.game.height, width / this.game.width);
|
|
16492
|
+
const multiplier = expanding ? Math.max(height / this.game.height, width / this.game.width) : Math.min(height / this.game.height, width / this.game.width);
|
|
16594
16493
|
this.width = Math.round(this.game.width * multiplier);
|
|
16595
16494
|
this.height = Math.round(this.game.height * multiplier);
|
|
16596
16495
|
}
|
|
@@ -16625,9 +16524,8 @@ var ScaleManager = class {
|
|
|
16625
16524
|
startFullScreen(antialias, allowTrampoline) {
|
|
16626
16525
|
if (this.isFullScreen) return false;
|
|
16627
16526
|
if (!this.compatibility.supportsFullScreen) {
|
|
16628
|
-
const scope = this;
|
|
16629
16527
|
setTimeout(() => {
|
|
16630
|
-
|
|
16528
|
+
this.fullScreenError(new Event("fullscreenerror"));
|
|
16631
16529
|
}, 10);
|
|
16632
16530
|
return false;
|
|
16633
16531
|
}
|
|
@@ -16673,9 +16571,8 @@ var ScaleManager = class {
|
|
|
16673
16571
|
cleanupCreatedTarget() {
|
|
16674
16572
|
const fsTarget = this._createdFullScreenTarget;
|
|
16675
16573
|
if (fsTarget && fsTarget.parentNode) {
|
|
16676
|
-
|
|
16677
|
-
|
|
16678
|
-
parent.removeChild(fsTarget);
|
|
16574
|
+
fsTarget.before(this.game.canvas);
|
|
16575
|
+
fsTarget.remove();
|
|
16679
16576
|
}
|
|
16680
16577
|
this._createdFullScreenTarget = null;
|
|
16681
16578
|
}
|
|
@@ -16687,15 +16584,13 @@ var ScaleManager = class {
|
|
|
16687
16584
|
const fsTarget = this._createdFullScreenTarget ?? this.fullScreenTarget;
|
|
16688
16585
|
if (!fsTarget) return;
|
|
16689
16586
|
if (enteringFullscreen) {
|
|
16690
|
-
if (this._createdFullScreenTarget || this.fullScreenScaleMode === 0) {
|
|
16691
|
-
|
|
16692
|
-
|
|
16693
|
-
|
|
16694
|
-
|
|
16695
|
-
|
|
16696
|
-
|
|
16697
|
-
fsTarget.style.height = "100%";
|
|
16698
|
-
}
|
|
16587
|
+
if ((this._createdFullScreenTarget || this.fullScreenScaleMode === 0) && fsTarget !== this.game.canvas) {
|
|
16588
|
+
this._fullScreenRestore = {
|
|
16589
|
+
targetWidth: fsTarget.style.width,
|
|
16590
|
+
targetHeight: fsTarget.style.height
|
|
16591
|
+
};
|
|
16592
|
+
fsTarget.style.width = "100%";
|
|
16593
|
+
fsTarget.style.height = "100%";
|
|
16699
16594
|
}
|
|
16700
16595
|
} else {
|
|
16701
16596
|
if (this._fullScreenRestore) {
|
|
@@ -17323,8 +17218,7 @@ var Sound = class {
|
|
|
17323
17218
|
/**
|
|
17324
17219
|
* Handler for when the sound ends.
|
|
17325
17220
|
*/
|
|
17326
|
-
onEndedHandler() {
|
|
17327
|
-
this._sound.onended = null;
|
|
17221
|
+
onEndedHandler = () => {
|
|
17328
17222
|
this.isPlaying = false;
|
|
17329
17223
|
this.currentTime = this.durationMS;
|
|
17330
17224
|
this.stop();
|
|
@@ -17346,7 +17240,7 @@ var Sound = class {
|
|
|
17346
17240
|
this.onMarkerComplete.dispose();
|
|
17347
17241
|
this.onFadeComplete.dispose();
|
|
17348
17242
|
}
|
|
17349
|
-
}
|
|
17243
|
+
};
|
|
17350
17244
|
/**
|
|
17351
17245
|
* Updates the sound state.
|
|
17352
17246
|
*/
|
|
@@ -17445,7 +17339,7 @@ var Sound = class {
|
|
|
17445
17339
|
this._buffer = this.game.cache.getSoundData(this.key);
|
|
17446
17340
|
this._sound.buffer = this._buffer;
|
|
17447
17341
|
if (this.loop && marker === "") this._sound.loop = true;
|
|
17448
|
-
if (!this.loop && marker === "") this._sound.
|
|
17342
|
+
if (!this.loop && marker === "") this._sound.addEventListener("ended", this.onEndedHandler, { once: true });
|
|
17449
17343
|
this.totalDuration = this._sound.buffer?.duration ?? 0;
|
|
17450
17344
|
if (this.duration === 0) {
|
|
17451
17345
|
this.duration = this.totalDuration;
|
|
@@ -17499,7 +17393,7 @@ var Sound = class {
|
|
|
17499
17393
|
if (this.externalNode) this._sound.connect(this.externalNode);
|
|
17500
17394
|
else this._sound.connect(this.gainNode);
|
|
17501
17395
|
if (this.loop) this._sound.loop = true;
|
|
17502
|
-
if (!this.loop && this.currentMarker === "") this._sound.
|
|
17396
|
+
if (!this.loop && this.currentMarker === "") this._sound.addEventListener("ended", this.onEndedHandler, { once: true });
|
|
17503
17397
|
const duration = this.duration - this.pausedPosition / 1e3;
|
|
17504
17398
|
if (this._sound.start === void 0) this._sound.noteGrainOn(0, p, duration);
|
|
17505
17399
|
else this._sound.start(0, p, duration);
|
|
@@ -17599,9 +17493,9 @@ var Sound = class {
|
|
|
17599
17493
|
* Sets the muted state of the sound.
|
|
17600
17494
|
*/
|
|
17601
17495
|
set mute(value) {
|
|
17602
|
-
|
|
17603
|
-
if (
|
|
17604
|
-
if (
|
|
17496
|
+
const muted = value ?? false;
|
|
17497
|
+
if (muted === this._muted) return;
|
|
17498
|
+
if (muted) {
|
|
17605
17499
|
this._muted = true;
|
|
17606
17500
|
this._muteVolume = this._tempVolume;
|
|
17607
17501
|
this.gainNode.gain.value = 0;
|
|
@@ -17651,13 +17545,11 @@ var SoundSprite = class {
|
|
|
17651
17545
|
this.config = this.game.cache.getJSON(`${key}-audioatlas`);
|
|
17652
17546
|
this.autoplayKey = null;
|
|
17653
17547
|
this.autoplay = false;
|
|
17654
|
-
/** @type {{[key: string]: Sound}} */
|
|
17655
17548
|
this.sounds = {};
|
|
17656
|
-
for (const
|
|
17657
|
-
const marker = this.config.spritemap[k];
|
|
17549
|
+
for (const [markerKey, marker] of Object.entries(this.config.spritemap)) {
|
|
17658
17550
|
const sound = this.game.sound.add(this.key);
|
|
17659
|
-
sound.addMarker(
|
|
17660
|
-
this.sounds[
|
|
17551
|
+
sound.addMarker(markerKey, marker.start, marker.end - marker.start, void 0, marker.loop);
|
|
17552
|
+
this.sounds[markerKey] = sound;
|
|
17661
17553
|
}
|
|
17662
17554
|
if (this.config.autoplay) {
|
|
17663
17555
|
this.autoplayKey = this.config.autoplay;
|
|
@@ -17672,15 +17564,18 @@ var SoundSprite = class {
|
|
|
17672
17564
|
* @returns {Sound} TBD.
|
|
17673
17565
|
*/
|
|
17674
17566
|
play(marker, volume = 1) {
|
|
17675
|
-
return this.sounds[marker]
|
|
17567
|
+
return this.sounds[marker]?.play(marker, void 0, volume);
|
|
17676
17568
|
}
|
|
17677
17569
|
/**
|
|
17678
17570
|
* TBD.
|
|
17679
17571
|
* @param {string} marker - TBD.
|
|
17680
17572
|
*/
|
|
17681
17573
|
stop(marker) {
|
|
17682
|
-
if (
|
|
17683
|
-
|
|
17574
|
+
if (marker) {
|
|
17575
|
+
this.sounds[marker]?.stop();
|
|
17576
|
+
return;
|
|
17577
|
+
}
|
|
17578
|
+
for (const sound of Object.values(this.sounds)) sound.stop();
|
|
17684
17579
|
}
|
|
17685
17580
|
/**
|
|
17686
17581
|
* TBD.
|
|
@@ -17763,7 +17658,8 @@ var SoundManager = class {
|
|
|
17763
17658
|
}
|
|
17764
17659
|
else if (globalThis.webkitAudioContext) try {
|
|
17765
17660
|
this.game.logger.info("initWebkitAudioContext");
|
|
17766
|
-
|
|
17661
|
+
const WebkitAudioContext = globalThis.webkitAudioContext;
|
|
17662
|
+
this.context = new WebkitAudioContext();
|
|
17767
17663
|
this.type = 2;
|
|
17768
17664
|
} catch (error) {
|
|
17769
17665
|
this.context = null;
|
|
@@ -17777,8 +17673,7 @@ var SoundManager = class {
|
|
|
17777
17673
|
return;
|
|
17778
17674
|
}
|
|
17779
17675
|
this.baseLatency = this.context.baseLatency ?? 256 / (this.context.sampleRate ?? 44100);
|
|
17780
|
-
|
|
17781
|
-
else this.masterGain = this.context.createGain();
|
|
17676
|
+
this.masterGain = this.context.createGain === void 0 ? this.context.createGainNode() : this.context.createGain();
|
|
17782
17677
|
this.masterGain.gain.value = 1;
|
|
17783
17678
|
this.masterGain.connect(this.context.destination);
|
|
17784
17679
|
if (this.context.state === "suspended" || this.context.state === "interrupted") this.addUnlockHandlers();
|
|
@@ -17847,6 +17742,13 @@ var SoundManager = class {
|
|
|
17847
17742
|
* @param {Event} event - The DOM event that triggered the unlock.
|
|
17848
17743
|
*/
|
|
17849
17744
|
onUnlockEvent = (event) => {
|
|
17745
|
+
this.resumeContext(event);
|
|
17746
|
+
};
|
|
17747
|
+
/**
|
|
17748
|
+
* Resumes the audio context a user gesture has just unlocked.
|
|
17749
|
+
* @param {Event} event - The DOM event that triggered the unlock.
|
|
17750
|
+
*/
|
|
17751
|
+
async resumeContext(event) {
|
|
17850
17752
|
const initialState = this.context.state;
|
|
17851
17753
|
if (initialState !== "suspended" && initialState !== "interrupted") {
|
|
17852
17754
|
this.game.logger.info("onUnlockResumeDenied", {
|
|
@@ -17862,14 +17764,15 @@ var SoundManager = class {
|
|
|
17862
17764
|
isLocked: this.isLocked,
|
|
17863
17765
|
event
|
|
17864
17766
|
});
|
|
17865
|
-
|
|
17767
|
+
try {
|
|
17768
|
+
await this.context.resume();
|
|
17866
17769
|
this.game.logger.info("onContextResumeResult", {
|
|
17867
17770
|
initialState,
|
|
17868
17771
|
state: this.context.state,
|
|
17869
17772
|
isLocked: this.isLocked
|
|
17870
17773
|
});
|
|
17871
17774
|
this.removeUnlockHandlers();
|
|
17872
|
-
}
|
|
17775
|
+
} catch (error) {
|
|
17873
17776
|
this.game.logger.info("onContextResumeReject", {
|
|
17874
17777
|
initialState,
|
|
17875
17778
|
state: this.context.state,
|
|
@@ -17884,8 +17787,8 @@ var SoundManager = class {
|
|
|
17884
17787
|
"audio.state": this.context.state
|
|
17885
17788
|
}
|
|
17886
17789
|
});
|
|
17887
|
-
}
|
|
17888
|
-
}
|
|
17790
|
+
}
|
|
17791
|
+
}
|
|
17889
17792
|
/**
|
|
17890
17793
|
* Stops all sounds in the manager.
|
|
17891
17794
|
*/
|
|
@@ -17911,14 +17814,14 @@ var SoundManager = class {
|
|
|
17911
17814
|
* Decodes an audio file for playback.
|
|
17912
17815
|
* @param {string} key - The key of the sound to decode.
|
|
17913
17816
|
*/
|
|
17914
|
-
decode(key) {
|
|
17817
|
+
async decode(key) {
|
|
17915
17818
|
const soundData = this.game.cache.getSoundData(key);
|
|
17916
17819
|
if (!(soundData instanceof ArrayBuffer)) return;
|
|
17917
17820
|
if (this.game.cache.isSoundDecoded(key) === true) return;
|
|
17918
17821
|
this.game.cache.updateSound(key, "isDecoding", true);
|
|
17919
|
-
|
|
17920
|
-
this.game.cache.decodedSound(key,
|
|
17921
|
-
}
|
|
17822
|
+
try {
|
|
17823
|
+
this.game.cache.decodedSound(key, await this.context.decodeAudioData(soundData));
|
|
17824
|
+
} catch (error) {
|
|
17922
17825
|
const typedError = error instanceof Error ? error : new Error(String(error));
|
|
17923
17826
|
this.game.logger.fatal("SoundManager", {
|
|
17924
17827
|
error: typedError,
|
|
@@ -17928,7 +17831,7 @@ var SoundManager = class {
|
|
|
17928
17831
|
this.decode(key);
|
|
17929
17832
|
});
|
|
17930
17833
|
else if (typedError.name === "EncodingError") this._watchList.remove(key);
|
|
17931
|
-
}
|
|
17834
|
+
}
|
|
17932
17835
|
}
|
|
17933
17836
|
/**
|
|
17934
17837
|
* Sets up a callback to be called when audio files are decoded.
|
|
@@ -18160,7 +18063,7 @@ var Stage = class extends DisplayObject {
|
|
|
18160
18063
|
*/
|
|
18161
18064
|
preUpdate() {
|
|
18162
18065
|
this.currentRenderOrderID = 0;
|
|
18163
|
-
for (
|
|
18066
|
+
for (const child of this.children) child.preUpdate();
|
|
18164
18067
|
}
|
|
18165
18068
|
/**
|
|
18166
18069
|
* Updates the stage and its children.
|
|
@@ -18176,7 +18079,7 @@ var Stage = class extends DisplayObject {
|
|
|
18176
18079
|
* Post-updates the stage and its children.
|
|
18177
18080
|
*/
|
|
18178
18081
|
postUpdate() {
|
|
18179
|
-
for (
|
|
18082
|
+
for (const child of this.children) child.postUpdate();
|
|
18180
18083
|
this.updateTransform();
|
|
18181
18084
|
}
|
|
18182
18085
|
/**
|
|
@@ -18310,8 +18213,7 @@ var Timer = class {
|
|
|
18310
18213
|
create(delay, loop, repeatCount, callback, callbackContext = null, args = []) {
|
|
18311
18214
|
const roundedDelay = Math.round(delay);
|
|
18312
18215
|
let tick = roundedDelay;
|
|
18313
|
-
|
|
18314
|
-
else tick += this._now;
|
|
18216
|
+
tick += this._now === 0 ? this.game.time.time : this._now;
|
|
18315
18217
|
const event = new TimerEvent(this, roundedDelay, tick, repeatCount, loop, callback, callbackContext, args);
|
|
18316
18218
|
this.events.push(event);
|
|
18317
18219
|
this.order();
|
|
@@ -18402,7 +18304,7 @@ var Timer = class {
|
|
|
18402
18304
|
order() {
|
|
18403
18305
|
if (this.events.length > 0) {
|
|
18404
18306
|
this.events.sort(this.sortHandler);
|
|
18405
|
-
const first = this.events
|
|
18307
|
+
const [first] = this.events;
|
|
18406
18308
|
if (first) this.nextTick = first.tick;
|
|
18407
18309
|
}
|
|
18408
18310
|
}
|
|
@@ -18501,8 +18403,7 @@ var Timer = class {
|
|
|
18501
18403
|
event.tick = this._now + t;
|
|
18502
18404
|
}
|
|
18503
18405
|
const d = this.nextTick - baseTime;
|
|
18504
|
-
|
|
18505
|
-
else this.nextTick = this._now + d;
|
|
18406
|
+
this.nextTick = d < 0 ? this._now : this._now + d;
|
|
18506
18407
|
}
|
|
18507
18408
|
/**
|
|
18508
18409
|
* Resumes the timer.
|
|
@@ -18919,10 +18820,8 @@ var TweenData = class {
|
|
|
18919
18820
|
*/
|
|
18920
18821
|
start() {
|
|
18921
18822
|
this.startTime = this.game.time.time + this.delay;
|
|
18922
|
-
|
|
18923
|
-
|
|
18924
|
-
if (this.delay > 0) this.isRunning = false;
|
|
18925
|
-
else this.isRunning = true;
|
|
18823
|
+
this.dt = this.parent.reverse ? this.duration : 0;
|
|
18824
|
+
this.isRunning = this.delay <= 0;
|
|
18926
18825
|
if (this.isFrom) {
|
|
18927
18826
|
const keys = Object.keys(this.vStartCache);
|
|
18928
18827
|
for (const property of keys) {
|
|
@@ -18945,7 +18844,7 @@ var TweenData = class {
|
|
|
18945
18844
|
for (const property of keys) {
|
|
18946
18845
|
this.vStart[property] = this.parent.properties[property];
|
|
18947
18846
|
if (Array.isArray(this.vEnd[property])) {
|
|
18948
|
-
if (this.vEnd[property].length === 0) {} else if (this.percent === 0) this.vEnd[property] = [this.vStart[property]
|
|
18847
|
+
if (this.vEnd[property].length === 0) {} else if (this.percent === 0) this.vEnd[property] = [this.vStart[property], ...this.vEnd[property]];
|
|
18949
18848
|
}
|
|
18950
18849
|
if (this.vEnd[property] !== void 0) {
|
|
18951
18850
|
if (typeof this.vEnd[property] === "string") this.vEnd[property] = this.vStart[property] + Number(this.vEnd[property]);
|
|
@@ -18980,8 +18879,7 @@ var TweenData = class {
|
|
|
18980
18879
|
for (const property of keys) {
|
|
18981
18880
|
const start = this.vStart[property];
|
|
18982
18881
|
const end = this.vEnd[property];
|
|
18983
|
-
|
|
18984
|
-
else this.parent.target[property] = start + (end - start) * this.value;
|
|
18882
|
+
this.parent.target[property] = Array.isArray(end) ? this.interpolationFunction.call(this.interpolationContext, end, this.value) : start + (end - start) * this.value;
|
|
18985
18883
|
}
|
|
18986
18884
|
if (!this.parent.reverse && this.percent === 1 || this.parent.reverse && this.percent === 0) return this.repeat();
|
|
18987
18885
|
return 1;
|
|
@@ -18992,8 +18890,7 @@ var TweenData = class {
|
|
|
18992
18890
|
* @returns {object[]} An array of tween data points.
|
|
18993
18891
|
*/
|
|
18994
18892
|
generateData(frameRate) {
|
|
18995
|
-
|
|
18996
|
-
else this.dt = 0;
|
|
18893
|
+
this.dt = this.parent.reverse ? this.duration : 0;
|
|
18997
18894
|
let data = [];
|
|
18998
18895
|
let complete = false;
|
|
18999
18896
|
const fps = 1 / frameRate * 1e3;
|
|
@@ -19012,17 +18909,12 @@ var TweenData = class {
|
|
|
19012
18909
|
for (const property of keys) {
|
|
19013
18910
|
const start = this.vStart[property];
|
|
19014
18911
|
const end = this.vEnd[property];
|
|
19015
|
-
|
|
19016
|
-
else blob[property] = start + (end - start) * this.value;
|
|
18912
|
+
blob[property] = Array.isArray(end) ? this.interpolationFunction(end, this.value) : start + (end - start) * this.value;
|
|
19017
18913
|
}
|
|
19018
18914
|
data.push(blob);
|
|
19019
18915
|
if (!this.parent.reverse && this.percent === 1 || this.parent.reverse && this.percent === 0) complete = true;
|
|
19020
18916
|
} while (!complete);
|
|
19021
|
-
if (this.yoyo)
|
|
19022
|
-
const reversed = [...data];
|
|
19023
|
-
reversed.reverse();
|
|
19024
|
-
data = data.concat(reversed);
|
|
19025
|
-
}
|
|
18917
|
+
if (this.yoyo) data = [...data, ...data.toReversed()];
|
|
19026
18918
|
return data;
|
|
19027
18919
|
}
|
|
19028
18920
|
/**
|
|
@@ -19059,8 +18951,7 @@ var TweenData = class {
|
|
|
19059
18951
|
this.startTime = this.game.time.time;
|
|
19060
18952
|
if (this.yoyo && this.inReverse) this.startTime += this.yoyoDelay;
|
|
19061
18953
|
else if (!this.inReverse) this.startTime += this.repeatDelay;
|
|
19062
|
-
|
|
19063
|
-
else this.dt = 0;
|
|
18954
|
+
this.dt = this.parent.reverse ? this.duration : 0;
|
|
19064
18955
|
return 2;
|
|
19065
18956
|
}
|
|
19066
18957
|
};
|
|
@@ -19452,7 +19343,7 @@ var Tween = class {
|
|
|
19452
19343
|
}
|
|
19453
19344
|
}
|
|
19454
19345
|
for (const tweenData of this.timeline) tweenData.loadValues();
|
|
19455
|
-
for (const tweenData of this.timeline) data = data
|
|
19346
|
+
for (const tweenData of this.timeline) data = [...data, ...tweenData.generateData(frameRate)];
|
|
19456
19347
|
return data;
|
|
19457
19348
|
}
|
|
19458
19349
|
/**
|
|
@@ -19472,25 +19363,25 @@ var Tween = class {
|
|
|
19472
19363
|
* @param {number} k - TBD.
|
|
19473
19364
|
* @returns {number} TBD.
|
|
19474
19365
|
*/
|
|
19475
|
-
const
|
|
19366
|
+
const linearNone = (k) => k;
|
|
19476
19367
|
/**
|
|
19477
19368
|
* TBD.
|
|
19478
19369
|
* @param {number} k - TBD.
|
|
19479
19370
|
* @returns {number} TBD.
|
|
19480
19371
|
*/
|
|
19481
|
-
const
|
|
19372
|
+
const quadraticIn = (k) => k * k;
|
|
19482
19373
|
/**
|
|
19483
19374
|
* TBD.
|
|
19484
19375
|
* @param {number} k - TBD.
|
|
19485
19376
|
* @returns {number} TBD.
|
|
19486
19377
|
*/
|
|
19487
|
-
const
|
|
19378
|
+
const quadraticOut = (k) => k * (2 - k);
|
|
19488
19379
|
/**
|
|
19489
19380
|
* TBD.
|
|
19490
19381
|
* @param {number} k - TBD.
|
|
19491
19382
|
* @returns {number} TBD.
|
|
19492
19383
|
*/
|
|
19493
|
-
const
|
|
19384
|
+
const quadraticInOut = (k) => {
|
|
19494
19385
|
const t = k * 2;
|
|
19495
19386
|
if (t < 1) return .5 * t * t;
|
|
19496
19387
|
const u = t - 1;
|
|
@@ -19501,13 +19392,13 @@ const QuadraticInOut = (k) => {
|
|
|
19501
19392
|
* @param {number} k - TBD.
|
|
19502
19393
|
* @returns {number} TBD.
|
|
19503
19394
|
*/
|
|
19504
|
-
const
|
|
19395
|
+
const cubicIn = (k) => k * k * k;
|
|
19505
19396
|
/**
|
|
19506
19397
|
* TBD.
|
|
19507
19398
|
* @param {number} k - TBD.
|
|
19508
19399
|
* @returns {number} TBD.
|
|
19509
19400
|
*/
|
|
19510
|
-
const
|
|
19401
|
+
const cubicOut = (k) => {
|
|
19511
19402
|
const u = k - 1;
|
|
19512
19403
|
return u * u * u + 1;
|
|
19513
19404
|
};
|
|
@@ -19516,7 +19407,7 @@ const CubicOut = (k) => {
|
|
|
19516
19407
|
* @param {number} k - TBD.
|
|
19517
19408
|
* @returns {number} TBD.
|
|
19518
19409
|
*/
|
|
19519
|
-
const
|
|
19410
|
+
const cubicInOut = (k) => {
|
|
19520
19411
|
const t = k * 2;
|
|
19521
19412
|
if (t < 1) return .5 * t * t * t;
|
|
19522
19413
|
const u = t - 2;
|
|
@@ -19527,13 +19418,13 @@ const CubicInOut = (k) => {
|
|
|
19527
19418
|
* @param {number} k - TBD.
|
|
19528
19419
|
* @returns {number} TBD.
|
|
19529
19420
|
*/
|
|
19530
|
-
const
|
|
19421
|
+
const quarticIn = (k) => k * k * k * k;
|
|
19531
19422
|
/**
|
|
19532
19423
|
* TBD.
|
|
19533
19424
|
* @param {number} k - TBD.
|
|
19534
19425
|
* @returns {number} TBD.
|
|
19535
19426
|
*/
|
|
19536
|
-
const
|
|
19427
|
+
const quarticOut = (k) => {
|
|
19537
19428
|
const u = k - 1;
|
|
19538
19429
|
return 1 - u * u * u * u;
|
|
19539
19430
|
};
|
|
@@ -19542,7 +19433,7 @@ const QuarticOut = (k) => {
|
|
|
19542
19433
|
* @param {number} k - TBD.
|
|
19543
19434
|
* @returns {number} TBD.
|
|
19544
19435
|
*/
|
|
19545
|
-
const
|
|
19436
|
+
const quarticInOut = (k) => {
|
|
19546
19437
|
const t = k * 2;
|
|
19547
19438
|
if (t < 1) return .5 * t * t * t * t;
|
|
19548
19439
|
const u = t - 2;
|
|
@@ -19553,13 +19444,13 @@ const QuarticInOut = (k) => {
|
|
|
19553
19444
|
* @param {number} k - TBD.
|
|
19554
19445
|
* @returns {number} TBD.
|
|
19555
19446
|
*/
|
|
19556
|
-
const
|
|
19447
|
+
const quinticIn = (k) => k * k * k * k * k;
|
|
19557
19448
|
/**
|
|
19558
19449
|
* TBD.
|
|
19559
19450
|
* @param {number} k - TBD.
|
|
19560
19451
|
* @returns {number} TBD.
|
|
19561
19452
|
*/
|
|
19562
|
-
const
|
|
19453
|
+
const quinticOut = (k) => {
|
|
19563
19454
|
const u = k - 1;
|
|
19564
19455
|
return u * u * u * u * u + 1;
|
|
19565
19456
|
};
|
|
@@ -19568,7 +19459,7 @@ const QuinticOut = (k) => {
|
|
|
19568
19459
|
* @param {number} k - TBD.
|
|
19569
19460
|
* @returns {number} TBD.
|
|
19570
19461
|
*/
|
|
19571
|
-
const
|
|
19462
|
+
const quinticInOut = (k) => {
|
|
19572
19463
|
const t = k * 2;
|
|
19573
19464
|
if (t < 1) return .5 * t * t * t * t * t;
|
|
19574
19465
|
const u = t - 2;
|
|
@@ -19579,7 +19470,7 @@ const QuinticInOut = (k) => {
|
|
|
19579
19470
|
* @param {number} k - TBD.
|
|
19580
19471
|
* @returns {number} TBD.
|
|
19581
19472
|
*/
|
|
19582
|
-
const
|
|
19473
|
+
const sinusoidalIn = (k) => {
|
|
19583
19474
|
if (k === 0) return 0;
|
|
19584
19475
|
if (k === 1) return 1;
|
|
19585
19476
|
return 1 - Math.cos(k * Math.PI / 2);
|
|
@@ -19589,7 +19480,7 @@ const SinusoidalIn = (k) => {
|
|
|
19589
19480
|
* @param {number} k - TBD.
|
|
19590
19481
|
* @returns {number} TBD.
|
|
19591
19482
|
*/
|
|
19592
|
-
const
|
|
19483
|
+
const sinusoidalOut = (k) => {
|
|
19593
19484
|
if (k === 0) return 0;
|
|
19594
19485
|
if (k === 1) return 1;
|
|
19595
19486
|
return Math.sin(k * Math.PI / 2);
|
|
@@ -19599,7 +19490,7 @@ const SinusoidalOut = (k) => {
|
|
|
19599
19490
|
* @param {number} k - TBD.
|
|
19600
19491
|
* @returns {number} TBD.
|
|
19601
19492
|
*/
|
|
19602
|
-
const
|
|
19493
|
+
const sinusoidalInOut = (k) => {
|
|
19603
19494
|
if (k === 0) return 0;
|
|
19604
19495
|
if (k === 1) return 1;
|
|
19605
19496
|
return .5 * (1 - Math.cos(Math.PI * k));
|
|
@@ -19609,19 +19500,19 @@ const SinusoidalInOut = (k) => {
|
|
|
19609
19500
|
* @param {number} k - TBD.
|
|
19610
19501
|
* @returns {number} TBD.
|
|
19611
19502
|
*/
|
|
19612
|
-
const
|
|
19503
|
+
const exponentialIn = (k) => k === 0 ? 0 : 1024 ** (k - 1);
|
|
19613
19504
|
/**
|
|
19614
19505
|
* TBD.
|
|
19615
19506
|
* @param {number} k - TBD.
|
|
19616
19507
|
* @returns {number} TBD.
|
|
19617
19508
|
*/
|
|
19618
|
-
const
|
|
19509
|
+
const exponentialOut = (k) => k === 1 ? 1 : 1 - 2 ** (-10 * k);
|
|
19619
19510
|
/**
|
|
19620
19511
|
* TBD.
|
|
19621
19512
|
* @param {number} k - TBD.
|
|
19622
19513
|
* @returns {number} TBD.
|
|
19623
19514
|
*/
|
|
19624
|
-
const
|
|
19515
|
+
const exponentialInOut = (k) => {
|
|
19625
19516
|
if (k === 0) return 0;
|
|
19626
19517
|
if (k === 1) return 1;
|
|
19627
19518
|
const t = k * 2;
|
|
@@ -19633,13 +19524,13 @@ const ExponentialInOut = (k) => {
|
|
|
19633
19524
|
* @param {number} k - TBD.
|
|
19634
19525
|
* @returns {number} TBD.
|
|
19635
19526
|
*/
|
|
19636
|
-
const
|
|
19527
|
+
const circularIn = (k) => 1 - Math.sqrt(1 - k * k);
|
|
19637
19528
|
/**
|
|
19638
19529
|
* TBD.
|
|
19639
19530
|
* @param {number} k - TBD.
|
|
19640
19531
|
* @returns {number} TBD.
|
|
19641
19532
|
*/
|
|
19642
|
-
const
|
|
19533
|
+
const circularOut = (k) => {
|
|
19643
19534
|
const u = k - 1;
|
|
19644
19535
|
return Math.sqrt(1 - u * u);
|
|
19645
19536
|
};
|
|
@@ -19648,7 +19539,7 @@ const CircularOut = (k) => {
|
|
|
19648
19539
|
* @param {number} k - TBD.
|
|
19649
19540
|
* @returns {number} TBD.
|
|
19650
19541
|
*/
|
|
19651
|
-
const
|
|
19542
|
+
const circularInOut = (k) => {
|
|
19652
19543
|
const t = k * 2;
|
|
19653
19544
|
if (t < 1) return -.5 * (Math.sqrt(1 - t * t) - 1);
|
|
19654
19545
|
const u = t - 2;
|
|
@@ -19662,7 +19553,7 @@ const ELASTIC_PHASE = ELASTIC_PERIOD / 4;
|
|
|
19662
19553
|
* @param {number} k - TBD.
|
|
19663
19554
|
* @returns {number} TBD.
|
|
19664
19555
|
*/
|
|
19665
|
-
const
|
|
19556
|
+
const elasticIn = (k) => {
|
|
19666
19557
|
if (k === 0) return 0;
|
|
19667
19558
|
if (k === 1) return 1;
|
|
19668
19559
|
const u = k - 1;
|
|
@@ -19673,7 +19564,7 @@ const ElasticIn = (k) => {
|
|
|
19673
19564
|
* @param {number} k - TBD.
|
|
19674
19565
|
* @returns {number} TBD.
|
|
19675
19566
|
*/
|
|
19676
|
-
const
|
|
19567
|
+
const elasticOut = (k) => {
|
|
19677
19568
|
if (k === 0) return 0;
|
|
19678
19569
|
if (k === 1) return 1;
|
|
19679
19570
|
return ELASTIC_AMPLITUDE * 2 ** (-10 * k) * Math.sin((k - ELASTIC_PHASE) * (2 * Math.PI) / ELASTIC_PERIOD) + 1;
|
|
@@ -19683,7 +19574,7 @@ const ElasticOut = (k) => {
|
|
|
19683
19574
|
* @param {number} k - TBD.
|
|
19684
19575
|
* @returns {number} TBD.
|
|
19685
19576
|
*/
|
|
19686
|
-
const
|
|
19577
|
+
const elasticInOut = (k) => {
|
|
19687
19578
|
if (k === 0) return 0;
|
|
19688
19579
|
if (k === 1) return 1;
|
|
19689
19580
|
const t = k * 2;
|
|
@@ -19699,13 +19590,13 @@ const BACK_OVERSHOOT_IN_OUT = BACK_OVERSHOOT * 1.525;
|
|
|
19699
19590
|
* @param {number} k - TBD.
|
|
19700
19591
|
* @returns {number} TBD.
|
|
19701
19592
|
*/
|
|
19702
|
-
const
|
|
19593
|
+
const backIn = (k) => k * k * (2.70158 * k - BACK_OVERSHOOT);
|
|
19703
19594
|
/**
|
|
19704
19595
|
* TBD.
|
|
19705
19596
|
* @param {number} k - TBD.
|
|
19706
19597
|
* @returns {number} TBD.
|
|
19707
19598
|
*/
|
|
19708
|
-
const
|
|
19599
|
+
const backOut = (k) => {
|
|
19709
19600
|
const u = k - 1;
|
|
19710
19601
|
return u * u * (2.70158 * u + BACK_OVERSHOOT) + 1;
|
|
19711
19602
|
};
|
|
@@ -19714,7 +19605,7 @@ const BackOut = (k) => {
|
|
|
19714
19605
|
* @param {number} k - TBD.
|
|
19715
19606
|
* @returns {number} TBD.
|
|
19716
19607
|
*/
|
|
19717
|
-
const
|
|
19608
|
+
const backInOut = (k) => {
|
|
19718
19609
|
const t = k * 2;
|
|
19719
19610
|
if (t < 1) return .5 * (t * t * (3.5949095 * t - BACK_OVERSHOOT_IN_OUT));
|
|
19720
19611
|
const u = t - 2;
|
|
@@ -19725,7 +19616,7 @@ const BackInOut = (k) => {
|
|
|
19725
19616
|
* @param {number} k - TBD.
|
|
19726
19617
|
* @returns {number} TBD.
|
|
19727
19618
|
*/
|
|
19728
|
-
const
|
|
19619
|
+
const bounceOut = (k) => {
|
|
19729
19620
|
if (k < 1 / 2.75) return 7.5625 * k * k;
|
|
19730
19621
|
if (k < 2 / 2.75) {
|
|
19731
19622
|
const u = k - 1.5 / 2.75;
|
|
@@ -19743,15 +19634,15 @@ const BounceOut = (k) => {
|
|
|
19743
19634
|
* @param {number} k - TBD.
|
|
19744
19635
|
* @returns {number} TBD.
|
|
19745
19636
|
*/
|
|
19746
|
-
const
|
|
19637
|
+
const bounceIn = (k) => 1 - bounceOut(1 - k);
|
|
19747
19638
|
/**
|
|
19748
19639
|
* TBD.
|
|
19749
19640
|
* @param {number} k - TBD.
|
|
19750
19641
|
* @returns {number} TBD.
|
|
19751
19642
|
*/
|
|
19752
|
-
const
|
|
19753
|
-
if (k < .5) return
|
|
19754
|
-
return
|
|
19643
|
+
const bounceInOut = (k) => {
|
|
19644
|
+
if (k < .5) return bounceIn(k * 2) * .5;
|
|
19645
|
+
return bounceOut(k * 2 - 1) * .5 + .5;
|
|
19755
19646
|
};
|
|
19756
19647
|
//#endregion
|
|
19757
19648
|
//#region src/phaser/core/tween_manager.ts
|
|
@@ -19772,47 +19663,47 @@ var TweenManager = class {
|
|
|
19772
19663
|
this._add = [];
|
|
19773
19664
|
/** @type {{[key: string]: (k: number) => number}} */
|
|
19774
19665
|
this.easeMap = {
|
|
19775
|
-
Linear:
|
|
19776
|
-
Quad:
|
|
19777
|
-
Cubic:
|
|
19778
|
-
Quart:
|
|
19779
|
-
Quint:
|
|
19780
|
-
Sine:
|
|
19781
|
-
Expo:
|
|
19782
|
-
Circ:
|
|
19783
|
-
Elastic:
|
|
19784
|
-
Back:
|
|
19785
|
-
Bounce:
|
|
19786
|
-
"Quad.easeIn":
|
|
19787
|
-
"Cubic.easeIn":
|
|
19788
|
-
"Quart.easeIn":
|
|
19789
|
-
"Quint.easeIn":
|
|
19790
|
-
"Sine.easeIn":
|
|
19791
|
-
"Expo.easeIn":
|
|
19792
|
-
"Circ.easeIn":
|
|
19793
|
-
"Elastic.easeIn":
|
|
19794
|
-
"Back.easeIn":
|
|
19795
|
-
"Bounce.easeIn":
|
|
19796
|
-
"Quad.easeOut":
|
|
19797
|
-
"Cubic.easeOut":
|
|
19798
|
-
"Quart.easeOut":
|
|
19799
|
-
"Quint.easeOut":
|
|
19800
|
-
"Sine.easeOut":
|
|
19801
|
-
"Expo.easeOut":
|
|
19802
|
-
"Circ.easeOut":
|
|
19803
|
-
"Elastic.easeOut":
|
|
19804
|
-
"Back.easeOut":
|
|
19805
|
-
"Bounce.easeOut":
|
|
19806
|
-
"Quad.easeInOut":
|
|
19807
|
-
"Cubic.easeInOut":
|
|
19808
|
-
"Quart.easeInOut":
|
|
19809
|
-
"Quint.easeInOut":
|
|
19810
|
-
"Sine.easeInOut":
|
|
19811
|
-
"Expo.easeInOut":
|
|
19812
|
-
"Circ.easeInOut":
|
|
19813
|
-
"Elastic.easeInOut":
|
|
19814
|
-
"Back.easeInOut":
|
|
19815
|
-
"Bounce.easeInOut":
|
|
19666
|
+
Linear: linearNone,
|
|
19667
|
+
Quad: quadraticOut,
|
|
19668
|
+
Cubic: cubicOut,
|
|
19669
|
+
Quart: quarticOut,
|
|
19670
|
+
Quint: quinticOut,
|
|
19671
|
+
Sine: sinusoidalOut,
|
|
19672
|
+
Expo: exponentialOut,
|
|
19673
|
+
Circ: circularOut,
|
|
19674
|
+
Elastic: elasticOut,
|
|
19675
|
+
Back: backOut,
|
|
19676
|
+
Bounce: bounceOut,
|
|
19677
|
+
"Quad.easeIn": quadraticIn,
|
|
19678
|
+
"Cubic.easeIn": cubicIn,
|
|
19679
|
+
"Quart.easeIn": quarticIn,
|
|
19680
|
+
"Quint.easeIn": quinticIn,
|
|
19681
|
+
"Sine.easeIn": sinusoidalIn,
|
|
19682
|
+
"Expo.easeIn": exponentialIn,
|
|
19683
|
+
"Circ.easeIn": circularIn,
|
|
19684
|
+
"Elastic.easeIn": elasticIn,
|
|
19685
|
+
"Back.easeIn": backIn,
|
|
19686
|
+
"Bounce.easeIn": bounceIn,
|
|
19687
|
+
"Quad.easeOut": quadraticOut,
|
|
19688
|
+
"Cubic.easeOut": cubicOut,
|
|
19689
|
+
"Quart.easeOut": quarticOut,
|
|
19690
|
+
"Quint.easeOut": quinticOut,
|
|
19691
|
+
"Sine.easeOut": sinusoidalOut,
|
|
19692
|
+
"Expo.easeOut": exponentialOut,
|
|
19693
|
+
"Circ.easeOut": circularOut,
|
|
19694
|
+
"Elastic.easeOut": elasticOut,
|
|
19695
|
+
"Back.easeOut": backOut,
|
|
19696
|
+
"Bounce.easeOut": bounceOut,
|
|
19697
|
+
"Quad.easeInOut": quadraticInOut,
|
|
19698
|
+
"Cubic.easeInOut": cubicInOut,
|
|
19699
|
+
"Quart.easeInOut": quarticInOut,
|
|
19700
|
+
"Quint.easeInOut": quinticInOut,
|
|
19701
|
+
"Sine.easeInOut": sinusoidalInOut,
|
|
19702
|
+
"Expo.easeInOut": exponentialInOut,
|
|
19703
|
+
"Circ.easeInOut": circularInOut,
|
|
19704
|
+
"Elastic.easeInOut": elasticInOut,
|
|
19705
|
+
"Back.easeInOut": backInOut,
|
|
19706
|
+
"Bounce.easeInOut": bounceInOut
|
|
19816
19707
|
};
|
|
19817
19708
|
this.game.onPause.add(this._pauseAll, this);
|
|
19818
19709
|
this.game.onResume.add(this._resumeAll, this);
|
|
@@ -19847,8 +19738,10 @@ var TweenManager = class {
|
|
|
19847
19738
|
for (const child of group.children) this.removeFrom(child);
|
|
19848
19739
|
return;
|
|
19849
19740
|
}
|
|
19850
|
-
|
|
19851
|
-
for (const tween of
|
|
19741
|
+
const running = [...this._tweens];
|
|
19742
|
+
for (const tween of running) if (obj === tween.target) this.remove(tween);
|
|
19743
|
+
const pending = [...this._add];
|
|
19744
|
+
for (const tween of pending) if (obj === tween.target) this.remove(tween);
|
|
19852
19745
|
}
|
|
19853
19746
|
/**
|
|
19854
19747
|
* Add a tween to the manager.
|
|
@@ -19894,7 +19787,7 @@ var TweenManager = class {
|
|
|
19894
19787
|
numTweens -= 1;
|
|
19895
19788
|
}
|
|
19896
19789
|
if (addTweens > 0) {
|
|
19897
|
-
this._tweens = this._tweens
|
|
19790
|
+
this._tweens = [...this._tweens, ...this._add];
|
|
19898
19791
|
this._add.length = 0;
|
|
19899
19792
|
}
|
|
19900
19793
|
return true;
|
|
@@ -20070,8 +19963,7 @@ var Game = class {
|
|
|
20070
19963
|
createRendererCanvas() {
|
|
20071
19964
|
this.logger.info("createRendererCanvas");
|
|
20072
19965
|
if (this.canvas) removeFromDOM(this.canvas);
|
|
20073
|
-
|
|
20074
|
-
else this.canvas = create(this, this.width, this.height, this.config.canvasID, true);
|
|
19966
|
+
this.canvas = this.config.canvas ?? create(this, this.width, this.height, this.config.canvasID, true);
|
|
20075
19967
|
if (this.config.canvasStyle) {
|
|
20076
19968
|
const { canvasStyle } = this.config;
|
|
20077
19969
|
for (const property of Object.keys(canvasStyle)) this.canvas.style.setProperty(property, canvasStyle[property] ?? null);
|