Threejs shader error

Hi Threejs Team,

I am trying 3d Testing in my machine and I a finding errors when I am trying to load same file repeatedly by navigating between 3d files . My testing scenaio Product A has 3d file(14MB), Product B has 3d file(38MB) and Product C has 3d file (76MB) . Now i am trying to repeatedly testing this file by navigating between them in this sequence ProductA → ProductB → ProductC. While this 3d files renders for first and second round of testing. It throws a big fat error in error logs and 3 warning in warnings logs. I am not able to figure out how to resolve this as this issue is more frequent in bigger files as compare to smaller files.

Error logs:

THREE.WebGLShader: gl.getShaderInfoLog() fragment
1: #version 300 es
2: #define varying in
3: out highp vec4 pc_fragColor;
4: #define gl_FragColor pc_fragColor
5: #define gl_FragDepthEXT gl_FragDepth
6: #define texture2D texture
7: #define textureCube texture
8: #define texture2DProj textureProj
9: #define texture2DLodEXT textureLod
10: #define texture2DProjLodEXT textureProjLod
11: #define textureCubeLodEXT textureLod
12: #define texture2DGradEXT textureGrad
13: #define texture2DProjGradEXT textureProjGrad
14: #define textureCubeGradEXT textureGrad
15: precision highp float;
16: precision highp int;
17: #define HIGH_PRECISION
18: #define SHADER_NAME ShadowMaterial
19: #define GAMMA_FACTOR 2
20: #define USE_SHADOWMAP
21: #define SHADOWMAP_TYPE_PCF_SOFT
22: uniform mat4 viewMatrix;
23: uniform vec3 cameraPosition;
24: uniform bool isOrthographic;
25: 
26: vec4 LinearToLinear( in vec4 value ) {
27: 	return value;
28: }
29: vec4 GammaToLinear( in vec4 value, in float gammaFactor ) {
30: 	return vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );
31: }
32: vec4 LinearToGamma( in vec4 value, in float gammaFactor ) {
33: 	return vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );
34: }
35: vec4 sRGBToLinear( in vec4 value ) {
36: 	return 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.a );
37: }
38: vec4 LinearTosRGB( in vec4 value ) {
39: 	return 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.a );
40: }
41: vec4 RGBEToLinear( in vec4 value ) {
42: 	return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );
43: }
44: vec4 LinearToRGBE( in vec4 value ) {
45: 	float maxComponent = max( max( value.r, value.g ), value.b );
46: 	float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );
47: 	return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );
48: }
49: vec4 RGBMToLinear( in vec4 value, in float maxRange ) {
50: 	return vec4( value.rgb * value.a * maxRange, 1.0 );
51: }
52: vec4 LinearToRGBM( in vec4 value, in float maxRange ) {
53: 	float maxRGB = max( value.r, max( value.g, value.b ) );
54: 	float M = clamp( maxRGB / maxRange, 0.0, 1.0 );
55: 	M = ceil( M * 255.0 ) / 255.0;
56: 	return vec4( value.rgb / ( M * maxRange ), M );
57: }
58: vec4 RGBDToLinear( in vec4 value, in float maxRange ) {
59: 	return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );
60: }
61: vec4 LinearToRGBD( in vec4 value, in float maxRange ) {
62: 	float maxRGB = max( value.r, max( value.g, value.b ) );
63: 	float D = max( maxRange / maxRGB, 1.0 );
64: 	D = clamp( floor( D ) / 255.0, 0.0, 1.0 );
65: 	return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );
66: }
67: const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );
68: vec4 LinearToLogLuv( in vec4 value ) {
69: 	vec3 Xp_Y_XYZp = cLogLuvM * value.rgb;
70: 	Xp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );
71: 	vec4 vResult;
72: 	vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;
73: 	float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;
74: 	vResult.w = fract( Le );
75: 	vResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;
76: 	return vResult;
77: }
78: const mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );
79: vec4 LogLuvToLinear( in vec4 value ) {
80: 	float Le = value.z * 255.0 + value.w;
81: 	vec3 Xp_Y_XYZp;
82: 	Xp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );
83: 	Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;
84: 	Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;
85: 	vec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;
86: 	return vec4( max( vRGB, 0.0 ), 1.0 );
87: }
88: vec4 linearToOutputTexel( vec4 value ) { return LinearTosRGB( value ); }
89: 
90: uniform vec3 color;
91: uniform float opacity;
92: #define PI 3.141592653589793
93: #define PI2 6.283185307179586
94: #define PI_HALF 1.5707963267948966
95: #define RECIPROCAL_PI 0.3183098861837907
96: #define RECIPROCAL_PI2 0.15915494309189535
97: #define EPSILON 1e-6
98: #ifndef saturate
99: #define saturate(a) clamp( a, 0.0, 1.0 )
100: #endif
101: #define whiteComplement(a) ( 1.0 - saturate( a ) )
102: float pow2( const in float x ) { return x*x; }
103: float pow3( const in float x ) { return x*x*x; }
104: float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
105: float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }
106: highp float rand( const in vec2 uv ) {
107: 	const highp float a = 12.9898, b = 78.233, c = 43758.5453;
108: 	highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
109: 	return fract(sin(sn) * c);
110: }
111: #ifdef HIGH_PRECISION
112: 	float precisionSafeLength( vec3 v ) { return length( v ); }
113: #else
114: 	float max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }
115: 	float precisionSafeLength( vec3 v ) {
116: 		float maxComponent = max3( abs( v ) );
117: 		return length( v / maxComponent ) * maxComponent;
118: 	}
119: #endif
120: struct IncidentLight {
121: 	vec3 color;
122: 	vec3 direction;
123: 	bool visible;
124: };
125: struct ReflectedLight {
126: 	vec3 directDiffuse;
127: 	vec3 directSpecular;
128: 	vec3 indirectDiffuse;
129: 	vec3 indirectSpecular;
130: };
131: struct GeometricContext {
132: 	vec3 position;
133: 	vec3 normal;
134: 	vec3 viewDir;
135: #ifdef CLEARCOAT
136: 	vec3 clearcoatNormal;
137: #endif
138: };
139: vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
140: 	return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
141: }
142: vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
143: 	return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
144: }
145: vec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
146: 	float distance = dot( planeNormal, point - pointOnPlane );
147: 	return - distance * planeNormal + point;
148: }
149: float sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
150: 	return sign( dot( point - pointOnPlane, planeNormal ) );
151: }
152: vec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {
153: 	return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;
154: }
155: mat3 transposeMat3( const in mat3 m ) {
156: 	mat3 tmp;
157: 	tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
158: 	tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
159: 	tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
160: 	return tmp;
161: }
162: float linearToRelativeLuminance( const in vec3 color ) {
163: 	vec3 weights = vec3( 0.2126, 0.7152, 0.0722 );
164: 	return dot( weights, color.rgb );
165: }
166: bool isPerspectiveMatrix( mat4 m ) {
167: 	return m[ 2 ][ 3 ] == - 1.0;
168: }
169: vec2 equirectUv( in vec3 dir ) {
170: 	float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
171: 	float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
172: 	return vec2( u, v );
173: }
174: vec3 packNormalToRGB( const in vec3 normal ) {
175: 	return normalize( normal ) * 0.5 + 0.5;
176: }
177: vec3 unpackRGBToNormal( const in vec3 rgb ) {
178: 	return 2.0 * rgb.xyz - 1.0;
179: }
180: const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
181: const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
182: const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
183: const float ShiftRight8 = 1. / 256.;
184: vec4 packDepthToRGBA( const in float v ) {
185: 	vec4 r = vec4( fract( v * PackFactors ), v );
186: 	r.yzw -= r.xyz * ShiftRight8;	return r * PackUpscale;
187: }
188: float unpackRGBAToDepth( const in vec4 v ) {
189: 	return dot( v, UnpackFactors );
190: }
191: vec4 pack2HalfToRGBA( vec2 v ) {
192: 	vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));
193: 	return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);
194: }
195: vec2 unpackRGBATo2Half( vec4 v ) {
196: 	return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
197: }
198: float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
199: 	return ( viewZ + near ) / ( near - far );
200: }
201: float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {
202: 	return linearClipZ * ( near - far ) - near;
203: }
204: float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
205: 	return (( near + viewZ ) * far ) / (( far - near ) * viewZ );
206: }
207: float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {
208: 	return ( near * far ) / ( ( far - near ) * invClipZ - far );
209: }
210: #ifdef USE_FOG
211: 	uniform vec3 fogColor;
212: 	varying float fogDepth;
213: 	#ifdef FOG_EXP2
214: 		uniform float fogDensity;
215: 	#else
216: 		uniform float fogNear;
217: 		uniform float fogFar;
218: 	#endif
219: #endif
220: vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {
221: 	const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
222: 	const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
223: 	vec4 r = roughness * c0 + c1;
224: 	float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
225: 	return vec2( -1.04, 1.04 ) * a004 + r.zw;
226: }
227: float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
228: #if defined ( PHYSICALLY_CORRECT_LIGHTS )
229: 	float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
230: 	if( cutoffDistance > 0.0 ) {
231: 		distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
232: 	}
233: 	return distanceFalloff;
234: #else
235: 	if( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
236: 		return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );
237: 	}
238: 	return 1.0;
239: #endif
240: }
241: vec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {
242: 	return RECIPROCAL_PI * diffuseColor;
243: }
244: vec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {
245: 	float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );
246: 	return ( 1.0 - specularColor ) * fresnel + specularColor;
247: }
248: vec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {
249: 	float fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );
250: 	vec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;
251: 	return Fr * fresnel + F0;
252: }
253: float G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {
254: 	float a2 = pow2( alpha );
255: 	float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
256: 	float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
257: 	return 1.0 / ( gl * gv );
258: }
259: float G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
260: 	float a2 = pow2( alpha );
261: 	float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
262: 	float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
263: 	return 0.5 / max( gv + gl, EPSILON );
264: }
265: float D_GGX( const in float alpha, const in float dotNH ) {
266: 	float a2 = pow2( alpha );
267: 	float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
268: 	return RECIPROCAL_PI * a2 / pow2( denom );
269: }
270: vec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {
271: 	float alpha = pow2( roughness );
272: 	vec3 halfDir = normalize( incidentLight.direction + viewDir );
273: 	float dotNL = saturate( dot( normal, incidentLight.direction ) );
274: 	float dotNV = saturate( dot( normal, viewDir ) );
275: 	float dotNH = saturate( dot( normal, halfDir ) );
276: 	float dotLH = saturate( dot( incidentLight.direction, halfDir ) );
277: 	vec3 F = F_Schlick( specularColor, dotLH );
278: 	float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );
279: 	float D = D_GGX( alpha, dotNH );
280: 	return F * ( G * D );
281: }
282: vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
283: 	const float LUT_SIZE = 64.0;
284: 	const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
285: 	const float LUT_BIAS = 0.5 / LUT_SIZE;
286: 	float dotNV = saturate( dot( N, V ) );
287: 	vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
288: 	uv = uv * LUT_SCALE + LUT_BIAS;
289: 	return uv;
290: }
291: float LTC_ClippedSphereFormFactor( const in vec3 f ) {
292: 	float l = length( f );
293: 	return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
294: }
295: vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
296: 	float x = dot( v1, v2 );
297: 	float y = abs( x );
298: 	float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
299: 	float b = 3.4175940 + ( 4.1616724 + y ) * y;
300: 	float v = a / b;
301: 	float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
302: 	return cross( v1, v2 ) * theta_sintheta;
303: }
304: vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
305: 	vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
306: 	vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
307: 	vec3 lightNormal = cross( v1, v2 );
308: 	if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
309: 	vec3 T1, T2;
310: 	T1 = normalize( V - N * dot( V, N ) );
311: 	T2 = - cross( N, T1 );
312: 	mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
313: 	vec3 coords[ 4 ];
314: 	coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
315: 	coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
316: 	coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
317: 	coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
318: 	coords[ 0 ] = normalize( coords[ 0 ] );
319: 	coords[ 1 ] = normalize( coords[ 1 ] );
320: 	coords[ 2 ] = normalize( coords[ 2 ] );
321: 	coords[ 3 ] = normalize( coords[ 3 ] );
322: 	vec3 vectorFormFactor = vec3( 0.0 );
323: 	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
324: 	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
325: 	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
326: 	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
327: 	float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
328: 	return vec3( result );
329: }
330: vec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {
331: 	float dotNV = saturate( dot( normal, viewDir ) );
332: 	vec2 brdf = integrateSpecularBRDF( dotNV, roughness );
333: 	return specularColor * brdf.x + brdf.y;
334: }
335: void BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
336: 	float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
337: 	vec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );
338: 	vec2 brdf = integrateSpecularBRDF( dotNV, roughness );
339: 	vec3 FssEss = F * brdf.x + brdf.y;
340: 	float Ess = brdf.x + brdf.y;
341: 	float Ems = 1.0 - Ess;
342: 	vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;	vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
343: 	singleScatter += FssEss;
344: 	multiScatter += Fms * Ems;
345: }
346: float G_BlinnPhong_Implicit( ) {
347: 	return 0.25;
348: }
349: float D_BlinnPhong( const in float shininess, const in float dotNH ) {
350: 	return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
351: }
352: vec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {
353: 	vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );
354: 	float dotNH = saturate( dot( geometry.normal, halfDir ) );
355: 	float dotLH = saturate( dot( incidentLight.direction, halfDir ) );
356: 	vec3 F = F_Schlick( specularColor, dotLH );
357: 	float G = G_BlinnPhong_Implicit( );
358: 	float D = D_BlinnPhong( shininess, dotNH );
359: 	return F * ( G * D );
360: }
361: float GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {
362: 	return ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );
363: }
364: float BlinnExponentToGGXRoughness( const in float blinnExponent ) {
365: 	return sqrt( 2.0 / ( blinnExponent + 2.0 ) );
366: }
367: #if defined( USE_SHEEN )
368: float D_Charlie(float roughness, float NoH) {
369: 	float invAlpha = 1.0 / roughness;
370: 	float cos2h = NoH * NoH;
371: 	float sin2h = max(1.0 - cos2h, 0.0078125);	return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);
372: }
373: float V_Neubelt(float NoV, float NoL) {
374: 	return saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));
375: }
376: vec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {
377: 	vec3 N = geometry.normal;
378: 	vec3 V = geometry.viewDir;
379: 	vec3 H = normalize( V + L );
380: 	float dotNH = saturate( dot( N, H ) );
381: 	return specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );
382: }
383: #endif
384: uniform bool receiveShadow;
385: uniform vec3 ambientLightColor;
386: uniform vec3 lightProbe[ 9 ];
387: vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
388: 	float x = normal.x, y = normal.y, z = normal.z;
389: 	vec3 result = shCoefficients[ 0 ] * 0.886227;
390: 	result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
391: 	result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
392: 	result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
393: 	result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
394: 	result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
395: 	result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
396: 	result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
397: 	result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
398: 	return result;
399: }
400: vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {
401: 	vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
402: 	vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
403: 	return irradiance;
404: }
405: vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
406: 	vec3 irradiance = ambientLightColor;
407: 	#ifndef PHYSICALLY_CORRECT_LIGHTS
408: 		irradiance *= PI;
409: 	#endif
410: 	return irradiance;
411: }
412: #if 0 > 0
413: 	struct DirectionalLight {
414: 		vec3 direction;
415: 		vec3 color;
416: 	};
417: 	uniform DirectionalLight directionalLights[ 0 ];
418: 	void getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {
419: 		directLight.color = directionalLight.color;
420: 		directLight.direction = directionalLight.direction;
421: 		directLight.visible = true;
422: 	}
423: #endif
424: #if 0 > 0
425: 	struct PointLight {
426: 		vec3 position;
427: 		vec3 color;
428: 		float distance;
429: 		float decay;
430: 	};
431: 	uniform PointLight pointLights[ 0 ];
432: 	void getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {
433: 		vec3 lVector = pointLight.position - geometry.position;
434: 		directLight.direction = normalize( lVector );
435: 		float lightDistance = length( lVector );
436: 		directLight.color = pointLight.color;
437: 		directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );
438: 		directLight.visible = ( directLight.color != vec3( 0.0 ) );
439: 	}
440: #endif
441: #if 1 > 0
442: 	struct SpotLight {
443: 		vec3 position;
444: 		vec3 direction;
445: 		vec3 color;
446: 		float distance;
447: 		float decay;
448: 		float coneCos;
449: 		float penumbraCos;
450: 	};
451: 	uniform SpotLight spotLights[ 1 ];
452: 	void getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {
453: 		vec3 lVector = spotLight.position - geometry.position;
454: 		directLight.direction = normalize( lVector );
455: 		float lightDistance = length( lVector );
456: 		float angleCos = dot( directLight.direction, spotLight.direction );
457: 		if ( angleCos > spotLight.coneCos ) {
458: 			float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );
459: 			directLight.color = spotLight.color;
460: 			directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );
461: 			directLight.visible = true;
462: 		} else {
463: 			directLight.color = vec3( 0.0 );
464: 			directLight.visible = false;
465: 		}
466: 	}
467: #endif
468: #if 0 > 0
469: 	struct RectAreaLight {
470: 		vec3 color;
471: 		vec3 position;
472: 		vec3 halfWidth;
473: 		vec3 halfHeight;
474: 	};
475: 	uniform sampler2D ltc_1;	uniform sampler2D ltc_2;
476: 	uniform RectAreaLight rectAreaLights[ 0 ];
477: #endif
478: #if 0 > 0
479: 	struct HemisphereLight {
480: 		vec3 direction;
481: 		vec3 skyColor;
482: 		vec3 groundColor;
483: 	};
484: 	uniform HemisphereLight hemisphereLights[ 0 ];
485: 	vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {
486: 		float dotNL = dot( geometry.normal, hemiLight.direction );
487: 		float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
488: 		vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
489: 		#ifndef PHYSICALLY_CORRECT_LIGHTS
490: 			irradiance *= PI;
491: 		#endif
492: 		return irradiance;
493: 	}
494: #endif
495: #ifdef USE_SHADOWMAP
496: 	#if 0 > 0
497: 		uniform sampler2D directionalShadowMap[ 0 ];
498: 		varying vec4 vDirectionalShadowCoord[ 0 ];
499: 		struct DirectionalLightShadow {
500: 			float shadowBias;
501: 			float shadowNormalBias;
502: 			float shadowRadius;
503: 			vec2 shadowMapSize;
504: 		};
505: 		uniform DirectionalLightShadow directionalLightShadows[ 0 ];
506: 	#endif
507: 	#if 1 > 0
508: 		uniform sampler2D spotShadowMap[ 1 ];
509: 		varying vec4 vSpotShadowCoord[ 1 ];
510: 		struct SpotLightShadow {
511: 			float shadowBias;
512: 			float shadowNormalBias;
513: 			float shadowRadius;
514: 			vec2 shadowMapSize;
515: 		};
516: 		uniform SpotLightShadow spotLightShadows[ 1 ];
517: 	#endif
518: 	#if 0 > 0
519: 		uniform sampler2D pointShadowMap[ 0 ];
520: 		varying vec4 vPointShadowCoord[ 0 ];
521: 		struct PointLightShadow {
522: 			float shadowBias;
523: 			float shadowNormalBias;
524: 			float shadowRadius;
525: 			vec2 shadowMapSize;
526: 			float shadowCameraNear;
527: 			float shadowCameraFar;
528: 		};
529: 		uniform PointLightShadow pointLightShadows[ 0 ];
530: 	#endif
531: 	float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
532: 		return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
533: 	}
534: 	vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
535: 		return unpackRGBATo2Half( texture2D( shadow, uv ) );
536: 	}
537: 	float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
538: 		float occlusion = 1.0;
539: 		vec2 distribution = texture2DDistribution( shadow, uv );
540: 		float hard_shadow = step( compare , distribution.x );
541: 		if (hard_shadow != 1.0 ) {
542: 			float distance = compare - distribution.x ;
543: 			float variance = max( 0.00000, distribution.y * distribution.y );
544: 			float softness_probability = variance / (variance + distance * distance );			softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );			occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
545: 		}
546: 		return occlusion;
547: 	}
548: 	float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
549: 		float shadow = 1.0;
550: 		shadowCoord.xyz /= shadowCoord.w;
551: 		shadowCoord.z += shadowBias;
552: 		bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
553: 		bool inFrustum = all( inFrustumVec );
554: 		bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
555: 		bool frustumTest = all( frustumTestVec );
556: 		if ( frustumTest ) {
557: 		#if defined( SHADOWMAP_TYPE_PCF )
558: 			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
559: 			float dx0 = - texelSize.x * shadowRadius;
560: 			float dy0 = - texelSize.y * shadowRadius;
561: 			float dx1 = + texelSize.x * shadowRadius;
562: 			float dy1 = + texelSize.y * shadowRadius;
563: 			float dx2 = dx0 / 2.0;
564: 			float dy2 = dy0 / 2.0;
565: 			float dx3 = dx1 / 2.0;
566: 			float dy3 = dy1 / 2.0;
567: 			shadow = (
568: 				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
569: 				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
570: 				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
571: 				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
572: 				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
573: 				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
574: 				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
575: 				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
576: 				texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
577: 				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
578: 				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
579: 				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
580: 				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
581: 				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
582: 				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
583: 				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
584: 				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
585: 			) * ( 1.0 / 17.0 );
586: 		#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
587: 			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
588: 			float dx = texelSize.x;
589: 			float dy = texelSize.y;
590: 			vec2 uv = shadowCoord.xy;
591: 			vec2 f = fract( uv * shadowMapSize + 0.5 );
592: 			uv -= f * texelSize;
593: 			shadow = (
594: 				texture2DCompare( shadowMap, uv, shadowCoord.z ) +
595: 				texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
596: 				texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
597: 				texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
598: 				mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), 
599: 					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
600: 					 f.x ) +
601: 				mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), 
602: 					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
603: 					 f.x ) +
604: 				mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), 
605: 					 texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
606: 					 f.y ) +
607: 				mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), 
608: 					 texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
609: 					 f.y ) +
610: 				mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), 
611: 						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
612: 						  f.x ),
613: 					 mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), 
614: 						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
615: 						  f.x ),
616: 					 f.y )
617: 			) * ( 1.0 / 9.0 );
618: 		#elif defined( SHADOWMAP_TYPE_VSM )
619: 			shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
620: 		#else
621: 			shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
622: 		#endif
623: 		}
624: 		return shadow;
625: 	}
626: 	vec2 cubeToUV( vec3 v, float texelSizeY ) {
627: 		vec3 absV = abs( v );
628: 		float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
629: 		absV *= scaleToCube;
630: 		v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
631: 		vec2 planar = v.xy;
632: 		float almostATexel = 1.5 * texelSizeY;
633: 		float almostOne = 1.0 - almostATexel;
634: 		if ( absV.z >= almostOne ) {
635: 			if ( v.z > 0.0 )
636: 				planar.x = 4.0 - v.x;
637: 		} else if ( absV.x >= almostOne ) {
638: 			float signX = sign( v.x );
639: 			planar.x = v.z * signX + 2.0 * signX;
640: 		} else if ( absV.y >= almostOne ) {
641: 			float signY = sign( v.y );
642: 			planar.x = v.x + 2.0 * signY + 2.0;
643: 			planar.y = v.z * signY - 2.0;
644: 		}
645: 		return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
646: 	}
647: 	float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
648: 		vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
649: 		vec3 lightToPosition = shadowCoord.xyz;
650: 		float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );		dp += shadowBias;
651: 		vec3 bd3D = normalize( lightToPosition );
652: 		#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
653: 			vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
654: 			return (
655: 				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
656: 				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
657: 				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
658: 				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
659: 				texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
660: 				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
661: 				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
662: 				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
663: 				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
664: 			) * ( 1.0 / 9.0 );
665: 		#else
666: 			return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
667: 		#endif
668: 	}
669: #endif
670: float getShadowMask() {
671: 	float shadow = 1.0;
672: 	#ifdef USE_SHADOWMAP
673: 	#if 0 > 0
674: 	DirectionalLightShadow directionalLight;
675: 	
676: 	#endif
677: 	#if 1 > 0
678: 	SpotLightShadow spotLight;
679: 	
680: 		spotLight = spotLightShadows[ 0 ];
681: 		shadow *= receiveShadow ? getShadow( spotShadowMap[ 0 ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ 0 ] ) : 1.0;
682: 	
683: 	#endif
684: 	#if 0 > 0
685: 	PointLightShadow pointLight;
686: 	
687: 	#endif
688: 	#endif
689: 	return shadow;
690: }
691: void main() {
692: 	gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
693: #if defined( TONE_MAPPING )
694: 	gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
695: #endif
696: gl_FragColor = linearToOutputTexel( gl_FragColor );
697: #ifdef USE_FOG
698: 	#ifdef FOG_EXP2
699: 		float fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );
700: 	#else
701: 		float fogFactor = smoothstep( fogNear, fogFar, fogDepth );
702: 	#endif
703: 	gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
704: #endif
705: }

