How can I use new Ammo() in My Project?

var MyVehicle = pc.createScript('myVehicle');
I want to use Ammo look like this.but it show me Ammo is not defined!
I need to include ammo.js by myself?


var ammoVec = new Ammo.btVector3();
// 获取一个Ammo的四元数数据类型
var ammoQuat = new Ammo.btQuaternion();
// 获取一个Ammo的transform数据类型,相当于是个矩阵,可以表示pos和rot
var ammoTransform = new Ammo.btTransform();

var wheelDirection = new Ammo.btVector3(0, -1, 0);
var wheelAxle = new Ammo.btVector3(-1, 0, 0);


MyVehicle.prototype.localCreateRigidBody=function(mass, transform, shape) {
    var localInertia = new Ammo.btVector3(0, 0, 0);
    if (mass > 0) {
        shape.calculateLocalInertia(mass, localInertia);
    }

    var motionState = new Ammo.btDefaultMotionState(transform);
    //构建刚体的构造信息,四个方面:质量,运动状态(旋转和pos),物理形状,和惯性
    var bodyInfo = new Ammo.btRigidBodyConstructionInfo(mass, motionState, shape, localInertia);
    var body = new Ammo.btRigidBody(bodyInfo);
    body.setContactProcessingThreshold(1000000.0);
    this.app.systems.rigidbody.dynamicsWorld.addRigidBody(body);
    
    return body;
};

Hi there,

You need to enable physics.

Click the Settings icon ( bottom icon in the left hand panel ), then in the right panel under Physics, tick the Enable button. Ammo.js will now be included.

1 Like

thank you very much!!!:grin: