vue+three.js中使用Ammo.js

文章讲述了在Vue项目中通过npm引入ammo.js并在webpack环境下遇到的错误,解决方法包括从github下载build版本、修改ammo.js文件、添加exportdefault及在webpack配置中处理fs库缺失问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

直接通过npm i ammo.js安装进webpack的项目里调用时,会出现如下报错:

ERROR in ./node_modules/ammo.js/ammo.js 1:1683-1696                                                                                                                  
Module not found: Error: Can't resolve 'fs' in 'D:\WebProject\GosunProject\project\my-viewer\node_modules\ammo.js'
 @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/Walk.vue?vue&type=script&lang=js& 11:0-27 131:41-77 132:29-55 133:29-50 134:25-48 136:30-58 137:39-53 153:34-50 373:24-46 377:27-41 384:31-45 386:28-44 388:30-44 389:30-55 390:27-59 391:23-39
 @ ./src/components/Walk.vue?vue&type=script&lang=js& 1:0-198 1:214-217 1:219-414 1:219-414
 @ ./src/components/Walk.vue 2:0-56 3:0-51 3:0-51 10:2-8
 @ ./src/router/index.js 3:0-42 15:13-17
 @ ./src/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值