Browse Source

Fix nme code generation

David Catuhe 5 years ago
parent
commit
af2057885f

+ 10 - 0
dist/preview release/viewer/babylon.module.d.ts

@@ -56606,6 +56606,7 @@ declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
         private _target;
         private _isFinalMerger;
         private _isInput;
+        protected _isUnique: boolean;
         /** @hidden */
         _codeVariableName: string;
         /** @hidden */
@@ -56623,6 +56624,10 @@ declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
          */
         uniqueId: number;
         /**
+         * Gets a boolean indicating that this block can only be used once per NodeMaterial
+         */
+        readonly isUnique: boolean;
+        /**
          * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
          */
         readonly isFinalMerger: boolean;
@@ -122079,6 +122084,7 @@ declare module BABYLON {
         private _target;
         private _isFinalMerger;
         private _isInput;
+        protected _isUnique: boolean;
         /** @hidden */
         _codeVariableName: string;
         /** @hidden */
@@ -122096,6 +122102,10 @@ declare module BABYLON {
          */
         uniqueId: number;
         /**
+         * Gets a boolean indicating that this block can only be used once per NodeMaterial
+         */
+        readonly isUnique: boolean;
+        /**
          * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
          */
         readonly isFinalMerger: boolean;

File diff suppressed because it is too large
+ 9 - 9
dist/preview release/viewer/babylon.viewer.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js


+ 6 - 2
src/Materials/Node/nodeMaterial.ts

@@ -1079,9 +1079,13 @@ export class NodeMaterial extends PushMaterial {
         }
 
         // Connections
+        alreadyDumped = [];
         codeString += "\r\n// Connections\r\n";
-        for (var node of alreadyDumped) {
-            codeString += node._dumpCodeForOutputConnections();
+        for (var node of this._vertexOutputNodes) {
+            codeString += node._dumpCodeForOutputConnections(alreadyDumped);
+        }
+        for (var node of this._fragmentOutputNodes) {
+            codeString += node._dumpCodeForOutputConnections(alreadyDumped);
         }
 
         // Output nodes

+ 8 - 1
src/Materials/Node/nodeMaterialBlock.ts

@@ -588,9 +588,15 @@ export class NodeMaterialBlock {
     }
 
     /** @hidden */
-    public _dumpCodeForOutputConnections() {
+    public _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]) {
         let codeString = "";
 
+        if (alreadyDumped.indexOf(this) !== -1) {
+            return codeString;
+        }
+
+        alreadyDumped.push(this);
+
         for (var input of this.inputs) {
             if (!input.isConnected) {
                 continue;
@@ -599,6 +605,7 @@ export class NodeMaterialBlock {
             var connectedOutput = input.connectedPoint!;
             var connectedBlock = connectedOutput.ownerBlock;
 
+            codeString += connectedBlock._dumpCodeForOutputConnections(alreadyDumped);
             codeString += `${connectedBlock._codeVariableName}.${connectedBlock._outputRename(connectedOutput.name)}.connectTo(${this._codeVariableName}.${this._inputRename(input.name)});\r\n`;
         }