meshBuilder.ts 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. import { RibbonBuilder } from "./Builders/ribbonBuilder";
  2. import { DiscBuilder } from "./Builders/discBuilder";
  3. import { BoxBuilder } from "./Builders/boxBuilder";
  4. import { TiledBoxBuilder } from "./Builders/tiledBoxBuilder";
  5. import { SphereBuilder } from "./Builders/sphereBuilder";
  6. import { CylinderBuilder } from "./Builders/cylinderBuilder";
  7. import { TorusBuilder } from "./Builders/torusBuilder";
  8. import { TorusKnotBuilder } from "./Builders/torusKnotBuilder";
  9. import { LinesBuilder } from "./Builders/linesBuilder";
  10. import { PolygonBuilder } from "./Builders/polygonBuilder";
  11. import { ShapeBuilder } from "./Builders/shapeBuilder";
  12. import { LatheBuilder } from "./Builders/latheBuilder";
  13. import { PlaneBuilder } from "./Builders/planeBuilder";
  14. import { TiledPlaneBuilder } from "./Builders/tiledPlaneBuilder";
  15. import { GroundBuilder } from "./Builders/groundBuilder";
  16. import { TubeBuilder } from "./Builders/tubeBuilder";
  17. import { PolyhedronBuilder } from "./Builders/polyhedronBuilder";
  18. import { IcoSphereBuilder } from "./Builders/icoSphereBuilder";
  19. import { DecalBuilder } from "./Builders/decalBuilder";
  20. import { CapsuleBuilder, ICreateCapsuleOptions } from "./Builders/capsuleBuilder";
  21. import { Vector4, Vector3, Vector2 } from "../Maths/math.vector";
  22. import { Nullable } from "../types";
  23. import { Scene } from "../scene";
  24. import { Mesh } from "./mesh";
  25. import { LinesMesh } from "./linesMesh";
  26. import { GroundMesh } from "./groundMesh";
  27. import { AbstractMesh } from "./abstractMesh";
  28. import { Color4, Color3 } from '../Maths/math.color';
  29. import { Plane } from '../Maths/math.plane';
  30. declare var earcut: any;
  31. /**
  32. * Class containing static functions to help procedurally build meshes
  33. */
  34. export class MeshBuilder {
  35. /**
  36. * Creates a box mesh
  37. * * The parameter `size` sets the size (float) of each box side (default 1)
  38. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  39. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  40. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45. * @param name defines the name of the mesh
  46. * @param options defines the options used to create the mesh
  47. * @param scene defines the hosting scene
  48. * @returns the box mesh
  49. */
  50. public static CreateBox(name: string, options: { size?: number, width?: number, height?: number, depth?: number, faceUV?: Vector4[], faceColors?: Color4[], sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean, topBaseAt?: number, bottomBaseAt?: number, updatable?: boolean }, scene: Nullable<Scene> = null): Mesh {
  51. return BoxBuilder.CreateBox(name, options, scene);
  52. }
  53. /**
  54. * Creates a tiled box mesh
  55. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57. * @param name defines the name of the mesh
  58. * @param options defines the options used to create the mesh
  59. * @param scene defines the hosting scene
  60. * @returns the tiled box mesh
  61. */
  62. public static CreateTiledBox(name: string, options: { pattern?: number, size?: number, width?: number, height?: number, depth: number, tileSize?: number, tileWidth?: number, tileHeight?: number, faceUV?: Vector4[], faceColors?: Color4[], alignHorizontal?: number, alignVertical?: number, sideOrientation?: number, updatable?: boolean }, scene: Nullable<Scene> = null): Mesh {
  63. return TiledBoxBuilder.CreateTiledBox(name, options, scene);
  64. }
  65. /**
  66. * Creates a sphere mesh
  67. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  68. * * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters `diameterX`, `diameterY` and `diameterZ` (all by default have the same value of `diameter`)
  69. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70. * * You can create an unclosed sphere with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference (latitude) : 2 x PI x ratio
  71. * * You can create an unclosed sphere on its height with the parameter `slice` (positive float, default1), valued between 0 and 1, what is the height ratio (longitude)
  72. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  74. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  75. * @param name defines the name of the mesh
  76. * @param options defines the options used to create the mesh
  77. * @param scene defines the hosting scene
  78. * @returns the sphere mesh
  79. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  80. */
  81. public static CreateSphere(name: string, options: { segments?: number, diameter?: number, diameterX?: number, diameterY?: number, diameterZ?: number, arc?: number, slice?: number, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, updatable?: boolean }, scene: Nullable<Scene> = null): Mesh {
  82. return SphereBuilder.CreateSphere(name, options, scene);
  83. }
  84. /**
  85. * Creates a plane polygonal mesh. By default, this is a disc
  86. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  87. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  88. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  89. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  91. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92. * @param name defines the name of the mesh
  93. * @param options defines the options used to create the mesh
  94. * @param scene defines the hosting scene
  95. * @returns the plane polygonal mesh
  96. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  97. */
  98. public static CreateDisc(name: string, options: { radius?: number, tessellation?: number, arc?: number, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }, scene: Nullable<Scene> = null): Mesh {
  99. return DiscBuilder.CreateDisc(name, options, scene);
  100. }
  101. /**
  102. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  103. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  104. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value of `radius`)
  105. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  106. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110. * @param name defines the name of the mesh
  111. * @param options defines the options used to create the mesh
  112. * @param scene defines the hosting scene
  113. * @returns the icosahedron mesh
  114. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115. */
  116. public static CreateIcoSphere(name: string, options: { radius?: number, radiusX?: number, radiusY?: number, radiusZ?: number, flat?: boolean, subdivisions?: number, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, updatable?: boolean }, scene: Nullable<Scene> = null): Mesh {
  117. return IcoSphereBuilder.CreateIcoSphere(name, options, scene);
  118. }
  119. /**
  120. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  122. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  123. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  124. * * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path
  125. * * It's the offset to join the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11
  126. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130. * * The parameter `uvs` is an optional flat array of `Vector2` to update/set each ribbon vertex with its own custom UV values instead of the computed ones
  131. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  132. * * Note that if you use the parameters `uvs` or `colors`, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  133. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135. * @param name defines the name of the mesh
  136. * @param options defines the options used to create the mesh
  137. * @param scene defines the hosting scene
  138. * @returns the ribbon mesh
  139. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  140. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141. */
  142. public static CreateRibbon(name: string, options: { pathArray: Vector3[][], closeArray?: boolean, closePath?: boolean, offset?: number, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, instance?: Mesh, invertUV?: boolean, uvs?: Vector2[], colors?: Color4[] }, scene: Nullable<Scene> = null): Mesh {
  143. return RibbonBuilder.CreateRibbon(name, options, scene);
  144. }
  145. /**
  146. * Creates a cylinder or a cone mesh
  147. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  148. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  149. * * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
  150. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  151. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  152. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  153. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  154. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  155. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  156. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of n Color3 elements) and `faceUV` (an array of n Vector4 elements).
  157. * * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3
  158. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  159. * * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17
  160. * * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.
  161. * * If `enclose` is false, a ring surface is one element.
  162. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  163. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  167. * @param name defines the name of the mesh
  168. * @param options defines the options used to create the mesh
  169. * @param scene defines the hosting scene
  170. * @returns the cylinder mesh
  171. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  172. */
  173. public static CreateCylinder(name: string, options: { height?: number, diameterTop?: number, diameterBottom?: number, diameter?: number, tessellation?: number, subdivisions?: number, arc?: number, faceColors?: Color4[], faceUV?: Vector4[], updatable?: boolean, hasRings?: boolean, enclose?: boolean, cap?: number, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }, scene: Nullable<Scene> = null): Mesh {
  174. return CylinderBuilder.CreateCylinder(name, options, scene);
  175. }
  176. /**
  177. * Creates a torus mesh
  178. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  179. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  180. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  182. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  184. * @param name defines the name of the mesh
  185. * @param options defines the options used to create the mesh
  186. * @param scene defines the hosting scene
  187. * @returns the torus mesh
  188. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  189. */
  190. public static CreateTorus(name: string, options: { diameter?: number, thickness?: number, tessellation?: number, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }, scene: Nullable<Scene> = null): Mesh {
  191. return TorusBuilder.CreateTorus(name, options, scene);
  192. }
  193. /**
  194. * Creates a torus knot mesh
  195. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  196. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  197. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  198. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  200. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  202. * @param name defines the name of the mesh
  203. * @param options defines the options used to create the mesh
  204. * @param scene defines the hosting scene
  205. * @returns the torus knot mesh
  206. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  207. */
  208. public static CreateTorusKnot(name: string, options: { radius?: number, tube?: number, radialSegments?: number, tubularSegments?: number, p?: number, q?: number, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }, scene: Nullable<Scene> = null): Mesh {
  209. return TorusKnotBuilder.CreateTorusKnot(name, options, scene);
  210. }
  211. /**
  212. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  213. * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
  214. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  215. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  216. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  217. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  218. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  219. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  220. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  222. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  223. * @param name defines the name of the new line system
  224. * @param options defines the options used to create the line system
  225. * @param scene defines the hosting scene
  226. * @returns a new line system mesh
  227. */
  228. public static CreateLineSystem(name: string, options: { lines: Vector3[][], updatable?: boolean, instance?: Nullable<LinesMesh>, colors?: Nullable<Color4[][]>, useVertexAlpha?: boolean }, scene: Nullable<Scene>): LinesMesh {
  229. return LinesBuilder.CreateLineSystem(name, options, scene);
  230. }
  231. /**
  232. * Creates a line mesh
  233. * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  234. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  235. * * The parameter `points` is an array successive Vector3
  236. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  237. * * The optional parameter `colors` is an array of successive Color4, one per line point
  238. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  239. * * When updating an instance, remember that only point positions can change, not the number of points
  240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  241. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  242. * @param name defines the name of the new line system
  243. * @param options defines the options used to create the line system
  244. * @param scene defines the hosting scene
  245. * @returns a new line mesh
  246. */
  247. public static CreateLines(name: string, options: { points: Vector3[], updatable?: boolean, instance?: Nullable<LinesMesh>, colors?: Color4[], useVertexAlpha?: boolean }, scene: Nullable<Scene> = null): LinesMesh {
  248. return LinesBuilder.CreateLines(name, options, scene);
  249. }
  250. /**
  251. * Creates a dashed line mesh
  252. * * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  253. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  254. * * The parameter `points` is an array successive Vector3
  255. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  256. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  257. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  258. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  259. * * When updating an instance, remember that only point positions can change, not the number of points
  260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  261. * @param name defines the name of the mesh
  262. * @param options defines the options used to create the mesh
  263. * @param scene defines the hosting scene
  264. * @returns the dashed line mesh
  265. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  266. */
  267. public static CreateDashedLines(name: string, options: { points: Vector3[], dashSize?: number, gapSize?: number, dashNb?: number, updatable?: boolean, instance?: LinesMesh }, scene: Nullable<Scene> = null): LinesMesh {
  268. return LinesBuilder.CreateDashedLines(name, options, scene);
  269. }
  270. /**
  271. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  272. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  273. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  274. * * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  275. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  276. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  277. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  278. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  280. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  281. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  283. * @param name defines the name of the mesh
  284. * @param options defines the options used to create the mesh
  285. * @param scene defines the hosting scene
  286. * @returns the extruded shape mesh
  287. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  288. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  289. */
  290. public static ExtrudeShape(name: string, options: { shape: Vector3[], path: Vector3[], scale?: number, rotation?: number, cap?: number, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, instance?: Mesh, invertUV?: boolean }, scene: Nullable<Scene> = null): Mesh {
  291. return ShapeBuilder.ExtrudeShape(name, options, scene);
  292. }
  293. /**
  294. * Creates an custom extruded shape mesh.
  295. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  296. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  297. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  298. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  299. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  300. * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  301. * * It must returns a float value that will be the scale value applied to the shape on each path point
  302. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  303. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  304. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  305. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  306. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  308. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  309. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  311. * @param name defines the name of the mesh
  312. * @param options defines the options used to create the mesh
  313. * @param scene defines the hosting scene
  314. * @returns the custom extruded shape mesh
  315. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  316. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  317. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  318. */
  319. public static ExtrudeShapeCustom(name: string, options: { shape: Vector3[], path: Vector3[], scaleFunction?: any, rotationFunction?: any, ribbonCloseArray?: boolean, ribbonClosePath?: boolean, cap?: number, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, instance?: Mesh, invertUV?: boolean }, scene: Nullable<Scene> = null): Mesh {
  320. return ShapeBuilder.ExtrudeShapeCustom(name, options, scene);
  321. }
  322. /**
  323. * Creates lathe mesh.
  324. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  325. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  326. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  327. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  328. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  329. * * The parameter `arc` (positive float, default 1) is the ratio of the lathe. 0.5 builds for instance half a lathe, so an opened shape
  330. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  331. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  333. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  334. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  336. * @param name defines the name of the mesh
  337. * @param options defines the options used to create the mesh
  338. * @param scene defines the hosting scene
  339. * @returns the lathe mesh
  340. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  341. */
  342. public static CreateLathe(name: string, options: { shape: Vector3[], radius?: number, tessellation?: number, clip?: number, arc?: number, closed?: boolean, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, cap?: number, invertUV?: boolean }, scene: Nullable<Scene> = null): Mesh {
  343. return LatheBuilder.CreateLathe(name, options, scene);
  344. }
  345. /**
  346. * Creates a tiled plane mesh
  347. * * You can set a limited pattern arrangement with the tiles
  348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  349. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  351. * @param name defines the name of the mesh
  352. * @param options defines the options used to create the mesh
  353. * @param scene defines the hosting scene
  354. * @returns the plane mesh
  355. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  356. */
  357. public static CreateTiledPlane(name: string, options: { pattern?: number, tileSize?: number, tileWidth?: number, tileHeight?: number, size?: number, width?: number, height?: number, alignHorizontal?: number, alignVertical?: number, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, updatable?: boolean }, scene: Nullable<Scene> = null): Mesh {
  358. return TiledPlaneBuilder.CreateTiledPlane(name, options, scene);
  359. }
  360. /**
  361. * Creates a plane mesh
  362. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  363. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  364. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  365. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  366. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  368. * @param name defines the name of the mesh
  369. * @param options defines the options used to create the mesh
  370. * @param scene defines the hosting scene
  371. * @returns the plane mesh
  372. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  373. */
  374. public static CreatePlane(name: string, options: { size?: number, width?: number, height?: number, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, updatable?: boolean, sourcePlane?: Plane }, scene: Nullable<Scene> = null): Mesh {
  375. return PlaneBuilder.CreatePlane(name, options, scene);
  376. }
  377. /**
  378. * Creates a ground mesh
  379. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  380. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  382. * @param name defines the name of the mesh
  383. * @param options defines the options used to create the mesh
  384. * @param scene defines the hosting scene
  385. * @returns the ground mesh
  386. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  387. */
  388. public static CreateGround(name: string, options: { width?: number, height?: number, subdivisions?: number, subdivisionsX?: number, subdivisionsY?: number, updatable?: boolean }, scene: Nullable<Scene> = null): Mesh {
  389. return GroundBuilder.CreateGround(name, options, scene);
  390. }
  391. /**
  392. * Creates a tiled ground mesh
  393. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  394. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  395. * * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  396. * * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  398. * @param name defines the name of the mesh
  399. * @param options defines the options used to create the mesh
  400. * @param scene defines the hosting scene
  401. * @returns the tiled ground mesh
  402. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  403. */
  404. public static CreateTiledGround(name: string, options: { xmin: number, zmin: number, xmax: number, zmax: number, subdivisions?: { w: number; h: number; }, precision?: { w: number; h: number; }, updatable?: boolean }, scene: Nullable<Scene> = null): Mesh {
  405. return GroundBuilder.CreateTiledGround(name, options, scene);
  406. }
  407. /**
  408. * Creates a ground mesh from a height map
  409. * * The parameter `url` sets the URL of the height map image resource.
  410. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  411. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  412. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  413. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  414. * * The parameter `colorFilter` (optional Color3, default (0.3, 0.59, 0.11) ) is the filter to apply to the image pixel colors to compute the height.
  415. * * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  416. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  418. * @param name defines the name of the mesh
  419. * @param url defines the url to the height map
  420. * @param options defines the options used to create the mesh
  421. * @param scene defines the hosting scene
  422. * @returns the ground mesh
  423. * @see https://doc.babylonjs.com/babylon101/height_map
  424. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  425. */
  426. public static CreateGroundFromHeightMap(name: string, url: string, options: { width?: number, height?: number, subdivisions?: number, minHeight?: number, maxHeight?: number, colorFilter?: Color3, alphaFilter?: number, updatable?: boolean, onReady?: (mesh: GroundMesh) => void }, scene: Nullable<Scene> = null): GroundMesh {
  427. return GroundBuilder.CreateGroundFromHeightMap(name, url, options, scene);
  428. }
  429. /**
  430. * Creates a polygon mesh
  431. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  432. * * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  433. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  435. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  436. * * Remember you can only change the shape positions, not their number when updating a polygon
  437. * @param name defines the name of the mesh
  438. * @param options defines the options used to create the mesh
  439. * @param scene defines the hosting scene
  440. * @param earcutInjection can be used to inject your own earcut reference
  441. * @returns the polygon mesh
  442. */
  443. public static CreatePolygon(name: string, options: { shape: Vector3[], holes?: Vector3[][], depth?: number, faceUV?: Vector4[], faceColors?: Color4[], updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, }, scene: Nullable<Scene> = null, earcutInjection = earcut): Mesh {
  444. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  445. }
  446. /**
  447. * Creates an extruded polygon mesh, with depth in the Y direction.
  448. * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
  449. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  450. * @param name defines the name of the mesh
  451. * @param options defines the options used to create the mesh
  452. * @param scene defines the hosting scene
  453. * @param earcutInjection can be used to inject your own earcut reference
  454. * @returns the polygon mesh
  455. */
  456. public static ExtrudePolygon(name: string, options: { shape: Vector3[], holes?: Vector3[][], depth?: number, faceUV?: Vector4[], faceColors?: Color4[], updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }, scene: Nullable<Scene> = null, earcutInjection = earcut): Mesh {
  457. return PolygonBuilder.ExtrudePolygon(name, options, scene, earcutInjection);
  458. }
  459. /**
  460. * Creates a tube mesh.
  461. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  462. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  463. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  464. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  465. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  466. * * This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path. It must return a radius value (positive float)
  467. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  468. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  469. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  471. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  472. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  474. * @param name defines the name of the mesh
  475. * @param options defines the options used to create the mesh
  476. * @param scene defines the hosting scene
  477. * @returns the tube mesh
  478. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  479. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  480. */
  481. public static CreateTube(name: string, options: { path: Vector3[], radius?: number, tessellation?: number, radiusFunction?: { (i: number, distance: number): number; }, cap?: number, arc?: number, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, instance?: Mesh, invertUV?: boolean }, scene: Nullable<Scene> = null): Mesh {
  482. return TubeBuilder.CreateTube(name, options, scene);
  483. }
  484. /**
  485. * Creates a polyhedron mesh
  486. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  487. * * The parameter `size` (positive float, default 1) sets the polygon size
  488. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  489. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  490. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  491. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  492. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  493. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  495. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  497. * @param name defines the name of the mesh
  498. * @param options defines the options used to create the mesh
  499. * @param scene defines the hosting scene
  500. * @returns the polyhedron mesh
  501. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  502. */
  503. public static CreatePolyhedron(name: string, options: { type?: number, size?: number, sizeX?: number, sizeY?: number, sizeZ?: number, custom?: any, faceUV?: Vector4[], faceColors?: Color4[], flat?: boolean, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }, scene: Nullable<Scene> = null): Mesh {
  504. return PolyhedronBuilder.CreatePolyhedron(name, options, scene);
  505. }
  506. /**
  507. * Creates a decal mesh.
  508. * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal
  509. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  510. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  511. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  512. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  513. * @param name defines the name of the mesh
  514. * @param sourceMesh defines the mesh where the decal must be applied
  515. * @param options defines the options used to create the mesh
  516. * @param scene defines the hosting scene
  517. * @returns the decal mesh
  518. * @see https://doc.babylonjs.com/how_to/decals
  519. */
  520. public static CreateDecal(name: string, sourceMesh: AbstractMesh, options: { position?: Vector3, normal?: Vector3, size?: Vector3, angle?: number }): Mesh {
  521. return DecalBuilder.CreateDecal(name, sourceMesh, options);
  522. }
  523. /**
  524. * @param name defines the name of the mesh.
  525. * @param options the constructors options used to shape the mesh.
  526. * @param scene defines the scene the mesh is scoped to.
  527. * @returns the capsule mesh
  528. * @see https://doc.babylonjs.com/how_to/capsule_shape
  529. */
  530. public static CreateCapsule(name: string, options: ICreateCapsuleOptions = {
  531. orientation : Vector3.Up(),
  532. subdivisions: 2,
  533. tessellation: 16,
  534. height: 1,
  535. radius: 0.25,
  536. capSubdivisions: 6
  537. }, scene: Nullable<Scene> = null): Mesh {
  538. return CapsuleBuilder.CreateCapsule(name, options, scene);
  539. }
  540. }