如何使用加载的图像数据更新 ThreeJS 中的纹理? [英] How to update texture in ThreeJS with loaded image data?
本文介绍了如何使用加载的图像数据更新 ThreeJS 中的纹理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找使用从图像加载的数据更新 Threejs 中的纹理的最佳方法?loadTextture 每次都会创建一个新纹理,我找不到传递图像对象的方法.
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.
我已经用 loadTexture 创建了所需的纹理数量,现在每次我需要加载新图像时,我只想用它们的数据更新我当前的纹理
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
感谢任何帮助
推荐答案
这段代码应该有帮助吧?
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';
这篇关于如何使用加载的图像数据更新 ThreeJS 中的纹理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文