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