【问题标题】:Loading gltf/glb without textures/colors issue using GLTF loader使用 GLTF 加载程序加载没有纹理/颜色问题的 gltf/glb
【发布时间】:2022-01-25 06:07:15
【问题描述】:

首先 - 我是 Three.js 的初学者。通过创建这个问题,我想留下有关在加载的 gltf 模型没有纹理时如何解决该问题的信息。

const loader = new GLTFLoader();
loader.load(
    // resource URL
    // PVPanelDataURI,
    process.env.PUBLIC_URL + 'staticPresets/PVPanel.gltf',
    (gltf) => {
        this.scene.add(gltf.scene);
        console.log('gltf', gltf)
    },
    function(xhr) {
        console.log((xhr.loaded / xhr.total * 100) + '% loaded');
    },
    function(error) {
        console.log('An error happened: ', error);
    }
);

另外,我想摆脱那个警告:

我将不胜感激。

【问题讨论】:

    标签: three.js 3d gltf


    【解决方案1】:

    有很多原因。有时您甚至可能会遇到损坏的 GLTF 文件。但如果你很幸运,那么你需要为你的模型创造光,一切都会好起来的!

    const ambientLight = new AmbientLight(0xFFFFFF);
    ambientLight.intensity = 4;
    this.scene.add( ambientLight );
    

    请注意,有时强度必须很大,而光线应该不同。我用过

    const spotLight = new THREE.SpotLight( 0xffffff );
    spotLight.intensity = 10;
    spotLight.position.set( 1000, 1000, 1000 );
    

    能够看到我的模型的黑色表面。此外,您可能需要在画布上导航以查看差异。

    【讨论】:

      猜你喜欢
      • 2022-12-01
      • 2021-07-10
      • 2021-11-12
      • 2022-07-09
      • 1970-01-01
      • 1970-01-01
      • 2019-02-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多