@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xeokit/xeokit-sdk",
3
- "version": "2.6.6",
3
+ "version": "2.6.7",
4
4
  "description": "Web Programming Toolkit for 3D/2D BIM and AEC Graphics",
5
5
  "module": "./dist/xeokit-sdk.es.js",
6
6
  "main": "./dist/xeokit-sdk.cjs.js",
@@ -117,6 +117,10 @@ export class VBORenderer {
117
117
  const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
118
118
  const baseIndex = layerIndex * numSectionPlanes;
119
119
  const renderFlags = model.renderFlags;
120
+ if (scene.crossSections) {
121
+ gl.uniform4fv(this._uSliceColor, scene.crossSections.sliceColor);
122
+ gl.uniform1f(this._uSliceThickness, scene.crossSections.sliceThickness);
123
+ }
120
124
  for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
121
125
  const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
122
126
  if (sectionPlaneUniforms) {
@@ -278,6 +282,11 @@ export class VBORenderer {
278
282
 
279
283
  this._uPointSize = program.getLocation("pointSize");
280
284
  this._uNearPlaneHeight = program.getLocation("nearPlaneHeight");
285
+
286
+ if (scene.crossSections) {
287
+ this._uSliceColor = program.getLocation("sliceColor");
288
+ this._uSliceThickness = program.getLocation("sliceThickness");
289
+ }
281
290
  }
282
291
 
283
292
  _bindProgram(frameCtx) {
@@ -643,4 +652,4 @@ export class VBORenderer {
643
652
  this._program = null;
644
653
  stats.memory.programs--;
645
654
  }
646
- }
655
+ }
@@ -67,7 +67,7 @@ export class EdgesColorRenderer extends EdgesRenderer {
67
67
 
68
68
  src.push("vec4 clipPos = projMatrix * viewPosition;");
69
69
  if (scene.logarithmicDepthBufferEnabled) {
70
- src.push("vFragDepth = 1.0 + clipPos.w;");
70
+ src.push("vFragDepth = 1.0 + clipPos.w;");
71
71
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
72
72
  }
73
73
  src.push("gl_Position = clipPos;");
@@ -128,4 +128,4 @@ export class EdgesColorRenderer extends EdgesRenderer {
128
128
  src.push("}");
129
129
  return src;
130
130
  }
131
- }
131
+ }
@@ -71,7 +71,7 @@ export class EdgesEmphasisRenderer extends EdgesRenderer {
71
71
 
72
72
  src.push("vec4 clipPos = projMatrix * viewPosition;");
73
73
  if (scene.logarithmicDepthBufferEnabled) {
74
- src.push("vFragDepth = 1.0 + clipPos.w;");
74
+ src.push("vFragDepth = 1.0 + clipPos.w;");
75
75
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
76
76
  }
77
77
  src.push("gl_Position = clipPos;");
@@ -88,7 +88,7 @@ export class EdgesEmphasisRenderer extends EdgesRenderer {
88
88
  const src = [];
89
89
  src.push("#version 300 es");
90
90
  src.push("// EdgesEmphasisRenderer fragment shader");
91
-
91
+
92
92
  src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
93
93
  src.push("precision highp float;");
94
94
  src.push("precision highp int;");
@@ -132,4 +132,4 @@ export class EdgesEmphasisRenderer extends EdgesRenderer {
132
132
  src.push("}");
133
133
  return src;
134
134
  }
135
- }
135
+ }
@@ -139,7 +139,7 @@ export class TrianglesColorRenderer extends TrianglesBatchingRenderer {
139
139
 
140
140
  src.push("vec4 clipPos = projMatrix * viewPosition;");
141
141
  if (scene.logarithmicDepthBufferEnabled) {
142
- src.push("vFragDepth = 1.0 + clipPos.w;");
142
+ src.push("vFragDepth = 1.0 + clipPos.w;");
143
143
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
144
144
  }
145
145
  if (clipping) {
@@ -194,11 +194,14 @@ export class TrianglesColorRenderer extends TrianglesBatchingRenderer {
194
194
  src.push("uniform vec3 sectionPlanePos" + i + ";");
195
195
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
196
196
  }
197
+ src.push("uniform float sliceThickness;");
198
+ src.push("uniform vec4 sliceColor;");
197
199
  }
198
200
  src.push("in vec4 vColor;");
199
201
  src.push("out vec4 outColor;");
200
202
  src.push("void main(void) {");
201
-
203
+ src.push(" vec4 newColor;");
204
+ src.push(" newColor = vColor;");
202
205
  if (clipping) {
203
206
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
204
207
  src.push(" if (clippable) {");
@@ -208,9 +211,12 @@ export class TrianglesColorRenderer extends TrianglesBatchingRenderer {
208
211
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
209
212
  src.push("}");
210
213
  }
211
- src.push(" if (dist > 0.0) { ");
212
- src.push(" discard;")
213
- src.push(" }");
214
+ src.push(" if (dist > sliceThickness) { ");
215
+ src.push(" discard;")
216
+ src.push(" }");
217
+ src.push(" if (dist > 0.0) { ");
218
+ src.push(" newColor = sliceColor;");
219
+ src.push(" }");
214
220
  src.push("}");
215
221
  }
216
222
 
@@ -227,12 +233,12 @@ export class TrianglesColorRenderer extends TrianglesBatchingRenderer {
227
233
  src.push(" float blendFactor = uSAOParams[3];");
228
234
  src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");
229
235
  src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");
230
- src.push(" outColor = vec4(vColor.rgb * ambient, 1.0);");
236
+ src.push(" outColor = vec4(newColor.rgb * ambient, 1.0);");
231
237
  } else {
232
- src.push(" outColor = vColor;");
238
+ src.push(" outColor = newColor;");
233
239
  }
234
240
 
235
241
  src.push("}");
236
242
  return src;
237
243
  }
