@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.
Binary file
@@ -11353,6 +11353,122 @@ function activateDraggableDots(cfg) {
11353
11353
  };
11354
11354
  }
11355
11355
 
11356
+ const touchPointSelector$1 = function(viewer, pointerCircle, ray2WorldPos) {
11357
+ return function(onCancel, onChange, onCommit) {
11358
+ const scene = viewer.scene;
11359
+ const canvas = scene.canvas.canvas;
11360
+ const longTouchTimeoutMs = 300;
11361
+ const moveTolerance = 20;
11362
+
11363
+ const copyCanvasPos = (event, vec2) => {
11364
+ vec2[0] = event.clientX;
11365
+ vec2[1] = event.clientY;
11366
+ transformToNode(canvas.ownerDocument.documentElement, canvas, vec2);
11367
+ return vec2;
11368
+ };
11369
+
11370
+ const pickWorldPos = canvasPos => {
11371
+ const origin = math.vec3();
11372
+ const direction = math.vec3();
11373
+ math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, scene.camera.projection, canvasPos, origin, direction);
11374
+ return ray2WorldPos(origin, direction);
11375
+ };
11376
+
11377
+ let longTouchTimeout = null;
11378
+ const nop = () => { };
11379
+ let onSingleTouchMove = nop;
11380
+ let startTouchIdentifier;
11381
+
11382
+ const resetAction = function() {
11383
+ pointerCircle.stop();
11384
+ clearTimeout(longTouchTimeout);
11385
+ viewer.cameraControl.active = true;
11386
+ onSingleTouchMove = nop;
11387
+ startTouchIdentifier = null;
11388
+ };
11389
+
11390
+ const cleanup = function() {
11391
+ resetAction();
11392
+ canvas.removeEventListener("touchstart", onCanvasTouchStart);
11393
+ canvas.removeEventListener("touchmove", onCanvasTouchMove);
11394
+ canvas.removeEventListener("touchend", onCanvasTouchEnd);
11395
+ };
11396
+
11397
+ const onCanvasTouchStart = function(event) {
11398
+ const touches = event.touches;
11399
+
11400
+ if (touches.length !== 1)
11401
+ {
11402
+ resetAction();
11403
+ onCancel();
11404
+ }
11405
+ else
11406
+ {
11407
+ const startTouch = touches[0];
11408
+ const startCanvasPos = copyCanvasPos(startTouch, math.vec2());
11409
+
11410
+ const startWorldPos = pickWorldPos(startCanvasPos);
11411
+ if (startWorldPos)
11412
+ {
11413
+ startTouchIdentifier = startTouch.identifier;
11414
+
11415
+ onSingleTouchMove = canvasPos => {
11416
+ if (math.distVec2(startCanvasPos, canvasPos) > moveTolerance)
11417
+ {
11418
+ resetAction();
11419
+ }
11420
+ };
11421
+
11422
+ longTouchTimeout = setTimeout(
11423
+ function() {
11424
+ pointerCircle.start(startCanvasPos);
11425
+
11426
+ longTouchTimeout = setTimeout(
11427
+ function() {
11428
+ pointerCircle.stop();
11429
+
11430
+ viewer.cameraControl.active = false;
11431
+
11432
+ onSingleTouchMove = canvasPos => {
11433
+ onChange(canvasPos, pickWorldPos(canvasPos));
11434
+ };
11435
+
11436
+ onSingleTouchMove(startCanvasPos);
11437
+ },
11438
+ longTouchTimeoutMs);
11439
+ },
11440
+ 250);
11441
+ }
11442
+ }
11443
+ };
11444
+ canvas.addEventListener("touchstart", onCanvasTouchStart, {passive: true});
11445
+
11446
+ // canvas.addEventListener("touchcancel", e => console.log("touchcancel", e), {passive: true});
11447
+
11448
+ const onCanvasTouchMove = function(event) {
11449
+ const touch = [...event.changedTouches].find(e => e.identifier === startTouchIdentifier);
11450
+ if (touch)
11451
+ {
11452
+ onSingleTouchMove(copyCanvasPos(touch, math.vec2()));
11453
+ }
11454
+ };
11455
+ canvas.addEventListener("touchmove", onCanvasTouchMove, {passive: true});
11456
+
11457
+ const onCanvasTouchEnd = function(event) {
11458
+ const touch = [...event.changedTouches].find(e => e.identifier === startTouchIdentifier);
11459
+ if (touch)
11460
+ {
11461
+ cleanup();
11462
+ const canvasPos = copyCanvasPos(touch, math.vec2());
11463
+ onCommit(canvasPos, pickWorldPos(canvasPos));
11464
+ }
11465
+ };
11466
+ canvas.addEventListener("touchend", onCanvasTouchEnd, {passive: true});
11467
+
11468
+ return cleanup;
11469
+ };
11470
+ };
11471
+
11356
11472
  /** @private */
