@thatopen/components 2.4.10 → 2.4.11

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.
@@ -6,7 +6,7 @@ export declare class Components implements Disposable {
6
6
  /**
7
7
  * The version of the @thatopen/components library.
8
8
  */
9
- static readonly release = "2.4.10";
9
+ static readonly release = "2.4.11";
10
10
  /** {@link Disposable.onDisposed} */
11
11
  readonly onDisposed: Event<void>;
12
12
  /**
package/dist/index.cjs CHANGED
@@ -6609,7 +6609,7 @@ const _Components = class _Components {
6609
6609
  /**
6610
6610
  * The version of the @thatopen/components library.
6611
6611
  */
6612
- __publicField(_Components, "release", "2.4.10");
6612
+ __publicField(_Components, "release", "2.4.11");
6613
6613
  let Components = _Components;
6614
6614
  class SimpleWorld extends Base {
6615
6615
  constructor() {
@@ -7179,24 +7179,20 @@ const ACTION = Object.freeze({
7179
7179
  NONE: 0,
7180
7180
  ROTATE: 1,
7181
7181
  TRUCK: 2,
7182
- SCREEN_PAN: 4,
7183
- OFFSET: 8,
7184
- DOLLY: 16,
7185
- ZOOM: 32,
7186
- TOUCH_ROTATE: 64,
7187
- TOUCH_TRUCK: 128,
7188
- TOUCH_SCREEN_PAN: 256,
7189
- TOUCH_OFFSET: 512,
7190
- TOUCH_DOLLY: 1024,
7191
- TOUCH_ZOOM: 2048,
7192
- TOUCH_DOLLY_TRUCK: 4096,
7193
- TOUCH_DOLLY_SCREEN_PAN: 8192,
7194
- TOUCH_DOLLY_OFFSET: 16384,
7195
- TOUCH_DOLLY_ROTATE: 32768,
7196
- TOUCH_ZOOM_TRUCK: 65536,
7197
- TOUCH_ZOOM_OFFSET: 131072,
7198
- TOUCH_ZOOM_SCREEN_PAN: 262144,
7199
- TOUCH_ZOOM_ROTATE: 524288
7182
+ OFFSET: 4,
7183
+ DOLLY: 8,
7184
+ ZOOM: 16,
7185
+ TOUCH_ROTATE: 32,
7186
+ TOUCH_TRUCK: 64,
7187
+ TOUCH_OFFSET: 128,
7188
+ TOUCH_DOLLY: 256,
7189
+ TOUCH_ZOOM: 512,
7190
+ TOUCH_DOLLY_TRUCK: 1024,
7191
+ TOUCH_DOLLY_OFFSET: 2048,
7192
+ TOUCH_DOLLY_ROTATE: 4096,
7193
+ TOUCH_ZOOM_TRUCK: 8192,
7194
+ TOUCH_ZOOM_OFFSET: 16384,
7195
+ TOUCH_ZOOM_ROTATE: 32768
7200
7196
  });
7201
7197
  const DOLLY_DIRECTION = {
7202
7198
  NONE: 0,
@@ -7396,7 +7392,7 @@ class EventDispatcher {
7396
7392
  }
7397
7393
  }
7398
7394
  var _a;
7399
- const VERSION = "2.10.1";
7395
+ const VERSION = "2.9.0";
7400
7396
  const TOUCH_DOLLY_FACTOR = 1 / 8;
7401
7397
  const isMac = /Mac/.test((_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _a === void 0 ? void 0 : _a.platform);
7402
7398
  let THREE;
@@ -7495,12 +7491,6 @@ class CameraControls extends EventDispatcher {
7495
7491
  static get ACTION() {
7496
7492
  return ACTION;
7497
7493
  }
7498
- /**
7499
- * @deprecated Use `cameraControls.mouseButtons.left = CameraControls.ACTION.SCREEN_PAN` instead.
7500
- */
7501
- set verticalDragToForward(_) {
7502
- console.warn("camera-controls: `verticalDragToForward` was removed. Use `mouseButtons.left = CameraControls.ACTION.SCREEN_PAN` instead.");
7503
- }
7504
7494
  /**
7505
7495
  * Creates a `CameraControls` instance.
7506
7496
  *
@@ -7539,6 +7529,7 @@ class CameraControls extends EventDispatcher {
7539
7529
  this.truckSpeed = 2;
7540
7530
  this.dollyToCursor = false;
7541
7531
  this.dragToOffset = false;
7532
+ this.verticalDragToForward = false;
7542
7533
  this.boundaryFriction = 0;
7543
7534
  this.restThreshold = 0.01;
7544
7535
  this.colliderMeshes = [];
@@ -7571,7 +7562,7 @@ class CameraControls extends EventDispatcher {
7571
7562
  this._targetVelocity = new THREE.Vector3();
7572
7563
  this._focalOffsetVelocity = new THREE.Vector3();
7573
7564
  this._zoomVelocity = { value: 0 };
7574
- this._truckInternal = (deltaX, deltaY, dragToOffset, screenSpacePanning) => {
7565
+ this._truckInternal = (deltaX, deltaY, dragToOffset) => {
7575
7566
  let truckX;
7576
7567
  let pedestalY;
7577
7568
  if (isPerspectiveCamera(this._camera)) {
@@ -7582,12 +7573,12 @@ class CameraControls extends EventDispatcher {
7582
7573
  pedestalY = this.truckSpeed * deltaY * targetDistance / this._elementRect.height;
7583
7574
  } else if (isOrthographicCamera(this._camera)) {
7584
7575
  const camera2 = this._camera;
7585
- truckX = this.truckSpeed * deltaX * (camera2.right - camera2.left) / camera2.zoom / this._elementRect.width;
7586
- pedestalY = this.truckSpeed * deltaY * (camera2.top - camera2.bottom) / camera2.zoom / this._elementRect.height;
7576
+ truckX = deltaX * (camera2.right - camera2.left) / camera2.zoom / this._elementRect.width;
7577
+ pedestalY = deltaY * (camera2.top - camera2.bottom) / camera2.zoom / this._elementRect.height;
7587
7578
  } else {
7588
7579
  return;
7589
7580
  }
7590
- if (screenSpacePanning) {
7581
+ if (this.verticalDragToForward) {
7591
7582
  dragToOffset ? this.setFocalOffset(this._focalOffsetEnd.x + truckX, this._focalOffsetEnd.y, this._focalOffsetEnd.z, true) : this.truck(truckX, 0, true);
7592
7583
  this.forward(-pedestalY, true);
7593
7584
  } else {
@@ -7790,7 +7781,7 @@ class CameraControls extends EventDispatcher {
7790
7781
  lastScrollTimeStamp = now;
7791
7782
  }
7792
7783
  const deltaYFactor = isMac ? -1 : -3;
7793
- const delta = event.deltaMode === 1 || event.ctrlKey ? event.deltaY / deltaYFactor : event.deltaY / (deltaYFactor * 10);
7784
+ const delta = event.deltaMode === 1 ? event.deltaY / deltaYFactor : event.deltaY / (deltaYFactor * 10);
7794
7785
  const x = this.dollyToCursor ? (event.clientX - this._elementRect.x) / this._elementRect.width * 2 - 1 : 0;
7795
7786
  const y = this.dollyToCursor ? (event.clientY - this._elementRect.y) / this._elementRect.height * -2 + 1 : 0;
7796
7787
  switch (this.mouseButtons.wheel) {
@@ -7800,17 +7791,12 @@ class CameraControls extends EventDispatcher {
7800
7791
  break;
7801
7792
  }
7802
7793
  case ACTION.TRUCK: {
7803
- this._truckInternal(event.deltaX, event.deltaY, false, false);
7804
- this._isUserControllingTruck = true;
7805
- break;
7806
- }
7807
- case ACTION.SCREEN_PAN: {
7808
- this._truckInternal(event.deltaX, event.deltaY, false, true);
7794
+ this._truckInternal(event.deltaX, event.deltaY, false);
7809
7795
  this._isUserControllingTruck = true;
7810
7796
  break;
7811
7797
  }
7812
7798
  case ACTION.OFFSET: {
7813
- this._truckInternal(event.deltaX, event.deltaY, true, false);
7799
+ this._truckInternal(event.deltaX, event.deltaY, true);
7814
7800
  this._isUserControllingOffset = true;
7815
7801
  break;
7816
7802
  }
@@ -7890,15 +7876,15 @@ class CameraControls extends EventDispatcher {
7890
7876
  this._thetaVelocity.value = 0;
7891
7877
  this._phiVelocity.value = 0;
7892
7878
  }
7893
- if ((this._state & ACTION.TRUCK) === ACTION.TRUCK || (this._state & ACTION.SCREEN_PAN) === ACTION.SCREEN_PAN || (this._state & ACTION.TOUCH_TRUCK) === ACTION.TOUCH_TRUCK || (this._state & ACTION.TOUCH_SCREEN_PAN) === ACTION.TOUCH_SCREEN_PAN || (this._state & ACTION.TOUCH_DOLLY_TRUCK) === ACTION.TOUCH_DOLLY_TRUCK || (this._state & ACTION.TOUCH_DOLLY_SCREEN_PAN) === ACTION.TOUCH_DOLLY_SCREEN_PAN || (this._state & ACTION.TOUCH_ZOOM_TRUCK) === ACTION.TOUCH_ZOOM_TRUCK || (this._state & ACTION.TOUCH_ZOOM_SCREEN_PAN) === ACTION.TOUCH_DOLLY_SCREEN_PAN) {
7879
+ if ((this._state & ACTION.TRUCK) === ACTION.TRUCK || (this._state & ACTION.TOUCH_TRUCK) === ACTION.TOUCH_TRUCK || (this._state & ACTION.TOUCH_DOLLY_TRUCK) === ACTION.TOUCH_DOLLY_TRUCK || (this._state & ACTION.TOUCH_ZOOM_TRUCK) === ACTION.TOUCH_ZOOM_TRUCK) {
7894
7880
  this._targetEnd.copy(this._target);
7895
7881
  this._targetVelocity.set(0, 0, 0);
7896
7882
  }
7897
- if ((this._state & ACTION.DOLLY) === ACTION.DOLLY || (this._state & ACTION.TOUCH_DOLLY) === ACTION.TOUCH_DOLLY || (this._state & ACTION.TOUCH_DOLLY_TRUCK) === ACTION.TOUCH_DOLLY_TRUCK || (this._state & ACTION.TOUCH_DOLLY_SCREEN_PAN) === ACTION.TOUCH_DOLLY_SCREEN_PAN || (this._state & ACTION.TOUCH_DOLLY_OFFSET) === ACTION.TOUCH_DOLLY_OFFSET || (this._state & ACTION.TOUCH_DOLLY_ROTATE) === ACTION.TOUCH_DOLLY_ROTATE) {
7883
+ if ((this._state & ACTION.DOLLY) === ACTION.DOLLY || (this._state & ACTION.TOUCH_DOLLY) === ACTION.TOUCH_DOLLY || (this._state & ACTION.TOUCH_DOLLY_TRUCK) === ACTION.TOUCH_DOLLY_TRUCK || (this._state & ACTION.TOUCH_DOLLY_OFFSET) === ACTION.TOUCH_DOLLY_OFFSET || (this._state & ACTION.TOUCH_DOLLY_ROTATE) === ACTION.TOUCH_DOLLY_ROTATE) {
7898
7884
  this._sphericalEnd.radius = this._spherical.radius;
7899
7885
  this._radiusVelocity.value = 0;
7900
7886
  }
7901
- if ((this._state & ACTION.ZOOM) === ACTION.ZOOM || (this._state & ACTION.TOUCH_ZOOM) === ACTION.TOUCH_ZOOM || (this._state & ACTION.TOUCH_ZOOM_TRUCK) === ACTION.TOUCH_ZOOM_TRUCK || (this._state & ACTION.TOUCH_ZOOM_SCREEN_PAN) === ACTION.TOUCH_ZOOM_SCREEN_PAN || (this._state & ACTION.TOUCH_ZOOM_OFFSET) === ACTION.TOUCH_ZOOM_OFFSET || (this._state & ACTION.TOUCH_ZOOM_ROTATE) === ACTION.TOUCH_ZOOM_ROTATE) {
7887
+ if ((this._state & ACTION.ZOOM) === ACTION.ZOOM || (this._state & ACTION.TOUCH_ZOOM) === ACTION.TOUCH_ZOOM || (this._state & ACTION.TOUCH_ZOOM_TRUCK) === ACTION.TOUCH_ZOOM_TRUCK || (this._state & ACTION.TOUCH_ZOOM_OFFSET) === ACTION.TOUCH_ZOOM_OFFSET || (this._state & ACTION.TOUCH_ZOOM_ROTATE) === ACTION.TOUCH_ZOOM_ROTATE) {
7902
7888
  this._zoomEnd = this._zoom;
7903
7889
  this._zoomVelocity.value = 0;
7904
7890
  }
@@ -7934,7 +7920,7 @@ class CameraControls extends EventDispatcher {
7934
7920
  this._isUserControllingZoom = true;
7935
7921
  }
7936
7922
  }
7937
- if ((this._state & ACTION.TOUCH_DOLLY) === ACTION.TOUCH_DOLLY || (this._state & ACTION.TOUCH_ZOOM) === ACTION.TOUCH_ZOOM || (this._state & ACTION.TOUCH_DOLLY_TRUCK) === ACTION.TOUCH_DOLLY_TRUCK || (this._state & ACTION.TOUCH_ZOOM_TRUCK) === ACTION.TOUCH_ZOOM_TRUCK || (this._state & ACTION.TOUCH_DOLLY_SCREEN_PAN) === ACTION.TOUCH_DOLLY_SCREEN_PAN || (this._state & ACTION.TOUCH_ZOOM_SCREEN_PAN) === ACTION.TOUCH_ZOOM_SCREEN_PAN || (this._state & ACTION.TOUCH_DOLLY_OFFSET) === ACTION.TOUCH_DOLLY_OFFSET || (this._state & ACTION.TOUCH_ZOOM_OFFSET) === ACTION.TOUCH_ZOOM_OFFSET || (this._state & ACTION.TOUCH_DOLLY_ROTATE) === ACTION.TOUCH_DOLLY_ROTATE || (this._state & ACTION.TOUCH_ZOOM_ROTATE) === ACTION.TOUCH_ZOOM_ROTATE) {
7923
+ if ((this._state & ACTION.TOUCH_DOLLY) === ACTION.TOUCH_DOLLY || (this._state & ACTION.TOUCH_ZOOM) === ACTION.TOUCH_ZOOM || (this._state & ACTION.TOUCH_DOLLY_TRUCK) === ACTION.TOUCH_DOLLY_TRUCK || (this._state & ACTION.TOUCH_ZOOM_TRUCK) === ACTION.TOUCH_ZOOM_TRUCK || (this._state & ACTION.TOUCH_DOLLY_OFFSET) === ACTION.TOUCH_DOLLY_OFFSET || (this._state & ACTION.TOUCH_ZOOM_OFFSET) === ACTION.TOUCH_ZOOM_OFFSET || (this._state & ACTION.TOUCH_DOLLY_ROTATE) === ACTION.TOUCH_DOLLY_ROTATE || (this._state & ACTION.TOUCH_ZOOM_ROTATE) === ACTION.TOUCH_ZOOM_ROTATE) {
7938
7924
  const dx = _v2$1.x - this._activePointers[1].clientX;
7939
7925
  const dy = _v2$1.y - this._activePointers[1].clientY;
7940
7926
  const distance = Math.sqrt(dx * dx + dy * dy);
@@ -7942,7 +7928,7 @@ class CameraControls extends EventDispatcher {
7942
7928
  dollyStart.set(0, distance);
7943
7929
  const dollyX = this.dollyToCursor ? (lastDragPosition.x - this._elementRect.x) / this._elementRect.width * 2 - 1 : 0;
7944
7930
  const dollyY = this.dollyToCursor ? (lastDragPosition.y - this._elementRect.y) / this._elementRect.height * -2 + 1 : 0;
7945
- if ((this._state & ACTION.TOUCH_DOLLY) === ACTION.TOUCH_DOLLY || (this._state & ACTION.TOUCH_DOLLY_ROTATE) === ACTION.TOUCH_DOLLY_ROTATE || (this._state & ACTION.TOUCH_DOLLY_TRUCK) === ACTION.TOUCH_DOLLY_TRUCK || (this._state & ACTION.TOUCH_DOLLY_SCREEN_PAN) === ACTION.TOUCH_DOLLY_SCREEN_PAN || (this._state & ACTION.TOUCH_DOLLY_OFFSET) === ACTION.TOUCH_DOLLY_OFFSET) {
7931
+ if ((this._state & ACTION.TOUCH_DOLLY) === ACTION.TOUCH_DOLLY || (this._state & ACTION.TOUCH_DOLLY_ROTATE) === ACTION.TOUCH_DOLLY_ROTATE || (this._state & ACTION.TOUCH_DOLLY_TRUCK) === ACTION.TOUCH_DOLLY_TRUCK || (this._state & ACTION.TOUCH_DOLLY_OFFSET) === ACTION.TOUCH_DOLLY_OFFSET) {
7946
7932
  this._dollyInternal(dollyDelta * TOUCH_DOLLY_FACTOR, dollyX, dollyY);
7947
7933
  this._isUserControllingDolly = true;
7948
7934
  } else {
@@ -7951,15 +7937,11 @@ class CameraControls extends EventDispatcher {
7951
7937
  }
7952
7938
  }
7953
7939
  if ((this._state & ACTION.TRUCK) === ACTION.TRUCK || (this._state & ACTION.TOUCH_TRUCK) === ACTION.TOUCH_TRUCK || (this._state & ACTION.TOUCH_DOLLY_TRUCK) === ACTION.TOUCH_DOLLY_TRUCK || (this._state & ACTION.TOUCH_ZOOM_TRUCK) === ACTION.TOUCH_ZOOM_TRUCK) {
7954
- this._truckInternal(deltaX, deltaY, false, false);
7955
- this._isUserControllingTruck = true;
7956
- }
7957
- if ((this._state & ACTION.SCREEN_PAN) === ACTION.SCREEN_PAN || (this._state & ACTION.TOUCH_SCREEN_PAN) === ACTION.TOUCH_SCREEN_PAN || (this._state & ACTION.TOUCH_DOLLY_SCREEN_PAN) === ACTION.TOUCH_DOLLY_SCREEN_PAN || (this._state & ACTION.TOUCH_ZOOM_SCREEN_PAN) === ACTION.TOUCH_ZOOM_SCREEN_PAN) {
7958
- this._truckInternal(deltaX, deltaY, false, true);
7940
+ this._truckInternal(deltaX, deltaY, false);
7959
7941
  this._isUserControllingTruck = true;
7960
7942
  }
7961
7943
  if ((this._state & ACTION.OFFSET) === ACTION.OFFSET || (this._state & ACTION.TOUCH_OFFSET) === ACTION.TOUCH_OFFSET || (this._state & ACTION.TOUCH_DOLLY_OFFSET) === ACTION.TOUCH_DOLLY_OFFSET || (this._state & ACTION.TOUCH_ZOOM_OFFSET) === ACTION.TOUCH_ZOOM_OFFSET) {
7962
- this._truckInternal(deltaX, deltaY, true, false);
7944
+ this._truckInternal(deltaX, deltaY, true);
7963
7945
  this._isUserControllingOffset = true;
7964
7946
  }
7965
7947
  this.dispatchEvent({ type: "control" });
@@ -9022,6 +9004,7 @@ class CameraControls extends EventDispatcher {
9022
9004
  this._camera.lookAt(this._target);
9023
9005
  const affectOffset = !approxZero(this._focalOffset.x) || !approxZero(this._focalOffset.y) || !approxZero(this._focalOffset.z);
9024
9006
  if (affectOffset) {
9007
+ this._camera.updateMatrixWorld();
9025
9008
  _xColumn.setFromMatrixColumn(this._camera.matrix, 0);
9026
9009
  _yColumn.setFromMatrixColumn(this._camera.matrix, 1);
9027
9010
  _zColumn.setFromMatrixColumn(this._camera.matrix, 2);
@@ -9030,7 +9013,6 @@ class CameraControls extends EventDispatcher {
9030
9013
  _zColumn.multiplyScalar(this._focalOffset.z);
9031
9014
  _v3A.copy(_xColumn).add(_yColumn).add(_zColumn);
9032
9015
  this._camera.position.add(_v3A);
9033
- this._camera.updateMatrixWorld();
9034
9016
  }
9035
9017
  if (this._boundaryEnclosesCamera) {
9036
9018
  this._encloseToBoundary(this._camera.position.copy(this._target), _v3A.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse), 1);
@@ -9075,6 +9057,7 @@ class CameraControls extends EventDispatcher {
9075
9057
  dollySpeed: this.dollySpeed,
9076
9058
  truckSpeed: this.truckSpeed,
9077
9059
  dollyToCursor: this.dollyToCursor,
9060
+ verticalDragToForward: this.verticalDragToForward,
9078
9061
  target: this._targetEnd.toArray(),
9079
9062
  position: _v3A.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),
9080
9063
  zoom: this._zoomEnd,
@@ -9107,6 +9090,7 @@ class CameraControls extends EventDispatcher {
9107
9090
  this.dollySpeed = obj.dollySpeed;
9108
9091
  this.truckSpeed = obj.truckSpeed;
9109
9092
  this.dollyToCursor = obj.dollyToCursor;
9093
+ this.verticalDragToForward = obj.verticalDragToForward;
9110
9094
  this._target0.fromArray(obj.target0);
9111
9095
  this._position0.fromArray(obj.position0);
9112
9096
  this._zoom0 = obj.zoom0;
@@ -9322,8 +9306,6 @@ class CameraControls extends EventDispatcher {
9322
9306
  if (!object.isMesh)
9323
9307
  return;
9324
9308
  const mesh = object;
9325
- if (!mesh.geometry)
9326
- return;
9327
9309
  const geometry = mesh.geometry.clone();
9328
9310
  geometry.applyMatrix4(mesh.matrixWorld);
9329
9311
  const bufferGeometry = geometry;