@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xeokit/xeokit-sdk",
3
- "version": "2.4.2-beta-21",
3
+ "version": "2.4.2-beta-22",
4
4
  "description": "Web Programming Toolkit for 3D/2D BIM and AEC Graphics",
5
5
  "module": "./dist/xeokit-sdk.es.js",
6
6
  "main": "./dist/xeokit-sdk.cjs.js",
@@ -57,6 +57,11 @@ class Viewer {
57
57
  * store geometry on the GPU for triangle meshes that don't have textures. This gives a much lower memory footprint for these types of model element. This mode may not perform well on low-end GPUs that are optimized
58
58
  * to use textures to hold geometry data. Works great on most medium/high-end GPUs found in desktop computers, including the nVIDIA and Intel HD chipsets. Set this false to use the default vertex buffer object (VBO)
59
59
  * mode for storing geometry, which is the standard technique used in most graphics engines, and will work adequately on most low-end GPUs.
60
+ * @param {number} [cfg.numPreallocatedSectionPlanes=0] Enhances the efficiency of SectionPlane creation by proactively allocating Viewer resources for a specified quantity
61
+ * of SectionPlanes. Introducing this parameter streamlines the initial creation speed of SectionPlanes, particularly up to the designated quantity. This parameter internally
62
+ * configures renderer logic for the specified number of SectionPlanes, eliminating the need for setting up logic with each SectionPlane creation and thereby enhancing
63
+ * responsiveness. It is important to consider that each SectionPlane impacts rendering performance, so it is recommended to set this value to a quantity that aligns with
64
+ * your expected usage.
60
65
  */
61
66
  constructor(cfg) {
62
67
 
@@ -114,7 +119,8 @@ class Viewer {
114
119
  logarithmicDepthBufferEnabled: (!!cfg.logarithmicDepthBufferEnabled),
115
120
  pbrEnabled: (!!cfg.pbrEnabled),
116
121
  colorTextureEnabled: (cfg.colorTextureEnabled !== false),
117
- dtxEnabled: (!!cfg.dtxEnabled)
122
+ dtxEnabled: (!!cfg.dtxEnabled),
123
+ numPreallocatedSectionPlanes: cfg.numPreallocatedSectionPlanes
118
124
  });
119
125
 
120
126
  /**
@@ -98,19 +98,29 @@ DrawRenderer.prototype.drawMesh = function (frameCtx, mesh) {
98
98
  gl.uniformMatrix4fv(this._uViewNormalMatrix, false, camera.viewNormalMatrix);
99
99
 
100
100
  if (meshState.clippable) {
101
+ const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
101
102
  const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
102
- if (numSectionPlanes > 0) {
103
+ if (numAllocatedSectionPlanes > 0) {
103
104
  const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
104
105
  const renderFlags = mesh.renderFlags;
105
- for (let sectionPlaneIndex = 0; sectionPlaneIndex < numSectionPlanes; sectionPlaneIndex++) {
106
+ for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
106
107
  const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
107
108
  if (sectionPlaneUniforms) {
108
- const active = renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];
109
- gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
110
- if (active) {
111
- const sectionPlane = sectionPlanes[sectionPlaneIndex];
112
- gl.uniform3fv(sectionPlaneUniforms.pos, origin ? getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a) : sectionPlane.pos);
113
- gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
109
+ if (sectionPlaneIndex < numSectionPlanes) {
110
+ const active = renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];
111
+ gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
112
+ if (active) {
113
+ const sectionPlane = sectionPlanes[sectionPlaneIndex];
114
+ if (origin) {
115
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
116
+ gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
117
+ } else {
118
+ gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
119
+ }
120
+ gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
121
+ }
122
+ } else {
123
+ gl.uniform1i(sectionPlaneUniforms.active, 0);
114
124
  }
115
125
  }
116
126
  }
@@ -71,7 +71,7 @@ function buildVertexLambert(mesh) {
71
71
  const geometryState = mesh._geometry._state;
72
72
  const billboard = mesh._state.billboard;
73
73
  const stationary = mesh._state.stationary;
74
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
74
+ const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
75
75
  const quantizedGeometry = !!geometryState.compressGeometry;
76
76
 
77
77
  const src = [];
@@ -248,7 +248,7 @@ function buildFragmentLambert(mesh) {
248
248
  const sectionPlanesState = scene._sectionPlanesState;
249
249
  const materialState = mesh._material._state;
250
250
  const geometryState = mesh._geometry._state;
251
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
251
+ const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
252
252
  const solid = false && materialState.backfaces;
253
253
  const gammaOutput = scene.gammaOutput; // If set, then it expects that all textures and colors need to be outputted in premultiplied gamma. Default is false.
254
254
  const src = [];
@@ -269,7 +269,7 @@ function buildFragmentLambert(mesh) {
269
269
  if (clipping) {
270
270
  src.push("in vec4 vWorldPosition;");
271
271
  src.push("uniform bool clippable;");
272
- for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
272
+ for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
273
273
  src.push("uniform bool sectionPlaneActive" + i + ";");
274
274
  src.push("uniform vec3 sectionPlanePos" + i + ";");
275
275
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
@@ -287,7 +287,7 @@ function buildFragmentLambert(mesh) {
287
287
  if (clipping) {
288
288
  src.push("if (clippable) {");
289
289
  src.push(" float dist = 0.0;");
290
- for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
290
+ for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
291
291
  src.push("if (sectionPlaneActive" + i + ") {");
292
292
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
293
293
  src.push("}");
@@ -336,7 +336,7 @@ function buildVertexDraw(mesh) {
336
336
  const stationary = meshState.stationary;
337
337
  const texturing = hasTextures(mesh);
338
338
  const normals = hasNormals(mesh);
339
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
339
+ const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
340
340
  const receivesShadow = getReceivesShadow(mesh);
341
341
  const quantizedGeometry = !!geometryState.compressGeometry;
342
342
  const src = [];
@@ -558,7 +558,7 @@ function buildFragmentDraw(mesh) {
558
558
  const sectionPlanesState = mesh.scene._sectionPlanesState;
559
559
  const lightsState = mesh.scene._lightsState;
560
560
  const materialState = mesh._material._state;
561
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
561
+ const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
562
562
  const normals = hasNormals(mesh);
563
563
  const uvs = geometryState.uvBuf;
564
564
  const solid = false && materialState.backfaces;
@@ -622,7 +622,7 @@ function buildFragmentDraw(mesh) {
622
622
  if (clipping) {
623
623
  src.push("in vec4 vWorldPosition;");
624
624
  src.push("uniform bool clippable;");
625
- for (var i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
625
+ for (var i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
626
626
  src.push("uniform bool sectionPlaneActive" + i + ";");
627
627
  src.push("uniform vec3 sectionPlanePos" + i + ";");
628
628
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
@@ -1112,7 +1112,7 @@ function buildFragmentDraw(mesh) {
1112
1112
  if (clipping) {
1113
1113
  src.push("if (clippable) {");
1114
1114
  src.push(" float dist = 0.0;");
1115
- for (var i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
1115
+ for (var i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
1116
1116
  src.push("if (sectionPlaneActive" + i + ") {");
1117
1117
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
1118
1118
  src.push("}");
@@ -83,19 +83,29 @@ EmphasisEdgesRenderer.prototype.drawMesh = function (frameCtx, mesh, mode) {
83
83
  gl.uniformMatrix4fv(this._uViewMatrix, false, origin ? frameCtx.getRTCViewMatrix(meshState.originHash, origin) : camera.viewMatrix);
84
84
 
85
85
  if (meshState.clippable) {
86
+ const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
86
87
  const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
87
- if (numSectionPlanes > 0) {
88
+ if (numAllocatedSectionPlanes > 0) {
88
89
  const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
89
90
  const renderFlags = mesh.renderFlags;
90
- for (let sectionPlaneIndex = 0; sectionPlaneIndex < numSectionPlanes; sectionPlaneIndex++) {
91
+ for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
91
92
  const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
92
93
  if (sectionPlaneUniforms) {
93
- const active = renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];
94
- gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
95
- if (active) {
96
- const sectionPlane = sectionPlanes[sectionPlaneIndex];
97
- gl.uniform3fv(sectionPlaneUniforms.pos, origin ? getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a) : sectionPlane.pos);
98
- gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
94
+ if (sectionPlaneIndex < numSectionPlanes) {
95
+ const active = renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];
96
+ gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
97
+ if (active) {
98
+ const sectionPlane = sectionPlanes[sectionPlaneIndex];
99
+ if (origin) {
100
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
101
+ gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
102
+ } else {
103
+ gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
104
+ }
105
+ gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
106
+ }
107
+ } else {
108
+ gl.uniform1i(sectionPlaneUniforms.active, 0);
99
109
  }
100
110
  }
101
111
  }
@@ -196,7 +206,7 @@ EmphasisEdgesRenderer.prototype._allocate = function (mesh) {
196
206
  this._uViewMatrix = program.getLocation("viewMatrix");
197
207
  this._uProjMatrix = program.getLocation("projMatrix");
198
208
  this._uSectionPlanes = [];
199
- for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
209
+ for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
200
210
  this._uSectionPlanes.push({
201
211
  active: program.getLocation("sectionPlaneActive" + i),
202
212
  pos: program.getLocation("sectionPlanePos" + i),
@@ -98,7 +98,7 @@ function buildFragment(mesh) {
98
98
  const scene = mesh.scene;
99
99
  const sectionPlanesState = mesh.scene._sectionPlanesState;
100
100
  const gammaOutput = mesh.scene.gammaOutput;
101
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
101
+ const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
102
102
  const src = [];
103
103
  src.push("#version 300 es");
104
104
  src.push("// Edges drawing fragment shader");
@@ -123,7 +123,7 @@ function buildFragment(mesh) {
123
123
  if (clipping) {
124
124
  src.push("in vec4 vWorldPosition;");
125
125
  src.push("uniform bool clippable;");
126
- for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
126
+ for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
127
127
  src.push("uniform bool sectionPlaneActive" + i + ";");
128
128
  src.push("uniform vec3 sectionPlanePos" + i + ";");
129
129
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
@@ -135,7 +135,7 @@ function buildFragment(mesh) {
135
135
  if (clipping) {
136
136
  src.push("if (clippable) {");
137
137
  src.push(" float dist = 0.0;");
138
- for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
138
+ for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
139
139
  src.push("if (sectionPlaneActive" + i + ") {");
140
140
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
141
141
  src.push("}");
@@ -84,19 +84,29 @@ EmphasisFillRenderer.prototype.drawMesh = function (frameCtx, mesh, mode) {
84
84
  gl.uniformMatrix4fv(this._uViewNormalMatrix, false, camera.viewNormalMatrix);
85
85
 
86
86
  if (meshState.clippable) {
87
+ const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
87
88
  const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
88
- if (numSectionPlanes > 0) {
89
+ if (numAllocatedSectionPlanes > 0) {
89
90
  const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
90
91
  const renderFlags = mesh.renderFlags;
91
- for (let sectionPlaneIndex = 0; sectionPlaneIndex < numSectionPlanes; sectionPlaneIndex++) {
92
+ for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
92
93
  const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
93
94
  if (sectionPlaneUniforms) {
94
- const active = renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];
95
- gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
96
- if (active) {
97
- const sectionPlane = sectionPlanes[sectionPlaneIndex];
98
- gl.uniform3fv(sectionPlaneUniforms.pos, origin ? getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a) : sectionPlane.pos);
99
- gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
95
+ if (sectionPlaneIndex < numSectionPlanes) {
96
+ const active = renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];
97
+ gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
98
+ if (active) {
99
+ const sectionPlane = sectionPlanes[sectionPlaneIndex];
100
+ if (origin) {
101
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
102
+ gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
103
+ } else {
104
+ gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
105
+ }
106
+ gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
107
+ }
108
+ } else {
109
+ gl.uniform1i(sectionPlaneUniforms.active, 0);
100
110
  }
101
111
  }
102
112
  }
@@ -208,7 +218,7 @@ EmphasisFillRenderer.prototype._allocate = function (mesh) {
208
218
  }
209
219
  }
210
220
  this._uSectionPlanes = [];
211
- for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
221
+ for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
212
222
  this._uSectionPlanes.push({
213
223
  active: program.getLocation("sectionPlaneActive" + i),
214
224
  pos: program.getLocation("sectionPlanePos" + i),
@@ -192,7 +192,7 @@ function buildFragment(mesh) {
192
192
  const scene = mesh.scene;
193
193
  const sectionPlanesState = mesh.scene._sectionPlanesState;
194
194
  const gammaOutput = mesh.scene.gammaOutput;
195
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
195
+ const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
196
196
  const src = [];
197
197
  src.push("#version 300 es");
198
198
  src.push("// Lambertian drawing fragment shader");
@@ -219,7 +219,7 @@ function buildFragment(mesh) {
219
219
  if (clipping) {
220
220
  src.push("in vec4 vWorldPosition;");
221
221
  src.push("uniform bool clippable;");
222
- for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
222
+ for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
223
223
  src.push("uniform bool sectionPlaneActive" + i + ";");
224
224
  src.push("uniform vec3 sectionPlanePos" + i + ";");
225
225
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
@@ -231,7 +231,7 @@ function buildFragment(mesh) {
231
231
  if (clipping) {
232
232
  src.push("if (clippable) {");
233
233
  src.push(" float dist = 0.0;");
234
- for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
234
+ for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
235
235
  src.push("if (sectionPlaneActive" + i + ") {");
236
236
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
237
237
  src.push("}");
@@ -105,19 +105,29 @@ OcclusionRenderer.prototype.drawMesh = function (frameCtx, mesh) {
105
105
  gl.uniformMatrix4fv(this._uViewMatrix, false, origin ? frameCtx.getRTCViewMatrix(meshState.originHash, origin) : camera.viewMatrix);
106
106
 
107
107
  if (meshState.clippable) {
108
+ const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
108
109
  const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
109
- if (numSectionPlanes > 0) {
110
+ if (numAllocatedSectionPlanes > 0) {
110
111
  const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
111
112
  const renderFlags = mesh.renderFlags;
112
- for (let sectionPlaneIndex = 0; sectionPlaneIndex < numSectionPlanes; sectionPlaneIndex++) {
113
+ for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
113
114
  const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
114
115
  if (sectionPlaneUniforms) {
115
- const active = renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];
116
- gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
117
- if (active) {
118
- const sectionPlane = sectionPlanes[sectionPlaneIndex];
119
- gl.uniform3fv(sectionPlaneUniforms.pos, origin ? getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a) : sectionPlane.pos);
120
- gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
116
+ if (sectionPlaneIndex < numSectionPlanes) {
117
+ const active = renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];
118
+ gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
119
+ if (active) {
120
+ const sectionPlane = sectionPlanes[sectionPlaneIndex];
121
+ if (origin) {
122
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
123
+ gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
124
+ } else {
125
+ gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
126
+ }
127
+ gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
128
+ }
129
+ } else {
130
+ gl.uniform1i(sectionPlaneUniforms.active, 0);
121
131
  }
122
132
  }
123
133
  }
@@ -98,7 +98,7 @@ function buildFragment(mesh) {
98
98
 
99
99
  const scene = mesh.scene;
100
100
  const sectionPlanesState = scene._sectionPlanesState;
101
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
101
+ const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
102
102
  const src = [];
103
103
  src.push('#version 300 es');
104
104
  src.push("// Mesh occlusion fragment shader");
@@ -119,7 +119,7 @@ function buildFragment(mesh) {
119
119
  if (clipping) {
120
120
  src.push("uniform bool clippable;");
121
121
  src.push("in vec4 vWorldPosition;");
122
- for (var i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
122
+ for (var i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
123
123
  src.push("uniform bool sectionPlaneActive" + i + ";");
124
124
  src.push("uniform vec3 sectionPlanePos" + i + ";");
125
125
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
@@ -133,7 +133,7 @@ function buildFragment(mesh) {
133
133
  if (clipping) {
134
134
  src.push("if (clippable) {");
135
135
  src.push(" float dist = 0.0;");
136
- for (var i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
136
+ for (var i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
137
137
  src.push("if (sectionPlaneActive" + i + ") {");
138
138
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
139
139
  src.push("}");
@@ -81,19 +81,29 @@ PickMeshRenderer.prototype.drawMesh = function (frameCtx, mesh) {
81
81
  gl.uniformMatrix4fv(this._uViewMatrix, false, origin ? frameCtx.getRTCPickViewMatrix(meshState.originHash, origin) : frameCtx.pickViewMatrix);
82
82
 
83
83
  if (meshState.clippable) {
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 renderFlags = mesh.renderFlags;
88
- for (let sectionPlaneIndex = 0; sectionPlaneIndex < numSectionPlanes; sectionPlaneIndex++) {
89
+ for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
89
90
  const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
90
91
  if (sectionPlaneUniforms) {
91
- const active = renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];
92
- gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
93
- if (active) {
94
- const sectionPlane = sectionPlanes[sectionPlaneIndex];
95
- gl.uniform3fv(sectionPlaneUniforms.pos, origin ? getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a) : sectionPlane.pos);
96
- gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
92
+ if (sectionPlaneIndex < numSectionPlanes) {
93
+ const active = renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];
94
+ gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
95
+ if (active) {
96
+ const sectionPlane = sectionPlanes[sectionPlaneIndex];
97
+ if (origin) {
98
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
99
+ gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
100
+ } else {
101
+ gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
102
+ }
103
+ gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
104
+ }
105
+ } else {
106
+ gl.uniform1i(sectionPlaneUniforms.active, 0);
97
107
  }
98
108
  }
99
109
  }
@@ -100,7 +100,7 @@ function buildVertex(mesh) {
100
100
  function buildFragment(mesh) {
101
101
  const scene = mesh.scene;
102
102
  const sectionPlanesState = scene._sectionPlanesState;
103
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
103
+ const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
104
104
  const src = [];
105
105
  src.push('#version 300 es');
106
106
  src.push("// Mesh picking fragment shader");
@@ -120,7 +120,7 @@ function buildFragment(mesh) {
120
120
  if (clipping) {
121
121
  src.push("uniform bool clippable;");
122
122
  src.push("in vec4 vWorldPosition;");
123
- for (var i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
123
+ for (var i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
124
124
  src.push("uniform bool sectionPlaneActive" + i + ";");
125
125
  src.push("uniform vec3 sectionPlanePos" + i + ";");
126
126
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
@@ -131,7 +131,7 @@ function buildFragment(mesh) {
131
131
  if (clipping) {
132
132
  src.push("if (clippable) {");
133
133
  src.push(" float dist = 0.0;");
134
- for (var i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
134
+ for (var i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
135
135
  src.push("if (sectionPlaneActive" + i + ") {");
136
136
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
137
137
  src.push("}");
@@ -89,19 +89,29 @@ PickTriangleRenderer.prototype.drawMesh = function (frameCtx, mesh) {
89
89
  gl.uniformMatrix4fv(this._uViewMatrix, false, origin ? frameCtx.getRTCPickViewMatrix(meshState.originHash, origin) : frameCtx.pickViewMatrix);
90
90
 
91
91
  if (meshState.clippable) {
92
+ const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
92
93
  const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
93
- if (numSectionPlanes > 0) {
94
+ if (numAllocatedSectionPlanes > 0) {
94
95
  const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
95
96
  const renderFlags = mesh.renderFlags;
96
- for (let sectionPlaneIndex = 0; sectionPlaneIndex < numSectionPlanes; sectionPlaneIndex++) {
97
+ for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
97
98
  const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
98
99
  if (sectionPlaneUniforms) {
99
- const active = renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];
100
- gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
101
- if (active) {
102
- const sectionPlane = sectionPlanes[sectionPlaneIndex];
103
- gl.uniform3fv(sectionPlaneUniforms.pos, origin ? getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a) : sectionPlane.pos);
104
- gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
100
+ if (sectionPlaneIndex < numSectionPlanes) {
101
+ const active = renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];
102
+ gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
103
+ if (active) {
104
+ const sectionPlane = sectionPlanes[sectionPlaneIndex];
105
+ if (origin) {
106
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
107
+ gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
108
+ } else {
109
+ gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
110
+ }
111
+ gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
112
+ }
113
+ } else {
114
+ gl.uniform1i(sectionPlaneUniforms.active, 0);
105
115
  }
106
116
  }
107
117
  }
@@ -73,7 +73,7 @@ function buildVertex(mesh) {
73
73
  function buildFragment(mesh) {
74
74
  const scene = mesh.scene;
75
75
  const sectionPlanesState = scene._sectionPlanesState;
76
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
76
+ const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
77
77
  const src = [];
78
78
  src.push('#version 300 es');
79
79
  src.push("// Surface picking fragment shader");
@@ -93,7 +93,7 @@ function buildFragment(mesh) {
93
93
  if (clipping) {
94
94
  src.push("uniform bool clippable;");
95
95
  src.push("in vec4 vWorldPosition;");
96
- for (let i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
96
+ for (let i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
97
97
  src.push("uniform bool sectionPlaneActive" + i + ";");
98
98
  src.push("uniform vec3 sectionPlanePos" + i + ";");
99
99
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
@@ -104,7 +104,7 @@ function buildFragment(mesh) {
104
104
  if (clipping) {
105
105
  src.push("if (clippable) {");
106
106
  src.push(" float dist = 0.0;");
107
- for (let i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
107
+ for (let i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
108
108
  src.push("if (sectionPlaneActive" + i + ") {");
109
109
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
110
110
  src.push("}");
@@ -186,7 +186,7 @@ ShadowRenderer.prototype._bindProgram = function (frame) {
186
186
  this._lastMaterialId = null;
187
187
  this._lastVertexBufsId = null;
188
188
  this._lastGeometryId = null;
189
- if (sectionPlanesState.sectionPlanes.length > 0) {
189
+ if (sectionPlanesState.getNumAllocatedSectionPlanes() > 0) {
190
190
  let sectionPlaneUniforms;
191
191
  let uSectionPlaneActive;
192
192
  let sectionPlane;
@@ -46,7 +46,7 @@ function buildFragment(mesh) {
46
46
  const scene = mesh.scene;
47
47
  const gl = scene.canvas.gl;
48
48
  const sectionPlanesState = scene._sectionPlanesState;
49
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
49
+ const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
50
50
  const src = [];
51
51
  src.push("// Mesh shadow fragment shader");
52
52
 
@@ -61,7 +61,7 @@ function buildFragment(mesh) {
61
61
  if (clipping) {
62
62
  src.push("uniform bool clippable;");
63
63
  src.push("in vec4 vWorldPosition;");
64
- for (var i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
64
+ for (var i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
65
65
  src.push("uniform bool sectionPlaneActive" + i + ";");
66
66
  src.push("uniform vec3 sectionPlanePos" + i + ";");
67
67
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
@@ -82,7 +82,7 @@ function buildFragment(mesh) {
82
82
  if (clipping) {
83
83
  src.push("if (clippable) {");
84
84
  src.push(" float dist = 0.0;");
85
- for (var i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
85
+ for (var i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
86
86
  src.push("if (sectionPlaneActive" + i + ") {");
87
87
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
88
88
  src.push("}");
@@ -104,25 +104,30 @@ export class TrianglesDataTextureColorRenderer {
104
104
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
105
105
  }
106
106
 
107
+ const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
107
108
  const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
108
- if (numSectionPlanes > 0) {
109
+ if (numAllocatedSectionPlanes > 0) {
109
110
  const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
110
111
  const baseIndex = dataTextureLayer.layerIndex * numSectionPlanes;
111
112
  const renderFlags = model.renderFlags;
112
- for (let sectionPlaneIndex = 0; sectionPlaneIndex < numSectionPlanes; sectionPlaneIndex++) {
113
+ for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
113
114
  const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
114
115
  if (sectionPlaneUniforms) {
115
- const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
116
- gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
117
- if (active) {
118
- const sectionPlane = sectionPlanes[sectionPlaneIndex];
119
- if (origin) {
120
- const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3d);
121
- gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
122
- } else {
123
- gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
116
+ if (sectionPlaneIndex < numSectionPlanes) {
117
+ const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
118
+ gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
119
+ if (active) {
120
+ const sectionPlane = sectionPlanes[sectionPlaneIndex];
121
+ if (origin) {
122
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
123
+ gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
124
+ } else {
125
+ gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
126
+ }
127
+ gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
124
128
  }
125
- gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
129
+ } else {
130
+ gl.uniform1i(sectionPlaneUniforms.active, 0);
126
131
  }
127
132
  }
128
133
  }
@@ -217,7 +222,7 @@ export class TrianglesDataTextureColorRenderer {
217
222
 
218
223
  this._uSectionPlanes = [];
219
224
 
220
- for (let i = 0, len = scene._sectionPlanesState.sectionPlanes.length; i < len; i++) {
225
+ for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
221
226
  this._uSectionPlanes.push({
222
227
  active: program.getLocation("sectionPlaneActive" + i),
223
228
  pos: program.getLocation("sectionPlanePos" + i),
@@ -307,7 +312,7 @@ export class TrianglesDataTextureColorRenderer {
307
312
  const scene = this._scene;
308
313
  const sectionPlanesState = scene._sectionPlanesState;
309
314
  const lightsState = scene._lightsState;
310
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
315
+ const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
311
316
  let light;
312
317
  const src = [];
313
318
  src.push("#version 300 es");
@@ -518,7 +523,7 @@ export class TrianglesDataTextureColorRenderer {
518
523
  _buildFragmentShader() {
519
524
  const scene = this._scene;
520
525
  const sectionPlanesState = scene._sectionPlanesState;
521
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
526
+ const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
522
527
  const src = [];
523
528
  src.push('#version 300 es');
524
529
  src.push("// TrianglesDataTextureColorRenderer fragment shader");
@@ -552,7 +557,7 @@ export class TrianglesDataTextureColorRenderer {
552
557
  if (clipping) {
553
558
  src.push("in vec4 vWorldPosition;");
554
559
  src.push("flat in uint vFlags2;");
555
- for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
560
+ for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
556
561
  src.push("uniform bool sectionPlaneActive" + i + ";");
557
562
  src.push("uniform vec3 sectionPlanePos" + i + ";");
558
563
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
@@ -566,7 +571,7 @@ export class TrianglesDataTextureColorRenderer {
566
571
  src.push(" bool clippable = vFlags2 > 0u;");
567
572
  src.push(" if (clippable) {");
568
573
  src.push(" float dist = 0.0;");
569
- for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
574
+ for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
570
575
  src.push("if (sectionPlaneActive" + i + ") {");
571
576
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
572
577
  src.push("}");