@jdultra/threedtiles 14.0.4 → 14.0.5

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();
@@ -9296,6 +9299,7 @@ uniform float minOpacity;
9296
9299
  uniform bool culling;
9297
9300
  uniform float antialiasingFactor;
9298
9301
  uniform float cropRadius;
9302
+ uniform float depthBias; // depth bias in meters
9299
9303
 
9300
9304
 
9301
9305
  void getVertexData(out vec3 position, out mat3 covariance) {
@@ -9431,7 +9435,10 @@ void main() {
9431
9435
 
9432
9436
 
9433
9437
  splatPositionWorld = (modelMatrix * vec4(splatPositionModel, 1.0)).xyz;
9434
- vec4 splatPositionProjected = projectionMatrix * viewMatrix * vec4(splatPositionWorld, 1.0);
9438
+ vec4 splatProjectionView = viewMatrix * vec4(splatPositionWorld, 1.0);
9439
+ vec4 splatPositionProjected = projectionMatrix * splatProjectionView;
9440
+ splatProjectionView.z += depthBias;
9441
+ vec4 splatPositionProjectedWithBias = projectionMatrix * splatProjectionView;
9435
9442
 
9436
9443
  if(culling){
9437
9444
  float clip = 1.2 * splatPositionProjected.w;
@@ -9456,9 +9463,9 @@ void main() {
9456
9463
 
9457
9464
  #if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
9458
9465
  float isPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
9459
- splatDepth = isPerspective == 0.0 ? splatPositionProjected.z : log2( 1.0 + splatPositionProjected.w ) * logDepthBufFC * 0.5;
9466
+ splatDepth = isPerspective == 0.0 ? splatPositionProjectedWithBias.z : log2( 1.0 + splatPositionProjectedWithBias.w ) * logDepthBufFC * 0.5;
9460
9467
  #else
9461
- splatDepth = (splatPositionProjected.z / splatPositionProjected.w)* 0.5 + 0.5;
9468
+ splatDepth = (splatPositionProjectedWithBias.z / splatPositionProjectedWithBias.w)* 0.5 + 0.5;
9462
9469
  #endif
9463
9470
 
9464
9471
 
@@ -9593,6 +9600,9 @@ class me extends P.Object3D {
9593
9600
  setSplatsCropRadius(A) {
9594
9601
  this.splatsCropRadius = A, this.splatsMesh && this.splatsMesh.setSplatsCropRadius(this.splatsCropRadius);
9595
9602
  }
9603
+ setSplatsDepthBias(A) {
9604
+ this.splatsDepthBias = A, this.splatsMesh && this.splatsMesh.setDepthBias(this.splatsDepthBias);
9605
+ }
9596
9606
  setSplatsCPUCulling(A) {
9597
9607
  this.splatsCPUCulling = A, this.splatsMesh && this.splatsMesh.setSplatsCPUCulling(A);
9598
9608
  }