gpt4 book ai didi

three.js - 无法克隆()纹理

转载 作者:行者123 更新时间:2023-12-04 16:31:42 29 4
gpt4 key购买 nike

基本上,

这有效:

var expl1 = new THREE.ImageUtils.loadTexture( 'images/explodes/expl1.png' );
this.material = new THREE.MeshBasicMaterial({ map: expl1, transparent:true, blending:THREE.AdditiveBlending });

而且这不...
var expl1 = new THREE.ImageUtils.loadTexture( 'images/explodes/expl1.png' );
this.material = new THREE.MeshBasicMaterial({ map: expl1.clone(), transparent:true, blending:THREE.AdditiveBlending });

问题是,我有多个具有此纹理的对象。我希望能够更改1个对象的纹理偏移,而其他对象也没有更改。这就是为什么我需要克隆,但是克隆的纹理似乎是空的。
var expl1 = new THREE.ImageUtils.loadTexture( 'images/explodes/expl1.png' );

在全局变量中仅加载一次。每次创建新对象时,我都可以加载新纹理,但是由于它为700KB,因此在加载图像时会产生延迟。

最佳答案

编辑:THREE.ImageUtils.loadTexture()已由loader = new THREE.TextureLoader(); loader.load()代替。

这可能是因为new THREE.TextureLoader().load()为您设置了needsUpdate标志,而克隆则没有。

改为这样做

var texture2 = texture1.clone();
texture2.needsUpdate = true;
material = new THREE.MeshBasicMaterial( { map: texture2, ... } );

three.js r.75

关于three.js - 无法克隆()纹理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16705399/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com