@xeokit/xeokit-sdk 2.6.61 → 2.6.63
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.
- package/dist/xeokit-sdk.cjs.js +123 -51
- package/dist/xeokit-sdk.es.js +123 -51
- package/dist/xeokit-sdk.es5.js +89 -87
- package/dist/xeokit-sdk.min.cjs.js +5 -5
- package/dist/xeokit-sdk.min.es.js +5 -5
- package/dist/xeokit-sdk.min.es5.js +4 -4
- package/package.json +2 -1
- package/src/extras/ContextMenu/ContextMenu.js +11 -4
- package/src/plugins/AnnotationsPlugin/Annotation.js +3 -3
- package/src/plugins/ZonesPlugin/ZonesPlugin.js +14 -14
- package/src/plugins/lib/html/MenuEvent.js +17 -4
- package/src/viewer/metadata/MetaScene.js +2 -2
- package/src/viewer/scene/CameraControl/lib/handlers/KeyboardPanRotateDollyHandler.js +10 -0
- package/src/viewer/scene/CameraControl/lib/handlers/MousePanRotateDollyHandler.js +10 -0
- package/src/viewer/scene/CameraControl/lib/handlers/MousePickHandler.js +1 -1
- package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesColorRenderer.js +19 -4
- package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesEdgesColorRenderer.js +11 -2
- package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesEdgesRenderer.js +11 -2
- package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesSilhouetteRenderer.js +9 -2
- package/src/viewer/scene/model/vbo/VBORenderer.js +2 -2
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesBatchingRenderer.js +3 -1
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesSnapRenderer.js +5 -3
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesInstancingRenderer.js +3 -1
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesSnapRenderer.js +6 -4
- package/src/viewer/scene/webgl/Renderer.js +6 -2
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xeokit/xeokit-sdk",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.63",
|
|
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",
|
|
7
7
|
"types": "./types/index.d.ts",
|
|
8
|
+
|
|
8
9
|
"scripts": {
|
|
9
10
|
"build": "rollup --config rollup.config.js; rollup --config rollup.minified.config.js",
|
|
10
11
|
"dev-build": "rollup --config rollup.dev.config.js",
|
|
@@ -738,12 +738,19 @@ class ContextMenu {
|
|
|
738
738
|
const menuRect = subMenuElement.getBoundingClientRect();
|
|
739
739
|
|
|
740
740
|
const subMenuWidth = 200; // TODO
|
|
741
|
-
const
|
|
741
|
+
const showOnRight = (itemRect.right + subMenuWidth) < window.innerWidth;
|
|
742
|
+
const showOnLeft = (itemRect.left - subMenuWidth) > 0;
|
|
742
743
|
|
|
743
|
-
if
|
|
744
|
-
self._showMenu(subMenu.id, itemRect.left - subMenuWidth, itemRect.top - 1);
|
|
745
|
-
} else {
|
|
744
|
+
if(showOnRight)
|
|
746
745
|
self._showMenu(subMenu.id, itemRect.right - 5, itemRect.top - 1);
|
|
746
|
+
else if (showOnLeft)
|
|
747
|
+
self._showMenu(subMenu.id, itemRect.left - subMenuWidth, itemRect.top - 1);
|
|
748
|
+
else {
|
|
749
|
+
const spaceOnLeft = itemRect.left, spaceOnRight = window.innerWidth - itemRect.right;
|
|
750
|
+
if(spaceOnRight > spaceOnLeft)
|
|
751
|
+
self._showMenu(subMenu.id, itemRect.right - 5 - (subMenuWidth - spaceOnRight), itemRect.top - 1);
|
|
752
|
+
else
|
|
753
|
+
self._showMenu(subMenu.id, itemRect.left - spaceOnLeft, itemRect.top - 1);
|
|
747
754
|
}
|
|
748
755
|
|
|
749
756
|
lastSubMenu = subMenu;
|
|
@@ -46,10 +46,10 @@ class Annotation extends Marker {
|
|
|
46
46
|
this._marker.addEventListener("click", this._onMouseClickedExternalMarker = () => {
|
|
47
47
|
this.plugin.fire("markerClicked", this);
|
|
48
48
|
});
|
|
49
|
-
this.
|
|
49
|
+
this._onContextMenuExternalMarker = () => {
|
|
50
50
|
this.plugin.fire("contextmenu", this);
|
|
51
51
|
}
|
|
52
|
-
this.
|
|
52
|
+
this._onContextMenuExternalMarkerRemover = addContextMenuListener(this._marker, this._onContextMenuExternalMarker);
|
|
53
53
|
this._marker.addEventListener("mouseenter", this._onMouseEnterExternalMarker = () => {
|
|
54
54
|
this.plugin.fire("markerMouseEnter", this);
|
|
55
55
|
});
|
|
@@ -420,7 +420,7 @@ class Annotation extends Marker {
|
|
|
420
420
|
this._marker = null;
|
|
421
421
|
} else {
|
|
422
422
|
this._marker.removeEventListener("click", this._onMouseClickedExternalMarker);
|
|
423
|
-
this.
|
|
423
|
+
this._onContextMenuExternalMarkerRemover();
|
|
424
424
|
this._marker.removeEventListener("mouseenter", this._onMouseEnterExternalMarker);
|
|
425
425
|
this._marker.removeEventListener("mouseleave", this._onMouseLeaveExternalMarker);
|
|
426
426
|
this._marker = null;
|
|
@@ -482,8 +482,21 @@ class Zone extends Component {
|
|
|
482
482
|
}
|
|
483
483
|
|
|
484
484
|
|
|
485
|
-
const
|
|
485
|
+
const min = idx => Math.min(...pos.map(p => p[idx]));
|
|
486
|
+
const max = idx => Math.max(...pos.map(p => p[idx]));
|
|
487
|
+
|
|
488
|
+
const xmin = min(0);
|
|
489
|
+
const ymin = min(1);
|
|
490
|
+
const zmin = min(2);
|
|
491
|
+
const xmax = max(0);
|
|
492
|
+
const ymax = max(1);
|
|
493
|
+
const zmax = max(2);
|
|
494
|
+
|
|
495
|
+
this._center = math.vec3([ (xmin + xmax) / 2, (ymin + ymax) / 2, (zmin + zmax) / 2 ]);
|
|
496
|
+
|
|
497
|
+
const positions = [].concat(...pos.map(p => math.subVec3(p, this._center, p)));
|
|
486
498
|
this._zoneMesh = new Mesh(scene, {
|
|
499
|
+
origin: this._center,
|
|
487
500
|
edges: this._edges,
|
|
488
501
|
geometry: new ReadableGeometry(
|
|
489
502
|
scene,
|
|
@@ -524,19 +537,6 @@ class Zone extends Component {
|
|
|
524
537
|
}
|
|
525
538
|
|
|
526
539
|
this._metrics = null;
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
const min = idx => Math.min(...pos.map(p => p[idx]));
|
|
530
|
-
const max = idx => Math.max(...pos.map(p => p[idx]));
|
|
531
|
-
|
|
532
|
-
const xmin = min(0);
|
|
533
|
-
const ymin = min(1);
|
|
534
|
-
const zmin = min(2);
|
|
535
|
-
const xmax = max(0);
|
|
536
|
-
const ymax = max(1);
|
|
537
|
-
const zmax = max(2);
|
|
538
|
-
|
|
539
|
-
this._center = math.vec3([ (xmin + xmax) / 2, (ymin + ymax) / 2, (zmin + zmax) / 2 ]);
|
|
540
540
|
}
|
|
541
541
|
|
|
542
542
|
get baseArea() {
|
|
@@ -10,14 +10,17 @@ export function addContextMenuListener(elem, callback) {
|
|
|
10
10
|
|
|
11
11
|
const touchStartHandler = (event) => {
|
|
12
12
|
event.preventDefault();
|
|
13
|
-
|
|
14
|
-
startX = touch.clientX;
|
|
15
|
-
startY = touch.clientY;
|
|
16
|
-
|
|
13
|
+
|
|
17
14
|
if (timeout) {
|
|
18
15
|
clearTimeout(timeout);
|
|
19
16
|
timeout = null;
|
|
20
17
|
}
|
|
18
|
+
// If more than one finger touches the screen, cancel the timeout
|
|
19
|
+
if (event.touches.length > 1) return;
|
|
20
|
+
|
|
21
|
+
const touch = event.touches[0];
|
|
22
|
+
startX = touch.clientX;
|
|
23
|
+
startY = touch.clientY;
|
|
21
24
|
|
|
22
25
|
timeout = setTimeout(() => {
|
|
23
26
|
event.clientX = touch.clientX;
|
|
@@ -28,6 +31,14 @@ export function addContextMenuListener(elem, callback) {
|
|
|
28
31
|
}, longPressTimer);
|
|
29
32
|
};
|
|
30
33
|
|
|
34
|
+
const globalTouchStartHandler = (event) => {
|
|
35
|
+
// Cancel timeout if multiple touches are detected anywhere on the screen
|
|
36
|
+
if (event.touches.length > 1 && timeout) {
|
|
37
|
+
clearTimeout(timeout);
|
|
38
|
+
timeout = null;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
31
42
|
const touchMoveHandler = (event) => {
|
|
32
43
|
if (!timeout) return;
|
|
33
44
|
const touch = event.touches[0];
|
|
@@ -58,6 +69,7 @@ export function addContextMenuListener(elem, callback) {
|
|
|
58
69
|
elem.addEventListener('touchstart', touchStartHandler);
|
|
59
70
|
elem.addEventListener('touchmove', touchMoveHandler);
|
|
60
71
|
elem.addEventListener('touchend', touchEndHandler);
|
|
72
|
+
window.addEventListener('touchstart', globalTouchStartHandler);
|
|
61
73
|
} else {
|
|
62
74
|
elem.addEventListener('contextmenu', contextMenuHandler);
|
|
63
75
|
}
|
|
@@ -67,6 +79,7 @@ export function addContextMenuListener(elem, callback) {
|
|
|
67
79
|
elem.removeEventListener('touchstart', touchStartHandler);
|
|
68
80
|
elem.removeEventListener('touchmove', touchMoveHandler);
|
|
69
81
|
elem.removeEventListener('touchend', touchEndHandler);
|
|
82
|
+
window.removeEventListener('touchstart', globalTouchStartHandler);
|
|
70
83
|
} else {
|
|
71
84
|
elem.removeEventListener('contextmenu', contextMenuHandler);
|
|
72
85
|
}
|
|
@@ -253,8 +253,8 @@ class MetaScene {
|
|
|
253
253
|
|
|
254
254
|
for (let modelId in this.metaModels) {
|
|
255
255
|
const metaModel = this.metaModels[modelId];
|
|
256
|
-
for (let
|
|
257
|
-
const metaObject = metaModel.metaObjects[
|
|
256
|
+
for (let objectId in metaModel.metaObjects) {
|
|
257
|
+
const metaObject = metaModel.metaObjects[objectId];
|
|
258
258
|
metaObject.metaModels.push(metaModel);
|
|
259
259
|
}
|
|
260
260
|
}
|
|
@@ -39,6 +39,14 @@ class KeyboardPanRotateDollyHandler {
|
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
+
document.addEventListener("visibilitychange", this._onVisibilityChange = () => {
|
|
43
|
+
keyDownMap.splice(0);
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
window.addEventListener("blur", this._onBlur = () => {
|
|
47
|
+
keyDownMap.splice(0);
|
|
48
|
+
})
|
|
49
|
+
|
|
42
50
|
this._onTick = scene.on("tick", (e) => {
|
|
43
51
|
|
|
44
52
|
if (!(configs.active && configs.pointerEnabled) || (!scene.input.keyboardEnabled)) {
|
|
@@ -168,6 +176,8 @@ class KeyboardPanRotateDollyHandler {
|
|
|
168
176
|
|
|
169
177
|
this._scene.input.off(this._onSceneMouseMove);
|
|
170
178
|
this._scene.input.off(this._onSceneKeyDown);
|
|
179
|
+
document.removeEventListener("visibilitychange", this._onVisibilityChange);
|
|
180
|
+
window.removeEventListener("blur", this._onBlur);
|
|
171
181
|
this._scene.input.off(this._onSceneKeyUp);
|
|
172
182
|
}
|
|
173
183
|
}
|
|
@@ -77,6 +77,14 @@ class MousePanRotateDollyHandler {
|
|
|
77
77
|
keyDown[keyCode] = false;
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
+
document.addEventListener("visibilitychange", this._onVisibilityChange = () => {
|
|
81
|
+
keyDown.splice(0);
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
window.addEventListener("blur", this._onBlur = () => {
|
|
85
|
+
keyDown.splice(0);
|
|
86
|
+
})
|
|
87
|
+
|
|
80
88
|
function setMousedownState(pick = true) {
|
|
81
89
|
setMousedownPositions();
|
|
82
90
|
if (pick) {
|
|
@@ -355,6 +363,8 @@ class MousePanRotateDollyHandler {
|
|
|
355
363
|
|
|
356
364
|
document.removeEventListener("keydown", this._documentKeyDownHandler);
|
|
357
365
|
document.removeEventListener("keyup", this._documentKeyUpHandler);
|
|
366
|
+
document.removeEventListener("visibilitychange", this._onVisibilityChange);
|
|
367
|
+
window.removeEventListener("blur", this._onBlur);
|
|
358
368
|
canvas.removeEventListener("mousedown", this._mouseDownHandler);
|
|
359
369
|
document.removeEventListener("mousemove", this._documentMouseMoveHandler);
|
|
360
370
|
canvas.removeEventListener("mousemove", this._canvasMouseMoveHandler);
|
|
@@ -110,6 +110,10 @@ export class DTXTrianglesColorRenderer {
|
|
|
110
110
|
const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
|
|
111
111
|
const baseIndex = dataTextureLayer.layerIndex * numSectionPlanes;
|
|
112
112
|
const renderFlags = model.renderFlags;
|
|
113
|
+
if (scene.crossSections) {
|
|
114
|
+
gl.uniform4fv(this._uSliceColor, scene.crossSections.sliceColor);
|
|
115
|
+
gl.uniform1f(this._uSliceThickness, scene.crossSections.sliceThickness);
|
|
116
|
+
}
|
|
113
117
|
for (let sectionPlaneIndex = 0; sectionPlaneIndex < numAllocatedSectionPlanes; sectionPlaneIndex++) {
|
|
114
118
|
const sectionPlaneUniforms = this._uSectionPlanes[sectionPlaneIndex];
|
|
115
119
|
if (sectionPlaneUniforms) {
|
|
@@ -247,6 +251,11 @@ export class DTXTrianglesColorRenderer {
|
|
|
247
251
|
this._uTexturePerPolygonIdPortionIds = "uTexturePerPolygonIdPortionIds";
|
|
248
252
|
this._uTexturePerObjectMatrix= "uTexturePerObjectMatrix";
|
|
249
253
|
this._uCameraEyeRtc = program.getLocation("uCameraEyeRtc");
|
|
254
|
+
|
|
255
|
+
if (scene.crossSections) {
|
|
256
|
+
this._uSliceColor = program.getLocation("sliceColor");
|
|
257
|
+
this._uSliceThickness = program.getLocation("sliceThickness");
|
|
258
|
+
}
|
|
250
259
|
}
|
|
251
260
|
|
|
252
261
|
_bindProgram(frameCtx) {
|
|
@@ -563,11 +572,14 @@ export class DTXTrianglesColorRenderer {
|
|
|
563
572
|
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
564
573
|
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
565
574
|
}
|
|
575
|
+
src.push("uniform float sliceThickness;");
|
|
576
|
+
src.push("uniform vec4 sliceColor;");
|
|
566
577
|
}
|
|
567
578
|
src.push("in vec4 vColor;");
|
|
568
579
|
src.push("out vec4 outColor;");
|
|
569
580
|
src.push("void main(void) {");
|
|
570
|
-
|
|
581
|
+
src.push(" vec4 newColor;");
|
|
582
|
+
src.push(" newColor = vColor;");
|
|
571
583
|
if (clipping) {
|
|
572
584
|
src.push(" bool clippable = vFlags2 > 0u;");
|
|
573
585
|
src.push(" if (clippable) {");
|
|
@@ -577,9 +589,12 @@ export class DTXTrianglesColorRenderer {
|
|
|
577
589
|
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
578
590
|
src.push("}");
|
|
579
591
|
}
|
|
580
|
-
src.push(" if (dist >
|
|
592
|
+
src.push(" if (dist > sliceThickness) { ");
|
|
581
593
|
src.push(" discard;")
|
|
582
594
|
src.push(" }");
|
|
595
|
+
src.push(" if (dist > 0.0) { ");
|
|
596
|
+
src.push(" newColor = sliceColor;");
|
|
597
|
+
src.push(" }");
|
|
583
598
|
src.push("}");
|
|
584
599
|
}
|
|
585
600
|
|
|
@@ -597,9 +612,9 @@ export class DTXTrianglesColorRenderer {
|
|
|
597
612
|
src.push(" float blendFactor = uSAOParams[3];");
|
|
598
613
|
src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");
|
|
599
614
|
src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");
|
|
600
|
-
src.push(" outColor = vec4(
|
|
615
|
+
src.push(" outColor = vec4(newColor.rgb * ambient, 1.0);");
|
|
601
616
|
} else {
|
|
602
|
-
src.push(" outColor =
|
|
617
|
+
src.push(" outColor = newColor;");
|
|
603
618
|
}
|
|
604
619
|
|
|
605
620
|
src.push("}");
|
|
@@ -377,10 +377,14 @@ export class DTXTrianglesEdgesColorRenderer {
|
|
|
377
377
|
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
378
378
|
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
379
379
|
}
|
|
380
|
+
src.push("uniform float sliceThickness;");
|
|
381
|
+
src.push("uniform vec4 sliceColor;");
|
|
380
382
|
}
|
|
381
383
|
src.push("in vec4 vColor;");
|
|
382
384
|
src.push("out vec4 outColor;");
|
|
383
385
|
src.push("void main(void) {");
|
|
386
|
+
src.push(" vec4 newColor;");
|
|
387
|
+
src.push(" newColor = vColor;");
|
|
384
388
|
if (clipping) {
|
|
385
389
|
src.push(" bool clippable = vFlags2 > 0u;");
|
|
386
390
|
src.push(" if (clippable) {");
|
|
@@ -390,13 +394,18 @@ export class DTXTrianglesEdgesColorRenderer {
|
|
|
390
394
|
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
391
395
|
src.push("}");
|
|
392
396
|
}
|
|
393
|
-
src.push(" if (dist >
|
|
397
|
+
src.push(" if (dist > sliceThickness) { ");
|
|
398
|
+
src.push(" discard;")
|
|
399
|
+
src.push(" }");
|
|
400
|
+
src.push(" if (dist > 0.0) { ");
|
|
401
|
+
src.push(" newColor = sliceColor;");
|
|
402
|
+
src.push(" }");
|
|
394
403
|
src.push("}");
|
|
395
404
|
}
|
|
396
405
|
if (scene.logarithmicDepthBufferEnabled) {
|
|
397
406
|
src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
398
407
|
}
|
|
399
|
-
src.push(" outColor =
|
|
408
|
+
src.push(" outColor = newColor;");
|
|
400
409
|
src.push("}");
|
|
401
410
|
return src;
|
|
402
411
|
}
|
|
@@ -385,10 +385,14 @@ export class DTXTrianglesEdgesRenderer {
|
|
|
385
385
|
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
386
386
|
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
387
387
|
}
|
|
388
|
+
src.push("uniform float sliceThickness;");
|
|
389
|
+
src.push("uniform vec4 sliceColor;");
|
|
388
390
|
}
|
|
389
391
|
src.push("in vec4 vColor;");
|
|
390
392
|
src.push("out vec4 outColor;");
|
|
391
393
|
src.push("void main(void) {");
|
|
394
|
+
src.push(" vec4 newColor;");
|
|
395
|
+
src.push(" newColor = vColor;");
|
|
392
396
|
if (clipping) {
|
|
393
397
|
src.push(" bool clippable = vFlags2 > 0u;");
|
|
394
398
|
src.push(" if (clippable) {");
|
|
@@ -398,13 +402,18 @@ export class DTXTrianglesEdgesRenderer {
|
|
|
398
402
|
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
399
403
|
src.push("}");
|
|
400
404
|
}
|
|
401
|
-
src.push(" if (dist >
|
|
405
|
+
src.push(" if (dist > sliceThickness) { ");
|
|
406
|
+
src.push(" discard;")
|
|
407
|
+
src.push(" }");
|
|
408
|
+
src.push(" if (dist > 0.0) { ");
|
|
409
|
+
src.push(" newColor = sliceColor;");
|
|
410
|
+
src.push(" }");
|
|
402
411
|
src.push("}");
|
|
403
412
|
}
|
|
404
413
|
if (scene.logarithmicDepthBufferEnabled) {
|
|
405
414
|
src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
406
415
|
}
|
|
407
|
-
src.push(" outColor =
|
|
416
|
+
src.push(" outColor = newColor;");
|
|
408
417
|
src.push("}");
|
|
409
418
|
return src;
|
|
410
419
|
}
|
|
@@ -426,10 +426,14 @@ export class DTXTrianglesSilhouetteRenderer {
|
|
|
426
426
|
src.push("uniform vec3 sectionPlanePos" + i + ";");
|
|
427
427
|
src.push("uniform vec3 sectionPlaneDir" + i + ";");
|
|
428
428
|
}
|
|
429
|
+
src.push("uniform float sliceThickness;");
|
|
430
|
+
src.push("uniform vec4 sliceColor;");
|
|
429
431
|
}
|
|
430
432
|
src.push("uniform vec4 color;");
|
|
431
433
|
src.push("out vec4 outColor;");
|
|
432
434
|
src.push("void main(void) {");
|
|
435
|
+
src.push(" vec4 newColor;");
|
|
436
|
+
src.push(" newColor = color;");
|
|
433
437
|
if (clipping) {
|
|
434
438
|
src.push(" bool clippable = vFlags2 > 0u;");
|
|
435
439
|
src.push(" if (clippable) {");
|
|
@@ -439,15 +443,18 @@ export class DTXTrianglesSilhouetteRenderer {
|
|
|
439
443
|
src.push(" dist += clamp(dot(-sectionPlaneDir" + i + ".xyz, vWorldPosition.xyz - sectionPlanePos" + i + ".xyz), 0.0, 1000.0);");
|
|
440
444
|
src.push("}");
|
|
441
445
|
}
|
|
442
|
-
src.push(" if (dist >
|
|
446
|
+
src.push(" if (dist > sliceThickness) { ");
|
|
443
447
|
src.push(" discard;")
|
|
444
448
|
src.push(" }");
|
|
449
|
+
src.push(" if (dist > 0.0) { ");
|
|
450
|
+
src.push(" newColor = sliceColor;");
|
|
451
|
+
src.push(" }");
|
|
445
452
|
src.push("}");
|
|
446
453
|
}
|
|
447
454
|
if (scene.logarithmicDepthBufferEnabled) {
|
|
448
455
|
src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
449
456
|
}
|
|
450
|
-
src.push(" outColor =
|
|
457
|
+
src.push(" outColor = newColor;");
|
|
451
458
|
src.push("}");
|
|
452
459
|
return src;
|
|
453
460
|
}
|
|
@@ -407,7 +407,7 @@ export class VBORenderer {
|
|
|
407
407
|
}
|
|
408
408
|
|
|
409
409
|
if (this._instancing) {
|
|
410
|
-
if (this._edges) {
|
|
410
|
+
if (this._edges && state.edgeIndicesBuf) {
|
|
411
411
|
state.edgeIndicesBuf.bind();
|
|
412
412
|
} else {
|
|
413
413
|
if (state.indicesBuf) {
|
|
@@ -415,7 +415,7 @@ export class VBORenderer {
|
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
417
|
} else {
|
|
418
|
-
if (this._edges) {
|
|
418
|
+
if (this._edges && state.edgeIndicesBuf) {
|
|
419
419
|
state.edgeIndicesBuf.bind();
|
|
420
420
|
} else {
|
|
421
421
|
if (state.indicesBuf) {
|
package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesBatchingRenderer.js
CHANGED
|
@@ -19,7 +19,9 @@ export class TrianglesBatchingRenderer extends VBORenderer {
|
|
|
19
19
|
} = drawCfg;
|
|
20
20
|
|
|
21
21
|
if (this._edges) {
|
|
22
|
-
|
|
22
|
+
if (state.edgeIndicesBuf) {
|
|
23
|
+
gl.drawElements(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0);
|
|
24
|
+
}
|
|
23
25
|
} else {
|
|
24
26
|
const count = frameCtx.pickElementsCount || state.indicesBuf.numItems;
|
|
25
27
|
const offset = frameCtx.pickElementsOffset ? frameCtx.pickElementsOffset * state.indicesBuf.itemByteSize : 0;
|
|
@@ -128,9 +128,11 @@ export class TrianglesSnapRenderer extends VBORenderer{
|
|
|
128
128
|
//=============================================================
|
|
129
129
|
|
|
130
130
|
if (frameCtx.snapMode === "edge") {
|
|
131
|
-
state.edgeIndicesBuf
|
|
132
|
-
|
|
133
|
-
|
|
131
|
+
if (state.edgeIndicesBuf) {
|
|
132
|
+
state.edgeIndicesBuf.bind();
|
|
133
|
+
gl.drawElements(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0);
|
|
134
|
+
state.edgeIndicesBuf.unbind(); // needed?
|
|
135
|
+
}
|
|
134
136
|
} else {
|
|
135
137
|
gl.drawArrays(gl.POINTS, 0, state.positionsBuf.numItems);
|
|
136
138
|
}
|
package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesInstancingRenderer.js
CHANGED
|
@@ -18,7 +18,9 @@ export class TrianglesInstancingRenderer extends VBORenderer {
|
|
|
18
18
|
} = drawCfg;
|
|
19
19
|
|
|
20
20
|
if (this._edges) {
|
|
21
|
-
|
|
21
|
+
if (state.edgeIndicesBuf) {
|
|
22
|
+
gl.drawElementsInstanced(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0, state.numInstances);
|
|
23
|
+
}
|
|
22
24
|
} else {
|
|
23
25
|
gl.drawElementsInstanced(gl.TRIANGLES, state.indicesBuf.numItems, state.indicesBuf.itemType, 0, state.numInstances);
|
|
24
26
|
|
|
@@ -134,10 +134,12 @@ export class TrianglesSnapRenderer extends VBORenderer {
|
|
|
134
134
|
this._aFlags.bindArrayBuffer(state.flagsBuf);
|
|
135
135
|
gl.vertexAttribDivisor(this._aFlags.location, 1);
|
|
136
136
|
|
|
137
|
-
if (frameCtx.snapMode === "edge") {
|
|
138
|
-
state.edgeIndicesBuf
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
if (frameCtx.snapMode === "edge" ) {
|
|
138
|
+
if (state.edgeIndicesBuf) {
|
|
139
|
+
state.edgeIndicesBuf.bind();
|
|
140
|
+
gl.drawElementsInstanced(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0, state.numInstances);
|
|
141
|
+
state.edgeIndicesBuf.unbind(); // needed?
|
|
142
|
+
}
|
|
141
143
|
} else {
|
|
142
144
|
gl.drawArraysInstanced(gl.POINTS, 0, state.positionsBuf.numItems, state.numInstances);
|
|
143
145
|
}
|
|
@@ -11,6 +11,8 @@ import {SAODepthLimitedBlurRenderer} from "./sao/SAODepthLimitedBlurRenderer.js"
|
|
|
11
11
|
import {RenderBufferManager} from "./RenderBufferManager.js";
|
|
12
12
|
import {getExtension} from "./getExtension.js";
|
|
13
13
|
|
|
14
|
+
const vec3_0 = math.vec3([0,0,0]);
|
|
15
|
+
|
|
14
16
|
/**
|
|
15
17
|
* @private
|
|
16
18
|
*/
|
|
@@ -713,9 +715,11 @@ const Renderer = function (scene, options) {
|
|
|
713
715
|
// Transparent color fill
|
|
714
716
|
|
|
715
717
|
if (normalFillTransparentBinLen > 0) {
|
|
718
|
+
const eye = frameCtx.pickOrigin || scene.camera.eye;
|
|
719
|
+
const byDist = normalFillTransparentBin.map(d => ({ drawable: d, distSq: math.distVec3(d.origin || vec3_0, eye) }));
|
|
720
|
+
byDist.sort((a, b) => b.distSq - a.distSq);
|
|
716
721
|
for (i = 0; i < normalFillTransparentBinLen; i++) {
|
|
717
|
-
|
|
718
|
-
drawable.drawColorTransparent(frameCtx);
|
|
722
|
+
byDist[i].drawable.drawColorTransparent(frameCtx);
|
|
719
723
|
}
|
|
720
724
|
}
|
|
721
725
|
|