@xeokit/xeokit-sdk 2.6.30 → 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.
@@ -9558,7 +9558,7 @@ class Dot {
9558
9558
  this._dotClickable = document.createElement('div');
9559
9559
  this._dotClickable.className += this._dotClickable.className ? ' viewer-ruler-dot-clickable' : 'viewer-ruler-dot-clickable';
9560
9560
 
9561
- this._visible = !!cfg.visible;
9561
+ this._visible = cfg.visible !== false;
9562
9562
  this._culled = false;
9563
9563
 
9564
9564
  var dot = this._dot;
@@ -9570,7 +9570,7 @@ class Dot {
9570
9570
  dotStyle["z-index"] = cfg.zIndex === undefined ? "40000005" : cfg.zIndex ;
9571
9571
  dotStyle.width = 8 + "px";
9572
9572
  dotStyle.height = 8 + "px";
9573
- dotStyle.visibility = cfg.visible !== false ? "visible" : "hidden";
9573
+ dotStyle.visibility = this._visible ? "visible" : "hidden";
9574
9574
  dotStyle.top = 0 + "px";
9575
9575
  dotStyle.left = 0 + "px";
9576
9576
  dotStyle["box-shadow"] = "0 2px 5px 0 #182A3D;";
@@ -19152,6 +19152,9 @@ const Renderer$1 = function (scene, options) {
19152
19152
  let drawableTypeInfo = {};
19153
19153
  let drawables = {};
19154
19154
 
19155
+ let postSortDrawableList = [];
19156
+ let postCullDrawableList = [];
19157
+
19155
19158
  let drawableListDirty = true;
19156
19159
  let stateSortDirty = true;
19157
19160
  let imageDirty = true;
@@ -19372,33 +19375,33 @@ const Renderer$1 = function (scene, options) {
19372
19375
  }
19373
19376
 
19374
19377
  function sortDrawableList() {
19378
+ let lenDrawableList = 0;
19375
19379
  for (let type in drawableTypeInfo) {
19376
19380
  if (drawableTypeInfo.hasOwnProperty(type)) {
19377
19381
  const drawableInfo = drawableTypeInfo[type];
19378
- if (drawableInfo.isStateSortable) {
19379
- drawableInfo.drawableListPreCull.sort(drawableInfo.stateSortCompare);
19382
+ const drawableListPreCull = drawableInfo.drawableListPreCull;
19383
+ for (let i = 0, len = drawableListPreCull.length; i < len; i++) {
19384
+ const drawable = drawableListPreCull[i];
19385
+ postSortDrawableList[lenDrawableList++] = drawable;
19380
19386
  }
19381
19387
  }
19382
19388
  }
19389
+ postSortDrawableList.length = lenDrawableList;
19390
+ postSortDrawableList.sort((a, b) => {
19391
+ return a.renderOrder - b.renderOrder;
19392
+ });
19383
19393
  }
19384
19394
 
19385
19395
  function cullDrawableList() {
19386
- for (let type in drawableTypeInfo) {
19387
- if (drawableTypeInfo.hasOwnProperty(type)) {
19388
- const drawableInfo = drawableTypeInfo[type];
19389
- const drawableListPreCull = drawableInfo.drawableListPreCull;
19390
- const drawableList = drawableInfo.drawableList;
19391
- let lenDrawableList = 0;
19392
- for (let i = 0, len = drawableListPreCull.length; i < len; i++) {
19393
- const drawable = drawableListPreCull[i];
19394
- drawable.rebuildRenderFlags();
19395
- if (!drawable.renderFlags.culled) {
19396
- drawableList[lenDrawableList++] = drawable;
19397
- }
19398
- }
19399
- drawableList.length = lenDrawableList;
19396
+ let lenDrawableList = 0;
19397
+ for (let i = 0, len = postSortDrawableList.length; i < len; i++) {
19398
+ const drawable = postSortDrawableList[i];
19399
+ drawable.rebuildRenderFlags();
19400
+ if (!drawable.renderFlags.culled) {
19401
+ postCullDrawableList[lenDrawableList++] = drawable;
19400
19402
  }
19401
19403
  }
19404
+ postCullDrawableList.length = lenDrawableList;
19402
19405
  }
19403
19406
 
19404
19407
  function draw(params) {
@@ -19474,25 +19477,16 @@ const Renderer$1 = function (scene, options) {
19474
19477
  if (params.clear !== false) {
19475
19478
  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
19476
19479
  }
19480
+ for (let i = 0, len = postCullDrawableList.length; i < len; i++) {
19477
19481
 
19478
- for (let type in drawableTypeInfo) {
19479
- if (drawableTypeInfo.hasOwnProperty(type)) {
19480
-
19481
- const drawableInfo = drawableTypeInfo[type];
19482
- const drawableList = drawableInfo.drawableList;
19483
-
19484
- for (let i = 0, len = drawableList.length; i < len; i++) {
19485
-
19486
- const drawable = drawableList[i];
19482
+ const drawable = postCullDrawableList[i];
19487
19483
 
19488
- if (drawable.culled === true || drawable.visible === false || !drawable.drawDepth || !drawable.saoEnabled) {
19489
- continue;
19490
- }
19484
+ if (drawable.culled === true || drawable.visible === false || !drawable.drawDepth || !drawable.saoEnabled) {
19485
+ continue;
19486
+ }
19491
19487
 
19492
- if (drawable.renderFlags.colorOpaque) {
19493
- drawable.drawDepth(frameCtx);
19494
- }
19495
- }
19488
+ if (drawable.renderFlags.colorOpaque) {
19489
+ drawable.drawDepth(frameCtx);
19496
19490
  }
19497
19491
  }
19498
19492
 
@@ -19631,7 +19625,6 @@ const Renderer$1 = function (scene, options) {
19631
19625
  }
19632
19626
 
19633
19627
  let i;
19634
- let len;
19635
19628
  let drawable;
19636
19629
 
19637
19630
  const startTime = Date.now();
@@ -19664,93 +19657,85 @@ const Renderer$1 = function (scene, options) {
19664
19657
  // Render normal opaque solids, defer others to bins to render after
19665
19658
  //------------------------------------------------------------------------------------------------------
19666
19659
 
19667
- for (let type in drawableTypeInfo) {
19668
- if (drawableTypeInfo.hasOwnProperty(type)) {
19669
-
19670
- const drawableInfo = drawableTypeInfo[type];
19671
- const drawableList = drawableInfo.drawableList;
19672
-
19673
- for (i = 0, len = drawableList.length; i < len; i++) {
19660
+ for (let i = 0, len = postCullDrawableList.length; i < len; i++) {
19674
19661
 
19675
- drawable = drawableList[i];
19662
+ drawable = postCullDrawableList[i];
19676
19663
 
19677
- if (drawable.culled === true || drawable.visible === false) {
19678
- continue;
19679
- }
19664
+ if (drawable.culled === true || drawable.visible === false) {
19665
+ continue;
19666
+ }
19680
19667
 
19681
- const renderFlags = drawable.renderFlags;
19668
+ const renderFlags = drawable.renderFlags;
19682
19669
 
19683
- if (renderFlags.colorOpaque) {
19684
- if (saoEnabled && saoPossible && drawable.saoEnabled) {
19685
- normalDrawSAOBin[normalDrawSAOBinLen++] = drawable;
19686
- } else {
19687
- drawable.drawColorOpaque(frameCtx);
19688
- }
19689
- }
19670
+ if (renderFlags.colorOpaque) {
19671
+ if (saoEnabled && saoPossible && drawable.saoEnabled) {
19672
+ normalDrawSAOBin[normalDrawSAOBinLen++] = drawable;
19673
+ } else {
19674
+ drawable.drawColorOpaque(frameCtx);
19675
+ }
19676
+ }
19690
19677
 
19691
- if (transparentEnabled) {
19692
- if (renderFlags.colorTransparent) {
19693
- normalFillTransparentBin[normalFillTransparentBinLen++] = drawable;
19694
- }
19695
- }
19678
+ if (transparentEnabled) {
19679
+ if (renderFlags.colorTransparent) {
19680
+ normalFillTransparentBin[normalFillTransparentBinLen++] = drawable;
19681
+ }
19682
+ }
19696
19683
 
19697
- if (renderFlags.xrayedSilhouetteTransparent) {
19698
- xrayedFillTransparentBin[xrayedFillTransparentBinLen++] = drawable;
19699
- }
19684
+ if (renderFlags.xrayedSilhouetteTransparent) {
19685
+ xrayedFillTransparentBin[xrayedFillTransparentBinLen++] = drawable;
19686
+ }
19700
19687
 
19701
- if (renderFlags.xrayedSilhouetteOpaque) {
19702
- xrayedFillOpaqueBin[xrayedFillOpaqueBinLen++] = drawable;
19703
- }
19688
+ if (renderFlags.xrayedSilhouetteOpaque) {
19689
+ xrayedFillOpaqueBin[xrayedFillOpaqueBinLen++] = drawable;
19690
+ }
19704
19691
 
19705
- if (renderFlags.highlightedSilhouetteTransparent) {
19706
- highlightedFillTransparentBin[highlightedFillTransparentBinLen++] = drawable;
19707
- }
19692
+ if (renderFlags.highlightedSilhouetteTransparent) {
19693
+ highlightedFillTransparentBin[highlightedFillTransparentBinLen++] = drawable;
19694
+ }
19708
19695
 
19709
- if (renderFlags.highlightedSilhouetteOpaque) {
19710
- highlightedFillOpaqueBin[highlightedFillOpaqueBinLen++] = drawable;
19711
- }
19696
+ if (renderFlags.highlightedSilhouetteOpaque) {
19697
+ highlightedFillOpaqueBin[highlightedFillOpaqueBinLen++] = drawable;
19698
+ }
19712
19699
 
19713
- if (renderFlags.selectedSilhouetteTransparent) {
19714
- selectedFillTransparentBin[selectedFillTransparentBinLen++] = drawable;
19715
- }
19700
+ if (renderFlags.selectedSilhouetteTransparent) {
19701
+ selectedFillTransparentBin[selectedFillTransparentBinLen++] = drawable;
19702
+ }
19716
19703
 
19717
- if (renderFlags.selectedSilhouetteOpaque) {
19718
- selectedFillOpaqueBin[selectedFillOpaqueBinLen++] = drawable;
19719
- }
19704
+ if (renderFlags.selectedSilhouetteOpaque) {
19705
+ selectedFillOpaqueBin[selectedFillOpaqueBinLen++] = drawable;
19706
+ }
19720
19707
 
19721
- if (drawable.edges && edgesEnabled) {
19722
- if (renderFlags.edgesOpaque) {
19723
- normalEdgesOpaqueBin[normalEdgesOpaqueBinLen++] = drawable;
19724
- }
19708
+ if (drawable.edges && edgesEnabled) {
19709
+ if (renderFlags.edgesOpaque) {
19710
+ normalEdgesOpaqueBin[normalEdgesOpaqueBinLen++] = drawable;
19711
+ }
19725
19712
 
19726
- if (renderFlags.edgesTransparent) {
19727
- normalEdgesTransparentBin[normalEdgesTransparentBinLen++] = drawable;
19728
- }
19713
+ if (renderFlags.edgesTransparent) {
19714
+ normalEdgesTransparentBin[normalEdgesTransparentBinLen++] = drawable;
19715
+ }
19729
19716
 
19730
- if (renderFlags.selectedEdgesTransparent) {
19731
- selectedEdgesTransparentBin[selectedEdgesTransparentBinLen++] = drawable;
19732
- }
19717
+ if (renderFlags.selectedEdgesTransparent) {
19718
+ selectedEdgesTransparentBin[selectedEdgesTransparentBinLen++] = drawable;
19719
+ }
19733
19720
 
19734
- if (renderFlags.selectedEdgesOpaque) {
19735
- selectedEdgesOpaqueBin[selectedEdgesOpaqueBinLen++] = drawable;
19736
- }
19721
+ if (renderFlags.selectedEdgesOpaque) {
19722
+ selectedEdgesOpaqueBin[selectedEdgesOpaqueBinLen++] = drawable;
19723
+ }
19737
19724
 
19738
- if (renderFlags.xrayedEdgesTransparent) {
19739
- xrayEdgesTransparentBin[xrayEdgesTransparentBinLen++] = drawable;
19740
- }
19725
+ if (renderFlags.xrayedEdgesTransparent) {
19726
+ xrayEdgesTransparentBin[xrayEdgesTransparentBinLen++] = drawable;
19727
+ }
19741
19728
 
19742
- if (renderFlags.xrayedEdgesOpaque) {
19743
- xrayEdgesOpaqueBin[xrayEdgesOpaqueBinLen++] = drawable;
19744
- }
19729
+ if (renderFlags.xrayedEdgesOpaque) {
19730
+ xrayEdgesOpaqueBin[xrayEdgesOpaqueBinLen++] = drawable;
19731
+ }
19745
19732
 
19746
- if (renderFlags.highlightedEdgesTransparent) {
19747
- highlightedEdgesTransparentBin[highlightedEdgesTransparentBinLen++] = drawable;
19748
- }
19733
+ if (renderFlags.highlightedEdgesTransparent) {
19734
+ highlightedEdgesTransparentBin[highlightedEdgesTransparentBinLen++] = drawable;
19735
+ }
19749
19736
 
19750
- if (renderFlags.highlightedEdgesOpaque) {
19751
- highlightedEdgesOpaqueBin[highlightedEdgesOpaqueBinLen++] = drawable;
19752
- }
19753
- }
19737
+ if (renderFlags.highlightedEdgesOpaque) {
19738
+ highlightedEdgesOpaqueBin[highlightedEdgesOpaqueBinLen++] = drawable;
19754
19739
  }
19755
19740
  }
19756
19741
  }
@@ -20156,7 +20141,7 @@ const Renderer$1 = function (scene, options) {
20156
20141
  frameCtx.pickInvisible = !!params.pickInvisible;
20157
20142
  frameCtx.pickClipPos = [
20158
20143
  getClipPosX(canvasPos[0] * resolutionScale, gl.drawingBufferWidth),
20159
- getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight),
20144
+ getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight)
20160
20145
  ];
20161
20146
 
20162
20147
  gl.viewport(0, 0, 1, 1);
@@ -20169,30 +20154,23 @@ const Renderer$1 = function (scene, options) {
20169
20154
  const includeEntityIds = params.includeEntityIds;
20170
20155
  const excludeEntityIds = params.excludeEntityIds;
20171
20156
 
20172
- for (let type in drawableTypeInfo) {
20173
- if (drawableTypeInfo.hasOwnProperty(type)) {
20174
-
20175
- const drawableInfo = drawableTypeInfo[type];
20176
- const drawableList = drawableInfo.drawableList;
20177
-
20178
- for (let i = 0, len = drawableList.length; i < len; i++) {
20179
-
20180
- const drawable = drawableList[i];
20181
-
20182
- if (!drawable.drawPickMesh || (params.pickInvisible !== true && drawable.visible === false) || drawable.pickable === false) {
20183
- continue;
20184
- }
20185
- if (includeEntityIds && !includeEntityIds[drawable.id]) { // TODO: push this logic into drawable
20186
- continue;
20187
- }
20188
- if (excludeEntityIds && excludeEntityIds[drawable.id]) {
20189
- continue;
20190
- }
20191
-
20192
- drawable.drawPickMesh(frameCtx);
20193
- }
20157
+ for (let i = 0, len = postCullDrawableList.length; i < len; i++) {
20158
+ const drawable = postCullDrawableList[i];
20159
+ if (drawable.culled === true || drawable.visible === false) {
20160
+ continue;
20161
+ }
20162
+ if (!drawable.drawPickMesh || (params.pickInvisible !== true && drawable.visible === false) || drawable.pickable === false) {
20163
+ continue;
20164
+ }
20165
+ if (includeEntityIds && !includeEntityIds[drawable.id]) { // TODO: push this logic into drawable
20166
+ continue;
20167
+ }
20168
+ if (excludeEntityIds && excludeEntityIds[drawable.id]) {
20169
+ continue;
20194
20170
  }
20171
+ drawable.drawPickMesh(frameCtx);
20195
20172
  }
20173
+
20196
20174
  const pix = pickBuffer.read(0, 0);
20197
20175
  const pickID = pix[0] + (pix[1] << 8) + (pix[2] << 16) + (pix[3] << 24);
20198
20176
 
@@ -20222,7 +20200,7 @@ const Renderer$1 = function (scene, options) {
20222
20200
  // frameCtx.pickInvisible = !!params.pickInvisible;
20223
20201
  frameCtx.pickClipPos = [
20224
20202
  getClipPosX(canvasPos[0] * resolutionScale, gl.drawingBufferWidth),
20225
- getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight),
20203
+ getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight)
20226
20204
  ];
20227
20205
 
20228
20206
  gl.viewport(0, 0, 1, 1);
@@ -20271,7 +20249,7 @@ const Renderer$1 = function (scene, options) {
20271
20249
  frameCtx.pickElementsOffset = pickable.pickElementsOffset;
20272
20250
  frameCtx.pickClipPos = [
20273
20251
  getClipPosX(canvasPos[0] * resolutionScale, gl.drawingBufferWidth),
20274
- getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight),
20252
+ getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight)
20275
20253
  ];
20276
20254
 
20277
20255
  gl.viewport(0, 0, 1, 1);
@@ -20336,15 +20314,14 @@ const Renderer$1 = function (scene, options) {
20336
20314
  function drawSnapInit(frameCtx) {
20337
20315
  frameCtx.snapPickLayerParams = [];
20338
20316
  frameCtx.snapPickLayerNumber = 0;
20339
- for (let type in drawableTypeInfo) {
20340
- const drawableInfo = drawableTypeInfo[type];
20341
- const drawableList = drawableInfo.drawableList;
20342
- for (let i = 0, len = drawableList.length; i < len; i++) {
20343
- const drawable = drawableList[i];
20344
- if (drawable.drawSnapInit) {
20345
- if (!drawable.culled && drawable.visible && drawable.pickable) {
20346
- drawable.drawSnapInit(frameCtx);
20347
- }
20317
+
20318
+ for (let i = 0, len = postCullDrawableList.length; i < len; i++) {
20319
+
20320
+ const drawable = postCullDrawableList[i];
20321
+
20322
+ if (drawable.drawSnapInit) {
20323
+ if (!drawable.culled && drawable.visible && drawable.pickable) {
20324
+ drawable.drawSnapInit(frameCtx);
20348
20325
  }
20349
20326
  }
20350
20327
  }
@@ -20354,11 +20331,11 @@ const Renderer$1 = function (scene, options) {
20354
20331
  function drawSnap(frameCtx) {
20355
20332
  frameCtx.snapPickLayerParams = frameCtx.snapPickLayerParams || [];
20356
20333
  frameCtx.snapPickLayerNumber = frameCtx.snapPickLayerParams.length;
20357
- for (let type in drawableTypeInfo) {
20358
- const drawableInfo = drawableTypeInfo[type];
20359
- const drawableList = drawableInfo.drawableList;
20360
- for (let i = 0, len = drawableList.length; i < len; i++) {
20361
- const drawable = drawableList[i];
20334
+ for (let i = 0, len = postCullDrawableList.length; i < len; i++) {
20335
+
20336
+ const drawable = postCullDrawableList[i];
20337
+
20338
+ if (drawable.drawSnapInit) {
20362
20339
  if (drawable.drawSnap) {
20363
20340
  if (!drawable.culled && drawable.visible && drawable.pickable) {
20364
20341
  drawable.drawSnap(frameCtx);
@@ -20504,6 +20481,8 @@ const Renderer$1 = function (scene, options) {
20504
20481
  // result 1) regular hi-precision world position
20505
20482
 
20506
20483
  let worldPos = null;
20484
+ let worldNormal = null;
20485
+ let pickable = null;
20507
20486
 
20508
20487
  const middleX = snapRadiusInPixels;
20509
20488
  const middleY = snapRadiusInPixels;
@@ -20521,7 +20500,7 @@ const Renderer$1 = function (scene, options) {
20521
20500
  pickResultMiddleXY[1] * scale[1] + origin[1],
20522
20501
  pickResultMiddleXY[2] * scale[2] + origin[2],
20523
20502
  ];
20524
- math.normalizeVec3([
20503
+ worldNormal = math.normalizeVec3([
20525
20504
  pickNormalResultMiddleXY[0] / math.MAX_INT,
20526
20505
  pickNormalResultMiddleXY[1] / math.MAX_INT,
20527
20506
  pickNormalResultMiddleXY[2] / math.MAX_INT,
@@ -20533,7 +20512,7 @@ const Renderer$1 = function (scene, options) {
20533
20512
  + (pickPickableResultMiddleXY[2] << 16)
20534
20513
  + (pickPickableResultMiddleXY[3] << 24);
20535
20514
 
20536
- pickIDs.items[pickID];
20515
+ pickable = pickIDs.items[pickID];
20537
20516
  }
20538
20517
 
20539
20518
  // result 2) hi-precision snapped (to vertex/edge) world position
@@ -20630,13 +20609,16 @@ const Renderer$1 = function (scene, options) {
20630
20609
  }
20631
20610
 
20632
20611
  const snappedEntity = (snappedPickable && snappedPickable.delegatePickedEntity) ? snappedPickable.delegatePickedEntity() : snappedPickable;
20612
+ if (!snappedEntity && pickable) {
20613
+ pickable = pickable.delegatePickedEntity ? pickable.delegatePickedEntity() : pickable;
20614
+ }
20633
20615
 
20634
20616
  pickResult.reset();
20635
20617
  pickResult.snappedToEdge = (snapType === "edge");
20636
20618
  pickResult.snappedToVertex = (snapType === "vertex");
20637
- pickResult.worldPos = snappedWorldPos;
20638
- pickResult.worldNormal = snappedWorldNormal;
20639
- pickResult.entity = snappedEntity;
20619
+ pickResult.worldPos = snappedWorldPos || worldPos;
20620
+ pickResult.worldNormal = snappedWorldNormal || worldNormal;
20621
+ pickResult.entity = snappedEntity || pickable;
20640
20622
  pickResult.canvasPos = canvasPos || scene.camera.projectWorldPos(worldPos || snappedWorldPos);
20641
20623
  pickResult.snappedCanvasPos = snappedCanvasPos || canvasPos;
20642
20624
 
@@ -20743,19 +20725,16 @@ const Renderer$1 = function (scene, options) {
20743
20725
  gl.disable(gl.BLEND);
20744
20726
  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
20745
20727
 
20746
- for (let type in drawableTypeInfo) {
20747
- if (drawableTypeInfo.hasOwnProperty(type)) {
20748
- const drawableInfo = drawableTypeInfo[type];
20749
- const drawableList = drawableInfo.drawableList;
20750
- for (let i = 0, len = drawableList.length; i < len; i++) {
20751
- const drawable = drawableList[i];
20752
- if (!drawable.drawOcclusion || drawable.culled === true || drawable.visible === false || drawable.pickable === false) { // TODO: Option to exclude transparent?
20753
- continue;
20754
- }
20755
20728
 
20756
- drawable.drawOcclusion(frameCtx);
20757
- }
20729
+ for (let i = 0, len = postCullDrawableList.length; i < len; i++) {
20730
+
20731
+ const drawable = postCullDrawableList[i];
20732
+
20733
+ if (!drawable.drawOcclusion || drawable.culled === true || drawable.visible === false || drawable.pickable === false) { // TODO: Option to exclude transparent?
20734
+ continue;
20758
20735
  }
20736
+
20737
+ drawable.drawOcclusion(frameCtx);
20759
20738
  }
20760
20739
 
20761
20740
  this._occlusionTester.drawMarkers(frameCtx);
@@ -118170,7 +118149,7 @@ const parseNodesWithNames = (function () {
118170
118149
 
118171
118150
  const objectIdStack = [];
118172
118151
  const meshIdsStack = [];
118173
- let meshIds = null;
118152
+ let meshIds = [];
118174
118153
 
118175
118154
  return function (ctx, node, depth, matrix) {
118176
118155
  matrix = parseNodeMatrix(node, matrix);
@@ -118346,7 +118325,11 @@ function parseNodeMesh(node, ctx, matrix, meshIds) {
118346
118325
  if (primitive.indices) {
118347
118326
  meshCfg.indices = primitive.indices.value;
118348
118327
  }
118349
- math.transformPositions3(matrix, meshCfg.localPositions, meshCfg.positions);
118328
+ if (matrix) {
118329
+ math.transformPositions3(matrix, meshCfg.localPositions, meshCfg.positions);
118330
+ } else { // eqiv to math.transformPositions3(math.identityMat4(), meshCfg.localPositions, meshCfg.positions);
118331
+ meshCfg.positions.set(meshCfg.localPositions);
118332
+ }
118350
118333
  const origin = math.vec3();
118351
118334
  const rtcNeeded = worldToRTCPositions(meshCfg.positions, meshCfg.positions, origin); // Small cellsize guarantees better accuracy
118352
118335
  if (rtcNeeded) {
@@ -127071,7 +127054,7 @@ class TreeViewPlugin extends Plugin {
127071
127054
  this._nodeNodes[buildingNode.nodeId] = buildingNode;
127072
127055
  } else if (metaObjectType === "IfcBuildingStorey") {
127073
127056
  if (!buildingNode) {
127074
- this.error("Failed to build storeys hierarchy for model '" + this.metaModel.id + "' - model does not have an IfcBuilding object, or is not an IFC model");
127057
+ this.error("Failed to build storeys hierarchy for model - model does not have an IfcBuilding object, or is not an IFC model");
127075
127058
  return;
127076
127059
  }
127077
127060
  storeyNode = {
@@ -132468,6 +132451,9 @@ class XKTLoaderPlugin extends Plugin {
132468
132451
  * represent the returned model. Set false to always use vertex buffer objects (VBOs). Note that DTX is only applicable
132469
132452
  * to non-textured triangle meshes, and that VBOs are always used for meshes that have textures, line segments, or point
132470
132453
  * primitives. Only works while {@link DTX#enabled} is also ````true````.
132454
+ * @param {Number} [params.renderOrder=0] Specifies the rendering order for the model. This is used to control the order in which
132455
+ * SceneModels are drawn when they have transparent objects, to give control over the order in which those objects are blended within the transparent
132456
+ * render pass.
132471
132457
  * @returns {Entity} Entity representing the model, which will have {@link Entity#isModel} set ````true```` and will be registered by {@link Entity#id} in {@link Scene#models}.
132472
132458
  */
132473
132459
  load(params = {}) {
@@ -132517,7 +132503,8 @@ class XKTLoaderPlugin extends Plugin {
132517
132503
  origin: params.origin,
132518
132504
  disableVertexWelding: params.disableVertexWelding || false,
132519
132505
  disableIndexRebucketing: params.disableIndexRebucketing || false,
132520
- dtxEnabled: params.dtxEnabled
132506
+ dtxEnabled: params.dtxEnabled,
132507
+ renderOrder: params.renderOrder
132521
132508
  }));
132522
132509
 
132523
132510
  const modelId = sceneModel.id; // In case ID was auto-generated
@@ -139258,49 +139245,126 @@ class DotBIMLoaderPlugin extends Plugin {
139258
139245
 
139259
139246
  const dbMeshId = element.mesh_id;
139260
139247
 
139261
- parseDBMesh(dbMeshId);
139262
-
139263
- const meshId = `${objectId}-mesh`;
139264
139248
  const vector = element.vector;
139265
139249
  const rotation = element.rotation;
139266
139250
  const props = objectDefaults ? objectDefaults[elementType] || objectDefaults["DEFAULT"] : null;
139267
-
139268
139251
  let visible = true;
139269
139252
  let pickable = true;
139270
- let color = element.color ? [element.color.r / 255, element.color.g / 255, element.color.b / 255] : [1, 1, 1];
139271
- let opacity = element.color ? element.color.a / 255 : 1.0;
139272
139253
 
139273
- if (props) {
139274
- if (props.visible === false) {
139275
- visible = false;
139276
- }
139277
- if (props.pickable === false) {
139278
- pickable = false;
139279
- }
139280
- if (props.colorize) {
139281
- color = props.colorize;
139282
- }
139283
- if (props.opacity !== undefined && props.opacity !== null) {
139284
- opacity = props.opacity;
139254
+ if (element.face_colors === undefined) {
139255
+
139256
+ parseDBMesh(dbMeshId);
139257
+
139258
+ const meshId = `${objectId}-mesh`;
139259
+
139260
+ let color = element.color ? [element.color.r / 255.0, element.color.g / 255.0, element.color.b / 255.0] : [1, 1, 1];
139261
+ let opacity = element.color ? element.color.a / 255.0 : 1.0;
139262
+
139263
+ if (props) {
139264
+ if (props.visible === false) {
139265
+ visible = false;
139266
+ }
139267
+ if (props.pickable === false) {
139268
+ pickable = false;
139269
+ }
139270
+ if (props.colorize) {
139271
+ color = props.colorize;
139272
+ }
139273
+ if (props.opacity !== undefined && props.opacity !== null) {
139274
+ opacity = props.opacity;
139275
+ }
139285
139276
  }
139277
+
139278
+ sceneModel.createMesh({
139279
+ id: meshId,
139280
+ geometryId: dbMeshId,
139281
+ color: color,
139282
+ opacity: opacity,
139283
+ quaternion: rotation && (rotation.qz !== 0 || rotation.qy !== 0 || rotation.qx !== 0 || rotation.qw !== 1.0) ? [rotation.qx, rotation.qy, rotation.qz, rotation.qw] : undefined,
139284
+ position: vector ? [vector.x, vector.y, vector.z] : undefined
139285
+ });
139286
+
139287
+ sceneModel.createEntity({
139288
+ id: objectId,
139289
+ meshIds: [meshId],
139290
+ visible: visible,
139291
+ pickable: pickable,
139292
+ isObject: true
139293
+ });
139286
139294
  }
139295
+ else {
139296
+ let faceColors = element.face_colors;
139297
+ let coloredTrianglesDictionary = {};
139298
+ let currentTriangleIndicesCount = 0;
139299
+ let dbMesh = fileData.meshes[element.mesh_id];
139300
+ for (let i = 0, len = faceColors.length; i < len; i+=4) {
139301
+ let faceColor = [faceColors[i], faceColors[i+1], faceColors[i+2], faceColors[i+3]];
139302
+ if (coloredTrianglesDictionary[faceColor] === undefined) {
139303
+ coloredTrianglesDictionary[faceColor] = [];
139304
+ }
139305
+ let indexForPoint0 = dbMesh.indices[currentTriangleIndicesCount];
139306
+ let x0 = dbMesh.coordinates[indexForPoint0*3];
139307
+ let y0 = dbMesh.coordinates[indexForPoint0*3+1];
139308
+ let z0 = dbMesh.coordinates[indexForPoint0*3+2];
139309
+ let indexForPoint1 = dbMesh.indices[currentTriangleIndicesCount+1];
139310
+ let x1 = dbMesh.coordinates[indexForPoint1*3];
139311
+ let y1 = dbMesh.coordinates[indexForPoint1*3+1];
139312
+ let z1 = dbMesh.coordinates[indexForPoint1*3+2];
139313
+ let indexForPoint2 = dbMesh.indices[currentTriangleIndicesCount+2];
139314
+ let x2 = dbMesh.coordinates[indexForPoint2*3];
139315
+ let y2 = dbMesh.coordinates[indexForPoint2*3+1];
139316
+ let z2 = dbMesh.coordinates[indexForPoint2*3+2];
139317
+ coloredTrianglesDictionary[faceColor].push(x0, y0, z0, x1, y1, z1, x2, y2, z2);
139318
+
139319
+ currentTriangleIndicesCount += 3;
139320
+ }
139321
+ let meshIds = [];
139322
+ for (const [faceColor, trianglesCoordinates] of Object.entries(coloredTrianglesDictionary)) {
139323
+ sceneModel.createGeometry({
139324
+ id: `${dbMeshId}-${faceColor}`,
139325
+ primitive: "triangles",
139326
+ positions: trianglesCoordinates,
139327
+ indices: [...Array(trianglesCoordinates.length).keys()]
139328
+ });
139329
+ const meshId = `${objectId}-mesh-${faceColor}`;
139330
+ const faceColorArray = faceColor.split(',').map(Number);
139287
139331
 
139288
- sceneModel.createMesh({
139289
- id: meshId,
139290
- geometryId: dbMeshId,
139291
- color,
139292
- opacity,
139293
- quaternion: rotation && (rotation.qz !== 0 || rotation.qy !== 0 || rotation.qx !== 0 || rotation.qw !== 1.0) ? [rotation.qx, rotation.qy, rotation.qz, rotation.qw] : undefined,
139294
- position: vector ? [vector.x, vector.y, vector.z] : undefined
139295
- });
139332
+ let color = [faceColorArray[0] / 255.0, faceColorArray[1] / 255.0, faceColorArray[2] / 255.0];
139333
+ let opacity = faceColorArray[3] / 255.0;
139296
139334
 
139297
- sceneModel.createEntity({
139298
- id: objectId,
139299
- meshIds: [meshId],
139300
- visible,
139301
- pickable,
139302
- isObject: true
139303
- });
139335
+ if (props) {
139336
+ if (props.visible === false) {
139337
+ visible = false;
139338
+ }
139339
+ if (props.pickable === false) {
139340
+ pickable = false;
139341
+ }
139342
+ if (props.colorize) {
139343
+ color = props.colorize;
139344
+ }
139345
+ if (props.opacity !== undefined && props.opacity !== null) {
139346
+ opacity = props.opacity;
139347
+ }
139348
+ }
139349
+
139350
+ sceneModel.createMesh({
139351
+ id: meshId,
139352
+ geometryId: `${dbMeshId}-${faceColor}`,
139353
+ color: color,
139354
+ opacity: opacity,
139355
+ quaternion: rotation && (rotation.qz !== 0 || rotation.qy !== 0 || rotation.qx !== 0 || rotation.qw !== 1.0) ? [rotation.qx, rotation.qy, rotation.qz, rotation.qw] : undefined,
139356
+ position: vector ? [vector.x, vector.y, vector.z] : undefined
139357
+ });
139358
+ meshIds.push(meshId);
139359
+ }
139360
+ sceneModel.createEntity({
139361
+ id: objectId,
139362
+ meshIds: meshIds,
139363
+ visible: visible,
139364
+ pickable: pickable,
139365
+ isObject: true
139366
+ });
139367
+ }
139304
139368
 
139305
139369
  for (let infoKey in info) {
139306
139370
  let properties;
@@ -139646,10 +139710,9 @@ const basePolygon3D = function(scene, color, alpha) {
139646
139710
  };
139647
139711
  };
139648
139712
 
139649
- const startAAZoneCreateUI = function(scene, zoneAltitude, zoneHeight, zoneColor, zoneAlpha, pointerLens, zonesPlugin, select3dPoint, onZoneCreated) {
139650
- const marker1 = marker3D(scene, zoneColor);
139651
- const marker2 = marker3D(scene, zoneColor);
139652
- const basePolygon = basePolygon3D(scene, zoneColor, zoneAlpha);
139713
+ const startAARectCreateUI = function(scene, markersColor, pointerLens, select3dPoint, withPoints, onPointsSelected) {
139714
+ const marker1 = marker3D(scene, markersColor);
139715
+ const marker2 = marker3D(scene, markersColor);
139653
139716
 
139654
139717
  const updatePointerLens = (pointerLens
139655
139718
  ? function(canvasPos) {
@@ -139677,29 +139740,14 @@ const startAAZoneCreateUI = function(scene, zoneAltitude, zoneHeight, zoneColor,
139677
139740
  function() {
139678
139741
  updatePointerLens(null);
139679
139742
  marker2.update(null);
139680
- basePolygon.updateBase(null);
139743
+ withPoints(null);
139681
139744
  },
139682
139745
  function(canvasPos, point2WorldPos) {
139683
139746
  updatePointerLens(canvasPos);
139684
139747
  marker2.update(point2WorldPos);
139685
-
139686
- if (math.distVec3(point1WorldPos, point2WorldPos) > 0.01)
139687
- {
139688
- const min = (idx) => Math.min(point1WorldPos[idx], point2WorldPos[idx]);
139689
- const max = (idx) => Math.max(point1WorldPos[idx], point2WorldPos[idx]);
139690
-
139691
- const xmin = min(0);
139692
- const ymin = min(1);
139693
- const zmin = min(2);
139694
- const xmax = max(0);
139695
- max(1);
139696
- const zmax = max(2);
139697
-
139698
- basePolygon.updateBase([ [ xmin, ymin, zmax ], [ xmax, ymin, zmax ],
139699
- [ xmax, ymin, zmin ], [ xmin, ymin, zmin ] ]);
139700
- }
139701
- else
139702
- basePolygon.updateBase(null);
139748
+ withPoints((math.distVec3(point1WorldPos, point2WorldPos) > 0.01)
139749
+ &&
139750
+ [ point1WorldPos, point2WorldPos ]);
139703
139751
  },
139704
139752
  function(point2CanvasPos, point2WorldPos) {
139705
139753
  // `marker2.update' makes sure marker's position has been updated from its default [0,0,0]
@@ -139709,35 +139757,9 @@ const startAAZoneCreateUI = function(scene, zoneAltitude, zoneHeight, zoneColor,
139709
139757
 
139710
139758
  marker1.destroy();
139711
139759
  marker2.destroy();
139712
- basePolygon.destroy();
139713
139760
  updatePointerLens(null);
139714
139761
 
139715
- const min = (idx) => Math.min(point1WorldPos[idx], point2WorldPos[idx]);
139716
- const max = (idx) => Math.max(point1WorldPos[idx], point2WorldPos[idx]);
139717
-
139718
- const xmin = min(0);
139719
- const zmin = min(2);
139720
- const xmax = max(0);
139721
- const zmax = max(2);
139722
-
139723
- const zone = zonesPlugin.createZone(
139724
- {
139725
- id: math.createUUID(),
139726
- geometry: {
139727
- planeCoordinates: [
139728
- [ xmin, zmax ],
139729
- [ xmax, zmax ],
139730
- [ xmax, zmin ],
139731
- [ xmin, zmin ]
139732
- ],
139733
- altitude: zoneAltitude,
139734
- height: zoneHeight
139735
- },
139736
- alpha: zoneAlpha,
139737
- color: zoneColor
139738
- });
139739
-
139740
- onZoneCreated(zone);
139762
+ onPointsSelected([ point1WorldPos, point2WorldPos ]);
139741
139763
  });
139742
139764
  });
139743
139765
 
@@ -139746,7 +139768,6 @@ const startAAZoneCreateUI = function(scene, zoneAltitude, zoneHeight, zoneColor,
139746
139768
  deactivatePointSelection();
139747
139769
  marker1.destroy();
139748
139770
  marker2.destroy();
139749
- basePolygon.destroy();
139750
139771
  updatePointerLens(null);
139751
139772
  }
139752
139773
  };
@@ -140406,6 +140427,34 @@ class Zone extends Component {
140406
140427
  }
140407
140428
  }
140408
140429
 
140430
+ const createAAZoneFromPoints = function(pos1, pos2, zoneAltitude, zoneHeight, zoneColor, zoneAlpha, zonesPlugin) {
140431
+
140432
+ const min = (idx) => Math.min(pos1[idx], pos2[idx]);
140433
+ const max = (idx) => Math.max(pos1[idx], pos2[idx]);
140434
+
140435
+ const xmin = min(0);
140436
+ const zmin = min(2);
140437
+ const xmax = max(0);
140438
+ const zmax = max(2);
140439
+
140440
+ return zonesPlugin.createZone(
140441
+ {
140442
+ id: math.createUUID(),
140443
+ geometry: {
140444
+ planeCoordinates: [
140445
+ [ xmin, zmax ],
140446
+ [ xmax, zmax ],
140447
+ [ xmax, zmin ],
140448
+ [ xmin, zmin ]
140449
+ ],
140450
+ altitude: zoneAltitude,
140451
+ height: zoneHeight
140452
+ },
140453
+ alpha: zoneAlpha,
140454
+ color: zoneColor
140455
+ });
140456
+ };
140457
+
140409
140458
  /**
140410
140459
  * Creates {@link Zone}s in a {@link ZonesPlugin} from mouse input.
140411
140460
  *
@@ -140436,7 +140485,7 @@ class Zone extends Component {
140436
140485
  * const zonesControl = new ZonesMouseControl(Zones)
140437
140486
  * ````
140438
140487
  */
140439
- class ZonesMouseControl extends Component {
140488
+ class ZonesAAZoneControl extends Component {
140440
140489
 
140441
140490
  /**
140442
140491
  * Creates a ZonesMouseControl bound to the given ZonesPlugin.
@@ -140445,11 +140494,12 @@ class ZonesMouseControl extends Component {
140445
140494
  * @param [cfg] Configuration
140446
140495
  * @param {PointerLens} [cfg.pointerLens] A PointerLens to use to provide a magnified view of the cursor when snapping is enabled.
140447
140496
  */
140448
- constructor(zonesPlugin, cfg = {}) {
140497
+ constructor(zonesPlugin, cfg, createSelect3dPoint) {
140449
140498
  super(zonesPlugin.viewer.scene);
140450
140499
 
140451
140500
  this.zonesPlugin = zonesPlugin;
140452
140501
  this.pointerLens = cfg.pointerLens;
140502
+ this.createSelect3dPoint = createSelect3dPoint;
140453
140503
  this._deactivate = null;
140454
140504
  }
140455
140505
 
@@ -140486,16 +140536,35 @@ class ZonesMouseControl extends Component {
140486
140536
  const scene = viewer.scene;
140487
140537
  const self = this;
140488
140538
 
140489
- const select3dPoint = mousePointSelector(
140490
- viewer,
140491
- function(origin, direction) {
140492
- return planeIntersect(zoneAltitude, math.vec3([ 0, 1, 0 ]), origin, direction);
140493
- });
140539
+ const select3dPoint = this.createSelect3dPoint(viewer, (origin, direction) => planeIntersect(zoneAltitude, math.vec3([ 0, 1, 0 ]), origin, direction));
140494
140540
 
140495
140541
  (function rec() {
140496
- self._deactivate = startAAZoneCreateUI(
140497
- scene, zoneAltitude, zoneHeight, zoneColor, zoneAlpha, self.pointerLens, zonesPlugin, select3dPoint,
140498
- zone => {
140542
+ const basePolygon = basePolygon3D(scene, zoneColor, zoneAlpha);
140543
+ const deactivate = startAARectCreateUI(
140544
+ scene, zoneColor, self.pointerLens, select3dPoint,
140545
+ points => {
140546
+ if (points) {
140547
+ const p0 = points[0];
140548
+ const p1 = points[1];
140549
+ const min = (idx) => Math.min(p0[idx], p1[idx]);
140550
+ const max = (idx) => Math.max(p0[idx], p1[idx]);
140551
+
140552
+ const xmin = min(0);
140553
+ const ymin = min(1);
140554
+ const zmin = min(2);
140555
+ const xmax = max(0);
140556
+ max(1);
140557
+ const zmax = max(2);
140558
+
140559
+ basePolygon.updateBase([ [ xmin, ymin, zmax ], [ xmax, ymin, zmax ],
140560
+ [ xmax, ymin, zmin ], [ xmin, ymin, zmin ] ]);
140561
+ } else {
140562
+ basePolygon.updateBase(null);
140563
+ }
140564
+ },
140565
+ points => {
140566
+ basePolygon.destroy();
140567
+ const zone = createAAZoneFromPoints(points[0], points[1], zoneAltitude, zoneHeight, zoneColor, zoneAlpha, zonesPlugin);
140499
140568
  let reactivate = true;
140500
140569
  self._deactivate = () => { reactivate = false; };
140501
140570
  self.fire("zoneEnd", zone);
@@ -140504,6 +140573,10 @@ class ZonesMouseControl extends Component {
140504
140573
  rec();
140505
140574
  }
140506
140575
  }).deactivate;
140576
+ self._deactivate = () => {
140577
+ deactivate();
140578
+ basePolygon.destroy();
140579
+ };
140507
140580
  })();
140508
140581
  }
140509
140582
 
@@ -140526,6 +140599,30 @@ class ZonesMouseControl extends Component {
140526
140599
  }
140527
140600
  }
140528
140601
 
140602
+ class ZonesMouseControl extends ZonesAAZoneControl {
140603
+ constructor(zonesPlugin, cfg = {}) {
140604
+ super(
140605
+ zonesPlugin,
140606
+ cfg,
140607
+ (viewer, ray2WorldPos) => mousePointSelector(viewer, ray2WorldPos));
140608
+ }
140609
+ }
140610
+ class ZonesTouchControl extends ZonesAAZoneControl {
140611
+ constructor(zonesPlugin, cfg = {}) {
140612
+ const pointerCircle = new PointerCircle(zonesPlugin.viewer);
140613
+ super(
140614
+ zonesPlugin,
140615
+ cfg,
140616
+ (viewer, ray2WorldPos) => touchPointSelector(viewer, pointerCircle, ray2WorldPos));
140617
+ this.pointerCircle = pointerCircle;
140618
+ }
140619
+
140620
+ destroy() {
140621
+ this.pointerCircle.destroy();
140622
+ super.destroy();
140623
+ }
140624
+ }
140625
+
140529
140626
  /**
140530
140627
  * ZonesPlugin documentation to be added, mostly compatible with DistanceMeasurementsPlugin.
140531
140628
  */
@@ -140640,86 +140737,6 @@ class ZonesPlugin extends Plugin {
140640
140737
  }
140641
140738
  }
140642
140739
 
140643
- class ZonesTouchControl extends Component {
140644
-
140645
- constructor(zonesPlugin, cfg = {}) {
140646
- super(zonesPlugin.viewer.scene);
140647
-
140648
- this.zonesPlugin = zonesPlugin;
140649
- this.pointerLens = cfg.pointerLens;
140650
- this.pointerCircle = new PointerCircle(zonesPlugin.viewer);
140651
- this._deactivate = null;
140652
- }
140653
-
140654
- get active() {
140655
- return !! this._deactivate;
140656
- }
140657
-
140658
- activate(zoneAltitude, zoneHeight, zoneColor, zoneAlpha) {
140659
-
140660
- if (typeof(zoneAltitude) === "object" && (zoneAltitude !== null)) {
140661
- const params = zoneAltitude;
140662
- const param = (name, defaultValue) => {
140663
- if (name in params) {
140664
- return params[name];
140665
- } else if (defaultValue !== undefined) {
140666
- return defaultValue;
140667
- } else {
140668
- throw "config missing: " + name;
140669
- }
140670
- };
140671
-
140672
- zoneAltitude = param("altitude");
140673
- zoneHeight = param("height");
140674
- zoneColor = param("color", "#008000");
140675
- zoneAlpha = param("alpha", 0.5);
140676
- }
140677
-
140678
- if (this._deactivate) {
140679
- return;
140680
- }
140681
-
140682
- const zonesPlugin = this.zonesPlugin;
140683
- const viewer = zonesPlugin.viewer;
140684
- const scene = viewer.scene;
140685
- const self = this;
140686
-
140687
- const select3dPoint = touchPointSelector(
140688
- viewer,
140689
- this.pointerCircle,
140690
- function(origin, direction) {
140691
- return planeIntersect(zoneAltitude, math.vec3([ 0, 1, 0 ]), origin, direction);
140692
- });
140693
-
140694
- (function rec() {
140695
- self._deactivate = startAAZoneCreateUI(
140696
- scene, zoneAltitude, zoneHeight, zoneColor, zoneAlpha, self.pointerLens, zonesPlugin, select3dPoint,
140697
- zone => {
140698
- let reactivate = true;
140699
- self._deactivate = () => { reactivate = false; };
140700
- self.fire("zoneEnd", zone);
140701
- if (reactivate)
140702
- {
140703
- rec();
140704
- }
140705
- }).deactivate;
140706
- })();
140707
- }
140708
-
140709
- deactivate() {
140710
- if (this._deactivate)
140711
- {
140712
- this._deactivate();
140713
- this._deactivate = null;
140714
- }
140715
- }
140716
-
140717
- destroy() {
140718
- this.deactivate();
140719
- super.destroy();
140720
- }
140721
- }
140722
-
140723
140740
  const startPolysurfaceZoneCreateUI = function(scene, zoneAltitude, zoneHeight, zoneColor, zoneAlpha, pointerLens, zonesPlugin, select3dPoint, onZoneCreated) {
140724
140741
  const updatePointerLens = (pointerLens
140725
140742
  ? function(canvasPos) {