Ignore:
Timestamp:
2015-01-21T15:12:08+13:00 (9 years ago)
Author:
bmt11
Message:

Added slider for wind control but the black box is a bug I have no figured out for some time now
Camera control is disabled whilst using the slider also :)

Location:
other-projects/nz-flag-design/trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • other-projects/nz-flag-design/trunk

  • other-projects/nz-flag-design/trunk/render-3d/Flag_files/Flag.js

    r29547 r29693  
    6262
    6363var wind = true;
    64 var windStrength = 2;
     64
    6565var windForce = new THREE.Vector3(0,0,0);
    6666
     
    107107// Performs verlet integration
    108108Particle.prototype.integrate = function(timesq) {
     109
    109110    var newPos = this.tmp.subVectors(this.position, this.previous);
    110111    newPos.multiplyScalar(DRAG).add(this.position);
     
    116117
    117118    this.a.set(0, 0, 0);
     119   
    118120}
    119121
     
    122124
    123125function satisifyConstrains(p1, p2, distance) {
     126   
    124127    diff.subVectors(p2.position, p1.position);
    125128    var currentDist = diff.length();
     
    129132    p1.position.add(correctionHalf);
    130133    p2.position.sub(correctionHalf);
    131 
    132     // float difference = (restingDistance - d) / d
    133     // im1 = 1 / p1.mass // inverse mass quantities
    134     // im2 = 1 / p2.mass
    135     // p1.position += delta * (im1 / (im1 + im2)) * stiffness * difference
    136 
     134   
    137135}
    138136
     
    158156
    159157    // Structural
    160 
     158   
    161159    for (v=0;v<h;v++) {
    162160        for (u=0;u<w;u++) {
     
    193191        ]);
    194192    }
    195 
     193   
    196194
    197195    // While many system uses shear and bend springs,
     
    219217        }
    220218    }
    221 
    222 
    223     // // Bend
    224 
    225     // var wlen = restDistance * 2;
    226     // var hlen = restDistance * 2;
    227     // diagonalDist = Math.sqrt(wlen * wlen + hlen * hlen);
    228 
    229     // for (v=0;v<h-1;v++) {
    230     //  for (u=0;u<w-1;u++) {
    231     //      constrains.push([
    232     //          particles[index(u, v)],
    233     //          particles[index(u+2, v)],
    234     //          wlen
    235     //      ]);
    236 
    237     //      constrains.push([
    238     //          particles[index(u, v)],
    239     //          particles[index(u, v+2)],
    240     //          hlen
    241     //      ]);
    242 
    243     //      constrains.push([
    244     //          particles[index(u, v)],
    245     //          particles[index(u+2, v+2)],
    246     //          diagonalDist
    247     //      ]);
    248 
    249     //      constrains.push([
    250     //          particles[index(u, v+2)],
    251     //          particles[index(u+2, v+2)],
    252     //          wlen
    253     //      ]);
    254 
    255     //      constrains.push([
    256     //          particles[index(u+2, v+2)],
    257     //          particles[index(u+2, v+2)],
    258     //          hlen
    259     //      ]);
    260 
    261     //      constrains.push([
    262     //          particles[index(u+2, v)],
    263     //          particles[index(u, v+2)],
    264     //          diagonalDist
    265     //      ]);
    266 
    267     //  }
    268     // }
    269 
    270 
     219   
    271220    this.particles = particles;
    272221    this.constrains = constrains;
     
    320269        particle.addForce(gravity);
    321270        //
    322         // var x = particle.position.x, y = particle.position.y, z = particle.position.z, t=Date.now() / 1000;
    323         // windForce.set(Math.sin(x*y*t), Math.cos(z*t), Math.sin(Math.cos(5*x*y*z))).multiplyScalar(100);
    324         // particle.addForce(windForce);
     271        var x = particle.position.x, y = particle.position.y, z = particle.position.z, t=Date.now() / 1000;
     272        //windForce.set(Math.sin(x*y*t), Math.cos(z*t), Math.sin(Math.cos(5*x*y*z))).multiplyScalar(0);
     273        particle.addForce(windForce);
    325274        particle.integrate(TIMESTEP_SQ);
    326275    }
Note: See TracChangeset for help on using the changeset viewer.