@jdultra/threedtiles 14.0.3 → 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: !1, 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) {
@@ -9303,7 +9307,6 @@ void getVertexData(out vec3 position, out mat3 covariance) {
9303
9307
 
9304
9308
  highp uint uOrder = order; // Use a local uint copy
9305
9309
 
9306
- // It's good practice to ensure textureSize is treated as uint for these calcs
9307
9310
  uint uTextureSize = uint(textureSize); // textureSize uniform is float
9308
9311
  uint uPixelsPerSlice = uTextureSize * uTextureSize;
9309
9312
 
@@ -9432,7 +9435,10 @@ void main() {
9432
9435
 
9433
9436
 
9434
9437
  splatPositionWorld = (modelMatrix * vec4(splatPositionModel, 1.0)).xyz;
9435
- 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;
9436
9442
 
9437
9443
  if(culling){
9438
9444
  float clip = 1.2 * splatPositionProjected.w;
@@ -9454,15 +9460,12 @@ void main() {
9454
9460
 
9455
9461
  gl_Position = outPosition;
9456
9462
  viewZW = outPosition.zw;
9457
- /* if(computeLinearDepth){
9458
- orthographicDepth = viewZToOrthographicDepth( -gl_Position.w, cameraNear, cameraFar );
9459
- } */
9460
9463
 
9461
- #if defined( USE_LOGDEPTHBUF )
9464
+ #if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
9462
9465
  float isPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
9463
- 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;
9464
9467
  #else
9465
- splatDepth = (splatPositionProjected.z / splatPositionProjected.w)* 0.5 + 0.5;
9468
+ splatDepth = (splatPositionProjectedWithBias.z / splatPositionProjectedWithBias.w)* 0.5 + 0.5;
9466
9469
  #endif
9467
9470
 
9468
9471
 
@@ -9497,7 +9500,6 @@ void main() {
9497
9500
  float alpha = color.w * exp(-beta_k * rk);
9498
9501
 
9499
9502
  fragColor = vec4(pow(color.xyz,vec3(1.0/2.2)), alpha);
9500
-
9501
9503
  gl_FragDepth = splatDepth;
9502
9504
 
9503
9505
  }`;
@@ -9598,6 +9600,9 @@ class me extends P.Object3D {
9598
9600
  setSplatsCropRadius(A) {
9599
9601
  this.splatsCropRadius = A, this.splatsMesh && this.splatsMesh.setSplatsCropRadius(this.splatsCropRadius);
9600
9602
  }
9603
+ setSplatsDepthBias(A) {
9604
+ this.splatsDepthBias = A, this.splatsMesh && this.splatsMesh.setDepthBias(this.splatsDepthBias);
9605
+ }
9601
9606
  setSplatsCPUCulling(A) {
9602
9607
  this.splatsCPUCulling = A, this.splatsMesh && this.splatsMesh.setSplatsCPUCulling(A);
9603
9608
  }