瀏覽代碼

Fix multi textures issue with nme

David Catuhe 5 年之前
父節點
當前提交
12199e6ca3

+ 3 - 0
nodeEditor/src/graphEditor.tsx

@@ -57,6 +57,7 @@ import { GradientNodeFactory } from './components/diagram/gradient/gradientNodeF
 import { ReflectionTextureBlock } from 'babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock';
 import { ReflectionTextureNodeFactory } from './components/diagram/reflectionTexture/reflectionTextureNodeFactory';
 import { ReflectionTextureNodeModel } from './components/diagram/reflectionTexture/reflectionTextureNodeModel';
+import { SerializationTools } from './serializationTools';
 
 require("storm-react-diagrams/dist/style.min.css");
 require("./main.scss");
@@ -369,6 +370,8 @@ export class GraphEditor extends React.Component<IGraphEditorProps> {
         catch (err) {
             this.props.globalState.onLogRequiredObservable.notifyObservers(new LogEntry(err, true));
         }
+
+        SerializationTools.UpdateLocations(this.props.globalState.nodeMaterial, this.props.globalState);
     }
 
     applyFragmentOutputConstraints(rootInput: DefaultPortModel) {

+ 16 - 0
nodeEditor/src/serializationTools.ts

@@ -4,6 +4,22 @@ import { Texture } from 'babylonjs/Materials/Textures/texture';
 import { DataStorage } from './dataStorage';
 
 export class SerializationTools {
+
+    public static UpdateLocations(material: NodeMaterial, globalState: GlobalState) {
+        material.editorData = [];
+
+        // Store node locations
+        for (var block of material.attachedBlocks) {
+            let node = globalState.onGetNodeFromBlock(block);
+
+            material.editorData.push({
+                blockId: block.uniqueId,
+                x: node ? node.x : 0,
+                y: node ? node.y : 0
+            });
+        }
+    }
+
     public static Serialize(material: NodeMaterial, globalState: GlobalState) {
         let bufferSerializationState = Texture.SerializeBuffers;
         Texture.SerializeBuffers = DataStorage.ReadBoolean("EmbedTextures", true);

+ 1 - 1
nodeEditor/src/sharedComponents/checkBoxLineComponent.tsx

@@ -42,7 +42,7 @@ export class CheckBoxLineComponent extends React.Component<ICheckBoxLineComponen
             this._localChange = false;
             return true;
         }
-        return false;
+        return nextProps.label !== this.props.label;
     }
 
     onChange() {

+ 1 - 1
src/Materials/Node/Blocks/Dual/textureBlock.ts

@@ -316,7 +316,7 @@ export class TextureBlock extends NodeMaterialBlock {
     protected _buildBlock(state: NodeMaterialBuildState) {
         super._buildBlock(state);
 
-        if (!this._tempTextureRead) {
+        if (state.target === NodeMaterialBlockTargets.Vertex) {
             this._tempTextureRead = state._getFreeVariableName("tempTextureRead");
         }
 

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

@@ -988,6 +988,8 @@ export class NodeMaterial extends PushMaterial {
     public setToDefault() {
         this.clear();
 
+        this.editorData = null;
+
         var positionInput = new InputBlock("position");
         positionInput.setAsAttribute("position");