三个软件包中包含的三j / gltfloader
有一个注释说,从三个r103开始,gltfloader包含在三个软件包本身中,并且不再需要安装三个GLTF-loader。
这是我的html文件脚本导入:
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/three.min.js"></script>
js.file,
如果我使用:
const loader = new THREE.GLTFLoader();
und typeError:必须使用'new'''调用类构造仪
,或者如果我使用:
const loader = new GLTFLoader();
nuck offfach coftucterror:gltfloader:gltfloader nons n n's n n n n n's n n n n's << /em>
所以我想我错过了进口或声明GLTF的观点
There is a note saying that starting with three.js r103, GLTFLoader is included in the three package itself and installing three-gltf-loader is no longer necessary.
Here is my html file script import :
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/three.min.js"></script>
JS.file
If I use :
const loader = new THREE.GLTFLoader();
Uncaught TypeError: class constructors must be invoked with 'new'
Or if I use :
const loader = new GLTFLoader();
Uncaught ReferenceError: GLTFLoader is not defined
So I think I have missed a point about importing or declaring gltf
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
GLTFLOADER(与其他三个JS加载器和控件一样)是同一NPM软件包的一部分,但不是核心捆绑包的一部分。它可以从子文件夹中导出,而是:
如果安装了“三个”,则捆绑器和构建工具将自动解决此问题,这是我建议使用的方法。如果您喜欢使用CDN,则可能需要其他导入地图来解决正确的URL的“三个”软件包。在
GLTFLoader (like other three.js loaders and controls) is part of the same NPM package, but not part of the core bundle. It can be exported from a subfolder, instead:
Bundlers and build tools will resolve this automatically if you have 'three' installed, and that's what I'd recommend using. If you prefer to use a CDN, then you may need additional import maps to resolve the 'three' package to the right URLs. Both options are discussed in the three.js installation documentation.