@babylonjs/gui 7.34.4 → 7.35.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. package/2D/FrameGraph/guiTask.js.map +1 -1
  2. package/2D/FrameGraph/renderGraphGUIBlock.js.map +1 -1
  3. package/2D/adtInstrumentation.js.map +1 -1
  4. package/2D/advancedDynamicTexture.d.ts +1 -1
  5. package/2D/advancedDynamicTexture.js.map +1 -1
  6. package/2D/controls/button.js.map +1 -1
  7. package/2D/controls/checkbox.js.map +1 -1
  8. package/2D/controls/colorpicker.js.map +1 -1
  9. package/2D/controls/container.js.map +1 -1
  10. package/2D/controls/control.js.map +1 -1
  11. package/2D/controls/displayGrid.js.map +1 -1
  12. package/2D/controls/ellipse.js.map +1 -1
  13. package/2D/controls/focusableButton.js.map +1 -1
  14. package/2D/controls/gradient/BaseGradient.js.map +1 -1
  15. package/2D/controls/grid.js.map +1 -1
  16. package/2D/controls/image.js.map +1 -1
  17. package/2D/controls/inputPassword.js.map +1 -1
  18. package/2D/controls/inputText.js.map +1 -1
  19. package/2D/controls/inputTextArea.js.map +1 -1
  20. package/2D/controls/line.js.map +1 -1
  21. package/2D/controls/multiLine.js.map +1 -1
  22. package/2D/controls/radioButton.js.map +1 -1
  23. package/2D/controls/rectangle.js.map +1 -1
  24. package/2D/controls/scrollViewers/scrollViewer.js.map +1 -1
  25. package/2D/controls/scrollViewers/scrollViewerWindow.js.map +1 -1
  26. package/2D/controls/selector.js.map +1 -1
  27. package/2D/controls/sliders/baseSlider.js.map +1 -1
  28. package/2D/controls/sliders/imageBasedSlider.js.map +1 -1
  29. package/2D/controls/sliders/imageScrollBar.js.map +1 -1
  30. package/2D/controls/sliders/scrollBar.js.map +1 -1
  31. package/2D/controls/sliders/slider.js.map +1 -1
  32. package/2D/controls/stackPanel.js.map +1 -1
  33. package/2D/controls/statics.js.map +1 -1
  34. package/2D/controls/textBlock.js.map +1 -1
  35. package/2D/controls/textWrapper.js.map +1 -1
  36. package/2D/controls/toggleButton.js.map +1 -1
  37. package/2D/controls/virtualKeyboard.js.map +1 -1
  38. package/2D/math2D.js.map +1 -1
  39. package/2D/measure.js.map +1 -1
  40. package/2D/multiLinePoint.js.map +1 -1
  41. package/2D/style.js.map +1 -1
  42. package/2D/valueAndUnit.js.map +1 -1
  43. package/2D/xmlLoader.js.map +1 -1
  44. package/3D/behaviors/defaultBehavior.js.map +1 -1
  45. package/3D/controls/MRTK3/touchHolographicButton.js.map +1 -1
  46. package/3D/controls/button3D.js.map +1 -1
  47. package/3D/controls/container3D.js.map +1 -1
  48. package/3D/controls/contentDisplay3D.js.map +1 -1
  49. package/3D/controls/control3D.js.map +1 -1
  50. package/3D/controls/cylinderPanel.js.map +1 -1
  51. package/3D/controls/holographicBackplate.js.map +1 -1
  52. package/3D/controls/holographicButton.js.map +1 -1
  53. package/3D/controls/holographicSlate.js.map +1 -1
  54. package/3D/controls/meshButton3D.js.map +1 -1
  55. package/3D/controls/nearMenu.js.map +1 -1
  56. package/3D/controls/planePanel.js.map +1 -1
  57. package/3D/controls/scatterPanel.js.map +1 -1
  58. package/3D/controls/slider3D.js.map +1 -1
  59. package/3D/controls/spherePanel.js.map +1 -1
  60. package/3D/controls/stackPanel3D.js.map +1 -1
  61. package/3D/controls/touchButton3D.js.map +1 -1
  62. package/3D/controls/touchHolographicButton.js.map +1 -1
  63. package/3D/controls/touchHolographicMenu.js.map +1 -1
  64. package/3D/controls/touchMeshButton3D.js.map +1 -1
  65. package/3D/controls/volumeBasedPanel.js.map +1 -1
  66. package/3D/gizmos/gizmoHandle.js.map +1 -1
  67. package/3D/gizmos/slateGizmo.js.map +1 -1
  68. package/3D/gui3DManager.js.map +1 -1
  69. package/3D/materials/fluent/fluentMaterial.js.map +1 -1
  70. package/3D/materials/fluentBackplate/fluentBackplateMaterial.js.map +1 -1
  71. package/3D/materials/fluentButton/fluentButtonMaterial.js.map +1 -1
  72. package/3D/materials/handle/handleMaterial.js.map +1 -1
  73. package/3D/materials/mrdl/mrdlBackglowMaterial.js.map +1 -1
  74. package/3D/materials/mrdl/mrdlBackplateMaterial.js.map +1 -1
  75. package/3D/materials/mrdl/mrdlFrontplateMaterial.js.map +1 -1
  76. package/3D/materials/mrdl/mrdlInnerquadMaterial.js.map +1 -1
  77. package/3D/materials/mrdl/mrdlSliderBarMaterial.js.map +1 -1
  78. package/3D/materials/mrdl/mrdlSliderThumbMaterial.js.map +1 -1
  79. package/legacy/legacy.js.map +1 -1
  80. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"virtualKeyboard.js","sourceRoot":"","sources":["../../../../../dev/gui/src/2D/controls/virtualKeyboard.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIlC,OAAO,EAAE,aAAa,EAAE,0CAA4B;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD;;GAEG;AACH,MAAM,OAAO,cAAc;CAiB1B;AAQD;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAA/C;;QACI,8CAA8C;QACvC,yBAAoB,GAAG,IAAI,UAAU,EAAU,CAAC;QAEvD,4CAA4C;QACrC,uBAAkB,GAAG,MAAM,CAAC;QACnC,6CAA6C;QACtC,wBAAmB,GAAG,MAAM,CAAC;QAEpC,mDAAmD;QAC5C,6BAAwB,GAAG,KAAK,CAAC;QACxC,oDAAoD;QAC7C,8BAAyB,GAAG,KAAK,CAAC;QACzC,kDAAkD;QAC3C,4BAAuB,GAAG,KAAK,CAAC;QACvC,qDAAqD;QAC9C,+BAA0B,GAAG,KAAK,CAAC;QAE1C,uDAAuD;QAChD,uBAAkB,GAAG,MAAM,CAAC;QACnC,uDAAuD;QAChD,4BAAuB,GAAG,SAAS,CAAC;QAE3C,iDAAiD;QAC1C,qBAAgB,GAAG,SAAS,CAAC;QACpC,yCAAyC;QACl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AE,eAAe,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport { Observable } from \"core/Misc/observable\";\r\n\r\nimport { StackPanel } from \"./stackPanel\";\r\nimport { Button } from \"./button\";\r\nimport type { Container } from \"./container\";\r\nimport type { TextBlock } from \"./textBlock\";\r\nimport type { InputText } from \"./inputText\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport type { AdvancedDynamicTexture } from \"../advancedDynamicTexture\";\r\nimport { InputTextArea } from \"./inputTextArea\";\r\nimport type { Control } from \"./control\";\r\n\r\n/**\r\n * Class used to store key control properties\r\n */\r\nexport class KeyPropertySet {\r\n /** Width */\r\n width?: string;\r\n /** Height */\r\n height?: string;\r\n /** Left padding */\r\n paddingLeft?: string;\r\n /** Right padding */\r\n paddingRight?: string;\r\n /** Top padding */\r\n paddingTop?: string;\r\n /** Bottom padding */\r\n paddingBottom?: string;\r\n /** Foreground color */\r\n color?: string;\r\n /** Background color */\r\n background?: string;\r\n}\r\n\r\ntype ConnectedInputText = {\r\n input: InputText;\r\n onFocusObserver: Nullable<Observer<Control>>;\r\n onBlurObserver: Nullable<Observer<Control>>;\r\n};\r\n\r\n/**\r\n * Class used to create virtual keyboard\r\n */\r\nexport class VirtualKeyboard extends StackPanel {\r\n /** Observable raised when a key is pressed */\r\n public onKeyPressObservable = new Observable<string>();\r\n\r\n /** Gets or sets default key button width */\r\n public defaultButtonWidth = \"40px\";\r\n /** Gets or sets default key button height */\r\n public defaultButtonHeight = \"40px\";\r\n\r\n /** Gets or sets default key button left padding */\r\n public defaultButtonPaddingLeft = \"2px\";\r\n /** Gets or sets default key button right padding */\r\n public defaultButtonPaddingRight = \"2px\";\r\n /** Gets or sets default key button top padding */\r\n public defaultButtonPaddingTop = \"2px\";\r\n /** Gets or sets default key button bottom padding */\r\n public defaultButtonPaddingBottom = \"2px\";\r\n\r\n /** Gets or sets default key button foreground color */\r\n public defaultButtonColor = \"#DDD\";\r\n /** Gets or sets default key button background color */\r\n public defaultButtonBackground = \"#070707\";\r\n\r\n /** Gets or sets shift button foreground color */\r\n public shiftButtonColor = \"#7799FF\";\r\n /** Gets or sets shift button thickness*/\r\n public selectedShiftThickness = 1;\r\n\r\n /** Gets shift key state */\r\n public shiftState = 0;\r\n\r\n protected override _getTypeName(): string {\r\n return \"VirtualKeyboard\";\r\n }\r\n\r\n private _createKey(key: string, propertySet: Nullable<KeyPropertySet>) {\r\n const button = Button.CreateSimpleButton(key, key);\r\n\r\n button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;\r\n button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;\r\n button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;\r\n button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;\r\n button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;\r\n button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;\r\n button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;\r\n button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;\r\n\r\n button.thickness = 0;\r\n button.isFocusInvisible = true;\r\n\r\n button.shadowColor = this.shadowColor;\r\n button.shadowBlur = this.shadowBlur;\r\n button.shadowOffsetX = this.shadowOffsetX;\r\n button.shadowOffsetY = this.shadowOffsetY;\r\n\r\n button.onPointerUpObservable.add(() => {\r\n this.onKeyPressObservable.notifyObservers(key);\r\n });\r\n\r\n return button;\r\n }\r\n\r\n /**\r\n * Adds a new row of keys\r\n * @param keys defines the list of keys to add\r\n * @param propertySets defines the associated property sets\r\n */\r\n public addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void {\r\n const panel = new StackPanel();\r\n panel.isVertical = false;\r\n panel.isFocusInvisible = true;\r\n\r\n let maxKey: Nullable<Button> = null;\r\n for (let i = 0; i < keys.length; i++) {\r\n let properties = null;\r\n\r\n if (propertySets && propertySets.length === keys.length) {\r\n properties = propertySets[i];\r\n }\r\n\r\n const key = this._createKey(keys[i], properties);\r\n if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {\r\n maxKey = key;\r\n }\r\n\r\n panel.addControl(key);\r\n }\r\n\r\n panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;\r\n\r\n this.addControl(panel);\r\n }\r\n\r\n /**\r\n * Set the shift key to a specific state\r\n * @param shiftState defines the new shift state\r\n */\r\n public applyShiftState(shiftState: number): void {\r\n if (!this.children) {\r\n return;\r\n }\r\n\r\n for (let i = 0; i < this.children.length; i++) {\r\n const row = this.children[i];\r\n if (!row || !(<Container>row).children) {\r\n continue;\r\n }\r\n\r\n const rowContainer = <Container>row;\r\n for (let j = 0; j < rowContainer.children.length; j++) {\r\n const button = rowContainer.children[j] as Button;\r\n\r\n if (!button || !button.children[0]) {\r\n continue;\r\n }\r\n\r\n const button_tblock = button.children[0] as TextBlock;\r\n\r\n if (button_tblock.text === \"\\u21E7\") {\r\n button.color = shiftState ? this.shiftButtonColor : this.defaultButtonColor;\r\n button.thickness = shiftState > 1 ? this.selectedShiftThickness : 0;\r\n }\r\n\r\n button_tblock.text = shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase();\r\n }\r\n }\r\n }\r\n\r\n private _currentlyConnectedInputText: Nullable<InputText | InputTextArea> = null;\r\n private _connectedInputTexts: ConnectedInputText[] = [];\r\n private _onKeyPressObserver: Nullable<Observer<string>> = null;\r\n\r\n /** Gets the input text control currently attached to the keyboard */\r\n public get connectedInputText(): Nullable<InputText | InputTextArea> {\r\n return this._currentlyConnectedInputText;\r\n }\r\n\r\n /**\r\n * Connects the keyboard with an input text control\r\n *\r\n * @param input defines the target control\r\n */\r\n public connect(input: InputText): void {\r\n const inputTextAlreadyConnected = this._connectedInputTexts.some((a) => a.input === input);\r\n if (inputTextAlreadyConnected) {\r\n return;\r\n }\r\n\r\n if (this._onKeyPressObserver === null) {\r\n this._onKeyPressObserver = this.onKeyPressObservable.add((key) => {\r\n if (!this._currentlyConnectedInputText) {\r\n return;\r\n }\r\n\r\n this._currentlyConnectedInputText._host.focusedControl = this._currentlyConnectedInputText;\r\n\r\n switch (key) {\r\n case \"\\u21E7\":\r\n this.shiftState++;\r\n if (this.shiftState > 2) {\r\n this.shiftState = 0;\r\n }\r\n this.applyShiftState(this.shiftState);\r\n return;\r\n case \"\\u2190\":\r\n if (this._currentlyConnectedInputText instanceof InputTextArea) {\r\n this._currentlyConnectedInputText.alternativeProcessKey(\"Backspace\");\r\n } else {\r\n this._currentlyConnectedInputText.processKey(8);\r\n }\r\n return;\r\n case \"\\u21B5\":\r\n if (this._currentlyConnectedInputText instanceof InputTextArea) {\r\n this._currentlyConnectedInputText.alternativeProcessKey(\"Enter\");\r\n } else {\r\n this._currentlyConnectedInputText.processKey(13);\r\n }\r\n return;\r\n }\r\n if (this._currentlyConnectedInputText instanceof InputTextArea) {\r\n this._currentlyConnectedInputText.alternativeProcessKey(\"\", this.shiftState ? key.toUpperCase() : key);\r\n } else {\r\n this._currentlyConnectedInputText.processKey(-1, this.shiftState ? key.toUpperCase() : key);\r\n }\r\n\r\n if (this.shiftState === 1) {\r\n this.shiftState = 0;\r\n this.applyShiftState(this.shiftState);\r\n }\r\n });\r\n }\r\n\r\n this.isVisible = false;\r\n this._currentlyConnectedInputText = input;\r\n input._connectedVirtualKeyboard = this;\r\n\r\n // Events hooking\r\n const onFocusObserver: Nullable<Observer<Control>> = input.onFocusObservable.add(() => {\r\n this._currentlyConnectedInputText = input;\r\n input._connectedVirtualKeyboard = this;\r\n this.isVisible = true;\r\n });\r\n\r\n const onBlurObserver: Nullable<Observer<Control>> = input.onBlurObservable.add(() => {\r\n input._connectedVirtualKeyboard = null;\r\n this._currentlyConnectedInputText = null;\r\n this.isVisible = false;\r\n });\r\n\r\n this._connectedInputTexts.push({\r\n input,\r\n onBlurObserver,\r\n onFocusObserver,\r\n });\r\n }\r\n\r\n /**\r\n * Disconnects the keyboard from connected InputText controls\r\n *\r\n * @param input optionally defines a target control, otherwise all are disconnected\r\n */\r\n public disconnect(input?: InputText): void {\r\n if (input) {\r\n // .find not available on IE\r\n const filtered = this._connectedInputTexts.filter((a) => a.input === input);\r\n if (filtered.length === 1) {\r\n this._removeConnectedInputObservables(filtered[0]);\r\n\r\n this._connectedInputTexts = this._connectedInputTexts.filter((a) => a.input !== input);\r\n if (this._currentlyConnectedInputText === input) {\r\n this._currentlyConnectedInputText = null;\r\n }\r\n }\r\n } else {\r\n this._connectedInputTexts.forEach((connectedInputText: ConnectedInputText) => {\r\n this._removeConnectedInputObservables(connectedInputText);\r\n });\r\n this._connectedInputTexts.length = 0;\r\n }\r\n\r\n if (this._connectedInputTexts.length === 0) {\r\n this._currentlyConnectedInputText = null;\r\n this.onKeyPressObservable.remove(this._onKeyPressObserver);\r\n this._onKeyPressObserver = null;\r\n }\r\n }\r\n\r\n private _removeConnectedInputObservables(connectedInputText: ConnectedInputText): void {\r\n connectedInputText.input._connectedVirtualKeyboard = null;\r\n connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);\r\n connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public override dispose(): void {\r\n super.dispose();\r\n\r\n this.disconnect();\r\n }\r\n\r\n // Statics\r\n\r\n /**\r\n * Creates a new keyboard using a default layout\r\n *\r\n * @param name defines control name\r\n * @returns a new VirtualKeyboard\r\n */\r\n public static CreateDefaultLayout(name?: string): VirtualKeyboard {\r\n const returnValue = new VirtualKeyboard(name);\r\n\r\n returnValue.addKeysRow([\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"0\", \"\\u2190\"]);\r\n returnValue.addKeysRow([\"q\", \"w\", \"e\", \"r\", \"t\", \"y\", \"u\", \"i\", \"o\", \"p\"]);\r\n returnValue.addKeysRow([\"a\", \"s\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \";\", \"'\", \"\\u21B5\"]);\r\n returnValue.addKeysRow([\"\\u21E7\", \"z\", \"x\", \"c\", \"v\", \"b\", \"n\", \"m\", \",\", \".\", \"/\"]);\r\n returnValue.addKeysRow([\" \"], [{ width: \"200px\" }]);\r\n\r\n return returnValue;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture) {\r\n super._parseFromContent(serializedObject, host);\r\n for (const row of this.children) {\r\n if (row.getClassName() === \"StackPanel\") {\r\n const stackPanel = row as StackPanel;\r\n for (const key of stackPanel.children) {\r\n if (key.getClassName() === \"Button\" && key.name) {\r\n key.onPointerUpObservable.add(() => {\r\n this.onKeyPressObservable.notifyObservers(key.name as string);\r\n });\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GUI.VirtualKeyboard\", VirtualKeyboard);\r\n"]}
