babylon.inspector.d.ts 43 KB

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