babylon.inspector.d.ts 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308
  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: any);
  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. private interval;
  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. dispose(): void;
  766. }
  767. }
  768. declare module INSPECTOR {
  769. abstract class Tab extends BasicElement {
  770. protected _tabbar: TabBar;
  771. name: string;
  772. protected _isActive: boolean;
  773. protected _panel: HTMLDivElement;
  774. constructor(tabbar: TabBar, name: string);
  775. /** True if the tab is active, false otherwise */
  776. isActive(): boolean;
  777. protected _build(): void;
  778. /** Set this tab as active or not, depending on the current state */
  779. active(b: boolean): void;
  780. update(): void;
  781. /** Creates the tab panel for this tab. */
  782. getPanel(): HTMLElement;
  783. /** Add this in the propertytab with the searchbar */
  784. filter(str: string): void;
  785. /** Dispose properly this tab */
  786. abstract dispose(): void;
  787. /** Select an item in the tree */
  788. select(item: TreeItem): void;
  789. /**
  790. * Returns the total width in pixel of this tab, 0 by default
  791. */
  792. getPixelWidth(): number;
  793. }
  794. }
  795. declare function Split(elements: HTMLDivElement[], options: any): void;
  796. declare module INSPECTOR {
  797. /**
  798. * A Property tab can creates two panels:
  799. * a tree panel and a detail panel,
  800. * in which properties will be displayed.
  801. * Both panels are separated by a resize bar
  802. */
  803. abstract class PropertyTab extends Tab {
  804. protected _inspector: Inspector;
  805. /** The panel containing a list of items */
  806. protected _treePanel: HTMLElement;
  807. /** The panel containing a list if properties corresponding to an item */
  808. protected _detailsPanel: DetailPanel;
  809. protected _treeItems: Array<TreeItem>;
  810. protected _searchBar: SearchBar;
  811. constructor(tabbar: TabBar, name: string, insp: Inspector);
  812. /** Overrides dispose */
  813. dispose(): void;
  814. update(_items?: Array<TreeItem>): void;
  815. /** Display the details of the given item */
  816. displayDetails(item: TreeItem): void;
  817. /** Select an item in the tree */
  818. select(item: TreeItem): void;
  819. /** Set the given item as active in the tree */
  820. activateNode(item: TreeItem): void;
  821. /** Returns the treeitem corersponding to the given obj, null if not found */
  822. getItemFor(_obj: any): BABYLON.Nullable<TreeItem>;
  823. filter(filter: string): void;
  824. /** Builds the tree panel */
  825. protected abstract _getTree(): Array<TreeItem>;
  826. }
  827. }
  828. declare module INSPECTOR {
  829. class CameraTab extends PropertyTab {
  830. constructor(tabbar: TabBar, inspector: Inspector);
  831. protected _getTree(): Array<TreeItem>;
  832. }
  833. }
  834. declare module INSPECTOR {
  835. class GUITab extends PropertyTab {
  836. constructor(tabbar: TabBar, inspector: Inspector);
  837. protected _getTree(): Array<TreeItem>;
  838. }
  839. }
  840. declare module INSPECTOR {
  841. class PhysicsTab extends PropertyTab {
  842. viewer: any;
  843. constructor(tabbar: TabBar, inspector: Inspector);
  844. protected _getTree(): Array<TreeItem>;
  845. }
  846. }
  847. declare module INSPECTOR {
  848. class SoundTab extends PropertyTab {
  849. constructor(tabbar: TabBar, inspector: Inspector);
  850. protected _getTree(): Array<TreeItem>;
  851. }
  852. }
  853. declare module INSPECTOR {
  854. class TextureTab extends Tab {
  855. private _inspector;
  856. /** The panel containing a list of items */
  857. protected _treePanel: HTMLElement;
  858. protected _treeItems: Array<TreeItem>;
  859. private _imagePanel;
  860. constructor(tabbar: TabBar, inspector: Inspector);
  861. dispose(): void;
  862. update(_items?: Array<TreeItem>): void;
  863. private _getTree();
  864. /** Display the details of the given item */
  865. displayDetails(item: TreeItem): void;
  866. /** Select an item in the tree */
  867. select(item: TreeItem): void;
  868. /** Set the given item as active in the tree */
  869. activateNode(item: TreeItem): void;
  870. }
  871. }
  872. declare module INSPECTOR {
  873. class LightTab extends PropertyTab {
  874. constructor(tabbar: TabBar, inspector: Inspector);
  875. protected _getTree(): Array<TreeItem>;
  876. }
  877. }
  878. declare module INSPECTOR {
  879. class MaterialTab extends PropertyTab {
  880. constructor(tabbar: TabBar, inspector: Inspector);
  881. protected _getTree(): Array<TreeItem>;
  882. }
  883. }
  884. declare module INSPECTOR {
  885. class MeshTab extends PropertyTab {
  886. constructor(tabbar: TabBar, inspector: Inspector);
  887. protected _getTree(): Array<TreeItem>;
  888. }
  889. }
  890. declare function Split(elements: HTMLElement[], options: any): void;
  891. declare module INSPECTOR {
  892. class SceneTab extends Tab {
  893. private _inspector;
  894. /** The list of channels/options that can be activated/deactivated */
  895. private _actions;
  896. /** The list of skeleton viewer */
  897. private _skeletonViewers;
  898. /** The detail of the scene */
  899. private _detailsPanel;
  900. constructor(tabbar: TabBar, insp: Inspector);
  901. /** Overrides super.dispose */
  902. dispose(): void;
  903. /** generates a div which correspond to an option that can be activated/deactivated */
  904. private _generateActionLine(name, initValue, action);
  905. /**
  906. * Add a click action for all given elements :
  907. * the clicked element is set as active, all others elements are deactivated
  908. */
  909. private _generateRadioAction(arr);
  910. }
  911. }
  912. declare function Split(elements: HTMLDivElement[], options: any): void;
  913. declare module INSPECTOR {
  914. /**
  915. * The console tab will have two features :
  916. * - hook all console.log call and display them in this panel (and in the browser console as well)
  917. * - display all Babylon logs (called with Tools.Log...)
  918. */
  919. class ConsoleTab extends Tab {
  920. private _inspector;
  921. private _consolePanelContent;
  922. private _bjsPanelContent;
  923. private _oldConsoleLog;
  924. private _oldConsoleWarn;
  925. private _oldConsoleError;
  926. constructor(tabbar: TabBar, insp: Inspector);
  927. /** Overrides super.dispose */
  928. dispose(): void;
  929. active(b: boolean): void;
  930. private _message(type, message, caller);
  931. private _addConsoleLog(...params);
  932. private _addConsoleWarn(...params);
  933. private _addConsoleError(...params);
  934. }
  935. }
  936. declare module INSPECTOR {
  937. class StatsTab extends Tab {
  938. private _inspector;
  939. /**
  940. * Properties in this array will be updated
  941. * in a render loop - Mostly stats properties
  942. */
  943. private _updatableProperties;
  944. private _scene;
  945. private _engine;
  946. private _glInfo;
  947. private _updateLoopHandler;
  948. private _sceneInstrumentation;
  949. private _engineInstrumentation;
  950. private _connectToInstrumentation();
  951. constructor(tabbar: TabBar, insp: Inspector);
  952. private _createStatLabel(content, parent);
  953. /** Update each properties of the stats panel */
  954. private _update();
  955. dispose(): void;
  956. active(b: boolean): void;
  957. }
  958. }
  959. declare module INSPECTOR {
  960. /**
  961. * A tab bar will contains each view the inspector can have : Canvas2D, Meshes...
  962. * The default active tab is the first one of the list.
  963. */
  964. class TabBar extends BasicElement {
  965. private _tabs;
  966. private _inspector;
  967. /** The tab displaying all meshes */
  968. private _meshTab;
  969. /** The toolbar */
  970. private _toolBar;
  971. /** The icon displayed at the end of the toolbar displaying a combo box of tabs not displayed */
  972. private _moreTabsIcon;
  973. /** The panel displayed when the 'more-tab' icon is selected */
  974. private _moreTabsPanel;
  975. /** The list of tab displayed by clicking on the remainingIcon */
  976. private _invisibleTabs;
  977. /** The list of tabs visible, displayed in the tab bar */
  978. private _visibleTabs;
  979. constructor(inspector: Inspector, initialTab?: number);
  980. update(): void;
  981. protected _build(): void;
  982. /**
  983. * Add a tab to the 'more-tabs' panel, displayed by clicking on the
  984. * 'more-tabs' icon
  985. */
  986. private _addInvisibleTabToPanel(tab);
  987. /** Dispose the current tab, set the given tab as active, and refresh the treeview */
  988. switchTab(tab: Tab): void;
  989. /** Display the mesh tab.
  990. * If a parameter is given, the given mesh details are displayed
  991. */
  992. switchMeshTab(mesh?: BABYLON.AbstractMesh): void;
  993. /** Returns the active tab */
  994. getActiveTab(): BABYLON.Nullable<Tab>;
  995. getActiveTabIndex(): number;
  996. readonly inspector: Inspector;
  997. /**
  998. * Returns the total width in pixel of the tabbar,
  999. * that corresponds to the sum of the width of each visible tab + toolbar width
  1000. */
  1001. getPixelWidth(): number;
  1002. /** Display the remaining icon or not depending on the tabbar width.
  1003. * This function should be called each time the inspector width is updated
  1004. */
  1005. updateWidth(): void;
  1006. }
  1007. }
  1008. declare module INSPECTOR {
  1009. abstract class AbstractTool {
  1010. private _elem;
  1011. protected _inspector: Inspector;
  1012. constructor(icon: string, parent: HTMLElement, inspector: Inspector, tooltip: string);
  1013. toHtml(): HTMLElement;
  1014. /**
  1015. * Returns the total width in pixel of this tool, 0 by default
  1016. */
  1017. getPixelWidth(): number;
  1018. /**
  1019. * Updates the icon of this tool with the given string
  1020. */
  1021. protected _updateIcon(icon: string): void;
  1022. abstract action(): void;
  1023. }
  1024. }
  1025. declare module INSPECTOR {
  1026. class PauseScheduleTool extends AbstractTool {
  1027. private _isPause;
  1028. constructor(parent: HTMLElement, inspector: Inspector);
  1029. action(): void;
  1030. }
  1031. }
  1032. declare module INSPECTOR {
  1033. class PickTool extends AbstractTool {
  1034. private _isActive;
  1035. private _pickHandler;
  1036. constructor(parent: HTMLElement, inspector: Inspector);
  1037. action(): void;
  1038. /** Deactivate this tool */
  1039. private _deactivate();
  1040. /** Pick a mesh in the scene */
  1041. private _pickMesh(evt);
  1042. private _updatePointerPosition(evt);
  1043. }
  1044. }
  1045. declare module INSPECTOR {
  1046. class PopupTool extends AbstractTool {
  1047. constructor(parent: HTMLElement, inspector: Inspector);
  1048. action(): void;
  1049. }
  1050. }
  1051. declare module INSPECTOR {
  1052. class RefreshTool extends AbstractTool {
  1053. constructor(parent: HTMLElement, inspector: Inspector);
  1054. action(): void;
  1055. }
  1056. }
  1057. declare module INSPECTOR {
  1058. class LabelTool extends AbstractTool {
  1059. /** True if label are displayed, false otherwise */
  1060. private _isDisplayed;
  1061. private _advancedTexture;
  1062. private _labelInitialized;
  1063. private _scene;
  1064. private _guiLoaded;
  1065. constructor(parent: HTMLElement, inspector: Inspector);
  1066. dispose(): void;
  1067. private _checkGUILoaded();
  1068. private _initializeLabels();
  1069. private _createLabel(mesh);
  1070. private _removeLabel(mesh);
  1071. action(): void;
  1072. }
  1073. }
  1074. declare module INSPECTOR {
  1075. class Toolbar extends BasicElement {
  1076. private _inspector;
  1077. private _tools;
  1078. constructor(inspector: Inspector);
  1079. update(): void;
  1080. protected _build(): void;
  1081. private _addTools();
  1082. /**
  1083. * Returns the total width in pixel of the tabbar,
  1084. * that corresponds to the sum of the width of each tab + toolbar width
  1085. */
  1086. getPixelWidth(): number;
  1087. }
  1088. }
  1089. declare module INSPECTOR {
  1090. /**
  1091. * Removes the inspector panel
  1092. */
  1093. class DisposeTool extends AbstractTool {
  1094. constructor(parent: HTMLElement, inspector: Inspector);
  1095. action(): void;
  1096. }
  1097. }
  1098. declare module INSPECTOR {
  1099. class TreeItem extends BasicElement {
  1100. private _tab;
  1101. private _adapter;
  1102. private _tools;
  1103. children: Array<TreeItem>;
  1104. private _lineContent;
  1105. constructor(tab: Tab, obj: Adapter);
  1106. /** Returns the item ID == its adapter ID */
  1107. readonly id: string;
  1108. /** Add the given item as a child of this one */
  1109. add(child: TreeItem): void;
  1110. /**
  1111. * Returns the original adapter
  1112. */
  1113. readonly adapter: Adapter;
  1114. /**
  1115. * Function used to compare this item to another tree item.
  1116. * Returns the alphabetical sort of the adapter ID
  1117. */
  1118. compareTo(item: TreeItem): number;
  1119. /** Returns true if the given obj correspond to the adapter linked to this tree item */
  1120. correspondsTo(obj: any): boolean;
  1121. /** hide all children of this item */
  1122. fold(): void;
  1123. /** Show all children of this item */
  1124. unfold(): void;
  1125. /** Build the HTML of this item */
  1126. protected _build(): void;
  1127. /**
  1128. * Returns one HTML element (.details) containing all details of this primitive
  1129. */
  1130. getDetails(): Array<PropertyLine>;
  1131. update(): void;
  1132. /**
  1133. * Add an event listener on the item :
  1134. * - one click display details
  1135. */
  1136. protected _addEvent(): void;
  1137. /** Returns true if the node is folded, false otherwise */
  1138. private _isFolded();
  1139. /** Set this item as active (background lighter) in the tree panel */
  1140. active(b: boolean): void;
  1141. getDiv(): HTMLElement;
  1142. }
  1143. }
  1144. declare module INSPECTOR {
  1145. abstract class AbstractTreeTool {
  1146. protected _elem: HTMLElement;
  1147. /** Is the tool enabled ? */
  1148. protected _on: boolean;
  1149. constructor();
  1150. toHtml(): HTMLElement;
  1151. protected _addEvents(): void;
  1152. /**
  1153. * Action launched when clicked on this element
  1154. * Should be overrided
  1155. */
  1156. protected action(): void;
  1157. }
  1158. }
  1159. declare module INSPECTOR {
  1160. /** Any object implementing this interface should
  1161. * provide methods to toggle its bounding box
  1162. */
  1163. interface IToolBoundingBox {
  1164. isBoxVisible: () => boolean;
  1165. setBoxVisible: (b: boolean) => void;
  1166. }
  1167. /**
  1168. * Checkbox to display/hide the primitive
  1169. */
  1170. class BoundingBox extends AbstractTreeTool {
  1171. private _obj;
  1172. constructor(obj: IToolBoundingBox);
  1173. protected action(): void;
  1174. private _check();
  1175. }
  1176. }
  1177. declare module INSPECTOR {
  1178. interface ICameraPOV {
  1179. setPOV: () => void;
  1180. }
  1181. /**
  1182. *
  1183. */
  1184. class CameraPOV extends AbstractTreeTool {
  1185. private cameraPOV;
  1186. constructor(camera: ICameraPOV);
  1187. protected action(): void;
  1188. private _gotoPOV();
  1189. }
  1190. }
  1191. declare module INSPECTOR {
  1192. interface ISoundInteractions {
  1193. setPlaying: (callback: Function) => void;
  1194. }
  1195. /**
  1196. *
  1197. */
  1198. class SoundInteractions extends AbstractTreeTool {
  1199. private playSound;
  1200. constructor(playSound: ISoundInteractions);
  1201. protected action(): void;
  1202. private _playSound();
  1203. }
  1204. }
  1205. declare module INSPECTOR {
  1206. /** Any object implementing this interface should
  1207. * provide methods to toggle its visibility
  1208. */
  1209. interface IToolVisible {
  1210. isVisible: () => boolean;
  1211. setVisible: (b: boolean) => void;
  1212. }
  1213. /**
  1214. * Checkbox to display/hide the primitive
  1215. */
  1216. class Checkbox extends AbstractTreeTool {
  1217. private _obj;
  1218. constructor(obj: IToolVisible);
  1219. protected action(): void;
  1220. private _check(dontEnable?);
  1221. }
  1222. }
  1223. declare module INSPECTOR {
  1224. /** Any object implementing this interface should
  1225. * provide methods to toggle a debug area
  1226. */
  1227. interface IToolDebug {
  1228. debug: (b: boolean) => void;
  1229. }
  1230. class DebugArea extends AbstractTreeTool {
  1231. private _obj;
  1232. constructor(obj: IToolDebug);
  1233. protected action(): void;
  1234. }
  1235. }
  1236. declare module INSPECTOR {
  1237. /** Any object implementing this interface should
  1238. * provide methods to retrieve its info
  1239. */
  1240. interface IToolInfo {
  1241. getInfo: () => string;
  1242. }
  1243. /**
  1244. * Checkbox to display/hide the primitive
  1245. */
  1246. class Info extends AbstractTreeTool {
  1247. private _obj;
  1248. constructor(obj: IToolInfo);
  1249. protected action(): void;
  1250. }
  1251. }