@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.umd.max.js
CHANGED
|
@@ -16792,6 +16792,10 @@ struct InstanceData {
|
|
|
16792
16792
|
name;
|
|
16793
16793
|
url;
|
|
16794
16794
|
gpuTexture;
|
|
16795
|
+
_isDestroyed = false;
|
|
16796
|
+
get isDestroyed() {
|
|
16797
|
+
return this._isDestroyed;
|
|
16798
|
+
}
|
|
16795
16799
|
pid;
|
|
16796
16800
|
view;
|
|
16797
16801
|
// Assigned later
|
|
@@ -17020,6 +17024,14 @@ struct InstanceData {
|
|
|
17020
17024
|
this.textureDescriptor = null;
|
|
17021
17025
|
this.gpuTexture.destroy();
|
|
17022
17026
|
this.gpuTexture = null;
|
|
17027
|
+
this._isDestroyed = true;
|
|
17028
|
+
}
|
|
17029
|
+
if (this._sourceImageData && this._sourceImageData instanceof ImageBitmap) {
|
|
17030
|
+
try {
|
|
17031
|
+
this._sourceImageData.close();
|
|
17032
|
+
} catch (e) {
|
|
17033
|
+
}
|
|
17034
|
+
this._sourceImageData = null;
|
|
17023
17035
|
}
|
|
17024
17036
|
this._stateChangeRef.clear();
|
|
17025
17037
|
}
|
|
@@ -20283,9 +20295,13 @@ struct InstanceData {
|
|
|
20283
20295
|
* @param target reference parent
|
|
20284
20296
|
*/
|
|
20285
20297
|
detached(ref, target) {
|
|
20298
|
+
if (!this.reference) return;
|
|
20286
20299
|
let refMap = this.reference.get(ref);
|
|
20287
20300
|
if (refMap) {
|
|
20288
20301
|
refMap.delete(target);
|
|
20302
|
+
if (refMap.size === 0) {
|
|
20303
|
+
this.reference.delete(ref);
|
|
20304
|
+
}
|
|
20289
20305
|
}
|
|
20290
20306
|
}
|
|
20291
20307
|
/**
|
|
@@ -22514,23 +22530,36 @@ struct InstanceData {
|
|
|
22514
22530
|
}
|
|
22515
22531
|
}
|
|
22516
22532
|
beforeDestroy(force) {
|
|
22517
|
-
|
|
22518
|
-
|
|
22519
|
-
this._geometry
|
|
22533
|
+
if (this._geometry) {
|
|
22534
|
+
Reference.getInstance().detached(this._geometry, this);
|
|
22535
|
+
if (!Reference.getInstance().hasReference(this._geometry)) {
|
|
22536
|
+
this._geometry.destroy(force);
|
|
22537
|
+
}
|
|
22520
22538
|
}
|
|
22521
22539
|
for (let i = 0; i < this._materials.length; i++) {
|
|
22522
22540
|
const mat = this._materials[i];
|
|
22523
|
-
|
|
22524
|
-
|
|
22525
|
-
|
|
22541
|
+
if (mat) {
|
|
22542
|
+
Reference.getInstance().detached(mat, this);
|
|
22543
|
+
if (!Reference.getInstance().hasReference(mat)) {
|
|
22544
|
+
mat.destroy(force);
|
|
22545
|
+
}
|
|
22526
22546
|
}
|
|
22527
22547
|
}
|
|
22548
|
+
if (this._computes) {
|
|
22549
|
+
this._computes.length = 0;
|
|
22550
|
+
}
|
|
22551
|
+
this.detachSceneOctree();
|
|
22528
22552
|
super.beforeDestroy(force);
|
|
22529
22553
|
}
|
|
22530
22554
|
destroy(force) {
|
|
22531
22555
|
super.destroy(force);
|
|
22532
22556
|
this._geometry = void 0;
|
|
22533
22557
|
this._materials.length = 0;
|
|
22558
|
+
this._computes = null;
|
|
22559
|
+
if (this._passInit) {
|
|
22560
|
+
this._passInit.clear();
|
|
22561
|
+
this._passInit = null;
|
|
22562
|
+
}
|
|
22534
22563
|
this._combineShaderRefection = void 0;
|
|
22535
22564
|
}
|
|
22536
22565
|
}
|
|
@@ -22550,6 +22579,7 @@ struct InstanceData {
|
|
|
22550
22579
|
enable = true;
|
|
22551
22580
|
_defaultSubShader;
|
|
22552
22581
|
_shader;
|
|
22582
|
+
_isDestroyed = false;
|
|
22553
22583
|
constructor() {
|
|
22554
22584
|
this.instanceID = UUID();
|
|
22555
22585
|
}
|
|
@@ -22664,10 +22694,17 @@ struct InstanceData {
|
|
|
22664
22694
|
return newMat;
|
|
22665
22695
|
}
|
|
22666
22696
|
destroy(force) {
|
|
22697
|
+
if (this._isDestroyed) {
|
|
22698
|
+
return;
|
|
22699
|
+
}
|
|
22667
22700
|
this.name = null;
|
|
22668
22701
|
this.instanceID = null;
|
|
22669
|
-
this._shader
|
|
22670
|
-
|
|
22702
|
+
if (this._shader) {
|
|
22703
|
+
this._shader.destroy(force);
|
|
22704
|
+
this._shader = null;
|
|
22705
|
+
}
|
|
22706
|
+
this._defaultSubShader = null;
|
|
22707
|
+
this._isDestroyed = true;
|
|
22671
22708
|
}
|
|
22672
22709
|
setDefine(define, value) {
|
|
22673
22710
|
this.shader.setDefine(define, value);
|
|
@@ -23172,8 +23209,15 @@ struct InstanceData {
|
|
|
23172
23209
|
}
|
|
23173
23210
|
}
|
|
23174
23211
|
}
|
|
23175
|
-
destroy() {
|
|
23176
|
-
this.
|
|
23212
|
+
destroy(force) {
|
|
23213
|
+
for (const pass of this.passShader) {
|
|
23214
|
+
for (const rd of pass[1]) {
|
|
23215
|
+
rd.destroy(force);
|
|
23216
|
+
}
|
|
23217
|
+
}
|
|
23218
|
+
this.passShader.clear();
|
|
23219
|
+
this.passShader = null;
|
|
23220
|
+
this.computes = null;
|
|
23177
23221
|
}
|
|
23178
23222
|
clone() {
|
|
23179
23223
|
let newShader = new Shader();
|
|
@@ -23665,6 +23709,7 @@ struct InstanceData {
|
|
|
23665
23709
|
_vertexBuffer;
|
|
23666
23710
|
_onChange = true;
|
|
23667
23711
|
_wireframeLines;
|
|
23712
|
+
_isDestroyed = false;
|
|
23668
23713
|
constructor() {
|
|
23669
23714
|
this.instanceID = UUID();
|
|
23670
23715
|
this._attributeMap = /* @__PURE__ */ new Map();
|
|
@@ -23911,18 +23956,40 @@ struct InstanceData {
|
|
|
23911
23956
|
return false;
|
|
23912
23957
|
}
|
|
23913
23958
|
destroy(force) {
|
|
23959
|
+
if (this._isDestroyed) {
|
|
23960
|
+
return;
|
|
23961
|
+
}
|
|
23914
23962
|
this.instanceID = null;
|
|
23915
23963
|
this.name = null;
|
|
23916
23964
|
this.subGeometries = null;
|
|
23917
23965
|
this.morphTargetDictionary = null;
|
|
23918
|
-
this.
|
|
23919
|
-
this.
|
|
23920
|
-
this.
|
|
23966
|
+
this.skinNames = null;
|
|
23967
|
+
this.bindPose = null;
|
|
23968
|
+
this.blendShapeData = null;
|
|
23969
|
+
this._wireframeLines = null;
|
|
23970
|
+
if (this._bounds) {
|
|
23971
|
+
this._bounds.destroy();
|
|
23972
|
+
this._bounds = null;
|
|
23973
|
+
}
|
|
23974
|
+
if (this._attributeMap) {
|
|
23975
|
+
this._attributeMap.forEach((vertexInfo) => {
|
|
23976
|
+
if (vertexInfo && vertexInfo.data) {
|
|
23977
|
+
vertexInfo.data = null;
|
|
23978
|
+
}
|
|
23979
|
+
});
|
|
23980
|
+
this._attributeMap.clear();
|
|
23981
|
+
this._attributeMap = null;
|
|
23982
|
+
}
|
|
23921
23983
|
this._attributes = null;
|
|
23922
|
-
this._indicesBuffer
|
|
23923
|
-
|
|
23924
|
-
|
|
23925
|
-
|
|
23984
|
+
if (this._indicesBuffer) {
|
|
23985
|
+
this._indicesBuffer.destroy();
|
|
23986
|
+
this._indicesBuffer = null;
|
|
23987
|
+
}
|
|
23988
|
+
if (this._vertexBuffer) {
|
|
23989
|
+
this._vertexBuffer.destroy();
|
|
23990
|
+
this._vertexBuffer = null;
|
|
23991
|
+
}
|
|
23992
|
+
this._isDestroyed = true;
|
|
23926
23993
|
}
|
|
23927
23994
|
}
|
|
23928
23995
|
|
|
@@ -25323,10 +25390,22 @@ struct InstanceData {
|
|
|
25323
25390
|
c.destroy(force);
|
|
25324
25391
|
});
|
|
25325
25392
|
this.components.clear();
|
|
25326
|
-
this.
|
|
25327
|
-
|
|
25328
|
-
|
|
25329
|
-
|
|
25393
|
+
this.components.clear();
|
|
25394
|
+
if (this.entityChildren) {
|
|
25395
|
+
this.entityChildren.forEach((c) => {
|
|
25396
|
+
c.destroy(force);
|
|
25397
|
+
});
|
|
25398
|
+
this.removeAllChild();
|
|
25399
|
+
this.entityChildren = [];
|
|
25400
|
+
}
|
|
25401
|
+
if (this._bound && this._bound.destroy) {
|
|
25402
|
+
this._bound.destroy();
|
|
25403
|
+
this._bound = null;
|
|
25404
|
+
}
|
|
25405
|
+
if (this._boundWorld && this._boundWorld.destroy) {
|
|
25406
|
+
this._boundWorld.destroy();
|
|
25407
|
+
this._boundWorld = null;
|
|
25408
|
+
}
|
|
25330
25409
|
this.transform.parent = null;
|
|
25331
25410
|
this._dispose = true;
|
|
25332
25411
|
super.destroy();
|
|
@@ -25598,6 +25677,16 @@ struct InstanceData {
|
|
|
25598
25677
|
this.onTransformLocalChange,
|
|
25599
25678
|
this
|
|
25600
25679
|
);
|
|
25680
|
+
const batchTable = this.batchTable;
|
|
25681
|
+
if (batchTable && typeof batchTable.destroy === "function") {
|
|
25682
|
+
batchTable.destroy();
|
|
25683
|
+
this.batchTable = null;
|
|
25684
|
+
}
|
|
25685
|
+
const featureTable = this.featureTable;
|
|
25686
|
+
if (featureTable && typeof featureTable.destroy === "function") {
|
|
25687
|
+
featureTable.destroy();
|
|
25688
|
+
this.featureTable = null;
|
|
25689
|
+
}
|
|
25601
25690
|
super.destroy(force);
|
|
25602
25691
|
}
|
|
25603
25692
|
};
|
|
@@ -32705,9 +32794,32 @@ fn CsMain( @builtin(workgroup_id) workgroup_id : vec3<u32> , @builtin(global_inv
|
|
|
32705
32794
|
return url.substring(0, s_pos);
|
|
32706
32795
|
}
|
|
32707
32796
|
static normalizePath(url) {
|
|
32708
|
-
|
|
32709
|
-
|
|
32710
|
-
|
|
32797
|
+
if (!url) {
|
|
32798
|
+
return url;
|
|
32799
|
+
}
|
|
32800
|
+
let normalized = url.replace(/\\/g, "/");
|
|
32801
|
+
const preserveLeadingDoubleSlash = normalized.startsWith("//");
|
|
32802
|
+
const protectedTokens = [];
|
|
32803
|
+
let tokenIndex = 0;
|
|
32804
|
+
normalized = normalized.replace(
|
|
32805
|
+
/([a-zA-Z][a-zA-Z0-9+\-.]*):\/{2}/g,
|
|
32806
|
+
(match, scheme, offset) => {
|
|
32807
|
+
if (scheme.length === 1 && offset === 0) {
|
|
32808
|
+
return match;
|
|
32809
|
+
}
|
|
32810
|
+
const token = `__SCHEME_SLASH_${tokenIndex++}__`;
|
|
32811
|
+
protectedTokens.push(token);
|
|
32812
|
+
return `${scheme}:${token}`;
|
|
32813
|
+
}
|
|
32814
|
+
);
|
|
32815
|
+
normalized = normalized.replace(/\/{2,}/g, "/");
|
|
32816
|
+
protectedTokens.forEach((token) => {
|
|
32817
|
+
normalized = normalized.replace(token, "//");
|
|
32818
|
+
});
|
|
32819
|
+
if (preserveLeadingDoubleSlash) {
|
|
32820
|
+
normalized = `//${normalized.replace(/^\/+/, "")}`;
|
|
32821
|
+
}
|
|
32822
|
+
return normalized;
|
|
32711
32823
|
}
|
|
32712
32824
|
static getStringList(str, char = ";") {
|
|
32713
32825
|
return str.split(char);
|
|
@@ -32889,6 +33001,12 @@ fn CsMain( @builtin(workgroup_id) workgroup_id : vec3<u32> , @builtin(global_inv
|
|
|
32889
33001
|
return this._source;
|
|
32890
33002
|
}
|
|
32891
33003
|
set source(value) {
|
|
33004
|
+
if (this._source && this._source instanceof ImageBitmap) {
|
|
33005
|
+
try {
|
|
33006
|
+
this._source.close();
|
|
33007
|
+
} catch (e) {
|
|
33008
|
+
}
|
|
33009
|
+
}
|
|
32892
33010
|
this._source = value;
|
|
32893
33011
|
if (this._source instanceof HTMLImageElement) {
|
|
32894
33012
|
this._source.decode().then(async () => {
|
|
@@ -32956,17 +33074,32 @@ fn CsMain( @builtin(workgroup_id) workgroup_id : vec3<u32> , @builtin(global_inv
|
|
|
32956
33074
|
if (imageBitmap.width < 32 || imageBitmap.height < 32) {
|
|
32957
33075
|
let width = Math.max(imageBitmap.width, 32);
|
|
32958
33076
|
let height = Math.max(imageBitmap.height, 32);
|
|
33077
|
+
const oldImageBitmap = imageBitmap;
|
|
32959
33078
|
imageBitmap = await createImageBitmap(imageBitmap, {
|
|
32960
33079
|
resizeWidth: width,
|
|
32961
33080
|
resizeHeight: height,
|
|
32962
33081
|
imageOrientation: this.flipY ? "flipY" : "from-image",
|
|
32963
33082
|
premultiplyAlpha: "none"
|
|
32964
33083
|
});
|
|
33084
|
+
try {
|
|
33085
|
+
oldImageBitmap.close();
|
|
33086
|
+
} catch (e) {
|
|
33087
|
+
}
|
|
32965
33088
|
}
|
|
32966
33089
|
this.format = GPUTextureFormat.rgba8unorm;
|
|
32967
33090
|
this.generate(imageBitmap);
|
|
32968
33091
|
return true;
|
|
32969
33092
|
}
|
|
33093
|
+
destroy(force) {
|
|
33094
|
+
if (this._source && this._source instanceof ImageBitmap) {
|
|
33095
|
+
try {
|
|
33096
|
+
this._source.close();
|
|
33097
|
+
} catch (e) {
|
|
33098
|
+
}
|
|
33099
|
+
this._source = null;
|
|
33100
|
+
}
|
|
33101
|
+
super.destroy(force);
|
|
33102
|
+
}
|
|
32970
33103
|
}
|
|
32971
33104
|
|
|
32972
33105
|
class LoaderBase {
|
|
@@ -36214,6 +36347,7 @@ else if (typeof exports === 'object')
|
|
|
36214
36347
|
this._gltf,
|
|
36215
36348
|
this._gltf.scene
|
|
36216
36349
|
);
|
|
36350
|
+
subParser.destroy();
|
|
36217
36351
|
if (nodes) {
|
|
36218
36352
|
this.data = nodes.rootNode;
|
|
36219
36353
|
return nodes.rootNode;
|
|
@@ -36251,6 +36385,7 @@ else if (typeof exports === 'object')
|
|
|
36251
36385
|
this._gltf,
|
|
36252
36386
|
this._gltf.scene
|
|
36253
36387
|
);
|
|
36388
|
+
subParser.destroy();
|
|
36254
36389
|
if (nodes) {
|
|
36255
36390
|
this.data = nodes.rootNode;
|
|
36256
36391
|
return nodes.rootNode;
|
|
@@ -39051,6 +39186,12 @@ else if (typeof exports === 'object')
|
|
|
39051
39186
|
return data;
|
|
39052
39187
|
}
|
|
39053
39188
|
}
|
|
39189
|
+
destroy() {
|
|
39190
|
+
this.buffer = null;
|
|
39191
|
+
this.header = null;
|
|
39192
|
+
this.binOffset = null;
|
|
39193
|
+
this.binLength = null;
|
|
39194
|
+
}
|
|
39054
39195
|
}
|
|
39055
39196
|
class BatchTable extends FeatureTable {
|
|
39056
39197
|
batchSize;
|
|
@@ -40976,6 +41117,25 @@ else if (typeof exports === 'object')
|
|
|
40976
41117
|
this._texturePool.set(url, texture);
|
|
40977
41118
|
return texture;
|
|
40978
41119
|
}
|
|
41120
|
+
destroyTexture(url) {
|
|
41121
|
+
const texture = this._texturePool.get(url);
|
|
41122
|
+
if (texture) {
|
|
41123
|
+
if (!Reference.getInstance().hasReference(texture)) {
|
|
41124
|
+
if (!texture.isDestroyed) {
|
|
41125
|
+
texture.destroy();
|
|
41126
|
+
}
|
|
41127
|
+
this._texturePool.delete(url);
|
|
41128
|
+
return true;
|
|
41129
|
+
}
|
|
41130
|
+
return false;
|
|
41131
|
+
}
|
|
41132
|
+
return false;
|
|
41133
|
+
}
|
|
41134
|
+
destroyTextureAllUnUsed() {
|
|
41135
|
+
for (const [url, texture] of this._texturePool.entries()) {
|
|
41136
|
+
this.destroyTexture(url);
|
|
41137
|
+
}
|
|
41138
|
+
}
|
|
40979
41139
|
async loadTextureCount(urls, count, loaderFunctions, flipY) {
|
|
40980
41140
|
return new Promise(async (suc, fail) => {
|
|
40981
41141
|
let total = 0;
|
|
@@ -41272,7 +41432,7 @@ else if (typeof exports === 'object')
|
|
|
41272
41432
|
}
|
|
41273
41433
|
}
|
|
41274
41434
|
|
|
41275
|
-
const version = "1.0.
|
|
41435
|
+
const version = "1.0.25";
|
|
41276
41436
|
|
|
41277
41437
|
class Engine3D {
|
|
41278
41438
|
/**
|
|
@@ -62504,7 +62664,7 @@ fn frag(){
|
|
|
62504
62664
|
if (sceneObj.parent) {
|
|
62505
62665
|
sceneObj.parent.object3D.removeChild(sceneObj);
|
|
62506
62666
|
}
|
|
62507
|
-
sceneObj.destroy();
|
|
62667
|
+
sceneObj.destroy(true);
|
|
62508
62668
|
tileItem.cached.scene = null;
|
|
62509
62669
|
}
|
|
62510
62670
|
tileItem.loadingState = UNLOADED;
|
|
@@ -62818,7 +62978,7 @@ fn frag(){
|
|
|
62818
62978
|
/**
|
|
62819
62979
|
* Clean up resources
|
|
62820
62980
|
*/
|
|
62821
|
-
dispose() {
|
|
62981
|
+
dispose(force) {
|
|
62822
62982
|
const plugins = [...this.plugins];
|
|
62823
62983
|
plugins.forEach((plugin) => this.unregisterPlugin(plugin));
|
|
62824
62984
|
this.lruCache.clear();
|
|
@@ -62830,7 +62990,7 @@ fn frag(){
|
|
|
62830
62990
|
this.frameCount = 0;
|
|
62831
62991
|
this.isLoading = false;
|
|
62832
62992
|
this.resetCacheStats();
|
|
62833
|
-
this.group.destroy();
|
|
62993
|
+
this.group.destroy(force);
|
|
62834
62994
|
}
|
|
62835
62995
|
/**
|
|
62836
62996
|
* Rings-specific: Add camera
|
|
@@ -44,6 +44,8 @@ export declare class Res {
|
|
|
44
44
|
loadB3DM(url: string, loaderFunctions?: LoaderFunctions, userData?: any): Promise<Object3D>;
|
|
45
45
|
loadI3DM(url: string, loaderFunctions?: LoaderFunctions, userData?: any): Promise<Object3D>;
|
|
46
46
|
loadTexture(url: string, loaderFunctions?: LoaderFunctions, flipY?: boolean): Promise<Texture>;
|
|
47
|
+
destroyTexture(url: string): boolean;
|
|
48
|
+
destroyTextureAllUnUsed(): void;
|
|
47
49
|
private loadTextureCount;
|
|
48
50
|
loadBitmapTextures(urls: string[], count?: number, loaderFunctions?: LoaderFunctions, flipY?: boolean): Promise<BitmapTexture2D[]>;
|
|
49
51
|
loadHDRTexture(url: string, loaderFunctions?: LoaderFunctions): Promise<Texture>;
|
|
@@ -2,6 +2,8 @@ export declare class Texture implements GPUSamplerDescriptor {
|
|
|
2
2
|
name: string;
|
|
3
3
|
url: string;
|
|
4
4
|
protected gpuTexture: GPUTexture;
|
|
5
|
+
private _isDestroyed;
|
|
6
|
+
get isDestroyed(): boolean;
|
|
5
7
|
pid: number;
|
|
6
8
|
view: GPUTextureView | GPUExternalTexture;
|
|
7
9
|
gpuSampler: GPUSampler;
|
|
@@ -47,7 +47,7 @@ export declare class Shader {
|
|
|
47
47
|
setStructStorageBuffer<T extends Struct>(arg0: string, arg1: StructStorageGPUBuffer<T>): void;
|
|
48
48
|
getStructStorageBuffer(arg0: string): GPUBufferBase;
|
|
49
49
|
noticeValueChange(): void;
|
|
50
|
-
destroy(): void;
|
|
50
|
+
destroy(force?: boolean): void;
|
|
51
51
|
clone(): Shader;
|
|
52
52
|
applyUniform(): void;
|
|
53
53
|
}
|
|
@@ -6,6 +6,7 @@ export declare class FeatureTable {
|
|
|
6
6
|
constructor(buffer: any, start: any, headerLength: any, binLength: any);
|
|
7
7
|
getKeys(): string[];
|
|
8
8
|
getData(key: any, count?: any, defaultComponentType?: any, defaultType?: any): any;
|
|
9
|
+
destroy(): void;
|
|
9
10
|
}
|
|
10
11
|
export declare class BatchTable extends FeatureTable {
|
|
11
12
|
private batchSize;
|