@babylonjs/gui 5.21.0 → 5.22.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 (178) hide show
  1. package/2D/adtInstrumentation.js +70 -90
  2. package/2D/adtInstrumentation.js.map +1 -1
  3. package/2D/advancedDynamicTexture.d.ts +6 -0
  4. package/2D/advancedDynamicTexture.js +554 -622
  5. package/2D/advancedDynamicTexture.js.map +1 -1
  6. package/2D/controls/button.js +76 -90
  7. package/2D/controls/button.js.map +1 -1
  8. package/2D/controls/checkbox.js +86 -106
  9. package/2D/controls/checkbox.js.map +1 -1
  10. package/2D/controls/colorpicker.js +395 -415
  11. package/2D/controls/colorpicker.js.map +1 -1
  12. package/2D/controls/container.js +187 -230
  13. package/2D/controls/container.js.map +1 -1
  14. package/2D/controls/control.js +1067 -1353
  15. package/2D/controls/control.js.map +1 -1
  16. package/2D/controls/displayGrid.js +152 -196
  17. package/2D/controls/displayGrid.js.map +1 -1
  18. package/2D/controls/ellipse.js +32 -40
  19. package/2D/controls/ellipse.js.map +1 -1
  20. package/2D/controls/focusableButton.js +30 -35
  21. package/2D/controls/focusableButton.js.map +1 -1
  22. package/2D/controls/grid.js +172 -212
  23. package/2D/controls/grid.js.map +1 -1
  24. package/2D/controls/image.js +489 -592
  25. package/2D/controls/image.js.map +1 -1
  26. package/2D/controls/inputPassword.js +9 -16
  27. package/2D/controls/inputPassword.js.map +1 -1
  28. package/2D/controls/inputText.js +380 -467
  29. package/2D/controls/inputText.js.map +1 -1
  30. package/2D/controls/inputTextArea.js +234 -273
  31. package/2D/controls/inputTextArea.js.map +1 -1
  32. package/2D/controls/line.js +147 -198
  33. package/2D/controls/line.js.map +1 -1
  34. package/2D/controls/multiLine.js +87 -113
  35. package/2D/controls/multiLine.js.map +1 -1
  36. package/2D/controls/radioButton.js +106 -127
  37. package/2D/controls/radioButton.js.map +1 -1
  38. package/2D/controls/rectangle.js +60 -72
  39. package/2D/controls/rectangle.js.map +1 -1
  40. package/2D/controls/scrollViewers/scrollViewer.js +439 -543
  41. package/2D/controls/scrollViewers/scrollViewer.js.map +1 -1
  42. package/2D/controls/scrollViewers/scrollViewerWindow.js +99 -118
  43. package/2D/controls/scrollViewers/scrollViewerWindow.js.map +1 -1
  44. package/2D/controls/selector.js +241 -329
  45. package/2D/controls/selector.js.map +1 -1
  46. package/2D/controls/sliders/baseSlider.js +182 -230
  47. package/2D/controls/sliders/baseSlider.js.map +1 -1
  48. package/2D/controls/sliders/imageBasedSlider.js +86 -109
  49. package/2D/controls/sliders/imageBasedSlider.js.map +1 -1
  50. package/2D/controls/sliders/imageScrollBar.js +148 -178
  51. package/2D/controls/sliders/imageScrollBar.js.map +1 -1
  52. package/2D/controls/sliders/scrollBar.js +64 -80
  53. package/2D/controls/sliders/scrollBar.js.map +1 -1
  54. package/2D/controls/sliders/slider.js +91 -115
  55. package/2D/controls/sliders/slider.js.map +1 -1
  56. package/2D/controls/stackPanel.js +114 -135
  57. package/2D/controls/stackPanel.js.map +1 -1
  58. package/2D/controls/statics.js +5 -5
  59. package/2D/controls/statics.js.map +1 -1
  60. package/2D/controls/textBlock.js +322 -384
  61. package/2D/controls/textBlock.js.map +1 -1
  62. package/2D/controls/textWrapper.js +27 -41
  63. package/2D/controls/textWrapper.js.map +1 -1
  64. package/2D/controls/toggleButton.js +105 -121
  65. package/2D/controls/toggleButton.js.map +1 -1
  66. package/2D/controls/virtualKeyboard.js +101 -123
  67. package/2D/controls/virtualKeyboard.js.map +1 -1
  68. package/2D/math2D.js +62 -70
  69. package/2D/math2D.js.map +1 -1
  70. package/2D/measure.js +30 -32
  71. package/2D/measure.js.map +1 -1
  72. package/2D/multiLinePoint.js +71 -89
  73. package/2D/multiLinePoint.js.map +1 -1
  74. package/2D/style.js +55 -73
  75. package/2D/style.js.map +1 -1
  76. package/2D/valueAndUnit.js +71 -104
  77. package/2D/valueAndUnit.js.map +1 -1
  78. package/2D/xmlLoader.js +70 -84
  79. package/2D/xmlLoader.js.map +1 -1
  80. package/3D/behaviors/defaultBehavior.js +40 -59
  81. package/3D/behaviors/defaultBehavior.js.map +1 -1
  82. package/3D/controls/abstractButton3D.js +8 -12
  83. package/3D/controls/abstractButton3D.js.map +1 -1
  84. package/3D/controls/button3D.js +30 -35
  85. package/3D/controls/button3D.js.map +1 -1
  86. package/3D/controls/container3D.js +57 -71
  87. package/3D/controls/container3D.js.map +1 -1
  88. package/3D/controls/contentDisplay3D.js +47 -60
  89. package/3D/controls/contentDisplay3D.js.map +1 -1
  90. package/3D/controls/control3D.js +123 -158
  91. package/3D/controls/control3D.js.map +1 -1
  92. package/3D/controls/cylinderPanel.js +28 -38
  93. package/3D/controls/cylinderPanel.js.map +1 -1
  94. package/3D/controls/handMenu.js +20 -29
  95. package/3D/controls/handMenu.js.map +1 -1
  96. package/3D/controls/holographicBackplate.js +52 -72
  97. package/3D/controls/holographicBackplate.js.map +1 -1
  98. package/3D/controls/holographicButton.js +160 -200
  99. package/3D/controls/holographicButton.js.map +1 -1
  100. package/3D/controls/holographicSlate.js +176 -206
  101. package/3D/controls/holographicSlate.js.map +1 -1
  102. package/3D/controls/meshButton3D.js +24 -30
  103. package/3D/controls/meshButton3D.js.map +1 -1
  104. package/3D/controls/nearMenu.js +57 -71
  105. package/3D/controls/nearMenu.js.map +1 -1
  106. package/3D/controls/planePanel.js +6 -13
  107. package/3D/controls/planePanel.js.map +1 -1
  108. package/3D/controls/scatterPanel.js +43 -54
  109. package/3D/controls/scatterPanel.js.map +1 -1
  110. package/3D/controls/slider3D.js +168 -222
  111. package/3D/controls/slider3D.js.map +1 -1
  112. package/3D/controls/spherePanel.js +29 -39
  113. package/3D/controls/spherePanel.js.map +1 -1
  114. package/3D/controls/stackPanel3D.js +36 -49
  115. package/3D/controls/stackPanel3D.js.map +1 -1
  116. package/3D/controls/touchButton3D.js +126 -154
  117. package/3D/controls/touchButton3D.js.map +1 -1
  118. package/3D/controls/touchHolographicButton.js +223 -272
  119. package/3D/controls/touchHolographicButton.js.map +1 -1
  120. package/3D/controls/touchHolographicMenu.js +55 -66
  121. package/3D/controls/touchHolographicMenu.js.map +1 -1
  122. package/3D/controls/touchMeshButton3D.js +24 -30
  123. package/3D/controls/touchMeshButton3D.js.map +1 -1
  124. package/3D/controls/volumeBasedPanel.js +85 -107
  125. package/3D/controls/volumeBasedPanel.js.map +1 -1
  126. package/3D/gizmos/gizmoHandle.js +68 -103
  127. package/3D/gizmos/gizmoHandle.js.map +1 -1
  128. package/3D/gizmos/slateGizmo.js +165 -182
  129. package/3D/gizmos/slateGizmo.js.map +1 -1
  130. package/3D/gui3DManager.js +76 -101
  131. package/3D/gui3DManager.js.map +1 -1
  132. package/3D/materials/fluent/fluentMaterial.js +110 -119
  133. package/3D/materials/fluent/fluentMaterial.js.map +1 -1
  134. package/3D/materials/fluent/shaders/fluent.fragment.js +20 -3
  135. package/3D/materials/fluent/shaders/fluent.fragment.js.map +1 -1
  136. package/3D/materials/fluent/shaders/fluent.vertex.js +11 -3
  137. package/3D/materials/fluent/shaders/fluent.vertex.js.map +1 -1
  138. package/3D/materials/fluentBackplate/fluentBackplateMaterial.js +168 -177
  139. package/3D/materials/fluentBackplate/fluentBackplateMaterial.js.map +1 -1
  140. package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.js +9 -3
  141. package/3D/materials/fluentBackplate/shaders/fluentBackplate.fragment.js.map +1 -1
  142. package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.js +15 -3
  143. package/3D/materials/fluentBackplate/shaders/fluentBackplate.vertex.js.map +1 -1
  144. package/3D/materials/fluentButton/fluentButtonMaterial.js +205 -213
  145. package/3D/materials/fluentButton/fluentButtonMaterial.js.map +1 -1
  146. package/3D/materials/fluentButton/shaders/fluentButton.fragment.js +6 -3
  147. package/3D/materials/fluentButton/shaders/fluentButton.fragment.js.map +1 -1
  148. package/3D/materials/fluentButton/shaders/fluentButton.vertex.js +6 -3
  149. package/3D/materials/fluentButton/shaders/fluentButton.vertex.js.map +1 -1
  150. package/3D/materials/handle/handleMaterial.js +56 -69
  151. package/3D/materials/handle/handleMaterial.js.map +1 -1
  152. package/3D/materials/handle/shaders/handle.fragment.js +3 -3
  153. package/3D/materials/handle/shaders/handle.fragment.js.map +1 -1
  154. package/3D/materials/handle/shaders/handle.vertex.js +3 -3
  155. package/3D/materials/handle/shaders/handle.vertex.js.map +1 -1
  156. package/3D/materials/mrdl/mrdlBackplateMaterial.js +158 -166
  157. package/3D/materials/mrdl/mrdlBackplateMaterial.js.map +1 -1
  158. package/3D/materials/mrdl/mrdlSliderBarMaterial.js +322 -330
  159. package/3D/materials/mrdl/mrdlSliderBarMaterial.js.map +1 -1
  160. package/3D/materials/mrdl/mrdlSliderThumbMaterial.js +322 -330
  161. package/3D/materials/mrdl/mrdlSliderThumbMaterial.js.map +1 -1
  162. package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.js +9 -3
  163. package/3D/materials/mrdl/shaders/mrdlBackplate.fragment.js.map +1 -1
  164. package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.js +6 -3
  165. package/3D/materials/mrdl/shaders/mrdlBackplate.vertex.js.map +1 -1
  166. package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.js +24 -3
  167. package/3D/materials/mrdl/shaders/mrdlSliderBar.fragment.js.map +1 -1
  168. package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.js +12 -3
  169. package/3D/materials/mrdl/shaders/mrdlSliderBar.vertex.js.map +1 -1
  170. package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.js +24 -3
  171. package/3D/materials/mrdl/shaders/mrdlSliderThumb.fragment.js.map +1 -1
  172. package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.js +12 -3
  173. package/3D/materials/mrdl/shaders/mrdlSliderThumb.vertex.js.map +1 -1
  174. package/3D/vector3WithInfo.js +6 -12
  175. package/3D/vector3WithInfo.js.map +1 -1
  176. package/legacy/legacy.js +1 -1
  177. package/legacy/legacy.js.map +1 -1
  178. package/package.json +2 -5
