babylon.inspector.d.ts 42 KB

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