copper3d 1.15.3 → 1.15.5

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);
@@ -45628,7 +45628,7 @@
45628
45628
  _panEnd.copy(_panStart);
45629
45629
  break;
45630
45630
  }
45631
- scope.dispatchEvent(_startEvent$2);
45631
+ scope.dispatchEvent(_startEvent$3);
45632
45632
  }
45633
45633
  function onTouchMove(event) {
45634
45634
  trackPointer(event);
@@ -45670,7 +45670,7 @@
45670
45670
  }
45671
45671
  break;
45672
45672
  }
45673
- scope.dispatchEvent(_endEvent$2);
45673
+ scope.dispatchEvent(_endEvent$3);
45674
45674
  }
45675
45675
  // function onTouchStart(event: PointerEvent) {
45676
45676
  // trackPointer(event);
@@ -45831,9 +45831,9 @@
45831
45831
  // Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish
45832
45832
  // Pan - right mouse, or left mouse + ctrl/meta/shiftKey, or arrow keys / touch: two-finger move
45833
45833
 
45834
- const _changeEvent$1 = { type: 'change' };
45835
- const _startEvent$1 = { type: 'start' };
45836
- const _endEvent$1 = { type: 'end' };
45834
+ const _changeEvent$2 = { type: 'change' };
45835
+ const _startEvent$2 = { type: 'start' };
45836
+ const _endEvent$2 = { type: 'end' };
45837
45837
 
45838
45838
  class OrbitControls extends EventDispatcher {
45839
45839
 
@@ -45962,7 +45962,7 @@
45962
45962
  scope.object.zoom = scope.zoom0;
45963
45963
 
45964
45964
  scope.object.updateProjectionMatrix();
45965
- scope.dispatchEvent( _changeEvent$1 );
45965
+ scope.dispatchEvent( _changeEvent$2 );
45966
45966
 
45967
45967
  scope.update();
45968
45968
 
@@ -46096,7 +46096,7 @@
46096
46096
  lastPosition.distanceToSquared( scope.object.position ) > EPS ||
46097
46097
  8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) {
46098
46098
 
46099
- scope.dispatchEvent( _changeEvent$1 );
46099
+ scope.dispatchEvent( _changeEvent$2 );
46100
46100
 
46101
46101
  lastPosition.copy( scope.object.position );
46102
46102
  lastQuaternion.copy( scope.object.quaternion );
@@ -46710,7 +46710,7 @@
46710
46710
 
46711
46711
  }
46712
46712
 
46713
- scope.dispatchEvent( _endEvent$1 );
46713
+ scope.dispatchEvent( _endEvent$2 );
46714
46714
 
46715
46715
  state = STATE.NONE;
46716
46716
 
@@ -46807,7 +46807,7 @@
46807
46807
 
46808
46808
  if ( state !== STATE.NONE ) {
46809
46809
 
46810
- scope.dispatchEvent( _startEvent$1 );
46810
+ scope.dispatchEvent( _startEvent$2 );
46811
46811
 
46812
46812
  }
46813
46813
 
@@ -46851,11 +46851,11 @@
46851
46851
 
46852
46852
  event.preventDefault();
46853
46853
 
46854
- scope.dispatchEvent( _startEvent$1 );
46854
+ scope.dispatchEvent( _startEvent$2 );
46855
46855
 
46856
46856
  handleMouseWheel( event );
46857
46857
 
46858
- scope.dispatchEvent( _endEvent$1 );
46858
+ scope.dispatchEvent( _endEvent$2 );
46859
46859
 
46860
46860
  }
46861
46861
 
@@ -46945,7 +46945,7 @@
46945
46945
 
46946
46946
  if ( state !== STATE.NONE ) {
46947
46947
 
46948
- scope.dispatchEvent( _startEvent$1 );
46948
+ scope.dispatchEvent( _startEvent$2 );
46949
46949
 
46950
46950
  }
46951
46951
 
@@ -48364,6 +48364,543 @@
48364
48364
  }
48365
48365
  }
