| 762 | this.init(); |
| 763 | } |
| 764 | update(...args: any[]) { |
| 765 | const { viscous, iterations, dt } = (args[0] || {}) as { |
| 766 | viscous?: number; |
| 767 | iterations?: number; |
| 768 | dt?: number; |
| 769 | }; |
| 770 | if (!this.uniforms) return; |
| 771 | let fbo_in: any, fbo_out: any; |
| 772 | if (typeof viscous === "number") this.uniforms.v.value = viscous; |
| 773 | const iter = iterations ?? 0; |
| 774 | for (let i = 0; i < iter; i++) { |
| 775 | if (i % 2 === 0) { |
| 776 | fbo_in = this.props.output0; |
| 777 | fbo_out = this.props.output1; |
| 778 | } else { |
| 779 | fbo_in = this.props.output1; |
| 780 | fbo_out = this.props.output0; |
| 781 | } |
| 782 | this.uniforms.velocity_new.value = fbo_in.texture; |
| 783 | this.props.output = fbo_out; |
| 784 | if (typeof dt === "number") this.uniforms.dt.value = dt; |
| 785 | super.update(); |
| 786 | } |
| 787 | return fbo_out; |
| 788 | } |
| 789 | } |
| 790 | |
| 791 | class Divergence extends ShaderPass { |