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.esm.js
CHANGED
|
@@ -45209,9 +45209,9 @@ class OBJLoader extends Loader {
|
|
|
45209
45209
|
|
|
45210
45210
|
const objLoader = new OBJLoader();
|
|
45211
45211
|
|
|
45212
|
-
const _changeEvent$
|
|
45213
|
-
const _startEvent$
|
|
45214
|
-
const _endEvent$
|
|
45212
|
+
const _changeEvent$3 = { type: "change" };
|
|
45213
|
+
const _startEvent$3 = { type: "start" };
|
|
45214
|
+
const _endEvent$3 = { type: "end" };
|
|
45215
45215
|
class Copper3dTrackballControls extends EventDispatcher {
|
|
45216
45216
|
constructor(object, domElement) {
|
|
45217
45217
|
super();
|
|
@@ -45432,7 +45432,7 @@ class Copper3dTrackballControls extends EventDispatcher {
|
|
|
45432
45432
|
scope.checkDistances();
|
|
45433
45433
|
scope.object.lookAt(scope.target);
|
|
45434
45434
|
if (lastPosition.distanceToSquared(scope.object.position) > EPS) {
|
|
45435
|
-
scope.dispatchEvent(_changeEvent$
|
|
45435
|
+
scope.dispatchEvent(_changeEvent$3);
|
|
45436
45436
|
lastPosition.copy(scope.object.position);
|
|
45437
45437
|
}
|
|
45438
45438
|
}
|
|
@@ -45440,7 +45440,7 @@ class Copper3dTrackballControls extends EventDispatcher {
|
|
|
45440
45440
|
scope.object.lookAt(scope.target);
|
|
45441
45441
|
if (lastPosition.distanceToSquared(scope.object.position) > EPS ||
|
|
45442
45442
|
lastZoom !== scope.object.zoom) {
|
|
45443
|
-
scope.dispatchEvent(_changeEvent$
|
|
45443
|
+
scope.dispatchEvent(_changeEvent$3);
|
|
45444
45444
|
lastPosition.copy(scope.object.position);
|
|
45445
45445
|
lastZoom = scope.object.zoom;
|
|
45446
45446
|
}
|
|
@@ -45459,7 +45459,7 @@ class Copper3dTrackballControls extends EventDispatcher {
|
|
|
45459
45459
|
scope.object.updateProjectionMatrix();
|
|
45460
45460
|
_eye.subVectors(scope.object.position, scope.target);
|
|
45461
45461
|
scope.object.lookAt(scope.target);
|
|
45462
|
-
scope.dispatchEvent(_changeEvent$
|
|
45462
|
+
scope.dispatchEvent(_changeEvent$3);
|
|
45463
45463
|
lastPosition.copy(scope.object.position);
|
|
45464
45464
|
lastZoom = scope.object.zoom;
|
|
45465
45465
|
};
|
|
@@ -45559,7 +45559,7 @@ class Copper3dTrackballControls extends EventDispatcher {
|
|
|
45559
45559
|
_panStart.copy(getMouseOnScreen(event.pageX, event.pageY));
|
|
45560
45560
|
_panEnd.copy(_panStart);
|
|
45561
45561
|
}
|
|
45562
|
-
scope.dispatchEvent(_startEvent$
|
|
45562
|
+
scope.dispatchEvent(_startEvent$3);
|
|
45563
45563
|
}
|
|
45564
45564
|
function onMouseMove(event) {
|
|
45565
45565
|
const state = _keyState !== STATE.NONE ? _keyState : _state;
|
|
@@ -45576,7 +45576,7 @@ class Copper3dTrackballControls extends EventDispatcher {
|
|
|
45576
45576
|
}
|
|
45577
45577
|
function onMouseUp(event) {
|
|
45578
45578
|
_state = STATE.NONE;
|
|
45579
|
-
scope.dispatchEvent(_endEvent$
|
|
45579
|
+
scope.dispatchEvent(_endEvent$3);
|
|
45580
45580
|
}
|
|
45581
45581
|
function onMouseWheel(event) {
|
|
45582
45582
|
if (scope.enabled === false)
|
|
@@ -45598,8 +45598,8 @@ class Copper3dTrackballControls extends EventDispatcher {
|
|
|
45598
45598
|
_zoomStart.y -= event.deltaY * 0.00025;
|
|
45599
45599
|
break;
|
|
45600
45600
|
}
|
|
45601
|
-
scope.dispatchEvent(_startEvent$
|
|
45602
|
-
scope.dispatchEvent(_endEvent$
|
|
45601
|
+
scope.dispatchEvent(_startEvent$3);
|
|
45602
|
+
scope.dispatchEvent(_endEvent$3);
|
|
45603
45603
|
}
|
|
45604
45604
|
function onTouchStart(event) {
|
|
45605
45605
|
trackPointer(event);
|
|
@@ -45620,7 +45620,7 @@ class Copper3dTrackballControls extends EventDispatcher {
|
|
|
45620
45620
|
_panEnd.copy(_panStart);
|
|
45621
45621
|
break;
|
|
45622
45622
|
}
|
|
45623
|
-
scope.dispatchEvent(_startEvent$
|
|
45623
|
+
scope.dispatchEvent(_startEvent$3);
|
|
45624
45624
|
}
|
|
45625
45625
|
function onTouchMove(event) {
|
|
45626
45626
|
trackPointer(event);
|
|
@@ -45662,7 +45662,7 @@ class Copper3dTrackballControls extends EventDispatcher {
|
|
|
45662
45662
|
}
|
|
45663
45663
|
break;
|
|
45664
45664
|
}
|
|
45665
|
-
scope.dispatchEvent(_endEvent$
|
|
45665
|
+
scope.dispatchEvent(_endEvent$3);
|
|
45666
45666
|
}
|
|
45667
45667
|
// function onTouchStart(event: PointerEvent) {
|
|
45668
45668
|
// trackPointer(event);
|
|
@@ -45823,9 +45823,9 @@ class Copper3dTrackballControls extends EventDispatcher {
|
|
|
45823
45823
|
// Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish
|
|
45824
45824
|
// Pan - right mouse, or left mouse + ctrl/meta/shiftKey, or arrow keys / touch: two-finger move
|
|
45825
45825
|
|
|
45826
|
-
const _changeEvent$
|
|
45827
|
-
const _startEvent$
|
|
45828
|
-
const _endEvent$
|
|
45826
|
+
const _changeEvent$2 = { type: 'change' };
|
|
45827
|
+
const _startEvent$2 = { type: 'start' };
|
|
45828
|
+
const _endEvent$2 = { type: 'end' };
|
|
45829
45829
|
|
|
45830
45830
|
class OrbitControls extends EventDispatcher {
|
|
45831
45831
|
|
|
@@ -45954,7 +45954,7 @@ class OrbitControls extends EventDispatcher {
|
|
|
45954
45954
|
scope.object.zoom = scope.zoom0;
|
|
45955
45955
|
|
|
45956
45956
|
scope.object.updateProjectionMatrix();
|
|
45957
|
-
scope.dispatchEvent( _changeEvent$
|
|
45957
|
+
scope.dispatchEvent( _changeEvent$2 );
|
|
45958
45958
|
|
|
45959
45959
|
scope.update();
|
|
45960
45960
|
|
|
@@ -46088,7 +46088,7 @@ class OrbitControls extends EventDispatcher {
|
|
|
46088
46088
|
lastPosition.distanceToSquared( scope.object.position ) > EPS ||
|
|
46089
46089
|
8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) {
|
|
46090
46090
|
|
|
46091
|
-
scope.dispatchEvent( _changeEvent$
|
|
46091
|
+
scope.dispatchEvent( _changeEvent$2 );
|
|
46092
46092
|
|
|
46093
46093
|
lastPosition.copy( scope.object.position );
|
|
46094
46094
|
lastQuaternion.copy( scope.object.quaternion );
|
|
@@ -46702,7 +46702,7 @@ class OrbitControls extends EventDispatcher {
|
|
|
46702
46702
|
|
|
46703
46703
|
}
|
|
46704
46704
|
|
|
46705
|
-
scope.dispatchEvent( _endEvent$
|
|
46705
|
+
scope.dispatchEvent( _endEvent$2 );
|
|
46706
46706
|
|
|
46707
46707
|
state = STATE.NONE;
|
|
46708
46708
|
|
|
@@ -46799,7 +46799,7 @@ class OrbitControls extends EventDispatcher {
|
|
|
46799
46799
|
|
|
46800
46800
|
if ( state !== STATE.NONE ) {
|
|
46801
46801
|
|
|
46802
|
-
scope.dispatchEvent( _startEvent$
|
|
46802
|
+
scope.dispatchEvent( _startEvent$2 );
|
|
46803
46803
|
|
|
46804
46804
|
}
|
|
46805
46805
|
|
|
@@ -46843,11 +46843,11 @@ class OrbitControls extends EventDispatcher {
|
|
|
46843
46843
|
|
|
46844
46844
|
event.preventDefault();
|
|
46845
46845
|
|
|
46846
|
-
scope.dispatchEvent( _startEvent$
|
|
46846
|
+
scope.dispatchEvent( _startEvent$2 );
|
|
46847
46847
|
|
|
46848
46848
|
handleMouseWheel( event );
|
|
46849
46849
|
|
|
46850
|
-
scope.dispatchEvent( _endEvent$
|
|
46850
|
+
scope.dispatchEvent( _endEvent$2 );
|
|
46851
46851
|
|
|
46852
46852
|
}
|
|
46853
46853
|
|
|
@@ -46937,7 +46937,7 @@ class OrbitControls extends EventDispatcher {
|
|
|
46937
46937
|
|
|
46938
46938
|
if ( state !== STATE.NONE ) {
|
|
46939
46939
|
|
|
46940
|
-
scope.dispatchEvent( _startEvent$
|
|
46940
|
+
scope.dispatchEvent( _startEvent$2 );
|
|
46941
46941
|
|
|
46942
46942
|
}
|
|
46943
46943
|
|
|
@@ -48356,6 +48356,508 @@ class baseRenderer {
|
|
|
48356
48356
|
}
|
|
48357
48357
|
}
|
|
48358
48358
|
|
|
48359
|
+
const _changeEvent$1 = { type: "change" };
|
|
48360
|
+
const _startEvent$1 = { type: "start" };
|
|
48361
|
+
const _endEvent$1 = { type: "end" };
|
|
48362
|
+
class Copper3dTrackballControls1 extends EventDispatcher {
|
|
48363
|
+
constructor(object, domElement) {
|
|
48364
|
+
super();
|
|
48365
|
+
const scope = this;
|
|
48366
|
+
const STATE = {
|
|
48367
|
+
NONE: -1,
|
|
48368
|
+
ROTATE: 0,
|
|
48369
|
+
ZOOM: 1,
|
|
48370
|
+
PAN: 2,
|
|
48371
|
+
TOUCH_ROTATE: 3,
|
|
48372
|
+
TOUCH_ZOOM_PAN: 4,
|
|
48373
|
+
};
|
|
48374
|
+
this.object = object;
|
|
48375
|
+
this.domElement = domElement;
|
|
48376
|
+
this.domElement.style.touchAction = "none"; // disable touch scroll
|
|
48377
|
+
// API
|
|
48378
|
+
this.enabled = true;
|
|
48379
|
+
this.screen = { left: 0, top: 0, width: 0, height: 0 };
|
|
48380
|
+
this.rotateSpeed = 1.0;
|
|
48381
|
+
this.zoomSpeed = 1.2;
|
|
48382
|
+
this.panSpeed = 0.3;
|
|
48383
|
+
this.noRotate = false;
|
|
48384
|
+
this.noZoom = false;
|
|
48385
|
+
this.noPan = false;
|
|
48386
|
+
this.staticMoving = false;
|
|
48387
|
+
this.dynamicDampingFactor = 0.2;
|
|
48388
|
+
this.minDistance = 0;
|
|
48389
|
+
this.maxDistance = Infinity;
|
|
48390
|
+
this.minZoom = 0;
|
|
48391
|
+
this.maxZoom = Infinity;
|
|
48392
|
+
this.keys = ["KeyA" /*A*/, "KeyS" /*S*/, "KeyD" /*D*/];
|
|
48393
|
+
this.mouseButtons = {
|
|
48394
|
+
LEFT: MOUSE.ROTATE,
|
|
48395
|
+
MIDDLE: MOUSE.DOLLY,
|
|
48396
|
+
RIGHT: MOUSE.PAN,
|
|
48397
|
+
};
|
|
48398
|
+
// internals
|
|
48399
|
+
this.target = new Vector3();
|
|
48400
|
+
const EPS = 0.000001;
|
|
48401
|
+
const lastPosition = new Vector3();
|
|
48402
|
+
let lastZoom = 1;
|
|
48403
|
+
let _state = STATE.NONE, _keyState = STATE.NONE, _touchZoomDistanceStart = 0, _touchZoomDistanceEnd = 0, _lastAngle = 0;
|
|
48404
|
+
const _eye = new Vector3(), _movePrev = new Vector2(), _moveCurr = new Vector2(), _lastAxis = new Vector3(), _zoomStart = new Vector2(), _zoomEnd = new Vector2(), _panStart = new Vector2(), _panEnd = new Vector2(), _pointers = [], _pointerPositions = {};
|
|
48405
|
+
// for reset
|
|
48406
|
+
this.target0 = this.target.clone();
|
|
48407
|
+
this.position0 = this.object.position.clone();
|
|
48408
|
+
this.up0 = this.object.up.clone();
|
|
48409
|
+
this.zoom0 = this.object.zoom;
|
|
48410
|
+
// methods
|
|
48411
|
+
this.handleResize = function () {
|
|
48412
|
+
const box = scope.domElement.getBoundingClientRect();
|
|
48413
|
+
// adjustments come from similar code in the jquery offset() function
|
|
48414
|
+
const d = scope.domElement.ownerDocument.documentElement;
|
|
48415
|
+
scope.screen.left = box.left + window.pageXOffset - d.clientLeft;
|
|
48416
|
+
scope.screen.top = box.top + window.pageYOffset - d.clientTop;
|
|
48417
|
+
scope.screen.width = box.width;
|
|
48418
|
+
scope.screen.height = box.height;
|
|
48419
|
+
};
|
|
48420
|
+
const getMouseOnScreen = (function () {
|
|
48421
|
+
const vector = new Vector2();
|
|
48422
|
+
return function getMouseOnScreen(pageX, pageY) {
|
|
48423
|
+
vector.set((pageX - scope.screen.left) / scope.screen.width, (pageY - scope.screen.top) / scope.screen.height);
|
|
48424
|
+
return vector;
|
|
48425
|
+
};
|
|
48426
|
+
})();
|
|
48427
|
+
const getMouseOnCircle = (function () {
|
|
48428
|
+
const vector = new Vector2();
|
|
48429
|
+
return function getMouseOnCircle(pageX, pageY) {
|
|
48430
|
+
vector.set((pageX - scope.screen.width * 0.5 - scope.screen.left) /
|
|
48431
|
+
(scope.screen.width * 0.5), (scope.screen.height + 2 * (scope.screen.top - pageY)) /
|
|
48432
|
+
scope.screen.width // screen.width intentional
|
|
48433
|
+
);
|
|
48434
|
+
return vector;
|
|
48435
|
+
};
|
|
48436
|
+
})();
|
|
48437
|
+
this.rotateCamera = (function () {
|
|
48438
|
+
const axis = new Vector3(), quaternion = new Quaternion(), eyeDirection = new Vector3(), objectUpDirection = new Vector3(), objectSidewaysDirection = new Vector3(), moveDirection = new Vector3();
|
|
48439
|
+
return function rotateCamera() {
|
|
48440
|
+
moveDirection.set(_moveCurr.x - _movePrev.x, _moveCurr.y - _movePrev.y, 0);
|
|
48441
|
+
let angle = moveDirection.length();
|
|
48442
|
+
if (angle) {
|
|
48443
|
+
_eye.copy(scope.object.position).sub(scope.target);
|
|
48444
|
+
eyeDirection.copy(_eye).normalize();
|
|
48445
|
+
objectUpDirection.copy(scope.object.up).normalize();
|
|
48446
|
+
objectSidewaysDirection
|
|
48447
|
+
.crossVectors(objectUpDirection, eyeDirection)
|
|
48448
|
+
.normalize();
|
|
48449
|
+
objectUpDirection.setLength(_moveCurr.y - _movePrev.y);
|
|
48450
|
+
objectSidewaysDirection.setLength(_moveCurr.x - _movePrev.x);
|
|
48451
|
+
moveDirection.copy(objectUpDirection.add(objectSidewaysDirection));
|
|
48452
|
+
axis.crossVectors(moveDirection, _eye).normalize();
|
|
48453
|
+
angle *= scope.rotateSpeed;
|
|
48454
|
+
quaternion.setFromAxisAngle(axis, angle);
|
|
48455
|
+
_eye.applyQuaternion(quaternion);
|
|
48456
|
+
scope.object.up.applyQuaternion(quaternion);
|
|
48457
|
+
_lastAxis.copy(axis);
|
|
48458
|
+
_lastAngle = angle;
|
|
48459
|
+
}
|
|
48460
|
+
else if (!scope.staticMoving && _lastAngle) {
|
|
48461
|
+
_lastAngle *= Math.sqrt(1.0 - scope.dynamicDampingFactor);
|
|
48462
|
+
_eye.copy(scope.object.position).sub(scope.target);
|
|
48463
|
+
quaternion.setFromAxisAngle(_lastAxis, _lastAngle);
|
|
48464
|
+
_eye.applyQuaternion(quaternion);
|
|
48465
|
+
scope.object.up.applyQuaternion(quaternion);
|
|
48466
|
+
}
|
|
48467
|
+
_movePrev.copy(_moveCurr);
|
|
48468
|
+
};
|
|
48469
|
+
})();
|
|
48470
|
+
this.zoomCamera = function () {
|
|
48471
|
+
let factor;
|
|
48472
|
+
if (_state === STATE.TOUCH_ZOOM_PAN) {
|
|
48473
|
+
factor = _touchZoomDistanceStart / _touchZoomDistanceEnd;
|
|
48474
|
+
_touchZoomDistanceStart = _touchZoomDistanceEnd;
|
|
48475
|
+
if (scope.object.isPerspectiveCamera) {
|
|
48476
|
+
_eye.multiplyScalar(factor);
|
|
48477
|
+
}
|
|
48478
|
+
else if (scope.object.isOrthographicCamera) {
|
|
48479
|
+
scope.object.zoom = MathUtils.clamp(scope.object.zoom / factor, scope.minZoom, scope.maxZoom);
|
|
48480
|
+
if (lastZoom !== scope.object.zoom) {
|
|
48481
|
+
scope.object.updateProjectionMatrix();
|
|
48482
|
+
}
|
|
48483
|
+
}
|
|
48484
|
+
else {
|
|
48485
|
+
console.warn("THREE.TrackballControls: Unsupported camera type");
|
|
48486
|
+
}
|
|
48487
|
+
}
|
|
48488
|
+
else {
|
|
48489
|
+
factor = 1.0 + (_zoomEnd.y - _zoomStart.y) * scope.zoomSpeed;
|
|
48490
|
+
if (factor !== 1.0 && factor > 0.0) {
|
|
48491
|
+
if (scope.object.isPerspectiveCamera) {
|
|
48492
|
+
_eye.multiplyScalar(factor);
|
|
48493
|
+
}
|
|
48494
|
+
else if (scope.object.isOrthographicCamera) {
|
|
48495
|
+
scope.object.zoom = MathUtils.clamp(scope.object.zoom / factor, scope.minZoom, scope.maxZoom);
|
|
48496
|
+
if (lastZoom !== scope.object.zoom) {
|
|
48497
|
+
scope.object.updateProjectionMatrix();
|
|
48498
|
+
}
|
|
48499
|
+
}
|
|
48500
|
+
else {
|
|
48501
|
+
console.warn("THREE.TrackballControls: Unsupported camera type");
|
|
48502
|
+
}
|
|
48503
|
+
}
|
|
48504
|
+
if (scope.staticMoving) {
|
|
48505
|
+
_zoomStart.copy(_zoomEnd);
|
|
48506
|
+
}
|
|
48507
|
+
else {
|
|
48508
|
+
_zoomStart.y +=
|
|
48509
|
+
(_zoomEnd.y - _zoomStart.y) * this.dynamicDampingFactor;
|
|
48510
|
+
}
|
|
48511
|
+
}
|
|
48512
|
+
};
|
|
48513
|
+
this.panCamera = (function () {
|
|
48514
|
+
const mouseChange = new Vector2(), objectUp = new Vector3(), pan = new Vector3();
|
|
48515
|
+
return function panCamera() {
|
|
48516
|
+
mouseChange.copy(_panEnd).sub(_panStart);
|
|
48517
|
+
if (mouseChange.lengthSq()) {
|
|
48518
|
+
if (scope.object.isOrthographicCamera) {
|
|
48519
|
+
const scale_x = (scope.object.right -
|
|
48520
|
+
scope.object.left) /
|
|
48521
|
+
scope.object.zoom /
|
|
48522
|
+
scope.domElement.clientWidth;
|
|
48523
|
+
const scale_y = (scope.object.top -
|
|
48524
|
+
scope.object.bottom) /
|
|
48525
|
+
scope.object.zoom /
|
|
48526
|
+
scope.domElement.clientWidth;
|
|
48527
|
+
mouseChange.x *= scale_x;
|
|
48528
|
+
mouseChange.y *= scale_y;
|
|
48529
|
+
}
|
|
48530
|
+
mouseChange.multiplyScalar(_eye.length() * scope.panSpeed);
|
|
48531
|
+
pan.copy(_eye).cross(scope.object.up).setLength(mouseChange.x);
|
|
48532
|
+
pan.add(objectUp.copy(scope.object.up).setLength(mouseChange.y));
|
|
48533
|
+
scope.object.position.add(pan);
|
|
48534
|
+
scope.target.add(pan);
|
|
48535
|
+
if (scope.staticMoving) {
|
|
48536
|
+
_panStart.copy(_panEnd);
|
|
48537
|
+
}
|
|
48538
|
+
else {
|
|
48539
|
+
_panStart.add(mouseChange
|
|
48540
|
+
.subVectors(_panEnd, _panStart)
|
|
48541
|
+
.multiplyScalar(scope.dynamicDampingFactor));
|
|
48542
|
+
}
|
|
48543
|
+
}
|
|
48544
|
+
};
|
|
48545
|
+
})();
|
|
48546
|
+
this.checkDistances = function () {
|
|
48547
|
+
if (!scope.noZoom || !scope.noPan) {
|
|
48548
|
+
if (_eye.lengthSq() > scope.maxDistance * scope.maxDistance) {
|
|
48549
|
+
scope.object.position.addVectors(scope.target, _eye.setLength(scope.maxDistance));
|
|
48550
|
+
_zoomStart.copy(_zoomEnd);
|
|
48551
|
+
}
|
|
48552
|
+
if (_eye.lengthSq() < scope.minDistance * scope.minDistance) {
|
|
48553
|
+
scope.object.position.addVectors(scope.target, _eye.setLength(scope.minDistance));
|
|
48554
|
+
_zoomStart.copy(_zoomEnd);
|
|
48555
|
+
}
|
|
48556
|
+
}
|
|
48557
|
+
};
|
|
48558
|
+
this.update = function () {
|
|
48559
|
+
_eye.subVectors(scope.object.position, scope.target);
|
|
48560
|
+
if (!scope.noRotate) {
|
|
48561
|
+
scope.rotateCamera();
|
|
48562
|
+
}
|
|
48563
|
+
if (!scope.noZoom) {
|
|
48564
|
+
scope.zoomCamera();
|
|
48565
|
+
}
|
|
48566
|
+
if (!scope.noPan) {
|
|
48567
|
+
scope.panCamera();
|
|
48568
|
+
}
|
|
48569
|
+
scope.object.position.addVectors(scope.target, _eye);
|
|
48570
|
+
if (scope.object.isPerspectiveCamera) {
|
|
48571
|
+
scope.checkDistances();
|
|
48572
|
+
scope.object.lookAt(scope.target);
|
|
48573
|
+
if (lastPosition.distanceToSquared(scope.object.position) > EPS) {
|
|
48574
|
+
scope.dispatchEvent(_changeEvent$1);
|
|
48575
|
+
lastPosition.copy(scope.object.position);
|
|
48576
|
+
}
|
|
48577
|
+
}
|
|
48578
|
+
else if (scope.object.isOrthographicCamera) {
|
|
48579
|
+
scope.object.lookAt(scope.target);
|
|
48580
|
+
if (lastPosition.distanceToSquared(scope.object.position) > EPS ||
|
|
48581
|
+
lastZoom !== scope.object.zoom) {
|
|
48582
|
+
scope.dispatchEvent(_changeEvent$1);
|
|
48583
|
+
lastPosition.copy(scope.object.position);
|
|
48584
|
+
lastZoom = scope.object.zoom;
|
|
48585
|
+
}
|
|
48586
|
+
}
|
|
48587
|
+
else {
|
|
48588
|
+
console.warn("THREE.TrackballControls: Unsupported camera type");
|
|
48589
|
+
}
|
|
48590
|
+
};
|
|
48591
|
+
this.reset = function () {
|
|
48592
|
+
_state = STATE.NONE;
|
|
48593
|
+
_keyState = STATE.NONE;
|
|
48594
|
+
scope.target.copy(scope.target0);
|
|
48595
|
+
scope.object.position.copy(scope.position0);
|
|
48596
|
+
scope.object.up.copy(scope.up0);
|
|
48597
|
+
scope.object.zoom = scope.zoom0;
|
|
48598
|
+
scope.object.updateProjectionMatrix();
|
|
48599
|
+
_eye.subVectors(scope.object.position, scope.target);
|
|
48600
|
+
scope.object.lookAt(scope.target);
|
|
48601
|
+
scope.dispatchEvent(_changeEvent$1);
|
|
48602
|
+
lastPosition.copy(scope.object.position);
|
|
48603
|
+
lastZoom = scope.object.zoom;
|
|
48604
|
+
};
|
|
48605
|
+
// listeners
|
|
48606
|
+
function onPointerDown(event) {
|
|
48607
|
+
if (scope.enabled === false)
|
|
48608
|
+
return;
|
|
48609
|
+
if (_pointers.length === 0) {
|
|
48610
|
+
scope.domElement.setPointerCapture(event.pointerId);
|
|
48611
|
+
scope.domElement.addEventListener("pointermove", onPointerMove);
|
|
48612
|
+
scope.domElement.addEventListener("pointerup", onPointerUp);
|
|
48613
|
+
}
|
|
48614
|
+
//
|
|
48615
|
+
addPointer(event);
|
|
48616
|
+
if (event.pointerType === "touch") {
|
|
48617
|
+
onTouchStart(event);
|
|
48618
|
+
}
|
|
48619
|
+
else {
|
|
48620
|
+
onMouseDown(event);
|
|
48621
|
+
}
|
|
48622
|
+
}
|
|
48623
|
+
function onPointerMove(event) {
|
|
48624
|
+
if (scope.enabled === false)
|
|
48625
|
+
return;
|
|
48626
|
+
if (event.pointerType === "touch") {
|
|
48627
|
+
onTouchMove(event);
|
|
48628
|
+
}
|
|
48629
|
+
else {
|
|
48630
|
+
onMouseMove(event);
|
|
48631
|
+
}
|
|
48632
|
+
}
|
|
48633
|
+
function onPointerUp(event) {
|
|
48634
|
+
if (scope.enabled === false)
|
|
48635
|
+
return;
|
|
48636
|
+
if (event.pointerType === "touch") {
|
|
48637
|
+
onTouchEnd(event);
|
|
48638
|
+
}
|
|
48639
|
+
else {
|
|
48640
|
+
onMouseUp();
|
|
48641
|
+
}
|
|
48642
|
+
//
|
|
48643
|
+
removePointer(event);
|
|
48644
|
+
if (_pointers.length === 0) {
|
|
48645
|
+
scope.domElement.releasePointerCapture(event.pointerId);
|
|
48646
|
+
scope.domElement.removeEventListener("pointermove", onPointerMove);
|
|
48647
|
+
scope.domElement.removeEventListener("pointerup", onPointerUp);
|
|
48648
|
+
}
|
|
48649
|
+
}
|
|
48650
|
+
function onPointerCancel(event) {
|
|
48651
|
+
removePointer(event);
|
|
48652
|
+
}
|
|
48653
|
+
function keydown(event) {
|
|
48654
|
+
if (scope.enabled === false)
|
|
48655
|
+
return;
|
|
48656
|
+
window.removeEventListener("keydown", keydown);
|
|
48657
|
+
if (_keyState !== STATE.NONE) {
|
|
48658
|
+
return;
|
|
48659
|
+
}
|
|
48660
|
+
else if (event.code === scope.keys[STATE.ROTATE] && !scope.noRotate) {
|
|
48661
|
+
_keyState = STATE.ROTATE;
|
|
48662
|
+
}
|
|
48663
|
+
else if (event.code === scope.keys[STATE.ZOOM] && !scope.noZoom) {
|
|
48664
|
+
_keyState = STATE.ZOOM;
|
|
48665
|
+
}
|
|
48666
|
+
else if (event.code === scope.keys[STATE.PAN] && !scope.noPan) {
|
|
48667
|
+
_keyState = STATE.PAN;
|
|
48668
|
+
}
|
|
48669
|
+
}
|
|
48670
|
+
function keyup() {
|
|
48671
|
+
if (scope.enabled === false)
|
|
48672
|
+
return;
|
|
48673
|
+
_keyState = STATE.NONE;
|
|
48674
|
+
window.addEventListener("keydown", keydown);
|
|
48675
|
+
}
|
|
48676
|
+
function onMouseDown(event) {
|
|
48677
|
+
if (_state === STATE.NONE) {
|
|
48678
|
+
switch (event.button) {
|
|
48679
|
+
case scope.mouseButtons.LEFT:
|
|
48680
|
+
_state = STATE.ROTATE;
|
|
48681
|
+
break;
|
|
48682
|
+
case scope.mouseButtons.MIDDLE:
|
|
48683
|
+
_state = STATE.ZOOM;
|
|
48684
|
+
break;
|
|
48685
|
+
case scope.mouseButtons.RIGHT:
|
|
48686
|
+
_state = STATE.PAN;
|
|
48687
|
+
break;
|
|
48688
|
+
}
|
|
48689
|
+
}
|
|
48690
|
+
const state = _keyState !== STATE.NONE ? _keyState : _state;
|
|
48691
|
+
if (state === STATE.ROTATE && !scope.noRotate) {
|
|
48692
|
+
_moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
|
|
48693
|
+
_movePrev.copy(_moveCurr);
|
|
48694
|
+
}
|
|
48695
|
+
else if (state === STATE.ZOOM && !scope.noZoom) {
|
|
48696
|
+
_zoomStart.copy(getMouseOnScreen(event.pageX, event.pageY));
|
|
48697
|
+
_zoomEnd.copy(_zoomStart);
|
|
48698
|
+
}
|
|
48699
|
+
else if (state === STATE.PAN && !scope.noPan) {
|
|
48700
|
+
_panStart.copy(getMouseOnScreen(event.pageX, event.pageY));
|
|
48701
|
+
_panEnd.copy(_panStart);
|
|
48702
|
+
}
|
|
48703
|
+
scope.dispatchEvent(_startEvent$1);
|
|
48704
|
+
}
|
|
48705
|
+
function onMouseMove(event) {
|
|
48706
|
+
const state = _keyState !== STATE.NONE ? _keyState : _state;
|
|
48707
|
+
if (state === STATE.ROTATE && !scope.noRotate) {
|
|
48708
|
+
_movePrev.copy(_moveCurr);
|
|
48709
|
+
_moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
|
|
48710
|
+
}
|
|
48711
|
+
else if (state === STATE.ZOOM && !scope.noZoom) {
|
|
48712
|
+
_zoomEnd.copy(getMouseOnScreen(event.pageX, event.pageY));
|
|
48713
|
+
}
|
|
48714
|
+
else if (state === STATE.PAN && !scope.noPan) {
|
|
48715
|
+
_panEnd.copy(getMouseOnScreen(event.pageX, event.pageY));
|
|
48716
|
+
}
|
|
48717
|
+
}
|
|
48718
|
+
function onMouseUp() {
|
|
48719
|
+
_state = STATE.NONE;
|
|
48720
|
+
scope.dispatchEvent(_endEvent$1);
|
|
48721
|
+
}
|
|
48722
|
+
function onMouseWheel(event) {
|
|
48723
|
+
if (scope.enabled === false)
|
|
48724
|
+
return;
|
|
48725
|
+
if (scope.noZoom === true)
|
|
48726
|
+
return;
|
|
48727
|
+
event.preventDefault();
|
|
48728
|
+
switch (event.deltaMode) {
|
|
48729
|
+
case 2:
|
|
48730
|
+
// Zoom in pages
|
|
48731
|
+
_zoomStart.y -= event.deltaY * 0.025;
|
|
48732
|
+
break;
|
|
48733
|
+
case 1:
|
|
48734
|
+
// Zoom in lines
|
|
48735
|
+
_zoomStart.y -= event.deltaY * 0.01;
|
|
48736
|
+
break;
|
|
48737
|
+
default:
|
|
48738
|
+
// undefined, 0, assume pixels
|
|
48739
|
+
_zoomStart.y -= event.deltaY * 0.00025;
|
|
48740
|
+
break;
|
|
48741
|
+
}
|
|
48742
|
+
scope.dispatchEvent(_startEvent$1);
|
|
48743
|
+
scope.dispatchEvent(_endEvent$1);
|
|
48744
|
+
}
|
|
48745
|
+
function onTouchStart(event) {
|
|
48746
|
+
trackPointer(event);
|
|
48747
|
+
switch (_pointers.length) {
|
|
48748
|
+
case 1:
|
|
48749
|
+
_state = STATE.TOUCH_ROTATE;
|
|
48750
|
+
_moveCurr.copy(getMouseOnCircle(_pointers[0].pageX, _pointers[0].pageY));
|
|
48751
|
+
_movePrev.copy(_moveCurr);
|
|
48752
|
+
break;
|
|
48753
|
+
default: // 2 or more
|
|
48754
|
+
_state = STATE.TOUCH_ZOOM_PAN;
|
|
48755
|
+
const dx = _pointers[0].pageX - _pointers[1].pageX;
|
|
48756
|
+
const dy = _pointers[0].pageY - _pointers[1].pageY;
|
|
48757
|
+
_touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt(dx * dx + dy * dy);
|
|
48758
|
+
const x = (_pointers[0].pageX + _pointers[1].pageX) / 2;
|
|
48759
|
+
const y = (_pointers[0].pageY + _pointers[1].pageY) / 2;
|
|
48760
|
+
_panStart.copy(getMouseOnScreen(x, y));
|
|
48761
|
+
_panEnd.copy(_panStart);
|
|
48762
|
+
break;
|
|
48763
|
+
}
|
|
48764
|
+
scope.dispatchEvent(_startEvent$1);
|
|
48765
|
+
}
|
|
48766
|
+
function onTouchMove(event) {
|
|
48767
|
+
trackPointer(event);
|
|
48768
|
+
switch (_pointers.length) {
|
|
48769
|
+
case 1:
|
|
48770
|
+
_movePrev.copy(_moveCurr);
|
|
48771
|
+
_moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
|
|
48772
|
+
break;
|
|
48773
|
+
default: // 2 or more
|
|
48774
|
+
const position = getSecondPointerPosition(event);
|
|
48775
|
+
const dx = event.pageX - position.x;
|
|
48776
|
+
const dy = event.pageY - position.y;
|
|
48777
|
+
_touchZoomDistanceEnd = Math.sqrt(dx * dx + dy * dy);
|
|
48778
|
+
const x = (event.pageX + position.x) / 2;
|
|
48779
|
+
const y = (event.pageY + position.y) / 2;
|
|
48780
|
+
_panEnd.copy(getMouseOnScreen(x, y));
|
|
48781
|
+
break;
|
|
48782
|
+
}
|
|
48783
|
+
}
|
|
48784
|
+
function onTouchEnd(event) {
|
|
48785
|
+
switch (_pointers.length) {
|
|
48786
|
+
case 0:
|
|
48787
|
+
_state = STATE.NONE;
|
|
48788
|
+
break;
|
|
48789
|
+
case 1:
|
|
48790
|
+
_state = STATE.TOUCH_ROTATE;
|
|
48791
|
+
_moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
|
|
48792
|
+
_movePrev.copy(_moveCurr);
|
|
48793
|
+
break;
|
|
48794
|
+
case 2:
|
|
48795
|
+
_state = STATE.TOUCH_ZOOM_PAN;
|
|
48796
|
+
for (let i = 0; i < _pointers.length; i++) {
|
|
48797
|
+
if (_pointers[i].pointerId !== event.pointerId) {
|
|
48798
|
+
const position = _pointerPositions[_pointers[i].pointerId];
|
|
48799
|
+
_moveCurr.copy(getMouseOnCircle(position.x, position.y));
|
|
48800
|
+
_movePrev.copy(_moveCurr);
|
|
48801
|
+
break;
|
|
48802
|
+
}
|
|
48803
|
+
}
|
|
48804
|
+
break;
|
|
48805
|
+
}
|
|
48806
|
+
scope.dispatchEvent(_endEvent$1);
|
|
48807
|
+
}
|
|
48808
|
+
function contextmenu(event) {
|
|
48809
|
+
if (scope.enabled === false)
|
|
48810
|
+
return;
|
|
48811
|
+
event.preventDefault();
|
|
48812
|
+
}
|
|
48813
|
+
function addPointer(event) {
|
|
48814
|
+
_pointers.push(event);
|
|
48815
|
+
}
|
|
48816
|
+
function removePointer(event) {
|
|
48817
|
+
delete _pointerPositions[event.pointerId];
|
|
48818
|
+
for (let i = 0; i < _pointers.length; i++) {
|
|
48819
|
+
if (_pointers[i].pointerId == event.pointerId) {
|
|
48820
|
+
_pointers.splice(i, 1);
|
|
48821
|
+
return;
|
|
48822
|
+
}
|
|
48823
|
+
}
|
|
48824
|
+
}
|
|
48825
|
+
function trackPointer(event) {
|
|
48826
|
+
let position = _pointerPositions[event.pointerId];
|
|
48827
|
+
if (position === undefined) {
|
|
48828
|
+
position = new Vector2();
|
|
48829
|
+
_pointerPositions[event.pointerId] = position;
|
|
48830
|
+
}
|
|
48831
|
+
position.set(event.pageX, event.pageY);
|
|
48832
|
+
}
|
|
48833
|
+
function getSecondPointerPosition(event) {
|
|
48834
|
+
const pointer = event.pointerId === _pointers[0].pointerId
|
|
48835
|
+
? _pointers[1]
|
|
48836
|
+
: _pointers[0];
|
|
48837
|
+
return _pointerPositions[pointer.pointerId];
|
|
48838
|
+
}
|
|
48839
|
+
this.dispose = function () {
|
|
48840
|
+
scope.domElement.removeEventListener("contextmenu", contextmenu);
|
|
48841
|
+
scope.domElement.removeEventListener("pointerdown", onPointerDown);
|
|
48842
|
+
scope.domElement.removeEventListener("pointercancel", onPointerCancel);
|
|
48843
|
+
scope.domElement.removeEventListener("wheel", onMouseWheel);
|
|
48844
|
+
scope.domElement.removeEventListener("pointermove", onPointerMove);
|
|
48845
|
+
scope.domElement.removeEventListener("pointerup", onPointerUp);
|
|
48846
|
+
window.removeEventListener("keydown", keydown);
|
|
48847
|
+
window.removeEventListener("keyup", keyup);
|
|
48848
|
+
};
|
|
48849
|
+
this.domElement.addEventListener("contextmenu", contextmenu);
|
|
48850
|
+
this.domElement.addEventListener("pointerdown", onPointerDown);
|
|
48851
|
+
this.domElement.addEventListener("pointercancel", onPointerCancel);
|
|
48852
|
+
this.domElement.addEventListener("wheel", onMouseWheel, { passive: false });
|
|
48853
|
+
window.addEventListener("keydown", keydown);
|
|
48854
|
+
window.addEventListener("keyup", keyup);
|
|
48855
|
+
this.handleResize();
|
|
48856
|
+
// force an update at start
|
|
48857
|
+
this.update();
|
|
48858
|
+
}
|
|
48859
|
+
}
|
|
48860
|
+
|
|
48359
48861
|
/**
|
|
48360
48862
|
* @param {BufferGeometry} geometry
|
|
48361
48863
|
* @param {number} drawMode
|
|
@@ -56334,7 +56836,7 @@ class copperScene extends baseScene {
|
|
|
56334
56836
|
this.controls = new OrbitControls(this.camera, this.renderer.domElement);
|
|
56335
56837
|
}
|
|
56336
56838
|
else {
|
|
56337
|
-
this.controls = new
|
|
56839
|
+
this.controls = new Copper3dTrackballControls1(this.camera, this.renderer.domElement);
|
|
56338
56840
|
}
|
|
56339
56841
|
this.controls.panSpeed = 3;
|
|
56340
56842
|
this.controls.rotateSpeed = 3;
|