Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:hapticdata/toxiclibsjs

  • Loading branch information...
commit e8b676e93a1d1a05ab32a9ffbbe0cb44c8135cca 2 parents bc05589 + ec80d65
@hapticdata hapticdata authored
Showing with 2 additions and 2 deletions.
  1. +1 −1  build/toxiclibs.js
  2. +1 −1  src/physics/physics2d/VerletPhysics2D.js
View
2  build/toxiclibs.js
@@ -270,7 +270,7 @@ toxi.physics2d.PullBackString2D=function(e,g,h){toxi.physics2d.VerletSpring2D.ca
toxi.physics2d.VerletConstrainedSpring2D=function(e,g,h,i,k){toxi.physics2d.VerletSpring2D.call(this,e,g,h,i);this.limit=k===undefined?Number.MAX_VALUE:k};toxi.extend(toxi.physics2d.VerletConstrainedSpring2D,toxi.physics2d.VerletSpring2D);
toxi.physics2d.VerletConstrainedSpring2D.update=function(e){var g=this.b.sub(this.a),h=g.magnitude()+toxi.physics2d.VerletSpring2D.EPS;h=(h-this.restLength)/(h*(this.a.invWeight+this.b.invWeight))*this.strength;if(!this.a.isLocked&&!this.isALocked){this.a.addSelf(g.scale(h*this.a.invWeight).limit(this.limit));e&&this.a.applyConstraints()}if(!this.b.isLocked&&!this.isBLocked){this.b.subSelf(g.scale(h*this.b.invWeight).limit(this.limit));e&&this.b.applyConstraints()}};
toxi.physics2d.VerletMinDistanceSpring2D=function(e,g,h,i){toxi.physics2d.VerletSpring2D.call(this,e,g,h,i);this.setRestLength(h)};toxi.extend(toxi.physics2d.VerletMinDistanceSpring2D,toxi.physics2d.VerletSpring2D);toxi.physics2d.VerletMinDistanceSpring2D.prototype.update=function(e){this.b.distanceToSquared(this.a)<this.restLengthSquared&&this.parent.update.call(this,e)};
-toxi.physics2d.VerletPhysics2D=function(e,g,h,i){this.behaviors=[];this.particles=[];this.springs=[];this.numIterations=g===undefined?50:g;this.timeStep=i===undefined?1:i;this.setDrag(h||0);e!==undefined&&this.addBehavior(new toxi.physics.GravityBehavior(e))};toxi.physics2d.VerletPhysics2D.addConstraintToAll=function(e,g){for(var h=0;h<g.length;h++)g[h].addConstraint(e)};toxi.physics2d.VerletPhysics2D.removeConstraintFromAll=function(e,g){for(var h=0;h<g.length;h++)g[h].removeConstraint(e)};
+toxi.physics2d.VerletPhysics2D=function(e,g,h,i){this.behaviors=[];this.particles=[];this.springs=[];this.numIterations=g===undefined?50:g;this.timeStep=i===undefined?1:i;this.setDrag(h||0);e!==undefined&&this.addBehavior(new toxi.physics2d.GravityBehavior(e))};toxi.physics2d.VerletPhysics2D.addConstraintToAll=function(e,g){for(var h=0;h<g.length;h++)g[h].addConstraint(e)};toxi.physics2d.VerletPhysics2D.removeConstraintFromAll=function(e,g){for(var h=0;h<g.length;h++)g[h].removeConstraint(e)};
toxi.physics2d.VerletPhysics2D.prototype={addBehavior:function(e){if(e===undefined)throw{name:"TypeError",message:"Incorrect Parameters for toxi.physics2d.VerletPhysics2D addBehavior"};e.configure(this.timeStep);this.behaviors.push(e)},addParticle:function(e){this.particles.push(e);return this},addSpring:function(e){this.getSpring(e.a,e.b)===undefined&&this.springs.push(e);return this},clear:function(){this.particles=[];this.springs=[];return this},constrainToBounds:function(){var e=undefined,g=0;
for(g=0;g<this.particles.length;g++){e=this.particles[g];e.bounds!==undefined&&e.constrain(e.bounds)}if(this.worldBounds!==undefined)for(g=0;g<this.particles.length;g++){e=this.particles[g];e.constrain(this.worldBounds)}},getCurrentBounds:function(){var e=new toxi.Vec2D(Number.MAX_VALUE,Number.MAX_VALUE),g=new toxi.Vec2D(Number.MIN_VALUE,Number.MIN_VALUE),h=0,i=undefined;for(h=0;h<this.particles.length;h++){i=this.particles[h];e.minSelf(i);g.maxSelf(i)}return new toxi.Rect(e,g)},getDrag:function(){return 1-
this.drag},getNumIterations:function(){return this.numIterations},getSpring:function(e,g){var h=0;for(h=0;h<this.springs.length;h++){var i=this.springs[h];if(i.a===e&&i.b===g||i.a===g&&i.b===g)return i}},getTimeStep:function(){return this.timeStep},getWorldBounds:function(){return this.worldBounds},removeBehavior:function(e){return toxi.physics2d.removeItemFrom(e,this.behaviors)},removeParticle:function(e){return toxi.physics2d.removeItemFrom(e,this.particles)},removeSpring:function(e){return toxi.physics2d.removeItemFrom(e,
View
2  src/physics/physics2d/VerletPhysics2D.js
@@ -7,7 +7,7 @@ toxi.physics2d.VerletPhysics2D = function(gravity, numIterations, drag, timeStep
this.setDrag(drag || 0);
if(gravity !== undefined){
- this.addBehavior(new toxi.physics.GravityBehavior(gravity));
+ this.addBehavior(new toxi.physics2d.GravityBehavior(gravity));
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.