解答: 將以下程式填入 fillScene()

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
// 解答
geometry = new THREE.Geometry();
geometry.vertices.push( new THREE.Vector3( 100, 0, 0 ) );
geometry.vertices.push( new THREE.Vector3( 0, 100, 0 ) );
geometry.vertices.push( new THREE.Vector3( 0, 0, 100 ) );

geometry.faces.push( new THREE.Face3( 0, 1, 2 ) );
// 這個實際上會乘上材質的顏色,預設是白色
var color1 = new THREE.Color( 0xff0000 );
var color2 = new THREE.Color( 0x00ff00 );
var color3 = new THREE.Color( 0x0000ff );
geometry.faces[0].vertexColors = [ color1, color2, color3 ];
mesh = new THREE.Mesh( geometry, material );