Three.js导入模型抗锯齿

时间:2014-10-13 07:36:13

标签: javascript html5 three.js

我将一个OBJ模型导入一个场景,但它没有抗锯齿,我无法弄清楚,如何使它平滑。搅拌机打开它平滑。

内置几何体(例如new THREE.SphereGeometry(4, 20, 20);)也很流畅。

渲染器:

    var renderer = new THREE.WebGLRenderer({antialias: true, alpha: true});

材料:

    var modelMaterial = new THREE.MeshPhongMaterial({
        color: 0xb9d5ff,
        ambient: 0xfff660,
        shininess: 100,
        wireframe: false,
        transparent: true,
        opacity: 0.8,
        side: THREE.DoubleSide,
        combine: THREE.MixOperation
    });

导入:

    var manager = new THREE.LoadingManager();
    manager.onProgress = function(item, loaded, total) {
        console.log(item, loaded, total);
    };
    var loader = new THREE.OBJLoader(manager);
    loader.load('BlondeElexis-nude.obj', function(object) {
        object.traverse(function(child) {
            if (child instanceof THREE.Mesh) {
                console.log(child);
                child.material = modelMaterial;
            }
        });
        object.position.y = 0;
        object.scale.x = 6;
        object.scale.y = 6;
        object.scale.z = 6;
        human = object;
        scene.add(human);
    });

结果:

enter image description here

1 个答案:

答案 0 :(得分:2)

实测值:

child.geometry.computeVertexNormals();

结果不是最好的,但更好的是没有。