通过objectloader加载的场景,凹凸贴图无法渲染

时间:2017-10-20 16:13:40

标签: javascript three.js bump-mapping

尝试将凹凸贴图应用于加载的对象,但未在材质上看到

var loader = new THREE.ObjectLoader();
loader.load("../js/brain2.json", function(object) {
    var mapHeight = new THREE.TextureLoader().load( "../js/texture.jpg" );
    var material = new THREE.MeshPhongMaterial( { color: 0x888888, specular: 0xEEEEEE, shininess: 5} );

    object.traverse( function ( child ) {
        if ( child instanceof THREE.Mesh ) {
            child.material = material;
            child.material.bumpMap = mapHeight;
            child.material.bumpScale = 1;
            var geometry = new THREE.Geometry().fromBufferGeometry( child.geometry );
            geometry.computeFaceNormals();
            geometry.mergeVertices();
            geometry.computeVertexNormals();
            child.geometry = new THREE.BufferGeometry().fromGeometry( geometry );
            var modifier = new THREE.BufferSubdivisionModifier(1);
            modifier.modify(geometry);
            child.material.overdraw = 1
        };  
    });
    object.scale.set(15, 15, 15);
    object.position.x = 1;
    object.position.y = 1;
    object.position.z = 1;
    object.rotation.set( 5, 1, 1 );
    scene.add( object );
});

我已经修复了此代码的早期问题,包括对其应用细分修改器,但现在看来凹凸贴图拒绝应用。

0 个答案:

没有答案