什么是纹理
纹理就是为网格上每个像素指定颜色
基本纹理使用
function createMesh(geom, imageFile) {
var texture = THREE.ImageUtils.loadTexture("../assets/textures/general/" + imageFile);
var mat = new THREE.MeshPhongMaterial();
mat.map = texture;
var mesh = new THREE.Mesh(geom, mat);
return mesh;
}
var polyhedron = createMesh(new THREE.IcosahedronGeometry(5, 0), "metal-rust.jpg");
凹凸贴图
function createMesh(geom, imageFile, bump) {
var texture = THREE.ImageUtils.loadTexture("../assets/textures/general/" + imageFile);
geom.computeVertexNormals();
var mat = new THREE.MeshPhongMaterial();
mat.map = texture;
if (bump) {
var bump = THREE.ImageUtils.loadTexture("../assets/textures/general/" + bump);
mat.bumpMap = bump;
mat.bumpScale = 0.2;
console.log('d');
}
// create a multimaterial
var mesh = new THREE.Mesh(geom, mat);
return mesh;
}