| 693 | this.init(simProps); |
| 694 | } |
| 695 | init(simProps: any) { |
| 696 | super.init(); |
| 697 | const mouseG = new THREE.PlaneGeometry(1, 1); |
| 698 | const mouseM = new THREE.RawShaderMaterial({ |
| 699 | vertexShader: mouse_vert, |
| 700 | fragmentShader: externalForce_frag, |
| 701 | blending: THREE.AdditiveBlending, |
| 702 | depthWrite: false, |
| 703 | uniforms: { |
| 704 | px: { value: simProps.cellScale }, |
| 705 | force: { value: new THREE.Vector2(0, 0) }, |
| 706 | center: { value: new THREE.Vector2(0, 0) }, |
| 707 | scale: { |
| 708 | value: new THREE.Vector2( |
| 709 | simProps.cursor_size, |
| 710 | simProps.cursor_size |
| 711 | ), |
| 712 | }, |
| 713 | }, |
| 714 | }); |
| 715 | this.mouse = new THREE.Mesh(mouseG, mouseM); |
| 716 | this.scene!.add(this.mouse); |
| 717 | } |
| 718 | update(...args: any[]) { |
| 719 | const props = args[0] || {}; |
| 720 | const forceX = (Mouse.diff.x / 2) * (props.mouse_force || 0); |