• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1export default (() => {
2    const initialize = () => {
3        return new Promise(resolve => {
4            Module({
5                locateFile() {
6                    const i = import.meta.url.lastIndexOf('/')
7                    return import.meta.url.substring(0, i) + '/glslang.wasm';
8                },
9                onRuntimeInitialized() {
10                    resolve({
11                        compileGLSLZeroCopy: this.compileGLSLZeroCopy,
12                        compileGLSL: this.compileGLSL,
13                    });
14                },
15            });
16        });
17    };
18
19    let instance;
20    return () => {
21        if (!instance) {
22            instance = initialize();
23        }
24        return instance;
25    };
26})();
27