@xeokit/xeokit-sdk 2.0.0-beta.21 → 2.0.0-beta.25

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.
@@ -15886,6 +15886,7 @@ const Renderer = function (scene, options) {
15886
15886
  const tempMat4a = math.mat4();
15887
15887
  const tempMat4b = math.mat4();
15888
15888
 
15889
+ const randomVec3 = math.vec3();
15889
15890
  const up = math.vec3([0, 1, 0]);
15890
15891
  const _pickResult = new PickResult();
15891
15892
 
@@ -15950,6 +15951,13 @@ const Renderer = function (scene, options) {
15950
15951
 
15951
15952
  look = math.addVec3(worldRayOrigin, worldRayDir, tempVec3a);
15952
15953
 
15954
+ randomVec3[0] = Math.random();
15955
+ randomVec3[1] = Math.random();
15956
+ randomVec3[2] = Math.random();
15957
+
15958
+ math.normalizeVec3(randomVec3);
15959
+ math.cross3Vec3(worldRayDir, randomVec3, up);
15960
+
15953
15961
  pickViewMatrix = math.lookAtMat4v(worldRayOrigin, look, up, tempMat4b);
15954
15962
  pickProjMatrix = pickFrustumMatrix;
15955
15963
 
@@ -27543,6 +27551,7 @@ class Scene extends Component {
27543
27551
  /**
27544
27552
  * @private
27545
27553
  */
27554
+
27546
27555
  const DrawShaderSource = function (mesh) {
27547
27556
  if (mesh._material._state.type === "LambertMaterial") {
27548
27557
  this.vertex = buildVertexLambert(mesh);
@@ -27631,7 +27640,13 @@ function buildVertexLambert(mesh) {
27631
27640
  }
27632
27641
  if (scene.logarithmicDepthBufferEnabled) {
27633
27642
  src.push("uniform float logDepthBufFC;");
27634
- src.push("varying float vFragDepth;");
27643
+ if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
27644
+ src.push("varying float vFragDepth;");
27645
+ }
27646
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
27647
+ src.push(" return (m[2][3] == - 1.0);");
27648
+ src.push("}");
27649
+ src.push("varying float isPerspective;");
27635
27650
  }
27636
27651
  if (clipping) {
27637
27652
  src.push("varying vec4 vWorldPosition;");
@@ -27774,7 +27789,13 @@ function buildVertexLambert(mesh) {
27774
27789
  }
27775
27790
  src.push("vec4 clipPos = projMatrix * viewPosition;");
27776
27791
  if (scene.logarithmicDepthBufferEnabled) {
27777
- src.push("vFragDepth = 1.0 + clipPos.w;");
27792
+ if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
27793
+ src.push("vFragDepth = 1.0 + clipPos.w;");
27794
+ } else {
27795
+ src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
27796
+ src.push("clipPos.z *= clipPos.w;");
27797
+ }
27798
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
27778
27799
  }
27779
27800
  src.push("gl_Position = clipPos;");
27780
27801
  src.push("}");
@@ -27800,7 +27821,8 @@ function buildFragmentLambert(mesh) {
27800
27821
  src.push("precision mediump float;");
27801
27822
  src.push("precision mediump int;");
27802
27823
  src.push("#endif");
27803
- if (scene.logarithmicDepthBufferEnabled) {
27824
+ if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
27825
+ src.push("varying float isPerspective;");
27804
27826
  src.push("uniform float logDepthBufFC;");
27805
27827
  src.push("varying float vFragDepth;");
27806
27828
  }
@@ -27840,8 +27862,8 @@ function buildFragmentLambert(mesh) {
27840
27862
  src.push("}");
27841
27863
 
27842
27864
  }
27843
- if (scene.logarithmicDepthBufferEnabled) {
27844
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
27865
+ if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
27866
+ src.push("gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
27845
27867
  }
27846
27868
  if (gammaOutput) {
27847
27869
  src.push("gl_FragColor = linearToGamma(vColor, gammaFactor);");
@@ -27889,7 +27911,13 @@ function buildVertexDraw(mesh) {
27889
27911
  }
27890
27912
  if (scene.logarithmicDepthBufferEnabled) {
27891
27913
  src.push("uniform float logDepthBufFC;");
27892
- src.push("varying float vFragDepth;");
27914
+ if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
27915
+ src.push("varying float vFragDepth;");
27916
+ }
27917
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
27918
+ src.push(" return (m[2][3] == - 1.0);");
27919
+ src.push("}");
27920
+ src.push("varying float isPerspective;");
27893
27921
  }
27894
27922
  if (lightsState.lightMaps.length > 0) {
27895
27923
  src.push("varying vec3 vWorldNormal;");
@@ -28056,7 +28084,13 @@ function buildVertexDraw(mesh) {
28056
28084
  src.push(" vViewPosition = viewPosition.xyz;");
28057
28085
  src.push("vec4 clipPos = projMatrix * viewPosition;");
28058
28086
  if (scene.logarithmicDepthBufferEnabled) {
28059
- src.push("vFragDepth = 1.0 + clipPos.w;");
28087
+ if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
28088
+ src.push("vFragDepth = 1.0 + clipPos.w;");
28089
+ } else {
28090
+ src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
28091
+ src.push("clipPos.z *= clipPos.w;");
28092
+ }
28093
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
28060
28094
  }
28061
28095
  src.push("gl_Position = clipPos;");
28062
28096
  if (receivesShadow) {
@@ -28110,7 +28144,8 @@ function buildFragmentDraw(mesh) {
28110
28144
  src.push("precision mediump int;");
28111
28145
  src.push("#endif");
28112
28146
 
28113
- if (scene.logarithmicDepthBufferEnabled) {
28147
+ if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
28148
+ src.push("varying float isPerspective;");
28114
28149
  src.push("uniform float logDepthBufFC;");
28115
28150
  src.push("varying float vFragDepth;");
28116
28151
  }
@@ -29070,8 +29105,8 @@ function buildFragmentDraw(mesh) {
29070
29105
  src.push("gl_FragColor = linearToGamma(gl_FragColor, gammaFactor);");
29071
29106
  }
29072
29107
 
29073
- if (scene.logarithmicDepthBufferEnabled) {
29074
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
29108
+ if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
29109
+ src.push("gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
29075
29110
  }
29076
29111
 
29077
29112
  src.push("}");
@@ -30087,6 +30122,10 @@ function buildVertex$5(mesh) {
30087
30122
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
30088
30123
  src.push("varying float vFragDepth;");
30089
30124
  }
30125
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
30126
+ src.push(" return (m[2][3] == - 1.0);");
30127
+ src.push("}");
30128
+ src.push("varying float isPerspective;");
30090
30129
  }
30091
30130
  if (clipping) {
30092
30131
  src.push("varying vec4 vWorldPosition;");
@@ -30226,6 +30265,7 @@ function buildVertex$5(mesh) {
30226
30265
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
30227
30266
  src.push("clipPos.z *= clipPos.w;");
30228
30267
  }
30268
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
30229
30269
  }
30230
30270
  src.push("gl_Position = clipPos;");
30231
30271
  src.push("}");
@@ -30263,6 +30303,7 @@ function buildFragment$5(mesh) {
30263
30303
  src.push("#endif");
30264
30304
 
30265
30305
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
30306
+ src.push("varying float isPerspective;");
30266
30307
  src.push("uniform float logDepthBufFC;");
30267
30308
  src.push("varying float vFragDepth;");
30268
30309
  }
@@ -30303,7 +30344,7 @@ function buildFragment$5(mesh) {
30303
30344
  src.push("}");
30304
30345
  }
30305
30346
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
30306
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
30347
+ src.push("gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
30307
30348
  }
30308
30349
  if (gammaOutput) {
30309
30350
  src.push("gl_FragColor = linearToGamma(vColor, gammaFactor);");
@@ -30614,6 +30655,10 @@ function buildVertex$4(mesh) {
30614
30655
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
30615
30656
  src.push("varying float vFragDepth;");
30616
30657
  }
30658
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
30659
+ src.push(" return (m[2][3] == - 1.0);");
30660
+ src.push("}");
30661
+ src.push("varying float isPerspective;");
30617
30662
  }
30618
30663
  if (clipping) {
30619
30664
  src.push("varying vec4 vWorldPosition;");
@@ -30670,6 +30715,7 @@ function buildVertex$4(mesh) {
30670
30715
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
30671
30716
  src.push("clipPos.z *= clipPos.w;");
30672
30717
  }
30718
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
30673
30719
  }
30674
30720
  src.push("gl_Position = clipPos;");
30675
30721
  src.push("}");
@@ -30696,6 +30742,7 @@ function buildFragment$4(mesh) {
30696
30742
  src.push("precision mediump int;");
30697
30743
  src.push("#endif");
30698
30744
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
30745
+ src.push("varying float isPerspective;");
30699
30746
  src.push("uniform float logDepthBufFC;");
30700
30747
  src.push("varying float vFragDepth;");
30701
30748
  }
@@ -30728,7 +30775,7 @@ function buildFragment$4(mesh) {
30728
30775
  src.push("}");
30729
30776
  }
30730
30777
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
30731
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
30778
+ src.push("gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
30732
30779
  }
30733
30780
  if (gammaOutput) {
30734
30781
  src.push("gl_FragColor = linearToGamma(vColor, gammaFactor);");
@@ -31022,6 +31069,10 @@ function buildVertex$3(mesh) {
31022
31069
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
31023
31070
  src.push("varying float vFragDepth;");
31024
31071
  }
31072
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
31073
+ src.push(" return (m[2][3] == - 1.0);");
31074
+ src.push("}");
31075
+ src.push("varying float isPerspective;");
31025
31076
  }
31026
31077
  if (billboard === "spherical" || billboard === "cylindrical") {
31027
31078
  src.push("void billboard(inout mat4 mat) {");
@@ -31067,6 +31118,7 @@ function buildVertex$3(mesh) {
31067
31118
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
31068
31119
  src.push("clipPos.z *= clipPos.w;");
31069
31120
  }
31121
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
31070
31122
  }
31071
31123
  src.push("gl_Position = clipPos;");
31072
31124
  src.push("}");
@@ -31090,6 +31142,7 @@ function buildFragment$3(mesh) {
31090
31142
  src.push("precision mediump int;");
31091
31143
  src.push("#endif");
31092
31144
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
31145
+ src.push("varying float isPerspective;");
31093
31146
  src.push("uniform float logDepthBufFC;");
31094
31147
  src.push("varying float vFragDepth;");
31095
31148
  }
@@ -31116,7 +31169,7 @@ function buildFragment$3(mesh) {
31116
31169
  src.push("}");
31117
31170
  }
31118
31171
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
31119
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
31172
+ src.push("gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
31120
31173
  }
31121
31174
  src.push(" gl_FragColor = pickColor; ");
31122
31175
  src.push("}");
@@ -31363,6 +31416,10 @@ function buildVertex$2(mesh) {
31363
31416
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
31364
31417
  src.push("varying float vFragDepth;");
31365
31418
  }
31419
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
31420
+ src.push(" return (m[2][3] == - 1.0);");
31421
+ src.push("}");
31422
+ src.push("varying float isPerspective;");
31366
31423
  }
31367
31424
  src.push("varying vec4 vColor;");
31368
31425
  if (quantizedGeometry) {
@@ -31388,6 +31445,7 @@ function buildVertex$2(mesh) {
31388
31445
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
31389
31446
  src.push("clipPos.z *= clipPos.w;");
31390
31447
  }
31448
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
31391
31449
  }
31392
31450
  src.push("gl_Position = clipPos;");
31393
31451
  src.push("}");
@@ -31412,6 +31470,7 @@ function buildFragment$2(mesh) {
31412
31470
  src.push("#endif");
31413
31471
  src.push("varying vec4 vColor;");
31414
31472
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
31473
+ src.push("varying float isPerspective;");
31415
31474
  src.push("uniform float logDepthBufFC;");
31416
31475
  src.push("varying float vFragDepth;");
31417
31476
  }
@@ -31437,7 +31496,7 @@ function buildFragment$2(mesh) {
31437
31496
  src.push("}");
31438
31497
  }
31439
31498
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
31440
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
31499
+ src.push("gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
31441
31500
  }
31442
31501
  src.push(" gl_FragColor = vColor;");
31443
31502
  src.push("}");
@@ -31661,6 +31720,10 @@ function buildVertex$1(mesh) {
31661
31720
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
31662
31721
  src.push("varying float vFragDepth;");
31663
31722
  }
31723
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
31724
+ src.push(" return (m[2][3] == - 1.0);");
31725
+ src.push("}");
31726
+ src.push("varying float isPerspective;");
31664
31727
  }
31665
31728
  if (billboard === "spherical" || billboard === "cylindrical") {
31666
31729
  src.push("void billboard(inout mat4 mat) {");
@@ -31706,6 +31769,7 @@ function buildVertex$1(mesh) {
31706
31769
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
31707
31770
  src.push("clipPos.z *= clipPos.w;");
31708
31771
  }
31772
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
31709
31773
  }
31710
31774
  src.push("gl_Position = clipPos;");
31711
31775
  src.push("}");
@@ -31734,6 +31798,7 @@ function buildFragment$1(mesh) {
31734
31798
  src.push("#endif");
31735
31799
 
31736
31800
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
31801
+ src.push("varying float isPerspective;");
31737
31802
  src.push("uniform float logDepthBufFC;");
31738
31803
  src.push("varying float vFragDepth;");
31739
31804
  }
@@ -31765,7 +31830,7 @@ function buildFragment$1(mesh) {
31765
31830
  src.push(" gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0); ");
31766
31831
 
31767
31832
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
31768
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
31833
+ src.push("gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
31769
31834
  }
31770
31835
 
31771
31836
  src.push("}");
@@ -32665,6 +32730,7 @@ class Mesh extends Component {
32665
32730
  * @param {Number[]} [cfg.rotation=[0,0,0]] Local rotation, as Euler angles given in degrees, for each of the X, Y and Z axis.
32666
32731
  * @param {Number[]} [cfg.matrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]] Local modelling transform matrix. Overrides the position, scale and rotation parameters.
32667
32732
  * @param {Number[]} [cfg.offset=[0,0,0]] World-space 3D translation offset. Translates the Mesh in World space, after modelling transforms.
32733
+ * @param {Boolean} [cfg.occluder=true] Indicates if the Mesh is able to occlude {@link Marker}s.
32668
32734
  * @param {Boolean} [cfg.visible=true] Indicates if the Mesh is initially visible.
32669
32735
  * @param {Boolean} [cfg.culled=false] Indicates if the Mesh is initially culled from view.
32670
32736
  * @param {Boolean} [cfg.pickable=true] Indicates if the Mesh is initially pickable.
@@ -32707,6 +32773,7 @@ class Mesh extends Component {
32707
32773
  pickable: null,
32708
32774
  clippable: null,
32709
32775
  collidable: null,
32776
+ occluder: (cfg.occluder !== false),
32710
32777
  castsShadow: null,
32711
32778
  receivesShadow: null,
32712
32779
  xrayed: false,
@@ -32877,11 +32944,13 @@ class Mesh extends Component {
32877
32944
  this._putPickRenderers();
32878
32945
  this._pickMeshRenderer = PickMeshRenderer.get(this);
32879
32946
  }
32880
- const occlusionHash = this._makeOcclusionHash();
32881
- if (this._state.occlusionHash !== occlusionHash) {
32882
- this._state.occlusionHash = occlusionHash;
32883
- this._putOcclusionRenderer();
32884
- this._occlusionRenderer = OcclusionRenderer.get(this);
32947
+ if (this._state.occluder) {
32948
+ const occlusionHash = this._makeOcclusionHash();
32949
+ if (this._state.occlusionHash !== occlusionHash) {
32950
+ this._state.occlusionHash = occlusionHash;
32951
+ this._putOcclusionRenderer();
32952
+ this._occlusionRenderer = OcclusionRenderer.get(this);
32953
+ }
32885
32954
  }
32886
32955
  }
32887
32956
 
@@ -34288,7 +34357,7 @@ class Mesh extends Component {
34288
34357
 
34289
34358
  /** @private */
34290
34359
  drawOcclusion(frameCtx) {
34291
- if (this._occlusionRenderer || (this._occlusionRenderer = OcclusionRenderer.get(this))) {
34360
+ if (this._state.occluder && this._occlusionRenderer || (this._occlusionRenderer = OcclusionRenderer.get(this))) {
34292
34361
  this._occlusionRenderer.drawMesh(frameCtx, this);
34293
34362
  }
34294
34363
  }
@@ -40226,6 +40295,10 @@ class TrianglesBatchingColorRenderer {
40226
40295
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
40227
40296
  src.push("varying float vFragDepth;");
40228
40297
  }
40298
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
40299
+ src.push(" return (m[2][3] == - 1.0);");
40300
+ src.push("}");
40301
+ src.push("varying float isPerspective;");
40229
40302
  }
40230
40303
 
40231
40304
  src.push("uniform vec4 lightAmbient;");
@@ -40327,6 +40400,7 @@ class TrianglesBatchingColorRenderer {
40327
40400
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
40328
40401
  src.push("clipPos.z *= clipPos.w;");
40329
40402
  }
40403
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
40330
40404
  }
40331
40405
  if (clipping) {
40332
40406
  src.push("vWorldPosition = worldPosition;");
@@ -40357,6 +40431,7 @@ class TrianglesBatchingColorRenderer {
40357
40431
  src.push("#endif");
40358
40432
 
40359
40433
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
40434
+ src.push("varying float isPerspective;");
40360
40435
  src.push("uniform float logDepthBufFC;");
40361
40436
  src.push("varying float vFragDepth;");
40362
40437
  }
@@ -40402,7 +40477,7 @@ class TrianglesBatchingColorRenderer {
40402
40477
  }
40403
40478
 
40404
40479
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
40405
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
40480
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
40406
40481
  }
40407
40482
 
40408
40483
  if (this._withSAO) {
@@ -40677,7 +40752,6 @@ class TrianglesBatchingFlatColorRenderer {
40677
40752
  _buildVertexShader() {
40678
40753
  const scene = this._scene;
40679
40754
  const sectionPlanesState = scene._sectionPlanesState;
40680
- scene._lightsState;
40681
40755
  const clipping = sectionPlanesState.sectionPlanes.length > 0;
40682
40756
  const src = [];
40683
40757
 
@@ -40709,6 +40783,10 @@ class TrianglesBatchingFlatColorRenderer {
40709
40783
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
40710
40784
  src.push("varying float vFragDepth;");
40711
40785
  }
40786
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
40787
+ src.push(" return (m[2][3] == - 1.0);");
40788
+ src.push("}");
40789
+ src.push("varying float isPerspective;");
40712
40790
  }
40713
40791
 
40714
40792
  if (clipping) {
@@ -40744,6 +40822,7 @@ class TrianglesBatchingFlatColorRenderer {
40744
40822
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
40745
40823
  src.push("clipPos.z *= clipPos.w;");
40746
40824
  }
40825
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
40747
40826
  }
40748
40827
  if (clipping) {
40749
40828
  src.push("vWorldPosition = worldPosition;");
@@ -40776,6 +40855,7 @@ class TrianglesBatchingFlatColorRenderer {
40776
40855
  src.push("#endif");
40777
40856
 
40778
40857
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
40858
+ src.push("varying float isPerspective;");
40779
40859
  src.push("uniform float logDepthBufFC;");
40780
40860
  src.push("varying float vFragDepth;");
40781
40861
  }
@@ -40902,7 +40982,7 @@ class TrianglesBatchingFlatColorRenderer {
40902
40982
  }
40903
40983
 
40904
40984
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
40905
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
40985
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
40906
40986
  }
40907
40987
 
40908
40988
  src.push("}");
@@ -41132,6 +41212,10 @@ class TrianglesBatchingSilhouetteRenderer {
41132
41212
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
41133
41213
  src.push("varying float vFragDepth;");
41134
41214
  }
41215
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
41216
+ src.push(" return (m[2][3] == - 1.0);");
41217
+ src.push("}");
41218
+ src.push("varying float isPerspective;");
41135
41219
  }
41136
41220
 
41137
41221
  if (clipping) {
@@ -41165,6 +41249,7 @@ class TrianglesBatchingSilhouetteRenderer {
41165
41249
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
41166
41250
  src.push("clipPos.z *= clipPos.w;");
41167
41251
  }
41252
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
41168
41253
  }
41169
41254
  src.push("gl_Position = clipPos;");
41170
41255
  src.push("}");
@@ -41191,6 +41276,7 @@ class TrianglesBatchingSilhouetteRenderer {
41191
41276
  src.push("precision mediump int;");
41192
41277
  src.push("#endif");
41193
41278
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
41279
+ src.push("varying float isPerspective;");
41194
41280
  src.push("uniform float logDepthBufFC;");
41195
41281
  src.push("varying float vFragDepth;");
41196
41282
  }
@@ -41218,7 +41304,7 @@ class TrianglesBatchingSilhouetteRenderer {
41218
41304
  src.push("}");
41219
41305
  }
41220
41306
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
41221
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
41307
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
41222
41308
  }
41223
41309
  src.push("gl_FragColor = color;");
41224
41310
  src.push("}");
@@ -41444,6 +41530,10 @@ class TrianglesBatchingEdgesRenderer {
41444
41530
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
41445
41531
  src.push("varying float vFragDepth;");
41446
41532
  }
41533
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
41534
+ src.push(" return (m[2][3] == - 1.0);");
41535
+ src.push("}");
41536
+ src.push("varying float isPerspective;");
41447
41537
  }
41448
41538
 
41449
41539
  if (clipping) {
@@ -41481,6 +41571,7 @@ class TrianglesBatchingEdgesRenderer {
41481
41571
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
41482
41572
  src.push("clipPos.z *= clipPos.w;");
41483
41573
  }
41574
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
41484
41575
  }
41485
41576
  src.push("gl_Position = clipPos;");
41486
41577
  src.push("vColor = vec4(color.r, color.g, color.b, color.a);");
@@ -41506,6 +41597,7 @@ class TrianglesBatchingEdgesRenderer {
41506
41597
  src.push("precision mediump int;");
41507
41598
  src.push("#endif");
41508
41599
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
41600
+ src.push("varying float isPerspective;");
41509
41601
  src.push("uniform float logDepthBufFC;");
41510
41602
  src.push("varying float vFragDepth;");
41511
41603
  }
@@ -41533,7 +41625,7 @@ class TrianglesBatchingEdgesRenderer {
41533
41625
  src.push("}");
41534
41626
  }
41535
41627
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
41536
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
41628
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
41537
41629
  }
41538
41630
  src.push("gl_FragColor = vColor;");
41539
41631
  src.push("}");
@@ -41737,6 +41829,10 @@ class TrianglesBatchingEdgesColorRenderer {
41737
41829
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
41738
41830
  src.push("varying float vFragDepth;");
41739
41831
  }
41832
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
41833
+ src.push(" return (m[2][3] == - 1.0);");
41834
+ src.push("}");
41835
+ src.push("varying float isPerspective;");
41740
41836
  }
41741
41837
 
41742
41838
  if (clipping) {
@@ -41774,6 +41870,7 @@ class TrianglesBatchingEdgesColorRenderer {
41774
41870
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
41775
41871
  src.push("clipPos.z *= clipPos.w;");
41776
41872
  }
41873
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
41777
41874
  }
41778
41875
  src.push("gl_Position = clipPos;");
41779
41876
  //src.push("vColor = vec4(float(color.r-100.0) / 255.0, float(color.g-100.0) / 255.0, float(color.b-100.0) / 255.0, float(color.a) / 255.0);");
@@ -41800,6 +41897,7 @@ class TrianglesBatchingEdgesColorRenderer {
41800
41897
  src.push("precision mediump int;");
41801
41898
  src.push("#endif");
41802
41899
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
41900
+ src.push("varying float isPerspective;");
41803
41901
  src.push("uniform float logDepthBufFC;");
41804
41902
  src.push("varying float vFragDepth;");
41805
41903
  }
@@ -41827,7 +41925,7 @@ class TrianglesBatchingEdgesColorRenderer {
41827
41925
  src.push("}");
41828
41926
  }
41829
41927
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
41830
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
41928
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
41831
41929
  }
41832
41930
  src.push("gl_FragColor = vColor;");
41833
41931
  src.push("}");
@@ -42039,6 +42137,10 @@ class TrianglesBatchingPickMeshRenderer {
42039
42137
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
42040
42138
  src.push("varying float vFragDepth;");
42041
42139
  }
42140
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
42141
+ src.push(" return (m[2][3] == - 1.0);");
42142
+ src.push("}");
42143
+ src.push("varying float isPerspective;");
42042
42144
  }
42043
42145
 
42044
42146
  if (clipping) {
@@ -42075,6 +42177,7 @@ class TrianglesBatchingPickMeshRenderer {
42075
42177
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
42076
42178
  src.push("clipPos.z *= clipPos.w;");
42077
42179
  }
42180
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
42078
42181
  }
42079
42182
  src.push("gl_Position = clipPos;");
42080
42183
  src.push(" }");
@@ -42099,6 +42202,7 @@ class TrianglesBatchingPickMeshRenderer {
42099
42202
  src.push("precision mediump int;");
42100
42203
  src.push("#endif");
42101
42204
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
42205
+ src.push("varying float isPerspective;");
42102
42206
  src.push("uniform float logDepthBufFC;");
42103
42207
  src.push("varying float vFragDepth;");
42104
42208
  }
@@ -42126,7 +42230,7 @@ class TrianglesBatchingPickMeshRenderer {
42126
42230
  src.push(" }");
42127
42231
  }
42128
42232
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
42129
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
42233
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
42130
42234
  }
42131
42235
  src.push(" gl_FragColor = vPickColor; ");
42132
42236
  src.push("}");
@@ -42338,6 +42442,10 @@ class TrianglesBatchingPickDepthRenderer {
42338
42442
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
42339
42443
  src.push("varying float vFragDepth;");
42340
42444
  }
42445
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
42446
+ src.push(" return (m[2][3] == - 1.0);");
42447
+ src.push("}");
42448
+ src.push("varying float isPerspective;");
42341
42449
  }
42342
42450
 
42343
42451
  if (clipping) {
@@ -42371,6 +42479,7 @@ class TrianglesBatchingPickDepthRenderer {
42371
42479
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
42372
42480
  src.push("clipPos.z *= clipPos.w;");
42373
42481
  }
42482
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
42374
42483
  }
42375
42484
  src.push("gl_Position = clipPos;");
42376
42485
  src.push(" }");
@@ -42400,6 +42509,7 @@ class TrianglesBatchingPickDepthRenderer {
42400
42509
  src.push("#endif");
42401
42510
 
42402
42511
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
42512
+ src.push("varying float isPerspective;");
42403
42513
  src.push("uniform float logDepthBufFC;");
42404
42514
  src.push("varying float vFragDepth;");
42405
42515
  }
@@ -42438,7 +42548,7 @@ class TrianglesBatchingPickDepthRenderer {
42438
42548
  src.push(" }");
42439
42549
  }
42440
42550
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
42441
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
42551
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
42442
42552
  }
42443
42553
  src.push(" float zNormalizedDepth = abs((pickZNear + vViewPosition.z) / (pickZFar - pickZNear));");
42444
42554
  src.push(" gl_FragColor = packDepth(zNormalizedDepth); "); // Must be linear depth
@@ -42644,6 +42754,10 @@ class TrianglesBatchingPickNormalsRenderer {
42644
42754
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
42645
42755
  src.push("varying float vFragDepth;");
42646
42756
  }
42757
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
42758
+ src.push(" return (m[2][3] == - 1.0);");
42759
+ src.push("}");
42760
+ src.push("varying float isPerspective;");
42647
42761
  }
