Creating Lines

Lines

Lines are created as a contiguous series of attached line segments from a list of points. You must set at least the points option. On update, you must set the points and instance options. You can also update the colors option if previously set at construction time.

MeshBuilder

Usage:

const options = {
points: myPoints, //vec3 array,
updatable: true
}
let lines = BABYLON.MeshBuilder.CreateLines("lines", options, scene); //scene is optional and defaults to the current scene
// Update
options.points[0].x +=6;
options.instance = lines;
lines = BABYLON.MeshBuilder.CreateLines("lines", options); //No scene parameter when using instance
optionvaluedefault value
option
points
value
(Vector3[]) array of Vector3, the path of the line REQUIRED
default value
 
option
updatable
value
(boolean) true if the mesh is updatable
default value
false
option
instance
value
(LineMesh) an instance of a line mesh to be updated
default value
null
option
colors
value
(Color4[]) array of Color4, each point color
default value
null
option
useVertexAlpha
value
(boolean) false if the alpha blending is not required (faster)
default value
true

Unlike a mesh Lines are colored after creation with a color property rather than a material.

lines.color = new BABYLON.Color3(1, 0, 0);

Examples

non updatable lines: Create Non Updatable Lines non updatable closed lines: Create Non Updatable Closed Lines updatable example: Create Updatable Closed Lines updatable spriral: Create Updatable Spiral Lines

multi colored lines have to be set on creation. Create Multi Colored Lines

Mesh

usage:

let lines = BABYLON.Mesh.CreateLines("lines", points, scene);
let lines = BABYLON.Mesh.CreateLines("lines", points, scene, updatable, instance);