hapticdata / toxiclibsjs

Toxiclibsjs is a library for computational design tasks with JavaScript. This library is a port of http://toxiclibs.org for java and processing.
http://haptic-data.com/toxiclibsjs
GNU Lesser General Public License v2.1
810 stars 107 forks source link

ParticleString2D missing constructor? #23

Closed aunruh closed 11 years ago

aunruh commented 11 years ago

Hi! When I initialize a ParticleString2D this way: ParticleString2D(VerletPhysics2D physics, java.util.List<VerletParticle2D> plist, float strength)

Then println(physics.particles.length); or println(physics.springs.length); returns 0. Is the constructor not yet implemented or am I doing something wrong?

The other way works perfectly: ParticleString2D(VerletPhysics2D physics, toxi.geom.Vec2D pos, toxi.geom.Vec2D step, int num, float mass, float strength)

Why do I want to use this constructor? The particles in java.util.List<VerletParticle2D> plist have specific coordinates. This way i'm not constricted to using toxi.geom.Vec2D step and toxi.geom.Vec2D pos for the positioning of the particles.

Cheers

aunruh commented 11 years ago

Ok it works! I just added my particles and springs directly to the VerletPhysics object. Instead of making a ParticleString object. :)

hapticdata commented 11 years ago

This unit test for the constructor passes. The array of particles, and the created springs end up in the physics object correctly:

Are you using this within Processing.js with the Processing/Java syntax? If so, maybe you are passing it a java collection? toxiclibs.js always wants a normal Array.

aunruh commented 11 years ago

Oh, yeah that must have been the problem. Didn't use the proper array. Thanks!