浏览代码

Rotation can now be set before the impostor ist created.
Until now it was only possible to set the rotation of the impostor after, but this prevents people from using a serialized scene.

Raanan Weber 7 年之前
父节点
当前提交
1fe2b82bdd
共有 1 个文件被更改,包括 2 次插入3 次删除
  1. 2 3
      src/Physics/Plugins/babylon.cannonJSPlugin.ts

+ 2 - 3
src/Physics/Plugins/babylon.cannonJSPlugin.ts

@@ -429,9 +429,6 @@
 
                 var oldPivot = mesh.getPivotMatrix() || Matrix.Translation(0, 0, 0);
 
-                //rotation is back
-                mesh.rotationQuaternion = rotationQuaternion;
-
                 //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)
                 var p = Matrix.Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);
                 mesh.setPivotMatrix(p);
@@ -444,6 +441,8 @@
                 //add it inverted to the delta
                 this._tmpDeltaPosition.copyFrom(boundingInfo.boundingBox.centerWorld.subtract(c));
                 this._tmpDeltaPosition.y += boundingInfo.boundingBox.extendSizeWorld.y;
+                //rotation is back
+                mesh.rotationQuaternion = rotationQuaternion;
 
                 mesh.setPivotMatrix(oldPivot);
                 mesh.computeWorldMatrix(true);