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 options properties and you should not change . Any other option will not be changed.
MeshBuilder
Usage:
const options = { points: myPoints, //vec3 array, updatable: true}
let dashedlines = BABYLON.MeshBuilder.CreateDashedLines("dashedlines", options, scene); //scene is optional and defaults to the current scene
// Updateoptions.points[0].x +=6; options.instance = lines;lines = BABYLON.MeshBuilder.CreateDashedLines("dashedlines", options); //No scene parameter when using instance
option | value | default value |
---|---|---|
option points | value (Vector3[]) array of Vector3, the path of the line REQUIRED | default value |
option dashSize | value (number) size of the dashes | default value 3 |
option gapSize | value (number) size of the gaps | default value 1 |
option dashNb | value (number) intended number of dashes | default value 200 |
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 |
The actual length of the dashes and gaps is determined by how many are set by the dashNb and then the ratio, of dashSize and * gapSize* rather than the actual size All of the following will produce equal 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.
dashedlines.color = new BABYLON.Color3(1, 0, 0);
Colored Dashed Lines: Create Colored Dashed Lines
Mesh
Usage:
const dashedlines = BABYLON.Mesh.CreateDashedLines("dashedLines", vector3 array, dashSize, gapSize, dashNb, scene);const dashedlines = BABYLON.Mesh.CreateDashedLines("dashedLines", vector3 array, dashSize, gapSize, dashNb, scene, updatable, instance); //optional parameters after scene