|
@@ -299,241 +299,252 @@ for ( let i = 0; i < 256; i ++ ) {
|
|
|
|
|
|
let _seed = 1234567;
|
|
|
|
|
|
-const MathUtils = {
|
|
|
|
|
|
- DEG2RAD: Math.PI / 180,
|
|
|
- RAD2DEG: 180 / Math.PI,
|
|
|
+const DEG2RAD = Math.PI / 180;
|
|
|
+const RAD2DEG = 180 / Math.PI;
|
|
|
|
|
|
- generateUUID: function () {
|
|
|
+// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
|
|
|
+function generateUUID() {
|
|
|
|
|
|
- // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
|
|
|
-
|
|
|
- const d0 = Math.random() * 0xffffffff | 0;
|
|
|
- const d1 = Math.random() * 0xffffffff | 0;
|
|
|
- const d2 = Math.random() * 0xffffffff | 0;
|
|
|
- const d3 = Math.random() * 0xffffffff | 0;
|
|
|
- const uuid = _lut[ d0 & 0xff ] + _lut[ d0 >> 8 & 0xff ] + _lut[ d0 >> 16 & 0xff ] + _lut[ d0 >> 24 & 0xff ] + '-' +
|
|
|
+ const d0 = Math.random() * 0xffffffff | 0;
|
|
|
+ const d1 = Math.random() * 0xffffffff | 0;
|
|
|
+ const d2 = Math.random() * 0xffffffff | 0;
|
|
|
+ const d3 = Math.random() * 0xffffffff | 0;
|
|
|
+ const uuid = _lut[ d0 & 0xff ] + _lut[ d0 >> 8 & 0xff ] + _lut[ d0 >> 16 & 0xff ] + _lut[ d0 >> 24 & 0xff ] + '-' +
|
|
|
_lut[ d1 & 0xff ] + _lut[ d1 >> 8 & 0xff ] + '-' + _lut[ d1 >> 16 & 0x0f | 0x40 ] + _lut[ d1 >> 24 & 0xff ] + '-' +
|
|
|
_lut[ d2 & 0x3f | 0x80 ] + _lut[ d2 >> 8 & 0xff ] + '-' + _lut[ d2 >> 16 & 0xff ] + _lut[ d2 >> 24 & 0xff ] +
|
|
|
_lut[ d3 & 0xff ] + _lut[ d3 >> 8 & 0xff ] + _lut[ d3 >> 16 & 0xff ] + _lut[ d3 >> 24 & 0xff ];
|
|
|
|
|
|
- // .toUpperCase() here flattens concatenated strings to save heap memory space.
|
|
|
- return uuid.toUpperCase();
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- clamp: function ( value, min, max ) {
|
|
|
-
|
|
|
- return Math.max( min, Math.min( max, value ) );
|
|
|
+ // .toUpperCase() here flattens concatenated strings to save heap memory space.
|
|
|
+ return uuid.toUpperCase();
|
|
|
|
|
|
- },
|
|
|
+}
|
|
|
|
|
|
- // compute euclidian modulo of m % n
|
|
|
- // https://en.wikipedia.org/wiki/Modulo_operation
|
|
|
+function clamp( value, min, max ) {
|
|
|
|
|
|
- euclideanModulo: function ( n, m ) {
|
|
|
+ return Math.max( min, Math.min( max, value ) );
|
|
|
|
|
|
- return ( ( n % m ) + m ) % m;
|
|
|
+}
|
|
|
|
|
|
- },
|
|
|
+// compute euclidian modulo of m % n
|
|
|
+// https://en.wikipedia.org/wiki/Modulo_operation
|
|
|
+function euclideanModulo( n, m ) {
|
|
|
|
|
|
- // Linear mapping from range <a1, a2> to range <b1, b2>
|
|
|
+ return ( ( n % m ) + m ) % m;
|
|
|
|
|
|
- mapLinear: function ( x, a1, a2, b1, b2 ) {
|
|
|
+}
|
|
|
|
|
|
- return b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 );
|
|
|
+// Linear mapping from range <a1, a2> to range <b1, b2>
|
|
|
+function mapLinear( x, a1, a2, b1, b2 ) {
|
|
|
|
|
|
- },
|
|
|
+ return b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 );
|
|
|
|
|
|
- // https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/inverse-lerp-a-super-useful-yet-often-overlooked-function-r5230/
|
|
|
+}
|
|
|
|
|
|
- inverseLerp: function ( x, y, value ) {
|
|
|
+// https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/inverse-lerp-a-super-useful-yet-often-overlooked-function-r5230/
|
|
|
+function inverseLerp( x, y, value ) {
|
|
|
|
|
|
- if ( x !== y ) {
|
|
|
+ if ( x !== y ) {
|
|
|
|
|
|
- return ( value - x ) / ( y - x );
|
|
|
+ return ( value - x ) / ( y - x );
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- return 0;
|
|
|
+ return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
- },
|
|
|
-
|
|
|
- // https://en.wikipedia.org/wiki/Linear_interpolation
|
|
|
-
|
|
|
- lerp: function ( x, y, t ) {
|
|
|
-
|
|
|
- return ( 1 - t ) * x + t * y;
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- // http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/
|
|
|
-
|
|
|
- damp: function ( x, y, lambda, dt ) {
|
|
|
-
|
|
|
- return MathUtils.lerp( x, y, 1 - Math.exp( - lambda * dt ) );
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- // https://www.desmos.com/calculator/vcsjnyz7x4
|
|
|
+}
|
|
|
|
|
|
- pingpong: function ( x, length = 1 ) {
|
|
|
+// https://en.wikipedia.org/wiki/Linear_interpolation
|
|
|
+function lerp( x, y, t ) {
|
|
|
|
|
|
- return length - Math.abs( MathUtils.euclideanModulo( x, length * 2 ) - length );
|
|
|
+ return ( 1 - t ) * x + t * y;
|
|
|
|
|
|
- },
|
|
|
+}
|
|
|
|
|
|
- // http://en.wikipedia.org/wiki/Smoothstep
|
|
|
+// http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/
|
|
|
+function damp( x, y, lambda, dt ) {
|
|
|
|
|
|
- smoothstep: function ( x, min, max ) {
|
|
|
+ return lerp( x, y, 1 - Math.exp( - lambda * dt ) );
|
|
|
|
|
|
- if ( x <= min ) return 0;
|
|
|
- if ( x >= max ) return 1;
|
|
|
+}
|
|
|
|
|
|
- x = ( x - min ) / ( max - min );
|
|
|
+// https://www.desmos.com/calculator/vcsjnyz7x4
|
|
|
+function pingpong( x, length = 1 ) {
|
|
|
|
|
|
- return x * x * ( 3 - 2 * x );
|
|
|
+ return length - Math.abs( euclideanModulo( x, length * 2 ) - length );
|
|
|
|
|
|
- },
|
|
|
+}
|
|
|
|
|
|
- smootherstep: function ( x, min, max ) {
|
|
|
+// http://en.wikipedia.org/wiki/Smoothstep
|
|
|
+function smoothstep( x, min, max ) {
|
|
|
|
|
|
- if ( x <= min ) return 0;
|
|
|
- if ( x >= max ) return 1;
|
|
|
+ if ( x <= min ) return 0;
|
|
|
+ if ( x >= max ) return 1;
|
|
|
|
|
|
- x = ( x - min ) / ( max - min );
|
|
|
+ x = ( x - min ) / ( max - min );
|
|
|
|
|
|
- return x * x * x * ( x * ( x * 6 - 15 ) + 10 );
|
|
|
+ return x * x * ( 3 - 2 * x );
|
|
|
|
|
|
- },
|
|
|
+}
|
|
|
|
|
|
- // Random integer from <low, high> interval
|
|
|
+function smootherstep( x, min, max ) {
|
|
|
|
|
|
- randInt: function ( low, high ) {
|
|
|
+ if ( x <= min ) return 0;
|
|
|
+ if ( x >= max ) return 1;
|
|
|
|
|
|
- return low + Math.floor( Math.random() * ( high - low + 1 ) );
|
|
|
+ x = ( x - min ) / ( max - min );
|
|
|
|
|
|
- },
|
|
|
+ return x * x * x * ( x * ( x * 6 - 15 ) + 10 );
|
|
|
|
|
|
- // Random float from <low, high> interval
|
|
|
+}
|
|
|
|
|
|
- randFloat: function ( low, high ) {
|
|
|
+// Random integer from <low, high> interval
|
|
|
+function randInt( low, high ) {
|
|
|
|
|
|
- return low + Math.random() * ( high - low );
|
|
|
+ return low + Math.floor( Math.random() * ( high - low + 1 ) );
|
|
|
|
|
|
- },
|
|
|
+}
|
|
|
|
|
|
- // Random float from <-range/2, range/2> interval
|
|
|
+// Random float from <low, high> interval
|
|
|
+function randFloat( low, high ) {
|
|
|
|
|
|
- randFloatSpread: function ( range ) {
|
|
|
+ return low + Math.random() * ( high - low );
|
|
|
|
|
|
- return range * ( 0.5 - Math.random() );
|
|
|
+}
|
|
|
|
|
|
- },
|
|
|
+// Random float from <-range/2, range/2> interval
|
|
|
+function randFloatSpread( range ) {
|
|
|
|
|
|
- // Deterministic pseudo-random float in the interval [ 0, 1 ]
|
|
|
+ return range * ( 0.5 - Math.random() );
|
|
|
|
|
|
- seededRandom: function ( s ) {
|
|
|
+}
|
|
|
|
|
|
- if ( s !== undefined ) _seed = s % 2147483647;
|
|
|
+// Deterministic pseudo-random float in the interval [ 0, 1 ]
|
|
|
+function seededRandom( s ) {
|
|
|
|
|
|
- // Park-Miller algorithm
|
|
|
+ if ( s !== undefined ) _seed = s % 2147483647;
|
|
|
|
|
|
- _seed = _seed * 16807 % 2147483647;
|
|
|
+ // Park-Miller algorithm
|
|
|
|
|
|
- return ( _seed - 1 ) / 2147483646;
|
|
|
+ _seed = _seed * 16807 % 2147483647;
|
|
|
|
|
|
- },
|
|
|
+ return ( _seed - 1 ) / 2147483646;
|
|
|
|
|
|
- degToRad: function ( degrees ) {
|
|
|
+}
|
|
|
|
|
|
- return degrees * MathUtils.DEG2RAD;
|
|
|
+function degToRad( degrees ) {
|
|
|
|
|
|
- },
|
|
|
+ return degrees * DEG2RAD;
|
|
|
|
|
|
- radToDeg: function ( radians ) {
|
|
|
+}
|
|
|
|
|
|
- return radians * MathUtils.RAD2DEG;
|
|
|
+function radToDeg( radians ) {
|
|
|
|
|
|
- },
|
|
|
+ return radians * RAD2DEG;
|
|
|
|
|
|
- isPowerOfTwo: function ( value ) {
|
|
|
+}
|
|
|
|
|
|
- return ( value & ( value - 1 ) ) === 0 && value !== 0;
|
|
|
+function isPowerOfTwo( value ) {
|
|
|
|
|
|
- },
|
|
|
+ return ( value & ( value - 1 ) ) === 0 && value !== 0;
|
|
|
|
|
|
- ceilPowerOfTwo: function ( value ) {
|
|
|
+}
|
|
|
|
|
|
- return Math.pow( 2, Math.ceil( Math.log( value ) / Math.LN2 ) );
|
|
|
+function ceilPowerOfTwo( value ) {
|
|
|
|
|
|
- },
|
|
|
+ return Math.pow( 2, Math.ceil( Math.log( value ) / Math.LN2 ) );
|
|
|
|
|
|
- floorPowerOfTwo: function ( value ) {
|
|
|
+}
|
|
|
|
|
|
- return Math.pow( 2, Math.floor( Math.log( value ) / Math.LN2 ) );
|
|
|
+function floorPowerOfTwo( value ) {
|
|
|
|
|
|
- },
|
|
|
+ return Math.pow( 2, Math.floor( Math.log( value ) / Math.LN2 ) );
|
|
|
|
|
|
- setQuaternionFromProperEuler: function ( q, a, b, c, order ) {
|
|
|
+}
|
|
|
|
|
|
- // Intrinsic Proper Euler Angles - see https://en.wikipedia.org/wiki/Euler_angles
|
|
|
+function setQuaternionFromProperEuler( q, a, b, c, order ) {
|
|
|
|
|
|
- // rotations are applied to the axes in the order specified by 'order'
|
|
|
- // rotation by angle 'a' is applied first, then by angle 'b', then by angle 'c'
|
|
|
- // angles are in radians
|
|
|
+ // Intrinsic Proper Euler Angles - see https://en.wikipedia.org/wiki/Euler_angles
|
|
|
|
|
|
- const cos = Math.cos;
|
|
|
- const sin = Math.sin;
|
|
|
+ // rotations are applied to the axes in the order specified by 'order'
|
|
|
+ // rotation by angle 'a' is applied first, then by angle 'b', then by angle 'c'
|
|
|
+ // angles are in radians
|
|
|
|
|
|
- const c2 = cos( b / 2 );
|
|
|
- const s2 = sin( b / 2 );
|
|
|
+ const cos = Math.cos;
|
|
|
+ const sin = Math.sin;
|
|
|
|
|
|
- const c13 = cos( ( a + c ) / 2 );
|
|
|
- const s13 = sin( ( a + c ) / 2 );
|
|
|
+ const c2 = cos( b / 2 );
|
|
|
+ const s2 = sin( b / 2 );
|
|
|
|
|
|
- const c1_3 = cos( ( a - c ) / 2 );
|
|
|
- const s1_3 = sin( ( a - c ) / 2 );
|
|
|
+ const c13 = cos( ( a + c ) / 2 );
|
|
|
+ const s13 = sin( ( a + c ) / 2 );
|
|
|
|
|
|
- const c3_1 = cos( ( c - a ) / 2 );
|
|
|
- const s3_1 = sin( ( c - a ) / 2 );
|
|
|
+ const c1_3 = cos( ( a - c ) / 2 );
|
|
|
+ const s1_3 = sin( ( a - c ) / 2 );
|
|
|
|
|
|
- switch ( order ) {
|
|
|
+ const c3_1 = cos( ( c - a ) / 2 );
|
|
|
+ const s3_1 = sin( ( c - a ) / 2 );
|
|
|
|
|
|
- case 'XYX':
|
|
|
- q.set( c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13 );
|
|
|
- break;
|
|
|
+ switch ( order ) {
|
|
|
|
|
|
- case 'YZY':
|
|
|
- q.set( s2 * s1_3, c2 * s13, s2 * c1_3, c2 * c13 );
|
|
|
- break;
|
|
|
+ case 'XYX':
|
|
|
+ q.set( c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13 );
|
|
|
+ break;
|
|
|
|
|
|
- case 'ZXZ':
|
|
|
- q.set( s2 * c1_3, s2 * s1_3, c2 * s13, c2 * c13 );
|
|
|
- break;
|
|
|
+ case 'YZY':
|
|
|
+ q.set( s2 * s1_3, c2 * s13, s2 * c1_3, c2 * c13 );
|
|
|
+ break;
|
|
|
|
|
|
- case 'XZX':
|
|
|
- q.set( c2 * s13, s2 * s3_1, s2 * c3_1, c2 * c13 );
|
|
|
- break;
|
|
|
+ case 'ZXZ':
|
|
|
+ q.set( s2 * c1_3, s2 * s1_3, c2 * s13, c2 * c13 );
|
|
|
+ break;
|
|
|
|
|
|
- case 'YXY':
|
|
|
- q.set( s2 * c3_1, c2 * s13, s2 * s3_1, c2 * c13 );
|
|
|
- break;
|
|
|
+ case 'XZX':
|
|
|
+ q.set( c2 * s13, s2 * s3_1, s2 * c3_1, c2 * c13 );
|
|
|
+ break;
|
|
|
|
|
|
- case 'ZYZ':
|
|
|
- q.set( s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13 );
|
|
|
- break;
|
|
|
+ case 'YXY':
|
|
|
+ q.set( s2 * c3_1, c2 * s13, s2 * s3_1, c2 * c13 );
|
|
|
+ break;
|
|
|
|
|
|
- default:
|
|
|
- console.warn( 'THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ' + order );
|
|
|
+ case 'ZYZ':
|
|
|
+ q.set( s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13 );
|
|
|
+ break;
|
|
|
|
|
|
- }
|
|
|
+ default:
|
|
|
+ console.warn( 'THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ' + order );
|
|
|
|
|
|
}
|
|
|
|
|
|
-};
|
|
|
+}
|
|
|
+
|
|
|
+var MathUtils = /*#__PURE__*/Object.freeze({
|
|
|
+ __proto__: null,
|
|
|
+ DEG2RAD: DEG2RAD,
|
|
|
+ RAD2DEG: RAD2DEG,
|
|
|
+ generateUUID: generateUUID,
|
|
|
+ clamp: clamp,
|
|
|
+ euclideanModulo: euclideanModulo,
|
|
|
+ mapLinear: mapLinear,
|
|
|
+ inverseLerp: inverseLerp,
|
|
|
+ lerp: lerp,
|
|
|
+ damp: damp,
|
|
|
+ pingpong: pingpong,
|
|
|
+ smoothstep: smoothstep,
|
|
|
+ smootherstep: smootherstep,
|
|
|
+ randInt: randInt,
|
|
|
+ randFloat: randFloat,
|
|
|
+ randFloatSpread: randFloatSpread,
|
|
|
+ seededRandom: seededRandom,
|
|
|
+ degToRad: degToRad,
|
|
|
+ radToDeg: radToDeg,
|
|
|
+ isPowerOfTwo: isPowerOfTwo,
|
|
|
+ ceilPowerOfTwo: ceilPowerOfTwo,
|
|
|
+ floorPowerOfTwo: floorPowerOfTwo,
|
|
|
+ setQuaternionFromProperEuler: setQuaternionFromProperEuler
|
|
|
+});
|
|
|
|
|
|
class Vector2 {
|
|
|
|
|
@@ -1422,7 +1433,7 @@ class Texture extends EventDispatcher {
|
|
|
|
|
|
Object.defineProperty( this, 'id', { value: textureId ++ } );
|
|
|
|
|
|
- this.uuid = MathUtils.generateUUID();
|
|
|
+ this.uuid = generateUUID();
|
|
|
|
|
|
this.name = '';
|
|
|
|
|
@@ -1571,7 +1582,7 @@ class Texture extends EventDispatcher {
|
|
|
|
|
|
if ( image.uuid === undefined ) {
|
|
|
|
|
|
- image.uuid = MathUtils.generateUUID(); // UGH
|
|
|
+ image.uuid = generateUUID(); // UGH
|
|
|
|
|
|
}
|
|
|
|
|
@@ -2951,7 +2962,7 @@ class Quaternion {
|
|
|
|
|
|
angleTo( q ) {
|
|
|
|
|
|
- return 2 * Math.acos( Math.abs( MathUtils.clamp( this.dot( q ), - 1, 1 ) ) );
|
|
|
+ return 2 * Math.acos( Math.abs( clamp( this.dot( q ), - 1, 1 ) ) );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -3771,7 +3782,7 @@ class Vector3 {
|
|
|
|
|
|
// clamp, to handle numerical problems
|
|
|
|
|
|
- return Math.acos( MathUtils.clamp( theta, - 1, 1 ) );
|
|
|
+ return Math.acos( clamp( theta, - 1, 1 ) );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -6194,8 +6205,6 @@ class Euler {
|
|
|
|
|
|
setFromRotationMatrix( m, order, update ) {
|
|
|
|
|
|
- const clamp = MathUtils.clamp;
|
|
|
-
|
|
|
// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
|
|
|
|
|
|
const te = m.elements;
|
|
@@ -6492,7 +6501,7 @@ class Object3D extends EventDispatcher {
|
|
|
|
|
|
Object.defineProperty( this, 'id', { value: _object3DId ++ } );
|
|
|
|
|
|
- this.uuid = MathUtils.generateUUID();
|
|
|
+ this.uuid = generateUUID();
|
|
|
|
|
|
this.name = '';
|
|
|
this.type = 'Object3D';
|
|
@@ -7918,7 +7927,7 @@ function Material() {
|
|
|
|
|
|
Object.defineProperty( this, 'id', { value: materialId ++ } );
|
|
|
|
|
|
- this.uuid = MathUtils.generateUUID();
|
|
|
+ this.uuid = generateUUID();
|
|
|
|
|
|
this.name = '';
|
|
|
this.type = 'Material';
|
|
@@ -8487,9 +8496,9 @@ class Color {
|
|
|
setHSL( h, s, l ) {
|
|
|
|
|
|
// h,s,l ranges are in 0.0 - 1.0
|
|
|
- h = MathUtils.euclideanModulo( h, 1 );
|
|
|
- s = MathUtils.clamp( s, 0, 1 );
|
|
|
- l = MathUtils.clamp( l, 0, 1 );
|
|
|
+ h = euclideanModulo( h, 1 );
|
|
|
+ s = clamp( s, 0, 1 );
|
|
|
+ l = clamp( l, 0, 1 );
|
|
|
|
|
|
if ( s === 0 ) {
|
|
|
|
|
@@ -8903,9 +8912,9 @@ class Color {
|
|
|
this.getHSL( _hslA );
|
|
|
color.getHSL( _hslB );
|
|
|
|
|
|
- const h = MathUtils.lerp( _hslA.h, _hslB.h, alpha );
|
|
|
- const s = MathUtils.lerp( _hslA.s, _hslB.s, alpha );
|
|
|
- const l = MathUtils.lerp( _hslA.l, _hslB.l, alpha );
|
|
|
+ const h = lerp( _hslA.h, _hslB.h, alpha );
|
|
|
+ const s = lerp( _hslA.s, _hslB.s, alpha );
|
|
|
+ const l = lerp( _hslA.l, _hslB.l, alpha );
|
|
|
|
|
|
this.setHSL( h, s, l );
|
|
|
|
|
@@ -9642,7 +9651,7 @@ class BufferGeometry extends EventDispatcher {
|
|
|
|
|
|
Object.defineProperty( this, 'id', { value: _id ++ } );
|
|
|
|
|
|
- this.uuid = MathUtils.generateUUID();
|
|
|
+ this.uuid = generateUUID();
|
|
|
|
|
|
this.name = '';
|
|
|
this.type = 'BufferGeometry';
|
|
@@ -11721,7 +11730,7 @@ class PerspectiveCamera extends Camera {
|
|
|
/** see {@link http://www.bobatkins.com/photography/technical/field_of_view.html} */
|
|
|
const vExtentSlope = 0.5 * this.getFilmHeight() / focalLength;
|
|
|
|
|
|
- this.fov = MathUtils.RAD2DEG * 2 * Math.atan( vExtentSlope );
|
|
|
+ this.fov = RAD2DEG * 2 * Math.atan( vExtentSlope );
|
|
|
this.updateProjectionMatrix();
|
|
|
|
|
|
}
|
|
@@ -11731,7 +11740,7 @@ class PerspectiveCamera extends Camera {
|
|
|
*/
|
|
|
getFocalLength() {
|
|
|
|
|
|
- const vExtentSlope = Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov );
|
|
|
+ const vExtentSlope = Math.tan( DEG2RAD * 0.5 * this.fov );
|
|
|
|
|
|
return 0.5 * this.getFilmHeight() / vExtentSlope;
|
|
|
|
|
@@ -11739,8 +11748,8 @@ class PerspectiveCamera extends Camera {
|
|
|
|
|
|
getEffectiveFOV() {
|
|
|
|
|
|
- return MathUtils.RAD2DEG * 2 * Math.atan(
|
|
|
- Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov ) / this.zoom );
|
|
|
+ return RAD2DEG * 2 * Math.atan(
|
|
|
+ Math.tan( DEG2RAD * 0.5 * this.fov ) / this.zoom );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -11838,7 +11847,7 @@ class PerspectiveCamera extends Camera {
|
|
|
updateProjectionMatrix() {
|
|
|
|
|
|
const near = this.near;
|
|
|
- let top = near * Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov ) / this.zoom;
|
|
|
+ let top = near * Math.tan( DEG2RAD * 0.5 * this.fov ) / this.zoom;
|
|
|
let height = 2 * top;
|
|
|
let width = this.aspect * height;
|
|
|
let left = - 0.5 * width;
|
|
@@ -20343,7 +20352,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||
|
|
|
( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) {
|
|
|
|
|
|
- const floor = needsPowerOfTwo ? MathUtils.floorPowerOfTwo : Math.floor;
|
|
|
+ const floor = needsPowerOfTwo ? floorPowerOfTwo : Math.floor;
|
|
|
|
|
|
const width = floor( scale * image.width );
|
|
|
const height = floor( scale * image.height );
|
|
@@ -20382,9 +20391,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
}
|
|
|
|
|
|
- function isPowerOfTwo( image ) {
|
|
|
+ function isPowerOfTwo$1( image ) {
|
|
|
|
|
|
- return MathUtils.isPowerOfTwo( image.width ) && MathUtils.isPowerOfTwo( image.height );
|
|
|
+ return isPowerOfTwo( image.width ) && isPowerOfTwo( image.height );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -20787,10 +20796,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
_gl.pixelStorei( 3317, texture.unpackAlignment );
|
|
|
_gl.pixelStorei( 37443, 0 );
|
|
|
|
|
|
- const needsPowerOfTwo = textureNeedsPowerOfTwo( texture ) && isPowerOfTwo( texture.image ) === false;
|
|
|
+ const needsPowerOfTwo = textureNeedsPowerOfTwo( texture ) && isPowerOfTwo$1( texture.image ) === false;
|
|
|
const image = resizeImage( texture.image, needsPowerOfTwo, false, maxTextureSize );
|
|
|
|
|
|
- const supportsMips = isPowerOfTwo( image ) || isWebGL2,
|
|
|
+ const supportsMips = isPowerOfTwo$1( image ) || isWebGL2,
|
|
|
glFormat = utils.convert( texture.format );
|
|
|
|
|
|
let glType = utils.convert( texture.type ),
|
|
@@ -21017,7 +21026,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
}
|
|
|
|
|
|
const image = cubeImage[ 0 ],
|
|
|
- supportsMips = isPowerOfTwo( image ) || isWebGL2,
|
|
|
+ supportsMips = isPowerOfTwo$1( image ) || isWebGL2,
|
|
|
glFormat = utils.convert( texture.format ),
|
|
|
glType = utils.convert( texture.type ),
|
|
|
glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType );
|
|
@@ -21325,7 +21334,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
|
|
|
const isMultisample = ( renderTarget.isWebGLMultisampleRenderTarget === true );
|
|
|
const isRenderTarget3D = texture.isDataTexture3D || texture.isDataTexture2DArray;
|
|
|
- const supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;
|
|
|
+ const supportsMips = isPowerOfTwo$1( renderTarget ) || isWebGL2;
|
|
|
|
|
|
// Handles WebGL2 RGBFormat fallback - #18858
|
|
|
|
|
@@ -21462,7 +21471,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
const texture = renderTarget.texture;
|
|
|
|
|
|
- const supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;
|
|
|
+ const supportsMips = isPowerOfTwo$1( renderTarget ) || isWebGL2;
|
|
|
|
|
|
if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
|
|
|
|
|
@@ -24861,7 +24870,7 @@ function WebGLRenderer( parameters ) {
|
|
|
|
|
|
|
|
|
let size = Math.sqrt( bones.length * 4 ); // 4 pixels needed for 1 matrix
|
|
|
- size = MathUtils.ceilPowerOfTwo( size );
|
|
|
+ size = ceilPowerOfTwo( size );
|
|
|
size = Math.max( size, 4 );
|
|
|
|
|
|
const boneMatrices = new Float32Array( size * size * 4 ); // 4 floats per RGBA pixel
|
|
@@ -25440,7 +25449,7 @@ class InterleavedBuffer {
|
|
|
|
|
|
this.version = 0;
|
|
|
|
|
|
- this.uuid = MathUtils.generateUUID();
|
|
|
+ this.uuid = generateUUID();
|
|
|
|
|
|
this.onUploadCallback = function () {};
|
|
|
|
|
@@ -25504,7 +25513,7 @@ class InterleavedBuffer {
|
|
|
|
|
|
if ( this.array.buffer._uuid === undefined ) {
|
|
|
|
|
|
- this.array.buffer._uuid = MathUtils.generateUUID();
|
|
|
+ this.array.buffer._uuid = generateUUID();
|
|
|
|
|
|
}
|
|
|
|
|
@@ -25543,7 +25552,7 @@ class InterleavedBuffer {
|
|
|
|
|
|
if ( this.array.buffer._uuid === undefined ) {
|
|
|
|
|
|
- this.array.buffer._uuid = MathUtils.generateUUID();
|
|
|
+ this.array.buffer._uuid = generateUUID();
|
|
|
|
|
|
}
|
|
|
|
|
@@ -26436,7 +26445,7 @@ class Skeleton {
|
|
|
|
|
|
constructor( bones = [], boneInverses = [] ) {
|
|
|
|
|
|
- this.uuid = MathUtils.generateUUID();
|
|
|
+ this.uuid = generateUUID();
|
|
|
|
|
|
this.bones = bones.slice( 0 );
|
|
|
this.boneInverses = boneInverses;
|
|
@@ -28266,7 +28275,7 @@ class EdgesGeometry extends BufferGeometry {
|
|
|
|
|
|
const precisionPoints = 4;
|
|
|
const precision = Math.pow( 10, precisionPoints );
|
|
|
- const thresholdDot = Math.cos( MathUtils.DEG2RAD * thresholdAngle );
|
|
|
+ const thresholdDot = Math.cos( DEG2RAD * thresholdAngle );
|
|
|
|
|
|
const indexAttr = geometry.getIndex();
|
|
|
const positionAttr = geometry.getAttribute( 'position' );
|
|
@@ -30084,7 +30093,7 @@ class LatheGeometry extends BufferGeometry {
|
|
|
|
|
|
// clamp phiLength so it's in range of [ 0, 2PI ]
|
|
|
|
|
|
- phiLength = MathUtils.clamp( phiLength, 0, Math.PI * 2 );
|
|
|
+ phiLength = clamp( phiLength, 0, Math.PI * 2 );
|
|
|
|
|
|
// buffers
|
|
|
|
|
@@ -31678,7 +31687,7 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
|
|
|
},
|
|
|
set: function ( ior ) {
|
|
|
|
|
|
- this.reflectivity = MathUtils.clamp( 2.5 * ( ior - 1 ) / ( ior + 1 ), 0, 1 );
|
|
|
+ this.reflectivity = clamp( 2.5 * ( ior - 1 ) / ( ior + 1 ), 0, 1 );
|
|
|
|
|
|
}
|
|
|
} );
|
|
@@ -33785,7 +33794,7 @@ class AnimationClip {
|
|
|
this.duration = duration;
|
|
|
this.blendMode = blendMode;
|
|
|
|
|
|
- this.uuid = MathUtils.generateUUID();
|
|
|
+ this.uuid = generateUUID();
|
|
|
|
|
|
// this means it should figure out its duration by scanning the tracks
|
|
|
if ( this.duration < 0 ) {
|
|
@@ -35571,7 +35580,7 @@ class Curve {
|
|
|
|
|
|
vec.normalize();
|
|
|
|
|
|
- const theta = Math.acos( MathUtils.clamp( tangents[ i - 1 ].dot( tangents[ i ] ), - 1, 1 ) ); // clamp for floating pt errors
|
|
|
+ const theta = Math.acos( clamp( tangents[ i - 1 ].dot( tangents[ i ] ), - 1, 1 ) ); // clamp for floating pt errors
|
|
|
|
|
|
normals[ i ].applyMatrix4( mat.makeRotationAxis( vec, theta ) );
|
|
|
|
|
@@ -35585,7 +35594,7 @@ class Curve {
|
|
|
|
|
|
if ( closed === true ) {
|
|
|
|
|
|
- let theta = Math.acos( MathUtils.clamp( normals[ 0 ].dot( normals[ segments ] ), - 1, 1 ) );
|
|
|
+ let theta = Math.acos( clamp( normals[ 0 ].dot( normals[ segments ] ), - 1, 1 ) );
|
|
|
theta /= segments;
|
|
|
|
|
|
if ( tangents[ 0 ].dot( vec.crossVectors( normals[ 0 ], normals[ segments ] ) ) > 0 ) {
|
|
@@ -37132,7 +37141,7 @@ class Shape extends Path {
|
|
|
|
|
|
super( points );
|
|
|
|
|
|
- this.uuid = MathUtils.generateUUID();
|
|
|
+ this.uuid = generateUUID();
|
|
|
|
|
|
this.type = 'Shape';
|
|
|
|
|
@@ -37460,7 +37469,7 @@ class SpotLightShadow extends LightShadow {
|
|
|
|
|
|
const camera = this.camera;
|
|
|
|
|
|
- const fov = MathUtils.RAD2DEG * 2 * light.angle * this.focus;
|
|
|
+ const fov = RAD2DEG * 2 * light.angle * this.focus;
|
|
|
const aspect = this.mapSize.width / this.mapSize.height;
|
|
|
const far = light.distance || camera.far;
|
|
|
|
|
@@ -40714,7 +40723,7 @@ class StereoCamera {
|
|
|
const projectionMatrix = camera.projectionMatrix.clone();
|
|
|
const eyeSepHalf = cache.eyeSep / 2;
|
|
|
const eyeSepOnProjection = eyeSepHalf * cache.near / cache.focus;
|
|
|
- const ymax = ( cache.near * Math.tan( MathUtils.DEG2RAD * cache.fov * 0.5 ) ) / cache.zoom;
|
|
|
+ const ymax = ( cache.near * Math.tan( DEG2RAD * cache.fov * 0.5 ) ) / cache.zoom;
|
|
|
let xmin, xmax;
|
|
|
|
|
|
// translate xOffset
|
|
@@ -42554,7 +42563,7 @@ class AnimationObjectGroup {
|
|
|
|
|
|
constructor() {
|
|
|
|
|
|
- this.uuid = MathUtils.generateUUID();
|
|
|
+ this.uuid = generateUUID();
|
|
|
|
|
|
// cached objects followed by the active ones
|
|
|
this._objects = Array.prototype.slice.call( arguments );
|
|
@@ -44654,7 +44663,7 @@ class Spherical {
|
|
|
} else {
|
|
|
|
|
|
this.theta = Math.atan2( x, z );
|
|
|
- this.phi = Math.acos( MathUtils.clamp( y / this.radius, - 1, 1 ) );
|
|
|
+ this.phi = Math.acos( clamp( y / this.radius, - 1, 1 ) );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -45051,7 +45060,7 @@ class Line3 {
|
|
|
|
|
|
if ( clampToLine ) {
|
|
|
|
|
|
- t = MathUtils.clamp( t, 0, 1 );
|
|
|
+ t = clamp( t, 0, 1 );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -47571,29 +47580,6 @@ Line3.prototype.center = function ( optionalTarget ) {
|
|
|
|
|
|
//
|
|
|
|
|
|
-MathUtils.random16 = function () {
|
|
|
-
|
|
|
- console.warn( 'THREE.Math: .random16() has been deprecated. Use Math.random() instead.' );
|
|
|
- return Math.random();
|
|
|
-
|
|
|
-};
|
|
|
-
|
|
|
-MathUtils.nearestPowerOfTwo = function ( value ) {
|
|
|
-
|
|
|
- console.warn( 'THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo().' );
|
|
|
- return MathUtils.floorPowerOfTwo( value );
|
|
|
-
|
|
|
-};
|
|
|
-
|
|
|
-MathUtils.nextPowerOfTwo = function ( value ) {
|
|
|
-
|
|
|
- console.warn( 'THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo().' );
|
|
|
- return MathUtils.ceilPowerOfTwo( value );
|
|
|
-
|
|
|
-};
|
|
|
-
|
|
|
-//
|
|
|
-
|
|
|
Matrix3.prototype.flattenToArrayOffset = function ( array, offset ) {
|
|
|
|
|
|
console.warn( 'THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.' );
|