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.
@@ -45209,9 +45209,9 @@ class OBJLoader extends Loader {
45209
45209
 
45210
45210
  const objLoader = new OBJLoader();
45211
45211
 
45212
- const _changeEvent$3 = { type: "change" };
45213
- const _startEvent$3 = { type: "start" };
45214
- const _endEvent$3 = { type: "end" };
45212
+ const _changeEvent$2 = { type: "change" };
45213
+ const _startEvent$2 = { type: "start" };
45214
+ const _endEvent$2 = { type: "end" };
45215
45215
  class Copper3dTrackballControls extends EventDispatcher {
45216
45216
  constructor(object, domElement) {
45217
45217
  super();
@@ -45432,7 +45432,7 @@ class Copper3dTrackballControls extends EventDispatcher {
45432
45432
  scope.checkDistances();
45433
45433
  scope.object.lookAt(scope.target);
45434
45434
  if (lastPosition.distanceToSquared(scope.object.position) > EPS) {
45435
- scope.dispatchEvent(_changeEvent$3);
45435
+ scope.dispatchEvent(_changeEvent$2);
45436
45436
  lastPosition.copy(scope.object.position);
45437
45437
  }
45438
45438
  }
@@ -45440,7 +45440,7 @@ class Copper3dTrackballControls extends EventDispatcher {
45440
45440
  scope.object.lookAt(scope.target);
45441
45441
  if (lastPosition.distanceToSquared(scope.object.position) > EPS ||
45442
45442
  lastZoom !== scope.object.zoom) {
45443
- scope.dispatchEvent(_changeEvent$3);
45443
+ scope.dispatchEvent(_changeEvent$2);
45444
45444
  lastPosition.copy(scope.object.position);
45445
45445
  lastZoom = scope.object.zoom;
45446
45446
  }
@@ -45459,7 +45459,7 @@ class Copper3dTrackballControls extends EventDispatcher {
45459
45459
  scope.object.updateProjectionMatrix();
45460
45460
  _eye.subVectors(scope.object.position, scope.target);
45461
45461
  scope.object.lookAt(scope.target);
45462
- scope.dispatchEvent(_changeEvent$3);
45462
+ scope.dispatchEvent(_changeEvent$2);
45463
45463
  lastPosition.copy(scope.object.position);
45464
45464
  lastZoom = scope.object.zoom;
45465
45465
  };
@@ -45559,7 +45559,7 @@ class Copper3dTrackballControls extends EventDispatcher {
45559
45559
  _panStart.copy(getMouseOnScreen(event.pageX, event.pageY));
45560
45560
  _panEnd.copy(_panStart);
45561
45561
  }
45562
- scope.dispatchEvent(_startEvent$3);
45562
+ scope.dispatchEvent(_startEvent$2);
45563
45563
  }
45564
45564
  function onMouseMove(event) {
45565
45565
  const state = _keyState !== STATE.NONE ? _keyState : _state;
@@ -45576,7 +45576,7 @@ class Copper3dTrackballControls extends EventDispatcher {
45576
45576
  }
45577
45577
  function onMouseUp(event) {
45578
45578
  _state = STATE.NONE;
45579
- scope.dispatchEvent(_endEvent$3);
45579
+ scope.dispatchEvent(_endEvent$2);
45580
45580
  }
45581
45581
  function onMouseWheel(event) {
45582
45582
  if (scope.enabled === false)
@@ -45598,8 +45598,8 @@ class Copper3dTrackballControls extends EventDispatcher {
45598
45598
  _zoomStart.y -= event.deltaY * 0.00025;
45599
45599
  break;
45600
45600
  }
45601
- scope.dispatchEvent(_startEvent$3);
45602
- scope.dispatchEvent(_endEvent$3);
45601
+ scope.dispatchEvent(_startEvent$2);
45602
+ scope.dispatchEvent(_endEvent$2);
45603
45603
  }
45604
45604
  function onTouchStart(event) {
45605
45605
  trackPointer(event);
@@ -45609,7 +45609,7 @@ class Copper3dTrackballControls extends EventDispatcher {
45609
45609
  _moveCurr.copy(getMouseOnCircle(_pointers[0].pageX, _pointers[0].pageY));
45610
45610
  _movePrev.copy(_moveCurr);
45611
45611
  break;
45612
- default: // 2 or more
45612
+ case 2:
45613
45613
  _state = STATE.TOUCH_ZOOM_PAN;
45614
45614
  const dx = _pointers[0].pageX - _pointers[1].pageX;
45615
45615
  const dy = _pointers[0].pageY - _pointers[1].pageY;
@@ -45619,25 +45619,47 @@ class Copper3dTrackballControls extends EventDispatcher {
45619
45619
  _panStart.copy(getMouseOnScreen(x, y));
45620
45620
  _panEnd.copy(_panStart);
45621
45621
  break;
45622
+ case 3:
45623
+ _state = STATE.TOUCH_PAN;
45624
+ const centerX = (_pointers[0].pageX + _pointers[1].pageX + _pointers[2].pageX) / 3;
45625
+ const centerY = (_pointers[0].pageY + _pointers[1].pageY + _pointers[2].pageY) / 3;
45626
+ _panStart.copy(getMouseOnScreen(centerX, centerY));
45627
+ _panEnd.copy(_panStart);
45628
+ break;
45622
45629
  }
45623
- scope.dispatchEvent(_startEvent$3);
45630
+ scope.dispatchEvent(_startEvent$2);
45624
45631
  }
45625
45632
  function onTouchMove(event) {
45626
45633
  trackPointer(event);
45634
+ let position, x, y;
45627
45635
  switch (_pointers.length) {
45628
45636
  case 1:
45637
+ if (_state != STATE.TOUCH_ROTATE)
45638
+ return;
45629
45639
  _movePrev.copy(_moveCurr);
45630
45640
  _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
45631
45641
  break;
45632
- default: // 2 or more
45633
- const position = getSecondPointerPosition(event);
45642
+ case 2:
45643
+ if (_state != STATE.TOUCH_ZOOM_PAN)
45644
+ return;
45645
+ position = getSecondPointerPosition(event);
45634
45646
  const dx = event.pageX - position.x;
45635
45647
  const dy = event.pageY - position.y;
45636
45648
  _touchZoomDistanceEnd = Math.sqrt(dx * dx + dy * dy);
45637
- const x = (event.pageX + position.x) / 2;
45638
- const y = (event.pageY + position.y) / 2;
45649
+ x = (event.pageX + position.x) / 2;
45650
+ y = (event.pageY + position.y) / 2;
45639
45651
  _panEnd.copy(getMouseOnScreen(x, y));
45640
45652
  break;
45653
+ case 3:
45654
+ if (_state != STATE.TOUCH_PAN)
45655
+ return;
45656
+ const point_1 = _pointerPositions[_pointers[0].pointerId];
45657
+ const point_2 = _pointerPositions[_pointers[1].pointerId];
45658
+ const point_3 = _pointerPositions[_pointers[2].pointerId];
45659
+ const centerX = (point_1.x + point_2.x + point_3.x) / 3;
45660
+ const centerY = (point_1.y + point_2.y + point_3.y) / 3;
45661
+ _panEnd.copy(getMouseOnScreen(centerX, centerY));
45662
+ break;
45641
45663
  }
45642
45664
  }
45643
45665
  function onTouchEnd(event) {
@@ -45655,114 +45677,26 @@ class Copper3dTrackballControls extends EventDispatcher {
45655
45677
  for (let i = 0; i < _pointers.length; i++) {
45656
45678
  if (_pointers[i].pointerId !== event.pointerId) {
45657
45679
  const position = _pointerPositions[_pointers[i].pointerId];
45658
- _moveCurr.copy(getMouseOnCircle(position.x, position.y));
45680
+ _moveCurr.copy(getMouseOnScreen(position.x, position.y));
45681
+ _movePrev.copy(_moveCurr);
45682
+ break;
45683
+ }
45684
+ }
45685
+ break;
45686
+ case 3:
45687
+ _state = STATE.TOUCH_PAN;
45688
+ for (let i = 0; i < _pointers.length; i++) {
45689
+ if (_pointers[i].pointerId !== event.pointerId) {
45690
+ const position = _pointerPositions[_pointers[i].pointerId];
45691
+ _moveCurr.copy(getMouseOnScreen(position.x, position.y));
45659
45692
  _movePrev.copy(_moveCurr);
45660
45693
  break;
45661
45694
  }
45662
45695
  }
45663
45696
  break;
45664
45697
  }
45665
- scope.dispatchEvent(_endEvent$3);
45698
+ scope.dispatchEvent(_endEvent$2);
45666
45699
  }
45667
- // function onTouchStart(event: PointerEvent) {
45668
- // trackPointer(event);
45669
- // switch (_pointers.length) {
45670
- // case 1:
45671
- // _state = STATE.TOUCH_ROTATE;
45672
- // _moveCurr.copy(
45673
- // getMouseOnCircle(_pointers[0].pageX, _pointers[0].pageY)
45674
- // );
45675
- // _movePrev.copy(_moveCurr);
45676
- // break;
45677
- // case 2:
45678
- // _state = STATE.TOUCH_ZOOM_PAN;
45679
- // const dx: number = _pointers[0].pageX - _pointers[1].pageX;
45680
- // const dy: number = _pointers[0].pageY - _pointers[1].pageY;
45681
- // _touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt(
45682
- // dx * dx + dy * dy
45683
- // );
45684
- // const x = (_pointers[0].pageX + _pointers[1].pageX) / 2;
45685
- // const y = (_pointers[0].pageY + _pointers[1].pageY) / 2;
45686
- // _panStart.copy(getMouseOnScreen(x, y));
45687
- // _panEnd.copy(_panStart);
45688
- // break;
45689
- // case 3:
45690
- // _state = STATE.TOUCH_PAN;
45691
- // const centerX =
45692
- // (_pointers[0].pageX + _pointers[1].pageX + _pointers[2].pageX) / 3;
45693
- // const centerY =
45694
- // (_pointers[0].pageY + _pointers[1].pageY + _pointers[2].pageY) / 3;
45695
- // _panStart.copy(getMouseOnScreen(centerX, centerY));
45696
- // _panEnd.copy(_panStart);
45697
- // break;
45698
- // }
45699
- // scope.dispatchEvent(_startEvent);
45700
- // }
45701
- // function onTouchMove(event: PointerEvent) {
45702
- // trackPointer(event);
45703
- // let position: Vector2, x: number, y: number;
45704
- // switch (_pointers.length) {
45705
- // case 1:
45706
- // if (_state != STATE.TOUCH_ROTATE) return;
45707
- // _movePrev.copy(_moveCurr);
45708
- // _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
45709
- // break;
45710
- // case 2:
45711
- // if (_state != STATE.TOUCH_ZOOM_PAN) return;
45712
- // position = getSecondPointerPosition(event);
45713
- // const dx: number = event.pageX - position.x;
45714
- // const dy: number = event.pageY - position.y;
45715
- // _touchZoomDistanceEnd = Math.sqrt(dx * dx + dy * dy);
45716
- // x = (event.pageX + position.x) / 2;
45717
- // y = (event.pageY + position.y) / 2;
45718
- // _panEnd.copy(getMouseOnScreen(x, y));
45719
- // break;
45720
- // case 3:
45721
- // if (_state != STATE.TOUCH_PAN) return;
45722
- // const point_1 = _pointerPositions[_pointers[0].pointerId];
45723
- // const point_2 = _pointerPositions[_pointers[1].pointerId];
45724
- // const point_3 = _pointerPositions[_pointers[2].pointerId];
45725
- // const centerX = (point_1.x + point_2.x + point_3.x) / 3;
45726
- // const centerY = (point_1.y + point_2.y + point_3.y) / 3;
45727
- // _panEnd.copy(getMouseOnScreen(centerX, centerY));
45728
- // break;
45729
- // }
45730
- // }
45731
- // function onTouchEnd(event: PointerEvent) {
45732
- // switch (_pointers.length) {
45733
- // case 0:
45734
- // _state = STATE.NONE;
45735
- // break;
45736
- // case 1:
45737
- // _state = STATE.TOUCH_ROTATE;
45738
- // _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
45739
- // _movePrev.copy(_moveCurr);
45740
- // break;
45741
- // case 2:
45742
- // _state = STATE.TOUCH_ZOOM_PAN;
45743
- // for (let i = 0; i < _pointers.length; i++) {
45744
- // if (_pointers[i].pointerId !== event.pointerId) {
45745
- // const position = _pointerPositions[_pointers[i].pointerId];
45746
- // _moveCurr.copy(getMouseOnScreen(position.x, position.y));
45747
- // _movePrev.copy(_moveCurr);
45748
- // break;
45749
- // }
45750
- // }
45751
- // break;
45752
- // case 3:
45753
- // _state = STATE.TOUCH_PAN;
45754
- // for (let i = 0; i < _pointers.length; i++) {
45755
- // if (_pointers[i].pointerId !== event.pointerId) {
45756
- // const position = _pointerPositions[_pointers[i].pointerId];
45757
- // _moveCurr.copy(getMouseOnScreen(position.x, position.y));
45758
- // _movePrev.copy(_moveCurr);
45759
- // break;
45760
- // }
45761
- // }
45762
- // break;
45763
- // }
45764
- // scope.dispatchEvent(_endEvent);
45765
- // }
45766
45700
  function contextmenu(event) {
45767
45701
  if (scope.enabled === false)
45768
45702
  return;
@@ -45786,7 +45720,7 @@ class Copper3dTrackballControls extends EventDispatcher {
45786
45720
  position = new Vector2();
45787
45721
  _pointerPositions[event.pointerId] = position;
45788
45722
  }
45789
- position.set(event.clientX, event.clientY);
45723
+ position.set(event.pageX, event.pageY);
45790
45724
  }
45791
45725
  function getSecondPointerPosition(event) {
45792
45726
  const pointer = event.pointerId === _pointers[0].pointerId
@@ -45823,9 +45757,9 @@ class Copper3dTrackballControls extends EventDispatcher {
45823
45757
  // Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish
45824
45758
  // Pan - right mouse, or left mouse + ctrl/meta/shiftKey, or arrow keys / touch: two-finger move
45825
45759
 
45826
- const _changeEvent$2 = { type: 'change' };
45827
- const _startEvent$2 = { type: 'start' };
45828
- const _endEvent$2 = { type: 'end' };
45760
+ const _changeEvent$1 = { type: 'change' };
45761
+ const _startEvent$1 = { type: 'start' };
45762
+ const _endEvent$1 = { type: 'end' };
45829
45763
 
45830
45764
  class OrbitControls extends EventDispatcher {
45831
45765
 
@@ -45954,7 +45888,7 @@ class OrbitControls extends EventDispatcher {
45954
45888
  scope.object.zoom = scope.zoom0;
45955
45889
 
45956
45890
  scope.object.updateProjectionMatrix();
45957
- scope.dispatchEvent( _changeEvent$2 );
45891
+ scope.dispatchEvent( _changeEvent$1 );
45958
45892
 
45959
45893
  scope.update();
45960
45894
 
@@ -46088,7 +46022,7 @@ class OrbitControls extends EventDispatcher {
46088
46022
  lastPosition.distanceToSquared( scope.object.position ) > EPS ||
46089
46023
  8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) {
46090
46024
 
46091
- scope.dispatchEvent( _changeEvent$2 );
46025
+ scope.dispatchEvent( _changeEvent$1 );
46092
46026
 
46093
46027
  lastPosition.copy( scope.object.position );
46094
46028
  lastQuaternion.copy( scope.object.quaternion );
@@ -46702,7 +46636,7 @@ class OrbitControls extends EventDispatcher {
46702
46636
 
46703
46637
  }
46704
46638
 
46705
- scope.dispatchEvent( _endEvent$2 );
46639
+ scope.dispatchEvent( _endEvent$1 );
46706
46640
 
46707
46641
  state = STATE.NONE;
46708
46642
 
@@ -46799,7 +46733,7 @@ class OrbitControls extends EventDispatcher {
46799
46733
 
46800
46734
  if ( state !== STATE.NONE ) {
46801
46735
 
46802
- scope.dispatchEvent( _startEvent$2 );
46736
+ scope.dispatchEvent( _startEvent$1 );
46803
46737
 
46804
46738
  }
46805
46739
 
@@ -46843,11 +46777,11 @@ class OrbitControls extends EventDispatcher {
46843
46777
 
46844
46778
  event.preventDefault();
46845
46779
 
46846
- scope.dispatchEvent( _startEvent$2 );
46780
+ scope.dispatchEvent( _startEvent$1 );
46847
46781
 
46848
46782
  handleMouseWheel( event );
46849
46783
 
46850
- scope.dispatchEvent( _endEvent$2 );
46784
+ scope.dispatchEvent( _endEvent$1 );
46851
46785
 
46852
46786
  }
46853
46787
 
@@ -46937,7 +46871,7 @@ class OrbitControls extends EventDispatcher {
46937
46871
 
46938
46872
  if ( state !== STATE.NONE ) {
46939
46873
 
46940
- scope.dispatchEvent( _startEvent$2 );
46874
+ scope.dispatchEvent( _startEvent$1 );
46941
46875
 
46942
46876
  }
46943
46877
 
@@ -48356,543 +48290,6 @@ class baseRenderer {
48356
48290
  }
48357
48291
  }
48358
48292
 
48359
- const _changeEvent$1 = { type: "change" };
48360
- const _startEvent$1 = { type: "start" };
48361
- const _endEvent$1 = { type: "end" };
48362
- class Copper3dTrackballControls1 extends EventDispatcher {
48363
- constructor(object, domElement) {
48364
- super();
48365
- const scope = this;
48366
- const STATE = {
48367
- NONE: -1,
48368
- ROTATE: 0,
48369
- ZOOM: 1,
48370
- PAN: 2,
48371
- TOUCH_ROTATE: 3,
48372
- TOUCH_ZOOM: 4,
48373
- TOUCH_PAN: 5,
48374
- TOUCH_ZOOM_PAN: 6,
48375
- };
48376
- this.object = object;
48377
- this.domElement = domElement;
48378
- this.domElement.style.touchAction = "none"; // disable touch scroll
48379
- // API
48380
- this.enabled = true;
48381
- this.screen = { left: 0, top: 0, width: 0, height: 0 };
48382
- this.rotateSpeed = 1.0;
48383
- this.zoomSpeed = 1.2;
48384
- this.panSpeed = 0.3;
48385
- this.noRotate = false;
48386
- this.noZoom = false;
48387
- this.noPan = false;
48388
- this.staticMoving = false;
48389
- this.dynamicDampingFactor = 0.2;
48390
- this.minDistance = 0;
48391
- this.maxDistance = Infinity;
48392
- this.minZoom = 0;
48393
- this.maxZoom = Infinity;
48394
- this.keys = ["KeyA" /*A*/, "KeyS" /*S*/, "KeyD" /*D*/];
48395
- this.mouseButtons = {
48396
- LEFT: MOUSE.ROTATE,
48397
- MIDDLE: MOUSE.DOLLY,
48398
- RIGHT: MOUSE.PAN,
48399
- };
48400
- // internals
48401
- this.target = new Vector3();
48402
- const EPS = 0.000001;
48403
- const lastPosition = new Vector3();
48404
- let lastZoom = 1;
48405
- let _state = STATE.NONE, _keyState = STATE.NONE, _touchZoomDistanceStart = 0, _touchZoomDistanceEnd = 0, _lastAngle = 0;
48406
- 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 = {};
48407
- // for reset
48408
- this.target0 = this.target.clone();
48409
- this.position0 = this.object.position.clone();
48410
- this.up0 = this.object.up.clone();
48411
- this.zoom0 = this.object.zoom;
48412
- // methods
48413
- this.handleResize = function () {
48414
- const box = scope.domElement.getBoundingClientRect();
48415
- // adjustments come from similar code in the jquery offset() function
48416
- const d = scope.domElement.ownerDocument.documentElement;
48417
- scope.screen.left = box.left + window.pageXOffset - d.clientLeft;
48418
- scope.screen.top = box.top + window.pageYOffset - d.clientTop;
48419
- scope.screen.width = box.width;
48420
- scope.screen.height = box.height;
48421
- };
48422
- const getMouseOnScreen = (function () {
48423
- const vector = new Vector2();
48424
- return function getMouseOnScreen(pageX, pageY) {
48425
- vector.set((pageX - scope.screen.left) / scope.screen.width, (pageY - scope.screen.top) / scope.screen.height);
48426
- return vector;
48427
- };
48428
- })();
48429
- const getMouseOnCircle = (function () {
48430
- const vector = new Vector2();
48431
- return function getMouseOnCircle(pageX, pageY) {
48432
- vector.set((pageX - scope.screen.width * 0.5 - scope.screen.left) /
48433
- (scope.screen.width * 0.5), (scope.screen.height + 2 * (scope.screen.top - pageY)) /
48434
- scope.screen.width // screen.width intentional
48435
- );
48436
- return vector;
48437
- };
48438
- })();
48439
- this.rotateCamera = (function () {
48440
- const axis = new Vector3(), quaternion = new Quaternion(), eyeDirection = new Vector3(), objectUpDirection = new Vector3(), objectSidewaysDirection = new Vector3(), moveDirection = new Vector3();
48441
- return function rotateCamera() {
48442
- moveDirection.set(_moveCurr.x - _movePrev.x, _moveCurr.y - _movePrev.y, 0);
48443
- let angle = moveDirection.length();
48444
- if (angle) {
48445
- _eye.copy(scope.object.position).sub(scope.target);
48446
- eyeDirection.copy(_eye).normalize();
48447
- objectUpDirection.copy(scope.object.up).normalize();
48448
- objectSidewaysDirection
48449
- .crossVectors(objectUpDirection, eyeDirection)
48450
- .normalize();
48451
- objectUpDirection.setLength(_moveCurr.y - _movePrev.y);
48452
- objectSidewaysDirection.setLength(_moveCurr.x - _movePrev.x);
48453
- moveDirection.copy(objectUpDirection.add(objectSidewaysDirection));
48454
- axis.crossVectors(moveDirection, _eye).normalize();
48455
- angle *= scope.rotateSpeed;
48456
- quaternion.setFromAxisAngle(axis, angle);
48457
- _eye.applyQuaternion(quaternion);
48458
- scope.object.up.applyQuaternion(quaternion);
48459
- _lastAxis.copy(axis);
48460
- _lastAngle = angle;
48461
- }
48462
- else if (!scope.staticMoving && _lastAngle) {
48463
- _lastAngle *= Math.sqrt(1.0 - scope.dynamicDampingFactor);
48464
- _eye.copy(scope.object.position).sub(scope.target);
48465
- quaternion.setFromAxisAngle(_lastAxis, _lastAngle);
48466
- _eye.applyQuaternion(quaternion);
48467
- scope.object.up.applyQuaternion(quaternion);
48468
- }
48469
- _movePrev.copy(_moveCurr);
48470
- };
48471
- })();
48472
- this.zoomCamera = function () {
48473
- let factor;
48474
- if (_state === STATE.TOUCH_ZOOM_PAN) {
48475
- factor = _touchZoomDistanceStart / _touchZoomDistanceEnd;
48476
- _touchZoomDistanceStart = _touchZoomDistanceEnd;
48477
- if (scope.object.isPerspectiveCamera) {
48478
- _eye.multiplyScalar(factor);
48479
- }
48480
- else if (scope.object.isOrthographicCamera) {
48481
- scope.object.zoom = MathUtils.clamp(scope.object.zoom / factor, scope.minZoom, scope.maxZoom);
48482
- if (lastZoom !== scope.object.zoom) {
48483
- scope.object.updateProjectionMatrix();
48484
- }
48485
- }
48486
- else {
48487
- console.warn("THREE.TrackballControls: Unsupported camera type");
48488
- }
48489
- }
48490
- else {
48491
- factor = 1.0 + (_zoomEnd.y - _zoomStart.y) * scope.zoomSpeed;
48492
- if (factor !== 1.0 && factor > 0.0) {
48493
- if (scope.object.isPerspectiveCamera) {
48494
- _eye.multiplyScalar(factor);
48495
- }
48496
- else if (scope.object.isOrthographicCamera) {
48497
- scope.object.zoom = MathUtils.clamp(scope.object.zoom / factor, scope.minZoom, scope.maxZoom);
48498
- if (lastZoom !== scope.object.zoom) {
48499
- scope.object.updateProjectionMatrix();
48500
- }
48501
- }
48502
- else {
48503
- console.warn("THREE.TrackballControls: Unsupported camera type");
48504
- }
48505
- }
48506
- if (scope.staticMoving) {
48507
- _zoomStart.copy(_zoomEnd);
48508
- }
48509
- else {
48510
- _zoomStart.y +=
48511
- (_zoomEnd.y - _zoomStart.y) * this.dynamicDampingFactor;
48512
- }
48513
- }
48514
- };
48515
- this.panCamera = (function () {
48516
- const mouseChange = new Vector2(), objectUp = new Vector3(), pan = new Vector3();
48517
- return function panCamera() {
48518
- mouseChange.copy(_panEnd).sub(_panStart);
48519
- if (mouseChange.lengthSq()) {
48520
- if (scope.object.isOrthographicCamera) {
48521
- const scale_x = (scope.object.right -
48522
- scope.object.left) /
48523
- scope.object.zoom /
48524
- scope.domElement.clientWidth;
48525
- const scale_y = (scope.object.top -
48526
- scope.object.bottom) /
48527
- scope.object.zoom /
48528
- scope.domElement.clientWidth;
48529
- mouseChange.x *= scale_x;
48530
- mouseChange.y *= scale_y;
48531
- }
48532
- mouseChange.multiplyScalar(_eye.length() * scope.panSpeed);
48533
- pan.copy(_eye).cross(scope.object.up).setLength(mouseChange.x);
48534
- pan.add(objectUp.copy(scope.object.up).setLength(mouseChange.y));
48535
- scope.object.position.add(pan);
48536
- scope.target.add(pan);
48537
- if (scope.staticMoving) {
48538
- _panStart.copy(_panEnd);
48539
- }
48540
- else {
48541
- _panStart.add(mouseChange
48542
- .subVectors(_panEnd, _panStart)
48543
- .multiplyScalar(scope.dynamicDampingFactor));
48544
- }
48545
- }
48546
- };
48547
- })();
48548
- this.checkDistances = function () {
48549
- if (!scope.noZoom || !scope.noPan) {
48550
- if (_eye.lengthSq() > scope.maxDistance * scope.maxDistance) {
48551
- scope.object.position.addVectors(scope.target, _eye.setLength(scope.maxDistance));
48552
- _zoomStart.copy(_zoomEnd);
48553
- }
48554
- if (_eye.lengthSq() < scope.minDistance * scope.minDistance) {
48555
- scope.object.position.addVectors(scope.target, _eye.setLength(scope.minDistance));
48556
- _zoomStart.copy(_zoomEnd);
48557
- }
48558
- }
48559
- };
48560
- this.update = function () {
48561
- _eye.subVectors(scope.object.position, scope.target);
48562
- if (!scope.noRotate) {
48563
- scope.rotateCamera();
48564
- }
48565
- if (!scope.noZoom) {
48566
- scope.zoomCamera();
48567
- }
48568
- if (!scope.noPan) {
48569
- scope.panCamera();
48570
- }
48571
- scope.object.position.addVectors(scope.target, _eye);
48572
- if (scope.object.isPerspectiveCamera) {
48573
- scope.checkDistances();
48574
- scope.object.lookAt(scope.target);
48575
- if (lastPosition.distanceToSquared(scope.object.position) > EPS) {
48576
- scope.dispatchEvent(_changeEvent$1);
48577
- lastPosition.copy(scope.object.position);
48578
- }
48579
- }
48580
- else if (scope.object.isOrthographicCamera) {
48581
- scope.object.lookAt(scope.target);
48582
- if (lastPosition.distanceToSquared(scope.object.position) > EPS ||
48583
- lastZoom !== scope.object.zoom) {
48584
- scope.dispatchEvent(_changeEvent$1);
48585
- lastPosition.copy(scope.object.position);
48586
- lastZoom = scope.object.zoom;
48587
- }
48588
- }
48589
- else {
48590
- console.warn("THREE.TrackballControls: Unsupported camera type");
48591
- }
48592
- };
48593
- this.reset = function () {
48594
- _state = STATE.NONE;
48595
- _keyState = STATE.NONE;
48596
- scope.target.copy(scope.target0);
48597
- scope.object.position.copy(scope.position0);
48598
- scope.object.up.copy(scope.up0);
48599
- scope.object.zoom = scope.zoom0;
48600
- scope.object.updateProjectionMatrix();
48601
- _eye.subVectors(scope.object.position, scope.target);
48602
- scope.object.lookAt(scope.target);
48603
- scope.dispatchEvent(_changeEvent$1);
48604
- lastPosition.copy(scope.object.position);
48605
- lastZoom = scope.object.zoom;
48606
- };
48607
- // listeners
48608
- function onPointerDown(event) {
48609
- if (scope.enabled === false)
48610
- return;
48611
- if (_pointers.length === 0) {
48612
- scope.domElement.setPointerCapture(event.pointerId);
48613
- scope.domElement.addEventListener("pointermove", onPointerMove);
48614
- scope.domElement.addEventListener("pointerup", onPointerUp);
48615
- }
48616
- //
48617
- addPointer(event);
48618
- if (event.pointerType === "touch") {
48619
- onTouchStart(event);
48620
- }
48621
- else {
48622
- onMouseDown(event);
48623
- }
48624
- }
48625
- function onPointerMove(event) {
48626
- if (scope.enabled === false)
48627
- return;
48628
- if (event.pointerType === "touch") {
48629
- onTouchMove(event);
48630
- }
48631
- else {
48632
- onMouseMove(event);
48633
- }
48634
- }
48635
- function onPointerUp(event) {
48636
- if (scope.enabled === false)
48637
- return;
48638
- if (event.pointerType === "touch") {
48639
- onTouchEnd(event);
48640
- }
48641
- else {
48642
- onMouseUp();
48643
- }
48644
- //
48645
- removePointer(event);
48646
- if (_pointers.length === 0) {
48647
- scope.domElement.releasePointerCapture(event.pointerId);
48648
- scope.domElement.removeEventListener("pointermove", onPointerMove);
48649
- scope.domElement.removeEventListener("pointerup", onPointerUp);
48650
- }
48651
- }
48652
- function onPointerCancel(event) {
48653
- removePointer(event);
48654
- }
48655
- function keydown(event) {
48656
- if (scope.enabled === false)
48657
- return;
48658
- window.removeEventListener("keydown", keydown);
48659
- if (_keyState !== STATE.NONE) {
48660
- return;
48661
- }
48662
- else if (event.code === scope.keys[STATE.ROTATE] && !scope.noRotate) {
48663
- _keyState = STATE.ROTATE;
48664
- }
48665
- else if (event.code === scope.keys[STATE.ZOOM] && !scope.noZoom) {
48666
- _keyState = STATE.ZOOM;
48667
- }
48668
- else if (event.code === scope.keys[STATE.PAN] && !scope.noPan) {
48669
- _keyState = STATE.PAN;
48670
- }
48671
- }
48672
- function keyup() {
48673
- if (scope.enabled === false)
48674
- return;
48675
- _keyState = STATE.NONE;
48676
- window.addEventListener("keydown", keydown);
48677
- }
48678
- function onMouseDown(event) {
48679
- if (_state === STATE.NONE) {
48680
- switch (event.button) {
48681
- case scope.mouseButtons.LEFT:
48682
- _state = STATE.ROTATE;
48683
- break;
48684
- case scope.mouseButtons.MIDDLE:
48685
- _state = STATE.ZOOM;
48686
- break;
48687
- case scope.mouseButtons.RIGHT:
48688
- _state = STATE.PAN;
48689
- break;
48690
- }
48691
- }
48692
- const state = _keyState !== STATE.NONE ? _keyState : _state;
48693
- if (state === STATE.ROTATE && !scope.noRotate) {
48694
- _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
48695
- _movePrev.copy(_moveCurr);
48696
- }
48697
- else if (state === STATE.ZOOM && !scope.noZoom) {
48698
- _zoomStart.copy(getMouseOnScreen(event.pageX, event.pageY));
48699
- _zoomEnd.copy(_zoomStart);
48700
- }
48701
- else if (state === STATE.PAN && !scope.noPan) {
48702
- _panStart.copy(getMouseOnScreen(event.pageX, event.pageY));
48703
- _panEnd.copy(_panStart);
48704
- }
48705
- scope.dispatchEvent(_startEvent$1);
48706
- }
48707
- function onMouseMove(event) {
48708
- const state = _keyState !== STATE.NONE ? _keyState : _state;
48709
- if (state === STATE.ROTATE && !scope.noRotate) {
48710
- _movePrev.copy(_moveCurr);
48711
- _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
48712
- }
48713
- else if (state === STATE.ZOOM && !scope.noZoom) {
48714
- _zoomEnd.copy(getMouseOnScreen(event.pageX, event.pageY));
48715
- }
48716
- else if (state === STATE.PAN && !scope.noPan) {
48717
- _panEnd.copy(getMouseOnScreen(event.pageX, event.pageY));
48718
- }
48719
- }
48720
- function onMouseUp() {
48721
- _state = STATE.NONE;
48722
- scope.dispatchEvent(_endEvent$1);
48723
- }
48724
- function onMouseWheel(event) {
48725
- if (scope.enabled === false)
48726
- return;
48727
- if (scope.noZoom === true)
48728
- return;
48729
- event.preventDefault();
48730
- switch (event.deltaMode) {
48731
- case 2:
48732
- // Zoom in pages
48733
- _zoomStart.y -= event.deltaY * 0.025;
48734
- break;
48735
- case 1:
48736
- // Zoom in lines
48737
- _zoomStart.y -= event.deltaY * 0.01;
48738
- break;
48739
- default:
48740
- // undefined, 0, assume pixels
48741
- _zoomStart.y -= event.deltaY * 0.00025;
48742
- break;
48743
- }
48744
- scope.dispatchEvent(_startEvent$1);
48745
- scope.dispatchEvent(_endEvent$1);
48746
- }
48747
- function onTouchStart(event) {
48748
- trackPointer(event);
48749
- switch (_pointers.length) {
48750
- case 1:
48751
- _state = STATE.TOUCH_ROTATE;
48752
- _moveCurr.copy(getMouseOnCircle(_pointers[0].pageX, _pointers[0].pageY));
48753
- _movePrev.copy(_moveCurr);
48754
- break;
48755
- case 2:
48756
- _state = STATE.TOUCH_ZOOM_PAN;
48757
- const dx = _pointers[0].pageX - _pointers[1].pageX;
48758
- const dy = _pointers[0].pageY - _pointers[1].pageY;
48759
- _touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt(dx * dx + dy * dy);
48760
- const x = (_pointers[0].pageX + _pointers[1].pageX) / 2;
48761
- const y = (_pointers[0].pageY + _pointers[1].pageY) / 2;
48762
- _panStart.copy(getMouseOnScreen(x, y));
48763
- _panEnd.copy(_panStart);
48764
- break;
48765
- case 3:
48766
- _state = STATE.TOUCH_PAN;
48767
- const centerX = (_pointers[0].pageX + _pointers[1].pageX + _pointers[2].pageX) / 3;
48768
- const centerY = (_pointers[0].pageY + _pointers[1].pageY + _pointers[2].pageY) / 3;
48769
- _panStart.copy(getMouseOnScreen(centerX, centerY));
48770
- _panEnd.copy(_panStart);
48771
- break;
48772
- }
48773
- scope.dispatchEvent(_startEvent$1);
48774
- }
48775
- function onTouchMove(event) {
48776
- trackPointer(event);
48777
- let position, x, y;
48778
- switch (_pointers.length) {
48779
- case 1:
48780
- if (_state != STATE.TOUCH_ROTATE)
48781
- return;
48782
- _movePrev.copy(_moveCurr);
48783
- _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
48784
- break;
48785
- case 2:
48786
- if (_state != STATE.TOUCH_ZOOM_PAN)
48787
- return;
48788
- position = getSecondPointerPosition(event);
48789
- const dx = event.pageX - position.x;
48790
- const dy = event.pageY - position.y;
48791
- _touchZoomDistanceEnd = Math.sqrt(dx * dx + dy * dy);
48792
- x = (event.pageX + position.x) / 2;
48793
- y = (event.pageY + position.y) / 2;
48794
- _panEnd.copy(getMouseOnScreen(x, y));
48795
- break;
48796
- case 3:
48797
- if (_state != STATE.TOUCH_PAN)
48798
- return;
48799
- const point_1 = _pointerPositions[_pointers[0].pointerId];
48800
- const point_2 = _pointerPositions[_pointers[1].pointerId];
48801
- const point_3 = _pointerPositions[_pointers[2].pointerId];
48802
- const centerX = (point_1.x + point_2.x + point_3.x) / 3;
48803
- const centerY = (point_1.y + point_2.y + point_3.y) / 3;
48804
- _panEnd.copy(getMouseOnScreen(centerX, centerY));
48805
- break;
48806
- }
48807
- }
48808
- function onTouchEnd(event) {
48809
- switch (_pointers.length) {
48810
- case 0:
48811
- _state = STATE.NONE;
48812
- break;
48813
- case 1:
48814
- _state = STATE.TOUCH_ROTATE;
48815
- _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
48816
- _movePrev.copy(_moveCurr);
48817
- break;
48818
- case 2:
48819
- _state = STATE.TOUCH_ZOOM_PAN;
48820
- for (let i = 0; i < _pointers.length; i++) {
48821
- if (_pointers[i].pointerId !== event.pointerId) {
48822
- const position = _pointerPositions[_pointers[i].pointerId];
48823
- _moveCurr.copy(getMouseOnScreen(position.x, position.y));
48824
- _movePrev.copy(_moveCurr);
48825
- break;
48826
- }
48827
- }
48828
- break;
48829
- case 3:
48830
- _state = STATE.TOUCH_PAN;
48831
- for (let i = 0; i < _pointers.length; i++) {
48832
- if (_pointers[i].pointerId !== event.pointerId) {
48833
- const position = _pointerPositions[_pointers[i].pointerId];
48834
- _moveCurr.copy(getMouseOnScreen(position.x, position.y));
48835
- _movePrev.copy(_moveCurr);
48836
- break;
48837
- }
48838
- }
48839
- break;
48840
- }
48841
- scope.dispatchEvent(_endEvent$1);
48842
- }
48843
- function contextmenu(event) {
48844
- if (scope.enabled === false)
48845
- return;
48846
- event.preventDefault();
48847
- }
48848
- function addPointer(event) {
48849
- _pointers.push(event);
48850
- }
48851
- function removePointer(event) {
48852
- delete _pointerPositions[event.pointerId];
48853
- for (let i = 0; i < _pointers.length; i++) {
48854
- if (_pointers[i].pointerId == event.pointerId) {
48855
- _pointers.splice(i, 1);
48856
- return;
48857
- }
48858
- }
48859
- }
48860
- function trackPointer(event) {
48861
- let position = _pointerPositions[event.pointerId];
48862
- if (position === undefined) {
48863
- position = new Vector2();
48864
- _pointerPositions[event.pointerId] = position;
48865
- }
48866
- position.set(event.pageX, event.pageY);
48867
- }
48868
- function getSecondPointerPosition(event) {
48869
- const pointer = event.pointerId === _pointers[0].pointerId
48870
- ? _pointers[1]
48871
- : _pointers[0];
48872
- return _pointerPositions[pointer.pointerId];
48873
- }
48874
- this.dispose = function () {
48875
- scope.domElement.removeEventListener("contextmenu", contextmenu);
48876
- scope.domElement.removeEventListener("pointerdown", onPointerDown);
48877
- scope.domElement.removeEventListener("pointercancel", onPointerCancel);
48878
- scope.domElement.removeEventListener("wheel", onMouseWheel);
48879
- scope.domElement.removeEventListener("pointermove", onPointerMove);
48880
- scope.domElement.removeEventListener("pointerup", onPointerUp);
48881
- window.removeEventListener("keydown", keydown);
48882
- window.removeEventListener("keyup", keyup);
48883
- };
48884
- this.domElement.addEventListener("contextmenu", contextmenu);
48885
- this.domElement.addEventListener("pointerdown", onPointerDown);
48886
- this.domElement.addEventListener("pointercancel", onPointerCancel);
48887
- this.domElement.addEventListener("wheel", onMouseWheel, { passive: false });
48888
- window.addEventListener("keydown", keydown);
48889
- window.addEventListener("keyup", keyup);
48890
- this.handleResize();
48891
- // force an update at start
48892
- this.update();
48893
- }
48894
- }
48895
-
48896
48293
  /**
48897
48294
  * @param {BufferGeometry} geometry
48898
48295
  * @param {number} drawMode
@@ -56871,7 +56268,7 @@ class copperScene extends baseScene {
56871
56268
  this.controls = new OrbitControls(this.camera, this.renderer.domElement);
56872
56269
  }
56873
56270
  else {
56874
- this.controls = new Copper3dTrackballControls1(this.camera, this.renderer.domElement);
56271
+ this.controls = new Copper3dTrackballControls(this.camera, this.renderer.domElement);
56875
56272
  }
56876
56273
  this.controls.panSpeed = 3;
56877
56274
  this.controls.rotateSpeed = 3;