nodeListComponent.tsx 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import * as React from "react";
  2. import { GlobalState } from '../../globalState';
  3. import { LineContainerComponent } from '../../sharedComponents/lineContainerComponent';
  4. import { DraggableLineComponent } from '../../sharedComponents/draggableLineComponent';
  5. require("./nodeList.scss");
  6. interface INodeListComponentProps {
  7. globalState: GlobalState;
  8. }
  9. export class NodeListComponent extends React.Component<INodeListComponentProps, {filter: string}> {
  10. constructor(props: INodeListComponentProps) {
  11. super(props);
  12. this.state = { filter: "" };
  13. }
  14. filterContent(filter: string) {
  15. this.setState({ filter: filter });
  16. }
  17. render() {
  18. // Block types used to create the menu from
  19. const allBlocks = {
  20. Animation: ["BonesBlock", "MorphTargetsBlock"],
  21. Basic_Math: ["AddBlock", "DivideBlock", "MultiplyBlock", "ScaleBlock", "SubtractBlock", "OppositeBlock"],
  22. Conversion_Blocks: ["ColorMergerBlock", "ColorSplitterBlock", "VectorMergerBlock", "VectorSplitterBlock"],
  23. Inputs: ["Float", "Vector2", "Vector3", "Vector4", "Color3", "Color4", "TextureBlock", "TimeBlock"],
  24. Interpolation: ["LerpBlock"],
  25. Matrices: ["Matrix", "WorldMatrixBlock", "WorldViewMatrixBlock", "WorldViewProjectionMatrixBlock", "ViewMatrixBlock", "ViewProjectionMatrixBlock", "ProjectionMatrixBlock"],
  26. Mesh_Attributes: ["InstancesBlock", "PositionBlock", "UVBlock", "ColorBlock", "NormalBlock", "TangentBlock", "MatrixIndicesBlock", "MatrixWeightsBlock"],
  27. Output_Blocks: ["VertexOutputBlock", "FragmentOutputBlock", "AlphaTestBlock"],
  28. Range: ["ClampBlock", "RemapBlock", "NormalizeBlock"],
  29. Round: ["StepBlock", "RoundBlock", "CeilingBlock", "FloorBlock"],
  30. Scene_Attributes: ["FogBlock", "CameraPositionBlock", "FogColorBlock", "ImageProcessingBlock", "LightBlock", "LightInformationBlock", "ReflectionTextureBlock", "ViewDirectionBlock"],
  31. Trigonometry: ["CosBlock", "SinBlock", "AbsBlock", "ExpBlock", "Exp2Block"],
  32. Vector_Math: ["CrossBlock", "DotBlock", "TransformBlock", "FresnelBlock"],
  33. }
  34. // Create node menu
  35. var blockMenu = []
  36. for (var key in allBlocks) {
  37. var blockList = (allBlocks as any)[key].filter((b: string) => !this.state.filter || b.toLowerCase().indexOf(this.state.filter.toLowerCase()) !== -1)
  38. .sort((a: string, b: string) => a.localeCompare(b))
  39. .map((block: any, i: number) => {
  40. return <DraggableLineComponent key={block} data={block} />
  41. });
  42. if (blockList.length) {
  43. blockMenu.push(
  44. <LineContainerComponent key={key + " blocks"} title={key.replace("_", " ")} closed={false}>
  45. {blockList}
  46. </LineContainerComponent>
  47. );
  48. }
  49. }
  50. return (
  51. <div id="nodeList" style={{ borderRightStyle: "solid", borderColor: "grey", borderWidth: "1px" }} >
  52. <div className="panes">
  53. <div className="pane">
  54. <div className="filter">
  55. <input type="text" placeholder="Filter" onChange={(evt) => this.filterContent(evt.target.value)} />
  56. </div>
  57. <div className="list-container">
  58. {blockMenu}
  59. </div>
  60. </div>
  61. </div>
  62. </div>
  63. );
  64. }
  65. }