im currently working on an little project with three.js and i need some physics in my project.
Three wasent a problem i just did bin/importmap pin three and it worked just fine.
I am using the "new" stimulus controllers for this projct so i just had to import * as THREE from "three" and i could use it.
But now to my problem, i want to use ammo.js to create objects with physics, but everything that i try to get ammo.js working in my project, without an bundler, is not working.
I feel like that i miss something important, but i cant wrap my head around it.
I tried to use the Importmap like this bin/importmap pin ammo.js and it also pined somethings but when i try to import it like i did with three import * as Ammo from "ammo.js" i get this message from VS Code when i hover above the "ammo.js":
Could not find a declaration file for module 'ammo.js'. '/Users/soerenklatt/Documents/Privat/Projects/Games/LightningStrike/node_modules/ammo.js/ammo.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/ammo.js` if it exists or add a new declaration (.d.ts) file containing `declare module 'ammo.js';`
Furthermore i tried to use the the <%= javascript_include_tag 'ammo' %>, i added an javascript folder under assets and downloaded the ammo.js file from github.
I than initialised ammo in my stimulus controller with this:
Ammo().then((AmmoLib) => {
Ammo = AmmoLib;
});
this also did not work so i did a yarn install, but at some point i was completely lost and out of my comfort zone. I am fairly new to Rails and especially to Rails 7 so thats why i need your help and hopefully we can finde a solution for me and everyone how has stumbled a cross the same problem.
In this manner thanks for your help.