|
@@ -7129,6 +7129,31 @@ var BABYLON;
|
|
this._scene = scene;
|
|
this._scene = scene;
|
|
this._initCache();
|
|
this._initCache();
|
|
}
|
|
}
|
|
|
|
+ Object.defineProperty(Node.prototype, "parent", {
|
|
|
|
+ get: function () {
|
|
|
|
+ return this._parentNode;
|
|
|
|
+ },
|
|
|
|
+ set: function (parent) {
|
|
|
|
+ if (this._parentNode === parent) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (this._parentNode) {
|
|
|
|
+ var index = this._parentNode._children.indexOf(this);
|
|
|
|
+ if (index !== -1) {
|
|
|
|
+ this._parentNode._children.splice(index, 1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this._parentNode = parent;
|
|
|
|
+ if (this._parentNode) {
|
|
|
|
+ if (!this._parentNode._children) {
|
|
|
|
+ this._parentNode._children = new Array();
|
|
|
|
+ }
|
|
|
|
+ this._parentNode._children.push(this);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
Node.prototype.getScene = function () {
|
|
Node.prototype.getScene = function () {
|
|
return this._scene;
|
|
return this._scene;
|
|
};
|
|
};
|
|
@@ -7232,32 +7257,35 @@ var BABYLON;
|
|
return false;
|
|
return false;
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
- * 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
|
|
|
|
|
|
+ * Evaluate the list of children and determine if they should be considered as descendants considering the given criterias
|
|
* @param {BABYLON.Node[]} results the result array containing the nodes matching the given criterias
|
|
* @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 {boolean} directDescendantsOnly 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.
|
|
* @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; }
|
|
|
|
- for (var index = 0; index < list.length; index++) {
|
|
|
|
- var item = list[index];
|
|
|
|
- if (((directDecendantsOnly && item.parent === this) || (!directDecendantsOnly && item.isDescendantOf(this))) && (!predicate || predicate(item))) {
|
|
|
|
|
|
+ Node.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
|
|
|
|
+ if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
|
|
|
|
+ if (!this._children) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for (var index = 0; index < this._children.length; index++) {
|
|
|
|
+ var item = this._children[index];
|
|
|
|
+ if (!predicate || predicate(item)) {
|
|
results.push(item);
|
|
results.push(item);
|
|
}
|
|
}
|
|
|
|
+ if (!directDescendantsOnly) {
|
|
|
|
+ item._getDescendants(results, false, predicate);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
- * 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.
|
|
|
|
|
|
+ * Will return all nodes that have this node as ascendant.
|
|
|
|
+ * @param {boolean} directDescendantsOnly 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.
|
|
* @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, predicate) {
|
|
|
|
|
|
+ Node.prototype.getDescendants = function (directDescendantsOnly, predicate) {
|
|
var results = [];
|
|
var results = [];
|
|
- this._getDescendants(this._scene.meshes, results, directDecendantsOnly, predicate);
|
|
|
|
- this._getDescendants(this._scene.lights, results, directDecendantsOnly, predicate);
|
|
|
|
- this._getDescendants(this._scene.cameras, results, directDecendantsOnly, predicate);
|
|
|
|
|
|
+ this._getDescendants(results, directDescendantsOnly, predicate);
|
|
return results;
|
|
return results;
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
@@ -7273,7 +7301,9 @@ var BABYLON;
|
|
*/
|
|
*/
|
|
Node.prototype.getChildMeshes = function (directDecendantsOnly, predicate) {
|
|
Node.prototype.getChildMeshes = function (directDecendantsOnly, predicate) {
|
|
var results = [];
|
|
var results = [];
|
|
- this._getDescendants(this._scene.meshes, results, directDecendantsOnly, predicate);
|
|
|
|
|
|
+ this._getDescendants(results, directDecendantsOnly, function (node) {
|
|
|
|
+ return ((!predicate || predicate(node)) && (node instanceof BABYLON.AbstractMesh));
|
|
|
|
+ });
|
|
return results;
|
|
return results;
|
|
};
|
|
};
|
|
Node.prototype._setReady = function (state) {
|
|
Node.prototype._setReady = function (state) {
|
|
@@ -7339,6 +7369,9 @@ var BABYLON;
|
|
}
|
|
}
|
|
return serializationRanges;
|
|
return serializationRanges;
|
|
};
|
|
};
|
|
|
|
+ Node.prototype.dispose = function () {
|
|
|
|
+ this.parent = null;
|
|
|
|
+ };
|
|
Node.ParseAnimationRanges = function (node, parsedNode, scene) {
|
|
Node.ParseAnimationRanges = function (node, parsedNode, scene) {
|
|
if (parsedNode.ranges) {
|
|
if (parsedNode.ranges) {
|
|
for (var index = 0; index < parsedNode.ranges.length; index++) {
|
|
for (var index = 0; index < parsedNode.ranges.length; index++) {
|
|
@@ -9023,6 +9056,7 @@ var BABYLON;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ _super.prototype.dispose.call(this);
|
|
this._onAfterWorldMatrixUpdate = [];
|
|
this._onAfterWorldMatrixUpdate = [];
|
|
this._isDisposed = true;
|
|
this._isDisposed = true;
|
|
// Callback
|
|
// Callback
|
|
@@ -9133,6 +9167,7 @@ var BABYLON;
|
|
this.getScene().stopAnimation(this);
|
|
this.getScene().stopAnimation(this);
|
|
// Remove from scene
|
|
// Remove from scene
|
|
this.getScene().removeLight(this);
|
|
this.getScene().removeLight(this);
|
|
|
|
+ _super.prototype.dispose.call(this);
|
|
};
|
|
};
|
|
Light.prototype.getTypeID = function () {
|
|
Light.prototype.getTypeID = function () {
|
|
return 0;
|
|
return 0;
|
|
@@ -10881,6 +10916,7 @@ var BABYLON;
|
|
for (var i = 0; i < this._postProcessesTakenIndices.length; ++i) {
|
|
for (var i = 0; i < this._postProcessesTakenIndices.length; ++i) {
|
|
this._postProcesses[this._postProcessesTakenIndices[i]].dispose(this);
|
|
this._postProcesses[this._postProcessesTakenIndices[i]].dispose(this);
|
|
}
|
|
}
|
|
|
|
+ _super.prototype.dispose.call(this);
|
|
};
|
|
};
|
|
// ---- Camera rigs section ----
|
|
// ---- Camera rigs section ----
|
|
Camera.prototype.setCameraRigMode = function (mode, rigParams) {
|
|
Camera.prototype.setCameraRigMode = function (mode, rigParams) {
|
|
@@ -11176,7 +11212,7 @@ var BABYLON;
|
|
CameraInputsManager.prototype.remove = function (inputToRemove) {
|
|
CameraInputsManager.prototype.remove = function (inputToRemove) {
|
|
for (var cam in this.attached) {
|
|
for (var cam in this.attached) {
|
|
var input = this.attached[cam];
|
|
var input = this.attached[cam];
|
|
- if (input == inputToRemove) {
|
|
|
|
|
|
+ if (input === inputToRemove) {
|
|
input.detachControl(this.attachedElement);
|
|
input.detachControl(this.attachedElement);
|
|
delete this.attached[cam];
|
|
delete this.attached[cam];
|
|
}
|
|
}
|
|
@@ -11185,7 +11221,7 @@ var BABYLON;
|
|
CameraInputsManager.prototype.removeByType = function (inputType) {
|
|
CameraInputsManager.prototype.removeByType = function (inputType) {
|
|
for (var cam in this.attached) {
|
|
for (var cam in this.attached) {
|
|
var input = this.attached[cam];
|
|
var input = this.attached[cam];
|
|
- if (input.getTypeName() == inputType) {
|
|
|
|
|
|
+ if (input.getTypeName() === inputType) {
|
|
input.detachControl(this.attachedElement);
|
|
input.detachControl(this.attachedElement);
|
|
delete this.attached[cam];
|
|
delete this.attached[cam];
|
|
}
|
|
}
|