babylon.gui.d.ts 122 KB

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