简体   繁体   English

app.js:63 Uncaught ReferenceError: GLTFLoader is not defined

[英]app.js:63 Uncaught ReferenceError: GLTFLoader is not defined

When i call this in three.js const loader = new GLTFLoader();当我在 three.js 中调用它时 const loader = new GLTFLoader(); get this error app.js:63 Uncaught ReferenceError: GLTFLoader is not defined.得到这个错误 app.js:63 Uncaught ReferenceError: GLTFLoader is not defined。 it is import in index.html.but got that error它是索引中的导入。html。但是得到了那个错误

<script src="./three.min.js"></script>
<script src="./OBJLoader.js"></script>
<script src="./GLTFLoader.js"></script>
<script src="./app.js"></script>

A code like const loader = new GLTFLoader();const loader = new GLTFLoader();这样的代码only works if you import GLTFLoader as an ES6 module via import statement.仅当您通过import语句将GLTFLoader作为 ES6 模块导入时才有效。 When doing so, GLTFLoader is no part of the THREE namespace.这样做时, GLTFLoader不是THREE命名空间的一部分。

Since you are using three.min.js , you are not using a module based workflow but global scripts.由于您使用的是three.min.js ,因此您使用的不是基于模块的工作流,而是全局脚本。 That means GLTFLoader is only available under the THREE namespace.这意味着GLTFLoader仅在THREE命名空间下可用。 So changing your code to the following should fix the issue:因此,将您的代码更改为以下内容应该可以解决问题:

const loader = new THREE.GLTFLoader();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未捕获的ReferenceError:未定义角度app.js - Uncaught ReferenceError: angular is not defined app.js 未捕获的ReferenceError:app.js中未定义require:3 - Uncaught ReferenceError: require is not defined at app.js:3 app.js:92未捕获的ReferenceError:未定义newCalculation - app.js:92 Uncaught ReferenceError: newCalculation is not defined AngularJS:未捕获ReferenceError:未定义angular app.js:1(匿名函数): - AngularJS: Uncaught ReferenceError: angular is not defined app.js:1(anonymous function): Laravel Uncaught ReferenceError webpackJsonp未在app.js:1中定义 - Laravel Uncaught ReferenceError webpackJsonp is not defined at app.js:1 将使用 CDN 链接创建的 React App 导入 App.js 时出现“未捕获的 ReferenceError:require is not defined” - “Uncaught ReferenceError: require is not defined” when importing into App.js for React App created using CDN links Uncaught ReferenceError: Glide is not defined - 尽管 Glide 像所有其他的一样在 app.js 中加载 - Uncaught ReferenceError: Glide is not defined - Although Glide loaded in app.js like all others 在 Laravel 中将 JS 添加到 app.js 时出现未捕获的 ReferenceError - Uncaught ReferenceError when adding JS to app.js in Laravel app.js:3524 Uncaught ReferenceError: THREE not defined at Object../node_modules/three-bmfont-text/index.js - app.js:3524 Uncaught ReferenceError: THREE is not defined at Object../node_modules/three-bmfont-text/index.js 未捕获的 ReferenceError:库未在 js 中定义 - Uncaught ReferenceError: Gallery is not defined in js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM