babylon.nodeEditor.d.ts 13 KB

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