/*global THREE*/
(function () {

  // Simulation
  // ----------

  var PTCL = Particulate;
  var PARTICLES = 150;
  var LINK_DISTANCE = 1;
  var GRAVITY = -0.05;
  var system = new PTCL.ParticleSystem(PARTICLES, 2);
  var bounds = new PTCL.BoxConstraint(-50, -50, -50, 50, 50, 50);
  var gravityForce = new PTCL.DirectionalForce();

  system.each(function (i) {
    if (i > 0) {
      system.setPosition(i,
        (Math.random() - 0.5) * 20,
        (Math.random() - 0.5) * 20,
        (Math.random() - 0.5) * 20);

      system.addConstraint(new PTCL.DistanceConstraint(LINK_DISTANCE, i - 1, i));
    }
  });

  system.addConstraint(bounds);
  system.addForce(gravityForce);

  // Visualization
  // -------------

  var demo = new PTCL.DemoScene();
  demo.camera.position.set(0, 200, 500);

  var geometry = new THREE.BufferGeometry();
  var position = new THREE.BufferAttribute();
  position.array = system.positions;
  position.itemSize = 3;

  geometry.addAttribute('position', position);
  geometry.computeBoundingSphere();

  var material = new THREE.ParticleSystemMaterial({size: 2});
  var particleSystem = new THREE.ParticleSystem(geometry, material);
  demo.scene.add(particleSystem);

  var box = new THREE.Mesh(
    new THREE.BoxGeometry(100, 100, 100, 1, 1, 1),
    new THREE.MeshBasicMaterial({
      wireframe : true
    }));
  demo.scene.add(box);

  var up = demo.controls.object.up;

  demo.animate(function () {
    gravityForce.set(up.x * GRAVITY, up.y * GRAVITY, up.z * GRAVITY);
    system.tick(1);
    system.setPosition(0, 0, 0, 0);
    geometry.attributes.position.needsUpdate = true;
    demo.update();
    demo.render();
  });
}());

@@ -369,16 +369,37 @@
 f (i %3E 0
+ && i %3C PARTICLES - 1
 ) %7B%0A    
@@ -531,16 +531,39 @@
  * 20);%0A
+    %7D%0A%0A    if (i %3E 0) %7B
 %0A      s
@@ -1587,16 +1587,67 @@
 tion(0, 
+-10, 0, 0);%0A    system.setPosition(PARTICLES - 1, 1
 0, 0, 0)

Update chain example