Problem with optimalization in three.js

Hello,

The problem is that during the FIRST ACCEPT of skills, a very long lag appears.
The strangest thing is that it occurs only at the beginning - once the browser bites this lag, the subsequent launches are smooth.

I thought it was the fault of optimization - but we subjected the whole scene to detailed optimization, leaving only one light source and the model 90% trimmed in all respects. The game is smoother, but the problem of the first lag still remains.

All I have is a an error that pops up once in a while:

THREE.WebGLProgram: shader error:  1282 35715 false gl.getProgramInfoLog Could not pack varying vUv
Note: Additional non-conformant packing restrictions are enforced on D3D9.

this is how scene looks like after optimalization (sponza edit):

Can you please try to pre-compile all shaders by using WebGLRenderer.compile()? This requires that you pass in a scene that contains all materials applied to 3D objects.

should i wait some times after using this compile method?
I run it 5 seconds after the scene is loaded and I can’t see any difference

Normally, it’s intended that you run WebGLRenderer.compile() first.

The idea behind this change is that if you cast a spell, the shader that renders the effect is already compiled.

1 Like

so i just did what you want and still same effects - huge lag on first spell cast.
It always happens the first time, no matter if the spell fires after 30 seconds from the start, or after 2. If he uses them, the next ones are displayed smoothly.

Are you using textures for your effects?

Thoes textures that you see while spell casting, were from another library. Three.JS is responsibility only for light system, and 3D models. If i’d remove 2D texture elements and leave only light system and 3d models from THREE, same thing happened. :confused: