@babylonjs/gui 5.45.2 → 5.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/2D/adtInstrumentation.js +21 -21
  2. package/2D/adtInstrumentation.js.map +1 -1
  3. package/2D/advancedDynamicTexture.d.ts +1 -1
  4. package/2D/advancedDynamicTexture.js +159 -159
  5. package/2D/advancedDynamicTexture.js.map +1 -1
  6. package/2D/controls/button.js +12 -12
  7. package/2D/controls/button.js.map +1 -1
  8. package/2D/controls/checkbox.js +17 -17
  9. package/2D/controls/checkbox.js.map +1 -1
  10. package/2D/controls/colorpicker.js +28 -28
  11. package/2D/controls/colorpicker.js.map +1 -1
  12. package/2D/controls/container.js +40 -40
  13. package/2D/controls/container.js.map +1 -1
  14. package/2D/controls/control.js +191 -191
  15. package/2D/controls/control.js.map +1 -1
  16. package/2D/controls/displayGrid.js +18 -18
  17. package/2D/controls/displayGrid.js.map +1 -1
  18. package/2D/controls/ellipse.js +9 -9
  19. package/2D/controls/ellipse.js.map +1 -1
  20. package/2D/controls/gradient/BaseGradient.d.ts +1 -1
  21. package/2D/controls/grid.js +14 -14
  22. package/2D/controls/grid.js.map +1 -1
  23. package/2D/controls/image.js +33 -33
  24. package/2D/controls/image.js.map +1 -1
  25. package/2D/controls/inputText.js +57 -57
  26. package/2D/controls/inputText.js.map +1 -1
  27. package/2D/controls/inputTextArea.js +34 -34
  28. package/2D/controls/inputTextArea.js.map +1 -1
  29. package/2D/controls/line.js +22 -22
  30. package/2D/controls/line.js.map +1 -1
  31. package/2D/controls/radioButton.js +17 -17
  32. package/2D/controls/radioButton.js.map +1 -1
  33. package/2D/controls/rectangle.js +10 -10
  34. package/2D/controls/rectangle.js.map +1 -1
  35. package/2D/controls/scrollViewers/scrollViewer.js +70 -70
  36. package/2D/controls/scrollViewers/scrollViewer.js.map +1 -1
  37. package/2D/controls/scrollViewers/scrollViewerWindow.js +11 -11
  38. package/2D/controls/scrollViewers/scrollViewerWindow.js.map +1 -1
  39. package/2D/controls/sliders/baseSlider.js +25 -25
  40. package/2D/controls/sliders/baseSlider.js.map +1 -1
  41. package/2D/controls/sliders/imageBasedSlider.js +9 -9
  42. package/2D/controls/sliders/imageBasedSlider.js.map +1 -1
  43. package/2D/controls/sliders/imageScrollBar.js +15 -15
  44. package/2D/controls/sliders/imageScrollBar.js.map +1 -1
  45. package/2D/controls/sliders/scrollBar.js +13 -13
  46. package/2D/controls/sliders/scrollBar.js.map +1 -1
  47. package/2D/controls/sliders/slider.js +14 -14
  48. package/2D/controls/sliders/slider.js.map +1 -1
  49. package/2D/controls/stackPanel.js +17 -17
  50. package/2D/controls/stackPanel.js.map +1 -1
  51. package/2D/controls/textBlock.js +35 -35
  52. package/2D/controls/textBlock.js.map +1 -1
  53. package/2D/controls/toggleButton.js +49 -49
  54. package/2D/controls/toggleButton.js.map +1 -1
  55. package/3D/controls/MRTK3/touchHolographicButton.js +127 -127
  56. package/3D/controls/MRTK3/touchHolographicButton.js.map +1 -1
  57. package/3D/controls/container3D.js +12 -12
  58. package/3D/controls/container3D.js.map +1 -1
  59. package/3D/controls/control3D.js +41 -41
  60. package/3D/controls/control3D.js.map +1 -1
  61. package/3D/controls/handMenu.js +11 -11
  62. package/3D/controls/handMenu.js.map +1 -1
  63. package/3D/controls/holographicBackplate.js +9 -9
  64. package/3D/controls/holographicBackplate.js.map +1 -1
  65. package/3D/controls/holographicButton.js +23 -23
  66. package/3D/controls/holographicButton.js.map +1 -1
  67. package/3D/controls/holographicSlate.js +34 -34
  68. package/3D/controls/holographicSlate.js.map +1 -1
  69. package/3D/controls/nearMenu.js +13 -13
  70. package/3D/controls/nearMenu.js.map +1 -1
  71. package/3D/controls/stackPanel3D.js +13 -13
  72. package/3D/controls/stackPanel3D.js.map +1 -1
  73. package/3D/controls/touchHolographicButton.js +52 -52
  74. package/3D/controls/touchHolographicButton.js.map +1 -1
  75. package/3D/controls/touchHolographicMenu.js +8 -8
  76. package/3D/controls/touchHolographicMenu.js.map +1 -1
  77. package/3D/controls/volumeBasedPanel.js +15 -15
  78. package/3D/controls/volumeBasedPanel.js.map +1 -1
  79. package/3D/gizmos/gizmoHandle.js +15 -15
  80. package/3D/gizmos/gizmoHandle.js.map +1 -1
  81. package/3D/gizmos/slateGizmo.js +29 -29
  82. package/3D/gizmos/slateGizmo.js.map +1 -1
  83. package/3D/gui3DManager.js +33 -33
  84. package/3D/gui3DManager.js.map +1 -1
  85. package/3D/materials/handle/handleMaterial.js +20 -20
  86. package/3D/materials/handle/handleMaterial.js.map +1 -1
  87. package/package.json +2 -2
