首页 > 解决方案 > Three.js:TypeError:无法读取未定义的属性“0”

问题描述

我是 Three.js 的新手,并不完全熟悉。在我的新项目中,我正在尝试使用GLTFLoader(). 但它给了我一个我不明白的错误。这是我第一次遇到这个错误。

这是错误:

TypeError: Cannot read property '0' of undefined
    at Application.js:41
    at GLTFLoader.js:147
    at GLTFLoader.js:1639

但是当我将它导入到https://gltf.insimo.com时,它显示得非常好。所以我的这个错误。这就是我加载 gltf 的方式:

this.gltfLoader.load('/corolla.gltf', (_corolla) => {
            this.resources.corolla = _corolla.children[0]

            // Set environment
            this.setEnvironment()
        }, (xhr) => {
            console.log(Math.round(xhr.loaded / xhr.total * 100) + '% loaded');
        }, (error) => {
            console.log('An error happened: ', error);
        });

标签: javascriptthree.js

解决方案


推荐阅读