UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

17 lines (16 loc) 516 B
"use strict"; import { ShaderChunk } from "three"; export function expandShader(shaderString) { function parseIncludes(string) { const pattern = /^[ \t]*#include +<([\w\d./]+)>/gm; function replace(match, include) { const replace2 = ShaderChunk[include]; if (replace2 === void 0) { throw new Error("Can not resolve #include <" + include + ">"); } return parseIncludes(replace2); } return string.replace(pattern, replace); } return parseIncludes(shaderString); }