1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- import * as React from "react";
- import { GlobalState } from '../../globalState';
- import { LineContainerComponent } from '../../sharedComponents/lineContainerComponent';
- import { DraggableLineComponent } from '../../sharedComponents/draggableLineComponent';
- require("./nodeList.scss");
- interface INodeListComponentProps {
- globalState: GlobalState;
- }
- export class NodeListComponent extends React.Component<INodeListComponentProps, {filter: string}> {
- constructor(props: INodeListComponentProps) {
- super(props);
- this.state = { filter: "" };
- }
- filterContent(filter: string) {
- this.setState({ filter: filter });
- }
- render() {
- // Block types used to create the menu from
- const allBlocks = {
- Animation: ["BonesBlock", "MorphTargetsBlock"],
- Basic_Math: ["AddBlock", "DivideBlock", "MultiplyBlock", "ScaleBlock", "SubtractBlock", "OppositeBlock"],
- Conversion_Blocks: ["ColorMergerBlock", "ColorSplitterBlock", "VectorMergerBlock", "VectorSplitterBlock"],
- Inputs: ["Float", "Vector2", "Vector3", "Vector4", "Color3", "Color4", "TextureBlock", "TimeBlock"],
- Interpolation: ["LerpBlock"],
- Matrices: ["Matrix", "WorldMatrixBlock", "WorldViewMatrixBlock", "WorldViewProjectionMatrixBlock", "ViewMatrixBlock", "ViewProjectionMatrixBlock", "ProjectionMatrixBlock"],
- Mesh_Attributes: ["InstancesBlock", "PositionBlock", "UVBlock", "ColorBlock", "NormalBlock", "TangentBlock", "MatrixIndicesBlock", "MatrixWeightsBlock"],
- Output_Blocks: ["VertexOutputBlock", "FragmentOutputBlock", "AlphaTestBlock"],
- Range: ["ClampBlock", "RemapBlock", "NormalizeBlock"],
- Round: ["StepBlock", "RoundBlock", "CeilingBlock", "FloorBlock"],
- Scene_Attributes: ["FogBlock", "CameraPositionBlock", "FogColorBlock", "ImageProcessingBlock", "LightBlock", "LightInformationBlock", "ReflectionTextureBlock", "ViewDirectionBlock"],
- Trigonometry: ["CosBlock", "SinBlock", "AbsBlock", "ExpBlock", "Exp2Block"],
- Vector_Math: ["CrossBlock", "DotBlock", "TransformBlock", "FresnelBlock"],
- }
- // Create node menu
- var blockMenu = []
- for (var key in allBlocks) {
- var blockList = (allBlocks as any)[key].filter((b: string) => !this.state.filter || b.toLowerCase().indexOf(this.state.filter.toLowerCase()) !== -1)
- .sort((a: string, b: string) => a.localeCompare(b))
- .map((block: any, i: number) => {
- return <DraggableLineComponent key={block} data={block} />
- });
- if (blockList.length) {
- blockMenu.push(
- <LineContainerComponent key={key + " blocks"} title={key.replace("_", " ")} closed={false}>
- {blockList}
- </LineContainerComponent>
- );
- }
- }
- return (
- <div id="nodeList" style={{ borderRightStyle: "solid", borderColor: "grey", borderWidth: "1px" }} >
- <div className="panes">
- <div className="pane">
- <div className="filter">
- <input type="text" placeholder="Filter" onChange={(evt) => this.filterContent(evt.target.value)} />
- </div>
- <div className="list-container">
- {blockMenu}
- </div>
- </div>
- </div>
- </div>
- );
- }
- }
|