@rings-webgpu/core 1.0.24 → 1.0.26
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/rings.es.js +14 -14
- package/dist/rings.es.js.map +3 -3
- package/dist/rings.es.max.js +188 -28
- package/dist/rings.umd.js +9 -9
- package/dist/rings.umd.js.map +3 -3
- package/dist/rings.umd.max.js +188 -28
- package/dist/types/assets/Res.d.ts +2 -0
- package/dist/types/core/geometry/GeometryBase.d.ts +1 -0
- package/dist/types/gfx/graphics/webGpu/core/texture/Texture.d.ts +2 -0
- package/dist/types/gfx/graphics/webGpu/shader/Shader.d.ts +1 -1
- package/dist/types/loader/parser/b3dm/FeatureTable.d.ts +1 -0
- package/dist/types/loader/parser/tileRenderer/TilesRenderer.d.ts +1 -1
- package/dist/types/materials/Material.d.ts +1 -0
- package/dist/types/textures/BitmapTexture2D.d.ts +1 -0
- package/package.json +1 -1
package/dist/rings.es.max.js
CHANGED
|
@@ -16785,6 +16785,10 @@ class Texture {
|
|
|
16785
16785
|
name;
|
|
16786
16786
|
url;
|
|
16787
16787
|
gpuTexture;
|
|
16788
|
+
_isDestroyed = false;
|
|
16789
|
+
get isDestroyed() {
|
|
16790
|
+
return this._isDestroyed;
|
|
16791
|
+
}
|
|
16788
16792
|
pid;
|
|
16789
16793
|
view;
|
|
16790
16794
|
// Assigned later
|
|
@@ -17013,6 +17017,14 @@ class Texture {
|
|
|
17013
17017
|
this.textureDescriptor = null;
|
|
17014
17018
|
this.gpuTexture.destroy();
|
|
17015
17019
|
this.gpuTexture = null;
|
|
17020
|
+
this._isDestroyed = true;
|
|
17021
|
+
}
|
|
17022
|
+
if (this._sourceImageData && this._sourceImageData instanceof ImageBitmap) {
|
|
17023
|
+
try {
|
|
17024
|
+
this._sourceImageData.close();
|
|
17025
|
+
} catch (e) {
|
|
17026
|
+
}
|
|
17027
|
+
this._sourceImageData = null;
|
|
17016
17028
|
}
|
|
17017
17029
|
this._stateChangeRef.clear();
|
|
17018
17030
|
}
|
|
@@ -20276,9 +20288,13 @@ class Reference {
|
|
|
20276
20288
|
* @param target reference parent
|
|
20277
20289
|
*/
|
|
20278
20290
|
detached(ref, target) {
|
|
20291
|
+
if (!this.reference) return;
|
|
20279
20292
|
let refMap = this.reference.get(ref);
|
|
20280
20293
|
if (refMap) {
|
|
20281
20294
|
refMap.delete(target);
|
|
20295
|
+
if (refMap.size === 0) {
|
|
20296
|
+
this.reference.delete(ref);
|
|
20297
|
+
}
|
|
20282
20298
|
}
|
|
20283
20299
|
}
|
|
20284
20300
|
/**
|
|
@@ -22507,23 +22523,36 @@ class RenderNode extends ComponentBase {
|
|
|
22507
22523
|
}
|
|
22508
22524
|
}
|
|
22509
22525
|
beforeDestroy(force) {
|
|
22510
|
-
|
|
22511
|
-
|
|
22512
|
-
this._geometry
|
|
22526
|
+
if (this._geometry) {
|
|
22527
|
+
Reference.getInstance().detached(this._geometry, this);
|
|
22528
|
+
if (!Reference.getInstance().hasReference(this._geometry)) {
|
|
22529
|
+
this._geometry.destroy(force);
|
|
22530
|
+
}
|
|
22513
22531
|
}
|
|
22514
22532
|
for (let i = 0; i < this._materials.length; i++) {
|
|
22515
22533
|
const mat = this._materials[i];
|
|
22516
|
-
|
|
22517
|
-
|
|
22518
|
-
|
|
22534
|
+
if (mat) {
|
|
22535
|
+
Reference.getInstance().detached(mat, this);
|
|
22536
|
+
if (!Reference.getInstance().hasReference(mat)) {
|
|
22537
|
+
mat.destroy(force);
|
|
22538
|
+
}
|
|
22519
22539
|
}
|
|
22520
22540
|
}
|
|
22541
|
+
if (this._computes) {
|
|
22542
|
+
this._computes.length = 0;
|
|
22543
|
+
}
|
|
22544
|
+
this.detachSceneOctree();
|
|
22521
22545
|
super.beforeDestroy(force);
|
|
22522
22546
|
}
|
|
22523
22547
|
destroy(force) {
|
|
22524
22548
|
super.destroy(force);
|
|
22525
22549
|
this._geometry = void 0;
|
|
22526
22550
|
this._materials.length = 0;
|
|
22551
|
+
this._computes = null;
|
|
22552
|
+
if (this._passInit) {
|
|
22553
|
+
this._passInit.clear();
|
|
22554
|
+
this._passInit = null;
|
|
22555
|
+
}
|
|
22527
22556
|
this._combineShaderRefection = void 0;
|
|
22528
22557
|
}
|
|
22529
22558
|
}
|
|
@@ -22543,6 +22572,7 @@ class Material {
|
|
|
22543
22572
|
enable = true;
|
|
22544
22573
|
_defaultSubShader;
|
|
22545
22574
|
_shader;
|
|
22575
|
+
_isDestroyed = false;
|
|
22546
22576
|
constructor() {
|
|
22547
22577
|
this.instanceID = UUID();
|
|
22548
22578
|
}
|
|
@@ -22657,10 +22687,17 @@ class Material {
|
|
|
22657
22687
|
return newMat;
|
|
22658
22688
|
}
|
|
22659
22689
|
destroy(force) {
|
|
22690
|
+
if (this._isDestroyed) {
|
|
22691
|
+
return;
|
|
22692
|
+
}
|
|
22660
22693
|
this.name = null;
|
|
22661
22694
|
this.instanceID = null;
|
|
22662
|
-
this._shader
|
|
22663
|
-
|
|
22695
|
+
if (this._shader) {
|
|
22696
|
+
this._shader.destroy(force);
|
|
22697
|
+
this._shader = null;
|
|
22698
|
+
}
|
|
22699
|
+
this._defaultSubShader = null;
|
|
22700
|
+
this._isDestroyed = true;
|
|
22664
22701
|
}
|
|
22665
22702
|
setDefine(define, value) {
|
|
22666
22703
|
this.shader.setDefine(define, value);
|
|
@@ -23165,8 +23202,15 @@ class Shader {
|
|
|
23165
23202
|
}
|
|
23166
23203
|
}
|
|
23167
23204
|
}
|
|
23168
|
-
destroy() {
|
|
23169
|
-
this.
|
|
23205
|
+
destroy(force) {
|
|
23206
|
+
for (const pass of this.passShader) {
|
|
23207
|
+
for (const rd of pass[1]) {
|
|
23208
|
+
rd.destroy(force);
|
|
23209
|
+
}
|
|
23210
|
+
}
|
|
23211
|
+
this.passShader.clear();
|
|
23212
|
+
this.passShader = null;
|
|
23213
|
+
this.computes = null;
|
|
23170
23214
|
}
|
|
23171
23215
|
clone() {
|
|
23172
23216
|
let newShader = new Shader();
|
|
@@ -23658,6 +23702,7 @@ class GeometryBase {
|
|
|
23658
23702
|
_vertexBuffer;
|
|
23659
23703
|
_onChange = true;
|
|
23660
23704
|
_wireframeLines;
|
|
23705
|
+
_isDestroyed = false;
|
|
23661
23706
|
constructor() {
|
|
23662
23707
|
this.instanceID = UUID();
|
|
23663
23708
|
this._attributeMap = /* @__PURE__ */ new Map();
|
|
@@ -23904,18 +23949,40 @@ class GeometryBase {
|
|
|
23904
23949
|
return false;
|
|
23905
23950
|
}
|
|
23906
23951
|
destroy(force) {
|
|
23952
|
+
if (this._isDestroyed) {
|
|
23953
|
+
return;
|
|
23954
|
+
}
|
|
23907
23955
|
this.instanceID = null;
|
|
23908
23956
|
this.name = null;
|
|
23909
23957
|
this.subGeometries = null;
|
|
23910
23958
|
this.morphTargetDictionary = null;
|
|
23911
|
-
this.
|
|
23912
|
-
this.
|
|
23913
|
-
this.
|
|
23959
|
+
this.skinNames = null;
|
|
23960
|
+
this.bindPose = null;
|
|
23961
|
+
this.blendShapeData = null;
|
|
23962
|
+
this._wireframeLines = null;
|
|
23963
|
+
if (this._bounds) {
|
|
23964
|
+
this._bounds.destroy();
|
|
23965
|
+
this._bounds = null;
|
|
23966
|
+
}
|
|
23967
|
+
if (this._attributeMap) {
|
|
23968
|
+
this._attributeMap.forEach((vertexInfo) => {
|
|
23969
|
+
if (vertexInfo && vertexInfo.data) {
|
|
23970
|
+
vertexInfo.data = null;
|
|
23971
|
+
}
|
|
23972
|
+
});
|
|
23973
|
+
this._attributeMap.clear();
|
|
23974
|
+
this._attributeMap = null;
|
|
23975
|
+
}
|
|
23914
23976
|
this._attributes = null;
|
|
23915
|
-
this._indicesBuffer
|
|
23916
|
-
|
|
23917
|
-
|
|
23918
|
-
|
|
23977
|
+
if (this._indicesBuffer) {
|
|
23978
|
+
this._indicesBuffer.destroy();
|
|
23979
|
+
this._indicesBuffer = null;
|
|
23980
|
+
}
|
|
23981
|
+
if (this._vertexBuffer) {
|
|
23982
|
+
this._vertexBuffer.destroy();
|
|
23983
|
+
this._vertexBuffer = null;
|
|
23984
|
+
}
|
|
23985
|
+
this._isDestroyed = true;
|
|
23919
23986
|
}
|
|
23920
23987
|
}
|
|
23921
23988
|
|
|
@@ -25316,10 +25383,22 @@ class Entity extends CEventDispatcher {
|
|
|
25316
25383
|
c.destroy(force);
|
|
25317
25384
|
});
|
|
25318
25385
|
this.components.clear();
|
|
25319
|
-
this.
|
|
25320
|
-
|
|
25321
|
-
|
|
25322
|
-
|
|
25386
|
+
this.components.clear();
|
|
25387
|
+
if (this.entityChildren) {
|
|
25388
|
+
this.entityChildren.forEach((c) => {
|
|
25389
|
+
c.destroy(force);
|
|
25390
|
+
});
|
|
25391
|
+
this.removeAllChild();
|
|
25392
|
+
this.entityChildren = [];
|
|
25393
|
+
}
|
|
25394
|
+
if (this._bound && this._bound.destroy) {
|
|
25395
|
+
this._bound.destroy();
|
|
25396
|
+
this._bound = null;
|
|
25397
|
+
}
|
|
25398
|
+
if (this._boundWorld && this._boundWorld.destroy) {
|
|
25399
|
+
this._boundWorld.destroy();
|
|
25400
|
+
this._boundWorld = null;
|
|
25401
|
+
}
|
|
25323
25402
|
this.transform.parent = null;
|
|
25324
25403
|
this._dispose = true;
|
|
25325
25404
|
super.destroy();
|
|
@@ -25591,6 +25670,16 @@ let Object3D = class extends Entity {
|
|
|
25591
25670
|
this.onTransformLocalChange,
|
|
25592
25671
|
this
|
|
25593
25672
|
);
|
|
25673
|
+
const batchTable = this.batchTable;
|
|
25674
|
+
if (batchTable && typeof batchTable.destroy === "function") {
|
|
25675
|
+
batchTable.destroy();
|
|
25676
|
+
this.batchTable = null;
|
|
25677
|
+
}
|
|
25678
|
+
const featureTable = this.featureTable;
|
|
25679
|
+
if (featureTable && typeof featureTable.destroy === "function") {
|
|
25680
|
+
featureTable.destroy();
|
|
25681
|
+
this.featureTable = null;
|
|
25682
|
+
}
|
|
25594
25683
|
super.destroy(force);
|
|
25595
25684
|
}
|
|
25596
25685
|
};
|
|
@@ -32698,9 +32787,32 @@ class StringUtil {
|
|
|
32698
32787
|
return url.substring(0, s_pos);
|
|
32699
32788
|
}
|
|
32700
32789
|
static normalizePath(url) {
|
|
32701
|
-
|
|
32702
|
-
|
|
32703
|
-
|
|
32790
|
+
if (!url) {
|
|
32791
|
+
return url;
|
|
32792
|
+
}
|
|
32793
|
+
let normalized = url.replace(/\\/g, "/");
|
|
32794
|
+
const preserveLeadingDoubleSlash = normalized.startsWith("//");
|
|
32795
|
+
const protectedTokens = [];
|
|
32796
|
+
let tokenIndex = 0;
|
|
32797
|
+
normalized = normalized.replace(
|
|
32798
|
+
/([a-zA-Z][a-zA-Z0-9+\-.]*):\/{2}/g,
|
|
32799
|
+
(match, scheme, offset) => {
|
|
32800
|
+
if (scheme.length === 1 && offset === 0) {
|
|
32801
|
+
return match;
|
|
32802
|
+
}
|
|
32803
|
+
const token = `__SCHEME_SLASH_${tokenIndex++}__`;
|
|
32804
|
+
protectedTokens.push(token);
|
|
32805
|
+
return `${scheme}:${token}`;
|
|
32806
|
+
}
|
|
32807
|
+
);
|
|
32808
|
+
normalized = normalized.replace(/\/{2,}/g, "/");
|
|
32809
|
+
protectedTokens.forEach((token) => {
|
|
32810
|
+
normalized = normalized.replace(token, "//");
|
|
32811
|
+
});
|
|
32812
|
+
if (preserveLeadingDoubleSlash) {
|
|
32813
|
+
normalized = `//${normalized.replace(/^\/+/, "")}`;
|
|
32814
|
+
}
|
|
32815
|
+
return normalized;
|
|
32704
32816
|
}
|
|
32705
32817
|
static getStringList(str, char = ";") {
|
|
32706
32818
|
return str.split(char);
|
|
@@ -32882,6 +32994,12 @@ class BitmapTexture2D extends Texture {
|
|
|
32882
32994
|
return this._source;
|
|
32883
32995
|
}
|
|
32884
32996
|
set source(value) {
|
|
32997
|
+
if (this._source && this._source instanceof ImageBitmap) {
|
|
32998
|
+
try {
|
|
32999
|
+
this._source.close();
|
|
33000
|
+
} catch (e) {
|
|
33001
|
+
}
|
|
33002
|
+
}
|
|
32885
33003
|
this._source = value;
|
|
32886
33004
|
if (this._source instanceof HTMLImageElement) {
|
|
32887
33005
|
this._source.decode().then(async () => {
|
|
@@ -32949,17 +33067,32 @@ class BitmapTexture2D extends Texture {
|
|
|
32949
33067
|
if (imageBitmap.width < 32 || imageBitmap.height < 32) {
|
|
32950
33068
|
let width = Math.max(imageBitmap.width, 32);
|
|
32951
33069
|
let height = Math.max(imageBitmap.height, 32);
|
|
33070
|
+
const oldImageBitmap = imageBitmap;
|
|
32952
33071
|
imageBitmap = await createImageBitmap(imageBitmap, {
|
|
32953
33072
|
resizeWidth: width,
|
|
32954
33073
|
resizeHeight: height,
|
|
32955
33074
|
imageOrientation: this.flipY ? "flipY" : "from-image",
|
|
32956
33075
|
premultiplyAlpha: "none"
|
|
32957
33076
|
});
|
|
33077
|
+
try {
|
|
33078
|
+
oldImageBitmap.close();
|
|
33079
|
+
} catch (e) {
|
|
33080
|
+
}
|
|
32958
33081
|
}
|
|
32959
33082
|
this.format = GPUTextureFormat.rgba8unorm;
|
|
32960
33083
|
this.generate(imageBitmap);
|
|
32961
33084
|
return true;
|
|
32962
33085
|
}
|
|
33086
|
+
destroy(force) {
|
|
33087
|
+
if (this._source && this._source instanceof ImageBitmap) {
|
|
33088
|
+
try {
|
|
33089
|
+
this._source.close();
|
|
33090
|
+
} catch (e) {
|
|
33091
|
+
}
|
|
33092
|
+
this._source = null;
|
|
33093
|
+
}
|
|
33094
|
+
super.destroy(force);
|
|
33095
|
+
}
|
|
32963
33096
|
}
|
|
32964
33097
|
|
|
32965
33098
|
class LoaderBase {
|
|
@@ -36207,6 +36340,7 @@ class GLBParser extends ParserBase {
|
|
|
36207
36340
|
this._gltf,
|
|
36208
36341
|
this._gltf.scene
|
|
36209
36342
|
);
|
|
36343
|
+
subParser.destroy();
|
|
36210
36344
|
if (nodes) {
|
|
36211
36345
|
this.data = nodes.rootNode;
|
|
36212
36346
|
return nodes.rootNode;
|
|
@@ -36244,6 +36378,7 @@ class GLBParser extends ParserBase {
|
|
|
36244
36378
|
this._gltf,
|
|
36245
36379
|
this._gltf.scene
|
|
36246
36380
|
);
|
|
36381
|
+
subParser.destroy();
|
|
36247
36382
|
if (nodes) {
|
|
36248
36383
|
this.data = nodes.rootNode;
|
|
36249
36384
|
return nodes.rootNode;
|
|
@@ -39044,6 +39179,12 @@ class FeatureTable {
|
|
|
39044
39179
|
return data;
|
|
39045
39180
|
}
|
|
39046
39181
|
}
|
|
39182
|
+
destroy() {
|
|
39183
|
+
this.buffer = null;
|
|
39184
|
+
this.header = null;
|
|
39185
|
+
this.binOffset = null;
|
|
39186
|
+
this.binLength = null;
|
|
39187
|
+
}
|
|
39047
39188
|
}
|
|
39048
39189
|
class BatchTable extends FeatureTable {
|
|
39049
39190
|
batchSize;
|
|
@@ -40969,6 +41110,25 @@ class Res {
|
|
|
40969
41110
|
this._texturePool.set(url, texture);
|
|
40970
41111
|
return texture;
|
|
40971
41112
|
}
|
|
41113
|
+
destroyTexture(url) {
|
|
41114
|
+
const texture = this._texturePool.get(url);
|
|
41115
|
+
if (texture) {
|
|
41116
|
+
if (!Reference.getInstance().hasReference(texture)) {
|
|
41117
|
+
if (!texture.isDestroyed) {
|
|
41118
|
+
texture.destroy();
|
|
41119
|
+
}
|
|
41120
|
+
this._texturePool.delete(url);
|
|
41121
|
+
return true;
|
|
41122
|
+
}
|
|
41123
|
+
return false;
|
|
41124
|
+
}
|
|
41125
|
+
return false;
|
|
41126
|
+
}
|
|
41127
|
+
destroyTextureAllUnUsed() {
|
|
41128
|
+
for (const [url, texture] of this._texturePool.entries()) {
|
|
41129
|
+
this.destroyTexture(url);
|
|
41130
|
+
}
|
|
41131
|
+
}
|
|
40972
41132
|
async loadTextureCount(urls, count, loaderFunctions, flipY) {
|
|
40973
41133
|
return new Promise(async (suc, fail) => {
|
|
40974
41134
|
let total = 0;
|
|
@@ -41265,7 +41425,7 @@ class PostProcessingComponent extends ComponentBase {
|
|
|
41265
41425
|
}
|
|
41266
41426
|
}
|
|
41267
41427
|
|
|
41268
|
-
const version = "1.0.
|
|
41428
|
+
const version = "1.0.25";
|
|
41269
41429
|
|
|
41270
41430
|
class Engine3D {
|
|
41271
41431
|
/**
|
|
@@ -62497,7 +62657,7 @@ class TilesRenderer {
|
|
|
62497
62657
|
if (sceneObj.parent) {
|
|
62498
62658
|
sceneObj.parent.object3D.removeChild(sceneObj);
|
|
62499
62659
|
}
|
|
62500
|
-
sceneObj.destroy();
|
|
62660
|
+
sceneObj.destroy(true);
|
|
62501
62661
|
tileItem.cached.scene = null;
|
|
62502
62662
|
}
|
|
62503
62663
|
tileItem.loadingState = UNLOADED;
|
|
@@ -62811,7 +62971,7 @@ class TilesRenderer {
|
|
|
62811
62971
|
/**
|
|
62812
62972
|
* Clean up resources
|
|
62813
62973
|
*/
|
|
62814
|
-
dispose() {
|
|
62974
|
+
dispose(force) {
|
|
62815
62975
|
const plugins = [...this.plugins];
|
|
62816
62976
|
plugins.forEach((plugin) => this.unregisterPlugin(plugin));
|
|
62817
62977
|
this.lruCache.clear();
|
|
@@ -62823,7 +62983,7 @@ class TilesRenderer {
|
|
|
62823
62983
|
this.frameCount = 0;
|
|
62824
62984
|
this.isLoading = false;
|
|
62825
62985
|
this.resetCacheStats();
|
|
62826
|
-
this.group.destroy();
|
|
62986
|
+
this.group.destroy(force);
|
|
62827
62987
|
}
|
|
62828
62988
|
/**
|
|
62829
62989
|
* Rings-specific: Add camera
|