无法克隆()纹理

编程入门 行业动态 更新时间:2024-10-27 18:18:46
本文介绍了无法克隆()纹理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

基本上,

这有效:

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 });

问题是,我有多个具有此纹理的对象.我希望能够在不改变其他对象的情况下更改其中一个对象的纹理偏移.这就是为什么我需要克隆,但克隆的纹理似乎是空的.

The problem is, i have multiple objects with this texture. I want to be able to change the texture offsets of 1 of the objects without the others changing also. That's why i need clone, but the cloned texture seems to be empty.

var expl1 = new THREE.ImageUtils.loadTexture( 'images/explodes/expl1.png' );

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

this is only loaded once in a global variable. I could load a new texture each time i'm creating a new object, but because it's 700KB, it creates lag when loading the image.

推荐答案

THREE.ImageUtils.loadTexture() 已被替换为 loader = new THREE.TextureLoader();loader.load().

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

This is likely because new THREE.TextureLoader().load() sets the needsUpdate flag for you, while cloning does not.

改为这样做

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

three.js r.75

three.js r.75

这篇关于无法克隆()纹理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-30 15:29:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1396355.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:纹理

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!