Uncaught TypeError: THREE.GLTFLoader is not a constructor

一曲冷凌霜 提交于 2020-06-23 03:30:16

问题


I am new to THREE js I can't figure out the error

when I am run my code the following error is showing

Uncaught TypeError: THREE.GLTFLoader is not a constructor

var loader = new THREE.GLTFLoader();

        loader.load('modelReq/Gully_update_2.gltf', 
            function (gltf) {

                scene.add(gltf.scene);
                gltf.animations; 
                gltf.scene;
                gltf.scenes; 
                gltf.cameras; 
                gltf.asset;


            },

            function (xhr) {
                console.log((xhr.loaded / xhr.total * 100 ) + '% loaded' );
            },

            function (error) {
                console.log( 'An error happened = ', error );
            }
        );

and error is at var loader = new THREE.GLTFLoader();

My html file :

    <link rel="stylesheet" href="css/main.css">
    <script src="js/plugins/three.min.js"></script>
    <script src="js/plugins/TrackballControls.js"></script>
    <script src="js/plugins/stats.min.js"></script>
    <script src="js/plugins/GLTFLoader.js"></script>
    <script src="js/custom.js"></script>

</head>
<body>
    <div id="animate">
        <canvas></canvas>
    </div>

and the GLTFLoader.js is in the path : <script src="js/plugins/GLTFLoader.js"></script>


回答1:


GLTFLoader is in a separate file...

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


来源:https://stackoverflow.com/questions/52233388/uncaught-typeerror-three-gltfloader-is-not-a-constructor

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!