48366
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: 4,
48381
+ TOUCH_PAN: 5,
48382
+ TOUCH_ZOOM_PAN: 6,
48383
+ };
48384
+ this.object = object;
48385
+ this.domElement = domElement;
48386
+ this.domElement.style.touchAction = "none"; // disable touch scroll
48387
+ // API
48388
+ this.enabled = true;
48389
+ this.screen = { left: 0, top: 0, width: 0, height: 0 };
48390
+ this.rotateSpeed = 1.0;
48391
+ this.zoomSpeed = 1.2;
48392
+ this.panSpeed = 0.3;
48393
+ this.noRotate = false;
48394
+ this.noZoom = false;
48395
+ this.noPan = false;
48396
+ this.staticMoving = false;
48397
+ this.dynamicDampingFactor = 0.2;
48398
+ this.minDistance = 0;
48399
+ this.maxDistance = Infinity;
48400
+ this.minZoom = 0;
48401
+ this.maxZoom = Infinity;
48402
+ this.keys = ["KeyA" /*A*/, "KeyS" /*S*/, "KeyD" /*D*/];
48403
+ this.mouseButtons = {
48404
+ LEFT: MOUSE.ROTATE,
48405
+ MIDDLE: MOUSE.DOLLY,
48406
+ RIGHT: MOUSE.PAN,
48407
+ };
48408
+ // internals
48409
+ this.target = new Vector3();
48410
+ const EPS = 0.000001;
48411
+ const lastPosition = new Vector3();
48412
+ let lastZoom = 1;
48413
+ let _state = STATE.NONE, _keyState = STATE.NONE, _touchZoomDistanceStart = 0, _touchZoomDistanceEnd = 0, _lastAngle = 0;
48414
+ const _eye = new Vector3(), _movePrev = new Vector2(), _moveCurr = new Vector2(), _lastAxis = new Vector3(), _zoomStart = new Vector2(), _zoomEnd = new Vector2(), _panStart = new Vector2(), _panEnd = new Vector2(), _pointers = [], _pointerPositions = {};
48415
+ // for reset
48416
+ this.target0 = this.target.clone();
48417
+ this.position0 = this.object.position.clone();
48418
+ this.up0 = this.object.up.clone();
48419
+ this.zoom0 = this.object.zoom;
48420
+ // methods
48421
+ this.handleResize = function () {
48422
+ const box = scope.domElement.getBoundingClientRect();
48423
+ // adjustments come from similar code in the jquery offset() function
48424
+ const d = scope.domElement.ownerDocument.documentElement;
48425
+ scope.screen.left = box.left + window.pageXOffset - d.clientLeft;
48426
+ scope.screen.top = box.top + window.pageYOffset - d.clientTop;
48427
+ scope.screen.width = box.width;
48428
+ scope.screen.height = box.height;
48429
+ };
48430
+ const getMouseOnScreen = (function () {
48431
+ const vector = new Vector2();
48432
+ return function getMouseOnScreen(pageX, pageY) {
48433
+ vector.set((pageX - scope.screen.left) / scope.screen.width, (pageY - scope.screen.top) / scope.screen.height);
48434
+ return vector;
48435
+ };
48436
+ })();
48437
+ const getMouseOnCircle = (function () {
48438
+ const vector = new Vector2();
48439
+ return function getMouseOnCircle(pageX, pageY) {
48440
+ vector.set((pageX - scope.screen.width * 0.5 - scope.screen.left) /
48441
+ (scope.screen.width * 0.5), (scope.screen.height + 2 * (scope.screen.top - pageY)) /
48442
+ scope.screen.width // screen.width intentional
48443
+ );
48444
+ return vector;
48445
+ };
48446
+ })();
48447
+ this.rotateCamera = (function () {
48448
+ const axis = new Vector3(), quaternion = new Quaternion(), eyeDirection = new Vector3(), objectUpDirection = new Vector3(), objectSidewaysDirection = new Vector3(), moveDirection = new Vector3();
48449
+ return function rotateCamera() {
48450
+ moveDirection.set(_moveCurr.x - _movePrev.x, _moveCurr.y - _movePrev.y, 0);
48451
+ let angle = moveDirection.length();
48452
+ if (angle) {
48453
+ _eye.copy(scope.object.position).sub(scope.target);
48454
+ eyeDirection.copy(_eye).normalize();
48455
+ objectUpDirection.copy(scope.object.up).normalize();
48456
+ objectSidewaysDirection
48457
+ .crossVectors(objectUpDirection, eyeDirection)
48458
+ .normalize();
48459
+ objectUpDirection.setLength(_moveCurr.y - _movePrev.y);
48460
+ objectSidewaysDirection.setLength(_moveCurr.x - _movePrev.x);
48461
+ moveDirection.copy(objectUpDirection.add(objectSidewaysDirection));
48462
+ axis.crossVectors(moveDirection, _eye).normalize();
48463
+ angle *= scope.rotateSpeed;
48464
+ quaternion.setFromAxisAngle(axis, angle);
48465
+ _eye.applyQuaternion(quaternion);
48466
+ scope.object.up.applyQuaternion(quaternion);
48467
+ _lastAxis.copy(axis);
48468
+ _lastAngle = angle;
48469
+ }
48470
+ else if (!scope.staticMoving && _lastAngle) {
48471
+ _lastAngle *= Math.sqrt(1.0 - scope.dynamicDampingFactor);
48472
+ _eye.copy(scope.object.position).sub(scope.target);
48473
+ quaternion.setFromAxisAngle(_lastAxis, _lastAngle);
48474
+ _eye.applyQuaternion(quaternion);
48475
+ scope.object.up.applyQuaternion(quaternion);
48476
+ }
48477
+ _movePrev.copy(_moveCurr);
48478
+ };
48479
+ })();
48480
+ this.zoomCamera = function () {
48481
+ let factor;
48482
+ if (_state === STATE.TOUCH_ZOOM_PAN) {
48483
+ factor = _touchZoomDistanceStart / _touchZoomDistanceEnd;
48484
+ _touchZoomDistanceStart = _touchZoomDistanceEnd;
48485
+ if (scope.object.isPerspectiveCamera) {
48486
+ _eye.multiplyScalar(factor);
48487
+ }
48488
+ else if (scope.object.isOrthographicCamera) {
48489
+ scope.object.zoom = MathUtils.clamp(scope.object.zoom / factor, scope.minZoom, scope.maxZoom);
48490
+ if (lastZoom !== scope.object.zoom) {
48491
+ scope.object.updateProjectionMatrix();
48492
+ }
48493
+ }
48494
+ else {
48495
+ console.warn("THREE.TrackballControls: Unsupported camera type");
48496
+ }
48497
+ }
48498
+ else {
48499
+ factor = 1.0 + (_zoomEnd.y - _zoomStart.y) * scope.zoomSpeed;
48500
+ if (factor !== 1.0 && factor > 0.0) {
48501
+ if (scope.object.isPerspectiveCamera) {
48502
+ _eye.multiplyScalar(factor);
48503
+ }
48504
+ else if (scope.object.isOrthographicCamera) {
48505
+ scope.object.zoom = MathUtils.clamp(scope.object.zoom / factor, scope.minZoom, scope.maxZoom);
48506
+ if (lastZoom !== scope.object.zoom) {
48507
+ scope.object.updateProjectionMatrix();
48508
+ }
48509
+ }
48510
+ else {
48511
+ console.warn("THREE.TrackballControls: Unsupported camera type");
48512
+ }
48513
+ }
48514
+ if (scope.staticMoving) {
48515
+ _zoomStart.copy(_zoomEnd);
48516
+ }
48517
+ else {
48518
+ _zoomStart.y +=
48519
+ (_zoomEnd.y - _zoomStart.y) * this.dynamicDampingFactor;
48520
+ }
48521
+ }
48522
+ };
48523
+ this.panCamera = (function () {
48524
+ const mouseChange = new Vector2(), objectUp = new Vector3(), pan = new Vector3();
48525
+ return function panCamera() {
48526
+ mouseChange.copy(_panEnd).sub(_panStart);
48527
+ if (mouseChange.lengthSq()) {
48528
+ if (scope.object.isOrthographicCamera) {
48529
+ const scale_x = (scope.object.right -
48530
+ scope.object.left) /
48531
+ scope.object.zoom /
48532
+ scope.domElement.clientWidth;
48533
+ const scale_y = (scope.object.top -
48534
+ scope.object.bottom) /
48535
+ scope.object.zoom /
48536
+ scope.domElement.clientWidth;
48537
+ mouseChange.x *= scale_x;
48538
+ mouseChange.y *= scale_y;
48539
+ }
48540
+ mouseChange.multiplyScalar(_eye.length() * scope.panSpeed);
48541
+ pan.copy(_eye).cross(scope.object.up).setLength(mouseChange.x);
48542
+ pan.add(objectUp.copy(scope.object.up).setLength(mouseChange.y));
48543
+ scope.object.position.add(pan);
48544
+ scope.target.add(pan);
48545
+ if (scope.staticMoving) {
48546
+ _panStart.copy(_panEnd);
48547
+ }
48548
+ else {
48549
+ _panStart.add(mouseChange
48550
+ .subVectors(_panEnd, _panStart)
48551
+ .multiplyScalar(scope.dynamicDampingFactor));
48552
+ }
48553
+ }
48554
+ };
48555
+ })();
48556
+ this.checkDistances = function () {
48557
+ if (!scope.noZoom || !scope.noPan) {
48558
+ if (_eye.lengthSq() > scope.maxDistance * scope.maxDistance) {
48559
+ scope.object.position.addVectors(scope.target, _eye.setLength(scope.maxDistance));
48560
+ _zoomStart.copy(_zoomEnd);
48561
+ }
48562
+ if (_eye.lengthSq() < scope.minDistance * scope.minDistance) {
48563
+ scope.object.position.addVectors(scope.target, _eye.setLength(scope.minDistance));
48564
+ _zoomStart.copy(_zoomEnd);
48565
+ }
48566
+ }
48567
+ };
48568
+ this.update = function () {
48569
+ _eye.subVectors(scope.object.position, scope.target);
48570
+ if (!scope.noRotate) {
48571
+ scope.rotateCamera();
48572
+ }
48573
+ if (!scope.noZoom) {
48574
+ scope.zoomCamera();
48575
+ }
48576
+ if (!scope.noPan) {
48577
+ scope.panCamera();
48578
+ }
48579
+ scope.object.position.addVectors(scope.target, _eye);
48580
+ if (scope.object.isPerspectiveCamera) {
48581
+ scope.checkDistances();
48582
+ scope.object.lookAt(scope.target);
48583
+ if (lastPosition.distanceToSquared(scope.object.position) > EPS) {
48584
+ scope.dispatchEvent(_changeEvent$1);
48585
+ lastPosition.copy(scope.object.position);
48586
+ }
48587
+ }
48588
+ else if (scope.object.isOrthographicCamera) {
48589
+ scope.object.lookAt(scope.target);
48590
+ if (lastPosition.distanceToSquared(scope.object.position) > EPS ||
48591
+ lastZoom !== scope.object.zoom) {
48592
+ scope.dispatchEvent(_changeEvent$1);
48593
+ lastPosition.copy(scope.object.position);
48594
+ lastZoom = scope.object.zoom;
48595
+ }
48596
+ }
48597
+ else {
48598
+ console.warn("THREE.TrackballControls: Unsupported camera type");
48599
+ }
48600
+ };
48601
+ this.reset = function () {
48602
+ _state = STATE.NONE;
48603
+ _keyState = STATE.NONE;
48604
+ scope.target.copy(scope.target0);
48605
+ scope.object.position.copy(scope.position0);
48606
+ scope.object.up.copy(scope.up0);
48607
+ scope.object.zoom = scope.zoom0;
48608
+ scope.object.updateProjectionMatrix();
48609
+ _eye.subVectors(scope.object.position, scope.target);
48610
+ scope.object.lookAt(scope.target);
48611
+ scope.dispatchEvent(_changeEvent$1);
48612
+ lastPosition.copy(scope.object.position);
48613
+ lastZoom = scope.object.zoom;
48614
+ };
48615
+ // listeners
48616
+ function onPointerDown(event) {
48617
+ if (scope.enabled === false)
48618
+ return;
48619
+ if (_pointers.length === 0) {
48620
+ scope.domElement.setPointerCapture(event.pointerId);
48621
+ scope.domElement.addEventListener("pointermove", onPointerMove);
48622
+ scope.domElement.addEventListener("pointerup", onPointerUp);
48623
+ }
48624
+ //
48625
+ addPointer(event);
48626
+ if (event.pointerType === "touch") {
48627
+ onTouchStart(event);
48628
+ }
48629
+ else {
48630
+ onMouseDown(event);
48631
+ }
48632
+ }
48633
+ function onPointerMove(event) {
48634
+ if (scope.enabled === false)
48635
+ return;
48636
+ if (event.pointerType === "touch") {
48637
+ onTouchMove(event);
48638
+ }
48639
+ else {
48640
+ onMouseMove(event);
48641
+ }
48642
+ }
48643
+ function onPointerUp(event) {
48644
+ if (scope.enabled === false)
48645
+ return;
48646
+ if (event.pointerType === "touch") {
48647
+ onTouchEnd(event);
48648
+ }
48649
+ else {
48650
+ onMouseUp();
48651
+ }
48652
+ //
48653
+ removePointer(event);
48654
+ if (_pointers.length === 0) {
48655
+ scope.domElement.releasePointerCapture(event.pointerId);
48656
+ scope.domElement.removeEventListener("pointermove", onPointerMove);
48657
+ scope.domElement.removeEventListener("pointerup", onPointerUp);
48658
+ }
48659
+ }
48660
+ function onPointerCancel(event) {
48661
+ removePointer(event);
48662
+ }
48663
+ function keydown(event) {
48664
+ if (scope.enabled === false)
48665
+ return;
48666
+ window.removeEventListener("keydown", keydown);
48667
+ if (_keyState !== STATE.NONE) {
48668
+ return;
48669
+ }
48670
+ else if (event.code === scope.keys[STATE.ROTATE] && !scope.noRotate) {
48671
+ _keyState = STATE.ROTATE;
48672
+ }
48673
+ else if (event.code === scope.keys[STATE.ZOOM] && !scope.noZoom) {
48674
+ _keyState = STATE.ZOOM;
48675
+ }
48676
+ else if (event.code === scope.keys[STATE.PAN] && !scope.noPan) {
48677
+ _keyState = STATE.PAN;
48678
+ }
48679
+ }
48680
+ function keyup() {
48681
+ if (scope.enabled === false)
48682
+ return;
48683
+ _keyState = STATE.NONE;
48684
+ window.addEventListener("keydown", keydown);
48685
+ }
48686
+ function onMouseDown(event) {
48687
+ if (_state === STATE.NONE) {
48688
+ switch (event.button) {
48689
+ case scope.mouseButtons.LEFT:
48690
+ _state = STATE.ROTATE;
48691
+ break;
48692
+ case scope.mouseButtons.MIDDLE:
48693
+ _state = STATE.ZOOM;
48694
+ break;
48695
+ case scope.mouseButtons.RIGHT:
48696
+ _state = STATE.PAN;
48697
+ break;
48698
+ }
48699
+ }
48700
+ const state = _keyState !== STATE.NONE ? _keyState : _state;
48701
+ if (state === STATE.ROTATE && !scope.noRotate) {
48702
+ _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
48703
+ _movePrev.copy(_moveCurr);
48704
+ }
48705
+ else if (state === STATE.ZOOM && !scope.noZoom) {
48706
+ _zoomStart.copy(getMouseOnScreen(event.pageX, event.pageY));
48707
+ _zoomEnd.copy(_zoomStart);
48708
+ }
48709
+ else if (state === STATE.PAN && !scope.noPan) {
48710
+ _panStart.copy(getMouseOnScreen(event.pageX, event.pageY));
48711
+ _panEnd.copy(_panStart);
48712
+ }
48713
+ scope.dispatchEvent(_startEvent$1);
48714
+ }
48715
+ function onMouseMove(event) {
48716
+ const state = _keyState !== STATE.NONE ? _keyState : _state;
48717
+ if (state === STATE.ROTATE && !scope.noRotate) {
48718
+ _movePrev.copy(_moveCurr);
48719
+ _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
48720
+ }
48721
+ else if (state === STATE.ZOOM && !scope.noZoom) {
48722
+ _zoomEnd.copy(getMouseOnScreen(event.pageX, event.pageY));
48723
+ }
48724
+ else if (state === STATE.PAN && !scope.noPan) {
48725
+ _panEnd.copy(getMouseOnScreen(event.pageX, event.pageY));
48726
+ }
48727
+ }
48728
+ function onMouseUp() {
48729
+ _state = STATE.NONE;
48730
+ scope.dispatchEvent(_endEvent$1);
48731
+ }
48732
+ function onMouseWheel(event) {
48733
+ if (scope.enabled === false)
48734
+ return;
48735
+ if (scope.noZoom === true)
48736
+ return;
48737
+ event.preventDefault();
48738
+ switch (event.deltaMode) {
48739
+ case 2:
48740
+ // Zoom in pages
48741
+ _zoomStart.y -= event.deltaY * 0.025;
48742
+ break;
48743
+ case 1:
48744
+ // Zoom in lines
48745
+ _zoomStart.y -= event.deltaY * 0.01;
48746
+ break;
48747
+ default:
48748
+ // undefined, 0, assume pixels
48749
+ _zoomStart.y -= event.deltaY * 0.00025;
48750
+ break;
48751
+ }
48752
+ scope.dispatchEvent(_startEvent$1);
48753
+ scope.dispatchEvent(_endEvent$1);
48754
+ }
48755
+ function onTouchStart(event) {
48756
+ trackPointer(event);
48757
+ switch (_pointers.length) {
48758
+ case 1:
48759
+ _state = STATE.TOUCH_ROTATE;
48760
+ _moveCurr.copy(getMouseOnCircle(_pointers[0].pageX, _pointers[0].pageY));
48761
+ _movePrev.copy(_moveCurr);
48762
+ break;
48763
+ case 2:
48764
+ _state = STATE.TOUCH_ZOOM_PAN;
48765
+ const dx = _pointers[0].pageX - _pointers[1].pageX;
48766
+ const dy = _pointers[0].pageY - _pointers[1].pageY;
48767
+ _touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt(dx * dx + dy * dy);
48768
+ const x = (_pointers[0].pageX + _pointers[1].pageX) / 2;
48769
+ const y = (_pointers[0].pageY + _pointers[1].pageY) / 2;
48770
+ _panStart.copy(getMouseOnScreen(x, y));
48771
+ _panEnd.copy(_panStart);
48772
+ break;
48773
+ case 3:
48774
+ _state = STATE.TOUCH_PAN;
48775
+ const centerX = (_pointers[0].pageX + _pointers[1].pageX + _pointers[2].pageX) / 3;
48776
+ const centerY = (_pointers[0].pageY + _pointers[1].pageY + _pointers[2].pageY) / 3;
48777
+ _panStart.copy(getMouseOnScreen(centerX, centerY));
48778
+ _panEnd.copy(_panStart);
48779
+ break;
48780
+ }
48781
+ scope.dispatchEvent(_startEvent$1);
48782
+ }
48783
+ function onTouchMove(event) {
48784
+ trackPointer(event);
48785
+ let position, x, y;
48786
+ switch (_pointers.length) {
48787
+ case 1:
48788
+ if (_state != STATE.TOUCH_ROTATE)
48789
+ return;
48790
+ _movePrev.copy(_moveCurr);
48791
+ _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
48792
+ break;
48793
+ case 2:
48794
+ if (_state != STATE.TOUCH_ZOOM_PAN)
48795
+ return;
48796
+ position = getSecondPointerPosition(event);
48797
+ const dx = event.pageX - position.x;
48798
+ const dy = event.pageY - position.y;
48799
+ _touchZoomDistanceEnd = Math.sqrt(dx * dx + dy * dy);
48800
+ x = (event.pageX + position.x) / 2;
48801
+ y = (event.pageY + position.y) / 2;
48802
+ _panEnd.copy(getMouseOnScreen(x, y));
48803
+ break;
48804
+ case 3:
48805
+ if (_state != STATE.TOUCH_PAN)
48806
+ return;
48807
+ const point_1 = _pointerPositions[_pointers[0].pointerId];
48808
+ const point_2 = _pointerPositions[_pointers[1].pointerId];
48809
+ const point_3 = _pointerPositions[_pointers[2].pointerId];
48810
+ const centerX = (point_1.x + point_2.x + point_3.x) / 3;
48811
+ const centerY = (point_1.y + point_2.y + point_3.y) / 3;
48812
+ _panEnd.copy(getMouseOnScreen(centerX, centerY));
48813
+ break;
48814
+ }
48815
+ }
48816
+ function onTouchEnd(event) {
48817
+ switch (_pointers.length) {
48818
+ case 0:
48819
+ _state = STATE.NONE;
48820
+ break;
48821
+ case 1:
48822
+ _state = STATE.TOUCH_ROTATE;
48823
+ _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
48824
+ _movePrev.copy(_moveCurr);
48825
+ break;
48826
+ case 2:
48827
+ _state = STATE.TOUCH_ZOOM_PAN;
48828
+ for (let i = 0; i < _pointers.length; i++) {
48829
+ if (_pointers[i].pointerId !== event.pointerId) {
48830
+ const position = _pointerPositions[_pointers[i].pointerId];
48831
+ _moveCurr.copy(getMouseOnScreen(position.x, position.y));
48832
+ _movePrev.copy(_moveCurr);
48833
+ break;
48834
+ }
48835
+ }
48836
+ break;
48837
+ case 3:
48838
+ _state = STATE.TOUCH_PAN;
48839
+ for (let i = 0; i < _pointers.length; i++) {
48840
+ if (_pointers[i].pointerId !== event.pointerId) {
48841
+ const position = _pointerPositions[_pointers[i].pointerId];
48842
+ _moveCurr.copy(getMouseOnScreen(position.x, position.y));
48843
+ _movePrev.copy(_moveCurr);
48844
+ break;
48845
+ }
48846
+ }
48847
+ break;
48848
+ }
48849
+ scope.dispatchEvent(_endEvent$1);
48850
+ }
48851
+ function contextmenu(event) {
48852
+ if (scope.enabled === false)
48853
+ return;
48854
+ event.preventDefault();
48855
+ }
48856
+ function addPointer(event) {
48857
+ _pointers.push(event);
48858
+ }
48859
+ function removePointer(event) {
48860
+ delete _pointerPositions[event.pointerId];
48861
+ for (let i = 0; i < _pointers.length; i++) {
48862
+ if (_pointers[i].pointerId == event.pointerId) {
48863
+ _pointers.splice(i, 1);
48864
+ return;
48865
+ }
48866
+ }
48867
+ }
48868
+ function trackPointer(event) {
48869
+ let position = _pointerPositions[event.pointerId];
48870
+ if (position === undefined) {
48871
+ position = new Vector2();
48872
+ _pointerPositions[event.pointerId] = position;
48873
+ }
48874
+ position.set(event.pageX, event.pageY);
48875
+ }
48876
+ function getSecondPointerPosition(event) {
48877
+ const pointer = event.pointerId === _pointers[0].pointerId
48878
+ ? _pointers[1]
48879
+ : _pointers[0];
48880
+ return _pointerPositions[pointer.pointerId];
48881
+ }
48882
+ this.dispose = function () {
48883
+ scope.domElement.removeEventListener("contextmenu", contextmenu);
48884
+ scope.domElement.removeEventListener("pointerdown", onPointerDown);
48885
+ scope.domElement.removeEventListener("pointercancel", onPointerCancel);
48886
+ scope.domElement.removeEventListener("wheel", onMouseWheel);
48887
+ scope.domElement.removeEventListener("pointermove", onPointerMove);
48888
+ scope.domElement.removeEventListener("pointerup", onPointerUp);
48889
+ window.removeEventListener("keydown", keydown);
48890
+ window.removeEventListener("keyup", keyup);
48891
+ };
48892
+ this.domElement.addEventListener("contextmenu", contextmenu);
48893
+ this.domElement.addEventListener("pointerdown", onPointerDown);
48894
+ this.domElement.addEventListener("pointercancel", onPointerCancel);
48895
+ this.domElement.addEventListener("wheel", onMouseWheel, { passive: false });
48896
+ window.addEventListener("keydown", keydown);
48897
+ window.addEventListener("keyup", keyup);
48898
+ this.handleResize();
48899
+ // force an update at start
48900
+ this.update();
48901
+ }
48902
+ }
48903
+
48367
48904
  /**
48368
48905
  * @param {BufferGeometry} geometry
48369
48906
  * @param {number} drawMode
@@ -56342,7 +56879,7 @@
56342
56879
  this.controls = new OrbitControls(this.camera, this.renderer.domElement);
56343
56880
  }
56344
56881
  else {
56345
- this.controls = new Copper3dTrackballControls(this.camera, this.renderer.domElement);
56882
+ this.controls = new Copper3dTrackballControls1(this.camera, this.renderer.domElement);
56346
56883
  }
56347
56884
  this.controls.panSpeed = 3;
56348
56885
  this.controls.rotateSpeed = 3;