javascript - Threejs: assign different colors to each vertex in a geometry - Stack Overflow
var geometry = new THREE.Geometry();

// Make the simplest shape possible: a triangle.
geometry.vertices.push(
new THREE.Vector3(-10, 10, 0),
new THREE.Vector3(-10, -10, 0),
new THREE.Vector3( 10, -10, 0)
);

// Note that I'm assigning the face to a variable
// I'm not just shoving it into the geometry.
var face = new THREE.Face3(0, 1, 2);

// Assign the colors to the vertices of the face.
face.vertexColors[0] = new THREE.Color(0xff0000); // red
face.vertexColors[1] = new THREE.Color(0x00ff00); // green
face.vertexColors[2] = new THREE.Color(0x0000ff); // blue

// Now the face gets added to the geometry.
geometry.faces.push(face);

// Using this material is important.
var material = new THREE.MeshBasicMaterial({vertexColors: THREE.VertexColors});

var mesh = new THREE.Mesh(geometry, material);
threejs 
8 weeks ago
« earlier      
2d 3d admin advice agile ai akka analytics android animation api app apple apps appstore architecture arduino art article asp.net async audio automation aws bike blog book books bootstrap browser business c c# cloud cms cocoa code coding color colour computing css culture cycling data database db dba deployment design dev development devops di diagram distributed diy docker docs documentation dotnet drawing ebook economics editor education electronics elixir email encryption engineering example exercise facebook film fitness flux font fonts food framework free game gamedev games generator git github go golang google graphics gui guitar happiness hardware health history hosting html html5 http icons image inspiration interesting internet interview ios iphone java javascript jquery js json jvm language layout learning library life linux list lua mac macos management map maps marketing math messaging microservices microsoft mobile money msdn music mvc network networking node nodejs objectivec office online opensource openssl oracle osx pattern patterns pdf people performance perl plugin podcast postgres postgresql product productivity programming project promises prototyping psychology python rails react reactjs recipe reference research resources rest retro route ruby running s3 scala science search security server sketch skills software sound sport sql sqlite startup static storage story stufftobuy swift synth sysadmin talk teaching tech template test testing text tips tool tools training tutorial twitter ubuntu ui usability ux video vst vsti web webdesign webdev webgl windows wordpress work wpf writing xcode xml

Copy this bookmark:



description:


tags: