Excuse me, how to introduce Vue Ammo.js
Your question is very generic, so I assume your question is how to add Ammo.js physics to a babylon scene with a Vue-like setup.
First add ammo.js to your dependencies like so:
npm install github:kripken/ammo.js
If you are using typescript you may have to add a module declaration by creating a file index.d.ts
in your src
folder, and include the following:
declare module "ammo.js";
Now in your babylon scene file:
import { AmmoJSPlugin } from "@babylonjs/core";
import * as Ammo from "ammo.js";
async function createScene() {
const scene = new Scene(engine);
...
const gravityVector = new Vector3(0, -9.81, 0);
const ammoModule = await new Ammo();
scene.enablePhysics(gravityVector, new AmmoJSPlugin(true, ammoModule));
...
return scene;
}
4 Likes
That’s exactly what I want. Thank you for your answer.I was puzzled by this question for a long time. It’s right to come to this community.
1 Like
Awesome!
I just love the ‘decrypting skills’ of the contributors in this BJS forum My study of this alien language continues…
1 Like