0

我已经导入了一个 JSON 模型,导入了几何和材质。

loader = new THREE.JSONLoader();

            loader.load( "alisopoli/alisopoli.js", function( geometry, materials ) {
                for ( var i = 0; i < materials.length; i ++ ) {
                    materials[ i ].side = THREE.DoubleSide;
                    materials[ i ].alphaTest = 0.75;
                    materials[ i ].overdraw = true;
                }
                mesh = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ) );
                mesh.overdraw = true;
                scene.add( mesh );
            } );

该模型有很多材质(超过 30 种),我需要在它们的每个纹理中添加“THREE.nearestFilter”。有可能做这样的事情吗?

loader.load( "model.js", function( geometry, materials ) {
    var modelMaterials = new THREE.MeshFaceMaterial( materials );
    var modelTextures = modelMaterials.map
    moderTextures.minFilter = THREE.nearestFilter;
    mesh = new THREE.Mesh( geometry, modelMaterials );
    scene.add( mesh );
} );

我想编辑模型每个纹理的“minFilter”和“magFilter”(如果可能,所有渲染场景)。提前致谢!

4

1 回答 1

0

传递给函数的材料参数实际上是所有材料的数组。您可以做的是遍历该数组并为每个数组设置 minFilter,如下所示:

loader.load( "model.js", function( geometry, materials ) {
    for ( var i = 0; i < materials.length; i++ ) {
        materials[i].map.minFilter = THREE.NearestFilter;
        materials[i].map.magFilter = THREE.NearestFilter;
    }
    mesh = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ) );
    scene.add( mesh );
} );

这应该够了吧。

于 2013-08-13T17:46:50.113 回答