1. 首页
  2. three.js

three.js将三个r102示例/jsm/GLTFLoader导入Angular 7项目

我正在尝试将GLTFLoader导入到我现有的angular项目中。我尝试了几个插件,例如这个12插件,但没有一个能起作用。我阅读并测试了我发现的所有stackoverflow线程…什么都不管用。现在将我的项目更新为102,我在示例中找到了jsm文件夹。我是这样写的:nimport * as THREE from \”three\”import {GLTFLoader}>nThrowing this Error when loading:nTHREE is not definednmodelmanager.ts:164 Error ReferenceError: THREE is not defined at GLTFLoader.js:2715 at ZoneDelegate.push…/node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388) at Object.onInvoke (core.js:16963) at ZoneDelegate.push…/node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:387) at Zone.push…/node_modules/zone.js/dist/zone.js.Zone.run (zone.js:138) at zone.js:872 at ZoneDelegate.push…/node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421) at Object.onInvokeTask (core.js:16954) at ZoneDelegate.push…/node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420) at Zone.push…/node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188)nWhat else can I provide? Please I really need to get this to work. This is frustrating me for days now. Thanks in advancenThanks for reporting! There is already a bug report at github for this issue:github.com/mrdoob/three.jsIssue: JSM / GLTFLoader: Webpack error using jsm80opened by hevalion 2019-03-09nDescription of the problemI´m using three.js in an Angular project with webpack as bundler.When trying to load a GLTF file a… BugnBTW: I think you can delete your post at stackoverflow 18 since there are still bugs in the converter that produces the modules. Fluqz:nimport {GLTFLoader} from \”three/examples/jsm/loaders/GLTFLoader\”nI using this https://www.npmjs.com/package/three-gltf-loader 265nimport GLTFLoader from \”three-gltf-loader\”;nHey already tested it, but its also throwing an error saying GLTFLoader is not a constructor.n我也尝试了GLTF2Loader(npm上的三个gltf2-loader),但基本上得到了相同的错误n这里有什么进展吗?n如果您的组件不是库,请这样尝试n这应该在下一版本R103中修复。dev分支的JSM版本应该已经可以运行了。nGLTFLoader r103 101工作正常!谢谢你所做的一切!nHi@Fluqz,我遇到了同样的问题,似乎无法访问GLTFLoader。我有点困惑我应该做什么-我的导入是这样的:nimport * as THREE from \”three\”;import \”three/examples/js/loaders/GLTFLoader\”;n但是我实际上如何访问3.GLTFLoader?n像这样导入它nimport { GLTFLoader } from \”three/examples/js/loaders/GLTFLoader\”n你必须像这样使用它let>. Remove the THREE.n你有什么错误吗?n好吧,这很有道理!我在跟踪doum的代码块。我现在明白了-必须提取更新版本的GLTFLoader并直接导入。n如果您使用的是typescript,您需要examples/jsm/GLTFLoader.js的模块化GLTFLoader,它在r102中还不起作用。但是r103 30有一个开发版本可以使用。只需替换GLTFLoader.js有了它。n我认为这与TypeScript无关。如果要将其作为模块导入,您必须始终使用jsm目录中的GLTFLoader。n伙计们,请共享github repo,以便我可以确切地了解这是如何实现的?n您必须从JSM文件夹的three/examples/JSM/loaders/GLTFLoader中导入GLTFLoader。nimport*作为three from“three”导入{GLTFLoader}从“three/examples/JSM/loaders/GLTFLoader”私有GLTFLoader:GLTFLoaderprivate loader GLTFModel(路径:string){此文件为.gltfLoader.load(一),>n它不适合AMD/Require.jsn@8Observer8此线程是关于ES模块的。如果您需要老年AMD的帮助/Require.js导入系统时,我认为您需要创建一个新线程,并提供重现问题的详细信息。@donmccurdy已经过时了Three.js不支持吗?二十三n Importing THREE r102 examples/jsm/GLTFLoader into Angular 7 projectn

three.js将三个r102示例/jsm/GLTFLoader导入Angular 7项目 为WP2原创文章,链接:https://www.wp2.cn/three-js/three-js%e5%b0%86%e4%b8%89%e4%b8%aar102%e7%a4%ba%e4%be%8b-jsm-gltfloader%e5%af%bc%e5%85%a5angular-7%e9%a1%b9%e7%9b%ae/