Three.js Update Texture image

守給你的承諾、 提交于 2019-11-29 04:28:59

When you update a texture, whether its based on canvas, video or loaded externally, you need to set the following property on the texture to true:

If an object is created like this:

var canvas = document.createElement("canvas");
var canvasMap = new THREE.Texture(canvas)
var mat = new THREE.MeshPhongMaterial();
mat.map = canvasMap;
var mesh = new THREE.Mesh(geom,mat);

After the texture has been changed, set the following to true:

cube.material.map.needsUpdate = true;

And next time you render the scene it'll show the new texture.

Alex Under

Here is all the basics of what you have to know about "updating" stuff in three.js: https://threejs.org/docs/#manual/introduction/How-to-update-things

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!