|
@@ -328,7 +328,6 @@ export class AmmoJSPlugin implements IPhysicsEnginePlugin {
|
|
vertex_data.applyToMesh(<Mesh>object);
|
|
vertex_data.applyToMesh(<Mesh>object);
|
|
}
|
|
}
|
|
|
|
|
|
- private _tmpVector = new Vector3();
|
|
|
|
private _tmpMatrix = new Matrix();
|
|
private _tmpMatrix = new Matrix();
|
|
/**
|
|
/**
|
|
* Applies an impulse on the imposter
|
|
* Applies an impulse on the imposter
|
|
@@ -342,11 +341,9 @@ export class AmmoJSPlugin implements IPhysicsEnginePlugin {
|
|
var worldPoint = this._tmpAmmoVectorA;
|
|
var worldPoint = this._tmpAmmoVectorA;
|
|
var impulse = this._tmpAmmoVectorB;
|
|
var impulse = this._tmpAmmoVectorB;
|
|
|
|
|
|
- // Convert contactPoint into world space
|
|
|
|
|
|
+ // Convert contactPoint relative to center of mass
|
|
if (impostor.object && impostor.object.getWorldMatrix) {
|
|
if (impostor.object && impostor.object.getWorldMatrix) {
|
|
- impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
|
|
|
|
- Vector3.TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
|
|
|
|
- contactPoint = this._tmpVector;
|
|
|
|
|
|
+ contactPoint.subtractInPlace(impostor.object.getWorldMatrix().getTranslation());
|
|
}
|
|
}
|
|
|
|
|
|
worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
|
|
worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
|
|
@@ -371,11 +368,9 @@ export class AmmoJSPlugin implements IPhysicsEnginePlugin {
|
|
var worldPoint = this._tmpAmmoVectorA;
|
|
var worldPoint = this._tmpAmmoVectorA;
|
|
var impulse = this._tmpAmmoVectorB;
|
|
var impulse = this._tmpAmmoVectorB;
|
|
|
|
|
|
- // Convert contactPoint into world space
|
|
|
|
|
|
+ // Convert contactPoint relative to center of mass
|
|
if (impostor.object && impostor.object.getWorldMatrix) {
|
|
if (impostor.object && impostor.object.getWorldMatrix) {
|
|
- impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
|
|
|
|
- Vector3.TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
|
|
|
|
- contactPoint = this._tmpVector;
|
|
|
|
|
|
+ contactPoint.subtractInPlace(impostor.object.getWorldMatrix().getTranslation());
|
|
}
|
|
}
|
|
|
|
|
|
worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
|
|
worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
|