238
- }
244
+ }
@@ -150,6 +150,8 @@ export class TrianglesColorTextureRenderer extends TrianglesBatchingRenderer {
150
150
  src.push("uniform vec3 sectionPlanePos" + i + ";");
151
151
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
152
152
  }
153
+ src.push("uniform float sliceThickness;");
154
+ src.push("uniform vec4 sliceColor;");
153
155
  }
154
156
  this._addMatricesUniformBlockLines(src);
155
157
  src.push("uniform vec4 lightAmbient;");
@@ -177,7 +179,8 @@ export class TrianglesColorTextureRenderer extends TrianglesBatchingRenderer {
177
179
  src.push("out vec4 outColor;");
178
180
 
179
181
  src.push("void main(void) {");
180
-
182
+ src.push(" vec4 newColor;");
183
+ src.push(" newColor = vColor;");
181
184
  if (clipping) {
182
185
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
183
186
  src.push(" if (clippable) {");
@@ -187,9 +190,12 @@ export class TrianglesColorTextureRenderer extends TrianglesBatchingRenderer {
187
190
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
188
191
  src.push("}");
189
192
  }
190
- src.push(" if (dist > 0.0) { ");
193
+ src.push(" if (dist > sliceThickness) { ");
191
194
  src.push(" discard;")
192
195
  src.push(" }");
196
+ src.push(" if (dist > 0.0) { ");
197
+ src.push(" newColor = sliceColor;");
198
+ src.push(" }");
193
199
  src.push("}");
194
200
  }
195
201
 
@@ -233,7 +239,7 @@ export class TrianglesColorTextureRenderer extends TrianglesBatchingRenderer {
233
239
  src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
234
240
  }
235
241
 
236
- src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
242
+ src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * newColor.rgb) + (reflectedColor * newColor.rgb), newColor.a);");
237
243
  if (gammaOutput) {
238
244
  src.push("vec4 colorTexel = color * sRGBToLinear(texture(uColorMap, vUV));");
239
245
  } else {
@@ -267,4 +273,4 @@ export class TrianglesColorTextureRenderer extends TrianglesBatchingRenderer {
267
273
  src.push("}");
268
274
  return src;
269
275
  }
270
- }
276
+ }
@@ -125,6 +125,8 @@ export class TrianglesFlatColorRenderer extends TrianglesBatchingRenderer {
125
125
  src.push("uniform vec3 sectionPlanePos" + i + ";");
126
126
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
127
127
  }
128
+ src.push("uniform float sliceThickness;");
129
+ src.push("uniform vec4 sliceColor;");
128
130
  }
