three.js更改场景中网格的材质。 72dev

时间:2015-04-07 08:09:00

标签: three.js material

我使用ObjectLoader加载对象并遍历场景以查找我想要更改材质的对象。

纹理(slika1.bmp)

http://s000.tinyupload.com/?file_id=11056683794946179258

更改材质后,对象如下所示:

http://s000.tinyupload.com/?file_id=03184439289213441291

纹理应该在几何体上划线,而不仅仅是纹理角落的单一颜色。代码是:

function pc(){
    var manager = new THREE.LoadingManager();
    manager.onProgress = function ( item, loaded, total ) {
        console.log(item,loaded,total);
    };
    var texture = new THREE.Texture();
    var imageLoader = new THREE.ImageLoader(manager);
    imageLoader.load("models/pc/slika1.bmp", function (image){
            texture.image=image;
/*          //Tried different things
            texture.minFilter = THREE.NearestFilter;
            texture.minFilter = THREE.LinearMipMapLinearFilter;
            texture.wrapS = THREE.ClampToEdgeWrapping;
            texture.wrapT = THREE.ClampToEdgeWrapping;
            texture.anistropy = renderer.getMaxAnisotropy();
            texture.needsUpdate = true;
*/          
    });



    var loader = new THREE.ObjectLoader(manager);
        loader.load(
        'models/pc/pc7_test.json',
        function ( result ){
            result.scale.set(7,7,7)

        scene.add(result);
        scene.traverse ( function ( object){

        if ( object.name == 'ekranSlika' ) {
            slikaEkran1.minFilter= THREE.NearestFilter;
            EkranSlika1M = new THREE.MeshBasicMaterial({ map: slikaEkran1});
            EkranSlika1M.map.wrapS = EkranSlika1M.map.wrapT = THREE.ClampToEdgeWrapping;
            //Tried different things:
            object.geometry.computeBoundingBox();
            object.material = EkranSlika1M;         
            object.buffersNeedUpdate = true;
            object.geometry.uvsNeedUpdate = true;
            object.needsUpdate=true;
            object.material.needsUpdate=true;
            //object.material.map.needsUpdate=true;
        }

0 个答案:

没有答案