babylon.inspector.d.ts 43 KB

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