polygonMesh.d.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import type { Scene } from "../scene";
  2. import { Vector2 } from "../Maths/math.vector";
  3. import { Mesh } from "../Meshes/mesh";
  4. import { VertexData } from "../Meshes/mesh.vertexData";
  5. import { Path2 } from "../Maths/math.path";
  6. /**
  7. * Polygon
  8. * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param#non-regular-polygon
  9. */
  10. export declare class Polygon {
  11. /**
  12. * Creates a rectangle
  13. * @param xmin bottom X coord
  14. * @param ymin bottom Y coord
  15. * @param xmax top X coord
  16. * @param ymax top Y coord
  17. * @returns points that make the resulting rectangle
  18. */
  19. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  20. /**
  21. * Creates a circle
  22. * @param radius radius of circle
  23. * @param cx scale in x
  24. * @param cy scale in y
  25. * @param numberOfSides number of sides that make up the circle
  26. * @returns points that make the resulting circle
  27. */
  28. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  29. /**
  30. * Creates a polygon from input string
  31. * @param input Input polygon data
  32. * @returns the parsed points
  33. */
  34. static Parse(input: string): Vector2[];
  35. /**
  36. * Starts building a polygon from x and y coordinates
  37. * @param x x coordinate
  38. * @param y y coordinate
  39. * @returns the started path2
  40. */
  41. static StartingAt(x: number, y: number): Path2;
  42. }
  43. /**
  44. * Builds a polygon
  45. * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/polyMeshBuilder
  46. */
  47. export declare class PolygonMeshBuilder {
  48. private _points;
  49. private _outlinepoints;
  50. private _holes;
  51. private _name;
  52. private _scene;
  53. private _epoints;
  54. private _eholes;
  55. private _addToepoint;
  56. /**
  57. * Babylon reference to the earcut plugin.
  58. */
  59. bjsEarcut: any;
  60. /**
  61. * Creates a PolygonMeshBuilder
  62. * @param name name of the builder
  63. * @param contours Path of the polygon
  64. * @param scene scene to add to when creating the mesh
  65. * @param earcutInjection can be used to inject your own earcut reference
  66. */
  67. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  68. /**
  69. * Adds a hole within the polygon
  70. * @param hole Array of points defining the hole
  71. * @returns this
  72. */
  73. addHole(hole: Vector2[]): PolygonMeshBuilder;
  74. /**
  75. * Creates the polygon
  76. * @param updatable If the mesh should be updatable
  77. * @param depth The depth of the mesh created
  78. * @param smoothingThreshold Dot product threshold for smoothed normals
  79. * @returns the created mesh
  80. */
  81. build(updatable?: boolean, depth?: number, smoothingThreshold?: number): Mesh;
  82. /**
  83. * Creates the polygon
  84. * @param depth The depth of the mesh created
  85. * @param smoothingThreshold Dot product threshold for smoothed normals
  86. * @returns the created VertexData
  87. */
  88. buildVertexData(depth?: number, smoothingThreshold?: number): VertexData;
  89. /**
  90. * Adds a side to the polygon
  91. * @param positions points that make the polygon
  92. * @param normals normals of the polygon
  93. * @param uvs uvs of the polygon
  94. * @param indices indices of the polygon
  95. * @param bounds bounds of the polygon
  96. * @param points points of the polygon
  97. * @param depth depth of the polygon
  98. * @param flip flip of the polygon
  99. * @param smoothingThreshold
  100. */
  101. private _addSide;
  102. }