45. let width = window.innerWidth;
let height = window.innerHeight;
let renderer =
new THREE.WebGLRenderer({antialias: true});
renderer.setPixelRatio(window.devicePixelRatio);
document.body.appendChild(renderer.domElement);
46. let aspect = width / height;
let camera =
new THREE.PerspectiveCamera(75, aspect, 0.1, 100);
let scene = new THREE.Scene();
47. let skysphereLoader = new THREE.TextureLoader();
skysphereLoader.load('img/bg_skyplane.png', (texture)
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set(4, 4);
let geometry =
new THREE.SphereGeometry(5000, 128, 128);
let material =
new THREE.MeshBasicMaterial({
map: texture,
color: 0xffffff,
side: THREE.BackSide
});
let skysphere = new THREE.Mesh(geometry, material);
skysphere.position.z = 0;
scene.add(skysphere);
});
48. let earth = new THREE.Object3D();
let earthLoader = new THREE.TextureLoader();
earthLoader.load(‘img/earth.jpg',
(texture) => {
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
let geometry =
new THREE.SphereGeometry(0.3, 32, 32);
let material =
new THREE.MeshLambertMaterial({
map: texture,
color: 0xffffff
});
earth = new THREE.Mesh(geometry, material);
earth.position.z = -1;
scene.add(earth);
});
49. let light = new THREE.DirectionalLight(0xffffff);
light.position.set(1, 1, 1);
scene.add(light);
57. let width = window.innerWidth;
let height = window.innerHeight;
let renderer =
new THREE.WebGLRenderer({antialias: true});
renderer.setPixelRatio(window.devicePixelRatio);
document.body.appendChild(renderer.domElement);
let vreffect = new THREE.VREffect(renderer);
vreffect.setSize(width, height);
58. let aspect = width / height;
let camera =
new THREE.PerspectiveCamera(75, aspect, 0.1, 100);
let vrcontrols = new THREE.VRControls(camera);
let scene = new THREE.Scene();