* You can convert fonts online using facetype.js
- *
* @author Dmitrii Tikhomirov
* Created by treblereel on 4/26/18.
*/
@JsType(isNative = true, namespace = "THREE")
-public class FontLoader {
-
- /**
- * The loadingManager the loader is using. Default is DefaultLoadingManager.
- */
- public LoadingManager manager;
-
- /**
- * The base path from which files will be loaded. See .setPath. Default is undefined.
- */
- public String path;
-
+public class FontLoader extends Loader
- * @return Texture
- */
- public native Texture load(String url, OnLoadCallback extends Texture> onLoad);
-
- /**
- * Begin loading from the given URL and pass the fully loaded texture to onLoad. The method also returns a new texture
- * object which can directly be used for material creation. If you do it this way, the texture may pop up in your scene
- * once the respective loading process is finished.
- *
- * @param url — the path or URL to the file. This can also be a Data URI.
- * @param onLoad — Will be called when load completes. The argument will be the loaded texture.
- * @param onProgress — Will be called while load progresses. The argument will be the XMLHttpRequest instance, which contains .total and .loaded bytes.
- *
- * @return Texture
- */
- public native Texture load(String url, OnLoadCallback extends Texture> onLoad, OnProgressCallback onProgress);
-
- /**
- * Begin loading from the given URL and pass the fully loaded texture to onLoad. The method also returns a new texture
- * object which can directly be used for material creation. If you do it this way, the texture may pop up in your scene
- * once the respective loading process is finished.
- *
- * @param url — the path or URL to the file. This can also be a Data URI.
- * @param onLoad — Will be called when load completes. The argument will be the loaded texture.
- * @param onProgress — Will be called while load progresses. The argument will be the XMLHttpRequest instance, which contains .total and .loaded bytes.
- * @param onError — Will be called when load errors.
- *
- * @return Texture
- */
- public native Texture load(String url, OnLoadCallback extends Texture> onLoad, OnProgressCallback onProgress, OnErrorCallback onError);
-
- /**
- * Set the .crossOrigin attribute.
- *
- * @param value crossOrigin attribute
- */
- public native void setCrossOrigin(String value);
-
-
- /**
- * Set the base path or URL from which to load files. This can be useful if you are loading many models from the same directory.
- *
- * @param path base path or URL
- * @return instance of TextureLoader
- */
- public native TextureLoader setPath(String path);
-
}
diff --git a/core/src/main/java/org/treblereel/gwt/three4g/materials/MeshPhysicalMaterial.java b/core/src/main/java/org/treblereel/gwt/three4g/materials/MeshPhysicalMaterial.java
index 0759a7cf..6d1a655a 100644
--- a/core/src/main/java/org/treblereel/gwt/three4g/materials/MeshPhysicalMaterial.java
+++ b/core/src/main/java/org/treblereel/gwt/three4g/materials/MeshPhysicalMaterial.java
@@ -17,12 +17,12 @@ public class MeshPhysicalMaterial extends MeshStandardMaterial {
/**
* ClearCoat level, from 0.0 to 1.0. Default is 0.0.
*/
- public float clearCoat;
+ public float clearcoat;
/**
* How rough the clearCoat appears, from 0.0 to 1.0. Default is 0.0.
*/
- public float clearCoatRoughness;
+ public float clearcoatRoughness;
/**
* Used to check whether this or derived classes are mesh physical materials. Default is true.
diff --git a/core/src/main/java/org/treblereel/gwt/three4g/materials/parameters/MeshPhysicalMaterialParameters.java b/core/src/main/java/org/treblereel/gwt/three4g/materials/parameters/MeshPhysicalMaterialParameters.java
index 403afe63..95f2d81a 100644
--- a/core/src/main/java/org/treblereel/gwt/three4g/materials/parameters/MeshPhysicalMaterialParameters.java
+++ b/core/src/main/java/org/treblereel/gwt/three4g/materials/parameters/MeshPhysicalMaterialParameters.java
@@ -13,12 +13,12 @@ public class MeshPhysicalMaterialParameters extends MeshStandardMaterialParamete
/**
* ClearCoat level, from 0.0 to 1.0. Default is 0.0.
*/
- public float clearCoat;
+ public float clearcoat;
/**
* How rough the clearCoat appears, from 0.0 to 1.0. Default is 0.0.
*/
- public float clearCoatRoughness;
+ public float clearcoatRoughness;
/**
* An object of the form:
diff --git a/core/src/main/resources/org/treblereel/gwt/three4g/resources/js/three.js b/core/src/main/resources/org/treblereel/gwt/three4g/resources/js/three.js
index 79f72980..00aeed27 100644
--- a/core/src/main/resources/org/treblereel/gwt/three4g/resources/js/three.js
+++ b/core/src/main/resources/org/treblereel/gwt/three4g/resources/js/three.js
@@ -61,31 +61,27 @@
// Missing in IE
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
- ( function () {
+ Object.assign = function ( target ) {
- Object.assign = function ( target ) {
+ if ( target === undefined || target === null ) {
- if ( target === undefined || target === null ) {
+ throw new TypeError( 'Cannot convert undefined or null to object' );
- throw new TypeError( 'Cannot convert undefined or null to object' );
-
- }
-
- var output = Object( target );
+ }
- for ( var index = 1; index < arguments.length; index ++ ) {
+ var output = Object( target );
- var source = arguments[ index ];
+ for ( var index = 1; index < arguments.length; index ++ ) {
- if ( source !== undefined && source !== null ) {
+ var source = arguments[ index ];
- for ( var nextKey in source ) {
+ if ( source !== undefined && source !== null ) {
- if ( Object.prototype.hasOwnProperty.call( source, nextKey ) ) {
+ for ( var nextKey in source ) {
- output[ nextKey ] = source[ nextKey ];
+ if ( Object.prototype.hasOwnProperty.call( source, nextKey ) ) {
- }
+ output[ nextKey ] = source[ nextKey ];
}
@@ -93,11 +89,11 @@
}
- return output;
+ }
- };
+ return output;
- } )();
+ };
}
@@ -185,7 +181,7 @@
} );
- var REVISION = '107';
+ var REVISION = '108';
var MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
var TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
var CullFaceNone = 0;
@@ -197,6 +193,7 @@
var BasicShadowMap = 0;
var PCFShadowMap = 1;
var PCFSoftShadowMap = 2;
+ var VSMShadowMap = 3;
var FrontSide = 0;
var BackSide = 1;
var DoubleSide = 2;
@@ -358,40 +355,36 @@
* @author mrdoob / http://mrdoob.com/
*/
- var _Math = {
-
- DEG2RAD: Math.PI / 180,
- RAD2DEG: 180 / Math.PI,
+ var _lut = [];
- generateUUID: ( function () {
+ for ( var i = 0; i < 256; i ++ ) {
- // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
-
- var lut = [];
+ _lut[ i ] = ( i < 16 ? '0' : '' ) + ( i ).toString( 16 );
- for ( var i = 0; i < 256; i ++ ) {
+ }
- lut[ i ] = ( i < 16 ? '0' : '' ) + ( i ).toString( 16 );
+ var _Math = {
- }
+ DEG2RAD: Math.PI / 180,
+ RAD2DEG: 180 / Math.PI,
- return function generateUUID() {
+ generateUUID: function () {
- var d0 = Math.random() * 0xffffffff | 0;
- var d1 = Math.random() * 0xffffffff | 0;
- var d2 = Math.random() * 0xffffffff | 0;
- var d3 = Math.random() * 0xffffffff | 0;
- var 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 ];
+ // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
- // .toUpperCase() here flattens concatenated strings to save heap memory space.
- return uuid.toUpperCase();
+ var d0 = Math.random() * 0xffffffff | 0;
+ var d1 = Math.random() * 0xffffffff | 0;
+ var d2 = Math.random() * 0xffffffff | 0;
+ var d3 = Math.random() * 0xffffffff | 0;
+ var 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 ) {
@@ -1635,6 +1628,9 @@
* @author WestLangley / http://github.com/WestLangley
*/
+ var _vector = new Vector3();
+ var _quaternion = new Quaternion();
+
function Vector3( x, y, z ) {
this.x = x || 0;
@@ -1856,35 +1852,23 @@
},
- applyEuler: function () {
-
- var quaternion = new Quaternion();
+ applyEuler: function ( euler ) {
- return function applyEuler( euler ) {
-
- if ( ! ( euler && euler.isEuler ) ) {
-
- console.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' );
-
- }
-
- return this.applyQuaternion( quaternion.setFromEuler( euler ) );
-
- };
+ if ( ! ( euler && euler.isEuler ) ) {
- }(),
+ console.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' );
- applyAxisAngle: function () {
+ }
- var quaternion = new Quaternion();
+ return this.applyQuaternion( _quaternion.setFromEuler( euler ) );
- return function applyAxisAngle( axis, angle ) {
+ },
- return this.applyQuaternion( quaternion.setFromAxisAngle( axis, angle ) );
+ applyAxisAngle: function ( axis, angle ) {
- };
+ return this.applyQuaternion( _quaternion.setFromAxisAngle( axis, angle ) );
- }(),
+ },
applyMatrix3: function ( m ) {
@@ -2168,34 +2152,22 @@
},
- projectOnPlane: function () {
-
- var v1 = new Vector3();
+ projectOnPlane: function ( planeNormal ) {
- return function projectOnPlane( planeNormal ) {
+ _vector.copy( this ).projectOnVector( planeNormal );
- v1.copy( this ).projectOnVector( planeNormal );
+ return this.sub( _vector );
- return this.sub( v1 );
-
- };
-
- }(),
+ },
- reflect: function () {
+ reflect: function ( normal ) {
// reflect incident vector off plane orthogonal to normal
// normal is assumed to have unit length
- var v1 = new Vector3();
+ return this.sub( _vector.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
- return function reflect( normal ) {
-
- return this.sub( v1.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
-
- };
-
- }(),
+ },
angleTo: function ( v ) {
@@ -2349,7 +2321,7 @@
* @author tschw
*/
- var _vector;
+ var _vector$1 = new Vector3();
function Matrix3() {
@@ -2436,17 +2408,15 @@
applyToBufferAttribute: function ( attribute ) {
- if ( _vector === undefined ) _vector = new Vector3();
-
for ( var i = 0, l = attribute.count; i < l; i ++ ) {
- _vector.x = attribute.getX( i );
- _vector.y = attribute.getY( i );
- _vector.z = attribute.getZ( i );
+ _vector$1.x = attribute.getX( i );
+ _vector$1.y = attribute.getY( i );
+ _vector$1.z = attribute.getZ( i );
- _vector.applyMatrix3( this );
+ _vector$1.applyMatrix3( this );
- attribute.setXYZ( i, _vector.x, _vector.y, _vector.z );
+ attribute.setXYZ( i, _vector$1.x, _vector$1.y, _vector$1.z );
}
@@ -3873,6 +3843,14 @@
} );
+ var _v1 = new Vector3();
+ var _m1 = new Matrix4();
+ var _zero = new Vector3( 0, 0, 0 );
+ var _one = new Vector3( 1, 1, 1 );
+ var _x = new Vector3();
+ var _y = new Vector3();
+ var _z = new Vector3();
+
/**
* @author mrdoob / http://mrdoob.com/
* @author supereggbert / http://www.paulbrunt.co.uk/
@@ -3992,46 +3970,40 @@
},
- extractRotation: function () {
-
- var v1 = new Vector3();
+ extractRotation: function ( m ) {
- return function extractRotation( m ) {
+ // this method does not support reflection matrices
- // this method does not support reflection matrices
-
- var te = this.elements;
- var me = m.elements;
-
- var scaleX = 1 / v1.setFromMatrixColumn( m, 0 ).length();
- var scaleY = 1 / v1.setFromMatrixColumn( m, 1 ).length();
- var scaleZ = 1 / v1.setFromMatrixColumn( m, 2 ).length();
+ var te = this.elements;
+ var me = m.elements;
- te[ 0 ] = me[ 0 ] * scaleX;
- te[ 1 ] = me[ 1 ] * scaleX;
- te[ 2 ] = me[ 2 ] * scaleX;
- te[ 3 ] = 0;
+ var scaleX = 1 / _v1.setFromMatrixColumn( m, 0 ).length();
+ var scaleY = 1 / _v1.setFromMatrixColumn( m, 1 ).length();
+ var scaleZ = 1 / _v1.setFromMatrixColumn( m, 2 ).length();
- te[ 4 ] = me[ 4 ] * scaleY;
- te[ 5 ] = me[ 5 ] * scaleY;
- te[ 6 ] = me[ 6 ] * scaleY;
- te[ 7 ] = 0;
+ te[ 0 ] = me[ 0 ] * scaleX;
+ te[ 1 ] = me[ 1 ] * scaleX;
+ te[ 2 ] = me[ 2 ] * scaleX;
+ te[ 3 ] = 0;
- te[ 8 ] = me[ 8 ] * scaleZ;
- te[ 9 ] = me[ 9 ] * scaleZ;
- te[ 10 ] = me[ 10 ] * scaleZ;
- te[ 11 ] = 0;
+ te[ 4 ] = me[ 4 ] * scaleY;
+ te[ 5 ] = me[ 5 ] * scaleY;
+ te[ 6 ] = me[ 6 ] * scaleY;
+ te[ 7 ] = 0;
- te[ 12 ] = 0;
- te[ 13 ] = 0;
- te[ 14 ] = 0;
- te[ 15 ] = 1;
+ te[ 8 ] = me[ 8 ] * scaleZ;
+ te[ 9 ] = me[ 9 ] * scaleZ;
+ te[ 10 ] = me[ 10 ] * scaleZ;
+ te[ 11 ] = 0;
- return this;
+ te[ 12 ] = 0;
+ te[ 13 ] = 0;
+ te[ 14 ] = 0;
+ te[ 15 ] = 1;
- };
+ return this;
- }(),
+ },
makeRotationFromEuler: function ( euler ) {
@@ -4161,73 +4133,58 @@
},
- makeRotationFromQuaternion: function () {
-
- var zero = new Vector3( 0, 0, 0 );
- var one = new Vector3( 1, 1, 1 );
+ makeRotationFromQuaternion: function ( q ) {
- return function makeRotationFromQuaternion( q ) {
+ return this.compose( _zero, q, _one );
- return this.compose( zero, q, one );
-
- };
-
- }(),
-
- lookAt: function () {
-
- var x = new Vector3();
- var y = new Vector3();
- var z = new Vector3();
-
- return function lookAt( eye, target, up ) {
+ },
- var te = this.elements;
+ lookAt: function ( eye, target, up ) {
- z.subVectors( eye, target );
+ var te = this.elements;
- if ( z.lengthSq() === 0 ) {
+ _z.subVectors( eye, target );
- // eye and target are in the same position
+ if ( _z.lengthSq() === 0 ) {
- z.z = 1;
+ // eye and target are in the same position
- }
+ _z.z = 1;
- z.normalize();
- x.crossVectors( up, z );
-
- if ( x.lengthSq() === 0 ) {
+ }
- // up and z are parallel
+ _z.normalize();
+ _x.crossVectors( up, _z );
- if ( Math.abs( up.z ) === 1 ) {
+ if ( _x.lengthSq() === 0 ) {
- z.x += 0.0001;
+ // up and z are parallel
- } else {
+ if ( Math.abs( up.z ) === 1 ) {
- z.z += 0.0001;
+ _z.x += 0.0001;
- }
+ } else {
- z.normalize();
- x.crossVectors( up, z );
+ _z.z += 0.0001;
}
- x.normalize();
- y.crossVectors( z, x );
+ _z.normalize();
+ _x.crossVectors( up, _z );
- te[ 0 ] = x.x; te[ 4 ] = y.x; te[ 8 ] = z.x;
- te[ 1 ] = x.y; te[ 5 ] = y.y; te[ 9 ] = z.y;
- te[ 2 ] = x.z; te[ 6 ] = y.z; te[ 10 ] = z.z;
+ }
- return this;
+ _x.normalize();
+ _y.crossVectors( _z, _x );
- };
+ te[ 0 ] = _x.x; te[ 4 ] = _y.x; te[ 8 ] = _z.x;
+ te[ 1 ] = _x.y; te[ 5 ] = _y.y; te[ 9 ] = _z.y;
+ te[ 2 ] = _x.z; te[ 6 ] = _y.z; te[ 10 ] = _z.z;
- }(),
+ return this;
+
+ },
multiply: function ( m, n ) {
@@ -4301,29 +4258,23 @@
},
- applyToBufferAttribute: function () {
-
- var v1 = new Vector3();
-
- return function applyToBufferAttribute( attribute ) {
-
- for ( var i = 0, l = attribute.count; i < l; i ++ ) {
+ applyToBufferAttribute: function ( attribute ) {
- v1.x = attribute.getX( i );
- v1.y = attribute.getY( i );
- v1.z = attribute.getZ( i );
+ for ( var i = 0, l = attribute.count; i < l; i ++ ) {
- v1.applyMatrix4( this );
+ _v1.x = attribute.getX( i );
+ _v1.y = attribute.getY( i );
+ _v1.z = attribute.getZ( i );
- attribute.setXYZ( i, v1.x, v1.y, v1.z );
+ _v1.applyMatrix4( this );
- }
+ attribute.setXYZ( i, _v1.x, _v1.y, _v1.z );
- return attribute;
+ }
- };
+ return attribute;
- }(),
+ },
determinant: function () {
@@ -4657,57 +4608,50 @@
},
- decompose: function () {
-
- var vector = new Vector3();
- var matrix = new Matrix4();
+ decompose: function ( position, quaternion, scale ) {
- return function decompose( position, quaternion, scale ) {
-
- var te = this.elements;
-
- var sx = vector.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length();
- var sy = vector.set( te[ 4 ], te[ 5 ], te[ 6 ] ).length();
- var sz = vector.set( te[ 8 ], te[ 9 ], te[ 10 ] ).length();
+ var te = this.elements;
- // if determine is negative, we need to invert one scale
- var det = this.determinant();
- if ( det < 0 ) sx = - sx;
+ var sx = _v1.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length();
+ var sy = _v1.set( te[ 4 ], te[ 5 ], te[ 6 ] ).length();
+ var sz = _v1.set( te[ 8 ], te[ 9 ], te[ 10 ] ).length();
- position.x = te[ 12 ];
- position.y = te[ 13 ];
- position.z = te[ 14 ];
+ // if determine is negative, we need to invert one scale
+ var det = this.determinant();
+ if ( det < 0 ) sx = - sx;
- // scale the rotation part
- matrix.copy( this );
+ position.x = te[ 12 ];
+ position.y = te[ 13 ];
+ position.z = te[ 14 ];
- var invSX = 1 / sx;
- var invSY = 1 / sy;
- var invSZ = 1 / sz;
+ // scale the rotation part
+ _m1.copy( this );
- matrix.elements[ 0 ] *= invSX;
- matrix.elements[ 1 ] *= invSX;
- matrix.elements[ 2 ] *= invSX;
+ var invSX = 1 / sx;
+ var invSY = 1 / sy;
+ var invSZ = 1 / sz;
- matrix.elements[ 4 ] *= invSY;
- matrix.elements[ 5 ] *= invSY;
- matrix.elements[ 6 ] *= invSY;
+ _m1.elements[ 0 ] *= invSX;
+ _m1.elements[ 1 ] *= invSX;
+ _m1.elements[ 2 ] *= invSX;
- matrix.elements[ 8 ] *= invSZ;
- matrix.elements[ 9 ] *= invSZ;
- matrix.elements[ 10 ] *= invSZ;
+ _m1.elements[ 4 ] *= invSY;
+ _m1.elements[ 5 ] *= invSY;
+ _m1.elements[ 6 ] *= invSY;
- quaternion.setFromRotationMatrix( matrix );
+ _m1.elements[ 8 ] *= invSZ;
+ _m1.elements[ 9 ] *= invSZ;
+ _m1.elements[ 10 ] *= invSZ;
- scale.x = sx;
- scale.y = sy;
- scale.z = sz;
+ quaternion.setFromRotationMatrix( _m1 );
- return this;
+ scale.x = sx;
+ scale.y = sy;
+ scale.z = sz;
- };
+ return this;
- }(),
+ },
makePerspective: function ( left, right, top, bottom, near, far ) {
@@ -4823,7 +4767,8 @@
* @author bhouston / http://clara.io
*/
- var _matrix, _quaternion;
+ var _matrix = new Matrix4();
+ var _quaternion$1 = new Quaternion();
function Euler( x, y, z, order ) {
@@ -4963,7 +4908,7 @@
this._y = Math.asin( clamp( m13, - 1, 1 ) );
- if ( Math.abs( m13 ) < 0.99999 ) {
+ if ( Math.abs( m13 ) < 0.9999999 ) {
this._x = Math.atan2( - m23, m33 );
this._z = Math.atan2( - m12, m11 );
@@ -4979,7 +4924,7 @@
this._x = Math.asin( - clamp( m23, - 1, 1 ) );
- if ( Math.abs( m23 ) < 0.99999 ) {
+ if ( Math.abs( m23 ) < 0.9999999 ) {
this._y = Math.atan2( m13, m33 );
this._z = Math.atan2( m21, m22 );
@@ -4995,7 +4940,7 @@
this._x = Math.asin( clamp( m32, - 1, 1 ) );
- if ( Math.abs( m32 ) < 0.99999 ) {
+ if ( Math.abs( m32 ) < 0.9999999 ) {
this._y = Math.atan2( - m31, m33 );
this._z = Math.atan2( - m12, m22 );
@@ -5011,7 +4956,7 @@
this._y = Math.asin( - clamp( m31, - 1, 1 ) );
- if ( Math.abs( m31 ) < 0.99999 ) {
+ if ( Math.abs( m31 ) < 0.9999999 ) {
this._x = Math.atan2( m32, m33 );
this._z = Math.atan2( m21, m11 );
@@ -5027,7 +4972,7 @@
this._z = Math.asin( clamp( m21, - 1, 1 ) );
- if ( Math.abs( m21 ) < 0.99999 ) {
+ if ( Math.abs( m21 ) < 0.9999999 ) {
this._x = Math.atan2( - m23, m22 );
this._y = Math.atan2( - m31, m11 );
@@ -5043,7 +4988,7 @@
this._z = Math.asin( - clamp( m12, - 1, 1 ) );
- if ( Math.abs( m12 ) < 0.99999 ) {
+ if ( Math.abs( m12 ) < 0.9999999 ) {
this._x = Math.atan2( m32, m22 );
this._y = Math.atan2( m13, m11 );
@@ -5071,8 +5016,6 @@
setFromQuaternion: function ( q, order, update ) {
- if ( _matrix === undefined ) _matrix = new Matrix4();
-
_matrix.makeRotationFromQuaternion( q );
return this.setFromRotationMatrix( _matrix, order, update );
@@ -5089,11 +5032,9 @@
// WARNING: this discards revolution information -bhouston
- if ( _quaternion === undefined ) _quaternion = new Quaternion();
+ _quaternion$1.setFromEuler( this );
- _quaternion.setFromEuler( this );
-
- return this.setFromQuaternion( _quaternion, newOrder );
+ return this.setFromQuaternion( _quaternion$1, newOrder );
},
@@ -5180,6 +5121,12 @@
},
+ enableAll: function () {
+
+ this.mask = 0xffffffff | 0;
+
+ },
+
toggle: function ( channel ) {
this.mask ^= 1 << channel | 0;
@@ -5192,6 +5139,12 @@
},
+ disableAll: function () {
+
+ this.mask = 0;
+
+ },
+
test: function ( layers ) {
return ( this.mask & layers.mask ) !== 0;
@@ -5200,6 +5153,24 @@
} );
+ var _object3DId = 0;
+
+ var _v1$1 = new Vector3();
+ var _q1 = new Quaternion();
+ var _m1$1 = new Matrix4();
+ var _target = new Vector3();
+
+ var _position = new Vector3();
+ var _scale = new Vector3();
+ var _quaternion$2 = new Quaternion();
+
+ var _xAxis = new Vector3( 1, 0, 0 );
+ var _yAxis = new Vector3( 0, 1, 0 );
+ var _zAxis = new Vector3( 0, 0, 1 );
+
+ var _addedEvent = { type: 'added' };
+ var _removedEvent = { type: 'removed' };
+
/**
* @author mrdoob / http://mrdoob.com/
* @author mikael emtinger / http://gomo.se/
@@ -5208,11 +5179,9 @@
* @author elephantatwork / www.elephantatwork.ch
*/
- var object3DId = 0;
-
function Object3D() {
- Object.defineProperty( this, 'id', { value: object3DId ++ } );
+ Object.defineProperty( this, 'id', { value: _object3DId ++ } );
this.uuid = _Math.generateUUID();
@@ -5352,135 +5321,81 @@
},
- rotateOnAxis: function () {
+ rotateOnAxis: function ( axis, angle ) {
// rotate object on axis in object space
// axis is assumed to be normalized
- var q1 = new Quaternion();
-
- return function rotateOnAxis( axis, angle ) {
+ _q1.setFromAxisAngle( axis, angle );
- q1.setFromAxisAngle( axis, angle );
+ this.quaternion.multiply( _q1 );
- this.quaternion.multiply( q1 );
-
- return this;
-
- };
+ return this;
- }(),
+ },
- rotateOnWorldAxis: function () {
+ rotateOnWorldAxis: function ( axis, angle ) {
// rotate object on axis in world space
// axis is assumed to be normalized
// method assumes no rotated parent
- var q1 = new Quaternion();
-
- return function rotateOnWorldAxis( axis, angle ) {
-
- q1.setFromAxisAngle( axis, angle );
+ _q1.setFromAxisAngle( axis, angle );
- this.quaternion.premultiply( q1 );
+ this.quaternion.premultiply( _q1 );
- return this;
-
- };
-
- }(),
-
- rotateX: function () {
-
- var v1 = new Vector3( 1, 0, 0 );
-
- return function rotateX( angle ) {
-
- return this.rotateOnAxis( v1, angle );
-
- };
-
- }(),
-
- rotateY: function () {
+ return this;
- var v1 = new Vector3( 0, 1, 0 );
+ },
- return function rotateY( angle ) {
+ rotateX: function ( angle ) {
- return this.rotateOnAxis( v1, angle );
+ return this.rotateOnAxis( _xAxis, angle );
- };
-
- }(),
+ },
- rotateZ: function () {
+ rotateY: function ( angle ) {
- var v1 = new Vector3( 0, 0, 1 );
+ return this.rotateOnAxis( _yAxis, angle );
- return function rotateZ( angle ) {
+ },
- return this.rotateOnAxis( v1, angle );
+ rotateZ: function ( angle ) {
- };
+ return this.rotateOnAxis( _zAxis, angle );
- }(),
+ },
- translateOnAxis: function () {
+ translateOnAxis: function ( axis, distance ) {
// translate object by distance along axis in object space
// axis is assumed to be normalized
- var v1 = new Vector3();
-
- return function translateOnAxis( axis, distance ) {
-
- v1.copy( axis ).applyQuaternion( this.quaternion );
-
- this.position.add( v1.multiplyScalar( distance ) );
-
- return this;
-
- };
-
- }(),
-
- translateX: function () {
-
- var v1 = new Vector3( 1, 0, 0 );
+ _v1$1.copy( axis ).applyQuaternion( this.quaternion );
- return function translateX( distance ) {
+ this.position.add( _v1$1.multiplyScalar( distance ) );
- return this.translateOnAxis( v1, distance );
-
- };
-
- }(),
-
- translateY: function () {
-
- var v1 = new Vector3( 0, 1, 0 );
+ return this;
- return function translateY( distance ) {
+ },
- return this.translateOnAxis( v1, distance );
+ translateX: function ( distance ) {
- };
+ return this.translateOnAxis( _xAxis, distance );
- }(),
+ },
- translateZ: function () {
+ translateY: function ( distance ) {
- var v1 = new Vector3( 0, 0, 1 );
+ return this.translateOnAxis( _yAxis, distance );
- return function translateZ( distance ) {
+ },
- return this.translateOnAxis( v1, distance );
+ translateZ: function ( distance ) {
- };
+ return this.translateOnAxis( _zAxis, distance );
- }(),
+ },
localToWorld: function ( vector ) {
@@ -5488,68 +5403,53 @@
},
- worldToLocal: function () {
-
- var m1 = new Matrix4();
+ worldToLocal: function ( vector ) {
- return function worldToLocal( vector ) {
+ return vector.applyMatrix4( _m1$1.getInverse( this.matrixWorld ) );
- return vector.applyMatrix4( m1.getInverse( this.matrixWorld ) );
-
- };
-
- }(),
+ },
- lookAt: function () {
+ lookAt: function ( x, y, z ) {
// This method does not support objects having non-uniformly-scaled parent(s)
- var q1 = new Quaternion();
- var m1 = new Matrix4();
- var target = new Vector3();
- var position = new Vector3();
-
- return function lookAt( x, y, z ) {
-
- if ( x.isVector3 ) {
-
- target.copy( x );
+ if ( x.isVector3 ) {
- } else {
+ _target.copy( x );
- target.set( x, y, z );
+ } else {
- }
+ _target.set( x, y, z );
- var parent = this.parent;
+ }
- this.updateWorldMatrix( true, false );
+ var parent = this.parent;
- position.setFromMatrixPosition( this.matrixWorld );
+ this.updateWorldMatrix( true, false );
- if ( this.isCamera || this.isLight ) {
+ _position.setFromMatrixPosition( this.matrixWorld );
- m1.lookAt( position, target, this.up );
+ if ( this.isCamera || this.isLight ) {
- } else {
+ _m1$1.lookAt( _position, _target, this.up );
- m1.lookAt( target, position, this.up );
+ } else {
- }
+ _m1$1.lookAt( _target, _position, this.up );
- this.quaternion.setFromRotationMatrix( m1 );
+ }
- if ( parent ) {
+ this.quaternion.setFromRotationMatrix( _m1$1 );
- m1.extractRotation( parent.matrixWorld );
- q1.setFromRotationMatrix( m1 );
- this.quaternion.premultiply( q1.inverse() );
+ if ( parent ) {
- }
+ _m1$1.extractRotation( parent.matrixWorld );
+ _q1.setFromRotationMatrix( _m1$1 );
+ this.quaternion.premultiply( _q1.inverse() );
- };
+ }
- }(),
+ },
add: function ( object ) {
@@ -5583,7 +5483,7 @@
object.parent = this;
this.children.push( object );
- object.dispatchEvent( { type: 'added' } );
+ object.dispatchEvent( _addedEvent );
} else {
@@ -5616,7 +5516,7 @@
object.parent = null;
this.children.splice( index, 1 );
- object.dispatchEvent( { type: 'removed' } );
+ object.dispatchEvent( _removedEvent );
}
@@ -5624,37 +5524,31 @@
},
- attach: function () {
+ attach: function ( object ) {
// adds object as a child of this, while maintaining the object's world transform
- var m = new Matrix4();
-
- return function attach( object ) {
+ this.updateWorldMatrix( true, false );
- this.updateWorldMatrix( true, false );
+ _m1$1.getInverse( this.matrixWorld );
- m.getInverse( this.matrixWorld );
+ if ( object.parent !== null ) {
- if ( object.parent !== null ) {
+ object.parent.updateWorldMatrix( true, false );
- object.parent.updateWorldMatrix( true, false );
+ _m1$1.multiply( object.parent.matrixWorld );
- m.multiply( object.parent.matrixWorld );
-
- }
-
- object.applyMatrix( m );
+ }
- object.updateWorldMatrix( false, false );
+ object.applyMatrix( _m1$1 );
- this.add( object );
+ object.updateWorldMatrix( false, false );
- return this;
+ this.add( object );
- };
+ return this;
- }(),
+ },
getObjectById: function ( id ) {
@@ -5704,53 +5598,39 @@
},
- getWorldQuaternion: function () {
-
- var position = new Vector3();
- var scale = new Vector3();
+ getWorldQuaternion: function ( target ) {
- return function getWorldQuaternion( target ) {
-
- if ( target === undefined ) {
-
- console.warn( 'THREE.Object3D: .getWorldQuaternion() target is now required' );
- target = new Quaternion();
-
- }
-
- this.updateMatrixWorld( true );
-
- this.matrixWorld.decompose( position, target, scale );
+ if ( target === undefined ) {
- return target;
+ console.warn( 'THREE.Object3D: .getWorldQuaternion() target is now required' );
+ target = new Quaternion();
- };
+ }
- }(),
+ this.updateMatrixWorld( true );
- getWorldScale: function () {
+ this.matrixWorld.decompose( _position, target, _scale );
- var position = new Vector3();
- var quaternion = new Quaternion();
+ return target;
- return function getWorldScale( target ) {
+ },
- if ( target === undefined ) {
+ getWorldScale: function ( target ) {
- console.warn( 'THREE.Object3D: .getWorldScale() target is now required' );
- target = new Vector3();
+ if ( target === undefined ) {
- }
+ console.warn( 'THREE.Object3D: .getWorldScale() target is now required' );
+ target = new Vector3();
- this.updateMatrixWorld( true );
+ }
- this.matrixWorld.decompose( position, quaternion, target );
+ this.updateMatrixWorld( true );
- return target;
+ this.matrixWorld.decompose( _position, _quaternion$2, target );
- };
+ return target;
- }(),
+ },
getWorldDirection: function ( target ) {
@@ -6183,6 +6063,35 @@
} );
+ var _points = [
+ new Vector3(),
+ new Vector3(),
+ new Vector3(),
+ new Vector3(),
+ new Vector3(),
+ new Vector3(),
+ new Vector3(),
+ new Vector3()
+ ];
+ var _vector$2 = new Vector3();
+
+ // triangle centered vertices
+
+ var _v0 = new Vector3();
+ var _v1$2 = new Vector3();
+ var _v2 = new Vector3();
+
+ // triangle edge vectors
+
+ var _f0 = new Vector3();
+ var _f1 = new Vector3();
+ var _f2 = new Vector3();
+
+ var _center = new Vector3();
+ var _extents = new Vector3();
+ var _triangleNormal = new Vector3();
+ var _testAxis = new Vector3();
+
/**
* @author bhouston / http://clara.io
* @author WestLangley / http://github.com/WestLangley
@@ -6288,22 +6197,16 @@
},
- setFromCenterAndSize: function () {
+ setFromCenterAndSize: function ( center, size ) {
- var v1 = new Vector3();
+ var halfSize = _vector$2.copy( size ).multiplyScalar( 0.5 );
- return function setFromCenterAndSize( center, size ) {
+ this.min.copy( center ).sub( halfSize );
+ this.max.copy( center ).add( halfSize );
- var halfSize = v1.copy( size ).multiplyScalar( 0.5 );
-
- this.min.copy( center ).sub( halfSize );
- this.max.copy( center ).add( halfSize );
-
- return this;
-
- };
+ return this;
- }(),
+ },
setFromObject: function ( object ) {
@@ -6398,47 +6301,43 @@
},
- expandByObject: function () {
+ expandByObject: function ( object ) {
+
+ var i, l;
// Computes the world-axis-aligned bounding box of an object (including its children),
// accounting for both the object's, and children's, world transforms
- var scope, i, l;
+ object.updateWorldMatrix( false, false );
- var v1 = new Vector3();
-
- function traverse( node ) {
-
- var geometry = node.geometry;
-
- if ( geometry !== undefined ) {
+ var geometry = object.geometry;
- if ( geometry.isGeometry ) {
+ if ( geometry !== undefined ) {
- var vertices = geometry.vertices;
+ if ( geometry.isGeometry ) {
- for ( i = 0, l = vertices.length; i < l; i ++ ) {
+ var vertices = geometry.vertices;
- v1.copy( vertices[ i ] );
- v1.applyMatrix4( node.matrixWorld );
+ for ( i = 0, l = vertices.length; i < l; i ++ ) {
- scope.expandByPoint( v1 );
+ _vector$2.copy( vertices[ i ] );
+ _vector$2.applyMatrix4( object.matrixWorld );
- }
+ this.expandByPoint( _vector$2 );
- } else if ( geometry.isBufferGeometry ) {
+ }
- var attribute = geometry.attributes.position;
+ } else if ( geometry.isBufferGeometry ) {
- if ( attribute !== undefined ) {
+ var attribute = geometry.attributes.position;
- for ( i = 0, l = attribute.count; i < l; i ++ ) {
+ if ( attribute !== undefined ) {
- v1.fromBufferAttribute( attribute, i ).applyMatrix4( node.matrixWorld );
+ for ( i = 0, l = attribute.count; i < l; i ++ ) {
- scope.expandByPoint( v1 );
+ _vector$2.fromBufferAttribute( attribute, i ).applyMatrix4( object.matrixWorld );
- }
+ this.expandByPoint( _vector$2 );
}
@@ -6448,19 +6347,19 @@
}
- return function expandByObject( object ) {
+ //
- scope = this;
+ var children = object.children;
- object.updateMatrixWorld( true );
+ for ( i = 0, l = children.length; i < l; i ++ ) {
- object.traverse( traverse );
+ this.expandByObject( children[ i ] );
- return this;
+ }
- };
+ return this;
- }(),
+ },
containsPoint: function ( point ) {
@@ -6507,21 +6406,15 @@
},
- intersectsSphere: ( function () {
-
- var closestPoint = new Vector3();
-
- return function intersectsSphere( sphere ) {
-
- // Find the point on the AABB closest to the sphere center.
- this.clampPoint( sphere.center, closestPoint );
+ intersectsSphere: function ( sphere ) {
- // If that point is inside the sphere, the AABB and sphere intersect.
- return closestPoint.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius );
+ // Find the point on the AABB closest to the sphere center.
+ this.clampPoint( sphere.center, _vector$2 );
- };
+ // If that point is inside the sphere, the AABB and sphere intersect.
+ return _vector$2.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius );
- } )(),
+ },
intersectsPlane: function ( plane ) {
@@ -6570,106 +6463,58 @@
},
- intersectsTriangle: ( function () {
-
- // triangle centered vertices
- var v0 = new Vector3();
- var v1 = new Vector3();
- var v2 = new Vector3();
-
- // triangle edge vectors
- var f0 = new Vector3();
- var f1 = new Vector3();
- var f2 = new Vector3();
-
- var testAxis = new Vector3();
-
- var center = new Vector3();
- var extents = new Vector3();
+ intersectsTriangle: function ( triangle ) {
- var triangleNormal = new Vector3();
-
- function satForAxes( axes ) {
-
- var i, j;
-
- for ( i = 0, j = axes.length - 3; i <= j; i += 3 ) {
-
- testAxis.fromArray( axes, i );
- // project the aabb onto the seperating axis
- var r = extents.x * Math.abs( testAxis.x ) + extents.y * Math.abs( testAxis.y ) + extents.z * Math.abs( testAxis.z );
- // project all 3 vertices of the triangle onto the seperating axis
- var p0 = v0.dot( testAxis );
- var p1 = v1.dot( testAxis );
- var p2 = v2.dot( testAxis );
- // actual test, basically see if either of the most extreme of the triangle points intersects r
- if ( Math.max( - Math.max( p0, p1, p2 ), Math.min( p0, p1, p2 ) ) > r ) {
-
- // points of the projected triangle are outside the projected half-length of the aabb
- // the axis is seperating and we can exit
- return false;
-
- }
-
- }
+ if ( this.isEmpty() ) {
- return true;
+ return false;
}
- return function intersectsTriangle( triangle ) {
-
- if ( this.isEmpty() ) {
-
- return false;
-
- }
-
- // compute box center and extents
- this.getCenter( center );
- extents.subVectors( this.max, center );
+ // compute box center and extents
+ this.getCenter( _center );
+ _extents.subVectors( this.max, _center );
- // translate triangle to aabb origin
- v0.subVectors( triangle.a, center );
- v1.subVectors( triangle.b, center );
- v2.subVectors( triangle.c, center );
+ // translate triangle to aabb origin
+ _v0.subVectors( triangle.a, _center );
+ _v1$2.subVectors( triangle.b, _center );
+ _v2.subVectors( triangle.c, _center );
- // compute edge vectors for triangle
- f0.subVectors( v1, v0 );
- f1.subVectors( v2, v1 );
- f2.subVectors( v0, v2 );
+ // compute edge vectors for triangle
+ _f0.subVectors( _v1$2, _v0 );
+ _f1.subVectors( _v2, _v1$2 );
+ _f2.subVectors( _v0, _v2 );
- // test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb
- // make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation
- // axis_ij = u_i x f_j (u0, u1, u2 = face normals of aabb = x,y,z axes vectors since aabb is axis aligned)
- var axes = [
- 0, - f0.z, f0.y, 0, - f1.z, f1.y, 0, - f2.z, f2.y,
- f0.z, 0, - f0.x, f1.z, 0, - f1.x, f2.z, 0, - f2.x,
- - f0.y, f0.x, 0, - f1.y, f1.x, 0, - f2.y, f2.x, 0
- ];
- if ( ! satForAxes( axes ) ) {
+ // test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb
+ // make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation
+ // axis_ij = u_i x f_j (u0, u1, u2 = face normals of aabb = x,y,z axes vectors since aabb is axis aligned)
+ var axes = [
+ 0, - _f0.z, _f0.y, 0, - _f1.z, _f1.y, 0, - _f2.z, _f2.y,
+ _f0.z, 0, - _f0.x, _f1.z, 0, - _f1.x, _f2.z, 0, - _f2.x,
+ - _f0.y, _f0.x, 0, - _f1.y, _f1.x, 0, - _f2.y, _f2.x, 0
+ ];
+ if ( ! satForAxes( axes, _v0, _v1$2, _v2, _extents ) ) {
- return false;
+ return false;
- }
+ }
- // test 3 face normals from the aabb
- axes = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ];
- if ( ! satForAxes( axes ) ) {
+ // test 3 face normals from the aabb
+ axes = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ];
+ if ( ! satForAxes( axes, _v0, _v1$2, _v2, _extents ) ) {
- return false;
+ return false;
- }
+ }
- // finally testing the face normal of the triangle
- // use already existing triangle edge vectors here
- triangleNormal.crossVectors( f0, f1 );
- axes = [ triangleNormal.x, triangleNormal.y, triangleNormal.z ];
- return satForAxes( axes );
+ // finally testing the face normal of the triangle
+ // use already existing triangle edge vectors here
+ _triangleNormal.crossVectors( _f0, _f1 );
+ axes = [ _triangleNormal.x, _triangleNormal.y, _triangleNormal.z ];
- };
+ return satForAxes( axes, _v0, _v1$2, _v2, _extents );
- } )(),
+ },
clampPoint: function ( point, target ) {
@@ -6684,41 +6529,30 @@
},
- distanceToPoint: function () {
-
- var v1 = new Vector3();
-
- return function distanceToPoint( point ) {
-
- var clampedPoint = v1.copy( point ).clamp( this.min, this.max );
- return clampedPoint.sub( point ).length();
-
- };
+ distanceToPoint: function ( point ) {
- }(),
+ var clampedPoint = _vector$2.copy( point ).clamp( this.min, this.max );
- getBoundingSphere: function () {
+ return clampedPoint.sub( point ).length();
- var v1 = new Vector3();
+ },
- return function getBoundingSphere( target ) {
+ getBoundingSphere: function ( target ) {
- if ( target === undefined ) {
+ if ( target === undefined ) {
- console.error( 'THREE.Box3: .getBoundingSphere() target is now required' );
- //target = new Sphere(); // removed to avoid cyclic dependency
+ console.error( 'THREE.Box3: .getBoundingSphere() target is now required' );
+ //target = new Sphere(); // removed to avoid cyclic dependency
- }
-
- this.getCenter( target.center );
+ }
- target.radius = this.getSize( v1 ).length() * 0.5;
+ this.getCenter( target.center );
- return target;
+ target.radius = this.getSize( _vector$2 ).length() * 0.5;
- };
+ return target;
- }(),
+ },
intersect: function ( box ) {
@@ -6741,41 +6575,26 @@
},
- applyMatrix4: function () {
-
- var points = [
- new Vector3(),
- new Vector3(),
- new Vector3(),
- new Vector3(),
- new Vector3(),
- new Vector3(),
- new Vector3(),
- new Vector3()
- ];
-
- return function applyMatrix4( matrix ) {
-
- // transform of empty box is an empty box.
- if ( this.isEmpty() ) return this;
+ applyMatrix4: function ( matrix ) {
- // NOTE: I am using a binary pattern to specify all 2^3 combinations below
- points[ 0 ].set( this.min.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 000
- points[ 1 ].set( this.min.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 001
- points[ 2 ].set( this.min.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 010
- points[ 3 ].set( this.min.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 011
- points[ 4 ].set( this.max.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 100
- points[ 5 ].set( this.max.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 101
- points[ 6 ].set( this.max.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 110
- points[ 7 ].set( this.max.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 111
+ // transform of empty box is an empty box.
+ if ( this.isEmpty() ) return this;
- this.setFromPoints( points );
+ // NOTE: I am using a binary pattern to specify all 2^3 combinations below
+ _points[ 0 ].set( this.min.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 000
+ _points[ 1 ].set( this.min.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 001
+ _points[ 2 ].set( this.min.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 010
+ _points[ 3 ].set( this.min.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 011
+ _points[ 4 ].set( this.max.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 100
+ _points[ 5 ].set( this.max.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 101
+ _points[ 6 ].set( this.max.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 110
+ _points[ 7 ].set( this.max.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 111
- return this;
+ this.setFromPoints( _points );
- };
+ return this;
- }(),
+ },
translate: function ( offset ) {
@@ -6794,13 +6613,41 @@
} );
+ function satForAxes( axes, v0, v1, v2, extents ) {
+
+ var i, j;
+
+ for ( i = 0, j = axes.length - 3; i <= j; i += 3 ) {
+
+ _testAxis.fromArray( axes, i );
+ // project the aabb onto the seperating axis
+ var r = extents.x * Math.abs( _testAxis.x ) + extents.y * Math.abs( _testAxis.y ) + extents.z * Math.abs( _testAxis.z );
+ // project all 3 vertices of the triangle onto the seperating axis
+ var p0 = v0.dot( _testAxis );
+ var p1 = v1.dot( _testAxis );
+ var p2 = v2.dot( _testAxis );
+ // actual test, basically see if either of the most extreme of the triangle points intersects r
+ if ( Math.max( - Math.max( p0, p1, p2 ), Math.min( p0, p1, p2 ) ) > r ) {
+
+ // points of the projected triangle are outside the projected half-length of the aabb
+ // the axis is seperating and we can exit
+ return false;
+
+ }
+
+ }
+
+ return true;
+
+ }
+
+ var _box = new Box3();
+
/**
* @author bhouston / http://clara.io
* @author mrdoob / http://mrdoob.com/
*/
- var _box;
-
function Sphere( center, radius ) {
this.center = ( center !== undefined ) ? center : new Vector3();
@@ -6821,8 +6668,6 @@
setFromPoints: function ( points, optionalCenter ) {
- if ( _box === undefined ) _box = new Box3();
-
var center = this.center;
if ( optionalCenter !== undefined ) {
@@ -6967,6 +6812,15 @@
} );
+ var _vector$3 = new Vector3();
+ var _segCenter = new Vector3();
+ var _segDir = new Vector3();
+ var _diff = new Vector3();
+
+ var _edge1 = new Vector3();
+ var _edge2 = new Vector3();
+ var _normal = new Vector3();
+
/**
* @author bhouston / http://clara.io
*/
@@ -7025,19 +6879,13 @@
},
- recast: function () {
-
- var v1 = new Vector3();
+ recast: function ( t ) {
- return function recast( t ) {
+ this.origin.copy( this.at( t, _vector$3 ) );
- this.origin.copy( this.at( t, v1 ) );
-
- return this;
-
- };
+ return this;
- }(),
+ },
closestPointToPoint: function ( point, target ) {
@@ -7068,94 +6916,72 @@
},
- distanceSqToPoint: function () {
-
- var v1 = new Vector3();
-
- return function distanceSqToPoint( point ) {
-
- var directionDistance = v1.subVectors( point, this.origin ).dot( this.direction );
-
- // point behind the ray
-
- if ( directionDistance < 0 ) {
+ distanceSqToPoint: function ( point ) {
- return this.origin.distanceToSquared( point );
+ var directionDistance = _vector$3.subVectors( point, this.origin ).dot( this.direction );
- }
-
- v1.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin );
-
- return v1.distanceToSquared( point );
-
- };
+ // point behind the ray
- }(),
+ if ( directionDistance < 0 ) {
- distanceSqToSegment: function () {
+ return this.origin.distanceToSquared( point );
- var segCenter = new Vector3();
- var segDir = new Vector3();
- var diff = new Vector3();
+ }
- return function distanceSqToSegment( v0, v1, optionalPointOnRay, optionalPointOnSegment ) {
+ _vector$3.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin );
- // from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteDistRaySegment.h
- // It returns the min distance between the ray and the segment
- // defined by v0 and v1
- // It can also set two optional targets :
- // - The closest point on the ray
- // - The closest point on the segment
+ return _vector$3.distanceToSquared( point );
- segCenter.copy( v0 ).add( v1 ).multiplyScalar( 0.5 );
- segDir.copy( v1 ).sub( v0 ).normalize();
- diff.copy( this.origin ).sub( segCenter );
+ },
- var segExtent = v0.distanceTo( v1 ) * 0.5;
- var a01 = - this.direction.dot( segDir );
- var b0 = diff.dot( this.direction );
- var b1 = - diff.dot( segDir );
- var c = diff.lengthSq();
- var det = Math.abs( 1 - a01 * a01 );
- var s0, s1, sqrDist, extDet;
+ distanceSqToSegment: function ( v0, v1, optionalPointOnRay, optionalPointOnSegment ) {
- if ( det > 0 ) {
+ // from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteDistRaySegment.h
+ // It returns the min distance between the ray and the segment
+ // defined by v0 and v1
+ // It can also set two optional targets :
+ // - The closest point on the ray
+ // - The closest point on the segment
- // The ray and segment are not parallel.
+ _segCenter.copy( v0 ).add( v1 ).multiplyScalar( 0.5 );
+ _segDir.copy( v1 ).sub( v0 ).normalize();
+ _diff.copy( this.origin ).sub( _segCenter );
- s0 = a01 * b1 - b0;
- s1 = a01 * b0 - b1;
- extDet = segExtent * det;
+ var segExtent = v0.distanceTo( v1 ) * 0.5;
+ var a01 = - this.direction.dot( _segDir );
+ var b0 = _diff.dot( this.direction );
+ var b1 = - _diff.dot( _segDir );
+ var c = _diff.lengthSq();
+ var det = Math.abs( 1 - a01 * a01 );
+ var s0, s1, sqrDist, extDet;
- if ( s0 >= 0 ) {
+ if ( det > 0 ) {
- if ( s1 >= - extDet ) {
+ // The ray and segment are not parallel.
- if ( s1 <= extDet ) {
+ s0 = a01 * b1 - b0;
+ s1 = a01 * b0 - b1;
+ extDet = segExtent * det;
- // region 0
- // Minimum at interior points of ray and segment.
+ if ( s0 >= 0 ) {
- var invDet = 1 / det;
- s0 *= invDet;
- s1 *= invDet;
- sqrDist = s0 * ( s0 + a01 * s1 + 2 * b0 ) + s1 * ( a01 * s0 + s1 + 2 * b1 ) + c;
+ if ( s1 >= - extDet ) {
- } else {
+ if ( s1 <= extDet ) {
- // region 1
+ // region 0
+ // Minimum at interior points of ray and segment.
- s1 = segExtent;
- s0 = Math.max( 0, - ( a01 * s1 + b0 ) );
- sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;
-
- }
+ var invDet = 1 / det;
+ s0 *= invDet;
+ s1 *= invDet;
+ sqrDist = s0 * ( s0 + a01 * s1 + 2 * b0 ) + s1 * ( a01 * s0 + s1 + 2 * b1 ) + c;
} else {
- // region 5
+ // region 1
- s1 = - segExtent;
+ s1 = segExtent;
s0 = Math.max( 0, - ( a01 * s1 + b0 ) );
sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;
@@ -7163,97 +6989,99 @@
} else {
- if ( s1 <= - extDet ) {
+ // region 5
- // region 4
+ s1 = - segExtent;
+ s0 = Math.max( 0, - ( a01 * s1 + b0 ) );
+ sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;
- s0 = Math.max( 0, - ( - a01 * segExtent + b0 ) );
- s1 = ( s0 > 0 ) ? - segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent );
- sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;
+ }
- } else if ( s1 <= extDet ) {
+ } else {
- // region 3
+ if ( s1 <= - extDet ) {
- s0 = 0;
- s1 = Math.min( Math.max( - segExtent, - b1 ), segExtent );
- sqrDist = s1 * ( s1 + 2 * b1 ) + c;
+ // region 4
- } else {
+ s0 = Math.max( 0, - ( - a01 * segExtent + b0 ) );
+ s1 = ( s0 > 0 ) ? - segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent );
+ sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;
- // region 2
+ } else if ( s1 <= extDet ) {
- s0 = Math.max( 0, - ( a01 * segExtent + b0 ) );
- s1 = ( s0 > 0 ) ? segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent );
- sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;
+ // region 3
- }
+ s0 = 0;
+ s1 = Math.min( Math.max( - segExtent, - b1 ), segExtent );
+ sqrDist = s1 * ( s1 + 2 * b1 ) + c;
- }
+ } else {
- } else {
+ // region 2
- // Ray and segment are parallel.
+ s0 = Math.max( 0, - ( a01 * segExtent + b0 ) );
+ s1 = ( s0 > 0 ) ? segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent );
+ sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;
- s1 = ( a01 > 0 ) ? - segExtent : segExtent;
- s0 = Math.max( 0, - ( a01 * s1 + b0 ) );
- sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;
+ }
}
- if ( optionalPointOnRay ) {
+ } else {
- optionalPointOnRay.copy( this.direction ).multiplyScalar( s0 ).add( this.origin );
+ // Ray and segment are parallel.
- }
+ s1 = ( a01 > 0 ) ? - segExtent : segExtent;
+ s0 = Math.max( 0, - ( a01 * s1 + b0 ) );
+ sqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;
- if ( optionalPointOnSegment ) {
+ }
- optionalPointOnSegment.copy( segDir ).multiplyScalar( s1 ).add( segCenter );
+ if ( optionalPointOnRay ) {
- }
+ optionalPointOnRay.copy( this.direction ).multiplyScalar( s0 ).add( this.origin );
- return sqrDist;
+ }
- };
+ if ( optionalPointOnSegment ) {
- }(),
+ optionalPointOnSegment.copy( _segDir ).multiplyScalar( s1 ).add( _segCenter );
- intersectSphere: function () {
+ }
- var v1 = new Vector3();
+ return sqrDist;
- return function intersectSphere( sphere, target ) {
+ },
- v1.subVectors( sphere.center, this.origin );
- var tca = v1.dot( this.direction );
- var d2 = v1.dot( v1 ) - tca * tca;
- var radius2 = sphere.radius * sphere.radius;
+ intersectSphere: function ( sphere, target ) {
- if ( d2 > radius2 ) return null;
+ _vector$3.subVectors( sphere.center, this.origin );
+ var tca = _vector$3.dot( this.direction );
+ var d2 = _vector$3.dot( _vector$3 ) - tca * tca;
+ var radius2 = sphere.radius * sphere.radius;
- var thc = Math.sqrt( radius2 - d2 );
+ if ( d2 > radius2 ) return null;
- // t0 = first intersect point - entrance on front of sphere
- var t0 = tca - thc;
+ var thc = Math.sqrt( radius2 - d2 );
- // t1 = second intersect point - exit point on back of sphere
- var t1 = tca + thc;
+ // t0 = first intersect point - entrance on front of sphere
+ var t0 = tca - thc;
- // test to see if both t0 and t1 are behind the ray - if so, return null
- if ( t0 < 0 && t1 < 0 ) return null;
+ // t1 = second intersect point - exit point on back of sphere
+ var t1 = tca + thc;
- // test to see if t0 is behind the ray:
- // if it is, the ray is inside the sphere, so return the second exit point scaled by t1,
- // in order to always return an intersect point that is in front of the ray.
- if ( t0 < 0 ) return this.at( t1, target );
+ // test to see if both t0 and t1 are behind the ray - if so, return null
+ if ( t0 < 0 && t1 < 0 ) return null;
- // else t0 is in front of the ray, so return the first collision point scaled by t0
- return this.at( t0, target );
+ // test to see if t0 is behind the ray:
+ // if it is, the ray is inside the sphere, so return the second exit point scaled by t1,
+ // in order to always return an intersect point that is in front of the ray.
+ if ( t0 < 0 ) return this.at( t1, target );
- };
+ // else t0 is in front of the ray, so return the first collision point scaled by t0
+ return this.at( t0, target );
- }(),
+ },
intersectsSphere: function ( sphere ) {
@@ -7397,100 +7225,86 @@
},
- intersectsBox: ( function () {
-
- var v = new Vector3();
-
- return function intersectsBox( box ) {
-
- return this.intersectBox( box, v ) !== null;
+ intersectsBox: function ( box ) {
- };
+ return this.intersectBox( box, _vector$3 ) !== null;
- } )(),
+ },
- intersectTriangle: function () {
+ intersectTriangle: function ( a, b, c, backfaceCulling, target ) {
// Compute the offset origin, edges, and normal.
- var diff = new Vector3();
- var edge1 = new Vector3();
- var edge2 = new Vector3();
- var normal = new Vector3();
- return function intersectTriangle( a, b, c, backfaceCulling, target ) {
+ // from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h
- // from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h
+ _edge1.subVectors( b, a );
+ _edge2.subVectors( c, a );
+ _normal.crossVectors( _edge1, _edge2 );
- edge1.subVectors( b, a );
- edge2.subVectors( c, a );
- normal.crossVectors( edge1, edge2 );
+ // Solve Q + t*D = b1*E1 + b2*E2 (Q = kDiff, D = ray direction,
+ // E1 = kEdge1, E2 = kEdge2, N = Cross(E1,E2)) by
+ // |Dot(D,N)|*b1 = sign(Dot(D,N))*Dot(D,Cross(Q,E2))
+ // |Dot(D,N)|*b2 = sign(Dot(D,N))*Dot(D,Cross(E1,Q))
+ // |Dot(D,N)|*t = -sign(Dot(D,N))*Dot(Q,N)
+ var DdN = this.direction.dot( _normal );
+ var sign;
- // Solve Q + t*D = b1*E1 + b2*E2 (Q = kDiff, D = ray direction,
- // E1 = kEdge1, E2 = kEdge2, N = Cross(E1,E2)) by
- // |Dot(D,N)|*b1 = sign(Dot(D,N))*Dot(D,Cross(Q,E2))
- // |Dot(D,N)|*b2 = sign(Dot(D,N))*Dot(D,Cross(E1,Q))
- // |Dot(D,N)|*t = -sign(Dot(D,N))*Dot(Q,N)
- var DdN = this.direction.dot( normal );
- var sign;
+ if ( DdN > 0 ) {
- if ( DdN > 0 ) {
+ if ( backfaceCulling ) return null;
+ sign = 1;
- if ( backfaceCulling ) return null;
- sign = 1;
+ } else if ( DdN < 0 ) {
- } else if ( DdN < 0 ) {
+ sign = - 1;
+ DdN = - DdN;
- sign = - 1;
- DdN = - DdN;
-
- } else {
-
- return null;
+ } else {
- }
+ return null;
- diff.subVectors( this.origin, a );
- var DdQxE2 = sign * this.direction.dot( edge2.crossVectors( diff, edge2 ) );
+ }
- // b1 < 0, no intersection
- if ( DdQxE2 < 0 ) {
+ _diff.subVectors( this.origin, a );
+ var DdQxE2 = sign * this.direction.dot( _edge2.crossVectors( _diff, _edge2 ) );
- return null;
+ // b1 < 0, no intersection
+ if ( DdQxE2 < 0 ) {
- }
+ return null;
- var DdE1xQ = sign * this.direction.dot( edge1.cross( diff ) );
+ }
- // b2 < 0, no intersection
- if ( DdE1xQ < 0 ) {
+ var DdE1xQ = sign * this.direction.dot( _edge1.cross( _diff ) );
- return null;
+ // b2 < 0, no intersection
+ if ( DdE1xQ < 0 ) {
- }
+ return null;
- // b1+b2 > 1, no intersection
- if ( DdQxE2 + DdE1xQ > DdN ) {
+ }
- return null;
+ // b1+b2 > 1, no intersection
+ if ( DdQxE2 + DdE1xQ > DdN ) {
- }
+ return null;
- // Line intersects triangle, check if ray does.
- var QdN = - sign * diff.dot( normal );
+ }
- // t < 0, no intersection
- if ( QdN < 0 ) {
+ // Line intersects triangle, check if ray does.
+ var QdN = - sign * _diff.dot( _normal );
- return null;
+ // t < 0, no intersection
+ if ( QdN < 0 ) {
- }
+ return null;
- // Ray intersects triangle.
- return this.at( QdN / DdN, target );
+ }
- };
+ // Ray intersects triangle.
+ return this.at( QdN / DdN, target );
- }(),
+ },
applyMatrix4: function ( matrix4 ) {
@@ -7514,6 +7328,18 @@
* @author mrdoob / http://mrdoob.com/
*/
+ var _v0$1 = new Vector3();
+ var _v1$3 = new Vector3();
+ var _v2$1 = new Vector3();
+ var _v3 = new Vector3();
+
+ var _vab = new Vector3();
+ var _vac = new Vector3();
+ var _vbc = new Vector3();
+ var _vap = new Vector3();
+ var _vbp = new Vector3();
+ var _vcp = new Vector3();
+
function Triangle( a, b, c ) {
this.a = ( a !== undefined ) ? a : new Vector3();
@@ -7524,134 +7350,101 @@
Object.assign( Triangle, {
- getNormal: function () {
+ getNormal: function ( a, b, c, target ) {
- var v0 = new Vector3();
-
- return function getNormal( a, b, c, target ) {
-
- if ( target === undefined ) {
-
- console.warn( 'THREE.Triangle: .getNormal() target is now required' );
- target = new Vector3();
+ if ( target === undefined ) {
- }
+ console.warn( 'THREE.Triangle: .getNormal() target is now required' );
+ target = new Vector3();
- target.subVectors( c, b );
- v0.subVectors( a, b );
- target.cross( v0 );
+ }
- var targetLengthSq = target.lengthSq();
- if ( targetLengthSq > 0 ) {
+ target.subVectors( c, b );
+ _v0$1.subVectors( a, b );
+ target.cross( _v0$1 );
- return target.multiplyScalar( 1 / Math.sqrt( targetLengthSq ) );
+ var targetLengthSq = target.lengthSq();
+ if ( targetLengthSq > 0 ) {
- }
+ return target.multiplyScalar( 1 / Math.sqrt( targetLengthSq ) );
- return target.set( 0, 0, 0 );
+ }
- };
+ return target.set( 0, 0, 0 );
- }(),
+ },
// static/instance method to calculate barycentric coordinates
// based on: http://www.blackpawn.com/texts/pointinpoly/default.html
- getBarycoord: function () {
-
- var v0 = new Vector3();
- var v1 = new Vector3();
- var v2 = new Vector3();
-
- return function getBarycoord( point, a, b, c, target ) {
-
- v0.subVectors( c, a );
- v1.subVectors( b, a );
- v2.subVectors( point, a );
+ getBarycoord: function ( point, a, b, c, target ) {
- var dot00 = v0.dot( v0 );
- var dot01 = v0.dot( v1 );
- var dot02 = v0.dot( v2 );
- var dot11 = v1.dot( v1 );
- var dot12 = v1.dot( v2 );
-
- var denom = ( dot00 * dot11 - dot01 * dot01 );
-
- if ( target === undefined ) {
-
- console.warn( 'THREE.Triangle: .getBarycoord() target is now required' );
- target = new Vector3();
-
- }
+ _v0$1.subVectors( c, a );
+ _v1$3.subVectors( b, a );
+ _v2$1.subVectors( point, a );
- // collinear or singular triangle
- if ( denom === 0 ) {
+ var dot00 = _v0$1.dot( _v0$1 );
+ var dot01 = _v0$1.dot( _v1$3 );
+ var dot02 = _v0$1.dot( _v2$1 );
+ var dot11 = _v1$3.dot( _v1$3 );
+ var dot12 = _v1$3.dot( _v2$1 );
- // arbitrary location outside of triangle?
- // not sure if this is the best idea, maybe should be returning undefined
- return target.set( - 2, - 1, - 1 );
+ var denom = ( dot00 * dot11 - dot01 * dot01 );
- }
-
- var invDenom = 1 / denom;
- var u = ( dot11 * dot02 - dot01 * dot12 ) * invDenom;
- var v = ( dot00 * dot12 - dot01 * dot02 ) * invDenom;
-
- // barycentric coordinates must always sum to 1
- return target.set( 1 - u - v, v, u );
-
- };
-
- }(),
-
- containsPoint: function () {
+ if ( target === undefined ) {
- var v1 = new Vector3();
+ console.warn( 'THREE.Triangle: .getBarycoord() target is now required' );
+ target = new Vector3();
- return function containsPoint( point, a, b, c ) {
+ }
- Triangle.getBarycoord( point, a, b, c, v1 );
+ // collinear or singular triangle
+ if ( denom === 0 ) {
- return ( v1.x >= 0 ) && ( v1.y >= 0 ) && ( ( v1.x + v1.y ) <= 1 );
+ // arbitrary location outside of triangle?
+ // not sure if this is the best idea, maybe should be returning undefined
+ return target.set( - 2, - 1, - 1 );
- };
+ }
- }(),
+ var invDenom = 1 / denom;
+ var u = ( dot11 * dot02 - dot01 * dot12 ) * invDenom;
+ var v = ( dot00 * dot12 - dot01 * dot02 ) * invDenom;
- getUV: function () {
+ // barycentric coordinates must always sum to 1
+ return target.set( 1 - u - v, v, u );
- var barycoord = new Vector3();
+ },
- return function getUV( point, p1, p2, p3, uv1, uv2, uv3, target ) {
+ containsPoint: function ( point, a, b, c ) {
- this.getBarycoord( point, p1, p2, p3, barycoord );
+ Triangle.getBarycoord( point, a, b, c, _v3 );
- target.set( 0, 0 );
- target.addScaledVector( uv1, barycoord.x );
- target.addScaledVector( uv2, barycoord.y );
- target.addScaledVector( uv3, barycoord.z );
+ return ( _v3.x >= 0 ) && ( _v3.y >= 0 ) && ( ( _v3.x + _v3.y ) <= 1 );
- return target;
+ },
- };
+ getUV: function ( point, p1, p2, p3, uv1, uv2, uv3, target ) {
- }(),
+ this.getBarycoord( point, p1, p2, p3, _v3 );
- isFrontFacing: function () {
+ target.set( 0, 0 );
+ target.addScaledVector( uv1, _v3.x );
+ target.addScaledVector( uv2, _v3.y );
+ target.addScaledVector( uv3, _v3.z );
- var v0 = new Vector3();
- var v1 = new Vector3();
+ return target;
- return function isFrontFacing( a, b, c, direction ) {
+ },
- v0.subVectors( c, b );
- v1.subVectors( a, b );
+ isFrontFacing: function ( a, b, c, direction ) {
- // strictly front facing
- return ( v0.cross( v1 ).dot( direction ) < 0 ) ? true : false;
+ _v0$1.subVectors( c, b );
+ _v1$3.subVectors( a, b );
- };
+ // strictly front facing
+ return ( _v0$1.cross( _v1$3 ).dot( direction ) < 0 ) ? true : false;
- }()
+ }
} );
@@ -7695,19 +7488,12 @@
getArea: function () {
- var v0 = new Vector3();
- var v1 = new Vector3();
+ _v0$1.subVectors( this.c, this.b );
+ _v1$3.subVectors( this.a, this.b );
- return function getArea() {
+ return _v0$1.cross( _v1$3 ).length() * 0.5;
- v0.subVectors( this.c, this.b );
- v1.subVectors( this.a, this.b );
-
- return v0.cross( v1 ).length() * 0.5;
-
- };
-
- }(),
+ },
getMidpoint: function ( target ) {
@@ -7771,103 +7557,93 @@
},
- closestPointToPoint: function () {
+ closestPointToPoint: function ( p, target ) {
- var vab = new Vector3();
- var vac = new Vector3();
- var vbc = new Vector3();
- var vap = new Vector3();
- var vbp = new Vector3();
- var vcp = new Vector3();
-
- return function closestPointToPoint( p, target ) {
-
- if ( target === undefined ) {
+ if ( target === undefined ) {
- console.warn( 'THREE.Triangle: .closestPointToPoint() target is now required' );
- target = new Vector3();
+ console.warn( 'THREE.Triangle: .closestPointToPoint() target is now required' );
+ target = new Vector3();
- }
+ }
- var a = this.a, b = this.b, c = this.c;
- var v, w;
+ var a = this.a, b = this.b, c = this.c;
+ var v, w;
- // algorithm thanks to Real-Time Collision Detection by Christer Ericson,
- // published by Morgan Kaufmann Publishers, (c) 2005 Elsevier Inc.,
- // under the accompanying license; see chapter 5.1.5 for detailed explanation.
- // basically, we're distinguishing which of the voronoi regions of the triangle
- // the point lies in with the minimum amount of redundant computation.
+ // algorithm thanks to Real-Time Collision Detection by Christer Ericson,
+ // published by Morgan Kaufmann Publishers, (c) 2005 Elsevier Inc.,
+ // under the accompanying license; see chapter 5.1.5 for detailed explanation.
+ // basically, we're distinguishing which of the voronoi regions of the triangle
+ // the point lies in with the minimum amount of redundant computation.
- vab.subVectors( b, a );
- vac.subVectors( c, a );
- vap.subVectors( p, a );
- var d1 = vab.dot( vap );
- var d2 = vac.dot( vap );
- if ( d1 <= 0 && d2 <= 0 ) {
+ _vab.subVectors( b, a );
+ _vac.subVectors( c, a );
+ _vap.subVectors( p, a );
+ var d1 = _vab.dot( _vap );
+ var d2 = _vac.dot( _vap );
+ if ( d1 <= 0 && d2 <= 0 ) {
- // vertex region of A; barycentric coords (1, 0, 0)
- return target.copy( a );
+ // vertex region of A; barycentric coords (1, 0, 0)
+ return target.copy( a );
- }
+ }
- vbp.subVectors( p, b );
- var d3 = vab.dot( vbp );
- var d4 = vac.dot( vbp );
- if ( d3 >= 0 && d4 <= d3 ) {
+ _vbp.subVectors( p, b );
+ var d3 = _vab.dot( _vbp );
+ var d4 = _vac.dot( _vbp );
+ if ( d3 >= 0 && d4 <= d3 ) {
- // vertex region of B; barycentric coords (0, 1, 0)
- return target.copy( b );
+ // vertex region of B; barycentric coords (0, 1, 0)
+ return target.copy( b );
- }
+ }
- var vc = d1 * d4 - d3 * d2;
- if ( vc <= 0 && d1 >= 0 && d3 <= 0 ) {
+ var vc = d1 * d4 - d3 * d2;
+ if ( vc <= 0 && d1 >= 0 && d3 <= 0 ) {
- v = d1 / ( d1 - d3 );
- // edge region of AB; barycentric coords (1-v, v, 0)
- return target.copy( a ).addScaledVector( vab, v );
+ v = d1 / ( d1 - d3 );
+ // edge region of AB; barycentric coords (1-v, v, 0)
+ return target.copy( a ).addScaledVector( _vab, v );
- }
+ }
- vcp.subVectors( p, c );
- var d5 = vab.dot( vcp );
- var d6 = vac.dot( vcp );
- if ( d6 >= 0 && d5 <= d6 ) {
+ _vcp.subVectors( p, c );
+ var d5 = _vab.dot( _vcp );
+ var d6 = _vac.dot( _vcp );
+ if ( d6 >= 0 && d5 <= d6 ) {
- // vertex region of C; barycentric coords (0, 0, 1)
- return target.copy( c );
+ // vertex region of C; barycentric coords (0, 0, 1)
+ return target.copy( c );
- }
+ }
- var vb = d5 * d2 - d1 * d6;
- if ( vb <= 0 && d2 >= 0 && d6 <= 0 ) {
+ var vb = d5 * d2 - d1 * d6;
+ if ( vb <= 0 && d2 >= 0 && d6 <= 0 ) {
- w = d2 / ( d2 - d6 );
- // edge region of AC; barycentric coords (1-w, 0, w)
- return target.copy( a ).addScaledVector( vac, w );
+ w = d2 / ( d2 - d6 );
+ // edge region of AC; barycentric coords (1-w, 0, w)
+ return target.copy( a ).addScaledVector( _vac, w );
- }
+ }
- var va = d3 * d6 - d5 * d4;
- if ( va <= 0 && ( d4 - d3 ) >= 0 && ( d5 - d6 ) >= 0 ) {
+ var va = d3 * d6 - d5 * d4;
+ if ( va <= 0 && ( d4 - d3 ) >= 0 && ( d5 - d6 ) >= 0 ) {
- vbc.subVectors( c, b );
- w = ( d4 - d3 ) / ( ( d4 - d3 ) + ( d5 - d6 ) );
- // edge region of BC; barycentric coords (0, 1-w, w)
- return target.copy( b ).addScaledVector( vbc, w ); // edge region of BC
+ _vbc.subVectors( c, b );
+ w = ( d4 - d3 ) / ( ( d4 - d3 ) + ( d5 - d6 ) );
+ // edge region of BC; barycentric coords (0, 1-w, w)
+ return target.copy( b ).addScaledVector( _vbc, w ); // edge region of BC
- }
+ }
- // face region
- var denom = 1 / ( va + vb + vc );
- // u = va * denom
- v = vb * denom;
- w = vc * denom;
- return target.copy( a ).addScaledVector( vab, v ).addScaledVector( vac, w );
+ // face region
+ var denom = 1 / ( va + vb + vc );
+ // u = va * denom
+ v = vb * denom;
+ w = vc * denom;
- };
+ return target.copy( a ).addScaledVector( _vab, v ).addScaledVector( _vac, w );
- }(),
+ },
equals: function ( triangle ) {
@@ -7881,7 +7657,7 @@
* @author mrdoob / http://mrdoob.com/
*/
- var ColorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF,
+ var _colorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF,
'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2,
'brown': 0xA52A2A, 'burlywood': 0xDEB887, 'cadetblue': 0x5F9EA0, 'chartreuse': 0x7FFF00, 'chocolate': 0xD2691E, 'coral': 0xFF7F50,
'cornflowerblue': 0x6495ED, 'cornsilk': 0xFFF8DC, 'crimson': 0xDC143C, 'cyan': 0x00FFFF, 'darkblue': 0x00008B, 'darkcyan': 0x008B8B,
@@ -7906,6 +7682,9 @@
'springgreen': 0x00FF7F, 'steelblue': 0x4682B4, 'tan': 0xD2B48C, 'teal': 0x008080, 'thistle': 0xD8BFD8, 'tomato': 0xFF6347, 'turquoise': 0x40E0D0,
'violet': 0xEE82EE, 'wheat': 0xF5DEB3, 'white': 0xFFFFFF, 'whitesmoke': 0xF5F5F5, 'yellow': 0xFFFF00, 'yellowgreen': 0x9ACD32 };
+ var _hslA = { h: 0, s: 0, l: 0 };
+ var _hslB = { h: 0, s: 0, l: 0 };
+
function Color( r, g, b ) {
if ( g === undefined && b === undefined ) {
@@ -8136,7 +7915,7 @@
if ( style && style.length > 0 ) {
// color keywords
- var hex = ColorKeywords[ style ];
+ var hex = _colorKeywords[ style ];
if ( hex !== undefined ) {
@@ -8318,23 +8097,17 @@
},
- offsetHSL: function () {
-
- var hsl = {};
+ offsetHSL: function ( h, s, l ) {
- return function ( h, s, l ) {
+ this.getHSL( _hslA );
- this.getHSL( hsl );
+ _hslA.h += h; _hslA.s += s; _hslA.l += l;
- hsl.h += h; hsl.s += s; hsl.l += l;
+ this.setHSL( _hslA.h, _hslA.s, _hslA.l );
- this.setHSL( hsl.h, hsl.s, hsl.l );
-
- return this;
-
- };
+ return this;
- }(),
+ },
add: function ( color ) {
@@ -8406,27 +8179,20 @@
},
- lerpHSL: function () {
-
- var hslA = { h: 0, s: 0, l: 0 };
- var hslB = { h: 0, s: 0, l: 0 };
-
- return function lerpHSL( color, alpha ) {
+ lerpHSL: function ( color, alpha ) {
- this.getHSL( hslA );
- color.getHSL( hslB );
+ this.getHSL( _hslA );
+ color.getHSL( _hslB );
- var h = _Math.lerp( hslA.h, hslB.h, alpha );
- var s = _Math.lerp( hslA.s, hslB.s, alpha );
- var l = _Math.lerp( hslA.l, hslB.l, alpha );
+ var h = _Math.lerp( _hslA.h, _hslB.h, alpha );
+ var s = _Math.lerp( _hslA.s, _hslB.s, alpha );
+ var l = _Math.lerp( _hslA.l, _hslB.l, alpha );
- this.setHSL( h, s, l );
-
- return this;
+ this.setHSL( h, s, l );
- };
+ return this;
- }(),
+ },
equals: function ( c ) {
@@ -8593,6 +8359,8 @@
this.visible = true;
+ this.toneMapped = true;
+
this.userData = {};
this.needsUpdate = true;
@@ -8695,8 +8463,15 @@
if ( this.specular && this.specular.isColor ) data.specular = this.specular.getHex();
if ( this.shininess !== undefined ) data.shininess = this.shininess;
- if ( this.clearCoat !== undefined ) data.clearCoat = this.clearCoat;
- if ( this.clearCoatRoughness !== undefined ) data.clearCoatRoughness = this.clearCoatRoughness;
+ if ( this.clearcoat !== undefined ) data.clearcoat = this.clearcoat;
+ if ( this.clearcoatRoughness !== undefined ) data.clearcoatRoughness = this.clearcoatRoughness;
+
+ if ( this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture ) {
+
+ data.clearcoatNormalMap = this.clearcoatNormalMap.toJSON( meta ).uuid;
+ data.clearcoatNormalScale = this.clearcoatNormalScale.toArray();
+
+ }
if ( this.map && this.map.isTexture ) data.map = this.map.toJSON( meta ).uuid;
if ( this.matcap && this.matcap.isTexture ) data.matcap = this.matcap.toJSON( meta ).uuid;
@@ -8806,6 +8581,9 @@
if ( this.skinning === true ) data.skinning = true;
if ( this.visible === false ) data.visible = false;
+
+ if ( this.toneMapped === false ) data.toneMapped = false;
+
if ( JSON.stringify( this.userData ) !== '{}' ) data.userData = this.userData;
// TODO: Copied from Object3D.toJSON
@@ -8894,6 +8672,9 @@
this.premultipliedAlpha = source.premultipliedAlpha;
this.visible = source.visible;
+
+ this.toneMapped = source.toneMapped;
+
this.userData = JSON.parse( JSON.stringify( source.userData ) );
this.clipShadows = source.clipShadows;
@@ -9771,11 +9552,18 @@
* @author mrdoob / http://mrdoob.com/
*/
- var bufferGeometryId = 1; // BufferGeometry uses odd numbers as Id
+ var _bufferGeometryId = 1; // BufferGeometry uses odd numbers as Id
+
+ var _m1$2 = new Matrix4();
+ var _obj = new Object3D();
+ var _offset = new Vector3();
+ var _box$1 = new Box3();
+ var _boxMorphTargets = new Box3();
+ var _vector$4 = new Vector3();
function BufferGeometry() {
- Object.defineProperty( this, 'id', { value: bufferGeometryId += 2 } );
+ Object.defineProperty( this, 'id', { value: _bufferGeometryId += 2 } );
this.uuid = _Math.generateUUID();
@@ -9938,129 +9726,89 @@
},
- rotateX: function () {
+ rotateX: function ( angle ) {
// rotate geometry around world x-axis
- var m1 = new Matrix4();
+ _m1$2.makeRotationX( angle );
- return function rotateX( angle ) {
+ this.applyMatrix( _m1$2 );
- m1.makeRotationX( angle );
-
- this.applyMatrix( m1 );
-
- return this;
-
- };
+ return this;
- }(),
+ },
- rotateY: function () {
+ rotateY: function ( angle ) {
// rotate geometry around world y-axis
- var m1 = new Matrix4();
-
- return function rotateY( angle ) {
-
- m1.makeRotationY( angle );
+ _m1$2.makeRotationY( angle );
- this.applyMatrix( m1 );
+ this.applyMatrix( _m1$2 );
- return this;
-
- };
+ return this;
- }(),
+ },
- rotateZ: function () {
+ rotateZ: function ( angle ) {
// rotate geometry around world z-axis
- var m1 = new Matrix4();
-
- return function rotateZ( angle ) {
-
- m1.makeRotationZ( angle );
-
- this.applyMatrix( m1 );
+ _m1$2.makeRotationZ( angle );
- return this;
+ this.applyMatrix( _m1$2 );
- };
+ return this;
- }(),
+ },
- translate: function () {
+ translate: function ( x, y, z ) {
// translate geometry
- var m1 = new Matrix4();
+ _m1$2.makeTranslation( x, y, z );
- return function translate( x, y, z ) {
+ this.applyMatrix( _m1$2 );
- m1.makeTranslation( x, y, z );
-
- this.applyMatrix( m1 );
-
- return this;
-
- };
+ return this;
- }(),
+ },
- scale: function () {
+ scale: function ( x, y, z ) {
// scale geometry
- var m1 = new Matrix4();
-
- return function scale( x, y, z ) {
-
- m1.makeScale( x, y, z );
+ _m1$2.makeScale( x, y, z );
- this.applyMatrix( m1 );
+ this.applyMatrix( _m1$2 );
- return this;
-
- };
-
- }(),
-
- lookAt: function () {
+ return this;
- var obj = new Object3D();
+ },
- return function lookAt( vector ) {
+ lookAt: function ( vector ) {
- obj.lookAt( vector );
+ _obj.lookAt( vector );
- obj.updateMatrix();
+ _obj.updateMatrix();
- this.applyMatrix( obj.matrix );
+ this.applyMatrix( _obj.matrix );
- };
+ return this;
- }(),
+ },
center: function () {
- var offset = new Vector3();
-
- return function center() {
+ this.computeBoundingBox();
- this.computeBoundingBox();
+ this.boundingBox.getCenter( _offset ).negate();
- this.boundingBox.getCenter( offset ).negate();
+ this.translate( _offset.x, _offset.y, _offset.z );
- this.translate( offset.x, offset.y, offset.z );
-
- return this;
-
- };
+ return this;
- }(),
+ },
setFromObject: function ( object ) {
@@ -10357,144 +10105,130 @@
computeBoundingBox: function () {
- var box = new Box3();
-
- return function computeBoundingBox() {
-
- if ( this.boundingBox === null ) {
+ if ( this.boundingBox === null ) {
- this.boundingBox = new Box3();
+ this.boundingBox = new Box3();
- }
+ }
- var position = this.attributes.position;
- var morphAttributesPosition = this.morphAttributes.position;
+ var position = this.attributes.position;
+ var morphAttributesPosition = this.morphAttributes.position;
- if ( position !== undefined ) {
+ if ( position !== undefined ) {
- this.boundingBox.setFromBufferAttribute( position );
+ this.boundingBox.setFromBufferAttribute( position );
- // process morph attributes if present
+ // process morph attributes if present
- if ( morphAttributesPosition ) {
+ if ( morphAttributesPosition ) {
- for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {
+ for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {
- var morphAttribute = morphAttributesPosition[ i ];
- box.setFromBufferAttribute( morphAttribute );
+ var morphAttribute = morphAttributesPosition[ i ];
+ _box$1.setFromBufferAttribute( morphAttribute );
- this.boundingBox.expandByPoint( box.min );
- this.boundingBox.expandByPoint( box.max );
-
- }
+ this.boundingBox.expandByPoint( _box$1.min );
+ this.boundingBox.expandByPoint( _box$1.max );
}
- } else {
-
- this.boundingBox.makeEmpty();
-
}
- if ( isNaN( this.boundingBox.min.x ) || isNaN( this.boundingBox.min.y ) || isNaN( this.boundingBox.min.z ) ) {
-
- console.error( 'THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this );
+ } else {
- }
+ this.boundingBox.makeEmpty();
- };
+ }
- }(),
+ if ( isNaN( this.boundingBox.min.x ) || isNaN( this.boundingBox.min.y ) || isNaN( this.boundingBox.min.z ) ) {
- computeBoundingSphere: function () {
+ console.error( 'THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this );
- var box = new Box3();
- var boxMorphTargets = new Box3();
- var vector = new Vector3();
+ }
- return function computeBoundingSphere() {
+ },
- if ( this.boundingSphere === null ) {
+ computeBoundingSphere: function () {
- this.boundingSphere = new Sphere();
+ if ( this.boundingSphere === null ) {
- }
+ this.boundingSphere = new Sphere();
- var position = this.attributes.position;
- var morphAttributesPosition = this.morphAttributes.position;
+ }
- if ( position ) {
+ var position = this.attributes.position;
+ var morphAttributesPosition = this.morphAttributes.position;
- // first, find the center of the bounding sphere
+ if ( position ) {
- var center = this.boundingSphere.center;
+ // first, find the center of the bounding sphere
- box.setFromBufferAttribute( position );
+ var center = this.boundingSphere.center;
- // process morph attributes if present
+ _box$1.setFromBufferAttribute( position );
- if ( morphAttributesPosition ) {
+ // process morph attributes if present
- for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {
+ if ( morphAttributesPosition ) {
- var morphAttribute = morphAttributesPosition[ i ];
- boxMorphTargets.setFromBufferAttribute( morphAttribute );
+ for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {
- box.expandByPoint( boxMorphTargets.min );
- box.expandByPoint( boxMorphTargets.max );
+ var morphAttribute = morphAttributesPosition[ i ];
+ _boxMorphTargets.setFromBufferAttribute( morphAttribute );
- }
+ _box$1.expandByPoint( _boxMorphTargets.min );
+ _box$1.expandByPoint( _boxMorphTargets.max );
}
- box.getCenter( center );
+ }
- // second, try to find a boundingSphere with a radius smaller than the
- // boundingSphere of the boundingBox: sqrt(3) smaller in the best case
+ _box$1.getCenter( center );
- var maxRadiusSq = 0;
+ // second, try to find a boundingSphere with a radius smaller than the
+ // boundingSphere of the boundingBox: sqrt(3) smaller in the best case
- for ( var i = 0, il = position.count; i < il; i ++ ) {
+ var maxRadiusSq = 0;
- vector.fromBufferAttribute( position, i );
+ for ( var i = 0, il = position.count; i < il; i ++ ) {
- maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
+ _vector$4.fromBufferAttribute( position, i );
- }
+ maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$4 ) );
- // process morph attributes if present
+ }
- if ( morphAttributesPosition ) {
+ // process morph attributes if present
- for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {
+ if ( morphAttributesPosition ) {
- var morphAttribute = morphAttributesPosition[ i ];
+ for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {
- for ( var j = 0, jl = morphAttribute.count; j < jl; j ++ ) {
+ var morphAttribute = morphAttributesPosition[ i ];
- vector.fromBufferAttribute( morphAttribute, j );
+ for ( var j = 0, jl = morphAttribute.count; j < jl; j ++ ) {
- maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
+ _vector$4.fromBufferAttribute( morphAttribute, j );
- }
+ maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$4 ) );
}
}
- this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
+ }
- if ( isNaN( this.boundingSphere.radius ) ) {
+ this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
- console.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this );
+ if ( isNaN( this.boundingSphere.radius ) ) {
- }
+ console.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this );
}
- };
+ }
- }(),
+ },
computeFaceNormals: function () {
@@ -10656,27 +10390,21 @@
normalizeNormals: function () {
- var vector = new Vector3();
-
- return function normalizeNormals() {
+ var normals = this.attributes.normal;
- var normals = this.attributes.normal;
+ for ( var i = 0, il = normals.count; i < il; i ++ ) {
- for ( var i = 0, il = normals.count; i < il; i ++ ) {
+ _vector$4.x = normals.getX( i );
+ _vector$4.y = normals.getY( i );
+ _vector$4.z = normals.getZ( i );
- vector.x = normals.getX( i );
- vector.y = normals.getY( i );
- vector.z = normals.getZ( i );
+ _vector$4.normalize();
- vector.normalize();
+ normals.setXYZ( i, _vector$4.x, _vector$4.y, _vector$4.z );
- normals.setXYZ( i, vector.x, vector.y, vector.z );
-
- }
-
- };
+ }
- }(),
+ },
toNonIndexed: function () {
@@ -11029,6 +10757,29 @@
* @author jonobr1 / http://jonobr1.com/
*/
+ var _inverseMatrix = new Matrix4();
+ var _ray = new Ray();
+ var _sphere = new Sphere();
+
+ var _vA = new Vector3();
+ var _vB = new Vector3();
+ var _vC = new Vector3();
+
+ var _tempA = new Vector3();
+ var _tempB = new Vector3();
+ var _tempC = new Vector3();
+
+ var _morphA = new Vector3();
+ var _morphB = new Vector3();
+ var _morphC = new Vector3();
+
+ var _uvA = new Vector2();
+ var _uvB = new Vector2();
+ var _uvC = new Vector2();
+
+ var _intersectionPoint = new Vector3();
+ var _intersectionPointWorld = new Vector3();
+
function Mesh( geometry, material ) {
Object3D.call( this );
@@ -11124,357 +10875,330 @@
},
- raycast: ( function () {
-
- var inverseMatrix = new Matrix4();
- var ray = new Ray();
- var sphere = new Sphere();
-
- var vA = new Vector3();
- var vB = new Vector3();
- var vC = new Vector3();
-
- var tempA = new Vector3();
- var tempB = new Vector3();
- var tempC = new Vector3();
-
- var morphA = new Vector3();
- var morphB = new Vector3();
- var morphC = new Vector3();
-
- var uvA = new Vector2();
- var uvB = new Vector2();
- var uvC = new Vector2();
-
- var intersectionPoint = new Vector3();
- var intersectionPointWorld = new Vector3();
-
- function checkIntersection( object, material, raycaster, ray, pA, pB, pC, point ) {
+ raycast: function ( raycaster, intersects ) {
- var intersect;
+ var geometry = this.geometry;
+ var material = this.material;
+ var matrixWorld = this.matrixWorld;
- if ( material.side === BackSide ) {
+ if ( material === undefined ) return;
- intersect = ray.intersectTriangle( pC, pB, pA, true, point );
+ // Checking boundingSphere distance to ray
- } else {
+ if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
- intersect = ray.intersectTriangle( pA, pB, pC, material.side !== DoubleSide, point );
+ _sphere.copy( geometry.boundingSphere );
+ _sphere.applyMatrix4( matrixWorld );
- }
+ if ( raycaster.ray.intersectsSphere( _sphere ) === false ) return;
- if ( intersect === null ) return null;
+ //
- intersectionPointWorld.copy( point );
- intersectionPointWorld.applyMatrix4( object.matrixWorld );
+ _inverseMatrix.getInverse( matrixWorld );
+ _ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );
- var distance = raycaster.ray.origin.distanceTo( intersectionPointWorld );
+ // Check boundingBox before continuing
- if ( distance < raycaster.near || distance > raycaster.far ) return null;
+ if ( geometry.boundingBox !== null ) {
- return {
- distance: distance,
- point: intersectionPointWorld.clone(),
- object: object
- };
+ if ( _ray.intersectsBox( geometry.boundingBox ) === false ) return;
}
- function checkBufferGeometryIntersection( object, material, raycaster, ray, position, morphPosition, uv, uv2, a, b, c ) {
+ var intersection;
- vA.fromBufferAttribute( position, a );
- vB.fromBufferAttribute( position, b );
- vC.fromBufferAttribute( position, c );
-
- var morphInfluences = object.morphTargetInfluences;
+ if ( geometry.isBufferGeometry ) {
- if ( material.morphTargets && morphPosition && morphInfluences ) {
+ var a, b, c;
+ var index = geometry.index;
+ var position = geometry.attributes.position;
+ var morphPosition = geometry.morphAttributes.position;
+ var uv = geometry.attributes.uv;
+ var uv2 = geometry.attributes.uv2;
+ var groups = geometry.groups;
+ var drawRange = geometry.drawRange;
+ var i, j, il, jl;
+ var group, groupMaterial;
+ var start, end;
- morphA.set( 0, 0, 0 );
- morphB.set( 0, 0, 0 );
- morphC.set( 0, 0, 0 );
+ if ( index !== null ) {
- for ( var i = 0, il = morphPosition.length; i < il; i ++ ) {
+ // indexed buffer geometry
- var influence = morphInfluences[ i ];
- var morphAttribute = morphPosition[ i ];
+ if ( Array.isArray( material ) ) {
- if ( influence === 0 ) continue;
+ for ( i = 0, il = groups.length; i < il; i ++ ) {
- tempA.fromBufferAttribute( morphAttribute, a );
- tempB.fromBufferAttribute( morphAttribute, b );
- tempC.fromBufferAttribute( morphAttribute, c );
+ group = groups[ i ];
+ groupMaterial = material[ group.materialIndex ];
- morphA.addScaledVector( tempA.sub( vA ), influence );
- morphB.addScaledVector( tempB.sub( vB ), influence );
- morphC.addScaledVector( tempC.sub( vC ), influence );
+ start = Math.max( group.start, drawRange.start );
+ end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );
- }
+ for ( j = start, jl = end; j < jl; j += 3 ) {
- vA.add( morphA );
- vB.add( morphB );
- vC.add( morphC );
+ a = index.getX( j );
+ b = index.getX( j + 1 );
+ c = index.getX( j + 2 );
- }
+ intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray, position, morphPosition, uv, uv2, a, b, c );
- var intersection = checkIntersection( object, material, raycaster, ray, vA, vB, vC, intersectionPoint );
+ if ( intersection ) {
- if ( intersection ) {
+ intersection.faceIndex = Math.floor( j / 3 ); // triangle number in indexed buffer semantics
+ intersection.face.materialIndex = group.materialIndex;
+ intersects.push( intersection );
- if ( uv ) {
+ }
- uvA.fromBufferAttribute( uv, a );
- uvB.fromBufferAttribute( uv, b );
- uvC.fromBufferAttribute( uv, c );
+ }
- intersection.uv = Triangle.getUV( intersectionPoint, vA, vB, vC, uvA, uvB, uvC, new Vector2() );
+ }
- }
+ } else {
- if ( uv2 ) {
+ start = Math.max( 0, drawRange.start );
+ end = Math.min( index.count, ( drawRange.start + drawRange.count ) );
- uvA.fromBufferAttribute( uv2, a );
- uvB.fromBufferAttribute( uv2, b );
- uvC.fromBufferAttribute( uv2, c );
+ for ( i = start, il = end; i < il; i += 3 ) {
- intersection.uv2 = Triangle.getUV( intersectionPoint, vA, vB, vC, uvA, uvB, uvC, new Vector2() );
+ a = index.getX( i );
+ b = index.getX( i + 1 );
+ c = index.getX( i + 2 );
- }
+ intersection = checkBufferGeometryIntersection( this, material, raycaster, _ray, position, morphPosition, uv, uv2, a, b, c );
- var face = new Face3( a, b, c );
- Triangle.getNormal( vA, vB, vC, face.normal );
+ if ( intersection ) {
- intersection.face = face;
+ intersection.faceIndex = Math.floor( i / 3 ); // triangle number in indexed buffer semantics
+ intersects.push( intersection );
- }
+ }
- return intersection;
+ }
- }
+ }
- return function raycast( raycaster, intersects ) {
+ } else if ( position !== undefined ) {
- var geometry = this.geometry;
- var material = this.material;
- var matrixWorld = this.matrixWorld;
+ // non-indexed buffer geometry
- if ( material === undefined ) return;
+ if ( Array.isArray( material ) ) {
- // Checking boundingSphere distance to ray
+ for ( i = 0, il = groups.length; i < il; i ++ ) {
- if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
+ group = groups[ i ];
+ groupMaterial = material[ group.materialIndex ];
- sphere.copy( geometry.boundingSphere );
- sphere.applyMatrix4( matrixWorld );
+ start = Math.max( group.start, drawRange.start );
+ end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );
- if ( raycaster.ray.intersectsSphere( sphere ) === false ) return;
+ for ( j = start, jl = end; j < jl; j += 3 ) {
- //
+ a = j;
+ b = j + 1;
+ c = j + 2;
- inverseMatrix.getInverse( matrixWorld );
- ray.copy( raycaster.ray ).applyMatrix4( inverseMatrix );
+ intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray, position, morphPosition, uv, uv2, a, b, c );
- // Check boundingBox before continuing
+ if ( intersection ) {
- if ( geometry.boundingBox !== null ) {
+ intersection.faceIndex = Math.floor( j / 3 ); // triangle number in non-indexed buffer semantics
+ intersection.face.materialIndex = group.materialIndex;
+ intersects.push( intersection );
- if ( ray.intersectsBox( geometry.boundingBox ) === false ) return;
+ }
- }
+ }
- var intersection;
+ }
- if ( geometry.isBufferGeometry ) {
+ } else {
- var a, b, c;
- var index = geometry.index;
- var position = geometry.attributes.position;
- var morphPosition = geometry.morphAttributes.position;
- var uv = geometry.attributes.uv;
- var uv2 = geometry.attributes.uv2;
- var groups = geometry.groups;
- var drawRange = geometry.drawRange;
- var i, j, il, jl;
- var group, groupMaterial;
- var start, end;
+ start = Math.max( 0, drawRange.start );
+ end = Math.min( position.count, ( drawRange.start + drawRange.count ) );
- if ( index !== null ) {
+ for ( i = start, il = end; i < il; i += 3 ) {
- // indexed buffer geometry
+ a = i;
+ b = i + 1;
+ c = i + 2;
- if ( Array.isArray( material ) ) {
+ intersection = checkBufferGeometryIntersection( this, material, raycaster, _ray, position, morphPosition, uv, uv2, a, b, c );
- for ( i = 0, il = groups.length; i < il; i ++ ) {
+ if ( intersection ) {
- group = groups[ i ];
- groupMaterial = material[ group.materialIndex ];
+ intersection.faceIndex = Math.floor( i / 3 ); // triangle number in non-indexed buffer semantics
+ intersects.push( intersection );
- start = Math.max( group.start, drawRange.start );
- end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );
-
- for ( j = start, jl = end; j < jl; j += 3 ) {
+ }
- a = index.getX( j );
- b = index.getX( j + 1 );
- c = index.getX( j + 2 );
+ }
- intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, ray, position, morphPosition, uv, uv2, a, b, c );
+ }
- if ( intersection ) {
+ }
- intersection.faceIndex = Math.floor( j / 3 ); // triangle number in indexed buffer semantics
- intersection.face.materialIndex = group.materialIndex;
- intersects.push( intersection );
+ } else if ( geometry.isGeometry ) {
- }
+ var fvA, fvB, fvC;
+ var isMultiMaterial = Array.isArray( material );
- }
+ var vertices = geometry.vertices;
+ var faces = geometry.faces;
+ var uvs;
- }
+ var faceVertexUvs = geometry.faceVertexUvs[ 0 ];
+ if ( faceVertexUvs.length > 0 ) uvs = faceVertexUvs;
- } else {
+ for ( var f = 0, fl = faces.length; f < fl; f ++ ) {
- start = Math.max( 0, drawRange.start );
- end = Math.min( index.count, ( drawRange.start + drawRange.count ) );
+ var face = faces[ f ];
+ var faceMaterial = isMultiMaterial ? material[ face.materialIndex ] : material;
- for ( i = start, il = end; i < il; i += 3 ) {
+ if ( faceMaterial === undefined ) continue;
- a = index.getX( i );
- b = index.getX( i + 1 );
- c = index.getX( i + 2 );
+ fvA = vertices[ face.a ];
+ fvB = vertices[ face.b ];
+ fvC = vertices[ face.c ];
- intersection = checkBufferGeometryIntersection( this, material, raycaster, ray, position, morphPosition, uv, uv2, a, b, c );
+ intersection = checkIntersection( this, faceMaterial, raycaster, _ray, fvA, fvB, fvC, _intersectionPoint );
- if ( intersection ) {
+ if ( intersection ) {
- intersection.faceIndex = Math.floor( i / 3 ); // triangle number in indexed buffer semantics
- intersects.push( intersection );
+ if ( uvs && uvs[ f ] ) {
- }
+ var uvs_f = uvs[ f ];
+ _uvA.copy( uvs_f[ 0 ] );
+ _uvB.copy( uvs_f[ 1 ] );
+ _uvC.copy( uvs_f[ 2 ] );
- }
+ intersection.uv = Triangle.getUV( _intersectionPoint, fvA, fvB, fvC, _uvA, _uvB, _uvC, new Vector2() );
}
- } else if ( position !== undefined ) {
+ intersection.face = face;
+ intersection.faceIndex = f;
+ intersects.push( intersection );
- // non-indexed buffer geometry
+ }
- if ( Array.isArray( material ) ) {
+ }
- for ( i = 0, il = groups.length; i < il; i ++ ) {
+ }
- group = groups[ i ];
- groupMaterial = material[ group.materialIndex ];
+ },
- start = Math.max( group.start, drawRange.start );
- end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );
+ clone: function () {
- for ( j = start, jl = end; j < jl; j += 3 ) {
+ return new this.constructor( this.geometry, this.material ).copy( this );
- a = j;
- b = j + 1;
- c = j + 2;
+ }
- intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, ray, position, morphPosition, uv, uv2, a, b, c );
+ } );
- if ( intersection ) {
+ function checkIntersection( object, material, raycaster, ray, pA, pB, pC, point ) {
- intersection.faceIndex = Math.floor( j / 3 ); // triangle number in non-indexed buffer semantics
- intersection.face.materialIndex = group.materialIndex;
- intersects.push( intersection );
+ var intersect;
- }
+ if ( material.side === BackSide ) {
- }
+ intersect = ray.intersectTriangle( pC, pB, pA, true, point );
- }
+ } else {
- } else {
+ intersect = ray.intersectTriangle( pA, pB, pC, material.side !== DoubleSide, point );
- start = Math.max( 0, drawRange.start );
- end = Math.min( position.count, ( drawRange.start + drawRange.count ) );
+ }
- for ( i = start, il = end; i < il; i += 3 ) {
+ if ( intersect === null ) return null;
- a = i;
- b = i + 1;
- c = i + 2;
+ _intersectionPointWorld.copy( point );
+ _intersectionPointWorld.applyMatrix4( object.matrixWorld );
- intersection = checkBufferGeometryIntersection( this, material, raycaster, ray, position, morphPosition, uv, uv2, a, b, c );
+ var distance = raycaster.ray.origin.distanceTo( _intersectionPointWorld );
- if ( intersection ) {
+ if ( distance < raycaster.near || distance > raycaster.far ) return null;
- intersection.faceIndex = Math.floor( i / 3 ); // triangle number in non-indexed buffer semantics
- intersects.push( intersection );
+ return {
+ distance: distance,
+ point: _intersectionPointWorld.clone(),
+ object: object
+ };
- }
+ }
- }
+ function checkBufferGeometryIntersection( object, material, raycaster, ray, position, morphPosition, uv, uv2, a, b, c ) {
- }
+ _vA.fromBufferAttribute( position, a );
+ _vB.fromBufferAttribute( position, b );
+ _vC.fromBufferAttribute( position, c );
- }
+ var morphInfluences = object.morphTargetInfluences;
- } else if ( geometry.isGeometry ) {
+ if ( material.morphTargets && morphPosition && morphInfluences ) {
- var fvA, fvB, fvC;
- var isMultiMaterial = Array.isArray( material );
+ _morphA.set( 0, 0, 0 );
+ _morphB.set( 0, 0, 0 );
+ _morphC.set( 0, 0, 0 );
- var vertices = geometry.vertices;
- var faces = geometry.faces;
- var uvs;
+ for ( var i = 0, il = morphPosition.length; i < il; i ++ ) {
- var faceVertexUvs = geometry.faceVertexUvs[ 0 ];
- if ( faceVertexUvs.length > 0 ) uvs = faceVertexUvs;
+ var influence = morphInfluences[ i ];
+ var morphAttribute = morphPosition[ i ];
- for ( var f = 0, fl = faces.length; f < fl; f ++ ) {
+ if ( influence === 0 ) continue;
- var face = faces[ f ];
- var faceMaterial = isMultiMaterial ? material[ face.materialIndex ] : material;
+ _tempA.fromBufferAttribute( morphAttribute, a );
+ _tempB.fromBufferAttribute( morphAttribute, b );
+ _tempC.fromBufferAttribute( morphAttribute, c );
- if ( faceMaterial === undefined ) continue;
+ _morphA.addScaledVector( _tempA.sub( _vA ), influence );
+ _morphB.addScaledVector( _tempB.sub( _vB ), influence );
+ _morphC.addScaledVector( _tempC.sub( _vC ), influence );
- fvA = vertices[ face.a ];
- fvB = vertices[ face.b ];
- fvC = vertices[ face.c ];
+ }
- intersection = checkIntersection( this, faceMaterial, raycaster, ray, fvA, fvB, fvC, intersectionPoint );
+ _vA.add( _morphA );
+ _vB.add( _morphB );
+ _vC.add( _morphC );
- if ( intersection ) {
+ }
- if ( uvs && uvs[ f ] ) {
+ var intersection = checkIntersection( object, material, raycaster, ray, _vA, _vB, _vC, _intersectionPoint );
- var uvs_f = uvs[ f ];
- uvA.copy( uvs_f[ 0 ] );
- uvB.copy( uvs_f[ 1 ] );
- uvC.copy( uvs_f[ 2 ] );
+ if ( intersection ) {
- intersection.uv = Triangle.getUV( intersectionPoint, fvA, fvB, fvC, uvA, uvB, uvC, new Vector2() );
+ if ( uv ) {
- }
+ _uvA.fromBufferAttribute( uv, a );
+ _uvB.fromBufferAttribute( uv, b );
+ _uvC.fromBufferAttribute( uv, c );
- intersection.face = face;
- intersection.faceIndex = f;
- intersects.push( intersection );
+ intersection.uv = Triangle.getUV( _intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() );
- }
+ }
- }
+ if ( uv2 ) {
- }
+ _uvA.fromBufferAttribute( uv2, a );
+ _uvB.fromBufferAttribute( uv2, b );
+ _uvC.fromBufferAttribute( uv2, c );
- };
+ intersection.uv2 = Triangle.getUV( _intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() );
- }() ),
+ }
- clone: function () {
+ var face = new Face3( a, b, c );
+ Triangle.getNormal( _vA, _vB, _vC, face.normal );
- return new this.constructor( this.geometry, this.material ).copy( this );
+ intersection.face = face;
}
- } );
+ return intersection;
+
+ }
/**
* @author mrdoob / http://mrdoob.com/
@@ -11485,11 +11209,14 @@
* @author bhouston / http://clara.io
*/
- var geometryId = 0; // Geometry uses even numbers as Id
+ var _geometryId = 0; // Geometry uses even numbers as Id
+ var _m1$3 = new Matrix4();
+ var _obj$1 = new Object3D();
+ var _offset$1 = new Vector3();
function Geometry() {
- Object.defineProperty( this, 'id', { value: geometryId += 2 } );
+ Object.defineProperty( this, 'id', { value: _geometryId += 2 } );
this.uuid = _Math.generateUUID();
@@ -11573,111 +11300,77 @@
},
- rotateX: function () {
+ rotateX: function ( angle ) {
// rotate geometry around world x-axis
- var m1 = new Matrix4();
-
- return function rotateX( angle ) {
+ _m1$3.makeRotationX( angle );
- m1.makeRotationX( angle );
+ this.applyMatrix( _m1$3 );
- this.applyMatrix( m1 );
-
- return this;
-
- };
+ return this;
- }(),
+ },
- rotateY: function () {
+ rotateY: function ( angle ) {
// rotate geometry around world y-axis
- var m1 = new Matrix4();
-
- return function rotateY( angle ) {
+ _m1$3.makeRotationY( angle );
- m1.makeRotationY( angle );
+ this.applyMatrix( _m1$3 );
- this.applyMatrix( m1 );
-
- return this;
-
- };
+ return this;
- }(),
+ },
- rotateZ: function () {
+ rotateZ: function ( angle ) {
// rotate geometry around world z-axis
- var m1 = new Matrix4();
-
- return function rotateZ( angle ) {
-
- m1.makeRotationZ( angle );
+ _m1$3.makeRotationZ( angle );
- this.applyMatrix( m1 );
+ this.applyMatrix( _m1$3 );
- return this;
-
- };
+ return this;
- }(),
+ },
- translate: function () {
+ translate: function ( x, y, z ) {
// translate geometry
- var m1 = new Matrix4();
-
- return function translate( x, y, z ) {
-
- m1.makeTranslation( x, y, z );
+ _m1$3.makeTranslation( x, y, z );
- this.applyMatrix( m1 );
+ this.applyMatrix( _m1$3 );
- return this;
-
- };
+ return this;
- }(),
+ },
- scale: function () {
+ scale: function ( x, y, z ) {
// scale geometry
- var m1 = new Matrix4();
-
- return function scale( x, y, z ) {
-
- m1.makeScale( x, y, z );
-
- this.applyMatrix( m1 );
-
- return this;
-
- };
+ _m1$3.makeScale( x, y, z );
- }(),
+ this.applyMatrix( _m1$3 );
- lookAt: function () {
+ return this;
- var obj = new Object3D();
+ },
- return function lookAt( vector ) {
+ lookAt: function ( vector ) {
- obj.lookAt( vector );
+ _obj$1.lookAt( vector );
- obj.updateMatrix();
+ _obj$1.updateMatrix();
- this.applyMatrix( obj.matrix );
+ this.applyMatrix( _obj$1.matrix );
- };
+ return this;
- }(),
+ },
fromBufferGeometry: function ( geometry ) {
@@ -11814,21 +11507,15 @@
center: function () {
- var offset = new Vector3();
-
- return function center() {
-
- this.computeBoundingBox();
+ this.computeBoundingBox();
- this.boundingBox.getCenter( offset ).negate();
+ this.boundingBox.getCenter( _offset$1 ).negate();
- this.translate( offset.x, offset.y, offset.z );
+ this.translate( _offset$1.x, _offset$1.y, _offset$1.z );
- return this;
-
- };
+ return this;
- }(),
+ },
normalize: function () {
@@ -13918,6 +13605,10 @@
* @author bhouston / http://clara.io
*/
+ var _vector1 = new Vector3();
+ var _vector2 = new Vector3();
+ var _normalMatrix = new Matrix3();
+
function Plane( normal, constant ) {
// normal is assumed to be normalized
@@ -13958,24 +13649,17 @@
},
- setFromCoplanarPoints: function () {
-
- var v1 = new Vector3();
- var v2 = new Vector3();
+ setFromCoplanarPoints: function ( a, b, c ) {
- return function setFromCoplanarPoints( a, b, c ) {
+ var normal = _vector1.subVectors( c, b ).cross( _vector2.subVectors( a, b ) ).normalize();
- var normal = v1.subVectors( c, b ).cross( v2.subVectors( a, b ) ).normalize();
+ // Q: should an error be thrown if normal is zero (e.g. degenerate plane)?
- // Q: should an error be thrown if normal is zero (e.g. degenerate plane)?
+ this.setFromNormalAndCoplanarPoint( normal, a );
- this.setFromNormalAndCoplanarPoint( normal, a );
-
- return this;
-
- };
+ return this;
- }(),
+ },
clone: function () {
@@ -14038,50 +13722,44 @@
},
- intersectLine: function () {
-
- var v1 = new Vector3();
-
- return function intersectLine( line, target ) {
-
- if ( target === undefined ) {
-
- console.warn( 'THREE.Plane: .intersectLine() target is now required' );
- target = new Vector3();
+ intersectLine: function ( line, target ) {
- }
+ if ( target === undefined ) {
- var direction = line.delta( v1 );
+ console.warn( 'THREE.Plane: .intersectLine() target is now required' );
+ target = new Vector3();
- var denominator = this.normal.dot( direction );
+ }
- if ( denominator === 0 ) {
+ var direction = line.delta( _vector1 );
- // line is coplanar, return origin
- if ( this.distanceToPoint( line.start ) === 0 ) {
+ var denominator = this.normal.dot( direction );
- return target.copy( line.start );
+ if ( denominator === 0 ) {
- }
+ // line is coplanar, return origin
+ if ( this.distanceToPoint( line.start ) === 0 ) {
- // Unsure if this is the correct method to handle this case.
- return undefined;
+ return target.copy( line.start );
}
- var t = - ( line.start.dot( this.normal ) + this.constant ) / denominator;
+ // Unsure if this is the correct method to handle this case.
+ return undefined;
+
+ }
- if ( t < 0 || t > 1 ) {
+ var t = - ( line.start.dot( this.normal ) + this.constant ) / denominator;
- return undefined;
+ if ( t < 0 || t > 1 ) {
- }
+ return undefined;
- return target.copy( direction ).multiplyScalar( t ).add( line.start );
+ }
- };
+ return target.copy( direction ).multiplyScalar( t ).add( line.start );
- }(),
+ },
intersectsLine: function ( line ) {
@@ -14119,26 +13797,19 @@
},
- applyMatrix4: function () {
-
- var v1 = new Vector3();
- var m1 = new Matrix3();
+ applyMatrix4: function ( matrix, optionalNormalMatrix ) {
- return function applyMatrix4( matrix, optionalNormalMatrix ) {
+ var normalMatrix = optionalNormalMatrix || _normalMatrix.getNormalMatrix( matrix );
- var normalMatrix = optionalNormalMatrix || m1.getNormalMatrix( matrix );
+ var referencePoint = this.coplanarPoint( _vector1 ).applyMatrix4( matrix );
- var referencePoint = this.coplanarPoint( v1 ).applyMatrix4( matrix );
+ var normal = this.normal.applyMatrix3( normalMatrix ).normalize();
- var normal = this.normal.applyMatrix3( normalMatrix ).normalize();
+ this.constant = - referencePoint.dot( normal );
- this.constant = - referencePoint.dot( normal );
-
- return this;
-
- };
+ return this;
- }(),
+ },
translate: function ( offset ) {
@@ -14162,6 +13833,9 @@
* @author bhouston / http://clara.io
*/
+ var _sphere$1 = new Sphere();
+ var _vector$5 = new Vector3();
+
function Frustum( p0, p1, p2, p3, p4, p5 ) {
this.planes = [
@@ -14234,41 +13908,27 @@
},
- intersectsObject: function () {
-
- var sphere = new Sphere();
+ intersectsObject: function ( object ) {
- return function intersectsObject( object ) {
-
- var geometry = object.geometry;
-
- if ( geometry.boundingSphere === null )
- geometry.computeBoundingSphere();
-
- sphere.copy( geometry.boundingSphere )
- .applyMatrix4( object.matrixWorld );
-
- return this.intersectsSphere( sphere );
-
- };
+ var geometry = object.geometry;
- }(),
+ if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
- intersectsSprite: function () {
+ _sphere$1.copy( geometry.boundingSphere ).applyMatrix4( object.matrixWorld );
- var sphere = new Sphere();
+ return this.intersectsSphere( _sphere$1 );
- return function intersectsSprite( sprite ) {
+ },
- sphere.center.set( 0, 0, 0 );
- sphere.radius = 0.7071067811865476;
- sphere.applyMatrix4( sprite.matrixWorld );
+ intersectsSprite: function ( sprite ) {
- return this.intersectsSphere( sphere );
+ _sphere$1.center.set( 0, 0, 0 );
+ _sphere$1.radius = 0.7071067811865476;
+ _sphere$1.applyMatrix4( sprite.matrixWorld );
- };
+ return this.intersectsSphere( _sphere$1 );
- }(),
+ },
intersectsSphere: function ( sphere ) {
@@ -14292,37 +13952,31 @@
},
- intersectsBox: function () {
-
- var p = new Vector3();
-
- return function intersectsBox( box ) {
-
- var planes = this.planes;
+ intersectsBox: function ( box ) {
- for ( var i = 0; i < 6; i ++ ) {
+ var planes = this.planes;
- var plane = planes[ i ];
+ for ( var i = 0; i < 6; i ++ ) {
- // corner at max distance
+ var plane = planes[ i ];
- p.x = plane.normal.x > 0 ? box.max.x : box.min.x;
- p.y = plane.normal.y > 0 ? box.max.y : box.min.y;
- p.z = plane.normal.z > 0 ? box.max.z : box.min.z;
+ // corner at max distance
- if ( plane.distanceToPoint( p ) < 0 ) {
+ _vector$5.x = plane.normal.x > 0 ? box.max.x : box.min.x;
+ _vector$5.y = plane.normal.y > 0 ? box.max.y : box.min.y;
+ _vector$5.z = plane.normal.z > 0 ? box.max.z : box.min.z;
- return false;
+ if ( plane.distanceToPoint( _vector$5 ) < 0 ) {
- }
+ return false;
}
- return true;
+ }
- };
+ return true;
- }(),
+ },
containsPoint: function ( point ) {
@@ -14350,7 +14004,7 @@
var alphatest_fragment = "#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif";
- var aomap_fragment = "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif";
+ var aomap_fragment = "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif";
var aomap_pars_fragment = "#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif";
@@ -14358,17 +14012,17 @@
var beginnormal_vertex = "vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif";
- var bsdfs = "vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}";
+ var bsdfs = "vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif";
var bumpmap_pars_fragment = "#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif";
var clipping_planes_fragment = "#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t#endif\n#endif";
- var clipping_planes_pars_fragment = "#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif";
+ var clipping_planes_pars_fragment = "#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif";
- var clipping_planes_pars_vertex = "#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvarying vec3 vViewPosition;\n#endif";
+ var clipping_planes_pars_vertex = "#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvarying vec3 vViewPosition;\n#endif";
- var clipping_planes_vertex = "#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif";
+ var clipping_planes_vertex = "#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif";
var color_fragment = "#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif";
@@ -14378,7 +14032,7 @@
var color_vertex = "#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif";
- var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}";
+ var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}";
var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV( sampler2D envMap, vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif";
@@ -14396,19 +14050,21 @@
var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}";
- var envmap_fragment = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif";
+ var envmap_fragment = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif";
- var envmap_pars_fragment = "#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif";
+ var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif";
- var envmap_pars_vertex = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif";
+ var envmap_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif";
- var envmap_vertex = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif";
+ var envmap_pars_vertex = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif";
+
+ var envmap_vertex = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif";
var fog_vertex = "#ifdef USE_FOG\n\tfogDepth = -mvPosition.z;\n#endif";
var fog_pars_vertex = "#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif";
- var fog_fragment = "#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif";
+ var fog_fragment = "#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif";
var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif";
@@ -14422,21 +14078,21 @@
var lights_pars_begin = "uniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif";
- var envmap_physical_pars_fragment = "#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent ));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif";
+ var envmap_physical_pars_fragment = "#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, roughness );\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif";
var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;";
var lights_phong_pars_fragment = "varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)";
- var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif";
+ var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = saturate( clearcoat );\tmaterial.clearcoatRoughness = clamp( clearcoatRoughness, 0.04, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif";
- var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\t\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#endif\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\tfloat clearCoatInv = 1.0 - clearCoatDHR;\n\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec3 singleScattering = vec3( 0.0 );\n\t\tvec3 multiScattering = vec3( 0.0 );\n\t\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\t\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\t\treflectedLight.indirectSpecular += clearCoatInv * radiance * singleScattering;\n\t\treflectedLight.indirectDiffuse += multiScattering * cosineWeightedIrradiance;\n\t\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n\t#else\n\t\treflectedLight.indirectSpecular += clearCoatInv * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#endif\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
+ var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectDiffuse += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
- var lights_fragment_begin = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearCoatRadiance = vec3( 0.0 );\n#endif";
+ var lights_fragment_begin = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif";
- var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), maxMipLevel );\n\t#ifndef STANDARD\n\t\tclearCoatRadiance += getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel );\n\t#endif\n#endif";
+ var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif";
- var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, irradiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif";
+ var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif";
var logdepthbuf_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif";
@@ -14464,33 +14120,39 @@
var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif";
- var normal_fragment_begin = "#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t#endif\n#endif";
+ var normal_fragment_begin = "#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;";
+
+ var normal_fragment_maps = "#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\t#ifdef USE_TANGENT\n\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, normalScale, normalMap );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif";
+
+ var normalmap_pars_fragment = "#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec2 normalScale, in sampler2D normalMap ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy *= normalScale;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvec3 NfromST = cross( S, T );\n\t\t\tif( dot( NfromST, N ) > 0.0 ) {\n\t\t\t\tS *= -1.0;\n\t\t\t\tT *= -1.0;\n\t\t\t}\n\t\t#else\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif";
- var normal_fragment_maps = "#ifdef USE_NORMALMAP\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t#ifdef FLIP_SIDED\n\t\t\tnormal = - normal;\n\t\t#endif\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\tnormal = normalize( normalMatrix * normal );\n\t#else\n\t\t#ifdef USE_TANGENT\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t\tmapN.xy = normalScale * mapN.xy;\n\t\t\tnormal = normalize( vTBN * mapN );\n\t\t#else\n\t\t\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n\t\t#endif\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif";
+ var clearcoat_normal_fragment_begin = "#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif";
- var normalmap_pars_fragment = "#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tuniform mat3 normalMatrix;\n\t#else\n\t\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\t\tvec2 st0 = dFdx( vUv.st );\n\t\t\tvec2 st1 = dFdy( vUv.st );\n\t\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\t\tvec3 N = normalize( surf_norm );\n\t\t\tmat3 tsn = mat3( S, T, N );\n\t\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t\tmapN.xy *= normalScale;\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\treturn normalize( tsn * mapN );\n\t\t}\n\t#endif\n#endif";
+ var clearcoat_normal_fragment_maps = "#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 vTBN = mat3( tangent, bitangent, clearcoatNormal );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = clearcoatNormalScale * mapN.xy;\n\t\tclearcoatNormal = normalize( vTBN * mapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatNormalScale, clearcoatNormalMap );\n\t#endif\n#endif";
- var packing = "vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}";
+ var clearcoat_normalmap_pars_fragment = "#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif";
+
+ var packing = "vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 encodeHalfRGBA ( vec2 v ) {\n\tvec4 encoded = vec4( 0.0 );\n\tconst vec2 offset = vec2( 1.0 / 255.0, 0.0 );\n\tencoded.xy = vec2( v.x, fract( v.x * 255.0 ) );\n\tencoded.xy = encoded.xy - ( encoded.yy * offset );\n\tencoded.zw = vec2( v.y, fract( v.y * 255.0 ) );\n\tencoded.zw = encoded.zw - ( encoded.ww * offset );\n\treturn encoded;\n}\nvec2 decodeHalfRGBA( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}";
var premultiplied_alpha_fragment = "#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif";
var project_vertex = "vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;";
- var dithering_fragment = "#if defined( DITHERING )\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif";
+ var dithering_fragment = "#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif";
- var dithering_pars_fragment = "#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif";
+ var dithering_pars_fragment = "#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif";
var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif";
var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif";
- var shadowmap_pars_fragment = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif";
+ var shadowmap_pars_fragment = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn decodeHalfRGBA( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = ( floor( uv * size - 0.5 ) + 0.5 ) * texelSize;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif";
- var shadowmap_pars_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif";
+ var shadowmap_pars_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif";
- var shadowmap_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif";
+ var shadowmap_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif";
- var shadowmask_pars_fragment = "float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}";
+ var shadowmask_pars_fragment = "float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}";
var skinbase_vertex = "#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif";
@@ -14508,11 +14170,11 @@
var tonemapping_pars_fragment = "#ifndef saturate\n\t#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}";
- var uv_pars_fragment = "#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif";
+ var uv_pars_fragment = "#ifdef USE_UV\n\tvarying vec2 vUv;\n#endif";
- var uv_pars_vertex = "#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif";
+ var uv_pars_vertex = "#ifdef USE_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif";
- var uv_vertex = "#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif";
+ var uv_vertex = "#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif";
var uv2_pars_fragment = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif";
@@ -14546,11 +14208,11 @@
var linedashed_vert = "uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include