因此,我设法使碰撞检测在ammo.js中工作,就像在Physijs中一样。这是能工作的代码
var i,
dp = this.dispatcher,
num = dp.getNumManifolds(),
manifold, num_contacts, j, pt;
for (i = 0; i < num; i++) {
manifold = dp.getManifoldByIndexInternal(i);
num_contacts = manifold.getNumContacts();
if (num_contacts === 0) {
continue;
}
for (j = 0; j < num_contacts; j++) {
pt = manifold.getContactPoint(j);
//console.log('body 1: ', manifold.getBody0());
//console.log('body 2: ', manifold.getBody1());
console.log('COLLISION DETECTED!');
// HERE: how to get impact force details?
// pt.getAppliedImpulse() is not working
}
}在一些论坛上,我发现这个函数提供了有关冲击力的信息:
getAppliedImpulse()但是在ammo.js中没有这样的功能。我搜索了密码但它不在那里。也许API更新了,或者读取力的方法完全不同?
编辑:
这里是我自定义的弹药,并启用了getAppliedImpulse()和许多基本功能。https://github.com/DVLP/ammo.js/tree/master/builds
发布于 2015-08-17 07:37:59
向ammo.idl添加绑定描述,并重新构建ammo.js。
interface btManifoldPoint {
...
[Const] double getAppliedImpulse();
}https://stackoverflow.com/questions/31991267
复制相似问题