import { ShaderMaterial , UniformsUtils , Shader } from 'three' ; type Uniforms = { [ uniform ] : any ; } ; param { ShaderMaterial } shader function getUniforms ( shader ) { const uniforms = { } ; for ( const uniform in shader . uniforms ) { uniforms [ uniform ] = shader . uniforms [ uniform ] . value ; } return uniforms ; } param { ShaderMaterial } shader param { Uniforms } uniforms function updateUniforms ( shader , uniforms = { } ) { for ( const uniform in uniforms ) { if ( shader . uniforms [ uniform ] === undefined ) { throw new Error ( `Uniform "${ uniform }" does not exist on shader "${ shader . name }"` ) ; } shader . uniforms [ uniform ] . value = uniforms [ uniform ] ; } } param { ShaderMaterial } shader function clearUniforms ( shader ) { shader . uniforms = UniformsUtils . clone ( shader . uniforms ) ; } param { Shader } shader param { Uniforms } uniforms function createShaderMaterial ( shader , uniforms = { } ) { const material = new ShaderMaterial ( { uniforms : UniformsUtils . clone ( shader . uniforms ) , vertexShader : shader . vertexShader , fragmentShader : shader . fragmentShader , } ) ; updateUniforms ( material , uniforms ) ; return material ; } const ShaderUtils = { getUniforms , updateUniforms , clearUniforms , createShaderMaterial , } ; export { Uniforms , ShaderUtils , } ; export default ShaderUtils ;