提交 4a5e31b5 编写于 作者: M Mr.doob

Interactive-er webvr_cubes.

上级 5ac7c500
......@@ -107,9 +107,9 @@
object.scale.z = Math.random() + 0.5;
object.userData.velocity = new THREE.Vector3();
object.userData.velocity.x = Math.random() * 0.4 - 0.2;
object.userData.velocity.y = Math.random() * 0.4 - 0.2;
object.userData.velocity.z = Math.random() * 0.4 - 0.2;
object.userData.velocity.x = Math.random() - 0.5;
object.userData.velocity.y = Math.random() - 0.5;
object.userData.velocity.z = Math.random() - 0.5;
scene.add( object );
cubes.push( object );
......@@ -134,6 +134,17 @@
}
renderer.domElement.addEventListener( 'click', function ( event ) {
if ( INTERSECTED ) {
var object = INTERSECTED;
object.userData.velocity.subVectors( object.position, camera.position ).normalize();
}
} );
//
window.addEventListener( 'resize', onWindowResize, false );
......@@ -182,7 +193,7 @@
if ( INTERSECTED ) INTERSECTED.material.emissive.setHex( INTERSECTED.currentHex );
INTERSECTED = null;
INTERSECTED = undefined;
}
......@@ -192,6 +203,8 @@
var cube = cubes[ i ];
cube.userData.velocity.multiplyScalar( 0.999 );
cube.position.add( cube.userData.velocity );
if ( cube.position.x < - 100 || cube.position.x > 100 ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册