babylon.gui.d.ts 123 KB

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