babylon.nodeEditor.d.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. /// <reference types="react" />
  2. declare module NODEEDITOR {
  3. export class GlobalState {
  4. nodeMaterial?: BABYLON.NodeMaterial;
  5. hostDocument?: BABYLON.Nullable<Document>;
  6. }
  7. }
  8. declare module NODEEDITOR {
  9. /**
  10. * Port model for the generic node
  11. */
  12. export class GenericPortModel extends PortModel {
  13. /**
  14. * If the port is input or output
  15. */
  16. position: string | "input" | "output";
  17. /**
  18. * What the port is connected to
  19. */
  20. connection: BABYLON.Nullable<BABYLON.NodeMaterialConnectionPoint>;
  21. static idCounter: number;
  22. constructor(name: string, type?: string);
  23. syncWithNodeMaterialConnectionPoint(connection: BABYLON.NodeMaterialConnectionPoint): void;
  24. getNodeModel(): GenericNodeModel;
  25. link(outPort: GenericPortModel): LinkModel<import("storm-react-diagrams").LinkModelListener>;
  26. getInputFromBlock(): void;
  27. createLinkModel(): LinkModel;
  28. getValue: Function;
  29. static SortInputOutput(a: BABYLON.Nullable<GenericPortModel>, b: BABYLON.Nullable<GenericPortModel>): {
  30. input: GenericPortModel;
  31. output: GenericPortModel;
  32. } | null;
  33. }
  34. }
  35. declare module NODEEDITOR {
  36. /**
  37. * Generic node model which stores information about a node editor block
  38. */
  39. export class GenericNodeModel extends NodeModel {
  40. /**
  41. * The babylon block this node represents
  42. */
  43. block: BABYLON.Nullable<BABYLON.NodeMaterialBlock>;
  44. /**
  45. * Labels for the block
  46. */
  47. headerLabels: Array<{
  48. text: string;
  49. }>;
  50. /**
  51. * BABYLON.Texture for the node if it exists
  52. */
  53. texture: BABYLON.Nullable<BABYLON.Texture>;
  54. /**
  55. * BABYLON.Vector2 for the node if it exists
  56. */
  57. vector2: BABYLON.Nullable<BABYLON.Vector2>;
  58. /**
  59. * BABYLON.Vector3 for the node if it exists
  60. */
  61. vector3: BABYLON.Nullable<BABYLON.Vector3>;
  62. /**
  63. * BABYLON.Vector4 for the node if it exists
  64. */
  65. vector4: BABYLON.Nullable<BABYLON.Vector4>;
  66. /**
  67. * BABYLON.Matrix for the node if it exists
  68. */
  69. matrix: BABYLON.Nullable<BABYLON.Matrix>;
  70. ports: {
  71. [s: string]: GenericPortModel;
  72. };
  73. /**
  74. * Constructs the node model
  75. */
  76. constructor();
  77. }
  78. }
  79. declare module NODEEDITOR {
  80. interface ITextureLineComponentProps {
  81. texture: BABYLON.BaseTexture;
  82. width: number;
  83. height: number;
  84. globalState?: any;
  85. hideChannelSelect?: boolean;
  86. }
  87. export class TextureLineComponent extends React.Component<ITextureLineComponentProps, {
  88. displayRed: boolean;
  89. displayGreen: boolean;
  90. displayBlue: boolean;
  91. displayAlpha: boolean;
  92. face: number;
  93. }> {
  94. constructor(props: ITextureLineComponentProps);
  95. shouldComponentUpdate(nextProps: ITextureLineComponentProps, nextState: {
  96. displayRed: boolean;
  97. displayGreen: boolean;
  98. displayBlue: boolean;
  99. displayAlpha: boolean;
  100. face: number;
  101. }): boolean;
  102. componentDidMount(): void;
  103. componentDidUpdate(): void;
  104. updatePreview(): void;
  105. render(): JSX.Element;
  106. }
  107. }
  108. declare module NODEEDITOR {
  109. interface IFileButtonLineComponentProps {
  110. label: string;
  111. onClick: (file: File) => void;
  112. accept: string;
  113. }
  114. export class FileButtonLineComponent extends React.Component<IFileButtonLineComponentProps> {
  115. constructor(props: IFileButtonLineComponentProps);
  116. onChange(evt: any): void;
  117. render(): JSX.Element;
  118. }
  119. }
  120. declare module NODEEDITOR {
  121. interface INumericInputComponentProps {
  122. label: string;
  123. value: number;
  124. step?: number;
  125. onChange: (value: number) => void;
  126. }
  127. export class NumericInputComponent extends React.Component<INumericInputComponentProps, {
  128. value: string;
  129. }> {
  130. static defaultProps: {
  131. step: number;
  132. };
  133. private _localChange;
  134. constructor(props: INumericInputComponentProps);
  135. shouldComponentUpdate(nextProps: INumericInputComponentProps, nextState: {
  136. value: string;
  137. }): boolean;
  138. updateValue(evt: any): void;
  139. render(): JSX.Element;
  140. }
  141. }
  142. declare module NODEEDITOR {
  143. export class PropertyChangedEvent {
  144. object: any;
  145. property: string;
  146. value: any;
  147. initialValue: any;
  148. }
  149. }
  150. declare module NODEEDITOR {
  151. interface IVector2LineComponentProps {
  152. label: string;
  153. target: any;
  154. propertyName: string;
  155. step?: number;
  156. onChange?: (newvalue: BABYLON.Vector2) => void;
  157. onPropertyChangedObservable?: BABYLON.Observable<PropertyChangedEvent>;
  158. }
  159. export class Vector2LineComponent extends React.Component<IVector2LineComponentProps, {
  160. isExpanded: boolean;
  161. value: BABYLON.Vector2;
  162. }> {
  163. static defaultProps: {
  164. step: number;
  165. };
  166. private _localChange;
  167. constructor(props: IVector2LineComponentProps);
  168. shouldComponentUpdate(nextProps: IVector2LineComponentProps, nextState: {
  169. isExpanded: boolean;
  170. value: BABYLON.Vector2;
  171. }): boolean;
  172. switchExpandState(): void;
  173. raiseOnPropertyChanged(previousValue: BABYLON.Vector2): void;
  174. updateStateX(value: number): void;
  175. updateStateY(value: number): void;
  176. render(): JSX.Element;
  177. }
  178. }
  179. declare module NODEEDITOR {
  180. interface IVector3LineComponentProps {
  181. label: string;
  182. target: any;
  183. propertyName: string;
  184. step?: number;
  185. onChange?: (newvalue: BABYLON.Vector3) => void;
  186. onPropertyChangedObservable?: BABYLON.Observable<PropertyChangedEvent>;
  187. }
  188. export class Vector3LineComponent extends React.Component<IVector3LineComponentProps, {
  189. isExpanded: boolean;
  190. value: BABYLON.Vector3;
  191. }> {
  192. static defaultProps: {
  193. step: number;
  194. };
  195. private _localChange;
  196. constructor(props: IVector3LineComponentProps);
  197. shouldComponentUpdate(nextProps: IVector3LineComponentProps, nextState: {
  198. isExpanded: boolean;
  199. value: BABYLON.Vector3;
  200. }): boolean;
  201. switchExpandState(): void;
  202. raiseOnPropertyChanged(previousValue: BABYLON.Vector3): void;
  203. updateVector3(): void;
  204. updateStateX(value: number): void;
  205. updateStateY(value: number): void;
  206. updateStateZ(value: number): void;
  207. render(): JSX.Element;
  208. }
  209. }
  210. declare module NODEEDITOR {
  211. /**
  212. * GenericNodeWidgetProps
  213. */
  214. export interface GenericNodeWidgetProps {
  215. node: BABYLON.Nullable<GenericNodeModel>;
  216. }
  217. /**
  218. * GenericNodeWidgetState
  219. */
  220. export interface GenericNodeWidgetState {
  221. }
  222. /**
  223. * Used to display a node block for the node editor
  224. */
  225. export class GenericNodeWidget extends React.Component<GenericNodeWidgetProps, GenericNodeWidgetState> {
  226. /**
  227. * Creates a GenericNodeWidget
  228. * @param props
  229. */
  230. constructor(props: GenericNodeWidgetProps);
  231. /**
  232. * Replaces the texture of the node
  233. * @param file the file of the texture to use
  234. */
  235. replaceTexture(file: File): void;
  236. render(): JSX.Element;
  237. }
  238. }
  239. declare module NODEEDITOR {
  240. /**
  241. * Node factory which creates editor nodes
  242. */
  243. export class GenericNodeFactory extends SRD.AbstractNodeFactory {
  244. /**
  245. * Constructs a GenericNodeFactory
  246. */
  247. constructor();
  248. /**
  249. * Generates a node widget
  250. * @param diagramEngine diagram engine
  251. * @param node node to generate
  252. * @returns node widget jsx
  253. */
  254. generateReactWidget(diagramEngine: SRD.DiagramEngine, node: GenericNodeModel): JSX.Element;
  255. /**
  256. * Gets a new instance of a node model
  257. * @returns generic node model
  258. */
  259. getNewInstance(): GenericNodeModel;
  260. }
  261. }
  262. declare module NODEEDITOR {
  263. interface ILineContainerComponentProps {
  264. globalState?: any;
  265. title: string;
  266. children: any[] | any;
  267. closed?: boolean;
  268. }
  269. export class LineContainerComponent extends React.Component<ILineContainerComponentProps, {
  270. isExpanded: boolean;
  271. isHighlighted: boolean;
  272. }> {
  273. private static _InMemoryStorage;
  274. constructor(props: ILineContainerComponentProps);
  275. switchExpandedState(): void;
  276. componentDidMount(): void;
  277. renderHeader(): JSX.Element;
  278. render(): JSX.Element;
  279. }
  280. }
  281. declare module NODEEDITOR {
  282. export interface IButtonLineComponentProps {
  283. label: string;
  284. onClick: () => void;
  285. }
  286. export class ButtonLineComponent extends React.Component<IButtonLineComponentProps> {
  287. constructor(props: IButtonLineComponentProps);
  288. render(): JSX.Element;
  289. }
  290. }
  291. declare module NODEEDITOR {
  292. interface IGraphEditorProps {
  293. globalState: GlobalState;
  294. }
  295. export class GraphEditor extends React.Component<IGraphEditorProps> {
  296. private _engine;
  297. private _model;
  298. private _nodes;
  299. /**
  300. * Current row/column position used when adding new nodes
  301. */
  302. private _rowPos;
  303. /**
  304. * Creates a node and recursivly creates its parent nodes from it's input
  305. * @param nodeMaterialBlock
  306. */
  307. createNodeFromObject(options: {
  308. column: number;
  309. nodeMaterialBlock?: BABYLON.NodeMaterialBlock;
  310. }): GenericNodeModel;
  311. componentDidMount(): void;
  312. componentWillUnmount(): void;
  313. constructor(props: IGraphEditorProps);
  314. addNodeFromClass(ObjectClass: typeof BABYLON.NodeMaterialBlock): GenericNodeModel;
  315. addValueNode(type: string, column?: number, connection?: BABYLON.NodeMaterialConnectionPoint): GenericNodeModel;
  316. allBlocks: {
  317. Fragment: (typeof BABYLON.AlphaTestBlock | typeof BABYLON.FragmentOutputBlock | typeof BABYLON.ImageProcessingBlock | typeof BABYLON.RGBAMergerBlock | typeof BABYLON.RGBASplitterBlock | typeof BABYLON.TextureBlock)[];
  318. Vertex: (typeof BABYLON.BonesBlock | typeof BABYLON.InstancesBlock | typeof BABYLON.MorphTargetsBlock | typeof BABYLON.VertexOutputBlock)[];
  319. Dual: (typeof BABYLON.FogBlock)[];
  320. Other: (typeof BABYLON.AddBlock | typeof BABYLON.ClampBlock | typeof BABYLON.MatrixMultiplicationBlock | typeof BABYLON.MultiplyBlock | typeof BABYLON.Vector2TransformBlock | typeof BABYLON.Vector3TransformBlock | typeof BABYLON.Vector4TransformBlock)[];
  321. Value: string[];
  322. };
  323. render(): JSX.Element;
  324. }
  325. }
  326. declare module NODEEDITOR {
  327. export class Popup {
  328. static CreatePopup(title: string, windowVariableName: string, width?: number, height?: number): HTMLDivElement | null;
  329. private static _CopyStyles;
  330. }
  331. }
  332. declare module NODEEDITOR {
  333. /**
  334. * Interface used to specify creation options for the node editor
  335. */
  336. export interface INodeEditorOptions {
  337. /**
  338. * Defines the DOM element that will host the node editor
  339. */
  340. hostElement?: HTMLDivElement;
  341. nodeMaterial?: BABYLON.NodeMaterial;
  342. }
  343. /**
  344. * Class used to create a node editor
  345. */
  346. export class NodeEditor {
  347. /**
  348. * Show the node editor
  349. * @param options defines the options to use to configure the node editor
  350. */
  351. static Show(options: INodeEditorOptions): void;
  352. }
  353. }