babylon.inspector.d.ts 45 KB

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