-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain2.js
38 lines (31 loc) · 966 Bytes
/
main2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function main()
{
var width = 500;
var height = 500;
var scene = new THREE.Scene();
var fov = 45;
var aspect = width / height;
var near = 1;
var far = 1000;
var camera = new THREE.PerspectiveCamera( fov, aspect, near, far );
camera.position.set( 0, 0, 5 );
scene.add( camera );
var renderer = new THREE.WebGLRenderer();
renderer.setSize( width, height );
document.body.appendChild( renderer.domElement );
var geometry = new THREE.BoxGeometry( 1, 1, 1 );
var material = new THREE.MeshLambertMaterial( { color: 0xffffff } );
var cube = new THREE.Mesh( geometry, material );
scene.add( cube );
var light = new THREE.PointLight(0xffffff);
light.position.set( 1,1,1 );
scene.add( light );
function loop()
{
requestAnimationFrame( loop );
cube.rotation.x += 0.001;
cube.rotation.y += 0.001;
renderer.render( scene, camera );
}
loop();
}