42648
42762
  src.push("vec3 octDecode(vec2 oct) {");
42649
42763
  src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");
@@ -42682,6 +42796,7 @@ class TrianglesBatchingPickNormalsRenderer {
42682
42796
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
42683
42797
  src.push("clipPos.z *= clipPos.w;");
42684
42798
  }
42799
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
42685
42800
  }
42686
42801
  src.push("gl_Position = clipPos;");
42687
42802
  src.push(" }");
@@ -42706,6 +42821,7 @@ class TrianglesBatchingPickNormalsRenderer {
42706
42821
  src.push("precision mediump int;");
42707
42822
  src.push("#endif");
42708
42823
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
42824
+ src.push("varying float isPerspective;");
42709
42825
  src.push("uniform float logDepthBufFC;");
42710
42826
  src.push("varying float vFragDepth;");
42711
42827
  }
@@ -42733,7 +42849,7 @@ class TrianglesBatchingPickNormalsRenderer {
42733
42849
  src.push(" }");
42734
42850
  }
42735
42851
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
42736
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
42852
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
42737
42853
  }
42738
42854
  src.push(" gl_FragColor = vec4((vWorldNormal * 0.5) + 0.5, 1.0);");
42739
42855
  src.push("}");
@@ -42935,6 +43051,10 @@ class TrianglesBatchingOcclusionRenderer {
42935
43051
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
42936
43052
  src.push("varying float vFragDepth;");
42937
43053
  }