129
131
 
130
132
  this._addMatricesUniformBlockLines(src);
@@ -153,7 +155,8 @@ export class TrianglesFlatColorRenderer extends TrianglesBatchingRenderer {
153
155
  src.push("out vec4 outColor;");
154
156
 
155
157
  src.push("void main(void) {");
156
-
158
+ src.push(" vec4 newColor;");
159
+ src.push(" newColor = vColor;");
157
160
  if (clipping) {
158
161
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
159
162
  src.push(" if (clippable) {");
@@ -163,9 +166,12 @@ export class TrianglesFlatColorRenderer extends TrianglesBatchingRenderer {
163
166
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
164
167
  src.push("}");
165
168
  }
166
- src.push(" if (dist > 0.0) { ");
169
+ src.push(" if (dist > sliceThickness) { ");
167
170
  src.push(" discard;")
168
171
  src.push(" }");
172
+ src.push(" if (dist > 0.0) { ");
173
+ src.push(" newColor = sliceColor;");
174
+ src.push(" }");
169
175
  src.push("}");
170
176
  }
171
177
 
@@ -209,7 +215,7 @@ export class TrianglesFlatColorRenderer extends TrianglesBatchingRenderer {
209
215
  src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
210
216
  }
211
217
 
212
- src.push("vec4 fragColor = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
218
+ src.push("vec4 fragColor = vec4((lightAmbient.rgb * lightAmbient.a * newColor.rgb) + (reflectedColor * newColor.rgb), newColor.a);");
213
219
 
214
220
  if (this._withSAO) {
215
221
  // Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
@@ -232,4 +238,4 @@ export class TrianglesFlatColorRenderer extends TrianglesBatchingRenderer {
232
238
  src.push("}");
233
239
  return src;
234
240
  }
235
- }
241
+ }
@@ -18,7 +18,7 @@ export class TrianglesSilhouetteRenderer extends TrianglesBatchingRenderer {
18
18
  const src = [];
19
19
  src.push("#version 300 es");
20
20
  src.push("// Triangles batching silhouette vertex shader");
21
-
21
+
22
22
  src.push("uniform int renderPass;");
23
23
 
24
24
  src.push("in vec3 position;");
@@ -70,7 +70,7 @@ export class TrianglesSilhouetteRenderer extends TrianglesBatchingRenderer {
70
70
  src.push("vColor = vec4(silhouetteColor.r, silhouetteColor.g, silhouetteColor.b, min(silhouetteColor.a, color.a ));");
71
71
  src.push("vec4 clipPos = projMatrix * viewPosition;");
72
72
  if (scene.logarithmicDepthBufferEnabled) {
73
- src.push("vFragDepth = 1.0 + clipPos.w;");
73
+ src.push("vFragDepth = 1.0 + clipPos.w;");
74
74
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
75
75
  }
76
76
  src.push("gl_Position = clipPos;");
@@ -88,7 +88,7 @@ export class TrianglesSilhouetteRenderer extends TrianglesBatchingRenderer {
88
88
  const src = [];
89
89
  src.push("#version 300 es");
90
90
  src.push("// Triangles batching silhouette fragment shader");
91
-
91
+
92
92
  src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
93
93
  src.push("precision highp float;");
94
94
  src.push("precision highp int;");
@@ -109,28 +109,36 @@ export class TrianglesSilhouetteRenderer extends TrianglesBatchingRenderer {
109
109
  src.push("uniform vec3 sectionPlanePos" + i + ";");
110
110
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
111
111
  }
112
+ src.push("uniform float sliceThickness;");
113
+ src.push("uniform vec4 sliceColor;");
112
114
  }
113
115
  src.push("in vec4 vColor;");
114
116
  src.push("out vec4 outColor;");
115
117
  src.push("void main(void) {");
118
+ src.push(" vec4 newColor;");
119
+ src.push(" newColor = vColor;");
116
120
  if (clipping) {
117
121
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
118
122
  src.push(" if (clippable) {");
119
123
  src.push(" float dist = 0.0;");
120
- for (i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
124
+ for (let i = 0, len = sectionPlanesState.getNumAllocatedSectionPlanes(); i < len; i++) {
121
125
  src.push("if (sectionPlaneActive" + i + ") {");
122
126
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
123
127
  src.push("}");
124
128
  }
125
- src.push(" if (dist > 0.0) { discard; }");
129
+ src.push(" if (dist > sliceThickness) { ");
130
+ src.push(" discard;")
131
+ src.push(" }");
132
+ src.push(" if (dist > 0.0) { ");
133
+ src.push(" newColor = sliceColor;");
134
+ src.push(" }");
126
135
  src.push("}");
127
136
  }
128
137
  if (scene.logarithmicDepthBufferEnabled) {
129
138
  src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
130
139
  }
131
- src.push("outColor = vColor;");
140
+ src.push("outColor = newColor;");
132
141
  src.push("}");
133
142
  return src;
134
143
  }
135
- }
136
-
144
+ }
@@ -132,5 +132,4 @@ export class EdgesColorRenderer extends EdgesRenderer {
132
132
  src.push("}");
133
133
  return src;
134
134
  }
135
- }
136
-
135
+ }
@@ -134,4 +134,4 @@ export class EdgesEmphasisRenderer extends EdgesRenderer {
134
134
  src.push("}");
135
135
  return src;
136
136
  }
