THREE.JS创建自定义3D形状

时间:2013-07-24 19:48:46

标签: 3d three.js webgl shape

如何使用THREE.JS中的WebGLRenderer创建下面的形状。

Image of required shape

这个形状是一个立方体,其顶面已旋转45度 是否可以创建立方体然后更改它的顶点或...
任何的想法?

1 个答案:

答案 0 :(得分:7)

您可以使用数组cubeMesh.geometry.vertices访问顶点位置。

//create a cube as per usual
var cubeMesh = new THREE.Mesh(
    new THREE.CubeGeometry(1, 2, 1),
    new THREE.MeshLambertMaterial()
);
scene.add(cubeMesh);

//change vertex positions
cubeMesh.geometry.vertices[1].y += 1;
cubeMesh.geometry.vertices[4].y += 1;

//indicate that the vertices need update
cubeMesh.geometry.verticesNeedUpdate = true;
相关问题