Files
nothoughts/node_modules/pixi.js/lib/rendering/high-shader/compiler/utils/compileInputs.js
2025-08-04 18:57:35 +02:00

33 lines
865 B
JavaScript

'use strict';
"use strict";
function extractInputs(fragmentSource, out) {
let match;
const regex = /@in\s+([^;]+);/g;
while ((match = regex.exec(fragmentSource)) !== null) {
out.push(match[1]);
}
}
function compileInputs(fragments, template, sort = false) {
const results = [];
extractInputs(template, results);
fragments.forEach((fragment) => {
if (fragment.header) {
extractInputs(fragment.header, results);
}
});
const mainInput = results;
if (sort) {
mainInput.sort();
}
const finalString = mainInput.map((inValue, i) => ` @location(${i}) ${inValue},`).join("\n");
let cleanedString = template.replace(/@in\s+[^;]+;\s*/g, "");
cleanedString = cleanedString.replace("{{in}}", `
${finalString}
`);
return cleanedString;
}
exports.compileInputs = compileInputs;
//# sourceMappingURL=compileInputs.js.map