Home  »  CodeLibrariesProgrammingSnippetsTechnology   »   Create Three.js Cube Mesh Example Code

Create Three.js Cube Mesh Example Code

Posted: January 2, 2023 | by Michael Bright

Use the BoxGeometry geometry class to create a rectangular cuboid with a given width, height, and depth.

const geometry = new THREE.BoxGeometry( 1, 1, 1 );
const material = new THREE.MeshBasicMaterial( {color: 0x00ff00} );
const cube = new THREE.Mesh( geometry, material );
scene.add( cube );

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.