137
- }
137
+ }
@@ -207,11 +207,14 @@ class TrianglesColorRenderer extends TrianglesInstancingRenderer {
207
207
  src.push("uniform vec3 sectionPlanePos" + i + ";");
208
208
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
209
209
  }
210
+ src.push("uniform float sliceThickness;");
211
+ src.push("uniform vec4 sliceColor;");
210
212
  }
211
213
  src.push("in vec4 vColor;");
212
214
  src.push("out vec4 outColor;");
213
215
  src.push("void main(void) {");
214
-
216
+ src.push(" vec4 newColor;");
217
+ src.push(" newColor = vColor;");
215
218
  if (clipping) {
216
219
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
217
220
  src.push(" if (clippable) {");
@@ -221,9 +224,12 @@ class TrianglesColorRenderer extends TrianglesInstancingRenderer {
221
224
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
222
225
  src.push("}");
223
226
  }
224
- src.push(" if (dist > 0.0) { ");
227
+ src.push(" if (dist > sliceThickness) { ");
225
228
  src.push(" discard;")
226
229
  src.push(" }");
230
+ src.push(" if (dist > 0.0) { ");
231
+ src.push(" newColor = sliceColor;");
232
+ src.push(" }");
227
233
  src.push("}");
228
234
  }
229
235
 
@@ -241,9 +247,9 @@ class TrianglesColorRenderer extends TrianglesInstancingRenderer {
241
247
  src.push(" float blendFactor = uSAOParams[3];");
242
248
  src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");
243
249
  src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");
244
- src.push(" outColor = vec4(vColor.rgb * ambient, 1.0);");
250
+ src.push(" outColor = vec4(newColor.rgb * ambient, 1.0);");
245
251
  } else {
246
- src.push(" outColor = vColor;");
252
+ src.push(" outColor = newColor;");
247
253
  }
248
254
  src.push("}");
249
255
  return src;
@@ -159,6 +159,8 @@ export class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
159
159
  src.push("uniform vec3 sectionPlanePos" + i + ";");
160
160
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
161
161
  }
162
+ src.push("uniform float sliceThickness;");
163
+ src.push("uniform vec4 sliceColor;");
162
164
  }
163
165
  this._addMatricesUniformBlockLines(src);
164
166
 
@@ -187,7 +189,8 @@ export class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
187
189
  src.push("out vec4 outColor;");
188
190
 
189
191
  src.push("void main(void) {");
190
-
192
+ src.push(" vec4 newColor;");
193
+ src.push(" newColor = vColor;");
191
194
  if (clipping) {
192
195
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
193
196
  src.push(" if (clippable) {");
@@ -197,9 +200,12 @@ export class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
197
200
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
198
201
  src.push("}");
199
202
  }
200
- src.push(" if (dist > 0.0) { ");
203
+ src.push(" if (dist > sliceThickness) { ");
201
204
  src.push(" discard;")
202
205
  src.push(" }");
206
+ src.push(" if (dist > 0.0) { ");
207
+ src.push(" newColor = sliceColor;");
208
+ src.push(" }");
203
209
  src.push("}");
