|
@@ -12272,6 +12272,10 @@ var BABYLON;
|
|
*/
|
|
*/
|
|
this.onBeginFrameObservable = new BABYLON.Observable();
|
|
this.onBeginFrameObservable = new BABYLON.Observable();
|
|
/**
|
|
/**
|
|
|
|
+ * If set, will be used to request the next animation frame for the render loop
|
|
|
|
+ */
|
|
|
|
+ this.customAnimationFrameRequester = null;
|
|
|
|
+ /**
|
|
* Observable raised when the engine ends the current frame
|
|
* Observable raised when the engine ends the current frame
|
|
*/
|
|
*/
|
|
this.onEndFrameObservable = new BABYLON.Observable();
|
|
this.onEndFrameObservable = new BABYLON.Observable();
|
|
@@ -13434,11 +13438,16 @@ var BABYLON;
|
|
}
|
|
}
|
|
if (this._activeRenderLoops.length > 0) {
|
|
if (this._activeRenderLoops.length > 0) {
|
|
// Register new frame
|
|
// Register new frame
|
|
- var requester = null;
|
|
|
|
- if (this._vrDisplay && this._vrDisplay.isPresenting) {
|
|
|
|
- requester = this._vrDisplay;
|
|
|
|
|
|
+ if (this.customAnimationFrameRequester) {
|
|
|
|
+ this.customAnimationFrameRequester.requestID = BABYLON.Tools.QueueNewFrame(this.customAnimationFrameRequester.renderFunction || this._bindedRenderFunction, this.customAnimationFrameRequester);
|
|
|
|
+ this._frameHandler = this.customAnimationFrameRequester.requestID;
|
|
|
|
+ }
|
|
|
|
+ else if (this._vrDisplay && this._vrDisplay.isPresenting) {
|
|
|
|
+ this._frameHandler = BABYLON.Tools.QueueNewFrame(this._bindedRenderFunction, this._vrDisplay);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ this._frameHandler = BABYLON.Tools.QueueNewFrame(this._bindedRenderFunction);
|
|
}
|
|
}
|
|
- this._frameHandler = BABYLON.Tools.QueueNewFrame(this._bindedRenderFunction, requester);
|
|
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
this._renderingQueueLaunched = false;
|
|
this._renderingQueueLaunched = false;
|
|
@@ -19208,7 +19217,7 @@ var BABYLON;
|
|
this.minimum.copyFrom(min);
|
|
this.minimum.copyFrom(min);
|
|
this.maximum.copyFrom(max);
|
|
this.maximum.copyFrom(max);
|
|
var distance = BABYLON.Vector3.Distance(min, max);
|
|
var distance = BABYLON.Vector3.Distance(min, max);
|
|
- BABYLON.Vector3.LerpToRef(min, max, 0.5, this.center);
|
|
|
|
|
|
+ max.addToRef(min, this.center).scaleInPlace(0.5);
|
|
this.radius = distance * 0.5;
|
|
this.radius = distance * 0.5;
|
|
this._update(worldMatrix || _identityMatrix);
|
|
this._update(worldMatrix || _identityMatrix);
|
|
};
|
|
};
|
|
@@ -19219,8 +19228,8 @@ var BABYLON;
|
|
*/
|
|
*/
|
|
BoundingSphere.prototype.scale = function (factor) {
|
|
BoundingSphere.prototype.scale = function (factor) {
|
|
var newRadius = this.radius * factor;
|
|
var newRadius = this.radius * factor;
|
|
- var tmpVectors = BABYLON.Tmp.Vector3;
|
|
|
|
- var tempRadiusVector = tmpVectors[0].copyFromFloats(newRadius, newRadius, newRadius);
|
|
|
|
|
|
+ var tmpVectors = BoundingSphere.TmpVector3;
|
|
|
|
+ var tempRadiusVector = tmpVectors[0].setAll(newRadius);
|
|
var min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);
|
|
var min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);
|
|
var max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);
|
|
var max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);
|
|
this.reConstruct(min, max);
|
|
this.reConstruct(min, max);
|
|
@@ -19230,7 +19239,7 @@ var BABYLON;
|
|
/** @hidden */
|
|
/** @hidden */
|
|
BoundingSphere.prototype._update = function (world) {
|
|
BoundingSphere.prototype._update = function (world) {
|
|
BABYLON.Vector3.TransformCoordinatesToRef(this.center, world, this.centerWorld);
|
|
BABYLON.Vector3.TransformCoordinatesToRef(this.center, world, this.centerWorld);
|
|
- var tempVector = BABYLON.Tmp.Vector3[0];
|
|
|
|
|
|
+ var tempVector = BoundingSphere.TmpVector3[0];
|
|
BABYLON.Vector3.TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, world, tempVector);
|
|
BABYLON.Vector3.TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, world, tempVector);
|
|
this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
|
|
this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
|
|
};
|
|
};
|
|
@@ -19253,11 +19262,8 @@ var BABYLON;
|
|
* @returns true if the point is inside the bounding sphere
|
|
* @returns true if the point is inside the bounding sphere
|
|
*/
|
|
*/
|
|
BoundingSphere.prototype.intersectsPoint = function (point) {
|
|
BoundingSphere.prototype.intersectsPoint = function (point) {
|
|
- var x = this.centerWorld.x - point.x;
|
|
|
|
- var y = this.centerWorld.y - point.y;
|
|
|
|
- var z = this.centerWorld.z - point.z;
|
|
|
|
- var distance = Math.sqrt((x * x) + (y * y) + (z * z));
|
|
|
|
- if (this.radiusWorld < distance) {
|
|
|
|
|
|
+ var squareDistance = BABYLON.Vector3.DistanceSquared(this.centerWorld, point);
|
|
|
|
+ if (this.radiusWorld * this.radiusWorld < squareDistance) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
return true;
|
|
@@ -19270,15 +19276,14 @@ var BABYLON;
|
|
* @returns true if the speres intersect
|
|
* @returns true if the speres intersect
|
|
*/
|
|
*/
|
|
BoundingSphere.Intersects = function (sphere0, sphere1) {
|
|
BoundingSphere.Intersects = function (sphere0, sphere1) {
|
|
- var x = sphere0.centerWorld.x - sphere1.centerWorld.x;
|
|
|
|
- var y = sphere0.centerWorld.y - sphere1.centerWorld.y;
|
|
|
|
- var z = sphere0.centerWorld.z - sphere1.centerWorld.z;
|
|
|
|
- var distance = Math.sqrt((x * x) + (y * y) + (z * z));
|
|
|
|
- if (sphere0.radiusWorld + sphere1.radiusWorld < distance) {
|
|
|
|
|
|
+ var squareDistance = BABYLON.Vector3.DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);
|
|
|
|
+ var radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;
|
|
|
|
+ if (radiusSum * radiusSum < squareDistance) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
return true;
|
|
};
|
|
};
|
|
|
|
+ BoundingSphere.TmpVector3 = BABYLON.Tools.BuildArray(3, BABYLON.Vector3.Zero);
|
|
return BoundingSphere;
|
|
return BoundingSphere;
|
|
}());
|
|
}());
|
|
BABYLON.BoundingSphere = BoundingSphere;
|
|
BABYLON.BoundingSphere = BoundingSphere;
|
|
@@ -19366,8 +19371,8 @@ var BABYLON;
|
|
vectors[6].copyFromFloats(minX, maxY, maxZ);
|
|
vectors[6].copyFromFloats(minX, maxY, maxZ);
|
|
vectors[7].copyFromFloats(maxX, minY, maxZ);
|
|
vectors[7].copyFromFloats(maxX, minY, maxZ);
|
|
// OBB
|
|
// OBB
|
|
- this.maximum.addToRef(min, this.center).scaleInPlace(0.5);
|
|
|
|
- this.maximum.subtractToRef(max, this.extendSize).scaleInPlace(0.5);
|
|
|
|
|
|
+ max.addToRef(min, this.center).scaleInPlace(0.5);
|
|
|
|
+ max.subtractToRef(max, this.extendSize).scaleInPlace(0.5);
|
|
this._update(worldMatrix || this._worldMatrix || BABYLON.Matrix.Identity());
|
|
this._update(worldMatrix || this._worldMatrix || BABYLON.Matrix.Identity());
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
@@ -19376,7 +19381,7 @@ var BABYLON;
|
|
* @returns the current bounding box
|
|
* @returns the current bounding box
|
|
*/
|
|
*/
|
|
BoundingBox.prototype.scale = function (factor) {
|
|
BoundingBox.prototype.scale = function (factor) {
|
|
- var tmpVectors = BABYLON.Tmp.Vector3;
|
|
|
|
|
|
+ var tmpVectors = BoundingBox.TmpVector3;
|
|
var diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);
|
|
var diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);
|
|
var len = diff.length();
|
|
var len = diff.length();
|
|
diff.normalizeFromLength(len);
|
|
diff.normalizeFromLength(len);
|
|
@@ -19557,6 +19562,7 @@ var BABYLON;
|
|
}
|
|
}
|
|
return true;
|
|
return true;
|
|
};
|
|
};
|
|
|
|
+ BoundingBox.TmpVector3 = BABYLON.Tools.BuildArray(3, BABYLON.Vector3.Zero);
|
|
return BoundingBox;
|
|
return BoundingBox;
|
|
}());
|
|
}());
|
|
BABYLON.BoundingBox = BoundingBox;
|
|
BABYLON.BoundingBox = BoundingBox;
|
|
@@ -19866,6 +19872,8 @@ var BABYLON;
|
|
_this._pivotMatrix = BABYLON.Matrix.Identity();
|
|
_this._pivotMatrix = BABYLON.Matrix.Identity();
|
|
_this._postMultiplyPivotMatrix = false;
|
|
_this._postMultiplyPivotMatrix = false;
|
|
_this._isWorldMatrixFrozen = false;
|
|
_this._isWorldMatrixFrozen = false;
|
|
|
|
+ /** @hidden */
|
|
|
|
+ _this._indexInSceneTransformNodesArray = -1;
|
|
/**
|
|
/**
|
|
* An event triggered after the world matrix is updated
|
|
* An event triggered after the world matrix is updated
|
|
*/
|
|
*/
|
|
@@ -19937,8 +19945,8 @@ var BABYLON;
|
|
set: function (quaternion) {
|
|
set: function (quaternion) {
|
|
this._rotationQuaternion = quaternion;
|
|
this._rotationQuaternion = quaternion;
|
|
//reset the rotation vector.
|
|
//reset the rotation vector.
|
|
- if (quaternion && this.rotation.length()) {
|
|
|
|
- this.rotation.copyFromFloats(0.0, 0.0, 0.0);
|
|
|
|
|
|
+ if (quaternion) {
|
|
|
|
+ this.rotation.setAll(0.0);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
enumerable: true,
|
|
enumerable: true,
|
|
@@ -20070,7 +20078,7 @@ var BABYLON;
|
|
*/
|
|
*/
|
|
TransformNode.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
|
|
TransformNode.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
|
|
if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = true; }
|
|
if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = true; }
|
|
- this._pivotMatrix = matrix.clone();
|
|
|
|
|
|
+ this._pivotMatrix.copyFrom(matrix);
|
|
this._cache.pivotMatrixUpdated = true;
|
|
this._cache.pivotMatrixUpdated = true;
|
|
this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
|
|
this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
|
|
if (this._postMultiplyPivotMatrix) {
|
|
if (this._postMultiplyPivotMatrix) {
|
|
@@ -20154,10 +20162,9 @@ var BABYLON;
|
|
absolutePositionZ = absolutePosition.z;
|
|
absolutePositionZ = absolutePosition.z;
|
|
}
|
|
}
|
|
if (this.parent) {
|
|
if (this.parent) {
|
|
- var invertParentWorldMatrix = this.parent.getWorldMatrix().clone();
|
|
|
|
- invertParentWorldMatrix.invert();
|
|
|
|
- var worldPosition = new BABYLON.Vector3(absolutePositionX, absolutePositionY, absolutePositionZ);
|
|
|
|
- this.position = BABYLON.Vector3.TransformCoordinates(worldPosition, invertParentWorldMatrix);
|
|
|
|
|
|
+ var invertParentWorldMatrix = BABYLON.Tmp.Matrix[0];
|
|
|
|
+ this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
|
|
|
|
+ BABYLON.Vector3.TransformCoordinatesFromFloatsToRef(absolutePositionX, absolutePositionY, absolutePositionZ, invertParentWorldMatrix, this.position);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
this.position.x = absolutePositionX;
|
|
this.position.x = absolutePositionX;
|
|
@@ -20182,8 +20189,8 @@ var BABYLON;
|
|
*/
|
|
*/
|
|
TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
|
|
TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
|
|
this.computeWorldMatrix();
|
|
this.computeWorldMatrix();
|
|
- var invLocalWorldMatrix = this._localWorld.clone();
|
|
|
|
- invLocalWorldMatrix.invert();
|
|
|
|
|
|
+ var invLocalWorldMatrix = BABYLON.Tmp.Matrix[0];
|
|
|
|
+ this._localWorld.invertToRef(invLocalWorldMatrix);
|
|
return BABYLON.Vector3.TransformNormal(this.position, invLocalWorldMatrix);
|
|
return BABYLON.Vector3.TransformNormal(this.position, invLocalWorldMatrix);
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
@@ -20320,52 +20327,33 @@ var BABYLON;
|
|
if (!node && !this.parent) {
|
|
if (!node && !this.parent) {
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
+ var quatRotation = BABYLON.Tmp.Quaternion[0];
|
|
|
|
+ var position = BABYLON.Tmp.Vector3[0];
|
|
|
|
+ var scale = BABYLON.Tmp.Vector3[1];
|
|
if (!node) {
|
|
if (!node) {
|
|
- var rotation = BABYLON.Tmp.Quaternion[0];
|
|
|
|
- var position = BABYLON.Tmp.Vector3[0];
|
|
|
|
- var scale = BABYLON.Tmp.Vector3[1];
|
|
|
|
if (this.parent && this.parent.computeWorldMatrix) {
|
|
if (this.parent && this.parent.computeWorldMatrix) {
|
|
this.parent.computeWorldMatrix(true);
|
|
this.parent.computeWorldMatrix(true);
|
|
}
|
|
}
|
|
this.computeWorldMatrix(true);
|
|
this.computeWorldMatrix(true);
|
|
- this.getWorldMatrix().decompose(scale, rotation, position);
|
|
|
|
- if (this.rotationQuaternion) {
|
|
|
|
- this.rotationQuaternion.copyFrom(rotation);
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- rotation.toEulerAnglesToRef(this.rotation);
|
|
|
|
- }
|
|
|
|
- this.scaling.x = scale.x;
|
|
|
|
- this.scaling.y = scale.y;
|
|
|
|
- this.scaling.z = scale.z;
|
|
|
|
- this.position.x = position.x;
|
|
|
|
- this.position.y = position.y;
|
|
|
|
- this.position.z = position.z;
|
|
|
|
|
|
+ this.getWorldMatrix().decompose(scale, quatRotation, position);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- var rotation = BABYLON.Tmp.Quaternion[0];
|
|
|
|
- var position = BABYLON.Tmp.Vector3[0];
|
|
|
|
- var scale = BABYLON.Tmp.Vector3[1];
|
|
|
|
var diffMatrix = BABYLON.Tmp.Matrix[0];
|
|
var diffMatrix = BABYLON.Tmp.Matrix[0];
|
|
var invParentMatrix = BABYLON.Tmp.Matrix[1];
|
|
var invParentMatrix = BABYLON.Tmp.Matrix[1];
|
|
this.computeWorldMatrix(true);
|
|
this.computeWorldMatrix(true);
|
|
node.computeWorldMatrix(true);
|
|
node.computeWorldMatrix(true);
|
|
node.getWorldMatrix().invertToRef(invParentMatrix);
|
|
node.getWorldMatrix().invertToRef(invParentMatrix);
|
|
this.getWorldMatrix().multiplyToRef(invParentMatrix, diffMatrix);
|
|
this.getWorldMatrix().multiplyToRef(invParentMatrix, diffMatrix);
|
|
- diffMatrix.decompose(scale, rotation, position);
|
|
|
|
- if (this.rotationQuaternion) {
|
|
|
|
- this.rotationQuaternion.copyFrom(rotation);
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- rotation.toEulerAnglesToRef(this.rotation);
|
|
|
|
- }
|
|
|
|
- this.position.x = position.x;
|
|
|
|
- this.position.y = position.y;
|
|
|
|
- this.position.z = position.z;
|
|
|
|
- this.scaling.x = scale.x;
|
|
|
|
- this.scaling.y = scale.y;
|
|
|
|
- this.scaling.z = scale.z;
|
|
|
|
|
|
+ diffMatrix.decompose(scale, quatRotation, position);
|
|
}
|
|
}
|
|
|
|
+ if (this.rotationQuaternion) {
|
|
|
|
+ this.rotationQuaternion.copyFrom(quatRotation);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ quatRotation.toEulerAnglesToRef(this.rotation);
|
|
|
|
+ }
|
|
|
|
+ this.scaling.copyFrom(scale);
|
|
|
|
+ this.position.copyFrom(position);
|
|
this.parent = node;
|
|
this.parent = node;
|
|
return this;
|
|
return this;
|
|
};
|
|
};
|
|
@@ -20429,8 +20417,8 @@ var BABYLON;
|
|
TransformNode.prototype.rotate = function (axis, amount, space) {
|
|
TransformNode.prototype.rotate = function (axis, amount, space) {
|
|
axis.normalize();
|
|
axis.normalize();
|
|
if (!this.rotationQuaternion) {
|
|
if (!this.rotationQuaternion) {
|
|
- this.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
|
|
|
|
- this.rotation = BABYLON.Vector3.Zero();
|
|
|
|
|
|
+ this.rotationQuaternion = this.rotation.toQuaternion();
|
|
|
|
+ this.rotation.setAll(0);
|
|
}
|
|
}
|
|
var rotationQuaternion;
|
|
var rotationQuaternion;
|
|
if (!space || space === BABYLON.Space.LOCAL) {
|
|
if (!space || space === BABYLON.Space.LOCAL) {
|
|
@@ -20439,8 +20427,8 @@ var BABYLON;
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
if (this.parent) {
|
|
if (this.parent) {
|
|
- var invertParentWorldMatrix = this.parent.getWorldMatrix().clone();
|
|
|
|
- invertParentWorldMatrix.invert();
|
|
|
|
|
|
+ var invertParentWorldMatrix = BABYLON.Tmp.Matrix[0];
|
|
|
|
+ this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
|
|
axis = BABYLON.Vector3.TransformNormal(axis, invertParentWorldMatrix);
|
|
axis = BABYLON.Vector3.TransformNormal(axis, invertParentWorldMatrix);
|
|
}
|
|
}
|
|
rotationQuaternion = BABYLON.Quaternion.RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
|
|
rotationQuaternion = BABYLON.Quaternion.RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
|
|
@@ -20462,17 +20450,25 @@ var BABYLON;
|
|
axis.normalize();
|
|
axis.normalize();
|
|
if (!this.rotationQuaternion) {
|
|
if (!this.rotationQuaternion) {
|
|
this.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
|
|
this.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
|
|
- this.rotation.copyFromFloats(0, 0, 0);
|
|
|
|
- }
|
|
|
|
- point.subtractToRef(this.position, BABYLON.Tmp.Vector3[0]);
|
|
|
|
- BABYLON.Matrix.TranslationToRef(BABYLON.Tmp.Vector3[0].x, BABYLON.Tmp.Vector3[0].y, BABYLON.Tmp.Vector3[0].z, BABYLON.Tmp.Matrix[0]);
|
|
|
|
- BABYLON.Tmp.Matrix[0].invertToRef(BABYLON.Tmp.Matrix[2]);
|
|
|
|
- BABYLON.Matrix.RotationAxisToRef(axis, amount, BABYLON.Tmp.Matrix[1]);
|
|
|
|
- BABYLON.Tmp.Matrix[2].multiplyToRef(BABYLON.Tmp.Matrix[1], BABYLON.Tmp.Matrix[2]);
|
|
|
|
- BABYLON.Tmp.Matrix[2].multiplyToRef(BABYLON.Tmp.Matrix[0], BABYLON.Tmp.Matrix[2]);
|
|
|
|
- BABYLON.Tmp.Matrix[2].decompose(BABYLON.Tmp.Vector3[0], BABYLON.Tmp.Quaternion[0], BABYLON.Tmp.Vector3[1]);
|
|
|
|
- this.position.addInPlace(BABYLON.Tmp.Vector3[1]);
|
|
|
|
- BABYLON.Tmp.Quaternion[0].multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
|
|
|
|
|
|
+ this.rotation.setAll(0);
|
|
|
|
+ }
|
|
|
|
+ var tmpVector = BABYLON.Tmp.Vector3[0];
|
|
|
|
+ var finalScale = BABYLON.Tmp.Vector3[1];
|
|
|
|
+ var finalTranslation = BABYLON.Tmp.Vector3[2];
|
|
|
|
+ var finalRotation = BABYLON.Tmp.Quaternion[0];
|
|
|
|
+ var translationMatrix = BABYLON.Tmp.Matrix[0]; // T
|
|
|
|
+ var translationMatrixInv = BABYLON.Tmp.Matrix[1]; // T'
|
|
|
|
+ var rotationMatrix = BABYLON.Tmp.Matrix[2]; // R
|
|
|
|
+ var finalMatrix = BABYLON.Tmp.Matrix[3]; // T' x R x T
|
|
|
|
+ point.subtractToRef(this.position, tmpVector);
|
|
|
|
+ BABYLON.Matrix.TranslationToRef(tmpVector.x, tmpVector.y, tmpVector.z, translationMatrix); // T
|
|
|
|
+ BABYLON.Matrix.TranslationToRef(-tmpVector.x, -tmpVector.y, -tmpVector.z, translationMatrixInv); // T'
|
|
|
|
+ BABYLON.Matrix.RotationAxisToRef(axis, amount, rotationMatrix); // R
|
|
|
|
+ translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R
|
|
|
|
+ finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x T
|
|
|
|
+ finalMatrix.decompose(finalScale, finalRotation, finalTranslation);
|
|
|
|
+ this.position.addInPlace(finalTranslation);
|
|
|
|
+ finalRotation.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
|
|
return this;
|
|
return this;
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
@@ -25204,6 +25200,9 @@ var BABYLON;
|
|
this.geometries = new Array();
|
|
this.geometries = new Array();
|
|
/**
|
|
/**
|
|
* All of the tranform nodes added to this scene
|
|
* All of the tranform nodes added to this scene
|
|
|
|
+ * In the context a the Scene, it is not supposed to be modified manually.
|
|
|
|
+ * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
|
|
|
|
+ * Note also that the order of the TransformNode wihin the array is not significant and might change.
|
|
* @see http://doc.babylonjs.com/how_to/transformnode
|
|
* @see http://doc.babylonjs.com/how_to/transformnode
|
|
*/
|
|
*/
|
|
this.transformNodes = new Array();
|
|
this.transformNodes = new Array();
|
|
@@ -27908,6 +27907,7 @@ var BABYLON;
|
|
* @param newTransformNode defines the transform node to add
|
|
* @param newTransformNode defines the transform node to add
|
|
*/
|
|
*/
|
|
Scene.prototype.addTransformNode = function (newTransformNode) {
|
|
Scene.prototype.addTransformNode = function (newTransformNode) {
|
|
|
|
+ newTransformNode._indexInSceneTransformNodesArray = this.transformNodes.length;
|
|
this.transformNodes.push(newTransformNode);
|
|
this.transformNodes.push(newTransformNode);
|
|
this.onNewTransformNodeAddedObservable.notifyObservers(newTransformNode);
|
|
this.onNewTransformNodeAddedObservable.notifyObservers(newTransformNode);
|
|
};
|
|
};
|
|
@@ -27917,10 +27917,15 @@ var BABYLON;
|
|
* @returns the index where the transform node was in the transform node list
|
|
* @returns the index where the transform node was in the transform node list
|
|
*/
|
|
*/
|
|
Scene.prototype.removeTransformNode = function (toRemove) {
|
|
Scene.prototype.removeTransformNode = function (toRemove) {
|
|
- var index = this.transformNodes.indexOf(toRemove);
|
|
|
|
|
|
+ var index = toRemove._indexInSceneTransformNodesArray;
|
|
if (index !== -1) {
|
|
if (index !== -1) {
|
|
- // Remove from the scene if found
|
|
|
|
- this.transformNodes.splice(index, 1);
|
|
|
|
|
|
+ if (index !== this.transformNodes.length - 1) {
|
|
|
|
+ var lastNode = this.transformNodes[this.transformNodes.length - 1];
|
|
|
|
+ this.transformNodes[index] = lastNode;
|
|
|
|
+ lastNode._indexInSceneTransformNodesArray = index;
|
|
|
|
+ }
|
|
|
|
+ toRemove._indexInSceneTransformNodesArray = -1;
|
|
|
|
+ this.transformNodes.pop();
|
|
}
|
|
}
|
|
this.onTransformNodeRemovedObservable.notifyObservers(toRemove);
|
|
this.onTransformNodeRemovedObservable.notifyObservers(toRemove);
|
|
return index;
|
|
return index;
|
|
@@ -33011,12 +33016,12 @@ var BABYLON;
|
|
this.computeWorldMatrix();
|
|
this.computeWorldMatrix();
|
|
var mat = this.material || scene.defaultMaterial;
|
|
var mat = this.material || scene.defaultMaterial;
|
|
if (mat) {
|
|
if (mat) {
|
|
- if (mat.storeEffectOnSubMeshes) {
|
|
|
|
|
|
+ if (mat._storeEffectOnSubMeshes) {
|
|
for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
|
|
for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
|
|
var subMesh = _a[_i];
|
|
var subMesh = _a[_i];
|
|
var effectiveMaterial = subMesh.getMaterial();
|
|
var effectiveMaterial = subMesh.getMaterial();
|
|
if (effectiveMaterial) {
|
|
if (effectiveMaterial) {
|
|
- if (effectiveMaterial.storeEffectOnSubMeshes) {
|
|
|
|
|
|
+ if (effectiveMaterial._storeEffectOnSubMeshes) {
|
|
if (!effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
|
|
if (!effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -33693,7 +33698,7 @@ var BABYLON;
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
this._effectiveMaterial = material;
|
|
this._effectiveMaterial = material;
|
|
- if (this._effectiveMaterial.storeEffectOnSubMeshes) {
|
|
|
|
|
|
+ if (this._effectiveMaterial._storeEffectOnSubMeshes) {
|
|
if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
|
|
if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
@@ -33710,7 +33715,7 @@ var BABYLON;
|
|
step.action(this, subMesh, batch);
|
|
step.action(this, subMesh, batch);
|
|
}
|
|
}
|
|
var effect;
|
|
var effect;
|
|
- if (this._effectiveMaterial.storeEffectOnSubMeshes) {
|
|
|
|
|
|
+ if (this._effectiveMaterial._storeEffectOnSubMeshes) {
|
|
effect = subMesh.effect;
|
|
effect = subMesh.effect;
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
@@ -33736,7 +33741,7 @@ var BABYLON;
|
|
this._bind(subMesh, effect, fillMode);
|
|
this._bind(subMesh, effect, fillMode);
|
|
}
|
|
}
|
|
var world = this.getWorldMatrix();
|
|
var world = this.getWorldMatrix();
|
|
- if (this._effectiveMaterial.storeEffectOnSubMeshes) {
|
|
|
|
|
|
+ if (this._effectiveMaterial._storeEffectOnSubMeshes) {
|
|
this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
|
|
this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
@@ -36378,9 +36383,9 @@ var BABYLON;
|
|
*/
|
|
*/
|
|
this.doNotSerialize = false;
|
|
this.doNotSerialize = false;
|
|
/**
|
|
/**
|
|
- * Specifies if the effect should be stored on sub meshes
|
|
|
|
|
|
+ * @hidden
|
|
*/
|
|
*/
|
|
- this.storeEffectOnSubMeshes = false;
|
|
|
|
|
|
+ this._storeEffectOnSubMeshes = false;
|
|
/**
|
|
/**
|
|
* An event triggered when the material is disposed
|
|
* An event triggered when the material is disposed
|
|
*/
|
|
*/
|
|
@@ -37066,7 +37071,7 @@ var BABYLON;
|
|
if (localOptions.clipPlane) {
|
|
if (localOptions.clipPlane) {
|
|
scene.clipPlane = new BABYLON.Plane(0, 0, 0, 1);
|
|
scene.clipPlane = new BABYLON.Plane(0, 0, 0, 1);
|
|
}
|
|
}
|
|
- if (_this.storeEffectOnSubMeshes) {
|
|
|
|
|
|
+ if (_this._storeEffectOnSubMeshes) {
|
|
if (_this.isReadyForSubMesh(mesh, subMesh)) {
|
|
if (_this.isReadyForSubMesh(mesh, subMesh)) {
|
|
if (onCompiled) {
|
|
if (onCompiled) {
|
|
onCompiled(_this);
|
|
onCompiled(_this);
|
|
@@ -37226,7 +37231,7 @@ var BABYLON;
|
|
mesh.material = null;
|
|
mesh.material = null;
|
|
if (mesh.geometry) {
|
|
if (mesh.geometry) {
|
|
var geometry = (mesh.geometry);
|
|
var geometry = (mesh.geometry);
|
|
- if (this.storeEffectOnSubMeshes) {
|
|
|
|
|
|
+ if (this._storeEffectOnSubMeshes) {
|
|
for (var _i = 0, _a = mesh.subMeshes; _i < _a.length; _i++) {
|
|
for (var _i = 0, _a = mesh.subMeshes; _i < _a.length; _i++) {
|
|
var subMesh = _a[_i];
|
|
var subMesh = _a[_i];
|
|
geometry._releaseVertexArrayObject(subMesh._materialEffect);
|
|
geometry._releaseVertexArrayObject(subMesh._materialEffect);
|
|
@@ -37244,7 +37249,7 @@ var BABYLON;
|
|
this._uniformBuffer.dispose();
|
|
this._uniformBuffer.dispose();
|
|
// Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
|
|
// Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
|
|
if (forceDisposeEffect && this._effect) {
|
|
if (forceDisposeEffect && this._effect) {
|
|
- if (!this.storeEffectOnSubMeshes) {
|
|
|
|
|
|
+ if (!this._storeEffectOnSubMeshes) {
|
|
this._scene.getEngine()._releaseEffect(this._effect);
|
|
this._scene.getEngine()._releaseEffect(this._effect);
|
|
}
|
|
}
|
|
this._effect = null;
|
|
this._effect = null;
|
|
@@ -43224,7 +43229,7 @@ var BABYLON;
|
|
* This is mostly used when shader parallel compilation is supported (true by default)
|
|
* This is mostly used when shader parallel compilation is supported (true by default)
|
|
*/
|
|
*/
|
|
_this.allowShaderHotSwapping = true;
|
|
_this.allowShaderHotSwapping = true;
|
|
- _this.storeEffectOnSubMeshes = true;
|
|
|
|
|
|
+ _this._storeEffectOnSubMeshes = true;
|
|
return _this;
|
|
return _this;
|
|
}
|
|
}
|
|
PushMaterial.prototype.getEffect = function () {
|
|
PushMaterial.prototype.getEffect = function () {
|
|
@@ -68345,13 +68350,22 @@ var BABYLON;
|
|
var index = 0;
|
|
var index = 0;
|
|
var idx = 0;
|
|
var idx = 0;
|
|
var tmpNormal = BABYLON.Tmp.Vector3[0];
|
|
var tmpNormal = BABYLON.Tmp.Vector3[0];
|
|
- var rotMatrix = BABYLON.Tmp.Matrix[0];
|
|
|
|
- var invertedRotMatrix = BABYLON.Tmp.Matrix[1];
|
|
|
|
|
|
+ var quaternion = BABYLON.Tmp.Quaternion[0];
|
|
|
|
+ var invertedRotMatrix = BABYLON.Tmp.Matrix[0];
|
|
for (var p = 0; p < this.particles.length; p++) {
|
|
for (var p = 0; p < this.particles.length; p++) {
|
|
var particle = this.particles[p];
|
|
var particle = this.particles[p];
|
|
var shape = particle._model._shape;
|
|
var shape = particle._model._shape;
|
|
- particle.getRotationMatrix(rotMatrix);
|
|
|
|
- rotMatrix.invertToRef(invertedRotMatrix);
|
|
|
|
|
|
+ // computing the inverse of the rotation matrix from the quaternion
|
|
|
|
+ // is equivalent to computing the matrix of the inverse quaternion, i.e of the conjugate quaternion
|
|
|
|
+ if (particle.rotationQuaternion) {
|
|
|
|
+ particle.rotationQuaternion.conjugateToRef(quaternion);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ var rotation = particle.rotation;
|
|
|
|
+ BABYLON.Quaternion.RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
|
|
|
|
+ quaternion.conjugateInPlace();
|
|
|
|
+ }
|
|
|
|
+ quaternion.toRotationMatrix(invertedRotMatrix);
|
|
for (var pt = 0; pt < shape.length; pt++) {
|
|
for (var pt = 0; pt < shape.length; pt++) {
|
|
idx = index + pt * 3;
|
|
idx = index + pt * 3;
|
|
BABYLON.Vector3.TransformNormalFromFloatsToRef(this._normals32[idx], this._normals32[idx + 1], this._normals32[idx + 2], invertedRotMatrix, tmpNormal);
|
|
BABYLON.Vector3.TransformNormalFromFloatsToRef(this._normals32[idx], this._normals32[idx + 1], this._normals32[idx + 2], invertedRotMatrix, tmpNormal);
|
|
@@ -80200,7 +80214,7 @@ var BABYLON;
|
|
var _this = _super.call(this, name, scene, true) || this;
|
|
var _this = _super.call(this, name, scene, true) || this;
|
|
scene.multiMaterials.push(_this);
|
|
scene.multiMaterials.push(_this);
|
|
_this.subMaterials = new Array();
|
|
_this.subMaterials = new Array();
|
|
- _this.storeEffectOnSubMeshes = true; // multimaterial is considered like a push material
|
|
|
|
|
|
+ _this._storeEffectOnSubMeshes = true; // multimaterial is considered like a push material
|
|
return _this;
|
|
return _this;
|
|
}
|
|
}
|
|
Object.defineProperty(MultiMaterial.prototype, "subMaterials", {
|
|
Object.defineProperty(MultiMaterial.prototype, "subMaterials", {
|
|
@@ -80282,7 +80296,7 @@ var BABYLON;
|
|
for (var index = 0; index < this.subMaterials.length; index++) {
|
|
for (var index = 0; index < this.subMaterials.length; index++) {
|
|
var subMaterial = this.subMaterials[index];
|
|
var subMaterial = this.subMaterials[index];
|
|
if (subMaterial) {
|
|
if (subMaterial) {
|
|
- if (subMaterial.storeEffectOnSubMeshes) {
|
|
|
|
|
|
+ if (subMaterial._storeEffectOnSubMeshes) {
|
|
if (!subMaterial.isReadyForSubMesh(mesh, subMesh, useInstances)) {
|
|
if (!subMaterial.isReadyForSubMesh(mesh, subMesh, useInstances)) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|