@xeokit/xeokit-sdk 2.4.2-beta-21 → 2.4.2-beta-22

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.
Files changed (90) hide show
  1. package/dist/xeokit-sdk.cjs.js +709 -588
  2. package/dist/xeokit-sdk.es.js +709 -588
  3. package/dist/xeokit-sdk.es5.js +203 -194
  4. package/dist/xeokit-sdk.min.cjs.js +4 -4
  5. package/dist/xeokit-sdk.min.es.js +4 -4
  6. package/dist/xeokit-sdk.min.es5.js +3 -3
  7. package/package.json +1 -1
  8. package/src/viewer/Viewer.js +7 -1
  9. package/src/viewer/scene/mesh/draw/DrawRenderer.js +18 -8
  10. package/src/viewer/scene/mesh/draw/DrawShaderSource.js +8 -8
  11. package/src/viewer/scene/mesh/emphasis/EmphasisEdgesRenderer.js +19 -9
  12. package/src/viewer/scene/mesh/emphasis/EmphasisEdgesShaderSource.js +3 -3
  13. package/src/viewer/scene/mesh/emphasis/EmphasisFillRenderer.js +19 -9
  14. package/src/viewer/scene/mesh/emphasis/EmphasisFillShaderSource.js +3 -3
  15. package/src/viewer/scene/mesh/occlusion/OcclusionRenderer.js +18 -8
  16. package/src/viewer/scene/mesh/occlusion/OcclusionShaderSource.js +3 -3
  17. package/src/viewer/scene/mesh/pick/PickMeshRenderer.js +18 -8
  18. package/src/viewer/scene/mesh/pick/PickMeshShaderSource.js +3 -3
  19. package/src/viewer/scene/mesh/pick/PickTriangleRenderer.js +18 -8
  20. package/src/viewer/scene/mesh/pick/PickTriangleShaderSource.js +3 -3
  21. package/src/viewer/scene/mesh/shadow/ShadowRenderer.js +1 -1
  22. package/src/viewer/scene/mesh/shadow/ShadowShaderSource.js +3 -3
  23. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureColorRenderer.js +22 -17
  24. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureDepthRenderer.js +21 -20
  25. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureEdgesColorRenderer.js +6 -9
  26. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureEdgesRenderer.js +21 -18
  27. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureNormalsRenderer.js +22 -18
  28. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureOcclusionRenderer.js +22 -17
  29. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickDepthRenderer.js +22 -18
  30. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickMeshRenderer.js +58 -54
  31. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickNormalsFlatRenderer.js +21 -19
  32. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickNormalsRenderer.js +22 -18
  33. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureSilhouetteRenderer.js +21 -18
  34. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureSnapDepthBufInitRenderer.js +21 -18
  35. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureSnapDepthRenderer.js +21 -18
  36. package/src/viewer/scene/model/vbo/VBOSceneModelRenderers.js +21 -16
  37. package/src/viewer/scene/model/vbo/linesBatching/renderers/LinesBatchingColorRenderer.js +4 -4
  38. package/src/viewer/scene/model/vbo/linesBatching/renderers/LinesBatchingSilhouetteRenderer.js +4 -4
  39. package/src/viewer/scene/model/vbo/linesInstancing/renderers/LinesInstancingColorRenderer.js +4 -4
  40. package/src/viewer/scene/model/vbo/linesInstancing/renderers/LinesInstancingSilhouetteRenderer.js +4 -4
  41. package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingColorRenderer.js +4 -4
  42. package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingOcclusionRenderer.js +4 -4
  43. package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingPickDepthRenderer.js +4 -4
  44. package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingPickMeshRenderer.js +4 -4
  45. package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingShadowRenderer.js +4 -4
  46. package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingSilhouetteRenderer.js +4 -4
  47. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingColorRenderer.js +4 -4
  48. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingDepthRenderer.js +4 -4
  49. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingOcclusionRenderer.js +4 -4
  50. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingPickDepthRenderer.js +4 -4
  51. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingPickMeshRenderer.js +4 -4
  52. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingShadowRenderer.js +4 -4
  53. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingSilhouetteRenderer.js +4 -4
  54. package/src/viewer/scene/model/vbo/snapBatching/SnapBatchingDepthBufInitRenderer.js +4 -4
  55. package/src/viewer/scene/model/vbo/snapBatching/SnapBatchingDepthRenderer.js +4 -4
  56. package/src/viewer/scene/model/vbo/snapInstancing/SnapInstancingDepthBufInitRenderer.js +4 -4
  57. package/src/viewer/scene/model/vbo/snapInstancing/SnapInstancingDepthRenderer.js +4 -4
  58. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingColorRenderer.js +4 -4
  59. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingColorTextureRenderer.js +4 -4
  60. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingDepthRenderer.js +4 -4
  61. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingEdgesColorRenderer.js +4 -4
  62. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingEdgesRenderer.js +4 -4
  63. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingFlatColorRenderer.js +4 -4
  64. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingNormalsRenderer.js +4 -4
  65. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingOcclusionRenderer.js +4 -4
  66. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPBRRenderer.js +4 -4
  67. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickDepthRenderer.js +4 -4
  68. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickMeshRenderer.js +4 -4
  69. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickNormalsFlatRenderer.js +4 -4
  70. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickNormalsRenderer.js +4 -4
  71. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingShadowRenderer.js +4 -4
  72. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingSilhouetteRenderer.js +4 -4
  73. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingColorRenderer.js +4 -4
  74. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingColorTextureRenderer.js +4 -4
  75. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingDepthRenderer.js +4 -4
  76. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingEdgesColorRenderer.js +4 -4
  77. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingEdgesRenderer.js +4 -4
  78. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingFlatColorRenderer.js +4 -4
  79. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingFlatNormalsRenderer.js +4 -4
  80. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingNormalsRenderer.js +4 -4
  81. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingOcclusionRenderer.js +4 -4
  82. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPBRRenderer.js +4 -4
  83. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickDepthRenderer.js +4 -4
  84. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickMeshRenderer.js +4 -4
  85. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickNormalsFlatRenderer.js +4 -4
  86. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickNormalsRenderer.js +4 -4
  87. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingShadowRenderer.js +4 -4
  88. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingSilhouetteRenderer.js +4 -4
  89. package/src/viewer/scene/scene/Scene.js +24 -9
  90. package/src/viewer/scene/sectionPlane/SectionPlaneCache.js +101 -0
