babylon.debugLayer.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. module BABYLON {
  2. // declare INSPECTOR namespace for compilation issue
  3. declare var INSPECTOR: any;
  4. export class DebugLayer {
  5. private _scene: Scene;
  6. public static InspectorURL = 'http://www.babylonjs.com/babylon.inspector.bundle.js';
  7. // The inspector instance
  8. private _inspector: any;
  9. constructor(scene: Scene) {
  10. this._scene = scene;
  11. }
  12. /** Creates the inspector window. */
  13. private _createInspector(config: { popup?: boolean, initialTab?: number, parentElement?: HTMLElement } = {}) {
  14. let popup = config.popup || false;
  15. let initialTab = config.initialTab || 0;
  16. let parentElement = config.parentElement || null;
  17. if (!this._inspector) {
  18. this._inspector = new INSPECTOR.Inspector(this._scene, popup, initialTab, parentElement);
  19. } // else nothing to do,; instance is already existing
  20. }
  21. public isVisible(): boolean {
  22. if (!this._inspector) {
  23. return false;
  24. }
  25. return true;
  26. }
  27. public hide() {
  28. if (this._inspector) {
  29. this._inspector.dispose();
  30. this._inspector = null;
  31. }
  32. }
  33. public show(config: { popup?: boolean, initialTab?: number, parentElement?: HTMLElement } = {}) {
  34. if (typeof INSPECTOR == 'undefined') {
  35. // Load inspector and add it to the DOM
  36. Tools.LoadScript(DebugLayer.InspectorURL, this._createInspector.bind(this, config));
  37. } else {
  38. // Otherwise creates the inspector
  39. this._createInspector(config);
  40. }
  41. }
  42. }
  43. }