43054
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
43055
+ src.push(" return (m[2][3] == - 1.0);");
43056
+ src.push("}");
43057
+ src.push("varying float isPerspective;");
42938
43058
  }
42939
43059
  if (clipping) {
42940
43060
  src.push("varying vec4 vWorldPosition;");
@@ -42968,6 +43088,7 @@ class TrianglesBatchingOcclusionRenderer {
42968
43088
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
42969
43089
  src.push("clipPos.z *= clipPos.w;");
42970
43090
  }
43091
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
42971
43092
  }
42972
43093
  src.push("gl_Position = clipPos;");
42973
43094
  src.push(" }");
@@ -42992,6 +43113,7 @@ class TrianglesBatchingOcclusionRenderer {
42992
43113
  src.push("precision mediump int;");
42993
43114
  src.push("#endif");
42994
43115
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
43116
+ src.push("varying float isPerspective;");
42995
43117
  src.push("uniform float logDepthBufFC;");
42996
43118
  src.push("varying float vFragDepth;");
42997
43119
  }
@@ -43018,7 +43140,7 @@ class TrianglesBatchingOcclusionRenderer {
43018
43140
  src.push(" }");
43019
43141
  }
43020
43142
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
43021
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
43143
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
43022
43144
  }
43023
43145
  src.push(" gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0); "); // Occluders are blue
