I loaded a texture by using Three.TextureLoader() and tried to render it by calling .texSubImage2D. But it emit the error below.
““Uncaught (in promise) TypeError: Failed to execute ‘texSubImage2D’ on ‘WebGLRenderingContext’: No function was found that matched the signature provided.””
I called the function like this
context.texSubImage2D(context.TEXTURE_2D, 0, 0, 0, context.RGBA, context.UNSIGNED_BYTE, loadedTexture);
Is the problem from CORS? or WebGL2?
texSubImage2D as a native WebGL function does not support an instance of THREE.Texture
as its last argument (pixels
).
Try it with loadedTexture.image
. But you have to ensure that the texture is actually loaded otherwise its image
property is undefined
.
I already tried loadTexture.image before, at that time still same error showed.
But in this time it worked with “loadTexture.image” code…
I don’t know exact reason for problem, but anyway it solved.
Thanks!
ps.
In my case, TextureLoader.setCrossOrigin(“anonymous”) and
Asset source location does not affect to this problem.