@xeokit/xeokit-sdk 2.6.6 → 2.6.7

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 (24) 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/viewer/scene/postfx/CrossSections.d.ts +42 -0
@@ -28401,6 +28401,206 @@ class SAO extends Component {
28401
28401
  }
28402
28402
  }
28403
28403
 
28404
+ /**
28405
+ * @desc Configures cross-section slices for a {@link Scene}.
28406
+ *
28407
+ * ## Overview
28408
+ *
28409
+ * Cross-sections allow to create an additional colored slice for used clipping planes. It is only a visual effect
28410
+ * calculated by shaders. It makes it easier to see the intersection between the model and the clipping plane this way.
28411
+ *
28412
+ * ## Usage
28413
+ *
28414
+ * In the example below, we'll configure CrossSections to manipulate the slice representation.
28415
+ *
28416
+ * ````javascript
28417
+ * //------------------------------------------------------------------------------------------------------------------
28418
+ * // Import the modules we need for this example
28419
+ * //------------------------------------------------------------------------------------------------------------------
28420
+ *
28421
+ * import {PhongMaterial, Viewer, math, SectionPlanesPlugin, XKTLoaderPlugin, Mesh, ReadableGeometry, buildPolylineGeometryFromCurve, SplineCurve} from "../../dist/xeokit-sdk.es.js";
28422
+ *
28423
+ * //------------------------------------------------------------------------------------------------------------------
28424
+ * // Create a Viewer and arrange the camera
28425
+ * //------------------------------------------------------------------------------------------------------------------
28426
+ *
28427
+ * const viewer = new Viewer({
28428
+ * canvasId: "myCanvas",
28429
+ * transparent: true
28430
+ * });
28431
+ *
28432
+ * viewer.camera.eye = [-2.341298674548419, 22.43987089731119, 7.236688436028655];
28433
+ * viewer.camera.look = [4.399999999999963, 3.7240000000000606, 8.899000000000006];
28434
+ * viewer.camera.up = [0.9102954845584759, 0.34781746407929504, 0.22446635042673466];
28435
+ *
28436
+ * const cameraControl = viewer.cameraControl;
28437
+ * cameraControl.navMode = "orbit";
28438
+ * cameraControl.followPointer = true;
28439
+ *
28440
+ * //----------------------------------------------------------------------------------------------------------------------
28441
+ * // Create a xeokit loader plugin, load a model, fit to view
28442
+ * //----------------------------------------------------------------------------------------------------------------------
28443
+ *
28444
+ * const xktLoader = new XKTLoaderPlugin(viewer);
28445
+ *
28446
+ * var t0 = performance.now();
28447
+ *
28448
+ * document.getElementById("time").innerHTML = "Loading model...";
28449
+ *
28450
+ * const sceneModel = xktLoader.load({
28451
+ * id: "myModel",
28452
+ * src: "../../assets/models/xkt/v10/glTF-Embedded/Duplex_A_20110505.glTFEmbedded.xkt",
28453
+ * edges: true
28454
+ * });
28455
+ *
28456
+ * sceneModel.on("loaded", () => {
28457
+ * var t1 = performance.now();
28458
+ * document.getElementById("time").innerHTML = "Model loaded in " + Math.floor(t1 - t0) / 1000.0 + " seconds<br>Objects: " + sceneModel.numEntities;
28459
+ *
28460
+ * let path = new SplineCurve(viewer.scene, {
28461
+ * points: [
28462
+ * [0, 0, -10],
28463
+ * [0, 0, -3],
28464
+ * [10, 0, 10],
28465
+ * [10, 0, 30],
28466
+ * ],
28467
+ * });
28468
+ *
28469
+ * new Mesh(viewer.scene, {
28470
+ * geometry: new ReadableGeometry(viewer.scene, buildPolylineGeometryFromCurve({
28471
+ * id: "SplineCurve",
28472
+ * curve: path,
28473
+ * divisions: 50,
28474
+ * })),
28475
+ * material: new PhongMaterial(viewer.scene, {
28476
+ * emissive: [1, 0, 0]
28477
+ * })
28478
+ * });
28479
+ *
28480
+ * //------------------------------------------------------------------------------------------------------------------
28481
+ * // Create a moving SectionPlane, that moves through the table models
28482
+ * //------------------------------------------------------------------------------------------------------------------
28483
+ *
28484
+ * const sectionPlanes = new SectionPlanesPlugin(viewer, {
28485
+ * overviewCanvasId: "mySectionPlanesOverviewCanvas",
28486
+ * overviewVisible: true
28487
+ * });
28488
+ *
28489
+ * let currentPoint = path.getPoint(0);
28490
+ * let currentDirection = path.getTangent(0);
28491
+ *
28492
+ * const sectionPlane = sectionPlanes.createSectionPlane({
28493
+ * id: "mySectionPlane",
28494
+ * pos: currentPoint,
28495
+ * dir: currentDirection
28496
+ * });
28497
+ *
28498
+ * sectionPlanes.showControl(sectionPlane.id);
28499
+ *
28500
+ * //------------------------------------------------------------------------------------------------------------------
28501
+ * // Controlling SectionPlane position and direction
28502
+ * //------------------------------------------------------------------------------------------------------------------
28503
+ *
28504
+ * let currentT = 0.0;
28505
+ * document.getElementById("section_path").oninput = function() {
28506
+ * currentT = Number(document.getElementById("section_path").value);
28507
+ * currentPoint = path.getPoint(currentT);
28508
+ * currentDirection = path.getTangent(currentT);
28509
+ * sectionPlane.pos = currentPoint;
28510
+ * sectionPlane.dir = currentDirection;
28511
+ * };
28512
+ *
28513
+ * window.viewer = viewer;
28514
+ *
28515
+ * //------------------------------------------------------------------------------------------------------------------
28516
+ * // Controlling CrossSections settings
28517
+ * //------------------------------------------------------------------------------------------------------------------
28518
+ *
28519
+ * viewer.scene.crossSections.sliceThickness = 0.05;
28520
+ * viewer.scene.crossSections.sliceColor = [0.0, 0.0, 0.0, 1.0];
28521
+ * });
28522
+ * ````
28523
+ *
28524
+ * [[Run this example](https://xeokit.github.io/xeokit-sdk/examples/slicing/#SectionPlanesPlugin_Duplex_SectionPath_CrossSections)]
28525
+ *
28526
+ */
28527
+ class CrossSections extends Component {
28528
+
28529
+ /** @private */
28530
+ constructor(owner, cfg = {}) {
28531
+
28532
+ super(owner, cfg);
28533
+
28534
+ this.sliceColor = cfg.sliceColor;
28535
+ this.sliceThickness = cfg.sliceThickness;
28536
+ }
28537
+
28538
+ /**
28539
+ * Sets the thickness of a slice created by a section.
28540
+ *
28541
+ * Default value is ````0.0````.
28542
+ *
28543
+ * @type {Number}
28544
+ */
28545
+ set sliceThickness(value) {
28546
+ if (value === undefined || value === null) {
28547
+ value = 0.0;
28548
+ }
28549
+ if (this._sliceThickness === value) {
28550
+ return;
28551
+ }
28552
+ this._sliceThickness = value;
28553
+ this.glRedraw();
28554
+ }
28555
+
28556
+ /**
28557
+ * Gets the thickness of a slice created by a section.
28558
+ *
28559
+ * Default value is ````0.0````.
28560
+ *
28561
+ * @type {Number}
28562
+ */
28563
+ get sliceThickness() {
28564
+ return this._sliceThickness;
28565
+ }
28566
+
28567
+ /**
28568
+ * Sets the color of a slice created by a section.
28569
+ *
28570
+ * Default value is ````[0.0, 0.0, 0.0, 1.0]````.
28571
+ *
28572
+ * @type {Number}
28573
+ */
28574
+ set sliceColor(value) {
28575
+ if (value === undefined || value === null) {
28576
+ value = [0.0, 0.0, 0.0, 1.0];
28577
+ }
28578
+ if (this._sliceColor === value) {
28579
+ return;
28580
+ }
28581
+ this._sliceColor = value;
28582
+ this.glRedraw();
28583
+ }
28584
+
28585
+ /**
28586
+ * Gets the color of a slice created by a section.
28587
+ *
28588
+ * Default value is ````[0.0, 0.0, 0.0, 1.0]````.
28589
+ *
28590
+ * @type {Number}
28591
+ */
28592
+ get sliceColor() {
28593
+ return this._sliceColor;
28594
+ }
28595
+
28596
+ /**
28597
+ * Destroys this component.
28598
+ */
28599
+ destroy() {
28600
+ super.destroy();
28601
+ }
28602
+ }
28603
+
28404
28604
  const PRESETS$1 = {
28405
28605
  "default": {
28406
28606
  pointSize: 4,
@@ -29787,6 +29987,14 @@ class Scene extends Component {
29787
29987
  enabled: cfg.saoEnabled
29788
29988
  });
29789
29989
 
29990
+ /** Configures Cross Sections for this Scene.
29991
+ * @type {CrossSections}
29992
+ * @final
29993
+ */
29994
+ this.crossSections = new CrossSections(this, {
29995
+
29996
+ });
29997
+
29790
29998
  this.ticksPerRender = cfg.ticksPerRender;
29791
29999
  this.ticksPerOcclusionTest = cfg.ticksPerOcclusionTest;
29792
30000
  this.passes = cfg.passes;
@@ -50049,6 +50257,10 @@ class VBORenderer {
50049
50257
  const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
50050
50258
  const baseIndex = layerIndex * numSectionPlanes;
50051
50259
  const renderFlags = model.renderFlags;
50260
+ if (scene.crossSections) {
50261
+ gl.uniform4fv(this._uSliceColor, scene.crossSections.sliceColor);
50262
+ gl.uniform1f(this._uSliceThickness, scene.crossSections.sliceThickness);
50263
+ }
50052
50264
  for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
50053
50265
  const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
50054
50266
  if (sectionPlaneUniforms) {
@@ -50210,6 +50422,11 @@ class VBORenderer {
50210
50422
 
50211
50423
  this._uPointSize = program.getLocation("pointSize");
50212
50424
  this._uNearPlaneHeight = program.getLocation("nearPlaneHeight");
50425
+
50426
+ if (scene.crossSections) {
50427
+ this._uSliceColor = program.getLocation("sliceColor");
50428
+ this._uSliceThickness = program.getLocation("sliceThickness");
50429
+ }
50213
50430
  }
50214
50431
 
50215
50432
  _bindProgram(frameCtx) {
@@ -50749,7 +50966,7 @@ class TrianglesColorRenderer$1 extends TrianglesBatchingRenderer {
50749
50966
 
50750
50967
  src.push("vec4 clipPos = projMatrix * viewPosition;");
50751
50968
  if (scene.logarithmicDepthBufferEnabled) {
50752
- src.push("vFragDepth = 1.0 + clipPos.w;");
50969
+ src.push("vFragDepth = 1.0 + clipPos.w;");
50753
50970
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
50754
50971
  }
50755
50972
  if (clipping) {
@@ -50804,11 +51021,14 @@ class TrianglesColorRenderer$1 extends TrianglesBatchingRenderer {
50804
51021
  src.push("uniform vec3 sectionPlanePos" + i + ";");
50805
51022
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
50806
51023
  }
51024
+ src.push("uniform float sliceThickness;");
51025
+ src.push("uniform vec4 sliceColor;");
50807
51026
  }
50808
51027
  src.push("in vec4 vColor;");
50809
51028
  src.push("out vec4 outColor;");
50810
51029
  src.push("void main(void) {");
50811
-
51030
+ src.push(" vec4 newColor;");
51031
+ src.push(" newColor = vColor;");
50812
51032
  if (clipping) {
50813
51033
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
50814
51034
  src.push(" if (clippable) {");
@@ -50818,9 +51038,12 @@ class TrianglesColorRenderer$1 extends TrianglesBatchingRenderer {
50818
51038
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
50819
51039
  src.push("}");
50820
51040
  }
50821
- src.push(" if (dist > 0.0) { ");
50822
- src.push(" discard;");
50823
- src.push(" }");
51041
+ src.push(" if (dist > sliceThickness) { ");
51042
+ src.push(" discard;");
51043
+ src.push(" }");
51044
+ src.push(" if (dist > 0.0) { ");
51045
+ src.push(" newColor = sliceColor;");
51046
+ src.push(" }");
50824
51047
  src.push("}");
50825
51048
  }
50826
51049
 
@@ -50837,9 +51060,9 @@ class TrianglesColorRenderer$1 extends TrianglesBatchingRenderer {
50837
51060
  src.push(" float blendFactor = uSAOParams[3];");
50838
51061
  src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");
50839
51062
  src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");
50840
- src.push(" outColor = vec4(vColor.rgb * ambient, 1.0);");
51063
+ src.push(" outColor = vec4(newColor.rgb * ambient, 1.0);");
50841
51064
  } else {
50842
- src.push(" outColor = vColor;");
51065
+ src.push(" outColor = newColor;");
50843
51066
  }
50844
51067
 
50845
51068
  src.push("}");
@@ -50972,6 +51195,8 @@ class TrianglesFlatColorRenderer$1 extends TrianglesBatchingRenderer {
50972
51195
  src.push("uniform vec3 sectionPlanePos" + i + ";");
50973
51196
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
50974
51197
  }
51198
+ src.push("uniform float sliceThickness;");
51199
+ src.push("uniform vec4 sliceColor;");
50975
51200
  }
50976
51201
 
50977
51202
  this._addMatricesUniformBlockLines(src);
@@ -51000,7 +51225,8 @@ class TrianglesFlatColorRenderer$1 extends TrianglesBatchingRenderer {
51000
51225
  src.push("out vec4 outColor;");
51001
51226
 
51002
51227
  src.push("void main(void) {");
51003
-
51228
+ src.push(" vec4 newColor;");
51229
+ src.push(" newColor = vColor;");
51004
51230
  if (clipping) {
51005
51231
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
51006
51232
  src.push(" if (clippable) {");
@@ -51010,9 +51236,12 @@ class TrianglesFlatColorRenderer$1 extends TrianglesBatchingRenderer {
51010
51236
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
51011
51237
  src.push("}");
51012
51238
  }
51013
- src.push(" if (dist > 0.0) { ");
51239
+ src.push(" if (dist > sliceThickness) { ");
51014
51240
  src.push(" discard;");
51015
51241
  src.push(" }");
51242
+ src.push(" if (dist > 0.0) { ");
51243
+ src.push(" newColor = sliceColor;");
51244
+ src.push(" }");
51016
51245
  src.push("}");
51017
51246
  }
51018
51247
 
@@ -51056,7 +51285,7 @@ class TrianglesFlatColorRenderer$1 extends TrianglesBatchingRenderer {
51056
51285
  src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
51057
51286
  }
51058
51287
 
51059
- src.push("vec4 fragColor = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
51288
+ src.push("vec4 fragColor = vec4((lightAmbient.rgb * lightAmbient.a * newColor.rgb) + (reflectedColor * newColor.rgb), newColor.a);");
51060
51289
 
51061
51290
  if (this._withSAO) {
51062
51291
  // Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
@@ -51099,7 +51328,7 @@ class TrianglesSilhouetteRenderer$1 extends TrianglesBatchingRenderer {
51099
51328
  const src = [];
51100
51329
  src.push("#version 300 es");
51101
51330
  src.push("// Triangles batching silhouette vertex shader");
51102
-
51331
+
51103
51332
  src.push("uniform int renderPass;");
51104
51333
 
51105
51334
  src.push("in vec3 position;");
@@ -51151,7 +51380,7 @@ class TrianglesSilhouetteRenderer$1 extends TrianglesBatchingRenderer {
51151
51380
  src.push("vColor = vec4(silhouetteColor.r, silhouetteColor.g, silhouetteColor.b, min(silhouetteColor.a, color.a ));");
51152
51381
  src.push("vec4 clipPos = projMatrix * viewPosition;");
51153
51382
  if (scene.logarithmicDepthBufferEnabled) {
51154
- src.push("vFragDepth = 1.0 + clipPos.w;");
51383
+ src.push("vFragDepth = 1.0 + clipPos.w;");
51155
51384
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
51156
51385
  }
51157
51386
  src.push("gl_Position = clipPos;");
@@ -51169,7 +51398,7 @@ class TrianglesSilhouetteRenderer$1 extends TrianglesBatchingRenderer {
51169
51398
  const src = [];
51170
51399
  src.push("#version 300 es");
51171
51400
  src.push("// Triangles batching silhouette fragment shader");
51172
-
51401
+
51173
51402
  src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
51174
51403
  src.push("precision highp float;");
51175
51404
  src.push("precision highp int;");
@@ -51190,26 +51419,35 @@ class TrianglesSilhouetteRenderer$1 extends TrianglesBatchingRenderer {
51190
51419
  src.push("uniform vec3 sectionPlanePos" + i + ";");
51191
51420
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
51192
51421
  }
51422
+ src.push("uniform float sliceThickness;");
51423
+ src.push("uniform vec4 sliceColor;");
51193
51424
  }
51194
51425
  src.push("in vec4 vColor;");
51195
51426
  src.push("out vec4 outColor;");
51196
51427
  src.push("void main(void) {");
51428
+ src.push(" vec4 newColor;");
51429
+ src.push(" newColor = vColor;");
51197
51430
  if (clipping) {
51198
51431
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
51199
51432
  src.push(" if (clippable) {");
51200
51433
  src.push(" float dist = 0.0;");
51201
- for (i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
51434
+ for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
51202
51435
  src.push("if (sectionPlaneActive" + i + ") {");
51203
51436
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
51204
51437
  src.push("}");
51205
51438
  }
51206
- src.push(" if (dist > 0.0) { discard; }");
51439
+ src.push(" if (dist > sliceThickness) { ");
51440
+ src.push(" discard;");
51441
+ src.push(" }");
51442
+ src.push(" if (dist > 0.0) { ");
51443
+ src.push(" newColor = sliceColor;");
51444
+ src.push(" }");
51207
51445
  src.push("}");
51208
51446
  }
51209
51447
  if (scene.logarithmicDepthBufferEnabled) {
51210
51448
  src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
51211
51449
  }
51212
- src.push("outColor = vColor;");
51450
+ src.push("outColor = newColor;");
51213
51451
  src.push("}");
51214
51452
  return src;
51215
51453
  }
@@ -51295,7 +51533,7 @@ class EdgesEmphasisRenderer$1 extends EdgesRenderer$1 {
51295
51533
 
51296
51534
  src.push("vec4 clipPos = projMatrix * viewPosition;");
51297
51535
  if (scene.logarithmicDepthBufferEnabled) {
51298
- src.push("vFragDepth = 1.0 + clipPos.w;");
51536
+ src.push("vFragDepth = 1.0 + clipPos.w;");
51299
51537
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
51300
51538
  }
51301
51539
  src.push("gl_Position = clipPos;");
@@ -51312,7 +51550,7 @@ class EdgesEmphasisRenderer$1 extends EdgesRenderer$1 {
51312
51550
  const src = [];
51313
51551
  src.push("#version 300 es");
51314
51552
  src.push("// EdgesEmphasisRenderer fragment shader");
51315
-
51553
+
51316
51554
  src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
51317
51555
  src.push("precision highp float;");
51318
51556
  src.push("precision highp int;");
@@ -51425,7 +51663,7 @@ class EdgesColorRenderer$1 extends EdgesRenderer$1 {
51425
51663
 
51426
51664
  src.push("vec4 clipPos = projMatrix * viewPosition;");
51427
51665
  if (scene.logarithmicDepthBufferEnabled) {
51428
- src.push("vFragDepth = 1.0 + clipPos.w;");
51666
+ src.push("vFragDepth = 1.0 + clipPos.w;");
51429
51667
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
51430
51668
  }
51431
51669
  src.push("gl_Position = clipPos;");
@@ -53178,6 +53416,8 @@ class TrianglesColorTextureRenderer$1 extends TrianglesBatchingRenderer {
53178
53416
  src.push("uniform vec3 sectionPlanePos" + i + ";");
53179
53417
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
53180
53418
  }
53419
+ src.push("uniform float sliceThickness;");
53420
+ src.push("uniform vec4 sliceColor;");
53181
53421
  }
53182
53422
  this._addMatricesUniformBlockLines(src);
53183
53423
  src.push("uniform vec4 lightAmbient;");
@@ -53205,7 +53445,8 @@ class TrianglesColorTextureRenderer$1 extends TrianglesBatchingRenderer {
53205
53445
  src.push("out vec4 outColor;");
53206
53446
 
53207
53447
  src.push("void main(void) {");
53208
-
53448
+ src.push(" vec4 newColor;");
53449
+ src.push(" newColor = vColor;");
53209
53450
  if (clipping) {
53210
53451
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
53211
53452
  src.push(" if (clippable) {");
@@ -53215,9 +53456,12 @@ class TrianglesColorTextureRenderer$1 extends TrianglesBatchingRenderer {
53215
53456
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
53216
53457
  src.push("}");
53217
53458
  }
53218
- src.push(" if (dist > 0.0) { ");
53459
+ src.push(" if (dist > sliceThickness) { ");
53219
53460
  src.push(" discard;");
53220
53461
  src.push(" }");
53462
+ src.push(" if (dist > 0.0) { ");
53463
+ src.push(" newColor = sliceColor;");
53464
+ src.push(" }");
53221
53465
  src.push("}");
53222
53466
  }
53223
53467
 
@@ -53261,7 +53505,7 @@ class TrianglesColorTextureRenderer$1 extends TrianglesBatchingRenderer {
53261
53505
  src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
53262
53506
  }
53263
53507
 
53264
- src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
53508
+ src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * newColor.rgb) + (reflectedColor * newColor.rgb), newColor.a);");
53265
53509
  if (gammaOutput) {
53266
53510
  src.push("vec4 colorTexel = color * sRGBToLinear(texture(uColorMap, vUV));");
53267
53511
  } else {
@@ -56042,11 +56286,14 @@ class TrianglesColorRenderer extends TrianglesInstancingRenderer {
56042
56286
  src.push("uniform vec3 sectionPlanePos" + i + ";");
56043
56287
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
56044
56288
  }
56289
+ src.push("uniform float sliceThickness;");
56290
+ src.push("uniform vec4 sliceColor;");
56045
56291
  }
56046
56292
  src.push("in vec4 vColor;");
56047
56293
  src.push("out vec4 outColor;");
56048
56294
  src.push("void main(void) {");
56049
-
56295
+ src.push(" vec4 newColor;");
56296
+ src.push(" newColor = vColor;");
56050
56297
  if (clipping) {
56051
56298
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
56052
56299
  src.push(" if (clippable) {");
@@ -56056,9 +56303,12 @@ class TrianglesColorRenderer extends TrianglesInstancingRenderer {
56056
56303
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
56057
56304
  src.push("}");
56058
56305
  }
56059
- src.push(" if (dist > 0.0) { ");
56306
+ src.push(" if (dist > sliceThickness) { ");
56060
56307
  src.push(" discard;");
56061
56308
  src.push(" }");
56309
+ src.push(" if (dist > 0.0) { ");
56310
+ src.push(" newColor = sliceColor;");
56311
+ src.push(" }");
56062
56312
  src.push("}");
56063
56313
  }
56064
56314
 
@@ -56076,9 +56326,9 @@ class TrianglesColorRenderer extends TrianglesInstancingRenderer {
56076
56326
  src.push(" float blendFactor = uSAOParams[3];");
56077
56327
  src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");
56078
56328
  src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");
56079
- src.push(" outColor = vec4(vColor.rgb * ambient, 1.0);");
56329
+ src.push(" outColor = vec4(newColor.rgb * ambient, 1.0);");
56080
56330
  } else {
56081
- src.push(" outColor = vColor;");
56331
+ src.push(" outColor = newColor;");
56082
56332
  }
56083
56333
  src.push("}");
56084
56334
  return src;
@@ -56103,7 +56353,7 @@ class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
56103
56353
  const src = [];
56104
56354
  src.push("#version 300 es");
56105
56355
  src.push("// Instancing geometry flat-shading drawing vertex shader");
56106
-
56356
+
56107
56357
  src.push("uniform int renderPass;");
56108
56358
 
56109
56359
  src.push("in vec3 position;");
@@ -56128,7 +56378,7 @@ class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
56128
56378
  src.push("}");
56129
56379
  src.push("out float isPerspective;");
56130
56380
  }
56131
-
56381
+
56132
56382
  if (clipping) {
56133
56383
  src.push("out vec4 vWorldPosition;");
56134
56384
  src.push("out float vFlags;");
@@ -56160,7 +56410,7 @@ class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
56160
56410
 
56161
56411
  src.push("vec4 clipPos = projMatrix * viewPosition;");
56162
56412
  if (scene.logarithmicDepthBufferEnabled) {
56163
- src.push("vFragDepth = 1.0 + clipPos.w;");
56413
+ src.push("vFragDepth = 1.0 + clipPos.w;");
56164
56414
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
56165
56415
  }
56166
56416
 
@@ -56185,7 +56435,7 @@ class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
56185
56435
  const src = [];
56186
56436
  src.push("#version 300 es");
56187
56437
  src.push("// Instancing geometry flat-shading drawing fragment shader");
56188
-
56438
+
56189
56439
  src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
56190
56440
  src.push("precision highp float;");
56191
56441
  src.push("precision highp int;");
@@ -56194,9 +56444,9 @@ class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
56194
56444
  src.push("precision mediump int;");
56195
56445
  src.push("#endif");
56196
56446
  if (scene.logarithmicDepthBufferEnabled) {
56197
- src.push("in float isPerspective;");
56198
- src.push("uniform float logDepthBufFC;");
56199
- src.push("in float vFragDepth;");
56447
+ src.push("in float isPerspective;");
56448
+ src.push("uniform float logDepthBufFC;");
56449
+ src.push("in float vFragDepth;");
56200
56450
  }
56201
56451
  if (this._withSAO) {
56202
56452
  src.push("uniform sampler2D uOcclusionTexture;");
@@ -56219,6 +56469,8 @@ class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
56219
56469
  src.push("uniform vec3 sectionPlanePos" + i + ";");
56220
56470
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
56221
56471
  }
56472
+ src.push("uniform float sliceThickness;");
56473
+ src.push("uniform vec4 sliceColor;");
56222
56474
  }
56223
56475
 
56224
56476
  this._addMatricesUniformBlockLines(src);
@@ -56248,7 +56500,8 @@ class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
56248
56500
  src.push("out vec4 outColor;");
56249
56501
 
56250
56502
  src.push("void main(void) {");
56251
-
56503
+ src.push(" vec4 newColor;");
56504
+ src.push(" newColor = vColor;");
56252
56505
  if (clipping) {
56253
56506
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
56254
56507
  src.push(" if (clippable) {");
@@ -56258,9 +56511,12 @@ class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
56258
56511
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
56259
56512
  src.push("}");
56260
56513
  }
56261
- src.push(" if (dist > 0.0) { ");
56514
+ src.push(" if (dist > sliceThickness) { ");
56262
56515
  src.push(" discard;");
56263
56516
  src.push(" }");
56517
+ src.push(" if (dist > 0.0) { ");
56518
+ src.push(" newColor = sliceColor;");
56519
+ src.push(" }");
56264
56520
  src.push("}");
56265
56521
  }
56266
56522
 
@@ -56303,7 +56559,7 @@ class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
56303
56559
  src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
56304
56560
  }
56305
56561
 
56306
- src.push("vec4 fragColor = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
56562
+ src.push("vec4 fragColor = vec4((lightAmbient.rgb * lightAmbient.a * newColor.rgb) + (reflectedColor * newColor.rgb), newColor.a);");
56307
56563
 
56308
56564
  if (this._withSAO) {
56309
56565
  // Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
@@ -56345,7 +56601,7 @@ class TrianglesSilhouetteRenderer extends TrianglesInstancingRenderer {
56345
56601
  const src = [];
56346
56602
  src.push("#version 300 es");
56347
56603
  src.push("// Instancing silhouette vertex shader");
56348
-
56604
+
56349
56605
  src.push("uniform int renderPass;");
56350
56606
 
56351
56607
  src.push("in vec3 position;");
@@ -56404,7 +56660,7 @@ class TrianglesSilhouetteRenderer extends TrianglesInstancingRenderer {
56404
56660
  src.push("vColor = vec4(silhouetteColor.r, silhouetteColor.g, silhouetteColor.b, min(silhouetteColor.a, float(color.a) / 255.0));");
56405
56661
  src.push("vec4 clipPos = projMatrix * viewPosition;");
56406
56662
  if (scene.logarithmicDepthBufferEnabled) {
56407
- src.push("vFragDepth = 1.0 + clipPos.w;");
56663
+ src.push("vFragDepth = 1.0 + clipPos.w;");
56408
56664
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
56409
56665
  }
56410
56666
  src.push("gl_Position = clipPos;");
@@ -56420,7 +56676,7 @@ class TrianglesSilhouetteRenderer extends TrianglesInstancingRenderer {
56420
56676
  const src = [];
56421
56677
  src.push("#version 300 es");
56422
56678
  src.push("// Instancing fill fragment shader");
56423
-
56679
+
56424
56680
  src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
56425
56681
  src.push("precision highp float;");
56426
56682
  src.push("precision highp int;");
@@ -56441,10 +56697,14 @@ class TrianglesSilhouetteRenderer extends TrianglesInstancingRenderer {
56441
56697
  src.push("uniform vec3 sectionPlanePos" + i + ";");
56442
56698
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
56443
56699
  }
56700
+ src.push("uniform float sliceThickness;");
56701
+ src.push("uniform vec4 sliceColor;");
56444
56702
  }
56445
56703
  src.push("in vec4 vColor;");
56446
56704
  src.push("out vec4 outColor;");
56447
56705
  src.push("void main(void) {");
56706
+ src.push(" vec4 newColor;");
56707
+ src.push(" newColor = vColor;");
56448
56708
  if (clipping) {
56449
56709
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
56450
56710
  src.push(" if (clippable) {");
@@ -56454,13 +56714,18 @@ class TrianglesSilhouetteRenderer extends TrianglesInstancingRenderer {
56454
56714
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
56455
56715
  src.push("}");
56456
56716
  }
56457
- src.push("if (dist > 0.0) { discard; }");
56717
+ src.push(" if (dist > sliceThickness) { ");
56718
+ src.push(" discard;");
56719
+ src.push(" }");
56720
+ src.push(" if (dist > 0.0) { ");
56721
+ src.push(" newColor = sliceColor;");
56722
+ src.push(" }");
56458
56723
  src.push("}");
56459
56724
  }
56460
56725
  if (scene.logarithmicDepthBufferEnabled) {
56461
56726
  src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
56462
56727
  }
56463
- src.push("outColor = vColor;");
56728
+ src.push("outColor = newColor;");
56464
56729
  src.push("}");
56465
56730
  return src;
56466
56731
  }
@@ -58490,6 +58755,8 @@ class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
58490
58755
  src.push("uniform vec3 sectionPlanePos" + i + ";");
58491
58756
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
58492
58757
  }
58758
+ src.push("uniform float sliceThickness;");
58759
+ src.push("uniform vec4 sliceColor;");
58493
58760
  }
58494
58761
  this._addMatricesUniformBlockLines(src);
58495
58762
 
@@ -58518,7 +58785,8 @@ class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
58518
58785
  src.push("out vec4 outColor;");
58519
58786
 
58520
58787
  src.push("void main(void) {");
58521
-
58788
+ src.push(" vec4 newColor;");
58789
+ src.push(" newColor = vColor;");
58522
58790
  if (clipping) {
58523
58791
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
58524
58792
  src.push(" if (clippable) {");
@@ -58528,9 +58796,12 @@ class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
58528
58796
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
58529
58797
  src.push("}");
58530
58798
  }
58531
- src.push(" if (dist > 0.0) { ");
58799
+ src.push(" if (dist > sliceThickness) { ");
58532
58800
  src.push(" discard;");
58533
58801
  src.push(" }");
58802
+ src.push(" if (dist > 0.0) { ");
58803
+ src.push(" newColor = sliceColor;");
58804
+ src.push(" }");
58534
58805
  src.push("}");
58535
58806
  }
58536
58807
 
@@ -58573,7 +58844,7 @@ class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
58573
58844
  src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
58574
58845
  }
58575
58846
 
58576
- src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
58847
+ src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * newColor.rgb) + (reflectedColor * newColor.rgb), newColor.a);");
58577
58848
  if (gammaOutput) {
58578
58849
  src.push("vec4 colorTexel = color * sRGBToLinear(texture(uColorMap, vUV));");
58579
58850
  } else {
@@ -58590,9 +58861,9 @@ class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
58590
58861
  src.push(" float blendFactor = uSAOParams[3];");
58591
58862
  src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");
58592
58863
  src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");
58593
- src.push(" outColor = vec4(vColor.rgb * colorTexel.rgb * ambient, opacity);");
58864
+ src.push(" outColor = vec4(newColor.rgb * colorTexel.rgb * ambient, opacity);");
58594
58865
  } else {
58595
- src.push(" outColor = vec4(vColor.rgb * colorTexel.rgb, opacity);");
58866
+ src.push(" outColor = vec4(newColor.rgb * colorTexel.rgb, opacity);");
58596
58867
  }
58597
58868
 
58598
58869
  if (gammaOutput) {