igs-view 1.0.6 → 1.0.8

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/main.js CHANGED
@@ -1355,6 +1355,1560 @@ class MapControls extends OrbitControls {
1355
1355
 
1356
1356
 
1357
1357
 
1358
+ /***/ }),
1359
+
1360
+ /***/ "./node_modules/.pnpm/three@0.139.2/node_modules/three/examples/jsm/controls/TransformControls.js":
1361
+ /*!********************************************************************************************************!*\
1362
+ !*** ./node_modules/.pnpm/three@0.139.2/node_modules/three/examples/jsm/controls/TransformControls.js ***!
1363
+ \********************************************************************************************************/
1364
+ /*! exports provided: TransformControls, TransformControlsGizmo, TransformControlsPlane */
1365
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1366
+
1367
+ "use strict";
1368
+ __webpack_require__.r(__webpack_exports__);
1369
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformControls", function() { return TransformControls; });
1370
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformControlsGizmo", function() { return TransformControlsGizmo; });
1371
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformControlsPlane", function() { return TransformControlsPlane; });
1372
+ /* harmony import */ var three__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! three */ "three");
1373
+ /* harmony import */ var three__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(three__WEBPACK_IMPORTED_MODULE_0__);
1374
+
1375
+
1376
+ const _raycaster = new three__WEBPACK_IMPORTED_MODULE_0__["Raycaster"]();
1377
+
1378
+ const _tempVector = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
1379
+ const _tempVector2 = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
1380
+ const _tempQuaternion = new three__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
1381
+ const _unit = {
1382
+ X: new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]( 1, 0, 0 ),
1383
+ Y: new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]( 0, 1, 0 ),
1384
+ Z: new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]( 0, 0, 1 )
1385
+ };
1386
+
1387
+ const _changeEvent = { type: 'change' };
1388
+ const _mouseDownEvent = { type: 'mouseDown' };
1389
+ const _mouseUpEvent = { type: 'mouseUp', mode: null };
1390
+ const _objectChangeEvent = { type: 'objectChange' };
1391
+
1392
+ class TransformControls extends three__WEBPACK_IMPORTED_MODULE_0__["Object3D"] {
1393
+
1394
+ constructor( camera, domElement ) {
1395
+
1396
+ super();
1397
+
1398
+ if ( domElement === undefined ) {
1399
+
1400
+ console.warn( 'THREE.TransformControls: The second parameter "domElement" is now mandatory.' );
1401
+ domElement = document;
1402
+
1403
+ }
1404
+
1405
+ this.visible = false;
1406
+ this.domElement = domElement;
1407
+ this.domElement.style.touchAction = 'none'; // disable touch scroll
1408
+
1409
+ const _gizmo = new TransformControlsGizmo();
1410
+ this._gizmo = _gizmo;
1411
+ this.add( _gizmo );
1412
+
1413
+ const _plane = new TransformControlsPlane();
1414
+ this._plane = _plane;
1415
+ this.add( _plane );
1416
+
1417
+ const scope = this;
1418
+
1419
+ // Defined getter, setter and store for a property
1420
+ function defineProperty( propName, defaultValue ) {
1421
+
1422
+ let propValue = defaultValue;
1423
+
1424
+ Object.defineProperty( scope, propName, {
1425
+
1426
+ get: function () {
1427
+
1428
+ return propValue !== undefined ? propValue : defaultValue;
1429
+
1430
+ },
1431
+
1432
+ set: function ( value ) {
1433
+
1434
+ if ( propValue !== value ) {
1435
+
1436
+ propValue = value;
1437
+ _plane[ propName ] = value;
1438
+ _gizmo[ propName ] = value;
1439
+
1440
+ scope.dispatchEvent( { type: propName + '-changed', value: value } );
1441
+ scope.dispatchEvent( _changeEvent );
1442
+
1443
+ }
1444
+
1445
+ }
1446
+
1447
+ } );
1448
+
1449
+ scope[ propName ] = defaultValue;
1450
+ _plane[ propName ] = defaultValue;
1451
+ _gizmo[ propName ] = defaultValue;
1452
+
1453
+ }
1454
+
1455
+ // Define properties with getters/setter
1456
+ // Setting the defined property will automatically trigger change event
1457
+ // Defined properties are passed down to gizmo and plane
1458
+
1459
+ defineProperty( 'camera', camera );
1460
+ defineProperty( 'object', undefined );
1461
+ defineProperty( 'enabled', true );
1462
+ defineProperty( 'axis', null );
1463
+ defineProperty( 'mode', 'translate' );
1464
+ defineProperty( 'translationSnap', null );
1465
+ defineProperty( 'rotationSnap', null );
1466
+ defineProperty( 'scaleSnap', null );
1467
+ defineProperty( 'space', 'world' );
1468
+ defineProperty( 'size', 1 );
1469
+ defineProperty( 'dragging', false );
1470
+ defineProperty( 'showX', true );
1471
+ defineProperty( 'showY', true );
1472
+ defineProperty( 'showZ', true );
1473
+
1474
+ // Reusable utility variables
1475
+
1476
+ const worldPosition = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
1477
+ const worldPositionStart = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
1478
+ const worldQuaternion = new three__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
1479
+ const worldQuaternionStart = new three__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
1480
+ const cameraPosition = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
1481
+ const cameraQuaternion = new three__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
1482
+ const pointStart = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
1483
+ const pointEnd = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
1484
+ const rotationAxis = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
1485
+ const rotationAngle = 0;
1486
+ const eye = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
1487
+
1488
+ // TODO: remove properties unused in plane and gizmo
1489
+
1490
+ defineProperty( 'worldPosition', worldPosition );
1491
+ defineProperty( 'worldPositionStart', worldPositionStart );
1492
+ defineProperty( 'worldQuaternion', worldQuaternion );
1493
+ defineProperty( 'worldQuaternionStart', worldQuaternionStart );
1494
+ defineProperty( 'cameraPosition', cameraPosition );
1495
+ defineProperty( 'cameraQuaternion', cameraQuaternion );
1496
+ defineProperty( 'pointStart', pointStart );
1497
+ defineProperty( 'pointEnd', pointEnd );
1498
+ defineProperty( 'rotationAxis', rotationAxis );
1499
+ defineProperty( 'rotationAngle', rotationAngle );
1500
+ defineProperty( 'eye', eye );
1501
+
1502
+ this._offset = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
1503
+ this._startNorm = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
1504
+ this._endNorm = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
1505
+ this._cameraScale = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
1506
+
1507
+ this._parentPosition = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
1508
+ this._parentQuaternion = new three__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
1509
+ this._parentQuaternionInv = new three__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
1510
+ this._parentScale = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
1511
+
1512
+ this._worldScaleStart = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
1513
+ this._worldQuaternionInv = new three__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
1514
+ this._worldScale = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
1515
+
1516
+ this._positionStart = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
1517
+ this._quaternionStart = new three__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
1518
+ this._scaleStart = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
1519
+
1520
+ this._getPointer = getPointer.bind( this );
1521
+ this._onPointerDown = onPointerDown.bind( this );
1522
+ this._onPointerHover = onPointerHover.bind( this );
1523
+ this._onPointerMove = onPointerMove.bind( this );
1524
+ this._onPointerUp = onPointerUp.bind( this );
1525
+
1526
+ this.domElement.addEventListener( 'pointerdown', this._onPointerDown );
1527
+ this.domElement.addEventListener( 'pointermove', this._onPointerHover );
1528
+ this.domElement.addEventListener( 'pointerup', this._onPointerUp );
1529
+
1530
+ }
1531
+
1532
+ // updateMatrixWorld updates key transformation variables
1533
+ updateMatrixWorld() {
1534
+
1535
+ if ( this.object !== undefined ) {
1536
+
1537
+ this.object.updateMatrixWorld();
1538
+
1539
+ if ( this.object.parent === null ) {
1540
+
1541
+ console.error( 'TransformControls: The attached 3D object must be a part of the scene graph.' );
1542
+
1543
+ } else {
1544
+
1545
+ this.object.parent.matrixWorld.decompose( this._parentPosition, this._parentQuaternion, this._parentScale );
1546
+
1547
+ }
1548
+
1549
+ this.object.matrixWorld.decompose( this.worldPosition, this.worldQuaternion, this._worldScale );
1550
+
1551
+ this._parentQuaternionInv.copy( this._parentQuaternion ).invert();
1552
+ this._worldQuaternionInv.copy( this.worldQuaternion ).invert();
1553
+
1554
+ }
1555
+
1556
+ this.camera.updateMatrixWorld();
1557
+ this.camera.matrixWorld.decompose( this.cameraPosition, this.cameraQuaternion, this._cameraScale );
1558
+
1559
+ this.eye.copy( this.cameraPosition ).sub( this.worldPosition ).normalize();
1560
+
1561
+ super.updateMatrixWorld( this );
1562
+
1563
+ }
1564
+
1565
+ pointerHover( pointer ) {
1566
+
1567
+ if ( this.object === undefined || this.dragging === true ) return;
1568
+
1569
+ _raycaster.setFromCamera( pointer, this.camera );
1570
+
1571
+ const intersect = intersectObjectWithRay( this._gizmo.picker[ this.mode ], _raycaster );
1572
+
1573
+ if ( intersect ) {
1574
+
1575
+ this.axis = intersect.object.name;
1576
+
1577
+ } else {
1578
+
1579
+ this.axis = null;
1580
+
1581
+ }
1582
+
1583
+ }
1584
+
1585
+ pointerDown( pointer ) {
1586
+
1587
+ if ( this.object === undefined || this.dragging === true || pointer.button !== 0 ) return;
1588
+
1589
+ if ( this.axis !== null ) {
1590
+
1591
+ _raycaster.setFromCamera( pointer, this.camera );
1592
+
1593
+ const planeIntersect = intersectObjectWithRay( this._plane, _raycaster, true );
1594
+
1595
+ if ( planeIntersect ) {
1596
+
1597
+ this.object.updateMatrixWorld();
1598
+ this.object.parent.updateMatrixWorld();
1599
+
1600
+ this._positionStart.copy( this.object.position );
1601
+ this._quaternionStart.copy( this.object.quaternion );
1602
+ this._scaleStart.copy( this.object.scale );
1603
+
1604
+ this.object.matrixWorld.decompose( this.worldPositionStart, this.worldQuaternionStart, this._worldScaleStart );
1605
+
1606
+ this.pointStart.copy( planeIntersect.point ).sub( this.worldPositionStart );
1607
+
1608
+ }
1609
+
1610
+ this.dragging = true;
1611
+ _mouseDownEvent.mode = this.mode;
1612
+ this.dispatchEvent( _mouseDownEvent );
1613
+
1614
+ }
1615
+
1616
+ }
1617
+
1618
+ pointerMove( pointer ) {
1619
+
1620
+ const axis = this.axis;
1621
+ const mode = this.mode;
1622
+ const object = this.object;
1623
+ let space = this.space;
1624
+
1625
+ if ( mode === 'scale' ) {
1626
+
1627
+ space = 'local';
1628
+
1629
+ } else if ( axis === 'E' || axis === 'XYZE' || axis === 'XYZ' ) {
1630
+
1631
+ space = 'world';
1632
+
1633
+ }
1634
+
1635
+ if ( object === undefined || axis === null || this.dragging === false || pointer.button !== - 1 ) return;
1636
+
1637
+ _raycaster.setFromCamera( pointer, this.camera );
1638
+
1639
+ const planeIntersect = intersectObjectWithRay( this._plane, _raycaster, true );
1640
+
1641
+ if ( ! planeIntersect ) return;
1642
+
1643
+ this.pointEnd.copy( planeIntersect.point ).sub( this.worldPositionStart );
1644
+
1645
+ if ( mode === 'translate' ) {
1646
+
1647
+ // Apply translate
1648
+
1649
+ this._offset.copy( this.pointEnd ).sub( this.pointStart );
1650
+
1651
+ if ( space === 'local' && axis !== 'XYZ' ) {
1652
+
1653
+ this._offset.applyQuaternion( this._worldQuaternionInv );
1654
+
1655
+ }
1656
+
1657
+ if ( axis.indexOf( 'X' ) === - 1 ) this._offset.x = 0;
1658
+ if ( axis.indexOf( 'Y' ) === - 1 ) this._offset.y = 0;
1659
+ if ( axis.indexOf( 'Z' ) === - 1 ) this._offset.z = 0;
1660
+
1661
+ if ( space === 'local' && axis !== 'XYZ' ) {
1662
+
1663
+ this._offset.applyQuaternion( this._quaternionStart ).divide( this._parentScale );
1664
+
1665
+ } else {
1666
+
1667
+ this._offset.applyQuaternion( this._parentQuaternionInv ).divide( this._parentScale );
1668
+
1669
+ }
1670
+
1671
+ object.position.copy( this._offset ).add( this._positionStart );
1672
+
1673
+ // Apply translation snap
1674
+
1675
+ if ( this.translationSnap ) {
1676
+
1677
+ if ( space === 'local' ) {
1678
+
1679
+ object.position.applyQuaternion( _tempQuaternion.copy( this._quaternionStart ).invert() );
1680
+
1681
+ if ( axis.search( 'X' ) !== - 1 ) {
1682
+
1683
+ object.position.x = Math.round( object.position.x / this.translationSnap ) * this.translationSnap;
1684
+
1685
+ }
1686
+
1687
+ if ( axis.search( 'Y' ) !== - 1 ) {
1688
+
1689
+ object.position.y = Math.round( object.position.y / this.translationSnap ) * this.translationSnap;
1690
+
1691
+ }
1692
+
1693
+ if ( axis.search( 'Z' ) !== - 1 ) {
1694
+
1695
+ object.position.z = Math.round( object.position.z / this.translationSnap ) * this.translationSnap;
1696
+
1697
+ }
1698
+
1699
+ object.position.applyQuaternion( this._quaternionStart );
1700
+
1701
+ }
1702
+
1703
+ if ( space === 'world' ) {
1704
+
1705
+ if ( object.parent ) {
1706
+
1707
+ object.position.add( _tempVector.setFromMatrixPosition( object.parent.matrixWorld ) );
1708
+
1709
+ }
1710
+
1711
+ if ( axis.search( 'X' ) !== - 1 ) {
1712
+
1713
+ object.position.x = Math.round( object.position.x / this.translationSnap ) * this.translationSnap;
1714
+
1715
+ }
1716
+
1717
+ if ( axis.search( 'Y' ) !== - 1 ) {
1718
+
1719
+ object.position.y = Math.round( object.position.y / this.translationSnap ) * this.translationSnap;
1720
+
1721
+ }
1722
+
1723
+ if ( axis.search( 'Z' ) !== - 1 ) {
1724
+
1725
+ object.position.z = Math.round( object.position.z / this.translationSnap ) * this.translationSnap;
1726
+
1727
+ }
1728
+
1729
+ if ( object.parent ) {
1730
+
1731
+ object.position.sub( _tempVector.setFromMatrixPosition( object.parent.matrixWorld ) );
1732
+
1733
+ }
1734
+
1735
+ }
1736
+
1737
+ }
1738
+
1739
+ } else if ( mode === 'scale' ) {
1740
+
1741
+ if ( axis.search( 'XYZ' ) !== - 1 ) {
1742
+
1743
+ let d = this.pointEnd.length() / this.pointStart.length();
1744
+
1745
+ if ( this.pointEnd.dot( this.pointStart ) < 0 ) d *= - 1;
1746
+
1747
+ _tempVector2.set( d, d, d );
1748
+
1749
+ } else {
1750
+
1751
+ _tempVector.copy( this.pointStart );
1752
+ _tempVector2.copy( this.pointEnd );
1753
+
1754
+ _tempVector.applyQuaternion( this._worldQuaternionInv );
1755
+ _tempVector2.applyQuaternion( this._worldQuaternionInv );
1756
+
1757
+ _tempVector2.divide( _tempVector );
1758
+
1759
+ if ( axis.search( 'X' ) === - 1 ) {
1760
+
1761
+ _tempVector2.x = 1;
1762
+
1763
+ }
1764
+
1765
+ if ( axis.search( 'Y' ) === - 1 ) {
1766
+
1767
+ _tempVector2.y = 1;
1768
+
1769
+ }
1770
+
1771
+ if ( axis.search( 'Z' ) === - 1 ) {
1772
+
1773
+ _tempVector2.z = 1;
1774
+
1775
+ }
1776
+
1777
+ }
1778
+
1779
+ // Apply scale
1780
+
1781
+ object.scale.copy( this._scaleStart ).multiply( _tempVector2 );
1782
+
1783
+ if ( this.scaleSnap ) {
1784
+
1785
+ if ( axis.search( 'X' ) !== - 1 ) {
1786
+
1787
+ object.scale.x = Math.round( object.scale.x / this.scaleSnap ) * this.scaleSnap || this.scaleSnap;
1788
+
1789
+ }
1790
+
1791
+ if ( axis.search( 'Y' ) !== - 1 ) {
1792
+
1793
+ object.scale.y = Math.round( object.scale.y / this.scaleSnap ) * this.scaleSnap || this.scaleSnap;
1794
+
1795
+ }
1796
+
1797
+ if ( axis.search( 'Z' ) !== - 1 ) {
1798
+
1799
+ object.scale.z = Math.round( object.scale.z / this.scaleSnap ) * this.scaleSnap || this.scaleSnap;
1800
+
1801
+ }
1802
+
1803
+ }
1804
+
1805
+ } else if ( mode === 'rotate' ) {
1806
+
1807
+ this._offset.copy( this.pointEnd ).sub( this.pointStart );
1808
+
1809
+ const ROTATION_SPEED = 20 / this.worldPosition.distanceTo( _tempVector.setFromMatrixPosition( this.camera.matrixWorld ) );
1810
+
1811
+ if ( axis === 'E' ) {
1812
+
1813
+ this.rotationAxis.copy( this.eye );
1814
+ this.rotationAngle = this.pointEnd.angleTo( this.pointStart );
1815
+
1816
+ this._startNorm.copy( this.pointStart ).normalize();
1817
+ this._endNorm.copy( this.pointEnd ).normalize();
1818
+
1819
+ this.rotationAngle *= ( this._endNorm.cross( this._startNorm ).dot( this.eye ) < 0 ? 1 : - 1 );
1820
+
1821
+ } else if ( axis === 'XYZE' ) {
1822
+
1823
+ this.rotationAxis.copy( this._offset ).cross( this.eye ).normalize();
1824
+ this.rotationAngle = this._offset.dot( _tempVector.copy( this.rotationAxis ).cross( this.eye ) ) * ROTATION_SPEED;
1825
+
1826
+ } else if ( axis === 'X' || axis === 'Y' || axis === 'Z' ) {
1827
+
1828
+ this.rotationAxis.copy( _unit[ axis ] );
1829
+
1830
+ _tempVector.copy( _unit[ axis ] );
1831
+
1832
+ if ( space === 'local' ) {
1833
+
1834
+ _tempVector.applyQuaternion( this.worldQuaternion );
1835
+
1836
+ }
1837
+
1838
+ this.rotationAngle = this._offset.dot( _tempVector.cross( this.eye ).normalize() ) * ROTATION_SPEED;
1839
+
1840
+ }
1841
+
1842
+ // Apply rotation snap
1843
+
1844
+ if ( this.rotationSnap ) this.rotationAngle = Math.round( this.rotationAngle / this.rotationSnap ) * this.rotationSnap;
1845
+
1846
+ // Apply rotate
1847
+ if ( space === 'local' && axis !== 'E' && axis !== 'XYZE' ) {
1848
+
1849
+ object.quaternion.copy( this._quaternionStart );
1850
+ object.quaternion.multiply( _tempQuaternion.setFromAxisAngle( this.rotationAxis, this.rotationAngle ) ).normalize();
1851
+
1852
+ } else {
1853
+
1854
+ this.rotationAxis.applyQuaternion( this._parentQuaternionInv );
1855
+ object.quaternion.copy( _tempQuaternion.setFromAxisAngle( this.rotationAxis, this.rotationAngle ) );
1856
+ object.quaternion.multiply( this._quaternionStart ).normalize();
1857
+
1858
+ }
1859
+
1860
+ }
1861
+
1862
+ this.dispatchEvent( _changeEvent );
1863
+ this.dispatchEvent( _objectChangeEvent );
1864
+
1865
+ }
1866
+
1867
+ pointerUp( pointer ) {
1868
+
1869
+ if ( pointer.button !== 0 ) return;
1870
+
1871
+ if ( this.dragging && ( this.axis !== null ) ) {
1872
+
1873
+ _mouseUpEvent.mode = this.mode;
1874
+ this.dispatchEvent( _mouseUpEvent );
1875
+
1876
+ }
1877
+
1878
+ this.dragging = false;
1879
+ this.axis = null;
1880
+
1881
+ }
1882
+
1883
+ dispose() {
1884
+
1885
+ this.domElement.removeEventListener( 'pointerdown', this._onPointerDown );
1886
+ this.domElement.removeEventListener( 'pointermove', this._onPointerHover );
1887
+ this.domElement.removeEventListener( 'pointermove', this._onPointerMove );
1888
+ this.domElement.removeEventListener( 'pointerup', this._onPointerUp );
1889
+
1890
+ this.traverse( function ( child ) {
1891
+
1892
+ if ( child.geometry ) child.geometry.dispose();
1893
+ if ( child.material ) child.material.dispose();
1894
+
1895
+ } );
1896
+
1897
+ }
1898
+
1899
+ // Set current object
1900
+ attach( object ) {
1901
+
1902
+ this.object = object;
1903
+ this.visible = true;
1904
+
1905
+ return this;
1906
+
1907
+ }
1908
+
1909
+ // Detatch from object
1910
+ detach() {
1911
+
1912
+ this.object = undefined;
1913
+ this.visible = false;
1914
+ this.axis = null;
1915
+
1916
+ return this;
1917
+
1918
+ }
1919
+
1920
+ reset() {
1921
+
1922
+ if ( ! this.enabled ) return;
1923
+
1924
+ if ( this.dragging ) {
1925
+
1926
+ this.object.position.copy( this._positionStart );
1927
+ this.object.quaternion.copy( this._quaternionStart );
1928
+ this.object.scale.copy( this._scaleStart );
1929
+
1930
+ this.dispatchEvent( _changeEvent );
1931
+ this.dispatchEvent( _objectChangeEvent );
1932
+
1933
+ this.pointStart.copy( this.pointEnd );
1934
+
1935
+ }
1936
+
1937
+ }
1938
+
1939
+ getRaycaster() {
1940
+
1941
+ return _raycaster;
1942
+
1943
+ }
1944
+
1945
+ // TODO: deprecate
1946
+
1947
+ getMode() {
1948
+
1949
+ return this.mode;
1950
+
1951
+ }
1952
+
1953
+ setMode( mode ) {
1954
+
1955
+ this.mode = mode;
1956
+
1957
+ }
1958
+
1959
+ setTranslationSnap( translationSnap ) {
1960
+
1961
+ this.translationSnap = translationSnap;
1962
+
1963
+ }
1964
+
1965
+ setRotationSnap( rotationSnap ) {
1966
+
1967
+ this.rotationSnap = rotationSnap;
1968
+
1969
+ }
1970
+
1971
+ setScaleSnap( scaleSnap ) {
1972
+
1973
+ this.scaleSnap = scaleSnap;
1974
+
1975
+ }
1976
+
1977
+ setSize( size ) {
1978
+
1979
+ this.size = size;
1980
+
1981
+ }
1982
+
1983
+ setSpace( space ) {
1984
+
1985
+ this.space = space;
1986
+
1987
+ }
1988
+
1989
+ update() {
1990
+
1991
+ console.warn( 'THREE.TransformControls: update function has no more functionality and therefore has been deprecated.' );
1992
+
1993
+ }
1994
+
1995
+ }
1996
+
1997
+ TransformControls.prototype.isTransformControls = true;
1998
+
1999
+ // mouse / touch event handlers
2000
+
2001
+ function getPointer( event ) {
2002
+
2003
+ if ( this.domElement.ownerDocument.pointerLockElement ) {
2004
+
2005
+ return {
2006
+ x: 0,
2007
+ y: 0,
2008
+ button: event.button
2009
+ };
2010
+
2011
+ } else {
2012
+
2013
+ const rect = this.domElement.getBoundingClientRect();
2014
+
2015
+ return {
2016
+ x: ( event.clientX - rect.left ) / rect.width * 2 - 1,
2017
+ y: - ( event.clientY - rect.top ) / rect.height * 2 + 1,
2018
+ button: event.button
2019
+ };
2020
+
2021
+ }
2022
+
2023
+ }
2024
+
2025
+ function onPointerHover( event ) {
2026
+
2027
+ if ( ! this.enabled ) return;
2028
+
2029
+ switch ( event.pointerType ) {
2030
+
2031
+ case 'mouse':
2032
+ case 'pen':
2033
+ this.pointerHover( this._getPointer( event ) );
2034
+ break;
2035
+
2036
+ }
2037
+
2038
+ }
2039
+
2040
+ function onPointerDown( event ) {
2041
+
2042
+ if ( ! this.enabled ) return;
2043
+
2044
+ if ( ! document.pointerLockElement ) {
2045
+
2046
+ this.domElement.setPointerCapture( event.pointerId );
2047
+
2048
+ }
2049
+
2050
+ this.domElement.addEventListener( 'pointermove', this._onPointerMove );
2051
+
2052
+ this.pointerHover( this._getPointer( event ) );
2053
+ this.pointerDown( this._getPointer( event ) );
2054
+
2055
+ }
2056
+
2057
+ function onPointerMove( event ) {
2058
+
2059
+ if ( ! this.enabled ) return;
2060
+
2061
+ this.pointerMove( this._getPointer( event ) );
2062
+
2063
+ }
2064
+
2065
+ function onPointerUp( event ) {
2066
+
2067
+ if ( ! this.enabled ) return;
2068
+
2069
+ this.domElement.releasePointerCapture( event.pointerId );
2070
+
2071
+ this.domElement.removeEventListener( 'pointermove', this._onPointerMove );
2072
+
2073
+ this.pointerUp( this._getPointer( event ) );
2074
+
2075
+ }
2076
+
2077
+ function intersectObjectWithRay( object, raycaster, includeInvisible ) {
2078
+
2079
+ const allIntersections = raycaster.intersectObject( object, true );
2080
+
2081
+ for ( let i = 0; i < allIntersections.length; i ++ ) {
2082
+
2083
+ if ( allIntersections[ i ].object.visible || includeInvisible ) {
2084
+
2085
+ return allIntersections[ i ];
2086
+
2087
+ }
2088
+
2089
+ }
2090
+
2091
+ return false;
2092
+
2093
+ }
2094
+
2095
+ //
2096
+
2097
+ // Reusable utility variables
2098
+
2099
+ const _tempEuler = new three__WEBPACK_IMPORTED_MODULE_0__["Euler"]();
2100
+ const _alignVector = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]( 0, 1, 0 );
2101
+ const _zeroVector = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]( 0, 0, 0 );
2102
+ const _lookAtMatrix = new three__WEBPACK_IMPORTED_MODULE_0__["Matrix4"]();
2103
+ const _tempQuaternion2 = new three__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
2104
+ const _identityQuaternion = new three__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
2105
+ const _dirVector = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
2106
+ const _tempMatrix = new three__WEBPACK_IMPORTED_MODULE_0__["Matrix4"]();
2107
+
2108
+ const _unitX = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]( 1, 0, 0 );
2109
+ const _unitY = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]( 0, 1, 0 );
2110
+ const _unitZ = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]( 0, 0, 1 );
2111
+
2112
+ const _v1 = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
2113
+ const _v2 = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
2114
+ const _v3 = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
2115
+
2116
+ class TransformControlsGizmo extends three__WEBPACK_IMPORTED_MODULE_0__["Object3D"] {
2117
+
2118
+ constructor() {
2119
+
2120
+ super();
2121
+
2122
+ this.type = 'TransformControlsGizmo';
2123
+
2124
+ // shared materials
2125
+
2126
+ const gizmoMaterial = new three__WEBPACK_IMPORTED_MODULE_0__["MeshBasicMaterial"]( {
2127
+ depthTest: false,
2128
+ depthWrite: false,
2129
+ fog: false,
2130
+ toneMapped: false,
2131
+ transparent: true
2132
+ } );
2133
+
2134
+ const gizmoLineMaterial = new three__WEBPACK_IMPORTED_MODULE_0__["LineBasicMaterial"]( {
2135
+ depthTest: false,
2136
+ depthWrite: false,
2137
+ fog: false,
2138
+ toneMapped: false,
2139
+ transparent: true
2140
+ } );
2141
+
2142
+ // Make unique material for each axis/color
2143
+
2144
+ const matInvisible = gizmoMaterial.clone();
2145
+ matInvisible.opacity = 0.15;
2146
+
2147
+ const matHelper = gizmoLineMaterial.clone();
2148
+ matHelper.opacity = 0.5;
2149
+
2150
+ const matRed = gizmoMaterial.clone();
2151
+ matRed.color.setHex( 0xff0000 );
2152
+
2153
+ const matGreen = gizmoMaterial.clone();
2154
+ matGreen.color.setHex( 0x00ff00 );
2155
+
2156
+ const matBlue = gizmoMaterial.clone();
2157
+ matBlue.color.setHex( 0x0000ff );
2158
+
2159
+ const matRedTransparent = gizmoMaterial.clone();
2160
+ matRedTransparent.color.setHex( 0xff0000 );
2161
+ matRedTransparent.opacity = 0.5;
2162
+
2163
+ const matGreenTransparent = gizmoMaterial.clone();
2164
+ matGreenTransparent.color.setHex( 0x00ff00 );
2165
+ matGreenTransparent.opacity = 0.5;
2166
+
2167
+ const matBlueTransparent = gizmoMaterial.clone();
2168
+ matBlueTransparent.color.setHex( 0x0000ff );
2169
+ matBlueTransparent.opacity = 0.5;
2170
+
2171
+ const matWhiteTransparent = gizmoMaterial.clone();
2172
+ matWhiteTransparent.opacity = 0.25;
2173
+
2174
+ const matYellowTransparent = gizmoMaterial.clone();
2175
+ matYellowTransparent.color.setHex( 0xffff00 );
2176
+ matYellowTransparent.opacity = 0.25;
2177
+
2178
+ const matYellow = gizmoMaterial.clone();
2179
+ matYellow.color.setHex( 0xffff00 );
2180
+
2181
+ const matGray = gizmoMaterial.clone();
2182
+ matGray.color.setHex( 0x787878 );
2183
+
2184
+ // reusable geometry
2185
+
2186
+ const arrowGeometry = new three__WEBPACK_IMPORTED_MODULE_0__["CylinderGeometry"]( 0, 0.04, 0.1, 12 );
2187
+ arrowGeometry.translate( 0, 0.05, 0 );
2188
+
2189
+ const scaleHandleGeometry = new three__WEBPACK_IMPORTED_MODULE_0__["BoxGeometry"]( 0.08, 0.08, 0.08 );
2190
+ scaleHandleGeometry.translate( 0, 0.04, 0 );
2191
+
2192
+ const lineGeometry = new three__WEBPACK_IMPORTED_MODULE_0__["BufferGeometry"]();
2193
+ lineGeometry.setAttribute( 'position', new three__WEBPACK_IMPORTED_MODULE_0__["Float32BufferAttribute"]( [ 0, 0, 0, 1, 0, 0 ], 3 ) );
2194
+
2195
+ const lineGeometry2 = new three__WEBPACK_IMPORTED_MODULE_0__["CylinderGeometry"]( 0.0075, 0.0075, 0.5, 3 );
2196
+ lineGeometry2.translate( 0, 0.25, 0 );
2197
+
2198
+ function CircleGeometry( radius, arc ) {
2199
+
2200
+ const geometry = new three__WEBPACK_IMPORTED_MODULE_0__["TorusGeometry"]( radius, 0.0075, 3, 64, arc * Math.PI * 2 );
2201
+ geometry.rotateY( Math.PI / 2 );
2202
+ geometry.rotateX( Math.PI / 2 );
2203
+ return geometry;
2204
+
2205
+ }
2206
+
2207
+ // Special geometry for transform helper. If scaled with position vector it spans from [0,0,0] to position
2208
+
2209
+ function TranslateHelperGeometry() {
2210
+
2211
+ const geometry = new three__WEBPACK_IMPORTED_MODULE_0__["BufferGeometry"]();
2212
+
2213
+ geometry.setAttribute( 'position', new three__WEBPACK_IMPORTED_MODULE_0__["Float32BufferAttribute"]( [ 0, 0, 0, 1, 1, 1 ], 3 ) );
2214
+
2215
+ return geometry;
2216
+
2217
+ }
2218
+
2219
+ // Gizmo definitions - custom hierarchy definitions for setupGizmo() function
2220
+
2221
+ const gizmoTranslate = {
2222
+ X: [
2223
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( arrowGeometry, matRed ), [ 0.5, 0, 0 ], [ 0, 0, - Math.PI / 2 ]],
2224
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( arrowGeometry, matRed ), [ - 0.5, 0, 0 ], [ 0, 0, Math.PI / 2 ]],
2225
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( lineGeometry2, matRed ), [ 0, 0, 0 ], [ 0, 0, - Math.PI / 2 ]]
2226
+ ],
2227
+ Y: [
2228
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( arrowGeometry, matGreen ), [ 0, 0.5, 0 ]],
2229
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( arrowGeometry, matGreen ), [ 0, - 0.5, 0 ], [ Math.PI, 0, 0 ]],
2230
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( lineGeometry2, matGreen ) ]
2231
+ ],
2232
+ Z: [
2233
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( arrowGeometry, matBlue ), [ 0, 0, 0.5 ], [ Math.PI / 2, 0, 0 ]],
2234
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( arrowGeometry, matBlue ), [ 0, 0, - 0.5 ], [ - Math.PI / 2, 0, 0 ]],
2235
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( lineGeometry2, matBlue ), null, [ Math.PI / 2, 0, 0 ]]
2236
+ ],
2237
+ XYZ: [
2238
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["OctahedronGeometry"]( 0.1, 0 ), matWhiteTransparent.clone() ), [ 0, 0, 0 ]]
2239
+ ],
2240
+ XY: [
2241
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["BoxGeometry"]( 0.15, 0.15, 0.01 ), matBlueTransparent.clone() ), [ 0.15, 0.15, 0 ]]
2242
+ ],
2243
+ YZ: [
2244
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["BoxGeometry"]( 0.15, 0.15, 0.01 ), matRedTransparent.clone() ), [ 0, 0.15, 0.15 ], [ 0, Math.PI / 2, 0 ]]
2245
+ ],
2246
+ XZ: [
2247
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["BoxGeometry"]( 0.15, 0.15, 0.01 ), matGreenTransparent.clone() ), [ 0.15, 0, 0.15 ], [ - Math.PI / 2, 0, 0 ]]
2248
+ ]
2249
+ };
2250
+
2251
+ const pickerTranslate = {
2252
+ X: [
2253
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["CylinderGeometry"]( 0.2, 0, 0.6, 4 ), matInvisible ), [ 0.3, 0, 0 ], [ 0, 0, - Math.PI / 2 ]],
2254
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["CylinderGeometry"]( 0.2, 0, 0.6, 4 ), matInvisible ), [ - 0.3, 0, 0 ], [ 0, 0, Math.PI / 2 ]]
2255
+ ],
2256
+ Y: [
2257
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["CylinderGeometry"]( 0.2, 0, 0.6, 4 ), matInvisible ), [ 0, 0.3, 0 ]],
2258
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["CylinderGeometry"]( 0.2, 0, 0.6, 4 ), matInvisible ), [ 0, - 0.3, 0 ], [ 0, 0, Math.PI ]]
2259
+ ],
2260
+ Z: [
2261
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["CylinderGeometry"]( 0.2, 0, 0.6, 4 ), matInvisible ), [ 0, 0, 0.3 ], [ Math.PI / 2, 0, 0 ]],
2262
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["CylinderGeometry"]( 0.2, 0, 0.6, 4 ), matInvisible ), [ 0, 0, - 0.3 ], [ - Math.PI / 2, 0, 0 ]]
2263
+ ],
2264
+ XYZ: [
2265
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["OctahedronGeometry"]( 0.2, 0 ), matInvisible ) ]
2266
+ ],
2267
+ XY: [
2268
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["BoxGeometry"]( 0.2, 0.2, 0.01 ), matInvisible ), [ 0.15, 0.15, 0 ]]
2269
+ ],
2270
+ YZ: [
2271
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["BoxGeometry"]( 0.2, 0.2, 0.01 ), matInvisible ), [ 0, 0.15, 0.15 ], [ 0, Math.PI / 2, 0 ]]
2272
+ ],
2273
+ XZ: [
2274
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["BoxGeometry"]( 0.2, 0.2, 0.01 ), matInvisible ), [ 0.15, 0, 0.15 ], [ - Math.PI / 2, 0, 0 ]]
2275
+ ]
2276
+ };
2277
+
2278
+ const helperTranslate = {
2279
+ START: [
2280
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["OctahedronGeometry"]( 0.01, 2 ), matHelper ), null, null, null, 'helper' ]
2281
+ ],
2282
+ END: [
2283
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["OctahedronGeometry"]( 0.01, 2 ), matHelper ), null, null, null, 'helper' ]
2284
+ ],
2285
+ DELTA: [
2286
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Line"]( TranslateHelperGeometry(), matHelper ), null, null, null, 'helper' ]
2287
+ ],
2288
+ X: [
2289
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Line"]( lineGeometry, matHelper.clone() ), [ - 1e3, 0, 0 ], null, [ 1e6, 1, 1 ], 'helper' ]
2290
+ ],
2291
+ Y: [
2292
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Line"]( lineGeometry, matHelper.clone() ), [ 0, - 1e3, 0 ], [ 0, 0, Math.PI / 2 ], [ 1e6, 1, 1 ], 'helper' ]
2293
+ ],
2294
+ Z: [
2295
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Line"]( lineGeometry, matHelper.clone() ), [ 0, 0, - 1e3 ], [ 0, - Math.PI / 2, 0 ], [ 1e6, 1, 1 ], 'helper' ]
2296
+ ]
2297
+ };
2298
+
2299
+ const gizmoRotate = {
2300
+ XYZE: [
2301
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( CircleGeometry( 0.5, 1 ), matGray ), null, [ 0, Math.PI / 2, 0 ]]
2302
+ ],
2303
+ X: [
2304
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( CircleGeometry( 0.5, 0.5 ), matRed ) ]
2305
+ ],
2306
+ Y: [
2307
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( CircleGeometry( 0.5, 0.5 ), matGreen ), null, [ 0, 0, - Math.PI / 2 ]]
2308
+ ],
2309
+ Z: [
2310
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( CircleGeometry( 0.5, 0.5 ), matBlue ), null, [ 0, Math.PI / 2, 0 ]]
2311
+ ],
2312
+ E: [
2313
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( CircleGeometry( 0.75, 1 ), matYellowTransparent ), null, [ 0, Math.PI / 2, 0 ]]
2314
+ ]
2315
+ };
2316
+
2317
+ const helperRotate = {
2318
+ AXIS: [
2319
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Line"]( lineGeometry, matHelper.clone() ), [ - 1e3, 0, 0 ], null, [ 1e6, 1, 1 ], 'helper' ]
2320
+ ]
2321
+ };
2322
+
2323
+ const pickerRotate = {
2324
+ XYZE: [
2325
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["SphereGeometry"]( 0.25, 10, 8 ), matInvisible ) ]
2326
+ ],
2327
+ X: [
2328
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["TorusGeometry"]( 0.5, 0.1, 4, 24 ), matInvisible ), [ 0, 0, 0 ], [ 0, - Math.PI / 2, - Math.PI / 2 ]],
2329
+ ],
2330
+ Y: [
2331
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["TorusGeometry"]( 0.5, 0.1, 4, 24 ), matInvisible ), [ 0, 0, 0 ], [ Math.PI / 2, 0, 0 ]],
2332
+ ],
2333
+ Z: [
2334
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["TorusGeometry"]( 0.5, 0.1, 4, 24 ), matInvisible ), [ 0, 0, 0 ], [ 0, 0, - Math.PI / 2 ]],
2335
+ ],
2336
+ E: [
2337
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["TorusGeometry"]( 0.75, 0.1, 2, 24 ), matInvisible ) ]
2338
+ ]
2339
+ };
2340
+
2341
+ const gizmoScale = {
2342
+ X: [
2343
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( scaleHandleGeometry, matRed ), [ 0.5, 0, 0 ], [ 0, 0, - Math.PI / 2 ]],
2344
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( lineGeometry2, matRed ), [ 0, 0, 0 ], [ 0, 0, - Math.PI / 2 ]],
2345
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( scaleHandleGeometry, matRed ), [ - 0.5, 0, 0 ], [ 0, 0, Math.PI / 2 ]],
2346
+ ],
2347
+ Y: [
2348
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( scaleHandleGeometry, matGreen ), [ 0, 0.5, 0 ]],
2349
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( lineGeometry2, matGreen ) ],
2350
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( scaleHandleGeometry, matGreen ), [ 0, - 0.5, 0 ], [ 0, 0, Math.PI ]],
2351
+ ],
2352
+ Z: [
2353
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( scaleHandleGeometry, matBlue ), [ 0, 0, 0.5 ], [ Math.PI / 2, 0, 0 ]],
2354
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( lineGeometry2, matBlue ), [ 0, 0, 0 ], [ Math.PI / 2, 0, 0 ]],
2355
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( scaleHandleGeometry, matBlue ), [ 0, 0, - 0.5 ], [ - Math.PI / 2, 0, 0 ]]
2356
+ ],
2357
+ XY: [
2358
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["BoxGeometry"]( 0.15, 0.15, 0.01 ), matBlueTransparent ), [ 0.15, 0.15, 0 ]]
2359
+ ],
2360
+ YZ: [
2361
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["BoxGeometry"]( 0.15, 0.15, 0.01 ), matRedTransparent ), [ 0, 0.15, 0.15 ], [ 0, Math.PI / 2, 0 ]]
2362
+ ],
2363
+ XZ: [
2364
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["BoxGeometry"]( 0.15, 0.15, 0.01 ), matGreenTransparent ), [ 0.15, 0, 0.15 ], [ - Math.PI / 2, 0, 0 ]]
2365
+ ],
2366
+ XYZ: [
2367
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["BoxGeometry"]( 0.1, 0.1, 0.1 ), matWhiteTransparent.clone() ) ],
2368
+ ]
2369
+ };
2370
+
2371
+ const pickerScale = {
2372
+ X: [
2373
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["CylinderGeometry"]( 0.2, 0, 0.6, 4 ), matInvisible ), [ 0.3, 0, 0 ], [ 0, 0, - Math.PI / 2 ]],
2374
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["CylinderGeometry"]( 0.2, 0, 0.6, 4 ), matInvisible ), [ - 0.3, 0, 0 ], [ 0, 0, Math.PI / 2 ]]
2375
+ ],
2376
+ Y: [
2377
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["CylinderGeometry"]( 0.2, 0, 0.6, 4 ), matInvisible ), [ 0, 0.3, 0 ]],
2378
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["CylinderGeometry"]( 0.2, 0, 0.6, 4 ), matInvisible ), [ 0, - 0.3, 0 ], [ 0, 0, Math.PI ]]
2379
+ ],
2380
+ Z: [
2381
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["CylinderGeometry"]( 0.2, 0, 0.6, 4 ), matInvisible ), [ 0, 0, 0.3 ], [ Math.PI / 2, 0, 0 ]],
2382
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["CylinderGeometry"]( 0.2, 0, 0.6, 4 ), matInvisible ), [ 0, 0, - 0.3 ], [ - Math.PI / 2, 0, 0 ]]
2383
+ ],
2384
+ XY: [
2385
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["BoxGeometry"]( 0.2, 0.2, 0.01 ), matInvisible ), [ 0.15, 0.15, 0 ]],
2386
+ ],
2387
+ YZ: [
2388
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["BoxGeometry"]( 0.2, 0.2, 0.01 ), matInvisible ), [ 0, 0.15, 0.15 ], [ 0, Math.PI / 2, 0 ]],
2389
+ ],
2390
+ XZ: [
2391
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["BoxGeometry"]( 0.2, 0.2, 0.01 ), matInvisible ), [ 0.15, 0, 0.15 ], [ - Math.PI / 2, 0, 0 ]],
2392
+ ],
2393
+ XYZ: [
2394
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Mesh"]( new three__WEBPACK_IMPORTED_MODULE_0__["BoxGeometry"]( 0.2, 0.2, 0.2 ), matInvisible ), [ 0, 0, 0 ]],
2395
+ ]
2396
+ };
2397
+
2398
+ const helperScale = {
2399
+ X: [
2400
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Line"]( lineGeometry, matHelper.clone() ), [ - 1e3, 0, 0 ], null, [ 1e6, 1, 1 ], 'helper' ]
2401
+ ],
2402
+ Y: [
2403
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Line"]( lineGeometry, matHelper.clone() ), [ 0, - 1e3, 0 ], [ 0, 0, Math.PI / 2 ], [ 1e6, 1, 1 ], 'helper' ]
2404
+ ],
2405
+ Z: [
2406
+ [ new three__WEBPACK_IMPORTED_MODULE_0__["Line"]( lineGeometry, matHelper.clone() ), [ 0, 0, - 1e3 ], [ 0, - Math.PI / 2, 0 ], [ 1e6, 1, 1 ], 'helper' ]
2407
+ ]
2408
+ };
2409
+
2410
+ // Creates an Object3D with gizmos described in custom hierarchy definition.
2411
+
2412
+ function setupGizmo( gizmoMap ) {
2413
+
2414
+ const gizmo = new three__WEBPACK_IMPORTED_MODULE_0__["Object3D"]();
2415
+
2416
+ for ( const name in gizmoMap ) {
2417
+
2418
+ for ( let i = gizmoMap[ name ].length; i --; ) {
2419
+
2420
+ const object = gizmoMap[ name ][ i ][ 0 ].clone();
2421
+ const position = gizmoMap[ name ][ i ][ 1 ];
2422
+ const rotation = gizmoMap[ name ][ i ][ 2 ];
2423
+ const scale = gizmoMap[ name ][ i ][ 3 ];
2424
+ const tag = gizmoMap[ name ][ i ][ 4 ];
2425
+
2426
+ // name and tag properties are essential for picking and updating logic.
2427
+ object.name = name;
2428
+ object.tag = tag;
2429
+
2430
+ if ( position ) {
2431
+
2432
+ object.position.set( position[ 0 ], position[ 1 ], position[ 2 ] );
2433
+
2434
+ }
2435
+
2436
+ if ( rotation ) {
2437
+
2438
+ object.rotation.set( rotation[ 0 ], rotation[ 1 ], rotation[ 2 ] );
2439
+
2440
+ }
2441
+
2442
+ if ( scale ) {
2443
+
2444
+ object.scale.set( scale[ 0 ], scale[ 1 ], scale[ 2 ] );
2445
+
2446
+ }
2447
+
2448
+ object.updateMatrix();
2449
+
2450
+ const tempGeometry = object.geometry.clone();
2451
+ tempGeometry.applyMatrix4( object.matrix );
2452
+ object.geometry = tempGeometry;
2453
+ object.renderOrder = Infinity;
2454
+
2455
+ object.position.set( 0, 0, 0 );
2456
+ object.rotation.set( 0, 0, 0 );
2457
+ object.scale.set( 1, 1, 1 );
2458
+
2459
+ gizmo.add( object );
2460
+
2461
+ }
2462
+
2463
+ }
2464
+
2465
+ return gizmo;
2466
+
2467
+ }
2468
+
2469
+ // Gizmo creation
2470
+
2471
+ this.gizmo = {};
2472
+ this.picker = {};
2473
+ this.helper = {};
2474
+
2475
+ this.add( this.gizmo[ 'translate' ] = setupGizmo( gizmoTranslate ) );
2476
+ this.add( this.gizmo[ 'rotate' ] = setupGizmo( gizmoRotate ) );
2477
+ this.add( this.gizmo[ 'scale' ] = setupGizmo( gizmoScale ) );
2478
+ this.add( this.picker[ 'translate' ] = setupGizmo( pickerTranslate ) );
2479
+ this.add( this.picker[ 'rotate' ] = setupGizmo( pickerRotate ) );
2480
+ this.add( this.picker[ 'scale' ] = setupGizmo( pickerScale ) );
2481
+ this.add( this.helper[ 'translate' ] = setupGizmo( helperTranslate ) );
2482
+ this.add( this.helper[ 'rotate' ] = setupGizmo( helperRotate ) );
2483
+ this.add( this.helper[ 'scale' ] = setupGizmo( helperScale ) );
2484
+
2485
+ // Pickers should be hidden always
2486
+
2487
+ this.picker[ 'translate' ].visible = false;
2488
+ this.picker[ 'rotate' ].visible = false;
2489
+ this.picker[ 'scale' ].visible = false;
2490
+
2491
+ }
2492
+
2493
+ // updateMatrixWorld will update transformations and appearance of individual handles
2494
+
2495
+ updateMatrixWorld( force ) {
2496
+
2497
+ const space = ( this.mode === 'scale' ) ? 'local' : this.space; // scale always oriented to local rotation
2498
+
2499
+ const quaternion = ( space === 'local' ) ? this.worldQuaternion : _identityQuaternion;
2500
+
2501
+ // Show only gizmos for current transform mode
2502
+
2503
+ this.gizmo[ 'translate' ].visible = this.mode === 'translate';
2504
+ this.gizmo[ 'rotate' ].visible = this.mode === 'rotate';
2505
+ this.gizmo[ 'scale' ].visible = this.mode === 'scale';
2506
+
2507
+ this.helper[ 'translate' ].visible = this.mode === 'translate';
2508
+ this.helper[ 'rotate' ].visible = this.mode === 'rotate';
2509
+ this.helper[ 'scale' ].visible = this.mode === 'scale';
2510
+
2511
+
2512
+ let handles = [];
2513
+ handles = handles.concat( this.picker[ this.mode ].children );
2514
+ handles = handles.concat( this.gizmo[ this.mode ].children );
2515
+ handles = handles.concat( this.helper[ this.mode ].children );
2516
+
2517
+ for ( let i = 0; i < handles.length; i ++ ) {
2518
+
2519
+ const handle = handles[ i ];
2520
+
2521
+ // hide aligned to camera
2522
+
2523
+ handle.visible = true;
2524
+ handle.rotation.set( 0, 0, 0 );
2525
+ handle.position.copy( this.worldPosition );
2526
+
2527
+ let factor;
2528
+
2529
+ if ( this.camera.isOrthographicCamera ) {
2530
+
2531
+ factor = ( this.camera.top - this.camera.bottom ) / this.camera.zoom;
2532
+
2533
+ } else {
2534
+
2535
+ factor = this.worldPosition.distanceTo( this.cameraPosition ) * Math.min( 1.9 * Math.tan( Math.PI * this.camera.fov / 360 ) / this.camera.zoom, 7 );
2536
+
2537
+ }
2538
+
2539
+ handle.scale.set( 1, 1, 1 ).multiplyScalar( factor * this.size / 4 );
2540
+
2541
+ // TODO: simplify helpers and consider decoupling from gizmo
2542
+
2543
+ if ( handle.tag === 'helper' ) {
2544
+
2545
+ handle.visible = false;
2546
+
2547
+ if ( handle.name === 'AXIS' ) {
2548
+
2549
+ handle.position.copy( this.worldPositionStart );
2550
+ handle.visible = !! this.axis;
2551
+
2552
+ if ( this.axis === 'X' ) {
2553
+
2554
+ _tempQuaternion.setFromEuler( _tempEuler.set( 0, 0, 0 ) );
2555
+ handle.quaternion.copy( quaternion ).multiply( _tempQuaternion );
2556
+
2557
+ if ( Math.abs( _alignVector.copy( _unitX ).applyQuaternion( quaternion ).dot( this.eye ) ) > 0.9 ) {
2558
+
2559
+ handle.visible = false;
2560
+
2561
+ }
2562
+
2563
+ }
2564
+
2565
+ if ( this.axis === 'Y' ) {
2566
+
2567
+ _tempQuaternion.setFromEuler( _tempEuler.set( 0, 0, Math.PI / 2 ) );
2568
+ handle.quaternion.copy( quaternion ).multiply( _tempQuaternion );
2569
+
2570
+ if ( Math.abs( _alignVector.copy( _unitY ).applyQuaternion( quaternion ).dot( this.eye ) ) > 0.9 ) {
2571
+
2572
+ handle.visible = false;
2573
+
2574
+ }
2575
+
2576
+ }
2577
+
2578
+ if ( this.axis === 'Z' ) {
2579
+
2580
+ _tempQuaternion.setFromEuler( _tempEuler.set( 0, Math.PI / 2, 0 ) );
2581
+ handle.quaternion.copy( quaternion ).multiply( _tempQuaternion );
2582
+
2583
+ if ( Math.abs( _alignVector.copy( _unitZ ).applyQuaternion( quaternion ).dot( this.eye ) ) > 0.9 ) {
2584
+
2585
+ handle.visible = false;
2586
+
2587
+ }
2588
+
2589
+ }
2590
+
2591
+ if ( this.axis === 'XYZE' ) {
2592
+
2593
+ _tempQuaternion.setFromEuler( _tempEuler.set( 0, Math.PI / 2, 0 ) );
2594
+ _alignVector.copy( this.rotationAxis );
2595
+ handle.quaternion.setFromRotationMatrix( _lookAtMatrix.lookAt( _zeroVector, _alignVector, _unitY ) );
2596
+ handle.quaternion.multiply( _tempQuaternion );
2597
+ handle.visible = this.dragging;
2598
+
2599
+ }
2600
+
2601
+ if ( this.axis === 'E' ) {
2602
+
2603
+ handle.visible = false;
2604
+
2605
+ }
2606
+
2607
+
2608
+ } else if ( handle.name === 'START' ) {
2609
+
2610
+ handle.position.copy( this.worldPositionStart );
2611
+ handle.visible = this.dragging;
2612
+
2613
+ } else if ( handle.name === 'END' ) {
2614
+
2615
+ handle.position.copy( this.worldPosition );
2616
+ handle.visible = this.dragging;
2617
+
2618
+ } else if ( handle.name === 'DELTA' ) {
2619
+
2620
+ handle.position.copy( this.worldPositionStart );
2621
+ handle.quaternion.copy( this.worldQuaternionStart );
2622
+ _tempVector.set( 1e-10, 1e-10, 1e-10 ).add( this.worldPositionStart ).sub( this.worldPosition ).multiplyScalar( - 1 );
2623
+ _tempVector.applyQuaternion( this.worldQuaternionStart.clone().invert() );
2624
+ handle.scale.copy( _tempVector );
2625
+ handle.visible = this.dragging;
2626
+
2627
+ } else {
2628
+
2629
+ handle.quaternion.copy( quaternion );
2630
+
2631
+ if ( this.dragging ) {
2632
+
2633
+ handle.position.copy( this.worldPositionStart );
2634
+
2635
+ } else {
2636
+
2637
+ handle.position.copy( this.worldPosition );
2638
+
2639
+ }
2640
+
2641
+ if ( this.axis ) {
2642
+
2643
+ handle.visible = this.axis.search( handle.name ) !== - 1;
2644
+
2645
+ }
2646
+
2647
+ }
2648
+
2649
+ // If updating helper, skip rest of the loop
2650
+ continue;
2651
+
2652
+ }
2653
+
2654
+ // Align handles to current local or world rotation
2655
+
2656
+ handle.quaternion.copy( quaternion );
2657
+
2658
+ if ( this.mode === 'translate' || this.mode === 'scale' ) {
2659
+
2660
+ // Hide translate and scale axis facing the camera
2661
+
2662
+ const AXIS_HIDE_TRESHOLD = 0.99;
2663
+ const PLANE_HIDE_TRESHOLD = 0.2;
2664
+
2665
+ if ( handle.name === 'X' ) {
2666
+
2667
+ if ( Math.abs( _alignVector.copy( _unitX ).applyQuaternion( quaternion ).dot( this.eye ) ) > AXIS_HIDE_TRESHOLD ) {
2668
+
2669
+ handle.scale.set( 1e-10, 1e-10, 1e-10 );
2670
+ handle.visible = false;
2671
+
2672
+ }
2673
+
2674
+ }
2675
+
2676
+ if ( handle.name === 'Y' ) {
2677
+
2678
+ if ( Math.abs( _alignVector.copy( _unitY ).applyQuaternion( quaternion ).dot( this.eye ) ) > AXIS_HIDE_TRESHOLD ) {
2679
+
2680
+ handle.scale.set( 1e-10, 1e-10, 1e-10 );
2681
+ handle.visible = false;
2682
+
2683
+ }
2684
+
2685
+ }
2686
+
2687
+ if ( handle.name === 'Z' ) {
2688
+
2689
+ if ( Math.abs( _alignVector.copy( _unitZ ).applyQuaternion( quaternion ).dot( this.eye ) ) > AXIS_HIDE_TRESHOLD ) {
2690
+
2691
+ handle.scale.set( 1e-10, 1e-10, 1e-10 );
2692
+ handle.visible = false;
2693
+
2694
+ }
2695
+
2696
+ }
2697
+
2698
+ if ( handle.name === 'XY' ) {
2699
+
2700
+ if ( Math.abs( _alignVector.copy( _unitZ ).applyQuaternion( quaternion ).dot( this.eye ) ) < PLANE_HIDE_TRESHOLD ) {
2701
+
2702
+ handle.scale.set( 1e-10, 1e-10, 1e-10 );
2703
+ handle.visible = false;
2704
+
2705
+ }
2706
+
2707
+ }
2708
+
2709
+ if ( handle.name === 'YZ' ) {
2710
+
2711
+ if ( Math.abs( _alignVector.copy( _unitX ).applyQuaternion( quaternion ).dot( this.eye ) ) < PLANE_HIDE_TRESHOLD ) {
2712
+
2713
+ handle.scale.set( 1e-10, 1e-10, 1e-10 );
2714
+ handle.visible = false;
2715
+
2716
+ }
2717
+
2718
+ }
2719
+
2720
+ if ( handle.name === 'XZ' ) {
2721
+
2722
+ if ( Math.abs( _alignVector.copy( _unitY ).applyQuaternion( quaternion ).dot( this.eye ) ) < PLANE_HIDE_TRESHOLD ) {
2723
+
2724
+ handle.scale.set( 1e-10, 1e-10, 1e-10 );
2725
+ handle.visible = false;
2726
+
2727
+ }
2728
+
2729
+ }
2730
+
2731
+ } else if ( this.mode === 'rotate' ) {
2732
+
2733
+ // Align handles to current local or world rotation
2734
+
2735
+ _tempQuaternion2.copy( quaternion );
2736
+ _alignVector.copy( this.eye ).applyQuaternion( _tempQuaternion.copy( quaternion ).invert() );
2737
+
2738
+ if ( handle.name.search( 'E' ) !== - 1 ) {
2739
+
2740
+ handle.quaternion.setFromRotationMatrix( _lookAtMatrix.lookAt( this.eye, _zeroVector, _unitY ) );
2741
+
2742
+ }
2743
+
2744
+ if ( handle.name === 'X' ) {
2745
+
2746
+ _tempQuaternion.setFromAxisAngle( _unitX, Math.atan2( - _alignVector.y, _alignVector.z ) );
2747
+ _tempQuaternion.multiplyQuaternions( _tempQuaternion2, _tempQuaternion );
2748
+ handle.quaternion.copy( _tempQuaternion );
2749
+
2750
+ }
2751
+
2752
+ if ( handle.name === 'Y' ) {
2753
+
2754
+ _tempQuaternion.setFromAxisAngle( _unitY, Math.atan2( _alignVector.x, _alignVector.z ) );
2755
+ _tempQuaternion.multiplyQuaternions( _tempQuaternion2, _tempQuaternion );
2756
+ handle.quaternion.copy( _tempQuaternion );
2757
+
2758
+ }
2759
+
2760
+ if ( handle.name === 'Z' ) {
2761
+
2762
+ _tempQuaternion.setFromAxisAngle( _unitZ, Math.atan2( _alignVector.y, _alignVector.x ) );
2763
+ _tempQuaternion.multiplyQuaternions( _tempQuaternion2, _tempQuaternion );
2764
+ handle.quaternion.copy( _tempQuaternion );
2765
+
2766
+ }
2767
+
2768
+ }
2769
+
2770
+ // Hide disabled axes
2771
+ handle.visible = handle.visible && ( handle.name.indexOf( 'X' ) === - 1 || this.showX );
2772
+ handle.visible = handle.visible && ( handle.name.indexOf( 'Y' ) === - 1 || this.showY );
2773
+ handle.visible = handle.visible && ( handle.name.indexOf( 'Z' ) === - 1 || this.showZ );
2774
+ handle.visible = handle.visible && ( handle.name.indexOf( 'E' ) === - 1 || ( this.showX && this.showY && this.showZ ) );
2775
+
2776
+ // highlight selected axis
2777
+
2778
+ handle.material._color = handle.material._color || handle.material.color.clone();
2779
+ handle.material._opacity = handle.material._opacity || handle.material.opacity;
2780
+
2781
+ handle.material.color.copy( handle.material._color );
2782
+ handle.material.opacity = handle.material._opacity;
2783
+
2784
+ if ( this.enabled && this.axis ) {
2785
+
2786
+ if ( handle.name === this.axis ) {
2787
+
2788
+ handle.material.color.setHex( 0xffff00 );
2789
+ handle.material.opacity = 1.0;
2790
+
2791
+ } else if ( this.axis.split( '' ).some( function ( a ) {
2792
+
2793
+ return handle.name === a;
2794
+
2795
+ } ) ) {
2796
+
2797
+ handle.material.color.setHex( 0xffff00 );
2798
+ handle.material.opacity = 1.0;
2799
+
2800
+ }
2801
+
2802
+ }
2803
+
2804
+ }
2805
+
2806
+ super.updateMatrixWorld( force );
2807
+
2808
+ }
2809
+
2810
+ }
2811
+
2812
+ TransformControlsGizmo.prototype.isTransformControlsGizmo = true;
2813
+
2814
+ //
2815
+
2816
+ class TransformControlsPlane extends three__WEBPACK_IMPORTED_MODULE_0__["Mesh"] {
2817
+
2818
+ constructor() {
2819
+
2820
+ super(
2821
+ new three__WEBPACK_IMPORTED_MODULE_0__["PlaneGeometry"]( 100000, 100000, 2, 2 ),
2822
+ new three__WEBPACK_IMPORTED_MODULE_0__["MeshBasicMaterial"]( { visible: false, wireframe: true, side: three__WEBPACK_IMPORTED_MODULE_0__["DoubleSide"], transparent: true, opacity: 0.1, toneMapped: false } )
2823
+ );
2824
+
2825
+ this.type = 'TransformControlsPlane';
2826
+
2827
+ }
2828
+
2829
+ updateMatrixWorld( force ) {
2830
+
2831
+ let space = this.space;
2832
+
2833
+ this.position.copy( this.worldPosition );
2834
+
2835
+ if ( this.mode === 'scale' ) space = 'local'; // scale always oriented to local rotation
2836
+
2837
+ _v1.copy( _unitX ).applyQuaternion( space === 'local' ? this.worldQuaternion : _identityQuaternion );
2838
+ _v2.copy( _unitY ).applyQuaternion( space === 'local' ? this.worldQuaternion : _identityQuaternion );
2839
+ _v3.copy( _unitZ ).applyQuaternion( space === 'local' ? this.worldQuaternion : _identityQuaternion );
2840
+
2841
+ // Align the plane for current transform mode, axis and space.
2842
+
2843
+ _alignVector.copy( _v2 );
2844
+
2845
+ switch ( this.mode ) {
2846
+
2847
+ case 'translate':
2848
+ case 'scale':
2849
+ switch ( this.axis ) {
2850
+
2851
+ case 'X':
2852
+ _alignVector.copy( this.eye ).cross( _v1 );
2853
+ _dirVector.copy( _v1 ).cross( _alignVector );
2854
+ break;
2855
+ case 'Y':
2856
+ _alignVector.copy( this.eye ).cross( _v2 );
2857
+ _dirVector.copy( _v2 ).cross( _alignVector );
2858
+ break;
2859
+ case 'Z':
2860
+ _alignVector.copy( this.eye ).cross( _v3 );
2861
+ _dirVector.copy( _v3 ).cross( _alignVector );
2862
+ break;
2863
+ case 'XY':
2864
+ _dirVector.copy( _v3 );
2865
+ break;
2866
+ case 'YZ':
2867
+ _dirVector.copy( _v1 );
2868
+ break;
2869
+ case 'XZ':
2870
+ _alignVector.copy( _v3 );
2871
+ _dirVector.copy( _v2 );
2872
+ break;
2873
+ case 'XYZ':
2874
+ case 'E':
2875
+ _dirVector.set( 0, 0, 0 );
2876
+ break;
2877
+
2878
+ }
2879
+
2880
+ break;
2881
+ case 'rotate':
2882
+ default:
2883
+ // special case for rotate
2884
+ _dirVector.set( 0, 0, 0 );
2885
+
2886
+ }
2887
+
2888
+ if ( _dirVector.length() === 0 ) {
2889
+
2890
+ // If in rotate mode, make the plane parallel to camera
2891
+ this.quaternion.copy( this.cameraQuaternion );
2892
+
2893
+ } else {
2894
+
2895
+ _tempMatrix.lookAt( _tempVector.set( 0, 0, 0 ), _dirVector, _alignVector );
2896
+
2897
+ this.quaternion.setFromRotationMatrix( _tempMatrix );
2898
+
2899
+ }
2900
+
2901
+ super.updateMatrixWorld( force );
2902
+
2903
+ }
2904
+
2905
+ }
2906
+
2907
+ TransformControlsPlane.prototype.isTransformControlsPlane = true;
2908
+
2909
+
2910
+
2911
+
1358
2912
  /***/ }),
