//var gl = new WebGL2RenderingContext(); //enable WebGL 2 partial support

Demo.prototype.init = function()
{
    const settings = new Settings();


    this.alku(0,10);
    this.normalchiken(10,8);
    this.vali(18,10);
    this.kana(28,5);
    this.chiken(33,27);
    


}

Demo.prototype.alku = function (start, duration)
{

  var layer = 1; 
  this.loader.addAnimation(
    {
        "start": start, "duration": duration, "layer": layer
        ,"image": "_embedded/defaultWhite.png",
        color: [
            {
              r: 1.5,
              g: 10.5,
              b: 10
            }
          ],
    });

    this.loader.addAnimation(
        {
            "start": start, "duration": duration, "layer": layer
            ,"image": "_embedded/defaultWhite.png",
            scale: [{ uniform3d: () => (getSceneTimeFromStart()%0.288)*0.3+0.6 }],
            color: [
                {
                  r: 100,
                  g: 100,
                  b: 100
                }
              ],
        });

 
    this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 1.5 }],
          
          image: { name: 'Chikenidle.png' },
          position: [
            {
              x: () => 0,
              y: () => Math.sin(Math.sin(getSceneTimeFromStart()*0.2))-0.2,
              z: () => 0.
            },
            {duration:5,z:0},
            {duration:5,z:2}
          ],

          angle: [
            {
              degreesY: () => 0,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);

       this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 1.5 }],
          
          image: { name: 'Chikenidle.png' },
          position: [
            {
              x: () => 0.2,
              y: () => Math.sin(Math.sin(getSceneTimeFromStart()*0.2))-0.2,
              z: () => 0.
            },
            {duration:5,z:0},
            {duration:5,z:2}
          ],

          angle: [
            {
              degreesY: () => 0,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);


       this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 1.5 }],
          
          image: { name: 'Chikenidle.png' },
          position: [
            {
              x: () => -0.2,
              y: () => Math.sin(Math.sin(getSceneTimeFromStart()*0.2))-0.2,
              z: () => 0.
            },
            {duration:5,z:0},
            {duration:5,z:2}
          ],

          angle: [
            {
              degreesY: () => 0,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);

             this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 1.5 }],
          
          image: { name: 'Chikenidle.png' },
          position: [
            {
              x: () => -0.4,
              y: () => Math.sin(Math.sin(getSceneTimeFromStart()*0.2))-0.2,
              z: () => 0.
            },
            {duration:5,z:0},
            {duration:5,z:2}
          ],

          angle: [
            {
              degreesY: () => 0,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);


             this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 1.5 }],
          
          image: { name: 'Chikenidle.png' },
          position: [
            {
              x: () => 0.4,
              y: () => Math.sin(Math.sin(getSceneTimeFromStart()*0.2))-0.2,
              z: () => 0.
            },
            {duration:5,z:0},
            {duration:5,z:2}
          ],

          angle: [
            {
              degreesY: () => 0,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);
}

