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.
@@ -45209,9 +45209,9 @@ class OBJLoader extends Loader {
45209
45209
 
45210
45210
  const objLoader = new OBJLoader();
45211
45211
 
45212
- const _changeEvent$2 = { type: "change" };
45213
- const _startEvent$2 = { type: "start" };
45214
- const _endEvent$2 = { type: "end" };
45212
+ const _changeEvent$3 = { type: "change" };
45213
+ const _startEvent$3 = { type: "start" };
45214
+ const _endEvent$3 = { 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$2);
45435
+ scope.dispatchEvent(_changeEvent$3);
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$2);
45443
+ scope.dispatchEvent(_changeEvent$3);
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$2);
45462
+ scope.dispatchEvent(_changeEvent$3);
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$2);
45562
+ scope.dispatchEvent(_startEvent$3);
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$2);
45579
+ scope.dispatchEvent(_endEvent$3);
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$2);
45602
- scope.dispatchEvent(_endEvent$2);
45601
+ scope.dispatchEvent(_startEvent$3);
45602
+ scope.dispatchEvent(_endEvent$3);
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
- case 2:
45612
+ default: // 2 or more
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,47 +45619,25 @@ 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;
45629
45622
  }
45630
- scope.dispatchEvent(_startEvent$2);
45623
+ scope.dispatchEvent(_startEvent$3);
45631
45624
  }
45632
45625
  function onTouchMove(event) {
45633
45626
  trackPointer(event);
45634
- let position, x, y;
45635
45627
  switch (_pointers.length) {
45636
45628
  case 1:
45637
- if (_state != STATE.TOUCH_ROTATE)
45638
- return;
45639
45629
  _movePrev.copy(_moveCurr);
45640
45630
  _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
45641
45631
  break;
45642
- case 2:
45643
- if (_state != STATE.TOUCH_ZOOM_PAN)
45644
- return;
45645
- position = getSecondPointerPosition(event);
45632
+ default: // 2 or more
45633
+ const position = getSecondPointerPosition(event);
45646
45634
  const dx = event.pageX - position.x;
45647
45635
  const dy = event.pageY - position.y;
45648
45636
  _touchZoomDistanceEnd = Math.sqrt(dx * dx + dy * dy);
45649
- x = (event.pageX + position.x) / 2;
45650
- y = (event.pageY + position.y) / 2;
45637
+ const x = (event.pageX + position.x) / 2;
45638
+ const y = (event.pageY + position.y) / 2;
45651
45639
  _panEnd.copy(getMouseOnScreen(x, y));
45652
45640
  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;
45663
45641
  }
45664
45642
  }
45665
45643
  function onTouchEnd(event) {
@@ -45677,26 +45655,114 @@ class Copper3dTrackballControls extends EventDispatcher {
45677
45655
  for (let i = 0; i < _pointers.length; i++) {
45678
45656
  if (_pointers[i].pointerId !== event.pointerId) {
45679
45657
  const position = _pointerPositions[_pointers[i].pointerId];
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));
45658
+ _moveCurr.copy(getMouseOnCircle(position.x, position.y));
45692
45659
  _movePrev.copy(_moveCurr);
45693
45660
  break;
45694
45661
  }
45695
45662
  }
45696
45663
  break;
45697
45664
  }
