babylon.gui.d.ts 129 KB

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