I’ve been following the ES6 docs for setting up a physics plugin with Babylon, However the AmmoJSPlugin keeps giving me an error
TypeError: Ammo.btCompoundShape is not a constructor
Heres my webpack config. At the bottom I’m using the ProvidePlugin like in the docs to point Ammo to ammo.js in the npm modules folder, but it wont work with any combination of configuration I can think of.
Thanks for the suggestion but that doesn’t appear to be the solution. The issue you found is with webpack-stream which intergrates webpack with gulp, and I’m not using gulp.
Just to test that ProvidePlugin is working correctly I used it to add babylon itself to all my modules and its working fine for importing babylon but ammo is still saying everything is not a constructor
new webpack.ProvidePlugin({
BABYLON: '@babylonjs/core',
Ammo: 'ammo.js'
})
I noticed webpack is giving a warning about type errors with asm.js which might give us another clue as to what is going wrong.
TypeError: asm.js type error: 'undefined' not found in local or asm.js module scope
That seems to have done the trick. Adding this to the docs would be a great idea! That way the next poor soul doesn’t have to muck about trying to get this working.
I installed from npm i --save-dev kripken/ammo.js, added that node: { fs: 'empty' } and used the import statement described here. No luck, I get this in the import statement:
There is not much we can do if they do not provide the typings, Could you not cast as any for this one ? I know it is not ideal but without typings, it does not leave a lot of options.
i hard-copied the ammo.js from the dist/ in babylonjs-4.2 repo locally to my sources, bundling takes now very long but its kinda working for me currently…
If i understand this post right, its an issue caused by the most recent build of ammo?..
Actually i forgot to update, babylonjs and babylonjs-loaders were on version 4.1.0, also file-loader and css-loader outdated. Updating them didnt change anything, see / try out this branch for reproduction.
Cannon package integration /injection works as described. (thanks for updating the documentation btw!)
Ammo still fails with the error described earlier, using the local copy of ammo still works.
Does anyone want to invest the time to clone the repo and run
npm install npm run dev
and tell if the same error occurs?
btw. i wont be using physics now as i had a hard time building up a reasonable character controller that interacts with pyhsics…
I am currently using using the bullet kinematic character controller as the underlying backbone to the BABYLON.CharacterController script component. I works great
I kind of did the same approach, but it does not use an physics engine afaik, only basic raycasting and intersection stuff… but i think this topic is maybe worth starting a new thread eventually.