polyhedronBuilder.d.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import type { Scene } from "../../scene";
  2. import { Vector4 } from "../../Maths/math.vector";
  3. import { Color4 } from "../../Maths/math.color";
  4. import { Mesh } from "../mesh";
  5. import { VertexData } from "../mesh.vertexData";
  6. import type { Nullable } from "../../types";
  7. /**
  8. * Creates the VertexData for a Polyhedron
  9. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  10. * * type provided types are:
  11. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  12. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  13. * * size the size of the IcoSphere, optional default 1
  14. * * sizeX allows stretching in the x direction, optional, default size
  15. * * sizeY allows stretching in the y direction, optional, default size
  16. * * sizeZ allows stretching in the z direction, optional, default size
  17. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  18. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  19. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  20. * * flat when true creates a flat shaded mesh, optional, default true
  21. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23. * * 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)
  24. * * 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)
  25. * @returns the VertexData of the Polyhedron
  26. */
  27. export declare function CreatePolyhedronVertexData(options: {
  28. type?: number;
  29. size?: number;
  30. sizeX?: number;
  31. sizeY?: number;
  32. sizeZ?: number;
  33. custom?: any;
  34. faceUV?: Vector4[];
  35. faceColors?: Color4[];
  36. flat?: boolean;
  37. sideOrientation?: number;
  38. frontUVs?: Vector4;
  39. backUVs?: Vector4;
  40. }): VertexData;
  41. /**
  42. * Creates a polyhedron mesh
  43. * * 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
  44. * * The parameter `size` (positive float, default 1) sets the polygon size
  45. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46. * * 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 overrides the parameter `type`
  47. * * 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
  48. * * 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)`)
  49. * * 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/features/featuresDeepDive/materials/using/texturePerBoxFace
  50. * * 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
  51. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52. * * 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
  53. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54. * @param name defines the name of the mesh
  55. * @param options defines the options used to create the mesh
  56. * @param scene defines the hosting scene
  57. * @returns the polyhedron mesh
  58. * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/polyhedra
  59. */
  60. export declare function CreatePolyhedron(name: string, options?: {
  61. type?: number;
  62. size?: number;
  63. sizeX?: number;
  64. sizeY?: number;
  65. sizeZ?: number;
  66. custom?: any;
  67. faceUV?: Vector4[];
  68. faceColors?: Color4[];
  69. flat?: boolean;
  70. updatable?: boolean;
  71. sideOrientation?: number;
  72. frontUVs?: Vector4;
  73. backUVs?: Vector4;
  74. }, scene?: Nullable<Scene>): Mesh;
  75. /**
  76. * Class containing static functions to help procedurally build meshes
  77. * @deprecated use the function directly from the module
  78. */
  79. export declare const PolyhedronBuilder: {
  80. CreatePolyhedron: typeof CreatePolyhedron;
  81. };