babylon.inspector.d.ts 43 KB

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