@@ -6,6 +6,55 @@ import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
6
6
  * @since 5.0.0
7
7
  */
8
8
  export class ToggleButton extends Rectangle {
9
+ /** Gets or sets group name this toggle button belongs to */
10
+ get group() {
11
+ return this._group;
12
+ }
13
+ set group(value) {
14
+ if (this._group === value) {
15
+ return;
16
+ }
17
+ this._group = value;
18
+ }
19
+ /** Gets or sets a boolean indicating if the toggle button is active or not */
20
+ get isActive() {
21
+ return this._isActive;
22
+ }
23
+ set isActive(value) {
24
+ var _a, _b;
25
+ // Function modeled after radioButton.ts
26
+ if (this._isActive === value) {
27
+ return;
28
+ }
29
+ this._isActive = value;
30
+ // Update the visual state based on the new value
31
+ if (this._isActive) {
32
+ (_a = this.toActiveAnimation) === null || _a === void 0 ? void 0 : _a.call(this);
33
+ }
34
+ else {
35
+ (_b = this.toInactiveAnimation) === null || _b === void 0 ? void 0 : _b.call(this);
36
+ }
37
+ this._markAsDirty();
38
+ this.onIsActiveChangedObservable.notifyObservers(value);
39
+ if (this._isActive && this._host && this._group) {
40
+ // A toggle button in a group can only have 1 active element at a given time.
41
+ // If this toggle button has a group, set other toggle buttons in the group to inactive.
42
+ this._host.executeOnAllControls((control) => {
43
+ // Check for control type ToggleButton
44
+ if (control.typeName === "ToggleButton") {
45
+ // Don't do anything to this toggle button
46
+ if (control === this) {
47
+ return;
48
+ }
49
+ const childToggle = control;
50
+ // If toggle button is in same group, set isActive to false
51
+ if (childToggle.group === this.group) {
52
+ childToggle.isActive = false;
53
+ }
54
+ }
55
+ });
56
+ }
57
+ }
9
58
  /**
10
59
  * Creates a new ToggleButton
11
60
  * @param name defines the control name
@@ -66,55 +115,6 @@ export class ToggleButton extends Rectangle {
66
115
  this.scaleY += 0.05;
67
116
  };
68
117
  }
69
- /** Gets or sets group name this toggle button belongs to */
70
- get group() {
71
- return this._group;
72
- }
73
- set group(value) {
74
- if (this._group === value) {
75
- return;
76
- }
77
- this._group = value;
78
- }
79
- /** Gets or sets a boolean indicating if the toggle button is active or not */
80
- get isActive() {
81
- return this._isActive;
82
- }
83
- set isActive(value) {
84
- var _a, _b;
85
- // Function modeled after radioButton.ts
86
- if (this._isActive === value) {
87
- return;
88
- }
89
- this._isActive = value;
90
- // Update the visual state based on the new value
91
- if (this._isActive) {
92
- (_a = this.toActiveAnimation) === null || _a === void 0 ? void 0 : _a.call(this);
93
- }
94
- else {
95
- (_b = this.toInactiveAnimation) === null || _b === void 0 ? void 0 : _b.call(this);
96
- }
97
- this._markAsDirty();
98
- this.onIsActiveChangedObservable.notifyObservers(value);
99
- if (this._isActive && this._host && this._group) {
100
- // A toggle button in a group can only have 1 active element at a given time.
101
- // If this toggle button has a group, set other toggle buttons in the group to inactive.
102
- this._host.executeOnAllControls((control) => {
103
- // Check for control type ToggleButton
104
- if (control.typeName === "ToggleButton") {
105
- // Don't do anything to this toggle button
106
- if (control === this) {
107
- return;
108
- }
109
- const childToggle = control;
110
- // If toggle button is in same group, set isActive to false
111
- if (childToggle.group === this.group) {
112
- childToggle.isActive = false;
113
- }
114
- }
115
- });
116
- }
117
- }
118
118
  _getTypeName() {
119
119
  return "ToggleButton";
120
120
  }
@@ -1 +1 @@
1
- {"version":3,"file":"toggleButton.js","sourceRoot":"","sources":["../../../../../lts/gui/generated/2D/controls/toggleButton.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE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;iBACnC;aACJ;iBAAM;gBACH,IAAI,IAAI,CAAC,0BAA0B,EAAE;oBACjC,IAAI,CAAC,0BAA0B,EAAE,CAAC;iBACrC;aACJ;SACJ;QAED,KAAK,CAAC,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC;IACrF,CAAC;CACJ;AAED,aAAa,CAAC,0BAA0B,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport type { Vector2 } from \"core/Maths/math.vector\";\r\n\r\nimport { Rectangle } from \"./rectangle\";\r\nimport type { Control } from \"./control\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport type { PointerInfoBase } from \"core/Events/pointerEvents\";\r\n\r\n/**\r\n * Class used to create toggle buttons\r\n * @since 5.0.0\r\n */\r\nexport class ToggleButton extends Rectangle {\r\n /**\r\n * Function called to generate the toActive animation\r\n */\r\n public toActiveAnimation: () => void;\r\n\r\n /**\r\n * Function called to generate the toInactive animation\r\n */\r\n public toInactiveAnimation: () => void;\r\n\r\n /**\r\n * Function called to generate a pointer enter animation when the toggle button is active.\r\n */\r\n public pointerEnterActiveAnimation: () => void;\r\n /**\r\n * Function called to generate a pointer out animation when the toggle button is active.\r\n */\r\n public pointerOutActiveAnimation: () => void;\r\n /**\r\n * Function called to generate a pointer down animation when the toggle button is active.\r\n */\r\n public pointerDownActiveAnimation: () => void;\r\n /**\r\n * Function called to generate a pointer up animation when the toggle button is active.\r\n */\r\n public pointerUpActiveAnimation: () => void;\r\n\r\n /**\r\n * Function called to generate a pointer enter animation when the toggle button is inactive.\r\n */\r\n public pointerEnterInactiveAnimation: () => void;\r\n /**\r\n * Function called to generate a pointer out animation when the toggle button is inactive.\r\n */\r\n public pointerOutInactiveAnimation: () => void;\r\n /**\r\n * Function called to generate a pointer down animation when the toggle button is inactive.\r\n */\r\n public pointerDownInactiveAnimation: () => void;\r\n /**\r\n * Function called to generate a pointer up animation when the toggle button is inactive.\r\n */\r\n public pointerUpInactiveAnimation: () => void;\r\n\r\n /** Observable raised when isActive is changed */\r\n public onIsActiveChangedObservable = new Observable<boolean>();\r\n\r\n /**\r\n * Gets or sets a boolean indicating that the toggle button will let internal controls handle picking instead of doing it directly using its bounding info\r\n */\r\n public delegatePickingToChildren = false;\r\n\r\n private _group: string;\r\n /** Gets or sets group name this toggle button belongs to */\r\n public get group(): string {\r\n return this._group;\r\n }\r\n public set group(value: string) {\r\n if (this._group === value) {\r\n return;\r\n }\r\n\r\n this._group = value;\r\n }\r\n\r\n private _isActive = false;\r\n /** Gets or sets a boolean indicating if the toggle button is active or not */\r\n public get isActive(): boolean {\r\n return this._isActive;\r\n }\r\n public set isActive(value: boolean) {\r\n // Function modeled after radioButton.ts\r\n if (this._isActive === value) {\r\n return;\r\n }\r\n\r\n this._isActive = value;\r\n\r\n // Update the visual state based on the new value\r\n if (this._isActive) {\r\n this.toActiveAnimation?.();\r\n } else {\r\n this.toInactiveAnimation?.();\r\n }\r\n\r\n this._markAsDirty();\r\n\r\n this.onIsActiveChangedObservable.notifyObservers(value);\r\n\r\n if (this._isActive && this._host && this._group) {\r\n // A toggle button in a group can only have 1 active element at a given time.\r\n // If this toggle button has a group, set other toggle buttons in the group to inactive.\r\n this._host.executeOnAllControls((control) => {\r\n // Check for control type ToggleButton\r\n if (control.typeName === \"ToggleButton\") {\r\n // Don't do anything to this toggle button\r\n if (control === this) {\r\n return;\r\n }\r\n\r\n const childToggle = <ToggleButton>control;\r\n // If toggle button is in same group, set isActive to false\r\n if (childToggle.group === this.group) {\r\n childToggle.isActive = false;\r\n }\r\n }\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new ToggleButton\r\n * @param name defines the control name\r\n * @param group defines the toggle group this toggle belongs to\r\n */\r\n constructor(public name?: string, group?: string) {\r\n super(name);\r\n this.group = group ?? \"\";\r\n\r\n this.thickness = 0;\r\n this.isPointerBlocker = true;\r\n\r\n let alphaStore: Nullable<number> = null;\r\n\r\n this.toActiveAnimation = () => {\r\n this.thickness = 1;\r\n };\r\n this.toInactiveAnimation = () => {\r\n this.thickness = 0;\r\n };\r\n\r\n this.pointerEnterActiveAnimation = () => {\r\n alphaStore = this.alpha;\r\n this.alpha -= 0.1;\r\n };\r\n\r\n this.pointerOutActiveAnimation = () => {\r\n if (alphaStore !== null) {\r\n this.alpha = alphaStore;\r\n }\r\n };\r\n\r\n this.pointerDownActiveAnimation = () => {\r\n this.scaleX -= 0.05;\r\n this.scaleY -= 0.05;\r\n };\r\n\r\n this.pointerUpActiveAnimation = () => {\r\n this.scaleX += 0.05;\r\n this.scaleY += 0.05;\r\n };\r\n\r\n this.pointerEnterInactiveAnimation = () => {\r\n alphaStore = this.alpha;\r\n this.alpha -= 0.1;\r\n };\r\n\r\n this.pointerOutInactiveAnimation = () => {\r\n if (alphaStore !== null) {\r\n this.alpha = alphaStore;\r\n }\r\n };\r\n\r\n this.pointerDownInactiveAnimation = () => {\r\n this.scaleX -= 0.05;\r\n this.scaleY -= 0.05;\r\n };\r\n\r\n this.pointerUpInactiveAnimation = () => {\r\n this.scaleX += 0.05;\r\n this.scaleY += 0.05;\r\n };\r\n }\r\n\r\n protected _getTypeName(): string {\r\n return \"ToggleButton\";\r\n }\r\n\r\n // While being a container, the toggle button behaves like a control.\r\n /**\r\n * @internal\r\n */\r\n public _processPicking(x: number, y: number, pi: PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean {\r\n if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {\r\n return false;\r\n }\r\n\r\n if (!super.contains(x, y)) {\r\n return false;\r\n }\r\n\r\n if (this.delegatePickingToChildren) {\r\n let contains = false;\r\n for (let index = this._children.length - 1; index >= 0; index--) {\r\n const child = this._children[index];\r\n if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {\r\n contains = true;\r\n break;\r\n }\r\n }\r\n\r\n if (!contains) {\r\n return false;\r\n }\r\n }\r\n\r\n this._processObservables(type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY);\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _onPointerEnter(target: Control, pi: PointerInfoBase): boolean {\r\n if (!super._onPointerEnter(target, pi)) {\r\n return false;\r\n }\r\n\r\n if (this.isReadOnly) {\r\n return true;\r\n }\r\n\r\n if (this._isActive) {\r\n if (this.pointerEnterActiveAnimation) {\r\n this.pointerEnterActiveAnimation();\r\n }\r\n } else {\r\n if (this.pointerEnterInactiveAnimation) {\r\n this.pointerEnterInactiveAnimation();\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _onPointerOut(target: Control, pi: PointerInfoBase, force = false): void {\r\n if (!this.isReadOnly) {\r\n if (this._isActive) {\r\n if (this.pointerOutActiveAnimation) {\r\n this.pointerOutActiveAnimation();\r\n }\r\n } else {\r\n if (this.pointerOutInactiveAnimation) {\r\n this.pointerOutInactiveAnimation();\r\n }\r\n }\r\n }\r\n\r\n super._onPointerOut(target, pi, force);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, pi: PointerInfoBase): boolean {\r\n if (!super._onPointerDown(target, coordinates, pointerId, buttonIndex, pi)) {\r\n return false;\r\n }\r\n\r\n if (this.isReadOnly) {\r\n return true;\r\n }\r\n\r\n if (this._isActive) {\r\n if (this.pointerDownActiveAnimation) {\r\n this.pointerDownActiveAnimation();\r\n }\r\n } else {\r\n if (this.pointerDownInactiveAnimation) {\r\n this.pointerDownInactiveAnimation();\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: PointerInfoBase): void {\r\n if (!this.isReadOnly) {\r\n if (this._isActive) {\r\n if (this.pointerUpActiveAnimation) {\r\n this.pointerUpActiveAnimation();\r\n }\r\n } else {\r\n if (this.pointerUpInactiveAnimation) {\r\n this.pointerUpInactiveAnimation();\r\n }\r\n }\r\n }\r\n\r\n super._onPointerUp(target, coordinates, pointerId, buttonIndex, notifyClick, pi);\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GUI.ToggleButton\", ToggleButton);\r\n"]}
1
+ {"version":3,"file":"toggleButton.js","sourceRoot":"","sources":["../../../../../lts/gui/generated/2D/controls/toggleButton.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAGlD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,0CAA4B;AAGpD;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,SAAS;IAsDvC,4DAA4D;IAC5D,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IACD,IAAW,KAAK,CAAC,KAAa;QAC1B,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,EAAE;YACvB,OAAO;SACV;QAED,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAGD,8EAA8E;IAC9E,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IACD,IAAW,QAAQ,CAAC,KAAc;;QAC9B,wCAAwC;QACxC,IAAI,IAAI,CAAC,SAAS,KAAK,KAAK,EAAE;YAC1B,OAAO;SACV;QAED,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QAEvB,iDAAiD;QACjD,IAAI,IAAI,CAAC,SAAS,EAAE;YAChB,MAAA,IAAI,CAAC,iBAAiB,oDAAI,CAAC;SAC9B;aAAM;YACH,MAAA,IAAI,CAAC,mBAAmB,oDAAI,CAAC;SAChC;QAED,IAAI,CAAC,YAAY,EAAE,CAAC;QAEpB,IAAI,CAAC,2BAA2B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AAM;YACH,IAAI,IAAI,CAAC,4BAA4B,EAAE;gBACnC,IAAI,CAAC,4BAA4B,EAAE,CAAC;aACvC;SACJ;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,YAAY,CAAC,MAAe,EAAE,WAAoB,EAAE,SAAiB,EAAE,WAAmB,EAAE,WAAoB,EAAE,EAAmB;QACxI,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YAClB,IAAI,IAAI,CAAC,SAAS,EAAE;gBAChB,IAAI,IAAI,CAAC,wBAAwB,EAAE;oBAC/B,IAAI,CAAC,wBAAwB,EAAE,CAAC;iBACnC;aACJ;iBAAM;gBACH,IAAI,IAAI,CAAC,0BAA0B,EAAE;oBACjC,IAAI,CAAC,0BAA0B,EAAE,CAAC;iBACrC;aACJ;SACJ;QAED,KAAK,CAAC,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC;IACrF,CAAC;CACJ;AAED,aAAa,CAAC,0BAA0B,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport type { Vector2 } from \"core/Maths/math.vector\";\r\n\r\nimport { Rectangle } from \"./rectangle\";\r\nimport type { Control } from \"./control\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport type { PointerInfoBase } from \"core/Events/pointerEvents\";\r\n\r\n/**\r\n * Class used to create toggle buttons\r\n * @since 5.0.0\r\n */\r\nexport class ToggleButton extends Rectangle {\r\n /**\r\n * Function called to generate the toActive animation\r\n */\r\n public toActiveAnimation: () => void;\r\n\r\n /**\r\n * Function called to generate the toInactive animation\r\n */\r\n public toInactiveAnimation: () => void;\r\n\r\n /**\r\n * Function called to generate a pointer enter animation when the toggle button is active.\r\n */\r\n public pointerEnterActiveAnimation: () => void;\r\n /**\r\n * Function called to generate a pointer out animation when the toggle button is active.\r\n */\r\n public pointerOutActiveAnimation: () => void;\r\n /**\r\n * Function called to generate a pointer down animation when the toggle button is active.\r\n */\r\n public pointerDownActiveAnimation: () => void;\r\n /**\r\n * Function called to generate a pointer up animation when the toggle button is active.\r\n */\r\n public pointerUpActiveAnimation: () => void;\r\n\r\n /**\r\n * Function called to generate a pointer enter animation when the toggle button is inactive.\r\n */\r\n public pointerEnterInactiveAnimation: () => void;\r\n /**\r\n * Function called to generate a pointer out animation when the toggle button is inactive.\r\n */\r\n public pointerOutInactiveAnimation: () => void;\r\n /**\r\n * Function called to generate a pointer down animation when the toggle button is inactive.\r\n */\r\n public pointerDownInactiveAnimation: () => void;\r\n /**\r\n * Function called to generate a pointer up animation when the toggle button is inactive.\r\n */\r\n public pointerUpInactiveAnimation: () => void;\r\n\r\n /** Observable raised when isActive is changed */\r\n public onIsActiveChangedObservable = new Observable<boolean>();\r\n\r\n /**\r\n * Gets or sets a boolean indicating that the toggle button will let internal controls handle picking instead of doing it directly using its bounding info\r\n */\r\n public delegatePickingToChildren = false;\r\n\r\n private _group: string;\r\n /** Gets or sets group name this toggle button belongs to */\r\n public get group(): string {\r\n return this._group;\r\n }\r\n public set group(value: string) {\r\n if (this._group === value) {\r\n return;\r\n }\r\n\r\n this._group = value;\r\n }\r\n\r\n private _isActive = false;\r\n /** Gets or sets a boolean indicating if the toggle button is active or not */\r\n public get isActive(): boolean {\r\n return this._isActive;\r\n }\r\n public set isActive(value: boolean) {\r\n // Function modeled after radioButton.ts\r\n if (this._isActive === value) {\r\n return;\r\n }\r\n\r\n this._isActive = value;\r\n\r\n // Update the visual state based on the new value\r\n if (this._isActive) {\r\n this.toActiveAnimation?.();\r\n } else {\r\n this.toInactiveAnimation?.();\r\n }\r\n\r\n this._markAsDirty();\r\n\r\n this.onIsActiveChangedObservable.notifyObservers(value);\r\n\r\n if (this._isActive && this._host && this._group) {\r\n // A toggle button in a group can only have 1 active element at a given time.\r\n // If this toggle button has a group, set other toggle buttons in the group to inactive.\r\n this._host.executeOnAllControls((control) => {\r\n // Check for control type ToggleButton\r\n if (control.typeName === \"ToggleButton\") {\r\n // Don't do anything to this toggle button\r\n if (control === this) {\r\n return;\r\n }\r\n\r\n const childToggle = <ToggleButton>control;\r\n // If toggle button is in same group, set isActive to false\r\n if (childToggle.group === this.group) {\r\n childToggle.isActive = false;\r\n }\r\n }\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new ToggleButton\r\n * @param name defines the control name\r\n * @param group defines the toggle group this toggle belongs to\r\n */\r\n constructor(public name?: string, group?: string) {\r\n super(name);\r\n this.group = group ?? \"\";\r\n\r\n this.thickness = 0;\r\n this.isPointerBlocker = true;\r\n\r\n let alphaStore: Nullable<number> = null;\r\n\r\n this.toActiveAnimation = () => {\r\n this.thickness = 1;\r\n };\r\n this.toInactiveAnimation = () => {\r\n this.thickness = 0;\r\n };\r\n\r\n this.pointerEnterActiveAnimation = () => {\r\n alphaStore = this.alpha;\r\n this.alpha -= 0.1;\r\n };\r\n\r\n this.pointerOutActiveAnimation = () => {\r\n if (alphaStore !== null) {\r\n this.alpha = alphaStore;\r\n }\r\n };\r\n\r\n this.pointerDownActiveAnimation = () => {\r\n this.scaleX -= 0.05;\r\n this.scaleY -= 0.05;\r\n };\r\n\r\n this.pointerUpActiveAnimation = () => {\r\n this.scaleX += 0.05;\r\n this.scaleY += 0.05;\r\n };\r\n\r\n this.pointerEnterInactiveAnimation = () => {\r\n alphaStore = this.alpha;\r\n this.alpha -= 0.1;\r\n };\r\n\r\n this.pointerOutInactiveAnimation = () => {\r\n if (alphaStore !== null) {\r\n this.alpha = alphaStore;\r\n }\r\n };\r\n\r\n this.pointerDownInactiveAnimation = () => {\r\n this.scaleX -= 0.05;\r\n this.scaleY -= 0.05;\r\n };\r\n\r\n this.pointerUpInactiveAnimation = () => {\r\n this.scaleX += 0.05;\r\n this.scaleY += 0.05;\r\n };\r\n }\r\n\r\n protected _getTypeName(): string {\r\n return \"ToggleButton\";\r\n }\r\n\r\n // While being a container, the toggle button behaves like a control.\r\n /**\r\n * @internal\r\n */\r\n public _processPicking(x: number, y: number, pi: PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean {\r\n if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {\r\n return false;\r\n }\r\n\r\n if (!super.contains(x, y)) {\r\n return false;\r\n }\r\n\r\n if (this.delegatePickingToChildren) {\r\n let contains = false;\r\n for (let index = this._children.length - 1; index >= 0; index--) {\r\n const child = this._children[index];\r\n if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {\r\n contains = true;\r\n break;\r\n }\r\n }\r\n\r\n if (!contains) {\r\n return false;\r\n }\r\n }\r\n\r\n this._processObservables(type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY);\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _onPointerEnter(target: Control, pi: PointerInfoBase): boolean {\r\n if (!super._onPointerEnter(target, pi)) {\r\n return false;\r\n }\r\n\r\n if (this.isReadOnly) {\r\n return true;\r\n }\r\n\r\n if (this._isActive) {\r\n if (this.pointerEnterActiveAnimation) {\r\n this.pointerEnterActiveAnimation();\r\n }\r\n } else {\r\n if (this.pointerEnterInactiveAnimation) {\r\n this.pointerEnterInactiveAnimation();\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _onPointerOut(target: Control, pi: PointerInfoBase, force = false): void {\r\n if (!this.isReadOnly) {\r\n if (this._isActive) {\r\n if (this.pointerOutActiveAnimation) {\r\n this.pointerOutActiveAnimation();\r\n }\r\n } else {\r\n if (this.pointerOutInactiveAnimation) {\r\n this.pointerOutInactiveAnimation();\r\n }\r\n }\r\n }\r\n\r\n super._onPointerOut(target, pi, force);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, pi: PointerInfoBase): boolean {\r\n if (!super._onPointerDown(target, coordinates, pointerId, buttonIndex, pi)) {\r\n return false;\r\n }\r\n\r\n if (this.isReadOnly) {\r\n return true;\r\n }\r\n\r\n if (this._isActive) {\r\n if (this.pointerDownActiveAnimation) {\r\n this.pointerDownActiveAnimation();\r\n }\r\n } else {\r\n if (this.pointerDownInactiveAnimation) {\r\n this.pointerDownInactiveAnimation();\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: PointerInfoBase): void {\r\n if (!this.isReadOnly) {\r\n if (this._isActive) {\r\n if (this.pointerUpActiveAnimation) {\r\n this.pointerUpActiveAnimation();\r\n }\r\n } else {\r\n if (this.pointerUpInactiveAnimation) {\r\n this.pointerUpInactiveAnimation();\r\n }\r\n }\r\n }\r\n\r\n super._onPointerUp(target, coordinates, pointerId, buttonIndex, notifyClick, pi);\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GUI.ToggleButton\", ToggleButton);\r\n"]}
@@ -25,133 +25,6 @@ import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
25
25
  * Class used to create the mrtkv3 button
26
26
  */
27
27
  export class TouchHolographicButton extends TouchButton3D {
28
- /**
29
- * Creates a new button
30
- * @param name defines the control name
31
- * @param shareMaterials
32
- */
33
- constructor(name, shareMaterials = true) {
34
- super(name);
35
- /**
36
- * Gets or sets the horizontal scaling for the button.
37
- */
38
- this.width = 1;
39
- /**
40
- * Gets or sets the vertical scaling for the button.
41
- */
42
- this.height = 1;
43
- /**
44
- * Gets or sets the bevel radius for the button.
45
- */
46
- this.radius = 0.14;
47
- /**
48
- * Gets or sets the font size of the button text in pixels.
49
- * This is only adjustable for a button with width to height ratio greater than 1.
50
- */
51
- this.textSizeInPixels = 18;
52
- /**
53
- * Gets or sets the size of the button image in pixels.
54
- * This is only adjustable for a button with width to height ratio greater than 1.
55
- */
56
- this.imageSizeInPixels = 40;
57
- /**
58
- * Gets or sets the color of the button plate.
59
- */
60
- this.plateMaterialColor = new Color3(0.4, 0.4, 0.4);
61
- // Shared variables for meshes
62
- /**
63
- * Gets or sets the depth of the button's front plate.
64
- * This variable determines the z scaling and z position for some of the button's meshes.
65
- */
66
- this.frontPlateDepth = 0.2;
67
- /**
68
- * Gets or sets the depth of the button's back plate.
69
- * This variable determines the z scaling and z position for some of the button's meshes.
70
- */
71
- this.backPlateDepth = 0.04;
72
- /**
73
- * Gets or sets the offset value for button's back glow.
74
- * This variable determines the x, y scaling of the button's meshes.
75
- */
76
- this.backGlowOffset = 0.1;
77
- /**
78
- * Gets or sets the value that determines the z scaling and z position for the innerQuad and BackGlow meshes.
79
- */
80
- this.flatPlaneDepth = 0.001;
81
- /**
82
- * Gets or sets the radius for FrontMaterial and innerQuadMaterial.
83
- */
84
- this.innerQuadRadius = this.radius - 0.04;
85
- /**
86
- * Gets or sets the color for innerQuadMaterial.
87
- */
88
- this.innerQuadColor = new Color4(0, 0, 0, 0);
89
- /**
90
- * Gets or sets the color for innerQuadMaterial for when it is toggled.
91
- */
92
- this.innerQuadToggledColor = new Color4(0.5197843, 0.6485234, 0.9607843, 0.6);
93
- /**
94
- * Gets or sets the color for innerQuadMaterial for when it is hovered.
95
- */
96
- this.innerQuadHoverColor = new Color4(1, 1, 1, 0.05);
97
- /**
98
- * Gets or sets the color for innerQuadMaterial for when it is toggled and hovered.
99
- */
100
- this.innerQuadToggledHoverColor = new Color4(0.5197843, 0.6485234, 0.9607843, 1);
101
- this._isBackplateVisible = true;
102
- // Materials
103
- this._shareMaterials = true;
104
- this._shareMaterials = shareMaterials;
105
- this.pointerEnterAnimation = () => {
106
- if (this._frontPlate && this._textPlate && !this.isToggleButton) {
107
- this._performEnterExitAnimation(1);
108
- }
109
- if (this.isToggleButton && this._innerQuadMaterial) {
110
- if (this.isToggled) {
111
- this._innerQuadMaterial.color = this.innerQuadToggledHoverColor;
112
- }
113
- else {
114
- this._innerQuadMaterial.color = this.innerQuadHoverColor;
115
- }
116
- }
117
- };
118
- this.pointerOutAnimation = () => {
119
- if (this._frontPlate && this._textPlate && !this.isToggleButton) {
120
- this._performEnterExitAnimation(-0.8);
121
- }
122
- if (this.isToggleButton && this._innerQuadMaterial) {
123
- this._onToggle(this.isToggled);
124
- }
125
- };
126
- this.pointerDownAnimation = () => {
127
- // Do nothing
128
- };
129
- this.pointerUpAnimation = () => {
130
- // Do nothing
131
- };
132
- this._pointerClickObserver = this.onPointerClickObservable.add(() => {
133
- if (this._frontPlate && this._backGlow && !this.isActiveNearInteraction) {
134
- this._performClickAnimation();
135
- }
136
- if (this.isToggleButton && this._innerQuadMaterial) {
137
- this._onToggle(this.isToggled);
138
- }
139
- });
140
- this._pointerEnterObserver = this.onPointerEnterObservable.add(() => {
141
- this.pointerEnterAnimation();
142
- });
143
- this._pointerOutObserver = this.onPointerOutObservable.add(() => {
144
- this.pointerOutAnimation();
145
- });
146
- this._toggleObserver = this.onToggleObservable.add((isToggled) => {
147
- if (isToggled) {
148
- this._innerQuadMaterial.color = this.innerQuadToggledColor;
149
- }
150
- else {
151
- this._innerQuadMaterial.color = this.innerQuadColor;
152
- }
153
- });
154
- }
155
28
  _disposeTooltip() {
156
29
  this._tooltipFade = null;
157
30
  if (this._tooltipTextBlock) {
@@ -330,6 +203,133 @@ export class TouchHolographicButton extends TouchButton3D {
330
203
  }
331
204
  this._isBackplateVisible = isVisible;
332
205
  }
206
+ /**
207
+ * Creates a new button
208
+ * @param name defines the control name
209
+ * @param shareMaterials
210
+ */
211
+ constructor(name, shareMaterials = true) {
212
+ super(name);
213
+ /**
214
+ * Gets or sets the horizontal scaling for the button.
215
+ */
216
+ this.width = 1;
217
+ /**
218
+ * Gets or sets the vertical scaling for the button.
219
+ */
220
+ this.height = 1;
221
+ /**
222
+ * Gets or sets the bevel radius for the button.
223
+ */
224
+ this.radius = 0.14;
225
+ /**
226
+ * Gets or sets the font size of the button text in pixels.
227
+ * This is only adjustable for a button with width to height ratio greater than 1.
228
+ */
229
+ this.textSizeInPixels = 18;
230
+ /**
231
+ * Gets or sets the size of the button image in pixels.
232
+ * This is only adjustable for a button with width to height ratio greater than 1.
233
+ */
234
+ this.imageSizeInPixels = 40;
235
+ /**
236
+ * Gets or sets the color of the button plate.
237
+ */
238
+ this.plateMaterialColor = new Color3(0.4, 0.4, 0.4);
239
+ // Shared variables for meshes
240
+ /**
241
+ * Gets or sets the depth of the button's front plate.
242
+ * This variable determines the z scaling and z position for some of the button's meshes.
243
+ */
244
+ this.frontPlateDepth = 0.2;
245
+ /**
246
+ * Gets or sets the depth of the button's back plate.
247
+ * This variable determines the z scaling and z position for some of the button's meshes.
248
+ */
249
+ this.backPlateDepth = 0.04;
250
+ /**
251
+ * Gets or sets the offset value for button's back glow.
252
+ * This variable determines the x, y scaling of the button's meshes.
253
+ */
254
+ this.backGlowOffset = 0.1;
255
+ /**
256
+ * Gets or sets the value that determines the z scaling and z position for the innerQuad and BackGlow meshes.
257
+ */
258
+ this.flatPlaneDepth = 0.001;
259
+ /**
260
+ * Gets or sets the radius for FrontMaterial and innerQuadMaterial.
261
+ */
262
+ this.innerQuadRadius = this.radius - 0.04;
263
+ /**
264
+ * Gets or sets the color for innerQuadMaterial.
265
+ */
266
+ this.innerQuadColor = new Color4(0, 0, 0, 0);
267
+ /**
268
+ * Gets or sets the color for innerQuadMaterial for when it is toggled.
269
+ */
270
+ this.innerQuadToggledColor = new Color4(0.5197843, 0.6485234, 0.9607843, 0.6);
271
+ /**
272
+ * Gets or sets the color for innerQuadMaterial for when it is hovered.
273
+ */
274
+ this.innerQuadHoverColor = new Color4(1, 1, 1, 0.05);
275
+ /**
276
+ * Gets or sets the color for innerQuadMaterial for when it is toggled and hovered.
277
+ */
278
+ this.innerQuadToggledHoverColor = new Color4(0.5197843, 0.6485234, 0.9607843, 1);
279
+ this._isBackplateVisible = true;
280
+ // Materials
281
+ this._shareMaterials = true;
282
+ this._shareMaterials = shareMaterials;
283
+ this.pointerEnterAnimation = () => {
284
+ if (this._frontPlate && this._textPlate && !this.isToggleButton) {
285
+ this._performEnterExitAnimation(1);
286
+ }
287
+ if (this.isToggleButton && this._innerQuadMaterial) {
288
+ if (this.isToggled) {
289
+ this._innerQuadMaterial.color = this.innerQuadToggledHoverColor;
290
+ }
291
+ else {
292
+ this._innerQuadMaterial.color = this.innerQuadHoverColor;
293
+ }
294
+ }
295
+ };
296
+ this.pointerOutAnimation = () => {
297
+ if (this._frontPlate && this._textPlate && !this.isToggleButton) {
298
+ this._performEnterExitAnimation(-0.8);
299
+ }
300
+ if (this.isToggleButton && this._innerQuadMaterial) {
301
+ this._onToggle(this.isToggled);
302
+ }
303
+ };
304
+ this.pointerDownAnimation = () => {
305
+ // Do nothing
306
+ };
307
+ this.pointerUpAnimation = () => {
308
+ // Do nothing
309
+ };
310
+ this._pointerClickObserver = this.onPointerClickObservable.add(() => {
311
+ if (this._frontPlate && this._backGlow && !this.isActiveNearInteraction) {
312
+ this._performClickAnimation();
313
+ }
314
+ if (this.isToggleButton && this._innerQuadMaterial) {
315
+ this._onToggle(this.isToggled);
316
+ }
317
+ });
318
+ this._pointerEnterObserver = this.onPointerEnterObservable.add(() => {
319
+ this.pointerEnterAnimation();
320
+ });
321
+ this._pointerOutObserver = this.onPointerOutObservable.add(() => {
322
+ this.pointerOutAnimation();
323
+ });
324
+ this._toggleObserver = this.onToggleObservable.add((isToggled) => {
325
+ if (isToggled) {
326
+ this._innerQuadMaterial.color = this.innerQuadToggledColor;
327
+ }
328
+ else {
329
+ this._innerQuadMaterial.color = this.innerQuadColor;
330
+ }
331
+ });
332
+ }
333
333
  _getTypeName() {
334
334
  return "TouchHolographicButton";
335
335
  }