204
210
  }
205
211
 
@@ -242,7 +248,7 @@ export class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
242
248
  src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
243
249
  }
244
250
 
245
- src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
251
+ src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * newColor.rgb) + (reflectedColor * newColor.rgb), newColor.a);");
246
252
  if (gammaOutput) {
247
253
  src.push("vec4 colorTexel = color * sRGBToLinear(texture(uColorMap, vUV));");
248
254
  } else {
@@ -259,9 +265,9 @@ export class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
259
265
  src.push(" float blendFactor = uSAOParams[3];");
260
266
  src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");
261
267
  src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");
262
- src.push(" outColor = vec4(vColor.rgb * colorTexel.rgb * ambient, opacity);");
268
+ src.push(" outColor = vec4(newColor.rgb * colorTexel.rgb * ambient, opacity);");
263
269
  } else {
264
- src.push(" outColor = vec4(vColor.rgb * colorTexel.rgb, opacity);");
270
+ src.push(" outColor = vec4(newColor.rgb * colorTexel.rgb, opacity);");
265
271
  }
266
272
 
267
273
  if (gammaOutput) {
@@ -275,4 +281,4 @@ export class TrianglesColorTextureRenderer extends TrianglesInstancingRenderer {
275
281
  src.push("}");
276
282
  return src;
277
283
  }
278
- }
284
+ }
@@ -18,7 +18,7 @@ export class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
18
18
  const src = [];
19
19
  src.push("#version 300 es");
20
20
  src.push("// Instancing geometry flat-shading drawing vertex shader");
21
-
21
+
22
22
  src.push("uniform int renderPass;");
23
23
 
24
24
  src.push("in vec3 position;");
@@ -43,7 +43,7 @@ export class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
43
43
  src.push("}");
44
44
  src.push("out float isPerspective;");
45
45
  }
46
-
46
+
47
47
  if (clipping) {
48
48
  src.push("out vec4 vWorldPosition;");
49
49
  src.push("out float vFlags;");
@@ -75,7 +75,7 @@ export class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
75
75
 
76
76
  src.push("vec4 clipPos = projMatrix * viewPosition;");
77
77
  if (scene.logarithmicDepthBufferEnabled) {
78
- src.push("vFragDepth = 1.0 + clipPos.w;");
78
+ src.push("vFragDepth = 1.0 + clipPos.w;");
79
79
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
80
80
  }
81
81
 
@@ -100,7 +100,7 @@ export class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
100
100
  const src = [];
101
101
  src.push("#version 300 es");
102
102
  src.push("// Instancing geometry flat-shading drawing fragment shader");
103
-
103
+
104
104
  src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
105
105
  src.push("precision highp float;");
106
106
  src.push("precision highp int;");
@@ -109,9 +109,9 @@ export class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
109
109
  src.push("precision mediump int;");
110
110
  src.push("#endif");
111
111
  if (scene.logarithmicDepthBufferEnabled) {
112
- src.push("in float isPerspective;");
113
- src.push("uniform float logDepthBufFC;");
114
- src.push("in float vFragDepth;");
112
+ src.push("in float isPerspective;");
113
+ src.push("uniform float logDepthBufFC;");
114
+ src.push("in float vFragDepth;");
115
115
  }
116
116
  if (this._withSAO) {
117
117
  src.push("uniform sampler2D uOcclusionTexture;");
@@ -134,6 +134,8 @@ export class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
134
134
  src.push("uniform vec3 sectionPlanePos" + i + ";");
135
135
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
136
136
  }
137
+ src.push("uniform float sliceThickness;");
138
+ src.push("uniform vec4 sliceColor;");
137
139
  }
138
140
 
139
141
  this._addMatricesUniformBlockLines(src);
@@ -163,7 +165,8 @@ export class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
163
165
  src.push("out vec4 outColor;");
164
166
 
165
167
  src.push("void main(void) {");
166
-
168
+ src.push(" vec4 newColor;");
169
+ src.push(" newColor = vColor;");
167
170
  if (clipping) {
168
171
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
169
172
  src.push(" if (clippable) {");
@@ -173,9 +176,12 @@ export class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
173
176
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
174
177
  src.push("}");
175
178
  }
