cylinderBuilder.d.ts 6.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import { Vector4 } from "../../Maths/math.vector";
  2. import { Color4 } from "../../Maths/math.color";
  3. import { Mesh } from "../mesh";
  4. import { VertexData } from "../mesh.vertexData";
  5. import { Scene } from "../../scene";
  6. import type { Nullable } from "../../types";
  7. /**
  8. * Creates the VertexData for a cylinder, cone or prism
  9. * @param options an object used to set the following optional parameters for the box, required but can be empty
  10. * * height sets the height (y direction) of the cylinder, optional, default 2
  11. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  12. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  13. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  14. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  15. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  16. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  17. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  18. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  19. * * hasRings when true makes each subdivision independently treated as a face for faceUV and faceColors, optional, default false
  20. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  24. * @returns the VertexData of the cylinder, cone or prism
  25. */
  26. export declare function CreateCylinderVertexData(options: {
  27. height?: number;
  28. diameterTop?: number;
  29. diameterBottom?: number;
  30. diameter?: number;
  31. tessellation?: number;
  32. subdivisions?: number;
  33. arc?: number;
  34. faceColors?: Color4[];
  35. faceUV?: Vector4[];
  36. hasRings?: boolean;
  37. enclose?: boolean;
  38. cap?: number;
  39. sideOrientation?: number;
  40. frontUVs?: Vector4;
  41. backUVs?: Vector4;
  42. }): VertexData;
  43. /**
  44. * Creates a cylinder or a cone mesh
  45. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47. * * 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.
  48. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  51. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52. * * 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).
  53. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  54. * * 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).
  55. * * 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
  56. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  57. * * 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
  58. * * 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.
  59. * * If `enclose` is false, a ring surface is one element.
  60. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61. * * 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
  62. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63. * * 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/features/featuresDeepDive/mesh/creation/set#side-orientation
  64. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65. * @param name defines the name of the mesh
  66. * @param options defines the options used to create the mesh
  67. * @param scene defines the hosting scene
  68. * @returns the cylinder mesh
  69. * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#cylinder-or-cone
  70. */
  71. export declare function CreateCylinder(name: string, options?: {
  72. height?: number;
  73. diameterTop?: number;
  74. diameterBottom?: number;
  75. diameter?: number;
  76. tessellation?: number;
  77. subdivisions?: number;
  78. arc?: number;
  79. faceColors?: Color4[];
  80. faceUV?: Vector4[];
  81. updatable?: boolean;
  82. hasRings?: boolean;
  83. enclose?: boolean;
  84. cap?: number;
  85. sideOrientation?: number;
  86. frontUVs?: Vector4;
  87. backUVs?: Vector4;
  88. }, scene?: Nullable<Scene>): Mesh;
  89. /**
  90. * Class containing static functions to help procedurally build meshes
  91. * @deprecated Please use CreateCylinder directly
  92. */
  93. export declare const CylinderBuilder: {
  94. CreateCylinder: typeof CreateCylinder;
  95. };