1、scene= new THREE.Scene();
2、camera的几个函数设置
camera = new THREE.PerspectiveCamera(VIEW_ANGLE, ASPECT, NEAR, FAR);
//照相机参数设定
camera.position.set(x,y,z);
//照相机的位置
camera.lookAt(scene.position);//这里的参数是个集合,所以要写成camera.lookAt(x: ,y: ,z:);这种形式
//照相机要看的点
2、renderer渲染窗口的设置
renderer = new THREE.WebGLRenderer({antialias:true} );
//建立renderer对象
renderer.setSize(SCREEN_WIDTH,SCREEN_HEIGHT);
//设置renderer的大小
container = document.getElementById( 'ThreeJS' );
//建立容器对象
container.appendChild( renderer.domElement);
//将renderer附在刚才创建的容器对象上。
3、light对象设置
var light = new THREE.PointLight(0xffffff);点光源设置
light.position.set(0,250,0);光源位置
scene.add(light);将光源对象附加在scene
4、mesh对象
首先:var sphereGeometry =new THREE.SphereGeometry( 半径, width的段数, height的段数 );
其次:var sphereMaterial =new THREE.MeshLambertMaterial( {color: 0x8888ff} );建立一种材质
再次:将前面两个建立的对象组成mesh对象var sphere = new THREE.Mesh(sphereGeometry, sphereMaterial);
然后:position.set(100, 50, -50);设置mesh的位置
最后:scene.add(sphere);将mesh加入sence中
5对每一帧刷新
function animate()
{
requestAnimationFrame( animate );//反复调用这个函数
render();//更新场景
update();//你要更新的其他内容
}
function render()
{
renderer.render( scene, camera );
}