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