textureNodeModel.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import * as React from 'react';
  2. import { Nullable } from 'babylonjs/types';
  3. import { Texture } from 'babylonjs/Materials/Textures/texture';
  4. import { DefaultNodeModel } from '../defaultNodeModel';
  5. import { GlobalState } from '../../../globalState';
  6. import { TexturePropertyTabComponent } from '../../../components/propertyTab/properties/texturePropertyTabComponent';
  7. import { NodeCreationOptions, GraphEditor } from '../../../graphEditor';
  8. import { DiagramModel } from 'storm-react-diagrams/dist/@types/src/models/DiagramModel';
  9. import { TextureBlock } from 'babylonjs/Materials/Node/Blocks/Fragment/textureBlock';
  10. /**
  11. * Texture node model which stores information about a node editor block
  12. */
  13. export class TextureNodeModel extends DefaultNodeModel {
  14. /**
  15. * Texture for the node if it exists
  16. */
  17. public texture: Nullable<Texture> = null;
  18. /**
  19. * Constructs the node model
  20. */
  21. constructor() {
  22. super("texture");
  23. }
  24. renderProperties(globalState: GlobalState) {
  25. return (
  26. <TexturePropertyTabComponent globalState={globalState} node={this} />
  27. );
  28. }
  29. prepare(options: NodeCreationOptions, nodes: Array<DefaultNodeModel>, model: DiagramModel, graphEditor: GraphEditor, filterInputs: string[]) {
  30. let textureBlock = options.nodeMaterialBlock as TextureBlock;
  31. this.texture = textureBlock.texture.value;
  32. super.prepare(options, nodes, model, graphEditor, filterInputs);
  33. }
  34. }