copper3d 1.15.2 → 1.15.4

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$2 = { type: "change" };
45221
- const _startEvent$2 = { type: "start" };
45222
- const _endEvent$2 = { type: "end" };
45220
+ const _changeEvent$3 = { type: "change" };
45221
+ const _startEvent$3 = { type: "start" };
45222
+ const _endEvent$3 = { 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$2);
45443
+ scope.dispatchEvent(_changeEvent$3);
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$2);
45451
+ scope.dispatchEvent(_changeEvent$3);
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$2);
45470
+ scope.dispatchEvent(_changeEvent$3);
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$2);
45570
+ scope.dispatchEvent(_startEvent$3);
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$2);
45587
+ scope.dispatchEvent(_endEvent$3);
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$2);
45610
- scope.dispatchEvent(_endEvent$2);
45609
+ scope.dispatchEvent(_startEvent$3);
45610
+ scope.dispatchEvent(_endEvent$3);
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
- case 2:
45620
+ default: // 2 or more
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,47 +45627,25 @@
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;
45637
45630
  }
45638
- scope.dispatchEvent(_startEvent$2);
45631
+ scope.dispatchEvent(_startEvent$3);
45639
45632
  }
45640
45633
  function onTouchMove(event) {
45641
45634
  trackPointer(event);
45642
- let position, x, y;
45643
45635
  switch (_pointers.length) {
45644
45636
  case 1:
45645
- if (_state != STATE.TOUCH_ROTATE)
45646
- return;
45647
45637
  _movePrev.copy(_moveCurr);
45648
45638
  _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
45649
45639
  break;
45650
- case 2:
45651
- if (_state != STATE.TOUCH_ZOOM_PAN)
45652
- return;
45653
- position = getSecondPointerPosition(event);
45640
+ default: // 2 or more
45641
+ const position = getSecondPointerPosition(event);
45654
45642
  const dx = event.pageX - position.x;
45655
45643
  const dy = event.pageY - position.y;
45656
45644
  _touchZoomDistanceEnd = Math.sqrt(dx * dx + dy * dy);
45657
- x = (event.pageX + position.x) / 2;
45658
- y = (event.pageY + position.y) / 2;
45645
+ const x = (event.pageX + position.x) / 2;
45646
+ const y = (event.pageY + position.y) / 2;
45659
45647
  _panEnd.copy(getMouseOnScreen(x, y));
45660
45648
  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;
45671
45649
  }
45672
45650
  }
45673
45651
  function onTouchEnd(event) {
@@ -45685,26 +45663,114 @@
45685
45663
  for (let i = 0; i < _pointers.length; i++) {
45686
45664
  if (_pointers[i].pointerId !== event.pointerId) {
45687
45665
  const position = _pointerPositions[_pointers[i].pointerId];
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));
45666
+ _moveCurr.copy(getMouseOnCircle(position.x, position.y));
45700
45667
  _movePrev.copy(_moveCurr);
45701
45668
  break;
45702
45669
  }
45703
45670
  }
45704
45671
  break;
45705
45672
  }
