123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- import { AlphaTestBlock } from 'babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock';
- import { BonesBlock } from 'babylonjs/Materials/Node/Blocks/Vertex/bonesBlock';
- import { InstancesBlock } from 'babylonjs/Materials/Node/Blocks/Vertex/instancesBlock';
- import { MorphTargetsBlock } from 'babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock';
- import { ImageProcessingBlock } from 'babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock';
- import { ColorMergerBlock } from 'babylonjs/Materials/Node/Blocks/colorMergerBlock';
- import { VectorMergerBlock } from 'babylonjs/Materials/Node/Blocks/vectorMergerBlock';
- import { ColorSplitterBlock } from 'babylonjs/Materials/Node/Blocks/colorSplitterBlock';
- import { VectorSplitterBlock } from 'babylonjs/Materials/Node/Blocks/vectorSplitterBlock';
- import { TextureBlock } from 'babylonjs/Materials/Node/Blocks/Dual/textureBlock';
- import { LightBlock } from 'babylonjs/Materials/Node/Blocks/Dual/lightBlock';
- import { FogBlock } from 'babylonjs/Materials/Node/Blocks/Dual/fogBlock';
- import { VertexOutputBlock } from 'babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock';
- import { FragmentOutputBlock } from 'babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock';
- import { AddBlock } from 'babylonjs/Materials/Node/Blocks/addBlock';
- import { ClampBlock } from 'babylonjs/Materials/Node/Blocks/clampBlock';
- import { CrossBlock } from 'babylonjs/Materials/Node/Blocks/crossBlock';
- import { DotBlock } from 'babylonjs/Materials/Node/Blocks/dotBlock';
- import { MultiplyBlock } from 'babylonjs/Materials/Node/Blocks/multiplyBlock';
- import { TransformBlock } from 'babylonjs/Materials/Node/Blocks/transformBlock';
- import { NodeMaterialBlockConnectionPointTypes } from 'babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes';
- export class BlockTools {
- public static GetBlockFromString(data: string) {
- switch (data) {
- case "BonesBlock":
- return new BonesBlock("Bones");
- case "InstancesBlock":
- return new InstancesBlock("Instances");
- case "MorphTargetsBlock":
- return new MorphTargetsBlock("MorphTargets");
- case "AlphaTestBlock":
- return new AlphaTestBlock("AlphaTest");
- case "ImageProcessingBlock":
- return new ImageProcessingBlock("ImageProcessing");
- case "ColorMergerBlock":
- return new ColorMergerBlock("ColorMerger");
- case "VectorMergerBlock":
- return new VectorMergerBlock("VectorMerger");
- case "ColorSplitterBlock":
- return new ColorSplitterBlock("ColorSplitter");
- case "VectorSplitterBlock":
- return new VectorSplitterBlock("VectorSplitter");
- case "TextureBlock":
- return new TextureBlock("Texture");
- case "LightBlock":
- return new LightBlock("Lights");
- case "FogBlock":
- return new FogBlock("Fog");
- case "VertexOutputBlock":
- return new VertexOutputBlock("VertexOutput");
- case "FragmentOutputBlock":
- return new FragmentOutputBlock("FragmentOutput");
- case "AddBlock":
- return new AddBlock("Add");
- case "ClampBlock":
- return new ClampBlock("Clamp");
- case "CrossBlock":
- return new CrossBlock("Dot");
- case "DotBlock":
- return new DotBlock("Dot");
- case "MultiplyBlock":
- return new MultiplyBlock("Multiply");
- case "TransformBlock":
- return new TransformBlock("Transform");
- }
- return null;
- }
- public static GetColorFromConnectionNodeType(type: NodeMaterialBlockConnectionPointTypes) {
- let color = "Red";
- switch (type) {
- case NodeMaterialBlockConnectionPointTypes.Float:
- color = "DimGrey";
- break;
- case NodeMaterialBlockConnectionPointTypes.Vector2:
- color = "Chocolate";
- break;
- case NodeMaterialBlockConnectionPointTypes.Vector3:
- color = "Crimson";
- break;
- case NodeMaterialBlockConnectionPointTypes.Vector4:
- color = "DarkMagenta";
- break;
- case NodeMaterialBlockConnectionPointTypes.Color3:
- color = "ForestGreen";
- break;
- case NodeMaterialBlockConnectionPointTypes.Color4:
- color = "Gold";
- break;
- case NodeMaterialBlockConnectionPointTypes.Matrix:
- color = "LightCoral";
- break;
- }
- return color;
- }
- public static GetConnectionNodeTypeFromString(type: string) {
- switch (type) {
- case "Float":
- return NodeMaterialBlockConnectionPointTypes.Float;
- case "Vector2":
- return NodeMaterialBlockConnectionPointTypes.Vector2;
- case "Vector3":
- return NodeMaterialBlockConnectionPointTypes.Vector3;
- case "Vector4":
- return NodeMaterialBlockConnectionPointTypes.Vector4;
- case "Matrix":
- return NodeMaterialBlockConnectionPointTypes.Matrix;
- case "Color3":
- return NodeMaterialBlockConnectionPointTypes.Color3;
- case "Color4":
- return NodeMaterialBlockConnectionPointTypes.Color4;
- }
- return NodeMaterialBlockConnectionPointTypes.AutoDetect;
- }
- public static GetStringFromConnectionNodeType(type: NodeMaterialBlockConnectionPointTypes) {
- switch (type){
- case NodeMaterialBlockConnectionPointTypes.Float:
- return "Float";
- case NodeMaterialBlockConnectionPointTypes.Vector2:
- return "Vector2";
- case NodeMaterialBlockConnectionPointTypes.Vector3:
- return "Vector3";
- case NodeMaterialBlockConnectionPointTypes.Vector4:
- return "Vector4";
- case NodeMaterialBlockConnectionPointTypes.Color3:
- return "Color3";
- case NodeMaterialBlockConnectionPointTypes.Color4:
- return "Color4";
- case NodeMaterialBlockConnectionPointTypes.Matrix:
- return "Matrix";
- }
- return "";
- }
- }
|