babylon.gui.d.ts 114 KB

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