@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.
Files changed (155) hide show
  1. package/package.json +10 -7
  2. package/cjs/engine.js +0 -218
  3. package/cjs/graph/base-node.js +0 -13
  4. package/cjs/graph/code-nodes.js +0 -23
  5. package/cjs/graph/context.js +0 -253
  6. package/cjs/graph/data-nodes.js +0 -146
  7. package/cjs/graph/edge.js +0 -12
  8. package/cjs/graph/evaluate.js +0 -32
  9. package/cjs/graph/graph-node.js +0 -143
  10. package/cjs/graph/graph-types.js +0 -25
  11. package/cjs/graph/graph.js +0 -533
  12. package/cjs/graph/graph.test.js +0 -173
  13. package/cjs/graph/index.js +0 -27
  14. package/cjs/graph/parsers.js +0 -219
  15. package/cjs/graph/shader-sections.js +0 -268
  16. package/cjs/index.js +0 -19
  17. package/cjs/package.json +0 -1
  18. package/cjs/plugins/babylon/bablyengine.js +0 -597
  19. package/cjs/plugins/babylon/importers.js +0 -66
  20. package/cjs/plugins/babylon/index.js +0 -5
  21. package/cjs/plugins/playcanvas/importers.js +0 -30
  22. package/cjs/plugins/playcanvas/index.js +0 -5
  23. package/cjs/plugins/playcanvas/playengine.js +0 -549
  24. package/cjs/plugins/three/importers.js +0 -17
  25. package/cjs/plugins/three/index.js +0 -6
  26. package/cjs/plugins/three/threngine.js +0 -619
  27. package/cjs/strategy/assignemntTo.js +0 -31
  28. package/cjs/strategy/declarationOf.js +0 -28
  29. package/cjs/strategy/hardCode.js +0 -28
  30. package/cjs/strategy/index.js +0 -25
  31. package/cjs/strategy/inject.js +0 -127
  32. package/cjs/strategy/namedAttribute.js +0 -53
  33. package/cjs/strategy/strategy.js +0 -35
  34. package/cjs/strategy/stratgies.test.js +0 -192
  35. package/cjs/strategy/texture2D.js +0 -88
  36. package/cjs/strategy/uniform.js +0 -195
  37. package/cjs/strategy/variable.js +0 -85
  38. package/cjs/util/ast.js +0 -351
  39. package/cjs/util/ensure.js +0 -11
  40. package/cjs/util/id.js +0 -6
  41. package/esm/engine.d.ts +0 -69
  42. package/esm/graph/base-node.d.ts +0 -36
  43. package/esm/graph/code-nodes.d.ts +0 -44
  44. package/esm/graph/context.d.ts +0 -37
  45. package/esm/graph/data-nodes.d.ts +0 -83
  46. package/esm/graph/edge.d.ts +0 -13
  47. package/esm/graph/evaluate.d.ts +0 -9
  48. package/esm/graph/graph-node.d.ts +0 -8
  49. package/esm/graph/graph-types.d.ts +0 -38
  50. package/esm/graph/graph.d.ts +0 -89
  51. package/esm/graph/graph.test.d.ts +0 -1
  52. package/esm/graph/index.d.ts +0 -11
  53. package/esm/graph/parsers.d.ts +0 -39
  54. package/esm/graph/shader-sections.d.ts +0 -47
  55. package/esm/index.d.ts +0 -3
  56. package/esm/package.json +0 -1
  57. package/esm/plugins/babylon/bablyengine.d.ts +0 -28
  58. package/esm/plugins/babylon/importers.d.ts +0 -3
  59. package/esm/plugins/babylon/index.d.ts +0 -2
  60. package/esm/plugins/playcanvas/importers.d.ts +0 -3
  61. package/esm/plugins/playcanvas/index.d.ts +0 -2
  62. package/esm/plugins/playcanvas/playengine.d.ts +0 -39
  63. package/esm/plugins/three/importers.d.ts +0 -3
  64. package/esm/plugins/three/index.d.ts +0 -2
  65. package/esm/plugins/three/threngine.d.ts +0 -34
  66. package/esm/strategy/assignemntTo.d.ts +0 -9
  67. package/esm/strategy/declarationOf.d.ts +0 -9
  68. package/esm/strategy/hardCode.d.ts +0 -15
  69. package/esm/strategy/index.d.ts +0 -9
  70. package/esm/strategy/inject.d.ts +0 -15
  71. package/esm/strategy/namedAttribute.d.ts +0 -9
  72. package/esm/strategy/strategy.d.ts +0 -28
  73. package/esm/strategy/stratgies.test.d.ts +0 -1
  74. package/esm/strategy/texture2D.d.ts +0 -6
  75. package/esm/strategy/uniform.d.ts +0 -6
  76. package/esm/strategy/variable.d.ts +0 -6
  77. package/esm/util/ast.d.ts +0 -30
  78. package/esm/util/ensure.d.ts +0 -1
  79. package/esm/util/id.d.ts +0 -1
  80. /package/{cjs/engine.d.ts → engine.d.ts} +0 -0
  81. /package/{esm/engine.js → engine.js} +0 -0
  82. /package/{cjs/graph → graph}/base-node.d.ts +0 -0
  83. /package/{esm/graph → graph}/base-node.js +0 -0
  84. /package/{cjs/graph → graph}/code-nodes.d.ts +0 -0
  85. /package/{esm/graph → graph}/code-nodes.js +0 -0
  86. /package/{cjs/graph → graph}/context.d.ts +0 -0
  87. /package/{esm/graph → graph}/context.js +0 -0
  88. /package/{cjs/graph → graph}/data-nodes.d.ts +0 -0
  89. /package/{esm/graph → graph}/data-nodes.js +0 -0
  90. /package/{cjs/graph → graph}/edge.d.ts +0 -0
  91. /package/{esm/graph → graph}/edge.js +0 -0
  92. /package/{cjs/graph → graph}/evaluate.d.ts +0 -0
  93. /package/{esm/graph → graph}/evaluate.js +0 -0
  94. /package/{cjs/graph → graph}/graph-node.d.ts +0 -0
  95. /package/{esm/graph → graph}/graph-node.js +0 -0
  96. /package/{cjs/graph → graph}/graph-types.d.ts +0 -0
  97. /package/{esm/graph → graph}/graph-types.js +0 -0
  98. /package/{cjs/graph → graph}/graph.d.ts +0 -0
  99. /package/{esm/graph → graph}/graph.js +0 -0
  100. /package/{cjs/graph → graph}/graph.test.d.ts +0 -0
  101. /package/{esm/graph → graph}/graph.test.js +0 -0
  102. /package/{cjs/graph → graph}/index.d.ts +0 -0
  103. /package/{esm/graph → graph}/index.js +0 -0
  104. /package/{cjs/graph → graph}/parsers.d.ts +0 -0
  105. /package/{esm/graph → graph}/parsers.js +0 -0
  106. /package/{cjs/graph → graph}/shader-sections.d.ts +0 -0
  107. /package/{esm/graph → graph}/shader-sections.js +0 -0
  108. /package/{cjs/index.d.ts → index.d.ts} +0 -0
  109. /package/{esm/index.js → index.js} +0 -0
  110. /package/{cjs/plugins → plugins}/babylon/bablyengine.d.ts +0 -0
  111. /package/{esm/plugins → plugins}/babylon/bablyengine.js +0 -0
  112. /package/{cjs/plugins → plugins}/babylon/importers.d.ts +0 -0
  113. /package/{esm/plugins → plugins}/babylon/importers.js +0 -0
  114. /package/{cjs/plugins → plugins}/babylon/index.d.ts +0 -0
  115. /package/{esm/plugins → plugins}/babylon/index.js +0 -0
  116. /package/{cjs/plugins → plugins}/playcanvas/importers.d.ts +0 -0
  117. /package/{esm/plugins → plugins}/playcanvas/importers.js +0 -0
  118. /package/{cjs/plugins → plugins}/playcanvas/index.d.ts +0 -0
  119. /package/{esm/plugins → plugins}/playcanvas/index.js +0 -0
  120. /package/{cjs/plugins → plugins}/playcanvas/playengine.d.ts +0 -0
  121. /package/{esm/plugins → plugins}/playcanvas/playengine.js +0 -0
  122. /package/{cjs/plugins → plugins}/three/importers.d.ts +0 -0
  123. /package/{esm/plugins → plugins}/three/importers.js +0 -0
  124. /package/{cjs/plugins → plugins}/three/index.d.ts +0 -0
  125. /package/{esm/plugins → plugins}/three/index.js +0 -0
  126. /package/{cjs/plugins → plugins}/three/threngine.d.ts +0 -0
  127. /package/{esm/plugins → plugins}/three/threngine.js +0 -0
  128. /package/{cjs/strategy → strategy}/assignemntTo.d.ts +0 -0
  129. /package/{esm/strategy → strategy}/assignemntTo.js +0 -0
  130. /package/{cjs/strategy → strategy}/declarationOf.d.ts +0 -0
  131. /package/{esm/strategy → strategy}/declarationOf.js +0 -0
  132. /package/{cjs/strategy → strategy}/hardCode.d.ts +0 -0
  133. /package/{esm/strategy → strategy}/hardCode.js +0 -0
  134. /package/{cjs/strategy → strategy}/index.d.ts +0 -0
  135. /package/{esm/strategy → strategy}/index.js +0 -0
  136. /package/{cjs/strategy → strategy}/inject.d.ts +0 -0
  137. /package/{esm/strategy → strategy}/inject.js +0 -0
  138. /package/{cjs/strategy → strategy}/namedAttribute.d.ts +0 -0
  139. /package/{esm/strategy → strategy}/namedAttribute.js +0 -0
  140. /package/{cjs/strategy → strategy}/strategy.d.ts +0 -0
  141. /package/{esm/strategy → strategy}/strategy.js +0 -0
  142. /package/{cjs/strategy → strategy}/stratgies.test.d.ts +0 -0
  143. /package/{esm/strategy → strategy}/stratgies.test.js +0 -0
  144. /package/{cjs/strategy → strategy}/texture2D.d.ts +0 -0
  145. /package/{esm/strategy → strategy}/texture2D.js +0 -0
  146. /package/{cjs/strategy → strategy}/uniform.d.ts +0 -0
  147. /package/{esm/strategy → strategy}/uniform.js +0 -0
  148. /package/{cjs/strategy → strategy}/variable.d.ts +0 -0
  149. /package/{esm/strategy → strategy}/variable.js +0 -0
  150. /package/{cjs/util → util}/ast.d.ts +0 -0
  151. /package/{esm/util → util}/ast.js +0 -0
  152. /package/{cjs/util → util}/ensure.d.ts +0 -0
  153. /package/{esm/util → util}/ensure.js +0 -0
  154. /package/{cjs/util → util}/id.d.ts +0 -0
  155. /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;
@@ -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;
@@ -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;
@@ -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';