GLTFLoader 错误:无法读取未定义的属性“itemStart”

Gho*_*ool 3 three.js

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

未捕获的类型错误:无法读取未定义的属性“itemStart”

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();
Run Code Online (Sandbox Code Playgroud)

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

Chr*_*yer 5

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

三.WebGLRenderer 96

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

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

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

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