11357
11473
  class Wire {
11358
11474
 
@@ -56018,9 +56134,9 @@ const configs$2 = new Configs();
56018
56134
  */
56019
56135
  class VBOBatchingTrianglesBuffer {
56020
56136
 
56021
- constructor() {
56022
- this.maxVerts = configs$2.maxGeometryBatchSize;
56023
- this.maxIndices = configs$2.maxGeometryBatchSize * 3; // Rough rule-of-thumb
56137
+ constructor(maxBatchSize = configs$2.maxGeometryBatchSize) {
56138
+ this.maxVerts = maxBatchSize;
56139
+ this.maxIndices = maxBatchSize * 3; // Rough rule-of-thumb
56024
56140
  this.positions = [];
56025
56141
  this.colors = [];
56026
56142
  this.uv = [];
@@ -67524,27 +67640,6 @@ function getRenderers$3(scene) {
67524
67640
  return renderers;
67525
67641
  }
67526
67642
 
67527
- /**
67528
- * @private
67529
- */
67530
- class VBOBatchingPointsBuffer {
67531
-
67532
- constructor(maxGeometryBatchSize = 5000000) {
67533
-
67534
- if (maxGeometryBatchSize > 5000000) {
67535
- maxGeometryBatchSize = 5000000;
67536
- }
67537
-
67538
- this.maxVerts = maxGeometryBatchSize;
67539
- this.maxIndices = maxGeometryBatchSize * 3; // Rough rule-of-thumb
67540
- this.positions = [];
67541
- this.colors = [];
67542
- this.intensities = [];
67543
- this.pickColors = [];
67544
- this.offsets = [];
67545
- }
67546
- }
67547
-
67548
67643
  /**
67549
67644
  * @private
67550
67645
  */
@@ -67583,7 +67678,58 @@ class VBOBatchingPointsLayer {
67583
67678
 
67584
67679
  this._renderers = getRenderers$3(cfg.model.scene);
67585
67680
 
67586
- this._buffer = new VBOBatchingPointsBuffer(cfg.maxGeometryBatchSize);
67681
+ const maxGeometryBatchSize = Math.min(5000000, cfg.maxGeometryBatchSize || window.Infinity);
67682
+
67683
+ const attribute = function() {
67684
+ const portions = [ ];
67685
+
67686
+ return {
67687
+ append: function(data, times = 1, denormalizeScale = 1.0) {
67688
+ portions.push({ data: data, times: times, denormalizeScale: denormalizeScale });
67689
+ },
67690
+ compileBuffer: function(type) {
67691
+ let len = 0;
67692
+ portions.forEach(p => { len += p.times * p.data.length; });
67693
+ const buf = new type(len);
67694
+
67695
+ let begin = 0;
67696
+ portions.forEach(p => {
67697
+ const data = p.data;
67698
+ const dScale = p.denormalizeScale;
67699
+ const subBuf = buf.subarray(begin);
67700
+
67701
+ if (dScale === 1.0) {
67702
+ subBuf.set(data, 0);
67703
+ } else {
67704
+ for (let i = 0; i < data.length; ++i) {
67705
+ subBuf[i] = data[i] * dScale;
67706
+ }
67707
+ }
67708
+
67709
+ let soFar = data.length;
67710
+ const allDataLen = p.times * data.length;
67711
+ while (soFar < allDataLen) {
67712
+ const toCopy = Math.min(soFar, allDataLen - soFar);
67713
+ subBuf.set(subBuf.subarray(0, toCopy), soFar);
67714
+ soFar += toCopy;
67715
+ }
67716
+
67717
+ begin += soFar;
67718
+ });
67719
+
67720
+ return buf;
67721
+ }
67722
+ };
67723
+ };
67724
+
67725
+ this._buffer = {
67726
+ maxVerts: maxGeometryBatchSize,
67727
+ positions: attribute(),
67728
+ colors: attribute(),
67729
+ pickColors: attribute(),
67730
+ vertsIndex: 0
67731
+ };
67732
+
67587
67733
  this._scratchMemory = cfg.scratchMemory;
67588
67734
 
67589
67735
  this._state = new RenderState({
@@ -67648,7 +67794,7 @@ class VBOBatchingPointsLayer {
67648
67794
  if (this._finalized) {
67649
67795
  throw "Already finalized";
67650
67796
  }
67651
- return ((this._buffer.positions.length + lenPositions) < (this._buffer.maxVerts * 3));
67797
+ return (this._buffer.vertsIndex + (lenPositions / 3)) < this._buffer.maxVerts;
67652
67798
  }
67653
67799
 
67654
67800
  /**
@@ -67673,97 +67819,40 @@ class VBOBatchingPointsLayer {
67673
67819
  throw "Already finalized";
67674
67820
  }
67675
67821
 
67676
- const positions = cfg.positions;
67677
- const positionsCompressed = cfg.positionsCompressed;
67678
- const color = cfg.color;
67679
- const colorsCompressed = cfg.colorsCompressed;
67680
- const colors = cfg.colors;
67681
- const pickColor = cfg.pickColor;
67682
-
67683
67822
  const buffer = this._buffer;
67684
- const positionsIndex = buffer.positions.length;
67685
- const vertsIndex = positionsIndex / 3;
67686
67823
 
67687
- let numVerts;
67688
-
67689
- math.expandAABB3(this._modelAABB, cfg.aabb);
67690
-
67691
- if (this._preCompressedPositionsExpected) {
67692
-
67693
- if (!positionsCompressed) {
67694
- throw "positionsCompressed expected";
67695
- }
67696
-
67697
- for (let i = 0, len = positionsCompressed.length; i < len; i++) {
67698
- buffer.positions.push(positionsCompressed[i]);
67699
- }
67700
-
67701
- numVerts = positionsCompressed.length / 3;
67702
-
67703
- } else {
67704
-
67705
- if (!positions) {
67706
- throw "positions expected";
67707
- }
67824
+ const positions = this._preCompressedPositionsExpected ? cfg.positionsCompressed : cfg.positions;
67825
+ if (! positions) {
67826
+ throw ((this._preCompressedPositionsExpected ? "positionsCompressed" : "positions") + " expected");
67827
+ }
67708
67828
 
67709
- numVerts = positions.length / 3;
67829
+ buffer.positions.append(positions);
67710
67830
 
67711
- positions.length;
67712
- buffer.positions.length;
67831
+ const numVerts = positions.length / 3;
67713
67832
 
67714
- for (let i = 0, len = positions.length; i < len; i++) {
67715
- buffer.positions.push(positions[i]);
67716
- }
67717
- }
67833
+ const color = cfg.color;
67834
+ const colorsCompressed = cfg.colorsCompressed;
67835
+ const colors = cfg.colors;
67836
+ const pickColor = cfg.pickColor;
67718
67837
 
67719
67838
  if (colorsCompressed) {
67720
- for (let i = 0, len = colorsCompressed.length; i < len; i++) {
67721
- buffer.colors.push(colorsCompressed[i]);
67722
- }
67723
-
67839
+ buffer.colors.append(colorsCompressed);
67724
67840
  } else if (colors) {
67725
- for (let i = 0, len = colors.length; i < len; i++) {
67726
- buffer.colors.push(colors[i] * 255);
67727
- }
67728
-
67841
+ buffer.colors.append(colors, 1, 255.0);
67729
67842
  } else if (color) {
67730
-
67731
- const r = color[0]; // Color is pre-quantized by VBOSceneModel
67732
- const g = color[1];
67733
- const b = color[2];
67734
- const a = 1.0;
67735
-
67736
- for (let i = 0; i < numVerts; i++) {
67737
- buffer.colors.push(r);
67738
- buffer.colors.push(g);
67739
- buffer.colors.push(b);
67740
- buffer.colors.push(a);
67741
- }
67843
+ // Color is pre-quantized by VBOSceneModel
67844
+ buffer.colors.append([ color[0], color[1], color[2], 1.0 ], numVerts);
67742
67845
  }
67743
67846
 
67744
- {
67745
- const pickColorsBase = buffer.pickColors.length;
67746
- const lenPickColors = numVerts * 4;
67747
- for (let i = pickColorsBase, len = pickColorsBase + lenPickColors; i < len; i += 4) {
67748
- buffer.pickColors.push(pickColor[0]);
67749
- buffer.pickColors.push(pickColor[1]);
67750
- buffer.pickColors.push(pickColor[2]);
67751
- buffer.pickColors.push(pickColor[3]);
67752
- }
67753
- }
67847
+ buffer.pickColors.append(pickColor.slice(0, 4), numVerts);
67754
67848
 
67755
- if (this.model.scene.entityOffsetsEnabled) {
67756
- for (let i = 0; i < numVerts; i++) {
67757
- buffer.offsets.push(0);
67758
- buffer.offsets.push(0);
67759
- buffer.offsets.push(0);
67760
- }
67761
- }
67849
+ math.expandAABB3(this._modelAABB, cfg.aabb);
67762
67850
 
67763
67851
  const portionId = this._portions.length / 2;
67764
67852
 
67765
- this._portions.push(vertsIndex);
67853
+ this._portions.push(this._buffer.vertsIndex);
67766
67854
  this._portions.push(numVerts);
67855
+ this._buffer.vertsIndex += numVerts;
67767
67856
 
67768
67857
  this._numPortions++;
67769
67858
  this.model.numPortions++;
@@ -67784,43 +67873,20 @@ class VBOBatchingPointsLayer {
67784
67873
  const state = this._state;
67785
67874
  const gl = this.model.scene.canvas.gl;
67786
67875
  const buffer = this._buffer;
67876
+ const maybeCreateGlBuffer = (srcData, size, usage) => (srcData.length > 0) ? new ArrayBuf(gl, gl.ARRAY_BUFFER, srcData, srcData.length, size, usage) : null;
67787
67877
 
67788
- if (buffer.positions.length > 0) {
67789
- if (this._preCompressedPositionsExpected) {
67790
- const positions = new Uint16Array(buffer.positions);
67791
- state.positionsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, positions, buffer.positions.length, 3, gl.STATIC_DRAW);
67792
- } else {
67793
- const positions = new Float32Array(buffer.positions);
67794
- const quantizedPositions = quantizePositions(positions, this._modelAABB, state.positionsDecodeMatrix);
67795
- state.positionsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, quantizedPositions, buffer.positions.length, 3, gl.STATIC_DRAW);
67796
- }
67797
- }
67878
+ const positions = (this._preCompressedPositionsExpected
67879
+ ? buffer.positions.compileBuffer(Uint16Array)
67880
+ : (quantizePositions(buffer.positions.compileBuffer(Float32Array), this._modelAABB, state.positionsDecodeMatrix)));
67881
+ state.positionsBuf = maybeCreateGlBuffer(positions, 3, gl.STATIC_DRAW);
67798
67882
 
67799
- if (buffer.colors.length > 0) {
67800
- const colors = new Uint8Array(buffer.colors);
67801
- let normalized = false;
67802
- state.colorsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, colors, buffer.colors.length, 4, gl.STATIC_DRAW, normalized);
67803
- }
67883
+ 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
67804
67884
 
67805
- if (buffer.positions.length > 0) { // Because we build flags arrays here, get their length from the positions array
67806
- const flagsLength = buffer.positions.length / 3;
67807
- const flags = new Float32Array(flagsLength);
67808
- let notNormalized = false;
67809
- state.flagsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, flags, flags.length, 1, gl.DYNAMIC_DRAW, notNormalized);
67810
- }
67885
+ state.colorsBuf = maybeCreateGlBuffer(buffer.colors.compileBuffer(Uint8Array), 4, gl.STATIC_DRAW);
67811
67886
 
67812
- if (buffer.pickColors.length > 0) {
67813
- const pickColors = new Uint8Array(buffer.pickColors);
67814
- let normalized = false;
67815
- state.pickColorsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, pickColors, buffer.pickColors.length, 4, gl.STATIC_DRAW, normalized);
67816
- }
67887
+ state.pickColorsBuf = maybeCreateGlBuffer(buffer.pickColors.compileBuffer(Uint8Array), 4, gl.STATIC_DRAW);
67817
67888
 
67818
- if (this.model.scene.entityOffsetsEnabled) {
67819
- if (buffer.offsets.length > 0) {
67820
- const offsets = new Float32Array(buffer.offsets);
67821
- state.offsetsBuf = new ArrayBuf(gl, gl.ARRAY_BUFFER, offsets, buffer.offsets.length, 3, gl.DYNAMIC_DRAW);
67822
- }
67823
- }
67889
+ state.offsetsBuf = this.model.scene.entityOffsetsEnabled ? maybeCreateGlBuffer(new Float32Array(this._buffer.vertsIndex * 3), 3, gl.DYNAMIC_DRAW) : null;
67824
67890
 
67825
67891
  this._buffer = null;
67826
67892
  this._finalized = true;
@@ -85120,7 +85186,21 @@ class SceneModel extends Component {
85120
85186
  if (cfg.image) { // Ignore transcoder for Images
85121
85187
  const image = cfg.image;
85122
85188
  image.crossOrigin = "Anonymous";
85123
- texture.setImage(image, {minFilter, magFilter, wrapS, wrapT, wrapR, flipY: cfg.flipY, encoding});
85189
+ if (image.compressed) {
85190
+ // see `parsedImage` in @loaders.gl/gltf/src/lib/parsers/parse-gltf.ts
85191
+ // NOTE: @loaders.gl in its current version discards potential mipmaps, leaving only a single one
85192
+ const data = image.data;
85193
+ texture.setCompressedData({
85194
+ mipmaps: data,
85195
+ props: {
85196
+ format: data[0].format,
85197
+ minFilter: minFilter,
85198
+ magFilter: magFilter
85199
+ }
85200
+ });
85201
+ } else {
85202
+ texture.setImage(image, {minFilter, magFilter, wrapS, wrapT, wrapR, flipY: cfg.flipY, encoding});
85203
+ }
85124
85204
  } else if (cfg.src) {
85125
85205
  const ext = cfg.src.split('.').pop();
85126
85206
  switch (ext) { // Don't transcode recognized image file types
@@ -88044,6 +88124,7 @@ class DistanceMeasurement extends Component {
88044
88124
  this._visible = false;
88045
88125
  this._originVisible = false;
88046
88126
  this._targetVisible = false;
88127
+ this._useRotationAdjustment = false;
88047
88128
  this._wireVisible = false;
88048
88129
  this._axisVisible = false;
88049
88130
  this._xAxisVisible = false;
@@ -88120,7 +88201,7 @@ class DistanceMeasurement extends Component {
88120
88201
  this.lengthLabelEnabled = cfg.lengthLabelEnabled;
88121
88202
  this.labelsVisible = cfg.labelsVisible;
88122
88203
  this.labelsOnWires = cfg.labelsOnWires;
88123
- this.useRotationAdjustment = cfg.useRotationAdjustment;
88204
+ this._useRotationAdjustment = cfg.useRotationAdjustment;
88124
88205
 
88125
88206
  /**
88126
88207
  * @type {number[]}
@@ -88182,7 +88263,7 @@ class DistanceMeasurement extends Component {
88182
88263
  this._factors = math.transformVec3(this._axesBasis, delta);
88183
88264
 
88184
88265
  this._measurementOrientation = determineMeasurementOrientation(this._originWorld, this._targetWorld, 0);
88185
- if(this._measurementOrientation === 'Vertical' && this.useRotationAdjustment){
88266
+ if (this._measurementOrientation === 'Vertical' && this._useRotationAdjustment) {
88186
88267
  this._wp[0] = this._originWorld[0];
88187
88268
  this._wp[1] = this._originWorld[1];
88188
88269
  this._wp[2] = this._originWorld[2];
@@ -88392,7 +88473,7 @@ class DistanceMeasurement extends Component {
88392
88473
  }
88393
88474
 
88394
88475
  if (!this._zAxisLabelCulled) {
88395
- if(this._measurementOrientation === 'Vertical' && this.useRotationAdjustment) {
88476
+ if (this._measurementOrientation === 'Vertical' && this._useRotationAdjustment) {
88396
88477
  this._zAxisLabel.setPrefix("");
88397
88478
  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);
88398
88479
  }
@@ -88587,6 +88668,25 @@ class DistanceMeasurement extends Component {
88587
88668
  return this._targetVisible;
88588
88669
  }
88589
88670
 
88671
+ /**
88672
+ * Sets if the measurement is adjusted based on rotation
88673
+ *
88674
+ * @type {Boolean}
88675
+ */
88676
+ set useRotationAdjustment(value) {
88677
+ value = value !== undefined ? Boolean(value) : this.plugin.useRotationAdjustment;
88678
+ this._useRotationAdjustment = value;
88679
+ }
88680
+
88681
+ /**
88682
+ * Gets if the measurement is adjusted based on rotation
88683
+ *
88684
+ * @type {Boolean}
88685
+ */
88686
+ get useRotationAdjustment() {
88687
+ return this._useRotationAdjustment;
88688
+ }
88689
+
88590
88690
  /**
88591
88691
  * Sets if the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are enabled.
88592
88692
  *
@@ -123621,7 +123721,13 @@ class StoreyViewsPlugin extends Plugin {
123621
123721
  return null;
123622
123722
  }
123623
123723
 
123624
- isPositionAboveOrBelowBuilding(worldPos){
123724
+ /**
123725
+ * Returns whether a position is above or below a building
123726
+ *
123727
+ * @param {Number[]} worldPos 3D World-space position.
123728
+ * @returns {String} ID of the lowest/highest story or null.
123729
+ */
123730
+ isPositionAboveOrBelowBuilding(worldPos) {
123625
123731
  const keys = Object.keys(this.storeys);
123626
123732
  const ids = [keys[0], keys[keys.length-1]];
123627
123733
  if(worldPos[1] < this.storeys[ids[0]].storeyAABB[1])
@@ -126773,6 +126879,8 @@ class TreeViewPlugin extends Plugin {
126773
126879
  return; // Node may not exist for the given object if (this._pruneEmptyNodes == true)
126774
126880
  }
126775
126881
 
126882
+ this.collapse();
126883
+
126776
126884
  const nodeId = node.nodeId;
126777
126885
 
126778
126886
  const switchElement = this._renderService.getSwitchElement(nodeId);
@@ -140505,122 +140613,6 @@ const mousePointSelector = function(viewer, ray2WorldPos) {
140505
140613
  };
140506
140614
  };
140507
140615
 
140508
- const touchPointSelector = function(viewer, pointerCircle, ray2WorldPos) {
140509
- return function(onCancel, onChange, onCommit) {
140510
- const scene = viewer.scene;
140511
- const canvas = scene.canvas.canvas;
140512
- const longTouchTimeoutMs = 300;
140513
- const moveTolerance = 20;
140514
-
140515
- const copyCanvasPos = (event, vec2) => {
140516
- vec2[0] = event.clientX;
140517
- vec2[1] = event.clientY;
140518
- transformToNode(canvas.ownerDocument.documentElement, canvas, vec2);
140519
- return vec2;
140520
- };
140521
-
140522
- const pickWorldPos = canvasPos => {
140523
- const origin = math.vec3();
140524
- const direction = math.vec3();
140525
- math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, scene.camera.projection, canvasPos, origin, direction);
140526
- return ray2WorldPos(origin, direction);
140527
- };
140528
-
140529
- let longTouchTimeout = null;
140530
- const nop = () => { };
140531
- let onSingleTouchMove = nop;
140532
- let startTouchIdentifier;
140533
-
140534
- const resetAction = function() {
140535
- pointerCircle.stop();
140536
- clearTimeout(longTouchTimeout);
140537
- viewer.cameraControl.active = true;
140538
- onSingleTouchMove = nop;
140539
- startTouchIdentifier = null;
140540
- };
140541
-
140542
- const cleanup = function() {
140543
- resetAction();
140544
- canvas.removeEventListener("touchstart", onCanvasTouchStart);
140545
- canvas.removeEventListener("touchmove", onCanvasTouchMove);
140546
- canvas.removeEventListener("touchend", onCanvasTouchEnd);
140547
- };
140548
-
140549
- const onCanvasTouchStart = function(event) {
140550
- const touches = event.touches;
140551
-
140552
- if (touches.length !== 1)
140553
- {
140554
- resetAction();
140555
- onCancel();
140556
- }
140557
- else
140558
- {
140559
- const startTouch = touches[0];
140560
- const startCanvasPos = copyCanvasPos(startTouch, math.vec2());
140561
-
140562
- const startWorldPos = pickWorldPos(startCanvasPos);
140563
- if (startWorldPos)
140564
- {
140565
- startTouchIdentifier = startTouch.identifier;
140566
-
140567
- onSingleTouchMove = canvasPos => {
140568
- if (math.distVec2(startCanvasPos, canvasPos) > moveTolerance)
140569
- {
140570
- resetAction();
140571
- }
140572
- };
140573
-
140574
- longTouchTimeout = setTimeout(
140575
- function() {
140576
- pointerCircle.start(startCanvasPos);
140577
-
140578
- longTouchTimeout = setTimeout(
140579
- function() {
140580
- pointerCircle.stop();
140581
-
140582
- viewer.cameraControl.active = false;
140583
-
140584
- onSingleTouchMove = canvasPos => {
140585
- onChange(canvasPos, pickWorldPos(canvasPos));
140586
- };
140587
-
140588
- onSingleTouchMove(startCanvasPos);
140589
- },
140590
- longTouchTimeoutMs);
140591
- },
140592
- 250);
140593
- }
140594
- }
140595
- };
140596
- canvas.addEventListener("touchstart", onCanvasTouchStart, {passive: true});
140597
-
140598
- // canvas.addEventListener("touchcancel", e => console.log("touchcancel", e), {passive: true});
140599
-
140600
- const onCanvasTouchMove = function(event) {
140601
- const touch = [...event.changedTouches].find(e => e.identifier === startTouchIdentifier);
140602
- if (touch)
140603
- {
140604
- onSingleTouchMove(copyCanvasPos(touch, math.vec2()));
140605
- }
140606
- };
140607
- canvas.addEventListener("touchmove", onCanvasTouchMove, {passive: true});
140608
-
140609
- const onCanvasTouchEnd = function(event) {
140610
- const touch = [...event.changedTouches].find(e => e.identifier === startTouchIdentifier);
140611
- if (touch)
140612
- {
140613
- cleanup();
140614
- const canvasPos = copyCanvasPos(touch, math.vec2());
140615
- onCommit(canvasPos, pickWorldPos(canvasPos));
140616
- }
140617
- };
140618
- canvas.addEventListener("touchend", onCanvasTouchEnd, {passive: true});
140619
-
140620
- return cleanup;
140621
- };
140622
- };
140623
-
140624
140616
  const planeIntersect = function(p0, n, origin, direction) {
140625
140617
  const t = - (math.dotVec3(origin, n) - p0) / math.dotVec3(direction, n);
140626
140618
  {
@@ -141996,6 +141988,7 @@ exports.DistanceMeasurementsControl = DistanceMeasurementsControl;
141996
141988
  exports.DistanceMeasurementsMouseControl = DistanceMeasurementsMouseControl;
141997
141989
  exports.DistanceMeasurementsPlugin = DistanceMeasurementsPlugin;
141998
141990
  exports.DistanceMeasurementsTouchControl = DistanceMeasurementsTouchControl;
141991
+ exports.Dot3D = Dot3D;
141999
141992
  exports.DotBIMDefaultDataSource = DotBIMDefaultDataSource;
142000
141993
  exports.DotBIMLoaderPlugin = DotBIMLoaderPlugin;
142001
141994
  exports.EdgeMaterial = EdgeMaterial;
@@ -142138,6 +142131,8 @@ exports.ZonesPlugin = ZonesPlugin;
142138
142131
  exports.ZonesPolysurfaceMouseControl = ZonesPolysurfaceMouseControl;
142139
142132
  exports.ZonesPolysurfaceTouchControl = ZonesPolysurfaceTouchControl;
142140
142133
  exports.ZonesTouchControl = ZonesTouchControl;
142134
+ exports.activateDraggableDot = activateDraggableDot;
142135
+ exports.activateDraggableDots = activateDraggableDots;
142141
142136
  exports.buildBoxGeometry = buildBoxGeometry;
142142
142137
  exports.buildBoxLinesGeometry = buildBoxLinesGeometry;
142143
142138
  exports.buildBoxLinesGeometryFromAABB = buildBoxLinesGeometryFromAABB;
@@ -142164,6 +142159,8 @@ exports.rtcToWorldPos = rtcToWorldPos;
142164
142159
  exports.sRGBEncoding = sRGBEncoding;
142165
142160
  exports.setFrustum = setFrustum;
142166
142161
  exports.stats = stats;
142162
+ exports.touchPointSelector = touchPointSelector$1;
142163
+ exports.transformToNode = transformToNode;
142167
142164
  exports.utils = utils;
142168
142165
  exports.worldToRTCPos = worldToRTCPos;
142169
142166
  exports.worldToRTCPositions = worldToRTCPositions;