Skip to content

Add automatic random splats on timer.#22

Open
DavidHaitch wants to merge 2 commits into
PavelDoGreat:masterfrom
DavidHaitch:master
Open

Add automatic random splats on timer.#22
DavidHaitch wants to merge 2 commits into
PavelDoGreat:masterfrom
DavidHaitch:master

Conversation

@DavidHaitch

Copy link
Copy Markdown

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
Copy Markdown
Author

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

@konnermacias

Copy link
Copy Markdown

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

Comment thread script.js
setTimeout(autosplat, config.AUTOSPLAT_DELAY*1000);
}

setTimeout(autosplat, config.AUTOSPLAT_DELAY*1000);

Copy link
Copy Markdown

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
Copy Markdown
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.

Copy link
Copy Markdown

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
Copy Markdown

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

MiracleCK commented Apr 16, 2024 via email

Copy link
Copy Markdown

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.

6 participants