Ver código fonte

Associated with #6012

David Catuhe 6 anos atrás
pai
commit
6726f2141a

+ 5 - 7
nodeEditor/src/components/diagram/diagram.scss

@@ -100,13 +100,6 @@
         }
     }
 
-    .preview {
-        border-bottom-left-radius: 16px;
-        border: black 4px solid;
-        border-left: 0px;
-        border-bottom: 0px;
-    }
-
     .inputs {
         grid-row: 2;
         grid-column: 1;
@@ -271,6 +264,11 @@
             height: 140px;
             grid-column: 1;
             grid-row: 3;     
+            overflow: hidden;
+            border-bottom-left-radius: 16px;
+            border: black 4px solid;
+            border-left: 0px;
+            border-bottom: 0px;
 
             canvas {
                 width: 100%;

+ 1 - 1
nodeEditor/src/components/diagram/texture/textureNodeWidget.tsx

@@ -53,7 +53,7 @@ export class TextureNodeWidget extends React.Component<ITextureNodeWidgetProps>
                 </div>
                 {
                     this.props.node && this.props.node.texture &&
-                    <TextureLineComponent ref="textureView" width={136} height={136} texture={this.props.node.texture} hideChannelSelect={true} />
+                    <TextureLineComponent ref="textureView" width={140} height={140} texture={this.props.node.texture} hideChannelSelect={true} />
                 }
             </div>
         );

+ 18 - 4
nodeEditor/src/graphEditor.tsx

@@ -75,6 +75,7 @@ export class GraphEditor extends React.Component<IGraphEditorProps> {
     private _rightWidth = DataStorage.ReadNumber("RightWidth", 300);
 
     private _nodes = new Array<DefaultNodeModel>();
+    private _blocks = new Array<NodeMaterialBlock>();
 
     /** @hidden */
     public _toAdd: LinkModel[] | null = [];
@@ -84,10 +85,16 @@ export class GraphEditor extends React.Component<IGraphEditorProps> {
      * @param nodeMaterialBlock 
      */
     public createNodeFromObject(options: NodeCreationOptions) {
+        if (this._blocks.indexOf(options.nodeMaterialBlock) !== -1) {        
+            return this._nodes.filter(n => n.block === options.nodeMaterialBlock)[0];
+        }
+
+        this._blocks.push(options.nodeMaterialBlock);
+
         // Create new node in the graph
         var newNode: DefaultNodeModel;
         var filterInputs = [];
-
+       
         if (options.nodeMaterialBlock instanceof TextureBlock) {
             newNode = new TextureNodeModel();
             filterInputs.push("uv");
@@ -269,9 +276,16 @@ export class GraphEditor extends React.Component<IGraphEditorProps> {
                     // Block is deleted
                     let targetBlock = (e.node as GenericNodeModel).block;
 
-                    if (targetBlock && targetBlock.isFinalMerger) {
-                        this.props.globalState.nodeMaterial!.removeOutputNode(targetBlock);
-                    }
+                    if (targetBlock) {
+                        if (targetBlock.isFinalMerger) {
+                            this.props.globalState.nodeMaterial!.removeOutputNode(targetBlock);
+                        }
+                        let blockIndex = this._blocks.indexOf(targetBlock);
+
+                        if (blockIndex > -1) {
+                            this._blocks.splice(blockIndex, 1);
+                        }
+                    }                  
 
                     this.props.globalState.onSelectionChangedObservable.notifyObservers(null);
                 }

+ 4 - 3
src/Meshes/instancedMesh.ts

@@ -47,9 +47,6 @@ export class InstancedMesh extends AbstractMesh {
         this.setPivotMatrix(source.getPivotMatrix());
 
         this.refreshBoundingInfo();
-        if (!this._sourceMesh.subMeshes) {
-            Logger.Warn("Instances should only be created for meshes with Geometry.");
-        }
         this._syncSubMeshes();
     }
 
@@ -284,6 +281,10 @@ export class InstancedMesh extends AbstractMesh {
 
     /** @hidden */
     public _activate(renderId: number, intermediateRendering: boolean): boolean {
+        if (!this._sourceMesh.subMeshes) {
+            Logger.Warn("Instances should only be created for meshes with geometry.");
+        }
+
         if (this._currentLOD) {
             this._currentLOD._registerInstanceForRenderId(this, renderId);