diff --git a/examples/jsm/transpiler/TSLEncoder.js b/examples/jsm/transpiler/TSLEncoder.js index d88d431cf1d9f4..5e8701db658ea9 100644 --- a/examples/jsm/transpiler/TSLEncoder.js +++ b/examples/jsm/transpiler/TSLEncoder.js @@ -501,7 +501,9 @@ ${ this.tab }} )`; this.addImport( 'overloadingFn' ); - return `export const ${ name } = /*#__PURE__*/ overloadingFn( [ ${ nodes.map( node => node.name + '_' + nodes.indexOf( node ) ).join( ', ' ) } ] );\n`; + const prefix = this.iife === false ? 'export ' : ''; + + return `${ prefix }const ${ name } = /*#__PURE__*/ overloadingFn( [ ${ nodes.map( node => node.name + '_' + nodes.indexOf( node ) ).join( ', ' ) } ] );\n`; } @@ -582,7 +584,9 @@ ${ this.tab }} )`; } - let funcStr = `export const ${ fnName } = /*#__PURE__*/ tslFn( (${ paramsStr }) => { + const prefix = this.iife === false ? 'export ' : ''; + + let funcStr = `${ prefix }const ${ fnName } = /*#__PURE__*/ tslFn( (${ paramsStr }) => { ${ bodyStr } @@ -684,6 +688,7 @@ ${ this.tab }} )`; } const imports = [ ...this.imports ]; + const exports = [ ...this.global ]; let header = '// Three.js Transpiler r' + THREE.REVISION + '\n\n'; let footer = ''; @@ -693,12 +698,13 @@ ${ this.tab }} )`; header += '( function ( TSL, uniforms ) {\n\n'; header += imports.length > 0 ? '\tconst { ' + imports.join( ', ' ) + ' } = TSL;\n' : ''; + footer += exports.length > 0 ? '\treturn { ' + exports.join( ', ' ) + ' };\n' : ''; footer += '\n} );'; } else { - header += imports.length > 0 ? 'import { ' + imports.join( ', ' ) + ' } from \'three/nodes\';\n' : ''; + header += imports.length > 0 ? 'import { ' + imports.join( ', ' ) + ' } from \'three/tsl\';\n' : ''; } diff --git a/examples/webgpu_shadertoy.html b/examples/webgpu_shadertoy.html index 49f5f01e7c5079..ca970af1864b80 100644 --- a/examples/webgpu_shadertoy.html +++ b/examples/webgpu_shadertoy.html @@ -169,7 +169,7 @@