@rings-webgpu/core 1.0.45 → 1.0.47
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 +132 -128
- package/dist/rings.es.js.map +3 -3
- package/dist/rings.es.max.js +49 -75
- package/dist/rings.umd.js +134 -130
- package/dist/rings.umd.js.map +3 -3
- package/dist/rings.umd.max.js +49 -75
- package/dist/types/loader/parser/tileRenderer/TilesRenderer.d.ts +1 -0
- package/dist/types/textures/Float16ArrayTexture.d.ts +5 -6
- package/package.json +1 -1
package/dist/rings.es.max.js
CHANGED
|
@@ -22843,13 +22843,15 @@ const GSplat_VS = (
|
|
|
22843
22843
|
}
|
|
22844
22844
|
|
|
22845
22845
|
// === calcSplatUV() - returns optional UV ===
|
|
22846
|
-
fn
|
|
22846
|
+
fn getSplatId(orderId: u32, textureWidth: u32, numSplats: u32) -> u32 {
|
|
22847
22847
|
let orderUV = vec2<i32>(
|
|
22848
22848
|
i32(orderId % textureWidth),
|
|
22849
22849
|
i32(orderId / textureWidth)
|
|
22850
22850
|
);
|
|
22851
22851
|
|
|
22852
|
-
|
|
22852
|
+
return u32(textureLoad(splatOrder, orderUV, 0).r);
|
|
22853
|
+
}
|
|
22854
|
+
fn calcSplatUV(splatId: u32, textureWidth: u32, numSplats: u32) -> vec2<i32> {
|
|
22853
22855
|
return vec2<i32>(
|
|
22854
22856
|
i32(splatId % textureWidth),
|
|
22855
22857
|
i32(splatId / textureWidth)
|
|
@@ -22948,9 +22950,11 @@ const GSplat_VS = (
|
|
|
22948
22950
|
if (orderId >= numSplats) {
|
|
22949
22951
|
return discardSplat();
|
|
22950
22952
|
}
|
|
22953
|
+
|
|
22954
|
+
let splatId = getSplatId(orderId, textureWidth, numSplats);
|
|
22951
22955
|
|
|
22952
22956
|
// Calculate splat UV and load all data in one go
|
|
22953
|
-
let splatUV = calcSplatUV(
|
|
22957
|
+
let splatUV = calcSplatUV(splatId, textureWidth, numSplats);
|
|
22954
22958
|
let splatData = getSplatData(splatUV);
|
|
22955
22959
|
|
|
22956
22960
|
// Load color early for alpha test
|
|
@@ -24301,75 +24305,44 @@ class R32UintTexture extends Texture {
|
|
|
24301
24305
|
}
|
|
24302
24306
|
|
|
24303
24307
|
const _floatView$1 = new Float32Array(1);
|
|
24304
|
-
|
|
24305
|
-
function batchConvertToHalfFloat(src, dst, offset, length) {
|
|
24306
|
-
for (let i = 0; i < length; i++) {
|
|
24307
|
-
const val = src[offset + i];
|
|
24308
|
-
_floatView$1[0] = val;
|
|
24309
|
-
const x = _int32View$1[0];
|
|
24310
|
-
let bits = x >> 16 & 32768;
|
|
24311
|
-
let m = x >> 12 & 2047;
|
|
24312
|
-
const e = x >> 23 & 255;
|
|
24313
|
-
if (e < 103) {
|
|
24314
|
-
dst[offset + i] = bits;
|
|
24315
|
-
continue;
|
|
24316
|
-
}
|
|
24317
|
-
if (e > 142) {
|
|
24318
|
-
bits |= 31744;
|
|
24319
|
-
bits |= (e == 255 ? 1 : 0) && x & 8388607;
|
|
24320
|
-
dst[offset + i] = bits;
|
|
24321
|
-
continue;
|
|
24322
|
-
}
|
|
24323
|
-
if (e < 114) {
|
|
24324
|
-
m |= 2048;
|
|
24325
|
-
bits |= (m >> 114 - e) + (m >> 113 - e & 1);
|
|
24326
|
-
dst[offset + i] = bits;
|
|
24327
|
-
continue;
|
|
24328
|
-
}
|
|
24329
|
-
bits |= e - 112 << 10 | m >> 1;
|
|
24330
|
-
bits += m & 1;
|
|
24331
|
-
dst[offset + i] = bits;
|
|
24332
|
-
}
|
|
24333
|
-
}
|
|
24308
|
+
new Int32Array(_floatView$1.buffer);
|
|
24334
24309
|
class Float16ArrayTexture extends Texture {
|
|
24335
24310
|
uint16Array;
|
|
24336
|
-
floatArray;
|
|
24337
24311
|
_dataBuffer;
|
|
24338
24312
|
/**
|
|
24339
|
-
*
|
|
24313
|
+
* 使用 Uint16Array 填充纹理(Float16 格式),格式为[红0, 绿0, 蓝0, 透明度0, 红1, 绿1, 蓝1, 透明度1...]
|
|
24340
24314
|
* @param width 纹理宽度
|
|
24341
24315
|
* @param height 纹理高度
|
|
24342
|
-
* @param
|
|
24316
|
+
* @param data Float16 数据数组(Uint16Array),每个元素是一个 Float16 值
|
|
24343
24317
|
* @param useMipmap 是否生成Mipmap
|
|
24344
24318
|
* @returns 返回纹理实例
|
|
24345
24319
|
*/
|
|
24346
|
-
create(width, height,
|
|
24347
|
-
if (
|
|
24348
|
-
|
|
24349
|
-
|
|
24350
|
-
|
|
24351
|
-
}
|
|
24320
|
+
create(width, height, data = null, mipmap = true) {
|
|
24321
|
+
if (data == null) {
|
|
24322
|
+
const size = width * height * 4;
|
|
24323
|
+
data = new Uint16Array(size);
|
|
24324
|
+
data.fill(0);
|
|
24352
24325
|
}
|
|
24353
|
-
this.updateTexture(width, height,
|
|
24326
|
+
this.updateTexture(width, height, data, mipmap);
|
|
24354
24327
|
return this;
|
|
24355
24328
|
}
|
|
24356
24329
|
/**
|
|
24357
24330
|
* 更新纹理内容
|
|
24358
24331
|
* @param width 纹理宽度
|
|
24359
24332
|
* @param height 纹理高度
|
|
24360
|
-
* @param
|
|
24333
|
+
* @param data Float16 数据数组(Uint16Array),每个元素是一个 Float16 值
|
|
24361
24334
|
* @param mipmap 是否生成Mipmap
|
|
24362
24335
|
* @param startRow 起始行(部分更新)
|
|
24363
24336
|
* @param rowCount 更新的行数(部分更新)
|
|
24364
24337
|
*/
|
|
24365
|
-
updateTexture(width, height,
|
|
24338
|
+
updateTexture(width, height, data, mipmap = true, startRow, rowCount) {
|
|
24366
24339
|
if (width != this.width || height != this.height) {
|
|
24367
24340
|
this._dataBuffer && this._dataBuffer.destroy();
|
|
24368
24341
|
this._dataBuffer = null;
|
|
24369
24342
|
this.gpuTexture && this.gpuTexture.destroy();
|
|
24370
24343
|
this.gpuTexture = null;
|
|
24371
24344
|
}
|
|
24372
|
-
this.
|
|
24345
|
+
this.uint16Array = data;
|
|
24373
24346
|
let device = webGPUContext.device;
|
|
24374
24347
|
const bytesPerRow = width * 4 * 2;
|
|
24375
24348
|
this.format = GPUTextureFormat.rgba16float;
|
|
@@ -24379,14 +24352,7 @@ class Float16ArrayTexture extends Texture {
|
|
|
24379
24352
|
const updateHeight = rowCount;
|
|
24380
24353
|
const updateOffset = startRow * width * 4;
|
|
24381
24354
|
const updateLength = updateHeight * width * 4;
|
|
24382
|
-
|
|
24383
|
-
if (!this.uint16Array || this.uint16Array.length < numbers.length) {
|
|
24384
|
-
this.uint16Array = new Uint16Array(numbers.length);
|
|
24385
|
-
}
|
|
24386
|
-
}
|
|
24387
|
-
const uint16Array2 = this.uint16Array;
|
|
24388
|
-
batchConvertToHalfFloat(numbers, uint16Array2, updateOffset, updateLength);
|
|
24389
|
-
const updateData = uint16Array2.subarray(updateOffset, updateOffset + updateLength);
|
|
24355
|
+
const updateData = data.subarray(updateOffset, updateOffset + updateLength);
|
|
24390
24356
|
const neededSize2 = updateData.byteLength;
|
|
24391
24357
|
if (!this._dataBuffer || this._dataBuffer.size < neededSize2) {
|
|
24392
24358
|
this._dataBuffer && this._dataBuffer.destroy();
|
|
@@ -24421,11 +24387,7 @@ class Float16ArrayTexture extends Texture {
|
|
|
24421
24387
|
GPUContext.endCommandEncoder(commandEncoder2);
|
|
24422
24388
|
return;
|
|
24423
24389
|
}
|
|
24424
|
-
|
|
24425
|
-
this.uint16Array = new Uint16Array(numbers.length);
|
|
24426
|
-
}
|
|
24427
|
-
const uint16Array = this.uint16Array;
|
|
24428
|
-
batchConvertToHalfFloat(numbers, uint16Array, 0, numbers.length);
|
|
24390
|
+
const uint16Array = data;
|
|
24429
24391
|
const neededSize = uint16Array.byteLength;
|
|
24430
24392
|
if (!this._dataBuffer || this._dataBuffer.size < neededSize) {
|
|
24431
24393
|
this._dataBuffer && this._dataBuffer.destroy();
|
|
@@ -24814,7 +24776,8 @@ let GSplatRenderer = class extends RenderNode {
|
|
|
24814
24776
|
const h = this.size.y | 0;
|
|
24815
24777
|
const count = asset.count;
|
|
24816
24778
|
const tA = new Uint32Array(w * h * 4);
|
|
24817
|
-
const tB = new
|
|
24779
|
+
const tB = new Uint16Array(w * h * 4);
|
|
24780
|
+
tB.fill(0);
|
|
24818
24781
|
const fb = new ArrayBuffer(4);
|
|
24819
24782
|
const f32 = new Float32Array(fb);
|
|
24820
24783
|
const u32 = new Uint32Array(fb);
|
|
@@ -24888,10 +24851,10 @@ let GSplatRenderer = class extends RenderNode {
|
|
|
24888
24851
|
const cBy = r01 * r02 + r11 * r12 + r21 * r22;
|
|
24889
24852
|
const cBz = r02 * r02 + r12 * r12 + r22 * r22;
|
|
24890
24853
|
const bidx = idx;
|
|
24891
|
-
tB[bidx + 0] = cAx;
|
|
24892
|
-
tB[bidx + 1] = cAy;
|
|
24893
|
-
tB[bidx + 2] = cAz;
|
|
24894
|
-
tB[bidx + 3] = cBz;
|
|
24854
|
+
tB[bidx + 0] = toHalfFloat(cAx) & 65535;
|
|
24855
|
+
tB[bidx + 1] = toHalfFloat(cAy) & 65535;
|
|
24856
|
+
tB[bidx + 2] = toHalfFloat(cAz) & 65535;
|
|
24857
|
+
tB[bidx + 3] = toHalfFloat(cBz) & 65535;
|
|
24895
24858
|
const hx = toHalfFloat(cBx) & 65535;
|
|
24896
24859
|
const hy = toHalfFloat(cBy) & 65535;
|
|
24897
24860
|
tA[idx + 3] = hx | hy << 16;
|
|
@@ -42363,7 +42326,7 @@ class PostProcessingComponent extends ComponentBase {
|
|
|
42363
42326
|
}
|
|
42364
42327
|
}
|
|
42365
42328
|
|
|
42366
|
-
const version = "1.0.
|
|
42329
|
+
const version = "1.0.46";
|
|
42367
42330
|
|
|
42368
42331
|
class Engine3D {
|
|
42369
42332
|
/**
|
|
@@ -54626,7 +54589,7 @@ let GSplatStreamRenderer = class extends RenderNode {
|
|
|
54626
54589
|
_transformAData;
|
|
54627
54590
|
// RGBA32U: count * 4
|
|
54628
54591
|
_transformBData;
|
|
54629
|
-
// RGBA16F: count * 4
|
|
54592
|
+
// RGBA16F: count * 4 (Float16 format)
|
|
54630
54593
|
_orderData;
|
|
54631
54594
|
// R32U: size.x * size.y
|
|
54632
54595
|
_positions;
|
|
@@ -54684,7 +54647,8 @@ let GSplatStreamRenderer = class extends RenderNode {
|
|
|
54684
54647
|
this._colorData.fill(0);
|
|
54685
54648
|
this._transformAData = new Uint32Array(total * 4);
|
|
54686
54649
|
this._transformAData.fill(0);
|
|
54687
|
-
this._transformBData = new
|
|
54650
|
+
this._transformBData = new Uint16Array(total * 4);
|
|
54651
|
+
this._transformBData.fill(0);
|
|
54688
54652
|
this._orderData = new Uint32Array(total);
|
|
54689
54653
|
for (let i = 0; i < total; i++) {
|
|
54690
54654
|
this._orderData[i] = i < totalCount ? i : totalCount > 0 ? totalCount - 1 : 0;
|
|
@@ -54834,10 +54798,10 @@ let GSplatStreamRenderer = class extends RenderNode {
|
|
|
54834
54798
|
const cBy = r01 * r02 + r11 * r12 + r21 * r22;
|
|
54835
54799
|
const cBz = r02 * r02 + r12 * r12 + r22 * r22;
|
|
54836
54800
|
const bidx = idx;
|
|
54837
|
-
this._transformBData[bidx + 0] = cAx;
|
|
54838
|
-
this._transformBData[bidx + 1] = cAy;
|
|
54839
|
-
this._transformBData[bidx + 2] = cAz;
|
|
54840
|
-
this._transformBData[bidx + 3] = cBz;
|
|
54801
|
+
this._transformBData[bidx + 0] = toHalfFloat(cAx) & 65535;
|
|
54802
|
+
this._transformBData[bidx + 1] = toHalfFloat(cAy) & 65535;
|
|
54803
|
+
this._transformBData[bidx + 2] = toHalfFloat(cAz) & 65535;
|
|
54804
|
+
this._transformBData[bidx + 3] = toHalfFloat(cBz) & 65535;
|
|
54841
54805
|
const hx = toHalfFloat(cBx) & 65535;
|
|
54842
54806
|
const hy = toHalfFloat(cBy) & 65535;
|
|
54843
54807
|
this._transformAData[idx + 3] = hx | hy << 16;
|
|
@@ -66402,6 +66366,7 @@ class TilesRenderer {
|
|
|
66402
66366
|
toggleTime: 0,
|
|
66403
66367
|
queueProcessTime: 0
|
|
66404
66368
|
};
|
|
66369
|
+
transCdnUrlFunc = null;
|
|
66405
66370
|
constructor(url = null) {
|
|
66406
66371
|
this.rootURL = url;
|
|
66407
66372
|
this.lruCache = new LRUCache();
|
|
@@ -66850,7 +66815,7 @@ class TilesRenderer {
|
|
|
66850
66815
|
return parts.length > 1 ? parts[parts.length - 1] : "";
|
|
66851
66816
|
};
|
|
66852
66817
|
const extension = getUrlExtension(uri);
|
|
66853
|
-
const fullUrl = url;
|
|
66818
|
+
const fullUrl = this.transCdnUrlFunc ? this.transCdnUrlFunc(url) : url;
|
|
66854
66819
|
let scene = null;
|
|
66855
66820
|
const loader = new FileLoader();
|
|
66856
66821
|
switch (extension.toLowerCase()) {
|
|
@@ -71924,14 +71889,19 @@ class SolidColorSky extends LDRTextureCube {
|
|
|
71924
71889
|
this.color.b,
|
|
71925
71890
|
this.color.a
|
|
71926
71891
|
);
|
|
71927
|
-
|
|
71892
|
+
const float16Data = new Uint16Array(numbers.length);
|
|
71893
|
+
for (let i = 0; i < numbers.length; i++) {
|
|
71894
|
+
float16Data[i] = toHalfFloat(numbers[i]) & 65535;
|
|
71895
|
+
}
|
|
71896
|
+
this._internalTexture.create(this._minSize, this._minSize, float16Data, false);
|
|
71928
71897
|
this.createFromTexture(this._minSize, this._internalTexture);
|
|
71929
71898
|
return this;
|
|
71930
71899
|
}
|
|
71931
71900
|
changeColor(color) {
|
|
71932
71901
|
this._skyColor = color;
|
|
71902
|
+
const numbers = [];
|
|
71933
71903
|
Engine3D.res.fillColor(
|
|
71934
|
-
|
|
71904
|
+
numbers,
|
|
71935
71905
|
this._minSize,
|
|
71936
71906
|
this._minSize,
|
|
71937
71907
|
this.color.r,
|
|
@@ -71939,10 +71909,14 @@ class SolidColorSky extends LDRTextureCube {
|
|
|
71939
71909
|
this.color.b,
|
|
71940
71910
|
this.color.a
|
|
71941
71911
|
);
|
|
71912
|
+
const float16Data = new Uint16Array(numbers.length);
|
|
71913
|
+
for (let i = 0; i < numbers.length; i++) {
|
|
71914
|
+
float16Data[i] = toHalfFloat(numbers[i]) & 65535;
|
|
71915
|
+
}
|
|
71942
71916
|
this._internalTexture.updateTexture(
|
|
71943
71917
|
this._minSize,
|
|
71944
71918
|
this._minSize,
|
|
71945
|
-
|
|
71919
|
+
float16Data,
|
|
71946
71920
|
false
|
|
71947
71921
|
);
|
|
71948
71922
|
this._faceData.uploadTexture(0, this._internalTexture);
|