babylon.inspector.d.ts 44 KB

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