copper3d 1.15.5 → 1.15.6

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.
@@ -45217,9 +45217,9 @@
45217
45217
 
45218
45218
  const objLoader = new OBJLoader();
45219
45219
 
45220
- const _changeEvent$3 = { type: "change" };
45221
- const _startEvent$3 = { type: "start" };
45222
- const _endEvent$3 = { type: "end" };
45220
+ const _changeEvent$2 = { type: "change" };
45221
+ const _startEvent$2 = { type: "start" };
45222
+ const _endEvent$2 = { type: "end" };
45223
45223
  class Copper3dTrackballControls extends EventDispatcher {
45224
45224
  constructor(object, domElement) {
45225
45225
  super();
@@ -45440,7 +45440,7 @@
45440
45440
  scope.checkDistances();
45441
45441
  scope.object.lookAt(scope.target);
45442
45442
  if (lastPosition.distanceToSquared(scope.object.position) > EPS) {
45443
- scope.dispatchEvent(_changeEvent$3);
45443
+ scope.dispatchEvent(_changeEvent$2);
45444
45444
  lastPosition.copy(scope.object.position);
45445
45445
  }
45446
45446
  }
@@ -45448,7 +45448,7 @@
45448
45448
  scope.object.lookAt(scope.target);
45449
45449
  if (lastPosition.distanceToSquared(scope.object.position) > EPS ||
45450
45450
  lastZoom !== scope.object.zoom) {
45451
- scope.dispatchEvent(_changeEvent$3);
45451
+ scope.dispatchEvent(_changeEvent$2);
45452
45452
  lastPosition.copy(scope.object.position);
45453
45453
  lastZoom = scope.object.zoom;
45454
45454
  }
@@ -45467,7 +45467,7 @@
45467
45467
  scope.object.updateProjectionMatrix();
45468
45468
  _eye.subVectors(scope.object.position, scope.target);
45469
45469
  scope.object.lookAt(scope.target);
45470
- scope.dispatchEvent(_changeEvent$3);
45470
+ scope.dispatchEvent(_changeEvent$2);
45471
45471
  lastPosition.copy(scope.object.position);
45472
45472
  lastZoom = scope.object.zoom;
45473
45473
  };
@@ -45567,7 +45567,7 @@
45567
45567
  _panStart.copy(getMouseOnScreen(event.pageX, event.pageY));
45568
45568
  _panEnd.copy(_panStart);
45569
45569
  }
45570
- scope.dispatchEvent(_startEvent$3);
45570
+ scope.dispatchEvent(_startEvent$2);
45571
45571
  }
45572
45572
  function onMouseMove(event) {
45573
45573
  const state = _keyState !== STATE.NONE ? _keyState : _state;
@@ -45584,7 +45584,7 @@
45584
45584
  }
45585
45585
  function onMouseUp(event) {
45586
45586
  _state = STATE.NONE;
45587
- scope.dispatchEvent(_endEvent$3);
45587
+ scope.dispatchEvent(_endEvent$2);
45588
45588
  }
45589
45589
  function onMouseWheel(event) {
45590
45590
  if (scope.enabled === false)
@@ -45606,8 +45606,8 @@
45606
45606
  _zoomStart.y -= event.deltaY * 0.00025;
45607
45607
  break;
45608
45608
  }
45609
- scope.dispatchEvent(_startEvent$3);
45610
- scope.dispatchEvent(_endEvent$3);
45609
+ scope.dispatchEvent(_startEvent$2);
45610
+ scope.dispatchEvent(_endEvent$2);
45611
45611
  }
45612
45612
  function onTouchStart(event) {
45613
45613
  trackPointer(event);
@@ -45617,7 +45617,7 @@
45617
45617
  _moveCurr.copy(getMouseOnCircle(_pointers[0].pageX, _pointers[0].pageY));
45618
45618
  _movePrev.copy(_moveCurr);
45619
45619
  break;
45620
- default: // 2 or more
45620
+ case 2:
45621
45621
  _state = STATE.TOUCH_ZOOM_PAN;
45622
45622
  const dx = _pointers[0].pageX - _pointers[1].pageX;
45623
45623
  const dy = _pointers[0].pageY - _pointers[1].pageY;
@@ -45627,25 +45627,47 @@
45627
45627
  _panStart.copy(getMouseOnScreen(x, y));
45628
45628
  _panEnd.copy(_panStart);
45629
45629
  break;
45630
+ case 3:
45631
+ _state = STATE.TOUCH_PAN;
45632
+ const centerX = (_pointers[0].pageX + _pointers[1].pageX + _pointers[2].pageX) / 3;
45633
+ const centerY = (_pointers[0].pageY + _pointers[1].pageY + _pointers[2].pageY) / 3;
45634
+ _panStart.copy(getMouseOnScreen(centerX, centerY));
45635
+ _panEnd.copy(_panStart);
45636
+ break;
45630
45637
  }
45631
- scope.dispatchEvent(_startEvent$3);
45638
+ scope.dispatchEvent(_startEvent$2);
45632
45639
  }
