# Changeset 29693 for other-projects/nz-flag-design

Show
Ignore:
Timestamp:
21.01.2015 15:12:08 (5 years ago)
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:
3 modified

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

• Property svn:mergeinfo changed /other-projects/nz-flag-design/trunk/render-3d (added) merged: 29599
• ## 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);

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();

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;

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);
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);
325274        particle.integrate(TIMESTEP_SQ);
326275    }
• ## other-projects/nz-flag-design/trunk/render-3d/flag.html

r29686 r29693
44    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
55
6         <title>three.js webgl - 3D Flag hhh</title>
6        <title>3D Representation of Flag</title>
77        <meta charset="utf-8">
88        <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">

6161        </style>
63
63
6464    <body>
65
6667            <div id="weatherMenu" style="color : white">

7576        </div>
7677
78        <div id="slider">
79            <div id="speed"></div>
80        </div>
81
7783
7884        <script type="text/javascript">
85
86            /*              JQUERY SLIDER                   */
87
88
89
90
91            /*----------------------------------------------*/
92
7993            var open = false;
8094            function openclose(){

103117        <script type="text/javascript" src="./weather/sun.js"></script>
119        <script type="text/javascript" src="./Flag_files/slider.js"></script>
105120
106121        <script type="text/javascript" src="./Flag_files/KeyboardState.js"></script>
107122
124
109126

332
333                 /*var tmp = mesh.position
334                 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; //125
338                 mesh.position.z = tmp.z;
342
343349
344350                //

428434                    object.position.z = -165;
436
430437                    initial = false;

475482
476483                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                 }
489484
490485                var p = cloth.particles;

500495                clothGeometry.normalsNeedUpdate = true;
501496                clothGeometry.verticesNeedUpdate = true;
502
503
504
497
505498                if(raining && weatherSystem.type != rainSystem){
506499                    snowing = false;

526519
527520            }
528
529         </script><div><canvas width="1366" height="600"></canvas>
521
522        </script>
523
530524</body></html>