API

Creating Tubes

Tube

A tube is much as you would expect it to be: a surface with a hollow interior along its length.
On creation, the local origin of a tube is coincident with the world origin. It is not possible to give a position relative to the constructed shape, as this depends on the data sets used.

MeshBuilder

Usage :

import { MeshBuilder } from "@babylonjs/core/Meshes/meshBuilder";
const options = {
path: myPath, //vec3 array,
updatable: true
};
let tube = MeshBuilder.CreateTube("tube", options, scene); //scene is optional and defaults to the current scene
// Update
options.path[0].x += 6;
options.instance = tube;
tube = MeshBuilder.CreateTube("tube", options); //No scene parameter when using instance
optionvaluedefault value
path
(Vector3[]) array of Vector3, the path of the tube REQUIRED
 
radius
(number) the radius of the tube
1
tessellation
(number) the number of radial segments
64
radiusFunction
( function(index, distance) ) a function returning a radius value from (index, distance) parameters
null
cap
(number) tube cap : NO_CAP, CAP_START, CAP_END, CAP_ALL
NO_CAP
arc
(number) ratio of the tube circumference between 0 and 1
1
updatable
(boolean) true if the mesh is updatable
false
sideOrientation
(number) side orientation
DEFAULTSIDE
frontUVs
(Vector4) ONLY WHEN sideOrientation:BABYLON.Mesh.DOUBLESIDE is an option
Vector4(0,0, 1,1)
backUVs
(Vector4) ONLY WHEN sideOrientation:BABYLON.Mesh.DOUBLESIDE is an option
Vector4(0,0, 1,1)
instance
(LineMesh) an instance of a tube to be updated
null
invertUV
(boolean) to swap the U and V coordinates at geometry construction time (texture rotation of 90°)
false

You must set at least the path option. On update, you must set the path and instance options and you may also set the radius, radiusFunction or arc options.

Examples

non updatable tube: Create a Non Updatable Tube updatable tube: Create an Updatable Tube spiral tube: Create a Spiral Tube

When using the radiusFunction, it must return a number. Its parameters refer to a path index or a distance along the path.

distance example: Create a Tube With Radius Function 1 index example: Create a Tube With Radius Function 2 with circular path and changing radius: Create a Tube With Radius Function 3

Mesh

usage:

import { Mesh } from "@babylonjs/core/Meshes/mesh";
let tube = Mesh.CreateTube("tube", path, radius, tesselation, optional radiusFunction, cap, scene);
let tube = Mesh.CreateTube("tube", path, radius, tesselation, optional radiusFunction, cap, scene, updatable, sideOrientation, instance); //optional parameters after scene