43024
43146
  src.push("}");
@@ -43213,6 +43335,10 @@ class TrianglesBatchingDepthRenderer {
43213
43335
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
43214
43336
  src.push("varying float vFragDepth;");
43215
43337
  }
43338
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
43339
+ src.push(" return (m[2][3] == - 1.0);");
43340
+ src.push("}");
43341
+ src.push("varying float isPerspective;");
43216
43342
  }
43217
43343
  if (clipping) {
43218
43344
  src.push("varying vec4 vWorldPosition;");
@@ -43244,6 +43370,7 @@ class TrianglesBatchingDepthRenderer {
43244
43370
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
43245
43371
  src.push("clipPos.z *= clipPos.w;");
43246
43372
  }
43373
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
43247
43374
  }
43248
43375
  src.push("gl_Position = clipPos;");
43249
43376
  src.push("vHighPrecisionZW = gl_Position.zw;");
@@ -43264,6 +43391,7 @@ class TrianglesBatchingDepthRenderer {
43264
43391
  src.push("precision highp float;");
43265
43392
  src.push("precision highp int;");
43266
43393
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
43394
+ src.push("varying float isPerspective;");
43267
43395
  src.push("uniform float logDepthBufFC;");
43268
43396
  src.push("varying float vFragDepth;");
43269
43397
  }
