diff --git a/build/three.js b/build/three.js index 972101d37ad3f26284c9642bec96c40baf5b86a4..bc71bab2926856b94ad0c3b506a337a8286045db 100644 --- a/build/three.js +++ b/build/three.js @@ -23409,7 +23409,7 @@ THREE.ShaderChunk[ 'color_vertex' ] = "#ifdef USE_COLOR\n vColor.xyz = color.xyz // File:src/renderers/shaders/ShaderChunk/common.glsl -THREE.ShaderChunk[ 'common' ] = "#define PI 3.14159\n#define PI2 6.28318\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 square( const in float x ) { return x*x; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n};\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\nstruct GeometricContext {\n vec3 position;\n vec3 normal;\n vec3 viewDir;\n};\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n int shadowEnabled;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n mat4 shadowMatrix;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float angleCos;\n float exponent;\n int shadowEnabled;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n mat4 shadowMatrix;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n int shadowEnabled;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n mat4 shadowMatrix;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n float distance = dot( planeNormal, point - pointOnPlane );\n return - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n return sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nvec3 inputToLinear( in vec3 a ) {\n #ifdef GAMMA_INPUT\n return pow( a, vec3( float( GAMMA_FACTOR ) ) );\n #else\n return a;\n #endif\n}\nvec3 linearToOutput( in vec3 a ) {\n #ifdef GAMMA_OUTPUT\n return pow( a, vec3( 1.0 / float( GAMMA_FACTOR ) ) );\n #else\n return a;\n #endif\n}\n"; +THREE.ShaderChunk[ 'common' ] = "#define PI 3.14159\n#define PI2 6.28318\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 square( const in float x ) { return x*x; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n};\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\nstruct GeometricContext {\n vec3 position;\n vec3 normal;\n vec3 viewDir;\n};\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float angleCos;\n float exponent;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n float distance = dot( planeNormal, point - pointOnPlane );\n return - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n return sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nvec3 inputToLinear( in vec3 a ) {\n #ifdef GAMMA_INPUT\n return pow( a, vec3( float( GAMMA_FACTOR ) ) );\n #else\n return a;\n #endif\n}\nvec3 linearToOutput( in vec3 a ) {\n #ifdef GAMMA_OUTPUT\n return pow( a, vec3( 1.0 / float( GAMMA_FACTOR ) ) );\n #else\n return a;\n #endif\n}\n"; // File:src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl @@ -23497,7 +23497,7 @@ THREE.ShaderChunk[ 'lights_standard_pars_fragment' ] = "struct StandardMaterial // File:src/renderers/shaders/ShaderChunk/lights_template.glsl -THREE.ShaderChunk[ 'lights_template' ] = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n directLight = getPointDirectLight( pointLight, geometry );\n #ifdef USE_SHADOWMAP\n if ( bool( pointLight.shadowEnabled ) ) directLight.color *= getPointShadow( pointLightsShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] );\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n directLight = getSpotDirectLight( spotLight, geometry );\n #ifdef USE_SHADOWMAP\n if ( bool( spotLight.shadowEnabled ) ) directLight.color *= getShadow( spotLightsShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] );\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n directLight = getDirectionalDirectLight( directionalLight, geometry );\n #ifdef USE_SHADOWMAP\n if ( bool( directionalLight.shadowEnabled ) ) directLight.color *= getShadow( directionalLightsShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] );\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #ifdef USE_LIGHTMAP\n irradiance += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n }\n #endif\n RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n vec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n RE_IndirectSpecular( radiance, geometry, material, reflectedLight );\n#endif\n"; +THREE.ShaderChunk[ 'lights_template' ] = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n directLight = getPointDirectLight( pointLight, geometry );\n #ifdef USE_SHADOWMAP\n directLight.color *= pointShadow[ i ] ? getPointShadow( pointShadowMap[ i ], pointShadowMapSize[ i ], pointShadowBias[ i ], pointShadowRadius[ i ], vPointShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n directLight = getSpotDirectLight( spotLight, geometry );\n #ifdef USE_SHADOWMAP\n directLight.color *= spotShadow[ i ] ? getShadow( spotShadowMap[ i ], spotShadowMapSize[ i ], spotShadowBias[ i ], spotShadowRadius[ i ], vSpotShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n directLight = getDirectionalDirectLight( directionalLight, geometry );\n #ifdef USE_SHADOWMAP\n directLight.color *= directionalShadow[ i ] ? getShadow( directionalShadowMap[ i ], directionalShadowMapSize[ i ], directionalShadowBias[ i ], directionalShadowRadius[ i ], vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #ifdef USE_LIGHTMAP\n irradiance += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n }\n #endif\n RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n vec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n RE_IndirectSpecular( radiance, geometry, material, reflectedLight );\n#endif\n"; // File:src/renderers/shaders/ShaderChunk/linear_to_gamma_fragment.glsl @@ -23577,15 +23577,15 @@ THREE.ShaderChunk[ 'roughnessmap_pars_fragment' ] = "#ifdef USE_ROUGHNESSMAP\n u // File:src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl -THREE.ShaderChunk[ 'shadowmap_pars_fragment' ] = "#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHTS > 0\n uniform sampler2D directionalLightsShadowMap[ NUM_DIR_LIGHTS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n #endif\n #if NUM_SPOT_LIGHTS > 0\n uniform sampler2D spotLightsShadowMap[ NUM_SPOT_LIGHTS ];\n varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n #endif\n #if NUM_POINT_LIGHTS > 0\n uniform sampler2D pointLightsShadowMap[ NUM_POINT_LIGHTS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n #endif\n float unpackDepth( const in vec4 rgba_depth ) {\n const vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\n return dot( rgba_depth, bit_shift );\n }\n float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n return step( compare, unpackDepth( texture2D( depths, uv ) ) );\n }\n float texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n const vec2 offset = vec2( 0.0, 1.0 );\n vec2 texelSize = vec2( 1.0 ) / size;\n vec2 centroidUV = floor( uv * size + 0.5 ) / size;\n float lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n float lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n float rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n float rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n vec2 f = fract( uv * size + 0.5 );\n float a = mix( lb, lt, f.y );\n float b = mix( rb, rt, f.y );\n float c = mix( a, b, f.x );\n return c;\n }\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n bool inFrustum = all( inFrustumVec );\n bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n bool frustumTest = all( frustumTestVec );\n if ( frustumTest ) {\n #if defined( SHADOWMAP_TYPE_PCF )\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float dx0 = - texelSize.x * shadowRadius;\n float dy0 = - texelSize.y * shadowRadius;\n float dx1 = + texelSize.x * shadowRadius;\n float dy1 = + texelSize.y * shadowRadius;\n return (\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n ) * ( 1.0 / 9.0 );\n #elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float dx0 = - texelSize.x * shadowRadius;\n float dy0 = - texelSize.y * shadowRadius;\n float dx1 = + texelSize.x * shadowRadius;\n float dy1 = + texelSize.y * shadowRadius;\n return (\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n ) * ( 1.0 / 9.0 );\n #else\n return texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n #endif\n }\n return 1.0;\n }\n vec2 cubeToUV( vec3 v, float texelSizeY ) {\n vec3 absV = abs( v );\n float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n absV *= scaleToCube;\n v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n vec2 planar = v.xy;\n float almostATexel = 1.5 * texelSizeY;\n float almostOne = 1.0 - almostATexel;\n if ( absV.z >= almostOne ) {\n if ( v.z > 0.0 )\n planar.x = 4.0 - v.x;\n } else if ( absV.x >= almostOne ) {\n float signX = sign( v.x );\n planar.x = v.z * signX + 2.0 * signX;\n } else if ( absV.y >= almostOne ) {\n float signY = sign( v.y );\n planar.x = v.x + 2.0 * signY + 2.0;\n planar.y = v.z * signY - 2.0;\n }\n return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n }\n float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n float dp = ( length( lightToPosition ) - shadowBias ) / 1000.0;\n #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n vec3 offset = vec3( - 1, 0, 1 ) * shadowRadius * 2.0 * texelSize.y;\n return (\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.zzz, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.zxz, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxz, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xzz, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.zzx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.zxx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xzx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.zzy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.zxy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xzy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.zyz, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyz, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.zyx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yzz, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxz, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yzx, texelSize.y ), dp )\n ) * ( 1.0 / 21.0 );\n #else\n return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n #endif\n }\n#endif\n"; +THREE.ShaderChunk[ 'shadowmap_pars_fragment' ] = "#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHTS > 0\n uniform bool directionalShadow[ NUM_DIR_LIGHTS ];\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n uniform vec2 directionalShadowMapSize[ NUM_DIR_LIGHTS ];\n uniform float directionalShadowBias[ NUM_DIR_LIGHTS ];\n uniform float directionalShadowRadius[ NUM_DIR_LIGHTS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n #endif\n #if NUM_SPOT_LIGHTS > 0\n uniform bool spotShadow[ NUM_SPOT_LIGHTS ];\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n uniform vec2 spotShadowMapSize[ NUM_SPOT_LIGHTS ];\n uniform float spotShadowBias[ NUM_SPOT_LIGHTS ];\n uniform float spotShadowRadius[ NUM_SPOT_LIGHTS ];\n varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n #endif\n #if NUM_POINT_LIGHTS > 0\n uniform bool pointShadow[ NUM_POINT_LIGHTS ];\n uniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n uniform vec2 pointShadowMapSize[ NUM_POINT_LIGHTS ];\n uniform float pointShadowBias[ NUM_POINT_LIGHTS ];\n uniform float pointShadowRadius[ NUM_POINT_LIGHTS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n #endif\n float unpackDepth( const in vec4 rgba_depth ) {\n const vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\n return dot( rgba_depth, bit_shift );\n }\n float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n return step( compare, unpackDepth( texture2D( depths, uv ) ) );\n }\n float texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n const vec2 offset = vec2( 0.0, 1.0 );\n vec2 texelSize = vec2( 1.0 ) / size;\n vec2 centroidUV = floor( uv * size + 0.5 ) / size;\n float lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n float lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n float rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n float rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n vec2 f = fract( uv * size + 0.5 );\n float a = mix( lb, lt, f.y );\n float b = mix( rb, rt, f.y );\n float c = mix( a, b, f.x );\n return c;\n }\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n bool inFrustum = all( inFrustumVec );\n bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n bool frustumTest = all( frustumTestVec );\n if ( frustumTest ) {\n #if defined( SHADOWMAP_TYPE_PCF )\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float dx0 = - texelSize.x * shadowRadius;\n float dy0 = - texelSize.y * shadowRadius;\n float dx1 = + texelSize.x * shadowRadius;\n float dy1 = + texelSize.y * shadowRadius;\n return (\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n ) * ( 1.0 / 9.0 );\n #elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float dx0 = - texelSize.x * shadowRadius;\n float dy0 = - texelSize.y * shadowRadius;\n float dx1 = + texelSize.x * shadowRadius;\n float dy1 = + texelSize.y * shadowRadius;\n return (\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n ) * ( 1.0 / 9.0 );\n #else\n return texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n #endif\n }\n return 1.0;\n }\n vec2 cubeToUV( vec3 v, float texelSizeY ) {\n vec3 absV = abs( v );\n float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n absV *= scaleToCube;\n v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n vec2 planar = v.xy;\n float almostATexel = 1.5 * texelSizeY;\n float almostOne = 1.0 - almostATexel;\n if ( absV.z >= almostOne ) {\n if ( v.z > 0.0 )\n planar.x = 4.0 - v.x;\n } else if ( absV.x >= almostOne ) {\n float signX = sign( v.x );\n planar.x = v.z * signX + 2.0 * signX;\n } else if ( absV.y >= almostOne ) {\n float signY = sign( v.y );\n planar.x = v.x + 2.0 * signY + 2.0;\n planar.y = v.z * signY - 2.0;\n }\n return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n }\n float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n float dp = ( length( lightToPosition ) - shadowBias ) / 1000.0;\n #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n vec3 offset = vec3( - 1, 0, 1 ) * shadowRadius * 2.0 * texelSize.y;\n return (\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.zzz, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.zxz, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxz, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xzz, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.zzx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.zxx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xzx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.zzy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.zxy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xzy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.zyz, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyz, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.zyx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yzz, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxz, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yzx, texelSize.y ), dp )\n ) * ( 1.0 / 21.0 );\n #else\n return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n #endif\n }\n#endif\n"; // File:src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl -THREE.ShaderChunk[ 'shadowmap_pars_vertex' ] = "#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHTS > 0\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n #endif\n #if NUM_SPOT_LIGHTS > 0\n varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n #endif\n #if NUM_POINT_LIGHTS > 0\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n #endif\n#endif\n"; +THREE.ShaderChunk[ 'shadowmap_pars_vertex' ] = "#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHTS > 0\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n #endif\n #if NUM_SPOT_LIGHTS > 0\n uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n #endif\n #if NUM_POINT_LIGHTS > 0\n uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n #endif\n#endif\n"; // File:src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl -THREE.ShaderChunk[ 'shadowmap_vertex' ] = "#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHTS > 0\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n vDirectionalShadowCoord[ i ] = directionalLights[ i ].shadowMatrix * worldPosition;\n }\n #endif\n #if NUM_SPOT_LIGHTS > 0\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n vSpotShadowCoord[ i ] = spotLights[ i ].shadowMatrix * worldPosition;\n }\n #endif\n #if NUM_POINT_LIGHTS > 0\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n vPointShadowCoord[ i ] = pointLights[ i ].shadowMatrix * worldPosition;\n }\n #endif\n#endif\n"; +THREE.ShaderChunk[ 'shadowmap_vertex' ] = "#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHTS > 0\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n }\n #endif\n #if NUM_SPOT_LIGHTS > 0\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n }\n #endif\n #if NUM_POINT_LIGHTS > 0\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n }\n #endif\n#endif\n"; // File:src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl @@ -23808,17 +23808,9 @@ THREE.UniformsLib = { "directionalLights": { type: "sa", value: [], properties: { "direction": { type: "v3" }, - "color": { type: "c" }, - - "shadowEnabled": { type: "i" }, - "shadowBias": { type: "f" }, - "shadowRadius": { type: "f" }, - "shadowMapSize": { type: "v2" }, - "shadowMatrix": { type: "m4" } + "color": { type: "c" } } }, - "directionalLightsShadowMap": { type: "tv", value: [] }, - "spotLights": { type: "sa", value: [], properties: { "color": { type: "c" }, "position": { type: "v3" }, @@ -23826,32 +23818,16 @@ THREE.UniformsLib = { "distance": { type: "f" }, "angleCos": { type: "f" }, "exponent": { type: "f" }, - "decay": { type: "f" }, - - "shadowEnabled": { type: "i" }, - "shadowBias": { type: "f" }, - "shadowRadius": { type: "f" }, - "shadowMapSize": { type: "v2" }, - "shadowMatrix": { type: "m4" } + "decay": { type: "f" } } }, - "spotLightsShadowMap": { type: "tv", value: [] }, - "pointLights": { type: "sa", value: [], properties: { "color": { type: "c" }, "position": { type: "v3" }, "decay": { type: "f" }, - "distance": { type: "f" }, - - "shadowEnabled": { type: "i" }, - "shadowBias": { type: "f" }, - "shadowRadius": { type: "f" }, - "shadowMapSize": { type: "v2" }, - "shadowMatrix": { type: "m4" } + "distance": { type: "f" } } }, - "pointLightsShadowMap": { type: "tv", value: [] }, - "hemisphereLights": { type: "sa", value: [], properties: { "direction": { type: "v3" }, "skyColor": { type: "c" }, @@ -23869,6 +23845,31 @@ THREE.UniformsLib = { "map": { type: "t", value: null }, "offsetRepeat": { type: "v4", value: new THREE.Vector4( 0, 0, 1, 1 ) } + }, + + shadowmap: { + + "directionalShadow": { type: "1iv", value: [] }, + "directionalShadowMap": { type: "tv", value: [] }, + "directionalShadowMapSize": { type: "v2v", value: [] }, + "directionalShadowBias": { type: "1fv", value: [] }, + "directionalShadowRadius": { type: "1fv", value: [] }, + "directionalShadowMatrix": { type: "m4v", value: [] }, + + "spotShadow": { type: "1iv", value: [] }, + "spotShadowMap": { type: "tv", value: [] }, + "spotShadowMapSize": { type: "v2v", value: [] }, + "spotShadowBias": { type: "1fv", value: [] }, + "spotShadowRadius": { type: "1fv", value: [] }, + "spotShadowMatrix": { type: "m4v", value: [] }, + + "pointShadow": { type: "1iv", value: [] }, + "pointShadowMap": { type: "tv", value: [] }, + "pointShadowMapSize": { type: "v2v", value: [] }, + "pointShadowBias": { type: "1fv", value: [] }, + "pointShadowRadius": { type: "1fv", value: [] }, + "pointShadowMatrix": { type: "m4v", value: [] } + } }; @@ -24161,6 +24162,7 @@ THREE.ShaderLib = { THREE.UniformsLib[ "fog" ], THREE.UniformsLib[ "ambient" ], THREE.UniformsLib[ "lights" ], + THREE.UniformsLib[ "shadowmap" ], { "emissive" : { type: "c", value: new THREE.Color( 0x000000 ) }, @@ -24314,6 +24316,7 @@ THREE.ShaderLib = { THREE.UniformsLib[ "fog" ], THREE.UniformsLib[ "ambient" ], THREE.UniformsLib[ "lights" ], + THREE.UniformsLib[ "shadowmap" ], { "emissive" : { type: "c", value: new THREE.Color( 0x000000 ) }, @@ -25104,13 +25107,35 @@ THREE.WebGLRenderer = function ( parameters ) { ambient: [ 0, 0, 0 ], directional: [], - directionalShadow: [], spot: [], - spotShadow: [], point: [], - pointShadow: [], hemi: [], + directionalShadow: { + enabled: [], + map: [], + mapSize: [], + bias: [], + radius: [], + matrix: [] + }, + spotShadow: { + enabled: [], + map: [], + mapSize: [], + bias: [], + radius: [], + matrix: [] + }, + pointShadow: { + enabled: [], + map: [], + mapSize: [], + bias: [], + radius: [], + matrix: [] + }, + shadows: [], shadowsPointLight: 0 @@ -26508,13 +26533,35 @@ THREE.WebGLRenderer = function ( parameters ) { uniforms.ambientLightColor.value = _lights.ambient; uniforms.directionalLights.value = _lights.directional; - uniforms.directionalLightsShadowMap.value = _lights.directionalShadow; uniforms.spotLights.value = _lights.spot; - uniforms.spotLightsShadowMap.value = _lights.spotShadow; uniforms.pointLights.value = _lights.point; - uniforms.pointLightsShadowMap.value = _lights.pointShadow; uniforms.hemisphereLights.value = _lights.hemi; + if ( shadowMap.enabled === true ) { + + uniforms.directionalShadow.value = _lights.directionalShadow.enabled; + uniforms.directionalShadowMap.value = _lights.directionalShadow.map; + uniforms.directionalShadowMapSize.value = _lights.directionalShadow.mapSize; + uniforms.directionalShadowBias.value = _lights.directionalShadow.bias; + uniforms.directionalShadowRadius.value = _lights.directionalShadow.radius; + uniforms.directionalShadowMatrix.value = _lights.directionalShadow.matrix; + + uniforms.spotShadow.value = _lights.spotShadow.enabled; + uniforms.spotShadowMap.value = _lights.spotShadow.map; + uniforms.spotShadowMapSize.value = _lights.spotShadow.mapSize; + uniforms.spotShadowBias.value = _lights.spotShadow.bias; + uniforms.spotShadowRadius.value = _lights.spotShadow.radius; + uniforms.spotShadowMatrix.value = _lights.spotShadow.matrix; + + uniforms.pointShadow.value = _lights.pointShadow.enabled; + uniforms.pointShadowMap.value = _lights.pointShadow.map; + uniforms.pointShadowMapSize.value = _lights.pointShadow.mapSize; + uniforms.pointShadowBias.value = _lights.pointShadow.bias; + uniforms.pointShadowRadius.value = _lights.pointShadow.radius; + uniforms.pointShadowMatrix.value = _lights.pointShadow.matrix; + + } + } // detect dynamic uniforms @@ -27648,20 +27695,20 @@ THREE.WebGLRenderer = function ( parameters ) { uniforms.direction.transformDirection( viewMatrix ); uniforms.color.copy( light.color ).multiplyScalar( light.intensity ); - uniforms.shadowEnabled = light.castShadow; + _lights.directionalShadow.enabled[ directionalLength ] = light.castShadow; if ( light.castShadow ) { - uniforms.shadowBias = light.shadow.bias; - uniforms.shadowRadius = light.shadow.radius; - uniforms.shadowMapSize = light.shadow.mapSize; - uniforms.shadowMatrix = light.shadow.matrix; + _lights.directionalShadow.map[ directionalLength ] = light.shadow.map; + _lights.directionalShadow.mapSize[ directionalLength ] = light.shadow.mapSize; + _lights.directionalShadow.bias[ directionalLength ] = light.shadow.bias; + _lights.directionalShadow.radius[ directionalLength ] = light.shadow.radius; + _lights.directionalShadow.matrix[ directionalLength ] = light.shadow.matrix; _lights.shadows[ shadowsLength ++ ] = light; } - _lights.directionalShadow[ directionalLength ] = light.shadow.map; _lights.directional[ directionalLength ++ ] = uniforms; } else if ( light instanceof THREE.SpotLight ) { @@ -27683,20 +27730,20 @@ THREE.WebGLRenderer = function ( parameters ) { uniforms.exponent = light.exponent; uniforms.decay = ( light.distance === 0 ) ? 0.0 : light.decay; - uniforms.shadowEnabled = light.castShadow; + _lights.spotShadow.enabled[ spotLength ] = light.castShadow; if ( light.castShadow ) { - uniforms.shadowBias = light.shadow.bias; - uniforms.shadowRadius = light.shadow.radius; - uniforms.shadowMapSize = light.shadow.mapSize; - uniforms.shadowMatrix = light.shadow.matrix; + _lights.spotShadow.map[ spotLength ] = light.shadow.map; + _lights.spotShadow.mapSize[ spotLength ] = light.shadow.mapSize; + _lights.spotShadow.bias[ spotLength ] = light.shadow.bias; + _lights.spotShadow.radius[ spotLength ] = light.shadow.radius; + _lights.spotShadow.matrix[ spotLength ] = light.shadow.matrix; _lights.shadows[ shadowsLength ++ ] = light; } - _lights.spotShadow[ spotLength ] = light.shadow.map; _lights.spot[ spotLength ++ ] = uniforms; } else if ( light instanceof THREE.PointLight ) { @@ -27710,24 +27757,26 @@ THREE.WebGLRenderer = function ( parameters ) { uniforms.distance = light.distance; uniforms.decay = ( light.distance === 0 ) ? 0.0 : light.decay; - uniforms.shadowEnabled = light.castShadow; + _lights.pointShadow.enabled[ pointLength ] = light.castShadow; if ( light.castShadow ) { - uniforms.shadowBias = light.shadow.bias; - uniforms.shadowRadius = light.shadow.radius; - uniforms.shadowMapSize = light.shadow.mapSize; + _lights.pointShadow.map[ pointLength ] = light.shadow.map; + _lights.pointShadow.mapSize[ pointLength ] = light.shadow.mapSize; + _lights.pointShadow.bias[ pointLength ] = light.shadow.bias; + _lights.pointShadow.radius[ pointLength ] = light.shadow.radius; // for point lights we set the shadow matrix to be a translation-only matrix // equal to inverse of the light's position _vector3.setFromMatrixPosition( light.matrixWorld ).negate(); - uniforms.shadowMatrix.identity().setPosition( _vector3 ); + // light.shadow.matrix.identity().setPosition( _vector3 ); + + _lights.pointShadow.matrix[ pointLength ] = new THREE.Matrix4().setPosition( _vector3 ); // light.shadow.matrix; _lights.shadows[ shadowsLength ++ ] = light; } - _lights.pointShadow[ pointLength ] = light.shadow.map; _lights.point[ pointLength ++ ] = uniforms; } else if ( light instanceof THREE.HemisphereLight ) { @@ -27752,12 +27801,33 @@ THREE.WebGLRenderer = function ( parameters ) { _lights.ambient[ 2 ] = b; _lights.directional.length = directionalLength; - _lights.point.length = pointLength; _lights.spot.length = spotLength; + _lights.point.length = pointLength; _lights.hemi.length = hemiLength; _lights.shadows.length = shadowsLength; + _lights.directionalShadow.enabled.length = directionalLength; + _lights.directionalShadow.map.length = directionalLength; + _lights.directionalShadow.mapSize.length = directionalLength; + _lights.directionalShadow.bias.length = directionalLength; + _lights.directionalShadow.radius.length = directionalLength; + _lights.directionalShadow.matrix.length = directionalLength; + + _lights.spotShadow.enabled.length = spotLength; + _lights.spotShadow.map.length = spotLength; + _lights.spotShadow.mapSize.length = spotLength; + _lights.spotShadow.bias.length = spotLength; + _lights.spotShadow.radius.length = spotLength; + _lights.spotShadow.matrix.length = spotLength; + + _lights.pointShadow.enabled.length = pointLength; + _lights.pointShadow.map.length = pointLength; + _lights.pointShadow.mapSize.length = pointLength; + _lights.pointShadow.bias.length = pointLength; + _lights.pointShadow.radius.length = pointLength; + _lights.pointShadow.matrix.length = pointLength; + _lights.hash = directionalLength + ',' + pointLength + ',' + spotLength + ',' + hemiLength + ',' + shadowsLength; } diff --git a/build/three.min.js b/build/three.min.js index 6e9b29fa1be36e6bf5c59615dd5dd28bb18e6328..1112456ff7c707c59d365bf181a7809f66d1706a 100644 --- a/build/three.min.js +++ b/build/three.min.js @@ -104,8 +104,8 @@ c[0]=b[0]*d;c[1]=b[1]*d;c[2]=b[2]*d;c[4]=b[4]*e;c[5]=b[5]*e;c[6]=b[6]*e;c[8]=b[8 d;b[1]=k+m*d;b[5]=a-n*d;b[9]=-c*g;b[2]=n-a*d;b[6]=m+k*d;b[10]=f*g}else"YXZ"===a.order?(a=g*h,k=g*e,m=d*h,n=d*e,b[0]=a+n*c,b[4]=m*c-k,b[8]=f*d,b[1]=f*e,b[5]=f*h,b[9]=-c,b[2]=k*c-m,b[6]=n+a*c,b[10]=f*g):"ZXY"===a.order?(a=g*h,k=g*e,m=d*h,n=d*e,b[0]=a-n*c,b[4]=-f*e,b[8]=m+k*c,b[1]=k+m*c,b[5]=f*h,b[9]=n-a*c,b[2]=-f*d,b[6]=c,b[10]=f*g):"ZYX"===a.order?(a=f*h,k=f*e,m=c*h,n=c*e,b[0]=g*h,b[4]=m*d-k,b[8]=a*d+n,b[1]=g*e,b[5]=n*d+a,b[9]=k*d-m,b[2]=-d,b[6]=c*g,b[10]=f*g):"YZX"===a.order?(a=f*g,k=f*d,m=c*g,n= c*d,b[0]=g*h,b[4]=n-a*e,b[8]=m*e+k,b[1]=e,b[5]=f*h,b[9]=-c*h,b[2]=-d*h,b[6]=k*e+m,b[10]=a-n*e):"XZY"===a.order&&(a=f*g,k=f*d,m=c*g,n=c*d,b[0]=g*h,b[4]=-e,b[8]=d*h,b[1]=a*e+n,b[5]=f*h,b[9]=k*e-m,b[2]=m*e-k,b[6]=c*h,b[10]=n*e+a);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},makeRotationFromQuaternion:function(a){var b=this.elements,c=a.x,d=a.y,e=a.z,f=a.w,g=c+c,h=d+d,k=e+e;a=c*g;var m=c*h,c=c*k,n=d*h,d=d*k,e=e*k,g=f*g,h=f*h,f=f*k;b[0]=1-(n+e);b[4]=m-f;b[8]=c+h;b[1]=m+f;b[5]=1-(a+ e);b[9]=d-g;b[2]=c-h;b[6]=d+g;b[10]=1-(a+n);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},lookAt:function(){var a,b,c;return function(d,e,f){void 0===a&&(a=new THREE.Vector3);void 0===b&&(b=new THREE.Vector3);void 0===c&&(c=new THREE.Vector3);var g=this.elements;c.subVectors(d,e).normalize();0===c.lengthSq()&&(c.z=1);a.crossVectors(f,c).normalize();0===a.lengthSq()&&(c.x+=1E-4,a.crossVectors(f,c).normalize());b.crossVectors(c,a);g[0]=a.x;g[4]=b.x;g[8]=c.x;g[1]=a.y;g[5]=b.y;g[9]= -c.y;g[2]=a.z;g[6]=b.z;g[10]=c.z;return this}}(),multiply:function(a,b){return void 0!==b?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(a,b)):this.multiplyMatrices(this,a)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements,e=this.elements,f=c[0],g=c[4],h=c[8],k=c[12],m=c[1],n=c[5],p=c[9],l=c[13],q=c[2],t=c[6],u=c[10],s=c[14],w=c[3],v=c[7],C=c[11],c=c[15],x=d[0],D=d[4],A=d[8],B=d[12],y=d[1],I=d[5],F= -d[9],z=d[13],J=d[2],P=d[6],N=d[10],K=d[14],G=d[3],L=d[7],Q=d[11],d=d[15];e[0]=f*x+g*y+h*J+k*G;e[4]=f*D+g*I+h*P+k*L;e[8]=f*A+g*F+h*N+k*Q;e[12]=f*B+g*z+h*K+k*d;e[1]=m*x+n*y+p*J+l*G;e[5]=m*D+n*I+p*P+l*L;e[9]=m*A+n*F+p*N+l*Q;e[13]=m*B+n*z+p*K+l*d;e[2]=q*x+t*y+u*J+s*G;e[6]=q*D+t*I+u*P+s*L;e[10]=q*A+t*F+u*N+s*Q;e[14]=q*B+t*z+u*K+s*d;e[3]=w*x+v*y+C*J+c*G;e[7]=w*D+v*I+C*P+c*L;e[11]=w*A+v*F+C*N+c*Q;e[15]=w*B+v*z+C*K+c*d;return this},multiplyToArray:function(a,b,c){var d=this.elements;this.multiplyMatrices(a, +c.y;g[2]=a.z;g[6]=b.z;g[10]=c.z;return this}}(),multiply:function(a,b){return void 0!==b?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(a,b)):this.multiplyMatrices(this,a)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements,e=this.elements,f=c[0],g=c[4],h=c[8],k=c[12],m=c[1],n=c[5],p=c[9],l=c[13],q=c[2],t=c[6],u=c[10],s=c[14],w=c[3],v=c[7],B=c[11],c=c[15],x=d[0],D=d[4],y=d[8],z=d[12],A=d[1],J=d[5],F= +d[9],C=d[13],K=d[2],Q=d[6],O=d[10],L=d[14],H=d[3],M=d[7],R=d[11],d=d[15];e[0]=f*x+g*A+h*K+k*H;e[4]=f*D+g*J+h*Q+k*M;e[8]=f*y+g*F+h*O+k*R;e[12]=f*z+g*C+h*L+k*d;e[1]=m*x+n*A+p*K+l*H;e[5]=m*D+n*J+p*Q+l*M;e[9]=m*y+n*F+p*O+l*R;e[13]=m*z+n*C+p*L+l*d;e[2]=q*x+t*A+u*K+s*H;e[6]=q*D+t*J+u*Q+s*M;e[10]=q*y+t*F+u*O+s*R;e[14]=q*z+t*C+u*L+s*d;e[3]=w*x+v*A+B*K+c*H;e[7]=w*D+v*J+B*Q+c*M;e[11]=w*y+v*F+B*O+c*R;e[15]=w*z+v*C+B*L+c*d;return this},multiplyToArray:function(a,b,c){var d=this.elements;this.multiplyMatrices(a, b);c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]=d[4];c[5]=d[5];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[11]=d[11];c[12]=d[12];c[13]=d[13];c[14]=d[14];c[15]=d[15];return this},multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[4]*=a;b[8]*=a;b[12]*=a;b[1]*=a;b[5]*=a;b[9]*=a;b[13]*=a;b[2]*=a;b[6]*=a;b[10]*=a;b[14]*=a;b[3]*=a;b[7]*=a;b[11]*=a;b[15]*=a;return this},applyToVector3Array:function(){var a;return function(b,c,d){void 0===a&&(a=new THREE.Vector3);void 0===c&&(c=0);void 0=== d&&(d=b.length);for(var e=0;eg;g++)l=v[k++],w=s[2*l],l=s[2*l+1],w=new THREE.Vector2(w,l),2!==g&&c.faceVertexUvs[d][h].push(w),0!==g&&c.faceVertexUvs[d][h+1].push(w);p&&(p=3*v[k++],q.normal.set(C[p++],C[p++],C[p]),u.normal.copy(q.normal));if(t)for(d=0;4>d;d++)p=3*v[k++],t=new THREE.Vector3(C[p++],C[p++],C[p]),2!==d&&q.vertexNormals.push(t),0!==d&&u.vertexNormals.push(t); -n&&(n=v[k++],n=x[n],q.color.setHex(n),u.color.setHex(n));if(b)for(d=0;4>d;d++)n=v[k++],n=x[n],2!==d&&q.vertexColors.push(new THREE.Color(n)),0!==d&&u.vertexColors.push(new THREE.Color(n));c.faces.push(q);c.faces.push(u)}else{q=new THREE.Face3;q.a=v[k++];q.b=v[k++];q.c=v[k++];h&&(h=v[k++],q.materialIndex=h);h=c.faces.length;if(d)for(d=0;dg;g++)l=v[k++],w=s[2*l],l=s[2*l+1],w=new THREE.Vector2(w,l),c.faceVertexUvs[d][h].push(w);p&&(p=3*v[k++],q.normal.set(C[p++], -C[p++],C[p]));if(t)for(d=0;3>d;d++)p=3*v[k++],t=new THREE.Vector3(C[p++],C[p++],C[p]),q.vertexNormals.push(t);n&&(n=v[k++],q.color.setHex(x[n]));if(b)for(d=0;3>d;d++)n=v[k++],q.vertexColors.push(new THREE.Color(x[n]));c.faces.push(q)}})(d);(function(){var b=void 0!==a.influencesPerVertex?a.influencesPerVertex:2;if(a.skinWeights)for(var d=0,g=a.skinWeights.length;dg;g++)l=v[k++],w=s[2*l],l=s[2*l+1],w=new THREE.Vector2(w,l),2!==g&&c.faceVertexUvs[d][h].push(w),0!==g&&c.faceVertexUvs[d][h+1].push(w);p&&(p=3*v[k++],q.normal.set(B[p++],B[p++],B[p]),u.normal.copy(q.normal));if(t)for(d=0;4>d;d++)p=3*v[k++],t=new THREE.Vector3(B[p++],B[p++],B[p]),2!==d&&q.vertexNormals.push(t),0!==d&&u.vertexNormals.push(t); +n&&(n=v[k++],n=x[n],q.color.setHex(n),u.color.setHex(n));if(b)for(d=0;4>d;d++)n=v[k++],n=x[n],2!==d&&q.vertexColors.push(new THREE.Color(n)),0!==d&&u.vertexColors.push(new THREE.Color(n));c.faces.push(q);c.faces.push(u)}else{q=new THREE.Face3;q.a=v[k++];q.b=v[k++];q.c=v[k++];h&&(h=v[k++],q.materialIndex=h);h=c.faces.length;if(d)for(d=0;dg;g++)l=v[k++],w=s[2*l],l=s[2*l+1],w=new THREE.Vector2(w,l),c.faceVertexUvs[d][h].push(w);p&&(p=3*v[k++],q.normal.set(B[p++], +B[p++],B[p]));if(t)for(d=0;3>d;d++)p=3*v[k++],t=new THREE.Vector3(B[p++],B[p++],B[p]),q.vertexNormals.push(t);n&&(n=v[k++],q.color.setHex(x[n]));if(b)for(d=0;3>d;d++)n=v[k++],q.vertexColors.push(new THREE.Color(x[n]));c.faces.push(q)}})(d);(function(){var b=void 0!==a.influencesPerVertex?a.influencesPerVertex:2;if(a.skinWeights)for(var d=0,g=a.skinWeights.length;db.far?null:{distance:c,point:w.clone(), object:a}}function c(c,d,e,f,m,n,p,w){g.fromArray(f,3*n);h.fromArray(f,3*p);k.fromArray(f,3*w);if(c=b(c,d,e,g,h,k,s))m&&(l.fromArray(m,2*n),q.fromArray(m,2*p),t.fromArray(m,2*w),c.uv=a(s,g,h,k,l,q,t)),c.face=new THREE.Face3(n,p,w,THREE.Triangle.normal(g,h,k)),c.faceIndex=n;return c}var d=new THREE.Matrix4,e=new THREE.Ray,f=new THREE.Sphere,g=new THREE.Vector3,h=new THREE.Vector3,k=new THREE.Vector3,m=new THREE.Vector3,n=new THREE.Vector3,p=new THREE.Vector3,l=new THREE.Vector2,q=new THREE.Vector2, -t=new THREE.Vector2,u=new THREE.Vector3,s=new THREE.Vector3,w=new THREE.Vector3;return function(w,u){var x=this.geometry,D=this.material,A=this.matrixWorld;if(void 0!==D&&(null===x.boundingSphere&&x.computeBoundingSphere(),f.copy(x.boundingSphere),f.applyMatrix4(A),!1!==w.ray.intersectsSphere(f)&&(d.getInverse(A),e.copy(w.ray).applyMatrix4(d),null===x.boundingBox||!1!==e.intersectsBox(x.boundingBox)))){var B,y;if(x instanceof THREE.BufferGeometry){var I,F,D=x.index,A=x.attributes,x=A.position.array; -void 0!==A.uv&&(B=A.uv.array);if(null!==D)for(var A=D.array,z=0,J=A.length;zc;c++)r.deleteFramebuffer(b.__webglFramebuffer[c]),r.deleteRenderbuffer(b.__webglDepthbuffer[c]);else r.deleteFramebuffer(b.__webglFramebuffer),r.deleteRenderbuffer(b.__webglDepthbuffer);T.delete(a.texture); T.delete(a)}ha.textures--}function h(a){a=a.target;a.removeEventListener("dispose",h);k(a);T.delete(a)}function k(a){var b=T.get(a).program;a.program=void 0;void 0!==b&&na.releaseProgram(b)}function m(a,b){return Math.abs(b[0])-Math.abs(a[0])}function n(a,b){return a.object.renderOrder!==b.object.renderOrder?a.object.renderOrder-b.object.renderOrder:a.material.id!==b.material.id?a.material.id-b.material.id:a.z!==b.z?a.z-b.z:a.id-b.id}function p(a,b){return a.object.renderOrder!==b.object.renderOrder? -a.object.renderOrder-b.object.renderOrder:a.z!==b.z?b.z-a.z:a.id-b.id}function l(a,b,c,d,e){var f;c.transparent?(d=V,f=++W):(d=M,f=++E);f=d[f];void 0!==f?(f.id=a.id,f.object=a,f.geometry=b,f.material=c,f.z=X.z,f.group=e):(f={id:a.id,object:a,geometry:b,material:c,z:X.z,group:e},d.push(f))}function q(a,b){if(!1!==a.visible){if(a.layers.test(b.layers))if(a instanceof THREE.Light)R.push(a);else if(a instanceof THREE.Sprite)!1!==a.frustumCulled&&!0!==ya.intersectsObject(a)||ia.push(a);else if(a instanceof +a.object.renderOrder-b.object.renderOrder:a.z!==b.z?b.z-a.z:a.id-b.id}function l(a,b,c,d,e){var f;c.transparent?(d=V,f=++W):(d=N,f=++E);f=d[f];void 0!==f?(f.id=a.id,f.object=a,f.geometry=b,f.material=c,f.z=X.z,f.group=e):(f={id:a.id,object:a,geometry:b,material:c,z:X.z,group:e},d.push(f))}function q(a,b){if(!1!==a.visible){if(a.layers.test(b.layers))if(a instanceof THREE.Light)S.push(a);else if(a instanceof THREE.Sprite)!1!==a.frustumCulled&&!0!==ya.intersectsObject(a)||ia.push(a);else if(a instanceof THREE.LensFlare)da.push(a);else if(a instanceof THREE.ImmediateRenderObject)!0===Y.sortObjects&&(X.setFromMatrixPosition(a.matrixWorld),X.applyProjection(ra)),l(a,null,a.material,X.z,null);else if(a instanceof THREE.Mesh||a instanceof THREE.Line||a instanceof THREE.Points)if(a instanceof THREE.SkinnedMesh&&a.skeleton.update(),!1===a.frustumCulled||!0===ya.intersectsObject(a)){var c=a.material;if(!0===c.visible){!0===Y.sortObjects&&(X.setFromMatrixPosition(a.matrixWorld),X.applyProjection(ra));var d= oa.update(a);if(c instanceof THREE.MultiMaterial)for(var e=d.groups,f=c.materials,c=0,g=e.length;c=ca.maxTextures&&console.warn("WebGLRenderer: trying to use "+a+" texture units while this GPU supports only "+ca.maxTextures);sa+=1;return a}function v(a){for(var b,c,d=0,e=a.length;db||a.height>b){var c=b/Math.max(a.width,a.height),d=document.createElement("canvas");d.width=Math.floor(a.width* -c);d.height=Math.floor(a.height*c);d.getContext("2d").drawImage(a,0,0,a.width,a.height,0,0,d.width,d.height);console.warn("THREE.WebGLRenderer: image is too big ("+a.width+"x"+a.height+"). Resized to "+d.width+"x"+d.height,a);return d}return a}function D(a){return THREE.Math.isPowerOfTwo(a.width)&&THREE.Math.isPowerOfTwo(a.height)}function A(a,b){var c=T.get(a);if(6===a.image.length)if(0h;h++)g[h]=!Y.autoScaleCubemaps||d||e?e?a.image[h].image:a.image[h]:x(a.image[h],ca.maxCubemapSize);var k=D(g[0]),l=z(a.format),m=z(a.type);C(r.TEXTURE_CUBE_MAP,a,k);for(h=0;6>h;h++)if(d)for(var n,q=g[h].mipmaps,p=0,t=q.length;pf;f++)b.__webglFramebuffer[f]=r.createFramebuffer()}else b.__webglFramebuffer=r.createFramebuffer();if(d){H.bindTexture(r.TEXTURE_CUBE_MAP,c.__webglTexture);C(r.TEXTURE_CUBE_MAP,a.texture,e);for(f=0;6>f;f++)y(b.__webglFramebuffer[f],a,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+f); -a.texture.generateMipmaps&&e&&r.generateMipmap(r.TEXTURE_CUBE_MAP);H.bindTexture(r.TEXTURE_CUBE_MAP,null)}else H.bindTexture(r.TEXTURE_2D,c.__webglTexture),C(r.TEXTURE_2D,a.texture,e),y(b.__webglFramebuffer,a,r.COLOR_ATTACHMENT0,r.TEXTURE_2D),a.texture.generateMipmaps&&e&&r.generateMipmap(r.TEXTURE_2D),H.bindTexture(r.TEXTURE_2D,null);if(a.depthBuffer){b=T.get(a);if(a instanceof THREE.WebGLRenderTargetCube)for(b.__webglDepthbuffer=[],c=0;6>c;c++)r.bindFramebuffer(r.FRAMEBUFFER,b.__webglFramebuffer[c]), -b.__webglDepthbuffer[c]=r.createRenderbuffer(),I(b.__webglDepthbuffer[c],a);else r.bindFramebuffer(r.FRAMEBUFFER,b.__webglFramebuffer),b.__webglDepthbuffer=r.createRenderbuffer(),I(b.__webglDepthbuffer,a);r.bindFramebuffer(r.FRAMEBUFFER,null)}}b=a instanceof THREE.WebGLRenderTargetCube;a?(c=T.get(a),c=b?c.__webglFramebuffer[a.activeCubeFace]:c.__webglFramebuffer,pa.copy(a.scissor),za=a.scissorTest,ja.copy(a.viewport)):(c=null,pa.copy(xa).multiplyScalar($),za=Aa,ja.copy(ka).multiplyScalar($));ta!== -c&&(r.bindFramebuffer(r.FRAMEBUFFER,c),ta=c);H.scissor(pa);H.setScissorTest(za);H.viewport(ja);b&&(b=T.get(a.texture),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+a.activeCubeFace,b.__webglTexture,0))};this.readRenderTargetPixels=function(a,b,c,d,e,g){if(!1===a instanceof THREE.WebGLRenderTarget)console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");else{var f=T.get(a).__webglFramebuffer;if(f){var h=!1;f!== -ta&&(r.bindFramebuffer(r.FRAMEBUFFER,f),h=!0);try{var k=a.texture;k.format!==THREE.RGBAFormat&&z(k.format)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT)?console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."):k.type===THREE.UnsignedByteType||z(k.type)===r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)||k.type===THREE.FloatType&&U.get("WEBGL_color_buffer_float")||k.type===THREE.HalfFloatType&&U.get("EXT_color_buffer_half_float")? -r.checkFramebufferStatus(r.FRAMEBUFFER)===r.FRAMEBUFFER_COMPLETE?r.readPixels(b,c,d,e,z(k.format),z(k.type),g):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."):console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.")}finally{h&&r.bindFramebuffer(r.FRAMEBUFFER,ta)}}}}}; +c.numSupportedMorphNormals=0;l=ca.maxTextures&&console.warn("WebGLRenderer: trying to use "+a+" texture units while this GPU supports only "+ca.maxTextures);sa+=1;return a}function v(a){for(var b,c,d=0,e=a.length;db||a.height>b){var c=b/Math.max(a.width,a.height),d=document.createElement("canvas");d.width=Math.floor(a.width*c);d.height=Math.floor(a.height*c);d.getContext("2d").drawImage(a,0,0,a.width,a.height,0,0,d.width,d.height);console.warn("THREE.WebGLRenderer: image is too big ("+a.width+"x"+a.height+ +"). Resized to "+d.width+"x"+d.height,a);return d}return a}function D(a){return THREE.Math.isPowerOfTwo(a.width)&&THREE.Math.isPowerOfTwo(a.height)}function y(a,b){var c=T.get(a);if(6===a.image.length)if(0h;h++)g[h]=!Y.autoScaleCubemaps||d||e?e?a.image[h].image:a.image[h]:x(a.image[h],ca.maxCubemapSize);var k=D(g[0]),l=C(a.format),m=C(a.type);B(r.TEXTURE_CUBE_MAP,a,k);for(h=0;6>h;h++)if(d)for(var n,q=g[h].mipmaps,p=0,t=q.length;pf;f++)b.__webglFramebuffer[f]=r.createFramebuffer()}else b.__webglFramebuffer=r.createFramebuffer();if(d){I.bindTexture(r.TEXTURE_CUBE_MAP,c.__webglTexture);B(r.TEXTURE_CUBE_MAP,a.texture,e);for(f=0;6>f;f++)A(b.__webglFramebuffer[f],a,r.COLOR_ATTACHMENT0, +r.TEXTURE_CUBE_MAP_POSITIVE_X+f);a.texture.generateMipmaps&&e&&r.generateMipmap(r.TEXTURE_CUBE_MAP);I.bindTexture(r.TEXTURE_CUBE_MAP,null)}else I.bindTexture(r.TEXTURE_2D,c.__webglTexture),B(r.TEXTURE_2D,a.texture,e),A(b.__webglFramebuffer,a,r.COLOR_ATTACHMENT0,r.TEXTURE_2D),a.texture.generateMipmaps&&e&&r.generateMipmap(r.TEXTURE_2D),I.bindTexture(r.TEXTURE_2D,null);if(a.depthBuffer){b=T.get(a);if(a instanceof THREE.WebGLRenderTargetCube)for(b.__webglDepthbuffer=[],c=0;6>c;c++)r.bindFramebuffer(r.FRAMEBUFFER, +b.__webglFramebuffer[c]),b.__webglDepthbuffer[c]=r.createRenderbuffer(),J(b.__webglDepthbuffer[c],a);else r.bindFramebuffer(r.FRAMEBUFFER,b.__webglFramebuffer),b.__webglDepthbuffer=r.createRenderbuffer(),J(b.__webglDepthbuffer,a);r.bindFramebuffer(r.FRAMEBUFFER,null)}}b=a instanceof THREE.WebGLRenderTargetCube;a?(c=T.get(a),c=b?c.__webglFramebuffer[a.activeCubeFace]:c.__webglFramebuffer,pa.copy(a.scissor),Aa=a.scissorTest,ja.copy(a.viewport)):(c=null,pa.copy(xa).multiplyScalar($),Aa=Ba,ja.copy(ka).multiplyScalar($)); +ta!==c&&(r.bindFramebuffer(r.FRAMEBUFFER,c),ta=c);I.scissor(pa);I.setScissorTest(Aa);I.viewport(ja);b&&(b=T.get(a.texture),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+a.activeCubeFace,b.__webglTexture,0))};this.readRenderTargetPixels=function(a,b,c,d,e,g){if(!1===a instanceof THREE.WebGLRenderTarget)console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");else{var f=T.get(a).__webglFramebuffer;if(f){var h= +!1;f!==ta&&(r.bindFramebuffer(r.FRAMEBUFFER,f),h=!0);try{var k=a.texture;k.format!==THREE.RGBAFormat&&C(k.format)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT)?console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."):k.type===THREE.UnsignedByteType||C(k.type)===r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)||k.type===THREE.FloatType&&U.get("WEBGL_color_buffer_float")||k.type===THREE.HalfFloatType&&U.get("EXT_color_buffer_half_float")? +r.checkFramebufferStatus(r.FRAMEBUFFER)===r.FRAMEBUFFER_COMPLETE?r.readPixels(b,c,d,e,C(k.format),C(k.type),g):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."):console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.")}finally{h&&r.bindFramebuffer(r.FRAMEBUFFER,ta)}}}}}; THREE.WebGLRenderTarget=function(a,b,c){this.uuid=THREE.Math.generateUUID();this.width=a;this.height=b;this.scissor=new THREE.Vector4(0,0,a,b);this.scissorTest=!1;this.viewport=new THREE.Vector4(0,0,a,b);c=c||{};void 0===c.minFilter&&(c.minFilter=THREE.LinearFilter);this.texture=new THREE.Texture(void 0,void 0,c.wrapS,c.wrapT,c.magFilter,c.minFilter,c.format,c.type,c.anisotropy);this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0}; THREE.WebGLRenderTarget.prototype={constructor:THREE.WebGLRenderTarget,setSize:function(a,b){if(this.width!==a||this.height!==b)this.width=a,this.height=b,this.dispose();this.viewport.set(0,0,a,b);this.scissor.set(0,0,a,b)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.width=a.width;this.height=a.height;this.viewport.copy(a.viewport);this.texture=a.texture.clone();this.depthBuffer=a.depthBuffer;this.stencilBuffer=a.stencilBuffer;this.shareDepthFrom=a.shareDepthFrom; return this},dispose:function(){this.dispatchEvent({type:"dispose"})}};THREE.EventDispatcher.prototype.apply(THREE.WebGLRenderTarget.prototype);THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,b,c);this.activeCubeFace=0};THREE.WebGLRenderTargetCube.prototype=Object.create(THREE.WebGLRenderTarget.prototype);THREE.WebGLRenderTargetCube.prototype.constructor=THREE.WebGLRenderTargetCube; @@ -692,20 +697,20 @@ function(c){var f=b.get(c);if(void 0!==f.wireframe)return f.wireframe;var k=[],m function(b){var c=f.get(b);b.geometry instanceof THREE.Geometry&&c.updateFromObject(b);b=c.index;var e=c.attributes;null!==b&&d(b,a.ELEMENT_ARRAY_BUFFER);for(var m in e)d(e[m],a.ARRAY_BUFFER);b=c.morphAttributes;for(m in b)for(var e=b[m],n=0,p=e.length;n 0 ) {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = 0.0;\nif ( fogType == 1 ) {\nfogFactor = smoothstep( fogNear, fogFar, depth );\n} else {\nconst float LOG2 = 1.442695;\nfogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n}\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n}"].join("\n")); -x.compileShader(G);x.compileShader(L);x.attachShader(K,G);x.attachShader(K,L);x.linkProgram(K);y=K;w=x.getAttribLocation(y,"position");v=x.getAttribLocation(y,"uv");c=x.getUniformLocation(y,"uvOffset");d=x.getUniformLocation(y,"uvScale");e=x.getUniformLocation(y,"rotation");f=x.getUniformLocation(y,"scale");g=x.getUniformLocation(y,"color");h=x.getUniformLocation(y,"map");k=x.getUniformLocation(y,"opacity");m=x.getUniformLocation(y,"modelViewMatrix");n=x.getUniformLocation(y,"projectionMatrix");p= -x.getUniformLocation(y,"fogType");l=x.getUniformLocation(y,"fogDensity");q=x.getUniformLocation(y,"fogNear");t=x.getUniformLocation(y,"fogFar");u=x.getUniformLocation(y,"fogColor");s=x.getUniformLocation(y,"alphaTest");K=document.createElement("canvas");K.width=8;K.height=8;G=K.getContext("2d");G.fillStyle="white";G.fillRect(0,0,8,8);I=new THREE.Texture(K);I.needsUpdate=!0}x.useProgram(y);D.initAttributes();D.enableAttribute(w);D.enableAttribute(v);D.disableUnusedAttributes();D.disable(x.CULL_FACE); -D.enable(x.BLEND);x.bindBuffer(x.ARRAY_BUFFER,A);x.vertexAttribPointer(w,2,x.FLOAT,!1,16,0);x.vertexAttribPointer(v,2,x.FLOAT,!1,16,8);x.bindBuffer(x.ELEMENT_ARRAY_BUFFER,B);x.uniformMatrix4fv(n,!1,N.projectionMatrix.elements);D.activeTexture(x.TEXTURE0);x.uniform1i(h,0);G=K=0;(L=P.fog)?(x.uniform3f(u,L.color.r,L.color.g,L.color.b),L instanceof THREE.Fog?(x.uniform1f(q,L.near),x.uniform1f(t,L.far),x.uniform1i(p,1),G=K=1):L instanceof THREE.FogExp2&&(x.uniform1f(l,L.density),x.uniform1i(p,2),G=K=2)): -(x.uniform1i(p,0),G=K=0);for(var L=0,Q=b.length;L 0 ) {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = 0.0;\nif ( fogType == 1 ) {\nfogFactor = smoothstep( fogNear, fogFar, depth );\n} else {\nconst float LOG2 = 1.442695;\nfogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n}\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n}"].join("\n")); +x.compileShader(H);x.compileShader(M);x.attachShader(L,H);x.attachShader(L,M);x.linkProgram(L);A=L;w=x.getAttribLocation(A,"position");v=x.getAttribLocation(A,"uv");c=x.getUniformLocation(A,"uvOffset");d=x.getUniformLocation(A,"uvScale");e=x.getUniformLocation(A,"rotation");f=x.getUniformLocation(A,"scale");g=x.getUniformLocation(A,"color");h=x.getUniformLocation(A,"map");k=x.getUniformLocation(A,"opacity");m=x.getUniformLocation(A,"modelViewMatrix");n=x.getUniformLocation(A,"projectionMatrix");p= +x.getUniformLocation(A,"fogType");l=x.getUniformLocation(A,"fogDensity");q=x.getUniformLocation(A,"fogNear");t=x.getUniformLocation(A,"fogFar");u=x.getUniformLocation(A,"fogColor");s=x.getUniformLocation(A,"alphaTest");L=document.createElement("canvas");L.width=8;L.height=8;H=L.getContext("2d");H.fillStyle="white";H.fillRect(0,0,8,8);J=new THREE.Texture(L);J.needsUpdate=!0}x.useProgram(A);D.initAttributes();D.enableAttribute(w);D.enableAttribute(v);D.disableUnusedAttributes();D.disable(x.CULL_FACE); +D.enable(x.BLEND);x.bindBuffer(x.ARRAY_BUFFER,y);x.vertexAttribPointer(w,2,x.FLOAT,!1,16,0);x.vertexAttribPointer(v,2,x.FLOAT,!1,16,8);x.bindBuffer(x.ELEMENT_ARRAY_BUFFER,z);x.uniformMatrix4fv(n,!1,O.projectionMatrix.elements);D.activeTexture(x.TEXTURE0);x.uniform1i(h,0);H=L=0;(M=Q.fog)?(x.uniform3f(u,M.color.r,M.color.g,M.color.b),M instanceof THREE.Fog?(x.uniform1f(q,M.near),x.uniform1f(t,M.far),x.uniform1i(p,1),H=L=1):M instanceof THREE.FogExp2&&(x.uniform1f(l,M.density),x.uniform1i(p,2),H=L=2)): +(x.uniform1i(p,0),H=L=0);for(var M=0,R=b.length;Mc)return null;var d=[],e=[],f=[],g,h,k;if(0=m--){console.warn("THREE.ShapeUtils: Unable to triangulate polygon! in triangulate()");break}g=h;c<=g&&(g=0);h=g+1;c<=h&&(h=0);k=h+1;c<=k&&(k=0);var n;a:{var p= -n=void 0,l=void 0,q=void 0,t=void 0,u=void 0,s=void 0,w=void 0,v=void 0,p=a[e[g]].x,l=a[e[g]].y,q=a[e[h]].x,t=a[e[h]].y,u=a[e[k]].x,s=a[e[k]].y;if(Number.EPSILON>(q-p)*(s-l)-(t-l)*(u-p))n=!1;else{var C=void 0,x=void 0,D=void 0,A=void 0,B=void 0,y=void 0,I=void 0,F=void 0,z=void 0,J=void 0,z=F=I=v=w=void 0,C=u-q,x=s-t,D=p-u,A=l-s,B=q-p,y=t-l;for(n=0;n=-Number.EPSILON&& -F>=-Number.EPSILON&&I>=-Number.EPSILON)){n=!1;break a}n=!0}}if(n){d.push([a[e[g]],a[e[h]],a[e[k]]]);f.push([e[g],e[h],e[k]]);g=h;for(k=h+1;kNumber.EPSILON){if(0y||y> -B)return[];k=m*n-k*p;if(0>k||k>B)return[]}else{if(0d?[]:k===d?f?[]:[g]:a<=d?[g,h]:[g,m]}function e(a,b,c,d){var e=b.x-a.x,f=b.y-a.y;b=c.x-a.x;c=c.y-a.y;var g=d.x-a.x;d=d.y-a.y;a=e*c-f*b;e=e*d-f*g;return Math.abs(a)>Number.EPSILON?(b=g*c-d*b,0(q-p)*(s-l)-(t-l)*(u-p))n=!1;else{var B=void 0,x=void 0,D=void 0,y=void 0,z=void 0,A=void 0,J=void 0,F=void 0,C=void 0,K=void 0,C=F=J=v=w=void 0,B=u-q,x=s-t,D=p-u,y=l-s,z=q-p,A=t-l;for(n=0;n=-Number.EPSILON&& +F>=-Number.EPSILON&&J>=-Number.EPSILON)){n=!1;break a}n=!0}}if(n){d.push([a[e[g]],a[e[h]],a[e[k]]]);f.push([e[g],e[h],e[k]]);g=h;for(k=h+1;kNumber.EPSILON){if(0A||A> +z)return[];k=m*n-k*p;if(0>k||k>z)return[]}else{if(0d?[]:k===d?f?[]:[g]:a<=d?[g,h]:[g,m]}function e(a,b,c,d){var e=b.x-a.x,f=b.y-a.y;b=c.x-a.x;c=c.y-a.y;var g=d.x-a.x;d=d.y-a.y;a=e*c-f*b;e=e*d-f*g;return Math.abs(a)>Number.EPSILON?(b=g*c-d*b,0f&&(f=d);var g=a+1;g>d&&(g=0);d=e(h[a],h[f],h[g],k[b]);if(!d)return!1;d=k.length-1;f=b-1;0>f&&(f=d);g=b+1;g>d&&(g=0);return(d=e(k[b],k[f],k[g],h[a]))?!0:!1}function f(a,b){var c,e;for(c=0;cN){console.log("Infinite Loop! Holes left:"+m.length+", Probably Hole outside Shape!");break}for(p=F;ph;h++)m=k[h].x+":"+k[h].y,m=n[m],void 0!==m&&(k[h]=m);return p.concat()},isClockWise:function(a){return 0>THREE.ShapeUtils.area(a)},b2:function(){return function(a,b,c,d){var e=1-a;return e*e*b+2*(1-a)*a*c+a*a*d}}(),b3:function(){return function(a,b,c,d,e){var f= +h=0;hO){console.log("Infinite Loop! Holes left:"+m.length+", Probably Hole outside Shape!");break}for(p=F;ph;h++)m=k[h].x+":"+k[h].y,m=n[m],void 0!==m&&(k[h]=m);return p.concat()},isClockWise:function(a){return 0>THREE.ShapeUtils.area(a)},b2:function(){return function(a,b,c,d){var e=1-a;return e*e*b+2*(1-a)*a*c+a*a*d}}(),b3:function(){return function(a,b,c,d,e){var f= 1-a,g=1-a;return f*f*f*b+3*g*g*a*c+3*(1-a)*a*a*d+a*a*a*e}}()};THREE.Curve=function(){}; THREE.Curve.prototype={constructor:THREE.Curve,getPoint:function(a){console.warn("THREE.Curve: Warning, getPoint() not implemented!");return null},getPointAt:function(a){a=this.getUtoTmapping(a);return this.getPoint(a)},getPoints:function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPoint(b/a));return c},getSpacedPoints:function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPointAt(b/a));return c},getLength:function(){var a=this.getLengths();return a[a.length-1]},getLengths:function(a){a|| (a=this.__arcLengthDivisions?this.__arcLengthDivisions:200);if(this.cacheArcLengths&&this.cacheArcLengths.length===a+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var b=[],c,d=this.getPoint(0),e,f=0;b.push(0);for(e=1;e<=a;e++)c=this.getPoint(e/a),f+=c.distanceTo(d),b.push(f),d=c;return this.cacheArcLengths=b},updateArcLengths:function(){this.needsUpdate=!0;this.getLengths()},getUtoTmapping:function(a,b){var c=this.getLengths(),d=0,e=c.length,f;f=b?b:a*c[e-1];for(var g=0,h=e- @@ -808,8 +813,8 @@ THREE.Curve.create=function(a,b){a.prototype=Object.create(THREE.Curve.prototype THREE.CurvePath.prototype.closePath=function(){var a=this.curves[0].getPoint(0),b=this.curves[this.curves.length-1].getPoint(1);a.equals(b)||this.curves.push(new THREE.LineCurve(b,a))};THREE.CurvePath.prototype.getPoint=function(a){for(var b=a*this.getLength(),c=this.getCurveLengths(),d=0;d=b)return a=this.curves[d],b=1-(c[d]-b)/a.getLength(),a.getPointAt(b);d++}return null};THREE.CurvePath.prototype.getLength=function(){var a=this.getCurveLengths();return a[a.length-1]}; THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var a=[],b=0,c=0,d=this.curves.length;cNumber.EPSILON){if(0>l&&(g=b[f],k=-k,h=b[e],l=-l),!(a.yh.y))if(a.y===g.y){if(a.x===g.x)return!0}else{e=l*(a.x-g.x)-k*(a.y-g.y);if(0===e)return!0;0>e||(d=!d)}}else if(a.y===g.y&&(h.x<=a.x&&a.x<=g.x|| g.x<=a.x&&a.x<=h.x))return!0}return d}var e=THREE.ShapeUtils.isClockWise,f=function(a){for(var b=[],c=new THREE.Path,d=0,e=a.length;dk&&console.log("duh, you need at least 2 points");a*=k-(this.closed?0:1);h=Math.floor(a);a-=h;this.closed?h+=0h&&(h=1);1E-4>k&&(k=h);1E-4>l&&(l=h);c.initNonuniformCatmullRom(m.x,n.x,p.x,g.x,k,h,l);d.initNonuniformCatmullRom(m.y,n.y,p.y,g.y,k,h,l);e.initNonuniformCatmullRom(m.z,n.z,p.z,g.z,k,h,l)}else"catmullrom"===this.type&&(k=void 0!==this.tension?this.tension:.5,c.initCatmullRom(m.x,n.x,p.x,g.x, k),d.initCatmullRom(m.y,n.y,p.y,g.y,k),e.initCatmullRom(m.z,n.z,p.z,g.z,k));return new THREE.Vector3(c.calc(a),d.calc(a),e.calc(a))})}();THREE.ClosedSplineCurve3=function(a){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Please use THREE.CatmullRomCurve3.");THREE.CatmullRomCurve3.call(this,a);this.type="catmullrom";this.closed=!0};THREE.ClosedSplineCurve3.prototype=Object.create(THREE.CatmullRomCurve3.prototype); -THREE.BoxGeometry=function(a,b,c,d,e,f){function g(a,b,c,d,e,f,g,u){var s,w=h.widthSegments,v=h.heightSegments,C=e/2,x=f/2,D=h.vertices.length;if("x"===a&&"y"===b||"y"===a&&"x"===b)s="z";else if("x"===a&&"z"===b||"z"===a&&"x"===b)s="y",v=h.depthSegments;else if("z"===a&&"y"===b||"y"===a&&"z"===b)s="x",w=h.depthSegments;var A=w+1,B=v+1,y=e/w,I=f/v,F=new THREE.Vector3;F[s]=0l;l++){e[0]=p[g[l]];e[1]=p[g[(l+1)%3]];e.sort(c);var q=e.toString();void 0===f[q]?f[q]={vert1:e[0],vert2:e[1],face1:m, face2:void 0}:f[q].face2=m}e=[];for(q in f)if(g=f[q],void 0===g.face2||h[g.face1].normal.dot(h[g.face2].normal)<=d)m=k[g.vert1],e.push(m.x),e.push(m.y),e.push(m.z),m=k[g.vert2],e.push(m.x),e.push(m.y),e.push(m.z);this.addAttribute("position",new THREE.BufferAttribute(new Float32Array(e),3))};THREE.EdgesGeometry.prototype=Object.create(THREE.BufferGeometry.prototype);THREE.EdgesGeometry.prototype.constructor=THREE.EdgesGeometry; THREE.ExtrudeGeometry=function(a,b){"undefined"!==typeof a&&(THREE.Geometry.call(this),this.type="ExtrudeGeometry",a=Array.isArray(a)?a:[a],this.addShapeList(a,b),this.computeFaceNormals())};THREE.ExtrudeGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry;THREE.ExtrudeGeometry.prototype.addShapeList=function(a,b){for(var c=a.length,d=0;dNumber.EPSILON){var k=Math.sqrt(h),l=Math.sqrt(f*f+g*g),h=b.x-e/k;b=b.y+d/k;f=((c.x-g/l-h)*g-(c.y+f/l-b)*f)/(d*g-e*f);c=h+d*f-a.x;a=b+e*f-a.y;d=c*c+a*a;if(2>=d)return new THREE.Vector2(c,a);d=Math.sqrt(d/2)}else a=!1,d>Number.EPSILON? -f>Number.EPSILON&&(a=!0):d<-Number.EPSILON?f<-Number.EPSILON&&(a=!0):Math.sign(e)===Math.sign(g)&&(a=!0),a?(c=-e,a=d,d=Math.sqrt(h)):(c=d,a=e,d=Math.sqrt(h/2));return new THREE.Vector2(c/d,a/d)}function e(a,b){var c,d;for(E=a.length;0<=--E;){c=E;d=E-1;0>d&&(d=a.length-1);for(var e=0,f=q+2*n,e=0;eNumber.EPSILON&&(a=!0):d<-Number.EPSILON?f<-Number.EPSILON&&(a=!0):Math.sign(e)===Math.sign(g)&&(a=!0),a?(c=-e,a=d,d=Math.sqrt(h)):(c=d,a=e,d=Math.sqrt(h/2));return new THREE.Vector2(c/d,a/d)}function e(a,b){var c,d;for(E=a.length;0<=--E;){c=E;d=E-1;0>d&&(d=a.length-1);for(var e=0,f=q+2*n,e=0;eMath.abs(b.y-c.y)?[new THREE.Vector2(b.x,1-b.z),new THREE.Vector2(c.x,1-c.z),new THREE.Vector2(d.x,1-d.z),new THREE.Vector2(e.x,1-e.z)]:[new THREE.Vector2(b.y,1-b.z),new THREE.Vector2(c.y,1-c.z),new THREE.Vector2(d.y, 1-d.z),new THREE.Vector2(e.y,1-e.z)]}};THREE.ShapeGeometry=function(a,b){THREE.Geometry.call(this);this.type="ShapeGeometry";!1===Array.isArray(a)&&(a=[a]);this.addShapeList(a,b);this.computeFaceNormals()};THREE.ShapeGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ShapeGeometry.prototype.constructor=THREE.ShapeGeometry;THREE.ShapeGeometry.prototype.addShapeList=function(a,b){for(var c=0,d=a.length;c