threejs多面体加纹理,貌似只改变了颜色,求大神指点! 20C
         function initModel() {
            //辅助工具
            var helper = new THREE.AxisHelper(10);
            scene.add(helper);
            var cubeGeometry = new THREE.Geometry();
            //创建立方体的顶点
            var vertices = [
                new THREE.Vector3(0, 0, 20), //v0
                new THREE.Vector3(30, 0, 0), //v1
                new THREE.Vector3(0, 0,-20), //v2
                new THREE.Vector3(-30, 0, 0), //v3
                new THREE.Vector3(-30,220,0), //v4
                new THREE.Vector3(-22,220,10), //v5
                new THREE.Vector3(22,220,10), //v6
                new THREE.Vector3(30,220,0), //v7
                new THREE.Vector3(22,220,-10), //v8
                new THREE.Vector3(-22,220,-10), //v9
            ];
            cubeGeometry.vertices = vertices;
            //创建立方的面
            var faces=[
                new THREE.Face3(0,1,2),
                new THREE.Face3(0,2,3),
                new THREE.Face3(3,0,5),
                new THREE.Face3(3,5,4),
                new THREE.Face3(3,4,9),
                new THREE.Face3(3,9,2),
                new THREE.Face3(2,9,8),
                new THREE.Face3(8,1,2),
                new THREE.Face3(8,7,1),
                new THREE.Face3(6,1,7),
                new THREE.Face3(6,0,1),
                new THREE.Face3(0,6,5),
                new THREE.Face3(5,6,7),
                new THREE.Face3(5,7,8),
                new THREE.Face3(5,8,9),
                new THREE.Face3(5,9,4),

            ];
            cubeGeometry.faces = faces;
            //生成法向量
            cubeGeometry.computeFaceNormals();

            function createMesh(geom, imageFile) {
            //  var texture = 
                var mat = new THREE.MeshPhongMaterial();
                mat.normalMap = new THREE.TextureLoader().load("/seismis/js/3djs/assets/textures/general/" + imageFile);
        //      mat.specular = new THREE.Color(0xffffff);
                mat.needsUpdate = true;
                mat.shininess = 10;
                var mesh = new THREE.Mesh(geom, mat);
                return mesh;
            }
            //中间立体图形
            var polyhedron1 = createMesh(cubeGeometry, "stone.jpg");
            polyhedron1.position.x = 0;
            polyhedron1.position.y = 120;
            polyhedron1.position.z = 0;
            scene.add(polyhedron1);          
}
liyae1994
liyae1994 请问你这个问题解决了吗?我好像也遇到了相同的问题,你这个最后是怎么解决的呢
接近 2 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