@@ -43302,7 +43430,7 @@ class TrianglesBatchingDepthRenderer {
43302
43430
  src.push(" }");
43303
43431
  }
43304
43432
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
43305
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
43433
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
43306
43434
  }
43307
43435
  src.push("float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;");
43308
43436
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["WEBGL_depth_texture"]) {
@@ -43513,6 +43641,10 @@ class TrianglesBatchingNormalsRenderer {
43513
43641
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
43514
43642
  src.push("varying float vFragDepth;");
43515
43643
  }
43644
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
43645
+ src.push(" return (m[2][3] == - 1.0);");
43646
+ src.push("}");
43647
+ src.push("varying float isPerspective;");
43516
43648
  }
43517
43649
  src.push("vec3 octDecode(vec2 oct) {");
43518
43650
  src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");
@@ -43555,6 +43687,7 @@ class TrianglesBatchingNormalsRenderer {
43555
43687
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
43556
43688
  src.push("clipPos.z *= clipPos.w;");
43557
43689
  }
43690
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
43558
43691
  }
43559
43692
  src.push("gl_Position = clipPos;");
43560
43693
  src.push(" }");
@@ -43582,6 +43715,7 @@ class TrianglesBatchingNormalsRenderer {
43582
43715
  src.push("#endif");
43583
43716
 
43584
43717
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
43718
+ src.push("varying float isPerspective;");
43585
43719
  src.push("uniform float logDepthBufFC;");
43586
43720
  src.push("varying float vFragDepth;");
43587
43721
  }
@@ -43613,7 +43747,7 @@ class TrianglesBatchingNormalsRenderer {
43613
43747
  src.push(" }");
43614
43748
  }
43615
43749
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
43616
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
43750
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
43617
43751
  }
43618
43752
  src.push(" gl_FragColor = vec4(packNormalToRGB(vViewNormal), 1.0); ");
43619
43753
  src.push("}");
@@ -44202,6 +44336,10 @@ class TrianglesBatchingColorQualityRenderer {
44202
44336
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
44203
44337
  src.push("varying float vFragDepth;");
44204
44338
  }
44339
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
44340
+ src.push(" return (m[2][3] == - 1.0);");
44341
+ src.push("}");
44342
+ src.push("varying float isPerspective;");
44205
44343
  }
44206
44344
 
44207
44345
  src.push("vec3 octDecode(vec2 oct) {");
@@ -44249,6 +44387,7 @@ class TrianglesBatchingColorQualityRenderer {
44249
44387
 
44250
44388
  src.push("vec4 clipPos = projMatrix * viewPosition;");
44251
44389
  if (scene.logarithmicDepthBufferEnabled) {
44390
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
44252
44391
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
44253
44392
  src.push("vFragDepth = 1.0 + clipPos.w;");
44254
44393
  } else {
@@ -44306,6 +44445,7 @@ class TrianglesBatchingColorQualityRenderer {
44306
44445
  src.push("#endif");
44307
44446
 
44308
44447
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
44448
+ src.push("varying float isPerspective;");
44309
44449
  src.push("uniform float logDepthBufFC;");
44310
44450
  src.push("varying float vFragDepth;");
44311
44451
  }
@@ -44653,7 +44793,7 @@ class TrianglesBatchingColorQualityRenderer {
44653
44793
  src.push("gl_FragColor = fragColor;");
44654
44794
 
44655
44795
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
44656
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
44796
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
44657
44797
  }
44658
44798
 
44659
44799
  src.push("}");
@@ -44850,6 +44990,10 @@ class TrianglesBatchingPickNormalsFlatRenderer {
44850
44990
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
44851
44991
  src.push("varying float vFragDepth;");
44852
44992
  }
44993
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
44994
+ src.push(" return (m[2][3] == - 1.0);");
44995
+ src.push("}");
44996
+ src.push("varying float isPerspective;");
44853
44997
  }
44854
44998
  src.push("varying vec4 vWorldPosition;");
44855
44999
  if (clipping) {
@@ -44878,6 +45022,7 @@ class TrianglesBatchingPickNormalsFlatRenderer {
44878
45022
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
44879
45023
  src.push("clipPos.z *= clipPos.w;");
44880
45024
  }
45025
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
44881
45026
  }
44882
45027
  src.push("gl_Position = clipPos;");
44883
45028
  src.push(" }");
@@ -44903,6 +45048,7 @@ class TrianglesBatchingPickNormalsFlatRenderer {
44903
45048
  src.push("precision mediump int;");
44904
45049
  src.push("#endif");
44905
45050
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
45051
+ src.push("varying float isPerspective;");
44906
45052
  src.push("uniform float logDepthBufFC;");
44907
45053
  src.push("varying float vFragDepth;");
44908
45054
  }
@@ -44929,7 +45075,7 @@ class TrianglesBatchingPickNormalsFlatRenderer {
44929
45075
  src.push(" }");
44930
45076
  }
44931
45077
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
44932
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
45078
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
44933
45079
  }
44934
45080
  src.push(" vec3 xTangent = dFdx( vWorldPosition.xyz );");
44935
45081
  src.push(" vec3 yTangent = dFdy( vWorldPosition.xyz );");
@@ -46959,6 +47105,10 @@ class TrianglesInstancingColorRenderer {
46959
47105
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
46960
47106
  src.push("varying float vFragDepth;");
46961
47107
  }
47108
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
47109
+ src.push(" return (m[2][3] == - 1.0);");
47110
+ src.push("}");
47111
+ src.push("varying float isPerspective;");
46962
47112
  }
46963
47113
 
46964
47114
  src.push("uniform vec4 lightAmbient;");
@@ -47062,6 +47212,7 @@ class TrianglesInstancingColorRenderer {
47062
47212
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
47063
47213
  src.push("clipPos.z *= clipPos.w;");
47064
47214
  }
47215
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
47065
47216
  }
47066
47217
 
47067
47218
  if (clipping) {
@@ -47093,6 +47244,7 @@ class TrianglesInstancingColorRenderer {
47093
47244
  src.push("#endif");
47094
47245
  if (scene.logarithmicDepthBufferEnabled) {
47095
47246
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
47247
+ src.push("varying float isPerspective;");
47096
47248
  src.push("uniform float logDepthBufFC;");
47097
47249
  src.push("varying float vFragDepth;");
47098
47250
  }
@@ -47139,7 +47291,7 @@ class TrianglesInstancingColorRenderer {
47139
47291
  }
47140
47292
 
47141
47293
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
47142
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
47294
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
47143
47295
  }
47144
47296
 
47145
47297
  // Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
@@ -47474,6 +47626,10 @@ class TrianglesInstancingFlatColorRenderer {
47474
47626
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
47475
47627
  src.push("varying float vFragDepth;");
47476
47628
  }
47629
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
47630
+ src.push(" return (m[2][3] == - 1.0);");
47631
+ src.push("}");
47632
+ src.push("varying float isPerspective;");
47477
47633
  }
47478
47634
 
47479
47635
  if (clipping) {
@@ -47512,6 +47668,7 @@ class TrianglesInstancingFlatColorRenderer {
47512
47668
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
47513
47669
  src.push("clipPos.z *= clipPos.w;");
47514
47670
  }
47671
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
47515
47672
  }
47516
47673
 
47517
47674
  if (clipping) {
@@ -47547,6 +47704,7 @@ class TrianglesInstancingFlatColorRenderer {
47547
47704
  src.push("#endif");
47548
47705
  if (scene.logarithmicDepthBufferEnabled) {
47549
47706
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
47707
+ src.push("varying float isPerspective;");
47550
47708
  src.push("uniform float logDepthBufFC;");
47551
47709
  src.push("varying float vFragDepth;");
47552
47710
  }
@@ -47673,7 +47831,7 @@ class TrianglesInstancingFlatColorRenderer {
47673
47831
  }
47674
47832
 
47675
47833
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
47676
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
47834
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
47677
47835
  }
47678
47836
 
47679
47837
  src.push("}");
@@ -47931,6 +48089,10 @@ class TrianglesInstancingSilhouetteRenderer {
47931
48089
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
47932
48090
  src.push("varying float vFragDepth;");
47933
48091
  }
48092
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
48093
+ src.push(" return (m[2][3] == - 1.0);");
48094
+ src.push("}");
48095
+ src.push("varying float isPerspective;");
47934
48096
  }
