API

Creating Dashed Lines

Dashed Lines

Creates a contiguous series of dashed line segments from a list of points. You must set at least the points option. On update, you must set the points and instance option properties, and you should not change them. Any other options will not be changed.

MeshBuilder

Usage:

import { MeshBuilder } from "@babylonjs/core/Meshes/meshBuilder";
const options = {
points: myPoints, //vec3 array,
updatable: true
};
let dashedlines = MeshBuilder.CreateDashedLines("dashedlines", options, scene); //scene is optional and defaults to the current scene
// Update
options.points[0].x += 6;
options.instance = lines;
lines = MeshBuilder.CreateDashedLines("dashedlines", options); //No scene parameter when using instance
optionvaluedefault value
points
(Vector3[]) array of Vector3, the path of the line REQUIRED
 
dashSize
(number) size of the dashes
3
gapSize
(number) size of the gaps
1
dashNb
(number) intended number of dashes
200
updatable
(boolean) true if the mesh is updatable
false
instance
(LineMesh) an instance of a line mesh to be updated
null

The actual length of the dashes and gaps is determined by how many are set by dashNb and then by the ratio of dashSize and gapSize, rather than by their literal values. All of the following will produce equally sized dashes and gaps.

dashSize = 1;
gapSize = 1;
dashSize = 1000;
gapSize = 1000;
dashSize = 876;
gapSize = dashSize;

Examples

non updatable default dashed lines: Create Non Updatable Default Dashed Lines non updatable dashed lines set options: Create Non Updatable Dashed Lines With Options non updatable 'closed' dashed lines: Create Non Updatable Closed Dashed Lines updatable example: Create Updatable Closed Dashed Lines

Dashed lines are colored with a color property rather than a material.

import { Color3 } from "@babylonjs/core/Maths/math.color";
dashedlines.color = new Color3(1, 0, 0);

Colored Dashed Lines: Create Colored Dashed Lines

Mesh

Usage:

import { Mesh } from "@babylonjs/core/Meshes/mesh";
const dashedlines = Mesh.CreateDashedLines("dashedLines", vector3 array, dashSize, gapSize, dashNb, scene);
const dashedlines = Mesh.CreateDashedLines("dashedLines", vector3 array, dashSize, gapSize, dashNb, scene, updatable, instance); //optional parameters after scene