babylon.gui.d.ts 118 KB

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