copper3d 1.15.0 → 1.15.1
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.
- package/dist/Renderer/copperRenderer.js +2 -2
- package/dist/Renderer/copperRenderer.js.map +1 -1
- package/dist/Scene/copperScene.d.ts +3 -2
- package/dist/Scene/copperScene.js +11 -2
- package/dist/Scene/copperScene.js.map +1 -1
- package/dist/bundle.esm.js +1101 -275
- package/dist/bundle.umd.js +1101 -275
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/types/Scene/copperScene.d.ts +3 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types/types.d.ts +1 -0
- package/dist/types/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/bundle.umd.js
CHANGED
|
@@ -45217,9 +45217,9 @@
|
|
|
45217
45217
|
|
|
45218
45218
|
const objLoader = new OBJLoader();
|
|
45219
45219
|
|
|
45220
|
-
const _changeEvent$
|
|
45221
|
-
const _startEvent$
|
|
45222
|
-
const _endEvent$
|
|
45220
|
+
const _changeEvent$2 = { type: "change" };
|
|
45221
|
+
const _startEvent$2 = { type: "start" };
|
|
45222
|
+
const _endEvent$2 = { type: "end" };
|
|
45223
45223
|
class Copper3dTrackballControls extends EventDispatcher {
|
|
45224
45224
|
constructor(object, domElement) {
|
|
45225
45225
|
super();
|
|
@@ -45440,7 +45440,7 @@
|
|
|
45440
45440
|
scope.checkDistances();
|
|
45441
45441
|
scope.object.lookAt(scope.target);
|
|
45442
45442
|
if (lastPosition.distanceToSquared(scope.object.position) > EPS) {
|
|
45443
|
-
scope.dispatchEvent(_changeEvent$
|
|
45443
|
+
scope.dispatchEvent(_changeEvent$2);
|
|
45444
45444
|
lastPosition.copy(scope.object.position);
|
|
45445
45445
|
}
|
|
45446
45446
|
}
|
|
@@ -45448,7 +45448,7 @@
|
|
|
45448
45448
|
scope.object.lookAt(scope.target);
|
|
45449
45449
|
if (lastPosition.distanceToSquared(scope.object.position) > EPS ||
|
|
45450
45450
|
lastZoom !== scope.object.zoom) {
|
|
45451
|
-
scope.dispatchEvent(_changeEvent$
|
|
45451
|
+
scope.dispatchEvent(_changeEvent$2);
|
|
45452
45452
|
lastPosition.copy(scope.object.position);
|
|
45453
45453
|
lastZoom = scope.object.zoom;
|
|
45454
45454
|
}
|
|
@@ -45467,7 +45467,7 @@
|
|
|
45467
45467
|
scope.object.updateProjectionMatrix();
|
|
45468
45468
|
_eye.subVectors(scope.object.position, scope.target);
|
|
45469
45469
|
scope.object.lookAt(scope.target);
|
|
45470
|
-
scope.dispatchEvent(_changeEvent$
|
|
45470
|
+
scope.dispatchEvent(_changeEvent$2);
|
|
45471
45471
|
lastPosition.copy(scope.object.position);
|
|
45472
45472
|
lastZoom = scope.object.zoom;
|
|
45473
45473
|
};
|
|
@@ -45567,7 +45567,7 @@
|
|
|
45567
45567
|
_panStart.copy(getMouseOnScreen(event.pageX, event.pageY));
|
|
45568
45568
|
_panEnd.copy(_panStart);
|
|
45569
45569
|
}
|
|
45570
|
-
scope.dispatchEvent(_startEvent$
|
|
45570
|
+
scope.dispatchEvent(_startEvent$2);
|
|
45571
45571
|
}
|
|
45572
45572
|
function onMouseMove(event) {
|
|
45573
45573
|
const state = _keyState !== STATE.NONE ? _keyState : _state;
|
|
@@ -45584,7 +45584,7 @@
|
|
|
45584
45584
|
}
|
|
45585
45585
|
function onMouseUp(event) {
|
|
45586
45586
|
_state = STATE.NONE;
|
|
45587
|
-
scope.dispatchEvent(_endEvent$
|
|
45587
|
+
scope.dispatchEvent(_endEvent$2);
|
|
45588
45588
|
}
|
|
45589
45589
|
function onMouseWheel(event) {
|
|
45590
45590
|
if (scope.enabled === false)
|
|
@@ -45606,8 +45606,8 @@
|
|
|
45606
45606
|
_zoomStart.y -= event.deltaY * 0.00025;
|
|
45607
45607
|
break;
|
|
45608
45608
|
}
|
|
45609
|
-
scope.dispatchEvent(_startEvent$
|
|
45610
|
-
scope.dispatchEvent(_endEvent$
|
|
45609
|
+
scope.dispatchEvent(_startEvent$2);
|
|
45610
|
+
scope.dispatchEvent(_endEvent$2);
|
|
45611
45611
|
}
|
|
45612
45612
|
function onTouchStart(event) {
|
|
45613
45613
|
trackPointer(event);
|
|
@@ -45635,7 +45635,7 @@
|
|
|
45635
45635
|
_panEnd.copy(_panStart);
|
|
45636
45636
|
break;
|
|
45637
45637
|
}
|
|
45638
|
-
scope.dispatchEvent(_startEvent$
|
|
45638
|
+
scope.dispatchEvent(_startEvent$2);
|
|
45639
45639
|
}
|
|
45640
45640
|
function onTouchMove(event) {
|
|
45641
45641
|
trackPointer(event);
|
|
@@ -45703,7 +45703,7 @@
|
|
|
45703
45703
|
}
|
|
45704
45704
|
break;
|
|
45705
45705
|
}
|
|
45706
|
-
scope.dispatchEvent(_endEvent$
|
|
45706
|
+
scope.dispatchEvent(_endEvent$2);
|
|
45707
45707
|
}
|
|
45708
45708
|
function contextmenu(event) {
|
|
45709
45709
|
if (scope.enabled === false)
|
|
@@ -45765,9 +45765,9 @@
|
|
|
45765
45765
|
// Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish
|
|
45766
45766
|
// Pan - right mouse, or left mouse + ctrl/meta/shiftKey, or arrow keys / touch: two-finger move
|
|
45767
45767
|
|
|
45768
|
-
const _changeEvent = { type: 'change' };
|
|
45769
|
-
const _startEvent = { type: 'start' };
|
|
45770
|
-
const _endEvent = { type: 'end' };
|
|
45768
|
+
const _changeEvent$1 = { type: 'change' };
|
|
45769
|
+
const _startEvent$1 = { type: 'start' };
|
|
45770
|
+
const _endEvent$1 = { type: 'end' };
|
|
45771
45771
|
|
|
45772
45772
|
class OrbitControls extends EventDispatcher {
|
|
45773
45773
|
|
|
@@ -45896,7 +45896,7 @@
|
|
|
45896
45896
|
scope.object.zoom = scope.zoom0;
|
|
45897
45897
|
|
|
45898
45898
|
scope.object.updateProjectionMatrix();
|
|
45899
|
-
scope.dispatchEvent( _changeEvent );
|
|
45899
|
+
scope.dispatchEvent( _changeEvent$1 );
|
|
45900
45900
|
|
|
45901
45901
|
scope.update();
|
|
45902
45902
|
|
|
@@ -46030,7 +46030,7 @@
|
|
|
46030
46030
|
lastPosition.distanceToSquared( scope.object.position ) > EPS ||
|
|
46031
46031
|
8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) {
|
|
46032
46032
|
|
|
46033
|
-
scope.dispatchEvent( _changeEvent );
|
|
46033
|
+
scope.dispatchEvent( _changeEvent$1 );
|
|
46034
46034
|
|
|
46035
46035
|
lastPosition.copy( scope.object.position );
|
|
46036
46036
|
lastQuaternion.copy( scope.object.quaternion );
|
|
@@ -46644,7 +46644,7 @@
|
|
|
46644
46644
|
|
|
46645
46645
|
}
|
|
46646
46646
|
|
|
46647
|
-
scope.dispatchEvent( _endEvent );
|
|
46647
|
+
scope.dispatchEvent( _endEvent$1 );
|
|
46648
46648
|
|
|
46649
46649
|
state = STATE.NONE;
|
|
46650
46650
|
|
|
@@ -46741,7 +46741,7 @@
|
|
|
46741
46741
|
|
|
46742
46742
|
if ( state !== STATE.NONE ) {
|
|
46743
46743
|
|
|
46744
|
-
scope.dispatchEvent( _startEvent );
|
|
46744
|
+
scope.dispatchEvent( _startEvent$1 );
|
|
46745
46745
|
|
|
46746
46746
|
}
|
|
46747
46747
|
|
|
@@ -46785,11 +46785,11 @@
|
|
|
46785
46785
|
|
|
46786
46786
|
event.preventDefault();
|
|
46787
46787
|
|
|
46788
|
-
scope.dispatchEvent( _startEvent );
|
|
46788
|
+
scope.dispatchEvent( _startEvent$1 );
|
|
46789
46789
|
|
|
46790
46790
|
handleMouseWheel( event );
|
|
46791
46791
|
|
|
46792
|
-
scope.dispatchEvent( _endEvent );
|
|
46792
|
+
scope.dispatchEvent( _endEvent$1 );
|
|
46793
46793
|
|
|
46794
46794
|
}
|
|
46795
46795
|
|
|
@@ -46879,7 +46879,7 @@
|
|
|
46879
46879
|
|
|
46880
46880
|
if ( state !== STATE.NONE ) {
|
|
46881
46881
|
|
|
46882
|
-
scope.dispatchEvent( _startEvent );
|
|
46882
|
+
scope.dispatchEvent( _startEvent$1 );
|
|
46883
46883
|
|
|
46884
46884
|
}
|
|
46885
46885
|
|
|
@@ -55436,255 +55436,1081 @@
|
|
|
55436
55436
|
}
|
|
55437
55437
|
}
|
|
55438
55438
|
|
|
55439
|
-
|
|
55440
|
-
|
|
55441
|
-
|
|
55442
|
-
|
|
55443
|
-
|
|
55444
|
-
|
|
55445
|
-
|
|
55446
|
-
|
|
55447
|
-
|
|
55448
|
-
|
|
55449
|
-
|
|
55450
|
-
|
|
55451
|
-
|
|
55452
|
-
|
|
55453
|
-
|
|
55454
|
-
|
|
55455
|
-
|
|
55456
|
-
|
|
55457
|
-
|
|
55458
|
-
|
|
55459
|
-
|
|
55460
|
-
|
|
55461
|
-
|
|
55462
|
-
|
|
55463
|
-
|
|
55464
|
-
|
|
55465
|
-
|
|
55466
|
-
|
|
55467
|
-
|
|
55468
|
-
|
|
55469
|
-
|
|
55470
|
-
|
|
55471
|
-
|
|
55472
|
-
|
|
55473
|
-
|
|
55474
|
-
|
|
55475
|
-
|
|
55476
|
-
|
|
55477
|
-
|
|
55478
|
-
|
|
55479
|
-
|
|
55480
|
-
|
|
55481
|
-
|
|
55482
|
-
|
|
55483
|
-
|
|
55484
|
-
|
|
55485
|
-
|
|
55486
|
-
|
|
55487
|
-
|
|
55488
|
-
|
|
55489
|
-
|
|
55490
|
-
|
|
55491
|
-
|
|
55492
|
-
|
|
55493
|
-
|
|
55494
|
-
|
|
55495
|
-
|
|
55496
|
-
|
|
55497
|
-
|
|
55498
|
-
|
|
55499
|
-
|
|
55500
|
-
|
|
55501
|
-
|
|
55502
|
-
|
|
55503
|
-
|
|
55504
|
-
|
|
55505
|
-
|
|
55506
|
-
|
|
55507
|
-
|
|
55508
|
-
|
|
55509
|
-
|
|
55510
|
-
|
|
55511
|
-
|
|
55512
|
-
|
|
55513
|
-
|
|
55514
|
-
|
|
55515
|
-
|
|
55516
|
-
|
|
55517
|
-
|
|
55518
|
-
|
|
55519
|
-
|
|
55520
|
-
|
|
55521
|
-
|
|
55522
|
-
|
|
55523
|
-
|
|
55524
|
-
|
|
55525
|
-
|
|
55526
|
-
|
|
55527
|
-
|
|
55528
|
-
|
|
55529
|
-
|
|
55530
|
-
|
|
55531
|
-
|
|
55532
|
-
|
|
55533
|
-
|
|
55534
|
-
|
|
55535
|
-
|
|
55536
|
-
|
|
55537
|
-
|
|
55538
|
-
|
|
55539
|
-
|
|
55540
|
-
|
|
55541
|
-
|
|
55542
|
-
|
|
55543
|
-
|
|
55544
|
-
|
|
55545
|
-
|
|
55546
|
-
|
|
55547
|
-
|
|
55548
|
-
|
|
55549
|
-
|
|
55550
|
-
|
|
55551
|
-
|
|
55552
|
-
|
|
55553
|
-
|
|
55554
|
-
|
|
55555
|
-
|
|
55556
|
-
|
|
55557
|
-
|
|
55558
|
-
|
|
55559
|
-
|
|
55560
|
-
|
|
55561
|
-
|
|
55562
|
-
|
|
55563
|
-
|
|
55564
|
-
|
|
55565
|
-
|
|
55566
|
-
|
|
55567
|
-
|
|
55568
|
-
|
|
55569
|
-
|
|
55570
|
-
|
|
55571
|
-
|
|
55572
|
-
|
|
55573
|
-
|
|
55574
|
-
|
|
55575
|
-
|
|
55576
|
-
|
|
55577
|
-
|
|
55578
|
-
|
|
55579
|
-
|
|
55580
|
-
|
|
55581
|
-
|
|
55582
|
-
|
|
55583
|
-
|
|
55584
|
-
|
|
55585
|
-
|
|
55586
|
-
|
|
55587
|
-
|
|
55588
|
-
|
|
55589
|
-
|
|
55590
|
-
|
|
55591
|
-
|
|
55592
|
-
|
|
55593
|
-
|
|
55594
|
-
|
|
55595
|
-
|
|
55596
|
-
|
|
55597
|
-
|
|
55598
|
-
|
|
55599
|
-
|
|
55600
|
-
|
|
55601
|
-
|
|
55602
|
-
|
|
55603
|
-
|
|
55604
|
-
|
|
55605
|
-
|
|
55606
|
-
|
|
55607
|
-
|
|
55608
|
-
|
|
55609
|
-
|
|
55610
|
-
|
|
55611
|
-
|
|
55612
|
-
|
|
55613
|
-
|
|
55614
|
-
|
|
55615
|
-
|
|
55616
|
-
|
|
55617
|
-
|
|
55618
|
-
|
|
55619
|
-
|
|
55620
|
-
|
|
55621
|
-
|
|
55622
|
-
|
|
55623
|
-
|
|
55624
|
-
|
|
55625
|
-
|
|
55626
|
-
|
|
55627
|
-
|
|
55628
|
-
|
|
55629
|
-
|
|
55630
|
-
|
|
55631
|
-
|
|
55632
|
-
|
|
55633
|
-
|
|
55634
|
-
|
|
55635
|
-
|
|
55636
|
-
|
|
55637
|
-
|
|
55638
|
-
|
|
55639
|
-
|
|
55640
|
-
|
|
55641
|
-
|
|
55642
|
-
|
|
55643
|
-
|
|
55644
|
-
|
|
55645
|
-
|
|
55646
|
-
|
|
55647
|
-
|
|
55648
|
-
|
|
55649
|
-
|
|
55650
|
-
|
|
55651
|
-
|
|
55652
|
-
|
|
55653
|
-
|
|
55654
|
-
|
|
55655
|
-
|
|
55656
|
-
|
|
55657
|
-
|
|
55658
|
-
|
|
55659
|
-
|
|
55660
|
-
|
|
55661
|
-
|
|
55662
|
-
|
|
55663
|
-
|
|
55664
|
-
|
|
55665
|
-
|
|
55666
|
-
|
|
55667
|
-
|
|
55668
|
-
|
|
55669
|
-
|
|
55670
|
-
|
|
55671
|
-
|
|
55672
|
-
|
|
55673
|
-
|
|
55674
|
-
|
|
55675
|
-
|
|
55676
|
-
|
|
55677
|
-
|
|
55678
|
-
|
|
55679
|
-
|
|
55680
|
-
|
|
55681
|
-
|
|
55682
|
-
|
|
55683
|
-
|
|
55684
|
-
|
|
55685
|
-
|
|
55686
|
-
|
|
55687
|
-
|
|
55439
|
+
const _changeEvent = { type: 'change' };
|
|
55440
|
+
const _startEvent = { type: 'start' };
|
|
55441
|
+
const _endEvent = { type: 'end' };
|
|
55442
|
+
|
|
55443
|
+
class TrackballControls extends EventDispatcher {
|
|
55444
|
+
|
|
55445
|
+
constructor( object, domElement ) {
|
|
55446
|
+
|
|
55447
|
+
super();
|
|
55448
|
+
|
|
55449
|
+
const scope = this;
|
|
55450
|
+
const STATE = { NONE: - 1, ROTATE: 0, ZOOM: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_ZOOM_PAN: 4 };
|
|
55451
|
+
|
|
55452
|
+
this.object = object;
|
|
55453
|
+
this.domElement = domElement;
|
|
55454
|
+
this.domElement.style.touchAction = 'none'; // disable touch scroll
|
|
55455
|
+
|
|
55456
|
+
// API
|
|
55457
|
+
|
|
55458
|
+
this.enabled = true;
|
|
55459
|
+
|
|
55460
|
+
this.screen = { left: 0, top: 0, width: 0, height: 0 };
|
|
55461
|
+
|
|
55462
|
+
this.rotateSpeed = 1.0;
|
|
55463
|
+
this.zoomSpeed = 1.2;
|
|
55464
|
+
this.panSpeed = 0.3;
|
|
55465
|
+
|
|
55466
|
+
this.noRotate = false;
|
|
55467
|
+
this.noZoom = false;
|
|
55468
|
+
this.noPan = false;
|
|
55469
|
+
|
|
55470
|
+
this.staticMoving = false;
|
|
55471
|
+
this.dynamicDampingFactor = 0.2;
|
|
55472
|
+
|
|
55473
|
+
this.minDistance = 0;
|
|
55474
|
+
this.maxDistance = Infinity;
|
|
55475
|
+
|
|
55476
|
+
this.minZoom = 0;
|
|
55477
|
+
this.maxZoom = Infinity;
|
|
55478
|
+
|
|
55479
|
+
this.keys = [ 'KeyA' /*A*/, 'KeyS' /*S*/, 'KeyD' /*D*/ ];
|
|
55480
|
+
|
|
55481
|
+
this.mouseButtons = { LEFT: MOUSE.ROTATE, MIDDLE: MOUSE.DOLLY, RIGHT: MOUSE.PAN };
|
|
55482
|
+
|
|
55483
|
+
// internals
|
|
55484
|
+
|
|
55485
|
+
this.target = new Vector3();
|
|
55486
|
+
|
|
55487
|
+
const EPS = 0.000001;
|
|
55488
|
+
|
|
55489
|
+
const lastPosition = new Vector3();
|
|
55490
|
+
let lastZoom = 1;
|
|
55491
|
+
|
|
55492
|
+
let _state = STATE.NONE,
|
|
55493
|
+
_keyState = STATE.NONE,
|
|
55494
|
+
|
|
55495
|
+
_touchZoomDistanceStart = 0,
|
|
55496
|
+
_touchZoomDistanceEnd = 0,
|
|
55497
|
+
|
|
55498
|
+
_lastAngle = 0;
|
|
55499
|
+
|
|
55500
|
+
const _eye = new Vector3(),
|
|
55501
|
+
|
|
55502
|
+
_movePrev = new Vector2(),
|
|
55503
|
+
_moveCurr = new Vector2(),
|
|
55504
|
+
|
|
55505
|
+
_lastAxis = new Vector3(),
|
|
55506
|
+
|
|
55507
|
+
_zoomStart = new Vector2(),
|
|
55508
|
+
_zoomEnd = new Vector2(),
|
|
55509
|
+
|
|
55510
|
+
_panStart = new Vector2(),
|
|
55511
|
+
_panEnd = new Vector2(),
|
|
55512
|
+
|
|
55513
|
+
_pointers = [],
|
|
55514
|
+
_pointerPositions = {};
|
|
55515
|
+
|
|
55516
|
+
// for reset
|
|
55517
|
+
|
|
55518
|
+
this.target0 = this.target.clone();
|
|
55519
|
+
this.position0 = this.object.position.clone();
|
|
55520
|
+
this.up0 = this.object.up.clone();
|
|
55521
|
+
this.zoom0 = this.object.zoom;
|
|
55522
|
+
|
|
55523
|
+
// methods
|
|
55524
|
+
|
|
55525
|
+
this.handleResize = function () {
|
|
55526
|
+
|
|
55527
|
+
const box = scope.domElement.getBoundingClientRect();
|
|
55528
|
+
// adjustments come from similar code in the jquery offset() function
|
|
55529
|
+
const d = scope.domElement.ownerDocument.documentElement;
|
|
55530
|
+
scope.screen.left = box.left + window.pageXOffset - d.clientLeft;
|
|
55531
|
+
scope.screen.top = box.top + window.pageYOffset - d.clientTop;
|
|
55532
|
+
scope.screen.width = box.width;
|
|
55533
|
+
scope.screen.height = box.height;
|
|
55534
|
+
|
|
55535
|
+
};
|
|
55536
|
+
|
|
55537
|
+
const getMouseOnScreen = ( function () {
|
|
55538
|
+
|
|
55539
|
+
const vector = new Vector2();
|
|
55540
|
+
|
|
55541
|
+
return function getMouseOnScreen( pageX, pageY ) {
|
|
55542
|
+
|
|
55543
|
+
vector.set(
|
|
55544
|
+
( pageX - scope.screen.left ) / scope.screen.width,
|
|
55545
|
+
( pageY - scope.screen.top ) / scope.screen.height
|
|
55546
|
+
);
|
|
55547
|
+
|
|
55548
|
+
return vector;
|
|
55549
|
+
|
|
55550
|
+
};
|
|
55551
|
+
|
|
55552
|
+
}() );
|
|
55553
|
+
|
|
55554
|
+
const getMouseOnCircle = ( function () {
|
|
55555
|
+
|
|
55556
|
+
const vector = new Vector2();
|
|
55557
|
+
|
|
55558
|
+
return function getMouseOnCircle( pageX, pageY ) {
|
|
55559
|
+
|
|
55560
|
+
vector.set(
|
|
55561
|
+
( ( pageX - scope.screen.width * 0.5 - scope.screen.left ) / ( scope.screen.width * 0.5 ) ),
|
|
55562
|
+
( ( scope.screen.height + 2 * ( scope.screen.top - pageY ) ) / scope.screen.width ) // screen.width intentional
|
|
55563
|
+
);
|
|
55564
|
+
|
|
55565
|
+
return vector;
|
|
55566
|
+
|
|
55567
|
+
};
|
|
55568
|
+
|
|
55569
|
+
}() );
|
|
55570
|
+
|
|
55571
|
+
this.rotateCamera = ( function () {
|
|
55572
|
+
|
|
55573
|
+
const axis = new Vector3(),
|
|
55574
|
+
quaternion = new Quaternion(),
|
|
55575
|
+
eyeDirection = new Vector3(),
|
|
55576
|
+
objectUpDirection = new Vector3(),
|
|
55577
|
+
objectSidewaysDirection = new Vector3(),
|
|
55578
|
+
moveDirection = new Vector3();
|
|
55579
|
+
|
|
55580
|
+
return function rotateCamera() {
|
|
55581
|
+
|
|
55582
|
+
moveDirection.set( _moveCurr.x - _movePrev.x, _moveCurr.y - _movePrev.y, 0 );
|
|
55583
|
+
let angle = moveDirection.length();
|
|
55584
|
+
|
|
55585
|
+
if ( angle ) {
|
|
55586
|
+
|
|
55587
|
+
_eye.copy( scope.object.position ).sub( scope.target );
|
|
55588
|
+
|
|
55589
|
+
eyeDirection.copy( _eye ).normalize();
|
|
55590
|
+
objectUpDirection.copy( scope.object.up ).normalize();
|
|
55591
|
+
objectSidewaysDirection.crossVectors( objectUpDirection, eyeDirection ).normalize();
|
|
55592
|
+
|
|
55593
|
+
objectUpDirection.setLength( _moveCurr.y - _movePrev.y );
|
|
55594
|
+
objectSidewaysDirection.setLength( _moveCurr.x - _movePrev.x );
|
|
55595
|
+
|
|
55596
|
+
moveDirection.copy( objectUpDirection.add( objectSidewaysDirection ) );
|
|
55597
|
+
|
|
55598
|
+
axis.crossVectors( moveDirection, _eye ).normalize();
|
|
55599
|
+
|
|
55600
|
+
angle *= scope.rotateSpeed;
|
|
55601
|
+
quaternion.setFromAxisAngle( axis, angle );
|
|
55602
|
+
|
|
55603
|
+
_eye.applyQuaternion( quaternion );
|
|
55604
|
+
scope.object.up.applyQuaternion( quaternion );
|
|
55605
|
+
|
|
55606
|
+
_lastAxis.copy( axis );
|
|
55607
|
+
_lastAngle = angle;
|
|
55608
|
+
|
|
55609
|
+
} else if ( ! scope.staticMoving && _lastAngle ) {
|
|
55610
|
+
|
|
55611
|
+
_lastAngle *= Math.sqrt( 1.0 - scope.dynamicDampingFactor );
|
|
55612
|
+
_eye.copy( scope.object.position ).sub( scope.target );
|
|
55613
|
+
quaternion.setFromAxisAngle( _lastAxis, _lastAngle );
|
|
55614
|
+
_eye.applyQuaternion( quaternion );
|
|
55615
|
+
scope.object.up.applyQuaternion( quaternion );
|
|
55616
|
+
|
|
55617
|
+
}
|
|
55618
|
+
|
|
55619
|
+
_movePrev.copy( _moveCurr );
|
|
55620
|
+
|
|
55621
|
+
};
|
|
55622
|
+
|
|
55623
|
+
}() );
|
|
55624
|
+
|
|
55625
|
+
|
|
55626
|
+
this.zoomCamera = function () {
|
|
55627
|
+
|
|
55628
|
+
let factor;
|
|
55629
|
+
|
|
55630
|
+
if ( _state === STATE.TOUCH_ZOOM_PAN ) {
|
|
55631
|
+
|
|
55632
|
+
factor = _touchZoomDistanceStart / _touchZoomDistanceEnd;
|
|
55633
|
+
_touchZoomDistanceStart = _touchZoomDistanceEnd;
|
|
55634
|
+
|
|
55635
|
+
if ( scope.object.isPerspectiveCamera ) {
|
|
55636
|
+
|
|
55637
|
+
_eye.multiplyScalar( factor );
|
|
55638
|
+
|
|
55639
|
+
} else if ( scope.object.isOrthographicCamera ) {
|
|
55640
|
+
|
|
55641
|
+
scope.object.zoom = MathUtils.clamp( scope.object.zoom / factor, scope.minZoom, scope.maxZoom );
|
|
55642
|
+
|
|
55643
|
+
if ( lastZoom !== scope.object.zoom ) {
|
|
55644
|
+
|
|
55645
|
+
scope.object.updateProjectionMatrix();
|
|
55646
|
+
|
|
55647
|
+
}
|
|
55648
|
+
|
|
55649
|
+
} else {
|
|
55650
|
+
|
|
55651
|
+
console.warn( 'THREE.TrackballControls: Unsupported camera type' );
|
|
55652
|
+
|
|
55653
|
+
}
|
|
55654
|
+
|
|
55655
|
+
} else {
|
|
55656
|
+
|
|
55657
|
+
factor = 1.0 + ( _zoomEnd.y - _zoomStart.y ) * scope.zoomSpeed;
|
|
55658
|
+
|
|
55659
|
+
if ( factor !== 1.0 && factor > 0.0 ) {
|
|
55660
|
+
|
|
55661
|
+
if ( scope.object.isPerspectiveCamera ) {
|
|
55662
|
+
|
|
55663
|
+
_eye.multiplyScalar( factor );
|
|
55664
|
+
|
|
55665
|
+
} else if ( scope.object.isOrthographicCamera ) {
|
|
55666
|
+
|
|
55667
|
+
scope.object.zoom = MathUtils.clamp( scope.object.zoom / factor, scope.minZoom, scope.maxZoom );
|
|
55668
|
+
|
|
55669
|
+
if ( lastZoom !== scope.object.zoom ) {
|
|
55670
|
+
|
|
55671
|
+
scope.object.updateProjectionMatrix();
|
|
55672
|
+
|
|
55673
|
+
}
|
|
55674
|
+
|
|
55675
|
+
} else {
|
|
55676
|
+
|
|
55677
|
+
console.warn( 'THREE.TrackballControls: Unsupported camera type' );
|
|
55678
|
+
|
|
55679
|
+
}
|
|
55680
|
+
|
|
55681
|
+
}
|
|
55682
|
+
|
|
55683
|
+
if ( scope.staticMoving ) {
|
|
55684
|
+
|
|
55685
|
+
_zoomStart.copy( _zoomEnd );
|
|
55686
|
+
|
|
55687
|
+
} else {
|
|
55688
|
+
|
|
55689
|
+
_zoomStart.y += ( _zoomEnd.y - _zoomStart.y ) * this.dynamicDampingFactor;
|
|
55690
|
+
|
|
55691
|
+
}
|
|
55692
|
+
|
|
55693
|
+
}
|
|
55694
|
+
|
|
55695
|
+
};
|
|
55696
|
+
|
|
55697
|
+
this.panCamera = ( function () {
|
|
55698
|
+
|
|
55699
|
+
const mouseChange = new Vector2(),
|
|
55700
|
+
objectUp = new Vector3(),
|
|
55701
|
+
pan = new Vector3();
|
|
55702
|
+
|
|
55703
|
+
return function panCamera() {
|
|
55704
|
+
|
|
55705
|
+
mouseChange.copy( _panEnd ).sub( _panStart );
|
|
55706
|
+
|
|
55707
|
+
if ( mouseChange.lengthSq() ) {
|
|
55708
|
+
|
|
55709
|
+
if ( scope.object.isOrthographicCamera ) {
|
|
55710
|
+
|
|
55711
|
+
const scale_x = ( scope.object.right - scope.object.left ) / scope.object.zoom / scope.domElement.clientWidth;
|
|
55712
|
+
const scale_y = ( scope.object.top - scope.object.bottom ) / scope.object.zoom / scope.domElement.clientWidth;
|
|
55713
|
+
|
|
55714
|
+
mouseChange.x *= scale_x;
|
|
55715
|
+
mouseChange.y *= scale_y;
|
|
55716
|
+
|
|
55717
|
+
}
|
|
55718
|
+
|
|
55719
|
+
mouseChange.multiplyScalar( _eye.length() * scope.panSpeed );
|
|
55720
|
+
|
|
55721
|
+
pan.copy( _eye ).cross( scope.object.up ).setLength( mouseChange.x );
|
|
55722
|
+
pan.add( objectUp.copy( scope.object.up ).setLength( mouseChange.y ) );
|
|
55723
|
+
|
|
55724
|
+
scope.object.position.add( pan );
|
|
55725
|
+
scope.target.add( pan );
|
|
55726
|
+
|
|
55727
|
+
if ( scope.staticMoving ) {
|
|
55728
|
+
|
|
55729
|
+
_panStart.copy( _panEnd );
|
|
55730
|
+
|
|
55731
|
+
} else {
|
|
55732
|
+
|
|
55733
|
+
_panStart.add( mouseChange.subVectors( _panEnd, _panStart ).multiplyScalar( scope.dynamicDampingFactor ) );
|
|
55734
|
+
|
|
55735
|
+
}
|
|
55736
|
+
|
|
55737
|
+
}
|
|
55738
|
+
|
|
55739
|
+
};
|
|
55740
|
+
|
|
55741
|
+
}() );
|
|
55742
|
+
|
|
55743
|
+
this.checkDistances = function () {
|
|
55744
|
+
|
|
55745
|
+
if ( ! scope.noZoom || ! scope.noPan ) {
|
|
55746
|
+
|
|
55747
|
+
if ( _eye.lengthSq() > scope.maxDistance * scope.maxDistance ) {
|
|
55748
|
+
|
|
55749
|
+
scope.object.position.addVectors( scope.target, _eye.setLength( scope.maxDistance ) );
|
|
55750
|
+
_zoomStart.copy( _zoomEnd );
|
|
55751
|
+
|
|
55752
|
+
}
|
|
55753
|
+
|
|
55754
|
+
if ( _eye.lengthSq() < scope.minDistance * scope.minDistance ) {
|
|
55755
|
+
|
|
55756
|
+
scope.object.position.addVectors( scope.target, _eye.setLength( scope.minDistance ) );
|
|
55757
|
+
_zoomStart.copy( _zoomEnd );
|
|
55758
|
+
|
|
55759
|
+
}
|
|
55760
|
+
|
|
55761
|
+
}
|
|
55762
|
+
|
|
55763
|
+
};
|
|
55764
|
+
|
|
55765
|
+
this.update = function () {
|
|
55766
|
+
|
|
55767
|
+
_eye.subVectors( scope.object.position, scope.target );
|
|
55768
|
+
|
|
55769
|
+
if ( ! scope.noRotate ) {
|
|
55770
|
+
|
|
55771
|
+
scope.rotateCamera();
|
|
55772
|
+
|
|
55773
|
+
}
|
|
55774
|
+
|
|
55775
|
+
if ( ! scope.noZoom ) {
|
|
55776
|
+
|
|
55777
|
+
scope.zoomCamera();
|
|
55778
|
+
|
|
55779
|
+
}
|
|
55780
|
+
|
|
55781
|
+
if ( ! scope.noPan ) {
|
|
55782
|
+
|
|
55783
|
+
scope.panCamera();
|
|
55784
|
+
|
|
55785
|
+
}
|
|
55786
|
+
|
|
55787
|
+
scope.object.position.addVectors( scope.target, _eye );
|
|
55788
|
+
|
|
55789
|
+
if ( scope.object.isPerspectiveCamera ) {
|
|
55790
|
+
|
|
55791
|
+
scope.checkDistances();
|
|
55792
|
+
|
|
55793
|
+
scope.object.lookAt( scope.target );
|
|
55794
|
+
|
|
55795
|
+
if ( lastPosition.distanceToSquared( scope.object.position ) > EPS ) {
|
|
55796
|
+
|
|
55797
|
+
scope.dispatchEvent( _changeEvent );
|
|
55798
|
+
|
|
55799
|
+
lastPosition.copy( scope.object.position );
|
|
55800
|
+
|
|
55801
|
+
}
|
|
55802
|
+
|
|
55803
|
+
} else if ( scope.object.isOrthographicCamera ) {
|
|
55804
|
+
|
|
55805
|
+
scope.object.lookAt( scope.target );
|
|
55806
|
+
|
|
55807
|
+
if ( lastPosition.distanceToSquared( scope.object.position ) > EPS || lastZoom !== scope.object.zoom ) {
|
|
55808
|
+
|
|
55809
|
+
scope.dispatchEvent( _changeEvent );
|
|
55810
|
+
|
|
55811
|
+
lastPosition.copy( scope.object.position );
|
|
55812
|
+
lastZoom = scope.object.zoom;
|
|
55813
|
+
|
|
55814
|
+
}
|
|
55815
|
+
|
|
55816
|
+
} else {
|
|
55817
|
+
|
|
55818
|
+
console.warn( 'THREE.TrackballControls: Unsupported camera type' );
|
|
55819
|
+
|
|
55820
|
+
}
|
|
55821
|
+
|
|
55822
|
+
};
|
|
55823
|
+
|
|
55824
|
+
this.reset = function () {
|
|
55825
|
+
|
|
55826
|
+
_state = STATE.NONE;
|
|
55827
|
+
_keyState = STATE.NONE;
|
|
55828
|
+
|
|
55829
|
+
scope.target.copy( scope.target0 );
|
|
55830
|
+
scope.object.position.copy( scope.position0 );
|
|
55831
|
+
scope.object.up.copy( scope.up0 );
|
|
55832
|
+
scope.object.zoom = scope.zoom0;
|
|
55833
|
+
|
|
55834
|
+
scope.object.updateProjectionMatrix();
|
|
55835
|
+
|
|
55836
|
+
_eye.subVectors( scope.object.position, scope.target );
|
|
55837
|
+
|
|
55838
|
+
scope.object.lookAt( scope.target );
|
|
55839
|
+
|
|
55840
|
+
scope.dispatchEvent( _changeEvent );
|
|
55841
|
+
|
|
55842
|
+
lastPosition.copy( scope.object.position );
|
|
55843
|
+
lastZoom = scope.object.zoom;
|
|
55844
|
+
|
|
55845
|
+
};
|
|
55846
|
+
|
|
55847
|
+
// listeners
|
|
55848
|
+
|
|
55849
|
+
function onPointerDown( event ) {
|
|
55850
|
+
|
|
55851
|
+
if ( scope.enabled === false ) return;
|
|
55852
|
+
|
|
55853
|
+
if ( _pointers.length === 0 ) {
|
|
55854
|
+
|
|
55855
|
+
scope.domElement.setPointerCapture( event.pointerId );
|
|
55856
|
+
|
|
55857
|
+
scope.domElement.addEventListener( 'pointermove', onPointerMove );
|
|
55858
|
+
scope.domElement.addEventListener( 'pointerup', onPointerUp );
|
|
55859
|
+
|
|
55860
|
+
}
|
|
55861
|
+
|
|
55862
|
+
//
|
|
55863
|
+
|
|
55864
|
+
addPointer( event );
|
|
55865
|
+
|
|
55866
|
+
if ( event.pointerType === 'touch' ) {
|
|
55867
|
+
|
|
55868
|
+
onTouchStart( event );
|
|
55869
|
+
|
|
55870
|
+
} else {
|
|
55871
|
+
|
|
55872
|
+
onMouseDown( event );
|
|
55873
|
+
|
|
55874
|
+
}
|
|
55875
|
+
|
|
55876
|
+
}
|
|
55877
|
+
|
|
55878
|
+
function onPointerMove( event ) {
|
|
55879
|
+
|
|
55880
|
+
if ( scope.enabled === false ) return;
|
|
55881
|
+
|
|
55882
|
+
if ( event.pointerType === 'touch' ) {
|
|
55883
|
+
|
|
55884
|
+
onTouchMove( event );
|
|
55885
|
+
|
|
55886
|
+
} else {
|
|
55887
|
+
|
|
55888
|
+
onMouseMove( event );
|
|
55889
|
+
|
|
55890
|
+
}
|
|
55891
|
+
|
|
55892
|
+
}
|
|
55893
|
+
|
|
55894
|
+
function onPointerUp( event ) {
|
|
55895
|
+
|
|
55896
|
+
if ( scope.enabled === false ) return;
|
|
55897
|
+
|
|
55898
|
+
if ( event.pointerType === 'touch' ) {
|
|
55899
|
+
|
|
55900
|
+
onTouchEnd( event );
|
|
55901
|
+
|
|
55902
|
+
} else {
|
|
55903
|
+
|
|
55904
|
+
onMouseUp();
|
|
55905
|
+
|
|
55906
|
+
}
|
|
55907
|
+
|
|
55908
|
+
//
|
|
55909
|
+
|
|
55910
|
+
removePointer( event );
|
|
55911
|
+
|
|
55912
|
+
if ( _pointers.length === 0 ) {
|
|
55913
|
+
|
|
55914
|
+
scope.domElement.releasePointerCapture( event.pointerId );
|
|
55915
|
+
|
|
55916
|
+
scope.domElement.removeEventListener( 'pointermove', onPointerMove );
|
|
55917
|
+
scope.domElement.removeEventListener( 'pointerup', onPointerUp );
|
|
55918
|
+
|
|
55919
|
+
}
|
|
55920
|
+
|
|
55921
|
+
|
|
55922
|
+
}
|
|
55923
|
+
|
|
55924
|
+
function onPointerCancel( event ) {
|
|
55925
|
+
|
|
55926
|
+
removePointer( event );
|
|
55927
|
+
|
|
55928
|
+
}
|
|
55929
|
+
|
|
55930
|
+
function keydown( event ) {
|
|
55931
|
+
|
|
55932
|
+
if ( scope.enabled === false ) return;
|
|
55933
|
+
|
|
55934
|
+
window.removeEventListener( 'keydown', keydown );
|
|
55935
|
+
|
|
55936
|
+
if ( _keyState !== STATE.NONE ) {
|
|
55937
|
+
|
|
55938
|
+
return;
|
|
55939
|
+
|
|
55940
|
+
} else if ( event.code === scope.keys[ STATE.ROTATE ] && ! scope.noRotate ) {
|
|
55941
|
+
|
|
55942
|
+
_keyState = STATE.ROTATE;
|
|
55943
|
+
|
|
55944
|
+
} else if ( event.code === scope.keys[ STATE.ZOOM ] && ! scope.noZoom ) {
|
|
55945
|
+
|
|
55946
|
+
_keyState = STATE.ZOOM;
|
|
55947
|
+
|
|
55948
|
+
} else if ( event.code === scope.keys[ STATE.PAN ] && ! scope.noPan ) {
|
|
55949
|
+
|
|
55950
|
+
_keyState = STATE.PAN;
|
|
55951
|
+
|
|
55952
|
+
}
|
|
55953
|
+
|
|
55954
|
+
}
|
|
55955
|
+
|
|
55956
|
+
function keyup() {
|
|
55957
|
+
|
|
55958
|
+
if ( scope.enabled === false ) return;
|
|
55959
|
+
|
|
55960
|
+
_keyState = STATE.NONE;
|
|
55961
|
+
|
|
55962
|
+
window.addEventListener( 'keydown', keydown );
|
|
55963
|
+
|
|
55964
|
+
}
|
|
55965
|
+
|
|
55966
|
+
function onMouseDown( event ) {
|
|
55967
|
+
|
|
55968
|
+
if ( _state === STATE.NONE ) {
|
|
55969
|
+
|
|
55970
|
+
switch ( event.button ) {
|
|
55971
|
+
|
|
55972
|
+
case scope.mouseButtons.LEFT:
|
|
55973
|
+
_state = STATE.ROTATE;
|
|
55974
|
+
break;
|
|
55975
|
+
|
|
55976
|
+
case scope.mouseButtons.MIDDLE:
|
|
55977
|
+
_state = STATE.ZOOM;
|
|
55978
|
+
break;
|
|
55979
|
+
|
|
55980
|
+
case scope.mouseButtons.RIGHT:
|
|
55981
|
+
_state = STATE.PAN;
|
|
55982
|
+
break;
|
|
55983
|
+
|
|
55984
|
+
}
|
|
55985
|
+
|
|
55986
|
+
}
|
|
55987
|
+
|
|
55988
|
+
const state = ( _keyState !== STATE.NONE ) ? _keyState : _state;
|
|
55989
|
+
|
|
55990
|
+
if ( state === STATE.ROTATE && ! scope.noRotate ) {
|
|
55991
|
+
|
|
55992
|
+
_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );
|
|
55993
|
+
_movePrev.copy( _moveCurr );
|
|
55994
|
+
|
|
55995
|
+
} else if ( state === STATE.ZOOM && ! scope.noZoom ) {
|
|
55996
|
+
|
|
55997
|
+
_zoomStart.copy( getMouseOnScreen( event.pageX, event.pageY ) );
|
|
55998
|
+
_zoomEnd.copy( _zoomStart );
|
|
55999
|
+
|
|
56000
|
+
} else if ( state === STATE.PAN && ! scope.noPan ) {
|
|
56001
|
+
|
|
56002
|
+
_panStart.copy( getMouseOnScreen( event.pageX, event.pageY ) );
|
|
56003
|
+
_panEnd.copy( _panStart );
|
|
56004
|
+
|
|
56005
|
+
}
|
|
56006
|
+
|
|
56007
|
+
scope.dispatchEvent( _startEvent );
|
|
56008
|
+
|
|
56009
|
+
}
|
|
56010
|
+
|
|
56011
|
+
function onMouseMove( event ) {
|
|
56012
|
+
|
|
56013
|
+
const state = ( _keyState !== STATE.NONE ) ? _keyState : _state;
|
|
56014
|
+
|
|
56015
|
+
if ( state === STATE.ROTATE && ! scope.noRotate ) {
|
|
56016
|
+
|
|
56017
|
+
_movePrev.copy( _moveCurr );
|
|
56018
|
+
_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );
|
|
56019
|
+
|
|
56020
|
+
} else if ( state === STATE.ZOOM && ! scope.noZoom ) {
|
|
56021
|
+
|
|
56022
|
+
_zoomEnd.copy( getMouseOnScreen( event.pageX, event.pageY ) );
|
|
56023
|
+
|
|
56024
|
+
} else if ( state === STATE.PAN && ! scope.noPan ) {
|
|
56025
|
+
|
|
56026
|
+
_panEnd.copy( getMouseOnScreen( event.pageX, event.pageY ) );
|
|
56027
|
+
|
|
56028
|
+
}
|
|
56029
|
+
|
|
56030
|
+
}
|
|
56031
|
+
|
|
56032
|
+
function onMouseUp() {
|
|
56033
|
+
|
|
56034
|
+
_state = STATE.NONE;
|
|
56035
|
+
|
|
56036
|
+
scope.dispatchEvent( _endEvent );
|
|
56037
|
+
|
|
56038
|
+
}
|
|
56039
|
+
|
|
56040
|
+
function onMouseWheel( event ) {
|
|
56041
|
+
|
|
56042
|
+
if ( scope.enabled === false ) return;
|
|
56043
|
+
|
|
56044
|
+
if ( scope.noZoom === true ) return;
|
|
56045
|
+
|
|
56046
|
+
event.preventDefault();
|
|
56047
|
+
|
|
56048
|
+
switch ( event.deltaMode ) {
|
|
56049
|
+
|
|
56050
|
+
case 2:
|
|
56051
|
+
// Zoom in pages
|
|
56052
|
+
_zoomStart.y -= event.deltaY * 0.025;
|
|
56053
|
+
break;
|
|
56054
|
+
|
|
56055
|
+
case 1:
|
|
56056
|
+
// Zoom in lines
|
|
56057
|
+
_zoomStart.y -= event.deltaY * 0.01;
|
|
56058
|
+
break;
|
|
56059
|
+
|
|
56060
|
+
default:
|
|
56061
|
+
// undefined, 0, assume pixels
|
|
56062
|
+
_zoomStart.y -= event.deltaY * 0.00025;
|
|
56063
|
+
break;
|
|
56064
|
+
|
|
56065
|
+
}
|
|
56066
|
+
|
|
56067
|
+
scope.dispatchEvent( _startEvent );
|
|
56068
|
+
scope.dispatchEvent( _endEvent );
|
|
56069
|
+
|
|
56070
|
+
}
|
|
56071
|
+
|
|
56072
|
+
function onTouchStart( event ) {
|
|
56073
|
+
|
|
56074
|
+
trackPointer( event );
|
|
56075
|
+
|
|
56076
|
+
switch ( _pointers.length ) {
|
|
56077
|
+
|
|
56078
|
+
case 1:
|
|
56079
|
+
_state = STATE.TOUCH_ROTATE;
|
|
56080
|
+
_moveCurr.copy( getMouseOnCircle( _pointers[ 0 ].pageX, _pointers[ 0 ].pageY ) );
|
|
56081
|
+
_movePrev.copy( _moveCurr );
|
|
56082
|
+
break;
|
|
56083
|
+
|
|
56084
|
+
default: // 2 or more
|
|
56085
|
+
_state = STATE.TOUCH_ZOOM_PAN;
|
|
56086
|
+
const dx = _pointers[ 0 ].pageX - _pointers[ 1 ].pageX;
|
|
56087
|
+
const dy = _pointers[ 0 ].pageY - _pointers[ 1 ].pageY;
|
|
56088
|
+
_touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt( dx * dx + dy * dy );
|
|
56089
|
+
|
|
56090
|
+
const x = ( _pointers[ 0 ].pageX + _pointers[ 1 ].pageX ) / 2;
|
|
56091
|
+
const y = ( _pointers[ 0 ].pageY + _pointers[ 1 ].pageY ) / 2;
|
|
56092
|
+
_panStart.copy( getMouseOnScreen( x, y ) );
|
|
56093
|
+
_panEnd.copy( _panStart );
|
|
56094
|
+
break;
|
|
56095
|
+
|
|
56096
|
+
}
|
|
56097
|
+
|
|
56098
|
+
scope.dispatchEvent( _startEvent );
|
|
56099
|
+
|
|
56100
|
+
}
|
|
56101
|
+
|
|
56102
|
+
function onTouchMove( event ) {
|
|
56103
|
+
|
|
56104
|
+
trackPointer( event );
|
|
56105
|
+
|
|
56106
|
+
switch ( _pointers.length ) {
|
|
56107
|
+
|
|
56108
|
+
case 1:
|
|
56109
|
+
_movePrev.copy( _moveCurr );
|
|
56110
|
+
_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );
|
|
56111
|
+
break;
|
|
56112
|
+
|
|
56113
|
+
default: // 2 or more
|
|
56114
|
+
|
|
56115
|
+
const position = getSecondPointerPosition( event );
|
|
56116
|
+
|
|
56117
|
+
const dx = event.pageX - position.x;
|
|
56118
|
+
const dy = event.pageY - position.y;
|
|
56119
|
+
_touchZoomDistanceEnd = Math.sqrt( dx * dx + dy * dy );
|
|
56120
|
+
|
|
56121
|
+
const x = ( event.pageX + position.x ) / 2;
|
|
56122
|
+
const y = ( event.pageY + position.y ) / 2;
|
|
56123
|
+
_panEnd.copy( getMouseOnScreen( x, y ) );
|
|
56124
|
+
break;
|
|
56125
|
+
|
|
56126
|
+
}
|
|
56127
|
+
|
|
56128
|
+
}
|
|
56129
|
+
|
|
56130
|
+
function onTouchEnd( event ) {
|
|
56131
|
+
|
|
56132
|
+
switch ( _pointers.length ) {
|
|
56133
|
+
|
|
56134
|
+
case 0:
|
|
56135
|
+
_state = STATE.NONE;
|
|
56136
|
+
break;
|
|
56137
|
+
|
|
56138
|
+
case 1:
|
|
56139
|
+
_state = STATE.TOUCH_ROTATE;
|
|
56140
|
+
_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );
|
|
56141
|
+
_movePrev.copy( _moveCurr );
|
|
56142
|
+
break;
|
|
56143
|
+
|
|
56144
|
+
case 2:
|
|
56145
|
+
_state = STATE.TOUCH_ZOOM_PAN;
|
|
56146
|
+
|
|
56147
|
+
for ( let i = 0; i < _pointers.length; i ++ ) {
|
|
56148
|
+
|
|
56149
|
+
if ( _pointers[ i ].pointerId !== event.pointerId ) {
|
|
56150
|
+
|
|
56151
|
+
const position = _pointerPositions[ _pointers[ i ].pointerId ];
|
|
56152
|
+
_moveCurr.copy( getMouseOnCircle( position.x, position.y ) );
|
|
56153
|
+
_movePrev.copy( _moveCurr );
|
|
56154
|
+
break;
|
|
56155
|
+
|
|
56156
|
+
}
|
|
56157
|
+
|
|
56158
|
+
}
|
|
56159
|
+
|
|
56160
|
+
break;
|
|
56161
|
+
|
|
56162
|
+
}
|
|
56163
|
+
|
|
56164
|
+
scope.dispatchEvent( _endEvent );
|
|
56165
|
+
|
|
56166
|
+
}
|
|
56167
|
+
|
|
56168
|
+
function contextmenu( event ) {
|
|
56169
|
+
|
|
56170
|
+
if ( scope.enabled === false ) return;
|
|
56171
|
+
|
|
56172
|
+
event.preventDefault();
|
|
56173
|
+
|
|
56174
|
+
}
|
|
56175
|
+
|
|
56176
|
+
function addPointer( event ) {
|
|
56177
|
+
|
|
56178
|
+
_pointers.push( event );
|
|
56179
|
+
|
|
56180
|
+
}
|
|
56181
|
+
|
|
56182
|
+
function removePointer( event ) {
|
|
56183
|
+
|
|
56184
|
+
delete _pointerPositions[ event.pointerId ];
|
|
56185
|
+
|
|
56186
|
+
for ( let i = 0; i < _pointers.length; i ++ ) {
|
|
56187
|
+
|
|
56188
|
+
if ( _pointers[ i ].pointerId == event.pointerId ) {
|
|
56189
|
+
|
|
56190
|
+
_pointers.splice( i, 1 );
|
|
56191
|
+
return;
|
|
56192
|
+
|
|
56193
|
+
}
|
|
56194
|
+
|
|
56195
|
+
}
|
|
56196
|
+
|
|
56197
|
+
}
|
|
56198
|
+
|
|
56199
|
+
function trackPointer( event ) {
|
|
56200
|
+
|
|
56201
|
+
let position = _pointerPositions[ event.pointerId ];
|
|
56202
|
+
|
|
56203
|
+
if ( position === undefined ) {
|
|
56204
|
+
|
|
56205
|
+
position = new Vector2();
|
|
56206
|
+
_pointerPositions[ event.pointerId ] = position;
|
|
56207
|
+
|
|
56208
|
+
}
|
|
56209
|
+
|
|
56210
|
+
position.set( event.pageX, event.pageY );
|
|
56211
|
+
|
|
56212
|
+
}
|
|
56213
|
+
|
|
56214
|
+
function getSecondPointerPosition( event ) {
|
|
56215
|
+
|
|
56216
|
+
const pointer = ( event.pointerId === _pointers[ 0 ].pointerId ) ? _pointers[ 1 ] : _pointers[ 0 ];
|
|
56217
|
+
|
|
56218
|
+
return _pointerPositions[ pointer.pointerId ];
|
|
56219
|
+
|
|
56220
|
+
}
|
|
56221
|
+
|
|
56222
|
+
this.dispose = function () {
|
|
56223
|
+
|
|
56224
|
+
scope.domElement.removeEventListener( 'contextmenu', contextmenu );
|
|
56225
|
+
|
|
56226
|
+
scope.domElement.removeEventListener( 'pointerdown', onPointerDown );
|
|
56227
|
+
scope.domElement.removeEventListener( 'pointercancel', onPointerCancel );
|
|
56228
|
+
scope.domElement.removeEventListener( 'wheel', onMouseWheel );
|
|
56229
|
+
|
|
56230
|
+
scope.domElement.removeEventListener( 'pointermove', onPointerMove );
|
|
56231
|
+
scope.domElement.removeEventListener( 'pointerup', onPointerUp );
|
|
56232
|
+
|
|
56233
|
+
window.removeEventListener( 'keydown', keydown );
|
|
56234
|
+
window.removeEventListener( 'keyup', keyup );
|
|
56235
|
+
|
|
56236
|
+
};
|
|
56237
|
+
|
|
56238
|
+
this.domElement.addEventListener( 'contextmenu', contextmenu );
|
|
56239
|
+
|
|
56240
|
+
this.domElement.addEventListener( 'pointerdown', onPointerDown );
|
|
56241
|
+
this.domElement.addEventListener( 'pointercancel', onPointerCancel );
|
|
56242
|
+
this.domElement.addEventListener( 'wheel', onMouseWheel, { passive: false } );
|
|
56243
|
+
|
|
56244
|
+
|
|
56245
|
+
window.addEventListener( 'keydown', keydown );
|
|
56246
|
+
window.addEventListener( 'keyup', keyup );
|
|
56247
|
+
|
|
56248
|
+
this.handleResize();
|
|
56249
|
+
|
|
56250
|
+
// force an update at start
|
|
56251
|
+
this.update();
|
|
56252
|
+
|
|
56253
|
+
}
|
|
56254
|
+
|
|
56255
|
+
}
|
|
56256
|
+
|
|
56257
|
+
class copperScene extends baseScene {
|
|
56258
|
+
// private preRenderCallbackFunctions: Array<preRenderCallbackFunctionType> = [];
|
|
56259
|
+
// private preRenderCallbackFunctions: preRenderCallbackFunctionType;
|
|
56260
|
+
// private sort: boolean = true; //default ascending order
|
|
56261
|
+
constructor(container, renderer, controls, alpha) {
|
|
56262
|
+
super(container, renderer, alpha);
|
|
56263
|
+
this.clock = new Clock();
|
|
56264
|
+
// isHalfed: boolean = false;
|
|
56265
|
+
this.mixer = null;
|
|
56266
|
+
this.playRate = 1.0;
|
|
56267
|
+
this.modelReady = false;
|
|
56268
|
+
// rayster pick
|
|
56269
|
+
// texture2d
|
|
56270
|
+
// private depthStep: number = 0.4;
|
|
56271
|
+
this.texture2dMesh = null;
|
|
56272
|
+
if (controls === "trackball") {
|
|
56273
|
+
this.controls = new TrackballControls(this.camera, this.renderer.domElement);
|
|
56274
|
+
}
|
|
56275
|
+
else if (controls === "orbit") {
|
|
56276
|
+
this.controls = new OrbitControls(this.camera, this.renderer.domElement);
|
|
56277
|
+
}
|
|
56278
|
+
else {
|
|
56279
|
+
this.controls = new Copper3dTrackballControls(this.camera, this.renderer.domElement);
|
|
56280
|
+
}
|
|
56281
|
+
this.controls.panSpeed = 3;
|
|
56282
|
+
this.controls.rotateSpeed = 3;
|
|
56283
|
+
window.addEventListener("resize", this.onWindowResize, false);
|
|
56284
|
+
}
|
|
56285
|
+
loadGltf(url, callback) {
|
|
56286
|
+
const loader = copperGltfLoader(this.renderer);
|
|
56287
|
+
loader.load(url, (gltf) => {
|
|
56288
|
+
const box = new Box3().setFromObject(gltf.scene);
|
|
56289
|
+
const size = box.getSize(new Vector3()).length();
|
|
56290
|
+
const center = box.getCenter(new Vector3());
|
|
56291
|
+
this.controls.maxDistance = size * 10;
|
|
56292
|
+
gltf.scene.position.x += gltf.scene.position.x - center.x;
|
|
56293
|
+
gltf.scene.position.y += gltf.scene.position.y - center.y;
|
|
56294
|
+
gltf.scene.position.z += gltf.scene.position.z - center.z;
|
|
56295
|
+
if (!this.cameraPositionFlag) {
|
|
56296
|
+
this.camera.position.copy(center);
|
|
56297
|
+
this.camera.position.x += size / 2.0;
|
|
56298
|
+
this.camera.position.y += size / 5.0;
|
|
56299
|
+
this.camera.position.z += size / 2.0;
|
|
56300
|
+
this.camera.lookAt(center);
|
|
56301
|
+
this.viewPoint = this.setViewPoint(this.camera, [center.x, center.y, center.z]);
|
|
56302
|
+
}
|
|
56303
|
+
this.mixer = new AnimationMixer(gltf.scene);
|
|
56304
|
+
gltf.animations.forEach((a, index) => {
|
|
56305
|
+
var _a, _b;
|
|
56306
|
+
if (index === 0)
|
|
56307
|
+
this.clipAction = (_a = this.mixer) === null || _a === void 0 ? void 0 : _a.clipAction(a).play();
|
|
56308
|
+
else
|
|
56309
|
+
(_b = this.mixer) === null || _b === void 0 ? void 0 : _b.clipAction(a).play();
|
|
56310
|
+
});
|
|
56311
|
+
this.content = gltf.scene;
|
|
56312
|
+
this.exportContent.copy(gltf.scene);
|
|
56313
|
+
this.exportContent.animations = gltf.animations;
|
|
56314
|
+
this.scene.add(gltf.scene);
|
|
56315
|
+
this.modelReady = true;
|
|
56316
|
+
callback && callback(gltf.scene);
|
|
56317
|
+
}, (error) => {
|
|
56318
|
+
// console.log(error);
|
|
56319
|
+
});
|
|
56320
|
+
}
|
|
56321
|
+
// loadOBJ(url: string, callback?: (mesh: THREE.Group) => void) {
|
|
56322
|
+
// objLoader.load(
|
|
56323
|
+
// url,
|
|
56324
|
+
// (obj) => {
|
|
56325
|
+
// obj.traverse((child) => {
|
|
56326
|
+
// if ((child as THREE.Mesh).isMesh) {
|
|
56327
|
+
// // (child as THREE.Mesh).material = new THREE.MeshStandardMaterial({
|
|
56328
|
+
// // side: THREE.DoubleSide,
|
|
56329
|
+
// // color: 0xffffff,
|
|
56330
|
+
// // });
|
|
56331
|
+
// // ((child as THREE.Mesh).material as THREE.MeshPhongMaterial).color =
|
|
56332
|
+
// // new THREE.Color(0xffffff);
|
|
56333
|
+
// }
|
|
56334
|
+
// });
|
|
56335
|
+
// const box = new THREE.Box3().setFromObject(obj);
|
|
56336
|
+
// const size = box.getSize(new THREE.Vector3()).length();
|
|
56337
|
+
// const center = box.getCenter(new THREE.Vector3());
|
|
56338
|
+
// this.controls.maxDistance = size * 10;
|
|
56339
|
+
// obj.position.x += obj.position.x - center.x;
|
|
56340
|
+
// obj.position.y += obj.position.y - center.y;
|
|
56341
|
+
// obj.position.z += obj.position.z - center.z;
|
|
56342
|
+
// if (!this.cameraPositionFlag) {
|
|
56343
|
+
// this.camera.position.copy(center);
|
|
56344
|
+
// this.camera.position.x += size / 2.0;
|
|
56345
|
+
// this.camera.position.y += size / 5.0;
|
|
56346
|
+
// this.camera.position.z += size / 2.0;
|
|
56347
|
+
// this.camera.lookAt(center);
|
|
56348
|
+
// this.viewPoint = this.setViewPoint(
|
|
56349
|
+
// this.camera as THREE.PerspectiveCamera,
|
|
56350
|
+
// [center.x, center.y, center.z]
|
|
56351
|
+
// );
|
|
56352
|
+
// }
|
|
56353
|
+
// this.scene.add(obj);
|
|
56354
|
+
// !!callback && callback(obj);
|
|
56355
|
+
// }, // called when loading is in progresses
|
|
56356
|
+
// (xhr: any) => {
|
|
56357
|
+
// console.log((xhr.loaded / xhr.total) * 100 + "% loaded");
|
|
56358
|
+
// },
|
|
56359
|
+
// // called when loading has errors
|
|
56360
|
+
// (error: any) => {
|
|
56361
|
+
// console.log("An error happened");
|
|
56362
|
+
// }
|
|
56363
|
+
// );
|
|
56364
|
+
// }
|
|
56365
|
+
loadVtk(url) {
|
|
56366
|
+
copperVtkLoader(url, this.scene, this.content);
|
|
56367
|
+
}
|
|
56368
|
+
loadVtks(models) {
|
|
56369
|
+
let count = 0;
|
|
56370
|
+
let { vtkLoader } = copperMultipleVtk();
|
|
56371
|
+
const group = new Group();
|
|
56372
|
+
const finishInterval = setInterval(() => {
|
|
56373
|
+
if (count === models.length) {
|
|
56374
|
+
this.scene.add(this.exportContent);
|
|
56375
|
+
this.mixer = new AnimationMixer(group);
|
|
56376
|
+
this.exportContent.animations.forEach((clip) => {
|
|
56377
|
+
var _a;
|
|
56378
|
+
const action = (_a = this.mixer) === null || _a === void 0 ? void 0 : _a.clipAction(clip);
|
|
56379
|
+
action.timeScale = 3;
|
|
56380
|
+
action.play();
|
|
56381
|
+
});
|
|
56382
|
+
this.modelReady = true;
|
|
56383
|
+
clearInterval(finishInterval);
|
|
56384
|
+
}
|
|
56385
|
+
}, 100);
|
|
56386
|
+
models.forEach((model) => {
|
|
56387
|
+
const geometries = [];
|
|
56388
|
+
model.urls.forEach((url, index) => {
|
|
56389
|
+
vtkLoader.load(url, (geometry) => {
|
|
56390
|
+
geometry.center();
|
|
56391
|
+
geometry.computeVertexNormals();
|
|
56392
|
+
geometry.name = index.toString();
|
|
56393
|
+
geometries.push(geometry);
|
|
56394
|
+
if (geometries.length === model.urls.length) {
|
|
56395
|
+
// sort the vtks by index order
|
|
56396
|
+
geometries.sort((a, b) => {
|
|
56397
|
+
if (this.sort) {
|
|
56398
|
+
return parseInt(a.name) - parseInt(b.name);
|
|
56399
|
+
}
|
|
56400
|
+
else {
|
|
56401
|
+
return parseInt(b.name) - parseInt(a.name);
|
|
56402
|
+
}
|
|
56403
|
+
});
|
|
56404
|
+
finishLoad(geometries, model);
|
|
56405
|
+
count += 1;
|
|
56406
|
+
}
|
|
56407
|
+
});
|
|
56408
|
+
});
|
|
56409
|
+
});
|
|
56410
|
+
const finishLoad = (geometries, model) => {
|
|
56411
|
+
let { vtkmaterial } = copperMultipleVtk(model.opts);
|
|
56412
|
+
let geometry = geometries[0];
|
|
56413
|
+
geometry.attributes.position;
|
|
56414
|
+
geometries.forEach((child, index) => {
|
|
56415
|
+
if (index === 0) {
|
|
56416
|
+
geometry = child;
|
|
56417
|
+
geometry.morphAttributes.position = [];
|
|
56418
|
+
}
|
|
56419
|
+
else {
|
|
56420
|
+
// if (index == 1) {
|
|
56421
|
+
// geometry.morphAttributes.position.push(position);
|
|
56422
|
+
// }
|
|
56423
|
+
// if (index == 6) {
|
|
56424
|
+
// geometry.morphAttributes.position.push(child.attributes.position);
|
|
56425
|
+
// }
|
|
56426
|
+
// if (index == 7) {
|
|
56427
|
+
// geometry.morphAttributes.position.push(position);
|
|
56428
|
+
// }
|
|
56429
|
+
geometry.morphAttributes.position.push(child.attributes.position);
|
|
56430
|
+
}
|
|
56431
|
+
});
|
|
56432
|
+
const mesh = new Mesh(geometry, vtkmaterial);
|
|
56433
|
+
mesh.scale.multiplyScalar(0.1);
|
|
56434
|
+
group.add(mesh);
|
|
56435
|
+
this.exportContent.add(group);
|
|
56436
|
+
mesh.morphTargetInfluences = [];
|
|
56437
|
+
mesh.name = model.name;
|
|
56438
|
+
let j = 0;
|
|
56439
|
+
let tracks = [];
|
|
56440
|
+
let duration = geometries.length - 1;
|
|
56441
|
+
// let duration = 5;
|
|
56442
|
+
for (let i = 0; i < duration; i++) {
|
|
56443
|
+
const track = new KeyframeTrack(`${mesh.name}.morphTargetInfluences[${i}]`, [j, j + 1, j + 2], [0, 1, 0]);
|
|
56444
|
+
tracks.push(track);
|
|
56445
|
+
j = j + 2;
|
|
56446
|
+
}
|
|
56447
|
+
const clip = new AnimationClip(`copper3d_heart_morph_${mesh.name}`, duration, tracks);
|
|
56448
|
+
this.exportContent.animations.push(clip);
|
|
56449
|
+
};
|
|
56450
|
+
}
|
|
56451
|
+
// texture2d
|
|
56452
|
+
texture2d(url) {
|
|
56453
|
+
createTexture2D_Zip(url, this.scene);
|
|
56454
|
+
const textureInterval = setInterval(() => {
|
|
56455
|
+
var _a;
|
|
56456
|
+
this.scene.children.forEach((child) => {
|
|
56457
|
+
if (child.isMesh) {
|
|
56458
|
+
if (child.name === "texture2d_mesh_zip") {
|
|
56459
|
+
this.texture2dMesh = child;
|
|
56460
|
+
const render_texture2d = () => {
|
|
56461
|
+
if (this.texture2dMesh) {
|
|
56462
|
+
let value = this.texture2dMesh.material.uniforms["depth"].value;
|
|
56463
|
+
value += this.depthStep;
|
|
56464
|
+
if (value > 109.0 || value < 0.0) {
|
|
56465
|
+
if (value > 1.0)
|
|
56466
|
+
value = 109.0 * 2.0 - value;
|
|
56467
|
+
if (value < 0.0)
|
|
56468
|
+
value = -value;
|
|
56469
|
+
this.depthStep = -this.depthStep;
|
|
56470
|
+
}
|
|
56471
|
+
this.texture2dMesh.material.uniforms["depth"].value =
|
|
56472
|
+
value;
|
|
56473
|
+
}
|
|
56474
|
+
};
|
|
56475
|
+
this.addPreRenderCallbackFunction(render_texture2d);
|
|
56476
|
+
}
|
|
56477
|
+
}
|
|
56478
|
+
});
|
|
56479
|
+
if (((_a = this.texture2dMesh) === null || _a === void 0 ? void 0 : _a.name) === "texture2d_mesh_zip") {
|
|
56480
|
+
clearInterval(textureInterval);
|
|
56481
|
+
}
|
|
56482
|
+
}, 500);
|
|
56483
|
+
}
|
|
56484
|
+
getPlayRate() {
|
|
56485
|
+
return this.playRate;
|
|
56486
|
+
}
|
|
56487
|
+
setPlayRate(playRate) {
|
|
56488
|
+
this.playRate = playRate;
|
|
56489
|
+
}
|
|
56490
|
+
setModelPosition(model, position) {
|
|
56491
|
+
if (position.x)
|
|
56492
|
+
model.position.x = position.x;
|
|
56493
|
+
if (position.y)
|
|
56494
|
+
model.position.y = position.y;
|
|
56495
|
+
if (position.z)
|
|
56496
|
+
model.position.z = position.z;
|
|
56497
|
+
}
|
|
56498
|
+
resetView() {
|
|
56499
|
+
this.controls.reset();
|
|
56500
|
+
this.updateCamera(this.viewPoint);
|
|
56501
|
+
}
|
|
56502
|
+
updateCamera(viewpoint) {
|
|
56503
|
+
this.cameraPositionFlag = true;
|
|
56504
|
+
this.copperControl.updateCameraViewPoint(viewpoint);
|
|
56505
|
+
}
|
|
56506
|
+
getCurrentTime() {
|
|
56507
|
+
let currentTime = 0;
|
|
56508
|
+
if (this.clipAction) {
|
|
56509
|
+
currentTime = this.clipAction.time / this.clipAction._clip.duration;
|
|
56510
|
+
}
|
|
56511
|
+
return currentTime;
|
|
56512
|
+
}
|
|
56513
|
+
getCurrentMixer() {
|
|
55688
56514
|
return this.mixer;
|
|
55689
56515
|
}
|
|
55690
56516
|
updateControls(camera) {
|
|
@@ -55757,13 +56583,13 @@
|
|
|
55757
56583
|
}
|
|
55758
56584
|
}
|
|
55759
56585
|
createScene(name) {
|
|
55760
|
-
var _a;
|
|
56586
|
+
var _a, _b;
|
|
55761
56587
|
if (this.sceneMap[name] != undefined) {
|
|
55762
56588
|
return undefined;
|
|
55763
56589
|
}
|
|
55764
56590
|
else {
|
|
55765
56591
|
const alpha = !!((_a = this.options) === null || _a === void 0 ? void 0 : _a.alpha);
|
|
55766
|
-
const new_scene = new copperScene(this.container, this.renderer, alpha);
|
|
56592
|
+
const new_scene = new copperScene(this.container, this.renderer, (_b = this.options) === null || _b === void 0 ? void 0 : _b.controls, alpha);
|
|
55767
56593
|
new_scene.sceneName = name;
|
|
55768
56594
|
this.updateEnvironment(new_scene.vignette);
|
|
55769
56595
|
this.sceneMap[name] = new_scene;
|
|
@@ -68953,8 +69779,8 @@
|
|
|
68953
69779
|
}
|
|
68954
69780
|
|
|
68955
69781
|
// import * as kiwrious from "copper3d_plugin_heart_k";
|
|
68956
|
-
const REVISION = "v1.15.
|
|
68957
|
-
console.log("%cCopper3D Visualisation %cBeta:v1.15.
|
|
69782
|
+
const REVISION = "v1.15.1";
|
|
69783
|
+
console.log("%cCopper3D Visualisation %cBeta:v1.15.1", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
|
|
68958
69784
|
|
|
68959
69785
|
exports.CameraViewPoint = CameraViewPoint;
|
|
68960
69786
|
exports.Copper3dTrackballControls = Copper3dTrackballControls;
|