Skip to content

Instantly share code, notes, and snippets.

@enjalot
Created April 21, 2013 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enjalot/5431559 to your computer and use it in GitHub Desktop.
Save enjalot/5431559 to your computer and use it in GitHub Desktop.
verlet-js
{"description":"verlet-js","endpoint":"","display":"canvas","public":true,"require":[{"name":"verlet-js","url":"http://enjalot.github.io/verlet-js/verlet.js"}],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":true,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/cQ0ruLw.png"}
//verlet-js: http://subprotocol.com/2013/04/18/introducing-verlet-js.html
var width = tributary.sw;
var height = tributary.sh;
var sim;
tributary.init = function(ctx) {
// simulation
sim = new VerletJS(width, height, tributary.canvas);
sim.friction = 1;
// entities
var segment = sim.lineSegments([new Vec2(20,10), new Vec2(40,10), new Vec2(60,10), new Vec2(80,10), new Vec2(100,10)], 0.02);
var pin = segment.pin(0);
var pin = segment.pin(4);
var tire1 = sim.tire(new Vec2(193,50), 75, 30, 0.3, 0.9);
var tire2 = sim.tire(new Vec2(400,50), 70, 7, 0.1, 0.2);
var tire3 = sim.tire(new Vec2(600,50), 70, 3, 1, 1);
console.log("sim", sim)
}
tributary.run = function(ctx, t) {
if(sim) {
sim.frame(8);
sim.draw();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment