greasedLinePluginMaterial.d.ts 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. import { RawTexture } from "../Textures/rawTexture";
  2. import { MaterialPluginBase } from "../materialPluginBase";
  3. import type { Scene } from "../../scene";
  4. import type { UniformBuffer } from "../uniformBuffer";
  5. import { Vector2 } from "../../Maths/math.vector";
  6. import type { Color3 } from "../../Maths/math.color";
  7. import type { Nullable } from "../../types";
  8. import type { Material } from "../material";
  9. import { MaterialDefines } from "../materialDefines";
  10. import type { AbstractMesh } from "../../Meshes/abstractMesh";
  11. import type { BaseTexture } from "../Textures/baseTexture";
  12. import type { GreasedLineMaterialOptions, IGreasedLineMaterial } from "./greasedLineMaterialInterfaces";
  13. import { GreasedLineMeshColorDistributionType, GreasedLineMeshColorMode } from "./greasedLineMaterialInterfaces";
  14. /**
  15. * @internal
  16. */
  17. export declare class MaterialGreasedLineDefines extends MaterialDefines {
  18. /**
  19. * The material has a color option specified
  20. */
  21. GREASED_LINE_HAS_COLOR: boolean;
  22. /**
  23. * The material's size attenuation optiom
  24. */
  25. GREASED_LINE_SIZE_ATTENUATION: boolean;
  26. /**
  27. * The type of color distribution is set to line this value equals to true.
  28. */
  29. GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE: boolean;
  30. /**
  31. * True if scene is in right handed coordinate system.
  32. */
  33. GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM: boolean;
  34. /**
  35. * True if the line is in camera facing mode
  36. */
  37. GREASED_LINE_CAMERA_FACING: boolean;
  38. }
  39. /**
  40. * GreasedLinePluginMaterial for GreasedLineMesh/GreasedLineRibbonMesh.
  41. * Use the GreasedLineBuilder.CreateGreasedLineMaterial function to create and instance of this class.
  42. */
  43. export declare class GreasedLinePluginMaterial extends MaterialPluginBase implements IGreasedLineMaterial {
  44. /**
  45. * Plugin name
  46. */
  47. static readonly GREASED_LINE_MATERIAL_NAME = "GreasedLinePluginMaterial";
  48. /**
  49. * Whether to use the colors option to colorize the line
  50. */
  51. useColors: boolean;
  52. /**
  53. * Normalized value of how much of the line will be visible
  54. * 0 - 0% of the line will be visible
  55. * 1 - 100% of the line will be visible
  56. */
  57. visibility: number;
  58. /**
  59. * Dash offset
  60. */
  61. dashOffset: number;
  62. /**
  63. * Length of the dash. 0 to 1. 0.5 means half empty, half drawn.
  64. */
  65. dashRatio: number;
  66. /**
  67. * Line base width. At each point the line width is calculated by widths[pointIndex] * width
  68. */
  69. width: number;
  70. /**
  71. * The type of sampling of the colors texture. The values are the same when using with textures.
  72. */
  73. colorsSampling: number;
  74. /**
  75. * Turns on/off dash mode
  76. */
  77. useDash: boolean;
  78. /**
  79. * The mixing mode of the color paramater. Default value is GreasedLineMeshColorMode.SET
  80. * @see GreasedLineMeshColorMode
  81. */
  82. colorMode: GreasedLineMeshColorMode;
  83. /**
  84. * You can provide a colorsTexture to use instead of one generated from the 'colors' option
  85. */
  86. colorsTexture: Nullable<RawTexture>;
  87. private _scene;
  88. private _dashCount;
  89. private _dashArray;
  90. private _color;
  91. private _colors;
  92. private _colorsDistributionType;
  93. private _resolution;
  94. private _aspect;
  95. private _sizeAttenuation;
  96. private _cameraFacing;
  97. private _engine;
  98. /**
  99. * Creates a new instance of the GreasedLinePluginMaterial
  100. * @param material base material for the plugin
  101. * @param scene the scene
  102. * @param options plugin options
  103. */
  104. constructor(material: Material, scene?: Scene, options?: GreasedLineMaterialOptions);
  105. /**
  106. * Get the shader attributes
  107. * @param attributes array which will be filled with the attributes
  108. */
  109. getAttributes(attributes: string[]): void;
  110. /**
  111. * Get the shader samplers
  112. * @param samplers
  113. */
  114. getSamplers(samplers: string[]): void;
  115. /**
  116. * Get the shader textures
  117. * @param activeTextures array which will be filled with the textures
  118. */
  119. getActiveTextures(activeTextures: BaseTexture[]): void;
  120. /**
  121. * Get the shader uniforms
  122. * @returns uniforms
  123. */
  124. getUniforms(): {
  125. ubo: {
  126. name: string;
  127. size: number;
  128. type: string;
  129. }[];
  130. vertex: string;
  131. fragment: string;
  132. };
  133. get isEnabled(): boolean;
  134. /**
  135. * Bind the uniform buffer
  136. * @param uniformBuffer
  137. */
  138. bindForSubMesh(uniformBuffer: UniformBuffer): void;
  139. /**
  140. * Prepare the defines
  141. * @param defines
  142. * @param _scene
  143. * @param _mesh
  144. */
  145. prepareDefines(defines: MaterialGreasedLineDefines, _scene: Scene, _mesh: AbstractMesh): void;
  146. /**
  147. * Get the class name
  148. * @returns class name
  149. */
  150. getClassName(): string;
  151. /**
  152. * Get shader code
  153. * @param shaderType vertex/fragment
  154. * @returns shader code
  155. */
  156. getCustomCode(shaderType: string): Nullable<{
  157. [pointName: string]: string;
  158. }>;
  159. /**
  160. * Disposes the plugin material.
  161. */
  162. dispose(): void;
  163. /**
  164. * Returns the colors used to colorize the line
  165. */
  166. get colors(): Nullable<Color3[]>;
  167. /**
  168. * Sets the colors used to colorize the line
  169. */
  170. set colors(value: Nullable<Color3[]>);
  171. /**
  172. * Creates or updates the colors texture
  173. * @param colors color table RGBA
  174. * @param lazy if lazy, the colors are not updated
  175. * @param forceNewTexture force creation of a new texture
  176. */
  177. setColors(colors: Nullable<Color3[]>, lazy?: boolean, forceNewTexture?: boolean): void;
  178. /**
  179. * Updates the material. Use when material created in lazy mode.
  180. */
  181. updateLazy(): void;
  182. /**
  183. * Gets the number of dashes in the line
  184. */
  185. get dashCount(): number;
  186. /**
  187. * Sets the number of dashes in the line
  188. * @param value dash
  189. */
  190. set dashCount(value: number);
  191. /**
  192. * If set to true the line will be rendered always with the same width regardless how far it is located from the camera.
  193. * Not supported for non camera facing lines.
  194. */
  195. get sizeAttenuation(): boolean;
  196. /**
  197. * Turn on/off size attenuation of the width option and widths array.
  198. * Not supported for non camera facing lines.
  199. * @param value If set to true the line will be rendered always with the same width regardless how far it is located from the camera.
  200. */
  201. set sizeAttenuation(value: boolean);
  202. /**
  203. * Gets the color of the line
  204. */
  205. get color(): Nullable<Color3>;
  206. /**
  207. * Sets the color of the line
  208. * @param value Color3 or null to clear the color. You need to clear the color if you use colors and useColors = true
  209. */
  210. set color(value: Nullable<Color3>);
  211. /**
  212. * Sets the color of the line. If set the whole line will be mixed with this color according to the colorMode option.
  213. * @param value color
  214. * @param doNotMarkDirty if true, the material will not be marked as dirty
  215. */
  216. setColor(value: Nullable<Color3>, doNotMarkDirty?: boolean): void;
  217. /**
  218. * Gets the color distributiopn type
  219. */
  220. get colorsDistributionType(): GreasedLineMeshColorDistributionType;
  221. /**
  222. * Sets the color distribution type
  223. * @see GreasedLineMeshColorDistributionType
  224. * @param value color distribution type
  225. */
  226. set colorsDistributionType(value: GreasedLineMeshColorDistributionType);
  227. /**
  228. * Gets the resolution
  229. */
  230. get resolution(): Vector2;
  231. /**
  232. * Sets the resolution
  233. * @param value resolution of the screen for GreasedLine
  234. */
  235. set resolution(value: Vector2);
  236. /**
  237. * Serializes this plugin material
  238. * @returns serializationObjec
  239. */
  240. serialize(): any;
  241. /**
  242. * Parses a serialized objects
  243. * @param source serialized object
  244. * @param scene scene
  245. * @param rootUrl root url for textures
  246. */
  247. parse(source: any, scene: Scene, rootUrl: string): void;
  248. /**
  249. * Makes a duplicate of the current configuration into another one.
  250. * @param plugin define the config where to copy the info
  251. */
  252. copyTo(plugin: MaterialPluginBase): void;
  253. }