Demo.prototype.normalchiken = function (start, duration)
{

  var layer = 1; 
  this.loader.addAnimation(
    {
        "start": start, "duration": duration, "layer": layer
        ,"image": "_embedded/defaultWhite.png",
        color: [
            {
              r: 10,
              g: 10,
              b: 10
            }
          ],
    });

     this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 0.5 }],
          
          image: { name: 'rebel.png' },
          position: [
            {
              x: () => 0,
              y: () => Math.sin(Math.sin(getSceneTimeFromStart()*1)),
              z: () => 0.
            }
          ],

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*1,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);
       this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 0.5 }],
          
          image: { name: 'rebel.png' },
          position: [
            {
              x: () => .1,
              y: () => Math.sin(Math.sin(getSceneTimeFromStart()*1)),
              z: () => 0.
            }
          ],

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*1,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);

       this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 1.5 }],
          
          image: { name: 'rebel.png' },
          position: [
            {
              x: () => -0.5,
              y: () =>  Math.sin(Math.sin(getSceneTimeFromStart()*1)),
              z: () =>  0.
            }
          ],

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*1,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);

           this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 0.5 }],
          
          image: { name: 'rebel.png' },
          position: [
            {
              x: () => 0,
              y: () => Math.sin(Math.sin(getSceneTimeFromStart()*1)),
              z: () => 0.
            }
          ],

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*1,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);
       this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 0.5 }],
          
          image: { name: 'rebel.png' },
          position: [
            {
              x: () => .45,
              y: () => Math.sin(Math.sin(getSceneTimeFromStart()*1)),
              z: () => 0.
            }
          ],

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*1,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);

       this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 1.5 }],
          
          image: { name: 'rebel.png' },
          position: [
            {
              x: () => -0.35,
              y: () =>  Math.sin(Math.sin(getSceneTimeFromStart()*1)),
              z: () =>  0.
            }
          ],

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*1,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);

           this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 0.5 }],
          
          image: { name: 'rebel.png' },
          position: [
            {
              x: () => 0.5,
              y: () => Math.sin(Math.sin(getSceneTimeFromStart()*1)),
              z: () => 0.
            }
          ],

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*1,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);
       this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 0.5 }],
          
          image: { name: 'rebel.png' },
          position: [
            {
              x: () => .25,
              y: () => Math.sin(Math.sin(getSceneTimeFromStart()*1)),
              z: () => 0.
            }
          ],

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*1,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);

       this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 1.5 }],
          
          image: { name: 'rebel.png' },
          position: [
            {
              x: () => -0.6,
              y: () =>  Math.sin(Math.sin(getSceneTimeFromStart()*1)),
              z: () =>  0.
            }
          ],

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*1,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);

           this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 0.5 }],
          
          image: { name: 'chiken with ak.png' },
          position: [
            {
              x: () => 0,
              y: () => 1,
              z: () => 0.
            }
          ],

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*1,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);

                 this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 0.5 }],
          
          image: { name: 'chiken with ak.png' },
          position: [
            {
              x: () => 0.,
              y: () => 0.1,
              z: () => 0.
            }
          ],

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*1,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);

                 this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 0.5 }],
          
          image: { name: 'chiken with ak.png' },
          position: [
            {
              x: () => 0.3,
              y: () => 0.1,
              z: () => 0.
            }
          ],

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*1,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);

                       this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 0.5 }],
          
          image: { name: 'chiken with ak.png' },
          position: [
            {
              x: () => -0.1,
              y: () => 0.1,
              z: () => 0.
            }
          ],

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*1,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);

                 this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 0.5 }],
          
          image: { name: 'chiken with ak.png' },
          position: [
            {
              x: () => -0.3,
              y: () => 0.1,
              z: () => 0.
            }
          ],

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*1,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);

}
Demo.prototype.kana = function (start, duration)
{

  var layer = 1; 
  this.loader.addAnimation(
    {
        "start": start, "duration": duration, "layer": layer
        ,"image": "_embedded/defaultWhite.png",
        color: [
            {
              r: 10,
              g: 0,
              b: 0
            }
          ],
    });
     this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 1 }],
          
          object: { name: 'chicken.obj' },
           
          position: [
            {
              x: () => 1,
              y: () => 0,
              z: () => 0.
            }
          ],

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*150,
              degreesX: () => 0,
              degreesZ: () => 90
            }
          ]
        }
      ]);

       this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 1 }],
          
          object: { name: 'chicken.obj' },
           
          position: [
            {
              x: () => -1,
              y: () => 0,
              z: () => 0.
            }
          ],

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*150,
              degreesX: () => 0,
              degreesZ: () => 90
            }
          ]
        }
      ]);
    }
