babylon.gui.d.ts 118 KB

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