无限平面的线框正方形在three.js

CL2*_*L22 4 javascript three.js

我想知道一种有效的方法来实例化一个无限大的(或有效无限大的)交叉线平面,这些平面被排列成方形.

three.js有一个行对象,我应该只是实例化大量这些吗?或者可能实例化一个Plane对象,并应用某种重复材质?也许还有其他更有效的方法?

谢谢

Wes*_*ley 12

这是另一种方法:

var grid = new THREE.GridHelper( 200, 10 );
grid.setColors( 0xffffff, 0xffffff );
scene.add( grid );
Run Code Online (Sandbox Code Playgroud)

您可以添加雾以使网格混合到地平线的背景中.

scene.fog = new THREE.FogExp2( 0x000000, 0.0128 );
renderer.setClearColor( scene.fog.color, 1 );
Run Code Online (Sandbox Code Playgroud)

它应该看起来很不错.

three.js r.71


gai*_*tat 5

这段代码将给出一个十字交叉线的半无限平面:

var geometry = new THREE.Geometry();
geometry.vertices.push(new THREE.Vector3( - 500, 0, 0 ) );
geometry.vertices.push(new THREE.Vector3( 500, 0, 0 ) );

linesMaterial = new THREE.LineBasicMaterial( { color: 0x787878, opacity: .2, linewidth: .1 } );

for ( var i = 0; i <= 20; i ++ ) {

    var line = new THREE.Line( geometry, linesMaterial );
    line.position.z = ( i * 50 ) - 500;
    scene.add( line );

    var line = new THREE.Line( geometry, linesMaterial );
    line.position.x = ( i * 50 ) - 500;
    line.rotation.y = 90 * Math.PI / 180;
    scene.add( line );
}
Run Code Online (Sandbox Code Playgroud)