gpt4 book ai didi

three.js - GLTFLoader 错误 : Cannot read property 'itemStart' of undefined

转载 作者:行者123 更新时间:2023-12-04 00:59:32 25 4
gpt4 key购买 nike

为了节省 12 兆字节,我必须从 OBJloader 切换到 GLTFLoader,但出现错误:

Uncaught TypeError: Cannot read property 'itemStart' of undefined



html
  <script src="https://cdn.rawgit.com/mrdoob/three.js/master/examples/js/loaders/GLTFLoader.js"></script>

...

// Load the creature
function load_creature()
{
// creature loader

var images = [
"./textures/00.jpg",
];


var texture = new THREE.TextureLoader().load( images[0] );

// var loader = new THREE.OBJLoader();
var loader = new THREE.GLTFLoader();


// var creature = './obj/trex.obj'
var creature = './gltf/trex.gltf'

// Load a glTF resource
loader.load(

// resource URL
'./gltf/rex.gltf',

// called when the resource is loaded
function ( gltf ) {

scene.add( gltf.scene );

gltf.animations; // Array<THREE.AnimationClip>
gltf.scene; // THREE.Scene
gltf.scenes; // Array<THREE.Scene>
gltf.cameras; // Array<THREE.Camera>
gltf.asset; // Object

},
// called while loading is progressing
function ( xhr ) {

console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );

},
// called when loading has errors
function ( error ) {

console.log( 'An error happened' );

}
);


// Load creature
var trex = load_creature();

我是 Three.js 的新手,我看不出哪里出错了。有任何想法吗?

最佳答案

当您在项目中打开控制台时,您可以在第一行看到 ThreeJS 版本:

THREE.WebGLRenderer 96



确保您的 GLTFLoader 具有相同的版本。所以在我的情况下是 96。

https://rawcdn.githack.com/mrdoob/three.js/r96/examples/js/loaders/GLTFLoader.js

确保将 URL 的粗体部分修改为 ThreeJS 版本以获得正确的代码。

感谢 Mugen87 提供我只想总结的信息。

关于three.js - GLTFLoader 错误 : Cannot read property 'itemStart' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59719623/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com