
/*
 *
 *  (c) BU Web Advanced
 *
 *
*/



var container = document.getElementById("container");


var renderer = new THREE.WebGLRenderer({ antialias: true });
// var renderer = new THREE.CanvasRenderer();
renderer.setSize(container.offsetWidth, container.offsetHeight);
container.appendChild( renderer.domElement );


var scene = new THREE.Scene();


var camera = new THREE.PerspectiveCamera( 45, container.offsetWidth / container.offsetHeight, 1, 4000 );
camera.position.set( 0, 2, 6 );
scene.add( camera );


var light = new THREE.DirectionalLight( 0xffffff, 1.5);
light.position.set(0, 1, 6);
scene.add( light );



var mesh = new THREE.Mesh();

var map = THREE.ImageUtils.loadTexture("models/texture.png");
var material = new THREE.MeshPhongMaterial({ map: map });

material.side = THREE.DoubleSide;

loader = new THREE.JSONLoader();
loader.load("models/myModel.js", onLoadComplete)



function onLoadComplete(geometry)
{
  mesh = new THREE.Mesh(geometry, material);
  mesh.position.y = 2;
  scene.add(mesh);
}








function changeCamera(rotX, rotY, rotZ) {
  $({
    rotX: mesh.rotation.x,
    rotY: mesh.rotation.y,
    rotZ: mesh.rotation.z
  }).animate({
    rotX: rotX,
    rotY: rotY,
    rotZ: rotZ
  },{
      duration: 500,
      step: function(){
        mesh.rotation.x = this.rotX;
        mesh.rotation.y = this.rotY;
        mesh.rotation.z = this.rotZ;
        renderer.render(scene, camera);
    }
  })
}



window.onresize = function() {

  $("canvas")[0].width = container.offsetWidth;
  $("canvas")[0].height = container.offsetHeight;
  
  renderer.setSize(container.offsetWidth, container.offsetHeight);
  camera.aspect = container.offsetWidth / container.offsetHeight;
  camera.updateProjectionMatrix();
}














/*

###### SNIPPETS ###########








// jquery Variable Counter
$({meineVar:1}).animate({meineVar:0},{
  step: function(){
  }
})



MeshLambertMaterial



2,.6,2.5

*/