babylon.gui.module.d.ts 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445
  1. declare module 'babylonjs-gui' {
  2. export = BABYLON.GUI;
  3. }
  4. declare module BABYLON.GUI {
  5. /**
  6. * Define a style used by control to automatically setup properties based on a template.
  7. * Only support font related properties so far
  8. */
  9. class Style implements BABYLON.IDisposable {
  10. private _fontFamily;
  11. private _fontStyle;
  12. private _fontWeight;
  13. /** @hidden */
  14. _host: AdvancedDynamicTexture;
  15. /** @hidden */
  16. _fontSize: ValueAndUnit;
  17. /**
  18. * Observable raised when the style values are changed
  19. */
  20. onChangedObservable: Observable<Style>;
  21. /**
  22. * Creates a new style object
  23. * @param host defines the AdvancedDynamicTexture which hosts this style
  24. */
  25. constructor(host: AdvancedDynamicTexture);
  26. /**
  27. * Gets or sets the font size
  28. */
  29. fontSize: string | number;
  30. /**
  31. * Gets or sets the font family
  32. */
  33. fontFamily: string;
  34. /**
  35. * Gets or sets the font style
  36. */
  37. fontStyle: string;
  38. /** Gets or sets font weight */
  39. fontWeight: string;
  40. /** Dispose all associated resources */
  41. dispose(): void;
  42. }
  43. }
  44. declare module BABYLON.GUI {
  45. class ValueAndUnit {
  46. unit: number;
  47. negativeValueAllowed: boolean;
  48. private _value;
  49. ignoreAdaptiveScaling: boolean;
  50. constructor(value: number, unit?: number, negativeValueAllowed?: boolean);
  51. readonly isPercentage: boolean;
  52. readonly isPixel: boolean;
  53. readonly internalValue: number;
  54. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  55. getValue(host: AdvancedDynamicTexture): number;
  56. toString(host: AdvancedDynamicTexture): string;
  57. fromString(source: string | number): boolean;
  58. private static _Regex;
  59. private static _UNITMODE_PERCENTAGE;
  60. private static _UNITMODE_PIXEL;
  61. static readonly UNITMODE_PERCENTAGE: number;
  62. static readonly UNITMODE_PIXEL: number;
  63. }
  64. }
  65. declare module BABYLON.GUI {
  66. interface IFocusableControl {
  67. onFocus(): void;
  68. onBlur(): void;
  69. processKeyboard(evt: KeyboardEvent): void;
  70. }
  71. class AdvancedDynamicTexture extends DynamicTexture {
  72. private _isDirty;
  73. private _renderObserver;
  74. private _resizeObserver;
  75. private _preKeyboardObserver;
  76. private _pointerMoveObserver;
  77. private _pointerObserver;
  78. private _canvasPointerOutObserver;
  79. private _background;
  80. _rootContainer: Container;
  81. _lastPickedControl: Control;
  82. _lastControlOver: {
  83. [pointerId: number]: Control;
  84. };
  85. _lastControlDown: {
  86. [pointerId: number]: Control;
  87. };
  88. _capturingControl: {
  89. [pointerId: number]: Control;
  90. };
  91. _shouldBlockPointer: boolean;
  92. _layerToDispose: Nullable<Layer>;
  93. _linkedControls: Control[];
  94. private _isFullscreen;
  95. private _fullscreenViewport;
  96. private _idealWidth;
  97. private _idealHeight;
  98. private _useSmallestIdeal;
  99. private _renderAtIdealSize;
  100. private _focusedControl;
  101. private _blockNextFocusCheck;
  102. private _renderScale;
  103. /**
  104. * Gets or sets a boolean defining if alpha is stored as premultiplied
  105. */
  106. premulAlpha: boolean;
  107. renderScale: number;
  108. background: string;
  109. idealWidth: number;
  110. idealHeight: number;
  111. useSmallestIdeal: boolean;
  112. renderAtIdealSize: boolean;
  113. readonly layer: Nullable<Layer>;
  114. readonly rootContainer: Container;
  115. focusedControl: Nullable<IFocusableControl>;
  116. isForeground: boolean;
  117. constructor(name: string, width: number | undefined, height: number | undefined, scene: Nullable<Scene>, generateMipMaps?: boolean, samplingMode?: number);
  118. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  119. markAsDirty(): void;
  120. /**
  121. * Helper function used to create a new style
  122. */
  123. createStyle(): Style;
  124. addControl(control: Control): AdvancedDynamicTexture;
  125. removeControl(control: Control): AdvancedDynamicTexture;
  126. dispose(): void;
  127. private _onResize();
  128. _getGlobalViewport(scene: Scene): Viewport;
  129. getProjectedPosition(position: Vector3, worldMatrix: Matrix): Vector2;
  130. private _checkUpdate(camera);
  131. private _render();
  132. private _doPicking(x, y, type, pointerId, buttonIndex);
  133. _cleanControlAfterRemovalFromList(list: {
  134. [pointerId: number]: Control;
  135. }, control: Control): void;
  136. _cleanControlAfterRemoval(control: Control): void;
  137. attach(): void;
  138. attachToMesh(mesh: AbstractMesh, supportPointerMove?: boolean): void;
  139. moveFocusToControl(control: IFocusableControl): void;
  140. private _manageFocus();
  141. private _attachToOnPointerOut(scene);
  142. static CreateForMesh(mesh: AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean): AdvancedDynamicTexture;
  143. /**
  144. * FullScreenUI is created in a layer. This allows it to be treated like any other layer.
  145. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  146. * When the GUI is not Created as FullscreenUI it does not respect the layerMask.
  147. * layerMask is set through advancedTexture.layer.layerMask
  148. * @param name name for the Texture
  149. * @param foreground render in foreground (default is true)
  150. * @param scene scene to be rendered in
  151. * @param sampling method for scaling to fit screen
  152. * @returns AdvancedDynamicTexture
  153. */
  154. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: Nullable<Scene>, sampling?: number): AdvancedDynamicTexture;
  155. }
  156. }
  157. declare module BABYLON.GUI {
  158. class Measure {
  159. left: number;
  160. top: number;
  161. width: number;
  162. height: number;
  163. constructor(left: number, top: number, width: number, height: number);
  164. copyFrom(other: Measure): void;
  165. isEqualsTo(other: Measure): boolean;
  166. static Empty(): Measure;
  167. }
  168. }
  169. declare module BABYLON.GUI {
  170. class Vector2WithInfo extends Vector2 {
  171. buttonIndex: number;
  172. constructor(source: Vector2, buttonIndex?: number);
  173. }
  174. class Matrix2D {
  175. m: Float32Array;
  176. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  177. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  178. determinant(): number;
  179. invertToRef(result: Matrix2D): Matrix2D;
  180. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  181. transformCoordinates(x: number, y: number, result: Vector2): Matrix2D;
  182. static Identity(): Matrix2D;
  183. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  184. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  185. static RotationToRef(angle: number, result: Matrix2D): void;
  186. private static _TempPreTranslationMatrix;
  187. private static _TempPostTranslationMatrix;
  188. private static _TempRotationMatrix;
  189. private static _TempScalingMatrix;
  190. private static _TempCompose0;
  191. private static _TempCompose1;
  192. private static _TempCompose2;
  193. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: Nullable<Matrix2D>, result: Matrix2D): void;
  194. }
  195. }
  196. declare module BABYLON.GUI {
  197. class MultiLinePoint {
  198. private _multiLine;
  199. private _x;
  200. private _y;
  201. private _control;
  202. private _mesh;
  203. private _controlObserver;
  204. private _meshObserver;
  205. _point: Vector2;
  206. constructor(multiLine: MultiLine);
  207. x: string | number;
  208. y: string | number;
  209. control: Nullable<Control>;
  210. mesh: Nullable<AbstractMesh>;
  211. translate(): Vector2;
  212. private _translatePoint();
  213. dispose(): void;
  214. }
  215. }
  216. declare module BABYLON.GUI {
  217. class Control {
  218. name: string | undefined;
  219. private _alpha;
  220. private _alphaSet;
  221. private _zIndex;
  222. _root: Nullable<Container>;
  223. _host: AdvancedDynamicTexture;
  224. parent: Nullable<Container>;
  225. _currentMeasure: Measure;
  226. private _fontFamily;
  227. private _fontStyle;
  228. private _fontWeight;
  229. private _fontSize;
  230. private _font;
  231. _width: ValueAndUnit;
  232. _height: ValueAndUnit;
  233. protected _fontOffset: {
  234. ascent: number;
  235. height: number;
  236. descent: number;
  237. };
  238. private _color;
  239. private _style;
  240. private _styleObserver;
  241. protected _horizontalAlignment: number;
  242. protected _verticalAlignment: number;
  243. private _isDirty;
  244. _tempParentMeasure: Measure;
  245. protected _cachedParentMeasure: Measure;
  246. private _paddingLeft;
  247. private _paddingRight;
  248. private _paddingTop;
  249. private _paddingBottom;
  250. _left: ValueAndUnit;
  251. _top: ValueAndUnit;
  252. private _scaleX;
  253. private _scaleY;
  254. private _rotation;
  255. private _transformCenterX;
  256. private _transformCenterY;
  257. private _transformMatrix;
  258. protected _invertTransformMatrix: Matrix2D;
  259. protected _transformedPosition: Vector2;
  260. private _onlyMeasureMode;
  261. private _isMatrixDirty;
  262. private _cachedOffsetX;
  263. private _cachedOffsetY;
  264. private _isVisible;
  265. _linkedMesh: Nullable<AbstractMesh>;
  266. private _fontSet;
  267. private _dummyVector2;
  268. private _downCount;
  269. private _enterCount;
  270. private _doNotRender;
  271. private _downPointerIds;
  272. isHitTestVisible: boolean;
  273. isPointerBlocker: boolean;
  274. isFocusInvisible: boolean;
  275. shadowOffsetX: number;
  276. shadowOffsetY: number;
  277. shadowBlur: number;
  278. shadowColor: string;
  279. protected _linkOffsetX: ValueAndUnit;
  280. protected _linkOffsetY: ValueAndUnit;
  281. readonly typeName: string;
  282. /**
  283. * An event triggered when the pointer move over the control.
  284. */
  285. onPointerMoveObservable: Observable<Vector2>;
  286. /**
  287. * An event triggered when the pointer move out of the control.
  288. */
  289. onPointerOutObservable: Observable<Control>;
  290. /**
  291. * An event triggered when the pointer taps the control
  292. */
  293. onPointerDownObservable: Observable<Vector2WithInfo>;
  294. /**
  295. * An event triggered when pointer up
  296. */
  297. onPointerUpObservable: Observable<Vector2WithInfo>;
  298. /**
  299. * An event triggered when a control is clicked on
  300. */
  301. onPointerClickObservable: Observable<Vector2WithInfo>;
  302. /**
  303. * An event triggered when pointer enters the control
  304. */
  305. onPointerEnterObservable: Observable<Control>;
  306. /**
  307. * An event triggered when the control is marked as dirty
  308. */
  309. onDirtyObservable: Observable<Control>;
  310. /**
  311. * An event triggered after the control is drawn
  312. */
  313. onAfterDrawObservable: Observable<Control>;
  314. /** Gets or set information about font offsets (used to render and align text) */
  315. fontOffset: {
  316. ascent: number;
  317. height: number;
  318. descent: number;
  319. };
  320. alpha: number;
  321. scaleX: number;
  322. scaleY: number;
  323. rotation: number;
  324. transformCenterY: number;
  325. transformCenterX: number;
  326. horizontalAlignment: number;
  327. verticalAlignment: number;
  328. width: string | number;
  329. readonly widthInPixels: number;
  330. height: string | number;
  331. readonly heightInPixels: number;
  332. fontFamily: string;
  333. /** Gets or sets font style */
  334. fontStyle: string;
  335. /** Gets or sets font weight */
  336. fontWeight: string;
  337. style: BABYLON.Nullable<Style>;
  338. /** @hidden */
  339. readonly _isFontSizeInPercentage: boolean;
  340. readonly fontSizeInPixels: number;
  341. fontSize: string | number;
  342. color: string;
  343. zIndex: number;
  344. notRenderable: boolean;
  345. isVisible: boolean;
  346. readonly isDirty: boolean;
  347. paddingLeft: string | number;
  348. readonly paddingLeftInPixels: number;
  349. paddingRight: string | number;
  350. readonly paddingRightInPixels: number;
  351. paddingTop: string | number;
  352. readonly paddingTopInPixels: number;
  353. paddingBottom: string | number;
  354. readonly paddingBottomInPixels: number;
  355. left: string | number;
  356. readonly leftInPixels: number;
  357. top: string | number;
  358. readonly topInPixels: number;
  359. linkOffsetX: string | number;
  360. readonly linkOffsetXInPixels: number;
  361. linkOffsetY: string | number;
  362. readonly linkOffsetYInPixels: number;
  363. readonly centerX: number;
  364. readonly centerY: number;
  365. constructor(name?: string | undefined);
  366. protected _getTypeName(): string;
  367. /** @hidden */
  368. _resetFontCache(): void;
  369. getLocalCoordinates(globalCoordinates: Vector2): Vector2;
  370. getLocalCoordinatesToRef(globalCoordinates: Vector2, result: Vector2): Control;
  371. getParentLocalCoordinates(globalCoordinates: Vector2): Vector2;
  372. moveToVector3(position: Vector3, scene: Scene): void;
  373. linkWithMesh(mesh: Nullable<AbstractMesh>): void;
  374. _moveToProjectedPosition(projectedPosition: Vector3): void;
  375. _markMatrixAsDirty(): void;
  376. _markAsDirty(): void;
  377. _markAllAsDirty(): void;
  378. _link(root: Nullable<Container>, host: AdvancedDynamicTexture): void;
  379. protected _transform(context: CanvasRenderingContext2D): void;
  380. protected _applyStates(context: CanvasRenderingContext2D): void;
  381. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  382. protected _clip(context: CanvasRenderingContext2D): void;
  383. _measure(): void;
  384. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  385. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  386. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  387. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  388. contains(x: number, y: number): boolean;
  389. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  390. _onPointerMove(target: Control, coordinates: Vector2): void;
  391. _onPointerEnter(target: Control): boolean;
  392. _onPointerOut(target: Control): void;
  393. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  394. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  395. forcePointerUp(pointerId?: Nullable<number>): void;
  396. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  397. private _prepareFont();
  398. dispose(): void;
  399. private static _HORIZONTAL_ALIGNMENT_LEFT;
  400. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  401. private static _HORIZONTAL_ALIGNMENT_CENTER;
  402. private static _VERTICAL_ALIGNMENT_TOP;
  403. private static _VERTICAL_ALIGNMENT_BOTTOM;
  404. private static _VERTICAL_ALIGNMENT_CENTER;
  405. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  406. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  407. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  408. static readonly VERTICAL_ALIGNMENT_TOP: number;
  409. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  410. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  411. private static _FontHeightSizes;
  412. static _GetFontOffset(font: string): {
  413. ascent: number;
  414. height: number;
  415. descent: number;
  416. };
  417. static AddHeader(control: Control, text: string, size: string | number, options: {
  418. isHorizontal: boolean;
  419. controlFirst: boolean;
  420. }): StackPanel;
  421. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  422. }
  423. }
  424. declare module BABYLON.GUI {
  425. class Container extends Control {
  426. name: string | undefined;
  427. protected _children: Control[];
  428. protected _measureForChildren: Measure;
  429. protected _background: string;
  430. protected _adaptWidthToChildren: boolean;
  431. protected _adaptHeightToChildren: boolean;
  432. adaptHeightToChildren: boolean;
  433. adaptWidthToChildren: boolean;
  434. background: string;
  435. readonly children: Control[];
  436. constructor(name?: string | undefined);
  437. protected _getTypeName(): string;
  438. getChildByName(name: string): Nullable<Control>;
  439. getChildByType(name: string, type: string): Nullable<Control>;
  440. containsControl(control: Control): boolean;
  441. addControl(control: Control): Container;
  442. removeControl(control: Control): Container;
  443. _reOrderControl(control: Control): void;
  444. _markMatrixAsDirty(): void;
  445. _markAllAsDirty(): void;
  446. protected _localDraw(context: CanvasRenderingContext2D): void;
  447. _link(root: Nullable<Container>, host: AdvancedDynamicTexture): void;
  448. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  449. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  450. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  451. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  452. dispose(): void;
  453. }
  454. }
  455. declare module BABYLON.GUI {
  456. class StackPanel extends Container {
  457. name: string | undefined;
  458. private _isVertical;
  459. private _manualWidth;
  460. private _manualHeight;
  461. private _doNotTrackManualChanges;
  462. private _tempMeasureStore;
  463. isVertical: boolean;
  464. width: string | number;
  465. height: string | number;
  466. constructor(name?: string | undefined);
  467. protected _getTypeName(): string;
  468. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  469. }
  470. }
  471. declare module BABYLON.GUI {
  472. class Rectangle extends Container {
  473. name: string | undefined;
  474. private _thickness;
  475. private _cornerRadius;
  476. thickness: number;
  477. cornerRadius: number;
  478. constructor(name?: string | undefined);
  479. protected _getTypeName(): string;
  480. protected _localDraw(context: CanvasRenderingContext2D): void;
  481. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  482. private _drawRoundedRect(context, offset?);
  483. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  484. }
  485. }
  486. declare module BABYLON.GUI {
  487. class Ellipse extends Container {
  488. name: string | undefined;
  489. private _thickness;
  490. thickness: number;
  491. constructor(name?: string | undefined);
  492. protected _getTypeName(): string;
  493. protected _localDraw(context: CanvasRenderingContext2D): void;
  494. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  495. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  496. }
  497. }
  498. declare module BABYLON.GUI {
  499. class Line extends Control {
  500. name: string | undefined;
  501. private _lineWidth;
  502. private _x1;
  503. private _y1;
  504. private _x2;
  505. private _y2;
  506. private _dash;
  507. private _connectedControl;
  508. private _connectedControlDirtyObserver;
  509. dash: Array<number>;
  510. connectedControl: Control;
  511. x1: string | number;
  512. y1: string | number;
  513. x2: string | number;
  514. y2: string | number;
  515. lineWidth: number;
  516. horizontalAlignment: number;
  517. verticalAlignment: number;
  518. private readonly _effectiveX2;
  519. private readonly _effectiveY2;
  520. constructor(name?: string | undefined);
  521. protected _getTypeName(): string;
  522. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  523. _measure(): void;
  524. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  525. /**
  526. * Move one end of the line given 3D cartesian coordinates.
  527. * @param position Targeted world position
  528. * @param scene Scene
  529. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  530. */
  531. moveToVector3(position: Vector3, scene: Scene, end?: boolean): void;
  532. /**
  533. * Move one end of the line to a position in screen absolute space.
  534. * @param projectedPosition Position in screen absolute space (X, Y)
  535. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  536. */
  537. _moveToProjectedPosition(projectedPosition: Vector3, end?: boolean): void;
  538. }
  539. }
  540. declare module BABYLON.GUI {
  541. class Slider extends Control {
  542. name: string | undefined;
  543. private _thumbWidth;
  544. private _minimum;
  545. private _maximum;
  546. private _value;
  547. private _background;
  548. private _borderColor;
  549. private _barOffset;
  550. private _isThumbCircle;
  551. private _isThumbClamped;
  552. onValueChangedObservable: Observable<number>;
  553. borderColor: string;
  554. background: string;
  555. barOffset: string | number;
  556. readonly barOffsetInPixels: number;
  557. thumbWidth: string | number;
  558. readonly thumbWidthInPixels: number;
  559. minimum: number;
  560. maximum: number;
  561. value: number;
  562. isThumbCircle: boolean;
  563. isThumbClamped: boolean;
  564. constructor(name?: string | undefined);
  565. protected _getTypeName(): string;
  566. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  567. private _pointerIsDown;
  568. private _updateValueFromPointer(x, y);
  569. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  570. _onPointerMove(target: Control, coordinates: Vector2): void;
  571. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  572. }
  573. }
  574. declare module BABYLON.GUI {
  575. class Checkbox extends Control {
  576. name: string | undefined;
  577. private _isChecked;
  578. private _background;
  579. private _checkSizeRatio;
  580. private _thickness;
  581. thickness: number;
  582. onIsCheckedChangedObservable: Observable<boolean>;
  583. checkSizeRatio: number;
  584. background: string;
  585. isChecked: boolean;
  586. constructor(name?: string | undefined);
  587. protected _getTypeName(): string;
  588. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  589. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  590. }
  591. }
  592. declare module BABYLON.GUI {
  593. class RadioButton extends Control {
  594. name: string | undefined;
  595. private _isChecked;
  596. private _background;
  597. private _checkSizeRatio;
  598. private _thickness;
  599. thickness: number;
  600. group: string;
  601. onIsCheckedChangedObservable: Observable<boolean>;
  602. checkSizeRatio: number;
  603. background: string;
  604. isChecked: boolean;
  605. constructor(name?: string | undefined);
  606. protected _getTypeName(): string;
  607. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  608. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  609. }
  610. }
  611. declare module BABYLON.GUI {
  612. class TextBlock extends Control {
  613. /**
  614. * Defines the name of the control
  615. */
  616. name: string | undefined;
  617. private _text;
  618. private _textWrapping;
  619. private _textHorizontalAlignment;
  620. private _textVerticalAlignment;
  621. private _lines;
  622. private _resizeToFit;
  623. private _lineSpacing;
  624. private _outlineWidth;
  625. private _outlineColor;
  626. /**
  627. * An event triggered after the text is changed
  628. */
  629. onTextChangedObservable: Observable<TextBlock>;
  630. /**
  631. * An event triggered after the text was broken up into lines
  632. */
  633. onLinesReadyObservable: Observable<TextBlock>;
  634. /**
  635. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  636. */
  637. readonly lines: any[];
  638. /**
  639. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  640. */
  641. /**
  642. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  643. */
  644. resizeToFit: boolean;
  645. /**
  646. * Gets or sets a boolean indicating if text must be wrapped
  647. */
  648. /**
  649. * Gets or sets a boolean indicating if text must be wrapped
  650. */
  651. textWrapping: boolean;
  652. /**
  653. * Gets or sets text to display
  654. */
  655. /**
  656. * Gets or sets text to display
  657. */
  658. text: string;
  659. /**
  660. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  661. */
  662. /**
  663. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  664. */
  665. textHorizontalAlignment: number;
  666. /**
  667. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  668. */
  669. /**
  670. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  671. */
  672. textVerticalAlignment: number;
  673. /**
  674. * Gets or sets line spacing value
  675. */
  676. /**
  677. * Gets or sets line spacing value
  678. */
  679. lineSpacing: string | number;
  680. /**
  681. * Gets or sets outlineWidth of the text to display
  682. */
  683. /**
  684. * Gets or sets outlineWidth of the text to display
  685. */
  686. outlineWidth: number;
  687. /**
  688. * Gets or sets outlineColor of the text to display
  689. */
  690. /**
  691. * Gets or sets outlineColor of the text to display
  692. */
  693. outlineColor: string;
  694. /**
  695. * Creates a new TextBlock object
  696. * @param name defines the name of the control
  697. * @param text defines the text to display (emptry string by default)
  698. */
  699. constructor(
  700. /**
  701. * Defines the name of the control
  702. */
  703. name?: string | undefined, text?: string);
  704. protected _getTypeName(): string;
  705. private _drawText(text, textWidth, y, context);
  706. /** @hidden */
  707. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  708. protected _applyStates(context: CanvasRenderingContext2D): void;
  709. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  710. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  711. protected _parseLineWithTextWrapping(line: string | undefined, context: CanvasRenderingContext2D): object;
  712. protected _renderLines(context: CanvasRenderingContext2D): void;
  713. dispose(): void;
  714. }
  715. }
  716. declare var DOMImage: new (width?: number | undefined, height?: number | undefined) => HTMLImageElement;
  717. declare module BABYLON.GUI {
  718. class Image extends Control {
  719. name: string | undefined;
  720. private _domImage;
  721. private _imageWidth;
  722. private _imageHeight;
  723. private _loaded;
  724. private _stretch;
  725. private _source;
  726. private _autoScale;
  727. private _sourceLeft;
  728. private _sourceTop;
  729. private _sourceWidth;
  730. private _sourceHeight;
  731. private _cellWidth;
  732. private _cellHeight;
  733. private _cellId;
  734. sourceLeft: number;
  735. sourceTop: number;
  736. sourceWidth: number;
  737. sourceHeight: number;
  738. autoScale: boolean;
  739. stretch: number;
  740. domImage: HTMLImageElement;
  741. private _onImageLoaded();
  742. source: Nullable<string>;
  743. cellWidth: number;
  744. cellHeight: number;
  745. cellId: number;
  746. constructor(name?: string | undefined, url?: Nullable<string>);
  747. protected _getTypeName(): string;
  748. synchronizeSizeWithContent(): void;
  749. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  750. private static _STRETCH_NONE;
  751. private static _STRETCH_FILL;
  752. private static _STRETCH_UNIFORM;
  753. private static _STRETCH_EXTEND;
  754. static readonly STRETCH_NONE: number;
  755. static readonly STRETCH_FILL: number;
  756. static readonly STRETCH_UNIFORM: number;
  757. static readonly STRETCH_EXTEND: number;
  758. }
  759. }
  760. declare module BABYLON.GUI {
  761. class Button extends Rectangle {
  762. name: string | undefined;
  763. pointerEnterAnimation: () => void;
  764. pointerOutAnimation: () => void;
  765. pointerDownAnimation: () => void;
  766. pointerUpAnimation: () => void;
  767. constructor(name?: string | undefined);
  768. protected _getTypeName(): string;
  769. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  770. _onPointerEnter(target: Control): boolean;
  771. _onPointerOut(target: Control): void;
  772. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  773. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  774. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  775. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  776. static CreateSimpleButton(name: string, text: string): Button;
  777. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  778. }
  779. }
  780. declare module BABYLON.GUI {
  781. class ColorPicker extends Control {
  782. name: string | undefined;
  783. private _colorWheelCanvas;
  784. private _value;
  785. private _tmpColor;
  786. private _pointerStartedOnSquare;
  787. private _pointerStartedOnWheel;
  788. private _squareLeft;
  789. private _squareTop;
  790. private _squareSize;
  791. private _h;
  792. private _s;
  793. private _v;
  794. onValueChangedObservable: Observable<Color3>;
  795. value: Color3;
  796. width: string | number;
  797. height: string | number;
  798. size: string | number;
  799. constructor(name?: string | undefined);
  800. protected _getTypeName(): string;
  801. private _updateSquareProps();
  802. private _drawGradientSquare(hueValue, left, top, width, height, context);
  803. private _drawCircle(centerX, centerY, radius, context);
  804. private _createColorWheelCanvas(radius, thickness);
  805. private _RGBtoHSV(color, result);
  806. private _HSVtoRGB(hue, saturation, value, result);
  807. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  808. private _pointerIsDown;
  809. private _updateValueFromPointer(x, y);
  810. private _isPointOnSquare(coordinates);
  811. private _isPointOnWheel(coordinates);
  812. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  813. _onPointerMove(target: Control, coordinates: Vector2): void;
  814. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  815. }
  816. }
  817. declare module BABYLON.GUI {
  818. class InputText extends Control implements IFocusableControl {
  819. name: string | undefined;
  820. private _text;
  821. private _placeholderText;
  822. private _background;
  823. private _focusedBackground;
  824. private _placeholderColor;
  825. private _thickness;
  826. private _margin;
  827. private _autoStretchWidth;
  828. private _maxWidth;
  829. private _isFocused;
  830. private _blinkTimeout;
  831. private _blinkIsEven;
  832. private _cursorOffset;
  833. private _scrollLeft;
  834. private _textWidth;
  835. private _clickedCoordinate;
  836. promptMessage: string;
  837. onTextChangedObservable: Observable<InputText>;
  838. onFocusObservable: Observable<InputText>;
  839. onBlurObservable: Observable<InputText>;
  840. maxWidth: string | number;
  841. readonly maxWidthInPixels: number;
  842. margin: string;
  843. readonly marginInPixels: number;
  844. autoStretchWidth: boolean;
  845. thickness: number;
  846. focusedBackground: string;
  847. background: string;
  848. placeholderColor: string;
  849. placeholderText: string;
  850. text: string;
  851. width: string | number;
  852. constructor(name?: string | undefined, text?: string);
  853. onBlur(): void;
  854. onFocus(): void;
  855. protected _getTypeName(): string;
  856. processKey(keyCode: number, key?: string): void;
  857. processKeyboard(evt: KeyboardEvent): void;
  858. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  859. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  860. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  861. dispose(): void;
  862. }
  863. }
  864. declare module BABYLON.GUI {
  865. class KeyPropertySet {
  866. width?: string;
  867. height?: string;
  868. paddingLeft?: string;
  869. paddingRight?: string;
  870. paddingTop?: string;
  871. paddingBottom?: string;
  872. color?: string;
  873. background?: string;
  874. }
  875. class VirtualKeyboard extends StackPanel {
  876. onKeyPressObservable: Observable<string>;
  877. defaultButtonWidth: string;
  878. defaultButtonHeight: string;
  879. defaultButtonPaddingLeft: string;
  880. defaultButtonPaddingRight: string;
  881. defaultButtonPaddingTop: string;
  882. defaultButtonPaddingBottom: string;
  883. defaultButtonColor: string;
  884. defaultButtonBackground: string;
  885. shiftButtonColor: string;
  886. selectedShiftThickness: number;
  887. shiftState: number;
  888. protected _getTypeName(): string;
  889. private _createKey(key, propertySet);
  890. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  891. applyShiftState(shiftState: number): void;
  892. private _connectedInputText;
  893. private _onFocusObserver;
  894. private _onBlurObserver;
  895. private _onKeyPressObserver;
  896. readonly connectedInputText: Nullable<InputText>;
  897. connect(input: InputText): void;
  898. disconnect(): void;
  899. static CreateDefaultLayout(): VirtualKeyboard;
  900. }
  901. }
  902. declare module BABYLON.GUI {
  903. class MultiLine extends Control {
  904. name: string | undefined;
  905. private _lineWidth;
  906. private _dash;
  907. private _points;
  908. private _minX;
  909. private _minY;
  910. private _maxX;
  911. private _maxY;
  912. constructor(name?: string | undefined);
  913. dash: Array<number>;
  914. getAt(index: number): MultiLinePoint;
  915. onPointUpdate: () => void;
  916. add(...items: (AbstractMesh | Control | {
  917. x: string | number;
  918. y: string | number;
  919. })[]): MultiLinePoint[];
  920. push(item?: (AbstractMesh | Control | {
  921. x: string | number;
  922. y: string | number;
  923. })): MultiLinePoint;
  924. remove(value: number | MultiLinePoint): void;
  925. lineWidth: number;
  926. horizontalAlignment: number;
  927. verticalAlignment: number;
  928. protected _getTypeName(): string;
  929. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  930. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  931. _measure(): void;
  932. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  933. dispose(): void;
  934. }
  935. }
  936. declare module BABYLON.GUI {
  937. /**
  938. * Class used to manage 3D user interface
  939. */
  940. class GUI3DManager implements BABYLON.IDisposable {
  941. private _scene;
  942. private _sceneDisposeObserver;
  943. private _utilityLayer;
  944. private _rootContainer;
  945. private _pointerObserver;
  946. _lastPickedControl: Control3D;
  947. /** @hidden */
  948. _lastControlOver: {
  949. [pointerId: number]: Control3D;
  950. };
  951. /** @hidden */
  952. _lastControlDown: {
  953. [pointerId: number]: Control3D;
  954. };
  955. /**
  956. * Observable raised when the point picked by the pointer events changed
  957. */
  958. onPickedPointChangedObservable: Observable<Nullable<Vector3>>;
  959. sharedMaterials: {
  960. [key: string]: Material;
  961. };
  962. /** Gets the hosting scene */
  963. readonly scene: Scene;
  964. readonly utilityLayer: Nullable<UtilityLayerRenderer>;
  965. /**
  966. * Creates a new GUI3DManager
  967. * @param scene
  968. */
  969. constructor(scene?: Scene);
  970. private _doPicking(type, pointerEvent, ray?);
  971. /**
  972. * Gets the root container
  973. */
  974. readonly rootContainer: Container3D;
  975. /**
  976. * Gets a boolean indicating if the given control is in the root child list
  977. * @param control defines the control to check
  978. * @returns true if the control is in the root child list
  979. */
  980. containsControl(control: Control3D): boolean;
  981. /**
  982. * Adds a control to the root child list
  983. * @param control defines the control to add
  984. * @returns the current manager
  985. */
  986. addControl(control: Control3D): GUI3DManager;
  987. /**
  988. * Removes the control from the root child list
  989. * @param control defines the control to remove
  990. * @returns the current container
  991. */
  992. removeControl(control: Control3D): GUI3DManager;
  993. /**
  994. * Releases all associated resources
  995. */
  996. dispose(): void;
  997. }
  998. }
  999. declare module BABYLON.GUI {
  1000. /** @hidden */
  1001. class FluentMaterialDefines extends MaterialDefines {
  1002. INNERGLOW: boolean;
  1003. BORDER: boolean;
  1004. HOVERLIGHT: boolean;
  1005. constructor();
  1006. }
  1007. /**
  1008. * Class used to render controls with fluent desgin
  1009. */
  1010. class FluentMaterial extends PushMaterial {
  1011. /**
  1012. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  1013. */
  1014. innerGlowColorIntensity: number;
  1015. /**
  1016. * Gets or sets the inner glow color (white by default)
  1017. */
  1018. innerGlowColor: Color3;
  1019. /**
  1020. * Gets or sets alpha value (default is 1.0)
  1021. */
  1022. alpha: number;
  1023. /**
  1024. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  1025. */
  1026. albedoColor: Color3;
  1027. /**
  1028. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  1029. */
  1030. renderBorders: boolean;
  1031. /**
  1032. * Gets or sets border width (default is 0.5)
  1033. */
  1034. borderWidth: number;
  1035. /**
  1036. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  1037. */
  1038. edgeSmoothingValue: number;
  1039. /**
  1040. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  1041. */
  1042. borderMinValue: number;
  1043. /**
  1044. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  1045. */
  1046. renderHoverLight: boolean;
  1047. /**
  1048. * Gets or sets the radius used to render the hover light (default is 0.15)
  1049. */
  1050. hoverRadius: number;
  1051. /**
  1052. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  1053. */
  1054. hoverColor: Color4;
  1055. /**
  1056. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  1057. */
  1058. hoverPosition: Vector3;
  1059. /**
  1060. * Creates a new Fluent material
  1061. * @param name defines the name of the material
  1062. * @param scene defines the hosting scene
  1063. */
  1064. constructor(name: string, scene: Scene);
  1065. needAlphaBlending(): boolean;
  1066. needAlphaTesting(): boolean;
  1067. getAlphaTestTexture(): Nullable<BaseTexture>;
  1068. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  1069. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  1070. getActiveTextures(): BaseTexture[];
  1071. hasTexture(texture: BaseTexture): boolean;
  1072. dispose(forceDisposeEffect?: boolean): void;
  1073. clone(name: string): FluentMaterial;
  1074. serialize(): any;
  1075. getClassName(): string;
  1076. static Parse(source: any, scene: Scene, rootUrl: string): FluentMaterial;
  1077. }
  1078. }
  1079. declare module BABYLON.GUI {
  1080. class Vector3WithInfo extends Vector3 {
  1081. buttonIndex: number;
  1082. constructor(source: Vector3, buttonIndex?: number);
  1083. }
  1084. }
  1085. declare module BABYLON.GUI {
  1086. /**
  1087. * Class used as base class for controls
  1088. */
  1089. class Control3D implements IDisposable, IBehaviorAware<Control3D> {
  1090. /** Defines the control name */
  1091. name: string | undefined;
  1092. /** @hidden */
  1093. _host: GUI3DManager;
  1094. private _node;
  1095. private _downCount;
  1096. private _enterCount;
  1097. private _downPointerIds;
  1098. private _isVisible;
  1099. /** Gets or sets the control position */
  1100. position: Vector3;
  1101. /** Gets or sets the control scaling */
  1102. scaling: Vector3;
  1103. /** Callback used to start pointer enter animation */
  1104. pointerEnterAnimation: () => void;
  1105. /** Callback used to start pointer out animation */
  1106. pointerOutAnimation: () => void;
  1107. /** Callback used to start pointer down animation */
  1108. pointerDownAnimation: () => void;
  1109. /** Callback used to start pointer up animation */
  1110. pointerUpAnimation: () => void;
  1111. /**
  1112. * An event triggered when the pointer move over the control.
  1113. */
  1114. onPointerMoveObservable: Observable<Vector3>;
  1115. /**
  1116. * An event triggered when the pointer move out of the control.
  1117. */
  1118. onPointerOutObservable: Observable<Control3D>;
  1119. /**
  1120. * An event triggered when the pointer taps the control
  1121. */
  1122. onPointerDownObservable: Observable<Vector3WithInfo>;
  1123. /**
  1124. * An event triggered when pointer up
  1125. */
  1126. onPointerUpObservable: Observable<Vector3WithInfo>;
  1127. /**
  1128. * An event triggered when a control is clicked on
  1129. */
  1130. onPointerClickObservable: Observable<Vector3WithInfo>;
  1131. /**
  1132. * An event triggered when pointer enters the control
  1133. */
  1134. onPointerEnterObservable: Observable<Control3D>;
  1135. /**
  1136. * Gets or sets the parent container
  1137. */
  1138. parent: Nullable<Container3D>;
  1139. private _behaviors;
  1140. /**
  1141. * Gets the list of attached behaviors
  1142. * @see http://doc.babylonjs.com/features/behaviour
  1143. */
  1144. readonly behaviors: Behavior<Control3D>[];
  1145. /**
  1146. * Attach a behavior to the control
  1147. * @see http://doc.babylonjs.com/features/behaviour
  1148. * @param behavior defines the behavior to attach
  1149. * @returns the current control
  1150. */
  1151. addBehavior(behavior: Behavior<Control3D>): Control3D;
  1152. /**
  1153. * Remove an attached behavior
  1154. * @see http://doc.babylonjs.com/features/behaviour
  1155. * @param behavior defines the behavior to attach
  1156. * @returns the current control
  1157. */
  1158. removeBehavior(behavior: Behavior<Control3D>): Control3D;
  1159. /**
  1160. * Gets an attached behavior by name
  1161. * @param name defines the name of the behavior to look for
  1162. * @see http://doc.babylonjs.com/features/behaviour
  1163. * @returns null if behavior was not found else the requested behavior
  1164. */
  1165. getBehaviorByName(name: string): Nullable<Behavior<Control3D>>;
  1166. /** Gets or sets a boolean indicating if the control is visible */
  1167. isVisible: boolean;
  1168. /**
  1169. * Creates a new control
  1170. * @param name defines the control name
  1171. */
  1172. constructor(
  1173. /** Defines the control name */
  1174. name?: string | undefined);
  1175. /**
  1176. * Gets a string representing the class name
  1177. */
  1178. readonly typeName: string;
  1179. protected _getTypeName(): string;
  1180. /**
  1181. * Gets the mesh used to render this control
  1182. */
  1183. readonly node: Nullable<TransformNode>;
  1184. /**
  1185. * Gets the mesh used to render this control
  1186. */
  1187. readonly mesh: Nullable<AbstractMesh>;
  1188. /**
  1189. * Link the control as child of the given node
  1190. * @param node defines the node to link to. Use null to unlink the control
  1191. * @returns the current control
  1192. */
  1193. linkToTransformNode(node: Nullable<TransformNode>): Control3D;
  1194. /** @hidden **/
  1195. _prepareNode(scene: Scene): void;
  1196. /**
  1197. * Node creation.
  1198. * Can be overriden by children
  1199. * @param scene defines the scene where the node must be attached
  1200. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  1201. */
  1202. protected _createNode(scene: Scene): Nullable<TransformNode>;
  1203. /**
  1204. * Affect a material to the given mesh
  1205. * @param mesh defines the mesh which will represent the control
  1206. */
  1207. protected _affectMaterial(mesh: AbstractMesh): void;
  1208. /** @hidden */
  1209. _onPointerMove(target: Control3D, coordinates: Vector3): void;
  1210. /** @hidden */
  1211. _onPointerEnter(target: Control3D): boolean;
  1212. /** @hidden */
  1213. _onPointerOut(target: Control3D): void;
  1214. /** @hidden */
  1215. _onPointerDown(target: Control3D, coordinates: Vector3, pointerId: number, buttonIndex: number): boolean;
  1216. /** @hidden */
  1217. _onPointerUp(target: Control3D, coordinates: Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  1218. /** @hidden */
  1219. forcePointerUp(pointerId?: Nullable<number>): void;
  1220. /** @hidden */
  1221. _processObservables(type: number, pickedPoint: Vector3, pointerId: number, buttonIndex: number): boolean;
  1222. /**
  1223. * Releases all associated resources
  1224. */
  1225. dispose(): void;
  1226. }
  1227. }
  1228. declare module BABYLON.GUI {
  1229. /**
  1230. * Class used to create containers for controls
  1231. */
  1232. class Container3D extends Control3D {
  1233. /**
  1234. * Gets the list of child controls
  1235. */
  1236. protected _children: Control3D[];
  1237. /**
  1238. * Creates a new container
  1239. * @param name defines the container name
  1240. */
  1241. constructor(name?: string);
  1242. /**
  1243. * Gets a boolean indicating if the given control is in the children of this control
  1244. * @param control defines the control to check
  1245. * @returns true if the control is in the child list
  1246. */
  1247. containsControl(control: Control3D): boolean;
  1248. /**
  1249. * Adds a control to the children of this control
  1250. * @param control defines the control to add
  1251. * @returns the current container
  1252. */
  1253. addControl(control: Control3D): Container3D;
  1254. /**
  1255. * This function will be called everytime a new control is added
  1256. */
  1257. protected _arrangeChildren(): void;
  1258. protected _createNode(scene: Scene): Nullable<TransformNode>;
  1259. /**
  1260. * Removes the control from the children of this control
  1261. * @param control defines the control to remove
  1262. * @returns the current container
  1263. */
  1264. removeControl(control: Control3D): Container3D;
  1265. protected _getTypeName(): string;
  1266. /**
  1267. * Releases all associated resources
  1268. */
  1269. dispose(): void;
  1270. }
  1271. }
  1272. declare module BABYLON.GUI {
  1273. /**
  1274. * Class used to create a button in 3D
  1275. */
  1276. class Button3D extends Control3D {
  1277. /** @hidden */
  1278. protected _currentMaterial: Material;
  1279. private _facadeTexture;
  1280. private _content;
  1281. /**
  1282. * Creates a new button
  1283. * @param name defines the control name
  1284. */
  1285. constructor(name?: string);
  1286. /**
  1287. * Gets or sets the GUI 2D content used to display the button's facade
  1288. */
  1289. content: Control;
  1290. /**
  1291. * Apply the facade texture (created from the content property).
  1292. * This function can be overloaded by child classes
  1293. * @param facadeTexture defines the AdvancedDynamicTexture to use
  1294. */
  1295. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  1296. protected _getTypeName(): string;
  1297. protected _createNode(scene: Scene): TransformNode;
  1298. protected _affectMaterial(mesh: AbstractMesh): void;
  1299. /**
  1300. * Releases all associated resources
  1301. */
  1302. dispose(): void;
  1303. }
  1304. }
  1305. declare module BABYLON.GUI {
  1306. /**
  1307. * Class used to create a holographic button in 3D
  1308. */
  1309. class HolographicButton extends Button3D {
  1310. private _backPlate;
  1311. private _textPlate;
  1312. private _frontPlate;
  1313. private _text;
  1314. private _imageUrl;
  1315. private _shareMaterials;
  1316. private _frontMaterial;
  1317. private _backMaterial;
  1318. private _plateMaterial;
  1319. private _pickedPointObserver;
  1320. /**
  1321. * Gets or sets text for the button
  1322. */
  1323. text: string;
  1324. /**
  1325. * Gets or sets the image url for the button
  1326. */
  1327. imageUrl: string;
  1328. /**
  1329. * Gets the back material used by this button
  1330. */
  1331. readonly backMaterial: FluentMaterial;
  1332. /**
  1333. * Gets the front material used by this button
  1334. */
  1335. readonly frontMaterial: FluentMaterial;
  1336. /**
  1337. * Gets the plate material used by this button
  1338. */
  1339. readonly plateMaterial: StandardMaterial;
  1340. /**
  1341. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  1342. */
  1343. readonly shareMaterials: boolean;
  1344. /**
  1345. * Creates a new button
  1346. * @param name defines the control name
  1347. */
  1348. constructor(name?: string, shareMaterials?: boolean);
  1349. protected _getTypeName(): string;
  1350. private _rebuildContent();
  1351. protected _createNode(scene: Scene): TransformNode;
  1352. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  1353. private _createBackMaterial(mesh);
  1354. private _createFrontMaterial(mesh);
  1355. private _createPlateMaterial(mesh);
  1356. protected _affectMaterial(mesh: Mesh): void;
  1357. /**
  1358. * Releases all associated resources
  1359. */
  1360. dispose(): void;
  1361. }
  1362. }
  1363. declare module BABYLON.GUI {
  1364. /**
  1365. * Class used to create a stack panel in 3D on XY plane
  1366. */
  1367. class StackPanel3D extends Container3D {
  1368. private _isVertical;
  1369. /**
  1370. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  1371. */
  1372. isVertical: boolean;
  1373. /**
  1374. * Gets or sets the distance between elements
  1375. */
  1376. margin: number;
  1377. /**
  1378. * Creates new StackPanel
  1379. * @param isVertical
  1380. */
  1381. constructor();
  1382. protected _arrangeChildren(): void;
  1383. }
  1384. }