Is typescript library for node.js that runs physical simulation on your svg picture in browser. This project uses awesome 2d physic library matterjs and for bezier curves bezier-js.
npm install physical-svg
or use js directly https://raw.githubusercontent.com/richardk123/physical-svg/main/dist/bundle.js with basic use example https://github.com/richardk123/physical-svg/blob/main/dist/example_usage.html
PhysicalSvg(svgElement)
.usePathAggregator()
.withGravity({x: 0, y: 1})
.withLimitVelocityPlugin(8)
.withLimitAngularVelocityPlugin(Math.PI / 100)
.withBorderCollider()
.withMouseInteraction(0.01)
.withDebugRenderer(debugElement!)
.startSimulation({colliderWidth: 5, restitution: .9, friction: 0, frictionAir: 0});
https://richardk123.github.io/physical-svg-examples/
Offers to choose between useCollisionAggregator(), usePathAggregator() useCustomAggregator(aggregator: Aggregator)
Aggregate svg commands to group by checking is the commands are intersecting, e.g. checks curve X line curve X curve...
Aggregate svg commands by path specified in svg content
Use your own better aggregator
Set gravity vector
Set max speed for all objects in scene. This is useful if colliders are thin and with high speed they are passing through themselves.
Set max angular velocity in radians. This is useful if colliders are thin and with high speed they are passing through themselves.
Create a collider around svg borders.
Mouse can interact with physical objects.
Force is applied to physical object when scrolling through page.
Use if you want to see what is going on in physics engine.
Your own awesome plugin.
start simulation loop and return StopPhysicalSvg