@xeokit/xeokit-sdk 2.6.40 → 2.6.42

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.
@@ -11349,6 +11349,122 @@ function activateDraggableDots(cfg) {
11349
11349
  };
11350
11350
  }
11351
11351
 
11352
+ const touchPointSelector$1 = function(viewer, pointerCircle, ray2WorldPos) {
11353
+ return function(onCancel, onChange, onCommit) {
11354
+ const scene = viewer.scene;
11355
+ const canvas = scene.canvas.canvas;
11356
+ const longTouchTimeoutMs = 300;
11357
+ const moveTolerance = 20;
11358
+
11359
+ const copyCanvasPos = (event, vec2) => {
11360
+ vec2[0] = event.clientX;
11361
+ vec2[1] = event.clientY;
11362
+ transformToNode(canvas.ownerDocument.documentElement, canvas, vec2);
11363
+ return vec2;
11364
+ };
11365
+
11366
+ const pickWorldPos = canvasPos => {
11367
+ const origin = math.vec3();
11368
+ const direction = math.vec3();
11369
+ math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, scene.camera.projection, canvasPos, origin, direction);
11370
+ return ray2WorldPos(origin, direction);
11371
+ };
11372
+
11373
+ let longTouchTimeout = null;
11374
+ const nop = () => { };
11375
+ let onSingleTouchMove = nop;
11376
+ let startTouchIdentifier;
11377
+
11378
+ const resetAction = function() {
11379
+ pointerCircle.stop();
11380
+ clearTimeout(longTouchTimeout);
11381
+ viewer.cameraControl.active = true;
11382
+ onSingleTouchMove = nop;
11383
+ startTouchIdentifier = null;
11384
+ };
11385
+
11386
+ const cleanup = function() {
11387
+ resetAction();
11388
+ canvas.removeEventListener("touchstart", onCanvasTouchStart);
11389
+ canvas.removeEventListener("touchmove", onCanvasTouchMove);
11390
+ canvas.removeEventListener("touchend", onCanvasTouchEnd);
11391
+ };
11392
+
11393
+ const onCanvasTouchStart = function(event) {
11394
+ const touches = event.touches;
11395
+
11396
+ if (touches.length !== 1)
11397
+ {
11398
+ resetAction();
11399
+ onCancel();
11400
+ }
11401
+ else
11402
+ {
11403
+ const startTouch = touches[0];
11404
+ const startCanvasPos = copyCanvasPos(startTouch, math.vec2());
11405
+
11406
+ const startWorldPos = pickWorldPos(startCanvasPos);
11407
+ if (startWorldPos)
11408
+ {
11409
+ startTouchIdentifier = startTouch.identifier;
11410
+
11411
+ onSingleTouchMove = canvasPos => {
11412
+ if (math.distVec2(startCanvasPos, canvasPos) > moveTolerance)
11413
+ {
11414
+ resetAction();
11415
+ }
11416
+ };
11417
+
11418
+ longTouchTimeout = setTimeout(
11419
+ function() {
11420
+ pointerCircle.start(startCanvasPos);
11421
+
11422
+ longTouchTimeout = setTimeout(
11423
+ function() {
11424
+ pointerCircle.stop();
11425
+
11426
+ viewer.cameraControl.active = false;
11427
+
11428
+ onSingleTouchMove = canvasPos => {
11429
+ onChange(canvasPos, pickWorldPos(canvasPos));
11430
+ };
11431
+
11432
+ onSingleTouchMove(startCanvasPos);
11433
+ },
11434
+ longTouchTimeoutMs);
11435
+ },
11436
+ 250);
11437
+ }
11438
+ }
11439
+ };
11440
+ canvas.addEventListener("touchstart", onCanvasTouchStart, {passive: true});
11441
+
11442
+ // canvas.addEventListener("touchcancel", e => console.log("touchcancel", e), {passive: true});
11443
+
11444
+ const onCanvasTouchMove = function(event) {
11445
+ const touch = [...event.changedTouches].find(e => e.identifier === startTouchIdentifier);
11446
+ if (touch)
11447
+ {
11448
+ onSingleTouchMove(copyCanvasPos(touch, math.vec2()));
11449
+ }
11450
+ };
11451
+ canvas.addEventListener("touchmove", onCanvasTouchMove, {passive: true});
11452
+
11453
+ const onCanvasTouchEnd = function(event) {
11454
+ const touch = [...event.changedTouches].find(e => e.identifier === startTouchIdentifier);
11455
+ if (touch)
11456
+ {
11457
+ cleanup();
11458
+ const canvasPos = copyCanvasPos(touch, math.vec2());
11459
+ onCommit(canvasPos, pickWorldPos(canvasPos));
11460
+ }
11461
+ };
11462
+ canvas.addEventListener("touchend", onCanvasTouchEnd, {passive: true});
11463
+
11464
+ return cleanup;
11465
+ };
11466
+ };
11467
+
11352
11468
  /** @private */