Demo.prototype.vali = function (start, duration)
{
var layer = 1; 
  this.loader.addAnimation(
    {
        "start": start, "duration": duration, "layer": layer
        ,"image": "_embedded/defaultWhite.png",
        color: [
            {
              r: 10,
              g: 10,
              b: 10
            }
          ],
    });

         this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 1 }],
          
          image: { name: 'chiken with ak.png' },

          position: [
            {
              x: () => Math.sin(Math.sin(getSceneTimeFromStart()*0.1)),
              y: () => 0.15,
              z: () => 0
            }
          ],

          angle: [
            {
              degreesY: () => 0,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);

      var layer = 1; 
  this.loader.addAnimation(
    {
        "start": start, "duration": duration, "layer": layer
        ,"image": "_embedded/defaultWhite.png",
        color: [
            {
              r: 10,
              g: 10,
              b: 10
            }
          ],
    });
         this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 1.5 }],
          
          image: { name: 'chiken with ak.png' },

          position: [
            {
              x: () => Math.sin(Math.sin(getSceneTimeFromStart()*0.1)),
              y: () => 0.4,
              z: () => 0.
            }
          ],

          angle: [
            {
              degreesY: () => 0,
              degreesX: () => 0.5,
              degreesZ: () => 0
            }
          ]
        }
      ]);

       this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 1 }],
          
          image: { name: 'chiken with ak.png' },

          position: [
            {
              x: () => Math.sin(Math.sin(getSceneTimeFromStart()*0.1)),
              y: () => 0.3,
              z: () => 0
            }
          ],

          angle: [
            {
              degreesY: () => 0,
              degreesX: () => 0.5,
              degreesZ: () => 0
            }
          ]
        }
      ]);

               this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 1.5 }],
          
          image: { name: 'chiken with ak.png' },

          position: [
            {
              x: () => Math.sin(Math.sin(getSceneTimeFromStart()*0.1)),
              y: () => 0.35,
              z: () => 0.
            }
          ],

          angle: [
            {
              degreesY: () => 0,
              degreesX: () => 0.5,
              degreesZ: () => 0
            }
          ]
        }
      ]);

       this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 1 }],
          
          image: { name: 'chiken with ak.png' },

          position: [
            {
              x: () => Math.sin(Math.sin(getSceneTimeFromStart()*0.1)),
              y: () => 0.25,
              z: () => 0
            }
          ],

          angle: [
            {
              degreesY: () => 0,
              degreesX: () => 0.5,
              degreesZ: () => 0
            }
          ]
        }
      ]);

               this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 1.5 }],
          
          image: { name: 'chiken with ak.png' },

          position: [
            {
              x: () => Math.sin(Math.sin(getSceneTimeFromStart()*0.1)),
              y: () => 0.15,
              z: () => 0.
            }
          ],

          angle: [
            {
              degreesY: () => 0,
              degreesX: () => 0.5,
              degreesZ: () => 0
            }
          ]
        }
      ]);

       this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 1 }],
          
          image: { name: 'chiken with ak.png' },

          position: [
            {
              x: () => Math.sin(Math.sin(getSceneTimeFromStart()*0.1)),
              y: () => 0.2,
              z: () => 0
            }
          ],

          angle: [
            {
              degreesY: () => 0,
              degreesX: () => 0.5,
              degreesZ: () => 0
            }
          ]
        }
      ]);

               this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 1.5 }],
          
          image: { name: 'chiken with ak.png' },

          position: [
            {
              x: () => Math.sin(Math.sin(getSceneTimeFromStart()*0.1)),
              y: () => 0.1,
              z: () => 0.
            }
          ],

          angle: [
            {
              degreesY: () => 0,
              degreesX: () => 0.5,
              degreesZ: () => 0
            }
          ]
        }
      ]);

       this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 1 }],
          
          image: { name: 'chiken with ak.png' },

          position: [
            {
              x: () => Math.sin(Math.sin(getSceneTimeFromStart()*0.2)),
              y: () => 0.15,
              z: () => 0
            }
          ],

          angle: [
            {
              degreesY: () => 0,
              degreesX: () => 0.5,
              degreesZ: () => 0
            }
          ]
        }
      ]);


       this.loader.addAnimation([{
       "start": start, "duration": duration, "layer": layer,
    text:{string:'music by jumalauta ',name:"monoSpace.ttf"},
    perspective:"2d", 
    position:[{x:0, y:0}],
    scale: [{ uniform2d: 3.0 }],
    color: [
            {
              r: 0,
              g: 0.5,
              b: 0.5
            }
          ],
    }]);

  }
Demo.prototype.chiken = function (start, duration)
{
  var layer = 1; 
  this.loader.addAnimation(
    {
        "start": start, "duration": duration, "layer": layer
        ,"image": "_embedded/defaultWhite.png",
        color: [
            {
              r: 10,
              g: 10,
              b: 10
            }
          ],
    });

          this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 1 }],
          
          image: { name: 'chiken burns.png' },

          position: [
            {
              x: () => Math.sin(Math.sin(getSceneTimeFromStart()*-0.1)),
              y: () => 0.1,
              z: () => 0
            }
          ],

          angle: [
            {
              degreesY: () => 0,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);
for(let i = 0; i<100; i++)
{
       this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 0.5 }],
          
          image: { name: 'fire bulding.png' },
          position: [
            {
              x: () => -0.8+i*.1,
              y: () => -0.15,
              z: () => 0.
            }
          ],

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*1,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);

       this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 0.5 }],
          
          image: { name: 'fire bulding.png' },
          position: [
            {
              x: () => -1.3+i*.1,
              y: () => 0,
              z: () => 0.
            }
          ],

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*1,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);

        this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 0.5 }],
          
          image: { name: 'fire bulding.png' },
          position: [
            {
              x: () => -0.8+i*.1,
              y: () => -0.30,
              z: () => 0.
            }
          ],

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*1,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);

       this.loader.addAnimation([
        {
          start: start,
          duration: duration,
          layer: 500,
          scale: [{ uniform3d: 0.5 }],
          
          image: { name: 'fire bulding.png' },
          position: [
            {
              x: () => -1.3+i*.1,
              y: () => -0.5,
              z: () => 0.
            }
          ],

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*1,
              degreesX: () => 0,
              degreesZ: () => 0
            }
          ]
        }
      ]);

}

}