babylon.gui.module.d.ts 97 KB

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