babylon.inspector.d.ts 39 KB

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