babylon.inspector.d.ts 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278
  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. private static _PROPERTIES;
  393. constructor(obj: BABYLON.Light);
  394. /** Returns the name displayed in the tree */
  395. id(): string;
  396. /** Returns the type of this object - displayed in the tree */
  397. type(): string;
  398. /** Returns the list of properties to be displayed for this adapter */
  399. getProperties(): Array<PropertyLine>;
  400. getTools(): Array<AbstractTreeTool>;
  401. setVisible(b: boolean): void;
  402. isVisible(): boolean;
  403. }
  404. }
  405. declare module INSPECTOR {
  406. class MaterialAdapter extends Adapter {
  407. constructor(obj: BABYLON.Material);
  408. /** Returns the name displayed in the tree */
  409. id(): string;
  410. /** Returns the type of this object - displayed in the tree */
  411. type(): string;
  412. /** Returns the list of properties to be displayed for this adapter */
  413. getProperties(): Array<PropertyLine>;
  414. /** No tools for a material adapter */
  415. getTools(): Array<AbstractTreeTool>;
  416. }
  417. }
  418. declare module INSPECTOR {
  419. class MeshAdapter extends Adapter implements IToolVisible, IToolDebug, IToolBoundingBox, IToolInfo {
  420. /** Keep track of the axis of the actual object */
  421. private _axis;
  422. constructor(obj: BABYLON.AbstractMesh);
  423. /** Returns the name displayed in the tree */
  424. id(): string;
  425. /** Returns the type of this object - displayed in the tree */
  426. type(): string;
  427. /** Returns the list of properties to be displayed for this adapter */
  428. getProperties(): Array<PropertyLine>;
  429. getTools(): Array<AbstractTreeTool>;
  430. setVisible(b: boolean): void;
  431. isVisible(): boolean;
  432. isBoxVisible(): boolean;
  433. setBoxVisible(b: boolean): boolean;
  434. debug(b: boolean): void;
  435. /** Returns some information about this mesh */
  436. getInfo(): string;
  437. /** Draw X, Y and Z axis for the actual object if this adapter.
  438. * Should be called only one time as it will fill this._axis
  439. */
  440. private _drawAxis();
  441. }
  442. }
  443. declare module INSPECTOR {
  444. interface SortDirection {
  445. [property: string]: number;
  446. }
  447. class DetailPanel extends BasicElement {
  448. private _headerRow;
  449. private _detailRows;
  450. private _sortDirection;
  451. constructor(dr?: Array<PropertyLine>);
  452. details: Array<PropertyLine>;
  453. protected _build(): void;
  454. /** Updates the HTML of the detail panel */
  455. update(): void;
  456. /** Add all lines in the html div. Does not sort them! */
  457. private _addDetails();
  458. /**
  459. * Sort the details row by comparing the given property of each row
  460. */
  461. private _sortDetails(property, _direction?);
  462. /**
  463. * Removes all data in the detail panel but keep the header row
  464. */
  465. clean(): void;
  466. /** Overrides basicelement.dispose */
  467. dispose(): void;
  468. /**
  469. * Creates the header row : name, value, id
  470. */
  471. private _createHeaderRow();
  472. }
  473. }
  474. declare module INSPECTOR {
  475. /**
  476. * A property is a link between a data (string) and an object.
  477. */
  478. class Property {
  479. /** The property name */
  480. private _property;
  481. /** The obj this property refers to */
  482. private _obj;
  483. constructor(prop: string, obj: any);
  484. readonly name: string;
  485. value: any;
  486. readonly type: string;
  487. obj: any;
  488. }
  489. }
  490. declare module INSPECTOR {
  491. class PropertyFormatter {
  492. /**
  493. * Format the value of the given property of the given object.
  494. */
  495. static format(obj: any, prop: string): string;
  496. }
  497. /**
  498. * A property line represents a line in the detail panel. This line is composed of :
  499. * - a name (the property name)
  500. * - a value if this property is of a type 'simple' : string, number, boolean, color, texture
  501. * - the type of the value if this property is of a complex type (Vector2, Size, ...)
  502. * - a ID if defined (otherwise an empty string is displayed)
  503. * The original object is sent to the value object who will update it at will.
  504. *
  505. * A property line can contain OTHER property line objects in the case of a complex type.
  506. * If this instance has no link to other instances, its type is ALWAYS a simple one (see above).
  507. *
  508. */
  509. class PropertyLine {
  510. private _property;
  511. private _div;
  512. private _valueDiv;
  513. private _children;
  514. private static _SIMPLE_TYPE;
  515. private static _MARGIN_LEFT;
  516. private _level;
  517. /** The list of viewer element displayed at the end of the line (color, texture...) */
  518. private _elements;
  519. /** The property parent of this one. Used to update the value of this property and to retrieve the correct object */
  520. private _parent;
  521. /** The input element to display if this property is 'simple' in order to update it */
  522. private _input;
  523. /** Display input handler (stored to be removed afterwards) */
  524. private _displayInputHandler;
  525. /** Handler used to validate the input by pressing 'enter' */
  526. private _validateInputHandler;
  527. /** Handler used to validate the input by pressing 'esc' */
  528. private _escapeInputHandler;
  529. constructor(prop: Property, parent?: PropertyLine, level?: number);
  530. /**
  531. * Init the input element and al its handler :
  532. * - a click in the window remove the input and restore the old property value
  533. * - enters updates the property
  534. */
  535. private _initInput();
  536. /**
  537. * On enter : validates the new value and removes the input
  538. * On escape : removes the input
  539. */
  540. private _validateInput(e);
  541. /**
  542. * On escape : removes the input
  543. */
  544. private _escapeInput(e);
  545. /** Removes the input without validating the new value */
  546. private _removeInputWithoutValidating();
  547. /** Replaces the default display with an input */
  548. private _displayInput(e);
  549. /** Retrieve the correct object from its parent.
  550. * If no parent exists, returns the property value.
  551. * This method is used at each update in case the property object is removed from the original object
  552. * (example : mesh.position = new BABYLON.Vector3 ; the original vector3 object is deleted from the mesh).
  553. */
  554. updateObject(): any;
  555. readonly name: string;
  556. readonly value: any;
  557. readonly type: string;
  558. /**
  559. * Creates elements that wil be displayed on a property line, depending on the
  560. * type of the property.
  561. */
  562. private _createElements();
  563. private _displayValueContent();
  564. /** Delete properly this property line.
  565. * Removes itself from the scheduler.
  566. * Dispose all viewer element (color, texture...)
  567. */
  568. dispose(): void;
  569. /** Updates the content of _valueDiv with the value of the property,
  570. * and all HTML element correpsonding to this type.
  571. * Elements are updated as well
  572. */
  573. private _updateValue();
  574. /**
  575. * Update the property division with the new property value.
  576. * If this property is complex, update its child, otherwise update its text content
  577. */
  578. update(): void;
  579. /**
  580. * Returns true if the given instance is a simple type
  581. */
  582. private static _IS_TYPE_SIMPLE(inst);
  583. /**
  584. * Returns true if the type of this property is simple, false otherwise.
  585. * Returns true if the value is null
  586. */
  587. private _isSimple();
  588. toHtml(): HTMLElement;
  589. /**
  590. * Add sub properties in case of a complex type
  591. */
  592. private _addDetails();
  593. }
  594. }
  595. declare module INSPECTOR {
  596. /**
  597. * Display a very small div corresponding to the given color
  598. */
  599. class ColorElement extends BasicElement {
  600. constructor(color: BABYLON.Color4 | BABYLON.Color3);
  601. update(color?: BABYLON.Color4 | BABYLON.Color3): void;
  602. private _toRgba(color);
  603. }
  604. }
  605. declare module INSPECTOR {
  606. /**
  607. * Display a very small div. A new canvas is created, with a new Babylon.js scene, containing only the
  608. * cube texture in a cube
  609. */
  610. class CubeTextureElement extends BasicElement {
  611. /** The big div displaying the full image */
  612. private _textureDiv;
  613. private _engine;
  614. protected _scene: BABYLON.Scene;
  615. protected _cube: BABYLON.Mesh;
  616. private _canvas;
  617. protected _textureUrl: string;
  618. private _pause;
  619. /** The texture given as a parameter should be cube. */
  620. constructor(tex: BABYLON.Texture);
  621. update(tex?: BABYLON.Texture): void;
  622. /** Creates the box */
  623. protected _populateScene(): void;
  624. /** Init the babylon engine */
  625. private _initEngine();
  626. private _showViewer(mode);
  627. /** Removes properly the babylon engine */
  628. dispose(): void;
  629. }
  630. }
  631. declare module INSPECTOR {
  632. /**
  633. * Display a very small div. A new canvas is created, with a new Babylon.js scene, containing only the
  634. * cube texture in a cube
  635. */
  636. class HDRCubeTextureElement extends CubeTextureElement {
  637. /** The texture given as a parameter should be cube. */
  638. constructor(tex: BABYLON.Texture);
  639. /** Creates the box */
  640. protected _populateScene(): void;
  641. }
  642. }
  643. declare module INSPECTOR {
  644. /**
  645. * A search bar can be used to filter elements in the tree panel.
  646. * At each keypress on the input, the treepanel will be filtered.
  647. */
  648. class SearchBar extends BasicElement {
  649. private _tab;
  650. private _inputElement;
  651. constructor(tab: PropertyTab);
  652. /** Delete all characters typped in the input element */
  653. reset(): void;
  654. update(): void;
  655. }
  656. }
  657. declare module INSPECTOR {
  658. /**
  659. * Display a very small div corresponding to the given texture. On mouse over, display the full image
  660. */
  661. class TextureElement extends BasicElement {
  662. /** The big div displaying the full image */
  663. private _textureDiv;
  664. constructor(tex: BABYLON.Texture);
  665. update(tex?: BABYLON.Texture): void;
  666. private _showViewer(mode);
  667. }
  668. }
  669. declare module INSPECTOR {
  670. /**
  671. * Creates a tooltip for the parent of the given html element
  672. */
  673. class Tooltip {
  674. /** The tooltip is displayed for this element */
  675. private _elem;
  676. /** The tooltip div */
  677. private _infoDiv;
  678. constructor(elem: HTMLElement, tip: string, attachTo?: HTMLElement);
  679. }
  680. }
  681. declare module INSPECTOR {
  682. class Helpers {
  683. /**
  684. * Returns the type of the given object. First
  685. * uses getClassName. If nothing is returned, used the type of the constructor
  686. */
  687. static GET_TYPE(obj: any): string;
  688. /**
  689. * Check if some properties are defined for the given type.
  690. */
  691. private static _CheckIfTypeExists(type);
  692. /**
  693. * Returns true if the user browser is edge.
  694. */
  695. static IsBrowserEdge(): boolean;
  696. /**
  697. * Returns the name of the type of the given object, where the name
  698. * is in PROPERTIES constant.
  699. * Returns 'Undefined' if no type exists for this object
  700. */
  701. private static _GetTypeFor(obj);
  702. /**
  703. * Returns the name of a function (workaround to get object type for IE11)
  704. */
  705. private static _GetFnName(fn);
  706. /** Send the event which name is given in parameter to the window */
  707. static SEND_EVENT(eventName: string): void;
  708. /** Returns the given number with 2 decimal number max if a decimal part exists */
  709. static Trunc(nb: any): number;
  710. /**
  711. * Useful function used to create a div
  712. */
  713. static CreateDiv(className?: string, parent?: HTMLElement): HTMLElement;
  714. static CreateElement(element: string, className?: string, parent?: HTMLElement): HTMLElement;
  715. /**
  716. * Removes all children of the given div.
  717. */
  718. static CleanDiv(div: HTMLElement): void;
  719. /**
  720. * 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)
  721. */
  722. static Css(elem: HTMLElement, cssAttribute: string): string;
  723. static LoadScript(): void;
  724. static IsSystemName(name: string): boolean;
  725. }
  726. }
  727. declare module INSPECTOR {
  728. class Scheduler {
  729. private static _instance;
  730. /** The number of the set interval */
  731. private _timer;
  732. /** Is this scheduler in pause ? */
  733. pause: boolean;
  734. /** All properties are refreshed every 250ms */
  735. static REFRESH_TIME: number;
  736. /** The list of data to update */
  737. private _updatableProperties;
  738. constructor();
  739. static getInstance(): Scheduler;
  740. /** Add a property line to be updated every X ms */
  741. add(prop: PropertyLine): void;
  742. /** Removes the given property from the list of properties to update */
  743. remove(prop: PropertyLine): void;
  744. private _update();
  745. }
  746. }
  747. declare module INSPECTOR {
  748. abstract class Tab extends BasicElement {
  749. protected _tabbar: TabBar;
  750. name: string;
  751. protected _isActive: boolean;
  752. protected _panel: HTMLDivElement;
  753. constructor(tabbar: TabBar, name: string);
  754. /** True if the tab is active, false otherwise */
  755. isActive(): boolean;
  756. protected _build(): void;
  757. /** Set this tab as active or not, depending on the current state */
  758. active(b: boolean): void;
  759. update(): void;
  760. /** Creates the tab panel for this tab. */
  761. getPanel(): HTMLElement;
  762. /** Add this in the propertytab with the searchbar */
  763. filter(str: string): void;
  764. /** Dispose properly this tab */
  765. abstract dispose(): any;
  766. /** Select an item in the tree */
  767. select(item: TreeItem): void;
  768. /**
  769. * Returns the total width in pixel of this tab, 0 by default
  770. */
  771. getPixelWidth(): number;
  772. }
  773. }
  774. declare module INSPECTOR {
  775. /**
  776. * A Property tab can creates two panels:
  777. * a tree panel and a detail panel,
  778. * in which properties will be displayed.
  779. * Both panels are separated by a resize bar
  780. */
  781. abstract class PropertyTab extends Tab {
  782. protected _inspector: Inspector;
  783. /** The panel containing a list of items */
  784. protected _treePanel: HTMLElement;
  785. /** The panel containing a list if properties corresponding to an item */
  786. protected _detailsPanel: DetailPanel;
  787. protected _treeItems: Array<TreeItem>;
  788. protected _searchBar: SearchBar;
  789. constructor(tabbar: TabBar, name: string, insp: Inspector);
  790. /** Overrides dispose */
  791. dispose(): void;
  792. update(_items?: Array<TreeItem>): void;
  793. /** Display the details of the given item */
  794. displayDetails(item: TreeItem): void;
  795. /** Select an item in the tree */
  796. select(item: TreeItem): void;
  797. /** Set the given item as active in the tree */
  798. activateNode(item: TreeItem): void;
  799. /** Returns the treeitem corersponding to the given obj, null if not found */
  800. getItemFor(_obj: any): TreeItem;
  801. filter(filter: string): void;
  802. /** Builds the tree panel */
  803. protected abstract _getTree(): Array<TreeItem>;
  804. }
  805. }
  806. declare module INSPECTOR {
  807. class CameraTab extends PropertyTab {
  808. constructor(tabbar: TabBar, inspector: Inspector);
  809. protected _getTree(): Array<TreeItem>;
  810. }
  811. }
  812. declare module INSPECTOR {
  813. class GUITab extends PropertyTab {
  814. constructor(tabbar: TabBar, inspector: Inspector);
  815. protected _getTree(): Array<TreeItem>;
  816. }
  817. }
  818. declare module INSPECTOR {
  819. class PhysicsTab extends PropertyTab {
  820. viewer: BABYLON.Debug.PhysicsViewer;
  821. constructor(tabbar: TabBar, inspector: Inspector);
  822. protected _getTree(): Array<TreeItem>;
  823. }
  824. }
  825. declare module INSPECTOR {
  826. class SoundTab extends PropertyTab {
  827. constructor(tabbar: TabBar, inspector: Inspector);
  828. protected _getTree(): Array<TreeItem>;
  829. }
  830. }
  831. declare module INSPECTOR {
  832. class TextureTab extends Tab {
  833. private _inspector;
  834. /** The panel containing a list of items */
  835. protected _treePanel: HTMLElement;
  836. protected _treeItems: Array<TreeItem>;
  837. private _imagePanel;
  838. constructor(tabbar: TabBar, inspector: Inspector);
  839. dispose(): void;
  840. update(_items?: Array<TreeItem>): void;
  841. private _getTree();
  842. /** Display the details of the given item */
  843. displayDetails(item: TreeItem): void;
  844. /** Select an item in the tree */
  845. select(item: TreeItem): void;
  846. /** Set the given item as active in the tree */
  847. activateNode(item: TreeItem): void;
  848. }
  849. }
  850. declare module INSPECTOR {
  851. class LightTab extends PropertyTab {
  852. constructor(tabbar: TabBar, inspector: Inspector);
  853. protected _getTree(): Array<TreeItem>;
  854. }
  855. }
  856. declare module INSPECTOR {
  857. class MaterialTab extends PropertyTab {
  858. constructor(tabbar: TabBar, inspector: Inspector);
  859. protected _getTree(): Array<TreeItem>;
  860. }
  861. }
  862. declare module INSPECTOR {
  863. class MeshTab extends PropertyTab {
  864. constructor(tabbar: TabBar, inspector: Inspector);
  865. protected _getTree(): Array<TreeItem>;
  866. }
  867. }
  868. declare module INSPECTOR {
  869. class SceneTab extends Tab {
  870. private _inspector;
  871. /** The list of channels/options that can be activated/deactivated */
  872. private _actions;
  873. /** The list of skeleton viewer */
  874. private _skeletonViewers;
  875. /** The detail of the scene */
  876. private _detailsPanel;
  877. constructor(tabbar: TabBar, insp: Inspector);
  878. /** Overrides super.dispose */
  879. dispose(): void;
  880. /** generates a div which correspond to an option that can be activated/deactivated */
  881. private _generateActionLine(name, initValue, action);
  882. /**
  883. * Add a click action for all given elements :
  884. * the clicked element is set as active, all others elements are deactivated
  885. */
  886. private _generateRadioAction(arr);
  887. }
  888. }
  889. declare module INSPECTOR {
  890. /**
  891. * The console tab will have two features :
  892. * - hook all console.log call and display them in this panel (and in the browser console as well)
  893. * - display all Babylon logs (called with Tools.Log...)
  894. */
  895. class ConsoleTab extends Tab {
  896. private _inspector;
  897. private _consolePanelContent;
  898. private _bjsPanelContent;
  899. private _oldConsoleLog;
  900. private _oldConsoleWarn;
  901. private _oldConsoleError;
  902. constructor(tabbar: TabBar, insp: Inspector);
  903. /** Overrides super.dispose */
  904. dispose(): void;
  905. active(b: boolean): void;
  906. private _message(type, message, caller);
  907. private _addConsoleLog(...params);
  908. private _addConsoleWarn(...params);
  909. private _addConsoleError(...params);
  910. }
  911. }
  912. declare module INSPECTOR {
  913. class StatsTab extends Tab {
  914. private _inspector;
  915. /**
  916. * Properties in this array will be updated
  917. * in a render loop - Mostly stats properties
  918. */
  919. private _updatableProperties;
  920. private _scene;
  921. private _engine;
  922. private _glInfo;
  923. private _updateLoopHandler;
  924. constructor(tabbar: TabBar, insp: Inspector);
  925. private _createStatLabel(content, parent);
  926. /** Update each properties of the stats panel */
  927. private _update();
  928. dispose(): void;
  929. active(b: boolean): void;
  930. }
  931. }
  932. declare module INSPECTOR {
  933. /**
  934. * A tab bar will contains each view the inspector can have : Canvas2D, Meshes...
  935. * The default active tab is the first one of the list.
  936. */
  937. class TabBar extends BasicElement {
  938. private _tabs;
  939. private _inspector;
  940. /** The tab displaying all meshes */
  941. private _meshTab;
  942. /** The toolbar */
  943. private _toolBar;
  944. /** The icon displayed at the end of the toolbar displaying a combo box of tabs not displayed */
  945. private _moreTabsIcon;
  946. /** The panel displayed when the 'more-tab' icon is selected */
  947. private _moreTabsPanel;
  948. /** The list of tab displayed by clicking on the remainingIcon */
  949. private _invisibleTabs;
  950. /** The list of tabs visible, displayed in the tab bar */
  951. private _visibleTabs;
  952. constructor(inspector: Inspector, initialTab?: number);
  953. update(): void;
  954. protected _build(): void;
  955. /**
  956. * Add a tab to the 'more-tabs' panel, displayed by clicking on the
  957. * 'more-tabs' icon
  958. */
  959. private _addInvisibleTabToPanel(tab);
  960. /** Dispose the current tab, set the given tab as active, and refresh the treeview */
  961. switchTab(tab: Tab): void;
  962. /** Display the mesh tab.
  963. * If a parameter is given, the given mesh details are displayed
  964. */
  965. switchMeshTab(mesh?: BABYLON.AbstractMesh): void;
  966. /** Returns the active tab */
  967. getActiveTab(): Tab;
  968. getActiveTabIndex(): number;
  969. readonly inspector: Inspector;
  970. /**
  971. * Returns the total width in pixel of the tabbar,
  972. * that corresponds to the sum of the width of each visible tab + toolbar width
  973. */
  974. getPixelWidth(): number;
  975. /** Display the remaining icon or not depending on the tabbar width.
  976. * This function should be called each time the inspector width is updated
  977. */
  978. updateWidth(): void;
  979. }
  980. }
  981. declare module INSPECTOR {
  982. abstract class AbstractTool {
  983. private _elem;
  984. protected _inspector: Inspector;
  985. constructor(icon: string, parent: HTMLElement, inspector: Inspector, tooltip: string);
  986. toHtml(): HTMLElement;
  987. /**
  988. * Returns the total width in pixel of this tool, 0 by default
  989. */
  990. getPixelWidth(): number;
  991. /**
  992. * Updates the icon of this tool with the given string
  993. */
  994. protected _updateIcon(icon: string): void;
  995. abstract action(): any;
  996. }
  997. }
  998. declare module INSPECTOR {
  999. class PauseScheduleTool extends AbstractTool {
  1000. private _isPause;
  1001. constructor(parent: HTMLElement, inspector: Inspector);
  1002. action(): void;
  1003. }
  1004. }
  1005. declare module INSPECTOR {
  1006. class PickTool extends AbstractTool {
  1007. private _isActive;
  1008. private _pickHandler;
  1009. constructor(parent: HTMLElement, inspector: Inspector);
  1010. action(): void;
  1011. /** Deactivate this tool */
  1012. private _deactivate();
  1013. /** Pick a mesh in the scene */
  1014. private _pickMesh(evt);
  1015. private _updatePointerPosition(evt);
  1016. }
  1017. }
  1018. declare module INSPECTOR {
  1019. class PopupTool extends AbstractTool {
  1020. constructor(parent: HTMLElement, inspector: Inspector);
  1021. action(): void;
  1022. }
  1023. }
  1024. declare module INSPECTOR {
  1025. class RefreshTool extends AbstractTool {
  1026. constructor(parent: HTMLElement, inspector: Inspector);
  1027. action(): void;
  1028. }
  1029. }
  1030. declare module INSPECTOR {
  1031. class LabelTool extends AbstractTool {
  1032. /** True if label are displayed, false otherwise */
  1033. private _isDisplayed;
  1034. private _advancedTexture;
  1035. private _labelInitialized;
  1036. private _scene;
  1037. private _guiLoaded;
  1038. constructor(parent: HTMLElement, inspector: Inspector);
  1039. dispose(): void;
  1040. private _checkGUILoaded();
  1041. private _initializeLabels();
  1042. private _createLabel(mesh);
  1043. private _removeLabel(mesh);
  1044. action(): void;
  1045. }
  1046. }
  1047. declare module INSPECTOR {
  1048. class Toolbar extends BasicElement {
  1049. private _inspector;
  1050. private _tools;
  1051. constructor(inspector: Inspector);
  1052. update(): void;
  1053. protected _build(): void;
  1054. private _addTools();
  1055. /**
  1056. * Returns the total width in pixel of the tabbar,
  1057. * that corresponds to the sum of the width of each tab + toolbar width
  1058. */
  1059. getPixelWidth(): number;
  1060. }
  1061. }
  1062. declare module INSPECTOR {
  1063. /**
  1064. * Removes the inspector panel
  1065. */
  1066. class DisposeTool extends AbstractTool {
  1067. constructor(parent: HTMLElement, inspector: Inspector);
  1068. action(): void;
  1069. }
  1070. }
  1071. declare module INSPECTOR {
  1072. class TreeItem extends BasicElement {
  1073. private _tab;
  1074. private _adapter;
  1075. private _tools;
  1076. children: Array<TreeItem>;
  1077. private _lineContent;
  1078. constructor(tab: Tab, obj: Adapter);
  1079. /** Returns the item ID == its adapter ID */
  1080. readonly id: string;
  1081. /** Add the given item as a child of this one */
  1082. add(child: TreeItem): void;
  1083. /**
  1084. * Returns the original adapter
  1085. */
  1086. readonly adapter: Adapter;
  1087. /**
  1088. * Function used to compare this item to another tree item.
  1089. * Returns the alphabetical sort of the adapter ID
  1090. */
  1091. compareTo(item: TreeItem): number;
  1092. /** Returns true if the given obj correspond to the adapter linked to this tree item */
  1093. correspondsTo(obj: any): boolean;
  1094. /** hide all children of this item */
  1095. fold(): void;
  1096. /** Show all children of this item */
  1097. unfold(): void;
  1098. /** Build the HTML of this item */
  1099. protected _build(): void;
  1100. /**
  1101. * Returns one HTML element (.details) containing all details of this primitive
  1102. */
  1103. getDetails(): Array<PropertyLine>;
  1104. update(): void;
  1105. /**
  1106. * Add an event listener on the item :
  1107. * - one click display details
  1108. */
  1109. protected _addEvent(): void;
  1110. /** Returns true if the node is folded, false otherwise */
  1111. private _isFolded();
  1112. /** Set this item as active (background lighter) in the tree panel */
  1113. active(b: boolean): void;
  1114. }
  1115. }
  1116. declare module INSPECTOR {
  1117. abstract class AbstractTreeTool {
  1118. protected _elem: HTMLElement;
  1119. /** Is the tool enabled ? */
  1120. protected _on: boolean;
  1121. constructor();
  1122. toHtml(): HTMLElement;
  1123. protected _addEvents(): void;
  1124. /**
  1125. * Action launched when clicked on this element
  1126. * Should be overrided
  1127. */
  1128. protected action(): void;
  1129. }
  1130. }
  1131. declare module INSPECTOR {
  1132. /** Any object implementing this interface should
  1133. * provide methods to toggle its bounding box
  1134. */
  1135. interface IToolBoundingBox {
  1136. isBoxVisible: () => boolean;
  1137. setBoxVisible: (b: boolean) => void;
  1138. }
  1139. /**
  1140. * Checkbox to display/hide the primitive
  1141. */
  1142. class BoundingBox extends AbstractTreeTool {
  1143. private _obj;
  1144. constructor(obj: IToolBoundingBox);
  1145. protected action(): void;
  1146. private _check();
  1147. }
  1148. }
  1149. declare module INSPECTOR {
  1150. interface ICameraPOV {
  1151. setPOV: () => void;
  1152. }
  1153. /**
  1154. *
  1155. */
  1156. class CameraPOV extends AbstractTreeTool {
  1157. private cameraPOV;
  1158. constructor(camera: ICameraPOV);
  1159. protected action(): void;
  1160. private _gotoPOV();
  1161. }
  1162. }
  1163. declare module INSPECTOR {
  1164. interface ISoundInteractions {
  1165. setPlaying: (callback: Function) => void;
  1166. }
  1167. /**
  1168. *
  1169. */
  1170. class SoundInteractions extends AbstractTreeTool {
  1171. private playSound;
  1172. private b;
  1173. constructor(playSound: ISoundInteractions);
  1174. protected action(): void;
  1175. private _playSound();
  1176. }
  1177. }
  1178. declare module INSPECTOR {
  1179. /** Any object implementing this interface should
  1180. * provide methods to toggle its visibility
  1181. */
  1182. interface IToolVisible {
  1183. isVisible: () => boolean;
  1184. setVisible: (b: boolean) => void;
  1185. }
  1186. /**
  1187. * Checkbox to display/hide the primitive
  1188. */
  1189. class Checkbox extends AbstractTreeTool {
  1190. private _obj;
  1191. constructor(obj: IToolVisible);
  1192. protected action(): void;
  1193. private _check(dontEnable?);
  1194. }
  1195. }
  1196. declare module INSPECTOR {
  1197. /** Any object implementing this interface should
  1198. * provide methods to toggle a debug area
  1199. */
  1200. interface IToolDebug {
  1201. debug: (b: boolean) => void;
  1202. }
  1203. class DebugArea extends AbstractTreeTool {
  1204. private _obj;
  1205. constructor(obj: IToolDebug);
  1206. protected action(): void;
  1207. }
  1208. }
  1209. declare module INSPECTOR {
  1210. /** Any object implementing this interface should
  1211. * provide methods to retrieve its info
  1212. */
  1213. interface IToolInfo {
  1214. getInfo: () => string;
  1215. }
  1216. /**
  1217. * Checkbox to display/hide the primitive
  1218. */
  1219. class Info extends AbstractTreeTool {
  1220. private _obj;
  1221. private _tooltip;
  1222. constructor(obj: IToolInfo);
  1223. protected action(): void;
  1224. }
  1225. }