45698
- scope.dispatchEvent(_endEvent$2);
45665
+ scope.dispatchEvent(_endEvent$3);
45699
45666
  }
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
+ // }
45700
45766
  function contextmenu(event) {
45701
45767
  if (scope.enabled === false)
45702
45768
  return;
@@ -45757,9 +45823,9 @@ class Copper3dTrackballControls extends EventDispatcher {
45757
45823
  // Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish
45758
45824
  // Pan - right mouse, or left mouse + ctrl/meta/shiftKey, or arrow keys / touch: two-finger move
45759
45825
 
45760
- const _changeEvent$1 = { type: 'change' };
45761
- const _startEvent$1 = { type: 'start' };
45762
- const _endEvent$1 = { type: 'end' };
45826
+ const _changeEvent$2 = { type: 'change' };
45827
+ const _startEvent$2 = { type: 'start' };
45828
+ const _endEvent$2 = { type: 'end' };
45763
45829
 
45764
45830
  class OrbitControls extends EventDispatcher {
45765
45831
 
@@ -45888,7 +45954,7 @@ class OrbitControls extends EventDispatcher {
45888
45954
  scope.object.zoom = scope.zoom0;
45889
45955
 
45890
45956
  scope.object.updateProjectionMatrix();
45891
- scope.dispatchEvent( _changeEvent$1 );
45957
+ scope.dispatchEvent( _changeEvent$2 );
45892
45958
 
45893
45959
  scope.update();
45894
45960
 
@@ -46022,7 +46088,7 @@ class OrbitControls extends EventDispatcher {
46022
46088
  lastPosition.distanceToSquared( scope.object.position ) > EPS ||
46023
46089
  8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) {
46024
46090
 
46025
- scope.dispatchEvent( _changeEvent$1 );
46091
+ scope.dispatchEvent( _changeEvent$2 );
46026
46092
 
46027
46093
  lastPosition.copy( scope.object.position );
46028
46094
  lastQuaternion.copy( scope.object.quaternion );
@@ -46636,7 +46702,7 @@ class OrbitControls extends EventDispatcher {
46636
46702
 
46637
46703
  }
46638
46704
 
46639
- scope.dispatchEvent( _endEvent$1 );
46705
+ scope.dispatchEvent( _endEvent$2 );
46640
46706
 
46641
46707
  state = STATE.NONE;
46642
46708
 
@@ -46733,7 +46799,7 @@ class OrbitControls extends EventDispatcher {
46733
46799
 
46734
46800
  if ( state !== STATE.NONE ) {
46735
46801
 
46736
- scope.dispatchEvent( _startEvent$1 );
46802
+ scope.dispatchEvent( _startEvent$2 );
46737
46803
 
46738
46804
  }
46739
46805
 
@@ -46777,11 +46843,11 @@ class OrbitControls extends EventDispatcher {
46777
46843
 
46778
46844
  event.preventDefault();
46779
46845
 
46780
- scope.dispatchEvent( _startEvent$1 );
46846
+ scope.dispatchEvent( _startEvent$2 );
46781
46847
 
46782
46848
  handleMouseWheel( event );
46783
46849
 
46784
- scope.dispatchEvent( _endEvent$1 );
46850
+ scope.dispatchEvent( _endEvent$2 );
46785
46851
 
46786
46852
  }
46787
46853
 
@@ -46871,7 +46937,7 @@ class OrbitControls extends EventDispatcher {
46871
46937
 
46872
46938
  if ( state !== STATE.NONE ) {
46873
46939
 
46874
- scope.dispatchEvent( _startEvent$1 );
46940
+ scope.dispatchEvent( _startEvent$2 );
46875
46941
 
46876
46942
  }
46877
46943
 
@@ -48290,6 +48356,508 @@ class baseRenderer {
48290
48356
  }
48291
48357
  }
48292
48358
 
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_PAN: 4,
48373
+ };
48374
+ this.object = object;
48375
+ this.domElement = domElement;
48376
+ this.domElement.style.touchAction = "none"; // disable touch scroll
48377
+ // API
48378
+ this.enabled = true;
48379
+ this.screen = { left: 0, top: 0, width: 0, height: 0 };
48380
+ this.rotateSpeed = 1.0;
48381
+ this.zoomSpeed = 1.2;
48382
+ this.panSpeed = 0.3;
48383
+ this.noRotate = false;
48384
+ this.noZoom = false;
48385
+ this.noPan = false;
48386
+ this.staticMoving = false;
48387
+ this.dynamicDampingFactor = 0.2;
48388
+ this.minDistance = 0;
48389
+ this.maxDistance = Infinity;
48390
+ this.minZoom = 0;
48391
+ this.maxZoom = Infinity;
48392
+ this.keys = ["KeyA" /*A*/, "KeyS" /*S*/, "KeyD" /*D*/];
48393
+ this.mouseButtons = {
48394
+ LEFT: MOUSE.ROTATE,
48395
+ MIDDLE: MOUSE.DOLLY,
48396
+ RIGHT: MOUSE.PAN,
48397
+ };
48398
+ // internals
48399
+ this.target = new Vector3();
48400
+ const EPS = 0.000001;
48401
+ const lastPosition = new Vector3();
48402
+ let lastZoom = 1;
48403
+ let _state = STATE.NONE, _keyState = STATE.NONE, _touchZoomDistanceStart = 0, _touchZoomDistanceEnd = 0, _lastAngle = 0;
48404
+ 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 = {};
48405
+ // for reset
48406
+ this.target0 = this.target.clone();
48407
+ this.position0 = this.object.position.clone();
48408
+ this.up0 = this.object.up.clone();
48409
+ this.zoom0 = this.object.zoom;
48410
+ // methods
48411
+ this.handleResize = function () {
48412
+ const box = scope.domElement.getBoundingClientRect();
48413
+ // adjustments come from similar code in the jquery offset() function
48414
+ const d = scope.domElement.ownerDocument.documentElement;
48415
+ scope.screen.left = box.left + window.pageXOffset - d.clientLeft;
48416
+ scope.screen.top = box.top + window.pageYOffset - d.clientTop;
48417
+ scope.screen.width = box.width;
48418
+ scope.screen.height = box.height;
48419
+ };
48420
+ const getMouseOnScreen = (function () {
48421
+ const vector = new Vector2();
48422
+ return function getMouseOnScreen(pageX, pageY) {
48423
+ vector.set((pageX - scope.screen.left) / scope.screen.width, (pageY - scope.screen.top) / scope.screen.height);
48424
+ return vector;
48425
+ };
48426
+ })();
48427
+ const getMouseOnCircle = (function () {
48428
+ const vector = new Vector2();
48429
+ return function getMouseOnCircle(pageX, pageY) {
48430
+ vector.set((pageX - scope.screen.width * 0.5 - scope.screen.left) /
48431
+ (scope.screen.width * 0.5), (scope.screen.height + 2 * (scope.screen.top - pageY)) /
48432
+ scope.screen.width // screen.width intentional
48433
+ );
48434
+ return vector;
48435
+ };
48436
+ })();
48437
+ this.rotateCamera = (function () {
48438
+ const axis = new Vector3(), quaternion = new Quaternion(), eyeDirection = new Vector3(), objectUpDirection = new Vector3(), objectSidewaysDirection = new Vector3(), moveDirection = new Vector3();
48439
+ return function rotateCamera() {
48440
+ moveDirection.set(_moveCurr.x - _movePrev.x, _moveCurr.y - _movePrev.y, 0);
48441
+ let angle = moveDirection.length();
48442
+ if (angle) {
48443
+ _eye.copy(scope.object.position).sub(scope.target);
48444
+ eyeDirection.copy(_eye).normalize();
48445
+ objectUpDirection.copy(scope.object.up).normalize();
48446
+ objectSidewaysDirection
48447
+ .crossVectors(objectUpDirection, eyeDirection)
48448
+ .normalize();
48449
+ objectUpDirection.setLength(_moveCurr.y - _movePrev.y);
48450
+ objectSidewaysDirection.setLength(_moveCurr.x - _movePrev.x);
48451
+ moveDirection.copy(objectUpDirection.add(objectSidewaysDirection));
48452
+ axis.crossVectors(moveDirection, _eye).normalize();
48453
+ angle *= scope.rotateSpeed;
48454
+ quaternion.setFromAxisAngle(axis, angle);
48455
+ _eye.applyQuaternion(quaternion);
48456
+ scope.object.up.applyQuaternion(quaternion);
48457
+ _lastAxis.copy(axis);
48458
+ _lastAngle = angle;
48459
+ }
48460
+ else if (!scope.staticMoving && _lastAngle) {
48461
+ _lastAngle *= Math.sqrt(1.0 - scope.dynamicDampingFactor);
48462
+ _eye.copy(scope.object.position).sub(scope.target);
48463
+ quaternion.setFromAxisAngle(_lastAxis, _lastAngle);
48464
+ _eye.applyQuaternion(quaternion);
48465
+ scope.object.up.applyQuaternion(quaternion);
48466
+ }
48467
+ _movePrev.copy(_moveCurr);
48468
+ };
48469
+ })();
48470
+ this.zoomCamera = function () {
48471
+ let factor;
48472
+ if (_state === STATE.TOUCH_ZOOM_PAN) {
48473
+ factor = _touchZoomDistanceStart / _touchZoomDistanceEnd;
48474
+ _touchZoomDistanceStart = _touchZoomDistanceEnd;
48475
+ if (scope.object.isPerspectiveCamera) {
48476
+ _eye.multiplyScalar(factor);
48477
+ }
48478
+ else if (scope.object.isOrthographicCamera) {
48479
+ scope.object.zoom = MathUtils.clamp(scope.object.zoom / factor, scope.minZoom, scope.maxZoom);
48480
+ if (lastZoom !== scope.object.zoom) {
48481
+ scope.object.updateProjectionMatrix();
48482
+ }
48483
+ }
48484
+ else {
48485
+ console.warn("THREE.TrackballControls: Unsupported camera type");
48486
+ }
48487
+ }
48488
+ else {
48489
+ factor = 1.0 + (_zoomEnd.y - _zoomStart.y) * scope.zoomSpeed;
48490
+ if (factor !== 1.0 && factor > 0.0) {
48491
+ if (scope.object.isPerspectiveCamera) {
48492
+ _eye.multiplyScalar(factor);
48493
+ }
48494
+ else if (scope.object.isOrthographicCamera) {
48495
+ scope.object.zoom = MathUtils.clamp(scope.object.zoom / factor, scope.minZoom, scope.maxZoom);
48496
+ if (lastZoom !== scope.object.zoom) {
48497
+ scope.object.updateProjectionMatrix();
48498
+ }
48499
+ }
48500
+ else {
48501
+ console.warn("THREE.TrackballControls: Unsupported camera type");
48502
+ }
48503
+ }
48504
+ if (scope.staticMoving) {
48505
+ _zoomStart.copy(_zoomEnd);
48506
+ }
48507
+ else {
48508
+ _zoomStart.y +=
48509
+ (_zoomEnd.y - _zoomStart.y) * this.dynamicDampingFactor;
48510
+ }
48511
+ }
48512
+ };
48513
+ this.panCamera = (function () {
48514
+ const mouseChange = new Vector2(), objectUp = new Vector3(), pan = new Vector3();
48515
+ return function panCamera() {
48516
+ mouseChange.copy(_panEnd).sub(_panStart);
48517
+ if (mouseChange.lengthSq()) {
48518
+ if (scope.object.isOrthographicCamera) {
48519
+ const scale_x = (scope.object.right -
48520
+ scope.object.left) /
48521
+ scope.object.zoom /
48522
+ scope.domElement.clientWidth;
48523
+ const scale_y = (scope.object.top -
48524
+ scope.object.bottom) /
48525
+ scope.object.zoom /
48526
+ scope.domElement.clientWidth;
48527
+ mouseChange.x *= scale_x;
48528
+ mouseChange.y *= scale_y;
48529
+ }
48530
+ mouseChange.multiplyScalar(_eye.length() * scope.panSpeed);
48531
+ pan.copy(_eye).cross(scope.object.up).setLength(mouseChange.x);
48532
+ pan.add(objectUp.copy(scope.object.up).setLength(mouseChange.y));
48533
+ scope.object.position.add(pan);
48534
+ scope.target.add(pan);
48535
+ if (scope.staticMoving) {
48536
+ _panStart.copy(_panEnd);
48537
+ }
48538
+ else {
48539
+ _panStart.add(mouseChange
48540
+ .subVectors(_panEnd, _panStart)
48541
+ .multiplyScalar(scope.dynamicDampingFactor));
48542
+ }
48543
+ }
48544
+ };
48545
+ })();
48546
+ this.checkDistances = function () {
48547
+ if (!scope.noZoom || !scope.noPan) {
48548
+ if (_eye.lengthSq() > scope.maxDistance * scope.maxDistance) {
48549
+ scope.object.position.addVectors(scope.target, _eye.setLength(scope.maxDistance));
48550
+ _zoomStart.copy(_zoomEnd);
48551
+ }
48552
+ if (_eye.lengthSq() < scope.minDistance * scope.minDistance) {
48553
+ scope.object.position.addVectors(scope.target, _eye.setLength(scope.minDistance));
48554
+ _zoomStart.copy(_zoomEnd);
48555
+ }
48556
+ }
48557
+ };
48558
+ this.update = function () {
48559
+ _eye.subVectors(scope.object.position, scope.target);
48560
+ if (!scope.noRotate) {
48561
+ scope.rotateCamera();
48562
+ }
48563
+ if (!scope.noZoom) {
48564
+ scope.zoomCamera();
48565
+ }
48566
+ if (!scope.noPan) {
48567
+ scope.panCamera();
48568
+ }
48569
+ scope.object.position.addVectors(scope.target, _eye);
48570
+ if (scope.object.isPerspectiveCamera) {
48571
+ scope.checkDistances();
48572
+ scope.object.lookAt(scope.target);
48573
+ if (lastPosition.distanceToSquared(scope.object.position) > EPS) {
48574
+ scope.dispatchEvent(_changeEvent$1);
48575
+ lastPosition.copy(scope.object.position);
48576
+ }
48577
+ }
48578
+ else if (scope.object.isOrthographicCamera) {
48579
+ scope.object.lookAt(scope.target);
48580
+ if (lastPosition.distanceToSquared(scope.object.position) > EPS ||
48581
+ lastZoom !== scope.object.zoom) {
48582
+ scope.dispatchEvent(_changeEvent$1);
48583
+ lastPosition.copy(scope.object.position);
48584
+ lastZoom = scope.object.zoom;
48585
+ }
48586
+ }
48587
+ else {
48588
+ console.warn("THREE.TrackballControls: Unsupported camera type");
48589
+ }
48590
+ };
48591
+ this.reset = function () {
48592
+ _state = STATE.NONE;
48593
+ _keyState = STATE.NONE;
48594
+ scope.target.copy(scope.target0);
48595
+ scope.object.position.copy(scope.position0);
48596
+ scope.object.up.copy(scope.up0);
48597
+ scope.object.zoom = scope.zoom0;
48598
+ scope.object.updateProjectionMatrix();
48599
+ _eye.subVectors(scope.object.position, scope.target);
48600
+ scope.object.lookAt(scope.target);
48601
+ scope.dispatchEvent(_changeEvent$1);
48602
+ lastPosition.copy(scope.object.position);
48603
+ lastZoom = scope.object.zoom;
48604
+ };
48605
+ // listeners
48606
+ function onPointerDown(event) {
48607
+ if (scope.enabled === false)
48608
+ return;
48609
+ if (_pointers.length === 0) {
48610
+ scope.domElement.setPointerCapture(event.pointerId);
48611
+ scope.domElement.addEventListener("pointermove", onPointerMove);
48612
+ scope.domElement.addEventListener("pointerup", onPointerUp);
48613
+ }
48614
+ //
48615
+ addPointer(event);
48616
+ if (event.pointerType === "touch") {
48617
+ onTouchStart(event);
48618
+ }
48619
+ else {
48620
+ onMouseDown(event);
48621
+ }
48622
+ }
48623
+ function onPointerMove(event) {
48624
+ if (scope.enabled === false)
48625
+ return;
48626
+ if (event.pointerType === "touch") {
48627
+ onTouchMove(event);
48628
+ }
48629
+ else {
48630
+ onMouseMove(event);
48631
+ }
48632
+ }
48633
+ function onPointerUp(event) {
48634
+ if (scope.enabled === false)
48635
+ return;
48636
+ if (event.pointerType === "touch") {
48637
+ onTouchEnd(event);
48638
+ }
48639
+ else {
48640
+ onMouseUp();
48641
+ }
48642
+ //
48643
+ removePointer(event);
48644
+ if (_pointers.length === 0) {
48645
+ scope.domElement.releasePointerCapture(event.pointerId);
48646
+ scope.domElement.removeEventListener("pointermove", onPointerMove);
48647
+ scope.domElement.removeEventListener("pointerup", onPointerUp);
48648
+ }
48649
+ }
48650
+ function onPointerCancel(event) {
48651
+ removePointer(event);
48652
+ }
48653
+ function keydown(event) {
48654
+ if (scope.enabled === false)
48655
+ return;
48656
+ window.removeEventListener("keydown", keydown);
48657
+ if (_keyState !== STATE.NONE) {
48658
+ return;
48659
+ }
48660
+ else if (event.code === scope.keys[STATE.ROTATE] && !scope.noRotate) {
48661
+ _keyState = STATE.ROTATE;
48662
+ }
48663
+ else if (event.code === scope.keys[STATE.ZOOM] && !scope.noZoom) {
48664
+ _keyState = STATE.ZOOM;
48665
+ }
48666
+ else if (event.code === scope.keys[STATE.PAN] && !scope.noPan) {
48667
+ _keyState = STATE.PAN;
48668
+ }
48669
+ }
48670
+ function keyup() {
48671
+ if (scope.enabled === false)
48672
+ return;
48673
+ _keyState = STATE.NONE;
48674
+ window.addEventListener("keydown", keydown);
48675
+ }
48676
+ function onMouseDown(event) {
48677
+ if (_state === STATE.NONE) {
48678
+ switch (event.button) {
48679
+ case scope.mouseButtons.LEFT:
48680
+ _state = STATE.ROTATE;
48681
+ break;
48682
+ case scope.mouseButtons.MIDDLE:
48683
+ _state = STATE.ZOOM;
48684
+ break;
48685
+ case scope.mouseButtons.RIGHT:
48686
+ _state = STATE.PAN;
48687
+ break;
48688
+ }
48689
+ }
48690
+ const state = _keyState !== STATE.NONE ? _keyState : _state;
48691
+ if (state === STATE.ROTATE && !scope.noRotate) {
48692
+ _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
48693
+ _movePrev.copy(_moveCurr);
48694
+ }
48695
+ else if (state === STATE.ZOOM && !scope.noZoom) {
48696
+ _zoomStart.copy(getMouseOnScreen(event.pageX, event.pageY));
48697
+ _zoomEnd.copy(_zoomStart);
48698
+ }
48699
+ else if (state === STATE.PAN && !scope.noPan) {
48700
+ _panStart.copy(getMouseOnScreen(event.pageX, event.pageY));
48701
+ _panEnd.copy(_panStart);
48702
+ }
48703
+ scope.dispatchEvent(_startEvent$1);
48704
+ }
48705
+ function onMouseMove(event) {
48706
+ const state = _keyState !== STATE.NONE ? _keyState : _state;
48707
+ if (state === STATE.ROTATE && !scope.noRotate) {
48708
+ _movePrev.copy(_moveCurr);
48709
+ _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
48710
+ }
48711
+ else if (state === STATE.ZOOM && !scope.noZoom) {
48712
+ _zoomEnd.copy(getMouseOnScreen(event.pageX, event.pageY));
48713
+ }
48714
+ else if (state === STATE.PAN && !scope.noPan) {
48715
+ _panEnd.copy(getMouseOnScreen(event.pageX, event.pageY));
48716
+ }
48717
+ }
48718
+ function onMouseUp() {
48719
+ _state = STATE.NONE;
48720
+ scope.dispatchEvent(_endEvent$1);
48721
+ }
48722
+ function onMouseWheel(event) {
48723
+ if (scope.enabled === false)
48724
+ return;
48725
+ if (scope.noZoom === true)
48726
+ return;
48727
+ event.preventDefault();
48728
+ switch (event.deltaMode) {
48729
+ case 2:
48730
+ // Zoom in pages
48731
+ _zoomStart.y -= event.deltaY * 0.025;
48732
+ break;
48733
+ case 1:
48734
+ // Zoom in lines
48735
+ _zoomStart.y -= event.deltaY * 0.01;
48736
+ break;
48737
+ default:
48738
+ // undefined, 0, assume pixels
48739
+ _zoomStart.y -= event.deltaY * 0.00025;
48740
+ break;
48741
+ }
48742
+ scope.dispatchEvent(_startEvent$1);
48743
+ scope.dispatchEvent(_endEvent$1);
48744
+ }
48745
+ function onTouchStart(event) {
48746
+ trackPointer(event);
48747
+ switch (_pointers.length) {
48748
+ case 1:
48749
+ _state = STATE.TOUCH_ROTATE;
48750
+ _moveCurr.copy(getMouseOnCircle(_pointers[0].pageX, _pointers[0].pageY));
48751
+ _movePrev.copy(_moveCurr);
48752
+ break;
48753
+ default: // 2 or more
48754
+ _state = STATE.TOUCH_ZOOM_PAN;
48755
+ const dx = _pointers[0].pageX - _pointers[1].pageX;
48756
+ const dy = _pointers[0].pageY - _pointers[1].pageY;
48757
+ _touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt(dx * dx + dy * dy);
48758
+ const x = (_pointers[0].pageX + _pointers[1].pageX) / 2;
48759
+ const y = (_pointers[0].pageY + _pointers[1].pageY) / 2;
48760
+ _panStart.copy(getMouseOnScreen(x, y));
48761
+ _panEnd.copy(_panStart);
48762
+ break;
48763
+ }
48764
+ scope.dispatchEvent(_startEvent$1);
48765
+ }
48766
+ function onTouchMove(event) {
48767
+ trackPointer(event);
48768
+ switch (_pointers.length) {
48769
+ case 1:
48770
+ _movePrev.copy(_moveCurr);
48771
+ _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
48772
+ break;
48773
+ default: // 2 or more
48774
+ const position = getSecondPointerPosition(event);
48775
+ const dx = event.pageX - position.x;
48776
+ const dy = event.pageY - position.y;
48777
+ _touchZoomDistanceEnd = Math.sqrt(dx * dx + dy * dy);
48778
+ const x = (event.pageX + position.x) / 2;
48779
+ const y = (event.pageY + position.y) / 2;
48780
+ _panEnd.copy(getMouseOnScreen(x, y));
48781
+ break;
48782
+ }
48783
+ }
48784
+ function onTouchEnd(event) {
48785
+ switch (_pointers.length) {
48786
+ case 0:
48787
+ _state = STATE.NONE;
48788
+ break;
48789
+ case 1:
48790
+ _state = STATE.TOUCH_ROTATE;
48791
+ _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
48792
+ _movePrev.copy(_moveCurr);
48793
+ break;
48794
+ case 2:
48795
+ _state = STATE.TOUCH_ZOOM_PAN;
48796
+ for (let i = 0; i < _pointers.length; i++) {
48797
+ if (_pointers[i].pointerId !== event.pointerId) {
48798
+ const position = _pointerPositions[_pointers[i].pointerId];
48799
+ _moveCurr.copy(getMouseOnCircle(position.x, position.y));
48800
+ _movePrev.copy(_moveCurr);
48801
+ break;
48802
+ }
48803
+ }
48804
+ break;
48805
+ }
48806
+ scope.dispatchEvent(_endEvent$1);
48807
+ }
48808
+ function contextmenu(event) {
48809
+ if (scope.enabled === false)
48810
+ return;
48811
+ event.preventDefault();
48812
+ }
48813
+ function addPointer(event) {
48814
+ _pointers.push(event);
48815
+ }
48816
+ function removePointer(event) {
48817
+ delete _pointerPositions[event.pointerId];
48818
+ for (let i = 0; i < _pointers.length; i++) {
48819
+ if (_pointers[i].pointerId == event.pointerId) {
48820
+ _pointers.splice(i, 1);
48821
+ return;
48822
+ }
48823
+ }
48824
+ }
48825
+ function trackPointer(event) {
48826
+ let position = _pointerPositions[event.pointerId];
48827
+ if (position === undefined) {
48828
+ position = new Vector2();
48829
+ _pointerPositions[event.pointerId] = position;
48830
+ }
48831
+ position.set(event.pageX, event.pageY);
48832
+ }
48833
+ function getSecondPointerPosition(event) {
48834
+ const pointer = event.pointerId === _pointers[0].pointerId
48835
+ ? _pointers[1]
48836
+ : _pointers[0];
48837
+ return _pointerPositions[pointer.pointerId];
48838
+ }
48839
+ this.dispose = function () {
48840
+ scope.domElement.removeEventListener("contextmenu", contextmenu);
48841
+ scope.domElement.removeEventListener("pointerdown", onPointerDown);
48842
+ scope.domElement.removeEventListener("pointercancel", onPointerCancel);
48843
+ scope.domElement.removeEventListener("wheel", onMouseWheel);
48844
+ scope.domElement.removeEventListener("pointermove", onPointerMove);
48845
+ scope.domElement.removeEventListener("pointerup", onPointerUp);
48846
+ window.removeEventListener("keydown", keydown);
48847
+ window.removeEventListener("keyup", keyup);
48848
+ };
48849
+ this.domElement.addEventListener("contextmenu", contextmenu);
48850
+ this.domElement.addEventListener("pointerdown", onPointerDown);
48851
+ this.domElement.addEventListener("pointercancel", onPointerCancel);
48852
+ this.domElement.addEventListener("wheel", onMouseWheel, { passive: false });
48853
+ window.addEventListener("keydown", keydown);
48854
+ window.addEventListener("keyup", keyup);
48855
+ this.handleResize();
48856
+ // force an update at start
48857
+ this.update();
48858
+ }
48859
+ }
48860
+
48293
48861
  /**
48294
48862
  * @param {BufferGeometry} geometry
48295
48863
  * @param {number} drawMode
@@ -56268,7 +56836,7 @@ class copperScene extends baseScene {
56268
56836
  this.controls = new OrbitControls(this.camera, this.renderer.domElement);
56269
56837
  }
56270
56838
  else {
56271
- this.controls = new Copper3dTrackballControls(this.camera, this.renderer.domElement);
56839
+ this.controls = new Copper3dTrackballControls1(this.camera, this.renderer.domElement);
56272
56840
  }
56273
56841
  this.controls.panSpeed = 3;
56274
56842
  this.controls.rotateSpeed = 3;
@@ -69771,7 +70339,7 @@ class nrrd_tools {
69771
70339
  }
69772
70340
 
69773
70341
  // import * as kiwrious from "copper3d_plugin_heart_k";
69774
- const REVISION = "v1.15.2";
69775
- console.log("%cCopper3D Visualisation %cBeta:v1.15.2", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
70342
+ const REVISION = "v1.15.3";
70343
+ console.log("%cCopper3D Visualisation %cBeta:v1.15.3", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
69776
70344
 
69777
70345
  export { CameraViewPoint, Copper3dTrackballControls, REVISION, addBoxHelper, addLabelToScene, configKiwriousHeart, convert3DPostoScreenPos, convertScreenPosto3DPos, copperMScene, copperMSceneRenderer, copperRenderer, copperRendererOnDemond, copperScene, copperSceneOnDemond, createTexture2D_NRRD, fullScreenListenner, kiwrious, loading, nrrd_tools, setHDRFilePath };