|
@@ -20518,17 +20518,7 @@ var BABYLON;
|
|
|
var dv = TransformNode._lookAtVectorCache;
|
|
|
var pos = space === BABYLON.Space.LOCAL ? this.position : this.getAbsolutePosition();
|
|
|
targetPoint.subtractToRef(pos, dv);
|
|
|
- var yaw = -Math.atan2(dv.z, dv.x) - Math.PI / 2;
|
|
|
- var len = Math.sqrt(dv.x * dv.x + dv.z * dv.z);
|
|
|
- var pitch = Math.atan2(dv.y, len);
|
|
|
- if (this.rotationQuaternion) {
|
|
|
- BABYLON.Quaternion.RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
|
|
|
- }
|
|
|
- else {
|
|
|
- this.rotation.x = pitch + pitchCor;
|
|
|
- this.rotation.y = yaw + yawCor;
|
|
|
- this.rotation.z = rollCor;
|
|
|
- }
|
|
|
+ this.setDirection(dv, yawCor, pitchCor, rollCor);
|
|
|
// Correct for parent's rotation offset
|
|
|
if (space === BABYLON.Space.WORLD && this.parent) {
|
|
|
if (this.rotationQuaternion) {
|
|
@@ -20583,6 +20573,31 @@ var BABYLON;
|
|
|
return this;
|
|
|
};
|
|
|
/**
|
|
|
+ * Sets this transform node rotation to the given local axis.
|
|
|
+ * @param localAxis the axis in local space
|
|
|
+ * @param yawCor optional yaw (y-axis) correction in radians
|
|
|
+ * @param pitchCor optional pitch (x-axis) correction in radians
|
|
|
+ * @param rollCor optional roll (z-axis) correction in radians
|
|
|
+ * @returns this TransformNode
|
|
|
+ */
|
|
|
+ TransformNode.prototype.setDirection = function (localAxis, yawCor, pitchCor, rollCor) {
|
|
|
+ if (yawCor === void 0) { yawCor = 0; }
|
|
|
+ if (pitchCor === void 0) { pitchCor = 0; }
|
|
|
+ if (rollCor === void 0) { rollCor = 0; }
|
|
|
+ var yaw = -Math.atan2(localAxis.z, localAxis.x) - Math.PI / 2;
|
|
|
+ var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
|
|
|
+ var pitch = Math.atan2(localAxis.y, len);
|
|
|
+ if (this.rotationQuaternion) {
|
|
|
+ BABYLON.Quaternion.RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.rotation.x = pitch + pitchCor;
|
|
|
+ this.rotation.y = yaw + yawCor;
|
|
|
+ this.rotation.z = rollCor;
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ /**
|
|
|
* Sets a new pivot point to the current node
|
|
|
* @param point defines the new pivot point to use
|
|
|
* @param space defines if the point is in world or local space (local by default)
|
|
@@ -70683,9 +70698,7 @@ var BABYLON;
|
|
|
vertexData.applyToMesh(plane, options.updatable);
|
|
|
if (options.sourcePlane) {
|
|
|
plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);
|
|
|
- var dot = BABYLON.Vector3.Dot(plane.position, options.sourcePlane.normal);
|
|
|
- var flip = dot >= 0;
|
|
|
- plane.lookAt(BABYLON.Vector3.Zero(), 0, flip ? Math.PI : 0, 0);
|
|
|
+ plane.setDirection(options.sourcePlane.normal);
|
|
|
}
|
|
|
return plane;
|
|
|
};
|