45633
45640
  function onTouchMove(event) {
45634
45641
  trackPointer(event);
45642
+ let position, x, y;
45635
45643
  switch (_pointers.length) {
45636
45644
  case 1:
45645
+ if (_state != STATE.TOUCH_ROTATE)
45646
+ return;
45637
45647
  _movePrev.copy(_moveCurr);
45638
45648
  _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
45639
45649
  break;
45640
- default: // 2 or more
45641
- const position = getSecondPointerPosition(event);
45650
+ case 2:
45651
+ if (_state != STATE.TOUCH_ZOOM_PAN)
45652
+ return;
45653
+ position = getSecondPointerPosition(event);
45642
45654
  const dx = event.pageX - position.x;
45643
45655
  const dy = event.pageY - position.y;
45644
45656
  _touchZoomDistanceEnd = Math.sqrt(dx * dx + dy * dy);
45645
- const x = (event.pageX + position.x) / 2;
45646
- const y = (event.pageY + position.y) / 2;
45657
+ x = (event.pageX + position.x) / 2;
45658
+ y = (event.pageY + position.y) / 2;
45647
45659
  _panEnd.copy(getMouseOnScreen(x, y));
45648
45660
  break;
45661
+ case 3:
45662
+ if (_state != STATE.TOUCH_PAN)
45663
+ return;
45664
+ const point_1 = _pointerPositions[_pointers[0].pointerId];
45665
+ const point_2 = _pointerPositions[_pointers[1].pointerId];
45666
+ const point_3 = _pointerPositions[_pointers[2].pointerId];
45667
+ const centerX = (point_1.x + point_2.x + point_3.x) / 3;
45668
+ const centerY = (point_1.y + point_2.y + point_3.y) / 3;
45669
+ _panEnd.copy(getMouseOnScreen(centerX, centerY));
45670
+ break;
45649
45671
  }
45650
45672
  }
45651
45673
  function onTouchEnd(event) {
@@ -45663,114 +45685,26 @@
45663
45685
  for (let i = 0; i < _pointers.length; i++) {
45664
45686
  if (_pointers[i].pointerId !== event.pointerId) {
45665
45687
  const position = _pointerPositions[_pointers[i].pointerId];
45666
- _moveCurr.copy(getMouseOnCircle(position.x, position.y));
45688
+ _moveCurr.copy(getMouseOnScreen(position.x, position.y));
45689
+ _movePrev.copy(_moveCurr);
45690
+ break;
45691
+ }
45692
+ }
45693
+ break;
45694
+ case 3:
45695
+ _state = STATE.TOUCH_PAN;
45696
+ for (let i = 0; i < _pointers.length; i++) {
45697
+ if (_pointers[i].pointerId !== event.pointerId) {
45698
+ const position = _pointerPositions[_pointers[i].pointerId];
45699
+ _moveCurr.copy(getMouseOnScreen(position.x, position.y));
45667
45700
  _movePrev.copy(_moveCurr);
45668
45701
  break;
45669
45702
  }
45670
45703
  }
45671
45704
  break;
45672
45705
  }
45673
- scope.dispatchEvent(_endEvent$3);
45706
+ scope.dispatchEvent(_endEvent$2);
45674
45707
  }
