OBJLoader上的奇怪工件

时间:2014-03-12 17:30:52

标签: three.js

我正在尝试加载obj模型。

为什么表面会出现奇怪的边界伪影?

我做错了什么?我正在使用3D扫描仪创建obj模型。

谢谢。

/examples/webgl_loader_obj.html

function init() {

            container = document.createElement( 'div' );
            document.body.appendChild( container );

            camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 200000 );
            camera.position.z = 100;

            // scene

            scene = new THREE.Scene();

            var ambient = new THREE.AmbientLight( 0x101030 );
            scene.add( ambient );

            var directionalLight = new THREE.DirectionalLight( 0xffeedd );
            directionalLight.position.set( 1, 1, 1 );
            scene.add( directionalLight );


            //var directionalLight = new THREE.DirectionalLight( 0xffeedd );
            //directionalLight.position.set( 0, 0, -1 );
            //scene.add( directionalLight );

            // texture

            var manager = new THREE.LoadingManager();
            manager.onProgress = function ( item, loaded, total ) {

                console.log( item, loaded, total );

            };

            var texture = new THREE.Texture();

            var loader = new THREE.ImageLoader( manager );
            loader.load( 'textures/UV_Grid_Sm.jpg', function ( image ) {

                texture.image = image;
                texture.needsUpdate = true;
            } );

            // model

            var loader = new THREE.OBJLoader( manager );
            //loader.load( 'obj/male02/male02.obj', function ( object ) {
            loader.load( '/ramgl/models/textured_mesh.obj', function ( object ) {

                object.traverse( function ( child ) {

                    if ( child instanceof THREE.Mesh ) {

                        child.material.map = texture;

                        //child.material.side = THREE.DoubleSide;

                    }

                } );

                //object.position.y = - 80;


                object.scale.x = object.scale.y = object.scale.z = 1000;

                object.position.y = 300;
                object.position.x = -500;
                object.position.z = -100;

                object.rotation.x = 180 * Math.PI / 180;
                object.rotation.y = 30 * Math.PI / 180;


                scene.add( object );

            } );

            //

            renderer = new THREE.WebGLRenderer();
            renderer.setSize( window.innerWidth, window.innerHeight );
            container.appendChild( renderer.domElement );

            document.addEventListener( 'mousemove', onDocumentMouseMove, false );

            //

            window.addEventListener( 'resize', onWindowResize, false );

        }

/examples/webgl_loader_obj_mtl.html

        function init() {

            container = document.createElement( 'div' );
            document.body.appendChild( container );

            camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 20000 );
            camera.position.z = 100;

            // scene

            scene = new THREE.Scene();

            var ambient = new THREE.AmbientLight( 0x444444 );
            scene.add( ambient );


            var directionalLight = new THREE.DirectionalLight( 0xffeedd );
            //directionalLight.intensity = 0.5;
            directionalLight.position.set( 1, 0, 1 ).normalize();
            //directionalLight.onlyShadow = false;
            scene.add( directionalLight );

            var directionalLight = new THREE.DirectionalLight( 0xffeedd );
            directionalLight.position.set( 0, 0, -1 ).normalize();
            scene.add( directionalLight );


            // model

            var loader = new THREE.OBJMTLLoader();
            //loader.load( 'obj/male02/male02.obj', 'obj/male02/male02_dds.mtl', function ( object ) {
            //loader.load( '/ramgl/models/textured_mesh.obj', '/ramgl/models/textured_mesh.mtl', function ( object ) {
            loader.load( '/ramgl/models/textured_mesh.obj', '', function ( object ) {

                object.scale.x = object.scale.y = object.scale.z = 1000;

                object.position.y = 300;
                object.position.x = -500;
                object.position.z = -100;

                object.rotation.x = 180 * Math.PI / 180;
                object.rotation.y = 30 * Math.PI / 180;

                scene.add( object );
            } );

            //

            renderer = new THREE.WebGLRenderer();
            renderer.setSize( window.innerWidth, window.innerHeight );
            renderer.setClearColorHex( 0x333333, 1 );

            container.appendChild( renderer.domElement );

            document.addEventListener( 'mousemove', onDocumentMouseMove, false );

            //

            window.addEventListener( 'resize', onWindowResize, false );

        }

0 个答案:

没有答案