本文主要是介绍threejs 展示gltf模型加了环境光,全黑,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
- 首先确定是否是gltf格式出现原因:
使用glft viewer 确定gltf 能否展示 https://gltf-viewer.donmccurdy.com/ - 查看exposure是否为大于0的数,在webGLRender 中设置
- 查看emissive和emssiveMap:
如果使用环境光看到黑色(或者其他纯色),将emssive设置为material.color,如果有纹理,将纹理赋值给emssiMap。var loader = new THREE.GLTFLoader();loader.load( 'xxx.gltf', function ( gltf ) {// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//需要添加的部分gltf.scene.traverse( function ( child ) {if ( child.isMesh ) {child.material.emissive = child.material.color;child.material.emissiveMap = child.material.map ;}} ); // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ scene.add( gltf.scene );}, undefined, function ( e ) {console.error( e );} );
这篇关于threejs 展示gltf模型加了环境光,全黑的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!