45675
- // function onTouchStart(event: PointerEvent) {
45676
- // trackPointer(event);
45677
- // switch (_pointers.length) {
45678
- // case 1:
45679
- // _state = STATE.TOUCH_ROTATE;
45680
- // _moveCurr.copy(
45681
- // getMouseOnCircle(_pointers[0].pageX, _pointers[0].pageY)
45682
- // );
45683
- // _movePrev.copy(_moveCurr);
45684
- // break;
45685
- // case 2:
45686
- // _state = STATE.TOUCH_ZOOM_PAN;
45687
- // const dx: number = _pointers[0].pageX - _pointers[1].pageX;
45688
- // const dy: number = _pointers[0].pageY - _pointers[1].pageY;
45689
- // _touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt(
45690
- // dx * dx + dy * dy
45691
- // );
45692
- // const x = (_pointers[0].pageX + _pointers[1].pageX) / 2;
45693
- // const y = (_pointers[0].pageY + _pointers[1].pageY) / 2;
45694
- // _panStart.copy(getMouseOnScreen(x, y));
45695
- // _panEnd.copy(_panStart);
45696
- // break;
45697
- // case 3:
45698
- // _state = STATE.TOUCH_PAN;
45699
- // const centerX =
45700
- // (_pointers[0].pageX + _pointers[1].pageX + _pointers[2].pageX) / 3;
45701
- // const centerY =
45702
- // (_pointers[0].pageY + _pointers[1].pageY + _pointers[2].pageY) / 3;
45703
- // _panStart.copy(getMouseOnScreen(centerX, centerY));
45704
- // _panEnd.copy(_panStart);
45705
- // break;
45706
- // }
45707
- // scope.dispatchEvent(_startEvent);
45708
- // }
45709
- // function onTouchMove(event: PointerEvent) {
45710
- // trackPointer(event);
45711
- // let position: Vector2, x: number, y: number;
45712
- // switch (_pointers.length) {
45713
- // case 1:
45714
- // if (_state != STATE.TOUCH_ROTATE) return;
45715
- // _movePrev.copy(_moveCurr);
45716
- // _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
45717
- // break;
45718
- // case 2:
45719
- // if (_state != STATE.TOUCH_ZOOM_PAN) return;
45720
- // position = getSecondPointerPosition(event);
45721
- // const dx: number = event.pageX - position.x;
45722
- // const dy: number = event.pageY - position.y;
45723
- // _touchZoomDistanceEnd = Math.sqrt(dx * dx + dy * dy);
45724
- // x = (event.pageX + position.x) / 2;
45725
- // y = (event.pageY + position.y) / 2;
45726
- // _panEnd.copy(getMouseOnScreen(x, y));
45727
- // break;
45728
- // case 3:
45729
- // if (_state != STATE.TOUCH_PAN) return;
45730
- // const point_1 = _pointerPositions[_pointers[0].pointerId];
45731
- // const point_2 = _pointerPositions[_pointers[1].pointerId];
45732
- // const point_3 = _pointerPositions[_pointers[2].pointerId];
45733
- // const centerX = (point_1.x + point_2.x + point_3.x) / 3;
45734
- // const centerY = (point_1.y + point_2.y + point_3.y) / 3;
45735
- // _panEnd.copy(getMouseOnScreen(centerX, centerY));
45736
- // break;
45737
- // }
45738
- // }
45739
- // function onTouchEnd(event: PointerEvent) {
45740
- // switch (_pointers.length) {
45741
- // case 0:
45742
- // _state = STATE.NONE;
45743
- // break;
45744
- // case 1:
45745
- // _state = STATE.TOUCH_ROTATE;
45746
- // _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
45747
- // _movePrev.copy(_moveCurr);
45748
- // break;
45749
- // case 2:
45750
- // _state = STATE.TOUCH_ZOOM_PAN;
45751
- // for (let i = 0; i < _pointers.length; i++) {
45752
- // if (_pointers[i].pointerId !== event.pointerId) {
45753
- // const position = _pointerPositions[_pointers[i].pointerId];
45754
- // _moveCurr.copy(getMouseOnScreen(position.x, position.y));
45755
- // _movePrev.copy(_moveCurr);
45756
- // break;
45757
- // }
45758
- // }
45759
- // break;
45760
- // case 3:
45761
- // _state = STATE.TOUCH_PAN;
45762
- // for (let i = 0; i < _pointers.length; i++) {
45763
- // if (_pointers[i].pointerId !== event.pointerId) {
45764
- // const position = _pointerPositions[_pointers[i].pointerId];
45765
- // _moveCurr.copy(getMouseOnScreen(position.x, position.y));
45766
- // _movePrev.copy(_moveCurr);
45767
- // break;
45768
- // }
45769
- // }
45770
- // break;
45771
- // }
45772
- // scope.dispatchEvent(_endEvent);
45773
- // }
45774
45708
  function contextmenu(event) {
45775
45709
  if (scope.enabled === false)
45776
45710
  return;
@@ -45794,7 +45728,7 @@
45794
45728
  position = new Vector2();
45795
45729
  _pointerPositions[event.pointerId] = position;
45796
45730
  }
45797
- position.set(event.clientX, event.clientY);
45731
+ position.set(event.pageX, event.pageY);
45798
45732
  }
45799
45733
  function getSecondPointerPosition(event) {
45800
45734
  const pointer = event.pointerId === _pointers[0].pointerId
@@ -45831,9 +45765,9 @@
45831
45765
  // Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish
45832
45766
  // Pan - right mouse, or left mouse + ctrl/meta/shiftKey, or arrow keys / touch: two-finger move
45833
45767
 
45834
- const _changeEvent$2 = { type: 'change' };
45835
- const _startEvent$2 = { type: 'start' };
45836
- const _endEvent$2 = { type: 'end' };
45768
+ const _changeEvent$1 = { type: 'change' };
45769
+ const _startEvent$1 = { type: 'start' };
45770
+ const _endEvent$1 = { type: 'end' };
45837
45771
 
45838
45772
  class OrbitControls extends EventDispatcher {
45839
45773
 
@@ -45962,7 +45896,7 @@
45962
45896
  scope.object.zoom = scope.zoom0;
45963
45897
 
45964
45898
  scope.object.updateProjectionMatrix();
45965
- scope.dispatchEvent( _changeEvent$2 );
45899
+ scope.dispatchEvent( _changeEvent$1 );
45966
45900
 
45967
45901
  scope.update();
45968
45902
 
@@ -46096,7 +46030,7 @@
46096
46030
  lastPosition.distanceToSquared( scope.object.position ) > EPS ||
46097
46031
  8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) {
46098
46032
 
46099
- scope.dispatchEvent( _changeEvent$2 );
46033
+ scope.dispatchEvent( _changeEvent$1 );
46100
46034
 
46101
46035
  lastPosition.copy( scope.object.position );
46102
46036
  lastQuaternion.copy( scope.object.quaternion );
@@ -46710,7 +46644,7 @@
46710
46644
 
46711
46645
  }
46712
46646
 
46713
- scope.dispatchEvent( _endEvent$2 );
46647
+ scope.dispatchEvent( _endEvent$1 );
46714
46648
 
46715
46649
  state = STATE.NONE;
46716
46650
 
@@ -46807,7 +46741,7 @@
46807
46741
 
46808
46742
  if ( state !== STATE.NONE ) {
46809
46743
 
46810
- scope.dispatchEvent( _startEvent$2 );
46744
+ scope.dispatchEvent( _startEvent$1 );
46811
46745
 
46812
46746
  }
46813
46747
 
@@ -46851,11 +46785,11 @@
46851
46785
 
46852
46786
  event.preventDefault();
46853
46787
 
46854
- scope.dispatchEvent( _startEvent$2 );
46788
+ scope.dispatchEvent( _startEvent$1 );
46855
46789
 
46856
46790
  handleMouseWheel( event );
46857
46791
 
46858
- scope.dispatchEvent( _endEvent$2 );
46792
+ scope.dispatchEvent( _endEvent$1 );
46859
46793
 
46860
46794
  }
