nodeListComponent.tsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. private static _Tooltips: {[key: string]: string} = {
  11. "BonesBlock": "Provides a world matrix for each vertex, based on skeletal (bone/joint) animation",
  12. "MorphTargetsBlock": "Provides the final positions, normals, tangents, and uvs based on morph targets in a mesh",
  13. "AddBlock": "Adds the left and right inputs of the same type together",
  14. "DistanceBlock": "Provides a distance vector based on the left and right input vectors",
  15. "DivideBlock": "Divides the left input by the right input of the same type",
  16. "LengthBlock": "Outputs the length of an input vector",
  17. "MaxBlock": "Outputs the largest value between the left and right inputs of the same type",
  18. "MinBlock": "Outputs the smallest value between the left and right inputs of the same type",
  19. "MultiplyBlock": "Multiplies the left and right inputs of the same type together",
  20. "NegateBlock": "Multiplies the input by -1",
  21. "OneMinusBlock": "Subtracts each channel of the input value from 1 (1 - input)",
  22. "RandomNumberBlock": "Provides a random number based on an input seed",
  23. "ReciprocalBlock": "Quotient of 1 divided by the input",
  24. "ScaleBlock": "Multiplies the input channels by a float factor",
  25. "SubtractBlock": "Subtracts the right input from the left input of the same type",
  26. "GradientBlock": "Returns the color in the gradient represented by the target value of the input",
  27. "PosterizeBlock": "Reduces the number of values in each channel to the number in the corresponding channel of steps",
  28. "ReplaceColorBlock": "Replaces a reference color in value with the color in replacement blended by distance",
  29. "ColorMergerBlock": "Combines float input channels into a color",
  30. "ColorSplitterBlock": "Separates color input channels into individual floats",
  31. "VectorMergerBlock": "Combines up to four input floats into a vector",
  32. "VectorSplitterBlock": "Separates vectors input channels into individual floats",
  33. "Color3": "A color made up of red, green, and blue channel values",
  34. "Color4": "A color made up of red, green, blue, and alpha channel values",
  35. "DeltaTimeBlock": "A float representing the time that has passed since the last frame was rendered",
  36. "Float": "A floating point number representing a value with a fractional component",
  37. "TextureBlock": "A node for reading a linked or embedded texture file",
  38. "TimeBlock": "A float value that represents the time that has passed since the scene was loaded",
  39. "Vector2": "a vector composed of X and Y channels",
  40. "Vector3": "a vector composed of X, Y, and Z channels",
  41. "Vector4": "a vector composed of X, Y, Z, and W channels",
  42. "LerpBlock": "Outputs a value that is a mix of the left and right inputs based on the target value",
  43. "NLerpBlock": "Outputs a value that is a mix of the left and right inputs based on the target's normalized value",
  44. "SmoothStepBlock": "Outputs a value based on a the input value's position on a curve between the two edge values",
  45. "StepBlock": "Outputs 1 for any input value above the edge input, outputs 0 for any input value below the edge input",
  46. "Matrix": "A 4x4 table of related values",
  47. "ProjectionMatrixBlock": "A matrix to remap points in 3D space to 2D plane relative to the screen",
  48. "ViewMatrixBlock": "A matrix to remap points in 3D space to 2D plane relative to the view of the scene camera",
  49. "ViewProjectionMatrixBlock": "A matrix to remap points in 3D space to 2D view space before remapping to 2D screen space",
  50. "WorldMatrixBlock": "A matrix to remap points in 3D local space to 3D world space",
  51. "WorldViewProjectionMatrixBlock": "A matrix to remap points in 3D local space to 3D world space, then to 2D camera space, and ending in 2D screen space",
  52. "ColorBlock": "Outputs the RGBA color of each vertex in the mesh",
  53. "InstancesBlock": "Provides the world matrix for each instance to apply this material to all instances",
  54. "MatrixIndicesBlock": "A Vector4 representing the vertex to bone skinning assignments",
  55. "MatrixWeightsBlock": "A Vector4 representing the vertex to bone skinning weights",
  56. "NormalBlock": "A Vector3 representing the normal of each vertex of the attached mesh",
  57. "PositionBlock": "A Vector3 representing the position of each vertex of the attached mesh",
  58. "TangentBlock": "A Vector3 representing the tangent of each vertex of the attached mesh",
  59. "UVBlock": "A Vector2 representing the UV coordinates of each vertex of the attached mesh",
  60. "WorldNormal": "A Vector4 representing the normal of each vertex of the attached mesh transformed into world space",
  61. "WorldTangent": "A Vector4 representing the tangent of each vertex of the attached mesh transformed into world space",
  62. "PerturbNormalBlock": "Creates high-frequency detail normal vectors based on a normal map, the world position, and world normal",
  63. "NormalBlend": "Outputs the result of blending two normal maps together using a per-channel screen",
  64. "WorldPosition": "A Vector4 representing the position of each vertex of the attached mesh transformed into world space",
  65. "DiscardBlock": "A final node that will not output a pixel below the cutoff value",
  66. "FragmentOutputBlock": "A mandatory final node for outputing the color of each pixel",
  67. "VertexOutputBlock": "A mandatory final node for outputing the position of each vertex",
  68. "ClampBlock": "Outputs values above the maximum or below minimum as maximum or minimum values respectively",
  69. "NormalizeBlock": "Remaps the length of a vector or color to 1",
  70. "RemapBlock": "Remaps input value between sourceMin and sourceMax to a new range between targetMin and targetMax",
  71. "CeilingBlock": "Outputs fractional values as the next higher whole number",
  72. "FloorBlock": "Outputs fractional values as the next lower whole number",
  73. "RoundBlock": "Outputs fractional values rounded to the nearest whole number",
  74. "CameraPositionBlock": "Outputs a Vector3 position of the active scene camera",
  75. "FogBlock": "Applies fog to the scene with an increasing opacity based on distance from the camera",
  76. "FogColorBlock": "The system value for fog color pulled from the scene",
  77. "ImageProcessingBlock": "Provides access to all of the Babylon image processing properties",
  78. "LightBlock": "Outputs diffuse and specular contributions from one or more scene lights",
  79. "LightInformationBlock": "Provides the direction, color and intensity of a selected light based on its world position",
  80. "ReflectionTextureBlock": "Creates a reflection from the input texture",
  81. "ViewDirectionBlock": "Outputs the direction vector of where the camera is aimed",
  82. "AbsBlock": "Outputs the absolute value of the input value",
  83. "ArcCosBlock": "Outputs the inverse of the cosine value based on the input value",
  84. "ArcSinBlock": "Outputs the inverse of the sine value based on the input value",
  85. "ArcTan2Block": "Outputs the inverse of the tangent value based on the input value",
  86. "ArcTanBlock": "Outputs the inverse of the tangent value based on the input value",
  87. "CosBlock": "Outputs the cosine value based on the input value",
  88. "DegreesToRadiansBlock": "Converts the input degrees value to radians",
  89. "Exp2Block": "Outputs the input value multiplied by itself 1 time. (Exponent of 2)",
  90. "ExpBlock": "Outputs the input value multiplied by itself 9 time. (Exponent of 10)",
  91. "FractBlock": "Outputs only the fractional value of a floating point number",
  92. "LogBlock": "The logarithmic value based on the input value",
  93. "PowBlock": "Outputs the input value multiplied by itself the number of times equal to the power input (Exponent of power)",
  94. "RadiansToDegreesBlock": "Converts the input radians value to degrees",
  95. "SawToothWaveBlock": "Outputs a sawtooth pattern value between -1 and 1 based on the input value",
  96. "SignBlock": "returns 1 if the input is positive, 0 if input is equal to 0, or -1 if the input is negative",
  97. "SinBlock": "Outputs the the sine value based on the input value",
  98. "SqrtBlock": "Outputs the the square root of the input value",
  99. "SquareWaveBlock": "Outputs a stepped pattern value between -1 and 1 based on the input value",
  100. "TanBlock": "Outputs the the tangent value based on the input value",
  101. "TriangleWaveBlock": "Outputs a sawtooth pattern value between 0 and 1 based on the input value",
  102. "CrossBlock": "Outputs a vector that is perpendicular to two input vectors",
  103. "DotBlock": "Outputs the cos of the angle between two vectors",
  104. "FresnelBlock": "Outputs the grazing angle of the surface of the mesh, relative to a camera influenced by the bias and power inputs",
  105. "TransformBlock": "Transforms a input vector based on the input matrix",
  106. "DerivativeBlock": "FRAGMENT SHADER ONLY. Provides the rate of change for an input on a given axis (x,y).",
  107. "DesaturateBlock": "Convert a color input into a grayscale representation.",
  108. "WorldViewMatrixBlock": "A matrix to remap points in 3D local space to 3D world space, and ending in 2D camera space.",
  109. "FrontFacingBlock": "Returns 1 if a mesh triangle faces the normal direction and 0 if it does not.",
  110. "SimplexPerlin3DBlock": "Creates a type of gradient noise with few directional artifacts.",
  111. "WorleyNoise3DBlock": "Creates a random pattern resembling cells.",
  112. "ReflectBlock": "Outputs the direction of the input vector reflected across the surface normal.",
  113. "RefractBlock": "Outputs a direction simulating a deflection of the input vector.",
  114. "Rotate2dBlock": "Rotates UV coordinates around the W axis.",
  115. "PBRMetallicRoughnessBlock": "PBR metallic/roughness material",
  116. "SheenBlock": "PBR Sheen block",
  117. "AmbientOcclusionBlock": "PBR Ambient occlusion block",
  118. "ReflectivityBlock": "PBR Reflectivity block",
  119. "AnisotropyBlock": "PBR Anisotropy block",
  120. "ReflectionBlock": "PBR Reflection block",
  121. "ClearCoatBlock": "PBR ClearCoat block",
  122. "RefractionBlock": "PBR Refraction block",
  123. "SubSurfaceBlock": "PBR SubSurface block",
  124. };
  125. constructor(props: INodeListComponentProps) {
  126. super(props);
  127. this.state = { filter: "" };
  128. }
  129. filterContent(filter: string) {
  130. this.setState({ filter: filter });
  131. }
  132. render() {
  133. // Block types used to create the menu from
  134. const allBlocks = {
  135. Animation: ["BonesBlock", "MorphTargetsBlock"],
  136. Color_Management: ["ReplaceColorBlock", "PosterizeBlock", "GradientBlock", "DesaturateBlock"],
  137. Conversion_Blocks: ["ColorMergerBlock", "ColorSplitterBlock", "VectorMergerBlock", "VectorSplitterBlock"],
  138. Inputs: ["Float", "Vector2", "Vector3", "Vector4", "Color3", "Color4", "TextureBlock", "ReflectionTextureBlock", "TimeBlock", "DeltaTimeBlock"],
  139. Interpolation: ["LerpBlock", "StepBlock", "SmoothStepBlock", "NLerpBlock"],
  140. Math__Standard: ["AddBlock", "DivideBlock", "MaxBlock", "MinBlock", "MultiplyBlock", "NegateBlock", "OneMinusBlock", "ReciprocalBlock", "ScaleBlock", "SignBlock", "SqrtBlock", "SubtractBlock"],
  141. Math__Scientific: ["AbsBlock", "ArcCosBlock", "ArcSinBlock", "ArcTanBlock", "ArcTan2Block", "CosBlock", "DegreesToRadiansBlock", "ExpBlock", "Exp2Block", "FractBlock", "LogBlock", "PowBlock", "RadiansToDegreesBlock", "SawToothWaveBlock", "SinBlock", "SquareWaveBlock", "TanBlock", "TriangleWaveBlock"],
  142. Math__Vector: ["CrossBlock", "DerivativeBlock", "DistanceBlock", "DotBlock", "FresnelBlock", "LengthBlock", "ReflectBlock", "RefractBlock", "Rotate2dBlock", "TransformBlock", ],
  143. Matrices: ["Matrix", "WorldMatrixBlock", "WorldViewMatrixBlock", "WorldViewProjectionMatrixBlock", "ViewMatrixBlock", "ViewProjectionMatrixBlock", "ProjectionMatrixBlock"],
  144. Mesh: ["InstancesBlock", "PositionBlock", "UVBlock", "ColorBlock", "NormalBlock", "PerturbNormalBlock", "NormalBlendBlock" , "TangentBlock", "MatrixIndicesBlock", "MatrixWeightsBlock", "WorldPositionBlock", "WorldNormalBlock", "WorldTangentBlock", "FrontFacingBlock"],
  145. Noises: ["RandomNumberBlock", "SimplexPerlin3DBlock", "WorleyNoise3DBlock"],
  146. Output_Nodes: ["VertexOutputBlock", "FragmentOutputBlock", "DiscardBlock"],
  147. PBR: ["PBRMetallicRoughnessBlock", "AmbientOcclusionBlock", "AnisotropyBlock", "ClearCoatBlock", "ReflectionBlock", "ReflectivityBlock", "RefractionBlock", "SheenBlock", "SubSurfaceBlock"],
  148. Range: ["ClampBlock", "RemapBlock", "NormalizeBlock"],
  149. Round: ["RoundBlock", "CeilingBlock", "FloorBlock"],
  150. Scene: ["FogBlock", "CameraPositionBlock", "FogColorBlock", "ImageProcessingBlock", "LightBlock", "LightInformationBlock", "ViewDirectionBlock"],
  151. };
  152. // Create node menu
  153. var blockMenu = [];
  154. for (var key in allBlocks) {
  155. var blockList = (allBlocks as any)[key].filter((b: string) => !this.state.filter || b.toLowerCase().indexOf(this.state.filter.toLowerCase()) !== -1)
  156. .sort((a: string, b: string) => a.localeCompare(b))
  157. .map((block: any, i: number) => {
  158. let tooltip = NodeListComponent._Tooltips[block] || "";
  159. return <DraggableLineComponent key={block} data={block} tooltip={tooltip}/>;
  160. });
  161. if (blockList.length) {
  162. blockMenu.push(
  163. <LineContainerComponent key={key + " blocks"} title={key.replace("__", ": ").replace("_", " ")} closed={false}>
  164. {blockList}
  165. </LineContainerComponent>
  166. );
  167. }
  168. }
  169. return (
  170. <div id="nodeList">
  171. <div className="panes">
  172. <div className="pane">
  173. <div className="filter">
  174. <input type="text" placeholder="Filter"
  175. onFocus={() => this.props.globalState.blockKeyboardEvents = true}
  176. onBlur={(evt) => {
  177. this.props.globalState.blockKeyboardEvents = false;
  178. }}
  179. onChange={(evt) => this.filterContent(evt.target.value)} />
  180. </div>
  181. <div className="list-container">
  182. {blockMenu}
  183. </div>
  184. </div>
  185. </div>
  186. </div>
  187. );
  188. }
  189. }