Warnings:
three.module.js:15988 WebGL: INVALID_OPERATION: useProgram: program not valid
useProgram @ three.module.js:15988
Me @ three.module.js:19331
renderBufferDirect @ three.module.js:18849
Oe @ three.module.js:19196
xe @ three.module.js:19179
render @ three.module.js:19056
e.manager.onLoad @ index.js:386
Ku.itemEnd @ three.module.js:26776
(anonymous) @ GLTFLoader.js:64
(anonymous) @ GLTFLoader.js:1208
Promise.then (async)
U.parse @ GLTFLoader.js:1196
parse @ GLTFLoader.js:191
(anonymous) @ GLTFLoader.js:62
(anonymous) @ three.module.js:26992
load (async)
load @ three.module.js:26977
load @ GLTFLoader.js:60
e.loadModel @ index.js:434
value @ index.js:105
cs @ react-dom.production.min.js:5161
(anonymous) @ react-dom.production.min.js:6408
t.unstable_runWithPriority @ scheduler.production.min.js:309
Go @ react-dom.production.min.js:2816
xc @ react-dom.production.min.js:6204
lc @ react-dom.production.min.js:5895
(anonymous) @ react-dom.production.min.js:2851
t.unstable_runWithPriority @ scheduler.production.min.js:309
Go @ react-dom.production.min.js:2816
Xo @ react-dom.production.min.js:2846
Ko @ react-dom.production.min.js:2836
te @ react-dom.production.min.js:7265
(anonymous) @ react-dom.production.min.js:1329
three.module.js:15988 WebGL: INVALID_OPERATION: useProgram: program not valid
useProgram @ three.module.js:15988
Me @ three.module.js:19331
renderBufferDirect @ three.module.js:18849
Oe @ three.module.js:19196
xe @ three.module.js:19179
render @ three.module.js:19056
e.renderScene @ index.js:211
requestAnimationFrame (async)
e.requestRenderIfNotRequested @ index.js:217
e.afterLoad @ index.js:344
(anonymous) @ index.js:439
(anonymous) @ GLTFLoader.js:63
(anonymous) @ GLTFLoader.js:1208
Promise.then (async)
U.parse @ GLTFLoader.js:1196
parse @ GLTFLoader.js:191
(anonymous) @ GLTFLoader.js:62
(anonymous) @ three.module.js:26992
load (async)
load @ three.module.js:26977
load @ GLTFLoader.js:60
e.loadModel @ index.js:434
value @ index.js:105
cs @ react-dom.production.min.js:5161
(anonymous) @ react-dom.production.min.js:6408
t.unstable_runWithPriority @ scheduler.production.min.js:309
Go @ react-dom.production.min.js:2816
xc @ react-dom.production.min.js:6204
lc @ react-dom.production.min.js:5895
(anonymous) @ react-dom.production.min.js:2851
t.unstable_runWithPriority @ scheduler.production.min.js:309
Go @ react-dom.production.min.js:2816
Xo @ react-dom.production.min.js:2846
Ko @ react-dom.production.min.js:2836
te @ react-dom.production.min.js:7265
(anonymous) @ react-dom.production.min.js:1329
12WebGL: CONTEXT_LOST_WEBGL: loseContext: context lost

Given the size of you third model, it could be that you reached the graphic card memory limit on your testing machine ? What is you model triangle count, and does it come with textures ? If so, what are the textures sizes ?

Also do you dispose of objects once you don’t need them anymore ?