Ocularus

Hello,
My name is M. Kenan Yigitoglu
I am UI Designer
and Developer from
Netherlands.

40.758896° N
-73.985130° W


+31 625 54 43 80

hello@mkyigitoglu.com

Three.js Source Code

    

$(function () { 

  var webglEl = document.getElementById('WebGL-output');



  var width  = window.innerWidth,
  height = window.innerHeight;

  // Earth params
  var radius   = 0.5,
  segments = 32,
  rotation = 6;  

  var scene = new THREE.Scene();
  var sceneOrtho = new THREE.Scene();

  var camera = new THREE.PerspectiveCamera(45 , window.innerWidth / window.innerHeight , 0.1, 1000); 
  camera.position.x = 0; 
  camera.position.y = 0; 
  camera.position.z = -2; 
  camera.lookAt(scene.position); 

  cameraOrtho = new THREE.OrthographicCamera();

  var renderer = new THREE.WebGLRenderer();
  renderer.autoClear = false;
  renderer.setSize(width, height);

  scene.add(new THREE.AmbientLight(0x333333));

  var light = new THREE.DirectionalLight(0xffffff, 0.3);
  light.position.set(5,3,5);
  scene.add(light);

  //create two spotlights to illuminate the scene
  var spotLight = new THREE.SpotLight( 0xffffff ); 
  spotLight.position.set( -40, 60, -10 ); 
  spotLight.intensity = 2;
  scene.add( spotLight );

  var spotLight2 = new THREE.SpotLight( 0x5192e9 ); 
  spotLight2.position.set( 40, -60, 30 );  
  spotLight2.intensity = 1.5;
  scene.add( spotLight2 );


  /*var stars = createStars(90, 64);
  scene.add(stars);*/

  var spacetex = THREE.ImageUtils.loadTexture("images/bone_8.jpg");
  var spacesphereGeo = new THREE.SphereGeometry(20,20,20);
  var spacesphereMat = new THREE.MeshPhongMaterial();
  spacesphereMat.map = spacetex;

  var spacesphere = new THREE.Mesh(spacesphereGeo,spacesphereMat);
  
  //spacesphere needs to be double sided as the camera is within the spacesphere
  spacesphere.material.side = THREE.DoubleSide;
  
  spacesphere.material.map.wrapS = THREE.RepeatWrapping; 
  spacesphere.material.map.wrapT = THREE.RepeatWrapping;
  spacesphere.material.map.repeat.set( 5, 3);
  
  scene.add(spacesphere);

  webglEl.appendChild(renderer.domElement);

  render();

  function render() {
  spacesphere.rotation.y += 0.001;
  renderer.clear();
  requestAnimationFrame(render);
  renderer.render(scene, camera);
  renderer.clearDepth();
  renderer.render( sceneOrtho, cameraOrtho ); 
}




window.addEventListener( 'resize', onWindowResize, false );

function onWindowResize(){

    camera.aspect = window.innerWidth / window.innerHeight;
    camera.updateProjectionMatrix();
    renderer.setSize( window.innerWidth, window.innerHeight );
}
});