- Timestamp:
- 2015-01-21T15:12:08+13:00 (9 years ago)
- Location:
- other-projects/nz-flag-design/trunk
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/nz-flag-design/trunk
- Property svn:mergeinfo changed
/other-projects/nz-flag-design/trunk/render-3d (added) merged: 29599
- Property svn:mergeinfo changed
-
other-projects/nz-flag-design/trunk/render-3d/Flag_files/Flag.js
r29547 r29693 62 62 63 63 var wind = true; 64 var windStrength = 2; 64 65 65 var windForce = new THREE.Vector3(0,0,0); 66 66 … … 107 107 // Performs verlet integration 108 108 Particle.prototype.integrate = function(timesq) { 109 109 110 var newPos = this.tmp.subVectors(this.position, this.previous); 110 111 newPos.multiplyScalar(DRAG).add(this.position); … … 116 117 117 118 this.a.set(0, 0, 0); 119 118 120 } 119 121 … … 122 124 123 125 function satisifyConstrains(p1, p2, distance) { 126 124 127 diff.subVectors(p2.position, p1.position); 125 128 var currentDist = diff.length(); … … 129 132 p1.position.add(correctionHalf); 130 133 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 137 135 } 138 136 … … 158 156 159 157 // Structural 160 158 161 159 for (v=0;v<h;v++) { 162 160 for (u=0;u<w;u++) { … … 193 191 ]); 194 192 } 195 193 196 194 197 195 // While many system uses shear and bend springs, … … 219 217 } 220 218 } 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 271 220 this.particles = particles; 272 221 this.constrains = constrains; … … 320 269 particle.addForce(gravity); 321 270 // 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); 325 274 particle.integrate(TIMESTEP_SQ); 326 275 }
Note:
See TracChangeset
for help on using the changeset viewer.