babylon.gui.module.d.ts 86 KB

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