47935
48097
 
47936
48098
  src.push("uniform vec4 color;");
@@ -47969,6 +48131,7 @@ class TrianglesInstancingSilhouetteRenderer {
47969
48131
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
47970
48132
  src.push("clipPos.z *= clipPos.w;");
47971
48133
  }
48134
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
47972
48135
  }
47973
48136
  src.push("gl_Position = clipPos;");
47974
48137
  src.push("}");
@@ -47993,6 +48156,7 @@ class TrianglesInstancingSilhouetteRenderer {
47993
48156
  src.push("precision mediump int;");
47994
48157
  src.push("#endif");
47995
48158
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
48159
+ src.push("varying float isPerspective;");
47996
48160
  src.push("uniform float logDepthBufFC;");
47997
48161
  src.push("varying float vFragDepth;");
47998
48162
  }
@@ -48020,7 +48184,7 @@ class TrianglesInstancingSilhouetteRenderer {
48020
48184
  src.push("}");
48021
48185
  }
48022
48186
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
48023
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
48187
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
48024
48188
  }
48025
48189
  src.push("gl_FragColor = color;");
48026
48190
  src.push("}");
@@ -48281,6 +48445,10 @@ class TrianglesInstancingEdgesRenderer {
48281
48445
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
48282
48446
  src.push("varying float vFragDepth;");
48283
48447
  }
48448
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
48449
+ src.push(" return (m[2][3] == - 1.0);");
48450
+ src.push("}");
48451
+ src.push("varying float isPerspective;");
48284
48452
  }
48285
48453
 
48286
48454
  if (clipping) {
@@ -48317,6 +48485,7 @@ class TrianglesInstancingEdgesRenderer {
48317
48485
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
48318
48486
  src.push("clipPos.z *= clipPos.w;");
48319
48487
  }
48488
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
48320
48489
  }
48321
48490
  src.push("gl_Position = clipPos;");
48322
48491
  src.push("vColor = vec4(color.r, color.g, color.b, color.a);");
@@ -48342,6 +48511,7 @@ class TrianglesInstancingEdgesRenderer {
48342
48511
  src.push("precision mediump int;");
48343
48512
  src.push("#endif");
48344
48513
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
48514
+ src.push("varying float isPerspective;");
48345
48515
  src.push("uniform float logDepthBufFC;");
48346
48516
  src.push("varying float vFragDepth;");
48347
48517
  }
@@ -48369,7 +48539,7 @@ class TrianglesInstancingEdgesRenderer {
48369
48539
  src.push("}");
48370
48540
  }
48371
48541
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
48372
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
48542
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
48373
48543
  }
48374
48544
  src.push("gl_FragColor = vColor;");
48375
48545
  src.push("}");
@@ -48611,6 +48781,10 @@ class TrianglesInstancingEdgesColorRenderer {
48611
48781
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
48612
48782
  src.push("varying float vFragDepth;");
48613
48783
  }
48784
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
48785
+ src.push(" return (m[2][3] == - 1.0);");
48786
+ src.push("}");
48787
+ src.push("varying float isPerspective;");
48614
48788
  }
48615
48789
 
48616
48790
  if (clipping) {
@@ -48647,6 +48821,7 @@ class TrianglesInstancingEdgesColorRenderer {
48647
48821
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
48648
48822
  src.push("clipPos.z *= clipPos.w;");
48649
48823
  }
48824
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
48650
48825
  }
48651
48826
  src.push("gl_Position = clipPos;");
48652
48827
  // src.push("vColor = vec4(float(color.r-100.0) / 255.0, float(color.g-100.0) / 255.0, float(color.b-100.0) / 255.0, float(color.a) / 255.0);");
@@ -48673,6 +48848,7 @@ class TrianglesInstancingEdgesColorRenderer {
48673
48848
  src.push("precision mediump int;");
48674
48849
  src.push("#endif");
48675
48850
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
48851
+ src.push("varying float isPerspective;");
48676
48852
  src.push("uniform float logDepthBufFC;");
48677
48853
  src.push("varying float vFragDepth;");
48678
48854
  }
@@ -48700,7 +48876,7 @@ class TrianglesInstancingEdgesColorRenderer {
48700
48876
  src.push("}");
48701
48877
  }
48702
48878
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
48703
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
48879
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
48704
48880
  }
48705
48881
  src.push("gl_FragColor = vColor;");
48706
48882
  src.push("}");
@@ -48953,6 +49129,10 @@ class TrianglesInstancingPickMeshRenderer {
48953
49129
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
48954
49130
  src.push("varying float vFragDepth;");
48955
49131
  }
49132
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
49133
+ src.push(" return (m[2][3] == - 1.0);");
49134
+ src.push("}");
49135
+ src.push("varying float isPerspective;");
48956
49136
  }
48957
49137
 
48958
49138
  if (clipping) {
@@ -48992,6 +49172,7 @@ class TrianglesInstancingPickMeshRenderer {
48992
49172
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
48993
49173
  src.push("clipPos.z *= clipPos.w;");
48994
49174
  }
49175
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
48995
49176
  }
48996
49177
  src.push("gl_Position = clipPos;");
48997
49178
  src.push("}");
@@ -49016,6 +49197,7 @@ class TrianglesInstancingPickMeshRenderer {
49016
49197
  src.push("precision mediump int;");
49017
49198
  src.push("#endif");
49018
49199
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
49200
+ src.push("varying float isPerspective;");
49019
49201
  src.push("uniform float logDepthBufFC;");
49020
49202
  src.push("varying float vFragDepth;");
49021
49203
  }
@@ -49043,7 +49225,7 @@ class TrianglesInstancingPickMeshRenderer {
49043
49225
  src.push("}");
49044
49226
  }
49045
49227
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
49046
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
49228
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
49047
49229
  }
49048
49230
  src.push("gl_FragColor = vPickColor; ");
49049
49231
  src.push("}");
@@ -49292,6 +49474,10 @@ class TrianglesInstancingPickDepthRenderer {
49292
49474
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
49293
49475
  src.push("varying float vFragDepth;");
49294
49476
  }
49477
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
49478
+ src.push(" return (m[2][3] == - 1.0);");
49479
+ src.push("}");
49480
+ src.push("varying float isPerspective;");
49295
49481
  }
49296
49482
 
49297
49483
  if (clipping) {
@@ -49329,6 +49515,7 @@ class TrianglesInstancingPickDepthRenderer {
49329
49515
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
49330
49516
  src.push("clipPos.z *= clipPos.w;");
49331
49517
  }
49518
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
49332
49519
  }
49333
49520
  src.push("gl_Position = clipPos;");
49334
49521
  src.push("}");
@@ -49356,6 +49543,7 @@ class TrianglesInstancingPickDepthRenderer {
49356
49543
  src.push("#endif");
49357
49544
 
49358
49545
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
49546
+ src.push("varying float isPerspective;");
49359
49547
  src.push("uniform float logDepthBufFC;");
49360
49548
  src.push("varying float vFragDepth;");
49361
49549
  }
@@ -49394,7 +49582,7 @@ class TrianglesInstancingPickDepthRenderer {
49394
49582
  src.push("}");
49395
49583
  }
49396
49584
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
49397
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
49585
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
49398
49586
  }
49399
49587
  src.push(" float zNormalizedDepth = abs((pickZNear + vViewPosition.z) / (pickZFar - pickZNear));");
49400
49588
  src.push(" gl_FragColor = packDepth(zNormalizedDepth); "); // Must be linear depth
@@ -49655,6 +49843,10 @@ class TrianglesInstancingPickNormalsRenderer {
49655
49843
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
49656
49844
  src.push("varying float vFragDepth;");
49657
49845
  }
49846
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
49847
+ src.push(" return (m[2][3] == - 1.0);");
49848
+ src.push("}");
49849
+ src.push("varying float isPerspective;");
49658
49850
  }
49659
49851
  src.push("vec3 octDecode(vec2 oct) {");
49660
49852
  src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");
@@ -49697,6 +49889,7 @@ class TrianglesInstancingPickNormalsRenderer {
49697
49889
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
49698
49890
  src.push("clipPos.z *= clipPos.w;");
49699
49891
  }
49892
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
49700
49893
  }
49701
49894
  src.push("gl_Position = clipPos;");
49702
49895
  src.push("}");
@@ -49724,6 +49917,7 @@ class TrianglesInstancingPickNormalsRenderer {
49724
49917
  src.push("#endif");
49725
49918
 
49726
49919
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
49920
+ src.push("varying float isPerspective;");
49727
49921
  src.push("uniform float logDepthBufFC;");
49728
49922
  src.push("varying float vFragDepth;");
49729
49923
  }
@@ -49752,7 +49946,7 @@ class TrianglesInstancingPickNormalsRenderer {
49752
49946
  src.push("}");
49753
49947
  }
49754
49948
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
49755
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
49949
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
49756
49950
  }
49757
49951
  src.push(" gl_FragColor = vec4((vWorldNormal * 0.5) + 0.5, 1.0);");
49758
49952
  src.push("}");
@@ -49994,6 +50188,10 @@ class TrianglesInstancingOcclusionRenderer {
49994
50188
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
49995
50189
  src.push("varying float vFragDepth;");
49996
50190
  }
50191
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
50192
+ src.push(" return (m[2][3] == - 1.0);");
50193
+ src.push("}");
50194
+ src.push("varying float isPerspective;");
49997
50195
  }
49998
50196
  if (clipping) {
49999
50197
  src.push("varying vec4 vWorldPosition;");
@@ -50025,6 +50223,7 @@ class TrianglesInstancingOcclusionRenderer {
50025
50223
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
50026
50224
  src.push("clipPos.z *= clipPos.w;");
50027
50225
  }
50226
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
50028
50227
  }
50029
50228
  src.push("gl_Position = clipPos;");
50030
50229
  src.push("}");
@@ -50049,6 +50248,7 @@ class TrianglesInstancingOcclusionRenderer {
50049
50248
  src.push("precision mediump int;");
50050
50249
  src.push("#endif");
50051
50250
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
50251
+ src.push("varying float isPerspective;");
50052
50252
  src.push("uniform float logDepthBufFC;");
50053
50253
  src.push("varying float vFragDepth;");
50054
50254
  }
@@ -50076,7 +50276,7 @@ class TrianglesInstancingOcclusionRenderer {
50076
50276
  }
50077
50277
  src.push(" gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0); "); // Occluders are blue
50078
50278
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
50079
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
50279
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
50080
50280
  }
50081
50281
  src.push("}");
50082
50282
  return src;
@@ -50306,6 +50506,10 @@ class TrianglesInstancingDepthRenderer {
50306
50506
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
50307
50507
  src.push("varying float vFragDepth;");
50308
50508
  }
50509
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
50510
+ src.push(" return (m[2][3] == - 1.0);");
50511
+ src.push("}");
50512
+ src.push("varying float isPerspective;");
50309
50513
  }
50310
50514
  if (clipping) {
50311
50515
  src.push("varying vec4 vWorldPosition;");
@@ -50340,6 +50544,7 @@ class TrianglesInstancingDepthRenderer {
50340
50544
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
50341
50545
  src.push("clipPos.z *= clipPos.w;");
50342
50546
  }
50547
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
50343
50548
  }
50344
50549
  src.push("gl_Position = clipPos;");
50345
50550
  src.push("vHighPrecisionZW = gl_Position.zw;");
@@ -50363,6 +50568,7 @@ class TrianglesInstancingDepthRenderer {
50363
50568
  src.push("precision highp int;");
50364
50569
  if (scene.logarithmicDepthBufferEnabled) {
50365
50570
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
50571
+ src.push("varying float isPerspective;");
50366
50572
  src.push("uniform float logDepthBufFC;");
50367
50573
  src.push("varying float vFragDepth;");
50368
50574
  }
@@ -50405,7 +50611,7 @@ class TrianglesInstancingDepthRenderer {
50405
50611
  src.push("}");
50406
50612
  }
50407
50613
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
50408
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
50614
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
50409
50615
  }
50410
50616
  src.push("float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;");
50411
50617
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["WEBGL_depth_texture"]) {
@@ -50661,6 +50867,10 @@ class TrianglesInstancingNormalsRenderer {
50661
50867
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
50662
50868
  src.push("varying float vFragDepth;");
50663
50869
  }
50870
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
50871
+ src.push(" return (m[2][3] == - 1.0);");
50872
+ src.push("}");
50873
+ src.push("varying float isPerspective;");
50664
50874
  }
50665
50875
  src.push("vec3 octDecode(vec2 oct) {");
50666
50876
  src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");
@@ -50704,6 +50914,7 @@ class TrianglesInstancingNormalsRenderer {
50704
50914
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
50705
50915
  src.push("clipPos.z *= clipPos.w;");
50706
50916
  }
50917
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
50707
50918
  }
50708
50919
  src.push("gl_Position = clipPos;");
50709
50920
  src.push("}");
@@ -50728,6 +50939,7 @@ class TrianglesInstancingNormalsRenderer {
50728
50939
  src.push("precision mediump int;");
50729
50940
  src.push("#endif");
50730
50941
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
50942
+ src.push("varying float isPerspective;");
50731
50943
  src.push("uniform float logDepthBufFC;");
50732
50944
  src.push("varying float vFragDepth;");
50733
50945
  }
@@ -50758,7 +50970,7 @@ class TrianglesInstancingNormalsRenderer {
50758
50970
  src.push("}");
50759
50971
  }
50760
50972
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
50761
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
50973
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
50762
50974
  }
50763
50975
  src.push(" gl_FragColor = vec4(packNormalToRGB(vViewNormal), 1.0); ");
50764
50976
  src.push("}");
@@ -51433,6 +51645,10 @@ class TrianglesInstancingColorQualityRenderer {
51433
51645
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
51434
51646
  src.push("varying float vFragDepth;");
51435
51647
  }
51648
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
51649
+ src.push(" return (m[2][3] == - 1.0);");
51650
+ src.push("}");
51651
+ src.push("varying float isPerspective;");
51436
51652
  }
51437
51653
 
51438
51654
  src.push("vec3 octDecode(vec2 oct) {");
@@ -51490,6 +51706,7 @@ class TrianglesInstancingColorQualityRenderer {
51490
51706
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
51491
51707
  src.push("clipPos.z *= clipPos.w;");
51492
51708
  }
51709
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
51493
51710
  }
51494
51711
 
