|
@@ -14972,23 +14972,38 @@ var BABYLON;
|
|
|
*/
|
|
|
var Node = /** @class */ (function () {
|
|
|
/**
|
|
|
- * @constructor
|
|
|
+ * Creates a new Node
|
|
|
* @param {string} name - the name and id to be given to this node
|
|
|
* @param {BABYLON.Scene} the scene this node will be added to
|
|
|
*/
|
|
|
function Node(name, scene) {
|
|
|
if (scene === void 0) { scene = null; }
|
|
|
+ /**
|
|
|
+ * Gets or sets a string used to store user defined state for the node
|
|
|
+ */
|
|
|
this.state = "";
|
|
|
+ /**
|
|
|
+ * Gets or sets an object used to store user defined information for the node
|
|
|
+ */
|
|
|
this.metadata = null;
|
|
|
+ /**
|
|
|
+ * Gets or sets a boolean used to define if the node must be serialized
|
|
|
+ */
|
|
|
this.doNotSerialize = false;
|
|
|
+ /** @ignore */
|
|
|
+ this._isDisposed = false;
|
|
|
+ /**
|
|
|
+ * Gets a list of {BABYLON.Animation} associated with the node
|
|
|
+ */
|
|
|
this.animations = new Array();
|
|
|
this._ranges = {};
|
|
|
this._isEnabled = true;
|
|
|
this._isReady = true;
|
|
|
+ /** @ignore */
|
|
|
this._currentRenderId = -1;
|
|
|
this._parentRenderId = -1;
|
|
|
/**
|
|
|
- * An event triggered when the mesh is disposed.
|
|
|
+ * An event triggered when the mesh is disposed
|
|
|
* @type {BABYLON.Observable}
|
|
|
*/
|
|
|
this.onDisposeObservable = new BABYLON.Observable();
|
|
@@ -15000,10 +15015,20 @@ var BABYLON;
|
|
|
this.uniqueId = this._scene.getUniqueId();
|
|
|
this._initCache();
|
|
|
}
|
|
|
+ /**
|
|
|
+ * Gets a boolean indicating if the node has been disposed
|
|
|
+ * @returns true if the node was disposed
|
|
|
+ */
|
|
|
+ Node.prototype.isDisposed = function () {
|
|
|
+ return this._isDisposed;
|
|
|
+ };
|
|
|
Object.defineProperty(Node.prototype, "parent", {
|
|
|
get: function () {
|
|
|
return this._parentNode;
|
|
|
},
|
|
|
+ /**
|
|
|
+ * Gets or sets the parent of the node
|
|
|
+ */
|
|
|
set: function (parent) {
|
|
|
if (this._parentNode === parent) {
|
|
|
return;
|
|
@@ -15028,10 +15053,17 @@ var BABYLON;
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
|
});
|
|
|
+ /**
|
|
|
+ * Gets a string idenfifying the name of the class
|
|
|
+ * @returns "Node" string
|
|
|
+ */
|
|
|
Node.prototype.getClassName = function () {
|
|
|
return "Node";
|
|
|
};
|
|
|
Object.defineProperty(Node.prototype, "onDispose", {
|
|
|
+ /**
|
|
|
+ * Sets a callback that will be raised when the node will be disposed
|
|
|
+ */
|
|
|
set: function (callback) {
|
|
|
if (this._onDisposeObserver) {
|
|
|
this.onDisposeObservable.remove(this._onDisposeObserver);
|
|
@@ -15041,12 +15073,26 @@ var BABYLON;
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
|
});
|
|
|
+ /**
|
|
|
+ * Gets the scene of the node
|
|
|
+ * @returns a {BABYLON.Scene}
|
|
|
+ */
|
|
|
Node.prototype.getScene = function () {
|
|
|
return this._scene;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Gets the engine of the node
|
|
|
+ * @returns a {BABYLON.Engine}
|
|
|
+ */
|
|
|
Node.prototype.getEngine = function () {
|
|
|
return this._scene.getEngine();
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Attach a behavior to the node
|
|
|
+ * @see http://doc.babylonjs.com/features/behaviour
|
|
|
+ * @param behavior defines the behavior to attach
|
|
|
+ * @returns the current Node
|
|
|
+ */
|
|
|
Node.prototype.addBehavior = function (behavior) {
|
|
|
var _this = this;
|
|
|
var index = this._behaviors.indexOf(behavior);
|
|
@@ -15070,6 +15116,12 @@ var BABYLON;
|
|
|
this._behaviors.push(behavior);
|
|
|
return this;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Remove an attached behavior
|
|
|
+ * @see http://doc.babylonjs.com/features/behaviour
|
|
|
+ * @param behavior defines the behavior to attach
|
|
|
+ * @returns the current Node
|
|
|
+ */
|
|
|
Node.prototype.removeBehavior = function (behavior) {
|
|
|
var index = this._behaviors.indexOf(behavior);
|
|
|
if (index === -1) {
|
|
@@ -15080,12 +15132,22 @@ var BABYLON;
|
|
|
return this;
|
|
|
};
|
|
|
Object.defineProperty(Node.prototype, "behaviors", {
|
|
|
+ /**
|
|
|
+ * Gets the list of attached behaviors
|
|
|
+ * @see http://doc.babylonjs.com/features/behaviour
|
|
|
+ */
|
|
|
get: function () {
|
|
|
return this._behaviors;
|
|
|
},
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
|
});
|
|
|
+ /**
|
|
|
+ * Gets an attached behavior by name
|
|
|
+ * @param name defines the name of the behavior to look for
|
|
|
+ * @see http://doc.babylonjs.com/features/behaviour
|
|
|
+ * @returns null if behavior was not found else the requested behavior
|
|
|
+ */
|
|
|
Node.prototype.getBehaviorByName = function (name) {
|
|
|
for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
|
|
|
var behavior = _a[_i];
|
|
@@ -15095,16 +15157,21 @@ var BABYLON;
|
|
|
}
|
|
|
return null;
|
|
|
};
|
|
|
- // override it in derived class
|
|
|
+ /**
|
|
|
+ * Returns the world matrix of the node
|
|
|
+ * @returns a matrix containing the node's world matrix
|
|
|
+ */
|
|
|
Node.prototype.getWorldMatrix = function () {
|
|
|
return BABYLON.Matrix.Identity();
|
|
|
};
|
|
|
// override it in derived class if you add new variables to the cache
|
|
|
// and call the parent class method
|
|
|
+ /** @ignore */
|
|
|
Node.prototype._initCache = function () {
|
|
|
this._cache = {};
|
|
|
this._cache.parent = undefined;
|
|
|
};
|
|
|
+ /** @ignore */
|
|
|
Node.prototype.updateCache = function (force) {
|
|
|
if (!force && this.isSynchronized())
|
|
|
return;
|
|
@@ -15113,17 +15180,21 @@ var BABYLON;
|
|
|
};
|
|
|
// override it in derived class if you add new variables to the cache
|
|
|
// and call the parent class method if !ignoreParentClass
|
|
|
+ /** @ignore */
|
|
|
Node.prototype._updateCache = function (ignoreParentClass) {
|
|
|
};
|
|
|
// override it in derived class if you add new variables to the cache
|
|
|
+ /** @ignore */
|
|
|
Node.prototype._isSynchronized = function () {
|
|
|
return true;
|
|
|
};
|
|
|
+ /** @ignore */
|
|
|
Node.prototype._markSyncedWithParent = function () {
|
|
|
if (this.parent) {
|
|
|
this._parentRenderId = this.parent._currentRenderId;
|
|
|
}
|
|
|
};
|
|
|
+ /** @ignore */
|
|
|
Node.prototype.isSynchronizedWithParent = function () {
|
|
|
if (!this.parent) {
|
|
|
return true;
|
|
@@ -15133,6 +15204,7 @@ var BABYLON;
|
|
|
}
|
|
|
return this.parent.isSynchronized();
|
|
|
};
|
|
|
+ /** @ignore */
|
|
|
Node.prototype.isSynchronized = function (updateCache) {
|
|
|
var check = this.hasNewParent();
|
|
|
check = check || !this.isSynchronizedWithParent();
|
|
@@ -15141,6 +15213,7 @@ var BABYLON;
|
|
|
this.updateCache(true);
|
|
|
return !check;
|
|
|
};
|
|
|
+ /** @ignore */
|
|
|
Node.prototype.hasNewParent = function (update) {
|
|
|
if (this._cache.parent === this.parent)
|
|
|
return false;
|
|
@@ -15150,16 +15223,16 @@ var BABYLON;
|
|
|
};
|
|
|
/**
|
|
|
* Is this node ready to be used/rendered
|
|
|
- * @return {boolean} is it ready
|
|
|
+ * @return true if the node is ready
|
|
|
*/
|
|
|
Node.prototype.isReady = function () {
|
|
|
return this._isReady;
|
|
|
};
|
|
|
/**
|
|
|
- * Is this node enabled.
|
|
|
- * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true.
|
|
|
- * @param {boolean} [checkAncestors=true] - Indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors.
|
|
|
- * @return {boolean} whether this node (and its parent) is enabled.
|
|
|
+ * Is this node enabled?
|
|
|
+ * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
|
|
|
+ * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
|
|
|
+ * @return whether this node (and its parent) is enabled
|
|
|
* @see setEnabled
|
|
|
*/
|
|
|
Node.prototype.isEnabled = function (checkAncestors) {
|
|
@@ -15176,18 +15249,19 @@ var BABYLON;
|
|
|
return true;
|
|
|
};
|
|
|
/**
|
|
|
- * Set the enabled state of this node.
|
|
|
- * @param {boolean} value - the new enabled state
|
|
|
+ * Set the enabled state of this node
|
|
|
+ * @param value defines the new enabled state
|
|
|
* @see isEnabled
|
|
|
*/
|
|
|
Node.prototype.setEnabled = function (value) {
|
|
|
this._isEnabled = value;
|
|
|
};
|
|
|
/**
|
|
|
- * Is this node a descendant of the given node.
|
|
|
- * The function will iterate up the hierarchy until the ancestor was found or no more parents defined.
|
|
|
- * @param {BABYLON.Node} ancestor - The parent node to inspect
|
|
|
+ * Is this node a descendant of the given node?
|
|
|
+ * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
|
|
|
+ * @param ancestor defines the parent node to inspect
|
|
|
* @see parent
|
|
|
+ * @returns a boolean indicating if this node is a descendant of the given node
|
|
|
*/
|
|
|
Node.prototype.isDescendantOf = function (ancestor) {
|
|
|
if (this.parent) {
|
|
@@ -15198,12 +15272,7 @@ var BABYLON;
|
|
|
}
|
|
|
return false;
|
|
|
};
|
|
|
- /**
|
|
|
- * 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 {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.
|
|
|
- */
|
|
|
+ /** @ignore */
|
|
|
Node.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
|
|
|
if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
|
|
|
if (!this._children) {
|
|
@@ -15220,10 +15289,10 @@ var BABYLON;
|
|
|
}
|
|
|
};
|
|
|
/**
|
|
|
- * 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.
|
|
|
- * @return {BABYLON.Node[]} all children nodes of all types.
|
|
|
+ * Will return all nodes that have this node as ascendant
|
|
|
+ * @param directDescendantsOnly defines 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 defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
|
|
|
+ * @return all children nodes of all types
|
|
|
*/
|
|
|
Node.prototype.getDescendants = function (directDescendantsOnly, predicate) {
|
|
|
var results = new Array();
|
|
@@ -15231,7 +15300,10 @@ var BABYLON;
|
|
|
return results;
|
|
|
};
|
|
|
/**
|
|
|
- * Get all child-meshes of this node.
|
|
|
+ * Get all child-meshes of this node
|
|
|
+ * @param directDescendantsOnly defines 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 defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
|
|
|
+ * @returns an array of {BABYLON.AbstractMesh}
|
|
|
*/
|
|
|
Node.prototype.getChildMeshes = function (directDescendantsOnly, predicate) {
|
|
|
var results = [];
|
|
@@ -15241,7 +15313,10 @@ var BABYLON;
|
|
|
return results;
|
|
|
};
|
|
|
/**
|
|
|
- * Get all child-transformNodes of this node.
|
|
|
+ * Get all child-transformNodes of this node
|
|
|
+ * @param directDescendantsOnly defines 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 defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
|
|
|
+ * @returns an array of {BABYLON.TransformNode}
|
|
|
*/
|
|
|
Node.prototype.getChildTransformNodes = function (directDescendantsOnly, predicate) {
|
|
|
var results = [];
|
|
@@ -15251,11 +15326,14 @@ var BABYLON;
|
|
|
return results;
|
|
|
};
|
|
|
/**
|
|
|
- * Get all direct children of this node.
|
|
|
- */
|
|
|
+ * Get all direct children of this node
|
|
|
+ * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
|
|
|
+ * @returns an array of {BABYLON.Node}
|
|
|
+ */
|
|
|
Node.prototype.getChildren = function (predicate) {
|
|
|
return this.getDescendants(true, predicate);
|
|
|
};
|
|
|
+ /** @ignore */
|
|
|
Node.prototype._setReady = function (state) {
|
|
|
if (state === this._isReady) {
|
|
|
return;
|
|
@@ -15269,6 +15347,11 @@ var BABYLON;
|
|
|
this.onReady(this);
|
|
|
}
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Get an animation by name
|
|
|
+ * @param name defines the name of the animation to look for
|
|
|
+ * @returns null if not found else the requested animation
|
|
|
+ */
|
|
|
Node.prototype.getAnimationByName = function (name) {
|
|
|
for (var i = 0; i < this.animations.length; i++) {
|
|
|
var animation = this.animations[i];
|
|
@@ -15278,6 +15361,12 @@ var BABYLON;
|
|
|
}
|
|
|
return null;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Creates an animation range for this node
|
|
|
+ * @param name defines the name of the range
|
|
|
+ * @param from defines the starting key
|
|
|
+ * @param to defines the end key
|
|
|
+ */
|
|
|
Node.prototype.createAnimationRange = function (name, from, to) {
|
|
|
// check name not already in use
|
|
|
if (!this._ranges[name]) {
|
|
@@ -15289,6 +15378,11 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Delete a specific animation range
|
|
|
+ * @param name defines the name of the range to delete
|
|
|
+ * @param deleteFrames defines if animation frames from the range must be deleted as well
|
|
|
+ */
|
|
|
Node.prototype.deleteAnimationRange = function (name, deleteFrames) {
|
|
|
if (deleteFrames === void 0) { deleteFrames = true; }
|
|
|
for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
|
|
@@ -15298,6 +15392,11 @@ var BABYLON;
|
|
|
}
|
|
|
this._ranges[name] = null; // said much faster than 'delete this._range[name]'
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Get an animation range by name
|
|
|
+ * @param name defines the name of the animation range to look for
|
|
|
+ * @returns null if not found else the requested animation range
|
|
|
+ */
|
|
|
Node.prototype.getAnimationRange = function (name) {
|
|
|
return this._ranges[name];
|
|
|
};
|
|
@@ -15307,7 +15406,7 @@ var BABYLON;
|
|
|
* @param loop defines if the animation should loop (false by default)
|
|
|
* @param speedRatio defines the speed factor in which to run the animation (1 by default)
|
|
|
* @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
|
|
|
- * @returns the {BABYLON.Animatable} object created for this animation. If range does not exist, it will return null
|
|
|
+ * @returns the object created for this animation. If range does not exist, it will return null
|
|
|
*/
|
|
|
Node.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
|
|
|
var range = this.getAnimationRange(name);
|
|
@@ -15316,6 +15415,10 @@ var BABYLON;
|
|
|
}
|
|
|
return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Serialize animation ranges into a JSON compatible object
|
|
|
+ * @returns serialization object
|
|
|
+ */
|
|
|
Node.prototype.serializeAnimationRanges = function () {
|
|
|
var serializationRanges = [];
|
|
|
for (var name in this._ranges) {
|
|
@@ -15331,10 +15434,17 @@ var BABYLON;
|
|
|
}
|
|
|
return serializationRanges;
|
|
|
};
|
|
|
- // override it in derived class
|
|
|
+ /**
|
|
|
+ * Computes the world matrix of the node
|
|
|
+ * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
|
|
|
+ * @returns the world matrix
|
|
|
+ */
|
|
|
Node.prototype.computeWorldMatrix = function (force) {
|
|
|
return BABYLON.Matrix.Identity();
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Releases all associated resources
|
|
|
+ */
|
|
|
Node.prototype.dispose = function () {
|
|
|
this.parent = null;
|
|
|
// Callback
|
|
@@ -15346,7 +15456,14 @@ var BABYLON;
|
|
|
behavior.detach();
|
|
|
}
|
|
|
this._behaviors = [];
|
|
|
+ this._isDisposed = true;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Parse animation range data from a serialization object and store them into a given node
|
|
|
+ * @param node defines where to store the animation ranges
|
|
|
+ * @param parsedNode defines the serialization object to read data from
|
|
|
+ * @param scene defines the hosting scene
|
|
|
+ */
|
|
|
Node.ParseAnimationRanges = function (node, parsedNode, scene) {
|
|
|
if (parsedNode.ranges) {
|
|
|
for (var index = 0; index < parsedNode.ranges.length; index++) {
|
|
@@ -16769,7 +16886,6 @@ var BABYLON;
|
|
|
// Cache
|
|
|
_this._collisionsTransformMatrix = BABYLON.Matrix.Zero();
|
|
|
_this._collisionsScalingMatrix = BABYLON.Matrix.Zero();
|
|
|
- _this._isDisposed = false;
|
|
|
_this._renderId = 0;
|
|
|
_this._intersectionsInProgress = new Array();
|
|
|
_this._unIndexed = false;
|
|
@@ -17144,12 +17260,6 @@ var BABYLON;
|
|
|
configurable: true
|
|
|
});
|
|
|
/**
|
|
|
- * Boolean : true if the mesh has been disposed.
|
|
|
- */
|
|
|
- AbstractMesh.prototype.isDisposed = function () {
|
|
|
- return this._isDisposed;
|
|
|
- };
|
|
|
- /**
|
|
|
* Returns the string "AbstractMesh"
|
|
|
*/
|
|
|
AbstractMesh.prototype.getClassName = function () {
|
|
@@ -18003,7 +18113,6 @@ var BABYLON;
|
|
|
this.onAfterWorldMatrixUpdateObservable.clear();
|
|
|
this.onCollideObservable.clear();
|
|
|
this.onCollisionPositionChangeObservable.clear();
|
|
|
- this._isDisposed = true;
|
|
|
_super.prototype.dispose.call(this, doNotRecurse);
|
|
|
};
|
|
|
/**
|
|
@@ -51300,7 +51409,7 @@ var BABYLON;
|
|
|
|
|
|
|
|
|
|
|
|
-//# sourceMappingURL=babylon.IParticleEmitterType.js.map
|
|
|
+//# sourceMappingURL=babylon.iParticleEmitterType.js.map
|
|
|
|
|
|
var BABYLON;
|
|
|
(function (BABYLON) {
|