Skip to content

formula1/verlet-js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

verlet-js

A simple Verlet (pronounced 'ver-ley') physics engine written in javascript.

Particles, distance constraints, and angular constraints are all supported by verlet-js. From these primitives it is possible to construct just about anything you can imagine.

License

You may use verlet-js under the terms of the MIT License (See LICENSE).

Examples

  1. Shapes (verlet-js Hello world)
  2. Fractal Trees
  3. Cloth
  4. Spiderweb

Code Layout

  1. js/verlet-js/vec2.js: 2d vector implementation
  2. js/verlet-js/constraint/: constraint code
  3. js/verlet-js/verlet.js: verlet-js engine
  4. js/verlet-js/objects.js: shapes and objects (triangles, circles, tires..)

Build for npm

npm run build

for automated building

npm run watch-build-test

Areas where speed might be able to be increased

  • Line/intersects#28 - I can compile the maxes and minimums before hand
  • any file that is named cachable can make lazy and store the information after
  • changing loops in verlet.js from for( in ) to while(i--)

Known Issues and the possible solutions

  • Problem: Constraints are applied after other constraints get applied
  • Solution: make each constraint only return a transform and apply them after all others do
  • Problem: Constraints that will force the particle in the same direction get applied ontop of eachother
  • Solution: Create a Governer Constraint that creates an average of all transforms done to each particle
  • Problem: Area Constraints cannot detect negative area
  • Solution: ??
  • Problem: Particles May tunnel
  • Solution: Make the Collision solver equation based
  • Problem: Collisions don't account for accelleration when solving the points new position
  • Solution: Make the collision solver equation based
  • Problem: Collisions don't solve lateral collisions (p goes behind ab)
  • Solution: look for when the lines intersect
  • Problem: Collision Solving only solves found collisions in timestep
  • Solution: Collision solver goes backward in time to first collision then searches
  • Problem: Collisions don't account for area behind a surface area
  • Solution: ??
  • Problem: points never rest
  • Solution: ??

About

A simple Verlet physics engine written in javascript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 89.0%
  • HTML 10.1%
  • CSS 0.9%