51495
51712
  if (clipping) {
@@ -51540,6 +51757,7 @@ class TrianglesInstancingColorQualityRenderer {
51540
51757
  src.push("#endif");
51541
51758
 
51542
51759
  if (scene.logarithmicDepthBufferEnabled) {
51760
+ src.push("varying float isPerspective;");
51543
51761
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
51544
51762
  src.push("uniform float logDepthBufFC;");
51545
51763
  src.push("varying float vFragDepth;");
@@ -51890,7 +52108,7 @@ class TrianglesInstancingColorQualityRenderer {
51890
52108
  src.push("gl_FragColor = fragColor;");
51891
52109
 
51892
52110
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
51893
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
52111
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
51894
52112
  }
51895
52113
 
51896
52114
  src.push("}");
@@ -52124,6 +52342,10 @@ class TrianglesInstancingPickNormalsFlatRenderer {
52124
52342
  if (WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
52125
52343
  src.push("varying float vFragDepth;");
52126
52344
  }
52345
+ src.push("bool isPerspectiveMatrix(mat4 m) {");
52346
+ src.push(" return (m[2][3] == - 1.0);");
52347
+ src.push("}");
52348
+ src.push("varying float isPerspective;");
52127
52349
  }
52128
52350
  if (clipping) {
52129
52351
  src.push("varying vec4 vFlags2;");
@@ -52152,6 +52374,7 @@ class TrianglesInstancingPickNormalsFlatRenderer {
52152
52374
  src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");
52153
52375
  src.push("clipPos.z *= clipPos.w;");
52154
52376
  }
52377
+ src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
52155
52378
  }
52156
52379
  src.push("gl_Position = clipPos;");
52157
52380
  src.push("}");
@@ -52178,6 +52401,7 @@ class TrianglesInstancingPickNormalsFlatRenderer {
52178
52401
  src.push("#endif");
52179
52402
 
52180
52403
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
52404
+ src.push("varying float isPerspective;");
52181
52405
  src.push("uniform float logDepthBufFC;");
52182
52406
  src.push("varying float vFragDepth;");
52183
52407
  }
@@ -52205,7 +52429,7 @@ class TrianglesInstancingPickNormalsFlatRenderer {
52205
52429
  src.push("}");
52206
52430
  }
52207
52431
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO$1.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
52208
- src.push("gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;");
52432
+ src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
52209
52433
  }
52210
52434
  src.push(" vec3 xTangent = dFdx( vWorldPosition.xyz );");
52211
52435
  src.push(" vec3 yTangent = dFdy( vWorldPosition.xyz );");
@@ -98073,10 +98297,60 @@ class Fresnel extends Component {
98073
98297
  }
98074
98298
 
98075
98299
  /**
98076
- * A {@link Marker} with a textured quad attached to it.
98300
+ * A {@link Marker} with a billboarded and textured quad attached to it.
98301
+ *
98302
+ * * Extends {@link Marker}
98303
+ * * Keeps the quad oriented towards the viewpoint
98304
+ * * Auto-fits the quad to the texture
98305
+ * * Has a world-space position
98306
+ * * Can be configured to hide the quad whenever the position is occluded by some other object
98307
+ *
98308
+ * ## Usage
98309
+ *
98310
+ * [[Run this example](http://xeokit.github.io/xeokit-sdk/examples/#markers_SpriteMarker)]
98311
+ *
98312
+ * ```` javascript
98313
+ * import {Viewer, SpriteMarker } from "../dist/xeokit-sdk.es.js";
98314
+ *
98315
+ * const viewer = new Viewer({
98316
+ * canvasId: "myCanvas",
98317
+ * transparent: true
98318
+ * });
98319
+ *
98320
+ * viewer.scene.camera.eye = [0, 0, 25];
98321
+ * viewer.scene.camera.look = [0, 0, 0];
98322
+ * viewer.scene.camera.up = [0, 1, 0];
98323
+ *
98324
+ * new SpriteMarker(viewer.scene, {
98325
+ * worldPos: [-10, 0, 0],
98326
+ * src: "../assets/textures/diffuse/uvGrid2_512x1024.jpg",
98327
+ * size: 5,
98328
+ * occludable: false
98329
+ * });
98330
+ *
98331
+ * new SpriteMarker(viewer.scene, {
98332
+ * worldPos: [+10, 0, 0],
98333
+ * src: "../assets/textures/diffuse/uvGrid2_1024x512.jpg",
98334
+ * size: 4,
98335
+ * occludable: false
98336
+ * });
98337
+ *````
98077
98338
  */
98078
98339
  class SpriteMarker extends Marker {
98079
98340
 
98341
+ /**
98342
+ * @constructor
98343
+ * @param {Component} owner Owner component. When destroyed, the owner will destroy this SpriteMarker as well.
98344
+ * @param {*} [cfg] Configs
98345
+ * @param {String} [cfg.id] Optional ID for this SpriteMarker, unique among all components in the parent scene, generated automatically when omitted.
98346
+ * @param {Entity} [cfg.entity] Entity to associate this Marker with. When the SpriteMarker has an Entity, then {@link Marker#visible} will always be ````false```` if {@link Entity#visible} is false.
98347
+ * @param {Boolean} [cfg.occludable=false] Indicates whether or not this Marker is hidden (ie. {@link Marker#visible} is ````false```` whenever occluded by {@link Entity}s in the {@link Scene}.
98348
+ * @param {Number[]} [cfg.worldPos=[0,0,0]] World-space 3D Marker position.
98349
+ * @param {String} [cfg.src=null] Path to image file to load into this SpriteMarker. See the {@link SpriteMarker#src} property for more info.
98350
+ * @param {HTMLImageElement} [cfg.image=null] HTML Image object to load into this SpriteMarker. See the {@link SpriteMarker#image} property for more info.
98351
+ * @param {Boolean} [cfg.flipY=false] Flips this SpriteMarker's texture image along its vertical axis when true.
98352
+ * @param {String} [cfg.encoding="linear"] Texture encoding format. See the {@link Texture#encoding} property for more info.
98353
+ */
98080
98354
  constructor(owner, cfg = {}) {
98081
98355
 
98082
98356
  super(owner, {
@@ -98096,11 +98370,11 @@ class SpriteMarker extends Marker {
98096
98370
  this._size = 1.0;
98097
98371
  this._imageSize = math.vec2();
98098
98372
 
98099
- this._texture = new Texture(owner, {
98373
+ this._texture = new Texture(this, {
98100
98374
  src: cfg.src
98101
98375
  });
98102
98376
 
98103
- this._geometry = new ReadableGeometry(owner, {
98377
+ this._geometry = new ReadableGeometry(this, {
98104
98378
  primitive: "triangles",
98105
98379
  positions: [3, 3, 0, -3, 3, 0, -3, -3, 0, 3, -3, 0],
98106
98380
  normals: [-1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0],
@@ -98108,9 +98382,9 @@ class SpriteMarker extends Marker {
98108
98382
  indices: [0, 1, 2, 0, 2, 3] // Ensure these will be front-faces
98109
98383
  });
98110
98384
 
98111
- this._mesh = new Mesh(owner, {
98385
+ this._mesh = new Mesh(this, {
98112
98386
  geometry: this._geometry,
98113
- material: new PhongMaterial(owner, {
98387
+ material: new PhongMaterial(this, {
98114
98388
  ambient: [0.9, 0.3, 0.9],
98115
98389
  shininess: 30,
98116
98390
  diffuseMap: this._texture,
@@ -98119,7 +98393,8 @@ class SpriteMarker extends Marker {
98119
98393
  scale: [1, 1, 1], // Note: by design, scale does not work with billboard
98120
98394
  position: cfg.worldPos,
98121
98395
  rotation: [90, 0, 0],
98122
- billboard: "spherical"
98396
+ billboard: "spherical",
98397
+ occluder: false // Don't occlude SpriteMarkers or Annotations
98123
98398
  });
98124
98399
 
98125
98400
  this.visible = true;
@@ -98162,7 +98437,7 @@ class SpriteMarker extends Marker {
98162
98437
  * @returns {Boolean} Returns ````true```` if visible.
98163
98438
  */
98164
98439
  get visible() {
98165
- return this._mesh.visible;
98440
+ return this._visible;
98166
98441
  }
98167
98442
 
98168
98443
  /**
@@ -98361,10 +98636,10 @@ class SpriteMarker extends Marker {
98361
98636
  ];
98362
98637
  } else {
98363
98638
  this._geometry.positions = [
98364
- halfSize * aspect, halfSize, 0,
98365
- -halfSize * aspect, halfSize, 0,
98366
- -halfSize * aspect, -halfSize, 0,
98367
- halfSize * aspect, -halfSize, 0
98639
+ halfSize / aspect, halfSize, 0,
98640
+ -halfSize / aspect, halfSize, 0,
98641
+ -halfSize / aspect, -halfSize, 0,
98642
+ halfSize / aspect, -halfSize, 0
98368
98643
  ];
98369
98644
  }
98370
98645
  }