three-render-objects 1.26.4 → 1.26.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/three-render-objects.common.js +13 -6
- package/dist/three-render-objects.d.ts +1 -2
- package/dist/three-render-objects.js +312 -199
- package/dist/three-render-objects.js.map +1 -1
- package/dist/three-render-objects.min.js +2 -2
- package/dist/three-render-objects.module.js +9 -2
- package/package.json +13 -13
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// Version 1.26.
|
|
1
|
+
// Version 1.26.5 three-render-objects - https://github.com/vasturiano/three-render-objects
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('three')) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['three'], factory) :
|
|
5
5
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.ThreeRenderObjects = factory(global.THREE));
|
|
6
|
-
}(this, (function (three$1) { 'use strict';
|
|
6
|
+
})(this, (function (three$1) { 'use strict';
|
|
7
7
|
|
|
8
8
|
function styleInject(css, ref) {
|
|
9
9
|
if ( ref === void 0 ) ref = {};
|
|
@@ -143,6 +143,7 @@
|
|
|
143
143
|
|
|
144
144
|
this.object = object;
|
|
145
145
|
this.domElement = domElement;
|
|
146
|
+
this.domElement.style.touchAction = 'none'; // disable touch scroll
|
|
146
147
|
|
|
147
148
|
// API
|
|
148
149
|
|
|
@@ -196,7 +197,10 @@
|
|
|
196
197
|
_zoomEnd = new three$1.Vector2(),
|
|
197
198
|
|
|
198
199
|
_panStart = new three$1.Vector2(),
|
|
199
|
-
_panEnd = new three$1.Vector2()
|
|
200
|
+
_panEnd = new three$1.Vector2(),
|
|
201
|
+
|
|
202
|
+
_pointers = [],
|
|
203
|
+
_pointerPositions = {};
|
|
200
204
|
|
|
201
205
|
// for reset
|
|
202
206
|
|
|
@@ -323,7 +327,7 @@
|
|
|
323
327
|
|
|
324
328
|
} else if ( scope.object.isOrthographicCamera ) {
|
|
325
329
|
|
|
326
|
-
scope.object.zoom
|
|
330
|
+
scope.object.zoom /= factor;
|
|
327
331
|
scope.object.updateProjectionMatrix();
|
|
328
332
|
|
|
329
333
|
} else {
|
|
@@ -525,14 +529,26 @@
|
|
|
525
529
|
|
|
526
530
|
if ( scope.enabled === false ) return;
|
|
527
531
|
|
|
528
|
-
|
|
532
|
+
if ( _pointers.length === 0 ) {
|
|
529
533
|
|
|
530
|
-
|
|
531
|
-
case 'pen':
|
|
532
|
-
onMouseDown( event );
|
|
533
|
-
break;
|
|
534
|
+
scope.domElement.setPointerCapture( event.pointerId );
|
|
534
535
|
|
|
535
|
-
|
|
536
|
+
scope.domElement.addEventListener( 'pointermove', onPointerMove );
|
|
537
|
+
scope.domElement.addEventListener( 'pointerup', onPointerUp );
|
|
538
|
+
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
//
|
|
542
|
+
|
|
543
|
+
addPointer( event );
|
|
544
|
+
|
|
545
|
+
if ( event.pointerType === 'touch' ) {
|
|
546
|
+
|
|
547
|
+
onTouchStart( event );
|
|
548
|
+
|
|
549
|
+
} else {
|
|
550
|
+
|
|
551
|
+
onMouseDown( event );
|
|
536
552
|
|
|
537
553
|
}
|
|
538
554
|
|
|
@@ -542,14 +558,13 @@
|
|
|
542
558
|
|
|
543
559
|
if ( scope.enabled === false ) return;
|
|
544
560
|
|
|
545
|
-
|
|
561
|
+
if ( event.pointerType === 'touch' ) {
|
|
546
562
|
|
|
547
|
-
|
|
548
|
-
case 'pen':
|
|
549
|
-
onMouseMove( event );
|
|
550
|
-
break;
|
|
563
|
+
onTouchMove( event );
|
|
551
564
|
|
|
552
|
-
|
|
565
|
+
} else {
|
|
566
|
+
|
|
567
|
+
onMouseMove( event );
|
|
553
568
|
|
|
554
569
|
}
|
|
555
570
|
|
|
@@ -559,17 +574,36 @@
|
|
|
559
574
|
|
|
560
575
|
if ( scope.enabled === false ) return;
|
|
561
576
|
|
|
562
|
-
|
|
577
|
+
if ( event.pointerType === 'touch' ) {
|
|
563
578
|
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
579
|
+
onTouchEnd( event );
|
|
580
|
+
|
|
581
|
+
} else {
|
|
582
|
+
|
|
583
|
+
onMouseUp();
|
|
584
|
+
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
//
|
|
588
|
+
|
|
589
|
+
removePointer( event );
|
|
568
590
|
|
|
569
|
-
|
|
591
|
+
if ( _pointers.length === 0 ) {
|
|
592
|
+
|
|
593
|
+
scope.domElement.releasePointerCapture( event.pointerId );
|
|
594
|
+
|
|
595
|
+
scope.domElement.removeEventListener( 'pointermove', onPointerMove );
|
|
596
|
+
scope.domElement.removeEventListener( 'pointerup', onPointerUp );
|
|
570
597
|
|
|
571
598
|
}
|
|
572
599
|
|
|
600
|
+
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
function onPointerCancel( event ) {
|
|
604
|
+
|
|
605
|
+
removePointer( event );
|
|
606
|
+
|
|
573
607
|
}
|
|
574
608
|
|
|
575
609
|
function keydown( event ) {
|
|
@@ -610,8 +644,6 @@
|
|
|
610
644
|
|
|
611
645
|
function onMouseDown( event ) {
|
|
612
646
|
|
|
613
|
-
event.preventDefault();
|
|
614
|
-
|
|
615
647
|
if ( _state === STATE.NONE ) {
|
|
616
648
|
|
|
617
649
|
switch ( event.button ) {
|
|
@@ -654,19 +686,12 @@
|
|
|
654
686
|
|
|
655
687
|
}
|
|
656
688
|
|
|
657
|
-
scope.domElement.ownerDocument.addEventListener( 'pointermove', onPointerMove );
|
|
658
|
-
scope.domElement.ownerDocument.addEventListener( 'pointerup', onPointerUp );
|
|
659
|
-
|
|
660
689
|
scope.dispatchEvent( _startEvent$1 );
|
|
661
690
|
|
|
662
691
|
}
|
|
663
692
|
|
|
664
693
|
function onMouseMove( event ) {
|
|
665
694
|
|
|
666
|
-
if ( scope.enabled === false ) return;
|
|
667
|
-
|
|
668
|
-
event.preventDefault();
|
|
669
|
-
|
|
670
695
|
const state = ( _keyState !== STATE.NONE ) ? _keyState : _state;
|
|
671
696
|
|
|
672
697
|
if ( state === STATE.ROTATE && ! scope.noRotate ) {
|
|
@@ -686,22 +711,15 @@
|
|
|
686
711
|
|
|
687
712
|
}
|
|
688
713
|
|
|
689
|
-
function onMouseUp(
|
|
690
|
-
|
|
691
|
-
if ( scope.enabled === false ) return;
|
|
692
|
-
|
|
693
|
-
event.preventDefault();
|
|
714
|
+
function onMouseUp() {
|
|
694
715
|
|
|
695
716
|
_state = STATE.NONE;
|
|
696
717
|
|
|
697
|
-
scope.domElement.ownerDocument.removeEventListener( 'pointermove', onPointerMove );
|
|
698
|
-
scope.domElement.ownerDocument.removeEventListener( 'pointerup', onPointerUp );
|
|
699
|
-
|
|
700
718
|
scope.dispatchEvent( _endEvent$1 );
|
|
701
719
|
|
|
702
720
|
}
|
|
703
721
|
|
|
704
|
-
function
|
|
722
|
+
function onMouseWheel( event ) {
|
|
705
723
|
|
|
706
724
|
if ( scope.enabled === false ) return;
|
|
707
725
|
|
|
@@ -733,28 +751,26 @@
|
|
|
733
751
|
|
|
734
752
|
}
|
|
735
753
|
|
|
736
|
-
function
|
|
737
|
-
|
|
738
|
-
if ( scope.enabled === false ) return;
|
|
754
|
+
function onTouchStart( event ) {
|
|
739
755
|
|
|
740
|
-
event
|
|
756
|
+
trackPointer( event );
|
|
741
757
|
|
|
742
|
-
switch (
|
|
758
|
+
switch ( _pointers.length ) {
|
|
743
759
|
|
|
744
760
|
case 1:
|
|
745
761
|
_state = STATE.TOUCH_ROTATE;
|
|
746
|
-
_moveCurr.copy( getMouseOnCircle(
|
|
762
|
+
_moveCurr.copy( getMouseOnCircle( _pointers[ 0 ].pageX, _pointers[ 0 ].pageY ) );
|
|
747
763
|
_movePrev.copy( _moveCurr );
|
|
748
764
|
break;
|
|
749
765
|
|
|
750
766
|
default: // 2 or more
|
|
751
767
|
_state = STATE.TOUCH_ZOOM_PAN;
|
|
752
|
-
const dx =
|
|
753
|
-
const dy =
|
|
768
|
+
const dx = _pointers[ 0 ].pageX - _pointers[ 1 ].pageX;
|
|
769
|
+
const dy = _pointers[ 0 ].pageY - _pointers[ 1 ].pageY;
|
|
754
770
|
_touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt( dx * dx + dy * dy );
|
|
755
771
|
|
|
756
|
-
const x = (
|
|
757
|
-
const y = (
|
|
772
|
+
const x = ( _pointers[ 0 ].pageX + _pointers[ 1 ].pageX ) / 2;
|
|
773
|
+
const y = ( _pointers[ 0 ].pageY + _pointers[ 1 ].pageY ) / 2;
|
|
758
774
|
_panStart.copy( getMouseOnScreen( x, y ) );
|
|
759
775
|
_panEnd.copy( _panStart );
|
|
760
776
|
break;
|
|
@@ -765,26 +781,27 @@
|
|
|
765
781
|
|
|
766
782
|
}
|
|
767
783
|
|
|
768
|
-
function
|
|
784
|
+
function onTouchMove( event ) {
|
|
769
785
|
|
|
770
|
-
|
|
786
|
+
trackPointer( event );
|
|
771
787
|
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
switch ( event.touches.length ) {
|
|
788
|
+
switch ( _pointers.length ) {
|
|
775
789
|
|
|
776
790
|
case 1:
|
|
777
791
|
_movePrev.copy( _moveCurr );
|
|
778
|
-
_moveCurr.copy( getMouseOnCircle( event.
|
|
792
|
+
_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );
|
|
779
793
|
break;
|
|
780
794
|
|
|
781
795
|
default: // 2 or more
|
|
782
|
-
|
|
783
|
-
const
|
|
796
|
+
|
|
797
|
+
const position = getSecondPointerPosition( event );
|
|
798
|
+
|
|
799
|
+
const dx = event.pageX - position.x;
|
|
800
|
+
const dy = event.pageY - position.y;
|
|
784
801
|
_touchZoomDistanceEnd = Math.sqrt( dx * dx + dy * dy );
|
|
785
802
|
|
|
786
|
-
const x = ( event.
|
|
787
|
-
const y = ( event.
|
|
803
|
+
const x = ( event.pageX + position.x ) / 2;
|
|
804
|
+
const y = ( event.pageY + position.y ) / 2;
|
|
788
805
|
_panEnd.copy( getMouseOnScreen( x, y ) );
|
|
789
806
|
break;
|
|
790
807
|
|
|
@@ -792,11 +809,9 @@
|
|
|
792
809
|
|
|
793
810
|
}
|
|
794
811
|
|
|
795
|
-
function
|
|
796
|
-
|
|
797
|
-
if ( scope.enabled === false ) return;
|
|
812
|
+
function onTouchEnd( event ) {
|
|
798
813
|
|
|
799
|
-
switch (
|
|
814
|
+
switch ( _pointers.length ) {
|
|
800
815
|
|
|
801
816
|
case 0:
|
|
802
817
|
_state = STATE.NONE;
|
|
@@ -804,7 +819,13 @@
|
|
|
804
819
|
|
|
805
820
|
case 1:
|
|
806
821
|
_state = STATE.TOUCH_ROTATE;
|
|
807
|
-
_moveCurr.copy( getMouseOnCircle( event.
|
|
822
|
+
_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );
|
|
823
|
+
_movePrev.copy( _moveCurr );
|
|
824
|
+
break;
|
|
825
|
+
|
|
826
|
+
case 2:
|
|
827
|
+
_state = STATE.TOUCH_ZOOM_PAN;
|
|
828
|
+
_moveCurr.copy( getMouseOnCircle( event.pageX - _movePrev.pageX, event.pageY - _movePrev.pageY ) );
|
|
808
829
|
_movePrev.copy( _moveCurr );
|
|
809
830
|
break;
|
|
810
831
|
|
|
@@ -822,19 +843,62 @@
|
|
|
822
843
|
|
|
823
844
|
}
|
|
824
845
|
|
|
846
|
+
function addPointer( event ) {
|
|
847
|
+
|
|
848
|
+
_pointers.push( event );
|
|
849
|
+
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
function removePointer( event ) {
|
|
853
|
+
|
|
854
|
+
delete _pointerPositions[ event.pointerId ];
|
|
855
|
+
|
|
856
|
+
for ( let i = 0; i < _pointers.length; i ++ ) {
|
|
857
|
+
|
|
858
|
+
if ( _pointers[ i ].pointerId == event.pointerId ) {
|
|
859
|
+
|
|
860
|
+
_pointers.splice( i, 1 );
|
|
861
|
+
return;
|
|
862
|
+
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
function trackPointer( event ) {
|
|
870
|
+
|
|
871
|
+
let position = _pointerPositions[ event.pointerId ];
|
|
872
|
+
|
|
873
|
+
if ( position === undefined ) {
|
|
874
|
+
|
|
875
|
+
position = new three$1.Vector2();
|
|
876
|
+
_pointerPositions[ event.pointerId ] = position;
|
|
877
|
+
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
position.set( event.pageX, event.pageY );
|
|
881
|
+
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
function getSecondPointerPosition( event ) {
|
|
885
|
+
|
|
886
|
+
const pointer = ( event.pointerId === _pointers[ 0 ].pointerId ) ? _pointers[ 1 ] : _pointers[ 0 ];
|
|
887
|
+
|
|
888
|
+
return _pointerPositions[ pointer.pointerId ];
|
|
889
|
+
|
|
890
|
+
}
|
|
891
|
+
|
|
825
892
|
this.dispose = function () {
|
|
826
893
|
|
|
827
894
|
scope.domElement.removeEventListener( 'contextmenu', contextmenu );
|
|
828
895
|
|
|
829
896
|
scope.domElement.removeEventListener( 'pointerdown', onPointerDown );
|
|
830
|
-
scope.domElement.removeEventListener( '
|
|
831
|
-
|
|
832
|
-
scope.domElement.removeEventListener( 'touchstart', touchstart );
|
|
833
|
-
scope.domElement.removeEventListener( 'touchend', touchend );
|
|
834
|
-
scope.domElement.removeEventListener( 'touchmove', touchmove );
|
|
897
|
+
scope.domElement.removeEventListener( 'pointercancel', onPointerCancel );
|
|
898
|
+
scope.domElement.removeEventListener( 'wheel', onMouseWheel );
|
|
835
899
|
|
|
836
|
-
scope.domElement.
|
|
837
|
-
scope.domElement.
|
|
900
|
+
scope.domElement.removeEventListener( 'pointermove', onPointerMove );
|
|
901
|
+
scope.domElement.removeEventListener( 'pointerup', onPointerUp );
|
|
838
902
|
|
|
839
903
|
window.removeEventListener( 'keydown', keydown );
|
|
840
904
|
window.removeEventListener( 'keyup', keyup );
|
|
@@ -844,14 +908,9 @@
|
|
|
844
908
|
this.domElement.addEventListener( 'contextmenu', contextmenu );
|
|
845
909
|
|
|
846
910
|
this.domElement.addEventListener( 'pointerdown', onPointerDown );
|
|
847
|
-
this.domElement.addEventListener( '
|
|
911
|
+
this.domElement.addEventListener( 'pointercancel', onPointerCancel );
|
|
912
|
+
this.domElement.addEventListener( 'wheel', onMouseWheel, { passive: false } );
|
|
848
913
|
|
|
849
|
-
this.domElement.addEventListener( 'touchstart', touchstart, { passive: false } );
|
|
850
|
-
this.domElement.addEventListener( 'touchend', touchend );
|
|
851
|
-
this.domElement.addEventListener( 'touchmove', touchmove, { passive: false } );
|
|
852
|
-
|
|
853
|
-
this.domElement.ownerDocument.addEventListener( 'pointermove', onPointerMove );
|
|
854
|
-
this.domElement.ownerDocument.addEventListener( 'pointerup', onPointerUp );
|
|
855
914
|
|
|
856
915
|
window.addEventListener( 'keydown', keydown );
|
|
857
916
|
window.addEventListener( 'keyup', keyup );
|
|
@@ -887,6 +946,7 @@
|
|
|
887
946
|
|
|
888
947
|
this.object = object;
|
|
889
948
|
this.domElement = domElement;
|
|
949
|
+
this.domElement.style.touchAction = 'none'; // disable touch scroll
|
|
890
950
|
|
|
891
951
|
// Set to false to disable this control
|
|
892
952
|
this.enabled = true;
|
|
@@ -970,6 +1030,12 @@
|
|
|
970
1030
|
|
|
971
1031
|
};
|
|
972
1032
|
|
|
1033
|
+
this.getDistance = function () {
|
|
1034
|
+
|
|
1035
|
+
return this.object.position.distanceTo( this.target );
|
|
1036
|
+
|
|
1037
|
+
};
|
|
1038
|
+
|
|
973
1039
|
this.listenToKeyEvents = function ( domElement ) {
|
|
974
1040
|
|
|
975
1041
|
domElement.addEventListener( 'keydown', onKeyDown );
|
|
@@ -1147,14 +1213,11 @@
|
|
|
1147
1213
|
scope.domElement.removeEventListener( 'contextmenu', onContextMenu );
|
|
1148
1214
|
|
|
1149
1215
|
scope.domElement.removeEventListener( 'pointerdown', onPointerDown );
|
|
1216
|
+
scope.domElement.removeEventListener( 'pointercancel', onPointerCancel );
|
|
1150
1217
|
scope.domElement.removeEventListener( 'wheel', onMouseWheel );
|
|
1151
1218
|
|
|
1152
|
-
scope.domElement.removeEventListener( '
|
|
1153
|
-
scope.domElement.removeEventListener( '
|
|
1154
|
-
scope.domElement.removeEventListener( 'touchmove', onTouchMove );
|
|
1155
|
-
|
|
1156
|
-
scope.domElement.ownerDocument.removeEventListener( 'pointermove', onPointerMove );
|
|
1157
|
-
scope.domElement.ownerDocument.removeEventListener( 'pointerup', onPointerUp );
|
|
1219
|
+
scope.domElement.removeEventListener( 'pointermove', onPointerMove );
|
|
1220
|
+
scope.domElement.removeEventListener( 'pointerup', onPointerUp );
|
|
1158
1221
|
|
|
1159
1222
|
|
|
1160
1223
|
if ( scope._domElementKeyEvents !== null ) {
|
|
@@ -1208,6 +1271,9 @@
|
|
|
1208
1271
|
const dollyEnd = new three$1.Vector2();
|
|
1209
1272
|
const dollyDelta = new three$1.Vector2();
|
|
1210
1273
|
|
|
1274
|
+
const pointers = [];
|
|
1275
|
+
const pointerPositions = {};
|
|
1276
|
+
|
|
1211
1277
|
function getAutoRotationAngle() {
|
|
1212
1278
|
|
|
1213
1279
|
return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
|
|
@@ -1487,16 +1553,16 @@
|
|
|
1487
1553
|
|
|
1488
1554
|
}
|
|
1489
1555
|
|
|
1490
|
-
function handleTouchStartRotate(
|
|
1556
|
+
function handleTouchStartRotate() {
|
|
1491
1557
|
|
|
1492
|
-
if (
|
|
1558
|
+
if ( pointers.length === 1 ) {
|
|
1493
1559
|
|
|
1494
|
-
rotateStart.set(
|
|
1560
|
+
rotateStart.set( pointers[ 0 ].pageX, pointers[ 0 ].pageY );
|
|
1495
1561
|
|
|
1496
1562
|
} else {
|
|
1497
1563
|
|
|
1498
|
-
const x = 0.5 * (
|
|
1499
|
-
const y = 0.5 * (
|
|
1564
|
+
const x = 0.5 * ( pointers[ 0 ].pageX + pointers[ 1 ].pageX );
|
|
1565
|
+
const y = 0.5 * ( pointers[ 0 ].pageY + pointers[ 1 ].pageY );
|
|
1500
1566
|
|
|
1501
1567
|
rotateStart.set( x, y );
|
|
1502
1568
|
|
|
@@ -1504,16 +1570,16 @@
|
|
|
1504
1570
|
|
|
1505
1571
|
}
|
|
1506
1572
|
|
|
1507
|
-
function handleTouchStartPan(
|
|
1573
|
+
function handleTouchStartPan() {
|
|
1508
1574
|
|
|
1509
|
-
if (
|
|
1575
|
+
if ( pointers.length === 1 ) {
|
|
1510
1576
|
|
|
1511
|
-
panStart.set(
|
|
1577
|
+
panStart.set( pointers[ 0 ].pageX, pointers[ 0 ].pageY );
|
|
1512
1578
|
|
|
1513
1579
|
} else {
|
|
1514
1580
|
|
|
1515
|
-
const x = 0.5 * (
|
|
1516
|
-
const y = 0.5 * (
|
|
1581
|
+
const x = 0.5 * ( pointers[ 0 ].pageX + pointers[ 1 ].pageX );
|
|
1582
|
+
const y = 0.5 * ( pointers[ 0 ].pageY + pointers[ 1 ].pageY );
|
|
1517
1583
|
|
|
1518
1584
|
panStart.set( x, y );
|
|
1519
1585
|
|
|
@@ -1521,10 +1587,10 @@
|
|
|
1521
1587
|
|
|
1522
1588
|
}
|
|
1523
1589
|
|
|
1524
|
-
function handleTouchStartDolly(
|
|
1590
|
+
function handleTouchStartDolly() {
|
|
1525
1591
|
|
|
1526
|
-
const dx =
|
|
1527
|
-
const dy =
|
|
1592
|
+
const dx = pointers[ 0 ].pageX - pointers[ 1 ].pageX;
|
|
1593
|
+
const dy = pointers[ 0 ].pageY - pointers[ 1 ].pageY;
|
|
1528
1594
|
|
|
1529
1595
|
const distance = Math.sqrt( dx * dx + dy * dy );
|
|
1530
1596
|
|
|
@@ -1532,32 +1598,34 @@
|
|
|
1532
1598
|
|
|
1533
1599
|
}
|
|
1534
1600
|
|
|
1535
|
-
function handleTouchStartDollyPan(
|
|
1601
|
+
function handleTouchStartDollyPan() {
|
|
1536
1602
|
|
|
1537
|
-
if ( scope.enableZoom ) handleTouchStartDolly(
|
|
1603
|
+
if ( scope.enableZoom ) handleTouchStartDolly();
|
|
1538
1604
|
|
|
1539
|
-
if ( scope.enablePan ) handleTouchStartPan(
|
|
1605
|
+
if ( scope.enablePan ) handleTouchStartPan();
|
|
1540
1606
|
|
|
1541
1607
|
}
|
|
1542
1608
|
|
|
1543
|
-
function handleTouchStartDollyRotate(
|
|
1609
|
+
function handleTouchStartDollyRotate() {
|
|
1544
1610
|
|
|
1545
|
-
if ( scope.enableZoom ) handleTouchStartDolly(
|
|
1611
|
+
if ( scope.enableZoom ) handleTouchStartDolly();
|
|
1546
1612
|
|
|
1547
|
-
if ( scope.enableRotate ) handleTouchStartRotate(
|
|
1613
|
+
if ( scope.enableRotate ) handleTouchStartRotate();
|
|
1548
1614
|
|
|
1549
1615
|
}
|
|
1550
1616
|
|
|
1551
1617
|
function handleTouchMoveRotate( event ) {
|
|
1552
1618
|
|
|
1553
|
-
if (
|
|
1619
|
+
if ( pointers.length == 1 ) {
|
|
1554
1620
|
|
|
1555
|
-
rotateEnd.set( event.
|
|
1621
|
+
rotateEnd.set( event.pageX, event.pageY );
|
|
1556
1622
|
|
|
1557
1623
|
} else {
|
|
1558
1624
|
|
|
1559
|
-
const
|
|
1560
|
-
|
|
1625
|
+
const position = getSecondPointerPosition( event );
|
|
1626
|
+
|
|
1627
|
+
const x = 0.5 * ( event.pageX + position.x );
|
|
1628
|
+
const y = 0.5 * ( event.pageY + position.y );
|
|
1561
1629
|
|
|
1562
1630
|
rotateEnd.set( x, y );
|
|
1563
1631
|
|
|
@@ -1577,14 +1645,16 @@
|
|
|
1577
1645
|
|
|
1578
1646
|
function handleTouchMovePan( event ) {
|
|
1579
1647
|
|
|
1580
|
-
if (
|
|
1648
|
+
if ( pointers.length === 1 ) {
|
|
1581
1649
|
|
|
1582
|
-
panEnd.set( event.
|
|
1650
|
+
panEnd.set( event.pageX, event.pageY );
|
|
1583
1651
|
|
|
1584
1652
|
} else {
|
|
1585
1653
|
|
|
1586
|
-
const
|
|
1587
|
-
|
|
1654
|
+
const position = getSecondPointerPosition( event );
|
|
1655
|
+
|
|
1656
|
+
const x = 0.5 * ( event.pageX + position.x );
|
|
1657
|
+
const y = 0.5 * ( event.pageY + position.y );
|
|
1588
1658
|
|
|
1589
1659
|
panEnd.set( x, y );
|
|
1590
1660
|
|
|
@@ -1600,8 +1670,10 @@
|
|
|
1600
1670
|
|
|
1601
1671
|
function handleTouchMoveDolly( event ) {
|
|
1602
1672
|
|
|
1603
|
-
const
|
|
1604
|
-
|
|
1673
|
+
const position = getSecondPointerPosition( event );
|
|
1674
|
+
|
|
1675
|
+
const dx = event.pageX - position.x;
|
|
1676
|
+
const dy = event.pageY - position.y;
|
|
1605
1677
|
|
|
1606
1678
|
const distance = Math.sqrt( dx * dx + dy * dy );
|
|
1607
1679
|
|
|
@@ -1639,14 +1711,26 @@
|
|
|
1639
1711
|
|
|
1640
1712
|
if ( scope.enabled === false ) return;
|
|
1641
1713
|
|
|
1642
|
-
|
|
1714
|
+
if ( pointers.length === 0 ) {
|
|
1643
1715
|
|
|
1644
|
-
|
|
1645
|
-
case 'pen':
|
|
1646
|
-
onMouseDown( event );
|
|
1647
|
-
break;
|
|
1716
|
+
scope.domElement.setPointerCapture( event.pointerId );
|
|
1648
1717
|
|
|
1649
|
-
|
|
1718
|
+
scope.domElement.addEventListener( 'pointermove', onPointerMove );
|
|
1719
|
+
scope.domElement.addEventListener( 'pointerup', onPointerUp );
|
|
1720
|
+
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
//
|
|
1724
|
+
|
|
1725
|
+
addPointer( event );
|
|
1726
|
+
|
|
1727
|
+
if ( event.pointerType === 'touch' ) {
|
|
1728
|
+
|
|
1729
|
+
onTouchStart( event );
|
|
1730
|
+
|
|
1731
|
+
} else {
|
|
1732
|
+
|
|
1733
|
+
onMouseDown( event );
|
|
1650
1734
|
|
|
1651
1735
|
}
|
|
1652
1736
|
|
|
@@ -1656,14 +1740,13 @@
|
|
|
1656
1740
|
|
|
1657
1741
|
if ( scope.enabled === false ) return;
|
|
1658
1742
|
|
|
1659
|
-
|
|
1743
|
+
if ( event.pointerType === 'touch' ) {
|
|
1660
1744
|
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
break;
|
|
1745
|
+
onTouchMove( event );
|
|
1746
|
+
|
|
1747
|
+
} else {
|
|
1665
1748
|
|
|
1666
|
-
|
|
1749
|
+
onMouseMove( event );
|
|
1667
1750
|
|
|
1668
1751
|
}
|
|
1669
1752
|
|
|
@@ -1671,28 +1754,30 @@
|
|
|
1671
1754
|
|
|
1672
1755
|
function onPointerUp( event ) {
|
|
1673
1756
|
|
|
1674
|
-
|
|
1757
|
+
removePointer( event );
|
|
1675
1758
|
|
|
1676
|
-
|
|
1677
|
-
case 'pen':
|
|
1678
|
-
onMouseUp();
|
|
1679
|
-
break;
|
|
1759
|
+
if ( pointers.length === 0 ) {
|
|
1680
1760
|
|
|
1681
|
-
|
|
1761
|
+
scope.domElement.releasePointerCapture( event.pointerId );
|
|
1682
1762
|
|
|
1683
|
-
|
|
1763
|
+
scope.domElement.removeEventListener( 'pointermove', onPointerMove );
|
|
1764
|
+
scope.domElement.removeEventListener( 'pointerup', onPointerUp );
|
|
1765
|
+
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
scope.dispatchEvent( _endEvent );
|
|
1769
|
+
|
|
1770
|
+
state = STATE.NONE;
|
|
1684
1771
|
|
|
1685
1772
|
}
|
|
1686
1773
|
|
|
1687
|
-
function
|
|
1774
|
+
function onPointerCancel( event ) {
|
|
1688
1775
|
|
|
1689
|
-
|
|
1690
|
-
event.preventDefault();
|
|
1776
|
+
removePointer( event );
|
|
1691
1777
|
|
|
1692
|
-
|
|
1693
|
-
// prevents the browser from setting it automatically.
|
|
1778
|
+
}
|
|
1694
1779
|
|
|
1695
|
-
|
|
1780
|
+
function onMouseDown( event ) {
|
|
1696
1781
|
|
|
1697
1782
|
let mouseAction;
|
|
1698
1783
|
|
|
@@ -1783,9 +1868,6 @@
|
|
|
1783
1868
|
|
|
1784
1869
|
if ( state !== STATE.NONE ) {
|
|
1785
1870
|
|
|
1786
|
-
scope.domElement.ownerDocument.addEventListener( 'pointermove', onPointerMove );
|
|
1787
|
-
scope.domElement.ownerDocument.addEventListener( 'pointerup', onPointerUp );
|
|
1788
|
-
|
|
1789
1871
|
scope.dispatchEvent( _startEvent );
|
|
1790
1872
|
|
|
1791
1873
|
}
|
|
@@ -1796,8 +1878,6 @@
|
|
|
1796
1878
|
|
|
1797
1879
|
if ( scope.enabled === false ) return;
|
|
1798
1880
|
|
|
1799
|
-
event.preventDefault();
|
|
1800
|
-
|
|
1801
1881
|
switch ( state ) {
|
|
1802
1882
|
|
|
1803
1883
|
case STATE.ROTATE:
|
|
@@ -1828,22 +1908,9 @@
|
|
|
1828
1908
|
|
|
1829
1909
|
}
|
|
1830
1910
|
|
|
1831
|
-
function onMouseUp( event ) {
|
|
1832
|
-
|
|
1833
|
-
scope.domElement.ownerDocument.removeEventListener( 'pointermove', onPointerMove );
|
|
1834
|
-
scope.domElement.ownerDocument.removeEventListener( 'pointerup', onPointerUp );
|
|
1835
|
-
|
|
1836
|
-
if ( scope.enabled === false ) return;
|
|
1837
|
-
|
|
1838
|
-
scope.dispatchEvent( _endEvent );
|
|
1839
|
-
|
|
1840
|
-
state = STATE.NONE;
|
|
1841
|
-
|
|
1842
|
-
}
|
|
1843
|
-
|
|
1844
1911
|
function onMouseWheel( event ) {
|
|
1845
1912
|
|
|
1846
|
-
if ( scope.enabled === false || scope.enableZoom === false ||
|
|
1913
|
+
if ( scope.enabled === false || scope.enableZoom === false || state !== STATE.NONE ) return;
|
|
1847
1914
|
|
|
1848
1915
|
event.preventDefault();
|
|
1849
1916
|
|
|
@@ -1865,11 +1932,9 @@
|
|
|
1865
1932
|
|
|
1866
1933
|
function onTouchStart( event ) {
|
|
1867
1934
|
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
event.preventDefault(); // prevent scrolling
|
|
1935
|
+
trackPointer( event );
|
|
1871
1936
|
|
|
1872
|
-
switch (
|
|
1937
|
+
switch ( pointers.length ) {
|
|
1873
1938
|
|
|
1874
1939
|
case 1:
|
|
1875
1940
|
|
|
@@ -1879,7 +1944,7 @@
|
|
|
1879
1944
|
|
|
1880
1945
|
if ( scope.enableRotate === false ) return;
|
|
1881
1946
|
|
|
1882
|
-
handleTouchStartRotate(
|
|
1947
|
+
handleTouchStartRotate();
|
|
1883
1948
|
|
|
1884
1949
|
state = STATE.TOUCH_ROTATE;
|
|
1885
1950
|
|
|
@@ -1889,7 +1954,7 @@
|
|
|
1889
1954
|
|
|
1890
1955
|
if ( scope.enablePan === false ) return;
|
|
1891
1956
|
|
|
1892
|
-
handleTouchStartPan(
|
|
1957
|
+
handleTouchStartPan();
|
|
1893
1958
|
|
|
1894
1959
|
state = STATE.TOUCH_PAN;
|
|
1895
1960
|
|
|
@@ -1911,7 +1976,7 @@
|
|
|
1911
1976
|
|
|
1912
1977
|
if ( scope.enableZoom === false && scope.enablePan === false ) return;
|
|
1913
1978
|
|
|
1914
|
-
handleTouchStartDollyPan(
|
|
1979
|
+
handleTouchStartDollyPan();
|
|
1915
1980
|
|
|
1916
1981
|
state = STATE.TOUCH_DOLLY_PAN;
|
|
1917
1982
|
|
|
@@ -1921,7 +1986,7 @@
|
|
|
1921
1986
|
|
|
1922
1987
|
if ( scope.enableZoom === false && scope.enableRotate === false ) return;
|
|
1923
1988
|
|
|
1924
|
-
handleTouchStartDollyRotate(
|
|
1989
|
+
handleTouchStartDollyRotate();
|
|
1925
1990
|
|
|
1926
1991
|
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
1927
1992
|
|
|
@@ -1951,9 +2016,7 @@
|
|
|
1951
2016
|
|
|
1952
2017
|
function onTouchMove( event ) {
|
|
1953
2018
|
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
event.preventDefault(); // prevent scrolling
|
|
2019
|
+
trackPointer( event );
|
|
1957
2020
|
|
|
1958
2021
|
switch ( state ) {
|
|
1959
2022
|
|
|
@@ -2005,21 +2068,57 @@
|
|
|
2005
2068
|
|
|
2006
2069
|
}
|
|
2007
2070
|
|
|
2008
|
-
function
|
|
2071
|
+
function onContextMenu( event ) {
|
|
2009
2072
|
|
|
2010
2073
|
if ( scope.enabled === false ) return;
|
|
2011
2074
|
|
|
2012
|
-
|
|
2075
|
+
event.preventDefault();
|
|
2013
2076
|
|
|
2014
|
-
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
function addPointer( event ) {
|
|
2080
|
+
|
|
2081
|
+
pointers.push( event );
|
|
2015
2082
|
|
|
2016
2083
|
}
|
|
2017
2084
|
|
|
2018
|
-
function
|
|
2085
|
+
function removePointer( event ) {
|
|
2019
2086
|
|
|
2020
|
-
|
|
2087
|
+
delete pointerPositions[ event.pointerId ];
|
|
2021
2088
|
|
|
2022
|
-
|
|
2089
|
+
for ( let i = 0; i < pointers.length; i ++ ) {
|
|
2090
|
+
|
|
2091
|
+
if ( pointers[ i ].pointerId == event.pointerId ) {
|
|
2092
|
+
|
|
2093
|
+
pointers.splice( i, 1 );
|
|
2094
|
+
return;
|
|
2095
|
+
|
|
2096
|
+
}
|
|
2097
|
+
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
function trackPointer( event ) {
|
|
2103
|
+
|
|
2104
|
+
let position = pointerPositions[ event.pointerId ];
|
|
2105
|
+
|
|
2106
|
+
if ( position === undefined ) {
|
|
2107
|
+
|
|
2108
|
+
position = new three$1.Vector2();
|
|
2109
|
+
pointerPositions[ event.pointerId ] = position;
|
|
2110
|
+
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
position.set( event.pageX, event.pageY );
|
|
2114
|
+
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
function getSecondPointerPosition( event ) {
|
|
2118
|
+
|
|
2119
|
+
const pointer = ( event.pointerId === pointers[ 0 ].pointerId ) ? pointers[ 1 ] : pointers[ 0 ];
|
|
2120
|
+
|
|
2121
|
+
return pointerPositions[ pointer.pointerId ];
|
|
2023
2122
|
|
|
2024
2123
|
}
|
|
2025
2124
|
|
|
@@ -2028,12 +2127,9 @@
|
|
|
2028
2127
|
scope.domElement.addEventListener( 'contextmenu', onContextMenu );
|
|
2029
2128
|
|
|
2030
2129
|
scope.domElement.addEventListener( 'pointerdown', onPointerDown );
|
|
2130
|
+
scope.domElement.addEventListener( 'pointercancel', onPointerCancel );
|
|
2031
2131
|
scope.domElement.addEventListener( 'wheel', onMouseWheel, { passive: false } );
|
|
2032
2132
|
|
|
2033
|
-
scope.domElement.addEventListener( 'touchstart', onTouchStart, { passive: false } );
|
|
2034
|
-
scope.domElement.addEventListener( 'touchend', onTouchEnd );
|
|
2035
|
-
scope.domElement.addEventListener( 'touchmove', onTouchMove, { passive: false } );
|
|
2036
|
-
|
|
2037
2133
|
// force an update at start
|
|
2038
2134
|
|
|
2039
2135
|
this.update();
|
|
@@ -2095,8 +2191,6 @@
|
|
|
2095
2191
|
|
|
2096
2192
|
}
|
|
2097
2193
|
|
|
2098
|
-
//event.preventDefault();
|
|
2099
|
-
|
|
2100
2194
|
switch ( event.code ) {
|
|
2101
2195
|
|
|
2102
2196
|
case 'ShiftLeft':
|
|
@@ -2161,14 +2255,6 @@
|
|
|
2161
2255
|
|
|
2162
2256
|
this.mousedown = function ( event ) {
|
|
2163
2257
|
|
|
2164
|
-
if ( this.domElement !== document ) {
|
|
2165
|
-
|
|
2166
|
-
this.domElement.focus();
|
|
2167
|
-
|
|
2168
|
-
}
|
|
2169
|
-
|
|
2170
|
-
event.preventDefault();
|
|
2171
|
-
|
|
2172
2258
|
if ( this.dragToLook ) {
|
|
2173
2259
|
|
|
2174
2260
|
this.mouseStatus ++;
|
|
@@ -2207,8 +2293,6 @@
|
|
|
2207
2293
|
|
|
2208
2294
|
this.mouseup = function ( event ) {
|
|
2209
2295
|
|
|
2210
|
-
event.preventDefault();
|
|
2211
|
-
|
|
2212
2296
|
if ( this.dragToLook ) {
|
|
2213
2297
|
|
|
2214
2298
|
this.mouseStatus --;
|
|
@@ -3537,6 +3621,8 @@
|
|
|
3537
3621
|
return value;
|
|
3538
3622
|
};
|
|
3539
3623
|
|
|
3624
|
+
var reduceHexValue$1 = reduceHexValue;
|
|
3625
|
+
|
|
3540
3626
|
function numberToHex(value) {
|
|
3541
3627
|
var hex = value.toString(16);
|
|
3542
3628
|
return hex.length === 1 ? "0" + hex : hex;
|
|
@@ -3567,9 +3653,9 @@
|
|
|
3567
3653
|
*/
|
|
3568
3654
|
function rgb(value, green, blue) {
|
|
3569
3655
|
if (typeof value === 'number' && typeof green === 'number' && typeof blue === 'number') {
|
|
3570
|
-
return reduceHexValue("#" + numberToHex(value) + numberToHex(green) + numberToHex(blue));
|
|
3656
|
+
return reduceHexValue$1("#" + numberToHex(value) + numberToHex(green) + numberToHex(blue));
|
|
3571
3657
|
} else if (typeof value === 'object' && green === undefined && blue === undefined) {
|
|
3572
|
-
return reduceHexValue("#" + numberToHex(value.red) + numberToHex(value.green) + numberToHex(value.blue));
|
|
3658
|
+
return reduceHexValue$1("#" + numberToHex(value.red) + numberToHex(value.green) + numberToHex(value.blue));
|
|
3573
3659
|
}
|
|
3574
3660
|
|
|
3575
3661
|
throw new PolishedError(6);
|
|
@@ -3688,6 +3774,7 @@
|
|
|
3688
3774
|
var curriedOpacify = /*#__PURE__*/curry
|
|
3689
3775
|
/* ::<number | string, string, string> */
|
|
3690
3776
|
(opacify);
|
|
3777
|
+
var curriedOpacify$1 = curriedOpacify;
|
|
3691
3778
|
|
|
3692
3779
|
/**
|
|
3693
3780
|
* The Ease class provides a collection of easing functions for use with tween.js.
|
|
@@ -4576,6 +4663,25 @@
|
|
|
4576
4663
|
}
|
|
4577
4664
|
}
|
|
4578
4665
|
|
|
4666
|
+
function _defineProperties(target, props) {
|
|
4667
|
+
for (var i = 0; i < props.length; i++) {
|
|
4668
|
+
var descriptor = props[i];
|
|
4669
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
4670
|
+
descriptor.configurable = true;
|
|
4671
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
4672
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
4673
|
+
}
|
|
4674
|
+
}
|
|
4675
|
+
|
|
4676
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
4677
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
4678
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
4679
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
4680
|
+
writable: false
|
|
4681
|
+
});
|
|
4682
|
+
return Constructor;
|
|
4683
|
+
}
|
|
4684
|
+
|
|
4579
4685
|
function _slicedToArray(arr, i) {
|
|
4580
4686
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
4581
4687
|
}
|
|
@@ -4585,7 +4691,7 @@
|
|
|
4585
4691
|
}
|
|
4586
4692
|
|
|
4587
4693
|
function _iterableToArrayLimit(arr, i) {
|
|
4588
|
-
var _i = arr
|
|
4694
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
4589
4695
|
|
|
4590
4696
|
if (_i == null) return;
|
|
4591
4697
|
var _arr = [];
|
|
@@ -4635,7 +4741,7 @@
|
|
|
4635
4741
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4636
4742
|
}
|
|
4637
4743
|
|
|
4638
|
-
var Prop = function Prop(name, _ref) {
|
|
4744
|
+
var Prop = /*#__PURE__*/_createClass(function Prop(name, _ref) {
|
|
4639
4745
|
var _ref$default = _ref["default"],
|
|
4640
4746
|
defaultVal = _ref$default === void 0 ? null : _ref$default,
|
|
4641
4747
|
_ref$triggerUpdate = _ref.triggerUpdate,
|
|
@@ -4649,7 +4755,7 @@
|
|
|
4649
4755
|
this.defaultVal = defaultVal;
|
|
4650
4756
|
this.triggerUpdate = triggerUpdate;
|
|
4651
4757
|
this.onChange = onChange;
|
|
4652
|
-
};
|
|
4758
|
+
});
|
|
4653
4759
|
|
|
4654
4760
|
function index (_ref2) {
|
|
4655
4761
|
var _ref2$stateInit = _ref2.stateInit,
|
|
@@ -4958,7 +5064,14 @@
|
|
|
4958
5064
|
}
|
|
4959
5065
|
|
|
4960
5066
|
function setLookAt(lookAt) {
|
|
4961
|
-
|
|
5067
|
+
var lookAtVect = new three.Vector3(lookAt.x, lookAt.y, lookAt.z);
|
|
5068
|
+
|
|
5069
|
+
if (state.controls.target) {
|
|
5070
|
+
state.controls.target = lookAtVect;
|
|
5071
|
+
} else {
|
|
5072
|
+
// Fly controls doesn't have target attribute
|
|
5073
|
+
camera.lookAt(lookAtVect); // note: lookAt may be overridden by other controls in some cases
|
|
5074
|
+
}
|
|
4962
5075
|
}
|
|
4963
5076
|
|
|
4964
5077
|
function getLookAt() {
|
|
@@ -5258,7 +5371,7 @@
|
|
|
5258
5371
|
if (changedProps.hasOwnProperty('backgroundColor')) {
|
|
5259
5372
|
var alpha = parseToRgb(state.backgroundColor).alpha;
|
|
5260
5373
|
if (alpha === undefined) alpha = 1;
|
|
5261
|
-
state.renderer.setClearColor(new three.Color(curriedOpacify(1, state.backgroundColor)), alpha);
|
|
5374
|
+
state.renderer.setClearColor(new three.Color(curriedOpacify$1(1, state.backgroundColor)), alpha);
|
|
5262
5375
|
}
|
|
5263
5376
|
|
|
5264
5377
|
if (changedProps.hasOwnProperty('backgroundImageUrl')) {
|
|
@@ -5301,5 +5414,5 @@
|
|
|
5301
5414
|
|
|
5302
5415
|
return threeRenderObjects;
|
|
5303
5416
|
|
|
5304
|
-
}))
|
|
5417
|
+
}));
|
|
5305
5418
|
//# sourceMappingURL=three-render-objects.js.map
|