Creating Tubes
Tube
A tube is much as you would expect it to be, a surface with hollow 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 :
const options = {path: myPath, //vec3 array,updatable: true}let tube = BABYLON.MeshBuilder.CreateTube("tube", options, scene); //scene is optional and defaults to the current scene// Updateoptions.path[0].x +=6;options.instance = tube;tube = BABYLON.MeshBuilder.CreateTubes("tube", options); //No scene parameter when using instance
option | value | default value |
---|---|---|
option path | value (Vector3[]) array of Vector3, the path of the tube REQUIRED | default value |
option radius | value (number) the radius of the tube | default value 1 |
option tessellation | value (number) the number of radial segments | default value 64 |
option radiusFunction | value ( function(index, distance) ) a function returning a radius value from (index, distance) parameters | default value null |
option cap | value (number) tube cap : NO_CAP, CAP_START, CAP_END, CAP_ALL | default value NO_CAP |
option arc | value (number) ratio of the tube circumference between 0 and 1 | default value 1 |
option updatable | value (boolean) true if the mesh is updatable | default value false |
option sideOrientation | value (number) side orientation | default value DEFAULTSIDE |
option frontUVs | value (Vector4) ONLY WHEN sideOrientation:BABYLON.Mesh.DOUBLESIDE is an option | default value Vector4(0,0, 1,1) |
option backUVs | value (Vector4) ONLY WHEN sideOrientation:BABYLON.Mesh.DOUBLESIDE is an option | default value Vector4(0,0, 1,1) |
option instance | value (LineMesh) an instance of a tube to be updated | default value null |
option invertUV | value (boolean) to swap the U and V coordinates at geometry construction time (texture rotation of 90°) | default value 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 parameter 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:
let tube = BABYLON.Mesh.CreateTube("tube", path, radius, tesselation, optional radiusFunction, cap, scene);let tube = BABYLON.Mesh.CreateTube("tube", path, radius, tesselation, optional radiusFunction, cap, scene, updatable, sideOrientation, instance); //optional parameters after scene