@jdultra/threedtiles 14.0.4 → 14.0.6

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.
@@ -9113,7 +9113,7 @@ class zn extends OQ {
9113
9113
  a.texture.type = kg, a.texture.format = Ng, a.texture.internalFormat = "RGBA32UI", A.initRenderTarget(a);
9114
9114
  const i = new uB(1024, 1024, 1, { magFilter: gg, minFilter: gg, anisotropy: 0, type: kg, format: Ng, depthBuffer: !1, resolveDepthBuffer: !1 });
9115
9115
  i.texture.type = kg, i.texture.format = Ng, i.texture.internalFormat = "RGBA32UI", A.initRenderTarget(i);
9116
- const t = new cQ({ glslVersion: hQ, uniforms: { textureSize: { value: 1024 }, numSlices: { value: 1 }, covarianceTexture: { value: i.texture }, positionColorTexture: { value: a.texture }, zUpToYUpMatrix3x3: { value: Ue }, sizeMultiplier: { value: 1 }, cropRadius: { value: Number.MAX_VALUE }, viewportPixelSize: { value: new sC() }, k: { value: 2 }, beta_k: { value: 2 }, minSplatPixelSize: { value: 0 }, minOpacity: { value: 0.01 }, culling: { value: !1 }, antialiasingFactor: { value: 2 } }, vertexShader: Xn(), fragmentShader: I || Zn(), transparent: !0, side: UB, depthTest: !0, depthWrite: !1, blending: Mi }), e = new YC(), o = new Float32Array([-0.5, 0.5, 0, 0.5, 0.5, 0, -0.5, -0.5, 0, 0.5, -0.5, 0]);
9116
+ const t = new cQ({ glslVersion: hQ, uniforms: { textureSize: { value: 1024 }, numSlices: { value: 1 }, covarianceTexture: { value: i.texture }, positionColorTexture: { value: a.texture }, zUpToYUpMatrix3x3: { value: Ue }, sizeMultiplier: { value: 1 }, cropRadius: { value: Number.MAX_VALUE }, viewportPixelSize: { value: new sC() }, k: { value: 2 }, beta_k: { value: 2 }, minSplatPixelSize: { value: 0 }, minOpacity: { value: 0.01 }, culling: { value: !1 }, antialiasingFactor: { value: 2 }, depthBias: { value: 0 } }, vertexShader: Xn(), fragmentShader: I || Zn(), transparent: !0, side: UB, depthTest: !0, depthWrite: !1, blending: Mi }), e = new YC(), o = new Float32Array([-0.5, 0.5, 0, 0.5, 0.5, 0, -0.5, -0.5, 0, 0.5, -0.5, 0]);
9117
9117
  e.setIndex([0, 2, 1, 2, 3, 1]), e.setAttribute("position", new aI(o, 3));
9118
9118
  const s = new Uint32Array(E), n = new vQ(s, 1, !1);
9119
9119
  n.needsUpdate = !0, n.setUsage(HC), e.setAttribute("order", n), e.instanceCount = 0, super(e, t), this.matrixAutoUpdate = !1, this.numBatches = 0, this.numVisibleBatches = 0, this.orderAttribute = n, this.textureSize = 1024, this.numTextures = 1, this.batchSize = C, this.maxSplats = E, this.numSplatsRendered = 0, this.positionColorRenderTarget = a, this.covarianceRenderTarget = i, this.renderer = A, this.sortID = 0, this.freeAddresses = new tB();
@@ -9165,6 +9165,9 @@ void main() {
9165
9165
  setSplatsCPUCulling(A) {
9166
9166
  this.splatsCPUCuling = A, this.material.uniforms.culling.value = A;
9167
9167
  }
9168
+ setDepthBias(A) {
9169
+ this.depthBias = A, this.material.uniforms.depthBias.value = this.depthBias;
9170
+ }
9168
9171
  updateShaderParams(A) {
9169
9172
  A.projectionMatrix.elements, this.renderer.getSize(this.material.uniforms.viewportPixelSize.value);
9170
9173
  const g = this.renderer.getPixelRatio();
@@ -9282,6 +9285,7 @@ out vec2 vUv;
9282
9285
  out vec3 splatPositionWorld;
9283
9286
  out vec3 splatPositionModel;
9284
9287
  out float splatDepth;
9288
+ out float splatDepthWithBias;
9285
9289
  out float stds;
9286
9290
  out vec2 viewZW;
9287
9291
  uniform highp usampler3D positionColorTexture;
@@ -9296,6 +9300,7 @@ uniform float minOpacity;
9296
9300
  uniform bool culling;
9297
9301
  uniform float antialiasingFactor;
9298
9302
  uniform float cropRadius;
9303
+ uniform float depthBias; // depth bias in meters
9299
9304
 
9300
9305
 
9301
9306
  void getVertexData(out vec3 position, out mat3 covariance) {
@@ -9431,7 +9436,10 @@ void main() {
9431
9436
 
9432
9437
 
9433
9438
  splatPositionWorld = (modelMatrix * vec4(splatPositionModel, 1.0)).xyz;
9434
- vec4 splatPositionProjected = projectionMatrix * viewMatrix * vec4(splatPositionWorld, 1.0);
9439
+ vec4 splatProjectionView = viewMatrix * vec4(splatPositionWorld, 1.0);
9440
+ vec4 splatPositionProjected = projectionMatrix * splatProjectionView;
9441
+ splatProjectionView.z += depthBias;
9442
+ vec4 splatPositionProjectedWithBias = projectionMatrix * splatProjectionView;
9435
9443
 
9436
9444
  if(culling){
9437
9445
  float clip = 1.2 * splatPositionProjected.w;
@@ -9456,8 +9464,10 @@ void main() {
9456
9464
 
9457
9465
  #if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
9458
9466
  float isPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
9467
+ splatDepthWithBias = isPerspective == 0.0 ? splatPositionProjectedWithBias.z : log2( 1.0 + splatPositionProjectedWithBias.w ) * logDepthBufFC * 0.5;
9459
9468
  splatDepth = isPerspective == 0.0 ? splatPositionProjected.z : log2( 1.0 + splatPositionProjected.w ) * logDepthBufFC * 0.5;
9460
9469
  #else
9470
+ splatDepthWithBias = (splatPositionProjectedWithBias.z / splatPositionProjectedWithBias.w)* 0.5 + 0.5;
9461
9471
  splatDepth = (splatPositionProjected.z / splatPositionProjected.w)* 0.5 + 0.5;
9462
9472
  #endif
9463
9473
 
@@ -9476,6 +9486,7 @@ in vec2 vUv;
9476
9486
  in vec3 splatPositionModel;
9477
9487
  in vec3 splatPositionWorld;
9478
9488
  in float splatDepth;
9489
+ in float splatDepthWithBias;
9479
9490
 
9480
9491
  layout(location = 0) out vec4 fragColor;
9481
9492
 
@@ -9493,7 +9504,7 @@ void main() {
9493
9504
  float alpha = color.w * exp(-beta_k * rk);
9494
9505
 
9495
9506
  fragColor = vec4(pow(color.xyz,vec3(1.0/2.2)), alpha);
9496
- gl_FragDepth = splatDepth;
9507
+ gl_FragDepth = splatDepthWithBias;
9497
9508
 
9498
9509
  }`;
9499
9510
  }
@@ -9593,6 +9604,9 @@ class me extends P.Object3D {
9593
9604
  setSplatsCropRadius(A) {
9594
9605
  this.splatsCropRadius = A, this.splatsMesh && this.splatsMesh.setSplatsCropRadius(this.splatsCropRadius);
9595
9606
  }
9607
+ setSplatsDepthBias(A) {
9608
+ this.splatsDepthBias = A, this.splatsMesh && this.splatsMesh.setDepthBias(this.splatsDepthBias);
9609
+ }
9596
9610
  setSplatsCPUCulling(A) {
9597
9611
  this.splatsCPUCulling = A, this.splatsMesh && this.splatsMesh.setSplatsCPUCulling(A);
9598
9612
  }