nodeMaterial.d.ts 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. import type { NodeMaterialBlock } from "./nodeMaterialBlock";
  2. import { PushMaterial } from "../pushMaterial";
  3. import type { Scene } from "../../scene";
  4. import { AbstractMesh } from "../../Meshes/abstractMesh";
  5. import { Matrix } from "../../Maths/math.vector";
  6. import { Color4 } from "../../Maths/math.color";
  7. import type { Mesh } from "../../Meshes/mesh";
  8. import { Engine } from "../../Engines/engine";
  9. import { Effect } from "../effect";
  10. import type { BaseTexture } from "../../Materials/Textures/baseTexture";
  11. import { Observable } from "../../Misc/observable";
  12. import type { SubMesh } from "../../Meshes/subMesh";
  13. import { MaterialDefines } from "../../Materials/materialDefines";
  14. import type { NodeMaterialOptimizer } from "./Optimizers/nodeMaterialOptimizer";
  15. import type { ImageProcessingConfiguration } from "../imageProcessingConfiguration";
  16. import type { Nullable } from "../../types";
  17. import { InputBlock } from "./Blocks/Input/inputBlock";
  18. import type { TextureBlock } from "./Blocks/Dual/textureBlock";
  19. import type { ReflectionTextureBaseBlock } from "./Blocks/Dual/reflectionTextureBaseBlock";
  20. import type { RefractionBlock } from "./Blocks/PBR/refractionBlock";
  21. import { CurrentScreenBlock } from "./Blocks/Dual/currentScreenBlock";
  22. import { ParticleTextureBlock } from "./Blocks/Particle/particleTextureBlock";
  23. import type { PostProcessOptions } from "../../PostProcesses/postProcess";
  24. import { PostProcess } from "../../PostProcesses/postProcess";
  25. import type { Camera } from "../../Cameras/camera";
  26. import { NodeMaterialModes } from "./Enums/nodeMaterialModes";
  27. import type { IParticleSystem } from "../../Particles/IParticleSystem";
  28. import { ProceduralTexture } from "../Textures/Procedurals/proceduralTexture";
  29. import type { ImageSourceBlock } from "./Blocks/Dual/imageSourceBlock";
  30. import type { Material } from "../material";
  31. import type { TriPlanarBlock } from "./Blocks/triPlanarBlock";
  32. import type { BiPlanarBlock } from "./Blocks/biPlanarBlock";
  33. import type { PrePassRenderer } from "../../Rendering/prePassRenderer";
  34. import type { PrePassTextureBlock } from "./Blocks/Input/prePassTextureBlock";
  35. import type { IImageProcessingConfigurationDefines } from "../imageProcessingConfiguration.defines";
  36. /**
  37. * Interface used to configure the node material editor
  38. */
  39. export interface INodeMaterialEditorOptions {
  40. /** Define the URL to load node editor script from */
  41. editorURL?: string;
  42. /** Additional configuration for the NME */
  43. nodeEditorConfig?: {
  44. backgroundColor?: Color4;
  45. };
  46. }
  47. /** @internal */
  48. export declare class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  49. /** Normal */
  50. NORMAL: boolean;
  51. /** Tangent */
  52. TANGENT: boolean;
  53. /** Vertex color */
  54. VERTEXCOLOR_NME: boolean;
  55. /** Uv1 **/
  56. UV1: boolean;
  57. /** Uv2 **/
  58. UV2: boolean;
  59. /** Uv3 **/
  60. UV3: boolean;
  61. /** Uv4 **/
  62. UV4: boolean;
  63. /** Uv5 **/
  64. UV5: boolean;
  65. /** Uv6 **/
  66. UV6: boolean;
  67. /** Prepass **/
  68. PREPASS: boolean;
  69. /** Prepass normal */
  70. PREPASS_NORMAL: boolean;
  71. /** Prepass normal index */
  72. PREPASS_NORMAL_INDEX: number;
  73. /** Prepass position */
  74. PREPASS_POSITION: boolean;
  75. /** Prepass position index */
  76. PREPASS_POSITION_INDEX: number;
  77. /** Prepass depth */
  78. PREPASS_DEPTH: boolean;
  79. /** Prepass depth index */
  80. PREPASS_DEPTH_INDEX: number;
  81. /** Scene MRT count */
  82. SCENE_MRT_COUNT: number;
  83. /** BONES */
  84. NUM_BONE_INFLUENCERS: number;
  85. /** Bones per mesh */
  86. BonesPerMesh: number;
  87. /** Using texture for bone storage */
  88. BONETEXTURE: boolean;
  89. /** MORPH TARGETS */
  90. MORPHTARGETS: boolean;
  91. /** Morph target normal */
  92. MORPHTARGETS_NORMAL: boolean;
  93. /** Morph target tangent */
  94. MORPHTARGETS_TANGENT: boolean;
  95. /** Morph target uv */
  96. MORPHTARGETS_UV: boolean;
  97. /** Number of morph influencers */
  98. NUM_MORPH_INFLUENCERS: number;
  99. /** Using a texture to store morph target data */
  100. MORPHTARGETS_TEXTURE: boolean;
  101. /** IMAGE PROCESSING */
  102. IMAGEPROCESSING: boolean;
  103. /** Vignette */
  104. VIGNETTE: boolean;
  105. /** Multiply blend mode for vignette */
  106. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107. /** Opaque blend mode for vignette */
  108. VIGNETTEBLENDMODEOPAQUE: boolean;
  109. /** Tone mapping */
  110. TONEMAPPING: boolean;
  111. /** ACES tone mapping mode */
  112. TONEMAPPING_ACES: boolean;
  113. /** Contrast */
  114. CONTRAST: boolean;
  115. /** Exposure */
  116. EXPOSURE: boolean;
  117. /** Color curves */
  118. COLORCURVES: boolean;
  119. /** Color grading */
  120. COLORGRADING: boolean;
  121. /** 3D color grading */
  122. COLORGRADING3D: boolean;
  123. /** Sampler green depth */
  124. SAMPLER3DGREENDEPTH: boolean;
  125. /** Sampler for BGR map */
  126. SAMPLER3DBGRMAP: boolean;
  127. /** Dithering */
  128. DITHER: boolean;
  129. /** Using post process for image processing */
  130. IMAGEPROCESSINGPOSTPROCESS: boolean;
  131. /** Skip color clamp */
  132. SKIPFINALCOLORCLAMP: boolean;
  133. /** MISC. */
  134. BUMPDIRECTUV: number;
  135. /** Camera is orthographic */
  136. CAMERA_ORTHOGRAPHIC: boolean;
  137. /** Camera is perspective */
  138. CAMERA_PERSPECTIVE: boolean;
  139. /**
  140. * Creates a new NodeMaterialDefines
  141. */
  142. constructor();
  143. /**
  144. * Set the value of a specific key
  145. * @param name defines the name of the key to set
  146. * @param value defines the value to set
  147. * @param markAsUnprocessedIfDirty Flag to indicate to the cache that this value needs processing
  148. */
  149. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  150. }
  151. /**
  152. * Class used to configure NodeMaterial
  153. */
  154. export interface INodeMaterialOptions {
  155. /**
  156. * Defines if blocks should emit comments
  157. */
  158. emitComments: boolean;
  159. }
  160. /**
  161. * Blocks that manage a texture
  162. */
  163. export type NodeMaterialTextureBlocks = TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock | ImageSourceBlock | TriPlanarBlock | BiPlanarBlock | PrePassTextureBlock;
  164. /**
  165. * Class used to create a node based material built by assembling shader blocks
  166. */
  167. export declare class NodeMaterial extends PushMaterial {
  168. private static _BuildIdGenerator;
  169. private _options;
  170. private _vertexCompilationState;
  171. private _fragmentCompilationState;
  172. private _sharedData;
  173. private _buildId;
  174. private _buildWasSuccessful;
  175. private _cachedWorldViewMatrix;
  176. private _cachedWorldViewProjectionMatrix;
  177. private _optimizers;
  178. private _animationFrame;
  179. /** Define the Url to load node editor script */
  180. static EditorURL: string;
  181. /** Define the Url to load snippets */
  182. static SnippetUrl: string;
  183. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  184. static IgnoreTexturesAtLoadTime: boolean;
  185. /**
  186. * Checks if a block is a texture block
  187. * @param block The block to check
  188. * @returns True if the block is a texture block
  189. */
  190. static _BlockIsTextureBlock(block: NodeMaterialBlock): block is NodeMaterialTextureBlocks;
  191. private BJSNODEMATERIALEDITOR;
  192. /** Get the inspector from bundle or global
  193. * @returns the global NME
  194. */
  195. private _getGlobalNodeMaterialEditor;
  196. /**
  197. * Snippet ID if the material was created from the snippet server
  198. */
  199. snippetId: string;
  200. /**
  201. * Gets or sets data used by visual editor
  202. * @see https://nme.babylonjs.com
  203. */
  204. editorData: any;
  205. /**
  206. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  207. */
  208. ignoreAlpha: boolean;
  209. /**
  210. * Defines the maximum number of lights that can be used in the material
  211. */
  212. maxSimultaneousLights: number;
  213. /**
  214. * Observable raised when the material is built
  215. */
  216. onBuildObservable: Observable<NodeMaterial>;
  217. /**
  218. * Gets or sets the root nodes of the material vertex shader
  219. */
  220. _vertexOutputNodes: NodeMaterialBlock[];
  221. /**
  222. * Gets or sets the root nodes of the material fragment (pixel) shader
  223. */
  224. _fragmentOutputNodes: NodeMaterialBlock[];
  225. /** Gets or sets options to control the node material overall behavior */
  226. get options(): INodeMaterialOptions;
  227. set options(options: INodeMaterialOptions);
  228. /**
  229. * Default configuration related to image processing available in the standard Material.
  230. */
  231. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  232. /**
  233. * Gets the image processing configuration used either in this material.
  234. */
  235. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  236. /**
  237. * Sets the Default image processing configuration used either in the this material.
  238. *
  239. * If sets to null, the scene one is in use.
  240. */
  241. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  242. /**
  243. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  244. */
  245. attachedBlocks: NodeMaterialBlock[];
  246. /**
  247. * Specifies the mode of the node material
  248. * @internal
  249. */
  250. _mode: NodeMaterialModes;
  251. /**
  252. * Gets or sets the mode property
  253. */
  254. get mode(): NodeMaterialModes;
  255. set mode(value: NodeMaterialModes);
  256. /** Gets or sets the unique identifier used to identified the effect associated with the material */
  257. get buildId(): number;
  258. set buildId(value: number);
  259. /**
  260. * A free comment about the material
  261. */
  262. comment: string;
  263. /**
  264. * Create a new node based material
  265. * @param name defines the material name
  266. * @param scene defines the hosting scene
  267. * @param options defines creation option
  268. */
  269. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  270. /**
  271. * Gets the current class name of the material e.g. "NodeMaterial"
  272. * @returns the class name
  273. */
  274. getClassName(): string;
  275. /**
  276. * Keep track of the image processing observer to allow dispose and replace.
  277. */
  278. private _imageProcessingObserver;
  279. /**
  280. * Attaches a new image processing configuration to the Standard Material.
  281. * @param configuration
  282. */
  283. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  284. /**
  285. * Get a block by its name
  286. * @param name defines the name of the block to retrieve
  287. * @returns the required block or null if not found
  288. */
  289. getBlockByName(name: string): NodeMaterialBlock | null;
  290. /**
  291. * Get a block using a predicate
  292. * @param predicate defines the predicate used to find the good candidate
  293. * @returns the required block or null if not found
  294. */
  295. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): NodeMaterialBlock | null;
  296. /**
  297. * Get an input block using a predicate
  298. * @param predicate defines the predicate used to find the good candidate
  299. * @returns the required input block or null if not found
  300. */
  301. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  302. /**
  303. * Gets the list of input blocks attached to this material
  304. * @returns an array of InputBlocks
  305. */
  306. getInputBlocks(): InputBlock[];
  307. /**
  308. * Adds a new optimizer to the list of optimizers
  309. * @param optimizer defines the optimizers to add
  310. * @returns the current material
  311. */
  312. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  313. /**
  314. * Remove an optimizer from the list of optimizers
  315. * @param optimizer defines the optimizers to remove
  316. * @returns the current material
  317. */
  318. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  319. /**
  320. * Add a new block to the list of output nodes
  321. * @param node defines the node to add
  322. * @returns the current material
  323. */
  324. addOutputNode(node: NodeMaterialBlock): this;
  325. /**
  326. * Remove a block from the list of root nodes
  327. * @param node defines the node to remove
  328. * @returns the current material
  329. */
  330. removeOutputNode(node: NodeMaterialBlock): this;
  331. private _addVertexOutputNode;
  332. private _removeVertexOutputNode;
  333. private _addFragmentOutputNode;
  334. private _removeFragmentOutputNode;
  335. /**
  336. * Gets or sets a boolean indicating that alpha blending must be enabled no matter what alpha value or alpha channel of the FragmentBlock are
  337. */
  338. forceAlphaBlending: boolean;
  339. /**
  340. * Specifies if the material will require alpha blending
  341. * @returns a boolean specifying if alpha blending is needed
  342. */
  343. needAlphaBlending(): boolean;
  344. /**
  345. * Specifies if this material should be rendered in alpha test mode
  346. * @returns a boolean specifying if an alpha test is needed.
  347. */
  348. needAlphaTesting(): boolean;
  349. private _processInitializeOnLink;
  350. private _initializeBlock;
  351. private _resetDualBlocks;
  352. /**
  353. * Remove a block from the current node material
  354. * @param block defines the block to remove
  355. */
  356. removeBlock(block: NodeMaterialBlock): void;
  357. /**
  358. * Build the material and generates the inner effect
  359. * @param verbose defines if the build should log activity
  360. * @param updateBuildId defines if the internal build Id should be updated (default is true)
  361. * @param autoConfigure defines if the autoConfigure method should be called when initializing blocks (default is false)
  362. */
  363. build(verbose?: boolean, updateBuildId?: boolean, autoConfigure?: boolean): void;
  364. /**
  365. * Runs an otpimization phase to try to improve the shader code
  366. */
  367. optimize(): void;
  368. private _prepareDefinesForAttributes;
  369. /**
  370. * Can this material render to prepass
  371. */
  372. get isPrePassCapable(): boolean;
  373. /**
  374. * Outputs written to the prepass
  375. */
  376. get prePassTextureOutputs(): number[];
  377. /**
  378. * Gets the list of prepass texture required
  379. */
  380. get prePassTextureInputs(): number[];
  381. /**
  382. * Sets the required values to the prepass renderer.
  383. * @param prePassRenderer defines the prepass renderer to set
  384. * @returns true if the pre pass is needed
  385. */
  386. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  387. /**
  388. * Create a post process from the material
  389. * @param camera The camera to apply the render pass to.
  390. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  391. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  392. * @param engine The engine which the post process will be applied. (default: current engine)
  393. * @param reusable If the post process can be reused on the same frame. (default: false)
  394. * @param textureType Type of textures used when performing the post process. (default: 0)
  395. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  396. * @returns the post process created
  397. */
  398. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  399. /**
  400. * Create the post process effect from the material
  401. * @param postProcess The post process to create the effect for
  402. */
  403. createEffectForPostProcess(postProcess: PostProcess): void;
  404. private _createEffectForPostProcess;
  405. /**
  406. * Create a new procedural texture based on this node material
  407. * @param size defines the size of the texture
  408. * @param scene defines the hosting scene
  409. * @returns the new procedural texture attached to this node material
  410. */
  411. createProceduralTexture(size: number | {
  412. width: number;
  413. height: number;
  414. layers?: number;
  415. }, scene: Scene): Nullable<ProceduralTexture>;
  416. private _createEffectForParticles;
  417. private _checkInternals;
  418. /**
  419. * Create the effect to be used as the custom effect for a particle system
  420. * @param particleSystem Particle system to create the effect for
  421. * @param onCompiled defines a function to call when the effect creation is successful
  422. * @param onError defines a function to call when the effect creation has failed
  423. */
  424. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  425. /**
  426. * Use this material as the shadow depth wrapper of a target material
  427. * @param targetMaterial defines the target material
  428. */
  429. createAsShadowDepthWrapper(targetMaterial: Material): void;
  430. private _processDefines;
  431. /**
  432. * Get if the submesh is ready to be used and all its information available.
  433. * Child classes can use it to update shaders
  434. * @param mesh defines the mesh to check
  435. * @param subMesh defines which submesh to check
  436. * @param useInstances specifies that instances should be used
  437. * @returns a boolean indicating that the submesh is ready or not
  438. */
  439. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  440. /**
  441. * Get a string representing the shaders built by the current node graph
  442. */
  443. get compiledShaders(): string;
  444. /**
  445. * Binds the world matrix to the material
  446. * @param world defines the world transformation matrix
  447. */
  448. bindOnlyWorldMatrix(world: Matrix): void;
  449. /**
  450. * Binds the submesh to this material by preparing the effect and shader to draw
  451. * @param world defines the world transformation matrix
  452. * @param mesh defines the mesh containing the submesh
  453. * @param subMesh defines the submesh to bind the material to
  454. */
  455. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  456. /**
  457. * Gets the active textures from the material
  458. * @returns an array of textures
  459. */
  460. getActiveTextures(): BaseTexture[];
  461. /**
  462. * Gets the list of texture blocks
  463. * Note that this method will only return blocks that are reachable from the final block(s) and only after the material has been built!
  464. * @returns an array of texture blocks
  465. */
  466. getTextureBlocks(): NodeMaterialTextureBlocks[];
  467. /**
  468. * Gets the list of all texture blocks
  469. * Note that this method will scan all attachedBlocks and return blocks that are texture blocks
  470. * @returns
  471. */
  472. getAllTextureBlocks(): NodeMaterialTextureBlocks[];
  473. /**
  474. * Specifies if the material uses a texture
  475. * @param texture defines the texture to check against the material
  476. * @returns a boolean specifying if the material uses the texture
  477. */
  478. hasTexture(texture: BaseTexture): boolean;
  479. /**
  480. * Disposes the material
  481. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  482. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  483. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  484. */
  485. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  486. /** Creates the node editor window.
  487. * @param additionalConfig Define the configuration of the editor
  488. */
  489. private _createNodeEditor;
  490. /**
  491. * Launch the node material editor
  492. * @param config Define the configuration of the editor
  493. * @returns a promise fulfilled when the node editor is visible
  494. */
  495. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  496. /**
  497. * Clear the current material
  498. */
  499. clear(): void;
  500. /**
  501. * Clear the current material and set it to a default state
  502. */
  503. setToDefault(): void;
  504. /**
  505. * Clear the current material and set it to a default state for post process
  506. */
  507. setToDefaultPostProcess(): void;
  508. /**
  509. * Clear the current material and set it to a default state for procedural texture
  510. */
  511. setToDefaultProceduralTexture(): void;
  512. /**
  513. * Clear the current material and set it to a default state for particle
  514. */
  515. setToDefaultParticle(): void;
  516. /**
  517. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  518. * @deprecated Please use NodeMaterial.ParseFromFileAsync instead
  519. * @param url defines the url to load from
  520. * @param rootUrl defines the root URL for nested url in the node material
  521. * @returns a promise that will fulfil when the material is fully loaded
  522. */
  523. loadAsync(url: string, rootUrl?: string): Promise<NodeMaterial>;
  524. private _gatherBlocks;
  525. /**
  526. * Generate a string containing the code declaration required to create an equivalent of this material
  527. * @returns a string
  528. */
  529. generateCode(): string;
  530. /**
  531. * Serializes this material in a JSON representation
  532. * @param selectedBlocks defines an optional list of blocks to serialize
  533. * @returns the serialized material object
  534. */
  535. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  536. private _restoreConnections;
  537. /**
  538. * Clear the current graph and load a new one from a serialization object
  539. * @param source defines the JSON representation of the material
  540. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  541. * @param merge defines whether or not the source must be merged or replace the current content
  542. */
  543. parseSerializedObject(source: any, rootUrl?: string, merge?: boolean): void;
  544. /**
  545. * Clear the current graph and load a new one from a serialization object
  546. * @param source defines the JSON representation of the material
  547. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  548. * @param merge defines whether or not the source must be merged or replace the current content
  549. * @deprecated Please use the parseSerializedObject method instead
  550. */
  551. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  552. /**
  553. * Makes a duplicate of the current material.
  554. * @param name defines the name to use for the new material
  555. * @param shareEffect defines if the clone material should share the same effect (default is false)
  556. * @returns the cloned material
  557. */
  558. clone(name: string, shareEffect?: boolean): NodeMaterial;
  559. /**
  560. * Awaits for all the material textures to be ready before resolving the returned promise.
  561. * @returns A promise that resolves when the textures are ready.
  562. */
  563. whenTexturesReadyAsync(): Promise<void[]>;
  564. /**
  565. * Creates a node material from parsed material data
  566. * @param source defines the JSON representation of the material
  567. * @param scene defines the hosting scene
  568. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  569. * @returns a new node material
  570. */
  571. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  572. /**
  573. * Creates a node material from a snippet saved in a remote file
  574. * @param name defines the name of the material to create
  575. * @param url defines the url to load from
  576. * @param scene defines the hosting scene
  577. * @param rootUrl defines the root URL for nested url in the node material
  578. * @param skipBuild defines whether to build the node material
  579. * @param targetMaterial defines a material to use instead of creating a new one
  580. * @returns a promise that will resolve to the new node material
  581. */
  582. static ParseFromFileAsync(name: string, url: string, scene: Scene, rootUrl?: string, skipBuild?: boolean, targetMaterial?: NodeMaterial): Promise<NodeMaterial>;
  583. /**
  584. * Creates a node material from a snippet saved by the node material editor
  585. * @param snippetId defines the snippet to load
  586. * @param scene defines the hosting scene
  587. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  588. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  589. * @param skipBuild defines whether to build the node material
  590. * @param waitForTextureReadyness defines whether to wait for texture readiness resolving the promise (default: false)
  591. * @returns a promise that will resolve to the new node material
  592. */
  593. static ParseFromSnippetAsync(snippetId: string, scene?: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial, skipBuild?: boolean, waitForTextureReadyness?: boolean): Promise<NodeMaterial>;
  594. /**
  595. * Creates a new node material set to default basic configuration
  596. * @param name defines the name of the material
  597. * @param scene defines the hosting scene
  598. * @returns a new NodeMaterial
  599. */
  600. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  601. }