Threejs开发笔记之十纹理

什么是纹理
纹理就是为网格上每个像素指定颜色

基本纹理使用

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

光照贴图制造阴影效果

环境贴图制造反光效果

高光贴图

UV定制指定贴图

画布纹理

视频纹理

posted @ 2017-09-03 16:00  keivnyau  阅读(508)  评论(0编辑  收藏  举报