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

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 +750 -598
  2. package/dist/xeokit-sdk.es.js +750 -598
  3. package/dist/xeokit-sdk.es5.js +227 -198
  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 +22 -21
  25. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureEdgesColorRenderer.js +7 -10
  26. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureEdgesRenderer.js +22 -19
  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 +59 -55
  31. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickNormalsFlatRenderer.js +22 -20
  32. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickNormalsRenderer.js +22 -18
  33. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureSilhouetteRenderer.js +22 -19
  34. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureSnapDepthBufInitRenderer.js +22 -19
  35. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureSnapDepthRenderer.js +22 -19
  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 +57 -11
  90. package/src/viewer/scene/sectionPlane/SectionPlaneCache.js +101 -0
@@ -99,25 +99,30 @@ export class TrianglesDataTextureDepthRenderer {
99
99
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
100
100
  }
101
101
 
102
+ const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
102
103
  const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
103
- if (numSectionPlanes > 0) {
104
+ if (numAllocatedSectionPlanes > 0) {
104
105
  const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
105
106
  const baseIndex = dataTextureLayer.layerIndex * numSectionPlanes;
106
107
  const renderFlags = model.renderFlags;
107
- for (let sectionPlaneIndex = 0; sectionPlaneIndex < numSectionPlanes; sectionPlaneIndex++) {
108
+ for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
108
109
  const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
109
110
  if (sectionPlaneUniforms) {
110
- const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + 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, tempVec3d);
116
- gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
117
- } else {
118
- gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
111
+ if (sectionPlaneIndex < numSectionPlanes) {
112
+ const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
113
+ gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
114
+ if (active) {
115
+ const sectionPlane = sectionPlanes[sectionPlaneIndex];
116
+ if (origin) {
117
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
118
+ gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
119
+ } else {
120
+ gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
121
+ }
122
+ gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
119
123
  }
120
- gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
124
+ } else {
125
+ gl.uniform1i(sectionPlaneUniforms.active, 0);
121
126
  }
122
127
  }
123
128
  }
@@ -180,7 +185,7 @@ export class TrianglesDataTextureDepthRenderer {
180
185
  this._uProjMatrix = program.getLocation("projMatrix");
181
186
  this._uSectionPlanes = [];
182
187
 
183
- for (let i = 0, len = scene._sectionPlanesState.sectionPlanes.length; i < len; i++) {
188
+ for (let i = 0, len = scene.getMaxSectionPlanes(); i < len; i++) {
184
189
  this._uSectionPlanes.push({
185
190
  active: program.getLocation("sectionPlaneActive" + i),
186
191
  pos: program.getLocation("sectionPlanePos" + i),
@@ -228,10 +233,7 @@ export class TrianglesDataTextureDepthRenderer {
228
233
 
229
234
  _buildVertexShader() {
230
235
  const scene = this._scene;
231
- const sectionPlanesState = scene._sectionPlanesState;
232
- const lightsState = scene._lightsState;
233
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
234
- let light;
236
+ const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
235
237
  const src = [];
236
238
  src.push("#version 300 es");
237
239
  src.push("// Triangles dataTexture draw vertex shader");
@@ -392,8 +394,7 @@ export class TrianglesDataTextureDepthRenderer {
392
394
 
393
395
  _buildFragmentShader() {
394
396
  const scene = this._scene;
395
- const sectionPlanesState = scene._sectionPlanesState;
396
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
397
+ const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
397
398
  const src = [];
398
399
  src.push('#version 300 es');
399
400
  src.push("// Triangles dataTexture draw fragment shader");
@@ -416,7 +417,7 @@ export class TrianglesDataTextureDepthRenderer {
416
417
  if (clipping) {
417
418
  src.push("in vec4 vWorldPosition;");
418
419
  src.push("flat in uint vFlags2;");
419
- for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
420
+ for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
420
421
  src.push("uniform bool sectionPlaneActive" + i + ";");
421
422
  src.push("uniform vec3 sectionPlanePos" + i + ";");
422
423
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
@@ -428,7 +429,7 @@ export class TrianglesDataTextureDepthRenderer {
428
429
  src.push(" bool clippable = vFlags2 > 0u;");
429
430
  src.push(" if (clippable) {");
430
431
  src.push(" float dist = 0.0;");
431
- for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
432
+ for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
432
433
  src.push("if (sectionPlaneActive" + i + ") {");
433
434
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
434
435
  src.push("}");
@@ -86,7 +86,7 @@ export class TrianglesDataTextureEdgesColorRenderer {
86
86
  gl.uniformMatrix4fv(this._uViewMatrix, false, rtcViewMatrix);
87
87
  gl.uniformMatrix4fv(this._uProjMatrix, false, camera.projMatrix);
88
88
 
89
- const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
89
+ const numSectionPlanes = scene.getMaxSectionPlanes();
90
90
  if (numSectionPlanes > 0) {
91
91
  const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
92
92
  const baseIndex = dataTextureLayer.layerIndex * numSectionPlanes;
@@ -166,7 +166,7 @@ export class TrianglesDataTextureEdgesColorRenderer {
166
166
  this._uProjMatrix = program.getLocation("projMatrix");
167
167
  this._uSectionPlanes = [];
168
168
 
169
- for (let i = 0, len = scene._sectionPlanesState.sectionPlanes.length; i < len; i++) {
169
+ for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
170
170
  this._uSectionPlanes.push({
171
171
  active: program.getLocation("sectionPlaneActive" + i),
172
172
  pos: program.getLocation("sectionPlanePos" + i),
@@ -212,8 +212,7 @@ export class TrianglesDataTextureEdgesColorRenderer {
212
212
 
213
213
  _buildVertexShader() {
214
214
  const scene = this._scene;
215
- const sectionPlanesState = scene._sectionPlanesState;
216
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
215
+ const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
217
216
  const src = [];
218
217
  src.push("#version 300 es");
219
218
  src.push("// TrianglesDataTextureEdgesColorRenderer");
@@ -350,8 +349,7 @@ export class TrianglesDataTextureEdgesColorRenderer {
350
349
 
351
350
  _buildFragmentShader() {
352
351
  const scene = this._scene;
353
- const sectionPlanesState = scene._sectionPlanesState;
354
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
352
+ const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
355
353
  const src = [];
356
354
  src.push('#version 300 es');
357
355
  src.push("// TrianglesDataTextureEdgesColorRenderer");
@@ -370,7 +368,7 @@ export class TrianglesDataTextureEdgesColorRenderer {
370
368
  if (clipping) {
371
369
  src.push("in vec4 vWorldPosition;");
372
370
  src.push("flat in uint vFlags2;");
373
- for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
371
+ for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
374
372
  src.push("uniform bool sectionPlaneActive" + i + ";");
375
373
  src.push("uniform vec3 sectionPlanePos" + i + ";");
376
374
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
@@ -383,7 +381,7 @@ export class TrianglesDataTextureEdgesColorRenderer {
383
381
  src.push(" bool clippable = vFlags2 > 0u;");
384
382
  src.push(" if (clippable) {");
385
383
  src.push(" float dist = 0.0;");
386
- for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
384
+ for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
387
385
  src.push("if (sectionPlaneActive" + i + ") {");
388
386
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
389
387
  src.push("}");
@@ -392,8 +390,7 @@ export class TrianglesDataTextureEdgesColorRenderer {
392
390
  src.push("}");
393
391
  }
394
392
  if (scene.logarithmicDepthBufferEnabled) {
395
- // src.push("gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");
396
- src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
393
+ src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
397
394
  }
398
395
  src.push(" outColor = vColor;");
399
396
  src.push("}");
@@ -112,25 +112,30 @@ export class TrianglesDataTextureEdgesRenderer {
112
112
  gl.uniform4fv(this._uColor, defaultColor);
113
113
  }
114
114
 
115
+ const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
115
116
  const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
116
- if (numSectionPlanes > 0) {
117
+ if (numAllocatedSectionPlanes > 0) {
117
118
  const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
118
119
  const baseIndex = dataTextureLayer.layerIndex * numSectionPlanes;
119
120
  const renderFlags = model.renderFlags;
120
- for (let sectionPlaneIndex = 0; sectionPlaneIndex < numSectionPlanes; sectionPlaneIndex++) {
121
+ for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
121
122
  const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
122
123
  if (sectionPlaneUniforms) {
123
- const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
124
- gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
125
- if (active) {
126
- const sectionPlane = sectionPlanes[sectionPlaneIndex];
127
- if (origin) {
128
- const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3d);
129
- gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
130
- } else {
131
- gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
124
+ if (sectionPlaneIndex < numSectionPlanes) {
125
+ const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
126
+ gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
127
+ if (active) {
128
+ const sectionPlane = sectionPlanes[sectionPlaneIndex];
129
+ if (origin) {
130
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
131
+ gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
132
+ } else {
133
+ gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
134
+ }
135
+ gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
132
136
  }
133
- gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
137
+ } else {
138
+ gl.uniform1i(sectionPlaneUniforms.active, 0);
134
139
  }
135
140
  }
136
141
  }
@@ -188,7 +193,7 @@ export class TrianglesDataTextureEdgesRenderer {
188
193
  this._uViewMatrix = program.getLocation("viewMatrix");
189
194
  this._uProjMatrix = program.getLocation("projMatrix");
190
195
  this._uSectionPlanes = [];
191
- for (let i = 0, len = scene._sectionPlanesState.sectionPlanes.length; i < len; i++) {
196
+ for (let i = 0, len = scene.getMaxSectionPlanes(); i < len; i++) {
192
197
  this._uSectionPlanes.push({
193
198
  active: program.getLocation("sectionPlaneActive" + i),
194
199
  pos: program.getLocation("sectionPlanePos" + i),
@@ -227,8 +232,7 @@ export class TrianglesDataTextureEdgesRenderer {
227
232
 
228
233
  _buildVertexShader() {
229
234
  const scene = this._scene;
230
- const sectionPlanesState = scene._sectionPlanesState;
231
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
235
+ const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
232
236
  const src = [];
233
237
  src.push("#version 300 es");
234
238
  src.push("// Batched geometry edges drawing vertex shader");
@@ -355,8 +359,7 @@ export class TrianglesDataTextureEdgesRenderer {
355
359
 
356
360
  _buildFragmentShader() {
357
361
  const scene = this._scene;
358
- const sectionPlanesState = scene._sectionPlanesState;
359
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
362
+ const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
360
363
  const src = [];
361
364
  src.push('#version 300 es');
362
365
  src.push("// Batched geometry edges drawing fragment shader");
@@ -378,7 +381,7 @@ export class TrianglesDataTextureEdgesRenderer {
378
381
  if (clipping) {
379
382
  src.push("in vec4 vWorldPosition;");
380
383
  src.push("flat in uint vFlags2;");
381
- for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
384
+ for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
382
385
  src.push("uniform bool sectionPlaneActive" + i + ";");
383
386
  src.push("uniform vec3 sectionPlanePos" + i + ";");
384
387
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
@@ -391,7 +394,7 @@ export class TrianglesDataTextureEdgesRenderer {
391
394
  src.push(" bool clippable = vFlags2 > 0u;");
392
395
  src.push(" if (clippable) {");
393
396
  src.push(" float dist = 0.0;");
394
- for (let i = 0, len = sectionPlanesState.sectionPlanes.length; i < len; i++) {
397
+ for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
395
398
  src.push("if (sectionPlaneActive" + i + ") {");
396
399
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
397
400
  src.push("}");
@@ -91,25 +91,30 @@ export class TrianglesDataTextureNormalsRenderer {
91
91
  gl.uniformMatrix4fv(this._uViewNormalMatrix, false, camera.viewNormalMatrix);
92
92
  gl.uniformMatrix4fv(this._uWorldNormalMatrix, false, model.worldNormalMatrix);
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, tempVec3d);
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
  }
@@ -147,7 +152,7 @@ export class TrianglesDataTextureNormalsRenderer {
147
152
  this._uViewNormalMatrix = program.getLocation("viewNormalMatrix");
148
153
  this._uProjMatrix = program.getLocation("projMatrix");
149
154
  this._uSectionPlanes = [];
150
- for (let i = 0, len = scene._sectionPlanesState.sectionPlanes.length; i < len; i++) {
155
+ for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
151
156
  this._uSectionPlanes.push({
152
157
  active: program.getLocation("sectionPlaneActive" + i),
153
158
  pos: program.getLocation("sectionPlanePos" + i),
@@ -188,7 +193,7 @@ export class TrianglesDataTextureNormalsRenderer {
188
193
 
189
194
  _buildVertexShader() {
190
195
  const scene = this._scene;
191
- const clipping = scene._sectionPlanesState.sectionPlanes.length > 0;
196
+ const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
192
197
  const src = [];
193
198
  src.push("// Batched geometry normals vertex shader");
194
199
  if (scene.logarithmicDepthBufferEnabled && WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]) {
@@ -270,8 +275,7 @@ export class TrianglesDataTextureNormalsRenderer {
270
275
 
271
276
  _buildFragmentShader() {
272
277
  const scene = this._scene;
273
- const sectionPlanesState = scene._sectionPlanesState;
274
- const clipping = (sectionPlanesState.sectionPlanes.length > 0);
278
+ const clipping = (scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0);
275
279
  const src = [];
276
280
  src.push("#version 300 es");
277
281
  src.push("// Batched geometry normals fragment shader");
@@ -297,7 +301,7 @@ export class TrianglesDataTextureNormalsRenderer {
297
301
  if (clipping) {
298
302
  src.push("in vec4 vWorldPosition;");
299
303
  src.push("in vec4 vFlags2;");
300
- for (let i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
304
+ for (let i = 0; i < scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
301
305
  src.push("uniform bool sectionPlaneActive" + i + ";");
302
306
  src.push("uniform vec3 sectionPlanePos" + i + ";");
303
307
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
@@ -312,7 +316,7 @@ export class TrianglesDataTextureNormalsRenderer {
312
316
  src.push(" bool clippable = (float(vFlags2.x) > 0.0);");
313
317
  src.push(" if (clippable) {");
314
318
  src.push(" float dist = 0.0;");
315
- for (var i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
319
+ for (var i = 0; i < scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
316
320
  src.push(" if (sectionPlaneActive" + i + ") {");
317
321
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
318
322
  src.push(" }");
@@ -106,25 +106,30 @@ export class TrianglesDataTextureOcclusionRenderer {
106
106
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
107
107
  }
108
108
 
109
+ const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
109
110
  const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
110
- if (numSectionPlanes > 0) {
111
+ if (numAllocatedSectionPlanes > 0) {
111
112
  const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
112
113
  const baseIndex = dataTextureLayer.layerIndex * numSectionPlanes;
113
114
  const renderFlags = model.renderFlags;
114
- for (let sectionPlaneIndex = 0; sectionPlaneIndex < numSectionPlanes; sectionPlaneIndex++) {
115
+ for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
115
116
  const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
116
117
  if (sectionPlaneUniforms) {
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, tempVec3d);
123
- gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
124
- } else {
125
- gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
118
+ if (sectionPlaneIndex < numSectionPlanes) {
119
+ const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
120
+ gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
121
+ if (active) {
122
+ const sectionPlane = sectionPlanes[sectionPlaneIndex];
123
+ if (origin) {
124
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
125
+ gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
126
+ } else {
127
+ gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
128
+ }
129
+ gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
126
130
  }
127
- gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
131
+ } else {
132
+ gl.uniform1i(sectionPlaneUniforms.active, 0);
128
133
  }
129
134
  }
130
135
  }
@@ -175,7 +180,7 @@ export class TrianglesDataTextureOcclusionRenderer {
175
180
  this._uViewMatrix = program.getLocation("viewMatrix");
176
181
  this._uProjMatrix = program.getLocation("projMatrix");
177
182
  this._uSectionPlanes = [];
178
- for (let i = 0, len = scene._sectionPlanesState.sectionPlanes.length; i < len; i++) {
183
+ for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
179
184
  this._uSectionPlanes.push({
180
185
  active: program.getLocation("sectionPlaneActive" + i),
181
186
  pos: program.getLocation("sectionPlanePos" + i),
@@ -220,7 +225,7 @@ export class TrianglesDataTextureOcclusionRenderer {
220
225
 
221
226
  _buildVertexShader() {
222
227
  const scene = this._scene;
223
- const clipping = scene._sectionPlanesState.sectionPlanes.length > 0;
228
+ const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
224
229
  const src = [];
225
230
  src.push("#version 300 es");
226
231
  src.push("// TrianglesDataTextureOcclusionRenderer vertex shader");
@@ -371,7 +376,7 @@ export class TrianglesDataTextureOcclusionRenderer {
371
376
  _buildFragmentShader() {
372
377
  const scene = this._scene;
373
378
  const sectionPlanesState = scene._sectionPlanesState;
374
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
379
+ const clipping = sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
375
380
  const src = [];
376
381
  src.push('#version 300 es');
377
382
  src.push("// TrianglesDataTextureColorRenderer fragment shader");
@@ -390,7 +395,7 @@ export class TrianglesDataTextureOcclusionRenderer {
390
395
  if (clipping) {
391
396
  src.push("in vec4 vWorldPosition;");
392
397
  src.push("flat in uint vFlags2;");
393
- for (let i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
398
+ for (let i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
394
399
  src.push("uniform bool sectionPlaneActive" + i + ";");
395
400
  src.push("uniform vec3 sectionPlanePos" + i + ";");
396
401
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
@@ -402,7 +407,7 @@ export class TrianglesDataTextureOcclusionRenderer {
402
407
  src.push(" bool clippable = (float(vFlags2) > 0.0);");
403
408
  src.push(" if (clippable) {");
404
409
  src.push(" float dist = 0.0;");
405
- for (let i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
410
+ for (let i = 0; i < sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
406
411
  src.push(" if (sectionPlaneActive" + i + ") {");
407
412
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
408
413
  src.push(" }");
@@ -106,25 +106,30 @@ export class TrianglesDataTexturePickDepthRenderer {
106
106
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
107
107
  }
108
108
 
109
+ const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
109
110
  const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
110
- if (numSectionPlanes > 0) {
111
+ if (numAllocatedSectionPlanes > 0) {
111
112
  const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
112
113
  const baseIndex = dataTextureLayer.layerIndex * numSectionPlanes;
113
114
  const renderFlags = model.renderFlags;
114
- for (let sectionPlaneIndex = 0; sectionPlaneIndex < numSectionPlanes; sectionPlaneIndex++) {
115
+ for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
115
116
  const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
116
117
  if (sectionPlaneUniforms) {
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, tempVec3d);
123
- gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
124
- } else {
125
- gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
118
+ if (sectionPlaneIndex < numSectionPlanes) {
119
+ const active = renderFlags.sectionPlanesActivePerLayer[baseIndex + sectionPlaneIndex];
120
+ gl.uniform1i(sectionPlaneUniforms.active, active ? 1 : 0);
121
+ if (active) {
122
+ const sectionPlane = sectionPlanes[sectionPlaneIndex];
123
+ if (origin) {
124
+ const rtcSectionPlanePos = getPlaneRTCPos(sectionPlane.dist, sectionPlane.dir, origin, tempVec3a);
125
+ gl.uniform3fv(sectionPlaneUniforms.pos, rtcSectionPlanePos);
126
+ } else {
127
+ gl.uniform3fv(sectionPlaneUniforms.pos, sectionPlane.pos);
128
+ }
129
+ gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
126
130
  }
127
- gl.uniform3fv(sectionPlaneUniforms.dir, sectionPlane.dir);
131
+ } else {
132
+ gl.uniform1i(sectionPlaneUniforms.active, 0);
128
133
  }
129
134
  }
130
135
  }
@@ -176,7 +181,7 @@ export class TrianglesDataTexturePickDepthRenderer {
176
181
  this._uViewMatrix = program.getLocation("viewMatrix");
177
182
  this._uProjMatrix = program.getLocation("projMatrix");
178
183
  this._uSectionPlanes = [];
179
- for (let i = 0, len = scene._sectionPlanesState.sectionPlanes.length; i < len; i++) {
184
+ for (let i = 0, len = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
180
185
  this._uSectionPlanes.push({
181
186
  active: program.getLocation("sectionPlaneActive" + i),
182
187
  pos: program.getLocation("sectionPlanePos" + i),
@@ -212,7 +217,7 @@ export class TrianglesDataTexturePickDepthRenderer {
212
217
  _buildVertexShader() {
213
218
 
214
219
  const scene = this._scene;
215
- const clipping = scene._sectionPlanesState.sectionPlanes.length > 0;
220
+ const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
216
221
  const src = [];
217
222
  src.push("#version 300 es");
218
223
  src.push("// Triangles dataTexture pick depth vertex shader");
@@ -380,8 +385,7 @@ export class TrianglesDataTexturePickDepthRenderer {
380
385
  _buildFragmentShader() {
381
386
 
382
387
  const scene = this._scene;
383
- const sectionPlanesState = scene._sectionPlanesState;
384
- const clipping = sectionPlanesState.sectionPlanes.length > 0;
388
+ const clipping = scene._sectionPlanesState.getNumAllocatedSectionPlanes() > 0;
385
389
  const src = [];
386
390
  src.push('#version 300 es');
387
391
  src.push("// Triangles dataTexture pick depth fragment shader");
@@ -406,7 +410,7 @@ export class TrianglesDataTexturePickDepthRenderer {
406
410
  if (clipping) {
407
411
  src.push("in vec4 vWorldPosition;");
408
412
  src.push("flat in uint vFlags2;");
409
- for (var i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
413
+ for (var i = 0; i < scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
410
414
  src.push("uniform bool sectionPlaneActive" + i + ";");
411
415
  src.push("uniform vec3 sectionPlanePos" + i + ";");
412
416
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
@@ -427,7 +431,7 @@ export class TrianglesDataTexturePickDepthRenderer {
427
431
  src.push(" bool clippable = vFlags2 > 0u;");
428
432
  src.push(" if (clippable) {");
429
433
  src.push(" float dist = 0.0;");
430
- for (var i = 0; i < sectionPlanesState.sectionPlanes.length; i++) {
434
+ for (var i = 0; i < scene._sectionPlanesState.getNumAllocatedSectionPlanes(); i++) {
431
435
  src.push(" if (sectionPlaneActive" + i + ") {");
432
436
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
433
437
  src.push(" }");