1359
2913
 
1360
2914
  /***/ "./package.json":
@@ -1364,7 +2918,7 @@ class MapControls extends OrbitControls {
1364
2918
  /*! exports provided: name, version, main, types, scripts, dependencies, devDependencies, author, license, description, default */
1365
2919
  /***/ (function(module) {
1366
2920
 
1367
- module.exports = JSON.parse("{\"name\":\"igs-view\",\"version\":\"1.0.6\",\"main\":\"./dist/main.js\",\"types\":\"./types/Main.d.ts\",\"scripts\":{\"dev\":\"webpack-dev-server --watch --open --config webpack.dev.js --host 127.0.0.1\",\"build\":\"webpack --config webpack.prod.js && npm run declare\",\"declare\":\"tsc -d --declarationDir types --emitDeclarationOnly\"},\"dependencies\":{\"@types/three\":\"^0.139.0\",\"three\":\"^0.139.2\"},\"devDependencies\":{\"@types/glob\":\"^9.0.0\",\"@types/node\":\"20.8.0\",\"ts-loader\":\"^4.0.0\",\"typescript\":\"^4.5.1\",\"webpack\":\"^4.1.0\",\"webpack-cli\":\"^3.1.1\",\"webpack-dev-server\":\"^3.1.0\",\"webpack-merge\":\"^4.2.2\",\"worker-loader\":\"^3.0.8\"},\"author\":\"\",\"license\":\"ISC\",\"description\":\"\"}");
2921
+ module.exports = JSON.parse("{\"name\":\"igs-view\",\"version\":\"1.0.8\",\"main\":\"./dist/main.js\",\"types\":\"./types/Main.d.ts\",\"scripts\":{\"dev\":\"webpack-dev-server --watch --open --config webpack.dev.js --host 127.0.0.1\",\"build\":\"webpack --config webpack.prod.js && npm run declare\",\"declare\":\"tsc -d --declarationDir types --emitDeclarationOnly\"},\"dependencies\":{\"@types/three\":\"^0.139.0\",\"three\":\"^0.139.2\"},\"devDependencies\":{\"@types/glob\":\"^9.0.0\",\"@types/node\":\"20.8.0\",\"ts-loader\":\"^4.0.0\",\"typescript\":\"^4.5.1\",\"webpack\":\"^4.1.0\",\"webpack-cli\":\"^3.1.1\",\"webpack-dev-server\":\"^3.1.0\",\"webpack-merge\":\"^4.2.2\",\"worker-loader\":\"^3.0.8\"},\"author\":\"\",\"license\":\"ISC\",\"description\":\"\"}");
1368
2922
 
1369
2923
  /***/ }),
1370
2924
 
@@ -1382,6 +2936,7 @@ __webpack_require__.r(__webpack_exports__);
1382
2936
  /* harmony import */ var three__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! three */ "three");