1
+ {"version":3,"file":"virtualKeyboard.js","sourceRoot":"","sources":["../../../../../dev/gui/src/2D/controls/virtualKeyboard.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIlC,OAAO,EAAE,aAAa,EAAE,0CAA4B;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD;;GAEG;AACH,MAAM,OAAO,cAAc;CAiB1B;AAQD;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAA/C;;QACI,8CAA8C;QACvC,yBAAoB,GAAG,IAAI,UAAU,EAAU,CAAC;QAEvD,4CAA4C;QACrC,uBAAkB,GAAG,MAAM,CAAC;QACnC,6CAA6C;QACtC,wBAAmB,GAAG,MAAM,CAAC;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pD,OAAO,WAAW,CAAC;IACvB,CAAC;IAED;;OAEG;IACa,iBAAiB,CAAC,gBAAqB,EAAE,IAA4B;QACjF,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;QAChD,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC9B,IAAI,GAAG,CAAC,YAAY,EAAE,KAAK,YAAY,EAAE,CAAC;gBACtC,MAAM,UAAU,GAAG,GAAiB,CAAC;gBACrC,KAAK,MAAM,GAAG,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;oBACpC,IAAI,GAAG,CAAC,YAAY,EAAE,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;wBAC9C,GAAG,CAAC,qBAAqB,CAAC,GAAG,CAAC,GAAG,EAAE;4BAC/B,IAAI,CAAC,oBAAoB,CAAC,eAAe,CAAC,GAAG,CAAC,IAAc,CAAC,CAAC;wBAClE,CAAC,CAAC,CAAC;oBACP,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;CACJ;AAED,aAAa,CAAC,6BAA6B,EAAE,eAAe,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport { Observable } from \"core/Misc/observable\";\r\n\r\nimport { StackPanel } from \"./stackPanel\";\r\nimport { Button } from \"./button\";\r\nimport type { Container } from \"./container\";\r\nimport type { TextBlock } from \"./textBlock\";\r\nimport type { InputText } from \"./inputText\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport type { AdvancedDynamicTexture } from \"../advancedDynamicTexture\";\r\nimport { InputTextArea } from \"./inputTextArea\";\r\nimport type { Control } from \"./control\";\r\n\r\n/**\r\n * Class used to store key control properties\r\n */\r\nexport class KeyPropertySet {\r\n /** Width */\r\n width?: string;\r\n /** Height */\r\n height?: string;\r\n /** Left padding */\r\n paddingLeft?: string;\r\n /** Right padding */\r\n paddingRight?: string;\r\n /** Top padding */\r\n paddingTop?: string;\r\n /** Bottom padding */\r\n paddingBottom?: string;\r\n /** Foreground color */\r\n color?: string;\r\n /** Background color */\r\n background?: string;\r\n}\r\n\r\ntype ConnectedInputText = {\r\n input: InputText;\r\n onFocusObserver: Nullable<Observer<Control>>;\r\n onBlurObserver: Nullable<Observer<Control>>;\r\n};\r\n\r\n/**\r\n * Class used to create virtual keyboard\r\n */\r\nexport class VirtualKeyboard extends StackPanel {\r\n /** Observable raised when a key is pressed */\r\n public onKeyPressObservable = new Observable<string>();\r\n\r\n /** Gets or sets default key button width */\r\n public defaultButtonWidth = \"40px\";\r\n /** Gets or sets default key button height */\r\n public defaultButtonHeight = \"40px\";\r\n\r\n /** Gets or sets default key button left padding */\r\n public defaultButtonPaddingLeft = \"2px\";\r\n /** Gets or sets default key button right padding */\r\n public defaultButtonPaddingRight = \"2px\";\r\n /** Gets or sets default key button top padding */\r\n public defaultButtonPaddingTop = \"2px\";\r\n /** Gets or sets default key button bottom padding */\r\n public defaultButtonPaddingBottom = \"2px\";\r\n\r\n /** Gets or sets default key button foreground color */\r\n public defaultButtonColor = \"#DDD\";\r\n /** Gets or sets default key button background color */\r\n public defaultButtonBackground = \"#070707\";\r\n\r\n /** Gets or sets shift button foreground color */\r\n public shiftButtonColor = \"#7799FF\";\r\n /** Gets or sets shift button thickness*/\r\n public selectedShiftThickness = 1;\r\n\r\n /** Gets shift key state */\r\n public shiftState = 0;\r\n\r\n protected override _getTypeName(): string {\r\n return \"VirtualKeyboard\";\r\n }\r\n\r\n private _createKey(key: string, propertySet: Nullable<KeyPropertySet>) {\r\n const button = Button.CreateSimpleButton(key, key);\r\n\r\n button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;\r\n button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;\r\n button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;\r\n button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;\r\n button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;\r\n button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;\r\n button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;\r\n button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;\r\n\r\n button.thickness = 0;\r\n button.isFocusInvisible = true;\r\n\r\n button.shadowColor = this.shadowColor;\r\n button.shadowBlur = this.shadowBlur;\r\n button.shadowOffsetX = this.shadowOffsetX;\r\n button.shadowOffsetY = this.shadowOffsetY;\r\n\r\n button.onPointerUpObservable.add(() => {\r\n this.onKeyPressObservable.notifyObservers(key);\r\n });\r\n\r\n return button;\r\n }\r\n\r\n /**\r\n * Adds a new row of keys\r\n * @param keys defines the list of keys to add\r\n * @param propertySets defines the associated property sets\r\n */\r\n public addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void {\r\n const panel = new StackPanel();\r\n panel.isVertical = false;\r\n panel.isFocusInvisible = true;\r\n\r\n let maxKey: Nullable<Button> = null;\r\n for (let i = 0; i < keys.length; i++) {\r\n let properties = null;\r\n\r\n if (propertySets && propertySets.length === keys.length) {\r\n properties = propertySets[i];\r\n }\r\n\r\n const key = this._createKey(keys[i], properties);\r\n if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {\r\n maxKey = key;\r\n }\r\n\r\n panel.addControl(key);\r\n }\r\n\r\n panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;\r\n\r\n this.addControl(panel);\r\n }\r\n\r\n /**\r\n * Set the shift key to a specific state\r\n * @param shiftState defines the new shift state\r\n */\r\n public applyShiftState(shiftState: number): void {\r\n if (!this.children) {\r\n return;\r\n }\r\n\r\n for (let i = 0; i < this.children.length; i++) {\r\n const row = this.children[i];\r\n if (!row || !(<Container>row).children) {\r\n continue;\r\n }\r\n\r\n const rowContainer = <Container>row;\r\n for (let j = 0; j < rowContainer.children.length; j++) {\r\n const button = rowContainer.children[j] as Button;\r\n\r\n if (!button || !button.children[0]) {\r\n continue;\r\n }\r\n\r\n const button_tblock = button.children[0] as TextBlock;\r\n\r\n if (button_tblock.text === \"\\u21E7\") {\r\n button.color = shiftState ? this.shiftButtonColor : this.defaultButtonColor;\r\n button.thickness = shiftState > 1 ? this.selectedShiftThickness : 0;\r\n }\r\n\r\n button_tblock.text = shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase();\r\n }\r\n }\r\n }\r\n\r\n private _currentlyConnectedInputText: Nullable<InputText | InputTextArea> = null;\r\n private _connectedInputTexts: ConnectedInputText[] = [];\r\n private _onKeyPressObserver: Nullable<Observer<string>> = null;\r\n\r\n /** Gets the input text control currently attached to the keyboard */\r\n public get connectedInputText(): Nullable<InputText | InputTextArea> {\r\n return this._currentlyConnectedInputText;\r\n }\r\n\r\n /**\r\n * Connects the keyboard with an input text control\r\n *\r\n * @param input defines the target control\r\n */\r\n public connect(input: InputText): void {\r\n const inputTextAlreadyConnected = this._connectedInputTexts.some((a) => a.input === input);\r\n if (inputTextAlreadyConnected) {\r\n return;\r\n }\r\n\r\n if (this._onKeyPressObserver === null) {\r\n this._onKeyPressObserver = this.onKeyPressObservable.add((key) => {\r\n if (!this._currentlyConnectedInputText) {\r\n return;\r\n }\r\n\r\n this._currentlyConnectedInputText._host.focusedControl = this._currentlyConnectedInputText;\r\n\r\n switch (key) {\r\n case \"\\u21E7\":\r\n this.shiftState++;\r\n if (this.shiftState > 2) {\r\n this.shiftState = 0;\r\n }\r\n this.applyShiftState(this.shiftState);\r\n return;\r\n case \"\\u2190\":\r\n if (this._currentlyConnectedInputText instanceof InputTextArea) {\r\n this._currentlyConnectedInputText.alternativeProcessKey(\"Backspace\");\r\n } else {\r\n this._currentlyConnectedInputText.processKey(8);\r\n }\r\n return;\r\n case \"\\u21B5\":\r\n if (this._currentlyConnectedInputText instanceof InputTextArea) {\r\n this._currentlyConnectedInputText.alternativeProcessKey(\"Enter\");\r\n } else {\r\n this._currentlyConnectedInputText.processKey(13);\r\n }\r\n return;\r\n }\r\n if (this._currentlyConnectedInputText instanceof InputTextArea) {\r\n this._currentlyConnectedInputText.alternativeProcessKey(\"\", this.shiftState ? key.toUpperCase() : key);\r\n } else {\r\n this._currentlyConnectedInputText.processKey(-1, this.shiftState ? key.toUpperCase() : key);\r\n }\r\n\r\n if (this.shiftState === 1) {\r\n this.shiftState = 0;\r\n this.applyShiftState(this.shiftState);\r\n }\r\n });\r\n }\r\n\r\n this.isVisible = false;\r\n this._currentlyConnectedInputText = input;\r\n input._connectedVirtualKeyboard = this;\r\n\r\n // Events hooking\r\n const onFocusObserver: Nullable<Observer<Control>> = input.onFocusObservable.add(() => {\r\n this._currentlyConnectedInputText = input;\r\n input._connectedVirtualKeyboard = this;\r\n this.isVisible = true;\r\n });\r\n\r\n const onBlurObserver: Nullable<Observer<Control>> = input.onBlurObservable.add(() => {\r\n input._connectedVirtualKeyboard = null;\r\n this._currentlyConnectedInputText = null;\r\n this.isVisible = false;\r\n });\r\n\r\n this._connectedInputTexts.push({\r\n input,\r\n onBlurObserver,\r\n onFocusObserver,\r\n });\r\n }\r\n\r\n /**\r\n * Disconnects the keyboard from connected InputText controls\r\n *\r\n * @param input optionally defines a target control, otherwise all are disconnected\r\n */\r\n public disconnect(input?: InputText): void {\r\n if (input) {\r\n // .find not available on IE\r\n const filtered = this._connectedInputTexts.filter((a) => a.input === input);\r\n if (filtered.length === 1) {\r\n this._removeConnectedInputObservables(filtered[0]);\r\n\r\n this._connectedInputTexts = this._connectedInputTexts.filter((a) => a.input !== input);\r\n if (this._currentlyConnectedInputText === input) {\r\n this._currentlyConnectedInputText = null;\r\n }\r\n }\r\n } else {\r\n this._connectedInputTexts.forEach((connectedInputText: ConnectedInputText) => {\r\n this._removeConnectedInputObservables(connectedInputText);\r\n });\r\n this._connectedInputTexts.length = 0;\r\n }\r\n\r\n if (this._connectedInputTexts.length === 0) {\r\n this._currentlyConnectedInputText = null;\r\n this.onKeyPressObservable.remove(this._onKeyPressObserver);\r\n this._onKeyPressObserver = null;\r\n }\r\n }\r\n\r\n private _removeConnectedInputObservables(connectedInputText: ConnectedInputText): void {\r\n connectedInputText.input._connectedVirtualKeyboard = null;\r\n connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);\r\n connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public override dispose(): void {\r\n super.dispose();\r\n\r\n this.disconnect();\r\n }\r\n\r\n // Statics\r\n\r\n /**\r\n * Creates a new keyboard using a default layout\r\n *\r\n * @param name defines control name\r\n * @returns a new VirtualKeyboard\r\n */\r\n public static CreateDefaultLayout(name?: string): VirtualKeyboard {\r\n const returnValue = new VirtualKeyboard(name);\r\n\r\n returnValue.addKeysRow([\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"0\", \"\\u2190\"]);\r\n returnValue.addKeysRow([\"q\", \"w\", \"e\", \"r\", \"t\", \"y\", \"u\", \"i\", \"o\", \"p\"]);\r\n returnValue.addKeysRow([\"a\", \"s\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \";\", \"'\", \"\\u21B5\"]);\r\n returnValue.addKeysRow([\"\\u21E7\", \"z\", \"x\", \"c\", \"v\", \"b\", \"n\", \"m\", \",\", \".\", \"/\"]);\r\n returnValue.addKeysRow([\" \"], [{ width: \"200px\" }]);\r\n\r\n return returnValue;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture) {\r\n super._parseFromContent(serializedObject, host);\r\n for (const row of this.children) {\r\n if (row.getClassName() === \"StackPanel\") {\r\n const stackPanel = row as StackPanel;\r\n for (const key of stackPanel.children) {\r\n if (key.getClassName() === \"Button\" && key.name) {\r\n key.onPointerUpObservable.add(() => {\r\n this.onKeyPressObservable.notifyObservers(key.name as string);\r\n });\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GUI.VirtualKeyboard\", VirtualKeyboard);\r\n"]}
package/2D/math2D.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"math2D.js","sourceRoot":"","sources":["../../../../dev/gui/src/2D/math2D.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,6CAA+B;AACjD,OAAO,EAAE,OAAO,EAAE,gDAAkC;AAEpD;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,OAAO;IACxC;;;;OAIG;IACH,YACI,MAAe;IACf,6CAA6C;IACtC,cAAsB,CAAC;QAE9B,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;QAFnB,gBAAW,GAAX,WAAW,CAAY;IAGlC,CAAC;CACJ;AAED,+CAA+C;AAC/C,MAAM,OAAO,QAAQ;IAIjB;;;;;;;;OAQG;IACH,YAAY,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;IACI,UAAU,CAAC,GAAW,EAAE,GAAW,EAAE,GAAW,EAAE,GAAW,EAAE,GAAW,EAAE,GAAW;QAC1F,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,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9D;aAAM;YACH,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAC;SACrF;IACL,CAAC;;AAnCc,kCAAyB,GAAG,QAAQ,CAAC,QAAQ,EAAE,AAAtB,CAAuB;AAChD,mCAA0B,GAAG,QAAQ,CAAC,QAAQ,EAAE,AAAtB,CAAuB;AACjD,4BAAmB,GAAG,QAAQ,CAAC,QAAQ,EAAE,AAAtB,CAAuB;AAC1C,2BAAkB,GAAG,QAAQ,CAAC,QAAQ,EAAE,AAAtB,CAAuB;AACzC,sBAAa,GAAG,QAAQ,CAAC,QAAQ,EAAE,AAAtB,CAAuB;AACpC,sBAAa,GAAG,QAAQ,CAAC,QAAQ,EAAE,AAAtB,CAAuB;AACpC,sBAAa,GAAG,QAAQ,CAAC,QAAQ,EAAE,AAAtB,CAAuB;AAgCvD;;GAEG;AACH,MAAM,OAAO,SAAS;IASlB;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,KAAa,EAAE,YAAoB,SAAS,CAAC,wBAAwB;QACrF,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;IACrD,CAAC;;AAhBD;;;;;GAKG;AACW,kCAAwB,GAAG,GAAG,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Vector2 } from \"core/Maths/math.vector\";\r\nimport { Epsilon } from \"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(\r\n source: Vector2,\r\n /** defines the current mouse button index */\r\n public buttonIndex: number = 0\r\n ) {\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;\r\n this.m[1] = m01;\r\n this.m[2] = m10;\r\n this.m[3] = m11;\r\n this.m[4] = m20;\r\n 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 const l0 = this.m[0];\r\n const l1 = this.m[1];\r\n const l2 = this.m[2];\r\n const l3 = this.m[3];\r\n const l4 = this.m[4];\r\n const l5 = this.m[5];\r\n\r\n const det = this.determinant();\r\n if (det < Epsilon * Epsilon) {\r\n result.m[0] = 0;\r\n result.m[1] = 0;\r\n result.m[2] = 0;\r\n result.m[3] = 0;\r\n result.m[4] = 0;\r\n result.m[5] = 0;\r\n return this;\r\n }\r\n\r\n const detDiv = 1 / det;\r\n\r\n const det4 = l2 * l5 - l3 * l4;\r\n const det5 = l1 * l4 - l0 * l5;\r\n\r\n result.m[0] = l3 * detDiv;\r\n result.m[1] = -l1 * detDiv;\r\n result.m[2] = -l2 * detDiv;\r\n result.m[3] = l0 * detDiv;\r\n result.m[4] = det4 * detDiv;\r\n 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 const l0 = this.m[0];\r\n const l1 = this.m[1];\r\n const l2 = this.m[2];\r\n const l3 = this.m[3];\r\n const l4 = this.m[4];\r\n const l5 = this.m[5];\r\n\r\n const r0 = other.m[0];\r\n const r1 = other.m[1];\r\n const r2 = other.m[2];\r\n const r3 = other.m[3];\r\n const r4 = other.m[4];\r\n const r5 = other.m[5];\r\n\r\n result.m[0] = l0 * r0 + l1 * r2;\r\n result.m[1] = l0 * r1 + l1 * r3;\r\n result.m[2] = l2 * r0 + l3 * r2;\r\n result.m[3] = l2 * r1 + l3 * r3;\r\n result.m[4] = l4 * r0 + l5 * r2 + r4;\r\n 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 const s = Math.sin(angle);\r\n const 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}\r\n\r\n/**\r\n * Useful math functions\r\n */\r\nexport class MathTools {\r\n /**\r\n * Default rounding precision for GUI elements. It should be\r\n * set to a power of ten, where the exponent means the number\r\n * of decimal digits to round to, i.e, 100 means 2 decimal digits,\r\n * 1000 means 3 decimal digits, etc. Default is 100 (2 decimal digits).\r\n */\r\n public static DefaultRoundingPrecision = 100;\r\n\r\n /**\r\n * Rounds a number to the nearest multiple of a given precision\r\n * @param value the value to be rounded\r\n * @param precision the multiple to which the value will be rounded. Default is 100 (2 decimal digits)\r\n * @returns\r\n */\r\n public static Round(value: number, precision: number = MathTools.DefaultRoundingPrecision): number {\r\n return Math.round(value * precision) / precision;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"math2D.js","sourceRoot":"","sources":["../../../../dev/gui/src/2D/math2D.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,6CAA+B;AACjD,OAAO,EAAE,OAAO,EAAE,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AAQ,EAAE,AAAtB,CAAuB;AAC1C,2BAAkB,GAAG,QAAQ,CAAC,QAAQ,EAAE,AAAtB,CAAuB;AACzC,sBAAa,GAAG,QAAQ,CAAC,QAAQ,EAAE,AAAtB,CAAuB;AACpC,sBAAa,GAAG,QAAQ,CAAC,QAAQ,EAAE,AAAtB,CAAuB;AACpC,sBAAa,GAAG,QAAQ,CAAC,QAAQ,EAAE,AAAtB,CAAuB;AAgCvD;;GAEG;AACH,MAAM,OAAO,SAAS;IASlB;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,KAAa,EAAE,YAAoB,SAAS,CAAC,wBAAwB;QACrF,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;IACrD,CAAC;;AAhBD;;;;;GAKG;AACW,kCAAwB,GAAG,GAAG,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { Vector2 } from \"core/Maths/math.vector\";\r\nimport { Epsilon } from \"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(\r\n source: Vector2,\r\n /** defines the current mouse button index */\r\n public buttonIndex: number = 0\r\n ) {\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;\r\n this.m[1] = m01;\r\n this.m[2] = m10;\r\n this.m[3] = m11;\r\n this.m[4] = m20;\r\n 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 const l0 = this.m[0];\r\n const l1 = this.m[1];\r\n const l2 = this.m[2];\r\n const l3 = this.m[3];\r\n const l4 = this.m[4];\r\n const l5 = this.m[5];\r\n\r\n const det = this.determinant();\r\n if (det < Epsilon * Epsilon) {\r\n result.m[0] = 0;\r\n result.m[1] = 0;\r\n result.m[2] = 0;\r\n result.m[3] = 0;\r\n result.m[4] = 0;\r\n result.m[5] = 0;\r\n return this;\r\n }\r\n\r\n const detDiv = 1 / det;\r\n\r\n const det4 = l2 * l5 - l3 * l4;\r\n const det5 = l1 * l4 - l0 * l5;\r\n\r\n result.m[0] = l3 * detDiv;\r\n result.m[1] = -l1 * detDiv;\r\n result.m[2] = -l2 * detDiv;\r\n result.m[3] = l0 * detDiv;\r\n result.m[4] = det4 * detDiv;\r\n 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 const l0 = this.m[0];\r\n const l1 = this.m[1];\r\n const l2 = this.m[2];\r\n const l3 = this.m[3];\r\n const l4 = this.m[4];\r\n const l5 = this.m[5];\r\n\r\n const r0 = other.m[0];\r\n const r1 = other.m[1];\r\n const r2 = other.m[2];\r\n const r3 = other.m[3];\r\n const r4 = other.m[4];\r\n const r5 = other.m[5];\r\n\r\n result.m[0] = l0 * r0 + l1 * r2;\r\n result.m[1] = l0 * r1 + l1 * r3;\r\n result.m[2] = l2 * r0 + l3 * r2;\r\n result.m[3] = l2 * r1 + l3 * r3;\r\n result.m[4] = l4 * r0 + l5 * r2 + r4;\r\n 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 const s = Math.sin(angle);\r\n const 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}\r\n\r\n/**\r\n * Useful math functions\r\n */\r\nexport class MathTools {\r\n /**\r\n * Default rounding precision for GUI elements. It should be\r\n * set to a power of ten, where the exponent means the number\r\n * of decimal digits to round to, i.e, 100 means 2 decimal digits,\r\n * 1000 means 3 decimal digits, etc. Default is 100 (2 decimal digits).\r\n */\r\n public static DefaultRoundingPrecision = 100;\r\n\r\n /**\r\n * Rounds a number to the nearest multiple of a given precision\r\n * @param value the value to be rounded\r\n * @param precision the multiple to which the value will be rounded. Default is 100 (2 decimal digits)\r\n * @returns\r\n */\r\n public static Round(value: number, precision: number = MathTools.DefaultRoundingPrecision): number {\r\n return Math.round(value * precision) / precision;\r\n }\r\n}\r\n"]}
package/2D/measure.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"measure.js","sourceRoot":"","sources":["../../../../dev/gui/src/2D/measure.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,6CAA+B;AAEjD,MAAM,OAAO,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAE7F,MAAM,QAAQ,GAAG,CAAC,IAAI,OAAO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MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC;QACtB,MAAM,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC;QACrB,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;QACjC,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACI,cAAc,CAAC,SAAmB,EAAE,MAAe;QACtD,IAAI,CAAC,oBAAoB,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IAC7D,CAAC;IACD;;;;OAIG;IACI,UAAU,CAAC,KAAc;QAC5B,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,EAAE;YAC1B,OAAO,KAAK,CAAC;SAChB;QAED,IAAI,IAAI,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,EAAE;YACxB,OAAO,KAAK,CAAC;SAChB;QAED,IAAI,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,EAAE;YAC5B,OAAO,KAAK,CAAC;SAChB;QAED,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE;YAC9B,OAAO,KAAK,CAAC;SAChB;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,KAAK;QACf,OAAO,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACnC,CAAC;CACJ","sourcesContent":["import type { Matrix2D } from \"./math2D\";\r\nimport { Vector2 } from \"core/Maths/math.vector\";\r\n\r\nconst tmpRect = [new Vector2(0, 0), new Vector2(0, 0), new Vector2(0, 0), new Vector2(0, 0)];\r\n\r\nconst tmpRect2 = [new Vector2(0, 0), new Vector2(0, 0), new Vector2(0, 0), new Vector2(0, 0)];\r\n\r\nconst tmpV1 = new Vector2(0, 0);\r\nconst tmpV2 = new Vector2(0, 0);\r\n\r\n/**\r\n * Class used to store 2D control sizes\r\n */\r\nexport class Measure {\r\n /**\r\n * Creates a new measure\r\n * @param left defines left coordinate\r\n * @param top defines top coordinate\r\n * @param width defines width dimension\r\n * @param height defines height dimension\r\n */\r\n public constructor(\r\n /** defines left coordinate */\r\n public left: number,\r\n /** defines top coordinate */\r\n public top: number,\r\n /** defines width dimension */\r\n public width: number,\r\n /** defines height dimension */\r\n public height: number\r\n ) {}\r\n\r\n /**\r\n * Copy from another measure\r\n * @param other defines the other measure to copy from\r\n */\r\n public copyFrom(other: Measure): void {\r\n this.left = other.left;\r\n this.top = other.top;\r\n this.width = other.width;\r\n this.height = other.height;\r\n }\r\n\r\n /**\r\n * Copy from a group of 4 floats\r\n * @param left defines left coordinate\r\n * @param top defines top coordinate\r\n * @param width defines width dimension\r\n * @param height defines height dimension\r\n */\r\n public copyFromFloats(left: number, top: number, width: number, height: number): void {\r\n this.left = left;\r\n this.top = top;\r\n this.width = width;\r\n this.height = height;\r\n }\r\n\r\n /**\r\n * Computes the axis aligned bounding box measure for two given measures\r\n * @param a Input measure\r\n * @param b Input measure\r\n * @param result the resulting bounding measure\r\n */\r\n public static CombineToRef(a: Measure, b: Measure, result: Measure) {\r\n const left = Math.min(a.left, b.left);\r\n const top = Math.min(a.top, b.top);\r\n const right = Math.max(a.left + a.width, b.left + b.width);\r\n const bottom = Math.max(a.top + a.height, b.top + b.height);\r\n result.left = left;\r\n result.top = top;\r\n result.width = right - left;\r\n result.height = bottom - top;\r\n }\r\n\r\n /**\r\n * Computes the axis aligned bounding box of the measure after it is modified by a given transform\r\n * @param transform the matrix to transform the measure before computing the AABB\r\n * @param addX number to add to left\r\n * @param addY number to add to top\r\n * @param addWidth number to add to width\r\n * @param addHeight number to add to height\r\n * @param result the resulting AABB\r\n */\r\n public addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure) {\r\n const left = this.left + addX;\r\n const top = this.top + addY;\r\n const width = this.width + addWidth;\r\n const height = this.height + addHeight;\r\n\r\n tmpRect[0].copyFromFloats(left, top);\r\n tmpRect[1].copyFromFloats(left + width, top);\r\n tmpRect[2].copyFromFloats(left + width, top + height);\r\n tmpRect[3].copyFromFloats(left, top + height);\r\n\r\n tmpV1.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE);\r\n tmpV2.copyFromFloats(0, 0);\r\n for (let i = 0; i < 4; i++) {\r\n transform.transformCoordinates(tmpRect[i].x, tmpRect[i].y, tmpRect2[i]);\r\n tmpV1.x = Math.floor(Math.min(tmpV1.x, tmpRect2[i].x));\r\n tmpV1.y = Math.floor(Math.min(tmpV1.y, tmpRect2[i].y));\r\n tmpV2.x = Math.ceil(Math.max(tmpV2.x, tmpRect2[i].x));\r\n tmpV2.y = Math.ceil(Math.max(tmpV2.y, tmpRect2[i].y));\r\n }\r\n result.left = tmpV1.x;\r\n result.top = tmpV1.y;\r\n result.width = tmpV2.x - tmpV1.x;\r\n result.height = tmpV2.y - tmpV1.y;\r\n }\r\n\r\n /**\r\n * Computes the axis aligned bounding box of the measure after it is modified by a given transform\r\n * @param transform the matrix to transform the measure before computing the AABB\r\n * @param result the resulting AABB\r\n */\r\n public transformToRef(transform: Matrix2D, result: Measure) {\r\n this.addAndTransformToRef(transform, 0, 0, 0, 0, result);\r\n }\r\n /**\r\n * Check equality between this measure and another one\r\n * @param other defines the other measures\r\n * @returns true if both measures are equals\r\n */\r\n public isEqualsTo(other: Measure): boolean {\r\n if (this.left !== other.left) {\r\n return false;\r\n }\r\n\r\n if (this.top !== other.top) {\r\n return false;\r\n }\r\n\r\n if (this.width !== other.width) {\r\n return false;\r\n }\r\n\r\n if (this.height !== other.height) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Creates an empty measure\r\n * @returns a new measure\r\n */\r\n public static Empty(): Measure {\r\n return new Measure(0, 0, 0, 0);\r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C,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;YAC/B,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,KAAK;QACf,OAAO,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACnC,CAAC;CACJ","sourcesContent":["import type { Matrix2D } from \"./math2D\";\r\nimport { Vector2 } from \"core/Maths/math.vector\";\r\n\r\nconst tmpRect = [new Vector2(0, 0), new Vector2(0, 0), new Vector2(0, 0), new Vector2(0, 0)];\r\n\r\nconst tmpRect2 = [new Vector2(0, 0), new Vector2(0, 0), new Vector2(0, 0), new Vector2(0, 0)];\r\n\r\nconst tmpV1 = new Vector2(0, 0);\r\nconst tmpV2 = new Vector2(0, 0);\r\n\r\n/**\r\n * Class used to store 2D control sizes\r\n */\r\nexport class Measure {\r\n /**\r\n * Creates a new measure\r\n * @param left defines left coordinate\r\n * @param top defines top coordinate\r\n * @param width defines width dimension\r\n * @param height defines height dimension\r\n */\r\n public constructor(\r\n /** defines left coordinate */\r\n public left: number,\r\n /** defines top coordinate */\r\n public top: number,\r\n /** defines width dimension */\r\n public width: number,\r\n /** defines height dimension */\r\n public height: number\r\n ) {}\r\n\r\n /**\r\n * Copy from another measure\r\n * @param other defines the other measure to copy from\r\n */\r\n public copyFrom(other: Measure): void {\r\n this.left = other.left;\r\n this.top = other.top;\r\n this.width = other.width;\r\n this.height = other.height;\r\n }\r\n\r\n /**\r\n * Copy from a group of 4 floats\r\n * @param left defines left coordinate\r\n * @param top defines top coordinate\r\n * @param width defines width dimension\r\n * @param height defines height dimension\r\n */\r\n public copyFromFloats(left: number, top: number, width: number, height: number): void {\r\n this.left = left;\r\n this.top = top;\r\n this.width = width;\r\n this.height = height;\r\n }\r\n\r\n /**\r\n * Computes the axis aligned bounding box measure for two given measures\r\n * @param a Input measure\r\n * @param b Input measure\r\n * @param result the resulting bounding measure\r\n */\r\n public static CombineToRef(a: Measure, b: Measure, result: Measure) {\r\n const left = Math.min(a.left, b.left);\r\n const top = Math.min(a.top, b.top);\r\n const right = Math.max(a.left + a.width, b.left + b.width);\r\n const bottom = Math.max(a.top + a.height, b.top + b.height);\r\n result.left = left;\r\n result.top = top;\r\n result.width = right - left;\r\n result.height = bottom - top;\r\n }\r\n\r\n /**\r\n * Computes the axis aligned bounding box of the measure after it is modified by a given transform\r\n * @param transform the matrix to transform the measure before computing the AABB\r\n * @param addX number to add to left\r\n * @param addY number to add to top\r\n * @param addWidth number to add to width\r\n * @param addHeight number to add to height\r\n * @param result the resulting AABB\r\n */\r\n public addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure) {\r\n const left = this.left + addX;\r\n const top = this.top + addY;\r\n const width = this.width + addWidth;\r\n const height = this.height + addHeight;\r\n\r\n tmpRect[0].copyFromFloats(left, top);\r\n tmpRect[1].copyFromFloats(left + width, top);\r\n tmpRect[2].copyFromFloats(left + width, top + height);\r\n tmpRect[3].copyFromFloats(left, top + height);\r\n\r\n tmpV1.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE);\r\n tmpV2.copyFromFloats(0, 0);\r\n for (let i = 0; i < 4; i++) {\r\n transform.transformCoordinates(tmpRect[i].x, tmpRect[i].y, tmpRect2[i]);\r\n tmpV1.x = Math.floor(Math.min(tmpV1.x, tmpRect2[i].x));\r\n tmpV1.y = Math.floor(Math.min(tmpV1.y, tmpRect2[i].y));\r\n tmpV2.x = Math.ceil(Math.max(tmpV2.x, tmpRect2[i].x));\r\n tmpV2.y = Math.ceil(Math.max(tmpV2.y, tmpRect2[i].y));\r\n }\r\n result.left = tmpV1.x;\r\n result.top = tmpV1.y;\r\n result.width = tmpV2.x - tmpV1.x;\r\n result.height = tmpV2.y - tmpV1.y;\r\n }\r\n\r\n /**\r\n * Computes the axis aligned bounding box of the measure after it is modified by a given transform\r\n * @param transform the matrix to transform the measure before computing the AABB\r\n * @param result the resulting AABB\r\n */\r\n public transformToRef(transform: Matrix2D, result: Measure) {\r\n this.addAndTransformToRef(transform, 0, 0, 0, 0, result);\r\n }\r\n /**\r\n * Check equality between this measure and another one\r\n * @param other defines the other measures\r\n * @returns true if both measures are equals\r\n */\r\n public isEqualsTo(other: Measure): boolean {\r\n if (this.left !== other.left) {\r\n return false;\r\n }\r\n\r\n if (this.top !== other.top) {\r\n return false;\r\n }\r\n\r\n if (this.width !== other.width) {\r\n return false;\r\n }\r\n\r\n if (this.height !== other.height) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Creates an empty measure\r\n * @returns a new measure\r\n */\r\n public static Empty(): Measure {\r\n return new Measure(0, 0, 0, 0);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"multiLinePoint.js","sourceRoot":"","sources":["../../../../dev/gui/src/2D/multiLinePoint.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,6CAA+B;AACjD,OAAO,EAAE,OAAO,EAAE,gDAAkC;AAKpD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C;;;GAGG;AACH,MAAM,OAAO,cAAc;IAcvB;;;OAGG;IACH,YAAY,SAAoB;QAC5B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAE5B,IAAI,CAAC,EAAE,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;QAE9B,IAAI,CAAC,MAAM,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACvC,CAAC;IAED,gCAAgC;IAChC,IAAW,CAAC;QACR,OAAO,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACnD,CAAC;IAED,IAAW,CAAC,CAAC,K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AI,IAAI,CAAC,QAAQ,IAAI,IAAI,EAAE;YAC9B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC;SACjF;aAAM;YACH,MAAM,IAAI,GAAQ,IAAI,CAAC,UAAU,CAAC,KAAY,CAAC;YAE/C,MAAM,MAAM,GAAW,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;YACjF,MAAM,MAAM,GAAW,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;YAElF,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC;SACnD;IACL,CAAC;IAED,mCAAmC;IAC5B,OAAO;QACV,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { Epsilon } from \"core/Maths/math.constants\";\r\nimport type { Camera } from \"core/Cameras/camera\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\n\r\nimport type { MultiLine } from \"./controls/multiLine\";\r\nimport { ValueAndUnit } from \"./valueAndUnit\";\r\nimport type { Control } from \"./controls/control\";\r\n\r\n/**\r\n * Class used to store a point for a MultiLine object.\r\n * The point can be pure 2D coordinates, a mesh or a control\r\n */\r\nexport class MultiLinePoint {\r\n private _multiLine: MultiLine;\r\n\r\n private _x: ValueAndUnit;\r\n private _y: ValueAndUnit;\r\n private _control: Nullable<Control>;\r\n private _mesh: Nullable<AbstractMesh>;\r\n\r\n private _controlObserver: Nullable<Observer<Control>>;\r\n private _meshObserver: Nullable<Observer<Camera>>;\r\n\r\n /** @internal */\r\n public _point: Vector3;\r\n\r\n /**\r\n * Creates a new MultiLinePoint\r\n * @param multiLine defines the source MultiLine object\r\n */\r\n constructor(multiLine: MultiLine) {\r\n this._multiLine = multiLine;\r\n\r\n this._x = new ValueAndUnit(0);\r\n this._y = new ValueAndUnit(0);\r\n\r\n this._point = new Vector3(0, 0, 0);\r\n }\r\n\r\n /** Gets or sets x coordinate */\r\n public get x(): string | number {\r\n return this._x.toString(this._multiLine._host);\r\n }\r\n\r\n public set x(value: string | number) {\r\n if (this._x.toString(this._multiLine._host) === value) {\r\n return;\r\n }\r\n\r\n if (this._x.fromString(value)) {\r\n this._multiLine._markAsDirty();\r\n }\r\n }\r\n\r\n /** Gets or sets y coordinate */\r\n public get y(): string | number {\r\n return this._y.toString(this._multiLine._host);\r\n }\r\n\r\n public set y(value: string | number) {\r\n if (this._y.toString(this._multiLine._host) === value) {\r\n return;\r\n }\r\n\r\n if (this._y.fromString(value)) {\r\n this._multiLine._markAsDirty();\r\n }\r\n }\r\n\r\n /** Gets or sets the control associated with this point */\r\n public get control(): Nullable<Control> {\r\n return this._control;\r\n }\r\n\r\n public set control(value: Nullable<Control>) {\r\n if (this._control === value) {\r\n return;\r\n }\r\n\r\n if (this._control && this._controlObserver) {\r\n this._control.onDirtyObservable.remove(this._controlObserver);\r\n\r\n this._controlObserver = null;\r\n }\r\n\r\n this._control = value;\r\n\r\n if (this._control) {\r\n this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);\r\n }\r\n\r\n this._multiLine._markAsDirty();\r\n }\r\n\r\n /** Gets or sets the mesh associated with this point */\r\n public get mesh(): Nullable<AbstractMesh> {\r\n return this._mesh;\r\n }\r\n\r\n public set mesh(value: Nullable<AbstractMesh>) {\r\n if (this._mesh === value) {\r\n return;\r\n }\r\n\r\n if (this._mesh && this._meshObserver) {\r\n this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);\r\n }\r\n\r\n this._mesh = value;\r\n\r\n if (this._mesh) {\r\n this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);\r\n }\r\n\r\n this._multiLine._markAsDirty();\r\n }\r\n\r\n /** Resets links */\r\n public resetLinks(): void {\r\n this.control = null;\r\n this.mesh = null;\r\n }\r\n\r\n /**\r\n * Gets a translation vector with Z component\r\n * @returns the translation vector\r\n */\r\n public translate(): Vector3 {\r\n this._point = this._translatePoint();\r\n\r\n return this._point;\r\n }\r\n\r\n private _translatePoint(): Vector3 {\r\n if (this._mesh != null) {\r\n return this._multiLine._host.getProjectedPositionWithZ(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());\r\n } else if (this._control != null) {\r\n return new Vector3(this._control.centerX, this._control.centerY, 1 - Epsilon);\r\n } else {\r\n const host: any = this._multiLine._host as any;\r\n\r\n const xValue: number = this._x.getValueInPixel(host, Number(host._canvas.width));\r\n const yValue: number = this._y.getValueInPixel(host, Number(host._canvas.height));\r\n\r\n return new Vector3(xValue, yValue, 1 - Epsilon);\r\n }\r\n }\r\n\r\n /** Release associated resources */\r\n public dispose(): void {\r\n this.resetLinks();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"multiLinePoint.js","sourceRoot":"","sources":["../../../../dev/gui/src/2D/multiLinePoint.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,6CAA+B;AACjD,OAAO,EAAE,OAAO,EAAE,gDAAkC;AAKpD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C;;;GAGG;AACH,MAAM,OAAO,cAAc;IAcvB;;;OAGG;IACH,YAAY,SAAoB;QAC5B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAE5B,IAAI,CAAC,EAAE,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,CAA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AED;;;OAGG;IACI,SAAS;QACZ,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QAErC,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAEO,eAAe;QACnB,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;YACrB,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC;QAC5I,CAAC;aAAM,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;YAC/B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC;QAClF,CAAC;aAAM,CAAC;YACJ,MAAM,IAAI,GAAQ,IAAI,CAAC,UAAU,CAAC,KAAY,CAAC;YAE/C,MAAM,MAAM,GAAW,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;YACjF,MAAM,MAAM,GAAW,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;YAElF,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC;QACpD,CAAC;IACL,CAAC;IAED,mCAAmC;IAC5B,OAAO;QACV,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { Epsilon } from \"core/Maths/math.constants\";\r\nimport type { Camera } from \"core/Cameras/camera\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\n\r\nimport type { MultiLine } from \"./controls/multiLine\";\r\nimport { ValueAndUnit } from \"./valueAndUnit\";\r\nimport type { Control } from \"./controls/control\";\r\n\r\n/**\r\n * Class used to store a point for a MultiLine object.\r\n * The point can be pure 2D coordinates, a mesh or a control\r\n */\r\nexport class MultiLinePoint {\r\n private _multiLine: MultiLine;\r\n\r\n private _x: ValueAndUnit;\r\n private _y: ValueAndUnit;\r\n private _control: Nullable<Control>;\r\n private _mesh: Nullable<AbstractMesh>;\r\n\r\n private _controlObserver: Nullable<Observer<Control>>;\r\n private _meshObserver: Nullable<Observer<Camera>>;\r\n\r\n /** @internal */\r\n public _point: Vector3;\r\n\r\n /**\r\n * Creates a new MultiLinePoint\r\n * @param multiLine defines the source MultiLine object\r\n */\r\n constructor(multiLine: MultiLine) {\r\n this._multiLine = multiLine;\r\n\r\n this._x = new ValueAndUnit(0);\r\n this._y = new ValueAndUnit(0);\r\n\r\n this._point = new Vector3(0, 0, 0);\r\n }\r\n\r\n /** Gets or sets x coordinate */\r\n public get x(): string | number {\r\n return this._x.toString(this._multiLine._host);\r\n }\r\n\r\n public set x(value: string | number) {\r\n if (this._x.toString(this._multiLine._host) === value) {\r\n return;\r\n }\r\n\r\n if (this._x.fromString(value)) {\r\n this._multiLine._markAsDirty();\r\n }\r\n }\r\n\r\n /** Gets or sets y coordinate */\r\n public get y(): string | number {\r\n return this._y.toString(this._multiLine._host);\r\n }\r\n\r\n public set y(value: string | number) {\r\n if (this._y.toString(this._multiLine._host) === value) {\r\n return;\r\n }\r\n\r\n if (this._y.fromString(value)) {\r\n this._multiLine._markAsDirty();\r\n }\r\n }\r\n\r\n /** Gets or sets the control associated with this point */\r\n public get control(): Nullable<Control> {\r\n return this._control;\r\n }\r\n\r\n public set control(value: Nullable<Control>) {\r\n if (this._control === value) {\r\n return;\r\n }\r\n\r\n if (this._control && this._controlObserver) {\r\n this._control.onDirtyObservable.remove(this._controlObserver);\r\n\r\n this._controlObserver = null;\r\n }\r\n\r\n this._control = value;\r\n\r\n if (this._control) {\r\n this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);\r\n }\r\n\r\n this._multiLine._markAsDirty();\r\n }\r\n\r\n /** Gets or sets the mesh associated with this point */\r\n public get mesh(): Nullable<AbstractMesh> {\r\n return this._mesh;\r\n }\r\n\r\n public set mesh(value: Nullable<AbstractMesh>) {\r\n if (this._mesh === value) {\r\n return;\r\n }\r\n\r\n if (this._mesh && this._meshObserver) {\r\n this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);\r\n }\r\n\r\n this._mesh = value;\r\n\r\n if (this._mesh) {\r\n this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);\r\n }\r\n\r\n this._multiLine._markAsDirty();\r\n }\r\n\r\n /** Resets links */\r\n public resetLinks(): void {\r\n this.control = null;\r\n this.mesh = null;\r\n }\r\n\r\n /**\r\n * Gets a translation vector with Z component\r\n * @returns the translation vector\r\n */\r\n public translate(): Vector3 {\r\n this._point = this._translatePoint();\r\n\r\n return this._point;\r\n }\r\n\r\n private _translatePoint(): Vector3 {\r\n if (this._mesh != null) {\r\n return this._multiLine._host.getProjectedPositionWithZ(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());\r\n } else if (this._control != null) {\r\n return new Vector3(this._control.centerX, this._control.centerY, 1 - Epsilon);\r\n } else {\r\n const host: any = this._multiLine._host as any;\r\n\r\n const xValue: number = this._x.getValueInPixel(host, Number(host._canvas.width));\r\n const yValue: number = this._y.getValueInPixel(host, Number(host._canvas.height));\r\n\r\n return new Vector3(xValue, yValue, 1 - Epsilon);\r\n }\r\n }\r\n\r\n /** Release associated resources */\r\n public dispose(): void {\r\n this.resetLinks();\r\n }\r\n}\r\n"]}
package/2D/style.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"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C;IAED;;OAEG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,IAAW,SAAS,CAAC,KAAa;QAC9B,IAAI,IAAI,CAAC,UAAU,KAAK,KAAK,EAAE;YAC3B,OAAO;SACV;QAED,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IAED,+BAA+B;IAC/B,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED,IAAW,UAAU,CAAC,KAAa;QAC/B,IAAI,IAAI,CAAC,WAAW,KAAK,KAAK,EAAE;YAC5B,OAAO;SACV;QAED,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QACzB,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IAED,uCAAuC;IAChC,OAAO;QACV,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;IACrC,CAAC;CACJ","sourcesContent":["import { Observable } from \"core/Misc/observable\";\r\nimport type { IDisposable } from \"core/scene\";\r\nimport type { AdvancedDynamicTexture } from \"./advancedDynamicTexture\";\r\nimport { ValueAndUnit } from \"./valueAndUnit\";\r\n\r\n/**\r\n * Define a style used by control to automatically setup properties based on a template.\r\n * Only support font related properties so far\r\n */\r\nexport class Style implements IDisposable {\r\n private _fontFamily = \"Arial\";\r\n private _fontStyle = \"\";\r\n private _fontWeight = \"\";\r\n /** @internal */\r\n public _host: AdvancedDynamicTexture;\r\n /** @internal */\r\n public _fontSize = new ValueAndUnit(18, ValueAndUnit.UNITMODE_PIXEL, false);\r\n\r\n /**\r\n * Observable raised when the style values are changed\r\n */\r\n public onChangedObservable = new Observable<Style>();\r\n\r\n /**\r\n * Creates a new style object\r\n * @param host defines the AdvancedDynamicTexture which hosts this style\r\n */\r\n public constructor(host: AdvancedDynamicTexture) {\r\n this._host = host;\r\n }\r\n\r\n /**\r\n * Gets or sets the font size\r\n */\r\n public get fontSize(): string | number {\r\n return this._fontSize.toString(this._host);\r\n }\r\n\r\n public set fontSize(value: string | number) {\r\n if (this._fontSize.toString(this._host) === value) {\r\n return;\r\n }\r\n\r\n if (this._fontSize.fromString(value)) {\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the font family\r\n */\r\n public get fontFamily(): string {\r\n return this._fontFamily;\r\n }\r\n\r\n public set fontFamily(value: string) {\r\n if (this._fontFamily === value) {\r\n return;\r\n }\r\n\r\n this._fontFamily = value;\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Gets or sets the font style\r\n */\r\n public get fontStyle(): string {\r\n return this._fontStyle;\r\n }\r\n\r\n public set fontStyle(value: string) {\r\n if (this._fontStyle === value) {\r\n return;\r\n }\r\n\r\n this._fontStyle = value;\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n\r\n /** Gets or sets font weight */\r\n public get fontWeight(): string {\r\n return this._fontWeight;\r\n }\r\n\r\n public set fontWeight(value: string) {\r\n if (this._fontWeight === value) {\r\n return;\r\n }\r\n\r\n this._fontWeight = value;\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n\r\n /** Dispose all associated resources */\r\n public dispose() {\r\n this.onChangedObservable.clear();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"style.js","sourceRoot":"","sources":["../../../../dev/gui/src/2D/style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAGlD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;GAGG;AACH,MAAM,OAAO,KAAK;IAcd;;;OAGG;IACH,YAAmB,IAA4B;QAjBvC,gBAAW,GAAG,OAAO,CAAC;QACtB,eAAU,GAAG,EAAE,CAAC;QAChB,gBAAW,GAAG,EAAE,CAAC;QAGzB,gBAAgB;QACT,cAA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+BAA+B;IAC/B,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED,IAAW,UAAU,CAAC,KAAa;QAC/B,IAAI,IAAI,CAAC,WAAW,KAAK,KAAK,EAAE,CAAC;YAC7B,OAAO;QACX,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QACzB,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IAED,uCAAuC;IAChC,OAAO;QACV,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;IACrC,CAAC;CACJ","sourcesContent":["import { Observable } from \"core/Misc/observable\";\r\nimport type { IDisposable } from \"core/scene\";\r\nimport type { AdvancedDynamicTexture } from \"./advancedDynamicTexture\";\r\nimport { ValueAndUnit } from \"./valueAndUnit\";\r\n\r\n/**\r\n * Define a style used by control to automatically setup properties based on a template.\r\n * Only support font related properties so far\r\n */\r\nexport class Style implements IDisposable {\r\n private _fontFamily = \"Arial\";\r\n private _fontStyle = \"\";\r\n private _fontWeight = \"\";\r\n /** @internal */\r\n public _host: AdvancedDynamicTexture;\r\n /** @internal */\r\n public _fontSize = new ValueAndUnit(18, ValueAndUnit.UNITMODE_PIXEL, false);\r\n\r\n /**\r\n * Observable raised when the style values are changed\r\n */\r\n public onChangedObservable = new Observable<Style>();\r\n\r\n /**\r\n * Creates a new style object\r\n * @param host defines the AdvancedDynamicTexture which hosts this style\r\n */\r\n public constructor(host: AdvancedDynamicTexture) {\r\n this._host = host;\r\n }\r\n\r\n /**\r\n * Gets or sets the font size\r\n */\r\n public get fontSize(): string | number {\r\n return this._fontSize.toString(this._host);\r\n }\r\n\r\n public set fontSize(value: string | number) {\r\n if (this._fontSize.toString(this._host) === value) {\r\n return;\r\n }\r\n\r\n if (this._fontSize.fromString(value)) {\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the font family\r\n */\r\n public get fontFamily(): string {\r\n return this._fontFamily;\r\n }\r\n\r\n public set fontFamily(value: string) {\r\n if (this._fontFamily === value) {\r\n return;\r\n }\r\n\r\n this._fontFamily = value;\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Gets or sets the font style\r\n */\r\n public get fontStyle(): string {\r\n return this._fontStyle;\r\n }\r\n\r\n public set fontStyle(value: string) {\r\n if (this._fontStyle === value) {\r\n return;\r\n }\r\n\r\n this._fontStyle = value;\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n\r\n /** Gets or sets font weight */\r\n public get fontWeight(): string {\r\n return this._fontWeight;\r\n }\r\n\r\n public set fontWeight(value: string) {\r\n if (this._fontWeight === value) {\r\n return;\r\n }\r\n\r\n this._fontWeight = value;\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n\r\n /** Dispose all associated resources */\r\n public dispose() {\r\n this.onChangedObservable.clear();\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"valueAndUnit.js","sourceRoot":"","sources":["../../../../dev/gui/src/2D/valueAndUnit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAGlD;;GAEG;AACH,MAAM,OAAO,YAAY;IAgBrB;;;;;OAKG;IACH,YACI,KAAa;IACb,gCAAgC;IAChC,IAAI,GAAG,YAAY,CAAC,cAAc;IAClC,gEAAgE;IACzD,uBAAuB,IAAI;QAA3B,yBAAoB,GAApB,oBAAoB,CAAO;QA1B9B,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;QAehD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC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,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;IAOD,0BAA0B;IACnB,MAAM,KAAK,mBAAmB;QACjC,OAAO,YAAY,CAAC,oBAAoB,CAAC;IAC7C,CAAC;IAED,qBAAqB;IACd,MAAM,KAAK,cAAc;QAC5B,OAAO,YAAY,CAAC,eAAe,CAAC;IACxC,CAAC;;AAbD,SAAS;AACM,mBAAM,GAAG,yBAAyB,AAA5B,CAA6B;AACnC,iCAAoB,GAAG,CAAC,AAAJ,CAAK;AACzB,4BAAe,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["import { Observable } from \"core/Misc/observable\";\r\nimport type { 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/features/featuresDeepDive/gui/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(\r\n 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 ) {\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 let width: number = 0;\r\n let height: number = 0;\r\n\r\n if (host.idealWidth) {\r\n width = Math.ceil((this._value * host.getSize().width) / host.idealWidth);\r\n }\r\n\r\n if (host.idealHeight) {\r\n height = Math.ceil((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) {\r\n // horizontal\r\n return width;\r\n }\r\n\r\n if (host.idealHeight) {\r\n // 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 const percentage = this.getValue(host) * 100;\r\n return (decimals ? percentage.toFixed(decimals) : percentage) + \"%\";\r\n }\r\n case ValueAndUnit.UNITMODE_PIXEL: {\r\n const pixels = this.getValue(host);\r\n return (decimals ? pixels.toFixed(decimals) : pixels) + \"px\";\r\n }\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 const 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 let sourceValue = parseFloat(match[1]);\r\n let 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}\r\n"]}
1
+ {"version":3,"file":"valueAndUnit.js","sourceRoot":"","sources":["../../../../dev/gui/src/2D/valueAndUnit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAGlD;;GAEG;AACH,MAAM,OAAO,YAAY;IAgBrB;;;;;OAKG;IACH,YACI,KAAa;IACb,gCAAgC;IAChC,IAAI,GAAG,YAAY,CAAC,cAAc;IAClC,gEAAgE;IACzD,uBAAuB,IAAI;QAA3B,yBAAoB,GAApB,oBAAoB,CAAO;QA1B9B,WAAM,GAAG,CAAC,CAAC;QACX,UAAK,GAAG,YAAY,CAAC,cAAc,CAAC;QAG5C;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AG,CAAC,AAAJ,CAAK","sourcesContent":["import { Observable } from \"core/Misc/observable\";\r\nimport type { 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/features/featuresDeepDive/gui/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(\r\n 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 ) {\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 let width: number = 0;\r\n let height: number = 0;\r\n\r\n if (host.idealWidth) {\r\n width = Math.ceil((this._value * host.getSize().width) / host.idealWidth);\r\n }\r\n\r\n if (host.idealHeight) {\r\n height = Math.ceil((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) {\r\n // horizontal\r\n return width;\r\n }\r\n\r\n if (host.idealHeight) {\r\n // 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 const percentage = this.getValue(host) * 100;\r\n return (decimals ? percentage.toFixed(decimals) : percentage) + \"%\";\r\n }\r\n case ValueAndUnit.UNITMODE_PIXEL: {\r\n const pixels = this.getValue(host);\r\n return (decimals ? pixels.toFixed(decimals) : pixels) + \"px\";\r\n }\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 const 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 let sourceValue = parseFloat(match[1]);\r\n let 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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,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import { GetClass } from \"core/Misc/typeStore\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nconst XmlLoaderError = \"XmlLoader Exception : XML file is malformed or corrupted.\";\r\n\r\n/**\r\n * Class used to load GUI via XML.\r\n */\r\nexport class XmlLoader {\r\n private _nodes: any = {};\r\n\r\n private _nodeTypes: any = {\r\n element: 1,\r\n attribute: 2,\r\n text: 3,\r\n };\r\n\r\n private _isLoaded: boolean = false;\r\n\r\n private _objectAttributes: any = {\r\n textHorizontalAlignment: 1,\r\n textVerticalAlignment: 2,\r\n horizontalAlignment: 3,\r\n verticalAlignment: 4,\r\n stretch: 5,\r\n };\r\n\r\n private _rootNode: any;\r\n\r\n private _parentClass: any;\r\n\r\n /**\r\n * Create a new xml loader\r\n * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context\r\n */\r\n constructor(parentClass: any = null) {\r\n if (parentClass) {\r\n this._parentClass = parentClass;\r\n }\r\n }\r\n\r\n private _getChainElement(attributeValue: any): any {\r\n let element: any = window;\r\n\r\n if (this._parentClass) {\r\n element = this._parentClass;\r\n }\r\n let value = attributeValue;\r\n value = value.split(\".\");\r\n\r\n for (let i = 0; i < value.length; i++) {\r\n element = element[value[i]];\r\n }\r\n return element;\r\n }\r\n\r\n private _getClassAttribute(attributeName: string): any {\r\n const attribute = attributeName.split(\".\");\r\n const className = GetClass(\"BABYLON.GUI.\" + attribute[0]);\r\n return className[attribute[1]];\r\n }\r\n\r\n private _createGuiElement(node: any, parent: any, linkParent: boolean = true): void {\r\n try {\r\n const className = GetClass(\"BABYLON.GUI.\" + node.nodeName);\r\n const guiNode = new className();\r\n\r\n if (parent && linkParent) {\r\n parent.addControl(guiNode);\r\n }\r\n\r\n for (let i = 0; i < node.attributes.length; i++) {\r\n if (node.attributes[i].name.toLowerCase().includes(\"datasource\")) {\r\n continue;\r\n }\r\n\r\n if (node.attributes[i].name.toLowerCase().includes(\"observable\")) {\r\n const element = this._getChainElement(node.attributes[i].value);\r\n guiNode[node.attributes[i].name].add(element);\r\n\r\n continue;\r\n } else if (node.attributes[i].name == \"linkWithMesh\") {\r\n if (this._parentClass) {\r\n guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);\r\n } else {\r\n guiNode.linkWithMesh(window[node.attributes[i].value]);\r\n }\r\n } else if (node.attributes[i].value.match(/{{.*}}/)) {\r\n const matches = node.attributes[i].value.match(/{{(.*)}}/);\r\n let element = this._getChainElement(matches[1]);\r\n if (!(node.attributes[i].value.startsWith(\"{{\") && node.attributes[i].value.endsWith(\"}}\"))) {\r\n element = (node.attributes[i].value as string).replace(/{{.*}}/, `${element}`);\r\n }\r\n guiNode[node.attributes[i].name] = element;\r\n } else if (!this._objectAttributes[node.attributes[i].name]) {\r\n if (node.attributes[i].value == \"true\" || node.attributes[i].value == \"false\") {\r\n guiNode[node.attributes[i].name] = node.attributes[i].value == \"true\";\r\n } else {\r\n guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;\r\n }\r\n } else {\r\n guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);\r\n }\r\n }\r\n\r\n if (!node.attributes.getNamedItem(\"id\")) {\r\n this._nodes[node.nodeName + Object.keys(this._nodes).length + \"_gen\"] = guiNode;\r\n return guiNode;\r\n }\r\n\r\n let id = node.attributes.getNamedItem(\"id\").value;\r\n if (id.startsWith(\"{{\") && id.endsWith(\"}}\")) {\r\n id = this._getChainElement(id.substring(2, id.length - 2));\r\n }\r\n\r\n if (!this._nodes[id]) {\r\n this._nodes[id] = guiNode;\r\n } else {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute\";\r\n }\r\n return guiNode;\r\n } catch (exception) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Error parsing Control \" + node.nodeName + \",\" + exception + \".\";\r\n }\r\n }\r\n\r\n private _parseGrid(node: any, guiNode: any, parent: any): void {\r\n let width;\r\n let height;\r\n let columns;\r\n const rows = node.children;\r\n let cells;\r\n let isPixel = false;\r\n let cellNode;\r\n let rowNumber = -1;\r\n let columnNumber = -1;\r\n let totalColumnsNumber = 0;\r\n\r\n for (let i = 0; i < rows.length; i++) {\r\n if (rows[i].nodeType != this._nodeTypes.element) {\r\n continue;\r\n }\r\n if (rows[i].nodeName != \"Row\") {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Expecting Row node, received \" + rows[i].nodeName;\r\n }\r\n rowNumber += 1;\r\n columns = rows[i].children;\r\n\r\n if (!rows[i].attributes.getNamedItem(\"height\")) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Height must be defined for grid rows\";\r\n }\r\n height = Number(rows[i].attributes.getNamedItem(\"height\").nodeValue);\r\n isPixel = rows[i].attributes.getNamedItem(\"isPixel\") ? JSON.parse(rows[i].attributes.getNamedItem(\"isPixel\").nodeValue) : false;\r\n guiNode.addRowDefinition(height, isPixel);\r\n\r\n for (let j = 0; j < columns.length; j++) {\r\n if (columns[j].nodeType != this._nodeTypes.element) {\r\n continue;\r\n }\r\n if (columns[j].nodeName != \"Column\") {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Expecting Column node, received \" + columns[j].nodeName;\r\n }\r\n columnNumber += 1;\r\n if (rowNumber > 0 && columnNumber > totalColumnsNumber) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : In the Grid element, the number of columns is defined in the first row, do not add more columns in the subsequent rows.\";\r\n }\r\n\r\n if (rowNumber == 0) {\r\n if (!columns[j].attributes.getNamedItem(\"width\")) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Width must be defined for all the grid columns in the first row\";\r\n }\r\n width = Number(columns[j].attributes.getNamedItem(\"width\").nodeValue);\r\n isPixel = columns[j].attributes.getNamedItem(\"isPixel\") ? JSON.parse(columns[j].attributes.getNamedItem(\"isPixel\").nodeValue) : false;\r\n guiNode.addColumnDefinition(width, isPixel);\r\n }\r\n\r\n cells = columns[j].children;\r\n\r\n for (let k = 0; k < cells.length; k++) {\r\n if (cells[k].nodeType != this._nodeTypes.element) {\r\n continue;\r\n }\r\n cellNode = this._createGuiElement(cells[k], guiNode, false);\r\n guiNode.addControl(cellNode, rowNumber, columnNumber);\r\n if (cells[k].firstChild) {\r\n this._parseXml(cells[k].firstChild, cellNode);\r\n }\r\n }\r\n }\r\n if (rowNumber == 0) {\r\n totalColumnsNumber = columnNumber;\r\n }\r\n columnNumber = -1;\r\n }\r\n\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent);\r\n }\r\n }\r\n\r\n private _parseElement(node: any, guiNode: any, parent: any): void {\r\n if (node.firstChild) {\r\n this._parseXml(node.firstChild, guiNode);\r\n }\r\n\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent);\r\n }\r\n }\r\n\r\n private _prepareSourceElement(node: any, guiNode: any, variable: any, source: any, iterator: any): void {\r\n if (this._parentClass) {\r\n this._parentClass[variable] = source[iterator];\r\n } else {\r\n window[variable] = source[iterator];\r\n }\r\n\r\n if (node.firstChild) {\r\n this._parseXml(node.firstChild, guiNode, true);\r\n }\r\n }\r\n\r\n private _parseElementsFromSource(node: any, guiNode: any, parent: any): void {\r\n const dataSource = node.attributes.getNamedItem(\"dataSource\").value;\r\n\r\n if (!dataSource.includes(\" in \")) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Malformed XML, Data Source must include an in\";\r\n } else {\r\n let isArray = true;\r\n const splittedSource = dataSource.split(\" in \");\r\n if (splittedSource.length < 2) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Malformed XML, Data Source must have an iterator and a source\";\r\n }\r\n let source = splittedSource[1];\r\n if (source.startsWith(\"{\") && source.endsWith(\"}\")) {\r\n isArray = false;\r\n }\r\n\r\n if (!isArray || (source.startsWith(\"[\") && source.endsWith(\"]\"))) {\r\n source = source.substring(1, source.length - 1);\r\n }\r\n\r\n if (this._parentClass) {\r\n source = this._parentClass[source];\r\n } else {\r\n source = window[source];\r\n }\r\n\r\n if (isArray) {\r\n for (let i = 0; i < source.length; i++) {\r\n this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);\r\n }\r\n } else {\r\n for (const i in source) {\r\n this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);\r\n }\r\n }\r\n\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent);\r\n }\r\n }\r\n }\r\n\r\n private _parseXml(node: any, parent: any, generated: boolean = false): void {\r\n if (node.nodeType != this._nodeTypes.element) {\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent, generated);\r\n }\r\n return;\r\n }\r\n\r\n if (generated) {\r\n node.setAttribute(\"id\", parent.id + (parent._children.length + 1));\r\n }\r\n\r\n const guiNode = this._createGuiElement(node, parent);\r\n\r\n if (!this._rootNode) {\r\n this._rootNode = guiNode;\r\n }\r\n\r\n if (node.nodeName == \"Grid\") {\r\n this._parseGrid(node, guiNode, parent);\r\n } else if (!node.attributes.getNamedItem(\"dataSource\")) {\r\n this._parseElement(node, guiNode, parent);\r\n } else {\r\n this._parseElementsFromSource(node, guiNode, parent);\r\n }\r\n }\r\n\r\n /**\r\n * Gets if the loading has finished.\r\n * @returns whether the loading has finished or not\r\n */\r\n public isLoaded(): boolean {\r\n return this._isLoaded;\r\n }\r\n\r\n /**\r\n * Gets a loaded node / control by id.\r\n * @param id the Controls id set in the xml\r\n * @returns element of type Control\r\n */\r\n public getNodeById(id: string): any {\r\n return this._nodes[id];\r\n }\r\n\r\n /**\r\n * Gets all loaded nodes / controls\r\n * @returns Array of controls\r\n */\r\n public getNodes(): any {\r\n return this._nodes;\r\n }\r\n /**\r\n * Disposes the loaded layout\r\n */\r\n public dispose(): void {\r\n if (this._rootNode) {\r\n this._rootNode.dispose();\r\n this._rootNode = null;\r\n this._nodes = {};\r\n }\r\n }\r\n\r\n /**\r\n * Initiates the xml layout loading\r\n * @param xmlFile defines the xml layout to load\r\n * @param rootNode defines the node / control to use as a parent for the loaded layout controls.\r\n * @param onSuccess defines the callback called on layout load successfully.\r\n * @param onError defines the callback called on layout load failure.\r\n */\r\n public loadLayout(xmlFile: any, rootNode: any, onSuccess: Nullable<() => void> = null, onError: Nullable<(error: string) => void> = null): void {\r\n const xhttp = new XMLHttpRequest();\r\n xhttp.onload = () => {\r\n if (xhttp.readyState === 4 && xhttp.status === 200) {\r\n if (!xhttp.responseXML) {\r\n if (onError) {\r\n onError(XmlLoaderError);\r\n return;\r\n } else {\r\n throw XmlLoaderError;\r\n }\r\n }\r\n\r\n const xmlDoc = xhttp.responseXML.documentElement;\r\n this._parseXml(xmlDoc.firstChild, rootNode);\r\n this._isLoaded = true;\r\n\r\n if (onSuccess) {\r\n onSuccess();\r\n }\r\n }\r\n };\r\n\r\n xhttp.onerror = function () {\r\n if (onError) {\r\n onError(\"an error occurred during loading the layout\");\r\n }\r\n };\r\n\r\n xhttp.open(\"GET\", xmlFile, true);\r\n xhttp.send();\r\n }\r\n /**\r\n * Initiates the xml layout loading asynchronously\r\n * @param xmlFile defines the xml layout to load\r\n * @param rootNode defines the node / control to use as a parent for the loaded layout controls.\r\n * @returns Promise\r\n */\r\n public async loadLayoutAsync(xmlFile: any, rootNode: any): Promise<any> {\r\n return new Promise((resolve: any, reject: any) => {\r\n this.loadLayout(xmlFile, rootNode, resolve, reject);\r\n });\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"xmlLoader.js","sourceRoot":"","sources":["../../../../dev/gui/src/2D/xmlLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,0CAA4B;AAG/C,MAAM,cAAc,GAAG,2DAA2D,CAAC;AAEnF;;GAEG;AACH,MAAM,OAAO,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C,CAAC;gBAC5C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;gBAEtB,IAAI,SAAS,EAAE,CAAC;oBACZ,SAAS,EAAE,CAAC;gBAChB,CAAC;YACL,CAAC;QACL,CAAC,CAAC;QAEF,KAAK,CAAC,OAAO,GAAG;YACZ,IAAI,OAAO,EAAE,CAAC;gBACV,OAAO,CAAC,6CAA6C,CAAC,CAAC;YAC3D,CAAC;QACL,CAAC,CAAC;QAEF,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QACjC,KAAK,CAAC,IAAI,EAAE,CAAC;IACjB,CAAC;IACD;;;;;OAKG;IACI,KAAK,CAAC,eAAe,CAAC,OAAY,EAAE,QAAa;QACpD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAY,EAAE,MAAW,EAAE,EAAE;YAC7C,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import { GetClass } from \"core/Misc/typeStore\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nconst XmlLoaderError = \"XmlLoader Exception : XML file is malformed or corrupted.\";\r\n\r\n/**\r\n * Class used to load GUI via XML.\r\n */\r\nexport class XmlLoader {\r\n private _nodes: any = {};\r\n\r\n private _nodeTypes: any = {\r\n element: 1,\r\n attribute: 2,\r\n text: 3,\r\n };\r\n\r\n private _isLoaded: boolean = false;\r\n\r\n private _objectAttributes: any = {\r\n textHorizontalAlignment: 1,\r\n textVerticalAlignment: 2,\r\n horizontalAlignment: 3,\r\n verticalAlignment: 4,\r\n stretch: 5,\r\n };\r\n\r\n private _rootNode: any;\r\n\r\n private _parentClass: any;\r\n\r\n /**\r\n * Create a new xml loader\r\n * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context\r\n */\r\n constructor(parentClass: any = null) {\r\n if (parentClass) {\r\n this._parentClass = parentClass;\r\n }\r\n }\r\n\r\n private _getChainElement(attributeValue: any): any {\r\n let element: any = window;\r\n\r\n if (this._parentClass) {\r\n element = this._parentClass;\r\n }\r\n let value = attributeValue;\r\n value = value.split(\".\");\r\n\r\n for (let i = 0; i < value.length; i++) {\r\n element = element[value[i]];\r\n }\r\n return element;\r\n }\r\n\r\n private _getClassAttribute(attributeName: string): any {\r\n const attribute = attributeName.split(\".\");\r\n const className = GetClass(\"BABYLON.GUI.\" + attribute[0]);\r\n return className[attribute[1]];\r\n }\r\n\r\n private _createGuiElement(node: any, parent: any, linkParent: boolean = true): void {\r\n try {\r\n const className = GetClass(\"BABYLON.GUI.\" + node.nodeName);\r\n const guiNode = new className();\r\n\r\n if (parent && linkParent) {\r\n parent.addControl(guiNode);\r\n }\r\n\r\n for (let i = 0; i < node.attributes.length; i++) {\r\n if (node.attributes[i].name.toLowerCase().includes(\"datasource\")) {\r\n continue;\r\n }\r\n\r\n if (node.attributes[i].name.toLowerCase().includes(\"observable\")) {\r\n const element = this._getChainElement(node.attributes[i].value);\r\n guiNode[node.attributes[i].name].add(element);\r\n\r\n continue;\r\n } else if (node.attributes[i].name == \"linkWithMesh\") {\r\n if (this._parentClass) {\r\n guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);\r\n } else {\r\n guiNode.linkWithMesh(window[node.attributes[i].value]);\r\n }\r\n } else if (node.attributes[i].value.match(/{{.*}}/)) {\r\n const matches = node.attributes[i].value.match(/{{(.*)}}/);\r\n let element = this._getChainElement(matches[1]);\r\n if (!(node.attributes[i].value.startsWith(\"{{\") && node.attributes[i].value.endsWith(\"}}\"))) {\r\n element = (node.attributes[i].value as string).replace(/{{.*}}/, `${element}`);\r\n }\r\n guiNode[node.attributes[i].name] = element;\r\n } else if (!this._objectAttributes[node.attributes[i].name]) {\r\n if (node.attributes[i].value == \"true\" || node.attributes[i].value == \"false\") {\r\n guiNode[node.attributes[i].name] = node.attributes[i].value == \"true\";\r\n } else {\r\n guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;\r\n }\r\n } else {\r\n guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);\r\n }\r\n }\r\n\r\n if (!node.attributes.getNamedItem(\"id\")) {\r\n this._nodes[node.nodeName + Object.keys(this._nodes).length + \"_gen\"] = guiNode;\r\n return guiNode;\r\n }\r\n\r\n let id = node.attributes.getNamedItem(\"id\").value;\r\n if (id.startsWith(\"{{\") && id.endsWith(\"}}\")) {\r\n id = this._getChainElement(id.substring(2, id.length - 2));\r\n }\r\n\r\n if (!this._nodes[id]) {\r\n this._nodes[id] = guiNode;\r\n } else {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute\";\r\n }\r\n return guiNode;\r\n } catch (exception) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Error parsing Control \" + node.nodeName + \",\" + exception + \".\";\r\n }\r\n }\r\n\r\n private _parseGrid(node: any, guiNode: any, parent: any): void {\r\n let width;\r\n let height;\r\n let columns;\r\n const rows = node.children;\r\n let cells;\r\n let isPixel = false;\r\n let cellNode;\r\n let rowNumber = -1;\r\n let columnNumber = -1;\r\n let totalColumnsNumber = 0;\r\n\r\n for (let i = 0; i < rows.length; i++) {\r\n if (rows[i].nodeType != this._nodeTypes.element) {\r\n continue;\r\n }\r\n if (rows[i].nodeName != \"Row\") {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Expecting Row node, received \" + rows[i].nodeName;\r\n }\r\n rowNumber += 1;\r\n columns = rows[i].children;\r\n\r\n if (!rows[i].attributes.getNamedItem(\"height\")) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Height must be defined for grid rows\";\r\n }\r\n height = Number(rows[i].attributes.getNamedItem(\"height\").nodeValue);\r\n isPixel = rows[i].attributes.getNamedItem(\"isPixel\") ? JSON.parse(rows[i].attributes.getNamedItem(\"isPixel\").nodeValue) : false;\r\n guiNode.addRowDefinition(height, isPixel);\r\n\r\n for (let j = 0; j < columns.length; j++) {\r\n if (columns[j].nodeType != this._nodeTypes.element) {\r\n continue;\r\n }\r\n if (columns[j].nodeName != \"Column\") {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Expecting Column node, received \" + columns[j].nodeName;\r\n }\r\n columnNumber += 1;\r\n if (rowNumber > 0 && columnNumber > totalColumnsNumber) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : In the Grid element, the number of columns is defined in the first row, do not add more columns in the subsequent rows.\";\r\n }\r\n\r\n if (rowNumber == 0) {\r\n if (!columns[j].attributes.getNamedItem(\"width\")) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Width must be defined for all the grid columns in the first row\";\r\n }\r\n width = Number(columns[j].attributes.getNamedItem(\"width\").nodeValue);\r\n isPixel = columns[j].attributes.getNamedItem(\"isPixel\") ? JSON.parse(columns[j].attributes.getNamedItem(\"isPixel\").nodeValue) : false;\r\n guiNode.addColumnDefinition(width, isPixel);\r\n }\r\n\r\n cells = columns[j].children;\r\n\r\n for (let k = 0; k < cells.length; k++) {\r\n if (cells[k].nodeType != this._nodeTypes.element) {\r\n continue;\r\n }\r\n cellNode = this._createGuiElement(cells[k], guiNode, false);\r\n guiNode.addControl(cellNode, rowNumber, columnNumber);\r\n if (cells[k].firstChild) {\r\n this._parseXml(cells[k].firstChild, cellNode);\r\n }\r\n }\r\n }\r\n if (rowNumber == 0) {\r\n totalColumnsNumber = columnNumber;\r\n }\r\n columnNumber = -1;\r\n }\r\n\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent);\r\n }\r\n }\r\n\r\n private _parseElement(node: any, guiNode: any, parent: any): void {\r\n if (node.firstChild) {\r\n this._parseXml(node.firstChild, guiNode);\r\n }\r\n\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent);\r\n }\r\n }\r\n\r\n private _prepareSourceElement(node: any, guiNode: any, variable: any, source: any, iterator: any): void {\r\n if (this._parentClass) {\r\n this._parentClass[variable] = source[iterator];\r\n } else {\r\n window[variable] = source[iterator];\r\n }\r\n\r\n if (node.firstChild) {\r\n this._parseXml(node.firstChild, guiNode, true);\r\n }\r\n }\r\n\r\n private _parseElementsFromSource(node: any, guiNode: any, parent: any): void {\r\n const dataSource = node.attributes.getNamedItem(\"dataSource\").value;\r\n\r\n if (!dataSource.includes(\" in \")) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Malformed XML, Data Source must include an in\";\r\n } else {\r\n let isArray = true;\r\n const splittedSource = dataSource.split(\" in \");\r\n if (splittedSource.length < 2) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"XmlLoader Exception : Malformed XML, Data Source must have an iterator and a source\";\r\n }\r\n let source = splittedSource[1];\r\n if (source.startsWith(\"{\") && source.endsWith(\"}\")) {\r\n isArray = false;\r\n }\r\n\r\n if (!isArray || (source.startsWith(\"[\") && source.endsWith(\"]\"))) {\r\n source = source.substring(1, source.length - 1);\r\n }\r\n\r\n if (this._parentClass) {\r\n source = this._parentClass[source];\r\n } else {\r\n source = window[source];\r\n }\r\n\r\n if (isArray) {\r\n for (let i = 0; i < source.length; i++) {\r\n this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);\r\n }\r\n } else {\r\n for (const i in source) {\r\n this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);\r\n }\r\n }\r\n\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent);\r\n }\r\n }\r\n }\r\n\r\n private _parseXml(node: any, parent: any, generated: boolean = false): void {\r\n if (node.nodeType != this._nodeTypes.element) {\r\n if (node.nextSibling) {\r\n this._parseXml(node.nextSibling, parent, generated);\r\n }\r\n return;\r\n }\r\n\r\n if (generated) {\r\n node.setAttribute(\"id\", parent.id + (parent._children.length + 1));\r\n }\r\n\r\n const guiNode = this._createGuiElement(node, parent);\r\n\r\n if (!this._rootNode) {\r\n this._rootNode = guiNode;\r\n }\r\n\r\n if (node.nodeName == \"Grid\") {\r\n this._parseGrid(node, guiNode, parent);\r\n } else if (!node.attributes.getNamedItem(\"dataSource\")) {\r\n this._parseElement(node, guiNode, parent);\r\n } else {\r\n this._parseElementsFromSource(node, guiNode, parent);\r\n }\r\n }\r\n\r\n /**\r\n * Gets if the loading has finished.\r\n * @returns whether the loading has finished or not\r\n */\r\n public isLoaded(): boolean {\r\n return this._isLoaded;\r\n }\r\n\r\n /**\r\n * Gets a loaded node / control by id.\r\n * @param id the Controls id set in the xml\r\n * @returns element of type Control\r\n */\r\n public getNodeById(id: string): any {\r\n return this._nodes[id];\r\n }\r\n\r\n /**\r\n * Gets all loaded nodes / controls\r\n * @returns Array of controls\r\n */\r\n public getNodes(): any {\r\n return this._nodes;\r\n }\r\n /**\r\n * Disposes the loaded layout\r\n */\r\n public dispose(): void {\r\n if (this._rootNode) {\r\n this._rootNode.dispose();\r\n this._rootNode = null;\r\n this._nodes = {};\r\n }\r\n }\r\n\r\n /**\r\n * Initiates the xml layout loading\r\n * @param xmlFile defines the xml layout to load\r\n * @param rootNode defines the node / control to use as a parent for the loaded layout controls.\r\n * @param onSuccess defines the callback called on layout load successfully.\r\n * @param onError defines the callback called on layout load failure.\r\n */\r\n public loadLayout(xmlFile: any, rootNode: any, onSuccess: Nullable<() => void> = null, onError: Nullable<(error: string) => void> = null): void {\r\n const xhttp = new XMLHttpRequest();\r\n xhttp.onload = () => {\r\n if (xhttp.readyState === 4 && xhttp.status === 200) {\r\n if (!xhttp.responseXML) {\r\n if (onError) {\r\n onError(XmlLoaderError);\r\n return;\r\n } else {\r\n throw XmlLoaderError;\r\n }\r\n }\r\n\r\n const xmlDoc = xhttp.responseXML.documentElement;\r\n this._parseXml(xmlDoc.firstChild, rootNode);\r\n this._isLoaded = true;\r\n\r\n if (onSuccess) {\r\n onSuccess();\r\n }\r\n }\r\n };\r\n\r\n xhttp.onerror = function () {\r\n if (onError) {\r\n onError(\"an error occurred during loading the layout\");\r\n }\r\n };\r\n\r\n xhttp.open(\"GET\", xmlFile, true);\r\n xhttp.send();\r\n }\r\n /**\r\n * Initiates the xml layout loading asynchronously\r\n * @param xmlFile defines the xml layout to load\r\n * @param rootNode defines the node / control to use as a parent for the loaded layout controls.\r\n * @returns Promise\r\n */\r\n public async loadLayoutAsync(xmlFile: any, rootNode: any): Promise<any> {\r\n return new Promise((resolve: any, reject: any) => {\r\n this.loadLayout(xmlFile, rootNode, resolve, reject);\r\n });\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"defaultBehavior.js","sourceRoot":"","sources":["../../../../../dev/gui/src/3D/behaviors/defaultBehavior.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,2DAA6C;AACtE,OAAO,EAAE,kBAAkB,EAAE,+DAAiD;AAK9E,OAAO,EAAE,wBAAwB,EAAE,qEAAuD;AAK1F;;;;GAIG;AACH,MAAM,OAAO,eAAe;IAQxB;;OAEG;IACH;QAuCA;;WAEG;QACI,0BAAqB,GAAY,KAAK,CAAC;QAE9C;;WAEG;QACI,8BAAyB,GAAY,IAAI,CAAC;QAEjD;;WAEG;QACI,oCAA+B,GAAY,IAAI,CAAC;QAnDnD,IAAI,CAAC,eAAe,GAAG,IAAI,cAAc,EAAE,CAAC;QAC5C,IAAI,CAAC,mBAAmB,GAAG,IAAI,kBAAkB,EAAE,CAAC;QACpD,IAAI,CAAC,yBAAyB,GAAG,IAAI,wBAAwB,EAAE,CAAC;IACpE,CAAC;IAOD;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,SAAS,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,IAAW,kBAAkB;QACzB,OAAO,IAAI,CAAC,mBAAmB,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,IAAW,wBAAwB;QAC/B,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AQ,GAAG,CAAC,IAAI,CAAC,mBAAmB,CAAC,QAAQ,IAAI,IAAI,CAAC,qBAAqB,CAAC;QACrG,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,KAAgC,EAAE,EAAE;YACtG,IAAI,CAAC,mBAAmB,CAAC,eAAe,GAAG,IAAI,CAAC,yBAAyB,CAAC,mBAAmB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAClH,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,kBAAkB;QACtB,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QAC1E,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC3E,CAAC;CACJ","sourcesContent":["import type { Behavior } from \"core/Behaviors/behavior\";\r\nimport { FollowBehavior } from \"core/Behaviors/Meshes/followBehavior\";\r\nimport { SixDofDragBehavior } from \"core/Behaviors/Meshes/sixDofDragBehavior\";\r\nimport type { Scene } from \"core/scene\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { SurfaceMagnetismBehavior } from \"core/Behaviors/Meshes/surfaceMagnetismBehavior\";\r\nimport type { Vector3 } from \"core/Maths/math.vector\";\r\nimport type { PickingInfo } from \"core/Collisions/pickingInfo\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\n\r\n/**\r\n * Default behavior for 3D UI elements.\r\n * Handles a FollowBehavior, SixDofBehavior and SurfaceMagnetismBehavior\r\n * @since 5.0.0\r\n */\r\nexport class DefaultBehavior implements Behavior<Mesh> {\r\n private _scene: Scene;\r\n private _followBehavior: FollowBehavior;\r\n private _sixDofDragBehavior: SixDofDragBehavior;\r\n private _surfaceMagnetismBehavior: SurfaceMagnetismBehavior;\r\n private _onBeforeRenderObserver: Nullable<Observer<Scene>>;\r\n private _onDragObserver: Nullable<Observer<{ delta: Vector3; position: Vector3; pickInfo: PickingInfo }>>;\r\n\r\n /**\r\n * Instantiates the default behavior\r\n */\r\n constructor() {\r\n this._followBehavior = new FollowBehavior();\r\n this._sixDofDragBehavior = new SixDofDragBehavior();\r\n this._surfaceMagnetismBehavior = new SurfaceMagnetismBehavior();\r\n }\r\n\r\n /**\r\n * Attached node of this behavior\r\n */\r\n public attachedNode: Nullable<Mesh>;\r\n\r\n /**\r\n * The name of the behavior\r\n */\r\n public get name(): string {\r\n return \"Default\";\r\n }\r\n\r\n /**\r\n * The follow behavior\r\n */\r\n public get followBehavior(): FollowBehavior {\r\n return this._followBehavior;\r\n }\r\n\r\n /**\r\n * The six DoF drag behavior\r\n */\r\n public get sixDofDragBehavior(): SixDofDragBehavior {\r\n return this._sixDofDragBehavior;\r\n }\r\n\r\n /**\r\n * The surface magnetism behavior\r\n */\r\n public get surfaceMagnetismBehavior(): SurfaceMagnetismBehavior {\r\n return this._surfaceMagnetismBehavior;\r\n }\r\n\r\n /**\r\n * Enables the follow behavior\r\n */\r\n public followBehaviorEnabled: boolean = false;\r\n\r\n /**\r\n * Enables the six DoF drag behavior\r\n */\r\n public sixDofDragBehaviorEnabled: boolean = true;\r\n\r\n /**\r\n * Enables the surface magnetism behavior\r\n */\r\n public surfaceMagnetismBehaviorEnabled: boolean = true;\r\n\r\n /**\r\n * Initializes the behavior\r\n */\r\n public init() {}\r\n\r\n /**\r\n * Attaches the default behavior\r\n * @param ownerMesh The top level mesh\r\n * @param draggablesMeshes Descendant meshes that can be used for dragging the owner mesh\r\n * @param sceneUnderstandingMeshes Meshes from the scene understanding that will be used for surface magnetism\r\n */\r\n public attach(ownerMesh: Mesh, draggablesMeshes?: Mesh[], sceneUnderstandingMeshes?: AbstractMesh[]): void {\r\n this._scene = ownerMesh.getScene();\r\n this.attachedNode = ownerMesh;\r\n\r\n this._addObservables();\r\n // Since our observables are bound before the child behaviors', ours are called first\r\n this._followBehavior.attach(ownerMesh);\r\n this._sixDofDragBehavior.attach(ownerMesh);\r\n this._sixDofDragBehavior.draggableMeshes = draggablesMeshes || null;\r\n this._sixDofDragBehavior.faceCameraOnDragStart = true;\r\n this._surfaceMagnetismBehavior.attach(ownerMesh, this._scene);\r\n if (sceneUnderstandingMeshes) {\r\n this._surfaceMagnetismBehavior.meshes = sceneUnderstandingMeshes;\r\n }\r\n\r\n // We disable this behavior because we will handle pose changing event manually with sixDofDragBehavior\r\n this._surfaceMagnetismBehavior.enabled = false;\r\n }\r\n\r\n /**\r\n * Detaches the behavior from the mesh\r\n */\r\n public detach(): void {\r\n this.attachedNode = null;\r\n this._removeObservables();\r\n this._followBehavior.detach();\r\n this._sixDofDragBehavior.detach();\r\n this._surfaceMagnetismBehavior.detach();\r\n }\r\n\r\n private _addObservables() {\r\n this._onBeforeRenderObserver = this._scene.onBeforeRenderObservable.add(() => {\r\n this._followBehavior._enabled = !this._sixDofDragBehavior.isMoving && this.followBehaviorEnabled;\r\n });\r\n this._onDragObserver = this._sixDofDragBehavior.onDragObservable.add((event: { pickInfo: PickingInfo }) => {\r\n this._sixDofDragBehavior.disableMovement = this._surfaceMagnetismBehavior.findAndUpdateTarget(event.pickInfo);\r\n });\r\n }\r\n\r\n private _removeObservables() {\r\n this._scene.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);\r\n this._sixDofDragBehavior.onDragObservable.remove(this._onDragObserver);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"defaultBehavior.js","sourceRoot":"","sources":["../../../../../dev/gui/src/3D/behaviors/defaultBehavior.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,2DAA6C;AACtE,OAAO,EAAE,kBAAkB,EAAE,+DAAiD;AAK9E,OAAO,EAAE,wBAAwB,EAAE,qEAAuD;AAK1F;;;;GAIG;AACH,MAAM,OAAO,eAAe;IAQxB;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nimport { FollowBehavior } from \"core/Behaviors/Meshes/followBehavior\";\r\nimport { SixDofDragBehavior } from \"core/Behaviors/Meshes/sixDofDragBehavior\";\r\nimport type { Scene } from \"core/scene\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { SurfaceMagnetismBehavior } from \"core/Behaviors/Meshes/surfaceMagnetismBehavior\";\r\nimport type { Vector3 } from \"core/Maths/math.vector\";\r\nimport type { PickingInfo } from \"core/Collisions/pickingInfo\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\n\r\n/**\r\n * Default behavior for 3D UI elements.\r\n * Handles a FollowBehavior, SixDofBehavior and SurfaceMagnetismBehavior\r\n * @since 5.0.0\r\n */\r\nexport class DefaultBehavior implements Behavior<Mesh> {\r\n private _scene: Scene;\r\n private _followBehavior: FollowBehavior;\r\n private _sixDofDragBehavior: SixDofDragBehavior;\r\n private _surfaceMagnetismBehavior: SurfaceMagnetismBehavior;\r\n private _onBeforeRenderObserver: Nullable<Observer<Scene>>;\r\n private _onDragObserver: Nullable<Observer<{ delta: Vector3; position: Vector3; pickInfo: PickingInfo }>>;\r\n\r\n /**\r\n * Instantiates the default behavior\r\n */\r\n constructor() {\r\n this._followBehavior = new FollowBehavior();\r\n this._sixDofDragBehavior = new SixDofDragBehavior();\r\n this._surfaceMagnetismBehavior = new SurfaceMagnetismBehavior();\r\n }\r\n\r\n /**\r\n * Attached node of this behavior\r\n */\r\n public attachedNode: Nullable<Mesh>;\r\n\r\n /**\r\n * The name of the behavior\r\n */\r\n public get name(): string {\r\n return \"Default\";\r\n }\r\n\r\n /**\r\n * The follow behavior\r\n */\r\n public get followBehavior(): FollowBehavior {\r\n return this._followBehavior;\r\n }\r\n\r\n /**\r\n * The six DoF drag behavior\r\n */\r\n public get sixDofDragBehavior(): SixDofDragBehavior {\r\n return this._sixDofDragBehavior;\r\n }\r\n\r\n /**\r\n * The surface magnetism behavior\r\n */\r\n public get surfaceMagnetismBehavior(): SurfaceMagnetismBehavior {\r\n return this._surfaceMagnetismBehavior;\r\n }\r\n\r\n /**\r\n * Enables the follow behavior\r\n */\r\n public followBehaviorEnabled: boolean = false;\r\n\r\n /**\r\n * Enables the six DoF drag behavior\r\n */\r\n public sixDofDragBehaviorEnabled: boolean = true;\r\n\r\n /**\r\n * Enables the surface magnetism behavior\r\n */\r\n public surfaceMagnetismBehaviorEnabled: boolean = true;\r\n\r\n /**\r\n * Initializes the behavior\r\n */\r\n public init() {}\r\n\r\n /**\r\n * Attaches the default behavior\r\n * @param ownerMesh The top level mesh\r\n * @param draggablesMeshes Descendant meshes that can be used for dragging the owner mesh\r\n * @param sceneUnderstandingMeshes Meshes from the scene understanding that will be used for surface magnetism\r\n */\r\n public attach(ownerMesh: Mesh, draggablesMeshes?: Mesh[], sceneUnderstandingMeshes?: AbstractMesh[]): void {\r\n this._scene = ownerMesh.getScene();\r\n this.attachedNode = ownerMesh;\r\n\r\n this._addObservables();\r\n // Since our observables are bound before the child behaviors', ours are called first\r\n this._followBehavior.attach(ownerMesh);\r\n this._sixDofDragBehavior.attach(ownerMesh);\r\n this._sixDofDragBehavior.draggableMeshes = draggablesMeshes || null;\r\n this._sixDofDragBehavior.faceCameraOnDragStart = true;\r\n this._surfaceMagnetismBehavior.attach(ownerMesh, this._scene);\r\n if (sceneUnderstandingMeshes) {\r\n this._surfaceMagnetismBehavior.meshes = sceneUnderstandingMeshes;\r\n }\r\n\r\n // We disable this behavior because we will handle pose changing event manually with sixDofDragBehavior\r\n this._surfaceMagnetismBehavior.enabled = false;\r\n }\r\n\r\n /**\r\n * Detaches the behavior from the mesh\r\n */\r\n public detach(): void {\r\n this.attachedNode = null;\r\n this._removeObservables();\r\n this._followBehavior.detach();\r\n this._sixDofDragBehavior.detach();\r\n this._surfaceMagnetismBehavior.detach();\r\n }\r\n\r\n private _addObservables() {\r\n this._onBeforeRenderObserver = this._scene.onBeforeRenderObservable.add(() => {\r\n this._followBehavior._enabled = !this._sixDofDragBehavior.isMoving && this.followBehaviorEnabled;\r\n });\r\n this._onDragObserver = this._sixDofDragBehavior.onDragObservable.add((event: { pickInfo: PickingInfo }) => {\r\n this._sixDofDragBehavior.disableMovement = this._surfaceMagnetismBehavior.findAndUpdateTarget(event.pickInfo);\r\n });\r\n }\r\n\r\n private _removeObservables() {\r\n this._scene.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);\r\n this._sixDofDragBehavior.onDragObservable.remove(this._onDragObserver);\r\n }\r\n}\r\n"]}