babylon.gui.d.ts 123 KB

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