|
@@ -203,6 +203,12 @@
|
|
|
BABYLON.Color3.prototype.multiply = function (otherColor) {
|
|
|
return new BABYLON.Color3(this.r * otherColor.r, this.g * otherColor.g, this.b * otherColor.b);
|
|
|
};
|
|
|
+
|
|
|
+ BABYLON.Color3.prototype.multiplyToRef = function (otherColor, result) {
|
|
|
+ result.r = this.r * otherColor.r;
|
|
|
+ result.g = this.g * otherColor.g;
|
|
|
+ result.b = this.b * otherColor.b;
|
|
|
+ };
|
|
|
|
|
|
BABYLON.Color3.prototype.equals = function (otherColor) {
|
|
|
return this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b;
|
|
@@ -212,9 +218,27 @@
|
|
|
return new BABYLON.Color3(this.r * scale, this.g * scale, this.b * scale);
|
|
|
};
|
|
|
|
|
|
+ BABYLON.Color3.prototype.scaleToRef = function (scale, result) {
|
|
|
+ result.r = this.r * scale;
|
|
|
+ result.g = this.g * scale;
|
|
|
+ result.b = this.b * scale;
|
|
|
+ };
|
|
|
+
|
|
|
BABYLON.Color3.prototype.clone = function () {
|
|
|
return new BABYLON.Color3(this.r, this.g, this.b);
|
|
|
};
|
|
|
+
|
|
|
+ BABYLON.Color3.prototype.copyFrom = function (source) {
|
|
|
+ this.r = source.r;
|
|
|
+ this.g = source.g;
|
|
|
+ this.b = source.b;
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Color3.prototype.copyFromFloats = function (r, g, b) {
|
|
|
+ this.r = r;
|
|
|
+ this.g = g;
|
|
|
+ this.b = b;
|
|
|
+ };
|
|
|
|
|
|
// Statics
|
|
|
BABYLON.Color3.FromArray = function (array) {
|
|
@@ -231,6 +255,13 @@
|
|
|
};
|
|
|
|
|
|
// Operators
|
|
|
+ BABYLON.Color4.prototype.addInPlace = function (right) {
|
|
|
+ this.r += right.r;
|
|
|
+ this.g += right.g;
|
|
|
+ this.b += right.b;
|
|
|
+ this.a += right.a;
|
|
|
+ };
|
|
|
+
|
|
|
BABYLON.Color4.prototype.add = function (right) {
|
|
|
return new BABYLON.Color4(this.r + right.r, this.g + right.g, this.b + right.b, this.a + right.a);
|
|
|
};
|
|
@@ -239,9 +270,23 @@
|
|
|
return new BABYLON.Color4(this.r - right.r, this.g - right.g, this.b - right.b, this.a - right.a);
|
|
|
};
|
|
|
|
|
|
+ BABYLON.Color4.prototype.subtractToRef = function (right, result) {
|
|
|
+ result.r = this.r - right.r;
|
|
|
+ result.g = this.g - right.g;
|
|
|
+ result.b = this.b - right.b;
|
|
|
+ result.a = this.a - right.a;
|
|
|
+ };
|
|
|
+
|
|
|
BABYLON.Color4.prototype.scale = function (scale) {
|
|
|
return new BABYLON.Color4(this.r * scale, this.g * scale, this.b * scale, this.a * scale);
|
|
|
};
|
|
|
+
|
|
|
+ BABYLON.Color4.prototype.scaleToRef = function (scale, result) {
|
|
|
+ result.r = this.r * scale;
|
|
|
+ result.g = this.g * scale;
|
|
|
+ result.b = this.b * scale;
|
|
|
+ result.a = this.a * scale;
|
|
|
+ };
|
|
|
|
|
|
BABYLON.Color4.prototype.toString = function () {
|
|
|
return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
|
|
@@ -253,12 +298,18 @@
|
|
|
|
|
|
// Statics
|
|
|
BABYLON.Color4.Lerp = function(left, right, amount) {
|
|
|
- var r = left.r + (right.r - left.r) * amount;
|
|
|
- var g = left.g + (right.g - left.g) * amount;
|
|
|
- var b = left.b + (right.b - left.b) * amount;
|
|
|
- var a = left.a + (right.a - left.a) * amount;
|
|
|
+ var result = new BABYLON.Color4(0, 0, 0, 0);
|
|
|
|
|
|
- return new BABYLON.Color4(r, g, b, a);
|
|
|
+ BABYLON.Color4.LerpToRef(left, right, amount, result);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Color4.LerpToRef = function (left, right, amount, result) {
|
|
|
+ result.r = left.r + (right.r - left.r) * amount;
|
|
|
+ result.g = left.g + (right.g - left.g) * amount;
|
|
|
+ result.b = left.b + (right.b - left.b) * amount;
|
|
|
+ result.a = left.a + (right.a - left.a) * amount;
|
|
|
};
|
|
|
|
|
|
BABYLON.Color4.FromArray = function (array, offset) {
|
|
@@ -292,6 +343,11 @@
|
|
|
BABYLON.Vector2.prototype.negate = function () {
|
|
|
return new BABYLON.Vector2(-this.x, -this.y);
|
|
|
};
|
|
|
+
|
|
|
+ BABYLON.Vector2.prototype.scaleInPlace = function (scale) {
|
|
|
+ this.x *= scale;
|
|
|
+ this.y *= scale;
|
|
|
+ };
|
|
|
|
|
|
BABYLON.Vector2.prototype.scale = function (scale) {
|
|
|
return new BABYLON.Vector2(this.x * scale, this.y * scale);
|
|
@@ -435,33 +491,101 @@
|
|
|
};
|
|
|
|
|
|
// Operators
|
|
|
+ BABYLON.Vector3.prototype.addInPlace = function (otherVector) {
|
|
|
+ this.x += otherVector.x;
|
|
|
+ this.y += otherVector.y;
|
|
|
+ this.z += otherVector.z;
|
|
|
+ };
|
|
|
+
|
|
|
BABYLON.Vector3.prototype.add = function (otherVector) {
|
|
|
return new BABYLON.Vector3(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
|
|
|
};
|
|
|
+
|
|
|
+ BABYLON.Vector3.prototype.addToRef = function (otherVector, result) {
|
|
|
+ result.x = this.x + otherVector.x;
|
|
|
+ result.y = this.y + otherVector.y;
|
|
|
+ result.z = this.z + otherVector.z;
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Vector3.prototype.subtractInPlace = function (otherVector) {
|
|
|
+ this.x -= otherVector.x;
|
|
|
+ this.y -= otherVector.y;
|
|
|
+ this.z -= otherVector.z;
|
|
|
+ };
|
|
|
|
|
|
BABYLON.Vector3.prototype.subtract = function (otherVector) {
|
|
|
return new BABYLON.Vector3(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z);
|
|
|
};
|
|
|
+
|
|
|
+ BABYLON.Vector3.prototype.subtractToRef = function (otherVector, result) {
|
|
|
+ result.x = this.x - otherVector.x;
|
|
|
+ result.y = this.y - otherVector.y;
|
|
|
+ result.z = this.z - otherVector.z;
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Vector3.prototype.subtractFromFloats = function (x, y, z) {
|
|
|
+ return new BABYLON.Vector3(this.x - x, this.y - y, this.z - z);
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Vector3.prototype.subtractFromFloatsToRef = function (x, y, z, result) {
|
|
|
+ result.x = this.x - x;
|
|
|
+ result.y = this.y - y;
|
|
|
+ result.z = this.z - z;
|
|
|
+ };
|
|
|
|
|
|
BABYLON.Vector3.prototype.negate = function () {
|
|
|
return new BABYLON.Vector3(-this.x, -this.y, -this.z);
|
|
|
};
|
|
|
+
|
|
|
+ BABYLON.Vector3.prototype.scaleInPlace = function (scale) {
|
|
|
+ this.x *= scale;
|
|
|
+ this.y *= scale;
|
|
|
+ this.z *= scale;
|
|
|
+ };
|
|
|
|
|
|
BABYLON.Vector3.prototype.scale = function (scale) {
|
|
|
return new BABYLON.Vector3(this.x * scale, this.y * scale, this.z * scale);
|
|
|
};
|
|
|
+
|
|
|
+ BABYLON.Vector3.prototype.scaleToRef = function (scale, result) {
|
|
|
+ result.x = this.x * scale;
|
|
|
+ result.y = this.y * scale;
|
|
|
+ result.z = this.z * scale;
|
|
|
+ };
|
|
|
|
|
|
BABYLON.Vector3.prototype.equals = function (otherVector) {
|
|
|
return this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z;
|
|
|
};
|
|
|
+
|
|
|
+ BABYLON.Vector3.prototype.equalsToFloats = function (x, y, z) {
|
|
|
+ return this.x === x && this.y === y && this.z === z;
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Vector3.prototype.multiplyInPlace = function (otherVector) {
|
|
|
+ this.x *= otherVector.x;
|
|
|
+ this.y *= otherVector.y;
|
|
|
+ this.z *= otherVector.z;
|
|
|
+ };
|
|
|
|
|
|
BABYLON.Vector3.prototype.multiply = function (otherVector) {
|
|
|
return new BABYLON.Vector3(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z);
|
|
|
};
|
|
|
+
|
|
|
+ BABYLON.Vector3.prototype.multiplyToRef = function (otherVector, result) {
|
|
|
+ result.x = this.x * otherVector.x;
|
|
|
+ result.y = this.y * otherVector.y;
|
|
|
+ result.z = this.z * otherVector.z;
|
|
|
+ };
|
|
|
|
|
|
BABYLON.Vector3.prototype.divide = function (otherVector) {
|
|
|
return new BABYLON.Vector3(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
|
|
|
};
|
|
|
+
|
|
|
+ BABYLON.Vector3.prototype.divideToRef = function (otherVector, result) {
|
|
|
+ result.x = this.x / otherVector.x;
|
|
|
+ result.y = this.y / otherVector.y;
|
|
|
+ result.z = this.z / otherVector.z;
|
|
|
+ };
|
|
|
|
|
|
// Properties
|
|
|
BABYLON.Vector3.prototype.length = function () {
|
|
@@ -489,6 +613,18 @@
|
|
|
BABYLON.Vector3.prototype.clone = function () {
|
|
|
return new BABYLON.Vector3(this.x, this.y, this.z);
|
|
|
};
|
|
|
+
|
|
|
+ BABYLON.Vector3.prototype.copyFrom = function (source) {
|
|
|
+ this.x = source.x;
|
|
|
+ this.y = source.y;
|
|
|
+ this.z = source.z;
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Vector3.prototype.copyFromFloats = function (x, y, z) {
|
|
|
+ this.x = x;
|
|
|
+ this.y = y;
|
|
|
+ this.z = z;
|
|
|
+ };
|
|
|
|
|
|
// Statics
|
|
|
BABYLON.Vector3.FromArray = function (array, offset) {
|
|
@@ -498,6 +634,22 @@
|
|
|
|
|
|
return new BABYLON.Vector3(array[offset], array[offset + 1], array[offset + 2]);
|
|
|
};
|
|
|
+
|
|
|
+ BABYLON.Vector3.FromArrayToRef = function (array, offset, result) {
|
|
|
+ if (!offset) {
|
|
|
+ offset = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ result.x = array[offset];
|
|
|
+ result.y = array[offset + 1];
|
|
|
+ result.z = array[offset + 2];
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Vector3.FromFloatsToRef = function (x, y, z, result) {
|
|
|
+ result.x = x;
|
|
|
+ result.y = y;
|
|
|
+ result.z = z;
|
|
|
+ };
|
|
|
|
|
|
BABYLON.Vector3.Zero = function () {
|
|
|
return new BABYLON.Vector3(0, 0, 0);
|
|
@@ -508,22 +660,54 @@
|
|
|
};
|
|
|
|
|
|
BABYLON.Vector3.TransformCoordinates = function (vector, transformation) {
|
|
|
+ var result = BABYLON.Vector3.Zero();
|
|
|
+
|
|
|
+ BABYLON.Vector3.TransformCoordinatesToRef(vector, transformation, result);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Vector3.TransformCoordinatesToRef = function (vector, transformation, result) {
|
|
|
var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]) + transformation.m[12];
|
|
|
var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]) + transformation.m[13];
|
|
|
var z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]) + transformation.m[14];
|
|
|
var w = (vector.x * transformation.m[3]) + (vector.y * transformation.m[7]) + (vector.z * transformation.m[11]) + transformation.m[15];
|
|
|
|
|
|
- return new BABYLON.Vector3(x / w, y / w, z / w);
|
|
|
+ result.x = x / w;
|
|
|
+ result.y = y / w;
|
|
|
+ result.z = z / w;
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Vector3.TransformCoordinatesFromFloatsToRef = function (x, y ,z, transformation, result) {
|
|
|
+ var rx = (x * transformation.m[0]) + (y * transformation.m[4]) + (z * transformation.m[8]) + transformation.m[12];
|
|
|
+ var ry = (x * transformation.m[1]) + (y * transformation.m[5]) + (z * transformation.m[9]) + transformation.m[13];
|
|
|
+ var rz = (x * transformation.m[2]) + (y * transformation.m[6]) + (z * transformation.m[10]) + transformation.m[14];
|
|
|
+ var rw = (x * transformation.m[3]) + (y * transformation.m[7]) + (z * transformation.m[11]) + transformation.m[15];
|
|
|
+
|
|
|
+ result.x = rx / rw;
|
|
|
+ result.y = ry / rw;
|
|
|
+ result.z = rz / rw;
|
|
|
};
|
|
|
|
|
|
BABYLON.Vector3.TransformNormal = function (vector, transformation) {
|
|
|
- var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]);
|
|
|
- var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]);
|
|
|
- var z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]);
|
|
|
+ var result = BABYLON.Vector3.Zero();
|
|
|
|
|
|
- return new BABYLON.Vector3(x, y, z);
|
|
|
+ BABYLON.Vector3.TransformNormalToRef(vector, transformation, result);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Vector3.TransformNormalToRef = function (vector, transformation, result) {
|
|
|
+ result.x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]);
|
|
|
+ result.y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]);
|
|
|
+ result.z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]);
|
|
|
};
|
|
|
|
|
|
+ BABYLON.Vector3.TransformNormalFromFloatsToRef = function (x, y, z, transformation, result) {
|
|
|
+ result.x = (x * transformation.m[0]) + (y * transformation.m[4]) + (z * transformation.m[8]);
|
|
|
+ result.y = (x * transformation.m[1]) + (y * transformation.m[5]) + (z * transformation.m[9]);
|
|
|
+ result.z = (x * transformation.m[2]) + (y * transformation.m[6]) + (z * transformation.m[10]);
|
|
|
+ };
|
|
|
|
|
|
BABYLON.Vector3.CatmullRom = function (value1, value2, value3, value4, amount) {
|
|
|
var squared = amount * amount;
|
|
@@ -588,17 +772,28 @@
|
|
|
};
|
|
|
|
|
|
BABYLON.Vector3.Cross = function (left, right) {
|
|
|
- var x = left.y * right.z - left.z * right.y;
|
|
|
- var y = left.z * right.x - left.x * right.z;
|
|
|
- var z = left.x * right.y - left.y * right.x;
|
|
|
+ var result = BABYLON.Vector3.Zero();
|
|
|
|
|
|
- return new BABYLON.Vector3(x, y, z);
|
|
|
+ BABYLON.Vector3.CrossToRef(left, right, result);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Vector3.CrossToRef = function (left, right, result) {
|
|
|
+ result.x = left.y * right.z - left.z * right.y;
|
|
|
+ result.y = left.z * right.x - left.x * right.z;
|
|
|
+ result.z = left.x * right.y - left.y * right.x;
|
|
|
};
|
|
|
|
|
|
BABYLON.Vector3.Normalize = function (vector) {
|
|
|
- var newVector = vector.clone();
|
|
|
- newVector.normalize();
|
|
|
- return newVector;
|
|
|
+ var result = BABYLON.Vector3.Zero();
|
|
|
+ BABYLON.Vector3.NormalizeToRef(vector, result);
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Vector3.NormalizeToRef = function (vector, result) {
|
|
|
+ result.copyFrom(vector);
|
|
|
+ result.normalize();
|
|
|
};
|
|
|
|
|
|
BABYLON.Vector3.Unproject = function (source, viewportWidth, viewportHeight, world, view, projection) {
|
|
@@ -680,6 +875,36 @@
|
|
|
return new BABYLON.Vector3(x, y, z);
|
|
|
};
|
|
|
|
|
|
+ BABYLON.Quaternion.prototype.toRotationMatrix = function(result)
|
|
|
+ {
|
|
|
+ var xx = this.x * this.x;
|
|
|
+ var yy = this.y * this.y;
|
|
|
+ var zz = this.z * this.z;
|
|
|
+ var xy = this.x * this.y;
|
|
|
+ var zw = this.z * this.w;
|
|
|
+ var zx = this.z * this.x;
|
|
|
+ var yw = this.y * this.w;
|
|
|
+ var yz = this.y * this.z;
|
|
|
+ var xw = this.x * this.w;
|
|
|
+
|
|
|
+ result.m[0] = 1.0 - (2.0 * (yy + zz));
|
|
|
+ result.m[1] = 2.0 * (xy + zw);
|
|
|
+ result.m[2] = 2.0 * (zx - yw);
|
|
|
+ result.m[3] = 0;
|
|
|
+ result.m[4] = 2.0 * (xy - zw);
|
|
|
+ result.m[5] = 1.0 - (2.0 * (zz + xx));
|
|
|
+ result.m[6] = 2.0 * (yz + xw);
|
|
|
+ result.m[7] = 0;
|
|
|
+ result.m[8] = 2.0 * (zx + yw);
|
|
|
+ result.m[9] = 2.0 * (yz - xw);
|
|
|
+ result.m[10] = 1.0 - (2.0 * (yy + xx));
|
|
|
+ result.m[11] = 0;
|
|
|
+ result.m[12] = 0;
|
|
|
+ result.m[13] = 0;
|
|
|
+ result.m[14] = 0;
|
|
|
+ result.m[15] = 1.0;
|
|
|
+ };
|
|
|
+
|
|
|
// Statics
|
|
|
BABYLON.Quaternion.FromArray = function (array, offset) {
|
|
|
if (!offset) {
|
|
@@ -689,6 +914,33 @@
|
|
|
return new BABYLON.Quaternion(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
|
|
|
};
|
|
|
|
|
|
+ BABYLON.Quaternion.RotationYawPitchRoll = function(yaw, pitch, roll) {
|
|
|
+ var result = new BABYLON.Quaternion();
|
|
|
+
|
|
|
+ BABYLON.Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, result);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Quaternion.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
|
|
|
+ var halfRoll = roll * 0.5;
|
|
|
+ var halfPitch = pitch * 0.5;
|
|
|
+ var halfYaw = yaw * 0.5;
|
|
|
+
|
|
|
+ var sinRoll = Math.sin(halfRoll);
|
|
|
+ var cosRoll = Math.cos(halfRoll);
|
|
|
+ var sinPitch = Math.sin(halfPitch);
|
|
|
+ var cosPitch = Math.cos(halfPitch);
|
|
|
+ var sinYaw = Math.sin(halfYaw);
|
|
|
+ var cosYaw = Math.cos(halfYaw);
|
|
|
+
|
|
|
+ result.x = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);
|
|
|
+ result.y = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);
|
|
|
+ result.z = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);
|
|
|
+ result.w = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
BABYLON.Quaternion.Slerp = function(left, right, amount) {
|
|
|
var num2;
|
|
|
var num3;
|
|
@@ -720,12 +972,12 @@
|
|
|
|
|
|
////////////////////////////////// Matrix //////////////////////////////////
|
|
|
|
|
|
- if(!MatrixType) {
|
|
|
- var MatrixType = (typeof Float32Array !== 'undefined') ? Float32Array : Array;
|
|
|
+ if (!BABYLON.MatrixType) {
|
|
|
+ BABYLON.MatrixType = (typeof Float32Array !== 'undefined') ? Float32Array : Array;
|
|
|
}
|
|
|
|
|
|
BABYLON.Matrix = function () {
|
|
|
- this.m = new MatrixType(16);
|
|
|
+ this.m = new BABYLON.MatrixType(16);
|
|
|
};
|
|
|
|
|
|
// Properties
|
|
@@ -822,6 +1074,12 @@
|
|
|
BABYLON.Matrix.prototype.multiply = function (other) {
|
|
|
var result = new BABYLON.Matrix();
|
|
|
|
|
|
+ this.multiplyToRef(other, result);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Matrix.prototype.multiplyToRef = function (other, result) {
|
|
|
result.m[0] = this.m[0] * other.m[0] + this.m[1] * other.m[4] + this.m[2] * other.m[8] + this.m[3] * other.m[12];
|
|
|
result.m[1] = this.m[0] * other.m[1] + this.m[1] * other.m[5] + this.m[2] * other.m[9] + this.m[3] * other.m[13];
|
|
|
result.m[2] = this.m[0] * other.m[2] + this.m[1] * other.m[6] + this.m[2] * other.m[10] + this.m[3] * other.m[14];
|
|
@@ -841,8 +1099,6 @@
|
|
|
result.m[13] = this.m[12] * other.m[1] + this.m[13] * other.m[5] + this.m[14] * other.m[9] + this.m[15] * other.m[13];
|
|
|
result.m[14] = this.m[12] * other.m[2] + this.m[13] * other.m[6] + this.m[14] * other.m[10] + this.m[15] * other.m[14];
|
|
|
result.m[15] = this.m[12] * other.m[3] + this.m[13] * other.m[7] + this.m[14] * other.m[11] + this.m[15] * other.m[15];
|
|
|
-
|
|
|
- return result;
|
|
|
};
|
|
|
|
|
|
BABYLON.Matrix.prototype.equals = function (value) {
|
|
@@ -860,6 +1116,29 @@
|
|
|
};
|
|
|
|
|
|
// Statics
|
|
|
+ BABYLON.Matrix.FromValuesToRef = function (initialM11, initialM12, initialM13, initialM14,
|
|
|
+ initialM21, initialM22, initialM23, initialM24,
|
|
|
+ initialM31, initialM32, initialM33, initialM34,
|
|
|
+ initialM41, initialM42, initialM43, initialM44, result) {
|
|
|
+
|
|
|
+ result.m[0] = initialM11;
|
|
|
+ result.m[1] = initialM12;
|
|
|
+ result.m[2] = initialM13;
|
|
|
+ result.m[3] = initialM14;
|
|
|
+ result.m[4] = initialM21;
|
|
|
+ result.m[5] = initialM22;
|
|
|
+ result.m[6] = initialM23;
|
|
|
+ result.m[7] = initialM24;
|
|
|
+ result.m[8] = initialM31;
|
|
|
+ result.m[9] = initialM32;
|
|
|
+ result.m[10] = initialM33;
|
|
|
+ result.m[11] = initialM34;
|
|
|
+ result.m[12] = initialM41;
|
|
|
+ result.m[13] = initialM42;
|
|
|
+ result.m[14] = initialM43;
|
|
|
+ result.m[15] = initialM44;
|
|
|
+ };
|
|
|
+
|
|
|
BABYLON.Matrix.FromValues = function (initialM11, initialM12, initialM13, initialM14,
|
|
|
initialM21, initialM22, initialM23, initialM24,
|
|
|
initialM31, initialM32, initialM33, initialM34,
|
|
@@ -893,6 +1172,13 @@
|
|
|
0, 0, 1.0, 0,
|
|
|
0, 0, 0, 1.0);
|
|
|
};
|
|
|
+
|
|
|
+ BABYLON.Matrix.IdentityToRef = function (result) {
|
|
|
+ BABYLON.Matrix.FromValuesToRef(1.0, 0, 0, 0,
|
|
|
+ 0, 1.0, 0, 0,
|
|
|
+ 0, 0, 1.0, 0,
|
|
|
+ 0, 0, 0, 1.0, result);
|
|
|
+ };
|
|
|
|
|
|
BABYLON.Matrix.Zero = function () {
|
|
|
return BABYLON.Matrix.FromValues(0, 0, 0, 0,
|
|
@@ -902,7 +1188,14 @@
|
|
|
};
|
|
|
|
|
|
BABYLON.Matrix.RotationX = function (angle) {
|
|
|
- var result = BABYLON.Matrix.Zero();
|
|
|
+ var result = new BABYLON.Matrix();
|
|
|
+
|
|
|
+ BABYLON.Matrix.RotationXToRef(angle, result);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Matrix.RotationXToRef = function (angle, result) {
|
|
|
var s = Math.sin(angle);
|
|
|
var c = Math.cos(angle);
|
|
|
|
|
@@ -914,11 +1207,27 @@
|
|
|
result.m[9] = -s;
|
|
|
result.m[6] = s;
|
|
|
|
|
|
- return result;
|
|
|
+ result.m[1] = 0;
|
|
|
+ result.m[2] = 0;
|
|
|
+ result.m[3] = 0;
|
|
|
+ result.m[4] = 0;
|
|
|
+ result.m[7] = 0;
|
|
|
+ result.m[8] = 0;
|
|
|
+ result.m[11] = 0;
|
|
|
+ result.m[12] = 0;
|
|
|
+ result.m[13] = 0;
|
|
|
+ result.m[14] = 0;
|
|
|
};
|
|
|
|
|
|
BABYLON.Matrix.RotationY = function (angle) {
|
|
|
- var result = BABYLON.Matrix.Zero();
|
|
|
+ var result = new BABYLON.Matrix();
|
|
|
+
|
|
|
+ BABYLON.Matrix.RotationYToRef(angle, result);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Matrix.RotationYToRef = function (angle, result) {
|
|
|
var s = Math.sin(angle);
|
|
|
var c = Math.cos(angle);
|
|
|
|
|
@@ -930,11 +1239,27 @@
|
|
|
result.m[8] = s;
|
|
|
result.m[10] = c;
|
|
|
|
|
|
+ result.m[1] = 0;
|
|
|
+ result.m[3] = 0;
|
|
|
+ result.m[4] = 0;
|
|
|
+ result.m[6] = 0;
|
|
|
+ result.m[7] = 0;
|
|
|
+ result.m[9] = 0;
|
|
|
+ result.m[11] = 0;
|
|
|
+ result.m[12] = 0;
|
|
|
+ result.m[13] = 0;
|
|
|
+ result.m[14] = 0;
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Matrix.RotationZ = function (angle) {
|
|
|
+ var result = new BABYLON.Matrix();
|
|
|
+
|
|
|
+ BABYLON.Matrix.RotationZToRef(angle, result);
|
|
|
+
|
|
|
return result;
|
|
|
};
|
|
|
|
|
|
- BABYLON.Matrix.RotationZ = function (angle) {
|
|
|
- var result = BABYLON.Matrix.Zero();
|
|
|
+ BABYLON.Matrix.RotationZToRef = function (angle, result) {
|
|
|
var s = Math.sin(angle);
|
|
|
var c = Math.cos(angle);
|
|
|
|
|
@@ -945,8 +1270,17 @@
|
|
|
result.m[1] = s;
|
|
|
result.m[4] = -s;
|
|
|
result.m[5] = c;
|
|
|
-
|
|
|
- return result;
|
|
|
+
|
|
|
+ result.m[2] = 0;
|
|
|
+ result.m[3] = 0;
|
|
|
+ result.m[6] = 0;
|
|
|
+ result.m[7] = 0;
|
|
|
+ result.m[8] = 0;
|
|
|
+ result.m[9] = 0;
|
|
|
+ result.m[11] = 0;
|
|
|
+ result.m[12] = 0;
|
|
|
+ result.m[13] = 0;
|
|
|
+ result.m[14] = 0;
|
|
|
};
|
|
|
|
|
|
BABYLON.Matrix.RotationAxis = function (axis, angle) {
|
|
@@ -978,41 +1312,86 @@
|
|
|
};
|
|
|
|
|
|
BABYLON.Matrix.RotationYawPitchRoll = function (yaw, pitch, roll) {
|
|
|
- return BABYLON.Matrix.RotationZ(roll).multiply(BABYLON.Matrix.RotationX(pitch)).multiply(BABYLON.Matrix.RotationY(yaw));
|
|
|
+ var result = new BABYLON.Matrix();
|
|
|
+
|
|
|
+ BABYLON.Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, result);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ var tempQuaternion = new BABYLON.Quaternion(); // For RotationYawPitchRoll
|
|
|
+ BABYLON.Matrix.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
|
|
|
+ BABYLON.Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, tempQuaternion);
|
|
|
+
|
|
|
+ tempQuaternion.toRotationMatrix(result);
|
|
|
};
|
|
|
|
|
|
BABYLON.Matrix.Scaling = function (x, y, z) {
|
|
|
var result = BABYLON.Matrix.Zero();
|
|
|
|
|
|
+ BABYLON.Matrix.ScalingToRef(x, y, z, result);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Matrix.ScalingToRef = function (x, y, z, result) {
|
|
|
result.m[0] = x;
|
|
|
+ result.m[1] = 0;
|
|
|
+ result.m[2] = 0;
|
|
|
+ result.m[3] = 0;
|
|
|
+ result.m[4] = 0;
|
|
|
result.m[5] = y;
|
|
|
+ result.m[6] = 0;
|
|
|
+ result.m[7] = 0;
|
|
|
+ result.m[8] = 0;
|
|
|
+ result.m[9] = 0;
|
|
|
result.m[10] = z;
|
|
|
+ result.m[11] = 0;
|
|
|
+ result.m[12] = 0;
|
|
|
+ result.m[13] = 0;
|
|
|
+ result.m[14] = 0;
|
|
|
result.m[15] = 1.0;
|
|
|
-
|
|
|
- return result;
|
|
|
};
|
|
|
|
|
|
BABYLON.Matrix.Translation = function (x, y, z) {
|
|
|
var result = BABYLON.Matrix.Identity();
|
|
|
|
|
|
- result.m[12] = x;
|
|
|
- result.m[13] = y;
|
|
|
- result.m[14] = z;
|
|
|
+ BABYLON.Matrix.TranslationToRef(x, y, z, result);
|
|
|
|
|
|
return result;
|
|
|
};
|
|
|
+
|
|
|
+ BABYLON.Matrix.TranslationToRef = function (x, y, z, result) {
|
|
|
+ BABYLON.Matrix.FromValuesToRef(1.0, 0, 0, 0,
|
|
|
+ 0, 1.0, 0, 0,
|
|
|
+ 0, 0, 1.0, 0,
|
|
|
+ x, y, z, 1.0, result);
|
|
|
+ };
|
|
|
|
|
|
BABYLON.Matrix.LookAtLH = function (eye, target, up) {
|
|
|
+ var result = BABYLON.Matrix.Zero();
|
|
|
+
|
|
|
+ BABYLON.Matrix.LookAtLHToRef(eye, target, up, result);
|
|
|
+
|
|
|
+ return result;
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ var xAxis = BABYLON.Vector3.Zero();
|
|
|
+ var yAxis = BABYLON.Vector3.Zero();
|
|
|
+ var zAxis = BABYLON.Vector3.Zero();
|
|
|
+ BABYLON.Matrix.LookAtLHToRef = function (eye, target, up, result) {
|
|
|
// Z axis
|
|
|
- var zAxis = target.subtract(eye);
|
|
|
+ target.subtractToRef(eye, zAxis);
|
|
|
zAxis.normalize();
|
|
|
|
|
|
// X axis
|
|
|
- var xAxis = BABYLON.Vector3.Cross(up, zAxis);
|
|
|
+ BABYLON.Vector3.CrossToRef(up, zAxis, xAxis);
|
|
|
xAxis.normalize();
|
|
|
|
|
|
// Y axis
|
|
|
- var yAxis = BABYLON.Vector3.Cross(zAxis, xAxis);
|
|
|
+ BABYLON.Vector3.CrossToRef(zAxis, xAxis, yAxis);
|
|
|
yAxis.normalize();
|
|
|
|
|
|
// Eye angles
|
|
@@ -1020,10 +1399,10 @@
|
|
|
var ey = -BABYLON.Vector3.Dot(yAxis, eye);
|
|
|
var ez = -BABYLON.Vector3.Dot(zAxis, eye);
|
|
|
|
|
|
- return BABYLON.Matrix.FromValues(xAxis.x, yAxis.x, zAxis.x, 0,
|
|
|
+ return BABYLON.Matrix.FromValuesToRef(xAxis.x, yAxis.x, zAxis.x, 0,
|
|
|
xAxis.y, yAxis.y, zAxis.y, 0,
|
|
|
xAxis.z, yAxis.z, zAxis.z, 0,
|
|
|
- ex, ey, ez, 1);
|
|
|
+ ex, ey, ez, 1, result);
|
|
|
};
|
|
|
|
|
|
BABYLON.Matrix.OrthoLH = function (width, height, znear, zfar) {
|
|
@@ -1041,19 +1420,23 @@
|
|
|
BABYLON.Matrix.OrthoOffCenterLH = function (left, right, bottom, top, znear, zfar) {
|
|
|
var matrix = BABYLON.Matrix.Zero();
|
|
|
|
|
|
- matrix.m[0] = 2.0 / (right - left);
|
|
|
- matrix.m[1] = matrix.m[2] = matrix.m[3] = 0;
|
|
|
- matrix.m[5] = 2.0 / (top - bottom);
|
|
|
- matrix.m[4] = matrix.m[6] = matrix.m[7] = 0;
|
|
|
- matrix.m[10] = -1.0 / (znear - zfar);
|
|
|
- matrix.m[8] = matrix.m[9] = matrix.m[11] = 0;
|
|
|
- matrix.m[12] = (left + right) / (left - right);
|
|
|
- matrix.m[13] = (top + bottom) / (bottom - top);
|
|
|
- matrix.m[14] = znear / (znear - zfar);
|
|
|
- matrix.m[15] = 1.0;
|
|
|
+ BABYLON.Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, matrix);
|
|
|
|
|
|
return matrix;
|
|
|
};
|
|
|
+
|
|
|
+ BABYLON.Matrix.OrthoOffCenterLHToRef = function (left, right, bottom, top, znear, zfar, result) {
|
|
|
+ result.m[0] = 2.0 / (right - left);
|
|
|
+ result.m[1] = result.m[2] = result.m[3] = 0;
|
|
|
+ result.m[5] = 2.0 / (top - bottom);
|
|
|
+ result.m[4] = result.m[6] = result.m[7] = 0;
|
|
|
+ result.m[10] = -1.0 / (znear - zfar);
|
|
|
+ result.m[8] = result.m[9] = result.m[11] = 0;
|
|
|
+ result.m[12] = (left + right) / (left - right);
|
|
|
+ result.m[13] = (top + bottom) / (bottom - top);
|
|
|
+ result.m[14] = znear / (znear - zfar);
|
|
|
+ result.m[15] = 1.0;
|
|
|
+ };
|
|
|
|
|
|
BABYLON.Matrix.PerspectiveLH = function (width, height, znear, zfar) {
|
|
|
var matrix = BABYLON.Matrix.Zero();
|
|
@@ -1074,19 +1457,23 @@
|
|
|
BABYLON.Matrix.PerspectiveFovLH = function (fov, aspect, znear, zfar) {
|
|
|
var matrix = BABYLON.Matrix.Zero();
|
|
|
|
|
|
+ BABYLON.Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
|
|
|
+
|
|
|
+ return matrix;
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result) {
|
|
|
var tan = 1.0 / (Math.tan(fov * 0.5));
|
|
|
|
|
|
- matrix.m[0] = tan / aspect;
|
|
|
- matrix.m[1] = matrix.m[2] = matrix.m[3] = 0.0;
|
|
|
- matrix.m[5] = tan;
|
|
|
- matrix.m[4] = matrix.m[6] = matrix.m[7] = 0.0;
|
|
|
- matrix.m[8] = matrix.m[9] = 0.0;
|
|
|
- matrix.m[10] = -zfar / (znear - zfar);
|
|
|
- matrix.m[11] = 1.0;
|
|
|
- matrix.m[12] = matrix.m[13] = matrix.m[15] = 0.0;
|
|
|
- matrix.m[14] = (znear * zfar) / (znear - zfar);
|
|
|
-
|
|
|
- return matrix;
|
|
|
+ result.m[0] = tan / aspect;
|
|
|
+ result.m[1] = result.m[2] = result.m[3] = 0.0;
|
|
|
+ result.m[5] = tan;
|
|
|
+ result.m[4] = result.m[6] = result.m[7] = 0.0;
|
|
|
+ result.m[8] = result.m[9] = 0.0;
|
|
|
+ result.m[10] = -zfar / (znear - zfar);
|
|
|
+ result.m[11] = 1.0;
|
|
|
+ result.m[12] = result.m[13] = result.m[15] = 0.0;
|
|
|
+ result.m[14] = (znear * zfar) / (znear - zfar);
|
|
|
};
|
|
|
|
|
|
BABYLON.Matrix.AffineTransformation = function (scaling, rotationCenter, rotation, translation) {
|
|
@@ -1139,6 +1526,12 @@
|
|
|
BABYLON.Matrix.Reflection = function (plane) {
|
|
|
var matrix = new BABYLON.Matrix();
|
|
|
|
|
|
+ BABYLON.Matrix.ReflectionToRef(plane, matrix);
|
|
|
+
|
|
|
+ return matrix;
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Matrix.ReflectionToRef = function (plane, result) {
|
|
|
plane.normalize();
|
|
|
var x = plane.normal.x;
|
|
|
var y = plane.normal.y;
|
|
@@ -1146,24 +1539,22 @@
|
|
|
var temp = -2 * x;
|
|
|
var temp2 = -2 * y;
|
|
|
var temp3 = -2 * z;
|
|
|
- matrix.m[0] = (temp * x) + 1;
|
|
|
- matrix.m[1] = temp2 * x;
|
|
|
- matrix.m[2] = temp3 * x;
|
|
|
- matrix.m[3] = 0.0;
|
|
|
- matrix.m[4] = temp * y;
|
|
|
- matrix.m[5] = (temp2 * y) + 1;
|
|
|
- matrix.m[6] = temp3 * y;
|
|
|
- matrix.m[7] = 0.0;
|
|
|
- matrix.m[8] = temp * z;
|
|
|
- matrix.m[9] = temp2 * z;
|
|
|
- matrix.m[10] = (temp3 * z) + 1;
|
|
|
- matrix.m[11] = 0.0;
|
|
|
- matrix.m[12] = temp * plane.d;
|
|
|
- matrix.m[13] = temp2 * plane.d;
|
|
|
- matrix.m[14] = temp3 * plane.d;
|
|
|
- matrix.m[15] = 1.0;
|
|
|
-
|
|
|
- return matrix;
|
|
|
+ result.m[0] = (temp * x) + 1;
|
|
|
+ result.m[1] = temp2 * x;
|
|
|
+ result.m[2] = temp3 * x;
|
|
|
+ result.m[3] = 0.0;
|
|
|
+ result.m[4] = temp * y;
|
|
|
+ result.m[5] = (temp2 * y) + 1;
|
|
|
+ result.m[6] = temp3 * y;
|
|
|
+ result.m[7] = 0.0;
|
|
|
+ result.m[8] = temp * z;
|
|
|
+ result.m[9] = temp2 * z;
|
|
|
+ result.m[10] = (temp3 * z) + 1;
|
|
|
+ result.m[11] = 0.0;
|
|
|
+ result.m[12] = temp * plane.d;
|
|
|
+ result.m[13] = temp2 * plane.d;
|
|
|
+ result.m[14] = temp3 * plane.d;
|
|
|
+ result.m[15] = 1.0;
|
|
|
};
|
|
|
|
|
|
////////////////////////////////// Plane //////////////////////////////////
|
|
@@ -1207,13 +1598,8 @@
|
|
|
BABYLON.Plane.prototype.dotCoordinate = function (point) {
|
|
|
return ((((this.normal.x * point.x) + (this.normal.y * point.y)) + (this.normal.z * point.z)) + this.d);
|
|
|
};
|
|
|
-
|
|
|
- // Statics
|
|
|
- BABYLON.Plane.FromArray = function (array) {
|
|
|
- return new BABYLON.Plane(array[0], array[1], array[2], array[3]);
|
|
|
- };
|
|
|
-
|
|
|
- BABYLON.Plane.FromPoints = function(point1, point2, point3) {
|
|
|
+
|
|
|
+ BABYLON.Plane.prototype.copyFromPoints = function (point1, point2, point3) {
|
|
|
var x1 = point2.x - point1.x;
|
|
|
var y1 = point2.y - point1.y;
|
|
|
var z1 = point2.z - point1.z;
|
|
@@ -1231,59 +1617,107 @@
|
|
|
else
|
|
|
invPyth = 0;
|
|
|
|
|
|
- var normal = new BABYLON.Vector3(yz * invPyth, xz * invPyth, xy * invPyth);
|
|
|
- var d = -((normal.x * point1.x) + (normal.y * point1.y) + (normal.z * point1.z));
|
|
|
- return new BABYLON.Plane(normal.x, normal.y, normal.z, d);
|
|
|
+ this.normal.x = yz * invPyth;
|
|
|
+ this.normal.y = xz * invPyth;
|
|
|
+ this.normal.z = xy * invPyth;
|
|
|
+ this.d = -((this.normal.x * point1.x) + (this.normal.y * point1.y) + (this.normal.z * point1.z));
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Plane.prototype.isFrontFacingTo = function (direction, epsilon) {
|
|
|
+ var dot = BABYLON.Vector3.Dot(this.normal, direction);
|
|
|
+
|
|
|
+ return (dot <= epsilon);
|
|
|
};
|
|
|
|
|
|
+ BABYLON.Plane.prototype.signedDistanceTo = function (point) {
|
|
|
+ return BABYLON.Vector3.Dot(point, this.normal) + this.d;
|
|
|
+ };
|
|
|
+
|
|
|
+ // Statics
|
|
|
+ BABYLON.Plane.FromArray = function (array) {
|
|
|
+ return new BABYLON.Plane(array[0], array[1], array[2], array[3]);
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Plane.FromPoints = function(point1, point2, point3) {
|
|
|
+ var result = new BABYLON.Plane(0, 0, 0, 0);
|
|
|
+
|
|
|
+ result.copyFromPoints(point1, point2, point3);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Plane.FromPositionAndNormal = function (origin, normal) {
|
|
|
+ var result = new BABYLON.Plane(0, 0, 0, 0);
|
|
|
+ normal.normalize();
|
|
|
+
|
|
|
+ result.normal = normal;
|
|
|
+ result.d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Plane.SignedDistanceToPlaneFromPositionAndNormal = function (origin, normal, point) {
|
|
|
+ var d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
|
|
|
+
|
|
|
+ return BABYLON.Vector3.Dot(point, normal) + d;
|
|
|
+ };
|
|
|
////////////////////////////////// Frustum //////////////////////////////////
|
|
|
BABYLON.Frustum = {};
|
|
|
|
|
|
// Statics
|
|
|
BABYLON.Frustum.GetPlanes = function (transform) {
|
|
|
var frustumPlanes = [];
|
|
|
- frustumPlanes.push(new BABYLON.Plane( // near
|
|
|
- transform.m[3] + transform.m[2],
|
|
|
- transform.m[7] + transform.m[6],
|
|
|
- transform.m[10] + transform.m[10],
|
|
|
- transform.m[15] + transform.m[14]));
|
|
|
- frustumPlanes[0].normalize();
|
|
|
+
|
|
|
+ for (var index = 0; index < 6; index++) {
|
|
|
+ frustumPlanes.push(new BABYLON.Plane(0, 0, 0, 0));
|
|
|
+ }
|
|
|
|
|
|
- frustumPlanes.push(new BABYLON.Plane( // far
|
|
|
- transform.m[3] - transform.m[2],
|
|
|
- transform.m[7] - transform.m[6],
|
|
|
- transform.m[11] - transform.m[10],
|
|
|
- transform.m[15] - transform.m[14]));
|
|
|
- frustumPlanes[1].normalize();
|
|
|
+ BABYLON.Frustum.GetPlanesToRef(transform, frustumPlanes);
|
|
|
|
|
|
- frustumPlanes.push(new BABYLON.Plane( // left
|
|
|
- transform.m[3] + transform.m[0],
|
|
|
- transform.m[7] + transform.m[4],
|
|
|
- transform.m[11] + transform.m[8],
|
|
|
- transform.m[15] + transform.m[12]));
|
|
|
+ return frustumPlanes;
|
|
|
+ };
|
|
|
+
|
|
|
+ BABYLON.Frustum.GetPlanesToRef = function (transform, frustumPlanes) {
|
|
|
+ // Near
|
|
|
+ frustumPlanes[0].normal.x = transform.m[3] + transform.m[2];
|
|
|
+ frustumPlanes[0].normal.y = transform.m[7] + transform.m[6];
|
|
|
+ frustumPlanes[0].normal.z = transform.m[10] + transform.m[10];
|
|
|
+ frustumPlanes[0].d = transform.m[15] + transform.m[14];
|
|
|
+ frustumPlanes[0].normalize();
|
|
|
+
|
|
|
+ // Far
|
|
|
+ frustumPlanes[1].normal.x = transform.m[3] - transform.m[2];
|
|
|
+ frustumPlanes[1].normal.y = transform.m[7] - transform.m[6];
|
|
|
+ frustumPlanes[1].normal.z = transform.m[11] - transform.m[10];
|
|
|
+ frustumPlanes[1].d = transform.m[15] - transform.m[14];
|
|
|
+ frustumPlanes[1].normalize();
|
|
|
+
|
|
|
+ // Left
|
|
|
+ frustumPlanes[2].normal.x = transform.m[3] + transform.m[0];
|
|
|
+ frustumPlanes[2].normal.y = transform.m[7] + transform.m[4];
|
|
|
+ frustumPlanes[2].normal.z = transform.m[11] + transform.m[8];
|
|
|
+ frustumPlanes[2].d = transform.m[15] + transform.m[12];
|
|
|
frustumPlanes[2].normalize();
|
|
|
|
|
|
- frustumPlanes.push(new BABYLON.Plane( // right
|
|
|
- transform.m[3] - transform.m[0],
|
|
|
- transform.m[7] - transform.m[4],
|
|
|
- transform.m[11] - transform.m[8],
|
|
|
- transform.m[15] - transform.m[12]));
|
|
|
+ // Right
|
|
|
+ frustumPlanes[3].normal.x = transform.m[3] - transform.m[0];
|
|
|
+ frustumPlanes[3].normal.y = transform.m[7] - transform.m[4];
|
|
|
+ frustumPlanes[3].normal.z = transform.m[11] - transform.m[8];
|
|
|
+ frustumPlanes[3].d = transform.m[15] - transform.m[12];
|
|
|
frustumPlanes[3].normalize();
|
|
|
|
|
|
- frustumPlanes.push(new BABYLON.Plane( // top
|
|
|
- transform.m[3] - transform.m[1],
|
|
|
- transform.m[7] - transform.m[5],
|
|
|
- transform.m[11] - transform.m[9],
|
|
|
- transform.m[15] - transform.m[13]));
|
|
|
+ // Top
|
|
|
+ frustumPlanes[4].normal.x = transform.m[3] - transform.m[1];
|
|
|
+ frustumPlanes[4].normal.y = transform.m[7] - transform.m[5];
|
|
|
+ frustumPlanes[4].normal.z = transform.m[11] - transform.m[9];
|
|
|
+ frustumPlanes[4].d = transform.m[15] - transform.m[13];
|
|
|
frustumPlanes[4].normalize();
|
|
|
|
|
|
- frustumPlanes.push(new BABYLON.Plane( // bottom
|
|
|
- transform.m[3] + transform.m[1],
|
|
|
- transform.m[7] + transform.m[5],
|
|
|
- transform.m[11] + transform.m[9],
|
|
|
- transform.m[15] + transform.m[13]));
|
|
|
+ // Bottom
|
|
|
+ frustumPlanes[5].normal.x = transform.m[3] + transform.m[1];
|
|
|
+ frustumPlanes[5].normal.y = transform.m[7] + transform.m[5];
|
|
|
+ frustumPlanes[5].normal.z = transform.m[11] + transform.m[9];
|
|
|
+ frustumPlanes[5].d = transform.m[15] + transform.m[13];
|
|
|
frustumPlanes[5].normalize();
|
|
|
-
|
|
|
- return frustumPlanes;
|
|
|
};
|
|
|
})();
|