babylon.node.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. var BABYLON = BABYLON || {};
  2. (function () {
  3. BABYLON.Node = function () {
  4. };
  5. // Properties
  6. BABYLON.Node.prototype.parent = null;
  7. BABYLON.Node.prototype._childrenFlag = false;
  8. BABYLON.Node.prototype._isReady = true;
  9. BABYLON.Node.prototype._isEnabled = true;
  10. BABYLON.Node.prototype.isSynchronized = function () {
  11. return true;
  12. };
  13. BABYLON.Node.prototype._needToSynchonizeChildren = function () {
  14. return this._childrenFlag;
  15. };
  16. BABYLON.Node.prototype.isReady = function () {
  17. return this._isReady;
  18. };
  19. BABYLON.Node.prototype.isEnabled = function () {
  20. if (!this.isReady() || !this._isEnabled) {
  21. return false;
  22. }
  23. if (this.parent) {
  24. return this.parent.isEnabled();
  25. }
  26. return true;
  27. };
  28. BABYLON.Node.prototype.setEnabled = function (value) {
  29. this._isEnabled = value;
  30. };
  31. BABYLON.Node.prototype.isDescendantOf = function (ancestor) {
  32. if (this.parent) {
  33. if (this.parent === ancestor) {
  34. return true;
  35. }
  36. return this.parent.isDescendantOf(ancestor);
  37. }
  38. return false;
  39. };
  40. BABYLON.Node.prototype._getDescendants = function(list, results) {
  41. for (var index = 0; index < list.length; index++) {
  42. var item = list[index];
  43. if (item.isDescendantOf(this)) {
  44. results.push(item);
  45. }
  46. }
  47. };
  48. BABYLON.Node.prototype.getDescendants = function () {
  49. var results = [];
  50. this._getDescendants(this._scene.meshes, results);
  51. this._getDescendants(this._scene.lights, results);
  52. this._getDescendants(this._scene.cameras, results);
  53. return results;
  54. };
  55. })();