Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automatic random splats on timer. #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DavidHaitch
Copy link

I wanted to use this sim as a more passive visualization for a party. To support this, I've added an "auto-splat" mode that adds random splats on a configurable interval.

@DavidHaitch
Copy link
Author

(Tip: for best results, let the autosplats develop slowly over time, with low density and velocity diffusions.)

@konnermacias
Copy link

This looks great! I'm going to try to incorporate these random autosplats with spotify song tempo

setTimeout(autosplat, config.AUTOSPLAT_DELAY*1000);
}

setTimeout(autosplat, config.AUTOSPLAT_DELAY*1000);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, but won't this recursion trigger a stack overflow over time?
If that's the case, how about using a setInterval instead?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a few hours of runtime, I didn't observe any significant slowdown or memory increase. You may be right that this could happen, but I wanted to use a repeated setTimeout to enable the user to change the splat interval after start.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This particular kind of stack-buildup is only an issue if you have asynchronous stack traces enabled (and by extension the debugger open), which can be disabled in chrome:
image

@cloydlau
Copy link

Thanks, merged your code into webgl-fluid@0.3.8:

npm i webgl-fluid
WebGLFluid(document.querySelector('canvas'), {
  AUTO: true, // Whether to enable auto-splating
  INTERVAL: 3000, // The time (in milliseconds) the timer should delay in between auto-splating
  SPLAT_COUNT: Number.parseInt(Math.random() * 20) + 5, // Set the splats' count
})

@MiracleCK
Copy link

MiracleCK commented Apr 16, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants