three.js加载obj模型
varscene =newTHREE.Scene();
varloader =newTHREE.OBJLoader();
loader.load('mod/tmxkmid.obj','mod/tmxkmid.mtl',function(modObject){
modObject.scale.set(10,10,10);
modObject.position.z=-100;
modObject.position.y=80;
scene.add(modObject);
});
varlight =newTHREE.PointLight(0xffffff);
light.position.set(300,400,200);
scene.add(light);
varlight1 =newTHREE.AmbientLight(0x808080);
scene.add(light1);
varcamera =newTHREE.PerspectiveCamera(40,800/600,1,1000);
camera.position.set(200,220,200);
camera.lookAt(scene.position);
varrenderer =newTHREE.WebGLRenderer();
renderer.setSize(800,600);
document.body.appendChild(renderer.domElement);
functionrender() {
renderer.render(scene,camera);
}
render();
varcontrols =newTHREE.OrbitControls(camera);
controls.addEventListener('change',render);
functionanimate() {
requestAnimationFrame(animate);
render();
}
animate();
网友评论