@shaderfrog/core 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -7
- package/cjs/engine.js +0 -218
- package/cjs/graph/base-node.js +0 -13
- package/cjs/graph/code-nodes.js +0 -23
- package/cjs/graph/context.js +0 -253
- package/cjs/graph/data-nodes.js +0 -146
- package/cjs/graph/edge.js +0 -12
- package/cjs/graph/evaluate.js +0 -32
- package/cjs/graph/graph-node.js +0 -143
- package/cjs/graph/graph-types.js +0 -25
- package/cjs/graph/graph.js +0 -533
- package/cjs/graph/graph.test.js +0 -173
- package/cjs/graph/index.js +0 -27
- package/cjs/graph/parsers.js +0 -219
- package/cjs/graph/shader-sections.js +0 -268
- package/cjs/index.js +0 -19
- package/cjs/package.json +0 -1
- package/cjs/plugins/babylon/bablyengine.js +0 -597
- package/cjs/plugins/babylon/importers.js +0 -66
- package/cjs/plugins/babylon/index.js +0 -5
- package/cjs/plugins/playcanvas/importers.js +0 -30
- package/cjs/plugins/playcanvas/index.js +0 -5
- package/cjs/plugins/playcanvas/playengine.js +0 -549
- package/cjs/plugins/three/importers.js +0 -17
- package/cjs/plugins/three/index.js +0 -6
- package/cjs/plugins/three/threngine.js +0 -619
- package/cjs/strategy/assignemntTo.js +0 -31
- package/cjs/strategy/declarationOf.js +0 -28
- package/cjs/strategy/hardCode.js +0 -28
- package/cjs/strategy/index.js +0 -25
- package/cjs/strategy/inject.js +0 -127
- package/cjs/strategy/namedAttribute.js +0 -53
- package/cjs/strategy/strategy.js +0 -35
- package/cjs/strategy/stratgies.test.js +0 -192
- package/cjs/strategy/texture2D.js +0 -88
- package/cjs/strategy/uniform.js +0 -195
- package/cjs/strategy/variable.js +0 -85
- package/cjs/util/ast.js +0 -351
- package/cjs/util/ensure.js +0 -11
- package/cjs/util/id.js +0 -6
- package/esm/engine.d.ts +0 -69
- package/esm/graph/base-node.d.ts +0 -36
- package/esm/graph/code-nodes.d.ts +0 -44
- package/esm/graph/context.d.ts +0 -37
- package/esm/graph/data-nodes.d.ts +0 -83
- package/esm/graph/edge.d.ts +0 -13
- package/esm/graph/evaluate.d.ts +0 -9
- package/esm/graph/graph-node.d.ts +0 -8
- package/esm/graph/graph-types.d.ts +0 -38
- package/esm/graph/graph.d.ts +0 -89
- package/esm/graph/graph.test.d.ts +0 -1
- package/esm/graph/index.d.ts +0 -11
- package/esm/graph/parsers.d.ts +0 -39
- package/esm/graph/shader-sections.d.ts +0 -47
- package/esm/index.d.ts +0 -3
- package/esm/package.json +0 -1
- package/esm/plugins/babylon/bablyengine.d.ts +0 -28
- package/esm/plugins/babylon/importers.d.ts +0 -3
- package/esm/plugins/babylon/index.d.ts +0 -2
- package/esm/plugins/playcanvas/importers.d.ts +0 -3
- package/esm/plugins/playcanvas/index.d.ts +0 -2
- package/esm/plugins/playcanvas/playengine.d.ts +0 -39
- package/esm/plugins/three/importers.d.ts +0 -3
- package/esm/plugins/three/index.d.ts +0 -2
- package/esm/plugins/three/threngine.d.ts +0 -34
- package/esm/strategy/assignemntTo.d.ts +0 -9
- package/esm/strategy/declarationOf.d.ts +0 -9
- package/esm/strategy/hardCode.d.ts +0 -15
- package/esm/strategy/index.d.ts +0 -9
- package/esm/strategy/inject.d.ts +0 -15
- package/esm/strategy/namedAttribute.d.ts +0 -9
- package/esm/strategy/strategy.d.ts +0 -28
- package/esm/strategy/stratgies.test.d.ts +0 -1
- package/esm/strategy/texture2D.d.ts +0 -6
- package/esm/strategy/uniform.d.ts +0 -6
- package/esm/strategy/variable.d.ts +0 -6
- package/esm/util/ast.d.ts +0 -30
- package/esm/util/ensure.d.ts +0 -1
- package/esm/util/id.d.ts +0 -1
- /package/{cjs/engine.d.ts → engine.d.ts} +0 -0
- /package/{esm/engine.js → engine.js} +0 -0
- /package/{cjs/graph → graph}/base-node.d.ts +0 -0
- /package/{esm/graph → graph}/base-node.js +0 -0
- /package/{cjs/graph → graph}/code-nodes.d.ts +0 -0
- /package/{esm/graph → graph}/code-nodes.js +0 -0
- /package/{cjs/graph → graph}/context.d.ts +0 -0
- /package/{esm/graph → graph}/context.js +0 -0
- /package/{cjs/graph → graph}/data-nodes.d.ts +0 -0
- /package/{esm/graph → graph}/data-nodes.js +0 -0
- /package/{cjs/graph → graph}/edge.d.ts +0 -0
- /package/{esm/graph → graph}/edge.js +0 -0
- /package/{cjs/graph → graph}/evaluate.d.ts +0 -0
- /package/{esm/graph → graph}/evaluate.js +0 -0
- /package/{cjs/graph → graph}/graph-node.d.ts +0 -0
- /package/{esm/graph → graph}/graph-node.js +0 -0
- /package/{cjs/graph → graph}/graph-types.d.ts +0 -0
- /package/{esm/graph → graph}/graph-types.js +0 -0
- /package/{cjs/graph → graph}/graph.d.ts +0 -0
- /package/{esm/graph → graph}/graph.js +0 -0
- /package/{cjs/graph → graph}/graph.test.d.ts +0 -0
- /package/{esm/graph → graph}/graph.test.js +0 -0
- /package/{cjs/graph → graph}/index.d.ts +0 -0
- /package/{esm/graph → graph}/index.js +0 -0
- /package/{cjs/graph → graph}/parsers.d.ts +0 -0
- /package/{esm/graph → graph}/parsers.js +0 -0
- /package/{cjs/graph → graph}/shader-sections.d.ts +0 -0
- /package/{esm/graph → graph}/shader-sections.js +0 -0
- /package/{cjs/index.d.ts → index.d.ts} +0 -0
- /package/{esm/index.js → index.js} +0 -0
- /package/{cjs/plugins → plugins}/babylon/bablyengine.d.ts +0 -0
- /package/{esm/plugins → plugins}/babylon/bablyengine.js +0 -0
- /package/{cjs/plugins → plugins}/babylon/importers.d.ts +0 -0
- /package/{esm/plugins → plugins}/babylon/importers.js +0 -0
- /package/{cjs/plugins → plugins}/babylon/index.d.ts +0 -0
- /package/{esm/plugins → plugins}/babylon/index.js +0 -0
- /package/{cjs/plugins → plugins}/playcanvas/importers.d.ts +0 -0
- /package/{esm/plugins → plugins}/playcanvas/importers.js +0 -0
- /package/{cjs/plugins → plugins}/playcanvas/index.d.ts +0 -0
- /package/{esm/plugins → plugins}/playcanvas/index.js +0 -0
- /package/{cjs/plugins → plugins}/playcanvas/playengine.d.ts +0 -0
- /package/{esm/plugins → plugins}/playcanvas/playengine.js +0 -0
- /package/{cjs/plugins → plugins}/three/importers.d.ts +0 -0
- /package/{esm/plugins → plugins}/three/importers.js +0 -0
- /package/{cjs/plugins → plugins}/three/index.d.ts +0 -0
- /package/{esm/plugins → plugins}/three/index.js +0 -0
- /package/{cjs/plugins → plugins}/three/threngine.d.ts +0 -0
- /package/{esm/plugins → plugins}/three/threngine.js +0 -0
- /package/{cjs/strategy → strategy}/assignemntTo.d.ts +0 -0
- /package/{esm/strategy → strategy}/assignemntTo.js +0 -0
- /package/{cjs/strategy → strategy}/declarationOf.d.ts +0 -0
- /package/{esm/strategy → strategy}/declarationOf.js +0 -0
- /package/{cjs/strategy → strategy}/hardCode.d.ts +0 -0
- /package/{esm/strategy → strategy}/hardCode.js +0 -0
- /package/{cjs/strategy → strategy}/index.d.ts +0 -0
- /package/{esm/strategy → strategy}/index.js +0 -0
- /package/{cjs/strategy → strategy}/inject.d.ts +0 -0
- /package/{esm/strategy → strategy}/inject.js +0 -0
- /package/{cjs/strategy → strategy}/namedAttribute.d.ts +0 -0
- /package/{esm/strategy → strategy}/namedAttribute.js +0 -0
- /package/{cjs/strategy → strategy}/strategy.d.ts +0 -0
- /package/{esm/strategy → strategy}/strategy.js +0 -0
- /package/{cjs/strategy → strategy}/stratgies.test.d.ts +0 -0
- /package/{esm/strategy → strategy}/stratgies.test.js +0 -0
- /package/{cjs/strategy → strategy}/texture2D.d.ts +0 -0
- /package/{esm/strategy → strategy}/texture2D.js +0 -0
- /package/{cjs/strategy → strategy}/uniform.d.ts +0 -0
- /package/{esm/strategy → strategy}/uniform.js +0 -0
- /package/{cjs/strategy → strategy}/variable.d.ts +0 -0
- /package/{esm/strategy → strategy}/variable.js +0 -0
- /package/{cjs/util → util}/ast.d.ts +0 -0
- /package/{esm/util → util}/ast.js +0 -0
- /package/{cjs/util → util}/ensure.d.ts +0 -0
- /package/{esm/util → util}/ensure.js +0 -0
- /package/{cjs/util → util}/id.d.ts +0 -0
- /package/{esm/util → util}/id.js +0 -0
package/cjs/graph/edge.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.linkFromVertToFrag = exports.makeEdge = void 0;
|
|
4
|
-
var graph_types_1 = require("./graph-types");
|
|
5
|
-
var makeEdge = function (id, from, to, output, input, type) { return ({ id: id, from: from, to: to, output: output, input: input, type: type }); };
|
|
6
|
-
exports.makeEdge = makeEdge;
|
|
7
|
-
var linkFromVertToFrag = function (id, vertId, fragId) {
|
|
8
|
-
return (0, exports.makeEdge)(id, vertId, fragId, graph_types_1.LinkHandle.NEXT_STAGE, // output from next_stage
|
|
9
|
-
graph_types_1.LinkHandle.PREVIOUS_STAGE, // input to previous_stage
|
|
10
|
-
graph_types_1.EdgeLink.NEXT_STAGE);
|
|
11
|
-
};
|
|
12
|
-
exports.linkFromVertToFrag = linkFromVertToFrag;
|
package/cjs/graph/evaluate.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.evaluateNode = exports.toGlsl = void 0;
|
|
4
|
-
var parsers_1 = require("./parsers");
|
|
5
|
-
var toGlsl = function (node) {
|
|
6
|
-
var type = node.type, value = node.value;
|
|
7
|
-
if (type === 'vector2') {
|
|
8
|
-
return "vec2(".concat(value[0], ", ").concat(value[1], ")");
|
|
9
|
-
}
|
|
10
|
-
if (type === 'vector3' || type === 'rgb') {
|
|
11
|
-
return "vec3(".concat(value[0], ", ").concat(value[1], ", ").concat(value[2], ")");
|
|
12
|
-
}
|
|
13
|
-
if (type === 'vector4' || type === 'rgba') {
|
|
14
|
-
return "vec4(".concat(value[0], ", ").concat(value[1], ", ").concat(value[2], ", ").concat(value[3], ")");
|
|
15
|
-
}
|
|
16
|
-
throw new Error("Unknown GLSL inline type: \"".concat(node.type, "\""));
|
|
17
|
-
};
|
|
18
|
-
exports.toGlsl = toGlsl;
|
|
19
|
-
var evaluateNode = function (engine, graph, node) {
|
|
20
|
-
// TODO: Data nodes themselves should have evaluators
|
|
21
|
-
if ('value' in node) {
|
|
22
|
-
return engine.evaluateNode(node);
|
|
23
|
-
}
|
|
24
|
-
var evaluate = parsers_1.coreParsers[node.type].evaluate;
|
|
25
|
-
if (!evaluate) {
|
|
26
|
-
throw new Error("No evaluator for node ".concat(node.name, " (type: ").concat(node.type, ", id: ").concat(node.id, ")"));
|
|
27
|
-
}
|
|
28
|
-
var inputEdges = graph.edges.filter(function (edge) { return edge.to === node.id; });
|
|
29
|
-
var inputNodes = inputEdges.map(function (edge) { return graph.nodes.find(function (node) { return node.id === edge.from; }); });
|
|
30
|
-
return evaluate(node, inputEdges, inputNodes, exports.evaluateNode.bind(null, engine, graph));
|
|
31
|
-
};
|
|
32
|
-
exports.evaluateNode = evaluateNode;
|
package/cjs/graph/graph-node.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.multiplyNode = exports.addNode = exports.expressionNode = exports.outputNode = exports.sourceNode = void 0;
|
|
4
|
-
var graph_types_1 = require("./graph-types");
|
|
5
|
-
var strategy_1 = require("../strategy");
|
|
6
|
-
var code_nodes_1 = require("./code-nodes");
|
|
7
|
-
var sourceNode = function (id, name, position, config, source, stage, originalEngine) { return ({
|
|
8
|
-
id: id,
|
|
9
|
-
name: name,
|
|
10
|
-
type: graph_types_1.NodeType.SOURCE,
|
|
11
|
-
sourceType: code_nodes_1.SourceType.SHADER_PROGRAM,
|
|
12
|
-
engine: false,
|
|
13
|
-
config: config,
|
|
14
|
-
position: position,
|
|
15
|
-
inputs: [],
|
|
16
|
-
outputs: [
|
|
17
|
-
{
|
|
18
|
-
name: 'vector4',
|
|
19
|
-
dataType: 'vector4',
|
|
20
|
-
category: 'data',
|
|
21
|
-
id: '1',
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
source: source,
|
|
25
|
-
stage: stage,
|
|
26
|
-
originalEngine: originalEngine,
|
|
27
|
-
}); };
|
|
28
|
-
exports.sourceNode = sourceNode;
|
|
29
|
-
var outputNode = function (id, name, position, stage) { return ({
|
|
30
|
-
id: id,
|
|
31
|
-
name: name,
|
|
32
|
-
position: position,
|
|
33
|
-
type: graph_types_1.NodeType.OUTPUT,
|
|
34
|
-
sourceType: code_nodes_1.SourceType.SHADER_PROGRAM,
|
|
35
|
-
engine: false,
|
|
36
|
-
config: {
|
|
37
|
-
version: 3,
|
|
38
|
-
mangle: false,
|
|
39
|
-
preprocess: false,
|
|
40
|
-
uniforms: [],
|
|
41
|
-
inputMapping: stage === 'fragment'
|
|
42
|
-
? {
|
|
43
|
-
filler_frogFragOut: 'Color',
|
|
44
|
-
}
|
|
45
|
-
: {
|
|
46
|
-
filler_gl_Position: 'Position',
|
|
47
|
-
},
|
|
48
|
-
strategies: [
|
|
49
|
-
(0, strategy_1.assignemntToStrategy)(stage === 'fragment' ? 'frogFragOut' : 'gl_Position'),
|
|
50
|
-
],
|
|
51
|
-
},
|
|
52
|
-
inputs: [],
|
|
53
|
-
outputs: [],
|
|
54
|
-
// Consumed by findVec4Constructo4
|
|
55
|
-
source: stage === 'fragment'
|
|
56
|
-
? "\n#version 300 es\nprecision highp float;\n\nout vec4 frogFragOut;\nvoid main() {\n frogFragOut = vec4(1.0);\n}\n"
|
|
57
|
-
: // gl_Position isn't "out"-able apparently https://stackoverflow.com/a/24425436/743464
|
|
58
|
-
"\n#version 300 es\nprecision highp float;\n\nvoid main() {\n gl_Position = vec4(1.0);\n}\n",
|
|
59
|
-
stage: stage,
|
|
60
|
-
}); };
|
|
61
|
-
exports.outputNode = outputNode;
|
|
62
|
-
var expressionNode = function (id, name, position, source) { return ({
|
|
63
|
-
id: id,
|
|
64
|
-
name: name,
|
|
65
|
-
position: position,
|
|
66
|
-
type: graph_types_1.NodeType.SOURCE,
|
|
67
|
-
engine: false,
|
|
68
|
-
sourceType: code_nodes_1.SourceType.EXPRESSION,
|
|
69
|
-
stage: undefined,
|
|
70
|
-
config: {
|
|
71
|
-
uniforms: [],
|
|
72
|
-
version: 3,
|
|
73
|
-
preprocess: false,
|
|
74
|
-
inputMapping: {},
|
|
75
|
-
strategies: [(0, strategy_1.variableStrategy)()],
|
|
76
|
-
},
|
|
77
|
-
inputs: [],
|
|
78
|
-
outputs: [
|
|
79
|
-
{
|
|
80
|
-
name: 'expression',
|
|
81
|
-
category: 'data',
|
|
82
|
-
id: '1',
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
source: source,
|
|
86
|
-
}); };
|
|
87
|
-
exports.expressionNode = expressionNode;
|
|
88
|
-
var addNode = function (id, position) { return ({
|
|
89
|
-
id: id,
|
|
90
|
-
name: 'add',
|
|
91
|
-
position: position,
|
|
92
|
-
type: graph_types_1.NodeType.BINARY,
|
|
93
|
-
engine: false,
|
|
94
|
-
stage: undefined,
|
|
95
|
-
config: {
|
|
96
|
-
mangle: false,
|
|
97
|
-
version: 3,
|
|
98
|
-
preprocess: true,
|
|
99
|
-
strategies: [],
|
|
100
|
-
uniforms: [],
|
|
101
|
-
},
|
|
102
|
-
inputs: [],
|
|
103
|
-
outputs: [
|
|
104
|
-
{
|
|
105
|
-
name: 'sum',
|
|
106
|
-
category: 'data',
|
|
107
|
-
id: '1',
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
source: "a + b",
|
|
111
|
-
operator: '+',
|
|
112
|
-
sourceType: code_nodes_1.SourceType.EXPRESSION,
|
|
113
|
-
biStage: true,
|
|
114
|
-
}); };
|
|
115
|
-
exports.addNode = addNode;
|
|
116
|
-
var multiplyNode = function (id, position) { return ({
|
|
117
|
-
id: id,
|
|
118
|
-
name: 'multiply',
|
|
119
|
-
type: graph_types_1.NodeType.BINARY,
|
|
120
|
-
engine: false,
|
|
121
|
-
stage: undefined,
|
|
122
|
-
position: position,
|
|
123
|
-
config: {
|
|
124
|
-
version: 3,
|
|
125
|
-
uniforms: [],
|
|
126
|
-
mangle: false,
|
|
127
|
-
preprocess: true,
|
|
128
|
-
strategies: [],
|
|
129
|
-
},
|
|
130
|
-
inputs: [],
|
|
131
|
-
outputs: [
|
|
132
|
-
{
|
|
133
|
-
name: 'product',
|
|
134
|
-
category: 'data',
|
|
135
|
-
id: '1',
|
|
136
|
-
},
|
|
137
|
-
],
|
|
138
|
-
source: "a * b",
|
|
139
|
-
operator: '*',
|
|
140
|
-
sourceType: code_nodes_1.SourceType.EXPRESSION,
|
|
141
|
-
biStage: true,
|
|
142
|
-
}); };
|
|
143
|
-
exports.multiplyNode = multiplyNode;
|
package/cjs/graph/graph-types.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MAGIC_OUTPUT_STMTS = exports.NodeType = exports.LinkHandle = exports.EdgeLink = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* The type applied to the edge representing a link between node stages
|
|
6
|
-
*/
|
|
7
|
-
var EdgeLink;
|
|
8
|
-
(function (EdgeLink) {
|
|
9
|
-
EdgeLink["NEXT_STAGE"] = "next_stage";
|
|
10
|
-
})(EdgeLink = exports.EdgeLink || (exports.EdgeLink = {}));
|
|
11
|
-
/**
|
|
12
|
-
* The handle types for links. These become <Handle /> ids
|
|
13
|
-
*/
|
|
14
|
-
var LinkHandle;
|
|
15
|
-
(function (LinkHandle) {
|
|
16
|
-
LinkHandle["NEXT_STAGE"] = "next_stage";
|
|
17
|
-
LinkHandle["PREVIOUS_STAGE"] = "previous_stage";
|
|
18
|
-
})(LinkHandle = exports.LinkHandle || (exports.LinkHandle = {}));
|
|
19
|
-
var NodeType;
|
|
20
|
-
(function (NodeType) {
|
|
21
|
-
NodeType["OUTPUT"] = "output";
|
|
22
|
-
NodeType["BINARY"] = "binary";
|
|
23
|
-
NodeType["SOURCE"] = "source";
|
|
24
|
-
})(NodeType = exports.NodeType || (exports.NodeType = {}));
|
|
25
|
-
exports.MAGIC_OUTPUT_STMTS = 'mainStmts';
|