@xeokit/xeokit-sdk 2.6.31 → 2.6.32
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/README.md +17 -23
- package/dist/xeokit-sdk.cjs.js +226 -295
- package/dist/xeokit-sdk.es.js +226 -295
- package/dist/xeokit-sdk.es5.js +408 -405
- package/dist/xeokit-sdk.min.cjs.js +2 -2
- package/dist/xeokit-sdk.min.es.js +2 -2
- package/dist/xeokit-sdk.min.es5.js +3 -3
- package/package.json +1 -1
- package/src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js +5 -1
- package/src/plugins/ZonesPlugin/ZonesPlugin.js +97 -148
- package/src/plugins/lib/html/Dot.js +2 -2
- package/src/viewer/scene/webgl/Renderer.js +126 -151
|
@@ -32,6 +32,9 @@ const Renderer = function (scene, options) {
|
|
|
32
32
|
let drawableTypeInfo = {};
|
|
33
33
|
let drawables = {};
|
|
34
34
|
|
|
35
|
+
let postSortDrawableList = [];
|
|
36
|
+
let postCullDrawableList = [];
|
|
37
|
+
|
|
35
38
|
let drawableListDirty = true;
|
|
36
39
|
let stateSortDirty = true;
|
|
37
40
|
let imageDirty = true;
|
|
@@ -264,33 +267,33 @@ const Renderer = function (scene, options) {
|
|
|
264
267
|
}
|
|
265
268
|
|
|
266
269
|
function sortDrawableList() {
|
|
270
|
+
let lenDrawableList = 0;
|
|
267
271
|
for (let type in drawableTypeInfo) {
|
|
268
272
|
if (drawableTypeInfo.hasOwnProperty(type)) {
|
|
269
273
|
const drawableInfo = drawableTypeInfo[type];
|
|
270
|
-
|
|
271
|
-
|
|
274
|
+
const drawableListPreCull = drawableInfo.drawableListPreCull;
|
|
275
|
+
for (let i = 0, len = drawableListPreCull.length; i < len; i++) {
|
|
276
|
+
const drawable = drawableListPreCull[i];
|
|
277
|
+
postSortDrawableList[lenDrawableList++] = drawable;
|
|
272
278
|
}
|
|
273
279
|
}
|
|
274
280
|
}
|
|
281
|
+
postSortDrawableList.length = lenDrawableList;
|
|
282
|
+
postSortDrawableList.sort((a, b) => {
|
|
283
|
+
return a.renderOrder - b.renderOrder;
|
|
284
|
+
});
|
|
275
285
|
}
|
|
276
286
|
|
|
277
287
|
function cullDrawableList() {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
for (let i = 0, len = drawableListPreCull.length; i < len; i++) {
|
|
285
|
-
const drawable = drawableListPreCull[i];
|
|
286
|
-
drawable.rebuildRenderFlags();
|
|
287
|
-
if (!drawable.renderFlags.culled) {
|
|
288
|
-
drawableList[lenDrawableList++] = drawable;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
drawableList.length = lenDrawableList;
|
|
288
|
+
let lenDrawableList = 0;
|
|
289
|
+
for (let i = 0, len = postSortDrawableList.length; i < len; i++) {
|
|
290
|
+
const drawable = postSortDrawableList[i];
|
|
291
|
+
drawable.rebuildRenderFlags();
|
|
292
|
+
if (!drawable.renderFlags.culled) {
|
|
293
|
+
postCullDrawableList[lenDrawableList++] = drawable;
|
|
292
294
|
}
|
|
293
295
|
}
|
|
296
|
+
postCullDrawableList.length = lenDrawableList;
|
|
294
297
|
}
|
|
295
298
|
|
|
296
299
|
function draw(params) {
|
|
@@ -366,25 +369,16 @@ const Renderer = function (scene, options) {
|
|
|
366
369
|
if (params.clear !== false) {
|
|
367
370
|
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
|
368
371
|
}
|
|
372
|
+
for (let i = 0, len = postCullDrawableList.length; i < len; i++) {
|
|
369
373
|
|
|
370
|
-
|
|
371
|
-
if (drawableTypeInfo.hasOwnProperty(type)) {
|
|
372
|
-
|
|
373
|
-
const drawableInfo = drawableTypeInfo[type];
|
|
374
|
-
const drawableList = drawableInfo.drawableList;
|
|
375
|
-
|
|
376
|
-
for (let i = 0, len = drawableList.length; i < len; i++) {
|
|
377
|
-
|
|
378
|
-
const drawable = drawableList[i];
|
|
374
|
+
const drawable = postCullDrawableList[i];
|
|
379
375
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
376
|
+
if (drawable.culled === true || drawable.visible === false || !drawable.drawDepth || !drawable.saoEnabled) {
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
383
379
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}
|
|
387
|
-
}
|
|
380
|
+
if (drawable.renderFlags.colorOpaque) {
|
|
381
|
+
drawable.drawDepth(frameCtx);
|
|
388
382
|
}
|
|
389
383
|
}
|
|
390
384
|
|
|
@@ -567,93 +561,85 @@ const Renderer = function (scene, options) {
|
|
|
567
561
|
// Render normal opaque solids, defer others to bins to render after
|
|
568
562
|
//------------------------------------------------------------------------------------------------------
|
|
569
563
|
|
|
570
|
-
for (let
|
|
571
|
-
if (drawableTypeInfo.hasOwnProperty(type)) {
|
|
572
|
-
|
|
573
|
-
const drawableInfo = drawableTypeInfo[type];
|
|
574
|
-
const drawableList = drawableInfo.drawableList;
|
|
575
|
-
|
|
576
|
-
for (i = 0, len = drawableList.length; i < len; i++) {
|
|
564
|
+
for (let i = 0, len = postCullDrawableList.length; i < len; i++) {
|
|
577
565
|
|
|
578
|
-
|
|
566
|
+
drawable = postCullDrawableList[i];
|
|
579
567
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
568
|
+
if (drawable.culled === true || drawable.visible === false) {
|
|
569
|
+
continue;
|
|
570
|
+
}
|
|
583
571
|
|
|
584
|
-
|
|
572
|
+
const renderFlags = drawable.renderFlags;
|
|
585
573
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
574
|
+
if (renderFlags.colorOpaque) {
|
|
575
|
+
if (saoEnabled && saoPossible && drawable.saoEnabled) {
|
|
576
|
+
normalDrawSAOBin[normalDrawSAOBinLen++] = drawable;
|
|
577
|
+
} else {
|
|
578
|
+
drawable.drawColorOpaque(frameCtx);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
593
581
|
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
582
|
+
if (transparentEnabled) {
|
|
583
|
+
if (renderFlags.colorTransparent) {
|
|
584
|
+
normalFillTransparentBin[normalFillTransparentBinLen++] = drawable;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
599
587
|
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
588
|
+
if (renderFlags.xrayedSilhouetteTransparent) {
|
|
589
|
+
xrayedFillTransparentBin[xrayedFillTransparentBinLen++] = drawable;
|
|
590
|
+
}
|
|
603
591
|
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
592
|
+
if (renderFlags.xrayedSilhouetteOpaque) {
|
|
593
|
+
xrayedFillOpaqueBin[xrayedFillOpaqueBinLen++] = drawable;
|
|
594
|
+
}
|
|
607
595
|
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
596
|
+
if (renderFlags.highlightedSilhouetteTransparent) {
|
|
597
|
+
highlightedFillTransparentBin[highlightedFillTransparentBinLen++] = drawable;
|
|
598
|
+
}
|
|
611
599
|
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
600
|
+
if (renderFlags.highlightedSilhouetteOpaque) {
|
|
601
|
+
highlightedFillOpaqueBin[highlightedFillOpaqueBinLen++] = drawable;
|
|
602
|
+
}
|
|
615
603
|
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
604
|
+
if (renderFlags.selectedSilhouetteTransparent) {
|
|
605
|
+
selectedFillTransparentBin[selectedFillTransparentBinLen++] = drawable;
|
|
606
|
+
}
|
|
619
607
|
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
608
|
+
if (renderFlags.selectedSilhouetteOpaque) {
|
|
609
|
+
selectedFillOpaqueBin[selectedFillOpaqueBinLen++] = drawable;
|
|
610
|
+
}
|
|
623
611
|
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
612
|
+
if (drawable.edges && edgesEnabled) {
|
|
613
|
+
if (renderFlags.edgesOpaque) {
|
|
614
|
+
normalEdgesOpaqueBin[normalEdgesOpaqueBinLen++] = drawable;
|
|
615
|
+
}
|
|
628
616
|
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
617
|
+
if (renderFlags.edgesTransparent) {
|
|
618
|
+
normalEdgesTransparentBin[normalEdgesTransparentBinLen++] = drawable;
|
|
619
|
+
}
|
|
632
620
|
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
621
|
+
if (renderFlags.selectedEdgesTransparent) {
|
|
622
|
+
selectedEdgesTransparentBin[selectedEdgesTransparentBinLen++] = drawable;
|
|
623
|
+
}
|
|
636
624
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
625
|
+
if (renderFlags.selectedEdgesOpaque) {
|
|
626
|
+
selectedEdgesOpaqueBin[selectedEdgesOpaqueBinLen++] = drawable;
|
|
627
|
+
}
|
|
640
628
|
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
629
|
+
if (renderFlags.xrayedEdgesTransparent) {
|
|
630
|
+
xrayEdgesTransparentBin[xrayEdgesTransparentBinLen++] = drawable;
|
|
631
|
+
}
|
|
644
632
|
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
633
|
+
if (renderFlags.xrayedEdgesOpaque) {
|
|
634
|
+
xrayEdgesOpaqueBin[xrayEdgesOpaqueBinLen++] = drawable;
|
|
635
|
+
}
|
|
648
636
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
637
|
+
if (renderFlags.highlightedEdgesTransparent) {
|
|
638
|
+
highlightedEdgesTransparentBin[highlightedEdgesTransparentBinLen++] = drawable;
|
|
639
|
+
}
|
|
652
640
|
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
}
|
|
656
|
-
}
|
|
641
|
+
if (renderFlags.highlightedEdgesOpaque) {
|
|
642
|
+
highlightedEdgesOpaqueBin[highlightedEdgesOpaqueBinLen++] = drawable;
|
|
657
643
|
}
|
|
658
644
|
}
|
|
659
645
|
}
|
|
@@ -1063,7 +1049,7 @@ const Renderer = function (scene, options) {
|
|
|
1063
1049
|
frameCtx.pickInvisible = !!params.pickInvisible;
|
|
1064
1050
|
frameCtx.pickClipPos = [
|
|
1065
1051
|
getClipPosX(canvasPos[0] * resolutionScale, gl.drawingBufferWidth),
|
|
1066
|
-
getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight)
|
|
1052
|
+
getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight)
|
|
1067
1053
|
];
|
|
1068
1054
|
|
|
1069
1055
|
gl.viewport(0, 0, 1, 1);
|
|
@@ -1076,30 +1062,23 @@ const Renderer = function (scene, options) {
|
|
|
1076
1062
|
const includeEntityIds = params.includeEntityIds;
|
|
1077
1063
|
const excludeEntityIds = params.excludeEntityIds;
|
|
1078
1064
|
|
|
1079
|
-
for (let
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
if (!drawable.drawPickMesh || (params.pickInvisible !== true && drawable.visible === false) || drawable.pickable === false) {
|
|
1090
|
-
continue;
|
|
1091
|
-
}
|
|
1092
|
-
if (includeEntityIds && !includeEntityIds[drawable.id]) { // TODO: push this logic into drawable
|
|
1093
|
-
continue;
|
|
1094
|
-
}
|
|
1095
|
-
if (excludeEntityIds && excludeEntityIds[drawable.id]) {
|
|
1096
|
-
continue;
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
drawable.drawPickMesh(frameCtx);
|
|
1100
|
-
}
|
|
1065
|
+
for (let i = 0, len = postCullDrawableList.length; i < len; i++) {
|
|
1066
|
+
const drawable = postCullDrawableList[i];
|
|
1067
|
+
if (drawable.culled === true || drawable.visible === false) {
|
|
1068
|
+
continue;
|
|
1069
|
+
}
|
|
1070
|
+
if (!drawable.drawPickMesh || (params.pickInvisible !== true && drawable.visible === false) || drawable.pickable === false) {
|
|
1071
|
+
continue;
|
|
1072
|
+
}
|
|
1073
|
+
if (includeEntityIds && !includeEntityIds[drawable.id]) { // TODO: push this logic into drawable
|
|
1074
|
+
continue;
|
|
1101
1075
|
}
|
|
1076
|
+
if (excludeEntityIds && excludeEntityIds[drawable.id]) {
|
|
1077
|
+
continue;
|
|
1078
|
+
}
|
|
1079
|
+
drawable.drawPickMesh(frameCtx);
|
|
1102
1080
|
}
|
|
1081
|
+
|
|
1103
1082
|
const pix = pickBuffer.read(0, 0);
|
|
1104
1083
|
const pickID = pix[0] + (pix[1] << 8) + (pix[2] << 16) + (pix[3] << 24);
|
|
1105
1084
|
|
|
@@ -1129,7 +1108,7 @@ const Renderer = function (scene, options) {
|
|
|
1129
1108
|
// frameCtx.pickInvisible = !!params.pickInvisible;
|
|
1130
1109
|
frameCtx.pickClipPos = [
|
|
1131
1110
|
getClipPosX(canvasPos[0] * resolutionScale, gl.drawingBufferWidth),
|
|
1132
|
-
getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight)
|
|
1111
|
+
getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight)
|
|
1133
1112
|
];
|
|
1134
1113
|
|
|
1135
1114
|
gl.viewport(0, 0, 1, 1);
|
|
@@ -1178,7 +1157,7 @@ const Renderer = function (scene, options) {
|
|
|
1178
1157
|
frameCtx.pickElementsOffset = pickable.pickElementsOffset;
|
|
1179
1158
|
frameCtx.pickClipPos = [
|
|
1180
1159
|
getClipPosX(canvasPos[0] * resolutionScale, gl.drawingBufferWidth),
|
|
1181
|
-
getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight)
|
|
1160
|
+
getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight)
|
|
1182
1161
|
];
|
|
1183
1162
|
|
|
1184
1163
|
gl.viewport(0, 0, 1, 1);
|
|
@@ -1243,15 +1222,14 @@ const Renderer = function (scene, options) {
|
|
|
1243
1222
|
function drawSnapInit(frameCtx) {
|
|
1244
1223
|
frameCtx.snapPickLayerParams = [];
|
|
1245
1224
|
frameCtx.snapPickLayerNumber = 0;
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
}
|
|
1225
|
+
|
|
1226
|
+
for (let i = 0, len = postCullDrawableList.length; i < len; i++) {
|
|
1227
|
+
|
|
1228
|
+
const drawable = postCullDrawableList[i];
|
|
1229
|
+
|
|
1230
|
+
if (drawable.drawSnapInit) {
|
|
1231
|
+
if (!drawable.culled && drawable.visible && drawable.pickable) {
|
|
1232
|
+
drawable.drawSnapInit(frameCtx);
|
|
1255
1233
|
}
|
|
1256
1234
|
}
|
|
1257
1235
|
}
|
|
@@ -1261,11 +1239,11 @@ const Renderer = function (scene, options) {
|
|
|
1261
1239
|
function drawSnap(frameCtx) {
|
|
1262
1240
|
frameCtx.snapPickLayerParams = frameCtx.snapPickLayerParams || [];
|
|
1263
1241
|
frameCtx.snapPickLayerNumber = frameCtx.snapPickLayerParams.length;
|
|
1264
|
-
for (let
|
|
1265
|
-
|
|
1266
|
-
const
|
|
1267
|
-
|
|
1268
|
-
|
|
1242
|
+
for (let i = 0, len = postCullDrawableList.length; i < len; i++) {
|
|
1243
|
+
|
|
1244
|
+
const drawable = postCullDrawableList[i];
|
|
1245
|
+
|
|
1246
|
+
if (drawable.drawSnapInit) {
|
|
1269
1247
|
if (drawable.drawSnap) {
|
|
1270
1248
|
if (!drawable.culled && drawable.visible && drawable.pickable) {
|
|
1271
1249
|
drawable.drawSnap(frameCtx);
|
|
@@ -1655,19 +1633,16 @@ const Renderer = function (scene, options) {
|
|
|
1655
1633
|
gl.disable(gl.BLEND);
|
|
1656
1634
|
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
|
1657
1635
|
|
|
1658
|
-
for (let type in drawableTypeInfo) {
|
|
1659
|
-
if (drawableTypeInfo.hasOwnProperty(type)) {
|
|
1660
|
-
const drawableInfo = drawableTypeInfo[type];
|
|
1661
|
-
const drawableList = drawableInfo.drawableList;
|
|
1662
|
-
for (let i = 0, len = drawableList.length; i < len; i++) {
|
|
1663
|
-
const drawable = drawableList[i];
|
|
1664
|
-
if (!drawable.drawOcclusion || drawable.culled === true || drawable.visible === false || drawable.pickable === false) { // TODO: Option to exclude transparent?
|
|
1665
|
-
continue;
|
|
1666
|
-
}
|
|
1667
1636
|
|
|
1668
|
-
|
|
1669
|
-
|
|
1637
|
+
for (let i = 0, len = postCullDrawableList.length; i < len; i++) {
|
|
1638
|
+
|
|
1639
|
+
const drawable = postCullDrawableList[i];
|
|
1640
|
+
|
|
1641
|
+
if (!drawable.drawOcclusion || drawable.culled === true || drawable.visible === false || drawable.pickable === false) { // TODO: Option to exclude transparent?
|
|
1642
|
+
continue;
|
|
1670
1643
|
}
|
|
1644
|
+
|
|
1645
|
+
drawable.drawOcclusion(frameCtx);
|
|
1671
1646
|
}
|
|
1672
1647
|
|
|
1673
1648
|
this._occlusionTester.drawMarkers(frameCtx);
|
|
@@ -1794,4 +1769,4 @@ const Renderer = function (scene, options) {
|
|
|
1794
1769
|
};
|
|
1795
1770
|
};
|
|
1796
1771
|
|
|
1797
|
-
export {Renderer};
|
|
1772
|
+
export {Renderer};
|