2017-02-16 116 views
1

我想在xz平面中繪製一系列平行直線,但找不到足夠簡單的示例。如何使用three.js在xz平面中繪製直線

我懷疑我對幾何的使用有些誤會。

function initGrid(){ 
    var material = new THREE.LineBasicMaterial({ color: 0x00ff00 }); 
    var geometry = new THREE.Geometry(); 
    for(var i=0 ; i<10; i++){ 
    geometry.vertices.push(
     (10*i,0,0), (10*i,0,100) 
    ); 
    } 
    var grid = new THREE.LineSegments(geometry, material); 
    scene.add(grid); 
} 

我的想法是提供給LineSegments幾何對象應包括對座標,代表着開始每一行的&終點。上述功能不起作用。

任何人都可以提供正確的技術嗎?

回答

1

Geometry的頂點是THREE.Vector3的數組。可以使用THREE.GridHelper(size, divisions, color1, color2)

three.js r.84