本文介绍了未捕获的类型错误:THREE.GLTFLoader 不是构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是三个 js 的新手我无法弄清楚错误
当我运行我的代码时,显示以下错误
未捕获的类型错误:THREE.GLTFLoader 不是构造函数
var loader = new THREE.GLTFLoader();loader.load('modelReq/Gully_update_2.gltf',功能(gltf){场景.添加(gltf.场景);gltf.animations;gltf.scene;gltf.scenes;gltf.cameras;gltf.资产;},功能(xhr){console.log((xhr.loaded/xhr.total * 100) + '%loaded');},功能(错误){console.log( '发生错误 = ', error );});
错误在 var loader = new THREE.GLTFLoader();
我的 html 文件:
<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>头部><身体><div id="动画"><canvas></canvas>
并且 GLTFLoader.js 在路径中:<script src="js/plugins/GLTFLoader.js"></script>
解决方案
GLTFLoader 在一个单独的文件中...
<script src="https://cdn.rawgit.com/mrdoob/three.js/master/examples/js/loaders/GLTFLoader.js"></script>
I am new to THREE js I can't figure out the error
when I am run my code the following error is showing
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>
解决方案
GLTFLoader is in a separate file...
<script src="https://cdn.rawgit.com/mrdoob/three.js/master/examples/js/loaders/GLTFLoader.js"></script>
这篇关于未捕获的类型错误:THREE.GLTFLoader 不是构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!