@xeokit/xeokit-sdk 2.6.6 → 2.6.8

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 (28) hide show
  1. package/README.md +20 -14
  2. package/dist/xeokit-sdk.cjs.js +317 -46
  3. package/dist/xeokit-sdk.es.js +317 -46
  4. package/dist/xeokit-sdk.es5.js +847 -696
  5. package/dist/xeokit-sdk.min.cjs.js +5 -5
  6. package/dist/xeokit-sdk.min.es.js +5 -5
  7. package/dist/xeokit-sdk.min.es5.js +4 -4
  8. package/package.json +1 -1
  9. package/src/viewer/scene/model/vbo/VBORenderer.js +10 -1
  10. package/src/viewer/scene/model/vbo/batching/triangles/renderers/EdgesColorRenderer.js +2 -2
  11. package/src/viewer/scene/model/vbo/batching/triangles/renderers/EdgesEmphasisRenderer.js +3 -3
  12. package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesColorRenderer.js +14 -8
  13. package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesColorTextureRenderer.js +10 -4
  14. package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesFlatColorRenderer.js +10 -4
  15. package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesSilhouetteRenderer.js +16 -8
  16. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/EdgesColorRenderer.js +1 -2
  17. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/EdgesEmphasisRenderer.js +1 -1
  18. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesColorRenderer.js +10 -4
  19. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesColorTextureRenderer.js +12 -6
  20. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesFlatColorRenderer.js +17 -11
  21. package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesSilhouetteRenderer.js +15 -6
  22. package/src/viewer/scene/postfx/CrossSections.js +203 -0
  23. package/src/viewer/scene/scene/Scene.js +10 -1
  24. package/types/plugins/AngleMeasurementsPlugin/AngleMeasurementsMouseControl.d.ts +3 -1
  25. package/types/plugins/AngleMeasurementsPlugin/AngleMeasurementsTouchControl.d.ts +2 -0
  26. package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsMouseControl.d.ts +2 -0
  27. package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsTouchControl.d.ts +2 -0
  28. package/types/viewer/scene/postfx/CrossSections.d.ts +42 -0
@@ -28405,6 +28405,206 @@ class SAO extends Component {
28405
28405
  }
28406
28406
  }
28407
28407
 
