@babylonjs/gui 5.0.0-alpha.61 → 5.0.0-alpha.65

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 (42) hide show
  1. package/2D/advancedDynamicTexture.d.ts +4 -1
  2. package/2D/advancedDynamicTexture.js +49 -5
  3. package/2D/advancedDynamicTexture.js.map +1 -1
  4. package/2D/controls/container.js +2 -2
  5. package/2D/controls/container.js.map +1 -1
  6. package/2D/controls/control.d.ts +23 -0
  7. package/2D/controls/control.js +132 -37
  8. package/2D/controls/control.js.map +1 -1
  9. package/2D/controls/grid.d.ts +5 -3
  10. package/2D/controls/grid.js +48 -21
  11. package/2D/controls/grid.js.map +1 -1
  12. package/2D/controls/sliders/imageBasedSlider.js.map +1 -1
  13. package/2D/controls/stackPanel.d.ts +7 -1
  14. package/2D/controls/stackPanel.js +29 -7
  15. package/2D/controls/stackPanel.js.map +1 -1
  16. package/2D/controls/textBlock.js +4 -4
  17. package/2D/controls/textBlock.js.map +1 -1
  18. package/2D/math2D.d.ts +5 -0
  19. package/2D/math2D.js +12 -0
  20. package/2D/math2D.js.map +1 -1
  21. package/2D/valueAndUnit.d.ts +21 -6
  22. package/2D/valueAndUnit.js +57 -13
  23. package/2D/valueAndUnit.js.map +1 -1
  24. package/3D/controls/button3D.js +8 -1
  25. package/3D/controls/button3D.js.map +1 -1
  26. package/3D/controls/control3D.d.ts +2 -0
  27. package/3D/controls/control3D.js +3 -0
  28. package/3D/controls/control3D.js.map +1 -1
  29. package/3D/controls/holographicButton.js +9 -8
  30. package/3D/controls/holographicButton.js.map +1 -1
  31. package/3D/controls/holographicSlate.js +11 -6
  32. package/3D/controls/holographicSlate.js.map +1 -1
  33. package/3D/controls/nearMenu.js +1 -1
  34. package/3D/controls/nearMenu.js.map +1 -1
  35. package/3D/controls/touchHolographicButton.js +12 -12
  36. package/3D/controls/touchHolographicButton.js.map +1 -1
  37. package/3D/controls/touchHolographicMenu.js +13 -11
  38. package/3D/controls/touchHolographicMenu.js.map +1 -1
  39. package/3D/gui3DManager.d.ts +10 -0
  40. package/3D/gui3DManager.js +43 -0
  41. package/3D/gui3DManager.js.map +1 -1
  42. package/package.json +2 -2
