greasedLineBuilder.d.ts 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. import { StandardMaterial } from "./../../Materials/standardMaterial";
  2. import { PBRMaterial } from "../../Materials/PBR/pbrMaterial";
  3. import type { Nullable } from "../../types";
  4. import { GreasedLineMesh } from "../GreasedLine/greasedLineMesh";
  5. import type { Scene } from "../../scene";
  6. import type { Color3 } from "../../Maths/math.color";
  7. import { GreasedLineSimpleMaterial } from "../../Materials/GreasedLine/greasedLineSimpleMaterial";
  8. import type { GreasedLineMeshOptions } from "../GreasedLine/greasedLineBaseMesh";
  9. import { GreasedLineRibbonMesh } from "../GreasedLine/greasedLineRibbonMesh";
  10. import type { GreasedLineMaterialOptions } from "../../Materials/GreasedLine/greasedLineMaterialInterfaces";
  11. /**
  12. * How are the colors distributed along the color table
  13. * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colors-and-colordistribution}
  14. */
  15. export declare enum GreasedLineMeshColorDistribution {
  16. /**
  17. * Do no modify the color table
  18. */
  19. COLOR_DISTRIBUTION_NONE = 0,
  20. /**
  21. * Repeat the colors until the color table is full
  22. */
  23. COLOR_DISTRIBUTION_REPEAT = 1,
  24. /**
  25. * Distribute the colors evenly through the color table
  26. */
  27. COLOR_DISTRIBUTION_EVEN = 2,
  28. /**
  29. * Put the colors to start of the color table a fill the rest with the default color
  30. */
  31. COLOR_DISTRIBUTION_START = 3,
  32. /**
  33. * Put the colors to the end of the color table and fill the rest with the default color
  34. */
  35. COLOR_DISTRIBUTION_END = 4,
  36. /**
  37. * Put the colors to start and to the end of the color table and fill the gap between with the default color
  38. */
  39. COLOR_DISTRIBUTION_START_END = 5
  40. }
  41. /**
  42. * How are the widths distributed along the width table
  43. * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#widths-and-widthdistribution}
  44. */
  45. export declare enum GreasedLineMeshWidthDistribution {
  46. /**
  47. * Do no modify the width table
  48. */
  49. WIDTH_DISTRIBUTION_NONE = 0,
  50. /**
  51. * Repeat the widths until the width table is full
  52. */
  53. WIDTH_DISTRIBUTION_REPEAT = 1,
  54. /**
  55. * Distribute the widths evenly through the width table
  56. */
  57. WIDTH_DISTRIBUTION_EVEN = 2,
  58. /**
  59. * Put the widths to start of the width table a fill the rest with the default width
  60. */
  61. WIDTH_DISTRIBUTION_START = 3,
  62. /**
  63. * Put the widths to the end of the width table and fill the rest with the default width
  64. */
  65. WIDTH_DISTRIBUTION_END = 4,
  66. /**
  67. * Put the widths to start and to the end of the width table and fill the gap between with the default width
  68. */
  69. WIDTH_DISTRIBUTION_START_END = 5
  70. }
  71. /**
  72. * Material options for GreasedLineBuilder
  73. */
  74. export interface GreasedLineMaterialBuilderOptions extends GreasedLineMaterialOptions {
  75. /**
  76. * If set to true a new material will be created and a new material plugin will be attached
  77. * to the material. The material will be set on the mesh. If the instance option is specified in the mesh options,
  78. * no material will be created/assigned. Defaults to true.
  79. */
  80. createAndAssignMaterial?: boolean;
  81. /**
  82. * Distribution of the colors if the color table contains fewer entries than needed. Defaults to GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START
  83. * @see CompleteGreasedLineColorTable
  84. */
  85. colorDistribution?: GreasedLineMeshColorDistribution;
  86. }
  87. /**
  88. * Line mesh options for GreasedLineBuilder
  89. */
  90. export interface GreasedLineMeshBuilderOptions extends GreasedLineMeshOptions {
  91. /**
  92. * Distribution of the widths if the width table contains fewer entries than needed. Defaults to GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START
  93. * @see CompleteGreasedLineWidthTable
  94. */
  95. widthDistribution?: GreasedLineMeshWidthDistribution;
  96. }
  97. /**
  98. * Builder functions for creating GreasedLineMeshes
  99. */
  100. /**
  101. * Creates a new @see GreasedLinePluginMaterial
  102. * @param name name of the material
  103. * @param options material options @see GreasedLineMaterialOptions
  104. * @param scene scene or null to use the last scene
  105. * @returns StandardMaterial or PBRMaterial with the @see GreasedLinePluginMaterial attached to it
  106. */
  107. export declare function CreateGreasedLineMaterial(name: string, options: GreasedLineMaterialOptions, scene: Nullable<Scene>): StandardMaterial | PBRMaterial | GreasedLineSimpleMaterial;
  108. /**
  109. * Creates a GreasedLine mesh
  110. * @param name name of the mesh
  111. * @param options options for the mesh
  112. * @param materialOptions material options for the mesh
  113. * @param scene scene where the mesh will be created
  114. * @returns instance of GreasedLineMesh
  115. */
  116. export declare function CreateGreasedLine(name: string, options: GreasedLineMeshBuilderOptions, materialOptions?: Nullable<GreasedLineMaterialBuilderOptions>, scene?: Nullable<Scene>): import("../GreasedLine/greasedLineBaseMesh").GreasedLineBaseMesh | GreasedLineMesh | GreasedLineRibbonMesh;
  117. /**
  118. * Counts the number of points
  119. * @param allPoints Array of points [[x, y, z], [x, y, z], ...] or Array of points [x, y, z, x, y, z, ...]
  120. * @returns total number of points
  121. */
  122. export declare function GetPointsCount(allPoints: number[][]): number;
  123. /**
  124. * Completes the width table/fills the missing entries. It means it creates a width entry for every point of the line mesh.
  125. * You can provide more points the widths when creating the mesh. This function will fill the empty entries.
  126. * The algorithm used to fill the empty entries can be
  127. * GreasedLineMeshWidthDistribution.REPEAT - the width table will be repeatedly copied to the empty values [wL, wU] = [wL, wU, wL, wU, wL, wU, wL, wU, ...]
  128. * GreasedLineMeshWidthDistribution.EVEN - the width table will be evenly copied to the empty values [wL, wU] = [wL, wL, wL, wL, wU, wU, wU, wU]
  129. * GreasedLineMeshWidthDistribution.START - the width table will be copied at the start of the empty values
  130. * and rest will be filled width the default width upper and default width lower values [wU, wL] = [wL, wU, dwL, dwU, dwL, dwU, dwL, dwU]
  131. * GreasedLineMeshWidthDistribution.END - the width table will be copied at the end of the empty values
  132. * and rest will be filled width the default values [wL, wU] = [wL, wU, dwL, dwU, dwL, dwU, wL, wU]
  133. * @param pointCount number of points of the line mesh
  134. * @param widths array of widths [widhtLower, widthUpper, widthLower, widthUpper ...]. Two widths (lower/upper) per point.
  135. * @param widthsDistribution how to distribute widths if the widths array has fewer entries than pointCount
  136. * @param defaultWidthUpper the default value which will be used to fill empty width entries - upper width
  137. * @param defaultWidthLower the default value which will be used to fill empty width entries - lower width
  138. * @returns completed width table.
  139. */
  140. export declare function CompleteGreasedLineWidthTable(pointCount: number, widths: number[], widthsDistribution: GreasedLineMeshWidthDistribution, defaultWidthUpper?: number, defaultWidthLower?: number): number[];
  141. /**
  142. * Completes the color table/fill the missing color entries. It means it creates a color entry for every point of the line mesh.
  143. * You can provide more points the colors when creating the mesh. This function will fill the empty entries.
  144. * The algorithm used to fill the empty entries can be
  145. * GreasedLineMesColorhDistribution.REPEAT - the color table will be repeatedly copied to the empty values [c1, c2] = [c1, c2, c1, c2, c1, c2, c1, c2]
  146. * GreasedLineMesColorhDistribution.EVEN - the color table will be evenly copied to the empty values [c1, c2] = [c1, c1, c1, c1, c2, c2, c2, c2]
  147. * GreasedLineMesColorhDistribution.START - the color table will be copied at the start of the empty values
  148. * and rest will be filled color the default color value [c1, c2] = [c1, c2, dc, dc, dc, dc, dc, dc]
  149. * GreasedLineMesColorhDistribution.START_END - the color table will be copied at the start and the end of the empty values
  150. * and rest will be filled color the default color value [c1, c2] = [c1, c2, dc, dc, dc, dc, c1, c2]
  151. * @param pointCount number of points of the line mesh
  152. * @param colors array of Color3 for the color table
  153. * @param colorDistribution how to distribute colors if the colors array has fewer entries than pointCount
  154. * @param defaultColor default color to be used to fill empty entries in the color table
  155. * @returns completed array of Color3s
  156. */
  157. export declare function CompleteGreasedLineColorTable(pointCount: number, colors: Color3[], colorDistribution: GreasedLineMeshColorDistribution, defaultColor: Color3): Color3[];