Answered step by step
Verified Expert Solution
Question
1 Approved Answer
THREE.JS Javasciprt assignment -> Write a program that renders a cube in which colors are assigned on a per-vertex basis. function createCube() { var geom
THREE.JS Javasciprt assignment -> Write a program that renders a cube in which colors are assigned on a per-vertex basis.
function createCube() { var geom = new THREE.CubeGeometry(2, 2, 2); var mat = new THREE.MeshFaceMaterial(); var colors = ["red", "green", "blue", "yellow", "cyan", "magenta"].map( function(colorname) {return new THREE.MeshBasicMaterial({color: colorname});}); for (var i = 0; i < 6; i++) mat.materials.push(colors[i]); for (var i = 0; i < 6; i++) for (var j = 0; j < 2; j++) geom.faces[2*i+j].materialIndex = i; var mesh = new THREE.Mesh(geom, mat); return mesh; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started