David Catuhe 6 年之前
父節點
當前提交
21eadb01d6

+ 4 - 0
nodeEditor/src/components/diagram/diagram.scss

@@ -1,3 +1,7 @@
+.srd-node {
+    width: 200px;
+}
+
 .diagramBlock {
     background: white;
     width: 100%;

+ 2 - 4
nodeEditor/src/components/nodeList/nodeListComponent.tsx

@@ -16,13 +16,11 @@ import { VertexOutputBlock } from 'babylonjs/Materials/Node/Blocks/Vertex/vertex
 import { FogBlock } from 'babylonjs/Materials/Node/Blocks/Dual/fogBlock';
 import { AddBlock } from 'babylonjs/Materials/Node/Blocks/addBlock';
 import { ClampBlock } from 'babylonjs/Materials/Node/Blocks/clampBlock';
-import { MatrixMultiplicationBlock } from 'babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock';
 import { MultiplyBlock } from 'babylonjs/Materials/Node/Blocks/multiplyBlock';
 import { Vector2TransformBlock } from 'babylonjs/Materials/Node/Blocks/vector2TransformBlock';
 import { Vector3TransformBlock } from 'babylonjs/Materials/Node/Blocks/vector3TransformBlock';
 import { Vector4TransformBlock } from 'babylonjs/Materials/Node/Blocks/vector4TransformBlock';
 import { NodeMaterialBlock } from 'babylonjs/Materials/Node/nodeMaterialBlock';
-import { ScaleBlock } from 'babylonjs/Materials/Node/Blocks/scaleBlock';
 import { LightBlock } from 'babylonjs/Materials/Node/Blocks/Dual/lightBlock';
 
 require("./nodeList.scss");
@@ -41,8 +39,8 @@ export class NodeListComponent extends React.Component<INodeListComponentProps>
             Fragment: [AlphaTestBlock, , ImageProcessingBlock, RGBAMergerBlock, RGBASplitterBlock, TextureBlock, LightBlock],
             Outputs: [VertexOutputBlock, FragmentOutputBlock],
             Dual: [FogBlock],
-            Math: [AddBlock, ClampBlock, MatrixMultiplicationBlock, MultiplyBlock, ScaleBlock, Vector2TransformBlock, Vector3TransformBlock, Vector4TransformBlock],
-            Inputs: ["Vector2", "Vector3", "Vector4", "Color3", "Color4", "Matrix"],
+            Math: [AddBlock, ClampBlock, MultiplyBlock, Vector2TransformBlock, Vector3TransformBlock, Vector4TransformBlock],
+            Inputs: ["Float", "Vector2", "Vector3", "Vector4", "Color3", "Color4", "Matrix"],
         }
 
         // Create node menu

+ 11 - 2
nodeEditor/src/graphEditor.tsx

@@ -215,8 +215,14 @@ export class GraphEditor extends React.Component<IGraphEditorProps> {
                                 link.output.connection.disconnectFrom(link.input.connection)
                                 link.input.syncWithNodeMaterialConnectionPoint(link.input.connection)
                                 link.output.syncWithNodeMaterialConnectionPoint(link.output.connection)
-                            } else if (link.input.connection.value) {
-                                link.input.connection.value = null;
+                            } else {
+                                let inputNode = link.output.parent as InputNodeModel
+                                inputNode.connection = undefined;
+
+                                if (link.input.connection.value) {
+                                    inputNode.ports[link.output.name].defaultValue = link.input.connection.value;
+                                    link.input.connection.value = null;
+                                }
                             }
                         }
                     }