@@ -295,13 +295,13 @@ var TextBlock = /** @class */ (function (_super) {
295
295
  }
296
296
  if (this._resizeToFit) {
297
297
  if (this._textWrapping === TextWrapping.Clip) {
298
- var newWidth = (this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth) | 0;
298
+ var newWidth = (this._paddingLeftInPixels + this._paddingRightInPixels + maxLineWidth) | 0;
299
299
  if (newWidth !== this._width.internalValue) {
300
300
  this._width.updateInPlace(newWidth, ValueAndUnit.UNITMODE_PIXEL);
301
301
  this._rebuildLayout = true;
302
302
  }
303
303
  }
304
- var newHeight = (this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length) | 0;
304
+ var newHeight = (this._paddingTopInPixels + this._paddingBottomInPixels + this._fontOffset.height * this._lines.length) | 0;
305
305
  if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
306
306
  var lineSpacing = 0;
307
307
  if (this._lineSpacing.isPixel) {
@@ -500,8 +500,8 @@ var TextBlock = /** @class */ (function (_super) {
500
500
  if (!this._fontOffset) {
501
501
  this._fontOffset = Control._GetFontOffset(context_1.font);
502
502
  }
503
- var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
504
- var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
503
+ var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this._paddingLeftInPixels - this._paddingRightInPixels, context_1);
504
+ var newHeight = this._paddingTopInPixels + this._paddingBottomInPixels + this._fontOffset.height * lines.length;
505
505
  if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
506
506
  var lineSpacing = 0;
507
507
  if (this._lineSpacing.isPixel) {
@@ -1 +1 @@
1
- {"version":3,"file":"textBlock.js","s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} from \"../measure\";\r\nimport { ValueAndUnit } from \"../valueAndUnit\";\r\nimport { Control } from \"./control\";\r\nimport { RegisterClass } from \"@babylonjs/core/Misc/typeStore\";\r\nimport { Nullable } from \"@babylonjs/core/types\";\r\nimport { serialize } from '@babylonjs/core/Misc/decorators';\r\nimport { ICanvasRenderingContext } from '@babylonjs/core/Engines/ICanvas';\r\nimport { Engine } from '@babylonjs/core/Engines/engine';\r\n\r\n/**\r\n * Enum that determines the text-wrapping mode to use.\r\n */\r\nexport enum TextWrapping {\r\n /**\r\n * Clip the text when it's larger than Control.width; this is the default mode.\r\n */\r\n Clip = 0,\r\n\r\n /**\r\n * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.\r\n */\r\n WordWrap = 1,\r\n\r\n /**\r\n * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.\r\n */\r\n Ellipsis,\r\n}\r\n\r\n/**\r\n * Class used to create text block control\r\n */\r\nexport class TextBlock extends Control {\r\n private _text = \"\";\r\n private _textWrapping = TextWrapping.Clip;\r\n private _textHorizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;\r\n private _textVerticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;\r\n\r\n private _lines: any[];\r\n private _resizeToFit: boolean = false;\r\n private _lineSpacing: ValueAndUnit = new ValueAndUnit(0);\r\n private _outlineWidth: number = 0;\r\n private _outlineColor: string = \"white\";\r\n private _underline: boolean = false;\r\n private _lineThrough: boolean = false;\r\n /**\r\n * An event triggered after the text is changed\r\n */\r\n public onTextChangedObservable = new Observable<TextBlock>();\r\n\r\n /**\r\n * An event triggered after the text was broken up into lines\r\n */\r\n public onLinesReadyObservable = new Observable<TextBlock>();\r\n\r\n /**\r\n * Function used to split a string into words. By default, a string is split at each space character found\r\n */\r\n public wordSplittingFunction: Nullable<(line: string) => string[]>;\r\n\r\n /**\r\n * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)\r\n */\r\n public get lines(): any[] {\r\n return this._lines;\r\n }\r\n\r\n /**\r\n * Gets or sets an boolean indicating that the TextBlock will be resized to fit container\r\n */\r\n @serialize()\r\n public get resizeToFit(): boolean {\r\n return this._resizeToFit;\r\n }\r\n\r\n /**\r\n * Gets or sets an boolean indicating that the TextBlock will be resized to fit container\r\n */\r\n public set resizeToFit(value: boolean) {\r\n if (this._resizeToFit === value) {\r\n return;\r\n }\r\n this._resizeToFit = value;\r\n\r\n if (this._resizeToFit) {\r\n this._width.ignoreAdaptiveScaling = true;\r\n this._height.ignoreAdaptiveScaling = true;\r\n }\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating if text must be wrapped\r\n */\r\n @serialize()\r\n public get textWrapping(): TextWrapping | boolean {\r\n return this._textWrapping;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating if text must be wrapped\r\n */\r\n public set textWrapping(value: TextWrapping | boolean) {\r\n if (this._textWrapping === value) {\r\n return;\r\n }\r\n this._textWrapping = +value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets text to display\r\n */\r\n @serialize()\r\n public get text(): string {\r\n return this._text;\r\n }\r\n\r\n /**\r\n * Gets or sets text to display\r\n */\r\n public set text(value: string) {\r\n if (this._text === value) {\r\n return;\r\n }\r\n this._text = value + \"\"; // Making sure it is a text\r\n this._markAsDirty();\r\n\r\n this.onTextChangedObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)\r\n */\r\n @serialize()\r\n public get textHorizontalAlignment(): number {\r\n return this._textHorizontalAlignment;\r\n }\r\n\r\n /**\r\n * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)\r\n */\r\n public set textHorizontalAlignment(value: number) {\r\n if (this._textHorizontalAlignment === value) {\r\n return;\r\n }\r\n\r\n this._textHorizontalAlignment = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)\r\n */\r\n @serialize()\r\n public get textVerticalAlignment(): number {\r\n return this._textVerticalAlignment;\r\n }\r\n\r\n /**\r\n * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)\r\n */\r\n public set textVerticalAlignment(value: number) {\r\n if (this._textVerticalAlignment === value) {\r\n return;\r\n }\r\n\r\n this._textVerticalAlignment = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets line spacing value\r\n */\r\n @serialize()\r\n public set lineSpacing(value: string | number) {\r\n if (this._lineSpacing.fromString(value)) {\r\n this._markAsDirty();\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets line spacing value\r\n */\r\n public get lineSpacing(): string | number {\r\n return this._lineSpacing.toString(this._host);\r\n }\r\n\r\n /**\r\n * Gets or sets outlineWidth of the text to display\r\n */\r\n @serialize()\r\n public get outlineWidth(): number {\r\n return this._outlineWidth;\r\n }\r\n\r\n /**\r\n * Gets or sets outlineWidth of the text to display\r\n */\r\n public set outlineWidth(value: number) {\r\n if (this._outlineWidth === value) {\r\n return;\r\n }\r\n this._outlineWidth = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating that text must have underline\r\n */\r\n @serialize()\r\n\r\n public get underline(): boolean {\r\n return this._underline;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating that text must have underline\r\n */\r\n public set underline(value: boolean) {\r\n if (this._underline === value) {\r\n return;\r\n }\r\n this._underline = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets an boolean indicating that text must be crossed out\r\n */\r\n @serialize()\r\n public get lineThrough(): boolean {\r\n return this._lineThrough;\r\n }\r\n\r\n /**\r\n * Gets or sets an boolean indicating that text must be crossed out\r\n */\r\n public set lineThrough(value: boolean) {\r\n if (this._lineThrough === value) {\r\n return;\r\n }\r\n this._lineThrough = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets outlineColor of the text to display\r\n */\r\n @serialize()\r\n public get outlineColor(): string {\r\n return this._outlineColor;\r\n }\r\n\r\n /**\r\n * Gets or sets outlineColor of the text to display\r\n */\r\n public set outlineColor(value: string) {\r\n if (this._outlineColor === value) {\r\n return;\r\n }\r\n this._outlineColor = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Creates a new TextBlock object\r\n * @param name defines the name of the control\r\n * @param text defines the text to display (emptry string by default)\r\n */\r\n constructor(\r\n /**\r\n * Defines the name of the control\r\n */\r\n public name?: string,\r\n text: string = \"\"\r\n ) {\r\n super(name);\r\n\r\n this.text = text;\r\n }\r\n\r\n protected _getTypeName(): string {\r\n return \"TextBlock\";\r\n }\r\n\r\n protected _processMeasures(parentMeasure: Measure, context: ICanvasRenderingContext): void {\r\n if (!this._fontOffset || this.isDirty) {\r\n this._fontOffset = Control._GetFontOffset(context.font);\r\n }\r\n super._processMeasures(parentMeasure, context);\r\n\r\n // Prepare lines\r\n this._lines = this._breakLines(this._currentMeasure.width, context);\r\n this.onLinesReadyObservable.notifyObservers(this);\r\n\r\n let maxLineWidth: number = 0;\r\n\r\n for (let i = 0; i < this._lines.length; i++) {\r\n const line = this._lines[i];\r\n\r\n if (line.width > maxLineWidth) {\r\n maxLineWidth = line.width;\r\n }\r\n }\r\n\r\n if (this._resizeToFit) {\r\n if (this._textWrapping === TextWrapping.Clip) {\r\n let newWidth = (this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth) | 0;\r\n if (newWidth !== this._width.internalValue) {\r\n this._width.updateInPlace(newWidth, ValueAndUnit.UNITMODE_PIXEL);\r\n this._rebuildLayout = true;\r\n }\r\n }\r\n let newHeight = (this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length) | 0;\r\n\r\n if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {\r\n let lineSpacing = 0;\r\n if (this._lineSpacing.isPixel) {\r\n lineSpacing = this._lineSpacing.getValue(this._host);\r\n } else {\r\n lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);\r\n }\r\n\r\n newHeight += (this._lines.length - 1) * lineSpacing;\r\n }\r\n\r\n if (newHeight !== this._height.internalValue) {\r\n this._height.updateInPlace(newHeight, ValueAndUnit.UNITMODE_PIXEL);\r\n this._rebuildLayout = true;\r\n }\r\n }\r\n }\r\n\r\n private _drawText(text: string, textWidth: number, y: number, context: ICanvasRenderingContext): void {\r\n var width = this._currentMeasure.width;\r\n var x = 0;\r\n switch (this._textHorizontalAlignment) {\r\n case Control.HORIZONTAL_ALIGNMENT_LEFT:\r\n x = 0;\r\n break;\r\n case Control.HORIZONTAL_ALIGNMENT_RIGHT:\r\n x = width - textWidth;\r\n break;\r\n case Control.HORIZONTAL_ALIGNMENT_CENTER:\r\n x = (width - textWidth) / 2;\r\n break;\r\n }\r\n\r\n if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {\r\n context.shadowColor = this.shadowColor;\r\n context.shadowBlur = this.shadowBlur;\r\n context.shadowOffsetX = this.shadowOffsetX;\r\n context.shadowOffsetY = this.shadowOffsetY;\r\n }\r\n\r\n if (this.outlineWidth) {\r\n context.strokeText(text, this._currentMeasure.left + x, y);\r\n }\r\n context.fillText(text, this._currentMeasure.left + x, y);\r\n\r\n if (this._underline) {\r\n context.beginPath();\r\n context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);\r\n context.moveTo(this._currentMeasure.left + x, y + 3);\r\n context.lineTo(this._currentMeasure.left + x + textWidth, y + 3);\r\n context.stroke();\r\n context.closePath();\r\n }\r\n\r\n if (this._lineThrough) {\r\n context.beginPath();\r\n context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);\r\n context.moveTo(this._currentMeasure.left + x, y - this.fontSizeInPixels / 3);\r\n context.lineTo(this._currentMeasure.left + x + textWidth, y - this.fontSizeInPixels / 3);\r\n context.stroke();\r\n context.closePath();\r\n }\r\n }\r\n\r\n /** @hidden */\r\n public _draw(context: ICanvasRenderingContext, invalidatedRectangle?: Nullable<Measure>): void {\r\n context.save();\r\n\r\n this._applyStates(context);\r\n\r\n // Render lines\r\n this._renderLines(context);\r\n\r\n context.restore();\r\n }\r\n\r\n protected _applyStates(context: ICanvasRenderingContext): void {\r\n super._applyStates(context);\r\n if (this.outlineWidth) {\r\n context.lineWidth = this.outlineWidth;\r\n context.strokeStyle = this.outlineColor;\r\n context.lineJoin = 'miter';\r\n context.miterLimit = 2;\r\n }\r\n }\r\n\r\n protected _breakLines(refWidth: number, context: ICanvasRenderingContext): object[] {\r\n var lines = [];\r\n var _lines = this.text.split(\"\\n\");\r\n\r\n if (this._textWrapping === TextWrapping.Ellipsis) {\r\n for (var _line of _lines) {\r\n lines.push(this._parseLineEllipsis(_line, refWidth, context));\r\n }\r\n } else if (this._textWrapping === TextWrapping.WordWrap) {\r\n for (var _line of _lines) {\r\n lines.push(...this._parseLineWordWrap(_line, refWidth, context));\r\n }\r\n } else {\r\n for (var _line of _lines) {\r\n lines.push(this._parseLine(_line, context));\r\n }\r\n }\r\n\r\n return lines;\r\n }\r\n\r\n protected _parseLine(line: string = \"\", context: ICanvasRenderingContext): object {\r\n var textMetrics = context.measureText(line);\r\n var lineWidth = Math.abs(textMetrics.actualBoundingBoxLeft) + Math.abs(textMetrics.actualBoundingBoxRight);\r\n return { text: line, width: lineWidth };\r\n }\r\n\r\n protected _parseLineEllipsis(line: string = \"\", width: number, context: ICanvasRenderingContext): object {\r\n var textMetrics = context.measureText(line);\r\n var lineWidth = Math.abs(textMetrics.actualBoundingBoxLeft) + Math.abs(textMetrics.actualBoundingBoxRight);\r\n\r\n if (lineWidth > width) {\r\n line += \"…\";\r\n }\r\n // unicode support. split('') does not work with unicode!\r\n // make sure Array.from is available\r\n const characters = Array.from && Array.from(line);\r\n if (!characters) {\r\n // no array.from, use the old method\r\n while (line.length > 2 && lineWidth > width) {\r\n line = line.slice(0, -2) + \"…\";\r\n textMetrics = context.measureText(line);\r\n lineWidth = Math.abs(textMetrics.actualBoundingBoxLeft) + Math.abs(textMetrics.actualBoundingBoxRight);\r\n }\r\n } else {\r\n while (characters.length && lineWidth > width) {\r\n characters.pop();\r\n line = `${characters.join(\"\")}...`;\r\n textMetrics = context.measureText(line);\r\n lineWidth = Math.abs(textMetrics.actualBoundingBoxLeft) + Math.abs(textMetrics.actualBoundingBoxRight);\r\n }\r\n }\r\n\r\n return { text: line, width: lineWidth };\r\n }\r\n\r\n protected _parseLineWordWrap(line: string = \"\", width: number, context: ICanvasRenderingContext): object[] {\r\n var lines = [];\r\n var words = this.wordSplittingFunction ? this.wordSplittingFunction(line) : line.split(\" \");\r\n var textMetrics = context.measureText(line);\r\n var lineWidth = Math.abs(textMetrics.actualBoundingBoxLeft) + Math.abs(textMetrics.actualBoundingBoxRight);\r\n\r\n for (var n = 0; n < words.length; n++) {\r\n var testLine = n > 0 ? line + \" \" + words[n] : words[0];\r\n var metrics = context.measureText(testLine);\r\n var testWidth = Math.abs(metrics.actualBoundingBoxLeft) + Math.abs(metrics.actualBoundingBoxRight);\r\n if (testWidth > width && n > 0) {\r\n lines.push({ text: line, width: lineWidth });\r\n line = words[n];\r\n textMetrics = context.measureText(line);\r\n lineWidth = Math.abs(textMetrics.actualBoundingBoxLeft) + Math.abs(textMetrics.actualBoundingBoxRight);\r\n } else {\r\n lineWidth = testWidth;\r\n line = testLine;\r\n }\r\n }\r\n lines.push({ text: line, width: lineWidth });\r\n\r\n return lines;\r\n }\r\n\r\n protected _renderLines(context: ICanvasRenderingContext): void {\r\n var height = this._currentMeasure.height;\r\n var rootY = 0;\r\n switch (this._textVerticalAlignment) {\r\n case Control.VERTICAL_ALIGNMENT_TOP:\r\n rootY = this._fontOffset.ascent;\r\n break;\r\n case Control.VERTICAL_ALIGNMENT_BOTTOM:\r\n rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;\r\n break;\r\n case Control.VERTICAL_ALIGNMENT_CENTER:\r\n rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;\r\n break;\r\n }\r\n\r\n rootY += this._currentMeasure.top;\r\n\r\n for (let i = 0; i < this._lines.length; i++) {\r\n const line = this._lines[i];\r\n\r\n if (i !== 0 && this._lineSpacing.internalValue !== 0) {\r\n if (this._lineSpacing.isPixel) {\r\n rootY += this._lineSpacing.getValue(this._host);\r\n } else {\r\n rootY = rootY + this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);\r\n }\r\n }\r\n\r\n this._drawText(line.text, line.width, rootY, context);\r\n rootY += this._fontOffset.height;\r\n }\r\n }\r\n\r\n /**\r\n * Given a width constraint applied on the text block, find the expected height\r\n * @returns expected height\r\n */\r\n public computeExpectedHeight(): number {\r\n if (this.text && this.widthInPixels) {\r\n // Shoudl abstract platform instead of using LastCreatedEngine\r\n const context = Engine.LastCreatedEngine?.createCanvas(0, 0).getContext(\"2d\");\r\n if (context) {\r\n this._applyStates(context);\r\n if (!this._fontOffset) {\r\n this._fontOffset = Control._GetFontOffset(context.font);\r\n }\r\n const lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context);\r\n\r\n let newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;\r\n\r\n if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {\r\n let lineSpacing = 0;\r\n if (this._lineSpacing.isPixel) {\r\n lineSpacing = this._lineSpacing.getValue(this._host);\r\n } else {\r\n lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);\r\n }\r\n\r\n newHeight += (lines.length - 1) * lineSpacing;\r\n }\r\n\r\n return newHeight;\r\n }\r\n }\r\n return 0;\r\n }\r\n\r\n dispose(): void {\r\n super.dispose();\r\n\r\n this.onTextChangedObservable.clear();\r\n }\r\n}\r\nRegisterClass(\"BABYLON.GUI.TextBlock\", TextBlock);\r\n"]}
1
+ {"version":3,"file":"textBlock.js","sourceRoot":"","sources":["../../../../sourceES6/gui/src/2D/controls/textBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAExD;;GAEG;AACH,MAAM,CAAN,IAAY,YAeX;AAfD,WAAY,YAAY;IACpB;;OAEG;IACH,+CAAQ,CAAA;IAER;;OAEG;IACH,uDAAY,CAAA;IAEZ;;OAEG;IACH,uDAAQ,CAAA;AACZ,CAAC,EAfW,YAAY,KAAZ,YAAY,QAevB;AAED;;GAEG;AACH;IAA+B,6BAAO;IA0OlC;;;;OAIG;IACH;IACI;;OAEG;IACI,IAAa,EACpB,IAAiB;QAAjB,qBAAA,EAAA,SAAiB;QALrB,YAOI,kBAAM,IAAI,CAAC,SAGd;QANU,UAAI,GAAJ,IAAI,CAAS;QAlPhB,WAAK,GAAG,EAAE,CAAC;QACX,mBAAa,GAAG,YAAY,CAAC,IAAI,CAAC;QAClC,8BAAwB,GAAG,OAAO,CAAC,2BAA2B,CAAC;QAC/D,4BAAsB,GAAG,OAAO,CAAC,yBAAyB,CAAC;QAG3D,kBAAY,GAAY,KAAK,CAAC;QAC9B,kBAAY,GAAiB,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;QACjD,mBAAa,GAAW,CAAC,CAAC;QAC1B,mBAAa,GAAW,OAAO,CAAC;QAChC,gBAAU,GAAY,KAAK,CAAC;QAC5B,kBAAY,GAAY,KAAK,CAAC;QACtC;;WAEG;QACI,6BAAuB,GAAG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C,CAAC","sourcesContent":["import { Observable } from \"@babylonjs/core/Misc/observable\";\r\nimport { Measure } from \"../measure\";\r\nimport { ValueAndUnit } from \"../valueAndUnit\";\r\nimport { Control } from \"./control\";\r\nimport { RegisterClass } from \"@babylonjs/core/Misc/typeStore\";\r\nimport { Nullable } from \"@babylonjs/core/types\";\r\nimport { serialize } from '@babylonjs/core/Misc/decorators';\r\nimport { ICanvasRenderingContext } from '@babylonjs/core/Engines/ICanvas';\r\nimport { Engine } from '@babylonjs/core/Engines/engine';\r\n\r\n/**\r\n * Enum that determines the text-wrapping mode to use.\r\n */\r\nexport enum TextWrapping {\r\n /**\r\n * Clip the text when it's larger than Control.width; this is the default mode.\r\n */\r\n Clip = 0,\r\n\r\n /**\r\n * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.\r\n */\r\n WordWrap = 1,\r\n\r\n /**\r\n * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.\r\n */\r\n Ellipsis,\r\n}\r\n\r\n/**\r\n * Class used to create text block control\r\n */\r\nexport class TextBlock extends Control {\r\n private _text = \"\";\r\n private _textWrapping = TextWrapping.Clip;\r\n private _textHorizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;\r\n private _textVerticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;\r\n\r\n private _lines: any[];\r\n private _resizeToFit: boolean = false;\r\n private _lineSpacing: ValueAndUnit = new ValueAndUnit(0);\r\n private _outlineWidth: number = 0;\r\n private _outlineColor: string = \"white\";\r\n private _underline: boolean = false;\r\n private _lineThrough: boolean = false;\r\n /**\r\n * An event triggered after the text is changed\r\n */\r\n public onTextChangedObservable = new Observable<TextBlock>();\r\n\r\n /**\r\n * An event triggered after the text was broken up into lines\r\n */\r\n public onLinesReadyObservable = new Observable<TextBlock>();\r\n\r\n /**\r\n * Function used to split a string into words. By default, a string is split at each space character found\r\n */\r\n public wordSplittingFunction: Nullable<(line: string) => string[]>;\r\n\r\n /**\r\n * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)\r\n */\r\n public get lines(): any[] {\r\n return this._lines;\r\n }\r\n\r\n /**\r\n * Gets or sets an boolean indicating that the TextBlock will be resized to fit container\r\n */\r\n @serialize()\r\n public get resizeToFit(): boolean {\r\n return this._resizeToFit;\r\n }\r\n\r\n /**\r\n * Gets or sets an boolean indicating that the TextBlock will be resized to fit container\r\n */\r\n public set resizeToFit(value: boolean) {\r\n if (this._resizeToFit === value) {\r\n return;\r\n }\r\n this._resizeToFit = value;\r\n\r\n if (this._resizeToFit) {\r\n this._width.ignoreAdaptiveScaling = true;\r\n this._height.ignoreAdaptiveScaling = true;\r\n }\r\n\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating if text must be wrapped\r\n */\r\n @serialize()\r\n public get textWrapping(): TextWrapping | boolean {\r\n return this._textWrapping;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating if text must be wrapped\r\n */\r\n public set textWrapping(value: TextWrapping | boolean) {\r\n if (this._textWrapping === value) {\r\n return;\r\n }\r\n this._textWrapping = +value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets text to display\r\n */\r\n @serialize()\r\n public get text(): string {\r\n return this._text;\r\n }\r\n\r\n /**\r\n * Gets or sets text to display\r\n */\r\n public set text(value: string) {\r\n if (this._text === value) {\r\n return;\r\n }\r\n this._text = value + \"\"; // Making sure it is a text\r\n this._markAsDirty();\r\n\r\n this.onTextChangedObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)\r\n */\r\n @serialize()\r\n public get textHorizontalAlignment(): number {\r\n return this._textHorizontalAlignment;\r\n }\r\n\r\n /**\r\n * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)\r\n */\r\n public set textHorizontalAlignment(value: number) {\r\n if (this._textHorizontalAlignment === value) {\r\n return;\r\n }\r\n\r\n this._textHorizontalAlignment = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)\r\n */\r\n @serialize()\r\n public get textVerticalAlignment(): number {\r\n return this._textVerticalAlignment;\r\n }\r\n\r\n /**\r\n * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)\r\n */\r\n public set textVerticalAlignment(value: number) {\r\n if (this._textVerticalAlignment === value) {\r\n return;\r\n }\r\n\r\n this._textVerticalAlignment = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets line spacing value\r\n */\r\n @serialize()\r\n public set lineSpacing(value: string | number) {\r\n if (this._lineSpacing.fromString(value)) {\r\n this._markAsDirty();\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets line spacing value\r\n */\r\n public get lineSpacing(): string | number {\r\n return this._lineSpacing.toString(this._host);\r\n }\r\n\r\n /**\r\n * Gets or sets outlineWidth of the text to display\r\n */\r\n @serialize()\r\n public get outlineWidth(): number {\r\n return this._outlineWidth;\r\n }\r\n\r\n /**\r\n * Gets or sets outlineWidth of the text to display\r\n */\r\n public set outlineWidth(value: number) {\r\n if (this._outlineWidth === value) {\r\n return;\r\n }\r\n this._outlineWidth = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating that text must have underline\r\n */\r\n @serialize()\r\n\r\n public get underline(): boolean {\r\n return this._underline;\r\n }\r\n\r\n /**\r\n * Gets or sets a boolean indicating that text must have underline\r\n */\r\n public set underline(value: boolean) {\r\n if (this._underline === value) {\r\n return;\r\n }\r\n this._underline = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets an boolean indicating that text must be crossed out\r\n */\r\n @serialize()\r\n public get lineThrough(): boolean {\r\n return this._lineThrough;\r\n }\r\n\r\n /**\r\n * Gets or sets an boolean indicating that text must be crossed out\r\n */\r\n public set lineThrough(value: boolean) {\r\n if (this._lineThrough === value) {\r\n return;\r\n }\r\n this._lineThrough = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Gets or sets outlineColor of the text to display\r\n */\r\n @serialize()\r\n public get outlineColor(): string {\r\n return this._outlineColor;\r\n }\r\n\r\n /**\r\n * Gets or sets outlineColor of the text to display\r\n */\r\n public set outlineColor(value: string) {\r\n if (this._outlineColor === value) {\r\n return;\r\n }\r\n this._outlineColor = value;\r\n this._markAsDirty();\r\n }\r\n\r\n /**\r\n * Creates a new TextBlock object\r\n * @param name defines the name of the control\r\n * @param text defines the text to display (emptry string by default)\r\n */\r\n constructor(\r\n /**\r\n * Defines the name of the control\r\n */\r\n public name?: string,\r\n text: string = \"\"\r\n ) {\r\n super(name);\r\n\r\n this.text = text;\r\n }\r\n\r\n protected _getTypeName(): string {\r\n return \"TextBlock\";\r\n }\r\n\r\n protected _processMeasures(parentMeasure: Measure, context: ICanvasRenderingContext): void {\r\n if (!this._fontOffset || this.isDirty) {\r\n this._fontOffset = Control._GetFontOffset(context.font);\r\n }\r\n super._processMeasures(parentMeasure, context);\r\n\r\n // Prepare lines\r\n this._lines = this._breakLines(this._currentMeasure.width, context);\r\n this.onLinesReadyObservable.notifyObservers(this);\r\n\r\n let maxLineWidth: number = 0;\r\n\r\n for (let i = 0; i < this._lines.length; i++) {\r\n const line = this._lines[i];\r\n\r\n if (line.width > maxLineWidth) {\r\n maxLineWidth = line.width;\r\n }\r\n }\r\n\r\n if (this._resizeToFit) {\r\n if (this._textWrapping === TextWrapping.Clip) {\r\n let newWidth = (this._paddingLeftInPixels + this._paddingRightInPixels + maxLineWidth) | 0;\r\n if (newWidth !== this._width.internalValue) {\r\n this._width.updateInPlace(newWidth, ValueAndUnit.UNITMODE_PIXEL);\r\n this._rebuildLayout = true;\r\n }\r\n }\r\n let newHeight = (this._paddingTopInPixels + this._paddingBottomInPixels + this._fontOffset.height * this._lines.length) | 0;\r\n\r\n if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {\r\n let lineSpacing = 0;\r\n if (this._lineSpacing.isPixel) {\r\n lineSpacing = this._lineSpacing.getValue(this._host);\r\n } else {\r\n lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);\r\n }\r\n\r\n newHeight += (this._lines.length - 1) * lineSpacing;\r\n }\r\n\r\n if (newHeight !== this._height.internalValue) {\r\n this._height.updateInPlace(newHeight, ValueAndUnit.UNITMODE_PIXEL);\r\n this._rebuildLayout = true;\r\n }\r\n }\r\n }\r\n\r\n private _drawText(text: string, textWidth: number, y: number, context: ICanvasRenderingContext): void {\r\n var width = this._currentMeasure.width;\r\n var x = 0;\r\n switch (this._textHorizontalAlignment) {\r\n case Control.HORIZONTAL_ALIGNMENT_LEFT:\r\n x = 0;\r\n break;\r\n case Control.HORIZONTAL_ALIGNMENT_RIGHT:\r\n x = width - textWidth;\r\n break;\r\n case Control.HORIZONTAL_ALIGNMENT_CENTER:\r\n x = (width - textWidth) / 2;\r\n break;\r\n }\r\n\r\n if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {\r\n context.shadowColor = this.shadowColor;\r\n context.shadowBlur = this.shadowBlur;\r\n context.shadowOffsetX = this.shadowOffsetX;\r\n context.shadowOffsetY = this.shadowOffsetY;\r\n }\r\n\r\n if (this.outlineWidth) {\r\n context.strokeText(text, this._currentMeasure.left + x, y);\r\n }\r\n context.fillText(text, this._currentMeasure.left + x, y);\r\n\r\n if (this._underline) {\r\n context.beginPath();\r\n context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);\r\n context.moveTo(this._currentMeasure.left + x, y + 3);\r\n context.lineTo(this._currentMeasure.left + x + textWidth, y + 3);\r\n context.stroke();\r\n context.closePath();\r\n }\r\n\r\n if (this._lineThrough) {\r\n context.beginPath();\r\n context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);\r\n context.moveTo(this._currentMeasure.left + x, y - this.fontSizeInPixels / 3);\r\n context.lineTo(this._currentMeasure.left + x + textWidth, y - this.fontSizeInPixels / 3);\r\n context.stroke();\r\n context.closePath();\r\n }\r\n }\r\n\r\n /** @hidden */\r\n public _draw(context: ICanvasRenderingContext, invalidatedRectangle?: Nullable<Measure>): void {\r\n context.save();\r\n\r\n this._applyStates(context);\r\n\r\n // Render lines\r\n this._renderLines(context);\r\n\r\n context.restore();\r\n }\r\n\r\n protected _applyStates(context: ICanvasRenderingContext): void {\r\n super._applyStates(context);\r\n if (this.outlineWidth) {\r\n context.lineWidth = this.outlineWidth;\r\n context.strokeStyle = this.outlineColor;\r\n context.lineJoin = 'miter';\r\n context.miterLimit = 2;\r\n }\r\n }\r\n\r\n protected _breakLines(refWidth: number, context: ICanvasRenderingContext): object[] {\r\n var lines = [];\r\n var _lines = this.text.split(\"\\n\");\r\n\r\n if (this._textWrapping === TextWrapping.Ellipsis) {\r\n for (var _line of _lines) {\r\n lines.push(this._parseLineEllipsis(_line, refWidth, context));\r\n }\r\n } else if (this._textWrapping === TextWrapping.WordWrap) {\r\n for (var _line of _lines) {\r\n lines.push(...this._parseLineWordWrap(_line, refWidth, context));\r\n }\r\n } else {\r\n for (var _line of _lines) {\r\n lines.push(this._parseLine(_line, context));\r\n }\r\n }\r\n\r\n return lines;\r\n }\r\n\r\n protected _parseLine(line: string = \"\", context: ICanvasRenderingContext): object {\r\n var textMetrics = context.measureText(line);\r\n var lineWidth = Math.abs(textMetrics.actualBoundingBoxLeft) + Math.abs(textMetrics.actualBoundingBoxRight);\r\n return { text: line, width: lineWidth };\r\n }\r\n\r\n protected _parseLineEllipsis(line: string = \"\", width: number, context: ICanvasRenderingContext): object {\r\n var textMetrics = context.measureText(line);\r\n var lineWidth = Math.abs(textMetrics.actualBoundingBoxLeft) + Math.abs(textMetrics.actualBoundingBoxRight);\r\n\r\n if (lineWidth > width) {\r\n line += \"…\";\r\n }\r\n // unicode support. split('') does not work with unicode!\r\n // make sure Array.from is available\r\n const characters = Array.from && Array.from(line);\r\n if (!characters) {\r\n // no array.from, use the old method\r\n while (line.length > 2 && lineWidth > width) {\r\n line = line.slice(0, -2) + \"…\";\r\n textMetrics = context.measureText(line);\r\n lineWidth = Math.abs(textMetrics.actualBoundingBoxLeft) + Math.abs(textMetrics.actualBoundingBoxRight);\r\n }\r\n } else {\r\n while (characters.length && lineWidth > width) {\r\n characters.pop();\r\n line = `${characters.join(\"\")}...`;\r\n textMetrics = context.measureText(line);\r\n lineWidth = Math.abs(textMetrics.actualBoundingBoxLeft) + Math.abs(textMetrics.actualBoundingBoxRight);\r\n }\r\n }\r\n\r\n return { text: line, width: lineWidth };\r\n }\r\n\r\n protected _parseLineWordWrap(line: string = \"\", width: number, context: ICanvasRenderingContext): object[] {\r\n var lines = [];\r\n var words = this.wordSplittingFunction ? this.wordSplittingFunction(line) : line.split(\" \");\r\n var textMetrics = context.measureText(line);\r\n var lineWidth = Math.abs(textMetrics.actualBoundingBoxLeft) + Math.abs(textMetrics.actualBoundingBoxRight);\r\n\r\n for (var n = 0; n < words.length; n++) {\r\n var testLine = n > 0 ? line + \" \" + words[n] : words[0];\r\n var metrics = context.measureText(testLine);\r\n var testWidth = Math.abs(metrics.actualBoundingBoxLeft) + Math.abs(metrics.actualBoundingBoxRight);\r\n if (testWidth > width && n > 0) {\r\n lines.push({ text: line, width: lineWidth });\r\n line = words[n];\r\n textMetrics = context.measureText(line);\r\n lineWidth = Math.abs(textMetrics.actualBoundingBoxLeft) + Math.abs(textMetrics.actualBoundingBoxRight);\r\n } else {\r\n lineWidth = testWidth;\r\n line = testLine;\r\n }\r\n }\r\n lines.push({ text: line, width: lineWidth });\r\n\r\n return lines;\r\n }\r\n\r\n protected _renderLines(context: ICanvasRenderingContext): void {\r\n var height = this._currentMeasure.height;\r\n var rootY = 0;\r\n switch (this._textVerticalAlignment) {\r\n case Control.VERTICAL_ALIGNMENT_TOP:\r\n rootY = this._fontOffset.ascent;\r\n break;\r\n case Control.VERTICAL_ALIGNMENT_BOTTOM:\r\n rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;\r\n break;\r\n case Control.VERTICAL_ALIGNMENT_CENTER:\r\n rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;\r\n break;\r\n }\r\n\r\n rootY += this._currentMeasure.top;\r\n\r\n for (let i = 0; i < this._lines.length; i++) {\r\n const line = this._lines[i];\r\n\r\n if (i !== 0 && this._lineSpacing.internalValue !== 0) {\r\n if (this._lineSpacing.isPixel) {\r\n rootY += this._lineSpacing.getValue(this._host);\r\n } else {\r\n rootY = rootY + this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);\r\n }\r\n }\r\n\r\n this._drawText(line.text, line.width, rootY, context);\r\n rootY += this._fontOffset.height;\r\n }\r\n }\r\n\r\n /**\r\n * Given a width constraint applied on the text block, find the expected height\r\n * @returns expected height\r\n */\r\n public computeExpectedHeight(): number {\r\n if (this.text && this.widthInPixels) {\r\n // Shoudl abstract platform instead of using LastCreatedEngine\r\n const context = Engine.LastCreatedEngine?.createCanvas(0, 0).getContext(\"2d\");\r\n if (context) {\r\n this._applyStates(context);\r\n if (!this._fontOffset) {\r\n this._fontOffset = Control._GetFontOffset(context.font);\r\n }\r\n const lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this._paddingLeftInPixels - this._paddingRightInPixels, context);\r\n\r\n let newHeight = this._paddingTopInPixels + this._paddingBottomInPixels + this._fontOffset.height * lines.length;\r\n\r\n if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {\r\n let lineSpacing = 0;\r\n if (this._lineSpacing.isPixel) {\r\n lineSpacing = this._lineSpacing.getValue(this._host);\r\n } else {\r\n lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);\r\n }\r\n\r\n newHeight += (lines.length - 1) * lineSpacing;\r\n }\r\n\r\n return newHeight;\r\n }\r\n }\r\n return 0;\r\n }\r\n\r\n dispose(): void {\r\n super.dispose();\r\n\r\n this.onTextChangedObservable.clear();\r\n }\r\n}\r\nRegisterClass(\"BABYLON.GUI.TextBlock\", TextBlock);\r\n"]}
package/2D/math2D.d.ts CHANGED
@@ -71,6 +71,11 @@ export declare class Matrix2D {
71
71
  * @returns a new matrix
72
72
  */
73
73
  static Identity(): Matrix2D;
74
+ /**
75
+ * Creates an identity matrix and stores it in a target matrix
76
+ * @param result defines the target matrix
77
+ */
78
+ static IdentityToRef(result: Matrix2D): void;
74
79
  /**
75
80
  * Creates a translation matrix and stores it in a target matrix
76
81
  * @param x defines the x coordinate of the translation
package/2D/math2D.js CHANGED
@@ -144,6 +144,18 @@ var Matrix2D = /** @class */ (function () {
144
144
  Matrix2D.Identity = function () {
145
145
  return new Matrix2D(1, 0, 0, 1, 0, 0);
146
146
  };
147
+ /**
148
+ * Creates an identity matrix and stores it in a target matrix
149
+ * @param result defines the target matrix
150
+ */
151
+ Matrix2D.IdentityToRef = function (result) {
152
+ result.m[0] = 1;
153
+ result.m[1] = 0;
154
+ result.m[2] = 0;
155
+ result.m[3] = 1;
156
+ result.m[4] = 0;
157
+ result.m[5] = 0;
158
+ };
147
159
  /**
148
160
  * Creates a translation matrix and stores it in a target matrix
149
161
  * @param x defines the x coordinate of the translation
package/2D/math2D.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"math2D.js","sourceRoot":"","sources":["../../../sourceES6/gui/src/2D/math2D.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAE/D;;GAEG;AACH;IAAqC,mCAAO;IACxC;;;;OAIG;IACH,yBAAmB,MAAe;IAC9B,6CAA6C;IACtC,WAAuB;QAAvB,4BAAA,EAAA,eAAuB;QAFlC,YAGI,kBAAM,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,SAC5B;QAFU,iBAAW,GAAX,WAAW,CAAY;;IAElC,C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,CAAC,CAAC;QACtG,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,CAAC,mBAAmB,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;QAC3F,IAAI,YAAY,EAAE;YACd,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,CAAC,0BAA0B,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;YAClG,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;SAC9D;aAAM;YACH,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAC;SACrF;IACL,CAAC;IAnCc,kCAAyB,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAChD,mCAA0B,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;IACjD,4BAAmB,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAC1C,2BAAkB,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;IACzC,sBAAa,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;IACpC,sBAAa,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;IACpC,sBAAa,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;IA8BvD,eAAC;CAAA,AAzLD,IAyLC;SAzLY,QAAQ","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\r\nimport { Vector2 } from \"@babylonjs/core/Maths/math.vector\";\r\nimport { Epsilon } from '@babylonjs/core/Maths/math.constants';\r\n\r\n/**\r\n * Class used to transport Vector2 information for pointer events\r\n */\r\nexport class Vector2WithInfo extends Vector2 {\r\n /**\r\n * Creates a new Vector2WithInfo\r\n * @param source defines the vector2 data to transport\r\n * @param buttonIndex defines the current mouse button index\r\n */\r\n public constructor(source: Vector2,\r\n /** defines the current mouse button index */\r\n public buttonIndex: number = 0) {\r\n super(source.x, source.y);\r\n }\r\n}\r\n\r\n/** Class used to provide 2D matrix features */\r\nexport class Matrix2D {\r\n /** Gets the internal array of 6 floats used to store matrix data */\r\n public m = new Float32Array(6);\r\n\r\n /**\r\n * Creates a new matrix\r\n * @param m00 defines value for (0, 0)\r\n * @param m01 defines value for (0, 1)\r\n * @param m10 defines value for (1, 0)\r\n * @param m11 defines value for (1, 1)\r\n * @param m20 defines value for (2, 0)\r\n * @param m21 defines value for (2, 1)\r\n */\r\n constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number) {\r\n this.fromValues(m00, m01, m10, m11, m20, m21);\r\n }\r\n\r\n /**\r\n * Fills the matrix from direct values\r\n * @param m00 defines value for (0, 0)\r\n * @param m01 defines value for (0, 1)\r\n * @param m10 defines value for (1, 0)\r\n * @param m11 defines value for (1, 1)\r\n * @param m20 defines value for (2, 0)\r\n * @param m21 defines value for (2, 1)\r\n * @returns the current modified matrix\r\n */\r\n public fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D {\r\n this.m[0] = m00; this.m[1] = m01;\r\n this.m[2] = m10; this.m[3] = m11;\r\n this.m[4] = m20; this.m[5] = m21;\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets matrix determinant\r\n * @returns the determinant\r\n */\r\n public determinant(): number {\r\n return this.m[0] * this.m[3] - this.m[1] * this.m[2];\r\n }\r\n\r\n /**\r\n * Inverses the matrix and stores it in a target matrix\r\n * @param result defines the target matrix\r\n * @returns the current matrix\r\n */\r\n public invertToRef(result: Matrix2D): Matrix2D {\r\n let l0 = this.m[0]; let l1 = this.m[1];\r\n let l2 = this.m[2]; let l3 = this.m[3];\r\n let l4 = this.m[4]; let l5 = this.m[5];\r\n\r\n let det = this.determinant();\r\n if (det < (Epsilon * Epsilon)) {\r\n result.m[0] = 0; result.m[1] = 0;\r\n result.m[2] = 0; result.m[3] = 0;\r\n result.m[4] = 0; result.m[5] = 0;\r\n return this;\r\n }\r\n\r\n let detDiv = 1 / det;\r\n\r\n let det4 = l2 * l5 - l3 * l4;\r\n let det5 = l1 * l4 - l0 * l5;\r\n\r\n result.m[0] = l3 * detDiv; result.m[1] = -l1 * detDiv;\r\n result.m[2] = -l2 * detDiv; result.m[3] = l0 * detDiv;\r\n result.m[4] = det4 * detDiv; result.m[5] = det5 * detDiv;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Multiplies the current matrix with another one\r\n * @param other defines the second operand\r\n * @param result defines the target matrix\r\n * @returns the current matrix\r\n */\r\n public multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D {\r\n let l0 = this.m[0]; let l1 = this.m[1];\r\n let l2 = this.m[2]; let l3 = this.m[3];\r\n let l4 = this.m[4]; let l5 = this.m[5];\r\n\r\n let r0 = other.m[0]; let r1 = other.m[1];\r\n let r2 = other.m[2]; let r3 = other.m[3];\r\n let r4 = other.m[4]; let r5 = other.m[5];\r\n\r\n result.m[0] = l0 * r0 + l1 * r2; result.m[1] = l0 * r1 + l1 * r3;\r\n result.m[2] = l2 * r0 + l3 * r2; result.m[3] = l2 * r1 + l3 * r3;\r\n result.m[4] = l4 * r0 + l5 * r2 + r4; result.m[5] = l4 * r1 + l5 * r3 + r5;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Applies the current matrix to a set of 2 floats and stores the result in a vector2\r\n * @param x defines the x coordinate to transform\r\n * @param y defines the x coordinate to transform\r\n * @param result defines the target vector2\r\n * @returns the current matrix\r\n */\r\n public transformCoordinates(x: number, y: number, result: Vector2): Matrix2D {\r\n result.x = x * this.m[0] + y * this.m[2] + this.m[4];\r\n result.y = x * this.m[1] + y * this.m[3] + this.m[5];\r\n\r\n return this;\r\n }\r\n\r\n // Statics\r\n /**\r\n * Creates an identity matrix\r\n * @returns a new matrix\r\n */\r\n public static Identity(): Matrix2D {\r\n return new Matrix2D(1, 0, 0, 1, 0, 0);\r\n }\r\n\r\n /**\r\n * Creates a translation matrix and stores it in a target matrix\r\n * @param x defines the x coordinate of the translation\r\n * @param y defines the y coordinate of the translation\r\n * @param result defines the target matrix\r\n */\r\n public static TranslationToRef(x: number, y: number, result: Matrix2D): void {\r\n result.fromValues(1, 0, 0, 1, x, y);\r\n }\r\n\r\n /**\r\n * Creates a scaling matrix and stores it in a target matrix\r\n * @param x defines the x coordinate of the scaling\r\n * @param y defines the y coordinate of the scaling\r\n * @param result defines the target matrix\r\n */\r\n public static ScalingToRef(x: number, y: number, result: Matrix2D): void {\r\n result.fromValues(x, 0, 0, y, 0, 0);\r\n }\r\n\r\n /**\r\n * Creates a rotation matrix and stores it in a target matrix\r\n * @param angle defines the rotation angle\r\n * @param result defines the target matrix\r\n */\r\n public static RotationToRef(angle: number, result: Matrix2D): void {\r\n var s = Math.sin(angle);\r\n var c = Math.cos(angle);\r\n\r\n result.fromValues(c, s, -s, c, 0, 0);\r\n }\r\n\r\n private static _TempPreTranslationMatrix = Matrix2D.Identity();\r\n private static _TempPostTranslationMatrix = Matrix2D.Identity();\r\n private static _TempRotationMatrix = Matrix2D.Identity();\r\n private static _TempScalingMatrix = Matrix2D.Identity();\r\n private static _TempCompose0 = Matrix2D.Identity();\r\n private static _TempCompose1 = Matrix2D.Identity();\r\n private static _TempCompose2 = Matrix2D.Identity();\r\n\r\n /**\r\n * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix\r\n * @param tx defines the x coordinate of the translation\r\n * @param ty defines the y coordinate of the translation\r\n * @param angle defines the rotation angle\r\n * @param scaleX defines the x coordinate of the scaling\r\n * @param scaleY defines the y coordinate of the scaling\r\n * @param parentMatrix defines the parent matrix to multiply by (can be null)\r\n * @param result defines the target matrix\r\n */\r\n public static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: Nullable<Matrix2D>, result: Matrix2D): void {\r\n Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);\r\n\r\n Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);\r\n\r\n Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);\r\n\r\n Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);\r\n\r\n Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);\r\n Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);\r\n if (parentMatrix) {\r\n Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);\r\n Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);\r\n } else {\r\n Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);\r\n }\r\n }\r\n}"]}
1
+ {"version":3,"file":"math2D.js","sourceRoot":"","sources":["../../../sourceES6/gui/src/2D/math2D.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAE/D;;GAEG;AACH;IAAqC,mCAAO;IACxC;;;;OAIG;IACH,yBAAmB,MAAe;IAC9B,6CAA6C;IACtC,WAAuB;QAAvB,4BAAA,EAAA,eAAuB;QAFlC,YAGI,kBAAM,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,SAC5B;QAFU,iBAAW,GAAX,WAAW,CAAY;;IAElC,CAAC;IACL,sBAAC;AAAD,CAAC,AAXD,CAAqC,OAAO,GAW3C;;AAED,+CAA+C;AAC/C;IAII;;;;;;;;OAQG;IACH,kBAAY,GAAW,EAAE,GAAW,EAAE,GAAW,EAAE,GAAW,EAAE,GAAW,EAAE,GAAW;QAZxF,oEAAoE;QAC7D,MAAC,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;QAY3B,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAClD,CAAC;IAED;;;;;;;;;OASG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C,kBAAkB,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;QACtG,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,CAAC,mBAAmB,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;QAC3F,IAAI,YAAY,EAAE;YACd,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,CAAC,0BAA0B,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;YAClG,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;SAC9D;aAAM;YACH,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAC;SACrF;IACL,CAAC;IAnCc,kCAAyB,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAChD,mCAA0B,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;IACjD,4BAAmB,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAC1C,2BAAkB,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;IACzC,sBAAa,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;IACpC,sBAAa,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;IACpC,sBAAa,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;IA8BvD,eAAC;CAAA,AAtMD,IAsMC;SAtMY,QAAQ","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\r\nimport { Vector2 } from \"@babylonjs/core/Maths/math.vector\";\r\nimport { Epsilon } from '@babylonjs/core/Maths/math.constants';\r\n\r\n/**\r\n * Class used to transport Vector2 information for pointer events\r\n */\r\nexport class Vector2WithInfo extends Vector2 {\r\n /**\r\n * Creates a new Vector2WithInfo\r\n * @param source defines the vector2 data to transport\r\n * @param buttonIndex defines the current mouse button index\r\n */\r\n public constructor(source: Vector2,\r\n /** defines the current mouse button index */\r\n public buttonIndex: number = 0) {\r\n super(source.x, source.y);\r\n }\r\n}\r\n\r\n/** Class used to provide 2D matrix features */\r\nexport class Matrix2D {\r\n /** Gets the internal array of 6 floats used to store matrix data */\r\n public m = new Float32Array(6);\r\n\r\n /**\r\n * Creates a new matrix\r\n * @param m00 defines value for (0, 0)\r\n * @param m01 defines value for (0, 1)\r\n * @param m10 defines value for (1, 0)\r\n * @param m11 defines value for (1, 1)\r\n * @param m20 defines value for (2, 0)\r\n * @param m21 defines value for (2, 1)\r\n */\r\n constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number) {\r\n this.fromValues(m00, m01, m10, m11, m20, m21);\r\n }\r\n\r\n /**\r\n * Fills the matrix from direct values\r\n * @param m00 defines value for (0, 0)\r\n * @param m01 defines value for (0, 1)\r\n * @param m10 defines value for (1, 0)\r\n * @param m11 defines value for (1, 1)\r\n * @param m20 defines value for (2, 0)\r\n * @param m21 defines value for (2, 1)\r\n * @returns the current modified matrix\r\n */\r\n public fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D {\r\n this.m[0] = m00; this.m[1] = m01;\r\n this.m[2] = m10; this.m[3] = m11;\r\n this.m[4] = m20; this.m[5] = m21;\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets matrix determinant\r\n * @returns the determinant\r\n */\r\n public determinant(): number {\r\n return this.m[0] * this.m[3] - this.m[1] * this.m[2];\r\n }\r\n\r\n /**\r\n * Inverses the matrix and stores it in a target matrix\r\n * @param result defines the target matrix\r\n * @returns the current matrix\r\n */\r\n public invertToRef(result: Matrix2D): Matrix2D {\r\n let l0 = this.m[0]; let l1 = this.m[1];\r\n let l2 = this.m[2]; let l3 = this.m[3];\r\n let l4 = this.m[4]; let l5 = this.m[5];\r\n\r\n let det = this.determinant();\r\n if (det < (Epsilon * Epsilon)) {\r\n result.m[0] = 0; result.m[1] = 0;\r\n result.m[2] = 0; result.m[3] = 0;\r\n result.m[4] = 0; result.m[5] = 0;\r\n return this;\r\n }\r\n\r\n let detDiv = 1 / det;\r\n\r\n let det4 = l2 * l5 - l3 * l4;\r\n let det5 = l1 * l4 - l0 * l5;\r\n\r\n result.m[0] = l3 * detDiv; result.m[1] = -l1 * detDiv;\r\n result.m[2] = -l2 * detDiv; result.m[3] = l0 * detDiv;\r\n result.m[4] = det4 * detDiv; result.m[5] = det5 * detDiv;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Multiplies the current matrix with another one\r\n * @param other defines the second operand\r\n * @param result defines the target matrix\r\n * @returns the current matrix\r\n */\r\n public multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D {\r\n let l0 = this.m[0]; let l1 = this.m[1];\r\n let l2 = this.m[2]; let l3 = this.m[3];\r\n let l4 = this.m[4]; let l5 = this.m[5];\r\n\r\n let r0 = other.m[0]; let r1 = other.m[1];\r\n let r2 = other.m[2]; let r3 = other.m[3];\r\n let r4 = other.m[4]; let r5 = other.m[5];\r\n\r\n result.m[0] = l0 * r0 + l1 * r2; result.m[1] = l0 * r1 + l1 * r3;\r\n result.m[2] = l2 * r0 + l3 * r2; result.m[3] = l2 * r1 + l3 * r3;\r\n result.m[4] = l4 * r0 + l5 * r2 + r4; result.m[5] = l4 * r1 + l5 * r3 + r5;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Applies the current matrix to a set of 2 floats and stores the result in a vector2\r\n * @param x defines the x coordinate to transform\r\n * @param y defines the x coordinate to transform\r\n * @param result defines the target vector2\r\n * @returns the current matrix\r\n */\r\n public transformCoordinates(x: number, y: number, result: Vector2): Matrix2D {\r\n result.x = x * this.m[0] + y * this.m[2] + this.m[4];\r\n result.y = x * this.m[1] + y * this.m[3] + this.m[5];\r\n\r\n return this;\r\n }\r\n\r\n // Statics\r\n /**\r\n * Creates an identity matrix\r\n * @returns a new matrix\r\n */\r\n public static Identity(): Matrix2D {\r\n return new Matrix2D(1, 0, 0, 1, 0, 0);\r\n }\r\n\r\n /**\r\n * Creates an identity matrix and stores it in a target matrix\r\n * @param result defines the target matrix\r\n */\r\n public static IdentityToRef(result: Matrix2D): void {\r\n result.m[0] = 1;\r\n result.m[1] = 0;\r\n result.m[2] = 0;\r\n result.m[3] = 1;\r\n result.m[4] = 0;\r\n result.m[5] = 0;\r\n }\r\n\r\n /**\r\n * Creates a translation matrix and stores it in a target matrix\r\n * @param x defines the x coordinate of the translation\r\n * @param y defines the y coordinate of the translation\r\n * @param result defines the target matrix\r\n */\r\n public static TranslationToRef(x: number, y: number, result: Matrix2D): void {\r\n result.fromValues(1, 0, 0, 1, x, y);\r\n }\r\n\r\n /**\r\n * Creates a scaling matrix and stores it in a target matrix\r\n * @param x defines the x coordinate of the scaling\r\n * @param y defines the y coordinate of the scaling\r\n * @param result defines the target matrix\r\n */\r\n public static ScalingToRef(x: number, y: number, result: Matrix2D): void {\r\n result.fromValues(x, 0, 0, y, 0, 0);\r\n }\r\n\r\n /**\r\n * Creates a rotation matrix and stores it in a target matrix\r\n * @param angle defines the rotation angle\r\n * @param result defines the target matrix\r\n */\r\n public static RotationToRef(angle: number, result: Matrix2D): void {\r\n var s = Math.sin(angle);\r\n var c = Math.cos(angle);\r\n\r\n result.fromValues(c, s, -s, c, 0, 0);\r\n }\r\n\r\n private static _TempPreTranslationMatrix = Matrix2D.Identity();\r\n private static _TempPostTranslationMatrix = Matrix2D.Identity();\r\n private static _TempRotationMatrix = Matrix2D.Identity();\r\n private static _TempScalingMatrix = Matrix2D.Identity();\r\n private static _TempCompose0 = Matrix2D.Identity();\r\n private static _TempCompose1 = Matrix2D.Identity();\r\n private static _TempCompose2 = Matrix2D.Identity();\r\n\r\n /**\r\n * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix\r\n * @param tx defines the x coordinate of the translation\r\n * @param ty defines the y coordinate of the translation\r\n * @param angle defines the rotation angle\r\n * @param scaleX defines the x coordinate of the scaling\r\n * @param scaleY defines the y coordinate of the scaling\r\n * @param parentMatrix defines the parent matrix to multiply by (can be null)\r\n * @param result defines the target matrix\r\n */\r\n public static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: Nullable<Matrix2D>, result: Matrix2D): void {\r\n Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);\r\n\r\n Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);\r\n\r\n Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);\r\n\r\n Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);\r\n\r\n Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);\r\n Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);\r\n if (parentMatrix) {\r\n Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);\r\n Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);\r\n } else {\r\n Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);\r\n }\r\n }\r\n}"]}
@@ -1,23 +1,27 @@
1
+ import { Observable } from "@babylonjs/core/Misc/observable";
1
2
  import { AdvancedDynamicTexture } from "./advancedDynamicTexture";
2
3
  /**
3
4
  * Class used to specific a value and its associated unit
4
5
  */
5
6
  export declare class ValueAndUnit {
6
- /** defines the unit to store */
7
- unit: number;
8
7
  /** defines a boolean indicating if the value can be negative */
9
8
  negativeValueAllowed: boolean;
10
9
  private _value;
10
+ private _unit;
11
11
  private _originalUnit;
12
12
  /**
13
13
  * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
14
14
  * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
15
15
  */
16
16
  ignoreAdaptiveScaling: boolean;
17
+ /**
18
+ * Observable event triggered each time the value or unit changes
19
+ */
20
+ onChangedObservable: Observable<void>;
17
21
  /**
18
22
  * Creates a new ValueAndUnit
19
23
  * @param value defines the value to store
20
- * @param unit defines the unit to store
24
+ * @param unit defines the unit to store - defaults to ValueAndUnit.UNITMODE_PIXEL
21
25
  * @param negativeValueAllowed defines a boolean indicating if the value can be negative
22
26
  */
23
27
  constructor(value: number,
@@ -29,8 +33,19 @@ export declare class ValueAndUnit {
29
33
  get isPercentage(): boolean;
30
34
  /** Gets a boolean indicating if the value is store as pixel */
31
35
  get isPixel(): boolean;
32
- /** Gets direct internal value */
36
+ /**
37
+ * Gets value (without units)
38
+ * @deprecated use value property instead
39
+ */
33
40
  get internalValue(): number;
41
+ /** Gets value (without units) */
42
+ get value(): number;
43
+ /** Sets value (without units) */
44
+ set value(value: number);
45
+ /** Gets units (without value) */
46
+ get unit(): number;
47
+ /** Sets units (without value) */
48
+ set unit(value: number);
34
49
  /**
35
50
  * Gets value as pixel
36
51
  * @param host defines the root host
@@ -39,7 +54,7 @@ export declare class ValueAndUnit {
39
54
  */
40
55
  getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
41
56
  /**
42
- * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
57
+ * Update the current value and unit.
43
58
  * @param value defines the value to store
44
59
  * @param unit defines the unit to store
45
60
  * @returns the current ValueAndUnit
@@ -61,7 +76,7 @@ export declare class ValueAndUnit {
61
76
  /**
62
77
  * Store a value parsed from a string
63
78
  * @param source defines the source string
64
- * @returns true if the value was successfully parsed
79
+ * @returns true if the value was successfully parsed and updated
65
80
  */
66
81
  fromString(source: string | number): boolean;
67
82
  private static _Regex;
@@ -1,3 +1,4 @@
1
+ import { Observable } from "@babylonjs/core/Misc/observable.js";
1
2
  /**
2
3
  * Class used to specific a value and its associated unit
3
4
  */
@@ -5,7 +6,7 @@ var ValueAndUnit = /** @class */ (function () {
5
6
  /**
6
7
  * Creates a new ValueAndUnit
7
8
  * @param value defines the value to store
8
- * @param unit defines the unit to store
9
+ * @param unit defines the unit to store - defaults to ValueAndUnit.UNITMODE_PIXEL
9
10
  * @param negativeValueAllowed defines a boolean indicating if the value can be negative
10
11
  */
11
12
  function ValueAndUnit(value,
@@ -15,21 +16,26 @@ var ValueAndUnit = /** @class */ (function () {
15
16
  negativeValueAllowed) {
16
17
  if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
17
18
  if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
18
- this.unit = unit;
19
19
  this.negativeValueAllowed = negativeValueAllowed;
20
20
  this._value = 1;
21
+ this._unit = ValueAndUnit.UNITMODE_PIXEL;
21
22
  /**
22
23
  * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
23
24
  * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
24
25
  */
25
26
  this.ignoreAdaptiveScaling = false;
27
+ /**
28
+ * Observable event triggered each time the value or unit changes
29
+ */
30
+ this.onChangedObservable = new Observable();
26
31
  this._value = value;
32
+ this._unit = unit;
27
33
  this._originalUnit = unit;
28
34
  }
29
35
  Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
30
36
  /** Gets a boolean indicating if the value is a percentage */
31
37
  get: function () {
32
- return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
38
+ return this._unit === ValueAndUnit.UNITMODE_PERCENTAGE;
33
39
  },
34
40
  enumerable: false,
35
41
  configurable: true
@@ -37,16 +43,49 @@ var ValueAndUnit = /** @class */ (function () {
37
43
  Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
38
44
  /** Gets a boolean indicating if the value is store as pixel */
39
45
  get: function () {
40
- return this.unit === ValueAndUnit.UNITMODE_PIXEL;
46
+ return this._unit === ValueAndUnit.UNITMODE_PIXEL;
41
47
  },
42
48
  enumerable: false,
43
49
  configurable: true
44
50
  });
45
51
  Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
46
- /** Gets direct internal value */
52
+ /**
53
+ * Gets value (without units)
54
+ * @deprecated use value property instead
55
+ */
56
+ get: function () {
57
+ return this._value;
58
+ },
59
+ enumerable: false,
60
+ configurable: true
61
+ });
62
+ Object.defineProperty(ValueAndUnit.prototype, "value", {
63
+ /** Gets value (without units) */
47
64
  get: function () {
48
65
  return this._value;
49
66
  },
67
+ /** Sets value (without units) */
68
+ set: function (value) {
69
+ if (value !== this._value) {
70
+ this._value = value;
71
+ this.onChangedObservable.notifyObservers();
72
+ }
73
+ },
74
+ enumerable: false,
75
+ configurable: true
76
+ });
77
+ Object.defineProperty(ValueAndUnit.prototype, "unit", {
78
+ /** Gets units (without value) */
79
+ get: function () {
80
+ return this._unit;
81
+ },
82
+ /** Sets units (without value) */
83
+ set: function (value) {
84
+ if (value !== this._unit) {
85
+ this._unit = value;
86
+ this.onChangedObservable.notifyObservers();
87
+ }
88
+ },
50
89
  enumerable: false,
51
90
  configurable: true
52
91
  });
@@ -63,15 +102,19 @@ var ValueAndUnit = /** @class */ (function () {
63
102
  return this.getValue(host) * refValue;
64
103
  };
65
104
  /**
66
- * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
105
+ * Update the current value and unit.
67
106
  * @param value defines the value to store
68
107
  * @param unit defines the unit to store
69
108
  * @returns the current ValueAndUnit
70
109
  */
71
110
  ValueAndUnit.prototype.updateInPlace = function (value, unit) {
72
111
  if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
73
- this._value = value;
74
- this.unit = unit;
112
+ if (this.value !== value || this.unit !== unit) {
113
+ // set member variables to notify only once
114
+ this._value = value;
115
+ this._unit = unit;
116
+ this.onChangedObservable.notifyObservers();
117
+ }
75
118
  return this;
76
119
  };
77
120
  /**
@@ -108,7 +151,7 @@ var ValueAndUnit = /** @class */ (function () {
108
151
  * @returns a string
109
152
  */
110
153
  ValueAndUnit.prototype.toString = function (host, decimals) {
111
- switch (this.unit) {
154
+ switch (this._unit) {
112
155
  case ValueAndUnit.UNITMODE_PERCENTAGE:
113
156
  var percentage = this.getValue(host) * 100;
114
157
  return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
@@ -116,12 +159,12 @@ var ValueAndUnit = /** @class */ (function () {
116
159
  var pixels = this.getValue(host);
117
160
  return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
118
161
  }
119
- return this.unit.toString();
162
+ return this._unit.toString();
120
163
  };
121
164
  /**
122
165
  * Store a value parsed from a string
123
166
  * @param source defines the source string
124
- * @returns true if the value was successfully parsed
167
+ * @returns true if the value was successfully parsed and updated
125
168
  */
126
169
  ValueAndUnit.prototype.fromString = function (source) {
127
170
  var match = ValueAndUnit._Regex.exec(source.toString());
@@ -146,11 +189,12 @@ var ValueAndUnit = /** @class */ (function () {
146
189
  break;
147
190
  }
148
191
  }
149
- if (sourceValue === this._value && sourceUnit === this.unit) {
192
+ if (sourceValue === this._value && sourceUnit === this._unit) {
150
193
  return false;
151
194
  }
152
195
  this._value = sourceValue;
153
- this.unit = sourceUnit;
196
+ this._unit = sourceUnit;
197
+ this.onChangedObservable.notifyObservers();
154
198
  return true;
155
199
  };
156
200
  Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
@@ -1 +1 @@
1
- {"version":3,"file":"valueAndUnit.js","sourceRoot":"","sources":["../../../sourceES6/gui/src/2D/valueAndUnit.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH;IASI;;;;;OAKG;IACH,sBAAmB,KAAa;IAC5B,gCAAgC;IACzB,IAAkC;IACzC,gEAAgE;IACzD,oBAA2B;QAF3B,qBAAA,EAAA,OAAO,YAAY,CAAC,cAAc;QAElC,qCAAA,EAAA,2BAA2B;QAF3B,SAAI,GAAJ,IAAI,CAA8B;QAElC,yBAAoB,GAApB,oBAAoB,CAAO;QAlB9B,WAAM,GAAG,CAAC,CAAC;QAEnB;;;WAGG;QACI,0BAAqB,GAAG,KAAK,CAAC;QAajC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC9B,CAAC;IAGD,sBAAW,sCAAY;QADvB,6DAA6D;aAC7D;YACI,OAAO,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,mBAAmB,CAAC;QAC1D,CAAC;;;OAAA;IAGD,sBAAW,i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r\n\r\n/**\r\n * Class used to specific a value and its associated unit\r\n */\r\nexport class ValueAndUnit {\r\n private _value = 1;\r\n private _originalUnit: number;\r\n /**\r\n * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property\r\n * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling\r\n */\r\n public ignoreAdaptiveScaling = false;\r\n\r\n /**\r\n * Creates a new ValueAndUnit\r\n * @param value defines the value to store\r\n * @param unit defines the unit to store\r\n * @param negativeValueAllowed defines a boolean indicating if the value can be negative\r\n */\r\n public constructor(value: number,\r\n /** defines the unit to store */\r\n public unit = ValueAndUnit.UNITMODE_PIXEL,\r\n /** defines a boolean indicating if the value can be negative */\r\n public negativeValueAllowed = true) {\r\n this._value = value;\r\n this._originalUnit = unit;\r\n }\r\n\r\n /** Gets a boolean indicating if the value is a percentage */\r\n public get isPercentage(): boolean {\r\n return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;\r\n }\r\n\r\n /** Gets a boolean indicating if the value is store as pixel */\r\n public get isPixel(): boolean {\r\n return this.unit === ValueAndUnit.UNITMODE_PIXEL;\r\n }\r\n\r\n /** Gets direct internal value */\r\n public get internalValue(): number {\r\n return this._value;\r\n }\r\n\r\n /**\r\n * Gets value as pixel\r\n * @param host defines the root host\r\n * @param refValue defines the reference value for percentages\r\n * @returns the value as pixel\r\n */\r\n public getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number {\r\n if (this.isPixel) {\r\n return this.getValue(host);\r\n }\r\n\r\n return this.getValue(host) * refValue;\r\n }\r\n\r\n /**\r\n * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.\r\n * @param value defines the value to store\r\n * @param unit defines the unit to store\r\n * @returns the current ValueAndUnit\r\n */\r\n public updateInPlace(value: number, unit = ValueAndUnit.UNITMODE_PIXEL): ValueAndUnit {\r\n this._value = value;\r\n this.unit = unit;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets the value accordingly to its unit\r\n * @param host defines the root host\r\n * @returns the value\r\n */\r\n public getValue(host: AdvancedDynamicTexture): number {\r\n if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {\r\n var width: number = 0;\r\n var height: number = 0;\r\n\r\n if (host.idealWidth) {\r\n width = (this._value * host.getSize().width) / host.idealWidth;\r\n }\r\n\r\n if (host.idealHeight) {\r\n height = (this._value * host.getSize().height) / host.idealHeight;\r\n }\r\n\r\n if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {\r\n return window.innerWidth < window.innerHeight ? width : height;\r\n }\r\n\r\n if (host.idealWidth) { // horizontal\r\n return width;\r\n }\r\n\r\n if (host.idealHeight) { // vertical\r\n return height;\r\n }\r\n }\r\n return this._value;\r\n }\r\n\r\n /**\r\n * Gets a string representation of the value\r\n * @param host defines the root host\r\n * @param decimals defines an optional number of decimals to display\r\n * @returns a string\r\n */\r\n public toString(host: AdvancedDynamicTexture, decimals?: number): string {\r\n switch (this.unit) {\r\n case ValueAndUnit.UNITMODE_PERCENTAGE:\r\n let percentage = this.getValue(host) * 100;\r\n\r\n return (decimals ? percentage.toFixed(decimals) : percentage) + \"%\";\r\n case ValueAndUnit.UNITMODE_PIXEL:\r\n let pixels = this.getValue(host);\r\n return (decimals ? pixels.toFixed(decimals) : pixels) + \"px\";\r\n }\r\n\r\n return this.unit.toString();\r\n }\r\n\r\n /**\r\n * Store a value parsed from a string\r\n * @param source defines the source string\r\n * @returns true if the value was successfully parsed\r\n */\r\n public fromString(source: string | number): boolean {\r\n var match = ValueAndUnit._Regex.exec(source.toString());\r\n\r\n if (!match || match.length === 0) {\r\n return false;\r\n }\r\n\r\n var sourceValue = parseFloat(match[1]);\r\n var sourceUnit = this._originalUnit;\r\n\r\n if (!this.negativeValueAllowed) {\r\n if (sourceValue < 0) {\r\n sourceValue = 0;\r\n }\r\n }\r\n\r\n if (match.length === 4) {\r\n switch (match[3]) {\r\n case \"px\":\r\n sourceUnit = ValueAndUnit.UNITMODE_PIXEL;\r\n break;\r\n case \"%\":\r\n sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;\r\n sourceValue /= 100.0;\r\n break;\r\n }\r\n }\r\n\r\n if (sourceValue === this._value && sourceUnit === this.unit) {\r\n return false;\r\n }\r\n\r\n this._value = sourceValue;\r\n this.unit = sourceUnit;\r\n\r\n return true;\r\n }\r\n\r\n // Static\r\n private static _Regex = /(^-?\\d*(\\.\\d+)?)(%|px)?/;\r\n private static _UNITMODE_PERCENTAGE = 0;\r\n private static _UNITMODE_PIXEL = 1;\r\n\r\n /** UNITMODE_PERCENTAGE */\r\n public static get UNITMODE_PERCENTAGE(): number {\r\n return ValueAndUnit._UNITMODE_PERCENTAGE;\r\n }\r\n\r\n /** UNITMODE_PIXEL */\r\n public static get UNITMODE_PIXEL(): number {\r\n return ValueAndUnit._UNITMODE_PIXEL;\r\n }\r\n}"]}
1
+ {"version":3,"file":"valueAndUnit.js","sourceRoot":"","sources":["../../../sourceES6/gui/src/2D/valueAndUnit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAG7D;;GAEG;AACH;IAgBI;;;;;OAKG;IACH,sBAAmB,KAAa;IAC5B,gCAAgC;IAChC,IAAkC;IAClC,gEAAgE;IACzD,oBAA2B;QAFlC,qBAAA,EAAA,OAAO,YAAY,CAAC,cAAc;QAE3B,qCAAA,EAAA,2BAA2B;QAA3B,yBAAoB,GAApB,oBAAoB,CAAO;QAzB9B,WAAM,GAAG,CAAC,CAAC;QACX,UAAK,GAAG,YAAY,CAAC,cAAc,CAAC;QAG5C;;;WAGG;QACI,0BAAqB,GAAG,KAAK,CAAC;QAErC;;WAEG;QACI,wBAAmB,GAAG,IAAI,UAAU,EAAQ,CAAC;QAahD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC9B,CAAC;IAGD,s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AQ,KAAK,CAAC,CAAC,CAAC,EAAE;gBACd,KAAK,IAAI;oBACL,UAAU,GAAG,YAAY,CAAC,cAAc,CAAC;oBACzC,MAAM;gBACV,KAAK,GAAG;oBACJ,UAAU,GAAG,YAAY,CAAC,mBAAmB,CAAC;oBAC9C,WAAW,IAAI,KAAK,CAAC;oBACrB,MAAM;aACb;SACJ;QAED,IAAI,WAAW,KAAK,IAAI,CAAC,MAAM,IAAI,UAAU,KAAK,IAAI,CAAC,KAAK,EAAE;YAC1D,OAAO,KAAK,CAAC;SAChB;QAED,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC;QACxB,IAAI,CAAC,mBAAmB,CAAC,eAAe,EAAE,CAAC;QAE3C,OAAO,IAAI,CAAC;IAChB,CAAC;IAQD,sBAAkB,mCAAmB;QADrC,0BAA0B;aAC1B;YACI,OAAO,YAAY,CAAC,oBAAoB,CAAC;QAC7C,CAAC;;;OAAA;IAGD,sBAAkB,8BAAc;QADhC,qBAAqB;aACrB;YACI,OAAO,YAAY,CAAC,eAAe,CAAC;QACxC,CAAC;;;OAAA;IAbD,SAAS;IACM,mBAAM,GAAG,yBAAyB,CAAC;IACnC,iCAAoB,GAAG,CAAC,CAAC;IACzB,4BAAe,GAAG,CAAC,CAAC;IAWvC,mBAAC;CAAA,AAzND,IAyNC;SAzNY,YAAY","sourcesContent":["import { Observable } from \"@babylonjs/core/Misc/observable\";\r\nimport { AdvancedDynamicTexture } from \"./advancedDynamicTexture\";\r\n\r\n/**\r\n * Class used to specific a value and its associated unit\r\n */\r\nexport class ValueAndUnit {\r\n private _value = 1;\r\n private _unit = ValueAndUnit.UNITMODE_PIXEL;\r\n private _originalUnit: number;\r\n\r\n /**\r\n * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property\r\n * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling\r\n */\r\n public ignoreAdaptiveScaling = false;\r\n\r\n /**\r\n * Observable event triggered each time the value or unit changes\r\n */\r\n public onChangedObservable = new Observable<void>();\r\n\r\n /**\r\n * Creates a new ValueAndUnit\r\n * @param value defines the value to store\r\n * @param unit defines the unit to store - defaults to ValueAndUnit.UNITMODE_PIXEL\r\n * @param negativeValueAllowed defines a boolean indicating if the value can be negative\r\n */\r\n public constructor(value: number,\r\n /** defines the unit to store */\r\n unit = ValueAndUnit.UNITMODE_PIXEL,\r\n /** defines a boolean indicating if the value can be negative */\r\n public negativeValueAllowed = true) {\r\n this._value = value;\r\n this._unit = unit;\r\n this._originalUnit = unit;\r\n }\r\n\r\n /** Gets a boolean indicating if the value is a percentage */\r\n public get isPercentage(): boolean {\r\n return this._unit === ValueAndUnit.UNITMODE_PERCENTAGE;\r\n }\r\n\r\n /** Gets a boolean indicating if the value is store as pixel */\r\n public get isPixel(): boolean {\r\n return this._unit === ValueAndUnit.UNITMODE_PIXEL;\r\n }\r\n\r\n /**\r\n * Gets value (without units)\r\n * @deprecated use value property instead\r\n */\r\n public get internalValue(): number {\r\n return this._value;\r\n }\r\n\r\n /** Gets value (without units) */\r\n public get value(): number {\r\n return this._value;\r\n }\r\n\r\n /** Sets value (without units) */\r\n public set value(value: number) {\r\n if (value !== this._value) {\r\n this._value = value;\r\n this.onChangedObservable.notifyObservers();\r\n }\r\n }\r\n\r\n /** Gets units (without value) */\r\n public get unit(): number {\r\n return this._unit;\r\n }\r\n\r\n /** Sets units (without value) */\r\n public set unit(value: number) {\r\n if (value !== this._unit) {\r\n this._unit = value;\r\n this.onChangedObservable.notifyObservers();\r\n }\r\n }\r\n\r\n /**\r\n * Gets value as pixel\r\n * @param host defines the root host\r\n * @param refValue defines the reference value for percentages\r\n * @returns the value as pixel\r\n */\r\n public getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number {\r\n if (this.isPixel) {\r\n return this.getValue(host);\r\n }\r\n\r\n return this.getValue(host) * refValue;\r\n }\r\n\r\n /**\r\n * Update the current value and unit.\r\n * @param value defines the value to store\r\n * @param unit defines the unit to store\r\n * @returns the current ValueAndUnit\r\n */\r\n public updateInPlace(value: number, unit = ValueAndUnit.UNITMODE_PIXEL): ValueAndUnit {\r\n if (this.value !== value || this.unit !== unit) {\r\n // set member variables to notify only once\r\n this._value = value;\r\n this._unit = unit;\r\n this.onChangedObservable.notifyObservers();\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets the value accordingly to its unit\r\n * @param host defines the root host\r\n * @returns the value\r\n */\r\n public getValue(host: AdvancedDynamicTexture): number {\r\n if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {\r\n var width: number = 0;\r\n var height: number = 0;\r\n\r\n if (host.idealWidth) {\r\n width = (this._value * host.getSize().width) / host.idealWidth;\r\n }\r\n\r\n if (host.idealHeight) {\r\n height = (this._value * host.getSize().height) / host.idealHeight;\r\n }\r\n\r\n if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {\r\n return window.innerWidth < window.innerHeight ? width : height;\r\n }\r\n\r\n if (host.idealWidth) { // horizontal\r\n return width;\r\n }\r\n\r\n if (host.idealHeight) { // vertical\r\n return height;\r\n }\r\n }\r\n return this._value;\r\n }\r\n\r\n /**\r\n * Gets a string representation of the value\r\n * @param host defines the root host\r\n * @param decimals defines an optional number of decimals to display\r\n * @returns a string\r\n */\r\n public toString(host: AdvancedDynamicTexture, decimals?: number): string {\r\n switch (this._unit) {\r\n case ValueAndUnit.UNITMODE_PERCENTAGE:\r\n let percentage = this.getValue(host) * 100;\r\n return (decimals ? percentage.toFixed(decimals) : percentage) + \"%\";\r\n case ValueAndUnit.UNITMODE_PIXEL:\r\n let pixels = this.getValue(host);\r\n return (decimals ? pixels.toFixed(decimals) : pixels) + \"px\";\r\n }\r\n\r\n return this._unit.toString();\r\n }\r\n\r\n /**\r\n * Store a value parsed from a string\r\n * @param source defines the source string\r\n * @returns true if the value was successfully parsed and updated\r\n */\r\n public fromString(source: string | number): boolean {\r\n var match = ValueAndUnit._Regex.exec(source.toString());\r\n\r\n if (!match || match.length === 0) {\r\n return false;\r\n }\r\n\r\n var sourceValue = parseFloat(match[1]);\r\n var sourceUnit = this._originalUnit;\r\n\r\n if (!this.negativeValueAllowed) {\r\n if (sourceValue < 0) {\r\n sourceValue = 0;\r\n }\r\n }\r\n\r\n if (match.length === 4) {\r\n switch (match[3]) {\r\n case \"px\":\r\n sourceUnit = ValueAndUnit.UNITMODE_PIXEL;\r\n break;\r\n case \"%\":\r\n sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;\r\n sourceValue /= 100.0;\r\n break;\r\n }\r\n }\r\n\r\n if (sourceValue === this._value && sourceUnit === this._unit) {\r\n return false;\r\n }\r\n\r\n this._value = sourceValue;\r\n this._unit = sourceUnit;\r\n this.onChangedObservable.notifyObservers();\r\n\r\n return true;\r\n }\r\n\r\n // Static\r\n private static _Regex = /(^-?\\d*(\\.\\d+)?)(%|px)?/;\r\n private static _UNITMODE_PERCENTAGE = 0;\r\n private static _UNITMODE_PIXEL = 1;\r\n\r\n /** UNITMODE_PERCENTAGE */\r\n public static get UNITMODE_PERCENTAGE(): number {\r\n return ValueAndUnit._UNITMODE_PERCENTAGE;\r\n }\r\n\r\n /** UNITMODE_PIXEL */\r\n public static get UNITMODE_PIXEL(): number {\r\n return ValueAndUnit._UNITMODE_PIXEL;\r\n }\r\n}"]}
@@ -55,12 +55,19 @@ var Button3D = /** @class */ (function (_super) {
55
55
  for (var i = 0; i < 6; i++) {
56
56
  faceUV[i] = new Vector4(0, 0, 0, 0);
57
57
  }
58
- faceUV[1] = new Vector4(0, 0, 1, 1);
58
+ if (scene.useRightHandedSystem) {
59
+ // Flip the u on the texture
60
+ faceUV[0].copyFromFloats(1, 0, 0, 1);
61
+ }
62
+ else {
63
+ faceUV[1].copyFromFloats(0, 0, 1, 1);
64
+ }
59
65
  var mesh = CreateBox(this.name + "_rootMesh", {
60
66
  width: 1.0,
61
67
  height: 1.0,
62
68
  depth: 0.08,
63
69
  faceUV: faceUV,
70
+ wrap: true,
64
71
  }, scene);
65
72
  return mesh;
66
73
  };