|
@@ -12272,6 +12272,10 @@ var BABYLON;
|
|
|
*/
|
|
|
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
|
|
|
*/
|
|
|
this.onEndFrameObservable = new BABYLON.Observable();
|
|
@@ -13434,11 +13438,16 @@ var BABYLON;
|
|
|
}
|
|
|
if (this._activeRenderLoops.length > 0) {
|
|
|
// 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 {
|
|
|
this._renderingQueueLaunched = false;
|
|
@@ -19208,7 +19217,7 @@ var BABYLON;
|
|
|
this.minimum.copyFrom(min);
|
|
|
this.maximum.copyFrom(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._update(worldMatrix || _identityMatrix);
|
|
|
};
|
|
@@ -19219,8 +19228,8 @@ var BABYLON;
|
|
|
*/
|
|
|
BoundingSphere.prototype.scale = function (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 max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);
|
|
|
this.reConstruct(min, max);
|
|
@@ -19230,7 +19239,7 @@ var BABYLON;
|
|
|
/** @hidden */
|
|
|
BoundingSphere.prototype._update = function (world) {
|
|
|
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);
|
|
|
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
|
|
|
*/
|
|
|
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 true;
|
|
@@ -19270,15 +19276,14 @@ var BABYLON;
|
|
|
* @returns true if the speres intersect
|
|
|
*/
|
|
|
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 true;
|
|
|
};
|
|
|
+ BoundingSphere.TmpVector3 = BABYLON.Tools.BuildArray(3, BABYLON.Vector3.Zero);
|
|
|
return BoundingSphere;
|
|
|
}());
|
|
|
BABYLON.BoundingSphere = BoundingSphere;
|
|
@@ -19366,8 +19371,8 @@ var BABYLON;
|
|
|
vectors[6].copyFromFloats(minX, maxY, maxZ);
|
|
|
vectors[7].copyFromFloats(maxX, minY, maxZ);
|
|
|
// 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(min, this.extendSize).scaleInPlace(0.5);
|
|
|
this._update(worldMatrix || this._worldMatrix || BABYLON.Matrix.Identity());
|
|
|
};
|
|
|
/**
|
|
@@ -19376,7 +19381,7 @@ var BABYLON;
|
|
|
* @returns the current bounding box
|
|
|
*/
|
|
|
BoundingBox.prototype.scale = function (factor) {
|
|
|
- var tmpVectors = BABYLON.Tmp.Vector3;
|
|
|
+ var tmpVectors = BoundingBox.TmpVector3;
|
|
|
var diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);
|
|
|
var len = diff.length();
|
|
|
diff.normalizeFromLength(len);
|
|
@@ -19557,6 +19562,7 @@ var BABYLON;
|
|
|
}
|
|
|
return true;
|
|
|
};
|
|
|
+ BoundingBox.TmpVector3 = BABYLON.Tools.BuildArray(3, BABYLON.Vector3.Zero);
|
|
|
return BoundingBox;
|
|
|
}());
|
|
|
BABYLON.BoundingBox = BoundingBox;
|
|
@@ -19866,6 +19872,8 @@ var BABYLON;
|
|
|
_this._pivotMatrix = BABYLON.Matrix.Identity();
|
|
|
_this._postMultiplyPivotMatrix = false;
|
|
|
_this._isWorldMatrixFrozen = false;
|
|
|
+ /** @hidden */
|
|
|
+ _this._indexInSceneTransformNodesArray = -1;
|
|
|
/**
|
|
|
* An event triggered after the world matrix is updated
|
|
|
*/
|
|
@@ -19937,8 +19945,8 @@ var BABYLON;
|
|
|
set: function (quaternion) {
|
|
|
this._rotationQuaternion = quaternion;
|
|
|
//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,
|
|
@@ -20070,7 +20078,7 @@ var BABYLON;
|
|
|
*/
|
|
|
TransformNode.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
|
|
|
if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = true; }
|
|
|
- this._pivotMatrix = matrix.clone();
|
|
|
+ this._pivotMatrix.copyFrom(matrix);
|
|
|
this._cache.pivotMatrixUpdated = true;
|
|
|
this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
|
|
|
if (this._postMultiplyPivotMatrix) {
|
|
@@ -20154,10 +20162,9 @@ var BABYLON;
|
|
|
absolutePositionZ = absolutePosition.z;
|
|
|
}
|
|
|
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 {
|
|
|
this.position.x = absolutePositionX;
|
|
@@ -20182,8 +20189,8 @@ var BABYLON;
|
|
|
*/
|
|
|
TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
|
|
|
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);
|
|
|
};
|
|
|
/**
|
|
@@ -20320,52 +20327,33 @@ var BABYLON;
|
|
|
if (!node && !this.parent) {
|
|
|
return this;
|
|
|
}
|
|
|
+ var quatRotation = BABYLON.Tmp.Quaternion[0];
|
|
|
+ var position = BABYLON.Tmp.Vector3[0];
|
|
|
+ var scale = BABYLON.Tmp.Vector3[1];
|
|
|
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) {
|
|
|
this.parent.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 {
|
|
|
- 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 invParentMatrix = BABYLON.Tmp.Matrix[1];
|
|
|
this.computeWorldMatrix(true);
|
|
|
node.computeWorldMatrix(true);
|
|
|
node.getWorldMatrix().invertToRef(invParentMatrix);
|
|
|
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;
|
|
|
return this;
|
|
|
};
|
|
@@ -20429,8 +20417,8 @@ var BABYLON;
|
|
|
TransformNode.prototype.rotate = function (axis, amount, space) {
|
|
|
axis.normalize();
|
|
|
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;
|
|
|
if (!space || space === BABYLON.Space.LOCAL) {
|
|
@@ -20439,8 +20427,8 @@ var BABYLON;
|
|
|
}
|
|
|
else {
|
|
|
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);
|
|
|
}
|
|
|
rotationQuaternion = BABYLON.Quaternion.RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
|
|
@@ -20462,17 +20450,25 @@ var BABYLON;
|
|
|
axis.normalize();
|
|
|
if (!this.rotationQuaternion) {
|
|
|
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;
|
|
|
};
|
|
|
/**
|
|
@@ -23469,6 +23465,10 @@ var BABYLON;
|
|
|
*/
|
|
|
_this.customRenderTargets = new Array();
|
|
|
/**
|
|
|
+ * When set, the camera will render to this render target instead of the default canvas
|
|
|
+ */
|
|
|
+ _this.customDefaultRenderTarget = null;
|
|
|
+ /**
|
|
|
* Observable triggered when the camera view matrix has changed.
|
|
|
*/
|
|
|
_this.onViewMatrixChangedObservable = new BABYLON.Observable();
|
|
@@ -24379,6 +24379,10 @@ var BABYLON;
|
|
|
*/
|
|
|
Camera.RIG_MODE_WEBVR = 21;
|
|
|
/**
|
|
|
+ * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
|
|
|
+ */
|
|
|
+ Camera.RIG_MODE_CUSTOM = 22;
|
|
|
+ /**
|
|
|
* Defines if by default attaching controls should prevent the default javascript event to continue.
|
|
|
*/
|
|
|
Camera.ForceAttachControlToAlwaysPreventDefault = false;
|
|
@@ -25204,6 +25208,9 @@ var BABYLON;
|
|
|
this.geometries = new Array();
|
|
|
/**
|
|
|
* 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
|
|
|
*/
|
|
|
this.transformNodes = new Array();
|
|
@@ -25404,6 +25411,11 @@ var BABYLON;
|
|
|
* in order to block unwanted artifacts like system double clicks
|
|
|
*/
|
|
|
_this.preventDefaultOnPointerDown = true;
|
|
|
+ /**
|
|
|
+ * This is used to call preventDefault() on pointer up
|
|
|
+ * in order to block unwanted artifacts like system double clicks
|
|
|
+ */
|
|
|
+ _this.preventDefaultOnPointerUp = true;
|
|
|
// Metadata
|
|
|
/**
|
|
|
* Gets or sets user defined metadata
|
|
@@ -26918,6 +26930,7 @@ var BABYLON;
|
|
|
checkPicking = act.hasPickTriggers;
|
|
|
}
|
|
|
}
|
|
|
+ var eventRaised = false;
|
|
|
if (checkPicking) {
|
|
|
var btn = evt.button;
|
|
|
clickInfo.hasSwiped = _this._isPointerSwiping();
|
|
@@ -26938,6 +26951,7 @@ var BABYLON;
|
|
|
if (Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay ||
|
|
|
btn !== _this._previousButtonPressed) {
|
|
|
clickInfo.singleClick = true;
|
|
|
+ eventRaised = true;
|
|
|
cb(clickInfo, _this._currentPickResult);
|
|
|
}
|
|
|
}
|
|
@@ -27003,8 +27017,10 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- clickInfo.ignore = true;
|
|
|
- cb(clickInfo, _this._currentPickResult);
|
|
|
+ if (!eventRaised) {
|
|
|
+ clickInfo.ignore = true;
|
|
|
+ cb(clickInfo, _this._currentPickResult);
|
|
|
+ }
|
|
|
};
|
|
|
this._onPointerMove = function (evt) {
|
|
|
_this._updatePointerPosition(evt);
|
|
@@ -27060,6 +27076,10 @@ var BABYLON;
|
|
|
_this._pickedUpMesh = null;
|
|
|
_this._meshPickProceed = false;
|
|
|
_this._updatePointerPosition(evt);
|
|
|
+ if (_this.preventDefaultOnPointerUp && canvas) {
|
|
|
+ evt.preventDefault();
|
|
|
+ canvas.focus();
|
|
|
+ }
|
|
|
_this._initClickEvent(_this.onPrePointerObservable, _this.onPointerObservable, evt, function (clickInfo, pickResult) {
|
|
|
// PreObservable support
|
|
|
if (_this.onPrePointerObservable.hasObservers()) {
|
|
@@ -27908,6 +27928,7 @@ var BABYLON;
|
|
|
* @param newTransformNode defines the transform node to add
|
|
|
*/
|
|
|
Scene.prototype.addTransformNode = function (newTransformNode) {
|
|
|
+ newTransformNode._indexInSceneTransformNodesArray = this.transformNodes.length;
|
|
|
this.transformNodes.push(newTransformNode);
|
|
|
this.onNewTransformNodeAddedObservable.notifyObservers(newTransformNode);
|
|
|
};
|
|
@@ -27917,10 +27938,15 @@ var BABYLON;
|
|
|
* @returns the index where the transform node was in the transform node list
|
|
|
*/
|
|
|
Scene.prototype.removeTransformNode = function (toRemove) {
|
|
|
- var index = this.transformNodes.indexOf(toRemove);
|
|
|
+ var index = toRemove._indexInSceneTransformNodesArray;
|
|
|
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);
|
|
|
return index;
|
|
@@ -28899,7 +28925,7 @@ var BABYLON;
|
|
|
continue;
|
|
|
}
|
|
|
mesh._preActivate();
|
|
|
- if (mesh.isVisible && mesh.visibility > 0 && (mesh.alwaysSelectAsActiveMesh || ((mesh.layerMask & this.activeCamera.layerMask) !== 0 && mesh.isInFrustum(this._frustumPlanes)))) {
|
|
|
+ if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
|
|
|
this._activeMeshes.push(mesh);
|
|
|
this.activeCamera._activeMeshes.push(mesh);
|
|
|
mesh._activate(this._renderId);
|
|
@@ -29028,7 +29054,18 @@ var BABYLON;
|
|
|
step.action(this.activeCamera);
|
|
|
}
|
|
|
this._intermediateRendering = false;
|
|
|
- engine.restoreDefaultFramebuffer(); // Restore back buffer if needed
|
|
|
+ if (this.activeCamera.customDefaultRenderTarget) {
|
|
|
+ var internalTexture = this.activeCamera.customDefaultRenderTarget.getInternalTexture();
|
|
|
+ if (internalTexture) {
|
|
|
+ engine.bindFramebuffer(internalTexture);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ BABYLON.Tools.Error("Camera contains invalid customDefaultRenderTarget");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ engine.restoreDefaultFramebuffer(); // Restore back buffer if needed
|
|
|
+ }
|
|
|
}
|
|
|
this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
|
|
|
// Prepare Frame
|
|
@@ -33011,12 +33048,12 @@ var BABYLON;
|
|
|
this.computeWorldMatrix();
|
|
|
var mat = this.material || scene.defaultMaterial;
|
|
|
if (mat) {
|
|
|
- if (mat.storeEffectOnSubMeshes) {
|
|
|
+ if (mat._storeEffectOnSubMeshes) {
|
|
|
for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
|
|
|
var subMesh = _a[_i];
|
|
|
var effectiveMaterial = subMesh.getMaterial();
|
|
|
if (effectiveMaterial) {
|
|
|
- if (effectiveMaterial.storeEffectOnSubMeshes) {
|
|
|
+ if (effectiveMaterial._storeEffectOnSubMeshes) {
|
|
|
if (!effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
|
|
|
return false;
|
|
|
}
|
|
@@ -33693,7 +33730,7 @@ var BABYLON;
|
|
|
return this;
|
|
|
}
|
|
|
this._effectiveMaterial = material;
|
|
|
- if (this._effectiveMaterial.storeEffectOnSubMeshes) {
|
|
|
+ if (this._effectiveMaterial._storeEffectOnSubMeshes) {
|
|
|
if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
|
|
|
return this;
|
|
|
}
|
|
@@ -33710,7 +33747,7 @@ var BABYLON;
|
|
|
step.action(this, subMesh, batch);
|
|
|
}
|
|
|
var effect;
|
|
|
- if (this._effectiveMaterial.storeEffectOnSubMeshes) {
|
|
|
+ if (this._effectiveMaterial._storeEffectOnSubMeshes) {
|
|
|
effect = subMesh.effect;
|
|
|
}
|
|
|
else {
|
|
@@ -33736,7 +33773,7 @@ var BABYLON;
|
|
|
this._bind(subMesh, effect, fillMode);
|
|
|
}
|
|
|
var world = this.getWorldMatrix();
|
|
|
- if (this._effectiveMaterial.storeEffectOnSubMeshes) {
|
|
|
+ if (this._effectiveMaterial._storeEffectOnSubMeshes) {
|
|
|
this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
|
|
|
}
|
|
|
else {
|
|
@@ -36378,9 +36415,9 @@ var BABYLON;
|
|
|
*/
|
|
|
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
|
|
|
*/
|
|
@@ -37066,7 +37103,7 @@ var BABYLON;
|
|
|
if (localOptions.clipPlane) {
|
|
|
scene.clipPlane = new BABYLON.Plane(0, 0, 0, 1);
|
|
|
}
|
|
|
- if (_this.storeEffectOnSubMeshes) {
|
|
|
+ if (_this._storeEffectOnSubMeshes) {
|
|
|
if (_this.isReadyForSubMesh(mesh, subMesh)) {
|
|
|
if (onCompiled) {
|
|
|
onCompiled(_this);
|
|
@@ -37226,7 +37263,7 @@ var BABYLON;
|
|
|
mesh.material = null;
|
|
|
if (mesh.geometry) {
|
|
|
var geometry = (mesh.geometry);
|
|
|
- if (this.storeEffectOnSubMeshes) {
|
|
|
+ if (this._storeEffectOnSubMeshes) {
|
|
|
for (var _i = 0, _a = mesh.subMeshes; _i < _a.length; _i++) {
|
|
|
var subMesh = _a[_i];
|
|
|
geometry._releaseVertexArrayObject(subMesh._materialEffect);
|
|
@@ -37244,7 +37281,7 @@ var BABYLON;
|
|
|
this._uniformBuffer.dispose();
|
|
|
// Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
|
|
|
if (forceDisposeEffect && this._effect) {
|
|
|
- if (!this.storeEffectOnSubMeshes) {
|
|
|
+ if (!this._storeEffectOnSubMeshes) {
|
|
|
this._scene.getEngine()._releaseEffect(this._effect);
|
|
|
}
|
|
|
this._effect = null;
|
|
@@ -43224,7 +43261,7 @@ var BABYLON;
|
|
|
* This is mostly used when shader parallel compilation is supported (true by default)
|
|
|
*/
|
|
|
_this.allowShaderHotSwapping = true;
|
|
|
- _this.storeEffectOnSubMeshes = true;
|
|
|
+ _this._storeEffectOnSubMeshes = true;
|
|
|
return _this;
|
|
|
}
|
|
|
PushMaterial.prototype.getEffect = function () {
|
|
@@ -61843,10 +61880,10 @@ var BABYLON;
|
|
|
if (!this.isReady()) {
|
|
|
return;
|
|
|
}
|
|
|
- if (this._currentRenderId === this._scene.getRenderId()) {
|
|
|
+ if (this._currentRenderId === this._scene.getFrameId()) {
|
|
|
return;
|
|
|
}
|
|
|
- this._currentRenderId = this._scene.getRenderId();
|
|
|
+ this._currentRenderId = this._scene.getFrameId();
|
|
|
}
|
|
|
this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
|
|
|
// Determine the number of particles we need to create
|
|
@@ -67566,10 +67603,10 @@ var BABYLON;
|
|
|
}
|
|
|
this._preWarmDone = true;
|
|
|
}
|
|
|
- if (this._currentRenderId === this._scene.getRenderId()) {
|
|
|
+ if (this._currentRenderId === this._scene.getFrameId()) {
|
|
|
return 0;
|
|
|
}
|
|
|
- this._currentRenderId = this._scene.getRenderId();
|
|
|
+ this._currentRenderId = this._scene.getFrameId();
|
|
|
}
|
|
|
// Get everything ready to render
|
|
|
this._initialize();
|
|
@@ -68345,13 +68382,22 @@ var BABYLON;
|
|
|
var index = 0;
|
|
|
var idx = 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++) {
|
|
|
var particle = this.particles[p];
|
|
|
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++) {
|
|
|
idx = index + pt * 3;
|
|
|
BABYLON.Vector3.TransformNormalFromFloatsToRef(this._normals32[idx], this._normals32[idx + 1], this._normals32[idx + 2], invertedRotMatrix, tmpNormal);
|
|
@@ -80200,7 +80246,7 @@ var BABYLON;
|
|
|
var _this = _super.call(this, name, scene, true) || this;
|
|
|
scene.multiMaterials.push(_this);
|
|
|
_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;
|
|
|
}
|
|
|
Object.defineProperty(MultiMaterial.prototype, "subMaterials", {
|
|
@@ -80282,7 +80328,7 @@ var BABYLON;
|
|
|
for (var index = 0; index < this.subMaterials.length; index++) {
|
|
|
var subMaterial = this.subMaterials[index];
|
|
|
if (subMaterial) {
|
|
|
- if (subMaterial.storeEffectOnSubMeshes) {
|
|
|
+ if (subMaterial._storeEffectOnSubMeshes) {
|
|
|
if (!subMaterial.isReadyForSubMesh(mesh, subMesh, useInstances)) {
|
|
|
return false;
|
|
|
}
|
|
@@ -91784,7 +91830,7 @@ var BABYLON;
|
|
|
* The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
|
|
|
* Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
|
|
|
* As an example, all you have to do is to create the post-process:
|
|
|
- * var mb = new BABYLON.MotionBlurProcess(
|
|
|
+ * var mb = new BABYLON.MotionBlurPostProcess(
|
|
|
* 'mb', // The name of the effect.
|
|
|
* scene, // The scene containing the objects to blur according to their velocity.
|
|
|
* 1.0, // The required width/height ratio to downsize to before computing the render pass.
|
|
@@ -91792,8 +91838,8 @@ var BABYLON;
|
|
|
* );
|
|
|
* Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
|
|
|
*/
|
|
|
- var MotionBlurProcess = /** @class */ (function (_super) {
|
|
|
- __extends(MotionBlurProcess, _super);
|
|
|
+ var MotionBlurPostProcess = /** @class */ (function (_super) {
|
|
|
+ __extends(MotionBlurPostProcess, _super);
|
|
|
/**
|
|
|
* Creates a new instance MotionBlurPostProcess
|
|
|
* @param name The name of the effect.
|
|
@@ -91806,7 +91852,7 @@ var BABYLON;
|
|
|
* @param textureType Type of textures used when performing the post process. (default: 0)
|
|
|
* @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
|
|
|
*/
|
|
|
- function MotionBlurProcess(name, scene, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
|
|
|
+ function MotionBlurPostProcess(name, scene, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
|
|
|
if (textureType === void 0) { textureType = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
|
|
|
if (blockCompilation === void 0) { blockCompilation = false; }
|
|
|
var _this = _super.call(this, name, "motionBlur", ["motionStrength", "motionScale", "screenSize"], ["velocitySampler"], options, camera, samplingMode, engine, reusable, "#define SAMPLES 64.0", textureType, undefined, null, blockCompilation) || this;
|
|
@@ -91835,7 +91881,7 @@ var BABYLON;
|
|
|
};
|
|
|
return _this;
|
|
|
}
|
|
|
- Object.defineProperty(MotionBlurProcess.prototype, "motionBlurSamples", {
|
|
|
+ Object.defineProperty(MotionBlurPostProcess.prototype, "motionBlurSamples", {
|
|
|
/**
|
|
|
* Gets the number of iterations are used for motion blur quality. Default value is equal to 32
|
|
|
*/
|
|
@@ -91856,16 +91902,16 @@ var BABYLON;
|
|
|
* Disposes the post process.
|
|
|
* @param camera The camera to dispose the post process on.
|
|
|
*/
|
|
|
- MotionBlurProcess.prototype.dispose = function (camera) {
|
|
|
+ MotionBlurPostProcess.prototype.dispose = function (camera) {
|
|
|
if (this._geometryBufferRenderer) {
|
|
|
// Clear previous transformation matrices dictionary used to compute objects velocities
|
|
|
this._geometryBufferRenderer._previousTransformationMatrices = {};
|
|
|
}
|
|
|
_super.prototype.dispose.call(this, camera);
|
|
|
};
|
|
|
- return MotionBlurProcess;
|
|
|
+ return MotionBlurPostProcess;
|
|
|
}(BABYLON.PostProcess));
|
|
|
- BABYLON.MotionBlurProcess = MotionBlurProcess;
|
|
|
+ BABYLON.MotionBlurPostProcess = MotionBlurPostProcess;
|
|
|
})(BABYLON || (BABYLON = {}));
|
|
|
|
|
|
//# sourceMappingURL=babylon.motionBlurPostProcess.js.map
|
|
@@ -108183,6 +108229,63 @@ var BABYLON;
|
|
|
|
|
|
//# sourceMappingURL=babylon.vrExperienceHelper.js.map
|
|
|
|
|
|
+
|
|
|
+var BABYLON;
|
|
|
+(function (BABYLON) {
|
|
|
+ /**
|
|
|
+ * WebXR Camera which holds the views for the xrSession
|
|
|
+ * @see https://doc.babylonjs.com/how_to/webxr
|
|
|
+ */
|
|
|
+ var WebXRCamera = /** @class */ (function (_super) {
|
|
|
+ __extends(WebXRCamera, _super);
|
|
|
+ /**
|
|
|
+ * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
|
|
|
+ * @param name the name of the camera
|
|
|
+ * @param scene the scene to add the camera to
|
|
|
+ */
|
|
|
+ function WebXRCamera(name, scene) {
|
|
|
+ var _this = _super.call(this, name, BABYLON.Vector3.Zero(), scene) || this;
|
|
|
+ // Initial camera configuration
|
|
|
+ _this.minZ = 0;
|
|
|
+ _this.rotationQuaternion = new BABYLON.Quaternion();
|
|
|
+ _this.cameraRigMode = BABYLON.Camera.RIG_MODE_CUSTOM;
|
|
|
+ _this._updateNumberOfRigCameras(1);
|
|
|
+ return _this;
|
|
|
+ }
|
|
|
+ WebXRCamera.prototype._updateNumberOfRigCameras = function (viewCount) {
|
|
|
+ if (viewCount === void 0) { viewCount = 1; }
|
|
|
+ while (this.rigCameras.length < viewCount) {
|
|
|
+ var newCamera = new BABYLON.TargetCamera("view: " + this.rigCameras.length, BABYLON.Vector3.Zero(), this.getScene());
|
|
|
+ newCamera.minZ = 0;
|
|
|
+ newCamera.parent = this;
|
|
|
+ this.rigCameras.push(newCamera);
|
|
|
+ }
|
|
|
+ while (this.rigCameras.length > viewCount) {
|
|
|
+ var removedCamera = this.rigCameras.pop();
|
|
|
+ if (removedCamera) {
|
|
|
+ removedCamera.dispose();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ /** @hidden */
|
|
|
+ WebXRCamera.prototype._updateForDualEyeDebugging = function (pupilDistance) {
|
|
|
+ if (pupilDistance === void 0) { pupilDistance = 0.01; }
|
|
|
+ // Create initial camera rigs
|
|
|
+ this._updateNumberOfRigCameras(2);
|
|
|
+ this.rigCameras[0].viewport = new BABYLON.Viewport(0, 0, 0.5, 1.0);
|
|
|
+ this.rigCameras[0].position.x = -pupilDistance / 2;
|
|
|
+ this.rigCameras[0].customDefaultRenderTarget = null;
|
|
|
+ this.rigCameras[1].viewport = new BABYLON.Viewport(0.5, 0, 0.5, 1.0);
|
|
|
+ this.rigCameras[1].position.x = pupilDistance / 2;
|
|
|
+ this.rigCameras[1].customDefaultRenderTarget = null;
|
|
|
+ };
|
|
|
+ return WebXRCamera;
|
|
|
+ }(BABYLON.FreeCamera));
|
|
|
+ BABYLON.WebXRCamera = WebXRCamera;
|
|
|
+})(BABYLON || (BABYLON = {}));
|
|
|
+
|
|
|
+//# sourceMappingURL=babylon.webXRCamera.js.map
|
|
|
+
|
|
|
// Mainly based on these 2 articles :
|
|
|
// Creating an universal virtual touch joystick working for all Touch models thanks to Hand.JS : http://blogs.msdn.com/b/davrous/archive/2013/02/22/creating-an-universal-virtual-touch-joystick-working-for-all-touch-models-thanks-to-hand-js.aspx
|
|
|
// & on Seb Lee-Delisle original work: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/
|