This repository shows how to use the Physics Plugin for the WebGL engine Polygonjs.
yarn && yarn polygon
and open your browser at:
http://localhost:8091?scene=default
This will open the scene saved in this repo. It is a simple scene with the following setup:
The right branch, which creates the moving rigid bodies:
- a Text node to create the geometry of a word
- a Scatter node to create points on the text
- a AttribCreate to add the
pscaleattribute on each point, with the expression1*rand(@ptnum+945)+0.5, which will give a random scale to each rigid body. - a Copy node to create boxes on all the points
- a PhysicsRbdAttributes to add the attributes necessary to the simulation
- another AttribCreate node to randomize the
restitutionattribute.
The left branch, which creates the static rigid bodies:
- a box node to create a box
- a transform to scale the geometry
- a second transform to position the object
- a PhysicsRbdAttributes to set the attributes for the simulation. The difference to the moving RBDs is that
activeis set to false, andmassis set to a very high number. - both boxes are merged (make sure to have the merge node set to
separate objectsby settingcompactto false), so that their geometries are not merged into a single object.
and finally both branches are merged into the PhysicsSolver, where all attributes are set to default.
yarn && yarn run snowpack dev
and open your browser at:
http://localhost:8080/

