@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.
@@ -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)) {
19482
+ const drawable = postCullDrawableList[i];
19480
19483
 
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];
19487
-
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);
@@ -20748,19 +20725,16 @@ const Renderer$1 = function (scene, options) {
20748
20725
  gl.disable(gl.BLEND);
20749
20726
  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
20750
20727
 
20751
- for (let type in drawableTypeInfo) {
20752
- if (drawableTypeInfo.hasOwnProperty(type)) {
20753
- const drawableInfo = drawableTypeInfo[type];
20754
- const drawableList = drawableInfo.drawableList;
20755
- for (let i = 0, len = drawableList.length; i < len; i++) {
20756
- const drawable = drawableList[i];
20757
- if (!drawable.drawOcclusion || drawable.culled === true || drawable.visible === false || drawable.pickable === false) { // TODO: Option to exclude transparent?
20758
- continue;
20759
- }
20760
20728
 
20761
- drawable.drawOcclusion(frameCtx);
20762
- }
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;
20763
20735
  }
20736
+
20737
+ drawable.drawOcclusion(frameCtx);
20764
20738
  }
20765
20739
 
20766
20740
  this._occlusionTester.drawMarkers(frameCtx);
@@ -132477,6 +132451,9 @@ class XKTLoaderPlugin extends Plugin {
132477
132451
  * represent the returned model. Set false to always use vertex buffer objects (VBOs). Note that DTX is only applicable
132478
132452
  * to non-textured triangle meshes, and that VBOs are always used for meshes that have textures, line segments, or point
132479
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.
132480
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}.
132481
132458
  */
132482
132459
  load(params = {}) {
@@ -132526,7 +132503,8 @@ class XKTLoaderPlugin extends Plugin {
132526
132503
  origin: params.origin,
132527
132504
  disableVertexWelding: params.disableVertexWelding || false,
132528
132505
  disableIndexRebucketing: params.disableIndexRebucketing || false,
132529
- dtxEnabled: params.dtxEnabled
132506
+ dtxEnabled: params.dtxEnabled,
132507
+ renderOrder: params.renderOrder
132530
132508
  }));
132531
132509
 
132532
132510
  const modelId = sceneModel.id; // In case ID was auto-generated
@@ -139732,10 +139710,9 @@ const basePolygon3D = function(scene, color, alpha) {
139732
139710
  };
139733
139711
  };
139734
139712
 
139735
- const startAAZoneCreateUI = function(scene, zoneAltitude, zoneHeight, zoneColor, zoneAlpha, pointerLens, zonesPlugin, select3dPoint, onZoneCreated) {
139736
- const marker1 = marker3D(scene, zoneColor);
139737
- const marker2 = marker3D(scene, zoneColor);
139738
- 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);
139739
139716
 
139740
139717
  const updatePointerLens = (pointerLens
139741
139718
  ? function(canvasPos) {
@@ -139763,29 +139740,14 @@ const startAAZoneCreateUI = function(scene, zoneAltitude, zoneHeight, zoneColor,
139763
139740
  function() {
139764
139741
  updatePointerLens(null);
139765
139742
  marker2.update(null);
139766
- basePolygon.updateBase(null);
139743
+ withPoints(null);
139767
139744
  },
139768
139745
  function(canvasPos, point2WorldPos) {
139769
139746
  updatePointerLens(canvasPos);
139770
139747
  marker2.update(point2WorldPos);
139771
-
139772
- if (math.distVec3(point1WorldPos, point2WorldPos) > 0.01)
139773
- {
139774
- const min = (idx) => Math.min(point1WorldPos[idx], point2WorldPos[idx]);
139775
- const max = (idx) => Math.max(point1WorldPos[idx], point2WorldPos[idx]);
139776
-
139777
- const xmin = min(0);
139778
- const ymin = min(1);
139779
- const zmin = min(2);
139780
- const xmax = max(0);
139781
- max(1);
139782
- const zmax = max(2);
139783
-
139784
- basePolygon.updateBase([ [ xmin, ymin, zmax ], [ xmax, ymin, zmax ],
139785
- [ xmax, ymin, zmin ], [ xmin, ymin, zmin ] ]);
139786
- }
139787
- else
139788
- basePolygon.updateBase(null);
139748
+ withPoints((math.distVec3(point1WorldPos, point2WorldPos) > 0.01)
139749
+ &&
139750
+ [ point1WorldPos, point2WorldPos ]);
139789
139751
  },
139790
139752
  function(point2CanvasPos, point2WorldPos) {
139791
139753
  // `marker2.update' makes sure marker's position has been updated from its default [0,0,0]
@@ -139795,35 +139757,9 @@ const startAAZoneCreateUI = function(scene, zoneAltitude, zoneHeight, zoneColor,
139795
139757
 
139796
139758
  marker1.destroy();
139797
139759
  marker2.destroy();
139798
- basePolygon.destroy();
139799
139760
  updatePointerLens(null);
139800
139761
 
139801
- const min = (idx) => Math.min(point1WorldPos[idx], point2WorldPos[idx]);
139802
- const max = (idx) => Math.max(point1WorldPos[idx], point2WorldPos[idx]);
139803
-
139804
- const xmin = min(0);
139805
- const zmin = min(2);
139806
- const xmax = max(0);
139807
- const zmax = max(2);
139808
-
139809
- const zone = zonesPlugin.createZone(
139810
- {
139811
- id: math.createUUID(),
139812
- geometry: {
139813
- planeCoordinates: [
139814
- [ xmin, zmax ],
139815
- [ xmax, zmax ],
139816
- [ xmax, zmin ],
139817
- [ xmin, zmin ]
139818
- ],
139819
- altitude: zoneAltitude,
139820
- height: zoneHeight
139821
- },
139822
- alpha: zoneAlpha,
139823
- color: zoneColor
139824
- });
139825
-
139826
- onZoneCreated(zone);
139762
+ onPointsSelected([ point1WorldPos, point2WorldPos ]);
139827
139763
  });
139828
139764
  });
139829
139765
 
@@ -139832,7 +139768,6 @@ const startAAZoneCreateUI = function(scene, zoneAltitude, zoneHeight, zoneColor,
139832
139768
  deactivatePointSelection();
139833
139769
  marker1.destroy();
139834
139770
  marker2.destroy();
139835
- basePolygon.destroy();
139836
139771
  updatePointerLens(null);
139837
139772
  }
139838
139773
  };
@@ -140492,6 +140427,34 @@ class Zone extends Component {
140492
140427
  }
140493
140428
  }
140494
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
+
140495
140458
  /**
140496
140459
  * Creates {@link Zone}s in a {@link ZonesPlugin} from mouse input.
140497
140460
  *
@@ -140522,7 +140485,7 @@ class Zone extends Component {
140522
140485
  * const zonesControl = new ZonesMouseControl(Zones)
140523
140486
  * ````
140524
140487
  */
140525
- class ZonesMouseControl extends Component {
140488
+ class ZonesAAZoneControl extends Component {
140526
140489
 
140527
140490
  /**
140528
140491
  * Creates a ZonesMouseControl bound to the given ZonesPlugin.
@@ -140531,11 +140494,12 @@ class ZonesMouseControl extends Component {
140531
140494
  * @param [cfg] Configuration
140532
140495
  * @param {PointerLens} [cfg.pointerLens] A PointerLens to use to provide a magnified view of the cursor when snapping is enabled.
140533
140496
  */
140534
- constructor(zonesPlugin, cfg = {}) {
140497
+ constructor(zonesPlugin, cfg, createSelect3dPoint) {
140535
140498
  super(zonesPlugin.viewer.scene);
140536
140499
 
140537
140500
  this.zonesPlugin = zonesPlugin;
140538
140501
  this.pointerLens = cfg.pointerLens;
140502
+ this.createSelect3dPoint = createSelect3dPoint;
140539
140503
  this._deactivate = null;
140540
140504
  }
140541
140505
 
@@ -140572,16 +140536,35 @@ class ZonesMouseControl extends Component {
140572
140536
  const scene = viewer.scene;
140573
140537
  const self = this;
140574
140538
 
140575
- const select3dPoint = mousePointSelector(
140576
- viewer,
140577
- function(origin, direction) {
140578
- return planeIntersect(zoneAltitude, math.vec3([ 0, 1, 0 ]), origin, direction);
140579
- });
140539
+ const select3dPoint = this.createSelect3dPoint(viewer, (origin, direction) => planeIntersect(zoneAltitude, math.vec3([ 0, 1, 0 ]), origin, direction));
140580
140540
 
140581
140541
  (function rec() {
140582
- self._deactivate = startAAZoneCreateUI(
140583
- scene, zoneAltitude, zoneHeight, zoneColor, zoneAlpha, self.pointerLens, zonesPlugin, select3dPoint,
140584
- 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);
140585
140568
  let reactivate = true;
140586
140569
  self._deactivate = () => { reactivate = false; };
140587
140570
  self.fire("zoneEnd", zone);
@@ -140590,6 +140573,10 @@ class ZonesMouseControl extends Component {
140590
140573
  rec();
140591
140574
  }
140592
140575
  }).deactivate;
140576
+ self._deactivate = () => {
140577
+ deactivate();
140578
+ basePolygon.destroy();
140579
+ };
140593
140580
  })();
140594
140581
  }
140595
140582
 
@@ -140612,6 +140599,30 @@ class ZonesMouseControl extends Component {
140612
140599
  }
140613
140600
  }
