|
14019 | 14019 |
|
14020 | 14020 | var color_vertex = "#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif"; |
14021 | 14021 |
|
14022 | | - 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}\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}"; |
| 14022 | + 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}"; |
14023 | 14023 |
|
14024 | 14024 | 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"; |
14025 | 14025 |
|
|
17607 | 17607 | 'precision ' + parameters.precision + ' float;', |
17608 | 17608 | 'precision ' + parameters.precision + ' int;', |
17609 | 17609 |
|
| 17610 | + ( parameters.precision === 'highp' ) ? '#define HIGH_PRECISION' : '', |
| 17611 | + |
17610 | 17612 | '#define SHADER_NAME ' + shader.name, |
17611 | 17613 |
|
17612 | 17614 | customDefines, |
|
17725 | 17727 | 'precision ' + parameters.precision + ' float;', |
17726 | 17728 | 'precision ' + parameters.precision + ' int;', |
17727 | 17729 |
|
| 17730 | + ( parameters.precision === 'highp' ) ? '#define HIGH_PRECISION' : '', |
| 17731 | + |
17728 | 17732 | '#define SHADER_NAME ' + shader.name, |
17729 | 17733 |
|
17730 | 17734 | customDefines, |
|
34838 | 34842 |
|
34839 | 34843 | AnimationLoader.prototype = Object.assign( Object.create( Loader.prototype ), { |
34840 | 34844 |
|
| 34845 | + constructor: AnimationLoader, |
| 34846 | + |
34841 | 34847 | load: function ( url, onLoad, onProgress, onError ) { |
34842 | 34848 |
|
34843 | 34849 | var scope = this; |
@@ -37478,11 +37484,20 @@ |
37478 | 37484 |
|
37479 | 37485 | }, |
37480 | 37486 |
|
37481 | | - updateMatrices: function () { |
| 37487 | + updateMatrices: function ( light ) { |
37482 | 37488 |
|
37483 | 37489 | var shadowCamera = this.camera, |
37484 | 37490 | shadowMatrix = this.matrix, |
37485 | | - projScreenMatrix = this._projScreenMatrix; |
| 37491 | + projScreenMatrix = this._projScreenMatrix, |
| 37492 | + lookTarget = this._lookTarget, |
| 37493 | + lightPositionWorld = this._lightPositionWorld; |
| 37494 | + |
| 37495 | + lightPositionWorld.setFromMatrixPosition( light.matrixWorld ); |
| 37496 | + shadowCamera.position.copy( lightPositionWorld ); |
| 37497 | + |
| 37498 | + lookTarget.setFromMatrixPosition( light.target.matrixWorld ); |
| 37499 | + shadowCamera.lookAt( lookTarget ); |
| 37500 | + shadowCamera.updateMatrixWorld(); |
37486 | 37501 |
|
37487 | 37502 | projScreenMatrix.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse ); |
37488 | 37503 | this._frustum.setFromMatrix( projScreenMatrix ); |
|
37565 | 37580 |
|
37566 | 37581 | updateMatrices: function ( light, viewCamera, viewportIndex ) { |
37567 | 37582 |
|
37568 | | - var camera = this.camera, |
37569 | | - lookTarget = this._lookTarget, |
37570 | | - lightPositionWorld = this._lightPositionWorld; |
| 37583 | + var camera = this.camera; |
37571 | 37584 |
|
37572 | 37585 | var fov = _Math.RAD2DEG * 2 * light.angle; |
37573 | 37586 | var aspect = this.mapSize.width / this.mapSize.height; |
|
37582 | 37595 |
|
37583 | 37596 | } |
37584 | 37597 |
|
37585 | | - lightPositionWorld.setFromMatrixPosition( light.matrixWorld ); |
37586 | | - camera.position.copy( lightPositionWorld ); |
37587 | | - |
37588 | | - lookTarget.setFromMatrixPosition( light.target.matrixWorld ); |
37589 | | - camera.lookAt( lookTarget ); |
37590 | | - camera.updateMatrixWorld(); |
37591 | | - |
37592 | 37598 | LightShadow.prototype.updateMatrices.call( this, light, viewCamera, viewportIndex ); |
37593 | 37599 |
|
37594 | 37600 | } |
|
37958 | 37964 |
|
37959 | 37965 | updateMatrices: function ( light, viewCamera, viewportIndex ) { |
37960 | 37966 |
|
37961 | | - var camera = this.camera, |
37962 | | - lightPositionWorld = this._lightPositionWorld, |
37963 | | - lookTarget = this._lookTarget; |
37964 | | - |
37965 | | - lightPositionWorld.setFromMatrixPosition( light.matrixWorld ); |
37966 | | - camera.position.copy( lightPositionWorld ); |
37967 | | - |
37968 | | - lookTarget.setFromMatrixPosition( light.target.matrixWorld ); |
37969 | | - camera.lookAt( lookTarget ); |
37970 | | - camera.updateMatrixWorld(); |
37971 | | - |
37972 | 37967 | LightShadow.prototype.updateMatrices.call( this, light, viewCamera, viewportIndex ); |
37973 | 37968 |
|
37974 | 37969 | } |
@@ -38488,11 +38483,13 @@ |
38488 | 38483 |
|
38489 | 38484 | function BufferGeometryLoader( manager ) { |
38490 | 38485 |
|
38491 | | - this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; |
| 38486 | + Loader.call( this, manager ); |
38492 | 38487 |
|
38493 | 38488 | } |
38494 | 38489 |
|
38495 | | - Object.assign( BufferGeometryLoader.prototype, { |
| 38490 | + BufferGeometryLoader.prototype = Object.assign( Object.create( Loader.prototype ), { |
| 38491 | + |
| 38492 | + constructor: BufferGeometryLoader, |
38496 | 38493 |
|
38497 | 38494 | load: function ( url, onLoad, onProgress, onError ) { |
38498 | 38495 |
|
|
38596 | 38593 |
|
38597 | 38594 | return geometry; |
38598 | 38595 |
|
38599 | | - }, |
38600 | | - |
38601 | | - setPath: function ( value ) { |
38602 | | - |
38603 | | - this.path = value; |
38604 | | - return this; |
38605 | | - |
38606 | 38596 | } |
38607 | 38597 |
|
38608 | 38598 | } ); |
|
0 commit comments