11353
11469
  class Wire {
11354
11470
 
@@ -56014,9 +56130,9 @@ const configs$2 = new Configs();
56014
56130
  */
56015
56131
  class VBOBatchingTrianglesBuffer {
56016
56132
 
56017
- constructor() {
56018
- this.maxVerts = configs$2.maxGeometryBatchSize;
56019
- this.maxIndices = configs$2.maxGeometryBatchSize * 3; // Rough rule-of-thumb
56133
+ constructor(maxBatchSize = configs$2.maxGeometryBatchSize) {
56134
+ this.maxVerts = maxBatchSize;
56135
+ this.maxIndices = maxBatchSize * 3; // Rough rule-of-thumb
56020
56136
  this.positions = [];
56021
56137
  this.colors = [];
56022
56138
  this.uv = [];
@@ -67520,27 +67636,6 @@ function getRenderers$3(scene) {
67520
67636
  return renderers;
67521
67637
  }
67522
67638
 
67523
- /**
67524
- * @private
67525
- */
67526
- class VBOBatchingPointsBuffer {
67527
-
67528
- constructor(maxGeometryBatchSize = 5000000) {
67529
-
67530
- if (maxGeometryBatchSize > 5000000) {
67531
- maxGeometryBatchSize = 5000000;
67532
- }
67533
-
67534
- this.maxVerts = maxGeometryBatchSize;
67535
- this.maxIndices = maxGeometryBatchSize * 3; // Rough rule-of-thumb
67536
- this.positions = [];
67537
- this.colors = [];
67538
- this.intensities = [];
67539
- this.pickColors = [];
67540
- this.offsets = [];
67541
- }
67542
- }
67543
-
67544
67639
  /**
67545
67640
  * @private
67546
67641
  */
@@ -67579,7 +67674,58 @@ class VBOBatchingPointsLayer {
67579
67674
 
67580
67675
  this._renderers = getRenderers$3(cfg.model.scene);
67581
67676
 
67582
- this._buffer = new VBOBatchingPointsBuffer(cfg.maxGeometryBatchSize);
67677
+ const maxGeometryBatchSize = Math.min(5000000, cfg.maxGeometryBatchSize || window.Infinity);
67678
+
67679
+ const attribute = function() {
67680
+ const portions = [ ];
67681
+
67682
+ return {
67683
+ append: function(data, times = 1, denormalizeScale = 1.0) {
67684
+ portions.push({ data: data, times: times, denormalizeScale: denormalizeScale });
67685
+ },
67686
+ compileBuffer: function(type) {
67687
+ let len = 0;
67688
+ portions.forEach(p => { len += p.times * p.data.length; });
67689
+ const buf = new type(len);
67690
+
67691
+ let begin = 0;
67692
+ portions.forEach(p => {
67693
+ const data = p.data;
67694
+ const dScale = p.denormalizeScale;
67695
+ const subBuf = buf.subarray(begin);
67696
+
67697
+ if (dScale === 1.0) {
67698
+ subBuf.set(data, 0);
67699
+ } else {
67700
+ for (let i = 0; i < data.length; ++i) {
67701
+ subBuf[i] = data[i] * dScale;
67702
+ }
67703
+ }
67704
+
67705
+ let soFar = data.length;
67706
+ const allDataLen = p.times * data.length;
67707
+ while (soFar < allDataLen) {
67708
+ const toCopy = Math.min(soFar, allDataLen - soFar);
67709
+ subBuf.set(subBuf.subarray(0, toCopy), soFar);
67710
+ soFar += toCopy;
67711
+ }
67712
+
67713
+ begin += soFar;
67714
+ });
67715
+
67716
+ return buf;
67717
+ }
67718
+ };
67719
+ };
67720
+
67721
+ this._buffer = {
67722
+ maxVerts: maxGeometryBatchSize,
67723
+ positions: attribute(),
67724
+ colors: attribute(),
67725
+ pickColors: attribute(),
67726
+ vertsIndex: 0
67727
+ };
67728
+
67583
67729
  this._scratchMemory = cfg.scratchMemory;
67584
67730
 
67585
67731
  this._state = new RenderState({
@@ -67644,7 +67790,7 @@ class VBOBatchingPointsLayer {
67644
67790
  if (this._finalized) {
67645
67791
  throw "Already finalized";
67646
67792
  }
67647
- return ((this._buffer.positions.length + lenPositions) < (this._buffer.maxVerts * 3));
67793
+ return (this._buffer.vertsIndex + (lenPositions / 3)) < this._buffer.maxVerts;
67648
67794
  }
67649
67795
 
67650
67796
  /**
@@ -67669,97 +67815,40 @@ class VBOBatchingPointsLayer {
67669
67815
  throw "Already finalized";
67670
67816
  }
67671
67817
 
67672
- const positions = cfg.positions;
67673
- const positionsCompressed = cfg.positionsCompressed;
67674
- const color = cfg.color;
67675
- const colorsCompressed = cfg.colorsCompressed;
67676
- const colors = cfg.colors;
67677
- const pickColor = cfg.pickColor;
67678
-
67679
67818
  const buffer = this._buffer;
67680
- const positionsIndex = buffer.positions.length;
67681
- const vertsIndex = positionsIndex / 3;
67682
67819
 
67683
- let numVerts;
67684
-
67685
- math.expandAABB3(this._modelAABB, cfg.aabb);
67686
-
67687
- if (this._preCompressedPositionsExpected) {
67688
-
67689
- if (!positionsCompressed) {
67690
- throw "positionsCompressed expected";
67691
- }
67692
-
67693
- for (let i = 0, len = positionsCompressed.length; i < len; i++) {
67694
- buffer.positions.push(positionsCompressed[i]);
67695
- }
67696
-
67697
- numVerts = positionsCompressed.length / 3;
67698
-
67699
- } else {
67700
-
67701
- if (!positions) {
67702
- throw "positions expected";
67703
- }
67820
+ const positions = this._preCompressedPositionsExpected ? cfg.positionsCompressed : cfg.positions;
67821
+ if (! positions) {
67822
+ throw ((this._preCompressedPositionsExpected ? "positionsCompressed" : "positions") + " expected");
67823
+ }
67704
67824
 
67705
- numVerts = positions.length / 3;
67825
+ buffer.positions.append(positions);
67706
67826
 
67707
- positions.length;
67708
- buffer.positions.length;
67827
+ const numVerts = positions.length / 3;
67709
67828
 
67710
- for (let i = 0, len = positions.length; i < len; i++) {
67711
- buffer.positions.push(positions[i]);
67712
- }
67713
- }
67829
+ const color = cfg.color;
67830
+ const colorsCompressed = cfg.colorsCompressed;
67831
+ const colors = cfg.colors;
67832
+ const pickColor = cfg.pickColor;
67714
67833
 
67715
67834
  if (colorsCompressed) {
67716
- for (let i = 0, len = colorsCompressed.length; i < len; i++) {
67717
- buffer.colors.push(colorsCompressed[i]);
67718
- }
67719
-
67835
+ buffer.colors.append(colorsCompressed);
67720
67836
  } else if (colors) {
67721
- for (let i = 0, len = colors.length; i < len; i++) {
67722
- buffer.colors.push(colors[i] * 255);
67723
- }
67724
-
67837
+ buffer.colors.append(colors, 1, 255.0);
67725
67838
  } else if (color) {
67726
-
67727
- const r = color[0]; // Color is pre-quantized by VBOSceneModel
67728
- const g = color[1];
67729
- const b = color[2];
67730
- const a = 1.0;
67731
-
67732
- for (let i = 0; i < numVerts; i++) {
67733
- buffer.colors.push(r);
67734
- buffer.colors.push(g);
67735
- buffer.colors.push(b);
67736
- buffer.colors.push(a);
67737
- }
67839
+ // Color is pre-quantized by VBOSceneModel
67840
+ buffer.colors.append([ color[0], color[1], color[2], 1.0 ], numVerts);
67738
67841
  }
67739
67842
 
67740
- {
67741
- const pickColorsBase = buffer.pickColors.length;
67742
- const lenPickColors = numVerts * 4;
67743
- for (let i = pickColorsBase, len = pickColorsBase + lenPickColors; i < len; i += 4) {
67744
- buffer.pickColors.push(pickColor[0]);
67745
- buffer.pickColors.push(pickColor[1]);
67746
- buffer.pickColors.push(pickColor[2]);
67747
- buffer.pickColors.push(pickColor[3]);
67748
- }
67749
- }
67843
+ buffer.pickColors.append(pickColor.slice(0, 4), numVerts);
67750
67844
 
67751
- if (this.model.scene.entityOffsetsEnabled) {
67752
- for (let i = 0; i < numVerts; i++) {
67753
- buffer.offsets.push(0);
67754
- buffer.offsets.push(0);
67755
- buffer.offsets.push(0);
67756
- }
67757
- }
67845
+ math.expandAABB3(this._modelAABB, cfg.aabb);
67758
67846
 
67759
67847
  const portionId = this._portions.length / 2;
67760
67848
 
67761
- this._portions.push(vertsIndex);
67849
+ this._portions.push(this._buffer.vertsIndex);
67762
67850
  this._portions.push(numVerts);
67851
+ this._buffer.vertsIndex += numVerts;
67763
67852
 
67764
67853
  this._numPortions++;
67765
67854
  this.model.numPortions++;
@@ -67780,43 +67869,20 @@ class VBOBatchingPointsLayer {
67780
67869
  const state = this._state;
67781
67870
  const gl = this.model.scene.canvas.gl;
67782
67871
  const buffer = this._buffer;
67872
+ const maybeCreateGlBuffer = (srcData, size, usage) => (srcData.length > 0) ? new ArrayBuf(gl, gl.ARRAY_BUFFER, srcData, srcData.length, size, usage) : null;
67783
67873
 
67784
- if (buffer.positions.length > 0) {
67785
- if (this._preCompressedPositionsExpected) {
67786
- const positions = new Uint16Array(buffer.positions);
67787
- state.positionsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, positions, buffer.positions.length, 3, gl.STATIC_DRAW);
67788
- } else {
67789
- const positions = new Float32Array(buffer.positions);
67790
- const quantizedPositions = quantizePositions(positions, this._modelAABB, state.positionsDecodeMatrix);
67791
- state.positionsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, quantizedPositions, buffer.positions.length, 3, gl.STATIC_DRAW);
67792
- }
67793
- }
67874
+ const positions = (this._preCompressedPositionsExpected
67875
+ ? buffer.positions.compileBuffer(Uint16Array)
67876
+ : (quantizePositions(buffer.positions.compileBuffer(Float32Array), this._modelAABB, state.positionsDecodeMatrix)));
67877
+ state.positionsBuf = maybeCreateGlBuffer(positions, 3, gl.STATIC_DRAW);
67794
67878
 
67795
- if (buffer.colors.length > 0) {
67796
- const colors = new Uint8Array(buffer.colors);
67797
- let normalized = false;
67798
- state.colorsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, colors, buffer.colors.length, 4, gl.STATIC_DRAW, normalized);
67799
- }
67879
+ state.flagsBuf = maybeCreateGlBuffer(new Float32Array(this._buffer.vertsIndex), 1, gl.DYNAMIC_DRAW); // Because we build flags arrays here, get their length from the positions array
67800
67880
 
67801
- if (buffer.positions.length > 0) { // Because we build flags arrays here, get their length from the positions array
67802
- const flagsLength = buffer.positions.length / 3;
67803
- const flags = new Float32Array(flagsLength);
67804
- let notNormalized = false;
67805
- state.flagsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, flags, flags.length, 1, gl.DYNAMIC_DRAW, notNormalized);
67806
- }
67881
+ state.colorsBuf = maybeCreateGlBuffer(buffer.colors.compileBuffer(Uint8Array), 4, gl.STATIC_DRAW);
67807
67882
 
67808
- if (buffer.pickColors.length > 0) {
67809
- const pickColors = new Uint8Array(buffer.pickColors);
67810
- let normalized = false;
67811
- state.pickColorsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, pickColors, buffer.pickColors.length, 4, gl.STATIC_DRAW, normalized);
67812
- }
67883
+ state.pickColorsBuf = maybeCreateGlBuffer(buffer.pickColors.compileBuffer(Uint8Array), 4, gl.STATIC_DRAW);
67813
67884
 
67814
- if (this.model.scene.entityOffsetsEnabled) {
67815
- if (buffer.offsets.length > 0) {
67816
- const offsets = new Float32Array(buffer.offsets);
67817
- state.offsetsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, offsets, buffer.offsets.length, 3, gl.DYNAMIC_DRAW);
67818
- }
67819
- }
67885
+ state.offsetsBuf = this.model.scene.entityOffsetsEnabled ? maybeCreateGlBuffer(new Float32Array(this._buffer.vertsIndex * 3), 3, gl.DYNAMIC_DRAW) : null;
67820
67886
 
67821
67887
  this._buffer = null;
67822
67888
  this._finalized = true;
@@ -85116,7 +85182,21 @@ class SceneModel extends Component {
85116
85182
  if (cfg.image) { // Ignore transcoder for Images
85117
85183
  const image = cfg.image;
85118
85184
  image.crossOrigin = "Anonymous";
85119
- texture.setImage(image, {minFilter, magFilter, wrapS, wrapT, wrapR, flipY: cfg.flipY, encoding});
85185
+ if (image.compressed) {
85186
+ // see `parsedImage` in @loaders.gl/gltf/src/lib/parsers/parse-gltf.ts
85187
+ // NOTE: @loaders.gl in its current version discards potential mipmaps, leaving only a single one
85188
+ const data = image.data;
85189
+ texture.setCompressedData({
85190
+ mipmaps: data,
85191
+ props: {
85192
+ format: data[0].format,
85193
+ minFilter: minFilter,
85194
+ magFilter: magFilter
85195
+ }
85196
+ });
85197
+ } else {
85198
+ texture.setImage(image, {minFilter, magFilter, wrapS, wrapT, wrapR, flipY: cfg.flipY, encoding});
85199
+ }
85120
85200
  } else if (cfg.src) {
85121
85201
  const ext = cfg.src.split('.').pop();
85122
85202
  switch (ext) { // Don't transcode recognized image file types
@@ -88040,6 +88120,7 @@ class DistanceMeasurement extends Component {
88040
88120
  this._visible = false;
88041
88121
  this._originVisible = false;
88042
88122
  this._targetVisible = false;
88123
+ this._useRotationAdjustment = false;
88043
88124
  this._wireVisible = false;
88044
88125
  this._axisVisible = false;
88045
88126
  this._xAxisVisible = false;
@@ -88116,7 +88197,7 @@ class DistanceMeasurement extends Component {
88116
88197
  this.lengthLabelEnabled = cfg.lengthLabelEnabled;
88117
88198
  this.labelsVisible = cfg.labelsVisible;
88118
88199
  this.labelsOnWires = cfg.labelsOnWires;
88119
- this.useRotationAdjustment = cfg.useRotationAdjustment;
88200
+ this._useRotationAdjustment = cfg.useRotationAdjustment;
88120
88201
 
88121
88202
  /**
88122
88203
  * @type {number[]}
@@ -88178,7 +88259,7 @@ class DistanceMeasurement extends Component {
88178
88259
  this._factors = math.transformVec3(this._axesBasis, delta);
88179
88260
 
88180
88261
  this._measurementOrientation = determineMeasurementOrientation(this._originWorld, this._targetWorld, 0);
88181
- if(this._measurementOrientation === 'Vertical' && this.useRotationAdjustment){
88262
+ if (this._measurementOrientation === 'Vertical' && this._useRotationAdjustment) {
88182
88263
  this._wp[0] = this._originWorld[0];
88183
88264
  this._wp[1] = this._originWorld[1];
88184
88265
  this._wp[2] = this._originWorld[2];
@@ -88388,7 +88469,7 @@ class DistanceMeasurement extends Component {
88388
88469
  }
88389
88470
 
88390
88471
  if (!this._zAxisLabelCulled) {
88391
- if(this._measurementOrientation === 'Vertical' && this.useRotationAdjustment) {
88472
+ if (this._measurementOrientation === 'Vertical' && this._useRotationAdjustment) {
88392
88473
  this._zAxisLabel.setPrefix("");
88393
88474
  this._zAxisLabel.setText(tilde + Math.abs(math.lenVec3(math.subVec3(this._targetWorld, [this._originWorld[0], this._targetWorld[1], this._originWorld[2]], distVec3)) * scale).toFixed(2) + unitAbbrev);
88394
88475
  }
@@ -88583,6 +88664,25 @@ class DistanceMeasurement extends Component {
88583
88664
  return this._targetVisible;
88584
88665
  }
88585
88666
 
88667
+ /**
88668
+ * Sets if the measurement is adjusted based on rotation
88669
+ *
88670
+ * @type {Boolean}
88671
+ */
88672
+ set useRotationAdjustment(value) {
88673
+ value = value !== undefined ? Boolean(value) : this.plugin.useRotationAdjustment;
88674
+ this._useRotationAdjustment = value;
88675
+ }
88676
+
88677
+ /**
88678
+ * Gets if the measurement is adjusted based on rotation
88679
+ *
88680
+ * @type {Boolean}
88681
+ */
88682
+ get useRotationAdjustment() {
88683
+ return this._useRotationAdjustment;
88684
+ }
88685
+
88586
88686
  /**
88587
88687
  * Sets if the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are enabled.
88588
88688
  *
@@ -123617,7 +123717,13 @@ class StoreyViewsPlugin extends Plugin {
123617
123717
  return null;
123618
123718
  }
123619
123719
 
123620
- isPositionAboveOrBelowBuilding(worldPos){
123720
+ /**
123721
+ * Returns whether a position is above or below a building
123722
+ *
123723
+ * @param {Number[]} worldPos 3D World-space position.
123724
+ * @returns {String} ID of the lowest/highest story or null.
123725
+ */
123726
+ isPositionAboveOrBelowBuilding(worldPos) {
123621
123727
  const keys = Object.keys(this.storeys);
123622
123728
  const ids = [keys[0], keys[keys.length-1]];
123623
123729
  if(worldPos[1] < this.storeys[ids[0]].storeyAABB[1])
@@ -126769,6 +126875,8 @@ class TreeViewPlugin extends Plugin {
126769
126875
  return; // Node may not exist for the given object if (this._pruneEmptyNodes == true)
126770
126876
  }
126771
126877
 
126878
+ this.collapse();
126879
+
126772
126880
  const nodeId = node.nodeId;
126773
126881
 
126774
126882
  const switchElement = this._renderService.getSwitchElement(nodeId);
@@ -140501,122 +140609,6 @@ const mousePointSelector = function(viewer, ray2WorldPos) {
140501
140609
  };
140502
140610
  };
140503
140611
 
140504
- const touchPointSelector = function(viewer, pointerCircle, ray2WorldPos) {
140505
- return function(onCancel, onChange, onCommit) {
140506
- const scene = viewer.scene;
140507
- const canvas = scene.canvas.canvas;
140508
- const longTouchTimeoutMs = 300;
140509
- const moveTolerance = 20;
140510
-
140511
- const copyCanvasPos = (event, vec2) => {
140512
- vec2[0] = event.clientX;
140513
- vec2[1] = event.clientY;
140514
- transformToNode(canvas.ownerDocument.documentElement, canvas, vec2);
140515
- return vec2;
140516
- };
140517
-
140518
- const pickWorldPos = canvasPos => {
140519
- const origin = math.vec3();
140520
- const direction = math.vec3();
140521
- math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, scene.camera.projection, canvasPos, origin, direction);
140522
- return ray2WorldPos(origin, direction);
140523
- };
140524
-
140525
- let longTouchTimeout = null;
140526
- const nop = () => { };
140527
- let onSingleTouchMove = nop;
140528
- let startTouchIdentifier;
140529
-
140530
- const resetAction = function() {
140531
- pointerCircle.stop();
140532
- clearTimeout(longTouchTimeout);
140533
- viewer.cameraControl.active = true;
140534
- onSingleTouchMove = nop;
140535
- startTouchIdentifier = null;
140536
- };
140537
-
140538
- const cleanup = function() {
140539
- resetAction();
140540
- canvas.removeEventListener("touchstart", onCanvasTouchStart);
140541
- canvas.removeEventListener("touchmove", onCanvasTouchMove);
140542
- canvas.removeEventListener("touchend", onCanvasTouchEnd);
140543
- };
140544
-
140545
- const onCanvasTouchStart = function(event) {
140546
- const touches = event.touches;
140547
-
140548
- if (touches.length !== 1)
140549
- {
140550
- resetAction();
140551
- onCancel();
140552
- }
140553
- else
140554
- {
140555
- const startTouch = touches[0];
140556
- const startCanvasPos = copyCanvasPos(startTouch, math.vec2());
140557
-
140558
- const startWorldPos = pickWorldPos(startCanvasPos);
140559
- if (startWorldPos)
140560
- {
140561
- startTouchIdentifier = startTouch.identifier;
140562
-
140563
- onSingleTouchMove = canvasPos => {
140564
- if (math.distVec2(startCanvasPos, canvasPos) > moveTolerance)
140565
- {
140566
- resetAction();
140567
- }
140568
- };
140569
-
140570
- longTouchTimeout = setTimeout(
140571
- function() {
140572
- pointerCircle.start(startCanvasPos);
140573
-
140574
- longTouchTimeout = setTimeout(
140575
- function() {
140576
- pointerCircle.stop();
140577
-
140578
- viewer.cameraControl.active = false;
140579
-
140580
- onSingleTouchMove = canvasPos => {
140581
- onChange(canvasPos, pickWorldPos(canvasPos));
140582
- };
140583
-
140584
- onSingleTouchMove(startCanvasPos);
140585
- },
140586
- longTouchTimeoutMs);
140587
- },
140588
- 250);
140589
- }
140590
- }
140591
- };
140592
- canvas.addEventListener("touchstart", onCanvasTouchStart, {passive: true});
140593
-
140594
- // canvas.addEventListener("touchcancel", e => console.log("touchcancel", e), {passive: true});
140595
-
140596
- const onCanvasTouchMove = function(event) {
140597
- const touch = [...event.changedTouches].find(e => e.identifier === startTouchIdentifier);
140598
- if (touch)
140599
- {
140600
- onSingleTouchMove(copyCanvasPos(touch, math.vec2()));
140601
- }
140602
- };
140603
- canvas.addEventListener("touchmove", onCanvasTouchMove, {passive: true});
140604
-
140605
- const onCanvasTouchEnd = function(event) {
140606
- const touch = [...event.changedTouches].find(e => e.identifier === startTouchIdentifier);
140607
- if (touch)
140608
- {
140609
- cleanup();
140610
- const canvasPos = copyCanvasPos(touch, math.vec2());
140611
- onCommit(canvasPos, pickWorldPos(canvasPos));
140612
- }
140613
- };
140614
- canvas.addEventListener("touchend", onCanvasTouchEnd, {passive: true});
140615
-
140616
- return cleanup;
140617
- };
140618
- };
140619
-
140620
140612
  const planeIntersect = function(p0, n, origin, direction) {
140621
140613
  const t = - (math.dotVec3(origin, n) - p0) / math.dotVec3(direction, n);
140622
140614
  {
@@ -141957,4 +141949,4 @@ class ZoneTranslateTouchControl extends ZoneTranslateControl {
141957
141949
  }
141958
141950
  }
141959
141951
 
141960
- export { AlphaFormat, AmbientLight, AngleMeasurementEditMouseControl, AngleMeasurementEditTouchControl, AngleMeasurementsControl, AngleMeasurementsMouseControl, AngleMeasurementsPlugin, AngleMeasurementsTouchControl, AnnotationsPlugin, AxisGizmoPlugin, BCFViewpointsPlugin, Bitmap, ByteType, CameraMemento, CameraPath, CameraPathAnimation, CityJSONLoaderPlugin, ClampToEdgeWrapping, Component, CompressedMediaType, Configs, ContextMenu, CubicBezierCurve, Curve, DefaultLoadingManager, DepthFormat, DepthStencilFormat, DirLight, DistanceMeasurementEditControl, DistanceMeasurementEditMouseControl, DistanceMeasurementEditTouchControl, DistanceMeasurementsControl, DistanceMeasurementsMouseControl, DistanceMeasurementsPlugin, DistanceMeasurementsTouchControl, DotBIMDefaultDataSource, DotBIMLoaderPlugin, EdgeMaterial, EmphasisMaterial, FaceAlignedSectionPlanesPlugin, FastNavPlugin, FloatType, Fresnel, Frustum$1 as Frustum, FrustumPlane, GIFMediaType, GLTFDefaultDataSource, GLTFLoaderPlugin, HalfFloatType, ImagePlane, IntType, JPEGMediaType, KTX2TextureTranscoder, LASLoaderPlugin, LambertMaterial, LightMap, LineSet, LinearEncoding, LinearFilter, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, Loader, LoadingManager, LocaleService, LuminanceAlphaFormat, LuminanceFormat, Map$1 as Map, Marker, MarqueePicker, MarqueePickerMouseControl, Mesh, MeshSurfaceArea, MeshVolume, MetallicMaterial, MirroredRepeatWrapping, ModelMemento, NavCubePlugin, NearestFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, Node$2 as Node, OBJLoaderPlugin, ObjectsKdTree3, ObjectsMemento, PNGMediaType, Path, PerformanceModel, PhongMaterial, PickResult, Plugin, PointLight, PointerCircle, PointerLens, QuadraticBezierCurve, Queue, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGBFormat, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGFormat, RGIntegerFormat, ReadableGeometry, RedFormat, RedIntegerFormat, ReflectionMap, RepeatWrapping, STLDefaultDataSource, STLLoaderPlugin, SceneModel, SceneModelMesh, SceneModelTransform, SectionPlane, SectionPlanesPlugin, ShortType, Skybox, SkyboxesPlugin, SpecularMaterial, SplineCurve, SpriteMarker, StoreyViewsPlugin, Texture, TextureTranscoder, TreeViewPlugin, UnsignedByteType, UnsignedInt248Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShortType, VBOGeometry, ViewCullPlugin, Viewer, WebIFCLoaderPlugin, WorkerPool$1 as WorkerPool, XKTDefaultDataSource, XKTLoaderPlugin, XML3DLoaderPlugin, ZoneEditControl, ZoneEditMouseControl, ZoneEditTouchControl, ZoneTranslateControl, ZoneTranslateMouseControl, ZoneTranslateTouchControl, ZonesMouseControl, ZonesPlugin, ZonesPolysurfaceMouseControl, ZonesPolysurfaceTouchControl, ZonesTouchControl, buildBoxGeometry, buildBoxLinesGeometry, buildBoxLinesGeometryFromAABB, buildCylinderGeometry, buildGridGeometry, buildLineGeometry, buildPlaneGeometry, buildPolylineGeometry, buildPolylineGeometryFromCurve, buildSphereGeometry, buildTorusGeometry, buildVectorTextGeometry, createRTCViewMat, frustumIntersectsAABB3, getKTX2TextureTranscoder, getPlaneRTCPos, isTriangleMeshSolid, load3DSGeometry, loadOBJGeometry, math, meshSurfaceArea, meshVolume, rtcToWorldPos, sRGBEncoding, setFrustum, stats, utils, worldToRTCPos, worldToRTCPositions };
141952
+ export { AlphaFormat, AmbientLight, AngleMeasurementEditMouseControl, AngleMeasurementEditTouchControl, AngleMeasurementsControl, AngleMeasurementsMouseControl, AngleMeasurementsPlugin, AngleMeasurementsTouchControl, AnnotationsPlugin, AxisGizmoPlugin, BCFViewpointsPlugin, Bitmap, ByteType, CameraMemento, CameraPath, CameraPathAnimation, CityJSONLoaderPlugin, ClampToEdgeWrapping, Component, CompressedMediaType, Configs, ContextMenu, CubicBezierCurve, Curve, DefaultLoadingManager, DepthFormat, DepthStencilFormat, DirLight, DistanceMeasurementEditControl, DistanceMeasurementEditMouseControl, DistanceMeasurementEditTouchControl, DistanceMeasurementsControl, DistanceMeasurementsMouseControl, DistanceMeasurementsPlugin, DistanceMeasurementsTouchControl, Dot3D, DotBIMDefaultDataSource, DotBIMLoaderPlugin, EdgeMaterial, EmphasisMaterial, FaceAlignedSectionPlanesPlugin, FastNavPlugin, FloatType, Fresnel, Frustum$1 as Frustum, FrustumPlane, GIFMediaType, GLTFDefaultDataSource, GLTFLoaderPlugin, HalfFloatType, ImagePlane, IntType, JPEGMediaType, KTX2TextureTranscoder, LASLoaderPlugin, LambertMaterial, LightMap, LineSet, LinearEncoding, LinearFilter, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, Loader, LoadingManager, LocaleService, LuminanceAlphaFormat, LuminanceFormat, Map$1 as Map, Marker, MarqueePicker, MarqueePickerMouseControl, Mesh, MeshSurfaceArea, MeshVolume, MetallicMaterial, MirroredRepeatWrapping, ModelMemento, NavCubePlugin, NearestFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, Node$2 as Node, OBJLoaderPlugin, ObjectsKdTree3, ObjectsMemento, PNGMediaType, Path, PerformanceModel, PhongMaterial, PickResult, Plugin, PointLight, PointerCircle, PointerLens, QuadraticBezierCurve, Queue, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGBFormat, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGFormat, RGIntegerFormat, ReadableGeometry, RedFormat, RedIntegerFormat, ReflectionMap, RepeatWrapping, STLDefaultDataSource, STLLoaderPlugin, SceneModel, SceneModelMesh, SceneModelTransform, SectionPlane, SectionPlanesPlugin, ShortType, Skybox, SkyboxesPlugin, SpecularMaterial, SplineCurve, SpriteMarker, StoreyViewsPlugin, Texture, TextureTranscoder, TreeViewPlugin, UnsignedByteType, UnsignedInt248Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShortType, VBOGeometry, ViewCullPlugin, Viewer, WebIFCLoaderPlugin, WorkerPool$1 as WorkerPool, XKTDefaultDataSource, XKTLoaderPlugin, XML3DLoaderPlugin, ZoneEditControl, ZoneEditMouseControl, ZoneEditTouchControl, ZoneTranslateControl, ZoneTranslateMouseControl, ZoneTranslateTouchControl, ZonesMouseControl, ZonesPlugin, ZonesPolysurfaceMouseControl, ZonesPolysurfaceTouchControl, ZonesTouchControl, activateDraggableDot, activateDraggableDots, buildBoxGeometry, buildBoxLinesGeometry, buildBoxLinesGeometryFromAABB, buildCylinderGeometry, buildGridGeometry, buildLineGeometry, buildPlaneGeometry, buildPolylineGeometry, buildPolylineGeometryFromCurve, buildSphereGeometry, buildTorusGeometry, buildVectorTextGeometry, createRTCViewMat, frustumIntersectsAABB3, getKTX2TextureTranscoder, getPlaneRTCPos, isTriangleMeshSolid, load3DSGeometry, loadOBJGeometry, math, meshSurfaceArea, meshVolume, rtcToWorldPos, sRGBEncoding, setFrustum, stats, touchPointSelector$1 as touchPointSelector, transformToNode, utils, worldToRTCPos, worldToRTCPositions };