Changeset 29693
- Timestamp:
- 2015-01-21T15:12:08+13:00 (8 years ago)
- Location:
- other-projects/nz-flag-design/trunk
- Files:
-
- 6 added
- 3 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 } -
other-projects/nz-flag-design/trunk/render-3d/flag.html
r29686 r29693 4 4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5 5 6 <title> three.js webgl - 3D Flag hhh</title>6 <title>3D Representation of Flag</title> 7 7 <meta charset="utf-8"> 8 8 <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> … … 61 61 </style> 62 62 <style type="text/css"></style></head> 63 63 64 64 <body> 65 65 66 <div id="menuContainer"> 66 67 <div id="weatherMenu" style="color : white"> … … 75 76 </div> 76 77 78 <div id="slider"> 79 <div id="speed"></div> 80 </div> 81 82 <link rel="stylesheet" href="./CSS/slider.css" /> 77 83 78 84 <script type="text/javascript"> 85 86 /* JQUERY SLIDER */ 87 88 89 90 91 /*----------------------------------------------*/ 92 79 93 var open = false; 80 94 function openclose(){ … … 103 117 <script type="text/javascript" src="./weather/sun.js"></script> 104 118 <script type="text/javascript" src="./Flag_files/ColladaLoader.js"></script> 119 <script type="text/javascript" src="./Flag_files/slider.js"></script> 105 120 106 121 <script type="text/javascript" src="./Flag_files/KeyboardState.js"></script> 107 122 123 <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script> 124 108 125 <script type="x-shader/x-fragment" id="fragmentShaderDepth"> 109 126 … … 330 347 mesh.castShadow = false; 331 348 scene.add( mesh ); 332 333 /*var tmp = mesh.position334 var gg = new THREE.BoxGeometry( 100, 100, 100 );335 var mesh = new THREE.Mesh( gg, poleMat );336 mesh.position.y = tmp.y - 740;337 mesh.position.x = tmp.x; //125338 mesh.position.z = tmp.z;339 mesh.receiveShadow = true;340 mesh.castShadow = false;341 scene.add( mesh );*/342 343 349 344 350 // … … 428 434 object.position.z = -165; 429 435 scene.add( object ); 436 430 437 initial = false; 431 438 object.customDepthMaterial = new THREE.ShaderMaterial( { uniforms: uniforms, vertexShader: vertexShader, fragmentShader: fragmentShader } ); … … 475 482 476 483 var timer = Date.now() * 0.0002; 477 478 keyboard.update();479 if( keyboard.down("A")) {480 flagSelector--;481 if(flagSelector < 0) flagSelector = flags.length-1;482 createFlag();483 484 }else if(keyboard.down("D")) {485 flagSelector++;486 if(flagSelector >= flags.length) flagSelector = 0;487 createFlag();488 }489 484 490 485 var p = cloth.particles; … … 500 495 clothGeometry.normalsNeedUpdate = true; 501 496 clothGeometry.verticesNeedUpdate = true; 502 503 504 497 505 498 if(raining && weatherSystem.type != rainSystem){ 506 499 snowing = false; … … 526 519 527 520 } 528 529 </script><div><canvas width="1366" height="600"></canvas> 521 522 </script> 523 530 524 </body></html>
Note:
See TracChangeset
for help on using the changeset viewer.