diff --git a/build/t3d.js b/build/t3d.js index 7b1e044..4ff4c6a 100644 --- a/build/t3d.js +++ b/build/t3d.js @@ -10617,7 +10617,7 @@ var begin_vert = "vec3 transformed = vec3(a_Position);\nvec3 objectNormal = vec3(a_Normal);\n#ifdef USE_TANGENT\n vec3 objectTangent = vec3(a_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}\nvec3 BRDF_Diffuse_Lambert(vec3 diffuseColor) {\n return 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 D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nvec3 BRDF_Specular_BlinnPhong(vec3 specularColor, vec3 N, vec3 L, vec3 V, float shininess) {\n vec3 H = normalize(L + V);\n float dotNH = saturate(dot(N, H));\n float dotLH = saturate(dot(L, H));\n vec3 F = F_Schlick(specularColor, dotLH);\n float G = G_BlinnPhong_Implicit( );\n float D = D_BlinnPhong(shininess, dotNH);\n return F * G * D;\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}\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}\nvec3 BRDF_Specular_GGX(vec3 specularColor, vec3 N, vec3 L, vec3 V, float roughness) {\n\tfloat alpha = pow2( roughness );\n\tvec3 H = normalize(L + V);\n\tfloat dotNL = saturate( dot(N, L) );\n\tfloat dotNV = saturate( dot(N, V) );\n\tfloat dotNH = saturate( dot(N, H) );\n\tfloat dotLH = saturate( dot(L, H) );\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}\nvec3 BRDF_Specular_GGX_Environment(const in vec3 N, const in vec3 V, const in vec3 specularColor, const in float roughness) {\n\tfloat dotNV = saturate(dot(N, V));\n\tvec2 brdf = integrateSpecularBRDF(dotNV, roughness);\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment(const in vec3 N, const in vec3 V, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter) {\n\tfloat dotNV = saturate(dot(N, V));\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 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}\nvec3 BRDF_Diffuse_Lambert(vec3 diffuseColor) {\n return 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 D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nvec3 BRDF_Specular_BlinnPhong(vec3 specularColor, vec3 N, vec3 L, vec3 V, float shininess) {\n vec3 H = normalize(L + V);\n float dotNH = saturate(dot(N, H));\n float dotLH = saturate(dot(L, H));\n vec3 F = F_Schlick(specularColor, dotLH);\n float G = G_BlinnPhong_Implicit( );\n float D = D_BlinnPhong(shininess, dotNH);\n return F * G * D;\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}\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}\nvec3 BRDF_Specular_GGX(vec3 specularColor, vec3 N, vec3 L, vec3 V, float roughness) {\n\tfloat alpha = pow2( roughness );\n\tvec3 H = normalize(L + V);\n\tfloat dotNL = saturate( dot(N, L) );\n\tfloat dotNV = saturate( dot(N, V) );\n\tfloat dotNH = saturate( dot(N, H) );\n\tfloat dotLH = saturate( dot(L, H) );\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}\nvec3 BRDF_Specular_GGX_Environment(const in vec3 N, const in vec3 V, const in vec3 specularColor, const in float roughness) {\n\tfloat dotNV = saturate(dot(N, V));\n\tvec2 brdf = integrateSpecularBRDF(dotNV, roughness);\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment(const in vec3 N, const in vec3 V, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter) {\n\tfloat dotNV = saturate(dot(N, V));\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 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}\nfloat getAARoughnessFactor(vec3 normal) {\n\tvec3 dxy = max( abs(dFdx(normal)), abs(dFdy(normal)) );\n\treturn 0.04 + max( max(dxy.x, dxy.y), dxy.z );\n}"; var bumpMap_pars_frag = "#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd(vec2 uv) {\n\t\tvec2 dSTdx = dFdx( uv );\n\t\tvec2 dSTdy = dFdy( uv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, uv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, uv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, uv + 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"; @@ -10669,7 +10669,7 @@ var inverse = "mat4 inverseMat4(mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n}"; - var light_frag = "\n#if (defined(USE_PHONG) || defined(USE_PBR))\n vec3 V = normalize(u_CameraPosition - v_modelPos);\n#endif\n#ifdef USE_PBR\n #ifdef USE_PBR2\n vec3 diffuseColor = outColor.xyz;\n vec3 specularColor = specularFactor.xyz;\n float roughness = max(1.0 - glossinessFactor, 0.0525);\n #else\n vec3 diffuseColor = outColor.xyz * (1.0 - metalnessFactor);\n vec3 specularColor = mix(vec3(0.04), outColor.xyz, metalnessFactor);\n float roughness = max(roughnessFactor, 0.0525);\n #endif\n vec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\n float geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);\n roughness += geometryRoughness;\n roughness = min(roughness, 1.0);\n #ifdef USE_CLEARCOAT\n float clearcoat = u_Clearcoat;\n float clearcoatRoughness = u_ClearcoatRoughness;\n #ifdef USE_CLEARCOATMAP\n\t\t clearcoat *= texture2D(clearcoatMap, v_Uv).x;\n #endif\n #ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\t clearcoatRoughness *= texture2D(clearcoatRoughnessMap, v_Uv).y;\n\t #endif\n clearcoat = saturate(clearcoat);\n clearcoatRoughness = max(clearcoatRoughness, 0.0525);\n\t clearcoatRoughness += geometryRoughness;\n\t clearcoatRoughness = min(clearcoatRoughness, 1.0);\n #endif\n#else\n vec3 diffuseColor = outColor.xyz;\n #ifdef USE_PHONG\n vec3 specularColor = u_SpecularColor.xyz;\n float shininess = u_Specular;\n #endif\n#endif\n#ifdef USE_LIGHT\n vec3 L;\n float falloff;\n float dotNL;\n vec3 irradiance;\n float clearcoatDHR;\n #ifdef USE_CLEARCOAT\n float ccDotNL;\n vec3 ccIrradiance;\n #endif\n #if NUM_DIR_LIGHTS > 0\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_DIR_LIGHTS; i++) {\n L = normalize(-u_Directional[i].direction);\n falloff = 1.0;\n #if defined(USE_SHADOW) && (UNROLLED_LOOP_INDEX < NUM_DIR_SHADOWS)\n #ifdef USE_PCSS_SOFT_SHADOW\n falloff *= getShadowWithPCSS(directionalDepthMap[i], directionalShadowMap[i], vDirectionalShadowCoord[i], u_DirectionalShadow[i].shadowMapSize, u_DirectionalShadow[i].shadowBias, u_DirectionalShadow[i].shadowParams);\n #else\n falloff *= getShadow(directionalShadowMap[i], vDirectionalShadowCoord[i], u_DirectionalShadow[i].shadowMapSize, u_DirectionalShadow[i].shadowBias, u_DirectionalShadow[i].shadowParams);\n #endif\n #endif\n dotNL = saturate(dot(N, L));\n irradiance = u_Directional[i].color * falloff * dotNL * PI;\n #ifdef USE_CLEARCOAT \n ccDotNL = saturate(dot(clearcoatNormal, L));\n ccIrradiance = ccDotNL * u_Directional[i].color * falloff * PI;\n clearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n reflectedLight.directSpecular += ccIrradiance * clearcoat * BRDF_Specular_GGX(specularColor, clearcoatNormal, L, V, clearcoatRoughness);\n #else\n\t\t clearcoatDHR = 0.0;\n\t #endif\n reflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance * BRDF_Diffuse_Lambert(diffuseColor);\n #ifdef USE_PHONG\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\n #endif\n #ifdef USE_PBR\n reflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness);\n #endif\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHTS > 0\n vec3 worldV;\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_POINT_LIGHTS; i++) {\n worldV = v_modelPos - u_Point[i].position;\n L = -worldV;\n falloff = pow(clamp(1. - length(L) / u_Point[i].distance, 0.0, 1.0), u_Point[i].decay);\n L = normalize(L);\n #if defined(USE_SHADOW) && (UNROLLED_LOOP_INDEX < NUM_POINT_SHADOWS)\n falloff *= getPointShadow(pointShadowMap[i], vPointShadowCoord[i], u_PointShadow[i].shadowMapSize, u_PointShadow[i].shadowBias, u_PointShadow[i].shadowParams, u_PointShadow[i].shadowCameraRange);\n #endif\n dotNL = saturate(dot(N, L));\n irradiance = u_Point[i].color * falloff * dotNL * PI;\n #ifdef USE_CLEARCOAT \n ccDotNL = saturate(dot(clearcoatNormal, L));\n ccIrradiance = ccDotNL * u_Point[i].color * falloff * PI;\n clearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n reflectedLight.directSpecular += ccIrradiance * clearcoat * BRDF_Specular_GGX(specularColor, clearcoatNormal, L, V, clearcoatRoughness);\n #else\n\t\t clearcoatDHR = 0.0;\n\t #endif\n reflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance * BRDF_Diffuse_Lambert(diffuseColor);\n #ifdef USE_PHONG\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\n #endif\n #ifdef USE_PBR\n reflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness);\n #endif\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHTS > 0\n float lightDistance;\n float angleCos;\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\n L = u_Spot[i].position - v_modelPos;\n lightDistance = length(L);\n L = normalize(L);\n angleCos = dot(L, -normalize(u_Spot[i].direction));\n falloff = smoothstep(u_Spot[i].coneCos, u_Spot[i].penumbraCos, angleCos);\n falloff *= pow(clamp(1. - lightDistance / u_Spot[i].distance, 0.0, 1.0), u_Spot[i].decay);\n #if defined(USE_SHADOW) && (UNROLLED_LOOP_INDEX < NUM_SPOT_SHADOWS)\n #ifdef USE_PCSS_SOFT_SHADOW\n falloff *= getShadowWithPCSS(spotDepthMap[i], spotShadowMap[i], vSpotShadowCoord[i], u_SpotShadow[i].shadowMapSize, u_SpotShadow[i].shadowBias, u_SpotShadow[i].shadowParams);\n #else\n falloff *= getShadow(spotShadowMap[i], vSpotShadowCoord[i], u_SpotShadow[i].shadowMapSize, u_SpotShadow[i].shadowBias, u_SpotShadow[i].shadowParams);\n #endif\n #endif\n dotNL = saturate(dot(N, L));\n irradiance = u_Spot[i].color * falloff * dotNL * PI;\n #ifdef USE_CLEARCOAT \n ccDotNL = saturate(dot(clearcoatNormal, L));\n ccIrradiance = ccDotNL * u_Spot[i].color * falloff * PI;\n clearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n reflectedLight.directSpecular += ccIrradiance * clearcoat * BRDF_Specular_GGX(specularColor, clearcoatNormal, L, V, clearcoatRoughness);\n #else\n\t\t clearcoatDHR = 0.0;\n\t #endif\n reflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance * BRDF_Diffuse_Lambert(diffuseColor);\n #ifdef USE_PHONG\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\n #endif\n #ifdef USE_PBR\n reflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness);\n #endif\n }\n #pragma unroll_loop_end\n #endif\n vec3 iblIrradiance = vec3(0., 0., 0.);\n vec3 indirectIrradiance = vec3(0., 0., 0.);\n vec3 indirectRadiance = vec3(0., 0., 0.);\n vec3 clearcoatRadiance = vec3(0., 0., 0.);\n #ifdef USE_AMBIENT_LIGHT\n indirectIrradiance += u_AmbientLightColor * PI;\n #endif\n #if NUM_HEMI_LIGHTS > 0\n float hemiDiffuseWeight;\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_HEMI_LIGHTS; i++) {\n L = normalize(u_Hemi[i].direction);\n dotNL = dot(N, L);\n hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n indirectIrradiance += mix(u_Hemi[i].groundColor, u_Hemi[i].skyColor, hemiDiffuseWeight) * PI;\n }\n #pragma unroll_loop_end\n #endif\n #if defined(USE_ENV_MAP) && defined(USE_PBR)\n vec3 envDir;\n #ifdef USE_VERTEX_ENVDIR\n envDir = v_EnvDir;\n #else\n envDir = reflect(normalize(v_modelPos - u_CameraPosition), N);\n #endif\n iblIrradiance += getLightProbeIndirectIrradiance(maxMipLevel, N);\n indirectRadiance += getLightProbeIndirectRadiance(GGXRoughnessToBlinnExponent(roughness), maxMipLevel, envDir);\n #ifdef USE_CLEARCOAT\n vec3 clearcoatDir = reflect(normalize(v_modelPos - u_CameraPosition), clearcoatNormal);\n\t\t clearcoatRadiance += getLightProbeIndirectRadiance(GGXRoughnessToBlinnExponent(clearcoatRoughness), maxMipLevel, clearcoatDir);\n\t #endif\n #endif\n reflectedLight.indirectDiffuse += indirectIrradiance * BRDF_Diffuse_Lambert(diffuseColor);\n #if defined(USE_ENV_MAP) && defined(USE_PBR)\n #ifdef USE_CLEARCOAT\n float ccDotNV = saturate(dot(clearcoatNormal, V));\n reflectedLight.indirectSpecular += clearcoatRadiance * clearcoat * BRDF_Specular_GGX_Environment(clearcoatNormal, V, specularColor, clearcoatRoughness);\n ccDotNL = ccDotNV;\n clearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n #else\n clearcoatDHR = 0.0;\n #endif\n float clearcoatInv = 1.0 - clearcoatDHR;\n vec3 singleScattering = vec3(0.0);\n\t vec3 multiScattering = vec3(0.0);\n vec3 cosineWeightedIrradiance = iblIrradiance * RECIPROCAL_PI;\n BRDF_Specular_Multiscattering_Environment(N, V, specularColor, roughness, singleScattering, multiScattering);\n vec3 diffuse = diffuseColor * (1.0 - (singleScattering + multiScattering));\n reflectedLight.indirectSpecular += clearcoatInv * indirectRadiance * singleScattering;\n reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n #endif\n#endif"; + var light_frag = "\n#if (defined(USE_PHONG) || defined(USE_PBR))\n vec3 V = normalize(u_CameraPosition - v_modelPos);\n#endif\n#ifdef USE_PBR\n #ifdef USE_PBR2\n vec3 diffuseColor = outColor.xyz;\n vec3 specularColor = specularFactor.xyz;\n float roughness = max(1.0 - glossinessFactor, 0.0525);\n #else\n vec3 diffuseColor = outColor.xyz * (1.0 - metalnessFactor);\n vec3 specularColor = mix(vec3(0.04), outColor.xyz, metalnessFactor);\n float roughness = max(roughnessFactor, 0.0525);\n #endif\n roughness = min(max(roughness, getAARoughnessFactor(N)), 1.0);\n #ifdef USE_CLEARCOAT\n float clearcoat = u_Clearcoat;\n float clearcoatRoughness = u_ClearcoatRoughness;\n #ifdef USE_CLEARCOATMAP\n\t\t clearcoat *= texture2D(clearcoatMap, v_Uv).x;\n #endif\n #ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\t clearcoatRoughness *= texture2D(clearcoatRoughnessMap, v_Uv).y;\n\t #endif\n clearcoat = saturate(clearcoat);\n clearcoatRoughness = max(clearcoatRoughness, 0.0525);\n\t clearcoatRoughness = min(max(clearcoatRoughness, getAARoughnessFactor(geometryNormal)), 1.0);\n #endif\n#else\n vec3 diffuseColor = outColor.xyz;\n #ifdef USE_PHONG\n vec3 specularColor = u_SpecularColor.xyz;\n float shininess = u_Specular;\n #endif\n#endif\n#ifdef USE_LIGHT\n vec3 L;\n float falloff;\n float dotNL;\n vec3 irradiance;\n float clearcoatDHR;\n #ifdef USE_CLEARCOAT\n float ccDotNL;\n vec3 ccIrradiance;\n #endif\n #if NUM_DIR_LIGHTS > 0\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_DIR_LIGHTS; i++) {\n L = normalize(-u_Directional[i].direction);\n falloff = 1.0;\n #if defined(USE_SHADOW) && (UNROLLED_LOOP_INDEX < NUM_DIR_SHADOWS)\n #ifdef USE_PCSS_SOFT_SHADOW\n falloff *= getShadowWithPCSS(directionalDepthMap[i], directionalShadowMap[i], vDirectionalShadowCoord[i], u_DirectionalShadow[i].shadowMapSize, u_DirectionalShadow[i].shadowBias, u_DirectionalShadow[i].shadowParams);\n #else\n falloff *= getShadow(directionalShadowMap[i], vDirectionalShadowCoord[i], u_DirectionalShadow[i].shadowMapSize, u_DirectionalShadow[i].shadowBias, u_DirectionalShadow[i].shadowParams);\n #endif\n #endif\n dotNL = saturate(dot(N, L));\n irradiance = u_Directional[i].color * falloff * dotNL * PI;\n #ifdef USE_CLEARCOAT \n ccDotNL = saturate(dot(clearcoatNormal, L));\n ccIrradiance = ccDotNL * u_Directional[i].color * falloff * PI;\n clearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n reflectedLight.directSpecular += ccIrradiance * clearcoat * BRDF_Specular_GGX(specularColor, clearcoatNormal, L, V, clearcoatRoughness);\n #else\n\t\t clearcoatDHR = 0.0;\n\t #endif\n reflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance * BRDF_Diffuse_Lambert(diffuseColor);\n #ifdef USE_PHONG\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\n #endif\n #ifdef USE_PBR\n reflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness);\n #endif\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHTS > 0\n vec3 worldV;\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_POINT_LIGHTS; i++) {\n worldV = v_modelPos - u_Point[i].position;\n L = -worldV;\n falloff = pow(clamp(1. - length(L) / u_Point[i].distance, 0.0, 1.0), u_Point[i].decay);\n L = normalize(L);\n #if defined(USE_SHADOW) && (UNROLLED_LOOP_INDEX < NUM_POINT_SHADOWS)\n falloff *= getPointShadow(pointShadowMap[i], vPointShadowCoord[i], u_PointShadow[i].shadowMapSize, u_PointShadow[i].shadowBias, u_PointShadow[i].shadowParams, u_PointShadow[i].shadowCameraRange);\n #endif\n dotNL = saturate(dot(N, L));\n irradiance = u_Point[i].color * falloff * dotNL * PI;\n #ifdef USE_CLEARCOAT \n ccDotNL = saturate(dot(clearcoatNormal, L));\n ccIrradiance = ccDotNL * u_Point[i].color * falloff * PI;\n clearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n reflectedLight.directSpecular += ccIrradiance * clearcoat * BRDF_Specular_GGX(specularColor, clearcoatNormal, L, V, clearcoatRoughness);\n #else\n\t\t clearcoatDHR = 0.0;\n\t #endif\n reflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance * BRDF_Diffuse_Lambert(diffuseColor);\n #ifdef USE_PHONG\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\n #endif\n #ifdef USE_PBR\n reflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness);\n #endif\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHTS > 0\n float lightDistance;\n float angleCos;\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\n L = u_Spot[i].position - v_modelPos;\n lightDistance = length(L);\n L = normalize(L);\n angleCos = dot(L, -normalize(u_Spot[i].direction));\n falloff = smoothstep(u_Spot[i].coneCos, u_Spot[i].penumbraCos, angleCos);\n falloff *= pow(clamp(1. - lightDistance / u_Spot[i].distance, 0.0, 1.0), u_Spot[i].decay);\n #if defined(USE_SHADOW) && (UNROLLED_LOOP_INDEX < NUM_SPOT_SHADOWS)\n #ifdef USE_PCSS_SOFT_SHADOW\n falloff *= getShadowWithPCSS(spotDepthMap[i], spotShadowMap[i], vSpotShadowCoord[i], u_SpotShadow[i].shadowMapSize, u_SpotShadow[i].shadowBias, u_SpotShadow[i].shadowParams);\n #else\n falloff *= getShadow(spotShadowMap[i], vSpotShadowCoord[i], u_SpotShadow[i].shadowMapSize, u_SpotShadow[i].shadowBias, u_SpotShadow[i].shadowParams);\n #endif\n #endif\n dotNL = saturate(dot(N, L));\n irradiance = u_Spot[i].color * falloff * dotNL * PI;\n #ifdef USE_CLEARCOAT \n ccDotNL = saturate(dot(clearcoatNormal, L));\n ccIrradiance = ccDotNL * u_Spot[i].color * falloff * PI;\n clearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n reflectedLight.directSpecular += ccIrradiance * clearcoat * BRDF_Specular_GGX(specularColor, clearcoatNormal, L, V, clearcoatRoughness);\n #else\n\t\t clearcoatDHR = 0.0;\n\t #endif\n reflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance * BRDF_Diffuse_Lambert(diffuseColor);\n #ifdef USE_PHONG\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\n #endif\n #ifdef USE_PBR\n reflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness);\n #endif\n }\n #pragma unroll_loop_end\n #endif\n vec3 iblIrradiance = vec3(0., 0., 0.);\n vec3 indirectIrradiance = vec3(0., 0., 0.);\n vec3 indirectRadiance = vec3(0., 0., 0.);\n vec3 clearcoatRadiance = vec3(0., 0., 0.);\n #ifdef USE_AMBIENT_LIGHT\n indirectIrradiance += u_AmbientLightColor * PI;\n #endif\n #if NUM_HEMI_LIGHTS > 0\n float hemiDiffuseWeight;\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_HEMI_LIGHTS; i++) {\n L = normalize(u_Hemi[i].direction);\n dotNL = dot(N, L);\n hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n indirectIrradiance += mix(u_Hemi[i].groundColor, u_Hemi[i].skyColor, hemiDiffuseWeight) * PI;\n }\n #pragma unroll_loop_end\n #endif\n #if defined(USE_ENV_MAP) && defined(USE_PBR)\n vec3 envDir;\n #ifdef USE_VERTEX_ENVDIR\n envDir = v_EnvDir;\n #else\n envDir = reflect(normalize(v_modelPos - u_CameraPosition), N);\n #endif\n iblIrradiance += getLightProbeIndirectIrradiance(maxMipLevel, N);\n indirectRadiance += getLightProbeIndirectRadiance(GGXRoughnessToBlinnExponent(roughness), maxMipLevel, envDir);\n #ifdef USE_CLEARCOAT\n vec3 clearcoatDir = reflect(normalize(v_modelPos - u_CameraPosition), clearcoatNormal);\n\t\t clearcoatRadiance += getLightProbeIndirectRadiance(GGXRoughnessToBlinnExponent(clearcoatRoughness), maxMipLevel, clearcoatDir);\n\t #endif\n #endif\n reflectedLight.indirectDiffuse += indirectIrradiance * BRDF_Diffuse_Lambert(diffuseColor);\n #if defined(USE_ENV_MAP) && defined(USE_PBR)\n #ifdef USE_CLEARCOAT\n float ccDotNV = saturate(dot(clearcoatNormal, V));\n reflectedLight.indirectSpecular += clearcoatRadiance * clearcoat * BRDF_Specular_GGX_Environment(clearcoatNormal, V, specularColor, clearcoatRoughness);\n ccDotNL = ccDotNV;\n clearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n #else\n clearcoatDHR = 0.0;\n #endif\n float clearcoatInv = 1.0 - clearcoatDHR;\n vec3 singleScattering = vec3(0.0);\n\t vec3 multiScattering = vec3(0.0);\n vec3 cosineWeightedIrradiance = iblIrradiance * RECIPROCAL_PI;\n BRDF_Specular_Multiscattering_Environment(N, V, specularColor, roughness, singleScattering, multiScattering);\n vec3 diffuse = diffuseColor * (1.0 - (singleScattering + multiScattering));\n reflectedLight.indirectSpecular += clearcoatInv * indirectRadiance * singleScattering;\n reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n #endif\n#endif"; var light_pars_frag = "#ifdef USE_AMBIENT_LIGHT\n uniform vec3 u_AmbientLightColor;\n#endif\n#ifdef USE_CLEARCOAT\n float clearcoatDHRApprox(const in float roughness, const in float dotNL) {\n return 0.04 + (1.0 - 0.16) * (pow(1.0 - dotNL, 5.0) * pow(1.0 - roughness, 2.0));\n }\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n\t\tvec3 groundColor;\n };\n uniform HemisphereLight u_Hemi[NUM_HEMI_LIGHTS];\n#endif\n#if NUM_DIR_LIGHTS > 0\n struct DirectLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectLight u_Directional[NUM_DIR_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 u_Point[NUM_POINT_LIGHTS];\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n vec3 direction;\n };\n uniform SpotLight u_Spot[NUM_SPOT_LIGHTS];\n#endif\n#if defined(USE_PBR) && defined(USE_ENV_MAP)\n vec3 getLightProbeIndirectIrradiance(const in int maxMIPLevel, const in vec3 N) {\n vec3 coordVec = vec3(u_EnvMap_Flip * N.x, N.yz);\n \t#ifdef TEXTURE_LOD_EXT\n \t\tvec4 envMapColor = textureCubeLodEXT(envMap, coordVec, float(maxMIPLevel));\n \t#else\n \t\tvec4 envMapColor = textureCube(envMap, coordVec, float(maxMIPLevel));\n \t#endif\n envMapColor = envMapTexelToLinear(envMapColor);\n return PI * envMapColor.rgb * u_EnvMap_Intensity * u_EnvMapLight_Intensity;\n }\n float getSpecularMIPLevel(const in float blinnShininessExponent, const in int maxMIPLevel) {\n \tfloat maxMIPLevelScalar = float(maxMIPLevel);\n \tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2(pow2(blinnShininessExponent) + 1.0);\n \treturn clamp(desiredMIPLevel, 0.0, maxMIPLevelScalar);\n }\n vec3 getLightProbeIndirectRadiance(const in float blinnShininessExponent, const in int maxMIPLevel, const in vec3 envDir) {\n float specularMIPLevel = getSpecularMIPLevel(blinnShininessExponent, maxMIPLevel);\n vec3 coordVec = vec3(u_EnvMap_Flip * envDir.x, envDir.yz);\n #ifdef TEXTURE_LOD_EXT\n \t\tvec4 envMapColor = textureCubeLodEXT(envMap, coordVec, specularMIPLevel);\n \t#else\n \t\tvec4 envMapColor = textureCube(envMap, coordVec, specularMIPLevel);\n \t#endif\n envMapColor = envMapTexelToLinear(envMapColor);\n return envMapColor.rgb * u_EnvMap_Intensity;\n }\n float 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 }\n#endif"; diff --git a/build/t3d.min.js b/build/t3d.min.js index 23b77d9..43545d4 100644 --- a/build/t3d.min.js +++ b/build/t3d.min.js @@ -1,3 +1,3 @@ // t3d -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).t3d={})}(this,(function(t){"use strict";function e(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,i=new Array(e);n=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var h=function(){function t(t,e,n,i,r){void 0===r&&(r=!0),this.target=t,this.propertyPath=e,this.name=this.target.uuid+"."+e,this.times=n,this.values=i,this.valueSize=i.length/n.length,this.interpolant=r}var e=t.prototype;return e.getValue=function(t,e){var n=this.times,i=n.length;if(t<=n[0])return this._copyValue(0,e);if(t>=n[i-1])return this._copyValue(i-1,e);for(var r=i-1;t0;)r--;var a=(t-n[r])/(n[r+1]-n[r]);return this._interpolate(r,a,e)},e._interpolate=function(t,e,n){for(var i,r,a=this.values,o=this.valueSize,s=0;s=0?1:-1,g=1-v*v;if(g>Number.EPSILON){var E=Math.sqrt(g),S=Math.atan2(E,v*m);_=Math.sin(_*S)/E,o=Math.sin(o*S)/E}var M=o*m;if(s=s*_+h*M,u=u*_+d*M,l=l*_+f*M,c=c*_+p*M,_===1-o){var T=1/Math.sqrt(s*s+u*u+l*l+c*c);s*=T,u*=T,l*=T,c*=T}}t[e]=s,t[e+1]=u,t[e+2]=l,t[e+3]=c},t.multiplyQuaternionsFlat=function(t,e,n,i,r,a){var o=n[i],s=n[i+1],u=n[i+2],l=n[i+3],c=r[a],h=r[a+1],d=r[a+2],f=r[a+3];return t[e]=o*f+l*c+s*d-u*h,t[e+1]=s*f+l*h+u*c-o*d,t[e+2]=u*f+l*d+o*h-s*c,t[e+3]=l*f-o*c-s*h-u*d,t};var e=t.prototype;return e.normalize=function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this.onChangeCallback(),this},e.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},e.lerpQuaternions=function(t,e,n){if(0===n)return this.copy(t);if(1===n)return this.copy(e);var i=t._w,r=t._x,a=t._y,o=t._z,s=e._w,u=e._x,l=e._y,c=e._z;i*s+r*u+a*l+o*c<0&&(s=-s,u=-u,l=-l,c=-c),this._w=i+n*(s-i),this._x=r+n*(u-r),this._y=a+n*(l-a),this._z=o+n*(c-o);var h=1/Math.sqrt(this._w*this._w+this._x*this._x+this._y*this._y+this._z*this._z);return this._w*=h,this._x*=h,this._y*=h,this._z*=h,this.onChangeCallback(),this},e.slerpQuaternions=function(t,e,n){if(0===n)return this.copy(t);if(1===n)return this.copy(e);var i=t._w,r=t._x,a=t._y,o=t._z,s=e._w,u=e._x,l=e._y,c=e._z,h=i*s+r*u+a*l+o*c;if(h<0&&(h=-h,s=-s,u=-u,l=-l,c=-c),h<.95){var d=Math.acos(h),f=1/Math.sin(d),p=Math.sin(d*(1-n))*f,_=Math.sin(d*n)*f;this._w=i*p+s*_,this._x=r*p+u*_,this._y=a*p+l*_,this._z=o*p+c*_}else{this._w=i+n*(s-i),this._x=r+n*(u-r),this._y=a+n*(l-a),this._z=o+n*(c-o);var v=1/Math.sqrt(this._w*this._w+this._x*this._x+this._y*this._y+this._z*this._z);this._w*=v,this._x*=v,this._y*=v,this._z*=v}return this.onChangeCallback(),this},e.set=function(t,e,n,i){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===i&&(i=1),this._x=t,this._y=e,this._z=n,this._w=i,this.onChangeCallback(),this},e.clone=function(){return new t(this._x,this._y,this._z,this._w)},e.copy=function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=void 0!==t.w?t.w:1,this.onChangeCallback(),this},e.setFromEuler=function(t,e){void 0===e&&(e=!0);var n=Math.cos(t._x/2),i=Math.cos(t._y/2),r=Math.cos(t._z/2),a=Math.sin(t._x/2),o=Math.sin(t._y/2),s=Math.sin(t._z/2),u=t._order;return"XYZ"===u?(this._x=a*i*r+n*o*s,this._y=n*o*r-a*i*s,this._z=n*i*s+a*o*r,this._w=n*i*r-a*o*s):"YXZ"===u?(this._x=a*i*r+n*o*s,this._y=n*o*r-a*i*s,this._z=n*i*s-a*o*r,this._w=n*i*r+a*o*s):"ZXY"===u?(this._x=a*i*r-n*o*s,this._y=n*o*r+a*i*s,this._z=n*i*s+a*o*r,this._w=n*i*r-a*o*s):"ZYX"===u?(this._x=a*i*r-n*o*s,this._y=n*o*r+a*i*s,this._z=n*i*s-a*o*r,this._w=n*i*r+a*o*s):"YZX"===u?(this._x=a*i*r+n*o*s,this._y=n*o*r+a*i*s,this._z=n*i*s-a*o*r,this._w=n*i*r-a*o*s):"XZY"===u&&(this._x=a*i*r-n*o*s,this._y=n*o*r-a*i*s,this._z=n*i*s+a*o*r,this._w=n*i*r+a*o*s),!0===e&&this.onChangeCallback(),this},e.setFromRotationMatrix=function(t){var e,n=t.elements,i=n[0],r=n[4],a=n[8],o=n[1],s=n[5],u=n[9],l=n[2],c=n[6],h=n[10],d=i+s+h;return d>0?(e=.5/Math.sqrt(d+1),this._w=.25/e,this._x=(c-u)*e,this._y=(a-l)*e,this._z=(o-r)*e):i>s&&i>h?(e=2*Math.sqrt(1+i-s-h),this._w=(c-u)/e,this._x=.25*e,this._y=(r+o)/e,this._z=(a+l)/e):s>h?(e=2*Math.sqrt(1+s-i-h),this._w=(a-l)/e,this._x=(r+o)/e,this._y=.25*e,this._z=(u+c)/e):(e=2*Math.sqrt(1+h-i-s),this._w=(o-r)/e,this._x=(a+l)/e,this._y=(u+c)/e,this._z=.25*e),this.onChangeCallback(),this},e.setFromUnitVectors=function(t,e){var n=t.dot(e)+1;return nMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()},e.multiply=function(t){return this.multiplyQuaternions(this,t)},e.premultiply=function(t){return this.multiplyQuaternions(t,this)},e.multiplyQuaternions=function(t,e){var n=t._x,i=t._y,r=t._z,a=t._w,o=e._x,s=e._y,u=e._z,l=e._w;return this._x=n*l+a*o+i*u-r*s,this._y=i*l+a*s+r*o-n*u,this._z=r*l+a*u+n*s-i*o,this._w=a*l-n*o-i*s-r*u,this.onChangeCallback(),this},e.toMatrix4=function(t){void 0===t&&(t=new m);var e=t.elements,n=2*this._x*this._y,i=2*this._x*this._z,r=2*this._x*this._w,a=2*this._y*this._z,o=2*this._y*this._w,s=2*this._z*this._w,u=this._x*this._x,l=this._y*this._y,c=this._z*this._z,h=this._w*this._w;return e[0]=u-l-c+h,e[4]=n-s,e[8]=i+o,e[12]=0,e[1]=n+s,e[5]=-u+l-c+h,e[9]=a-r,e[13]=0,e[2]=i-o,e[6]=a+r,e[10]=-u-l+c+h,e[14]=0,e[3]=0,e[7]=0,e[11]=0,e[15]=1,t},e.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},e.dot=function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},e.setFromAxisAngle=function(t,e){var n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this.onChangeCallback(),this},e.fromArray=function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this.onChangeCallback(),this},e.toArray=function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},e.onChange=function(t){return this.onChangeCallback=t,this},e.onChangeCallback=function(){},n(t,[{key:"x",get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback()}},{key:"y",get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback()}},{key:"z",get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback()}},{key:"w",get:function(){return this._w},set:function(t){this._w=t,this.onChangeCallback()}}]),t}(),x=function(t){function e(e,n,i,r,a){return t.call(this,e,n,i,r,a)||this}return i(e,t),e.prototype._interpolate=function(t,e,n){var i=this.values;return this.interpolant?y.slerpFlat(n,0,i,4*t,i,4*(t+1),e):this._copyValue(t,n),n},e}(h);x.prototype.valueTypeName="quaternion";var w=function(t){function e(e,n,i,r,a){return t.call(this,e,n,i,r,a)||this}return i(e,t),e.prototype._interpolate=function(t,e,n){return n[0]=this.values[t],n},e}(h);w.prototype.valueTypeName="string";var A=function(t){function e(e,n,i,r,a){return t.call(this,e,n,i,r,a)||this}return i(e,t),e}(h);A.prototype.valueTypeName="vector";var b={BASIC:"basic",LAMBERT:"lambert",PHONG:"phong",PBR:"pbr",PBR2:"pbr2",MATCAP:"matcap",POINT:"point",LINE:"line",SHADER:"shader",DEPTH:"depth",DISTANCE:"distance"},R={NONE:"none",NORMAL:"normal",ADD:"add",SUB:"sub",MUL:"mul",CUSTOM:"custom"},N={ADD:100,SUBTRACT:101,REVERSE_SUBTRACT:102},P={ZERO:200,ONE:201,SRC_COLOR:202,SRC_ALPHA:203,SRC_ALPHA_SATURATE:204,DST_COLOR:205,DST_ALPHA:206,ONE_MINUS_SRC_COLOR:207,ONE_MINUS_SRC_ALPHA:208,ONE_MINUS_DST_COLOR:209,ONE_MINUS_DST_ALPHA:210},L={NONE:"none",FRONT:"front",BACK:"back",FRONT_AND_BACK:"front_and_back"},C={FRONT:"front",BACK:"back",DOUBLE:"double"},D={SMOOTH_SHADING:"smooth_shading",FLAT_SHADING:"flat_shading"},O={DEPTH_COMPONENT:1e3,DEPTH_STENCIL:1001,STENCIL_INDEX8:1002,ALPHA:1003,RED:1004,RGB:1005,RGBA:1006,LUMINANCE:1007,LUMINANCE_ALPHA:1008,RED_INTEGER:1010,RG:1011,RG_INTEGER:1012,RGB_INTEGER:1013,RGBA_INTEGER:1014,R32F:1100,R16F:1101,R8:1102,RG32F:1103,RG16F:1104,RG8:1105,RGB32F:1106,RGB16F:1107,RGB8:1108,RGBA32F:1109,RGBA16F:1110,RGBA8:1111,RGBA4:1112,RGB5_A1:1113,DEPTH_COMPONENT32F:1114,DEPTH_COMPONENT24:1115,DEPTH_COMPONENT16:1116,DEPTH24_STENCIL8:1117,DEPTH32F_STENCIL8:1118,RGB_S3TC_DXT1:1200,RGBA_S3TC_DXT1:1201,RGBA_S3TC_DXT3:1202,RGBA_S3TC_DXT5:1203,RGB_PVRTC_4BPPV1:1204,RGB_PVRTC_2BPPV1:1205,RGBA_PVRTC_4BPPV1:1206,RGBA_PVRTC_2BPPV1:1207,RGB_ETC1:1208,RGBA_ASTC_4x4:1209,RGBA_BPTC:1210},F={UNSIGNED_BYTE:1500,UNSIGNED_SHORT_5_6_5:1501,UNSIGNED_SHORT_4_4_4_4:1502,UNSIGNED_SHORT_5_5_5_1:1503,UNSIGNED_SHORT:1504,UNSIGNED_INT:1505,UNSIGNED_INT_24_8:1506,FLOAT:1507,HALF_FLOAT:1508,FLOAT_32_UNSIGNED_INT_24_8_REV:1509,BYTE:1510,SHORT:1511,INT:1512},I={NEAREST:1600,LINEAR:1601,NEAREST_MIPMAP_NEAREST:1602,LINEAR_MIPMAP_NEAREST:1603,NEAREST_MIPMAP_LINEAR:1604,LINEAR_MIPMAP_LINEAR:1605},U={REPEAT:1700,CLAMP_TO_EDGE:1701,MIRRORED_REPEAT:1702},B={LEQUAL:515,GEQUAL:518,LESS:513,GREATER:516,EQUAL:514,NOTEQUAL:517,ALWAYS:519,NEVER:512},G={KEEP:7680,REPLACE:7681,INCR:7682,DECR:7683,INVERT:5386,INCR_WRAP:34055,DECR_WRAP:34056},z={HARD:"hard",POISSON_SOFT:"poisson_soft",PCF3_SOFT:"pcf3_soft",PCF5_SOFT:"pcf5_soft",PCSS16_SOFT:"pcss16_soft",PCSS32_SOFT:"pcss32_soft",PCSS64_SOFT:"pcss64_soft"},H={LINEAR:"linear",SRGB:"sRGB",RGBE:"RGBE",RGBM7:"RGBM7",RGBM16:"RGBM16",RGBD:"RGBD",GAMMA:"Gamma"},V={MULTIPLY:"ENVMAP_BLENDING_MULTIPLY",MIX:"ENVMAP_BLENDING_MIX",ADD:"ENVMAP_BLENDING_ADD"},k={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},X={NONE:0,RGB:1,RGBA:2},W={COLOR_ATTACHMENT0:2e3,COLOR_ATTACHMENT1:2001,COLOR_ATTACHMENT2:2002,COLOR_ATTACHMENT3:2003,COLOR_ATTACHMENT4:2004,COLOR_ATTACHMENT5:2005,COLOR_ATTACHMENT6:2006,COLOR_ATTACHMENT7:2007,COLOR_ATTACHMENT8:2008,COLOR_ATTACHMENT9:2009,COLOR_ATTACHMENT10:2010,COLOR_ATTACHMENT11:2011,COLOR_ATTACHMENT12:2012,COLOR_ATTACHMENT13:2013,COLOR_ATTACHMENT14:2014,COLOR_ATTACHMENT15:2015,DEPTH_ATTACHMENT:2020,STENCIL_ATTACHMENT:2021,DEPTH_STENCIL_ATTACHMENT:2030},j={STREAM_DRAW:35040,STREAM_READ:35041,STREAM_COPY:35042,STATIC_DRAW:35044,STATIC_READ:35045,STATIC_COPY:35046,DYNAMIC_DRAW:35048,DYNAMIC_READ:35049,DYNAMIC_COPY:35050},Y={ANY_SAMPLES_PASSED:7e3,ANY_SAMPLES_PASSED_CONSERVATIVE:7001,TIME_ELAPSED:7002},q=function(){function t(){}var e=t.prototype;return e.addEventListener=function(t,e,n){void 0===this._eventMap&&(this._eventMap={});var i=this._eventMap;void 0===i[t]&&(i[t]=[]),i[t].push({listener:e,thisObject:n||this})},e.removeEventListener=function(t,e,n){if(void 0!==this._eventMap){var i=this._eventMap[t];if(void 0!==i)for(var r=0,a=i.length;re&&(this.time=this.time%e),this.time<0&&(this.time=this.time%e+e)},e}(q),Z=function(){function t(t,e,n,i){this.target=null,this.property="",this.parseBinding(t,e),this.valueSize=i;var r,a,o,s=Float64Array;switch(n){case"quaternion":r=J,a=tt,o=rt;break;case"string":case"bool":s=Array,r=K,a=K,o=at;break;default:r=et,a=nt,o=it}this.buffer=new s(4*i),this._mixBufferFunction=r,this._mixBufferFunctionAdditive=a,this._setIdentity=o,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}var e=t.prototype;return e.parseBinding=function(t,e){if((e=e.split(".")).length>1){for(var n=t[e[0]],i=1;i1?this.target[this.property].toArray?this.target[this.property].toArray(t,n):function(t,e,n,i){for(var r=0;r0&&this._mixBufferFunctionAdditive(t,e,3*e,1,e),this.valueSize>1?this.target[this.property].fromArray?this.target[this.property].fromArray(t,e):function(t,e,n,i){for(var r=0;r=.5)for(var a=0;a!==r;++a)t[e+a]=t[n+a]}function J(t,e,n,i){y.slerpFlat(t,e,t,e,t,n,i)}var $=new Float64Array(4);function tt(t,e,n,i){y.multiplyQuaternionsFlat($,0,t,e,t,n),y.slerpFlat(t,e,t,e,$,0,i)}function et(t,e,n,i,r){for(var a=1-i,o=0;o!==r;++o){var s=e+o;t[s]=t[s]*a+t[n+o]*i}}function nt(t,e,n,i,r){for(var a=0;a!==r;++a){var o=e+a;t[o]=t[o]+t[n+a]*i}}function it(t,e,n){for(var i=0;i.")},e.removeAction=function(t){var e=this._actions.indexOf(t);if(-1!==e)if(t.weight>0)console.warn("AnimationMixer.removeAction(): make sure action's weight is zero before removing it.");else{this._actions.splice(e,1);for(var n=clip.tracks,i=0;i.")},e.hasAction=function(t){return this._actions.indexOf(t)>-1},e.getActions=function(){return this._actions},e.update=function(t){for(var e in this._bindings)this._bindings[e].active=!1;for(var n=0,i=this._actions.length;n0){r.update(t);for(var a=r.clip.tracks,o=0,s=a.length;oo&&(o=h),d>s&&(s=d),f>u&&(u=f)}return this.min.set(i,r,a),this.max.set(o,s,u),this},e.isEmpty=function(){return this.max.x>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},e.getHex=function(){return St(255*this.r,0,255)<<16^St(255*this.g,0,255)<<8^St(255*this.b,0,255)<<0},e.setRGB=function(t,e,n){return this.r=t,this.g=e,this.b=n,this},e.setHSL=function(t,e,n){var i;if(t=(t%(i=1)+i)%i,e=Math.max(0,Math.min(1,e)),n=Math.max(0,Math.min(1,n)),0===e)this.r=this.g=this.b=n;else{var r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=Et(a,r,t+1/3),this.g=Et(a,r,t),this.b=Et(a,r,t-1/3)}return this},e.fromArray=function(t,e){return void 0===e&&(e=0),this.r=t[e],this.g=t[e+1],this.b=t[e+2],this},e.toArray=function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t},t}();function Et(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}function St(t,e,n){return Math.max(e,Math.min(n,t))}var Mt=new m,Tt=function(){function t(e,n,i,r){void 0===e&&(e=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=t.DefaultOrder),this._x=e,this._y=n,this._z=i,this._order=r}var e=t.prototype;return e.clone=function(){return new t(this._x,this._y,this._z,this._order)},e.copy=function(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this.onChangeCallback(),this},e.set=function(t,e,n,i){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===i&&(i=this._order),this._x=t,this._y=e,this._z=n,this._order=i,this.onChangeCallback(),this},e.setFromRotationMatrix=function(t,e,n){void 0===e&&(e=this._order),void 0===n&&(n=!0);var i=t.elements,r=i[0],a=i[4],o=i[8],s=i[1],u=i[5],l=i[9],c=i[2],h=i[6],d=i[10];return"XYZ"===e?(this._y=Math.asin(yt(o,-1,1)),Math.abs(o)<.99999?(this._x=Math.atan2(-l,d),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(h,u),this._z=0)):"YXZ"===e?(this._x=Math.asin(-yt(l,-1,1)),Math.abs(l)<.99999?(this._y=Math.atan2(o,d),this._z=Math.atan2(s,u)):(this._y=Math.atan2(-c,r),this._z=0)):"ZXY"===e?(this._x=Math.asin(yt(h,-1,1)),Math.abs(h)<.99999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-a,u)):(this._y=0,this._z=Math.atan2(s,r))):"ZYX"===e?(this._y=Math.asin(-yt(c,-1,1)),Math.abs(c)<.99999?(this._x=Math.atan2(h,d),this._z=Math.atan2(s,r)):(this._x=0,this._z=Math.atan2(-a,u))):"YZX"===e?(this._z=Math.asin(yt(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-l,u),this._y=Math.atan2(-c,r)):(this._x=0,this._y=Math.atan2(o,d))):"XZY"===e?(this._z=Math.asin(-yt(a,-1,1)),Math.abs(a)<.99999?(this._x=Math.atan2(h,u),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-l,d),this._y=0)):console.warn("given unsupported order: "+e),this._order=e,!0===n&&this.onChangeCallback(),this},e.setFromQuaternion=function(t,e,n){return t.toMatrix4(Mt),this.setFromRotationMatrix(Mt,e,n)},e.onChange=function(t){return this.onChangeCallback=t,this},e.onChangeCallback=function(){},n(t,[{key:"x",get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback()}},{key:"y",get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback()}},{key:"z",get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback()}},{key:"order",get:function(){return this._order},set:function(t){this._order=t,this.onChangeCallback()}}]),t}();function yt(t,e,n){return Math.max(e,Math.min(n,t))}Tt.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],Tt.DefaultOrder="XYZ";for(var xt=function(){function t(){this.elements=[1,0,0,0,1,0,0,0,1]}var e=t.prototype;return e.set=function(t,e,n,i,r,a,o,s,u){var l=this.elements;return l[0]=t,l[3]=e,l[6]=n,l[1]=i,l[4]=r,l[7]=a,l[2]=o,l[5]=s,l[8]=u,this},e.identity=function(){return this.set(1,0,0,0,1,0,0,0,1)},e.inverse=function(){return this.getInverse(this)},e.getInverse=function(t){var e=t.elements,n=this.elements,i=e[0],r=e[1],a=e[2],o=e[3],s=e[4],u=e[5],l=e[6],c=e[7],h=e[8],d=h*s-u*c,f=u*l-h*o,p=c*o-s*l,_=i*d+r*f+a*p;if(0===_)return console.warn("Matrix3: .getInverse() can not invert matrix, determinant is 0"),this.identity();var v=1/_;return n[0]=d*v,n[1]=(a*c-h*r)*v,n[2]=(u*r-a*s)*v,n[3]=f*v,n[4]=(h*i-a*l)*v,n[5]=(a*o-u*i)*v,n[6]=p*v,n[7]=(r*l-c*i)*v,n[8]=(s*i-r*o)*v,this},e.transpose=function(){var t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this},e.fromArray=function(t,e){void 0===e&&(e=0);for(var n=0;n<9;n++)this.elements[n]=t[n+e];return this},e.toArray=function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t},e.clone=function(){return(new t).fromArray(this.elements)},e.copy=function(t){var e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this},e.multiply=function(t){return this.multiplyMatrices(this,t)},e.premultiply=function(t){return this.multiplyMatrices(t,this)},e.multiplyMatrices=function(t,e){var n=t.elements,i=e.elements,r=this.elements,a=n[0],o=n[3],s=n[6],u=n[1],l=n[4],c=n[7],h=n[2],d=n[5],f=n[8],p=i[0],_=i[3],v=i[6],m=i[1],g=i[4],E=i[7],S=i[2],M=i[5],T=i[8];return r[0]=a*p+o*m+s*S,r[3]=a*_+o*g+s*M,r[6]=a*v+o*E+s*T,r[1]=u*p+l*m+c*S,r[4]=u*_+l*g+c*M,r[7]=u*v+l*E+c*T,r[2]=h*p+d*m+f*S,r[5]=h*_+d*g+f*M,r[8]=h*v+d*E+f*T,this},e.transform=function(t,e,n,i,r,a,o){var s=this.elements,u=Math.cos(r),l=Math.sin(r);return s[0]=u*n,s[3]=-l*i,s[6]=t,s[1]=l*n,s[4]=u*i,s[7]=e,s[2]=0,s[5]=0,s[8]=1,(a||o)&&(s[6]-=a*s[0]+o*s[3],s[7]-=a*s[1]+o*s[4]),this},e.setUvTransform=function(t,e,n,i,r,a,o){var s=Math.cos(r),u=Math.sin(r);return this.set(n*s,n*u,-n*(s*a+u*o)+a+t,-i*u,i*s,-i*(-u*a+s*o)+o+e,0,0,1)},e.setFromMatrix4=function(t){var e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10])},t}(),wt=new _,At=new xt,bt=function(){function t(t,e){void 0===t&&(t=new _(1,0,0)),void 0===e&&(e=0),this.normal=t,this.constant=e}var e=t.prototype;return e.set=function(t,e){return this.normal.copy(t),this.constant=e,this},e.setComponents=function(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this},e.setFromNormalAndCoplanarPoint=function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},e.normalize=function(){var t=1/this.normal.getLength();return this.normal.multiplyScalar(t),this.constant*=t,this},e.distanceToPoint=function(t){return this.normal.dot(t)+this.constant},e.coplanarPoint=function(t){return void 0===t&&(t=new _),t.copy(this.normal).multiplyScalar(-this.constant)},e.clone=function(){return(new t).copy(this)},e.copy=function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},e.applyMatrix4=function(t,e){var n=e||At.setFromMatrix4(t).inverse().transpose(),i=this.coplanarPoint(wt).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this},t}(),Rt=new _,Nt=function(){function t(t,e,n,i,r,a){void 0===t&&(t=new bt),void 0===e&&(e=new bt),void 0===n&&(n=new bt),void 0===i&&(i=new bt),void 0===r&&(r=new bt),void 0===a&&(a=new bt),this.planes=[t,e,n,i,r,a]}var e=t.prototype;return e.set=function(t,e,n,i,r,a){var o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this},e.setFromMatrix=function(t){var e=this.planes,n=t.elements,i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],u=n[5],l=n[6],c=n[7],h=n[8],d=n[9],f=n[10],p=n[11],_=n[12],v=n[13],m=n[14],g=n[15];return e[0].setComponents(o-i,c-s,p-h,g-_).normalize(),e[1].setComponents(o+i,c+s,p+h,g+_).normalize(),e[2].setComponents(o+r,c+u,p+d,g+v).normalize(),e[3].setComponents(o-r,c-u,p-d,g-v).normalize(),e[4].setComponents(o-a,c-l,p-f,g-m).normalize(),e[5].setComponents(o+a,c+l,p+f,g+m).normalize(),this},e.intersectsSphere=function(t){for(var e=this.planes,n=t.center,i=-t.radius,r=0;r<6;r++){if(e[r].distanceToPoint(n)0?t.max.x:t.min.x,Rt.y=i.normal.y>0?t.max.y:t.min.y,Rt.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(Rt)<0)return!1}return!0},e.clone=function(){return(new this.constructor).copy(this)},e.copy=function(t){for(var e=this.planes,n=0;n<6;n++)e[n].copy(t.planes[n]);return this},t}(),Pt=new _,Lt=new _,Ct=new _,Dt=new _,Ot=new _,Ft=function(){function t(t,e){void 0===t&&(t=new _),void 0===e&&(e=new _(0,0,-1)),this.origin=t,this.direction=e}var e=t.prototype;return e.set=function(t,e){return this.origin.copy(t),this.direction.copy(e),this},e.copy=function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},e.applyMatrix4=function(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this},e.at=function(t,e){return void 0===e&&(e=new _),e.copy(this.direction).multiplyScalar(t).add(this.origin)},e.distanceSqToPoint=function(t){var e=Pt.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Pt.copy(this.direction).multiplyScalar(e).add(this.origin),Pt.distanceToSquared(t))},e.intersectsBox=function(t){return null!==this.intersectBox(t,Pt)},e.intersectBox=function(t,e){var n,i,r,a,o,s,u=1/this.direction.x,l=1/this.direction.y,c=1/this.direction.z,h=this.origin;return u>=0?(n=(t.min.x-h.x)*u,i=(t.max.x-h.x)*u):(n=(t.max.x-h.x)*u,i=(t.min.x-h.x)*u),l>=0?(r=(t.min.y-h.y)*l,a=(t.max.y-h.y)*l):(r=(t.max.y-h.y)*l,a=(t.min.y-h.y)*l),n>a||r>i?null:((r>n||n!=n)&&(n=r),(a=0?(o=(t.min.z-h.z)*c,s=(t.max.z-h.z)*c):(o=(t.max.z-h.z)*c,s=(t.min.z-h.z)*c),n>s||o>i?null:((o>n||n!=n)&&(n=o),(s=0?n:i,e)))},e.intersectsSphere=function(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius},e.intersectSphere=function(t,e){Pt.subVectors(t.center,this.origin);var n=Pt.dot(this.direction),i=Pt.dot(Pt)-n*n,r=t.radius*t.radius;if(i>r)return null;var a=Math.sqrt(r-i),o=n-a,s=n+a;return o<0&&s<0?null:o<0?this.at(s,e):this.at(o,e)},e.intersectTriangle=function(t,e,n,i,r){Ct.subVectors(e,t),Dt.subVectors(n,t),Ot.crossVectors(Ct,Dt);var a,o=this.direction.dot(Ot);if(o>0){if(i)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}Lt.subVectors(this.origin,t);var s=a*this.direction.dot(Dt.crossVectors(Lt,Dt));if(s<0)return null;var u=a*this.direction.dot(Ct.cross(Lt));if(u<0)return null;if(s+u>o)return null;var l=-a*Lt.dot(Ot);return l<0?null:this.at(l/o,r)},t}(),It=new mt,Ut=new _,Bt=function(){function t(t,e){void 0===t&&(t=new _),void 0===e&&(e=-1),this.center=t,this.radius=e}var e=t.prototype;return e.set=function(t,e){return this.center.copy(t),this.radius=e,this},e.setFromArray=function(t,e,n){void 0===e&&(e=3),void 0===n&&(n=0);var i=this.center;It.setFromArray(t,e).getCenter(i);for(var r=0,a=0,o=t.length;athis.radius*this.radius){var n=Math.sqrt(e),i=.5*(n-this.radius);this.center.addScaledVector(Ut,i/n),this.radius+=i}return this},e.clone=function(){return(new t).copy(this)},e.copy=function(t){return this.center.copy(t.center),this.radius=t.radius,this},t}(),Gt=function(){function t(t,e,n){void 0===t&&(t=1),void 0===e&&(e=0),void 0===n&&(n=0),this.radius=t,this.phi=e,this.theta=n}var e=t.prototype;return e.set=function(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this},e.copy=function(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this},e.clone=function(){return(new t).copy(this)},e.makeSafe=function(){var t=1e-6;return this.phi=Math.max(t,Math.min(Math.PI-t,this.phi)),this},e.setFromVector3=function(t){return this.radius=t.getLength(),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t.x,t.z),this.phi=Math.acos(Math.min(1,Math.max(-1,t.y/this.radius)))),this},t}(),zt=new _,Ht=new _,Vt=new _,kt=new _,Xt=function(){function t(t,e,n){void 0===t&&(t=new _),void 0===e&&(e=new _),void 0===n&&(n=new _),this.a=t,this.b=e,this.c=n}return t.normal=function(t,e,n,i){var r=i||new _;r.subVectors(n,e),zt.subVectors(t,e),r.cross(zt);var a=r.getLengthSquared();return a>0?r.multiplyScalar(1/Math.sqrt(a)):r.set(0,0,0)},t.barycoordFromPoint=function(t,e,n,i,r){zt.subVectors(i,e),Ht.subVectors(n,e),Vt.subVectors(t,e);var a=zt.dot(zt),o=zt.dot(Ht),s=zt.dot(Vt),u=Ht.dot(Ht),l=Ht.dot(Vt),c=a*u-o*o,h=r||new _;if(0===c)return h.set(-2,-1,-1);var d=1/c,f=(u*s-o*l)*d,p=(a*l-o*s)*d;return h.set(1-f-p,p,f)},t.containsPoint=function(t,e,n,i){return this.barycoordFromPoint(t,e,n,i,kt),kt.x>=0&&kt.y>=0&&kt.x+kt.y<=1},t.prototype.set=function(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this},t}(),Wt=function(){function t(t,e,n,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===i&&(i=1),this.x=t,this.y=e,this.z=n,this.w=i}var e=t.prototype;return e.lerpVectors=function(t,e,n){return this.subVectors(e,t).multiplyScalar(n).add(t)},e.set=function(t,e,n,i){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===i&&(i=1),this.x=t,this.y=e,this.z=n,this.w=i,this},e.normalize=function(){return this.multiplyScalar(1/(this.getLength()||1))},e.multiplyScalar=function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},e.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},e.getLengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},e.getLength=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.getManhattanLength=function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},e.applyMatrix4=function(t){var e=this.x,n=this.y,i=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*i+a[15]*r,this},e.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},e.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this},e.multiply=function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this},e.subVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},e.fromArray=function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},e.toArray=function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t},e.clone=function(){return new t(this.x,this.y,this.z,this.w)},e.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},t}(),jt=[],Yt=0;Yt<256;Yt++)jt[Yt]=(Yt<16?"0":"")+Yt.toString(16);function qt(){var t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(jt[255&t]+jt[t>>8&255]+jt[t>>16&255]+jt[t>>24&255]+"-"+jt[255&e]+jt[e>>8&255]+"-"+jt[e>>16&15|64]+jt[e>>24&255]+"-"+jt[63&n|128]+jt[n>>8&255]+"-"+jt[n>>16&255]+jt[n>>24&255]+jt[255&i]+jt[i>>8&255]+jt[i>>16&255]+jt[i>>24&255]).toUpperCase()}function Qt(t){return 0==(t&t-1)&&0!==t}function Zt(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))}function Kt(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t}function Jt(t){var e={};for(var n in t){var i=t[n];Array.isArray(i)||ArrayBuffer.isView(i)?e[n]=i.slice():e[n]=i}return e}function $t(t){var e=Array.isArray(t)?[]:{};if(t&&"object"==typeof t)for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]&&"object"==typeof t[n]?$t(t[n]):t[n]);return e}var te=0,ee=new m,ne=function(){function t(){this.id=te++,this.uuid=qt(),this.name="",this.position=new _,this.scale=new _(1,1,1),this.euler=new Tt,this.quaternion=new y;var t=this.euler,e=this.quaternion;t.onChange((function(){e.setFromEuler(t,!1)})),e.onChange((function(){t.setFromQuaternion(e,void 0,!1)})),this.matrix=new m,this.worldMatrix=new m,this.children=new Array,this.parent=null,this.castShadow=!1,this.receiveShadow=!1,this.shadowType=z.PCF3_SOFT,this.frustumCulled=!0,this.visible=!0,this.renderOrder=0,this.renderLayer=0,this.renderable=!0,this.userData={},this.matrixAutoUpdate=!0,this.matrixNeedsUpdate=!0,this.worldMatrixNeedsUpdate=!0}var e=t.prototype;return e.onBeforeRender=function(){},e.onAfterRender=function(){},e.add=function(t){t!==this?(null!==t.parent&&t.parent.remove(t),t.parent=this,this.children.push(t),t.worldMatrixNeedsUpdate=!0):console.error("Object3D.add: object can't be added as a child of itself.",t)},e.remove=function(t){var e=this.children.indexOf(t);-1!==e&&(t.parent=null,this.children.splice(e,1),t.worldMatrixNeedsUpdate=!0)},e.getObjectByName=function(t){return this.getObjectByProperty("name",t)},e.getObjectByProperty=function(t,e){if(this[t]===e)return this;for(var n=0,i=this.children.length;n0){this.directionalShadowMap.length=a,this.directionalShadowDepthMap.length=a,re.length=a,this.directionalShadowMatrix.length!==16*a&&(this.directionalShadowMatrix=new Float32Array(16*a));for(var o=0;o0){this.pointShadowMap.length=s,ae.length=s,this.pointShadowMatrix.length!==16*s&&(this.pointShadowMatrix=new Float32Array(16*s));for(var u=0;u0){this.spotShadowMap.length=l,this.spotShadowDepthMap.length=l,oe.length=l,this.spotShadowMatrix.length!==16*l&&(this.spotShadowMatrix=new Float32Array(16*l));for(var c=0;ct)for(var n=this._cache,i=t;ie&&(e=t[n]);return e}(t)>65535?Uint32Array:Uint16Array)(t);this.index=new an(new on(e,1))}else this.index=t},n.addGroup=function(t,e,n){void 0===n&&(n=0),this.groups.push({start:t,count:e,materialIndex:n})},n.clearGroups=function(){this.groups=[]},n.computeBoundingBox=function(){var t=this.attributes.a_Position||this.attributes.position,e=this.morphAttributes.position;if(this.boundingBox.setFromArray(t.buffer.array,t.buffer.stride,t.offset),e)for(var n=0;na&&(a=l,ln.add(un))}}this.boundingSphere.radius=Math.sqrt(a)}else this.boundingSphere.setFromArray(t.buffer.array,t.buffer.stride,t.offset)},n.dispose=function(){this.dispatchEvent({type:"dispose"})},n.copy=function(t){var e,n,i;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[];var r=new WeakMap,a=t.index;null!==a&&this.setIndex(a.clone(r));var o=t.attributes;for(e in o){var s=o[e];this.addAttribute(e,s.clone(r))}var u=t.morphAttributes;for(e in u){var l=[],c=u[e];for(n=0,i=c.length;n65536?new Uint32Array(v):new Uint16Array(v),1))),a.addAttribute("a_Position",new an(new on(new Float32Array(m),3))),a.addAttribute("a_Normal",new an(new on(new Float32Array(g),3))),a.addAttribute("a_Uv",new an(new on(new Float32Array(E),2))),a.computeBoundingBox(),a.computeBoundingSphere(),a}return i(e,t),e}(fn),_n=0,vn=function(t){function e(){var e;return(e=t.call(this)||this).id=_n++,e.uuid=qt(),e.type=b.SHADER,e.shaderName="",e.defines={},e.uniforms={},e.vertexShader="",e.fragmentShader="",e.precision=null,e.transparent=!1,e.blending=R.NORMAL,e.blendSrc=P.SRC_ALPHA,e.blendDst=P.ONE_MINUS_SRC_ALPHA,e.blendEquation=N.ADD,e.blendSrcAlpha=null,e.blendDstAlpha=null,e.blendEquationAlpha=null,e.premultipliedAlpha=!1,e.vertexColors=X.NONE,e.vertexTangents=!1,e.opacity=1,e.diffuse=new gt(16777215),e.diffuseMap=null,e.diffuseMapCoord=0,e.diffuseMapTransform=new xt,e.alphaMap=null,e.alphaMapCoord=0,e.alphaMapTransform=new xt,e.emissive=new gt(0),e.emissiveMap=null,e.emissiveMapCoord=0,e.emissiveMapTransform=new xt,e.aoMap=null,e.aoMapIntensity=1,e.aoMapCoord=0,e.aoMapTransform=new xt,e.normalMap=null,e.normalScale=new pt(1,1),e.bumpMap=null,e.bumpScale=1,e.envMap=null,e.envMapIntensity=1,e.envMapCombine=V.MULTIPLY,e.depthFunc=B.LEQUAL,e.depthTest=!0,e.depthWrite=!0,e.colorWrite=!0,e.stencilTest=!1,e.stencilWriteMask=255,e.stencilFunc=B.ALWAYS,e.stencilRef=0,e.stencilFuncMask=255,e.stencilFail=G.KEEP,e.stencilZFail=G.KEEP,e.stencilZPass=G.KEEP,e.stencilFuncBack=null,e.stencilRefBack=null,e.stencilFuncMaskBack=null,e.stencilFailBack=null,e.stencilZFailBack=null,e.stencilZPassBack=null,e.clippingPlanes=null,e.alphaTest=0,e.alphaToCoverage=!1,e.side=C.FRONT,e.polygonOffset=!1,e.polygonOffsetFactor=0,e.polygonOffsetUnits=0,e.shading=D.SMOOTH_SHADING,e.dithering=!1,e.acceptLight=!1,e.fog=!0,e.drawMode=k.TRIANGLES,e.needsUpdate=!0,e}i(e,t);var n=e.prototype;return n.copy=function(t){return this.shaderName=t.shaderName,this.defines=Object.assign({},t.defines),this.uniforms=Jt(t.uniforms),this.vertexShader=t.vertexShader,this.fragmentShader=t.fragmentShader,this.precision=t.precision,this.transparent=t.transparent,this.blending=t.blending,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.premultipliedAlpha=t.premultipliedAlpha,this.vertexColors=t.vertexColors,this.vertexTangents=t.vertexTangents,this.opacity=t.opacity,this.diffuse.copy(t.diffuse),this.diffuseMap=t.diffuseMap,this.diffuseMapCoord=t.diffuseMapCoord,this.diffuseMapTransform.copy(t.diffuseMapTransform),this.alphaMap=t.alphaMap,this.alphaMapCoord=t.alphaMapCoord,this.alphaMapTransform.copy(t.alphaMapTransform),this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveMapCoord=t.emissiveMapCoord,this.emissiveMapTransform.copy(t.emissiveMapTransform),this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.aoMapCoord=t.aoMapCoord,this.aoMapTransform.copy(t.aoMapTransform),this.normalMap=t.normalMap,this.normalScale.copy(t.normalScale),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.envMap=t.envMap,this.envMapIntensity=t.envMapIntensity,this.envMapCombine=t.envMapCombine,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.colorWrite=t.colorWrite,this.stencilTest=t.stencilTest,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilFuncBack=t.stencilFuncBack,this.stencilRefBack=t.stencilRefBack,this.stencilFuncMaskBack=t.stencilFuncMaskBack,this.stencilFailBack=t.stencilFailBack,this.stencilZFailBack=t.stencilZFailBack,this.stencilZPassBack=t.stencilZPassBack,this.clippingPlanes=t.clippingPlanes,this.alphaTest=t.alphaTest,this.alphaToCoverage=t.alphaToCoverage,this.side=t.side,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.shading=t.shading,this.dithering=t.dithering,this.acceptLight=t.acceptLight,this.fog=t.fog,this.drawMode=t.drawMode,this},n.clone=function(){return(new this.constructor).copy(this)},n.dispose=function(){this.dispatchEvent({type:"dispose"})},e}(q),mn=function(t){function e(e){var n;return n=t.call(this)||this,e&&(n.shaderName=e.name,Object.assign(n.defines,e.defines),n.uniforms=Jt(e.uniforms),n.vertexShader=e.vertexShader,n.fragmentShader=e.fragmentShader),n}return i(e,t),e}(vn),gn=function(){function t(t){var e=new Re,n=this.camera=new Ne;n.frustumCulled=!1,n.position.set(0,1,0),n.lookAt(new _(0,0,0),new _(0,0,-1)),n.setOrtho(-1,1,-1,1,.1,2),e.add(n);var i=this.geometry=new pn(2,2,1,1),r=this.material=new mn(t);this.uniforms=r.uniforms;var a=new tn(i,r);a.frustumCulled=!1,e.add(a),e.updateMatrix(),this.renderStates=e.updateRenderStates(n);var o=e.updateRenderQueue(n,!1,!1);this.renderQueueLayer=o.layerList[0],this.renderConfig={}}var e=t.prototype;return e.render=function(t){t.renderRenderableList(this.renderQueueLayer.opaque,this.renderStates,this.renderConfig)},e.dispose=function(){this.geometry.dispose(),this.material.dispose()},t}(),En=function(t){function e(){var e;return(e=t.call(this)||this).type=b.DEPTH,e.packToRGBA=!1,e}return i(e,t),e}(vn),Sn=function(t){function e(){var e;return(e=t.call(this)||this).type=b.DISTANCE,e}return i(e,t),e}(vn),Mn=function(){function t(){this.getDepthMaterial=An,this.getDistanceMaterial=bn,this.getGeometry=null,this.shadowLayers=null,this.transparentShadow=!1}return t.prototype.render=function(t,e){var n=this,i=t.renderPass,r=this.getGeometry,a=this.getDepthMaterial,o=this.getDistanceMaterial;Tn.copy(i.getClearColor()),i.setClearColor(1,1,1,1);for(var s=e._lightData.lights,u=e._lightData.shadowsNum,l=function(){var u=s[c],l=u.shadow;if(!1===l.autoUpdate&&!1===l.needsUpdate)return"continue";var h=l.camera,d=l.renderTarget,f=u.isPointLight,p=f?6:1;l.prepareDepthMap(!e.disableShadowSampler,i.capabilities);for(var _=0;_0,r=t.material.clippingPlanes,a=r&&r.length>0?r.length:0,o=i<<0|n<<1,s=xn[o];void 0===s&&(s={},xn[o]=s);var u=s[a];return void 0===u&&((u=new En).packToRGBA=!0,s[a]=u),u.side=yn[t.material.side],u.clippingPlanes=t.material.clippingPlanes,u.drawMode=t.material.drawMode,u}function bn(t,e){var n=!!t.object.skeleton,i=t.geometry.morphAttributes.position&&t.geometry.morphAttributes.position.length>0,r=t.material.clippingPlanes,a=r&&r.length>0?r.length:0,o=i<<0|n<<1,s=wn[o];void 0===s&&(s={},wn[o]=s);var u=s[a];return void 0===u&&(u=new Sn,s[a]=u),u.side=yn[t.material.side],u.uniforms.nearDistance=e.shadow.cameraNear,u.uniforms.farDistance=e.shadow.cameraFar,u.clippingPlanes=t.material.clippingPlanes,u.drawMode=t.material.drawMode,u}var Rn=0,Nn=function(t){function e(){var e;return(e=t.call(this)||this).id=Rn++,e.mipmaps=[],e.border=0,e.format=O.RGBA,e.internalformat=null,e.type=F.UNSIGNED_BYTE,e.magFilter=I.LINEAR,e.minFilter=I.LINEAR_MIPMAP_LINEAR,e.wrapS=U.CLAMP_TO_EDGE,e.wrapT=U.CLAMP_TO_EDGE,e.anisotropy=1,e.compare=void 0,e.generateMipmaps=!0,e.encoding=H.LINEAR,e.flipY=!0,e.premultiplyAlpha=!1,e.unpackAlignment=4,e.version=0,e}i(e,t);var n=e.prototype;return n.clone=function(){return(new this.constructor).copy(this)},n.copy=function(t){return this.mipmaps=t.mipmaps.slice(0),this.border=t.border,this.format=t.format,this.internalformat=t.internalformat,this.type=t.type,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.anisotropy=t.anisotropy,this.compare=t.compare,this.generateMipmaps=t.generateMipmaps,this.encoding=t.encoding,this.flipY=t.flipY,this.premultiplyAlpha=t.premultiplyAlpha,this.unpackAlignment=t.unpackAlignment,this.version=t.version,this},n.dispose=function(){this.dispatchEvent({type:"dispose"}),this.version=0},e}(q);Nn.prototype.isTexture=!0;var Pn=function(t){function e(){var e;return(e=t.call(this)||this).image=null,e}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.image=e.image,this},e}(Nn);Pn.prototype.isTexture2D=!0;var Ln=function(t){function e(){var e;return(e=t.call(this)||this).images=[],e.flipY=!1,e}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.images=e.images.slice(0),this},e}(Nn);Ln.prototype.isTextureCube=!0;var Cn=function(t){function e(){var e;return(e=t.call(this)||this).image={data:new Uint8Array([255,255,255,255,255,255,255,255]),width:2,height:2,depth:2},e.wrapR=U.CLAMP_TO_EDGE,e.format=O.RED,e.type=F.UNSIGNED_BYTE,e.magFilter=I.NEAREST,e.minFilter=I.NEAREST,e.generateMipmaps=!1,e.flipY=!1,e.unpackAlignment=1,e}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.image=e.image,this},e}(Nn);Cn.prototype.isTexture3D=!0;var Dn={u_Model:[1,null],u_Projection:[2,function(t){this.set(t.projectionMatrix.elements)}],u_View:[2,function(t){this.set(t.viewMatrix.elements)}],u_ProjectionView:[2,function(t){this.set(t.projectionViewMatrix.elements)}],u_CameraPosition:[2,function(t){this.setValue(t.position.x,t.position.y,t.position.z)}],logDepthBufFC:[2,function(t){this.set(t.logDepthBufFC)}],logDepthCameraNear:[2,function(t){this.set(t.logDepthCameraNear)}],u_EnvMapLight_Intensity:[3,function(t){this.set(t.environmentLightIntensity)}],u_FogColor:[3,function(t){var e=t.fog.color;this.setValue(e.r,e.g,e.b)}],u_FogDensity:[3,function(t){this.set(t.fog.density)}],u_FogNear:[3,function(t){this.set(t.fog.near)}],u_FogFar:[3,function(t){this.set(t.fog.far)}],u_Color:[4,function(t,e){var n=t.diffuse;this.setValue(n.r,n.g,n.b)}],u_Opacity:[4,function(t,e){this.set(t.opacity)}],diffuseMap:[4,function(t,e){this.set(t.diffuseMap,e)}],alphaMap:[4,function(t,e){this.set(t.alphaMap,e)}],alphaMapUVTransform:[4,function(t,e){this.set(t.alphaMapTransform.elements)}],normalMap:[4,function(t,e){this.set(t.normalMap,e)}],normalScale:[4,function(t,e){this.setValue(t.normalScale.x,t.normalScale.y)}],bumpMap:[4,function(t,e){this.set(t.bumpMap,e)}],bumpScale:[4,function(t,e){this.set(t.bumpScale)}],cubeMap:[4,function(t,e){this.set(t.cubeMap,e)}],u_EnvMap_Intensity:[4,function(t,e){this.set(t.envMapIntensity)}],u_Specular:[4,function(t,e){this.set(t.shininess)}],u_SpecularColor:[4,function(t,e){var n=t.specular;this.setValue(n.r,n.g,n.b)}],specularMap:[4,function(t,e){this.set(t.specularMap,e)}],aoMap:[4,function(t,e){this.set(t.aoMap,e)}],aoMapIntensity:[4,function(t,e){this.set(t.aoMapIntensity)}],aoMapUVTransform:[4,function(t,e){this.set(t.aoMapTransform.elements)}],u_Roughness:[4,function(t,e){this.set(t.roughness)}],roughnessMap:[4,function(t,e){this.set(t.roughnessMap,e)}],u_Metalness:[4,function(t,e){this.set(t.metalness)}],metalnessMap:[4,function(t,e){this.set(t.metalnessMap,e)}],u_Clearcoat:[4,function(t,e){this.set(t.clearcoat)}],u_ClearcoatRoughness:[4,function(t,e){this.set(t.clearcoatRoughness)}],clearcoatMap:[4,function(t,e){this.set(t.clearcoatMap,e)}],clearcoatRoughnessMap:[4,function(t,e){this.set(t.clearcoatRoughnessMap,e)}],clearcoatNormalMap:[4,function(t,e){this.set(t.clearcoatNormalMap,e)}],clearcoatNormalScale:[4,function(t,e){this.setValue(t.clearcoatNormalScale.x,t.clearcoatNormalScale.y)}],glossiness:[4,function(t,e){this.set(t.glossiness)}],glossinessMap:[4,function(t,e){this.set(t.glossinessMap,e)}],emissive:[4,function(t,e){var n=t.emissive;this.setValue(n.r,n.g,n.b)}],emissiveMap:[4,function(t,e){this.set(t.emissiveMap,e)}],emissiveMapUVTransform:[4,function(t,e){this.set(t.emissiveMapTransform.elements)}],matcap:[4,function(t,e){this.set(t.matcap,e)}],uvTransform:[4,function(t,e){this.set(t.diffuseMapTransform.elements)}],u_PointSize:[4,function(t,e){this.set(t.size)}],u_PointScale:[5,null],maxMipLevel:[5,function(t,e){this.set(e.get(t).__maxMipLevel||8)}],envMap:[5,function(t,e){this.set(t,e)}],u_EnvMap_Flip:[5,function(t,e){this.set(t.images[0]&&t.images[0].rtt?1:-1)}]},On=new Pn;On.image={data:new Uint8Array([1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1]),width:2,height:2},On.magFilter=I.NEAREST,On.minFilter=I.NEAREST,On.generateMipmaps=!1,On.version++;var Fn=new Pn;Fn.image={data:null,width:2,height:2},Fn.version++,Fn.type=F.FLOAT_32_UNSIGNED_INT_24_8_REV,Fn.format=O.DEPTH_STENCIL,Fn.magFilter=I.NEAREST,Fn.minFilter=I.NEAREST,Fn.compare=B.LESS,Fn.generateMipmaps=!1,Fn.version++;var In=new Cn,Un=new Ln;function Bn(t,e){if(t.length!==e.length)return!1;for(var n=0,i=t.length;n":" ")+" "+s+": "+n[o])}return i.join("\n")}(t.getShaderSource(e),o)}return r}var ni={alphaTest_frag:"#ifdef ALPHATEST\n\tif ( outColor.a < ALPHATEST ) {\n\t\tdiscard;\n\t} else {\n\t\toutColor.a = u_Opacity;\n\t}\n#endif",aoMap_pars_frag:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n\tvarying vec2 vAOMapUV;\n#endif",aoMap_pars_vert:"#ifdef USE_AOMAP\n\tuniform mat3 aoMapUVTransform;\n\tvarying vec2 vAOMapUV;\n#endif",aoMap_vert:"#ifdef USE_AOMAP\n\t#if (USE_AOMAP == 2)\n\t\t\t\tvAOMapUV = (aoMapUVTransform * vec3(a_Uv2, 1.)).xy;\n\t\t#else\n\t\t\t\tvAOMapUV = (aoMapUVTransform * vec3(a_Uv, 1.)).xy;\n\t\t#endif\n#endif",aoMap_frag:"\n#ifdef USE_AOMAP\n\t\tfloat ambientOcclusion = (texture2D(aoMap, vAOMapUV).r - 1.0) * aoMapIntensity + 1.0;\n\t\t\n\t\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t\t#if defined(USE_ENV_MAP) && defined(USE_PBR)\n\t\t\t\tfloat dotNV = saturate(dot(N, V));\n\t\t\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion(dotNV, ambientOcclusion, GGXRoughnessToBlinnExponent(roughness));\n\t\t#endif\n#endif",begin_frag:"vec4 outColor = vec4(u_Color, u_Opacity);",begin_vert:"vec3 transformed = vec3(a_Position);\nvec3 objectNormal = vec3(a_Normal);\n#ifdef USE_TANGENT\n\t\tvec3 objectTangent = vec3(a_Tangent.xyz);\n#endif",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}\nvec3 BRDF_Diffuse_Lambert(vec3 diffuseColor) {\n\t\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 D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nvec3 BRDF_Specular_BlinnPhong(vec3 specularColor, vec3 N, vec3 L, vec3 V, float shininess) {\n\t\tvec3 H = normalize(L + V);\n\t\tfloat dotNH = saturate(dot(N, H));\n\t\tfloat dotLH = saturate(dot(L, H));\n\t\tvec3 F = F_Schlick(specularColor, dotLH);\n\t\tfloat G = G_BlinnPhong_Implicit( );\n\t\tfloat D = D_BlinnPhong(shininess, dotNH);\n\t\treturn F * G * D;\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}\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}\nvec3 BRDF_Specular_GGX(vec3 specularColor, vec3 N, vec3 L, vec3 V, float roughness) {\n\tfloat alpha = pow2( roughness );\n\tvec3 H = normalize(L + V);\n\tfloat dotNL = saturate( dot(N, L) );\n\tfloat dotNV = saturate( dot(N, V) );\n\tfloat dotNH = saturate( dot(N, H) );\n\tfloat dotLH = saturate( dot(L, H) );\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}\nvec3 BRDF_Specular_GGX_Environment(const in vec3 N, const in vec3 V, const in vec3 specularColor, const in float roughness) {\n\tfloat dotNV = saturate(dot(N, V));\n\tvec2 brdf = integrateSpecularBRDF(dotNV, roughness);\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment(const in vec3 N, const in vec3 V, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter) {\n\tfloat dotNV = saturate(dot(N, V));\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 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}",bumpMap_pars_frag:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd(vec2 uv) {\n\t\tvec2 dSTdx = dFdx( uv );\n\t\tvec2 dSTdy = dFdy( uv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, uv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, uv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, uv + 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",clippingPlanes_frag:"\n#if NUM_CLIPPING_PLANES > 0\n\t\tvec4 plane;\n\t\t#pragma unroll_loop_start\n\t\tfor (int i = 0; i < NUM_CLIPPING_PLANES; i++) {\n\t\t\t\tplane = clippingPlanes[i];\n\t\t\t\tif ( dot( -v_modelPos, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n#endif",clippingPlanes_pars_frag:"#if NUM_CLIPPING_PLANES > 0\n\t\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",color_frag:"#ifdef USE_VCOLOR_RGB\n\t\toutColor.rgb *= v_Color;\n#endif\n#ifdef USE_VCOLOR_RGBA\n\t\toutColor *= v_Color;\n#endif",color_pars_frag:"#ifdef USE_VCOLOR_RGB\n\t\tvarying vec3 v_Color;\n#endif\n#ifdef USE_VCOLOR_RGBA\n\t\tvarying vec4 v_Color;\n#endif",color_pars_vert:"#ifdef USE_VCOLOR_RGB\n\t\tattribute vec3 a_Color;\n\t\tvarying vec3 v_Color;\n#endif\n#ifdef USE_VCOLOR_RGBA\n\t\tattribute vec4 a_Color;\n\t\tvarying vec4 v_Color;\n#endif",color_vert:"#if defined(USE_VCOLOR_RGB) || defined(USE_VCOLOR_RGBA)\n\t\tv_Color = a_Color;\n#endif",common_frag:"uniform mat4 u_View;\nuniform float u_Opacity;\nuniform vec3 u_Color;\nuniform vec3 u_CameraPosition;\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};",common_vert:"attribute vec3 a_Position;\nattribute vec3 a_Normal;\n#ifdef USE_TANGENT\n\tattribute vec4 a_Tangent;\n#endif\n#include \n#include \nuniform mat4 u_Projection;\nuniform mat4 u_View;\nuniform mat4 u_Model;\nuniform mat4 u_ProjectionView;\nuniform vec3 u_CameraPosition;\n#define EPSILON 1e-6\n#ifdef USE_MORPHTARGETS\n\t\tattribute vec3 morphTarget0;\n\t\tattribute vec3 morphTarget1;\n\t\tattribute vec3 morphTarget2;\n\t\tattribute vec3 morphTarget3;\n\t\t#ifdef USE_MORPHNORMALS\n\t\t\tattribute vec3 morphNormal0;\n\t\t\tattribute vec3 morphNormal1;\n\t\t\tattribute vec3 morphNormal2;\n\t\t\tattribute vec3 morphNormal3;\n\t\t#else\n\t\t\tattribute vec3 morphTarget4;\n\t\t\tattribute vec3 morphTarget5;\n\t\t\tattribute vec3 morphTarget6;\n\t\t\tattribute vec3 morphTarget7;\n\t\t#endif\n#endif\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}",diffuseMap_frag:"#ifdef USE_DIFFUSE_MAP\n\t\t#if (USE_DIFFUSE_MAP == 2)\n\t\t\t\tvec4 texelColor = texture2D(diffuseMap, v_Uv2);\n\t\t#else \n\t\t\t\tvec4 texelColor = texture2D(diffuseMap, v_Uv);\n\t\t#endif\n\t\t\n\t\ttexelColor = mapTexelToLinear(texelColor);\n\t\toutColor *= texelColor;\n#endif",diffuseMap_pars_frag:"#ifdef USE_DIFFUSE_MAP\n\t\tuniform sampler2D diffuseMap;\n#endif",emissiveMap_frag:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D(emissiveMap, vEmissiveMapUV);\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissiveMap_pars_frag:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n\tvarying vec2 vEmissiveMapUV;\n#endif",emissiveMap_vert:"#ifdef USE_EMISSIVEMAP\n\t#if (USE_EMISSIVEMAP == 2)\n\t\t\t\tvEmissiveMapUV = (emissiveMapUVTransform * vec3(a_Uv2, 1.)).xy;\n\t\t#else\n\t\t\t\tvEmissiveMapUV = (emissiveMapUVTransform * vec3(a_Uv, 1.)).xy;\n\t\t#endif\n#endif",emissiveMap_pars_vert:"#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapUVTransform;\n\tvarying vec2 vEmissiveMapUV;\n#endif",encodings_frag:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_frag:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\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.w );\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.w );\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.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M\t\t\t= clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM\t\t\t\t\t\t= 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.x, max( value.g, value.b ) );\n\tfloat D\t\t\t= max( maxRange / maxRGB, 1.0 );\n\tD\t\t\t\t\t\t= 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 )\t{\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\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 = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}",end_frag:"gl_FragColor = outColor;",envMap_frag:"#ifdef USE_ENV_MAP\n\t\tvec3 envDir;\n\t\t#ifdef USE_VERTEX_ENVDIR\n\t\t\t\tenvDir = v_EnvDir;\n\t\t#else\n\t\t\t\tenvDir = reflect(normalize(v_modelPos - u_CameraPosition), N);\n\t\t#endif\n\t\tvec4 envColor = textureCube(envMap, vec3(u_EnvMap_Flip * envDir.x, envDir.yz));\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutColor = mix(outColor, envColor * outColor, u_EnvMap_Intensity);\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutColor = mix(outColor, envColor, u_EnvMap_Intensity);\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutColor += envColor * u_EnvMap_Intensity;\n\t#endif\n#endif",envMap_pars_frag:"#ifdef USE_ENV_MAP\n\t\t#ifdef USE_VERTEX_ENVDIR\n\t\t\t\tvarying vec3 v_EnvDir;\n\t\t#endif\n\t\tuniform samplerCube envMap;\n\t\tuniform float u_EnvMap_Flip;\n\t\tuniform float u_EnvMap_Intensity;\n\t\tuniform float u_EnvMapLight_Intensity;\n\t\tuniform int maxMipLevel;\n#endif",envMap_pars_vert:"#ifdef USE_ENV_MAP\n\t\t#ifdef USE_VERTEX_ENVDIR\n\t\t\t\tvarying vec3 v_EnvDir;\n\t\t#endif\n#endif",envMap_vert:"\n#ifdef USE_ENV_MAP\n\t\t#ifdef USE_VERTEX_ENVDIR\n\t\t\t\tvec3 transformedNormal = (transposeMat4(inverseMat4(u_Model)) * vec4(objectNormal, 0.0)).xyz;\n\t\t\t\ttransformedNormal = normalize(transformedNormal);\n\t\t\t\tv_EnvDir = reflect(normalize(worldPosition.xyz - u_CameraPosition), transformedNormal);\n\t\t#endif\n#endif",fog_frag:"#ifdef USE_FOG\n\t\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\t\t#ifdef USE_EXP2_FOG\n\t\t\t\tfloat fogFactor = 1.0 - exp(-u_FogDensity * u_FogDensity * depth * depth);\n\t\t#else\n\t\t\t\tfloat fogFactor = smoothstep(u_FogNear, u_FogFar, depth);\n\t\t#endif\n\t\tgl_FragColor.rgb = mix(gl_FragColor.rgb, u_FogColor, fogFactor);\n#endif",fog_pars_frag:"#ifdef USE_FOG\n\t\tuniform vec3 u_FogColor;\n\t\t#ifdef USE_EXP2_FOG\n\t\t\t\tuniform float u_FogDensity;\n\t\t#else\n\t\t\t\tuniform float u_FogNear;\n\t\t\t\tuniform float u_FogFar;\n\t\t#endif\n#endif",inverse:"mat4 inverseMat4(mat4 m) {\n\t\tfloat\n\t\ta00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n\t\ta10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n\t\ta20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n\t\ta30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\t\tb00 = a00 * a11 - a01 * a10,\n\t\tb01 = a00 * a12 - a02 * a10,\n\t\tb02 = a00 * a13 - a03 * a10,\n\t\tb03 = a01 * a12 - a02 * a11,\n\t\tb04 = a01 * a13 - a03 * a11,\n\t\tb05 = a02 * a13 - a03 * a12,\n\t\tb06 = a20 * a31 - a21 * a30,\n\t\tb07 = a20 * a32 - a22 * a30,\n\t\tb08 = a20 * a33 - a23 * a30,\n\t\tb09 = a21 * a32 - a22 * a31,\n\t\tb10 = a21 * a33 - a23 * a31,\n\t\tb11 = a22 * a33 - a23 * a32,\n\t\tdet = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\t\treturn mat4(\n\t\t\t\ta11 * b11 - a12 * b10 + a13 * b09,\n\t\t\t\ta02 * b10 - a01 * b11 - a03 * b09,\n\t\t\t\ta31 * b05 - a32 * b04 + a33 * b03,\n\t\t\t\ta22 * b04 - a21 * b05 - a23 * b03,\n\t\t\t\ta12 * b08 - a10 * b11 - a13 * b07,\n\t\t\t\ta00 * b11 - a02 * b08 + a03 * b07,\n\t\t\t\ta32 * b02 - a30 * b05 - a33 * b01,\n\t\t\t\ta20 * b05 - a22 * b02 + a23 * b01,\n\t\t\t\ta10 * b10 - a11 * b08 + a13 * b06,\n\t\t\t\ta01 * b08 - a00 * b10 - a03 * b06,\n\t\t\t\ta30 * b04 - a31 * b02 + a33 * b00,\n\t\t\t\ta21 * b02 - a20 * b04 - a23 * b00,\n\t\t\t\ta11 * b07 - a10 * b09 - a12 * b06,\n\t\t\t\ta00 * b09 - a01 * b07 + a02 * b06,\n\t\t\t\ta31 * b01 - a30 * b03 - a32 * b00,\n\t\t\t\ta20 * b03 - a21 * b01 + a22 * b00) / det;\n}",light_frag:"\n#if (defined(USE_PHONG) || defined(USE_PBR))\n\t\tvec3 V = normalize(u_CameraPosition - v_modelPos);\n#endif\n#ifdef USE_PBR\n\t\t#ifdef USE_PBR2\n\t\t\t\tvec3 diffuseColor = outColor.xyz;\n\t\t\t\tvec3 specularColor = specularFactor.xyz;\n\t\t\t\tfloat roughness = max(1.0 - glossinessFactor, 0.0525);\n\t\t#else\n\t\t\t\tvec3 diffuseColor = outColor.xyz * (1.0 - metalnessFactor);\n\t\t\t\tvec3 specularColor = mix(vec3(0.04), outColor.xyz, metalnessFactor);\n\t\t\t\tfloat roughness = max(roughnessFactor, 0.0525);\n\t\t#endif\n\t\tvec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\n\t\tfloat geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);\n\t\troughness += geometryRoughness;\n\t\troughness = min(roughness, 1.0);\n\t\t#ifdef USE_CLEARCOAT\n\t\t\t\tfloat clearcoat = u_Clearcoat;\n\t\t\t\tfloat clearcoatRoughness = u_ClearcoatRoughness;\n\t\t\t\t#ifdef USE_CLEARCOATMAP\n\t\t\t\tclearcoat *= texture2D(clearcoatMap, v_Uv).x;\n\t\t\t\t#endif\n\t\t\t\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\t\t\tclearcoatRoughness *= texture2D(clearcoatRoughnessMap, v_Uv).y;\n\t\t\t#endif\n\t\t\t\tclearcoat = saturate(clearcoat);\n\t\t\t\tclearcoatRoughness = max(clearcoatRoughness, 0.0525);\n\t\t\tclearcoatRoughness += geometryRoughness;\n\t\t\tclearcoatRoughness = min(clearcoatRoughness, 1.0);\n\t\t#endif\n#else\n\t\tvec3 diffuseColor = outColor.xyz;\n\t\t#ifdef USE_PHONG\n\t\t\t\tvec3 specularColor = u_SpecularColor.xyz;\n\t\t\t\tfloat shininess = u_Specular;\n\t\t#endif\n#endif\n#ifdef USE_LIGHT\n\t\tvec3 L;\n\t\tfloat falloff;\n\t\tfloat dotNL;\n\t\tvec3 irradiance;\n\t\tfloat clearcoatDHR;\n\t\t#ifdef USE_CLEARCOAT\n\t\t\t\tfloat ccDotNL;\n\t\t\t\tvec3 ccIrradiance;\n\t\t#endif\n\t\t#if NUM_DIR_LIGHTS > 0\n\t\t\t\t#pragma unroll_loop_start\n\t\t\t\tfor (int i = 0; i < NUM_DIR_LIGHTS; i++) {\n\t\t\t\t\t\tL = normalize(-u_Directional[i].direction);\n\t\t\t\t\t\tfalloff = 1.0;\n\t\t\t\t\t\t#if defined(USE_SHADOW) && (UNROLLED_LOOP_INDEX < NUM_DIR_SHADOWS)\n\t\t\t\t\t\t\t\t#ifdef USE_PCSS_SOFT_SHADOW\n\t\t\t\t\t\t\t\t\t\tfalloff *= getShadowWithPCSS(directionalDepthMap[i], directionalShadowMap[i], vDirectionalShadowCoord[i], u_DirectionalShadow[i].shadowMapSize, u_DirectionalShadow[i].shadowBias, u_DirectionalShadow[i].shadowParams);\n\t\t\t\t\t\t\t\t#else\n\t\t\t\t\t\t\t\t\t\tfalloff *= getShadow(directionalShadowMap[i], vDirectionalShadowCoord[i], u_DirectionalShadow[i].shadowMapSize, u_DirectionalShadow[i].shadowBias, u_DirectionalShadow[i].shadowParams);\n\t\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\tdotNL = saturate(dot(N, L));\n\t\t\t\t\t\tirradiance = u_Directional[i].color * falloff * dotNL * PI;\n\t\t\t\t\t\t#ifdef USE_CLEARCOAT\t\t\t\t\n\t\t\t\t\t\t\t\tccDotNL = saturate(dot(clearcoatNormal, L));\n\t\t\t\t\t\t\t\tccIrradiance = ccDotNL * u_Directional[i].color * falloff\t* PI;\n\t\t\t\t\t\t\t\tclearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n\t\t\t\t\t\t\t\treflectedLight.directSpecular += ccIrradiance * clearcoat * BRDF_Specular_GGX(specularColor, clearcoatNormal, L, V, clearcoatRoughness);\n\t\t\t\t\t\t#else\n\t\t\t\t\t\tclearcoatDHR = 0.0;\n\t\t\t\t\t#endif\n\t\t\t\t\t\treflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance * BRDF_Diffuse_Lambert(diffuseColor);\n\t\t\t\t\t\t#ifdef USE_PHONG\n\t\t\t\t\t\t\t\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#ifdef USE_PBR\n\t\t\t\t\t\t\t\treflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness);\n\t\t\t\t\t\t#endif\n\t\t\t\t}\n\t\t\t\t#pragma unroll_loop_end\n\t\t#endif\n\t\t#if NUM_POINT_LIGHTS > 0\n\t\t\t\tvec3 worldV;\n\t\t\t\t#pragma unroll_loop_start\n\t\t\t\tfor (int i = 0; i < NUM_POINT_LIGHTS; i++) {\n\t\t\t\t\t\tworldV = v_modelPos - u_Point[i].position;\n\t\t\t\t\t\tL = -worldV;\n\t\t\t\t\t\tfalloff = pow(clamp(1. - length(L) / u_Point[i].distance, 0.0, 1.0), u_Point[i].decay);\n\t\t\t\t\t\tL = normalize(L);\n\t\t\t\t\t\t#if defined(USE_SHADOW) && (UNROLLED_LOOP_INDEX < NUM_POINT_SHADOWS)\n\t\t\t\t\t\t\t\tfalloff *= getPointShadow(pointShadowMap[i], vPointShadowCoord[i], u_PointShadow[i].shadowMapSize, u_PointShadow[i].shadowBias, u_PointShadow[i].shadowParams, u_PointShadow[i].shadowCameraRange);\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\tdotNL = saturate(dot(N, L));\n\t\t\t\t\t\tirradiance = u_Point[i].color * falloff * dotNL * PI;\n\t\t\t\t\t\t#ifdef USE_CLEARCOAT\t\t\t\t\n\t\t\t\t\t\t\t\tccDotNL = saturate(dot(clearcoatNormal, L));\n\t\t\t\t\t\t\t\tccIrradiance = ccDotNL *\tu_Point[i].color * falloff\t* PI;\n\t\t\t\t\t\t\t\tclearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n\t\t\t\t\t\t\t\treflectedLight.directSpecular += ccIrradiance * clearcoat * BRDF_Specular_GGX(specularColor, clearcoatNormal, L, V, clearcoatRoughness);\n\t\t\t\t\t\t#else\n\t\t\t\t\t\tclearcoatDHR = 0.0;\n\t\t\t\t\t#endif\n\t\t\t\t\t\treflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance * BRDF_Diffuse_Lambert(diffuseColor);\n\t\t\t\t\t\t#ifdef USE_PHONG\n\t\t\t\t\t\t\t\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#ifdef USE_PBR\n\t\t\t\t\t\t\t\treflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness);\n\t\t\t\t\t\t#endif\n\t\t\t\t}\n\t\t\t\t#pragma unroll_loop_end\n\t\t#endif\n\t\t#if NUM_SPOT_LIGHTS > 0\n\t\t\t\tfloat lightDistance;\n\t\t\t\tfloat angleCos;\n\t\t\t\t#pragma unroll_loop_start\n\t\t\t\tfor (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\n\t\t\t\t\t\tL = u_Spot[i].position - v_modelPos;\n\t\t\t\t\t\tlightDistance = length(L);\n\t\t\t\t\t\tL = normalize(L);\n\t\t\t\t\t\tangleCos = dot(L, -normalize(u_Spot[i].direction));\n\t\t\t\t\t\tfalloff = smoothstep(u_Spot[i].coneCos, u_Spot[i].penumbraCos, angleCos);\n\t\t\t\t\t\tfalloff *= pow(clamp(1. - lightDistance / u_Spot[i].distance, 0.0, 1.0), u_Spot[i].decay);\n\t\t\t\t\t\t#if defined(USE_SHADOW) && (UNROLLED_LOOP_INDEX < NUM_SPOT_SHADOWS)\n\t\t\t\t\t\t\t\t#ifdef USE_PCSS_SOFT_SHADOW\n\t\t\t\t\t\t\t\t\t\tfalloff *= getShadowWithPCSS(spotDepthMap[i], spotShadowMap[i], vSpotShadowCoord[i], u_SpotShadow[i].shadowMapSize, u_SpotShadow[i].shadowBias, u_SpotShadow[i].shadowParams);\n\t\t\t\t\t\t\t\t#else\n\t\t\t\t\t\t\t\t\t\tfalloff *= getShadow(spotShadowMap[i], vSpotShadowCoord[i], u_SpotShadow[i].shadowMapSize, u_SpotShadow[i].shadowBias, u_SpotShadow[i].shadowParams);\n\t\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\tdotNL = saturate(dot(N, L));\n\t\t\t\t\t\tirradiance = u_Spot[i].color * falloff * dotNL * PI;\n\t\t\t\t\t\t#ifdef USE_CLEARCOAT\t\t\t\t\n\t\t\t\t\t\t\t\tccDotNL = saturate(dot(clearcoatNormal, L));\n\t\t\t\t\t\t\t\tccIrradiance = ccDotNL *\tu_Spot[i].color * falloff\t* PI;\n\t\t\t\t\t\t\t\tclearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n\t\t\t\t\t\t\t\treflectedLight.directSpecular += ccIrradiance * clearcoat * BRDF_Specular_GGX(specularColor, clearcoatNormal, L, V, clearcoatRoughness);\n\t\t\t\t\t\t#else\n\t\t\t\t\t\tclearcoatDHR = 0.0;\n\t\t\t\t\t#endif\n\t\t\t\t\t\treflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance * BRDF_Diffuse_Lambert(diffuseColor);\n\t\t\t\t\t\t#ifdef USE_PHONG\n\t\t\t\t\t\t\t\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#ifdef USE_PBR\n\t\t\t\t\t\t\t\treflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness);\n\t\t\t\t\t\t#endif\n\t\t\t\t}\n\t\t\t\t#pragma unroll_loop_end\n\t\t#endif\n\t\tvec3 iblIrradiance = vec3(0., 0., 0.);\n\t\tvec3 indirectIrradiance = vec3(0., 0., 0.);\n\t\tvec3 indirectRadiance = vec3(0., 0., 0.);\n\t\tvec3 clearcoatRadiance = vec3(0., 0., 0.);\n\t\t#ifdef USE_AMBIENT_LIGHT\n\t\t\t\tindirectIrradiance += u_AmbientLightColor * PI;\n\t\t#endif\n\t\t#if NUM_HEMI_LIGHTS > 0\n\t\t\t\tfloat hemiDiffuseWeight;\n\t\t\t\t#pragma unroll_loop_start\n\t\t\t\tfor (int i = 0; i < NUM_HEMI_LIGHTS; i++) {\n\t\t\t\t\t\tL = normalize(u_Hemi[i].direction);\n\t\t\t\t\t\tdotNL = dot(N, L);\n\t\t\t\t\t\themiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\t\t\t\t\tindirectIrradiance += mix(u_Hemi[i].groundColor, u_Hemi[i].skyColor, hemiDiffuseWeight) * PI;\n\t\t\t\t}\n\t\t\t\t#pragma unroll_loop_end\n\t\t#endif\n\t\t#if defined(USE_ENV_MAP) && defined(USE_PBR)\n\t\t\t\tvec3 envDir;\n\t\t\t\t#ifdef USE_VERTEX_ENVDIR\n\t\t\t\t\t\tenvDir = v_EnvDir;\n\t\t\t\t#else\n\t\t\t\t\t\tenvDir = reflect(normalize(v_modelPos - u_CameraPosition), N);\n\t\t\t\t#endif\n\t\t\t\tiblIrradiance += getLightProbeIndirectIrradiance(maxMipLevel, N);\n\t\t\t\tindirectRadiance += getLightProbeIndirectRadiance(GGXRoughnessToBlinnExponent(roughness), maxMipLevel, envDir);\n\t\t\t\t#ifdef USE_CLEARCOAT\n\t\t\t\t\t\tvec3 clearcoatDir = reflect(normalize(v_modelPos - u_CameraPosition), clearcoatNormal);\n\t\t\t\tclearcoatRadiance += getLightProbeIndirectRadiance(GGXRoughnessToBlinnExponent(clearcoatRoughness), maxMipLevel, clearcoatDir);\n\t\t\t#endif\n\t\t#endif\n\t\treflectedLight.indirectDiffuse += indirectIrradiance * BRDF_Diffuse_Lambert(diffuseColor);\n\t\t#if defined(USE_ENV_MAP) && defined(USE_PBR)\n\t\t\t\t#ifdef USE_CLEARCOAT\n\t\t\t\t\t\tfloat ccDotNV = saturate(dot(clearcoatNormal, V));\n\t\t\t\t\t\treflectedLight.indirectSpecular += clearcoatRadiance * clearcoat * BRDF_Specular_GGX_Environment(clearcoatNormal, V, specularColor, clearcoatRoughness);\n\t\t\t\t\t\tccDotNL = ccDotNV;\n\t\t\t\t\t\tclearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n\t\t\t\t#else\n\t\t\t\t\t\tclearcoatDHR = 0.0;\n\t\t\t\t#endif\n\t\t\t\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\t\t\t\tvec3 singleScattering = vec3(0.0);\n\t\t\tvec3 multiScattering = vec3(0.0);\n\t\t\t\tvec3 cosineWeightedIrradiance = iblIrradiance * RECIPROCAL_PI;\n\t\t\t\tBRDF_Specular_Multiscattering_Environment(N, V, specularColor, roughness, singleScattering, multiScattering);\n\t\t\t\tvec3 diffuse = diffuseColor * (1.0 - (singleScattering + multiScattering));\n\t\t\t\treflectedLight.indirectSpecular += clearcoatInv * indirectRadiance * singleScattering;\n\t\t\t\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\t\t\t\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n\t\t#endif\n#endif",light_pars_frag:"#ifdef USE_AMBIENT_LIGHT\n\t\tuniform vec3 u_AmbientLightColor;\n#endif\n#ifdef USE_CLEARCOAT\n\t\tfloat clearcoatDHRApprox(const in float roughness, const in float dotNL) {\n\t\t\t\treturn 0.04 + (1.0 - 0.16) * (pow(1.0 - dotNL, 5.0) * pow(1.0 - roughness, 2.0));\n\t\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t\tstruct HemisphereLight {\n\t\t\t\tvec3 direction;\n\t\t\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t\t};\n\t\tuniform HemisphereLight u_Hemi[NUM_HEMI_LIGHTS];\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t\tstruct DirectLight {\n\t\t\t\tvec3 direction;\n\t\t\t\tvec3 color;\n\t\t};\n\t\tuniform DirectLight u_Directional[NUM_DIR_LIGHTS];\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t\tstruct PointLight {\n\t\t\t\tvec3 position;\n\t\t\t\tvec3 color;\n\t\t\t\tfloat distance;\n\t\t\t\tfloat decay;\n\t\t};\n\t\tuniform PointLight u_Point[NUM_POINT_LIGHTS];\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t\tstruct SpotLight {\n\t\t\t\tvec3 position;\n\t\t\t\tvec3 color;\n\t\t\t\tfloat distance;\n\t\t\t\tfloat decay;\n\t\t\t\tfloat coneCos;\n\t\t\t\tfloat penumbraCos;\n\t\t\t\tvec3 direction;\n\t\t};\n\t\tuniform SpotLight u_Spot[NUM_SPOT_LIGHTS];\n#endif\n#if defined(USE_PBR) && defined(USE_ENV_MAP)\n\t\tvec3 getLightProbeIndirectIrradiance(const in int maxMIPLevel, const in vec3 N) {\n\t\t\t\tvec3 coordVec = vec3(u_EnvMap_Flip * N.x, N.yz);\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT(envMap, coordVec, float(maxMIPLevel));\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube(envMap, coordVec, float(maxMIPLevel));\n\t\t\t#endif\n\t\t\t\tenvMapColor = envMapTexelToLinear(envMapColor);\n\t\t\t\treturn PI * envMapColor.rgb * u_EnvMap_Intensity * u_EnvMapLight_Intensity;\n\t\t}\n\t\tfloat getSpecularMIPLevel(const in float blinnShininessExponent, const in int maxMIPLevel) {\n\t\t\tfloat maxMIPLevelScalar = float(maxMIPLevel);\n\t\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2(pow2(blinnShininessExponent) + 1.0);\n\t\t\treturn clamp(desiredMIPLevel, 0.0, maxMIPLevelScalar);\n\t\t}\n\t\tvec3 getLightProbeIndirectRadiance(const in float blinnShininessExponent, const in int maxMIPLevel, const in vec3 envDir) {\n\t\t\t\tfloat specularMIPLevel = getSpecularMIPLevel(blinnShininessExponent, maxMIPLevel);\n\t\t\t\tvec3 coordVec = vec3(u_EnvMap_Flip * envDir.x, envDir.yz);\n\t\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT(envMap, coordVec, specularMIPLevel);\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube(envMap, coordVec, specularMIPLevel);\n\t\t\t#endif\n\t\t\t\tenvMapColor = envMapTexelToLinear(envMapColor);\n\t\t\t\treturn envMapColor.rgb * u_EnvMap_Intensity;\n\t\t}\n\t\tfloat computeSpecularOcclusion(const in float dotNV, const in float ambientOcclusion, const in float roughness) {\n\t\t\treturn saturate(pow(dotNV + ambientOcclusion, exp2(-16.0 * roughness - 1.0)) - 1.0 + ambientOcclusion);\n\t\t}\n#endif",alphamap_pars_frag:"#ifdef USE_ALPHA_MAP\n\tuniform sampler2D alphaMap;\n\tvarying vec2 vAlphaMapUV;\n#endif",alphamap_frag:"#ifdef USE_ALPHA_MAP\n\toutColor.a *= texture2D(alphaMap, vAlphaMapUV).g;\n#endif",alphamap_pars_vert:"#ifdef USE_ALPHA_MAP\n\t\tuniform mat3 alphaMapUVTransform;\n\tvarying vec2 vAlphaMapUV;\n#endif",alphamap_vert:"#ifdef USE_ALPHA_MAP\n\t#if (USE_ALPHA_MAP == 2)\n\t\t\t\tvAlphaMapUV = (alphaMapUVTransform * vec3(a_Uv2, 1.)).xy;\n\t\t#else\n\t\t\t\tvAlphaMapUV = (alphaMapUVTransform * vec3(a_Uv, 1.)).xy;\n\t\t#endif\n#endif",normalMap_pars_frag:"#ifdef USE_NORMAL_MAP\n\t\tuniform sampler2D normalMap;\n\t\tuniform vec2 normalScale;\n#endif\n#if defined(USE_NORMAL_MAP) || defined(USE_CLEARCOAT_NORMALMAP)\n\t\t#if defined(USE_TANGENT) && !defined(FLAT_SHADED)\n\t\t\t\t#define USE_TBN\n\t\t#else\n\t\t\t\t#include \n\t\t#endif\n#endif",normal_frag:"\n#ifdef FLAT_SHADED\n\t\tvec3 fdx = dFdx(v_modelPos);\n\t\tvec3 fdy = dFdy(v_modelPos);\n\t\tvec3 N = normalize(cross(fdx, fdy));\n#else\n\t\tvec3 N = normalize(v_Normal);\n\t\t#ifdef DOUBLE_SIDED\n\t\t\t\tN = N * (float(gl_FrontFacing) * 2.0 - 1.0);\n\t\t#endif\n#endif\n#ifdef USE_TBN\n\tvec3 tangent = normalize(v_Tangent);\n\tvec3 bitangent = normalize(v_Bitangent);\n\t#ifdef DOUBLE_SIDED\n\t\ttangent = tangent * (float(gl_FrontFacing) * 2.0 - 1.0);\n\t\tbitangent = bitangent * (float(gl_FrontFacing) * 2.0 - 1.0);\n\t#endif\n\tmat3 tspace = mat3(tangent, bitangent, N);\n#endif\nvec3 geometryNormal = N;\n#ifdef USE_NORMAL_MAP\n\t\tvec3 mapN = texture2D(normalMap, v_Uv).rgb * 2.0 - 1.0;\n\t\tmapN.xy *= normalScale;\n\t\t#ifdef USE_TBN\n\t\t\t\tN = normalize(tspace * mapN);\n\t\t#else\n\t\t\t\tmapN.xy *= (float(gl_FrontFacing) * 2.0 - 1.0);\n\t\t\t\tN = normalize(tsn(N, v_modelPos, v_Uv) * mapN);\n\t\t#endif\n#elif defined(USE_BUMPMAP)\n\t\tN = perturbNormalArb(v_modelPos, N, dHdxy_fwd(v_Uv));\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D(clearcoatNormalMap, v_Uv).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TBN\n\t\tclearcoatNormal = normalize(tspace * clearcoatMapN);\n\t#else\n\t\tclearcoatMapN.xy *= (float(gl_FrontFacing) * 2.0 - 1.0);\n\t\tclearcoatNormal = normalize(tsn(clearcoatNormal, v_modelPos, v_Uv) * clearcoatMapN);\n\t#endif\n#endif",normal_pars_frag:"#ifndef FLAT_SHADED\n\t\tvarying vec3 v_Normal;\n\t\t#ifdef USE_TANGENT\n\t\t\t\tvarying vec3 v_Tangent;\n\t\tvarying vec3 v_Bitangent;\n\t\t#endif\n#endif",normal_pars_vert:"#ifndef FLAT_SHADED\n\t\tvarying vec3 v_Normal;\n\t\t#ifdef USE_TANGENT\n\t\t\t\tvarying vec3 v_Tangent;\n\t\tvarying vec3 v_Bitangent;\n\t\t#endif\n#endif",normal_vert:"#ifndef FLAT_SHADED\n\t\tv_Normal = (transposeMat4(inverseMat4(u_Model)) * vec4(objectNormal, 0.0)).xyz;\n\t\t#ifdef FLIP_SIDED\n\t\t\tv_Normal = - v_Normal;\n\t\t#endif\n\t\t#ifdef USE_TANGENT\n\t\t\t\tv_Tangent = (transposeMat4(inverseMat4(u_Model)) * vec4(objectTangent, 0.0)).xyz;\n\t\t\t\t#ifdef FLIP_SIDED\n\t\t\t\t\t\tv_Tangent = - v_Tangent;\n\t\t\t\t#endif\n\t\t\t\tv_Bitangent = normalize(cross(v_Normal, v_Tangent) * a_Tangent.w);\n\t\t#endif\n#endif",packing:"const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256.,\t256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\t\tvec4 r = vec4( fract( v * PackFactors ), v );\n\t\tr.yzw -= r.xyz * ShiftRight8;\t\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\t\treturn dot( v, UnpackFactors );\n}",premultipliedAlpha_frag:"#ifdef USE_PREMULTIPLIED_ALPHA\n\t\tgl_FragColor.rgb = gl_FragColor.rgb * gl_FragColor.a;\n#endif",pvm_vert:"vec4 worldPosition = u_Model * vec4(transformed, 1.0);\ngl_Position = u_ProjectionView * worldPosition;",dithering_frag:"#if defined( DITHERING )\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_frag:"#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",shadow:"#ifdef USE_SHADOW_SAMPLER\n\t\tfloat computeShadow(sampler2DShadow shadowMap, vec3 shadowCoord) {\n\t\t\t\treturn texture2D( shadowMap, shadowCoord );\n\t\t}\n#else\n\t\tfloat computeShadow(sampler2D shadowMap, vec3 shadowCoord) {\n\t\t\t\treturn step(shadowCoord.z, unpackRGBAToDepth(texture2D(shadowMap, shadowCoord.xy)));\n\t\t}\n#endif\nfloat computeShadowWithPoissonSampling(sampler2DShadow shadowMap, vec3 shadowCoord, float texelSize) {\n\t\tvec3 poissonDisk[4];\n\t\tpoissonDisk[0] = vec3(-0.94201624, -0.39906216, 0);\n\t\tpoissonDisk[1] = vec3(0.94558609, -0.76890725, 0);\n\t\tpoissonDisk[2] = vec3(-0.094184101, -0.92938870, 0);\n\t\tpoissonDisk[3] = vec3(0.34495938, 0.29387760, 0);\n\t\treturn computeShadow(shadowMap, shadowCoord + poissonDisk[0] * texelSize) * 0.25 +\n\t\t\t\tcomputeShadow(shadowMap, shadowCoord + poissonDisk[1] * texelSize) * 0.25 +\n\t\t\t\tcomputeShadow(shadowMap, shadowCoord + poissonDisk[2] * texelSize) * 0.25 +\n\t\t\t\tcomputeShadow(shadowMap, shadowCoord + poissonDisk[3] * texelSize) * 0.25;\n}\nfloat computeShadowWithPCF1(sampler2DShadow shadowSampler, vec3 shadowCoord) {\n\t\treturn computeShadow(shadowSampler, shadowCoord);\n}\nfloat computeShadowWithPCF3(sampler2DShadow shadowSampler, vec3 shadowCoord, vec2 shadowMapSizeAndInverse) {\n\t\tvec2 uv = shadowCoord.xy * shadowMapSizeAndInverse.x;\t\tuv += 0.5;\t\tvec2 st = fract(uv);\t\tvec2 base_uv = floor(uv) - 0.5;\t\tbase_uv *= shadowMapSizeAndInverse.y;\n\t\tvec2 uvw0 = 3. - 2. * st;\n\t\tvec2 uvw1 = 1. + 2. * st;\n\t\tvec2 u = vec2((2. - st.x) / uvw0.x - 1., st.x / uvw1.x + 1.) * shadowMapSizeAndInverse.y;\n\t\tvec2 v = vec2((2. - st.y) / uvw0.y - 1., st.y / uvw1.y + 1.) * shadowMapSizeAndInverse.y;\n\t\tfloat shadow = 0.;\n\t\tshadow += uvw0.x * uvw0.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[0], v[0]), shadowCoord.z));\n\t\tshadow += uvw1.x * uvw0.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[1], v[0]), shadowCoord.z));\n\t\tshadow += uvw0.x * uvw1.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[0], v[1]), shadowCoord.z));\n\t\tshadow += uvw1.x * uvw1.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[1], v[1]), shadowCoord.z));\n\t\tshadow = shadow / 16.;\n\t\treturn shadow;\n}\nfloat computeShadowWithPCF5(sampler2DShadow shadowSampler, vec3 shadowCoord, vec2 shadowMapSizeAndInverse) {\n\t\tvec2 uv = shadowCoord.xy * shadowMapSizeAndInverse.x;\t\tuv += 0.5;\t\tvec2 st = fract(uv);\t\tvec2 base_uv = floor(uv) - 0.5;\t\tbase_uv *= shadowMapSizeAndInverse.y;\n\t\tvec2 uvw0 = 4. - 3. * st;\n\t\tvec2 uvw1 = vec2(7.);\n\t\tvec2 uvw2 = 1. + 3. * st;\n\t\tvec3 u = vec3((3. - 2. * st.x) / uvw0.x - 2., (3. + st.x) / uvw1.x, st.x / uvw2.x + 2.) * shadowMapSizeAndInverse.y;\n\t\tvec3 v = vec3((3. - 2. * st.y) / uvw0.y - 2., (3. + st.y) / uvw1.y, st.y / uvw2.y + 2.) * shadowMapSizeAndInverse.y;\n\t\tfloat shadow = 0.;\n\t\tshadow += uvw0.x * uvw0.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[0], v[0]), shadowCoord.z));\n\t\tshadow += uvw1.x * uvw0.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[1], v[0]), shadowCoord.z));\n\t\tshadow += uvw2.x * uvw0.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[2], v[0]), shadowCoord.z));\n\t\tshadow += uvw0.x * uvw1.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[0], v[1]), shadowCoord.z));\n\t\tshadow += uvw1.x * uvw1.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[1], v[1]), shadowCoord.z));\n\t\tshadow += uvw2.x * uvw1.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[2], v[1]), shadowCoord.z));\n\t\tshadow += uvw0.x * uvw2.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[0], v[2]), shadowCoord.z));\n\t\tshadow += uvw1.x * uvw2.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[1], v[2]), shadowCoord.z));\n\t\tshadow += uvw2.x * uvw2.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[2], v[2]), shadowCoord.z));\n\t\tshadow = shadow / 144.;\n\t\treturn shadow;\n}\nfloat computeFallOff(float value, vec2 clipSpace, float frustumEdgeFalloff) {\n\t\tfloat mask = smoothstep(1.0 - frustumEdgeFalloff, 1.00000012, clamp(dot(clipSpace, clipSpace), 0., 1.));\n\t\treturn mix(value, 1.0, mask);\n}\nfloat getShadow(sampler2DShadow shadowMap, vec4 shadowCoord, vec2 shadowMapSize, vec2 shadowBias, vec2 shadowParams) {\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias.x;\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\tfloat shadow = 1.0;\n\t\tif (frustumTest) {\n\t\t\t\t#ifdef USE_HARD_SHADOW\n\t\t\t\t\t\tshadow = computeShadow(shadowMap, shadowCoord.xyz);\n\t\t\t\t#else\n\t\t\t\t\t\t#ifdef USE_PCF3_SOFT_SHADOW\n\t\t\t\t\t\t\t\tvec2 shadowMapSizeAndInverse = vec2(shadowMapSize.x, 1. / shadowMapSize.x);\n\t\t\t\t\t\t\t\tshadow = computeShadowWithPCF3(shadowMap, shadowCoord.xyz, shadowMapSizeAndInverse);\n\t\t\t\t\t\t#else\n\t\t\t\t\t\t\t\t#ifdef USE_PCF5_SOFT_SHADOW\n\t\t\t\t\t\t\t\t\t\tvec2 shadowMapSizeAndInverse = vec2(shadowMapSize.x, 1. / shadowMapSize.x);\n\t\t\t\t\t\t\t\t\t\tshadow = computeShadowWithPCF5(shadowMap, shadowCoord.xyz, shadowMapSizeAndInverse);\n\t\t\t\t\t\t\t\t#else\n\t\t\t\t\t\t\t\t\t\tfloat texelSize = shadowParams.x / shadowMapSize.x;\n\t\t\t\t\t\t\t\t\t\tshadow = computeShadowWithPoissonSampling(shadowMap, shadowCoord.xyz, texelSize);\n\t\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#endif\n\t\t\t\t#endif\n\t\t\t\tshadow = computeFallOff(shadow, shadowCoord.xy * 2. - 1., shadowParams.y);\n\t\t}\n\t\treturn shadow;\n}\nfloat textureCubeCompare(samplerCube depths, vec3 uv, float compare) {\n\t\treturn step(compare, unpackRGBAToDepth(textureCube(depths, uv)));\n}\nfloat getPointShadow(samplerCube shadowMap, vec4 shadowCoord, vec2 shadowMapSize, vec2 shadowBias, vec2 shadowParams, vec2 shadowCameraRange) {\n\t\tvec3 V = shadowCoord.xyz;\n\t\tfloat depth = (length(V) - shadowCameraRange.x) / (shadowCameraRange.y - shadowCameraRange.x);\t\tdepth += shadowBias.x;\n\t\t#ifdef USE_HARD_SHADOW\n\t\t\t\treturn textureCubeCompare(shadowMap, normalize(V), depth);\n\t\t#else\n\t\t\t\tfloat texelSize = shadowParams.x / shadowMapSize.x;\n\t\t\t\tvec3 poissonDisk[4];\n\t\t\t\tpoissonDisk[0] = vec3(-1.0, 1.0, -1.0);\n\t\t\t\tpoissonDisk[1] = vec3(1.0, -1.0, -1.0);\n\t\t\t\tpoissonDisk[2] = vec3(-1.0, -1.0, -1.0);\n\t\t\t\tpoissonDisk[3] = vec3(1.0, -1.0, 1.0);\n\t\t\t\treturn textureCubeCompare(shadowMap, normalize(V) + poissonDisk[0] * texelSize, depth) * 0.25 +\n\t\t\t\t\t\ttextureCubeCompare(shadowMap, normalize(V) + poissonDisk[1] * texelSize, depth) * 0.25 +\n\t\t\t\t\t\ttextureCubeCompare(shadowMap, normalize(V) + poissonDisk[2] * texelSize, depth) * 0.25 +\n\t\t\t\t\t\ttextureCubeCompare(shadowMap, normalize(V) + poissonDisk[3] * texelSize, depth) * 0.25;\n\t\t#endif\n}\n#ifdef USE_PCSS_SOFT_SHADOW\n\t\tconst vec3 PoissonSamplers32[64] = vec3[64](\n\t\t\t\tvec3(0.06407013, 0.05409927, 0.),\n\t\t\t\tvec3(0.7366577, 0.5789394, 0.),\n\t\t\t\tvec3(-0.6270542, -0.5320278, 0.),\n\t\t\t\tvec3(-0.4096107, 0.8411095, 0.),\n\t\t\t\tvec3(0.6849564, -0.4990818, 0.),\n\t\t\t\tvec3(-0.874181, -0.04579735, 0.),\n\t\t\t\tvec3(0.9989998, 0.0009880066, 0.),\n\t\t\t\tvec3(-0.004920578, -0.9151649, 0.),\n\t\t\t\tvec3(0.1805763, 0.9747483, 0.),\n\t\t\t\tvec3(-0.2138451, 0.2635818, 0.),\n\t\t\t\tvec3(0.109845, 0.3884785, 0.),\n\t\t\t\tvec3(0.06876755, -0.3581074, 0.),\n\t\t\t\tvec3(0.374073, -0.7661266, 0.),\n\t\t\t\tvec3(0.3079132, -0.1216763, 0.),\n\t\t\t\tvec3(-0.3794335, -0.8271583, 0.),\n\t\t\t\tvec3(-0.203878, -0.07715034, 0.),\n\t\t\t\tvec3(0.5912697, 0.1469799, 0.),\n\t\t\t\tvec3(-0.88069, 0.3031784, 0.),\n\t\t\t\tvec3(0.5040108, 0.8283722, 0.),\n\t\t\t\tvec3(-0.5844124, 0.5494877, 0.),\n\t\t\t\tvec3(0.6017799, -0.1726654, 0.),\n\t\t\t\tvec3(-0.5554981, 0.1559997, 0.),\n\t\t\t\tvec3(-0.3016369, -0.3900928, 0.),\n\t\t\t\tvec3(-0.5550632, -0.1723762, 0.),\n\t\t\t\tvec3(0.925029, 0.2995041, 0.),\n\t\t\t\tvec3(-0.2473137, 0.5538505, 0.),\n\t\t\t\tvec3(0.9183037, -0.2862392, 0.),\n\t\t\t\tvec3(0.2469421, 0.6718712, 0.),\n\t\t\t\tvec3(0.3916397, -0.4328209, 0.),\n\t\t\t\tvec3(-0.03576927, -0.6220032, 0.),\n\t\t\t\tvec3(-0.04661255, 0.7995201, 0.),\n\t\t\t\tvec3(0.4402924, 0.3640312, 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.)\n\t\t);\n\t\tconst vec3 PoissonSamplers64[64] = vec3[64](\n\t\t\t\tvec3(-0.613392, 0.617481, 0.),\n\t\t\t\tvec3(0.170019, -0.040254, 0.),\n\t\t\t\tvec3(-0.299417, 0.791925, 0.),\n\t\t\t\tvec3(0.645680, 0.493210, 0.),\n\t\t\t\tvec3(-0.651784, 0.717887, 0.),\n\t\t\t\tvec3(0.421003, 0.027070, 0.),\n\t\t\t\tvec3(-0.817194, -0.271096, 0.),\n\t\t\t\tvec3(-0.705374, -0.668203, 0.),\n\t\t\t\tvec3(0.977050, -0.108615, 0.),\n\t\t\t\tvec3(0.063326, 0.142369, 0.),\n\t\t\t\tvec3(0.203528, 0.214331, 0.),\n\t\t\t\tvec3(-0.667531, 0.326090, 0.),\n\t\t\t\tvec3(-0.098422, -0.295755, 0.),\n\t\t\t\tvec3(-0.885922, 0.215369, 0.),\n\t\t\t\tvec3(0.566637, 0.605213, 0.),\n\t\t\t\tvec3(0.039766, -0.396100, 0.),\n\t\t\t\tvec3(0.751946, 0.453352, 0.),\n\t\t\t\tvec3(0.078707, -0.715323, 0.),\n\t\t\t\tvec3(-0.075838, -0.529344, 0.),\n\t\t\t\tvec3(0.724479, -0.580798, 0.),\n\t\t\t\tvec3(0.222999, -0.215125, 0.),\n\t\t\t\tvec3(-0.467574, -0.405438, 0.),\n\t\t\t\tvec3(-0.248268, -0.814753, 0.),\n\t\t\t\tvec3(0.354411, -0.887570, 0.),\n\t\t\t\tvec3(0.175817, 0.382366, 0.),\n\t\t\t\tvec3(0.487472, -0.063082, 0.),\n\t\t\t\tvec3(-0.084078, 0.898312, 0.),\n\t\t\t\tvec3(0.488876, -0.783441, 0.),\n\t\t\t\tvec3(0.470016, 0.217933, 0.),\n\t\t\t\tvec3(-0.696890, -0.549791, 0.),\n\t\t\t\tvec3(-0.149693, 0.605762, 0.),\n\t\t\t\tvec3(0.034211, 0.979980, 0.),\n\t\t\t\tvec3(0.503098, -0.308878, 0.),\n\t\t\t\tvec3(-0.016205, -0.872921, 0.),\n\t\t\t\tvec3(0.385784, -0.393902, 0.),\n\t\t\t\tvec3(-0.146886, -0.859249, 0.),\n\t\t\t\tvec3(0.643361, 0.164098, 0.),\n\t\t\t\tvec3(0.634388, -0.049471, 0.),\n\t\t\t\tvec3(-0.688894, 0.007843, 0.),\n\t\t\t\tvec3(0.464034, -0.188818, 0.),\n\t\t\t\tvec3(-0.440840, 0.137486, 0.),\n\t\t\t\tvec3(0.364483, 0.511704, 0.),\n\t\t\t\tvec3(0.034028, 0.325968, 0.),\n\t\t\t\tvec3(0.099094, -0.308023, 0.),\n\t\t\t\tvec3(0.693960, -0.366253, 0.),\n\t\t\t\tvec3(0.678884, -0.204688, 0.),\n\t\t\t\tvec3(0.001801, 0.780328, 0.),\n\t\t\t\tvec3(0.145177, -0.898984, 0.),\n\t\t\t\tvec3(0.062655, -0.611866, 0.),\n\t\t\t\tvec3(0.315226, -0.604297, 0.),\n\t\t\t\tvec3(-0.780145, 0.486251, 0.),\n\t\t\t\tvec3(-0.371868, 0.882138, 0.),\n\t\t\t\tvec3(0.200476, 0.494430, 0.),\n\t\t\t\tvec3(-0.494552, -0.711051, 0.),\n\t\t\t\tvec3(0.612476, 0.705252, 0.),\n\t\t\t\tvec3(-0.578845, -0.768792, 0.),\n\t\t\t\tvec3(-0.772454, -0.090976, 0.),\n\t\t\t\tvec3(0.504440, 0.372295, 0.),\n\t\t\t\tvec3(0.155736, 0.065157, 0.),\n\t\t\t\tvec3(0.391522, 0.849605, 0.),\n\t\t\t\tvec3(-0.620106, -0.328104, 0.),\n\t\t\t\tvec3(0.789239, -0.419965, 0.),\n\t\t\t\tvec3(-0.545396, 0.538133, 0.),\n\t\t\t\tvec3(-0.178564, -0.596057, 0.)\n\t\t);\n\t\tfloat getRand(vec2 seed) {\n\t\t\t\treturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233))) * 43758.5453);\n\t\t}\n\t\tfloat computeShadowWithPCSS(sampler2D depthSampler, sampler2DShadow shadowSampler, vec3 shadowCoord, float shadowMapSizeInverse, float lightSizeUV, int searchTapCount, int pcfTapCount, vec3[64] poissonSamplers) {\n\t\t\t\tfloat depthMetric = shadowCoord.z;\n\t\t\t\tfloat blockerDepth = 0.0;\n\t\t\t\tfloat sumBlockerDepth = 0.0;\n\t\t\t\tfloat numBlocker = 0.0;\n\t\t\t\tfor (int i = 0; i < searchTapCount; i++) {\n\t\t\t\t\t\tblockerDepth = unpackRGBAToDepth(texture(depthSampler, shadowCoord.xy + (lightSizeUV * shadowMapSizeInverse * PoissonSamplers32[i].xy)));\n\t\t\t\t\t\tif (blockerDepth < depthMetric) {\n\t\t\t\t\t\t\t\tsumBlockerDepth += blockerDepth;\n\t\t\t\t\t\t\t\tnumBlocker++;\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (numBlocker < 1.0) {\n\t\t\t\t\t\treturn 1.0;\n\t\t\t\t}\n\t\t\t\tfloat avgBlockerDepth = sumBlockerDepth / numBlocker;\n\t\t\t\tfloat AAOffset = shadowMapSizeInverse * 10.;\n\t\t\t\tfloat penumbraRatio = ((depthMetric - avgBlockerDepth) + AAOffset);\n\t\t\t\tfloat filterRadius = penumbraRatio * lightSizeUV * shadowMapSizeInverse;\n\t\t\t\tfloat random = getRand(shadowCoord.xy);\t\t\t\tfloat rotationAngle = random * 3.1415926;\n\t\t\t\tvec2 rotationVector = vec2(cos(rotationAngle), sin(rotationAngle));\n\t\t\t\tfloat shadow = 0.;\n\t\t\t\tfor (int i = 0; i < pcfTapCount; i++) {\n\t\t\t\t\t\tvec3 offset = poissonSamplers[i];\n\t\t\t\t\t\toffset = vec3(offset.x * rotationVector.x - offset.y * rotationVector.y, offset.y * rotationVector.x + offset.x * rotationVector.y, 0.);\n\t\t\t\t\t\tshadow += texture(shadowSampler, shadowCoord + offset * filterRadius);\n\t\t\t\t}\n\t\t\t\tshadow /= float(pcfTapCount);\n\t\t\t\tshadow = mix(shadow, 1., depthMetric - avgBlockerDepth);\n\t\t\t\treturn shadow;\n\t\t}\n\t\tfloat getShadowWithPCSS(sampler2D depthSampler, sampler2DShadow shadowMap, vec4 shadowCoord, vec2 shadowMapSize, vec2 shadowBias, vec2 shadowParams) {\n\t\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\t\tshadowCoord.z += shadowBias.x;\n\t\t\t\tbvec4 inFrustumVec = bvec4 (shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0);\n\t\t\t\tbool inFrustum = all(inFrustumVec);\n\t\t\t\tbvec2 frustumTestVec = bvec2(inFrustum, shadowCoord.z <= 1.0);\n\t\t\t\tbool frustumTest = all(frustumTestVec);\n\t\t\t\tfloat shadow = 1.0;\n\t\t\t\tif (frustumTest) {\n\t\t\t\t\t\t#ifdef USE_PCSS16_SOFT_SHADOW\n\t\t\t\t\t\t\t\tshadow = computeShadowWithPCSS(depthSampler, shadowMap, shadowCoord.xyz, 1. / shadowMapSize.x, 0.1 * shadowMapSize.x, 16, 16, PoissonSamplers32);\n\t\t\t\t\t\t#else\n\t\t\t\t\t\t\t\t#ifdef USE_PCSS32_SOFT_SHADOW\n\t\t\t\t\t\t\t\t\t\tshadow = computeShadowWithPCSS(depthSampler, shadowMap, shadowCoord.xyz, 1. / shadowMapSize.x, 0.1 * shadowMapSize.x, 16, 32, PoissonSamplers32);\n\t\t\t\t\t\t\t\t#else\n\t\t\t\t\t\t\t\t\t\tshadow = computeShadowWithPCSS(depthSampler, shadowMap, shadowCoord.xyz, 1. / shadowMapSize.x, 0.1 * shadowMapSize.x, 32, 64, PoissonSamplers64);\n\t\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\tshadow = computeFallOff(shadow, shadowCoord.xy * 2. - 1., shadowParams.y);\n\t\t\t\t}\n\t\t\t\treturn shadow;\n\t\t}\n#endif",shadowMap_frag:"#ifdef USE_SHADOW\n#endif",shadowMap_pars_frag:"#ifdef USE_SHADOW\n\t#if NUM_DIR_SHADOWS > 0\n\t\tuniform sampler2DShadow directionalShadowMap[NUM_DIR_SHADOWS];\n\t\tvarying vec4 vDirectionalShadowCoord[NUM_DIR_SHADOWS];\n\t\t#ifdef USE_PCSS_SOFT_SHADOW\n\t\t\tuniform sampler2D directionalDepthMap[NUM_DIR_SHADOWS];\n\t\t#endif\n\t\tstruct DirectLightShadow {\n\t\t\tvec2 shadowBias;\n\t\t\tvec2 shadowMapSize;\n\t\t\tvec2 shadowParams;\n\t\t};\n\t\tuniform DirectLightShadow u_DirectionalShadow[NUM_DIR_SHADOWS];\n\t#endif\n\t#if NUM_POINT_SHADOWS > 0\n\t\tuniform samplerCube pointShadowMap[NUM_POINT_SHADOWS];\n\t\tvarying vec4 vPointShadowCoord[NUM_POINT_SHADOWS];\n\t\tstruct PointLightShadow {\n\t\t\tvec2 shadowBias;\n\t\t\tvec2 shadowMapSize;\n\t\t\tvec2 shadowParams;\n\t\t\tvec2 shadowCameraRange;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow u_PointShadow[NUM_POINT_SHADOWS];\n\t#endif\n\t#if NUM_SPOT_SHADOWS > 0\n\t\tuniform sampler2DShadow spotShadowMap[NUM_SPOT_SHADOWS];\n\t\tvarying vec4 vSpotShadowCoord[NUM_SPOT_SHADOWS];\n\t\t#ifdef USE_PCSS_SOFT_SHADOW\n\t\t\tuniform sampler2D spotDepthMap[NUM_SPOT_SHADOWS];\n\t\t#endif\n\t\tstruct SpotLightShadow {\n\t\t\tvec2 shadowBias;\n\t\t\tvec2 shadowMapSize;\n\t\t\tvec2 shadowParams;\n\t\t};\n\t\tuniform SpotLightShadow u_SpotShadow[NUM_SPOT_SHADOWS];\n\t#endif\n\t#include \n\t#include \n#endif",shadowMap_pars_vert:"#ifdef USE_SHADOW\n\t#if NUM_DIR_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[NUM_DIR_SHADOWS];\n\t\tvarying vec4 vDirectionalShadowCoord[NUM_DIR_SHADOWS];\n\t\tstruct DirectLightShadow {\n\t\t\tvec2 shadowBias;\n\t\t\tvec2 shadowMapSize;\n\t\t\tvec2 shadowParams;\n\t\t};\n\t\tuniform DirectLightShadow u_DirectionalShadow[NUM_DIR_SHADOWS];\n\t#endif\n\t#if NUM_POINT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[NUM_POINT_SHADOWS];\n\t\tvarying vec4 vPointShadowCoord[NUM_POINT_SHADOWS];\n\t\tstruct PointLightShadow {\n\t\t\tvec2 shadowBias;\n\t\t\tvec2 shadowMapSize;\n\t\t\tvec2 shadowParams;\n\t\t\tvec2 shadowCameraRange;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow u_PointShadow[NUM_POINT_SHADOWS];\n\t#endif\n\t#if NUM_SPOT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[NUM_SPOT_SHADOWS];\n\t\tvarying vec4 vSpotShadowCoord[NUM_SPOT_SHADOWS];\n\t\tstruct SpotLightShadow {\n\t\t\tvec2 shadowBias;\n\t\t\tvec2 shadowMapSize;\n\t\t\tvec2 shadowParams;\n\t\t};\n\t\tuniform SpotLightShadow u_SpotShadow[NUM_SPOT_SHADOWS];\n\t#endif\n#endif",shadowMap_vert:"\n#ifdef USE_SHADOW\n\t#if NUM_DIR_SHADOWS > 0 || NUM_POINT_SHADOWS > 0 || NUM_SPOT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = (transposeMat4(inverseMat4(u_Model)) * vec4(objectNormal, 0.0)).xyz;\n\t\tshadowWorldNormal = normalize(shadowWorldNormal);\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor (int i = 0; i < NUM_DIR_SHADOWS; i++) {\n\t\t\tshadowWorldPosition = worldPosition + vec4(shadowWorldNormal * u_DirectionalShadow[i].shadowBias[1], 0);\n\t\t\tvDirectionalShadowCoord[i] = directionalShadowMatrix[i] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor (int i = 0; i < NUM_POINT_SHADOWS; i++) {\n\t\t\tshadowWorldPosition = worldPosition + vec4(shadowWorldNormal * u_PointShadow[i].shadowBias[1], 0);\n\t\t\tvPointShadowCoord[i] = pointShadowMatrix[i] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor (int i = 0; i < NUM_SPOT_SHADOWS; i++) {\n\t\t\tshadowWorldPosition = worldPosition + vec4(shadowWorldNormal * u_SpotShadow[i].shadowBias[1], 0);\n\t\t\tvSpotShadowCoord[i] = spotShadowMatrix[i] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif",morphnormal_vert:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif",morphtarget_pars_vert:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vert:"#ifdef USE_MORPHTARGETS\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\t\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif",skinning_pars_vert:"#ifdef USE_SKINNING\n\t\tattribute vec4 skinIndex;\n\tattribute vec4 skinWeight;\n\t\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t\t#ifdef BONE_TEXTURE\n\t\t\t\tuniform sampler2D boneTexture;\n\t\t\t\tuniform int boneTextureSize;\n\t\t\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\t\t\t\tfloat j = i * 4.0;\n\t\t\t\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\t\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\t\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\t\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\t\t\t\ty = dy * ( y + 0.5 );\n\t\t\t\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\t\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\t\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\t\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\t\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\t\t\t\treturn bone;\n\t\t\t\t}\n\t\t#else\n\t\t\t\tuniform mat4 boneMatrices[MAX_BONES];\n\t\t\t\tmat4 getBoneMatrix(const in float i) {\n\t\t\t\t\t\tmat4 bone = boneMatrices[int(i)];\n\t\t\t\t\t\treturn bone;\n\t\t\t\t}\n\t\t#endif\n#endif",skinning_vert:"#ifdef USE_SKINNING\n\t\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\t\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\t\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\t\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n\t\tvec4 skinVertex = bindMatrix * vec4(transformed, 1.0);\n\t\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\tskinned = bindMatrixInverse * skinned;\n\t\ttransformed = skinned.xyz / skinned.w;\n#endif",skinnormal_vert:"#ifdef USE_SKINNING\n\t\tmat4 skinMatrix = mat4( 0.0 );\n\t\tskinMatrix += skinWeight.x * boneMatX;\n\t\tskinMatrix += skinWeight.y * boneMatY;\n\t\tskinMatrix += skinWeight.z * boneMatZ;\n\t\tskinMatrix += skinWeight.w * boneMatW;\n\t\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\t\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularMap_frag:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, v_Uv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularMap_pars_frag:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",transpose:"mat4 transposeMat4(mat4 inMatrix) {\n\t\tvec4 i0 = inMatrix[0];\n\t\tvec4 i1 = inMatrix[1];\n\t\tvec4 i2 = inMatrix[2];\n\t\tvec4 i3 = inMatrix[3];\n\t\tmat4 outMatrix = mat4(\n\t\t\t\tvec4(i0.x, i1.x, i2.x, i3.x),\n\t\t\t\tvec4(i0.y, i1.y, i2.y, i3.y),\n\t\t\t\tvec4(i0.z, i1.z, i2.z, i3.z),\n\t\t\t\tvec4(i0.w, i1.w, i2.w, i3.w)\n\t\t);\n\t\treturn outMatrix;\n}",tsn:"mat3 tsn(vec3 N, vec3 V, vec2 uv) {\n\t\tvec3 q0 = vec3(dFdx(V.x), dFdx(V.y), dFdx(V.z));\n\t\tvec3 q1 = vec3(dFdy(V.x), dFdy(V.y), dFdy(V.z));\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.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\tmat3 tsn = mat3( S, T, N );\n\t\treturn tsn;\n}",uv_pars_frag:"#ifdef USE_UV1\n\t\tvarying vec2 v_Uv;\n#endif\n#ifdef USE_UV2\n\t\tvarying vec2 v_Uv2;\n#endif",uv_pars_vert:"#if defined(USE_UV1) || defined(USE_UV2)\n\t\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_UV1\n\t\tattribute vec2 a_Uv;\n\t\tvarying vec2 v_Uv;\n#endif\n#ifdef USE_UV2\n\t\tattribute vec2 a_Uv2;\n\t\tvarying vec2 v_Uv2;\n#endif",uv_vert:"#ifdef USE_UV1\n\t\tv_Uv = (uvTransform * vec3(a_Uv, 1.)).xy;\n#endif\n#ifdef USE_UV2\n\t\tv_Uv2 = (uvTransform * vec3(a_Uv2, 1.)).xy;\n#endif",modelPos_pars_frag:"varying vec3 v_modelPos;",modelPos_pars_vert:"varying vec3 v_modelPos;",modelPos_vert:"\nv_modelPos = worldPosition.xyz;",logdepthbuf_frag:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_frag:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vert:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tuniform float logDepthCameraNear;\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t\tuniform float logDepthCameraNear;\n\t#endif\n#endif",logdepthbuf_vert:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w - logDepthCameraNear;\n\t\tvIsPerspective = float( isPerspectiveMatrix( u_Projection ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( u_Projection ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w - logDepthCameraNear + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",clearcoat_pars_frag:"#ifdef USE_CLEARCOAT\n\tuniform float u_Clearcoat;\n\tuniform float u_ClearcoatRoughness;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif"},ii="#define USE_PBR\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",ri={basic_frag:"#include \n#include \n#include \n#include \n#include \n#include \n#if defined(USE_ENV_MAP) && !defined(USE_VERTEX_ENVDIR)\n\t\t#include \n\t\t#include \t\t\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\tReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n\t\treflectedLight.indirectDiffuse += vec3(1.0);\n\t\t#include \n\t\treflectedLight.indirectDiffuse *= outColor.xyz;\n\t\toutColor.xyz = reflectedLight.indirectDiffuse;\n\t\t#if defined(USE_ENV_MAP) && !defined(USE_VERTEX_ENVDIR)\n\t\t\t\t#include \n\t\t#endif\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",basic_vert:"#include \n#include \n#include \n#include \n#if defined(USE_ENV_MAP) && !defined(USE_VERTEX_ENVDIR)\n\t\t#include \n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#ifdef USE_ENV_MAP\n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#ifndef USE_VERTEX_ENVDIR\n\t\t\t\t\t\t#include \n\t\t\t\t#endif\t\n\t\t#endif\n\t\t#include \n\t\t#include \n\t\t#include \n}",depth_frag:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#if defined(USE_DIFFUSE_MAP) && defined(ALPHATEST)\n\t\t\t\tvec4 texelColor = texture2D( diffuseMap, v_Uv );\n\t\t\t\tfloat alpha = texelColor.a * u_Opacity;\n\t\t\t\tif(alpha < ALPHATEST) discard;\n\t\t#endif\n\t\t#include \n\t\t\n\t\t#ifdef DEPTH_PACKING_RGBA\n\t\t\t\tgl_FragColor = packDepthToRGBA(gl_FragCoord.z);\n\t\t#else\n\t\t\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), u_Opacity );\n\t\t#endif\n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",distance_frag:"#include \nuniform float nearDistance;\nuniform float farDistance;\n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t\n\t\tfloat dist = length( v_modelPos - u_CameraPosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\t\tgl_FragColor = packDepthToRGBA(dist);\n}",distance_vert:"#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",lambert_frag:"#define USE_LAMBERT\n#include \n#include \nuniform vec3 emissive;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\tReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n\t\t#include \n\t\t#include \n\t\toutColor.xyz = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\t\t#include \n\t\t#include \n\t\tvec3 totalEmissiveRadiance = emissive;\n\t\t#include \n\t\toutColor.xyz += totalEmissiveRadiance;\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",lambert_vert:"#define USE_LAMBERT\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",normaldepth_frag:"#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#if defined(USE_DIFFUSE_MAP) && defined(ALPHATEST)\n\t\t\t\tvec4 texelColor = texture2D( diffuseMap, v_Uv );\n\t\t\t\tfloat alpha = texelColor.a * u_Opacity;\n\t\t\t\tif(alpha < ALPHATEST) discard;\n\t\t#endif\n\t\t#include \n\t\tvec4 packedNormalDepth;\n\t\tpackedNormalDepth.xyz = normalize(v_Normal) * 0.5 + 0.5;\n\t\tpackedNormalDepth.w = gl_FragCoord.z;\n\t\tgl_FragColor = packedNormalDepth;\n}",normaldepth_vert:"#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",pbr_frag:"#define USE_PBR\n#include \n#include \nuniform float u_Metalness;\n#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif\nuniform float u_Roughness;\n#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif\nuniform vec3 emissive;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\tfloat roughnessFactor = u_Roughness;\n\t\t#ifdef USE_ROUGHNESSMAP\n\t\t\tvec4 texelRoughness = texture2D( roughnessMap, v_Uv );\n\t\t\troughnessFactor *= texelRoughness.g;\n\t\t#endif\n\t\tfloat metalnessFactor = u_Metalness;\n\t\t#ifdef USE_METALNESSMAP\n\t\t\tvec4 texelMetalness = texture2D( metalnessMap, v_Uv );\n\t\t\tmetalnessFactor *= texelMetalness.b;\n\t\t#endif\n\t\tReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n\t\t#include \n\t\t#include \n\t\toutColor.xyz = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t\t#include \n\t\tvec3 totalEmissiveRadiance = emissive;\n\t\t#include \n\t\toutColor.xyz += totalEmissiveRadiance;\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",pbr_vert:ii,pbr2_frag:"#define USE_PBR\n#define USE_PBR2\n#include \n#include \nuniform vec3 u_SpecularColor;\n#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif\nuniform float glossiness;\n#ifdef USE_GLOSSINESSMAP\n\tuniform sampler2D glossinessMap;\n#endif\nuniform vec3 emissive;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\tvec3 specularFactor = u_SpecularColor;\n\t\t#ifdef USE_SPECULARMAP\n\t\t\t\tvec4 texelSpecular = texture2D(specularMap, v_Uv);\n\t\t\t\ttexelSpecular = sRGBToLinear(texelSpecular);\n\t\t\t\tspecularFactor *= texelSpecular.rgb;\n\t\t#endif\n\t\tfloat glossinessFactor = glossiness;\n\t\t#ifdef USE_GLOSSINESSMAP\n\t\t\t\tvec4 texelGlossiness = texture2D(glossinessMap, v_Uv);\n\t\t\t\tglossinessFactor *= texelGlossiness.a;\n\t\t#endif\n\t\tReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n\t\t#include \n\t\t#include \n\t\toutColor.xyz = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t\t#include \n\t\tvec3 totalEmissiveRadiance = emissive;\n\t\t#include \n\t\toutColor.xyz += totalEmissiveRadiance;\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",pbr2_vert:ii,matcap_frag:"#define MATCAP\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\tvec3 viewDir = normalize(vViewPosition);\n\tvec3 x = normalize(vec3(viewDir.z, 0.0, -viewDir.x));\n\tvec3 y = cross(viewDir, x);\n\t\tvec3 viewN = (u_View * vec4(N, 0.0)).xyz;\n\tvec2 uv = vec2(dot(x, viewN), dot(y, viewN)) * 0.495 + 0.5;\n\t\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D(matcap, uv);\n\t\tmatcapColor = matcapTexelToLinear(matcapColor);\n\t#else\n\t\tvec4 matcapColor = vec4(1.0);\n\t#endif\n\toutColor.rgb *= matcapColor.rgb;\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",matcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\tvec4 mvPosition = u_View * worldPosition;\n\t\tvViewPosition = - mvPosition.xyz;\n}",phong_frag:"#define USE_PHONG\n#include \n#include \nuniform float u_Specular;\nuniform vec3 u_SpecularColor;\n#include \nuniform vec3 emissive;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\tReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n\t\t#include \n\t\t#include \n\t\toutColor.xyz = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t\t#include \n\t\t#include \n\t\tvec3 totalEmissiveRadiance = emissive;\n\t\t#include \n\t\toutColor.xyz += totalEmissiveRadiance;\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",phong_vert:"#define USE_PHONG\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",point_frag:"#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#ifdef USE_DIFFUSE_MAP\n\t\t\t\toutColor *= texture2D(diffuseMap, vec2(gl_PointCoord.x, 1.0 - gl_PointCoord.y));\n\t\t#endif\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",point_vert:"#include \n#include \n#include \nuniform float u_PointSize;\nuniform float u_PointScale;\nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\tvec4 mvPosition = u_View * u_Model * vec4(transformed, 1.0);\n\t\t#ifdef USE_SIZEATTENUATION\n\t\t\t\tgl_PointSize = u_PointSize * ( u_PointScale / - mvPosition.z );\n\t\t#else\n\t\t\t\tgl_PointSize = u_PointSize;\n\t\t#endif\n\t\t#include \n}"},ai=function(){function t(t,e,n){this._gl=t,this._state=e,this._capabilities=n,this._programs=[]}var e=t.prototype;return e.getProgram=function(t,e,n,i){for(var r,a=this._programs,o=function(t,e,n,i,r){var a=n.acceptLight?r.lights:null,o=n.fog?r.scene.fog:null,s=void 0!==n.envMap?n.envMap||r.scene.environment:null,u=r.scene.logarithmicDepthBuffer,l=r.scene.disableShadowSampler,c=n.clippingPlanes&&n.clippingPlanes.length>0?n.clippingPlanes.length:r.scene.numClippingPlanes,h={};h.shaderName=n.type===b.SHADER&&n.shaderName?n.shaderName:n.type,h.version=e.version,h.precision=n.precision||e.maxPrecision,h.useStandardDerivatives=e.version>=2||!!e.getExtension("OES_standard_derivatives")||!!e.getExtension("GL_OES_standard_derivatives"),h.useShaderTextureLOD=e.version>=2||!!e.getExtension("EXT_shader_texture_lod"),h.useDiffuseMap=n.diffuseMap?n.diffuseMapCoord+1:0,h.useAlphaMap=n.alphaMap?n.alphaMapCoord+1:0,h.useEmissiveMap=n.emissiveMap?n.emissiveMapCoord+1:0,h.useAOMap=n.aoMap?n.aoMapCoord+1:0,h.useNormalMap=!!n.normalMap,h.useBumpMap=!!n.bumpMap,h.useSpecularMap=!!n.specularMap,h.useRoughnessMap=!!n.roughnessMap,h.useMetalnessMap=!!n.metalnessMap,h.useGlossinessMap=!!n.glossinessMap,h.useMatcap=!!n.matcap,h.useEnvMap=!!s,h.envMapCombine=n.envMapCombine,h.useClearcoat=n.clearcoat>0,h.useClearcoatMap=h.useClearcoat&&!!n.clearcoatMap,h.useClearcoatRoughnessMap=h.useClearcoat&&!!n.clearcoatRoughnessMap,h.useClearcoatNormalMap=h.useClearcoat&&!!n.clearcoatNormalMap,h.useUv1=1===h.useDiffuseMap||1===h.useAlphaMap||1===h.useEmissiveMap||1===h.useAOMap||h.useNormalMap||h.useBumpMap||h.useSpecularMap||h.useRoughnessMap||h.useMetalnessMap||h.useGlossinessMap||h.useClearcoatMap||h.useClearcoatNormalMap||h.useClearcoatRoughnessMap,h.useUv2=2===h.useDiffuseMap||2===h.useAlphaMap||2===h.useEmissiveMap||2===h.useAOMap,h.useAmbientLight=!!a&&a.useAmbient,h.hemisphereLightNum=a?a.hemisNum:0,h.directLightNum=a?a.directsNum:0,h.pointLightNum=a?a.pointsNum:0,h.spotLightNum=a?a.spotsNum:0,h.directShadowNum=i.receiveShadow&&a?a.directShadowNum:0,h.pointShadowNum=i.receiveShadow&&a?a.pointShadowNum:0,h.spotShadowNum=i.receiveShadow&&a?a.spotShadowNum:0,h.useShadow=i.receiveShadow&&!!a&&a.shadowsNum>0,h.useShadowSampler=e.version>=2&&!l,h.shadowType=h.useShadowSampler?i.shadowType:z.POISSON_SOFT,h.dithering=n.dithering;var d=t.currentRenderTarget;h.gammaFactor=r.gammaFactor,h.outputEncoding=d.texture?oi(d.texture):r.outputEncoding,h.diffuseMapEncoding=oi(n.diffuseMap||n.cubeMap),h.envMapEncoding=oi(s),h.emissiveMapEncoding=oi(n.emissiveMap),h.matcapEncoding=oi(n.matcap),h.alphaTest=n.alphaTest,h.premultipliedAlpha=n.premultipliedAlpha,h.useVertexColors=n.vertexColors,h.useVertexTangents=!!n.normalMap&&n.vertexTangents,h.numClippingPlanes=c,h.flatShading=n.shading===D.FLAT_SHADING,h.fog=!!o,h.fogExp2=!!o&&o.isFogExp2,h.sizeAttenuation=n.sizeAttenuation,h.doubleSided=n.side===C.DOUBLE,h.flipSided=n.side===C.BACK,h.packDepthToRGBA=n.packToRGBA,h.logarithmicDepthBuffer=!!u,h.rendererExtensionFragDepth=e.version>=2||!!e.getExtension("EXT_frag_depth"),h.morphTargets=!!i.morphTargetInfluences,h.morphNormals=!!i.morphTargetInfluences&&i.geometry.morphAttributes.normal;var f=i.isSkinnedMesh&&i.skeleton,p=e.maxVertexUniformVectors,_=e.maxVertexTextures>0&&(!!e.getExtension("OES_texture_float")||e.version>=2),v=0;_?v=1024:16*(v=i.skeleton?i.skeleton.bones.length:0)>p&&(console.warn("Program: too many bones ("+v+"), current cpu only support "+Math.floor(p/16)+" bones!!"),v=Math.floor(p/16));return h.useSkinning=f,h.bonesNum=v,h.useVertexTexture=_,h}(this._state,this._capabilities,t,e,n),s=function(t,e){var n="";for(var i in t)n+=t[i]+"_";for(var r in e.defines)n+=r+"_"+e.defines[r]+"_";e.type!==b.SHADER||e.shaderName||(n+=e.vertexShader,n+=e.fragmentShader);return n}(o,t),u=0,l=a.length;u=2?"#define WEBGL2":"",n.useRoughnessMap?"#define USE_ROUGHNESSMAP":"",n.useMetalnessMap?"#define USE_METALNESSMAP":"",n.useGlossinessMap?"#define USE_GLOSSINESSMAP":"",n.useAmbientLight?"#define USE_AMBIENT_LIGHT":"",n.pointLightNum>0||n.directLightNum>0||n.useAmbientLight||n.hemisphereLightNum>0||n.spotLightNum>0?"#define USE_LIGHT":"",n.useNormalMap?"#define USE_NORMAL_MAP":"",n.useBumpMap?"#define USE_BUMPMAP":"",n.useSpecularMap?"#define USE_SPECULARMAP":"",n.useEmissiveMap?"#define USE_EMISSIVEMAP "+n.useEmissiveMap:"",n.useShadow?"#define USE_SHADOW":"",n.flatShading?"#define FLAT_SHADED":"",n.flipSided?"#define FLIP_SIDED":"",n.useDiffuseMap?"#define USE_DIFFUSE_MAP "+n.useDiffuseMap:"",n.useAlphaMap?"#define USE_ALPHA_MAP "+n.useAlphaMap:"",n.useEnvMap?"#define USE_ENV_MAP":"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.useAOMap?"#define USE_AOMAP "+n.useAOMap:"",n.useVertexColors==X.RGB?"#define USE_VCOLOR_RGB":"",n.useVertexColors==X.RGBA?"#define USE_VCOLOR_RGBA":"",n.useVertexTangents?"#define USE_TANGENT":"",n.useUv1?"#define USE_UV1":"",n.useUv2?"#define USE_UV2":"",n.fog?"#define USE_FOG":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.useSkinning?"#define USE_SKINNING":"",n.bonesNum>0?"#define MAX_BONES "+n.bonesNum:"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","\n"].filter(hi).join("\n"),o=[n.useStandardDerivatives&&n.version<2?"#extension GL_OES_standard_derivatives : enable":"",n.useShaderTextureLOD&&n.version<2?"#extension GL_EXT_shader_texture_lod : enable":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth&&n.version<2?"#extension GL_EXT_frag_depth : enable":"","precision "+n.precision+" float;","precision "+n.precision+" int;","precision "+n.precision+" sampler2D;",n.version>=2?"precision "+n.precision+" sampler2DShadow;":"",n.version>=2?"precision "+n.precision+" samplerCubeShadow;":"","#define SHADER_NAME "+n.shaderName,"#define PI 3.14159265359","#define EPSILON 1e-6","float pow2(const in float x) { return x * x; }","#define LOG2 1.442695","#define RECIPROCAL_PI 0.31830988618","#define saturate(a) clamp(a, 0.0, 1.0)","#define whiteCompliment(a) (1.0 - saturate(a))","highp float rand(const in vec2 uv) {","\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;","\thighp float dt = dot(uv.xy, vec2(a, b)), sn = mod(dt, PI);","\treturn fract(sin(sn) * c);","}",e,n.version>=2?"#define WEBGL2":"",n.useShadowSampler?"#define USE_SHADOW_SAMPLER":"#define sampler2DShadow sampler2D",n.useRoughnessMap?"#define USE_ROUGHNESSMAP":"",n.useMetalnessMap?"#define USE_METALNESSMAP":"",n.useGlossinessMap?"#define USE_GLOSSINESSMAP":"",n.useClearcoat?"#define USE_CLEARCOAT":"",n.useClearcoatMap?"#define USE_CLEARCOATMAP":"",n.useClearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.useClearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.useAmbientLight?"#define USE_AMBIENT_LIGHT":"",n.pointLightNum>0||n.directLightNum>0||n.useAmbientLight||n.hemisphereLightNum>0||n.spotLightNum>0?"#define USE_LIGHT":"",n.useNormalMap?"#define USE_NORMAL_MAP":"",n.useBumpMap?"#define USE_BUMPMAP":"",n.useSpecularMap?"#define USE_SPECULARMAP":"",n.useEmissiveMap?"#define USE_EMISSIVEMAP "+n.useEmissiveMap:"",n.useShadow?"#define USE_SHADOW":"",n.shadowType===z.HARD?"#define USE_HARD_SHADOW":"",n.shadowType===z.POISSON_SOFT?"#define USE_POISSON_SOFT_SHADOW":"",n.shadowType===z.PCF3_SOFT?"#define USE_PCF3_SOFT_SHADOW":"",n.shadowType===z.PCF5_SOFT?"#define USE_PCF5_SOFT_SHADOW":"",n.shadowType===z.PCSS16_SOFT?"#define USE_PCSS16_SOFT_SHADOW":"",n.shadowType===z.PCSS32_SOFT?"#define USE_PCSS32_SOFT_SHADOW":"",n.shadowType===z.PCSS64_SOFT?"#define USE_PCSS64_SOFT_SHADOW":"",n.shadowType===z.PCSS16_SOFT||n.shadowType===z.PCSS32_SOFT||n.shadowType===z.PCSS64_SOFT?"#define USE_PCSS_SOFT_SHADOW":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.useShaderTextureLOD?"#define TEXTURE_LOD_EXT":"",n.useDiffuseMap?"#define USE_DIFFUSE_MAP "+n.useDiffuseMap:"",n.useAlphaMap?"#define USE_ALPHA_MAP "+n.useAlphaMap:"",n.useEnvMap?"#define USE_ENV_MAP":"",n.useAOMap?"#define USE_AOMAP "+n.useAOMap:"",n.useVertexColors==X.RGB?"#define USE_VCOLOR_RGB":"",n.useVertexColors==X.RGBA?"#define USE_VCOLOR_RGBA":"",n.useVertexTangents?"#define USE_TANGENT":"",n.premultipliedAlpha?"#define USE_PREMULTIPLIED_ALPHA":"",n.fog?"#define USE_FOG":"",n.fogExp2?"#define USE_EXP2_FOG":"",n.alphaTest?"#define ALPHATEST "+n.alphaTest:"",n.useEnvMap?"#define "+n.envMapCombine:"","#define GAMMA_FACTOR "+n.gammaFactor,n.useMatcap?"#define USE_MATCAP":"",n.useUv1?"#define USE_UV1":"",n.useUv2?"#define USE_UV2":"",n.dithering?"#define DITHERING":"",ni.encodings_pars_frag,ui("mapTexelToLinear",n.diffuseMapEncoding),n.useEnvMap?ui("envMapTexelToLinear",n.envMapEncoding):"",n.useEmissiveMap?ui("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.useMatcap?ui("matcapTexelToLinear",n.matcapEncoding):"",li("linearToOutputTexel",n.outputEncoding),n.packDepthToRGBA?"#define DEPTH_PACKING_RGBA":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","\n"].filter(hi).join("\n"),s=i,u=r;if(s=ci(s),u=ci(u),s=di(s,n),u=di(u,n),s=fi(s,n),u=fi(u,n),s=vi(s),u=vi(u),n.version>1){a=["#version 300 es\n","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+a,u=u.replace("#extension GL_EXT_draw_buffers : require","");for(var l=0,c=[];u.indexOf("gl_FragData["+l+"]")>-1;)u=u.replace("gl_FragData["+l+"]","pc_fragData"+l),c.push("layout(location = "+l+") out highp vec4 pc_fragData"+l+";"),l++;o=["#version 300 es\n","#define varying in",u.indexOf("layout")>-1||c.length>0?"":"out highp vec4 pc_fragColor;","#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad",c.join("\n")].join("\n")+"\n"+o}return new $n(t,s=a+s,u=o+u)}(this._gl,h,o,d,f),r.compile(i),r.code=s,a.push(r)}return r},e.releaseProgram=function(t){if(0==--t.usedTimes){var e=this._programs,n=e.indexOf(t);e[n]=e[e.length-1],e.pop(),t.dispose(this._gl)}},t}();function oi(t){var e;return t?t.encoding&&(e=t.encoding):e=H.LINEAR,e}function si(t){switch(t){case H.LINEAR:return["Linear","(value)"];case H.SRGB:return["sRGB","(value)"];case H.RGBE:return["RGBE","(value)"];case H.RGBM7:return["RGBM","(value, 7.0)"];case H.RGBM16:return["RGBM","(value, 16.0)"];case H.RGBD:return["RGBD","(value, 256.0)"];case H.GAMMA:return["Gamma","(value, float(GAMMA_FACTOR))"];default:console.error("unsupported encoding: "+t)}}function ui(t,e){var n=si(e);return"vec4 "+t+"(vec4 value) { return "+n[0]+"ToLinear"+n[1]+"; }"}function li(t,e){var n=si(e);return"vec4 "+t+"(vec4 value) { return LinearTo"+n[0]+n[1]+"; }"}var ci=function t(e){return e.replace(/#include +<([\w\d.]+)>/g,(function(e,n){var i=ni[n];if(void 0===i)throw new Error("Can not resolve #include <"+n+">");return t(i)}))};function hi(t){return""!==t}function di(t,e){return t.replace(/NUM_HEMI_LIGHTS/g,e.hemisphereLightNum).replace(/NUM_DIR_LIGHTS/g,e.directLightNum).replace(/NUM_SPOT_LIGHTS/g,e.spotLightNum).replace(/NUM_POINT_LIGHTS/g,e.pointLightNum).replace(/NUM_DIR_SHADOWS/g,e.directShadowNum).replace(/NUM_SPOT_SHADOWS/g,e.spotShadowNum).replace(/NUM_POINT_SHADOWS/g,e.pointShadowNum)}function fi(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes)}var pi=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function _i(t,e,n,i){for(var r="",a=parseInt(e);a1){if(n=this.getExtension("EXT_disjoint_timer_query_webgl2"))i=(null!=(r=t.getQuery(n.TIMESTAMP_EXT,n.QUERY_COUNTER_BITS_EXT))?r:0)>0}else if(n=this.getExtension("EXT_disjoint_timer_query"))i=(null!=(a=n.getQueryEXT(n.TIMESTAMP_EXT,n.QUERY_COUNTER_BITS_EXT))?a:0)>0}catch(t){console.warn(t)}this.timerQuery=n,this.canUseTimestamp=i,this.maxPrecision=function(t,e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}if("mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0)return"mediump";return"lowp"}(t,"highp"),this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.maxVertexTextures=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),this.maxCubemapSize=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),this.maxVertexUniformVectors=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),this.maxSamples=this.version>1?t.getParameter(t.MAX_SAMPLES):1,this.lineWidthRange=t.getParameter(t.ALIASED_LINE_WIDTH_RANGE)}return t.prototype.getExtension=function(t){var e=this._gl,n=this._extensions;if(void 0!==n[t])return n[t];var i=null;for(var r in gi)if(i=e.getExtension(gi[r]+t))break;return n[t]=i,i},t}(),gi=["","WEBKIT_","MOZ_"];var Ei=function(){function t(t,e){this._gl=t,this._capabilities=e}var e=t.prototype;return e.getGLType=function(t){var e,n=this._gl,i=this._capabilities,r=i.version>=2;if(t===F.UNSIGNED_BYTE)return n.UNSIGNED_BYTE;if(t===F.UNSIGNED_SHORT_5_6_5)return n.UNSIGNED_SHORT_5_6_5;if(t===F.UNSIGNED_SHORT_4_4_4_4)return n.UNSIGNED_SHORT_4_4_4_4;if(t===F.UNSIGNED_SHORT_5_5_5_1)return n.UNSIGNED_SHORT_5_5_5_1;if(r){if(t===F.UNSIGNED_SHORT)return n.UNSIGNED_SHORT;if(t===F.UNSIGNED_INT)return n.UNSIGNED_INT;if(t===F.UNSIGNED_INT_24_8)return n.UNSIGNED_INT_24_8;if(t===F.FLOAT)return n.FLOAT;if(t===F.HALF_FLOAT)return n.HALF_FLOAT;if(t===F.FLOAT_32_UNSIGNED_INT_24_8_REV)return n.FLOAT_32_UNSIGNED_INT_24_8_REV;if(t===F.BYTE)return n.BYTE;if(t===F.SHORT)return n.SHORT;if(t===F.INT)return n.INT}else{if(t===F.UNSIGNED_SHORT||t===F.UNSIGNED_INT||t===F.UNSIGNED_INT_24_8){if(!(e=i.getExtension("WEBGL_depth_texture")))return console.warn("extension WEBGL_depth_texture is not support."),null;if(t===F.UNSIGNED_SHORT)return n.UNSIGNED_SHORT;if(t===F.UNSIGNED_INT)return n.UNSIGNED_INT;if(t===F.UNSIGNED_INT_24_8)return e.UNSIGNED_INT_24_8_WEBGL}if(t===F.FLOAT)return(e=i.getExtension("OES_texture_float"))?n.FLOAT:(console.warn("extension OES_texture_float is not support."),null);if(t===F.HALF_FLOAT)return(e=i.getExtension("OES_texture_half_float"))?e.HALF_FLOAT_OES:(console.warn("extension OES_texture_half_float is not support."),null)}return void 0!==n[t]?n[t]:t},e.getGLFormat=function(t){var e,n=this._gl,i=this._capabilities;if(t===O.RGB)return n.RGB;if(t===O.RGBA)return n.RGBA;if(t===O.ALPHA)return n.ALPHA;if(t===O.LUMINANCE)return n.LUMINANCE;if(t===O.LUMINANCE_ALPHA)return n.LUMINANCE_ALPHA;if(t===O.DEPTH_COMPONENT)return n.DEPTH_COMPONENT;if(t===O.DEPTH_STENCIL)return n.DEPTH_STENCIL;if(t===O.RED)return n.RED;if(t===O.RED_INTEGER)return n.RED_INTEGER;if(t===O.RG)return n.RG;if(t===O.RG_INTEGER)return n.RG_INTEGER;if(t===O.RGB_INTEGER)return n.RGB_INTEGER;if(t===O.RGBA_INTEGER)return n.RGBA_INTEGER;if(t===O.RGB_S3TC_DXT1||t===O.RGBA_S3TC_DXT1||t===O.RGBA_S3TC_DXT3||t===O.RGBA_S3TC_DXT5){if(!(e=i.getExtension("WEBGL_compressed_texture_s3tc")))return console.warn("extension WEBGL_compressed_texture_s3tc is not support."),null;if(t===O.RGB_S3TC_DXT1)return e.COMPRESSED_RGB_S3TC_DXT1_EXT;if(t===O.RGBA_S3TC_DXT1)return e.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(t===O.RGBA_S3TC_DXT3)return e.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(t===O.RGBA_S3TC_DXT5)return e.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(t===O.RGB_PVRTC_4BPPV1||t===O.RGB_PVRTC_2BPPV1||t===O.RGBA_PVRTC_4BPPV1||t===O.RGBA_PVRTC_2BPPV1){if(!(e=i.getExtension("WEBGL_compressed_texture_pvrtc")))return console.warn("extension WEBGL_compressed_texture_pvrtc is not support."),null;if(t===O.RGB_PVRTC_4BPPV1)return e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(t===O.RGB_PVRTC_2BPPV1)return e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(t===O.RGBA_PVRTC_4BPPV1)return e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(t===O.RGBA_PVRTC_2BPPV1)return e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}return t===O.RGB_ETC1?(e=i.getExtension("WEBGL_compressed_texture_etc1"))?e.COMPRESSED_RGB_ETC1_WEBGL:(console.warn("extension WEBGL_compressed_texture_etc1 is not support."),null):t===O.RGBA_ASTC_4x4?(e=i.getExtension("WEBGL_compressed_texture_astc"))?e.COMPRESSED_RGBA_ASTC_4x4_KHR:(console.warn("extension WEBGL_compressed_texture_astc is not support."),null):t===O.RGBA_BPTC?(e=i.getExtension("EXT_texture_compression_bptc"))?e.COMPRESSED_RGBA_BPTC_UNORM_EXT:(console.warn("extension EXT_texture_compression_bptc is not support."),null):void 0!==n[t]?n[t]:t},e.getGLInternalFormat=function(t){var e,n=this._gl,i=this._capabilities,r=i.version>=2;if(t===O.RGBA4)return n.RGBA4;if(t===O.RGB5_A1)return n.RGB5_A1;if(t===O.DEPTH_COMPONENT16)return n.DEPTH_COMPONENT16;if(t===O.STENCIL_INDEX8)return n.STENCIL_INDEX8;if(t===O.DEPTH_STENCIL)return n.DEPTH_STENCIL;if(r){if(t===O.R8)return n.R8;if(t===O.RG8)return n.RG8;if(t===O.RGB8)return n.RGB8;if(t===O.RGBA8)return n.RGBA8;if(t===O.DEPTH_COMPONENT24)return n.DEPTH_COMPONENT24;if(t===O.DEPTH_COMPONENT32F)return n.DEPTH_COMPONENT32F;if(t===O.DEPTH24_STENCIL8)return n.DEPTH24_STENCIL8;if(t===O.DEPTH32F_STENCIL8)return n.DEPTH32F_STENCIL8;if(t===O.R16F||t===O.RG16F||t===O.RGB16F||t===O.RGBA16F||t===O.R32F||t===O.RG32F||t===O.RGB32F||t===O.RGBA32F){if(!(e=i.getExtension("EXT_color_buffer_float")))return console.warn("extension EXT_color_buffer_float is not support."),null;if(t===O.R16F)return n.R16F;if(t===O.RG16F)return n.RG16F;if(t===O.RGB16F)return n.RGB16F;if(t===O.RGBA16F)return n.RGBA16F;if(t===O.R32F)return n.R32F;if(t===O.RG32F)return n.RG32F;if(t===O.RGB32F)return n.RGB32F;if(t===O.RGBA32F)return n.RGBA32F}}else if(t===O.RGBA32F||t===O.RGB32F){if(!(e=i.getExtension("WEBGL_color_buffer_float")))return console.warn("extension WEBGL_color_buffer_float is not support."),null;if(t===O.RGBA32F)return e.RGBA32F_EXT;if(t===O.RGB32F)return e.RGB32F_EXT}return void 0!==n[t]?n[t]:t},t}();function Si(t,e,n,i){var r=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(var o=0;o=this._capabilities.maxTextures&&console.warn("trying to use "+t+" texture units while this GPU supports only "+this._capabilities.maxTextures),t},n.resetTextureUnits=function(){this._usedTextureUnits=0},n.setTexture2D=function(t,e){var n=this._gl,i=this._state,r=this._capabilities,a=this._constants;void 0!==e&&(e=n.TEXTURE0+e);var o=this.get(t);if(t.image&&o.__version!==t.version&&(!t.image.rtt||void 0===e)&&!o.__external){void 0===o.__webglTexture&&(t.addEventListener("dispose",this._onTextureDispose),o.__webglTexture=n.createTexture()),i.activeTexture(e),i.bindTexture(n.TEXTURE_2D,o.__webglTexture);var s=t.image,u=Di(s);u&&(s=Li(s,r.maxTextureSize),bi(t)&&!1===Ni(s)&&r.version<2&&(s=Pi(s)));var l=!Ni(s)&&r.version<2;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,t.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,n.NONE),this._setTextureParameters(t,l);var c,h=a.getGLFormat(t.format),d=a.getGLType(t.type),f=null!==t.internalformat?a.getGLInternalFormat(t.internalformat):Ci(n,r,h,d),p=t.mipmaps;if(u)if(p.length>0&&!l){for(var _=0,v=p.length;_0&&!l){for(var m=s.isCompressed,g=0,E=p.length;g0&&!u){for(var E=0,S=v.length;E0&&!u){for(var M=g.isCompressed,T=0,y=v.length;T=2&&(void 0!==s[6]?(n.texParameteri(o,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(o,n.TEXTURE_COMPARE_FUNC,s[6])):n.texParameteri(o,n.TEXTURE_COMPARE_MODE,n.NONE))},n._generateMipmap=function(t,e,n,i){this._gl.generateMipmap(t),this.get(e).__maxMipLevel=Math.log(Math.max(n,i))*Math.LOG2E},e}(wi);function bi(t){return t.wrapS!==U.CLAMP_TO_EDGE||t.wrapT!==U.CLAMP_TO_EDGE||t.minFilter!==I.NEAREST&&t.minFilter!==I.LINEAR}function Ri(t){return t===I.NEAREST||t===I.NEAREST_MIPMAP_LINEAR||t===I.NEAREST_MIPMAP_NEAREST?I.NEAREST:I.LINEAR}function Ni(t){return Qt(t.width)&&Qt(t.height)}function Pi(t){if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){var e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return e.width=Zt(t.width),e.height=Zt(t.height),e.getContext("2d").drawImage(t,0,0,e.width,e.height),console.warn("image is not power of two ("+t.width+"x"+t.height+"). Resized to "+e.width+"x"+e.height,t),e}return t}function Li(t,e){if(t.width>e||t.height>e){var n=e/Math.max(t.width,t.height),i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return i.width=Math.floor(t.width*n),i.height=Math.floor(t.height*n),i.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,i.width,i.height),console.warn("image is too big ("+t.width+"x"+t.height+"). Resized to "+i.width+"x"+i.height,t),i}return t}function Ci(t,e,n,i){if(!1===e.version>=2)return n;var r=n;return n===t.RED&&(i===t.FLOAT&&(r=t.R32F),i===t.HALF_FLOAT&&(r=t.R16F),i===t.UNSIGNED_BYTE&&(r=t.R8)),n===t.RG&&(i===t.FLOAT&&(r=t.RG32F),i===t.HALF_FLOAT&&(r=t.RG16F),i===t.UNSIGNED_BYTE&&(r=t.RG8)),n===t.RGB&&(i===t.FLOAT&&(r=t.RGB32F),i===t.HALF_FLOAT&&(r=t.RGB16F),i===t.UNSIGNED_BYTE&&(r=t.RGB8)),n===t.RGBA&&(i===t.FLOAT&&(r=t.RGBA32F),i===t.HALF_FLOAT&&(r=t.RGBA16F),i===t.UNSIGNED_BYTE&&(r=t.RGBA8),i===t.UNSIGNED_SHORT_4_4_4_4&&(r=t.RGBA4),i===t.UNSIGNED_SHORT_5_5_5_1&&(r=t.RGB5_A1)),n!==t.DEPTH_COMPONENT&&n!==t.DEPTH_STENCIL||(r=t.DEPTH_COMPONENT16,i===t.FLOAT&&(r=t.DEPTH_COMPONENT32F),i===t.UNSIGNED_INT&&(r=t.DEPTH_COMPONENT24),i===t.UNSIGNED_INT_24_8&&(r=t.DEPTH24_STENCIL8),i===t.FLOAT_32_UNSIGNED_INT_24_8_REV&&(r=t.DEPTH32F_STENCIL8)),r!==t.R16F&&r!==t.R32F&&r!==t.RG16F&&r!==t.RG32F&&r!==t.RGB16F&&r!==t.RGB32F&&r!==t.RGBA16F&&r!==t.RGBA32F||e.getExtension("EXT_color_buffer_float"),r}function Di(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap}var Oi,Fi=function(t){function e(e,n,i,r){var a;(a=t.call(this,e)||this)._gl=n,a._capabilities=i,a._constants=r;var o=u(a);return a._onRenderBufferDispose=function t(e){var i=e.target;i.removeEventListener("dispose",t);var r=o.get(i);r.__webglRenderbuffer&&!r.__external&&n.deleteRenderbuffer(r.__webglRenderbuffer),o.delete(i)},a}i(e,t);var n=e.prototype;return n.setRenderBuffer=function(t){var e=this._gl,n=this._capabilities,i=this._constants,r=this.get(t);if(void 0===r.__webglRenderbuffer){t.addEventListener("dispose",this._onRenderBufferDispose),r.__webglRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,r.__webglRenderbuffer);var a=i.getGLInternalFormat(t.format);t.multipleSampling>0?(n.version<2&&console.error("render buffer multipleSampling is not support in webgl 1.0."),e.renderbufferStorageMultisample(e.RENDERBUFFER,Math.min(t.multipleSampling,n.maxSamples),a,t.width,t.height)):e.renderbufferStorage(e.RENDERBUFFER,a,t.width,t.height)}else e.bindRenderbuffer(e.RENDERBUFFER,r.__webglRenderbuffer);return r},n.setRenderBufferExternal=function(t,e){var n=this._gl,i=this.get(t);i.__external||(i.__webglRenderbuffer?n.deleteRenderbuffer(i.__webglRenderbuffer):t.addEventListener("dispose",this._onRenderBufferDispose)),i.__webglRenderbuffer=e,i.__external=!0},e}(wi),Ii=function(t){function e(e,n,i,r,a,o,s){var l;(l=t.call(this,e)||this)._gl=n,l._state=i,l._capabilities=r,l._textures=a,l._renderBuffers=o,l._constants=s;var c=u(l);return l._onRenderTargetDispose=function t(e){var r=e.target;r.removeEventListener("dispose",t);var a=c.get(r);a.__webglFramebuffer&&n.deleteFramebuffer(a.__webglFramebuffer),c.delete(r),i.currentRenderTarget===r&&(i.currentRenderTarget=null)},l}i(e,t);var n=e.prototype;return n._setupRenderTarget=function(t){var e=this._gl,n=this._state,i=this._textures,r=this._renderBuffers,a=this._capabilities,o=this.get(t);t.addEventListener("dispose",this._onRenderTargetDispose);var s=e.createFramebuffer(),u=[];for(var l in o.__webglFramebuffer=s,o.__drawBuffers=u,t.isRenderTargetCube&&(o.__currentActiveCubeFace=t.activeCubeFace),e.bindFramebuffer(e.FRAMEBUFFER,s),t._attachments){var c=Ui[l];c===e.DEPTH_ATTACHMENT||c===e.DEPTH_STENCIL_ATTACHMENT?a.version<2&&!a.getExtension("WEBGL_depth_texture")&&console.warn("WebGLRenderTargets: extension WEBGL_depth_texture is not support."):c!==e.STENCIL_ATTACHMENT&&u.push(c);var h=t._attachments[l];if(h.isTexture2D){var d=i.setTexture2D(h);e.framebufferTexture2D(e.FRAMEBUFFER,c,e.TEXTURE_2D,d.__webglTexture,0),n.bindTexture(e.TEXTURE_2D,null)}else if(h.isTextureCube){var f=i.setTextureCube(h);e.framebufferTexture2D(e.FRAMEBUFFER,c,e.TEXTURE_CUBE_MAP_POSITIVE_X+t.activeCubeFace,f.__webglTexture,0),n.bindTexture(e.TEXTURE_CUBE_MAP,null)}else{var p=r.setRenderBuffer(h);e.framebufferRenderbuffer(e.FRAMEBUFFER,c,e.RENDERBUFFER,p.__webglRenderbuffer)}}u.sort(Bi),a.version>=2?e.drawBuffers(u):a.getExtension("WEBGL_draw_buffers")&&a.getExtension("WEBGL_draw_buffers").drawBuffersWEBGL(u)},n.setRenderTarget=function(t){var e,n=this._gl,i=this._state,r=this._textures;if(i.currentRenderTarget!==t&&(t.isRenderTargetBack?n.bindFramebuffer(n.FRAMEBUFFER,null):void 0===(e=this.get(t)).__webglFramebuffer?this._setupRenderTarget(t):n.bindFramebuffer(n.FRAMEBUFFER,e.__webglFramebuffer),i.currentRenderTarget=t),t.isRenderTargetCube){e=this.get(t);var a=t.activeCubeFace;if(e.__currentActiveCubeFace!==a){for(var o in t._attachments){var s=t._attachments[o];if(s.isTextureCube){var u=r.get(s);n.framebufferTexture2D(n.FRAMEBUFFER,Ui[o],n.TEXTURE_CUBE_MAP_POSITIVE_X+a,u.__webglTexture,0)}}e.__currentActiveCubeFace=a}}},n.blitRenderTarget=function(t,e,n,i,r){void 0===n&&(n=!0),void 0===i&&(i=!0),void 0===r&&(r=!0);var a=this._gl,o=this._capabilities;if(o.version<2)console.warn("WebGLRenderTargets: blitFramebuffer not support by WebGL"+o.version);else{var s=this.get(t).__webglFramebuffer,u=this.get(e).__webglFramebuffer;a.bindFramebuffer(a.READ_FRAMEBUFFER,s),a.bindFramebuffer(a.DRAW_FRAMEBUFFER,u);var l=0;n&&(l|=a.COLOR_BUFFER_BIT),i&&(l|=a.DEPTH_BUFFER_BIT),r&&(l|=a.STENCIL_BUFFER_BIT),a.blitFramebuffer(0,0,t.width,t.height,0,0,e.width,e.height,l,a.NEAREST)}},n.readRenderTargetPixels=function(t,e,n,i,r){var a=this._gl,o=this._state,s=this._constants,u=o.currentRenderTarget;if(u&&u.texture){if(t>=0&&t<=u.width-n&&e>=0&&e<=u.height-i){var l=s.getGLType(u.texture.type),c=s.getGLFormat(u.texture.format);a.readPixels(t,e,n,i,c,l,r)}}else console.warn("WebGLRenderTargets.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not bound or texture not attached.")},n.updateRenderTargetMipmap=function(t){var e=this._gl,n=this._state,i=this._capabilities,r=t.texture;if(r.generateMipmaps&&r.minFilter!==I.NEAREST&&r.minFilter!==I.LINEAR&&(function(t){return Qt(t.width)&&Qt(t.height)}(t)||i.version>=2)){var a=e.TEXTURE_2D;r.isTextureCube&&(a=e.TEXTURE_CUBE_MAP),r.isTexture3D&&(a=e.TEXTURE_3D);var o=this._textures.get(r).__webglTexture;n.bindTexture(a,o),e.generateMipmap(a),n.bindTexture(a,null)}},e}(wi),Ui=((Oi={})[W.COLOR_ATTACHMENT0]=36064,Oi[W.COLOR_ATTACHMENT1]=36065,Oi[W.COLOR_ATTACHMENT2]=36066,Oi[W.COLOR_ATTACHMENT3]=36067,Oi[W.COLOR_ATTACHMENT4]=36068,Oi[W.COLOR_ATTACHMENT5]=36069,Oi[W.COLOR_ATTACHMENT6]=36070,Oi[W.COLOR_ATTACHMENT7]=36071,Oi[W.COLOR_ATTACHMENT8]=36072,Oi[W.COLOR_ATTACHMENT9]=36073,Oi[W.COLOR_ATTACHMENT10]=36074,Oi[W.COLOR_ATTACHMENT11]=36075,Oi[W.COLOR_ATTACHMENT12]=36076,Oi[W.COLOR_ATTACHMENT13]=36077,Oi[W.COLOR_ATTACHMENT14]=36078,Oi[W.COLOR_ATTACHMENT15]=36079,Oi[W.DEPTH_ATTACHMENT]=36096,Oi[W.STENCIL_ATTACHMENT]=36128,Oi[W.DEPTH_STENCIL_ATTACHMENT]=33306,Oi);function Bi(t,e){return t-e}var Gi=function(t){function e(e,n,i){var r;return(r=t.call(this,e)||this)._gl=n,r._capabilities=i,r}i(e,t);var n=e.prototype;return n.setBuffer=function(t,e,n){var i=this.get(t),r=void 0===i.glBuffer;(r||i.version!==t.version)&&(n&&n.reset(),r||i.__external?this._createGLBuffer(i,t,e):(this._updateGLBuffer(i.glBuffer,t,e),i.version=t.version))},n.removeBuffer=function(t){var e=this._gl,n=this.get(t);n.glBuffer&&!n.__external&&e.deleteBuffer(n.glBuffer),this.delete(t)},n.setBufferExternal=function(t,e){var n=this._gl,i=this.get(t);i.__external||i.glBuffer&&n.deleteBuffer(i.glBuffer);var r=zi(n,t.array);i.glBuffer=e,i.type=r,i.bytesPerElement=t.array.BYTES_PER_ELEMENT,i.version=t.version,i.__external=!0},n._createGLBuffer=function(t,e,n){var i=this._gl,r=e.array,a=e.usage,o=i.createBuffer();i.bindBuffer(n,o),i.bufferData(n,r,a),e.onUploadCallback();var s=zi(i,r);t.glBuffer=o,t.type=s,t.bytesPerElement=r.BYTES_PER_ELEMENT,t.version=e.version,t.__external=!1},n._updateGLBuffer=function(t,e,n){var i=this._gl,r=this._capabilities,a=e.array,o=e.updateRange;i.bindBuffer(n,t),-1===o.count?i.bufferSubData(n,0,a):(r.version>=2?i.bufferSubData(n,o.offset*a.BYTES_PER_ELEMENT,a,o.offset,o.count):i.bufferSubData(n,o.offset*a.BYTES_PER_ELEMENT,a.subarray(o.offset,o.offset+o.count)),o.count=-1)},e}(wi);function zi(t,e){var n;return e instanceof Float32Array?n=t.FLOAT:e instanceof Float64Array?console.warn("Unsupported data buffer format: Float64Array."):n=e instanceof Uint16Array?t.UNSIGNED_SHORT:e instanceof Int16Array?t.SHORT:e instanceof Uint32Array?t.UNSIGNED_INT:e instanceof Int32Array?t.INT:e instanceof Int8Array?t.BYTE:e instanceof Uint8Array?t.UNSIGNED_BYTE:t.FLOAT,n}var Hi=function(t){function e(e,n,i,r){var a;(a=t.call(this,e)||this)._gl=n,a._buffers=i,a._vertexArrayBindings=r;var o=u(a);return a._onGeometryDispose=function t(e){var n=e.target,a=o.get(n);for(var s in n.removeEventListener("dispose",t),null!==n.index&&i.removeBuffer(n.index.buffer),n.attributes)i.removeBuffer(n.attributes[s].buffer);for(var u in n.morphAttributes)for(var l=n.morphAttributes[u],c=0,h=l.length;c=2,a._vaoExt=i.getExtension("OES_vertex_array_object"),a._currentGeometryProgram="",a._currentVAO=null,a}i(e,t);var n=e.prototype;return n.setup=function(t,e,n){if(t.morphTargetInfluences)this.reset(),this._setupVertexAttributes(n,e),this._currentGeometryProgram="";else if(this._isWebGL2||this._vaoExt){var i=this.get(e);void 0===i._vaos&&(i._vaos={});var r=i._vaos[n.id];r||(r=i._vaos[n.id]={version:-1,object:this._createVAO()}),this._bindVAO(r.object),r.version!==e.version&&(this._setupVertexAttributes(n,e),r.version=e.version)}else{var a=n.id+"_"+e.id+"_"+e.version;a!==this._currentGeometryProgram&&(this._setupVertexAttributes(n,e),this._currentGeometryProgram=a)}},n.releaseByGeometry=function(t){var e=this.get(t);if(e._vaos){for(var n in e._vaos){var i=e[n];i&&this._disposeVAO(i.object)}e._vaos={}}},n.reset=function(t){(null!==this._currentVAO||t)&&(this._isWebGL2?this._gl.bindVertexArray(null):this._vaoExt&&this._vaoExt.bindVertexArrayOES(null),this._currentVAO=null),""!==this._currentGeometryProgram&&(this._currentGeometryProgram="")},n._createVAO=function(){return this._isWebGL2?this._gl.createVertexArray():this._vaoExt?this._vaoExt.createVertexArrayOES():null},n._bindVAO=function(t){this._currentVAO!==t&&(this._isWebGL2?this._gl.bindVertexArray(t):this._vaoExt&&this._vaoExt.bindVertexArrayOES(t),this._currentVAO=t)},n._disposeVAO=function(t){this._isWebGL2?this._gl.deleteVertexArray(t):this._vaoExt&&this._vaoExt.deleteVertexArrayOES(t)},n._setupVertexAttributes=function(t,e){var n=this._gl,i=this._isWebGL2,r=t.getAttributes(),a=this._capabilities,o=this._buffers;for(var s in r){var u=r[s],l=e.getAttribute(s);if(l){var c=l.size;u.count!==c&&console.warn("WebGLVertexArrayBindings: attribute "+s+" size not match! "+u.count+" : "+c);var h=l.buffer,d=o.get(h),f=d.type;u.format;for(var p=0,_=u.locationSize;p<_;p++)n.enableVertexAttribArray(u.location+p);if(l.divisor>0)for(var v=0,m=u.locationSize;v1?n.deleteQuery(a._webglQuery):o.deleteQueryEXT(a._webglQuery)),s.delete(r)},a._typeToGL=((r={})[Y.ANY_SAMPLES_PASSED]=35887,r[Y.ANY_SAMPLES_PASSED_CONSERVATIVE]=36202,r[Y.TIME_ELAPSED]=35007,r),a}i(e,t);var n=e.prototype;return n._get=function(t){var e=this._capabilities,n=this.get(t);return void 0===n._webglQuery&&(t.addEventListener("dispose",this._onQueryDispose),n._webglQuery=e.version>1?this._gl.createQuery():e.timerQuery.createQueryEXT(),n._target=null,n._result=null),n},n.begin=function(t,e){var n=this._capabilities,i=this._typeToGL,r=this._get(t);n.version>1?this._gl.beginQuery(i[e],r._webglQuery):n.timerQuery.beginQueryEXT(i[e],r._webglQuery),r._target=e,r._result=null},n.end=function(t){var e=this._capabilities,n=this._typeToGL,i=this._get(t);e.version>1?this._gl.endQuery(n[i._target]):e.timerQuery.endQueryEXT(n[i._target])},n.counter=function(t){var e=this._capabilities.timerQuery,n=this._get(t);e.queryCounterEXT(n._webglQuery,e.TIMESTAMP_EXT),n._target=e.TIMESTAMP_EXT,n._result=null},n.isResultAvailable=function(t){var e=this._gl,n=this._capabilities,i=n.timerQuery,r=this._get(t);return n.version>1?e.getQueryParameter(r._webglQuery,e.QUERY_RESULT_AVAILABLE):i.getQueryObjectEXT(r._webglQuery,i.QUERY_RESULT_AVAILABLE)},n.isTimerDisjoint=function(){return this._gl.getParameter(this._capabilities.timerQuery.GPU_DISJOINT_EXT)},n.getResult=function(t){var e=this._gl,n=this._capabilities,i=n.timerQuery,r=this._get(t);return null===r._result&&(n.version>1?r._result=e.getQueryParameter(r._webglQuery,e.QUERY_RESULT):r._result=i.getQueryObjectEXT(r._webglQuery,i.QUERY_RESULT_EXT)),r._result},e}(wi),Wi=new Wt,ji=new m,Yi=new WeakMap,qi=new Float32Array(8),Qi=new Float32Array([]);function Zi(t){return t.geometry}function Ki(t){return t.material}function Ji(t){return!0}function $i(){}var tr=0,er=function(){function t(t){var e=tr++,n=new mi(t),i=new Ei(t,n),r=new xi(t,n),a=new Ai(e,t,r,n,i),o=new Fi(e,t,n,i),s=new Ii(e,t,r,n,a,o,i),u=new Gi(e,t,n),l=new ki(e,t,n,u),c=new Hi(e,t,u,l),h=new ai(t,r,n),d=new Vi(e,h),f=new Xi(e,t,n);this.id=e,this.gl=t,this.capabilities=n,this._textures=a,this._renderBuffers=o,this._renderTargets=s,this._buffers=u,this._geometries=c,this._programs=h,this._materials=d,this._state=r,this._vertexArrayBindings=l,this._queries=f}var e=t.prototype;return e.clear=function(t,e,n){var i=this.gl,r=0;(void 0===t||t)&&(r|=i.COLOR_BUFFER_BIT),(void 0===e||e)&&(r|=i.DEPTH_BUFFER_BIT),(void 0===n||n)&&(r|=i.STENCIL_BUFFER_BIT),r>0&&i.clear(r)},e.setClearColor=function(t,e,n,i,r){this._state.colorBuffer.setClear(t,e,n,i,r)},e.getClearColor=function(){return this._state.colorBuffer.getClear()},e.setRenderTarget=function(t){this._renderTargets.setRenderTarget(t)},e.getRenderTarget=function(){return this._state.currentRenderTarget},e.blitRenderTarget=function(t,e,n,i,r){void 0===n&&(n=!0),void 0===i&&(i=!0),void 0===r&&(r=!0),this._renderTargets.blitRenderTarget(t,e,n,i,r)},e.readRenderTargetPixels=function(t,e,n,i,r){this._renderTargets.readRenderTargetPixels(t,e,n,i,r)},e.updateRenderTargetMipmap=function(t){this._renderTargets.updateRenderTargetMipmap(t)},e.setTextureExternal=function(t,e){this._textures.setTextureExternal(t,e)},e.setRenderBufferExternal=function(t,e){this._renderBuffers.setRenderBufferExternal(t,e)},e.setBufferExternal=function(t,e){this._buffers.setBufferExternal(t,e)},e.resetVertexArrayBindings=function(t){this._vertexArrayBindings.reset(t)},e.resetState=function(){this._state.reset()},e.beginQuery=function(t,e){this._queries.begin(t,e)},e.endQuery=function(t){this._queries.end(t)},e.queryCounter=function(t){this._queries.counter(t)},e.isTimerQueryDisjoint=function(t){return this._queries.isTimerDisjoint(t)},e.isQueryResultAvailable=function(t){return this._queries.isResultAvailable(t)},e.getQueryResult=function(t){return this._queries.getResult(t)},e.render=function(t,e,n){var i=this._state,r=this.capabilities,a=this._vertexArrayBindings,o=this._textures,s=n.getGeometry||Zi,u=n.getMaterial||Ki,l=n.beforeRender||$i,c=n.afterRender||$i,h=n.ifRender||Ji,d=n.renderInfo,f=e.scene,p=e.lights,_=e.camera,v=i.currentRenderTarget;if(h(t)){var m=t.object,g=u.call(this,t),E=s.call(this,t),S=t.group,M=g.fog?f.fog:null,T=void 0!==g.envMap?g.envMap||f.environment:null,y=f.clippingPlanesData,x=f.numClippingPlanes;g.clippingPlanes&&g.clippingPlanes.length>0&&(Qi.length<4*g.clippingPlanes.length&&(Qi=new Float32Array(4*g.clippingPlanes.length)),y=f.setClippingPlanesData(g.clippingPlanes,Qi),x=g.clippingPlanes.length),m.onBeforeRender(t,g),l.call(this,t,g);var w=this._materials.setMaterial(g);if(!1===g.needsUpdate)if(void 0===w.program)g.needsUpdate=!0;else if(w.fog!==M)g.needsUpdate=!0;else if(w.envMap!==T)g.needsUpdate=!0;else if(w.numClippingPlanes!==x)g.needsUpdate=!0;else if(w.logarithmicDepthBuffer!==f.logarithmicDepthBuffer)g.needsUpdate=!0;else if(e.outputEncoding!==w.outputEncoding||e.gammaFactor!==w.gammaFactor)g.needsUpdate=!0;else if(r.version>1&&f.disableShadowSampler!==w.disableShadowSampler)g.needsUpdate=!0;else{var A=g.acceptLight&&p.totalNum>0;A!==w.acceptLight?g.needsUpdate=!0:A&&(p.hash.compare(w.lightsHash)&&m.receiveShadow===w.receiveShadow&&m.shadowType===w.shadowType||(g.needsUpdate=!0))}if(g.needsUpdate){var b=w.program;w.program=this._programs.getProgram(g,m,e,!0),b&&this._programs.releaseProgram(b),w.fog=M,w.envMap=T,w.logarithmicDepthBuffer=f.logarithmicDepthBuffer,w.acceptLight=g.acceptLight,w.lightsHash=p.hash.copyTo(w.lightsHash),w.receiveShadow=m.receiveShadow,w.shadowType=m.shadowType,w.numClippingPlanes=x,w.outputEncoding=e.outputEncoding,w.gammaFactor=e.gammaFactor,w.disableShadowSampler=f.disableShadowSampler,g.needsUpdate=!1}var R=w.program;if(void 0!==R.program){i.setProgram(R),this._geometries.setGeometry(E),m.morphTargetInfluences&&this._updateMorphtargets(m,E,R),a.setup(m,E,R);var N=!1;R.lightId===p.id&&R.lightVersion===p.version||(N=!0,R.lightId=p.id,R.lightVersion=p.version);var P=!1;R.cameraId===_.id&&R.cameraVersion===_.version||(P=!0,R.cameraId=_.id,R.cameraVersion=_.version);var L=!1;R.sceneId===f.id&&R.sceneVersion===f.version||(L=!0,R.sceneId=f.id,R.sceneVersion=f.version);var C=R.getUniforms();g.acceptLight&&this._uploadLights(C,p,f.disableShadowSampler,N),m.isSkinnedMesh&&this._uploadSkeleton(C,m,f);for(var D=0,O=C.seq.length;D0&&i&&t.set("u_Hemi",e.hemisphere),e.directsNum>0&&(i&&t.set("u_Directional",e.directional),e.directShadowNum>0&&(i&&t.set("u_DirectionalShadow",e.directionalShadow),t.has("directionalShadowMap")&&(this.capabilities.version>=2&&!n?t.set("directionalShadowMap",e.directionalShadowDepthMap,r):t.set("directionalShadowMap",e.directionalShadowMap,r),t.set("directionalShadowMatrix",e.directionalShadowMatrix)),t.has("directionalDepthMap")&&t.set("directionalDepthMap",e.directionalShadowMap,r))),e.pointsNum>0&&(i&&t.set("u_Point",e.point),e.pointShadowNum>0&&(i&&t.set("u_PointShadow",e.pointShadow),t.has("pointShadowMap")&&(t.set("pointShadowMap",e.pointShadowMap,r),t.set("pointShadowMatrix",e.pointShadowMatrix)))),e.spotsNum>0&&(i&&t.set("u_Spot",e.spot),e.spotShadowNum>0&&(i&&t.set("u_SpotShadow",e.spotShadow),t.has("spotShadowMap")&&(this.capabilities.version>=2&&!n?t.set("spotShadowMap",e.spotShadowDepthMap,r):t.set("spotShadowMap",e.spotShadowMap,r),t.set("spotShadowMatrix",e.spotShadowMatrix)),t.has("spotDepthMap")&&t.set("spotDepthMap",e.spotShadowMap,r)))},e._uploadSkeleton=function(t,e,n){if(e.skeleton&&e.skeleton.bones.length>0){var i=e.skeleton,r=this.capabilities;r.maxVertexTextures>0&&(r.getExtension("OES_texture_float")||r.version>=2)?(void 0===i.boneTexture&&i.generateBoneTexture(r.version>=2),t.set("boneTexture",i.boneTexture,this._textures),t.set("boneTextureSize",i.boneTexture.image.width)):t.set("boneMatrices",i.boneMatrices),t.set("bindMatrix",e.bindMatrix.elements),ji.copy(e.bindMatrixInverse),n.useAnchorMatrix&&ji.multiply(n.anchorMatrix),t.set("bindMatrixInverse",ji.elements)}},e._updateMorphtargets=function(t,e,n){var i=t.morphTargetInfluences;Yi.has(e)||Yi.set(e,i.slice(0));for(var r=e.morphAttributes.position,a=e.morphAttributes.normal,o=Yi.get(e),s=0;s0&&(r&&e.addAttribute("morphTarget"+l,r[c]),a&&e.addAttribute("morphNormal"+l,a[c]),qi[l]=h,l++)}for(;l<8;l++)qi[l]=0;n.getUniforms().set("morphTargetInfluences",qi)},e._draw=function(t,e,n,i){var r=this.gl,a=this.capabilities,o=this._buffers,s=null!==t.index,u=0,l=s?t.index.buffer.count:t.getAttribute("a_Position").buffer.count,c=n?n.start:0,h=n?n.count:1/0;u=Math.max(u,c),l=Math.min(l,h);var d=t.instanceCount,f=d>=0;if(s){var p=o.get(t.index.buffer),_=p.bytesPerElement,v=p.type;if(v===r.UNSIGNED_INT&&a.version<2&&!a.getExtension("OES_element_index_uint")&&console.warn("draw elements type not support UNSIGNED_INT!"),f){if(d>0)if(a.version>=2)r.drawElementsInstanced(e.drawMode,l,v,u*_,d);else{if(!a.getExtension("ANGLE_instanced_arrays"))return void console.warn("no support instanced draw.");a.getExtension("ANGLE_instanced_arrays").drawElementsInstancedANGLE(e.drawMode,l,v,u*_,d)}}else r.drawElements(e.drawMode,l,v,u*_)}else if(f){if(d>0)if(a.version>=2)r.drawArraysInstanced(e.drawMode,u,l,d);else{if(!a.getExtension("ANGLE_instanced_arrays"))return void console.warn("no support instanced draw.");a.getExtension("ANGLE_instanced_arrays").drawArraysInstancedANGLE(e.drawMode,u,l,d)}}else r.drawArrays(e.drawMode,u,l);i&&i.update(l,e.drawMode,d<0?1:d)},t}(),nr=function(){function t(t){this.renderPass=new er(t)}var e=t.prototype;return e.renderScene=function(t,e){for(var n,i=t.getRenderStates(e),r=t.getRenderQueue(e),a=0,o=r.layerList.length;a0?1:-1,d.push(R.x,R.y,R.z),f.push(L/u),f.push(1-N/m),A+=1}for(var D=0;D65536?new Uint32Array(c):new Uint16Array(c),1))),s.addAttribute("a_Position",new an(new on(new Float32Array(h),3))),s.addAttribute("a_Normal",new an(new on(new Float32Array(d),3))),s.addAttribute("a_Uv",new an(new on(new Float32Array(f),2))),s.computeBoundingBox(),s.computeBoundingSphere(),s}return i(e,t),e}(fn),or=function(t){function e(e,n,i,r,a,o,s,l){var c;void 0===e&&(e=1),void 0===n&&(n=1),void 0===i&&(i=1),void 0===r&&(r=8),void 0===a&&(a=1),void 0===o&&(o=!1),void 0===s&&(s=0),void 0===l&&(l=2*Math.PI);var h=u(c=t.call(this)||this);r=Math.floor(r),a=Math.floor(a);var d=[],f=[],p=[],v=[],m=0,g=[],E=i/2,S=0;function M(t){var i,a=m,o=new pt,u=new _,c=0,g=!0===t?e:n,M=!0===t?1:-1;for(i=1;i<=r;i++)f.push(0,E*M,0),p.push(0,M,0),v.push(.5,.5),m++;var T=m;for(i=0;i<=r;i++){var y=i/r*l+s,x=Math.cos(y),w=Math.sin(y);u.x=g*w,u.y=E*M,u.z=g*x,f.push(u.x,u.y,u.z),p.push(0,M,0),o.x=.5*x+.5,o.y=.5*w*M+.5,v.push(o.x,o.y),m++}for(i=0;i0&&M(!0),n>0&&M(!1)),c.setIndex(new an(new on(f.length/3>65536?new Uint32Array(d):new Uint16Array(d),1))),c.addAttribute("a_Position",new an(new on(new Float32Array(f),3))),c.addAttribute("a_Normal",new an(new on(new Float32Array(p),3))),c.addAttribute("a_Uv",new an(new on(new Float32Array(v),2))),c.computeBoundingBox(),c.computeBoundingSphere(),c}return i(e,t),e}(fn),sr=function(t){function e(e,n,i,r,a,o,s){var u;void 0===e&&(e=1),void 0===n&&(n=8),void 0===i&&(i=6),void 0===r&&(r=0),void 0===a&&(a=2*Math.PI),void 0===o&&(o=0),void 0===s&&(s=Math.PI),u=t.call(this)||this,n=Math.max(3,Math.floor(n)),i=Math.max(2,Math.floor(i));var l,c,h=o+s,d=0,f=[],p=new _,v=new _,m=[],g=[],E=[],S=[];for(c=0;c<=i;c++){var M=[],T=c/i,y=0;for(0==c&&0==o?y=.5/n:c==i&&h==Math.PI&&(y=-.5/n),l=0;l<=n;l++){var x=l/n;p.x=-e*Math.cos(r+x*a)*Math.sin(o+T*s),p.y=e*Math.cos(o+T*s),p.z=e*Math.sin(r+x*a)*Math.sin(o+T*s),g.push(p.x,p.y,p.z),v.copy(p).normalize(),E.push(v.x,v.y,v.z),S.push(x+y,1-T),M.push(d++)}f.push(M)}for(c=0;c0)&&m.push(w,A,R),(c!==i-1||h65536?new Uint32Array(m):new Uint16Array(m),1))),u.addAttribute("a_Position",new an(new on(new Float32Array(g),3))),u.addAttribute("a_Normal",new an(new on(new Float32Array(E),3))),u.addAttribute("a_Uv",new an(new on(new Float32Array(S),2))),u.computeBoundingBox(),u.computeBoundingSphere(),u}return i(e,t),e}(fn),ur=function(t){function e(e,n,i,r,a,o){var s;void 0===e&&(e=1),void 0===n&&(n=.4),void 0===i&&(i=64),void 0===r&&(r=8),void 0===a&&(a=2),void 0===o&&(o=3),s=t.call(this)||this,i=Math.floor(i),r=Math.floor(r);var u,l,c=[],h=[],d=[],f=[],p=new _,v=new _,m=new _,g=new _,E=new _,S=new _,M=new _;for(u=0;u<=i;++u){var T=u/i*a*Math.PI*2;for(P(T,a,o,e,m),P(T+.01,a,o,e,g),S.subVectors(g,m),M.addVectors(g,m),E.crossVectors(S,M),M.crossVectors(E,S),E.normalize(),M.normalize(),l=0;l<=r;++l){var y=l/r*Math.PI*2,x=-n*Math.cos(y),w=n*Math.sin(y);p.x=m.x+(x*M.x+w*E.x),p.y=m.y+(x*M.y+w*E.y),p.z=m.z+(x*M.z+w*E.z),h.push(p.x,p.y,p.z),v.subVectors(p,m).normalize(),d.push(v.x,v.y,v.z),f.push(u/i),f.push(l/r)}}for(l=1;l<=i;l++)for(u=1;u<=r;u++){var A=(r+1)*(l-1)+(u-1),b=(r+1)*l+(u-1),R=(r+1)*l+u,N=(r+1)*(l-1)+u;c.push(A,b,N),c.push(b,R,N)}function P(t,e,n,i,r){var a=Math.cos(t),o=Math.sin(t),s=n/e*t,u=Math.cos(s);r.x=i*(2+u)*.5*a,r.y=i*(2+u)*o*.5,r.z=i*Math.sin(s)*.5}return s.setIndex(new an(new on(h.length/3>65536?new Uint32Array(c):new Uint16Array(c),1))),s.addAttribute("a_Position",new an(new on(new Float32Array(h),3))),s.addAttribute("a_Normal",new an(new on(new Float32Array(d),3))),s.addAttribute("a_Uv",new an(new on(new Float32Array(f),2))),s.computeBoundingBox(),s.computeBoundingSphere(),s}return i(e,t),e}(fn),lr=function(t){function e(){var e;return(e=t.call(this)||this).type=b.BASIC,e}return i(e,t),e}(vn),cr=function(t){function e(){var e;return(e=t.call(this)||this).type=b.LAMBERT,e.acceptLight=!0,e}return i(e,t),e}(vn),hr=function(t){function e(){var e;return(e=t.call(this)||this).type=b.LINE,e.lineWidth=1,e.drawMode=k.LINES,e}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.lineWidth=e.lineWidth,this},e}(vn),dr=function(t){function e(){var e;return(e=t.call(this)||this).type=b.MATCAP,e.matcap=null,e}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.matcap=e.matcap,this},e}(vn),fr=function(t){function e(){var e;return(e=t.call(this)||this).type=b.PBR2,e.specular=new gt(1118481),e.glossiness=.5,e.specularMap=null,e.glossinessMap=null,e.acceptLight=!0,e}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.specular=e.specular,this.glossiness=e.glossiness,this.specularMap=e.specularMap,this.glossinessMap=e.glossinessMap,this},e}(vn),pr=function(t){function e(){var e;return(e=t.call(this)||this).type=b.PBR,e.roughness=.5,e.metalness=.5,e.roughnessMap=null,e.metalnessMap=null,e.clearcoat=0,e.clearcoatMap=null,e.clearcoatRoughness=0,e.clearcoatRoughnessMap=null,e.clearcoatNormalScale=new pt(1,1),e.clearcoatNormalMap=null,e.acceptLight=!0,e}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.roughness=e.roughness,this.metalness=e.metalness,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this},e}(vn),_r=function(t){function e(){var e;return(e=t.call(this)||this).type=b.PHONG,e.shininess=30,e.specular=new gt(1118481),e.specularMap=null,e.acceptLight=!0,e}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.shininess=e.shininess,this.specular.copy(e.specular),this.specularMap=e.specularMap,this},e}(vn),vr=function(t){function e(){var e;return(e=t.call(this)||this).type=b.POINT,e.size=1,e.sizeAttenuation=!0,e.drawMode=k.POINTS,e}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this},e}(vn),mr=function(t){function e(e,n){var i;return(i=t.call(this)||this).width=e,i.height=n,i}i(e,t);var n=e.prototype;return n.resize=function(t,e){return(this.width!==t||this.height!==e)&&(this.width=t,this.height=e,!0)},n.dispose=function(){this.dispatchEvent({type:"dispose"})},e}(q);mr.prototype.isRenderTarget=!0;var gr=function(t){function e(e,n,i,r){var a;return void 0===i&&(i=O.RGBA8),void 0===r&&(r=0),(a=t.call(this)||this).width=e,a.height=n,a.format=i,a.multipleSampling=r,a}i(e,t);var n=e.prototype;return n.resize=function(t,e){return(this.width!==t||this.height!==e)&&(this.dispose(),this.width=t,this.height=e,!0)},n.clone=function(){return(new this.constructor).copy(this)},n.copy=function(t){return this.format=t.format,this.multipleSampling=t.multipleSampling,this},n.dispose=function(){this.dispatchEvent({type:"dispose"})},e}(q);gr.prototype.isRenderBuffer=!0;var Er=function(t){function e(e,n){var i;return(i=t.call(this,e,n)||this)._attachments={},i.attach(new Pn,W.COLOR_ATTACHMENT0),i.attach(new gr(e,n,O.DEPTH_STENCIL),W.DEPTH_STENCIL_ATTACHMENT),i}i(e,t);var n=e.prototype;return n.attach=function(t,e){void 0===e&&(e=W.COLOR_ATTACHMENT0),t.isTexture?t.image&&t.image.rtt?t.image.width===this.width&&t.image.height===this.height||(t.version++,t.image.width=this.width,t.image.height=this.height):(t.version++,t.image={rtt:!0,data:null,width:this.width,height:this.height}):t.resize(this.width,this.height),this._attachments[e]=t},n.detach=function(t){void 0===t&&(t=W.COLOR_ATTACHMENT0),delete this._attachments[t]},n.resize=function(e,n){var i=t.prototype.resize.call(this,e,n);if(i)for(var r in this.dispose(!1),this._attachments){var a=this._attachments[r];a.isTexture?(a.image={rtt:!0,data:null,width:this.width,height:this.height},a.version++):a.resize(e,n)}return i},n.dispose=function(e){if(void 0===e&&(e=!0),t.prototype.dispose.call(this),e)for(var n in this._attachments)this._attachments[n].dispose()},e}(mr);Er.prototype.isRenderTarget2D=!0,Object.defineProperties(Er.prototype,{texture:{set:function(t){t?t.isTexture&&this.attach(t,W.COLOR_ATTACHMENT0):this.detach(W.COLOR_ATTACHMENT0)},get:function(){var t=this._attachments[W.COLOR_ATTACHMENT0];return t.isTexture?t:null}}});var Sr=function(t){function e(e){var n;return(n=t.call(this,e.width,e.height)||this).view=e,n}i(e,t);var n=e.prototype;return n.resize=function(t,e){this.view.width=t,this.view.height=e,this.width=t,this.height=e},n.dispose=function(){},e}(mr);Sr.prototype.isRenderTargetBack=!0;var Mr=function(t){function e(e,n){var i;return(i=t.call(this,e,n)||this)._attachments={},i.attach(new Ln,W.COLOR_ATTACHMENT0),i.attach(new gr(e,n,O.DEPTH_STENCIL),W.DEPTH_STENCIL_ATTACHMENT),i.activeCubeFace=0,i}i(e,t);var n=e.prototype;return n.attach=function(t,e){if(void 0===e&&(e=W.COLOR_ATTACHMENT0),t.isTexture){for(var n=!1,i=0;i<6;i++)t.images[i]&&t.images[i].rtt?t.images[i].width===this.width&&t.images[i].height===this.height||(t.images[i].width=this.width,t.images[i].height=this.height,n=!0):(t.images[i]={rtt:!0,data:null,width:this.width,height:this.height},n=!0);n&&t.version++}else t.resize(this.width,this.height);this._attachments[e]=t},n.detach=function(t){void 0===t&&(t=W.COLOR_ATTACHMENT0),delete this._attachments[t]},n.resize=function(e,n){if(t.prototype.resize.call(this,e,n))for(var i in this.dispose(!1),this._attachments){var r=this._attachments[i];if(r.isTexture){for(var a=0;a<6;a++)r.images[a]={rtt:!0,data:null,width:this.width,height:this.height};r.version++}else r.resize(e,n)}},n.dispose=function(e){if(void 0===e&&(e=!0),t.prototype.dispose.call(this),e)for(var n in this._attachments)this._attachments[n].dispose()},e}(mr);Mr.prototype.isRenderTargetCube=!0,Object.defineProperties(Mr.prototype,{texture:{set:function(t){t?t.isTexture&&this.attach(t,W.COLOR_ATTACHMENT0):this.detach(W.COLOR_ATTACHMENT0)},get:function(){var t=this._attachments[W.COLOR_ATTACHMENT0];return t.isTexture?t:null}}});var Tr=0,yr=function(t){function e(){var e;return(e=t.call(this)||this).id=Tr++,e}return i(e,t),e.prototype.dispose=function(){this.dispatchEvent({type:"dispose"})},e}(q),xr=new m,wr=function(){function t(t,e){this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=new Float32Array(16*this.bones.length),this.boneTexture=void 0}var e=t.prototype;return e.pose=function(){for(var t=this.boneInverses,e=0;e=2,i=this.renderTarget;n!==(i._attachments[W.DEPTH_ATTACHMENT]===this.depthMap)&&(n?(e.getExtension("OES_texture_float_linear")&&(this.depthMap.type=F.FLOAT),i.dispose(),i.attach(this.depthMap,W.DEPTH_ATTACHMENT)):(i.dispose(),i.attach(this._depthBuffer,W.DEPTH_ATTACHMENT)))},e}(Nr),Lr=function(t){function e(e,n){var i;return(i=t.call(this,e,n)||this).shadow=new Pr,i}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.shadow.copy(e.shadow),this},e}(Ar);Lr.prototype.isDirectionalLight=!0;var Cr=function(t){function e(e,n,i){var r;return(r=t.call(this,e,i)||this).groundColor=new gt(void 0!==n?n:16777215),r}return i(e,t),e.prototype.copy=function(e){t.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor)},e}(Ar);Cr.prototype.isHemisphereLight=!0;var Dr=function(t){function e(){var e;(e=t.call(this)||this).renderTarget=new Mr(e.mapSize.x,e.mapSize.y);var n=e.renderTarget.texture;return n.generateMipmaps=!1,n.minFilter=I.LINEAR,e.map=n,e._targets=[new _(1,0,0),new _(-1,0,0),new _(0,1,0),new _(0,-1,0),new _(0,0,1),new _(0,0,-1)],e._ups=[new _(0,-1,0),new _(0,-1,0),new _(0,0,1),new _(0,0,-1),new _(0,-1,0),new _(0,-1,0)],e._lookTarget=new _,e}i(e,t);var n=e.prototype;return n.update=function(t,e){this._updateCamera(t,e),this.mapSize.x===this.renderTarget.width&&this.mapSize.y===this.renderTarget.height||this.renderTarget.resize(this.mapSize.x,this.mapSize.y)},n._updateCamera=function(t,e){var n=this.camera,i=this._lookTarget,r=this._targets,a=this._ups;n.position.setFromMatrixPosition(t.worldMatrix),i.set(r[e].x+n.position.x,r[e].y+n.position.y,r[e].z+n.position.z),n.lookAt(i,a[e]),n.updateMatrix(),n.setPerspective(.5*Math.PI,1,this.cameraNear,this.cameraFar)},e}(Nr),Or=function(t){function e(e,n,i,r){var a;return(a=t.call(this,e,n)||this).decay=void 0!==r?r:1,a.distance=void 0!==i?i:200,a.shadow=new Dr,a}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.shadow.copy(e.shadow),this},e}(Ar);Or.prototype.isPointLight=!0;var Fr=function(t){function e(){var e;(e=t.call(this)||this).frustumEdgeFalloff=0,e.renderTarget=new Er(e.mapSize.x,e.mapSize.y);var n=e.renderTarget.texture;n.generateMipmaps=!1,n.minFilter=I.LINEAR;var i=new Pn;i.type=F.UNSIGNED_INT,i.format=O.DEPTH_COMPONENT,i.magFilter=I.LINEAR,i.minFilter=I.LINEAR,i.compare=B.LESS,i.generateMipmaps=!1;var r=new gr(e.mapSize.x,e.mapSize.y,O.DEPTH_COMPONENT16);return e.renderTarget.detach(W.DEPTH_STENCIL_ATTACHMENT),e.renderTarget.attach(r,W.DEPTH_ATTACHMENT),e.map=n,e.depthMap=i,e._depthBuffer=r,e._lookTarget=new _,e._up=new _(0,1,0),e}i(e,t);var n=e.prototype;return n.update=function(t){this._updateCamera(t),this.mapSize.x===this.renderTarget.width&&this.mapSize.y===this.renderTarget.height||this.renderTarget.resize(this.mapSize.x,this.mapSize.y)},n._updateCamera=function(t){var e=this.camera,n=this._lookTarget;t.getWorldDirection(n),e.position.setFromMatrixPosition(t.worldMatrix),n.multiplyScalar(-1).add(e.position),e.lookAt(n,this._up),e.updateMatrix(),e.setPerspective(2*t.angle,1,this.cameraNear,this.cameraFar)},n.copy=function(e){return t.prototype.copy.call(this,e),this.frustumEdgeFalloff=e.frustumEdgeFalloff,this},n.prepareDepthMap=function(t,e){var n=t&&e.version>=2,i=this.renderTarget;n!==(i._attachments[W.DEPTH_ATTACHMENT]===this.depthMap)&&(n?(e.getExtension("OES_texture_float_linear")&&(this.depthMap.type=F.FLOAT),i.dispose(),i.attach(this.depthMap,W.DEPTH_ATTACHMENT)):(i.dispose(),i.attach(this._depthBuffer,W.DEPTH_ATTACHMENT)))},e}(Nr),Ir=function(t){function e(e,n,i,r,a,o){var s;return(s=t.call(this,e,n)||this).decay=void 0!==o?o:1,s.distance=void 0!==i?i:200,s.penumbra=void 0!==a?a:0,s.angle=void 0!==r?r:Math.PI/6,s.shadow=new Fr,s}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.shadow.copy(e.shadow),this},e}(Ar);Ir.prototype.isSpotLight=!0;var Ur=function(t){function e(){return t.call(this)||this}return i(e,t),e}(ne);Ur.prototype.isBone=!0;var Br=function(t){function e(e,n){var i;return(i=t.call(this,e,n)||this).skeleton=void 0,i.bindMode="attached",i.bindMatrix=new m,i.bindMatrixInverse=new m,i}i(e,t);var n=e.prototype;return n.bind=function(t,e){this.skeleton=t,void 0===e&&(this.updateMatrix(),e=this.worldMatrix),this.bindMatrix.copy(e),this.bindMatrixInverse.getInverse(e)},n.updateMatrix=function(e){t.prototype.updateMatrix.call(this,e),"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.worldMatrix):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("t3d.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},n.copy=function(e){return t.prototype.copy.call(this,e),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this},e}(tn);Br.prototype.isSkinnedMesh=!0;var Gr=function(t){function e(){return t.call(this)||this}return i(e,t),e}(ne);Gr.prototype.isGroup=!0;_.prototype.applyProjection=function(t){console.error("t3d.Vector3: .applyProjection has been removed. Use .applyMatrix4 instead.")},Object.defineProperties(Ne.prototype,{gammaInput:{get:function(){return console.warn("t3d.Camera: .gammaInput has been removed. Use texture.encoding instead."),!1},set:function(t){console.warn("t3d.Camera: .gammaInput has been removed. Use texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("t3d.Camera: .gammaOutput has been removed. Use .outputEncoding or renderTarget.texture.encoding instead."),this.outputEncoding==H.GAMMA},set:function(t){console.warn("t3d.Camera: .gammaOutput has been removed. Use .outputEncoding or renderTarget.texture.encoding instead."),this.outputEncoding=t?H.GAMMA:H.LINEAR}}}),Object.defineProperties(vn.prototype,{emissiveIntensity:{get:function(){return console.warn("t3d.Material: .emissiveIntensity has been removed. Use material.emissive instead."),!1},set:function(t){console.warn("t3d.Material: .emissiveIntensity has been removed. Use material.emissive instead.")}}}),Object.defineProperties(er.prototype,{textures:{get:function(){return console.warn("WebGLRenderPass: .textures has been deprecated. All methods are moved to WebGLRenderPass."),this._textures}},renderBuffers:{get:function(){return console.warn("WebGLRenderPass: .renderBuffers has been deprecated. All methods are moved to WebGLRenderPass."),this._renderBuffers}},renderTarget:{get:function(){return this._renderTargets}},state:{get:function(){return this._state}},vertexArrayBindings:{get:function(){return console.warn("WebGLRenderPass: .vertexArrayBindings has been deprecated. All methods are moved to WebGLRenderPass."),this._vertexArrayBindings}}}),ki.prototype.resetBinding=function(){console.error("WebGLVertexArrayBindings: .resetBinding() has been removed. Use WebGLRenderPass.resetVertexArrayBindings() instead.")},Hi.prototype.setBufferExternal=function(t,e){console.warn("WebGLGeometries: .setBufferExternal has been removed. Use WebGLRenderPass.setBufferExternal instead."),this._buffers.setBufferExternal(t,e)};var zr={TEXTURE_2D:3553,TEXTURE_CUBE_MAP:34067,TEXTURE_3D:32879};Object.defineProperties(Nn.prototype,{textureType:{get:function(){return console.warn("TextureBase: .textureType has been removed."),""},set:function(t){console.warn("TextureBase: .textureType has been removed.")}}}),Object.defineProperties(Pn,{textureType:{get:function(){return console.warn("Texture2D: .textureType has been removed."),zr.TEXTURE_2D},set:function(t){console.warn("Texture2D: .textureType has been removed.")}}}),Object.defineProperties(Cn,{textureType:{get:function(){return console.warn("Texture3D: .textureType has been removed."),zr.TEXTURE_3D},set:function(t){console.warn("Texture3D: .textureType has been removed.")}}}),Object.defineProperties(Ln,{textureType:{get:function(){return console.warn("TextureCube: .textureType has been removed."),zr.TEXTURE_CUBE_MAP},set:function(t){console.warn("TextureCube: .textureType has been removed.")}}});var Hr={AMBIENT:"ambient",HEMISPHERE:"hemisphere",DIRECT:"direct",POINT:"point",SPOT:"spot"};Object.defineProperties(Ar.prototype,{lightType:{get:function(){return console.warn("Light: .lightType has been removed."),""},set:function(t){console.warn("Light: .lightType has been removed.")}}}),Object.defineProperties(Rr.prototype,{lightType:{get:function(){return console.warn("AmbientLight: .lightType has been removed."),Hr.AMBIENT},set:function(t){console.warn("AmbientLight: .lightType has been removed.")}}}),Object.defineProperties(Lr.prototype,{lightType:{get:function(){return console.warn("DirectionalLight: .lightType has been removed."),Hr.DIRECT},set:function(t){console.warn("DirectionalLight: .lightType has been removed.")}}}),Object.defineProperties(Cr.prototype,{lightType:{get:function(){return console.warn("HemisphereLight: .lightType has been removed."),Hr.HEMISPHERE},set:function(t){console.warn("HemisphereLight: .lightType has been removed.")}}}),Object.defineProperties(Or.prototype,{lightType:{get:function(){return console.warn("PointLight: .lightType has been removed."),Hr.POINT},set:function(t){console.warn("PointLight: .lightType has been removed.")}}}),Object.defineProperties(Ir.prototype,{lightType:{get:function(){return console.warn("SpotLight: .lightType has been removed."),Hr.SPOT},set:function(t){console.warn("SpotLight: .lightType has been removed.")}}});var Vr={MESH:"mesh",SKINNED_MESH:"skinned_mesh",LIGHT:"light",CAMERA:"camera",SCENE:"scene",GROUP:"group"};Object.defineProperties(tn.prototype,{type:{get:function(){return console.warn("Mesh: .type has been removed, use .isMesh instead."),Vr.MESH},set:function(t){console.warn("Mesh: .type has been removed.")}}}),Object.defineProperties(Br.prototype,{type:{get:function(){return console.warn("SkinnedMesh: .type has been removed, use .isSkinnedMesh instead."),Vr.SKINNED_MESH},set:function(t){console.warn("SkinnedMesh: .type has been removed.")}}}),Object.defineProperties(Ar.prototype,{type:{get:function(){return console.warn("Light: .type has been removed, use .isLight instead."),Vr.LIGHT},set:function(t){console.warn("Light: .type has been removed.")}}}),Object.defineProperties(Ne.prototype,{type:{get:function(){return console.warn("Camera: .type has been removed, use .isCamera instead."),Vr.CAMERA},set:function(t){console.warn("Camera: .type has been removed.")}}}),Object.defineProperties(Re.prototype,{type:{get:function(){return console.warn("Scene: .type has been removed, use .isScene instead."),Vr.SCENE},set:function(t){console.warn("Scene: .type has been removed.")}}}),Object.defineProperties(Gr.prototype,{type:{get:function(){return console.warn("Group: .type has been removed, use .isGroup instead."),Vr.GROUP},set:function(t){console.warn("Group: .type has been removed.")}}});var kr={NORMAL:"normal",EXP2:"exp2"};Object.defineProperties(ir.prototype,{fogType:{get:function(){return console.warn("Fog: .fogType has been removed, use .isFog instead."),kr.NORMAL},set:function(t){console.warn("Fog: .fogType has been removed.")}}}),Object.defineProperties(rr.prototype,{fogType:{get:function(){return console.warn("FogExp2: .fogType has been removed, use .isFogExp2 instead."),kr.EXP2},set:function(t){console.warn("FogExp2: .fogType has been removed.")}}}),Pn.fromImage=function(t){console.warn("Texture2D.fromImage has been removed.");var e=new Pn;return e.image=t,e.version++,e},Pn.fromSrc=function(t){console.warn("Texture2D.fromSrc has been removed, use Texture2DLoader(jsm) instead.");var e=new Pn;return(new ft).load(t,(function(t){e.image=t,e.version++,e.dispatchEvent({type:"onload"})})),e},Ln.fromImage=function(t){console.warn("TextureCube.fromImage has been removed.");for(var e=new Ln,n=e.images,i=0;i<6;i++)n[i]=t[i];return e.version++,e},Ln.fromSrc=function(t){console.warn("TextureCube.fromSrc has been removed, use TextureCubeLoader(jsm) instead.");var e=new Ln,n=e.images,i=new ft,r=0;return function a(o){if(o&&(n.push(o),r++),r>=6)return e.version++,void e.dispatchEvent({type:"onload"});i.load(t[r],a)}(),e},t.ATTACHMENT=W,t.AmbientLight=Rr,t.AnimationAction=Q,t.AnimationMixer=ot,t.Attribute=an,t.BLEND_EQUATION=N,t.BLEND_FACTOR=P,t.BLEND_TYPE=R,t.BUFFER_USAGE=j,t.BasicMaterial=lr,t.Bone=Ur,t.BooleanKeyframeTrack=d,t.Box2=_t,t.Box3=mt,t.BoxGeometry=ar,t.Buffer=on,t.COMPARE_FUNC=B,t.CULL_FACE_TYPE=L,t.Camera=Ne,t.Color3=gt,t.ColorKeyframeTrack=f,t.CubeGeometry=ar,t.CylinderGeometry=or,t.DRAW_MODE=k,t.DRAW_SIDE=C,t.DefaultLoadingManager=lt,t.DepthMaterial=En,t.DirectionalLight=Lr,t.DirectionalLightShadow=Pr,t.DistanceMaterial=Sn,t.ENVMAP_COMBINE_TYPE=V,t.EnvironmentMapPass=function(){console.error("EnvironmentMapPass has been removed, use ReflectionProbe(jsm) instead.")},t.Euler=Tt,t.EventDispatcher=q,t.FOG_TYPE=kr,t.FileLoader=ht,t.Fog=ir,t.FogExp2=rr,t.Frustum=Nt,t.Geometry=fn,t.Group=Gr,t.HemisphereLight=Cr,t.ImageLoader=ft,t.KeyframeClip=st,t.KeyframeTrack=h,t.LIGHT_TYPE=Hr,t.LambertMaterial=cr,t.Light=Ar,t.LightData=ue,t.LightShadow=Nr,t.LineMaterial=hr,t.Loader=ct,t.LoadingManager=ut,t.MATERIAL_TYPE=b,t.MatcapMaterial=dr,t.Material=vn,t.Matrix3=xt,t.Matrix4=m,t.Mesh=tn,t.NumberKeyframeTrack=p,t.OBJECT_TYPE=Vr,t.OPERATION=G,t.Object3D=ne,t.PBR2Material=fr,t.PBRMaterial=pr,t.PIXEL_FORMAT=O,t.PIXEL_TYPE=F,t.PhongMaterial=_r,t.Plane=bt,t.PlaneGeometry=pn,t.PointLight=Or,t.PointLightShadow=Dr,t.PointsMaterial=vr,t.PropertyBindingMixer=Z,t.QUERY_TYPE=Y,t.Quaternion=y,t.QuaternionKeyframeTrack=x,t.Query=yr,t.Ray=Ft,t.RenderBuffer=gr,t.RenderInfo=function(){var t={calls:0,triangles:0,lines:0,points:0},e=[function(e,n){t.points+=e*n},function(e,n){t.lines+=e*(n/2)},function(e,n){t.lines+=e*n},function(e,n){t.lines+=e*(n-1)},function(e,n){t.triangles+=e*(n/3)},function(e,n){t.triangles+=e*(n-2)},function(e,n){t.triangles+=e*(n-2)}];this.update=function(n,i,r){t.calls++,e[i](r,n)},this.reset=function(){t.calls=0,t.triangles=0,t.lines=0,t.points=0},this.render=t},t.RenderQueue=Ee,t.RenderQueueLayer=ge,t.RenderStates=be,t.RenderTarget2D=Er,t.RenderTargetBack=Sr,t.RenderTargetBase=mr,t.RenderTargetCube=Mr,t.Renderer=nr,t.SHADING_TYPE=D,t.SHADOW_TYPE=z,t.Scene=Re,t.SceneData=we,t.ShaderChunk=ni,t.ShaderLib=ri,t.ShaderMaterial=mn,t.ShaderPostPass=gn,t.ShadowMapPass=Mn,t.Skeleton=wr,t.SkinnedMesh=Br,t.Sphere=Bt,t.SphereGeometry=sr,t.Spherical=Gt,t.SpotLight=Ir,t.SpotLightShadow=Fr,t.StringKeyframeTrack=w,t.TEXEL_ENCODING_TYPE=H,t.TEXTURE_FILTER=I,t.TEXTURE_WRAP=U,t.Texture2D=Pn,t.Texture3D=Cn,t.TextureBase=Nn,t.TextureCube=Ln,t.TorusKnotGeometry=ur,t.Triangle=Xt,t.VERTEX_COLOR=X,t.Vector2=pt,t.Vector3=_,t.Vector4=Wt,t.VectorKeyframeTrack=A,t.WEBGL_COMPARE_FUNC=B,t.WEBGL_OP=G,t.WEBGL_PIXEL_FORMAT=O,t.WEBGL_PIXEL_TYPE=F,t.WEBGL_TEXTURE_FILTER=I,t.WEBGL_TEXTURE_TYPE=zr,t.WEBGL_TEXTURE_WRAP=U,t.WebGLAttribute=Kn,t.WebGLCapabilities=mi,t.WebGLGeometries=Hi,t.WebGLProgram=$n,t.WebGLPrograms=ai,t.WebGLProperties=wi,t.WebGLQueries=Xi,t.WebGLRenderBuffers=Fi,t.WebGLRenderPass=er,t.WebGLState=xi,t.WebGLTextures=Ai,t.WebGLUniforms=Zn,t.cloneJson=$t,t.cloneUniforms=Jt,t.generateUUID=qt,t.isPowerOfTwo=Qt,t.nearestPowerOfTwo=Zt,t.nextPowerOfTwo=Kt})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).t3d={})}(this,(function(t){"use strict";function e(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,i=new Array(e);n=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var h=function(){function t(t,e,n,i,r){void 0===r&&(r=!0),this.target=t,this.propertyPath=e,this.name=this.target.uuid+"."+e,this.times=n,this.values=i,this.valueSize=i.length/n.length,this.interpolant=r}var e=t.prototype;return e.getValue=function(t,e){var n=this.times,i=n.length;if(t<=n[0])return this._copyValue(0,e);if(t>=n[i-1])return this._copyValue(i-1,e);for(var r=i-1;t0;)r--;var a=(t-n[r])/(n[r+1]-n[r]);return this._interpolate(r,a,e)},e._interpolate=function(t,e,n){for(var i,r,a=this.values,o=this.valueSize,s=0;s=0?1:-1,g=1-v*v;if(g>Number.EPSILON){var E=Math.sqrt(g),S=Math.atan2(E,v*m);_=Math.sin(_*S)/E,o=Math.sin(o*S)/E}var M=o*m;if(s=s*_+h*M,u=u*_+d*M,l=l*_+f*M,c=c*_+p*M,_===1-o){var T=1/Math.sqrt(s*s+u*u+l*l+c*c);s*=T,u*=T,l*=T,c*=T}}t[e]=s,t[e+1]=u,t[e+2]=l,t[e+3]=c},t.multiplyQuaternionsFlat=function(t,e,n,i,r,a){var o=n[i],s=n[i+1],u=n[i+2],l=n[i+3],c=r[a],h=r[a+1],d=r[a+2],f=r[a+3];return t[e]=o*f+l*c+s*d-u*h,t[e+1]=s*f+l*h+u*c-o*d,t[e+2]=u*f+l*d+o*h-s*c,t[e+3]=l*f-o*c-s*h-u*d,t};var e=t.prototype;return e.normalize=function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this.onChangeCallback(),this},e.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},e.lerpQuaternions=function(t,e,n){if(0===n)return this.copy(t);if(1===n)return this.copy(e);var i=t._w,r=t._x,a=t._y,o=t._z,s=e._w,u=e._x,l=e._y,c=e._z;i*s+r*u+a*l+o*c<0&&(s=-s,u=-u,l=-l,c=-c),this._w=i+n*(s-i),this._x=r+n*(u-r),this._y=a+n*(l-a),this._z=o+n*(c-o);var h=1/Math.sqrt(this._w*this._w+this._x*this._x+this._y*this._y+this._z*this._z);return this._w*=h,this._x*=h,this._y*=h,this._z*=h,this.onChangeCallback(),this},e.slerpQuaternions=function(t,e,n){if(0===n)return this.copy(t);if(1===n)return this.copy(e);var i=t._w,r=t._x,a=t._y,o=t._z,s=e._w,u=e._x,l=e._y,c=e._z,h=i*s+r*u+a*l+o*c;if(h<0&&(h=-h,s=-s,u=-u,l=-l,c=-c),h<.95){var d=Math.acos(h),f=1/Math.sin(d),p=Math.sin(d*(1-n))*f,_=Math.sin(d*n)*f;this._w=i*p+s*_,this._x=r*p+u*_,this._y=a*p+l*_,this._z=o*p+c*_}else{this._w=i+n*(s-i),this._x=r+n*(u-r),this._y=a+n*(l-a),this._z=o+n*(c-o);var v=1/Math.sqrt(this._w*this._w+this._x*this._x+this._y*this._y+this._z*this._z);this._w*=v,this._x*=v,this._y*=v,this._z*=v}return this.onChangeCallback(),this},e.set=function(t,e,n,i){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===i&&(i=1),this._x=t,this._y=e,this._z=n,this._w=i,this.onChangeCallback(),this},e.clone=function(){return new t(this._x,this._y,this._z,this._w)},e.copy=function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=void 0!==t.w?t.w:1,this.onChangeCallback(),this},e.setFromEuler=function(t,e){void 0===e&&(e=!0);var n=Math.cos(t._x/2),i=Math.cos(t._y/2),r=Math.cos(t._z/2),a=Math.sin(t._x/2),o=Math.sin(t._y/2),s=Math.sin(t._z/2),u=t._order;return"XYZ"===u?(this._x=a*i*r+n*o*s,this._y=n*o*r-a*i*s,this._z=n*i*s+a*o*r,this._w=n*i*r-a*o*s):"YXZ"===u?(this._x=a*i*r+n*o*s,this._y=n*o*r-a*i*s,this._z=n*i*s-a*o*r,this._w=n*i*r+a*o*s):"ZXY"===u?(this._x=a*i*r-n*o*s,this._y=n*o*r+a*i*s,this._z=n*i*s+a*o*r,this._w=n*i*r-a*o*s):"ZYX"===u?(this._x=a*i*r-n*o*s,this._y=n*o*r+a*i*s,this._z=n*i*s-a*o*r,this._w=n*i*r+a*o*s):"YZX"===u?(this._x=a*i*r+n*o*s,this._y=n*o*r+a*i*s,this._z=n*i*s-a*o*r,this._w=n*i*r-a*o*s):"XZY"===u&&(this._x=a*i*r-n*o*s,this._y=n*o*r-a*i*s,this._z=n*i*s+a*o*r,this._w=n*i*r+a*o*s),!0===e&&this.onChangeCallback(),this},e.setFromRotationMatrix=function(t){var e,n=t.elements,i=n[0],r=n[4],a=n[8],o=n[1],s=n[5],u=n[9],l=n[2],c=n[6],h=n[10],d=i+s+h;return d>0?(e=.5/Math.sqrt(d+1),this._w=.25/e,this._x=(c-u)*e,this._y=(a-l)*e,this._z=(o-r)*e):i>s&&i>h?(e=2*Math.sqrt(1+i-s-h),this._w=(c-u)/e,this._x=.25*e,this._y=(r+o)/e,this._z=(a+l)/e):s>h?(e=2*Math.sqrt(1+s-i-h),this._w=(a-l)/e,this._x=(r+o)/e,this._y=.25*e,this._z=(u+c)/e):(e=2*Math.sqrt(1+h-i-s),this._w=(o-r)/e,this._x=(a+l)/e,this._y=(u+c)/e,this._z=.25*e),this.onChangeCallback(),this},e.setFromUnitVectors=function(t,e){var n=t.dot(e)+1;return nMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()},e.multiply=function(t){return this.multiplyQuaternions(this,t)},e.premultiply=function(t){return this.multiplyQuaternions(t,this)},e.multiplyQuaternions=function(t,e){var n=t._x,i=t._y,r=t._z,a=t._w,o=e._x,s=e._y,u=e._z,l=e._w;return this._x=n*l+a*o+i*u-r*s,this._y=i*l+a*s+r*o-n*u,this._z=r*l+a*u+n*s-i*o,this._w=a*l-n*o-i*s-r*u,this.onChangeCallback(),this},e.toMatrix4=function(t){void 0===t&&(t=new m);var e=t.elements,n=2*this._x*this._y,i=2*this._x*this._z,r=2*this._x*this._w,a=2*this._y*this._z,o=2*this._y*this._w,s=2*this._z*this._w,u=this._x*this._x,l=this._y*this._y,c=this._z*this._z,h=this._w*this._w;return e[0]=u-l-c+h,e[4]=n-s,e[8]=i+o,e[12]=0,e[1]=n+s,e[5]=-u+l-c+h,e[9]=a-r,e[13]=0,e[2]=i-o,e[6]=a+r,e[10]=-u-l+c+h,e[14]=0,e[3]=0,e[7]=0,e[11]=0,e[15]=1,t},e.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},e.dot=function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},e.setFromAxisAngle=function(t,e){var n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this.onChangeCallback(),this},e.fromArray=function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this.onChangeCallback(),this},e.toArray=function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},e.onChange=function(t){return this.onChangeCallback=t,this},e.onChangeCallback=function(){},n(t,[{key:"x",get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback()}},{key:"y",get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback()}},{key:"z",get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback()}},{key:"w",get:function(){return this._w},set:function(t){this._w=t,this.onChangeCallback()}}]),t}(),x=function(t){function e(e,n,i,r,a){return t.call(this,e,n,i,r,a)||this}return i(e,t),e.prototype._interpolate=function(t,e,n){var i=this.values;return this.interpolant?y.slerpFlat(n,0,i,4*t,i,4*(t+1),e):this._copyValue(t,n),n},e}(h);x.prototype.valueTypeName="quaternion";var A=function(t){function e(e,n,i,r,a){return t.call(this,e,n,i,r,a)||this}return i(e,t),e.prototype._interpolate=function(t,e,n){return n[0]=this.values[t],n},e}(h);A.prototype.valueTypeName="string";var w=function(t){function e(e,n,i,r,a){return t.call(this,e,n,i,r,a)||this}return i(e,t),e}(h);w.prototype.valueTypeName="vector";var b={BASIC:"basic",LAMBERT:"lambert",PHONG:"phong",PBR:"pbr",PBR2:"pbr2",MATCAP:"matcap",POINT:"point",LINE:"line",SHADER:"shader",DEPTH:"depth",DISTANCE:"distance"},R={NONE:"none",NORMAL:"normal",ADD:"add",SUB:"sub",MUL:"mul",CUSTOM:"custom"},N={ADD:100,SUBTRACT:101,REVERSE_SUBTRACT:102},P={ZERO:200,ONE:201,SRC_COLOR:202,SRC_ALPHA:203,SRC_ALPHA_SATURATE:204,DST_COLOR:205,DST_ALPHA:206,ONE_MINUS_SRC_COLOR:207,ONE_MINUS_SRC_ALPHA:208,ONE_MINUS_DST_COLOR:209,ONE_MINUS_DST_ALPHA:210},L={NONE:"none",FRONT:"front",BACK:"back",FRONT_AND_BACK:"front_and_back"},C={FRONT:"front",BACK:"back",DOUBLE:"double"},D={SMOOTH_SHADING:"smooth_shading",FLAT_SHADING:"flat_shading"},O={DEPTH_COMPONENT:1e3,DEPTH_STENCIL:1001,STENCIL_INDEX8:1002,ALPHA:1003,RED:1004,RGB:1005,RGBA:1006,LUMINANCE:1007,LUMINANCE_ALPHA:1008,RED_INTEGER:1010,RG:1011,RG_INTEGER:1012,RGB_INTEGER:1013,RGBA_INTEGER:1014,R32F:1100,R16F:1101,R8:1102,RG32F:1103,RG16F:1104,RG8:1105,RGB32F:1106,RGB16F:1107,RGB8:1108,RGBA32F:1109,RGBA16F:1110,RGBA8:1111,RGBA4:1112,RGB5_A1:1113,DEPTH_COMPONENT32F:1114,DEPTH_COMPONENT24:1115,DEPTH_COMPONENT16:1116,DEPTH24_STENCIL8:1117,DEPTH32F_STENCIL8:1118,RGB_S3TC_DXT1:1200,RGBA_S3TC_DXT1:1201,RGBA_S3TC_DXT3:1202,RGBA_S3TC_DXT5:1203,RGB_PVRTC_4BPPV1:1204,RGB_PVRTC_2BPPV1:1205,RGBA_PVRTC_4BPPV1:1206,RGBA_PVRTC_2BPPV1:1207,RGB_ETC1:1208,RGBA_ASTC_4x4:1209,RGBA_BPTC:1210},F={UNSIGNED_BYTE:1500,UNSIGNED_SHORT_5_6_5:1501,UNSIGNED_SHORT_4_4_4_4:1502,UNSIGNED_SHORT_5_5_5_1:1503,UNSIGNED_SHORT:1504,UNSIGNED_INT:1505,UNSIGNED_INT_24_8:1506,FLOAT:1507,HALF_FLOAT:1508,FLOAT_32_UNSIGNED_INT_24_8_REV:1509,BYTE:1510,SHORT:1511,INT:1512},I={NEAREST:1600,LINEAR:1601,NEAREST_MIPMAP_NEAREST:1602,LINEAR_MIPMAP_NEAREST:1603,NEAREST_MIPMAP_LINEAR:1604,LINEAR_MIPMAP_LINEAR:1605},U={REPEAT:1700,CLAMP_TO_EDGE:1701,MIRRORED_REPEAT:1702},B={LEQUAL:515,GEQUAL:518,LESS:513,GREATER:516,EQUAL:514,NOTEQUAL:517,ALWAYS:519,NEVER:512},G={KEEP:7680,REPLACE:7681,INCR:7682,DECR:7683,INVERT:5386,INCR_WRAP:34055,DECR_WRAP:34056},z={HARD:"hard",POISSON_SOFT:"poisson_soft",PCF3_SOFT:"pcf3_soft",PCF5_SOFT:"pcf5_soft",PCSS16_SOFT:"pcss16_soft",PCSS32_SOFT:"pcss32_soft",PCSS64_SOFT:"pcss64_soft"},H={LINEAR:"linear",SRGB:"sRGB",RGBE:"RGBE",RGBM7:"RGBM7",RGBM16:"RGBM16",RGBD:"RGBD",GAMMA:"Gamma"},V={MULTIPLY:"ENVMAP_BLENDING_MULTIPLY",MIX:"ENVMAP_BLENDING_MIX",ADD:"ENVMAP_BLENDING_ADD"},k={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},X={NONE:0,RGB:1,RGBA:2},W={COLOR_ATTACHMENT0:2e3,COLOR_ATTACHMENT1:2001,COLOR_ATTACHMENT2:2002,COLOR_ATTACHMENT3:2003,COLOR_ATTACHMENT4:2004,COLOR_ATTACHMENT5:2005,COLOR_ATTACHMENT6:2006,COLOR_ATTACHMENT7:2007,COLOR_ATTACHMENT8:2008,COLOR_ATTACHMENT9:2009,COLOR_ATTACHMENT10:2010,COLOR_ATTACHMENT11:2011,COLOR_ATTACHMENT12:2012,COLOR_ATTACHMENT13:2013,COLOR_ATTACHMENT14:2014,COLOR_ATTACHMENT15:2015,DEPTH_ATTACHMENT:2020,STENCIL_ATTACHMENT:2021,DEPTH_STENCIL_ATTACHMENT:2030},j={STREAM_DRAW:35040,STREAM_READ:35041,STREAM_COPY:35042,STATIC_DRAW:35044,STATIC_READ:35045,STATIC_COPY:35046,DYNAMIC_DRAW:35048,DYNAMIC_READ:35049,DYNAMIC_COPY:35050},Y={ANY_SAMPLES_PASSED:7e3,ANY_SAMPLES_PASSED_CONSERVATIVE:7001,TIME_ELAPSED:7002},q=function(){function t(){}var e=t.prototype;return e.addEventListener=function(t,e,n){void 0===this._eventMap&&(this._eventMap={});var i=this._eventMap;void 0===i[t]&&(i[t]=[]),i[t].push({listener:e,thisObject:n||this})},e.removeEventListener=function(t,e,n){if(void 0!==this._eventMap){var i=this._eventMap[t];if(void 0!==i)for(var r=0,a=i.length;re&&(this.time=this.time%e),this.time<0&&(this.time=this.time%e+e)},e}(q),Z=function(){function t(t,e,n,i){this.target=null,this.property="",this.parseBinding(t,e),this.valueSize=i;var r,a,o,s=Float64Array;switch(n){case"quaternion":r=J,a=tt,o=rt;break;case"string":case"bool":s=Array,r=K,a=K,o=at;break;default:r=et,a=nt,o=it}this.buffer=new s(4*i),this._mixBufferFunction=r,this._mixBufferFunctionAdditive=a,this._setIdentity=o,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}var e=t.prototype;return e.parseBinding=function(t,e){if((e=e.split(".")).length>1){for(var n=t[e[0]],i=1;i1?this.target[this.property].toArray?this.target[this.property].toArray(t,n):function(t,e,n,i){for(var r=0;r0&&this._mixBufferFunctionAdditive(t,e,3*e,1,e),this.valueSize>1?this.target[this.property].fromArray?this.target[this.property].fromArray(t,e):function(t,e,n,i){for(var r=0;r=.5)for(var a=0;a!==r;++a)t[e+a]=t[n+a]}function J(t,e,n,i){y.slerpFlat(t,e,t,e,t,n,i)}var $=new Float64Array(4);function tt(t,e,n,i){y.multiplyQuaternionsFlat($,0,t,e,t,n),y.slerpFlat(t,e,t,e,$,0,i)}function et(t,e,n,i,r){for(var a=1-i,o=0;o!==r;++o){var s=e+o;t[s]=t[s]*a+t[n+o]*i}}function nt(t,e,n,i,r){for(var a=0;a!==r;++a){var o=e+a;t[o]=t[o]+t[n+a]*i}}function it(t,e,n){for(var i=0;i.")},e.removeAction=function(t){var e=this._actions.indexOf(t);if(-1!==e)if(t.weight>0)console.warn("AnimationMixer.removeAction(): make sure action's weight is zero before removing it.");else{this._actions.splice(e,1);for(var n=clip.tracks,i=0;i.")},e.hasAction=function(t){return this._actions.indexOf(t)>-1},e.getActions=function(){return this._actions},e.update=function(t){for(var e in this._bindings)this._bindings[e].active=!1;for(var n=0,i=this._actions.length;n0){r.update(t);for(var a=r.clip.tracks,o=0,s=a.length;oo&&(o=h),d>s&&(s=d),f>u&&(u=f)}return this.min.set(i,r,a),this.max.set(o,s,u),this},e.isEmpty=function(){return this.max.x>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},e.getHex=function(){return St(255*this.r,0,255)<<16^St(255*this.g,0,255)<<8^St(255*this.b,0,255)<<0},e.setRGB=function(t,e,n){return this.r=t,this.g=e,this.b=n,this},e.setHSL=function(t,e,n){var i;if(t=(t%(i=1)+i)%i,e=Math.max(0,Math.min(1,e)),n=Math.max(0,Math.min(1,n)),0===e)this.r=this.g=this.b=n;else{var r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=Et(a,r,t+1/3),this.g=Et(a,r,t),this.b=Et(a,r,t-1/3)}return this},e.fromArray=function(t,e){return void 0===e&&(e=0),this.r=t[e],this.g=t[e+1],this.b=t[e+2],this},e.toArray=function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t},t}();function Et(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}function St(t,e,n){return Math.max(e,Math.min(n,t))}var Mt=new m,Tt=function(){function t(e,n,i,r){void 0===e&&(e=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=t.DefaultOrder),this._x=e,this._y=n,this._z=i,this._order=r}var e=t.prototype;return e.clone=function(){return new t(this._x,this._y,this._z,this._order)},e.copy=function(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this.onChangeCallback(),this},e.set=function(t,e,n,i){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===i&&(i=this._order),this._x=t,this._y=e,this._z=n,this._order=i,this.onChangeCallback(),this},e.setFromRotationMatrix=function(t,e,n){void 0===e&&(e=this._order),void 0===n&&(n=!0);var i=t.elements,r=i[0],a=i[4],o=i[8],s=i[1],u=i[5],l=i[9],c=i[2],h=i[6],d=i[10];return"XYZ"===e?(this._y=Math.asin(yt(o,-1,1)),Math.abs(o)<.99999?(this._x=Math.atan2(-l,d),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(h,u),this._z=0)):"YXZ"===e?(this._x=Math.asin(-yt(l,-1,1)),Math.abs(l)<.99999?(this._y=Math.atan2(o,d),this._z=Math.atan2(s,u)):(this._y=Math.atan2(-c,r),this._z=0)):"ZXY"===e?(this._x=Math.asin(yt(h,-1,1)),Math.abs(h)<.99999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-a,u)):(this._y=0,this._z=Math.atan2(s,r))):"ZYX"===e?(this._y=Math.asin(-yt(c,-1,1)),Math.abs(c)<.99999?(this._x=Math.atan2(h,d),this._z=Math.atan2(s,r)):(this._x=0,this._z=Math.atan2(-a,u))):"YZX"===e?(this._z=Math.asin(yt(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-l,u),this._y=Math.atan2(-c,r)):(this._x=0,this._y=Math.atan2(o,d))):"XZY"===e?(this._z=Math.asin(-yt(a,-1,1)),Math.abs(a)<.99999?(this._x=Math.atan2(h,u),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-l,d),this._y=0)):console.warn("given unsupported order: "+e),this._order=e,!0===n&&this.onChangeCallback(),this},e.setFromQuaternion=function(t,e,n){return t.toMatrix4(Mt),this.setFromRotationMatrix(Mt,e,n)},e.onChange=function(t){return this.onChangeCallback=t,this},e.onChangeCallback=function(){},n(t,[{key:"x",get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback()}},{key:"y",get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback()}},{key:"z",get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback()}},{key:"order",get:function(){return this._order},set:function(t){this._order=t,this.onChangeCallback()}}]),t}();function yt(t,e,n){return Math.max(e,Math.min(n,t))}Tt.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],Tt.DefaultOrder="XYZ";for(var xt=function(){function t(){this.elements=[1,0,0,0,1,0,0,0,1]}var e=t.prototype;return e.set=function(t,e,n,i,r,a,o,s,u){var l=this.elements;return l[0]=t,l[3]=e,l[6]=n,l[1]=i,l[4]=r,l[7]=a,l[2]=o,l[5]=s,l[8]=u,this},e.identity=function(){return this.set(1,0,0,0,1,0,0,0,1)},e.inverse=function(){return this.getInverse(this)},e.getInverse=function(t){var e=t.elements,n=this.elements,i=e[0],r=e[1],a=e[2],o=e[3],s=e[4],u=e[5],l=e[6],c=e[7],h=e[8],d=h*s-u*c,f=u*l-h*o,p=c*o-s*l,_=i*d+r*f+a*p;if(0===_)return console.warn("Matrix3: .getInverse() can not invert matrix, determinant is 0"),this.identity();var v=1/_;return n[0]=d*v,n[1]=(a*c-h*r)*v,n[2]=(u*r-a*s)*v,n[3]=f*v,n[4]=(h*i-a*l)*v,n[5]=(a*o-u*i)*v,n[6]=p*v,n[7]=(r*l-c*i)*v,n[8]=(s*i-r*o)*v,this},e.transpose=function(){var t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this},e.fromArray=function(t,e){void 0===e&&(e=0);for(var n=0;n<9;n++)this.elements[n]=t[n+e];return this},e.toArray=function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t},e.clone=function(){return(new t).fromArray(this.elements)},e.copy=function(t){var e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this},e.multiply=function(t){return this.multiplyMatrices(this,t)},e.premultiply=function(t){return this.multiplyMatrices(t,this)},e.multiplyMatrices=function(t,e){var n=t.elements,i=e.elements,r=this.elements,a=n[0],o=n[3],s=n[6],u=n[1],l=n[4],c=n[7],h=n[2],d=n[5],f=n[8],p=i[0],_=i[3],v=i[6],m=i[1],g=i[4],E=i[7],S=i[2],M=i[5],T=i[8];return r[0]=a*p+o*m+s*S,r[3]=a*_+o*g+s*M,r[6]=a*v+o*E+s*T,r[1]=u*p+l*m+c*S,r[4]=u*_+l*g+c*M,r[7]=u*v+l*E+c*T,r[2]=h*p+d*m+f*S,r[5]=h*_+d*g+f*M,r[8]=h*v+d*E+f*T,this},e.transform=function(t,e,n,i,r,a,o){var s=this.elements,u=Math.cos(r),l=Math.sin(r);return s[0]=u*n,s[3]=-l*i,s[6]=t,s[1]=l*n,s[4]=u*i,s[7]=e,s[2]=0,s[5]=0,s[8]=1,(a||o)&&(s[6]-=a*s[0]+o*s[3],s[7]-=a*s[1]+o*s[4]),this},e.setUvTransform=function(t,e,n,i,r,a,o){var s=Math.cos(r),u=Math.sin(r);return this.set(n*s,n*u,-n*(s*a+u*o)+a+t,-i*u,i*s,-i*(-u*a+s*o)+o+e,0,0,1)},e.setFromMatrix4=function(t){var e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10])},t}(),At=new _,wt=new xt,bt=function(){function t(t,e){void 0===t&&(t=new _(1,0,0)),void 0===e&&(e=0),this.normal=t,this.constant=e}var e=t.prototype;return e.set=function(t,e){return this.normal.copy(t),this.constant=e,this},e.setComponents=function(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this},e.setFromNormalAndCoplanarPoint=function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},e.normalize=function(){var t=1/this.normal.getLength();return this.normal.multiplyScalar(t),this.constant*=t,this},e.distanceToPoint=function(t){return this.normal.dot(t)+this.constant},e.coplanarPoint=function(t){return void 0===t&&(t=new _),t.copy(this.normal).multiplyScalar(-this.constant)},e.clone=function(){return(new t).copy(this)},e.copy=function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},e.applyMatrix4=function(t,e){var n=e||wt.setFromMatrix4(t).inverse().transpose(),i=this.coplanarPoint(At).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this},t}(),Rt=new _,Nt=function(){function t(t,e,n,i,r,a){void 0===t&&(t=new bt),void 0===e&&(e=new bt),void 0===n&&(n=new bt),void 0===i&&(i=new bt),void 0===r&&(r=new bt),void 0===a&&(a=new bt),this.planes=[t,e,n,i,r,a]}var e=t.prototype;return e.set=function(t,e,n,i,r,a){var o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this},e.setFromMatrix=function(t){var e=this.planes,n=t.elements,i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],u=n[5],l=n[6],c=n[7],h=n[8],d=n[9],f=n[10],p=n[11],_=n[12],v=n[13],m=n[14],g=n[15];return e[0].setComponents(o-i,c-s,p-h,g-_).normalize(),e[1].setComponents(o+i,c+s,p+h,g+_).normalize(),e[2].setComponents(o+r,c+u,p+d,g+v).normalize(),e[3].setComponents(o-r,c-u,p-d,g-v).normalize(),e[4].setComponents(o-a,c-l,p-f,g-m).normalize(),e[5].setComponents(o+a,c+l,p+f,g+m).normalize(),this},e.intersectsSphere=function(t){for(var e=this.planes,n=t.center,i=-t.radius,r=0;r<6;r++){if(e[r].distanceToPoint(n)0?t.max.x:t.min.x,Rt.y=i.normal.y>0?t.max.y:t.min.y,Rt.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(Rt)<0)return!1}return!0},e.clone=function(){return(new this.constructor).copy(this)},e.copy=function(t){for(var e=this.planes,n=0;n<6;n++)e[n].copy(t.planes[n]);return this},t}(),Pt=new _,Lt=new _,Ct=new _,Dt=new _,Ot=new _,Ft=function(){function t(t,e){void 0===t&&(t=new _),void 0===e&&(e=new _(0,0,-1)),this.origin=t,this.direction=e}var e=t.prototype;return e.set=function(t,e){return this.origin.copy(t),this.direction.copy(e),this},e.copy=function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},e.applyMatrix4=function(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this},e.at=function(t,e){return void 0===e&&(e=new _),e.copy(this.direction).multiplyScalar(t).add(this.origin)},e.distanceSqToPoint=function(t){var e=Pt.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Pt.copy(this.direction).multiplyScalar(e).add(this.origin),Pt.distanceToSquared(t))},e.intersectsBox=function(t){return null!==this.intersectBox(t,Pt)},e.intersectBox=function(t,e){var n,i,r,a,o,s,u=1/this.direction.x,l=1/this.direction.y,c=1/this.direction.z,h=this.origin;return u>=0?(n=(t.min.x-h.x)*u,i=(t.max.x-h.x)*u):(n=(t.max.x-h.x)*u,i=(t.min.x-h.x)*u),l>=0?(r=(t.min.y-h.y)*l,a=(t.max.y-h.y)*l):(r=(t.max.y-h.y)*l,a=(t.min.y-h.y)*l),n>a||r>i?null:((r>n||n!=n)&&(n=r),(a=0?(o=(t.min.z-h.z)*c,s=(t.max.z-h.z)*c):(o=(t.max.z-h.z)*c,s=(t.min.z-h.z)*c),n>s||o>i?null:((o>n||n!=n)&&(n=o),(s=0?n:i,e)))},e.intersectsSphere=function(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius},e.intersectSphere=function(t,e){Pt.subVectors(t.center,this.origin);var n=Pt.dot(this.direction),i=Pt.dot(Pt)-n*n,r=t.radius*t.radius;if(i>r)return null;var a=Math.sqrt(r-i),o=n-a,s=n+a;return o<0&&s<0?null:o<0?this.at(s,e):this.at(o,e)},e.intersectTriangle=function(t,e,n,i,r){Ct.subVectors(e,t),Dt.subVectors(n,t),Ot.crossVectors(Ct,Dt);var a,o=this.direction.dot(Ot);if(o>0){if(i)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}Lt.subVectors(this.origin,t);var s=a*this.direction.dot(Dt.crossVectors(Lt,Dt));if(s<0)return null;var u=a*this.direction.dot(Ct.cross(Lt));if(u<0)return null;if(s+u>o)return null;var l=-a*Lt.dot(Ot);return l<0?null:this.at(l/o,r)},t}(),It=new mt,Ut=new _,Bt=function(){function t(t,e){void 0===t&&(t=new _),void 0===e&&(e=-1),this.center=t,this.radius=e}var e=t.prototype;return e.set=function(t,e){return this.center.copy(t),this.radius=e,this},e.setFromArray=function(t,e,n){void 0===e&&(e=3),void 0===n&&(n=0);var i=this.center;It.setFromArray(t,e).getCenter(i);for(var r=0,a=0,o=t.length;athis.radius*this.radius){var n=Math.sqrt(e),i=.5*(n-this.radius);this.center.addScaledVector(Ut,i/n),this.radius+=i}return this},e.clone=function(){return(new t).copy(this)},e.copy=function(t){return this.center.copy(t.center),this.radius=t.radius,this},t}(),Gt=function(){function t(t,e,n){void 0===t&&(t=1),void 0===e&&(e=0),void 0===n&&(n=0),this.radius=t,this.phi=e,this.theta=n}var e=t.prototype;return e.set=function(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this},e.copy=function(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this},e.clone=function(){return(new t).copy(this)},e.makeSafe=function(){var t=1e-6;return this.phi=Math.max(t,Math.min(Math.PI-t,this.phi)),this},e.setFromVector3=function(t){return this.radius=t.getLength(),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t.x,t.z),this.phi=Math.acos(Math.min(1,Math.max(-1,t.y/this.radius)))),this},t}(),zt=new _,Ht=new _,Vt=new _,kt=new _,Xt=function(){function t(t,e,n){void 0===t&&(t=new _),void 0===e&&(e=new _),void 0===n&&(n=new _),this.a=t,this.b=e,this.c=n}return t.normal=function(t,e,n,i){var r=i||new _;r.subVectors(n,e),zt.subVectors(t,e),r.cross(zt);var a=r.getLengthSquared();return a>0?r.multiplyScalar(1/Math.sqrt(a)):r.set(0,0,0)},t.barycoordFromPoint=function(t,e,n,i,r){zt.subVectors(i,e),Ht.subVectors(n,e),Vt.subVectors(t,e);var a=zt.dot(zt),o=zt.dot(Ht),s=zt.dot(Vt),u=Ht.dot(Ht),l=Ht.dot(Vt),c=a*u-o*o,h=r||new _;if(0===c)return h.set(-2,-1,-1);var d=1/c,f=(u*s-o*l)*d,p=(a*l-o*s)*d;return h.set(1-f-p,p,f)},t.containsPoint=function(t,e,n,i){return this.barycoordFromPoint(t,e,n,i,kt),kt.x>=0&&kt.y>=0&&kt.x+kt.y<=1},t.prototype.set=function(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this},t}(),Wt=function(){function t(t,e,n,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===i&&(i=1),this.x=t,this.y=e,this.z=n,this.w=i}var e=t.prototype;return e.lerpVectors=function(t,e,n){return this.subVectors(e,t).multiplyScalar(n).add(t)},e.set=function(t,e,n,i){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===i&&(i=1),this.x=t,this.y=e,this.z=n,this.w=i,this},e.normalize=function(){return this.multiplyScalar(1/(this.getLength()||1))},e.multiplyScalar=function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},e.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},e.getLengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},e.getLength=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.getManhattanLength=function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},e.applyMatrix4=function(t){var e=this.x,n=this.y,i=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*i+a[15]*r,this},e.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},e.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this},e.multiply=function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this},e.subVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},e.fromArray=function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},e.toArray=function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t},e.clone=function(){return new t(this.x,this.y,this.z,this.w)},e.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},t}(),jt=[],Yt=0;Yt<256;Yt++)jt[Yt]=(Yt<16?"0":"")+Yt.toString(16);function qt(){var t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(jt[255&t]+jt[t>>8&255]+jt[t>>16&255]+jt[t>>24&255]+"-"+jt[255&e]+jt[e>>8&255]+"-"+jt[e>>16&15|64]+jt[e>>24&255]+"-"+jt[63&n|128]+jt[n>>8&255]+"-"+jt[n>>16&255]+jt[n>>24&255]+jt[255&i]+jt[i>>8&255]+jt[i>>16&255]+jt[i>>24&255]).toUpperCase()}function Qt(t){return 0==(t&t-1)&&0!==t}function Zt(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))}function Kt(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t}function Jt(t){var e={};for(var n in t){var i=t[n];Array.isArray(i)||ArrayBuffer.isView(i)?e[n]=i.slice():e[n]=i}return e}function $t(t){var e=Array.isArray(t)?[]:{};if(t&&"object"==typeof t)for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]&&"object"==typeof t[n]?$t(t[n]):t[n]);return e}var te=0,ee=new m,ne=function(){function t(){this.id=te++,this.uuid=qt(),this.name="",this.position=new _,this.scale=new _(1,1,1),this.euler=new Tt,this.quaternion=new y;var t=this.euler,e=this.quaternion;t.onChange((function(){e.setFromEuler(t,!1)})),e.onChange((function(){t.setFromQuaternion(e,void 0,!1)})),this.matrix=new m,this.worldMatrix=new m,this.children=new Array,this.parent=null,this.castShadow=!1,this.receiveShadow=!1,this.shadowType=z.PCF3_SOFT,this.frustumCulled=!0,this.visible=!0,this.renderOrder=0,this.renderLayer=0,this.renderable=!0,this.userData={},this.matrixAutoUpdate=!0,this.matrixNeedsUpdate=!0,this.worldMatrixNeedsUpdate=!0}var e=t.prototype;return e.onBeforeRender=function(){},e.onAfterRender=function(){},e.add=function(t){t!==this?(null!==t.parent&&t.parent.remove(t),t.parent=this,this.children.push(t),t.worldMatrixNeedsUpdate=!0):console.error("Object3D.add: object can't be added as a child of itself.",t)},e.remove=function(t){var e=this.children.indexOf(t);-1!==e&&(t.parent=null,this.children.splice(e,1),t.worldMatrixNeedsUpdate=!0)},e.getObjectByName=function(t){return this.getObjectByProperty("name",t)},e.getObjectByProperty=function(t,e){if(this[t]===e)return this;for(var n=0,i=this.children.length;n0){this.directionalShadowMap.length=a,this.directionalShadowDepthMap.length=a,re.length=a,this.directionalShadowMatrix.length!==16*a&&(this.directionalShadowMatrix=new Float32Array(16*a));for(var o=0;o0){this.pointShadowMap.length=s,ae.length=s,this.pointShadowMatrix.length!==16*s&&(this.pointShadowMatrix=new Float32Array(16*s));for(var u=0;u0){this.spotShadowMap.length=l,this.spotShadowDepthMap.length=l,oe.length=l,this.spotShadowMatrix.length!==16*l&&(this.spotShadowMatrix=new Float32Array(16*l));for(var c=0;ct)for(var n=this._cache,i=t;ie&&(e=t[n]);return e}(t)>65535?Uint32Array:Uint16Array)(t);this.index=new an(new on(e,1))}else this.index=t},n.addGroup=function(t,e,n){void 0===n&&(n=0),this.groups.push({start:t,count:e,materialIndex:n})},n.clearGroups=function(){this.groups=[]},n.computeBoundingBox=function(){var t=this.attributes.a_Position||this.attributes.position,e=this.morphAttributes.position;if(this.boundingBox.setFromArray(t.buffer.array,t.buffer.stride,t.offset),e)for(var n=0;na&&(a=l,ln.add(un))}}this.boundingSphere.radius=Math.sqrt(a)}else this.boundingSphere.setFromArray(t.buffer.array,t.buffer.stride,t.offset)},n.dispose=function(){this.dispatchEvent({type:"dispose"})},n.copy=function(t){var e,n,i;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[];var r=new WeakMap,a=t.index;null!==a&&this.setIndex(a.clone(r));var o=t.attributes;for(e in o){var s=o[e];this.addAttribute(e,s.clone(r))}var u=t.morphAttributes;for(e in u){var l=[],c=u[e];for(n=0,i=c.length;n65536?new Uint32Array(v):new Uint16Array(v),1))),a.addAttribute("a_Position",new an(new on(new Float32Array(m),3))),a.addAttribute("a_Normal",new an(new on(new Float32Array(g),3))),a.addAttribute("a_Uv",new an(new on(new Float32Array(E),2))),a.computeBoundingBox(),a.computeBoundingSphere(),a}return i(e,t),e}(fn),_n=0,vn=function(t){function e(){var e;return(e=t.call(this)||this).id=_n++,e.uuid=qt(),e.type=b.SHADER,e.shaderName="",e.defines={},e.uniforms={},e.vertexShader="",e.fragmentShader="",e.precision=null,e.transparent=!1,e.blending=R.NORMAL,e.blendSrc=P.SRC_ALPHA,e.blendDst=P.ONE_MINUS_SRC_ALPHA,e.blendEquation=N.ADD,e.blendSrcAlpha=null,e.blendDstAlpha=null,e.blendEquationAlpha=null,e.premultipliedAlpha=!1,e.vertexColors=X.NONE,e.vertexTangents=!1,e.opacity=1,e.diffuse=new gt(16777215),e.diffuseMap=null,e.diffuseMapCoord=0,e.diffuseMapTransform=new xt,e.alphaMap=null,e.alphaMapCoord=0,e.alphaMapTransform=new xt,e.emissive=new gt(0),e.emissiveMap=null,e.emissiveMapCoord=0,e.emissiveMapTransform=new xt,e.aoMap=null,e.aoMapIntensity=1,e.aoMapCoord=0,e.aoMapTransform=new xt,e.normalMap=null,e.normalScale=new pt(1,1),e.bumpMap=null,e.bumpScale=1,e.envMap=null,e.envMapIntensity=1,e.envMapCombine=V.MULTIPLY,e.depthFunc=B.LEQUAL,e.depthTest=!0,e.depthWrite=!0,e.colorWrite=!0,e.stencilTest=!1,e.stencilWriteMask=255,e.stencilFunc=B.ALWAYS,e.stencilRef=0,e.stencilFuncMask=255,e.stencilFail=G.KEEP,e.stencilZFail=G.KEEP,e.stencilZPass=G.KEEP,e.stencilFuncBack=null,e.stencilRefBack=null,e.stencilFuncMaskBack=null,e.stencilFailBack=null,e.stencilZFailBack=null,e.stencilZPassBack=null,e.clippingPlanes=null,e.alphaTest=0,e.alphaToCoverage=!1,e.side=C.FRONT,e.polygonOffset=!1,e.polygonOffsetFactor=0,e.polygonOffsetUnits=0,e.shading=D.SMOOTH_SHADING,e.dithering=!1,e.acceptLight=!1,e.fog=!0,e.drawMode=k.TRIANGLES,e.needsUpdate=!0,e}i(e,t);var n=e.prototype;return n.copy=function(t){return this.shaderName=t.shaderName,this.defines=Object.assign({},t.defines),this.uniforms=Jt(t.uniforms),this.vertexShader=t.vertexShader,this.fragmentShader=t.fragmentShader,this.precision=t.precision,this.transparent=t.transparent,this.blending=t.blending,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.premultipliedAlpha=t.premultipliedAlpha,this.vertexColors=t.vertexColors,this.vertexTangents=t.vertexTangents,this.opacity=t.opacity,this.diffuse.copy(t.diffuse),this.diffuseMap=t.diffuseMap,this.diffuseMapCoord=t.diffuseMapCoord,this.diffuseMapTransform.copy(t.diffuseMapTransform),this.alphaMap=t.alphaMap,this.alphaMapCoord=t.alphaMapCoord,this.alphaMapTransform.copy(t.alphaMapTransform),this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveMapCoord=t.emissiveMapCoord,this.emissiveMapTransform.copy(t.emissiveMapTransform),this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.aoMapCoord=t.aoMapCoord,this.aoMapTransform.copy(t.aoMapTransform),this.normalMap=t.normalMap,this.normalScale.copy(t.normalScale),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.envMap=t.envMap,this.envMapIntensity=t.envMapIntensity,this.envMapCombine=t.envMapCombine,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.colorWrite=t.colorWrite,this.stencilTest=t.stencilTest,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilFuncBack=t.stencilFuncBack,this.stencilRefBack=t.stencilRefBack,this.stencilFuncMaskBack=t.stencilFuncMaskBack,this.stencilFailBack=t.stencilFailBack,this.stencilZFailBack=t.stencilZFailBack,this.stencilZPassBack=t.stencilZPassBack,this.clippingPlanes=t.clippingPlanes,this.alphaTest=t.alphaTest,this.alphaToCoverage=t.alphaToCoverage,this.side=t.side,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.shading=t.shading,this.dithering=t.dithering,this.acceptLight=t.acceptLight,this.fog=t.fog,this.drawMode=t.drawMode,this},n.clone=function(){return(new this.constructor).copy(this)},n.dispose=function(){this.dispatchEvent({type:"dispose"})},e}(q),mn=function(t){function e(e){var n;return n=t.call(this)||this,e&&(n.shaderName=e.name,Object.assign(n.defines,e.defines),n.uniforms=Jt(e.uniforms),n.vertexShader=e.vertexShader,n.fragmentShader=e.fragmentShader),n}return i(e,t),e}(vn),gn=function(){function t(t){var e=new Re,n=this.camera=new Ne;n.frustumCulled=!1,n.position.set(0,1,0),n.lookAt(new _(0,0,0),new _(0,0,-1)),n.setOrtho(-1,1,-1,1,.1,2),e.add(n);var i=this.geometry=new pn(2,2,1,1),r=this.material=new mn(t);this.uniforms=r.uniforms;var a=new tn(i,r);a.frustumCulled=!1,e.add(a),e.updateMatrix(),this.renderStates=e.updateRenderStates(n);var o=e.updateRenderQueue(n,!1,!1);this.renderQueueLayer=o.layerList[0],this.renderConfig={}}var e=t.prototype;return e.render=function(t){t.renderRenderableList(this.renderQueueLayer.opaque,this.renderStates,this.renderConfig)},e.dispose=function(){this.geometry.dispose(),this.material.dispose()},t}(),En=function(t){function e(){var e;return(e=t.call(this)||this).type=b.DEPTH,e.packToRGBA=!1,e}return i(e,t),e}(vn),Sn=function(t){function e(){var e;return(e=t.call(this)||this).type=b.DISTANCE,e}return i(e,t),e}(vn),Mn=function(){function t(){this.getDepthMaterial=wn,this.getDistanceMaterial=bn,this.getGeometry=null,this.shadowLayers=null,this.transparentShadow=!1}return t.prototype.render=function(t,e){var n=this,i=t.renderPass,r=this.getGeometry,a=this.getDepthMaterial,o=this.getDistanceMaterial;Tn.copy(i.getClearColor()),i.setClearColor(1,1,1,1);for(var s=e._lightData.lights,u=e._lightData.shadowsNum,l=function(){var u=s[c],l=u.shadow;if(!1===l.autoUpdate&&!1===l.needsUpdate)return"continue";var h=l.camera,d=l.renderTarget,f=u.isPointLight,p=f?6:1;l.prepareDepthMap(!e.disableShadowSampler,i.capabilities);for(var _=0;_0,r=t.material.clippingPlanes,a=r&&r.length>0?r.length:0,o=i<<0|n<<1,s=xn[o];void 0===s&&(s={},xn[o]=s);var u=s[a];return void 0===u&&((u=new En).packToRGBA=!0,s[a]=u),u.side=yn[t.material.side],u.clippingPlanes=t.material.clippingPlanes,u.drawMode=t.material.drawMode,u}function bn(t,e){var n=!!t.object.skeleton,i=t.geometry.morphAttributes.position&&t.geometry.morphAttributes.position.length>0,r=t.material.clippingPlanes,a=r&&r.length>0?r.length:0,o=i<<0|n<<1,s=An[o];void 0===s&&(s={},An[o]=s);var u=s[a];return void 0===u&&(u=new Sn,s[a]=u),u.side=yn[t.material.side],u.uniforms.nearDistance=e.shadow.cameraNear,u.uniforms.farDistance=e.shadow.cameraFar,u.clippingPlanes=t.material.clippingPlanes,u.drawMode=t.material.drawMode,u}var Rn=0,Nn=function(t){function e(){var e;return(e=t.call(this)||this).id=Rn++,e.mipmaps=[],e.border=0,e.format=O.RGBA,e.internalformat=null,e.type=F.UNSIGNED_BYTE,e.magFilter=I.LINEAR,e.minFilter=I.LINEAR_MIPMAP_LINEAR,e.wrapS=U.CLAMP_TO_EDGE,e.wrapT=U.CLAMP_TO_EDGE,e.anisotropy=1,e.compare=void 0,e.generateMipmaps=!0,e.encoding=H.LINEAR,e.flipY=!0,e.premultiplyAlpha=!1,e.unpackAlignment=4,e.version=0,e}i(e,t);var n=e.prototype;return n.clone=function(){return(new this.constructor).copy(this)},n.copy=function(t){return this.mipmaps=t.mipmaps.slice(0),this.border=t.border,this.format=t.format,this.internalformat=t.internalformat,this.type=t.type,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.anisotropy=t.anisotropy,this.compare=t.compare,this.generateMipmaps=t.generateMipmaps,this.encoding=t.encoding,this.flipY=t.flipY,this.premultiplyAlpha=t.premultiplyAlpha,this.unpackAlignment=t.unpackAlignment,this.version=t.version,this},n.dispose=function(){this.dispatchEvent({type:"dispose"}),this.version=0},e}(q);Nn.prototype.isTexture=!0;var Pn=function(t){function e(){var e;return(e=t.call(this)||this).image=null,e}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.image=e.image,this},e}(Nn);Pn.prototype.isTexture2D=!0;var Ln=function(t){function e(){var e;return(e=t.call(this)||this).images=[],e.flipY=!1,e}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.images=e.images.slice(0),this},e}(Nn);Ln.prototype.isTextureCube=!0;var Cn=function(t){function e(){var e;return(e=t.call(this)||this).image={data:new Uint8Array([255,255,255,255,255,255,255,255]),width:2,height:2,depth:2},e.wrapR=U.CLAMP_TO_EDGE,e.format=O.RED,e.type=F.UNSIGNED_BYTE,e.magFilter=I.NEAREST,e.minFilter=I.NEAREST,e.generateMipmaps=!1,e.flipY=!1,e.unpackAlignment=1,e}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.image=e.image,this},e}(Nn);Cn.prototype.isTexture3D=!0;var Dn={u_Model:[1,null],u_Projection:[2,function(t){this.set(t.projectionMatrix.elements)}],u_View:[2,function(t){this.set(t.viewMatrix.elements)}],u_ProjectionView:[2,function(t){this.set(t.projectionViewMatrix.elements)}],u_CameraPosition:[2,function(t){this.setValue(t.position.x,t.position.y,t.position.z)}],logDepthBufFC:[2,function(t){this.set(t.logDepthBufFC)}],logDepthCameraNear:[2,function(t){this.set(t.logDepthCameraNear)}],u_EnvMapLight_Intensity:[3,function(t){this.set(t.environmentLightIntensity)}],u_FogColor:[3,function(t){var e=t.fog.color;this.setValue(e.r,e.g,e.b)}],u_FogDensity:[3,function(t){this.set(t.fog.density)}],u_FogNear:[3,function(t){this.set(t.fog.near)}],u_FogFar:[3,function(t){this.set(t.fog.far)}],u_Color:[4,function(t,e){var n=t.diffuse;this.setValue(n.r,n.g,n.b)}],u_Opacity:[4,function(t,e){this.set(t.opacity)}],diffuseMap:[4,function(t,e){this.set(t.diffuseMap,e)}],alphaMap:[4,function(t,e){this.set(t.alphaMap,e)}],alphaMapUVTransform:[4,function(t,e){this.set(t.alphaMapTransform.elements)}],normalMap:[4,function(t,e){this.set(t.normalMap,e)}],normalScale:[4,function(t,e){this.setValue(t.normalScale.x,t.normalScale.y)}],bumpMap:[4,function(t,e){this.set(t.bumpMap,e)}],bumpScale:[4,function(t,e){this.set(t.bumpScale)}],cubeMap:[4,function(t,e){this.set(t.cubeMap,e)}],u_EnvMap_Intensity:[4,function(t,e){this.set(t.envMapIntensity)}],u_Specular:[4,function(t,e){this.set(t.shininess)}],u_SpecularColor:[4,function(t,e){var n=t.specular;this.setValue(n.r,n.g,n.b)}],specularMap:[4,function(t,e){this.set(t.specularMap,e)}],aoMap:[4,function(t,e){this.set(t.aoMap,e)}],aoMapIntensity:[4,function(t,e){this.set(t.aoMapIntensity)}],aoMapUVTransform:[4,function(t,e){this.set(t.aoMapTransform.elements)}],u_Roughness:[4,function(t,e){this.set(t.roughness)}],roughnessMap:[4,function(t,e){this.set(t.roughnessMap,e)}],u_Metalness:[4,function(t,e){this.set(t.metalness)}],metalnessMap:[4,function(t,e){this.set(t.metalnessMap,e)}],u_Clearcoat:[4,function(t,e){this.set(t.clearcoat)}],u_ClearcoatRoughness:[4,function(t,e){this.set(t.clearcoatRoughness)}],clearcoatMap:[4,function(t,e){this.set(t.clearcoatMap,e)}],clearcoatRoughnessMap:[4,function(t,e){this.set(t.clearcoatRoughnessMap,e)}],clearcoatNormalMap:[4,function(t,e){this.set(t.clearcoatNormalMap,e)}],clearcoatNormalScale:[4,function(t,e){this.setValue(t.clearcoatNormalScale.x,t.clearcoatNormalScale.y)}],glossiness:[4,function(t,e){this.set(t.glossiness)}],glossinessMap:[4,function(t,e){this.set(t.glossinessMap,e)}],emissive:[4,function(t,e){var n=t.emissive;this.setValue(n.r,n.g,n.b)}],emissiveMap:[4,function(t,e){this.set(t.emissiveMap,e)}],emissiveMapUVTransform:[4,function(t,e){this.set(t.emissiveMapTransform.elements)}],matcap:[4,function(t,e){this.set(t.matcap,e)}],uvTransform:[4,function(t,e){this.set(t.diffuseMapTransform.elements)}],u_PointSize:[4,function(t,e){this.set(t.size)}],u_PointScale:[5,null],maxMipLevel:[5,function(t,e){this.set(e.get(t).__maxMipLevel||8)}],envMap:[5,function(t,e){this.set(t,e)}],u_EnvMap_Flip:[5,function(t,e){this.set(t.images[0]&&t.images[0].rtt?1:-1)}]},On=new Pn;On.image={data:new Uint8Array([1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1]),width:2,height:2},On.magFilter=I.NEAREST,On.minFilter=I.NEAREST,On.generateMipmaps=!1,On.version++;var Fn=new Pn;Fn.image={data:null,width:2,height:2},Fn.version++,Fn.type=F.FLOAT_32_UNSIGNED_INT_24_8_REV,Fn.format=O.DEPTH_STENCIL,Fn.magFilter=I.NEAREST,Fn.minFilter=I.NEAREST,Fn.compare=B.LESS,Fn.generateMipmaps=!1,Fn.version++;var In=new Cn,Un=new Ln;function Bn(t,e){if(t.length!==e.length)return!1;for(var n=0,i=t.length;n":" ")+" "+s+": "+n[o])}return i.join("\n")}(t.getShaderSource(e),o)}return r}var ni={alphaTest_frag:"#ifdef ALPHATEST\n\tif ( outColor.a < ALPHATEST ) {\n\t\tdiscard;\n\t} else {\n\t\toutColor.a = u_Opacity;\n\t}\n#endif",aoMap_pars_frag:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n\tvarying vec2 vAOMapUV;\n#endif",aoMap_pars_vert:"#ifdef USE_AOMAP\n\tuniform mat3 aoMapUVTransform;\n\tvarying vec2 vAOMapUV;\n#endif",aoMap_vert:"#ifdef USE_AOMAP\n\t#if (USE_AOMAP == 2)\n\t\t\t\tvAOMapUV = (aoMapUVTransform * vec3(a_Uv2, 1.)).xy;\n\t\t#else\n\t\t\t\tvAOMapUV = (aoMapUVTransform * vec3(a_Uv, 1.)).xy;\n\t\t#endif\n#endif",aoMap_frag:"\n#ifdef USE_AOMAP\n\t\tfloat ambientOcclusion = (texture2D(aoMap, vAOMapUV).r - 1.0) * aoMapIntensity + 1.0;\n\t\t\n\t\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t\t#if defined(USE_ENV_MAP) && defined(USE_PBR)\n\t\t\t\tfloat dotNV = saturate(dot(N, V));\n\t\t\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion(dotNV, ambientOcclusion, GGXRoughnessToBlinnExponent(roughness));\n\t\t#endif\n#endif",begin_frag:"vec4 outColor = vec4(u_Color, u_Opacity);",begin_vert:"vec3 transformed = vec3(a_Position);\nvec3 objectNormal = vec3(a_Normal);\n#ifdef USE_TANGENT\n\t\tvec3 objectTangent = vec3(a_Tangent.xyz);\n#endif",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}\nvec3 BRDF_Diffuse_Lambert(vec3 diffuseColor) {\n\t\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 D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nvec3 BRDF_Specular_BlinnPhong(vec3 specularColor, vec3 N, vec3 L, vec3 V, float shininess) {\n\t\tvec3 H = normalize(L + V);\n\t\tfloat dotNH = saturate(dot(N, H));\n\t\tfloat dotLH = saturate(dot(L, H));\n\t\tvec3 F = F_Schlick(specularColor, dotLH);\n\t\tfloat G = G_BlinnPhong_Implicit( );\n\t\tfloat D = D_BlinnPhong(shininess, dotNH);\n\t\treturn F * G * D;\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}\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}\nvec3 BRDF_Specular_GGX(vec3 specularColor, vec3 N, vec3 L, vec3 V, float roughness) {\n\tfloat alpha = pow2( roughness );\n\tvec3 H = normalize(L + V);\n\tfloat dotNL = saturate( dot(N, L) );\n\tfloat dotNV = saturate( dot(N, V) );\n\tfloat dotNH = saturate( dot(N, H) );\n\tfloat dotLH = saturate( dot(L, H) );\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}\nvec3 BRDF_Specular_GGX_Environment(const in vec3 N, const in vec3 V, const in vec3 specularColor, const in float roughness) {\n\tfloat dotNV = saturate(dot(N, V));\n\tvec2 brdf = integrateSpecularBRDF(dotNV, roughness);\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment(const in vec3 N, const in vec3 V, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter) {\n\tfloat dotNV = saturate(dot(N, V));\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 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}\nfloat getAARoughnessFactor(vec3 normal) {\n\tvec3 dxy = max( abs(dFdx(normal)), abs(dFdy(normal)) );\n\treturn 0.04 + max( max(dxy.x, dxy.y), dxy.z );\n}",bumpMap_pars_frag:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd(vec2 uv) {\n\t\tvec2 dSTdx = dFdx( uv );\n\t\tvec2 dSTdy = dFdy( uv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, uv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, uv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, uv + 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",clippingPlanes_frag:"\n#if NUM_CLIPPING_PLANES > 0\n\t\tvec4 plane;\n\t\t#pragma unroll_loop_start\n\t\tfor (int i = 0; i < NUM_CLIPPING_PLANES; i++) {\n\t\t\t\tplane = clippingPlanes[i];\n\t\t\t\tif ( dot( -v_modelPos, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n#endif",clippingPlanes_pars_frag:"#if NUM_CLIPPING_PLANES > 0\n\t\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",color_frag:"#ifdef USE_VCOLOR_RGB\n\t\toutColor.rgb *= v_Color;\n#endif\n#ifdef USE_VCOLOR_RGBA\n\t\toutColor *= v_Color;\n#endif",color_pars_frag:"#ifdef USE_VCOLOR_RGB\n\t\tvarying vec3 v_Color;\n#endif\n#ifdef USE_VCOLOR_RGBA\n\t\tvarying vec4 v_Color;\n#endif",color_pars_vert:"#ifdef USE_VCOLOR_RGB\n\t\tattribute vec3 a_Color;\n\t\tvarying vec3 v_Color;\n#endif\n#ifdef USE_VCOLOR_RGBA\n\t\tattribute vec4 a_Color;\n\t\tvarying vec4 v_Color;\n#endif",color_vert:"#if defined(USE_VCOLOR_RGB) || defined(USE_VCOLOR_RGBA)\n\t\tv_Color = a_Color;\n#endif",common_frag:"uniform mat4 u_View;\nuniform float u_Opacity;\nuniform vec3 u_Color;\nuniform vec3 u_CameraPosition;\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};",common_vert:"attribute vec3 a_Position;\nattribute vec3 a_Normal;\n#ifdef USE_TANGENT\n\tattribute vec4 a_Tangent;\n#endif\n#include \n#include \nuniform mat4 u_Projection;\nuniform mat4 u_View;\nuniform mat4 u_Model;\nuniform mat4 u_ProjectionView;\nuniform vec3 u_CameraPosition;\n#define EPSILON 1e-6\n#ifdef USE_MORPHTARGETS\n\t\tattribute vec3 morphTarget0;\n\t\tattribute vec3 morphTarget1;\n\t\tattribute vec3 morphTarget2;\n\t\tattribute vec3 morphTarget3;\n\t\t#ifdef USE_MORPHNORMALS\n\t\t\tattribute vec3 morphNormal0;\n\t\t\tattribute vec3 morphNormal1;\n\t\t\tattribute vec3 morphNormal2;\n\t\t\tattribute vec3 morphNormal3;\n\t\t#else\n\t\t\tattribute vec3 morphTarget4;\n\t\t\tattribute vec3 morphTarget5;\n\t\t\tattribute vec3 morphTarget6;\n\t\t\tattribute vec3 morphTarget7;\n\t\t#endif\n#endif\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}",diffuseMap_frag:"#ifdef USE_DIFFUSE_MAP\n\t\t#if (USE_DIFFUSE_MAP == 2)\n\t\t\t\tvec4 texelColor = texture2D(diffuseMap, v_Uv2);\n\t\t#else \n\t\t\t\tvec4 texelColor = texture2D(diffuseMap, v_Uv);\n\t\t#endif\n\t\t\n\t\ttexelColor = mapTexelToLinear(texelColor);\n\t\toutColor *= texelColor;\n#endif",diffuseMap_pars_frag:"#ifdef USE_DIFFUSE_MAP\n\t\tuniform sampler2D diffuseMap;\n#endif",emissiveMap_frag:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D(emissiveMap, vEmissiveMapUV);\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissiveMap_pars_frag:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n\tvarying vec2 vEmissiveMapUV;\n#endif",emissiveMap_vert:"#ifdef USE_EMISSIVEMAP\n\t#if (USE_EMISSIVEMAP == 2)\n\t\t\t\tvEmissiveMapUV = (emissiveMapUVTransform * vec3(a_Uv2, 1.)).xy;\n\t\t#else\n\t\t\t\tvEmissiveMapUV = (emissiveMapUVTransform * vec3(a_Uv, 1.)).xy;\n\t\t#endif\n#endif",emissiveMap_pars_vert:"#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapUVTransform;\n\tvarying vec2 vEmissiveMapUV;\n#endif",encodings_frag:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_frag:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\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.w );\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.w );\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.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M\t\t\t= clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM\t\t\t\t\t\t= 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.x, max( value.g, value.b ) );\n\tfloat D\t\t\t= max( maxRange / maxRGB, 1.0 );\n\tD\t\t\t\t\t\t= 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 )\t{\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\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 = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}",end_frag:"gl_FragColor = outColor;",envMap_frag:"#ifdef USE_ENV_MAP\n\t\tvec3 envDir;\n\t\t#ifdef USE_VERTEX_ENVDIR\n\t\t\t\tenvDir = v_EnvDir;\n\t\t#else\n\t\t\t\tenvDir = reflect(normalize(v_modelPos - u_CameraPosition), N);\n\t\t#endif\n\t\tvec4 envColor = textureCube(envMap, vec3(u_EnvMap_Flip * envDir.x, envDir.yz));\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutColor = mix(outColor, envColor * outColor, u_EnvMap_Intensity);\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutColor = mix(outColor, envColor, u_EnvMap_Intensity);\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutColor += envColor * u_EnvMap_Intensity;\n\t#endif\n#endif",envMap_pars_frag:"#ifdef USE_ENV_MAP\n\t\t#ifdef USE_VERTEX_ENVDIR\n\t\t\t\tvarying vec3 v_EnvDir;\n\t\t#endif\n\t\tuniform samplerCube envMap;\n\t\tuniform float u_EnvMap_Flip;\n\t\tuniform float u_EnvMap_Intensity;\n\t\tuniform float u_EnvMapLight_Intensity;\n\t\tuniform int maxMipLevel;\n#endif",envMap_pars_vert:"#ifdef USE_ENV_MAP\n\t\t#ifdef USE_VERTEX_ENVDIR\n\t\t\t\tvarying vec3 v_EnvDir;\n\t\t#endif\n#endif",envMap_vert:"\n#ifdef USE_ENV_MAP\n\t\t#ifdef USE_VERTEX_ENVDIR\n\t\t\t\tvec3 transformedNormal = (transposeMat4(inverseMat4(u_Model)) * vec4(objectNormal, 0.0)).xyz;\n\t\t\t\ttransformedNormal = normalize(transformedNormal);\n\t\t\t\tv_EnvDir = reflect(normalize(worldPosition.xyz - u_CameraPosition), transformedNormal);\n\t\t#endif\n#endif",fog_frag:"#ifdef USE_FOG\n\t\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\t\t#ifdef USE_EXP2_FOG\n\t\t\t\tfloat fogFactor = 1.0 - exp(-u_FogDensity * u_FogDensity * depth * depth);\n\t\t#else\n\t\t\t\tfloat fogFactor = smoothstep(u_FogNear, u_FogFar, depth);\n\t\t#endif\n\t\tgl_FragColor.rgb = mix(gl_FragColor.rgb, u_FogColor, fogFactor);\n#endif",fog_pars_frag:"#ifdef USE_FOG\n\t\tuniform vec3 u_FogColor;\n\t\t#ifdef USE_EXP2_FOG\n\t\t\t\tuniform float u_FogDensity;\n\t\t#else\n\t\t\t\tuniform float u_FogNear;\n\t\t\t\tuniform float u_FogFar;\n\t\t#endif\n#endif",inverse:"mat4 inverseMat4(mat4 m) {\n\t\tfloat\n\t\ta00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n\t\ta10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n\t\ta20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n\t\ta30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\t\tb00 = a00 * a11 - a01 * a10,\n\t\tb01 = a00 * a12 - a02 * a10,\n\t\tb02 = a00 * a13 - a03 * a10,\n\t\tb03 = a01 * a12 - a02 * a11,\n\t\tb04 = a01 * a13 - a03 * a11,\n\t\tb05 = a02 * a13 - a03 * a12,\n\t\tb06 = a20 * a31 - a21 * a30,\n\t\tb07 = a20 * a32 - a22 * a30,\n\t\tb08 = a20 * a33 - a23 * a30,\n\t\tb09 = a21 * a32 - a22 * a31,\n\t\tb10 = a21 * a33 - a23 * a31,\n\t\tb11 = a22 * a33 - a23 * a32,\n\t\tdet = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\t\treturn mat4(\n\t\t\t\ta11 * b11 - a12 * b10 + a13 * b09,\n\t\t\t\ta02 * b10 - a01 * b11 - a03 * b09,\n\t\t\t\ta31 * b05 - a32 * b04 + a33 * b03,\n\t\t\t\ta22 * b04 - a21 * b05 - a23 * b03,\n\t\t\t\ta12 * b08 - a10 * b11 - a13 * b07,\n\t\t\t\ta00 * b11 - a02 * b08 + a03 * b07,\n\t\t\t\ta32 * b02 - a30 * b05 - a33 * b01,\n\t\t\t\ta20 * b05 - a22 * b02 + a23 * b01,\n\t\t\t\ta10 * b10 - a11 * b08 + a13 * b06,\n\t\t\t\ta01 * b08 - a00 * b10 - a03 * b06,\n\t\t\t\ta30 * b04 - a31 * b02 + a33 * b00,\n\t\t\t\ta21 * b02 - a20 * b04 - a23 * b00,\n\t\t\t\ta11 * b07 - a10 * b09 - a12 * b06,\n\t\t\t\ta00 * b09 - a01 * b07 + a02 * b06,\n\t\t\t\ta31 * b01 - a30 * b03 - a32 * b00,\n\t\t\t\ta20 * b03 - a21 * b01 + a22 * b00) / det;\n}",light_frag:"\n#if (defined(USE_PHONG) || defined(USE_PBR))\n\t\tvec3 V = normalize(u_CameraPosition - v_modelPos);\n#endif\n#ifdef USE_PBR\n\t\t#ifdef USE_PBR2\n\t\t\t\tvec3 diffuseColor = outColor.xyz;\n\t\t\t\tvec3 specularColor = specularFactor.xyz;\n\t\t\t\tfloat roughness = max(1.0 - glossinessFactor, 0.0525);\n\t\t#else\n\t\t\t\tvec3 diffuseColor = outColor.xyz * (1.0 - metalnessFactor);\n\t\t\t\tvec3 specularColor = mix(vec3(0.04), outColor.xyz, metalnessFactor);\n\t\t\t\tfloat roughness = max(roughnessFactor, 0.0525);\n\t\t#endif\n\t\troughness = min(max(roughness, getAARoughnessFactor(N)), 1.0);\n\t\t#ifdef USE_CLEARCOAT\n\t\t\t\tfloat clearcoat = u_Clearcoat;\n\t\t\t\tfloat clearcoatRoughness = u_ClearcoatRoughness;\n\t\t\t\t#ifdef USE_CLEARCOATMAP\n\t\t\t\tclearcoat *= texture2D(clearcoatMap, v_Uv).x;\n\t\t\t\t#endif\n\t\t\t\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\t\t\tclearcoatRoughness *= texture2D(clearcoatRoughnessMap, v_Uv).y;\n\t\t\t#endif\n\t\t\t\tclearcoat = saturate(clearcoat);\n\t\t\t\tclearcoatRoughness = max(clearcoatRoughness, 0.0525);\n\t\t\tclearcoatRoughness = min(max(clearcoatRoughness, getAARoughnessFactor(geometryNormal)), 1.0);\n\t\t#endif\n#else\n\t\tvec3 diffuseColor = outColor.xyz;\n\t\t#ifdef USE_PHONG\n\t\t\t\tvec3 specularColor = u_SpecularColor.xyz;\n\t\t\t\tfloat shininess = u_Specular;\n\t\t#endif\n#endif\n#ifdef USE_LIGHT\n\t\tvec3 L;\n\t\tfloat falloff;\n\t\tfloat dotNL;\n\t\tvec3 irradiance;\n\t\tfloat clearcoatDHR;\n\t\t#ifdef USE_CLEARCOAT\n\t\t\t\tfloat ccDotNL;\n\t\t\t\tvec3 ccIrradiance;\n\t\t#endif\n\t\t#if NUM_DIR_LIGHTS > 0\n\t\t\t\t#pragma unroll_loop_start\n\t\t\t\tfor (int i = 0; i < NUM_DIR_LIGHTS; i++) {\n\t\t\t\t\t\tL = normalize(-u_Directional[i].direction);\n\t\t\t\t\t\tfalloff = 1.0;\n\t\t\t\t\t\t#if defined(USE_SHADOW) && (UNROLLED_LOOP_INDEX < NUM_DIR_SHADOWS)\n\t\t\t\t\t\t\t\t#ifdef USE_PCSS_SOFT_SHADOW\n\t\t\t\t\t\t\t\t\t\tfalloff *= getShadowWithPCSS(directionalDepthMap[i], directionalShadowMap[i], vDirectionalShadowCoord[i], u_DirectionalShadow[i].shadowMapSize, u_DirectionalShadow[i].shadowBias, u_DirectionalShadow[i].shadowParams);\n\t\t\t\t\t\t\t\t#else\n\t\t\t\t\t\t\t\t\t\tfalloff *= getShadow(directionalShadowMap[i], vDirectionalShadowCoord[i], u_DirectionalShadow[i].shadowMapSize, u_DirectionalShadow[i].shadowBias, u_DirectionalShadow[i].shadowParams);\n\t\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\tdotNL = saturate(dot(N, L));\n\t\t\t\t\t\tirradiance = u_Directional[i].color * falloff * dotNL * PI;\n\t\t\t\t\t\t#ifdef USE_CLEARCOAT\t\t\t\t\n\t\t\t\t\t\t\t\tccDotNL = saturate(dot(clearcoatNormal, L));\n\t\t\t\t\t\t\t\tccIrradiance = ccDotNL * u_Directional[i].color * falloff\t* PI;\n\t\t\t\t\t\t\t\tclearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n\t\t\t\t\t\t\t\treflectedLight.directSpecular += ccIrradiance * clearcoat * BRDF_Specular_GGX(specularColor, clearcoatNormal, L, V, clearcoatRoughness);\n\t\t\t\t\t\t#else\n\t\t\t\t\t\tclearcoatDHR = 0.0;\n\t\t\t\t\t#endif\n\t\t\t\t\t\treflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance * BRDF_Diffuse_Lambert(diffuseColor);\n\t\t\t\t\t\t#ifdef USE_PHONG\n\t\t\t\t\t\t\t\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#ifdef USE_PBR\n\t\t\t\t\t\t\t\treflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness);\n\t\t\t\t\t\t#endif\n\t\t\t\t}\n\t\t\t\t#pragma unroll_loop_end\n\t\t#endif\n\t\t#if NUM_POINT_LIGHTS > 0\n\t\t\t\tvec3 worldV;\n\t\t\t\t#pragma unroll_loop_start\n\t\t\t\tfor (int i = 0; i < NUM_POINT_LIGHTS; i++) {\n\t\t\t\t\t\tworldV = v_modelPos - u_Point[i].position;\n\t\t\t\t\t\tL = -worldV;\n\t\t\t\t\t\tfalloff = pow(clamp(1. - length(L) / u_Point[i].distance, 0.0, 1.0), u_Point[i].decay);\n\t\t\t\t\t\tL = normalize(L);\n\t\t\t\t\t\t#if defined(USE_SHADOW) && (UNROLLED_LOOP_INDEX < NUM_POINT_SHADOWS)\n\t\t\t\t\t\t\t\tfalloff *= getPointShadow(pointShadowMap[i], vPointShadowCoord[i], u_PointShadow[i].shadowMapSize, u_PointShadow[i].shadowBias, u_PointShadow[i].shadowParams, u_PointShadow[i].shadowCameraRange);\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\tdotNL = saturate(dot(N, L));\n\t\t\t\t\t\tirradiance = u_Point[i].color * falloff * dotNL * PI;\n\t\t\t\t\t\t#ifdef USE_CLEARCOAT\t\t\t\t\n\t\t\t\t\t\t\t\tccDotNL = saturate(dot(clearcoatNormal, L));\n\t\t\t\t\t\t\t\tccIrradiance = ccDotNL *\tu_Point[i].color * falloff\t* PI;\n\t\t\t\t\t\t\t\tclearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n\t\t\t\t\t\t\t\treflectedLight.directSpecular += ccIrradiance * clearcoat * BRDF_Specular_GGX(specularColor, clearcoatNormal, L, V, clearcoatRoughness);\n\t\t\t\t\t\t#else\n\t\t\t\t\t\tclearcoatDHR = 0.0;\n\t\t\t\t\t#endif\n\t\t\t\t\t\treflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance * BRDF_Diffuse_Lambert(diffuseColor);\n\t\t\t\t\t\t#ifdef USE_PHONG\n\t\t\t\t\t\t\t\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#ifdef USE_PBR\n\t\t\t\t\t\t\t\treflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness);\n\t\t\t\t\t\t#endif\n\t\t\t\t}\n\t\t\t\t#pragma unroll_loop_end\n\t\t#endif\n\t\t#if NUM_SPOT_LIGHTS > 0\n\t\t\t\tfloat lightDistance;\n\t\t\t\tfloat angleCos;\n\t\t\t\t#pragma unroll_loop_start\n\t\t\t\tfor (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\n\t\t\t\t\t\tL = u_Spot[i].position - v_modelPos;\n\t\t\t\t\t\tlightDistance = length(L);\n\t\t\t\t\t\tL = normalize(L);\n\t\t\t\t\t\tangleCos = dot(L, -normalize(u_Spot[i].direction));\n\t\t\t\t\t\tfalloff = smoothstep(u_Spot[i].coneCos, u_Spot[i].penumbraCos, angleCos);\n\t\t\t\t\t\tfalloff *= pow(clamp(1. - lightDistance / u_Spot[i].distance, 0.0, 1.0), u_Spot[i].decay);\n\t\t\t\t\t\t#if defined(USE_SHADOW) && (UNROLLED_LOOP_INDEX < NUM_SPOT_SHADOWS)\n\t\t\t\t\t\t\t\t#ifdef USE_PCSS_SOFT_SHADOW\n\t\t\t\t\t\t\t\t\t\tfalloff *= getShadowWithPCSS(spotDepthMap[i], spotShadowMap[i], vSpotShadowCoord[i], u_SpotShadow[i].shadowMapSize, u_SpotShadow[i].shadowBias, u_SpotShadow[i].shadowParams);\n\t\t\t\t\t\t\t\t#else\n\t\t\t\t\t\t\t\t\t\tfalloff *= getShadow(spotShadowMap[i], vSpotShadowCoord[i], u_SpotShadow[i].shadowMapSize, u_SpotShadow[i].shadowBias, u_SpotShadow[i].shadowParams);\n\t\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\tdotNL = saturate(dot(N, L));\n\t\t\t\t\t\tirradiance = u_Spot[i].color * falloff * dotNL * PI;\n\t\t\t\t\t\t#ifdef USE_CLEARCOAT\t\t\t\t\n\t\t\t\t\t\t\t\tccDotNL = saturate(dot(clearcoatNormal, L));\n\t\t\t\t\t\t\t\tccIrradiance = ccDotNL *\tu_Spot[i].color * falloff\t* PI;\n\t\t\t\t\t\t\t\tclearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n\t\t\t\t\t\t\t\treflectedLight.directSpecular += ccIrradiance * clearcoat * BRDF_Specular_GGX(specularColor, clearcoatNormal, L, V, clearcoatRoughness);\n\t\t\t\t\t\t#else\n\t\t\t\t\t\tclearcoatDHR = 0.0;\n\t\t\t\t\t#endif\n\t\t\t\t\t\treflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance * BRDF_Diffuse_Lambert(diffuseColor);\n\t\t\t\t\t\t#ifdef USE_PHONG\n\t\t\t\t\t\t\t\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#ifdef USE_PBR\n\t\t\t\t\t\t\t\treflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness);\n\t\t\t\t\t\t#endif\n\t\t\t\t}\n\t\t\t\t#pragma unroll_loop_end\n\t\t#endif\n\t\tvec3 iblIrradiance = vec3(0., 0., 0.);\n\t\tvec3 indirectIrradiance = vec3(0., 0., 0.);\n\t\tvec3 indirectRadiance = vec3(0., 0., 0.);\n\t\tvec3 clearcoatRadiance = vec3(0., 0., 0.);\n\t\t#ifdef USE_AMBIENT_LIGHT\n\t\t\t\tindirectIrradiance += u_AmbientLightColor * PI;\n\t\t#endif\n\t\t#if NUM_HEMI_LIGHTS > 0\n\t\t\t\tfloat hemiDiffuseWeight;\n\t\t\t\t#pragma unroll_loop_start\n\t\t\t\tfor (int i = 0; i < NUM_HEMI_LIGHTS; i++) {\n\t\t\t\t\t\tL = normalize(u_Hemi[i].direction);\n\t\t\t\t\t\tdotNL = dot(N, L);\n\t\t\t\t\t\themiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\t\t\t\t\tindirectIrradiance += mix(u_Hemi[i].groundColor, u_Hemi[i].skyColor, hemiDiffuseWeight) * PI;\n\t\t\t\t}\n\t\t\t\t#pragma unroll_loop_end\n\t\t#endif\n\t\t#if defined(USE_ENV_MAP) && defined(USE_PBR)\n\t\t\t\tvec3 envDir;\n\t\t\t\t#ifdef USE_VERTEX_ENVDIR\n\t\t\t\t\t\tenvDir = v_EnvDir;\n\t\t\t\t#else\n\t\t\t\t\t\tenvDir = reflect(normalize(v_modelPos - u_CameraPosition), N);\n\t\t\t\t#endif\n\t\t\t\tiblIrradiance += getLightProbeIndirectIrradiance(maxMipLevel, N);\n\t\t\t\tindirectRadiance += getLightProbeIndirectRadiance(GGXRoughnessToBlinnExponent(roughness), maxMipLevel, envDir);\n\t\t\t\t#ifdef USE_CLEARCOAT\n\t\t\t\t\t\tvec3 clearcoatDir = reflect(normalize(v_modelPos - u_CameraPosition), clearcoatNormal);\n\t\t\t\tclearcoatRadiance += getLightProbeIndirectRadiance(GGXRoughnessToBlinnExponent(clearcoatRoughness), maxMipLevel, clearcoatDir);\n\t\t\t#endif\n\t\t#endif\n\t\treflectedLight.indirectDiffuse += indirectIrradiance * BRDF_Diffuse_Lambert(diffuseColor);\n\t\t#if defined(USE_ENV_MAP) && defined(USE_PBR)\n\t\t\t\t#ifdef USE_CLEARCOAT\n\t\t\t\t\t\tfloat ccDotNV = saturate(dot(clearcoatNormal, V));\n\t\t\t\t\t\treflectedLight.indirectSpecular += clearcoatRadiance * clearcoat * BRDF_Specular_GGX_Environment(clearcoatNormal, V, specularColor, clearcoatRoughness);\n\t\t\t\t\t\tccDotNL = ccDotNV;\n\t\t\t\t\t\tclearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n\t\t\t\t#else\n\t\t\t\t\t\tclearcoatDHR = 0.0;\n\t\t\t\t#endif\n\t\t\t\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\t\t\t\tvec3 singleScattering = vec3(0.0);\n\t\t\tvec3 multiScattering = vec3(0.0);\n\t\t\t\tvec3 cosineWeightedIrradiance = iblIrradiance * RECIPROCAL_PI;\n\t\t\t\tBRDF_Specular_Multiscattering_Environment(N, V, specularColor, roughness, singleScattering, multiScattering);\n\t\t\t\tvec3 diffuse = diffuseColor * (1.0 - (singleScattering + multiScattering));\n\t\t\t\treflectedLight.indirectSpecular += clearcoatInv * indirectRadiance * singleScattering;\n\t\t\t\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\t\t\t\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n\t\t#endif\n#endif",light_pars_frag:"#ifdef USE_AMBIENT_LIGHT\n\t\tuniform vec3 u_AmbientLightColor;\n#endif\n#ifdef USE_CLEARCOAT\n\t\tfloat clearcoatDHRApprox(const in float roughness, const in float dotNL) {\n\t\t\t\treturn 0.04 + (1.0 - 0.16) * (pow(1.0 - dotNL, 5.0) * pow(1.0 - roughness, 2.0));\n\t\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t\tstruct HemisphereLight {\n\t\t\t\tvec3 direction;\n\t\t\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t\t};\n\t\tuniform HemisphereLight u_Hemi[NUM_HEMI_LIGHTS];\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t\tstruct DirectLight {\n\t\t\t\tvec3 direction;\n\t\t\t\tvec3 color;\n\t\t};\n\t\tuniform DirectLight u_Directional[NUM_DIR_LIGHTS];\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t\tstruct PointLight {\n\t\t\t\tvec3 position;\n\t\t\t\tvec3 color;\n\t\t\t\tfloat distance;\n\t\t\t\tfloat decay;\n\t\t};\n\t\tuniform PointLight u_Point[NUM_POINT_LIGHTS];\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t\tstruct SpotLight {\n\t\t\t\tvec3 position;\n\t\t\t\tvec3 color;\n\t\t\t\tfloat distance;\n\t\t\t\tfloat decay;\n\t\t\t\tfloat coneCos;\n\t\t\t\tfloat penumbraCos;\n\t\t\t\tvec3 direction;\n\t\t};\n\t\tuniform SpotLight u_Spot[NUM_SPOT_LIGHTS];\n#endif\n#if defined(USE_PBR) && defined(USE_ENV_MAP)\n\t\tvec3 getLightProbeIndirectIrradiance(const in int maxMIPLevel, const in vec3 N) {\n\t\t\t\tvec3 coordVec = vec3(u_EnvMap_Flip * N.x, N.yz);\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT(envMap, coordVec, float(maxMIPLevel));\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube(envMap, coordVec, float(maxMIPLevel));\n\t\t\t#endif\n\t\t\t\tenvMapColor = envMapTexelToLinear(envMapColor);\n\t\t\t\treturn PI * envMapColor.rgb * u_EnvMap_Intensity * u_EnvMapLight_Intensity;\n\t\t}\n\t\tfloat getSpecularMIPLevel(const in float blinnShininessExponent, const in int maxMIPLevel) {\n\t\t\tfloat maxMIPLevelScalar = float(maxMIPLevel);\n\t\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2(pow2(blinnShininessExponent) + 1.0);\n\t\t\treturn clamp(desiredMIPLevel, 0.0, maxMIPLevelScalar);\n\t\t}\n\t\tvec3 getLightProbeIndirectRadiance(const in float blinnShininessExponent, const in int maxMIPLevel, const in vec3 envDir) {\n\t\t\t\tfloat specularMIPLevel = getSpecularMIPLevel(blinnShininessExponent, maxMIPLevel);\n\t\t\t\tvec3 coordVec = vec3(u_EnvMap_Flip * envDir.x, envDir.yz);\n\t\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT(envMap, coordVec, specularMIPLevel);\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube(envMap, coordVec, specularMIPLevel);\n\t\t\t#endif\n\t\t\t\tenvMapColor = envMapTexelToLinear(envMapColor);\n\t\t\t\treturn envMapColor.rgb * u_EnvMap_Intensity;\n\t\t}\n\t\tfloat computeSpecularOcclusion(const in float dotNV, const in float ambientOcclusion, const in float roughness) {\n\t\t\treturn saturate(pow(dotNV + ambientOcclusion, exp2(-16.0 * roughness - 1.0)) - 1.0 + ambientOcclusion);\n\t\t}\n#endif",alphamap_pars_frag:"#ifdef USE_ALPHA_MAP\n\tuniform sampler2D alphaMap;\n\tvarying vec2 vAlphaMapUV;\n#endif",alphamap_frag:"#ifdef USE_ALPHA_MAP\n\toutColor.a *= texture2D(alphaMap, vAlphaMapUV).g;\n#endif",alphamap_pars_vert:"#ifdef USE_ALPHA_MAP\n\t\tuniform mat3 alphaMapUVTransform;\n\tvarying vec2 vAlphaMapUV;\n#endif",alphamap_vert:"#ifdef USE_ALPHA_MAP\n\t#if (USE_ALPHA_MAP == 2)\n\t\t\t\tvAlphaMapUV = (alphaMapUVTransform * vec3(a_Uv2, 1.)).xy;\n\t\t#else\n\t\t\t\tvAlphaMapUV = (alphaMapUVTransform * vec3(a_Uv, 1.)).xy;\n\t\t#endif\n#endif",normalMap_pars_frag:"#ifdef USE_NORMAL_MAP\n\t\tuniform sampler2D normalMap;\n\t\tuniform vec2 normalScale;\n#endif\n#if defined(USE_NORMAL_MAP) || defined(USE_CLEARCOAT_NORMALMAP)\n\t\t#if defined(USE_TANGENT) && !defined(FLAT_SHADED)\n\t\t\t\t#define USE_TBN\n\t\t#else\n\t\t\t\t#include \n\t\t#endif\n#endif",normal_frag:"\n#ifdef FLAT_SHADED\n\t\tvec3 fdx = dFdx(v_modelPos);\n\t\tvec3 fdy = dFdy(v_modelPos);\n\t\tvec3 N = normalize(cross(fdx, fdy));\n#else\n\t\tvec3 N = normalize(v_Normal);\n\t\t#ifdef DOUBLE_SIDED\n\t\t\t\tN = N * (float(gl_FrontFacing) * 2.0 - 1.0);\n\t\t#endif\n#endif\n#ifdef USE_TBN\n\tvec3 tangent = normalize(v_Tangent);\n\tvec3 bitangent = normalize(v_Bitangent);\n\t#ifdef DOUBLE_SIDED\n\t\ttangent = tangent * (float(gl_FrontFacing) * 2.0 - 1.0);\n\t\tbitangent = bitangent * (float(gl_FrontFacing) * 2.0 - 1.0);\n\t#endif\n\tmat3 tspace = mat3(tangent, bitangent, N);\n#endif\nvec3 geometryNormal = N;\n#ifdef USE_NORMAL_MAP\n\t\tvec3 mapN = texture2D(normalMap, v_Uv).rgb * 2.0 - 1.0;\n\t\tmapN.xy *= normalScale;\n\t\t#ifdef USE_TBN\n\t\t\t\tN = normalize(tspace * mapN);\n\t\t#else\n\t\t\t\tmapN.xy *= (float(gl_FrontFacing) * 2.0 - 1.0);\n\t\t\t\tN = normalize(tsn(N, v_modelPos, v_Uv) * mapN);\n\t\t#endif\n#elif defined(USE_BUMPMAP)\n\t\tN = perturbNormalArb(v_modelPos, N, dHdxy_fwd(v_Uv));\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D(clearcoatNormalMap, v_Uv).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TBN\n\t\tclearcoatNormal = normalize(tspace * clearcoatMapN);\n\t#else\n\t\tclearcoatMapN.xy *= (float(gl_FrontFacing) * 2.0 - 1.0);\n\t\tclearcoatNormal = normalize(tsn(clearcoatNormal, v_modelPos, v_Uv) * clearcoatMapN);\n\t#endif\n#endif",normal_pars_frag:"#ifndef FLAT_SHADED\n\t\tvarying vec3 v_Normal;\n\t\t#ifdef USE_TANGENT\n\t\t\t\tvarying vec3 v_Tangent;\n\t\tvarying vec3 v_Bitangent;\n\t\t#endif\n#endif",normal_pars_vert:"#ifndef FLAT_SHADED\n\t\tvarying vec3 v_Normal;\n\t\t#ifdef USE_TANGENT\n\t\t\t\tvarying vec3 v_Tangent;\n\t\tvarying vec3 v_Bitangent;\n\t\t#endif\n#endif",normal_vert:"#ifndef FLAT_SHADED\n\t\tv_Normal = (transposeMat4(inverseMat4(u_Model)) * vec4(objectNormal, 0.0)).xyz;\n\t\t#ifdef FLIP_SIDED\n\t\t\tv_Normal = - v_Normal;\n\t\t#endif\n\t\t#ifdef USE_TANGENT\n\t\t\t\tv_Tangent = (transposeMat4(inverseMat4(u_Model)) * vec4(objectTangent, 0.0)).xyz;\n\t\t\t\t#ifdef FLIP_SIDED\n\t\t\t\t\t\tv_Tangent = - v_Tangent;\n\t\t\t\t#endif\n\t\t\t\tv_Bitangent = normalize(cross(v_Normal, v_Tangent) * a_Tangent.w);\n\t\t#endif\n#endif",packing:"const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256.,\t256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\t\tvec4 r = vec4( fract( v * PackFactors ), v );\n\t\tr.yzw -= r.xyz * ShiftRight8;\t\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\t\treturn dot( v, UnpackFactors );\n}",premultipliedAlpha_frag:"#ifdef USE_PREMULTIPLIED_ALPHA\n\t\tgl_FragColor.rgb = gl_FragColor.rgb * gl_FragColor.a;\n#endif",pvm_vert:"vec4 worldPosition = u_Model * vec4(transformed, 1.0);\ngl_Position = u_ProjectionView * worldPosition;",dithering_frag:"#if defined( DITHERING )\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_frag:"#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",shadow:"#ifdef USE_SHADOW_SAMPLER\n\t\tfloat computeShadow(sampler2DShadow shadowMap, vec3 shadowCoord) {\n\t\t\t\treturn texture2D( shadowMap, shadowCoord );\n\t\t}\n#else\n\t\tfloat computeShadow(sampler2D shadowMap, vec3 shadowCoord) {\n\t\t\t\treturn step(shadowCoord.z, unpackRGBAToDepth(texture2D(shadowMap, shadowCoord.xy)));\n\t\t}\n#endif\nfloat computeShadowWithPoissonSampling(sampler2DShadow shadowMap, vec3 shadowCoord, float texelSize) {\n\t\tvec3 poissonDisk[4];\n\t\tpoissonDisk[0] = vec3(-0.94201624, -0.39906216, 0);\n\t\tpoissonDisk[1] = vec3(0.94558609, -0.76890725, 0);\n\t\tpoissonDisk[2] = vec3(-0.094184101, -0.92938870, 0);\n\t\tpoissonDisk[3] = vec3(0.34495938, 0.29387760, 0);\n\t\treturn computeShadow(shadowMap, shadowCoord + poissonDisk[0] * texelSize) * 0.25 +\n\t\t\t\tcomputeShadow(shadowMap, shadowCoord + poissonDisk[1] * texelSize) * 0.25 +\n\t\t\t\tcomputeShadow(shadowMap, shadowCoord + poissonDisk[2] * texelSize) * 0.25 +\n\t\t\t\tcomputeShadow(shadowMap, shadowCoord + poissonDisk[3] * texelSize) * 0.25;\n}\nfloat computeShadowWithPCF1(sampler2DShadow shadowSampler, vec3 shadowCoord) {\n\t\treturn computeShadow(shadowSampler, shadowCoord);\n}\nfloat computeShadowWithPCF3(sampler2DShadow shadowSampler, vec3 shadowCoord, vec2 shadowMapSizeAndInverse) {\n\t\tvec2 uv = shadowCoord.xy * shadowMapSizeAndInverse.x;\t\tuv += 0.5;\t\tvec2 st = fract(uv);\t\tvec2 base_uv = floor(uv) - 0.5;\t\tbase_uv *= shadowMapSizeAndInverse.y;\n\t\tvec2 uvw0 = 3. - 2. * st;\n\t\tvec2 uvw1 = 1. + 2. * st;\n\t\tvec2 u = vec2((2. - st.x) / uvw0.x - 1., st.x / uvw1.x + 1.) * shadowMapSizeAndInverse.y;\n\t\tvec2 v = vec2((2. - st.y) / uvw0.y - 1., st.y / uvw1.y + 1.) * shadowMapSizeAndInverse.y;\n\t\tfloat shadow = 0.;\n\t\tshadow += uvw0.x * uvw0.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[0], v[0]), shadowCoord.z));\n\t\tshadow += uvw1.x * uvw0.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[1], v[0]), shadowCoord.z));\n\t\tshadow += uvw0.x * uvw1.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[0], v[1]), shadowCoord.z));\n\t\tshadow += uvw1.x * uvw1.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[1], v[1]), shadowCoord.z));\n\t\tshadow = shadow / 16.;\n\t\treturn shadow;\n}\nfloat computeShadowWithPCF5(sampler2DShadow shadowSampler, vec3 shadowCoord, vec2 shadowMapSizeAndInverse) {\n\t\tvec2 uv = shadowCoord.xy * shadowMapSizeAndInverse.x;\t\tuv += 0.5;\t\tvec2 st = fract(uv);\t\tvec2 base_uv = floor(uv) - 0.5;\t\tbase_uv *= shadowMapSizeAndInverse.y;\n\t\tvec2 uvw0 = 4. - 3. * st;\n\t\tvec2 uvw1 = vec2(7.);\n\t\tvec2 uvw2 = 1. + 3. * st;\n\t\tvec3 u = vec3((3. - 2. * st.x) / uvw0.x - 2., (3. + st.x) / uvw1.x, st.x / uvw2.x + 2.) * shadowMapSizeAndInverse.y;\n\t\tvec3 v = vec3((3. - 2. * st.y) / uvw0.y - 2., (3. + st.y) / uvw1.y, st.y / uvw2.y + 2.) * shadowMapSizeAndInverse.y;\n\t\tfloat shadow = 0.;\n\t\tshadow += uvw0.x * uvw0.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[0], v[0]), shadowCoord.z));\n\t\tshadow += uvw1.x * uvw0.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[1], v[0]), shadowCoord.z));\n\t\tshadow += uvw2.x * uvw0.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[2], v[0]), shadowCoord.z));\n\t\tshadow += uvw0.x * uvw1.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[0], v[1]), shadowCoord.z));\n\t\tshadow += uvw1.x * uvw1.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[1], v[1]), shadowCoord.z));\n\t\tshadow += uvw2.x * uvw1.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[2], v[1]), shadowCoord.z));\n\t\tshadow += uvw0.x * uvw2.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[0], v[2]), shadowCoord.z));\n\t\tshadow += uvw1.x * uvw2.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[1], v[2]), shadowCoord.z));\n\t\tshadow += uvw2.x * uvw2.y * computeShadow(shadowSampler, vec3(base_uv.xy + vec2(u[2], v[2]), shadowCoord.z));\n\t\tshadow = shadow / 144.;\n\t\treturn shadow;\n}\nfloat computeFallOff(float value, vec2 clipSpace, float frustumEdgeFalloff) {\n\t\tfloat mask = smoothstep(1.0 - frustumEdgeFalloff, 1.00000012, clamp(dot(clipSpace, clipSpace), 0., 1.));\n\t\treturn mix(value, 1.0, mask);\n}\nfloat getShadow(sampler2DShadow shadowMap, vec4 shadowCoord, vec2 shadowMapSize, vec2 shadowBias, vec2 shadowParams) {\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias.x;\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\tfloat shadow = 1.0;\n\t\tif (frustumTest) {\n\t\t\t\t#ifdef USE_HARD_SHADOW\n\t\t\t\t\t\tshadow = computeShadow(shadowMap, shadowCoord.xyz);\n\t\t\t\t#else\n\t\t\t\t\t\t#ifdef USE_PCF3_SOFT_SHADOW\n\t\t\t\t\t\t\t\tvec2 shadowMapSizeAndInverse = vec2(shadowMapSize.x, 1. / shadowMapSize.x);\n\t\t\t\t\t\t\t\tshadow = computeShadowWithPCF3(shadowMap, shadowCoord.xyz, shadowMapSizeAndInverse);\n\t\t\t\t\t\t#else\n\t\t\t\t\t\t\t\t#ifdef USE_PCF5_SOFT_SHADOW\n\t\t\t\t\t\t\t\t\t\tvec2 shadowMapSizeAndInverse = vec2(shadowMapSize.x, 1. / shadowMapSize.x);\n\t\t\t\t\t\t\t\t\t\tshadow = computeShadowWithPCF5(shadowMap, shadowCoord.xyz, shadowMapSizeAndInverse);\n\t\t\t\t\t\t\t\t#else\n\t\t\t\t\t\t\t\t\t\tfloat texelSize = shadowParams.x / shadowMapSize.x;\n\t\t\t\t\t\t\t\t\t\tshadow = computeShadowWithPoissonSampling(shadowMap, shadowCoord.xyz, texelSize);\n\t\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#endif\n\t\t\t\t#endif\n\t\t\t\tshadow = computeFallOff(shadow, shadowCoord.xy * 2. - 1., shadowParams.y);\n\t\t}\n\t\treturn shadow;\n}\nfloat textureCubeCompare(samplerCube depths, vec3 uv, float compare) {\n\t\treturn step(compare, unpackRGBAToDepth(textureCube(depths, uv)));\n}\nfloat getPointShadow(samplerCube shadowMap, vec4 shadowCoord, vec2 shadowMapSize, vec2 shadowBias, vec2 shadowParams, vec2 shadowCameraRange) {\n\t\tvec3 V = shadowCoord.xyz;\n\t\tfloat depth = (length(V) - shadowCameraRange.x) / (shadowCameraRange.y - shadowCameraRange.x);\t\tdepth += shadowBias.x;\n\t\t#ifdef USE_HARD_SHADOW\n\t\t\t\treturn textureCubeCompare(shadowMap, normalize(V), depth);\n\t\t#else\n\t\t\t\tfloat texelSize = shadowParams.x / shadowMapSize.x;\n\t\t\t\tvec3 poissonDisk[4];\n\t\t\t\tpoissonDisk[0] = vec3(-1.0, 1.0, -1.0);\n\t\t\t\tpoissonDisk[1] = vec3(1.0, -1.0, -1.0);\n\t\t\t\tpoissonDisk[2] = vec3(-1.0, -1.0, -1.0);\n\t\t\t\tpoissonDisk[3] = vec3(1.0, -1.0, 1.0);\n\t\t\t\treturn textureCubeCompare(shadowMap, normalize(V) + poissonDisk[0] * texelSize, depth) * 0.25 +\n\t\t\t\t\t\ttextureCubeCompare(shadowMap, normalize(V) + poissonDisk[1] * texelSize, depth) * 0.25 +\n\t\t\t\t\t\ttextureCubeCompare(shadowMap, normalize(V) + poissonDisk[2] * texelSize, depth) * 0.25 +\n\t\t\t\t\t\ttextureCubeCompare(shadowMap, normalize(V) + poissonDisk[3] * texelSize, depth) * 0.25;\n\t\t#endif\n}\n#ifdef USE_PCSS_SOFT_SHADOW\n\t\tconst vec3 PoissonSamplers32[64] = vec3[64](\n\t\t\t\tvec3(0.06407013, 0.05409927, 0.),\n\t\t\t\tvec3(0.7366577, 0.5789394, 0.),\n\t\t\t\tvec3(-0.6270542, -0.5320278, 0.),\n\t\t\t\tvec3(-0.4096107, 0.8411095, 0.),\n\t\t\t\tvec3(0.6849564, -0.4990818, 0.),\n\t\t\t\tvec3(-0.874181, -0.04579735, 0.),\n\t\t\t\tvec3(0.9989998, 0.0009880066, 0.),\n\t\t\t\tvec3(-0.004920578, -0.9151649, 0.),\n\t\t\t\tvec3(0.1805763, 0.9747483, 0.),\n\t\t\t\tvec3(-0.2138451, 0.2635818, 0.),\n\t\t\t\tvec3(0.109845, 0.3884785, 0.),\n\t\t\t\tvec3(0.06876755, -0.3581074, 0.),\n\t\t\t\tvec3(0.374073, -0.7661266, 0.),\n\t\t\t\tvec3(0.3079132, -0.1216763, 0.),\n\t\t\t\tvec3(-0.3794335, -0.8271583, 0.),\n\t\t\t\tvec3(-0.203878, -0.07715034, 0.),\n\t\t\t\tvec3(0.5912697, 0.1469799, 0.),\n\t\t\t\tvec3(-0.88069, 0.3031784, 0.),\n\t\t\t\tvec3(0.5040108, 0.8283722, 0.),\n\t\t\t\tvec3(-0.5844124, 0.5494877, 0.),\n\t\t\t\tvec3(0.6017799, -0.1726654, 0.),\n\t\t\t\tvec3(-0.5554981, 0.1559997, 0.),\n\t\t\t\tvec3(-0.3016369, -0.3900928, 0.),\n\t\t\t\tvec3(-0.5550632, -0.1723762, 0.),\n\t\t\t\tvec3(0.925029, 0.2995041, 0.),\n\t\t\t\tvec3(-0.2473137, 0.5538505, 0.),\n\t\t\t\tvec3(0.9183037, -0.2862392, 0.),\n\t\t\t\tvec3(0.2469421, 0.6718712, 0.),\n\t\t\t\tvec3(0.3916397, -0.4328209, 0.),\n\t\t\t\tvec3(-0.03576927, -0.6220032, 0.),\n\t\t\t\tvec3(-0.04661255, 0.7995201, 0.),\n\t\t\t\tvec3(0.4402924, 0.3640312, 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.),\n\t\t\t\tvec3(0., 0., 0.)\n\t\t);\n\t\tconst vec3 PoissonSamplers64[64] = vec3[64](\n\t\t\t\tvec3(-0.613392, 0.617481, 0.),\n\t\t\t\tvec3(0.170019, -0.040254, 0.),\n\t\t\t\tvec3(-0.299417, 0.791925, 0.),\n\t\t\t\tvec3(0.645680, 0.493210, 0.),\n\t\t\t\tvec3(-0.651784, 0.717887, 0.),\n\t\t\t\tvec3(0.421003, 0.027070, 0.),\n\t\t\t\tvec3(-0.817194, -0.271096, 0.),\n\t\t\t\tvec3(-0.705374, -0.668203, 0.),\n\t\t\t\tvec3(0.977050, -0.108615, 0.),\n\t\t\t\tvec3(0.063326, 0.142369, 0.),\n\t\t\t\tvec3(0.203528, 0.214331, 0.),\n\t\t\t\tvec3(-0.667531, 0.326090, 0.),\n\t\t\t\tvec3(-0.098422, -0.295755, 0.),\n\t\t\t\tvec3(-0.885922, 0.215369, 0.),\n\t\t\t\tvec3(0.566637, 0.605213, 0.),\n\t\t\t\tvec3(0.039766, -0.396100, 0.),\n\t\t\t\tvec3(0.751946, 0.453352, 0.),\n\t\t\t\tvec3(0.078707, -0.715323, 0.),\n\t\t\t\tvec3(-0.075838, -0.529344, 0.),\n\t\t\t\tvec3(0.724479, -0.580798, 0.),\n\t\t\t\tvec3(0.222999, -0.215125, 0.),\n\t\t\t\tvec3(-0.467574, -0.405438, 0.),\n\t\t\t\tvec3(-0.248268, -0.814753, 0.),\n\t\t\t\tvec3(0.354411, -0.887570, 0.),\n\t\t\t\tvec3(0.175817, 0.382366, 0.),\n\t\t\t\tvec3(0.487472, -0.063082, 0.),\n\t\t\t\tvec3(-0.084078, 0.898312, 0.),\n\t\t\t\tvec3(0.488876, -0.783441, 0.),\n\t\t\t\tvec3(0.470016, 0.217933, 0.),\n\t\t\t\tvec3(-0.696890, -0.549791, 0.),\n\t\t\t\tvec3(-0.149693, 0.605762, 0.),\n\t\t\t\tvec3(0.034211, 0.979980, 0.),\n\t\t\t\tvec3(0.503098, -0.308878, 0.),\n\t\t\t\tvec3(-0.016205, -0.872921, 0.),\n\t\t\t\tvec3(0.385784, -0.393902, 0.),\n\t\t\t\tvec3(-0.146886, -0.859249, 0.),\n\t\t\t\tvec3(0.643361, 0.164098, 0.),\n\t\t\t\tvec3(0.634388, -0.049471, 0.),\n\t\t\t\tvec3(-0.688894, 0.007843, 0.),\n\t\t\t\tvec3(0.464034, -0.188818, 0.),\n\t\t\t\tvec3(-0.440840, 0.137486, 0.),\n\t\t\t\tvec3(0.364483, 0.511704, 0.),\n\t\t\t\tvec3(0.034028, 0.325968, 0.),\n\t\t\t\tvec3(0.099094, -0.308023, 0.),\n\t\t\t\tvec3(0.693960, -0.366253, 0.),\n\t\t\t\tvec3(0.678884, -0.204688, 0.),\n\t\t\t\tvec3(0.001801, 0.780328, 0.),\n\t\t\t\tvec3(0.145177, -0.898984, 0.),\n\t\t\t\tvec3(0.062655, -0.611866, 0.),\n\t\t\t\tvec3(0.315226, -0.604297, 0.),\n\t\t\t\tvec3(-0.780145, 0.486251, 0.),\n\t\t\t\tvec3(-0.371868, 0.882138, 0.),\n\t\t\t\tvec3(0.200476, 0.494430, 0.),\n\t\t\t\tvec3(-0.494552, -0.711051, 0.),\n\t\t\t\tvec3(0.612476, 0.705252, 0.),\n\t\t\t\tvec3(-0.578845, -0.768792, 0.),\n\t\t\t\tvec3(-0.772454, -0.090976, 0.),\n\t\t\t\tvec3(0.504440, 0.372295, 0.),\n\t\t\t\tvec3(0.155736, 0.065157, 0.),\n\t\t\t\tvec3(0.391522, 0.849605, 0.),\n\t\t\t\tvec3(-0.620106, -0.328104, 0.),\n\t\t\t\tvec3(0.789239, -0.419965, 0.),\n\t\t\t\tvec3(-0.545396, 0.538133, 0.),\n\t\t\t\tvec3(-0.178564, -0.596057, 0.)\n\t\t);\n\t\tfloat getRand(vec2 seed) {\n\t\t\t\treturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233))) * 43758.5453);\n\t\t}\n\t\tfloat computeShadowWithPCSS(sampler2D depthSampler, sampler2DShadow shadowSampler, vec3 shadowCoord, float shadowMapSizeInverse, float lightSizeUV, int searchTapCount, int pcfTapCount, vec3[64] poissonSamplers) {\n\t\t\t\tfloat depthMetric = shadowCoord.z;\n\t\t\t\tfloat blockerDepth = 0.0;\n\t\t\t\tfloat sumBlockerDepth = 0.0;\n\t\t\t\tfloat numBlocker = 0.0;\n\t\t\t\tfor (int i = 0; i < searchTapCount; i++) {\n\t\t\t\t\t\tblockerDepth = unpackRGBAToDepth(texture(depthSampler, shadowCoord.xy + (lightSizeUV * shadowMapSizeInverse * PoissonSamplers32[i].xy)));\n\t\t\t\t\t\tif (blockerDepth < depthMetric) {\n\t\t\t\t\t\t\t\tsumBlockerDepth += blockerDepth;\n\t\t\t\t\t\t\t\tnumBlocker++;\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (numBlocker < 1.0) {\n\t\t\t\t\t\treturn 1.0;\n\t\t\t\t}\n\t\t\t\tfloat avgBlockerDepth = sumBlockerDepth / numBlocker;\n\t\t\t\tfloat AAOffset = shadowMapSizeInverse * 10.;\n\t\t\t\tfloat penumbraRatio = ((depthMetric - avgBlockerDepth) + AAOffset);\n\t\t\t\tfloat filterRadius = penumbraRatio * lightSizeUV * shadowMapSizeInverse;\n\t\t\t\tfloat random = getRand(shadowCoord.xy);\t\t\t\tfloat rotationAngle = random * 3.1415926;\n\t\t\t\tvec2 rotationVector = vec2(cos(rotationAngle), sin(rotationAngle));\n\t\t\t\tfloat shadow = 0.;\n\t\t\t\tfor (int i = 0; i < pcfTapCount; i++) {\n\t\t\t\t\t\tvec3 offset = poissonSamplers[i];\n\t\t\t\t\t\toffset = vec3(offset.x * rotationVector.x - offset.y * rotationVector.y, offset.y * rotationVector.x + offset.x * rotationVector.y, 0.);\n\t\t\t\t\t\tshadow += texture(shadowSampler, shadowCoord + offset * filterRadius);\n\t\t\t\t}\n\t\t\t\tshadow /= float(pcfTapCount);\n\t\t\t\tshadow = mix(shadow, 1., depthMetric - avgBlockerDepth);\n\t\t\t\treturn shadow;\n\t\t}\n\t\tfloat getShadowWithPCSS(sampler2D depthSampler, sampler2DShadow shadowMap, vec4 shadowCoord, vec2 shadowMapSize, vec2 shadowBias, vec2 shadowParams) {\n\t\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\t\tshadowCoord.z += shadowBias.x;\n\t\t\t\tbvec4 inFrustumVec = bvec4 (shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0);\n\t\t\t\tbool inFrustum = all(inFrustumVec);\n\t\t\t\tbvec2 frustumTestVec = bvec2(inFrustum, shadowCoord.z <= 1.0);\n\t\t\t\tbool frustumTest = all(frustumTestVec);\n\t\t\t\tfloat shadow = 1.0;\n\t\t\t\tif (frustumTest) {\n\t\t\t\t\t\t#ifdef USE_PCSS16_SOFT_SHADOW\n\t\t\t\t\t\t\t\tshadow = computeShadowWithPCSS(depthSampler, shadowMap, shadowCoord.xyz, 1. / shadowMapSize.x, 0.1 * shadowMapSize.x, 16, 16, PoissonSamplers32);\n\t\t\t\t\t\t#else\n\t\t\t\t\t\t\t\t#ifdef USE_PCSS32_SOFT_SHADOW\n\t\t\t\t\t\t\t\t\t\tshadow = computeShadowWithPCSS(depthSampler, shadowMap, shadowCoord.xyz, 1. / shadowMapSize.x, 0.1 * shadowMapSize.x, 16, 32, PoissonSamplers32);\n\t\t\t\t\t\t\t\t#else\n\t\t\t\t\t\t\t\t\t\tshadow = computeShadowWithPCSS(depthSampler, shadowMap, shadowCoord.xyz, 1. / shadowMapSize.x, 0.1 * shadowMapSize.x, 32, 64, PoissonSamplers64);\n\t\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\tshadow = computeFallOff(shadow, shadowCoord.xy * 2. - 1., shadowParams.y);\n\t\t\t\t}\n\t\t\t\treturn shadow;\n\t\t}\n#endif",shadowMap_frag:"#ifdef USE_SHADOW\n#endif",shadowMap_pars_frag:"#ifdef USE_SHADOW\n\t#if NUM_DIR_SHADOWS > 0\n\t\tuniform sampler2DShadow directionalShadowMap[NUM_DIR_SHADOWS];\n\t\tvarying vec4 vDirectionalShadowCoord[NUM_DIR_SHADOWS];\n\t\t#ifdef USE_PCSS_SOFT_SHADOW\n\t\t\tuniform sampler2D directionalDepthMap[NUM_DIR_SHADOWS];\n\t\t#endif\n\t\tstruct DirectLightShadow {\n\t\t\tvec2 shadowBias;\n\t\t\tvec2 shadowMapSize;\n\t\t\tvec2 shadowParams;\n\t\t};\n\t\tuniform DirectLightShadow u_DirectionalShadow[NUM_DIR_SHADOWS];\n\t#endif\n\t#if NUM_POINT_SHADOWS > 0\n\t\tuniform samplerCube pointShadowMap[NUM_POINT_SHADOWS];\n\t\tvarying vec4 vPointShadowCoord[NUM_POINT_SHADOWS];\n\t\tstruct PointLightShadow {\n\t\t\tvec2 shadowBias;\n\t\t\tvec2 shadowMapSize;\n\t\t\tvec2 shadowParams;\n\t\t\tvec2 shadowCameraRange;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow u_PointShadow[NUM_POINT_SHADOWS];\n\t#endif\n\t#if NUM_SPOT_SHADOWS > 0\n\t\tuniform sampler2DShadow spotShadowMap[NUM_SPOT_SHADOWS];\n\t\tvarying vec4 vSpotShadowCoord[NUM_SPOT_SHADOWS];\n\t\t#ifdef USE_PCSS_SOFT_SHADOW\n\t\t\tuniform sampler2D spotDepthMap[NUM_SPOT_SHADOWS];\n\t\t#endif\n\t\tstruct SpotLightShadow {\n\t\t\tvec2 shadowBias;\n\t\t\tvec2 shadowMapSize;\n\t\t\tvec2 shadowParams;\n\t\t};\n\t\tuniform SpotLightShadow u_SpotShadow[NUM_SPOT_SHADOWS];\n\t#endif\n\t#include \n\t#include \n#endif",shadowMap_pars_vert:"#ifdef USE_SHADOW\n\t#if NUM_DIR_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[NUM_DIR_SHADOWS];\n\t\tvarying vec4 vDirectionalShadowCoord[NUM_DIR_SHADOWS];\n\t\tstruct DirectLightShadow {\n\t\t\tvec2 shadowBias;\n\t\t\tvec2 shadowMapSize;\n\t\t\tvec2 shadowParams;\n\t\t};\n\t\tuniform DirectLightShadow u_DirectionalShadow[NUM_DIR_SHADOWS];\n\t#endif\n\t#if NUM_POINT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[NUM_POINT_SHADOWS];\n\t\tvarying vec4 vPointShadowCoord[NUM_POINT_SHADOWS];\n\t\tstruct PointLightShadow {\n\t\t\tvec2 shadowBias;\n\t\t\tvec2 shadowMapSize;\n\t\t\tvec2 shadowParams;\n\t\t\tvec2 shadowCameraRange;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow u_PointShadow[NUM_POINT_SHADOWS];\n\t#endif\n\t#if NUM_SPOT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[NUM_SPOT_SHADOWS];\n\t\tvarying vec4 vSpotShadowCoord[NUM_SPOT_SHADOWS];\n\t\tstruct SpotLightShadow {\n\t\t\tvec2 shadowBias;\n\t\t\tvec2 shadowMapSize;\n\t\t\tvec2 shadowParams;\n\t\t};\n\t\tuniform SpotLightShadow u_SpotShadow[NUM_SPOT_SHADOWS];\n\t#endif\n#endif",shadowMap_vert:"\n#ifdef USE_SHADOW\n\t#if NUM_DIR_SHADOWS > 0 || NUM_POINT_SHADOWS > 0 || NUM_SPOT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = (transposeMat4(inverseMat4(u_Model)) * vec4(objectNormal, 0.0)).xyz;\n\t\tshadowWorldNormal = normalize(shadowWorldNormal);\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor (int i = 0; i < NUM_DIR_SHADOWS; i++) {\n\t\t\tshadowWorldPosition = worldPosition + vec4(shadowWorldNormal * u_DirectionalShadow[i].shadowBias[1], 0);\n\t\t\tvDirectionalShadowCoord[i] = directionalShadowMatrix[i] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor (int i = 0; i < NUM_POINT_SHADOWS; i++) {\n\t\t\tshadowWorldPosition = worldPosition + vec4(shadowWorldNormal * u_PointShadow[i].shadowBias[1], 0);\n\t\t\tvPointShadowCoord[i] = pointShadowMatrix[i] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor (int i = 0; i < NUM_SPOT_SHADOWS; i++) {\n\t\t\tshadowWorldPosition = worldPosition + vec4(shadowWorldNormal * u_SpotShadow[i].shadowBias[1], 0);\n\t\t\tvSpotShadowCoord[i] = spotShadowMatrix[i] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif",morphnormal_vert:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif",morphtarget_pars_vert:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vert:"#ifdef USE_MORPHTARGETS\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\t\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif",skinning_pars_vert:"#ifdef USE_SKINNING\n\t\tattribute vec4 skinIndex;\n\tattribute vec4 skinWeight;\n\t\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t\t#ifdef BONE_TEXTURE\n\t\t\t\tuniform sampler2D boneTexture;\n\t\t\t\tuniform int boneTextureSize;\n\t\t\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\t\t\t\tfloat j = i * 4.0;\n\t\t\t\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\t\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\t\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\t\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\t\t\t\ty = dy * ( y + 0.5 );\n\t\t\t\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\t\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\t\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\t\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\t\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\t\t\t\treturn bone;\n\t\t\t\t}\n\t\t#else\n\t\t\t\tuniform mat4 boneMatrices[MAX_BONES];\n\t\t\t\tmat4 getBoneMatrix(const in float i) {\n\t\t\t\t\t\tmat4 bone = boneMatrices[int(i)];\n\t\t\t\t\t\treturn bone;\n\t\t\t\t}\n\t\t#endif\n#endif",skinning_vert:"#ifdef USE_SKINNING\n\t\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\t\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\t\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\t\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n\t\tvec4 skinVertex = bindMatrix * vec4(transformed, 1.0);\n\t\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\tskinned = bindMatrixInverse * skinned;\n\t\ttransformed = skinned.xyz / skinned.w;\n#endif",skinnormal_vert:"#ifdef USE_SKINNING\n\t\tmat4 skinMatrix = mat4( 0.0 );\n\t\tskinMatrix += skinWeight.x * boneMatX;\n\t\tskinMatrix += skinWeight.y * boneMatY;\n\t\tskinMatrix += skinWeight.z * boneMatZ;\n\t\tskinMatrix += skinWeight.w * boneMatW;\n\t\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\t\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularMap_frag:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, v_Uv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularMap_pars_frag:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",transpose:"mat4 transposeMat4(mat4 inMatrix) {\n\t\tvec4 i0 = inMatrix[0];\n\t\tvec4 i1 = inMatrix[1];\n\t\tvec4 i2 = inMatrix[2];\n\t\tvec4 i3 = inMatrix[3];\n\t\tmat4 outMatrix = mat4(\n\t\t\t\tvec4(i0.x, i1.x, i2.x, i3.x),\n\t\t\t\tvec4(i0.y, i1.y, i2.y, i3.y),\n\t\t\t\tvec4(i0.z, i1.z, i2.z, i3.z),\n\t\t\t\tvec4(i0.w, i1.w, i2.w, i3.w)\n\t\t);\n\t\treturn outMatrix;\n}",tsn:"mat3 tsn(vec3 N, vec3 V, vec2 uv) {\n\t\tvec3 q0 = vec3(dFdx(V.x), dFdx(V.y), dFdx(V.z));\n\t\tvec3 q1 = vec3(dFdy(V.x), dFdy(V.y), dFdy(V.z));\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.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\tmat3 tsn = mat3( S, T, N );\n\t\treturn tsn;\n}",uv_pars_frag:"#ifdef USE_UV1\n\t\tvarying vec2 v_Uv;\n#endif\n#ifdef USE_UV2\n\t\tvarying vec2 v_Uv2;\n#endif",uv_pars_vert:"#if defined(USE_UV1) || defined(USE_UV2)\n\t\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_UV1\n\t\tattribute vec2 a_Uv;\n\t\tvarying vec2 v_Uv;\n#endif\n#ifdef USE_UV2\n\t\tattribute vec2 a_Uv2;\n\t\tvarying vec2 v_Uv2;\n#endif",uv_vert:"#ifdef USE_UV1\n\t\tv_Uv = (uvTransform * vec3(a_Uv, 1.)).xy;\n#endif\n#ifdef USE_UV2\n\t\tv_Uv2 = (uvTransform * vec3(a_Uv2, 1.)).xy;\n#endif",modelPos_pars_frag:"varying vec3 v_modelPos;",modelPos_pars_vert:"varying vec3 v_modelPos;",modelPos_vert:"\nv_modelPos = worldPosition.xyz;",logdepthbuf_frag:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_frag:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vert:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tuniform float logDepthCameraNear;\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t\tuniform float logDepthCameraNear;\n\t#endif\n#endif",logdepthbuf_vert:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w - logDepthCameraNear;\n\t\tvIsPerspective = float( isPerspectiveMatrix( u_Projection ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( u_Projection ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w - logDepthCameraNear + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",clearcoat_pars_frag:"#ifdef USE_CLEARCOAT\n\tuniform float u_Clearcoat;\n\tuniform float u_ClearcoatRoughness;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif"},ii="#define USE_PBR\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",ri={basic_frag:"#include \n#include \n#include \n#include \n#include \n#include \n#if defined(USE_ENV_MAP) && !defined(USE_VERTEX_ENVDIR)\n\t\t#include \n\t\t#include \t\t\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\tReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n\t\treflectedLight.indirectDiffuse += vec3(1.0);\n\t\t#include \n\t\treflectedLight.indirectDiffuse *= outColor.xyz;\n\t\toutColor.xyz = reflectedLight.indirectDiffuse;\n\t\t#if defined(USE_ENV_MAP) && !defined(USE_VERTEX_ENVDIR)\n\t\t\t\t#include \n\t\t#endif\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",basic_vert:"#include \n#include \n#include \n#include \n#if defined(USE_ENV_MAP) && !defined(USE_VERTEX_ENVDIR)\n\t\t#include \n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#ifdef USE_ENV_MAP\n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#ifndef USE_VERTEX_ENVDIR\n\t\t\t\t\t\t#include \n\t\t\t\t#endif\t\n\t\t#endif\n\t\t#include \n\t\t#include \n\t\t#include \n}",depth_frag:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#if defined(USE_DIFFUSE_MAP) && defined(ALPHATEST)\n\t\t\t\tvec4 texelColor = texture2D( diffuseMap, v_Uv );\n\t\t\t\tfloat alpha = texelColor.a * u_Opacity;\n\t\t\t\tif(alpha < ALPHATEST) discard;\n\t\t#endif\n\t\t#include \n\t\t\n\t\t#ifdef DEPTH_PACKING_RGBA\n\t\t\t\tgl_FragColor = packDepthToRGBA(gl_FragCoord.z);\n\t\t#else\n\t\t\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), u_Opacity );\n\t\t#endif\n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",distance_frag:"#include \nuniform float nearDistance;\nuniform float farDistance;\n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t\n\t\tfloat dist = length( v_modelPos - u_CameraPosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\t\tgl_FragColor = packDepthToRGBA(dist);\n}",distance_vert:"#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",lambert_frag:"#define USE_LAMBERT\n#include \n#include \nuniform vec3 emissive;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\tReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n\t\t#include \n\t\t#include \n\t\toutColor.xyz = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\t\t#include \n\t\t#include \n\t\tvec3 totalEmissiveRadiance = emissive;\n\t\t#include \n\t\toutColor.xyz += totalEmissiveRadiance;\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",lambert_vert:"#define USE_LAMBERT\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",normaldepth_frag:"#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#if defined(USE_DIFFUSE_MAP) && defined(ALPHATEST)\n\t\t\t\tvec4 texelColor = texture2D( diffuseMap, v_Uv );\n\t\t\t\tfloat alpha = texelColor.a * u_Opacity;\n\t\t\t\tif(alpha < ALPHATEST) discard;\n\t\t#endif\n\t\t#include \n\t\tvec4 packedNormalDepth;\n\t\tpackedNormalDepth.xyz = normalize(v_Normal) * 0.5 + 0.5;\n\t\tpackedNormalDepth.w = gl_FragCoord.z;\n\t\tgl_FragColor = packedNormalDepth;\n}",normaldepth_vert:"#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",pbr_frag:"#define USE_PBR\n#include \n#include \nuniform float u_Metalness;\n#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif\nuniform float u_Roughness;\n#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif\nuniform vec3 emissive;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\tfloat roughnessFactor = u_Roughness;\n\t\t#ifdef USE_ROUGHNESSMAP\n\t\t\tvec4 texelRoughness = texture2D( roughnessMap, v_Uv );\n\t\t\troughnessFactor *= texelRoughness.g;\n\t\t#endif\n\t\tfloat metalnessFactor = u_Metalness;\n\t\t#ifdef USE_METALNESSMAP\n\t\t\tvec4 texelMetalness = texture2D( metalnessMap, v_Uv );\n\t\t\tmetalnessFactor *= texelMetalness.b;\n\t\t#endif\n\t\tReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n\t\t#include \n\t\t#include \n\t\toutColor.xyz = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t\t#include \n\t\tvec3 totalEmissiveRadiance = emissive;\n\t\t#include \n\t\toutColor.xyz += totalEmissiveRadiance;\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",pbr_vert:ii,pbr2_frag:"#define USE_PBR\n#define USE_PBR2\n#include \n#include \nuniform vec3 u_SpecularColor;\n#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif\nuniform float glossiness;\n#ifdef USE_GLOSSINESSMAP\n\tuniform sampler2D glossinessMap;\n#endif\nuniform vec3 emissive;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\tvec3 specularFactor = u_SpecularColor;\n\t\t#ifdef USE_SPECULARMAP\n\t\t\t\tvec4 texelSpecular = texture2D(specularMap, v_Uv);\n\t\t\t\ttexelSpecular = sRGBToLinear(texelSpecular);\n\t\t\t\tspecularFactor *= texelSpecular.rgb;\n\t\t#endif\n\t\tfloat glossinessFactor = glossiness;\n\t\t#ifdef USE_GLOSSINESSMAP\n\t\t\t\tvec4 texelGlossiness = texture2D(glossinessMap, v_Uv);\n\t\t\t\tglossinessFactor *= texelGlossiness.a;\n\t\t#endif\n\t\tReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n\t\t#include \n\t\t#include \n\t\toutColor.xyz = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t\t#include \n\t\tvec3 totalEmissiveRadiance = emissive;\n\t\t#include \n\t\toutColor.xyz += totalEmissiveRadiance;\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",pbr2_vert:ii,matcap_frag:"#define MATCAP\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\tvec3 viewDir = normalize(vViewPosition);\n\tvec3 x = normalize(vec3(viewDir.z, 0.0, -viewDir.x));\n\tvec3 y = cross(viewDir, x);\n\t\tvec3 viewN = (u_View * vec4(N, 0.0)).xyz;\n\tvec2 uv = vec2(dot(x, viewN), dot(y, viewN)) * 0.495 + 0.5;\n\t\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D(matcap, uv);\n\t\tmatcapColor = matcapTexelToLinear(matcapColor);\n\t#else\n\t\tvec4 matcapColor = vec4(1.0);\n\t#endif\n\toutColor.rgb *= matcapColor.rgb;\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",matcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\tvec4 mvPosition = u_View * worldPosition;\n\t\tvViewPosition = - mvPosition.xyz;\n}",phong_frag:"#define USE_PHONG\n#include \n#include \nuniform float u_Specular;\nuniform vec3 u_SpecularColor;\n#include \nuniform vec3 emissive;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\tReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n\t\t#include \n\t\t#include \n\t\toutColor.xyz = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t\t#include \n\t\t#include \n\t\tvec3 totalEmissiveRadiance = emissive;\n\t\t#include \n\t\toutColor.xyz += totalEmissiveRadiance;\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",phong_vert:"#define USE_PHONG\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",point_frag:"#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#ifdef USE_DIFFUSE_MAP\n\t\t\t\toutColor *= texture2D(diffuseMap, vec2(gl_PointCoord.x, 1.0 - gl_PointCoord.y));\n\t\t#endif\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n}",point_vert:"#include \n#include \n#include \nuniform float u_PointSize;\nuniform float u_PointScale;\nvoid main() {\n\t\t#include \n\t\t#include \n\t\t#include \n\t\tvec4 mvPosition = u_View * u_Model * vec4(transformed, 1.0);\n\t\t#ifdef USE_SIZEATTENUATION\n\t\t\t\tgl_PointSize = u_PointSize * ( u_PointScale / - mvPosition.z );\n\t\t#else\n\t\t\t\tgl_PointSize = u_PointSize;\n\t\t#endif\n\t\t#include \n}"},ai=function(){function t(t,e,n){this._gl=t,this._state=e,this._capabilities=n,this._programs=[]}var e=t.prototype;return e.getProgram=function(t,e,n,i){for(var r,a=this._programs,o=function(t,e,n,i,r){var a=n.acceptLight?r.lights:null,o=n.fog?r.scene.fog:null,s=void 0!==n.envMap?n.envMap||r.scene.environment:null,u=r.scene.logarithmicDepthBuffer,l=r.scene.disableShadowSampler,c=n.clippingPlanes&&n.clippingPlanes.length>0?n.clippingPlanes.length:r.scene.numClippingPlanes,h={};h.shaderName=n.type===b.SHADER&&n.shaderName?n.shaderName:n.type,h.version=e.version,h.precision=n.precision||e.maxPrecision,h.useStandardDerivatives=e.version>=2||!!e.getExtension("OES_standard_derivatives")||!!e.getExtension("GL_OES_standard_derivatives"),h.useShaderTextureLOD=e.version>=2||!!e.getExtension("EXT_shader_texture_lod"),h.useDiffuseMap=n.diffuseMap?n.diffuseMapCoord+1:0,h.useAlphaMap=n.alphaMap?n.alphaMapCoord+1:0,h.useEmissiveMap=n.emissiveMap?n.emissiveMapCoord+1:0,h.useAOMap=n.aoMap?n.aoMapCoord+1:0,h.useNormalMap=!!n.normalMap,h.useBumpMap=!!n.bumpMap,h.useSpecularMap=!!n.specularMap,h.useRoughnessMap=!!n.roughnessMap,h.useMetalnessMap=!!n.metalnessMap,h.useGlossinessMap=!!n.glossinessMap,h.useMatcap=!!n.matcap,h.useEnvMap=!!s,h.envMapCombine=n.envMapCombine,h.useClearcoat=n.clearcoat>0,h.useClearcoatMap=h.useClearcoat&&!!n.clearcoatMap,h.useClearcoatRoughnessMap=h.useClearcoat&&!!n.clearcoatRoughnessMap,h.useClearcoatNormalMap=h.useClearcoat&&!!n.clearcoatNormalMap,h.useUv1=1===h.useDiffuseMap||1===h.useAlphaMap||1===h.useEmissiveMap||1===h.useAOMap||h.useNormalMap||h.useBumpMap||h.useSpecularMap||h.useRoughnessMap||h.useMetalnessMap||h.useGlossinessMap||h.useClearcoatMap||h.useClearcoatNormalMap||h.useClearcoatRoughnessMap,h.useUv2=2===h.useDiffuseMap||2===h.useAlphaMap||2===h.useEmissiveMap||2===h.useAOMap,h.useAmbientLight=!!a&&a.useAmbient,h.hemisphereLightNum=a?a.hemisNum:0,h.directLightNum=a?a.directsNum:0,h.pointLightNum=a?a.pointsNum:0,h.spotLightNum=a?a.spotsNum:0,h.directShadowNum=i.receiveShadow&&a?a.directShadowNum:0,h.pointShadowNum=i.receiveShadow&&a?a.pointShadowNum:0,h.spotShadowNum=i.receiveShadow&&a?a.spotShadowNum:0,h.useShadow=i.receiveShadow&&!!a&&a.shadowsNum>0,h.useShadowSampler=e.version>=2&&!l,h.shadowType=h.useShadowSampler?i.shadowType:z.POISSON_SOFT,h.dithering=n.dithering;var d=t.currentRenderTarget;h.gammaFactor=r.gammaFactor,h.outputEncoding=d.texture?oi(d.texture):r.outputEncoding,h.diffuseMapEncoding=oi(n.diffuseMap||n.cubeMap),h.envMapEncoding=oi(s),h.emissiveMapEncoding=oi(n.emissiveMap),h.matcapEncoding=oi(n.matcap),h.alphaTest=n.alphaTest,h.premultipliedAlpha=n.premultipliedAlpha,h.useVertexColors=n.vertexColors,h.useVertexTangents=!!n.normalMap&&n.vertexTangents,h.numClippingPlanes=c,h.flatShading=n.shading===D.FLAT_SHADING,h.fog=!!o,h.fogExp2=!!o&&o.isFogExp2,h.sizeAttenuation=n.sizeAttenuation,h.doubleSided=n.side===C.DOUBLE,h.flipSided=n.side===C.BACK,h.packDepthToRGBA=n.packToRGBA,h.logarithmicDepthBuffer=!!u,h.rendererExtensionFragDepth=e.version>=2||!!e.getExtension("EXT_frag_depth"),h.morphTargets=!!i.morphTargetInfluences,h.morphNormals=!!i.morphTargetInfluences&&i.geometry.morphAttributes.normal;var f=i.isSkinnedMesh&&i.skeleton,p=e.maxVertexUniformVectors,_=e.maxVertexTextures>0&&(!!e.getExtension("OES_texture_float")||e.version>=2),v=0;_?v=1024:16*(v=i.skeleton?i.skeleton.bones.length:0)>p&&(console.warn("Program: too many bones ("+v+"), current cpu only support "+Math.floor(p/16)+" bones!!"),v=Math.floor(p/16));return h.useSkinning=f,h.bonesNum=v,h.useVertexTexture=_,h}(this._state,this._capabilities,t,e,n),s=function(t,e){var n="";for(var i in t)n+=t[i]+"_";for(var r in e.defines)n+=r+"_"+e.defines[r]+"_";e.type!==b.SHADER||e.shaderName||(n+=e.vertexShader,n+=e.fragmentShader);return n}(o,t),u=0,l=a.length;u=2?"#define WEBGL2":"",n.useRoughnessMap?"#define USE_ROUGHNESSMAP":"",n.useMetalnessMap?"#define USE_METALNESSMAP":"",n.useGlossinessMap?"#define USE_GLOSSINESSMAP":"",n.useAmbientLight?"#define USE_AMBIENT_LIGHT":"",n.pointLightNum>0||n.directLightNum>0||n.useAmbientLight||n.hemisphereLightNum>0||n.spotLightNum>0?"#define USE_LIGHT":"",n.useNormalMap?"#define USE_NORMAL_MAP":"",n.useBumpMap?"#define USE_BUMPMAP":"",n.useSpecularMap?"#define USE_SPECULARMAP":"",n.useEmissiveMap?"#define USE_EMISSIVEMAP "+n.useEmissiveMap:"",n.useShadow?"#define USE_SHADOW":"",n.flatShading?"#define FLAT_SHADED":"",n.flipSided?"#define FLIP_SIDED":"",n.useDiffuseMap?"#define USE_DIFFUSE_MAP "+n.useDiffuseMap:"",n.useAlphaMap?"#define USE_ALPHA_MAP "+n.useAlphaMap:"",n.useEnvMap?"#define USE_ENV_MAP":"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.useAOMap?"#define USE_AOMAP "+n.useAOMap:"",n.useVertexColors==X.RGB?"#define USE_VCOLOR_RGB":"",n.useVertexColors==X.RGBA?"#define USE_VCOLOR_RGBA":"",n.useVertexTangents?"#define USE_TANGENT":"",n.useUv1?"#define USE_UV1":"",n.useUv2?"#define USE_UV2":"",n.fog?"#define USE_FOG":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.useSkinning?"#define USE_SKINNING":"",n.bonesNum>0?"#define MAX_BONES "+n.bonesNum:"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","\n"].filter(hi).join("\n"),o=[n.useStandardDerivatives&&n.version<2?"#extension GL_OES_standard_derivatives : enable":"",n.useShaderTextureLOD&&n.version<2?"#extension GL_EXT_shader_texture_lod : enable":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth&&n.version<2?"#extension GL_EXT_frag_depth : enable":"","precision "+n.precision+" float;","precision "+n.precision+" int;","precision "+n.precision+" sampler2D;",n.version>=2?"precision "+n.precision+" sampler2DShadow;":"",n.version>=2?"precision "+n.precision+" samplerCubeShadow;":"","#define SHADER_NAME "+n.shaderName,"#define PI 3.14159265359","#define EPSILON 1e-6","float pow2(const in float x) { return x * x; }","#define LOG2 1.442695","#define RECIPROCAL_PI 0.31830988618","#define saturate(a) clamp(a, 0.0, 1.0)","#define whiteCompliment(a) (1.0 - saturate(a))","highp float rand(const in vec2 uv) {","\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;","\thighp float dt = dot(uv.xy, vec2(a, b)), sn = mod(dt, PI);","\treturn fract(sin(sn) * c);","}",e,n.version>=2?"#define WEBGL2":"",n.useShadowSampler?"#define USE_SHADOW_SAMPLER":"#define sampler2DShadow sampler2D",n.useRoughnessMap?"#define USE_ROUGHNESSMAP":"",n.useMetalnessMap?"#define USE_METALNESSMAP":"",n.useGlossinessMap?"#define USE_GLOSSINESSMAP":"",n.useClearcoat?"#define USE_CLEARCOAT":"",n.useClearcoatMap?"#define USE_CLEARCOATMAP":"",n.useClearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.useClearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.useAmbientLight?"#define USE_AMBIENT_LIGHT":"",n.pointLightNum>0||n.directLightNum>0||n.useAmbientLight||n.hemisphereLightNum>0||n.spotLightNum>0?"#define USE_LIGHT":"",n.useNormalMap?"#define USE_NORMAL_MAP":"",n.useBumpMap?"#define USE_BUMPMAP":"",n.useSpecularMap?"#define USE_SPECULARMAP":"",n.useEmissiveMap?"#define USE_EMISSIVEMAP "+n.useEmissiveMap:"",n.useShadow?"#define USE_SHADOW":"",n.shadowType===z.HARD?"#define USE_HARD_SHADOW":"",n.shadowType===z.POISSON_SOFT?"#define USE_POISSON_SOFT_SHADOW":"",n.shadowType===z.PCF3_SOFT?"#define USE_PCF3_SOFT_SHADOW":"",n.shadowType===z.PCF5_SOFT?"#define USE_PCF5_SOFT_SHADOW":"",n.shadowType===z.PCSS16_SOFT?"#define USE_PCSS16_SOFT_SHADOW":"",n.shadowType===z.PCSS32_SOFT?"#define USE_PCSS32_SOFT_SHADOW":"",n.shadowType===z.PCSS64_SOFT?"#define USE_PCSS64_SOFT_SHADOW":"",n.shadowType===z.PCSS16_SOFT||n.shadowType===z.PCSS32_SOFT||n.shadowType===z.PCSS64_SOFT?"#define USE_PCSS_SOFT_SHADOW":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.useShaderTextureLOD?"#define TEXTURE_LOD_EXT":"",n.useDiffuseMap?"#define USE_DIFFUSE_MAP "+n.useDiffuseMap:"",n.useAlphaMap?"#define USE_ALPHA_MAP "+n.useAlphaMap:"",n.useEnvMap?"#define USE_ENV_MAP":"",n.useAOMap?"#define USE_AOMAP "+n.useAOMap:"",n.useVertexColors==X.RGB?"#define USE_VCOLOR_RGB":"",n.useVertexColors==X.RGBA?"#define USE_VCOLOR_RGBA":"",n.useVertexTangents?"#define USE_TANGENT":"",n.premultipliedAlpha?"#define USE_PREMULTIPLIED_ALPHA":"",n.fog?"#define USE_FOG":"",n.fogExp2?"#define USE_EXP2_FOG":"",n.alphaTest?"#define ALPHATEST "+n.alphaTest:"",n.useEnvMap?"#define "+n.envMapCombine:"","#define GAMMA_FACTOR "+n.gammaFactor,n.useMatcap?"#define USE_MATCAP":"",n.useUv1?"#define USE_UV1":"",n.useUv2?"#define USE_UV2":"",n.dithering?"#define DITHERING":"",ni.encodings_pars_frag,ui("mapTexelToLinear",n.diffuseMapEncoding),n.useEnvMap?ui("envMapTexelToLinear",n.envMapEncoding):"",n.useEmissiveMap?ui("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.useMatcap?ui("matcapTexelToLinear",n.matcapEncoding):"",li("linearToOutputTexel",n.outputEncoding),n.packDepthToRGBA?"#define DEPTH_PACKING_RGBA":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","\n"].filter(hi).join("\n"),s=i,u=r;if(s=ci(s),u=ci(u),s=di(s,n),u=di(u,n),s=fi(s,n),u=fi(u,n),s=vi(s),u=vi(u),n.version>1){a=["#version 300 es\n","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+a,u=u.replace("#extension GL_EXT_draw_buffers : require","");for(var l=0,c=[];u.indexOf("gl_FragData["+l+"]")>-1;)u=u.replace("gl_FragData["+l+"]","pc_fragData"+l),c.push("layout(location = "+l+") out highp vec4 pc_fragData"+l+";"),l++;o=["#version 300 es\n","#define varying in",u.indexOf("layout")>-1||c.length>0?"":"out highp vec4 pc_fragColor;","#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad",c.join("\n")].join("\n")+"\n"+o}return new $n(t,s=a+s,u=o+u)}(this._gl,h,o,d,f),r.compile(i),r.code=s,a.push(r)}return r},e.releaseProgram=function(t){if(0==--t.usedTimes){var e=this._programs,n=e.indexOf(t);e[n]=e[e.length-1],e.pop(),t.dispose(this._gl)}},t}();function oi(t){var e;return t?t.encoding&&(e=t.encoding):e=H.LINEAR,e}function si(t){switch(t){case H.LINEAR:return["Linear","(value)"];case H.SRGB:return["sRGB","(value)"];case H.RGBE:return["RGBE","(value)"];case H.RGBM7:return["RGBM","(value, 7.0)"];case H.RGBM16:return["RGBM","(value, 16.0)"];case H.RGBD:return["RGBD","(value, 256.0)"];case H.GAMMA:return["Gamma","(value, float(GAMMA_FACTOR))"];default:console.error("unsupported encoding: "+t)}}function ui(t,e){var n=si(e);return"vec4 "+t+"(vec4 value) { return "+n[0]+"ToLinear"+n[1]+"; }"}function li(t,e){var n=si(e);return"vec4 "+t+"(vec4 value) { return LinearTo"+n[0]+n[1]+"; }"}var ci=function t(e){return e.replace(/#include +<([\w\d.]+)>/g,(function(e,n){var i=ni[n];if(void 0===i)throw new Error("Can not resolve #include <"+n+">");return t(i)}))};function hi(t){return""!==t}function di(t,e){return t.replace(/NUM_HEMI_LIGHTS/g,e.hemisphereLightNum).replace(/NUM_DIR_LIGHTS/g,e.directLightNum).replace(/NUM_SPOT_LIGHTS/g,e.spotLightNum).replace(/NUM_POINT_LIGHTS/g,e.pointLightNum).replace(/NUM_DIR_SHADOWS/g,e.directShadowNum).replace(/NUM_SPOT_SHADOWS/g,e.spotShadowNum).replace(/NUM_POINT_SHADOWS/g,e.pointShadowNum)}function fi(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes)}var pi=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function _i(t,e,n,i){for(var r="",a=parseInt(e);a1){if(n=this.getExtension("EXT_disjoint_timer_query_webgl2"))i=(null!=(r=t.getQuery(n.TIMESTAMP_EXT,n.QUERY_COUNTER_BITS_EXT))?r:0)>0}else if(n=this.getExtension("EXT_disjoint_timer_query"))i=(null!=(a=n.getQueryEXT(n.TIMESTAMP_EXT,n.QUERY_COUNTER_BITS_EXT))?a:0)>0}catch(t){console.warn(t)}this.timerQuery=n,this.canUseTimestamp=i,this.maxPrecision=function(t,e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}if("mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0)return"mediump";return"lowp"}(t,"highp"),this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.maxVertexTextures=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),this.maxCubemapSize=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),this.maxVertexUniformVectors=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),this.maxSamples=this.version>1?t.getParameter(t.MAX_SAMPLES):1,this.lineWidthRange=t.getParameter(t.ALIASED_LINE_WIDTH_RANGE)}return t.prototype.getExtension=function(t){var e=this._gl,n=this._extensions;if(void 0!==n[t])return n[t];var i=null;for(var r in gi)if(i=e.getExtension(gi[r]+t))break;return n[t]=i,i},t}(),gi=["","WEBKIT_","MOZ_"];var Ei=function(){function t(t,e){this._gl=t,this._capabilities=e}var e=t.prototype;return e.getGLType=function(t){var e,n=this._gl,i=this._capabilities,r=i.version>=2;if(t===F.UNSIGNED_BYTE)return n.UNSIGNED_BYTE;if(t===F.UNSIGNED_SHORT_5_6_5)return n.UNSIGNED_SHORT_5_6_5;if(t===F.UNSIGNED_SHORT_4_4_4_4)return n.UNSIGNED_SHORT_4_4_4_4;if(t===F.UNSIGNED_SHORT_5_5_5_1)return n.UNSIGNED_SHORT_5_5_5_1;if(r){if(t===F.UNSIGNED_SHORT)return n.UNSIGNED_SHORT;if(t===F.UNSIGNED_INT)return n.UNSIGNED_INT;if(t===F.UNSIGNED_INT_24_8)return n.UNSIGNED_INT_24_8;if(t===F.FLOAT)return n.FLOAT;if(t===F.HALF_FLOAT)return n.HALF_FLOAT;if(t===F.FLOAT_32_UNSIGNED_INT_24_8_REV)return n.FLOAT_32_UNSIGNED_INT_24_8_REV;if(t===F.BYTE)return n.BYTE;if(t===F.SHORT)return n.SHORT;if(t===F.INT)return n.INT}else{if(t===F.UNSIGNED_SHORT||t===F.UNSIGNED_INT||t===F.UNSIGNED_INT_24_8){if(!(e=i.getExtension("WEBGL_depth_texture")))return console.warn("extension WEBGL_depth_texture is not support."),null;if(t===F.UNSIGNED_SHORT)return n.UNSIGNED_SHORT;if(t===F.UNSIGNED_INT)return n.UNSIGNED_INT;if(t===F.UNSIGNED_INT_24_8)return e.UNSIGNED_INT_24_8_WEBGL}if(t===F.FLOAT)return(e=i.getExtension("OES_texture_float"))?n.FLOAT:(console.warn("extension OES_texture_float is not support."),null);if(t===F.HALF_FLOAT)return(e=i.getExtension("OES_texture_half_float"))?e.HALF_FLOAT_OES:(console.warn("extension OES_texture_half_float is not support."),null)}return void 0!==n[t]?n[t]:t},e.getGLFormat=function(t){var e,n=this._gl,i=this._capabilities;if(t===O.RGB)return n.RGB;if(t===O.RGBA)return n.RGBA;if(t===O.ALPHA)return n.ALPHA;if(t===O.LUMINANCE)return n.LUMINANCE;if(t===O.LUMINANCE_ALPHA)return n.LUMINANCE_ALPHA;if(t===O.DEPTH_COMPONENT)return n.DEPTH_COMPONENT;if(t===O.DEPTH_STENCIL)return n.DEPTH_STENCIL;if(t===O.RED)return n.RED;if(t===O.RED_INTEGER)return n.RED_INTEGER;if(t===O.RG)return n.RG;if(t===O.RG_INTEGER)return n.RG_INTEGER;if(t===O.RGB_INTEGER)return n.RGB_INTEGER;if(t===O.RGBA_INTEGER)return n.RGBA_INTEGER;if(t===O.RGB_S3TC_DXT1||t===O.RGBA_S3TC_DXT1||t===O.RGBA_S3TC_DXT3||t===O.RGBA_S3TC_DXT5){if(!(e=i.getExtension("WEBGL_compressed_texture_s3tc")))return console.warn("extension WEBGL_compressed_texture_s3tc is not support."),null;if(t===O.RGB_S3TC_DXT1)return e.COMPRESSED_RGB_S3TC_DXT1_EXT;if(t===O.RGBA_S3TC_DXT1)return e.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(t===O.RGBA_S3TC_DXT3)return e.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(t===O.RGBA_S3TC_DXT5)return e.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(t===O.RGB_PVRTC_4BPPV1||t===O.RGB_PVRTC_2BPPV1||t===O.RGBA_PVRTC_4BPPV1||t===O.RGBA_PVRTC_2BPPV1){if(!(e=i.getExtension("WEBGL_compressed_texture_pvrtc")))return console.warn("extension WEBGL_compressed_texture_pvrtc is not support."),null;if(t===O.RGB_PVRTC_4BPPV1)return e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(t===O.RGB_PVRTC_2BPPV1)return e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(t===O.RGBA_PVRTC_4BPPV1)return e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(t===O.RGBA_PVRTC_2BPPV1)return e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}return t===O.RGB_ETC1?(e=i.getExtension("WEBGL_compressed_texture_etc1"))?e.COMPRESSED_RGB_ETC1_WEBGL:(console.warn("extension WEBGL_compressed_texture_etc1 is not support."),null):t===O.RGBA_ASTC_4x4?(e=i.getExtension("WEBGL_compressed_texture_astc"))?e.COMPRESSED_RGBA_ASTC_4x4_KHR:(console.warn("extension WEBGL_compressed_texture_astc is not support."),null):t===O.RGBA_BPTC?(e=i.getExtension("EXT_texture_compression_bptc"))?e.COMPRESSED_RGBA_BPTC_UNORM_EXT:(console.warn("extension EXT_texture_compression_bptc is not support."),null):void 0!==n[t]?n[t]:t},e.getGLInternalFormat=function(t){var e,n=this._gl,i=this._capabilities,r=i.version>=2;if(t===O.RGBA4)return n.RGBA4;if(t===O.RGB5_A1)return n.RGB5_A1;if(t===O.DEPTH_COMPONENT16)return n.DEPTH_COMPONENT16;if(t===O.STENCIL_INDEX8)return n.STENCIL_INDEX8;if(t===O.DEPTH_STENCIL)return n.DEPTH_STENCIL;if(r){if(t===O.R8)return n.R8;if(t===O.RG8)return n.RG8;if(t===O.RGB8)return n.RGB8;if(t===O.RGBA8)return n.RGBA8;if(t===O.DEPTH_COMPONENT24)return n.DEPTH_COMPONENT24;if(t===O.DEPTH_COMPONENT32F)return n.DEPTH_COMPONENT32F;if(t===O.DEPTH24_STENCIL8)return n.DEPTH24_STENCIL8;if(t===O.DEPTH32F_STENCIL8)return n.DEPTH32F_STENCIL8;if(t===O.R16F||t===O.RG16F||t===O.RGB16F||t===O.RGBA16F||t===O.R32F||t===O.RG32F||t===O.RGB32F||t===O.RGBA32F){if(!(e=i.getExtension("EXT_color_buffer_float")))return console.warn("extension EXT_color_buffer_float is not support."),null;if(t===O.R16F)return n.R16F;if(t===O.RG16F)return n.RG16F;if(t===O.RGB16F)return n.RGB16F;if(t===O.RGBA16F)return n.RGBA16F;if(t===O.R32F)return n.R32F;if(t===O.RG32F)return n.RG32F;if(t===O.RGB32F)return n.RGB32F;if(t===O.RGBA32F)return n.RGBA32F}}else if(t===O.RGBA32F||t===O.RGB32F){if(!(e=i.getExtension("WEBGL_color_buffer_float")))return console.warn("extension WEBGL_color_buffer_float is not support."),null;if(t===O.RGBA32F)return e.RGBA32F_EXT;if(t===O.RGB32F)return e.RGB32F_EXT}return void 0!==n[t]?n[t]:t},t}();function Si(t,e,n,i){var r=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(var o=0;o=this._capabilities.maxTextures&&console.warn("trying to use "+t+" texture units while this GPU supports only "+this._capabilities.maxTextures),t},n.resetTextureUnits=function(){this._usedTextureUnits=0},n.setTexture2D=function(t,e){var n=this._gl,i=this._state,r=this._capabilities,a=this._constants;void 0!==e&&(e=n.TEXTURE0+e);var o=this.get(t);if(t.image&&o.__version!==t.version&&(!t.image.rtt||void 0===e)&&!o.__external){void 0===o.__webglTexture&&(t.addEventListener("dispose",this._onTextureDispose),o.__webglTexture=n.createTexture()),i.activeTexture(e),i.bindTexture(n.TEXTURE_2D,o.__webglTexture);var s=t.image,u=Di(s);u&&(s=Li(s,r.maxTextureSize),bi(t)&&!1===Ni(s)&&r.version<2&&(s=Pi(s)));var l=!Ni(s)&&r.version<2;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,t.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,n.NONE),this._setTextureParameters(t,l);var c,h=a.getGLFormat(t.format),d=a.getGLType(t.type),f=null!==t.internalformat?a.getGLInternalFormat(t.internalformat):Ci(n,r,h,d),p=t.mipmaps;if(u)if(p.length>0&&!l){for(var _=0,v=p.length;_0&&!l){for(var m=s.isCompressed,g=0,E=p.length;g0&&!u){for(var E=0,S=v.length;E0&&!u){for(var M=g.isCompressed,T=0,y=v.length;T=2&&(void 0!==s[6]?(n.texParameteri(o,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(o,n.TEXTURE_COMPARE_FUNC,s[6])):n.texParameteri(o,n.TEXTURE_COMPARE_MODE,n.NONE))},n._generateMipmap=function(t,e,n,i){this._gl.generateMipmap(t),this.get(e).__maxMipLevel=Math.log(Math.max(n,i))*Math.LOG2E},e}(Ai);function bi(t){return t.wrapS!==U.CLAMP_TO_EDGE||t.wrapT!==U.CLAMP_TO_EDGE||t.minFilter!==I.NEAREST&&t.minFilter!==I.LINEAR}function Ri(t){return t===I.NEAREST||t===I.NEAREST_MIPMAP_LINEAR||t===I.NEAREST_MIPMAP_NEAREST?I.NEAREST:I.LINEAR}function Ni(t){return Qt(t.width)&&Qt(t.height)}function Pi(t){if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){var e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return e.width=Zt(t.width),e.height=Zt(t.height),e.getContext("2d").drawImage(t,0,0,e.width,e.height),console.warn("image is not power of two ("+t.width+"x"+t.height+"). Resized to "+e.width+"x"+e.height,t),e}return t}function Li(t,e){if(t.width>e||t.height>e){var n=e/Math.max(t.width,t.height),i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return i.width=Math.floor(t.width*n),i.height=Math.floor(t.height*n),i.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,i.width,i.height),console.warn("image is too big ("+t.width+"x"+t.height+"). Resized to "+i.width+"x"+i.height,t),i}return t}function Ci(t,e,n,i){if(!1===e.version>=2)return n;var r=n;return n===t.RED&&(i===t.FLOAT&&(r=t.R32F),i===t.HALF_FLOAT&&(r=t.R16F),i===t.UNSIGNED_BYTE&&(r=t.R8)),n===t.RG&&(i===t.FLOAT&&(r=t.RG32F),i===t.HALF_FLOAT&&(r=t.RG16F),i===t.UNSIGNED_BYTE&&(r=t.RG8)),n===t.RGB&&(i===t.FLOAT&&(r=t.RGB32F),i===t.HALF_FLOAT&&(r=t.RGB16F),i===t.UNSIGNED_BYTE&&(r=t.RGB8)),n===t.RGBA&&(i===t.FLOAT&&(r=t.RGBA32F),i===t.HALF_FLOAT&&(r=t.RGBA16F),i===t.UNSIGNED_BYTE&&(r=t.RGBA8),i===t.UNSIGNED_SHORT_4_4_4_4&&(r=t.RGBA4),i===t.UNSIGNED_SHORT_5_5_5_1&&(r=t.RGB5_A1)),n!==t.DEPTH_COMPONENT&&n!==t.DEPTH_STENCIL||(r=t.DEPTH_COMPONENT16,i===t.FLOAT&&(r=t.DEPTH_COMPONENT32F),i===t.UNSIGNED_INT&&(r=t.DEPTH_COMPONENT24),i===t.UNSIGNED_INT_24_8&&(r=t.DEPTH24_STENCIL8),i===t.FLOAT_32_UNSIGNED_INT_24_8_REV&&(r=t.DEPTH32F_STENCIL8)),r!==t.R16F&&r!==t.R32F&&r!==t.RG16F&&r!==t.RG32F&&r!==t.RGB16F&&r!==t.RGB32F&&r!==t.RGBA16F&&r!==t.RGBA32F||e.getExtension("EXT_color_buffer_float"),r}function Di(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap}var Oi,Fi=function(t){function e(e,n,i,r){var a;(a=t.call(this,e)||this)._gl=n,a._capabilities=i,a._constants=r;var o=u(a);return a._onRenderBufferDispose=function t(e){var i=e.target;i.removeEventListener("dispose",t);var r=o.get(i);r.__webglRenderbuffer&&!r.__external&&n.deleteRenderbuffer(r.__webglRenderbuffer),o.delete(i)},a}i(e,t);var n=e.prototype;return n.setRenderBuffer=function(t){var e=this._gl,n=this._capabilities,i=this._constants,r=this.get(t);if(void 0===r.__webglRenderbuffer){t.addEventListener("dispose",this._onRenderBufferDispose),r.__webglRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,r.__webglRenderbuffer);var a=i.getGLInternalFormat(t.format);t.multipleSampling>0?(n.version<2&&console.error("render buffer multipleSampling is not support in webgl 1.0."),e.renderbufferStorageMultisample(e.RENDERBUFFER,Math.min(t.multipleSampling,n.maxSamples),a,t.width,t.height)):e.renderbufferStorage(e.RENDERBUFFER,a,t.width,t.height)}else e.bindRenderbuffer(e.RENDERBUFFER,r.__webglRenderbuffer);return r},n.setRenderBufferExternal=function(t,e){var n=this._gl,i=this.get(t);i.__external||(i.__webglRenderbuffer?n.deleteRenderbuffer(i.__webglRenderbuffer):t.addEventListener("dispose",this._onRenderBufferDispose)),i.__webglRenderbuffer=e,i.__external=!0},e}(Ai),Ii=function(t){function e(e,n,i,r,a,o,s){var l;(l=t.call(this,e)||this)._gl=n,l._state=i,l._capabilities=r,l._textures=a,l._renderBuffers=o,l._constants=s;var c=u(l);return l._onRenderTargetDispose=function t(e){var r=e.target;r.removeEventListener("dispose",t);var a=c.get(r);a.__webglFramebuffer&&n.deleteFramebuffer(a.__webglFramebuffer),c.delete(r),i.currentRenderTarget===r&&(i.currentRenderTarget=null)},l}i(e,t);var n=e.prototype;return n._setupRenderTarget=function(t){var e=this._gl,n=this._state,i=this._textures,r=this._renderBuffers,a=this._capabilities,o=this.get(t);t.addEventListener("dispose",this._onRenderTargetDispose);var s=e.createFramebuffer(),u=[];for(var l in o.__webglFramebuffer=s,o.__drawBuffers=u,t.isRenderTargetCube&&(o.__currentActiveCubeFace=t.activeCubeFace),e.bindFramebuffer(e.FRAMEBUFFER,s),t._attachments){var c=Ui[l];c===e.DEPTH_ATTACHMENT||c===e.DEPTH_STENCIL_ATTACHMENT?a.version<2&&!a.getExtension("WEBGL_depth_texture")&&console.warn("WebGLRenderTargets: extension WEBGL_depth_texture is not support."):c!==e.STENCIL_ATTACHMENT&&u.push(c);var h=t._attachments[l];if(h.isTexture2D){var d=i.setTexture2D(h);e.framebufferTexture2D(e.FRAMEBUFFER,c,e.TEXTURE_2D,d.__webglTexture,0),n.bindTexture(e.TEXTURE_2D,null)}else if(h.isTextureCube){var f=i.setTextureCube(h);e.framebufferTexture2D(e.FRAMEBUFFER,c,e.TEXTURE_CUBE_MAP_POSITIVE_X+t.activeCubeFace,f.__webglTexture,0),n.bindTexture(e.TEXTURE_CUBE_MAP,null)}else{var p=r.setRenderBuffer(h);e.framebufferRenderbuffer(e.FRAMEBUFFER,c,e.RENDERBUFFER,p.__webglRenderbuffer)}}u.sort(Bi),a.version>=2?e.drawBuffers(u):a.getExtension("WEBGL_draw_buffers")&&a.getExtension("WEBGL_draw_buffers").drawBuffersWEBGL(u)},n.setRenderTarget=function(t){var e,n=this._gl,i=this._state,r=this._textures;if(i.currentRenderTarget!==t&&(t.isRenderTargetBack?n.bindFramebuffer(n.FRAMEBUFFER,null):void 0===(e=this.get(t)).__webglFramebuffer?this._setupRenderTarget(t):n.bindFramebuffer(n.FRAMEBUFFER,e.__webglFramebuffer),i.currentRenderTarget=t),t.isRenderTargetCube){e=this.get(t);var a=t.activeCubeFace;if(e.__currentActiveCubeFace!==a){for(var o in t._attachments){var s=t._attachments[o];if(s.isTextureCube){var u=r.get(s);n.framebufferTexture2D(n.FRAMEBUFFER,Ui[o],n.TEXTURE_CUBE_MAP_POSITIVE_X+a,u.__webglTexture,0)}}e.__currentActiveCubeFace=a}}},n.blitRenderTarget=function(t,e,n,i,r){void 0===n&&(n=!0),void 0===i&&(i=!0),void 0===r&&(r=!0);var a=this._gl,o=this._capabilities;if(o.version<2)console.warn("WebGLRenderTargets: blitFramebuffer not support by WebGL"+o.version);else{var s=this.get(t).__webglFramebuffer,u=this.get(e).__webglFramebuffer;a.bindFramebuffer(a.READ_FRAMEBUFFER,s),a.bindFramebuffer(a.DRAW_FRAMEBUFFER,u);var l=0;n&&(l|=a.COLOR_BUFFER_BIT),i&&(l|=a.DEPTH_BUFFER_BIT),r&&(l|=a.STENCIL_BUFFER_BIT),a.blitFramebuffer(0,0,t.width,t.height,0,0,e.width,e.height,l,a.NEAREST)}},n.readRenderTargetPixels=function(t,e,n,i,r){var a=this._gl,o=this._state,s=this._constants,u=o.currentRenderTarget;if(u&&u.texture){if(t>=0&&t<=u.width-n&&e>=0&&e<=u.height-i){var l=s.getGLType(u.texture.type),c=s.getGLFormat(u.texture.format);a.readPixels(t,e,n,i,c,l,r)}}else console.warn("WebGLRenderTargets.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not bound or texture not attached.")},n.updateRenderTargetMipmap=function(t){var e=this._gl,n=this._state,i=this._capabilities,r=t.texture;if(r.generateMipmaps&&r.minFilter!==I.NEAREST&&r.minFilter!==I.LINEAR&&(function(t){return Qt(t.width)&&Qt(t.height)}(t)||i.version>=2)){var a=e.TEXTURE_2D;r.isTextureCube&&(a=e.TEXTURE_CUBE_MAP),r.isTexture3D&&(a=e.TEXTURE_3D);var o=this._textures.get(r).__webglTexture;n.bindTexture(a,o),e.generateMipmap(a),n.bindTexture(a,null)}},e}(Ai),Ui=((Oi={})[W.COLOR_ATTACHMENT0]=36064,Oi[W.COLOR_ATTACHMENT1]=36065,Oi[W.COLOR_ATTACHMENT2]=36066,Oi[W.COLOR_ATTACHMENT3]=36067,Oi[W.COLOR_ATTACHMENT4]=36068,Oi[W.COLOR_ATTACHMENT5]=36069,Oi[W.COLOR_ATTACHMENT6]=36070,Oi[W.COLOR_ATTACHMENT7]=36071,Oi[W.COLOR_ATTACHMENT8]=36072,Oi[W.COLOR_ATTACHMENT9]=36073,Oi[W.COLOR_ATTACHMENT10]=36074,Oi[W.COLOR_ATTACHMENT11]=36075,Oi[W.COLOR_ATTACHMENT12]=36076,Oi[W.COLOR_ATTACHMENT13]=36077,Oi[W.COLOR_ATTACHMENT14]=36078,Oi[W.COLOR_ATTACHMENT15]=36079,Oi[W.DEPTH_ATTACHMENT]=36096,Oi[W.STENCIL_ATTACHMENT]=36128,Oi[W.DEPTH_STENCIL_ATTACHMENT]=33306,Oi);function Bi(t,e){return t-e}var Gi=function(t){function e(e,n,i){var r;return(r=t.call(this,e)||this)._gl=n,r._capabilities=i,r}i(e,t);var n=e.prototype;return n.setBuffer=function(t,e,n){var i=this.get(t),r=void 0===i.glBuffer;(r||i.version!==t.version)&&(n&&n.reset(),r||i.__external?this._createGLBuffer(i,t,e):(this._updateGLBuffer(i.glBuffer,t,e),i.version=t.version))},n.removeBuffer=function(t){var e=this._gl,n=this.get(t);n.glBuffer&&!n.__external&&e.deleteBuffer(n.glBuffer),this.delete(t)},n.setBufferExternal=function(t,e){var n=this._gl,i=this.get(t);i.__external||i.glBuffer&&n.deleteBuffer(i.glBuffer);var r=zi(n,t.array);i.glBuffer=e,i.type=r,i.bytesPerElement=t.array.BYTES_PER_ELEMENT,i.version=t.version,i.__external=!0},n._createGLBuffer=function(t,e,n){var i=this._gl,r=e.array,a=e.usage,o=i.createBuffer();i.bindBuffer(n,o),i.bufferData(n,r,a),e.onUploadCallback();var s=zi(i,r);t.glBuffer=o,t.type=s,t.bytesPerElement=r.BYTES_PER_ELEMENT,t.version=e.version,t.__external=!1},n._updateGLBuffer=function(t,e,n){var i=this._gl,r=this._capabilities,a=e.array,o=e.updateRange;i.bindBuffer(n,t),-1===o.count?i.bufferSubData(n,0,a):(r.version>=2?i.bufferSubData(n,o.offset*a.BYTES_PER_ELEMENT,a,o.offset,o.count):i.bufferSubData(n,o.offset*a.BYTES_PER_ELEMENT,a.subarray(o.offset,o.offset+o.count)),o.count=-1)},e}(Ai);function zi(t,e){var n;return e instanceof Float32Array?n=t.FLOAT:e instanceof Float64Array?console.warn("Unsupported data buffer format: Float64Array."):n=e instanceof Uint16Array?t.UNSIGNED_SHORT:e instanceof Int16Array?t.SHORT:e instanceof Uint32Array?t.UNSIGNED_INT:e instanceof Int32Array?t.INT:e instanceof Int8Array?t.BYTE:e instanceof Uint8Array?t.UNSIGNED_BYTE:t.FLOAT,n}var Hi=function(t){function e(e,n,i,r){var a;(a=t.call(this,e)||this)._gl=n,a._buffers=i,a._vertexArrayBindings=r;var o=u(a);return a._onGeometryDispose=function t(e){var n=e.target,a=o.get(n);for(var s in n.removeEventListener("dispose",t),null!==n.index&&i.removeBuffer(n.index.buffer),n.attributes)i.removeBuffer(n.attributes[s].buffer);for(var u in n.morphAttributes)for(var l=n.morphAttributes[u],c=0,h=l.length;c=2,a._vaoExt=i.getExtension("OES_vertex_array_object"),a._currentGeometryProgram="",a._currentVAO=null,a}i(e,t);var n=e.prototype;return n.setup=function(t,e,n){if(t.morphTargetInfluences)this.reset(),this._setupVertexAttributes(n,e),this._currentGeometryProgram="";else if(this._isWebGL2||this._vaoExt){var i=this.get(e);void 0===i._vaos&&(i._vaos={});var r=i._vaos[n.id];r||(r=i._vaos[n.id]={version:-1,object:this._createVAO()}),this._bindVAO(r.object),r.version!==e.version&&(this._setupVertexAttributes(n,e),r.version=e.version)}else{var a=n.id+"_"+e.id+"_"+e.version;a!==this._currentGeometryProgram&&(this._setupVertexAttributes(n,e),this._currentGeometryProgram=a)}},n.releaseByGeometry=function(t){var e=this.get(t);if(e._vaos){for(var n in e._vaos){var i=e[n];i&&this._disposeVAO(i.object)}e._vaos={}}},n.reset=function(t){(null!==this._currentVAO||t)&&(this._isWebGL2?this._gl.bindVertexArray(null):this._vaoExt&&this._vaoExt.bindVertexArrayOES(null),this._currentVAO=null),""!==this._currentGeometryProgram&&(this._currentGeometryProgram="")},n._createVAO=function(){return this._isWebGL2?this._gl.createVertexArray():this._vaoExt?this._vaoExt.createVertexArrayOES():null},n._bindVAO=function(t){this._currentVAO!==t&&(this._isWebGL2?this._gl.bindVertexArray(t):this._vaoExt&&this._vaoExt.bindVertexArrayOES(t),this._currentVAO=t)},n._disposeVAO=function(t){this._isWebGL2?this._gl.deleteVertexArray(t):this._vaoExt&&this._vaoExt.deleteVertexArrayOES(t)},n._setupVertexAttributes=function(t,e){var n=this._gl,i=this._isWebGL2,r=t.getAttributes(),a=this._capabilities,o=this._buffers;for(var s in r){var u=r[s],l=e.getAttribute(s);if(l){var c=l.size;u.count!==c&&console.warn("WebGLVertexArrayBindings: attribute "+s+" size not match! "+u.count+" : "+c);var h=l.buffer,d=o.get(h),f=d.type;u.format;for(var p=0,_=u.locationSize;p<_;p++)n.enableVertexAttribArray(u.location+p);if(l.divisor>0)for(var v=0,m=u.locationSize;v1?n.deleteQuery(a._webglQuery):o.deleteQueryEXT(a._webglQuery)),s.delete(r)},a._typeToGL=((r={})[Y.ANY_SAMPLES_PASSED]=35887,r[Y.ANY_SAMPLES_PASSED_CONSERVATIVE]=36202,r[Y.TIME_ELAPSED]=35007,r),a}i(e,t);var n=e.prototype;return n._get=function(t){var e=this._capabilities,n=this.get(t);return void 0===n._webglQuery&&(t.addEventListener("dispose",this._onQueryDispose),n._webglQuery=e.version>1?this._gl.createQuery():e.timerQuery.createQueryEXT(),n._target=null,n._result=null),n},n.begin=function(t,e){var n=this._capabilities,i=this._typeToGL,r=this._get(t);n.version>1?this._gl.beginQuery(i[e],r._webglQuery):n.timerQuery.beginQueryEXT(i[e],r._webglQuery),r._target=e,r._result=null},n.end=function(t){var e=this._capabilities,n=this._typeToGL,i=this._get(t);e.version>1?this._gl.endQuery(n[i._target]):e.timerQuery.endQueryEXT(n[i._target])},n.counter=function(t){var e=this._capabilities.timerQuery,n=this._get(t);e.queryCounterEXT(n._webglQuery,e.TIMESTAMP_EXT),n._target=e.TIMESTAMP_EXT,n._result=null},n.isResultAvailable=function(t){var e=this._gl,n=this._capabilities,i=n.timerQuery,r=this._get(t);return n.version>1?e.getQueryParameter(r._webglQuery,e.QUERY_RESULT_AVAILABLE):i.getQueryObjectEXT(r._webglQuery,i.QUERY_RESULT_AVAILABLE)},n.isTimerDisjoint=function(){return this._gl.getParameter(this._capabilities.timerQuery.GPU_DISJOINT_EXT)},n.getResult=function(t){var e=this._gl,n=this._capabilities,i=n.timerQuery,r=this._get(t);return null===r._result&&(n.version>1?r._result=e.getQueryParameter(r._webglQuery,e.QUERY_RESULT):r._result=i.getQueryObjectEXT(r._webglQuery,i.QUERY_RESULT_EXT)),r._result},e}(Ai),Wi=new Wt,ji=new m,Yi=new WeakMap,qi=new Float32Array(8),Qi=new Float32Array([]);function Zi(t){return t.geometry}function Ki(t){return t.material}function Ji(t){return!0}function $i(){}var tr=0,er=function(){function t(t){var e=tr++,n=new mi(t),i=new Ei(t,n),r=new xi(t,n),a=new wi(e,t,r,n,i),o=new Fi(e,t,n,i),s=new Ii(e,t,r,n,a,o,i),u=new Gi(e,t,n),l=new ki(e,t,n,u),c=new Hi(e,t,u,l),h=new ai(t,r,n),d=new Vi(e,h),f=new Xi(e,t,n);this.id=e,this.gl=t,this.capabilities=n,this._textures=a,this._renderBuffers=o,this._renderTargets=s,this._buffers=u,this._geometries=c,this._programs=h,this._materials=d,this._state=r,this._vertexArrayBindings=l,this._queries=f}var e=t.prototype;return e.clear=function(t,e,n){var i=this.gl,r=0;(void 0===t||t)&&(r|=i.COLOR_BUFFER_BIT),(void 0===e||e)&&(r|=i.DEPTH_BUFFER_BIT),(void 0===n||n)&&(r|=i.STENCIL_BUFFER_BIT),r>0&&i.clear(r)},e.setClearColor=function(t,e,n,i,r){this._state.colorBuffer.setClear(t,e,n,i,r)},e.getClearColor=function(){return this._state.colorBuffer.getClear()},e.setRenderTarget=function(t){this._renderTargets.setRenderTarget(t)},e.getRenderTarget=function(){return this._state.currentRenderTarget},e.blitRenderTarget=function(t,e,n,i,r){void 0===n&&(n=!0),void 0===i&&(i=!0),void 0===r&&(r=!0),this._renderTargets.blitRenderTarget(t,e,n,i,r)},e.readRenderTargetPixels=function(t,e,n,i,r){this._renderTargets.readRenderTargetPixels(t,e,n,i,r)},e.updateRenderTargetMipmap=function(t){this._renderTargets.updateRenderTargetMipmap(t)},e.setTextureExternal=function(t,e){this._textures.setTextureExternal(t,e)},e.setRenderBufferExternal=function(t,e){this._renderBuffers.setRenderBufferExternal(t,e)},e.setBufferExternal=function(t,e){this._buffers.setBufferExternal(t,e)},e.resetVertexArrayBindings=function(t){this._vertexArrayBindings.reset(t)},e.resetState=function(){this._state.reset()},e.beginQuery=function(t,e){this._queries.begin(t,e)},e.endQuery=function(t){this._queries.end(t)},e.queryCounter=function(t){this._queries.counter(t)},e.isTimerQueryDisjoint=function(t){return this._queries.isTimerDisjoint(t)},e.isQueryResultAvailable=function(t){return this._queries.isResultAvailable(t)},e.getQueryResult=function(t){return this._queries.getResult(t)},e.render=function(t,e,n){var i=this._state,r=this.capabilities,a=this._vertexArrayBindings,o=this._textures,s=n.getGeometry||Zi,u=n.getMaterial||Ki,l=n.beforeRender||$i,c=n.afterRender||$i,h=n.ifRender||Ji,d=n.renderInfo,f=e.scene,p=e.lights,_=e.camera,v=i.currentRenderTarget;if(h(t)){var m=t.object,g=u.call(this,t),E=s.call(this,t),S=t.group,M=g.fog?f.fog:null,T=void 0!==g.envMap?g.envMap||f.environment:null,y=f.clippingPlanesData,x=f.numClippingPlanes;g.clippingPlanes&&g.clippingPlanes.length>0&&(Qi.length<4*g.clippingPlanes.length&&(Qi=new Float32Array(4*g.clippingPlanes.length)),y=f.setClippingPlanesData(g.clippingPlanes,Qi),x=g.clippingPlanes.length),m.onBeforeRender(t,g),l.call(this,t,g);var A=this._materials.setMaterial(g);if(!1===g.needsUpdate)if(void 0===A.program)g.needsUpdate=!0;else if(A.fog!==M)g.needsUpdate=!0;else if(A.envMap!==T)g.needsUpdate=!0;else if(A.numClippingPlanes!==x)g.needsUpdate=!0;else if(A.logarithmicDepthBuffer!==f.logarithmicDepthBuffer)g.needsUpdate=!0;else if(e.outputEncoding!==A.outputEncoding||e.gammaFactor!==A.gammaFactor)g.needsUpdate=!0;else if(r.version>1&&f.disableShadowSampler!==A.disableShadowSampler)g.needsUpdate=!0;else{var w=g.acceptLight&&p.totalNum>0;w!==A.acceptLight?g.needsUpdate=!0:w&&(p.hash.compare(A.lightsHash)&&m.receiveShadow===A.receiveShadow&&m.shadowType===A.shadowType||(g.needsUpdate=!0))}if(g.needsUpdate){var b=A.program;A.program=this._programs.getProgram(g,m,e,!0),b&&this._programs.releaseProgram(b),A.fog=M,A.envMap=T,A.logarithmicDepthBuffer=f.logarithmicDepthBuffer,A.acceptLight=g.acceptLight,A.lightsHash=p.hash.copyTo(A.lightsHash),A.receiveShadow=m.receiveShadow,A.shadowType=m.shadowType,A.numClippingPlanes=x,A.outputEncoding=e.outputEncoding,A.gammaFactor=e.gammaFactor,A.disableShadowSampler=f.disableShadowSampler,g.needsUpdate=!1}var R=A.program;if(void 0!==R.program){i.setProgram(R),this._geometries.setGeometry(E),m.morphTargetInfluences&&this._updateMorphtargets(m,E,R),a.setup(m,E,R);var N=!1;R.lightId===p.id&&R.lightVersion===p.version||(N=!0,R.lightId=p.id,R.lightVersion=p.version);var P=!1;R.cameraId===_.id&&R.cameraVersion===_.version||(P=!0,R.cameraId=_.id,R.cameraVersion=_.version);var L=!1;R.sceneId===f.id&&R.sceneVersion===f.version||(L=!0,R.sceneId=f.id,R.sceneVersion=f.version);var C=R.getUniforms();g.acceptLight&&this._uploadLights(C,p,f.disableShadowSampler,N),m.isSkinnedMesh&&this._uploadSkeleton(C,m,f);for(var D=0,O=C.seq.length;D0&&i&&t.set("u_Hemi",e.hemisphere),e.directsNum>0&&(i&&t.set("u_Directional",e.directional),e.directShadowNum>0&&(i&&t.set("u_DirectionalShadow",e.directionalShadow),t.has("directionalShadowMap")&&(this.capabilities.version>=2&&!n?t.set("directionalShadowMap",e.directionalShadowDepthMap,r):t.set("directionalShadowMap",e.directionalShadowMap,r),t.set("directionalShadowMatrix",e.directionalShadowMatrix)),t.has("directionalDepthMap")&&t.set("directionalDepthMap",e.directionalShadowMap,r))),e.pointsNum>0&&(i&&t.set("u_Point",e.point),e.pointShadowNum>0&&(i&&t.set("u_PointShadow",e.pointShadow),t.has("pointShadowMap")&&(t.set("pointShadowMap",e.pointShadowMap,r),t.set("pointShadowMatrix",e.pointShadowMatrix)))),e.spotsNum>0&&(i&&t.set("u_Spot",e.spot),e.spotShadowNum>0&&(i&&t.set("u_SpotShadow",e.spotShadow),t.has("spotShadowMap")&&(this.capabilities.version>=2&&!n?t.set("spotShadowMap",e.spotShadowDepthMap,r):t.set("spotShadowMap",e.spotShadowMap,r),t.set("spotShadowMatrix",e.spotShadowMatrix)),t.has("spotDepthMap")&&t.set("spotDepthMap",e.spotShadowMap,r)))},e._uploadSkeleton=function(t,e,n){if(e.skeleton&&e.skeleton.bones.length>0){var i=e.skeleton,r=this.capabilities;r.maxVertexTextures>0&&(r.getExtension("OES_texture_float")||r.version>=2)?(void 0===i.boneTexture&&i.generateBoneTexture(r.version>=2),t.set("boneTexture",i.boneTexture,this._textures),t.set("boneTextureSize",i.boneTexture.image.width)):t.set("boneMatrices",i.boneMatrices),t.set("bindMatrix",e.bindMatrix.elements),ji.copy(e.bindMatrixInverse),n.useAnchorMatrix&&ji.multiply(n.anchorMatrix),t.set("bindMatrixInverse",ji.elements)}},e._updateMorphtargets=function(t,e,n){var i=t.morphTargetInfluences;Yi.has(e)||Yi.set(e,i.slice(0));for(var r=e.morphAttributes.position,a=e.morphAttributes.normal,o=Yi.get(e),s=0;s0&&(r&&e.addAttribute("morphTarget"+l,r[c]),a&&e.addAttribute("morphNormal"+l,a[c]),qi[l]=h,l++)}for(;l<8;l++)qi[l]=0;n.getUniforms().set("morphTargetInfluences",qi)},e._draw=function(t,e,n,i){var r=this.gl,a=this.capabilities,o=this._buffers,s=null!==t.index,u=0,l=s?t.index.buffer.count:t.getAttribute("a_Position").buffer.count,c=n?n.start:0,h=n?n.count:1/0;u=Math.max(u,c),l=Math.min(l,h);var d=t.instanceCount,f=d>=0;if(s){var p=o.get(t.index.buffer),_=p.bytesPerElement,v=p.type;if(v===r.UNSIGNED_INT&&a.version<2&&!a.getExtension("OES_element_index_uint")&&console.warn("draw elements type not support UNSIGNED_INT!"),f){if(d>0)if(a.version>=2)r.drawElementsInstanced(e.drawMode,l,v,u*_,d);else{if(!a.getExtension("ANGLE_instanced_arrays"))return void console.warn("no support instanced draw.");a.getExtension("ANGLE_instanced_arrays").drawElementsInstancedANGLE(e.drawMode,l,v,u*_,d)}}else r.drawElements(e.drawMode,l,v,u*_)}else if(f){if(d>0)if(a.version>=2)r.drawArraysInstanced(e.drawMode,u,l,d);else{if(!a.getExtension("ANGLE_instanced_arrays"))return void console.warn("no support instanced draw.");a.getExtension("ANGLE_instanced_arrays").drawArraysInstancedANGLE(e.drawMode,u,l,d)}}else r.drawArrays(e.drawMode,u,l);i&&i.update(l,e.drawMode,d<0?1:d)},t}(),nr=function(){function t(t){this.renderPass=new er(t)}var e=t.prototype;return e.renderScene=function(t,e){for(var n,i=t.getRenderStates(e),r=t.getRenderQueue(e),a=0,o=r.layerList.length;a0?1:-1,d.push(R.x,R.y,R.z),f.push(L/u),f.push(1-N/m),w+=1}for(var D=0;D65536?new Uint32Array(c):new Uint16Array(c),1))),s.addAttribute("a_Position",new an(new on(new Float32Array(h),3))),s.addAttribute("a_Normal",new an(new on(new Float32Array(d),3))),s.addAttribute("a_Uv",new an(new on(new Float32Array(f),2))),s.computeBoundingBox(),s.computeBoundingSphere(),s}return i(e,t),e}(fn),or=function(t){function e(e,n,i,r,a,o,s,l){var c;void 0===e&&(e=1),void 0===n&&(n=1),void 0===i&&(i=1),void 0===r&&(r=8),void 0===a&&(a=1),void 0===o&&(o=!1),void 0===s&&(s=0),void 0===l&&(l=2*Math.PI);var h=u(c=t.call(this)||this);r=Math.floor(r),a=Math.floor(a);var d=[],f=[],p=[],v=[],m=0,g=[],E=i/2,S=0;function M(t){var i,a=m,o=new pt,u=new _,c=0,g=!0===t?e:n,M=!0===t?1:-1;for(i=1;i<=r;i++)f.push(0,E*M,0),p.push(0,M,0),v.push(.5,.5),m++;var T=m;for(i=0;i<=r;i++){var y=i/r*l+s,x=Math.cos(y),A=Math.sin(y);u.x=g*A,u.y=E*M,u.z=g*x,f.push(u.x,u.y,u.z),p.push(0,M,0),o.x=.5*x+.5,o.y=.5*A*M+.5,v.push(o.x,o.y),m++}for(i=0;i0&&M(!0),n>0&&M(!1)),c.setIndex(new an(new on(f.length/3>65536?new Uint32Array(d):new Uint16Array(d),1))),c.addAttribute("a_Position",new an(new on(new Float32Array(f),3))),c.addAttribute("a_Normal",new an(new on(new Float32Array(p),3))),c.addAttribute("a_Uv",new an(new on(new Float32Array(v),2))),c.computeBoundingBox(),c.computeBoundingSphere(),c}return i(e,t),e}(fn),sr=function(t){function e(e,n,i,r,a,o,s){var u;void 0===e&&(e=1),void 0===n&&(n=8),void 0===i&&(i=6),void 0===r&&(r=0),void 0===a&&(a=2*Math.PI),void 0===o&&(o=0),void 0===s&&(s=Math.PI),u=t.call(this)||this,n=Math.max(3,Math.floor(n)),i=Math.max(2,Math.floor(i));var l,c,h=o+s,d=0,f=[],p=new _,v=new _,m=[],g=[],E=[],S=[];for(c=0;c<=i;c++){var M=[],T=c/i,y=0;for(0==c&&0==o?y=.5/n:c==i&&h==Math.PI&&(y=-.5/n),l=0;l<=n;l++){var x=l/n;p.x=-e*Math.cos(r+x*a)*Math.sin(o+T*s),p.y=e*Math.cos(o+T*s),p.z=e*Math.sin(r+x*a)*Math.sin(o+T*s),g.push(p.x,p.y,p.z),v.copy(p).normalize(),E.push(v.x,v.y,v.z),S.push(x+y,1-T),M.push(d++)}f.push(M)}for(c=0;c0)&&m.push(A,w,R),(c!==i-1||h65536?new Uint32Array(m):new Uint16Array(m),1))),u.addAttribute("a_Position",new an(new on(new Float32Array(g),3))),u.addAttribute("a_Normal",new an(new on(new Float32Array(E),3))),u.addAttribute("a_Uv",new an(new on(new Float32Array(S),2))),u.computeBoundingBox(),u.computeBoundingSphere(),u}return i(e,t),e}(fn),ur=function(t){function e(e,n,i,r,a,o){var s;void 0===e&&(e=1),void 0===n&&(n=.4),void 0===i&&(i=64),void 0===r&&(r=8),void 0===a&&(a=2),void 0===o&&(o=3),s=t.call(this)||this,i=Math.floor(i),r=Math.floor(r);var u,l,c=[],h=[],d=[],f=[],p=new _,v=new _,m=new _,g=new _,E=new _,S=new _,M=new _;for(u=0;u<=i;++u){var T=u/i*a*Math.PI*2;for(P(T,a,o,e,m),P(T+.01,a,o,e,g),S.subVectors(g,m),M.addVectors(g,m),E.crossVectors(S,M),M.crossVectors(E,S),E.normalize(),M.normalize(),l=0;l<=r;++l){var y=l/r*Math.PI*2,x=-n*Math.cos(y),A=n*Math.sin(y);p.x=m.x+(x*M.x+A*E.x),p.y=m.y+(x*M.y+A*E.y),p.z=m.z+(x*M.z+A*E.z),h.push(p.x,p.y,p.z),v.subVectors(p,m).normalize(),d.push(v.x,v.y,v.z),f.push(u/i),f.push(l/r)}}for(l=1;l<=i;l++)for(u=1;u<=r;u++){var w=(r+1)*(l-1)+(u-1),b=(r+1)*l+(u-1),R=(r+1)*l+u,N=(r+1)*(l-1)+u;c.push(w,b,N),c.push(b,R,N)}function P(t,e,n,i,r){var a=Math.cos(t),o=Math.sin(t),s=n/e*t,u=Math.cos(s);r.x=i*(2+u)*.5*a,r.y=i*(2+u)*o*.5,r.z=i*Math.sin(s)*.5}return s.setIndex(new an(new on(h.length/3>65536?new Uint32Array(c):new Uint16Array(c),1))),s.addAttribute("a_Position",new an(new on(new Float32Array(h),3))),s.addAttribute("a_Normal",new an(new on(new Float32Array(d),3))),s.addAttribute("a_Uv",new an(new on(new Float32Array(f),2))),s.computeBoundingBox(),s.computeBoundingSphere(),s}return i(e,t),e}(fn),lr=function(t){function e(){var e;return(e=t.call(this)||this).type=b.BASIC,e}return i(e,t),e}(vn),cr=function(t){function e(){var e;return(e=t.call(this)||this).type=b.LAMBERT,e.acceptLight=!0,e}return i(e,t),e}(vn),hr=function(t){function e(){var e;return(e=t.call(this)||this).type=b.LINE,e.lineWidth=1,e.drawMode=k.LINES,e}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.lineWidth=e.lineWidth,this},e}(vn),dr=function(t){function e(){var e;return(e=t.call(this)||this).type=b.MATCAP,e.matcap=null,e}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.matcap=e.matcap,this},e}(vn),fr=function(t){function e(){var e;return(e=t.call(this)||this).type=b.PBR2,e.specular=new gt(1118481),e.glossiness=.5,e.specularMap=null,e.glossinessMap=null,e.acceptLight=!0,e}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.specular=e.specular,this.glossiness=e.glossiness,this.specularMap=e.specularMap,this.glossinessMap=e.glossinessMap,this},e}(vn),pr=function(t){function e(){var e;return(e=t.call(this)||this).type=b.PBR,e.roughness=.5,e.metalness=.5,e.roughnessMap=null,e.metalnessMap=null,e.clearcoat=0,e.clearcoatMap=null,e.clearcoatRoughness=0,e.clearcoatRoughnessMap=null,e.clearcoatNormalScale=new pt(1,1),e.clearcoatNormalMap=null,e.acceptLight=!0,e}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.roughness=e.roughness,this.metalness=e.metalness,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this},e}(vn),_r=function(t){function e(){var e;return(e=t.call(this)||this).type=b.PHONG,e.shininess=30,e.specular=new gt(1118481),e.specularMap=null,e.acceptLight=!0,e}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.shininess=e.shininess,this.specular.copy(e.specular),this.specularMap=e.specularMap,this},e}(vn),vr=function(t){function e(){var e;return(e=t.call(this)||this).type=b.POINT,e.size=1,e.sizeAttenuation=!0,e.drawMode=k.POINTS,e}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this},e}(vn),mr=function(t){function e(e,n){var i;return(i=t.call(this)||this).width=e,i.height=n,i}i(e,t);var n=e.prototype;return n.resize=function(t,e){return(this.width!==t||this.height!==e)&&(this.width=t,this.height=e,!0)},n.dispose=function(){this.dispatchEvent({type:"dispose"})},e}(q);mr.prototype.isRenderTarget=!0;var gr=function(t){function e(e,n,i,r){var a;return void 0===i&&(i=O.RGBA8),void 0===r&&(r=0),(a=t.call(this)||this).width=e,a.height=n,a.format=i,a.multipleSampling=r,a}i(e,t);var n=e.prototype;return n.resize=function(t,e){return(this.width!==t||this.height!==e)&&(this.dispose(),this.width=t,this.height=e,!0)},n.clone=function(){return(new this.constructor).copy(this)},n.copy=function(t){return this.format=t.format,this.multipleSampling=t.multipleSampling,this},n.dispose=function(){this.dispatchEvent({type:"dispose"})},e}(q);gr.prototype.isRenderBuffer=!0;var Er=function(t){function e(e,n){var i;return(i=t.call(this,e,n)||this)._attachments={},i.attach(new Pn,W.COLOR_ATTACHMENT0),i.attach(new gr(e,n,O.DEPTH_STENCIL),W.DEPTH_STENCIL_ATTACHMENT),i}i(e,t);var n=e.prototype;return n.attach=function(t,e){void 0===e&&(e=W.COLOR_ATTACHMENT0),t.isTexture?t.image&&t.image.rtt?t.image.width===this.width&&t.image.height===this.height||(t.version++,t.image.width=this.width,t.image.height=this.height):(t.version++,t.image={rtt:!0,data:null,width:this.width,height:this.height}):t.resize(this.width,this.height),this._attachments[e]=t},n.detach=function(t){void 0===t&&(t=W.COLOR_ATTACHMENT0),delete this._attachments[t]},n.resize=function(e,n){var i=t.prototype.resize.call(this,e,n);if(i)for(var r in this.dispose(!1),this._attachments){var a=this._attachments[r];a.isTexture?(a.image={rtt:!0,data:null,width:this.width,height:this.height},a.version++):a.resize(e,n)}return i},n.dispose=function(e){if(void 0===e&&(e=!0),t.prototype.dispose.call(this),e)for(var n in this._attachments)this._attachments[n].dispose()},e}(mr);Er.prototype.isRenderTarget2D=!0,Object.defineProperties(Er.prototype,{texture:{set:function(t){t?t.isTexture&&this.attach(t,W.COLOR_ATTACHMENT0):this.detach(W.COLOR_ATTACHMENT0)},get:function(){var t=this._attachments[W.COLOR_ATTACHMENT0];return t.isTexture?t:null}}});var Sr=function(t){function e(e){var n;return(n=t.call(this,e.width,e.height)||this).view=e,n}i(e,t);var n=e.prototype;return n.resize=function(t,e){this.view.width=t,this.view.height=e,this.width=t,this.height=e},n.dispose=function(){},e}(mr);Sr.prototype.isRenderTargetBack=!0;var Mr=function(t){function e(e,n){var i;return(i=t.call(this,e,n)||this)._attachments={},i.attach(new Ln,W.COLOR_ATTACHMENT0),i.attach(new gr(e,n,O.DEPTH_STENCIL),W.DEPTH_STENCIL_ATTACHMENT),i.activeCubeFace=0,i}i(e,t);var n=e.prototype;return n.attach=function(t,e){if(void 0===e&&(e=W.COLOR_ATTACHMENT0),t.isTexture){for(var n=!1,i=0;i<6;i++)t.images[i]&&t.images[i].rtt?t.images[i].width===this.width&&t.images[i].height===this.height||(t.images[i].width=this.width,t.images[i].height=this.height,n=!0):(t.images[i]={rtt:!0,data:null,width:this.width,height:this.height},n=!0);n&&t.version++}else t.resize(this.width,this.height);this._attachments[e]=t},n.detach=function(t){void 0===t&&(t=W.COLOR_ATTACHMENT0),delete this._attachments[t]},n.resize=function(e,n){if(t.prototype.resize.call(this,e,n))for(var i in this.dispose(!1),this._attachments){var r=this._attachments[i];if(r.isTexture){for(var a=0;a<6;a++)r.images[a]={rtt:!0,data:null,width:this.width,height:this.height};r.version++}else r.resize(e,n)}},n.dispose=function(e){if(void 0===e&&(e=!0),t.prototype.dispose.call(this),e)for(var n in this._attachments)this._attachments[n].dispose()},e}(mr);Mr.prototype.isRenderTargetCube=!0,Object.defineProperties(Mr.prototype,{texture:{set:function(t){t?t.isTexture&&this.attach(t,W.COLOR_ATTACHMENT0):this.detach(W.COLOR_ATTACHMENT0)},get:function(){var t=this._attachments[W.COLOR_ATTACHMENT0];return t.isTexture?t:null}}});var Tr=0,yr=function(t){function e(){var e;return(e=t.call(this)||this).id=Tr++,e}return i(e,t),e.prototype.dispose=function(){this.dispatchEvent({type:"dispose"})},e}(q),xr=new m,Ar=function(){function t(t,e){this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=new Float32Array(16*this.bones.length),this.boneTexture=void 0}var e=t.prototype;return e.pose=function(){for(var t=this.boneInverses,e=0;e=2,i=this.renderTarget;n!==(i._attachments[W.DEPTH_ATTACHMENT]===this.depthMap)&&(n?(e.getExtension("OES_texture_float_linear")&&(this.depthMap.type=F.FLOAT),i.dispose(),i.attach(this.depthMap,W.DEPTH_ATTACHMENT)):(i.dispose(),i.attach(this._depthBuffer,W.DEPTH_ATTACHMENT)))},e}(Nr),Lr=function(t){function e(e,n){var i;return(i=t.call(this,e,n)||this).shadow=new Pr,i}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.shadow.copy(e.shadow),this},e}(wr);Lr.prototype.isDirectionalLight=!0;var Cr=function(t){function e(e,n,i){var r;return(r=t.call(this,e,i)||this).groundColor=new gt(void 0!==n?n:16777215),r}return i(e,t),e.prototype.copy=function(e){t.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor)},e}(wr);Cr.prototype.isHemisphereLight=!0;var Dr=function(t){function e(){var e;(e=t.call(this)||this).renderTarget=new Mr(e.mapSize.x,e.mapSize.y);var n=e.renderTarget.texture;return n.generateMipmaps=!1,n.minFilter=I.LINEAR,e.map=n,e._targets=[new _(1,0,0),new _(-1,0,0),new _(0,1,0),new _(0,-1,0),new _(0,0,1),new _(0,0,-1)],e._ups=[new _(0,-1,0),new _(0,-1,0),new _(0,0,1),new _(0,0,-1),new _(0,-1,0),new _(0,-1,0)],e._lookTarget=new _,e}i(e,t);var n=e.prototype;return n.update=function(t,e){this._updateCamera(t,e),this.mapSize.x===this.renderTarget.width&&this.mapSize.y===this.renderTarget.height||this.renderTarget.resize(this.mapSize.x,this.mapSize.y)},n._updateCamera=function(t,e){var n=this.camera,i=this._lookTarget,r=this._targets,a=this._ups;n.position.setFromMatrixPosition(t.worldMatrix),i.set(r[e].x+n.position.x,r[e].y+n.position.y,r[e].z+n.position.z),n.lookAt(i,a[e]),n.updateMatrix(),n.setPerspective(.5*Math.PI,1,this.cameraNear,this.cameraFar)},e}(Nr),Or=function(t){function e(e,n,i,r){var a;return(a=t.call(this,e,n)||this).decay=void 0!==r?r:1,a.distance=void 0!==i?i:200,a.shadow=new Dr,a}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.shadow.copy(e.shadow),this},e}(wr);Or.prototype.isPointLight=!0;var Fr=function(t){function e(){var e;(e=t.call(this)||this).frustumEdgeFalloff=0,e.renderTarget=new Er(e.mapSize.x,e.mapSize.y);var n=e.renderTarget.texture;n.generateMipmaps=!1,n.minFilter=I.LINEAR;var i=new Pn;i.type=F.UNSIGNED_INT,i.format=O.DEPTH_COMPONENT,i.magFilter=I.LINEAR,i.minFilter=I.LINEAR,i.compare=B.LESS,i.generateMipmaps=!1;var r=new gr(e.mapSize.x,e.mapSize.y,O.DEPTH_COMPONENT16);return e.renderTarget.detach(W.DEPTH_STENCIL_ATTACHMENT),e.renderTarget.attach(r,W.DEPTH_ATTACHMENT),e.map=n,e.depthMap=i,e._depthBuffer=r,e._lookTarget=new _,e._up=new _(0,1,0),e}i(e,t);var n=e.prototype;return n.update=function(t){this._updateCamera(t),this.mapSize.x===this.renderTarget.width&&this.mapSize.y===this.renderTarget.height||this.renderTarget.resize(this.mapSize.x,this.mapSize.y)},n._updateCamera=function(t){var e=this.camera,n=this._lookTarget;t.getWorldDirection(n),e.position.setFromMatrixPosition(t.worldMatrix),n.multiplyScalar(-1).add(e.position),e.lookAt(n,this._up),e.updateMatrix(),e.setPerspective(2*t.angle,1,this.cameraNear,this.cameraFar)},n.copy=function(e){return t.prototype.copy.call(this,e),this.frustumEdgeFalloff=e.frustumEdgeFalloff,this},n.prepareDepthMap=function(t,e){var n=t&&e.version>=2,i=this.renderTarget;n!==(i._attachments[W.DEPTH_ATTACHMENT]===this.depthMap)&&(n?(e.getExtension("OES_texture_float_linear")&&(this.depthMap.type=F.FLOAT),i.dispose(),i.attach(this.depthMap,W.DEPTH_ATTACHMENT)):(i.dispose(),i.attach(this._depthBuffer,W.DEPTH_ATTACHMENT)))},e}(Nr),Ir=function(t){function e(e,n,i,r,a,o){var s;return(s=t.call(this,e,n)||this).decay=void 0!==o?o:1,s.distance=void 0!==i?i:200,s.penumbra=void 0!==a?a:0,s.angle=void 0!==r?r:Math.PI/6,s.shadow=new Fr,s}return i(e,t),e.prototype.copy=function(e){return t.prototype.copy.call(this,e),this.shadow.copy(e.shadow),this},e}(wr);Ir.prototype.isSpotLight=!0;var Ur=function(t){function e(){return t.call(this)||this}return i(e,t),e}(ne);Ur.prototype.isBone=!0;var Br=function(t){function e(e,n){var i;return(i=t.call(this,e,n)||this).skeleton=void 0,i.bindMode="attached",i.bindMatrix=new m,i.bindMatrixInverse=new m,i}i(e,t);var n=e.prototype;return n.bind=function(t,e){this.skeleton=t,void 0===e&&(this.updateMatrix(),e=this.worldMatrix),this.bindMatrix.copy(e),this.bindMatrixInverse.getInverse(e)},n.updateMatrix=function(e){t.prototype.updateMatrix.call(this,e),"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.worldMatrix):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("t3d.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},n.copy=function(e){return t.prototype.copy.call(this,e),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this},e}(tn);Br.prototype.isSkinnedMesh=!0;var Gr=function(t){function e(){return t.call(this)||this}return i(e,t),e}(ne);Gr.prototype.isGroup=!0;_.prototype.applyProjection=function(t){console.error("t3d.Vector3: .applyProjection has been removed. Use .applyMatrix4 instead.")},Object.defineProperties(Ne.prototype,{gammaInput:{get:function(){return console.warn("t3d.Camera: .gammaInput has been removed. Use texture.encoding instead."),!1},set:function(t){console.warn("t3d.Camera: .gammaInput has been removed. Use texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("t3d.Camera: .gammaOutput has been removed. Use .outputEncoding or renderTarget.texture.encoding instead."),this.outputEncoding==H.GAMMA},set:function(t){console.warn("t3d.Camera: .gammaOutput has been removed. Use .outputEncoding or renderTarget.texture.encoding instead."),this.outputEncoding=t?H.GAMMA:H.LINEAR}}}),Object.defineProperties(vn.prototype,{emissiveIntensity:{get:function(){return console.warn("t3d.Material: .emissiveIntensity has been removed. Use material.emissive instead."),!1},set:function(t){console.warn("t3d.Material: .emissiveIntensity has been removed. Use material.emissive instead.")}}}),Object.defineProperties(er.prototype,{textures:{get:function(){return console.warn("WebGLRenderPass: .textures has been deprecated. All methods are moved to WebGLRenderPass."),this._textures}},renderBuffers:{get:function(){return console.warn("WebGLRenderPass: .renderBuffers has been deprecated. All methods are moved to WebGLRenderPass."),this._renderBuffers}},renderTarget:{get:function(){return this._renderTargets}},state:{get:function(){return this._state}},vertexArrayBindings:{get:function(){return console.warn("WebGLRenderPass: .vertexArrayBindings has been deprecated. All methods are moved to WebGLRenderPass."),this._vertexArrayBindings}}}),ki.prototype.resetBinding=function(){console.error("WebGLVertexArrayBindings: .resetBinding() has been removed. Use WebGLRenderPass.resetVertexArrayBindings() instead.")},Hi.prototype.setBufferExternal=function(t,e){console.warn("WebGLGeometries: .setBufferExternal has been removed. Use WebGLRenderPass.setBufferExternal instead."),this._buffers.setBufferExternal(t,e)};var zr={TEXTURE_2D:3553,TEXTURE_CUBE_MAP:34067,TEXTURE_3D:32879};Object.defineProperties(Nn.prototype,{textureType:{get:function(){return console.warn("TextureBase: .textureType has been removed."),""},set:function(t){console.warn("TextureBase: .textureType has been removed.")}}}),Object.defineProperties(Pn,{textureType:{get:function(){return console.warn("Texture2D: .textureType has been removed."),zr.TEXTURE_2D},set:function(t){console.warn("Texture2D: .textureType has been removed.")}}}),Object.defineProperties(Cn,{textureType:{get:function(){return console.warn("Texture3D: .textureType has been removed."),zr.TEXTURE_3D},set:function(t){console.warn("Texture3D: .textureType has been removed.")}}}),Object.defineProperties(Ln,{textureType:{get:function(){return console.warn("TextureCube: .textureType has been removed."),zr.TEXTURE_CUBE_MAP},set:function(t){console.warn("TextureCube: .textureType has been removed.")}}});var Hr={AMBIENT:"ambient",HEMISPHERE:"hemisphere",DIRECT:"direct",POINT:"point",SPOT:"spot"};Object.defineProperties(wr.prototype,{lightType:{get:function(){return console.warn("Light: .lightType has been removed."),""},set:function(t){console.warn("Light: .lightType has been removed.")}}}),Object.defineProperties(Rr.prototype,{lightType:{get:function(){return console.warn("AmbientLight: .lightType has been removed."),Hr.AMBIENT},set:function(t){console.warn("AmbientLight: .lightType has been removed.")}}}),Object.defineProperties(Lr.prototype,{lightType:{get:function(){return console.warn("DirectionalLight: .lightType has been removed."),Hr.DIRECT},set:function(t){console.warn("DirectionalLight: .lightType has been removed.")}}}),Object.defineProperties(Cr.prototype,{lightType:{get:function(){return console.warn("HemisphereLight: .lightType has been removed."),Hr.HEMISPHERE},set:function(t){console.warn("HemisphereLight: .lightType has been removed.")}}}),Object.defineProperties(Or.prototype,{lightType:{get:function(){return console.warn("PointLight: .lightType has been removed."),Hr.POINT},set:function(t){console.warn("PointLight: .lightType has been removed.")}}}),Object.defineProperties(Ir.prototype,{lightType:{get:function(){return console.warn("SpotLight: .lightType has been removed."),Hr.SPOT},set:function(t){console.warn("SpotLight: .lightType has been removed.")}}});var Vr={MESH:"mesh",SKINNED_MESH:"skinned_mesh",LIGHT:"light",CAMERA:"camera",SCENE:"scene",GROUP:"group"};Object.defineProperties(tn.prototype,{type:{get:function(){return console.warn("Mesh: .type has been removed, use .isMesh instead."),Vr.MESH},set:function(t){console.warn("Mesh: .type has been removed.")}}}),Object.defineProperties(Br.prototype,{type:{get:function(){return console.warn("SkinnedMesh: .type has been removed, use .isSkinnedMesh instead."),Vr.SKINNED_MESH},set:function(t){console.warn("SkinnedMesh: .type has been removed.")}}}),Object.defineProperties(wr.prototype,{type:{get:function(){return console.warn("Light: .type has been removed, use .isLight instead."),Vr.LIGHT},set:function(t){console.warn("Light: .type has been removed.")}}}),Object.defineProperties(Ne.prototype,{type:{get:function(){return console.warn("Camera: .type has been removed, use .isCamera instead."),Vr.CAMERA},set:function(t){console.warn("Camera: .type has been removed.")}}}),Object.defineProperties(Re.prototype,{type:{get:function(){return console.warn("Scene: .type has been removed, use .isScene instead."),Vr.SCENE},set:function(t){console.warn("Scene: .type has been removed.")}}}),Object.defineProperties(Gr.prototype,{type:{get:function(){return console.warn("Group: .type has been removed, use .isGroup instead."),Vr.GROUP},set:function(t){console.warn("Group: .type has been removed.")}}});var kr={NORMAL:"normal",EXP2:"exp2"};Object.defineProperties(ir.prototype,{fogType:{get:function(){return console.warn("Fog: .fogType has been removed, use .isFog instead."),kr.NORMAL},set:function(t){console.warn("Fog: .fogType has been removed.")}}}),Object.defineProperties(rr.prototype,{fogType:{get:function(){return console.warn("FogExp2: .fogType has been removed, use .isFogExp2 instead."),kr.EXP2},set:function(t){console.warn("FogExp2: .fogType has been removed.")}}}),Pn.fromImage=function(t){console.warn("Texture2D.fromImage has been removed.");var e=new Pn;return e.image=t,e.version++,e},Pn.fromSrc=function(t){console.warn("Texture2D.fromSrc has been removed, use Texture2DLoader(jsm) instead.");var e=new Pn;return(new ft).load(t,(function(t){e.image=t,e.version++,e.dispatchEvent({type:"onload"})})),e},Ln.fromImage=function(t){console.warn("TextureCube.fromImage has been removed.");for(var e=new Ln,n=e.images,i=0;i<6;i++)n[i]=t[i];return e.version++,e},Ln.fromSrc=function(t){console.warn("TextureCube.fromSrc has been removed, use TextureCubeLoader(jsm) instead.");var e=new Ln,n=e.images,i=new ft,r=0;return function a(o){if(o&&(n.push(o),r++),r>=6)return e.version++,void e.dispatchEvent({type:"onload"});i.load(t[r],a)}(),e},t.ATTACHMENT=W,t.AmbientLight=Rr,t.AnimationAction=Q,t.AnimationMixer=ot,t.Attribute=an,t.BLEND_EQUATION=N,t.BLEND_FACTOR=P,t.BLEND_TYPE=R,t.BUFFER_USAGE=j,t.BasicMaterial=lr,t.Bone=Ur,t.BooleanKeyframeTrack=d,t.Box2=_t,t.Box3=mt,t.BoxGeometry=ar,t.Buffer=on,t.COMPARE_FUNC=B,t.CULL_FACE_TYPE=L,t.Camera=Ne,t.Color3=gt,t.ColorKeyframeTrack=f,t.CubeGeometry=ar,t.CylinderGeometry=or,t.DRAW_MODE=k,t.DRAW_SIDE=C,t.DefaultLoadingManager=lt,t.DepthMaterial=En,t.DirectionalLight=Lr,t.DirectionalLightShadow=Pr,t.DistanceMaterial=Sn,t.ENVMAP_COMBINE_TYPE=V,t.EnvironmentMapPass=function(){console.error("EnvironmentMapPass has been removed, use ReflectionProbe(jsm) instead.")},t.Euler=Tt,t.EventDispatcher=q,t.FOG_TYPE=kr,t.FileLoader=ht,t.Fog=ir,t.FogExp2=rr,t.Frustum=Nt,t.Geometry=fn,t.Group=Gr,t.HemisphereLight=Cr,t.ImageLoader=ft,t.KeyframeClip=st,t.KeyframeTrack=h,t.LIGHT_TYPE=Hr,t.LambertMaterial=cr,t.Light=wr,t.LightData=ue,t.LightShadow=Nr,t.LineMaterial=hr,t.Loader=ct,t.LoadingManager=ut,t.MATERIAL_TYPE=b,t.MatcapMaterial=dr,t.Material=vn,t.Matrix3=xt,t.Matrix4=m,t.Mesh=tn,t.NumberKeyframeTrack=p,t.OBJECT_TYPE=Vr,t.OPERATION=G,t.Object3D=ne,t.PBR2Material=fr,t.PBRMaterial=pr,t.PIXEL_FORMAT=O,t.PIXEL_TYPE=F,t.PhongMaterial=_r,t.Plane=bt,t.PlaneGeometry=pn,t.PointLight=Or,t.PointLightShadow=Dr,t.PointsMaterial=vr,t.PropertyBindingMixer=Z,t.QUERY_TYPE=Y,t.Quaternion=y,t.QuaternionKeyframeTrack=x,t.Query=yr,t.Ray=Ft,t.RenderBuffer=gr,t.RenderInfo=function(){var t={calls:0,triangles:0,lines:0,points:0},e=[function(e,n){t.points+=e*n},function(e,n){t.lines+=e*(n/2)},function(e,n){t.lines+=e*n},function(e,n){t.lines+=e*(n-1)},function(e,n){t.triangles+=e*(n/3)},function(e,n){t.triangles+=e*(n-2)},function(e,n){t.triangles+=e*(n-2)}];this.update=function(n,i,r){t.calls++,e[i](r,n)},this.reset=function(){t.calls=0,t.triangles=0,t.lines=0,t.points=0},this.render=t},t.RenderQueue=Ee,t.RenderQueueLayer=ge,t.RenderStates=be,t.RenderTarget2D=Er,t.RenderTargetBack=Sr,t.RenderTargetBase=mr,t.RenderTargetCube=Mr,t.Renderer=nr,t.SHADING_TYPE=D,t.SHADOW_TYPE=z,t.Scene=Re,t.SceneData=Ae,t.ShaderChunk=ni,t.ShaderLib=ri,t.ShaderMaterial=mn,t.ShaderPostPass=gn,t.ShadowMapPass=Mn,t.Skeleton=Ar,t.SkinnedMesh=Br,t.Sphere=Bt,t.SphereGeometry=sr,t.Spherical=Gt,t.SpotLight=Ir,t.SpotLightShadow=Fr,t.StringKeyframeTrack=A,t.TEXEL_ENCODING_TYPE=H,t.TEXTURE_FILTER=I,t.TEXTURE_WRAP=U,t.Texture2D=Pn,t.Texture3D=Cn,t.TextureBase=Nn,t.TextureCube=Ln,t.TorusKnotGeometry=ur,t.Triangle=Xt,t.VERTEX_COLOR=X,t.Vector2=pt,t.Vector3=_,t.Vector4=Wt,t.VectorKeyframeTrack=w,t.WEBGL_COMPARE_FUNC=B,t.WEBGL_OP=G,t.WEBGL_PIXEL_FORMAT=O,t.WEBGL_PIXEL_TYPE=F,t.WEBGL_TEXTURE_FILTER=I,t.WEBGL_TEXTURE_TYPE=zr,t.WEBGL_TEXTURE_WRAP=U,t.WebGLAttribute=Kn,t.WebGLCapabilities=mi,t.WebGLGeometries=Hi,t.WebGLProgram=$n,t.WebGLPrograms=ai,t.WebGLProperties=Ai,t.WebGLQueries=Xi,t.WebGLRenderBuffers=Fi,t.WebGLRenderPass=er,t.WebGLState=xi,t.WebGLTextures=wi,t.WebGLUniforms=Zn,t.cloneJson=$t,t.cloneUniforms=Jt,t.generateUUID=qt,t.isPowerOfTwo=Qt,t.nearestPowerOfTwo=Zt,t.nextPowerOfTwo=Kt})); diff --git a/build/t3d.module.js b/build/t3d.module.js index 25294ce..3c2dff5 100644 --- a/build/t3d.module.js +++ b/build/t3d.module.js @@ -10776,7 +10776,7 @@ var begin_frag = "vec4 outColor = vec4(u_Color, u_Opacity);"; var begin_vert = "vec3 transformed = vec3(a_Position);\nvec3 objectNormal = vec3(a_Normal);\n#ifdef USE_TANGENT\n vec3 objectTangent = vec3(a_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}\nvec3 BRDF_Diffuse_Lambert(vec3 diffuseColor) {\n return 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 D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nvec3 BRDF_Specular_BlinnPhong(vec3 specularColor, vec3 N, vec3 L, vec3 V, float shininess) {\n vec3 H = normalize(L + V);\n float dotNH = saturate(dot(N, H));\n float dotLH = saturate(dot(L, H));\n vec3 F = F_Schlick(specularColor, dotLH);\n float G = G_BlinnPhong_Implicit( );\n float D = D_BlinnPhong(shininess, dotNH);\n return F * G * D;\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}\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}\nvec3 BRDF_Specular_GGX(vec3 specularColor, vec3 N, vec3 L, vec3 V, float roughness) {\n\tfloat alpha = pow2( roughness );\n\tvec3 H = normalize(L + V);\n\tfloat dotNL = saturate( dot(N, L) );\n\tfloat dotNV = saturate( dot(N, V) );\n\tfloat dotNH = saturate( dot(N, H) );\n\tfloat dotLH = saturate( dot(L, H) );\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}\nvec3 BRDF_Specular_GGX_Environment(const in vec3 N, const in vec3 V, const in vec3 specularColor, const in float roughness) {\n\tfloat dotNV = saturate(dot(N, V));\n\tvec2 brdf = integrateSpecularBRDF(dotNV, roughness);\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment(const in vec3 N, const in vec3 V, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter) {\n\tfloat dotNV = saturate(dot(N, V));\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 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}\nvec3 BRDF_Diffuse_Lambert(vec3 diffuseColor) {\n return 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 D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nvec3 BRDF_Specular_BlinnPhong(vec3 specularColor, vec3 N, vec3 L, vec3 V, float shininess) {\n vec3 H = normalize(L + V);\n float dotNH = saturate(dot(N, H));\n float dotLH = saturate(dot(L, H));\n vec3 F = F_Schlick(specularColor, dotLH);\n float G = G_BlinnPhong_Implicit( );\n float D = D_BlinnPhong(shininess, dotNH);\n return F * G * D;\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}\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}\nvec3 BRDF_Specular_GGX(vec3 specularColor, vec3 N, vec3 L, vec3 V, float roughness) {\n\tfloat alpha = pow2( roughness );\n\tvec3 H = normalize(L + V);\n\tfloat dotNL = saturate( dot(N, L) );\n\tfloat dotNV = saturate( dot(N, V) );\n\tfloat dotNH = saturate( dot(N, H) );\n\tfloat dotLH = saturate( dot(L, H) );\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}\nvec3 BRDF_Specular_GGX_Environment(const in vec3 N, const in vec3 V, const in vec3 specularColor, const in float roughness) {\n\tfloat dotNV = saturate(dot(N, V));\n\tvec2 brdf = integrateSpecularBRDF(dotNV, roughness);\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment(const in vec3 N, const in vec3 V, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter) {\n\tfloat dotNV = saturate(dot(N, V));\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 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}\nfloat getAARoughnessFactor(vec3 normal) {\n\tvec3 dxy = max( abs(dFdx(normal)), abs(dFdy(normal)) );\n\treturn 0.04 + max( max(dxy.x, dxy.y), dxy.z );\n}"; var bumpMap_pars_frag = "#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd(vec2 uv) {\n\t\tvec2 dSTdx = dFdx( uv );\n\t\tvec2 dSTdy = dFdy( uv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, uv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, uv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, uv + 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"; @@ -10828,7 +10828,7 @@ var fog_pars_frag = "#ifdef USE_FOG\n uniform vec3 u_FogColor;\n #ifdef US var inverse = "mat4 inverseMat4(mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n}"; -var light_frag = "\n#if (defined(USE_PHONG) || defined(USE_PBR))\n vec3 V = normalize(u_CameraPosition - v_modelPos);\n#endif\n#ifdef USE_PBR\n #ifdef USE_PBR2\n vec3 diffuseColor = outColor.xyz;\n vec3 specularColor = specularFactor.xyz;\n float roughness = max(1.0 - glossinessFactor, 0.0525);\n #else\n vec3 diffuseColor = outColor.xyz * (1.0 - metalnessFactor);\n vec3 specularColor = mix(vec3(0.04), outColor.xyz, metalnessFactor);\n float roughness = max(roughnessFactor, 0.0525);\n #endif\n vec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\n float geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);\n roughness += geometryRoughness;\n roughness = min(roughness, 1.0);\n #ifdef USE_CLEARCOAT\n float clearcoat = u_Clearcoat;\n float clearcoatRoughness = u_ClearcoatRoughness;\n #ifdef USE_CLEARCOATMAP\n\t\t clearcoat *= texture2D(clearcoatMap, v_Uv).x;\n #endif\n #ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\t clearcoatRoughness *= texture2D(clearcoatRoughnessMap, v_Uv).y;\n\t #endif\n clearcoat = saturate(clearcoat);\n clearcoatRoughness = max(clearcoatRoughness, 0.0525);\n\t clearcoatRoughness += geometryRoughness;\n\t clearcoatRoughness = min(clearcoatRoughness, 1.0);\n #endif\n#else\n vec3 diffuseColor = outColor.xyz;\n #ifdef USE_PHONG\n vec3 specularColor = u_SpecularColor.xyz;\n float shininess = u_Specular;\n #endif\n#endif\n#ifdef USE_LIGHT\n vec3 L;\n float falloff;\n float dotNL;\n vec3 irradiance;\n float clearcoatDHR;\n #ifdef USE_CLEARCOAT\n float ccDotNL;\n vec3 ccIrradiance;\n #endif\n #if NUM_DIR_LIGHTS > 0\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_DIR_LIGHTS; i++) {\n L = normalize(-u_Directional[i].direction);\n falloff = 1.0;\n #if defined(USE_SHADOW) && (UNROLLED_LOOP_INDEX < NUM_DIR_SHADOWS)\n #ifdef USE_PCSS_SOFT_SHADOW\n falloff *= getShadowWithPCSS(directionalDepthMap[i], directionalShadowMap[i], vDirectionalShadowCoord[i], u_DirectionalShadow[i].shadowMapSize, u_DirectionalShadow[i].shadowBias, u_DirectionalShadow[i].shadowParams);\n #else\n falloff *= getShadow(directionalShadowMap[i], vDirectionalShadowCoord[i], u_DirectionalShadow[i].shadowMapSize, u_DirectionalShadow[i].shadowBias, u_DirectionalShadow[i].shadowParams);\n #endif\n #endif\n dotNL = saturate(dot(N, L));\n irradiance = u_Directional[i].color * falloff * dotNL * PI;\n #ifdef USE_CLEARCOAT \n ccDotNL = saturate(dot(clearcoatNormal, L));\n ccIrradiance = ccDotNL * u_Directional[i].color * falloff * PI;\n clearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n reflectedLight.directSpecular += ccIrradiance * clearcoat * BRDF_Specular_GGX(specularColor, clearcoatNormal, L, V, clearcoatRoughness);\n #else\n\t\t clearcoatDHR = 0.0;\n\t #endif\n reflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance * BRDF_Diffuse_Lambert(diffuseColor);\n #ifdef USE_PHONG\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\n #endif\n #ifdef USE_PBR\n reflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness);\n #endif\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHTS > 0\n vec3 worldV;\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_POINT_LIGHTS; i++) {\n worldV = v_modelPos - u_Point[i].position;\n L = -worldV;\n falloff = pow(clamp(1. - length(L) / u_Point[i].distance, 0.0, 1.0), u_Point[i].decay);\n L = normalize(L);\n #if defined(USE_SHADOW) && (UNROLLED_LOOP_INDEX < NUM_POINT_SHADOWS)\n falloff *= getPointShadow(pointShadowMap[i], vPointShadowCoord[i], u_PointShadow[i].shadowMapSize, u_PointShadow[i].shadowBias, u_PointShadow[i].shadowParams, u_PointShadow[i].shadowCameraRange);\n #endif\n dotNL = saturate(dot(N, L));\n irradiance = u_Point[i].color * falloff * dotNL * PI;\n #ifdef USE_CLEARCOAT \n ccDotNL = saturate(dot(clearcoatNormal, L));\n ccIrradiance = ccDotNL * u_Point[i].color * falloff * PI;\n clearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n reflectedLight.directSpecular += ccIrradiance * clearcoat * BRDF_Specular_GGX(specularColor, clearcoatNormal, L, V, clearcoatRoughness);\n #else\n\t\t clearcoatDHR = 0.0;\n\t #endif\n reflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance * BRDF_Diffuse_Lambert(diffuseColor);\n #ifdef USE_PHONG\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\n #endif\n #ifdef USE_PBR\n reflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness);\n #endif\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHTS > 0\n float lightDistance;\n float angleCos;\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\n L = u_Spot[i].position - v_modelPos;\n lightDistance = length(L);\n L = normalize(L);\n angleCos = dot(L, -normalize(u_Spot[i].direction));\n falloff = smoothstep(u_Spot[i].coneCos, u_Spot[i].penumbraCos, angleCos);\n falloff *= pow(clamp(1. - lightDistance / u_Spot[i].distance, 0.0, 1.0), u_Spot[i].decay);\n #if defined(USE_SHADOW) && (UNROLLED_LOOP_INDEX < NUM_SPOT_SHADOWS)\n #ifdef USE_PCSS_SOFT_SHADOW\n falloff *= getShadowWithPCSS(spotDepthMap[i], spotShadowMap[i], vSpotShadowCoord[i], u_SpotShadow[i].shadowMapSize, u_SpotShadow[i].shadowBias, u_SpotShadow[i].shadowParams);\n #else\n falloff *= getShadow(spotShadowMap[i], vSpotShadowCoord[i], u_SpotShadow[i].shadowMapSize, u_SpotShadow[i].shadowBias, u_SpotShadow[i].shadowParams);\n #endif\n #endif\n dotNL = saturate(dot(N, L));\n irradiance = u_Spot[i].color * falloff * dotNL * PI;\n #ifdef USE_CLEARCOAT \n ccDotNL = saturate(dot(clearcoatNormal, L));\n ccIrradiance = ccDotNL * u_Spot[i].color * falloff * PI;\n clearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n reflectedLight.directSpecular += ccIrradiance * clearcoat * BRDF_Specular_GGX(specularColor, clearcoatNormal, L, V, clearcoatRoughness);\n #else\n\t\t clearcoatDHR = 0.0;\n\t #endif\n reflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance * BRDF_Diffuse_Lambert(diffuseColor);\n #ifdef USE_PHONG\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\n #endif\n #ifdef USE_PBR\n reflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness);\n #endif\n }\n #pragma unroll_loop_end\n #endif\n vec3 iblIrradiance = vec3(0., 0., 0.);\n vec3 indirectIrradiance = vec3(0., 0., 0.);\n vec3 indirectRadiance = vec3(0., 0., 0.);\n vec3 clearcoatRadiance = vec3(0., 0., 0.);\n #ifdef USE_AMBIENT_LIGHT\n indirectIrradiance += u_AmbientLightColor * PI;\n #endif\n #if NUM_HEMI_LIGHTS > 0\n float hemiDiffuseWeight;\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_HEMI_LIGHTS; i++) {\n L = normalize(u_Hemi[i].direction);\n dotNL = dot(N, L);\n hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n indirectIrradiance += mix(u_Hemi[i].groundColor, u_Hemi[i].skyColor, hemiDiffuseWeight) * PI;\n }\n #pragma unroll_loop_end\n #endif\n #if defined(USE_ENV_MAP) && defined(USE_PBR)\n vec3 envDir;\n #ifdef USE_VERTEX_ENVDIR\n envDir = v_EnvDir;\n #else\n envDir = reflect(normalize(v_modelPos - u_CameraPosition), N);\n #endif\n iblIrradiance += getLightProbeIndirectIrradiance(maxMipLevel, N);\n indirectRadiance += getLightProbeIndirectRadiance(GGXRoughnessToBlinnExponent(roughness), maxMipLevel, envDir);\n #ifdef USE_CLEARCOAT\n vec3 clearcoatDir = reflect(normalize(v_modelPos - u_CameraPosition), clearcoatNormal);\n\t\t clearcoatRadiance += getLightProbeIndirectRadiance(GGXRoughnessToBlinnExponent(clearcoatRoughness), maxMipLevel, clearcoatDir);\n\t #endif\n #endif\n reflectedLight.indirectDiffuse += indirectIrradiance * BRDF_Diffuse_Lambert(diffuseColor);\n #if defined(USE_ENV_MAP) && defined(USE_PBR)\n #ifdef USE_CLEARCOAT\n float ccDotNV = saturate(dot(clearcoatNormal, V));\n reflectedLight.indirectSpecular += clearcoatRadiance * clearcoat * BRDF_Specular_GGX_Environment(clearcoatNormal, V, specularColor, clearcoatRoughness);\n ccDotNL = ccDotNV;\n clearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n #else\n clearcoatDHR = 0.0;\n #endif\n float clearcoatInv = 1.0 - clearcoatDHR;\n vec3 singleScattering = vec3(0.0);\n\t vec3 multiScattering = vec3(0.0);\n vec3 cosineWeightedIrradiance = iblIrradiance * RECIPROCAL_PI;\n BRDF_Specular_Multiscattering_Environment(N, V, specularColor, roughness, singleScattering, multiScattering);\n vec3 diffuse = diffuseColor * (1.0 - (singleScattering + multiScattering));\n reflectedLight.indirectSpecular += clearcoatInv * indirectRadiance * singleScattering;\n reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n #endif\n#endif"; +var light_frag = "\n#if (defined(USE_PHONG) || defined(USE_PBR))\n vec3 V = normalize(u_CameraPosition - v_modelPos);\n#endif\n#ifdef USE_PBR\n #ifdef USE_PBR2\n vec3 diffuseColor = outColor.xyz;\n vec3 specularColor = specularFactor.xyz;\n float roughness = max(1.0 - glossinessFactor, 0.0525);\n #else\n vec3 diffuseColor = outColor.xyz * (1.0 - metalnessFactor);\n vec3 specularColor = mix(vec3(0.04), outColor.xyz, metalnessFactor);\n float roughness = max(roughnessFactor, 0.0525);\n #endif\n roughness = min(max(roughness, getAARoughnessFactor(N)), 1.0);\n #ifdef USE_CLEARCOAT\n float clearcoat = u_Clearcoat;\n float clearcoatRoughness = u_ClearcoatRoughness;\n #ifdef USE_CLEARCOATMAP\n\t\t clearcoat *= texture2D(clearcoatMap, v_Uv).x;\n #endif\n #ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\t clearcoatRoughness *= texture2D(clearcoatRoughnessMap, v_Uv).y;\n\t #endif\n clearcoat = saturate(clearcoat);\n clearcoatRoughness = max(clearcoatRoughness, 0.0525);\n\t clearcoatRoughness = min(max(clearcoatRoughness, getAARoughnessFactor(geometryNormal)), 1.0);\n #endif\n#else\n vec3 diffuseColor = outColor.xyz;\n #ifdef USE_PHONG\n vec3 specularColor = u_SpecularColor.xyz;\n float shininess = u_Specular;\n #endif\n#endif\n#ifdef USE_LIGHT\n vec3 L;\n float falloff;\n float dotNL;\n vec3 irradiance;\n float clearcoatDHR;\n #ifdef USE_CLEARCOAT\n float ccDotNL;\n vec3 ccIrradiance;\n #endif\n #if NUM_DIR_LIGHTS > 0\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_DIR_LIGHTS; i++) {\n L = normalize(-u_Directional[i].direction);\n falloff = 1.0;\n #if defined(USE_SHADOW) && (UNROLLED_LOOP_INDEX < NUM_DIR_SHADOWS)\n #ifdef USE_PCSS_SOFT_SHADOW\n falloff *= getShadowWithPCSS(directionalDepthMap[i], directionalShadowMap[i], vDirectionalShadowCoord[i], u_DirectionalShadow[i].shadowMapSize, u_DirectionalShadow[i].shadowBias, u_DirectionalShadow[i].shadowParams);\n #else\n falloff *= getShadow(directionalShadowMap[i], vDirectionalShadowCoord[i], u_DirectionalShadow[i].shadowMapSize, u_DirectionalShadow[i].shadowBias, u_DirectionalShadow[i].shadowParams);\n #endif\n #endif\n dotNL = saturate(dot(N, L));\n irradiance = u_Directional[i].color * falloff * dotNL * PI;\n #ifdef USE_CLEARCOAT \n ccDotNL = saturate(dot(clearcoatNormal, L));\n ccIrradiance = ccDotNL * u_Directional[i].color * falloff * PI;\n clearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n reflectedLight.directSpecular += ccIrradiance * clearcoat * BRDF_Specular_GGX(specularColor, clearcoatNormal, L, V, clearcoatRoughness);\n #else\n\t\t clearcoatDHR = 0.0;\n\t #endif\n reflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance * BRDF_Diffuse_Lambert(diffuseColor);\n #ifdef USE_PHONG\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\n #endif\n #ifdef USE_PBR\n reflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness);\n #endif\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHTS > 0\n vec3 worldV;\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_POINT_LIGHTS; i++) {\n worldV = v_modelPos - u_Point[i].position;\n L = -worldV;\n falloff = pow(clamp(1. - length(L) / u_Point[i].distance, 0.0, 1.0), u_Point[i].decay);\n L = normalize(L);\n #if defined(USE_SHADOW) && (UNROLLED_LOOP_INDEX < NUM_POINT_SHADOWS)\n falloff *= getPointShadow(pointShadowMap[i], vPointShadowCoord[i], u_PointShadow[i].shadowMapSize, u_PointShadow[i].shadowBias, u_PointShadow[i].shadowParams, u_PointShadow[i].shadowCameraRange);\n #endif\n dotNL = saturate(dot(N, L));\n irradiance = u_Point[i].color * falloff * dotNL * PI;\n #ifdef USE_CLEARCOAT \n ccDotNL = saturate(dot(clearcoatNormal, L));\n ccIrradiance = ccDotNL * u_Point[i].color * falloff * PI;\n clearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n reflectedLight.directSpecular += ccIrradiance * clearcoat * BRDF_Specular_GGX(specularColor, clearcoatNormal, L, V, clearcoatRoughness);\n #else\n\t\t clearcoatDHR = 0.0;\n\t #endif\n reflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance * BRDF_Diffuse_Lambert(diffuseColor);\n #ifdef USE_PHONG\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\n #endif\n #ifdef USE_PBR\n reflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness);\n #endif\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHTS > 0\n float lightDistance;\n float angleCos;\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\n L = u_Spot[i].position - v_modelPos;\n lightDistance = length(L);\n L = normalize(L);\n angleCos = dot(L, -normalize(u_Spot[i].direction));\n falloff = smoothstep(u_Spot[i].coneCos, u_Spot[i].penumbraCos, angleCos);\n falloff *= pow(clamp(1. - lightDistance / u_Spot[i].distance, 0.0, 1.0), u_Spot[i].decay);\n #if defined(USE_SHADOW) && (UNROLLED_LOOP_INDEX < NUM_SPOT_SHADOWS)\n #ifdef USE_PCSS_SOFT_SHADOW\n falloff *= getShadowWithPCSS(spotDepthMap[i], spotShadowMap[i], vSpotShadowCoord[i], u_SpotShadow[i].shadowMapSize, u_SpotShadow[i].shadowBias, u_SpotShadow[i].shadowParams);\n #else\n falloff *= getShadow(spotShadowMap[i], vSpotShadowCoord[i], u_SpotShadow[i].shadowMapSize, u_SpotShadow[i].shadowBias, u_SpotShadow[i].shadowParams);\n #endif\n #endif\n dotNL = saturate(dot(N, L));\n irradiance = u_Spot[i].color * falloff * dotNL * PI;\n #ifdef USE_CLEARCOAT \n ccDotNL = saturate(dot(clearcoatNormal, L));\n ccIrradiance = ccDotNL * u_Spot[i].color * falloff * PI;\n clearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n reflectedLight.directSpecular += ccIrradiance * clearcoat * BRDF_Specular_GGX(specularColor, clearcoatNormal, L, V, clearcoatRoughness);\n #else\n\t\t clearcoatDHR = 0.0;\n\t #endif\n reflectedLight.directDiffuse += (1.0 - clearcoatDHR) * irradiance * BRDF_Diffuse_Lambert(diffuseColor);\n #ifdef USE_PHONG\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong(specularColor, N, L, V, shininess) * specularStrength;\n #endif\n #ifdef USE_PBR\n reflectedLight.directSpecular += (1.0 - clearcoatDHR) * irradiance * BRDF_Specular_GGX(specularColor, N, L, V, roughness);\n #endif\n }\n #pragma unroll_loop_end\n #endif\n vec3 iblIrradiance = vec3(0., 0., 0.);\n vec3 indirectIrradiance = vec3(0., 0., 0.);\n vec3 indirectRadiance = vec3(0., 0., 0.);\n vec3 clearcoatRadiance = vec3(0., 0., 0.);\n #ifdef USE_AMBIENT_LIGHT\n indirectIrradiance += u_AmbientLightColor * PI;\n #endif\n #if NUM_HEMI_LIGHTS > 0\n float hemiDiffuseWeight;\n #pragma unroll_loop_start\n for (int i = 0; i < NUM_HEMI_LIGHTS; i++) {\n L = normalize(u_Hemi[i].direction);\n dotNL = dot(N, L);\n hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n indirectIrradiance += mix(u_Hemi[i].groundColor, u_Hemi[i].skyColor, hemiDiffuseWeight) * PI;\n }\n #pragma unroll_loop_end\n #endif\n #if defined(USE_ENV_MAP) && defined(USE_PBR)\n vec3 envDir;\n #ifdef USE_VERTEX_ENVDIR\n envDir = v_EnvDir;\n #else\n envDir = reflect(normalize(v_modelPos - u_CameraPosition), N);\n #endif\n iblIrradiance += getLightProbeIndirectIrradiance(maxMipLevel, N);\n indirectRadiance += getLightProbeIndirectRadiance(GGXRoughnessToBlinnExponent(roughness), maxMipLevel, envDir);\n #ifdef USE_CLEARCOAT\n vec3 clearcoatDir = reflect(normalize(v_modelPos - u_CameraPosition), clearcoatNormal);\n\t\t clearcoatRadiance += getLightProbeIndirectRadiance(GGXRoughnessToBlinnExponent(clearcoatRoughness), maxMipLevel, clearcoatDir);\n\t #endif\n #endif\n reflectedLight.indirectDiffuse += indirectIrradiance * BRDF_Diffuse_Lambert(diffuseColor);\n #if defined(USE_ENV_MAP) && defined(USE_PBR)\n #ifdef USE_CLEARCOAT\n float ccDotNV = saturate(dot(clearcoatNormal, V));\n reflectedLight.indirectSpecular += clearcoatRadiance * clearcoat * BRDF_Specular_GGX_Environment(clearcoatNormal, V, specularColor, clearcoatRoughness);\n ccDotNL = ccDotNV;\n clearcoatDHR = clearcoat * clearcoatDHRApprox(clearcoatRoughness, ccDotNL);\n #else\n clearcoatDHR = 0.0;\n #endif\n float clearcoatInv = 1.0 - clearcoatDHR;\n vec3 singleScattering = vec3(0.0);\n\t vec3 multiScattering = vec3(0.0);\n vec3 cosineWeightedIrradiance = iblIrradiance * RECIPROCAL_PI;\n BRDF_Specular_Multiscattering_Environment(N, V, specularColor, roughness, singleScattering, multiScattering);\n vec3 diffuse = diffuseColor * (1.0 - (singleScattering + multiScattering));\n reflectedLight.indirectSpecular += clearcoatInv * indirectRadiance * singleScattering;\n reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n #endif\n#endif"; var light_pars_frag = "#ifdef USE_AMBIENT_LIGHT\n uniform vec3 u_AmbientLightColor;\n#endif\n#ifdef USE_CLEARCOAT\n float clearcoatDHRApprox(const in float roughness, const in float dotNL) {\n return 0.04 + (1.0 - 0.16) * (pow(1.0 - dotNL, 5.0) * pow(1.0 - roughness, 2.0));\n }\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n\t\tvec3 groundColor;\n };\n uniform HemisphereLight u_Hemi[NUM_HEMI_LIGHTS];\n#endif\n#if NUM_DIR_LIGHTS > 0\n struct DirectLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectLight u_Directional[NUM_DIR_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 u_Point[NUM_POINT_LIGHTS];\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n vec3 direction;\n };\n uniform SpotLight u_Spot[NUM_SPOT_LIGHTS];\n#endif\n#if defined(USE_PBR) && defined(USE_ENV_MAP)\n vec3 getLightProbeIndirectIrradiance(const in int maxMIPLevel, const in vec3 N) {\n vec3 coordVec = vec3(u_EnvMap_Flip * N.x, N.yz);\n \t#ifdef TEXTURE_LOD_EXT\n \t\tvec4 envMapColor = textureCubeLodEXT(envMap, coordVec, float(maxMIPLevel));\n \t#else\n \t\tvec4 envMapColor = textureCube(envMap, coordVec, float(maxMIPLevel));\n \t#endif\n envMapColor = envMapTexelToLinear(envMapColor);\n return PI * envMapColor.rgb * u_EnvMap_Intensity * u_EnvMapLight_Intensity;\n }\n float getSpecularMIPLevel(const in float blinnShininessExponent, const in int maxMIPLevel) {\n \tfloat maxMIPLevelScalar = float(maxMIPLevel);\n \tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2(pow2(blinnShininessExponent) + 1.0);\n \treturn clamp(desiredMIPLevel, 0.0, maxMIPLevelScalar);\n }\n vec3 getLightProbeIndirectRadiance(const in float blinnShininessExponent, const in int maxMIPLevel, const in vec3 envDir) {\n float specularMIPLevel = getSpecularMIPLevel(blinnShininessExponent, maxMIPLevel);\n vec3 coordVec = vec3(u_EnvMap_Flip * envDir.x, envDir.yz);\n #ifdef TEXTURE_LOD_EXT\n \t\tvec4 envMapColor = textureCubeLodEXT(envMap, coordVec, specularMIPLevel);\n \t#else\n \t\tvec4 envMapColor = textureCube(envMap, coordVec, specularMIPLevel);\n \t#endif\n envMapColor = envMapTexelToLinear(envMapColor);\n return envMapColor.rgb * u_EnvMap_Intensity;\n }\n float 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 }\n#endif"; diff --git a/examples/files.json b/examples/files.json index 0ba3e56..5198127 100644 --- a/examples/files.json +++ b/examples/files.json @@ -74,7 +74,8 @@ "material_vertexcolors", "material_alphamask", "material_clippingplanes", - "material_clearcoat" + "material_clearcoat", + "material_specularAA" ], "camera": [ "camera_cameras", diff --git a/examples/material_specularAA.html b/examples/material_specularAA.html new file mode 100644 index 0000000..ddd5fdd --- /dev/null +++ b/examples/material_specularAA.html @@ -0,0 +1,134 @@ + + + + + + t3d - specular AA + + + + +
+ t3d - specular AA +
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/resources/models/gltf/colt-type_revolver/license.txt b/examples/resources/models/gltf/colt-type_revolver/license.txt new file mode 100644 index 0000000..40af51c --- /dev/null +++ b/examples/resources/models/gltf/colt-type_revolver/license.txt @@ -0,0 +1,8 @@ +Model Information: +* title: Colt-type revolver +* source: https://sketchfab.com/3d-models/colt-type-revolver-d0c9d2c989134fefb623c62b25a51daf +* author: Virtual Museums of Małopolska (https://sketchfab.com/WirtualneMuzeaMalopolski) + +Model License: +* license type: CC0-1.0 (http://creativecommons.org/publicdomain/zero/1.0/) +* requirements: Credit is not mandatory. Commercial use is allowed. diff --git a/examples/resources/models/gltf/colt-type_revolver/scene.bin b/examples/resources/models/gltf/colt-type_revolver/scene.bin new file mode 100644 index 0000000..63ad0a3 Binary files /dev/null and b/examples/resources/models/gltf/colt-type_revolver/scene.bin differ diff --git a/examples/resources/models/gltf/colt-type_revolver/scene.gltf b/examples/resources/models/gltf/colt-type_revolver/scene.gltf new file mode 100644 index 0000000..ad3eba7 --- /dev/null +++ b/examples/resources/models/gltf/colt-type_revolver/scene.gltf @@ -0,0 +1,568 @@ +{ + "accessors": [ + { + "bufferView": 2, + "componentType": 5126, + "count": 12351, + "max": [ + 0.01023900043219328, + 0.2876420021057129, + 0.1563130021095276 + ], + "min": [ + -0.4337269961833954, + -0.19032500684261322, + -0.3297869861125946 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 148212, + "componentType": 5126, + "count": 12351, + "max": [ + 0.9993467330932617, + 0.999626636505127, + 0.9999514818191528 + ], + "min": [ + -0.999255895614624, + -1.0, + -0.997488260269165 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "componentType": 5126, + "count": 12351, + "max": [ + 0.9999815225601196, + 0.9994451999664307, + 0.9997614026069641, + 1.0 + ], + "min": [ + -0.9998846054077148, + -0.9996145367622375, + -0.9983330965042114, + -1.0 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "componentType": 5126, + "count": 12351, + "max": [ + 0.9849709868431091, + 0.9892209768295288 + ], + "min": [ + 0.01867000013589859, + 0.008609999902546406 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "componentType": 5125, + "count": 67809, + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 296424, + "componentType": 5126, + "count": 65532, + "max": [ + 1.4070700407028198, + 0.3186340034008026, + 0.518513023853302 + ], + "min": [ + -1.3685799837112427, + -0.29662400484085083, + -0.3618690073490143 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 1082808, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9994122385978699, + 0.9999516606330872, + 0.9999513626098633 + ], + "min": [ + -0.9999678730964661, + -0.9999834895133972, + -0.9999529719352722 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 197616, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9997813701629639, + 0.999999463558197, + 0.9994206428527832, + 1.0 + ], + "min": [ + -0.9999995827674866, + -0.9999482035636902, + -0.9999989867210388, + 1.0 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 98808, + "componentType": 5126, + "count": 65532, + "max": [ + 0.978905975818634, + 0.988070011138916 + ], + "min": [ + 0.009999999776482582, + 0.009999999776482582 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 271236, + "componentType": 5125, + "count": 339786, + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 1869192, + "componentType": 5126, + "count": 65532, + "max": [ + 1.4036500453948975, + 0.1899999976158142, + 0.5185880064964294 + ], + "min": [ + -1.495479941368103, + -0.4656749963760376, + -0.3695549964904785 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 2655576, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9999555349349976, + 0.999965250492096, + 0.9999727606773376 + ], + "min": [ + -0.9997665286064148, + -0.9999116063117981, + -0.9998611211776733 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 1246128, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9999947547912598, + 0.9999721050262451, + 0.9992319941520691, + 1.0 + ], + "min": [ + -0.9990314841270447, + -0.9999626874923706, + -0.9999987483024597, + 1.0 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 623064, + "componentType": 5126, + "count": 65532, + "max": [ + 0.9603390097618103, + 0.9883760213851929 + ], + "min": [ + 0.009999999776482582, + 0.011273999698460102 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 1630380, + "componentType": 5125, + "count": 338319, + "type": "SCALAR" + }, + { + "bufferView": 2, + "byteOffset": 3441960, + "componentType": 5126, + "count": 49442, + "max": [ + 1.3997000455856323, + 0.35751399397850037, + 0.5192379951477051 + ], + "min": [ + -1.4917099475860596, + -0.4860759973526001, + -0.4236240088939667 + ], + "type": "VEC3" + }, + { + "bufferView": 2, + "byteOffset": 4035264, + "componentType": 5126, + "count": 49442, + "max": [ + 0.9998608827590942, + 0.9999516606330872, + 0.999967098236084 + ], + "min": [ + -0.9999971389770508, + -0.9999890923500061, + -0.9999529719352722 + ], + "type": "VEC3" + }, + { + "bufferView": 3, + "byteOffset": 2294640, + "componentType": 5126, + "count": 49442, + "max": [ + 0.9997773766517639, + 0.9999926686286926, + 0.9997642636299133, + 1.0 + ], + "min": [ + -0.9999465346336365, + -0.9998719692230225, + -0.9999542236328125, + 1.0 + ], + "type": "VEC4" + }, + { + "bufferView": 1, + "byteOffset": 1147320, + "componentType": 5126, + "count": 49442, + "max": [ + 0.9821640253067017, + 0.9900000095367432 + ], + "min": [ + 0.009999999776482582, + 0.009999999776482582 + ], + "type": "VEC2" + }, + { + "bufferView": 0, + "byteOffset": 2983656, + "componentType": 5125, + "count": 218835, + "type": "SCALAR" + } + ], + "asset": { + "extras": { + "author": "Virtual Museums of Małopolska (https://sketchfab.com/WirtualneMuzeaMalopolski)", + "license": "CC0-1.0 (http://creativecommons.org/publicdomain/zero/1.0/)", + "source": "https://sketchfab.com/3d-models/colt-type-revolver-d0c9d2c989134fefb623c62b25a51daf", + "title": "Colt-type revolver" + }, + "generator": "Sketchfab-12.68.0", + "version": "2.0" + }, + "bufferViews": [ + { + "buffer": 0, + "byteLength": 3858996, + "name": "floatBufferViews", + "target": 34963 + }, + { + "buffer": 0, + "byteLength": 1542856, + "byteOffset": 3858996, + "byteStride": 8, + "name": "floatBufferViews", + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 4628568, + "byteOffset": 5401852, + "byteStride": 12, + "name": "floatBufferViews", + "target": 34962 + }, + { + "buffer": 0, + "byteLength": 3085712, + "byteOffset": 10030420, + "byteStride": 16, + "name": "floatBufferViews", + "target": 34962 + } + ], + "buffers": [ + { + "byteLength": 13116132, + "uri": "scene.bin" + } + ], + "images": [ + { + "uri": "textures/MNS_587_baseColor.jpeg" + }, + { + "uri": "textures/MNS_587_metallicRoughness.png" + }, + { + "uri": "textures/MNS_587_normal.png" + }, + { + "uri": "textures/MNS_5871_baseColor.jpeg" + }, + { + "uri": "textures/MNS_5871_metallicRoughness.png" + }, + { + "uri": "textures/MNS_5871_normal.png" + } + ], + "materials": [ + { + "doubleSided": true, + "name": "MNS_587", + "normalTexture": { + "index": 2 + }, + "occlusionTexture": { + "index": 1 + }, + "pbrMetallicRoughness": { + "baseColorTexture": { + "index": 0 + }, + "metallicFactor": 0.9102515244, + "metallicRoughnessTexture": { + "index": 1 + } + } + }, + { + "doubleSided": true, + "name": "MNS_5871", + "normalTexture": { + "index": 5 + }, + "occlusionTexture": { + "index": 4 + }, + "pbrMetallicRoughness": { + "baseColorTexture": { + "index": 3 + }, + "metallicFactor": 0.8919588415, + "metallicRoughnessTexture": { + "index": 4 + } + } + } + ], + "meshes": [ + { + "name": "Object_0", + "primitives": [ + { + "attributes": { + "NORMAL": 1, + "POSITION": 0, + "TANGENT": 2, + "TEXCOORD_0": 3 + }, + "indices": 4, + "material": 0, + "mode": 4 + } + ] + }, + { + "name": "Object_1", + "primitives": [ + { + "attributes": { + "NORMAL": 6, + "POSITION": 5, + "TANGENT": 7, + "TEXCOORD_0": 8 + }, + "indices": 9, + "material": 1, + "mode": 4 + } + ] + }, + { + "name": "Object_2", + "primitives": [ + { + "attributes": { + "NORMAL": 11, + "POSITION": 10, + "TANGENT": 12, + "TEXCOORD_0": 13 + }, + "indices": 14, + "material": 1, + "mode": 4 + } + ] + }, + { + "name": "Object_3", + "primitives": [ + { + "attributes": { + "NORMAL": 16, + "POSITION": 15, + "TANGENT": 17, + "TEXCOORD_0": 18 + }, + "indices": 19, + "material": 1, + "mode": 4 + } + ] + } + ], + "nodes": [ + { + "children": [ + 1 + ], + "matrix": [ + -0.10666780173778534, + -1.7153490511570238e-17, + 6.531519383517872e-18, + 0.0, + -6.531519383517876e-18, + 0.0, + -0.10666780173778534, + 0.0, + 1.7153490511570238e-17, + -0.10666780173778534, + 0.0, + 0.0, + -0.18417790532112122, + 0.13625323772430414, + 0.2580936551094056, + 1.0 + ], + "name": "Sketchfab_model" + }, + { + "children": [ + 2, + 3, + 4, + 5 + ], + "name": "MNS_587.obj.cleaner.materialmerger.gles" + }, + { + "mesh": 0, + "name": "Object_2" + }, + { + "mesh": 1, + "name": "Object_3" + }, + { + "mesh": 2, + "name": "Object_4" + }, + { + "mesh": 3, + "name": "Object_5" + } + ], + "samplers": [ + { + "magFilter": 9729, + "minFilter": 9987, + "wrapS": 10497, + "wrapT": 10497 + } + ], + "scene": 0, + "scenes": [ + { + "name": "Sketchfab_Scene", + "nodes": [ + 0 + ] + } + ], + "textures": [ + { + "sampler": 0, + "source": 0 + }, + { + "sampler": 0, + "source": 1 + }, + { + "sampler": 0, + "source": 2 + }, + { + "sampler": 0, + "source": 3 + }, + { + "sampler": 0, + "source": 4 + }, + { + "sampler": 0, + "source": 5 + } + ] +} diff --git a/examples/resources/models/gltf/colt-type_revolver/textures/MNS_5871_baseColor.jpeg b/examples/resources/models/gltf/colt-type_revolver/textures/MNS_5871_baseColor.jpeg new file mode 100644 index 0000000..9a4c167 Binary files /dev/null and b/examples/resources/models/gltf/colt-type_revolver/textures/MNS_5871_baseColor.jpeg differ diff --git a/examples/resources/models/gltf/colt-type_revolver/textures/MNS_5871_metallicRoughness.png b/examples/resources/models/gltf/colt-type_revolver/textures/MNS_5871_metallicRoughness.png new file mode 100644 index 0000000..6a51559 Binary files /dev/null and b/examples/resources/models/gltf/colt-type_revolver/textures/MNS_5871_metallicRoughness.png differ diff --git a/examples/resources/models/gltf/colt-type_revolver/textures/MNS_5871_normal.png b/examples/resources/models/gltf/colt-type_revolver/textures/MNS_5871_normal.png new file mode 100644 index 0000000..e8939ba Binary files /dev/null and b/examples/resources/models/gltf/colt-type_revolver/textures/MNS_5871_normal.png differ diff --git a/examples/resources/models/gltf/colt-type_revolver/textures/MNS_587_baseColor.jpeg b/examples/resources/models/gltf/colt-type_revolver/textures/MNS_587_baseColor.jpeg new file mode 100644 index 0000000..5b13d1e Binary files /dev/null and b/examples/resources/models/gltf/colt-type_revolver/textures/MNS_587_baseColor.jpeg differ diff --git a/examples/resources/models/gltf/colt-type_revolver/textures/MNS_587_metallicRoughness.png b/examples/resources/models/gltf/colt-type_revolver/textures/MNS_587_metallicRoughness.png new file mode 100644 index 0000000..081fd4d Binary files /dev/null and b/examples/resources/models/gltf/colt-type_revolver/textures/MNS_587_metallicRoughness.png differ diff --git a/examples/resources/models/gltf/colt-type_revolver/textures/MNS_587_normal.png b/examples/resources/models/gltf/colt-type_revolver/textures/MNS_587_normal.png new file mode 100644 index 0000000..3686566 Binary files /dev/null and b/examples/resources/models/gltf/colt-type_revolver/textures/MNS_587_normal.png differ diff --git a/src/shaders/shaderChunk/bsdfs.glsl b/src/shaders/shaderChunk/bsdfs.glsl index bca830a..001ed76 100644 --- a/src/shaders/shaderChunk/bsdfs.glsl +++ b/src/shaders/shaderChunk/bsdfs.glsl @@ -166,4 +166,18 @@ float GGXRoughnessToBlinnExponent( const in float ggxRoughness ) { float BlinnExponentToGGXRoughness( const in float blinnExponent ) { return sqrt( 2.0 / ( blinnExponent + 2.0 ) ); +} + +float getAARoughnessFactor(vec3 normal) { + // Kaplanyan 2016, "Stable specular highlights" + // Tokuyoshi 2017, "Error Reduction and Simplification for Shading Anti-Aliasing" + // Tokuyoshi and Kaplanyan 2019, "Improved Geometric Specular Antialiasing" + + // This implementation is meant for deferred rendering in the original paper but + // we use it in forward rendering as well (as discussed in Tokuyoshi and Kaplanyan + // 2019). The main reason is that the forward version requires an expensive transform + // of the half vector by the tangent frame for every light. + + vec3 dxy = max( abs(dFdx(normal)), abs(dFdy(normal)) ); + return 0.04 + max( max(dxy.x, dxy.y), dxy.z ); } \ No newline at end of file diff --git a/src/shaders/shaderChunk/light_frag.glsl b/src/shaders/shaderChunk/light_frag.glsl index 899377d..124dba8 100644 --- a/src/shaders/shaderChunk/light_frag.glsl +++ b/src/shaders/shaderChunk/light_frag.glsl @@ -16,11 +16,7 @@ float roughness = max(roughnessFactor, 0.0525); #endif - vec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal))); - float geometryRoughness = max(max(dxy.x, dxy.y), dxy.z); - roughness += geometryRoughness; - - roughness = min(roughness, 1.0); + roughness = min(max(roughness, getAARoughnessFactor(N)), 1.0); #ifdef USE_CLEARCOAT float clearcoat = u_Clearcoat; @@ -33,8 +29,7 @@ #endif clearcoat = saturate(clearcoat); clearcoatRoughness = max(clearcoatRoughness, 0.0525); - clearcoatRoughness += geometryRoughness; - clearcoatRoughness = min(clearcoatRoughness, 1.0); + clearcoatRoughness = min(max(clearcoatRoughness, getAARoughnessFactor(geometryNormal)), 1.0); #endif #else vec3 diffuseColor = outColor.xyz;