icn3d 3.44.2 → 3.45.0

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.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 );\nvec3 fdx = dFdx( vViewPosition );\nvec3 fdy = dFdy( vViewPosition );\nvec3 nonPerturbedNormal = normalize( cross( fdx, fdy ) );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\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";
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
 
@@ -56015,7 +56015,7 @@ class MyEventCls {
56015
56015
  }
56016
56016
 
56017
56017
  onId(id, eventName, myFunction) { this.icn3dui;
56018
- if(Object.keys(window).length < 2) return;
56018
+ if(Object.keys(window).length < 3) return;
56019
56019
 
56020
56020
  if(id.substr(0, 1) == '#') id = id.substr(1);
56021
56021
  if(document.getElementById(id)) {
@@ -75048,13 +75048,18 @@ class Scene {
75048
75048
  rebuildScene(options) { let ic = this.icn3d, me = ic.icn3dui;
75049
75049
  if(options === undefined) options = ic.opts;
75050
75050
 
75051
+ // whether camera was set
75052
+ me.bCamera = (ic.cam) ? true : false;
75053
+
75051
75054
  this.rebuildSceneBase(options);
75052
75055
 
75053
75056
  ic.fogCls.setFog();
75054
75057
 
75055
- // if(!ic.bVr && !ic.bAr) { // first time
75058
+ if(ic.bSetCamera) { // load a URL with trackball transformation, or no info after "|||"
75056
75059
  ic.cameraCls.setCamera();
75057
- // }
75060
+ }
75061
+
75062
+ if(ic.opts['slab'] === 'yes') ic.cameraCls.setSlab();
75058
75063
 
75059
75064
  // if(!ic.bSetVrArButtons) { // call once
75060
75065
  if(!me.cfg.imageonly) this.setVrArButtons();
@@ -76254,7 +76259,7 @@ function TrackballControls( object, domElement, icn3d ) {
76254
76259
  function keydown( event ) {
76255
76260
  //console.log("keydown");
76256
76261
 
76257
- if ( _this.enabled === false || Object.keys(window).length < 2) return;
76262
+ if ( _this.enabled === false || Object.keys(window).length < 3) return;
76258
76263
 
76259
76264
  window.removeEventListener( 'keydown', keydown );
76260
76265
 
@@ -76285,7 +76290,7 @@ function TrackballControls( object, domElement, icn3d ) {
76285
76290
  function keyup( event ) {
76286
76291
  //console.log("keyup");
76287
76292
 
76288
- if ( _this.enabled === false || Object.keys(window).length < 2) return;
76293
+ if ( _this.enabled === false || Object.keys(window).length < 3) return;
76289
76294
 
76290
76295
  _this._state = _prevState;
76291
76296
 
@@ -76295,7 +76300,7 @@ function TrackballControls( object, domElement, icn3d ) {
76295
76300
 
76296
76301
  function mousedown( event ) {
76297
76302
 
76298
- if ( _this.enabled === false || Object.keys(window).length < 2) return;
76303
+ if ( _this.enabled === false || Object.keys(window).length < 3) return;
76299
76304
 
76300
76305
  //event.preventDefault();
76301
76306
  event.stopPropagation();
@@ -76332,7 +76337,7 @@ function TrackballControls( object, domElement, icn3d ) {
76332
76337
 
76333
76338
  function mousemove( event ) {
76334
76339
 
76335
- if ( _this.enabled === false || Object.keys(window).length < 2) return;
76340
+ if ( _this.enabled === false || Object.keys(window).length < 3) return;
76336
76341
 
76337
76342
  //event.preventDefault();
76338
76343
  event.stopPropagation();
@@ -76355,7 +76360,7 @@ function TrackballControls( object, domElement, icn3d ) {
76355
76360
  }
76356
76361
 
76357
76362
  function mouseup( event ) {
76358
- if ( _this.enabled === false || Object.keys(window).length < 2) return;
76363
+ if ( _this.enabled === false || Object.keys(window).length < 3) return;
76359
76364
 
76360
76365
  //event.preventDefault();
76361
76366
  event.stopPropagation();
@@ -76370,7 +76375,7 @@ function TrackballControls( object, domElement, icn3d ) {
76370
76375
 
76371
76376
  function mousewheel( event ) {
76372
76377
 
76373
- if ( _this.enabled === false || Object.keys(window).length < 2) return;
76378
+ if ( _this.enabled === false || Object.keys(window).length < 3) return;
76374
76379
 
76375
76380
  //event.preventDefault();
76376
76381
  event.stopPropagation();
@@ -76397,7 +76402,7 @@ function TrackballControls( object, domElement, icn3d ) {
76397
76402
 
76398
76403
  function touchstart( event ) {
76399
76404
 
76400
- if ( _this.enabled === false || Object.keys(window).length < 2) return;
76405
+ if ( _this.enabled === false || Object.keys(window).length < 3) return;
76401
76406
 
76402
76407
  switch ( event.touches.length ) {
76403
76408
  case 1:
@@ -76429,7 +76434,7 @@ function TrackballControls( object, domElement, icn3d ) {
76429
76434
 
76430
76435
  function touchmove( event ) {
76431
76436
 
76432
- if ( _this.enabled === false || Object.keys(window).length < 2) return;
76437
+ if ( _this.enabled === false || Object.keys(window).length < 3) return;
76433
76438
 
76434
76439
  //event.preventDefault();
76435
76440
  event.stopPropagation();
@@ -76459,7 +76464,7 @@ function TrackballControls( object, domElement, icn3d ) {
76459
76464
 
76460
76465
  function touchend( event ) {
76461
76466
 
76462
- if ( _this.enabled === false || Object.keys(window).length < 2) return;
76467
+ if ( _this.enabled === false || Object.keys(window).length < 3) return;
76463
76468
 
76464
76469
  switch ( event.touches.length ) {
76465
76470
 
@@ -76484,7 +76489,7 @@ function TrackballControls( object, domElement, icn3d ) {
76484
76489
 
76485
76490
  }
76486
76491
 
76487
- if(Object.keys(window).length >= 2 && this.domElement) {
76492
+ if(Object.keys(window).length >= 3 && this.domElement) {
76488
76493
  this.domElement.addEventListener( 'contextmn', function ( event ) {
76489
76494
  //event.preventDefault();
76490
76495
  }, false );
@@ -76498,8 +76503,8 @@ function TrackballControls( object, domElement, icn3d ) {
76498
76503
  this.domElement.addEventListener( 'touchend', touchend, false );
76499
76504
  this.domElement.addEventListener( 'touchmove', touchmove, false );
76500
76505
 
76501
- if(Object.keys(window).length >= 2) window.addEventListener( 'keydown', keydown, false );
76502
- if(Object.keys(window).length >= 2) window.addEventListener( 'keyup', keyup, false );
76506
+ if(Object.keys(window).length >= 3) window.addEventListener( 'keydown', keydown, false );
76507
+ if(Object.keys(window).length >= 3) window.addEventListener( 'keyup', keyup, false );
76503
76508
  }
76504
76509
 
76505
76510
  this.handleResize();
@@ -76932,7 +76937,7 @@ function OrthographicTrackballControls( object, domElement, icn3d ) { var me = t
76932
76937
 
76933
76938
  function keydown( event ) {
76934
76939
 
76935
- if ( _this.enabled === false || Object.keys(window).length < 2) return;
76940
+ if ( _this.enabled === false || Object.keys(window).length < 3) return;
76936
76941
 
76937
76942
  window.removeEventListener( 'keydown', keydown );
76938
76943
 
@@ -76960,7 +76965,7 @@ function OrthographicTrackballControls( object, domElement, icn3d ) { var me = t
76960
76965
 
76961
76966
  function keyup( event ) {
76962
76967
 
76963
- if ( _this.enabled === false || Object.keys(window).length < 2) return;
76968
+ if ( _this.enabled === false || Object.keys(window).length < 3) return;
76964
76969
 
76965
76970
  _this._state = _prevState;
76966
76971
 
@@ -76970,7 +76975,7 @@ function OrthographicTrackballControls( object, domElement, icn3d ) { var me = t
76970
76975
 
76971
76976
  function mousedown( event ) {
76972
76977
 
76973
- if ( _this.enabled === false || Object.keys(window).length < 2) return;
76978
+ if ( _this.enabled === false || Object.keys(window).length < 3) return;
76974
76979
 
76975
76980
  //event.preventDefault();
76976
76981
  event.stopPropagation();
@@ -77007,7 +77012,7 @@ function OrthographicTrackballControls( object, domElement, icn3d ) { var me = t
77007
77012
 
77008
77013
  function mousemove( event ) {
77009
77014
 
77010
- if ( _this.enabled === false || Object.keys(window).length < 2) return;
77015
+ if ( _this.enabled === false || Object.keys(window).length < 3) return;
77011
77016
 
77012
77017
  //event.preventDefault();
77013
77018
  event.stopPropagation();
@@ -77030,7 +77035,7 @@ function OrthographicTrackballControls( object, domElement, icn3d ) { var me = t
77030
77035
 
77031
77036
  function mouseup( event ) {
77032
77037
 
77033
- if ( _this.enabled === false || Object.keys(window).length < 2) return;
77038
+ if ( _this.enabled === false || Object.keys(window).length < 3) return;
77034
77039
 
77035
77040
  //event.preventDefault();
77036
77041
  event.stopPropagation();
@@ -77045,7 +77050,7 @@ function OrthographicTrackballControls( object, domElement, icn3d ) { var me = t
77045
77050
 
77046
77051
  function mousewheel( event ) {
77047
77052
 
77048
- if ( _this.enabled === false || Object.keys(window).length < 2) return;
77053
+ if ( _this.enabled === false || Object.keys(window).length < 3) return;
77049
77054
 
77050
77055
  //event.preventDefault();
77051
77056
  event.stopPropagation();
@@ -77071,7 +77076,7 @@ function OrthographicTrackballControls( object, domElement, icn3d ) { var me = t
77071
77076
 
77072
77077
  function touchstart( event ) {
77073
77078
 
77074
- if ( _this.enabled === false || Object.keys(window).length < 2) return;
77079
+ if ( _this.enabled === false || Object.keys(window).length < 3) return;
77075
77080
 
77076
77081
  switch ( event.touches.length ) {
77077
77082
 
@@ -77104,7 +77109,7 @@ function OrthographicTrackballControls( object, domElement, icn3d ) { var me = t
77104
77109
 
77105
77110
  function touchmove( event ) {
77106
77111
 
77107
- if ( _this.enabled === false || Object.keys(window).length < 2) return;
77112
+ if ( _this.enabled === false || Object.keys(window).length < 3) return;
77108
77113
 
77109
77114
  //event.preventDefault();
77110
77115
  event.stopPropagation();
@@ -77134,7 +77139,7 @@ function OrthographicTrackballControls( object, domElement, icn3d ) { var me = t
77134
77139
 
77135
77140
  function touchend( event ) {
77136
77141
 
77137
- if ( _this.enabled === false || Object.keys(window).length < 2) return;
77142
+ if ( _this.enabled === false || Object.keys(window).length < 3) return;
77138
77143
 
77139
77144
  switch ( event.touches.length ) {
77140
77145
 
@@ -77159,7 +77164,7 @@ function OrthographicTrackballControls( object, domElement, icn3d ) { var me = t
77159
77164
 
77160
77165
  }
77161
77166
 
77162
- if(Object.keys(window).length >= 2 && this.domElement) {
77167
+ if(Object.keys(window).length >= 3 && this.domElement) {
77163
77168
  this.domElement.addEventListener( 'contextmn', function ( event ) {
77164
77169
  //event.preventDefault();
77165
77170
  }, false );
@@ -77205,7 +77210,8 @@ class Camera {
77205
77210
 
77206
77211
  let maxD = ic.maxD;
77207
77212
 
77208
- if(window.cam === ic.perspectiveCamera) {
77213
+ // if(window.cam === ic.perspectiveCamera) {
77214
+ if(ic.opts.camera.toLowerCase() == 'perspective') {
77209
77215
  let bInstance = (ic.biomtMatrices !== undefined && ic.biomtMatrices.length * ic.cnt > ic.maxatomcnt) ? true : false;
77210
77216
  //var factor = (ic.biomtMatrices !== undefined && ic.biomtMatrices.length * ic.cnt > 10 * ic.maxatomcnt) ? 1 : 2;
77211
77217
  //var factor = (ic.biomtMatrices !== undefined && ic.biomtMatrices.length * ic.cnt > 10 * ic.maxatomcnt) ? 1 : 3;
@@ -77220,26 +77226,26 @@ class Camera {
77220
77226
  }
77221
77227
 
77222
77228
  if(window.cam_z > 0) {
77223
- window.cam.position.z = maxD * window.camMaxDFactor; // for perspective, the z position should be large enough to see the whole molecule
77229
+ window.cam.position.z = maxD * window.camMaxDFactor; // for perspective, the z position should be large enough to see the whole molecule
77224
77230
  }
77225
77231
  else {
77226
- window.cam.position.z = -maxD * window.camMaxDFactor; // for perspective, the z position should be large enough to see the whole molecule
77232
+ window.cam.position.z = -maxD * window.camMaxDFactor; // for perspective, the z position should be large enough to see the whole molecule
77227
77233
  }
77228
77234
 
77229
- if(ic.opts['slab'] === 'yes') {
77230
- if(bInstance) {
77231
- window.cam.near = 0.1;
77232
- }
77233
- else if(window.camMaxDFactorFog !== undefined) {
77234
- window.cam.near = maxD * window.camMaxDFactorFog - 10; // keep some surrounding residues
77235
- }
77236
- else {
77237
- window.cam.near = maxD * window.camMaxDFactor;
77238
- }
77239
- }
77240
- else {
77235
+ // if(ic.opts['slab'] === 'yes') {
77236
+ // if(bInstance) {
77237
+ // window.cam.near = 0.1;
77238
+ // }
77239
+ // else if(window.camMaxDFactorFog !== undefined) {
77240
+ // window.cam.near = maxD * window.camMaxDFactorFog - 10; // keep some surrounding residues
77241
+ // }
77242
+ // else {
77243
+ // window.cam.near = maxD * window.camMaxDFactor;
77244
+ // }
77245
+ // }
77246
+ // else {
77241
77247
  window.cam.near = 0.1;
77242
- }
77248
+ // }
77243
77249
  window.cam.far = 10000;
77244
77250
 
77245
77251
  if(ic.bControlGl && !me.bNode) {
@@ -77254,7 +77260,8 @@ class Camera {
77254
77260
  }
77255
77261
  }
77256
77262
  }
77257
- else if (window.cam === ic.orthographicCamera){
77263
+ // else if (window.cam === ic.orthographicCamera){
77264
+ else if(ic.opts.camera.toLowerCase() == 'orthographic') {
77258
77265
  if(ic.biomtMatrices !== undefined && ic.biomtMatrices.length * ic.cnt > 10 * ic.maxatomcnt) {
77259
77266
  window.cam.right = ic.maxD/2 * 1.5;
77260
77267
  }
@@ -77266,12 +77273,12 @@ class Camera {
77266
77273
  window.cam.top = window.cam.right /ic.container.whratio;
77267
77274
  window.cam.bottom = -window.cam.right /ic.container.whratio;
77268
77275
 
77269
- if(ic.opts['slab'] === 'yes') {
77270
- window.cam.near = ic.maxD * 2;
77271
- }
77272
- else {
77276
+ // if(ic.opts['slab'] === 'yes') {
77277
+ // window.cam.near = ic.maxD * 2;
77278
+ // }
77279
+ // else {
77273
77280
  window.cam.near = 0;
77274
- }
77281
+ // }
77275
77282
 
77276
77283
  window.cam.far = 10000;
77277
77284
 
@@ -77297,7 +77304,8 @@ class Camera {
77297
77304
 
77298
77305
  let maxD = ic.maxD;
77299
77306
 
77300
- if(ic.cam === ic.perspectiveCamera) {
77307
+ // if(ic.cam === ic.perspectiveCamera) {
77308
+ if(ic.opts.camera.toLowerCase() == 'perspective') {
77301
77309
  let bInstance = (ic.biomtMatrices !== undefined && ic.biomtMatrices.length * ic.cnt > ic.maxatomcnt) ? true : false;
77302
77310
  //var factor = (ic.biomtMatrices !== undefined && ic.biomtMatrices.length * ic.cnt > 10 * ic.maxatomcnt) ? 1 : 2;
77303
77311
  //var factor = (ic.biomtMatrices !== undefined && ic.biomtMatrices.length * ic.cnt > 10 * ic.maxatomcnt) ? 1 : 3;
@@ -77312,26 +77320,26 @@ class Camera {
77312
77320
  }
77313
77321
 
77314
77322
  if(ic.cam_z > 0) {
77315
- ic.cam.position.z = maxD * ic.camMaxDFactor; // forperspective, the z positionshould be large enough to see the whole molecule
77323
+ ic.cam.position.z = maxD * ic.camMaxDFactor; // forperspective, the z positionshould be large enough to see the whole molecule
77316
77324
  }
77317
77325
  else {
77318
- ic.cam.position.z = -maxD * ic.camMaxDFactor; // forperspective, the z positionshould be large enough to see the whole molecule
77326
+ ic.cam.position.z = -maxD * ic.camMaxDFactor; // forperspective, the z positionshould be large enough to see the whole molecule
77319
77327
  }
77320
77328
 
77321
- if(ic.opts['slab'] === 'yes') {
77322
- if(bInstance) {
77323
- ic.cam.near = 0.1;
77324
- }
77325
- else if(ic.camMaxDFactorFog !== undefined) {
77326
- ic.cam.near = maxD * ic.camMaxDFactorFog - 10; // keep some surrounding residues
77327
- }
77328
- else {
77329
- ic.cam.near = maxD * ic.camMaxDFactor;
77330
- }
77331
- }
77332
- else {
77329
+ // if(ic.opts['slab'] === 'yes') {
77330
+ // if(bInstance) {
77331
+ // ic.cam.near = 0.1;
77332
+ // }
77333
+ // else if(ic.camMaxDFactorFog !== undefined) {
77334
+ // ic.cam.near = maxD * ic.camMaxDFactorFog - 10; // keep some surrounding residues
77335
+ // }
77336
+ // else {
77337
+ // ic.cam.near = maxD * ic.camMaxDFactor;
77338
+ // }
77339
+ // }
77340
+ // else {
77333
77341
  ic.cam.near = 0.1;
77334
- }
77342
+ // }
77335
77343
  ic.cam.far = 10000;
77336
77344
 
77337
77345
  if(ic.bControlGl && !me.bNode) {
@@ -77346,7 +77354,8 @@ class Camera {
77346
77354
  }
77347
77355
  }
77348
77356
  }
77349
- else if (ic.cam === ic.orthographicCamera){
77357
+ // else if (ic.cam === ic.orthographicCamera){
77358
+ else if(ic.opts.camera.toLowerCase() == 'orthographic') {
77350
77359
  if(ic.biomtMatrices !== undefined && ic.biomtMatrices.length * ic.cnt > 10 * ic.maxatomcnt) {
77351
77360
  ic.cam.right = ic.maxD/2 * 1.5;
77352
77361
  }
@@ -77358,12 +77367,12 @@ class Camera {
77358
77367
  ic.cam.top = ic.cam.right /ic.container.whratio;
77359
77368
  ic.cam.bottom = -ic.cam.right /ic.container.whratio;
77360
77369
 
77361
- if(ic.opts['slab'] === 'yes') {
77362
- ic.cam.near = ic.maxD * 2;
77363
- }
77364
- else {
77370
+ // if(ic.opts['slab'] === 'yes') {
77371
+ // ic.cam.near = ic.maxD * 2;
77372
+ // }
77373
+ // else {
77365
77374
  ic.cam.near = 0;
77366
- }
77375
+ // }
77367
77376
 
77368
77377
  ic.cam.far = 10000;
77369
77378
 
@@ -77385,6 +77394,85 @@ class Camera {
77385
77394
  ic.cam.updateProjectionMatrix();
77386
77395
  // }
77387
77396
  }
77397
+
77398
+ setSlab() { let ic = this.icn3d, me = ic.icn3dui;
77399
+ if(ic.bControlGl && !me.bNode) {
77400
+ let maxD = ic.maxD;
77401
+
77402
+ // if(window.cam === ic.perspectiveCamera) {
77403
+ if(ic.opts.camera.toLowerCase() == 'perspective') {
77404
+ let bInstance = (ic.biomtMatrices !== undefined && ic.biomtMatrices.length * ic.cnt > ic.maxatomcnt) ? true : false;
77405
+
77406
+ if(ic.opts['slab'] === 'yes') {
77407
+ if(bInstance) {
77408
+ window.cam.near = 0.1;
77409
+ }
77410
+ else if(window.camMaxDFactorFog !== undefined) {
77411
+ window.cam.near = maxD * window.camMaxDFactorFog - 10; // keep some surrounding residues
77412
+ }
77413
+ else {
77414
+ window.cam.near = maxD * window.camMaxDFactor;
77415
+ }
77416
+ }
77417
+ else {
77418
+ window.cam.near = 0.1;
77419
+ }
77420
+ }
77421
+ // else if (window.cam === ic.orthographicCamera){
77422
+ else if(ic.opts.camera.toLowerCase() == 'orthographic') {
77423
+ if(ic.opts['slab'] === 'yes') {
77424
+ window.cam.near = ic.maxD * 2;
77425
+ }
77426
+ else {
77427
+ window.cam.near = 0;
77428
+ }
77429
+
77430
+ window.cam.far = 10000;
77431
+ }
77432
+
77433
+ window.cam.updateProjectionMatrix();
77434
+ }
77435
+ // else {
77436
+ // also set its own camera for picking purpose
77437
+
77438
+ let maxD = ic.maxD;
77439
+
77440
+ // if(ic.cam === ic.perspectiveCamera) {
77441
+ if(ic.opts.camera.toLowerCase() == 'perspective') {
77442
+ let bInstance = (ic.biomtMatrices !== undefined && ic.biomtMatrices.length * ic.cnt > ic.maxatomcnt) ? true : false;
77443
+
77444
+ if(ic.opts['slab'] === 'yes') {
77445
+ if(bInstance) {
77446
+ ic.cam.near = 0.1;
77447
+ }
77448
+ else if(ic.camMaxDFactorFog !== undefined) {
77449
+ ic.cam.near = maxD * ic.camMaxDFactorFog - 10; // keep some surrounding residues
77450
+ }
77451
+ else {
77452
+ ic.cam.near = maxD * ic.camMaxDFactor;
77453
+ }
77454
+ }
77455
+ else {
77456
+ ic.cam.near = 0.1;
77457
+ }
77458
+ }
77459
+ // else if (ic.cam === ic.orthographicCamera){
77460
+ else if(ic.opts.camera.toLowerCase() == 'orthographic') {
77461
+ if(ic.opts['slab'] === 'yes') {
77462
+ ic.cam.near = ic.maxD * 2;
77463
+ }
77464
+ else {
77465
+ ic.cam.near = 0;
77466
+ }
77467
+
77468
+ ic.cam.far = 10000;
77469
+ }
77470
+
77471
+ // ic.cam.add(ic.directionalLight);
77472
+
77473
+ ic.cam.updateProjectionMatrix();
77474
+ // }
77475
+ }
77388
77476
  }
77389
77477
 
77390
77478
  /**
@@ -93521,7 +93609,7 @@ class AnnoSnpClinVar {
93521
93609
  let snpResn = snpStr.substr(posSymbol - 1, 1);
93522
93610
  let atom = ic.firstAtomObjCls.getFirstAtomObj(ic.residues[chnid + '_' + realResi]);
93523
93611
  let oneLetterRes = (atom) ? me.utilsCls.residueName2Abbr(atom.resn.substr(0, 3)) : '';
93524
- if(!bFromClinVarDb) {
93612
+ if(!bFromClinVarDb && ic.chainsSeq[chnid][resi - 1]) {
93525
93613
  oneLetterRes = ic.chainsSeq[chnid][resi - 1].name;
93526
93614
  }
93527
93615
 
@@ -106393,11 +106481,14 @@ class MmcifParser {
106393
106481
  let mat4 = new Matrix4$1();
106394
106482
  mat4.fromArray(data.assembly[i]);
106395
106483
 
106396
- ic.biomtMatrices[i] = mat4;
106484
+ // sometimes an extra matrix as included, e.g., PDb ID 2GTL
106485
+ if(i == 0 && data.assembly[i][0] != 1) continue;
106486
+
106487
+ ic.biomtMatrices.push(mat4);
106397
106488
  }
106398
106489
 
106399
106490
  ic.asuCnt = ic.biomtMatrices.length;
106400
-
106491
+
106401
106492
  // show bioassembly
106402
106493
  if(me.cfg.bu == 1 && Object.keys(ic.atoms).length * ic.asuCnt > ic.maxatomcnt) {
106403
106494
  ic.bAssembly = true;
@@ -119650,19 +119741,7 @@ class LoadScript {
119650
119741
  updateTransformation(steps) { let ic = this.icn3d; ic.icn3dui;
119651
119742
  let commandTransformation = (ic.commands[steps-1]) ? ic.commands[steps-1].split('|||') : [];
119652
119743
 
119653
- if(commandTransformation.length == 2) {
119654
- let transformation = JSON.parse(commandTransformation[1]);
119655
-
119656
- ic._zoomFactor = transformation.factor;
119657
-
119658
- ic.mouseChange.x = transformation.mouseChange.x;
119659
- ic.mouseChange.y = transformation.mouseChange.y;
119660
-
119661
- ic.quaternion._x = transformation.quaternion._x;
119662
- ic.quaternion._y = transformation.quaternion._y;
119663
- ic.quaternion._z = transformation.quaternion._z;
119664
- ic.quaternion._w = transformation.quaternion._w;
119665
- }
119744
+ ic.transformCls.resetOrientation_base(commandTransformation);
119666
119745
 
119667
119746
  // ic.bRender = true;
119668
119747
  ic.drawCls.draw();
@@ -120444,19 +120523,17 @@ class LoadScript {
120444
120523
 
120445
120524
  let commandTransformation = (ic.commands[steps-1]) ? ic.commands[steps-1].split('|||') : [];
120446
120525
 
120447
- if(commandTransformation.length == 2) {
120448
- let transformation = JSON.parse(commandTransformation[1]);
120526
+ // load a URL with trackball transformation, or no info after "|||"
120527
+ if(commandTransformation.length != 2 || (commandTransformation.length == 2 && commandTransformation[1].substr(0,1) == '{')) {
120528
+ ic.bSetCamera = true;
120529
+ }
120530
+ else {
120531
+ ic.bSetCamera = false;
120532
+ }
120449
120533
 
120450
- ic._zoomFactor = transformation.factor;
120534
+ if(commandTransformation.length == 2 && commandTransformation[1].substr(0,1) == '{') ic.bTransformation = true;
120451
120535
 
120452
- ic.mouseChange.x = transformation.mouseChange.x;
120453
- ic.mouseChange.y = transformation.mouseChange.y;
120454
-
120455
- ic.quaternion._x = transformation.quaternion._x;
120456
- ic.quaternion._y = transformation.quaternion._y;
120457
- ic.quaternion._z = transformation.quaternion._z;
120458
- ic.quaternion._w = transformation.quaternion._w;
120459
- }
120536
+ ic.transformCls.resetOrientation_base(commandTransformation);
120460
120537
 
120461
120538
  ic.selectionCls.oneStructurePerWindow();
120462
120539
 
@@ -128858,13 +128935,9 @@ class Transform {
128858
128935
  this.icn3d = icn3d;
128859
128936
  }
128860
128937
 
128861
- //Set the orientation to the original one, but leave the style, color, etc alone.
128862
- resetOrientation() { let ic = this.icn3d; ic.icn3dui;
128863
- let bSet = false;
128864
- if(ic.commands.length > 0) {
128865
- let commandTransformation = ic.commands[0].split('|||');
128866
-
128867
- if(commandTransformation.length == 2) {
128938
+ resetOrientation_base(commandTransformation) { let ic = this.icn3d; ic.icn3dui;
128939
+ if(commandTransformation.length == 2 && commandTransformation[1].length > 0) {
128940
+ if(ic.bSetCamera) { // |||{"factor"...}
128868
128941
  let transformation = JSON.parse(commandTransformation[1]);
128869
128942
 
128870
128943
  ic._zoomFactor = transformation.factor;
@@ -128876,16 +128949,46 @@ class Transform {
128876
128949
  ic.quaternion._y = transformation.quaternion._y;
128877
128950
  ic.quaternion._z = transformation.quaternion._z;
128878
128951
  ic.quaternion._w = transformation.quaternion._w;
128952
+ bSet1 = true;
128953
+ }
128954
+ else { // |||pos:a,b,c|dir:a,b,c|up:a,b,c|fov:a
128955
+ let bcfArray = commandTransformation[1].split('|');
128956
+ bcfArray.forEach(item => {
128957
+ let itemArray = item.split(':');
128958
+ if(itemArray[0] == 'fov') {
128959
+ ic.cam.fov = parseFloat(itemArray[1]);
128960
+ }
128961
+ else {
128962
+ let abc = itemArray[1].split(',');
128963
+ if(itemArray[0] == 'pos') {
128964
+ ic.cam.position.set(parseFloat(abc[0]), parseFloat(abc[1]), parseFloat(abc[2]));
128965
+ }
128966
+ else if(itemArray[0] == 'dir') {
128967
+ ic.cam.quaternion.setFromUnitVectors(new Vector3$1(0, 0, -1), new Vector3$1(parseFloat(abc[0]), parseFloat(abc[1]), parseFloat(abc[2])));
128968
+ }
128969
+ else if(itemArray[0] == 'up') {
128970
+ ic.cam.up.set(parseFloat(abc[0]), parseFloat(abc[1]), parseFloat(abc[2]));
128971
+ }
128972
+ }
128973
+ });
128974
+
128879
128975
 
128880
- bSet = true;
128881
128976
  }
128882
128977
  }
128883
-
128884
- if(!bSet) {
128978
+ else {
128885
128979
  ic._zoomFactor = 1.0;
128886
128980
  ic.mouseChange = new Vector2$1(0,0);
128887
128981
  ic.quaternion = new Quaternion(0,0,0,1);
128888
128982
  }
128983
+ }
128984
+
128985
+ //Set the orientation to the original one, but leave the style, color, etc alone.
128986
+ resetOrientation() { let ic = this.icn3d; ic.icn3dui;
128987
+ if(ic.commands.length > 0) {
128988
+ let commandTransformation = ic.commands[0].split('|||');
128989
+
128990
+ this.resetOrientation_base(commandTransformation);
128991
+ }
128889
128992
 
128890
128993
  //reset ic.maxD
128891
128994
  ic.maxD = ic.oriMaxD;
@@ -129115,25 +129218,43 @@ class Transform {
129115
129218
  }
129116
129219
 
129117
129220
  getTransformationStr(transformation) {var ic = this.icn3d; ic.icn3dui;
129118
- let transformation2 = {"factor": 1.0, "mouseChange": {"x": 0, "y": 0}, "quaternion": {"_x": 0, "_y": 0, "_z": 0, "_w": 1} };
129119
- transformation2.factor = parseFloat(transformation.factor).toPrecision(4);
129120
- transformation2.mouseChange.x = parseFloat(transformation.mouseChange.x).toPrecision(4);
129121
- transformation2.mouseChange.y = parseFloat(transformation.mouseChange.y).toPrecision(4);
129122
- transformation2.quaternion._x = parseFloat(transformation.quaternion._x).toPrecision(4);
129123
- transformation2.quaternion._y = parseFloat(transformation.quaternion._y).toPrecision(4);
129124
- transformation2.quaternion._z = parseFloat(transformation.quaternion._z).toPrecision(4);
129125
- transformation2.quaternion._w = parseFloat(transformation.quaternion._w).toPrecision(4);
129126
-
129127
- if(transformation2.factor == '1.0000') transformation2.factor = 1;
129128
- if(transformation2.mouseChange.x == '0.0000') transformation2.mouseChange.x = 0;
129129
- if(transformation2.mouseChange.y == '0.0000') transformation2.mouseChange.y = 0;
129130
-
129131
- if(transformation2.quaternion._x == '0.0000') transformation2.quaternion._x = 0;
129132
- if(transformation2.quaternion._y == '0.0000') transformation2.quaternion._y = 0;
129133
- if(transformation2.quaternion._z == '0.0000') transformation2.quaternion._z = 0;
129134
- if(transformation2.quaternion._w == '1.0000') transformation2.quaternion._w = 1;
129135
-
129136
- return JSON.stringify(transformation2);
129221
+ if(ic.bTransformation) {
129222
+ let transformation2 = {"factor": 1.0, "mouseChange": {"x": 0, "y": 0}, "quaternion": {"_x": 0, "_y": 0, "_z": 0, "_w": 1} };
129223
+ transformation2.factor = parseFloat(transformation.factor).toPrecision(4);
129224
+ transformation2.mouseChange.x = parseFloat(transformation.mouseChange.x).toPrecision(4);
129225
+ transformation2.mouseChange.y = parseFloat(transformation.mouseChange.y).toPrecision(4);
129226
+ transformation2.quaternion._x = parseFloat(transformation.quaternion._x).toPrecision(4);
129227
+ transformation2.quaternion._y = parseFloat(transformation.quaternion._y).toPrecision(4);
129228
+ transformation2.quaternion._z = parseFloat(transformation.quaternion._z).toPrecision(4);
129229
+ transformation2.quaternion._w = parseFloat(transformation.quaternion._w).toPrecision(4);
129230
+
129231
+ if(transformation2.factor == '1.0000') transformation2.factor = 1;
129232
+ if(transformation2.mouseChange.x == '0.0000') transformation2.mouseChange.x = 0;
129233
+ if(transformation2.mouseChange.y == '0.0000') transformation2.mouseChange.y = 0;
129234
+
129235
+ if(transformation2.quaternion._x == '0.0000') transformation2.quaternion._x = 0;
129236
+ if(transformation2.quaternion._y == '0.0000') transformation2.quaternion._y = 0;
129237
+ if(transformation2.quaternion._z == '0.0000') transformation2.quaternion._z = 0;
129238
+ if(transformation2.quaternion._w == '1.0000') transformation2.quaternion._w = 1;
129239
+
129240
+ return JSON.stringify(transformation2);
129241
+ }
129242
+ else if(ic.cam) {
129243
+ // |||pos:a,b,c|dir:a,b,c|up:a,b,c|fov:a
129244
+ let str = '';
129245
+ str += 'pos:' + ic.cam.position.x.toPrecision(4) + ',' + ic.cam.position.y.toPrecision(4) + ',' + ic.cam.position.z.toPrecision(4);
129246
+
129247
+ let direction = (new Vector3$1(0, 0, -1)).applyQuaternion(ic.cam.quaternion);
129248
+ str += '|dir:' + direction.x.toPrecision(4) + ',' + direction.y.toPrecision(4) + ',' + direction.z.toPrecision(4);
129249
+
129250
+ str += '|up:' + ic.cam.up.x.toPrecision(4) + ',' + ic.cam.up.y.toPrecision(4) + ',' + ic.cam.up.z.toPrecision(4);
129251
+ str += '|fov:' + ic.cam.fov.toPrecision(4);
129252
+
129253
+ return str;
129254
+ }
129255
+ else {
129256
+ return '';
129257
+ }
129137
129258
  }
129138
129259
  }
129139
129260
 
@@ -132048,38 +132169,14 @@ class Picking {
132048
132169
  else {
132049
132170
  // highlight the sequence background
132050
132171
  ic.hlUpdateCls.updateHlAll();
132051
- let transformation = {};
132052
- transformation.factor = ic._zoomFactor;
132053
- transformation.mouseChange = ic.mouseChange;
132054
- //transformation.quaternion = ic.quaternion;
132055
- transformation.quaternion = {};
132056
- transformation.quaternion._x = parseFloat(ic.quaternion._x).toPrecision(5);
132057
- transformation.quaternion._y = parseFloat(ic.quaternion._y).toPrecision(5);
132058
- transformation.quaternion._z = parseFloat(ic.quaternion._z).toPrecision(5);
132059
- transformation.quaternion._w = parseFloat(ic.quaternion._w).toPrecision(5);
132060
-
132061
- /*
132062
- if(ic.bAddCommands) {
132063
- ic.commands.push('pickatom ' + atom.serial + '|||' + ic.transformCls.getTransformationStr(transformation));
132064
- ic.optsHistory.push(me.hashUtilsCls.cloneHash(ic.opts));
132065
- ic.optsHistory[ic.optsHistory.length - 1].hlatomcount = Object.keys(ic.hAtoms).length;
132066
- if(me.utilsCls.isSessionStorageSupported()) ic.setStyleCls.saveCommandsToSession();
132067
- ic.STATENUMBER = ic.commands.length;
132068
- }
132069
- ic.logs.push('pickatom ' + atom.serial + '(chain: ' + atom.structure + '_' + atom.chain + ', residue: ' + atom.resn + ', number: ' + atom.resi + ', atom: ' + atom.name + ')');
132070
- if( $( "#" + ic.pre + "logtext" ).length ) {
132071
- $("#" + ic.pre + "logtext").val("> " + ic.logs.join("\n> ") + "\n> ").scrollTop($("#" + ic.pre + "logtext")[0].scrollHeight);
132072
- }
132073
- */
132172
+
132074
132173
  me.htmlCls.clickMenuCls.setLogCmd('pickatom ' + atom.serial, true);
132075
132174
 
132076
132175
  ic.selectionCls.saveSelInCommand();
132077
132176
 
132078
132177
  // update the interaction flag
132079
132178
  ic.bSphereCalc = false;
132080
- //me.htmlCls.clickMenuCls.setLogCmd('set calculate sphere false', true);
132081
132179
  ic.bHbondCalc = false;
132082
- //me.htmlCls.clickMenuCls.setLogCmd('set calculate hbond false', true);
132083
132180
  }
132084
132181
  }
132085
132182
  }
@@ -132873,6 +132970,8 @@ class iCn3D {
132873
132970
 
132874
132971
  this.bUsePdbNum = true;
132875
132972
 
132973
+ this.bSetCamera = true;
132974
+
132876
132975
  let bWebGL, bWebGL2, bVR;
132877
132976
  if(!this.icn3dui.bNode) {
132878
132977
  let canvas = document.createElement( 'canvas' );
@@ -133572,10 +133671,10 @@ class iCn3DUI {
133572
133671
  //even when multiple iCn3D viewers are shown together.
133573
133672
  this.pre = this.cfg.divid + "_";
133574
133673
 
133575
- this.REVISION = '3.44.2';
133674
+ this.REVISION = '3.45.0';
133576
133675
 
133577
- // In nodejs, iCn3D defines "window = {navigator: {}}"
133578
- this.bNode = (Object.keys(window).length < 2) ? true : false;
133676
+ // In nodejs, iCn3D defines "window = {navigator: {}}", and added window = {navigator: {}, "__THREE__":"177"}
133677
+ this.bNode = (Object.keys(window).length < 3) ? true : false;
133579
133678
 
133580
133679
  if(this.cfg.command === undefined) this.cfg.command = '';
133581
133680
  if(this.cfg.width === undefined) this.cfg.width = '100%';