【问题标题】:How to update texture in ThreeJS with loaded image data?如何使用加载的图像数据更新 ThreeJS 中的纹理?
【发布时间】:2014-07-06 05:57:13
【问题描述】:

我正在寻找使用从图像加载的数据更新threejs 中的纹理的最佳方法? loadTextture 每次都会创建一个新纹理,我找不到传递图像对象的方法。

我已经使用 loadTexture 创建了所需的纹理数量,现在每次我需要加载新图像时,我只想用它们的数据更新我当前的纹理

感谢任何帮助

【问题讨论】:

    标签: javascript three.js textures


    【解决方案1】:

    这段代码应该有帮助吗?

    var image = document.createElement( 'img' );
    var texture = new THREE.Texture( image );
    
    image.onload = function () {
    
        texture.needsUpdate = true;
    
    };
    
    image.src = 'image.png';
    

    【讨论】:

    • 谢谢 mrbood。为我工作。
    猜你喜欢
    • 2015-09-18
    • 2014-09-26
    • 2021-11-14
    • 2018-12-05
    • 2016-05-03
    • 2016-03-05
    • 1970-01-01
    • 2020-01-18
    • 1970-01-01
    相关资源
    最近更新 更多