@@ -1,4 +1,4 @@
1
- import { __decorate, __extends } from "tslib";
1
+ import { __decorate } from "@babylonjs/core/tslib.es6.js";
2
2
  import { Observable } from "@babylonjs/core/Misc/observable.js";
3
3
  import { Tools } from "@babylonjs/core/Misc/tools.js";
4
4
  import { Control } from "./control.js";
@@ -8,318 +8,245 @@ import { EngineStore } from "@babylonjs/core/Engines/engineStore.js";
8
8
  /**
9
9
  * Class used to create 2D images
10
10
  */
11
- var Image = /** @class */ (function (_super) {
12
- __extends(Image, _super);
11
+ export class Image extends Control {
13
12
  /**
14
13
  * Creates a new Image
15
14
  * @param name defines the control name
16
15
  * @param url defines the image url
17
16
  */
18
- function Image(name, url) {
19
- if (url === void 0) { url = null; }
20
- var _this = _super.call(this, name) || this;
21
- _this.name = name;
22
- _this._workingCanvas = null;
23
- _this._loaded = false;
24
- _this._stretch = Image.STRETCH_FILL;
25
- _this._autoScale = false;
26
- _this._sourceLeft = 0;
27
- _this._sourceTop = 0;
28
- _this._sourceWidth = 0;
29
- _this._sourceHeight = 0;
30
- _this._svgAttributesComputationCompleted = false;
31
- _this._isSVG = false;
32
- _this._cellWidth = 0;
33
- _this._cellHeight = 0;
34
- _this._cellId = -1;
35
- _this._populateNinePatchSlicesFromImage = false;
36
- _this._imageDataCache = { data: null, key: "" };
17
+ constructor(name, url = null) {
18
+ super(name);
19
+ this.name = name;
20
+ this._workingCanvas = null;
21
+ this._loaded = false;
22
+ this._stretch = Image.STRETCH_FILL;
23
+ this._autoScale = false;
24
+ this._sourceLeft = 0;
25
+ this._sourceTop = 0;
26
+ this._sourceWidth = 0;
27
+ this._sourceHeight = 0;
28
+ this._svgAttributesComputationCompleted = false;
29
+ this._isSVG = false;
30
+ this._cellWidth = 0;
31
+ this._cellHeight = 0;
32
+ this._cellId = -1;
33
+ this._populateNinePatchSlicesFromImage = false;
34
+ this._imageDataCache = { data: null, key: "" };
37
35
  /**
38
36
  * Observable notified when the content is loaded
39
37
  */
40
- _this.onImageLoadedObservable = new Observable();
38
+ this.onImageLoadedObservable = new Observable();
41
39
  /**
42
40
  * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
43
41
  */
44
- _this.onSVGAttributesComputedObservable = new Observable();
45
- _this.source = url;
46
- return _this;
42
+ this.onSVGAttributesComputedObservable = new Observable();
43
+ this.source = url;
44
+ }
45
+ /**
46
+ * Gets a boolean indicating that the content is loaded
47
+ */
48
+ get isLoaded() {
49
+ return this._loaded;
50
+ }
51
+ /**
52
+ * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
53
+ * Beware using this as this will consume more memory as the image has to be stored twice
54
+ */
55
+ get detectPointerOnOpaqueOnly() {
56
+ return this._detectPointerOnOpaqueOnly;
57
+ }
58
+ set detectPointerOnOpaqueOnly(value) {
59
+ if (this._detectPointerOnOpaqueOnly === value) {
60
+ return;
61
+ }
62
+ this._detectPointerOnOpaqueOnly = value;
63
+ }
64
+ /**
65
+ * Gets or sets the left value for slicing (9-patch)
66
+ */
67
+ get sliceLeft() {
68
+ return this._sliceLeft;
69
+ }
70
+ set sliceLeft(value) {
71
+ if (this._sliceLeft === value) {
72
+ return;
73
+ }
74
+ this._sliceLeft = value;
75
+ this._markAsDirty();
76
+ }
77
+ /**
78
+ * Gets or sets the right value for slicing (9-patch)
79
+ */
80
+ get sliceRight() {
81
+ return this._sliceRight;
82
+ }
83
+ set sliceRight(value) {
84
+ if (this._sliceRight === value) {
85
+ return;
86
+ }
87
+ this._sliceRight = value;
88
+ this._markAsDirty();
89
+ }
90
+ /**
91
+ * Gets or sets the top value for slicing (9-patch)
92
+ */
93
+ get sliceTop() {
94
+ return this._sliceTop;
95
+ }
96
+ set sliceTop(value) {
97
+ if (this._sliceTop === value) {
98
+ return;
99
+ }
100
+ this._sliceTop = value;
101
+ this._markAsDirty();
102
+ }
103
+ /**
104
+ * Gets or sets the bottom value for slicing (9-patch)
105
+ */
106
+ get sliceBottom() {
107
+ return this._sliceBottom;
108
+ }
109
+ set sliceBottom(value) {
110
+ if (this._sliceBottom === value) {
111
+ return;
112
+ }
113
+ this._sliceBottom = value;
114
+ this._markAsDirty();
115
+ }
116
+ /**
117
+ * Gets or sets the left coordinate in the source image
118
+ */
119
+ get sourceLeft() {
120
+ return this._sourceLeft;
121
+ }
122
+ set sourceLeft(value) {
123
+ if (this._sourceLeft === value) {
124
+ return;
125
+ }
126
+ this._sourceLeft = value;
127
+ this._markAsDirty();
128
+ }
129
+ /**
130
+ * Gets or sets the top coordinate in the source image
131
+ */
132
+ get sourceTop() {
133
+ return this._sourceTop;
134
+ }
135
+ set sourceTop(value) {
136
+ if (this._sourceTop === value) {
137
+ return;
138
+ }
139
+ this._sourceTop = value;
140
+ this._markAsDirty();
141
+ }
142
+ /**
143
+ * Gets or sets the width to capture in the source image
144
+ */
145
+ get sourceWidth() {
146
+ return this._sourceWidth;
147
+ }
148
+ set sourceWidth(value) {
149
+ if (this._sourceWidth === value) {
150
+ return;
151
+ }
152
+ this._sourceWidth = value;
153
+ this._markAsDirty();
154
+ }
155
+ /**
156
+ * Gets or sets the height to capture in the source image
157
+ */
158
+ get sourceHeight() {
159
+ return this._sourceHeight;
160
+ }
161
+ set sourceHeight(value) {
162
+ if (this._sourceHeight === value) {
163
+ return;
164
+ }
165
+ this._sourceHeight = value;
166
+ this._markAsDirty();
167
+ }
168
+ /**
169
+ * Gets the image width
170
+ */
171
+ get imageWidth() {
172
+ return this._imageWidth;
173
+ }
174
+ /**
175
+ * Gets the image height
176
+ */
177
+ get imageHeight() {
178
+ return this._imageHeight;
179
+ }
180
+ /**
181
+ * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
182
+ */
183
+ get populateNinePatchSlicesFromImage() {
184
+ return this._populateNinePatchSlicesFromImage;
185
+ }
186
+ set populateNinePatchSlicesFromImage(value) {
187
+ if (this._populateNinePatchSlicesFromImage === value) {
188
+ return;
189
+ }
190
+ this._populateNinePatchSlicesFromImage = value;
191
+ if (this._populateNinePatchSlicesFromImage && this._loaded) {
192
+ this._extractNinePatchSliceDataFromImage();
193
+ }
194
+ }
195
+ /** Indicates if the format of the image is SVG */
196
+ get isSVG() {
197
+ return this._isSVG;
198
+ }
199
+ /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
200
+ get svgAttributesComputationCompleted() {
201
+ return this._svgAttributesComputationCompleted;
202
+ }
203
+ /**
204
+ * Gets or sets a boolean indicating if the image can force its container to adapt its size
205
+ * @see https://doc.babylonjs.com/how_to/gui#image
206
+ */
207
+ get autoScale() {
208
+ return this._autoScale;
209
+ }
210
+ set autoScale(value) {
211
+ if (this._autoScale === value) {
212
+ return;
213
+ }
214
+ this._autoScale = value;
215
+ if (value && this._loaded) {
216
+ this.synchronizeSizeWithContent();
217
+ }
218
+ }
219
+ /** Gets or sets the stretching mode used by the image */
220
+ get stretch() {
221
+ return this._stretch;
222
+ }
223
+ set stretch(value) {
224
+ if (this._stretch === value) {
225
+ return;
226
+ }
227
+ this._stretch = value;
228
+ this._markAsDirty();
47
229
  }
48
- Object.defineProperty(Image.prototype, "isLoaded", {
49
- /**
50
- * Gets a boolean indicating that the content is loaded
51
- */
52
- get: function () {
53
- return this._loaded;
54
- },
55
- enumerable: false,
56
- configurable: true
57
- });
58
- Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
59
- /**
60
- * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
61
- * Beware using this as this will consume more memory as the image has to be stored twice
62
- */
63
- get: function () {
64
- return this._detectPointerOnOpaqueOnly;
65
- },
66
- set: function (value) {
67
- if (this._detectPointerOnOpaqueOnly === value) {
68
- return;
69
- }
70
- this._detectPointerOnOpaqueOnly = value;
71
- },
72
- enumerable: false,
73
- configurable: true
74
- });
75
- Object.defineProperty(Image.prototype, "sliceLeft", {
76
- /**
77
- * Gets or sets the left value for slicing (9-patch)
78
- */
79
- get: function () {
80
- return this._sliceLeft;
81
- },
82
- set: function (value) {
83
- if (this._sliceLeft === value) {
84
- return;
85
- }
86
- this._sliceLeft = value;
87
- this._markAsDirty();
88
- },
89
- enumerable: false,
90
- configurable: true
91
- });
92
- Object.defineProperty(Image.prototype, "sliceRight", {
93
- /**
94
- * Gets or sets the right value for slicing (9-patch)
95
- */
96
- get: function () {
97
- return this._sliceRight;
98
- },
99
- set: function (value) {
100
- if (this._sliceRight === value) {
101
- return;
102
- }
103
- this._sliceRight = value;
104
- this._markAsDirty();
105
- },
106
- enumerable: false,
107
- configurable: true
108
- });
109
- Object.defineProperty(Image.prototype, "sliceTop", {
110
- /**
111
- * Gets or sets the top value for slicing (9-patch)
112
- */
113
- get: function () {
114
- return this._sliceTop;
115
- },
116
- set: function (value) {
117
- if (this._sliceTop === value) {
118
- return;
119
- }
120
- this._sliceTop = value;
121
- this._markAsDirty();
122
- },
123
- enumerable: false,
124
- configurable: true
125
- });
126
- Object.defineProperty(Image.prototype, "sliceBottom", {
127
- /**
128
- * Gets or sets the bottom value for slicing (9-patch)
129
- */
130
- get: function () {
131
- return this._sliceBottom;
132
- },
133
- set: function (value) {
134
- if (this._sliceBottom === value) {
135
- return;
136
- }
137
- this._sliceBottom = value;
138
- this._markAsDirty();
139
- },
140
- enumerable: false,
141
- configurable: true
142
- });
143
- Object.defineProperty(Image.prototype, "sourceLeft", {
144
- /**
145
- * Gets or sets the left coordinate in the source image
146
- */
147
- get: function () {
148
- return this._sourceLeft;
149
- },
150
- set: function (value) {
151
- if (this._sourceLeft === value) {
152
- return;
153
- }
154
- this._sourceLeft = value;
155
- this._markAsDirty();
156
- },
157
- enumerable: false,
158
- configurable: true
159
- });
160
- Object.defineProperty(Image.prototype, "sourceTop", {
161
- /**
162
- * Gets or sets the top coordinate in the source image
163
- */
164
- get: function () {
165
- return this._sourceTop;
166
- },
167
- set: function (value) {
168
- if (this._sourceTop === value) {
169
- return;
170
- }
171
- this._sourceTop = value;
172
- this._markAsDirty();
173
- },
174
- enumerable: false,
175
- configurable: true
176
- });
177
- Object.defineProperty(Image.prototype, "sourceWidth", {
178
- /**
179
- * Gets or sets the width to capture in the source image
180
- */
181
- get: function () {
182
- return this._sourceWidth;
183
- },
184
- set: function (value) {
185
- if (this._sourceWidth === value) {
186
- return;
187
- }
188
- this._sourceWidth = value;
189
- this._markAsDirty();
190
- },
191
- enumerable: false,
192
- configurable: true
193
- });
194
- Object.defineProperty(Image.prototype, "sourceHeight", {
195
- /**
196
- * Gets or sets the height to capture in the source image
197
- */
198
- get: function () {
199
- return this._sourceHeight;
200
- },
201
- set: function (value) {
202
- if (this._sourceHeight === value) {
203
- return;
204
- }
205
- this._sourceHeight = value;
206
- this._markAsDirty();
207
- },
208
- enumerable: false,
209
- configurable: true
210
- });
211
- Object.defineProperty(Image.prototype, "imageWidth", {
212
- /**
213
- * Gets the image width
214
- */
215
- get: function () {
216
- return this._imageWidth;
217
- },
218
- enumerable: false,
219
- configurable: true
220
- });
221
- Object.defineProperty(Image.prototype, "imageHeight", {
222
- /**
223
- * Gets the image height
224
- */
225
- get: function () {
226
- return this._imageHeight;
227
- },
228
- enumerable: false,
229
- configurable: true
230
- });
231
- Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
232
- /**
233
- * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
234
- */
235
- get: function () {
236
- return this._populateNinePatchSlicesFromImage;
237
- },
238
- set: function (value) {
239
- if (this._populateNinePatchSlicesFromImage === value) {
240
- return;
241
- }
242
- this._populateNinePatchSlicesFromImage = value;
243
- if (this._populateNinePatchSlicesFromImage && this._loaded) {
244
- this._extractNinePatchSliceDataFromImage();
245
- }
246
- },
247
- enumerable: false,
248
- configurable: true
249
- });
250
- Object.defineProperty(Image.prototype, "isSVG", {
251
- /** Indicates if the format of the image is SVG */
252
- get: function () {
253
- return this._isSVG;
254
- },
255
- enumerable: false,
256
- configurable: true
257
- });
258
- Object.defineProperty(Image.prototype, "svgAttributesComputationCompleted", {
259
- /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
260
- get: function () {
261
- return this._svgAttributesComputationCompleted;
262
- },
263
- enumerable: false,
264
- configurable: true
265
- });
266
- Object.defineProperty(Image.prototype, "autoScale", {
267
- /**
268
- * Gets or sets a boolean indicating if the image can force its container to adapt its size
269
- * @see https://doc.babylonjs.com/how_to/gui#image
270
- */
271
- get: function () {
272
- return this._autoScale;
273
- },
274
- set: function (value) {
275
- if (this._autoScale === value) {
276
- return;
277
- }
278
- this._autoScale = value;
279
- if (value && this._loaded) {
280
- this.synchronizeSizeWithContent();
281
- }
282
- },
283
- enumerable: false,
284
- configurable: true
285
- });
286
- Object.defineProperty(Image.prototype, "stretch", {
287
- /** Gets or sets the stretching mode used by the image */
288
- get: function () {
289
- return this._stretch;
290
- },
291
- set: function (value) {
292
- if (this._stretch === value) {
293
- return;
294
- }
295
- this._stretch = value;
296
- this._markAsDirty();
297
- },
298
- enumerable: false,
299
- configurable: true
300
- });
301
230
  /**
302
231
  * @param n
303
232
  * @param preserveProperties
304
233
  * @hidden
305
234
  */
