babylon.inspector.d.ts 43 KB

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