@@ -91,25 +91,30 @@ export class TrianglesDataTexturePickMeshRenderer {
91
91
  const logDepthBufFC = 2.0 / (Math.log(camera.project.far + 1.0) / Math.LN2); // TODO: Far from pick project matrix?
92
92
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
93
93
  }
94
+ const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
94
95
  const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
95
- if (numSectionPlanes > 0) {
96
+ if (numAllocatedSectionPlanes > 0) {
96
97
  const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
97
98
  const baseIndex = dataTextureLayer.layerIndex * numSectionPlanes;
98
99
  const renderFlags = model.renderFlags;
99
- for (let sectionPlaneIndex = 0; sectionPlaneIndex < numSectionPlanes; sectionPlaneIndex++) {
100
+ for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
100
101
  const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
101
102
  if (sectionPlaneUniforms) {
102
- const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
103
- gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
104
- if (active) {
105
- const sectionPlane = sectionPlanes[sectionPlaneIndex];
106
- if (origin) {
107
- const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
108
- gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
109
- } else {
110
- gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
103
+ if (sectionPlaneIndex < numSectionPlanes) {
104
+ const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
105
+ gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
106
+ if (active) {
107
+ const sectionPlane = sectionPlanes[sectionPlaneIndex];
108
+ if (origin) {
109
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
110
+ gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
111
+ } else {
112
+ gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
113
+ }
114
+ gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
111
115
  }
112
- gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
116
+ } else {
117
+ gl.uniform1i(sectionPlaneUniforms.active, 0);
113
118
  }
114
119
  }
115
120
  }
@@ -117,8 +122,8 @@ export class TrianglesDataTexturePickMeshRenderer {
117
122
  if (state.numIndices8Bits > 0) {
118
123
  textureState.bindTriangleIndicesTextures(
119
124
  this._program,
120
- this._uTexturePerPolygonIdPortionIds,
121
- this._uTexturePerPolygonIdIndices,
125
+ this._uTexturePerPolygonIdPortionIds,
126
+ this._uTexturePerPolygonIdIndices,
122
127
  8 // 8 bits indices
123
128
  );
124
129
  gl.drawArrays(gl.TRIANGLES, 0, state.numIndices8Bits);
@@ -126,8 +131,8 @@ export class TrianglesDataTexturePickMeshRenderer {
126
131
  if (state.numIndices16Bits > 0) {
127
132
  textureState.bindTriangleIndicesTextures(
128
133
  this._program,
129
- this._uTexturePerPolygonIdPortionIds,
130
- this._uTexturePerPolygonIdIndices,
134
+ this._uTexturePerPolygonIdPortionIds,
135
+ this._uTexturePerPolygonIdIndices,
131
136
  16 // 16 bits indices
132
137
  );
133
138
  gl.drawArrays(gl.TRIANGLES, 0, state.numIndices16Bits);
@@ -135,8 +140,8 @@ export class TrianglesDataTexturePickMeshRenderer {
135
140
  if (state.numIndices32Bits > 0) {
136
141
  textureState.bindTriangleIndicesTextures(
137
142
  this._program,
138
- this._uTexturePerPolygonIdPortionIds,
139
- this._uTexturePerPolygonIdIndices,
143
+ this._uTexturePerPolygonIdPortionIds,
144
+ this._uTexturePerPolygonIdIndices,
140
145
  32 // 32 bits indices
141
146
  );
142
147
  gl.drawArrays(gl.TRIANGLES, 0, state.numIndices32Bits);
@@ -171,14 +176,14 @@ export class TrianglesDataTexturePickMeshRenderer {
171
176
  if (scene.logarithmicDepthBufferEnabled) {
172
177
  this._uLogDepthBufFC = program.getLocation("logDepthBufFC");
173
178
  }
174
- this.uTexturePerObjectPositionsDecodeMatrix = "uObjectPerObjectPositionsDecodeMatrix";
175
- this.uTexturePerObjectColorsAndFlags = "uObjectPerObjectColorsAndFlags";
176
- this._uTexturePerVertexIdCoordinates = "uTexturePerVertexIdCoordinates";
177
- this._uTexturePerPolygonIdNormals = "uTexturePerPolygonIdNormals";
178
- this._uTexturePerPolygonIdIndices = "uTexturePerPolygonIdIndices";
179
+ this.uTexturePerObjectPositionsDecodeMatrix = "uObjectPerObjectPositionsDecodeMatrix";
180
+ this.uTexturePerObjectColorsAndFlags = "uObjectPerObjectColorsAndFlags";
181
+ this._uTexturePerVertexIdCoordinates = "uTexturePerVertexIdCoordinates";
182
+ this._uTexturePerPolygonIdNormals = "uTexturePerPolygonIdNormals";
183
+ this._uTexturePerPolygonIdIndices = "uTexturePerPolygonIdIndices";
179
184
  this._uTexturePerPolygonIdPortionIds = "uTexturePerPolygonIdPortionIds";
180
- this._uTexturePerObjectMatrix= "uTexturePerObjectMatrix";
181
- this._uCameraEyeRtc = program.getLocation("uCameraEyeRtc");
185
+ this._uTexturePerObjectMatrix = "uTexturePerObjectMatrix";
186
+ this._uCameraEyeRtc = program.getLocation("uCameraEyeRtc");
182
187
  }
183
188
 
184
189
  _bindProgram(frameCtx) {
@@ -197,7 +202,7 @@ export class TrianglesDataTexturePickMeshRenderer {
197
202
 
198
203
  _buildVertexShader() {
199
204
  const scene = this._scene;
200
- const clipping = scene._sectionPlanesState.sectionPlanes.length > 0;
205
+ const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
201
206
  const src = [];
202
207
  src.push("#version 300 es");
203
208
  src.push("// Batched geometry picking vertex shader");
@@ -232,10 +237,10 @@ export class TrianglesDataTexturePickMeshRenderer {
232
237
  src.push("uniform highp sampler2D uObjectPerObjectPositionsDecodeMatrix;");
233
238
  src.push("uniform highp sampler2D uTexturePerObjectMatrix;");
234
239
  src.push("uniform lowp usampler2D uObjectPerObjectColorsAndFlags;");
235
- src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");
236
- src.push("uniform highp usampler2D uTexturePerPolygonIdIndices;");
240
+ src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");
241
+ src.push("uniform highp usampler2D uTexturePerPolygonIdIndices;");
237
242
  src.push("uniform mediump usampler2D uTexturePerPolygonIdPortionIds;");
238
- src.push("uniform vec3 uCameraEyeRtc;");
243
+ src.push("uniform vec3 uCameraEyeRtc;");
239
244
 
240
245
  src.push("vec3 positions[3];")
241
246
 
@@ -278,9 +283,9 @@ export class TrianglesDataTexturePickMeshRenderer {
278
283
  src.push("ivec2 objectIndexCoords = ivec2(objectIndex % 512, objectIndex / 512);");
279
284
 
280
285
  // get flags & flags2
281
- src.push("uvec4 flags = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+2, objectIndexCoords.y), 0);");
282
- src.push("uvec4 flags2 = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+3, objectIndexCoords.y), 0);");
283
-
286
+ src.push("uvec4 flags = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+2, objectIndexCoords.y), 0);");
287
+ src.push("uvec4 flags2 = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+3, objectIndexCoords.y), 0);");
288
+
284
289
  // flags.w = NOT_RENDERED | PICK
285
290
  // renderPass = PICK
286
291
 
@@ -290,9 +295,9 @@ export class TrianglesDataTexturePickMeshRenderer {
290
295
  src.push("} else {");
291
296
 
292
297
  // get vertex base
293
- src.push("ivec4 packedVertexBase = ivec4(texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+4, objectIndexCoords.y), 0));");
298
+ src.push("ivec4 packedVertexBase = ivec4(texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+4, objectIndexCoords.y), 0));");
294
299
 
295
- src.push("ivec4 packedIndexBaseOffset = ivec4(texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+5, objectIndexCoords.y), 0));");
300
+ src.push("ivec4 packedIndexBaseOffset = ivec4(texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+5, objectIndexCoords.y), 0));");
296
301
 
297
302
  src.push("int indexBaseOffset = (packedIndexBaseOffset.r << 24) + (packedIndexBaseOffset.g << 16) + (packedIndexBaseOffset.b << 8) + packedIndexBaseOffset.a;");
298
303
 
@@ -301,7 +306,7 @@ export class TrianglesDataTexturePickMeshRenderer {
301
306
 
302
307
  src.push("ivec3 vertexIndices = ivec3(texelFetch(uTexturePerPolygonIdIndices, ivec2(h_index, v_index), 0));");
303
308
  src.push("ivec3 uniqueVertexIndexes = vertexIndices + (packedVertexBase.r << 24) + (packedVertexBase.g << 16) + (packedVertexBase.b << 8) + packedVertexBase.a;")
304
-
309
+
305
310
  src.push("ivec3 indexPositionH = uniqueVertexIndexes & 4095;")
306
311
  src.push("ivec3 indexPositionV = uniqueVertexIndexes >> 12;")
307
312
 
@@ -309,7 +314,7 @@ export class TrianglesDataTexturePickMeshRenderer {
309
314
 
310
315
  src.push("mat4 objectDecodeAndInstanceMatrix = objectInstanceMatrix * mat4 (texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+0, objectIndexCoords.y), 0), texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+1, objectIndexCoords.y), 0), texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+2, objectIndexCoords.y), 0), texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+3, objectIndexCoords.y), 0));")
311
316
 
312
- src.push("uint solid = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+7, objectIndexCoords.y), 0).r;");
317
+ src.push("uint solid = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+7, objectIndexCoords.y), 0).r;");
313
318
 
314
319
  // get position
315
320
  src.push("positions[0] = vec3(texelFetch(uTexturePerVertexIdCoordinates, ivec2(indexPositionH.r, indexPositionV.r), 0));")
@@ -317,7 +322,7 @@ export class TrianglesDataTexturePickMeshRenderer {
317
322
  src.push("positions[2] = vec3(texelFetch(uTexturePerVertexIdCoordinates, ivec2(indexPositionH.b, indexPositionV.b), 0));")
318
323
 
319
324
  // get color
320
- src.push("uvec4 color = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+0, objectIndexCoords.y), 0);");
325
+ src.push("uvec4 color = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+0, objectIndexCoords.y), 0);");
321
326
 
322
327
  src.push(`if (color.a == 0u) {`);
323
328
  src.push(" gl_Position = vec4(3.0, 3.0, 3.0, 1.0);"); // Cull vertex
@@ -335,17 +340,17 @@ export class TrianglesDataTexturePickMeshRenderer {
335
340
 
336
341
  // when the geometry is not solid, if needed, flip the triangle winding
337
342
  src.push("if (solid != 1u) {");
338
- src.push("if (isPerspectiveMatrix(projMatrix)) {");
339
- src.push("vec3 uCameraEyeRtcInQuantizedSpace = (inverse(sceneModelMatrix * objectDecodeAndInstanceMatrix) * vec4(uCameraEyeRtc, 1)).xyz;")
340
- src.push("if (dot(position.xyz - uCameraEyeRtcInQuantizedSpace, normal) < 0.0) {");
341
- src.push("position = positions[2 - (gl_VertexID % 3)];");
342
- src.push("}");
343
- src.push("} else {");
344
- src.push("vec3 viewNormal = -normalize((transpose(inverse(viewMatrix*objectDecodeAndInstanceMatrix)) * vec4(normal,1)).xyz);");
345
- src.push("if (viewNormal.z < 0.0) {");
346
- src.push("position = positions[2 - (gl_VertexID % 3)];");
347
- src.push("}");
348
- src.push("}");
343
+ src.push("if (isPerspectiveMatrix(projMatrix)) {");
344
+ src.push("vec3 uCameraEyeRtcInQuantizedSpace = (inverse(sceneModelMatrix * objectDecodeAndInstanceMatrix) * vec4(uCameraEyeRtc, 1)).xyz;")
345
+ src.push("if (dot(position.xyz - uCameraEyeRtcInQuantizedSpace, normal) < 0.0) {");
346
+ src.push("position = positions[2 - (gl_VertexID % 3)];");
347
+ src.push("}");
348
+ src.push("} else {");
349
+ src.push("vec3 viewNormal = -normalize((transpose(inverse(viewMatrix*objectDecodeAndInstanceMatrix)) * vec4(normal,1)).xyz);");
350
+ src.push("if (viewNormal.z < 0.0) {");
351
+ src.push("position = positions[2 - (gl_VertexID % 3)];");
352
+ src.push("}");
353
+ src.push("}");
349
354
  src.push("}");
350
355
 
351
356
  src.push("vec4 worldPosition = sceneModelMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");
@@ -369,10 +374,9 @@ export class TrianglesDataTexturePickMeshRenderer {
369
374
 
370
375
  _buildFragmentShader() {
371
376
  const scene = this._scene;
372
- const sectionPlanesState = scene._sectionPlanesState;
373
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
377
+ const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
374
378
  const src = [];
375
- src.push ('#version 300 es');
379
+ src.push('#version 300 es');
376
380
  src.push("// Batched geometry picking fragment shader");
377
381
  src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
378
382
  src.push("precision highp float;");
@@ -389,7 +393,7 @@ export class TrianglesDataTexturePickMeshRenderer {
389
393
  if (clipping) {
390
394
  src.push("in vec4 vWorldPosition;");
391
395
  src.push("flat in uvec4 vFlags2;");
392
- for (var i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
396
+ for (var i = 0; i < scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
393
397
  src.push("uniform bool sectionPlaneActive" + i + ";");
394
398
  src.push("uniform vec3 sectionPlanePos" + i + ";");
395
399
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
@@ -402,7 +406,7 @@ export class TrianglesDataTexturePickMeshRenderer {
402
406
  src.push(" bool clippable = (float(vFlags2.x) > 0.0);");
403
407
  src.push(" if (clippable) {");
404
408
  src.push(" float dist = 0.0;");
405
- for (var i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
409
+ for (var i = 0; i < scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
406
410
  src.push(" if (sectionPlaneActive" + i + ") {");
407
411
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
408
412
  src.push(" }");
@@ -411,7 +415,7 @@ export class TrianglesDataTexturePickMeshRenderer {
411
415
  src.push(" }");
412
416
  }
413
417
  if (scene.logarithmicDepthBufferEnabled) {
414
- src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
418
+ src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
415
419
  //src.push(" gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");
416
420
  }
417
421
  src.push(" outPickColor = vPickColor; ");
@@ -103,25 +103,30 @@ export class TrianglesDataTexturePickNormalsFlatRenderer {
103
103
  const logDepthBufFC = 2.0 / (Math.log(frameCtx.pickZFar + 1.0) / Math.LN2);
104
104
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
105
105
  }
106
+ const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
106
107
  const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
107
- if (numSectionPlanes > 0) {
108
+ if (numAllocatedSectionPlanes > 0) {
108
109
  const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
109
110
  const baseIndex = dataTextureLayer.layerIndex * numSectionPlanes;
110
111
  const renderFlags = model.renderFlags;
111
- for (let sectionPlaneIndex = 0; sectionPlaneIndex < numSectionPlanes; sectionPlaneIndex++) {
112
+ for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
112
113
  const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
113
114
  if (sectionPlaneUniforms) {
114
- const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
115
- gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
116
- if (active) {
117
- const sectionPlane = sectionPlanes[sectionPlaneIndex];
118
- if (origin) {
119
- const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3d);
120
- gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
121
- } else {
122
- gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
115
+ if (sectionPlaneIndex < numSectionPlanes) {
116
+ const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
117
+ gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
118
+ if (active) {
119
+ const sectionPlane = sectionPlanes[sectionPlaneIndex];
120
+ if (origin) {
121
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
122
+ gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
123
+ } else {
124
+ gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
125
+ }
126
+ gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
123
127
  }
124
- gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
128
+ } else {
129
+ gl.uniform1i(sectionPlaneUniforms.active, 0);
125
130
  }
126
131
  }
127
132
  }
@@ -218,9 +223,7 @@ export class TrianglesDataTexturePickNormalsFlatRenderer {
218
223
 
219
224
  _buildVertexShader() {
220
225
  const scene = this._scene;
221
- const sectionPlanesState = scene._sectionPlanesState;
222
- const lightsState = scene._lightsState;
223
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
226
+ const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
224
227
  let light;
225
228
  const src = [];
226
229
  src.push("#version 300 es");
@@ -387,8 +390,7 @@ export class TrianglesDataTexturePickNormalsFlatRenderer {
387
390
 
388
391
  _buildFragmentShader() {
389
392
  const scene = this._scene;
390
- const sectionPlanesState = scene._sectionPlanesState;
391
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
393
+ const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
392
394
  const src = [];
393
395
  src.push('#version 300 es');
394
396
  src.push("// TrianglesDataTexturePickNormalsRenderer fragment shader");
@@ -407,7 +409,7 @@ export class TrianglesDataTexturePickNormalsFlatRenderer {
407
409
  src.push("in vec4 vWorldPosition;");
408
410
  if (clipping) {
409
411
  src.push("flat in uint vFlags2;");
410
- for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
412
+ for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
411
413
  src.push("uniform bool sectionPlaneActive" + i + ";");
412
414
  src.push("uniform vec3 sectionPlanePos" + i + ";");
413
415
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
@@ -419,7 +421,7 @@ export class TrianglesDataTexturePickNormalsFlatRenderer {
419
421
  src.push(" bool clippable = vFlags2 > 0u;");
420
422
  src.push(" if (clippable) {");
421
423
  src.push(" float dist = 0.0;");
422
- for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
424
+ for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
423
425
  src.push("if (sectionPlaneActive" + i + ") {");
424
426
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
425
427
  src.push("}");
@@ -81,25 +81,30 @@ export class TrianglesDataTexturePickNormalsRenderer {
81
81
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
82
82
  }
83
83
 
84
+ const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
84
85
  const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
85
- if (numSectionPlanes > 0) {
86
+ if (numAllocatedSectionPlanes > 0) {
86
87
  const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
87
88
  const baseIndex = dataTextureLayer.layerIndex * numSectionPlanes;
88
89
  const renderFlags = model.renderFlags;
89
- for (let sectionPlaneIndex = 0; sectionPlaneIndex < numSectionPlanes; sectionPlaneIndex++) {
90
+ for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
90
91
  const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
91
92
  if (sectionPlaneUniforms) {
92
- const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
93
- gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
94
- if (active) {
95
- const sectionPlane = sectionPlanes[sectionPlaneIndex];
96
- if (origin) {
97
- const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
98
- gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
99
- } else {
100
- gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
93
+ if (sectionPlaneIndex < numSectionPlanes) {
94
+ const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
95
+ gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
96
+ if (active) {
97
+ const sectionPlane = sectionPlanes[sectionPlaneIndex];
98
+ if (origin) {
99
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
100
+ gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
101
+ } else {
102
+ gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
103
+ }
104
+ gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
101
105
  }
102
- gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
106
+ } else {
107
+ gl.uniform1i(sectionPlaneUniforms.active, 0);
103
108
  }
104
109
  }
105
110
  }
@@ -162,7 +167,7 @@ export class TrianglesDataTexturePickNormalsRenderer {
162
167
 
163
168
  this._uSectionPlanes = [];
164
169
 
165
- for (let i = 0, len = scene._sectionPlanesState.sectionPlanes.length; i < len; i++) {
170
+ for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
166
171
  this._uSectionPlanes.push({
167
172
  active: program.getLocation("sectionPlaneActive" + i),
168
173
  pos: program.getLocation("sectionPlanePos" + i),
@@ -197,7 +202,7 @@ export class TrianglesDataTexturePickNormalsRenderer {
197
202
 
198
203
  _buildVertexShader() {
199
204
  const scene = this._scene;
200
- const clipping = scene._sectionPlanesState.sectionPlanes.length > 0;
205
+ const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
201
206
  const src = [];
202
207
  src.push("#version 300 es");
203
208
  src.push("// Triangles dataTexture pick normals vertex shader");
@@ -371,8 +376,7 @@ export class TrianglesDataTexturePickNormalsRenderer {
371
376
 
372
377
  _buildFragmentShader() {
373
378
  const scene = this._scene;
374
- const sectionPlanesState = scene._sectionPlanesState;
375
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
379
+ const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
376
380
  const src = [];
377
381
  src.push('#version 300 es');
378
382
  src.push("// Triangles dataTexture pick normals fragment shader");
@@ -392,7 +396,7 @@ export class TrianglesDataTexturePickNormalsRenderer {
392
396
  if (clipping) {
393
397
  src.push("in vec4 vWorldPosition;");
394
398
  src.push("flat in uint vFlags2;");
395
- for (var i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
399
+ for (var i = 0; i < scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
396
400
  src.push("uniform bool sectionPlaneActive" + i + ";");
397
401
  src.push("uniform vec3 sectionPlanePos" + i + ";");
398
402
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
@@ -405,7 +409,7 @@ export class TrianglesDataTexturePickNormalsRenderer {
405
409
  src.push(" bool clippable = vFlags2 > 0u;");
406
410
  src.push(" if (clippable) {");
407
411
  src.push(" float dist = 0.0;");
408
- for (var i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
412
+ for (var i = 0; i < scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
409
413
  src.push(" if (sectionPlaneActive" + i + ") {");
410
414
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
411
415
  src.push(" }");
@@ -123,25 +123,30 @@ export class TrianglesDataTextureSilhouetteRenderer {
123
123
  const logDepthBufFC = 2.0 / (Math.log(frameCtx.pickZFar + 1.0) / Math.LN2);
124
124
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
125
125
  }
126
+ const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
126
127
  const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
127
- if (numSectionPlanes > 0) {
128
+ if (numAllocatedSectionPlanes > 0) {
128
129
  const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
129
130
  const baseIndex = dataTextureLayer.layerIndex * numSectionPlanes;
130
131
  const renderFlags = model.renderFlags;
131
- for (let sectionPlaneIndex = 0; sectionPlaneIndex < numSectionPlanes; sectionPlaneIndex++) {
132
+ for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
132
133
  const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
133
134
  if (sectionPlaneUniforms) {
134
- const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
135
- gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
136
- if (active) {
137
- const sectionPlane = sectionPlanes[sectionPlaneIndex];
138
- if (origin) {
139
- const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3d);
140
- gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
141
- } else {
142
- gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
135
+ if (sectionPlaneIndex < numSectionPlanes) {
136
+ const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
137
+ gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
138
+ if (active) {
139
+ const sectionPlane = sectionPlanes[sectionPlaneIndex];
140
+ if (origin) {
141
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
142
+ gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
143
+ } else {
144
+ gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
145
+ }
146
+ gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
143
147
  }
144
- gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
148
+ } else {
149
+ gl.uniform1i(sectionPlaneUniforms.active, 0);
145
150
  }
146
151
  }
147
152
  }
@@ -243,8 +248,7 @@ export class TrianglesDataTextureSilhouetteRenderer {
243
248
  _buildVertexShader() {
244
249
 
245
250
  const scene = this._scene;
246
- const sectionPlanesState = scene._sectionPlanesState;
247
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
251
+ const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
248
252
 
249
253
  const src = [];
250
254
  src.push("#version 300 es");
@@ -398,8 +402,7 @@ export class TrianglesDataTextureSilhouetteRenderer {
398
402
 
399
403
  _buildFragmentShader() {
400
404
  const scene = this._scene;
401
- const sectionPlanesState = scene._sectionPlanesState;
402
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
405
+ const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
403
406
  const src = [];
404
407
  src.push('#version 300 es');
405
408
  src.push("// Triangles dataTexture draw fragment shader");
@@ -418,7 +421,7 @@ export class TrianglesDataTextureSilhouetteRenderer {
418
421
  if (clipping) {
419
422
  src.push("in vec4 vWorldPosition;");
420
423
  src.push("flat in uint vFlags2;");
421
- for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
424
+ for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
422
425
  src.push("uniform bool sectionPlaneActive" + i + ";");
423
426
  src.push("uniform vec3 sectionPlanePos" + i + ";");
424
427
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
@@ -431,7 +434,7 @@ export class TrianglesDataTextureSilhouetteRenderer {
431
434
  src.push(" bool clippable = vFlags2 > 0u;");
432
435
  src.push(" if (clippable) {");
433
436
  src.push(" float dist = 0.0;");
434
- for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
437
+ for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
435
438
  src.push("if (sectionPlaneActive" + i + ") {");
436
439
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
437
440
  src.push("}");
@@ -117,25 +117,30 @@ export class TrianglesDataTextureSnapDepthBufInitRenderer {
117
117
  const logDepthBufFC = 2.0 / (Math.log(frameCtx.pickZFar + 1.0) / Math.LN2);
118
118
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
119
119
  }
120
+ const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
120
121
  const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
121
- if (numSectionPlanes > 0) {
122
+ if (numAllocatedSectionPlanes > 0) {
122
123
  const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
123
124
  const baseIndex = dataTextureLayer.layerIndex * numSectionPlanes;
124
125
  const renderFlags = model.renderFlags;
125
- for (let sectionPlaneIndex = 0; sectionPlaneIndex < numSectionPlanes; sectionPlaneIndex++) {
126
+ for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
126
127
  const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
127
128
  if (sectionPlaneUniforms) {
128
- const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
129
- gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
130
- if (active) {
131
- const sectionPlane = sectionPlanes[sectionPlaneIndex];
132
- if (origin) {
133
- const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3e);
134
- gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
135
- } else {
136
- gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
129
+ if (sectionPlaneIndex < numSectionPlanes) {
130
+ const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
131
+ gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
132
+ if (active) {
133
+ const sectionPlane = sectionPlanes[sectionPlaneIndex];
134
+ if (origin) {
135
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
136
+ gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
137
+ } else {
138
+ gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
139
+ }
140
+ gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
137
141
  }
138
- gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
142
+ } else {
143
+ gl.uniform1i(sectionPlaneUniforms.active, 0);
139
144
  }
140
145
  }
141
146
  }
@@ -221,8 +226,7 @@ export class TrianglesDataTextureSnapDepthBufInitRenderer {
221
226
 
222
227
  _buildVertexShader() {
223
228
  const scene = this._scene;
224
- const sectionPlanesState = scene._sectionPlanesState;
225
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
229
+ const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
226
230
  const src = [];
227
231
  src.push("#version 300 es");
228
232
  src.push("// TrianglesDataTextureSnapDepthBufInitRenderer vertex shader");
@@ -384,8 +388,7 @@ export class TrianglesDataTextureSnapDepthBufInitRenderer {
384
388
 
385
389
  _buildFragmentShader() {
386
390
  const scene = this._scene;
387
- const sectionPlanesState = scene._sectionPlanesState;
388
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
391
+ const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
389
392
  const src = [];
390
393
  src.push('#version 300 es');
391
394
  src.push("// TrianglesDataTextureSnapDepthBufInitRenderer fragment shader");
@@ -407,7 +410,7 @@ export class TrianglesDataTextureSnapDepthBufInitRenderer {
407
410
  src.push("flat in vec4 vPickColor;");
408
411
  if (clipping) {
409
412
  src.push("flat in uint vFlags2;");
410
- for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
413
+ for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
411
414
  src.push("uniform bool sectionPlaneActive" + i + ";");
412
415
  src.push("uniform vec3 sectionPlanePos" + i + ";");
413
416
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
@@ -422,7 +425,7 @@ export class TrianglesDataTextureSnapDepthBufInitRenderer {
422
425
  src.push(" bool clippable = vFlags2 > 0u;");
423
426
  src.push(" if (clippable) {");
424
427
  src.push(" float dist = 0.0;");
425
- for (var i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
428
+ for (var i = 0; i < scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
426
429
  src.push(" if (sectionPlaneActive" + i + ") {");
427
430
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
428
431
  src.push(" }");