材料的克隆工作不正常

Cloning of the material is not working properly

提问人:gevaraweb 提问时间:4/12/2015 最后编辑:gevaraweb 更新时间:3/26/2019 访问量:5847

问:

更改新材质对旧材质的参数效果

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

因此,纹理同样需要用几何语言设置重复和偏移纹理?

三个.js

评论

0赞 skrJS 3/26/2019
也许你需要material.copy()

答:

9赞 BMac 4/12/2015 #1

Material.clone 会制作一个浅拷贝,因此您最终会得到具有相同地图的两种不同材质。如果要在纹理上设置不同的值,也需要克隆纹理。

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;