此类形状或网格是由参数或数学数据决定的,它们包括lines(线)、system of lines(线系)、ribbons(带)、tubes(管)、extrusion(挤出物)、lathed shape(板条形状)和irregular shape(不规则多边形)。
-
lines 线条
线是三维中的一系列线段,其中一个线段的结束是下一个线段的开始,直线是由三维空间中的一系列点来描述的。
点坐标通常以Vector3类型来指定
实例如下
var myPoints = [];//存放端点坐标的数组
//向数组中添加元素的方法之一
var point1 = new BABYLON.Vector3(0, 0, 0);
myPoints.push(point1);
var point2 = new BABYLON.Vector3(0, 1, 1);
myPoints.push(point2);
var point3 = new BABYLON.Vector3(0, 1, 0);
myPoints.push(point3);
//or the possible alternative
//方法之二
var myPoints =[
new BABYLON.Vector3(0, 0, 0),
new BABYLON.Vector3(0, 1, 1),
new BABYLON.Vector3(0, 1, 0)
];
//creates lines 创建线条
var lines = BABYLON.MeshBuilder.CreateLines("lines", {points: myPoints}, scene);
效果如下:
ps:创建虚线的方法:
BABYLON.MeshBuilder.CreateDashedLines("lines", {points: myPoints, dashNb:400}, scene);
当设置updatable为true时,可以通过instance参数对端点数据进行更新
参考资料:https://doc.babylonjs.com/babylon101/parametric_shapes