Meshes

Other topics

Remarks:

Both the geometry and material are optional and will default to BufferGeometry and MeshBasicMaterial respectively if they are not provided in the constructor.

Render a cube mesh with a box geometry and a basic material

var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 50);
camera.position.z = 25;

var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

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

var render = function () {
    requestAnimationFrame(render);

    renderer.render(scene, camera);
};

render();

Syntax:

  • new THREE.Mesh(geometry, material);

Contributors

Topic Id: 8838

Example Ids: 27531

This site is not affiliated with any of the contributors.