threejs 绘制辅助网格
GridHelper.js可以帮助绘制一个xz平面网格,它没有提供更多的参数,所以不能用于生成xy网格。
xy网格实现代码如下:
var size = 6000; var divisions = 50; // var gridHelper = new THREE.GridHelper(size, divisions, 0x1231c3, 0x135133); // this.scene.add(gridHelper); var geometry = new THREE.Geometry(); //创建geometry geometry.vertices.push(new THREE.Vector3(-size / 2, 0, 0)); //添加顶点 geometry.vertices.push(new THREE.Vector3(size / 2, 0, 0)); for (var i = 0, len = size / divisions; i <= len; i++) { var line = new THREE.Line(geometry, new THREE.LineBasicMaterial({ color: 0x455454 })); //利用geometry和material创建line line.position.y = i * divisions - size / 2; //设置line的位置 this.scene.add(line); //将line添加到场景中 var line = new THREE.Line(geometry, new THREE.LineBasicMaterial({ color: 0x324132 })); line.position.x = i * divisions - size / 2; line.rotation.z = Math.PI / 2; //绕y轴旋转90度 this.scene.add(line); }
相关推荐
ALLENJIAO 2020-06-13
stcaolei 2020-03-08
moyebaobei 2020-03-07
stcaolei 2020-03-06
ixshells 2020-03-05
moyebaobei 2020-01-14
liulinsp 2020-01-09
moyebaobei 2019-09-06
涓涓溪流 2018-03-02
ALLENJIAO 2019-07-01
moyebaobei 2019-07-01
颜辉 2019-06-28
moyebaobei 2019-06-28
liulinsp 2019-06-27
ALLENJIAO 2019-06-27
ALLENJIAO 2019-06-27
moyebaobei 2015-01-05
stcaolei 2019-06-25
cibeidelangren 2019-06-21