greasedLineMaterialInterfaces.d.ts 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. import type { RawTexture } from "../Textures/rawTexture";
  2. import type { Vector2 } from "../../Maths/math.vector";
  3. import type { Nullable } from "../../types";
  4. import type { Color3 } from "../../Maths/math.color";
  5. /**
  6. * Interface which defines the available methods for a GreasedLineMaterial
  7. */
  8. export interface IGreasedLineMaterial {
  9. /**
  10. * Normalized value of how much of the line will be visible
  11. * 0 - 0% of the line will be visible
  12. * 1 - 100% of the line will be visible
  13. */
  14. visibility: number;
  15. /**
  16. * Line base width. At each point the line width is calculated by widths[pointIndex] * width
  17. */
  18. width: number;
  19. /**
  20. * Turns on/off dash mode
  21. */
  22. useDash: boolean;
  23. /**
  24. * @see GreasedLinePluginMaterial.setDashCount
  25. * Number of dashes in the line.
  26. * Defaults to 1.
  27. */
  28. dashCount: number;
  29. /**
  30. * Dash offset
  31. */
  32. dashOffset: number;
  33. /**
  34. * Length of the dash. 0 to 1. 0.5 means half empty, half drawn.
  35. */
  36. dashRatio: number;
  37. /**
  38. * Whether to use the colors option to colorize the line
  39. */
  40. useColors: boolean;
  41. /**
  42. * The mixing mode of the color paramater. Default value is GreasedLineMeshColorMode.SET.
  43. * MATERIAL_TYPE_SIMPLE mixes the color and colors of the greased line material.
  44. * MATERIAL_TYPE_STANDARD and MATERIAL_TYPE_PBR mixes the color from the base material with the color and/or colors of the greased line material.
  45. * @see GreasedLineMeshColorMode
  46. */
  47. colorMode: GreasedLineMeshColorMode;
  48. /**
  49. * Colors of the line segments.
  50. * Defaults to empty.
  51. */
  52. colors: Nullable<Color3[]>;
  53. /**
  54. * If false then width units = scene units. If true then line will width be reduced.
  55. * Defaults to false.
  56. */
  57. sizeAttenuation: boolean;
  58. /**
  59. * Color of the line. Applies to all line segments.
  60. * Defaults to White.
  61. */
  62. color: Nullable<Color3>;
  63. /**
  64. * The method used to distribute the colors along the line.
  65. * You can use segment distribution when each segment will use on color from the color table.
  66. * Or you can use line distribution when the colors are distributed evenly along the line ignoring the segments.
  67. */
  68. colorsDistributionType: GreasedLineMeshColorDistributionType;
  69. /**
  70. * Defaults to engine.getRenderWidth() and engine.getRenderHeight()
  71. * Rendering resolution
  72. */
  73. resolution: Vector2;
  74. /**
  75. * You can provide a colorsTexture to use instead of one generated from the 'colors' option
  76. */
  77. colorsTexture: Nullable<RawTexture>;
  78. /**
  79. * Allows to change the color without marking the material dirty.
  80. * MATERIAL_TYPE_STANDARD and MATERIAL_TYPE_PBR material's shaders will get recompiled if there was no color set and you set a color or when there was a color set and you set it to null.
  81. * @param value the color
  82. * @param doNotMarkDirty the flag
  83. */
  84. setColor(value: Nullable<Color3>, doNotMarkDirty?: boolean): void;
  85. /**
  86. * Set the colors
  87. * @param colors colors array
  88. * @param lazy if true the colors texture will not be updated
  89. * @param forceNewTexture forces to create a new colors texture
  90. */
  91. setColors(colors: Nullable<Color3[]>, lazy: boolean, forceNewTexture?: boolean): void;
  92. /**
  93. * Creates and sets the colors texture from the colors array which was created in lazy mode
  94. */
  95. updateLazy(): void;
  96. }
  97. /**
  98. * Material types for GreasedLine
  99. * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#materialtype}
  100. */
  101. export declare enum GreasedLineMeshMaterialType {
  102. /**
  103. * StandardMaterial
  104. */
  105. MATERIAL_TYPE_STANDARD = 0,
  106. /**
  107. * PBR Material
  108. */
  109. MATERIAL_TYPE_PBR = 1,
  110. /**
  111. * Simple and fast shader material not supporting lightning nor textures
  112. */
  113. MATERIAL_TYPE_SIMPLE = 2
  114. }
  115. /**
  116. * Color blending mode of the @see GreasedLineMaterial and the base material
  117. * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colormode}
  118. */
  119. export declare enum GreasedLineMeshColorMode {
  120. /**
  121. * Color blending mode SET
  122. */
  123. COLOR_MODE_SET = 0,
  124. /**
  125. * Color blending mode ADD
  126. */
  127. COLOR_MODE_ADD = 1,
  128. /**
  129. * Color blending mode ADD
  130. */
  131. COLOR_MODE_MULTIPLY = 2
  132. }
  133. /**
  134. * Color distribution type of the @see colors.
  135. * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colordistributiontype}
  136. *
  137. */
  138. export declare enum GreasedLineMeshColorDistributionType {
  139. /**
  140. * Colors distributed between segments of the line
  141. */
  142. COLOR_DISTRIBUTION_TYPE_SEGMENT = 0,
  143. /**
  144. * Colors distributed along the line ingoring the segments
  145. */
  146. COLOR_DISTRIBUTION_TYPE_LINE = 1
  147. }
  148. /**
  149. * Options for GreasedLineMaterial
  150. */
  151. export interface GreasedLineMaterialOptions {
  152. /**
  153. * Line width. If sizeAttenuation os false scene units will be used for width.
  154. * Defaults to 0.1 if @see sizeAttenuation is false, or to 1 if it's true.
  155. */
  156. width?: number;
  157. /**
  158. * If false then width units = scene units. If true then line will width be reduced.
  159. * Defaults to false.
  160. */
  161. sizeAttenuation?: boolean;
  162. /**
  163. * Type of the material to use to render the line.
  164. * Defaults to StandardMaterial.
  165. */
  166. materialType?: GreasedLineMeshMaterialType;
  167. /**
  168. * Color of the line. Applies to all line segments.
  169. * Defaults to White.
  170. */
  171. color?: Color3;
  172. /**
  173. * Color mode of the line. Applies to all line segments.
  174. * The pixel color from the material shader will be modified with the value of @see color using the colorMode.
  175. * Defaults to @see GreasedLineMeshColorMode.SET
  176. */
  177. colorMode?: GreasedLineMeshColorMode;
  178. /**
  179. * Colors of the line segments.
  180. * Defaults to empty.
  181. */
  182. colors?: Color3[];
  183. /**
  184. * If true, @see colors are used, otherwise they're ignored.
  185. * Defaults to false.
  186. */
  187. useColors?: boolean;
  188. /**
  189. * Sampling type of the colors texture
  190. * Defaults to NEAREST_NEAREST.
  191. */
  192. colorsSampling?: number;
  193. /**
  194. * The method used to distribute the colors along the line.
  195. * You can use segment distribution when each segment will use on color from the color table.
  196. * Or you can use line distribution when the colors are distributed evenly along the line ignoring the segments.
  197. */
  198. colorDistributionType?: GreasedLineMeshColorDistributionType;
  199. /**
  200. * If true, dashing is used.
  201. * Defaults to false.
  202. */
  203. useDash?: boolean;
  204. /**
  205. * @see GreasedLinePluginMaterial.setDashCount
  206. * Number of dashes in the line.
  207. * Defaults to 1.
  208. */
  209. dashCount?: number;
  210. /**
  211. * Offset of the dashes along the line. 0 to 1.
  212. * Defaults to 0.
  213. * @see GreasedLinePluginMaterial.setDashOffset
  214. */
  215. dashOffset?: number;
  216. /**
  217. * Length of the dash. 0 to 1. 0.5 means half empty, half drawn.
  218. * Defaults to 0.5.
  219. * @see GreasedLinePluginMaterial.setDashRatio
  220. */
  221. dashRatio?: number;
  222. /**
  223. * Sets the line length visibility.
  224. * 0 - 0% of the line will be visible.
  225. * 1 - 100% of the line will be visible.
  226. * @see GreasedLinePluginMaterial.setVisibility
  227. */
  228. visibility?: number;
  229. /**
  230. * Defaults to engine.getRenderWidth() and engine.getRenderHeight()
  231. * Rendering resolution
  232. */
  233. resolution?: Vector2;
  234. /**
  235. * Whether to use camera facing for the line.
  236. * Defaults to true.
  237. */
  238. cameraFacing?: boolean;
  239. /**
  240. * You can provide a colorsTexture to use instead of one generated from the 'colors' option
  241. */
  242. colorsTexture?: RawTexture;
  243. }