Ignore:
Timestamp:
2014-12-15T13:07:02+13:00 (9 years ago)
Author:
bmt11
Message:

All weather is now functioning including switching back to fine weather. Weather is now also affected by wind force

Location:
other-projects/nz-flag-design/trunk/render-3d
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • other-projects/nz-flag-design/trunk/render-3d/CSS/button.css

    r29579 r29634  
    44    -webkit-border-radius:42px;
    55    border-radius:100%;
    6     border:1vh solid #057fd0;
     6    border:1vh solid #7F90B9;
    77    display: block;
    88    cursor:pointer;
  • other-projects/nz-flag-design/trunk/render-3d/flag.html

    r29620 r29634  
    2727                transition: right 0.5s;
    2828                background-image: url("./images/slider.png");
    29                 background-size: 25vw 150vh;
     29                background-size: cover;
    3030                background-position: center;
    3131            }
     
    6767                <!--Toggle:
    6868                <a onclick="wind = !wind;">Wind</a> |-->
    69                 <a class="myButton" style="background-image:url('./images/sunButton.jpg')" onclick="fine = !fine;"></a>
     69                <a class="myButton" style="background-image:url('./images/sunButton.jpg')" onclick="sunny = !sunny;"></a>
    7070                <a class="myButton" style="background-image:url('./images/rainButton.jpg')" onclick="raining = !raining;"></a>
    7171                <a class="myButton" style="background-image:url('./images/snowButton.jpg')" onclick="snowing = !snowing;"></a>
     
    8080            function openclose(){
    8181                if (open){
    82                     document.getElementById("menuContainer").style.right = "-20vw";
     82                    document.getElementById("menuContainer").style.right = "-19vw";
    8383                    document.getElementById("arrow").style.transform = "rotate(360deg)";
    8484                }else{document.getElementById("menuContainer").style.right = "0vw";
     
    101101        <script type="text/javascript" src="./weather/rain.js"></script>
    102102        <script type="text/javascript" src="./weather/snow.js"></script>
     103        <script type="text/javascript" src="./weather/sun.js"></script>
    103104       
    104105        <script type="text/javascript" src="./Flag_files/KeyboardState.js"></script>
     
    161162            /*  Weather variables  */
    162163            var weatherSystem;
     164           
    163165            var raining = false;
    164166            var snowing = false;
     167            var sunny = false;
     168           
    165169            var snowSystem;
    166170            var rainSystem;
     171            var sunSystem;
    167172           
    168173            /*  Mouse variables     */
     
    184189           
    185190            var object, tmpFlag, arrow;
     191           
    186192
    187193            var rotate = false;
     
    259265                rainSystem = new rain();
    260266                snowSystem = new snow();
     267                sunSystem = new sun();
    261268                weatherSystem = new weatherSystem(scene);
    262269           
     
    285292                arrow = new THREE.ArrowHelper( new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 0, 0 ), 50, 0xff0000 );
    286293                arrow.position.set( -200, -50, -200 );
     294                arrow.setLength( 0 );
     295                arrow.setDirection( 0 );
    287296                //scene.add( arrow );
    288297
     
    423432
    424433                var time = Date.now();
     434               
    425435                windStrength = Math.cos( time / 7000 ) * 100 + 200;
    426436                windForce.set( 1000,500,Math.sin( time / 1000 ) ).normalize().multiplyScalar( windStrength );
    427437                arrow.setLength( windStrength );
    428438                arrow.setDirection( windForce );
     439
    429440                controls.update();
    430441                simulate(time);
     
    468479                if(raining && weatherSystem.type != rainSystem){
    469480                    snowing = false;
     481                    sunny = false;
    470482                    weatherSystem.swap(rainSystem);
    471483                }else if(snowing && weatherSystem.type != snowSystem){
    472484                    raining = false;
     485                    sunny = false;
    473486                    weatherSystem.swap(snowSystem);
     487                }else if(sunny && weatherSystem.type != sunSystem){
     488                    raining = false;
     489                    snowing = false;
     490                    weatherSystem.swap(sunSystem);
    474491                }
    475492               
  • other-projects/nz-flag-design/trunk/render-3d/weather/rain.js

    r29475 r29634  
    33   
    44    this.isInit = false;
     5    this.MASS = 0.01;
    56   
    67    this.init = function() {
     
    1314   
    1415        // create the particle variables
    15         this.particleCount = 1800,
     16        this.particleCount = 3500,
    1617        this.particles = new THREE.Geometry(),
    1718        this.pMaterial = new THREE.ParticleBasicMaterial({
     
    3132            // create a particle with random
    3233            // position values, -250 -> 250
    33             var pX = Math.random() * window.innerWidth * 2 - window.innerWidth,
    34                 pY = Math.random() * window.innerHeight * 3 - window.innerHeight,
    35                 pZ = Math.random() * window.innerWidth * 2 - window.innerWidth;
    36                 this.particle = new THREE.Vector3(pX, pY, pZ);
     34            var pX = (Math.random() * 3000) - 1500,
     35                pY = Math.random() * window.innerHeight * 3 - window.innerHeight,
     36                pZ = (Math.random() * 3000) - 1500;
     37                this.particle = new THREE.Vector3(pX, pY, pZ); 
    3738
    3839            // create a velocity vector
    39             this.particle.velocity = new THREE.Vector3(
    40                 0, // x
    41                 -Math.random(), // y
    42                 0); // z
     40            this.particle.velocity = new THREE.Vector3(
     41                (windForce.x * this.MASS), // x
     42                -Math.random() * 0.01, // y
     43                (windForce.z * this.MASS)); // z
    4344
    4445            // add it to the geometry
     
    7071           
    7172            // check if we need to reset
    72             if(this.particle.y < -200) {
    73                 this.particle.y = Math.random() * window.innerHeight+10;
     73            if(this.particle.y < -10) {
     74                this.particle.y = (window.innerHeight*2)+(Math.random() * 100);
    7475                this.particle.velocity.y = 0;
     76                this.particle.x = (Math.random() * 4000) - 2000;
     77                this.particle.z = (Math.random() * 4000) - 2000;
     78
    7579            }
    7680           
    7781            // update the velocity
    78             this.particle.velocity.y -= Math.random() * .1;
     82            this.particle.velocity.y -= Math.random() * 0.01;
    7983           
    8084            // and the position
  • other-projects/nz-flag-design/trunk/render-3d/weather/snow.js

    r29547 r29634  
    33   
    44        this.isInit = false;
    5         this.Mass = 0.01;
     5        this.MASS = 0.005;
    66       
    77        this.init = function() {
     
    1414       
    1515            // create the particle variables
    16             this.particleCount = 2000,
     16            this.particleCount = 3000,
    1717            this.particles = new THREE.Geometry(),
    1818           
     
    3232
    3333                // create a particle with random
    34                 // position values, -250 -> 250
    35                 var pX = Math.random() * window.innerWidth * 3 - window.innerWidth,
    36                     pY = Math.random() * window.innerHeight * 4 - window.innerHeight,
    37                     pZ = Math.random() * window.innerWidth * 3 - window.innerWidth;
     34                // position values
     35                var pX = (Math.random() * 3000) - 1500,
     36                    pY = Math.random() * window.innerHeight * 3 - window.innerHeight,
     37                    pZ = (Math.random() * 3000) - 1500;
    3838                    this.particle = new THREE.Vector3(pX, pY, pZ); 
    3939               
    4040                // create a velocity vector
    4141                this.particle.velocity = new THREE.Vector3(
    42                     0, // x
    43                     -Math.random(), // y
    44                     0); // z
    45 
     42                    (windForce.x * this.MASS), // x
     43                    -Math.random() * 0.01, // y
     44                    (windForce.z * this.MASS)); // z
     45               
     46                //this.particle.velocity.z = arrow.direction.z * this.MASS;
    4647                // add it to the geometry
    4748                this.particles.vertices.push(this.particle);
     
    7374               
    7475                // check if we need to reset
    75                 if(this.particle.y < -200) {
    76                     this.particle.y = Math.random() * window.innerHeight+10;
     76                if(this.particle.y < -10) {
     77                    this.particle.y = (window.innerHeight*2)+(Math.random() * 100);
    7778                    this.particle.velocity.y = 0;
     79                    this.particle.x = (Math.random() * 4000) - 2000;
     80                    this.particle.z = (Math.random() * 4000) - 2000;
     81
    7882                }
    7983               
    8084                // update the velocity
    81                 this.particle.velocity.y -= Math.random() * this.Mass;
    82                
     85                this.particle.velocity.y -= Math.random() * 0.001;
     86                //this.particle.velocity.x = (windForce.x * this.MASS);
     87                //this.particle.velocity.z = (windForce.z * this.MASS);
     88
    8389                // and the position
    8490                this.particle.addVectors(
  • other-projects/nz-flag-design/trunk/render-3d/weather/weather.js

    r29475 r29634  
    2323        this.swap = function(w){
    2424            if(this.type != w){
    25                 if(this.type !== null) this.scene.remove(this.getWeather());
     25                if(this.type !== null){
     26                    this.scene.remove(this.getWeather());
     27                }
    2628                this.set(w);
    2729            }
    2830        }
    29        
    30        
    3131       
    3232        this.isSet = function(){
Note: See TracChangeset for help on using the changeset viewer.