解答:以下程式加入 drawSquare() 函式:
1
2
3
4
5
6
7
8
|
var square = new THREE.Geometry();
square.vertices.push( new THREE.Vector3( x1, y1, 0 ) );
square.vertices.push( new THREE.Vector3( x2, y1, 0 ) );
square.vertices.push( new THREE.Vector3( x2, y2, 0 ) );
square.vertices.push( new THREE.Vector3( x1, y2, 0 ) );
square.faces.push( new THREE.Face3( 0, 1, 2 ) );
square.faces.push( new THREE.Face3( 2, 0, 3 ) );
return square;
|
更新:Three.js r60 之後 Face4 被移除不應該再繼續使用:https://github.com/mrdoob/three.js/wiki/Migration#r59–r60