|
1 | 1 | /**
|
2 | 2 | * @license
|
3 |
| - * PlayCanvas Engine v1.34.0-dev revision 7397d249 |
| 3 | + * PlayCanvas Engine v1.34.0-dev revision 8f01a724 |
4 | 4 | * Copyright 2011-2020 PlayCanvas Ltd. All rights reserved.
|
5 | 5 | */
|
6 | 6 | (function (global, factory) {
|
|
447 | 447 | return result;
|
448 | 448 | }();
|
449 | 449 | var version = "1.34.0-dev";
|
450 |
| - var revision = "7397d249"; |
| 450 | + var revision = "8f01a724"; |
451 | 451 | var config = { };
|
452 | 452 | var common = { };
|
453 | 453 | var apps = { };
|
|
23899 | 23899 | } else if (typeof(value) === 'number') {
|
23900 | 23900 | graphVar = { type: type, name: name, valueX: value };
|
23901 | 23901 | } else {
|
23902 |
| - graphVar = { type: type, name: name}; |
| 23902 | + graphVar = { type: type, name: name }; |
23903 | 23903 | }
|
23904 | 23904 | this.graphData.graphVars.push(graphVar);
|
23905 | 23905 | return graphVar;
|
|
24161 | 24161 | } else {
|
24162 | 24162 | if (con.srcIndex >= 0) {
|
24163 | 24163 | graphOutputVarTmpVarMap[con.dstVarName] = srcTmpVarMap[con.srcIndex][con.srcVarName];
|
| 24164 | + } else { |
| 24165 | + graphOutputVarTmpVarMap[con.dstVarName] = con.srcVarName; |
24164 | 24166 | }
|
24165 | 24167 | }
|
24166 | 24168 | }
|
|
24225 | 24227 | }
|
24226 | 24228 | return this.nodeRegistry[name];
|
24227 | 24229 | };
|
24228 |
| - shadergraph.start = function () { |
| 24230 | + shadergraph._addCoreFunction = function (coreName, coreNode) { |
| 24231 | + this[coreName] = function (...args) { |
| 24232 | + var sgIndex = this.graph.addSubGraph(this._getNode(coreName)); |
| 24233 | + var sgInputs = coreNode.graphData.graphVars.filter(function (graphVar) { |
| 24234 | + return graphVar.name.startsWith('IN_'); |
| 24235 | + }); |
| 24236 | + if (sgInputs.length === args.length) { |
| 24237 | + args.forEach((arg, argIndex) => { |
| 24238 | + if (typeof(arg) === 'number') { |
| 24239 | + var argNodeIndex = arg; |
| 24240 | + this.graph.connect(argNodeIndex, 'OUT_ret', sgIndex, sgInputs[argIndex].name); |
| 24241 | + } else if (arg.type) { |
| 24242 | + this.graph.connect(-1, arg.name, sgIndex, sgInputs[argIndex].name); |
| 24243 | + } else { |
| 24244 | + this.graph.connect(arg.node, arg.port, sgIndex, sgInputs[argIndex].name); |
| 24245 | + } |
| 24246 | + }); |
| 24247 | + } else { |
| 24248 | + console.log("arguments do not match core node function"); |
| 24249 | + } |
| 24250 | + return sgIndex; |
| 24251 | + }; |
| 24252 | + }; |
| 24253 | + shadergraph.start = function (coreNodesJSON) { |
| 24254 | + const coreNodeList = JSON.parse(coreNodesJSON); |
| 24255 | + Object.keys(coreNodeList).forEach((key) => { |
| 24256 | + var coreNode = this._getNode(key, coreNodeList[key].code); |
| 24257 | + this._addCoreFunction(key, coreNode); |
| 24258 | + }); |
24229 | 24259 | shadergraph.graph = this._getNode('graphRoot_' + shadergraph.graphCounter);
|
24230 | 24260 | shadergraph.graph.name = 'graphRoot_' + shadergraph.graphCounter;
|
24231 | 24261 | };
|
@@ -24280,13 +24310,27 @@
|
24280 | 24310 | var graphVar = this.graph.addInput(type, name, value);
|
24281 | 24311 | return graphVar;
|
24282 | 24312 | };
|
24283 |
| - shadergraph.connectFragOut = function (nodeIndex, name) { |
| 24313 | + shadergraph.connectFragOut = function (arg) { |
24284 | 24314 | var graphVar = this.graph.addOutput('vec4', 'fragOut', new Vec4(0, 0, 0, 1));
|
24285 |
| - this.graph.connect(nodeIndex, (name) ? 'OUT_' + name : 'OUT_ret', -1, graphVar.name); |
| 24315 | + if (typeof(arg) === 'number') { |
| 24316 | + var argNodeIndex = arg; |
| 24317 | + this.graph.connect(argNodeIndex, 'OUT_ret', -1, graphVar.name); |
| 24318 | + } else if (arg.type) { |
| 24319 | + this.graph.connect(-1, arg.name, -1, graphVar.name); |
| 24320 | + } else { |
| 24321 | + this.graph.connect(arg.node, arg.port, -1, graphVar.name); |
| 24322 | + } |
24286 | 24323 | };
|
24287 |
| - shadergraph.connectVertexOffset = function (nodeIndex, name) { |
| 24324 | + shadergraph.connectVertexOffset = function (arg) { |
24288 | 24325 | var graphVar = this.graph.addOutput('vec3', 'vertOff', new Vec3(0, 0, 0));
|
24289 |
| - this.graph.connect(nodeIndex, (name) ? 'OUT_' + name : 'OUT_ret', -1, graphVar.name); |
| 24326 | + if (typeof(arg) === 'number') { |
| 24327 | + var argNodeIndex = arg; |
| 24328 | + this.graph.connect(argNodeIndex, 'OUT_ret', -1, graphVar.name); |
| 24329 | + } else if (arg.type) { |
| 24330 | + this.graph.connect(-1, arg.name, -1, graphVar.name); |
| 24331 | + } else { |
| 24332 | + this.graph.connect(arg.node, arg.port, -1, graphVar.name); |
| 24333 | + } |
24290 | 24334 | };
|
24291 | 24335 | shadergraph.connectCustom = function (destNodeIndex, destName, nodeIndex_or_param, name) {
|
24292 | 24336 | if (typeof(nodeIndex_or_param) === 'number') {
|
|
0 commit comments