shapeBuilder.d.ts 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import type { Nullable } from "../../types";
  2. import type { Scene } from "../../scene";
  3. import type { Vector4 } from "../../Maths/math.vector";
  4. import { Vector3 } from "../../Maths/math.vector";
  5. import { Mesh } from "../mesh";
  6. /**
  7. * 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.
  8. * * 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.
  9. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  10. * * 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.
  11. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  12. * * The parameter `closeShape` (boolean, default false) closes the shape when true, since v5.0.0.
  13. * * The parameter `closePath` (boolean, default false) closes the path when true and no caps, since v5.0.0.
  14. * * 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
  15. * * 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/features/featuresDeepDive/mesh/dynamicMeshMorph#extruded-shape
  16. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  17. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18. * * 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
  19. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  20. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21. * * The optional parameter `firstNormal` (Vector3) defines the direction of the first normal of the supplied path. Consider using this for any path that is straight, and particular for paths in the xy plane.
  22. * * The optional `adjustFrame` (boolean, default false) will cause the internally generated Path3D tangents, normals, and binormals to be adjusted so that a) they are always well-defined, and b) they do not reverse from one path point to the next. This prevents the extruded shape from being flipped and/or rotated with resulting mesh self-intersections. This is primarily useful for straight paths that can reverse direction.
  23. * @param name defines the name of the mesh
  24. * @param options defines the options used to create the mesh
  25. * @param scene defines the hosting scene
  26. * @returns the extruded shape mesh
  27. * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param
  28. * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param#extruded-shapes
  29. */
  30. export declare function ExtrudeShape(name: string, options: {
  31. shape: Vector3[];
  32. path: Vector3[];
  33. scale?: number;
  34. rotation?: number;
  35. closeShape?: boolean;
  36. closePath?: boolean;
  37. cap?: number;
  38. updatable?: boolean;
  39. sideOrientation?: number;
  40. frontUVs?: Vector4;
  41. backUVs?: Vector4;
  42. instance?: Mesh;
  43. invertUV?: boolean;
  44. firstNormal?: Vector3;
  45. adjustFrame?: boolean;
  46. }, scene?: Nullable<Scene>): Mesh;
  47. /**
  48. * Creates an custom extruded shape mesh.
  49. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50. * * 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.
  51. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52. * * 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 beginning of the path
  53. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54. * * 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 beginning of the path
  55. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56. * * The parameter `closeShape` (boolean, default false) closes the shape when true, since v5.0.0.
  57. * * The parameter `closePath` (boolean, default false) closes the path when true and no caps, since v5.0.0.
  58. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray` - depreciated in favor of closeShape
  59. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray` - depreciated in favor of closePath
  60. * * 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
  61. * * 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/features/featuresDeepDive/mesh/dynamicMeshMorph#extruded-shape
  62. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  63. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64. * * 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
  65. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67. * * The optional parameter `firstNormal` (Vector3) defines the direction of the first normal of the supplied path. It should be supplied when the path is in the xy plane, and particularly if these sections are straight, because the underlying Path3D object will pick a normal in the xy plane that causes the extrusion to be collapsed into the plane. This should be used for any path that is straight.
  68. * * The optional `adjustFrame` (boolean, default false) will cause the internally generated Path3D tangents, normals, and binormals to be adjusted so that a) they are always well-defined, and b) they do not reverse from one path point to the next. This prevents the extruded shape from being flipped and/or rotated with resulting mesh self-intersections. This is primarily useful for straight paths that can reverse direction.
  69. * @param name defines the name of the mesh
  70. * @param options defines the options used to create the mesh
  71. * @param scene defines the hosting scene
  72. * @returns the custom extruded shape mesh
  73. * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param#custom-extruded-shapes
  74. * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param
  75. * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param#extruded-shapes
  76. */
  77. export declare function ExtrudeShapeCustom(name: string, options: {
  78. shape: Vector3[];
  79. path: Vector3[];
  80. scaleFunction?: Nullable<{
  81. (i: number, distance: number): number;
  82. }>;
  83. rotationFunction?: Nullable<{
  84. (i: number, distance: number): number;
  85. }>;
  86. ribbonCloseArray?: boolean;
  87. ribbonClosePath?: boolean;
  88. closeShape?: boolean;
  89. closePath?: boolean;
  90. cap?: number;
  91. updatable?: boolean;
  92. sideOrientation?: number;
  93. frontUVs?: Vector4;
  94. backUVs?: Vector4;
  95. instance?: Mesh;
  96. invertUV?: boolean;
  97. firstNormal?: Vector3;
  98. adjustFrame?: boolean;
  99. }, scene?: Nullable<Scene>): Mesh;
  100. /**
  101. * Class containing static functions to help procedurally build meshes
  102. * @deprecated please use the functions directly from the module
  103. */
  104. export declare const ShapeBuilder: {
  105. ExtrudeShape: typeof ExtrudeShape;
  106. ExtrudeShapeCustom: typeof ExtrudeShapeCustom;
  107. };