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

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


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


}

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

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

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

    this.loader.addAnimation(
        {
            "start": start, "duration": duration, "layer": layer
            ,"image": "_embedded/defaultWhite.png",
            scale: [{ uniform3d: 0.2 }],
            color: [
                {
                  r: 0,
                  g: 0.5,
                  b: 1
                }
              ],
              position: [
                {
                  x: () => 0.3*Math.sin(Math.sin(getSceneTimeFromStart()*5)),
                  y: () => 0.3*Math.sin(Math.sin(getSceneTimeFromStart()*5)),
                  z: () => 0
                }
              ]
        });
        this.loader.addAnimation(
            {
                "start": start, "duration": duration, "layer": layer
                ,"image": "_embedded/defaultWhite.png",
                scale: [{ uniform3d: 0.2 }],
                color: [
                    {
                      r: 0,
                      g: 0.5,
                      b: 1
                    }
                  ],
                  position: [
                    {
                      x: () => 0.3*Math.sin(Math.sin(getSceneTimeFromStart()*5)),
                      y: () => -0.3*Math.sin(Math.sin(getSceneTimeFromStart()*5)),
                      z: () => 0
                    }
                  ]
            });
            
            for(let i = 0; i<2; i++)
            {
                this.loader.addAnimation(
                    {
                        "start": start, "duration": duration, "layer": layer
                        ,"image": "_embedded/defaultWhite.png",
                        scale: [{ uniform3d: 0.2 }],
                        color: [
                            {
                            r: 0,
                            g: 0.5,
                            b: 0,
                            a: () => Math.sin(getSceneTimeFromStart()*4+i) 
                            }
                        ],
                        position: [
                            {
                            x: () => 0.4 - (0.8 * i),
                            y: () => 0.4,
                            z: () => 0
                            }
                        ]
                    });
            }
            for(let i = 0; i<2; i++)
                {
                    this.loader.addAnimation(
                        {
                            "start": start, "duration": duration, "layer": layer
                            ,"image": "_embedded/defaultWhite.png",
                            scale: [{ uniform3d: 0.2 }],
                            color: [
                                {
                                r: 0,
                                g: 1.0,
                                b: 0.3,
                                a: () => Math.sin(getSceneTimeFromStart()*5+i) 
                                }
                            ],
                            position: [
                                {
                                x: () => 0.4 - (0.8 * i),
                                y: () => -0.4,
                                z: () => 0
                                }
                            ]
                        });
                }
    

    this.loader.addAnimation({
        start: start,
        duration: duration,
        layer: 500,
        light: {
          type: 'Directional',
          // animate intensity
          properties: { intensity: () => 13 }
        },
        color: [{ r: 1.0, g: 1.0, b: 1.0 }],
        position: [
          {
            x: () => 0,
            y: () => 2,
            z: () => 1
          }
        ]
      });

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

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*150,
              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 }],
          
          object: { name: 'EGG.obj' },
          position: [
            {
              x: () => -1,
              y: () => Math.sin(Math.sin(getSceneTimeFromStart()*5)),
              z: () => -1.
            }
          ],

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

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

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

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*150,
              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: 'Munakas.obj' },
           color: [
            {
              r: 0,
              g: 0,
              b: 0
            }
          ],
          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: 'Munakas.obj' },
           color: [
            {
              r: 100,
              g: 100,
              b: 100
            }
          ],
          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 }],
          
          object: { name: 'paistin pannu.obj' },
           color: [
            {
              r: 10,
              g: 10,
              b: 0
            }
          ],
          position: [
            {
              x: () => 1,
              y: () => Math.sin(Math.sin(getSceneTimeFromStart()*2)),
              z: () => 1.
            }
          ],

          angle: [
            {
              degreesY: () => getSceneTimeFromStart()*150,
              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 }],
          
          object: { name: 'chicken.obj' },
           color: [
            {
              r: 2,
              g: 2,
              b: 2
            }
          ],
          position: [
            {
              x: () => 1,
              y: () => -1,
              z: () => 1.
            }
          ],

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

       this.loader.addAnimation([{
       "start": start, "duration": duration, "layer": layer,
    text:{string:'Ponk Ponk Ponk Ponk Ponk Pok bok Ponk Ponk Ponk Ponk Ponk Ponk Ponk Ponk Ponk \n Ponk Ponk Ponk Ponk Ponk Ponk bonk Ponk Ponk Ponk Ponk Ponk Ponk Ponk Ponk Ponk \n Ponk Ponk Ponk Ponk Ponk Ponk Ponk Ponk Ponk Ponk Ponk Ponk moi Ponk Ponk Ponk \n  Ponk Ponk Ponk Ponk Ponk moi Ponk Ponk Ponk Ponk Ponk Ponk Ponk Ponk Ponk Ponk \n Ponk Ponk Ponk Ponk Ponk Ponk Ponk Ponk Ponk Ponk Ponk Ponk Ponk Ponk Ponk ',name:"monoSpace.ttf"},
    perspective:"2d", 
    position:[{x:0, y:0}],
    scale: [{ uniform2d: 3.0 }],
    color: [
            {
              r: 0,
              g: 0.5,
              b: 0.5
            }
          ],
    }]);

  }