提交 6a7d187e 编写于 作者: M Mr.doob

Clean up of canvas performance example.

上级 8a9e567c
......@@ -25,7 +25,7 @@
var camera, scene, renderer;
var sphere, plane;
var light;
init();
animate();
......@@ -35,10 +35,12 @@
container = document.createElement( 'div' );
document.body.appendChild( container );
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 );
camera.position.set( 0, 1000, 1000 );
camera.lookAt( scene.position );
scene = new THREE.Scene();
// Grid
......@@ -69,7 +71,7 @@
for ( var i = 0; i < 20; i ++ ) {
sphere = new THREE.Mesh( geometry, material );
var sphere = new THREE.Mesh( geometry, material );
sphere.position.x = ( i % 5 ) * 200 - 400;
sphere.position.z = Math.floor( i / 5 ) * 200 - 400;
......@@ -87,12 +89,11 @@
directionalLight.position.set( 0, 1, 0 );
scene.add( directionalLight );
var pointLight = new THREE.PointLight( 0xff0000, 1, 500 );
scene.add( pointLight );
light = new THREE.PointLight( 0xff0000, 1, 500 );
scene.add( light );
renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
stats = new Stats();
......@@ -128,7 +129,11 @@
function render() {
camera.lookAt( scene.position );
var timer = Date.now() * 0.001;
light.position.x = Math.cos( timer ) * 1000;
light.position.y = 500;
light.position.z = Math.sin( timer ) * 1000;
renderer.render( scene, camera );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册