{
const renderer = new THREE.WebGLRenderer({antialias: false});
renderer.setSize(width,height);
renderer.setPixelRatio(window.devicePixelRatio);
renderer.autoClear = false;
renderer.setClearColor(0x00000, 0.0);
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(45, width / height, 0.1, 1000);
camera.position.z = 2;
scene.add(camera);
earthImgTexture.flipY = true;
earthBumpTexture.flipY = true;
earthCloudTexture.flipY = true;
earthGalaxyTexture.flipY = true;
const earth = new THREE.SphereGeometry(0.6,32,32);
const earth_material = new THREE.MeshPhongMaterial({
roughness : 1,
metalness:0,
map: earthImgTexture,
bumpMap: earthBumpTexture,
bumpScale: 0.3,
});
const earth_mesh = new THREE.Mesh(earth, earth_material)
scene.add(earth_mesh)
const galaxy = new THREE.SphereGeometry(80,64,64);
const galaxy_material = new THREE.MeshBasicMaterial({
map: earthGalaxyTexture ,
side: THREE.BackSide
});
const galaxy_mesh = new THREE.Mesh(galaxy,galaxy_material);
scene.add(galaxy_mesh);
const oura = new THREE.SphereGeometry(0.62,32,32)
const oura_matrial = getFresnelMat()
const oura_mesh = new THREE.Mesh(oura, oura_matrial);
scene.add(oura_mesh)
const cloud = new THREE.SphereGeometry(0.62,32,32);
const cloud_material = new THREE.MeshPhongMaterial({
map: earthCloudTexture,
transparent: true,
opacity:0.9
});
const cloud_mesh = new THREE.Mesh(cloud,cloud_material);
scene.add(cloud_mesh);
const ambientlight = new THREE.AmbientLight(0xffffff, 0.2);
scene.add(ambientlight);
const pointerlight = new THREE.PointLight(0xffffff,0.9);
pointerlight.position.set(5,3,5);
scene.add(pointerlight);
const animate = () =>{
requestAnimationFrame(animate);
earth_mesh.rotation.y -= 0.0010;
cloud_mesh.rotation.y += 0.0005;
oura_mesh.rotation.y += 0.0005;
galaxy_mesh.rotation.y += 0.0001;
render();
}
const render = () => {
renderer.render(scene,camera);
}
animate();
return renderer.domElement;
}