【问题标题】:How to draw lines in xz plane using three.js如何使用three.js在xz平面上画线
【发布时间】:2017-02-17 08:14:44
【问题描述】:

我想在 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 的几何对象应该由坐标对组成,代表每条线的起点和终点。但是,上面的功能不起作用。

谁能给出正确的技巧?

【问题讨论】:

    标签: javascript three.js


    【解决方案1】:

    Geometry 的顶点是THREE.Vector3 的数组。

    geometry.vertices.push( new THREE.Vector3( x, y, z ) );
    

    另外,您可以使用THREE.GridHelper( size, divisions, color1, color2 )

    three.js r.84

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-06-20
      • 1970-01-01
      • 2016-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-17
      相关资源
      最近更新 更多