MCPcopy Create free account
hub / github.com/TheOrcDev/github-creature / Advection

Class Advection

components/liquid-ether.tsx:632–687  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

630 }
631
632 class Advection extends ShaderPass {
633 line!: THREE.LineSegments;
634 constructor(simProps: any) {
635 super({
636 material: {
637 vertexShader: face_vert,
638 fragmentShader: advection_frag,
639 uniforms: {
640 boundarySpace: { value: simProps.cellScale },
641 px: { value: simProps.cellScale },
642 fboSize: { value: simProps.fboSize },
643 velocity: { value: simProps.src.texture },
644 dt: { value: simProps.dt },
645 isBFECC: { value: true },
646 },
647 },
648 output: simProps.dst,
649 });
650 this.uniforms = this.props.material.uniforms;
651 this.init();
652 }
653 init() {
654 super.init();
655 this.createBoundary();
656 }
657 createBoundary() {
658 const boundaryG = new THREE.BufferGeometry();
659 const vertices_boundary = new Float32Array([
660 -1, -1, 0, -1, 1, 0, -1, 1, 0, 1, 1, 0, 1, 1, 0, 1, -1, 0, 1, -1, 0,
661 -1, -1, 0,
662 ]);
663 boundaryG.setAttribute(
664 "position",
665 new THREE.BufferAttribute(vertices_boundary, 3)
666 );
667 const boundaryM = new THREE.RawShaderMaterial({
668 vertexShader: line_vert,
669 fragmentShader: advection_frag,
670 uniforms: this.uniforms!,
671 });
672 this.line = new THREE.LineSegments(boundaryG, boundaryM);
673 this.scene!.add(this.line);
674 }
675 update(...args: any[]) {
676 const { dt, isBounce, BFECC } = (args[0] || {}) as {
677 dt?: number;
678 isBounce?: boolean;
679 BFECC?: boolean;
680 };
681 if (!this.uniforms) return;
682 if (typeof dt === "number") this.uniforms.dt.value = dt;
683 if (typeof isBounce === "boolean") this.line.visible = isBounce;
684 if (typeof BFECC === "boolean") this.uniforms.isBFECC.value = BFECC;
685 super.update();
686 }
687 }
688
689 class ExternalForce extends ShaderPass {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected