icn3d 3.44.1 → 3.44.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/icn3d.js +122 -8
- package/icn3d.min.js +3 -3
- package/icn3d.module.js +122 -8
- package/package.json +1 -1
package/icn3d.module.js
CHANGED
|
@@ -37241,7 +37241,7 @@ var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor
|
|
|
37241
37241
|
|
|
37242
37242
|
var lights_phong_pars_fragment = "varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong";
|
|
37243
37243
|
|
|
37244
|
-
var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\
|
|
37244
|
+
var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nfloat geometryRoughness = 0.0;\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif";
|
|
37245
37245
|
|
|
37246
37246
|
var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\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\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
|
|
37247
37247
|
|
|
@@ -57387,6 +57387,10 @@ class ClickMenu {
|
|
|
57387
57387
|
me.htmlCls.dialogCls.openDlg('dl_state', 'Please input the state file');
|
|
57388
57388
|
});
|
|
57389
57389
|
|
|
57390
|
+
me.myEventCls.onIds("#" + me.pre + "mn1_bcfviewpoint", "click", function(e) { me.icn3d; //e.preventDefault();
|
|
57391
|
+
me.htmlCls.dialogCls.openDlg('dl_bcfviewpoint', 'Please input the BCF viewpoint file');
|
|
57392
|
+
});
|
|
57393
|
+
|
|
57390
57394
|
me.myEventCls.onIds("#" + me.pre + "mn1_selection", "click", function(e) { me.icn3d; //e.preventDefault();
|
|
57391
57395
|
me.htmlCls.dialogCls.openDlg('dl_selection', 'Please input the selection file');
|
|
57392
57396
|
});
|
|
@@ -60300,6 +60304,7 @@ class SetMenu {
|
|
|
60300
60304
|
html += this.getLink('mn1_fixedversion', 'Share Link in Archived Ver. ' + me.htmlCls.wifiStr, undefined, 2);
|
|
60301
60305
|
html += this.getLink('mn1_selection', 'Selection File', undefined, 2);
|
|
60302
60306
|
html += this.getLink("mn1_collection", "Collection File", undefined, 2);
|
|
60307
|
+
html += this.getLink('mn1_bcfviewpoint', 'BCF Viewpoint File', undefined, 2);
|
|
60303
60308
|
|
|
60304
60309
|
html += this.getMenuSep();
|
|
60305
60310
|
|
|
@@ -62788,6 +62793,12 @@ class SetDialog {
|
|
|
62788
62793
|
html += me.htmlCls.buttonStr + "reload_state' style='margin-top: 6px;'>Load</button>";
|
|
62789
62794
|
html += "</div>";
|
|
62790
62795
|
|
|
62796
|
+
html += me.htmlCls.divStr + "dl_bcfviewpoint' class='" + dialogClass + "'>";
|
|
62797
|
+
html += this.addNotebookTitle('dl_bcfviewpoint', 'Please input a BCF viewpoint file');
|
|
62798
|
+
html += "BCF viewpoint file: " + me.htmlCls.inputFileStr + "id='" + me.pre + "bcfviewpoint'><br/>";
|
|
62799
|
+
html += me.htmlCls.buttonStr + "reload_bcfviewpoint' style='margin-top: 6px;'>Load</button>";
|
|
62800
|
+
html += "</div>";
|
|
62801
|
+
|
|
62791
62802
|
html += me.htmlCls.divStr + "dl_video' class='" + dialogClass + "'>";
|
|
62792
62803
|
html += this.addNotebookTitle('dl_video', 'Save canvas changes in a video');
|
|
62793
62804
|
html += "State file: " + me.htmlCls.inputFileStr + "id='" + me.pre + "state'><br/>";
|
|
@@ -64282,6 +64293,67 @@ class Events {
|
|
|
64282
64293
|
}
|
|
64283
64294
|
}
|
|
64284
64295
|
|
|
64296
|
+
async openBcf(file) { let me = this.icn3dui, ic = me.icn3d;
|
|
64297
|
+
let url = './script/jszip.min.js';
|
|
64298
|
+
await me.getAjaxPromise(url, 'script');
|
|
64299
|
+
|
|
64300
|
+
let jszip = new JSZip();
|
|
64301
|
+
|
|
64302
|
+
me.htmlCls.setHtmlCls.fileSupport();
|
|
64303
|
+
|
|
64304
|
+
jszip.loadAsync(file).then(function(zip) {
|
|
64305
|
+
zip.forEach(function (relativePath, zipEntry) {
|
|
64306
|
+
if (zipEntry.dir) {
|
|
64307
|
+
// Handle directory creation
|
|
64308
|
+
let folder = jszip.folder(relativePath);
|
|
64309
|
+
folder.forEach(function (filename, zipEntry2) {
|
|
64310
|
+
if(filename.substr(0, 9) == 'viewpoint') {
|
|
64311
|
+
zipEntry2.async('string') // or 'blob', 'arraybuffer'
|
|
64312
|
+
.then(function(fileData) {
|
|
64313
|
+
let parser = new DOMParser();
|
|
64314
|
+
let xmlDoc = parser.parseFromString(fileData, "text/xml");
|
|
64315
|
+
|
|
64316
|
+
// Accessing elements
|
|
64317
|
+
//const author = xmlDoc.getElementsByTagName("author")[0].textContent;
|
|
64318
|
+
//const author = xmlDoc.querySelector("author").textContent;
|
|
64319
|
+
let viewpoint = xmlDoc.querySelector("CameraViewPoint");
|
|
64320
|
+
let direction = xmlDoc.querySelector("CameraDirection");
|
|
64321
|
+
let upvector = xmlDoc.querySelector("CameraUpVector");
|
|
64322
|
+
let fov = xmlDoc.querySelector("FieldOfView").textContent;
|
|
64323
|
+
xmlDoc.querySelector("AspectRatio").textContent;
|
|
64324
|
+
|
|
64325
|
+
let childNodes, viewpointArray = [], directionArray = [], upvectorArray = [];
|
|
64326
|
+
|
|
64327
|
+
childNodes = viewpoint.children;
|
|
64328
|
+
viewpointArray = [childNodes[0].textContent, childNodes[1].textContent, childNodes[2].textContent];
|
|
64329
|
+
childNodes = direction.children;
|
|
64330
|
+
directionArray = [childNodes[0].textContent, childNodes[1].textContent, childNodes[2].textContent];
|
|
64331
|
+
childNodes = upvector.children;
|
|
64332
|
+
upvectorArray = [childNodes[0].textContent, childNodes[1].textContent, childNodes[2].textContent];
|
|
64333
|
+
|
|
64334
|
+
ic.cam.position.set(viewpointArray[0], viewpointArray[1], viewpointArray[2]);
|
|
64335
|
+
ic.cam.quaternion.setFromUnitVectors(new Vector3$1(0, 0, -1), new Vector3$1(directionArray[0], directionArray[1], directionArray[2]));
|
|
64336
|
+
ic.cam.up.set(upvectorArray[0], upvectorArray[1], upvectorArray[2]);
|
|
64337
|
+
ic.cam.fov = fov;
|
|
64338
|
+
//ic.container.whratio = aspect;
|
|
64339
|
+
|
|
64340
|
+
ic.drawCls.applyTransformation(ic._zoomFactor, ic.mouseChange, ic.quaternion);
|
|
64341
|
+
ic.drawCls.render();
|
|
64342
|
+
});
|
|
64343
|
+
}
|
|
64344
|
+
});
|
|
64345
|
+
}
|
|
64346
|
+
// else {
|
|
64347
|
+
// // Handle file extraction
|
|
64348
|
+
// zipEntry.async("string").then(function (content) {
|
|
64349
|
+
// });
|
|
64350
|
+
// }
|
|
64351
|
+
});
|
|
64352
|
+
}, function (e) {
|
|
64353
|
+
console.error("Error loading BCF viewpoint file:", e);
|
|
64354
|
+
});
|
|
64355
|
+
}
|
|
64356
|
+
|
|
64285
64357
|
//Hold all functions related to click events.
|
|
64286
64358
|
allEventFunctions() { let me = this.icn3dui, ic = me.icn3d;
|
|
64287
64359
|
let thisClass = this;
|
|
@@ -64708,7 +64780,7 @@ class Events {
|
|
|
64708
64780
|
let v2Y = $("#" + me.pre + "v2Y").val();
|
|
64709
64781
|
let v2Z = $("#" + me.pre + "v2Z").val();
|
|
64710
64782
|
|
|
64711
|
-
let angleRad = new
|
|
64783
|
+
let angleRad = new Vector3$1(parseFloat(v1X), parseFloat(v1Y), parseFloat(v1Z)).angleTo(new Vector3$1(parseFloat(v2X), parseFloat(v2Y), parseFloat(v2Z)));
|
|
64712
64784
|
let angle = angleRad / 3.1416 * 180;
|
|
64713
64785
|
angle = Math.abs(angle).toFixed(0);
|
|
64714
64786
|
if(angle > 180) angle -= 180;
|
|
@@ -65374,6 +65446,19 @@ class Events {
|
|
|
65374
65446
|
}
|
|
65375
65447
|
});
|
|
65376
65448
|
|
|
65449
|
+
me.myEventCls.onIds("#" + me.pre + "reload_bcfviewpoint", "click", async function(e) { me.icn3d;
|
|
65450
|
+
e.preventDefault();
|
|
65451
|
+
if(!me.cfg.notebook) dialog.dialog( "close" );
|
|
65452
|
+
|
|
65453
|
+
let file = $("#" + me.pre + "bcfviewpoint")[0].files[0];
|
|
65454
|
+
if(!file) {
|
|
65455
|
+
var aaa = 1; //alert("Please select a file before clicking 'Load'");
|
|
65456
|
+
}
|
|
65457
|
+
else {
|
|
65458
|
+
await thisClass.openBcf(file);
|
|
65459
|
+
}
|
|
65460
|
+
});
|
|
65461
|
+
|
|
65377
65462
|
me.myEventCls.onIds("#" + me.pre + "reload_selectionfile", "click", function(e) { let ic = me.icn3d;
|
|
65378
65463
|
e.preventDefault();
|
|
65379
65464
|
if(!me.cfg.notebook) dialog.dialog( "close" );
|
|
@@ -66809,8 +66894,8 @@ class Events {
|
|
|
66809
66894
|
let posArray1 = ic.contactCls.getExtent(atomSet1);
|
|
66810
66895
|
let posArray2 = ic.contactCls.getExtent(atomSet2);
|
|
66811
66896
|
|
|
66812
|
-
let pos1 = new
|
|
66813
|
-
let pos2 = new
|
|
66897
|
+
let pos1 = new Vector3$1(posArray1[2][0], posArray1[2][1], posArray1[2][2]);
|
|
66898
|
+
let pos2 = new Vector3$1(posArray2[2][0], posArray2[2][1], posArray2[2][2]);
|
|
66814
66899
|
|
|
66815
66900
|
let radius = $("#" + me.pre + "linebtwsets_radius").val();
|
|
66816
66901
|
let color = $("#" + me.pre + "linebtwsets_customcolor").val();
|
|
@@ -66834,7 +66919,7 @@ class Events {
|
|
|
66834
66919
|
let nameArray = $("#" + me.pre + "cartoonshape").val();
|
|
66835
66920
|
let atomSet1 = ic.definedSetsCls.getAtomsFromNameArray(nameArray);
|
|
66836
66921
|
let posArray1 = ic.contactCls.getExtent(atomSet1);
|
|
66837
|
-
let pos1 = new
|
|
66922
|
+
let pos1 = new Vector3$1(posArray1[2][0], posArray1[2][1], posArray1[2][2]);
|
|
66838
66923
|
|
|
66839
66924
|
let shape = $("#" + me.pre + "cartoonshape_shape").val(); // Sphere or Cube
|
|
66840
66925
|
let radius = $("#" + me.pre + "cartoonshape_radius").val();
|
|
@@ -67295,6 +67380,32 @@ class Events {
|
|
|
67295
67380
|
thisClass.setLogCmd("set theme black", true);
|
|
67296
67381
|
});
|
|
67297
67382
|
|
|
67383
|
+
// dragover and drop
|
|
67384
|
+
me.myEventCls.onIds("#" + me.pre + "viewer", "dragover", function(e) { me.icn3d;
|
|
67385
|
+
e.preventDefault();
|
|
67386
|
+
$("#" + me.pre + "viewer")[0].style.border = "5px solid blue";
|
|
67387
|
+
});
|
|
67388
|
+
me.myEventCls.onIds("#" + me.pre + "viewer", "drop", async function(e) { me.icn3d;
|
|
67389
|
+
e.preventDefault();
|
|
67390
|
+
|
|
67391
|
+
let files = e.dataTransfer.files;
|
|
67392
|
+
|
|
67393
|
+
for(let i = 0, il = e.dataTransfer.files.length; i < il; ++i) {
|
|
67394
|
+
let file = e.dataTransfer.files[i];
|
|
67395
|
+
let fileName = file.name;
|
|
67396
|
+
|
|
67397
|
+
let fileType = fileName.substr(fileName.lastIndexOf('.') + 1).toLowerCase();
|
|
67398
|
+
if(fileType == 'pdb' || fileType == 'mmcif' || fileType == 'png') {
|
|
67399
|
+
await me.htmlCls.eventsCls.readFile(true, files, i, '', (fileType == 'mmcif'), (fileType == 'png'));
|
|
67400
|
+
}
|
|
67401
|
+
else if(fileType == 'bcf') {
|
|
67402
|
+
await thisClass.openBcf(file);
|
|
67403
|
+
}
|
|
67404
|
+
}
|
|
67405
|
+
|
|
67406
|
+
$("#" + me.pre + "viewer")[0].style.border = "0px solid black";
|
|
67407
|
+
});
|
|
67408
|
+
|
|
67298
67409
|
$(document).on("click", "." + me.pre + "snpin3d", async function(e) { let ic = me.icn3d;
|
|
67299
67410
|
e.stopImmediatePropagation();
|
|
67300
67411
|
|
|
@@ -106282,11 +106393,14 @@ class MmcifParser {
|
|
|
106282
106393
|
let mat4 = new Matrix4$1();
|
|
106283
106394
|
mat4.fromArray(data.assembly[i]);
|
|
106284
106395
|
|
|
106285
|
-
|
|
106396
|
+
// sometimes an extra matrix as included, e.g., PDb ID 2GTL
|
|
106397
|
+
if(i == 0 && data.assembly[i][0] != 1) continue;
|
|
106398
|
+
|
|
106399
|
+
ic.biomtMatrices.push(mat4);
|
|
106286
106400
|
}
|
|
106287
106401
|
|
|
106288
106402
|
ic.asuCnt = ic.biomtMatrices.length;
|
|
106289
|
-
|
|
106403
|
+
|
|
106290
106404
|
// show bioassembly
|
|
106291
106405
|
if(me.cfg.bu == 1 && Object.keys(ic.atoms).length * ic.asuCnt > ic.maxatomcnt) {
|
|
106292
106406
|
ic.bAssembly = true;
|
|
@@ -133461,7 +133575,7 @@ class iCn3DUI {
|
|
|
133461
133575
|
//even when multiple iCn3D viewers are shown together.
|
|
133462
133576
|
this.pre = this.cfg.divid + "_";
|
|
133463
133577
|
|
|
133464
|
-
this.REVISION = '3.44.
|
|
133578
|
+
this.REVISION = '3.44.2';
|
|
133465
133579
|
|
|
133466
133580
|
// In nodejs, iCn3D defines "window = {navigator: {}}"
|
|
133467
133581
|
this.bNode = (Object.keys(window).length < 2) ? true : false;
|