@holoscript/core 6.0.4 → 7.0.0

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 (236) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -1
  3. package/dist/compiler/index.d.ts +82 -0
  4. package/dist/constants.d.ts +3 -2
  5. package/dist/coordinators/index.d.ts +189 -0
  6. package/dist/index.d.ts +501 -19
  7. package/dist/paper-0c-spike/index.d.ts +29 -0
  8. package/dist/reconstruction/index.d.ts +78 -0
  9. package/dist/tools/index.d.ts +22 -1
  10. package/dist/traitDocs/traitDocs.d.ts +69 -0
  11. package/dist/traits/index.d.ts +61 -0
  12. package/package.json +105 -57
  13. package/dist/GLTFPipeline-DEN36VNK.js +0 -12
  14. package/dist/GLTFPipeline-YPCAK236.cjs +0 -33
  15. package/dist/HoloScriptPlusParser-BN6KVRCM.js +0 -692
  16. package/dist/HoloScriptPlusParser-NC5FE6AL.cjs +0 -697
  17. package/dist/USDZExporter-NTMBNTDB.js +0 -707
  18. package/dist/USDZExporter-UWGWNMMD.cjs +0 -709
  19. package/dist/chunk-27LWW5FU.cjs +0 -410
  20. package/dist/chunk-2CWOLHTE.js +0 -69
  21. package/dist/chunk-33LSUQDD.cjs +0 -835
  22. package/dist/chunk-3FJCK5XA.js +0 -2232
  23. package/dist/chunk-3FXV5S25.cjs +0 -633
  24. package/dist/chunk-3FYZOR7S.cjs +0 -69
  25. package/dist/chunk-3SAK5KFL.cjs +0 -83
  26. package/dist/chunk-4XSNJCLC.cjs +0 -1859
  27. package/dist/chunk-54FHG2MX.js +0 -655
  28. package/dist/chunk-56IF4NTA.js +0 -56
  29. package/dist/chunk-5BGSECRJ.cjs +0 -2237
  30. package/dist/chunk-5GLCTO44.js +0 -161
  31. package/dist/chunk-5O6TQC6M.cjs +0 -1871
  32. package/dist/chunk-5OEOHAAW.cjs +0 -682
  33. package/dist/chunk-5TOFIR6L.js +0 -407
  34. package/dist/chunk-5WUNN6ZN.cjs +0 -428
  35. package/dist/chunk-6TZPZCOJ.cjs +0 -1404
  36. package/dist/chunk-6UEHYZ7V.cjs +0 -773
  37. package/dist/chunk-6XSERL6L.js +0 -5678
  38. package/dist/chunk-72EQECGT.cjs +0 -908
  39. package/dist/chunk-7AGYRWKW.cjs +0 -507
  40. package/dist/chunk-7LCYLPW2.cjs +0 -663
  41. package/dist/chunk-A7PIMZGU.js +0 -263
  42. package/dist/chunk-ATSKSYVE.cjs +0 -51683
  43. package/dist/chunk-B5TCIAPQ.cjs +0 -117
  44. package/dist/chunk-BF2235SI.cjs +0 -5714
  45. package/dist/chunk-BKIGPPVM.js +0 -629
  46. package/dist/chunk-BND3ST2K.cjs +0 -662
  47. package/dist/chunk-BU7VWW2K.js +0 -2522
  48. package/dist/chunk-BWFJEM5A.js +0 -5419
  49. package/dist/chunk-CAUCGUEA.cjs +0 -130
  50. package/dist/chunk-CBJSLA2E.cjs +0 -5423
  51. package/dist/chunk-CDPGV4DN.js +0 -114
  52. package/dist/chunk-CLYEIWA5.cjs +0 -408
  53. package/dist/chunk-CS2EMTGF.js +0 -1966
  54. package/dist/chunk-DMG7C4H2.js +0 -975
  55. package/dist/chunk-DXJQDCFL.js +0 -468
  56. package/dist/chunk-E3FWRT3Z.js +0 -608
  57. package/dist/chunk-E3UALNFA.js +0 -421
  58. package/dist/chunk-EONILVMF.js +0 -762
  59. package/dist/chunk-EQV4R3EV.cjs +0 -769
  60. package/dist/chunk-F3HH56EB.cjs +0 -5538
  61. package/dist/chunk-F4IULT7N.js +0 -1488
  62. package/dist/chunk-FF3Q7ADR.js +0 -380
  63. package/dist/chunk-FFKU7BTK.cjs +0 -1046
  64. package/dist/chunk-FHQVYCH2.js +0 -70
  65. package/dist/chunk-FSF7EQVA.cjs +0 -1974
  66. package/dist/chunk-G4VZTCIB.js +0 -659
  67. package/dist/chunk-G7CT3EMP.cjs +0 -1002
  68. package/dist/chunk-GGHSW2NN.js +0 -51334
  69. package/dist/chunk-GVUR45UF.cjs +0 -777
  70. package/dist/chunk-H5Z7NASB.js +0 -9662
  71. package/dist/chunk-HE7ULERA.cjs +0 -697
  72. package/dist/chunk-HJJLD366.js +0 -1169
  73. package/dist/chunk-HPS76H7Q.js +0 -309
  74. package/dist/chunk-HQUEA5R6.cjs +0 -424
  75. package/dist/chunk-HYNTS5CP.js +0 -422
  76. package/dist/chunk-I6XZ5DZF.cjs +0 -488
  77. package/dist/chunk-IBDG74G2.cjs +0 -1219
  78. package/dist/chunk-IFNQFCTM.js +0 -3098
  79. package/dist/chunk-IHOUYQIA.js +0 -406
  80. package/dist/chunk-ILRBGFVD.cjs +0 -72
  81. package/dist/chunk-IWI6J7FX.js +0 -421
  82. package/dist/chunk-K3JDKWGI.cjs +0 -270
  83. package/dist/chunk-K6EKD26I.js +0 -630
  84. package/dist/chunk-KCQ5NDYC.cjs +0 -3172
  85. package/dist/chunk-KED34ILP.js +0 -832
  86. package/dist/chunk-KSGXLT74.cjs +0 -457
  87. package/dist/chunk-L4G4RLXX.js +0 -767
  88. package/dist/chunk-LDP5OK6G.js +0 -1216
  89. package/dist/chunk-LGGRPKTV.cjs +0 -735
  90. package/dist/chunk-LK5IAVH6.cjs +0 -1173
  91. package/dist/chunk-LSW7P7ML.js +0 -3675
  92. package/dist/chunk-LXJ4667L.cjs +0 -3874
  93. package/dist/chunk-LZ266PCM.cjs +0 -4499
  94. package/dist/chunk-MD6KDHVE.cjs +0 -237
  95. package/dist/chunk-MEASWI2Y.js +0 -126
  96. package/dist/chunk-MPXBVFHQ.js +0 -768
  97. package/dist/chunk-N5FTS757.cjs +0 -415
  98. package/dist/chunk-NCUKG4SK.cjs +0 -3075
  99. package/dist/chunk-NDQNIJEH.js +0 -1715
  100. package/dist/chunk-NOZZ46QU.js +0 -168
  101. package/dist/chunk-OFKWH2IP.js +0 -449
  102. package/dist/chunk-PHENW4MQ.js +0 -65
  103. package/dist/chunk-PMGODDJA.cjs +0 -319
  104. package/dist/chunk-Q4QX3AET.cjs +0 -1505
  105. package/dist/chunk-Q56TT7IL.js +0 -483
  106. package/dist/chunk-Q5JT3YML.cjs +0 -129
  107. package/dist/chunk-Q5SJOGHQ.cjs +0 -4256
  108. package/dist/chunk-QGKNANZ3.js +0 -3071
  109. package/dist/chunk-QLEAOI3Q.cjs +0 -424
  110. package/dist/chunk-R7MA7QWV.js +0 -732
  111. package/dist/chunk-RVYPEYPX.js +0 -678
  112. package/dist/chunk-S2N5TNMA.js +0 -1855
  113. package/dist/chunk-S565K7NK.js +0 -752
  114. package/dist/chunk-SDAMZIRE.js +0 -765
  115. package/dist/chunk-T36DDXSF.js +0 -4250
  116. package/dist/chunk-T4NKMBDL.js +0 -5474
  117. package/dist/chunk-T7LEXZUZ.cjs +0 -2526
  118. package/dist/chunk-TEWCN33Y.js +0 -694
  119. package/dist/chunk-TQSZUOW5.cjs +0 -793
  120. package/dist/chunk-TSH3MSQU.cjs +0 -129
  121. package/dist/chunk-UERJ3YJV.js +0 -504
  122. package/dist/chunk-UPJBDCVF.js +0 -1395
  123. package/dist/chunk-V3NN3HPP.js +0 -4462
  124. package/dist/chunk-VJ3L7CHT.cjs +0 -169
  125. package/dist/chunk-WB4Z63GG.js +0 -229
  126. package/dist/chunk-WDW67DZB.cjs +0 -9728
  127. package/dist/chunk-WGMEAYBG.js +0 -126
  128. package/dist/chunk-X4ZF6CNE.cjs +0 -473
  129. package/dist/chunk-X6SEAXAX.cjs +0 -3681
  130. package/dist/chunk-XCWFGZAA.js +0 -1043
  131. package/dist/chunk-XD6IYDUX.js +0 -903
  132. package/dist/chunk-XG23EUQX.cjs +0 -1717
  133. package/dist/chunk-XRKWN5PL.cjs +0 -173
  134. package/dist/chunk-XUILI4KB.cjs +0 -430
  135. package/dist/chunk-XUTX5CBW.js +0 -126
  136. package/dist/chunk-XWPNTWDN.cjs +0 -755
  137. package/dist/chunk-XXINBTZK.cjs +0 -633
  138. package/dist/chunk-YCXFCXDS.js +0 -1868
  139. package/dist/chunk-YQK5JNFK.js +0 -3725
  140. package/dist/chunk-YYXH45E2.js +0 -426
  141. package/dist/chunk-Z34RLXRA.cjs +0 -612
  142. package/dist/chunk-ZP4D3CSX.cjs +0 -72
  143. package/dist/cli/holoscript-runner.cjs +0 -2259
  144. package/dist/cli/holoscript-runner.js +0 -2234
  145. package/dist/codebase/index.cjs +0 -336
  146. package/dist/codebase/index.js +0 -331
  147. package/dist/compiler/agent-inference.cjs +0 -28
  148. package/dist/compiler/agent-inference.js +0 -5
  149. package/dist/compiler/android-xr.cjs +0 -19
  150. package/dist/compiler/android-xr.js +0 -9
  151. package/dist/compiler/android.cjs +0 -20
  152. package/dist/compiler/android.js +0 -10
  153. package/dist/compiler/ar.cjs +0 -20
  154. package/dist/compiler/ar.js +0 -8
  155. package/dist/compiler/babylon.cjs +0 -17
  156. package/dist/compiler/babylon.js +0 -11
  157. package/dist/compiler/coco.cjs +0 -27
  158. package/dist/compiler/coco.js +0 -4
  159. package/dist/compiler/domain-block-utils.cjs +0 -602
  160. package/dist/compiler/domain-block-utils.js +0 -8
  161. package/dist/compiler/dtdl.cjs +0 -24
  162. package/dist/compiler/dtdl.js +0 -8
  163. package/dist/compiler/gltf-pipeline.cjs +0 -39
  164. package/dist/compiler/gltf-pipeline.js +0 -4
  165. package/dist/compiler/godot.cjs +0 -15
  166. package/dist/compiler/godot.js +0 -9
  167. package/dist/compiler/incremental.cjs +0 -29
  168. package/dist/compiler/incremental.js +0 -4
  169. package/dist/compiler/index.cjs +0 -2578
  170. package/dist/compiler/index.js +0 -2383
  171. package/dist/compiler/ios.cjs +0 -20
  172. package/dist/compiler/ios.js +0 -10
  173. package/dist/compiler/multi-layer.cjs +0 -20
  174. package/dist/compiler/multi-layer.js +0 -11
  175. package/dist/compiler/nodetoy.cjs +0 -23
  176. package/dist/compiler/nodetoy.js +0 -4
  177. package/dist/compiler/openxr.cjs +0 -15
  178. package/dist/compiler/openxr.js +0 -9
  179. package/dist/compiler/playcanvas.cjs +0 -16
  180. package/dist/compiler/playcanvas.js +0 -10
  181. package/dist/compiler/r3f.cjs +0 -34
  182. package/dist/compiler/r3f.js +0 -12
  183. package/dist/compiler/remotion.cjs +0 -23
  184. package/dist/compiler/remotion.js +0 -4
  185. package/dist/compiler/reproducibility.cjs +0 -39
  186. package/dist/compiler/reproducibility.js +0 -4
  187. package/dist/compiler/sdf.cjs +0 -21
  188. package/dist/compiler/sdf.js +0 -9
  189. package/dist/compiler/semantic-scene.cjs +0 -31
  190. package/dist/compiler/semantic-scene.js +0 -4
  191. package/dist/compiler/state.cjs +0 -17
  192. package/dist/compiler/state.js +0 -7
  193. package/dist/compiler/trait-composition.cjs +0 -26
  194. package/dist/compiler/trait-composition.js +0 -5
  195. package/dist/compiler/unity.cjs +0 -15
  196. package/dist/compiler/unity.js +0 -9
  197. package/dist/compiler/unreal.cjs +0 -19
  198. package/dist/compiler/unreal.js +0 -9
  199. package/dist/compiler/urdf.cjs +0 -45
  200. package/dist/compiler/urdf.js +0 -9
  201. package/dist/compiler/usd-physics.cjs +0 -23
  202. package/dist/compiler/usd-physics.js +0 -6
  203. package/dist/compiler/visionos.cjs +0 -15
  204. package/dist/compiler/visionos.js +0 -9
  205. package/dist/compiler/vrchat.cjs +0 -19
  206. package/dist/compiler/vrchat.js +0 -9
  207. package/dist/compiler/vrr.cjs +0 -21
  208. package/dist/compiler/vrr.js +0 -9
  209. package/dist/compiler/wasm.cjs +0 -33
  210. package/dist/compiler/wasm.js +0 -9
  211. package/dist/compiler/webgpu.cjs +0 -15
  212. package/dist/compiler/webgpu.js +0 -9
  213. package/dist/debugger.cjs +0 -21
  214. package/dist/debugger.js +0 -8
  215. package/dist/entries/interop.cjs +0 -62
  216. package/dist/entries/interop.js +0 -5
  217. package/dist/entries/scripting.cjs +0 -68
  218. package/dist/entries/scripting.js +0 -11
  219. package/dist/index.cjs +0 -40921
  220. package/dist/index.js +0 -37763
  221. package/dist/math/vec3.cjs +0 -57
  222. package/dist/math/vec3.js +0 -4
  223. package/dist/ml-dsa-PHCWUBPX.cjs +0 -1178
  224. package/dist/ml-dsa-WYLJHJO6.js +0 -1178
  225. package/dist/parser.cjs +0 -27
  226. package/dist/parser.js +0 -10
  227. package/dist/playwright-5OSAPTNH.js +0 -98660
  228. package/dist/playwright-RL6GY4F7.cjs +0 -98673
  229. package/dist/runtime.cjs +0 -16
  230. package/dist/runtime.js +0 -7
  231. package/dist/storage/index.cjs +0 -37
  232. package/dist/storage/index.js +0 -4
  233. package/dist/traits/index.cjs +0 -14649
  234. package/dist/traits/index.js +0 -12243
  235. package/dist/type-checker.cjs +0 -18
  236. package/dist/type-checker.js +0 -5
@@ -1,410 +0,0 @@
1
- 'use strict';
2
-
3
- // src/compiler/NodeToyMapping.ts
4
- var NODE_TYPE_MAP = {
5
- // Math operations
6
- Add: { expression: "({in:a} + {in:b})", outputType: "float" },
7
- Subtract: { expression: "({in:a} - {in:b})", outputType: "float" },
8
- Multiply: { expression: "({in:a} * {in:b})", outputType: "float" },
9
- Divide: { expression: "({in:a} / max({in:b}, 0.0001))", outputType: "float" },
10
- Power: { expression: "pow({in:a}, {in:b})", outputType: "float" },
11
- Sqrt: { expression: "sqrt({in:a})", outputType: "float" },
12
- Abs: { expression: "abs({in:a})", outputType: "float" },
13
- Sign: { expression: "sign({in:a})", outputType: "float" },
14
- Floor: { expression: "floor({in:a})", outputType: "float" },
15
- Ceil: { expression: "ceil({in:a})", outputType: "float" },
16
- Fract: { expression: "fract({in:a})", outputType: "float" },
17
- Mod: { expression: "mod({in:a}, {in:b})", outputType: "float" },
18
- Min: { expression: "min({in:a}, {in:b})", outputType: "float" },
19
- Max: { expression: "max({in:a}, {in:b})", outputType: "float" },
20
- Clamp: { expression: "clamp({in:a}, {in:min}, {in:max})", outputType: "float" },
21
- Lerp: { expression: "mix({in:a}, {in:b}, {in:t})", outputType: "float" },
22
- Smoothstep: { expression: "smoothstep({in:edge0}, {in:edge1}, {in:x})", outputType: "float" },
23
- Step: { expression: "step({in:edge}, {in:x})", outputType: "float" },
24
- OneMinus: { expression: "(1.0 - {in:a})", outputType: "float" },
25
- Negate: { expression: "(-{in:a})", outputType: "float" },
26
- Length: { expression: "length({in:a})", outputType: "float" },
27
- Distance: { expression: "distance({in:a}, {in:b})", outputType: "float" },
28
- Dot: { expression: "dot({in:a}, {in:b})", outputType: "float" },
29
- Cross: { expression: "cross({in:a}, {in:b})", outputType: "vec3" },
30
- Normalize: { expression: "normalize({in:a})", outputType: "vec3" },
31
- Reflect: { expression: "reflect({in:a}, {in:b})", outputType: "vec3" },
32
- // Trigonometry
33
- Sin: { expression: "sin({in:a})", outputType: "float" },
34
- Cos: { expression: "cos({in:a})", outputType: "float" },
35
- Tan: { expression: "tan({in:a})", outputType: "float" },
36
- Asin: { expression: "asin({in:a})", outputType: "float" },
37
- Acos: { expression: "acos({in:a})", outputType: "float" },
38
- Atan: { expression: "atan({in:a})", outputType: "float" },
39
- Atan2: { expression: "atan({in:y}, {in:x})", outputType: "float" },
40
- // Color operations
41
- Mix: { expression: "mix({in:a}, {in:b}, {in:factor})", outputType: "vec3" },
42
- Saturate: { expression: "clamp({in:a}, 0.0, 1.0)", outputType: "float" },
43
- // Constructors
44
- Vec2: { expression: "vec2({in:x}, {in:y})", outputType: "vec2" },
45
- Vec3: { expression: "vec3({in:x}, {in:y}, {in:z})", outputType: "vec3" },
46
- Vec4: { expression: "vec4({in:x}, {in:y}, {in:z}, {in:w})", outputType: "vec4" },
47
- // Component extraction
48
- SplitVec2: { expression: "{in:a}", outputType: "float" },
49
- SplitVec3: { expression: "{in:a}", outputType: "float" },
50
- SplitVec4: { expression: "{in:a}", outputType: "float" },
51
- // Texture sampling
52
- Texture2D: { expression: "texture2D({in:sampler}, {in:uv})", outputType: "vec4" },
53
- CubeMap: { expression: "textureCube({in:sampler}, {in:dir})", outputType: "vec4" },
54
- // Noise
55
- ProceduralNoise: { expression: "snoise({in:uv} * {in:scale})", outputType: "float" }
56
- };
57
- var BUILTIN_INPUT_NODES = /* @__PURE__ */ new Set([
58
- "Time",
59
- "Resolution",
60
- "ScreenUV",
61
- "UV",
62
- "Normal",
63
- "Position",
64
- "ViewDirection",
65
- "FragCoord",
66
- "Constant",
67
- "Parameter"
68
- ]);
69
- var OUTPUT_NODES = /* @__PURE__ */ new Set(["FragColor", "Output", "Emission", "Alpha", "Discard"]);
70
- function mapNodeToyToShader(graph, options = {}) {
71
- const mapper = new NodeToyMapper(options);
72
- return mapper.map(graph);
73
- }
74
- var NodeToyMapper = class {
75
- constructor(options = {}) {
76
- this.warnings = [];
77
- this.unsupportedNodes = [];
78
- this.uniforms = {};
79
- this.varyingDecls = [];
80
- this.fragmentLines = [];
81
- this.nodeOutputVars = /* @__PURE__ */ new Map();
82
- this.nodeMap = /* @__PURE__ */ new Map();
83
- this.edgesByTarget = /* @__PURE__ */ new Map();
84
- this.visitedNodes = /* @__PURE__ */ new Set();
85
- this.language = options.language ?? "glsl";
86
- this.autoTimeUniform = options.autoTimeUniform ?? true;
87
- this.autoResolutionUniform = options.autoResolutionUniform ?? true;
88
- this.variablePrefix = options.variablePrefix ?? "nt_";
89
- this.optimization = options.optimization ?? "basic";
90
- }
91
- map(graph) {
92
- this.warnings = [];
93
- this.unsupportedNodes = [];
94
- this.uniforms = {};
95
- this.varyingDecls = [];
96
- this.fragmentLines = [];
97
- this.nodeOutputVars.clear();
98
- this.nodeMap.clear();
99
- this.edgesByTarget.clear();
100
- this.visitedNodes.clear();
101
- for (const node of graph.nodes) {
102
- this.nodeMap.set(node.id, node);
103
- }
104
- for (const edge of graph.edges) {
105
- const key = `${edge.toNode}:${edge.toPort}`;
106
- if (!this.edgesByTarget.has(key)) {
107
- this.edgesByTarget.set(key, []);
108
- }
109
- this.edgesByTarget.get(key).push(edge);
110
- }
111
- const outputNodes = graph.nodes.filter((n) => OUTPUT_NODES.has(n.type));
112
- if (outputNodes.length === 0) {
113
- this.warnings.push("No output node found in graph; generating passthrough shader");
114
- }
115
- for (const outputNode of outputNodes) {
116
- this.traverseNode(outputNode.id);
117
- }
118
- const hasTimeNode = graph.nodes.some((n) => n.type === "Time");
119
- const hasResolutionNode = graph.nodes.some((n) => n.type === "Resolution");
120
- if (this.autoTimeUniform && hasTimeNode) {
121
- this.uniforms["time"] = { type: "float", value: 0 };
122
- }
123
- if (this.autoResolutionUniform && hasResolutionNode) {
124
- this.uniforms["resolution"] = { type: "vec2", value: [1920, 1080] };
125
- }
126
- for (const node of graph.nodes) {
127
- if (node.type === "Parameter" || node.type === "Constant") {
128
- this.extractParameterUniform(node);
129
- }
130
- }
131
- const vertexSource = this.generateVertexSource();
132
- const fragmentSource = this.generateFragmentSource(outputNodes);
133
- const shaderConfig = {
134
- name: graph.name || "nodetoy_shader",
135
- source: {
136
- language: this.language,
137
- vertex: vertexSource,
138
- fragment: fragmentSource
139
- },
140
- uniforms: this.uniforms,
141
- blendMode: graph.settings?.blendMode ?? "opaque",
142
- depthTest: graph.settings?.depthTest ?? true,
143
- depthWrite: graph.settings?.depthWrite ?? true,
144
- cullFace: graph.settings?.doubleSided ? "none" : "back"
145
- };
146
- return {
147
- shaderConfig,
148
- vertexSource,
149
- fragmentSource,
150
- uniforms: this.uniforms,
151
- warnings: this.warnings,
152
- unsupportedNodes: this.unsupportedNodes
153
- };
154
- }
155
- // ---------------------------------------------------------------------------
156
- // Graph traversal (reverse topological from output nodes)
157
- // ---------------------------------------------------------------------------
158
- traverseNode(nodeId) {
159
- if (this.nodeOutputVars.has(nodeId)) {
160
- return this.nodeOutputVars.get(nodeId);
161
- }
162
- if (this.visitedNodes.has(nodeId)) {
163
- this.warnings.push(`Cycle detected at node ${nodeId}; breaking with default value`);
164
- return "0.0";
165
- }
166
- this.visitedNodes.add(nodeId);
167
- const node = this.nodeMap.get(nodeId);
168
- if (!node) {
169
- this.warnings.push(`Missing node: ${nodeId}`);
170
- return "0.0";
171
- }
172
- if (BUILTIN_INPUT_NODES.has(node.type)) {
173
- const varExpr = this.resolveBuiltinNode(node);
174
- this.nodeOutputVars.set(nodeId, varExpr);
175
- return varExpr;
176
- }
177
- if (OUTPUT_NODES.has(node.type)) {
178
- for (const input of node.inputs) {
179
- const inputExpr = this.resolveInputPort(nodeId, input.name, input);
180
- if (node.type === "FragColor" || node.type === "Output") {
181
- this.fragmentLines.push(` // Output: ${node.label || node.type}`);
182
- if (input.type === "vec4") {
183
- this.fragmentLines.push(` gl_FragColor = ${inputExpr};`);
184
- } else if (input.type === "vec3") {
185
- this.fragmentLines.push(` gl_FragColor = vec4(${inputExpr}, 1.0);`);
186
- } else {
187
- this.fragmentLines.push(` gl_FragColor = vec4(vec3(${inputExpr}), 1.0);`);
188
- }
189
- }
190
- }
191
- const varName2 = `${this.variablePrefix}out_${this.sanitize(nodeId)}`;
192
- this.nodeOutputVars.set(nodeId, varName2);
193
- return varName2;
194
- }
195
- const codegen = NODE_TYPE_MAP[node.type];
196
- if (!codegen) {
197
- this.unsupportedNodes.push(node.type);
198
- this.warnings.push(`Unsupported node type: ${node.type}; using default value`);
199
- this.nodeOutputVars.set(nodeId, "0.0");
200
- return "0.0";
201
- }
202
- const resolvedInputs = {};
203
- for (const input of node.inputs) {
204
- resolvedInputs[input.name] = this.resolveInputPort(nodeId, input.name, input);
205
- }
206
- let expression = codegen.expression;
207
- for (const [portName, portExpr] of Object.entries(resolvedInputs)) {
208
- expression = expression.replace(`{in:${portName}}`, portExpr);
209
- }
210
- expression = expression.replace(/\{in:\w+\}/g, "0.0");
211
- const varName = `${this.variablePrefix}${this.sanitize(nodeId)}`;
212
- const glslType = this.uniformTypeToGLSL(codegen.outputType);
213
- this.fragmentLines.push(` ${glslType} ${varName} = ${expression};`);
214
- this.nodeOutputVars.set(nodeId, varName);
215
- return varName;
216
- }
217
- resolveInputPort(nodeId, portName, port) {
218
- const edgeKey = `${nodeId}:${portName}`;
219
- const edges = this.edgesByTarget.get(edgeKey);
220
- if (edges && edges.length > 0) {
221
- const edge = edges[0];
222
- return this.traverseNode(edge.fromNode);
223
- }
224
- if (port.default !== void 0) {
225
- if (typeof port.default === "number") return String(port.default);
226
- if (Array.isArray(port.default)) {
227
- const len = port.default.length;
228
- if (len === 2) return `vec2(${port.default.join(", ")})`;
229
- if (len === 3) return `vec3(${port.default.join(", ")})`;
230
- if (len === 4) return `vec4(${port.default.join(", ")})`;
231
- return String(port.default[0] ?? 0);
232
- }
233
- }
234
- return "0.0";
235
- }
236
- resolveBuiltinNode(node) {
237
- switch (node.type) {
238
- case "Time":
239
- return "time";
240
- case "Resolution":
241
- return "resolution";
242
- case "UV":
243
- case "ScreenUV":
244
- this.ensureVarying("vUv", "vec2");
245
- return "vUv";
246
- case "Normal":
247
- this.ensureVarying("vNormal", "vec3");
248
- return "vNormal";
249
- case "Position":
250
- this.ensureVarying("vPosition", "vec3");
251
- return "vPosition";
252
- case "ViewDirection":
253
- this.ensureVarying("vViewDir", "vec3");
254
- return "vViewDir";
255
- case "FragCoord":
256
- return "gl_FragCoord.xy";
257
- case "Constant": {
258
- const val = node.params?.["value"];
259
- if (typeof val === "number") return String(val);
260
- if (Array.isArray(val)) {
261
- if (val.length === 2) return `vec2(${val.join(", ")})`;
262
- if (val.length === 3) return `vec3(${val.join(", ")})`;
263
- if (val.length === 4) return `vec4(${val.join(", ")})`;
264
- }
265
- return "0.0";
266
- }
267
- case "Parameter": {
268
- const name = node.params?.["name"] || `param_${node.id}`;
269
- return name;
270
- }
271
- default:
272
- return "0.0";
273
- }
274
- }
275
- // ---------------------------------------------------------------------------
276
- // Uniform and varying management
277
- // ---------------------------------------------------------------------------
278
- extractParameterUniform(node) {
279
- const name = node.params?.["name"] || `param_${node.id}`;
280
- const value = node.params?.["value"];
281
- const uniformType = this.inferUniformType(value);
282
- if (!this.uniforms[name]) {
283
- this.uniforms[name] = {
284
- type: uniformType,
285
- value: typeof value === "number" || Array.isArray(value) ? value : 0,
286
- min: node.params?.["min"],
287
- max: node.params?.["max"],
288
- label: node.label
289
- };
290
- }
291
- }
292
- inferUniformType(value) {
293
- if (typeof value === "number") return "float";
294
- if (typeof value === "boolean") return "bool";
295
- if (Array.isArray(value)) {
296
- if (value.length === 2) return "vec2";
297
- if (value.length === 3) return "vec3";
298
- if (value.length === 4) return "vec4";
299
- if (value.length === 9) return "mat3";
300
- if (value.length === 16) return "mat4";
301
- }
302
- return "float";
303
- }
304
- ensureVarying(name, type) {
305
- const decl = `varying ${type} ${name};`;
306
- if (!this.varyingDecls.includes(decl)) {
307
- this.varyingDecls.push(decl);
308
- }
309
- }
310
- // ---------------------------------------------------------------------------
311
- // Source generation
312
- // ---------------------------------------------------------------------------
313
- generateVertexSource() {
314
- const lines = [];
315
- for (const decl of this.varyingDecls) {
316
- lines.push(decl);
317
- }
318
- lines.push("");
319
- lines.push("void main() {");
320
- if (this.varyingDecls.some((d) => d.includes("vUv"))) {
321
- lines.push(" vUv = uv;");
322
- }
323
- if (this.varyingDecls.some((d) => d.includes("vNormal"))) {
324
- lines.push(" vNormal = normalize(normalMatrix * normal);");
325
- }
326
- if (this.varyingDecls.some((d) => d.includes("vPosition"))) {
327
- lines.push(" vPosition = position;");
328
- }
329
- if (this.varyingDecls.some((d) => d.includes("vViewDir"))) {
330
- lines.push(" vec4 mvPos = modelViewMatrix * vec4(position, 1.0);");
331
- lines.push(" vViewDir = normalize(-mvPos.xyz);");
332
- }
333
- lines.push(" gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);");
334
- lines.push("}");
335
- return lines.join("\n");
336
- }
337
- generateFragmentSource(outputNodes) {
338
- const lines = [];
339
- lines.push("precision highp float;");
340
- lines.push("");
341
- for (const [name, uniform] of Object.entries(this.uniforms)) {
342
- lines.push(`uniform ${this.uniformTypeToGLSL(uniform.type)} ${name};`);
343
- }
344
- lines.push("");
345
- for (const decl of this.varyingDecls) {
346
- lines.push(decl);
347
- }
348
- lines.push("");
349
- if (this.nodeMap.size > 0) {
350
- const hasNoise = Array.from(this.nodeMap.values()).some((n) => n.type === "ProceduralNoise");
351
- if (hasNoise) {
352
- lines.push(SIMPLEX_NOISE_2D);
353
- lines.push("");
354
- }
355
- }
356
- lines.push("void main() {");
357
- for (const line of this.fragmentLines) {
358
- lines.push(line);
359
- }
360
- if (!this.fragmentLines.some((l) => l.includes("gl_FragColor"))) {
361
- lines.push(" gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0); // No output node");
362
- }
363
- lines.push("}");
364
- return lines.join("\n");
365
- }
366
- // ---------------------------------------------------------------------------
367
- // Helpers
368
- // ---------------------------------------------------------------------------
369
- uniformTypeToGLSL(type) {
370
- return type;
371
- }
372
- sanitize(id) {
373
- return id.replace(/[^a-zA-Z0-9]/g, "_");
374
- }
375
- };
376
- var SIMPLEX_NOISE_2D = `
377
- // Simplex 2D noise for ProceduralNoise nodes
378
- vec3 mod289_n(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
379
- vec2 mod289_n(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
380
- vec3 permute_n(vec3 x) { return mod289_n(((x*34.0)+1.0)*x); }
381
-
382
- float snoise(vec2 v) {
383
- const vec4 C = vec4(0.211324865405187, 0.366025403784439,
384
- -0.577350269189626, 0.024390243902439);
385
- vec2 i = floor(v + dot(v, C.yy));
386
- vec2 x0 = v - i + dot(i, C.xx);
387
- vec2 i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
388
- vec4 x12 = x0.xyxy + C.xxzz;
389
- x12.xy -= i1;
390
- i = mod289_n(i);
391
- vec3 p = permute_n(permute_n(i.y + vec3(0.0, i1.y, 1.0)) + i.x + vec3(0.0, i1.x, 1.0));
392
- vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);
393
- m = m*m; m = m*m;
394
- vec3 x = 2.0 * fract(p * C.www) - 1.0;
395
- vec3 h = abs(x) - 0.5;
396
- vec3 ox = floor(x + 0.5);
397
- vec3 a0 = x - ox;
398
- m *= 1.79284291400159 - 0.85373472095314 * (a0*a0 + h*h);
399
- vec3 g;
400
- g.x = a0.x * x0.x + h.x * x0.y;
401
- g.yz = a0.yz * x12.xz + h.yz * x12.yw;
402
- return 130.0 * dot(m, g);
403
- }`.trim();
404
- var NodeToyMapping_default = mapNodeToyToShader;
405
-
406
- exports.NodeToyMapper = NodeToyMapper;
407
- exports.NodeToyMapping_default = NodeToyMapping_default;
408
- exports.mapNodeToyToShader = mapNodeToyToShader;
409
- //# sourceMappingURL=chunk-27LWW5FU.cjs.map
410
- //# sourceMappingURL=chunk-27LWW5FU.cjs.map
@@ -1,69 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __typeError = (msg) => {
8
- throw TypeError(msg);
9
- };
10
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
12
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
13
- }) : x)(function(x) {
14
- if (typeof require !== "undefined") return require.apply(this, arguments);
15
- throw Error('Dynamic require of "' + x + '" is not supported');
16
- });
17
- var __esm = (fn, res) => function __init() {
18
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
19
- };
20
- var __commonJS = (cb, mod) => function __require2() {
21
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
22
- };
23
- var __export = (target, all) => {
24
- for (var name in all)
25
- __defProp(target, name, { get: all[name], enumerable: true });
26
- };
27
- var __copyProps = (to, from, except, desc) => {
28
- if (from && typeof from === "object" || typeof from === "function") {
29
- for (let key of __getOwnPropNames(from))
30
- if (!__hasOwnProp.call(to, key) && key !== except)
31
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
- }
33
- return to;
34
- };
35
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
36
- // If the importer is in node compatibility mode or this is not an ESM
37
- // file that has been converted to a CommonJS file using a Babel-
38
- // compatible transform (i.e. "__esModule" has not been set), then set
39
- // "default" to the CommonJS "module.exports" for node compatibility.
40
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
41
- mod
42
- ));
43
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
44
- var __decorateClass = (decorators, target, key, kind) => {
45
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
46
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
47
- if (decorator = decorators[i])
48
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
49
- if (kind && result) __defProp(target, key, result);
50
- return result;
51
- };
52
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
53
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
54
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
55
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
56
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
57
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
58
- var __privateWrapper = (obj, member, setter, getter) => ({
59
- set _(value) {
60
- __privateSet(obj, member, value, setter);
61
- },
62
- get _() {
63
- return __privateGet(obj, member, getter);
64
- }
65
- });
66
-
67
- export { __commonJS, __decorateClass, __esm, __export, __privateAdd, __privateGet, __privateMethod, __privateSet, __privateWrapper, __publicField, __require, __toCommonJS, __toESM };
68
- //# sourceMappingURL=chunk-2CWOLHTE.js.map
69
- //# sourceMappingURL=chunk-2CWOLHTE.js.map