babylon.gui.d.ts 117 KB

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