lighteningcards 2.2.0 → 2.2.2
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.cjs.js +449 -1236
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.esm.js +449 -1236
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/LighteningCard.css +8 -4
- package/src/components/LightningCardHTML.js +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -2957,8 +2957,8 @@ const _TextureStyle = class _TextureStyle extends EventEmitter {
|
|
|
2957
2957
|
return this._sharedResourceId || this._generateResourceId();
|
|
2958
2958
|
}
|
|
2959
2959
|
update() {
|
|
2960
|
-
this._sharedResourceId = null;
|
|
2961
2960
|
this.emit("change", this);
|
|
2961
|
+
this._sharedResourceId = null;
|
|
2962
2962
|
}
|
|
2963
2963
|
_generateResourceId() {
|
|
2964
2964
|
const bigKey = `${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;
|
|
@@ -2987,10 +2987,6 @@ const _TextureSource = class _TextureSource extends EventEmitter {
|
|
|
2987
2987
|
constructor(options = {}) {
|
|
2988
2988
|
super();
|
|
2989
2989
|
this.options = options;
|
|
2990
|
-
/** @internal */
|
|
2991
|
-
this._gpuData = /* @__PURE__ */ Object.create(null);
|
|
2992
|
-
/** @internal */
|
|
2993
|
-
this._gcLastUsed = -1;
|
|
2994
2990
|
/** unique id for this Texture source */
|
|
2995
2991
|
this.uid = uid$1("textureSource");
|
|
2996
2992
|
/**
|
|
@@ -3186,8 +3182,8 @@ const _TextureSource = class _TextureSource extends EventEmitter {
|
|
|
3186
3182
|
/** Destroys this texture source */
|
|
3187
3183
|
destroy() {
|
|
3188
3184
|
this.destroyed = true;
|
|
3189
|
-
this.unload();
|
|
3190
3185
|
this.emit("destroy", this);
|
|
3186
|
+
this.emit("change", this);
|
|
3191
3187
|
if (this._style) {
|
|
3192
3188
|
this._style.destroy();
|
|
3193
3189
|
this._style = null;
|
|
@@ -3204,10 +3200,6 @@ const _TextureSource = class _TextureSource extends EventEmitter {
|
|
|
3204
3200
|
this._resourceId = uid$1("resource");
|
|
3205
3201
|
this.emit("change", this);
|
|
3206
3202
|
this.emit("unload", this);
|
|
3207
|
-
for (const key in this._gpuData) {
|
|
3208
|
-
this._gpuData[key]?.destroy?.();
|
|
3209
|
-
}
|
|
3210
|
-
this._gpuData = /* @__PURE__ */ Object.create(null);
|
|
3211
3203
|
}
|
|
3212
3204
|
/** the width of the resource. This is the REAL pure number, not accounting resolution */
|
|
3213
3205
|
get resourceWidth() {
|
|
@@ -3574,7 +3566,6 @@ class Texture extends EventEmitter {
|
|
|
3574
3566
|
*/
|
|
3575
3567
|
destroy(destroySource = false) {
|
|
3576
3568
|
if (this._source) {
|
|
3577
|
-
this._source.off("resize", this.update, this);
|
|
3578
3569
|
if (destroySource) {
|
|
3579
3570
|
this._source.destroy();
|
|
3580
3571
|
this._source = null;
|
|
@@ -5410,7 +5401,6 @@ class Pool {
|
|
|
5410
5401
|
item = this._pool[--this._index];
|
|
5411
5402
|
} else {
|
|
5412
5403
|
item = new this._classType();
|
|
5413
|
-
this._count++;
|
|
5414
5404
|
}
|
|
5415
5405
|
item.init?.(data);
|
|
5416
5406
|
return item;
|
|
@@ -6868,13 +6858,6 @@ class Container extends EventEmitter {
|
|
|
6868
6858
|
this.measurable = true;
|
|
6869
6859
|
/** @private */
|
|
6870
6860
|
this.isSimple = true;
|
|
6871
|
-
/**
|
|
6872
|
-
* The RenderLayer this container belongs to, if any.
|
|
6873
|
-
* If it belongs to a RenderLayer, it will be rendered from the RenderLayer's position in the scene.
|
|
6874
|
-
* @readonly
|
|
6875
|
-
* @advanced
|
|
6876
|
-
*/
|
|
6877
|
-
this.parentRenderLayer = null;
|
|
6878
6861
|
// / /////////////Transform related props//////////////
|
|
6879
6862
|
// used by the transform system to check if a container needs to be updated that frame
|
|
6880
6863
|
// if the tick matches the current transform system tick, it is not updated again
|
|
@@ -7950,6 +7933,7 @@ extensions.mixin(
|
|
|
7950
7933
|
);
|
|
7951
7934
|
|
|
7952
7935
|
class ViewContainer extends Container {
|
|
7936
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
7953
7937
|
constructor(options) {
|
|
7954
7938
|
super(options);
|
|
7955
7939
|
/** @internal */
|
|
@@ -7962,13 +7946,8 @@ class ViewContainer extends Container {
|
|
|
7962
7946
|
this._lastUsed = -1;
|
|
7963
7947
|
/** @internal */
|
|
7964
7948
|
this._gpuData = /* @__PURE__ */ Object.create(null);
|
|
7965
|
-
/** If set to true, the resource will be garbage collected automatically when it is not used. */
|
|
7966
|
-
this.autoGarbageCollect = true;
|
|
7967
|
-
/** @internal */
|
|
7968
|
-
this._gcLastUsed = -1;
|
|
7969
7949
|
this._bounds = new Bounds(0, 1, 0, 0);
|
|
7970
7950
|
this._boundsDirty = true;
|
|
7971
|
-
this.autoGarbageCollect = options.autoGarbageCollect ?? true;
|
|
7972
7951
|
}
|
|
7973
7952
|
/**
|
|
7974
7953
|
* The local bounds of the view in its own coordinate space.
|
|
@@ -8037,19 +8016,13 @@ class ViewContainer extends Container {
|
|
|
8037
8016
|
renderGroup.onChildViewUpdate(this);
|
|
8038
8017
|
}
|
|
8039
8018
|
}
|
|
8040
|
-
/** Unloads the GPU data from the view. */
|
|
8041
|
-
unload() {
|
|
8042
|
-
this.emit("unload", this);
|
|
8043
|
-
for (const key in this._gpuData) {
|
|
8044
|
-
this._gpuData[key]?.destroy();
|
|
8045
|
-
}
|
|
8046
|
-
this._gpuData = /* @__PURE__ */ Object.create(null);
|
|
8047
|
-
this.onViewUpdate();
|
|
8048
|
-
}
|
|
8049
8019
|
destroy(options) {
|
|
8050
|
-
this.unload();
|
|
8051
8020
|
super.destroy(options);
|
|
8052
8021
|
this._bounds = null;
|
|
8022
|
+
for (const key in this._gpuData) {
|
|
8023
|
+
this._gpuData[key].destroy?.();
|
|
8024
|
+
}
|
|
8025
|
+
this._gpuData = null;
|
|
8053
8026
|
}
|
|
8054
8027
|
/**
|
|
8055
8028
|
* Collects renderables for the view container.
|
|
@@ -8241,6 +8214,7 @@ class Sprite extends ViewContainer {
|
|
|
8241
8214
|
this._visualBounds = null;
|
|
8242
8215
|
this._bounds = null;
|
|
8243
8216
|
this._anchor = null;
|
|
8217
|
+
this._gpuData = null;
|
|
8244
8218
|
}
|
|
8245
8219
|
/**
|
|
8246
8220
|
* The anchor sets the origin point of the sprite. The default value is taken from the {@link Texture}
|
|
@@ -8453,8 +8427,6 @@ class AlphaMask {
|
|
|
8453
8427
|
this.mask.measurable = false;
|
|
8454
8428
|
}
|
|
8455
8429
|
reset() {
|
|
8456
|
-
if (this.mask === null)
|
|
8457
|
-
return;
|
|
8458
8430
|
this.mask.measurable = true;
|
|
8459
8431
|
this.mask = null;
|
|
8460
8432
|
}
|
|
@@ -8512,8 +8484,6 @@ class StencilMask {
|
|
|
8512
8484
|
this.mask.measurable = false;
|
|
8513
8485
|
}
|
|
8514
8486
|
reset() {
|
|
8515
|
-
if (this.mask === null)
|
|
8516
|
-
return;
|
|
8517
8487
|
this.mask.measurable = true;
|
|
8518
8488
|
this.mask.includeInBuild = true;
|
|
8519
8489
|
this.mask = null;
|
|
@@ -8770,6 +8740,7 @@ const _Ticker = class _Ticker {
|
|
|
8770
8740
|
*
|
|
8771
8741
|
* This is NOT in milliseconds - it's a scalar multiplier for frame-independent animations.
|
|
8772
8742
|
* For actual milliseconds, use {@link Ticker#deltaMS}.
|
|
8743
|
+
* @member {number}
|
|
8773
8744
|
* @example
|
|
8774
8745
|
* ```ts
|
|
8775
8746
|
* // Frame-independent animation using deltaTime scalar
|
|
@@ -8785,6 +8756,7 @@ const _Ticker = class _Ticker {
|
|
|
8785
8756
|
* Similar to performance.now() timestamp format.
|
|
8786
8757
|
*
|
|
8787
8758
|
* Used internally for calculating time deltas between frames.
|
|
8759
|
+
* @member {number}
|
|
8788
8760
|
* @example
|
|
8789
8761
|
* ```ts
|
|
8790
8762
|
* ticker.add((ticker) => {
|
|
@@ -10802,12 +10774,7 @@ class Resolver {
|
|
|
10802
10774
|
const assetArray = convertToList(assets);
|
|
10803
10775
|
assetArray.forEach((asset) => {
|
|
10804
10776
|
const { src } = asset;
|
|
10805
|
-
let {
|
|
10806
|
-
data,
|
|
10807
|
-
format,
|
|
10808
|
-
loadParser: userDefinedLoadParser,
|
|
10809
|
-
parser: userDefinedParser
|
|
10810
|
-
} = asset;
|
|
10777
|
+
let { data, format, loadParser: userDefinedLoadParser, parser: userDefinedParser } = asset;
|
|
10811
10778
|
const srcsToUse = convertToList(src).map((src2) => {
|
|
10812
10779
|
if (typeof src2 === "string") {
|
|
10813
10780
|
return createStringVariations(src2);
|
|
@@ -10817,18 +10784,18 @@ class Resolver {
|
|
|
10817
10784
|
const aliasesToUse = this.getAlias(asset);
|
|
10818
10785
|
Array.isArray(aliasesToUse) ? aliasesToUse.forEach(keyCheck) : keyCheck(aliasesToUse);
|
|
10819
10786
|
const resolvedAssets = [];
|
|
10820
|
-
const parseUrl = (url) => {
|
|
10821
|
-
const parser = this._parsers.find((p) => p.test(url));
|
|
10822
|
-
return {
|
|
10823
|
-
...parser?.parse(url),
|
|
10824
|
-
src: url
|
|
10825
|
-
};
|
|
10826
|
-
};
|
|
10827
10787
|
srcsToUse.forEach((srcs) => {
|
|
10828
10788
|
srcs.forEach((src2) => {
|
|
10829
10789
|
let formattedAsset = {};
|
|
10830
10790
|
if (typeof src2 !== "object") {
|
|
10831
|
-
formattedAsset =
|
|
10791
|
+
formattedAsset.src = src2;
|
|
10792
|
+
for (let i = 0; i < this._parsers.length; i++) {
|
|
10793
|
+
const parser = this._parsers[i];
|
|
10794
|
+
if (parser.test(src2)) {
|
|
10795
|
+
formattedAsset = parser.parse(src2);
|
|
10796
|
+
break;
|
|
10797
|
+
}
|
|
10798
|
+
}
|
|
10832
10799
|
} else {
|
|
10833
10800
|
data = src2.data ?? data;
|
|
10834
10801
|
format = src2.format ?? format;
|
|
@@ -10837,7 +10804,7 @@ class Resolver {
|
|
|
10837
10804
|
userDefinedParser = src2.parser ?? userDefinedParser;
|
|
10838
10805
|
}
|
|
10839
10806
|
formattedAsset = {
|
|
10840
|
-
...
|
|
10807
|
+
...formattedAsset,
|
|
10841
10808
|
...src2
|
|
10842
10809
|
};
|
|
10843
10810
|
}
|
|
@@ -10849,8 +10816,7 @@ class Resolver {
|
|
|
10849
10816
|
data,
|
|
10850
10817
|
format,
|
|
10851
10818
|
loadParser: userDefinedLoadParser,
|
|
10852
|
-
parser: userDefinedParser
|
|
10853
|
-
progressSize: asset.progressSize
|
|
10819
|
+
parser: userDefinedParser
|
|
10854
10820
|
});
|
|
10855
10821
|
resolvedAssets.push(formattedAsset);
|
|
10856
10822
|
});
|
|
@@ -11010,7 +10976,7 @@ class Resolver {
|
|
|
11010
10976
|
return `${url}${paramConnector}${this._defaultSearchParams}`;
|
|
11011
10977
|
}
|
|
11012
10978
|
_buildResolvedAsset(formattedAsset, data) {
|
|
11013
|
-
const { aliases, data: assetData, loadParser, parser, format
|
|
10979
|
+
const { aliases, data: assetData, loadParser, parser, format } = data;
|
|
11014
10980
|
if (this._basePath || this._rootPath) {
|
|
11015
10981
|
formattedAsset.src = path.toAbsolute(formattedAsset.src, this._basePath, this._rootPath);
|
|
11016
10982
|
}
|
|
@@ -11020,9 +10986,6 @@ class Resolver {
|
|
|
11020
10986
|
formattedAsset.loadParser = loadParser ?? formattedAsset.loadParser;
|
|
11021
10987
|
formattedAsset.parser = parser ?? formattedAsset.parser;
|
|
11022
10988
|
formattedAsset.format = format ?? formattedAsset.format ?? getUrlExtension(formattedAsset.src);
|
|
11023
|
-
if (progressSize !== void 0) {
|
|
11024
|
-
formattedAsset.progressSize = progressSize;
|
|
11025
|
-
}
|
|
11026
10989
|
return formattedAsset;
|
|
11027
10990
|
}
|
|
11028
10991
|
}
|
|
@@ -11799,7 +11762,7 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
11799
11762
|
/** This is the dom element that will sit over the PixiJS element. This is where the div overlays will go. */
|
|
11800
11763
|
this._div = null;
|
|
11801
11764
|
/** A simple pool for storing divs. */
|
|
11802
|
-
this.
|
|
11765
|
+
this._pool = [];
|
|
11803
11766
|
/** This is a tick used to check if an object is no longer being rendered. */
|
|
11804
11767
|
this._renderId = 0;
|
|
11805
11768
|
/** The array of currently active accessible items. */
|
|
@@ -11808,11 +11771,6 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
11808
11771
|
this._androidUpdateCount = 0;
|
|
11809
11772
|
/** The frequency to update the div elements. */
|
|
11810
11773
|
this._androidUpdateFrequency = 500;
|
|
11811
|
-
// eslint-disable-next-line @typescript-eslint/prefer-readonly
|
|
11812
|
-
this._isRunningTests = false;
|
|
11813
|
-
/** Bound function references for proper event listener removal */
|
|
11814
|
-
this._boundOnKeyDown = this._onKeyDown.bind(this);
|
|
11815
|
-
this._boundOnMouseMove = this._onMouseMove.bind(this);
|
|
11816
11774
|
this._hookDiv = null;
|
|
11817
11775
|
if (_mobileInfo.tablet || _mobileInfo.phone) {
|
|
11818
11776
|
this._createTouchHook();
|
|
@@ -11836,19 +11794,12 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
11836
11794
|
return this._isMobileAccessibility;
|
|
11837
11795
|
}
|
|
11838
11796
|
/**
|
|
11839
|
-
*
|
|
11797
|
+
* The DOM element that will sit over the PixiJS element. This is where the div overlays will go.
|
|
11840
11798
|
* @readonly
|
|
11841
11799
|
*/
|
|
11842
11800
|
get hookDiv() {
|
|
11843
11801
|
return this._hookDiv;
|
|
11844
11802
|
}
|
|
11845
|
-
/**
|
|
11846
|
-
* The DOM element that will sit over the PixiJS element. This is where the div overlays will go.
|
|
11847
|
-
* @readonly
|
|
11848
|
-
*/
|
|
11849
|
-
get div() {
|
|
11850
|
-
return this._div;
|
|
11851
|
-
}
|
|
11852
11803
|
/**
|
|
11853
11804
|
* Creates the touch hooks.
|
|
11854
11805
|
* @private
|
|
@@ -11905,10 +11856,12 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
11905
11856
|
});
|
|
11906
11857
|
}
|
|
11907
11858
|
if (this._activateOnTab) {
|
|
11908
|
-
|
|
11859
|
+
this._onKeyDown = this._onKeyDown.bind(this);
|
|
11860
|
+
globalThis.addEventListener("keydown", this._onKeyDown, false);
|
|
11909
11861
|
}
|
|
11910
11862
|
if (this._deactivateOnMouseMove) {
|
|
11911
|
-
|
|
11863
|
+
this._onMouseMove = this._onMouseMove.bind(this);
|
|
11864
|
+
globalThis.document.addEventListener("mousemove", this._onMouseMove, true);
|
|
11912
11865
|
}
|
|
11913
11866
|
const canvas = this._renderer.view.canvas;
|
|
11914
11867
|
if (!canvas.parentNode) {
|
|
@@ -11941,31 +11894,27 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
11941
11894
|
return;
|
|
11942
11895
|
}
|
|
11943
11896
|
this._isActive = false;
|
|
11944
|
-
globalThis.document.removeEventListener("mousemove", this.
|
|
11897
|
+
globalThis.document.removeEventListener("mousemove", this._onMouseMove, true);
|
|
11945
11898
|
if (this._activateOnTab) {
|
|
11946
|
-
globalThis.addEventListener("keydown", this.
|
|
11899
|
+
globalThis.addEventListener("keydown", this._onKeyDown, false);
|
|
11947
11900
|
}
|
|
11948
11901
|
this._renderer.runners.postrender.remove(this);
|
|
11949
11902
|
for (const child of this._children) {
|
|
11950
|
-
if (child._accessibleDiv
|
|
11903
|
+
if (child._accessibleDiv && child._accessibleDiv.parentNode) {
|
|
11951
11904
|
child._accessibleDiv.parentNode.removeChild(child._accessibleDiv);
|
|
11952
11905
|
child._accessibleDiv = null;
|
|
11953
11906
|
}
|
|
11954
11907
|
child._accessibleActive = false;
|
|
11955
11908
|
}
|
|
11956
|
-
|
|
11957
|
-
|
|
11958
|
-
|
|
11959
|
-
|
|
11960
|
-
|
|
11961
|
-
|
|
11962
|
-
});
|
|
11963
|
-
delete this._pools[accessibleType];
|
|
11964
|
-
}
|
|
11965
|
-
if (this._div?.parentNode) {
|
|
11909
|
+
this._pool.forEach((div) => {
|
|
11910
|
+
if (div.parentNode) {
|
|
11911
|
+
div.parentNode.removeChild(div);
|
|
11912
|
+
}
|
|
11913
|
+
});
|
|
11914
|
+
if (this._div && this._div.parentNode) {
|
|
11966
11915
|
this._div.parentNode.removeChild(this._div);
|
|
11967
11916
|
}
|
|
11968
|
-
this.
|
|
11917
|
+
this._pool = [];
|
|
11969
11918
|
this._children = [];
|
|
11970
11919
|
}
|
|
11971
11920
|
/**
|
|
@@ -12007,6 +11956,9 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
12007
11956
|
this._deactivateOnMouseMove = mergedOptions.accessibilityOptions.deactivateOnMouseMove;
|
|
12008
11957
|
if (mergedOptions.accessibilityOptions.enabledByDefault) {
|
|
12009
11958
|
this._activate();
|
|
11959
|
+
} else if (this._activateOnTab) {
|
|
11960
|
+
this._onKeyDown = this._onKeyDown.bind(this);
|
|
11961
|
+
globalThis.addEventListener("keydown", this._onKeyDown, false);
|
|
12010
11962
|
}
|
|
12011
11963
|
this._renderer.runners.postrender.remove(this);
|
|
12012
11964
|
}
|
|
@@ -12024,7 +11976,7 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
12024
11976
|
return;
|
|
12025
11977
|
}
|
|
12026
11978
|
this._androidUpdateCount = now + this._androidUpdateFrequency;
|
|
12027
|
-
if (
|
|
11979
|
+
if (!this._renderer.renderingToScreen || !this._renderer.view.canvas) {
|
|
12028
11980
|
return;
|
|
12029
11981
|
}
|
|
12030
11982
|
const activeIds = /* @__PURE__ */ new Set();
|
|
@@ -12041,8 +11993,7 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
12041
11993
|
if (!activeIds.has(i)) {
|
|
12042
11994
|
if (child._accessibleDiv && child._accessibleDiv.parentNode) {
|
|
12043
11995
|
child._accessibleDiv.parentNode.removeChild(child._accessibleDiv);
|
|
12044
|
-
|
|
12045
|
-
pool.push(child._accessibleDiv);
|
|
11996
|
+
this._pool.push(child._accessibleDiv);
|
|
12046
11997
|
child._accessibleDiv = null;
|
|
12047
11998
|
}
|
|
12048
11999
|
child._accessibleActive = false;
|
|
@@ -12111,14 +12062,8 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
12111
12062
|
* @param {Container} container - The child to make accessible.
|
|
12112
12063
|
*/
|
|
12113
12064
|
_addChild(container) {
|
|
12114
|
-
|
|
12115
|
-
|
|
12116
|
-
if (div) {
|
|
12117
|
-
div.innerHTML = "";
|
|
12118
|
-
div.removeAttribute("title");
|
|
12119
|
-
div.removeAttribute("aria-label");
|
|
12120
|
-
div.tabIndex = 0;
|
|
12121
|
-
} else {
|
|
12065
|
+
let div = this._pool.pop();
|
|
12066
|
+
if (!div) {
|
|
12122
12067
|
if (container.accessibleType === "button") {
|
|
12123
12068
|
div = document.createElement("button");
|
|
12124
12069
|
} else {
|
|
@@ -12261,14 +12206,12 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
12261
12206
|
this._canvasObserver?.destroy();
|
|
12262
12207
|
this._canvasObserver = null;
|
|
12263
12208
|
this._div = null;
|
|
12264
|
-
this.
|
|
12209
|
+
this._pool = null;
|
|
12265
12210
|
this._children = null;
|
|
12266
12211
|
this._renderer = null;
|
|
12267
|
-
this.
|
|
12268
|
-
|
|
12269
|
-
|
|
12270
|
-
globalThis.document.removeEventListener("mousemove", this._boundOnMouseMove, true);
|
|
12271
|
-
this._boundOnMouseMove = null;
|
|
12212
|
+
if (this._activateOnTab) {
|
|
12213
|
+
globalThis.removeEventListener("keydown", this._onKeyDown);
|
|
12214
|
+
}
|
|
12272
12215
|
}
|
|
12273
12216
|
/**
|
|
12274
12217
|
* Enables or disables the accessibility system.
|
|
@@ -12286,12 +12229,6 @@ const _AccessibilitySystem = class _AccessibilitySystem {
|
|
|
12286
12229
|
this._deactivate();
|
|
12287
12230
|
}
|
|
12288
12231
|
}
|
|
12289
|
-
_getPool(accessibleType) {
|
|
12290
|
-
if (!this._pools[accessibleType]) {
|
|
12291
|
-
this._pools[accessibleType] = [];
|
|
12292
|
-
}
|
|
12293
|
-
return this._pools[accessibleType];
|
|
12294
|
-
}
|
|
12295
12232
|
};
|
|
12296
12233
|
/** @ignore */
|
|
12297
12234
|
_AccessibilitySystem.extension = {
|
|
@@ -13018,14 +12955,12 @@ class BindGroup {
|
|
|
13018
12955
|
/**
|
|
13019
12956
|
* Used internally to 'touch' each resource, to ensure that the GC
|
|
13020
12957
|
* knows that all resources in this bind group are still being used.
|
|
13021
|
-
* @param now - The current time in milliseconds.
|
|
13022
12958
|
* @param tick - The current tick.
|
|
13023
12959
|
* @internal
|
|
13024
12960
|
*/
|
|
13025
|
-
_touch(
|
|
12961
|
+
_touch(tick) {
|
|
13026
12962
|
const resources = this.resources;
|
|
13027
12963
|
for (const i in resources) {
|
|
13028
|
-
resources[i]._gcLastUsed = now;
|
|
13029
12964
|
resources[i]._touched = tick;
|
|
13030
12965
|
}
|
|
13031
12966
|
}
|
|
@@ -13072,8 +13007,6 @@ class Shader extends EventEmitter {
|
|
|
13072
13007
|
*/
|
|
13073
13008
|
this._uniformBindMap = /* @__PURE__ */ Object.create(null);
|
|
13074
13009
|
this._ownedBindGroups = [];
|
|
13075
|
-
/** @internal */
|
|
13076
|
-
this._destroyed = false;
|
|
13077
13010
|
let {
|
|
13078
13011
|
gpuProgram,
|
|
13079
13012
|
glProgram,
|
|
@@ -13201,9 +13134,6 @@ class Shader extends EventEmitter {
|
|
|
13201
13134
|
* Make sure its not being used by other shaders!
|
|
13202
13135
|
*/
|
|
13203
13136
|
destroy(destroyPrograms = false) {
|
|
13204
|
-
if (this._destroyed)
|
|
13205
|
-
return;
|
|
13206
|
-
this._destroyed = true;
|
|
13207
13137
|
this.emit("destroy", this);
|
|
13208
13138
|
if (destroyPrograms) {
|
|
13209
13139
|
this.gpuProgram?.destroy();
|
|
@@ -13418,9 +13348,6 @@ const _Filter = class _Filter extends Shader {
|
|
|
13418
13348
|
this.blendRequired = options.blendRequired;
|
|
13419
13349
|
this.clipToViewport = options.clipToViewport;
|
|
13420
13350
|
this.addResource("uTexture", 0, 1);
|
|
13421
|
-
if (options.blendRequired) {
|
|
13422
|
-
this.addResource("uBackTexture", 0, 3);
|
|
13423
|
-
}
|
|
13424
13351
|
}
|
|
13425
13352
|
/**
|
|
13426
13353
|
* Applies the filter
|
|
@@ -14262,8 +14189,6 @@ const _AbstractRenderer = class _AbstractRenderer extends EventEmitter {
|
|
|
14262
14189
|
*/
|
|
14263
14190
|
constructor(config) {
|
|
14264
14191
|
super();
|
|
14265
|
-
/** The current tick of the renderer. */
|
|
14266
|
-
this.tick = 0;
|
|
14267
14192
|
/** @internal */
|
|
14268
14193
|
this.uid = uid$1("renderer");
|
|
14269
14194
|
/** @internal */
|
|
@@ -14301,7 +14226,6 @@ const _AbstractRenderer = class _AbstractRenderer extends EventEmitter {
|
|
|
14301
14226
|
this._initOptions = options;
|
|
14302
14227
|
}
|
|
14303
14228
|
render(args, deprecated) {
|
|
14304
|
-
this.tick++;
|
|
14305
14229
|
let options = args;
|
|
14306
14230
|
if (options instanceof Container) {
|
|
14307
14231
|
options = { container: options };
|
|
@@ -14477,12 +14401,12 @@ const _AbstractRenderer = class _AbstractRenderer extends EventEmitter {
|
|
|
14477
14401
|
destroy(options = false) {
|
|
14478
14402
|
this.runners.destroy.items.reverse();
|
|
14479
14403
|
this.runners.destroy.emit(options);
|
|
14480
|
-
if (options === true || typeof options === "object" && options.releaseGlobalResources) {
|
|
14481
|
-
GlobalResourceRegistry.release();
|
|
14482
|
-
}
|
|
14483
14404
|
Object.values(this.runners).forEach((runner) => {
|
|
14484
14405
|
runner.destroy();
|
|
14485
14406
|
});
|
|
14407
|
+
if (options === true || typeof options === "object" && options.releaseGlobalResources) {
|
|
14408
|
+
GlobalResourceRegistry.release();
|
|
14409
|
+
}
|
|
14486
14410
|
this._systemsHash = null;
|
|
14487
14411
|
this.renderPipes = null;
|
|
14488
14412
|
}
|
|
@@ -14671,7 +14595,7 @@ async function autoDetectRenderer(options) {
|
|
|
14671
14595
|
return renderer;
|
|
14672
14596
|
}
|
|
14673
14597
|
|
|
14674
|
-
const VERSION = "8.
|
|
14598
|
+
const VERSION = "8.13.2";
|
|
14675
14599
|
|
|
14676
14600
|
class ApplicationInitHook {
|
|
14677
14601
|
static init() {
|
|
@@ -14745,7 +14669,6 @@ const _Application = class _Application {
|
|
|
14745
14669
|
*/
|
|
14746
14670
|
async init(options) {
|
|
14747
14671
|
options = { ...options };
|
|
14748
|
-
this.stage || (this.stage = new Container());
|
|
14749
14672
|
this.renderer = await autoDetectRenderer(options);
|
|
14750
14673
|
_Application._plugins.forEach((plugin) => {
|
|
14751
14674
|
plugin.init.call(this, options);
|
|
@@ -14911,7 +14834,6 @@ class ResizePlugin {
|
|
|
14911
14834
|
this,
|
|
14912
14835
|
"resizeTo",
|
|
14913
14836
|
{
|
|
14914
|
-
configurable: true,
|
|
14915
14837
|
set(dom) {
|
|
14916
14838
|
globalThis.removeEventListener("resize", this.queueResize);
|
|
14917
14839
|
this._resizeTo = dom;
|
|
@@ -14991,7 +14913,6 @@ class TickerPlugin {
|
|
|
14991
14913
|
this,
|
|
14992
14914
|
"ticker",
|
|
14993
14915
|
{
|
|
14994
|
-
configurable: true,
|
|
14995
14916
|
set(ticker) {
|
|
14996
14917
|
if (this._ticker) {
|
|
14997
14918
|
this._ticker.remove(this.render, this);
|
|
@@ -15122,9 +15043,9 @@ class AbstractBitmapFont extends EventEmitter {
|
|
|
15122
15043
|
/**
|
|
15123
15044
|
* tiny-lru
|
|
15124
15045
|
*
|
|
15125
|
-
* @copyright
|
|
15046
|
+
* @copyright 2025 Jason Mulligan <jason.mulligan@avoidwork.com>
|
|
15126
15047
|
* @license BSD-3-Clause
|
|
15127
|
-
* @version 11.4.
|
|
15048
|
+
* @version 11.4.5
|
|
15128
15049
|
*/
|
|
15129
15050
|
/**
|
|
15130
15051
|
* A high-performance Least Recently Used (LRU) cache implementation with optional TTL support.
|
|
@@ -15247,13 +15168,7 @@ class LRU {
|
|
|
15247
15168
|
* @since 11.1.0
|
|
15248
15169
|
*/
|
|
15249
15170
|
entries (keys = this.keys()) {
|
|
15250
|
-
|
|
15251
|
-
for (let i = 0; i < keys.length; i++) {
|
|
15252
|
-
const key = keys[i];
|
|
15253
|
-
result[i] = [key, this.get(key)];
|
|
15254
|
-
}
|
|
15255
|
-
|
|
15256
|
-
return result;
|
|
15171
|
+
return keys.map(key => [key, this.get(key)]);
|
|
15257
15172
|
}
|
|
15258
15173
|
|
|
15259
15174
|
/**
|
|
@@ -15430,12 +15345,11 @@ class LRU {
|
|
|
15430
15345
|
* @since 9.0.0
|
|
15431
15346
|
*/
|
|
15432
15347
|
keys () {
|
|
15433
|
-
const result =
|
|
15348
|
+
const result = [];
|
|
15434
15349
|
let x = this.first;
|
|
15435
|
-
let i = 0;
|
|
15436
15350
|
|
|
15437
15351
|
while (x !== null) {
|
|
15438
|
-
result
|
|
15352
|
+
result.push(x.key);
|
|
15439
15353
|
x = x.next;
|
|
15440
15354
|
}
|
|
15441
15355
|
|
|
@@ -15564,12 +15478,7 @@ class LRU {
|
|
|
15564
15478
|
* @since 11.1.0
|
|
15565
15479
|
*/
|
|
15566
15480
|
values (keys = this.keys()) {
|
|
15567
|
-
|
|
15568
|
-
for (let i = 0; i < keys.length; i++) {
|
|
15569
|
-
result[i] = this.get(keys[i]);
|
|
15570
|
-
}
|
|
15571
|
-
|
|
15572
|
-
return result;
|
|
15481
|
+
return keys.map(key => this.get(key));
|
|
15573
15482
|
}
|
|
15574
15483
|
}
|
|
15575
15484
|
|
|
@@ -17929,15 +17838,13 @@ class ViewableBuffer {
|
|
|
17929
17838
|
/** Destroys all buffer references. Do not use after calling this. */
|
|
17930
17839
|
destroy() {
|
|
17931
17840
|
this.rawBinaryData = null;
|
|
17932
|
-
this.uint32View = null;
|
|
17933
|
-
this.float32View = null;
|
|
17934
|
-
this.uint16View = null;
|
|
17935
17841
|
this._int8View = null;
|
|
17936
17842
|
this._uint8View = null;
|
|
17937
17843
|
this._int16View = null;
|
|
17844
|
+
this.uint16View = null;
|
|
17938
17845
|
this._int32View = null;
|
|
17939
|
-
this.
|
|
17940
|
-
this.
|
|
17846
|
+
this.uint32View = null;
|
|
17847
|
+
this.float32View = null;
|
|
17941
17848
|
}
|
|
17942
17849
|
/**
|
|
17943
17850
|
* Returns the size of the given type in bytes.
|
|
@@ -18400,24 +18307,13 @@ const _Batcher = class _Batcher {
|
|
|
18400
18307
|
indexBuffer[index++] = indicesOffset + indices[i + indexOffset] - attributeOffset;
|
|
18401
18308
|
}
|
|
18402
18309
|
}
|
|
18403
|
-
|
|
18404
|
-
* Destroys the batch and its resources.
|
|
18405
|
-
* @param options - destruction options
|
|
18406
|
-
* @param options.shader - whether to destroy the associated shader
|
|
18407
|
-
*/
|
|
18408
|
-
destroy(options = {}) {
|
|
18310
|
+
destroy() {
|
|
18409
18311
|
if (this.batches === null)
|
|
18410
18312
|
return;
|
|
18411
|
-
for (let i = 0; i < this.
|
|
18313
|
+
for (let i = 0; i < this.batches.length; i++) {
|
|
18412
18314
|
returnBatchToPool(this.batches[i]);
|
|
18413
18315
|
}
|
|
18414
18316
|
this.batches = null;
|
|
18415
|
-
this.geometry.destroy(true);
|
|
18416
|
-
this.geometry = null;
|
|
18417
|
-
if (options.shader) {
|
|
18418
|
-
this.shader?.destroy();
|
|
18419
|
-
this.shader = null;
|
|
18420
|
-
}
|
|
18421
18317
|
for (let i = 0; i < this._elements.length; i++) {
|
|
18422
18318
|
if (this._elements[i])
|
|
18423
18319
|
this._elements[i]._batch = null;
|
|
@@ -18473,12 +18369,6 @@ class Buffer extends EventEmitter {
|
|
|
18473
18369
|
* emits when the buffer is destroyed. letting the renderer know that it needs to destroy the buffer on the GPU
|
|
18474
18370
|
* @event destroy
|
|
18475
18371
|
*/
|
|
18476
|
-
/** @internal */
|
|
18477
|
-
this._gpuData = /* @__PURE__ */ Object.create(null);
|
|
18478
|
-
/** @internal */
|
|
18479
|
-
this._gcLastUsed = -1;
|
|
18480
|
-
/** If set to true, the buffer will be garbage collected automatically when it is not used. */
|
|
18481
|
-
this.autoGarbageCollect = true;
|
|
18482
18372
|
/** a unique id for this uniform group used through the renderer */
|
|
18483
18373
|
this.uid = uid$1("buffer");
|
|
18484
18374
|
/**
|
|
@@ -18594,18 +18484,9 @@ class Buffer extends EventEmitter {
|
|
|
18594
18484
|
this._updateID++;
|
|
18595
18485
|
this.emit("update", this);
|
|
18596
18486
|
}
|
|
18597
|
-
/** Unloads the buffer from the GPU */
|
|
18598
|
-
unload() {
|
|
18599
|
-
this.emit("unload", this);
|
|
18600
|
-
for (const key in this._gpuData) {
|
|
18601
|
-
this._gpuData[key]?.destroy();
|
|
18602
|
-
}
|
|
18603
|
-
this._gpuData = /* @__PURE__ */ Object.create(null);
|
|
18604
|
-
}
|
|
18605
18487
|
/** Destroys the buffer */
|
|
18606
18488
|
destroy() {
|
|
18607
18489
|
this.destroyed = true;
|
|
18608
|
-
this.unload();
|
|
18609
18490
|
this.emit("destroy", this);
|
|
18610
18491
|
this.emit("change", this);
|
|
18611
18492
|
this._data = null;
|
|
@@ -18687,12 +18568,6 @@ class Geometry extends EventEmitter {
|
|
|
18687
18568
|
*/
|
|
18688
18569
|
constructor(options = {}) {
|
|
18689
18570
|
super();
|
|
18690
|
-
/** @internal */
|
|
18691
|
-
this._gpuData = /* @__PURE__ */ Object.create(null);
|
|
18692
|
-
/** If set to true, the resource will be garbage collected automatically when it is not used. */
|
|
18693
|
-
this.autoGarbageCollect = true;
|
|
18694
|
-
/** @internal */
|
|
18695
|
-
this._gcLastUsed = -1;
|
|
18696
18571
|
/** The unique id of the geometry. */
|
|
18697
18572
|
this.uid = uid$1("geometry");
|
|
18698
18573
|
/**
|
|
@@ -18788,14 +18663,6 @@ class Geometry extends EventEmitter {
|
|
|
18788
18663
|
this._boundsDirty = false;
|
|
18789
18664
|
return getGeometryBounds(this, "aPosition", this._bounds);
|
|
18790
18665
|
}
|
|
18791
|
-
/** Unloads the geometry from the GPU. */
|
|
18792
|
-
unload() {
|
|
18793
|
-
this.emit("unload", this);
|
|
18794
|
-
for (const key in this._gpuData) {
|
|
18795
|
-
this._gpuData[key]?.destroy();
|
|
18796
|
-
}
|
|
18797
|
-
this._gpuData = /* @__PURE__ */ Object.create(null);
|
|
18798
|
-
}
|
|
18799
18666
|
/**
|
|
18800
18667
|
* destroys the geometry.
|
|
18801
18668
|
* @param destroyBuffers - destroy the buffers associated with this geometry
|
|
@@ -18806,8 +18673,6 @@ class Geometry extends EventEmitter {
|
|
|
18806
18673
|
if (destroyBuffers) {
|
|
18807
18674
|
this.buffers.forEach((buffer) => buffer.destroy());
|
|
18808
18675
|
}
|
|
18809
|
-
this.unload();
|
|
18810
|
-
this.indexBuffer?.destroy();
|
|
18811
18676
|
this.attributes = null;
|
|
18812
18677
|
this.buffers = null;
|
|
18813
18678
|
this.indexBuffer = null;
|
|
@@ -19483,7 +19348,6 @@ class DefaultShader extends Shader {
|
|
|
19483
19348
|
batchSamplers: getBatchSamplersUniformGroup(maxTextures)
|
|
19484
19349
|
}
|
|
19485
19350
|
});
|
|
19486
|
-
this.maxTextures = maxTextures;
|
|
19487
19351
|
}
|
|
19488
19352
|
}
|
|
19489
19353
|
|
|
@@ -19581,21 +19445,6 @@ const _DefaultBatcher = class _DefaultBatcher extends Batcher {
|
|
|
19581
19445
|
uint32View[index + 22] = argb;
|
|
19582
19446
|
uint32View[index + 23] = textureIdAndRound;
|
|
19583
19447
|
}
|
|
19584
|
-
/**
|
|
19585
|
-
* Updates the maximum number of textures that can be used in the shader.
|
|
19586
|
-
* @param maxTextures - The maximum number of textures that can be used in the shader.
|
|
19587
|
-
* @internal
|
|
19588
|
-
*/
|
|
19589
|
-
_updateMaxTextures(maxTextures) {
|
|
19590
|
-
if (this.shader.maxTextures === maxTextures)
|
|
19591
|
-
return;
|
|
19592
|
-
defaultShader = new DefaultShader(maxTextures);
|
|
19593
|
-
this.shader = defaultShader;
|
|
19594
|
-
}
|
|
19595
|
-
destroy() {
|
|
19596
|
-
this.shader = null;
|
|
19597
|
-
super.destroy();
|
|
19598
|
-
}
|
|
19599
19448
|
};
|
|
19600
19449
|
/** @ignore */
|
|
19601
19450
|
_DefaultBatcher.extension = {
|
|
@@ -19606,51 +19455,6 @@ _DefaultBatcher.extension = {
|
|
|
19606
19455
|
};
|
|
19607
19456
|
let DefaultBatcher = _DefaultBatcher;
|
|
19608
19457
|
|
|
19609
|
-
class GCManagedHash {
|
|
19610
|
-
constructor(options) {
|
|
19611
|
-
// Exposed directly for GC system access
|
|
19612
|
-
this.items = /* @__PURE__ */ Object.create(null);
|
|
19613
|
-
const { renderer, type, onUnload, priority, name } = options;
|
|
19614
|
-
this._renderer = renderer;
|
|
19615
|
-
renderer.gc.addResourceHash(this, "items", type, priority ?? 0);
|
|
19616
|
-
this._onUnload = onUnload;
|
|
19617
|
-
this.name = name;
|
|
19618
|
-
}
|
|
19619
|
-
/**
|
|
19620
|
-
* Add an item to the hash. No-op if already added.
|
|
19621
|
-
* @param item
|
|
19622
|
-
* @returns true if the item was added, false if it was already in the hash
|
|
19623
|
-
*/
|
|
19624
|
-
add(item) {
|
|
19625
|
-
if (this.items[item.uid])
|
|
19626
|
-
return false;
|
|
19627
|
-
this.items[item.uid] = item;
|
|
19628
|
-
item.once("unload", this.remove, this);
|
|
19629
|
-
item._gcLastUsed = this._renderer.gc.now;
|
|
19630
|
-
return true;
|
|
19631
|
-
}
|
|
19632
|
-
remove(item, ...args) {
|
|
19633
|
-
if (!this.items[item.uid])
|
|
19634
|
-
return;
|
|
19635
|
-
const gpuData = item._gpuData[this._renderer.uid];
|
|
19636
|
-
if (!gpuData)
|
|
19637
|
-
return;
|
|
19638
|
-
this._onUnload?.(item, ...args);
|
|
19639
|
-
gpuData.destroy();
|
|
19640
|
-
item._gpuData[this._renderer.uid] = null;
|
|
19641
|
-
this.items[item.uid] = null;
|
|
19642
|
-
}
|
|
19643
|
-
removeAll(...args) {
|
|
19644
|
-
Object.values(this.items).forEach((item) => item && this.remove(item, ...args));
|
|
19645
|
-
}
|
|
19646
|
-
destroy(...args) {
|
|
19647
|
-
this.removeAll(...args);
|
|
19648
|
-
this.items = /* @__PURE__ */ Object.create(null);
|
|
19649
|
-
this._renderer = null;
|
|
19650
|
-
this._onUnload = null;
|
|
19651
|
-
}
|
|
19652
|
-
}
|
|
19653
|
-
|
|
19654
19458
|
function buildUvs(vertices, verticesStride, verticesOffset, uvs, uvsOffset, uvsStride, size, matrix = null) {
|
|
19655
19459
|
let index = 0;
|
|
19656
19460
|
verticesOffset *= verticesStride;
|
|
@@ -20618,36 +20422,15 @@ class GpuGraphicsContext {
|
|
|
20618
20422
|
indices: []
|
|
20619
20423
|
};
|
|
20620
20424
|
}
|
|
20621
|
-
reset() {
|
|
20622
|
-
if (this.batches) {
|
|
20623
|
-
this.batches.forEach((batch) => {
|
|
20624
|
-
BigPool.return(batch);
|
|
20625
|
-
});
|
|
20626
|
-
}
|
|
20627
|
-
if (this.graphicsData) {
|
|
20628
|
-
BigPool.return(this.graphicsData);
|
|
20629
|
-
}
|
|
20630
|
-
this.isBatchable = false;
|
|
20631
|
-
this.context = null;
|
|
20632
|
-
this.batches.length = 0;
|
|
20633
|
-
this.geometryData.indices.length = 0;
|
|
20634
|
-
this.geometryData.vertices.length = 0;
|
|
20635
|
-
this.geometryData.uvs.length = 0;
|
|
20636
|
-
this.graphicsData = null;
|
|
20637
|
-
}
|
|
20638
|
-
destroy() {
|
|
20639
|
-
this.reset();
|
|
20640
|
-
this.batches = null;
|
|
20641
|
-
this.geometryData = null;
|
|
20642
|
-
}
|
|
20643
20425
|
}
|
|
20644
20426
|
class GraphicsContextRenderData {
|
|
20645
20427
|
constructor() {
|
|
20646
20428
|
this.instructions = new InstructionSet();
|
|
20647
20429
|
}
|
|
20648
|
-
init(
|
|
20649
|
-
|
|
20650
|
-
|
|
20430
|
+
init(maxTextures) {
|
|
20431
|
+
this.batcher = new DefaultBatcher({
|
|
20432
|
+
maxTextures
|
|
20433
|
+
});
|
|
20651
20434
|
this.instructions.reset();
|
|
20652
20435
|
}
|
|
20653
20436
|
/**
|
|
@@ -20668,8 +20451,14 @@ class GraphicsContextRenderData {
|
|
|
20668
20451
|
}
|
|
20669
20452
|
const _GraphicsContextSystem = class _GraphicsContextSystem {
|
|
20670
20453
|
constructor(renderer) {
|
|
20454
|
+
// the root context batches, used to either make a batch or geometry
|
|
20455
|
+
// all graphics use this as a base
|
|
20456
|
+
this._gpuContextHash = {};
|
|
20457
|
+
// used for non-batchable graphics
|
|
20458
|
+
this._graphicsDataContextHash = /* @__PURE__ */ Object.create(null);
|
|
20671
20459
|
this._renderer = renderer;
|
|
20672
|
-
|
|
20460
|
+
renderer.renderableGC.addManagedHash(this, "_gpuContextHash");
|
|
20461
|
+
renderer.renderableGC.addManagedHash(this, "_graphicsDataContextHash");
|
|
20673
20462
|
}
|
|
20674
20463
|
/**
|
|
20675
20464
|
* Runner init called, update the default options
|
|
@@ -20684,7 +20473,7 @@ const _GraphicsContextSystem = class _GraphicsContextSystem {
|
|
|
20684
20473
|
* @internal
|
|
20685
20474
|
*/
|
|
20686
20475
|
getContextRenderData(context) {
|
|
20687
|
-
return
|
|
20476
|
+
return this._graphicsDataContextHash[context.uid] || this._initContextRenderData(context);
|
|
20688
20477
|
}
|
|
20689
20478
|
/**
|
|
20690
20479
|
* Updates the GPU context for a given GraphicsContext.
|
|
@@ -20694,11 +20483,12 @@ const _GraphicsContextSystem = class _GraphicsContextSystem {
|
|
|
20694
20483
|
* @internal
|
|
20695
20484
|
*/
|
|
20696
20485
|
updateGpuContext(context) {
|
|
20697
|
-
|
|
20698
|
-
|
|
20699
|
-
|
|
20700
|
-
|
|
20701
|
-
|
|
20486
|
+
let gpuContext = this._gpuContextHash[context.uid] || this._initContext(context);
|
|
20487
|
+
if (context.dirty) {
|
|
20488
|
+
if (gpuContext) {
|
|
20489
|
+
this._cleanGraphicsContextData(context);
|
|
20490
|
+
} else {
|
|
20491
|
+
gpuContext = this._initContext(context);
|
|
20702
20492
|
}
|
|
20703
20493
|
buildContextBatches(context, gpuContext);
|
|
20704
20494
|
const batchMode = context.batchMode;
|
|
@@ -20721,15 +20511,13 @@ const _GraphicsContextSystem = class _GraphicsContextSystem {
|
|
|
20721
20511
|
* @internal
|
|
20722
20512
|
*/
|
|
20723
20513
|
getGpuContext(context) {
|
|
20724
|
-
return
|
|
20514
|
+
return this._gpuContextHash[context.uid] || this._initContext(context);
|
|
20725
20515
|
}
|
|
20726
20516
|
_initContextRenderData(context) {
|
|
20727
20517
|
const graphicsData = BigPool.get(GraphicsContextRenderData, {
|
|
20728
20518
|
maxTextures: this._renderer.limits.maxBatchableTextures
|
|
20729
20519
|
});
|
|
20730
|
-
const
|
|
20731
|
-
const { batches, geometryData } = gpuContext;
|
|
20732
|
-
gpuContext.graphicsData = graphicsData;
|
|
20520
|
+
const { batches, geometryData } = this._gpuContextHash[context.uid];
|
|
20733
20521
|
const vertexSize = geometryData.vertices.length;
|
|
20734
20522
|
const indexSize = geometryData.indices.length;
|
|
20735
20523
|
for (let i = 0; i < batches.length; i++) {
|
|
@@ -20756,18 +20544,41 @@ const _GraphicsContextSystem = class _GraphicsContextSystem {
|
|
|
20756
20544
|
this._renderer.limits.maxBatchableTextures
|
|
20757
20545
|
);
|
|
20758
20546
|
}
|
|
20547
|
+
this._graphicsDataContextHash[context.uid] = graphicsData;
|
|
20759
20548
|
return graphicsData;
|
|
20760
20549
|
}
|
|
20761
20550
|
_initContext(context) {
|
|
20762
20551
|
const gpuContext = new GpuGraphicsContext();
|
|
20763
20552
|
gpuContext.context = context;
|
|
20764
|
-
|
|
20765
|
-
this.
|
|
20766
|
-
return
|
|
20553
|
+
this._gpuContextHash[context.uid] = gpuContext;
|
|
20554
|
+
context.on("destroy", this.onGraphicsContextDestroy, this);
|
|
20555
|
+
return this._gpuContextHash[context.uid];
|
|
20556
|
+
}
|
|
20557
|
+
onGraphicsContextDestroy(context) {
|
|
20558
|
+
this._cleanGraphicsContextData(context);
|
|
20559
|
+
context.off("destroy", this.onGraphicsContextDestroy, this);
|
|
20560
|
+
this._gpuContextHash[context.uid] = null;
|
|
20561
|
+
}
|
|
20562
|
+
_cleanGraphicsContextData(context) {
|
|
20563
|
+
const gpuContext = this._gpuContextHash[context.uid];
|
|
20564
|
+
if (!gpuContext.isBatchable) {
|
|
20565
|
+
if (this._graphicsDataContextHash[context.uid]) {
|
|
20566
|
+
BigPool.return(this.getContextRenderData(context));
|
|
20567
|
+
this._graphicsDataContextHash[context.uid] = null;
|
|
20568
|
+
}
|
|
20569
|
+
}
|
|
20570
|
+
if (gpuContext.batches) {
|
|
20571
|
+
gpuContext.batches.forEach((batch) => {
|
|
20572
|
+
BigPool.return(batch);
|
|
20573
|
+
});
|
|
20574
|
+
}
|
|
20767
20575
|
}
|
|
20768
20576
|
destroy() {
|
|
20769
|
-
this.
|
|
20770
|
-
|
|
20577
|
+
for (const i in this._gpuContextHash) {
|
|
20578
|
+
if (this._gpuContextHash[i]) {
|
|
20579
|
+
this.onGraphicsContextDestroy(this._gpuContextHash[i].context);
|
|
20580
|
+
}
|
|
20581
|
+
}
|
|
20771
20582
|
}
|
|
20772
20583
|
};
|
|
20773
20584
|
/** @ignore */
|
|
@@ -22590,7 +22401,7 @@ function renderChildren(svg, session, fillStyle, strokeStyle) {
|
|
|
22590
22401
|
break;
|
|
22591
22402
|
case "polygon":
|
|
22592
22403
|
pointsString = svg.getAttribute("points");
|
|
22593
|
-
points = pointsString.match(
|
|
22404
|
+
points = pointsString.match(/\d+/g).map((n) => parseInt(n, 10));
|
|
22594
22405
|
session.context.poly(points, true);
|
|
22595
22406
|
if (fillStyle)
|
|
22596
22407
|
session.context.fill(fillStyle);
|
|
@@ -22599,7 +22410,7 @@ function renderChildren(svg, session, fillStyle, strokeStyle) {
|
|
|
22599
22410
|
break;
|
|
22600
22411
|
case "polyline":
|
|
22601
22412
|
pointsString = svg.getAttribute("points");
|
|
22602
|
-
points = pointsString.match(
|
|
22413
|
+
points = pointsString.match(/\d+/g).map((n) => parseInt(n, 10));
|
|
22603
22414
|
session.context.poly(points, false);
|
|
22604
22415
|
if (strokeStyle)
|
|
22605
22416
|
session.context.stroke(strokeStyle);
|
|
@@ -22709,12 +22520,6 @@ const tempMatrix$2 = new Matrix();
|
|
|
22709
22520
|
const _GraphicsContext = class _GraphicsContext extends EventEmitter {
|
|
22710
22521
|
constructor() {
|
|
22711
22522
|
super(...arguments);
|
|
22712
|
-
/** @internal */
|
|
22713
|
-
this._gpuData = /* @__PURE__ */ Object.create(null);
|
|
22714
|
-
/** If set to true, the resource will be garbage collected automatically when it is not used. */
|
|
22715
|
-
this.autoGarbageCollect = true;
|
|
22716
|
-
/** @internal */
|
|
22717
|
-
this._gcLastUsed = -1;
|
|
22718
22523
|
/**
|
|
22719
22524
|
* unique id for this graphics context
|
|
22720
22525
|
* @internal
|
|
@@ -22729,8 +22534,6 @@ const _GraphicsContext = class _GraphicsContext extends EventEmitter {
|
|
|
22729
22534
|
this.batchMode = "auto";
|
|
22730
22535
|
/** @internal */
|
|
22731
22536
|
this.instructions = [];
|
|
22732
|
-
/** Whether the graphics context has been destroyed. */
|
|
22733
|
-
this.destroyed = false;
|
|
22734
22537
|
this._activePath = new GraphicsPath();
|
|
22735
22538
|
this._transform = new Matrix();
|
|
22736
22539
|
this._fillStyle = { ..._GraphicsContext.defaultFillStyle };
|
|
@@ -22827,7 +22630,7 @@ const _GraphicsContext = class _GraphicsContext extends EventEmitter {
|
|
|
22827
22630
|
fill(style, alpha) {
|
|
22828
22631
|
let path;
|
|
22829
22632
|
const lastInstruction = this.instructions[this.instructions.length - 1];
|
|
22830
|
-
if (this._tick === 0 && lastInstruction
|
|
22633
|
+
if (this._tick === 0 && lastInstruction && lastInstruction.action === "stroke") {
|
|
22831
22634
|
path = lastInstruction.data.path;
|
|
22832
22635
|
} else {
|
|
22833
22636
|
path = this._activePath.clone();
|
|
@@ -22865,7 +22668,7 @@ const _GraphicsContext = class _GraphicsContext extends EventEmitter {
|
|
|
22865
22668
|
stroke(style) {
|
|
22866
22669
|
let path;
|
|
22867
22670
|
const lastInstruction = this.instructions[this.instructions.length - 1];
|
|
22868
|
-
if (this._tick === 0 && lastInstruction
|
|
22671
|
+
if (this._tick === 0 && lastInstruction && lastInstruction.action === "fill") {
|
|
22869
22672
|
path = lastInstruction.data.path;
|
|
22870
22673
|
} else {
|
|
22871
22674
|
path = this._activePath.clone();
|
|
@@ -23447,14 +23250,6 @@ const _GraphicsContext = class _GraphicsContext extends EventEmitter {
|
|
|
23447
23250
|
}
|
|
23448
23251
|
return hasHit;
|
|
23449
23252
|
}
|
|
23450
|
-
/** Unloads the GPU data from the graphics context. */
|
|
23451
|
-
unload() {
|
|
23452
|
-
this.emit("unload", this);
|
|
23453
|
-
for (const key in this._gpuData) {
|
|
23454
|
-
this._gpuData[key]?.destroy();
|
|
23455
|
-
}
|
|
23456
|
-
this._gpuData = /* @__PURE__ */ Object.create(null);
|
|
23457
|
-
}
|
|
23458
23253
|
/**
|
|
23459
23254
|
* Destroys the GraphicsData object.
|
|
23460
23255
|
* @param options - Options parameter. A boolean will act as if all options
|
|
@@ -23465,12 +23260,8 @@ const _GraphicsContext = class _GraphicsContext extends EventEmitter {
|
|
|
23465
23260
|
* context.destroy({ texture: true, textureSource: true });
|
|
23466
23261
|
*/
|
|
23467
23262
|
destroy(options = false) {
|
|
23468
|
-
if (this.destroyed)
|
|
23469
|
-
return;
|
|
23470
|
-
this.destroyed = true;
|
|
23471
23263
|
this._stateStack.length = 0;
|
|
23472
23264
|
this._transform = null;
|
|
23473
|
-
this.unload();
|
|
23474
23265
|
this.emit("destroy", this);
|
|
23475
23266
|
this.removeAllListeners();
|
|
23476
23267
|
const destroyTexture = typeof options === "boolean" ? options : options?.texture;
|
|
@@ -23569,8 +23360,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23569
23360
|
return this._align;
|
|
23570
23361
|
}
|
|
23571
23362
|
set align(value) {
|
|
23572
|
-
if (this._align === value)
|
|
23573
|
-
return;
|
|
23574
23363
|
this._align = value;
|
|
23575
23364
|
this.update();
|
|
23576
23365
|
}
|
|
@@ -23579,8 +23368,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23579
23368
|
return this._breakWords;
|
|
23580
23369
|
}
|
|
23581
23370
|
set breakWords(value) {
|
|
23582
|
-
if (this._breakWords === value)
|
|
23583
|
-
return;
|
|
23584
23371
|
this._breakWords = value;
|
|
23585
23372
|
this.update();
|
|
23586
23373
|
}
|
|
@@ -23589,8 +23376,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23589
23376
|
return this._dropShadow;
|
|
23590
23377
|
}
|
|
23591
23378
|
set dropShadow(value) {
|
|
23592
|
-
if (this._dropShadow === value)
|
|
23593
|
-
return;
|
|
23594
23379
|
if (value !== null && typeof value === "object") {
|
|
23595
23380
|
this._dropShadow = this._createProxy({ ..._TextStyle.defaultDropShadow, ...value });
|
|
23596
23381
|
} else {
|
|
@@ -23603,8 +23388,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23603
23388
|
return this._fontFamily;
|
|
23604
23389
|
}
|
|
23605
23390
|
set fontFamily(value) {
|
|
23606
|
-
if (this._fontFamily === value)
|
|
23607
|
-
return;
|
|
23608
23391
|
this._fontFamily = value;
|
|
23609
23392
|
this.update();
|
|
23610
23393
|
}
|
|
@@ -23613,8 +23396,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23613
23396
|
return this._fontSize;
|
|
23614
23397
|
}
|
|
23615
23398
|
set fontSize(value) {
|
|
23616
|
-
if (this._fontSize === value)
|
|
23617
|
-
return;
|
|
23618
23399
|
if (typeof value === "string") {
|
|
23619
23400
|
this._fontSize = parseInt(value, 10);
|
|
23620
23401
|
} else {
|
|
@@ -23630,8 +23411,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23630
23411
|
return this._fontStyle;
|
|
23631
23412
|
}
|
|
23632
23413
|
set fontStyle(value) {
|
|
23633
|
-
if (this._fontStyle === value)
|
|
23634
|
-
return;
|
|
23635
23414
|
this._fontStyle = value.toLowerCase();
|
|
23636
23415
|
this.update();
|
|
23637
23416
|
}
|
|
@@ -23643,8 +23422,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23643
23422
|
return this._fontVariant;
|
|
23644
23423
|
}
|
|
23645
23424
|
set fontVariant(value) {
|
|
23646
|
-
if (this._fontVariant === value)
|
|
23647
|
-
return;
|
|
23648
23425
|
this._fontVariant = value;
|
|
23649
23426
|
this.update();
|
|
23650
23427
|
}
|
|
@@ -23656,8 +23433,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23656
23433
|
return this._fontWeight;
|
|
23657
23434
|
}
|
|
23658
23435
|
set fontWeight(value) {
|
|
23659
|
-
if (this._fontWeight === value)
|
|
23660
|
-
return;
|
|
23661
23436
|
this._fontWeight = value;
|
|
23662
23437
|
this.update();
|
|
23663
23438
|
}
|
|
@@ -23666,8 +23441,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23666
23441
|
return this._leading;
|
|
23667
23442
|
}
|
|
23668
23443
|
set leading(value) {
|
|
23669
|
-
if (this._leading === value)
|
|
23670
|
-
return;
|
|
23671
23444
|
this._leading = value;
|
|
23672
23445
|
this.update();
|
|
23673
23446
|
}
|
|
@@ -23676,8 +23449,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23676
23449
|
return this._letterSpacing;
|
|
23677
23450
|
}
|
|
23678
23451
|
set letterSpacing(value) {
|
|
23679
|
-
if (this._letterSpacing === value)
|
|
23680
|
-
return;
|
|
23681
23452
|
this._letterSpacing = value;
|
|
23682
23453
|
this.update();
|
|
23683
23454
|
}
|
|
@@ -23686,8 +23457,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23686
23457
|
return this._lineHeight;
|
|
23687
23458
|
}
|
|
23688
23459
|
set lineHeight(value) {
|
|
23689
|
-
if (this._lineHeight === value)
|
|
23690
|
-
return;
|
|
23691
23460
|
this._lineHeight = value;
|
|
23692
23461
|
this.update();
|
|
23693
23462
|
}
|
|
@@ -23700,8 +23469,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23700
23469
|
return this._padding;
|
|
23701
23470
|
}
|
|
23702
23471
|
set padding(value) {
|
|
23703
|
-
if (this._padding === value)
|
|
23704
|
-
return;
|
|
23705
23472
|
this._padding = value;
|
|
23706
23473
|
this.update();
|
|
23707
23474
|
}
|
|
@@ -23715,8 +23482,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23715
23482
|
return this._filters;
|
|
23716
23483
|
}
|
|
23717
23484
|
set filters(value) {
|
|
23718
|
-
if (this._filters === value)
|
|
23719
|
-
return;
|
|
23720
23485
|
this._filters = Object.freeze(value);
|
|
23721
23486
|
this.update();
|
|
23722
23487
|
}
|
|
@@ -23730,8 +23495,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23730
23495
|
return this._trim;
|
|
23731
23496
|
}
|
|
23732
23497
|
set trim(value) {
|
|
23733
|
-
if (this._trim === value)
|
|
23734
|
-
return;
|
|
23735
23498
|
this._trim = value;
|
|
23736
23499
|
this.update();
|
|
23737
23500
|
}
|
|
@@ -23743,8 +23506,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23743
23506
|
return this._textBaseline;
|
|
23744
23507
|
}
|
|
23745
23508
|
set textBaseline(value) {
|
|
23746
|
-
if (this._textBaseline === value)
|
|
23747
|
-
return;
|
|
23748
23509
|
this._textBaseline = value;
|
|
23749
23510
|
this.update();
|
|
23750
23511
|
}
|
|
@@ -23763,8 +23524,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23763
23524
|
return this._whiteSpace;
|
|
23764
23525
|
}
|
|
23765
23526
|
set whiteSpace(value) {
|
|
23766
|
-
if (this._whiteSpace === value)
|
|
23767
|
-
return;
|
|
23768
23527
|
this._whiteSpace = value;
|
|
23769
23528
|
this.update();
|
|
23770
23529
|
}
|
|
@@ -23773,8 +23532,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23773
23532
|
return this._wordWrap;
|
|
23774
23533
|
}
|
|
23775
23534
|
set wordWrap(value) {
|
|
23776
|
-
if (this._wordWrap === value)
|
|
23777
|
-
return;
|
|
23778
23535
|
this._wordWrap = value;
|
|
23779
23536
|
this.update();
|
|
23780
23537
|
}
|
|
@@ -23783,8 +23540,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23783
23540
|
return this._wordWrapWidth;
|
|
23784
23541
|
}
|
|
23785
23542
|
set wordWrapWidth(value) {
|
|
23786
|
-
if (this._wordWrapWidth === value)
|
|
23787
|
-
return;
|
|
23788
23543
|
this._wordWrapWidth = value;
|
|
23789
23544
|
this.update();
|
|
23790
23545
|
}
|
|
@@ -23950,8 +23705,6 @@ const _TextStyle = class _TextStyle extends EventEmitter {
|
|
|
23950
23705
|
_createProxy(value, cb) {
|
|
23951
23706
|
return new Proxy(value, {
|
|
23952
23707
|
set: (target, property, newValue) => {
|
|
23953
|
-
if (target[property] === newValue)
|
|
23954
|
-
return true;
|
|
23955
23708
|
target[property] = newValue;
|
|
23956
23709
|
cb?.(property, newValue);
|
|
23957
23710
|
this.update();
|
|
@@ -25132,7 +24885,7 @@ const bitmapFontXMLParser = {
|
|
|
25132
24885
|
|
|
25133
24886
|
const bitmapFontXMLStringParser = {
|
|
25134
24887
|
test(data) {
|
|
25135
|
-
if (typeof data === "string" && data.
|
|
24888
|
+
if (typeof data === "string" && data.includes("<font>")) {
|
|
25136
24889
|
return bitmapFontXMLParser.test(DOMAdapter.get().parseXML(data));
|
|
25137
24890
|
}
|
|
25138
24891
|
return false;
|
|
@@ -25431,26 +25184,8 @@ const detectWebp = {
|
|
|
25431
25184
|
remove: async (formats) => formats.filter((f) => f !== "webp")
|
|
25432
25185
|
};
|
|
25433
25186
|
|
|
25434
|
-
|
|
25187
|
+
class Loader {
|
|
25435
25188
|
constructor() {
|
|
25436
|
-
/**
|
|
25437
|
-
* Options for loading assets with the loader.
|
|
25438
|
-
* These options will be used as defaults for all load calls made with this loader instance.
|
|
25439
|
-
* They can be overridden by passing options directly to the load method.
|
|
25440
|
-
* @example
|
|
25441
|
-
* ```ts
|
|
25442
|
-
* // Create a loader with custom default options
|
|
25443
|
-
* const loader = new Loader();
|
|
25444
|
-
* loader.loadOptions = {
|
|
25445
|
-
* strategy: 'skip', // Default strategy to 'skip'
|
|
25446
|
-
* retryCount: 5, // Default retry count to 5
|
|
25447
|
-
* retryDelay: 500, // Default retry delay to 500ms
|
|
25448
|
-
* };
|
|
25449
|
-
*
|
|
25450
|
-
* // This load call will use the loader's default options
|
|
25451
|
-
* await loader.load('image1.png');
|
|
25452
|
-
*/
|
|
25453
|
-
this.loadOptions = { ..._Loader.defaultOptions };
|
|
25454
25189
|
this._parsers = [];
|
|
25455
25190
|
this._parsersValidated = false;
|
|
25456
25191
|
/**
|
|
@@ -25527,12 +25262,10 @@ const _Loader = class _Loader {
|
|
|
25527
25262
|
})();
|
|
25528
25263
|
return result;
|
|
25529
25264
|
}
|
|
25530
|
-
async load(assetsToLoadIn,
|
|
25265
|
+
async load(assetsToLoadIn, onProgress) {
|
|
25531
25266
|
if (!this._parsersValidated) {
|
|
25532
25267
|
this._validateParsers();
|
|
25533
25268
|
}
|
|
25534
|
-
const options = typeof onProgressOrOptions === "function" ? { ..._Loader.defaultOptions, ...this.loadOptions, onProgress: onProgressOrOptions } : { ..._Loader.defaultOptions, ...this.loadOptions, ...onProgressOrOptions || {} };
|
|
25535
|
-
const { onProgress, onError, strategy, retryCount, retryDelay } = options;
|
|
25536
25269
|
let count = 0;
|
|
25537
25270
|
const assets = {};
|
|
25538
25271
|
const singleAsset = isSingleItem(assetsToLoadIn);
|
|
@@ -25541,15 +25274,24 @@ const _Loader = class _Loader {
|
|
|
25541
25274
|
src: item,
|
|
25542
25275
|
data: {}
|
|
25543
25276
|
}));
|
|
25544
|
-
const total = assetsToLoad.
|
|
25277
|
+
const total = assetsToLoad.length;
|
|
25545
25278
|
const promises = assetsToLoad.map(async (asset) => {
|
|
25546
25279
|
const url = path.toAbsolute(asset.src);
|
|
25547
|
-
if (assets[asset.src])
|
|
25548
|
-
|
|
25549
|
-
|
|
25550
|
-
|
|
25551
|
-
|
|
25552
|
-
|
|
25280
|
+
if (!assets[asset.src]) {
|
|
25281
|
+
try {
|
|
25282
|
+
if (!this.promiseCache[url]) {
|
|
25283
|
+
this.promiseCache[url] = this._getLoadPromiseAndParser(url, asset);
|
|
25284
|
+
}
|
|
25285
|
+
assets[asset.src] = await this.promiseCache[url].promise;
|
|
25286
|
+
if (onProgress)
|
|
25287
|
+
onProgress(++count / total);
|
|
25288
|
+
} catch (e) {
|
|
25289
|
+
delete this.promiseCache[url];
|
|
25290
|
+
delete assets[asset.src];
|
|
25291
|
+
throw new Error(`[Loader.load] Failed to load ${url}.
|
|
25292
|
+
${e}`);
|
|
25293
|
+
}
|
|
25294
|
+
}
|
|
25553
25295
|
});
|
|
25554
25296
|
await Promise.all(promises);
|
|
25555
25297
|
return singleAsset ? assets[assetsToLoad[0].src] : assets;
|
|
@@ -25597,65 +25339,7 @@ const _Loader = class _Loader {
|
|
|
25597
25339
|
return hash;
|
|
25598
25340
|
}, {});
|
|
25599
25341
|
}
|
|
25600
|
-
|
|
25601
|
-
let attempt = 0;
|
|
25602
|
-
const { onError, strategy, retryCount, retryDelay } = options;
|
|
25603
|
-
const wait = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
25604
|
-
while (true) {
|
|
25605
|
-
try {
|
|
25606
|
-
if (!this.promiseCache[url]) {
|
|
25607
|
-
this.promiseCache[url] = this._getLoadPromiseAndParser(url, asset);
|
|
25608
|
-
}
|
|
25609
|
-
assets[asset.src] = await this.promiseCache[url].promise;
|
|
25610
|
-
return;
|
|
25611
|
-
} catch (e) {
|
|
25612
|
-
delete this.promiseCache[url];
|
|
25613
|
-
delete assets[asset.src];
|
|
25614
|
-
attempt++;
|
|
25615
|
-
const isLast = strategy !== "retry" || attempt > retryCount;
|
|
25616
|
-
if (strategy === "retry" && !isLast) {
|
|
25617
|
-
if (onError)
|
|
25618
|
-
onError(e, asset);
|
|
25619
|
-
await wait(retryDelay);
|
|
25620
|
-
continue;
|
|
25621
|
-
}
|
|
25622
|
-
if (strategy === "skip") {
|
|
25623
|
-
if (onError)
|
|
25624
|
-
onError(e, asset);
|
|
25625
|
-
return;
|
|
25626
|
-
}
|
|
25627
|
-
if (onError)
|
|
25628
|
-
onError(e, asset);
|
|
25629
|
-
const error = new Error(`[Loader.load] Failed to load ${url}.
|
|
25630
|
-
${e}`);
|
|
25631
|
-
if (e instanceof Error && e.stack) {
|
|
25632
|
-
error.stack = e.stack;
|
|
25633
|
-
}
|
|
25634
|
-
throw error;
|
|
25635
|
-
}
|
|
25636
|
-
}
|
|
25637
|
-
}
|
|
25638
|
-
};
|
|
25639
|
-
/**
|
|
25640
|
-
* Default options for loading assets
|
|
25641
|
-
* @example
|
|
25642
|
-
* ```ts
|
|
25643
|
-
* // Change default load options globally
|
|
25644
|
-
* Loader.defaultOptions = {
|
|
25645
|
-
* strategy: 'skip', // Change default strategy to 'skip'
|
|
25646
|
-
* retryCount: 5, // Change default retry count to 5
|
|
25647
|
-
* retryDelay: 500, // Change default retry delay to 500ms
|
|
25648
|
-
* };
|
|
25649
|
-
* ```
|
|
25650
|
-
*/
|
|
25651
|
-
_Loader.defaultOptions = {
|
|
25652
|
-
onProgress: void 0,
|
|
25653
|
-
onError: void 0,
|
|
25654
|
-
strategy: "throw",
|
|
25655
|
-
retryCount: 3,
|
|
25656
|
-
retryDelay: 250
|
|
25657
|
-
};
|
|
25658
|
-
let Loader = _Loader;
|
|
25342
|
+
}
|
|
25659
25343
|
|
|
25660
25344
|
function checkDataUrl(url, mimes) {
|
|
25661
25345
|
if (Array.isArray(mimes)) {
|
|
@@ -26054,15 +25738,12 @@ class WorkerManagerClass {
|
|
|
26054
25738
|
* @param data - Result data from the worker containing uuid, data, and optional error
|
|
26055
25739
|
*/
|
|
26056
25740
|
_complete(data) {
|
|
26057
|
-
if (!this._resolveHash[data.uuid]) {
|
|
26058
|
-
return;
|
|
26059
|
-
}
|
|
26060
25741
|
if (data.error !== void 0) {
|
|
26061
25742
|
this._resolveHash[data.uuid].reject(data.error);
|
|
26062
25743
|
} else {
|
|
26063
25744
|
this._resolveHash[data.uuid].resolve(data.data);
|
|
26064
25745
|
}
|
|
26065
|
-
|
|
25746
|
+
this._resolveHash[data.uuid] = null;
|
|
26066
25747
|
}
|
|
26067
25748
|
/**
|
|
26068
25749
|
* Executes a task using the worker pool system.
|
|
@@ -26123,7 +25804,7 @@ class WorkerManagerClass {
|
|
|
26123
25804
|
this._workerPool.forEach((worker) => worker.terminate());
|
|
26124
25805
|
this._workerPool.length = 0;
|
|
26125
25806
|
Object.values(this._resolveHash).forEach(({ reject }) => {
|
|
26126
|
-
reject?.(new Error("WorkerManager
|
|
25807
|
+
reject?.(new Error("WorkerManager destroyed"));
|
|
26127
25808
|
});
|
|
26128
25809
|
this._resolveHash = {};
|
|
26129
25810
|
this._queue.length = 0;
|
|
@@ -26462,12 +26143,6 @@ class AssetsClass {
|
|
|
26462
26143
|
if (options.preferences) {
|
|
26463
26144
|
this.setPreferences(options.preferences);
|
|
26464
26145
|
}
|
|
26465
|
-
if (options.loadOptions) {
|
|
26466
|
-
this.loader.loadOptions = {
|
|
26467
|
-
...this.loader.loadOptions,
|
|
26468
|
-
...options.loadOptions
|
|
26469
|
-
};
|
|
26470
|
-
}
|
|
26471
26146
|
}
|
|
26472
26147
|
/**
|
|
26473
26148
|
* Registers assets with the Assets resolver. This method maps keys (aliases) to asset sources,
|
|
@@ -26687,22 +26362,17 @@ class AssetsClass {
|
|
|
26687
26362
|
const resolveResults = this.resolver.resolveBundle(bundleIds);
|
|
26688
26363
|
const out = {};
|
|
26689
26364
|
const keys = Object.keys(resolveResults);
|
|
26365
|
+
let count = 0;
|
|
26690
26366
|
let total = 0;
|
|
26691
|
-
const counts = [];
|
|
26692
26367
|
const _onProgress = () => {
|
|
26693
|
-
onProgress?.(
|
|
26368
|
+
onProgress?.(++count / total);
|
|
26694
26369
|
};
|
|
26695
|
-
const promises = keys.map((bundleId
|
|
26370
|
+
const promises = keys.map((bundleId) => {
|
|
26696
26371
|
const resolveResult = resolveResults[bundleId];
|
|
26697
26372
|
const values = Object.values(resolveResult);
|
|
26698
26373
|
const totalAssetsToLoad = [...new Set(values.flat())];
|
|
26699
|
-
|
|
26700
|
-
|
|
26701
|
-
total += progressSize;
|
|
26702
|
-
return this._mapLoadToResolve(resolveResult, (e) => {
|
|
26703
|
-
counts[i] = e * progressSize;
|
|
26704
|
-
_onProgress();
|
|
26705
|
-
}).then((resolveResult2) => {
|
|
26374
|
+
total += totalAssetsToLoad.length;
|
|
26375
|
+
return this._mapLoadToResolve(resolveResult, _onProgress).then((resolveResult2) => {
|
|
26706
26376
|
out[bundleId] = resolveResult2;
|
|
26707
26377
|
});
|
|
26708
26378
|
});
|
|
@@ -26854,12 +26524,12 @@ class AssetsClass {
|
|
|
26854
26524
|
/**
|
|
26855
26525
|
* helper function to map resolved assets back to loaded assets
|
|
26856
26526
|
* @param resolveResults - the resolve results from the resolver
|
|
26857
|
-
* @param
|
|
26527
|
+
* @param onProgress - the progress callback
|
|
26858
26528
|
*/
|
|
26859
|
-
async _mapLoadToResolve(resolveResults,
|
|
26529
|
+
async _mapLoadToResolve(resolveResults, onProgress) {
|
|
26860
26530
|
const resolveArray = [...new Set(Object.values(resolveResults))];
|
|
26861
26531
|
this._backgroundLoader.active = false;
|
|
26862
|
-
const loadedAssets = await this.loader.load(resolveArray,
|
|
26532
|
+
const loadedAssets = await this.loader.load(resolveArray, onProgress);
|
|
26863
26533
|
this._backgroundLoader.active = true;
|
|
26864
26534
|
const out = {};
|
|
26865
26535
|
resolveArray.forEach((resolveResult) => {
|
|
@@ -29144,31 +28814,6 @@ const FederatedContainer = {
|
|
|
29144
28814
|
}
|
|
29145
28815
|
};
|
|
29146
28816
|
|
|
29147
|
-
var vertex$2 = "in vec2 aPosition;\nout vec2 vTextureCoord;\n\nuniform vec4 uInputSize;\nuniform vec4 uOutputFrame;\nuniform vec4 uOutputTexture;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;\n \n position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( void )\n{\n return aPosition * (uOutputFrame.zw * uInputSize.zw);\n}\n\nvoid main(void)\n{\n gl_Position = filterVertexPosition();\n vTextureCoord = filterTextureCoord();\n}\n";
|
|
29148
|
-
|
|
29149
|
-
var fragment$2 = "in vec2 vTextureCoord;\nout vec4 finalColor;\nuniform sampler2D uTexture;\nvoid main() {\n finalColor = texture(uTexture, vTextureCoord);\n}\n";
|
|
29150
|
-
|
|
29151
|
-
var source$1 = "struct GlobalFilterUniforms {\n uInputSize: vec4<f32>,\n uInputPixel: vec4<f32>,\n uInputClamp: vec4<f32>,\n uOutputFrame: vec4<f32>,\n uGlobalFrame: vec4<f32>,\n uOutputTexture: vec4<f32>,\n};\n\n@group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;\n@group(0) @binding(1) var uTexture: texture_2d<f32>;\n@group(0) @binding(2) var uSampler: sampler;\n\nstruct VSOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv: vec2<f32>\n};\n\nfn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>\n{\n var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;\n\n position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nfn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>\n{\n return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);\n}\n\n@vertex\nfn mainVertex(\n @location(0) aPosition: vec2<f32>,\n) -> VSOutput {\n return VSOutput(\n filterVertexPosition(aPosition),\n filterTextureCoord(aPosition)\n );\n}\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n) -> @location(0) vec4<f32> {\n return textureSample(uTexture, uSampler, uv);\n}\n";
|
|
29152
|
-
|
|
29153
|
-
class PassthroughFilter extends Filter {
|
|
29154
|
-
constructor() {
|
|
29155
|
-
const gpuProgram = GpuProgram.from({
|
|
29156
|
-
vertex: { source: source$1, entryPoint: "mainVertex" },
|
|
29157
|
-
fragment: { source: source$1, entryPoint: "mainFragment" },
|
|
29158
|
-
name: "passthrough-filter"
|
|
29159
|
-
});
|
|
29160
|
-
const glProgram = GlProgram.from({
|
|
29161
|
-
vertex: vertex$2,
|
|
29162
|
-
fragment: fragment$2,
|
|
29163
|
-
name: "passthrough-filter"
|
|
29164
|
-
});
|
|
29165
|
-
super({
|
|
29166
|
-
gpuProgram,
|
|
29167
|
-
glProgram
|
|
29168
|
-
});
|
|
29169
|
-
}
|
|
29170
|
-
}
|
|
29171
|
-
|
|
29172
28817
|
class FilterPipe {
|
|
29173
28818
|
constructor(renderer) {
|
|
29174
28819
|
this._renderer = renderer;
|
|
@@ -29293,10 +28938,6 @@ class FilterData {
|
|
|
29293
28938
|
* @type {{ x: number, y: number, width: number, height: number }}
|
|
29294
28939
|
*/
|
|
29295
28940
|
this.globalFrame = { x: 0, y: 0, width: 0, height: 0 };
|
|
29296
|
-
/** The first enabled filter index in the current filter list. */
|
|
29297
|
-
this.firstEnabledIndex = -1;
|
|
29298
|
-
/** The last enabled filter index in the current filter list. */
|
|
29299
|
-
this.lastEnabledIndex = -1;
|
|
29300
28941
|
}
|
|
29301
28942
|
}
|
|
29302
28943
|
class FilterSystem {
|
|
@@ -29337,7 +28978,7 @@ class FilterSystem {
|
|
|
29337
28978
|
const colorTextureSource = renderer.renderTarget.renderTarget.colorTexture.source;
|
|
29338
28979
|
const rootResolution = colorTextureSource.resolution;
|
|
29339
28980
|
const rootAntialias = colorTextureSource.antialias;
|
|
29340
|
-
if (filters.
|
|
28981
|
+
if (filters.length === 0) {
|
|
29341
28982
|
filterData.skip = true;
|
|
29342
28983
|
return;
|
|
29343
28984
|
}
|
|
@@ -29400,7 +29041,7 @@ class FilterSystem {
|
|
|
29400
29041
|
const colorTextureSource = texture.source;
|
|
29401
29042
|
const rootResolution = colorTextureSource.resolution;
|
|
29402
29043
|
const rootAntialias = colorTextureSource.antialias;
|
|
29403
|
-
if (filters.
|
|
29044
|
+
if (filters.length === 0) {
|
|
29404
29045
|
filterData.skip = true;
|
|
29405
29046
|
return texture;
|
|
29406
29047
|
}
|
|
@@ -29507,8 +29148,7 @@ class FilterSystem {
|
|
|
29507
29148
|
offsetY = offset.y;
|
|
29508
29149
|
}
|
|
29509
29150
|
this._updateFilterUniforms(input, output, filterData, offsetX, offsetY, resolution, isFinalTarget, clear);
|
|
29510
|
-
|
|
29511
|
-
this._setupBindGroupsAndRender(filterToApply, input, renderer);
|
|
29151
|
+
this._setupBindGroupsAndRender(filter, input, renderer);
|
|
29512
29152
|
}
|
|
29513
29153
|
/**
|
|
29514
29154
|
* Multiply _input normalized coordinates_ to this matrix to get _sprite texture normalized coordinates_.
|
|
@@ -29543,12 +29183,6 @@ class FilterSystem {
|
|
|
29543
29183
|
return mappedMatrix;
|
|
29544
29184
|
}
|
|
29545
29185
|
destroy() {
|
|
29546
|
-
this._passthroughFilter?.destroy(true);
|
|
29547
|
-
this._passthroughFilter = null;
|
|
29548
|
-
}
|
|
29549
|
-
_getPassthroughFilter() {
|
|
29550
|
-
this._passthroughFilter ?? (this._passthroughFilter = new PassthroughFilter());
|
|
29551
|
-
return this._passthroughFilter;
|
|
29552
29186
|
}
|
|
29553
29187
|
/**
|
|
29554
29188
|
* Sets up the bind groups and renders the filter.
|
|
@@ -29734,12 +29368,10 @@ class FilterSystem {
|
|
|
29734
29368
|
const inputTexture = filterData.inputTexture;
|
|
29735
29369
|
const bounds = filterData.bounds;
|
|
29736
29370
|
const filters = filterData.filters;
|
|
29737
|
-
const firstEnabled = filterData.firstEnabledIndex;
|
|
29738
|
-
const lastEnabled = filterData.lastEnabledIndex;
|
|
29739
29371
|
this._globalFilterBindGroup.setResource(inputTexture.source.style, 2);
|
|
29740
29372
|
this._globalFilterBindGroup.setResource(filterData.backTexture.source, 3);
|
|
29741
|
-
if (
|
|
29742
|
-
filters[
|
|
29373
|
+
if (filters.length === 1) {
|
|
29374
|
+
filters[0].apply(this, inputTexture, filterData.outputRenderSurface, clear);
|
|
29743
29375
|
} else {
|
|
29744
29376
|
let flip = filterData.inputTexture;
|
|
29745
29377
|
const tempTexture = TexturePool.getOptimalTexture(
|
|
@@ -29749,16 +29381,15 @@ class FilterSystem {
|
|
|
29749
29381
|
false
|
|
29750
29382
|
);
|
|
29751
29383
|
let flop = tempTexture;
|
|
29752
|
-
|
|
29384
|
+
let i = 0;
|
|
29385
|
+
for (i = 0; i < filters.length - 1; ++i) {
|
|
29753
29386
|
const filter = filters[i];
|
|
29754
|
-
if (!filter.enabled)
|
|
29755
|
-
continue;
|
|
29756
29387
|
filter.apply(this, flip, flop, true);
|
|
29757
29388
|
const t = flip;
|
|
29758
29389
|
flip = flop;
|
|
29759
29390
|
flop = t;
|
|
29760
29391
|
}
|
|
29761
|
-
filters[
|
|
29392
|
+
filters[i].apply(this, flip, filterData.outputRenderSurface, clear);
|
|
29762
29393
|
TexturePool.returnTexture(tempTexture);
|
|
29763
29394
|
}
|
|
29764
29395
|
}
|
|
@@ -29772,15 +29403,8 @@ class FilterSystem {
|
|
|
29772
29403
|
let blendRequired = false;
|
|
29773
29404
|
let enabled = false;
|
|
29774
29405
|
let clipToViewport = true;
|
|
29775
|
-
let firstEnabledIndex = -1;
|
|
29776
|
-
let lastEnabledIndex = -1;
|
|
29777
29406
|
for (let i = 0; i < filters.length; i++) {
|
|
29778
29407
|
const filter = filters[i];
|
|
29779
|
-
if (!filter.enabled)
|
|
29780
|
-
continue;
|
|
29781
|
-
if (firstEnabledIndex === -1)
|
|
29782
|
-
firstEnabledIndex = i;
|
|
29783
|
-
lastEnabledIndex = i;
|
|
29784
29408
|
resolution = Math.min(resolution, filter.resolution === "inherit" ? rootResolution : filter.resolution);
|
|
29785
29409
|
padding += filter.padding;
|
|
29786
29410
|
if (filter.antialias === "off") {
|
|
@@ -29801,7 +29425,7 @@ class FilterSystem {
|
|
|
29801
29425
|
enabled = false;
|
|
29802
29426
|
break;
|
|
29803
29427
|
}
|
|
29804
|
-
enabled =
|
|
29428
|
+
enabled = filter.enabled || enabled;
|
|
29805
29429
|
blendRequired || (blendRequired = filter.blendRequired);
|
|
29806
29430
|
}
|
|
29807
29431
|
if (!enabled) {
|
|
@@ -29819,8 +29443,6 @@ class FilterSystem {
|
|
|
29819
29443
|
filterData.antialias = antialias;
|
|
29820
29444
|
filterData.resolution = resolution;
|
|
29821
29445
|
filterData.blendRequired = blendRequired;
|
|
29822
|
-
filterData.firstEnabledIndex = firstEnabledIndex;
|
|
29823
|
-
filterData.lastEnabledIndex = lastEnabledIndex;
|
|
29824
29446
|
}
|
|
29825
29447
|
_popFilterData() {
|
|
29826
29448
|
this._filterStackIndex--;
|
|
@@ -29934,11 +29556,11 @@ class Graphics extends ViewContainer {
|
|
|
29934
29556
|
/** @internal */
|
|
29935
29557
|
this.renderPipeId = "graphics";
|
|
29936
29558
|
if (!context) {
|
|
29937
|
-
this.
|
|
29938
|
-
this.context.autoGarbageCollect = this.autoGarbageCollect;
|
|
29559
|
+
this._context = this._ownedContext = new GraphicsContext();
|
|
29939
29560
|
} else {
|
|
29940
|
-
this.
|
|
29561
|
+
this._context = context;
|
|
29941
29562
|
}
|
|
29563
|
+
this._context.on("update", this.onViewUpdate, this);
|
|
29942
29564
|
this.didViewUpdate = true;
|
|
29943
29565
|
this.allowChildren = false;
|
|
29944
29566
|
this.roundPixels = roundPixels ?? false;
|
|
@@ -29946,13 +29568,9 @@ class Graphics extends ViewContainer {
|
|
|
29946
29568
|
set context(context) {
|
|
29947
29569
|
if (context === this._context)
|
|
29948
29570
|
return;
|
|
29949
|
-
|
|
29950
|
-
this._context.off("update", this.onViewUpdate, this);
|
|
29951
|
-
this._context.off("unload", this.unload, this);
|
|
29952
|
-
}
|
|
29571
|
+
this._context.off("update", this.onViewUpdate, this);
|
|
29953
29572
|
this._context = context;
|
|
29954
29573
|
this._context.on("update", this.onViewUpdate, this);
|
|
29955
|
-
this._context.on("unload", this.unload, this);
|
|
29956
29574
|
this.onViewUpdate();
|
|
29957
29575
|
}
|
|
29958
29576
|
/**
|
|
@@ -30066,14 +29684,6 @@ class Graphics extends ViewContainer {
|
|
|
30066
29684
|
this._context = null;
|
|
30067
29685
|
super.destroy(options);
|
|
30068
29686
|
}
|
|
30069
|
-
/**
|
|
30070
|
-
* @param now - The current time in milliseconds.
|
|
30071
|
-
* @internal
|
|
30072
|
-
*/
|
|
30073
|
-
_onTouch(now) {
|
|
30074
|
-
this._gcLastUsed = now;
|
|
30075
|
-
this._context._gcLastUsed = now;
|
|
30076
|
-
}
|
|
30077
29687
|
_callContextMethod(method, args) {
|
|
30078
29688
|
this.context[method](...args);
|
|
30079
29689
|
return this;
|
|
@@ -32190,7 +31800,7 @@ class GpuBatchAdaptor {
|
|
|
32190
31800
|
tempState,
|
|
32191
31801
|
batch.topology
|
|
32192
31802
|
);
|
|
32193
|
-
batch.bindGroup._touch(renderer.
|
|
31803
|
+
batch.bindGroup._touch(renderer.textureGC.count);
|
|
32194
31804
|
encoder.setPipeline(pipeline);
|
|
32195
31805
|
encoder.renderPassEncoder.setBindGroup(1, gpuBindGroup);
|
|
32196
31806
|
encoder.renderPassEncoder.drawIndexed(batch.size, 1, batch.start);
|
|
@@ -32796,14 +32406,6 @@ class GlBuffer {
|
|
|
32796
32406
|
this.byteLength = -1;
|
|
32797
32407
|
this.type = type;
|
|
32798
32408
|
}
|
|
32799
|
-
destroy() {
|
|
32800
|
-
this.buffer = null;
|
|
32801
|
-
this.updateID = -1;
|
|
32802
|
-
this.byteLength = -1;
|
|
32803
|
-
this.type = -1;
|
|
32804
|
-
this._lastBindBaseLocation = -1;
|
|
32805
|
-
this._lastBindCallId = -1;
|
|
32806
|
-
}
|
|
32807
32409
|
}
|
|
32808
32410
|
|
|
32809
32411
|
class GlBufferSystem {
|
|
@@ -32811,35 +32413,30 @@ class GlBufferSystem {
|
|
|
32811
32413
|
* @param {Renderer} renderer - The renderer this System works for.
|
|
32812
32414
|
*/
|
|
32813
32415
|
constructor(renderer) {
|
|
32416
|
+
this._gpuBuffers = /* @__PURE__ */ Object.create(null);
|
|
32814
32417
|
/** Cache keeping track of the base bound buffer bases */
|
|
32815
32418
|
this._boundBufferBases = /* @__PURE__ */ Object.create(null);
|
|
32816
32419
|
this._minBaseLocation = 0;
|
|
32817
32420
|
this._nextBindBaseIndex = this._minBaseLocation;
|
|
32818
32421
|
this._bindCallId = 0;
|
|
32819
32422
|
this._renderer = renderer;
|
|
32820
|
-
this.
|
|
32821
|
-
renderer,
|
|
32822
|
-
type: "resource",
|
|
32823
|
-
onUnload: this.onBufferUnload.bind(this),
|
|
32824
|
-
name: "glBuffer"
|
|
32825
|
-
});
|
|
32423
|
+
this._renderer.renderableGC.addManagedHash(this, "_gpuBuffers");
|
|
32826
32424
|
}
|
|
32827
32425
|
/** @ignore */
|
|
32828
32426
|
destroy() {
|
|
32829
|
-
this._managedBuffers.destroy();
|
|
32830
32427
|
this._renderer = null;
|
|
32831
32428
|
this._gl = null;
|
|
32832
|
-
this.
|
|
32429
|
+
this._gpuBuffers = null;
|
|
32430
|
+
this._boundBufferBases = null;
|
|
32833
32431
|
}
|
|
32834
32432
|
/** Sets up the renderer context and necessary buffers. */
|
|
32835
32433
|
contextChange() {
|
|
32836
32434
|
this._gl = this._renderer.gl;
|
|
32837
|
-
this.
|
|
32435
|
+
this._gpuBuffers = /* @__PURE__ */ Object.create(null);
|
|
32838
32436
|
this._maxBindings = this._renderer.limits.maxUniformBindings;
|
|
32839
32437
|
}
|
|
32840
32438
|
getGlBuffer(buffer) {
|
|
32841
|
-
buffer.
|
|
32842
|
-
return buffer._gpuData[this._renderer.uid] || this.createGLBuffer(buffer);
|
|
32439
|
+
return this._gpuBuffers[buffer.uid] || this.createGLBuffer(buffer);
|
|
32843
32440
|
}
|
|
32844
32441
|
/**
|
|
32845
32442
|
* This binds specified buffer. On first run, it will create the webGL buffers for the context too
|
|
@@ -32954,19 +32551,26 @@ class GlBufferSystem {
|
|
|
32954
32551
|
}
|
|
32955
32552
|
return glBuffer;
|
|
32956
32553
|
}
|
|
32554
|
+
/** dispose all WebGL resources of all managed buffers */
|
|
32555
|
+
destroyAll() {
|
|
32556
|
+
const gl = this._gl;
|
|
32557
|
+
for (const id in this._gpuBuffers) {
|
|
32558
|
+
gl.deleteBuffer(this._gpuBuffers[id].buffer);
|
|
32559
|
+
}
|
|
32560
|
+
this._gpuBuffers = /* @__PURE__ */ Object.create(null);
|
|
32561
|
+
}
|
|
32957
32562
|
/**
|
|
32958
|
-
*
|
|
32959
|
-
* @param
|
|
32563
|
+
* Disposes buffer
|
|
32564
|
+
* @param {Buffer} buffer - buffer with data
|
|
32565
|
+
* @param {boolean} [contextLost=false] - If context was lost, we suppress deleteVertexArray
|
|
32960
32566
|
*/
|
|
32961
|
-
|
|
32962
|
-
this.
|
|
32963
|
-
|
|
32964
|
-
|
|
32965
|
-
|
|
32966
|
-
|
|
32967
|
-
|
|
32968
|
-
if (!contextLost)
|
|
32969
|
-
this._gl.deleteBuffer(glBuffer.buffer);
|
|
32567
|
+
onBufferDestroy(buffer, contextLost) {
|
|
32568
|
+
const glBuffer = this._gpuBuffers[buffer.uid];
|
|
32569
|
+
const gl = this._gl;
|
|
32570
|
+
if (!contextLost) {
|
|
32571
|
+
gl.deleteBuffer(glBuffer.buffer);
|
|
32572
|
+
}
|
|
32573
|
+
this._gpuBuffers[buffer.uid] = null;
|
|
32970
32574
|
}
|
|
32971
32575
|
/**
|
|
32972
32576
|
* creates and attaches a GLBuffer object tied to the current context.
|
|
@@ -32982,8 +32586,8 @@ class GlBufferSystem {
|
|
|
32982
32586
|
type = BUFFER_TYPE.UNIFORM_BUFFER;
|
|
32983
32587
|
}
|
|
32984
32588
|
const glBuffer = new GlBuffer(gl.createBuffer(), type);
|
|
32985
|
-
|
|
32986
|
-
this.
|
|
32589
|
+
this._gpuBuffers[buffer.uid] = glBuffer;
|
|
32590
|
+
buffer.on("destroy", this.onBufferDestroy, this);
|
|
32987
32591
|
return glBuffer;
|
|
32988
32592
|
}
|
|
32989
32593
|
resetState() {
|
|
@@ -33395,28 +32999,16 @@ const topologyToGlMap = {
|
|
|
33395
32999
|
"triangle-list": 4,
|
|
33396
33000
|
"triangle-strip": 5
|
|
33397
33001
|
};
|
|
33398
|
-
class GlGeometryGpuData {
|
|
33399
|
-
constructor() {
|
|
33400
|
-
this.vaoCache = /* @__PURE__ */ Object.create(null);
|
|
33401
|
-
}
|
|
33402
|
-
destroy() {
|
|
33403
|
-
this.vaoCache = /* @__PURE__ */ Object.create(null);
|
|
33404
|
-
}
|
|
33405
|
-
}
|
|
33406
33002
|
class GlGeometrySystem {
|
|
33407
33003
|
/** @param renderer - The renderer this System works for. */
|
|
33408
33004
|
constructor(renderer) {
|
|
33005
|
+
this._geometryVaoHash = /* @__PURE__ */ Object.create(null);
|
|
33409
33006
|
this._renderer = renderer;
|
|
33410
33007
|
this._activeGeometry = null;
|
|
33411
33008
|
this._activeVao = null;
|
|
33412
33009
|
this.hasVao = true;
|
|
33413
33010
|
this.hasInstance = true;
|
|
33414
|
-
this.
|
|
33415
|
-
renderer,
|
|
33416
|
-
type: "resource",
|
|
33417
|
-
onUnload: this.onGeometryUnload.bind(this),
|
|
33418
|
-
name: "glGeometry"
|
|
33419
|
-
});
|
|
33011
|
+
this._renderer.renderableGC.addManagedHash(this, "_geometryVaoHash");
|
|
33420
33012
|
}
|
|
33421
33013
|
/** Sets up the renderer context and necessary buffers. */
|
|
33422
33014
|
contextChange() {
|
|
@@ -33424,7 +33016,6 @@ class GlGeometrySystem {
|
|
|
33424
33016
|
if (!this._renderer.context.supports.vertexArrayObject) {
|
|
33425
33017
|
throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");
|
|
33426
33018
|
}
|
|
33427
|
-
this.destroyAll(true);
|
|
33428
33019
|
const nativeVaoExtension = this._renderer.context.extensions.vertexArrayObject;
|
|
33429
33020
|
if (nativeVaoExtension) {
|
|
33430
33021
|
gl.createVertexArray = () => nativeVaoExtension.createVertexArrayOES();
|
|
@@ -33443,6 +33034,7 @@ class GlGeometrySystem {
|
|
|
33443
33034
|
}
|
|
33444
33035
|
this._activeGeometry = null;
|
|
33445
33036
|
this._activeVao = null;
|
|
33037
|
+
this._geometryVaoHash = /* @__PURE__ */ Object.create(null);
|
|
33446
33038
|
}
|
|
33447
33039
|
/**
|
|
33448
33040
|
* Binds geometry so that is can be drawn. Creating a Vao if required
|
|
@@ -33471,7 +33063,6 @@ class GlGeometrySystem {
|
|
|
33471
33063
|
const buffer = geometry.buffers[i];
|
|
33472
33064
|
bufferSystem.updateBuffer(buffer);
|
|
33473
33065
|
}
|
|
33474
|
-
geometry._gcLastUsed = this._renderer.gc.now;
|
|
33475
33066
|
}
|
|
33476
33067
|
/**
|
|
33477
33068
|
* Check compatibility between a geometry and a program
|
|
@@ -33505,7 +33096,7 @@ class GlGeometrySystem {
|
|
|
33505
33096
|
return strings.join("-");
|
|
33506
33097
|
}
|
|
33507
33098
|
getVao(geometry, program) {
|
|
33508
|
-
return
|
|
33099
|
+
return this._geometryVaoHash[geometry.uid]?.[program._key] || this.initGeometryVao(geometry, program);
|
|
33509
33100
|
}
|
|
33510
33101
|
/**
|
|
33511
33102
|
* Creates or gets Vao with the same structure as the geometry and stores it on the geometry.
|
|
@@ -33521,10 +33112,11 @@ class GlGeometrySystem {
|
|
|
33521
33112
|
this._renderer.shader._getProgramData(program);
|
|
33522
33113
|
this.checkCompatibility(geometry, program);
|
|
33523
33114
|
const signature = this.getSignature(geometry, program);
|
|
33524
|
-
|
|
33525
|
-
|
|
33526
|
-
|
|
33527
|
-
|
|
33115
|
+
if (!this._geometryVaoHash[geometry.uid]) {
|
|
33116
|
+
this._geometryVaoHash[geometry.uid] = /* @__PURE__ */ Object.create(null);
|
|
33117
|
+
geometry.on("destroy", this.onGeometryDestroy, this);
|
|
33118
|
+
}
|
|
33119
|
+
const vaoObjectHash = this._geometryVaoHash[geometry.uid];
|
|
33528
33120
|
let vao = vaoObjectHash[signature];
|
|
33529
33121
|
if (vao) {
|
|
33530
33122
|
vaoObjectHash[program._key] = vao;
|
|
@@ -33544,18 +33136,24 @@ class GlGeometrySystem {
|
|
|
33544
33136
|
gl.bindVertexArray(null);
|
|
33545
33137
|
return vao;
|
|
33546
33138
|
}
|
|
33547
|
-
|
|
33548
|
-
|
|
33549
|
-
|
|
33550
|
-
|
|
33551
|
-
|
|
33552
|
-
|
|
33553
|
-
|
|
33554
|
-
|
|
33555
|
-
|
|
33139
|
+
/**
|
|
33140
|
+
* Disposes geometry.
|
|
33141
|
+
* @param geometry - Geometry with buffers. Only VAO will be disposed
|
|
33142
|
+
* @param [contextLost=false] - If context was lost, we suppress deleteVertexArray
|
|
33143
|
+
*/
|
|
33144
|
+
onGeometryDestroy(geometry, contextLost) {
|
|
33145
|
+
const vaoObjectHash = this._geometryVaoHash[geometry.uid];
|
|
33146
|
+
const gl = this.gl;
|
|
33147
|
+
if (vaoObjectHash) {
|
|
33148
|
+
if (contextLost) {
|
|
33149
|
+
for (const i in vaoObjectHash) {
|
|
33150
|
+
if (this._activeVao !== vaoObjectHash[i]) {
|
|
33151
|
+
this.unbind();
|
|
33152
|
+
}
|
|
33153
|
+
gl.deleteVertexArray(vaoObjectHash[i]);
|
|
33556
33154
|
}
|
|
33557
|
-
this.gl.deleteVertexArray(vaoCache[i]);
|
|
33558
33155
|
}
|
|
33156
|
+
this._geometryVaoHash[geometry.uid] = null;
|
|
33559
33157
|
}
|
|
33560
33158
|
}
|
|
33561
33159
|
/**
|
|
@@ -33563,7 +33161,19 @@ class GlGeometrySystem {
|
|
|
33563
33161
|
* @param [contextLost=false] - If context was lost, we suppress `gl.delete` calls
|
|
33564
33162
|
*/
|
|
33565
33163
|
destroyAll(contextLost = false) {
|
|
33566
|
-
this.
|
|
33164
|
+
const gl = this.gl;
|
|
33165
|
+
for (const i in this._geometryVaoHash) {
|
|
33166
|
+
if (contextLost) {
|
|
33167
|
+
for (const j in this._geometryVaoHash[i]) {
|
|
33168
|
+
const vaoObjectHash = this._geometryVaoHash[i];
|
|
33169
|
+
if (this._activeVao !== vaoObjectHash) {
|
|
33170
|
+
this.unbind();
|
|
33171
|
+
}
|
|
33172
|
+
gl.deleteVertexArray(vaoObjectHash[j]);
|
|
33173
|
+
}
|
|
33174
|
+
}
|
|
33175
|
+
this._geometryVaoHash[i] = null;
|
|
33176
|
+
}
|
|
33567
33177
|
}
|
|
33568
33178
|
/**
|
|
33569
33179
|
* Activate vertex array object.
|
|
@@ -33640,12 +33250,12 @@ class GlGeometrySystem {
|
|
|
33640
33250
|
if (geometry.indexBuffer) {
|
|
33641
33251
|
const byteSize = geometry.indexBuffer.data.BYTES_PER_ELEMENT;
|
|
33642
33252
|
const glType = byteSize === 2 ? gl.UNSIGNED_SHORT : gl.UNSIGNED_INT;
|
|
33643
|
-
if (instanceCount
|
|
33253
|
+
if (instanceCount > 1) {
|
|
33644
33254
|
gl.drawElementsInstanced(glTopology, size || geometry.indexBuffer.data.length, glType, (start || 0) * byteSize, instanceCount);
|
|
33645
33255
|
} else {
|
|
33646
33256
|
gl.drawElements(glTopology, size || geometry.indexBuffer.data.length, glType, (start || 0) * byteSize);
|
|
33647
33257
|
}
|
|
33648
|
-
} else if (instanceCount
|
|
33258
|
+
} else if (instanceCount > 1) {
|
|
33649
33259
|
gl.drawArraysInstanced(glTopology, start || 0, size || geometry.getSize(), instanceCount);
|
|
33650
33260
|
} else {
|
|
33651
33261
|
gl.drawArrays(glTopology, start || 0, size || geometry.getSize());
|
|
@@ -33659,11 +33269,11 @@ class GlGeometrySystem {
|
|
|
33659
33269
|
this._activeGeometry = null;
|
|
33660
33270
|
}
|
|
33661
33271
|
destroy() {
|
|
33662
|
-
this._managedGeometries.destroy();
|
|
33663
33272
|
this._renderer = null;
|
|
33664
33273
|
this.gl = null;
|
|
33665
33274
|
this._activeVao = null;
|
|
33666
33275
|
this._activeGeometry = null;
|
|
33276
|
+
this._geometryVaoHash = null;
|
|
33667
33277
|
}
|
|
33668
33278
|
}
|
|
33669
33279
|
/** @ignore */
|
|
@@ -34464,11 +34074,6 @@ class GlRenderTargetAdaptor {
|
|
|
34464
34074
|
contextChange() {
|
|
34465
34075
|
this._clearColorCache = [0, 0, 0, 0];
|
|
34466
34076
|
this._viewPortCache = new Rectangle();
|
|
34467
|
-
const gl = this._renderer.gl;
|
|
34468
|
-
this._drawBuffersCache = [];
|
|
34469
|
-
for (let i = 1; i <= 16; i++) {
|
|
34470
|
-
this._drawBuffersCache[i] = Array.from({ length: i }, (_, j) => gl.COLOR_ATTACHMENT0 + j);
|
|
34471
|
-
}
|
|
34472
34077
|
}
|
|
34473
34078
|
copyToTexture(sourceRenderSurfaceTexture, destinationTexture, originSrc, size, originDest) {
|
|
34474
34079
|
const renderTargetSystem = this._renderTargetSystem;
|
|
@@ -34496,16 +34101,13 @@ class GlRenderTargetAdaptor {
|
|
|
34496
34101
|
const gpuRenderTarget = renderTargetSystem.getGpuRenderTarget(renderTarget);
|
|
34497
34102
|
let viewPortY = viewport.y;
|
|
34498
34103
|
if (renderTarget.isRoot) {
|
|
34499
|
-
viewPortY = source.pixelHeight - viewport.height
|
|
34104
|
+
viewPortY = source.pixelHeight - viewport.height;
|
|
34500
34105
|
}
|
|
34501
34106
|
renderTarget.colorTextures.forEach((texture) => {
|
|
34502
34107
|
this._renderer.texture.unbind(texture);
|
|
34503
34108
|
});
|
|
34504
34109
|
const gl = this._renderer.gl;
|
|
34505
34110
|
gl.bindFramebuffer(gl.FRAMEBUFFER, gpuRenderTarget.framebuffer);
|
|
34506
|
-
if (renderTarget.colorTextures.length > 1) {
|
|
34507
|
-
this._setDrawBuffers(renderTarget, gl);
|
|
34508
|
-
}
|
|
34509
34111
|
const viewPortCache = this._viewPortCache;
|
|
34510
34112
|
if (viewPortCache.x !== viewport.x || viewPortCache.y !== viewPortY || viewPortCache.width !== viewport.width || viewPortCache.height !== viewport.height) {
|
|
34511
34113
|
viewPortCache.x = viewport.x;
|
|
@@ -34619,8 +34221,7 @@ class GlRenderTargetAdaptor {
|
|
|
34619
34221
|
gl.bindFramebuffer(gl.FRAMEBUFFER, resolveTargetFramebuffer);
|
|
34620
34222
|
glRenderTarget.width = renderTarget.colorTexture.source.pixelWidth;
|
|
34621
34223
|
glRenderTarget.height = renderTarget.colorTexture.source.pixelHeight;
|
|
34622
|
-
|
|
34623
|
-
colorTextures.forEach((colorTexture, i) => {
|
|
34224
|
+
renderTarget.colorTextures.forEach((colorTexture, i) => {
|
|
34624
34225
|
const source = colorTexture.source;
|
|
34625
34226
|
if (source.antialias) {
|
|
34626
34227
|
if (renderer.context.supports.msaa) {
|
|
@@ -34754,20 +34355,6 @@ class GlRenderTargetAdaptor {
|
|
|
34754
34355
|
);
|
|
34755
34356
|
}
|
|
34756
34357
|
}
|
|
34757
|
-
_setDrawBuffers(renderTarget, gl) {
|
|
34758
|
-
const count = renderTarget.colorTextures.length;
|
|
34759
|
-
const bufferArray = this._drawBuffersCache[count];
|
|
34760
|
-
if (this._renderer.context.webGLVersion === 1) {
|
|
34761
|
-
const ext = this._renderer.context.extensions.drawBuffers;
|
|
34762
|
-
if (!ext) {
|
|
34763
|
-
warn("[RenderTexture] This WebGL1 context does not support rendering to multiple targets");
|
|
34764
|
-
} else {
|
|
34765
|
-
ext.drawBuffersWEBGL(bufferArray);
|
|
34766
|
-
}
|
|
34767
|
-
} else {
|
|
34768
|
-
gl.drawBuffers(bufferArray);
|
|
34769
|
-
}
|
|
34770
|
-
}
|
|
34771
34358
|
}
|
|
34772
34359
|
|
|
34773
34360
|
function calculateProjection(pm, x, y, width, height, flipY) {
|
|
@@ -35312,7 +34899,6 @@ class BufferResource extends EventEmitter {
|
|
|
35312
34899
|
}
|
|
35313
34900
|
this.emit("change", this);
|
|
35314
34901
|
this.buffer = null;
|
|
35315
|
-
this.removeAllListeners();
|
|
35316
34902
|
}
|
|
35317
34903
|
}
|
|
35318
34904
|
|
|
@@ -35727,6 +35313,7 @@ class GlShaderSystem {
|
|
|
35727
35313
|
this._programDataHash = /* @__PURE__ */ Object.create(null);
|
|
35728
35314
|
this._shaderSyncFunctions = /* @__PURE__ */ Object.create(null);
|
|
35729
35315
|
this._renderer = renderer;
|
|
35316
|
+
this._renderer.renderableGC.addManagedHash(this, "_programDataHash");
|
|
35730
35317
|
}
|
|
35731
35318
|
contextChange(gl) {
|
|
35732
35319
|
this._gl = gl;
|
|
@@ -35813,7 +35400,9 @@ class GlShaderSystem {
|
|
|
35813
35400
|
}
|
|
35814
35401
|
destroy() {
|
|
35815
35402
|
for (const key of Object.keys(this._programDataHash)) {
|
|
35816
|
-
this._programDataHash[key]
|
|
35403
|
+
const programData = this._programDataHash[key];
|
|
35404
|
+
programData.destroy();
|
|
35405
|
+
this._programDataHash[key] = null;
|
|
35817
35406
|
}
|
|
35818
35407
|
this._programDataHash = null;
|
|
35819
35408
|
this._shaderSyncFunctions = null;
|
|
@@ -36357,8 +35946,6 @@ class GlTexture {
|
|
|
36357
35946
|
this.format = GL_FORMATS.RGBA;
|
|
36358
35947
|
this.samplerType = 0;
|
|
36359
35948
|
}
|
|
36360
|
-
destroy() {
|
|
36361
|
-
}
|
|
36362
35949
|
}
|
|
36363
35950
|
|
|
36364
35951
|
const glUploadBufferImageResource = {
|
|
@@ -36898,6 +36485,8 @@ function mapFormatToGlType(gl) {
|
|
|
36898
36485
|
const BYTES_PER_PIXEL = 4;
|
|
36899
36486
|
class GlTextureSystem {
|
|
36900
36487
|
constructor(renderer) {
|
|
36488
|
+
this.managedTextures = [];
|
|
36489
|
+
this._glTextures = /* @__PURE__ */ Object.create(null);
|
|
36901
36490
|
this._glSamplers = /* @__PURE__ */ Object.create(null);
|
|
36902
36491
|
this._boundTextures = [];
|
|
36903
36492
|
this._activeTextureLocation = -1;
|
|
@@ -36912,18 +36501,8 @@ class GlTextureSystem {
|
|
|
36912
36501
|
// TODO - separate samplers will be a cool thing to add, but not right now!
|
|
36913
36502
|
this._useSeparateSamplers = false;
|
|
36914
36503
|
this._renderer = renderer;
|
|
36915
|
-
this.
|
|
36916
|
-
|
|
36917
|
-
type: "resource",
|
|
36918
|
-
onUnload: this.onSourceUnload.bind(this),
|
|
36919
|
-
name: "glTexture"
|
|
36920
|
-
});
|
|
36921
|
-
}
|
|
36922
|
-
/**
|
|
36923
|
-
* @deprecated since 8.15.0
|
|
36924
|
-
*/
|
|
36925
|
-
get managedTextures() {
|
|
36926
|
-
return Object.values(this._managedTextures.items);
|
|
36504
|
+
this._renderer.renderableGC.addManagedHash(this, "_glTextures");
|
|
36505
|
+
this._renderer.renderableGC.addManagedHash(this, "_glSamplers");
|
|
36927
36506
|
}
|
|
36928
36507
|
contextChange(gl) {
|
|
36929
36508
|
this._gl = gl;
|
|
@@ -36932,7 +36511,7 @@ class GlTextureSystem {
|
|
|
36932
36511
|
this._mapFormatToType = mapFormatToGlType(gl);
|
|
36933
36512
|
this._mapFormatToFormat = mapFormatToGlFormat(gl);
|
|
36934
36513
|
}
|
|
36935
|
-
this.
|
|
36514
|
+
this._glTextures = /* @__PURE__ */ Object.create(null);
|
|
36936
36515
|
this._glSamplers = /* @__PURE__ */ Object.create(null);
|
|
36937
36516
|
this._boundSamplers = /* @__PURE__ */ Object.create(null);
|
|
36938
36517
|
this._premultiplyAlpha = false;
|
|
@@ -36964,7 +36543,7 @@ class GlTextureSystem {
|
|
|
36964
36543
|
}
|
|
36965
36544
|
bindSource(source, location = 0) {
|
|
36966
36545
|
const gl = this._gl;
|
|
36967
|
-
source.
|
|
36546
|
+
source._touched = this._renderer.textureGC.count;
|
|
36968
36547
|
if (this._boundTextures[location] !== source) {
|
|
36969
36548
|
this._boundTextures[location] = source;
|
|
36970
36549
|
this._activateLocation(location);
|
|
@@ -37015,13 +36594,15 @@ class GlTextureSystem {
|
|
|
37015
36594
|
const biggestDimension = Math.max(source.width, source.height);
|
|
37016
36595
|
source.mipLevelCount = Math.floor(Math.log2(biggestDimension)) + 1;
|
|
37017
36596
|
}
|
|
37018
|
-
|
|
37019
|
-
|
|
37020
|
-
if (added) {
|
|
36597
|
+
this._glTextures[source.uid] = glTexture;
|
|
36598
|
+
if (!this.managedTextures.includes(source)) {
|
|
37021
36599
|
source.on("update", this.onSourceUpdate, this);
|
|
37022
36600
|
source.on("resize", this.onSourceUpdate, this);
|
|
37023
36601
|
source.on("styleChange", this.onStyleChange, this);
|
|
36602
|
+
source.on("destroy", this.onSourceDestroy, this);
|
|
36603
|
+
source.on("unload", this.onSourceUnload, this);
|
|
37024
36604
|
source.on("updateMipmaps", this.onUpdateMipmaps, this);
|
|
36605
|
+
this.managedTextures.push(source);
|
|
37025
36606
|
}
|
|
37026
36607
|
this.onSourceUpdate(source);
|
|
37027
36608
|
this.updateStyle(source, false);
|
|
@@ -37047,18 +36628,13 @@ class GlTextureSystem {
|
|
|
37047
36628
|
firstCreation
|
|
37048
36629
|
);
|
|
37049
36630
|
}
|
|
37050
|
-
onSourceUnload(source
|
|
37051
|
-
const glTexture =
|
|
36631
|
+
onSourceUnload(source) {
|
|
36632
|
+
const glTexture = this._glTextures[source.uid];
|
|
37052
36633
|
if (!glTexture)
|
|
37053
36634
|
return;
|
|
37054
|
-
|
|
37055
|
-
|
|
37056
|
-
|
|
37057
|
-
}
|
|
37058
|
-
source.off("update", this.onSourceUpdate, this);
|
|
37059
|
-
source.off("resize", this.onSourceUpdate, this);
|
|
37060
|
-
source.off("styleChange", this.onStyleChange, this);
|
|
37061
|
-
source.off("updateMipmaps", this.onUpdateMipmaps, this);
|
|
36635
|
+
this.unbind(source);
|
|
36636
|
+
this._glTextures[source.uid] = null;
|
|
36637
|
+
this._gl.deleteTexture(glTexture.texture);
|
|
37062
36638
|
}
|
|
37063
36639
|
onSourceUpdate(source) {
|
|
37064
36640
|
const gl = this._gl;
|
|
@@ -37073,17 +36649,7 @@ class GlTextureSystem {
|
|
|
37073
36649
|
if (this._uploads[source.uploadMethodId]) {
|
|
37074
36650
|
this._uploads[source.uploadMethodId].upload(source, glTexture, gl, this._renderer.context.webGLVersion);
|
|
37075
36651
|
} else {
|
|
37076
|
-
gl.texImage2D(
|
|
37077
|
-
gl.TEXTURE_2D,
|
|
37078
|
-
0,
|
|
37079
|
-
glTexture.internalFormat,
|
|
37080
|
-
source.pixelWidth,
|
|
37081
|
-
source.pixelHeight,
|
|
37082
|
-
0,
|
|
37083
|
-
glTexture.format,
|
|
37084
|
-
glTexture.type,
|
|
37085
|
-
null
|
|
37086
|
-
);
|
|
36652
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, source.pixelWidth, source.pixelHeight, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
37087
36653
|
}
|
|
37088
36654
|
if (source.autoGenerateMipmaps && source.mipLevelCount > 1) {
|
|
37089
36655
|
this.onUpdateMipmaps(source, false);
|
|
@@ -37095,6 +36661,16 @@ class GlTextureSystem {
|
|
|
37095
36661
|
const glTexture = this.getGlSource(source);
|
|
37096
36662
|
this._gl.generateMipmap(glTexture.target);
|
|
37097
36663
|
}
|
|
36664
|
+
onSourceDestroy(source) {
|
|
36665
|
+
source.off("destroy", this.onSourceDestroy, this);
|
|
36666
|
+
source.off("update", this.onSourceUpdate, this);
|
|
36667
|
+
source.off("resize", this.onSourceUpdate, this);
|
|
36668
|
+
source.off("unload", this.onSourceUnload, this);
|
|
36669
|
+
source.off("styleChange", this.onStyleChange, this);
|
|
36670
|
+
source.off("updateMipmaps", this.onUpdateMipmaps, this);
|
|
36671
|
+
this.managedTextures.splice(this.managedTextures.indexOf(source), 1);
|
|
36672
|
+
this.onSourceUnload(source);
|
|
36673
|
+
}
|
|
37098
36674
|
_initSampler(style) {
|
|
37099
36675
|
const gl = this._gl;
|
|
37100
36676
|
const glSampler = this._gl.createSampler();
|
|
@@ -37115,8 +36691,7 @@ class GlTextureSystem {
|
|
|
37115
36691
|
return this._glSamplers[sampler._resourceId] || this._initSampler(sampler);
|
|
37116
36692
|
}
|
|
37117
36693
|
getGlSource(source) {
|
|
37118
|
-
source.
|
|
37119
|
-
return source._gpuData[this._renderer.uid] || this._initSource(source);
|
|
36694
|
+
return this._glTextures[source.uid] || this._initSource(source);
|
|
37120
36695
|
}
|
|
37121
36696
|
generateCanvas(texture) {
|
|
37122
36697
|
const { pixels, width, height } = this.getPixels(texture);
|
|
@@ -37154,7 +36729,9 @@ class GlTextureSystem {
|
|
|
37154
36729
|
return { pixels: new Uint8ClampedArray(pixels.buffer), width, height };
|
|
37155
36730
|
}
|
|
37156
36731
|
destroy() {
|
|
37157
|
-
this.
|
|
36732
|
+
this.managedTextures.slice().forEach((source) => this.onSourceDestroy(source));
|
|
36733
|
+
this.managedTextures = null;
|
|
36734
|
+
this._glTextures = null;
|
|
37158
36735
|
this._glSamplers = null;
|
|
37159
36736
|
this._boundTextures = null;
|
|
37160
36737
|
this._boundSamplers = null;
|
|
@@ -37358,7 +36935,6 @@ class BatchableSprite {
|
|
|
37358
36935
|
this.bounds = null;
|
|
37359
36936
|
}
|
|
37360
36937
|
destroy() {
|
|
37361
|
-
this.reset();
|
|
37362
36938
|
}
|
|
37363
36939
|
}
|
|
37364
36940
|
|
|
@@ -37571,9 +37147,9 @@ function updateColorBlendVisibility(container, parent, updateFlags) {
|
|
|
37571
37147
|
}
|
|
37572
37148
|
|
|
37573
37149
|
function validateRenderables(renderGroup, renderPipes) {
|
|
37574
|
-
const { list } = renderGroup.childrenRenderablesToUpdate;
|
|
37150
|
+
const { list, index } = renderGroup.childrenRenderablesToUpdate;
|
|
37575
37151
|
let rebuildRequired = false;
|
|
37576
|
-
for (let i = 0; i <
|
|
37152
|
+
for (let i = 0; i < index; i++) {
|
|
37577
37153
|
const container = list[i];
|
|
37578
37154
|
const renderable = container;
|
|
37579
37155
|
const pipe = renderPipes[renderable.renderPipeId];
|
|
@@ -38385,19 +37961,9 @@ _ExtractSystem.defaultImageOptions = {
|
|
|
38385
37961
|
let ExtractSystem = _ExtractSystem;
|
|
38386
37962
|
|
|
38387
37963
|
class RenderTexture extends Texture {
|
|
38388
|
-
/**
|
|
38389
|
-
* Creates a RenderTexture. Pass `dynamic: true` in options to allow resizing after creation.
|
|
38390
|
-
* @param options - Options for the RenderTexture, including width, height, and dynamic.
|
|
38391
|
-
* @returns A new RenderTexture instance.
|
|
38392
|
-
* @example
|
|
38393
|
-
* const rt = RenderTexture.create({ width: 100, height: 100, dynamic: true });
|
|
38394
|
-
* rt.resize(500, 500);
|
|
38395
|
-
*/
|
|
38396
37964
|
static create(options) {
|
|
38397
|
-
const { dynamic, ...rest } = options;
|
|
38398
37965
|
return new RenderTexture({
|
|
38399
|
-
source: new TextureSource(
|
|
38400
|
-
dynamic: dynamic ?? false
|
|
37966
|
+
source: new TextureSource(options)
|
|
38401
37967
|
});
|
|
38402
37968
|
}
|
|
38403
37969
|
/**
|
|
@@ -38508,278 +38074,6 @@ GenerateTextureSystem.extension = {
|
|
|
38508
38074
|
name: "textureGenerator"
|
|
38509
38075
|
};
|
|
38510
38076
|
|
|
38511
|
-
const _GCSystem = class _GCSystem {
|
|
38512
|
-
/**
|
|
38513
|
-
* Creates a new GCSystem instance.
|
|
38514
|
-
* @param renderer - The renderer this garbage collection system works for
|
|
38515
|
-
*/
|
|
38516
|
-
constructor(renderer) {
|
|
38517
|
-
/** Array of resources being tracked for garbage collection */
|
|
38518
|
-
this._managedResources = [];
|
|
38519
|
-
this._managedResourceHashes = [];
|
|
38520
|
-
this._ready = false;
|
|
38521
|
-
this._renderer = renderer;
|
|
38522
|
-
}
|
|
38523
|
-
/**
|
|
38524
|
-
* Initializes the garbage collection system with the provided options.
|
|
38525
|
-
* @param options - Configuration options
|
|
38526
|
-
*/
|
|
38527
|
-
init(options) {
|
|
38528
|
-
options = { ..._GCSystem.defaultOptions, ...options };
|
|
38529
|
-
this.maxUnusedTime = options.gcMaxUnusedTime;
|
|
38530
|
-
this._frequency = options.gcFrequency;
|
|
38531
|
-
this.enabled = options.gcActive;
|
|
38532
|
-
this.now = performance.now();
|
|
38533
|
-
}
|
|
38534
|
-
/**
|
|
38535
|
-
* Gets whether the garbage collection system is currently enabled.
|
|
38536
|
-
* @returns True if GC is enabled, false otherwise
|
|
38537
|
-
*/
|
|
38538
|
-
get enabled() {
|
|
38539
|
-
return !!this._handler;
|
|
38540
|
-
}
|
|
38541
|
-
/**
|
|
38542
|
-
* Enables or disables the garbage collection system.
|
|
38543
|
-
* When enabled, schedules periodic cleanup of resources.
|
|
38544
|
-
* When disabled, cancels all scheduled cleanups.
|
|
38545
|
-
*/
|
|
38546
|
-
set enabled(value) {
|
|
38547
|
-
if (this.enabled === value)
|
|
38548
|
-
return;
|
|
38549
|
-
if (value) {
|
|
38550
|
-
this._handler = this._renderer.scheduler.repeat(
|
|
38551
|
-
() => {
|
|
38552
|
-
this._ready = true;
|
|
38553
|
-
},
|
|
38554
|
-
this._frequency,
|
|
38555
|
-
false
|
|
38556
|
-
);
|
|
38557
|
-
} else {
|
|
38558
|
-
this._renderer.scheduler.cancel(this._handler);
|
|
38559
|
-
this._handler = 0;
|
|
38560
|
-
}
|
|
38561
|
-
}
|
|
38562
|
-
/**
|
|
38563
|
-
* Called before rendering. Updates the current timestamp.
|
|
38564
|
-
* @param options - The render options
|
|
38565
|
-
* @param options.container - The container to render
|
|
38566
|
-
*/
|
|
38567
|
-
prerender({ container }) {
|
|
38568
|
-
this.now = performance.now();
|
|
38569
|
-
container.renderGroup.gcTick = this._renderer.tick++;
|
|
38570
|
-
this._updateInstructionGCTick(container.renderGroup, container.renderGroup.gcTick);
|
|
38571
|
-
}
|
|
38572
|
-
/** Performs garbage collection after rendering. */
|
|
38573
|
-
postrender() {
|
|
38574
|
-
if (!this._ready || !this.enabled)
|
|
38575
|
-
return;
|
|
38576
|
-
this.run();
|
|
38577
|
-
this._ready = false;
|
|
38578
|
-
}
|
|
38579
|
-
/**
|
|
38580
|
-
* Updates the GC tick counter for a render group and its children.
|
|
38581
|
-
* @param renderGroup - The render group to update
|
|
38582
|
-
* @param gcTick - The new tick value
|
|
38583
|
-
*/
|
|
38584
|
-
_updateInstructionGCTick(renderGroup, gcTick) {
|
|
38585
|
-
renderGroup.instructionSet.gcTick = gcTick;
|
|
38586
|
-
for (const child of renderGroup.renderGroupChildren) {
|
|
38587
|
-
this._updateInstructionGCTick(child, gcTick);
|
|
38588
|
-
}
|
|
38589
|
-
}
|
|
38590
|
-
/**
|
|
38591
|
-
* Registers a resource for garbage collection tracking.
|
|
38592
|
-
* @param resource - The resource to track
|
|
38593
|
-
* @param type - The type of resource to track
|
|
38594
|
-
*/
|
|
38595
|
-
addResource(resource, type) {
|
|
38596
|
-
if (resource._gcLastUsed !== -1) {
|
|
38597
|
-
resource._gcLastUsed = this.now;
|
|
38598
|
-
resource._onTouch?.(this.now);
|
|
38599
|
-
return;
|
|
38600
|
-
}
|
|
38601
|
-
const index = this._managedResources.length;
|
|
38602
|
-
resource._gcData = {
|
|
38603
|
-
index,
|
|
38604
|
-
type
|
|
38605
|
-
};
|
|
38606
|
-
resource._gcLastUsed = this.now;
|
|
38607
|
-
resource._onTouch?.(this.now);
|
|
38608
|
-
resource.once("unload", this.removeResource, this);
|
|
38609
|
-
this._managedResources.push(resource);
|
|
38610
|
-
}
|
|
38611
|
-
/**
|
|
38612
|
-
* Removes a resource from garbage collection tracking.
|
|
38613
|
-
* Call this when manually destroying a resource.
|
|
38614
|
-
* @param resource - The resource to stop tracking
|
|
38615
|
-
*/
|
|
38616
|
-
removeResource(resource) {
|
|
38617
|
-
const gcData = resource._gcData;
|
|
38618
|
-
if (!gcData)
|
|
38619
|
-
return;
|
|
38620
|
-
const index = gcData.index;
|
|
38621
|
-
const last = this._managedResources.length - 1;
|
|
38622
|
-
if (index !== last) {
|
|
38623
|
-
const lastResource = this._managedResources[last];
|
|
38624
|
-
this._managedResources[index] = lastResource;
|
|
38625
|
-
lastResource._gcData.index = index;
|
|
38626
|
-
}
|
|
38627
|
-
this._managedResources.length--;
|
|
38628
|
-
resource._gcData = null;
|
|
38629
|
-
resource._gcLastUsed = -1;
|
|
38630
|
-
}
|
|
38631
|
-
/**
|
|
38632
|
-
* Registers a hash-based resource collection for garbage collection tracking.
|
|
38633
|
-
* Resources in the hash will be automatically tracked and cleaned up when unused.
|
|
38634
|
-
* @param context - The object containing the hash property
|
|
38635
|
-
* @param hash - The property name on context that holds the resource hash
|
|
38636
|
-
* @param type - The type of resources in the hash ('resource' or 'renderable')
|
|
38637
|
-
* @param priority - Processing priority (lower values are processed first)
|
|
38638
|
-
*/
|
|
38639
|
-
addResourceHash(context, hash, type, priority = 0) {
|
|
38640
|
-
this._managedResourceHashes.push({
|
|
38641
|
-
context,
|
|
38642
|
-
hash,
|
|
38643
|
-
type,
|
|
38644
|
-
priority
|
|
38645
|
-
});
|
|
38646
|
-
this._managedResourceHashes.sort((a, b) => a.priority - b.priority);
|
|
38647
|
-
}
|
|
38648
|
-
/**
|
|
38649
|
-
* Performs garbage collection by cleaning up unused resources.
|
|
38650
|
-
* Removes resources that haven't been used for longer than maxUnusedTime.
|
|
38651
|
-
*/
|
|
38652
|
-
run() {
|
|
38653
|
-
const now = performance.now();
|
|
38654
|
-
const managedResourceHashes = this._managedResourceHashes;
|
|
38655
|
-
for (const hashEntry of managedResourceHashes) {
|
|
38656
|
-
this.runOnHash(hashEntry, now);
|
|
38657
|
-
}
|
|
38658
|
-
let writeIndex = 0;
|
|
38659
|
-
for (let i = 0; i < this._managedResources.length; i++) {
|
|
38660
|
-
const resource = this._managedResources[i];
|
|
38661
|
-
writeIndex = this.runOnResource(resource, now, writeIndex);
|
|
38662
|
-
}
|
|
38663
|
-
this._managedResources.length = writeIndex;
|
|
38664
|
-
}
|
|
38665
|
-
updateRenderableGCTick(renderable, now) {
|
|
38666
|
-
const renderGroup = renderable.renderGroup ?? renderable.parentRenderGroup;
|
|
38667
|
-
const currentTick = renderGroup?.instructionSet?.gcTick ?? -1;
|
|
38668
|
-
if ((renderGroup?.gcTick ?? 0) === currentTick) {
|
|
38669
|
-
renderable._gcLastUsed = now;
|
|
38670
|
-
renderable._onTouch?.(now);
|
|
38671
|
-
}
|
|
38672
|
-
}
|
|
38673
|
-
runOnResource(resource, now, writeIndex) {
|
|
38674
|
-
const gcData = resource._gcData;
|
|
38675
|
-
if (gcData.type === "renderable") {
|
|
38676
|
-
this.updateRenderableGCTick(resource, now);
|
|
38677
|
-
}
|
|
38678
|
-
const isRecentlyUsed = now - resource._gcLastUsed < this.maxUnusedTime;
|
|
38679
|
-
if (isRecentlyUsed || !resource.autoGarbageCollect) {
|
|
38680
|
-
this._managedResources[writeIndex] = resource;
|
|
38681
|
-
gcData.index = writeIndex;
|
|
38682
|
-
writeIndex++;
|
|
38683
|
-
} else {
|
|
38684
|
-
resource.unload();
|
|
38685
|
-
resource._gcData = null;
|
|
38686
|
-
resource._gcLastUsed = -1;
|
|
38687
|
-
resource.off("unload", this.removeResource, this);
|
|
38688
|
-
}
|
|
38689
|
-
return writeIndex;
|
|
38690
|
-
}
|
|
38691
|
-
/**
|
|
38692
|
-
* Creates a clone of the hash, copying all non-null entries up to (but not including) the stop key.
|
|
38693
|
-
* @param hashValue - The original hash to clone from
|
|
38694
|
-
* @param stopKey - The key to stop at (exclusive)
|
|
38695
|
-
* @returns A new hash object with copied entries
|
|
38696
|
-
*/
|
|
38697
|
-
_createHashClone(hashValue, stopKey) {
|
|
38698
|
-
const hashClone = /* @__PURE__ */ Object.create(null);
|
|
38699
|
-
for (const k in hashValue) {
|
|
38700
|
-
if (k === stopKey)
|
|
38701
|
-
break;
|
|
38702
|
-
if (hashValue[k] !== null)
|
|
38703
|
-
hashClone[k] = hashValue[k];
|
|
38704
|
-
}
|
|
38705
|
-
return hashClone;
|
|
38706
|
-
}
|
|
38707
|
-
runOnHash(hashEntry, now) {
|
|
38708
|
-
const { context, hash, type } = hashEntry;
|
|
38709
|
-
const hashValue = context[hash];
|
|
38710
|
-
let hashClone = null;
|
|
38711
|
-
let nullCount = 0;
|
|
38712
|
-
for (const key in hashValue) {
|
|
38713
|
-
const resource = hashValue[key];
|
|
38714
|
-
if (resource === null) {
|
|
38715
|
-
nullCount++;
|
|
38716
|
-
if (nullCount === 1e4 && !hashClone) {
|
|
38717
|
-
hashClone = this._createHashClone(hashValue, key);
|
|
38718
|
-
}
|
|
38719
|
-
continue;
|
|
38720
|
-
}
|
|
38721
|
-
if (resource._gcLastUsed === -1) {
|
|
38722
|
-
resource._gcLastUsed = now;
|
|
38723
|
-
resource._onTouch?.(now);
|
|
38724
|
-
if (hashClone)
|
|
38725
|
-
hashClone[key] = resource;
|
|
38726
|
-
continue;
|
|
38727
|
-
}
|
|
38728
|
-
if (type === "renderable") {
|
|
38729
|
-
this.updateRenderableGCTick(resource, now);
|
|
38730
|
-
}
|
|
38731
|
-
const isRecentlyUsed = now - resource._gcLastUsed < this.maxUnusedTime;
|
|
38732
|
-
if (!isRecentlyUsed && resource.autoGarbageCollect) {
|
|
38733
|
-
if (!hashClone) {
|
|
38734
|
-
if (nullCount + 1 !== 1e4) {
|
|
38735
|
-
hashValue[key] = null;
|
|
38736
|
-
nullCount++;
|
|
38737
|
-
} else {
|
|
38738
|
-
hashClone = this._createHashClone(hashValue, key);
|
|
38739
|
-
}
|
|
38740
|
-
}
|
|
38741
|
-
resource.unload();
|
|
38742
|
-
resource._gcData = null;
|
|
38743
|
-
resource._gcLastUsed = -1;
|
|
38744
|
-
} else if (hashClone) {
|
|
38745
|
-
hashClone[key] = resource;
|
|
38746
|
-
}
|
|
38747
|
-
}
|
|
38748
|
-
if (hashClone) {
|
|
38749
|
-
context[hash] = hashClone;
|
|
38750
|
-
}
|
|
38751
|
-
}
|
|
38752
|
-
/** Cleans up the garbage collection system. Disables GC and removes all tracked resources. */
|
|
38753
|
-
destroy() {
|
|
38754
|
-
this.enabled = false;
|
|
38755
|
-
this._managedResources.forEach((resource) => {
|
|
38756
|
-
resource.off("unload", this.removeResource, this);
|
|
38757
|
-
});
|
|
38758
|
-
this._managedResources.length = 0;
|
|
38759
|
-
this._managedResourceHashes.length = 0;
|
|
38760
|
-
this._renderer = null;
|
|
38761
|
-
}
|
|
38762
|
-
};
|
|
38763
|
-
/** @ignore */
|
|
38764
|
-
_GCSystem.extension = {
|
|
38765
|
-
type: [
|
|
38766
|
-
ExtensionType.WebGLSystem,
|
|
38767
|
-
ExtensionType.WebGPUSystem
|
|
38768
|
-
],
|
|
38769
|
-
name: "gc",
|
|
38770
|
-
priority: 0
|
|
38771
|
-
};
|
|
38772
|
-
/** Default options for the GCSystem */
|
|
38773
|
-
_GCSystem.defaultOptions = {
|
|
38774
|
-
/** Enable/disable the garbage collector */
|
|
38775
|
-
gcActive: true,
|
|
38776
|
-
/** Time in ms before an unused resource is collected (default 1 minute) */
|
|
38777
|
-
gcMaxUnusedTime: 6e4,
|
|
38778
|
-
/** How often to run garbage collection in ms (default 30 seconds) */
|
|
38779
|
-
gcFrequency: 3e4
|
|
38780
|
-
};
|
|
38781
|
-
let GCSystem = _GCSystem;
|
|
38782
|
-
|
|
38783
38077
|
function color32BitToUniform(abgr, out, offset) {
|
|
38784
38078
|
const alpha = (abgr >> 24 & 255) / 255;
|
|
38785
38079
|
out[offset++] = (abgr & 255) / 255 * alpha;
|
|
@@ -39286,86 +38580,48 @@ _RenderableGCSystem.defaultOptions = {
|
|
|
39286
38580
|
let RenderableGCSystem = _RenderableGCSystem;
|
|
39287
38581
|
|
|
39288
38582
|
const _TextureGCSystem = class _TextureGCSystem {
|
|
39289
|
-
/**
|
|
39290
|
-
* Frame count since started.
|
|
39291
|
-
* @readonly
|
|
39292
|
-
* @deprecated since 8.15.0
|
|
39293
|
-
*/
|
|
39294
|
-
get count() {
|
|
39295
|
-
return this._renderer.tick;
|
|
39296
|
-
}
|
|
39297
|
-
/**
|
|
39298
|
-
* Frame count since last garbage collection.
|
|
39299
|
-
* @readonly
|
|
39300
|
-
* @deprecated since 8.15.0
|
|
39301
|
-
*/
|
|
39302
|
-
get checkCount() {
|
|
39303
|
-
return this._checkCount;
|
|
39304
|
-
}
|
|
39305
|
-
set checkCount(value) {
|
|
39306
|
-
deprecation("8.15.0", "TextureGCSystem.run is deprecated, please use the GCSystem instead.");
|
|
39307
|
-
this._checkCount = value;
|
|
39308
|
-
}
|
|
39309
|
-
/**
|
|
39310
|
-
* Maximum idle frames before a texture is destroyed by garbage collection.
|
|
39311
|
-
* @see TextureGCSystem.defaultMaxIdle
|
|
39312
|
-
* @deprecated since 8.15.0
|
|
39313
|
-
*/
|
|
39314
|
-
get maxIdle() {
|
|
39315
|
-
return this._renderer.gc.maxUnusedTime / 1e3 * 60;
|
|
39316
|
-
}
|
|
39317
|
-
set maxIdle(value) {
|
|
39318
|
-
deprecation("8.15.0", "TextureGCSystem.run is deprecated, please use the GCSystem instead.");
|
|
39319
|
-
this._renderer.gc.maxUnusedTime = value / 60 * 1e3;
|
|
39320
|
-
}
|
|
39321
|
-
/**
|
|
39322
|
-
* Frames between two garbage collections.
|
|
39323
|
-
* @see TextureGCSystem.defaultCheckCountMax
|
|
39324
|
-
* @deprecated since 8.15.0
|
|
39325
|
-
*/
|
|
39326
|
-
// eslint-disable-next-line dot-notation
|
|
39327
|
-
get checkCountMax() {
|
|
39328
|
-
return Math.floor(this._renderer.gc["_frequency"] / 1e3);
|
|
39329
|
-
}
|
|
39330
|
-
set checkCountMax(_value) {
|
|
39331
|
-
deprecation("8.15.0", "TextureGCSystem.run is deprecated, please use the GCSystem instead.");
|
|
39332
|
-
}
|
|
39333
|
-
/**
|
|
39334
|
-
* Current garbage collection mode.
|
|
39335
|
-
* @see TextureGCSystem.defaultMode
|
|
39336
|
-
* @deprecated since 8.15.0
|
|
39337
|
-
*/
|
|
39338
|
-
get active() {
|
|
39339
|
-
return this._renderer.gc.enabled;
|
|
39340
|
-
}
|
|
39341
|
-
set active(value) {
|
|
39342
|
-
deprecation("8.15.0", "TextureGCSystem.run is deprecated, please use the GCSystem instead.");
|
|
39343
|
-
this._renderer.gc.enabled = value;
|
|
39344
|
-
}
|
|
39345
38583
|
/** @param renderer - The renderer this System works for. */
|
|
39346
38584
|
constructor(renderer) {
|
|
39347
38585
|
this._renderer = renderer;
|
|
39348
|
-
this.
|
|
38586
|
+
this.count = 0;
|
|
38587
|
+
this.checkCount = 0;
|
|
39349
38588
|
}
|
|
39350
38589
|
init(options) {
|
|
39351
|
-
|
|
39352
|
-
|
|
39353
|
-
|
|
39354
|
-
|
|
39355
|
-
|
|
38590
|
+
options = { ..._TextureGCSystem.defaultOptions, ...options };
|
|
38591
|
+
this.checkCountMax = options.textureGCCheckCountMax;
|
|
38592
|
+
this.maxIdle = options.textureGCAMaxIdle ?? options.textureGCMaxIdle;
|
|
38593
|
+
this.active = options.textureGCActive;
|
|
38594
|
+
}
|
|
38595
|
+
/**
|
|
38596
|
+
* Checks to see when the last time a texture was used.
|
|
38597
|
+
* If the texture has not been used for a specified amount of time, it will be removed from the GPU.
|
|
38598
|
+
*/
|
|
38599
|
+
postrender() {
|
|
38600
|
+
if (!this._renderer.renderingToScreen) {
|
|
38601
|
+
return;
|
|
39356
38602
|
}
|
|
39357
|
-
|
|
39358
|
-
|
|
38603
|
+
this.count++;
|
|
38604
|
+
if (!this.active)
|
|
38605
|
+
return;
|
|
38606
|
+
this.checkCount++;
|
|
38607
|
+
if (this.checkCount > this.checkCountMax) {
|
|
38608
|
+
this.checkCount = 0;
|
|
38609
|
+
this.run();
|
|
39359
38610
|
}
|
|
39360
38611
|
}
|
|
39361
38612
|
/**
|
|
39362
38613
|
* Checks to see when the last time a texture was used.
|
|
39363
38614
|
* If the texture has not been used for a specified amount of time, it will be removed from the GPU.
|
|
39364
|
-
* @deprecated since 8.15.0
|
|
39365
38615
|
*/
|
|
39366
38616
|
run() {
|
|
39367
|
-
|
|
39368
|
-
|
|
38617
|
+
const managedTextures = this._renderer.texture.managedTextures;
|
|
38618
|
+
for (let i = 0; i < managedTextures.length; i++) {
|
|
38619
|
+
const texture = managedTextures[i];
|
|
38620
|
+
if (texture.autoGarbageCollect && texture.resource && texture._touched > -1 && this.count - texture._touched > this.maxIdle) {
|
|
38621
|
+
texture._touched = -1;
|
|
38622
|
+
texture.unload();
|
|
38623
|
+
}
|
|
38624
|
+
}
|
|
39369
38625
|
}
|
|
39370
38626
|
destroy() {
|
|
39371
38627
|
this._renderer = null;
|
|
@@ -39379,10 +38635,7 @@ _TextureGCSystem.extension = {
|
|
|
39379
38635
|
],
|
|
39380
38636
|
name: "textureGC"
|
|
39381
38637
|
};
|
|
39382
|
-
/**
|
|
39383
|
-
* Default options for the TextureGCSystem
|
|
39384
|
-
* @deprecated since 8.15.0
|
|
39385
|
-
*/
|
|
38638
|
+
/** default options for the TextureGCSystem */
|
|
39386
38639
|
_TextureGCSystem.defaultOptions = {
|
|
39387
38640
|
/**
|
|
39388
38641
|
* If set to true, this will enable the garbage collector on the GPU.
|
|
@@ -39523,7 +38776,6 @@ const SharedSystems = [
|
|
|
39523
38776
|
HelloSystem,
|
|
39524
38777
|
ViewSystem,
|
|
39525
38778
|
RenderGroupSystem,
|
|
39526
|
-
GCSystem,
|
|
39527
38779
|
TextureGCSystem,
|
|
39528
38780
|
GenerateTextureSystem,
|
|
39529
38781
|
ExtractSystem,
|
|
@@ -39590,6 +38842,7 @@ class BindGroupSystem {
|
|
|
39590
38842
|
constructor(renderer) {
|
|
39591
38843
|
this._hash = /* @__PURE__ */ Object.create(null);
|
|
39592
38844
|
this._renderer = renderer;
|
|
38845
|
+
this._renderer.renderableGC.addManagedHash(this, "_hash");
|
|
39593
38846
|
}
|
|
39594
38847
|
contextChange(gpu) {
|
|
39595
38848
|
this._gpu = gpu;
|
|
@@ -39635,7 +38888,7 @@ class BindGroupSystem {
|
|
|
39635
38888
|
gpuResource = renderer.texture.getGpuSampler(sampler);
|
|
39636
38889
|
} else if (resource._resourceType === "textureSource") {
|
|
39637
38890
|
const texture = resource;
|
|
39638
|
-
gpuResource = renderer.texture.getGpuSource(texture).createView();
|
|
38891
|
+
gpuResource = renderer.texture.getGpuSource(texture).createView({});
|
|
39639
38892
|
}
|
|
39640
38893
|
entries.push({
|
|
39641
38894
|
binding: groupLayout[j],
|
|
@@ -39651,6 +38904,9 @@ class BindGroupSystem {
|
|
|
39651
38904
|
return gpuBindGroup;
|
|
39652
38905
|
}
|
|
39653
38906
|
destroy() {
|
|
38907
|
+
for (const key of Object.keys(this._hash)) {
|
|
38908
|
+
this._hash[key] = null;
|
|
38909
|
+
}
|
|
39654
38910
|
this._hash = null;
|
|
39655
38911
|
this._renderer = null;
|
|
39656
38912
|
}
|
|
@@ -39663,34 +38919,20 @@ BindGroupSystem.extension = {
|
|
|
39663
38919
|
name: "bindGroup"
|
|
39664
38920
|
};
|
|
39665
38921
|
|
|
39666
|
-
class GpuBufferData {
|
|
39667
|
-
constructor(gpuBuffer) {
|
|
39668
|
-
this.gpuBuffer = gpuBuffer;
|
|
39669
|
-
}
|
|
39670
|
-
destroy() {
|
|
39671
|
-
this.gpuBuffer.destroy();
|
|
39672
|
-
this.gpuBuffer = null;
|
|
39673
|
-
}
|
|
39674
|
-
}
|
|
39675
38922
|
class GpuBufferSystem {
|
|
39676
38923
|
constructor(renderer) {
|
|
39677
|
-
this.
|
|
39678
|
-
this._managedBuffers =
|
|
39679
|
-
|
|
39680
|
-
type: "resource",
|
|
39681
|
-
onUnload: this.onBufferUnload.bind(this),
|
|
39682
|
-
name: "gpuBuffer"
|
|
39683
|
-
});
|
|
38924
|
+
this._gpuBuffers = /* @__PURE__ */ Object.create(null);
|
|
38925
|
+
this._managedBuffers = [];
|
|
38926
|
+
renderer.renderableGC.addManagedHash(this, "_gpuBuffers");
|
|
39684
38927
|
}
|
|
39685
38928
|
contextChange(gpu) {
|
|
39686
38929
|
this._gpu = gpu;
|
|
39687
38930
|
}
|
|
39688
38931
|
getGPUBuffer(buffer) {
|
|
39689
|
-
buffer.
|
|
39690
|
-
return buffer._gpuData[this._renderer.uid]?.gpuBuffer || this.createGPUBuffer(buffer);
|
|
38932
|
+
return this._gpuBuffers[buffer.uid] || this.createGPUBuffer(buffer);
|
|
39691
38933
|
}
|
|
39692
38934
|
updateBuffer(buffer) {
|
|
39693
|
-
const gpuBuffer = this.
|
|
38935
|
+
const gpuBuffer = this._gpuBuffers[buffer.uid] || this.createGPUBuffer(buffer);
|
|
39694
38936
|
const data = buffer.data;
|
|
39695
38937
|
if (buffer._updateID && data) {
|
|
39696
38938
|
buffer._updateID = 0;
|
|
@@ -39707,36 +38949,53 @@ class GpuBufferSystem {
|
|
|
39707
38949
|
}
|
|
39708
38950
|
/** dispose all WebGL resources of all managed buffers */
|
|
39709
38951
|
destroyAll() {
|
|
39710
|
-
this.
|
|
39711
|
-
|
|
39712
|
-
|
|
39713
|
-
|
|
39714
|
-
buffer.off("change", this.onBufferChange, this);
|
|
38952
|
+
for (const id in this._gpuBuffers) {
|
|
38953
|
+
this._gpuBuffers[id].destroy();
|
|
38954
|
+
}
|
|
38955
|
+
this._gpuBuffers = {};
|
|
39715
38956
|
}
|
|
39716
38957
|
createGPUBuffer(buffer) {
|
|
38958
|
+
if (!this._gpuBuffers[buffer.uid]) {
|
|
38959
|
+
buffer.on("update", this.updateBuffer, this);
|
|
38960
|
+
buffer.on("change", this.onBufferChange, this);
|
|
38961
|
+
buffer.on("destroy", this.onBufferDestroy, this);
|
|
38962
|
+
this._managedBuffers.push(buffer);
|
|
38963
|
+
}
|
|
39717
38964
|
const gpuBuffer = this._gpu.device.createBuffer(buffer.descriptor);
|
|
39718
38965
|
buffer._updateID = 0;
|
|
39719
|
-
buffer._resourceId = uid$1("resource");
|
|
39720
38966
|
if (buffer.data) {
|
|
39721
38967
|
fastCopy(buffer.data.buffer, gpuBuffer.getMappedRange());
|
|
39722
38968
|
gpuBuffer.unmap();
|
|
39723
38969
|
}
|
|
39724
|
-
|
|
39725
|
-
if (this._managedBuffers.add(buffer)) {
|
|
39726
|
-
buffer.on("update", this.updateBuffer, this);
|
|
39727
|
-
buffer.on("change", this.onBufferChange, this);
|
|
39728
|
-
}
|
|
38970
|
+
this._gpuBuffers[buffer.uid] = gpuBuffer;
|
|
39729
38971
|
return gpuBuffer;
|
|
39730
38972
|
}
|
|
39731
38973
|
onBufferChange(buffer) {
|
|
39732
|
-
this.
|
|
38974
|
+
const gpuBuffer = this._gpuBuffers[buffer.uid];
|
|
38975
|
+
gpuBuffer.destroy();
|
|
39733
38976
|
buffer._updateID = 0;
|
|
39734
|
-
this.createGPUBuffer(buffer);
|
|
38977
|
+
this._gpuBuffers[buffer.uid] = this.createGPUBuffer(buffer);
|
|
38978
|
+
}
|
|
38979
|
+
/**
|
|
38980
|
+
* Disposes buffer
|
|
38981
|
+
* @param buffer - buffer with data
|
|
38982
|
+
*/
|
|
38983
|
+
onBufferDestroy(buffer) {
|
|
38984
|
+
this._managedBuffers.splice(this._managedBuffers.indexOf(buffer), 1);
|
|
38985
|
+
this._destroyBuffer(buffer);
|
|
39735
38986
|
}
|
|
39736
38987
|
destroy() {
|
|
39737
|
-
this._managedBuffers.
|
|
39738
|
-
this.
|
|
39739
|
-
this.
|
|
38988
|
+
this._managedBuffers.forEach((buffer) => this._destroyBuffer(buffer));
|
|
38989
|
+
this._managedBuffers = null;
|
|
38990
|
+
this._gpuBuffers = null;
|
|
38991
|
+
}
|
|
38992
|
+
_destroyBuffer(buffer) {
|
|
38993
|
+
const gpuBuffer = this._gpuBuffers[buffer.uid];
|
|
38994
|
+
gpuBuffer.destroy();
|
|
38995
|
+
buffer.off("update", this.updateBuffer, this);
|
|
38996
|
+
buffer.off("change", this.onBufferChange, this);
|
|
38997
|
+
buffer.off("destroy", this.onBufferDestroy, this);
|
|
38998
|
+
this._gpuBuffers[buffer.uid] = null;
|
|
39740
38999
|
}
|
|
39741
39000
|
}
|
|
39742
39001
|
/** @ignore */
|
|
@@ -39933,7 +39192,7 @@ class GpuEncoderSystem {
|
|
|
39933
39192
|
if (this._boundBindGroup[index] === bindGroup)
|
|
39934
39193
|
return;
|
|
39935
39194
|
this._boundBindGroup[index] = bindGroup;
|
|
39936
|
-
bindGroup._touch(this._renderer.
|
|
39195
|
+
bindGroup._touch(this._renderer.textureGC.count);
|
|
39937
39196
|
const gpuBindGroup = this._renderer.bindGroup.getBindGroup(bindGroup, program, index);
|
|
39938
39197
|
this.renderPassEncoder.setBindGroup(index, gpuBindGroup);
|
|
39939
39198
|
}
|
|
@@ -40219,6 +39478,7 @@ class GpuUniformBatchPipe {
|
|
|
40219
39478
|
this._bindGroups = [];
|
|
40220
39479
|
this._bufferResources = [];
|
|
40221
39480
|
this._renderer = renderer;
|
|
39481
|
+
this._renderer.renderableGC.addManagedHash(this, "_bindGroupHash");
|
|
40222
39482
|
this._batchBuffer = new UboBatch({ minUniformOffsetAlignment });
|
|
40223
39483
|
const totalBuffers = 256 / minUniformOffsetAlignment;
|
|
40224
39484
|
for (let i = 0; i < totalBuffers; i++) {
|
|
@@ -40236,7 +39496,9 @@ class GpuUniformBatchPipe {
|
|
|
40236
39496
|
this._resetBindGroups();
|
|
40237
39497
|
}
|
|
40238
39498
|
_resetBindGroups() {
|
|
40239
|
-
|
|
39499
|
+
for (const i in this._bindGroupHash) {
|
|
39500
|
+
this._bindGroupHash[i] = null;
|
|
39501
|
+
}
|
|
40240
39502
|
this._batchBuffer.clear();
|
|
40241
39503
|
}
|
|
40242
39504
|
// just works for single bind groups for now
|
|
@@ -40319,6 +39581,7 @@ class GpuUniformBatchPipe {
|
|
|
40319
39581
|
}
|
|
40320
39582
|
this._bufferResources = null;
|
|
40321
39583
|
this._batchBuffer.destroy();
|
|
39584
|
+
this._bindGroupHash = null;
|
|
40322
39585
|
this._renderer = null;
|
|
40323
39586
|
}
|
|
40324
39587
|
}
|
|
@@ -40340,8 +39603,8 @@ const topologyStringToId = {
|
|
|
40340
39603
|
function getGraphicsStateKey(geometryLayout, shaderKey, state, blendMode, topology) {
|
|
40341
39604
|
return geometryLayout << 24 | shaderKey << 16 | state << 10 | blendMode << 5 | topology;
|
|
40342
39605
|
}
|
|
40343
|
-
function getGlobalStateKey(stencilStateId, multiSampleCount, colorMask, renderTarget
|
|
40344
|
-
return colorMask <<
|
|
39606
|
+
function getGlobalStateKey(stencilStateId, multiSampleCount, colorMask, renderTarget) {
|
|
39607
|
+
return colorMask << 6 | stencilStateId << 3 | renderTarget << 1 | multiSampleCount;
|
|
40345
39608
|
}
|
|
40346
39609
|
class PipelineSystem {
|
|
40347
39610
|
constructor(renderer) {
|
|
@@ -40352,7 +39615,6 @@ class PipelineSystem {
|
|
|
40352
39615
|
this._pipeStateCaches = /* @__PURE__ */ Object.create(null);
|
|
40353
39616
|
this._colorMask = 15;
|
|
40354
39617
|
this._multisampleCount = 1;
|
|
40355
|
-
this._colorTargetCount = 1;
|
|
40356
39618
|
this._renderer = renderer;
|
|
40357
39619
|
}
|
|
40358
39620
|
contextChange(gpu) {
|
|
@@ -40369,7 +39631,6 @@ class PipelineSystem {
|
|
|
40369
39631
|
setRenderTarget(renderTarget) {
|
|
40370
39632
|
this._multisampleCount = renderTarget.msaaSamples;
|
|
40371
39633
|
this._depthStencilAttachment = renderTarget.descriptor.depthStencilAttachment ? 1 : 0;
|
|
40372
|
-
this._colorTargetCount = renderTarget.colorTargetCount;
|
|
40373
39634
|
this._updatePipeHash();
|
|
40374
39635
|
}
|
|
40375
39636
|
setColorMask(colorMask) {
|
|
@@ -40410,11 +39671,8 @@ class PipelineSystem {
|
|
|
40410
39671
|
_createPipeline(geometry, program, state, topology) {
|
|
40411
39672
|
const device = this._gpu.device;
|
|
40412
39673
|
const buffers = this._createVertexBufferLayouts(geometry, program);
|
|
40413
|
-
const blendModes = this._renderer.state.getColorTargets(state
|
|
40414
|
-
|
|
40415
|
-
for (let i = 0; i < blendModes.length; i++) {
|
|
40416
|
-
blendModes[i].writeMask = writeMask;
|
|
40417
|
-
}
|
|
39674
|
+
const blendModes = this._renderer.state.getColorTargets(state);
|
|
39675
|
+
blendModes[0].writeMask = this._stencilMode === STENCIL_MODES.RENDERING_MASK_ADD ? 0 : this._colorMask;
|
|
40418
39676
|
const layout = this._renderer.shader.getProgramData(program).pipeline;
|
|
40419
39677
|
const descriptor = {
|
|
40420
39678
|
// TODO later check if its helpful to create..
|
|
@@ -40558,8 +39816,7 @@ class PipelineSystem {
|
|
|
40558
39816
|
this._stencilMode,
|
|
40559
39817
|
this._multisampleCount,
|
|
40560
39818
|
this._colorMask,
|
|
40561
|
-
this._depthStencilAttachment
|
|
40562
|
-
this._colorTargetCount
|
|
39819
|
+
this._depthStencilAttachment
|
|
40563
39820
|
);
|
|
40564
39821
|
if (!this._pipeStateCaches[key]) {
|
|
40565
39822
|
this._pipeStateCaches[key] = /* @__PURE__ */ Object.create(null);
|
|
@@ -40719,7 +39976,6 @@ class GpuRenderTargetAdaptor {
|
|
|
40719
39976
|
initGpuRenderTarget(renderTarget) {
|
|
40720
39977
|
renderTarget.isRoot = true;
|
|
40721
39978
|
const gpuRenderTarget = new GpuRenderTarget();
|
|
40722
|
-
gpuRenderTarget.colorTargetCount = renderTarget.colorTextures.length;
|
|
40723
39979
|
renderTarget.colorTextures.forEach((colorTexture, i) => {
|
|
40724
39980
|
if (colorTexture instanceof CanvasSource) {
|
|
40725
39981
|
const context = colorTexture.resource.getContext(
|
|
@@ -40992,20 +40248,16 @@ class GpuStateSystem {
|
|
|
40992
40248
|
/**
|
|
40993
40249
|
* Gets the blend mode data for the current state
|
|
40994
40250
|
* @param state - The state to get the blend mode from
|
|
40995
|
-
* @param count - The number of color targets to create
|
|
40996
40251
|
*/
|
|
40997
|
-
getColorTargets(state
|
|
40252
|
+
getColorTargets(state) {
|
|
40998
40253
|
const blend = GpuBlendModesToPixi[state.blendMode] || GpuBlendModesToPixi.normal;
|
|
40999
|
-
|
|
41000
|
-
|
|
41001
|
-
|
|
41002
|
-
|
|
41003
|
-
|
|
41004
|
-
|
|
41005
|
-
|
|
41006
|
-
targets[i] = target;
|
|
41007
|
-
}
|
|
41008
|
-
return targets;
|
|
40254
|
+
return [
|
|
40255
|
+
{
|
|
40256
|
+
format: "bgra8unorm",
|
|
40257
|
+
writeMask: 0,
|
|
40258
|
+
blend
|
|
40259
|
+
}
|
|
40260
|
+
];
|
|
41009
40261
|
}
|
|
41010
40262
|
destroy() {
|
|
41011
40263
|
this.gpu = null;
|
|
@@ -41031,7 +40283,7 @@ const gpuUploadBufferImageResource = {
|
|
|
41031
40283
|
{
|
|
41032
40284
|
offset: 0,
|
|
41033
40285
|
rowsPerImage: source.pixelHeight,
|
|
41034
|
-
bytesPerRow: source.
|
|
40286
|
+
bytesPerRow: source.pixelHeight * bytesPerPixel
|
|
41035
40287
|
},
|
|
41036
40288
|
{
|
|
41037
40289
|
width: source.pixelWidth,
|
|
@@ -41270,22 +40522,13 @@ class GpuMipmapGenerator {
|
|
|
41270
40522
|
}
|
|
41271
40523
|
}
|
|
41272
40524
|
|
|
41273
|
-
class GPUTextureGpuData {
|
|
41274
|
-
constructor(gpuTexture) {
|
|
41275
|
-
this.textureView = null;
|
|
41276
|
-
this.gpuTexture = gpuTexture;
|
|
41277
|
-
}
|
|
41278
|
-
/** Destroys this GPU data instance. */
|
|
41279
|
-
destroy() {
|
|
41280
|
-
this.gpuTexture.destroy();
|
|
41281
|
-
this.textureView = null;
|
|
41282
|
-
this.gpuTexture = null;
|
|
41283
|
-
}
|
|
41284
|
-
}
|
|
41285
40525
|
class GpuTextureSystem {
|
|
41286
40526
|
constructor(renderer) {
|
|
40527
|
+
this.managedTextures = [];
|
|
40528
|
+
this._gpuSources = /* @__PURE__ */ Object.create(null);
|
|
41287
40529
|
this._gpuSamplers = /* @__PURE__ */ Object.create(null);
|
|
41288
40530
|
this._bindGroupHash = /* @__PURE__ */ Object.create(null);
|
|
40531
|
+
this._textureViewHash = /* @__PURE__ */ Object.create(null);
|
|
41289
40532
|
this._uploads = {
|
|
41290
40533
|
image: gpuUploadImageResource,
|
|
41291
40534
|
buffer: gpuUploadBufferImageResource,
|
|
@@ -41293,19 +40536,10 @@ class GpuTextureSystem {
|
|
|
41293
40536
|
compressed: gpuUploadCompressedTextureResource
|
|
41294
40537
|
};
|
|
41295
40538
|
this._renderer = renderer;
|
|
40539
|
+
renderer.renderableGC.addManagedHash(this, "_gpuSources");
|
|
40540
|
+
renderer.renderableGC.addManagedHash(this, "_gpuSamplers");
|
|
41296
40541
|
renderer.renderableGC.addManagedHash(this, "_bindGroupHash");
|
|
41297
|
-
this
|
|
41298
|
-
renderer,
|
|
41299
|
-
type: "resource",
|
|
41300
|
-
onUnload: this.onSourceUnload.bind(this),
|
|
41301
|
-
name: "gpuTextureSource"
|
|
41302
|
-
});
|
|
41303
|
-
}
|
|
41304
|
-
/**
|
|
41305
|
-
* @deprecated since 8.15.0
|
|
41306
|
-
*/
|
|
41307
|
-
get managedTextures() {
|
|
41308
|
-
return Object.values(this._managedTextures.items);
|
|
40542
|
+
renderer.renderableGC.addManagedHash(this, "_textureViewHash");
|
|
41309
40543
|
}
|
|
41310
40544
|
contextChange(gpu) {
|
|
41311
40545
|
this._gpu = gpu;
|
|
@@ -41316,7 +40550,10 @@ class GpuTextureSystem {
|
|
|
41316
40550
|
* @returns The initialized texture source.
|
|
41317
40551
|
*/
|
|
41318
40552
|
initSource(source) {
|
|
41319
|
-
|
|
40553
|
+
if (this._gpuSources[source.uid]) {
|
|
40554
|
+
return this._gpuSources[source.uid];
|
|
40555
|
+
}
|
|
40556
|
+
return this._initSource(source);
|
|
41320
40557
|
}
|
|
41321
40558
|
_initSource(source) {
|
|
41322
40559
|
if (source.autoGenerateMipmaps) {
|
|
@@ -41340,13 +40577,14 @@ class GpuTextureSystem {
|
|
|
41340
40577
|
dimension: source.dimension,
|
|
41341
40578
|
usage
|
|
41342
40579
|
};
|
|
41343
|
-
const gpuTexture = this._gpu.device.createTexture(textureDescriptor);
|
|
41344
|
-
|
|
41345
|
-
const added = this._managedTextures.add(source);
|
|
41346
|
-
if (added) {
|
|
40580
|
+
const gpuTexture = this._gpuSources[source.uid] = this._gpu.device.createTexture(textureDescriptor);
|
|
40581
|
+
if (!this.managedTextures.includes(source)) {
|
|
41347
40582
|
source.on("update", this.onSourceUpdate, this);
|
|
41348
40583
|
source.on("resize", this.onSourceResize, this);
|
|
40584
|
+
source.on("destroy", this.onSourceDestroy, this);
|
|
40585
|
+
source.on("unload", this.onSourceUnload, this);
|
|
41349
40586
|
source.on("updateMipmaps", this.onUpdateMipmaps, this);
|
|
40587
|
+
this.managedTextures.push(source);
|
|
41350
40588
|
}
|
|
41351
40589
|
this.onSourceUpdate(source);
|
|
41352
40590
|
return gpuTexture;
|
|
@@ -41362,6 +40600,13 @@ class GpuTextureSystem {
|
|
|
41362
40600
|
this.onUpdateMipmaps(source);
|
|
41363
40601
|
}
|
|
41364
40602
|
}
|
|
40603
|
+
onSourceUnload(source) {
|
|
40604
|
+
const gpuTexture = this._gpuSources[source.uid];
|
|
40605
|
+
if (gpuTexture) {
|
|
40606
|
+
this._gpuSources[source.uid] = null;
|
|
40607
|
+
gpuTexture.destroy();
|
|
40608
|
+
}
|
|
40609
|
+
}
|
|
41365
40610
|
onUpdateMipmaps(source) {
|
|
41366
40611
|
if (!this._mipmapGenerator) {
|
|
41367
40612
|
this._mipmapGenerator = new GpuMipmapGenerator(this._gpu.device);
|
|
@@ -41369,21 +40614,23 @@ class GpuTextureSystem {
|
|
|
41369
40614
|
const gpuTexture = this.getGpuSource(source);
|
|
41370
40615
|
this._mipmapGenerator.generateMipmap(gpuTexture);
|
|
41371
40616
|
}
|
|
41372
|
-
|
|
40617
|
+
onSourceDestroy(source) {
|
|
41373
40618
|
source.off("update", this.onSourceUpdate, this);
|
|
40619
|
+
source.off("unload", this.onSourceUnload, this);
|
|
40620
|
+
source.off("destroy", this.onSourceDestroy, this);
|
|
41374
40621
|
source.off("resize", this.onSourceResize, this);
|
|
41375
40622
|
source.off("updateMipmaps", this.onUpdateMipmaps, this);
|
|
40623
|
+
this.managedTextures.splice(this.managedTextures.indexOf(source), 1);
|
|
40624
|
+
this.onSourceUnload(source);
|
|
41376
40625
|
}
|
|
41377
40626
|
onSourceResize(source) {
|
|
41378
|
-
|
|
41379
|
-
const gpuData = source._gpuData[this._renderer.uid];
|
|
41380
|
-
const gpuTexture = gpuData?.gpuTexture;
|
|
40627
|
+
const gpuTexture = this._gpuSources[source.uid];
|
|
41381
40628
|
if (!gpuTexture) {
|
|
41382
40629
|
this.initSource(source);
|
|
41383
40630
|
} else if (gpuTexture.width !== source.pixelWidth || gpuTexture.height !== source.pixelHeight) {
|
|
41384
|
-
|
|
40631
|
+
this._textureViewHash[source.uid] = null;
|
|
41385
40632
|
this._bindGroupHash[source.uid] = null;
|
|
41386
|
-
|
|
40633
|
+
this.onSourceUnload(source);
|
|
41387
40634
|
this.initSource(source);
|
|
41388
40635
|
}
|
|
41389
40636
|
}
|
|
@@ -41395,8 +40642,7 @@ class GpuTextureSystem {
|
|
|
41395
40642
|
return this._gpuSamplers[sampler._resourceId] || this._initSampler(sampler);
|
|
41396
40643
|
}
|
|
41397
40644
|
getGpuSource(source) {
|
|
41398
|
-
source.
|
|
41399
|
-
return source._gpuData[this._renderer.uid]?.gpuTexture || this.initSource(source);
|
|
40645
|
+
return this._gpuSources[source.uid] || this.initSource(source);
|
|
41400
40646
|
}
|
|
41401
40647
|
/**
|
|
41402
40648
|
* this returns s bind group for a specific texture, the bind group contains
|
|
@@ -41408,7 +40654,7 @@ class GpuTextureSystem {
|
|
|
41408
40654
|
* @returns the bind group for the texture
|
|
41409
40655
|
*/
|
|
41410
40656
|
getTextureBindGroup(texture) {
|
|
41411
|
-
return this._bindGroupHash[texture.uid]
|
|
40657
|
+
return this._bindGroupHash[texture.uid] ?? this._createTextureBindGroup(texture);
|
|
41412
40658
|
}
|
|
41413
40659
|
_createTextureBindGroup(texture) {
|
|
41414
40660
|
const source = texture.source;
|
|
@@ -41423,15 +40669,11 @@ class GpuTextureSystem {
|
|
|
41423
40669
|
}
|
|
41424
40670
|
getTextureView(texture) {
|
|
41425
40671
|
const source = texture.source;
|
|
41426
|
-
source.
|
|
41427
|
-
|
|
41428
|
-
|
|
41429
|
-
|
|
41430
|
-
|
|
41431
|
-
gpuData = source._gpuData[this._renderer.uid];
|
|
41432
|
-
}
|
|
41433
|
-
textureView = gpuData.textureView || gpuData.gpuTexture.createView();
|
|
41434
|
-
return textureView;
|
|
40672
|
+
return this._textureViewHash[source.uid] ?? this._createTextureView(source);
|
|
40673
|
+
}
|
|
40674
|
+
_createTextureView(texture) {
|
|
40675
|
+
this._textureViewHash[texture.uid] = this.getGpuSource(texture).createView();
|
|
40676
|
+
return this._textureViewHash[texture.uid];
|
|
41435
40677
|
}
|
|
41436
40678
|
generateCanvas(texture) {
|
|
41437
40679
|
const renderer = this._renderer;
|
|
@@ -41473,17 +40715,20 @@ class GpuTextureSystem {
|
|
|
41473
40715
|
return { pixels, width, height };
|
|
41474
40716
|
}
|
|
41475
40717
|
destroy() {
|
|
41476
|
-
this.
|
|
40718
|
+
this.managedTextures.slice().forEach((source) => this.onSourceDestroy(source));
|
|
40719
|
+
this.managedTextures = null;
|
|
41477
40720
|
for (const k of Object.keys(this._bindGroupHash)) {
|
|
41478
40721
|
const key = Number(k);
|
|
41479
40722
|
const bindGroup = this._bindGroupHash[key];
|
|
41480
40723
|
bindGroup?.destroy();
|
|
40724
|
+
this._bindGroupHash[key] = null;
|
|
41481
40725
|
}
|
|
41482
|
-
this._renderer = null;
|
|
41483
40726
|
this._gpu = null;
|
|
41484
40727
|
this._mipmapGenerator = null;
|
|
41485
|
-
this.
|
|
40728
|
+
this._gpuSources = null;
|
|
41486
40729
|
this._bindGroupHash = null;
|
|
40730
|
+
this._textureViewHash = null;
|
|
40731
|
+
this._gpuSamplers = null;
|
|
41487
40732
|
}
|
|
41488
40733
|
}
|
|
41489
40734
|
/** @ignore */
|
|
@@ -41700,7 +40945,6 @@ class GraphicsPipe {
|
|
|
41700
40945
|
this.renderer = renderer;
|
|
41701
40946
|
this._adaptor = adaptor;
|
|
41702
40947
|
this.renderer.runners.contextChange.add(this);
|
|
41703
|
-
this._managedGraphics = new GCManagedHash({ renderer, type: "renderable", priority: -1, name: "graphics" });
|
|
41704
40948
|
}
|
|
41705
40949
|
contextChange() {
|
|
41706
40950
|
this._adaptor.contextChange(this.renderer);
|
|
@@ -41777,7 +41021,6 @@ class GraphicsPipe {
|
|
|
41777
41021
|
_initGpuDataForRenderable(graphics) {
|
|
41778
41022
|
const gpuData = new GraphicsGpuData();
|
|
41779
41023
|
graphics._gpuData[this.renderer.uid] = gpuData;
|
|
41780
|
-
this._managedGraphics.add(graphics);
|
|
41781
41024
|
return gpuData;
|
|
41782
41025
|
}
|
|
41783
41026
|
_updateBatchesForRenderable(graphics, gpuData) {
|
|
@@ -41793,7 +41036,6 @@ class GraphicsPipe {
|
|
|
41793
41036
|
});
|
|
41794
41037
|
}
|
|
41795
41038
|
destroy() {
|
|
41796
|
-
this._managedGraphics.destroy();
|
|
41797
41039
|
this.renderer = null;
|
|
41798
41040
|
this._adaptor.destroy();
|
|
41799
41041
|
this._adaptor = null;
|
|
@@ -42366,7 +41608,6 @@ class ParticleContainerPipe {
|
|
|
42366
41608
|
this.adaptor = adaptor;
|
|
42367
41609
|
this.defaultShader = new ParticleShader();
|
|
42368
41610
|
this.state = State.for2d();
|
|
42369
|
-
this._managedContainers = new GCManagedHash({ renderer, type: "renderable", name: "particleContainer" });
|
|
42370
41611
|
}
|
|
42371
41612
|
validateRenderable(_renderable) {
|
|
42372
41613
|
return false;
|
|
@@ -42383,7 +41624,6 @@ class ParticleContainerPipe {
|
|
|
42383
41624
|
size: renderable.particleChildren.length,
|
|
42384
41625
|
properties: renderable._properties
|
|
42385
41626
|
});
|
|
42386
|
-
this._managedContainers.add(renderable);
|
|
42387
41627
|
return renderable._gpuData[this.renderer.uid];
|
|
42388
41628
|
}
|
|
42389
41629
|
updateRenderable(_renderable) {
|
|
@@ -42415,7 +41655,6 @@ class ParticleContainerPipe {
|
|
|
42415
41655
|
}
|
|
42416
41656
|
/** Destroys the ParticleRenderer. */
|
|
42417
41657
|
destroy() {
|
|
42418
|
-
this._managedContainers.destroy();
|
|
42419
41658
|
this.renderer = null;
|
|
42420
41659
|
if (this.defaultShader) {
|
|
42421
41660
|
this.defaultShader.destroy();
|
|
@@ -42558,7 +41797,6 @@ class NineSliceSpriteGpuData extends BatchableMesh {
|
|
|
42558
41797
|
class NineSliceSpritePipe {
|
|
42559
41798
|
constructor(renderer) {
|
|
42560
41799
|
this._renderer = renderer;
|
|
42561
|
-
this._managedSprites = new GCManagedHash({ renderer, type: "renderable", name: "nineSliceSprite" });
|
|
42562
41800
|
}
|
|
42563
41801
|
addRenderable(sprite, instructionSet) {
|
|
42564
41802
|
const gpuSprite = this._getGpuSprite(sprite);
|
|
@@ -42593,14 +41831,12 @@ class NineSliceSpritePipe {
|
|
|
42593
41831
|
batchableMesh.transform = sprite.groupTransform;
|
|
42594
41832
|
batchableMesh.texture = sprite._texture;
|
|
42595
41833
|
batchableMesh.roundPixels = this._renderer._roundPixels | sprite._roundPixels;
|
|
42596
|
-
this._managedSprites.add(sprite);
|
|
42597
41834
|
if (!sprite.didViewUpdate) {
|
|
42598
41835
|
this._updateBatchableSprite(sprite, batchableMesh);
|
|
42599
41836
|
}
|
|
42600
41837
|
return gpuData;
|
|
42601
41838
|
}
|
|
42602
41839
|
destroy() {
|
|
42603
|
-
this._managedSprites.destroy();
|
|
42604
41840
|
this._renderer = null;
|
|
42605
41841
|
}
|
|
42606
41842
|
}
|
|
@@ -42883,7 +42119,6 @@ class TilingSpritePipe {
|
|
|
42883
42119
|
constructor(renderer) {
|
|
42884
42120
|
this._state = State.default2d;
|
|
42885
42121
|
this._renderer = renderer;
|
|
42886
|
-
this._managedTilingSprites = new GCManagedHash({ renderer, type: "renderable", name: "tilingSprite" });
|
|
42887
42122
|
}
|
|
42888
42123
|
validateRenderable(renderable) {
|
|
42889
42124
|
const tilingSpriteData = this._getTilingSpriteData(renderable);
|
|
@@ -42968,7 +42203,6 @@ class TilingSpritePipe {
|
|
|
42968
42203
|
const gpuData = new TilingSpriteGpuData();
|
|
42969
42204
|
gpuData.renderable = tilingSprite;
|
|
42970
42205
|
tilingSprite._gpuData[this._renderer.uid] = gpuData;
|
|
42971
|
-
this._managedTilingSprites.add(tilingSprite);
|
|
42972
42206
|
return gpuData;
|
|
42973
42207
|
}
|
|
42974
42208
|
_updateBatchableMesh(tilingSprite) {
|
|
@@ -42983,7 +42217,6 @@ class TilingSpritePipe {
|
|
|
42983
42217
|
setPositions(tilingSprite, geometry.positions);
|
|
42984
42218
|
}
|
|
42985
42219
|
destroy() {
|
|
42986
|
-
this._managedTilingSprites.destroy();
|
|
42987
42220
|
this._renderer = null;
|
|
42988
42221
|
}
|
|
42989
42222
|
_updateCanBatch(tilingSprite) {
|
|
@@ -43230,7 +42463,6 @@ class BitmapTextGraphics extends Graphics {
|
|
|
43230
42463
|
class BitmapTextPipe {
|
|
43231
42464
|
constructor(renderer) {
|
|
43232
42465
|
this._renderer = renderer;
|
|
43233
|
-
this._managedBitmapTexts = new GCManagedHash({ renderer, type: "renderable", priority: -2, name: "bitmapText" });
|
|
43234
42466
|
}
|
|
43235
42467
|
validateRenderable(bitmapText) {
|
|
43236
42468
|
const graphicsRenderable = this._getGpuBitmapText(bitmapText);
|
|
@@ -43316,7 +42548,6 @@ class BitmapTextPipe {
|
|
|
43316
42548
|
const proxyRenderable = new BitmapTextGraphics();
|
|
43317
42549
|
bitmapText._gpuData[this._renderer.uid] = proxyRenderable;
|
|
43318
42550
|
this._updateContext(bitmapText, proxyRenderable);
|
|
43319
|
-
this._managedBitmapTexts.add(bitmapText);
|
|
43320
42551
|
return proxyRenderable;
|
|
43321
42552
|
}
|
|
43322
42553
|
_updateDistanceField(bitmapText) {
|
|
@@ -43332,9 +42563,7 @@ class BitmapTextPipe {
|
|
|
43332
42563
|
context.customShader.resources.localUniforms.uniforms.uDistance = distance;
|
|
43333
42564
|
}
|
|
43334
42565
|
destroy() {
|
|
43335
|
-
this._managedBitmapTexts.destroy();
|
|
43336
42566
|
this._renderer = null;
|
|
43337
|
-
this._managedBitmapTexts = null;
|
|
43338
42567
|
}
|
|
43339
42568
|
}
|
|
43340
42569
|
/** @ignore */
|
|
@@ -43359,17 +42588,31 @@ function syncWithProxy(container, proxy) {
|
|
|
43359
42588
|
}
|
|
43360
42589
|
|
|
43361
42590
|
class BatchableHTMLText extends BatchableSprite {
|
|
43362
|
-
|
|
43363
|
-
|
|
42591
|
+
/**
|
|
42592
|
+
* Creates an instance of BatchableHTMLText.
|
|
42593
|
+
* @param renderer - The renderer instance to be used.
|
|
42594
|
+
*/
|
|
42595
|
+
constructor(renderer) {
|
|
42596
|
+
super();
|
|
43364
42597
|
this.generatingTexture = false;
|
|
43365
42598
|
this.currentKey = "--";
|
|
42599
|
+
this._renderer = renderer;
|
|
42600
|
+
renderer.runners.resolutionChange.add(this);
|
|
42601
|
+
}
|
|
42602
|
+
/** Handles resolution changes for the HTML text. If the text has auto resolution enabled, it triggers a view update. */
|
|
42603
|
+
resolutionChange() {
|
|
42604
|
+
const text = this.renderable;
|
|
42605
|
+
if (text._autoResolution) {
|
|
42606
|
+
text.onViewUpdate();
|
|
42607
|
+
}
|
|
43366
42608
|
}
|
|
43367
42609
|
/** Destroys the BatchableHTMLText instance. Returns the texture promise to the renderer and cleans up references. */
|
|
43368
42610
|
destroy() {
|
|
42611
|
+
const { htmlText } = this._renderer;
|
|
42612
|
+
htmlText.getReferenceCount(this.currentKey) === null ? htmlText.returnTexturePromise(this.texturePromise) : htmlText.decreaseReferenceCount(this.currentKey);
|
|
42613
|
+
this._renderer.runners.resolutionChange.remove(this);
|
|
43369
42614
|
this.texturePromise = null;
|
|
43370
|
-
this.
|
|
43371
|
-
this.currentKey = "--";
|
|
43372
|
-
super.destroy();
|
|
42615
|
+
this._renderer = null;
|
|
43373
42616
|
}
|
|
43374
42617
|
}
|
|
43375
42618
|
|
|
@@ -43388,21 +42631,6 @@ function updateTextBounds(batchableSprite, text) {
|
|
|
43388
42631
|
class HTMLTextPipe {
|
|
43389
42632
|
constructor(renderer) {
|
|
43390
42633
|
this._renderer = renderer;
|
|
43391
|
-
renderer.runners.resolutionChange.add(this);
|
|
43392
|
-
this._managedTexts = new GCManagedHash({
|
|
43393
|
-
renderer,
|
|
43394
|
-
type: "renderable",
|
|
43395
|
-
onUnload: this.onTextUnload.bind(this),
|
|
43396
|
-
name: "htmlText"
|
|
43397
|
-
});
|
|
43398
|
-
}
|
|
43399
|
-
resolutionChange() {
|
|
43400
|
-
for (const key in this._managedTexts.items) {
|
|
43401
|
-
const text = this._managedTexts.items[key];
|
|
43402
|
-
if (text?._autoResolution) {
|
|
43403
|
-
text.onViewUpdate();
|
|
43404
|
-
}
|
|
43405
|
-
}
|
|
43406
42634
|
}
|
|
43407
42635
|
validateRenderable(htmlText) {
|
|
43408
42636
|
const gpuText = this._getGpuText(htmlText);
|
|
@@ -43460,7 +42688,7 @@ class HTMLTextPipe {
|
|
|
43460
42688
|
return htmlText._gpuData[this._renderer.uid] || this.initGpuText(htmlText);
|
|
43461
42689
|
}
|
|
43462
42690
|
initGpuText(htmlText) {
|
|
43463
|
-
const batchableHTMLText = new BatchableHTMLText();
|
|
42691
|
+
const batchableHTMLText = new BatchableHTMLText(this._renderer);
|
|
43464
42692
|
batchableHTMLText.renderable = htmlText;
|
|
43465
42693
|
batchableHTMLText.transform = htmlText.groupTransform;
|
|
43466
42694
|
batchableHTMLText.texture = Texture.EMPTY;
|
|
@@ -43468,18 +42696,9 @@ class HTMLTextPipe {
|
|
|
43468
42696
|
batchableHTMLText.roundPixels = this._renderer._roundPixels | htmlText._roundPixels;
|
|
43469
42697
|
htmlText._resolution = htmlText._autoResolution ? this._renderer.resolution : htmlText.resolution;
|
|
43470
42698
|
htmlText._gpuData[this._renderer.uid] = batchableHTMLText;
|
|
43471
|
-
this._managedTexts.add(htmlText);
|
|
43472
42699
|
return batchableHTMLText;
|
|
43473
42700
|
}
|
|
43474
|
-
onTextUnload(text) {
|
|
43475
|
-
const gpuData = text._gpuData[this._renderer.uid];
|
|
43476
|
-
if (!gpuData)
|
|
43477
|
-
return;
|
|
43478
|
-
const { htmlText } = this._renderer;
|
|
43479
|
-
htmlText.getReferenceCount(gpuData.currentKey) === null ? htmlText.returnTexturePromise(gpuData.texturePromise) : htmlText.decreaseReferenceCount(gpuData.currentKey);
|
|
43480
|
-
}
|
|
43481
42701
|
destroy() {
|
|
43482
|
-
this._managedTexts.destroy();
|
|
43483
42702
|
this._renderer = null;
|
|
43484
42703
|
}
|
|
43485
42704
|
}
|
|
@@ -43787,25 +43006,33 @@ HTMLTextSystem.extension = {
|
|
|
43787
43006
|
};
|
|
43788
43007
|
|
|
43789
43008
|
class BatchableText extends BatchableSprite {
|
|
43790
|
-
}
|
|
43791
|
-
|
|
43792
|
-
class CanvasTextPipe {
|
|
43793
43009
|
constructor(renderer) {
|
|
43010
|
+
super();
|
|
43794
43011
|
this._renderer = renderer;
|
|
43795
43012
|
renderer.runners.resolutionChange.add(this);
|
|
43796
|
-
this._managedTexts = new GCManagedHash({
|
|
43797
|
-
renderer,
|
|
43798
|
-
type: "renderable",
|
|
43799
|
-
onUnload: this.onTextUnload.bind(this),
|
|
43800
|
-
name: "canvasText"
|
|
43801
|
-
});
|
|
43802
43013
|
}
|
|
43803
43014
|
resolutionChange() {
|
|
43804
|
-
|
|
43805
|
-
|
|
43806
|
-
|
|
43807
|
-
|
|
43015
|
+
const text = this.renderable;
|
|
43016
|
+
if (text._autoResolution) {
|
|
43017
|
+
text.onViewUpdate();
|
|
43018
|
+
}
|
|
43019
|
+
}
|
|
43020
|
+
destroy() {
|
|
43021
|
+
const { canvasText } = this._renderer;
|
|
43022
|
+
const refCount = canvasText.getReferenceCount(this.currentKey);
|
|
43023
|
+
if (refCount > 0) {
|
|
43024
|
+
canvasText.decreaseReferenceCount(this.currentKey);
|
|
43025
|
+
} else if (this.texture) {
|
|
43026
|
+
canvasText.returnTexture(this.texture);
|
|
43808
43027
|
}
|
|
43028
|
+
this._renderer.runners.resolutionChange.remove(this);
|
|
43029
|
+
this._renderer = null;
|
|
43030
|
+
}
|
|
43031
|
+
}
|
|
43032
|
+
|
|
43033
|
+
class CanvasTextPipe {
|
|
43034
|
+
constructor(renderer) {
|
|
43035
|
+
this._renderer = renderer;
|
|
43809
43036
|
}
|
|
43810
43037
|
validateRenderable(text) {
|
|
43811
43038
|
const gpuText = this._getGpuText(text);
|
|
@@ -43822,7 +43049,6 @@ class CanvasTextPipe {
|
|
|
43822
43049
|
this._updateGpuText(text);
|
|
43823
43050
|
}
|
|
43824
43051
|
text._didTextUpdate = false;
|
|
43825
|
-
updateTextBounds(batchableText, text);
|
|
43826
43052
|
}
|
|
43827
43053
|
this._renderer.renderPipes.batch.addToBatch(batchableText, instructionSet);
|
|
43828
43054
|
}
|
|
@@ -43838,35 +43064,22 @@ class CanvasTextPipe {
|
|
|
43838
43064
|
text._resolution = text._autoResolution ? this._renderer.resolution : text.resolution;
|
|
43839
43065
|
batchableText.texture = this._renderer.canvasText.getManagedTexture(text);
|
|
43840
43066
|
batchableText.currentKey = text.styleKey;
|
|
43067
|
+
updateTextBounds(batchableText, text);
|
|
43841
43068
|
}
|
|
43842
43069
|
_getGpuText(text) {
|
|
43843
43070
|
return text._gpuData[this._renderer.uid] || this.initGpuText(text);
|
|
43844
43071
|
}
|
|
43845
43072
|
initGpuText(text) {
|
|
43846
|
-
const batchableText = new BatchableText();
|
|
43073
|
+
const batchableText = new BatchableText(this._renderer);
|
|
43847
43074
|
batchableText.currentKey = "--";
|
|
43848
43075
|
batchableText.renderable = text;
|
|
43849
43076
|
batchableText.transform = text.groupTransform;
|
|
43850
43077
|
batchableText.bounds = { minX: 0, maxX: 1, minY: 0, maxY: 0 };
|
|
43851
43078
|
batchableText.roundPixels = this._renderer._roundPixels | text._roundPixels;
|
|
43852
43079
|
text._gpuData[this._renderer.uid] = batchableText;
|
|
43853
|
-
this._managedTexts.add(text);
|
|
43854
43080
|
return batchableText;
|
|
43855
43081
|
}
|
|
43856
|
-
onTextUnload(text) {
|
|
43857
|
-
const gpuData = text._gpuData[this._renderer.uid];
|
|
43858
|
-
if (!gpuData)
|
|
43859
|
-
return;
|
|
43860
|
-
const { canvasText } = this._renderer;
|
|
43861
|
-
const refCount = canvasText.getReferenceCount(gpuData.currentKey);
|
|
43862
|
-
if (refCount > 0) {
|
|
43863
|
-
canvasText.decreaseReferenceCount(gpuData.currentKey);
|
|
43864
|
-
} else if (gpuData.texture) {
|
|
43865
|
-
canvasText.returnTexture(gpuData.texture);
|
|
43866
|
-
}
|
|
43867
|
-
}
|
|
43868
43082
|
destroy() {
|
|
43869
|
-
this._managedTexts.destroy();
|
|
43870
43083
|
this._renderer = null;
|
|
43871
43084
|
}
|
|
43872
43085
|
}
|
|
@@ -45650,7 +44863,7 @@ const LightningCardHTML = ({
|
|
|
45650
44863
|
}, multiplier !== null && multiplier !== undefined && /*#__PURE__*/React.createElement("div", {
|
|
45651
44864
|
className: "multiplier--22733",
|
|
45652
44865
|
style: {
|
|
45653
|
-
fontSize: "
|
|
44866
|
+
fontSize: "15px"
|
|
45654
44867
|
}
|
|
45655
44868
|
}, /*#__PURE__*/React.createElement("div", {
|
|
45656
44869
|
className: "multiplier--fe086"
|
|
@@ -45746,7 +44959,7 @@ const LightningCardHTML = ({
|
|
|
45746
44959
|
}, multiplier !== null && multiplier !== undefined && /*#__PURE__*/React.createElement("div", {
|
|
45747
44960
|
className: "multiplier--22733",
|
|
45748
44961
|
style: {
|
|
45749
|
-
fontSize: "
|
|
44962
|
+
fontSize: "15px"
|
|
45750
44963
|
}
|
|
45751
44964
|
}, /*#__PURE__*/React.createElement("div", {
|
|
45752
44965
|
className: "multiplier--fe086"
|