three.js automatically resizes the texture image, if it is not power of two. In my case am using a custom canvas as texture , which is not power of two.while resizing makes the texture not appearing properly.Is there any way to disable the resizing of the images in three.js
相关问题
- Rotating an Object properly around a pivot point g
- SecurityError for same-origin image texImage2D
- Loading texture from Web Worker in Three.js
- My object isn't reflects the light in Three.js
- Reading a openGL ES texture to a raw array
相关文章
- Get size of Object3D in Three.js
- Change color of mesh using mouseover in three js
- THREE.Object3D.add: object not an instance of THRE
- MeshLab: How to import XYZRGB file
- Why do I need to define a precision value in webgl
- Check a face is upwards/downwards towards mouse di
- How to change one texture image of a 3d model(maya
- Why do my three.js examples not load properly?
three.js actually is trying to do you a favor.
Since it is open source we can read the source code of WebGLRenderer.js and see that the
setTexture
method calls the (non public visible) methoduploadTexture
.The latter has this check:
Which is quite explanatory itself.
You may wonder now what
textureNeedsPowerOfTwo
actually checks. Let's see.If you use wrapping for the texture coordinated different from clamp or if you use a filtering that is not nearest nor linear the texture gets scaled.
If you are surprised by this code I strongly suggest you to take a look at the MDN page on using textures.
Quoting
So using a NPOT texture with incorrect texture parameters would give you the good old solid black.
Since three.js is open source, you can edit your local copy and remove the "offending" check.
However a better, simpler, and more maintainable approach is to simply scale the UV mapping. After all it is there just for this use case.