@rings-webgpu/core 1.0.25 → 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 +13 -13
- package/dist/rings.es.js.map +3 -3
- package/dist/rings.es.max.js +162 -25
- package/dist/rings.umd.js +8 -8
- package/dist/rings.umd.js.map +3 -3
- package/dist/rings.umd.max.js +162 -25
- 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
|
};
|
|
@@ -32905,6 +32994,12 @@ class BitmapTexture2D extends Texture {
|
|
|
32905
32994
|
return this._source;
|
|
32906
32995
|
}
|
|
32907
32996
|
set source(value) {
|
|
32997
|
+
if (this._source && this._source instanceof ImageBitmap) {
|
|
32998
|
+
try {
|
|
32999
|
+
this._source.close();
|
|
33000
|
+
} catch (e) {
|
|
33001
|
+
}
|
|
33002
|
+
}
|
|
32908
33003
|
this._source = value;
|
|
32909
33004
|
if (this._source instanceof HTMLImageElement) {
|
|
32910
33005
|
this._source.decode().then(async () => {
|
|
@@ -32972,17 +33067,32 @@ class BitmapTexture2D extends Texture {
|
|
|
32972
33067
|
if (imageBitmap.width < 32 || imageBitmap.height < 32) {
|
|
32973
33068
|
let width = Math.max(imageBitmap.width, 32);
|
|
32974
33069
|
let height = Math.max(imageBitmap.height, 32);
|
|
33070
|
+
const oldImageBitmap = imageBitmap;
|
|
32975
33071
|
imageBitmap = await createImageBitmap(imageBitmap, {
|
|
32976
33072
|
resizeWidth: width,
|
|
32977
33073
|
resizeHeight: height,
|
|
32978
33074
|
imageOrientation: this.flipY ? "flipY" : "from-image",
|
|
32979
33075
|
premultiplyAlpha: "none"
|
|
32980
33076
|
});
|
|
33077
|
+
try {
|
|
33078
|
+
oldImageBitmap.close();
|
|
33079
|
+
} catch (e) {
|
|
33080
|
+
}
|
|
32981
33081
|
}
|
|
32982
33082
|
this.format = GPUTextureFormat.rgba8unorm;
|
|
32983
33083
|
this.generate(imageBitmap);
|
|
32984
33084
|
return true;
|
|
32985
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
|
+
}
|
|
32986
33096
|
}
|
|
32987
33097
|
|
|
32988
33098
|
class LoaderBase {
|
|
@@ -36230,6 +36340,7 @@ class GLBParser extends ParserBase {
|
|
|
36230
36340
|
this._gltf,
|
|
36231
36341
|
this._gltf.scene
|
|
36232
36342
|
);
|
|
36343
|
+
subParser.destroy();
|
|
36233
36344
|
if (nodes) {
|
|
36234
36345
|
this.data = nodes.rootNode;
|
|
36235
36346
|
return nodes.rootNode;
|
|
@@ -36267,6 +36378,7 @@ class GLBParser extends ParserBase {
|
|
|
36267
36378
|
this._gltf,
|
|
36268
36379
|
this._gltf.scene
|
|
36269
36380
|
);
|
|
36381
|
+
subParser.destroy();
|
|
36270
36382
|
if (nodes) {
|
|
36271
36383
|
this.data = nodes.rootNode;
|
|
36272
36384
|
return nodes.rootNode;
|
|
@@ -39067,6 +39179,12 @@ class FeatureTable {
|
|
|
39067
39179
|
return data;
|
|
39068
39180
|
}
|
|
39069
39181
|
}
|
|
39182
|
+
destroy() {
|
|
39183
|
+
this.buffer = null;
|
|
39184
|
+
this.header = null;
|
|
39185
|
+
this.binOffset = null;
|
|
39186
|
+
this.binLength = null;
|
|
39187
|
+
}
|
|
39070
39188
|
}
|
|
39071
39189
|
class BatchTable extends FeatureTable {
|
|
39072
39190
|
batchSize;
|
|
@@ -40992,6 +41110,25 @@ class Res {
|
|
|
40992
41110
|
this._texturePool.set(url, texture);
|
|
40993
41111
|
return texture;
|
|
40994
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
|
+
}
|
|
40995
41132
|
async loadTextureCount(urls, count, loaderFunctions, flipY) {
|
|
40996
41133
|
return new Promise(async (suc, fail) => {
|
|
40997
41134
|
let total = 0;
|
|
@@ -41288,7 +41425,7 @@ class PostProcessingComponent extends ComponentBase {
|
|
|
41288
41425
|
}
|
|
41289
41426
|
}
|
|
41290
41427
|
|
|
41291
|
-
const version = "1.0.
|
|
41428
|
+
const version = "1.0.25";
|
|
41292
41429
|
|
|
41293
41430
|
class Engine3D {
|
|
41294
41431
|
/**
|
|
@@ -62520,7 +62657,7 @@ class TilesRenderer {
|
|
|
62520
62657
|
if (sceneObj.parent) {
|
|
62521
62658
|
sceneObj.parent.object3D.removeChild(sceneObj);
|
|
62522
62659
|
}
|
|
62523
|
-
sceneObj.destroy();
|
|
62660
|
+
sceneObj.destroy(true);
|
|
62524
62661
|
tileItem.cached.scene = null;
|
|
62525
62662
|
}
|
|
62526
62663
|
tileItem.loadingState = UNLOADED;
|
|
@@ -62834,7 +62971,7 @@ class TilesRenderer {
|
|
|
62834
62971
|
/**
|
|
62835
62972
|
* Clean up resources
|
|
62836
62973
|
*/
|
|
62837
|
-
dispose() {
|
|
62974
|
+
dispose(force) {
|
|
62838
62975
|
const plugins = [...this.plugins];
|
|
62839
62976
|
plugins.forEach((plugin) => this.unregisterPlugin(plugin));
|
|
62840
62977
|
this.lruCache.clear();
|
|
@@ -62846,7 +62983,7 @@ class TilesRenderer {
|
|
|
62846
62983
|
this.frameCount = 0;
|
|
62847
62984
|
this.isLoading = false;
|
|
62848
62985
|
this.resetCacheStats();
|
|
62849
|
-
this.group.destroy();
|
|
62986
|
+
this.group.destroy(force);
|
|
62850
62987
|
}
|
|
62851
62988
|
/**
|
|
62852
62989
|
* Rings-specific: Add camera
|