Uncaught TypeError: THREE.GLTFLoader is not a constructor
Uncaught TypeError: THREE.GLTFLoader is not a constructor
我是三个 js 的新手,我无法找出错误
当我 运行 我的代码显示以下错误
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 );
}
);
错误在var loader = new THREE.GLTFLoader();
我的 html 文件:
<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>
并且 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>
对我来说,错误不包括“从 'three/examples/jsm/loaders/GLTFLoader.js'
导入 { GLTFLoader }
我是三个 js 的新手,我无法找出错误
当我 运行 我的代码显示以下错误
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 );
}
);
错误在var loader = new THREE.GLTFLoader();
我的 html 文件:
<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>
并且 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>
对我来说,错误不包括“从 'three/examples/jsm/loaders/GLTFLoader.js'
导入 { GLTFLoader }