javascript - Three.js Importing gltf without a background
问题描述
There are 2 example scenes on Three.js (I'm using), that are teaching how to import gltf models.
Both using a RGBELoader function, which does initialize the background.
new RGBELoader()
.setDataType( THREE.UnsignedByteType )
.setPath( 'textures/equirectangular/' )
.load( 'venice_sunset_2k.hdr', function ( texture ) {
var cubeGenerator = new EquirectangularToCubeGenerator( texture, { resolution: 1024 } );
cubeGenerator.update( renderer );
//background = cubeGenerator.renderTarget;
var pmremGenerator = new PMREMGenerator( cubeGenerator.renderTarget.texture );
pmremGenerator.update( renderer );
var pmremCubeUVPacker = new PMREMCubeUVPacker( pmremGenerator.cubeLods );
pmremCubeUVPacker.update( renderer );
envMap = pmremCubeUVPacker.CubeUVRenderTarget.texture;
pmremGenerator.dispose();
pmremCubeUVPacker.dispose();
I want now to get a empty background (or just a ground or smth) without loading that background.
It works to comment the "background" line in the code to see my object and NOT the background, but it should be unnecessary to load the textures for the background. When I'm commenting/deleting more things my object has no texture.
How can I see the helmet/boombox (example object in the example scene "gltf loader") and get rid of the background? I know that it has something to do with the "envmap"..
解决方案
但应该没有必要为背景加载纹理。
立方体纹理也用于 glTF 模型的环境贴图。因此,如果您真的想删除它,则必须删除webgl_loader_gltf中的以下代码部分。
gltf.scene.traverse( function ( child ) {
if ( child.isMesh ) {
child.material.envMap = envMap;
}
} );
但是,这样做时头盔会或多或少变暗,因为环境贴图是场景中唯一的(间接)光源。然后,您可能想要添加环境光和定向光或点光。
three.js R109
推荐阅读
- python - Python 脚本返回 KafkaTimeoutError:60.0 秒后更新元数据失败
- jquery - 当滑块向左/向右改变时,如何为 owlcarousel 卡片设置动画
- json - 如何解析 JSON 输入
- python - 如何解决 python shopify api InvalidURL:非数字端口:错误
- firebase - 如何在 React Native 中显示来自 Firebase 的对象列表?
- javascript - 将 Syncfusion Dashboard 安装到本地计算机
- wordpress - 是否可以备份具有所有卷/数据/状态的 Docker 容器?
- typescript - Graphql 文件中的查询需要大括号
- python-3.x - 如何从python调用和管道多个postgres命令
- hangout - Google Hangout 生成访问令牌的范围是什么?