Creating A Torus Knot
Torus Knot
A torus knot is a continuous shape that twists and turns around the surface of a torus. The number of twists and turns is determined by two winding integers, p and q. The simplest torus knot uses 2 and 3 for p and q. The origin of the created torus knot is at the center of the underlying torus.
MeshBuilder
Example :
import { MeshBuilder } from "@babylonjs/core/Meshes/meshBuilder";const torus = MeshBuilder.CreateTorusKnot("torusKnot", options, scene);| option | value | default value |
|---|---|---|
| radius | (number) radius of the torus knot | 2 |
| tube | (number) thickness of its tube | 0.5 |
| radialSegments | (number) number of radial segments | 32 |
| tubularSegments | (number) number of tubular segments | 32 |
| p | (number) number of windings | 2 |
| q | (number) number of windings | 3 |
| updatable | (boolean) true if the mesh is updatable | false |
| sideOrientation | (number) side orientation | DEFAULTSIDE |
| frontUVs | (Vector4) ONLY WHEN sideOrientation:BABYLON.Mesh.DOUBLESIDE set | Vector4(0,0, 1,1) |
| backUVs | (Vector4) ONLY WHEN sideOrientation:BABYLON.Mesh.DOUBLESIDE set | Vector4(0,0, 1,1) |
Examples
Simplest: Create a Simple Torus Knot Low p and q: Create a Torus Knot With Low P And Q High p and q: Create a Torus Knot With High P And Q Breaking the rules - using high non-integer P and q: Create a Torus Knot With High non integer P And Q
Mesh
import { MeshBuilder } from "@babylonjs/core/Meshes/meshBuilder";const knot = MeshBuilder.CreateTorusKnot("knot", { radius, tube, radialSegments, tubularSegments, p, q }, scene);