nodeMaterialBlockConnectionPoint.d.ts 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. import { NodeMaterialBlockConnectionPointTypes } from "./Enums/nodeMaterialBlockConnectionPointTypes";
  2. import { NodeMaterialBlockTargets } from "./Enums/nodeMaterialBlockTargets";
  3. import type { Nullable } from "../../types";
  4. import type { InputBlock } from "./Blocks/Input/inputBlock";
  5. import { Observable } from "../../Misc/observable";
  6. import type { NodeMaterialBlock } from "./nodeMaterialBlock";
  7. /**
  8. * Enum used to define the compatibility state between two connection points
  9. */
  10. export declare enum NodeMaterialConnectionPointCompatibilityStates {
  11. /** Points are compatibles */
  12. Compatible = 0,
  13. /** Points are incompatible because of their types */
  14. TypeIncompatible = 1,
  15. /** Points are incompatible because of their targets (vertex vs fragment) */
  16. TargetIncompatible = 2,
  17. /** Points are incompatible because they are in the same hierarchy **/
  18. HierarchyIssue = 3
  19. }
  20. /**
  21. * Defines the direction of a connection point
  22. */
  23. export declare enum NodeMaterialConnectionPointDirection {
  24. /** Input */
  25. Input = 0,
  26. /** Output */
  27. Output = 1
  28. }
  29. /**
  30. * Defines a connection point for a block
  31. */
  32. export declare class NodeMaterialConnectionPoint {
  33. /**
  34. * Checks if two types are equivalent
  35. * @param type1 type 1 to check
  36. * @param type2 type 2 to check
  37. * @returns true if both types are equivalent, else false
  38. */
  39. static AreEquivalentTypes(type1: number, type2: number): boolean;
  40. /** @internal */
  41. _ownerBlock: NodeMaterialBlock;
  42. /** @internal */
  43. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  44. private _endpoints;
  45. private _associatedVariableName;
  46. private _direction;
  47. /** @internal */
  48. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  49. /** @internal */
  50. _defaultConnectionPointType: Nullable<NodeMaterialBlockConnectionPointTypes>;
  51. /** @internal */
  52. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53. /** @internal */
  54. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  55. private _type;
  56. /** @internal */
  57. _enforceAssociatedVariableName: boolean;
  58. /** Gets the direction of the point */
  59. get direction(): NodeMaterialConnectionPointDirection;
  60. /** Indicates that this connection point needs dual validation before being connected to another point */
  61. needDualDirectionValidation: boolean;
  62. /**
  63. * Gets or sets the additional types supported by this connection point
  64. */
  65. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  66. /**
  67. * Gets or sets the additional types excluded by this connection point
  68. */
  69. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  70. /**
  71. * Observable triggered when this point is connected
  72. */
  73. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  74. /**
  75. * Observable triggered when this point is disconnected
  76. */
  77. onDisconnectionObservable: Observable<NodeMaterialConnectionPoint>;
  78. /**
  79. * Gets or sets the associated variable name in the shader
  80. */
  81. get associatedVariableName(): string;
  82. set associatedVariableName(value: string);
  83. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  84. get innerType(): NodeMaterialBlockConnectionPointTypes;
  85. /**
  86. * Gets or sets the connection point type (default is float)
  87. */
  88. get type(): NodeMaterialBlockConnectionPointTypes;
  89. set type(value: NodeMaterialBlockConnectionPointTypes);
  90. /**
  91. * Gets or sets the connection point name
  92. */
  93. name: string;
  94. /**
  95. * Gets or sets the connection point name
  96. */
  97. displayName: string;
  98. /**
  99. * Gets or sets a boolean indicating that this connection point can be omitted
  100. */
  101. isOptional: boolean;
  102. /**
  103. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  104. */
  105. isExposedOnFrame: boolean;
  106. /**
  107. * Gets or sets number indicating the position that the port is exposed to on a frame
  108. */
  109. exposedPortPosition: number;
  110. /**
  111. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  112. */
  113. define: string;
  114. /** @internal */
  115. _prioritizeVertex: boolean;
  116. private _target;
  117. /** Gets or sets the target of that connection point */
  118. get target(): NodeMaterialBlockTargets;
  119. set target(value: NodeMaterialBlockTargets);
  120. /**
  121. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  122. */
  123. get isConnected(): boolean;
  124. /**
  125. * Gets a boolean indicating that the current point is connected to an input block
  126. */
  127. get isConnectedToInputBlock(): boolean;
  128. /**
  129. * Gets a the connected input block (if any)
  130. */
  131. get connectInputBlock(): Nullable<InputBlock>;
  132. /** Get the other side of the connection (if any) */
  133. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  134. /** Get the block that owns this connection point */
  135. get ownerBlock(): NodeMaterialBlock;
  136. /** Get the block connected on the other side of this connection (if any) */
  137. get sourceBlock(): Nullable<NodeMaterialBlock>;
  138. /** Get the block connected on the endpoints of this connection (if any) */
  139. get connectedBlocks(): Array<NodeMaterialBlock>;
  140. /** Gets the list of connected endpoints */
  141. get endpoints(): NodeMaterialConnectionPoint[];
  142. /** Gets a boolean indicating if that output point is connected to at least one input */
  143. get hasEndpoints(): boolean;
  144. /** Gets a boolean indicating that this connection has a path to the vertex output*/
  145. get isDirectlyConnectedToVertexOutput(): boolean;
  146. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  147. get isConnectedInVertexShader(): boolean;
  148. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  149. get isConnectedInFragmentShader(): boolean;
  150. /**
  151. * Creates a block suitable to be used as an input for this input point.
  152. * If null is returned, a block based on the point type will be created.
  153. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  154. */
  155. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  156. /**
  157. * Creates a new connection point
  158. * @param name defines the connection point name
  159. * @param ownerBlock defines the block hosting this connection point
  160. * @param direction defines the direction of the connection point
  161. */
  162. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  163. /**
  164. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  165. * @returns the class name
  166. */
  167. getClassName(): string;
  168. /**
  169. * Gets a boolean indicating if the current point can be connected to another point
  170. * @param connectionPoint defines the other connection point
  171. * @returns a boolean
  172. */
  173. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  174. /**
  175. * Gets a number indicating if the current point can be connected to another point
  176. * @param connectionPoint defines the other connection point
  177. * @returns a number defining the compatibility state
  178. */
  179. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  180. /**
  181. * Connect this point to another connection point
  182. * @param connectionPoint defines the other connection point
  183. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  184. * @returns the current connection point
  185. */
  186. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  187. /**
  188. * Disconnect this point from one of his endpoint
  189. * @param endpoint defines the other connection point
  190. * @returns the current connection point
  191. */
  192. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  193. /**
  194. * Fill the list of excluded connection point types with all types other than those passed in the parameter
  195. * @param mask Types (ORed values of NodeMaterialBlockConnectionPointTypes) that are allowed, and thus will not be pushed to the excluded list
  196. */
  197. addExcludedConnectionPointFromAllowedTypes(mask: number): void;
  198. /**
  199. * Serializes this point in a JSON representation
  200. * @param isInput defines if the connection point is an input (default is true)
  201. * @returns the serialized point object
  202. */
  203. serialize(isInput?: boolean): any;
  204. /**
  205. * Release resources
  206. */
  207. dispose(): void;
  208. }