Share your repls and programming experiences

← Back to all posts
Fluid Simulator - Google's Liquidfun
mwilki7 (806)

I searched everywhere for sample javascript code for this (based on Box2D which is a C++ library) and finally found something functional.

The only things I added were html controls for the objects.

Most of it is based off of https://github.com/doebi/liquidfun.js-demo/tree/master

If you want faster framerate, shrink your window.

Hotkeys:

• B : Create physics box
• W : Create blob of fluid
• Left mouse: Create Blob of Fluid
• Right mouse: Create frozen box
• Middle mouse: Create physics box
Commentshotnewtop
AdCharity (944)

ngl I'm pretty sure if you tried hard enough you could conceivably make something similar without basing it on something.

mwilki7 (806)

@AdCharity rotational physics 2 scary 4 me

AdCharity (944)

@mwilki7 physics 2 scary 4 me even though I'm taking it next year

mwilki7 (806)

@SixBeeps
pls not partial derivatives
ಥ_ಥ

SixBeeps (1083)

@mwilki7 oh is that what that is? i thought euler just smashed his keyboard and called it physics lol

MatthewDoan1 (257)

@SixBeeps You mean his typewriter?

AdCharity (944)

@MatthewDoan1 For euler it was probably sticks and rocks

MatthewDoan1 (257)

My friends: So what do you do in your free time?
Me: It's complicated...

xBlaziken (13)

I don't recommend jitter click spawning in the water or else the repl will crash. Also i get 45cps so it might just be me lol

RobertFurr (41)

9.8/10 could use more features

PDanielY (634)

Whats middle click

mwilki7 (806)

@PDanielY spawns physics box, by physics i mean it moves

mwilki7 (806)

@kindred ive been seeing that happen to me sometimes if i leave it running for too long

sugarfi (158)

I don't see anything when I run this. In the console, I get errors from PixiJS about not being able to initialize a shader.

mwilki7 (806)

@sugarfi
what specs do you have?

sugarfi (158)

@mwilki7 amd a6, ubntu 19.10, firefox

mwilki7 (806)

@LiamDonohue
glad you think so
I have only ran this on my machine, how is the framerate on your computer?

LiamDonohue (74)

runs nicely on a (older)chromebook as long as i dont spawn in to many objects (aka spawn like 100 blobs) @mwilki7

LiamDonohue (74)

if u want me to i can be ur tester and push it to its limits @mwilki7

mwilki7 (806)

@LiamDonohue
give it your best shot
just don't melt your computer lol

LiamDonohue (74)

ok so what i found is that you can completely push it with the physics blocks buut the blob slow it down pretty quickly. will that be cash or credit lol @mwilki7

mwilki7 (806)

@LiamDonohue
umm do you accept upvotes (´・ω・`)?

mwilki7 (806)

if anyone could tell me how to change the darn fluid color that would be rly nice

TaylorLiang (656)

@mwilki7 in the let current color variable, change the R G and B values.

mwilki7 (806)

@TaylorLiang
sadly ive tried all sorts of combinations of stuff so far
i can change the color of the boxes but not the fluid

even commenting out the line: pgd.set_color(color); doesn't change the color
i think me mind is going ded