45706
- scope.dispatchEvent(_endEvent$2);
45673
+ scope.dispatchEvent(_endEvent$3);
45707
45674
  }
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
+ // }
45708
45774
  function contextmenu(event) {
45709
45775
  if (scope.enabled === false)
45710
45776
  return;
@@ -45765,9 +45831,9 @@
45765
45831
  // Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish
45766
45832
  // Pan - right mouse, or left mouse + ctrl/meta/shiftKey, or arrow keys / touch: two-finger move
45767
45833
 
45768
- const _changeEvent$1 = { type: 'change' };
45769
- const _startEvent$1 = { type: 'start' };
45770
- const _endEvent$1 = { type: 'end' };
45834
+ const _changeEvent$2 = { type: 'change' };
45835
+ const _startEvent$2 = { type: 'start' };
45836
+ const _endEvent$2 = { type: 'end' };
45771
45837
 
45772
45838
  class OrbitControls extends EventDispatcher {
45773
45839
 
@@ -45896,7 +45962,7 @@
45896
45962
  scope.object.zoom = scope.zoom0;
45897
45963
 
45898
45964
  scope.object.updateProjectionMatrix();
45899
- scope.dispatchEvent( _changeEvent$1 );
45965
+ scope.dispatchEvent( _changeEvent$2 );
45900
45966
 
45901
45967
  scope.update();
45902
45968
 
@@ -46030,7 +46096,7 @@
46030
46096
  lastPosition.distanceToSquared( scope.object.position ) > EPS ||
46031
46097
  8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) {
46032
46098
 
46033
- scope.dispatchEvent( _changeEvent$1 );
46099
+ scope.dispatchEvent( _changeEvent$2 );
46034
46100
 
46035
46101
  lastPosition.copy( scope.object.position );
46036
46102
  lastQuaternion.copy( scope.object.quaternion );
@@ -46644,7 +46710,7 @@
46644
46710
 
46645
46711
  }
46646
46712
 
46647
- scope.dispatchEvent( _endEvent$1 );
46713
+ scope.dispatchEvent( _endEvent$2 );
46648
46714
 
46649
46715
  state = STATE.NONE;
46650
46716
 
@@ -46741,7 +46807,7 @@
46741
46807
 
46742
46808
  if ( state !== STATE.NONE ) {
46743
46809
 
46744
- scope.dispatchEvent( _startEvent$1 );
46810
+ scope.dispatchEvent( _startEvent$2 );
46745
46811
 
46746
46812
  }
46747
46813
 
@@ -46785,11 +46851,11 @@
46785
46851
 
46786
46852
  event.preventDefault();
46787
46853
 
46788
- scope.dispatchEvent( _startEvent$1 );
46854
+ scope.dispatchEvent( _startEvent$2 );
46789
46855
 
46790
46856
  handleMouseWheel( event );
46791
46857
 
46792
- scope.dispatchEvent( _endEvent$1 );
46858
+ scope.dispatchEvent( _endEvent$2 );
46793
46859
 
46794
46860
  }
46795
46861
 
@@ -46879,7 +46945,7 @@
46879
46945
 
46880
46946
  if ( state !== STATE.NONE ) {
46881
46947
 
46882
- scope.dispatchEvent( _startEvent$1 );
46948
+ scope.dispatchEvent( _startEvent$2 );
46883
46949
 
46884
46950
  }
46885
46951
 
@@ -48298,6 +48364,508 @@
48298
48364
  }
48299
48365
  }
48300
48366
 
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_PAN: 4,
48381
+ };
48382
+ this.object = object;
48383
+ this.domElement = domElement;
48384
+ this.domElement.style.touchAction = "none"; // disable touch scroll
48385
+ // API
48386
+ this.enabled = true;
48387
+ this.screen = { left: 0, top: 0, width: 0, height: 0 };
48388
+ this.rotateSpeed = 1.0;
48389
+ this.zoomSpeed = 1.2;
48390
+ this.panSpeed = 0.3;
48391
+ this.noRotate = false;
48392
+ this.noZoom = false;
48393
+ this.noPan = false;
48394
+ this.staticMoving = false;
48395
+ this.dynamicDampingFactor = 0.2;
48396
+ this.minDistance = 0;
48397
+ this.maxDistance = Infinity;
48398
+ this.minZoom = 0;
48399
+ this.maxZoom = Infinity;
48400
+ this.keys = ["KeyA" /*A*/, "KeyS" /*S*/, "KeyD" /*D*/];
48401
+ this.mouseButtons = {
48402
+ LEFT: MOUSE.ROTATE,
48403
+ MIDDLE: MOUSE.DOLLY,
48404
+ RIGHT: MOUSE.PAN,
48405
+ };
48406
+ // internals
48407
+ this.target = new Vector3();
48408
+ const EPS = 0.000001;
48409
+ const lastPosition = new Vector3();
48410
+ let lastZoom = 1;
48411
+ let _state = STATE.NONE, _keyState = STATE.NONE, _touchZoomDistanceStart = 0, _touchZoomDistanceEnd = 0, _lastAngle = 0;
48412
+ 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 = {};
48413
+ // for reset
48414
+ this.target0 = this.target.clone();
48415
+ this.position0 = this.object.position.clone();
48416
+ this.up0 = this.object.up.clone();
48417
+ this.zoom0 = this.object.zoom;
48418
+ // methods
48419
+ this.handleResize = function () {
48420
+ const box = scope.domElement.getBoundingClientRect();
48421
+ // adjustments come from similar code in the jquery offset() function
48422
+ const d = scope.domElement.ownerDocument.documentElement;
48423
+ scope.screen.left = box.left + window.pageXOffset - d.clientLeft;
48424
+ scope.screen.top = box.top + window.pageYOffset - d.clientTop;
48425
+ scope.screen.width = box.width;
48426
+ scope.screen.height = box.height;
48427
+ };
48428
+ const getMouseOnScreen = (function () {
48429
+ const vector = new Vector2();
48430
+ return function getMouseOnScreen(pageX, pageY) {
48431
+ vector.set((pageX - scope.screen.left) / scope.screen.width, (pageY - scope.screen.top) / scope.screen.height);
48432
+ return vector;
48433
+ };
48434
+ })();
48435
+ const getMouseOnCircle = (function () {
48436
+ const vector = new Vector2();
48437
+ return function getMouseOnCircle(pageX, pageY) {
48438
+ vector.set((pageX - scope.screen.width * 0.5 - scope.screen.left) /
48439
+ (scope.screen.width * 0.5), (scope.screen.height + 2 * (scope.screen.top - pageY)) /
48440
+ scope.screen.width // screen.width intentional
48441
+ );
48442
+ return vector;
48443
+ };
48444
+ })();
48445
+ this.rotateCamera = (function () {
48446
+ const axis = new Vector3(), quaternion = new Quaternion(), eyeDirection = new Vector3(), objectUpDirection = new Vector3(), objectSidewaysDirection = new Vector3(), moveDirection = new Vector3();
48447
+ return function rotateCamera() {
48448
+ moveDirection.set(_moveCurr.x - _movePrev.x, _moveCurr.y - _movePrev.y, 0);
48449
+ let angle = moveDirection.length();
48450
+ if (angle) {
48451
+ _eye.copy(scope.object.position).sub(scope.target);
48452
+ eyeDirection.copy(_eye).normalize();
48453
+ objectUpDirection.copy(scope.object.up).normalize();
48454
+ objectSidewaysDirection
48455
+ .crossVectors(objectUpDirection, eyeDirection)
48456
+ .normalize();
48457
+ objectUpDirection.setLength(_moveCurr.y - _movePrev.y);
48458
+ objectSidewaysDirection.setLength(_moveCurr.x - _movePrev.x);
48459
+ moveDirection.copy(objectUpDirection.add(objectSidewaysDirection));
48460
+ axis.crossVectors(moveDirection, _eye).normalize();
48461
+ angle *= scope.rotateSpeed;
48462
+ quaternion.setFromAxisAngle(axis, angle);
48463
+ _eye.applyQuaternion(quaternion);
48464
+ scope.object.up.applyQuaternion(quaternion);
48465
+ _lastAxis.copy(axis);
48466
+ _lastAngle = angle;
48467
+ }
48468
+ else if (!scope.staticMoving && _lastAngle) {
48469
+ _lastAngle *= Math.sqrt(1.0 - scope.dynamicDampingFactor);
48470
+ _eye.copy(scope.object.position).sub(scope.target);
48471
+ quaternion.setFromAxisAngle(_lastAxis, _lastAngle);
48472
+ _eye.applyQuaternion(quaternion);
48473
+ scope.object.up.applyQuaternion(quaternion);
48474
+ }
48475
+ _movePrev.copy(_moveCurr);
48476
+ };
48477
+ })();
48478
+ this.zoomCamera = function () {
48479
+ let factor;
48480
+ if (_state === STATE.TOUCH_ZOOM_PAN) {
48481
+ factor = _touchZoomDistanceStart / _touchZoomDistanceEnd;
48482
+ _touchZoomDistanceStart = _touchZoomDistanceEnd;
48483
+ if (scope.object.isPerspectiveCamera) {
48484
+ _eye.multiplyScalar(factor);
48485
+ }
48486
+ else if (scope.object.isOrthographicCamera) {
48487
+ scope.object.zoom = MathUtils.clamp(scope.object.zoom / factor, scope.minZoom, scope.maxZoom);
48488
+ if (lastZoom !== scope.object.zoom) {
48489
+ scope.object.updateProjectionMatrix();
48490
+ }
48491
+ }
48492
+ else {
48493
+ console.warn("THREE.TrackballControls: Unsupported camera type");
48494
+ }
48495
+ }
48496
+ else {
48497
+ factor = 1.0 + (_zoomEnd.y - _zoomStart.y) * scope.zoomSpeed;
48498
+ if (factor !== 1.0 && factor > 0.0) {
48499
+ if (scope.object.isPerspectiveCamera) {
48500
+ _eye.multiplyScalar(factor);
48501
+ }
48502
+ else if (scope.object.isOrthographicCamera) {
48503
+ scope.object.zoom = MathUtils.clamp(scope.object.zoom / factor, scope.minZoom, scope.maxZoom);
48504
+ if (lastZoom !== scope.object.zoom) {
48505
+ scope.object.updateProjectionMatrix();
48506
+ }
48507
+ }
48508
+ else {
48509
+ console.warn("THREE.TrackballControls: Unsupported camera type");
48510
+ }
48511
+ }
48512
+ if (scope.staticMoving) {
48513
+ _zoomStart.copy(_zoomEnd);
48514
+ }
48515
+ else {
48516
+ _zoomStart.y +=
48517
+ (_zoomEnd.y - _zoomStart.y) * this.dynamicDampingFactor;
48518
+ }
48519
+ }
48520
+ };
48521
+ this.panCamera = (function () {
48522
+ const mouseChange = new Vector2(), objectUp = new Vector3(), pan = new Vector3();
48523
+ return function panCamera() {
48524
+ mouseChange.copy(_panEnd).sub(_panStart);
48525
+ if (mouseChange.lengthSq()) {
48526
+ if (scope.object.isOrthographicCamera) {
48527
+ const scale_x = (scope.object.right -
48528
+ scope.object.left) /
48529
+ scope.object.zoom /
48530
+ scope.domElement.clientWidth;
48531
+ const scale_y = (scope.object.top -
48532
+ scope.object.bottom) /
48533
+ scope.object.zoom /
48534
+ scope.domElement.clientWidth;
48535
+ mouseChange.x *= scale_x;
48536
+ mouseChange.y *= scale_y;
48537
+ }
48538
+ mouseChange.multiplyScalar(_eye.length() * scope.panSpeed);
48539
+ pan.copy(_eye).cross(scope.object.up).setLength(mouseChange.x);
48540
+ pan.add(objectUp.copy(scope.object.up).setLength(mouseChange.y));
48541
+ scope.object.position.add(pan);
48542
+ scope.target.add(pan);
48543
+ if (scope.staticMoving) {
48544
+ _panStart.copy(_panEnd);
48545
+ }
48546
+ else {
48547
+ _panStart.add(mouseChange
48548
+ .subVectors(_panEnd, _panStart)
48549
+ .multiplyScalar(scope.dynamicDampingFactor));
48550
+ }
48551
+ }
48552
+ };
48553
+ })();
48554
+ this.checkDistances = function () {
48555
+ if (!scope.noZoom || !scope.noPan) {
48556
+ if (_eye.lengthSq() > scope.maxDistance * scope.maxDistance) {
48557
+ scope.object.position.addVectors(scope.target, _eye.setLength(scope.maxDistance));
48558
+ _zoomStart.copy(_zoomEnd);
48559
+ }
48560
+ if (_eye.lengthSq() < scope.minDistance * scope.minDistance) {
48561
+ scope.object.position.addVectors(scope.target, _eye.setLength(scope.minDistance));
48562
+ _zoomStart.copy(_zoomEnd);
48563
+ }
48564
+ }
48565
+ };
48566
+ this.update = function () {
48567
+ _eye.subVectors(scope.object.position, scope.target);
48568
+ if (!scope.noRotate) {
48569
+ scope.rotateCamera();
48570
+ }
48571
+ if (!scope.noZoom) {
48572
+ scope.zoomCamera();
48573
+ }
48574
+ if (!scope.noPan) {
48575
+ scope.panCamera();
48576
+ }
48577
+ scope.object.position.addVectors(scope.target, _eye);
48578
+ if (scope.object.isPerspectiveCamera) {
48579
+ scope.checkDistances();
48580
+ scope.object.lookAt(scope.target);
48581
+ if (lastPosition.distanceToSquared(scope.object.position) > EPS) {
48582
+ scope.dispatchEvent(_changeEvent$1);
48583
+ lastPosition.copy(scope.object.position);
48584
+ }
48585
+ }
48586
+ else if (scope.object.isOrthographicCamera) {
48587
+ scope.object.lookAt(scope.target);
48588
+ if (lastPosition.distanceToSquared(scope.object.position) > EPS ||
48589
+ lastZoom !== scope.object.zoom) {
48590
+ scope.dispatchEvent(_changeEvent$1);
48591
+ lastPosition.copy(scope.object.position);
48592
+ lastZoom = scope.object.zoom;
48593
+ }
48594
+ }
48595
+ else {
48596
+ console.warn("THREE.TrackballControls: Unsupported camera type");
48597
+ }
48598
+ };
48599
+ this.reset = function () {
48600
+ _state = STATE.NONE;
48601
+ _keyState = STATE.NONE;
48602
+ scope.target.copy(scope.target0);
48603
+ scope.object.position.copy(scope.position0);
48604
+ scope.object.up.copy(scope.up0);
48605
+ scope.object.zoom = scope.zoom0;
48606
+ scope.object.updateProjectionMatrix();
48607
+ _eye.subVectors(scope.object.position, scope.target);
48608
+ scope.object.lookAt(scope.target);
48609
+ scope.dispatchEvent(_changeEvent$1);
48610
+ lastPosition.copy(scope.object.position);
48611
+ lastZoom = scope.object.zoom;
48612
+ };
48613
+ // listeners
48614
+ function onPointerDown(event) {
48615
+ if (scope.enabled === false)
48616
+ return;
48617
+ if (_pointers.length === 0) {
48618
+ scope.domElement.setPointerCapture(event.pointerId);
48619
+ scope.domElement.addEventListener("pointermove", onPointerMove);
48620
+ scope.domElement.addEventListener("pointerup", onPointerUp);
48621
+ }
48622
+ //
48623
+ addPointer(event);
48624
+ if (event.pointerType === "touch") {
48625
+ onTouchStart(event);
48626
+ }
48627
+ else {
48628
+ onMouseDown(event);
48629
+ }
48630
+ }
48631
+ function onPointerMove(event) {
48632
+ if (scope.enabled === false)
48633
+ return;
48634
+ if (event.pointerType === "touch") {
48635
+ onTouchMove(event);
48636
+ }
48637
+ else {
48638
+ onMouseMove(event);
48639
+ }
48640
+ }
48641
+ function onPointerUp(event) {
48642
+ if (scope.enabled === false)
48643
+ return;
48644
+ if (event.pointerType === "touch") {
48645
+ onTouchEnd(event);
48646
+ }
48647
+ else {
48648
+ onMouseUp();
48649
+ }
48650
+ //
48651
+ removePointer(event);
48652
+ if (_pointers.length === 0) {
48653
+ scope.domElement.releasePointerCapture(event.pointerId);
48654
+ scope.domElement.removeEventListener("pointermove", onPointerMove);
48655
+ scope.domElement.removeEventListener("pointerup", onPointerUp);
48656
+ }
48657
+ }
48658
+ function onPointerCancel(event) {
48659
+ removePointer(event);
48660
+ }
48661
+ function keydown(event) {
48662
+ if (scope.enabled === false)
48663
+ return;
48664
+ window.removeEventListener("keydown", keydown);
48665
+ if (_keyState !== STATE.NONE) {
48666
+ return;
48667
+ }
48668
+ else if (event.code === scope.keys[STATE.ROTATE] && !scope.noRotate) {
48669
+ _keyState = STATE.ROTATE;
48670
+ }
48671
+ else if (event.code === scope.keys[STATE.ZOOM] && !scope.noZoom) {
48672
+ _keyState = STATE.ZOOM;
48673
+ }
48674
+ else if (event.code === scope.keys[STATE.PAN] && !scope.noPan) {
48675
+ _keyState = STATE.PAN;
48676
+ }
48677
+ }
48678
+ function keyup() {
48679
+ if (scope.enabled === false)
48680
+ return;
48681
+ _keyState = STATE.NONE;
48682
+ window.addEventListener("keydown", keydown);
48683
+ }
48684
+ function onMouseDown(event) {
48685
+ if (_state === STATE.NONE) {
48686
+ switch (event.button) {
48687
+ case scope.mouseButtons.LEFT:
48688
+ _state = STATE.ROTATE;
48689
+ break;
48690
+ case scope.mouseButtons.MIDDLE:
48691
+ _state = STATE.ZOOM;
48692
+ break;
48693
+ case scope.mouseButtons.RIGHT:
48694
+ _state = STATE.PAN;
48695
+ break;
48696
+ }
48697
+ }
48698
+ const state = _keyState !== STATE.NONE ? _keyState : _state;
48699
+ if (state === STATE.ROTATE && !scope.noRotate) {
48700
+ _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
48701
+ _movePrev.copy(_moveCurr);
48702
+ }
48703
+ else if (state === STATE.ZOOM && !scope.noZoom) {
48704
+ _zoomStart.copy(getMouseOnScreen(event.pageX, event.pageY));
48705
+ _zoomEnd.copy(_zoomStart);
48706
+ }
48707
+ else if (state === STATE.PAN && !scope.noPan) {
48708
+ _panStart.copy(getMouseOnScreen(event.pageX, event.pageY));
48709
+ _panEnd.copy(_panStart);
48710
+ }
48711
+ scope.dispatchEvent(_startEvent$1);
48712
+ }
48713
+ function onMouseMove(event) {
48714
+ const state = _keyState !== STATE.NONE ? _keyState : _state;
48715
+ if (state === STATE.ROTATE && !scope.noRotate) {
48716
+ _movePrev.copy(_moveCurr);
48717
+ _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
48718
+ }
48719
+ else if (state === STATE.ZOOM && !scope.noZoom) {
48720
+ _zoomEnd.copy(getMouseOnScreen(event.pageX, event.pageY));
48721
+ }
48722
+ else if (state === STATE.PAN && !scope.noPan) {
48723
+ _panEnd.copy(getMouseOnScreen(event.pageX, event.pageY));
48724
+ }
48725
+ }
48726
+ function onMouseUp() {
48727
+ _state = STATE.NONE;
48728
+ scope.dispatchEvent(_endEvent$1);
48729
+ }
48730
+ function onMouseWheel(event) {
48731
+ if (scope.enabled === false)
48732
+ return;
48733
+ if (scope.noZoom === true)
48734
+ return;
48735
+ event.preventDefault();
48736
+ switch (event.deltaMode) {
48737
+ case 2:
48738
+ // Zoom in pages
48739
+ _zoomStart.y -= event.deltaY * 0.025;
48740
+ break;
48741
+ case 1:
48742
+ // Zoom in lines
48743
+ _zoomStart.y -= event.deltaY * 0.01;
48744
+ break;
48745
+ default:
48746
+ // undefined, 0, assume pixels
48747
+ _zoomStart.y -= event.deltaY * 0.00025;
48748
+ break;
48749
+ }
48750
+ scope.dispatchEvent(_startEvent$1);
48751
+ scope.dispatchEvent(_endEvent$1);
48752
+ }
48753
+ function onTouchStart(event) {
48754
+ trackPointer(event);
48755
+ switch (_pointers.length) {
48756
+ case 1:
48757
+ _state = STATE.TOUCH_ROTATE;
48758
+ _moveCurr.copy(getMouseOnCircle(_pointers[0].pageX, _pointers[0].pageY));
48759
+ _movePrev.copy(_moveCurr);
48760
+ break;
48761
+ default: // 2 or more
48762
+ _state = STATE.TOUCH_ZOOM_PAN;
48763
+ const dx = _pointers[0].pageX - _pointers[1].pageX;
48764
+ const dy = _pointers[0].pageY - _pointers[1].pageY;
48765
+ _touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt(dx * dx + dy * dy);
48766
+ const x = (_pointers[0].pageX + _pointers[1].pageX) / 2;
48767
+ const y = (_pointers[0].pageY + _pointers[1].pageY) / 2;
48768
+ _panStart.copy(getMouseOnScreen(x, y));
48769
+ _panEnd.copy(_panStart);
48770
+ break;
48771
+ }
48772
+ scope.dispatchEvent(_startEvent$1);
48773
+ }
48774
+ function onTouchMove(event) {
48775
+ trackPointer(event);
48776
+ switch (_pointers.length) {
48777
+ case 1:
48778
+ _movePrev.copy(_moveCurr);
48779
+ _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
48780
+ break;
48781
+ default: // 2 or more
48782
+ const position = getSecondPointerPosition(event);
48783
+ const dx = event.pageX - position.x;
48784
+ const dy = event.pageY - position.y;
48785
+ _touchZoomDistanceEnd = Math.sqrt(dx * dx + dy * dy);
48786
+ const x = (event.pageX + position.x) / 2;
48787
+ const y = (event.pageY + position.y) / 2;
48788
+ _panEnd.copy(getMouseOnScreen(x, y));
48789
+ break;
48790
+ }
48791
+ }
48792
+ function onTouchEnd(event) {
48793
+ switch (_pointers.length) {
48794
+ case 0:
48795
+ _state = STATE.NONE;
48796
+ break;
48797
+ case 1:
48798
+ _state = STATE.TOUCH_ROTATE;
48799
+ _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
48800
+ _movePrev.copy(_moveCurr);
48801
+ break;
48802
+ case 2:
48803
+ _state = STATE.TOUCH_ZOOM_PAN;
48804
+ for (let i = 0; i < _pointers.length; i++) {
48805
+ if (_pointers[i].pointerId !== event.pointerId) {
48806
+ const position = _pointerPositions[_pointers[i].pointerId];
48807
+ _moveCurr.copy(getMouseOnCircle(position.x, position.y));
48808
+ _movePrev.copy(_moveCurr);
48809
+ break;
48810
+ }
48811
+ }
48812
+ break;
48813
+ }
48814
+ scope.dispatchEvent(_endEvent$1);
48815
+ }
48816
+ function contextmenu(event) {
48817
+ if (scope.enabled === false)
48818
+ return;
48819
+ event.preventDefault();
48820
+ }
48821
+ function addPointer(event) {
48822
+ _pointers.push(event);
48823
+ }
48824
+ function removePointer(event) {
48825
+ delete _pointerPositions[event.pointerId];
48826
+ for (let i = 0; i < _pointers.length; i++) {
48827
+ if (_pointers[i].pointerId == event.pointerId) {
48828
+ _pointers.splice(i, 1);
48829
+ return;
48830
+ }
48831
+ }
48832
+ }
48833
+ function trackPointer(event) {
48834
+ let position = _pointerPositions[event.pointerId];
48835
+ if (position === undefined) {
48836
+ position = new Vector2();
48837
+ _pointerPositions[event.pointerId] = position;
48838
+ }
48839
+ position.set(event.pageX, event.pageY);
48840
+ }
48841
+ function getSecondPointerPosition(event) {
48842
+ const pointer = event.pointerId === _pointers[0].pointerId
48843
+ ? _pointers[1]
48844
+ : _pointers[0];
48845
+ return _pointerPositions[pointer.pointerId];
48846
+ }
48847
+ this.dispose = function () {
48848
+ scope.domElement.removeEventListener("contextmenu", contextmenu);
48849
+ scope.domElement.removeEventListener("pointerdown", onPointerDown);
48850
+ scope.domElement.removeEventListener("pointercancel", onPointerCancel);
48851
+ scope.domElement.removeEventListener("wheel", onMouseWheel);
48852
+ scope.domElement.removeEventListener("pointermove", onPointerMove);
48853
+ scope.domElement.removeEventListener("pointerup", onPointerUp);
48854
+ window.removeEventListener("keydown", keydown);
48855
+ window.removeEventListener("keyup", keyup);
48856
+ };
48857
+ this.domElement.addEventListener("contextmenu", contextmenu);
48858
+ this.domElement.addEventListener("pointerdown", onPointerDown);
48859
+ this.domElement.addEventListener("pointercancel", onPointerCancel);
48860
+ this.domElement.addEventListener("wheel", onMouseWheel, { passive: false });
48861
+ window.addEventListener("keydown", keydown);
48862
+ window.addEventListener("keyup", keyup);
48863
+ this.handleResize();
48864
+ // force an update at start
48865
+ this.update();
48866
+ }
48867
+ }
48868
+
48301
48869
  /**
48302
48870
  * @param {BufferGeometry} geometry
48303
48871
  * @param {number} drawMode
@@ -56276,7 +56844,7 @@
56276
56844
  this.controls = new OrbitControls(this.camera, this.renderer.domElement);
56277
56845
  }
56278
56846
  else {
56279
- this.controls = new Copper3dTrackballControls(this.camera, this.renderer.domElement);
56847
+ this.controls = new Copper3dTrackballControls1(this.camera, this.renderer.domElement);
56280
56848
  }
56281
56849
  this.controls.panSpeed = 3;
56282
56850
  this.controls.rotateSpeed = 3;
@@ -69779,8 +70347,8 @@
69779
70347
  }
69780
70348
 
69781
70349
  // import * as kiwrious from "copper3d_plugin_heart_k";
69782
- const REVISION = "v1.15.2";
69783
- console.log("%cCopper3D Visualisation %cBeta:v1.15.2", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
70350
+ const REVISION = "v1.15.3";
70351
+ console.log("%cCopper3D Visualisation %cBeta:v1.15.3", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
69784
70352
 
69785
70353
  exports.CameraViewPoint = CameraViewPoint;
69786
70354
  exports.Copper3dTrackballControls = Copper3dTrackballControls;