THREE.JS create custom 3D shape
3d, shapes, three.js, webgl
Solution
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;
Problem
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?