|
@@ -26,11 +26,6 @@
|
|
|
|
|
|
var camera, scene, renderer;
|
|
|
|
|
|
- var mouseX = 0, mouseY = 0;
|
|
|
-
|
|
|
- var windowHalfX = window.innerWidth / 2;
|
|
|
- var windowHalfY = window.innerHeight / 2;
|
|
|
-
|
|
|
init();
|
|
|
animate();
|
|
|
|
|
@@ -39,8 +34,8 @@
|
|
|
container = document.createElement( 'div' );
|
|
|
document.body.appendChild( container );
|
|
|
|
|
|
- camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 10000 );
|
|
|
- camera.position.set( 0, 0, 1000 );
|
|
|
+ camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 0.1, 10 );
|
|
|
+ camera.position.set( 0, 0, 1 );
|
|
|
|
|
|
scene = new THREE.Scene();
|
|
|
|
|
@@ -50,7 +45,7 @@
|
|
|
|
|
|
for ( var i = 0; i < 100; i ++ ) {
|
|
|
|
|
|
- positions.push( 4000 * ( Math.random() - 0.5 ), 4000 * ( Math.random() - 0.5 ), 4000 * ( Math.random() - 0.5 ) );
|
|
|
+ positions.push( Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5 );
|
|
|
|
|
|
var clr = colorArray[ Math.floor( Math.random() * colorArray.length ) ];
|
|
|
|
|
@@ -78,17 +73,12 @@
|
|
|
|
|
|
//
|
|
|
|
|
|
- document.addEventListener( 'mousemove', onDocumentMouseMove, false );
|
|
|
-
|
|
|
window.addEventListener( 'resize', onWindowResize, false );
|
|
|
|
|
|
}
|
|
|
|
|
|
function onWindowResize() {
|
|
|
|
|
|
- windowHalfX = window.innerWidth / 2;
|
|
|
- windowHalfY = window.innerHeight / 2;
|
|
|
-
|
|
|
camera.aspect = window.innerWidth / window.innerHeight;
|
|
|
camera.updateProjectionMatrix();
|
|
|
|
|
@@ -96,13 +86,6 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- function onDocumentMouseMove( event ) {
|
|
|
-
|
|
|
- mouseX = ( event.clientX - windowHalfX ) * 10;
|
|
|
- mouseY = ( event.clientY - windowHalfY ) * 10;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
//
|
|
|
|
|
|
function animate() {
|
|
@@ -116,10 +99,7 @@
|
|
|
|
|
|
function render() {
|
|
|
|
|
|
- camera.position.x += ( mouseX - camera.position.x ) * .05;
|
|
|
- camera.position.y += ( - mouseY - camera.position.y ) * .05;
|
|
|
-
|
|
|
- camera.lookAt( scene.position );
|
|
|
+ scene.rotation.y = Date.now() / 2000;
|
|
|
|
|
|
renderer.render( scene, camera );
|
|
|
|