babylon.inspector.d.ts 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967
  1. declare module INSPECTOR {
  2. class Inspector {
  3. private _c2diwrapper;
  4. /** The panel displayed at the top of the inspector */
  5. private _topPanel;
  6. /** The div containing the content of the active tab */
  7. private _tabPanel;
  8. /** The panel containing the list if items */
  9. /** The list if tree items displayed in the tree panel. */
  10. private _items;
  11. private _tabbar;
  12. private _scene;
  13. /** The HTML document relative to this inspector (the window or the popup depending on its mode) */
  14. static DOCUMENT: HTMLDocument;
  15. /** The HTML window. In popup mode, it's the popup itself. Otherwise, it's the current tab */
  16. static WINDOW: Window;
  17. /** True if the inspector is built as a popup tab */
  18. private _popupMode;
  19. /** The original canvas style, before applying the inspector*/
  20. private _canvasStyle;
  21. /** The inspector is created with the given engine.
  22. * If a HTML parent is not given as a parameter, the inspector is created as a right panel on the main window.
  23. * If a HTML parent is given, the inspector is created in this element, taking full size of its parent.
  24. */
  25. constructor(scene: BABYLON.Scene, parent?: HTMLElement);
  26. /** Build the inspector panel in the given HTML element */
  27. private _buildInspector(parent);
  28. scene: BABYLON.Scene;
  29. popupMode: boolean;
  30. /**
  31. * Filter the list of item present in the tree.
  32. * All item returned should have the given filter contained in the item id.
  33. */
  34. filterItem(filter: string): void;
  35. /** Display the mesh tab on the given object */
  36. displayObjectDetails(mesh: BABYLON.AbstractMesh): void;
  37. /** Clean the whole tree of item and rebuilds it */
  38. refresh(): void;
  39. /** Remove the inspector panel when it's built as a right panel:
  40. * remove the right panel and remove the wrapper
  41. */
  42. dispose(): void;
  43. /** Open the inspector in a new popup */
  44. openPopup(): void;
  45. }
  46. }
  47. declare module INSPECTOR {
  48. const PROPERTIES: {
  49. format: (obj: any) => any;
  50. 'type_not_defined': {
  51. properties: any[];
  52. format: () => string;
  53. };
  54. 'Vector2': {
  55. type: typeof BABYLON.Vector2;
  56. properties: string[];
  57. format: (vec: BABYLON.Vector2) => string;
  58. };
  59. 'Vector3': {
  60. type: typeof BABYLON.Vector3;
  61. properties: string[];
  62. format: (vec: BABYLON.Vector3) => string;
  63. };
  64. 'Color3': {
  65. type: typeof BABYLON.Color3;
  66. properties: string[];
  67. format: (color: BABYLON.Color3) => string;
  68. };
  69. 'Quaternion': {
  70. type: typeof BABYLON.Quaternion;
  71. properties: string[];
  72. };
  73. 'Size': {
  74. type: typeof BABYLON.Size;
  75. properties: string[];
  76. format: (size: BABYLON.Size) => string;
  77. };
  78. 'Texture': {
  79. type: typeof BABYLON.Texture;
  80. properties: string[];
  81. };
  82. 'ArcRotateCamera': {
  83. properties: string[];
  84. };
  85. 'Scene': {
  86. type: typeof BABYLON.Scene;
  87. properties: string[];
  88. };
  89. 'Mesh': {
  90. type: typeof BABYLON.Mesh;
  91. properties: string[];
  92. format: (m: BABYLON.Mesh) => string;
  93. };
  94. 'StandardMaterial': {
  95. type: typeof BABYLON.StandardMaterial;
  96. properties: string[];
  97. format: (mat: BABYLON.StandardMaterial) => string;
  98. };
  99. 'PrimitiveAlignment': {
  100. type: typeof BABYLON.PrimitiveAlignment;
  101. properties: string[];
  102. };
  103. 'PrimitiveThickness': {
  104. type: typeof BABYLON.PrimitiveThickness;
  105. properties: string[];
  106. };
  107. 'BoundingInfo2D': {
  108. type: typeof BABYLON.BoundingInfo2D;
  109. properties: string[];
  110. };
  111. 'SolidColorBrush2D': {
  112. type: typeof BABYLON.SolidColorBrush2D;
  113. properties: string[];
  114. };
  115. 'GradientColorBrush2D': {
  116. type: typeof BABYLON.GradientColorBrush2D;
  117. properties: string[];
  118. };
  119. 'PBRMaterial': {
  120. type: typeof BABYLON.PBRMaterial;
  121. properties: string[];
  122. };
  123. };
  124. }
  125. declare module INSPECTOR {
  126. /**
  127. * Represents a html div element.
  128. * The div is built when an instance of BasicElement is created.
  129. */
  130. abstract class BasicElement {
  131. protected _div: HTMLElement;
  132. constructor();
  133. /**
  134. * Returns the div element
  135. */
  136. toHtml(): HTMLElement;
  137. /**
  138. * Build the html element
  139. */
  140. protected _build(): void;
  141. abstract update(data?: any): any;
  142. /** Default dispose method if needed */
  143. dispose(): void;
  144. }
  145. }
  146. declare module INSPECTOR {
  147. interface IHighlight {
  148. highlight: (b: boolean) => void;
  149. }
  150. abstract class Adapter implements IHighlight {
  151. protected _obj: any;
  152. private static _name;
  153. constructor(obj: any);
  154. /** Returns the name displayed in the tree */
  155. abstract id(): string;
  156. /** Returns the type of this object - displayed in the tree */
  157. abstract type(): string;
  158. /** Returns the list of properties to be displayed for this adapter */
  159. abstract getProperties(): Array<PropertyLine>;
  160. /** Returns the actual object behind this adapter */
  161. actualObject: any;
  162. /** Returns true if the given object correspond to this */
  163. correspondsTo(obj: any): boolean;
  164. /** Returns the adapter unique name */
  165. name: string;
  166. /** Returns the list of tools available for this adapter */
  167. abstract getTools(): Array<AbstractTreeTool>;
  168. /** Should be overriden in subclasses */
  169. highlight(b: boolean): void;
  170. }
  171. }
  172. declare module INSPECTOR {
  173. class Canvas2DAdapter extends Adapter implements IToolVisible, IToolDebug {
  174. constructor(obj: any);
  175. /** Returns the name displayed in the tree */
  176. id(): string;
  177. /** Returns the type of this object - displayed in the tree */
  178. type(): string;
  179. /** Returns the list of properties to be displayed for this adapter */
  180. getProperties(): Array<PropertyLine>;
  181. getTools(): Array<AbstractTreeTool>;
  182. setVisible(b: boolean): void;
  183. isVisible(): boolean;
  184. /** Overrides super */
  185. debug(b: boolean): void;
  186. /** Overrides super.highlight */
  187. highlight(b: boolean): void;
  188. }
  189. }
  190. declare module INSPECTOR {
  191. class LightAdapter extends Adapter implements IToolVisible {
  192. private static _PROPERTIES;
  193. constructor(obj: BABYLON.Light);
  194. /** Returns the name displayed in the tree */
  195. id(): string;
  196. /** Returns the type of this object - displayed in the tree */
  197. type(): string;
  198. /** Returns the list of properties to be displayed for this adapter */
  199. getProperties(): Array<PropertyLine>;
  200. getTools(): Array<AbstractTreeTool>;
  201. setVisible(b: boolean): void;
  202. isVisible(): boolean;
  203. /** Returns some information about this mesh */
  204. /** Overrides super.highlight */
  205. highlight(b: boolean): void;
  206. }
  207. }
  208. declare module INSPECTOR {
  209. class MaterialAdapter extends Adapter {
  210. constructor(obj: BABYLON.Material);
  211. /** Returns the name displayed in the tree */
  212. id(): string;
  213. /** Returns the type of this object - displayed in the tree */
  214. type(): string;
  215. /** Returns the list of properties to be displayed for this adapter */
  216. getProperties(): Array<PropertyLine>;
  217. /** No tools for a material adapter */
  218. getTools(): Array<AbstractTreeTool>;
  219. /** Overrides super.highlight.
  220. * Highlighting a material outlines all meshes linked to this material
  221. */
  222. highlight(b: boolean): void;
  223. }
  224. }
  225. declare module INSPECTOR {
  226. class MeshAdapter extends Adapter implements IToolVisible, IToolDebug, IToolBoundingBox, IToolInfo {
  227. /** Keep track of the axis of the actual object */
  228. private _axis;
  229. constructor(obj: BABYLON.AbstractMesh);
  230. /** Returns the name displayed in the tree */
  231. id(): string;
  232. /** Returns the type of this object - displayed in the tree */
  233. type(): string;
  234. /** Returns the list of properties to be displayed for this adapter */
  235. getProperties(): Array<PropertyLine>;
  236. getTools(): Array<AbstractTreeTool>;
  237. setVisible(b: boolean): void;
  238. isVisible(): boolean;
  239. isBoxVisible(): boolean;
  240. setBoxVisible(b: boolean): boolean;
  241. debug(b: boolean): void;
  242. /** Returns some information about this mesh */
  243. getInfo(): string;
  244. /** Overrides super.highlight */
  245. highlight(b: boolean): void;
  246. /** Draw X, Y and Z axis for the actual object if this adapter.
  247. * Should be called only one time as it will fill this._axis
  248. */
  249. private _drawAxis();
  250. }
  251. }
  252. declare module INSPECTOR {
  253. interface SortDirection {
  254. [property: string]: number;
  255. }
  256. class DetailPanel extends BasicElement {
  257. private _headerRow;
  258. private _detailRows;
  259. private _sortDirection;
  260. constructor(dr?: Array<PropertyLine>);
  261. details: Array<PropertyLine>;
  262. protected _build(): void;
  263. /** Updates the HTML of the detail panel */
  264. update(): void;
  265. /** Add all lines in the html div. Does not sort them! */
  266. private _addDetails();
  267. /**
  268. * Sort the details row by comparing the given property of each row
  269. */
  270. private _sortDetails(property, _direction?);
  271. /**
  272. * Removes all data in the detail panel but keep the header row
  273. */
  274. clean(): void;
  275. /** Overrides basicelement.dispose */
  276. dispose(): void;
  277. /**
  278. * Creates the header row : name, value, id
  279. */
  280. private _createHeaderRow();
  281. }
  282. }
  283. declare module INSPECTOR {
  284. /**
  285. * A property is a link between a data (string) and an object.
  286. */
  287. class Property {
  288. /** The property name */
  289. private _property;
  290. /** The obj this property refers to */
  291. private _obj;
  292. constructor(prop: string, obj: any);
  293. name: string;
  294. value: any;
  295. type: string;
  296. obj: any;
  297. }
  298. }
  299. declare module INSPECTOR {
  300. class PropertyFormatter {
  301. /**
  302. * Format the value of the given property of the given object.
  303. */
  304. static format(obj: any, prop: string): string;
  305. }
  306. /**
  307. * A property line represents a line in the detail panel. This line is composed of :
  308. * - a name (the property name)
  309. * - a value if this property is of a type 'simple' : string, number, boolean, color, texture
  310. * - the type of the value if this property is of a complex type (Vector2, Size, ...)
  311. * - a ID if defined (otherwise an empty string is displayed)
  312. * The original object is sent to the value object who will update it at will.
  313. *
  314. * A property line can contain OTHER property line objects in the case of a complex type.
  315. * If this instance has no link to other instances, its type is ALWAYS a simple one (see above).
  316. *
  317. */
  318. class PropertyLine {
  319. private _property;
  320. private _div;
  321. private _valueDiv;
  322. private _children;
  323. private static _SIMPLE_TYPE;
  324. private static _MARGIN_LEFT;
  325. private _level;
  326. /** The list of viewer element displayed at the end of the line (color, texture...) */
  327. private _elements;
  328. /** The property parent of this one. Used to update the value of this property and to retrieve the correct object */
  329. private _parent;
  330. /** The input element to display if this property is 'simple' in order to update it */
  331. private _input;
  332. /** Display input handler (stored to be removed afterwards) */
  333. private _displayInputHandler;
  334. /** Handler used to validate the input by pressing 'enter' */
  335. private _validateInputHandler;
  336. constructor(prop: Property, parent?: PropertyLine, level?: number);
  337. /**
  338. * Init the input element and al its handler :
  339. * - a click in the window remove the input and restore the old property value
  340. * - enters updates the property
  341. */
  342. private _initInput();
  343. /**
  344. * On enter : validates the new value and removes the input
  345. * On escape : removes the input
  346. */
  347. private _validateInput(e);
  348. /** Removes the input without validating the new value */
  349. private _removeInputWithoutValidating();
  350. /** Replaces the default display with an input */
  351. private _displayInput(e);
  352. /** Retrieve the correct object from its parent.
  353. * If no parent exists, returns the property value.
  354. * This method is used at each update in case the property object is removed from the original object
  355. * (example : mesh.position = new BABYLON.Vector3 ; the original vector3 object is deleted from the mesh).
  356. */
  357. updateObject(): any;
  358. name: string;
  359. value: any;
  360. type: string;
  361. /**
  362. * Creates elements that wil be displayed on a property line, depending on the
  363. * type of the property.
  364. */
  365. private _createElements();
  366. private _displayValueContent();
  367. /** Delete properly this property line.
  368. * Removes itself from the scheduler.
  369. * Dispose all viewer element (color, texture...)
  370. */
  371. dispose(): void;
  372. /** Updates the content of _valueDiv with the value of the property,
  373. * and all HTML element correpsonding to this type.
  374. * Elements are updated as well
  375. */
  376. private _updateValue();
  377. /**
  378. * Update the property division with the new property value.
  379. * If this property is complex, update its child, otherwise update its text content
  380. */
  381. update(): void;
  382. /**
  383. * Returns true if the given instance is a simple type
  384. */
  385. private static _IS_TYPE_SIMPLE(inst);
  386. /**
  387. * Returns true if the type of this property is simple, false otherwise.
  388. * Returns true if the value is null
  389. */
  390. private _isSimple();
  391. toHtml(): HTMLElement;
  392. /**
  393. * Add sub properties in case of a complex type
  394. */
  395. private _addDetails();
  396. }
  397. }
  398. declare module INSPECTOR {
  399. /**
  400. * Display a very small div corresponding to the given color
  401. */
  402. class ColorElement extends BasicElement {
  403. constructor(color: BABYLON.Color4 | BABYLON.Color3);
  404. update(color?: BABYLON.Color4 | BABYLON.Color3): void;
  405. private _toRgba(color);
  406. }
  407. }
  408. declare module INSPECTOR {
  409. /**
  410. * Display a very small div. A new canvas is created, with a new Babylon.js scene, containing only the
  411. * cube texture in a cube
  412. */
  413. class CubeTextureElement extends BasicElement {
  414. /** The big div displaying the full image */
  415. private _textureDiv;
  416. private _engine;
  417. protected _scene: BABYLON.Scene;
  418. protected _cube: BABYLON.Mesh;
  419. private _canvas;
  420. protected _textureUrl: string;
  421. private _pause;
  422. /** The texture given as a parameter should be cube. */
  423. constructor(tex: BABYLON.Texture);
  424. update(tex?: BABYLON.Texture): void;
  425. /** Creates the box */
  426. protected _populateScene(): void;
  427. /** Init the babylon engine */
  428. private _initEngine();
  429. private _showViewer(mode);
  430. /** Removes properly the babylon engine */
  431. dispose(): void;
  432. }
  433. }
  434. declare module INSPECTOR {
  435. /**
  436. * Display a very small div. A new canvas is created, with a new Babylon.js scene, containing only the
  437. * cube texture in a cube
  438. */
  439. class HDRCubeTextureElement extends CubeTextureElement {
  440. /** The texture given as a parameter should be cube. */
  441. constructor(tex: BABYLON.Texture);
  442. /** Creates the box */
  443. protected _populateScene(): void;
  444. }
  445. }
  446. declare module INSPECTOR {
  447. /**
  448. * A search bar can be used to filter elements in the tree panel.
  449. * At each keypress on the input, the treepanel will be filtered.
  450. */
  451. class SearchBar extends BasicElement {
  452. private _tab;
  453. private _inputElement;
  454. constructor(tab: PropertyTab);
  455. /** Delete all characters typped in the input element */
  456. reset(): void;
  457. update(): void;
  458. }
  459. }
  460. declare module INSPECTOR {
  461. /**
  462. * Display a very small div corresponding to the given texture. On mouse over, display the full image
  463. */
  464. class TextureElement extends BasicElement {
  465. /** The big div displaying the full image */
  466. private _textureDiv;
  467. constructor(tex: BABYLON.Texture);
  468. update(tex?: BABYLON.Texture): void;
  469. private _showViewer(mode);
  470. }
  471. }
  472. declare module INSPECTOR {
  473. /**
  474. * Creates a tooltip for the parent of the given html element
  475. */
  476. class Tooltip {
  477. /** The tooltip is displayed for this element */
  478. private _elem;
  479. /** The tooltip div */
  480. private _infoDiv;
  481. constructor(elem: HTMLElement, tip: string);
  482. }
  483. }
  484. declare module INSPECTOR {
  485. class Helpers {
  486. /**
  487. * Returns the type of the given object. First
  488. * uses getClassName. If nothing is returned, used the type of the constructor
  489. */
  490. static GET_TYPE(obj: any): string;
  491. /**
  492. * Check if some properties are defined for the given type.
  493. */
  494. private static _CheckIfTypeExists(type);
  495. /**
  496. * Returns the name of the type of the given object, where the name
  497. * is in PROPERTIES constant.
  498. * Returns 'Undefined' if no type exists for this object
  499. */
  500. private static _GetTypeFor(obj);
  501. /**
  502. * Returns the name of a function (workaround to get object type for IE11)
  503. */
  504. private static _GetFnName(fn);
  505. /** Send the event which name is given in parameter to the window */
  506. static SEND_EVENT(eventName: string): void;
  507. /** Returns the given number with 2 decimal number max if a decimal part exists */
  508. static Trunc(nb: any): number;
  509. /**
  510. * Useful function used to create a div
  511. */
  512. static CreateDiv(className?: string, parent?: HTMLElement): HTMLElement;
  513. static CreateElement(element: string, className?: string, parent?: HTMLElement): HTMLElement;
  514. /**
  515. * Removes all children of the given div.
  516. */
  517. static CleanDiv(div: HTMLElement): void;
  518. static LoadScript(): void;
  519. }
  520. }
  521. declare module INSPECTOR {
  522. class Scheduler {
  523. private static _instance;
  524. /** The number of the set interval */
  525. private _timer;
  526. /** Is this scheduler in pause ? */
  527. pause: boolean;
  528. /** All properties are refreshed every 250ms */
  529. static REFRESH_TIME: number;
  530. /** The list of data to update */
  531. private _updatableProperties;
  532. constructor();
  533. static getInstance(): Scheduler;
  534. /** Add a property line to be updated every X ms */
  535. add(prop: PropertyLine): void;
  536. /** Removes the given property from the list of properties to update */
  537. remove(prop: PropertyLine): void;
  538. private _update();
  539. }
  540. }
  541. declare module INSPECTOR {
  542. abstract class Tab extends BasicElement {
  543. protected _tabbar: TabBar;
  544. name: string;
  545. protected _isActive: boolean;
  546. protected _panel: HTMLDivElement;
  547. constructor(tabbar: TabBar, name: string);
  548. /** True if the tab is active, false otherwise */
  549. isActive(): boolean;
  550. protected _build(): void;
  551. /** Set this tab as active or not, depending on the current state */
  552. active(b: boolean): void;
  553. update(): void;
  554. /** Creates the tab panel for this tab. */
  555. getPanel(): HTMLElement;
  556. /** Add this in the propertytab with the searchbar */
  557. filter(str: string): void;
  558. /** Dispose properly this tab */
  559. abstract dispose(): any;
  560. /**
  561. * Returns the total width in pixel of this tab, 0 by default
  562. */
  563. getPixelWidth(): number;
  564. }
  565. }
  566. declare module INSPECTOR {
  567. /**
  568. * A Property tab can creates two panels:
  569. * a tree panel and a detail panel,
  570. * in which properties will be displayed.
  571. * Both panels are separated by a resize bar
  572. */
  573. abstract class PropertyTab extends Tab {
  574. protected _inspector: Inspector;
  575. /** The panel containing a list of items */
  576. protected _treePanel: HTMLElement;
  577. /** The panel containing a list if properties corresponding to an item */
  578. protected _detailsPanel: DetailPanel;
  579. protected _treeItems: Array<TreeItem>;
  580. protected _searchBar: SearchBar;
  581. constructor(tabbar: TabBar, name: string, insp: Inspector);
  582. /** Overrides dispose */
  583. dispose(): void;
  584. update(_items?: Array<TreeItem>): void;
  585. /** Display the details of the given item */
  586. displayDetails(item: TreeItem): void;
  587. /** Select an item in the tree */
  588. select(item: TreeItem): void;
  589. /** Highlight the given node, and downplay all others */
  590. highlightNode(item?: TreeItem): void;
  591. /** Set the given item as active in the tree */
  592. activateNode(item: TreeItem): void;
  593. /** Returns the treeitem corersponding to the given obj, null if not found */
  594. getItemFor(_obj: any): TreeItem;
  595. filter(filter: string): void;
  596. /** Builds the tree panel */
  597. protected abstract _getTree(): Array<TreeItem>;
  598. }
  599. }
  600. declare module INSPECTOR {
  601. class Canvas2DTab extends PropertyTab {
  602. constructor(tabbar: TabBar, inspector: Inspector);
  603. protected _getTree(): Array<TreeItem>;
  604. }
  605. }
  606. declare module INSPECTOR {
  607. class LightTab extends PropertyTab {
  608. constructor(tabbar: TabBar, inspector: Inspector);
  609. protected _getTree(): Array<TreeItem>;
  610. }
  611. }
  612. declare module INSPECTOR {
  613. class MaterialTab extends PropertyTab {
  614. constructor(tabbar: TabBar, inspector: Inspector);
  615. protected _getTree(): Array<TreeItem>;
  616. }
  617. }
  618. declare module INSPECTOR {
  619. class MeshTab extends PropertyTab {
  620. constructor(tabbar: TabBar, inspector: Inspector);
  621. protected _getTree(): Array<TreeItem>;
  622. }
  623. }
  624. declare module INSPECTOR {
  625. class SceneTab extends Tab {
  626. private _inspector;
  627. /** The list of channels/options that can be activated/deactivated */
  628. private _actions;
  629. /** The list of skeleton viewer */
  630. private _skeletonViewers;
  631. /** The detail of the scene */
  632. private _detailsPanel;
  633. constructor(tabbar: TabBar, insp: Inspector);
  634. /** Overrides super.dispose */
  635. dispose(): void;
  636. /** generates a div which correspond to an option that can be activated/deactivated */
  637. private _generateActionLine(name, initValue, action);
  638. /**
  639. * Add a click action for all given elements :
  640. * the clicked element is set as active, all others elements are deactivated
  641. */
  642. private _generateRadioAction(arr);
  643. }
  644. }
  645. declare module INSPECTOR {
  646. class ShaderTab extends Tab {
  647. private _inspector;
  648. private _vertexPanel;
  649. private _fragmentPanel;
  650. constructor(tabbar: TabBar, insp: Inspector);
  651. private _selectShader(event);
  652. /** Overrides super.dispose */
  653. dispose(): void;
  654. /** Returns the position of the first { and the corresponding } */
  655. private _getBracket(str);
  656. /**
  657. * Beautify the given string : correct indentation
  658. */
  659. private _beautify(glsl, level?);
  660. }
  661. }
  662. declare module INSPECTOR {
  663. class StatsTab extends Tab {
  664. private _inspector;
  665. /**
  666. * Properties in this array will be updated
  667. * in a render loop - Mostly stats properties
  668. */
  669. private _updatableProperties;
  670. private _scene;
  671. private _engine;
  672. private _glInfo;
  673. private _updateLoopHandler;
  674. constructor(tabbar: TabBar, insp: Inspector);
  675. private _createStatLabel(content, parent);
  676. /** Update each properties of the stats panel */
  677. private _update();
  678. dispose(): void;
  679. }
  680. }
  681. declare module INSPECTOR {
  682. /**
  683. * A tab bar will contains each view the inspector can have : Canvas2D, Meshes...
  684. * The default active tab is the first one of the list.
  685. */
  686. class TabBar extends BasicElement {
  687. private _tabs;
  688. private _inspector;
  689. /** The tab displaying all meshes */
  690. private _meshTab;
  691. /** The toolbar */
  692. private _toolBar;
  693. /** The icon displayed at the end of the toolbar displaying a combo box of tabs not displayed */
  694. private _moreTabsIcon;
  695. /** The panel displayed when the 'more-tab' icon is selected */
  696. private _moreTabsPanel;
  697. /** The list of tab displayed by clicking on the remainingIcon */
  698. private _invisibleTabs;
  699. /** The list of tabs visible, displayed in the tab bar */
  700. private _visibleTabs;
  701. constructor(inspector: Inspector);
  702. update(): void;
  703. protected _build(): void;
  704. /**
  705. * Add a tab to the 'more-tabs' panel, displayed by clicking on the
  706. * 'more-tabs' icon
  707. */
  708. private _addInvisibleTabToPanel(tab);
  709. /** Dispose the current tab, set the given tab as active, and refresh the treeview */
  710. switchTab(tab: Tab): void;
  711. /** Display the mesh tab.
  712. * If a parameter is given, the given mesh details are displayed
  713. */
  714. switchMeshTab(mesh?: BABYLON.AbstractMesh): void;
  715. /** Returns the active tab */
  716. getActiveTab(): Tab;
  717. inspector: Inspector;
  718. /**
  719. * Returns the total width in pixel of the tabbar,
  720. * that corresponds to the sum of the width of each visible tab + toolbar width
  721. */
  722. getPixelWidth(): number;
  723. /** Display the remaining icon or not depending on the tabbar width.
  724. * This function should be called each time the inspector width is updated
  725. */
  726. updateWidth(): void;
  727. }
  728. }
  729. declare module INSPECTOR {
  730. abstract class AbstractTool {
  731. private _elem;
  732. protected _inspector: Inspector;
  733. constructor(icon: string, parent: HTMLElement, inspector: Inspector, tooltip: string);
  734. toHtml(): HTMLElement;
  735. /**
  736. * Returns the total width in pixel of this tool, 0 by default
  737. */
  738. getPixelWidth(): number;
  739. /**
  740. * Updates the icon of this tool with the given string
  741. */
  742. protected _updateIcon(icon: string): void;
  743. abstract action(): any;
  744. }
  745. }
  746. declare module INSPECTOR {
  747. class PauseScheduleTool extends AbstractTool {
  748. private _isPause;
  749. constructor(parent: HTMLElement, inspector: Inspector);
  750. action(): void;
  751. }
  752. }
  753. declare module INSPECTOR {
  754. class PickTool extends AbstractTool {
  755. private _isActive;
  756. private _pickHandler;
  757. constructor(parent: HTMLElement, inspector: Inspector);
  758. action(): void;
  759. /** Deactivate this tool */
  760. private _deactivate();
  761. /** Pick a mesh in the scene */
  762. private _pickMesh(evt);
  763. private _updatePointerPosition(evt);
  764. }
  765. }
  766. declare module INSPECTOR {
  767. class PopupTool extends AbstractTool {
  768. constructor(parent: HTMLElement, inspector: Inspector);
  769. action(): void;
  770. }
  771. }
  772. declare module INSPECTOR {
  773. class RefreshTool extends AbstractTool {
  774. constructor(parent: HTMLElement, inspector: Inspector);
  775. action(): void;
  776. }
  777. }
  778. declare module INSPECTOR {
  779. class Toolbar extends BasicElement {
  780. private _inspector;
  781. private _tools;
  782. constructor(inspector: Inspector);
  783. update(): void;
  784. protected _build(): void;
  785. private _addTools();
  786. /**
  787. * Returns the total width in pixel of the tabbar,
  788. * that corresponds to the sum of the width of each tab + toolbar width
  789. */
  790. getPixelWidth(): number;
  791. }
  792. }
  793. declare module INSPECTOR {
  794. /**
  795. * Removes the inspector panel
  796. */
  797. class DisposeTool extends AbstractTool {
  798. constructor(parent: HTMLElement, inspector: Inspector);
  799. action(): void;
  800. }
  801. }
  802. declare module INSPECTOR {
  803. class TreeItem extends BasicElement {
  804. private _tab;
  805. private _adapter;
  806. private _tools;
  807. private _children;
  808. private _lineContent;
  809. constructor(tab: PropertyTab, obj: Adapter);
  810. /** Returns the item ID == its adapter ID */
  811. id: string;
  812. /** Add the given item as a child of this one */
  813. add(child: TreeItem): void;
  814. /**
  815. * Function used to compare this item to another tree item.
  816. * Returns the alphabetical sort of the adapter ID
  817. */
  818. compareTo(item: TreeItem): number;
  819. /** Returns true if the given obj correspond to the adapter linked to this tree item */
  820. correspondsTo(obj: any): boolean;
  821. /** hide all children of this item */
  822. fold(): void;
  823. /** Show all children of this item */
  824. unfold(): void;
  825. /** Build the HTML of this item */
  826. protected _build(): void;
  827. /**
  828. * Returns one HTML element (.details) containing all details of this primitive
  829. */
  830. getDetails(): Array<PropertyLine>;
  831. update(): void;
  832. /**
  833. * Add an event listener on the item :
  834. * - one click display details
  835. * - on mouse hover the item is highlighted
  836. */
  837. protected _addEvent(): void;
  838. /** Highlight or downplay this node */
  839. highlight(b: boolean): void;
  840. /** Returns true if the node is folded, false otherwise */
  841. private _isFolded();
  842. /** Set this item as active (background lighter) in the tree panel */
  843. active(b: boolean): void;
  844. }
  845. }
  846. declare module INSPECTOR {
  847. abstract class AbstractTreeTool {
  848. protected _elem: HTMLElement;
  849. /** Is the tool enabled ? */
  850. protected _on: boolean;
  851. constructor();
  852. toHtml(): HTMLElement;
  853. protected _addEvents(): void;
  854. /**
  855. * Action launched when clicked on this element
  856. * Should be overrided
  857. */
  858. protected action(): void;
  859. }
  860. }
  861. declare module INSPECTOR {
  862. /** Any object implementing this interface should
  863. * provide methods to toggle its bounding box
  864. */
  865. interface IToolBoundingBox {
  866. isBoxVisible: () => boolean;
  867. setBoxVisible: (b: boolean) => void;
  868. }
  869. /**
  870. * Checkbox to display/hide the primitive
  871. */
  872. class BoundingBox extends AbstractTreeTool {
  873. private _obj;
  874. constructor(obj: IToolBoundingBox);
  875. protected action(): void;
  876. private _check();
  877. }
  878. }
  879. declare module INSPECTOR {
  880. /** Any object implementing this interface should
  881. * provide methods to toggle its visibility
  882. */
  883. interface IToolVisible {
  884. isVisible: () => boolean;
  885. setVisible: (b: boolean) => void;
  886. }
  887. /**
  888. * Checkbox to display/hide the primitive
  889. */
  890. class Checkbox extends AbstractTreeTool {
  891. private _obj;
  892. constructor(obj: IToolVisible);
  893. protected action(): void;
  894. private _check(dontEnable?);
  895. }
  896. }
  897. declare module INSPECTOR {
  898. /** Any object implementing this interface should
  899. * provide methods to toggle a debug area
  900. */
  901. interface IToolDebug {
  902. debug: (b: boolean) => void;
  903. }
  904. class DebugArea extends AbstractTreeTool {
  905. private _obj;
  906. constructor(obj: IToolDebug);
  907. protected action(): void;
  908. }
  909. }
  910. declare module INSPECTOR {
  911. /** Any object implementing this interface should
  912. * provide methods to retrieve its info
  913. */
  914. interface IToolInfo {
  915. getInfo: () => string;
  916. }
  917. /**
  918. * Checkbox to display/hide the primitive
  919. */
  920. class Info extends AbstractTreeTool {
  921. private _obj;
  922. private _tooltip;
  923. constructor(obj: IToolInfo);
  924. protected action(): void;
  925. }
  926. }