|
@@ -303,7 +303,10 @@ var BABYLON = BABYLON || {};
|
|
|
if (this.parent && this.parent.getWorldMatrix && this.billboardMode === BABYLON.Mesh.BILLBOARDMODE_NONE) {
|
|
|
this._localWorld.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
|
|
|
} else {
|
|
|
- this._worldMatrix = this._localWorld;
|
|
|
+ // multiplyToRef instead of this._worldMatrix = this._localWorld;
|
|
|
+ // to be sure not to have a bug with a call to this._localWorld.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
|
|
|
+ // Moreover multiplyToRef is more efficient than clone
|
|
|
+ this._localPivotScalingRotation.multiplyToRef(this._localTranslation, this._worldMatrix);
|
|
|
}
|
|
|
|
|
|
// Bounding info
|
|
@@ -533,6 +536,27 @@ var BABYLON = BABYLON || {};
|
|
|
};
|
|
|
|
|
|
// Geometry
|
|
|
+ // deprecated: use setPositionWithLocalVector instead. It fixes setLocalTranslation.
|
|
|
+ BABYLON.Mesh.prototype.setLocalTranslation = function(vector3) {
|
|
|
+ console.warn("deprecated: use setPositionWithLocalVector instead");
|
|
|
+ this.computeWorldMatrix();
|
|
|
+ var worldMatrix = this._worldMatrix.clone();
|
|
|
+ worldMatrix.setTranslation(BABYLON.Vector3.Zero());
|
|
|
+
|
|
|
+ this.position = BABYLON.Vector3.TransformCoordinates(vector3, worldMatrix);
|
|
|
+ };
|
|
|
+
|
|
|
+ // deprecated: use getPositionExpressedInLocalSpace instead. It fixes getLocalTranslation.
|
|
|
+ BABYLON.Mesh.prototype.getLocalTranslation = function () {
|
|
|
+ console.warn("deprecated: use getPositionExpressedInLocalSpace instead");
|
|
|
+ this.computeWorldMatrix();
|
|
|
+ var invWorldMatrix = this._worldMatrix.clone();
|
|
|
+ invWorldMatrix.setTranslation(BABYLON.Vector3.Zero());
|
|
|
+ invWorldMatrix.invert();
|
|
|
+
|
|
|
+ return BABYLON.Vector3.TransformCoordinates(this.position, invWorldMatrix);
|
|
|
+ };
|
|
|
+
|
|
|
BABYLON.Mesh.prototype.setPositionWithLocalVector = function(vector3) {
|
|
|
this.computeWorldMatrix();
|
|
|
|