|
@@ -5688,6 +5688,16 @@ var BABYLON;
|
|
|
Vector3.Up = function () {
|
|
|
return new Vector3(0.0, 1.0, 0.0);
|
|
|
};
|
|
|
+ Object.defineProperty(Vector3, "UpReadOnly", {
|
|
|
+ /**
|
|
|
+ * Gets a up Vector3 that must not be updated
|
|
|
+ */
|
|
|
+ get: function () {
|
|
|
+ return Vector3._UpReadOnly;
|
|
|
+ },
|
|
|
+ enumerable: true,
|
|
|
+ configurable: true
|
|
|
+ });
|
|
|
/**
|
|
|
* Returns a new Vector3 set to (0.0, -1.0, 0.0)
|
|
|
* @returns a new down Vector3
|
|
@@ -6165,6 +6175,7 @@ var BABYLON;
|
|
|
Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
|
|
|
quat.toEulerAnglesToRef(ref);
|
|
|
};
|
|
|
+ Vector3._UpReadOnly = Vector3.Up();
|
|
|
return Vector3;
|
|
|
}());
|
|
|
BABYLON.Vector3 = Vector3;
|
|
@@ -6823,6 +6834,16 @@ var BABYLON;
|
|
|
result.z = (x * m[2]) + (y * m[6]) + (z * m[10]);
|
|
|
result.w = w;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Creates a new Vector4 from a Vector3
|
|
|
+ * @param source defines the source data
|
|
|
+ * @param w defines the 4th component (default is 0)
|
|
|
+ * @returns a new Vector4
|
|
|
+ */
|
|
|
+ Vector4.FromVector3 = function (source, w) {
|
|
|
+ if (w === void 0) { w = 0; }
|
|
|
+ return new Vector4(source.x, source.y, source.z, w);
|
|
|
+ };
|
|
|
return Vector4;
|
|
|
}());
|
|
|
BABYLON.Vector4 = Vector4;
|
|
@@ -52632,6 +52653,19 @@ var BABYLON;
|
|
|
}
|
|
|
var target = this._getTargetPosition();
|
|
|
this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
|
|
|
+ // Rotate according to up vector
|
|
|
+ if (this.upVector.x !== 0 || this.upVector.y !== 1.0 || this.upVector.z !== 0) {
|
|
|
+ if (!this._tempAxisVector) {
|
|
|
+ this._tempAxisVector = new BABYLON.Vector3();
|
|
|
+ this._tempAxisRotationMatrix = new BABYLON.Matrix();
|
|
|
+ }
|
|
|
+ BABYLON.Vector3.CrossToRef(BABYLON.Vector3.Up(), this.upVector, this._tempAxisVector);
|
|
|
+ this._tempAxisVector.normalize();
|
|
|
+ var angle = Math.acos(BABYLON.Vector3.Dot(BABYLON.Vector3.UpReadOnly, this.upVector));
|
|
|
+ BABYLON.Matrix.RotationAxisToRef(this._tempAxisVector, angle, this._tempAxisRotationMatrix);
|
|
|
+ this._tempAxisVector.copyFrom(this._computationVector);
|
|
|
+ BABYLON.Vector3.TransformCoordinatesToRef(this._tempAxisVector, this._tempAxisRotationMatrix, this._computationVector);
|
|
|
+ }
|
|
|
target.addToRef(this._computationVector, this._newPosition);
|
|
|
if (this.getScene().collisionsEnabled && this.checkCollisions) {
|
|
|
if (!this._collider) {
|
|
@@ -99909,6 +99943,7 @@ var BABYLON;
|
|
|
*/
|
|
|
this.name = "AmmoJSPlugin";
|
|
|
this._timeStep = 1 / 60;
|
|
|
+ this._fixedTimeStep = 1 / 60;
|
|
|
this._maxSteps = 5;
|
|
|
this._tmpQuaternion = new BABYLON.Quaternion();
|
|
|
this._tmpContactCallbackResult = false;
|
|
@@ -99952,6 +99987,20 @@ var BABYLON;
|
|
|
this._timeStep = timeStep;
|
|
|
};
|
|
|
/**
|
|
|
+ * Increment to step forward in the physics engine (If timeStep is set to 1/60 and fixedTimeStep is set to 1/120 the physics engine should run 2 steps per frame) (Default: 1/60)
|
|
|
+ * @param fixedTimeStep fixedTimeStep to use in seconds
|
|
|
+ */
|
|
|
+ AmmoJSPlugin.prototype.setFixedTimeStep = function (fixedTimeStep) {
|
|
|
+ this._fixedTimeStep = fixedTimeStep;
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Sets the maximum number of steps by the physics engine per frame (Default: 5)
|
|
|
+ * @param maxSteps the maximum number of steps by the physics engine per frame
|
|
|
+ */
|
|
|
+ AmmoJSPlugin.prototype.setMaxSteps = function (maxSteps) {
|
|
|
+ this._maxSteps = maxSteps;
|
|
|
+ };
|
|
|
+ /**
|
|
|
* Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
|
|
|
* @returns the current timestep in seconds
|
|
|
*/
|
|
@@ -100012,7 +100061,7 @@ var BABYLON;
|
|
|
// Update physics world objects to match babylon world
|
|
|
impostor.beforeStep();
|
|
|
}
|
|
|
- this._stepSimulation(this._useDeltaForWorldStep ? delta : this._timeStep, this._maxSteps);
|
|
|
+ this._stepSimulation(this._useDeltaForWorldStep ? delta : this._timeStep, this._maxSteps, this._fixedTimeStep);
|
|
|
for (var _a = 0, impostors_2 = impostors; _a < impostors_2.length; _a++) {
|
|
|
var mainImpostor = impostors_2[_a];
|
|
|
// After physics update make babylon world objects match physics world objects
|
|
@@ -100156,7 +100205,9 @@ var BABYLON;
|
|
|
* @param impostorJoint the imposter joint to remove the joint from
|
|
|
*/
|
|
|
AmmoJSPlugin.prototype.removeJoint = function (impostorJoint) {
|
|
|
- this.world.removeConstraint(impostorJoint.joint.physicsJoint);
|
|
|
+ if (this.world) {
|
|
|
+ this.world.removeConstraint(impostorJoint.joint.physicsJoint);
|
|
|
+ }
|
|
|
};
|
|
|
// adds all verticies (including child verticies) to the triangle mesh
|
|
|
AmmoJSPlugin.prototype._addMeshVerts = function (btTriangleMesh, topLevelObject, object) {
|