Three.js细分和纹理

时间:2014-07-31 09:35:45

标签: three.js

我正在尝试使用OBJLoader加载一个对象并细分每个几何体,因此它看起来更平滑......但是当我这样做时,纹理正在被破坏。如何避免?

            var modifier = new THREE.SubdivisionModifier(4);

            var loader = new THREE.OBJLoader( manager );
            loader.load( 'obj/'+model+'.obj', function ( object ) {

                var reflection = THREE.ImageUtils.loadTextureCube( [ 'additional/background.jpg', 'additional/background.jpg', 'additional/background_top.jpg', 'additional/background_down.jpg', 'additional/background.jpg', 'additional/background.jpg' ] );

                object.traverse( function ( child ) {

                    if ( child instanceof THREE.Mesh ) {


                        child.geometry.mergeVertices()
                        child.geometry.computeFaceNormals();
                        child.geometry.computeVertexNormals();
                        child.material.map = texture;



                        if(reflex){
                            child.material.envMap = reflection;
                            child.material.reflectivity = reflex;
                        }

                        modifier.modify(child.geometry);

                    }

                } );

0 个答案:

没有答案