Reputation: 2542
How can I create the shape below with THREE.JS
in WebGLRenderer
.
This shape is a cube, the top face of which has been rotated 45 degrees.
Is it possible to create the cube then change it vertexes or ...
any idea?
Upvotes: 4
Views: 3596
Reputation: 892
You can access the vertex positions using the array 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;
Upvotes: 8