nodeGeometryBlockConnectionPoint.d.ts 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. import type { Nullable } from "../../types";
  2. import type { NodeGeometryBlock } from "./nodeGeometryBlock";
  3. import { Observable } from "../../Misc/observable";
  4. import { NodeGeometryBlockConnectionPointTypes } from "./Enums/nodeGeometryConnectionPointTypes";
  5. import type { NodeGeometryBuildState } from "./nodeGeometryBuildState";
  6. /**
  7. * Enum used to define the compatibility state between two connection points
  8. */
  9. export declare enum NodeGeometryConnectionPointCompatibilityStates {
  10. /** Points are compatibles */
  11. Compatible = 0,
  12. /** Points are incompatible because of their types */
  13. TypeIncompatible = 1,
  14. /** Points are incompatible because they are in the same hierarchy **/
  15. HierarchyIssue = 2
  16. }
  17. /**
  18. * Defines the direction of a connection point
  19. */
  20. export declare enum NodeGeometryConnectionPointDirection {
  21. /** Input */
  22. Input = 0,
  23. /** Output */
  24. Output = 1
  25. }
  26. /**
  27. * Defines a connection point for a block
  28. */
  29. export declare class NodeGeometryConnectionPoint {
  30. /** @internal */
  31. _ownerBlock: NodeGeometryBlock;
  32. /** @internal */
  33. _connectedPoint: Nullable<NodeGeometryConnectionPoint>;
  34. /** @internal */
  35. _storedValue: any;
  36. /** @internal */
  37. _storedFunction: Nullable<(state: NodeGeometryBuildState) => any>;
  38. /** @internal */
  39. _acceptedConnectionPointType: Nullable<NodeGeometryConnectionPoint>;
  40. private _endpoints;
  41. private _direction;
  42. private _type;
  43. /** @internal */
  44. _linkedConnectionSource: Nullable<NodeGeometryConnectionPoint>;
  45. /** @internal */
  46. _typeConnectionSource: Nullable<NodeGeometryConnectionPoint>;
  47. /** @internal */
  48. _defaultConnectionPointType: Nullable<NodeGeometryBlockConnectionPointTypes>;
  49. /** Gets the direction of the point */
  50. get direction(): NodeGeometryConnectionPointDirection;
  51. /**
  52. * Gets or sets the additional types supported by this connection point
  53. */
  54. acceptedConnectionPointTypes: NodeGeometryBlockConnectionPointTypes[];
  55. /**
  56. * Gets or sets the additional types excluded by this connection point
  57. */
  58. excludedConnectionPointTypes: NodeGeometryBlockConnectionPointTypes[];
  59. /**
  60. * Observable triggered when this point is connected
  61. */
  62. onConnectionObservable: Observable<NodeGeometryConnectionPoint>;
  63. /**
  64. * Observable triggered when this point is disconnected
  65. */
  66. onDisconnectionObservable: Observable<NodeGeometryConnectionPoint>;
  67. /**
  68. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  69. */
  70. isExposedOnFrame: boolean;
  71. /**
  72. * Gets or sets number indicating the position that the port is exposed to on a frame
  73. */
  74. exposedPortPosition: number;
  75. /**
  76. * Gets the default value used for this point at creation time
  77. */
  78. defaultValue: Nullable<any>;
  79. /**
  80. * Gets or sets the default value used for this point if nothing is connected
  81. */
  82. value: Nullable<any>;
  83. /**
  84. * Gets or sets the min value accepted for this point if nothing is connected
  85. */
  86. valueMin: Nullable<any>;
  87. /**
  88. * Gets or sets the max value accepted for this point if nothing is connected
  89. */
  90. valueMax: Nullable<any>;
  91. /**
  92. * Gets or sets the connection point type (default is float)
  93. */
  94. get type(): NodeGeometryBlockConnectionPointTypes;
  95. set type(value: NodeGeometryBlockConnectionPointTypes);
  96. /**
  97. * Gets or sets the connection point name
  98. */
  99. name: string;
  100. /**
  101. * Gets or sets the connection point display name
  102. */
  103. displayName: string;
  104. /**
  105. * Gets or sets a boolean indicating that this connection point can be omitted
  106. */
  107. isOptional: boolean;
  108. /**
  109. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  110. */
  111. get isConnected(): boolean;
  112. /** Get the other side of the connection (if any) */
  113. get connectedPoint(): Nullable<NodeGeometryConnectionPoint>;
  114. /** Get the block that owns this connection point */
  115. get ownerBlock(): NodeGeometryBlock;
  116. /** Get the block connected on the other side of this connection (if any) */
  117. get sourceBlock(): Nullable<NodeGeometryBlock>;
  118. /** Get the block connected on the endpoints of this connection (if any) */
  119. get connectedBlocks(): Array<NodeGeometryBlock>;
  120. /** Gets the list of connected endpoints */
  121. get endpoints(): NodeGeometryConnectionPoint[];
  122. /** Gets a boolean indicating if that output point is connected to at least one input */
  123. get hasEndpoints(): boolean;
  124. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  125. get innerType(): NodeGeometryBlockConnectionPointTypes;
  126. /** @internal */
  127. _callCount: number;
  128. /** @internal */
  129. _executionCount: number;
  130. /** @internal */
  131. _resetCounters(): void;
  132. /**
  133. * Gets the number of times this point was called
  134. */
  135. get callCount(): number;
  136. /**
  137. * Gets the number of times this point was executed
  138. */
  139. get executionCount(): number;
  140. /**
  141. * Gets the value represented by this connection point
  142. * @param state current evaluation state
  143. * @returns the connected value or the value if nothing is connected
  144. */
  145. getConnectedValue(state: NodeGeometryBuildState): any;
  146. /**
  147. * Creates a new connection point
  148. * @param name defines the connection point name
  149. * @param ownerBlock defines the block hosting this connection point
  150. * @param direction defines the direction of the connection point
  151. */
  152. constructor(name: string, ownerBlock: NodeGeometryBlock, direction: NodeGeometryConnectionPointDirection);
  153. /**
  154. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  155. * @returns the class name
  156. */
  157. getClassName(): string;
  158. /**
  159. * Gets a boolean indicating if the current point can be connected to another point
  160. * @param connectionPoint defines the other connection point
  161. * @returns a boolean
  162. */
  163. canConnectTo(connectionPoint: NodeGeometryConnectionPoint): boolean;
  164. /**
  165. * Gets a number indicating if the current point can be connected to another point
  166. * @param connectionPoint defines the other connection point
  167. * @returns a number defining the compatibility state
  168. */
  169. checkCompatibilityState(connectionPoint: NodeGeometryConnectionPoint): NodeGeometryConnectionPointCompatibilityStates;
  170. /**
  171. * Connect this point to another connection point
  172. * @param connectionPoint defines the other connection point
  173. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  174. * @returns the current connection point
  175. */
  176. connectTo(connectionPoint: NodeGeometryConnectionPoint, ignoreConstraints?: boolean): NodeGeometryConnectionPoint;
  177. /**
  178. * Disconnect this point from one of his endpoint
  179. * @param endpoint defines the other connection point
  180. * @returns the current connection point
  181. */
  182. disconnectFrom(endpoint: NodeGeometryConnectionPoint): NodeGeometryConnectionPoint;
  183. /**
  184. * Fill the list of excluded connection point types with all types other than those passed in the parameter
  185. * @param mask Types (ORed values of NodeMaterialBlockConnectionPointTypes) that are allowed, and thus will not be pushed to the excluded list
  186. */
  187. addExcludedConnectionPointFromAllowedTypes(mask: number): void;
  188. /**
  189. * Serializes this point in a JSON representation
  190. * @param isInput defines if the connection point is an input (default is true)
  191. * @returns the serialized point object
  192. */
  193. serialize(isInput?: boolean): any;
  194. /**
  195. * Release resources
  196. */
  197. dispose(): void;
  198. }