@@ -297,6 +303,9 @@ export class GraphEditor extends React.Component<IGraphEditorProps> {
 
         if (!connection) {
             switch (type) {
+                case "Float":
+                    outPort.defaultValue = 0;
+                    break;
                 case "Vector2":
                     outPort.defaultValue = Vector2.Zero();
                     break;

+ 1 - 3
src/Materials/Node/Blocks/index.ts

@@ -4,8 +4,6 @@ export * from "./Dual/index";
 export * from "./multiplyBlock";
 export * from "./addBlock";
 export * from "./clampBlock";
-export * from "./scaleBlock";
 export * from "./vector2TransformBlock";
 export * from "./vector3TransformBlock";
-export * from "./vector4TransformBlock";
-export * from "./matrixMultiplicationBlock";
+export * from "./vector4TransformBlock";

+ 0 - 61
src/Materials/Node/Blocks/matrixMultiplicationBlock.ts

@@ -1,61 +0,0 @@
-import { NodeMaterialBlock } from '../nodeMaterialBlock';
-import { NodeMaterialBlockConnectionPointTypes } from '../nodeMaterialBlockConnectionPointTypes';
-import { NodeMaterialBuildState } from '../nodeMaterialBuildState';
-import { NodeMaterialBlockTargets } from '../nodeMaterialBlockTargets';
-import { NodeMaterialConnectionPoint } from '../nodeMaterialBlockConnectionPoint';
-
-/**
- * Block used to multiply two matrices
- */
-export class MatrixMultiplicationBlock extends NodeMaterialBlock {
-    /**
-     * Creates a new MatrixMultiplicationBlock
-     * @param name defines the block name
-     */
-    public constructor(name: string) {
-        super(name, NodeMaterialBlockTargets.Vertex);
-
-        this.registerInput("left", NodeMaterialBlockConnectionPointTypes.Matrix);
-        this.registerInput("right", NodeMaterialBlockConnectionPointTypes.Matrix);
-        this.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Matrix);
-    }
-
-    /**
-     * Gets the left operand
-     */
-    public get left(): NodeMaterialConnectionPoint {
-        return this._inputs[0];
-    }
-
-    /**
-     * Gets the right operand
-     */
-    public get right(): NodeMaterialConnectionPoint {
-        return this._inputs[1];
-    }
-
-    /**
-     * Gets the output component
-     */
-    public get output(): NodeMaterialConnectionPoint {
-        return this._outputs[0];
-    }
-
-    /**
-     * Gets the current class name
-     * @returns the class name
-     */
-    public getClassName() {
-        return "MatrixMultiplicationBlock";
-    }
-
-    protected _buildBlock(state: NodeMaterialBuildState) {
-        super._buildBlock(state);
-
-        let output = this._outputs[0];
-
-        state.compilationString += this._declareOutput(output, state) + ` = ${this.left.associatedVariableName} * ${this.right.associatedVariableName};\r\n`;
-
-        return this;
-    }
-}

+ 1 - 1
src/Materials/Node/Blocks/multiplyBlock.ts

@@ -3,7 +3,7 @@ import { NodeMaterialBlockConnectionPointTypes } from '../nodeMaterialBlockConne
 import { NodeMaterialBuildState } from '../nodeMaterialBuildState';
 import { NodeMaterialConnectionPoint } from '../nodeMaterialBlockConnectionPoint';
 /**
- * Block used to multiply 2 vector4
+ * Block used to multiply 2 values
  */
 export class MultiplyBlock extends NodeMaterialBlock {
     /**

+ 0 - 63
src/Materials/Node/Blocks/scaleBlock.ts

@@ -1,63 +0,0 @@
-import { NodeMaterialBlock } from '../nodeMaterialBlock';
-import { NodeMaterialBlockConnectionPointTypes } from '../nodeMaterialBlockConnectionPointTypes';
-import { NodeMaterialBuildState } from '../nodeMaterialBuildState';
-import { NodeMaterialConnectionPoint } from '../nodeMaterialBlockConnectionPoint';
-/**
- * Block used to scale a value
- */
-export class ScaleBlock extends NodeMaterialBlock {
-    /**
-     * Creates a new ScaleBlock
-     * @param name defines the block name
-     */
-    public constructor(name: string) {
-        super(name);
-
-        this.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect);
-        this.registerInput("scale", NodeMaterialBlockConnectionPointTypes.Float);
-        this.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput);
-
-        this._outputs[0]._typeConnectionSource = this._inputs[0];
-
-        this.scale.value = 1;
-    }
-
-    /**
-     * Gets the current class name
-     * @returns the class name
-     */
-    public getClassName() {
-        return "ScaleBlock";
-    }
-
-    /**
-     * Gets the value operand input component
-     */
-    public get value(): NodeMaterialConnectionPoint {
-        return this._inputs[0];
-    }
-
-    /**
-     * Gets the scale operand input component
-     */
-    public get scale(): NodeMaterialConnectionPoint {
-        return this._inputs[1];
-    }
-
-    /**
-     * Gets the output component
-     */
-    public get output(): NodeMaterialConnectionPoint {
-        return this._outputs[0];
-    }
-
-    protected _buildBlock(state: NodeMaterialBuildState) {
-        super._buildBlock(state);
-
-        let output = this._outputs[0];
-
-        state.compilationString += this._declareOutput(output, state) + ` = ${this.value.associatedVariableName} * ${this.scale.associatedVariableName};\r\n`;
-
-        return this;
-    }
-}

+ 4 - 0
src/Materials/Node/nodeMaterialBlockConnectionPoint.ts

@@ -46,6 +46,10 @@ export class NodeMaterialConnectionPoint {
             }
 
             if (this.isUniform && this.value != null) {
+                if (!isNaN(this.value)) {
+                    return NodeMaterialBlockConnectionPointTypes.Float;
+                }
+
                 switch (this.value.getClassName()) {
                     case "Vector2":
                         return NodeMaterialBlockConnectionPointTypes.Vector2;