46861
46795
 
@@ -46945,7 +46879,7 @@
46945
46879
 
46946
46880
  if ( state !== STATE.NONE ) {
46947
46881
 
46948
- scope.dispatchEvent( _startEvent$2 );
46882
+ scope.dispatchEvent( _startEvent$1 );
46949
46883
 
46950
46884
  }
46951
46885
 
@@ -48364,543 +48298,6 @@
48364
48298
  }
48365
48299
  }
48366
48300
 
48367
- const _changeEvent$1 = { type: "change" };
48368
- const _startEvent$1 = { type: "start" };
48369
- const _endEvent$1 = { type: "end" };
48370
- class Copper3dTrackballControls1 extends EventDispatcher {
48371
- constructor(object, domElement) {
48372
- super();
48373
- const scope = this;
48374
- const STATE = {
48375
- NONE: -1,
48376
- ROTATE: 0,
48377
- ZOOM: 1,
48378
- PAN: 2,
48379
- TOUCH_ROTATE: 3,
48380
- TOUCH_ZOOM: 4,
48381
- TOUCH_PAN: 5,
48382
- TOUCH_ZOOM_PAN: 6,
48383
- };
48384
- this.object = object;
48385
- this.domElement = domElement;
48386
- this.domElement.style.touchAction = "none"; // disable touch scroll
48387
- // API
48388
- this.enabled = true;
48389
- this.screen = { left: 0, top: 0, width: 0, height: 0 };
48390
- this.rotateSpeed = 1.0;
48391
- this.zoomSpeed = 1.2;
48392
- this.panSpeed = 0.3;
48393
- this.noRotate = false;
48394
- this.noZoom = false;
48395
- this.noPan = false;
48396
- this.staticMoving = false;
48397
- this.dynamicDampingFactor = 0.2;
48398
- this.minDistance = 0;
48399
- this.maxDistance = Infinity;
48400
- this.minZoom = 0;
48401
- this.maxZoom = Infinity;
48402
- this.keys = ["KeyA" /*A*/, "KeyS" /*S*/, "KeyD" /*D*/];
48403
- this.mouseButtons = {
48404
- LEFT: MOUSE.ROTATE,
48405
- MIDDLE: MOUSE.DOLLY,
48406
- RIGHT: MOUSE.PAN,
48407
- };
48408
- // internals
48409
- this.target = new Vector3();
48410
- const EPS = 0.000001;
48411
- const lastPosition = new Vector3();
48412
- let lastZoom = 1;
48413
- let _state = STATE.NONE, _keyState = STATE.NONE, _touchZoomDistanceStart = 0, _touchZoomDistanceEnd = 0, _lastAngle = 0;
48414
- const _eye = new Vector3(), _movePrev = new Vector2(), _moveCurr = new Vector2(), _lastAxis = new Vector3(), _zoomStart = new Vector2(), _zoomEnd = new Vector2(), _panStart = new Vector2(), _panEnd = new Vector2(), _pointers = [], _pointerPositions = {};
48415
- // for reset
48416
- this.target0 = this.target.clone();
48417
- this.position0 = this.object.position.clone();
48418
- this.up0 = this.object.up.clone();
48419
- this.zoom0 = this.object.zoom;
48420
- // methods
48421
- this.handleResize = function () {
48422
- const box = scope.domElement.getBoundingClientRect();
48423
- // adjustments come from similar code in the jquery offset() function
48424
- const d = scope.domElement.ownerDocument.documentElement;
48425
- scope.screen.left = box.left + window.pageXOffset - d.clientLeft;
48426
- scope.screen.top = box.top + window.pageYOffset - d.clientTop;
48427
- scope.screen.width = box.width;
48428
- scope.screen.height = box.height;
48429
- };
48430
- const getMouseOnScreen = (function () {
48431
- const vector = new Vector2();
48432
- return function getMouseOnScreen(pageX, pageY) {
48433
- vector.set((pageX - scope.screen.left) / scope.screen.width, (pageY - scope.screen.top) / scope.screen.height);
48434
- return vector;
48435
- };
48436
- })();
48437
- const getMouseOnCircle = (function () {
48438
- const vector = new Vector2();
48439
- return function getMouseOnCircle(pageX, pageY) {
48440
- vector.set((pageX - scope.screen.width * 0.5 - scope.screen.left) /
48441
- (scope.screen.width * 0.5), (scope.screen.height + 2 * (scope.screen.top - pageY)) /
48442
- scope.screen.width // screen.width intentional
48443
- );
48444
- return vector;
48445
- };
48446
- })();
48447
- this.rotateCamera = (function () {
48448
- const axis = new Vector3(), quaternion = new Quaternion(), eyeDirection = new Vector3(), objectUpDirection = new Vector3(), objectSidewaysDirection = new Vector3(), moveDirection = new Vector3();
48449
- return function rotateCamera() {
48450
- moveDirection.set(_moveCurr.x - _movePrev.x, _moveCurr.y - _movePrev.y, 0);
48451
- let angle = moveDirection.length();
48452
- if (angle) {
48453
- _eye.copy(scope.object.position).sub(scope.target);
48454
- eyeDirection.copy(_eye).normalize();
48455
- objectUpDirection.copy(scope.object.up).normalize();
48456
- objectSidewaysDirection
48457
- .crossVectors(objectUpDirection, eyeDirection)
48458
- .normalize();
48459
- objectUpDirection.setLength(_moveCurr.y - _movePrev.y);
48460
- objectSidewaysDirection.setLength(_moveCurr.x - _movePrev.x);
48461
- moveDirection.copy(objectUpDirection.add(objectSidewaysDirection));
48462
- axis.crossVectors(moveDirection, _eye).normalize();
48463
- angle *= scope.rotateSpeed;
48464
- quaternion.setFromAxisAngle(axis, angle);
48465
- _eye.applyQuaternion(quaternion);
48466
- scope.object.up.applyQuaternion(quaternion);
48467
- _lastAxis.copy(axis);
48468
- _lastAngle = angle;
48469
- }
48470
- else if (!scope.staticMoving && _lastAngle) {
48471
- _lastAngle *= Math.sqrt(1.0 - scope.dynamicDampingFactor);
48472
- _eye.copy(scope.object.position).sub(scope.target);
48473
- quaternion.setFromAxisAngle(_lastAxis, _lastAngle);
48474
- _eye.applyQuaternion(quaternion);
48475
- scope.object.up.applyQuaternion(quaternion);
48476
- }
48477
- _movePrev.copy(_moveCurr);
48478
- };
48479
- })();
48480
- this.zoomCamera = function () {
48481
- let factor;
48482
- if (_state === STATE.TOUCH_ZOOM_PAN) {
48483
- factor = _touchZoomDistanceStart / _touchZoomDistanceEnd;
48484
- _touchZoomDistanceStart = _touchZoomDistanceEnd;
48485
- if (scope.object.isPerspectiveCamera) {
48486
- _eye.multiplyScalar(factor);
48487
- }
48488
- else if (scope.object.isOrthographicCamera) {
48489
- scope.object.zoom = MathUtils.clamp(scope.object.zoom / factor, scope.minZoom, scope.maxZoom);
48490
- if (lastZoom !== scope.object.zoom) {
48491
- scope.object.updateProjectionMatrix();
48492
- }
48493
- }
48494
- else {
48495
- console.warn("THREE.TrackballControls: Unsupported camera type");
48496
- }
48497
- }
48498
- else {
48499
- factor = 1.0 + (_zoomEnd.y - _zoomStart.y) * scope.zoomSpeed;
48500
- if (factor !== 1.0 && factor > 0.0) {
48501
- if (scope.object.isPerspectiveCamera) {
48502
- _eye.multiplyScalar(factor);
48503
- }
48504
- else if (scope.object.isOrthographicCamera) {
48505
- scope.object.zoom = MathUtils.clamp(scope.object.zoom / factor, scope.minZoom, scope.maxZoom);
48506
- if (lastZoom !== scope.object.zoom) {
48507
- scope.object.updateProjectionMatrix();
48508
- }
48509
- }
48510
- else {
48511
- console.warn("THREE.TrackballControls: Unsupported camera type");
48512
- }
48513
- }
48514
- if (scope.staticMoving) {
48515
- _zoomStart.copy(_zoomEnd);
48516
- }
48517
- else {
48518
- _zoomStart.y +=
48519
- (_zoomEnd.y - _zoomStart.y) * this.dynamicDampingFactor;
48520
- }
48521
- }
48522
- };
48523
- this.panCamera = (function () {
48524
- const mouseChange = new Vector2(), objectUp = new Vector3(), pan = new Vector3();
48525
- return function panCamera() {
48526
- mouseChange.copy(_panEnd).sub(_panStart);
48527
- if (mouseChange.lengthSq()) {
48528
- if (scope.object.isOrthographicCamera) {
48529
- const scale_x = (scope.object.right -
48530
- scope.object.left) /
48531
- scope.object.zoom /
48532
- scope.domElement.clientWidth;
48533
- const scale_y = (scope.object.top -
48534
- scope.object.bottom) /
48535
- scope.object.zoom /
48536
- scope.domElement.clientWidth;
48537
- mouseChange.x *= scale_x;
48538
- mouseChange.y *= scale_y;
48539
- }
48540
- mouseChange.multiplyScalar(_eye.length() * scope.panSpeed);
48541
- pan.copy(_eye).cross(scope.object.up).setLength(mouseChange.x);
48542
- pan.add(objectUp.copy(scope.object.up).setLength(mouseChange.y));
48543
- scope.object.position.add(pan);
48544
- scope.target.add(pan);
48545
- if (scope.staticMoving) {
48546
- _panStart.copy(_panEnd);
48547
- }
48548
- else {
48549
- _panStart.add(mouseChange
48550
- .subVectors(_panEnd, _panStart)
48551
- .multiplyScalar(scope.dynamicDampingFactor));
48552
- }
48553
- }
48554
- };
48555
- })();
48556
- this.checkDistances = function () {
48557
- if (!scope.noZoom || !scope.noPan) {
48558
- if (_eye.lengthSq() > scope.maxDistance * scope.maxDistance) {
48559
- scope.object.position.addVectors(scope.target, _eye.setLength(scope.maxDistance));
48560
- _zoomStart.copy(_zoomEnd);
48561
- }
48562
- if (_eye.lengthSq() < scope.minDistance * scope.minDistance) {
48563
- scope.object.position.addVectors(scope.target, _eye.setLength(scope.minDistance));
48564
- _zoomStart.copy(_zoomEnd);
48565
- }
48566
- }
48567
- };
48568
- this.update = function () {
48569
- _eye.subVectors(scope.object.position, scope.target);
48570
- if (!scope.noRotate) {
48571
- scope.rotateCamera();
48572
- }
48573
- if (!scope.noZoom) {
48574
- scope.zoomCamera();
48575
- }
48576
- if (!scope.noPan) {
48577
- scope.panCamera();
48578
- }
48579
- scope.object.position.addVectors(scope.target, _eye);
48580
- if (scope.object.isPerspectiveCamera) {
48581
- scope.checkDistances();
48582
- scope.object.lookAt(scope.target);
48583
- if (lastPosition.distanceToSquared(scope.object.position) > EPS) {
48584
- scope.dispatchEvent(_changeEvent$1);
48585
- lastPosition.copy(scope.object.position);
48586
- }
48587
- }
48588
- else if (scope.object.isOrthographicCamera) {
48589
- scope.object.lookAt(scope.target);
48590
- if (lastPosition.distanceToSquared(scope.object.position) > EPS ||
48591
- lastZoom !== scope.object.zoom) {
48592
- scope.dispatchEvent(_changeEvent$1);
48593
- lastPosition.copy(scope.object.position);
48594
- lastZoom = scope.object.zoom;
48595
- }
48596
- }
48597
- else {
48598
- console.warn("THREE.TrackballControls: Unsupported camera type");
48599
- }
48600
- };
48601
- this.reset = function () {
48602
- _state = STATE.NONE;
48603
- _keyState = STATE.NONE;
48604
- scope.target.copy(scope.target0);
48605
- scope.object.position.copy(scope.position0);
48606
- scope.object.up.copy(scope.up0);
48607
- scope.object.zoom = scope.zoom0;
48608
- scope.object.updateProjectionMatrix();
48609
- _eye.subVectors(scope.object.position, scope.target);
48610
- scope.object.lookAt(scope.target);
48611
- scope.dispatchEvent(_changeEvent$1);
48612
- lastPosition.copy(scope.object.position);
48613
- lastZoom = scope.object.zoom;
48614
- };
48615
- // listeners
48616
- function onPointerDown(event) {
48617
- if (scope.enabled === false)
48618
- return;
48619
- if (_pointers.length === 0) {
48620
- scope.domElement.setPointerCapture(event.pointerId);
48621
- scope.domElement.addEventListener("pointermove", onPointerMove);
48622
- scope.domElement.addEventListener("pointerup", onPointerUp);
48623
- }
48624
- //
48625
- addPointer(event);
48626
- if (event.pointerType === "touch") {
48627
- onTouchStart(event);
48628
- }
48629
- else {
48630
- onMouseDown(event);
48631
- }
48632
- }
48633
- function onPointerMove(event) {
48634
- if (scope.enabled === false)
48635
- return;
48636
- if (event.pointerType === "touch") {
48637
- onTouchMove(event);
48638
- }
48639
- else {
48640
- onMouseMove(event);
48641
- }
48642
- }
48643
- function onPointerUp(event) {
48644
- if (scope.enabled === false)
48645
- return;
48646
- if (event.pointerType === "touch") {
48647
- onTouchEnd(event);
48648
- }
48649
- else {
48650
- onMouseUp();
48651
- }
48652
- //
48653
- removePointer(event);
48654
- if (_pointers.length === 0) {
48655
- scope.domElement.releasePointerCapture(event.pointerId);
48656
- scope.domElement.removeEventListener("pointermove", onPointerMove);
48657
- scope.domElement.removeEventListener("pointerup", onPointerUp);
48658
- }
48659
- }
48660
- function onPointerCancel(event) {
48661
- removePointer(event);
48662
- }
48663
- function keydown(event) {
48664
- if (scope.enabled === false)
48665
- return;
48666
- window.removeEventListener("keydown", keydown);
48667
- if (_keyState !== STATE.NONE) {
48668
- return;
48669
- }
48670
- else if (event.code === scope.keys[STATE.ROTATE] && !scope.noRotate) {
48671
- _keyState = STATE.ROTATE;
48672
- }
48673
- else if (event.code === scope.keys[STATE.ZOOM] && !scope.noZoom) {
48674
- _keyState = STATE.ZOOM;
48675
- }
48676
- else if (event.code === scope.keys[STATE.PAN] && !scope.noPan) {
48677
- _keyState = STATE.PAN;
48678
- }
48679
- }
48680
- function keyup() {
48681
- if (scope.enabled === false)
48682
- return;
48683
- _keyState = STATE.NONE;
48684
- window.addEventListener("keydown", keydown);
48685
- }
48686
- function onMouseDown(event) {
48687
- if (_state === STATE.NONE) {
48688
- switch (event.button) {
48689
- case scope.mouseButtons.LEFT:
48690
- _state = STATE.ROTATE;
48691
- break;
48692
- case scope.mouseButtons.MIDDLE:
48693
- _state = STATE.ZOOM;
48694
- break;
48695
- case scope.mouseButtons.RIGHT:
48696
- _state = STATE.PAN;
48697
- break;
48698
- }
48699
- }
48700
- const state = _keyState !== STATE.NONE ? _keyState : _state;
48701
- if (state === STATE.ROTATE && !scope.noRotate) {
48702
- _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
48703
- _movePrev.copy(_moveCurr);
48704
- }
48705
- else if (state === STATE.ZOOM && !scope.noZoom) {
48706
- _zoomStart.copy(getMouseOnScreen(event.pageX, event.pageY));
48707
- _zoomEnd.copy(_zoomStart);
48708
- }
48709
- else if (state === STATE.PAN && !scope.noPan) {
48710
- _panStart.copy(getMouseOnScreen(event.pageX, event.pageY));
48711
- _panEnd.copy(_panStart);
48712
- }
48713
- scope.dispatchEvent(_startEvent$1);
48714
- }
48715
- function onMouseMove(event) {
48716
- const state = _keyState !== STATE.NONE ? _keyState : _state;
48717
- if (state === STATE.ROTATE && !scope.noRotate) {
48718
- _movePrev.copy(_moveCurr);
48719
- _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
48720
- }
48721
- else if (state === STATE.ZOOM && !scope.noZoom) {
48722
- _zoomEnd.copy(getMouseOnScreen(event.pageX, event.pageY));
48723
- }
48724
- else if (state === STATE.PAN && !scope.noPan) {
48725
- _panEnd.copy(getMouseOnScreen(event.pageX, event.pageY));
48726
- }
48727
- }
48728
- function onMouseUp() {
48729
- _state = STATE.NONE;
48730
- scope.dispatchEvent(_endEvent$1);
48731
- }
48732
- function onMouseWheel(event) {
48733
- if (scope.enabled === false)
48734
- return;
48735
- if (scope.noZoom === true)
48736
- return;
48737
- event.preventDefault();
48738
- switch (event.deltaMode) {
48739
- case 2:
48740
- // Zoom in pages
48741
- _zoomStart.y -= event.deltaY * 0.025;
48742
- break;
48743
- case 1:
48744
- // Zoom in lines
48745
- _zoomStart.y -= event.deltaY * 0.01;
48746
- break;
48747
- default:
48748
- // undefined, 0, assume pixels
48749
- _zoomStart.y -= event.deltaY * 0.00025;
48750
- break;
48751
- }
48752
- scope.dispatchEvent(_startEvent$1);
48753
- scope.dispatchEvent(_endEvent$1);
48754
- }
48755
- function onTouchStart(event) {
48756
- trackPointer(event);
48757
- switch (_pointers.length) {
48758
- case 1:
48759
- _state = STATE.TOUCH_ROTATE;
48760
- _moveCurr.copy(getMouseOnCircle(_pointers[0].pageX, _pointers[0].pageY));
48761
- _movePrev.copy(_moveCurr);
48762
- break;
48763
- case 2:
48764
- _state = STATE.TOUCH_ZOOM_PAN;
48765
- const dx = _pointers[0].pageX - _pointers[1].pageX;
48766
- const dy = _pointers[0].pageY - _pointers[1].pageY;
48767
- _touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt(dx * dx + dy * dy);
48768
- const x = (_pointers[0].pageX + _pointers[1].pageX) / 2;
48769
- const y = (_pointers[0].pageY + _pointers[1].pageY) / 2;
48770
- _panStart.copy(getMouseOnScreen(x, y));
48771
- _panEnd.copy(_panStart);
48772
- break;
48773
- case 3:
48774
- _state = STATE.TOUCH_PAN;
48775
- const centerX = (_pointers[0].pageX + _pointers[1].pageX + _pointers[2].pageX) / 3;
48776
- const centerY = (_pointers[0].pageY + _pointers[1].pageY + _pointers[2].pageY) / 3;
48777
- _panStart.copy(getMouseOnScreen(centerX, centerY));
48778
- _panEnd.copy(_panStart);
48779
- break;
48780
- }
48781
- scope.dispatchEvent(_startEvent$1);
48782
- }
48783
- function onTouchMove(event) {
48784
- trackPointer(event);
48785
- let position, x, y;
48786
- switch (_pointers.length) {
48787
- case 1:
48788
- if (_state != STATE.TOUCH_ROTATE)
48789
- return;
48790
- _movePrev.copy(_moveCurr);
48791
- _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
48792
- break;
48793
- case 2:
48794
- if (_state != STATE.TOUCH_ZOOM_PAN)
48795
- return;
48796
- position = getSecondPointerPosition(event);
48797
- const dx = event.pageX - position.x;
48798
- const dy = event.pageY - position.y;
48799
- _touchZoomDistanceEnd = Math.sqrt(dx * dx + dy * dy);
48800
- x = (event.pageX + position.x) / 2;
48801
- y = (event.pageY + position.y) / 2;
48802
- _panEnd.copy(getMouseOnScreen(x, y));
48803
- break;
48804
- case 3:
48805
- if (_state != STATE.TOUCH_PAN)
48806
- return;
48807
- const point_1 = _pointerPositions[_pointers[0].pointerId];
48808
- const point_2 = _pointerPositions[_pointers[1].pointerId];
48809
- const point_3 = _pointerPositions[_pointers[2].pointerId];
48810
- const centerX = (point_1.x + point_2.x + point_3.x) / 3;
48811
- const centerY = (point_1.y + point_2.y + point_3.y) / 3;
48812
- _panEnd.copy(getMouseOnScreen(centerX, centerY));
48813
- break;
48814
- }
48815
- }
48816
- function onTouchEnd(event) {
48817
- switch (_pointers.length) {
48818
- case 0:
48819
- _state = STATE.NONE;
48820
- break;
48821
- case 1:
48822
- _state = STATE.TOUCH_ROTATE;
48823
- _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
48824
- _movePrev.copy(_moveCurr);
48825
- break;
48826
- case 2:
48827
- _state = STATE.TOUCH_ZOOM_PAN;
48828
- for (let i = 0; i < _pointers.length; i++) {
48829
- if (_pointers[i].pointerId !== event.pointerId) {
48830
- const position = _pointerPositions[_pointers[i].pointerId];
48831
- _moveCurr.copy(getMouseOnScreen(position.x, position.y));
48832
- _movePrev.copy(_moveCurr);
48833
- break;
48834
- }
48835
- }
48836
- break;
48837
- case 3:
48838
- _state = STATE.TOUCH_PAN;
48839
- for (let i = 0; i < _pointers.length; i++) {
48840
- if (_pointers[i].pointerId !== event.pointerId) {
48841
- const position = _pointerPositions[_pointers[i].pointerId];
48842
- _moveCurr.copy(getMouseOnScreen(position.x, position.y));
48843
- _movePrev.copy(_moveCurr);
48844
- break;
48845
- }
48846
- }
48847
- break;
48848
- }
48849
- scope.dispatchEvent(_endEvent$1);
48850
- }
48851
- function contextmenu(event) {
48852
- if (scope.enabled === false)
48853
- return;
48854
- event.preventDefault();
48855
- }
48856
- function addPointer(event) {
48857
- _pointers.push(event);
48858
- }
48859
- function removePointer(event) {
48860
- delete _pointerPositions[event.pointerId];
48861
- for (let i = 0; i < _pointers.length; i++) {
48862
- if (_pointers[i].pointerId == event.pointerId) {
48863
- _pointers.splice(i, 1);
48864
- return;
48865
- }
48866
- }
48867
- }
48868
- function trackPointer(event) {
48869
- let position = _pointerPositions[event.pointerId];
48870
- if (position === undefined) {
48871
- position = new Vector2();
48872
- _pointerPositions[event.pointerId] = position;
48873
- }
48874
- position.set(event.pageX, event.pageY);
48875
- }
48876
- function getSecondPointerPosition(event) {
48877
- const pointer = event.pointerId === _pointers[0].pointerId
48878
- ? _pointers[1]
48879
- : _pointers[0];
48880
- return _pointerPositions[pointer.pointerId];
48881
- }
48882
- this.dispose = function () {
48883
- scope.domElement.removeEventListener("contextmenu", contextmenu);
48884
- scope.domElement.removeEventListener("pointerdown", onPointerDown);
48885
- scope.domElement.removeEventListener("pointercancel", onPointerCancel);
48886
- scope.domElement.removeEventListener("wheel", onMouseWheel);
48887
- scope.domElement.removeEventListener("pointermove", onPointerMove);
48888
- scope.domElement.removeEventListener("pointerup", onPointerUp);
48889
- window.removeEventListener("keydown", keydown);
48890
- window.removeEventListener("keyup", keyup);
48891
- };
48892
- this.domElement.addEventListener("contextmenu", contextmenu);
48893
- this.domElement.addEventListener("pointerdown", onPointerDown);
48894
- this.domElement.addEventListener("pointercancel", onPointerCancel);
48895
- this.domElement.addEventListener("wheel", onMouseWheel, { passive: false });
48896
- window.addEventListener("keydown", keydown);
48897
- window.addEventListener("keyup", keyup);
48898
- this.handleResize();
48899
- // force an update at start
48900
- this.update();
48901
- }
48902
- }
48903
-
48904
48301
  /**
48905
48302
  * @param {BufferGeometry} geometry
48906
48303
  * @param {number} drawMode
@@ -56879,7 +56276,7 @@
56879
56276
  this.controls = new OrbitControls(this.camera, this.renderer.domElement);
56880
56277
  }
56881
56278
  else {
56882
- this.controls = new Copper3dTrackballControls1(this.camera, this.renderer.domElement);
56279
+ this.controls = new Copper3dTrackballControls(this.camera, this.renderer.domElement);
56883
56280
  }
56884
56281
  this.controls.panSpeed = 3;
56885
56282
  this.controls.rotateSpeed = 3;