var starPoints = [];
starPoints.push(new THREE.Vector2(-500, 0));
starPoints.push(new THREE.Vector2(0, 500));
starPoints.push(new THREE.Vector2(500, 0));
var starShape = new THREE.Shape(starPoints);
var extrusionSettings = {
size: 0, height: 0, curveSegments: 0,
bevelThickness: 0, bevelSize: 0, bevelEnabled: false,
material: 0
, extrudeMaterial: 1
, amount: 100
};
var starGeometry = new THREE.ExtrudeGeometry(starShape, extrusionSettings);
var materialFront = get_material(gparams.kirpich, 1, 1); //materials_list.basic_color; // new THREE.MeshBasicMaterial({ color: 0xffff00 });
var materialSide = get_material(gparams.kirpich, 1, 1);
var materialSide2 = new THREE.MeshBasicMaterial({ color: "#f00" });
var materialArray = [materialFront, materialSide];
var starMaterial = new THREE.MeshFaceMaterial(materialArray);
var star = new THREE.Mesh(starGeometry, materialFront);
star.position.set(0, 250, 0);
//star.rotation.x = -90 * Math.PI / 180;
scene.add(star);
我有一个triange,但我无法得到这个三角形的必要材料。 我只能获得彩色材料,但我希望从材质图片中获取自定义材料。 我怎样才能获得必要的材料,或者是否有另一种方法可以为这些目的使用自定义材料定制网格?
非常感谢你!
答案 0 :(得分:1)
听起来您想要使用loadTexture
,您可以使用texture = THREE.ImageUtils.loadTexture(<your image>);
material = new THREE.MeshBasicMaterial({map: texture});
将图像加载到网格上。
needsUpdate
更新(请参阅评论)
要更改纹理,请保留网格的副本,然后更改纹理并在纹理上将 function setTextureImage( imageSrc )
{
texture = THREE.ImageUtils.loadTexture(<your imageSrc>);
texture.needsUpdate = true;
m_modelMesh.material.map = texture;
}
设置为true。最后,在材质贴图上设置纹理。请参阅下面的here和代码:
{{1}}