three-render-objects 1.29.0 → 1.29.2
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Version 1.29.
|
|
1
|
+
// Version 1.29.2 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) :
|
|
@@ -62,6 +62,20 @@
|
|
|
62
62
|
return a;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
+
function _toPrimitive$1(t, r) {
|
|
66
|
+
if ("object" != typeof t || !t) return t;
|
|
67
|
+
var e = t[Symbol.toPrimitive];
|
|
68
|
+
if (void 0 !== e) {
|
|
69
|
+
var i = e.call(t, r || "default");
|
|
70
|
+
if ("object" != typeof i) return i;
|
|
71
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
72
|
+
}
|
|
73
|
+
return ("string" === r ? String : Number)(t);
|
|
74
|
+
}
|
|
75
|
+
function _toPropertyKey$1(t) {
|
|
76
|
+
var i = _toPrimitive$1(t, "string");
|
|
77
|
+
return "symbol" == typeof i ? i : String(i);
|
|
78
|
+
}
|
|
65
79
|
function _defineProperty(obj, key, value) {
|
|
66
80
|
key = _toPropertyKey$1(key);
|
|
67
81
|
if (key in obj) {
|
|
@@ -110,20 +124,6 @@
|
|
|
110
124
|
function _nonIterableRest$1() {
|
|
111
125
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
112
126
|
}
|
|
113
|
-
function _toPrimitive$1(input, hint) {
|
|
114
|
-
if (typeof input !== "object" || input === null) return input;
|
|
115
|
-
var prim = input[Symbol.toPrimitive];
|
|
116
|
-
if (prim !== undefined) {
|
|
117
|
-
var res = prim.call(input, hint || "default");
|
|
118
|
-
if (typeof res !== "object") return res;
|
|
119
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
120
|
-
}
|
|
121
|
-
return (hint === "string" ? String : Number)(input);
|
|
122
|
-
}
|
|
123
|
-
function _toPropertyKey$1(arg) {
|
|
124
|
-
var key = _toPrimitive$1(arg, "string");
|
|
125
|
-
return typeof key === "symbol" ? key : String(key);
|
|
126
|
-
}
|
|
127
127
|
|
|
128
128
|
const _changeEvent$2 = { type: 'change' };
|
|
129
129
|
const _startEvent$1 = { type: 'start' };
|
|
@@ -973,6 +973,9 @@
|
|
|
973
973
|
// "target" sets the location of focus, where the object orbits around
|
|
974
974
|
this.target = new three$1.Vector3();
|
|
975
975
|
|
|
976
|
+
// Sets the 3D cursor (similar to Blender), from which the maxTargetRadius takes effect
|
|
977
|
+
this.cursor = new three$1.Vector3();
|
|
978
|
+
|
|
976
979
|
// How far you can dolly in and out ( PerspectiveCamera only )
|
|
977
980
|
this.minDistance = 0;
|
|
978
981
|
this.maxDistance = Infinity;
|
|
@@ -981,6 +984,10 @@
|
|
|
981
984
|
this.minZoom = 0;
|
|
982
985
|
this.maxZoom = Infinity;
|
|
983
986
|
|
|
987
|
+
// Limit camera target within a spherical area around the cursor
|
|
988
|
+
this.minTargetRadius = 0;
|
|
989
|
+
this.maxTargetRadius = Infinity;
|
|
990
|
+
|
|
984
991
|
// How far you can orbit vertically, upper and lower limits.
|
|
985
992
|
// Range is 0 to Math.PI radians.
|
|
986
993
|
this.minPolarAngle = 0; // radians
|
|
@@ -1181,6 +1188,11 @@
|
|
|
1181
1188
|
|
|
1182
1189
|
}
|
|
1183
1190
|
|
|
1191
|
+
// Limit the target distance from the cursor to create a sphere around the center of interest
|
|
1192
|
+
scope.target.sub( scope.cursor );
|
|
1193
|
+
scope.target.clampLength( scope.minTargetRadius, scope.maxTargetRadius );
|
|
1194
|
+
scope.target.add( scope.cursor );
|
|
1195
|
+
|
|
1184
1196
|
// adjust the camera position based on zoom only if we're not zooming to the cursor or if it's an ortho camera
|
|
1185
1197
|
// we adjust zoom later in these cases
|
|
1186
1198
|
if ( scope.zoomToCursor && performCursorZoom || scope.object.isOrthographicCamera ) {
|
|
@@ -1193,7 +1205,6 @@
|
|
|
1193
1205
|
|
|
1194
1206
|
}
|
|
1195
1207
|
|
|
1196
|
-
|
|
1197
1208
|
offset.setFromSpherical( spherical );
|
|
1198
1209
|
|
|
1199
1210
|
// rotate offset back to "camera-up-vector-is-up" space
|
|
@@ -1295,9 +1306,14 @@
|
|
|
1295
1306
|
|
|
1296
1307
|
} else if ( scope.object.isOrthographicCamera ) {
|
|
1297
1308
|
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
zoomChanged
|
|
1309
|
+
zoomChanged = scale !== 1;
|
|
1310
|
+
|
|
1311
|
+
if ( zoomChanged ) {
|
|
1312
|
+
|
|
1313
|
+
scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / scale ) );
|
|
1314
|
+
scope.object.updateProjectionMatrix();
|
|
1315
|
+
|
|
1316
|
+
}
|
|
1301
1317
|
|
|
1302
1318
|
}
|
|
1303
1319
|
|
|
@@ -1319,8 +1335,6 @@
|
|
|
1319
1335
|
lastQuaternion.copy( scope.object.quaternion );
|
|
1320
1336
|
lastTargetPosition.copy( scope.target );
|
|
1321
1337
|
|
|
1322
|
-
zoomChanged = false;
|
|
1323
|
-
|
|
1324
1338
|
return true;
|
|
1325
1339
|
|
|
1326
1340
|
}
|
|
@@ -1401,6 +1415,8 @@
|
|
|
1401
1415
|
const pointers = [];
|
|
1402
1416
|
const pointerPositions = {};
|
|
1403
1417
|
|
|
1418
|
+
let controlActive = false;
|
|
1419
|
+
|
|
1404
1420
|
function getAutoRotationAngle( deltaTime ) {
|
|
1405
1421
|
|
|
1406
1422
|
if ( deltaTime !== null ) {
|
|
@@ -1415,9 +1431,10 @@
|
|
|
1415
1431
|
|
|
1416
1432
|
}
|
|
1417
1433
|
|
|
1418
|
-
function getZoomScale() {
|
|
1434
|
+
function getZoomScale( delta ) {
|
|
1419
1435
|
|
|
1420
|
-
|
|
1436
|
+
const normalizedDelta = Math.abs( delta * 0.01 );
|
|
1437
|
+
return Math.pow( 0.95, scope.zoomSpeed * normalizedDelta );
|
|
1421
1438
|
|
|
1422
1439
|
}
|
|
1423
1440
|
|
|
@@ -1544,7 +1561,7 @@
|
|
|
1544
1561
|
|
|
1545
1562
|
}
|
|
1546
1563
|
|
|
1547
|
-
function
|
|
1564
|
+
function updateZoomParameters( x, y ) {
|
|
1548
1565
|
|
|
1549
1566
|
if ( ! scope.zoomToCursor ) {
|
|
1550
1567
|
|
|
@@ -1555,13 +1572,13 @@
|
|
|
1555
1572
|
performCursorZoom = true;
|
|
1556
1573
|
|
|
1557
1574
|
const rect = scope.domElement.getBoundingClientRect();
|
|
1558
|
-
const
|
|
1559
|
-
const
|
|
1575
|
+
const dx = x - rect.left;
|
|
1576
|
+
const dy = y - rect.top;
|
|
1560
1577
|
const w = rect.width;
|
|
1561
1578
|
const h = rect.height;
|
|
1562
1579
|
|
|
1563
|
-
mouse.x = (
|
|
1564
|
-
mouse.y = - (
|
|
1580
|
+
mouse.x = ( dx / w ) * 2 - 1;
|
|
1581
|
+
mouse.y = - ( dy / h ) * 2 + 1;
|
|
1565
1582
|
|
|
1566
1583
|
dollyDirection.set( mouse.x, mouse.y, 1 ).unproject( scope.object ).sub( scope.object.position ).normalize();
|
|
1567
1584
|
|
|
@@ -1585,7 +1602,7 @@
|
|
|
1585
1602
|
|
|
1586
1603
|
function handleMouseDownDolly( event ) {
|
|
1587
1604
|
|
|
1588
|
-
|
|
1605
|
+
updateZoomParameters( event.clientX, event.clientX );
|
|
1589
1606
|
dollyStart.set( event.clientX, event.clientY );
|
|
1590
1607
|
|
|
1591
1608
|
}
|
|
@@ -1622,11 +1639,11 @@
|
|
|
1622
1639
|
|
|
1623
1640
|
if ( dollyDelta.y > 0 ) {
|
|
1624
1641
|
|
|
1625
|
-
dollyOut( getZoomScale() );
|
|
1642
|
+
dollyOut( getZoomScale( dollyDelta.y ) );
|
|
1626
1643
|
|
|
1627
1644
|
} else if ( dollyDelta.y < 0 ) {
|
|
1628
1645
|
|
|
1629
|
-
dollyIn( getZoomScale() );
|
|
1646
|
+
dollyIn( getZoomScale( dollyDelta.y ) );
|
|
1630
1647
|
|
|
1631
1648
|
}
|
|
1632
1649
|
|
|
@@ -1652,15 +1669,15 @@
|
|
|
1652
1669
|
|
|
1653
1670
|
function handleMouseWheel( event ) {
|
|
1654
1671
|
|
|
1655
|
-
|
|
1672
|
+
updateZoomParameters( event.clientX, event.clientY );
|
|
1656
1673
|
|
|
1657
1674
|
if ( event.deltaY < 0 ) {
|
|
1658
1675
|
|
|
1659
|
-
dollyIn( getZoomScale() );
|
|
1676
|
+
dollyIn( getZoomScale( event.deltaY ) );
|
|
1660
1677
|
|
|
1661
1678
|
} else if ( event.deltaY > 0 ) {
|
|
1662
1679
|
|
|
1663
|
-
dollyOut( getZoomScale() );
|
|
1680
|
+
dollyOut( getZoomScale( event.deltaY ) );
|
|
1664
1681
|
|
|
1665
1682
|
}
|
|
1666
1683
|
|
|
@@ -1748,16 +1765,18 @@
|
|
|
1748
1765
|
|
|
1749
1766
|
}
|
|
1750
1767
|
|
|
1751
|
-
function handleTouchStartRotate() {
|
|
1768
|
+
function handleTouchStartRotate( event ) {
|
|
1752
1769
|
|
|
1753
1770
|
if ( pointers.length === 1 ) {
|
|
1754
1771
|
|
|
1755
|
-
rotateStart.set(
|
|
1772
|
+
rotateStart.set( event.pageX, event.pageY );
|
|
1756
1773
|
|
|
1757
1774
|
} else {
|
|
1758
1775
|
|
|
1759
|
-
const
|
|
1760
|
-
|
|
1776
|
+
const position = getSecondPointerPosition( event );
|
|
1777
|
+
|
|
1778
|
+
const x = 0.5 * ( event.pageX + position.x );
|
|
1779
|
+
const y = 0.5 * ( event.pageY + position.y );
|
|
1761
1780
|
|
|
1762
1781
|
rotateStart.set( x, y );
|
|
1763
1782
|
|
|
@@ -1765,16 +1784,18 @@
|
|
|
1765
1784
|
|
|
1766
1785
|
}
|
|
1767
1786
|
|
|
1768
|
-
function handleTouchStartPan() {
|
|
1787
|
+
function handleTouchStartPan( event ) {
|
|
1769
1788
|
|
|
1770
1789
|
if ( pointers.length === 1 ) {
|
|
1771
1790
|
|
|
1772
|
-
panStart.set(
|
|
1791
|
+
panStart.set( event.pageX, event.pageY );
|
|
1773
1792
|
|
|
1774
1793
|
} else {
|
|
1775
1794
|
|
|
1776
|
-
const
|
|
1777
|
-
|
|
1795
|
+
const position = getSecondPointerPosition( event );
|
|
1796
|
+
|
|
1797
|
+
const x = 0.5 * ( event.pageX + position.x );
|
|
1798
|
+
const y = 0.5 * ( event.pageY + position.y );
|
|
1778
1799
|
|
|
1779
1800
|
panStart.set( x, y );
|
|
1780
1801
|
|
|
@@ -1782,10 +1803,12 @@
|
|
|
1782
1803
|
|
|
1783
1804
|
}
|
|
1784
1805
|
|
|
1785
|
-
function handleTouchStartDolly() {
|
|
1806
|
+
function handleTouchStartDolly( event ) {
|
|
1807
|
+
|
|
1808
|
+
const position = getSecondPointerPosition( event );
|
|
1786
1809
|
|
|
1787
|
-
const dx =
|
|
1788
|
-
const dy =
|
|
1810
|
+
const dx = event.pageX - position.x;
|
|
1811
|
+
const dy = event.pageY - position.y;
|
|
1789
1812
|
|
|
1790
1813
|
const distance = Math.sqrt( dx * dx + dy * dy );
|
|
1791
1814
|
|
|
@@ -1793,19 +1816,19 @@
|
|
|
1793
1816
|
|
|
1794
1817
|
}
|
|
1795
1818
|
|
|
1796
|
-
function handleTouchStartDollyPan() {
|
|
1819
|
+
function handleTouchStartDollyPan( event ) {
|
|
1797
1820
|
|
|
1798
|
-
if ( scope.enableZoom ) handleTouchStartDolly();
|
|
1821
|
+
if ( scope.enableZoom ) handleTouchStartDolly( event );
|
|
1799
1822
|
|
|
1800
|
-
if ( scope.enablePan ) handleTouchStartPan();
|
|
1823
|
+
if ( scope.enablePan ) handleTouchStartPan( event );
|
|
1801
1824
|
|
|
1802
1825
|
}
|
|
1803
1826
|
|
|
1804
|
-
function handleTouchStartDollyRotate() {
|
|
1827
|
+
function handleTouchStartDollyRotate( event ) {
|
|
1805
1828
|
|
|
1806
|
-
if ( scope.enableZoom ) handleTouchStartDolly();
|
|
1829
|
+
if ( scope.enableZoom ) handleTouchStartDolly( event );
|
|
1807
1830
|
|
|
1808
|
-
if ( scope.enableRotate ) handleTouchStartRotate();
|
|
1831
|
+
if ( scope.enableRotate ) handleTouchStartRotate( event );
|
|
1809
1832
|
|
|
1810
1833
|
}
|
|
1811
1834
|
|
|
@@ -1880,6 +1903,11 @@
|
|
|
1880
1903
|
|
|
1881
1904
|
dollyStart.copy( dollyEnd );
|
|
1882
1905
|
|
|
1906
|
+
const centerX = ( event.pageX + position.x ) * 0.5;
|
|
1907
|
+
const centerY = ( event.pageY + position.y ) * 0.5;
|
|
1908
|
+
|
|
1909
|
+
updateZoomParameters( centerX, centerY );
|
|
1910
|
+
|
|
1883
1911
|
}
|
|
1884
1912
|
|
|
1885
1913
|
function handleTouchMoveDollyPan( event ) {
|
|
@@ -1951,18 +1979,32 @@
|
|
|
1951
1979
|
|
|
1952
1980
|
removePointer( event );
|
|
1953
1981
|
|
|
1954
|
-
|
|
1982
|
+
switch ( pointers.length ) {
|
|
1955
1983
|
|
|
1956
|
-
|
|
1984
|
+
case 0:
|
|
1957
1985
|
|
|
1958
|
-
|
|
1959
|
-
scope.domElement.removeEventListener( 'pointerup', onPointerUp );
|
|
1986
|
+
scope.domElement.releasePointerCapture( event.pointerId );
|
|
1960
1987
|
|
|
1961
|
-
|
|
1988
|
+
scope.domElement.removeEventListener( 'pointermove', onPointerMove );
|
|
1989
|
+
scope.domElement.removeEventListener( 'pointerup', onPointerUp );
|
|
1962
1990
|
|
|
1963
|
-
|
|
1991
|
+
scope.dispatchEvent( _endEvent );
|
|
1964
1992
|
|
|
1965
|
-
|
|
1993
|
+
state = STATE.NONE;
|
|
1994
|
+
|
|
1995
|
+
break;
|
|
1996
|
+
|
|
1997
|
+
case 1:
|
|
1998
|
+
|
|
1999
|
+
const pointerId = pointers[ 0 ];
|
|
2000
|
+
const position = pointerPositions[ pointerId ];
|
|
2001
|
+
|
|
2002
|
+
// minimal placeholder event - allows state correction on pointer-up
|
|
2003
|
+
onTouchStart( { pointerId: pointerId, pageX: position.x, pageY: position.y } );
|
|
2004
|
+
|
|
2005
|
+
break;
|
|
2006
|
+
|
|
2007
|
+
}
|
|
1966
2008
|
|
|
1967
2009
|
}
|
|
1968
2010
|
|
|
@@ -2103,12 +2145,76 @@
|
|
|
2103
2145
|
|
|
2104
2146
|
scope.dispatchEvent( _startEvent );
|
|
2105
2147
|
|
|
2106
|
-
handleMouseWheel( event );
|
|
2148
|
+
handleMouseWheel( customWheelEvent( event ) );
|
|
2107
2149
|
|
|
2108
2150
|
scope.dispatchEvent( _endEvent );
|
|
2109
2151
|
|
|
2110
2152
|
}
|
|
2111
2153
|
|
|
2154
|
+
function customWheelEvent( event ) {
|
|
2155
|
+
|
|
2156
|
+
const mode = event.deltaMode;
|
|
2157
|
+
|
|
2158
|
+
// minimal wheel event altered to meet delta-zoom demand
|
|
2159
|
+
const newEvent = {
|
|
2160
|
+
clientX: event.clientX,
|
|
2161
|
+
clientY: event.clientY,
|
|
2162
|
+
deltaY: event.deltaY,
|
|
2163
|
+
};
|
|
2164
|
+
|
|
2165
|
+
switch ( mode ) {
|
|
2166
|
+
|
|
2167
|
+
case 1: // LINE_MODE
|
|
2168
|
+
newEvent.deltaY *= 16;
|
|
2169
|
+
break;
|
|
2170
|
+
|
|
2171
|
+
case 2: // PAGE_MODE
|
|
2172
|
+
newEvent.deltaY *= 100;
|
|
2173
|
+
break;
|
|
2174
|
+
|
|
2175
|
+
}
|
|
2176
|
+
|
|
2177
|
+
// detect if event was triggered by pinching
|
|
2178
|
+
if ( event.ctrlKey && ! controlActive ) {
|
|
2179
|
+
|
|
2180
|
+
newEvent.deltaY *= 10;
|
|
2181
|
+
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
return newEvent;
|
|
2185
|
+
|
|
2186
|
+
}
|
|
2187
|
+
|
|
2188
|
+
function interceptControlDown( event ) {
|
|
2189
|
+
|
|
2190
|
+
if ( event.key === 'Control' ) {
|
|
2191
|
+
|
|
2192
|
+
controlActive = true;
|
|
2193
|
+
|
|
2194
|
+
|
|
2195
|
+
const document = scope.domElement.getRootNode(); // offscreen canvas compatibility
|
|
2196
|
+
|
|
2197
|
+
document.addEventListener( 'keyup', interceptControlUp, { passive: true, capture: true } );
|
|
2198
|
+
|
|
2199
|
+
}
|
|
2200
|
+
|
|
2201
|
+
}
|
|
2202
|
+
|
|
2203
|
+
function interceptControlUp( event ) {
|
|
2204
|
+
|
|
2205
|
+
if ( event.key === 'Control' ) {
|
|
2206
|
+
|
|
2207
|
+
controlActive = false;
|
|
2208
|
+
|
|
2209
|
+
|
|
2210
|
+
const document = scope.domElement.getRootNode(); // offscreen canvas compatibility
|
|
2211
|
+
|
|
2212
|
+
document.removeEventListener( 'keyup', interceptControlUp, { passive: true, capture: true } );
|
|
2213
|
+
|
|
2214
|
+
}
|
|
2215
|
+
|
|
2216
|
+
}
|
|
2217
|
+
|
|
2112
2218
|
function onKeyDown( event ) {
|
|
2113
2219
|
|
|
2114
2220
|
if ( scope.enabled === false || scope.enablePan === false ) return;
|
|
@@ -2131,7 +2237,7 @@
|
|
|
2131
2237
|
|
|
2132
2238
|
if ( scope.enableRotate === false ) return;
|
|
2133
2239
|
|
|
2134
|
-
handleTouchStartRotate();
|
|
2240
|
+
handleTouchStartRotate( event );
|
|
2135
2241
|
|
|
2136
2242
|
state = STATE.TOUCH_ROTATE;
|
|
2137
2243
|
|
|
@@ -2141,7 +2247,7 @@
|
|
|
2141
2247
|
|
|
2142
2248
|
if ( scope.enablePan === false ) return;
|
|
2143
2249
|
|
|
2144
|
-
handleTouchStartPan();
|
|
2250
|
+
handleTouchStartPan( event );
|
|
2145
2251
|
|
|
2146
2252
|
state = STATE.TOUCH_PAN;
|
|
2147
2253
|
|
|
@@ -2163,7 +2269,7 @@
|
|
|
2163
2269
|
|
|
2164
2270
|
if ( scope.enableZoom === false && scope.enablePan === false ) return;
|
|
2165
2271
|
|
|
2166
|
-
handleTouchStartDollyPan();
|
|
2272
|
+
handleTouchStartDollyPan( event );
|
|
2167
2273
|
|
|
2168
2274
|
state = STATE.TOUCH_DOLLY_PAN;
|
|
2169
2275
|
|
|
@@ -2173,7 +2279,7 @@
|
|
|
2173
2279
|
|
|
2174
2280
|
if ( scope.enableZoom === false && scope.enableRotate === false ) return;
|
|
2175
2281
|
|
|
2176
|
-
handleTouchStartDollyRotate();
|
|
2282
|
+
handleTouchStartDollyRotate( event );
|
|
2177
2283
|
|
|
2178
2284
|
state = STATE.TOUCH_DOLLY_ROTATE;
|
|
2179
2285
|
|
|
@@ -2265,7 +2371,7 @@
|
|
|
2265
2371
|
|
|
2266
2372
|
function addPointer( event ) {
|
|
2267
2373
|
|
|
2268
|
-
pointers.push( event );
|
|
2374
|
+
pointers.push( event.pointerId );
|
|
2269
2375
|
|
|
2270
2376
|
}
|
|
2271
2377
|
|
|
@@ -2275,7 +2381,7 @@
|
|
|
2275
2381
|
|
|
2276
2382
|
for ( let i = 0; i < pointers.length; i ++ ) {
|
|
2277
2383
|
|
|
2278
|
-
if ( pointers[ i ]
|
|
2384
|
+
if ( pointers[ i ] == event.pointerId ) {
|
|
2279
2385
|
|
|
2280
2386
|
pointers.splice( i, 1 );
|
|
2281
2387
|
return;
|
|
@@ -2303,9 +2409,9 @@
|
|
|
2303
2409
|
|
|
2304
2410
|
function getSecondPointerPosition( event ) {
|
|
2305
2411
|
|
|
2306
|
-
const
|
|
2412
|
+
const pointerId = ( event.pointerId === pointers[ 0 ] ) ? pointers[ 1 ] : pointers[ 0 ];
|
|
2307
2413
|
|
|
2308
|
-
return pointerPositions[
|
|
2414
|
+
return pointerPositions[ pointerId ];
|
|
2309
2415
|
|
|
2310
2416
|
}
|
|
2311
2417
|
|
|
@@ -2317,6 +2423,10 @@
|
|
|
2317
2423
|
scope.domElement.addEventListener( 'pointercancel', onPointerUp );
|
|
2318
2424
|
scope.domElement.addEventListener( 'wheel', onMouseWheel, { passive: false } );
|
|
2319
2425
|
|
|
2426
|
+
const document = scope.domElement.getRootNode(); // offscreen canvas compatibility
|
|
2427
|
+
|
|
2428
|
+
document.addEventListener( 'keydown', interceptControlDown, { passive: true, capture: true } );
|
|
2429
|
+
|
|
2320
2430
|
// force an update at start
|
|
2321
2431
|
|
|
2322
2432
|
this.update();
|
|
@@ -2507,6 +2617,29 @@
|
|
|
2507
2617
|
|
|
2508
2618
|
};
|
|
2509
2619
|
|
|
2620
|
+
this.pointercancel = function () {
|
|
2621
|
+
|
|
2622
|
+
if ( this.enabled === false ) return;
|
|
2623
|
+
|
|
2624
|
+
if ( this.dragToLook ) {
|
|
2625
|
+
|
|
2626
|
+
this.status = 0;
|
|
2627
|
+
|
|
2628
|
+
this.moveState.yawLeft = this.moveState.pitchDown = 0;
|
|
2629
|
+
|
|
2630
|
+
} else {
|
|
2631
|
+
|
|
2632
|
+
this.moveState.forward = 0;
|
|
2633
|
+
this.moveState.back = 0;
|
|
2634
|
+
|
|
2635
|
+
this.updateMovementVector();
|
|
2636
|
+
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
this.updateRotationVector();
|
|
2640
|
+
|
|
2641
|
+
};
|
|
2642
|
+
|
|
2510
2643
|
this.contextMenu = function ( event ) {
|
|
2511
2644
|
|
|
2512
2645
|
if ( this.enabled === false ) return;
|
|
@@ -2590,6 +2723,7 @@
|
|
|
2590
2723
|
this.domElement.removeEventListener( 'pointerdown', _pointerdown );
|
|
2591
2724
|
this.domElement.removeEventListener( 'pointermove', _pointermove );
|
|
2592
2725
|
this.domElement.removeEventListener( 'pointerup', _pointerup );
|
|
2726
|
+
this.domElement.removeEventListener( 'pointercancel', _pointercancel );
|
|
2593
2727
|
|
|
2594
2728
|
window.removeEventListener( 'keydown', _keydown );
|
|
2595
2729
|
window.removeEventListener( 'keyup', _keyup );
|
|
@@ -2600,6 +2734,7 @@
|
|
|
2600
2734
|
const _pointermove = this.pointermove.bind( this );
|
|
2601
2735
|
const _pointerdown = this.pointerdown.bind( this );
|
|
2602
2736
|
const _pointerup = this.pointerup.bind( this );
|
|
2737
|
+
const _pointercancel = this.pointercancel.bind( this );
|
|
2603
2738
|
const _keydown = this.keydown.bind( this );
|
|
2604
2739
|
const _keyup = this.keyup.bind( this );
|
|
2605
2740
|
|
|
@@ -2607,6 +2742,7 @@
|
|
|
2607
2742
|
this.domElement.addEventListener( 'pointerdown', _pointerdown );
|
|
2608
2743
|
this.domElement.addEventListener( 'pointermove', _pointermove );
|
|
2609
2744
|
this.domElement.addEventListener( 'pointerup', _pointerup );
|
|
2745
|
+
this.domElement.addEventListener( 'pointercancel', _pointercancel );
|
|
2610
2746
|
|
|
2611
2747
|
window.addEventListener( 'keydown', _keydown );
|
|
2612
2748
|
window.addEventListener( 'keyup', _keyup );
|
|
@@ -2700,9 +2836,20 @@
|
|
|
2700
2836
|
|
|
2701
2837
|
// https://github.com/mrdoob/three.js/pull/21358
|
|
2702
2838
|
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2839
|
+
class FullscreenTriangleGeometry extends three$1.BufferGeometry {
|
|
2840
|
+
|
|
2841
|
+
constructor() {
|
|
2842
|
+
|
|
2843
|
+
super();
|
|
2844
|
+
|
|
2845
|
+
this.setAttribute( 'position', new three$1.Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );
|
|
2846
|
+
this.setAttribute( 'uv', new three$1.Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );
|
|
2847
|
+
|
|
2848
|
+
}
|
|
2849
|
+
|
|
2850
|
+
}
|
|
2851
|
+
|
|
2852
|
+
const _geometry = new FullscreenTriangleGeometry();
|
|
2706
2853
|
|
|
2707
2854
|
class FullScreenQuad {
|
|
2708
2855
|
|
|
@@ -3272,31 +3419,20 @@
|
|
|
3272
3419
|
}
|
|
3273
3420
|
|
|
3274
3421
|
function _isNativeReflectConstruct() {
|
|
3275
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
3276
|
-
if (Reflect.construct.sham) return false;
|
|
3277
|
-
if (typeof Proxy === "function") return true;
|
|
3278
3422
|
try {
|
|
3279
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
return
|
|
3283
|
-
}
|
|
3423
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
3424
|
+
} catch (t) {}
|
|
3425
|
+
return (_isNativeReflectConstruct = function _isNativeReflectConstruct() {
|
|
3426
|
+
return !!t;
|
|
3427
|
+
})();
|
|
3284
3428
|
}
|
|
3285
3429
|
|
|
3286
|
-
function _construct(
|
|
3287
|
-
if (_isNativeReflectConstruct())
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
a.push.apply(a, args);
|
|
3293
|
-
var Constructor = Function.bind.apply(Parent, a);
|
|
3294
|
-
var instance = new Constructor();
|
|
3295
|
-
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
3296
|
-
return instance;
|
|
3297
|
-
};
|
|
3298
|
-
}
|
|
3299
|
-
return _construct.apply(null, arguments);
|
|
3430
|
+
function _construct(t, e, r) {
|
|
3431
|
+
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
|
3432
|
+
var o = [null];
|
|
3433
|
+
o.push.apply(o, e);
|
|
3434
|
+
var p = new (t.bind.apply(t, o))();
|
|
3435
|
+
return r && _setPrototypeOf(p, r.prototype), p;
|
|
3300
3436
|
}
|
|
3301
3437
|
|
|
3302
3438
|
function _wrapNativeSuper(Class) {
|
|
@@ -3327,7 +3463,6 @@
|
|
|
3327
3463
|
}
|
|
3328
3464
|
|
|
3329
3465
|
// based on https://github.com/styled-components/styled-components/blob/fcf6f3804c57a14dd7984dfab7bc06ee2edca044/src/utils/error.js
|
|
3330
|
-
|
|
3331
3466
|
/**
|
|
3332
3467
|
* Parse errors.md and turn it into a simple hash of code: message
|
|
3333
3468
|
* @private
|
|
@@ -3412,84 +3547,71 @@
|
|
|
3412
3547
|
"77": "remToPx expects a value in \"rem\" but you provided it in \"%s\".\n\n",
|
|
3413
3548
|
"78": "base must be set in \"px\" or \"%\" but you set it in \"%s\".\n"
|
|
3414
3549
|
};
|
|
3550
|
+
|
|
3415
3551
|
/**
|
|
3416
3552
|
* super basic version of sprintf
|
|
3417
3553
|
* @private
|
|
3418
3554
|
*/
|
|
3419
|
-
|
|
3420
3555
|
function format() {
|
|
3421
3556
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3422
3557
|
args[_key] = arguments[_key];
|
|
3423
3558
|
}
|
|
3424
|
-
|
|
3425
3559
|
var a = args[0];
|
|
3426
3560
|
var b = [];
|
|
3427
3561
|
var c;
|
|
3428
|
-
|
|
3429
3562
|
for (c = 1; c < args.length; c += 1) {
|
|
3430
3563
|
b.push(args[c]);
|
|
3431
3564
|
}
|
|
3432
|
-
|
|
3433
3565
|
b.forEach(function (d) {
|
|
3434
3566
|
a = a.replace(/%[a-z]/, d);
|
|
3435
3567
|
});
|
|
3436
3568
|
return a;
|
|
3437
3569
|
}
|
|
3570
|
+
|
|
3438
3571
|
/**
|
|
3439
3572
|
* Create an error file out of errors.md for development and a simple web link to the full errors
|
|
3440
3573
|
* in production mode.
|
|
3441
3574
|
* @private
|
|
3442
3575
|
*/
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
3576
|
var PolishedError = /*#__PURE__*/function (_Error) {
|
|
3446
3577
|
_inheritsLoose(PolishedError, _Error);
|
|
3447
|
-
|
|
3448
3578
|
function PolishedError(code) {
|
|
3449
3579
|
var _this;
|
|
3450
|
-
|
|
3451
3580
|
if (process.env.NODE_ENV === 'production') {
|
|
3452
3581
|
_this = _Error.call(this, "An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#" + code + " for more information.") || this;
|
|
3453
3582
|
} else {
|
|
3454
3583
|
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
3455
3584
|
args[_key2 - 1] = arguments[_key2];
|
|
3456
3585
|
}
|
|
3457
|
-
|
|
3458
3586
|
_this = _Error.call(this, format.apply(void 0, [ERRORS[code]].concat(args))) || this;
|
|
3459
3587
|
}
|
|
3460
|
-
|
|
3461
3588
|
return _assertThisInitialized(_this);
|
|
3462
3589
|
}
|
|
3463
|
-
|
|
3464
3590
|
return PolishedError;
|
|
3465
3591
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
3466
3592
|
|
|
3467
3593
|
function colorToInt(color) {
|
|
3468
3594
|
return Math.round(color * 255);
|
|
3469
3595
|
}
|
|
3470
|
-
|
|
3471
3596
|
function convertToInt(red, green, blue) {
|
|
3472
3597
|
return colorToInt(red) + "," + colorToInt(green) + "," + colorToInt(blue);
|
|
3473
3598
|
}
|
|
3474
|
-
|
|
3475
3599
|
function hslToRgb(hue, saturation, lightness, convert) {
|
|
3476
3600
|
if (convert === void 0) {
|
|
3477
3601
|
convert = convertToInt;
|
|
3478
3602
|
}
|
|
3479
|
-
|
|
3480
3603
|
if (saturation === 0) {
|
|
3481
3604
|
// achromatic
|
|
3482
3605
|
return convert(lightness, lightness, lightness);
|
|
3483
|
-
}
|
|
3484
|
-
|
|
3606
|
+
}
|
|
3485
3607
|
|
|
3608
|
+
// formulae from https://en.wikipedia.org/wiki/HSL_and_HSV
|
|
3486
3609
|
var huePrime = (hue % 360 + 360) % 360 / 60;
|
|
3487
3610
|
var chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
|
|
3488
3611
|
var secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
|
|
3489
3612
|
var red = 0;
|
|
3490
3613
|
var green = 0;
|
|
3491
3614
|
var blue = 0;
|
|
3492
|
-
|
|
3493
3615
|
if (huePrime >= 0 && huePrime < 1) {
|
|
3494
3616
|
red = chroma;
|
|
3495
3617
|
green = secondComponent;
|
|
@@ -3509,7 +3631,6 @@
|
|
|
3509
3631
|
red = chroma;
|
|
3510
3632
|
blue = secondComponent;
|
|
3511
3633
|
}
|
|
3512
|
-
|
|
3513
3634
|
var lightnessModification = lightness - chroma / 2;
|
|
3514
3635
|
var finalRed = red + lightnessModification;
|
|
3515
3636
|
var finalGreen = green + lightnessModification;
|
|
@@ -3667,11 +3788,11 @@
|
|
|
3667
3788
|
yellow: 'ff0',
|
|
3668
3789
|
yellowgreen: '9acd32'
|
|
3669
3790
|
};
|
|
3791
|
+
|
|
3670
3792
|
/**
|
|
3671
3793
|
* Checks if a string is a CSS named color and returns its equivalent hex value, otherwise returns the original color.
|
|
3672
3794
|
* @private
|
|
3673
3795
|
*/
|
|
3674
|
-
|
|
3675
3796
|
function nameToHex(color) {
|
|
3676
3797
|
if (typeof color !== 'string') return color;
|
|
3677
3798
|
var normalizedColorName = color.toLowerCase();
|
|
@@ -3686,6 +3807,7 @@
|
|
|
3686
3807
|
var rgbaRegex = /^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
|
|
3687
3808
|
var hslRegex = /^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i;
|
|
3688
3809
|
var hslaRegex = /^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
|
|
3810
|
+
|
|
3689
3811
|
/**
|
|
3690
3812
|
* Returns an RgbColor or RgbaColor object. This utility function is only useful
|
|
3691
3813
|
* if want to extract a color component. With the color util `toColorString` you
|
|
@@ -3697,14 +3819,11 @@
|
|
|
3697
3819
|
* // Assigns `{ red: 92, green: 102, blue: 112, alpha: 0.75 }` to color2
|
|
3698
3820
|
* const color2 = parseToRgb('hsla(210, 10%, 40%, 0.75)');
|
|
3699
3821
|
*/
|
|
3700
|
-
|
|
3701
3822
|
function parseToRgb(color) {
|
|
3702
3823
|
if (typeof color !== 'string') {
|
|
3703
3824
|
throw new PolishedError(3);
|
|
3704
3825
|
}
|
|
3705
|
-
|
|
3706
3826
|
var normalizedColor = nameToHex(color);
|
|
3707
|
-
|
|
3708
3827
|
if (normalizedColor.match(hexRegex)) {
|
|
3709
3828
|
return {
|
|
3710
3829
|
red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
|
|
@@ -3712,7 +3831,6 @@
|
|
|
3712
3831
|
blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16)
|
|
3713
3832
|
};
|
|
3714
3833
|
}
|
|
3715
|
-
|
|
3716
3834
|
if (normalizedColor.match(hexRgbaRegex)) {
|
|
3717
3835
|
var alpha = parseFloat((parseInt("" + normalizedColor[7] + normalizedColor[8], 16) / 255).toFixed(2));
|
|
3718
3836
|
return {
|
|
@@ -3722,7 +3840,6 @@
|
|
|
3722
3840
|
alpha: alpha
|
|
3723
3841
|
};
|
|
3724
3842
|
}
|
|
3725
|
-
|
|
3726
3843
|
if (normalizedColor.match(reducedHexRegex)) {
|
|
3727
3844
|
return {
|
|
3728
3845
|
red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
|
|
@@ -3730,10 +3847,8 @@
|
|
|
3730
3847
|
blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16)
|
|
3731
3848
|
};
|
|
3732
3849
|
}
|
|
3733
|
-
|
|
3734
3850
|
if (normalizedColor.match(reducedRgbaHexRegex)) {
|
|
3735
3851
|
var _alpha = parseFloat((parseInt("" + normalizedColor[4] + normalizedColor[4], 16) / 255).toFixed(2));
|
|
3736
|
-
|
|
3737
3852
|
return {
|
|
3738
3853
|
red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
|
|
3739
3854
|
green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
|
|
@@ -3741,9 +3856,7 @@
|
|
|
3741
3856
|
alpha: _alpha
|
|
3742
3857
|
};
|
|
3743
3858
|
}
|
|
3744
|
-
|
|
3745
3859
|
var rgbMatched = rgbRegex.exec(normalizedColor);
|
|
3746
|
-
|
|
3747
3860
|
if (rgbMatched) {
|
|
3748
3861
|
return {
|
|
3749
3862
|
red: parseInt("" + rgbMatched[1], 10),
|
|
@@ -3751,9 +3864,7 @@
|
|
|
3751
3864
|
blue: parseInt("" + rgbMatched[3], 10)
|
|
3752
3865
|
};
|
|
3753
3866
|
}
|
|
3754
|
-
|
|
3755
3867
|
var rgbaMatched = rgbaRegex.exec(normalizedColor.substring(0, 50));
|
|
3756
|
-
|
|
3757
3868
|
if (rgbaMatched) {
|
|
3758
3869
|
return {
|
|
3759
3870
|
red: parseInt("" + rgbaMatched[1], 10),
|
|
@@ -3762,44 +3873,32 @@
|
|
|
3762
3873
|
alpha: parseFloat("" + rgbaMatched[4]) > 1 ? parseFloat("" + rgbaMatched[4]) / 100 : parseFloat("" + rgbaMatched[4])
|
|
3763
3874
|
};
|
|
3764
3875
|
}
|
|
3765
|
-
|
|
3766
3876
|
var hslMatched = hslRegex.exec(normalizedColor);
|
|
3767
|
-
|
|
3768
3877
|
if (hslMatched) {
|
|
3769
3878
|
var hue = parseInt("" + hslMatched[1], 10);
|
|
3770
3879
|
var saturation = parseInt("" + hslMatched[2], 10) / 100;
|
|
3771
3880
|
var lightness = parseInt("" + hslMatched[3], 10) / 100;
|
|
3772
3881
|
var rgbColorString = "rgb(" + hslToRgb(hue, saturation, lightness) + ")";
|
|
3773
3882
|
var hslRgbMatched = rgbRegex.exec(rgbColorString);
|
|
3774
|
-
|
|
3775
3883
|
if (!hslRgbMatched) {
|
|
3776
3884
|
throw new PolishedError(4, normalizedColor, rgbColorString);
|
|
3777
3885
|
}
|
|
3778
|
-
|
|
3779
3886
|
return {
|
|
3780
3887
|
red: parseInt("" + hslRgbMatched[1], 10),
|
|
3781
3888
|
green: parseInt("" + hslRgbMatched[2], 10),
|
|
3782
3889
|
blue: parseInt("" + hslRgbMatched[3], 10)
|
|
3783
3890
|
};
|
|
3784
3891
|
}
|
|
3785
|
-
|
|
3786
3892
|
var hslaMatched = hslaRegex.exec(normalizedColor.substring(0, 50));
|
|
3787
|
-
|
|
3788
3893
|
if (hslaMatched) {
|
|
3789
3894
|
var _hue = parseInt("" + hslaMatched[1], 10);
|
|
3790
|
-
|
|
3791
3895
|
var _saturation = parseInt("" + hslaMatched[2], 10) / 100;
|
|
3792
|
-
|
|
3793
3896
|
var _lightness = parseInt("" + hslaMatched[3], 10) / 100;
|
|
3794
|
-
|
|
3795
3897
|
var _rgbColorString = "rgb(" + hslToRgb(_hue, _saturation, _lightness) + ")";
|
|
3796
|
-
|
|
3797
3898
|
var _hslRgbMatched = rgbRegex.exec(_rgbColorString);
|
|
3798
|
-
|
|
3799
3899
|
if (!_hslRgbMatched) {
|
|
3800
3900
|
throw new PolishedError(4, normalizedColor, _rgbColorString);
|
|
3801
3901
|
}
|
|
3802
|
-
|
|
3803
3902
|
return {
|
|
3804
3903
|
red: parseInt("" + _hslRgbMatched[1], 10),
|
|
3805
3904
|
green: parseInt("" + _hslRgbMatched[2], 10),
|
|
@@ -3807,10 +3906,82 @@
|
|
|
3807
3906
|
alpha: parseFloat("" + hslaMatched[4]) > 1 ? parseFloat("" + hslaMatched[4]) / 100 : parseFloat("" + hslaMatched[4])
|
|
3808
3907
|
};
|
|
3809
3908
|
}
|
|
3810
|
-
|
|
3811
3909
|
throw new PolishedError(5);
|
|
3812
3910
|
}
|
|
3813
3911
|
|
|
3912
|
+
function rgbToHsl(color) {
|
|
3913
|
+
// make sure rgb are contained in a set of [0, 255]
|
|
3914
|
+
var red = color.red / 255;
|
|
3915
|
+
var green = color.green / 255;
|
|
3916
|
+
var blue = color.blue / 255;
|
|
3917
|
+
var max = Math.max(red, green, blue);
|
|
3918
|
+
var min = Math.min(red, green, blue);
|
|
3919
|
+
var lightness = (max + min) / 2;
|
|
3920
|
+
if (max === min) {
|
|
3921
|
+
// achromatic
|
|
3922
|
+
if (color.alpha !== undefined) {
|
|
3923
|
+
return {
|
|
3924
|
+
hue: 0,
|
|
3925
|
+
saturation: 0,
|
|
3926
|
+
lightness: lightness,
|
|
3927
|
+
alpha: color.alpha
|
|
3928
|
+
};
|
|
3929
|
+
} else {
|
|
3930
|
+
return {
|
|
3931
|
+
hue: 0,
|
|
3932
|
+
saturation: 0,
|
|
3933
|
+
lightness: lightness
|
|
3934
|
+
};
|
|
3935
|
+
}
|
|
3936
|
+
}
|
|
3937
|
+
var hue;
|
|
3938
|
+
var delta = max - min;
|
|
3939
|
+
var saturation = lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min);
|
|
3940
|
+
switch (max) {
|
|
3941
|
+
case red:
|
|
3942
|
+
hue = (green - blue) / delta + (green < blue ? 6 : 0);
|
|
3943
|
+
break;
|
|
3944
|
+
case green:
|
|
3945
|
+
hue = (blue - red) / delta + 2;
|
|
3946
|
+
break;
|
|
3947
|
+
default:
|
|
3948
|
+
// blue case
|
|
3949
|
+
hue = (red - green) / delta + 4;
|
|
3950
|
+
break;
|
|
3951
|
+
}
|
|
3952
|
+
hue *= 60;
|
|
3953
|
+
if (color.alpha !== undefined) {
|
|
3954
|
+
return {
|
|
3955
|
+
hue: hue,
|
|
3956
|
+
saturation: saturation,
|
|
3957
|
+
lightness: lightness,
|
|
3958
|
+
alpha: color.alpha
|
|
3959
|
+
};
|
|
3960
|
+
}
|
|
3961
|
+
return {
|
|
3962
|
+
hue: hue,
|
|
3963
|
+
saturation: saturation,
|
|
3964
|
+
lightness: lightness
|
|
3965
|
+
};
|
|
3966
|
+
}
|
|
3967
|
+
|
|
3968
|
+
/**
|
|
3969
|
+
* Returns an HslColor or HslaColor object. This utility function is only useful
|
|
3970
|
+
* if want to extract a color component. With the color util `toColorString` you
|
|
3971
|
+
* can convert a HslColor or HslaColor object back to a string.
|
|
3972
|
+
*
|
|
3973
|
+
* @example
|
|
3974
|
+
* // Assigns `{ hue: 0, saturation: 1, lightness: 0.5 }` to color1
|
|
3975
|
+
* const color1 = parseToHsl('rgb(255, 0, 0)');
|
|
3976
|
+
* // Assigns `{ hue: 128, saturation: 1, lightness: 0.5, alpha: 0.75 }` to color2
|
|
3977
|
+
* const color2 = parseToHsl('hsla(128, 100%, 50%, 0.75)');
|
|
3978
|
+
*/
|
|
3979
|
+
function parseToHsl(color) {
|
|
3980
|
+
// Note: At a later stage we can optimize this function as right now a hsl
|
|
3981
|
+
// color would be parsed converted to rgb values and converted back to hsl.
|
|
3982
|
+
return rgbToHsl(parseToRgb(color));
|
|
3983
|
+
}
|
|
3984
|
+
|
|
3814
3985
|
/**
|
|
3815
3986
|
* Reduces hex values if possible e.g. #ff8866 to #f86
|
|
3816
3987
|
* @private
|
|
@@ -3819,10 +3990,8 @@
|
|
|
3819
3990
|
if (value.length === 7 && value[1] === value[2] && value[3] === value[4] && value[5] === value[6]) {
|
|
3820
3991
|
return "#" + value[1] + value[3] + value[5];
|
|
3821
3992
|
}
|
|
3822
|
-
|
|
3823
3993
|
return value;
|
|
3824
3994
|
};
|
|
3825
|
-
|
|
3826
3995
|
var reduceHexValue$1 = reduceHexValue;
|
|
3827
3996
|
|
|
3828
3997
|
function numberToHex(value) {
|
|
@@ -3830,6 +3999,83 @@
|
|
|
3830
3999
|
return hex.length === 1 ? "0" + hex : hex;
|
|
3831
4000
|
}
|
|
3832
4001
|
|
|
4002
|
+
function colorToHex(color) {
|
|
4003
|
+
return numberToHex(Math.round(color * 255));
|
|
4004
|
+
}
|
|
4005
|
+
function convertToHex(red, green, blue) {
|
|
4006
|
+
return reduceHexValue$1("#" + colorToHex(red) + colorToHex(green) + colorToHex(blue));
|
|
4007
|
+
}
|
|
4008
|
+
function hslToHex(hue, saturation, lightness) {
|
|
4009
|
+
return hslToRgb(hue, saturation, lightness, convertToHex);
|
|
4010
|
+
}
|
|
4011
|
+
|
|
4012
|
+
/**
|
|
4013
|
+
* Returns a string value for the color. The returned result is the smallest possible hex notation.
|
|
4014
|
+
*
|
|
4015
|
+
* @example
|
|
4016
|
+
* // Styles as object usage
|
|
4017
|
+
* const styles = {
|
|
4018
|
+
* background: hsl(359, 0.75, 0.4),
|
|
4019
|
+
* background: hsl({ hue: 360, saturation: 0.75, lightness: 0.4 }),
|
|
4020
|
+
* }
|
|
4021
|
+
*
|
|
4022
|
+
* // styled-components usage
|
|
4023
|
+
* const div = styled.div`
|
|
4024
|
+
* background: ${hsl(359, 0.75, 0.4)};
|
|
4025
|
+
* background: ${hsl({ hue: 360, saturation: 0.75, lightness: 0.4 })};
|
|
4026
|
+
* `
|
|
4027
|
+
*
|
|
4028
|
+
* // CSS in JS Output
|
|
4029
|
+
*
|
|
4030
|
+
* element {
|
|
4031
|
+
* background: "#b3191c";
|
|
4032
|
+
* background: "#b3191c";
|
|
4033
|
+
* }
|
|
4034
|
+
*/
|
|
4035
|
+
function hsl(value, saturation, lightness) {
|
|
4036
|
+
if (typeof value === 'number' && typeof saturation === 'number' && typeof lightness === 'number') {
|
|
4037
|
+
return hslToHex(value, saturation, lightness);
|
|
4038
|
+
} else if (typeof value === 'object' && saturation === undefined && lightness === undefined) {
|
|
4039
|
+
return hslToHex(value.hue, value.saturation, value.lightness);
|
|
4040
|
+
}
|
|
4041
|
+
throw new PolishedError(1);
|
|
4042
|
+
}
|
|
4043
|
+
|
|
4044
|
+
/**
|
|
4045
|
+
* Returns a string value for the color. The returned result is the smallest possible rgba or hex notation.
|
|
4046
|
+
*
|
|
4047
|
+
* @example
|
|
4048
|
+
* // Styles as object usage
|
|
4049
|
+
* const styles = {
|
|
4050
|
+
* background: hsla(359, 0.75, 0.4, 0.7),
|
|
4051
|
+
* background: hsla({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0,7 }),
|
|
4052
|
+
* background: hsla(359, 0.75, 0.4, 1),
|
|
4053
|
+
* }
|
|
4054
|
+
*
|
|
4055
|
+
* // styled-components usage
|
|
4056
|
+
* const div = styled.div`
|
|
4057
|
+
* background: ${hsla(359, 0.75, 0.4, 0.7)};
|
|
4058
|
+
* background: ${hsla({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0,7 })};
|
|
4059
|
+
* background: ${hsla(359, 0.75, 0.4, 1)};
|
|
4060
|
+
* `
|
|
4061
|
+
*
|
|
4062
|
+
* // CSS in JS Output
|
|
4063
|
+
*
|
|
4064
|
+
* element {
|
|
4065
|
+
* background: "rgba(179,25,28,0.7)";
|
|
4066
|
+
* background: "rgba(179,25,28,0.7)";
|
|
4067
|
+
* background: "#b3191c";
|
|
4068
|
+
* }
|
|
4069
|
+
*/
|
|
4070
|
+
function hsla(value, saturation, lightness, alpha) {
|
|
4071
|
+
if (typeof value === 'number' && typeof saturation === 'number' && typeof lightness === 'number' && typeof alpha === 'number') {
|
|
4072
|
+
return alpha >= 1 ? hslToHex(value, saturation, lightness) : "rgba(" + hslToRgb(value, saturation, lightness) + "," + alpha + ")";
|
|
4073
|
+
} else if (typeof value === 'object' && saturation === undefined && lightness === undefined && alpha === undefined) {
|
|
4074
|
+
return value.alpha >= 1 ? hslToHex(value.hue, value.saturation, value.lightness) : "rgba(" + hslToRgb(value.hue, value.saturation, value.lightness) + "," + value.alpha + ")";
|
|
4075
|
+
}
|
|
4076
|
+
throw new PolishedError(2);
|
|
4077
|
+
}
|
|
4078
|
+
|
|
3833
4079
|
/**
|
|
3834
4080
|
* Returns a string value for the color. The returned result is the smallest possible hex notation.
|
|
3835
4081
|
*
|
|
@@ -3859,7 +4105,6 @@
|
|
|
3859
4105
|
} else if (typeof value === 'object' && green === undefined && blue === undefined) {
|
|
3860
4106
|
return reduceHexValue$1("#" + numberToHex(value.red) + numberToHex(value.green) + numberToHex(value.blue));
|
|
3861
4107
|
}
|
|
3862
|
-
|
|
3863
4108
|
throw new PolishedError(6);
|
|
3864
4109
|
}
|
|
3865
4110
|
|
|
@@ -3906,13 +4151,65 @@
|
|
|
3906
4151
|
} else if (typeof firstValue === 'object' && secondValue === undefined && thirdValue === undefined && fourthValue === undefined) {
|
|
3907
4152
|
return firstValue.alpha >= 1 ? rgb(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
|
|
3908
4153
|
}
|
|
3909
|
-
|
|
3910
4154
|
throw new PolishedError(7);
|
|
3911
4155
|
}
|
|
3912
4156
|
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
4157
|
+
var isRgb = function isRgb(color) {
|
|
4158
|
+
return typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number' && (typeof color.alpha !== 'number' || typeof color.alpha === 'undefined');
|
|
4159
|
+
};
|
|
4160
|
+
var isRgba = function isRgba(color) {
|
|
4161
|
+
return typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number' && typeof color.alpha === 'number';
|
|
4162
|
+
};
|
|
4163
|
+
var isHsl = function isHsl(color) {
|
|
4164
|
+
return typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number' && (typeof color.alpha !== 'number' || typeof color.alpha === 'undefined');
|
|
4165
|
+
};
|
|
4166
|
+
var isHsla = function isHsla(color) {
|
|
4167
|
+
return typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number' && typeof color.alpha === 'number';
|
|
4168
|
+
};
|
|
4169
|
+
|
|
4170
|
+
/**
|
|
4171
|
+
* Converts a RgbColor, RgbaColor, HslColor or HslaColor object to a color string.
|
|
4172
|
+
* This util is useful in case you only know on runtime which color object is
|
|
4173
|
+
* used. Otherwise we recommend to rely on `rgb`, `rgba`, `hsl` or `hsla`.
|
|
4174
|
+
*
|
|
4175
|
+
* @example
|
|
4176
|
+
* // Styles as object usage
|
|
4177
|
+
* const styles = {
|
|
4178
|
+
* background: toColorString({ red: 255, green: 205, blue: 100 }),
|
|
4179
|
+
* background: toColorString({ red: 255, green: 205, blue: 100, alpha: 0.72 }),
|
|
4180
|
+
* background: toColorString({ hue: 240, saturation: 1, lightness: 0.5 }),
|
|
4181
|
+
* background: toColorString({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0.72 }),
|
|
4182
|
+
* }
|
|
4183
|
+
*
|
|
4184
|
+
* // styled-components usage
|
|
4185
|
+
* const div = styled.div`
|
|
4186
|
+
* background: ${toColorString({ red: 255, green: 205, blue: 100 })};
|
|
4187
|
+
* background: ${toColorString({ red: 255, green: 205, blue: 100, alpha: 0.72 })};
|
|
4188
|
+
* background: ${toColorString({ hue: 240, saturation: 1, lightness: 0.5 })};
|
|
4189
|
+
* background: ${toColorString({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0.72 })};
|
|
4190
|
+
* `
|
|
4191
|
+
*
|
|
4192
|
+
* // CSS in JS Output
|
|
4193
|
+
* element {
|
|
4194
|
+
* background: "#ffcd64";
|
|
4195
|
+
* background: "rgba(255,205,100,0.72)";
|
|
4196
|
+
* background: "#00f";
|
|
4197
|
+
* background: "rgba(179,25,25,0.72)";
|
|
4198
|
+
* }
|
|
4199
|
+
*/
|
|
4200
|
+
|
|
4201
|
+
function toColorString(color) {
|
|
4202
|
+
if (typeof color !== 'object') throw new PolishedError(8);
|
|
4203
|
+
if (isRgba(color)) return rgba(color);
|
|
4204
|
+
if (isRgb(color)) return rgb(color);
|
|
4205
|
+
if (isHsla(color)) return hsla(color);
|
|
4206
|
+
if (isHsl(color)) return hsl(color);
|
|
4207
|
+
throw new PolishedError(8);
|
|
4208
|
+
}
|
|
4209
|
+
|
|
4210
|
+
// Type definitions taken from https://github.com/gcanti/flow-static-land/blob/master/src/Fun.js
|
|
4211
|
+
// eslint-disable-next-line no-unused-vars
|
|
4212
|
+
// eslint-disable-next-line no-unused-vars
|
|
3916
4213
|
// eslint-disable-next-line no-redeclare
|
|
3917
4214
|
function curried(f, length, acc) {
|
|
3918
4215
|
return function fn() {
|
|
@@ -3920,18 +4217,216 @@
|
|
|
3920
4217
|
var combined = acc.concat(Array.prototype.slice.call(arguments));
|
|
3921
4218
|
return combined.length >= length ? f.apply(this, combined) : curried(f, length, combined);
|
|
3922
4219
|
};
|
|
3923
|
-
}
|
|
3924
|
-
|
|
4220
|
+
}
|
|
3925
4221
|
|
|
4222
|
+
// eslint-disable-next-line no-redeclare
|
|
3926
4223
|
function curry(f) {
|
|
3927
4224
|
// eslint-disable-line no-redeclare
|
|
3928
4225
|
return curried(f, f.length, []);
|
|
3929
4226
|
}
|
|
3930
4227
|
|
|
4228
|
+
/**
|
|
4229
|
+
* Changes the hue of the color. Hue is a number between 0 to 360. The first
|
|
4230
|
+
* argument for adjustHue is the amount of degrees the color is rotated around
|
|
4231
|
+
* the color wheel, always producing a positive hue value.
|
|
4232
|
+
*
|
|
4233
|
+
* @example
|
|
4234
|
+
* // Styles as object usage
|
|
4235
|
+
* const styles = {
|
|
4236
|
+
* background: adjustHue(180, '#448'),
|
|
4237
|
+
* background: adjustHue('180', 'rgba(101,100,205,0.7)'),
|
|
4238
|
+
* }
|
|
4239
|
+
*
|
|
4240
|
+
* // styled-components usage
|
|
4241
|
+
* const div = styled.div`
|
|
4242
|
+
* background: ${adjustHue(180, '#448')};
|
|
4243
|
+
* background: ${adjustHue('180', 'rgba(101,100,205,0.7)')};
|
|
4244
|
+
* `
|
|
4245
|
+
*
|
|
4246
|
+
* // CSS in JS Output
|
|
4247
|
+
* element {
|
|
4248
|
+
* background: "#888844";
|
|
4249
|
+
* background: "rgba(136,136,68,0.7)";
|
|
4250
|
+
* }
|
|
4251
|
+
*/
|
|
4252
|
+
function adjustHue(degree, color) {
|
|
4253
|
+
if (color === 'transparent') return color;
|
|
4254
|
+
var hslColor = parseToHsl(color);
|
|
4255
|
+
return toColorString(_extends({}, hslColor, {
|
|
4256
|
+
hue: hslColor.hue + parseFloat(degree)
|
|
4257
|
+
}));
|
|
4258
|
+
}
|
|
4259
|
+
|
|
4260
|
+
// prettier-ignore
|
|
4261
|
+
curry /* ::<number | string, string, string> */(adjustHue);
|
|
4262
|
+
|
|
3931
4263
|
function guard(lowerBoundary, upperBoundary, value) {
|
|
3932
4264
|
return Math.max(lowerBoundary, Math.min(upperBoundary, value));
|
|
3933
4265
|
}
|
|
3934
4266
|
|
|
4267
|
+
/**
|
|
4268
|
+
* Returns a string value for the darkened color.
|
|
4269
|
+
*
|
|
4270
|
+
* @example
|
|
4271
|
+
* // Styles as object usage
|
|
4272
|
+
* const styles = {
|
|
4273
|
+
* background: darken(0.2, '#FFCD64'),
|
|
4274
|
+
* background: darken('0.2', 'rgba(255,205,100,0.7)'),
|
|
4275
|
+
* }
|
|
4276
|
+
*
|
|
4277
|
+
* // styled-components usage
|
|
4278
|
+
* const div = styled.div`
|
|
4279
|
+
* background: ${darken(0.2, '#FFCD64')};
|
|
4280
|
+
* background: ${darken('0.2', 'rgba(255,205,100,0.7)')};
|
|
4281
|
+
* `
|
|
4282
|
+
*
|
|
4283
|
+
* // CSS in JS Output
|
|
4284
|
+
*
|
|
4285
|
+
* element {
|
|
4286
|
+
* background: "#ffbd31";
|
|
4287
|
+
* background: "rgba(255,189,49,0.7)";
|
|
4288
|
+
* }
|
|
4289
|
+
*/
|
|
4290
|
+
function darken(amount, color) {
|
|
4291
|
+
if (color === 'transparent') return color;
|
|
4292
|
+
var hslColor = parseToHsl(color);
|
|
4293
|
+
return toColorString(_extends({}, hslColor, {
|
|
4294
|
+
lightness: guard(0, 1, hslColor.lightness - parseFloat(amount))
|
|
4295
|
+
}));
|
|
4296
|
+
}
|
|
4297
|
+
|
|
4298
|
+
// prettier-ignore
|
|
4299
|
+
curry /* ::<number | string, string, string> */(darken);
|
|
4300
|
+
|
|
4301
|
+
/**
|
|
4302
|
+
* Decreases the intensity of a color. Its range is between 0 to 1. The first
|
|
4303
|
+
* argument of the desaturate function is the amount by how much the color
|
|
4304
|
+
* intensity should be decreased.
|
|
4305
|
+
*
|
|
4306
|
+
* @example
|
|
4307
|
+
* // Styles as object usage
|
|
4308
|
+
* const styles = {
|
|
4309
|
+
* background: desaturate(0.2, '#CCCD64'),
|
|
4310
|
+
* background: desaturate('0.2', 'rgba(204,205,100,0.7)'),
|
|
4311
|
+
* }
|
|
4312
|
+
*
|
|
4313
|
+
* // styled-components usage
|
|
4314
|
+
* const div = styled.div`
|
|
4315
|
+
* background: ${desaturate(0.2, '#CCCD64')};
|
|
4316
|
+
* background: ${desaturate('0.2', 'rgba(204,205,100,0.7)')};
|
|
4317
|
+
* `
|
|
4318
|
+
*
|
|
4319
|
+
* // CSS in JS Output
|
|
4320
|
+
* element {
|
|
4321
|
+
* background: "#b8b979";
|
|
4322
|
+
* background: "rgba(184,185,121,0.7)";
|
|
4323
|
+
* }
|
|
4324
|
+
*/
|
|
4325
|
+
function desaturate(amount, color) {
|
|
4326
|
+
if (color === 'transparent') return color;
|
|
4327
|
+
var hslColor = parseToHsl(color);
|
|
4328
|
+
return toColorString(_extends({}, hslColor, {
|
|
4329
|
+
saturation: guard(0, 1, hslColor.saturation - parseFloat(amount))
|
|
4330
|
+
}));
|
|
4331
|
+
}
|
|
4332
|
+
|
|
4333
|
+
// prettier-ignore
|
|
4334
|
+
curry /* ::<number | string, string, string> */(desaturate);
|
|
4335
|
+
|
|
4336
|
+
/**
|
|
4337
|
+
* Returns a string value for the lightened color.
|
|
4338
|
+
*
|
|
4339
|
+
* @example
|
|
4340
|
+
* // Styles as object usage
|
|
4341
|
+
* const styles = {
|
|
4342
|
+
* background: lighten(0.2, '#CCCD64'),
|
|
4343
|
+
* background: lighten('0.2', 'rgba(204,205,100,0.7)'),
|
|
4344
|
+
* }
|
|
4345
|
+
*
|
|
4346
|
+
* // styled-components usage
|
|
4347
|
+
* const div = styled.div`
|
|
4348
|
+
* background: ${lighten(0.2, '#FFCD64')};
|
|
4349
|
+
* background: ${lighten('0.2', 'rgba(204,205,100,0.7)')};
|
|
4350
|
+
* `
|
|
4351
|
+
*
|
|
4352
|
+
* // CSS in JS Output
|
|
4353
|
+
*
|
|
4354
|
+
* element {
|
|
4355
|
+
* background: "#e5e6b1";
|
|
4356
|
+
* background: "rgba(229,230,177,0.7)";
|
|
4357
|
+
* }
|
|
4358
|
+
*/
|
|
4359
|
+
function lighten(amount, color) {
|
|
4360
|
+
if (color === 'transparent') return color;
|
|
4361
|
+
var hslColor = parseToHsl(color);
|
|
4362
|
+
return toColorString(_extends({}, hslColor, {
|
|
4363
|
+
lightness: guard(0, 1, hslColor.lightness + parseFloat(amount))
|
|
4364
|
+
}));
|
|
4365
|
+
}
|
|
4366
|
+
|
|
4367
|
+
// prettier-ignore
|
|
4368
|
+
curry /* ::<number | string, string, string> */(lighten);
|
|
4369
|
+
|
|
4370
|
+
/**
|
|
4371
|
+
* Mixes the two provided colors together by calculating the average of each of the RGB components weighted to the first color by the provided weight.
|
|
4372
|
+
*
|
|
4373
|
+
* @example
|
|
4374
|
+
* // Styles as object usage
|
|
4375
|
+
* const styles = {
|
|
4376
|
+
* background: mix(0.5, '#f00', '#00f')
|
|
4377
|
+
* background: mix(0.25, '#f00', '#00f')
|
|
4378
|
+
* background: mix('0.5', 'rgba(255, 0, 0, 0.5)', '#00f')
|
|
4379
|
+
* }
|
|
4380
|
+
*
|
|
4381
|
+
* // styled-components usage
|
|
4382
|
+
* const div = styled.div`
|
|
4383
|
+
* background: ${mix(0.5, '#f00', '#00f')};
|
|
4384
|
+
* background: ${mix(0.25, '#f00', '#00f')};
|
|
4385
|
+
* background: ${mix('0.5', 'rgba(255, 0, 0, 0.5)', '#00f')};
|
|
4386
|
+
* `
|
|
4387
|
+
*
|
|
4388
|
+
* // CSS in JS Output
|
|
4389
|
+
*
|
|
4390
|
+
* element {
|
|
4391
|
+
* background: "#7f007f";
|
|
4392
|
+
* background: "#3f00bf";
|
|
4393
|
+
* background: "rgba(63, 0, 191, 0.75)";
|
|
4394
|
+
* }
|
|
4395
|
+
*/
|
|
4396
|
+
function mix(weight, color, otherColor) {
|
|
4397
|
+
if (color === 'transparent') return otherColor;
|
|
4398
|
+
if (otherColor === 'transparent') return color;
|
|
4399
|
+
if (weight === 0) return otherColor;
|
|
4400
|
+
var parsedColor1 = parseToRgb(color);
|
|
4401
|
+
var color1 = _extends({}, parsedColor1, {
|
|
4402
|
+
alpha: typeof parsedColor1.alpha === 'number' ? parsedColor1.alpha : 1
|
|
4403
|
+
});
|
|
4404
|
+
var parsedColor2 = parseToRgb(otherColor);
|
|
4405
|
+
var color2 = _extends({}, parsedColor2, {
|
|
4406
|
+
alpha: typeof parsedColor2.alpha === 'number' ? parsedColor2.alpha : 1
|
|
4407
|
+
});
|
|
4408
|
+
|
|
4409
|
+
// The formula is copied from the original Sass implementation:
|
|
4410
|
+
// http://sass-lang.com/documentation/Sass/Script/Functions.html#mix-instance_method
|
|
4411
|
+
var alphaDelta = color1.alpha - color2.alpha;
|
|
4412
|
+
var x = parseFloat(weight) * 2 - 1;
|
|
4413
|
+
var y = x * alphaDelta === -1 ? x : x + alphaDelta;
|
|
4414
|
+
var z = 1 + x * alphaDelta;
|
|
4415
|
+
var weight1 = (y / z + 1) / 2.0;
|
|
4416
|
+
var weight2 = 1 - weight1;
|
|
4417
|
+
var mixedColor = {
|
|
4418
|
+
red: Math.floor(color1.red * weight1 + color2.red * weight2),
|
|
4419
|
+
green: Math.floor(color1.green * weight1 + color2.green * weight2),
|
|
4420
|
+
blue: Math.floor(color1.blue * weight1 + color2.blue * weight2),
|
|
4421
|
+
alpha: color1.alpha * parseFloat(weight) + color2.alpha * (1 - parseFloat(weight))
|
|
4422
|
+
};
|
|
4423
|
+
return rgba(mixedColor);
|
|
4424
|
+
}
|
|
4425
|
+
|
|
4426
|
+
// prettier-ignore
|
|
4427
|
+
var curriedMix = curry /* ::<number | string, string, string, string> */(mix);
|
|
4428
|
+
var mix$1 = curriedMix;
|
|
4429
|
+
|
|
3935
4430
|
/**
|
|
3936
4431
|
* Increases the opacity of a color. Its range for the amount is between 0 to 1.
|
|
3937
4432
|
*
|
|
@@ -3959,25 +4454,257 @@
|
|
|
3959
4454
|
* background: "rgba(255,0,0,0.7)";
|
|
3960
4455
|
* }
|
|
3961
4456
|
*/
|
|
3962
|
-
|
|
3963
4457
|
function opacify(amount, color) {
|
|
3964
4458
|
if (color === 'transparent') return color;
|
|
3965
4459
|
var parsedColor = parseToRgb(color);
|
|
3966
4460
|
var alpha = typeof parsedColor.alpha === 'number' ? parsedColor.alpha : 1;
|
|
3967
|
-
|
|
3968
4461
|
var colorWithAlpha = _extends({}, parsedColor, {
|
|
3969
4462
|
alpha: guard(0, 1, (alpha * 100 + parseFloat(amount) * 100) / 100)
|
|
3970
4463
|
});
|
|
3971
|
-
|
|
3972
4464
|
return rgba(colorWithAlpha);
|
|
3973
|
-
}
|
|
3974
|
-
|
|
4465
|
+
}
|
|
3975
4466
|
|
|
3976
|
-
|
|
3977
|
-
/* ::<number | string, string, string> */
|
|
3978
|
-
(opacify);
|
|
4467
|
+
// prettier-ignore
|
|
4468
|
+
var curriedOpacify = curry /* ::<number | string, string, string> */(opacify);
|
|
3979
4469
|
var curriedOpacify$1 = curriedOpacify;
|
|
3980
4470
|
|
|
4471
|
+
/**
|
|
4472
|
+
* Increases the intensity of a color. Its range is between 0 to 1. The first
|
|
4473
|
+
* argument of the saturate function is the amount by how much the color
|
|
4474
|
+
* intensity should be increased.
|
|
4475
|
+
*
|
|
4476
|
+
* @example
|
|
4477
|
+
* // Styles as object usage
|
|
4478
|
+
* const styles = {
|
|
4479
|
+
* background: saturate(0.2, '#CCCD64'),
|
|
4480
|
+
* background: saturate('0.2', 'rgba(204,205,100,0.7)'),
|
|
4481
|
+
* }
|
|
4482
|
+
*
|
|
4483
|
+
* // styled-components usage
|
|
4484
|
+
* const div = styled.div`
|
|
4485
|
+
* background: ${saturate(0.2, '#FFCD64')};
|
|
4486
|
+
* background: ${saturate('0.2', 'rgba(204,205,100,0.7)')};
|
|
4487
|
+
* `
|
|
4488
|
+
*
|
|
4489
|
+
* // CSS in JS Output
|
|
4490
|
+
*
|
|
4491
|
+
* element {
|
|
4492
|
+
* background: "#e0e250";
|
|
4493
|
+
* background: "rgba(224,226,80,0.7)";
|
|
4494
|
+
* }
|
|
4495
|
+
*/
|
|
4496
|
+
function saturate(amount, color) {
|
|
4497
|
+
if (color === 'transparent') return color;
|
|
4498
|
+
var hslColor = parseToHsl(color);
|
|
4499
|
+
return toColorString(_extends({}, hslColor, {
|
|
4500
|
+
saturation: guard(0, 1, hslColor.saturation + parseFloat(amount))
|
|
4501
|
+
}));
|
|
4502
|
+
}
|
|
4503
|
+
|
|
4504
|
+
// prettier-ignore
|
|
4505
|
+
curry /* ::<number | string, string, string> */(saturate);
|
|
4506
|
+
|
|
4507
|
+
/**
|
|
4508
|
+
* Sets the hue of a color to the provided value. The hue range can be
|
|
4509
|
+
* from 0 and 359.
|
|
4510
|
+
*
|
|
4511
|
+
* @example
|
|
4512
|
+
* // Styles as object usage
|
|
4513
|
+
* const styles = {
|
|
4514
|
+
* background: setHue(42, '#CCCD64'),
|
|
4515
|
+
* background: setHue('244', 'rgba(204,205,100,0.7)'),
|
|
4516
|
+
* }
|
|
4517
|
+
*
|
|
4518
|
+
* // styled-components usage
|
|
4519
|
+
* const div = styled.div`
|
|
4520
|
+
* background: ${setHue(42, '#CCCD64')};
|
|
4521
|
+
* background: ${setHue('244', 'rgba(204,205,100,0.7)')};
|
|
4522
|
+
* `
|
|
4523
|
+
*
|
|
4524
|
+
* // CSS in JS Output
|
|
4525
|
+
* element {
|
|
4526
|
+
* background: "#cdae64";
|
|
4527
|
+
* background: "rgba(107,100,205,0.7)";
|
|
4528
|
+
* }
|
|
4529
|
+
*/
|
|
4530
|
+
function setHue(hue, color) {
|
|
4531
|
+
if (color === 'transparent') return color;
|
|
4532
|
+
return toColorString(_extends({}, parseToHsl(color), {
|
|
4533
|
+
hue: parseFloat(hue)
|
|
4534
|
+
}));
|
|
4535
|
+
}
|
|
4536
|
+
|
|
4537
|
+
// prettier-ignore
|
|
4538
|
+
curry /* ::<number | string, string, string> */(setHue);
|
|
4539
|
+
|
|
4540
|
+
/**
|
|
4541
|
+
* Sets the lightness of a color to the provided value. The lightness range can be
|
|
4542
|
+
* from 0 and 1.
|
|
4543
|
+
*
|
|
4544
|
+
* @example
|
|
4545
|
+
* // Styles as object usage
|
|
4546
|
+
* const styles = {
|
|
4547
|
+
* background: setLightness(0.2, '#CCCD64'),
|
|
4548
|
+
* background: setLightness('0.75', 'rgba(204,205,100,0.7)'),
|
|
4549
|
+
* }
|
|
4550
|
+
*
|
|
4551
|
+
* // styled-components usage
|
|
4552
|
+
* const div = styled.div`
|
|
4553
|
+
* background: ${setLightness(0.2, '#CCCD64')};
|
|
4554
|
+
* background: ${setLightness('0.75', 'rgba(204,205,100,0.7)')};
|
|
4555
|
+
* `
|
|
4556
|
+
*
|
|
4557
|
+
* // CSS in JS Output
|
|
4558
|
+
* element {
|
|
4559
|
+
* background: "#4d4d19";
|
|
4560
|
+
* background: "rgba(223,224,159,0.7)";
|
|
4561
|
+
* }
|
|
4562
|
+
*/
|
|
4563
|
+
function setLightness(lightness, color) {
|
|
4564
|
+
if (color === 'transparent') return color;
|
|
4565
|
+
return toColorString(_extends({}, parseToHsl(color), {
|
|
4566
|
+
lightness: parseFloat(lightness)
|
|
4567
|
+
}));
|
|
4568
|
+
}
|
|
4569
|
+
|
|
4570
|
+
// prettier-ignore
|
|
4571
|
+
curry /* ::<number | string, string, string> */(setLightness);
|
|
4572
|
+
|
|
4573
|
+
/**
|
|
4574
|
+
* Sets the saturation of a color to the provided value. The saturation range can be
|
|
4575
|
+
* from 0 and 1.
|
|
4576
|
+
*
|
|
4577
|
+
* @example
|
|
4578
|
+
* // Styles as object usage
|
|
4579
|
+
* const styles = {
|
|
4580
|
+
* background: setSaturation(0.2, '#CCCD64'),
|
|
4581
|
+
* background: setSaturation('0.75', 'rgba(204,205,100,0.7)'),
|
|
4582
|
+
* }
|
|
4583
|
+
*
|
|
4584
|
+
* // styled-components usage
|
|
4585
|
+
* const div = styled.div`
|
|
4586
|
+
* background: ${setSaturation(0.2, '#CCCD64')};
|
|
4587
|
+
* background: ${setSaturation('0.75', 'rgba(204,205,100,0.7)')};
|
|
4588
|
+
* `
|
|
4589
|
+
*
|
|
4590
|
+
* // CSS in JS Output
|
|
4591
|
+
* element {
|
|
4592
|
+
* background: "#adad84";
|
|
4593
|
+
* background: "rgba(228,229,76,0.7)";
|
|
4594
|
+
* }
|
|
4595
|
+
*/
|
|
4596
|
+
function setSaturation(saturation, color) {
|
|
4597
|
+
if (color === 'transparent') return color;
|
|
4598
|
+
return toColorString(_extends({}, parseToHsl(color), {
|
|
4599
|
+
saturation: parseFloat(saturation)
|
|
4600
|
+
}));
|
|
4601
|
+
}
|
|
4602
|
+
|
|
4603
|
+
// prettier-ignore
|
|
4604
|
+
curry /* ::<number | string, string, string> */(setSaturation);
|
|
4605
|
+
|
|
4606
|
+
/**
|
|
4607
|
+
* Shades a color by mixing it with black. `shade` can produce
|
|
4608
|
+
* hue shifts, where as `darken` manipulates the luminance channel and therefore
|
|
4609
|
+
* doesn't produce hue shifts.
|
|
4610
|
+
*
|
|
4611
|
+
* @example
|
|
4612
|
+
* // Styles as object usage
|
|
4613
|
+
* const styles = {
|
|
4614
|
+
* background: shade(0.25, '#00f')
|
|
4615
|
+
* }
|
|
4616
|
+
*
|
|
4617
|
+
* // styled-components usage
|
|
4618
|
+
* const div = styled.div`
|
|
4619
|
+
* background: ${shade(0.25, '#00f')};
|
|
4620
|
+
* `
|
|
4621
|
+
*
|
|
4622
|
+
* // CSS in JS Output
|
|
4623
|
+
*
|
|
4624
|
+
* element {
|
|
4625
|
+
* background: "#00003f";
|
|
4626
|
+
* }
|
|
4627
|
+
*/
|
|
4628
|
+
|
|
4629
|
+
function shade(percentage, color) {
|
|
4630
|
+
if (color === 'transparent') return color;
|
|
4631
|
+
return mix$1(parseFloat(percentage), 'rgb(0, 0, 0)', color);
|
|
4632
|
+
}
|
|
4633
|
+
|
|
4634
|
+
// prettier-ignore
|
|
4635
|
+
curry /* ::<number | string, string, string> */(shade);
|
|
4636
|
+
|
|
4637
|
+
/**
|
|
4638
|
+
* Tints a color by mixing it with white. `tint` can produce
|
|
4639
|
+
* hue shifts, where as `lighten` manipulates the luminance channel and therefore
|
|
4640
|
+
* doesn't produce hue shifts.
|
|
4641
|
+
*
|
|
4642
|
+
* @example
|
|
4643
|
+
* // Styles as object usage
|
|
4644
|
+
* const styles = {
|
|
4645
|
+
* background: tint(0.25, '#00f')
|
|
4646
|
+
* }
|
|
4647
|
+
*
|
|
4648
|
+
* // styled-components usage
|
|
4649
|
+
* const div = styled.div`
|
|
4650
|
+
* background: ${tint(0.25, '#00f')};
|
|
4651
|
+
* `
|
|
4652
|
+
*
|
|
4653
|
+
* // CSS in JS Output
|
|
4654
|
+
*
|
|
4655
|
+
* element {
|
|
4656
|
+
* background: "#bfbfff";
|
|
4657
|
+
* }
|
|
4658
|
+
*/
|
|
4659
|
+
|
|
4660
|
+
function tint(percentage, color) {
|
|
4661
|
+
if (color === 'transparent') return color;
|
|
4662
|
+
return mix$1(parseFloat(percentage), 'rgb(255, 255, 255)', color);
|
|
4663
|
+
}
|
|
4664
|
+
|
|
4665
|
+
// prettier-ignore
|
|
4666
|
+
curry /* ::<number | string, string, string> */(tint);
|
|
4667
|
+
|
|
4668
|
+
/**
|
|
4669
|
+
* Decreases the opacity of a color. Its range for the amount is between 0 to 1.
|
|
4670
|
+
*
|
|
4671
|
+
*
|
|
4672
|
+
* @example
|
|
4673
|
+
* // Styles as object usage
|
|
4674
|
+
* const styles = {
|
|
4675
|
+
* background: transparentize(0.1, '#fff'),
|
|
4676
|
+
* background: transparentize(0.2, 'hsl(0, 0%, 100%)'),
|
|
4677
|
+
* background: transparentize('0.5', 'rgba(255, 0, 0, 0.8)'),
|
|
4678
|
+
* }
|
|
4679
|
+
*
|
|
4680
|
+
* // styled-components usage
|
|
4681
|
+
* const div = styled.div`
|
|
4682
|
+
* background: ${transparentize(0.1, '#fff')};
|
|
4683
|
+
* background: ${transparentize(0.2, 'hsl(0, 0%, 100%)')};
|
|
4684
|
+
* background: ${transparentize('0.5', 'rgba(255, 0, 0, 0.8)')};
|
|
4685
|
+
* `
|
|
4686
|
+
*
|
|
4687
|
+
* // CSS in JS Output
|
|
4688
|
+
*
|
|
4689
|
+
* element {
|
|
4690
|
+
* background: "rgba(255,255,255,0.9)";
|
|
4691
|
+
* background: "rgba(255,255,255,0.8)";
|
|
4692
|
+
* background: "rgba(255,0,0,0.3)";
|
|
4693
|
+
* }
|
|
4694
|
+
*/
|
|
4695
|
+
function transparentize(amount, color) {
|
|
4696
|
+
if (color === 'transparent') return color;
|
|
4697
|
+
var parsedColor = parseToRgb(color);
|
|
4698
|
+
var alpha = typeof parsedColor.alpha === 'number' ? parsedColor.alpha : 1;
|
|
4699
|
+
var colorWithAlpha = _extends({}, parsedColor, {
|
|
4700
|
+
alpha: guard(0, 1, +(alpha * 100 - parseFloat(amount) * 100).toFixed(2) / 100)
|
|
4701
|
+
});
|
|
4702
|
+
return rgba(colorWithAlpha);
|
|
4703
|
+
}
|
|
4704
|
+
|
|
4705
|
+
// prettier-ignore
|
|
4706
|
+
curry /* ::<number | string, string, string> */(transparentize);
|
|
4707
|
+
|
|
3981
4708
|
/**
|
|
3982
4709
|
* The Ease class provides a collection of easing functions for use with tween.js.
|
|
3983
4710
|
*/
|
|
@@ -4193,7 +4920,7 @@
|
|
|
4193
4920
|
},
|
|
4194
4921
|
});
|
|
4195
4922
|
|
|
4196
|
-
var now$
|
|
4923
|
+
var now$1 = function () { return performance.now(); };
|
|
4197
4924
|
|
|
4198
4925
|
/**
|
|
4199
4926
|
* Controlling groups of tweens
|
|
@@ -4224,7 +4951,7 @@
|
|
|
4224
4951
|
delete this._tweensAddedDuringUpdate[tween.getId()];
|
|
4225
4952
|
};
|
|
4226
4953
|
Group.prototype.update = function (time, preserve) {
|
|
4227
|
-
if (time === void 0) { time = now$
|
|
4954
|
+
if (time === void 0) { time = now$1(); }
|
|
4228
4955
|
if (preserve === void 0) { preserve = false; }
|
|
4229
4956
|
var tweenIds = Object.keys(this._tweens);
|
|
4230
4957
|
if (tweenIds.length === 0) {
|
|
@@ -4393,18 +5120,21 @@
|
|
|
4393
5120
|
Tween.prototype.isPaused = function () {
|
|
4394
5121
|
return this._isPaused;
|
|
4395
5122
|
};
|
|
5123
|
+
Tween.prototype.getDuration = function () {
|
|
5124
|
+
return this._duration;
|
|
5125
|
+
};
|
|
4396
5126
|
Tween.prototype.to = function (target, duration) {
|
|
4397
5127
|
if (duration === void 0) { duration = 1000; }
|
|
4398
5128
|
if (this._isPlaying)
|
|
4399
5129
|
throw new Error('Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.');
|
|
4400
5130
|
this._valuesEnd = target;
|
|
4401
5131
|
this._propertiesAreSetUp = false;
|
|
4402
|
-
this._duration = duration;
|
|
5132
|
+
this._duration = duration < 0 ? 0 : duration;
|
|
4403
5133
|
return this;
|
|
4404
5134
|
};
|
|
4405
5135
|
Tween.prototype.duration = function (duration) {
|
|
4406
5136
|
if (duration === void 0) { duration = 1000; }
|
|
4407
|
-
this._duration = duration;
|
|
5137
|
+
this._duration = duration < 0 ? 0 : duration;
|
|
4408
5138
|
return this;
|
|
4409
5139
|
};
|
|
4410
5140
|
Tween.prototype.dynamic = function (dynamic) {
|
|
@@ -4413,7 +5143,7 @@
|
|
|
4413
5143
|
return this;
|
|
4414
5144
|
};
|
|
4415
5145
|
Tween.prototype.start = function (time, overrideStartingValues) {
|
|
4416
|
-
if (time === void 0) { time = now$
|
|
5146
|
+
if (time === void 0) { time = now$1(); }
|
|
4417
5147
|
if (overrideStartingValues === void 0) { overrideStartingValues = false; }
|
|
4418
5148
|
if (this._isPlaying) {
|
|
4419
5149
|
return this;
|
|
@@ -4551,7 +5281,7 @@
|
|
|
4551
5281
|
return this;
|
|
4552
5282
|
};
|
|
4553
5283
|
Tween.prototype.pause = function (time) {
|
|
4554
|
-
if (time === void 0) { time = now$
|
|
5284
|
+
if (time === void 0) { time = now$1(); }
|
|
4555
5285
|
if (this._isPaused || !this._isPlaying) {
|
|
4556
5286
|
return this;
|
|
4557
5287
|
}
|
|
@@ -4562,7 +5292,7 @@
|
|
|
4562
5292
|
return this;
|
|
4563
5293
|
};
|
|
4564
5294
|
Tween.prototype.resume = function (time) {
|
|
4565
|
-
if (time === void 0) { time = now$
|
|
5295
|
+
if (time === void 0) { time = now$1(); }
|
|
4566
5296
|
if (!this._isPaused || !this._isPlaying) {
|
|
4567
5297
|
return this;
|
|
4568
5298
|
}
|
|
@@ -4653,12 +5383,13 @@
|
|
|
4653
5383
|
* it is still playing, just paused).
|
|
4654
5384
|
*/
|
|
4655
5385
|
Tween.prototype.update = function (time, autoStart) {
|
|
4656
|
-
|
|
5386
|
+
var _this = this;
|
|
5387
|
+
var _a;
|
|
5388
|
+
if (time === void 0) { time = now$1(); }
|
|
4657
5389
|
if (autoStart === void 0) { autoStart = true; }
|
|
4658
5390
|
if (this._isPaused)
|
|
4659
5391
|
return true;
|
|
4660
5392
|
var property;
|
|
4661
|
-
var elapsed;
|
|
4662
5393
|
var endTime = this._startTime + this._duration;
|
|
4663
5394
|
if (!this._goToEnd && !this._isPlaying) {
|
|
4664
5395
|
if (time > endTime)
|
|
@@ -4682,18 +5413,37 @@
|
|
|
4682
5413
|
}
|
|
4683
5414
|
this._onEveryStartCallbackFired = true;
|
|
4684
5415
|
}
|
|
4685
|
-
|
|
4686
|
-
|
|
5416
|
+
var elapsedTime = time - this._startTime;
|
|
5417
|
+
var durationAndDelay = this._duration + ((_a = this._repeatDelayTime) !== null && _a !== void 0 ? _a : this._delayTime);
|
|
5418
|
+
var totalTime = this._duration + this._repeat * durationAndDelay;
|
|
5419
|
+
var calculateElapsedPortion = function () {
|
|
5420
|
+
if (_this._duration === 0)
|
|
5421
|
+
return 1;
|
|
5422
|
+
if (elapsedTime > totalTime) {
|
|
5423
|
+
return 1;
|
|
5424
|
+
}
|
|
5425
|
+
var timesRepeated = Math.trunc(elapsedTime / durationAndDelay);
|
|
5426
|
+
var timeIntoCurrentRepeat = elapsedTime - timesRepeated * durationAndDelay;
|
|
5427
|
+
// TODO use %?
|
|
5428
|
+
// const timeIntoCurrentRepeat = elapsedTime % durationAndDelay
|
|
5429
|
+
var portion = Math.min(timeIntoCurrentRepeat / _this._duration, 1);
|
|
5430
|
+
if (portion === 0 && elapsedTime === _this._duration) {
|
|
5431
|
+
return 1;
|
|
5432
|
+
}
|
|
5433
|
+
return portion;
|
|
5434
|
+
};
|
|
5435
|
+
var elapsed = calculateElapsedPortion();
|
|
4687
5436
|
var value = this._easingFunction(elapsed);
|
|
4688
5437
|
// properties transformations
|
|
4689
5438
|
this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value);
|
|
4690
5439
|
if (this._onUpdateCallback) {
|
|
4691
5440
|
this._onUpdateCallback(this._object, elapsed);
|
|
4692
5441
|
}
|
|
4693
|
-
if (
|
|
5442
|
+
if (this._duration === 0 || elapsedTime >= this._duration) {
|
|
4694
5443
|
if (this._repeat > 0) {
|
|
5444
|
+
var completeCount = Math.min(Math.trunc((elapsedTime - this._duration) / durationAndDelay) + 1, this._repeat);
|
|
4695
5445
|
if (isFinite(this._repeat)) {
|
|
4696
|
-
this._repeat
|
|
5446
|
+
this._repeat -= completeCount;
|
|
4697
5447
|
}
|
|
4698
5448
|
// Reassign starting values, restart by making startTime = now
|
|
4699
5449
|
for (property in this._valuesStartRepeat) {
|
|
@@ -4711,12 +5461,7 @@
|
|
|
4711
5461
|
if (this._yoyo) {
|
|
4712
5462
|
this._reversed = !this._reversed;
|
|
4713
5463
|
}
|
|
4714
|
-
|
|
4715
|
-
this._startTime = time + this._repeatDelayTime;
|
|
4716
|
-
}
|
|
4717
|
-
else {
|
|
4718
|
-
this._startTime = time + this._delayTime;
|
|
4719
|
-
}
|
|
5464
|
+
this._startTime += durationAndDelay * completeCount;
|
|
4720
5465
|
if (this._onRepeatCallback) {
|
|
4721
5466
|
this._onRepeatCallback(this._object);
|
|
4722
5467
|
}
|
|
@@ -4818,23 +5563,101 @@
|
|
|
4818
5563
|
};
|
|
4819
5564
|
}); // constant
|
|
4820
5565
|
|
|
5566
|
+
/**
|
|
5567
|
+
* Checks if `value` is the
|
|
5568
|
+
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
5569
|
+
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
5570
|
+
*
|
|
5571
|
+
* @static
|
|
5572
|
+
* @memberOf _
|
|
5573
|
+
* @since 0.1.0
|
|
5574
|
+
* @category Lang
|
|
5575
|
+
* @param {*} value The value to check.
|
|
5576
|
+
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
5577
|
+
* @example
|
|
5578
|
+
*
|
|
5579
|
+
* _.isObject({});
|
|
5580
|
+
* // => true
|
|
5581
|
+
*
|
|
5582
|
+
* _.isObject([1, 2, 3]);
|
|
5583
|
+
* // => true
|
|
5584
|
+
*
|
|
5585
|
+
* _.isObject(_.noop);
|
|
5586
|
+
* // => true
|
|
5587
|
+
*
|
|
5588
|
+
* _.isObject(null);
|
|
5589
|
+
* // => false
|
|
5590
|
+
*/
|
|
5591
|
+
function isObject(value) {
|
|
5592
|
+
var type = typeof value;
|
|
5593
|
+
return value != null && (type == 'object' || type == 'function');
|
|
5594
|
+
}
|
|
5595
|
+
|
|
4821
5596
|
/** Detect free variable `global` from Node.js. */
|
|
4822
5597
|
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
|
4823
5598
|
|
|
4824
|
-
var freeGlobal$1 = freeGlobal;
|
|
4825
|
-
|
|
4826
5599
|
/** Detect free variable `self`. */
|
|
4827
5600
|
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
4828
5601
|
|
|
4829
5602
|
/** Used as a reference to the global object. */
|
|
4830
|
-
var root = freeGlobal
|
|
5603
|
+
var root = freeGlobal || freeSelf || Function('return this')();
|
|
5604
|
+
|
|
5605
|
+
/**
|
|
5606
|
+
* Gets the timestamp of the number of milliseconds that have elapsed since
|
|
5607
|
+
* the Unix epoch (1 January 1970 00:00:00 UTC).
|
|
5608
|
+
*
|
|
5609
|
+
* @static
|
|
5610
|
+
* @memberOf _
|
|
5611
|
+
* @since 2.4.0
|
|
5612
|
+
* @category Date
|
|
5613
|
+
* @returns {number} Returns the timestamp.
|
|
5614
|
+
* @example
|
|
5615
|
+
*
|
|
5616
|
+
* _.defer(function(stamp) {
|
|
5617
|
+
* console.log(_.now() - stamp);
|
|
5618
|
+
* }, _.now());
|
|
5619
|
+
* // => Logs the number of milliseconds it took for the deferred invocation.
|
|
5620
|
+
*/
|
|
5621
|
+
var now = function() {
|
|
5622
|
+
return root.Date.now();
|
|
5623
|
+
};
|
|
4831
5624
|
|
|
4832
|
-
|
|
5625
|
+
/** Used to match a single whitespace character. */
|
|
5626
|
+
var reWhitespace = /\s/;
|
|
4833
5627
|
|
|
4834
|
-
/**
|
|
4835
|
-
|
|
5628
|
+
/**
|
|
5629
|
+
* Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
|
|
5630
|
+
* character of `string`.
|
|
5631
|
+
*
|
|
5632
|
+
* @private
|
|
5633
|
+
* @param {string} string The string to inspect.
|
|
5634
|
+
* @returns {number} Returns the index of the last non-whitespace character.
|
|
5635
|
+
*/
|
|
5636
|
+
function trimmedEndIndex(string) {
|
|
5637
|
+
var index = string.length;
|
|
5638
|
+
|
|
5639
|
+
while (index-- && reWhitespace.test(string.charAt(index))) {}
|
|
5640
|
+
return index;
|
|
5641
|
+
}
|
|
5642
|
+
|
|
5643
|
+
/** Used to match leading whitespace. */
|
|
5644
|
+
var reTrimStart = /^\s+/;
|
|
5645
|
+
|
|
5646
|
+
/**
|
|
5647
|
+
* The base implementation of `_.trim`.
|
|
5648
|
+
*
|
|
5649
|
+
* @private
|
|
5650
|
+
* @param {string} string The string to trim.
|
|
5651
|
+
* @returns {string} Returns the trimmed string.
|
|
5652
|
+
*/
|
|
5653
|
+
function baseTrim(string) {
|
|
5654
|
+
return string
|
|
5655
|
+
? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
|
|
5656
|
+
: string;
|
|
5657
|
+
}
|
|
4836
5658
|
|
|
4837
|
-
|
|
5659
|
+
/** Built-in value references. */
|
|
5660
|
+
var Symbol$1 = root.Symbol;
|
|
4838
5661
|
|
|
4839
5662
|
/** Used for built-in method references. */
|
|
4840
5663
|
var objectProto$1 = Object.prototype;
|
|
@@ -4850,7 +5673,7 @@
|
|
|
4850
5673
|
var nativeObjectToString$1 = objectProto$1.toString;
|
|
4851
5674
|
|
|
4852
5675
|
/** Built-in value references. */
|
|
4853
|
-
var symToStringTag$1 = Symbol$
|
|
5676
|
+
var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
|
|
4854
5677
|
|
|
4855
5678
|
/**
|
|
4856
5679
|
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
@@ -4905,7 +5728,7 @@
|
|
|
4905
5728
|
undefinedTag = '[object Undefined]';
|
|
4906
5729
|
|
|
4907
5730
|
/** Built-in value references. */
|
|
4908
|
-
var symToStringTag = Symbol$
|
|
5731
|
+
var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
|
|
4909
5732
|
|
|
4910
5733
|
/**
|
|
4911
5734
|
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
@@ -4976,70 +5799,6 @@
|
|
|
4976
5799
|
(isObjectLike(value) && baseGetTag(value) == symbolTag);
|
|
4977
5800
|
}
|
|
4978
5801
|
|
|
4979
|
-
/** Used to match a single whitespace character. */
|
|
4980
|
-
var reWhitespace = /\s/;
|
|
4981
|
-
|
|
4982
|
-
/**
|
|
4983
|
-
* Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
|
|
4984
|
-
* character of `string`.
|
|
4985
|
-
*
|
|
4986
|
-
* @private
|
|
4987
|
-
* @param {string} string The string to inspect.
|
|
4988
|
-
* @returns {number} Returns the index of the last non-whitespace character.
|
|
4989
|
-
*/
|
|
4990
|
-
function trimmedEndIndex(string) {
|
|
4991
|
-
var index = string.length;
|
|
4992
|
-
|
|
4993
|
-
while (index-- && reWhitespace.test(string.charAt(index))) {}
|
|
4994
|
-
return index;
|
|
4995
|
-
}
|
|
4996
|
-
|
|
4997
|
-
/** Used to match leading whitespace. */
|
|
4998
|
-
var reTrimStart = /^\s+/;
|
|
4999
|
-
|
|
5000
|
-
/**
|
|
5001
|
-
* The base implementation of `_.trim`.
|
|
5002
|
-
*
|
|
5003
|
-
* @private
|
|
5004
|
-
* @param {string} string The string to trim.
|
|
5005
|
-
* @returns {string} Returns the trimmed string.
|
|
5006
|
-
*/
|
|
5007
|
-
function baseTrim(string) {
|
|
5008
|
-
return string
|
|
5009
|
-
? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
|
|
5010
|
-
: string;
|
|
5011
|
-
}
|
|
5012
|
-
|
|
5013
|
-
/**
|
|
5014
|
-
* Checks if `value` is the
|
|
5015
|
-
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
5016
|
-
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
5017
|
-
*
|
|
5018
|
-
* @static
|
|
5019
|
-
* @memberOf _
|
|
5020
|
-
* @since 0.1.0
|
|
5021
|
-
* @category Lang
|
|
5022
|
-
* @param {*} value The value to check.
|
|
5023
|
-
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
5024
|
-
* @example
|
|
5025
|
-
*
|
|
5026
|
-
* _.isObject({});
|
|
5027
|
-
* // => true
|
|
5028
|
-
*
|
|
5029
|
-
* _.isObject([1, 2, 3]);
|
|
5030
|
-
* // => true
|
|
5031
|
-
*
|
|
5032
|
-
* _.isObject(_.noop);
|
|
5033
|
-
* // => true
|
|
5034
|
-
*
|
|
5035
|
-
* _.isObject(null);
|
|
5036
|
-
* // => false
|
|
5037
|
-
*/
|
|
5038
|
-
function isObject(value) {
|
|
5039
|
-
var type = typeof value;
|
|
5040
|
-
return value != null && (type == 'object' || type == 'function');
|
|
5041
|
-
}
|
|
5042
|
-
|
|
5043
5802
|
/** Used as references for various `Number` constants. */
|
|
5044
5803
|
var NAN = 0 / 0;
|
|
5045
5804
|
|
|
@@ -5099,28 +5858,6 @@
|
|
|
5099
5858
|
: (reIsBadHex.test(value) ? NAN : +value);
|
|
5100
5859
|
}
|
|
5101
5860
|
|
|
5102
|
-
/**
|
|
5103
|
-
* Gets the timestamp of the number of milliseconds that have elapsed since
|
|
5104
|
-
* the Unix epoch (1 January 1970 00:00:00 UTC).
|
|
5105
|
-
*
|
|
5106
|
-
* @static
|
|
5107
|
-
* @memberOf _
|
|
5108
|
-
* @since 2.4.0
|
|
5109
|
-
* @category Date
|
|
5110
|
-
* @returns {number} Returns the timestamp.
|
|
5111
|
-
* @example
|
|
5112
|
-
*
|
|
5113
|
-
* _.defer(function(stamp) {
|
|
5114
|
-
* console.log(_.now() - stamp);
|
|
5115
|
-
* }, _.now());
|
|
5116
|
-
* // => Logs the number of milliseconds it took for the deferred invocation.
|
|
5117
|
-
*/
|
|
5118
|
-
var now = function() {
|
|
5119
|
-
return root$1.Date.now();
|
|
5120
|
-
};
|
|
5121
|
-
|
|
5122
|
-
var now$1 = now;
|
|
5123
|
-
|
|
5124
5861
|
/** Error message constants. */
|
|
5125
5862
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
5126
5863
|
|
|
@@ -5246,7 +5983,7 @@
|
|
|
5246
5983
|
}
|
|
5247
5984
|
|
|
5248
5985
|
function timerExpired() {
|
|
5249
|
-
var time = now
|
|
5986
|
+
var time = now();
|
|
5250
5987
|
if (shouldInvoke(time)) {
|
|
5251
5988
|
return trailingEdge(time);
|
|
5252
5989
|
}
|
|
@@ -5275,11 +6012,11 @@
|
|
|
5275
6012
|
}
|
|
5276
6013
|
|
|
5277
6014
|
function flush() {
|
|
5278
|
-
return timerId === undefined ? result : trailingEdge(now
|
|
6015
|
+
return timerId === undefined ? result : trailingEdge(now());
|
|
5279
6016
|
}
|
|
5280
6017
|
|
|
5281
6018
|
function debounced() {
|
|
5282
|
-
var time = now
|
|
6019
|
+
var time = now(),
|
|
5283
6020
|
isInvoking = shouldInvoke(time);
|
|
5284
6021
|
|
|
5285
6022
|
lastArgs = arguments;
|
|
@@ -5307,31 +6044,31 @@
|
|
|
5307
6044
|
return debounced;
|
|
5308
6045
|
}
|
|
5309
6046
|
|
|
5310
|
-
function _iterableToArrayLimit(
|
|
5311
|
-
var
|
|
5312
|
-
if (null !=
|
|
5313
|
-
var
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
6047
|
+
function _iterableToArrayLimit(r, l) {
|
|
6048
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
6049
|
+
if (null != t) {
|
|
6050
|
+
var e,
|
|
6051
|
+
n,
|
|
6052
|
+
i,
|
|
6053
|
+
u,
|
|
6054
|
+
a = [],
|
|
6055
|
+
f = !0,
|
|
6056
|
+
o = !1;
|
|
5320
6057
|
try {
|
|
5321
|
-
if (
|
|
5322
|
-
if (Object(
|
|
5323
|
-
|
|
5324
|
-
} else for (; !(
|
|
5325
|
-
} catch (
|
|
5326
|
-
|
|
6058
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
6059
|
+
if (Object(t) !== t) return;
|
|
6060
|
+
f = !1;
|
|
6061
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
6062
|
+
} catch (r) {
|
|
6063
|
+
o = !0, n = r;
|
|
5327
6064
|
} finally {
|
|
5328
6065
|
try {
|
|
5329
|
-
if (!
|
|
6066
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
5330
6067
|
} finally {
|
|
5331
|
-
if (
|
|
6068
|
+
if (o) throw n;
|
|
5332
6069
|
}
|
|
5333
6070
|
}
|
|
5334
|
-
return
|
|
6071
|
+
return a;
|
|
5335
6072
|
}
|
|
5336
6073
|
}
|
|
5337
6074
|
function _classCallCheck(instance, Constructor) {
|
|
@@ -5656,7 +6393,6 @@
|
|
|
5656
6393
|
}
|
|
5657
6394
|
update(); // update camera animation tweens
|
|
5658
6395
|
}
|
|
5659
|
-
|
|
5660
6396
|
return this;
|
|
5661
6397
|
},
|
|
5662
6398
|
getPointerPos: function getPointerPos(state) {
|
|
@@ -5718,7 +6454,6 @@
|
|
|
5718
6454
|
camera.lookAt(lookAtVect); // note: lookAt may be overridden by other controls in some cases
|
|
5719
6455
|
}
|
|
5720
6456
|
}
|
|
5721
|
-
|
|
5722
6457
|
function getLookAt() {
|
|
5723
6458
|
return Object.assign(new three.Vector3(0, 0, -1000).applyQuaternion(camera.quaternion).add(camera.position));
|
|
5724
6459
|
}
|
|
@@ -5817,7 +6552,6 @@
|
|
|
5817
6552
|
return state.controls;
|
|
5818
6553
|
} // to be deprecated
|
|
5819
6554
|
},
|
|
5820
|
-
|
|
5821
6555
|
stateInit: function stateInit() {
|
|
5822
6556
|
return {
|
|
5823
6557
|
scene: new three.Scene(),
|
|
@@ -5908,14 +6642,12 @@
|
|
|
5908
6642
|
state.isPointerDragging = false;
|
|
5909
6643
|
if (!state.clickAfterDrag) return; // don't trigger onClick after pointer drag (camera motion via controls)
|
|
5910
6644
|
}
|
|
5911
|
-
|
|
5912
6645
|
requestAnimationFrame(function () {
|
|
5913
6646
|
// trigger click events asynchronously, to allow hoverObj to be set (on frame)
|
|
5914
6647
|
if (ev.button === 0) {
|
|
5915
6648
|
// left-click
|
|
5916
6649
|
state.onClick(state.hoverObj || null, ev, state.intersectionPoint); // trigger background clicks with null
|
|
5917
6650
|
}
|
|
5918
|
-
|
|
5919
6651
|
if (ev.button === 2 && state.onRightClick) {
|
|
5920
6652
|
// right-click
|
|
5921
6653
|
state.onRightClick(state.hoverObj || null, ev, state.intersectionPoint);
|
|
@@ -6043,7 +6775,6 @@
|
|
|
6043
6775
|
return state.scene.add(light);
|
|
6044
6776
|
}); // Add to scene
|
|
6045
6777
|
}
|
|
6046
|
-
|
|
6047
6778
|
if (changedProps.hasOwnProperty('objects')) {
|
|
6048
6779
|
(changedProps.objects || []).forEach(function (obj) {
|
|
6049
6780
|
return state.scene.remove(obj);
|