|
@@ -835,6 +835,14 @@ var BABYLON;
|
|
* to something in order to rotate it from its local system to the given target system.
|
|
* to something in order to rotate it from its local system to the given target system.
|
|
*/
|
|
*/
|
|
Vector3.RotationFromAxis = function (axis1, axis2, axis3) {
|
|
Vector3.RotationFromAxis = function (axis1, axis2, axis3) {
|
|
|
|
+ var rotation = Vector3.Zero();
|
|
|
|
+ Vector3.RotationFromAxisToRef(axis1, axis2, axis3, rotation);
|
|
|
|
+ return rotation;
|
|
|
|
+ };
|
|
|
|
+ /**
|
|
|
|
+ * The same than RotationFromAxis but updates the passed ref Vector3 parameter.
|
|
|
|
+ */
|
|
|
|
+ Vector3.RotationFromAxisToRef = function (axis1, axis2, axis3, ref) {
|
|
var u = Vector3.Normalize(axis1);
|
|
var u = Vector3.Normalize(axis1);
|
|
var w = Vector3.Normalize(axis3);
|
|
var w = Vector3.Normalize(axis3);
|
|
// world axis
|
|
// world axis
|
|
@@ -935,7 +943,9 @@ var BABYLON;
|
|
if (dot < 0 && nbRevert < 2) {
|
|
if (dot < 0 && nbRevert < 2) {
|
|
yaw = Math.PI + yaw;
|
|
yaw = Math.PI + yaw;
|
|
}
|
|
}
|
|
- return new Vector3(pitch, yaw, roll);
|
|
|
|
|
|
+ ref.x = pitch;
|
|
|
|
+ ref.y = yaw;
|
|
|
|
+ ref.z = roll;
|
|
};
|
|
};
|
|
return Vector3;
|
|
return Vector3;
|
|
})();
|
|
})();
|
|
@@ -2815,7 +2825,13 @@ var BABYLON;
|
|
})();
|
|
})();
|
|
BABYLON.Path2 = Path2;
|
|
BABYLON.Path2 = Path2;
|
|
var Path3D = (function () {
|
|
var Path3D = (function () {
|
|
- function Path3D(path, firstNormal) {
|
|
|
|
|
|
+ /**
|
|
|
|
+ * new Path3D(path, normal, raw)
|
|
|
|
+ * path : an array of Vector3, the curve axis of the Path3D
|
|
|
|
+ * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
|
|
|
|
+ * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
|
|
|
|
+ */
|
|
|
|
+ function Path3D(path, firstNormal, raw) {
|
|
this.path = path;
|
|
this.path = path;
|
|
this._curve = new Array();
|
|
this._curve = new Array();
|
|
this._distances = new Array();
|
|
this._distances = new Array();
|
|
@@ -2825,6 +2841,7 @@ var BABYLON;
|
|
for (var p = 0; p < path.length; p++) {
|
|
for (var p = 0; p < path.length; p++) {
|
|
this._curve[p] = path[p].clone(); // hard copy
|
|
this._curve[p] = path[p].clone(); // hard copy
|
|
}
|
|
}
|
|
|
|
+ this._raw = raw || false;
|
|
this._compute(firstNormal);
|
|
this._compute(firstNormal);
|
|
}
|
|
}
|
|
Path3D.prototype.getCurve = function () {
|
|
Path3D.prototype.getCurve = function () {
|
|
@@ -2856,16 +2873,24 @@ var BABYLON;
|
|
var l = this._curve.length;
|
|
var l = this._curve.length;
|
|
// first and last tangents
|
|
// first and last tangents
|
|
this._tangents[0] = this._getFirstNonNullVector(0);
|
|
this._tangents[0] = this._getFirstNonNullVector(0);
|
|
- this._tangents[0].normalize();
|
|
|
|
|
|
+ if (!this._raw) {
|
|
|
|
+ this._tangents[0].normalize();
|
|
|
|
+ }
|
|
this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
|
|
this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
|
|
- this._tangents[l - 1].normalize();
|
|
|
|
|
|
+ if (!this._raw) {
|
|
|
|
+ this._tangents[l - 1].normalize();
|
|
|
|
+ }
|
|
// normals and binormals at first point : arbitrary vector with _normalVector()
|
|
// normals and binormals at first point : arbitrary vector with _normalVector()
|
|
var tg0 = this._tangents[0];
|
|
var tg0 = this._tangents[0];
|
|
var pp0 = this._normalVector(this._curve[0], tg0, firstNormal);
|
|
var pp0 = this._normalVector(this._curve[0], tg0, firstNormal);
|
|
this._normals[0] = pp0;
|
|
this._normals[0] = pp0;
|
|
- this._normals[0].normalize();
|
|
|
|
|
|
+ if (!this._raw) {
|
|
|
|
+ this._normals[0].normalize();
|
|
|
|
+ }
|
|
this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
|
|
this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
|
|
- this._binormals[0].normalize();
|
|
|
|
|
|
+ if (!this._raw) {
|
|
|
|
+ this._binormals[0].normalize();
|
|
|
|
+ }
|
|
this._distances[0] = 0;
|
|
this._distances[0] = 0;
|
|
// normals and binormals : next points
|
|
// normals and binormals : next points
|
|
var prev; // previous vector (segment)
|
|
var prev; // previous vector (segment)
|
|
@@ -2887,9 +2912,13 @@ var BABYLON;
|
|
curTang = this._tangents[i];
|
|
curTang = this._tangents[i];
|
|
prevBinor = this._binormals[i - 1];
|
|
prevBinor = this._binormals[i - 1];
|
|
this._normals[i] = Vector3.Cross(prevBinor, curTang);
|
|
this._normals[i] = Vector3.Cross(prevBinor, curTang);
|
|
- this._normals[i].normalize();
|
|
|
|
|
|
+ if (!this._raw) {
|
|
|
|
+ this._normals[i].normalize();
|
|
|
|
+ }
|
|
this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
|
|
this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
|
|
- this._binormals[i].normalize();
|
|
|
|
|
|
+ if (!this._raw) {
|
|
|
|
+ this._binormals[i].normalize();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
};
|
|
};
|
|
// private function getFirstNonNullVector(index)
|
|
// private function getFirstNonNullVector(index)
|