@vpmedia/phaser 1.122.0 → 1.124.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 +341 -325
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation.d.ts +3 -3
- 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 +27 -2
- package/dist/phaser/core/animation_parser.d.ts.map +1 -1
- package/dist/phaser/core/array_set.d.ts +11 -11
- package/dist/phaser/core/array_set.d.ts.map +1 -1
- package/dist/phaser/core/cache.d.ts.map +1 -1
- package/dist/phaser/core/callback.d.ts.map +1 -1
- package/dist/phaser/core/dom.d.ts +125 -19
- package/dist/phaser/core/dom.d.ts.map +1 -1
- package/dist/phaser/core/factory.d.ts +3 -2
- package/dist/phaser/core/factory.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts +3 -2
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_handler.d.ts.map +1 -1
- package/dist/phaser/core/input_mouse.d.ts +5 -1
- package/dist/phaser/core/input_mouse.d.ts.map +1 -1
- package/dist/phaser/core/input_pointer.d.ts +3 -3
- package/dist/phaser/core/input_pointer.d.ts.map +1 -1
- package/dist/phaser/core/input_touch.d.ts +8 -8
- package/dist/phaser/core/input_touch.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts +11 -2
- package/dist/phaser/core/loader.d.ts.map +1 -1
- package/dist/phaser/core/loader_parser.d.ts +14 -1
- package/dist/phaser/core/loader_parser.d.ts.map +1 -1
- package/dist/phaser/core/raf.d.ts +1 -1
- package/dist/phaser/core/raf.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/sound_manager.d.ts +1 -1
- package/dist/phaser/core/sound_manager.d.ts.map +1 -1
- package/dist/phaser/core/stage.d.ts +16 -6
- package/dist/phaser/core/stage.d.ts.map +1 -1
- package/dist/phaser/core/time.d.ts.map +1 -1
- package/dist/phaser/core/timer.d.ts +1 -1
- package/dist/phaser/core/timer.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts +13 -5
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_data.d.ts +9 -7
- package/dist/phaser/core/tween_data.d.ts.map +1 -1
- package/dist/phaser/core/tween_manager.d.ts.map +1 -1
- package/dist/phaser/display/button.d.ts +6 -5
- package/dist/phaser/display/button.d.ts.map +1 -1
- package/dist/phaser/display/canvas/buffer.d.ts +1 -1
- package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/masker.d.ts +1 -1
- package/dist/phaser/display/canvas/masker.d.ts.map +1 -1
- package/dist/phaser/display/canvas/pool.d.ts +2 -2
- package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
- package/dist/phaser/display/canvas/renderer.d.ts +9 -8
- package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/dist/phaser/display/display_object.d.ts +3 -1
- package/dist/phaser/display/display_object.d.ts.map +1 -1
- package/dist/phaser/display/graphics.d.ts +1 -1
- 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 +6 -5
- package/dist/phaser/display/image.d.ts.map +1 -1
- package/dist/phaser/display/sprite_util.d.ts +3 -2
- package/dist/phaser/display/sprite_util.d.ts.map +1 -1
- package/dist/phaser/display/text.d.ts +2 -16
- package/dist/phaser/display/text.d.ts.map +1 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts +14 -8
- package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts +2 -3
- package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +11 -5
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts +6 -4
- package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts +4 -4
- package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics.d.ts +2 -2
- package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/dist/phaser/display/webgl/mask_manager.d.ts +3 -2
- package/dist/phaser/display/webgl/mask_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/render_texture.d.ts +11 -8
- package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/renderer.d.ts +8 -4
- package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/normal.d.ts +28 -3
- package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/dist/phaser/display/webgl/sprite_batch.d.ts +6 -5
- package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/stencil_manager.d.ts +3 -3
- package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture_util.d.ts +2 -2
- package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/dist/phaser/display/webgl/util.d.ts +1 -1
- package/dist/phaser/display/webgl/util.d.ts.map +1 -1
- package/dist/phaser/geom/circle.d.ts.map +1 -1
- package/dist/phaser/geom/line.d.ts +10 -1
- package/dist/phaser/geom/line.d.ts.map +1 -1
- package/dist/phaser/geom/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/util/circle.d.ts +2 -1
- package/dist/phaser/geom/util/circle.d.ts.map +1 -1
- package/dist/phaser/geom/util/point.d.ts +1 -1
- package/dist/phaser/geom/util/point.d.ts.map +1 -1
- package/dist/phaser/geom/util/rectangle.d.ts +1 -1
- package/dist/phaser/geom/util/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 +4 -4
- package/src/phaser/core/animation_manager.ts +10 -10
- package/src/phaser/core/animation_parser.ts +30 -24
- package/src/phaser/core/array_set.ts +27 -27
- package/src/phaser/core/cache.test.ts +33 -33
- package/src/phaser/core/cache.ts +3 -3
- package/src/phaser/core/callback.ts +1 -0
- package/src/phaser/core/callback_context.test.ts +8 -8
- package/src/phaser/core/dom.ts +15 -5
- package/src/phaser/core/factory.ts +9 -2
- package/src/phaser/core/frame_data.test.ts +23 -23
- package/src/phaser/core/input.ts +9 -8
- package/src/phaser/core/input_handler.test.ts +18 -18
- package/src/phaser/core/input_handler.ts +1 -1
- package/src/phaser/core/input_mouse.ts +9 -8
- package/src/phaser/core/input_pointer.test.ts +26 -26
- package/src/phaser/core/input_pointer.ts +3 -3
- package/src/phaser/core/input_touch.ts +8 -8
- package/src/phaser/core/loader.test.ts +26 -26
- package/src/phaser/core/loader.ts +25 -25
- package/src/phaser/core/loader_parser.test.ts +16 -16
- package/src/phaser/core/loader_parser.ts +16 -6
- package/src/phaser/core/raf.ts +1 -1
- package/src/phaser/core/registry.test.ts +6 -6
- package/src/phaser/core/scale_manager.ts +2 -2
- package/src/phaser/core/scene_manager.test.ts +30 -30
- package/src/phaser/core/scene_manager.ts +1 -1
- package/src/phaser/core/signal.test.ts +8 -8
- package/src/phaser/core/signal.ts +1 -1
- package/src/phaser/core/signal_dispatch.test.ts +30 -30
- package/src/phaser/core/sound.ts +20 -8
- package/src/phaser/core/sound_manager.ts +6 -6
- package/src/phaser/core/stage.ts +19 -9
- package/src/phaser/core/time.ts +1 -1
- package/src/phaser/core/timer.test.ts +47 -47
- package/src/phaser/core/timer.ts +1 -1
- package/src/phaser/core/tween.ts +28 -25
- package/src/phaser/core/tween_data.test.ts +119 -0
- package/src/phaser/core/tween_data.ts +54 -39
- package/src/phaser/core/tween_easing.test.ts +5 -5
- package/src/phaser/core/tween_manager.ts +2 -2
- package/src/phaser/display/bitmap_text.test.ts +30 -30
- package/src/phaser/display/button.ts +8 -6
- package/src/phaser/display/canvas/buffer.ts +2 -2
- package/src/phaser/display/canvas/masker.ts +1 -1
- package/src/phaser/display/canvas/pool.test.ts +20 -20
- package/src/phaser/display/canvas/pool.ts +3 -3
- package/src/phaser/display/canvas/renderer.ts +12 -11
- package/src/phaser/display/canvas/util.test.ts +31 -24
- package/src/phaser/display/canvas/util.ts +2 -2
- package/src/phaser/display/display_object.ts +3 -1
- package/src/phaser/display/graphics.test.ts +70 -20
- package/src/phaser/display/graphics.ts +38 -32
- package/src/phaser/display/group.ts +4 -4
- package/src/phaser/display/image.ts +28 -25
- package/src/phaser/display/sprite_util.ts +3 -2
- package/src/phaser/display/text.test.ts +28 -25
- package/src/phaser/display/text.ts +21 -18
- package/src/phaser/display/webgl/abstract_filter.ts +20 -10
- package/src/phaser/display/webgl/blend_manager.ts +4 -5
- package/src/phaser/display/webgl/earcut.test.ts +20 -20
- package/src/phaser/display/webgl/fast_sprite_batch.ts +21 -16
- package/src/phaser/display/webgl/filter_manager.ts +7 -4
- package/src/phaser/display/webgl/filter_texture.ts +5 -5
- package/src/phaser/display/webgl/graphics.ts +2 -2
- package/src/phaser/display/webgl/mask_manager.ts +9 -14
- package/src/phaser/display/webgl/render_texture.ts +15 -14
- package/src/phaser/display/webgl/renderer.ts +7 -6
- package/src/phaser/display/webgl/shader/normal.ts +41 -31
- package/src/phaser/display/webgl/shader/shader.test.ts +24 -24
- package/src/phaser/display/webgl/shader_manager.test.ts +18 -18
- package/src/phaser/display/webgl/sprite_batch.ts +8 -8
- package/src/phaser/display/webgl/stencil_manager.ts +4 -4
- package/src/phaser/display/webgl/texture_util.ts +2 -2
- package/src/phaser/display/webgl/util.ts +1 -1
- package/src/phaser/geom/circle.test.ts +38 -38
- package/src/phaser/geom/circle.ts +7 -7
- package/src/phaser/geom/ellipse.test.ts +12 -12
- package/src/phaser/geom/line.test.ts +15 -15
- package/src/phaser/geom/line.ts +5 -2
- package/src/phaser/geom/matrix.test.ts +31 -31
- package/src/phaser/geom/point.test.ts +31 -31
- package/src/phaser/geom/polygon.test.ts +27 -27
- package/src/phaser/geom/rectangle.test.ts +87 -87
- package/src/phaser/geom/rectangle.ts +11 -11
- package/src/phaser/geom/rounded_rectangle.test.ts +9 -9
- package/src/phaser/geom/util/circle.test.ts +5 -5
- package/src/phaser/geom/util/circle.ts +2 -1
- package/src/phaser/geom/util/ellipse.test.ts +2 -2
- package/src/phaser/geom/util/line.test.ts +2 -2
- package/src/phaser/geom/util/matrix.test.ts +4 -4
- package/src/phaser/geom/util/point.test.ts +2 -2
- package/src/phaser/geom/util/point.ts +1 -1
- package/src/phaser/geom/util/polygon.test.ts +2 -2
- package/src/phaser/geom/util/rectangle.test.ts +2 -2
- package/src/phaser/geom/util/rectangle.ts +1 -1
- package/src/phaser/geom/util/rounded_rectangle.test.ts +2 -2
- package/src/phaser/util/math.test.ts +41 -41
- package/src/phaser/util/math.ts +5 -2
package/dist/index.js
CHANGED
|
@@ -1377,8 +1377,8 @@ const getColor32 = (a, r, g, b) => a << 24 | r << 16 | g << 8 | b;
|
|
|
1377
1377
|
const getColor = (r, g, b) => r << 16 | g << 8 | b;
|
|
1378
1378
|
/** Converts a hex color string to RGB components. */
|
|
1379
1379
|
const hexToColor = (value, out) => {
|
|
1380
|
-
|
|
1381
|
-
const result = /^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(
|
|
1380
|
+
const expanded = value.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i, (_match, r, g, b) => r + r + g + g + b + b);
|
|
1381
|
+
const result = /^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(expanded);
|
|
1382
1382
|
if (result) {
|
|
1383
1383
|
out.r = Number.parseInt(result[1], 16);
|
|
1384
1384
|
out.g = Number.parseInt(result[2], 16);
|
|
@@ -1518,7 +1518,7 @@ const create$1 = (parent, width, height, skipPool = false) => {
|
|
|
1518
1518
|
const { canvas } = entry;
|
|
1519
1519
|
if (width !== void 0) {
|
|
1520
1520
|
canvas.width = width;
|
|
1521
|
-
canvas.height = height;
|
|
1521
|
+
canvas.height = height ?? 0;
|
|
1522
1522
|
}
|
|
1523
1523
|
return canvas;
|
|
1524
1524
|
};
|
|
@@ -1720,8 +1720,8 @@ const setUserSelect = (canvas, value = "none") => {
|
|
|
1720
1720
|
*/
|
|
1721
1721
|
const addToDOM = (canvas, parent, overflowHidden = true) => {
|
|
1722
1722
|
let target = null;
|
|
1723
|
-
if (typeof parent === "string") target = document.querySelector(`#${CSS.escape(parent)}`);
|
|
1724
|
-
else if (parent?.nodeType === 1) target = parent;
|
|
1723
|
+
if (typeof parent === "string" && parent !== "") target = document.querySelector(`#${CSS.escape(parent)}`);
|
|
1724
|
+
else if (typeof parent === "object" && parent?.nodeType === 1) target = parent;
|
|
1725
1725
|
target ??= document.body;
|
|
1726
1726
|
if (overflowHidden) target.style.overflow = "hidden";
|
|
1727
1727
|
target.append(canvas);
|
|
@@ -2061,8 +2061,10 @@ var DisplayObject = class {
|
|
|
2061
2061
|
}
|
|
2062
2062
|
/**
|
|
2063
2063
|
* Destroys this display object and cleans up resources.
|
|
2064
|
+
* @param {boolean} _destroyChildren - Whether the subclass should destroy its children too.
|
|
2065
|
+
* @param {boolean} _destroyTexture - Whether the subclass should destroy its texture too.
|
|
2064
2066
|
*/
|
|
2065
|
-
destroy() {
|
|
2067
|
+
destroy(_destroyChildren = true, _destroyTexture = false) {
|
|
2066
2068
|
if (this.children) {
|
|
2067
2069
|
let i = this.children.length;
|
|
2068
2070
|
while (i) {
|
|
@@ -3912,6 +3914,153 @@ var Texture = class Texture {
|
|
|
3912
3914
|
}
|
|
3913
3915
|
};
|
|
3914
3916
|
//#endregion
|
|
3917
|
+
//#region src/phaser/core/frame_data.ts
|
|
3918
|
+
var FrameData = class {
|
|
3919
|
+
_frames;
|
|
3920
|
+
_frameNames;
|
|
3921
|
+
constructor() {
|
|
3922
|
+
this._frames = [];
|
|
3923
|
+
this._frameNames = {};
|
|
3924
|
+
}
|
|
3925
|
+
addFrame(frame) {
|
|
3926
|
+
frame.index = this._frames.length;
|
|
3927
|
+
this._frames.push(frame);
|
|
3928
|
+
if (frame.name !== "") this._frameNames[frame.name] = frame.index;
|
|
3929
|
+
return frame;
|
|
3930
|
+
}
|
|
3931
|
+
getFrame(index = 0) {
|
|
3932
|
+
if (index >= this._frames.length) index = 0;
|
|
3933
|
+
return this._frames[index];
|
|
3934
|
+
}
|
|
3935
|
+
getFrameByName(name) {
|
|
3936
|
+
const index = this._frameNames[name];
|
|
3937
|
+
if (typeof index === "number") return this._frames[index] ?? null;
|
|
3938
|
+
return null;
|
|
3939
|
+
}
|
|
3940
|
+
checkFrameName(name) {
|
|
3941
|
+
if (this._frameNames[name] == null) return false;
|
|
3942
|
+
return true;
|
|
3943
|
+
}
|
|
3944
|
+
clone() {
|
|
3945
|
+
return cloneFrameData(this);
|
|
3946
|
+
}
|
|
3947
|
+
getFrameRange(start, end, output = null) {
|
|
3948
|
+
const result = output ?? [];
|
|
3949
|
+
for (let i = start; i <= end; i += 1) result.push(this._frames[i]);
|
|
3950
|
+
return result;
|
|
3951
|
+
}
|
|
3952
|
+
getFrameIndexes(frames, useNumericIndex = true, output = null) {
|
|
3953
|
+
const result = output ?? [];
|
|
3954
|
+
if (frames && frames.length > 0) for (const f of frames) if (useNumericIndex && this._frames[f]) result.push(this._frames[f].index);
|
|
3955
|
+
else {
|
|
3956
|
+
const found = this.getFrameByName(f);
|
|
3957
|
+
if (found) result.push(found.index);
|
|
3958
|
+
}
|
|
3959
|
+
else for (const frame of this._frames) result.push(frame.index);
|
|
3960
|
+
return result;
|
|
3961
|
+
}
|
|
3962
|
+
destroy() {
|
|
3963
|
+
this._frames = null;
|
|
3964
|
+
this._frameNames = null;
|
|
3965
|
+
}
|
|
3966
|
+
get total() {
|
|
3967
|
+
return this._frames.length;
|
|
3968
|
+
}
|
|
3969
|
+
};
|
|
3970
|
+
//#endregion
|
|
3971
|
+
//#region src/phaser/core/frame_util.ts
|
|
3972
|
+
const cloneFrame = (frame, output = null) => {
|
|
3973
|
+
const result = output ?? new Frame(frame.index, frame.x, frame.y, frame.width, frame.height);
|
|
3974
|
+
result.initialize(frame.index, frame.x, frame.y, frame.width, frame.height);
|
|
3975
|
+
return result;
|
|
3976
|
+
};
|
|
3977
|
+
const cloneFrameData = (frameData, output = null) => {
|
|
3978
|
+
const result = output ?? new FrameData();
|
|
3979
|
+
for (let i = 0; i < frameData.total; i += 1) result.addFrame(frameData.getFrame(i).clone());
|
|
3980
|
+
return result;
|
|
3981
|
+
};
|
|
3982
|
+
//#endregion
|
|
3983
|
+
//#region src/phaser/core/frame.ts
|
|
3984
|
+
var Frame = class {
|
|
3985
|
+
index;
|
|
3986
|
+
x;
|
|
3987
|
+
y;
|
|
3988
|
+
width;
|
|
3989
|
+
height;
|
|
3990
|
+
name;
|
|
3991
|
+
centerX;
|
|
3992
|
+
centerY;
|
|
3993
|
+
distance;
|
|
3994
|
+
rotated;
|
|
3995
|
+
rotationDirection;
|
|
3996
|
+
trimmed;
|
|
3997
|
+
sourceSizeW;
|
|
3998
|
+
sourceSizeH;
|
|
3999
|
+
spriteSourceSizeX;
|
|
4000
|
+
spriteSourceSizeY;
|
|
4001
|
+
spriteSourceSizeW;
|
|
4002
|
+
spriteSourceSizeH;
|
|
4003
|
+
right;
|
|
4004
|
+
bottom;
|
|
4005
|
+
constructor(index, x, y, width, height, name) {
|
|
4006
|
+
this.initialize(index, x, y, width, height, name);
|
|
4007
|
+
}
|
|
4008
|
+
initialize(index, x, y, width, height, name) {
|
|
4009
|
+
this.index = index;
|
|
4010
|
+
this.x = x;
|
|
4011
|
+
this.y = y;
|
|
4012
|
+
this.width = width;
|
|
4013
|
+
this.height = height;
|
|
4014
|
+
this.name = name;
|
|
4015
|
+
this.centerX = Math.floor(width / 2);
|
|
4016
|
+
this.centerY = Math.floor(height / 2);
|
|
4017
|
+
this.distance = distance(0, 0, width, height);
|
|
4018
|
+
this.rotated = false;
|
|
4019
|
+
this.rotationDirection = "cw";
|
|
4020
|
+
this.trimmed = false;
|
|
4021
|
+
this.sourceSizeW = width;
|
|
4022
|
+
this.sourceSizeH = height;
|
|
4023
|
+
this.spriteSourceSizeX = 0;
|
|
4024
|
+
this.spriteSourceSizeY = 0;
|
|
4025
|
+
this.spriteSourceSizeW = 0;
|
|
4026
|
+
this.spriteSourceSizeH = 0;
|
|
4027
|
+
this.right = this.x + this.width;
|
|
4028
|
+
this.bottom = this.y + this.height;
|
|
4029
|
+
}
|
|
4030
|
+
resize(width, height) {
|
|
4031
|
+
this.width = width;
|
|
4032
|
+
this.height = height;
|
|
4033
|
+
this.centerX = Math.floor(width / 2);
|
|
4034
|
+
this.centerY = Math.floor(height / 2);
|
|
4035
|
+
this.distance = distance(0, 0, width, height);
|
|
4036
|
+
this.sourceSizeW = width;
|
|
4037
|
+
this.sourceSizeH = height;
|
|
4038
|
+
this.right = this.x + width;
|
|
4039
|
+
this.bottom = this.y + height;
|
|
4040
|
+
}
|
|
4041
|
+
setTrim(trimmed, actualWidth, actualHeight, destX, destY, destWidth, destHeight) {
|
|
4042
|
+
this.trimmed = trimmed;
|
|
4043
|
+
if (trimmed) {
|
|
4044
|
+
this.sourceSizeW = actualWidth;
|
|
4045
|
+
this.sourceSizeH = actualHeight;
|
|
4046
|
+
this.centerX = Math.floor(actualWidth / 2);
|
|
4047
|
+
this.centerY = Math.floor(actualHeight / 2);
|
|
4048
|
+
this.spriteSourceSizeX = destX;
|
|
4049
|
+
this.spriteSourceSizeY = destY;
|
|
4050
|
+
this.spriteSourceSizeW = destWidth;
|
|
4051
|
+
this.spriteSourceSizeH = destHeight;
|
|
4052
|
+
}
|
|
4053
|
+
}
|
|
4054
|
+
clone() {
|
|
4055
|
+
return cloneFrame(this);
|
|
4056
|
+
}
|
|
4057
|
+
getRect(output = null) {
|
|
4058
|
+
const result = output ?? new Rectangle();
|
|
4059
|
+
result.setTo(this.x, this.y, this.width, this.height);
|
|
4060
|
+
return result;
|
|
4061
|
+
}
|
|
4062
|
+
};
|
|
4063
|
+
//#endregion
|
|
3915
4064
|
//#region src/phaser/display/image.ts
|
|
3916
4065
|
var Image$1 = class extends DisplayObject {
|
|
3917
4066
|
key;
|
|
@@ -4054,18 +4203,19 @@ var Image$1 = class extends DisplayObject {
|
|
|
4054
4203
|
this.texture.crop.y = frame.y;
|
|
4055
4204
|
this.texture.crop.width = frame.width;
|
|
4056
4205
|
this.texture.crop.height = frame.height;
|
|
4057
|
-
|
|
4206
|
+
const trimmed = frame instanceof Frame && frame.trimmed ? frame : null;
|
|
4207
|
+
if (trimmed) {
|
|
4058
4208
|
if (this.texture.trim) {
|
|
4059
|
-
this.texture.trim.x =
|
|
4060
|
-
this.texture.trim.y =
|
|
4061
|
-
this.texture.trim.width =
|
|
4062
|
-
this.texture.trim.height =
|
|
4063
|
-
} else this.texture.trim = new Rectangle(
|
|
4064
|
-
this.texture.width =
|
|
4065
|
-
this.texture.height =
|
|
4066
|
-
this.texture.frame.width =
|
|
4067
|
-
this.texture.frame.height =
|
|
4068
|
-
} else if (
|
|
4209
|
+
this.texture.trim.x = trimmed.spriteSourceSizeX;
|
|
4210
|
+
this.texture.trim.y = trimmed.spriteSourceSizeY;
|
|
4211
|
+
this.texture.trim.width = trimmed.sourceSizeW;
|
|
4212
|
+
this.texture.trim.height = trimmed.sourceSizeH;
|
|
4213
|
+
} else this.texture.trim = new Rectangle(trimmed.spriteSourceSizeX, trimmed.spriteSourceSizeY, trimmed.sourceSizeW, trimmed.sourceSizeH);
|
|
4214
|
+
this.texture.width = trimmed.sourceSizeW;
|
|
4215
|
+
this.texture.height = trimmed.sourceSizeH;
|
|
4216
|
+
this.texture.frame.width = trimmed.sourceSizeW;
|
|
4217
|
+
this.texture.frame.height = trimmed.sourceSizeH;
|
|
4218
|
+
} else if (this.texture.trim) this.texture.trim = null;
|
|
4069
4219
|
if (this.cropRect) this.updateCrop();
|
|
4070
4220
|
this.texture.requiresReTint = true;
|
|
4071
4221
|
this.texture._updateUvs();
|
|
@@ -4141,13 +4291,14 @@ var Image$1 = class extends DisplayObject {
|
|
|
4141
4291
|
const oldY = this.texture.crop.y;
|
|
4142
4292
|
const oldW = this.texture.crop.width;
|
|
4143
4293
|
const oldH = this.texture.crop.height;
|
|
4294
|
+
const frame = this._frame;
|
|
4144
4295
|
this._crop = clone$5(this.cropRect, this._crop);
|
|
4145
|
-
this._crop.x +=
|
|
4146
|
-
this._crop.y +=
|
|
4147
|
-
const cx = Math.max(
|
|
4148
|
-
const cy = Math.max(
|
|
4149
|
-
const cw = Math.min(
|
|
4150
|
-
const ch = Math.min(
|
|
4296
|
+
this._crop.x += frame.x;
|
|
4297
|
+
this._crop.y += frame.y;
|
|
4298
|
+
const cx = Math.max(frame.x, this._crop.x);
|
|
4299
|
+
const cy = Math.max(frame.y, this._crop.y);
|
|
4300
|
+
const cw = Math.min(frame.right, this._crop.right) - cx;
|
|
4301
|
+
const ch = Math.min(frame.bottom, this._crop.bottom) - cy;
|
|
4151
4302
|
this.texture.crop.x = cx;
|
|
4152
4303
|
this.texture.crop.y = cy;
|
|
4153
4304
|
this.texture.crop.width = cw;
|
|
@@ -5545,7 +5696,8 @@ var Button = class extends Image$1 {
|
|
|
5545
5696
|
onInputUpHandler(_sprite, pointer, isOver) {
|
|
5546
5697
|
if (this.onInputUp) this.onInputUp.dispatch(this, pointer, isOver);
|
|
5547
5698
|
if (this.freezeFrames) return;
|
|
5548
|
-
|
|
5699
|
+
const forcedOutMode = typeof this.forceOut === "number" ? this.forceOut : 0;
|
|
5700
|
+
if (this.forceOut === true || (forcedOutMode & pointer.pointerMode) === pointer.pointerMode) this.changeStateFrame(STATE_OUT);
|
|
5549
5701
|
else if (!this.changeStateFrame(STATE_UP)) {
|
|
5550
5702
|
if (isOver) this.changeStateFrame(STATE_OVER);
|
|
5551
5703
|
else this.changeStateFrame(STATE_OUT);
|
|
@@ -7801,6 +7953,18 @@ const baseTextureFromCanvas = (canvas, scaleMode) => {
|
|
|
7801
7953
|
const textureFromCanvas = (canvas, scaleMode) => new Texture(baseTextureFromCanvas(canvas, scaleMode));
|
|
7802
7954
|
//#endregion
|
|
7803
7955
|
//#region src/phaser/display/graphics.ts
|
|
7956
|
+
/**
|
|
7957
|
+
* Reports whether a triangle winds towards the viewer. In two dimensions the cross product is a
|
|
7958
|
+
* scalar, so its sign alone says which way the face points.
|
|
7959
|
+
* @param {Point[]} points - The three corners of the triangle, in order.
|
|
7960
|
+
* @returns {boolean} True when the triangle faces the viewer.
|
|
7961
|
+
*/
|
|
7962
|
+
const isFrontFacing = (points) => {
|
|
7963
|
+
const [a, b, c] = points;
|
|
7964
|
+
if (!a || !b || !c) return true;
|
|
7965
|
+
const ab = new Point(b.x - a.x, b.y - a.y);
|
|
7966
|
+
return new Point(b.x - c.x, b.y - c.y).cross(ab) > 0;
|
|
7967
|
+
};
|
|
7804
7968
|
var Graphics = class extends DisplayObject {
|
|
7805
7969
|
fillAlpha;
|
|
7806
7970
|
lineWidth;
|
|
@@ -8486,13 +8650,8 @@ var Graphics = class extends DisplayObject {
|
|
|
8486
8650
|
*/
|
|
8487
8651
|
drawTriangle(points, cull = false) {
|
|
8488
8652
|
const triangle = new Polygon(points);
|
|
8489
|
-
if (cull)
|
|
8490
|
-
|
|
8491
|
-
const cameraToFace = new Point(0 - a.x, 0 - a.y);
|
|
8492
|
-
const ab = new Point(b.x - a.x, b.y - a.y);
|
|
8493
|
-
const faceNormal = new Point(b.x - c.x, b.y - c.y).cross(ab);
|
|
8494
|
-
if (cameraToFace.dot(faceNormal) > 0) this.drawPolygon(triangle);
|
|
8495
|
-
} else this.drawPolygon(triangle);
|
|
8653
|
+
if (cull && !isFrontFacing(points)) return;
|
|
8654
|
+
this.drawPolygon(triangle);
|
|
8496
8655
|
}
|
|
8497
8656
|
/**
|
|
8498
8657
|
* Draws triangles with the specified vertices and indices.
|
|
@@ -8501,46 +8660,41 @@ var Graphics = class extends DisplayObject {
|
|
|
8501
8660
|
* @param {boolean} cull - Whether to perform backface culling.
|
|
8502
8661
|
*/
|
|
8503
8662
|
drawTriangles(vertices, indices, cull = false) {
|
|
8504
|
-
const point1 = new Point();
|
|
8505
|
-
const point2 = new Point();
|
|
8506
|
-
const point3 = new Point();
|
|
8507
8663
|
let points = [];
|
|
8508
8664
|
let i;
|
|
8509
8665
|
if (!indices) {
|
|
8510
|
-
if (vertices[0] instanceof Point)
|
|
8511
|
-
|
|
8512
|
-
|
|
8513
|
-
|
|
8514
|
-
|
|
8515
|
-
|
|
8516
|
-
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
|
|
8521
|
-
|
|
8522
|
-
|
|
8523
|
-
point1,
|
|
8524
|
-
point2,
|
|
8525
|
-
point3
|
|
8666
|
+
if (vertices[0] instanceof Point) {
|
|
8667
|
+
const corners = vertices;
|
|
8668
|
+
for (i = 0; i < corners.length / 3; i += 1) this.drawTriangle([
|
|
8669
|
+
corners[i * 3],
|
|
8670
|
+
corners[i * 3 + 1],
|
|
8671
|
+
corners[i * 3 + 2]
|
|
8672
|
+
], cull);
|
|
8673
|
+
} else {
|
|
8674
|
+
const coordinates = vertices;
|
|
8675
|
+
for (i = 0; i < coordinates.length / 6; i += 1) this.drawTriangle([
|
|
8676
|
+
new Point(coordinates[i * 6 + 0], coordinates[i * 6 + 1]),
|
|
8677
|
+
new Point(coordinates[i * 6 + 2], coordinates[i * 6 + 3]),
|
|
8678
|
+
new Point(coordinates[i * 6 + 4], coordinates[i * 6 + 5])
|
|
8526
8679
|
], cull);
|
|
8527
8680
|
}
|
|
8528
|
-
} else if (vertices[0] instanceof Point)
|
|
8529
|
-
|
|
8530
|
-
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
|
|
8534
|
-
|
|
8681
|
+
} else if (vertices[0] instanceof Point) {
|
|
8682
|
+
const corners = vertices;
|
|
8683
|
+
for (i = 0; i < indices.length / 3; i += 1) {
|
|
8684
|
+
points.push(corners[indices[i * 3]], corners[indices[i * 3 + 1]], corners[indices[i * 3 + 2]]);
|
|
8685
|
+
if (points.length === 3) {
|
|
8686
|
+
this.drawTriangle(points, cull);
|
|
8687
|
+
points = [];
|
|
8688
|
+
}
|
|
8535
8689
|
}
|
|
8536
|
-
}
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8690
|
+
} else {
|
|
8691
|
+
const coordinates = vertices;
|
|
8692
|
+
for (i = 0; i < indices.length; i += 1) {
|
|
8693
|
+
points.push(new Point(coordinates[indices[i] * 2], coordinates[indices[i] * 2 + 1]));
|
|
8694
|
+
if (points.length === 3) {
|
|
8695
|
+
this.drawTriangle(points, cull);
|
|
8696
|
+
points = [];
|
|
8697
|
+
}
|
|
8544
8698
|
}
|
|
8545
8699
|
}
|
|
8546
8700
|
}
|
|
@@ -8789,7 +8943,7 @@ var Group = class extends DisplayObject {
|
|
|
8789
8943
|
*/
|
|
8790
8944
|
remove(child, destroy = true, silent = false) {
|
|
8791
8945
|
if (this.children.length === 0 || !this.children.includes(child)) return false;
|
|
8792
|
-
if (!silent && child.events
|
|
8946
|
+
if (!silent && child.events) child.events.onRemovedFromGroup$dispatch(child, this);
|
|
8793
8947
|
const removed = this.removeChild(child);
|
|
8794
8948
|
this.updateZ();
|
|
8795
8949
|
if (this.cursor === child) this.next();
|
|
@@ -8959,9 +9113,7 @@ var Text = class extends Image$1 {
|
|
|
8959
9113
|
updateText() {
|
|
8960
9114
|
this.texture.baseTexture.resolution = this._res;
|
|
8961
9115
|
this.context.font = this.style.font;
|
|
8962
|
-
|
|
8963
|
-
if (this.style.wordWrap) outputText = this.runWordWrap(this.text);
|
|
8964
|
-
const lines = outputText.split(/(?:\r\n|\r|\n)/);
|
|
9116
|
+
const lines = (this.style.wordWrap ? this.runWordWrap(this.text) : this.text).split(/(?:\r\n|\r|\n)/);
|
|
8965
9117
|
const { tabs } = this.style;
|
|
8966
9118
|
const lineWidths = [];
|
|
8967
9119
|
let lineWidth = 0;
|
|
@@ -8972,17 +9124,19 @@ var Text = class extends Image$1 {
|
|
|
8972
9124
|
if (this.style.maxLines > 0 && this.style.maxLines < lines.length) drawnLines = this.style.maxLines;
|
|
8973
9125
|
this._charCount = 0;
|
|
8974
9126
|
for (let i = 0; i < drawnLines; i += 1) {
|
|
9127
|
+
const currentLine = lines[i];
|
|
8975
9128
|
if (tabs === 0) {
|
|
8976
9129
|
lineWidth = this.style.strokeThickness + this.padding.x;
|
|
8977
|
-
lineWidth += this.hasCharacterStyles() ? this.measureLine(
|
|
9130
|
+
lineWidth += this.hasCharacterStyles() ? this.measureLine(currentLine) : this.context.measureText(currentLine).width;
|
|
8978
9131
|
if (this.style.wordWrap) lineWidth -= this.context.measureText(" ").width;
|
|
8979
9132
|
} else {
|
|
8980
|
-
const line =
|
|
9133
|
+
const line = currentLine.split(/(?:\t)/);
|
|
8981
9134
|
lineWidth = this.padding.x + this.style.strokeThickness;
|
|
8982
9135
|
if (Array.isArray(tabs)) {
|
|
8983
9136
|
let tab = 0;
|
|
8984
9137
|
for (let c = 0; c < line.length; c += 1) {
|
|
8985
|
-
const
|
|
9138
|
+
const part = line[c];
|
|
9139
|
+
const section = this.hasCharacterStyles() ? this.measureLine(part) : Math.ceil(this.context.measureText(part).width);
|
|
8986
9140
|
if (c > 0) tab += tabs[c - 1];
|
|
8987
9141
|
lineWidth = tab + section;
|
|
8988
9142
|
}
|
|
@@ -9018,6 +9172,7 @@ var Text = class extends Image$1 {
|
|
|
9018
9172
|
let linePositionY;
|
|
9019
9173
|
this._charCount = 0;
|
|
9020
9174
|
for (let i = 0; i < drawnLines; i += 1) {
|
|
9175
|
+
const line = lines[i];
|
|
9021
9176
|
linePositionX = this.style.strokeThickness / 2;
|
|
9022
9177
|
linePositionY = this.style.strokeThickness / 2 + i * lineHeight + fontProperties.ascent;
|
|
9023
9178
|
if (i > 0) linePositionY += lineSpacing * i;
|
|
@@ -9027,17 +9182,17 @@ var Text = class extends Image$1 {
|
|
|
9027
9182
|
linePositionX = Math.round(linePositionX);
|
|
9028
9183
|
linePositionY = Math.round(linePositionY);
|
|
9029
9184
|
}
|
|
9030
|
-
if (this.hasCharacterStyles()) this.updateLine(
|
|
9185
|
+
if (this.hasCharacterStyles()) this.updateLine(line, linePositionX, linePositionY);
|
|
9031
9186
|
else {
|
|
9032
9187
|
if (this.style.stroke && this.style.strokeThickness) {
|
|
9033
9188
|
this.updateShadow(this.style.shadowStroke ?? false);
|
|
9034
|
-
if (tabs === 0) this.context.strokeText(
|
|
9035
|
-
else this.renderTabLine(
|
|
9189
|
+
if (tabs === 0) this.context.strokeText(line, linePositionX, linePositionY);
|
|
9190
|
+
else this.renderTabLine(line, linePositionX, linePositionY, false);
|
|
9036
9191
|
}
|
|
9037
9192
|
if (this.style.fill) {
|
|
9038
9193
|
this.updateShadow(this.style.shadowFill ?? false);
|
|
9039
|
-
if (tabs === 0) this.context.fillText(
|
|
9040
|
-
else this.renderTabLine(
|
|
9194
|
+
if (tabs === 0) this.context.fillText(line, linePositionX, linePositionY);
|
|
9195
|
+
else this.renderTabLine(line, linePositionX, linePositionY, true);
|
|
9041
9196
|
}
|
|
9042
9197
|
}
|
|
9043
9198
|
}
|
|
@@ -9396,12 +9551,15 @@ var Text = class extends Image$1 {
|
|
|
9396
9551
|
parseList(list) {
|
|
9397
9552
|
if (!Array.isArray(list)) return this;
|
|
9398
9553
|
let s = "";
|
|
9399
|
-
for (let i = 0; i < list.length; i += 1)
|
|
9400
|
-
|
|
9401
|
-
if (
|
|
9402
|
-
|
|
9403
|
-
|
|
9404
|
-
|
|
9554
|
+
for (let i = 0; i < list.length; i += 1) {
|
|
9555
|
+
const row = list[i];
|
|
9556
|
+
if (Array.isArray(row)) {
|
|
9557
|
+
s += row.join(" ");
|
|
9558
|
+
if (i < list.length - 1) s += "\n";
|
|
9559
|
+
} else {
|
|
9560
|
+
s += row;
|
|
9561
|
+
if (i < list.length - 1) s += " ";
|
|
9562
|
+
}
|
|
9405
9563
|
}
|
|
9406
9564
|
this.text = s;
|
|
9407
9565
|
this.dirty = true;
|
|
@@ -10071,7 +10229,7 @@ var GameObjectFactory = class {
|
|
|
10071
10229
|
* @param {Group} group - The parent group for the image.
|
|
10072
10230
|
* @returns {Image} The created Image object.
|
|
10073
10231
|
*/
|
|
10074
|
-
image(x, y, key, frame, group = null) {
|
|
10232
|
+
image(x, y, key, frame = null, group = null) {
|
|
10075
10233
|
return (group ?? this.game.world).add(new Image$1(this.game, x, y, key, frame));
|
|
10076
10234
|
}
|
|
10077
10235
|
/**
|
|
@@ -10194,7 +10352,7 @@ var CanvasRenderer = class {
|
|
|
10194
10352
|
this.type = 1;
|
|
10195
10353
|
this.resolution = game.config.resolution;
|
|
10196
10354
|
this.clearBeforeRender = game.config.clearBeforeRender;
|
|
10197
|
-
this.transparent = game.config.transparent;
|
|
10355
|
+
this.transparent = Boolean(game.config.transparent);
|
|
10198
10356
|
this.autoResize = false;
|
|
10199
10357
|
this.contextLost = false;
|
|
10200
10358
|
this.width = game.width * this.resolution;
|
|
@@ -10268,10 +10426,10 @@ var CanvasRenderer = class {
|
|
|
10268
10426
|
* @param {CanvasRenderingContext2D} context - The canvas rendering context.
|
|
10269
10427
|
* @param {Matrix} matrix - The transformation matrix.
|
|
10270
10428
|
*/
|
|
10271
|
-
renderDisplayObject(displayObject, context
|
|
10429
|
+
renderDisplayObject(displayObject, context) {
|
|
10272
10430
|
this.renderSession.context = context ?? this.context;
|
|
10273
10431
|
this.renderSession.resolution = this.resolution;
|
|
10274
|
-
displayObject.renderCanvas(this.renderSession
|
|
10432
|
+
displayObject.renderCanvas(this.renderSession);
|
|
10275
10433
|
}
|
|
10276
10434
|
/**
|
|
10277
10435
|
* Maps blend modes to canvas rendering operations.
|
|
@@ -10308,7 +10466,7 @@ var CanvasRenderer = class {
|
|
|
10308
10466
|
//#endregion
|
|
10309
10467
|
//#region src/phaser/display/webgl/blend_manager.ts
|
|
10310
10468
|
var WebGLBlendModeManager = class {
|
|
10311
|
-
gl
|
|
10469
|
+
gl;
|
|
10312
10470
|
currentBlendMode = 99999;
|
|
10313
10471
|
/**
|
|
10314
10472
|
* Creates a new BlendModeManager instance.
|
|
@@ -10403,8 +10561,9 @@ var mask_manager_exports = /* @__PURE__ */ __exportAll({
|
|
|
10403
10561
|
const pushMask = (maskData, renderSession) => {
|
|
10404
10562
|
const { gl } = renderSession;
|
|
10405
10563
|
if (maskData.dirty) updateGraphics(maskData, gl);
|
|
10406
|
-
|
|
10407
|
-
|
|
10564
|
+
const [first] = maskData._webGL[gl.id]?.data ?? [];
|
|
10565
|
+
if (!first) return;
|
|
10566
|
+
renderSession.stencilManager.pushStencil(maskData, first, renderSession);
|
|
10408
10567
|
};
|
|
10409
10568
|
/**
|
|
10410
10569
|
* Sets up the mask manager for WebGL rendering.
|
|
@@ -10413,8 +10572,9 @@ const pushMask = (maskData, renderSession) => {
|
|
|
10413
10572
|
*/
|
|
10414
10573
|
const popMask = (maskData, renderSession) => {
|
|
10415
10574
|
const { gl } = renderSession;
|
|
10416
|
-
|
|
10417
|
-
|
|
10575
|
+
const [first] = maskData?._webGL[gl.id]?.data ?? [];
|
|
10576
|
+
if (!first) return;
|
|
10577
|
+
renderSession.stencilManager.popStencil(maskData, first, renderSession);
|
|
10418
10578
|
};
|
|
10419
10579
|
const INVALID_ENUM = 1280;
|
|
10420
10580
|
const INVALID_VALUE = 1281;
|
|
@@ -10815,10 +10975,11 @@ var NormalShader = class {
|
|
|
10815
10975
|
* @param {object} uniform - The uniform to set.
|
|
10816
10976
|
*/
|
|
10817
10977
|
initSampler2D(uniform) {
|
|
10818
|
-
|
|
10978
|
+
const texture = uniform.value;
|
|
10979
|
+
if (!texture?.baseTexture.hasLoaded) return;
|
|
10819
10980
|
const { gl } = this;
|
|
10820
10981
|
gl.activeTexture(glMember(gl, `TEXTURE${this.textureCount}`));
|
|
10821
|
-
gl.bindTexture(gl.TEXTURE_2D,
|
|
10982
|
+
gl.bindTexture(gl.TEXTURE_2D, texture.baseTexture._glTextures[gl.id] ?? null);
|
|
10822
10983
|
if (uniform.textureData) {
|
|
10823
10984
|
const data = uniform.textureData;
|
|
10824
10985
|
const magFilter = data.magFilter ?? gl.LINEAR;
|
|
@@ -10836,13 +10997,13 @@ var NormalShader = class {
|
|
|
10836
10997
|
const height = data.height ?? 2;
|
|
10837
10998
|
const border = data.border ?? 0;
|
|
10838
10999
|
gl.texImage2D(gl.TEXTURE_2D, 0, format, width, height, border, format, gl.UNSIGNED_BYTE, null);
|
|
10839
|
-
} else gl.texImage2D(gl.TEXTURE_2D, 0, format, gl.RGBA, gl.UNSIGNED_BYTE,
|
|
11000
|
+
} else gl.texImage2D(gl.TEXTURE_2D, 0, format, gl.RGBA, gl.UNSIGNED_BYTE, texture.baseTexture.source);
|
|
10840
11001
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
|
|
10841
11002
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
|
|
10842
11003
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS);
|
|
10843
11004
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT);
|
|
10844
11005
|
}
|
|
10845
|
-
gl.uniform1i(uniform.uniformLocation, this.textureCount);
|
|
11006
|
+
gl.uniform1i(uniform.uniformLocation ?? null, this.textureCount);
|
|
10846
11007
|
uniform._init = true;
|
|
10847
11008
|
this.textureCount += 1;
|
|
10848
11009
|
}
|
|
@@ -10852,20 +11013,25 @@ var NormalShader = class {
|
|
|
10852
11013
|
syncUniforms() {
|
|
10853
11014
|
this.textureCount = 1;
|
|
10854
11015
|
const { gl } = this;
|
|
10855
|
-
for (const uniform of Object.values(this.uniforms))
|
|
10856
|
-
|
|
10857
|
-
|
|
10858
|
-
|
|
10859
|
-
|
|
10860
|
-
|
|
10861
|
-
|
|
10862
|
-
if (uniform.
|
|
10863
|
-
|
|
10864
|
-
|
|
10865
|
-
|
|
10866
|
-
|
|
10867
|
-
|
|
10868
|
-
|
|
11016
|
+
for (const uniform of Object.values(this.uniforms)) {
|
|
11017
|
+
const vector = uniform.value;
|
|
11018
|
+
const sampler = uniform;
|
|
11019
|
+
if (uniform.glValueLength === 1) {
|
|
11020
|
+
if (uniform.glMatrix === true) callUniformSetter(uniform.glFunc, gl, uniform.uniformLocation, uniform.transpose, uniform.value);
|
|
11021
|
+
else callUniformSetter(uniform.glFunc, gl, uniform.uniformLocation, uniform.value);
|
|
11022
|
+
} else if (uniform.glValueLength === 2) callUniformSetter(uniform.glFunc, gl, uniform.uniformLocation, vector.x, vector.y);
|
|
11023
|
+
else if (uniform.glValueLength === 3) callUniformSetter(uniform.glFunc, gl, uniform.uniformLocation, vector.x, vector.y, vector.z);
|
|
11024
|
+
else if (uniform.glValueLength === 4) callUniformSetter(uniform.glFunc, gl, uniform.uniformLocation, vector.x, vector.y, vector.z, vector.w);
|
|
11025
|
+
else if (uniform.type === "sampler2D") {
|
|
11026
|
+
if (uniform._init) {
|
|
11027
|
+
gl.activeTexture(glMember(gl, `TEXTURE${this.textureCount}`));
|
|
11028
|
+
const { baseTexture } = sampler.value;
|
|
11029
|
+
if (baseTexture._dirty[gl.id]) globalThis.PhaserRegistry.INSTANCES[gl.id]?.updateTexture(baseTexture);
|
|
11030
|
+
else gl.bindTexture(gl.TEXTURE_2D, baseTexture._glTextures[gl.id] ?? null);
|
|
11031
|
+
gl.uniform1i(uniform.uniformLocation ?? null, this.textureCount);
|
|
11032
|
+
this.textureCount += 1;
|
|
11033
|
+
} else this.initSampler2D(sampler);
|
|
11034
|
+
}
|
|
10869
11035
|
}
|
|
10870
11036
|
}
|
|
10871
11037
|
/**
|
|
@@ -11125,6 +11291,7 @@ var WebGLShaderManager = class {
|
|
|
11125
11291
|
//#endregion
|
|
11126
11292
|
//#region src/phaser/display/webgl/abstract_filter.ts
|
|
11127
11293
|
var AbstractFilter = class {
|
|
11294
|
+
_UID;
|
|
11128
11295
|
passes;
|
|
11129
11296
|
shaders;
|
|
11130
11297
|
dirty;
|
|
@@ -11137,6 +11304,7 @@ var AbstractFilter = class {
|
|
|
11137
11304
|
* @param {object} uniforms - The uniform variables for the shader.
|
|
11138
11305
|
*/
|
|
11139
11306
|
constructor(fragmentSrc, uniforms) {
|
|
11307
|
+
this._UID = v4();
|
|
11140
11308
|
this.passes = [this];
|
|
11141
11309
|
this.shaders = [];
|
|
11142
11310
|
this.dirty = true;
|
|
@@ -11148,7 +11316,7 @@ var AbstractFilter = class {
|
|
|
11148
11316
|
* Initializes the filter.
|
|
11149
11317
|
*/
|
|
11150
11318
|
syncUniforms() {
|
|
11151
|
-
for (
|
|
11319
|
+
for (const shader of this.shaders) shader.dirty = true;
|
|
11152
11320
|
}
|
|
11153
11321
|
};
|
|
11154
11322
|
//#endregion
|
|
@@ -11411,7 +11579,7 @@ var WebGLSpriteBatch = class {
|
|
|
11411
11579
|
* @param {number} startIndex - The start index in the batch.
|
|
11412
11580
|
*/
|
|
11413
11581
|
renderBatch(texture, size, startIndex) {
|
|
11414
|
-
if (size === 0) return;
|
|
11582
|
+
if (size === 0 || !texture) return;
|
|
11415
11583
|
const { gl } = this;
|
|
11416
11584
|
if (texture._dirty[gl.id]) {
|
|
11417
11585
|
if (!this.renderSession.renderer.updateTexture(texture)) return;
|
|
@@ -11471,7 +11639,7 @@ var WebGLStencilManager = class {
|
|
|
11471
11639
|
* Sets up the stencil buffer for rendering.
|
|
11472
11640
|
*/
|
|
11473
11641
|
destroy() {
|
|
11474
|
-
this.stencilStack =
|
|
11642
|
+
this.stencilStack = [];
|
|
11475
11643
|
}
|
|
11476
11644
|
/**
|
|
11477
11645
|
* Renders the stencil buffer for graphics.
|
|
@@ -11762,15 +11930,15 @@ var WebGLRenderer = class {
|
|
|
11762
11930
|
* @param {object} buffer - The render buffer.
|
|
11763
11931
|
* @param {Matrix} matrix - The transformation matrix.
|
|
11764
11932
|
*/
|
|
11765
|
-
renderDisplayObject(displayObject, projection, buffer
|
|
11933
|
+
renderDisplayObject(displayObject, projection, buffer) {
|
|
11766
11934
|
this.renderSession.blendModeManager.setBlendMode(0);
|
|
11767
11935
|
this.renderSession.drawCount = 0;
|
|
11768
11936
|
this.renderSession.flipY = buffer ? -1 : 1;
|
|
11769
11937
|
this.renderSession.projection = projection;
|
|
11770
11938
|
this.renderSession.offset = this.offset;
|
|
11771
11939
|
this.spriteBatch.begin(this.renderSession);
|
|
11772
|
-
this.filterManager.begin(
|
|
11773
|
-
displayObject.renderWebGL(this.renderSession
|
|
11940
|
+
this.filterManager.begin();
|
|
11941
|
+
displayObject.renderWebGL(this.renderSession);
|
|
11774
11942
|
this.spriteBatch.end();
|
|
11775
11943
|
}
|
|
11776
11944
|
/**
|
|
@@ -11846,153 +12014,6 @@ var WebGLRenderer = class {
|
|
|
11846
12014
|
}
|
|
11847
12015
|
};
|
|
11848
12016
|
//#endregion
|
|
11849
|
-
//#region src/phaser/core/frame_data.ts
|
|
11850
|
-
var FrameData = class {
|
|
11851
|
-
_frames;
|
|
11852
|
-
_frameNames;
|
|
11853
|
-
constructor() {
|
|
11854
|
-
this._frames = [];
|
|
11855
|
-
this._frameNames = {};
|
|
11856
|
-
}
|
|
11857
|
-
addFrame(frame) {
|
|
11858
|
-
frame.index = this._frames.length;
|
|
11859
|
-
this._frames.push(frame);
|
|
11860
|
-
if (frame.name !== "") this._frameNames[frame.name] = frame.index;
|
|
11861
|
-
return frame;
|
|
11862
|
-
}
|
|
11863
|
-
getFrame(index = 0) {
|
|
11864
|
-
if (index >= this._frames.length) index = 0;
|
|
11865
|
-
return this._frames[index];
|
|
11866
|
-
}
|
|
11867
|
-
getFrameByName(name) {
|
|
11868
|
-
const index = this._frameNames[name];
|
|
11869
|
-
if (typeof index === "number") return this._frames[index] ?? null;
|
|
11870
|
-
return null;
|
|
11871
|
-
}
|
|
11872
|
-
checkFrameName(name) {
|
|
11873
|
-
if (this._frameNames[name] == null) return false;
|
|
11874
|
-
return true;
|
|
11875
|
-
}
|
|
11876
|
-
clone() {
|
|
11877
|
-
return cloneFrameData(this);
|
|
11878
|
-
}
|
|
11879
|
-
getFrameRange(start, end, output = null) {
|
|
11880
|
-
const result = output ?? [];
|
|
11881
|
-
for (let i = start; i <= end; i += 1) result.push(this._frames[i]);
|
|
11882
|
-
return result;
|
|
11883
|
-
}
|
|
11884
|
-
getFrameIndexes(frames, useNumericIndex = true, output = null) {
|
|
11885
|
-
const result = output ?? [];
|
|
11886
|
-
if (frames && frames.length > 0) for (const f of frames) if (useNumericIndex && this._frames[f]) result.push(this._frames[f].index);
|
|
11887
|
-
else {
|
|
11888
|
-
const found = this.getFrameByName(f);
|
|
11889
|
-
if (found) result.push(found.index);
|
|
11890
|
-
}
|
|
11891
|
-
else for (const frame of this._frames) result.push(frame.index);
|
|
11892
|
-
return result;
|
|
11893
|
-
}
|
|
11894
|
-
destroy() {
|
|
11895
|
-
this._frames = null;
|
|
11896
|
-
this._frameNames = null;
|
|
11897
|
-
}
|
|
11898
|
-
get total() {
|
|
11899
|
-
return this._frames.length;
|
|
11900
|
-
}
|
|
11901
|
-
};
|
|
11902
|
-
//#endregion
|
|
11903
|
-
//#region src/phaser/core/frame_util.ts
|
|
11904
|
-
const cloneFrame = (frame, output = null) => {
|
|
11905
|
-
const result = output ?? new Frame(frame.index, frame.x, frame.y, frame.width, frame.height);
|
|
11906
|
-
result.initialize(frame.index, frame.x, frame.y, frame.width, frame.height);
|
|
11907
|
-
return result;
|
|
11908
|
-
};
|
|
11909
|
-
const cloneFrameData = (frameData, output = null) => {
|
|
11910
|
-
const result = output ?? new FrameData();
|
|
11911
|
-
for (let i = 0; i < frameData.total; i += 1) result.addFrame(frameData.getFrame(i).clone());
|
|
11912
|
-
return result;
|
|
11913
|
-
};
|
|
11914
|
-
//#endregion
|
|
11915
|
-
//#region src/phaser/core/frame.ts
|
|
11916
|
-
var Frame = class {
|
|
11917
|
-
index;
|
|
11918
|
-
x;
|
|
11919
|
-
y;
|
|
11920
|
-
width;
|
|
11921
|
-
height;
|
|
11922
|
-
name;
|
|
11923
|
-
centerX;
|
|
11924
|
-
centerY;
|
|
11925
|
-
distance;
|
|
11926
|
-
rotated;
|
|
11927
|
-
rotationDirection;
|
|
11928
|
-
trimmed;
|
|
11929
|
-
sourceSizeW;
|
|
11930
|
-
sourceSizeH;
|
|
11931
|
-
spriteSourceSizeX;
|
|
11932
|
-
spriteSourceSizeY;
|
|
11933
|
-
spriteSourceSizeW;
|
|
11934
|
-
spriteSourceSizeH;
|
|
11935
|
-
right;
|
|
11936
|
-
bottom;
|
|
11937
|
-
constructor(index, x, y, width, height, name) {
|
|
11938
|
-
this.initialize(index, x, y, width, height, name);
|
|
11939
|
-
}
|
|
11940
|
-
initialize(index, x, y, width, height, name) {
|
|
11941
|
-
this.index = index;
|
|
11942
|
-
this.x = x;
|
|
11943
|
-
this.y = y;
|
|
11944
|
-
this.width = width;
|
|
11945
|
-
this.height = height;
|
|
11946
|
-
this.name = name;
|
|
11947
|
-
this.centerX = Math.floor(width / 2);
|
|
11948
|
-
this.centerY = Math.floor(height / 2);
|
|
11949
|
-
this.distance = distance(0, 0, width, height);
|
|
11950
|
-
this.rotated = false;
|
|
11951
|
-
this.rotationDirection = "cw";
|
|
11952
|
-
this.trimmed = false;
|
|
11953
|
-
this.sourceSizeW = width;
|
|
11954
|
-
this.sourceSizeH = height;
|
|
11955
|
-
this.spriteSourceSizeX = 0;
|
|
11956
|
-
this.spriteSourceSizeY = 0;
|
|
11957
|
-
this.spriteSourceSizeW = 0;
|
|
11958
|
-
this.spriteSourceSizeH = 0;
|
|
11959
|
-
this.right = this.x + this.width;
|
|
11960
|
-
this.bottom = this.y + this.height;
|
|
11961
|
-
}
|
|
11962
|
-
resize(width, height) {
|
|
11963
|
-
this.width = width;
|
|
11964
|
-
this.height = height;
|
|
11965
|
-
this.centerX = Math.floor(width / 2);
|
|
11966
|
-
this.centerY = Math.floor(height / 2);
|
|
11967
|
-
this.distance = distance(0, 0, width, height);
|
|
11968
|
-
this.sourceSizeW = width;
|
|
11969
|
-
this.sourceSizeH = height;
|
|
11970
|
-
this.right = this.x + width;
|
|
11971
|
-
this.bottom = this.y + height;
|
|
11972
|
-
}
|
|
11973
|
-
setTrim(trimmed, actualWidth, actualHeight, destX, destY, destWidth, destHeight) {
|
|
11974
|
-
this.trimmed = trimmed;
|
|
11975
|
-
if (trimmed) {
|
|
11976
|
-
this.sourceSizeW = actualWidth;
|
|
11977
|
-
this.sourceSizeH = actualHeight;
|
|
11978
|
-
this.centerX = Math.floor(actualWidth / 2);
|
|
11979
|
-
this.centerY = Math.floor(actualHeight / 2);
|
|
11980
|
-
this.spriteSourceSizeX = destX;
|
|
11981
|
-
this.spriteSourceSizeY = destY;
|
|
11982
|
-
this.spriteSourceSizeW = destWidth;
|
|
11983
|
-
this.spriteSourceSizeH = destHeight;
|
|
11984
|
-
}
|
|
11985
|
-
}
|
|
11986
|
-
clone() {
|
|
11987
|
-
return cloneFrame(this);
|
|
11988
|
-
}
|
|
11989
|
-
getRect(output = null) {
|
|
11990
|
-
const result = output ?? new Rectangle();
|
|
11991
|
-
result.setTo(this.x, this.y, this.width, this.height);
|
|
11992
|
-
return result;
|
|
11993
|
-
}
|
|
11994
|
-
};
|
|
11995
|
-
//#endregion
|
|
11996
12017
|
//#region src/phaser/core/animation_parser.ts
|
|
11997
12018
|
/**
|
|
11998
12019
|
* TBD.
|
|
@@ -12006,8 +12027,7 @@ var Frame = class {
|
|
|
12006
12027
|
* @returns {FrameData} TBD.
|
|
12007
12028
|
*/
|
|
12008
12029
|
const spriteSheet = (game, key, frameWidth, frameHeight, frameMax, margin, spacing) => {
|
|
12009
|
-
|
|
12010
|
-
if (typeof key === "string") img = game.cache.getImage(key);
|
|
12030
|
+
const img = typeof key === "string" ? game.cache.getImage(key) : key;
|
|
12011
12031
|
if (img === null) return null;
|
|
12012
12032
|
const { width } = img;
|
|
12013
12033
|
const { height } = img;
|
|
@@ -12016,7 +12036,7 @@ const spriteSheet = (game, key, frameWidth, frameHeight, frameMax, margin, spaci
|
|
|
12016
12036
|
let total = Math.floor((width - margin) / (frameWidth + spacing)) * Math.floor((height - margin) / (frameHeight + spacing));
|
|
12017
12037
|
if (frameMax !== -1) total = frameMax;
|
|
12018
12038
|
if (width === 0 || height === 0 || width < frameWidth || height < frameHeight || total === 0) {
|
|
12019
|
-
game.logger.warn(`AnimationParser.spriteSheet: '${key}'s width/height zero or width/height < given frameWidth/frameHeight`);
|
|
12039
|
+
game.logger.warn(`AnimationParser.spriteSheet: '${typeof key === "string" ? key : "image"}'s width/height zero or width/height < given frameWidth/frameHeight`);
|
|
12020
12040
|
return null;
|
|
12021
12041
|
}
|
|
12022
12042
|
const data = new FrameData();
|
|
@@ -12039,18 +12059,17 @@ const spriteSheet = (game, key, frameWidth, frameHeight, frameMax, margin, spaci
|
|
|
12039
12059
|
* @returns {FrameData} TBD.
|
|
12040
12060
|
*/
|
|
12041
12061
|
const jsonDataHash = (game, json, _key) => {
|
|
12042
|
-
|
|
12043
|
-
|
|
12062
|
+
const atlas = json;
|
|
12063
|
+
if (!atlas?.frames) {
|
|
12064
|
+
game.logger.warn("jsonDataHash: Invalid Texture Atlas JSON given, missing frames object");
|
|
12044
12065
|
return null;
|
|
12045
12066
|
}
|
|
12046
12067
|
const data = new FrameData();
|
|
12047
|
-
const { frames } =
|
|
12048
|
-
let newFrame;
|
|
12068
|
+
const { frames } = atlas;
|
|
12049
12069
|
let i = 0;
|
|
12050
|
-
const
|
|
12051
|
-
|
|
12052
|
-
|
|
12053
|
-
if (frames[key].trimmed) newFrame.setTrim(frames[key].trimmed, frames[key].sourceSize.w, frames[key].sourceSize.h, frames[key].spriteSourceSize.x, frames[key].spriteSourceSize.y, frames[key].spriteSourceSize.w, frames[key].spriteSourceSize.h);
|
|
12070
|
+
for (const [key, entry] of Object.entries(frames)) {
|
|
12071
|
+
const newFrame = data.addFrame(new Frame(i, entry.frame.x, entry.frame.y, entry.frame.w, entry.frame.h, key));
|
|
12072
|
+
if (entry.trimmed && entry.sourceSize && entry.spriteSourceSize) newFrame.setTrim(entry.trimmed, entry.sourceSize.w, entry.sourceSize.h, entry.spriteSourceSize.x, entry.spriteSourceSize.y, entry.spriteSourceSize.w, entry.spriteSourceSize.h);
|
|
12054
12073
|
i += 1;
|
|
12055
12074
|
}
|
|
12056
12075
|
return data;
|
|
@@ -12111,9 +12130,9 @@ const xmlBitmapFont = (xml, baseTexture, xSpacing, ySpacing) => {
|
|
|
12111
12130
|
*/
|
|
12112
12131
|
const jsonBitmapFont = (json, baseTexture, xSpacing, ySpacing) => {
|
|
12113
12132
|
const data = {
|
|
12114
|
-
font: json.font.info
|
|
12115
|
-
size: Math.trunc(Number(json.font.info
|
|
12116
|
-
lineHeight: Math.trunc(Number(json.font.common
|
|
12133
|
+
font: json.font.info["_face"] ?? "",
|
|
12134
|
+
size: Math.trunc(Number(json.font.info["_size"])),
|
|
12135
|
+
lineHeight: Math.trunc(Number(json.font.common["_lineHeight"])) + ySpacing,
|
|
12117
12136
|
chars: {}
|
|
12118
12137
|
};
|
|
12119
12138
|
for (const letter of json.font.chars.char) {
|
|
@@ -13064,11 +13083,7 @@ var ArraySet = class {
|
|
|
13064
13083
|
* @returns {object} TBD.
|
|
13065
13084
|
*/
|
|
13066
13085
|
getByKey(property, value) {
|
|
13067
|
-
let i = this.list.length;
|
|
13068
|
-
while (i) {
|
|
13069
|
-
i -= 1;
|
|
13070
|
-
if (this.list[i][property] === value) return this.list[i];
|
|
13071
|
-
}
|
|
13086
|
+
for (let i = this.list.length - 1; i >= 0; i -= 1) if (this.list[i]?.[property] === value) return this.list[i];
|
|
13072
13087
|
return null;
|
|
13073
13088
|
}
|
|
13074
13089
|
/**
|
|
@@ -13114,7 +13129,7 @@ var ArraySet = class {
|
|
|
13114
13129
|
callAll(key, ...args) {
|
|
13115
13130
|
for (let i = this.list.length - 1; i >= 0; i -= 1) {
|
|
13116
13131
|
const item = this.list[i];
|
|
13117
|
-
if (item
|
|
13132
|
+
if (item?.[key]) item[key](...args);
|
|
13118
13133
|
}
|
|
13119
13134
|
}
|
|
13120
13135
|
/**
|
|
@@ -13122,12 +13137,11 @@ var ArraySet = class {
|
|
|
13122
13137
|
* @param {boolean} destroy - TBD.
|
|
13123
13138
|
*/
|
|
13124
13139
|
removeAll(destroy = false) {
|
|
13125
|
-
let i = this.list.length;
|
|
13126
|
-
|
|
13127
|
-
|
|
13128
|
-
|
|
13129
|
-
|
|
13130
|
-
if (destroy) item.destroy();
|
|
13140
|
+
for (let i = this.list.length - 1; i >= 0; i -= 1) {
|
|
13141
|
+
const entry = this.list[i];
|
|
13142
|
+
if (entry) {
|
|
13143
|
+
const item = this.remove(entry);
|
|
13144
|
+
if (destroy) item?.destroy?.();
|
|
13131
13145
|
}
|
|
13132
13146
|
}
|
|
13133
13147
|
this.position = 0;
|
|
@@ -13156,7 +13170,7 @@ var ArraySet = class {
|
|
|
13156
13170
|
get next() {
|
|
13157
13171
|
if (this.position < this.list.length) {
|
|
13158
13172
|
this.position += 1;
|
|
13159
|
-
return this.list[this.position];
|
|
13173
|
+
return this.list[this.position] ?? null;
|
|
13160
13174
|
}
|
|
13161
13175
|
return null;
|
|
13162
13176
|
}
|
|
@@ -13362,11 +13376,11 @@ var Mouse = class {
|
|
|
13362
13376
|
* @param {WheelEvent} event - TBD.
|
|
13363
13377
|
*/
|
|
13364
13378
|
onMouseWheel(event) {
|
|
13365
|
-
|
|
13366
|
-
this.event =
|
|
13367
|
-
this.eventPreventDefault(
|
|
13368
|
-
this.wheelDelta = Math.max(-1, Math.min(1, -(
|
|
13369
|
-
if (this.mouseWheelCallback) this.mouseWheelCallback.call(this.callbackContext,
|
|
13379
|
+
const wheelEvent = this._wheelEvent ? this._wheelEvent.bindEvent(event) : event;
|
|
13380
|
+
this.event = wheelEvent;
|
|
13381
|
+
this.eventPreventDefault(wheelEvent);
|
|
13382
|
+
this.wheelDelta = Math.max(-1, Math.min(1, -(wheelEvent.deltaY ?? 0)));
|
|
13383
|
+
if (this.mouseWheelCallback) this.mouseWheelCallback.call(this.callbackContext, wheelEvent);
|
|
13370
13384
|
}
|
|
13371
13385
|
/**
|
|
13372
13386
|
* TBD.
|
|
@@ -13905,7 +13919,7 @@ var Pointer = class {
|
|
|
13905
13919
|
* @param {number} duration - TBD.
|
|
13906
13920
|
* @returns {boolean} TBD.
|
|
13907
13921
|
*/
|
|
13908
|
-
justPressed(duration) {
|
|
13922
|
+
justPressed(duration = 0) {
|
|
13909
13923
|
const window = duration || this.game.input.justPressedRate;
|
|
13910
13924
|
return this.isDown && this.timeDown + window > this.game.time.time;
|
|
13911
13925
|
}
|
|
@@ -13914,7 +13928,7 @@ var Pointer = class {
|
|
|
13914
13928
|
* @param {number} duration - TBD.
|
|
13915
13929
|
* @returns {boolean} TBD.
|
|
13916
13930
|
*/
|
|
13917
|
-
justReleased(duration) {
|
|
13931
|
+
justReleased(duration = 0) {
|
|
13918
13932
|
const window = duration || this.game.input.justReleasedRate;
|
|
13919
13933
|
return this.isUp && this.timeUp + window > this.game.time.time;
|
|
13920
13934
|
}
|
|
@@ -14683,9 +14697,8 @@ var Loader = class {
|
|
|
14683
14697
|
direction,
|
|
14684
14698
|
width: sprite.width,
|
|
14685
14699
|
height: sprite.height,
|
|
14686
|
-
rect:
|
|
14700
|
+
rect: direction === 0 ? new Rectangle(0, 0, 1, sprite.height) : new Rectangle(0, 0, sprite.width, 1)
|
|
14687
14701
|
};
|
|
14688
|
-
this.preloadSprite.rect = direction === 0 ? new Rectangle(0, 0, 1, sprite.height) : new Rectangle(0, 0, sprite.width, 1);
|
|
14689
14702
|
sprite.crop(this.preloadSprite.rect);
|
|
14690
14703
|
sprite.visible = true;
|
|
14691
14704
|
}
|
|
@@ -15507,16 +15520,11 @@ var Loader = class {
|
|
|
15507
15520
|
parseXml(data) {
|
|
15508
15521
|
let xml = null;
|
|
15509
15522
|
try {
|
|
15510
|
-
|
|
15511
|
-
else {
|
|
15512
|
-
xml = new globalThis.ActiveXObject("Microsoft.XMLDOM");
|
|
15513
|
-
xml.async = "false";
|
|
15514
|
-
xml.loadXML(data);
|
|
15515
|
-
}
|
|
15523
|
+
xml = new DOMParser().parseFromString(data, "text/xml");
|
|
15516
15524
|
} catch {
|
|
15517
15525
|
xml = null;
|
|
15518
15526
|
}
|
|
15519
|
-
if (!xml
|
|
15527
|
+
if (!xml?.documentElement || xml.querySelectorAll("parsererror").length > 0) return null;
|
|
15520
15528
|
return xml;
|
|
15521
15529
|
}
|
|
15522
15530
|
/**
|
|
@@ -18842,14 +18850,15 @@ var TweenData = class {
|
|
|
18842
18850
|
loadValues() {
|
|
18843
18851
|
const keys = Object.keys(this.parent.properties);
|
|
18844
18852
|
for (const property of keys) {
|
|
18845
|
-
|
|
18846
|
-
|
|
18847
|
-
|
|
18848
|
-
|
|
18849
|
-
if (this.vEnd[property]
|
|
18850
|
-
|
|
18853
|
+
const start = this.parent.properties[property];
|
|
18854
|
+
this.vStart[property] = start;
|
|
18855
|
+
const end = this.vEnd[property];
|
|
18856
|
+
if (Array.isArray(end) && end.length > 0 && this.percent === 0) this.vEnd[property] = [Number(start), ...end];
|
|
18857
|
+
if (end === void 0) this.vEnd[property] = start;
|
|
18858
|
+
else {
|
|
18859
|
+
if (typeof end === "string") this.vEnd[property] = Number(start) + Number(end);
|
|
18851
18860
|
this.parent.properties[property] = this.vEnd[property];
|
|
18852
|
-
}
|
|
18861
|
+
}
|
|
18853
18862
|
this.vStartCache[property] = this.vStart[property];
|
|
18854
18863
|
this.vEndCache[property] = this.vEnd[property];
|
|
18855
18864
|
}
|
|
@@ -18877,9 +18886,9 @@ var TweenData = class {
|
|
|
18877
18886
|
this.value = this.easingFunction(this.percent);
|
|
18878
18887
|
const keys = Object.keys(this.vEnd);
|
|
18879
18888
|
for (const property of keys) {
|
|
18880
|
-
const start = this.vStart[property];
|
|
18881
18889
|
const end = this.vEnd[property];
|
|
18882
|
-
|
|
18890
|
+
const start = Number(this.vStart[property]);
|
|
18891
|
+
this.parent.target[property] = Array.isArray(end) ? this.interpolationFunction.call(this.interpolationContext, end, this.value) : start + (Number(end) - start) * this.value;
|
|
18883
18892
|
}
|
|
18884
18893
|
if (!this.parent.reverse && this.percent === 1 || this.parent.reverse && this.percent === 0) return this.repeat();
|
|
18885
18894
|
return 1;
|
|
@@ -18907,9 +18916,9 @@ var TweenData = class {
|
|
|
18907
18916
|
const blob = {};
|
|
18908
18917
|
const keys = Object.keys(this.vEnd);
|
|
18909
18918
|
for (const property of keys) {
|
|
18910
|
-
const start = this.vStart[property];
|
|
18911
18919
|
const end = this.vEnd[property];
|
|
18912
|
-
|
|
18920
|
+
const start = Number(this.vStart[property]);
|
|
18921
|
+
blob[property] = Array.isArray(end) ? this.interpolationFunction(end, this.value) : start + (Number(end) - start) * this.value;
|
|
18913
18922
|
}
|
|
18914
18923
|
data.push(blob);
|
|
18915
18924
|
if (!this.parent.reverse && this.percent === 1 || this.parent.reverse && this.percent === 0) complete = true;
|
|
@@ -19041,9 +19050,9 @@ var Tween = class {
|
|
|
19041
19050
|
* @returns {Tween} This Tween object for chaining.
|
|
19042
19051
|
*/
|
|
19043
19052
|
to(properties, duration = 1e3, ease = "Linear", autoStart = false, delay = 0, repeat = 0, yoyo = false) {
|
|
19044
|
-
|
|
19053
|
+
const easing = this.resolveEasing(ease);
|
|
19045
19054
|
if (this.isRunning) return this;
|
|
19046
|
-
this.timeline.push(new TweenData(this).to(properties, duration,
|
|
19055
|
+
this.timeline.push(new TweenData(this).to(properties, duration, easing, delay, repeat, yoyo));
|
|
19047
19056
|
if (autoStart) this.start();
|
|
19048
19057
|
return this;
|
|
19049
19058
|
}
|
|
@@ -19059,12 +19068,11 @@ var Tween = class {
|
|
|
19059
19068
|
* @returns {Tween} This Tween object for chaining.
|
|
19060
19069
|
*/
|
|
19061
19070
|
from(properties, duration = 1e3, ease = "Linear", autoStart = false, delay = 0, repeat = 0, yoyo = false) {
|
|
19062
|
-
if (typeof ease === "string" && this.manager.easeMap[ease]) ease = this.manager.easeMap[ease];
|
|
19063
19071
|
if (this.isRunning) {
|
|
19064
19072
|
this.game.logger.warn("Tween.from cannot be called after Tween.start");
|
|
19065
19073
|
return this;
|
|
19066
19074
|
}
|
|
19067
|
-
this.timeline.push(new TweenData(this).from(properties, duration, ease, delay, repeat, yoyo));
|
|
19075
|
+
this.timeline.push(new TweenData(this).from(properties, duration, this.resolveEasing(ease), delay, repeat, yoyo));
|
|
19068
19076
|
if (autoStart) this.start();
|
|
19069
19077
|
return this;
|
|
19070
19078
|
}
|
|
@@ -19079,8 +19087,7 @@ var Tween = class {
|
|
|
19079
19087
|
const keys = Object.keys(tweenData.vEnd);
|
|
19080
19088
|
for (const property of keys) {
|
|
19081
19089
|
const targetProperties = this.target;
|
|
19082
|
-
this.properties[property] = targetProperties[property] ?? 0;
|
|
19083
|
-
if (!Array.isArray(this.properties[property])) this.properties[property] *= 1;
|
|
19090
|
+
this.properties[property] = Number(targetProperties[property] ?? 0);
|
|
19084
19091
|
}
|
|
19085
19092
|
}
|
|
19086
19093
|
for (const tweenData of this.timeline) tweenData.loadValues();
|
|
@@ -19176,6 +19183,16 @@ var Tween = class {
|
|
|
19176
19183
|
* @param {number} index - The index in the timeline to apply easing to.
|
|
19177
19184
|
* @returns {Tween} This Tween object for chaining.
|
|
19178
19185
|
*/
|
|
19186
|
+
resolveEasing(ease) {
|
|
19187
|
+
if (typeof ease !== "string") return ease;
|
|
19188
|
+
return this.manager.easeMap[ease] ?? this.manager.easeMap["Linear"];
|
|
19189
|
+
}
|
|
19190
|
+
/**
|
|
19191
|
+
* Sets the easing function for a tween in the timeline.
|
|
19192
|
+
* @param {string | Function} ease - The easing function or its name.
|
|
19193
|
+
* @param {number} index - The index of the tween in the timeline.
|
|
19194
|
+
* @returns {Tween} This Tween object for chaining.
|
|
19195
|
+
*/
|
|
19179
19196
|
easing(ease, index) {
|
|
19180
19197
|
if (typeof ease === "string" && this.manager.easeMap[ease]) ease = this.manager.easeMap[ease];
|
|
19181
19198
|
return this.updateTweenData("easingFunction", ease, index);
|
|
@@ -19338,8 +19355,7 @@ var Tween = class {
|
|
|
19338
19355
|
const keys = Object.keys(tweenData.vEnd);
|
|
19339
19356
|
for (const property of keys) {
|
|
19340
19357
|
const targetProperties = this.target;
|
|
19341
|
-
this.properties[property] = targetProperties[property] ?? 0;
|
|
19342
|
-
if (!Array.isArray(this.properties[property])) this.properties[property] *= 1;
|
|
19358
|
+
this.properties[property] = Number(targetProperties[property] ?? 0);
|
|
19343
19359
|
}
|
|
19344
19360
|
}
|
|
19345
19361
|
for (const tweenData of this.timeline) tweenData.loadValues();
|