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?
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With