gpt4 book ai didi

three.js - Material 的克隆工作不正常

转载 作者:行者123 更新时间:2023-12-04 00:41:45 27 4
gpt4 key购买 nike

改变新 Material 的参数对旧 Material 的影响

var material = new THREE.MeshLambertMaterial({
map: Texture,
side: THREE.DoubleSide
});

material.map.repeat.set(3,3);
material.map.offset.set(0.1,0);

var geometry = new THREE.PlaneGeometry(100, 100, 1, 1);
var mesh = new THREE.Mesh(geometry, material);

mesh.position.set(-70, 0, 0);
scene.add(mesh);

var material2 = material.clone();

material2.map.repeat.set(2,2);
material2.map.offset.set(0.5,0);

var geometry = new THREE.PlaneGeometry(100, 100, 1, 1);
var mesh = new THREE.Mesh(geometry, material2);

mesh.position.set(70, 0, 0);
scene.add(mesh);

结果, the texture are equally
也许您需要在几何语言中设置重复和偏移纹理?

最佳答案

Material.clone 制作一个浅拷贝,所以你最终会得到两种具有相同的不同 Material map .如果要在其上设置不同的值,还需要克隆纹理。

var material2 = material.clone();
material2.map = material2.map.clone();
material2.map.repeat.set(2,2);
material2.map.offset.set(0.5,0);
material2.map.needsUpdate = true;

关于three.js - Material 的克隆工作不正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29580285/

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