babylon.inspector.d.ts 43 KB

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