|
@@ -19,7 +19,7 @@ import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } fr
|
|
|
import { Nullable } from '../../types';
|
|
|
import { VertexBuffer } from '../../Meshes/buffer';
|
|
|
import { Tools } from '../../Misc/tools';
|
|
|
-import { VectorTransformBlock } from './Blocks/vectorTransformBlock';
|
|
|
+import { TransformBlock } from './Blocks/transformBlock';
|
|
|
import { VertexOutputBlock } from './Blocks/Vertex/vertexOutputBlock';
|
|
|
import { FragmentOutputBlock } from './Blocks/Fragment/fragmentOutputBlock';
|
|
|
import { InputBlock } from './Blocks/Input/inputBlock';
|
|
@@ -847,14 +847,14 @@ export class NodeMaterial extends PushMaterial {
|
|
|
var worldInput = new InputBlock("world");
|
|
|
worldInput.setAsWellKnownValue(BABYLON.NodeMaterialWellKnownValues.World);
|
|
|
|
|
|
- var worldPos = new VectorTransformBlock("worldPos");
|
|
|
+ var worldPos = new TransformBlock("worldPos");
|
|
|
positionInput.connectTo(worldPos);
|
|
|
worldInput.connectTo(worldPos);
|
|
|
|
|
|
var viewProjectionInput = new InputBlock("viewProjection");
|
|
|
viewProjectionInput.setAsWellKnownValue(BABYLON.NodeMaterialWellKnownValues.ViewProjection);
|
|
|
|
|
|
- var worldPosdMultipliedByViewProjection = new VectorTransformBlock("worldPos * viewProjectionTransform");
|
|
|
+ var worldPosdMultipliedByViewProjection = new TransformBlock("worldPos * viewProjectionTransform");
|
|
|
worldPos.connectTo(worldPosdMultipliedByViewProjection);
|
|
|
viewProjectionInput.connectTo(worldPosdMultipliedByViewProjection);
|
|
|
|
|
@@ -924,14 +924,12 @@ export class NodeMaterial extends PushMaterial {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Creates a node material from parsed material data
|
|
|
+ * Clear the current graph and load a new one from a serialization object
|
|
|
* @param source defines the JSON representation of the material
|
|
|
- * @param scene defines the hosting scene
|
|
|
* @param rootUrl defines the root URL to use to load textures and relative dependencies
|
|
|
- * @returns a new node material
|
|
|
*/
|
|
|
- public static Parse(source: any, scene: Scene, rootUrl: string = ""): NodeMaterial {
|
|
|
- let nodeMaterial = SerializationHelper.Parse(() => new NodeMaterial(source.name, scene), source, scene, rootUrl);
|
|
|
+ public loadFromSerialization(source: any, rootUrl: string = "") {
|
|
|
+ this.clear();
|
|
|
|
|
|
let map: {[key: number]: NodeMaterialBlock} = {};
|
|
|
|
|
@@ -940,7 +938,7 @@ export class NodeMaterial extends PushMaterial {
|
|
|
let blockType = _TypeStore.GetClass(parsedBlock.customType);
|
|
|
if (blockType) {
|
|
|
let block: NodeMaterialBlock = new blockType();
|
|
|
- block._deserialize(parsedBlock, scene, rootUrl);
|
|
|
+ block._deserialize(parsedBlock, this.getScene(), rootUrl);
|
|
|
map[parsedBlock.id] = block;
|
|
|
}
|
|
|
}
|
|
@@ -968,8 +966,21 @@ export class NodeMaterial extends PushMaterial {
|
|
|
|
|
|
// Outputs
|
|
|
for (var outputNodeId of source.outputNodes) {
|
|
|
- nodeMaterial.addOutputNode(map[outputNodeId]);
|
|
|
+ this.addOutputNode(map[outputNodeId]);
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Creates a node material from parsed material data
|
|
|
+ * @param source defines the JSON representation of the material
|
|
|
+ * @param scene defines the hosting scene
|
|
|
+ * @param rootUrl defines the root URL to use to load textures and relative dependencies
|
|
|
+ * @returns a new node material
|
|
|
+ */
|
|
|
+ public static Parse(source: any, scene: Scene, rootUrl: string = ""): NodeMaterial {
|
|
|
+ let nodeMaterial = SerializationHelper.Parse(() => new NodeMaterial(source.name, scene), source, scene, rootUrl);
|
|
|
+
|
|
|
+ nodeMaterial.loadFromSerialization(source, rootUrl);
|
|
|
|
|
|
return nodeMaterial;
|
|
|
}
|