babylon.inspector.d.ts 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980
  1. /*BabylonJS Inspector*/
  2. // Dependencies for this module:
  3. // ../../../../Tools/Gulp/babylonjs
  4. declare module INSPECTOR {
  5. }
  6. declare module INSPECTOR {
  7. }
  8. declare module INSPECTOR {
  9. }
  10. declare module INSPECTOR {
  11. }
  12. declare module INSPECTOR {
  13. }
  14. declare module INSPECTOR {
  15. }
  16. declare module INSPECTOR {
  17. }
  18. declare module INSPECTOR {
  19. export class Tools {
  20. static LookForItem(item: any, selectedEntity: any): boolean;
  21. static SortAndFilter(items: any[]): any[];
  22. }
  23. }
  24. declare module INSPECTOR {
  25. }
  26. declare module INSPECTOR {
  27. }
  28. declare module INSPECTOR {
  29. export class Inspector {
  30. /** The HTML document relative to this inspector (the window or the popup depending on its mode) */
  31. static DOCUMENT: HTMLDocument;
  32. /** The HTML window. In popup mode, it's the popup itself. Otherwise, it's the current tab */
  33. static WINDOW: Window;
  34. onGUILoaded: BABYLON.Observable<any>;
  35. static GUIObject: any;
  36. /** The inspector is created with the given engine.
  37. * If the parameter 'popup' is false, the inspector is created as a right panel on the main window.
  38. * If the parameter 'popup' is true, the inspector is created in another popup.
  39. */
  40. constructor(scene: BABYLON.Scene, popup?: boolean, initialTab?: number | string, parentElement?: BABYLON.Nullable<HTMLElement>, newColors?: {
  41. backgroundColor?: string;
  42. backgroundColorLighter?: string;
  43. backgroundColorLighter2?: string;
  44. backgroundColorLighter3?: string;
  45. color?: string;
  46. colorTop?: string;
  47. colorBot?: string;
  48. });
  49. readonly scene: BABYLON.Scene;
  50. readonly popupMode: boolean;
  51. /**
  52. * Filter the list of item present in the tree.
  53. * All item returned should have the given filter contained in the item id.
  54. */
  55. filterItem(filter: string): void;
  56. /** Display the mesh tab on the given object */
  57. displayObjectDetails(mesh: BABYLON.AbstractMesh): void;
  58. /** Clean the whole tree of item and rebuilds it */
  59. refresh(): void;
  60. /** Remove the inspector panel when it's built as a right panel:
  61. * remove the right panel and remove the wrapper
  62. */
  63. dispose(): void;
  64. /** Open the inspector in a new popup
  65. * Set 'firstTime' to true if there is no inspector created beforehands
  66. */
  67. openPopup(firstTime?: boolean): void;
  68. getActiveTabIndex(): number;
  69. }
  70. }
  71. declare module INSPECTOR {
  72. export const PROPERTIES: {
  73. /** Format the given object :
  74. * If a format function exists, returns the result of this function.
  75. * If this function doesn't exists, return the object type instead
  76. */
  77. format: (obj: any) => any;
  78. 'type_not_defined': {
  79. properties: any[];
  80. format: () => string;
  81. };
  82. 'Vector2': {
  83. type: typeof BABYLON.Vector2;
  84. format: (vec: BABYLON.Vector2) => string;
  85. };
  86. 'Vector3': {
  87. type: typeof BABYLON.Vector3;
  88. format: (vec: BABYLON.Vector3) => string;
  89. };
  90. 'Color3': {
  91. type: typeof BABYLON.Color3;
  92. format: (color: BABYLON.Color3) => string;
  93. slider: {
  94. r: {
  95. min: number;
  96. max: number;
  97. step: number;
  98. };
  99. g: {
  100. min: number;
  101. max: number;
  102. step: number;
  103. };
  104. b: {
  105. min: number;
  106. max: number;
  107. step: number;
  108. };
  109. };
  110. };
  111. 'Color4': {
  112. type: typeof BABYLON.Color4;
  113. format: (color: BABYLON.Color4) => string;
  114. slider: {
  115. r: {
  116. min: number;
  117. max: number;
  118. step: number;
  119. };
  120. g: {
  121. min: number;
  122. max: number;
  123. step: number;
  124. };
  125. b: {
  126. min: number;
  127. max: number;
  128. step: number;
  129. };
  130. };
  131. };
  132. 'Quaternion': {
  133. type: typeof BABYLON.Quaternion;
  134. };
  135. 'Size': {
  136. type: typeof BABYLON.Size;
  137. format: (size: BABYLON.Size) => string;
  138. };
  139. 'Texture': {
  140. type: typeof BABYLON.Texture;
  141. format: (tex: BABYLON.Texture) => string;
  142. };
  143. 'RenderTargetTexture': {
  144. type: typeof BABYLON.RenderTargetTexture;
  145. };
  146. 'DynamicTexture': {
  147. type: typeof BABYLON.DynamicTexture;
  148. };
  149. 'BaseTexture': {
  150. type: typeof BABYLON.BaseTexture;
  151. };
  152. 'CubeTexture': {
  153. type: typeof BABYLON.CubeTexture;
  154. };
  155. 'HDRCubeTexture': {
  156. type: typeof BABYLON.HDRCubeTexture;
  157. };
  158. 'Sound': {
  159. type: typeof BABYLON.Sound;
  160. };
  161. 'ArcRotateCamera': {
  162. type: typeof BABYLON.ArcRotateCamera;
  163. slider: {
  164. alpha: {
  165. min: number;
  166. max: number;
  167. step: number;
  168. };
  169. beta: {
  170. min: number;
  171. max: number;
  172. step: number;
  173. };
  174. fov: {
  175. min: number;
  176. max: number;
  177. step: number;
  178. };
  179. };
  180. };
  181. 'FreeCamera': {
  182. type: typeof BABYLON.FreeCamera;
  183. slider: {
  184. fov: {
  185. min: number;
  186. max: number;
  187. step: number;
  188. };
  189. };
  190. };
  191. 'Scene': {
  192. type: typeof BABYLON.Scene;
  193. };
  194. 'TransformNode': {
  195. type: typeof BABYLON.TransformNode;
  196. format: (m: BABYLON.TransformNode) => string;
  197. };
  198. 'AbstractMesh': {
  199. type: typeof BABYLON.AbstractMesh;
  200. format: (m: BABYLON.AbstractMesh) => string;
  201. };
  202. 'Mesh': {
  203. type: typeof BABYLON.Mesh;
  204. format: (m: BABYLON.Mesh) => string;
  205. slider: {
  206. visibility: {
  207. min: number;
  208. max: number;
  209. step: number;
  210. };
  211. };
  212. };
  213. 'StandardMaterial': {
  214. type: typeof BABYLON.StandardMaterial;
  215. format: (mat: BABYLON.StandardMaterial) => string;
  216. slider: {
  217. alpha: {
  218. min: number;
  219. max: number;
  220. step: number;
  221. };
  222. };
  223. };
  224. 'PBRMaterial': {
  225. type: typeof BABYLON.PBRMaterial;
  226. slider: {
  227. alpha: {
  228. min: number;
  229. max: number;
  230. step: number;
  231. };
  232. };
  233. };
  234. 'PhysicsImpostor': {
  235. type: typeof BABYLON.PhysicsImpostor;
  236. };
  237. 'ImageProcessingConfiguration': {
  238. type: typeof BABYLON.ImageProcessingConfiguration;
  239. };
  240. 'ColorCurves': {
  241. type: typeof BABYLON.ColorCurves;
  242. };
  243. };
  244. }
  245. declare module INSPECTOR {
  246. export type GUITyping = any;
  247. export let guiLoaded: boolean;
  248. /**
  249. * Function that add gui objects properties to the variable PROPERTIES
  250. */
  251. export function loadGUIProperties(GUI: GUITyping): void;
  252. }
  253. declare module INSPECTOR {
  254. export abstract class Adapter {
  255. protected _obj: any;
  256. constructor(obj: any);
  257. /** Returns the name displayed in the tree */
  258. abstract id(): string;
  259. /** Returns the type of this object - displayed in the tree */
  260. abstract type(): string;
  261. /** Returns the list of properties to be displayed for this adapter */
  262. abstract getProperties(): Array<PropertyLine>;
  263. /** Returns true if the given object correspond to this */
  264. correspondsTo(obj: any): boolean;
  265. /** Returns the adapter unique name */
  266. readonly name: string;
  267. /**
  268. * Returns the actual object used for this adapter
  269. */
  270. readonly object: any;
  271. /** Returns the list of tools available for this adapter */
  272. abstract getTools(): Array<AbstractTreeTool>;
  273. }
  274. }
  275. declare module INSPECTOR {
  276. export class CameraAdapter extends Adapter implements ICameraPOV {
  277. constructor(obj: BABYLON.Camera);
  278. /** Returns the name displayed in the tree */
  279. id(): string;
  280. /** Returns the type of this object - displayed in the tree */
  281. type(): string;
  282. /** Returns the list of properties to be displayed for this adapter */
  283. getProperties(): Array<PropertyLine>;
  284. getTools(): Array<AbstractTreeTool>;
  285. setPOV(): void;
  286. getCurrentActiveCamera(): string;
  287. }
  288. }
  289. declare module INSPECTOR {
  290. export class GUIAdapter extends Adapter implements IToolVisible {
  291. constructor(obj: any);
  292. /** Returns the name displayed in the tree */
  293. id(): string;
  294. /** Returns the type of this object - displayed in the tree */
  295. type(): string;
  296. /** Returns the list of properties to be displayed for this adapter */
  297. getProperties(): Array<PropertyLine>;
  298. getTools(): Array<AbstractTreeTool>;
  299. setVisible(b: boolean): void;
  300. isVisible(): boolean;
  301. }
  302. }
  303. declare module INSPECTOR {
  304. export class LightAdapter extends Adapter implements IToolVisible {
  305. constructor(obj: BABYLON.Light);
  306. /** Returns the name displayed in the tree */
  307. id(): string;
  308. /** Returns the type of this object - displayed in the tree */
  309. type(): string;
  310. /** Returns the list of properties to be displayed for this adapter */
  311. getProperties(): Array<PropertyLine>;
  312. getTools(): Array<AbstractTreeTool>;
  313. setVisible(b: boolean): void;
  314. isVisible(): boolean;
  315. }
  316. }
  317. declare module INSPECTOR {
  318. export class MaterialAdapter extends Adapter {
  319. constructor(obj: BABYLON.Material);
  320. /** Returns the name displayed in the tree */
  321. id(): string;
  322. /** Returns the type of this object - displayed in the tree */
  323. type(): string;
  324. /** Returns the list of properties to be displayed for this adapter */
  325. getProperties(): Array<PropertyLine>;
  326. /** No tools for a material adapter */
  327. getTools(): Array<AbstractTreeTool>;
  328. }
  329. }
  330. declare module INSPECTOR {
  331. export class MeshAdapter extends Adapter implements IToolVisible, IToolDebug, IToolBoundingBox, IToolInfo {
  332. constructor(mesh: BABYLON.Node);
  333. /** Returns the name displayed in the tree */
  334. id(): string;
  335. /** Returns the type of this object - displayed in the tree */
  336. type(): string;
  337. /** Returns the list of properties to be displayed for this adapter */
  338. getProperties(): Array<PropertyLine>;
  339. getTools(): Array<AbstractTreeTool>;
  340. setVisible(b: boolean): void;
  341. isVisible(): boolean;
  342. isBoxVisible(): boolean;
  343. setBoxVisible(b: boolean): boolean;
  344. debug(enable: boolean): void;
  345. /** Returns some information about this mesh */
  346. getInfo(): string;
  347. }
  348. }
  349. declare module INSPECTOR {
  350. export class PhysicsImpostorAdapter extends Adapter implements IToolVisible {
  351. constructor(obj: BABYLON.PhysicsImpostor, viewer: any);
  352. /** Returns the name displayed in the tree */
  353. id(): string;
  354. /** Returns the type of this object - displayed in the tree */
  355. type(): string;
  356. /** Returns the list of properties to be displayed for this adapter */
  357. getProperties(): Array<PropertyLine>;
  358. getTools(): Array<AbstractTreeTool>;
  359. setVisible(b: boolean): void;
  360. isVisible(): boolean;
  361. }
  362. }
  363. declare module INSPECTOR {
  364. export class SoundAdapter extends Adapter implements ISoundInteractions {
  365. constructor(obj: BABYLON.Sound);
  366. /** Returns the name displayed in the tree */
  367. id(): string;
  368. /** Returns the type of this object - displayed in the tree */
  369. type(): string;
  370. /** Returns the list of properties to be displayed for this adapter */
  371. getProperties(): Array<PropertyLine>;
  372. getTools(): Array<AbstractTreeTool>;
  373. setPlaying(callback: Function): void;
  374. }
  375. }
  376. declare module INSPECTOR {
  377. export class TextureAdapter extends Adapter {
  378. constructor(obj: BABYLON.BaseTexture);
  379. /** Returns the name displayed in the tree */
  380. id(): string;
  381. /** Returns the type of this object - displayed in the tree */
  382. type(): string;
  383. /** Returns the list of properties to be displayed for this adapter */
  384. getProperties(): Array<PropertyLine>;
  385. getTools(): Array<AbstractTreeTool>;
  386. }
  387. }
  388. declare module INSPECTOR {
  389. export interface SortDirection {
  390. [property: string]: number;
  391. }
  392. export class DetailPanel extends BasicElement {
  393. constructor(dr?: Array<PropertyLine>);
  394. details: Array<PropertyLine>;
  395. protected _build(): void;
  396. /** Updates the HTML of the detail panel */
  397. update(_items?: Array<PropertyLine>): void;
  398. /** Search an element by name */
  399. searchByName(searchName: string): void;
  400. /**
  401. * Removes all data in the detail panel but keep the header row
  402. */
  403. clean(): void;
  404. /**
  405. * Clean the rows only
  406. */
  407. cleanRow(): void;
  408. /** Overrides basicelement.dispose */
  409. dispose(): void;
  410. }
  411. }
  412. declare module INSPECTOR {
  413. /**
  414. * A property is a link between a data (string) and an object.
  415. */
  416. export class Property {
  417. constructor(prop: string, obj: any, parentObj?: any);
  418. readonly name: string;
  419. value: any;
  420. readonly type: string;
  421. obj: any;
  422. }
  423. }
  424. declare module INSPECTOR {
  425. export class PropertyFormatter {
  426. /**
  427. * Format the value of the given property of the given object.
  428. */
  429. static format(obj: any, prop: string): string;
  430. }
  431. /**
  432. * A property line represents a line in the detail panel. This line is composed of :
  433. * - a name (the property name)
  434. * - a value if this property is of a type 'simple' : string, number, boolean, color, texture
  435. * - the type of the value if this property is of a complex type (Vector2, BABYLON.Size, ...)
  436. * - a ID if defined (otherwise an empty string is displayed)
  437. * The original object is sent to the value object who will update it at will.
  438. *
  439. * A property line can contain OTHER property line objects in the case of a complex type.
  440. * If this instance has no link to other instances, its type is ALWAYS a simple one (see above).
  441. *
  442. */
  443. export class PropertyLine {
  444. constructor(prop: Property, parent?: BABYLON.Nullable<PropertyLine>, level?: number);
  445. validateInput(value: any, forceupdate?: boolean): void;
  446. /** Retrieve the correct object from its parent.
  447. * If no parent exists, returns the property value.
  448. * This method is used at each update in case the property object is removed from the original object
  449. * (example : mesh.position = new BABYLON.Vector3 ; the original vector3 object is deleted from the mesh).
  450. */
  451. updateObject(): any;
  452. readonly name: string;
  453. readonly value: any;
  454. readonly type: string;
  455. /** Delete properly this property line.
  456. * Removes itself from the scheduler.
  457. * Dispose all viewer element (color, texture...)
  458. */
  459. dispose(): void;
  460. /**
  461. * Update the property division with the new property value.
  462. * If this property is complex, update its child, otherwise update its text content
  463. */
  464. update(): void;
  465. toHtml(): HTMLElement;
  466. closeDetails(): void;
  467. }
  468. }
  469. declare module INSPECTOR {
  470. /**
  471. * Represents a html div element.
  472. * The div is built when an instance of BasicElement is created.
  473. */
  474. export abstract class BasicElement {
  475. protected _div: HTMLDivElement;
  476. constructor();
  477. /**
  478. * Returns the div element
  479. */
  480. toHtml(): HTMLDivElement;
  481. /**
  482. * Build the html element
  483. */
  484. protected _build(): void;
  485. abstract update(data?: any): void;
  486. /** Default dispose method if needed */
  487. dispose(): void;
  488. }
  489. }
  490. declare module INSPECTOR {
  491. /**
  492. * Display a very small div corresponding to the given color
  493. */
  494. export class ColorElement extends BasicElement {
  495. constructor(color: BABYLON.Color4 | BABYLON.Color3);
  496. update(color?: BABYLON.Color4 | BABYLON.Color3): void;
  497. }
  498. }
  499. declare module INSPECTOR {
  500. /**
  501. * Represents a html div element.
  502. * The div is built when an instance of BasicElement is created.
  503. */
  504. export class ColorPickerElement extends BasicElement {
  505. protected _input: HTMLInputElement;
  506. constructor(color: BABYLON.Color4 | BABYLON.Color3, propertyLine: PropertyLine);
  507. update(color?: BABYLON.Color4 | BABYLON.Color3): void;
  508. }
  509. }
  510. declare module INSPECTOR {
  511. /**
  512. * Display a very small div. A new canvas is created, with a new js scene, containing only the
  513. * cube texture in a cube
  514. */
  515. export class CubeTextureElement extends BasicElement {
  516. protected _scene: BABYLON.Scene;
  517. protected _cube: BABYLON.Mesh;
  518. protected _textureUrl: string;
  519. /** The texture given as a parameter should be cube. */
  520. constructor(tex: BABYLON.Texture);
  521. update(tex?: BABYLON.Texture): void;
  522. /** Creates the box */
  523. protected _populateScene(): void;
  524. /** Removes properly the babylon engine */
  525. dispose(): void;
  526. }
  527. }
  528. declare module INSPECTOR {
  529. /**
  530. * Display a very small div. A new canvas is created, with a new js scene, containing only the
  531. * cube texture in a cube
  532. */
  533. export class HDRCubeTextureElement extends CubeTextureElement {
  534. /** The texture given as a parameter should be cube. */
  535. constructor(tex: BABYLON.Texture);
  536. /** Creates the box */
  537. protected _populateScene(): void;
  538. }
  539. }
  540. declare module INSPECTOR {
  541. /**
  542. * A search bar can be used to filter elements in the tree panel.
  543. * At each keypress on the input, the treepanel will be filtered.
  544. */
  545. export class SearchBar extends BasicElement {
  546. constructor(tab: PropertyTab);
  547. /** Delete all characters typped in the input element */
  548. reset(): void;
  549. update(): void;
  550. }
  551. export class SearchBarDetails extends BasicElement {
  552. constructor(tab: DetailPanel);
  553. /** Delete all characters typped in the input element */
  554. reset(): void;
  555. update(): void;
  556. }
  557. }
  558. declare module INSPECTOR {
  559. /**
  560. * Display a very small div corresponding to the given texture. On mouse over, display the full image
  561. */
  562. export class TextureElement extends BasicElement {
  563. constructor(tex: BABYLON.Texture);
  564. update(tex?: BABYLON.Texture): void;
  565. }
  566. }
  567. declare module INSPECTOR {
  568. /**
  569. * Creates a tooltip for the parent of the given html element
  570. */
  571. export class Tooltip {
  572. constructor(elem: HTMLElement, tip: string, attachTo?: BABYLON.Nullable<HTMLElement>);
  573. }
  574. }
  575. declare module INSPECTOR {
  576. export class Helpers {
  577. /**
  578. * Returns the type of the given object. First
  579. * uses getClassName. If nothing is returned, used the type of the constructor
  580. */
  581. static GET_TYPE(obj: any): string;
  582. /**
  583. * Returns true if the user browser is edge.
  584. */
  585. static IsBrowserEdge(): boolean;
  586. /**
  587. * Returns true if the user browser is IE.
  588. */
  589. static IsBrowserIE(): boolean;
  590. /** Send the event which name is given in parameter to the window */
  591. static SEND_EVENT(eventName: string): void;
  592. /** Returns the given number with 2 decimal number max if a decimal part exists */
  593. static Trunc(nb: number): number;
  594. /**
  595. * Useful function used to create a div
  596. */
  597. static CreateDiv(className?: BABYLON.Nullable<string>, parent?: HTMLElement, tooltip?: string): HTMLDivElement;
  598. /**
  599. * Useful function used to create a input
  600. */
  601. static CreateInput(className?: string, parent?: HTMLElement, tooltip?: string): HTMLInputElement;
  602. static CreateElement(element: string, className?: BABYLON.Nullable<string>, parent?: HTMLElement, tooltip?: string): HTMLElement;
  603. /**
  604. * Removes all children of the given div.
  605. */
  606. static CleanDiv(div: HTMLElement): void;
  607. /**
  608. * 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)
  609. */
  610. static Css(elem: HTMLElement, cssAttribute: string): string;
  611. static LoadScript(): void;
  612. static IsSystemName(name: string): boolean;
  613. /**
  614. * Return an array of PropertyLine for an obj
  615. * @param obj
  616. */
  617. static GetAllLinesProperties(obj: any): Array<PropertyLine>;
  618. /**
  619. * Returns an array of string corresponding to tjhe list of properties of the object to be displayed
  620. * @param obj
  621. */
  622. static GetAllLinesPropertiesAsString(obj: any, dontTakeThis?: Array<string>): Array<string>;
  623. static Capitalize(str: string): string;
  624. }
  625. }
  626. declare module INSPECTOR {
  627. export class Scheduler {
  628. /** Is this scheduler in pause ? */
  629. pause: boolean;
  630. /** All properties are refreshed every 250ms */
  631. static REFRESH_TIME: number;
  632. constructor();
  633. static getInstance(): Scheduler;
  634. /** Add a property line to be updated every X ms */
  635. add(prop: PropertyLine): void;
  636. /** Removes the given property from the list of properties to update */
  637. remove(prop: PropertyLine): void;
  638. dispose(): void;
  639. }
  640. }
  641. declare module INSPECTOR {
  642. export class CameraTab extends PropertyTab {
  643. constructor(tabbar: TabBar, inspector: Inspector);
  644. protected _getTree(): Array<TreeItem>;
  645. }
  646. }
  647. declare module INSPECTOR {
  648. /**
  649. * The console tab will have two features :
  650. * - hook all console.log call and display them in this panel (and in the browser console as well)
  651. * - display all Babylon logs (called with Tools.Log...)
  652. */
  653. export class ConsoleTab extends Tab {
  654. constructor(tabbar: TabBar, insp: Inspector);
  655. /** Overrides super.dispose */
  656. dispose(): void;
  657. active(b: boolean): void;
  658. }
  659. }
  660. declare module INSPECTOR {
  661. export class GLTFTab extends Tab {
  662. static readonly IsSupported: boolean;
  663. /** @hidden */
  664. static _Initialize(): void;
  665. constructor(tabbar: TabBar, inspector: Inspector);
  666. dispose(): void;
  667. /** @hidden */
  668. static _GetLoaderDefaultsAsync(): Promise<any>;
  669. }
  670. }
  671. declare module INSPECTOR {
  672. export class GUITab extends PropertyTab {
  673. constructor(tabbar: TabBar, inspector: Inspector);
  674. protected _getTree(): Array<TreeItem>;
  675. }
  676. }
  677. declare module INSPECTOR {
  678. export class LightTab extends PropertyTab {
  679. constructor(tabbar: TabBar, inspector: Inspector);
  680. protected _getTree(): Array<TreeItem>;
  681. }
  682. }
  683. declare module INSPECTOR {
  684. export class MaterialTab extends PropertyTab {
  685. constructor(tabbar: TabBar, inspector: Inspector);
  686. protected _getTree(): Array<TreeItem>;
  687. }
  688. }
  689. declare module INSPECTOR {
  690. export class MeshTab extends PropertyTab {
  691. constructor(tabbar: TabBar, inspector: Inspector);
  692. protected _getTree(): Array<TreeItem>;
  693. }
  694. }
  695. declare module INSPECTOR {
  696. export class PhysicsTab extends PropertyTab {
  697. viewer: any;
  698. constructor(tabbar: TabBar, inspector: Inspector);
  699. protected _getTree(): Array<TreeItem>;
  700. }
  701. }
  702. declare module INSPECTOR {
  703. /**
  704. * A Property tab can creates two panels:
  705. * a tree panel and a detail panel,
  706. * in which properties will be displayed.
  707. * Both panels are separated by a resize bar
  708. */
  709. export abstract class PropertyTab extends Tab {
  710. protected _inspector: Inspector;
  711. /** The panel containing a list of items */
  712. protected _treePanel: HTMLDivElement;
  713. /** The panel containing a list if properties corresponding to an item */
  714. protected _detailsPanel: DetailPanel;
  715. protected _treeItems: Array<TreeItem>;
  716. protected _searchBar: SearchBar;
  717. constructor(tabbar: TabBar, name: string, insp: Inspector);
  718. /** Overrides dispose */
  719. dispose(): void;
  720. update(_items?: Array<TreeItem>): void;
  721. /** Display the details of the given item */
  722. displayDetails(item: TreeItem): void;
  723. /** Select an item in the tree */
  724. select(item: TreeItem): void;
  725. /** Set the given item as active in the tree */
  726. activateNode(item: TreeItem): void;
  727. /** Returns the treeitem corersponding to the given obj, null if not found */
  728. getItemFor(_obj: any): BABYLON.Nullable<TreeItem>;
  729. filter(filter: string): void;
  730. /** Builds the tree panel */
  731. protected abstract _getTree(): Array<TreeItem>;
  732. }
  733. }
  734. declare module INSPECTOR {
  735. export class SceneTab extends Tab {
  736. constructor(tabbar: TabBar, insp: Inspector);
  737. /** Overrides super.dispose */
  738. dispose(): void;
  739. }
  740. }
  741. declare module INSPECTOR {
  742. export class SoundTab extends PropertyTab {
  743. constructor(tabbar: TabBar, inspector: Inspector);
  744. protected _getTree(): Array<TreeItem>;
  745. }
  746. }
  747. declare module INSPECTOR {
  748. export class StatsTab extends Tab {
  749. constructor(tabbar: TabBar, insp: Inspector);
  750. dispose(): void;
  751. active(b: boolean): void;
  752. }
  753. }
  754. declare module INSPECTOR {
  755. export abstract class Tab extends BasicElement {
  756. protected _tabbar: TabBar;
  757. name: string;
  758. protected _isActive: boolean;
  759. protected _panel: HTMLDivElement;
  760. constructor(tabbar: TabBar, name: string);
  761. /** True if the tab is active, false otherwise */
  762. isActive(): boolean;
  763. protected _build(): void;
  764. /** Set this tab as active or not, depending on the current state */
  765. active(b: boolean): void;
  766. update(): void;
  767. /** Creates the tab panel for this tab. */
  768. getPanel(): HTMLElement;
  769. /** Add this in the propertytab with the searchbar */
  770. filter(str: string): void;
  771. /** Dispose properly this tab */
  772. abstract dispose(): void;
  773. /** Select an item in the tree */
  774. select(item: TreeItem): void;
  775. /**
  776. * Returns the total width in pixel of this tab, 0 by default
  777. */
  778. getPixelWidth(): number;
  779. }
  780. }
  781. declare module INSPECTOR {
  782. /**
  783. * A tab bar will contains each view the inspector can have : Canvas2D, Meshes...
  784. * The default active tab is the first one of the list.
  785. */
  786. export class TabBar extends BasicElement {
  787. constructor(inspector: Inspector, initialTab?: number | string);
  788. update(): void;
  789. protected _build(): void;
  790. /** Dispose the current tab, set the given tab as active, and refresh the treeview */
  791. switchTab(tab: Tab): void;
  792. /** Display the mesh tab.
  793. * If a parameter is given, the given mesh details are displayed
  794. */
  795. switchMeshTab(mesh?: BABYLON.AbstractMesh): void;
  796. /** Returns the active tab */
  797. getActiveTab(): BABYLON.Nullable<Tab>;
  798. getActiveTabIndex(): number;
  799. getTabIndex(name: string): number;
  800. readonly inspector: Inspector;
  801. /**
  802. * Returns the total width in pixel of the tabbar,
  803. * that corresponds to the sum of the width of each visible tab + toolbar width
  804. */
  805. getPixelWidth(): number;
  806. /** Display the remaining icon or not depending on the tabbar width.
  807. * This function should be called each time the inspector width is updated
  808. */
  809. updateWidth(): void;
  810. }
  811. }
  812. declare module INSPECTOR {
  813. export class TextureTab extends Tab {
  814. static DDSPreview: DDSPreview;
  815. /** The panel containing a list of items */
  816. protected _treePanel: HTMLElement;
  817. protected _treeItems: Array<TreeItem>;
  818. constructor(tabbar: TabBar, inspector: Inspector);
  819. dispose(): void;
  820. update(_items?: Array<TreeItem>): void;
  821. /** Display the details of the given item */
  822. displayDetails(item: TreeItem): void;
  823. /** Select an item in the tree */
  824. select(item: TreeItem): void;
  825. /** Set the given item as active in the tree */
  826. activateNode(item: TreeItem): void;
  827. }
  828. class DDSPreview {
  829. canvas: HTMLCanvasElement | null;
  830. constructor(AdapterItem: TextureAdapter);
  831. insertPreview(AdapterItem: TextureAdapter): void;
  832. dispose(): void;
  833. }
  834. }
  835. declare module INSPECTOR {
  836. export class ToolsTab extends Tab {
  837. constructor(tabbar: TabBar, insp: Inspector);
  838. dispose(): void;
  839. }
  840. }
  841. declare module INSPECTOR {
  842. export class TreeItem extends BasicElement {
  843. children: Array<TreeItem>;
  844. constructor(tab: Tab, obj: Adapter);
  845. /** Returns the item ID == its adapter ID */
  846. readonly id: string;
  847. /** Add the given item as a child of this one */
  848. add(child: TreeItem): void;
  849. /**
  850. * Returns the original adapter
  851. */
  852. readonly adapter: Adapter;
  853. /**
  854. * Function used to compare this item to another tree item.
  855. * Returns the alphabetical sort of the adapter ID
  856. */
  857. compareTo(item: TreeItem): number;
  858. /** Returns true if the given obj correspond to the adapter linked to this tree item */
  859. correspondsTo(obj: any): boolean;
  860. /** hide all children of this item */
  861. fold(): void;
  862. /** Show all children of this item */
  863. unfold(): void;
  864. /** Build the HTML of this item */
  865. protected _build(): void;
  866. /**
  867. * Returns one HTML element (.details) containing all details of this primitive
  868. */
  869. getDetails(): Array<PropertyLine>;
  870. update(): void;
  871. /**
  872. * Add an event listener on the item :
  873. * - one click display details
  874. */
  875. protected _addEvent(): void;
  876. /** Set this item as active (background lighter) in the tree panel */
  877. active(b: boolean): void;
  878. getDiv(): HTMLDivElement;
  879. }
  880. }
  881. declare module INSPECTOR {
  882. export abstract class AbstractTreeTool {
  883. protected _elem: HTMLElement;
  884. /** Is the tool enabled ? */
  885. protected _on: boolean;
  886. constructor();
  887. toHtml(): HTMLElement;
  888. protected _addEvents(): void;
  889. /**
  890. * Action launched when clicked on this element
  891. * Should be overrided
  892. */
  893. protected action(): void;
  894. }
  895. }
  896. declare module INSPECTOR {
  897. /** Any object implementing this interface should
  898. * provide methods to toggle its bounding box
  899. */
  900. export interface IToolBoundingBox {
  901. isBoxVisible: () => boolean;
  902. setBoxVisible: (b: boolean) => void;
  903. }
  904. /**
  905. * Checkbox to display/hide the primitive
  906. */
  907. export class BoundingBox extends AbstractTreeTool {
  908. constructor(obj: IToolBoundingBox);
  909. protected action(): void;
  910. }
  911. }
  912. declare module INSPECTOR {
  913. export interface ICameraPOV {
  914. setPOV: () => void;
  915. getCurrentActiveCamera: () => string;
  916. id: () => string;
  917. }
  918. /**
  919. *
  920. */
  921. export class CameraPOV extends AbstractTreeTool {
  922. constructor(camera: ICameraPOV);
  923. protected action(): void;
  924. }
  925. }
  926. declare module INSPECTOR {
  927. /** Any object implementing this interface should
  928. * provide methods to toggle its visibility
  929. */
  930. export interface IToolVisible {
  931. isVisible: () => boolean;
  932. setVisible: (b: boolean) => void;
  933. }
  934. /**
  935. * Checkbox to display/hide the primitive
  936. */
  937. export class Checkbox extends AbstractTreeTool {
  938. constructor(obj: IToolVisible);
  939. protected action(): void;
  940. }
  941. }
  942. declare module INSPECTOR {
  943. /** Any object implementing this interface should
  944. * provide methods to toggle a debug area
  945. */
  946. export interface IToolDebug {
  947. debug: (b: boolean) => void;
  948. }
  949. export class DebugArea extends AbstractTreeTool {
  950. constructor(obj: IToolDebug);
  951. protected action(): void;
  952. }
  953. }
  954. declare module INSPECTOR {
  955. /** Any object implementing this interface should
  956. * provide methods to retrieve its info
  957. */
  958. export interface IToolInfo {
  959. getInfo: () => string;
  960. }
  961. /**
  962. * Checkbox to display/hide the primitive
  963. */
  964. export class Info extends AbstractTreeTool {
  965. constructor(obj: IToolInfo);
  966. protected action(): void;
  967. }
  968. }
  969. declare module INSPECTOR {
  970. export interface ISoundInteractions {
  971. setPlaying: (callback: Function) => void;
  972. }
  973. /**
  974. *
  975. */
  976. export class SoundInteractions extends AbstractTreeTool {
  977. constructor(playSound: ISoundInteractions);
  978. protected action(): void;
  979. }
  980. }