|
@@ -51,6 +51,7 @@
|
|
|
|
|
|
var container, stats;
|
|
var container, stats;
|
|
var camera, scene, renderer;
|
|
var camera, scene, renderer;
|
|
|
|
+ var sphere;
|
|
|
|
|
|
var parameters = {
|
|
var parameters = {
|
|
width: 2000,
|
|
width: 2000,
|
|
@@ -77,20 +78,20 @@
|
|
container.appendChild( renderer.domElement );
|
|
container.appendChild( renderer.domElement );
|
|
|
|
|
|
scene = new THREE.Scene();
|
|
scene = new THREE.Scene();
|
|
- camera = new THREE.PerspectiveCamera( 55, window.innerWidth / window.innerHeight, 0.5, 3000000 );
|
|
|
|
|
|
|
|
- camera.position.set( 0, Math.max( parameters.width * 1.5, parameters.height ) / 8, parameters.height );
|
|
|
|
- camera.lookAt( new THREE.Vector3( 0, 0, 0 ) );
|
|
|
|
|
|
+ camera = new THREE.PerspectiveCamera( 55, window.innerWidth / window.innerHeight, 0.5, 3000000 );
|
|
|
|
+ camera.position.set( 2000, 750, 2000 );
|
|
|
|
|
|
controls = new THREE.OrbitControls( camera, renderer.domElement );
|
|
controls = new THREE.OrbitControls( camera, renderer.domElement );
|
|
controls.userPan = false;
|
|
controls.userPan = false;
|
|
controls.userPanSpeed = 0.0;
|
|
controls.userPanSpeed = 0.0;
|
|
controls.maxDistance = 5000.0;
|
|
controls.maxDistance = 5000.0;
|
|
controls.maxPolarAngle = Math.PI * 0.495;
|
|
controls.maxPolarAngle = Math.PI * 0.495;
|
|
|
|
+ controls.center.set( 0, 500, 0 );
|
|
|
|
|
|
- directionalLight = new THREE.DirectionalLight( 0xffff55, 1 );
|
|
|
|
- directionalLight.position.set( - 1, 0.4, - 1 );
|
|
|
|
- scene.add( directionalLight );
|
|
|
|
|
|
+ var light = new THREE.HemisphereLight( 0xffffbb, 0x080820, 1 );
|
|
|
|
+ light.position.set( - 1, 1, - 1 );
|
|
|
|
+ scene.add( light );
|
|
|
|
|
|
|
|
|
|
waterNormals = new THREE.ImageUtils.loadTexture( 'textures/waternormals.jpg' );
|
|
waterNormals = new THREE.ImageUtils.loadTexture( 'textures/waternormals.jpg' );
|
|
@@ -101,7 +102,7 @@
|
|
textureHeight: 512,
|
|
textureHeight: 512,
|
|
waterNormals: waterNormals,
|
|
waterNormals: waterNormals,
|
|
alpha: 1.0,
|
|
alpha: 1.0,
|
|
- sunDirection: directionalLight.position.normalize(),
|
|
|
|
|
|
+ sunDirection: light.position.clone().normalize(),
|
|
sunColor: 0xffffff,
|
|
sunColor: 0xffffff,
|
|
waterColor: 0x001e0f,
|
|
waterColor: 0x001e0f,
|
|
distortionScale: 50.0,
|
|
distortionScale: 50.0,
|
|
@@ -171,6 +172,24 @@
|
|
|
|
|
|
scene.add( skyBox );
|
|
scene.add( skyBox );
|
|
|
|
|
|
|
|
+
|
|
|
|
+ var geometry = new THREE.IcosahedronGeometry( 400, 4 );
|
|
|
|
+
|
|
|
|
+ for ( var i = 0, j = geometry.faces.length; i < j; i ++ ) {
|
|
|
|
+
|
|
|
|
+ geometry.faces[ i ].color.setHex( Math.random() * 0xffffff );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var material = new THREE.MeshPhongMaterial( {
|
|
|
|
+ vertexColors: THREE.FaceColors,
|
|
|
|
+ shininess: 100,
|
|
|
|
+ envMap: cubeMap
|
|
|
|
+ } );
|
|
|
|
+
|
|
|
|
+ sphere = new THREE.Mesh( geometry, material );
|
|
|
|
+ scene.add( sphere );
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
//
|
|
//
|
|
@@ -184,6 +203,12 @@
|
|
|
|
|
|
function render() {
|
|
function render() {
|
|
|
|
|
|
|
|
+ var time = performance.now() * 0.001;
|
|
|
|
+
|
|
|
|
+ sphere.position.y = Math.sin( time ) * 500 + 250;
|
|
|
|
+ sphere.rotation.x = time * 0.5;
|
|
|
|
+ sphere.rotation.z = time * 0.51;
|
|
|
|
+
|
|
water.material.uniforms.time.value += 1.0 / 60.0;
|
|
water.material.uniforms.time.value += 1.0 / 60.0;
|
|
controls.update();
|
|
controls.update();
|
|
water.render();
|
|
water.render();
|