babylon.node.js 1.8 KB

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