1383
2937
  /* harmony import */ var three__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(three__WEBPACK_IMPORTED_MODULE_0__);
1384
2938
  /* harmony import */ var three_examples_jsm_controls_OrbitControls__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! three/examples/jsm/controls/OrbitControls */ "./node_modules/.pnpm/three@0.139.2/node_modules/three/examples/jsm/controls/OrbitControls.js");
2939
+ /* harmony import */ var three_examples_jsm_controls_TransformControls__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! three/examples/jsm/controls/TransformControls */ "./node_modules/.pnpm/three@0.139.2/node_modules/three/examples/jsm/controls/TransformControls.js");
1385
2940
  var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
1386
2941
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1387
2942
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -1393,6 +2948,7 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
1393
2948
  };
1394
2949
 
1395
2950
 
2951
+
1396
2952
  var OutEventTypes;
1397
2953
  (function (OutEventTypes) {
1398
2954
  /**
@@ -1527,7 +3083,7 @@ class Main extends three__WEBPACK_IMPORTED_MODULE_0__["EventDispatcher"] {
1527
3083
  this.map.length = 0;
1528
3084
  this.entities = entities;
1529
3085
  entities.forEach(({ Triangles, Vertices, Id }) => {
1530
- console.log(Triangles, Vertices);
3086
+ // console.log(Triangles, Vertices)
1531
3087
  // ========== 创建BufferGeometry ==========
1532
3088
  const geometry = new three__WEBPACK_IMPORTED_MODULE_0__["BufferGeometry"]();
1533
3089
  // 顶点位置数组
@@ -1590,49 +3146,109 @@ class Main extends three__WEBPACK_IMPORTED_MODULE_0__["EventDispatcher"] {
1590
3146
  verticalView() {
1591
3147
  if (!this.igsGroup.children.length)
1592
3148
  return null;
1593
- if (this.rotateX == 0 && this.rotateY == 0) {
1594
- let canvas = document.createElement("canvas");
1595
- let originX = (this.pading - this.box.min.x) * this.scale;
1596
- let originY = (this.pading - this.box.min.y) * this.scale;
1597
- let vec = this.box.getSize(new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]);
1598
- canvas.width = (vec.x + this.pading * 2) * this.scale;
1599
- canvas.height = (vec.y + this.pading * 2) * this.scale;
1600
- let ctx = canvas.getContext("2d");
1601
- ctx.setTransform(this.scale, 0, 0, this.scale, originX, originY);
1602
- this.map.sort((a, b) => a.height - b.height);
1603
- let max = this.map[this.map.length - 1].height;
1604
- // console.log(this.map)
1605
- this.map.forEach(({ height, points }, index) => {
1606
- let grey = (max - height) / max * 200;
1607
- ctx.fillStyle = `rgba(${grey}, ${grey}, ${grey}, 1)`;
1608
- ctx.strokeStyle = `rgba(${grey}, ${grey}, ${grey}, 1)`;
1609
- ctx.lineWidth = 1 / this.scale;
1610
- ctx.lineCap = "round";
1611
- ctx.lineJoin = "round";
1612
- ctx.beginPath();
1613
- for (let i = 0; i < points.length; i += 2) {
1614
- if (i == 0) {
1615
- ctx.moveTo(points[i], points[i + 1]);
1616
- }
1617
- else {
1618
- ctx.lineTo(points[i], points[i + 1]);
1619
- }
1620
- }
1621
- ctx.closePath();
1622
- ctx.fill();
1623
- ctx.stroke();
1624
- });
1625
- // document.body.appendChild(canvas);
1626
- return {
1627
- x: originX,
1628
- y: originY,
1629
- scale: this.scale,
1630
- base64: canvas.toDataURL("image/jpeg", 0.8)
1631
- };
1632
- }
1633
- else {
1634
- //带旋转
1635
- }
3149
+ // if (this.igsGroup.rotation.x == 0 && this.igsGroup.rotation.y == 0) {
3150
+ // let canvas = document.createElement("canvas")
3151
+ // let originX = (this.pading - this.box.min.x) * this.scale;
3152
+ // let originY = (this.pading - this.box.min.y) * this.scale;
3153
+ // let vec = this.box.getSize(new Vector3);
3154
+ // canvas.width = (vec.x + this.pading * 2) * this.scale;
3155
+ // canvas.height = (vec.y + this.pading * 2) * this.scale;
3156
+ // let ctx = canvas.getContext("2d")
3157
+ // ctx.fillStyle = "#ffffff"
3158
+ // ctx.fillRect(0, 0, canvas.width, canvas.height)
3159
+ // ctx.setTransform(this.scale, 0, 0, this.scale, originX, originY)
3160
+ // this.map.sort((a, b) => a.height - b.height);
3161
+ // let max = this.map[this.map.length - 1].height;
3162
+ // // console.log(this.map)
3163
+ // this.map.forEach(({ height, points }, index) => {
3164
+ // let grey = (max - height) / max * 200
3165
+ // ctx.fillStyle = `rgba(${grey}, ${grey}, ${grey}, 1)`;
3166
+ // ctx.strokeStyle = `rgba(${grey}, ${grey}, ${grey}, 1)`;
3167
+ // ctx.lineWidth = 1 / this.scale
3168
+ // ctx.lineCap = "round";
3169
+ // ctx.lineJoin = "round"
3170
+ // ctx.beginPath()
3171
+ // for (let i = 0; i < points.length; i += 2) {
3172
+ // if (i == 0) {
3173
+ // ctx.moveTo(points[i], points[i + 1])
3174
+ // } else {
3175
+ // ctx.lineTo(points[i], points[i + 1])
3176
+ // }
3177
+ // }
3178
+ // ctx.closePath();
3179
+ // ctx.fill();
3180
+ // ctx.stroke();
3181
+ // })
3182
+ // // document.body.appendChild(canvas);
3183
+ // return {
3184
+ // rotateX: 0,
3185
+ // rotateY: 0,
3186
+ // x: originX,
3187
+ // y: originY,
3188
+ // scale: this.scale,
3189
+ // base64: canvas.toDataURL("image/jpeg", 0.8)
3190
+ // }
3191
+ // } else {
3192
+ //带旋转
3193
+ let igsGroup = this.igsGroup.clone();
3194
+ igsGroup.scale.set(-1, 1, 1);
3195
+ igsGroup.updateMatrix();
3196
+ let box = new three__WEBPACK_IMPORTED_MODULE_0__["Box3"];
3197
+ igsGroup.children.forEach((m) => {
3198
+ let geo = m.geometry.clone();
3199
+ geo.applyMatrix4(this.igsGroup.matrix);
3200
+ geo.computeBoundingBox();
3201
+ box.union(geo.boundingBox);
3202
+ });
3203
+ const size = box.getSize(new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]());
3204
+ // console.log(size)
3205
+ const center = box.getCenter(new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]());
3206
+ // 2. 创建离屏渲染场景
3207
+ const scene = new three__WEBPACK_IMPORTED_MODULE_0__["Scene"]();
3208
+ scene.background = new three__WEBPACK_IMPORTED_MODULE_0__["Color"](0xffffff); // 白色背景
3209
+ scene.add(igsGroup);
3210
+ var pll = new three__WEBPACK_IMPORTED_MODULE_0__["DirectionalLight"](0xffffff, 0.3);
3211
+ pll.position.set(5, -10, 10);
3212
+ scene.add(pll);
3213
+ var pll = new three__WEBPACK_IMPORTED_MODULE_0__["DirectionalLight"](0xffffff, 0.3);
3214
+ pll.position.set(0, 10, 0);
3215
+ scene.add(pll);
3216
+ scene.add(new three__WEBPACK_IMPORTED_MODULE_0__["AmbientLight"](0xeeeeee, 0.05));
3217
+ // 3. 配置正交相机(俯视图)
3218
+ const viewWidth = size.x + this.pading * 2;
3219
+ const viewHeight = size.y + this.pading * 2;
3220
+ const camera = new three__WEBPACK_IMPORTED_MODULE_0__["OrthographicCamera"](-viewWidth / 2, viewWidth / 2, viewHeight / 2, -viewHeight / 2,
3221
+ // viewWidth / 2, // left (正值) ← 关键:+X映射到左
3222
+ // -viewWidth / 2, // right (负值) ← 关键:-X映射到右
3223
+ // -viewHeight / 2, // top (负值) ← 关键:-Y映射到上
3224
+ // viewHeight / 2, // bottom (正值) ← 关键:+Y映射到下
3225
+ 0.1, 1000);
3226
+ camera.up = new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0);
3227
+ // 相机放在 Z 轴正上方(向下看)
3228
+ camera.position.set(center.x, center.y, center.z + size.z + 50);
3229
+ camera.lookAt(center.x, center.y, center.z);
3230
+ // 5. 渲染到 canvas
3231
+ const renderer = new three__WEBPACK_IMPORTED_MODULE_0__["WebGLRenderer"]({
3232
+ antialias: true,
3233
+ preserveDrawingBuffer: true // 允许导出图片
3234
+ });
3235
+ // 设置合适的像素尺寸(可调整)
3236
+ const pixelRatio = 2; // 用于提高清晰度
3237
+ renderer.setSize(viewWidth * pixelRatio, viewHeight * pixelRatio);
3238
+ renderer.setPixelRatio(window.devicePixelRatio);
3239
+ // 渲染
3240
+ renderer.render(scene, camera);
3241
+ // document.body.appendChild(renderer.domElement);
3242
+ // 6. 返回渲染结果(canvas 元素)
3243
+ return {
3244
+ rotateX: this.igsGroup.rotation.x,
3245
+ rotateY: this.igsGroup.rotation.y,
3246
+ x: this.pading - box.min.x,
3247
+ y: this.pading - box.min.y,
3248
+ scale: 1,
3249
+ base64: renderer.domElement.toDataURL("image/jpeg", 0.8)
3250
+ };
3251
+ // }
1636
3252
  }
1637
3253
  addMouseEvent() {
1638
3254
  this.raycaster = new three__WEBPACK_IMPORTED_MODULE_0__["Raycaster"]();
@@ -1691,6 +3307,66 @@ class Main extends three__WEBPACK_IMPORTED_MODULE_0__["EventDispatcher"] {
1691
3307
  this.selected = mesh;
1692
3308
  this.selected.material = this.defaultMeshMaterial_selected;
1693
3309
  }
3310
+ /**
3311
+ * @description: 添加变换控制器
3312
+ * @return {*}
3313
+ * @author: shanbian
3314
+ */
3315
+ addTransformControls() {
3316
+ // 添加变换控制器
3317
+ this.transformControls = new three_examples_jsm_controls_TransformControls__WEBPACK_IMPORTED_MODULE_2__["TransformControls"](this.camera, this.renderer.domElement);
3318
+ this.scene.add(this.transformControls);
3319
+ // 选中父类为需要控制的物体
3320
+ this.transformControls.attach(this.igsGroup);
3321
+ this.transformControls.mode = 'rotate';
3322
+ this.transformControls.showZ = false;
3323
+ this.transformControls.showX = this.transformControls.showY = true;
3324
+ // 如果指针(鼠标/触摸)为活动状态则触发该事件。
3325
+ this.transformControls.addEventListener('mouseDown', () => {
3326
+ this.orbit.enabled = false;
3327
+ });
3328
+ // 如果指针(鼠标/触摸)不再为活动状态则触发该事件。
3329
+ this.transformControls.addEventListener('mouseUp', () => {
3330
+ this.orbit.enabled = true;
3331
+ });
3332
+ // 如果被控制的3D对象发生改变则触发该事件。
3333
+ this.transformControls.addEventListener('objectChange', () => {
3334
+ // // 更新Box3Helper
3335
+ // if (this.modelsSystem.getSelectedModelInfo()) {
3336
+ // const { uuid } = this.modelsSystem.getSelectedModelInfo();
3337
+ // this.modelsSystem.updateBox3Helper(uuid);
3338
+ // }
3339
+ // 渲染界面
3340
+ });
3341
+ // 通过按键控制 transformControls的mode
3342
+ document.addEventListener('keydown', (event) => {
3343
+ if (event.repeat) {
3344
+ return false;
3345
+ }
3346
+ // console.log(event);
3347
+ // if (event.key === 'e') {
3348
+ // this.transformControls.mode = 'scale';
3349
+ // return false;
3350
+ // }
3351
+ // if (event.key === 'r') {
3352
+ // this.transformControls.mode = 'rotate';
3353
+ // this.transformControls.showZ = true;
3354
+ // this.transformControls.showX = this.transformControls.showY = false;
3355
+ // return false;
3356
+ // }
3357
+ // if (event.key === 't') {
3358
+ // this.transformControls.mode = 'translate';
3359
+ // this.transformControls.showZ = false;
3360
+ // this.transformControls.showX = this.transformControls.showY = true;
3361
+ // return false;
3362
+ // }
3363
+ });
3364
+ }
3365
+ removeTransformControls() {
3366
+ this.scene.remove(this.transformControls);
3367
+ // 选中父类为需要控制的物体
3368
+ this.transformControls.detach();
3369
+ }
1694
3370
  }
1695
3371
 
1696
3372