babylon.inspector.d.ts 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050
  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 | string, 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. /** @hidden */
  664. static _GetLoaderDefaultsAsync(): Promise<any>;
  665. }
  666. }
  667. declare module INSPECTOR {
  668. export class GUITab extends PropertyTab {
  669. constructor(tabbar: TabBar, inspector: Inspector);
  670. protected _getTree(): Array<TreeItem>;
  671. }
  672. }
  673. declare module INSPECTOR {
  674. export class LightTab extends PropertyTab {
  675. constructor(tabbar: TabBar, inspector: Inspector);
  676. protected _getTree(): Array<TreeItem>;
  677. }
  678. }
  679. declare module INSPECTOR {
  680. export class MaterialTab extends PropertyTab {
  681. constructor(tabbar: TabBar, inspector: Inspector);
  682. protected _getTree(): Array<TreeItem>;
  683. }
  684. }
  685. declare module INSPECTOR {
  686. export class MeshTab extends PropertyTab {
  687. constructor(tabbar: TabBar, inspector: Inspector);
  688. protected _getTree(): Array<TreeItem>;
  689. }
  690. }
  691. declare module INSPECTOR {
  692. export class PhysicsTab extends PropertyTab {
  693. viewer: any;
  694. constructor(tabbar: TabBar, inspector: Inspector);
  695. protected _getTree(): Array<TreeItem>;
  696. }
  697. }
  698. declare module INSPECTOR {
  699. /**
  700. * A Property tab can creates two panels:
  701. * a tree panel and a detail panel,
  702. * in which properties will be displayed.
  703. * Both panels are separated by a resize bar
  704. */
  705. export abstract class PropertyTab extends Tab {
  706. protected _inspector: Inspector;
  707. /** The panel containing a list of items */
  708. protected _treePanel: HTMLDivElement;
  709. /** The panel containing a list if properties corresponding to an item */
  710. protected _detailsPanel: DetailPanel;
  711. protected _treeItems: Array<TreeItem>;
  712. protected _searchBar: SearchBar;
  713. constructor(tabbar: TabBar, name: string, insp: Inspector);
  714. /** Overrides dispose */
  715. dispose(): void;
  716. update(_items?: Array<TreeItem>): void;
  717. /** Display the details of the given item */
  718. displayDetails(item: TreeItem): void;
  719. /** Select an item in the tree */
  720. select(item: TreeItem): void;
  721. /** Set the given item as active in the tree */
  722. activateNode(item: TreeItem): void;
  723. /** Returns the treeitem corersponding to the given obj, null if not found */
  724. getItemFor(_obj: any): BABYLON.Nullable<TreeItem>;
  725. filter(filter: string): void;
  726. /** Builds the tree panel */
  727. protected abstract _getTree(): Array<TreeItem>;
  728. }
  729. }
  730. declare module INSPECTOR {
  731. export class SceneTab extends Tab {
  732. constructor(tabbar: TabBar, insp: Inspector);
  733. /** Overrides super.dispose */
  734. dispose(): void;
  735. }
  736. }
  737. declare module INSPECTOR {
  738. export class SoundTab extends PropertyTab {
  739. constructor(tabbar: TabBar, inspector: Inspector);
  740. protected _getTree(): Array<TreeItem>;
  741. }
  742. }
  743. declare module INSPECTOR {
  744. export class StatsTab extends Tab {
  745. constructor(tabbar: TabBar, insp: Inspector);
  746. dispose(): void;
  747. active(b: boolean): void;
  748. }
  749. }
  750. declare module INSPECTOR {
  751. export abstract class Tab extends BasicElement {
  752. protected _tabbar: TabBar;
  753. name: string;
  754. protected _isActive: boolean;
  755. protected _panel: HTMLDivElement;
  756. constructor(tabbar: TabBar, name: string);
  757. /** True if the tab is active, false otherwise */
  758. isActive(): boolean;
  759. protected _build(): void;
  760. /** Set this tab as active or not, depending on the current state */
  761. active(b: boolean): void;
  762. update(): void;
  763. /** Creates the tab panel for this tab. */
  764. getPanel(): HTMLElement;
  765. /** Add this in the propertytab with the searchbar */
  766. filter(str: string): void;
  767. /** Dispose properly this tab */
  768. abstract dispose(): void;
  769. /** Select an item in the tree */
  770. select(item: TreeItem): void;
  771. /**
  772. * Returns the total width in pixel of this tab, 0 by default
  773. */
  774. getPixelWidth(): number;
  775. }
  776. }
  777. declare module INSPECTOR {
  778. /**
  779. * A tab bar will contains each view the inspector can have : Canvas2D, Meshes...
  780. * The default active tab is the first one of the list.
  781. */
  782. export class TabBar extends BasicElement {
  783. constructor(inspector: Inspector, initialTab?: number | string);
  784. update(): void;
  785. protected _build(): void;
  786. /** Dispose the current tab, set the given tab as active, and refresh the treeview */
  787. switchTab(tab: Tab): void;
  788. /** Display the mesh tab.
  789. * If a parameter is given, the given mesh details are displayed
  790. */
  791. switchMeshTab(mesh?: BABYLON.AbstractMesh): void;
  792. /** Returns the active tab */
  793. getActiveTab(): BABYLON.Nullable<Tab>;
  794. getActiveTabIndex(): number;
  795. getTabIndex(name: string): number;
  796. readonly inspector: Inspector;
  797. /**
  798. * Returns the total width in pixel of the tabbar,
  799. * that corresponds to the sum of the width of each visible tab + toolbar width
  800. */
  801. getPixelWidth(): number;
  802. /** Display the remaining icon or not depending on the tabbar width.
  803. * This function should be called each time the inspector width is updated
  804. */
  805. updateWidth(): void;
  806. }
  807. }
  808. declare module INSPECTOR {
  809. export class TextureTab extends Tab {
  810. static DDSPreview: DDSPreview;
  811. /** The panel containing a list of items */
  812. protected _treePanel: HTMLElement;
  813. protected _treeItems: Array<TreeItem>;
  814. constructor(tabbar: TabBar, inspector: Inspector);
  815. dispose(): void;
  816. update(_items?: Array<TreeItem>): void;
  817. /** Display the details of the given item */
  818. displayDetails(item: TreeItem): void;
  819. /** Select an item in the tree */
  820. select(item: TreeItem): void;
  821. /** Set the given item as active in the tree */
  822. activateNode(item: TreeItem): void;
  823. }
  824. class DDSPreview {
  825. canvas: HTMLCanvasElement | null;
  826. constructor(AdapterItem: TextureAdapter);
  827. insertPreview(AdapterItem: TextureAdapter): void;
  828. dispose(): void;
  829. }
  830. }
  831. declare module INSPECTOR {
  832. export class ToolsTab extends Tab {
  833. constructor(tabbar: TabBar, insp: Inspector);
  834. dispose(): void;
  835. }
  836. }
  837. declare module INSPECTOR {
  838. export abstract class AbstractTool {
  839. protected _inspector: Inspector;
  840. constructor(iconSet: string, icon: string, parent: HTMLElement, inspector: Inspector, tooltip: string);
  841. toHtml(): HTMLElement;
  842. /**
  843. * Returns the total width in pixel of this tool, 0 by default
  844. */
  845. getPixelWidth(): number;
  846. /**
  847. * Updates the icon of this tool with the given string
  848. */
  849. protected _updateIcon(icon: string): void;
  850. abstract action(): void;
  851. }
  852. }
  853. declare module INSPECTOR {
  854. /**
  855. * Removes the inspector panel
  856. */
  857. export class DisposeTool extends AbstractTool {
  858. constructor(parent: HTMLElement, inspector: Inspector);
  859. action(): void;
  860. }
  861. }
  862. declare module INSPECTOR {
  863. export class FullscreenTool extends AbstractTool {
  864. constructor(parent: HTMLElement, inspector: Inspector);
  865. action(): void;
  866. }
  867. }
  868. declare module INSPECTOR {
  869. export class LabelTool extends AbstractTool {
  870. constructor(parent: HTMLElement, inspector: Inspector);
  871. dispose(): void;
  872. action(): void;
  873. }
  874. }
  875. declare module INSPECTOR {
  876. export class PauseScheduleTool extends AbstractTool {
  877. constructor(parent: HTMLElement, inspector: Inspector);
  878. action(): void;
  879. }
  880. }
  881. declare module INSPECTOR {
  882. export class PickTool extends AbstractTool {
  883. constructor(parent: HTMLElement, inspector: Inspector);
  884. action(): void;
  885. }
  886. }
  887. declare module INSPECTOR {
  888. export class PopupTool extends AbstractTool {
  889. constructor(parent: HTMLElement, inspector: Inspector);
  890. action(): void;
  891. }
  892. }
  893. declare module INSPECTOR {
  894. export class RefreshTool extends AbstractTool {
  895. constructor(parent: HTMLElement, inspector: Inspector);
  896. action(): void;
  897. }
  898. }
  899. declare module INSPECTOR {
  900. export class Toolbar extends BasicElement {
  901. constructor(inspector: Inspector);
  902. update(): void;
  903. protected _build(): void;
  904. /**
  905. * Returns the total width in pixel of the tabbar,
  906. * that corresponds to the sum of the width of each tab + toolbar width
  907. */
  908. getPixelWidth(): number;
  909. }
  910. }
  911. declare module INSPECTOR {
  912. export class TreeItem extends BasicElement {
  913. children: Array<TreeItem>;
  914. constructor(tab: Tab, obj: Adapter);
  915. /** Returns the item ID == its adapter ID */
  916. readonly id: string;
  917. /** Add the given item as a child of this one */
  918. add(child: TreeItem): void;
  919. /**
  920. * Returns the original adapter
  921. */
  922. readonly adapter: Adapter;
  923. /**
  924. * Function used to compare this item to another tree item.
  925. * Returns the alphabetical sort of the adapter ID
  926. */
  927. compareTo(item: TreeItem): number;
  928. /** Returns true if the given obj correspond to the adapter linked to this tree item */
  929. correspondsTo(obj: any): boolean;
  930. /** hide all children of this item */
  931. fold(): void;
  932. /** Show all children of this item */
  933. unfold(): void;
  934. /** Build the HTML of this item */
  935. protected _build(): void;
  936. /**
  937. * Returns one HTML element (.details) containing all details of this primitive
  938. */
  939. getDetails(): Array<PropertyLine>;
  940. update(): void;
  941. /**
  942. * Add an event listener on the item :
  943. * - one click display details
  944. */
  945. protected _addEvent(): void;
  946. /** Set this item as active (background lighter) in the tree panel */
  947. active(b: boolean): void;
  948. getDiv(): HTMLDivElement;
  949. }
  950. }
  951. declare module INSPECTOR {
  952. export abstract class AbstractTreeTool {
  953. protected _elem: HTMLElement;
  954. /** Is the tool enabled ? */
  955. protected _on: boolean;
  956. constructor();
  957. toHtml(): HTMLElement;
  958. protected _addEvents(): void;
  959. /**
  960. * Action launched when clicked on this element
  961. * Should be overrided
  962. */
  963. protected action(): void;
  964. }
  965. }
  966. declare module INSPECTOR {
  967. /** Any object implementing this interface should
  968. * provide methods to toggle its bounding box
  969. */
  970. export interface IToolBoundingBox {
  971. isBoxVisible: () => boolean;
  972. setBoxVisible: (b: boolean) => void;
  973. }
  974. /**
  975. * Checkbox to display/hide the primitive
  976. */
  977. export class BoundingBox extends AbstractTreeTool {
  978. constructor(obj: IToolBoundingBox);
  979. protected action(): void;
  980. }
  981. }
  982. declare module INSPECTOR {
  983. export interface ICameraPOV {
  984. setPOV: () => void;
  985. getCurrentActiveCamera: () => string;
  986. id: () => string;
  987. }
  988. /**
  989. *
  990. */
  991. export class CameraPOV extends AbstractTreeTool {
  992. constructor(camera: ICameraPOV);
  993. protected action(): void;
  994. }
  995. }
  996. declare module INSPECTOR {
  997. /** Any object implementing this interface should
  998. * provide methods to toggle its visibility
  999. */
  1000. export interface IToolVisible {
  1001. isVisible: () => boolean;
  1002. setVisible: (b: boolean) => void;
  1003. }
  1004. /**
  1005. * Checkbox to display/hide the primitive
  1006. */
  1007. export class Checkbox extends AbstractTreeTool {
  1008. constructor(obj: IToolVisible);
  1009. protected action(): void;
  1010. }
  1011. }
  1012. declare module INSPECTOR {
  1013. /** Any object implementing this interface should
  1014. * provide methods to toggle a debug area
  1015. */
  1016. export interface IToolDebug {
  1017. debug: (b: boolean) => void;
  1018. }
  1019. export class DebugArea extends AbstractTreeTool {
  1020. constructor(obj: IToolDebug);
  1021. protected action(): void;
  1022. }
  1023. }
  1024. declare module INSPECTOR {
  1025. /** Any object implementing this interface should
  1026. * provide methods to retrieve its info
  1027. */
  1028. export interface IToolInfo {
  1029. getInfo: () => string;
  1030. }
  1031. /**
  1032. * Checkbox to display/hide the primitive
  1033. */
  1034. export class Info extends AbstractTreeTool {
  1035. constructor(obj: IToolInfo);
  1036. protected action(): void;
  1037. }
  1038. }
  1039. declare module INSPECTOR {
  1040. export interface ISoundInteractions {
  1041. setPlaying: (callback: Function) => void;
  1042. }
  1043. /**
  1044. *
  1045. */
  1046. export class SoundInteractions extends AbstractTreeTool {
  1047. constructor(playSound: ISoundInteractions);
  1048. protected action(): void;
  1049. }
  1050. }