Comments (13)
You can alter the script.js to listen to mousemove on the overlay layer instead of the canvas
from webgl-fluid-simulation.
I had the same question and someone helped me. You can check out his work.
https://codepen.io/Sempervivum/pen/bGYPXJg
from webgl-fluid-simulation.
I had the same question and someone helped me. You can check out his work.
Thanks I'll try to leverage this. Very much appreciated.
from webgl-fluid-simulation.
Thanks for the replies! I managed to get the particles to animate below the page elements using the JavaScript and min .js file @networkmrt provided. However, I'm not able to get the event listener to work with the original version of the fluid GL JS file. How do I tweak the code so it works with the original script.js file? I can't modify the webgl-fluid.umd.min.js because its minified.
This works:
<script src="https://unpkg.com/[email protected]/dist/webgl-fluid.umd.min.js">
</script>
window['webgl-fluid'].default(document.querySelector('canvas'));
document.querySelector('#wrap').addEventListener('mousemove', event => {
console.log('move');
newEvent = new event.constructor(event.type, event);
document.querySelector('canvas').dispatchEvent(newEvent);
});`
This does not work:
<script src="myurl/files/fluid/script.js"></script>
window['script'].default(document.querySelector('canvas'));
document.querySelector('#wrap').addEventListener('mousemove', event => {
console.log('move');
newEvent = new event.constructor(event.type, event);
document.querySelector('canvas').dispatchEvent(newEvent);
});
What am I doing wrong? :S
from webgl-fluid-simulation.
Have you discovered what was your problem?
from webgl-fluid-simulation.
from webgl-fluid-simulation.
So I spent yesterday playing with the code trying to achieve this, and I think I achieved it :
1st thing : listen to window instead of canvas :
window.addEventListener(mousemove
, function)
"2nd thing : change the event property from offsetX and offsetY to clientX and clientY
Next you will have to apply some changes to the function ### updatePointerMoveData :
- change the canvas.width and height in these two lines :
pointer.texcoordX = posX / canvas.width;
pointer.texcoordY = 1.0 - posY / canvas.height;
it should be something like this :
pointer.texcoordX = posX / (canvas.width/2);
pointer.texcoordY = 1 - posY / (canvas.height/2);
This worked for me because i am setting the canvas size to 100vw and 100vh
these were all the changes i made and it worked fine for me
from webgl-fluid-simulation.
from webgl-fluid-simulation.
This animation not working on mobile, how to solve this issue? any reference please send me urgent
from webgl-fluid-simulation.
from webgl-fluid-simulation.
This animation not working on mobile, how to solve this issue? any reference please send me urgent. Anyone please help me out
from webgl-fluid-simulation.
Related Issues (20)
- General Question: App Store App
- Test conjugate gradient for pressure solve HOT 1
- Suggestion: Finish Steam version HOT 1
- Wordpress integration! HOT 1
- Initially Invisible and Mouse Event
- HELP HOT 2
- NextJS Usage HOT 2
- only single blue color on hover in javascript
- Does this simulation implement the boundary conditions described in GPUGems? HOT 1
- Issue with transparent background HOT 2
- High CPU Usage HOT 2
- how we can change the shades color HOT 2
- How to add an obstacle? HOT 2
- i have no experience at all, i just want to change the splat colours to a single one. any help please?
- Stdin write fail: Cannot access a disposed object. Object name: 'System.Diagnostics.Process'. HOT 1
- 我可以把它放入我的网站吗?如果可以,我应该怎样做? HOT 4
- Doesnt work on Samsung Galaxy S23 ultra HOT 5
- Mistake in gradientSubtractShader, should be mutiplied by 0.5
- omnidirectional burst HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webgl-fluid-simulation.