How to update texture in ThreeJS with loaded image data?

爱⌒轻易说出口 提交于 2019-12-11 04:55:44

问题


I'm looking for the best way to update a texture in threejs with data loaded from an image ? loadTextture will create a new texture every time and i can't find a way to pass on an image object.

I've created the amount of textures needed with loadTexture, now every time i need to load a new image i just want to update my current textures with their data

Appreciate any help


回答1:


This code should be of some help?

var image = document.createElement( 'img' );
var texture = new THREE.Texture( image );

image.onload = function () {

    texture.needsUpdate = true;

};

image.src = 'image.png';


来源:https://stackoverflow.com/questions/23718005/how-to-update-texture-in-threejs-with-loaded-image-data

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