|
@@ -7173,39 +7173,49 @@ var BABYLON;
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
};
|
|
};
|
|
- Node.prototype._getDescendants = function (list, results, directDecendantsOnly) {
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Evaluate a list of nodes and determine if they should be considered as descendants considering the given criterias
|
|
|
|
+ * @param {BABYLON.Node[]} list the input array of nodes to evaluate
|
|
|
|
+ * @param {BABYLON.Node[]} results the result array containing the nodes matching the given criterias
|
|
|
|
+ * @param {boolean} directDecendantsOnly if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered.
|
|
|
|
+ * @param predicate: an optional predicate that will be called on every evaluated children, the predicate must return true for a given child to be part of the result, otherwise it will be ignored.
|
|
|
|
+ */
|
|
|
|
+ Node.prototype._getDescendants = function (list, results, directDecendantsOnly, predicate) {
|
|
if (directDecendantsOnly === void 0) { directDecendantsOnly = false; }
|
|
if (directDecendantsOnly === void 0) { directDecendantsOnly = false; }
|
|
for (var index = 0; index < list.length; index++) {
|
|
for (var index = 0; index < list.length; index++) {
|
|
var item = list[index];
|
|
var item = list[index];
|
|
- if ((directDecendantsOnly && item.parent === this) || (!directDecendantsOnly && item.isDescendantOf(this))) {
|
|
|
|
|
|
+ if (((directDecendantsOnly && item.parent === this) || (!directDecendantsOnly && item.isDescendantOf(this))) && (predicate === null || predicate(item))) {
|
|
results.push(item);
|
|
results.push(item);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
* Will return all nodes that have this node as parent.
|
|
* Will return all nodes that have this node as parent.
|
|
|
|
+ * @param {boolean} directDecendantsOnly if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered.
|
|
|
|
+ * @param predicate: an optional predicate that will be called on every evaluated children, the predicate must return true for a given child to be part of the result, otherwise it will be ignored.
|
|
* @return {BABYLON.Node[]} all children nodes of all types.
|
|
* @return {BABYLON.Node[]} all children nodes of all types.
|
|
*/
|
|
*/
|
|
- Node.prototype.getDescendants = function (directDecendantsOnly) {
|
|
|
|
|
|
+ Node.prototype.getDescendants = function (directDecendantsOnly, predicate) {
|
|
var results = [];
|
|
var results = [];
|
|
- this._getDescendants(this._scene.meshes, results, directDecendantsOnly);
|
|
|
|
- this._getDescendants(this._scene.lights, results, directDecendantsOnly);
|
|
|
|
- this._getDescendants(this._scene.cameras, results, directDecendantsOnly);
|
|
|
|
|
|
+ this._getDescendants(this._scene.meshes, results, directDecendantsOnly, predicate);
|
|
|
|
+ this._getDescendants(this._scene.lights, results, directDecendantsOnly, predicate);
|
|
|
|
+ this._getDescendants(this._scene.cameras, results, directDecendantsOnly, predicate);
|
|
return results;
|
|
return results;
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
|
|
+ * @param predicate: an optional predicate that will be called on every evaluated children, the predicate must return true for a given child to be part of the result, otherwise it will be ignored.
|
|
* @Deprecated, legacy support.
|
|
* @Deprecated, legacy support.
|
|
* use getDecendants instead.
|
|
* use getDecendants instead.
|
|
*/
|
|
*/
|
|
- Node.prototype.getChildren = function () {
|
|
|
|
- return this.getDescendants(true);
|
|
|
|
|
|
+ Node.prototype.getChildren = function (predicate) {
|
|
|
|
+ return this.getDescendants(true, predicate);
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
* Get all child-meshes of this node.
|
|
* Get all child-meshes of this node.
|
|
*/
|
|
*/
|
|
- Node.prototype.getChildMeshes = function (directDecendantsOnly) {
|
|
|
|
|
|
+ Node.prototype.getChildMeshes = function (directDecendantsOnly, predicate) {
|
|
var results = [];
|
|
var results = [];
|
|
- this._getDescendants(this._scene.meshes, results, directDecendantsOnly);
|
|
|
|
|
|
+ this._getDescendants(this._scene.meshes, results, directDecendantsOnly, predicate);
|
|
return results;
|
|
return results;
|
|
};
|
|
};
|
|
Node.prototype._setReady = function (state) {
|
|
Node.prototype._setReady = function (state) {
|
|
@@ -10973,6 +10983,7 @@ var BABYLON;
|
|
Camera._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12;
|
|
Camera._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12;
|
|
Camera._RIG_MODE_STEREOSCOPIC_OVERUNDER = 13;
|
|
Camera._RIG_MODE_STEREOSCOPIC_OVERUNDER = 13;
|
|
Camera._RIG_MODE_VR = 20;
|
|
Camera._RIG_MODE_VR = 20;
|
|
|
|
+ Camera.ForceAttachControlToAlwaysPreventDefault = false;
|
|
__decorate([
|
|
__decorate([
|
|
BABYLON.serializeAsVector3()
|
|
BABYLON.serializeAsVector3()
|
|
], Camera.prototype, "position", void 0);
|
|
], Camera.prototype, "position", void 0);
|
|
@@ -11344,6 +11355,7 @@ var BABYLON;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
this._attachedElement = element;
|
|
this._attachedElement = element;
|
|
|
|
+ noPreventDefault = BABYLON.Camera.ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
|
|
if (this._onMouseDown === undefined) {
|
|
if (this._onMouseDown === undefined) {
|
|
this._onMouseDown = function (evt) {
|
|
this._onMouseDown = function (evt) {
|
|
previousPosition = {
|
|
previousPosition = {
|
|
@@ -11687,6 +11699,7 @@ var BABYLON;
|
|
if (this._attachedCanvas) {
|
|
if (this._attachedCanvas) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ noPreventDefault = BABYLON.Camera.ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
|
|
if (this._onPointerDown === undefined) {
|
|
if (this._onPointerDown === undefined) {
|
|
this._onPointerDown = function (evt) {
|
|
this._onPointerDown = function (evt) {
|
|
if (evt.pointerType === "mouse") {
|
|
if (evt.pointerType === "mouse") {
|
|
@@ -11943,6 +11956,7 @@ var BABYLON;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
this._attachedElement = element;
|
|
this._attachedElement = element;
|
|
|
|
+ noPreventDefault = BABYLON.Camera.ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
|
|
var engine = this.getEngine();
|
|
var engine = this.getEngine();
|
|
if (this._onPointerDown === undefined) {
|
|
if (this._onPointerDown === undefined) {
|
|
this._onPointerDown = function (evt) {
|
|
this._onPointerDown = function (evt) {
|
|
@@ -34106,6 +34120,7 @@ var BABYLON;
|
|
};
|
|
};
|
|
VRDeviceOrientationFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
|
|
VRDeviceOrientationFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
|
|
_super.prototype.attachControl.call(this, element, noPreventDefault);
|
|
_super.prototype.attachControl.call(this, element, noPreventDefault);
|
|
|
|
+ noPreventDefault = BABYLON.Camera.ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
|
|
window.addEventListener("deviceorientation", this._deviceOrientationHandler);
|
|
window.addEventListener("deviceorientation", this._deviceOrientationHandler);
|
|
};
|
|
};
|
|
VRDeviceOrientationFreeCamera.prototype.detachControl = function (element) {
|
|
VRDeviceOrientationFreeCamera.prototype.detachControl = function (element) {
|
|
@@ -34179,6 +34194,7 @@ var BABYLON;
|
|
};
|
|
};
|
|
WebVRFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
|
|
WebVRFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
|
|
_super.prototype.attachControl.call(this, element, noPreventDefault);
|
|
_super.prototype.attachControl.call(this, element, noPreventDefault);
|
|
|
|
+ noPreventDefault = BABYLON.Camera.ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
|
|
if (navigator.getVRDevices) {
|
|
if (navigator.getVRDevices) {
|
|
navigator.getVRDevices().then(this._getWebVRDevices);
|
|
navigator.getVRDevices().then(this._getWebVRDevices);
|
|
}
|
|
}
|
|
@@ -35523,6 +35539,7 @@ var BABYLON;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
this._attachedCanvas = canvas;
|
|
this._attachedCanvas = canvas;
|
|
|
|
+ noPreventDefault = BABYLON.Camera.ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
|
|
if (!this._orientationChanged) {
|
|
if (!this._orientationChanged) {
|
|
this._orientationChanged = function (evt) {
|
|
this._orientationChanged = function (evt) {
|
|
if (!_this._initialOrientationGamma) {
|
|
if (!_this._initialOrientationGamma) {
|