28408
+ /**
28409
+ * @desc Configures cross-section slices for a {@link Scene}.
28410
+ *
28411
+ * ## Overview
28412
+ *
28413
+ * Cross-sections allow to create an additional colored slice for used clipping planes. It is only a visual effect
28414
+ * calculated by shaders. It makes it easier to see the intersection between the model and the clipping plane this way.
28415
+ *
28416
+ * ## Usage
28417
+ *
28418
+ * In the example below, we'll configure CrossSections to manipulate the slice representation.
28419
+ *
28420
+ * ````javascript
28421
+ * //------------------------------------------------------------------------------------------------------------------
28422
+ * // Import the modules we need for this example
28423
+ * //------------------------------------------------------------------------------------------------------------------
28424
+ *
28425
+ * import {PhongMaterial, Viewer, math, SectionPlanesPlugin, XKTLoaderPlugin, Mesh, ReadableGeometry, buildPolylineGeometryFromCurve, SplineCurve} from "../../dist/xeokit-sdk.es.js";
28426
+ *
28427
+ * //------------------------------------------------------------------------------------------------------------------
28428
+ * // Create a Viewer and arrange the camera
28429
+ * //------------------------------------------------------------------------------------------------------------------
28430
+ *
28431
+ * const viewer = new Viewer({
28432
+ * canvasId: "myCanvas",
28433
+ * transparent: true
28434
+ * });
28435
+ *
28436
+ * viewer.camera.eye = [-2.341298674548419, 22.43987089731119, 7.236688436028655];
28437
+ * viewer.camera.look = [4.399999999999963, 3.7240000000000606, 8.899000000000006];
28438
+ * viewer.camera.up = [0.9102954845584759, 0.34781746407929504, 0.22446635042673466];
28439
+ *
28440
+ * const cameraControl = viewer.cameraControl;
28441
+ * cameraControl.navMode = "orbit";
28442
+ * cameraControl.followPointer = true;
28443
+ *
28444
+ * //----------------------------------------------------------------------------------------------------------------------
28445
+ * // Create a xeokit loader plugin, load a model, fit to view
28446
+ * //----------------------------------------------------------------------------------------------------------------------
28447
+ *
28448
+ * const xktLoader = new XKTLoaderPlugin(viewer);
28449
+ *
28450
+ * var t0 = performance.now();
28451
+ *
28452
+ * document.getElementById("time").innerHTML = "Loading model...";
28453
+ *
28454
+ * const sceneModel = xktLoader.load({
28455
+ * id: "myModel",
28456
+ * src: "../../assets/models/xkt/v10/glTF-Embedded/Duplex_A_20110505.glTFEmbedded.xkt",
28457
+ * edges: true
28458
+ * });
28459
+ *
28460
+ * sceneModel.on("loaded", () => {
28461
+ * var t1 = performance.now();
28462
+ * document.getElementById("time").innerHTML = "Model loaded in " + Math.floor(t1 - t0) / 1000.0 + " seconds<br>Objects: " + sceneModel.numEntities;
28463
+ *
28464
+ * let path = new SplineCurve(viewer.scene, {
28465
+ * points: [
28466
+ * [0, 0, -10],
28467
+ * [0, 0, -3],
28468
+ * [10, 0, 10],
28469
+ * [10, 0, 30],
28470
+ * ],
28471
+ * });
28472
+ *
28473
+ * new Mesh(viewer.scene, {
28474
+ * geometry: new ReadableGeometry(viewer.scene, buildPolylineGeometryFromCurve({
28475
+ * id: "SplineCurve",
28476
+ * curve: path,
28477
+ * divisions: 50,
28478
+ * })),
28479
+ * material: new PhongMaterial(viewer.scene, {
28480
+ * emissive: [1, 0, 0]
28481
+ * })
28482
+ * });
28483
+ *
28484
+ * //------------------------------------------------------------------------------------------------------------------
28485
+ * // Create a moving SectionPlane, that moves through the table models
28486
+ * //------------------------------------------------------------------------------------------------------------------
28487
+ *
28488
+ * const sectionPlanes = new SectionPlanesPlugin(viewer, {
28489
+ * overviewCanvasId: "mySectionPlanesOverviewCanvas",
28490
+ * overviewVisible: true
28491
+ * });
28492
+ *
28493
+ * let currentPoint = path.getPoint(0);
28494
+ * let currentDirection = path.getTangent(0);
28495
+ *
28496
+ * const sectionPlane = sectionPlanes.createSectionPlane({
28497
+ * id: "mySectionPlane",
28498
+ * pos: currentPoint,
28499
+ * dir: currentDirection
28500
+ * });
28501
+ *
28502
+ * sectionPlanes.showControl(sectionPlane.id);
28503
+ *
28504
+ * //------------------------------------------------------------------------------------------------------------------
28505
+ * // Controlling SectionPlane position and direction
28506
+ * //------------------------------------------------------------------------------------------------------------------
28507
+ *
28508
+ * let currentT = 0.0;
28509
+ * document.getElementById("section_path").oninput = function() {
28510
+ * currentT = Number(document.getElementById("section_path").value);
28511
+ * currentPoint = path.getPoint(currentT);
28512
+ * currentDirection = path.getTangent(currentT);
28513
+ * sectionPlane.pos = currentPoint;
28514
+ * sectionPlane.dir = currentDirection;
28515
+ * };
28516
+ *
28517
+ * window.viewer = viewer;
28518
+ *
28519
+ * //------------------------------------------------------------------------------------------------------------------
28520
+ * // Controlling CrossSections settings
28521
+ * //------------------------------------------------------------------------------------------------------------------
28522
+ *
28523
+ * viewer.scene.crossSections.sliceThickness = 0.05;
28524
+ * viewer.scene.crossSections.sliceColor = [0.0, 0.0, 0.0, 1.0];
28525
+ * });
28526
+ * ````
28527
+ *
28528
+ * [[Run this example](https://xeokit.github.io/xeokit-sdk/examples/slicing/#SectionPlanesPlugin_Duplex_SectionPath_CrossSections)]
28529
+ *
28530
+ */
28531
+ class CrossSections extends Component {
28532
+
28533
+ /** @private */
28534
+ constructor(owner, cfg = {}) {
28535
+
28536
+ super(owner, cfg);
28537
+
28538
+ this.sliceColor = cfg.sliceColor;
28539
+ this.sliceThickness = cfg.sliceThickness;
28540
+ }
28541
+
28542
+ /**
28543
+ * Sets the thickness of a slice created by a section.
28544
+ *
28545
+ * Default value is ````0.0````.
28546
+ *
28547
+ * @type {Number}
28548
+ */
28549
+ set sliceThickness(value) {
28550
+ if (value === undefined || value === null) {
28551
+ value = 0.0;
28552
+ }
28553
+ if (this._sliceThickness === value) {
28554
+ return;
28555
+ }
28556
+ this._sliceThickness = value;
28557
+ this.glRedraw();
28558
+ }
28559
+
28560
+ /**
28561
+ * Gets the thickness of a slice created by a section.
28562
+ *
28563
+ * Default value is ````0.0````.
28564
+ *
28565
+ * @type {Number}
28566
+ */
28567
+ get sliceThickness() {
28568
+ return this._sliceThickness;
28569
+ }
28570
+
28571
+ /**
28572
+ * Sets the color of a slice created by a section.
28573
+ *
28574
+ * Default value is ````[0.0, 0.0, 0.0, 1.0]````.
28575
+ *
28576
+ * @type {Number}
28577
+ */
28578
+ set sliceColor(value) {
28579
+ if (value === undefined || value === null) {
28580
+ value = [0.0, 0.0, 0.0, 1.0];
28581
+ }
28582
+ if (this._sliceColor === value) {
28583
+ return;
28584
+ }
28585
+ this._sliceColor = value;
28586
+ this.glRedraw();
28587
+ }
28588
+
28589
+ /**
28590
+ * Gets the color of a slice created by a section.
28591
+ *
28592
+ * Default value is ````[0.0, 0.0, 0.0, 1.0]````.
28593
+ *
28594
+ * @type {Number}
28595
+ */
28596
+ get sliceColor() {
28597
+ return this._sliceColor;
28598
+ }
28599
+
28600
+ /**
28601
+ * Destroys this component.
28602
+ */
28603
+ destroy() {
28604
+ super.destroy();
28605
+ }
28606
+ }
28607
+
28408
28608
  const PRESETS$1 = {
28409
28609
  "default": {
28410
28610
  pointSize: 4,
@@ -29791,6 +29991,14 @@ class Scene extends Component {
29791
29991
  enabled: cfg.saoEnabled
29792
29992
  });
29793
29993
 
29994
+ /** Configures Cross Sections for this Scene.
29995
+ * @type {CrossSections}
29996
+ * @final
29997
+ */
29998
+ this.crossSections = new CrossSections(this, {
29999
+
30000
+ });
30001
+
29794
30002
  this.ticksPerRender = cfg.ticksPerRender;
29795
30003
  this.ticksPerOcclusionTest = cfg.ticksPerOcclusionTest;
29796
30004
  this.passes = cfg.passes;
@@ -50053,6 +50261,10 @@ class VBORenderer {
50053
50261
  const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
50054
50262
  const baseIndex = layerIndex * numSectionPlanes;
50055
50263
  const renderFlags = model.renderFlags;
50264
+ if (scene.crossSections) {
50265
+ gl.uniform4fv(this._uSliceColor, scene.crossSections.sliceColor);
50266
+ gl.uniform1f(this._uSliceThickness, scene.crossSections.sliceThickness);
50267
+ }
50056
50268
  for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
50057
50269
  const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
50058
50270
  if (sectionPlaneUniforms) {
@@ -50214,6 +50426,11 @@ class VBORenderer {
50214
50426
 
50215
50427
  this._uPointSize = program.getLocation("pointSize");
50216
50428
  this._uNearPlaneHeight = program.getLocation("nearPlaneHeight");
50429
+
50430
+ if (scene.crossSections) {
50431
+ this._uSliceColor = program.getLocation("sliceColor");
50432
+ this._uSliceThickness = program.getLocation("sliceThickness");
50433
+ }
50217
50434
  }
50218
50435
 
50219
50436
  _bindProgram(frameCtx) {
@@ -50753,7 +50970,7 @@ class TrianglesColorRenderer$1 extends TrianglesBatchingRenderer {
50753
50970
 
50754
50971
  src.push("vec4 clipPos = projMatrix * viewPosition;");
50755
50972
  if (scene.logarithmicDepthBufferEnabled) {
50756
- src.push("vFragDepth = 1.0 + clipPos.w;");
50973
+ src.push("vFragDepth = 1.0 + clipPos.w;");
50757
50974
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
50758
50975
  }
50759
50976
  if (clipping) {
@@ -50808,11 +51025,14 @@ class TrianglesColorRenderer$1 extends TrianglesBatchingRenderer {
50808
51025
  src.push("uniform vec3 sectionPlanePos" + i + ";");
50809
51026
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
50810
51027
  }
51028
+ src.push("uniform float sliceThickness;");
51029
+ src.push("uniform vec4 sliceColor;");
50811
51030
  }
50812
51031
  src.push("in vec4 vColor;");
50813
51032
  src.push("out vec4 outColor;");
50814
51033
  src.push("void main(void) {");
50815
-
51034
+ src.push(" vec4 newColor;");
51035
+ src.push(" newColor = vColor;");
50816
51036
  if (clipping) {
50817
51037
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
50818
51038
  src.push(" if (clippable) {");
@@ -50822,9 +51042,12 @@ class TrianglesColorRenderer$1 extends TrianglesBatchingRenderer {
50822
51042
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
50823
51043
  src.push("}");
50824
51044
  }
50825
- src.push(" if (dist > 0.0) { ");
50826
- src.push(" discard;");
50827
- src.push(" }");
51045
+ src.push(" if (dist > sliceThickness) { ");
51046
+ src.push(" discard;");
51047
+ src.push(" }");
51048
+ src.push(" if (dist > 0.0) { ");
51049
+ src.push(" newColor = sliceColor;");
51050
+ src.push(" }");
50828
51051
  src.push("}");
50829
51052
  }
50830
51053
 
@@ -50841,9 +51064,9 @@ class TrianglesColorRenderer$1 extends TrianglesBatchingRenderer {
50841
51064
  src.push(" float blendFactor = uSAOParams[3];");
50842
51065
  src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");
50843
51066
  src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");
50844
- src.push(" outColor = vec4(vColor.rgb * ambient, 1.0);");
51067
+ src.push(" outColor = vec4(newColor.rgb * ambient, 1.0);");
50845
51068
  } else {
50846
- src.push(" outColor = vColor;");
51069
+ src.push(" outColor = newColor;");
50847
51070
  }
50848
51071
 
50849
51072
  src.push("}");
@@ -50976,6 +51199,8 @@ class TrianglesFlatColorRenderer$1 extends TrianglesBatchingRenderer {
50976
51199
  src.push("uniform vec3 sectionPlanePos" + i + ";");
50977
51200
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
50978
51201
  }
51202
+ src.push("uniform float sliceThickness;");
51203
+ src.push("uniform vec4 sliceColor;");
50979
51204
  }
50980
51205
 
50981
51206
  this._addMatricesUniformBlockLines(src);
@@ -51004,7 +51229,8 @@ class TrianglesFlatColorRenderer$1 extends TrianglesBatchingRenderer {
51004
51229
  src.push("out vec4 outColor;");
51005
51230
 
51006
51231
  src.push("void main(void) {");
51007
-
51232
+ src.push(" vec4 newColor;");
51233
+ src.push(" newColor = vColor;");
51008
51234
  if (clipping) {
51009
51235
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
51010
51236
  src.push(" if (clippable) {");
@@ -51014,9 +51240,12 @@ class TrianglesFlatColorRenderer$1 extends TrianglesBatchingRenderer {
51014
51240
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
51015
51241
  src.push("}");
51016
51242
  }
51017
- src.push(" if (dist > 0.0) { ");
51243
+ src.push(" if (dist > sliceThickness) { ");
51018
51244
  src.push(" discard;");
51019
51245
  src.push(" }");
51246
+ src.push(" if (dist > 0.0) { ");
51247
+ src.push(" newColor = sliceColor;");
51248
+ src.push(" }");
51020
51249
  src.push("}");
51021
51250
  }
51022
51251
 
@@ -51060,7 +51289,7 @@ class TrianglesFlatColorRenderer$1 extends TrianglesBatchingRenderer {
51060
51289
  src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
51061
51290
  }
51062
51291
 
51063
- src.push("vec4 fragColor = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
51292
+ src.push("vec4 fragColor = vec4((lightAmbient.rgb * lightAmbient.a * newColor.rgb) + (reflectedColor * newColor.rgb), newColor.a);");
51064
51293
 
51065
51294
  if (this._withSAO) {
51066
51295
  // Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
@@ -51103,7 +51332,7 @@ class TrianglesSilhouetteRenderer$1 extends TrianglesBatchingRenderer {
51103
51332
  const src = [];
51104
51333
  src.push("#version 300 es");
51105
51334
  src.push("// Triangles batching silhouette vertex shader");
51106
-
51335
+
51107
51336
  src.push("uniform int renderPass;");
51108
51337
 
51109
51338
  src.push("in vec3 position;");
@@ -51155,7 +51384,7 @@ class TrianglesSilhouetteRenderer$1 extends TrianglesBatchingRenderer {
51155
51384
  src.push("vColor = vec4(silhouetteColor.r, silhouetteColor.g, silhouetteColor.b, min(silhouetteColor.a, color.a ));");
51156
51385
  src.push("vec4 clipPos = projMatrix * viewPosition;");
51157
51386
  if (scene.logarithmicDepthBufferEnabled) {
51158
- src.push("vFragDepth = 1.0 + clipPos.w;");
51387
+ src.push("vFragDepth = 1.0 + clipPos.w;");
51159
51388
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
51160
51389
  }
51161
51390
  src.push("gl_Position = clipPos;");
@@ -51173,7 +51402,7 @@ class TrianglesSilhouetteRenderer$1 extends TrianglesBatchingRenderer {
51173
51402
  const src = [];
51174
51403
  src.push("#version 300 es");
51175
51404
  src.push("// Triangles batching silhouette fragment shader");
51176
-
51405
+
51177
51406
  src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
51178
51407
  src.push("precision highp float;");
51179
51408
  src.push("precision highp int;");
@@ -51194,26 +51423,35 @@ class TrianglesSilhouetteRenderer$1 extends TrianglesBatchingRenderer {
51194
51423
  src.push("uniform vec3 sectionPlanePos" + i + ";");
51195
51424
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
51196
51425
  }
51426
+ src.push("uniform float sliceThickness;");
51427
+ src.push("uniform vec4 sliceColor;");
51197
51428
  }
51198
51429
  src.push("in vec4 vColor;");
51199
51430
  src.push("out vec4 outColor;");
51200
51431
  src.push("void main(void) {");
51432
+ src.push(" vec4 newColor;");
51433
+ src.push(" newColor = vColor;");
51201
51434
  if (clipping) {
51202
51435
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
51203
51436
  src.push(" if (clippable) {");
51204
51437
  src.push(" float dist = 0.0;");
51205
- for (i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
51438
+ for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
51206
51439
  src.push("if (sectionPlaneActive" + i + ") {");
51207
51440
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
51208
51441
  src.push("}");
51209
51442
  }
51210
- src.push(" if (dist > 0.0) { discard; }");
51443
+ src.push(" if (dist > sliceThickness) { ");
51444
+ src.push(" discard;");
51445
+ src.push(" }");
51446
+ src.push(" if (dist > 0.0) { ");
51447
+ src.push(" newColor = sliceColor;");
51448
+ src.push(" }");
51211
51449
  src.push("}");
51212
51450
  }
51213
51451
  if (scene.logarithmicDepthBufferEnabled) {
51214
51452
  src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
51215
51453
  }
51216
- src.push("outColor = vColor;");
51454
+ src.push("outColor = newColor;");
51217
51455
  src.push("}");
51218
51456
  return src;
51219
51457
  }
@@ -51299,7 +51537,7 @@ class EdgesEmphasisRenderer$1 extends EdgesRenderer$1 {
51299
51537
 
51300
51538
  src.push("vec4 clipPos = projMatrix * viewPosition;");
51301
51539
  if (scene.logarithmicDepthBufferEnabled) {
51302
- src.push("vFragDepth = 1.0 + clipPos.w;");
51540
+ src.push("vFragDepth = 1.0 + clipPos.w;");
51303
51541
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
51304
51542
  }
51305
51543
  src.push("gl_Position = clipPos;");
@@ -51316,7 +51554,7 @@ class EdgesEmphasisRenderer$1 extends EdgesRenderer$1 {
51316
51554
  const src = [];
51317
51555
  src.push("#version 300 es");
51318
51556
  src.push("// EdgesEmphasisRenderer fragment shader");
51319
-
51557
+
51320
51558
  src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
51321
51559
  src.push("precision highp float;");
51322
51560
  src.push("precision highp int;");
@@ -51429,7 +51667,7 @@ class EdgesColorRenderer$1 extends EdgesRenderer$1 {
51429
51667
 
51430
51668
  src.push("vec4 clipPos = projMatrix * viewPosition;");
51431
51669
  if (scene.logarithmicDepthBufferEnabled) {
51432
- src.push("vFragDepth = 1.0 + clipPos.w;");
51670
+ src.push("vFragDepth = 1.0 + clipPos.w;");
51433
51671
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
51434
51672
  }
51435
51673
  src.push("gl_Position = clipPos;");
@@ -53182,6 +53420,8 @@ class TrianglesColorTextureRenderer$1 extends TrianglesBatchingRenderer {
53182
53420
  src.push("uniform vec3 sectionPlanePos" + i + ";");
53183
53421
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
53184
53422
  }
53423
+ src.push("uniform float sliceThickness;");
53424
+ src.push("uniform vec4 sliceColor;");
53185
53425
  }
53186
53426
  this._addMatricesUniformBlockLines(src);
53187
53427
  src.push("uniform vec4 lightAmbient;");
@@ -53209,7 +53449,8 @@ class TrianglesColorTextureRenderer$1 extends TrianglesBatchingRenderer {
53209
53449
  src.push("out vec4 outColor;");
53210
53450
 
53211
53451
  src.push("void main(void) {");
53212
-
53452
+ src.push(" vec4 newColor;");
53453
+ src.push(" newColor = vColor;");
53213
53454
  if (clipping) {
53214
53455
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
53215
53456
  src.push(" if (clippable) {");
@@ -53219,9 +53460,12 @@ class TrianglesColorTextureRenderer$1 extends TrianglesBatchingRenderer {
53219
53460
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
53220
53461
  src.push("}");
53221
53462
  }
53222
- src.push(" if (dist > 0.0) { ");
53463
+ src.push(" if (dist > sliceThickness) { ");
53223
53464
  src.push(" discard;");
53224
53465
  src.push(" }");
53466
+ src.push(" if (dist > 0.0) { ");
53467
+ src.push(" newColor = sliceColor;");
53468
+ src.push(" }");
53225
53469
  src.push("}");
53226
53470
  }
53227
53471
 
@@ -53265,7 +53509,7 @@ class TrianglesColorTextureRenderer$1 extends TrianglesBatchingRenderer {
53265
53509
  src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
53266
53510
  }
53267
53511
 
53268
- src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
53512
+ src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * newColor.rgb) + (reflectedColor * newColor.rgb), newColor.a);");
53269
53513
  if (gammaOutput) {
53270
53514
  src.push("vec4 colorTexel = color * sRGBToLinear(texture(uColorMap, vUV));");
53271
53515
  } else {
@@ -56046,11 +56290,14 @@ class TrianglesColorRenderer extends TrianglesInstancingRenderer {
56046
56290
  src.push("uniform vec3 sectionPlanePos" + i + ";");
56047
56291
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
56048
56292
  }
56293
+ src.push("uniform float sliceThickness;");
56294
+ src.push("uniform vec4 sliceColor;");
56049
56295
  }
56050
56296
  src.push("in vec4 vColor;");
56051
56297
  src.push("out vec4 outColor;");
56052
56298
  src.push("void main(void) {");
56053
-
56299
+ src.push(" vec4 newColor;");
56300
+ src.push(" newColor = vColor;");
56054
56301
  if (clipping) {
56055
56302
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
56056
56303
  src.push(" if (clippable) {");
@@ -56060,9 +56307,12 @@ class TrianglesColorRenderer extends TrianglesInstancingRenderer {
56060
56307
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
56061
56308
  src.push("}");
56062
56309
  }
56063
- src.push(" if (dist > 0.0) { ");
56310
+ src.push(" if (dist > sliceThickness) { ");
56064
56311
  src.push(" discard;");
56065
56312
  src.push(" }");
56313
+ src.push(" if (dist > 0.0) { ");
56314
+ src.push(" newColor = sliceColor;");
56315
+ src.push(" }");
56066
56316
  src.push("}");
56067
56317
  }
56068
56318
 
@@ -56080,9 +56330,9 @@ class TrianglesColorRenderer extends TrianglesInstancingRenderer {
56080
56330
  src.push(" float blendFactor = uSAOParams[3];");
56081
56331
  src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");
56082
56332
  src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");
56083
- src.push(" outColor = vec4(vColor.rgb * ambient, 1.0);");
56333
+ src.push(" outColor = vec4(newColor.rgb * ambient, 1.0);");
56084
56334
  } else {
56085
- src.push(" outColor = vColor;");
56335
+ src.push(" outColor = newColor;");
56086
56336
  }
56087
56337
  src.push("}");
56088
56338
  return src;
@@ -56107,7 +56357,7 @@ class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
56107
56357
  const src = [];
56108
56358
  src.push("#version 300 es");
56109
56359
  src.push("// Instancing geometry flat-shading drawing vertex shader");
56110
-
56360
+
56111
56361
  src.push("uniform int renderPass;");
56112
56362
 
56113
56363
  src.push("in vec3 position;");
@@ -56132,7 +56382,7 @@ class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
56132
56382
  src.push("}");
56133
56383
  src.push("out float isPerspective;");
56134
56384
  }
56135
-
56385
+
56136
56386
  if (clipping) {
56137
56387
  src.push("out vec4 vWorldPosition;");
56138
56388
  src.push("out float vFlags;");
@@ -56164,7 +56414,7 @@ class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
56164
56414
 
56165
56415
  src.push("vec4 clipPos = projMatrix * viewPosition;");
56166
56416
  if (scene.logarithmicDepthBufferEnabled) {
56167
- src.push("vFragDepth = 1.0 + clipPos.w;");
56417
+ src.push("vFragDepth = 1.0 + clipPos.w;");
56168
56418
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
56169
56419
  }
56170
56420
 
@@ -56189,7 +56439,7 @@ class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
56189
56439
  const src = [];
56190
56440
  src.push("#version 300 es");
56191
56441
  src.push("// Instancing geometry flat-shading drawing fragment shader");
56192
-
56442
+
56193
56443
  src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
56194
56444
  src.push("precision highp float;");
56195
56445
  src.push("precision highp int;");
@@ -56198,9 +56448,9 @@ class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
56198
56448
  src.push("precision mediump int;");
56199
56449
  src.push("#endif");
56200
56450
  if (scene.logarithmicDepthBufferEnabled) {
56201
- src.push("in float isPerspective;");
56202
- src.push("uniform float logDepthBufFC;");
56203
- src.push("in float vFragDepth;");
56451
+ src.push("in float isPerspective;");
56452
+ src.push("uniform float logDepthBufFC;");
56453
+ src.push("in float vFragDepth;");
56204
56454
  }
56205
56455
  if (this._withSAO) {
56206
56456
  src.push("uniform sampler2D uOcclusionTexture;");
@@ -56223,6 +56473,8 @@ class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
56223
56473
  src.push("uniform vec3 sectionPlanePos" + i + ";");
56224
56474
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
56225
56475
  }
56476
+ src.push("uniform float sliceThickness;");
56477
+ src.push("uniform vec4 sliceColor;");
56226
56478
  }
56227
56479
 
56228
56480
  this._addMatricesUniformBlockLines(src);
@@ -56252,7 +56504,8 @@ class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
56252
56504
  src.push("out vec4 outColor;");
56253
56505
 
56254
56506
  src.push("void main(void) {");
56255
-
56507
+ src.push(" vec4 newColor;");
56508
+ src.push(" newColor = vColor;");
56256
56509
  if (clipping) {
56257
56510
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
56258
56511
  src.push(" if (clippable) {");
@@ -56262,9 +56515,12 @@ class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
56262
56515
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
56263
56516
  src.push("}");
56264
56517
  }
56265
- src.push(" if (dist > 0.0) { ");
56518
+ src.push(" if (dist > sliceThickness) { ");
56266
56519
  src.push(" discard;");
56267
56520
  src.push(" }");
56521
+ src.push(" if (dist > 0.0) { ");
56522
+ src.push(" newColor = sliceColor;");
56523
+ src.push(" }");
56268
56524
  src.push("}");
56269
56525
  }
56270
56526
 
@@ -56307,7 +56563,7 @@ class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
56307
56563
  src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
56308
56564
  }
56309
56565
 
56310
- src.push("vec4 fragColor = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
56566
+ src.push("vec4 fragColor = vec4((lightAmbient.rgb * lightAmbient.a * newColor.rgb) + (reflectedColor * newColor.rgb), newColor.a);");
56311
56567
 
56312
56568
  if (this._withSAO) {
56313
56569
  // Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
@@ -56349,7 +56605,7 @@ class TrianglesSilhouetteRenderer extends TrianglesInstancingRenderer {
56349
56605
  const src = [];
56350
56606
  src.push("#version 300 es");
56351
56607
  src.push("// Instancing silhouette vertex shader");
56352
-
56608
+
56353
56609
  src.push("uniform int renderPass;");
56354
56610
 
56355
56611
  src.push("in vec3 position;");
@@ -56408,7 +56664,7 @@ class TrianglesSilhouetteRenderer extends TrianglesInstancingRenderer {
56408
56664
  src.push("vColor = vec4(silhouetteColor.r, silhouetteColor.g, silhouetteColor.b, min(silhouetteColor.a, float(color.a) / 255.0));");
56409
56665
  src.push("vec4 clipPos = projMatrix * viewPosition;");
56410
56666
  if (scene.logarithmicDepthBufferEnabled) {
56411
- src.push("vFragDepth = 1.0 + clipPos.w;");
56667
+ src.push("vFragDepth = 1.0 + clipPos.w;");
56412
56668
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
56413
56669
  }
56414
56670
  src.push("gl_Position = clipPos;");
@@ -56424,7 +56680,7 @@ class TrianglesSilhouetteRenderer extends TrianglesInstancingRenderer {
56424
56680
  const src = [];
56425
56681
  src.push("#version 300 es");
56426
56682
  src.push("// Instancing fill fragment shader");
56427
-
56683
+
56428
56684
  src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
56429
56685
  src.push("precision highp float;");
56430
56686
  src.push("precision highp int;");
@@ -56445,10 +56701,14 @@ class TrianglesSilhouetteRenderer extends TrianglesInstancingRenderer {
56445
56701
  src.push("uniform vec3 sectionPlanePos" + i + ";");
56446
56702
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
56447
56703
  }
56704
+ src.push("uniform float sliceThickness;");
56705
+ src.push("uniform vec4 sliceColor;");
56448
56706
  }
56449
56707
  src.push("in vec4 vColor;");
56450
56708
  src.push("out vec4 outColor;");
56451
56709
  src.push("void main(void) {");
56710
+ src.push(" vec4 newColor;");
56711
+ src.push(" newColor = vColor;");
56452
56712
  if (clipping) {
56453
56713
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
56454
56714
  src.push(" if (clippable) {");
@@ -56458,13 +56718,18 @@ class TrianglesSilhouetteRenderer extends TrianglesInstancingRenderer {
56458
56718
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
56459
56719
  src.push("}");
56460
56720
  }
56461
- src.push("if (dist > 0.0) { discard; }");
56721
+ src.push(" if (dist > sliceThickness) { ");
56722
+ src.push(" discard;");
56723
+ src.push(" }");
56724
+ src.push(" if (dist > 0.0) { ");
56725
+ src.push(" newColor = sliceColor;");
56726
+ src.push(" }");
56462
56727
  src.push("}");
56463
56728
  }
56464
56729
  if (scene.logarithmicDepthBufferEnabled) {
56465
56730
  src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
56466
56731
  }
56467
- src.push("outColor = vColor;");
56732
+ src.push("outColor = newColor;");
56468
56733
  src.push("}");
56469
56734
  return src;
56470
56735
  }
@@ -58494,6 +58759,8 @@ class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
58494
58759
  src.push("uniform vec3 sectionPlanePos" + i + ";");
58495
58760
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
58496
58761
  }
58762
+ src.push("uniform float sliceThickness;");
58763
+ src.push("uniform vec4 sliceColor;");
58497
58764
  }
58498
58765
  this._addMatricesUniformBlockLines(src);
58499
58766
 
@@ -58522,7 +58789,8 @@ class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
58522
58789
  src.push("out vec4 outColor;");
58523
58790
 
58524
58791
  src.push("void main(void) {");
58525
-
58792
+ src.push(" vec4 newColor;");
58793
+ src.push(" newColor = vColor;");
58526
58794
  if (clipping) {
58527
58795
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
58528
58796
  src.push(" if (clippable) {");
@@ -58532,9 +58800,12 @@ class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
58532
58800
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
58533
58801
  src.push("}");
58534
58802
  }
58535
- src.push(" if (dist > 0.0) { ");
58803
+ src.push(" if (dist > sliceThickness) { ");
58536
58804
  src.push(" discard;");
58537
58805
  src.push(" }");
58806
+ src.push(" if (dist > 0.0) { ");
58807
+ src.push(" newColor = sliceColor;");
58808
+ src.push(" }");
58538
58809
  src.push("}");
58539
58810
  }
58540
58811
 
@@ -58577,7 +58848,7 @@ class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
58577
58848
  src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
58578
58849
  }
58579
58850
 
58580
- src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
58851
+ src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * newColor.rgb) + (reflectedColor * newColor.rgb), newColor.a);");
58581
58852
  if (gammaOutput) {
58582
58853
  src.push("vec4 colorTexel = color * sRGBToLinear(texture(uColorMap, vUV));");
58583
58854
  } else {
@@ -58594,9 +58865,9 @@ class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
58594
58865
  src.push(" float blendFactor = uSAOParams[3];");
58595
58866
  src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");
58596
58867
  src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");
58597
- src.push(" outColor = vec4(vColor.rgb * colorTexel.rgb * ambient, opacity);");
58868
+ src.push(" outColor = vec4(newColor.rgb * colorTexel.rgb * ambient, opacity);");
58598
58869
  } else {
58599
- src.push(" outColor = vec4(vColor.rgb * colorTexel.rgb, opacity);");
58870
+ src.push(" outColor = vec4(newColor.rgb * colorTexel.rgb, opacity);");
58600
58871
  }
58601
58872
 
58602
58873
  if (gammaOutput) {