From 8e06140df29aaa306999c350ba0446f838ff2fc0 Mon Sep 17 00:00:00 2001 From: SebastianCrow Date: Thu, 5 Mar 2015 00:08:40 +0100 Subject: [PATCH] Native invisible entities handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Draw functions for constraints and particles now can be null or undefined so they won’t be rendered. --- js/verlet-1.0.0.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/js/verlet-1.0.0.js b/js/verlet-1.0.0.js index bdf342e..40841c1 100644 --- a/js/verlet-1.0.0.js +++ b/js/verlet-1.0.0.js @@ -610,8 +610,10 @@ VerletJS.prototype.draw = function() { this.composites[c].drawConstraints(this.ctx, this.composites[c]); } else { var constraints = this.composites[c].constraints; - for (i in constraints) - constraints[i].draw(this.ctx); + for (i in constraints) { + var constraint = constraints[i]; + if (constraint.draw) constraint.draw(this.ctx); + } } // draw particles @@ -619,8 +621,10 @@ VerletJS.prototype.draw = function() { this.composites[c].drawParticles(this.ctx, this.composites[c]); } else { var particles = this.composites[c].particles; - for (i in particles) - particles[i].draw(this.ctx); + for (i in particles) { + var particle = particles[i]; + if (particle.draw) particle.draw(this.ctx); + } } }