@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.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
|
};
|
|
@@ -32912,6 +33001,12 @@ fn CsMain( @builtin(workgroup_id) workgroup_id : vec3<u32> , @builtin(global_inv
|
|
|
32912
33001
|
return this._source;
|
|
32913
33002
|
}
|
|
32914
33003
|
set source(value) {
|
|
33004
|
+
if (this._source && this._source instanceof ImageBitmap) {
|
|
33005
|
+
try {
|
|
33006
|
+
this._source.close();
|
|
33007
|
+
} catch (e) {
|
|
33008
|
+
}
|
|
33009
|
+
}
|
|
32915
33010
|
this._source = value;
|
|
32916
33011
|
if (this._source instanceof HTMLImageElement) {
|
|
32917
33012
|
this._source.decode().then(async () => {
|
|
@@ -32979,17 +33074,32 @@ fn CsMain( @builtin(workgroup_id) workgroup_id : vec3<u32> , @builtin(global_inv
|
|
|
32979
33074
|
if (imageBitmap.width < 32 || imageBitmap.height < 32) {
|
|
32980
33075
|
let width = Math.max(imageBitmap.width, 32);
|
|
32981
33076
|
let height = Math.max(imageBitmap.height, 32);
|
|
33077
|
+
const oldImageBitmap = imageBitmap;
|
|
32982
33078
|
imageBitmap = await createImageBitmap(imageBitmap, {
|
|
32983
33079
|
resizeWidth: width,
|
|
32984
33080
|
resizeHeight: height,
|
|
32985
33081
|
imageOrientation: this.flipY ? "flipY" : "from-image",
|
|
32986
33082
|
premultiplyAlpha: "none"
|
|
32987
33083
|
});
|
|
33084
|
+
try {
|
|
33085
|
+
oldImageBitmap.close();
|
|
33086
|
+
} catch (e) {
|
|
33087
|
+
}
|
|
32988
33088
|
}
|
|
32989
33089
|
this.format = GPUTextureFormat.rgba8unorm;
|
|
32990
33090
|
this.generate(imageBitmap);
|
|
32991
33091
|
return true;
|
|
32992
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
|
+
}
|
|
32993
33103
|
}
|
|
32994
33104
|
|
|
32995
33105
|
class LoaderBase {
|
|
@@ -36237,6 +36347,7 @@ else if (typeof exports === 'object')
|
|
|
36237
36347
|
this._gltf,
|
|
36238
36348
|
this._gltf.scene
|
|
36239
36349
|
);
|
|
36350
|
+
subParser.destroy();
|
|
36240
36351
|
if (nodes) {
|
|
36241
36352
|
this.data = nodes.rootNode;
|
|
36242
36353
|
return nodes.rootNode;
|
|
@@ -36274,6 +36385,7 @@ else if (typeof exports === 'object')
|
|
|
36274
36385
|
this._gltf,
|
|
36275
36386
|
this._gltf.scene
|
|
36276
36387
|
);
|
|
36388
|
+
subParser.destroy();
|
|
36277
36389
|
if (nodes) {
|
|
36278
36390
|
this.data = nodes.rootNode;
|
|
36279
36391
|
return nodes.rootNode;
|
|
@@ -39074,6 +39186,12 @@ else if (typeof exports === 'object')
|
|
|
39074
39186
|
return data;
|
|
39075
39187
|
}
|
|
39076
39188
|
}
|
|
39189
|
+
destroy() {
|
|
39190
|
+
this.buffer = null;
|
|
39191
|
+
this.header = null;
|
|
39192
|
+
this.binOffset = null;
|
|
39193
|
+
this.binLength = null;
|
|
39194
|
+
}
|
|
39077
39195
|
}
|
|
39078
39196
|
class BatchTable extends FeatureTable {
|
|
39079
39197
|
batchSize;
|
|
@@ -40999,6 +41117,25 @@ else if (typeof exports === 'object')
|
|
|
40999
41117
|
this._texturePool.set(url, texture);
|
|
41000
41118
|
return texture;
|
|
41001
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
|
+
}
|
|
41002
41139
|
async loadTextureCount(urls, count, loaderFunctions, flipY) {
|
|
41003
41140
|
return new Promise(async (suc, fail) => {
|
|
41004
41141
|
let total = 0;
|
|
@@ -41295,7 +41432,7 @@ else if (typeof exports === 'object')
|
|
|
41295
41432
|
}
|
|
41296
41433
|
}
|
|
41297
41434
|
|
|
41298
|
-
const version = "1.0.
|
|
41435
|
+
const version = "1.0.25";
|
|
41299
41436
|
|
|
41300
41437
|
class Engine3D {
|
|
41301
41438
|
/**
|
|
@@ -62527,7 +62664,7 @@ fn frag(){
|
|
|
62527
62664
|
if (sceneObj.parent) {
|
|
62528
62665
|
sceneObj.parent.object3D.removeChild(sceneObj);
|
|
62529
62666
|
}
|
|
62530
|
-
sceneObj.destroy();
|
|
62667
|
+
sceneObj.destroy(true);
|
|
62531
62668
|
tileItem.cached.scene = null;
|
|
62532
62669
|
}
|
|
62533
62670
|
tileItem.loadingState = UNLOADED;
|
|
@@ -62841,7 +62978,7 @@ fn frag(){
|
|
|
62841
62978
|
/**
|
|
62842
62979
|
* Clean up resources
|
|
62843
62980
|
*/
|
|
62844
|
-
dispose() {
|
|
62981
|
+
dispose(force) {
|
|
62845
62982
|
const plugins = [...this.plugins];
|
|
62846
62983
|
plugins.forEach((plugin) => this.unregisterPlugin(plugin));
|
|
62847
62984
|
this.lruCache.clear();
|
|
@@ -62853,7 +62990,7 @@ fn frag(){
|
|
|
62853
62990
|
this.frameCount = 0;
|
|
62854
62991
|
this.isLoading = false;
|
|
62855
62992
|
this.resetCacheStats();
|
|
62856
|
-
this.group.destroy();
|
|
62993
|
+
this.group.destroy(force);
|
|
62857
62994
|
}
|
|
62858
62995
|
/**
|
|
62859
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;
|