WebGL-Fluid-Simulation icon indicating copy to clipboard operation
WebGL-Fluid-Simulation copied to clipboard

Start animation on mouse move?

Open zahmundzornig opened this issue 6 years ago • 4 comments

Thank you for this great animation! Absolutely amazing! I like to use this for our website background.

https://www.zahmundzornig.de/zuz

I change some issue for our needs. Her is one thing I can´t solve on desktop view: Actually the animation starts with a mouse click (mousedown). But I like to start the animation one mousemove. The animation should be start directly after loading only with mouse moving. Any ideas? Thank you!

zahmundzornig avatar Aug 26 '19 15:08 zahmundzornig

this line, move it to the bottom of a function and change it to pointer.moved = Math.abs(pointer.deltaX) > 0 || Math.abs(pointer.deltaY) > 0;

PavelDoGreat avatar Aug 27 '19 09:08 PavelDoGreat

There is also can be a problem when deltaX and deltaY can be very high on first frame mouse move which can destroy simulation.

PavelDoGreat avatar Aug 27 '19 09:08 PavelDoGreat

Thank you, that works! I aware of the high deltaXY. Most of the time it works fine. Sometimes it destroys the simulation. But thats ok for now.

zahmundzornig avatar Aug 27 '19 10:08 zahmundzornig

Simulation will crash if mouse is moving in the begining. Which can be solved by delaying the mousemove event listener. It's worth making it configurable:

import WebglFuild from 'webgl-fluid'

WebglFuild(document.querySelector('canvas'), {
  TRIGGER: 'hover', // Can be change to 'click'
})

cloydlau avatar Nov 14 '20 12:11 cloydlau