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