【发布时间】:2020-04-05 07:53:12
【问题描述】:
我正在使用集成了 Autodesk forge 查看器 javscript 库的 Angular 创建一个 Web 应用程序。
forge viewer.js 库包含在 forge viewer.js 本身中,它是 THREE.js 版本 r71 的定制版本。
因此,我在我的应用中看到了一些意想不到的结果:
THREE.Object3D.add: object not an instance of THREE.Object3D
通过一些研究,这是因为 THREE.js 被两次加载到我的应用程序中。我试过从 node_modules 卸载 three.js,但这会导致构建错误:
Error: ENOENT: no such file or directory, open 'C:\Users\username\source\repos\Testing\appname\appname-SPA\node_modules\three\build\three.min.js'
当我在 tsconfig.json 中排除 THREE.js 时,此错误已消除,但我仍然看到意外结果。
显然,React 应用程序中的一个修复方法是在使用 webpack 时在外部提及 THREE.js:
const config = {
…
externals: {
three: 'THREE'
},
但是 Angular 不包括 webpack.config.js。我将如何排除 THREE.js?
【问题讨论】:
-
这不是我最喜欢的方法,但你可以像 here 那样扩充 webpack 配置。
标签: angular typescript webpack autodesk-forge autodesk-viewer