babylon.gui.module.d.ts 87 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390
  1. declare module 'babylonjs-gui' {
  2. export = BABYLON.GUI;
  3. }
  4. declare module BABYLON.GUI {
  5. /**
  6. * Define a style used by control to automatically setup properties based on a template.
  7. * Only support font related properties so far
  8. */
  9. class Style implements BABYLON.IDisposable {
  10. private _fontFamily;
  11. private _fontStyle;
  12. private _fontWeight;
  13. /** @hidden */
  14. _host: AdvancedDynamicTexture;
  15. /** @hidden */
  16. _fontSize: ValueAndUnit;
  17. /**
  18. * Observable raised when the style values are changed
  19. */
  20. onChangedObservable: Observable<Style>;
  21. /**
  22. * Creates a new style object
  23. * @param host defines the AdvancedDynamicTexture which hosts this style
  24. */
  25. constructor(host: AdvancedDynamicTexture);
  26. /**
  27. * Gets or sets the font size
  28. */
  29. fontSize: string | number;
  30. /**
  31. * Gets or sets the font family
  32. */
  33. fontFamily: string;
  34. /**
  35. * Gets or sets the font style
  36. */
  37. fontStyle: string;
  38. /** Gets or sets font weight */
  39. fontWeight: string;
  40. /** Dispose all associated resources */
  41. dispose(): void;
  42. }
  43. }
  44. declare module BABYLON.GUI {
  45. /**
  46. * Class used to specific a value and its associated unit
  47. */
  48. class ValueAndUnit {
  49. /** defines the unit to store */
  50. unit: number;
  51. /** defines a boolean indicating if the value can be negative */
  52. negativeValueAllowed: boolean;
  53. private _value;
  54. /**
  55. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  56. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  57. */
  58. ignoreAdaptiveScaling: boolean;
  59. /**
  60. * Creates a new ValueAndUnit
  61. * @param value defines the value to store
  62. * @param unit defines the unit to store
  63. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  64. */
  65. constructor(value: number,
  66. /** defines the unit to store */
  67. unit?: number,
  68. /** defines a boolean indicating if the value can be negative */
  69. negativeValueAllowed?: boolean);
  70. /** Gets a boolean indicating if the value is a percentage */
  71. readonly isPercentage: boolean;
  72. /** Gets a boolean indicating if the value is store as pixel */
  73. readonly isPixel: boolean;
  74. /** Gets direct internal value */
  75. readonly internalValue: number;
  76. /**
  77. * Gets value as pixel
  78. * @param host defines the root host
  79. * @param refValue defines the reference value for percentages
  80. * @returns the value as pixel
  81. */
  82. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  83. /**
  84. * Gets the value accordingly to its unit
  85. * @param host defines the root host
  86. * @returns the value
  87. */
  88. getValue(host: AdvancedDynamicTexture): number;
  89. /**
  90. * Gets a string representation of the value
  91. * @param host defines the root host
  92. * @returns a string
  93. */
  94. toString(host: AdvancedDynamicTexture): string;
  95. /**
  96. * Store a value parsed from a string
  97. * @param source defines the source string
  98. * @returns true if the value was successfully parsed
  99. */
  100. fromString(source: string | number): boolean;
  101. private static _Regex;
  102. private static _UNITMODE_PERCENTAGE;
  103. private static _UNITMODE_PIXEL;
  104. /** UNITMODE_PERCENTAGE */
  105. static readonly UNITMODE_PERCENTAGE: number;
  106. /** UNITMODE_PIXEL */
  107. static readonly UNITMODE_PIXEL: number;
  108. }
  109. }
  110. /**
  111. * This module hosts all controls for 2D and 3D GUIs
  112. * @see http://doc.babylonjs.com/how_to/gui
  113. */
  114. declare module BABYLON.GUI {
  115. /**
  116. * Interface used to define a control that can receive focus
  117. */
  118. interface IFocusableControl {
  119. /**
  120. * Function called when the control receives the focus
  121. */
  122. onFocus(): void;
  123. /**
  124. * Function called when the control loses the focus
  125. */
  126. onBlur(): void;
  127. /**
  128. * Function called to let the control handle keyboard events
  129. * @param evt defines the current keyboard event
  130. */
  131. processKeyboard(evt: KeyboardEvent): void;
  132. }
  133. /**
  134. * Class used to create texture to support 2D GUI elements
  135. * @see http://doc.babylonjs.com/how_to/gui
  136. */
  137. class AdvancedDynamicTexture extends DynamicTexture {
  138. private _isDirty;
  139. private _renderObserver;
  140. private _resizeObserver;
  141. private _preKeyboardObserver;
  142. private _pointerMoveObserver;
  143. private _pointerObserver;
  144. private _canvasPointerOutObserver;
  145. private _background;
  146. /** @hidden */
  147. _rootContainer: Container;
  148. /** @hidden */
  149. _lastPickedControl: Control;
  150. /** @hidden */
  151. _lastControlOver: {
  152. [pointerId: number]: Control;
  153. };
  154. /** @hidden */
  155. _lastControlDown: {
  156. [pointerId: number]: Control;
  157. };
  158. /** @hidden */
  159. _capturingControl: {
  160. [pointerId: number]: Control;
  161. };
  162. /** @hidden */
  163. _shouldBlockPointer: boolean;
  164. /** @hidden */
  165. _layerToDispose: Nullable<Layer>;
  166. /** @hidden */
  167. _linkedControls: Control[];
  168. private _isFullscreen;
  169. private _fullscreenViewport;
  170. private _idealWidth;
  171. private _idealHeight;
  172. private _useSmallestIdeal;
  173. private _renderAtIdealSize;
  174. private _focusedControl;
  175. private _blockNextFocusCheck;
  176. private _renderScale;
  177. /**
  178. * Gets or sets a boolean defining if alpha is stored as premultiplied
  179. */
  180. premulAlpha: boolean;
  181. /**
  182. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  183. * Useful when you want more antialiasing
  184. */
  185. renderScale: number;
  186. /** Gets or sets the background color */
  187. background: string;
  188. /**
  189. * Gets or sets the ideal width used to design controls.
  190. * The GUI will then rescale everything accordingly
  191. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  192. */
  193. idealWidth: number;
  194. /**
  195. * Gets or sets the ideal height used to design controls.
  196. * The GUI will then rescale everything accordingly
  197. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  198. */
  199. idealHeight: number;
  200. /**
  201. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  202. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  203. */
  204. useSmallestIdeal: boolean;
  205. /**
  206. * Gets or sets a boolean indicating if adaptive scaling must be used
  207. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  208. */
  209. renderAtIdealSize: boolean;
  210. /**
  211. * Gets the underlying layer used to render the texture when in fullscreen mode
  212. */
  213. readonly layer: Nullable<Layer>;
  214. /**
  215. * Gets the root container control
  216. */
  217. readonly rootContainer: Container;
  218. /**
  219. * Gets or sets the current focused control
  220. */
  221. focusedControl: Nullable<IFocusableControl>;
  222. /**
  223. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  224. */
  225. isForeground: boolean;
  226. /**
  227. * Creates a new AdvancedDynamicTexture
  228. * @param name defines the name of the texture
  229. * @param width defines the width of the texture
  230. * @param height defines the height of the texture
  231. * @param scene defines the hosting scene
  232. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  233. * @param samplingMode defines the texture sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  234. */
  235. constructor(name: string, width: number | undefined, height: number | undefined, scene: Nullable<Scene>, generateMipMaps?: boolean, samplingMode?: number);
  236. /**
  237. * Function used to execute a function on all controls
  238. * @param func defines the function to execute
  239. * @param container defines the container where controls belong. If null the root container will be used
  240. */
  241. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  242. /**
  243. * Marks the texture as dirty forcing a complete update
  244. */
  245. markAsDirty(): void;
  246. /**
  247. * Helper function used to create a new style
  248. * @returns a new style
  249. * @see http://doc.babylonjs.com/how_to/gui#styles
  250. */
  251. createStyle(): Style;
  252. /**
  253. * Adds a new control to the root container
  254. * @param control defines the control to add
  255. * @returns the current texture
  256. */
  257. addControl(control: Control): AdvancedDynamicTexture;
  258. /**
  259. * Removes a control from the root container
  260. * @param control defines the control to remove
  261. * @returns the current texture
  262. */
  263. removeControl(control: Control): AdvancedDynamicTexture;
  264. /**
  265. * Release all resources
  266. */
  267. dispose(): void;
  268. private _onResize();
  269. /** @hidden */
  270. _getGlobalViewport(scene: Scene): Viewport;
  271. /**
  272. * Get screen coordinates for a vector3
  273. * @param position defines the position to project
  274. * @param worldMatrix defines the world matrix to use
  275. * @returns the projected position
  276. */
  277. getProjectedPosition(position: Vector3, worldMatrix: Matrix): Vector2;
  278. private _checkUpdate(camera);
  279. private _render();
  280. private _doPicking(x, y, type, pointerId, buttonIndex);
  281. /** @hidden */
  282. _cleanControlAfterRemovalFromList(list: {
  283. [pointerId: number]: Control;
  284. }, control: Control): void;
  285. /** @hidden */
  286. _cleanControlAfterRemoval(control: Control): void;
  287. /** Attach to all scene events required to support pointer events */
  288. attach(): void;
  289. /**
  290. * Connect the texture to a hosting mesh to enable interactions
  291. * @param mesh defines the mesh to attach to
  292. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  293. */
  294. attachToMesh(mesh: AbstractMesh, supportPointerMove?: boolean): void;
  295. /**
  296. * Move the focus to a specific control
  297. * @param control defines the control which will receive the focus
  298. */
  299. moveFocusToControl(control: IFocusableControl): void;
  300. private _manageFocus();
  301. private _attachToOnPointerOut(scene);
  302. /**
  303. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  304. * @param mesh defines the mesh which will receive the texture
  305. * @param width defines the texture width (1024 by default)
  306. * @param height defines the texture height (1024 by default)
  307. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  308. * @returns a new AdvancedDynamicTexture
  309. */
  310. static CreateForMesh(mesh: AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean): AdvancedDynamicTexture;
  311. /**
  312. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  313. * In this mode the texture will rely on a layer for its rendering.
  314. * This allows it to be treated like any other layer.
  315. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  316. * LayerMask is set through advancedTexture.layer.layerMask
  317. * @param name defines name for the texture
  318. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  319. * @param scene defines the hsoting scene
  320. * @param sampling defines the texture sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  321. * @returns a new AdvancedDynamicTexture
  322. */
  323. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: Nullable<Scene>, sampling?: number): AdvancedDynamicTexture;
  324. }
  325. }
  326. declare module BABYLON.GUI {
  327. /**
  328. * Class used to store 2D control sizes
  329. */
  330. class Measure {
  331. /** defines left coordinate */
  332. left: number;
  333. /** defines top coordinate */
  334. top: number;
  335. /** defines width dimension */
  336. width: number;
  337. /** defines height dimension */
  338. height: number;
  339. /**
  340. * Creates a new measure
  341. * @param left defines left coordinate
  342. * @param top defines top coordinate
  343. * @param width defines width dimension
  344. * @param height defines height dimension
  345. */
  346. constructor(
  347. /** defines left coordinate */
  348. left: number,
  349. /** defines top coordinate */
  350. top: number,
  351. /** defines width dimension */
  352. width: number,
  353. /** defines height dimension */
  354. height: number);
  355. /**
  356. * Copy from another measure
  357. * @param other defines the other measure to copy from
  358. */
  359. copyFrom(other: Measure): void;
  360. /**
  361. * Check equality between this measure and another one
  362. * @param other defines the other measures
  363. * @returns true if both measures are equals
  364. */
  365. isEqualsTo(other: Measure): boolean;
  366. /**
  367. * Creates an empty measure
  368. * @returns a new measure
  369. */
  370. static Empty(): Measure;
  371. }
  372. }
  373. declare module BABYLON.GUI {
  374. /**
  375. * Class used to transport Vector2 information for pointer events
  376. */
  377. class Vector2WithInfo extends Vector2 {
  378. /** defines the current mouse button index */
  379. buttonIndex: number;
  380. /**
  381. * Creates a new Vector2WithInfo
  382. * @param source defines the vector2 data to transport
  383. * @param buttonIndex defines the current mouse button index
  384. */
  385. constructor(source: Vector2,
  386. /** defines the current mouse button index */
  387. buttonIndex?: number);
  388. }
  389. /** Class used to provide 2D matrix features */
  390. class Matrix2D {
  391. /** Gets the internal array of 6 floats used to store matrix data */
  392. m: Float32Array;
  393. /**
  394. * Creates a new matrix
  395. * @param m00 defines value for (0, 0)
  396. * @param m01 defines value for (0, 1)
  397. * @param m10 defines value for (1, 0)
  398. * @param m11 defines value for (1, 1)
  399. * @param m20 defines value for (2, 0)
  400. * @param m21 defines value for (2, 1)
  401. */
  402. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  403. /**
  404. * Fills the matrix from direct values
  405. * @param m00 defines value for (0, 0)
  406. * @param m01 defines value for (0, 1)
  407. * @param m10 defines value for (1, 0)
  408. * @param m11 defines value for (1, 1)
  409. * @param m20 defines value for (2, 0)
  410. * @param m21 defines value for (2, 1)
  411. * @returns the current modified matrix
  412. */
  413. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  414. /**
  415. * Gets matrix determinant
  416. * @returns the determinant
  417. */
  418. determinant(): number;
  419. /**
  420. * Inverses the matrix and stores it in a target matrix
  421. * @param result defines the target matrix
  422. * @returns the current matrix
  423. */
  424. invertToRef(result: Matrix2D): Matrix2D;
  425. /**
  426. * Multiplies the current matrix with another one
  427. * @param other defines the second operand
  428. * @param result defines the target matrix
  429. * @returns the current matrix
  430. */
  431. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  432. /**
  433. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  434. * @param x defines the x coordinate to transform
  435. * @param y defines the x coordinate to transform
  436. * @param result defines the target vector2
  437. * @returns the current matrix
  438. */
  439. transformCoordinates(x: number, y: number, result: Vector2): Matrix2D;
  440. /**
  441. * Creates an identity matrix
  442. * @returns a new matrix
  443. */
  444. static Identity(): Matrix2D;
  445. /**
  446. * Creates a translation matrix and stores it in a target matrix
  447. * @param x defines the x coordinate of the translation
  448. * @param y defines the y coordinate of the translation
  449. * @param result defines the target matrix
  450. */
  451. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  452. /**
  453. * Creates a scaling matrix and stores it in a target matrix
  454. * @param x defines the x coordinate of the scaling
  455. * @param y defines the y coordinate of the scaling
  456. * @param result defines the target matrix
  457. */
  458. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  459. /**
  460. * Creates a rotation matrix and stores it in a target matrix
  461. * @param angle defines the rotation angle
  462. * @param result defines the target matrix
  463. */
  464. static RotationToRef(angle: number, result: Matrix2D): void;
  465. private static _TempPreTranslationMatrix;
  466. private static _TempPostTranslationMatrix;
  467. private static _TempRotationMatrix;
  468. private static _TempScalingMatrix;
  469. private static _TempCompose0;
  470. private static _TempCompose1;
  471. private static _TempCompose2;
  472. /**
  473. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  474. * @param tx defines the x coordinate of the translation
  475. * @param ty defines the y coordinate of the translation
  476. * @param angle defines the rotation angle
  477. * @param scaleX defines the x coordinate of the scaling
  478. * @param scaleY defines the y coordinate of the scaling
  479. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  480. * @param result defines the target matrix
  481. */
  482. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: Nullable<Matrix2D>, result: Matrix2D): void;
  483. }
  484. }
  485. declare module BABYLON.GUI {
  486. /**
  487. * Class used to store a point for a MultiLine object.
  488. * The point can be pure 2D coordinates, a mesh or a control
  489. */
  490. class MultiLinePoint {
  491. private _multiLine;
  492. private _x;
  493. private _y;
  494. private _control;
  495. private _mesh;
  496. private _controlObserver;
  497. private _meshObserver;
  498. /** @hidden */
  499. _point: Vector2;
  500. /**
  501. * Creates a new MultiLinePoint
  502. * @param multiLine defines the source MultiLine object
  503. */
  504. constructor(multiLine: MultiLine);
  505. /** Gets or sets x coordinate */
  506. x: string | number;
  507. /** Gets or sets y coordinate */
  508. y: string | number;
  509. /** Gets or sets the control associated with this point */
  510. control: Nullable<Control>;
  511. /** Gets or sets the mesh associated with this point */
  512. mesh: Nullable<AbstractMesh>;
  513. /**
  514. * Gets a translation vector
  515. * @returns the translation vector
  516. */
  517. translate(): Vector2;
  518. private _translatePoint();
  519. /** Release associated resources */
  520. dispose(): void;
  521. }
  522. }
  523. declare module BABYLON.GUI {
  524. /**
  525. * Root class used for all 2D controls
  526. * @see http://doc.babylonjs.com/how_to/gui#controls
  527. */
  528. class Control {
  529. /** defines the name of the control */
  530. name: string | undefined;
  531. private _alpha;
  532. private _alphaSet;
  533. private _zIndex;
  534. /** @hidden */
  535. _root: Nullable<Container>;
  536. /** @hidden */
  537. _host: AdvancedDynamicTexture;
  538. /** Gets or sets the control parent */
  539. parent: Nullable<Container>;
  540. /** @hidden */
  541. _currentMeasure: Measure;
  542. private _fontFamily;
  543. private _fontStyle;
  544. private _fontWeight;
  545. private _fontSize;
  546. private _font;
  547. /** @hidden */
  548. _width: ValueAndUnit;
  549. /** @hidden */
  550. _height: ValueAndUnit;
  551. /** @hidden */
  552. protected _fontOffset: {
  553. ascent: number;
  554. height: number;
  555. descent: number;
  556. };
  557. private _color;
  558. private _style;
  559. private _styleObserver;
  560. /** @hidden */
  561. protected _horizontalAlignment: number;
  562. /** @hidden */
  563. protected _verticalAlignment: number;
  564. private _isDirty;
  565. /** @hidden */
  566. _tempParentMeasure: Measure;
  567. /** @hidden */
  568. protected _cachedParentMeasure: Measure;
  569. private _paddingLeft;
  570. private _paddingRight;
  571. private _paddingTop;
  572. private _paddingBottom;
  573. /** @hidden */
  574. _left: ValueAndUnit;
  575. /** @hidden */
  576. _top: ValueAndUnit;
  577. private _scaleX;
  578. private _scaleY;
  579. private _rotation;
  580. private _transformCenterX;
  581. private _transformCenterY;
  582. private _transformMatrix;
  583. /** @hidden */
  584. protected _invertTransformMatrix: Matrix2D;
  585. /** @hidden */
  586. protected _transformedPosition: Vector2;
  587. private _onlyMeasureMode;
  588. private _isMatrixDirty;
  589. private _cachedOffsetX;
  590. private _cachedOffsetY;
  591. private _isVisible;
  592. /** @hidden */
  593. _linkedMesh: Nullable<AbstractMesh>;
  594. private _fontSet;
  595. private _dummyVector2;
  596. private _downCount;
  597. private _enterCount;
  598. private _doNotRender;
  599. private _downPointerIds;
  600. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  601. isHitTestVisible: boolean;
  602. /** Gets or sets a boolean indicating if the control can block pointer events */
  603. isPointerBlocker: boolean;
  604. /** Gets or sets a boolean indicating if the control can be focusable */
  605. isFocusInvisible: boolean;
  606. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  607. shadowOffsetX: number;
  608. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  609. shadowOffsetY: number;
  610. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  611. shadowBlur: number;
  612. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  613. shadowColor: string;
  614. /** @hidden */
  615. protected _linkOffsetX: ValueAndUnit;
  616. /** @hidden */
  617. protected _linkOffsetY: ValueAndUnit;
  618. /** Gets the control type name */
  619. readonly typeName: string;
  620. /**
  621. * An event triggered when the pointer move over the control.
  622. */
  623. onPointerMoveObservable: Observable<Vector2>;
  624. /**
  625. * An event triggered when the pointer move out of the control.
  626. */
  627. onPointerOutObservable: Observable<Control>;
  628. /**
  629. * An event triggered when the pointer taps the control
  630. */
  631. onPointerDownObservable: Observable<Vector2WithInfo>;
  632. /**
  633. * An event triggered when pointer up
  634. */
  635. onPointerUpObservable: Observable<Vector2WithInfo>;
  636. /**
  637. * An event triggered when a control is clicked on
  638. */
  639. onPointerClickObservable: Observable<Vector2WithInfo>;
  640. /**
  641. * An event triggered when pointer enters the control
  642. */
  643. onPointerEnterObservable: Observable<Control>;
  644. /**
  645. * An event triggered when the control is marked as dirty
  646. */
  647. onDirtyObservable: Observable<Control>;
  648. /**
  649. * An event triggered after the control is drawn
  650. */
  651. onAfterDrawObservable: Observable<Control>;
  652. /** Gets or set information about font offsets (used to render and align text) */
  653. fontOffset: {
  654. ascent: number;
  655. height: number;
  656. descent: number;
  657. };
  658. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  659. alpha: number;
  660. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  661. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  662. */
  663. scaleX: number;
  664. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  665. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  666. */
  667. scaleY: number;
  668. /** Gets or sets the rotation angle (0 by default)
  669. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  670. */
  671. rotation: number;
  672. /** Gets or sets the transformation center on Y axis (0 by default)
  673. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  674. */
  675. transformCenterY: number;
  676. /** Gets or sets the transformation center on X axis (0 by default)
  677. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  678. */
  679. transformCenterX: number;
  680. /**
  681. * Gets or sets the horizontal alignment
  682. * @see http://doc.babylonjs.com/how_to/gui#alignments
  683. */
  684. horizontalAlignment: number;
  685. /**
  686. * Gets or sets the vertical alignment
  687. * @see http://doc.babylonjs.com/how_to/gui#alignments
  688. */
  689. verticalAlignment: number;
  690. /**
  691. * Gets or sets control width
  692. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  693. */
  694. width: string | number;
  695. /**
  696. * Gets control width in pixel
  697. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  698. */
  699. readonly widthInPixels: number;
  700. /**
  701. * Gets or sets control height
  702. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  703. */
  704. height: string | number;
  705. /**
  706. * Gets control height in pixel
  707. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  708. */
  709. readonly heightInPixels: number;
  710. /** Gets or set font family */
  711. fontFamily: string;
  712. /** Gets or sets font style */
  713. fontStyle: string;
  714. /** Gets or sets font weight */
  715. fontWeight: string;
  716. /**
  717. * Gets or sets style
  718. * @see http://doc.babylonjs.com/how_to/gui#styles
  719. */
  720. style: BABYLON.Nullable<Style>;
  721. /** @hidden */
  722. readonly _isFontSizeInPercentage: boolean;
  723. /** Gets font size in pixels */
  724. readonly fontSizeInPixels: number;
  725. /** Gets or sets font size */
  726. fontSize: string | number;
  727. /** Gets or sets foreground color */
  728. color: string;
  729. /** Gets or sets z index which is used to reorder controls on the z axis */
  730. zIndex: number;
  731. /** Gets or sets a boolean indicating if the control can be rendered */
  732. notRenderable: boolean;
  733. /** Gets or sets a boolean indicating if the control is visible */
  734. isVisible: boolean;
  735. /** Gets a boolean indicating that the control needs to update its rendering */
  736. readonly isDirty: boolean;
  737. /**
  738. * Gets or sets a value indicating the padding to use on the left of the control
  739. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  740. */
  741. paddingLeft: string | number;
  742. /**
  743. * Gets a value indicating the padding in pixels to use on the left of the control
  744. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  745. */
  746. readonly paddingLeftInPixels: number;
  747. /**
  748. * Gets or sets a value indicating the padding to use on the right of the control
  749. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  750. */
  751. paddingRight: string | number;
  752. /**
  753. * Gets a value indicating the padding in pixels to use on the right of the control
  754. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  755. */
  756. readonly paddingRightInPixels: number;
  757. /**
  758. * Gets or sets a value indicating the padding to use on the top of the control
  759. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  760. */
  761. paddingTop: string | number;
  762. /**
  763. * Gets a value indicating the padding in pixels to use on the top of the control
  764. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  765. */
  766. readonly paddingTopInPixels: number;
  767. /**
  768. * Gets or sets a value indicating the padding to use on the bottom of the control
  769. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  770. */
  771. paddingBottom: string | number;
  772. /**
  773. * Gets a value indicating the padding in pixels to use on the bottom of the control
  774. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  775. */
  776. readonly paddingBottomInPixels: number;
  777. /**
  778. * Gets or sets a value indicating the left coordinate of the control
  779. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  780. */
  781. left: string | number;
  782. /**
  783. * Gets a value indicating the left coordinate in pixels of the control
  784. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  785. */
  786. readonly leftInPixels: number;
  787. /**
  788. * Gets or sets a value indicating the top coordinate of the control
  789. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  790. */
  791. top: string | number;
  792. /**
  793. * Gets a value indicating the top coordinate in pixels of the control
  794. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  795. */
  796. readonly topInPixels: number;
  797. /**
  798. * Gets or sets a value indicating the offset on X axis to the linked mesh
  799. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  800. */
  801. linkOffsetX: string | number;
  802. /**
  803. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  804. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  805. */
  806. readonly linkOffsetXInPixels: number;
  807. /**
  808. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  809. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  810. */
  811. linkOffsetY: string | number;
  812. /**
  813. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  814. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  815. */
  816. readonly linkOffsetYInPixels: number;
  817. /** Gets the center coordinate on X axis */
  818. readonly centerX: number;
  819. /** Gets the center coordinate on Y axis */
  820. readonly centerY: number;
  821. /**
  822. * Creates a new control
  823. * @param name defines the name of the control
  824. */
  825. constructor(
  826. /** defines the name of the control */
  827. name?: string | undefined);
  828. /** @hidden */
  829. protected _getTypeName(): string;
  830. /** @hidden */
  831. _resetFontCache(): void;
  832. /**
  833. * Gets coordinates in local control space
  834. * @param globalCoordinates defines the coordinates to transform
  835. * @returns the new coordinates in local space
  836. */
  837. getLocalCoordinates(globalCoordinates: Vector2): Vector2;
  838. /**
  839. * Gets coordinates in local control space
  840. * @param globalCoordinates defines the coordinates to transform
  841. * @param result defines the target vector2 where to store the result
  842. * @returns the current control
  843. */
  844. getLocalCoordinatesToRef(globalCoordinates: Vector2, result: Vector2): Control;
  845. /**
  846. * Gets coordinates in parent local control space
  847. * @param globalCoordinates defines the coordinates to transform
  848. * @returns the new coordinates in parent local space
  849. */
  850. getParentLocalCoordinates(globalCoordinates: Vector2): Vector2;
  851. /**
  852. * Move the current control to a vector3 position projected onto the screen.
  853. * @param position defines the target position
  854. * @param scene defines the hosting scene
  855. */
  856. moveToVector3(position: Vector3, scene: Scene): void;
  857. /**
  858. * Link current control with a target mesh
  859. * @param mesh defines the mesh to link with
  860. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  861. */
  862. linkWithMesh(mesh: Nullable<AbstractMesh>): void;
  863. /** @hidden */
  864. _moveToProjectedPosition(projectedPosition: Vector3): void;
  865. /** @hidden */
  866. _markMatrixAsDirty(): void;
  867. /** @hidden */
  868. _markAsDirty(): void;
  869. /** @hidden */
  870. _markAllAsDirty(): void;
  871. /** @hidden */
  872. _link(root: Nullable<Container>, host: AdvancedDynamicTexture): void;
  873. /** @hidden */
  874. protected _transform(context: CanvasRenderingContext2D): void;
  875. /** @hidden */
  876. protected _applyStates(context: CanvasRenderingContext2D): void;
  877. /** @hidden */
  878. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  879. /** @hidden */
  880. protected _clip(context: CanvasRenderingContext2D): void;
  881. /** @hidden */
  882. _measure(): void;
  883. /** @hidden */
  884. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  885. /** @hidden */
  886. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  887. /** @hidden */
  888. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  889. /** @hidden */
  890. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  891. /**
  892. * Tests if a given coordinates belong to the current control
  893. * @param x defines x coordinate to test
  894. * @param y defines y coordinate to test
  895. * @returns true if the coordinates are inside the control
  896. */
  897. contains(x: number, y: number): boolean;
  898. /** @hidden */
  899. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  900. /** @hidden */
  901. _onPointerMove(target: Control, coordinates: Vector2): void;
  902. /** @hidden */
  903. _onPointerEnter(target: Control): boolean;
  904. /** @hidden */
  905. _onPointerOut(target: Control): void;
  906. /** @hidden */
  907. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  908. /** @hidden */
  909. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  910. /** @hidden */
  911. _forcePointerUp(pointerId?: Nullable<number>): void;
  912. /** @hidden */
  913. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  914. private _prepareFont();
  915. /** Releases associated resources */
  916. dispose(): void;
  917. private static _HORIZONTAL_ALIGNMENT_LEFT;
  918. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  919. private static _HORIZONTAL_ALIGNMENT_CENTER;
  920. private static _VERTICAL_ALIGNMENT_TOP;
  921. private static _VERTICAL_ALIGNMENT_BOTTOM;
  922. private static _VERTICAL_ALIGNMENT_CENTER;
  923. /** HORIZONTAL_ALIGNMENT_LEFT */
  924. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  925. /** HORIZONTAL_ALIGNMENT_RIGHT */
  926. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  927. /** HORIZONTAL_ALIGNMENT_CENTER */
  928. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  929. /** VERTICAL_ALIGNMENT_TOP */
  930. static readonly VERTICAL_ALIGNMENT_TOP: number;
  931. /** VERTICAL_ALIGNMENT_BOTTOM */
  932. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  933. /** VERTICAL_ALIGNMENT_CENTER */
  934. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  935. private static _FontHeightSizes;
  936. /** @hidden */
  937. static _GetFontOffset(font: string): {
  938. ascent: number;
  939. height: number;
  940. descent: number;
  941. };
  942. /**
  943. * Creates a stack panel that can be used to render headers
  944. * @param control defines the control to associate with the header
  945. * @param text defines the text of the header
  946. * @param size defines the size of the header
  947. * @param options defines options used to configure the header
  948. * @returns a new StackPanel
  949. */
  950. static AddHeader(control: Control, text: string, size: string | number, options: {
  951. isHorizontal: boolean;
  952. controlFirst: boolean;
  953. }): StackPanel;
  954. /** @hidden */
  955. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  956. }
  957. }
  958. declare module BABYLON.GUI {
  959. /**
  960. * Root class for 2D containers
  961. * @see http://doc.babylonjs.com/how_to/gui#containers
  962. */
  963. class Container extends Control {
  964. name: string | undefined;
  965. /** @hidden */
  966. protected _children: Control[];
  967. /** @hidden */
  968. protected _measureForChildren: Measure;
  969. /** @hidden */
  970. protected _background: string;
  971. /** @hidden */
  972. protected _adaptWidthToChildren: boolean;
  973. /** @hidden */
  974. protected _adaptHeightToChildren: boolean;
  975. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  976. adaptHeightToChildren: boolean;
  977. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  978. adaptWidthToChildren: boolean;
  979. /** Gets or sets background color */
  980. background: string;
  981. /** Gets the list of children */
  982. readonly children: Control[];
  983. /**
  984. * Creates a new Container
  985. * @param name defines the name of the container
  986. */
  987. constructor(name?: string | undefined);
  988. protected _getTypeName(): string;
  989. /**
  990. * Gets a child using its name
  991. * @param name defines the child name to look for
  992. * @returns the child control if found
  993. */
  994. getChildByName(name: string): Nullable<Control>;
  995. /**
  996. * Gets a child using its type and its name
  997. * @param name defines the child name to look for
  998. * @param type defines the child type to look for
  999. * @returns the child control if found
  1000. */
  1001. getChildByType(name: string, type: string): Nullable<Control>;
  1002. /**
  1003. * Search for a specific control in children
  1004. * @param control defines the control to look for
  1005. * @returns true if the control is in child list
  1006. */
  1007. containsControl(control: Control): boolean;
  1008. /**
  1009. * Adds a new control to the current container
  1010. * @param control defines the control to add
  1011. * @returns the current container
  1012. */
  1013. addControl(control: Nullable<Control>): Container;
  1014. /**
  1015. * Removes a control from the current container
  1016. * @param control defines the control to remove
  1017. * @returns the current container
  1018. */
  1019. removeControl(control: Control): Container;
  1020. /** @hidden */
  1021. _reOrderControl(control: Control): void;
  1022. /** @hidden */
  1023. _markMatrixAsDirty(): void;
  1024. /** @hidden */
  1025. _markAllAsDirty(): void;
  1026. /** @hidden */
  1027. protected _localDraw(context: CanvasRenderingContext2D): void;
  1028. /** @hidden */
  1029. _link(root: Nullable<Container>, host: AdvancedDynamicTexture): void;
  1030. /** @hidden */
  1031. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1032. /** @hidden */
  1033. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  1034. /** @hidden */
  1035. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  1036. /** @hidden */
  1037. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1038. /** Releases associated resources */
  1039. dispose(): void;
  1040. }
  1041. }
  1042. declare module BABYLON.GUI {
  1043. /**
  1044. * Class used to create a 2D stack panel container
  1045. */
  1046. class StackPanel extends Container {
  1047. name: string | undefined;
  1048. private _isVertical;
  1049. private _manualWidth;
  1050. private _manualHeight;
  1051. private _doNotTrackManualChanges;
  1052. private _tempMeasureStore;
  1053. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  1054. isVertical: boolean;
  1055. /** Gets or sets panel width */
  1056. width: string | number;
  1057. /** Gets or sets panel height */
  1058. height: string | number;
  1059. /**
  1060. * Creates a new StackPanel
  1061. * @param name defines control name
  1062. */
  1063. constructor(name?: string | undefined);
  1064. protected _getTypeName(): string;
  1065. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1066. }
  1067. }
  1068. declare module BABYLON.GUI {
  1069. /** Class used to create rectangle container */
  1070. class Rectangle extends Container {
  1071. name: string | undefined;
  1072. private _thickness;
  1073. private _cornerRadius;
  1074. /** Gets or sets border thickness */
  1075. thickness: number;
  1076. /** Gets or sets the corner radius angle */
  1077. cornerRadius: number;
  1078. /**
  1079. * Creates a new Rectangle
  1080. * @param name defines the control name
  1081. */
  1082. constructor(name?: string | undefined);
  1083. protected _getTypeName(): string;
  1084. protected _localDraw(context: CanvasRenderingContext2D): void;
  1085. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1086. private _drawRoundedRect(context, offset?);
  1087. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  1088. }
  1089. }
  1090. declare module BABYLON.GUI {
  1091. /** Class used to create 2D ellipse containers */
  1092. class Ellipse extends Container {
  1093. name: string | undefined;
  1094. private _thickness;
  1095. /** Gets or sets border thickness */
  1096. thickness: number;
  1097. /**
  1098. * Creates a new Ellipse
  1099. * @param name defines the control name
  1100. */
  1101. constructor(name?: string | undefined);
  1102. protected _getTypeName(): string;
  1103. protected _localDraw(context: CanvasRenderingContext2D): void;
  1104. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1105. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  1106. }
  1107. }
  1108. declare module BABYLON.GUI {
  1109. /** Class used to render 2D lines */
  1110. class Line extends Control {
  1111. name: string | undefined;
  1112. private _lineWidth;
  1113. private _x1;
  1114. private _y1;
  1115. private _x2;
  1116. private _y2;
  1117. private _dash;
  1118. private _connectedControl;
  1119. private _connectedControlDirtyObserver;
  1120. /** Gets or sets the dash pattern */
  1121. dash: Array<number>;
  1122. /** Gets or sets the control connected with the line end */
  1123. connectedControl: Control;
  1124. /** Gets or sets start coordinates on X axis */
  1125. x1: string | number;
  1126. /** Gets or sets start coordinates on Y axis */
  1127. y1: string | number;
  1128. /** Gets or sets end coordinates on X axis */
  1129. x2: string | number;
  1130. /** Gets or sets end coordinates on Y axis */
  1131. y2: string | number;
  1132. /** Gets or sets line width */
  1133. lineWidth: number;
  1134. /** Gets or sets horizontal alignment */
  1135. horizontalAlignment: number;
  1136. /** Gets or sets vertical alignment */
  1137. verticalAlignment: number;
  1138. private readonly _effectiveX2;
  1139. private readonly _effectiveY2;
  1140. /**
  1141. * Creates a new Line
  1142. * @param name defines the control name
  1143. */
  1144. constructor(name?: string | undefined);
  1145. protected _getTypeName(): string;
  1146. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1147. _measure(): void;
  1148. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1149. /**
  1150. * Move one end of the line given 3D cartesian coordinates.
  1151. * @param position Targeted world position
  1152. * @param scene Scene
  1153. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  1154. */
  1155. moveToVector3(position: Vector3, scene: Scene, end?: boolean): void;
  1156. /**
  1157. * Move one end of the line to a position in screen absolute space.
  1158. * @param projectedPosition Position in screen absolute space (X, Y)
  1159. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  1160. */
  1161. _moveToProjectedPosition(projectedPosition: Vector3, end?: boolean): void;
  1162. }
  1163. }
  1164. declare module BABYLON.GUI {
  1165. /**
  1166. * Class used to create slider controls
  1167. */
  1168. class Slider extends Control {
  1169. name: string | undefined;
  1170. private _thumbWidth;
  1171. private _minimum;
  1172. private _maximum;
  1173. private _value;
  1174. private _background;
  1175. private _borderColor;
  1176. private _barOffset;
  1177. private _isThumbCircle;
  1178. private _isThumbClamped;
  1179. /** Observable raised when the sldier value changes */
  1180. onValueChangedObservable: Observable<number>;
  1181. /** Gets or sets border color */
  1182. borderColor: string;
  1183. /** Gets or sets background color */
  1184. background: string;
  1185. /** Gets or sets main bar offset */
  1186. barOffset: string | number;
  1187. /** Gets main bar offset in pixels*/
  1188. readonly barOffsetInPixels: number;
  1189. /** Gets or sets thumb width */
  1190. thumbWidth: string | number;
  1191. /** Gets thumb width in pixels */
  1192. readonly thumbWidthInPixels: number;
  1193. /** Gets or sets minimum value */
  1194. minimum: number;
  1195. /** Gets or sets maximum value */
  1196. maximum: number;
  1197. /** Gets or sets current value */
  1198. value: number;
  1199. /** Gets or sets a boolean indicating if the thumb should be round or square */
  1200. isThumbCircle: boolean;
  1201. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  1202. isThumbClamped: boolean;
  1203. /**
  1204. * Creates a new Slider
  1205. * @param name defines the control name
  1206. */
  1207. constructor(name?: string | undefined);
  1208. protected _getTypeName(): string;
  1209. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1210. private _pointerIsDown;
  1211. private _updateValueFromPointer(x, y);
  1212. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1213. _onPointerMove(target: Control, coordinates: Vector2): void;
  1214. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  1215. }
  1216. }
  1217. declare module BABYLON.GUI {
  1218. /**
  1219. * Class used to represent a 2D checkbox
  1220. */
  1221. class Checkbox extends Control {
  1222. name: string | undefined;
  1223. private _isChecked;
  1224. private _background;
  1225. private _checkSizeRatio;
  1226. private _thickness;
  1227. /** Gets or sets border thickness */
  1228. thickness: number;
  1229. /**
  1230. * Observable raised when isChecked property changes
  1231. */
  1232. onIsCheckedChangedObservable: Observable<boolean>;
  1233. /** Gets or sets a value indicating the ratio between overall size and check size */
  1234. checkSizeRatio: number;
  1235. /** Gets or sets background color */
  1236. background: string;
  1237. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1238. isChecked: boolean;
  1239. /**
  1240. * Creates a new CheckBox
  1241. * @param name defines the control name
  1242. */
  1243. constructor(name?: string | undefined);
  1244. protected _getTypeName(): string;
  1245. /** @hidden */
  1246. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1247. /** @hidden */
  1248. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1249. }
  1250. }
  1251. declare module BABYLON.GUI {
  1252. /**
  1253. * Class used to create radio button controls
  1254. */
  1255. class RadioButton extends Control {
  1256. name: string | undefined;
  1257. private _isChecked;
  1258. private _background;
  1259. private _checkSizeRatio;
  1260. private _thickness;
  1261. /** Gets or sets border thickness */
  1262. thickness: number;
  1263. /** Gets or sets group name */
  1264. group: string;
  1265. /** Observable raised when isChecked is changed */
  1266. onIsCheckedChangedObservable: Observable<boolean>;
  1267. /** Gets or sets a value indicating the ratio between overall size and check size */
  1268. checkSizeRatio: number;
  1269. /** Gets or sets background color */
  1270. background: string;
  1271. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1272. isChecked: boolean;
  1273. /**
  1274. * Creates a new RadioButton
  1275. * @param name defines the control name
  1276. */
  1277. constructor(name?: string | undefined);
  1278. protected _getTypeName(): string;
  1279. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1280. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1281. }
  1282. }
  1283. declare module BABYLON.GUI {
  1284. /**
  1285. * Class used to create text block control
  1286. */
  1287. class TextBlock extends Control {
  1288. /**
  1289. * Defines the name of the control
  1290. */
  1291. name: string | undefined;
  1292. private _text;
  1293. private _textWrapping;
  1294. private _textHorizontalAlignment;
  1295. private _textVerticalAlignment;
  1296. private _lines;
  1297. private _resizeToFit;
  1298. private _lineSpacing;
  1299. private _outlineWidth;
  1300. private _outlineColor;
  1301. /**
  1302. * An event triggered after the text is changed
  1303. */
  1304. onTextChangedObservable: Observable<TextBlock>;
  1305. /**
  1306. * An event triggered after the text was broken up into lines
  1307. */
  1308. onLinesReadyObservable: Observable<TextBlock>;
  1309. /**
  1310. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  1311. */
  1312. readonly lines: any[];
  1313. /**
  1314. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  1315. */
  1316. /**
  1317. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  1318. */
  1319. resizeToFit: boolean;
  1320. /**
  1321. * Gets or sets a boolean indicating if text must be wrapped
  1322. */
  1323. /**
  1324. * Gets or sets a boolean indicating if text must be wrapped
  1325. */
  1326. textWrapping: boolean;
  1327. /**
  1328. * Gets or sets text to display
  1329. */
  1330. /**
  1331. * Gets or sets text to display
  1332. */
  1333. text: string;
  1334. /**
  1335. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  1336. */
  1337. /**
  1338. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  1339. */
  1340. textHorizontalAlignment: number;
  1341. /**
  1342. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  1343. */
  1344. /**
  1345. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  1346. */
  1347. textVerticalAlignment: number;
  1348. /**
  1349. * Gets or sets line spacing value
  1350. */
  1351. /**
  1352. * Gets or sets line spacing value
  1353. */
  1354. lineSpacing: string | number;
  1355. /**
  1356. * Gets or sets outlineWidth of the text to display
  1357. */
  1358. /**
  1359. * Gets or sets outlineWidth of the text to display
  1360. */
  1361. outlineWidth: number;
  1362. /**
  1363. * Gets or sets outlineColor of the text to display
  1364. */
  1365. /**
  1366. * Gets or sets outlineColor of the text to display
  1367. */
  1368. outlineColor: string;
  1369. /**
  1370. * Creates a new TextBlock object
  1371. * @param name defines the name of the control
  1372. * @param text defines the text to display (emptry string by default)
  1373. */
  1374. constructor(
  1375. /**
  1376. * Defines the name of the control
  1377. */
  1378. name?: string | undefined, text?: string);
  1379. protected _getTypeName(): string;
  1380. private _drawText(text, textWidth, y, context);
  1381. /** @hidden */
  1382. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1383. protected _applyStates(context: CanvasRenderingContext2D): void;
  1384. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1385. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  1386. protected _parseLineWithTextWrapping(line: string | undefined, context: CanvasRenderingContext2D): object;
  1387. protected _renderLines(context: CanvasRenderingContext2D): void;
  1388. dispose(): void;
  1389. }
  1390. }
  1391. declare var DOMImage: new (width?: number | undefined, height?: number | undefined) => HTMLImageElement;
  1392. declare module BABYLON.GUI {
  1393. /**
  1394. * Class used to create 2D images
  1395. */
  1396. class Image extends Control {
  1397. name: string | undefined;
  1398. private _domImage;
  1399. private _imageWidth;
  1400. private _imageHeight;
  1401. private _loaded;
  1402. private _stretch;
  1403. private _source;
  1404. private _autoScale;
  1405. private _sourceLeft;
  1406. private _sourceTop;
  1407. private _sourceWidth;
  1408. private _sourceHeight;
  1409. private _cellWidth;
  1410. private _cellHeight;
  1411. private _cellId;
  1412. /**
  1413. * Gets or sets the left coordinate in the source image
  1414. */
  1415. sourceLeft: number;
  1416. /**
  1417. * Gets or sets the top coordinate in the source image
  1418. */
  1419. sourceTop: number;
  1420. /**
  1421. * Gets or sets the width to capture in the source image
  1422. */
  1423. sourceWidth: number;
  1424. /**
  1425. * Gets or sets the height to capture in the source image
  1426. */
  1427. sourceHeight: number;
  1428. /**
  1429. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  1430. * @see http://doc.babylonjs.com/how_to/gui#image
  1431. */
  1432. autoScale: boolean;
  1433. /** Gets or sets the streching mode used by the image */
  1434. stretch: number;
  1435. /**
  1436. * Gets or sets the internal DOM image used to render the control
  1437. */
  1438. domImage: HTMLImageElement;
  1439. private _onImageLoaded();
  1440. /**
  1441. * Gets or sets image source url
  1442. */
  1443. source: Nullable<string>;
  1444. /**
  1445. * Gets or sets the cell width to use when animation sheet is enabled
  1446. * @see http://doc.babylonjs.com/how_to/gui#image
  1447. */
  1448. cellWidth: number;
  1449. /**
  1450. * Gets or sets the cell height to use when animation sheet is enabled
  1451. * @see http://doc.babylonjs.com/how_to/gui#image
  1452. */
  1453. cellHeight: number;
  1454. /**
  1455. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  1456. * @see http://doc.babylonjs.com/how_to/gui#image
  1457. */
  1458. cellId: number;
  1459. /**
  1460. * Creates a new Image
  1461. * @param name defines the control name
  1462. * @param url defines the image url
  1463. */
  1464. constructor(name?: string | undefined, url?: Nullable<string>);
  1465. protected _getTypeName(): string;
  1466. /** Force the control to synchronize with its content */
  1467. synchronizeSizeWithContent(): void;
  1468. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1469. private static _STRETCH_NONE;
  1470. private static _STRETCH_FILL;
  1471. private static _STRETCH_UNIFORM;
  1472. private static _STRETCH_EXTEND;
  1473. /** STRETCH_NONE */
  1474. static readonly STRETCH_NONE: number;
  1475. /** STRETCH_FILL */
  1476. static readonly STRETCH_FILL: number;
  1477. /** STRETCH_UNIFORM */
  1478. static readonly STRETCH_UNIFORM: number;
  1479. /** STRETCH_EXTEND */
  1480. static readonly STRETCH_EXTEND: number;
  1481. }
  1482. }
  1483. declare module BABYLON.GUI {
  1484. /**
  1485. * Class used to create 2D buttons
  1486. */
  1487. class Button extends Rectangle {
  1488. name: string | undefined;
  1489. /**
  1490. * Function called to generate a pointer enter animation
  1491. */
  1492. pointerEnterAnimation: () => void;
  1493. /**
  1494. * Function called to generate a pointer out animation
  1495. */
  1496. pointerOutAnimation: () => void;
  1497. /**
  1498. * Function called to generate a pointer down animation
  1499. */
  1500. pointerDownAnimation: () => void;
  1501. /**
  1502. * Function called to generate a pointer up animation
  1503. */
  1504. pointerUpAnimation: () => void;
  1505. /**
  1506. * Creates a new Button
  1507. * @param name defines the name of the button
  1508. */
  1509. constructor(name?: string | undefined);
  1510. protected _getTypeName(): string;
  1511. /** @hidden */
  1512. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  1513. /** @hidden */
  1514. _onPointerEnter(target: Control): boolean;
  1515. /** @hidden */
  1516. _onPointerOut(target: Control): void;
  1517. /** @hidden */
  1518. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1519. /** @hidden */
  1520. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  1521. /**
  1522. * Creates a new button made with an image and a text
  1523. * @param name defines the name of the button
  1524. * @param text defines the text of the button
  1525. * @param imageUrl defines the url of the image
  1526. * @returns a new Button
  1527. */
  1528. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  1529. /**
  1530. * Creates a new button made with an image
  1531. * @param name defines the name of the button
  1532. * @param imageUrl defines the url of the image
  1533. * @returns a new Button
  1534. */
  1535. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  1536. /**
  1537. * Creates a new button made with a text
  1538. * @param name defines the name of the button
  1539. * @param text defines the text of the button
  1540. * @returns a new Button
  1541. */
  1542. static CreateSimpleButton(name: string, text: string): Button;
  1543. /**
  1544. * Creates a new button made with an image and a centered text
  1545. * @param name defines the name of the button
  1546. * @param text defines the text of the button
  1547. * @param imageUrl defines the url of the image
  1548. * @returns a new Button
  1549. */
  1550. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  1551. }
  1552. }
  1553. declare module BABYLON.GUI {
  1554. /** Class used to create color pickers */
  1555. class ColorPicker extends Control {
  1556. name: string | undefined;
  1557. private _colorWheelCanvas;
  1558. private _value;
  1559. private _tmpColor;
  1560. private _pointerStartedOnSquare;
  1561. private _pointerStartedOnWheel;
  1562. private _squareLeft;
  1563. private _squareTop;
  1564. private _squareSize;
  1565. private _h;
  1566. private _s;
  1567. private _v;
  1568. /**
  1569. * Observable raised when the value changes
  1570. */
  1571. onValueChangedObservable: Observable<Color3>;
  1572. /** Gets or sets the color of the color picker */
  1573. value: Color3;
  1574. /** Gets or sets control width */
  1575. width: string | number;
  1576. /** Gets or sets control height */
  1577. height: string | number;
  1578. /** Gets or sets control size */
  1579. size: string | number;
  1580. /**
  1581. * Creates a new ColorPicker
  1582. * @param name defines the control name
  1583. */
  1584. constructor(name?: string | undefined);
  1585. protected _getTypeName(): string;
  1586. private _updateSquareProps();
  1587. private _drawGradientSquare(hueValue, left, top, width, height, context);
  1588. private _drawCircle(centerX, centerY, radius, context);
  1589. private _createColorWheelCanvas(radius, thickness);
  1590. private _RGBtoHSV(color, result);
  1591. private _HSVtoRGB(hue, saturation, value, result);
  1592. /** @hidden */
  1593. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1594. private _pointerIsDown;
  1595. private _updateValueFromPointer(x, y);
  1596. private _isPointOnSquare(coordinates);
  1597. private _isPointOnWheel(coordinates);
  1598. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1599. _onPointerMove(target: Control, coordinates: Vector2): void;
  1600. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  1601. }
  1602. }
  1603. declare module BABYLON.GUI {
  1604. /**
  1605. * Class used to create input text control
  1606. */
  1607. class InputText extends Control implements IFocusableControl {
  1608. name: string | undefined;
  1609. private _text;
  1610. private _placeholderText;
  1611. private _background;
  1612. private _focusedBackground;
  1613. private _placeholderColor;
  1614. private _thickness;
  1615. private _margin;
  1616. private _autoStretchWidth;
  1617. private _maxWidth;
  1618. private _isFocused;
  1619. private _blinkTimeout;
  1620. private _blinkIsEven;
  1621. private _cursorOffset;
  1622. private _scrollLeft;
  1623. private _textWidth;
  1624. private _clickedCoordinate;
  1625. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  1626. promptMessage: string;
  1627. /** Observable raised when the text changes */
  1628. onTextChangedObservable: Observable<InputText>;
  1629. /** Observable raised when the control gets the focus */
  1630. onFocusObservable: Observable<InputText>;
  1631. /** Observable raised when the control loses the focus */
  1632. onBlurObservable: Observable<InputText>;
  1633. /** Gets or sets the maximum width allowed by the control */
  1634. maxWidth: string | number;
  1635. /** Gets the maximum width allowed by the control in pixels */
  1636. readonly maxWidthInPixels: number;
  1637. /** Gets or sets control margin */
  1638. margin: string;
  1639. /** Gets control margin in pixels */
  1640. readonly marginInPixels: number;
  1641. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  1642. autoStretchWidth: boolean;
  1643. /** Gets or sets border thickness */
  1644. thickness: number;
  1645. /** Gets or sets the background color when focused */
  1646. focusedBackground: string;
  1647. /** Gets or sets the background color */
  1648. background: string;
  1649. /** Gets or sets the placeholder color */
  1650. placeholderColor: string;
  1651. /** Gets or sets the text displayed when the control is empty */
  1652. placeholderText: string;
  1653. /** Gets or sets the text displayed in the control */
  1654. text: string;
  1655. /** Gets or sets control width */
  1656. width: string | number;
  1657. /**
  1658. * Creates a new InputText
  1659. * @param name defines the control name
  1660. * @param text defines the text of the control
  1661. */
  1662. constructor(name?: string | undefined, text?: string);
  1663. /** @hidden */
  1664. onBlur(): void;
  1665. /** @hidden */
  1666. onFocus(): void;
  1667. protected _getTypeName(): string;
  1668. /** @hidden */
  1669. processKey(keyCode: number, key?: string): void;
  1670. /** @hidden */
  1671. processKeyboard(evt: KeyboardEvent): void;
  1672. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1673. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1674. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  1675. dispose(): void;
  1676. }
  1677. }
  1678. declare module BABYLON.GUI {
  1679. /**
  1680. * Class used to store key control properties
  1681. */
  1682. class KeyPropertySet {
  1683. /** Width */
  1684. width?: string;
  1685. /** Height */
  1686. height?: string;
  1687. /** Left padding */
  1688. paddingLeft?: string;
  1689. /** Right padding */
  1690. paddingRight?: string;
  1691. /** Top padding */
  1692. paddingTop?: string;
  1693. /** Bottom padding */
  1694. paddingBottom?: string;
  1695. /** Foreground color */
  1696. color?: string;
  1697. /** Background color */
  1698. background?: string;
  1699. }
  1700. /**
  1701. * Class used to create virtual keyboard
  1702. */
  1703. class VirtualKeyboard extends StackPanel {
  1704. /** Observable raised when a key is pressed */
  1705. onKeyPressObservable: Observable<string>;
  1706. /** Gets or sets default key button width */
  1707. defaultButtonWidth: string;
  1708. /** Gets or sets default key button height */
  1709. defaultButtonHeight: string;
  1710. /** Gets or sets default key button left padding */
  1711. defaultButtonPaddingLeft: string;
  1712. /** Gets or sets default key button right padding */
  1713. defaultButtonPaddingRight: string;
  1714. /** Gets or sets default key button top padding */
  1715. defaultButtonPaddingTop: string;
  1716. /** Gets or sets default key button bottom padding */
  1717. defaultButtonPaddingBottom: string;
  1718. /** Gets or sets default key button foreground color */
  1719. defaultButtonColor: string;
  1720. /** Gets or sets default key button background color */
  1721. defaultButtonBackground: string;
  1722. /** Gets or sets shift button foreground color */
  1723. shiftButtonColor: string;
  1724. /** Gets or sets shift button thickness*/
  1725. selectedShiftThickness: number;
  1726. /** Gets shift key state */
  1727. shiftState: number;
  1728. protected _getTypeName(): string;
  1729. private _createKey(key, propertySet);
  1730. /**
  1731. * Adds a new row of keys
  1732. * @param keys defines the list of keys to add
  1733. * @param propertySets defines the associated property sets
  1734. */
  1735. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  1736. /**
  1737. * Set the shift key to a specific state
  1738. * @param shiftState defines the new shift state
  1739. */
  1740. applyShiftState(shiftState: number): void;
  1741. private _connectedInputText;
  1742. private _onFocusObserver;
  1743. private _onBlurObserver;
  1744. private _onKeyPressObserver;
  1745. /** Gets the input text control attached with the keyboard */
  1746. readonly connectedInputText: Nullable<InputText>;
  1747. /**
  1748. * Connects the keyboard with an input text control
  1749. * @param input defines the target control
  1750. */
  1751. connect(input: InputText): void;
  1752. /**
  1753. * Disconnects the keyboard from an input text control
  1754. */
  1755. disconnect(): void;
  1756. /**
  1757. * Creates a new keyboard using a default layout
  1758. * @returns a new VirtualKeyboard
  1759. */
  1760. static CreateDefaultLayout(): VirtualKeyboard;
  1761. }
  1762. }
  1763. declare module BABYLON.GUI {
  1764. /**
  1765. * Class used to create multi line control
  1766. */
  1767. class MultiLine extends Control {
  1768. name: string | undefined;
  1769. private _lineWidth;
  1770. private _dash;
  1771. private _points;
  1772. private _minX;
  1773. private _minY;
  1774. private _maxX;
  1775. private _maxY;
  1776. /**
  1777. * Creates a new MultiLine
  1778. * @param name defines the control name
  1779. */
  1780. constructor(name?: string | undefined);
  1781. /** Gets or sets dash pattern */
  1782. dash: Array<number>;
  1783. /**
  1784. * Gets point stored at specified index
  1785. * @param index defines the index to look for
  1786. * @returns the requested point if found
  1787. */
  1788. getAt(index: number): MultiLinePoint;
  1789. /** Function called when a point is updated */
  1790. onPointUpdate: () => void;
  1791. /**
  1792. * Adds new points to the point collection
  1793. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  1794. * @returns the list of created MultiLinePoint
  1795. */
  1796. add(...items: (AbstractMesh | Control | {
  1797. x: string | number;
  1798. y: string | number;
  1799. })[]): MultiLinePoint[];
  1800. /**
  1801. * Adds a new point to the point collection
  1802. * @param item defines the item (mesh, control or 2d coordiantes) to add
  1803. * @returns the created MultiLinePoint
  1804. */
  1805. push(item?: (AbstractMesh | Control | {
  1806. x: string | number;
  1807. y: string | number;
  1808. })): MultiLinePoint;
  1809. /**
  1810. * Remove a specific value or point from the active point collection
  1811. * @param value defines the value or point to remove
  1812. */
  1813. remove(value: number | MultiLinePoint): void;
  1814. /** Gets or sets line width */
  1815. lineWidth: number;
  1816. horizontalAlignment: number;
  1817. verticalAlignment: number;
  1818. protected _getTypeName(): string;
  1819. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1820. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1821. _measure(): void;
  1822. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1823. dispose(): void;
  1824. }
  1825. }
  1826. declare module BABYLON.GUI {
  1827. /**
  1828. * Class used to manage 3D user interface
  1829. * @see http://doc.babylonjs.com/how_to/gui3d
  1830. */
  1831. class GUI3DManager implements BABYLON.IDisposable {
  1832. private _scene;
  1833. private _sceneDisposeObserver;
  1834. private _utilityLayer;
  1835. private _rootContainer;
  1836. private _pointerObserver;
  1837. /** @hidden */
  1838. _lastPickedControl: Control3D;
  1839. /** @hidden */
  1840. _lastControlOver: {
  1841. [pointerId: number]: Control3D;
  1842. };
  1843. /** @hidden */
  1844. _lastControlDown: {
  1845. [pointerId: number]: Control3D;
  1846. };
  1847. /**
  1848. * Observable raised when the point picked by the pointer events changed
  1849. */
  1850. onPickedPointChangedObservable: Observable<Nullable<Vector3>>;
  1851. /** @hidden */
  1852. _sharedMaterials: {
  1853. [key: string]: Material;
  1854. };
  1855. /** Gets the hosting scene */
  1856. readonly scene: Scene;
  1857. /** Gets associated utility layer */
  1858. readonly utilityLayer: Nullable<UtilityLayerRenderer>;
  1859. /**
  1860. * Creates a new GUI3DManager
  1861. * @param scene
  1862. */
  1863. constructor(scene?: Scene);
  1864. private _doPicking(type, pointerEvent, ray?);
  1865. /**
  1866. * Gets the root container
  1867. */
  1868. readonly rootContainer: Container3D;
  1869. /**
  1870. * Gets a boolean indicating if the given control is in the root child list
  1871. * @param control defines the control to check
  1872. * @returns true if the control is in the root child list
  1873. */
  1874. containsControl(control: Control3D): boolean;
  1875. /**
  1876. * Adds a control to the root child list
  1877. * @param control defines the control to add
  1878. * @returns the current manager
  1879. */
  1880. addControl(control: Control3D): GUI3DManager;
  1881. /**
  1882. * Removes a control from the root child list
  1883. * @param control defines the control to remove
  1884. * @returns the current container
  1885. */
  1886. removeControl(control: Control3D): GUI3DManager;
  1887. /**
  1888. * Releases all associated resources
  1889. */
  1890. dispose(): void;
  1891. }
  1892. }
  1893. declare module BABYLON.GUI {
  1894. /** @hidden */
  1895. class FluentMaterialDefines extends MaterialDefines {
  1896. INNERGLOW: boolean;
  1897. BORDER: boolean;
  1898. HOVERLIGHT: boolean;
  1899. constructor();
  1900. }
  1901. /**
  1902. * Class used to render controls with fluent desgin
  1903. */
  1904. class FluentMaterial extends PushMaterial {
  1905. /**
  1906. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  1907. */
  1908. innerGlowColorIntensity: number;
  1909. /**
  1910. * Gets or sets the inner glow color (white by default)
  1911. */
  1912. innerGlowColor: Color3;
  1913. /**
  1914. * Gets or sets alpha value (default is 1.0)
  1915. */
  1916. alpha: number;
  1917. /**
  1918. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  1919. */
  1920. albedoColor: Color3;
  1921. /**
  1922. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  1923. */
  1924. renderBorders: boolean;
  1925. /**
  1926. * Gets or sets border width (default is 0.5)
  1927. */
  1928. borderWidth: number;
  1929. /**
  1930. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  1931. */
  1932. edgeSmoothingValue: number;
  1933. /**
  1934. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  1935. */
  1936. borderMinValue: number;
  1937. /**
  1938. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  1939. */
  1940. renderHoverLight: boolean;
  1941. /**
  1942. * Gets or sets the radius used to render the hover light (default is 0.15)
  1943. */
  1944. hoverRadius: number;
  1945. /**
  1946. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  1947. */
  1948. hoverColor: Color4;
  1949. /**
  1950. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  1951. */
  1952. hoverPosition: Vector3;
  1953. /**
  1954. * Creates a new Fluent material
  1955. * @param name defines the name of the material
  1956. * @param scene defines the hosting scene
  1957. */
  1958. constructor(name: string, scene: Scene);
  1959. needAlphaBlending(): boolean;
  1960. needAlphaTesting(): boolean;
  1961. getAlphaTestTexture(): Nullable<BaseTexture>;
  1962. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  1963. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  1964. getActiveTextures(): BaseTexture[];
  1965. hasTexture(texture: BaseTexture): boolean;
  1966. dispose(forceDisposeEffect?: boolean): void;
  1967. clone(name: string): FluentMaterial;
  1968. serialize(): any;
  1969. getClassName(): string;
  1970. static Parse(source: any, scene: Scene, rootUrl: string): FluentMaterial;
  1971. }
  1972. }
  1973. declare module BABYLON.GUI {
  1974. /**
  1975. * Class used to transport Vector3 information for pointer events
  1976. */
  1977. class Vector3WithInfo extends Vector3 {
  1978. /** defines the current mouse button index */
  1979. buttonIndex: number;
  1980. /**
  1981. * Creates a new Vector3WithInfo
  1982. * @param source defines the vector3 data to transport
  1983. * @param buttonIndex defines the current mouse button index
  1984. */
  1985. constructor(source: Vector3,
  1986. /** defines the current mouse button index */
  1987. buttonIndex?: number);
  1988. }
  1989. }
  1990. declare module BABYLON.GUI {
  1991. /**
  1992. * Class used as base class for controls
  1993. */
  1994. class Control3D implements IDisposable, IBehaviorAware<Control3D> {
  1995. /** Defines the control name */
  1996. name: string | undefined;
  1997. /** @hidden */
  1998. _host: GUI3DManager;
  1999. private _node;
  2000. private _downCount;
  2001. private _enterCount;
  2002. private _downPointerIds;
  2003. private _isVisible;
  2004. /** Gets or sets the control position in world space */
  2005. position: Vector3;
  2006. /** Gets or sets the control scaling in world space */
  2007. scaling: Vector3;
  2008. /** Callback used to start pointer enter animation */
  2009. pointerEnterAnimation: () => void;
  2010. /** Callback used to start pointer out animation */
  2011. pointerOutAnimation: () => void;
  2012. /** Callback used to start pointer down animation */
  2013. pointerDownAnimation: () => void;
  2014. /** Callback used to start pointer up animation */
  2015. pointerUpAnimation: () => void;
  2016. /**
  2017. * An event triggered when the pointer move over the control
  2018. */
  2019. onPointerMoveObservable: Observable<Vector3>;
  2020. /**
  2021. * An event triggered when the pointer move out of the control
  2022. */
  2023. onPointerOutObservable: Observable<Control3D>;
  2024. /**
  2025. * An event triggered when the pointer taps the control
  2026. */
  2027. onPointerDownObservable: Observable<Vector3WithInfo>;
  2028. /**
  2029. * An event triggered when pointer is up
  2030. */
  2031. onPointerUpObservable: Observable<Vector3WithInfo>;
  2032. /**
  2033. * An event triggered when a control is clicked on (with a mouse)
  2034. */
  2035. onPointerClickObservable: Observable<Vector3WithInfo>;
  2036. /**
  2037. * An event triggered when pointer enters the control
  2038. */
  2039. onPointerEnterObservable: Observable<Control3D>;
  2040. /**
  2041. * Gets or sets the parent container
  2042. */
  2043. parent: Nullable<Container3D>;
  2044. private _behaviors;
  2045. /**
  2046. * Gets the list of attached behaviors
  2047. * @see http://doc.babylonjs.com/features/behaviour
  2048. */
  2049. readonly behaviors: Behavior<Control3D>[];
  2050. /**
  2051. * Attach a behavior to the control
  2052. * @see http://doc.babylonjs.com/features/behaviour
  2053. * @param behavior defines the behavior to attach
  2054. * @returns the current control
  2055. */
  2056. addBehavior(behavior: Behavior<Control3D>): Control3D;
  2057. /**
  2058. * Remove an attached behavior
  2059. * @see http://doc.babylonjs.com/features/behaviour
  2060. * @param behavior defines the behavior to attach
  2061. * @returns the current control
  2062. */
  2063. removeBehavior(behavior: Behavior<Control3D>): Control3D;
  2064. /**
  2065. * Gets an attached behavior by name
  2066. * @param name defines the name of the behavior to look for
  2067. * @see http://doc.babylonjs.com/features/behaviour
  2068. * @returns null if behavior was not found else the requested behavior
  2069. */
  2070. getBehaviorByName(name: string): Nullable<Behavior<Control3D>>;
  2071. /** Gets or sets a boolean indicating if the control is visible */
  2072. isVisible: boolean;
  2073. /**
  2074. * Creates a new control
  2075. * @param name defines the control name
  2076. */
  2077. constructor(
  2078. /** Defines the control name */
  2079. name?: string | undefined);
  2080. /**
  2081. * Gets a string representing the class name
  2082. */
  2083. readonly typeName: string;
  2084. protected _getTypeName(): string;
  2085. /**
  2086. * Gets the transform node used by this control
  2087. */
  2088. readonly node: Nullable<TransformNode>;
  2089. /**
  2090. * Gets the mesh used to render this control
  2091. */
  2092. readonly mesh: Nullable<AbstractMesh>;
  2093. /**
  2094. * Link the control as child of the given node
  2095. * @param node defines the node to link to. Use null to unlink the control
  2096. * @returns the current control
  2097. */
  2098. linkToTransformNode(node: Nullable<TransformNode>): Control3D;
  2099. /** @hidden **/
  2100. _prepareNode(scene: Scene): void;
  2101. /**
  2102. * Node creation.
  2103. * Can be overriden by children
  2104. * @param scene defines the scene where the node must be attached
  2105. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  2106. */
  2107. protected _createNode(scene: Scene): Nullable<TransformNode>;
  2108. /**
  2109. * Affect a material to the given mesh
  2110. * @param mesh defines the mesh which will represent the control
  2111. */
  2112. protected _affectMaterial(mesh: AbstractMesh): void;
  2113. /** @hidden */
  2114. _onPointerMove(target: Control3D, coordinates: Vector3): void;
  2115. /** @hidden */
  2116. _onPointerEnter(target: Control3D): boolean;
  2117. /** @hidden */
  2118. _onPointerOut(target: Control3D): void;
  2119. /** @hidden */
  2120. _onPointerDown(target: Control3D, coordinates: Vector3, pointerId: number, buttonIndex: number): boolean;
  2121. /** @hidden */
  2122. _onPointerUp(target: Control3D, coordinates: Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  2123. /** @hidden */
  2124. forcePointerUp(pointerId?: Nullable<number>): void;
  2125. /** @hidden */
  2126. _processObservables(type: number, pickedPoint: Vector3, pointerId: number, buttonIndex: number): boolean;
  2127. /** @hidden */
  2128. _disposeNode(): void;
  2129. /**
  2130. * Releases all associated resources
  2131. */
  2132. dispose(): void;
  2133. }
  2134. }
  2135. declare module BABYLON.GUI {
  2136. /**
  2137. * Class used to create containers for controls
  2138. */
  2139. class Container3D extends Control3D {
  2140. /**
  2141. * Gets the list of child controls
  2142. */
  2143. protected _children: Control3D[];
  2144. /**
  2145. * Creates a new container
  2146. * @param name defines the container name
  2147. */
  2148. constructor(name?: string);
  2149. /**
  2150. * Gets a boolean indicating if the given control is in the children of this control
  2151. * @param control defines the control to check
  2152. * @returns true if the control is in the child list
  2153. */
  2154. containsControl(control: Control3D): boolean;
  2155. /**
  2156. * Adds a control to the children of this control
  2157. * @param control defines the control to add
  2158. * @returns the current container
  2159. */
  2160. addControl(control: Control3D): Container3D;
  2161. /**
  2162. * This function will be called everytime a new control is added
  2163. */
  2164. protected _arrangeChildren(): void;
  2165. protected _createNode(scene: Scene): Nullable<TransformNode>;
  2166. /**
  2167. * Removes a control from the children of this control
  2168. * @param control defines the control to remove
  2169. * @returns the current container
  2170. */
  2171. removeControl(control: Control3D): Container3D;
  2172. protected _getTypeName(): string;
  2173. /**
  2174. * Releases all associated resources
  2175. */
  2176. dispose(): void;
  2177. }
  2178. }
  2179. declare module BABYLON.GUI {
  2180. /**
  2181. * Class used to create a button in 3D
  2182. */
  2183. class Button3D extends Control3D {
  2184. /** @hidden */
  2185. protected _currentMaterial: Material;
  2186. private _facadeTexture;
  2187. private _content;
  2188. private _contentResolution;
  2189. private _contentScaleRatio;
  2190. /**
  2191. * Gets or sets the texture resolution used to render content (512 by default)
  2192. */
  2193. contentResolution: int;
  2194. /**
  2195. * Gets or sets the texture scale ratio used to render content (2 by default)
  2196. */
  2197. contentScaleRatio: number;
  2198. protected _disposeFacadeTexture(): void;
  2199. protected _resetContent(): void;
  2200. /**
  2201. * Creates a new button
  2202. * @param name defines the control name
  2203. */
  2204. constructor(name?: string);
  2205. /**
  2206. * Gets or sets the GUI 2D content used to display the button's facade
  2207. */
  2208. content: Control;
  2209. /**
  2210. * Apply the facade texture (created from the content property).
  2211. * This function can be overloaded by child classes
  2212. * @param facadeTexture defines the AdvancedDynamicTexture to use
  2213. */
  2214. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  2215. protected _getTypeName(): string;
  2216. protected _createNode(scene: Scene): TransformNode;
  2217. protected _affectMaterial(mesh: AbstractMesh): void;
  2218. /**
  2219. * Releases all associated resources
  2220. */
  2221. dispose(): void;
  2222. }
  2223. }
  2224. declare module BABYLON.GUI {
  2225. /**
  2226. * Class used to create a holographic button in 3D
  2227. */
  2228. class HolographicButton extends Button3D {
  2229. private _backPlate;
  2230. private _textPlate;
  2231. private _frontPlate;
  2232. private _text;
  2233. private _imageUrl;
  2234. private _shareMaterials;
  2235. private _frontMaterial;
  2236. private _backMaterial;
  2237. private _plateMaterial;
  2238. private _pickedPointObserver;
  2239. /**
  2240. * Gets or sets text for the button
  2241. */
  2242. text: string;
  2243. /**
  2244. * Gets or sets the image url for the button
  2245. */
  2246. imageUrl: string;
  2247. /**
  2248. * Gets the back material used by this button
  2249. */
  2250. readonly backMaterial: FluentMaterial;
  2251. /**
  2252. * Gets the front material used by this button
  2253. */
  2254. readonly frontMaterial: FluentMaterial;
  2255. /**
  2256. * Gets the plate material used by this button
  2257. */
  2258. readonly plateMaterial: StandardMaterial;
  2259. /**
  2260. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  2261. */
  2262. readonly shareMaterials: boolean;
  2263. /**
  2264. * Creates a new button
  2265. * @param name defines the control name
  2266. */
  2267. constructor(name?: string, shareMaterials?: boolean);
  2268. protected _getTypeName(): string;
  2269. private _rebuildContent();
  2270. protected _createNode(scene: Scene): TransformNode;
  2271. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  2272. private _createBackMaterial(mesh);
  2273. private _createFrontMaterial(mesh);
  2274. private _createPlateMaterial(mesh);
  2275. protected _affectMaterial(mesh: Mesh): void;
  2276. /**
  2277. * Releases all associated resources
  2278. */
  2279. dispose(): void;
  2280. }
  2281. }
  2282. declare module BABYLON.GUI {
  2283. /**
  2284. * Class used to create a stack panel in 3D on XY plane
  2285. */
  2286. class StackPanel3D extends Container3D {
  2287. private _isVertical;
  2288. /**
  2289. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  2290. */
  2291. isVertical: boolean;
  2292. /**
  2293. * Gets or sets the distance between elements
  2294. */
  2295. margin: number;
  2296. /**
  2297. * Creates new StackPanel
  2298. * @param isVertical
  2299. */
  2300. constructor(isVertical?: boolean);
  2301. protected _arrangeChildren(): void;
  2302. }
  2303. }
  2304. declare module BABYLON.GUI {
  2305. /**
  2306. * Class used to create a conainter panel deployed on the surface of a sphere
  2307. */
  2308. class SpherePanel extends Container3D {
  2309. private _radius;
  2310. private _columns;
  2311. /**
  2312. * Gets or sets a the radius of the sphere where to project controls (5 by default)
  2313. */
  2314. radius: float;
  2315. /**
  2316. * Gets or sets a the number of columns requested (10 by default).
  2317. * The panel will automatically compute the number of rows based on number of child controls
  2318. */
  2319. columns: int;
  2320. /**
  2321. * Creates new SpherePanel
  2322. */
  2323. constructor();
  2324. protected _arrangeChildren(): void;
  2325. private _sphericalMapping(source);
  2326. }
  2327. }