babylon.gui.d.ts 98 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660
  1. declare module BABYLON.GUI {
  2. /**
  3. * Define a style used by control to automatically setup properties based on a template.
  4. * Only support font related properties so far
  5. */
  6. class Style implements BABYLON.IDisposable {
  7. private _fontFamily;
  8. private _fontStyle;
  9. private _fontWeight;
  10. /** @hidden */
  11. _host: AdvancedDynamicTexture;
  12. /** @hidden */
  13. _fontSize: ValueAndUnit;
  14. /**
  15. * Observable raised when the style values are changed
  16. */
  17. onChangedObservable: Observable<Style>;
  18. /**
  19. * Creates a new style object
  20. * @param host defines the AdvancedDynamicTexture which hosts this style
  21. */
  22. constructor(host: AdvancedDynamicTexture);
  23. /**
  24. * Gets or sets the font size
  25. */
  26. fontSize: string | number;
  27. /**
  28. * Gets or sets the font family
  29. */
  30. fontFamily: string;
  31. /**
  32. * Gets or sets the font style
  33. */
  34. fontStyle: string;
  35. /** Gets or sets font weight */
  36. fontWeight: string;
  37. /** Dispose all associated resources */
  38. dispose(): void;
  39. }
  40. }
  41. declare module BABYLON.GUI {
  42. /**
  43. * Class used to specific a value and its associated unit
  44. */
  45. class ValueAndUnit {
  46. /** defines the unit to store */
  47. unit: number;
  48. /** defines a boolean indicating if the value can be negative */
  49. negativeValueAllowed: boolean;
  50. private _value;
  51. /**
  52. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  53. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  54. */
  55. ignoreAdaptiveScaling: boolean;
  56. /**
  57. * Creates a new ValueAndUnit
  58. * @param value defines the value to store
  59. * @param unit defines the unit to store
  60. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  61. */
  62. constructor(value: number,
  63. /** defines the unit to store */
  64. unit?: number,
  65. /** defines a boolean indicating if the value can be negative */
  66. negativeValueAllowed?: boolean);
  67. /** Gets a boolean indicating if the value is a percentage */
  68. readonly isPercentage: boolean;
  69. /** Gets a boolean indicating if the value is store as pixel */
  70. readonly isPixel: boolean;
  71. /** Gets direct internal value */
  72. readonly internalValue: number;
  73. /**
  74. * Gets value as pixel
  75. * @param host defines the root host
  76. * @param refValue defines the reference value for percentages
  77. * @returns the value as pixel
  78. */
  79. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  80. /**
  81. * Gets the value accordingly to its unit
  82. * @param host defines the root host
  83. * @returns the value
  84. */
  85. getValue(host: AdvancedDynamicTexture): number;
  86. /**
  87. * Gets a string representation of the value
  88. * @param host defines the root host
  89. * @returns a string
  90. */
  91. toString(host: AdvancedDynamicTexture): string;
  92. /**
  93. * Store a value parsed from a string
  94. * @param source defines the source string
  95. * @returns true if the value was successfully parsed
  96. */
  97. fromString(source: string | number): boolean;
  98. private static _Regex;
  99. private static _UNITMODE_PERCENTAGE;
  100. private static _UNITMODE_PIXEL;
  101. /** UNITMODE_PERCENTAGE */
  102. static readonly UNITMODE_PERCENTAGE: number;
  103. /** UNITMODE_PIXEL */
  104. static readonly UNITMODE_PIXEL: number;
  105. }
  106. }
  107. /**
  108. * This module hosts all controls for 2D and 3D GUIs
  109. * @see http://doc.babylonjs.com/how_to/gui
  110. */
  111. declare module BABYLON.GUI {
  112. /**
  113. * Interface used to define a control that can receive focus
  114. */
  115. interface IFocusableControl {
  116. /**
  117. * Function called when the control receives the focus
  118. */
  119. onFocus(): void;
  120. /**
  121. * Function called when the control loses the focus
  122. */
  123. onBlur(): void;
  124. /**
  125. * Function called to let the control handle keyboard events
  126. * @param evt defines the current keyboard event
  127. */
  128. processKeyboard(evt: KeyboardEvent): void;
  129. }
  130. /**
  131. * Class used to create texture to support 2D GUI elements
  132. * @see http://doc.babylonjs.com/how_to/gui
  133. */
  134. class AdvancedDynamicTexture extends DynamicTexture {
  135. private _isDirty;
  136. private _renderObserver;
  137. private _resizeObserver;
  138. private _preKeyboardObserver;
  139. private _pointerMoveObserver;
  140. private _pointerObserver;
  141. private _canvasPointerOutObserver;
  142. private _background;
  143. /** @hidden */
  144. _rootContainer: Container;
  145. /** @hidden */
  146. _lastPickedControl: Control;
  147. /** @hidden */
  148. _lastControlOver: {
  149. [pointerId: number]: Control;
  150. };
  151. /** @hidden */
  152. _lastControlDown: {
  153. [pointerId: number]: Control;
  154. };
  155. /** @hidden */
  156. _capturingControl: {
  157. [pointerId: number]: Control;
  158. };
  159. /** @hidden */
  160. _shouldBlockPointer: boolean;
  161. /** @hidden */
  162. _layerToDispose: Nullable<Layer>;
  163. /** @hidden */
  164. _linkedControls: Control[];
  165. private _isFullscreen;
  166. private _fullscreenViewport;
  167. private _idealWidth;
  168. private _idealHeight;
  169. private _useSmallestIdeal;
  170. private _renderAtIdealSize;
  171. private _focusedControl;
  172. private _blockNextFocusCheck;
  173. private _renderScale;
  174. /**
  175. * Gets or sets a boolean defining if alpha is stored as premultiplied
  176. */
  177. premulAlpha: boolean;
  178. /**
  179. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  180. * Useful when you want more antialiasing
  181. */
  182. renderScale: number;
  183. /** Gets or sets the background color */
  184. background: string;
  185. /**
  186. * Gets or sets the ideal width used to design controls.
  187. * The GUI will then rescale everything accordingly
  188. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  189. */
  190. idealWidth: number;
  191. /**
  192. * Gets or sets the ideal height used to design controls.
  193. * The GUI will then rescale everything accordingly
  194. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  195. */
  196. idealHeight: number;
  197. /**
  198. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  199. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  200. */
  201. useSmallestIdeal: boolean;
  202. /**
  203. * Gets or sets a boolean indicating if adaptive scaling must be used
  204. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  205. */
  206. renderAtIdealSize: boolean;
  207. /**
  208. * Gets the underlying layer used to render the texture when in fullscreen mode
  209. */
  210. readonly layer: Nullable<Layer>;
  211. /**
  212. * Gets the root container control
  213. */
  214. readonly rootContainer: Container;
  215. /**
  216. * Gets or sets the current focused control
  217. */
  218. focusedControl: Nullable<IFocusableControl>;
  219. /**
  220. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  221. */
  222. isForeground: boolean;
  223. /**
  224. * Creates a new AdvancedDynamicTexture
  225. * @param name defines the name of the texture
  226. * @param width defines the width of the texture
  227. * @param height defines the height of the texture
  228. * @param scene defines the hosting scene
  229. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  230. * @param samplingMode defines the texture sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  231. */
  232. constructor(name: string, width: number | undefined, height: number | undefined, scene: Nullable<Scene>, generateMipMaps?: boolean, samplingMode?: number);
  233. /**
  234. * Function used to execute a function on all controls
  235. * @param func defines the function to execute
  236. * @param container defines the container where controls belong. If null the root container will be used
  237. */
  238. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  239. /**
  240. * Marks the texture as dirty forcing a complete update
  241. */
  242. markAsDirty(): void;
  243. /**
  244. * Helper function used to create a new style
  245. * @returns a new style
  246. * @see http://doc.babylonjs.com/how_to/gui#styles
  247. */
  248. createStyle(): Style;
  249. /**
  250. * Adds a new control to the root container
  251. * @param control defines the control to add
  252. * @returns the current texture
  253. */
  254. addControl(control: Control): AdvancedDynamicTexture;
  255. /**
  256. * Removes a control from the root container
  257. * @param control defines the control to remove
  258. * @returns the current texture
  259. */
  260. removeControl(control: Control): AdvancedDynamicTexture;
  261. /**
  262. * Release all resources
  263. */
  264. dispose(): void;
  265. private _onResize();
  266. /** @hidden */
  267. _getGlobalViewport(scene: Scene): Viewport;
  268. /**
  269. * Get screen coordinates for a vector3
  270. * @param position defines the position to project
  271. * @param worldMatrix defines the world matrix to use
  272. * @returns the projected position
  273. */
  274. getProjectedPosition(position: Vector3, worldMatrix: Matrix): Vector2;
  275. private _checkUpdate(camera);
  276. private _render();
  277. private _doPicking(x, y, type, pointerId, buttonIndex);
  278. /** @hidden */
  279. _cleanControlAfterRemovalFromList(list: {
  280. [pointerId: number]: Control;
  281. }, control: Control): void;
  282. /** @hidden */
  283. _cleanControlAfterRemoval(control: Control): void;
  284. /** Attach to all scene events required to support pointer events */
  285. attach(): void;
  286. /**
  287. * Connect the texture to a hosting mesh to enable interactions
  288. * @param mesh defines the mesh to attach to
  289. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  290. */
  291. attachToMesh(mesh: AbstractMesh, supportPointerMove?: boolean): void;
  292. /**
  293. * Move the focus to a specific control
  294. * @param control defines the control which will receive the focus
  295. */
  296. moveFocusToControl(control: IFocusableControl): void;
  297. private _manageFocus();
  298. private _attachToOnPointerOut(scene);
  299. /**
  300. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  301. * @param mesh defines the mesh which will receive the texture
  302. * @param width defines the texture width (1024 by default)
  303. * @param height defines the texture height (1024 by default)
  304. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  305. * @returns a new AdvancedDynamicTexture
  306. */
  307. static CreateForMesh(mesh: AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean): AdvancedDynamicTexture;
  308. /**
  309. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  310. * In this mode the texture will rely on a layer for its rendering.
  311. * This allows it to be treated like any other layer.
  312. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  313. * LayerMask is set through advancedTexture.layer.layerMask
  314. * @param name defines name for the texture
  315. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  316. * @param scene defines the hsoting scene
  317. * @param sampling defines the texture sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  318. * @returns a new AdvancedDynamicTexture
  319. */
  320. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: Nullable<Scene>, sampling?: number): AdvancedDynamicTexture;
  321. }
  322. }
  323. declare module BABYLON.GUI {
  324. /**
  325. * Class used to store 2D control sizes
  326. */
  327. class Measure {
  328. /** defines left coordinate */
  329. left: number;
  330. /** defines top coordinate */
  331. top: number;
  332. /** defines width dimension */
  333. width: number;
  334. /** defines height dimension */
  335. height: number;
  336. /**
  337. * Creates a new measure
  338. * @param left defines left coordinate
  339. * @param top defines top coordinate
  340. * @param width defines width dimension
  341. * @param height defines height dimension
  342. */
  343. constructor(
  344. /** defines left coordinate */
  345. left: number,
  346. /** defines top coordinate */
  347. top: number,
  348. /** defines width dimension */
  349. width: number,
  350. /** defines height dimension */
  351. height: number);
  352. /**
  353. * Copy from another measure
  354. * @param other defines the other measure to copy from
  355. */
  356. copyFrom(other: Measure): void;
  357. /**
  358. * Check equality between this measure and another one
  359. * @param other defines the other measures
  360. * @returns true if both measures are equals
  361. */
  362. isEqualsTo(other: Measure): boolean;
  363. /**
  364. * Creates an empty measure
  365. * @returns a new measure
  366. */
  367. static Empty(): Measure;
  368. }
  369. }
  370. declare module BABYLON.GUI {
  371. /**
  372. * Class used to transport Vector2 information for pointer events
  373. */
  374. class Vector2WithInfo extends Vector2 {
  375. /** defines the current mouse button index */
  376. buttonIndex: number;
  377. /**
  378. * Creates a new Vector2WithInfo
  379. * @param source defines the vector2 data to transport
  380. * @param buttonIndex defines the current mouse button index
  381. */
  382. constructor(source: Vector2,
  383. /** defines the current mouse button index */
  384. buttonIndex?: number);
  385. }
  386. /** Class used to provide 2D matrix features */
  387. class Matrix2D {
  388. /** Gets the internal array of 6 floats used to store matrix data */
  389. m: Float32Array;
  390. /**
  391. * Creates a new matrix
  392. * @param m00 defines value for (0, 0)
  393. * @param m01 defines value for (0, 1)
  394. * @param m10 defines value for (1, 0)
  395. * @param m11 defines value for (1, 1)
  396. * @param m20 defines value for (2, 0)
  397. * @param m21 defines value for (2, 1)
  398. */
  399. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  400. /**
  401. * Fills the matrix from direct values
  402. * @param m00 defines value for (0, 0)
  403. * @param m01 defines value for (0, 1)
  404. * @param m10 defines value for (1, 0)
  405. * @param m11 defines value for (1, 1)
  406. * @param m20 defines value for (2, 0)
  407. * @param m21 defines value for (2, 1)
  408. * @returns the current modified matrix
  409. */
  410. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  411. /**
  412. * Gets matrix determinant
  413. * @returns the determinant
  414. */
  415. determinant(): number;
  416. /**
  417. * Inverses the matrix and stores it in a target matrix
  418. * @param result defines the target matrix
  419. * @returns the current matrix
  420. */
  421. invertToRef(result: Matrix2D): Matrix2D;
  422. /**
  423. * Multiplies the current matrix with another one
  424. * @param other defines the second operand
  425. * @param result defines the target matrix
  426. * @returns the current matrix
  427. */
  428. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  429. /**
  430. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  431. * @param x defines the x coordinate to transform
  432. * @param y defines the x coordinate to transform
  433. * @param result defines the target vector2
  434. * @returns the current matrix
  435. */
  436. transformCoordinates(x: number, y: number, result: Vector2): Matrix2D;
  437. /**
  438. * Creates an identity matrix
  439. * @returns a new matrix
  440. */
  441. static Identity(): Matrix2D;
  442. /**
  443. * Creates a translation matrix and stores it in a target matrix
  444. * @param x defines the x coordinate of the translation
  445. * @param y defines the y coordinate of the translation
  446. * @param result defines the target matrix
  447. */
  448. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  449. /**
  450. * Creates a scaling matrix and stores it in a target matrix
  451. * @param x defines the x coordinate of the scaling
  452. * @param y defines the y coordinate of the scaling
  453. * @param result defines the target matrix
  454. */
  455. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  456. /**
  457. * Creates a rotation matrix and stores it in a target matrix
  458. * @param angle defines the rotation angle
  459. * @param result defines the target matrix
  460. */
  461. static RotationToRef(angle: number, result: Matrix2D): void;
  462. private static _TempPreTranslationMatrix;
  463. private static _TempPostTranslationMatrix;
  464. private static _TempRotationMatrix;
  465. private static _TempScalingMatrix;
  466. private static _TempCompose0;
  467. private static _TempCompose1;
  468. private static _TempCompose2;
  469. /**
  470. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  471. * @param tx defines the x coordinate of the translation
  472. * @param ty defines the y coordinate of the translation
  473. * @param angle defines the rotation angle
  474. * @param scaleX defines the x coordinate of the scaling
  475. * @param scaleY defines the y coordinate of the scaling
  476. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  477. * @param result defines the target matrix
  478. */
  479. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: Nullable<Matrix2D>, result: Matrix2D): void;
  480. }
  481. }
  482. declare module BABYLON.GUI {
  483. /**
  484. * Class used to store a point for a MultiLine object.
  485. * The point can be pure 2D coordinates, a mesh or a control
  486. */
  487. class MultiLinePoint {
  488. private _multiLine;
  489. private _x;
  490. private _y;
  491. private _control;
  492. private _mesh;
  493. private _controlObserver;
  494. private _meshObserver;
  495. /** @hidden */
  496. _point: Vector2;
  497. /**
  498. * Creates a new MultiLinePoint
  499. * @param multiLine defines the source MultiLine object
  500. */
  501. constructor(multiLine: MultiLine);
  502. /** Gets or sets x coordinate */
  503. x: string | number;
  504. /** Gets or sets y coordinate */
  505. y: string | number;
  506. /** Gets or sets the control associated with this point */
  507. control: Nullable<Control>;
  508. /** Gets or sets the mesh associated with this point */
  509. mesh: Nullable<AbstractMesh>;
  510. /**
  511. * Gets a translation vector
  512. * @returns the translation vector
  513. */
  514. translate(): Vector2;
  515. private _translatePoint();
  516. /** Release associated resources */
  517. dispose(): void;
  518. }
  519. }
  520. declare module BABYLON.GUI {
  521. /**
  522. * Root class used for all 2D controls
  523. * @see http://doc.babylonjs.com/how_to/gui#controls
  524. */
  525. class Control {
  526. /** defines the name of the control */
  527. name: string | undefined;
  528. private _alpha;
  529. private _alphaSet;
  530. private _zIndex;
  531. /** @hidden */
  532. _root: Nullable<Container>;
  533. /** @hidden */
  534. _host: AdvancedDynamicTexture;
  535. /** Gets or sets the control parent */
  536. parent: Nullable<Container>;
  537. /** @hidden */
  538. _currentMeasure: Measure;
  539. private _fontFamily;
  540. private _fontStyle;
  541. private _fontWeight;
  542. private _fontSize;
  543. private _font;
  544. /** @hidden */
  545. _width: ValueAndUnit;
  546. /** @hidden */
  547. _height: ValueAndUnit;
  548. /** @hidden */
  549. protected _fontOffset: {
  550. ascent: number;
  551. height: number;
  552. descent: number;
  553. };
  554. private _color;
  555. private _style;
  556. private _styleObserver;
  557. /** @hidden */
  558. protected _horizontalAlignment: number;
  559. /** @hidden */
  560. protected _verticalAlignment: number;
  561. private _isDirty;
  562. /** @hidden */
  563. _tempParentMeasure: Measure;
  564. /** @hidden */
  565. protected _cachedParentMeasure: Measure;
  566. private _paddingLeft;
  567. private _paddingRight;
  568. private _paddingTop;
  569. private _paddingBottom;
  570. /** @hidden */
  571. _left: ValueAndUnit;
  572. /** @hidden */
  573. _top: ValueAndUnit;
  574. private _scaleX;
  575. private _scaleY;
  576. private _rotation;
  577. private _transformCenterX;
  578. private _transformCenterY;
  579. private _transformMatrix;
  580. /** @hidden */
  581. protected _invertTransformMatrix: Matrix2D;
  582. /** @hidden */
  583. protected _transformedPosition: Vector2;
  584. private _onlyMeasureMode;
  585. private _isMatrixDirty;
  586. private _cachedOffsetX;
  587. private _cachedOffsetY;
  588. private _isVisible;
  589. /** @hidden */
  590. _linkedMesh: Nullable<AbstractMesh>;
  591. private _fontSet;
  592. private _dummyVector2;
  593. private _downCount;
  594. private _enterCount;
  595. private _doNotRender;
  596. private _downPointerIds;
  597. /** @hidden */
  598. _tag: any;
  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: Nullable<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 _isVertical;
  1174. private _background;
  1175. private _borderColor;
  1176. private _barOffset;
  1177. private _isThumbCircle;
  1178. private _isThumbClamped;
  1179. /** Observable raised when the sldier value changes */
  1180. onValueChangedObservable: Observable<number>;
  1181. /** Gets or sets border color */
  1182. borderColor: string;
  1183. /** Gets or sets background color */
  1184. background: string;
  1185. /** Gets or sets main bar offset */
  1186. barOffset: string | number;
  1187. /** Gets main bar offset in pixels*/
  1188. readonly barOffsetInPixels: number;
  1189. /** Gets or sets thumb width */
  1190. thumbWidth: string | number;
  1191. /** Gets thumb width in pixels */
  1192. readonly thumbWidthInPixels: number;
  1193. /** Gets or sets minimum value */
  1194. minimum: number;
  1195. /** Gets or sets maximum value */
  1196. maximum: number;
  1197. /** Gets or sets current value */
  1198. value: number;
  1199. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  1200. isVertical: boolean;
  1201. /** Gets or sets a boolean indicating if the thumb should be round or square */
  1202. isThumbCircle: boolean;
  1203. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  1204. isThumbClamped: boolean;
  1205. /**
  1206. * Creates a new Slider
  1207. * @param name defines the control name
  1208. */
  1209. constructor(name?: string | undefined);
  1210. protected _getTypeName(): string;
  1211. protected _getThumbThickness(type: string, backgroundLength: number): number;
  1212. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1213. private _pointerIsDown;
  1214. private _updateValueFromPointer(x, y);
  1215. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1216. _onPointerMove(target: Control, coordinates: Vector2): void;
  1217. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  1218. }
  1219. }
  1220. declare module BABYLON.GUI {
  1221. /**
  1222. * Class used to represent a 2D checkbox
  1223. */
  1224. class Checkbox extends Control {
  1225. name: string | undefined;
  1226. private _isChecked;
  1227. private _background;
  1228. private _checkSizeRatio;
  1229. private _thickness;
  1230. /** Gets or sets border thickness */
  1231. thickness: number;
  1232. /**
  1233. * Observable raised when isChecked property changes
  1234. */
  1235. onIsCheckedChangedObservable: Observable<boolean>;
  1236. /** Gets or sets a value indicating the ratio between overall size and check size */
  1237. checkSizeRatio: number;
  1238. /** Gets or sets background color */
  1239. background: string;
  1240. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1241. isChecked: boolean;
  1242. /**
  1243. * Creates a new CheckBox
  1244. * @param name defines the control name
  1245. */
  1246. constructor(name?: string | undefined);
  1247. protected _getTypeName(): string;
  1248. /** @hidden */
  1249. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1250. /** @hidden */
  1251. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1252. }
  1253. }
  1254. declare module BABYLON.GUI {
  1255. /**
  1256. * Class used to create radio button controls
  1257. */
  1258. class RadioButton extends Control {
  1259. name: string | undefined;
  1260. private _isChecked;
  1261. private _background;
  1262. private _checkSizeRatio;
  1263. private _thickness;
  1264. /** Gets or sets border thickness */
  1265. thickness: number;
  1266. /** Gets or sets group name */
  1267. group: string;
  1268. /** Observable raised when isChecked is changed */
  1269. onIsCheckedChangedObservable: Observable<boolean>;
  1270. /** Gets or sets a value indicating the ratio between overall size and check size */
  1271. checkSizeRatio: number;
  1272. /** Gets or sets background color */
  1273. background: string;
  1274. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1275. isChecked: boolean;
  1276. /**
  1277. * Creates a new RadioButton
  1278. * @param name defines the control name
  1279. */
  1280. constructor(name?: string | undefined);
  1281. protected _getTypeName(): string;
  1282. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1283. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1284. }
  1285. }
  1286. declare module BABYLON.GUI {
  1287. /**
  1288. * Enum that determines the text-wrapping mode to use.
  1289. */
  1290. enum TextWrapping {
  1291. /**
  1292. * Clip the text when it's larger than Control.width; this is the default mode.
  1293. */
  1294. Clip = 0,
  1295. /**
  1296. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  1297. */
  1298. WordWrap = 1,
  1299. /**
  1300. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  1301. */
  1302. Ellipsis = 2,
  1303. }
  1304. /**
  1305. * Class used to create text block control
  1306. */
  1307. class TextBlock extends Control {
  1308. /**
  1309. * Defines the name of the control
  1310. */
  1311. name: string | undefined;
  1312. private _text;
  1313. private _textWrapping;
  1314. private _textHorizontalAlignment;
  1315. private _textVerticalAlignment;
  1316. private _lines;
  1317. private _resizeToFit;
  1318. private _lineSpacing;
  1319. private _outlineWidth;
  1320. private _outlineColor;
  1321. /**
  1322. * An event triggered after the text is changed
  1323. */
  1324. onTextChangedObservable: Observable<TextBlock>;
  1325. /**
  1326. * An event triggered after the text was broken up into lines
  1327. */
  1328. onLinesReadyObservable: Observable<TextBlock>;
  1329. /**
  1330. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  1331. */
  1332. readonly lines: any[];
  1333. /**
  1334. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  1335. */
  1336. /**
  1337. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  1338. */
  1339. resizeToFit: boolean;
  1340. /**
  1341. * Gets or sets a boolean indicating if text must be wrapped
  1342. */
  1343. /**
  1344. * Gets or sets a boolean indicating if text must be wrapped
  1345. */
  1346. textWrapping: TextWrapping | boolean;
  1347. /**
  1348. * Gets or sets text to display
  1349. */
  1350. /**
  1351. * Gets or sets text to display
  1352. */
  1353. text: string;
  1354. /**
  1355. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  1356. */
  1357. /**
  1358. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  1359. */
  1360. textHorizontalAlignment: number;
  1361. /**
  1362. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  1363. */
  1364. /**
  1365. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  1366. */
  1367. textVerticalAlignment: number;
  1368. /**
  1369. * Gets or sets line spacing value
  1370. */
  1371. /**
  1372. * Gets or sets line spacing value
  1373. */
  1374. lineSpacing: string | number;
  1375. /**
  1376. * Gets or sets outlineWidth of the text to display
  1377. */
  1378. /**
  1379. * Gets or sets outlineWidth of the text to display
  1380. */
  1381. outlineWidth: number;
  1382. /**
  1383. * Gets or sets outlineColor of the text to display
  1384. */
  1385. /**
  1386. * Gets or sets outlineColor of the text to display
  1387. */
  1388. outlineColor: string;
  1389. /**
  1390. * Creates a new TextBlock object
  1391. * @param name defines the name of the control
  1392. * @param text defines the text to display (emptry string by default)
  1393. */
  1394. constructor(
  1395. /**
  1396. * Defines the name of the control
  1397. */
  1398. name?: string | undefined, text?: string);
  1399. protected _getTypeName(): string;
  1400. private _drawText(text, textWidth, y, context);
  1401. /** @hidden */
  1402. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1403. protected _applyStates(context: CanvasRenderingContext2D): void;
  1404. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1405. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  1406. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  1407. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  1408. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  1409. protected _renderLines(context: CanvasRenderingContext2D): void;
  1410. /**
  1411. * Given a width constraint applied on the text block, find the expected height
  1412. * @returns expected height
  1413. */
  1414. computeExpectedHeight(): number;
  1415. dispose(): void;
  1416. }
  1417. }
  1418. declare var DOMImage: new (width?: number | undefined, height?: number | undefined) => HTMLImageElement;
  1419. declare module BABYLON.GUI {
  1420. /**
  1421. * Class used to create 2D images
  1422. */
  1423. class Image extends Control {
  1424. name: string | undefined;
  1425. private _domImage;
  1426. private _imageWidth;
  1427. private _imageHeight;
  1428. private _loaded;
  1429. private _stretch;
  1430. private _source;
  1431. private _autoScale;
  1432. private _sourceLeft;
  1433. private _sourceTop;
  1434. private _sourceWidth;
  1435. private _sourceHeight;
  1436. private _cellWidth;
  1437. private _cellHeight;
  1438. private _cellId;
  1439. /**
  1440. * Gets or sets the left coordinate in the source image
  1441. */
  1442. sourceLeft: number;
  1443. /**
  1444. * Gets or sets the top coordinate in the source image
  1445. */
  1446. sourceTop: number;
  1447. /**
  1448. * Gets or sets the width to capture in the source image
  1449. */
  1450. sourceWidth: number;
  1451. /**
  1452. * Gets or sets the height to capture in the source image
  1453. */
  1454. sourceHeight: number;
  1455. /**
  1456. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  1457. * @see http://doc.babylonjs.com/how_to/gui#image
  1458. */
  1459. autoScale: boolean;
  1460. /** Gets or sets the streching mode used by the image */
  1461. stretch: number;
  1462. /**
  1463. * Gets or sets the internal DOM image used to render the control
  1464. */
  1465. domImage: HTMLImageElement;
  1466. private _onImageLoaded();
  1467. /**
  1468. * Gets or sets image source url
  1469. */
  1470. source: Nullable<string>;
  1471. /**
  1472. * Gets or sets the cell width to use when animation sheet is enabled
  1473. * @see http://doc.babylonjs.com/how_to/gui#image
  1474. */
  1475. cellWidth: number;
  1476. /**
  1477. * Gets or sets the cell height to use when animation sheet is enabled
  1478. * @see http://doc.babylonjs.com/how_to/gui#image
  1479. */
  1480. cellHeight: number;
  1481. /**
  1482. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  1483. * @see http://doc.babylonjs.com/how_to/gui#image
  1484. */
  1485. cellId: number;
  1486. /**
  1487. * Creates a new Image
  1488. * @param name defines the control name
  1489. * @param url defines the image url
  1490. */
  1491. constructor(name?: string | undefined, url?: Nullable<string>);
  1492. protected _getTypeName(): string;
  1493. /** Force the control to synchronize with its content */
  1494. synchronizeSizeWithContent(): void;
  1495. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1496. private static _STRETCH_NONE;
  1497. private static _STRETCH_FILL;
  1498. private static _STRETCH_UNIFORM;
  1499. private static _STRETCH_EXTEND;
  1500. /** STRETCH_NONE */
  1501. static readonly STRETCH_NONE: number;
  1502. /** STRETCH_FILL */
  1503. static readonly STRETCH_FILL: number;
  1504. /** STRETCH_UNIFORM */
  1505. static readonly STRETCH_UNIFORM: number;
  1506. /** STRETCH_EXTEND */
  1507. static readonly STRETCH_EXTEND: number;
  1508. }
  1509. }
  1510. declare module BABYLON.GUI {
  1511. /**
  1512. * Class used to create 2D buttons
  1513. */
  1514. class Button extends Rectangle {
  1515. name: string | undefined;
  1516. /**
  1517. * Function called to generate a pointer enter animation
  1518. */
  1519. pointerEnterAnimation: () => void;
  1520. /**
  1521. * Function called to generate a pointer out animation
  1522. */
  1523. pointerOutAnimation: () => void;
  1524. /**
  1525. * Function called to generate a pointer down animation
  1526. */
  1527. pointerDownAnimation: () => void;
  1528. /**
  1529. * Function called to generate a pointer up animation
  1530. */
  1531. pointerUpAnimation: () => void;
  1532. /**
  1533. * Creates a new Button
  1534. * @param name defines the name of the button
  1535. */
  1536. constructor(name?: string | undefined);
  1537. protected _getTypeName(): string;
  1538. /** @hidden */
  1539. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  1540. /** @hidden */
  1541. _onPointerEnter(target: Control): boolean;
  1542. /** @hidden */
  1543. _onPointerOut(target: Control): void;
  1544. /** @hidden */
  1545. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1546. /** @hidden */
  1547. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  1548. /**
  1549. * Creates a new button made with an image and a text
  1550. * @param name defines the name of the button
  1551. * @param text defines the text of the button
  1552. * @param imageUrl defines the url of the image
  1553. * @returns a new Button
  1554. */
  1555. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  1556. /**
  1557. * Creates a new button made with an image
  1558. * @param name defines the name of the button
  1559. * @param imageUrl defines the url of the image
  1560. * @returns a new Button
  1561. */
  1562. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  1563. /**
  1564. * Creates a new button made with a text
  1565. * @param name defines the name of the button
  1566. * @param text defines the text of the button
  1567. * @returns a new Button
  1568. */
  1569. static CreateSimpleButton(name: string, text: string): Button;
  1570. /**
  1571. * Creates a new button made with an image and a centered text
  1572. * @param name defines the name of the button
  1573. * @param text defines the text of the button
  1574. * @param imageUrl defines the url of the image
  1575. * @returns a new Button
  1576. */
  1577. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  1578. }
  1579. }
  1580. declare module BABYLON.GUI {
  1581. /** Class used to create color pickers */
  1582. class ColorPicker extends Control {
  1583. name: string | undefined;
  1584. private _colorWheelCanvas;
  1585. private _value;
  1586. private _tmpColor;
  1587. private _pointerStartedOnSquare;
  1588. private _pointerStartedOnWheel;
  1589. private _squareLeft;
  1590. private _squareTop;
  1591. private _squareSize;
  1592. private _h;
  1593. private _s;
  1594. private _v;
  1595. /**
  1596. * Observable raised when the value changes
  1597. */
  1598. onValueChangedObservable: Observable<Color3>;
  1599. /** Gets or sets the color of the color picker */
  1600. value: Color3;
  1601. /** Gets or sets control width */
  1602. width: string | number;
  1603. /** Gets or sets control height */
  1604. height: string | number;
  1605. /** Gets or sets control size */
  1606. size: string | number;
  1607. /**
  1608. * Creates a new ColorPicker
  1609. * @param name defines the control name
  1610. */
  1611. constructor(name?: string | undefined);
  1612. protected _getTypeName(): string;
  1613. private _updateSquareProps();
  1614. private _drawGradientSquare(hueValue, left, top, width, height, context);
  1615. private _drawCircle(centerX, centerY, radius, context);
  1616. private _createColorWheelCanvas(radius, thickness);
  1617. private _RGBtoHSV(color, result);
  1618. private _HSVtoRGB(hue, saturation, value, result);
  1619. /** @hidden */
  1620. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1621. private _pointerIsDown;
  1622. private _updateValueFromPointer(x, y);
  1623. private _isPointOnSquare(coordinates);
  1624. private _isPointOnWheel(coordinates);
  1625. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1626. _onPointerMove(target: Control, coordinates: Vector2): void;
  1627. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  1628. }
  1629. }
  1630. declare module BABYLON.GUI {
  1631. /**
  1632. * Class used to create input text control
  1633. */
  1634. class InputText extends Control implements IFocusableControl {
  1635. name: string | undefined;
  1636. private _text;
  1637. private _placeholderText;
  1638. private _background;
  1639. private _focusedBackground;
  1640. private _placeholderColor;
  1641. private _thickness;
  1642. private _margin;
  1643. private _autoStretchWidth;
  1644. private _maxWidth;
  1645. private _isFocused;
  1646. private _blinkTimeout;
  1647. private _blinkIsEven;
  1648. private _cursorOffset;
  1649. private _scrollLeft;
  1650. private _textWidth;
  1651. private _clickedCoordinate;
  1652. private _deadKey;
  1653. private _addKey;
  1654. private _currentKey;
  1655. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  1656. promptMessage: string;
  1657. /** Observable raised when the text changes */
  1658. onTextChangedObservable: Observable<InputText>;
  1659. /** Observable raised just before an entered character is to be added */
  1660. onBeforeKeyAddObservable: Observable<InputText>;
  1661. /** Observable raised when the control gets the focus */
  1662. onFocusObservable: Observable<InputText>;
  1663. /** Observable raised when the control loses the focus */
  1664. onBlurObservable: Observable<InputText>;
  1665. /** Gets or sets the maximum width allowed by the control */
  1666. maxWidth: string | number;
  1667. /** Gets the maximum width allowed by the control in pixels */
  1668. readonly maxWidthInPixels: number;
  1669. /** Gets or sets control margin */
  1670. margin: string;
  1671. /** Gets control margin in pixels */
  1672. readonly marginInPixels: number;
  1673. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  1674. autoStretchWidth: boolean;
  1675. /** Gets or sets border thickness */
  1676. thickness: number;
  1677. /** Gets or sets the background color when focused */
  1678. focusedBackground: string;
  1679. /** Gets or sets the background color */
  1680. background: string;
  1681. /** Gets or sets the placeholder color */
  1682. placeholderColor: string;
  1683. /** Gets or sets the text displayed when the control is empty */
  1684. placeholderText: string;
  1685. /** Gets or sets the dead key flag */
  1686. deadKey: boolean;
  1687. /** Gets or sets if the current key should be added */
  1688. addKey: boolean;
  1689. /** Gets or sets the value of the current key being entered */
  1690. currentKey: string;
  1691. /** Gets or sets the text displayed in the control */
  1692. text: string;
  1693. /** Gets or sets control width */
  1694. width: string | number;
  1695. /**
  1696. * Creates a new InputText
  1697. * @param name defines the control name
  1698. * @param text defines the text of the control
  1699. */
  1700. constructor(name?: string | undefined, text?: string);
  1701. /** @hidden */
  1702. onBlur(): void;
  1703. /** @hidden */
  1704. onFocus(): void;
  1705. protected _getTypeName(): string;
  1706. /** @hidden */
  1707. processKey(keyCode: number, key?: string): void;
  1708. /** @hidden */
  1709. processKeyboard(evt: KeyboardEvent): void;
  1710. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1711. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1712. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  1713. protected _beforeRenderText(text: string): string;
  1714. dispose(): void;
  1715. }
  1716. }
  1717. declare module BABYLON.GUI {
  1718. /**
  1719. * Class used to create a password control
  1720. */
  1721. class InputPassword extends InputText {
  1722. protected _beforeRenderText(text: string): string;
  1723. }
  1724. }
  1725. declare module BABYLON.GUI {
  1726. /**
  1727. * Class used to store key control properties
  1728. */
  1729. class KeyPropertySet {
  1730. /** Width */
  1731. width?: string;
  1732. /** Height */
  1733. height?: string;
  1734. /** Left padding */
  1735. paddingLeft?: string;
  1736. /** Right padding */
  1737. paddingRight?: string;
  1738. /** Top padding */
  1739. paddingTop?: string;
  1740. /** Bottom padding */
  1741. paddingBottom?: string;
  1742. /** Foreground color */
  1743. color?: string;
  1744. /** Background color */
  1745. background?: string;
  1746. }
  1747. /**
  1748. * Class used to create virtual keyboard
  1749. */
  1750. class VirtualKeyboard extends StackPanel {
  1751. /** Observable raised when a key is pressed */
  1752. onKeyPressObservable: Observable<string>;
  1753. /** Gets or sets default key button width */
  1754. defaultButtonWidth: string;
  1755. /** Gets or sets default key button height */
  1756. defaultButtonHeight: string;
  1757. /** Gets or sets default key button left padding */
  1758. defaultButtonPaddingLeft: string;
  1759. /** Gets or sets default key button right padding */
  1760. defaultButtonPaddingRight: string;
  1761. /** Gets or sets default key button top padding */
  1762. defaultButtonPaddingTop: string;
  1763. /** Gets or sets default key button bottom padding */
  1764. defaultButtonPaddingBottom: string;
  1765. /** Gets or sets default key button foreground color */
  1766. defaultButtonColor: string;
  1767. /** Gets or sets default key button background color */
  1768. defaultButtonBackground: string;
  1769. /** Gets or sets shift button foreground color */
  1770. shiftButtonColor: string;
  1771. /** Gets or sets shift button thickness*/
  1772. selectedShiftThickness: number;
  1773. /** Gets shift key state */
  1774. shiftState: number;
  1775. protected _getTypeName(): string;
  1776. private _createKey(key, propertySet);
  1777. /**
  1778. * Adds a new row of keys
  1779. * @param keys defines the list of keys to add
  1780. * @param propertySets defines the associated property sets
  1781. */
  1782. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  1783. /**
  1784. * Set the shift key to a specific state
  1785. * @param shiftState defines the new shift state
  1786. */
  1787. applyShiftState(shiftState: number): void;
  1788. private _connectedInputText;
  1789. private _onFocusObserver;
  1790. private _onBlurObserver;
  1791. private _onKeyPressObserver;
  1792. /** Gets the input text control attached with the keyboard */
  1793. readonly connectedInputText: Nullable<InputText>;
  1794. /**
  1795. * Connects the keyboard with an input text control
  1796. * @param input defines the target control
  1797. */
  1798. connect(input: InputText): void;
  1799. /**
  1800. * Disconnects the keyboard from an input text control
  1801. */
  1802. disconnect(): void;
  1803. /**
  1804. * Creates a new keyboard using a default layout
  1805. * @returns a new VirtualKeyboard
  1806. */
  1807. static CreateDefaultLayout(): VirtualKeyboard;
  1808. }
  1809. }
  1810. declare module BABYLON.GUI {
  1811. /**
  1812. * Class used to create multi line control
  1813. */
  1814. class MultiLine extends Control {
  1815. name: string | undefined;
  1816. private _lineWidth;
  1817. private _dash;
  1818. private _points;
  1819. private _minX;
  1820. private _minY;
  1821. private _maxX;
  1822. private _maxY;
  1823. /**
  1824. * Creates a new MultiLine
  1825. * @param name defines the control name
  1826. */
  1827. constructor(name?: string | undefined);
  1828. /** Gets or sets dash pattern */
  1829. dash: Array<number>;
  1830. /**
  1831. * Gets point stored at specified index
  1832. * @param index defines the index to look for
  1833. * @returns the requested point if found
  1834. */
  1835. getAt(index: number): MultiLinePoint;
  1836. /** Function called when a point is updated */
  1837. onPointUpdate: () => void;
  1838. /**
  1839. * Adds new points to the point collection
  1840. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  1841. * @returns the list of created MultiLinePoint
  1842. */
  1843. add(...items: (AbstractMesh | Control | {
  1844. x: string | number;
  1845. y: string | number;
  1846. })[]): MultiLinePoint[];
  1847. /**
  1848. * Adds a new point to the point collection
  1849. * @param item defines the item (mesh, control or 2d coordiantes) to add
  1850. * @returns the created MultiLinePoint
  1851. */
  1852. push(item?: (AbstractMesh | Control | {
  1853. x: string | number;
  1854. y: string | number;
  1855. })): MultiLinePoint;
  1856. /**
  1857. * Remove a specific value or point from the active point collection
  1858. * @param value defines the value or point to remove
  1859. */
  1860. remove(value: number | MultiLinePoint): void;
  1861. /** Gets or sets line width */
  1862. lineWidth: number;
  1863. horizontalAlignment: number;
  1864. verticalAlignment: number;
  1865. protected _getTypeName(): string;
  1866. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1867. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1868. _measure(): void;
  1869. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1870. dispose(): void;
  1871. }
  1872. }
  1873. declare module BABYLON.GUI {
  1874. /**
  1875. * Class used to create a 2D grid container
  1876. */
  1877. class Grid extends Container {
  1878. name: string | undefined;
  1879. private _rowDefinitions;
  1880. private _columnDefinitions;
  1881. private _cells;
  1882. private _childControls;
  1883. /** Gets the list of children */
  1884. readonly children: Control[];
  1885. /**
  1886. * Adds a new row to the grid
  1887. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  1888. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  1889. * @returns the current grid
  1890. */
  1891. addRowDefinition(height: number, isPixel?: boolean): Grid;
  1892. /**
  1893. * Adds a new column to the grid
  1894. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  1895. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  1896. * @returns the current grid
  1897. */
  1898. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  1899. /**
  1900. * Update a row definition
  1901. * @param index defines the index of the row to update
  1902. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  1903. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  1904. * @returns the current grid
  1905. */
  1906. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  1907. /**
  1908. * Update a column definition
  1909. * @param index defines the index of the column to update
  1910. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  1911. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  1912. * @returns the current grid
  1913. */
  1914. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  1915. private _removeCell(cell, key);
  1916. private _offsetCell(previousKey, key);
  1917. /**
  1918. * Remove a column definition at specified index
  1919. * @param index defines the index of the column to remove
  1920. * @returns the current grid
  1921. */
  1922. removeColumnDefinition(index: number): Grid;
  1923. /**
  1924. * Remove a row definition at specified index
  1925. * @param index defines the index of the row to remove
  1926. * @returns the current grid
  1927. */
  1928. removeRowDefinition(index: number): Grid;
  1929. /**
  1930. * Adds a new control to the current grid
  1931. * @param control defines the control to add
  1932. * @param row defines the row where to add the control (0 by default)
  1933. * @param column defines the column where to add the control (0 by default)
  1934. * @returns the current grid
  1935. */
  1936. addControl(control: Control, row?: number, column?: number): Grid;
  1937. /**
  1938. * Removes a control from the current container
  1939. * @param control defines the control to remove
  1940. * @returns the current container
  1941. */
  1942. removeControl(control: Control): Container;
  1943. /**
  1944. * Creates a new Grid
  1945. * @param name defines control name
  1946. */
  1947. constructor(name?: string | undefined);
  1948. protected _getTypeName(): string;
  1949. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1950. /** Releases associated resources */
  1951. dispose(): void;
  1952. }
  1953. }
  1954. declare module BABYLON.GUI {
  1955. /**
  1956. * Class used to manage 3D user interface
  1957. * @see http://doc.babylonjs.com/how_to/gui3d
  1958. */
  1959. class GUI3DManager implements BABYLON.IDisposable {
  1960. private _scene;
  1961. private _sceneDisposeObserver;
  1962. private _utilityLayer;
  1963. private _rootContainer;
  1964. private _pointerObserver;
  1965. private _pointerOutObserver;
  1966. /** @hidden */
  1967. _lastPickedControl: Control3D;
  1968. /** @hidden */
  1969. _lastControlOver: {
  1970. [pointerId: number]: Control3D;
  1971. };
  1972. /** @hidden */
  1973. _lastControlDown: {
  1974. [pointerId: number]: Control3D;
  1975. };
  1976. /**
  1977. * Observable raised when the point picked by the pointer events changed
  1978. */
  1979. onPickedPointChangedObservable: Observable<Nullable<Vector3>>;
  1980. /** @hidden */
  1981. _sharedMaterials: {
  1982. [key: string]: Material;
  1983. };
  1984. /** Gets the hosting scene */
  1985. readonly scene: Scene;
  1986. /** Gets associated utility layer */
  1987. readonly utilityLayer: Nullable<UtilityLayerRenderer>;
  1988. /**
  1989. * Creates a new GUI3DManager
  1990. * @param scene
  1991. */
  1992. constructor(scene?: Scene);
  1993. private _handlePointerOut(pointerId, isPointerUp);
  1994. private _doPicking(pi);
  1995. /**
  1996. * Gets the root container
  1997. */
  1998. readonly rootContainer: Container3D;
  1999. /**
  2000. * Gets a boolean indicating if the given control is in the root child list
  2001. * @param control defines the control to check
  2002. * @returns true if the control is in the root child list
  2003. */
  2004. containsControl(control: Control3D): boolean;
  2005. /**
  2006. * Adds a control to the root child list
  2007. * @param control defines the control to add
  2008. * @returns the current manager
  2009. */
  2010. addControl(control: Control3D): GUI3DManager;
  2011. /**
  2012. * Removes a control from the root child list
  2013. * @param control defines the control to remove
  2014. * @returns the current container
  2015. */
  2016. removeControl(control: Control3D): GUI3DManager;
  2017. /**
  2018. * Releases all associated resources
  2019. */
  2020. dispose(): void;
  2021. }
  2022. }
  2023. declare module BABYLON.GUI {
  2024. /** @hidden */
  2025. class FluentMaterialDefines extends MaterialDefines {
  2026. INNERGLOW: boolean;
  2027. BORDER: boolean;
  2028. HOVERLIGHT: boolean;
  2029. constructor();
  2030. }
  2031. /**
  2032. * Class used to render controls with fluent desgin
  2033. */
  2034. class FluentMaterial extends PushMaterial {
  2035. /**
  2036. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  2037. */
  2038. innerGlowColorIntensity: number;
  2039. /**
  2040. * Gets or sets the inner glow color (white by default)
  2041. */
  2042. innerGlowColor: Color3;
  2043. /**
  2044. * Gets or sets alpha value (default is 1.0)
  2045. */
  2046. alpha: number;
  2047. /**
  2048. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  2049. */
  2050. albedoColor: Color3;
  2051. /**
  2052. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  2053. */
  2054. renderBorders: boolean;
  2055. /**
  2056. * Gets or sets border width (default is 0.5)
  2057. */
  2058. borderWidth: number;
  2059. /**
  2060. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  2061. */
  2062. edgeSmoothingValue: number;
  2063. /**
  2064. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  2065. */
  2066. borderMinValue: number;
  2067. /**
  2068. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  2069. */
  2070. renderHoverLight: boolean;
  2071. /**
  2072. * Gets or sets the radius used to render the hover light (default is 0.15)
  2073. */
  2074. hoverRadius: number;
  2075. /**
  2076. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  2077. */
  2078. hoverColor: Color4;
  2079. /**
  2080. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  2081. */
  2082. hoverPosition: Vector3;
  2083. /**
  2084. * Creates a new Fluent material
  2085. * @param name defines the name of the material
  2086. * @param scene defines the hosting scene
  2087. */
  2088. constructor(name: string, scene: Scene);
  2089. needAlphaBlending(): boolean;
  2090. needAlphaTesting(): boolean;
  2091. getAlphaTestTexture(): Nullable<BaseTexture>;
  2092. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  2093. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  2094. getActiveTextures(): BaseTexture[];
  2095. hasTexture(texture: BaseTexture): boolean;
  2096. dispose(forceDisposeEffect?: boolean): void;
  2097. clone(name: string): FluentMaterial;
  2098. serialize(): any;
  2099. getClassName(): string;
  2100. static Parse(source: any, scene: Scene, rootUrl: string): FluentMaterial;
  2101. }
  2102. }
  2103. declare module BABYLON.GUI {
  2104. /**
  2105. * Class used to transport Vector3 information for pointer events
  2106. */
  2107. class Vector3WithInfo extends Vector3 {
  2108. /** defines the current mouse button index */
  2109. buttonIndex: number;
  2110. /**
  2111. * Creates a new Vector3WithInfo
  2112. * @param source defines the vector3 data to transport
  2113. * @param buttonIndex defines the current mouse button index
  2114. */
  2115. constructor(source: Vector3,
  2116. /** defines the current mouse button index */
  2117. buttonIndex?: number);
  2118. }
  2119. }
  2120. declare module BABYLON.GUI {
  2121. /**
  2122. * Class used as base class for controls
  2123. */
  2124. class Control3D implements IDisposable, IBehaviorAware<Control3D> {
  2125. /** Defines the control name */
  2126. name: string | undefined;
  2127. /** @hidden */
  2128. _host: GUI3DManager;
  2129. private _node;
  2130. private _downCount;
  2131. private _enterCount;
  2132. private _downPointerIds;
  2133. private _isVisible;
  2134. /** Gets or sets the control position in world space */
  2135. position: Vector3;
  2136. /** Gets or sets the control scaling in world space */
  2137. scaling: Vector3;
  2138. /** Callback used to start pointer enter animation */
  2139. pointerEnterAnimation: () => void;
  2140. /** Callback used to start pointer out animation */
  2141. pointerOutAnimation: () => void;
  2142. /** Callback used to start pointer down animation */
  2143. pointerDownAnimation: () => void;
  2144. /** Callback used to start pointer up animation */
  2145. pointerUpAnimation: () => void;
  2146. /**
  2147. * An event triggered when the pointer move over the control
  2148. */
  2149. onPointerMoveObservable: Observable<Vector3>;
  2150. /**
  2151. * An event triggered when the pointer move out of the control
  2152. */
  2153. onPointerOutObservable: Observable<Control3D>;
  2154. /**
  2155. * An event triggered when the pointer taps the control
  2156. */
  2157. onPointerDownObservable: Observable<Vector3WithInfo>;
  2158. /**
  2159. * An event triggered when pointer is up
  2160. */
  2161. onPointerUpObservable: Observable<Vector3WithInfo>;
  2162. /**
  2163. * An event triggered when a control is clicked on (with a mouse)
  2164. */
  2165. onPointerClickObservable: Observable<Vector3WithInfo>;
  2166. /**
  2167. * An event triggered when pointer enters the control
  2168. */
  2169. onPointerEnterObservable: Observable<Control3D>;
  2170. /**
  2171. * Gets or sets the parent container
  2172. */
  2173. parent: Nullable<Container3D>;
  2174. private _behaviors;
  2175. /**
  2176. * Gets the list of attached behaviors
  2177. * @see http://doc.babylonjs.com/features/behaviour
  2178. */
  2179. readonly behaviors: Behavior<Control3D>[];
  2180. /**
  2181. * Attach a behavior to the control
  2182. * @see http://doc.babylonjs.com/features/behaviour
  2183. * @param behavior defines the behavior to attach
  2184. * @returns the current control
  2185. */
  2186. addBehavior(behavior: Behavior<Control3D>): Control3D;
  2187. /**
  2188. * Remove an attached behavior
  2189. * @see http://doc.babylonjs.com/features/behaviour
  2190. * @param behavior defines the behavior to attach
  2191. * @returns the current control
  2192. */
  2193. removeBehavior(behavior: Behavior<Control3D>): Control3D;
  2194. /**
  2195. * Gets an attached behavior by name
  2196. * @param name defines the name of the behavior to look for
  2197. * @see http://doc.babylonjs.com/features/behaviour
  2198. * @returns null if behavior was not found else the requested behavior
  2199. */
  2200. getBehaviorByName(name: string): Nullable<Behavior<Control3D>>;
  2201. /** Gets or sets a boolean indicating if the control is visible */
  2202. isVisible: boolean;
  2203. /**
  2204. * Creates a new control
  2205. * @param name defines the control name
  2206. */
  2207. constructor(
  2208. /** Defines the control name */
  2209. name?: string | undefined);
  2210. /**
  2211. * Gets a string representing the class name
  2212. */
  2213. readonly typeName: string;
  2214. protected _getTypeName(): string;
  2215. /**
  2216. * Gets the transform node used by this control
  2217. */
  2218. readonly node: Nullable<TransformNode>;
  2219. /**
  2220. * Gets the mesh used to render this control
  2221. */
  2222. readonly mesh: Nullable<AbstractMesh>;
  2223. /**
  2224. * Link the control as child of the given node
  2225. * @param node defines the node to link to. Use null to unlink the control
  2226. * @returns the current control
  2227. */
  2228. linkToTransformNode(node: Nullable<TransformNode>): Control3D;
  2229. /** @hidden **/
  2230. _prepareNode(scene: Scene): void;
  2231. /**
  2232. * Node creation.
  2233. * Can be overriden by children
  2234. * @param scene defines the scene where the node must be attached
  2235. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  2236. */
  2237. protected _createNode(scene: Scene): Nullable<TransformNode>;
  2238. /**
  2239. * Affect a material to the given mesh
  2240. * @param mesh defines the mesh which will represent the control
  2241. */
  2242. protected _affectMaterial(mesh: AbstractMesh): void;
  2243. /** @hidden */
  2244. _onPointerMove(target: Control3D, coordinates: Vector3): void;
  2245. /** @hidden */
  2246. _onPointerEnter(target: Control3D): boolean;
  2247. /** @hidden */
  2248. _onPointerOut(target: Control3D): void;
  2249. /** @hidden */
  2250. _onPointerDown(target: Control3D, coordinates: Vector3, pointerId: number, buttonIndex: number): boolean;
  2251. /** @hidden */
  2252. _onPointerUp(target: Control3D, coordinates: Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  2253. /** @hidden */
  2254. forcePointerUp(pointerId?: Nullable<number>): void;
  2255. /** @hidden */
  2256. _processObservables(type: number, pickedPoint: Vector3, pointerId: number, buttonIndex: number): boolean;
  2257. /** @hidden */
  2258. _disposeNode(): void;
  2259. /**
  2260. * Releases all associated resources
  2261. */
  2262. dispose(): void;
  2263. }
  2264. }
  2265. declare module BABYLON.GUI {
  2266. /**
  2267. * Class used to create containers for controls
  2268. */
  2269. class Container3D extends Control3D {
  2270. private _blockLayout;
  2271. /**
  2272. * Gets the list of child controls
  2273. */
  2274. protected _children: Control3D[];
  2275. /**
  2276. * Gets the list of child controls
  2277. */
  2278. readonly children: Array<Control3D>;
  2279. /**
  2280. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  2281. * This is helpful to optimize layout operation when adding multiple children in a row
  2282. */
  2283. blockLayout: boolean;
  2284. /**
  2285. * Creates a new container
  2286. * @param name defines the container name
  2287. */
  2288. constructor(name?: string);
  2289. /**
  2290. * Gets a boolean indicating if the given control is in the children of this control
  2291. * @param control defines the control to check
  2292. * @returns true if the control is in the child list
  2293. */
  2294. containsControl(control: Control3D): boolean;
  2295. /**
  2296. * Adds a control to the children of this control
  2297. * @param control defines the control to add
  2298. * @returns the current container
  2299. */
  2300. addControl(control: Control3D): Container3D;
  2301. /**
  2302. * This function will be called everytime a new control is added
  2303. */
  2304. protected _arrangeChildren(): void;
  2305. protected _createNode(scene: Scene): Nullable<TransformNode>;
  2306. /**
  2307. * Removes a control from the children of this control
  2308. * @param control defines the control to remove
  2309. * @returns the current container
  2310. */
  2311. removeControl(control: Control3D): Container3D;
  2312. protected _getTypeName(): string;
  2313. /**
  2314. * Releases all associated resources
  2315. */
  2316. dispose(): void;
  2317. /** Control rotation will remain unchanged */
  2318. static readonly UNSET_ORIENTATION: number;
  2319. /** Control will rotate to make it look at sphere central axis */
  2320. static readonly FACEORIGIN_ORIENTATION: number;
  2321. /** Control will rotate to make it look back at sphere central axis */
  2322. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  2323. /** Control will rotate to look at z axis (0, 0, 1) */
  2324. static readonly FACEFORWARD_ORIENTATION: number;
  2325. /** Control will rotate to look at negative z axis (0, 0, -1) */
  2326. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  2327. }
  2328. }
  2329. declare module BABYLON.GUI {
  2330. /**
  2331. * Class used as a root to all buttons
  2332. */
  2333. class AbstractButton3D extends Control3D {
  2334. /**
  2335. * Creates a new button
  2336. * @param name defines the control name
  2337. */
  2338. constructor(name?: string);
  2339. protected _getTypeName(): string;
  2340. protected _createNode(scene: Scene): TransformNode;
  2341. }
  2342. }
  2343. declare module BABYLON.GUI {
  2344. /**
  2345. * Class used to create a button in 3D
  2346. */
  2347. class Button3D extends AbstractButton3D {
  2348. /** @hidden */
  2349. protected _currentMaterial: Material;
  2350. private _facadeTexture;
  2351. private _content;
  2352. private _contentResolution;
  2353. private _contentScaleRatio;
  2354. /**
  2355. * Gets or sets the texture resolution used to render content (512 by default)
  2356. */
  2357. contentResolution: int;
  2358. /**
  2359. * Gets or sets the texture scale ratio used to render content (2 by default)
  2360. */
  2361. contentScaleRatio: number;
  2362. protected _disposeFacadeTexture(): void;
  2363. protected _resetContent(): void;
  2364. /**
  2365. * Creates a new button
  2366. * @param name defines the control name
  2367. */
  2368. constructor(name?: string);
  2369. /**
  2370. * Gets or sets the GUI 2D content used to display the button's facade
  2371. */
  2372. content: Control;
  2373. /**
  2374. * Apply the facade texture (created from the content property).
  2375. * This function can be overloaded by child classes
  2376. * @param facadeTexture defines the AdvancedDynamicTexture to use
  2377. */
  2378. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  2379. protected _getTypeName(): string;
  2380. protected _createNode(scene: Scene): TransformNode;
  2381. protected _affectMaterial(mesh: AbstractMesh): void;
  2382. /**
  2383. * Releases all associated resources
  2384. */
  2385. dispose(): void;
  2386. }
  2387. }
  2388. declare module BABYLON.GUI {
  2389. /**
  2390. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  2391. */
  2392. class MeshButton3D extends Button3D {
  2393. /** @hidden */
  2394. protected _currentMesh: Mesh;
  2395. /**
  2396. * Creates a new 3D button based on a mesh
  2397. * @param mesh mesh to become a 3D button
  2398. * @param name defines the control name
  2399. */
  2400. constructor(mesh: Mesh, name?: string);
  2401. protected _getTypeName(): string;
  2402. protected _createNode(scene: Scene): TransformNode;
  2403. protected _affectMaterial(mesh: AbstractMesh): void;
  2404. }
  2405. }
  2406. declare module BABYLON.GUI {
  2407. /**
  2408. * Class used to create a holographic button in 3D
  2409. */
  2410. class HolographicButton extends Button3D {
  2411. private _backPlate;
  2412. private _textPlate;
  2413. private _frontPlate;
  2414. private _text;
  2415. private _imageUrl;
  2416. private _shareMaterials;
  2417. private _frontMaterial;
  2418. private _backMaterial;
  2419. private _plateMaterial;
  2420. private _pickedPointObserver;
  2421. /**
  2422. * Gets or sets text for the button
  2423. */
  2424. text: string;
  2425. /**
  2426. * Gets or sets the image url for the button
  2427. */
  2428. imageUrl: string;
  2429. /**
  2430. * Gets the back material used by this button
  2431. */
  2432. readonly backMaterial: FluentMaterial;
  2433. /**
  2434. * Gets the front material used by this button
  2435. */
  2436. readonly frontMaterial: FluentMaterial;
  2437. /**
  2438. * Gets the plate material used by this button
  2439. */
  2440. readonly plateMaterial: StandardMaterial;
  2441. /**
  2442. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  2443. */
  2444. readonly shareMaterials: boolean;
  2445. /**
  2446. * Creates a new button
  2447. * @param name defines the control name
  2448. */
  2449. constructor(name?: string, shareMaterials?: boolean);
  2450. protected _getTypeName(): string;
  2451. private _rebuildContent();
  2452. protected _createNode(scene: Scene): TransformNode;
  2453. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  2454. private _createBackMaterial(mesh);
  2455. private _createFrontMaterial(mesh);
  2456. private _createPlateMaterial(mesh);
  2457. protected _affectMaterial(mesh: Mesh): void;
  2458. /**
  2459. * Releases all associated resources
  2460. */
  2461. dispose(): void;
  2462. }
  2463. }
  2464. declare module BABYLON.GUI {
  2465. /**
  2466. * Class used to create a stack panel in 3D on XY plane
  2467. */
  2468. class StackPanel3D extends Container3D {
  2469. private _isVertical;
  2470. /**
  2471. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  2472. */
  2473. isVertical: boolean;
  2474. /**
  2475. * Gets or sets the distance between elements
  2476. */
  2477. margin: number;
  2478. /**
  2479. * Creates new StackPanel
  2480. * @param isVertical
  2481. */
  2482. constructor(isVertical?: boolean);
  2483. protected _arrangeChildren(): void;
  2484. }
  2485. }
  2486. declare module BABYLON.GUI {
  2487. /**
  2488. * Abstract class used to create a container panel deployed on the surface of a volume
  2489. */
  2490. abstract class VolumeBasedPanel extends Container3D {
  2491. private _columns;
  2492. private _rows;
  2493. private _rowThenColum;
  2494. private _orientation;
  2495. protected _cellWidth: number;
  2496. protected _cellHeight: number;
  2497. /**
  2498. * Gets or sets the distance between elements
  2499. */
  2500. margin: number;
  2501. /**
  2502. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  2503. * | Value | Type | Description |
  2504. * | ----- | ----------------------------------- | ----------- |
  2505. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  2506. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  2507. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  2508. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  2509. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  2510. */
  2511. orientation: number;
  2512. /**
  2513. * Gets or sets the number of columns requested (10 by default).
  2514. * The panel will automatically compute the number of rows based on number of child controls.
  2515. */
  2516. columns: int;
  2517. /**
  2518. * Gets or sets a the number of rows requested.
  2519. * The panel will automatically compute the number of columns based on number of child controls.
  2520. */
  2521. rows: int;
  2522. /**
  2523. * Creates new SpherePanel
  2524. */
  2525. constructor();
  2526. protected _arrangeChildren(): void;
  2527. /** Child classes must implement this function to provide correct control positioning */
  2528. protected abstract _mapGridNode(control: Control3D, nodePosition: Vector3): void;
  2529. /** Child classes can implement this function to provide additional processing */
  2530. protected _finalProcessing(): void;
  2531. }
  2532. }
  2533. declare module BABYLON.GUI {
  2534. /**
  2535. * Class used to create a container panel deployed on the surface of a sphere
  2536. */
  2537. class SpherePanel extends VolumeBasedPanel {
  2538. private _radius;
  2539. /**
  2540. * Gets or sets the radius of the sphere where to project controls (5 by default)
  2541. */
  2542. radius: float;
  2543. protected _mapGridNode(control: Control3D, nodePosition: Vector3): void;
  2544. private _sphericalMapping(source);
  2545. }
  2546. }
  2547. declare module BABYLON.GUI {
  2548. /**
  2549. * Class used to create a container panel deployed on the surface of a plane
  2550. */
  2551. class PlanePanel extends VolumeBasedPanel {
  2552. protected _mapGridNode(control: Control3D, nodePosition: Vector3): void;
  2553. }
  2554. }
  2555. declare module BABYLON.GUI {
  2556. /**
  2557. * Class used to create a container panel where items get randomized planar mapping
  2558. */
  2559. class ScatterPanel extends VolumeBasedPanel {
  2560. private _iteration;
  2561. /**
  2562. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  2563. */
  2564. iteration: float;
  2565. protected _mapGridNode(control: Control3D, nodePosition: Vector3): void;
  2566. private _scatterMapping(source);
  2567. protected _finalProcessing(): void;
  2568. }
  2569. }
  2570. declare module BABYLON.GUI {
  2571. /**
  2572. * Class used to create a container panel deployed on the surface of a cylinder
  2573. */
  2574. class CylinderPanel extends VolumeBasedPanel {
  2575. private _radius;
  2576. /**
  2577. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  2578. */
  2579. radius: float;
  2580. protected _mapGridNode(control: Control3D, nodePosition: Vector3): void;
  2581. private _cylindricalMapping(source);
  2582. }
  2583. }