176
- src.push(" if (dist > 0.0) { ");
179
+ src.push(" if (dist > sliceThickness) { ");
177
180
  src.push(" discard;")
178
181
  src.push(" }");
182
+ src.push(" if (dist > 0.0) { ");
183
+ src.push(" newColor = sliceColor;");
184
+ src.push(" }");
179
185
  src.push("}");
180
186
  }
181
187
 
@@ -218,7 +224,7 @@ export class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
218
224
  src.push("reflectedColor += lambertian * (lightColor" + i + ".rgb * lightColor" + i + ".a);");
219
225
  }
220
226
 
221
- src.push("vec4 fragColor = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
227
+ src.push("vec4 fragColor = vec4((lightAmbient.rgb * lightAmbient.a * newColor.rgb) + (reflectedColor * newColor.rgb), newColor.a);");
222
228
 
223
229
  if (this._withSAO) {
224
230
  // Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
@@ -241,4 +247,4 @@ export class TrianglesFlatColorRenderer extends TrianglesInstancingRenderer {
241
247
  src.push("}");
242
248
  return src;
243
249
  }
244
- }
250
+ }
@@ -17,7 +17,7 @@ export class TrianglesSilhouetteRenderer extends TrianglesInstancingRenderer {
17
17
  const src = [];
18
18
  src.push("#version 300 es");
19
19
  src.push("// Instancing silhouette vertex shader");
20
-
20
+
21
21
  src.push("uniform int renderPass;");
22
22
 
23
23
  src.push("in vec3 position;");
@@ -76,7 +76,7 @@ export class TrianglesSilhouetteRenderer extends TrianglesInstancingRenderer {
76
76
  src.push("vColor = vec4(silhouetteColor.r, silhouetteColor.g, silhouetteColor.b, min(silhouetteColor.a, float(color.a) / 255.0));");
77
77
  src.push("vec4 clipPos = projMatrix * viewPosition;");
78
78
  if (scene.logarithmicDepthBufferEnabled) {
79
- src.push("vFragDepth = 1.0 + clipPos.w;");
79
+ src.push("vFragDepth = 1.0 + clipPos.w;");
80
80
  src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
81
81
  }
82
82
  src.push("gl_Position = clipPos;");
@@ -92,7 +92,7 @@ export class TrianglesSilhouetteRenderer extends TrianglesInstancingRenderer {
92
92
  const src = [];
93
93
  src.push("#version 300 es");
94
94
  src.push("// Instancing fill fragment shader");
95
-
95
+
96
96
  src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
97
97
  src.push("precision highp float;");
98
98
  src.push("precision highp int;");
@@ -113,10 +113,14 @@ export class TrianglesSilhouetteRenderer extends TrianglesInstancingRenderer {
113
113
  src.push("uniform vec3 sectionPlanePos" + i + ";");
114
114
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
115
115
  }
116
+ src.push("uniform float sliceThickness;");
117
+ src.push("uniform vec4 sliceColor;");
116
118
  }
117
119
  src.push("in vec4 vColor;");
118
120
  src.push("out vec4 outColor;");
119
121
  src.push("void main(void) {");
122
+ src.push(" vec4 newColor;");
123
+ src.push(" newColor = vColor;");
120
124
  if (clipping) {
121
125
  src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");
122
126
  src.push(" if (clippable) {");
@@ -126,14 +130,19 @@ export class TrianglesSilhouetteRenderer extends TrianglesInstancingRenderer {
126
130
  src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
127
131
  src.push("}");
128
132
  }
129
- src.push("if (dist > 0.0) { discard; }");
133
+ src.push(" if (dist > sliceThickness) { ");
134
+ src.push(" discard;")
135
+ src.push(" }");
136
+ src.push(" if (dist > 0.0) { ");
137
+ src.push(" newColor = sliceColor;");
138
+ src.push(" }");
130
139
  src.push("}");
131
140
  }
132
141
  if (scene.logarithmicDepthBufferEnabled) {
133
142
  src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
134
143
  }
135
- src.push("outColor = vColor;");
144
+ src.push("outColor = newColor;");
136
145
  src.push("}");
137
146
  return src;
138
147
  }
139
- }
148
+ }