@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.
@@ -9554,7 +9554,7 @@ class Dot {
9554
9554
  this._dotClickable = document.createElement('div');
9555
9555
  this._dotClickable.className += this._dotClickable.className ? ' viewer-ruler-dot-clickable' : 'viewer-ruler-dot-clickable';
9556
9556
 
9557
- this._visible = !!cfg.visible;
9557
+ this._visible = cfg.visible !== false;
9558
9558
  this._culled = false;
9559
9559
 
9560
9560
  var dot = this._dot;
@@ -9566,7 +9566,7 @@ class Dot {
9566
9566
  dotStyle["z-index"] = cfg.zIndex === undefined ? "40000005" : cfg.zIndex ;
9567
9567
  dotStyle.width = 8 + "px";
9568
9568
  dotStyle.height = 8 + "px";
9569
- dotStyle.visibility = cfg.visible !== false ? "visible" : "hidden";
9569
+ dotStyle.visibility = this._visible ? "visible" : "hidden";
9570
9570
  dotStyle.top = 0 + "px";
9571
9571
  dotStyle.left = 0 + "px";
9572
9572
  dotStyle["box-shadow"] = "0 2px 5px 0 #182A3D;";
@@ -19148,6 +19148,9 @@ const Renderer$1 = function (scene, options) {
19148
19148
  let drawableTypeInfo = {};
19149
19149
  let drawables = {};
19150
19150
 
19151
+ let postSortDrawableList = [];
19152
+ let postCullDrawableList = [];
19153
+
19151
19154
  let drawableListDirty = true;
19152
19155
  let stateSortDirty = true;
19153
19156
  let imageDirty = true;
@@ -19368,33 +19371,33 @@ const Renderer$1 = function (scene, options) {
19368
19371
  }
19369
19372
 
19370
19373
  function sortDrawableList() {
19374
+ let lenDrawableList = 0;
19371
19375
  for (let type in drawableTypeInfo) {
19372
19376
  if (drawableTypeInfo.hasOwnProperty(type)) {
19373
19377
  const drawableInfo = drawableTypeInfo[type];
19374
- if (drawableInfo.isStateSortable) {
19375
- drawableInfo.drawableListPreCull.sort(drawableInfo.stateSortCompare);
19378
+ const drawableListPreCull = drawableInfo.drawableListPreCull;
19379
+ for (let i = 0, len = drawableListPreCull.length; i < len; i++) {
19380
+ const drawable = drawableListPreCull[i];
19381
+ postSortDrawableList[lenDrawableList++] = drawable;
19376
19382
  }
19377
19383
  }
19378
19384
  }
19385
+ postSortDrawableList.length = lenDrawableList;
19386
+ postSortDrawableList.sort((a, b) => {
19387
+ return a.renderOrder - b.renderOrder;
19388
+ });
19379
19389
  }
19380
19390
 
19381
19391
  function cullDrawableList() {
19382
- for (let type in drawableTypeInfo) {
19383
- if (drawableTypeInfo.hasOwnProperty(type)) {
19384
- const drawableInfo = drawableTypeInfo[type];
19385
- const drawableListPreCull = drawableInfo.drawableListPreCull;
19386
- const drawableList = drawableInfo.drawableList;
19387
- let lenDrawableList = 0;
19388
- for (let i = 0, len = drawableListPreCull.length; i < len; i++) {
19389
- const drawable = drawableListPreCull[i];
19390
- drawable.rebuildRenderFlags();
19391
- if (!drawable.renderFlags.culled) {
19392
- drawableList[lenDrawableList++] = drawable;
19393
- }
19394
- }
19395
- drawableList.length = lenDrawableList;
19392
+ let lenDrawableList = 0;
19393
+ for (let i = 0, len = postSortDrawableList.length; i < len; i++) {
19394
+ const drawable = postSortDrawableList[i];
19395
+ drawable.rebuildRenderFlags();
19396
+ if (!drawable.renderFlags.culled) {
19397
+ postCullDrawableList[lenDrawableList++] = drawable;
19396
19398
  }
19397
19399
  }
19400
+ postCullDrawableList.length = lenDrawableList;
19398
19401
  }
19399
19402
 
19400
19403
  function draw(params) {
@@ -19470,25 +19473,16 @@ const Renderer$1 = function (scene, options) {
19470
19473
  if (params.clear !== false) {
19471
19474
  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
19472
19475
  }
19476
+ for (let i = 0, len = postCullDrawableList.length; i < len; i++) {
19473
19477
 
19474
- for (let type in drawableTypeInfo) {
19475
- if (drawableTypeInfo.hasOwnProperty(type)) {
19478
+ const drawable = postCullDrawableList[i];
19476
19479
 
19477
- const drawableInfo = drawableTypeInfo[type];
19478
- const drawableList = drawableInfo.drawableList;
19479
-
19480
- for (let i = 0, len = drawableList.length; i < len; i++) {
19481
-
19482
- const drawable = drawableList[i];
19483
-
19484
- if (drawable.culled === true || drawable.visible === false || !drawable.drawDepth || !drawable.saoEnabled) {
19485
- continue;
19486
- }
19480
+ if (drawable.culled === true || drawable.visible === false || !drawable.drawDepth || !drawable.saoEnabled) {
19481
+ continue;
19482
+ }
19487
19483
 
19488
- if (drawable.renderFlags.colorOpaque) {
19489
- drawable.drawDepth(frameCtx);
19490
- }
19491
- }
19484
+ if (drawable.renderFlags.colorOpaque) {
19485
+ drawable.drawDepth(frameCtx);
19492
19486
  }
19493
19487
  }
19494
19488
 
@@ -19627,7 +19621,6 @@ const Renderer$1 = function (scene, options) {
19627
19621
  }
19628
19622
 
19629
19623
  let i;
19630
- let len;
19631
19624
  let drawable;
19632
19625
 
19633
19626
  const startTime = Date.now();
@@ -19660,93 +19653,85 @@ const Renderer$1 = function (scene, options) {
19660
19653
  // Render normal opaque solids, defer others to bins to render after
19661
19654
  //------------------------------------------------------------------------------------------------------
19662
19655
 
19663
- for (let type in drawableTypeInfo) {
19664
- if (drawableTypeInfo.hasOwnProperty(type)) {
19665
-
19666
- const drawableInfo = drawableTypeInfo[type];
19667
- const drawableList = drawableInfo.drawableList;
19668
-
19669
- for (i = 0, len = drawableList.length; i < len; i++) {
19656
+ for (let i = 0, len = postCullDrawableList.length; i < len; i++) {
19670
19657
 
19671
- drawable = drawableList[i];
19658
+ drawable = postCullDrawableList[i];
19672
19659
 
19673
- if (drawable.culled === true || drawable.visible === false) {
19674
- continue;
19675
- }
19660
+ if (drawable.culled === true || drawable.visible === false) {
19661
+ continue;
19662
+ }
19676
19663
 
19677
- const renderFlags = drawable.renderFlags;
19664
+ const renderFlags = drawable.renderFlags;
19678
19665
 
19679
- if (renderFlags.colorOpaque) {
19680
- if (saoEnabled && saoPossible && drawable.saoEnabled) {
19681
- normalDrawSAOBin[normalDrawSAOBinLen++] = drawable;
19682
- } else {
19683
- drawable.drawColorOpaque(frameCtx);
19684
- }
19685
- }
19666
+ if (renderFlags.colorOpaque) {
19667
+ if (saoEnabled && saoPossible && drawable.saoEnabled) {
19668
+ normalDrawSAOBin[normalDrawSAOBinLen++] = drawable;
19669
+ } else {
19670
+ drawable.drawColorOpaque(frameCtx);
19671
+ }
19672
+ }
19686
19673
 
19687
- if (transparentEnabled) {
19688
- if (renderFlags.colorTransparent) {
19689
- normalFillTransparentBin[normalFillTransparentBinLen++] = drawable;
19690
- }
19691
- }
19674
+ if (transparentEnabled) {
19675
+ if (renderFlags.colorTransparent) {
19676
+ normalFillTransparentBin[normalFillTransparentBinLen++] = drawable;
19677
+ }
19678
+ }
19692
19679
 
19693
- if (renderFlags.xrayedSilhouetteTransparent) {
19694
- xrayedFillTransparentBin[xrayedFillTransparentBinLen++] = drawable;
19695
- }
19680
+ if (renderFlags.xrayedSilhouetteTransparent) {
19681
+ xrayedFillTransparentBin[xrayedFillTransparentBinLen++] = drawable;
19682
+ }
19696
19683
 
19697
- if (renderFlags.xrayedSilhouetteOpaque) {
19698
- xrayedFillOpaqueBin[xrayedFillOpaqueBinLen++] = drawable;
19699
- }
19684
+ if (renderFlags.xrayedSilhouetteOpaque) {
19685
+ xrayedFillOpaqueBin[xrayedFillOpaqueBinLen++] = drawable;
19686
+ }
19700
19687
 
19701
- if (renderFlags.highlightedSilhouetteTransparent) {
19702
- highlightedFillTransparentBin[highlightedFillTransparentBinLen++] = drawable;
19703
- }
19688
+ if (renderFlags.highlightedSilhouetteTransparent) {
19689
+ highlightedFillTransparentBin[highlightedFillTransparentBinLen++] = drawable;
19690
+ }
19704
19691
 
19705
- if (renderFlags.highlightedSilhouetteOpaque) {
19706
- highlightedFillOpaqueBin[highlightedFillOpaqueBinLen++] = drawable;
19707
- }
19692
+ if (renderFlags.highlightedSilhouetteOpaque) {
19693
+ highlightedFillOpaqueBin[highlightedFillOpaqueBinLen++] = drawable;
19694
+ }
19708
19695
 
19709
- if (renderFlags.selectedSilhouetteTransparent) {
19710
- selectedFillTransparentBin[selectedFillTransparentBinLen++] = drawable;
19711
- }
19696
+ if (renderFlags.selectedSilhouetteTransparent) {
19697
+ selectedFillTransparentBin[selectedFillTransparentBinLen++] = drawable;
19698
+ }
19712
19699
 
19713
- if (renderFlags.selectedSilhouetteOpaque) {
19714
- selectedFillOpaqueBin[selectedFillOpaqueBinLen++] = drawable;
19715
- }
19700
+ if (renderFlags.selectedSilhouetteOpaque) {
19701
+ selectedFillOpaqueBin[selectedFillOpaqueBinLen++] = drawable;
19702
+ }
19716
19703
 
19717
- if (drawable.edges && edgesEnabled) {
19718
- if (renderFlags.edgesOpaque) {
19719
- normalEdgesOpaqueBin[normalEdgesOpaqueBinLen++] = drawable;
19720
- }
19704
+ if (drawable.edges && edgesEnabled) {
19705
+ if (renderFlags.edgesOpaque) {
19706
+ normalEdgesOpaqueBin[normalEdgesOpaqueBinLen++] = drawable;
19707
+ }
19721
19708
 
19722
- if (renderFlags.edgesTransparent) {
19723
- normalEdgesTransparentBin[normalEdgesTransparentBinLen++] = drawable;
19724
- }
19709
+ if (renderFlags.edgesTransparent) {
19710
+ normalEdgesTransparentBin[normalEdgesTransparentBinLen++] = drawable;
19711
+ }
19725
19712
 
19726
- if (renderFlags.selectedEdgesTransparent) {
19727
- selectedEdgesTransparentBin[selectedEdgesTransparentBinLen++] = drawable;
19728
- }
19713
+ if (renderFlags.selectedEdgesTransparent) {
19714
+ selectedEdgesTransparentBin[selectedEdgesTransparentBinLen++] = drawable;
19715
+ }
19729
19716
 
19730
- if (renderFlags.selectedEdgesOpaque) {
19731
- selectedEdgesOpaqueBin[selectedEdgesOpaqueBinLen++] = drawable;
19732
- }
19717
+ if (renderFlags.selectedEdgesOpaque) {
19718
+ selectedEdgesOpaqueBin[selectedEdgesOpaqueBinLen++] = drawable;
19719
+ }
19733
19720
 
19734
- if (renderFlags.xrayedEdgesTransparent) {
19735
- xrayEdgesTransparentBin[xrayEdgesTransparentBinLen++] = drawable;
19736
- }
19721
+ if (renderFlags.xrayedEdgesTransparent) {
19722
+ xrayEdgesTransparentBin[xrayEdgesTransparentBinLen++] = drawable;
19723
+ }
19737
19724
 
19738
- if (renderFlags.xrayedEdgesOpaque) {
19739
- xrayEdgesOpaqueBin[xrayEdgesOpaqueBinLen++] = drawable;
19740
- }
19725
+ if (renderFlags.xrayedEdgesOpaque) {
19726
+ xrayEdgesOpaqueBin[xrayEdgesOpaqueBinLen++] = drawable;
19727
+ }
19741
19728
 
19742
- if (renderFlags.highlightedEdgesTransparent) {
19743
- highlightedEdgesTransparentBin[highlightedEdgesTransparentBinLen++] = drawable;
19744
- }
19729
+ if (renderFlags.highlightedEdgesTransparent) {
19730
+ highlightedEdgesTransparentBin[highlightedEdgesTransparentBinLen++] = drawable;
19731
+ }
19745
19732
 
19746
- if (renderFlags.highlightedEdgesOpaque) {
19747
- highlightedEdgesOpaqueBin[highlightedEdgesOpaqueBinLen++] = drawable;
19748
- }
19749
- }
19733
+ if (renderFlags.highlightedEdgesOpaque) {
19734
+ highlightedEdgesOpaqueBin[highlightedEdgesOpaqueBinLen++] = drawable;
19750
19735
  }
19751
19736
  }
19752
19737
  }
@@ -20152,7 +20137,7 @@ const Renderer$1 = function (scene, options) {
20152
20137
  frameCtx.pickInvisible = !!params.pickInvisible;
20153
20138
  frameCtx.pickClipPos = [
20154
20139
  getClipPosX(canvasPos[0] * resolutionScale, gl.drawingBufferWidth),
20155
- getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight),
20140
+ getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight)
20156
20141
  ];
20157
20142
 
20158
20143
  gl.viewport(0, 0, 1, 1);
@@ -20165,30 +20150,23 @@ const Renderer$1 = function (scene, options) {
20165
20150
  const includeEntityIds = params.includeEntityIds;
20166
20151
  const excludeEntityIds = params.excludeEntityIds;
20167
20152
 
20168
- for (let type in drawableTypeInfo) {
20169
- if (drawableTypeInfo.hasOwnProperty(type)) {
20170
-
20171
- const drawableInfo = drawableTypeInfo[type];
20172
- const drawableList = drawableInfo.drawableList;
20173
-
20174
- for (let i = 0, len = drawableList.length; i < len; i++) {
20175
-
20176
- const drawable = drawableList[i];
20177
-
20178
- if (!drawable.drawPickMesh || (params.pickInvisible !== true && drawable.visible === false) || drawable.pickable === false) {
20179
- continue;
20180
- }
20181
- if (includeEntityIds && !includeEntityIds[drawable.id]) { // TODO: push this logic into drawable
20182
- continue;
20183
- }
20184
- if (excludeEntityIds && excludeEntityIds[drawable.id]) {
20185
- continue;
20186
- }
20187
-
20188
- drawable.drawPickMesh(frameCtx);
20189
- }
20153
+ for (let i = 0, len = postCullDrawableList.length; i < len; i++) {
20154
+ const drawable = postCullDrawableList[i];
20155
+ if (drawable.culled === true || drawable.visible === false) {
20156
+ continue;
20157
+ }
20158
+ if (!drawable.drawPickMesh || (params.pickInvisible !== true && drawable.visible === false) || drawable.pickable === false) {
20159
+ continue;
20160
+ }
20161
+ if (includeEntityIds && !includeEntityIds[drawable.id]) { // TODO: push this logic into drawable
20162
+ continue;
20163
+ }
20164
+ if (excludeEntityIds && excludeEntityIds[drawable.id]) {
20165
+ continue;
20190
20166
  }
20167
+ drawable.drawPickMesh(frameCtx);
20191
20168
  }
20169
+
20192
20170
  const pix = pickBuffer.read(0, 0);
20193
20171
  const pickID = pix[0] + (pix[1] << 8) + (pix[2] << 16) + (pix[3] << 24);
20194
20172
 
@@ -20218,7 +20196,7 @@ const Renderer$1 = function (scene, options) {
20218
20196
  // frameCtx.pickInvisible = !!params.pickInvisible;
20219
20197
  frameCtx.pickClipPos = [
20220
20198
  getClipPosX(canvasPos[0] * resolutionScale, gl.drawingBufferWidth),
20221
- getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight),
20199
+ getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight)
20222
20200
  ];
20223
20201
 
20224
20202
  gl.viewport(0, 0, 1, 1);
@@ -20267,7 +20245,7 @@ const Renderer$1 = function (scene, options) {
20267
20245
  frameCtx.pickElementsOffset = pickable.pickElementsOffset;
20268
20246
  frameCtx.pickClipPos = [
20269
20247
  getClipPosX(canvasPos[0] * resolutionScale, gl.drawingBufferWidth),
20270
- getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight),
20248
+ getClipPosY(canvasPos[1] * resolutionScale, gl.drawingBufferHeight)
20271
20249
  ];
20272
20250
 
20273
20251
  gl.viewport(0, 0, 1, 1);
@@ -20332,15 +20310,14 @@ const Renderer$1 = function (scene, options) {
20332
20310
  function drawSnapInit(frameCtx) {
20333
20311
  frameCtx.snapPickLayerParams = [];
20334
20312
  frameCtx.snapPickLayerNumber = 0;
20335
- for (let type in drawableTypeInfo) {
20336
- const drawableInfo = drawableTypeInfo[type];
20337
- const drawableList = drawableInfo.drawableList;
20338
- for (let i = 0, len = drawableList.length; i < len; i++) {
20339
- const drawable = drawableList[i];
20340
- if (drawable.drawSnapInit) {
20341
- if (!drawable.culled && drawable.visible && drawable.pickable) {
20342
- drawable.drawSnapInit(frameCtx);
20343
- }
20313
+
20314
+ for (let i = 0, len = postCullDrawableList.length; i < len; i++) {
20315
+
20316
+ const drawable = postCullDrawableList[i];
20317
+
20318
+ if (drawable.drawSnapInit) {
20319
+ if (!drawable.culled && drawable.visible && drawable.pickable) {
20320
+ drawable.drawSnapInit(frameCtx);
20344
20321
  }
20345
20322
  }
20346
20323
  }
@@ -20350,11 +20327,11 @@ const Renderer$1 = function (scene, options) {
20350
20327
  function drawSnap(frameCtx) {
20351
20328
  frameCtx.snapPickLayerParams = frameCtx.snapPickLayerParams || [];
20352
20329
  frameCtx.snapPickLayerNumber = frameCtx.snapPickLayerParams.length;
20353
- for (let type in drawableTypeInfo) {
20354
- const drawableInfo = drawableTypeInfo[type];
20355
- const drawableList = drawableInfo.drawableList;
20356
- for (let i = 0, len = drawableList.length; i < len; i++) {
20357
- const drawable = drawableList[i];
20330
+ for (let i = 0, len = postCullDrawableList.length; i < len; i++) {
20331
+
20332
+ const drawable = postCullDrawableList[i];
20333
+
20334
+ if (drawable.drawSnapInit) {
20358
20335
  if (drawable.drawSnap) {
20359
20336
  if (!drawable.culled && drawable.visible && drawable.pickable) {
20360
20337
  drawable.drawSnap(frameCtx);
@@ -20744,19 +20721,16 @@ const Renderer$1 = function (scene, options) {
20744
20721
  gl.disable(gl.BLEND);
20745
20722
  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
20746
20723
 
20747
- for (let type in drawableTypeInfo) {
20748
- if (drawableTypeInfo.hasOwnProperty(type)) {
20749
- const drawableInfo = drawableTypeInfo[type];
20750
- const drawableList = drawableInfo.drawableList;
20751
- for (let i = 0, len = drawableList.length; i < len; i++) {
20752
- const drawable = drawableList[i];
20753
- if (!drawable.drawOcclusion || drawable.culled === true || drawable.visible === false || drawable.pickable === false) { // TODO: Option to exclude transparent?
20754
- continue;
20755
- }
20756
20724
 
20757
- drawable.drawOcclusion(frameCtx);
20758
- }
20725
+ for (let i = 0, len = postCullDrawableList.length; i < len; i++) {
20726
+
20727
+ const drawable = postCullDrawableList[i];
20728
+
20729
+ if (!drawable.drawOcclusion || drawable.culled === true || drawable.visible === false || drawable.pickable === false) { // TODO: Option to exclude transparent?
20730
+ continue;
20759
20731
  }
20732
+
20733
+ drawable.drawOcclusion(frameCtx);
20760
20734
  }
20761
20735
 
20762
20736
  this._occlusionTester.drawMarkers(frameCtx);
@@ -132473,6 +132447,9 @@ class XKTLoaderPlugin extends Plugin {
132473
132447
  * represent the returned model. Set false to always use vertex buffer objects (VBOs). Note that DTX is only applicable
132474
132448
  * to non-textured triangle meshes, and that VBOs are always used for meshes that have textures, line segments, or point
132475
132449
  * primitives. Only works while {@link DTX#enabled} is also ````true````.
132450
+ * @param {Number} [params.renderOrder=0] Specifies the rendering order for the model. This is used to control the order in which
132451
+ * SceneModels are drawn when they have transparent objects, to give control over the order in which those objects are blended within the transparent
132452
+ * render pass.
132476
132453
  * @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}.
132477
132454
  */
132478
132455
  load(params = {}) {
@@ -132522,7 +132499,8 @@ class XKTLoaderPlugin extends Plugin {
132522
132499
  origin: params.origin,
132523
132500
  disableVertexWelding: params.disableVertexWelding || false,
132524
132501
  disableIndexRebucketing: params.disableIndexRebucketing || false,
132525
- dtxEnabled: params.dtxEnabled
132502
+ dtxEnabled: params.dtxEnabled,
132503
+ renderOrder: params.renderOrder
132526
132504
  }));
132527
132505
 
132528
132506
  const modelId = sceneModel.id; // In case ID was auto-generated
@@ -139728,10 +139706,9 @@ const basePolygon3D = function(scene, color, alpha) {
139728
139706
  };
139729
139707
  };
139730
139708
 
139731
- const startAAZoneCreateUI = function(scene, zoneAltitude, zoneHeight, zoneColor, zoneAlpha, pointerLens, zonesPlugin, select3dPoint, onZoneCreated) {
139732
- const marker1 = marker3D(scene, zoneColor);
139733
- const marker2 = marker3D(scene, zoneColor);
139734
- const basePolygon = basePolygon3D(scene, zoneColor, zoneAlpha);
139709
+ const startAARectCreateUI = function(scene, markersColor, pointerLens, select3dPoint, withPoints, onPointsSelected) {
139710
+ const marker1 = marker3D(scene, markersColor);
139711
+ const marker2 = marker3D(scene, markersColor);
139735
139712
 
139736
139713
  const updatePointerLens = (pointerLens
139737
139714
  ? function(canvasPos) {
@@ -139759,29 +139736,14 @@ const startAAZoneCreateUI = function(scene, zoneAltitude, zoneHeight, zoneColor,
139759
139736
  function() {
139760
139737
  updatePointerLens(null);
139761
139738
  marker2.update(null);
139762
- basePolygon.updateBase(null);
139739
+ withPoints(null);
139763
139740
  },
139764
139741
  function(canvasPos, point2WorldPos) {
139765
139742
  updatePointerLens(canvasPos);
139766
139743
  marker2.update(point2WorldPos);
139767
-
139768
- if (math.distVec3(point1WorldPos, point2WorldPos) > 0.01)
139769
- {
139770
- const min = (idx) => Math.min(point1WorldPos[idx], point2WorldPos[idx]);
139771
- const max = (idx) => Math.max(point1WorldPos[idx], point2WorldPos[idx]);
139772
-
139773
- const xmin = min(0);
139774
- const ymin = min(1);
139775
- const zmin = min(2);
139776
- const xmax = max(0);
139777
- max(1);
139778
- const zmax = max(2);
139779
-
139780
- basePolygon.updateBase([ [ xmin, ymin, zmax ], [ xmax, ymin, zmax ],
139781
- [ xmax, ymin, zmin ], [ xmin, ymin, zmin ] ]);
139782
- }
139783
- else
139784
- basePolygon.updateBase(null);
139744
+ withPoints((math.distVec3(point1WorldPos, point2WorldPos) > 0.01)
139745
+ &&
139746
+ [ point1WorldPos, point2WorldPos ]);
139785
139747
  },
139786
139748
  function(point2CanvasPos, point2WorldPos) {
139787
139749
  // `marker2.update' makes sure marker's position has been updated from its default [0,0,0]
@@ -139791,35 +139753,9 @@ const startAAZoneCreateUI = function(scene, zoneAltitude, zoneHeight, zoneColor,
139791
139753
 
139792
139754
  marker1.destroy();
139793
139755
  marker2.destroy();
139794
- basePolygon.destroy();
139795
139756
  updatePointerLens(null);
139796
139757
 
139797
- const min = (idx) => Math.min(point1WorldPos[idx], point2WorldPos[idx]);
139798
- const max = (idx) => Math.max(point1WorldPos[idx], point2WorldPos[idx]);
139799
-
139800
- const xmin = min(0);
139801
- const zmin = min(2);
139802
- const xmax = max(0);
139803
- const zmax = max(2);
139804
-
139805
- const zone = zonesPlugin.createZone(
139806
- {
139807
- id: math.createUUID(),
139808
- geometry: {
139809
- planeCoordinates: [
139810
- [ xmin, zmax ],
139811
- [ xmax, zmax ],
139812
- [ xmax, zmin ],
139813
- [ xmin, zmin ]
139814
- ],
139815
- altitude: zoneAltitude,
139816
- height: zoneHeight
139817
- },
139818
- alpha: zoneAlpha,
139819
- color: zoneColor
139820
- });
139821
-
139822
- onZoneCreated(zone);
139758
+ onPointsSelected([ point1WorldPos, point2WorldPos ]);
139823
139759
  });
139824
139760
  });
139825
139761
 
@@ -139828,7 +139764,6 @@ const startAAZoneCreateUI = function(scene, zoneAltitude, zoneHeight, zoneColor,
139828
139764
  deactivatePointSelection();
139829
139765
  marker1.destroy();
139830
139766
  marker2.destroy();
139831
- basePolygon.destroy();
139832
139767
  updatePointerLens(null);
139833
139768
  }
139834
139769
  };
@@ -140488,6 +140423,34 @@ class Zone extends Component {
140488
140423
  }
140489
140424
  }
140490
140425
 
140426
+ const createAAZoneFromPoints = function(pos1, pos2, zoneAltitude, zoneHeight, zoneColor, zoneAlpha, zonesPlugin) {
140427
+
140428
+ const min = (idx) => Math.min(pos1[idx], pos2[idx]);
140429
+ const max = (idx) => Math.max(pos1[idx], pos2[idx]);
140430
+
140431
+ const xmin = min(0);
140432
+ const zmin = min(2);
140433
+ const xmax = max(0);
140434
+ const zmax = max(2);
140435
+
140436
+ return zonesPlugin.createZone(
140437
+ {
140438
+ id: math.createUUID(),
140439
+ geometry: {
140440
+ planeCoordinates: [
140441
+ [ xmin, zmax ],
140442
+ [ xmax, zmax ],
140443
+ [ xmax, zmin ],
140444
+ [ xmin, zmin ]
140445
+ ],
140446
+ altitude: zoneAltitude,
140447
+ height: zoneHeight
140448
+ },
140449
+ alpha: zoneAlpha,
140450
+ color: zoneColor
140451
+ });
140452
+ };
140453
+
140491
140454
  /**
140492
140455
  * Creates {@link Zone}s in a {@link ZonesPlugin} from mouse input.
140493
140456
  *
@@ -140518,7 +140481,7 @@ class Zone extends Component {
140518
140481
  * const zonesControl = new ZonesMouseControl(Zones)
140519
140482
  * ````
140520
140483
  */
140521
- class ZonesMouseControl extends Component {
140484
+ class ZonesAAZoneControl extends Component {
140522
140485
 
140523
140486
  /**
140524
140487
  * Creates a ZonesMouseControl bound to the given ZonesPlugin.
@@ -140527,11 +140490,12 @@ class ZonesMouseControl extends Component {
140527
140490
  * @param [cfg] Configuration
140528
140491
  * @param {PointerLens} [cfg.pointerLens] A PointerLens to use to provide a magnified view of the cursor when snapping is enabled.
140529
140492
  */
140530
- constructor(zonesPlugin, cfg = {}) {
140493
+ constructor(zonesPlugin, cfg, createSelect3dPoint) {
140531
140494
  super(zonesPlugin.viewer.scene);
140532
140495
 
140533
140496
  this.zonesPlugin = zonesPlugin;
140534
140497
  this.pointerLens = cfg.pointerLens;
140498
+ this.createSelect3dPoint = createSelect3dPoint;
140535
140499
  this._deactivate = null;
140536
140500
  }
140537
140501
 
@@ -140568,16 +140532,35 @@ class ZonesMouseControl extends Component {
140568
140532
  const scene = viewer.scene;
140569
140533
  const self = this;
140570
140534
 
140571
- const select3dPoint = mousePointSelector(
140572
- viewer,
140573
- function(origin, direction) {
140574
- return planeIntersect(zoneAltitude, math.vec3([ 0, 1, 0 ]), origin, direction);
140575
- });
140535
+ const select3dPoint = this.createSelect3dPoint(viewer, (origin, direction) => planeIntersect(zoneAltitude, math.vec3([ 0, 1, 0 ]), origin, direction));
140576
140536
 
140577
140537
  (function rec() {
140578
- self._deactivate = startAAZoneCreateUI(
140579
- scene, zoneAltitude, zoneHeight, zoneColor, zoneAlpha, self.pointerLens, zonesPlugin, select3dPoint,
140580
- zone => {
140538
+ const basePolygon = basePolygon3D(scene, zoneColor, zoneAlpha);
140539
+ const deactivate = startAARectCreateUI(
140540
+ scene, zoneColor, self.pointerLens, select3dPoint,
140541
+ points => {
140542
+ if (points) {
140543
+ const p0 = points[0];
140544
+ const p1 = points[1];
140545
+ const min = (idx) => Math.min(p0[idx], p1[idx]);
140546
+ const max = (idx) => Math.max(p0[idx], p1[idx]);
140547
+
140548
+ const xmin = min(0);
140549
+ const ymin = min(1);
140550
+ const zmin = min(2);
140551
+ const xmax = max(0);
140552
+ max(1);
140553
+ const zmax = max(2);
140554
+
140555
+ basePolygon.updateBase([ [ xmin, ymin, zmax ], [ xmax, ymin, zmax ],
140556
+ [ xmax, ymin, zmin ], [ xmin, ymin, zmin ] ]);
140557
+ } else {
140558
+ basePolygon.updateBase(null);
140559
+ }
140560
+ },
140561
+ points => {
140562
+ basePolygon.destroy();
140563
+ const zone = createAAZoneFromPoints(points[0], points[1], zoneAltitude, zoneHeight, zoneColor, zoneAlpha, zonesPlugin);
140581
140564
  let reactivate = true;
140582
140565
  self._deactivate = () => { reactivate = false; };
140583
140566
  self.fire("zoneEnd", zone);
@@ -140586,6 +140569,10 @@ class ZonesMouseControl extends Component {
140586
140569
  rec();
140587
140570
  }
140588
140571
  }).deactivate;
140572
+ self._deactivate = () => {
140573
+ deactivate();
140574
+ basePolygon.destroy();
140575
+ };
140589
140576
  })();
140590
140577
  }
140591
140578
 
@@ -140608,6 +140595,30 @@ class ZonesMouseControl extends Component {
140608
140595
  }
140609
140596
  }
140610
140597
 
140598
+ class ZonesMouseControl extends ZonesAAZoneControl {
140599
+ constructor(zonesPlugin, cfg = {}) {
140600
+ super(
140601
+ zonesPlugin,
140602
+ cfg,
140603
+ (viewer, ray2WorldPos) => mousePointSelector(viewer, ray2WorldPos));
140604
+ }
140605
+ }
140606
+ class ZonesTouchControl extends ZonesAAZoneControl {
140607
+ constructor(zonesPlugin, cfg = {}) {
140608
+ const pointerCircle = new PointerCircle(zonesPlugin.viewer);
140609
+ super(
140610
+ zonesPlugin,
140611
+ cfg,
140612
+ (viewer, ray2WorldPos) => touchPointSelector(viewer, pointerCircle, ray2WorldPos));
140613
+ this.pointerCircle = pointerCircle;
140614
+ }
140615
+
140616
+ destroy() {
140617
+ this.pointerCircle.destroy();
140618
+ super.destroy();
140619
+ }
140620
+ }
140621
+
140611
140622
  /**
140612
140623
  * ZonesPlugin documentation to be added, mostly compatible with DistanceMeasurementsPlugin.
140613
140624
  */
@@ -140722,86 +140733,6 @@ class ZonesPlugin extends Plugin {
140722
140733
  }
140723
140734
  }
140724
140735
 
140725
- class ZonesTouchControl extends Component {
140726
-
140727
- constructor(zonesPlugin, cfg = {}) {
140728
- super(zonesPlugin.viewer.scene);
140729
-
140730
- this.zonesPlugin = zonesPlugin;
140731
- this.pointerLens = cfg.pointerLens;
140732
- this.pointerCircle = new PointerCircle(zonesPlugin.viewer);
140733
- this._deactivate = null;
140734
- }
140735
-
140736
- get active() {
140737
- return !! this._deactivate;
140738
- }
140739
-
140740
- activate(zoneAltitude, zoneHeight, zoneColor, zoneAlpha) {
140741
-
140742
- if (typeof(zoneAltitude) === "object" && (zoneAltitude !== null)) {
140743
- const params = zoneAltitude;
140744
- const param = (name, defaultValue) => {
140745
- if (name in params) {
140746
- return params[name];
140747
- } else if (defaultValue !== undefined) {
140748
- return defaultValue;
140749
- } else {
140750
- throw "config missing: " + name;
140751
- }
140752
- };
140753
-
140754
- zoneAltitude = param("altitude");
140755
- zoneHeight = param("height");
140756
- zoneColor = param("color", "#008000");
140757
- zoneAlpha = param("alpha", 0.5);
140758
- }
140759
-
140760
- if (this._deactivate) {
140761
- return;
140762
- }
140763
-
140764
- const zonesPlugin = this.zonesPlugin;
140765
- const viewer = zonesPlugin.viewer;
140766
- const scene = viewer.scene;
140767
- const self = this;
140768
-
140769
- const select3dPoint = touchPointSelector(
140770
- viewer,
140771
- this.pointerCircle,
140772
- function(origin, direction) {
140773
- return planeIntersect(zoneAltitude, math.vec3([ 0, 1, 0 ]), origin, direction);
140774
- });
140775
-
140776
- (function rec() {
140777
- self._deactivate = startAAZoneCreateUI(
140778
- scene, zoneAltitude, zoneHeight, zoneColor, zoneAlpha, self.pointerLens, zonesPlugin, select3dPoint,
140779
- zone => {
140780
- let reactivate = true;
140781
- self._deactivate = () => { reactivate = false; };
140782
- self.fire("zoneEnd", zone);
140783
- if (reactivate)
140784
- {
140785
- rec();
140786
- }
140787
- }).deactivate;
140788
- })();
140789
- }
140790
-
140791
- deactivate() {
140792
- if (this._deactivate)
140793
- {
140794
- this._deactivate();
140795
- this._deactivate = null;
140796
- }
140797
- }
140798
-
140799
- destroy() {
140800
- this.deactivate();
140801
- super.destroy();
140802
- }
140803
- }
140804
-
140805
140736
  const startPolysurfaceZoneCreateUI = function(scene, zoneAltitude, zoneHeight, zoneColor, zoneAlpha, pointerLens, zonesPlugin, select3dPoint, onZoneCreated) {
140806
140737
  const updatePointerLens = (pointerLens
140807
140738
  ? function(canvasPos) {