美文网首页WebGL
15three.js加载obj模型

15three.js加载obj模型

作者: 狂暴机甲 | 来源:发表于2017-08-07 17:30 被阅读58次

    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();

    相关文章

      网友评论

        本文标题:15three.js加载obj模型

        本文链接:https://www.haomeiwen.com/subject/kdealxtx.html