polygonBuilder.d.ts 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import type { Scene } from "../../scene";
  2. import type { Vector3 } from "../../Maths/math.vector";
  3. import { Vector4 } from "../../Maths/math.vector";
  4. import { Color4 } from "../../Maths/math.color";
  5. import { Mesh } from "../mesh";
  6. import { VertexData } from "../mesh.vertexData";
  7. import type { Nullable } from "../../types";
  8. /**
  9. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  10. * All parameters are provided by CreatePolygon as needed
  11. * @param polygon a mesh built from polygonTriangulation.build()
  12. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  13. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  14. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  15. * @param 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)
  16. * @param 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)
  17. * @param wrp a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  18. * @returns the VertexData of the Polygon
  19. */
  20. export declare function CreatePolygonVertexData(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrp?: boolean): VertexData;
  21. /**
  22. * Creates a polygon mesh
  23. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  24. * * 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
  25. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27. * * 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)
  28. * * Remember you can only change the shape positions, not their number when updating a polygon
  29. * @param name defines the name of the mesh
  30. * @param options defines the options used to create the mesh
  31. * @param scene defines the hosting scene
  32. * @param earcutInjection can be used to inject your own earcut reference
  33. * @returns the polygon mesh
  34. */
  35. export declare function CreatePolygon(name: string, options: {
  36. shape: Vector3[];
  37. holes?: Vector3[][];
  38. depth?: number;
  39. smoothingThreshold?: number;
  40. faceUV?: Vector4[];
  41. faceColors?: Color4[];
  42. updatable?: boolean;
  43. sideOrientation?: number;
  44. frontUVs?: Vector4;
  45. backUVs?: Vector4;
  46. wrap?: boolean;
  47. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  48. /**
  49. * Creates an extruded polygon mesh, with depth in the Y direction.
  50. * * 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)
  51. * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/texturePerBoxFace
  52. * @param name defines the name of the mesh
  53. * @param options defines the options used to create the mesh
  54. * @param scene defines the hosting scene
  55. * @param earcutInjection can be used to inject your own earcut reference
  56. * @returns the polygon mesh
  57. */
  58. export declare function ExtrudePolygon(name: string, options: {
  59. shape: Vector3[];
  60. holes?: Vector3[][];
  61. depth?: number;
  62. faceUV?: Vector4[];
  63. faceColors?: Color4[];
  64. updatable?: boolean;
  65. sideOrientation?: number;
  66. frontUVs?: Vector4;
  67. backUVs?: Vector4;
  68. wrap?: boolean;
  69. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70. /**
  71. * Class containing static functions to help procedurally build meshes
  72. * @deprecated use the functions directly from the module
  73. */
  74. export declare const PolygonBuilder: {
  75. ExtrudePolygon: typeof ExtrudePolygon;
  76. CreatePolygon: typeof CreatePolygon;
  77. };