babylon.inspector.d.ts 38 KB

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