| 815 | } |
| 816 | |
| 817 | class Poisson extends ShaderPass { |
| 818 | constructor(simProps: any) { |
| 819 | super({ |
| 820 | material: { |
| 821 | vertexShader: face_vert, |
| 822 | fragmentShader: poisson_frag, |
| 823 | uniforms: { |
| 824 | boundarySpace: { value: simProps.boundarySpace }, |
| 825 | pressure: { value: simProps.dst_.texture }, |
| 826 | divergence: { value: simProps.src.texture }, |
| 827 | px: { value: simProps.cellScale }, |
| 828 | }, |
| 829 | }, |
| 830 | output: simProps.dst, |
| 831 | output0: simProps.dst_, |
| 832 | output1: simProps.dst, |
| 833 | }); |
| 834 | this.init(); |
| 835 | } |
| 836 | update(...args: any[]) { |
| 837 | const { iterations } = (args[0] || {}) as { iterations?: number }; |
| 838 | let p_in: any, p_out: any; |
| 839 | const iter = iterations ?? 0; |
| 840 | for (let i = 0; i < iter; i++) { |
| 841 | if (i % 2 === 0) { |
| 842 | p_in = this.props.output0; |
| 843 | p_out = this.props.output1; |
| 844 | } else { |
| 845 | p_in = this.props.output1; |
| 846 | p_out = this.props.output0; |
| 847 | } |
| 848 | if (this.uniforms) this.uniforms.pressure.value = p_in.texture; |
| 849 | this.props.output = p_out; |
| 850 | super.update(); |
| 851 | } |
| 852 | return p_out; |
| 853 | } |
| 854 | } |
| 855 | |
| 856 | class Pressure extends ShaderPass { |
| 857 | constructor(simProps: any) { |
nothing calls this directly
no outgoing calls
no test coverage detected