306
- Image.prototype._rotate90 = function (n, preserveProperties) {
307
- var _a, _b;
308
- if (preserveProperties === void 0) { preserveProperties = false; }
309
- var width = this._domImage.width;
310
- var height = this._domImage.height;
235
+ _rotate90(n, preserveProperties = false) {
236
+ const width = this._domImage.width;
237
+ const height = this._domImage.height;
311
238
  // Should abstract platform instead of using LastCreatedEngine
312
- var engine = ((_b = (_a = this._host) === null || _a === void 0 ? void 0 : _a.getScene()) === null || _b === void 0 ? void 0 : _b.getEngine()) || EngineStore.LastCreatedEngine;
239
+ const engine = this._host?.getScene()?.getEngine() || EngineStore.LastCreatedEngine;
313
240
  if (!engine) {
314
241
  throw new Error("Invalid engine. Unable to create a canvas.");
315
242
  }
316
- var canvas = engine.createCanvas(height, width);
317
- var context = canvas.getContext("2d");
243
+ const canvas = engine.createCanvas(height, width);
244
+ const context = canvas.getContext("2d");
318
245
  context.translate(canvas.width / 2, canvas.height / 2);
319
246
  context.rotate((n * Math.PI) / 2);
320
247
  context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);
321
- var dataUrl = canvas.toDataURL("image/jpg");
322
- var rotatedImage = new Image(this.name + "rotated", dataUrl);
248
+ const dataUrl = canvas.toDataURL("image/jpg");
249
+ const rotatedImage = new Image(this.name + "rotated", dataUrl);
323
250
  if (preserveProperties) {
324
251
  rotatedImage._stretch = this._stretch;
325
252
  rotatedImage._autoScale = this._autoScale;
@@ -330,9 +257,8 @@ var Image = /** @class */ (function (_super) {
330
257
  this._handleRotationForSVGImage(this, rotatedImage, n);
331
258
  this._imageDataCache.data = null;
332
259
  return rotatedImage;
333
- };
334
- Image.prototype._handleRotationForSVGImage = function (srcImage, dstImage, n) {
335
- var _this = this;
260
+ }
261
+ _handleRotationForSVGImage(srcImage, dstImage, n) {
336
262
  if (!srcImage._isSVG) {
337
263
  return;
338
264
  }
@@ -341,23 +267,22 @@ var Image = /** @class */ (function (_super) {
341
267
  this._markAsDirty();
342
268
  }
343
269
  else {
344
- srcImage.onSVGAttributesComputedObservable.addOnce(function () {
345
- _this._rotate90SourceProperties(srcImage, dstImage, n);
346
- _this._markAsDirty();
270
+ srcImage.onSVGAttributesComputedObservable.addOnce(() => {
271
+ this._rotate90SourceProperties(srcImage, dstImage, n);
272
+ this._markAsDirty();
347
273
  });
348
274
  }
349
- };
350
- Image.prototype._rotate90SourceProperties = function (srcImage, dstImage, n) {
351
- var _a, _b;
352
- var srcLeft = srcImage.sourceLeft, srcTop = srcImage.sourceTop, srcWidth = srcImage.domImage.width, srcHeight = srcImage.domImage.height;
353
- var dstLeft = srcLeft, dstTop = srcTop, dstWidth = srcImage.sourceWidth, dstHeight = srcImage.sourceHeight;
275
+ }
276
+ _rotate90SourceProperties(srcImage, dstImage, n) {
277
+ let srcLeft = srcImage.sourceLeft, srcTop = srcImage.sourceTop, srcWidth = srcImage.domImage.width, srcHeight = srcImage.domImage.height;
278
+ let dstLeft = srcLeft, dstTop = srcTop, dstWidth = srcImage.sourceWidth, dstHeight = srcImage.sourceHeight;
354
279
  if (n != 0) {
355
- var mult = n < 0 ? -1 : 1;
280
+ const mult = n < 0 ? -1 : 1;
356
281
  n = n % 4;
357
- for (var i = 0; i < Math.abs(n); ++i) {
282
+ for (let i = 0; i < Math.abs(n); ++i) {
358
283
  dstLeft = -(srcTop - srcHeight / 2) * mult + srcHeight / 2;
359
284
  dstTop = (srcLeft - srcWidth / 2) * mult + srcWidth / 2;
360
- _a = [dstHeight, dstWidth], dstWidth = _a[0], dstHeight = _a[1];
285
+ [dstWidth, dstHeight] = [dstHeight, dstWidth];
361
286
  if (n < 0) {
362
287
  dstTop -= dstHeight;
363
288
  }
@@ -366,34 +291,33 @@ var Image = /** @class */ (function (_super) {
366
291
  }
367
292
  srcLeft = dstLeft;
368
293
  srcTop = dstTop;
369
- _b = [srcHeight, srcWidth], srcWidth = _b[0], srcHeight = _b[1];
294
+ [srcWidth, srcHeight] = [srcHeight, srcWidth];
370
295
  }
371
296
  }
372
297
  dstImage.sourceLeft = dstLeft;
373
298
  dstImage.sourceTop = dstTop;
374
299
  dstImage.sourceWidth = dstWidth;
375
300
  dstImage.sourceHeight = dstHeight;
376
- };
377
- Image.prototype._extractNinePatchSliceDataFromImage = function () {
378
- var _a, _b;
379
- var width = this._domImage.width;
380
- var height = this._domImage.height;
301
+ }
302
+ _extractNinePatchSliceDataFromImage() {
303
+ const width = this._domImage.width;
304
+ const height = this._domImage.height;
381
305
  if (!this._workingCanvas) {
382
- var engine = ((_b = (_a = this._host) === null || _a === void 0 ? void 0 : _a.getScene()) === null || _b === void 0 ? void 0 : _b.getEngine()) || EngineStore.LastCreatedEngine;
306
+ const engine = this._host?.getScene()?.getEngine() || EngineStore.LastCreatedEngine;
383
307
  if (!engine) {
384
308
  throw new Error("Invalid engine. Unable to create a canvas.");
385
309
  }
386
310
  this._workingCanvas = engine.createCanvas(width, height);
387
311
  }
388
- var canvas = this._workingCanvas;
389
- var context = canvas.getContext("2d");
312
+ const canvas = this._workingCanvas;
313
+ const context = canvas.getContext("2d");
390
314
  context.drawImage(this._domImage, 0, 0, width, height);
391
- var imageData = context.getImageData(0, 0, width, height);
315
+ const imageData = context.getImageData(0, 0, width, height);
392
316
  // Left and right
393
317
  this._sliceLeft = -1;
394
318
  this._sliceRight = -1;
395
- for (var x = 0; x < width; x++) {
396
- var alpha = imageData.data[x * 4 + 3];
319
+ for (let x = 0; x < width; x++) {
320
+ const alpha = imageData.data[x * 4 + 3];
397
321
  if (alpha > 127 && this._sliceLeft === -1) {
398
322
  this._sliceLeft = x;
399
323
  continue;
@@ -406,8 +330,8 @@ var Image = /** @class */ (function (_super) {
406
330
  // top and bottom
407
331
  this._sliceTop = -1;
408
332
  this._sliceBottom = -1;
409
- for (var y = 0; y < height; y++) {
410
- var alpha = imageData.data[y * width * 4 + 3];
333
+ for (let y = 0; y < height; y++) {
334
+ const alpha = imageData.data[y * width * 4 + 3];
411
335
  if (alpha > 127 && this._sliceTop === -1) {
412
336
  this._sliceTop = y;
413
337
  continue;
@@ -417,32 +341,27 @@ var Image = /** @class */ (function (_super) {
417
341
  break;
418
342
  }
419
343
  }
420
- };
421
- Object.defineProperty(Image.prototype, "domImage", {
422
- get: function () {
423
- return this._domImage;
424
- },
425
- /**
426
- * Gets or sets the internal DOM image used to render the control
427
- */
428
- set: function (value) {
429
- var _this = this;
430
- this._domImage = value;
431
- this._loaded = false;
432
- this._imageDataCache.data = null;
433
- if (this._domImage.width) {
344
+ }
345
+ /**
346
+ * Gets or sets the internal DOM image used to render the control
347
+ */
348
+ set domImage(value) {
349
+ this._domImage = value;
350
+ this._loaded = false;
351
+ this._imageDataCache.data = null;
352
+ if (this._domImage.width) {
353
+ this._onImageLoaded();
354
+ }
355
+ else {
356
+ this._domImage.onload = () => {
434
357
  this._onImageLoaded();
435
- }
436
- else {
437
- this._domImage.onload = function () {
438
- _this._onImageLoaded();
439
- };
440
- }
441
- },
442
- enumerable: false,
443
- configurable: true
444
- });
445
- Image.prototype._onImageLoaded = function () {
358
+ };
359
+ }
360
+ }
361
+ get domImage() {
362
+ return this._domImage;
363
+ }
364
+ _onImageLoaded() {
446
365
  this._imageDataCache.data = null;
447
366
  this._imageWidth = this._domImage.width;
448
367
  this._imageHeight = this._domImage.height;
@@ -455,123 +374,116 @@ var Image = /** @class */ (function (_super) {
455
374
  }
456
375
  this.onImageLoadedObservable.notifyObservers(this);
457
376
  this._markAsDirty();
458
- };
459
- Object.defineProperty(Image.prototype, "source", {
460
- /**
461
- * Gets the image source url
462
- */
463
- get: function () {
464
- return this._source;
465
- },
466
- /**
467
- * Gets or sets image source url
468
- */
469
- set: function (value) {
470
- var _this = this;
471
- var _a, _b;
472
- if (this._source === value) {
473
- return;
474
- }
475
- this._loaded = false;
476
- this._source = value;
477
- this._imageDataCache.data = null;
478
- if (value) {
479
- value = this._svgCheck(value);
480
- }
481
- // Should abstract platform instead of using LastCreatedEngine
482
- var engine = ((_b = (_a = this._host) === null || _a === void 0 ? void 0 : _a.getScene()) === null || _b === void 0 ? void 0 : _b.getEngine()) || EngineStore.LastCreatedEngine;
483
- if (!engine) {
484
- throw new Error("Invalid engine. Unable to create a canvas.");
485
- }
486
- this._domImage = engine.createCanvasImage();
487
- this._domImage.onload = function () {
488
- _this._onImageLoaded();
489
- };
490
- if (value) {
491
- Tools.SetCorsBehavior(value, this._domImage);
492
- Tools.SetReferrerPolicyBehavior(this.referrerPolicy, this._domImage);
493
- this._domImage.src = value;
494
- }
495
- },
496
- enumerable: false,
497
- configurable: true
498
- });
377
+ }
378
+ /**
379
+ * Gets the image source url
380
+ */
381
+ get source() {
382
+ return this._source;
383
+ }
384
+ /**
385
+ * Gets or sets image source url
386
+ */
387
+ set source(value) {
388
+ if (this._source === value) {
389
+ return;
390
+ }
391
+ this._loaded = false;
392
+ this._source = value;
393
+ this._imageDataCache.data = null;
394
+ if (value) {
395
+ value = this._svgCheck(value);
396
+ }
397
+ // Should abstract platform instead of using LastCreatedEngine
398
+ const engine = this._host?.getScene()?.getEngine() || EngineStore.LastCreatedEngine;
399
+ if (!engine) {
400
+ throw new Error("Invalid engine. Unable to create a canvas.");
401
+ }
402
+ this._domImage = engine.createCanvasImage();
403
+ this._domImage.onload = () => {
404
+ this._onImageLoaded();
405
+ };
406
+ if (value) {
407
+ Tools.SetCorsBehavior(value, this._domImage);
408
+ Tools.SetReferrerPolicyBehavior(this.referrerPolicy, this._domImage);
409
+ this._domImage.src = value;
410
+ }
411
+ }
499
412
  /**
500
413
  * Checks for svg document with icon id present
501
414
  * @param value
502
415
  */
503
- Image.prototype._svgCheck = function (value) {
504
- var _this = this;
416
+ _svgCheck(value) {
505
417
  if (window.SVGSVGElement && value.search(/.svg#/gi) !== -1 && value.indexOf("#") === value.lastIndexOf("#")) {
506
418
  this._isSVG = true;
507
- var svgsrc_1 = value.split("#")[0];
508
- var elemid_1 = value.split("#")[1];
419
+ const svgsrc = value.split("#")[0];
420
+ const elemid = value.split("#")[1];
509
421
  // check if object alr exist in document
510
- var svgExist_1 = document.body.querySelector('object[data="' + svgsrc_1 + '"]');
511
- if (svgExist_1) {
512
- var svgDoc = svgExist_1.contentDocument;
422
+ const svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
423
+ if (svgExist) {
424
+ const svgDoc = svgExist.contentDocument;
513
425
  // get viewbox width and height, get svg document width and height in px
514
426
  if (svgDoc && svgDoc.documentElement) {
515
- var vb = svgDoc.documentElement.getAttribute("viewBox");
516
- var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
517
- var docheight = Number(svgDoc.documentElement.getAttribute("height"));
518
- var elem = svgDoc.getElementById(elemid_1);
427
+ const vb = svgDoc.documentElement.getAttribute("viewBox");
428
+ const docwidth = Number(svgDoc.documentElement.getAttribute("width"));
429
+ const docheight = Number(svgDoc.documentElement.getAttribute("height"));
430
+ const elem = svgDoc.getElementById(elemid);
519
431
  if (elem && vb && docwidth && docheight) {
520
- this._getSVGAttribs(svgExist_1, elemid_1);
432
+ this._getSVGAttribs(svgExist, elemid);
521
433
  return value;
522
434
  }
523
435
  }
524
436
  // wait for object to load
525
- svgExist_1.addEventListener("load", function () {
526
- _this._getSVGAttribs(svgExist_1, elemid_1);
437
+ svgExist.addEventListener("load", () => {
438
+ this._getSVGAttribs(svgExist, elemid);
527
439
  });
528
440
  }
529
441
  else {
530
442
  // create document object
531
- var svgImage = document.createElement("object");
532
- svgImage.data = svgsrc_1;
443
+ const svgImage = document.createElement("object");
444
+ svgImage.data = svgsrc;
533
445
  svgImage.type = "image/svg+xml";
534
446
  svgImage.width = "0%";
535
447
  svgImage.height = "0%";
536
448
  document.body.appendChild(svgImage);
537
449
  // when the object has loaded, get the element attribs
538
- svgImage.onload = function () {
539
- var svgobj = document.body.querySelector('object[data="' + svgsrc_1 + '"]');
450
+ svgImage.onload = () => {
451
+ const svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
540
452
  if (svgobj) {
541
- _this._getSVGAttribs(svgobj, elemid_1);
453
+ this._getSVGAttribs(svgobj, elemid);
542
454
  }
543
455
  };
544
456
  }
545
- return svgsrc_1;
457
+ return svgsrc;
546
458
  }
547
459
  else {
548
460
  return value;
549
461
  }
550
- };
462
+ }
551
463
  /**
552
464
  * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
553
465
  * given external svg file and icon id
554
466
  * @param svgsrc
555
467
  * @param elemid
556
468
  */
557
- Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
558
- var svgDoc = svgsrc.contentDocument;
469
+ _getSVGAttribs(svgsrc, elemid) {
470
+ const svgDoc = svgsrc.contentDocument;
559
471
  // get viewbox width and height, get svg document width and height in px
560
472
  if (svgDoc && svgDoc.documentElement) {
561
- var vb = svgDoc.documentElement.getAttribute("viewBox");
562
- var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
563
- var docheight = Number(svgDoc.documentElement.getAttribute("height"));
473
+ const vb = svgDoc.documentElement.getAttribute("viewBox");
474
+ const docwidth = Number(svgDoc.documentElement.getAttribute("width"));
475
+ const docheight = Number(svgDoc.documentElement.getAttribute("height"));
564
476
  // get element bbox and matrix transform
565
- var elem = svgDoc.getElementById(elemid);
477
+ const elem = svgDoc.getElementById(elemid);
566
478
  if (vb && docwidth && docheight && elem) {
567
- var vb_width = Number(vb.split(" ")[2]);
568
- var vb_height = Number(vb.split(" ")[3]);
569
- var elem_bbox = elem.getBBox();
570
- var elem_matrix_a = 1;
571
- var elem_matrix_d = 1;
572
- var elem_matrix_e = 0;
573
- var elem_matrix_f = 0;
574
- var mainMatrix = elem.transform.baseVal.consolidate().matrix;
479
+ const vb_width = Number(vb.split(" ")[2]);
480
+ const vb_height = Number(vb.split(" ")[3]);
481
+ const elem_bbox = elem.getBBox();
482
+ let elem_matrix_a = 1;
483
+ let elem_matrix_d = 1;
484
+ let elem_matrix_e = 0;
485
+ let elem_matrix_f = 0;
486
+ const mainMatrix = elem.transform.baseVal.consolidate().matrix;
575
487
  if (elem.transform && elem.transform.baseVal.consolidate()) {
576
488
  elem_matrix_a = mainMatrix.a;
577
489
  elem_matrix_d = mainMatrix.d;
@@ -587,101 +499,89 @@ var Image = /** @class */ (function (_super) {
587
499
  this.onSVGAttributesComputedObservable.notifyObservers(this);
588
500
  }
589
501
  }
590
- };
591
- Object.defineProperty(Image.prototype, "cellWidth", {
592
- /**
593
- * Gets or sets the cell width to use when animation sheet is enabled
594
- * @see https://doc.babylonjs.com/how_to/gui#image
595
- */
596
- get: function () {
597
- return this._cellWidth;
598
- },
599
- set: function (value) {
600
- if (this._cellWidth === value) {
601
- return;
602
- }
603
- this._cellWidth = value;
604
- this._markAsDirty();
605
- },
606
- enumerable: false,
607
- configurable: true
608
- });
609
- Object.defineProperty(Image.prototype, "cellHeight", {
610
- /**
611
- * Gets or sets the cell height to use when animation sheet is enabled
612
- * @see https://doc.babylonjs.com/how_to/gui#image
613
- */
614
- get: function () {
615
- return this._cellHeight;
616
- },
617
- set: function (value) {
618
- if (this._cellHeight === value) {
619
- return;
620
- }
621
- this._cellHeight = value;
622
- this._markAsDirty();
623
- },
624
- enumerable: false,
625
- configurable: true
626
- });
627
- Object.defineProperty(Image.prototype, "cellId", {
628
- /**
629
- * Gets or sets the cell id to use (this will turn on the animation sheet mode)
630
- * @see https://doc.babylonjs.com/how_to/gui#image
631
- */
632
- get: function () {
633
- return this._cellId;
634
- },
635
- set: function (value) {
636
- if (this._cellId === value) {
637
- return;
638
- }
639
- this._cellId = value;
640
- this._markAsDirty();
641
- },
642
- enumerable: false,
643
- configurable: true
644
- });
502
+ }
503
+ /**
504
+ * Gets or sets the cell width to use when animation sheet is enabled
505
+ * @see https://doc.babylonjs.com/how_to/gui#image
506
+ */
507
+ get cellWidth() {
508
+ return this._cellWidth;
509
+ }
510
+ set cellWidth(value) {
511
+ if (this._cellWidth === value) {
512
+ return;
513
+ }
514
+ this._cellWidth = value;
515
+ this._markAsDirty();
516
+ }
517
+ /**
518
+ * Gets or sets the cell height to use when animation sheet is enabled
519
+ * @see https://doc.babylonjs.com/how_to/gui#image
520
+ */
521
+ get cellHeight() {
522
+ return this._cellHeight;
523
+ }
524
+ set cellHeight(value) {
525
+ if (this._cellHeight === value) {
526
+ return;
527
+ }
528
+ this._cellHeight = value;
529
+ this._markAsDirty();
530
+ }
531
+ /**
532
+ * Gets or sets the cell id to use (this will turn on the animation sheet mode)
533
+ * @see https://doc.babylonjs.com/how_to/gui#image
534
+ */
535
+ get cellId() {
536
+ return this._cellId;
537
+ }
538
+ set cellId(value) {
539
+ if (this._cellId === value) {
540
+ return;
541
+ }
542
+ this._cellId = value;
543
+ this._markAsDirty();
544
+ }
645
545
  /**
646
546
  * Tests if a given coordinates belong to the current control
647
547
  * @param x defines x coordinate to test
648
548
  * @param y defines y coordinate to test
649
549
  * @returns true if the coordinates are inside the control
650
550
  */
651
- Image.prototype.contains = function (x, y) {
652
- if (!_super.prototype.contains.call(this, x, y)) {
551
+ contains(x, y) {
552
+ if (!super.contains(x, y)) {
653
553
  return false;
654
554
  }
655
555
  if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
656
556
  return true;
657
557
  }
658
- var width = this._currentMeasure.width | 0;
659
- var height = this._currentMeasure.height | 0;
660
- var key = width + "_" + height;
661
- var imageData = this._imageDataCache.data;
558
+ const width = this._currentMeasure.width | 0;
559
+ const height = this._currentMeasure.height | 0;
560
+ const key = width + "_" + height;
561
+ let imageData = this._imageDataCache.data;
662
562
  if (!imageData || this._imageDataCache.key !== key) {
663
- var canvas = this._workingCanvas;
664
- var context_1 = canvas.getContext("2d");
665
- this._imageDataCache.data = imageData = context_1.getImageData(0, 0, width, height).data;
563
+ const canvas = this._workingCanvas;
564
+ const context = canvas.getContext("2d");
565
+ this._imageDataCache.data = imageData = context.getImageData(0, 0, width, height).data;
666
566
  this._imageDataCache.key = key;
667
567
  }
668
568
  x = (x - this._currentMeasure.left) | 0;
669
569
  y = (y - this._currentMeasure.top) | 0;
670
- var pickedPixel = imageData[(x + y * width) * 4 + 3];
570
+ const pickedPixel = imageData[(x + y * width) * 4 + 3];
671
571
  return pickedPixel > 0;
672
- };
673
- Image.prototype._getTypeName = function () {
572
+ }
573
+ _getTypeName() {
674
574
  return "Image";
675
- };
575
+ }
676
576
  /** Force the control to synchronize with its content */
677
- Image.prototype.synchronizeSizeWithContent = function () {
577
+ synchronizeSizeWithContent() {
678
578
  if (!this._loaded) {
679
579
  return;
680
580
  }
681
581
  this.width = this._domImage.width + "px";
682
582
  this.height = this._domImage.height + "px";
683
- };
684
- Image.prototype._processMeasures = function (parentMeasure, context) {
583
+ }
584
+ _processMeasures(parentMeasure, context) {
685
585
  if (this._loaded) {
686
586
  switch (this._stretch) {
687
587
  case Image.STRETCH_NONE:
@@ -704,36 +604,35 @@ var Image = /** @class */ (function (_super) {
704
604
  break;
705
605
  }
706
606
  }
707
- _super.prototype._processMeasures.call(this, parentMeasure, context);
708
- };
709
- Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
710
- var _a, _b;
607
+ super._processMeasures(parentMeasure, context);
608
+ }
609
+ _prepareWorkingCanvasForOpaqueDetection() {
711
610
  if (!this._detectPointerOnOpaqueOnly) {
712
611
  return;
713
612
  }
714
- var width = this._currentMeasure.width;
715
- var height = this._currentMeasure.height;
613
+ const width = this._currentMeasure.width;
614
+ const height = this._currentMeasure.height;
716
615
  if (!this._workingCanvas) {
717
- var engine = ((_b = (_a = this._host) === null || _a === void 0 ? void 0 : _a.getScene()) === null || _b === void 0 ? void 0 : _b.getEngine()) || EngineStore.LastCreatedEngine;
616
+ const engine = this._host?.getScene()?.getEngine() || EngineStore.LastCreatedEngine;
718
617
  if (!engine) {
719
618
  throw new Error("Invalid engine. Unable to create a canvas.");
720
619
  }
721
620
  this._workingCanvas = engine.createCanvas(width, height);
722
621
  }
723
- var canvas = this._workingCanvas;
724
- var context = canvas.getContext("2d");
622
+ const canvas = this._workingCanvas;
623
+ const context = canvas.getContext("2d");
725
624
  context.clearRect(0, 0, width, height);
726
- };
727
- Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
625
+ }
626
+ _drawImage(context, sx, sy, sw, sh, tx, ty, tw, th) {
728
627
  context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
729
628
  if (!this._detectPointerOnOpaqueOnly) {
730
629
  return;
731
630
  }
732
- var canvas = this._workingCanvas;
631
+ const canvas = this._workingCanvas;
733
632
  context = canvas.getContext("2d");
734
633
  context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
735
- };
736
- Image.prototype._draw = function (context) {
634
+ }
635
+ _draw(context) {
737
636
  context.save();
738
637
  if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
739
638
  context.shadowColor = this.shadowColor;
@@ -741,7 +640,7 @@ var Image = /** @class */ (function (_super) {
741
640
  context.shadowOffsetX = this.shadowOffsetX;
742
641
  context.shadowOffsetY = this.shadowOffsetY;
743
642
  }
744
- var x, y, width, height;
643
+ let x, y, width, height;
745
644
  if (this.cellId == -1) {
746
645
  x = this._sourceLeft;
747
646
  y = this._sourceTop;
@@ -749,9 +648,9 @@ var Image = /** @class */ (function (_super) {
749
648
  height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
750
649
  }
751
650
  else {
752
- var rowCount = this._domImage.naturalWidth / this.cellWidth;
753
- var column = (this.cellId / rowCount) >> 0;
754
- var row = this.cellId % rowCount;
651
+ const rowCount = this._domImage.naturalWidth / this.cellWidth;
652
+ const column = (this.cellId / rowCount) >> 0;
653
+ const row = this.cellId % rowCount;
755
654
  x = this.cellWidth * row;
756
655
  y = this.cellHeight * column;
757
656
  width = this.cellWidth;
@@ -768,11 +667,11 @@ var Image = /** @class */ (function (_super) {
768
667
  this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
769
668
  break;
770
669
  case Image.STRETCH_UNIFORM: {
771
- var hRatio = this._currentMeasure.width / width;
772
- var vRatio = this._currentMeasure.height / height;
773
- var ratio = Math.min(hRatio, vRatio);
774
- var centerX = (this._currentMeasure.width - width * ratio) / 2;
775
- var centerY = (this._currentMeasure.height - height * ratio) / 2;
670
+ const hRatio = this._currentMeasure.width / width;
671
+ const vRatio = this._currentMeasure.height / height;
672
+ const ratio = Math.min(hRatio, vRatio);
673
+ const centerX = (this._currentMeasure.width - width * ratio) / 2;
674
+ const centerY = (this._currentMeasure.height - height * ratio) / 2;
776
675
  this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
777
676
  break;
778
677
  }
@@ -785,20 +684,20 @@ var Image = /** @class */ (function (_super) {
785
684
  }
786
685
  }
787
686
  context.restore();
788
- };
789
- Image.prototype._renderNinePatch = function (context) {
790
- var leftWidth = this._sliceLeft;
791
- var topHeight = this._sliceTop;
792
- var bottomHeight = this._imageHeight - this._sliceBottom;
793
- var rightWidth = this._imageWidth - this._sliceRight;
794
- var centerWidth = this._sliceRight - this._sliceLeft;
795
- var centerHeight = this._sliceBottom - this._sliceTop;
796
- var targetCenterWidth = this._currentMeasure.width - rightWidth - leftWidth + 2;
797
- var targetCenterHeight = this._currentMeasure.height - bottomHeight - topHeight + 2;
798
- var centerLeftOffset = this._currentMeasure.left + leftWidth - 1;
799
- var centerTopOffset = this._currentMeasure.top + topHeight - 1;
800
- var rightOffset = this._currentMeasure.left + this._currentMeasure.width - rightWidth;
801
- var bottomOffset = this._currentMeasure.top + this._currentMeasure.height - bottomHeight;
687
+ }
688
+ _renderNinePatch(context) {
689
+ const leftWidth = this._sliceLeft;
690
+ const topHeight = this._sliceTop;
691
+ const bottomHeight = this._imageHeight - this._sliceBottom;
692
+ const rightWidth = this._imageWidth - this._sliceRight;
693
+ const centerWidth = this._sliceRight - this._sliceLeft;
694
+ const centerHeight = this._sliceBottom - this._sliceTop;
695
+ const targetCenterWidth = this._currentMeasure.width - rightWidth - leftWidth + 2;
696
+ const targetCenterHeight = this._currentMeasure.height - bottomHeight - topHeight + 2;
697
+ const centerLeftOffset = this._currentMeasure.left + leftWidth - 1;
698
+ const centerTopOffset = this._currentMeasure.top + topHeight - 1;
699
+ const rightOffset = this._currentMeasure.left + this._currentMeasure.width - rightWidth;
700
+ const bottomOffset = this._currentMeasure.top + this._currentMeasure.height - bottomHeight;
802
701
  //Top Left
803
702
  this._drawImage(context, 0, 0, leftWidth, topHeight, this._currentMeasure.left, this._currentMeasure.top, leftWidth, topHeight);
804
703
  //Top
@@ -825,73 +724,71 @@ var Image = /** @class */ (function (_super) {
825
724
  //Bottom Right
826
725
  context.clearRect(rightOffset, bottomOffset, rightWidth, bottomHeight);
827
726
  this._drawImage(context, this._sliceRight, this._sliceBottom, rightWidth, bottomHeight, rightOffset, bottomOffset, rightWidth, bottomHeight);
828
- };
829
- Image.prototype.dispose = function () {
830
- _super.prototype.dispose.call(this);
727
+ }
728
+ dispose() {
729
+ super.dispose();
831
730
  this.onImageLoadedObservable.clear();
832
731
  this.onSVGAttributesComputedObservable.clear();
833
- };
834
- // Static
835
- /** STRETCH_NONE */
836
- Image.STRETCH_NONE = 0;
837
- /** STRETCH_FILL */
838
- Image.STRETCH_FILL = 1;
839
- /** STRETCH_UNIFORM */
840
- Image.STRETCH_UNIFORM = 2;
841
- /** STRETCH_EXTEND */
842
- Image.STRETCH_EXTEND = 3;
843
- /** NINE_PATCH */
844
- Image.STRETCH_NINE_PATCH = 4;
845
- __decorate([
846
- serialize()
847
- ], Image.prototype, "detectPointerOnOpaqueOnly", null);
848
- __decorate([
849
- serialize()
850
- ], Image.prototype, "sliceLeft", null);
851
- __decorate([
852
- serialize()
853
- ], Image.prototype, "sliceRight", null);
854
- __decorate([
855
- serialize()
856
- ], Image.prototype, "sliceTop", null);
857
- __decorate([
858
- serialize()
859
- ], Image.prototype, "sliceBottom", null);
860
- __decorate([
861
- serialize()
862
- ], Image.prototype, "sourceLeft", null);
863
- __decorate([
864
- serialize()
865
- ], Image.prototype, "sourceTop", null);
866
- __decorate([
867
- serialize()
868
- ], Image.prototype, "sourceWidth", null);
869
- __decorate([
870
- serialize()
871
- ], Image.prototype, "sourceHeight", null);
872
- __decorate([
873
- serialize()
874
- ], Image.prototype, "populateNinePatchSlicesFromImage", null);
875
- __decorate([
876
- serialize()
877
- ], Image.prototype, "autoScale", null);
878
- __decorate([
879
- serialize()
880
- ], Image.prototype, "stretch", null);
881
- __decorate([
882
- serialize()
883
- ], Image.prototype, "source", null);
884
- __decorate([
885
- serialize()
886
- ], Image.prototype, "cellWidth", null);
887
- __decorate([
888
- serialize()
889
- ], Image.prototype, "cellHeight", null);
890
- __decorate([
891
- serialize()
892
- ], Image.prototype, "cellId", null);
893
- return Image;
894
- }(Control));
895
- export { Image };
732
+ }
733
+ }
734
+ // Static
735
+ /** STRETCH_NONE */
736
+ Image.STRETCH_NONE = 0;
737
+ /** STRETCH_FILL */
738
+ Image.STRETCH_FILL = 1;
739
+ /** STRETCH_UNIFORM */
740
+ Image.STRETCH_UNIFORM = 2;
741
+ /** STRETCH_EXTEND */
742
+ Image.STRETCH_EXTEND = 3;
743
+ /** NINE_PATCH */
744
+ Image.STRETCH_NINE_PATCH = 4;
745
+ __decorate([
746
+ serialize()
747
+ ], Image.prototype, "detectPointerOnOpaqueOnly", null);
748
+ __decorate([
749
+ serialize()
750
+ ], Image.prototype, "sliceLeft", null);
751
+ __decorate([
752
+ serialize()
753
+ ], Image.prototype, "sliceRight", null);
754
+ __decorate([
755
+ serialize()
756
+ ], Image.prototype, "sliceTop", null);
757
+ __decorate([
758
+ serialize()
759
+ ], Image.prototype, "sliceBottom", null);
760
+ __decorate([
761
+ serialize()
762
+ ], Image.prototype, "sourceLeft", null);
763
+ __decorate([
764
+ serialize()
765
+ ], Image.prototype, "sourceTop", null);
766
+ __decorate([
767
+ serialize()
768
+ ], Image.prototype, "sourceWidth", null);
769
+ __decorate([
770
+ serialize()
771
+ ], Image.prototype, "sourceHeight", null);
772
+ __decorate([
773
+ serialize()
774
+ ], Image.prototype, "populateNinePatchSlicesFromImage", null);
775
+ __decorate([
776
+ serialize()
777
+ ], Image.prototype, "autoScale", null);
778
+ __decorate([
779
+ serialize()
780
+ ], Image.prototype, "stretch", null);
781
+ __decorate([
782
+ serialize()
783
+ ], Image.prototype, "source", null);
784
+ __decorate([
785
+ serialize()
786
+ ], Image.prototype, "cellWidth", null);
787
+ __decorate([
788
+ serialize()
789
+ ], Image.prototype, "cellHeight", null);
790
+ __decorate([
791
+ serialize()
792
+ ], Image.prototype, "cellId", null);
896
793
  RegisterClass("BABYLON.GUI.Image", Image);
897
794
  //# sourceMappingURL=image.js.map