babylon.inspector.d.ts 43 KB

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