类型错误:无法在 THREE 中设置 null 的属性(设置"编码.js



我正试图从Minecraft加载一个简单的草块,它显示了一个错误,从GLTFLoader行2893读取TypeError: Cannot set properties of null (setting 'encoding'),该行只显示texture.encoding = encoding;。我没有使用纹理,所以我不确定为什么它会显示这个错误。以下代码加载草块。

const loader = new THREE.GLTFLoader();
loader.load(
'https://cdn.glitch.global/c7ffc3e9-df32-4837-b046-23be12a0896a/minecraft_grass_block.glb?v=1664906819996',

function ( gltf ) {
scene.add( gltf.scene );
gltf.animations; // Array<THREE.AnimationClip>
var grass = gltf.scene; // THREE.Group
gltf.scenes; // Array<THREE.Group>
gltf.cameras; // Array<THREE.Camera>
gltf.asset; // Object
console.log(grass)
},
// called while loading is progressing
function ( xhr ) {
console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
},
// called when loading has errors
function ( error ) {
console.log( error );
}
);

以下是完整的错误:

TypeError: Cannot set properties of null (setting 'encoding')
at GLTFLoader.js:2893:23
at async Promise.all (index 0)
at async Promise.all (index 0)
at async Promise.all (index 0)
at async Promise.all (index 0)
at async Promise.all (index 0)
at async Promise.all (index 0)
at async Promise.all (index 0)
at async Promise.all (index 0)
THREE.GLTFLoader: Couldn't load texture blob:null/23946df4-f704-42bc-a59d-bd78afa6a4fc

至少有一个纹理无法加载。它可能不见了。查看网络选项卡查找404错误,您可能会在那里找到丢失的图像。

最新更新