babylon.inspector.d.ts 43 KB

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