I've noticed setTexture2D has been removed in recent versions of ThreeJS. In my experience this has been a really important function in production applications to give the developer more control about when this texture is first uploaded to the GPU. For example, uploading textures during a preloader rather than waiting until first render (which leads to a huge 'jank' in common WebGL apps). Currently, the functionality still seems to exist in the WebGLTextures interface, but not exposed to the user. The only option is to render a scene with the texture visible (such as on a full screen quad in a plain scene with ortho camera), and then immediately afterwards clear the screen in order to ensure there is no 'flash' of content displayed to the user.
Is there any particular reason this functionality has been removed?
Thanks!
Have you tried using renderer.initMaterial()
?
Ah, have not seen that. Does it initialize all materials? In my preload step I am loading textures and would like to manually upload them to the GPU during that phase (ie; progress bar ticks forward after each texture is uploaded) - but at that point I still haven鈥檛 created any materials.
I see... Maybe we can add a initTexture()
?
Yeah, we have the same requirements for VR. We preloaded our textures up front with .setTexture2D
to not experience framedrops during the experience. An alternative would be great.
Anyone wants to give it a go at implementing initTexture()
?
Bumping into the same problem.
Would it be ok to set "textures" as property of th renderer instance for a quick fix ?
https://github.com/mrdoob/three.js/blob/master/src/renderers/WebGLRenderer.js#L283
Most helpful comment
I see... Maybe we can add a
initTexture()
?