Download node_modules/three/examples/jsm/transpiler/ShaderToyDecoder.js from SimWorld-AI/industrial-harbor-viewer: direct link, hf CLI and curl.
- Browser
- Download file 1.02 kB
-
https://huggingface.co/spaces/SimWorld-AI/industrial-harbor-viewer/resolve/main/node_modules/three/examples/jsm/transpiler/ShaderToyDecoder.js
- Command line
-
hf download hf://spaces/SimWorld-AI/industrial-harbor-viewer/node_modules/three/examples/jsm/transpiler/ShaderToyDecoder.js
-
curl -L -o ShaderToyDecoder.js https://huggingface.co/spaces/SimWorld-AI/industrial-harbor-viewer/resolve/main/node_modules/three/examples/jsm/transpiler/ShaderToyDecoder.js
1.02 kB
| import { Return, VariableDeclaration, Accessor } from './AST.js'; | |
| import GLSLDecoder from './GLSLDecoder.js'; | |
| class ShaderToyDecoder extends GLSLDecoder { | |
| constructor() { | |
| super(); | |
| this.addPolyfill( 'iTime', 'float iTime = timerGlobal();' ); | |
| this.addPolyfill( 'iResolution', 'vec2 iResolution = viewportResolution;' ); | |
| this.addPolyfill( 'fragCoord', 'vec2 fragCoord = vec2( viewportCoordinate.x, viewportResolution.y - viewportCoordinate.y );' ); | |
| } | |
| parseFunction() { | |
| const node = super.parseFunction(); | |
| if ( node.name === 'mainImage' ) { | |
| node.params = []; // remove default parameters | |
| node.type = 'vec4'; | |
| node.layout = false; // for now | |
| const fragColor = new Accessor( 'fragColor' ); | |
| for ( const subNode of node.body ) { | |
| if ( subNode.isReturn ) { | |
| subNode.value = fragColor; | |
| } | |
| } | |
| node.body.unshift( new VariableDeclaration( 'vec4', 'fragColor' ) ); | |
| node.body.push( new Return( fragColor ) ); | |
| } | |
| return node; | |
| } | |
| } | |
| export default ShaderToyDecoder; |