@rings-webgpu/core 1.0.37 → 1.0.38

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.
@@ -54367,7 +54367,41 @@ fn frag(){
54367
54367
  // Splat count and texture dimensions
54368
54368
  totalCount = 0;
54369
54369
  size = new Vector2();
54370
- worldBoundBox = new BoundingBox();
54370
+ localBoundBox = new BoundingBox();
54371
+ // public worldBoundBox: BoundingBox = new BoundingBox();
54372
+ get worldBoundBox() {
54373
+ const boundBox = new BoundingBox();
54374
+ boundBox.makeEmpty();
54375
+ const worldMatrix = this.object3D.transform.worldMatrix;
54376
+ const m = worldMatrix.rawData;
54377
+ const localMin = this.localBoundBox.min;
54378
+ const localMax = this.localBoundBox.max;
54379
+ const corners = [
54380
+ [localMin.x, localMin.y, localMin.z],
54381
+ // 0: min, min, min
54382
+ [localMax.x, localMin.y, localMin.z],
54383
+ // 1: max, min, min
54384
+ [localMin.x, localMax.y, localMin.z],
54385
+ // 2: min, max, min
54386
+ [localMax.x, localMax.y, localMin.z],
54387
+ // 3: max, max, min
54388
+ [localMin.x, localMin.y, localMax.z],
54389
+ // 4: min, min, max
54390
+ [localMax.x, localMin.y, localMax.z],
54391
+ // 5: max, min, max
54392
+ [localMin.x, localMax.y, localMax.z],
54393
+ // 6: min, max, max
54394
+ [localMax.x, localMax.y, localMax.z]
54395
+ // 7: max, max, max
54396
+ ];
54397
+ for (const [x, y, z] of corners) {
54398
+ const wx = m[0] * x + m[4] * y + m[8] * z + m[12];
54399
+ const wy = m[1] * x + m[5] * y + m[9] * z + m[13];
54400
+ const wz = m[2] * x + m[6] * y + m[10] * z + m[14];
54401
+ boundBox.expandByPoint(new Vector3(wx, wy, wz));
54402
+ }
54403
+ return boundBox;
54404
+ }
54371
54405
  // GPU textures for splat data
54372
54406
  splatColor;
54373
54407
  transformA;
@@ -54388,8 +54422,7 @@ fn frag(){
54388
54422
  // R32U: size.x * size.y
54389
54423
  _positions;
54390
54424
  // xyz per splat (local space)
54391
- _worldPositions;
54392
- // xyz per splat (world space, cached)
54425
+ // private _worldPositions: Float32Array; // xyz per splat (world space, cached)
54393
54426
  // Tracking which splats have been set
54394
54427
  _splatSetFlags;
54395
54428
  // Track which indices have data
@@ -54449,8 +54482,7 @@ fn frag(){
54449
54482
  }
54450
54483
  this._positions = new Float32Array(totalCount * 3);
54451
54484
  this._positions.fill(0);
54452
- this._worldPositions = new Float32Array(totalCount * 3);
54453
- this._worldPositions.fill(0);
54485
+ this.localBoundBox.makeEmpty();
54454
54486
  this._splatSetFlags = new Array(totalCount).fill(false);
54455
54487
  this._validCount = 0;
54456
54488
  this.texParams = new Float32Array([this._validCount, this.size.x, 0, 1]);
@@ -54499,6 +54531,7 @@ fn frag(){
54499
54531
  this._positions[index * 3 + 0] = data.position[0];
54500
54532
  this._positions[index * 3 + 1] = data.position[1];
54501
54533
  this._positions[index * 3 + 2] = data.position[2];
54534
+ this.localBoundBox.expandByPoint(new Vector3(data.position[0], data.position[1], data.position[2]));
54502
54535
  const SH_C0 = 0.28209479177387814;
54503
54536
  let r = 0.5, g = 0.5, b = 0.5;
54504
54537
  if (data.sh && data.sh.coeffs && data.sh.coeffs.length >= 3) {
@@ -54517,7 +54550,6 @@ fn frag(){
54517
54550
  this._splatSetFlags[index] = true;
54518
54551
  this._validCount++;
54519
54552
  this.texParams[2] = this._validCount;
54520
- this._centersSent = false;
54521
54553
  }
54522
54554
  this._pendingUpdates.add(index);
54523
54555
  }
@@ -54650,43 +54682,10 @@ fn frag(){
54650
54682
  */
54651
54683
  updateWorldPositions() {
54652
54684
  if (!this._positions || this._validCount === 0) return;
54653
- const worldMatrix = this.object3D.transform.worldMatrix;
54654
- const localPos = this._positions;
54655
- const count = this._validCount;
54656
- const m = worldMatrix.rawData;
54657
- this.worldBoundBox.makeEmpty();
54658
- for (let i = 0; i < count; i++) {
54659
- if (!this._splatSetFlags[i]) continue;
54660
- const idx = i * 3;
54661
- const x = localPos[idx + 0];
54662
- const y = localPos[idx + 1];
54663
- const z = localPos[idx + 2];
54664
- this._worldPositions[idx + 0] = m[0] * x + m[4] * y + m[8] * z + m[12];
54665
- this._worldPositions[idx + 1] = m[1] * x + m[5] * y + m[9] * z + m[13];
54666
- this._worldPositions[idx + 2] = m[2] * x + m[6] * y + m[10] * z + m[14];
54667
- this.worldBoundBox.expandByPoint(new Vector3(this._worldPositions[idx + 0], this._worldPositions[idx + 1], this._worldPositions[idx + 2]));
54668
- }
54669
54685
  this._centersSent = false;
54670
54686
  }
54671
54687
  updatePendingWorldPositions() {
54672
54688
  if (!this._positions || this._validCount === 0) return;
54673
- const worldMatrix = this.object3D.transform.worldMatrix;
54674
- const localPos = this._positions;
54675
- this._validCount;
54676
- const m = worldMatrix.rawData;
54677
- const pendingUpdates = Array.from(this._pendingUpdates.values());
54678
- for (let i = 0; i < pendingUpdates.length; i++) {
54679
- const ii = pendingUpdates[i];
54680
- if (!this._splatSetFlags[ii]) continue;
54681
- const idx = ii * 3;
54682
- const x = localPos[idx + 0];
54683
- const y = localPos[idx + 1];
54684
- const z = localPos[idx + 2];
54685
- this._worldPositions[idx + 0] = m[0] * x + m[4] * y + m[8] * z + m[12];
54686
- this._worldPositions[idx + 1] = m[1] * x + m[5] * y + m[9] * z + m[13];
54687
- this._worldPositions[idx + 2] = m[2] * x + m[6] * y + m[10] * z + m[14];
54688
- this.worldBoundBox.expandByPoint(new Vector3(this._worldPositions[idx + 0], this._worldPositions[idx + 1], this._worldPositions[idx + 2]));
54689
- }
54690
54689
  this._centersSent = false;
54691
54690
  }
54692
54691
  /**
@@ -54696,7 +54695,7 @@ fn frag(){
54696
54695
  scheduleOrder(viewMatrix) {
54697
54696
  if (this._validCount === 0) return;
54698
54697
  const transformChanged = this.object3D.transform.localChange;
54699
- if (transformChanged || !this._worldPositions || this._worldPositions.length === 0) {
54698
+ if (transformChanged) {
54700
54699
  this.updateWorldPositions();
54701
54700
  }
54702
54701
  const r = viewMatrix.rawData;
@@ -54758,14 +54757,19 @@ fn frag(){
54758
54757
  this.instanceCount = newInstanceCount;
54759
54758
  };
54760
54759
  const centers = new Float32Array(this._validCount * 3);
54761
- const worldPos = this._worldPositions || this._positions;
54762
54760
  let centerIdx = 0;
54761
+ const worldMatrix = this.object3D.transform.worldMatrix;
54762
+ const localPos = this._positions;
54763
+ const m = worldMatrix.rawData;
54763
54764
  for (let i = 0; i < this._validCount; i++) {
54764
54765
  if (this._splatSetFlags[i]) {
54765
54766
  const srcIdx = i * 3;
54766
- centers[centerIdx * 3 + 0] = worldPos[srcIdx + 0];
54767
- centers[centerIdx * 3 + 1] = worldPos[srcIdx + 1];
54768
- centers[centerIdx * 3 + 2] = worldPos[srcIdx + 2];
54767
+ const x = localPos[srcIdx + 0];
54768
+ const y = localPos[srcIdx + 1];
54769
+ const z = localPos[srcIdx + 2];
54770
+ centers[centerIdx * 3 + 0] = m[0] * x + m[4] * y + m[8] * z + m[12];
54771
+ centers[centerIdx * 3 + 1] = m[1] * x + m[5] * y + m[9] * z + m[13];
54772
+ centers[centerIdx * 3 + 2] = m[2] * x + m[6] * y + m[10] * z + m[14];
54769
54773
  centerIdx++;
54770
54774
  }
54771
54775
  }
@@ -54781,14 +54785,19 @@ fn frag(){
54781
54785
  }
54782
54786
  if (!this._centersSent && this._sortWorker) {
54783
54787
  const centers = new Float32Array(this._validCount * 3);
54784
- const worldPos = this._worldPositions || this._positions;
54785
54788
  let centerIdx = 0;
54789
+ const worldMatrix = this.object3D.transform.worldMatrix;
54790
+ const localPos = this._positions;
54791
+ const m = worldMatrix.rawData;
54786
54792
  for (let i = 0; i < this._validCount; i++) {
54787
54793
  if (this._splatSetFlags[i]) {
54788
54794
  const srcIdx = i * 3;
54789
- centers[centerIdx * 3 + 0] = worldPos[srcIdx + 0];
54790
- centers[centerIdx * 3 + 1] = worldPos[srcIdx + 1];
54791
- centers[centerIdx * 3 + 2] = worldPos[srcIdx + 2];
54795
+ const x = localPos[srcIdx + 0];
54796
+ const y = localPos[srcIdx + 1];
54797
+ const z = localPos[srcIdx + 2];
54798
+ centers[centerIdx * 3 + 0] = m[0] * x + m[4] * y + m[8] * z + m[12];
54799
+ centers[centerIdx * 3 + 1] = m[1] * x + m[5] * y + m[9] * z + m[13];
54800
+ centers[centerIdx * 3 + 2] = m[2] * x + m[6] * y + m[10] * z + m[14];
54792
54801
  centerIdx++;
54793
54802
  }
54794
54803
  }
@@ -55101,7 +55110,6 @@ fn frag(){
55101
55110
  this.splatOrder = null;
55102
55111
  }
55103
55112
  this._positions = null;
55104
- this._worldPositions = null;
55105
55113
  this._orderData = null;
55106
55114
  this._colorData = null;
55107
55115
  this._transformAData = null;
@@ -29,7 +29,8 @@ export type SplatData = {
29
29
  export declare class GSplatStreamRenderer extends RenderNode {
30
30
  totalCount: number;
31
31
  size: Vector2;
32
- worldBoundBox: BoundingBox;
32
+ localBoundBox: BoundingBox;
33
+ get worldBoundBox(): BoundingBox;
33
34
  splatColor: Uint8ArrayTexture;
34
35
  transformA: Uint32ArrayTexture;
35
36
  transformB: Float16ArrayTexture;
@@ -41,7 +42,6 @@ export declare class GSplatStreamRenderer extends RenderNode {
41
42
  private _transformBData;
42
43
  private _orderData;
43
44
  private _positions;
44
- private _worldPositions;
45
45
  private _splatSetFlags;
46
46
  private _validCount;
47
47
  private _sortWorker;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rings-webgpu/core",
3
- "version": "1.0.37",
3
+ "version": "1.0.38",
4
4
  "description": "Rings webgpu Engine",
5
5
  "main": "index.js",
6
6
  "exports": {