140614
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
+
140615
140626
  /**
140616
140627
  * ZonesPlugin documentation to be added, mostly compatible with DistanceMeasurementsPlugin.
140617
140628
  */
@@ -140726,86 +140737,6 @@ class ZonesPlugin extends Plugin {
140726
140737
  }
140727
140738
  }
140728
140739
 
140729
- class ZonesTouchControl extends Component {
140730
-
140731
- constructor(zonesPlugin, cfg = {}) {
140732
- super(zonesPlugin.viewer.scene);
140733
-
140734
- this.zonesPlugin = zonesPlugin;
140735
- this.pointerLens = cfg.pointerLens;
140736
- this.pointerCircle = new PointerCircle(zonesPlugin.viewer);
140737
- this._deactivate = null;
140738
- }
140739
-
140740
- get active() {
140741
- return !! this._deactivate;
140742
- }
140743
-
140744
- activate(zoneAltitude, zoneHeight, zoneColor, zoneAlpha) {
140745
-
140746
- if (typeof(zoneAltitude) === "object" && (zoneAltitude !== null)) {
140747
- const params = zoneAltitude;
140748
- const param = (name, defaultValue) => {
140749
- if (name in params) {
140750
- return params[name];
140751
- } else if (defaultValue !== undefined) {
140752
- return defaultValue;
140753
- } else {
140754
- throw "config missing: " + name;
140755
- }
140756
- };
140757
-
140758
- zoneAltitude = param("altitude");
140759
- zoneHeight = param("height");
140760
- zoneColor = param("color", "#008000");
140761
- zoneAlpha = param("alpha", 0.5);
140762
- }
140763
-
140764
- if (this._deactivate) {
140765
- return;
140766
- }
140767
-
140768
- const zonesPlugin = this.zonesPlugin;
140769
- const viewer = zonesPlugin.viewer;
140770
- const scene = viewer.scene;
140771
- const self = this;
140772
-
140773
- const select3dPoint = touchPointSelector(
140774
- viewer,
140775
- this.pointerCircle,
140776
- function(origin, direction) {
140777
- return planeIntersect(zoneAltitude, math.vec3([ 0, 1, 0 ]), origin, direction);
140778
- });
140779
-
140780
- (function rec() {
140781
- self._deactivate = startAAZoneCreateUI(
140782
- scene, zoneAltitude, zoneHeight, zoneColor, zoneAlpha, self.pointerLens, zonesPlugin, select3dPoint,
140783
- zone => {
140784
- let reactivate = true;
140785
- self._deactivate = () => { reactivate = false; };
140786
- self.fire("zoneEnd", zone);
140787
- if (reactivate)
140788
- {
140789
- rec();
140790
- }
140791
- }).deactivate;
140792
- })();
140793
- }
140794
-
140795
- deactivate() {
140796
- if (this._deactivate)
140797
- {
140798
- this._deactivate();
140799
- this._deactivate = null;
140800
- }
140801
- }
140802
-
140803
- destroy() {
140804
- this.deactivate();
140805
- super.destroy();
140806
- }
140807
- }
140808
-
140809
140740
  const startPolysurfaceZoneCreateUI = function(scene, zoneAltitude, zoneHeight, zoneColor, zoneAlpha, pointerLens, zonesPlugin, select3dPoint, onZoneCreated) {
140810
140741
  const updatePointerLens = (pointerLens
140811
140742
  ? function(canvasPos) {