in packages/common/src/math/path3.ts [100:156]
private _compute(firstNormal?: Vector3): void {
const l = this._curve.length;
// first and last tangents
this._tangents[0] = this._getFirstNonNullVector(0);
if (!this._raw) {
this._tangents[0].normalize();
}
this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
if (!this._raw) {
this._tangents[l - 1].normalize();
}
// normals and binormals at first point : arbitrary vector with _normalVector()
const tg0 = this._tangents[0];
const pp0 = this._normalVector(this._curve[0], tg0, firstNormal);
this._normals[0] = pp0;
if (!this._raw) {
this._normals[0].normalize();
}
this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
if (!this._raw) {
this._binormals[0].normalize();
}
this._distances[0] = 0.0;
// normals and binormals : next points
let prev: Vector3; // previous vector (segment)
let cur: Vector3; // current vector (segment)
let curTang: Vector3; // current tangent
// previous normal
let prevBinor: Vector3; // previous binormal
for (let i = 1; i < l; i++) {
// tangents
prev = this._getLastNonNullVector(i);
if (i < l - 1) {
cur = this._getFirstNonNullVector(i);
this._tangents[i] = prev.add(cur);
this._tangents[i].normalize();
}
this._distances[i] = this._distances[i - 1] + prev.length();
// normals and binormals
// http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
curTang = this._tangents[i];
prevBinor = this._binormals[i - 1];
this._normals[i] = Vector3.Cross(prevBinor, curTang);
if (!this._raw) {
this._normals[i].normalize();
}
this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
if (!this._raw) {
this._binormals[i].normalize();
}
}
}