@babylonjs/shared-ui-components 7.6.0 → 7.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Fonts.scss +0 -1
- package/components/colorPicker/ColorComponentEntry.d.ts +1 -1
- package/components/colorPicker/ColorComponentEntry.js +1 -1
- package/components/colorPicker/ColorComponentEntry.js.map +1 -1
- package/components/colorPicker/ColorPicker.d.ts +4 -4
- package/components/colorPicker/ColorPicker.js +8 -8
- package/components/colorPicker/ColorPicker.js.map +1 -1
- package/components/colorPicker/HexColor.d.ts +1 -1
- package/components/colorPicker/HexColor.js +1 -1
- package/components/colorPicker/HexColor.js.map +1 -1
- package/components/lines/ColorPickerLineComponent.d.ts +5 -5
- package/components/lines/ColorPickerLineComponent.js +2 -2
- package/components/lines/ColorPickerLineComponent.js.map +1 -1
- package/components/reactGraphSystem/GraphNode.d.ts +1 -1
- package/components/reactGraphSystem/GraphNode.js +1 -1
- package/components/reactGraphSystem/GraphNode.js.map +1 -1
- package/components/reactGraphSystem/NodeRenderer.js +2 -2
- package/components/reactGraphSystem/NodeRenderer.js.map +1 -1
- package/lines/color3LineComponent.js +2 -2
- package/lines/color3LineComponent.js.map +1 -1
- package/lines/color4LineComponent.js +2 -2
- package/lines/color4LineComponent.js.map +1 -1
- package/lines/colorLineComponent.d.ts +5 -5
- package/lines/colorLineComponent.js +5 -5
- package/lines/colorLineComponent.js.map +1 -1
- package/lines/colorPickerComponent.d.ts +5 -5
- package/lines/colorPickerComponent.js +1 -1
- package/lines/colorPickerComponent.js.map +1 -1
- package/lines/fileButtonLineComponent.d.ts +3 -3
- package/lines/fileButtonLineComponent.js +3 -3
- package/lines/fileButtonLineComponent.js.map +1 -1
- package/lines/matrixLineComponent.js +2 -2
- package/lines/matrixLineComponent.js.map +1 -1
- package/lines/numericInputComponent.d.ts +4 -4
- package/lines/numericInputComponent.js +2 -2
- package/lines/numericInputComponent.js.map +1 -1
- package/lines/optionsLineComponent.d.ts +4 -4
- package/lines/optionsLineComponent.js +1 -1
- package/lines/optionsLineComponent.js.map +1 -1
- package/lines/vector2LineComponent.js +2 -2
- package/lines/vector2LineComponent.js.map +1 -1
- package/lines/vector3LineComponent.js +2 -2
- package/lines/vector3LineComponent.js.map +1 -1
- package/lines/vector4LineComponent.js +2 -2
- package/lines/vector4LineComponent.js.map +1 -1
- package/package.json +1 -1
- package/stories/colorPicker/ColorPicker.stories.d.ts +3 -3
- package/stories/colorPicker/ColorPicker.stories.js +2 -2
- package/stories/colorPicker/ColorPicker.stories.js.map +1 -1
- package/stories/lines/ColorPickerLineComponent.stories.js.map +1 -1
- package/tabs/propertyGrids/gui/commonControlPropertyGridComponent.js +2 -2
- package/tabs/propertyGrids/gui/commonControlPropertyGridComponent.js.map +1 -1
- package/tabs/propertyGrids/gui/imagePropertyGridComponent.js +2 -2
- package/tabs/propertyGrids/gui/imagePropertyGridComponent.js.map +1 -1
- package/tabs/propertyGrids/gui/textBlockPropertyGridComponent.js +2 -2
- package/tabs/propertyGrids/gui/textBlockPropertyGridComponent.js.map +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"colorLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/colorLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,4CAA8B;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAEpE,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAC9F,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAElE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;A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Y,CAAC,KAAK,CAAC,GAAI,EAChJ,KAAC,qBAAqB,IAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,EAAC,GAAG,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAI,EAChJ,KAAC,qBAAqB,IAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,EAAC,GAAG,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAI,EAC/I,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,CACxB,KAAC,qBAAqB,IAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,EAAC,GAAG,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAI,CACnJ,IACC,CACT,IACC,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport { Color3, Color4 } from \"core/Maths/math.color\";\r\nimport { NumericInputComponent } from \"./numericInputComponent\";\r\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\r\nimport { faMinus, faPlus } from \"@fortawesome/free-solid-svg-icons\";\r\nimport type { PropertyChangedEvent } from \"../propertyChangedEvent\";\r\nimport { copyCommandToClipboard, getClassNameWithNamespace } from \"../copyCommandToClipboard\";\r\nimport { ColorPickerLineComponent } from \"./colorPickerComponent\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\nimport { conflictingValuesPlaceholder } from \"./targetsProxy\";\r\nimport copyIcon from \"./copy.svg\";\r\n\r\nconst emptyColor = new Color4(0, 0, 0, 0);\r\n\r\nexport interface IColorLineComponentProps {\r\n label: string;\r\n target?: any;\r\n propertyName: string;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n onChange?: () => void;\r\n isLinear?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n disableAlpha?: boolean;\r\n lockObject: LockObject;\r\n}\r\n\r\ninterface IColorLineComponentState {\r\n isExpanded: boolean;\r\n color: Color4;\r\n}\r\n\r\nexport class ColorLineComponent extends React.Component<IColorLineComponentProps, IColorLineComponentState> {\r\n constructor(props: IColorLineComponentProps) {\r\n super(props);\r\n\r\n this.state = { isExpanded: false, color: this.getValue() };\r\n\r\n const target = this.props.target;\r\n target._isLinearColor = props.isLinear; // so that replayRecorder can append toLinearSpace() as appropriate\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IColorLineComponentProps, nextState: IColorLineComponentState) {\r\n const stateColor = nextState.color;\r\n const propsColor = this.getValue(nextProps);\r\n if (stateColor !== this.state.color) {\r\n nextState.color = stateColor;\r\n return true;\r\n }\r\n if (propsColor !== this.state.color) {\r\n nextState.color = propsColor;\r\n return true;\r\n }\r\n if (nextState.isExpanded !== this.state.isExpanded) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n getValue(props = this.props): Color4 {\r\n const target = props.target;\r\n const property = target[props.propertyName];\r\n if (!property) return emptyColor;\r\n if (typeof property === \"string\") {\r\n if (property === conflictingValuesPlaceholder) {\r\n return emptyColor;\r\n }\r\n return this._convertToColor(property);\r\n } else {\r\n if (props.isLinear) {\r\n return property.toGammaSpace();\r\n }\r\n return property.clone();\r\n }\r\n }\r\n\r\n setColorFromString(colorString: string) {\r\n const color = this._convertToColor(colorString);\r\n this.setColor(color);\r\n }\r\n\r\n setColor(newColor: Color4) {\r\n this.setState({ color: newColor.clone() });\r\n if (this.props.isLinear) {\r\n newColor.toLinearSpaceToRef(newColor);\r\n }\r\n // whether to set properties to color3 or color4\r\n const setColor = this.props.disableAlpha ? this._toColor3(newColor) : newColor;\r\n\r\n const target = this.props.target;\r\n const initialValue = target[this.props.propertyName];\r\n const value = typeof target[this.props.propertyName] === \"string\" ? setColor.toHexString() : setColor;\r\n // make the change\r\n target[this.props.propertyName] = value;\r\n // notify observers\r\n if (this.props.onPropertyChangedObservable) {\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: target,\r\n property: this.props.propertyName,\r\n value,\r\n initialValue,\r\n });\r\n }\r\n\r\n if (this.props.onChange) {\r\n this.props.onChange();\r\n }\r\n }\r\n\r\n switchExpandState() {\r\n this.setState({ isExpanded: !this.state.isExpanded });\r\n }\r\n\r\n updateStateR(value: number) {\r\n this.setColor(new Color4(value, this.state.color.g, this.state.color.b, this.state.color.a));\r\n }\r\n\r\n updateStateG(value: number) {\r\n this.setColor(new Color4(this.state.color.r, value, this.state.color.b, this.state.color.a));\r\n }\r\n\r\n updateStateB(value: number) {\r\n this.setColor(new Color4(this.state.color.r, this.state.color.g, value, this.state.color.a));\r\n }\r\n\r\n updateStateA(value: number) {\r\n if (this.props.disableAlpha) {\r\n return;\r\n }\r\n this.setColor(new Color4(this.state.color.r, this.state.color.g, this.state.color.b, value));\r\n }\r\n\r\n private _convertToColor(color: string): Color4 {\r\n if (color === \"\" || color === \"transparent\") {\r\n return emptyColor;\r\n }\r\n\r\n if (color.substring(0, 1) !== \"#\" || (color.length !== 7 && color.length !== 9)) {\r\n const d = document.createElement(\"div\");\r\n d.style.color = color;\r\n document.body.append(d);\r\n const rgb = window.getComputedStyle(d).color;\r\n document.body.removeChild(d);\r\n\r\n const rgbArray = rgb\r\n .substring(4, rgb.length - 1)\r\n .replace(/ /g, \"\")\r\n .split(\",\");\r\n\r\n const alpha = rgbArray.length > 3 ? parseInt(rgbArray[3]) / 255 : 1.0;\r\n\r\n return new Color4(parseInt(rgbArray[0]) / 255, parseInt(rgbArray[1]) / 255, parseInt(rgbArray[2]) / 255, alpha);\r\n }\r\n\r\n if (this.props.disableAlpha) {\r\n const color3 = Color3.FromHexString(color);\r\n return new Color4(color3.r, color3.g, color3.b, 1.0);\r\n }\r\n\r\n return Color4.FromHexString(color);\r\n }\r\n\r\n private _toColor3(color: Color4) {\r\n return new Color3(color.r, color.g, color.b);\r\n }\r\n\r\n // Copy to clipboard the code this Color3 actually does\r\n // Example : material.diffuseColor = new BABYLON.Vector3(0,1,0);\r\n onCopyClick() {\r\n if (this.props && this.props.target) {\r\n const { className, babylonNamespace } = getClassNameWithNamespace(this.props.target);\r\n const targetName = \"globalThis.debugNode\";\r\n const targetProperty = this.props.propertyName;\r\n const value = this.props.target[this.props.propertyName!];\r\n const hex = this.state.color.toHexString();\r\n let strColor;\r\n if (value.a) {\r\n strColor = \"new \" + babylonNamespace + \"Color4(\" + value.r + \", \" + value.g + \", \" + value.b + \", \" + value.a + \")\";\r\n } else {\r\n strColor = \"new \" + babylonNamespace + \"Color3(\" + value.r + \", \" + value.g + \", \" + value.b + \")\";\r\n }\r\n strColor += \";// (HEX : \" + hex;\r\n const strCommand = targetName + \".\" + targetProperty + \" = \" + strColor + \" , debugNode as \" + babylonNamespace + className + \")\";\r\n copyCommandToClipboard(strCommand);\r\n } else {\r\n copyCommandToClipboard(\"undefined\");\r\n }\r\n }\r\n\r\n override render() {\r\n const chevron = this.state.isExpanded ? <FontAwesomeIcon icon={faMinus} /> : <FontAwesomeIcon icon={faPlus} />;\r\n\r\n return (\r\n <div className=\"color3Line\">\r\n <div className=\"firstLine\">\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <div className=\"label\" title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n <div className=\"color3\">\r\n <ColorPickerLineComponent\r\n lockObject={this.props.lockObject}\r\n linearHint={this.props.isLinear}\r\n value={this.props.disableAlpha ? this._toColor3(this.state.color) : this.state.color}\r\n onColorChanged={(colorString) => {\r\n this.setColorFromString(colorString);\r\n }}\r\n />\r\n </div>\r\n <div className=\"expand hoverIcon\" onClick={() => this.switchExpandState()} title=\"Expand\">\r\n {chevron}\r\n </div>\r\n <div className=\"copy hoverIcon\" onClick={() => this.onCopyClick()} title=\"Copy to clipboard\">\r\n <img src={copyIcon} alt=\"Copy\" />\r\n </div>\r\n </div>\r\n {this.state.isExpanded && (\r\n <div className=\"secondLine\">\r\n <NumericInputComponent lockObject={this.props.lockObject} label=\"r\" value={this.state.color.r} onChange={(value) => this.updateStateR(value)} />\r\n <NumericInputComponent lockObject={this.props.lockObject} label=\"g\" value={this.state.color.g} onChange={(value) => this.updateStateG(value)} />\r\n <NumericInputComponent lockObject={this.props.lockObject} label=\"b\" value={this.state.color.b} onChange={(value) => this.updateStateB(value)} />\r\n {this.props.disableAlpha || (\r\n <NumericInputComponent lockObject={this.props.lockObject} label=\"a\" value={this.state.color.a} onChange={(value) => this.updateStateA(value)} />\r\n )}\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
1
|
+
{"version":3,"file":"colorLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/colorLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,4CAA8B;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAEpE,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAC9F,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,QAAQ,MAA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ACvI,KAAC,YAAY,IAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,EAAC,GAAG,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAI,EACvI,KAAC,YAAY,IAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,EAAC,GAAG,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAI,EACtI,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,CACxB,KAAC,YAAY,IAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,EAAC,GAAG,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAI,CAC1I,IACC,CACT,IACC,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport { Color3, Color4 } from \"core/Maths/math.color\";\r\nimport { NumericInput } from \"./numericInputComponent\";\r\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\r\nimport { faMinus, faPlus } from \"@fortawesome/free-solid-svg-icons\";\r\nimport type { PropertyChangedEvent } from \"../propertyChangedEvent\";\r\nimport { copyCommandToClipboard, getClassNameWithNamespace } from \"../copyCommandToClipboard\";\r\nimport { ColorPickerLine } from \"./colorPickerComponent\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\nimport { conflictingValuesPlaceholder } from \"./targetsProxy\";\r\nimport copyIcon from \"./copy.svg\";\r\n\r\nconst emptyColor = new Color4(0, 0, 0, 0);\r\n\r\nexport interface IColorLineProps {\r\n label: string;\r\n target?: any;\r\n propertyName: string;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n onChange?: () => void;\r\n isLinear?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n disableAlpha?: boolean;\r\n lockObject: LockObject;\r\n}\r\n\r\ninterface IColorLineComponentState {\r\n isExpanded: boolean;\r\n color: Color4;\r\n}\r\n\r\nexport class ColorLine extends React.Component<IColorLineProps, IColorLineComponentState> {\r\n constructor(props: IColorLineProps) {\r\n super(props);\r\n\r\n this.state = { isExpanded: false, color: this.getValue() };\r\n\r\n const target = this.props.target;\r\n target._isLinearColor = props.isLinear; // so that replayRecorder can append toLinearSpace() as appropriate\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IColorLineProps, nextState: IColorLineComponentState) {\r\n const stateColor = nextState.color;\r\n const propsColor = this.getValue(nextProps);\r\n if (stateColor !== this.state.color) {\r\n nextState.color = stateColor;\r\n return true;\r\n }\r\n if (propsColor !== this.state.color) {\r\n nextState.color = propsColor;\r\n return true;\r\n }\r\n if (nextState.isExpanded !== this.state.isExpanded) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n getValue(props = this.props): Color4 {\r\n const target = props.target;\r\n const property = target[props.propertyName];\r\n if (!property) return emptyColor;\r\n if (typeof property === \"string\") {\r\n if (property === conflictingValuesPlaceholder) {\r\n return emptyColor;\r\n }\r\n return this._convertToColor(property);\r\n } else {\r\n if (props.isLinear) {\r\n return property.toGammaSpace();\r\n }\r\n return property.clone();\r\n }\r\n }\r\n\r\n setColorFromString(colorString: string) {\r\n const color = this._convertToColor(colorString);\r\n this.setColor(color);\r\n }\r\n\r\n setColor(newColor: Color4) {\r\n this.setState({ color: newColor.clone() });\r\n if (this.props.isLinear) {\r\n newColor.toLinearSpaceToRef(newColor);\r\n }\r\n // whether to set properties to color3 or color4\r\n const setColor = this.props.disableAlpha ? this._toColor3(newColor) : newColor;\r\n\r\n const target = this.props.target;\r\n const initialValue = target[this.props.propertyName];\r\n const value = typeof target[this.props.propertyName] === \"string\" ? setColor.toHexString() : setColor;\r\n // make the change\r\n target[this.props.propertyName] = value;\r\n // notify observers\r\n if (this.props.onPropertyChangedObservable) {\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: target,\r\n property: this.props.propertyName,\r\n value,\r\n initialValue,\r\n });\r\n }\r\n\r\n if (this.props.onChange) {\r\n this.props.onChange();\r\n }\r\n }\r\n\r\n switchExpandState() {\r\n this.setState({ isExpanded: !this.state.isExpanded });\r\n }\r\n\r\n updateStateR(value: number) {\r\n this.setColor(new Color4(value, this.state.color.g, this.state.color.b, this.state.color.a));\r\n }\r\n\r\n updateStateG(value: number) {\r\n this.setColor(new Color4(this.state.color.r, value, this.state.color.b, this.state.color.a));\r\n }\r\n\r\n updateStateB(value: number) {\r\n this.setColor(new Color4(this.state.color.r, this.state.color.g, value, this.state.color.a));\r\n }\r\n\r\n updateStateA(value: number) {\r\n if (this.props.disableAlpha) {\r\n return;\r\n }\r\n this.setColor(new Color4(this.state.color.r, this.state.color.g, this.state.color.b, value));\r\n }\r\n\r\n private _convertToColor(color: string): Color4 {\r\n if (color === \"\" || color === \"transparent\") {\r\n return emptyColor;\r\n }\r\n\r\n if (color.substring(0, 1) !== \"#\" || (color.length !== 7 && color.length !== 9)) {\r\n const d = document.createElement(\"div\");\r\n d.style.color = color;\r\n document.body.append(d);\r\n const rgb = window.getComputedStyle(d).color;\r\n document.body.removeChild(d);\r\n\r\n const rgbArray = rgb\r\n .substring(4, rgb.length - 1)\r\n .replace(/ /g, \"\")\r\n .split(\",\");\r\n\r\n const alpha = rgbArray.length > 3 ? parseInt(rgbArray[3]) / 255 : 1.0;\r\n\r\n return new Color4(parseInt(rgbArray[0]) / 255, parseInt(rgbArray[1]) / 255, parseInt(rgbArray[2]) / 255, alpha);\r\n }\r\n\r\n if (this.props.disableAlpha) {\r\n const color3 = Color3.FromHexString(color);\r\n return new Color4(color3.r, color3.g, color3.b, 1.0);\r\n }\r\n\r\n return Color4.FromHexString(color);\r\n }\r\n\r\n private _toColor3(color: Color4) {\r\n return new Color3(color.r, color.g, color.b);\r\n }\r\n\r\n // Copy to clipboard the code this Color3 actually does\r\n // Example : material.diffuseColor = new BABYLON.Vector3(0,1,0);\r\n onCopyClick() {\r\n if (this.props && this.props.target) {\r\n const { className, babylonNamespace } = getClassNameWithNamespace(this.props.target);\r\n const targetName = \"globalThis.debugNode\";\r\n const targetProperty = this.props.propertyName;\r\n const value = this.props.target[this.props.propertyName!];\r\n const hex = this.state.color.toHexString();\r\n let strColor;\r\n if (value.a) {\r\n strColor = \"new \" + babylonNamespace + \"Color4(\" + value.r + \", \" + value.g + \", \" + value.b + \", \" + value.a + \")\";\r\n } else {\r\n strColor = \"new \" + babylonNamespace + \"Color3(\" + value.r + \", \" + value.g + \", \" + value.b + \")\";\r\n }\r\n strColor += \";// (HEX : \" + hex;\r\n const strCommand = targetName + \".\" + targetProperty + \" = \" + strColor + \" , debugNode as \" + babylonNamespace + className + \")\";\r\n copyCommandToClipboard(strCommand);\r\n } else {\r\n copyCommandToClipboard(\"undefined\");\r\n }\r\n }\r\n\r\n override render() {\r\n const chevron = this.state.isExpanded ? <FontAwesomeIcon icon={faMinus} /> : <FontAwesomeIcon icon={faPlus} />;\r\n\r\n return (\r\n <div className=\"color3Line\">\r\n <div className=\"firstLine\">\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <div className=\"label\" title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n <div className=\"color3\">\r\n <ColorPickerLine\r\n lockObject={this.props.lockObject}\r\n linearHint={this.props.isLinear}\r\n value={this.props.disableAlpha ? this._toColor3(this.state.color) : this.state.color}\r\n onColorChanged={(colorString) => {\r\n this.setColorFromString(colorString);\r\n }}\r\n />\r\n </div>\r\n <div className=\"expand hoverIcon\" onClick={() => this.switchExpandState()} title=\"Expand\">\r\n {chevron}\r\n </div>\r\n <div className=\"copy hoverIcon\" onClick={() => this.onCopyClick()} title=\"Copy to clipboard\">\r\n <img src={copyIcon} alt=\"Copy\" />\r\n </div>\r\n </div>\r\n {this.state.isExpanded && (\r\n <div className=\"secondLine\">\r\n <NumericInput lockObject={this.props.lockObject} label=\"r\" value={this.state.color.r} onChange={(value) => this.updateStateR(value)} />\r\n <NumericInput lockObject={this.props.lockObject} label=\"g\" value={this.state.color.g} onChange={(value) => this.updateStateG(value)} />\r\n <NumericInput lockObject={this.props.lockObject} label=\"b\" value={this.state.color.b} onChange={(value) => this.updateStateB(value)} />\r\n {this.props.disableAlpha || (\r\n <NumericInput lockObject={this.props.lockObject} label=\"a\" value={this.state.color.a} onChange={(value) => this.updateStateA(value)} />\r\n )}\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import * as React from "react";
|
2
2
|
import type { Color4, Color3 } from "@babylonjs/core/Maths/math.color.js";
|
3
3
|
import type { LockObject } from "../tabs/propertyGrids/lockObject";
|
4
|
-
export interface
|
4
|
+
export interface IColorPickerLineProps {
|
5
5
|
value: Color4 | Color3;
|
6
6
|
linearHint?: boolean;
|
7
7
|
onColorChanged: (newOne: string) => void;
|
@@ -15,13 +15,13 @@ interface IColorPickerComponentState {
|
|
15
15
|
color: Color3 | Color4;
|
16
16
|
hex: string;
|
17
17
|
}
|
18
|
-
export declare class
|
18
|
+
export declare class ColorPickerLine extends React.Component<IColorPickerLineProps, IColorPickerComponentState> {
|
19
19
|
private _floatRef;
|
20
20
|
private _floatHostRef;
|
21
|
-
constructor(props:
|
21
|
+
constructor(props: IColorPickerLineProps);
|
22
22
|
syncPositions(): void;
|
23
|
-
shouldComponentUpdate(nextProps:
|
24
|
-
getHexString(props?: Readonly<
|
23
|
+
shouldComponentUpdate(nextProps: IColorPickerLineProps, nextState: IColorPickerComponentState): boolean;
|
24
|
+
getHexString(props?: Readonly<IColorPickerLineProps> & Readonly<{
|
25
25
|
children?: React.ReactNode;
|
26
26
|
}>): string;
|
27
27
|
componentDidUpdate(): void;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
2
2
|
import * as React from "react";
|
3
3
|
import { ColorPicker } from "../colorPicker/colorPicker.js";
|
4
|
-
export class
|
4
|
+
export class ColorPickerLine extends React.Component {
|
5
5
|
constructor(props) {
|
6
6
|
super(props);
|
7
7
|
this.state = { pickerEnabled: false, color: this.props.value, hex: this.getHexString(props) };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"colorPickerComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/colorPickerComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAmBzD,MAAM,OAAO,
|
1
|
+
{"version":3,"file":"colorPickerComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/colorPickerComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAmBzD,MAAM,OAAO,eAAgB,SAAQ,KAAK,CAAC,SAA4D;IAInG,YAAY,KAA4B;QACpC,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,IAAI,CAAC,KAAK,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QAE9F,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,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AE,KAAK,EAAE,CAAC,CAAC;wBAC5C,CAAC,YAED,cAAK,SAAS,EAAC,oBAAoB,EAAC,GAAG,EAAE,IAAI,CAAC,SAAS,YACnD,KAAC,WAAW,IACR,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,IAAK,EAAU,EAChD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,cAAc,EAAE,CAAC,KAAsB,EAAE,EAAE;oCACvC,MAAM,GAAG,GAAW,KAAK,CAAC,WAAW,EAAE,CAAC;oCACxC,IAAI,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;oCAC9B,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;gCACnC,CAAC,GACH,GACA,GACJ,GACP,CACN,IACC,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Color4, Color3 } from \"core/Maths/math.color\";\r\nimport { ColorPicker } from \"../colorPicker/colorPicker\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\n\r\nexport interface IColorPickerLineProps {\r\n value: Color4 | Color3;\r\n linearHint?: boolean;\r\n onColorChanged: (newOne: string) => void;\r\n icon?: string;\r\n iconLabel?: string;\r\n shouldPopRight?: boolean;\r\n lockObject?: LockObject;\r\n}\r\n\r\ninterface IColorPickerComponentState {\r\n pickerEnabled: boolean;\r\n color: Color3 | Color4;\r\n hex: string;\r\n}\r\n\r\nexport class ColorPickerLine extends React.Component<IColorPickerLineProps, IColorPickerComponentState> {\r\n private _floatRef: React.RefObject<HTMLDivElement>;\r\n private _floatHostRef: React.RefObject<HTMLDivElement>;\r\n\r\n constructor(props: IColorPickerLineProps) {\r\n super(props);\r\n\r\n this.state = { pickerEnabled: false, color: this.props.value, hex: this.getHexString(props) };\r\n\r\n this._floatRef = React.createRef();\r\n this._floatHostRef = React.createRef();\r\n }\r\n\r\n syncPositions() {\r\n const div = this._floatRef.current as HTMLDivElement;\r\n const host = this._floatHostRef.current as HTMLDivElement;\r\n\r\n if (!div || !host) {\r\n return;\r\n }\r\n\r\n let top = host.getBoundingClientRect().top;\r\n const height = div.getBoundingClientRect().height;\r\n\r\n if (top + height + 10 > window.innerHeight) {\r\n top = window.innerHeight - height - 10;\r\n }\r\n\r\n div.style.top = top + \"px\";\r\n if (!this.props.shouldPopRight) {\r\n div.style.left = host.getBoundingClientRect().left - div.getBoundingClientRect().width + \"px\";\r\n } else {\r\n div.style.left = host.getBoundingClientRect().left + \"px\";\r\n }\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IColorPickerLineProps, nextState: IColorPickerComponentState) {\r\n const diffProps = this.getHexString(nextProps) !== this.getHexString();\r\n\r\n if (diffProps) {\r\n nextState.color = nextProps.value;\r\n nextState.hex = this.getHexString(nextProps);\r\n }\r\n\r\n return diffProps || nextState.hex !== this.state.hex || nextState.pickerEnabled !== this.state.pickerEnabled;\r\n }\r\n\r\n getHexString(props = this.props) {\r\n return props.value.toHexString();\r\n }\r\n\r\n override componentDidUpdate() {\r\n this.syncPositions();\r\n }\r\n\r\n override componentDidMount() {\r\n this.syncPositions();\r\n }\r\n\r\n override render() {\r\n return (\r\n <div className=\"color-picker\">\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <div className=\"color-rect-background\" ref={this._floatHostRef} onClick={() => this.setState({ pickerEnabled: true })}>\r\n <div className=\"color-rect\" style={{ background: this.state.hex }}></div>\r\n </div>\r\n {this.state.pickerEnabled && (\r\n <>\r\n <div\r\n className=\"color-picker-cover\"\r\n onClick={(evt) => {\r\n if (evt.target !== this._floatRef.current?.ownerDocument?.querySelector(\".color-picker-cover\")) {\r\n return;\r\n }\r\n this.setState({ pickerEnabled: false });\r\n }}\r\n >\r\n <div className=\"color-picker-float\" ref={this._floatRef}>\r\n <ColorPicker\r\n lockObject={this.props.lockObject || ({} as any)}\r\n color={this.state.color}\r\n linearhint={this.props.linearHint}\r\n onColorChanged={(color: Color3 | Color4) => {\r\n const hex: string = color.toHexString();\r\n this.setState({ hex, color });\r\n this.props.onColorChanged(hex);\r\n }}\r\n />\r\n </div>\r\n </div>\r\n </>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
@@ -1,16 +1,16 @@
|
|
1
1
|
import * as React from "react";
|
2
|
-
interface
|
2
|
+
interface IFileButtonLineProps {
|
3
3
|
label: string;
|
4
4
|
onClick: (file: File) => void;
|
5
5
|
accept: string;
|
6
6
|
icon?: string;
|
7
7
|
iconLabel?: string;
|
8
8
|
}
|
9
|
-
export declare class
|
9
|
+
export declare class FileButtonLine extends React.Component<IFileButtonLineProps> {
|
10
10
|
private static _IDGenerator;
|
11
11
|
private _id;
|
12
12
|
private _uploadInputRef;
|
13
|
-
constructor(props:
|
13
|
+
constructor(props: IFileButtonLineProps);
|
14
14
|
onChange(evt: any): void;
|
15
15
|
render(): import("react/jsx-runtime").JSX.Element;
|
16
16
|
}
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
2
|
import * as React from "react";
|
3
|
-
export class
|
3
|
+
export class FileButtonLine extends React.Component {
|
4
4
|
constructor(props) {
|
5
5
|
super(props);
|
6
|
-
this._id =
|
6
|
+
this._id = FileButtonLine._IDGenerator++;
|
7
7
|
this._uploadInputRef = React.createRef();
|
8
8
|
}
|
9
9
|
onChange(evt) {
|
@@ -17,5 +17,5 @@ export class FileButtonLineComponent extends React.Component {
|
|
17
17
|
return (_jsxs("div", { className: "buttonLine", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), _jsx("label", { htmlFor: "file-upload" + this._id, className: "file-upload", children: this.props.label }), _jsx("input", { ref: this._uploadInputRef, id: "file-upload" + this._id, type: "file", accept: this.props.accept, onChange: (evt) => this.onChange(evt) })] }));
|
18
18
|
}
|
19
19
|
}
|
20
|
-
|
20
|
+
FileButtonLine._IDGenerator = 0;
|
21
21
|
//# sourceMappingURL=fileButtonLineComponent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fileButtonLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/fileButtonLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,MAAM,OAAO,
|
1
|
+
{"version":3,"file":"fileButtonLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/fileButtonLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,MAAM,OAAO,cAAe,SAAQ,KAAK,CAAC,SAA+B;IAKrE,YAAY,KAA2B;QACnC,KAAK,CAAC,KAAK,CAAC,CAAC;QAJT,QAAG,GAAG,cAAc,CAAC,YAAY,EAAE,CAAC;QAKxC,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IAC7C,CAAC;IAED,QAAQ,CAAC,GAAQ;QACb,MAAM,KAAK,GAAW,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;QACvC,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE;YACvB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SAChC;QAED,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC;IAC1B,CAAC;IAEQ,MAAM;QACX,OAAO,CACH,eAAK,SAAS,EAAC,YAAY,aACtB,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,cAAK,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,SAAS,EAAC,MAAM,GAAG,EAC1H,gBAAO,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC,GAAG,EAAE,SAAS,EAAC,aAAa,YAC5D,IAAI,CAAC,KAAK,CAAC,KAAK,GACb,EACR,gBAAO,GAAG,EAAE,IAAI,CAAC,eAAe,EAAE,EAAE,EAAE,aAAa,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,EAAC,MAAM,EAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAI,IAC9I,CACT,CAAC;IACN,CAAC;;AA5Bc,2BAAY,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["import * as React from \"react\";\r\n\r\ninterface IFileButtonLineProps {\r\n label: string;\r\n onClick: (file: File) => void;\r\n accept: string;\r\n icon?: string;\r\n iconLabel?: string;\r\n}\r\n\r\nexport class FileButtonLine extends React.Component<IFileButtonLineProps> {\r\n private static _IDGenerator = 0;\r\n private _id = FileButtonLine._IDGenerator++;\r\n private _uploadInputRef: React.RefObject<HTMLInputElement>;\r\n\r\n constructor(props: IFileButtonLineProps) {\r\n super(props);\r\n this._uploadInputRef = React.createRef();\r\n }\r\n\r\n onChange(evt: any) {\r\n const files: File[] = evt.target.files;\r\n if (files && files.length) {\r\n this.props.onClick(files[0]);\r\n }\r\n\r\n evt.target.value = \"\";\r\n }\r\n\r\n override render() {\r\n return (\r\n <div className=\"buttonLine\">\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <label htmlFor={\"file-upload\" + this._id} className=\"file-upload\">\r\n {this.props.label}\r\n </label>\r\n <input ref={this._uploadInputRef} id={\"file-upload\" + this._id} type=\"file\" accept={this.props.accept} onChange={(evt) => this.onChange(evt)} />\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
3
3
|
import { Matrix, Quaternion } from "@babylonjs/core/Maths/math.vector.js";
|
4
4
|
import { Vector4LineComponent } from "./vector4LineComponent.js";
|
5
|
-
import {
|
5
|
+
import { OptionsLine } from "./optionsLineComponent.js";
|
6
6
|
import { SliderLineComponent } from "./sliderLineComponent.js";
|
7
7
|
export class MatrixLineComponent extends React.Component {
|
8
8
|
constructor(props) {
|
@@ -87,7 +87,7 @@ export class MatrixLineComponent extends React.Component {
|
|
87
87
|
{ label: "Rotation over Y axis", value: 2 },
|
88
88
|
{ label: "Rotation over Z axis", value: 3 },
|
89
89
|
];
|
90
|
-
return (_jsxs("div", { className: "vector3Line", children: [_jsx("div", { className: "firstLine", children: _jsx("div", { className: "label", title: this.props.label, children: this.props.label }) }), _jsx("div", { className: "secondLine", children: _jsx(
|
90
|
+
return (_jsxs("div", { className: "vector3Line", children: [_jsx("div", { className: "firstLine", children: _jsx("div", { className: "label", title: this.props.label, children: this.props.label }) }), _jsx("div", { className: "secondLine", children: _jsx(OptionsLine, { label: "Mode", className: "no-right-margin", options: modeOptions, target: this, noDirectUpdate: true, propertyName: "", extractValue: () => {
|
91
91
|
return this.state.mode;
|
92
92
|
}, onSelect: (value) => {
|
93
93
|
this.props.target[this.props.propertyName] = Matrix.Identity();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"matrixLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/matrixLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,6CAA+B;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AA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CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Vector3, Vector4 } from \"core/Maths/math.vector\";\r\nimport { Matrix, Quaternion } from \"core/Maths/math.vector\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport { Vector4LineComponent } from \"./vector4LineComponent\";\r\nimport type { PropertyChangedEvent } from \"../propertyChangedEvent\";\r\nimport { OptionsLineComponent } from \"./optionsLineComponent\";\r\nimport { SliderLineComponent } from \"./sliderLineComponent\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\n\r\ninterface IMatrixLineComponentProps {\r\n label: string;\r\n target: any;\r\n propertyName: string;\r\n step?: number;\r\n onChange?: (newValue: Matrix) => void;\r\n onModeChange?: (mode: number) => void;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n mode?: number;\r\n lockObject: LockObject;\r\n}\r\n\r\nexport class MatrixLineComponent extends React.Component<IMatrixLineComponentProps, { value: Matrix; mode: number; angle: number }> {\r\n private _localChange = false;\r\n\r\n constructor(props: IMatrixLineComponentProps) {\r\n super(props);\r\n\r\n const matrix: Matrix = this.props.target[this.props.propertyName].clone();\r\n\r\n let angle = 0;\r\n\r\n if (this.props.mode) {\r\n const quat = new Quaternion();\r\n matrix.decompose(undefined, quat);\r\n\r\n const euler = quat.toEulerAngles();\r\n\r\n switch (this.props.mode) {\r\n case 1:\r\n angle = euler.x;\r\n break;\r\n case 2:\r\n angle = euler.y;\r\n break;\r\n case 3:\r\n angle = euler.z;\r\n break;\r\n }\r\n }\r\n\r\n this.state = { value: matrix, mode: this.props.mode || 0, angle: angle };\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IMatrixLineComponentProps, nextState: { value: Matrix; mode: number; angle: number }) {\r\n const nextPropsValue = nextProps.target[nextProps.propertyName];\r\n\r\n if (!nextPropsValue.equals(nextState.value) || this._localChange) {\r\n nextState.value = nextPropsValue.clone();\r\n this._localChange = false;\r\n return true;\r\n }\r\n return nextState.mode !== this.state.mode || nextState.angle !== this.state.angle;\r\n }\r\n\r\n raiseOnPropertyChanged(previousValue: Vector3) {\r\n if (this.props.onChange) {\r\n this.props.onChange(this.state.value);\r\n }\r\n\r\n if (!this.props.onPropertyChangedObservable) {\r\n return;\r\n }\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: this.props.target,\r\n property: this.props.propertyName,\r\n value: this.state.value,\r\n initialValue: previousValue,\r\n });\r\n }\r\n\r\n updateMatrix() {\r\n const store = this.props.target[this.props.propertyName].clone();\r\n this.props.target[this.props.propertyName] = this.state.value;\r\n\r\n this.setState({ value: store });\r\n\r\n this.raiseOnPropertyChanged(store);\r\n }\r\n\r\n updateRow(value: Vector4, row: number) {\r\n this._localChange = true;\r\n\r\n this.state.value.setRow(row, value);\r\n this.updateMatrix();\r\n }\r\n\r\n updateBasedOnMode(value: number) {\r\n switch (this.state.mode) {\r\n case 1: {\r\n Matrix.RotationXToRef(this.state.angle, this.state.value);\r\n break;\r\n }\r\n case 2: {\r\n Matrix.RotationYToRef(this.state.angle, this.state.value);\r\n break;\r\n }\r\n case 3: {\r\n Matrix.RotationZToRef(this.state.angle, this.state.value);\r\n break;\r\n }\r\n }\r\n this.updateMatrix();\r\n\r\n this.setState({ angle: value });\r\n }\r\n\r\n override render() {\r\n const modeOptions = [\r\n { label: \"User-defined\", value: 0 },\r\n { label: \"Rotation over X axis\", value: 1 },\r\n { label: \"Rotation over Y axis\", value: 2 },\r\n { label: \"Rotation over Z axis\", value: 3 },\r\n ];\r\n\r\n return (\r\n <div className=\"vector3Line\">\r\n <div className=\"firstLine\">\r\n <div className=\"label\" title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n </div>\r\n <div className=\"secondLine\">\r\n <OptionsLineComponent\r\n label=\"Mode\"\r\n className=\"no-right-margin\"\r\n options={modeOptions}\r\n target={this}\r\n noDirectUpdate={true}\r\n propertyName={\"\"}\r\n extractValue={() => {\r\n return this.state.mode;\r\n }}\r\n onSelect={(value: any) => {\r\n this.props.target[this.props.propertyName] = Matrix.Identity();\r\n Matrix.IdentityToRef(this.state.value);\r\n this.setState({ mode: value, angle: 0 });\r\n\r\n this.updateMatrix();\r\n\r\n if (this.props.onModeChange) {\r\n this.props.onModeChange(value);\r\n }\r\n }}\r\n />\r\n </div>\r\n {this.state.mode === 0 && (\r\n <div className=\"secondLine\">\r\n <Vector4LineComponent\r\n lockObject={this.props.lockObject}\r\n label=\"Row #0\"\r\n value={this.state.value.getRow(0)!}\r\n onChange={(value) => this.updateRow(value, 0)}\r\n />\r\n <Vector4LineComponent\r\n lockObject={this.props.lockObject}\r\n label=\"Row #1\"\r\n value={this.state.value.getRow(1)!}\r\n onChange={(value) => this.updateRow(value, 1)}\r\n />\r\n <Vector4LineComponent\r\n lockObject={this.props.lockObject}\r\n label=\"Row #2\"\r\n value={this.state.value.getRow(2)!}\r\n onChange={(value) => this.updateRow(value, 2)}\r\n />\r\n <Vector4LineComponent\r\n lockObject={this.props.lockObject}\r\n label=\"Row #3\"\r\n value={this.state.value.getRow(3)!}\r\n onChange={(value) => this.updateRow(value, 3)}\r\n />\r\n </div>\r\n )}\r\n {this.state.mode !== 0 && (\r\n <div className=\"secondLine\">\r\n <SliderLineComponent\r\n label=\"Angle\"\r\n lockObject={this.props.lockObject}\r\n minimum={0}\r\n maximum={2 * Math.PI}\r\n useEuler={true}\r\n step={0.1}\r\n directValue={this.state.angle}\r\n onChange={(value) => this.updateBasedOnMode(value)}\r\n />\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
1
|
+
{"version":3,"file":"matrixLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/matrixLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,6CAA+B;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,W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KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,GACpD,GACA,CACT,IACC,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Vector3, Vector4 } from \"core/Maths/math.vector\";\r\nimport { Matrix, Quaternion } from \"core/Maths/math.vector\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport { Vector4LineComponent } from \"./vector4LineComponent\";\r\nimport type { PropertyChangedEvent } from \"../propertyChangedEvent\";\r\nimport { OptionsLine } from \"./optionsLineComponent\";\r\nimport { SliderLineComponent } from \"./sliderLineComponent\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\n\r\ninterface IMatrixLineComponentProps {\r\n label: string;\r\n target: any;\r\n propertyName: string;\r\n step?: number;\r\n onChange?: (newValue: Matrix) => void;\r\n onModeChange?: (mode: number) => void;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n mode?: number;\r\n lockObject: LockObject;\r\n}\r\n\r\nexport class MatrixLineComponent extends React.Component<IMatrixLineComponentProps, { value: Matrix; mode: number; angle: number }> {\r\n private _localChange = false;\r\n\r\n constructor(props: IMatrixLineComponentProps) {\r\n super(props);\r\n\r\n const matrix: Matrix = this.props.target[this.props.propertyName].clone();\r\n\r\n let angle = 0;\r\n\r\n if (this.props.mode) {\r\n const quat = new Quaternion();\r\n matrix.decompose(undefined, quat);\r\n\r\n const euler = quat.toEulerAngles();\r\n\r\n switch (this.props.mode) {\r\n case 1:\r\n angle = euler.x;\r\n break;\r\n case 2:\r\n angle = euler.y;\r\n break;\r\n case 3:\r\n angle = euler.z;\r\n break;\r\n }\r\n }\r\n\r\n this.state = { value: matrix, mode: this.props.mode || 0, angle: angle };\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IMatrixLineComponentProps, nextState: { value: Matrix; mode: number; angle: number }) {\r\n const nextPropsValue = nextProps.target[nextProps.propertyName];\r\n\r\n if (!nextPropsValue.equals(nextState.value) || this._localChange) {\r\n nextState.value = nextPropsValue.clone();\r\n this._localChange = false;\r\n return true;\r\n }\r\n return nextState.mode !== this.state.mode || nextState.angle !== this.state.angle;\r\n }\r\n\r\n raiseOnPropertyChanged(previousValue: Vector3) {\r\n if (this.props.onChange) {\r\n this.props.onChange(this.state.value);\r\n }\r\n\r\n if (!this.props.onPropertyChangedObservable) {\r\n return;\r\n }\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: this.props.target,\r\n property: this.props.propertyName,\r\n value: this.state.value,\r\n initialValue: previousValue,\r\n });\r\n }\r\n\r\n updateMatrix() {\r\n const store = this.props.target[this.props.propertyName].clone();\r\n this.props.target[this.props.propertyName] = this.state.value;\r\n\r\n this.setState({ value: store });\r\n\r\n this.raiseOnPropertyChanged(store);\r\n }\r\n\r\n updateRow(value: Vector4, row: number) {\r\n this._localChange = true;\r\n\r\n this.state.value.setRow(row, value);\r\n this.updateMatrix();\r\n }\r\n\r\n updateBasedOnMode(value: number) {\r\n switch (this.state.mode) {\r\n case 1: {\r\n Matrix.RotationXToRef(this.state.angle, this.state.value);\r\n break;\r\n }\r\n case 2: {\r\n Matrix.RotationYToRef(this.state.angle, this.state.value);\r\n break;\r\n }\r\n case 3: {\r\n Matrix.RotationZToRef(this.state.angle, this.state.value);\r\n break;\r\n }\r\n }\r\n this.updateMatrix();\r\n\r\n this.setState({ angle: value });\r\n }\r\n\r\n override render() {\r\n const modeOptions = [\r\n { label: \"User-defined\", value: 0 },\r\n { label: \"Rotation over X axis\", value: 1 },\r\n { label: \"Rotation over Y axis\", value: 2 },\r\n { label: \"Rotation over Z axis\", value: 3 },\r\n ];\r\n\r\n return (\r\n <div className=\"vector3Line\">\r\n <div className=\"firstLine\">\r\n <div className=\"label\" title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n </div>\r\n <div className=\"secondLine\">\r\n <OptionsLine\r\n label=\"Mode\"\r\n className=\"no-right-margin\"\r\n options={modeOptions}\r\n target={this}\r\n noDirectUpdate={true}\r\n propertyName={\"\"}\r\n extractValue={() => {\r\n return this.state.mode;\r\n }}\r\n onSelect={(value: any) => {\r\n this.props.target[this.props.propertyName] = Matrix.Identity();\r\n Matrix.IdentityToRef(this.state.value);\r\n this.setState({ mode: value, angle: 0 });\r\n\r\n this.updateMatrix();\r\n\r\n if (this.props.onModeChange) {\r\n this.props.onModeChange(value);\r\n }\r\n }}\r\n />\r\n </div>\r\n {this.state.mode === 0 && (\r\n <div className=\"secondLine\">\r\n <Vector4LineComponent\r\n lockObject={this.props.lockObject}\r\n label=\"Row #0\"\r\n value={this.state.value.getRow(0)!}\r\n onChange={(value) => this.updateRow(value, 0)}\r\n />\r\n <Vector4LineComponent\r\n lockObject={this.props.lockObject}\r\n label=\"Row #1\"\r\n value={this.state.value.getRow(1)!}\r\n onChange={(value) => this.updateRow(value, 1)}\r\n />\r\n <Vector4LineComponent\r\n lockObject={this.props.lockObject}\r\n label=\"Row #2\"\r\n value={this.state.value.getRow(2)!}\r\n onChange={(value) => this.updateRow(value, 2)}\r\n />\r\n <Vector4LineComponent\r\n lockObject={this.props.lockObject}\r\n label=\"Row #3\"\r\n value={this.state.value.getRow(3)!}\r\n onChange={(value) => this.updateRow(value, 3)}\r\n />\r\n </div>\r\n )}\r\n {this.state.mode !== 0 && (\r\n <div className=\"secondLine\">\r\n <SliderLineComponent\r\n label=\"Angle\"\r\n lockObject={this.props.lockObject}\r\n minimum={0}\r\n maximum={2 * Math.PI}\r\n useEuler={true}\r\n step={0.1}\r\n directValue={this.state.angle}\r\n onChange={(value) => this.updateBasedOnMode(value)}\r\n />\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import * as React from "react";
|
2
2
|
import type { LockObject } from "../tabs/propertyGrids/lockObject";
|
3
|
-
interface
|
3
|
+
interface INumericInputProps {
|
4
4
|
label: string;
|
5
5
|
value: number;
|
6
6
|
step?: number;
|
@@ -10,16 +10,16 @@ interface INumericInputComponentProps {
|
|
10
10
|
iconLabel?: string;
|
11
11
|
lockObject: LockObject;
|
12
12
|
}
|
13
|
-
export declare class
|
13
|
+
export declare class NumericInput extends React.Component<INumericInputProps, {
|
14
14
|
value: string;
|
15
15
|
}> {
|
16
16
|
static defaultProps: {
|
17
17
|
step: number;
|
18
18
|
};
|
19
19
|
private _localChange;
|
20
|
-
constructor(props:
|
20
|
+
constructor(props: INumericInputProps);
|
21
21
|
componentWillUnmount(): void;
|
22
|
-
shouldComponentUpdate(nextProps:
|
22
|
+
shouldComponentUpdate(nextProps: INumericInputProps, nextState: {
|
23
23
|
value: string;
|
24
24
|
}): boolean;
|
25
25
|
updateValue(valueString: string): void;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
2
|
import * as React from "react";
|
3
|
-
export class
|
3
|
+
export class NumericInput extends React.Component {
|
4
4
|
constructor(props) {
|
5
5
|
super(props);
|
6
6
|
this._localChange = false;
|
@@ -81,7 +81,7 @@ export class NumericInputComponent extends React.Component {
|
|
81
81
|
}
|
82
82
|
}
|
83
83
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
84
|
-
|
84
|
+
NumericInput.defaultProps = {
|
85
85
|
step: 1,
|
86
86
|
};
|
87
87
|
//# sourceMappingURL=numericInputComponent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"numericInputComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/numericInputComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAc/B,MAAM,OAAO,
|
1
|
+
{"version":3,"file":"numericInputComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/numericInputComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAc/B,MAAM,OAAO,YAAa,SAAQ,KAAK,CAAC,SAAgD;IAOpF,YAAY,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AAC,UAAU,EAAE;4BACvB,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC;yBACrC;oBACL,CAAC,EACD,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,GAC7B,IACA,CACT,CAAC;IACN,CAAC;;AAtHD,gEAAgE;AACzD,yBAAY,GAAG;IAClB,IAAI,EAAE,CAAC;CACV,AAFkB,CAEjB","sourcesContent":["import * as React from \"react\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\n\r\ninterface INumericInputProps {\r\n label: string;\r\n value: number;\r\n step?: number;\r\n onChange: (value: number) => void;\r\n precision?: number;\r\n icon?: string;\r\n iconLabel?: string;\r\n lockObject: LockObject;\r\n}\r\n\r\nexport class NumericInput extends React.Component<INumericInputProps, { value: string }> {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n static defaultProps = {\r\n step: 1,\r\n };\r\n\r\n private _localChange = false;\r\n constructor(props: INumericInputProps) {\r\n super(props);\r\n\r\n this.state = { value: this.props.value.toFixed(this.props.precision !== undefined ? this.props.precision : 3) };\r\n }\r\n\r\n override componentWillUnmount() {\r\n if (this.props.lockObject) {\r\n this.props.lockObject.lock = false;\r\n }\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: INumericInputProps, nextState: { value: string }) {\r\n if (this._localChange) {\r\n this._localChange = false;\r\n return true;\r\n }\r\n\r\n if (nextProps.value.toString() !== nextState.value) {\r\n nextState.value = nextProps.value.toFixed(this.props.precision !== undefined ? this.props.precision : 3);\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n updateValue(valueString: string) {\r\n if (/[^0-9.-]/g.test(valueString)) {\r\n return;\r\n }\r\n\r\n const valueAsNumber = parseFloat(valueString);\r\n\r\n this._localChange = true;\r\n this.setState({ value: valueString });\r\n\r\n if (isNaN(valueAsNumber)) {\r\n return;\r\n }\r\n\r\n this.props.onChange(valueAsNumber);\r\n }\r\n\r\n onBlur() {\r\n this._localChange = false;\r\n const valueAsNumber = parseFloat(this.state.value);\r\n\r\n if (this.props.lockObject) {\r\n this.props.lockObject.lock = false;\r\n }\r\n\r\n if (isNaN(valueAsNumber)) {\r\n this.props.onChange(this.props.value);\r\n return;\r\n }\r\n\r\n this.props.onChange(valueAsNumber);\r\n }\r\n\r\n incrementValue(amount: number) {\r\n let currentValue = parseFloat(this.state.value);\r\n if (isNaN(currentValue)) {\r\n currentValue = 0;\r\n }\r\n this.updateValue((currentValue + amount).toFixed(this.props.precision !== undefined ? this.props.precision : 3));\r\n }\r\n\r\n onKeyDown(evt: React.KeyboardEvent<HTMLInputElement>) {\r\n const step = this.props.step || 1;\r\n const handleArrowKey = (sign: number) => {\r\n if (evt.shiftKey) {\r\n sign *= 10;\r\n if (evt.ctrlKey || evt.metaKey) {\r\n sign *= 10;\r\n }\r\n }\r\n\r\n this.incrementValue(sign * step);\r\n evt.preventDefault();\r\n };\r\n\r\n if (evt.key === \"ArrowUp\") {\r\n handleArrowKey(1);\r\n } else if (evt.key === \"ArrowDown\") {\r\n handleArrowKey(-1);\r\n }\r\n }\r\n\r\n override render() {\r\n return (\r\n <div className=\"numeric\">\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n {this.props.label && (\r\n <div className=\"numeric-label\" title={this.props.label}>\r\n {`${this.props.label}: `}\r\n </div>\r\n )}\r\n <input\r\n type=\"number\"\r\n step={this.props.step}\r\n className=\"numeric-input\"\r\n value={this.state.value}\r\n onChange={(evt) => this.updateValue(evt.target.value)}\r\n onKeyDown={(evt) => this.onKeyDown(evt)}\r\n onFocus={() => {\r\n if (this.props.lockObject) {\r\n this.props.lockObject.lock = true;\r\n }\r\n }}\r\n onBlur={() => this.onBlur()}\r\n />\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
@@ -3,7 +3,7 @@ import type { Observable } from "@babylonjs/core/Misc/observable.js";
|
|
3
3
|
import type { PropertyChangedEvent } from "../propertyChangedEvent";
|
4
4
|
import type { IInspectableOptions } from "@babylonjs/core/Misc/iInspectable.js";
|
5
5
|
export declare const Null_Value: number;
|
6
|
-
export interface
|
6
|
+
export interface IOptionsLineProps {
|
7
7
|
label: string;
|
8
8
|
target: any;
|
9
9
|
propertyName: string;
|
@@ -19,15 +19,15 @@ export interface IOptionsLineComponentProps {
|
|
19
19
|
valuesAreStrings?: boolean;
|
20
20
|
defaultIfNull?: number;
|
21
21
|
}
|
22
|
-
export declare class
|
22
|
+
export declare class OptionsLine extends React.Component<IOptionsLineProps, {
|
23
23
|
value: number | string;
|
24
24
|
}> {
|
25
25
|
private _localChange;
|
26
26
|
private _remapValueIn;
|
27
27
|
private _remapValueOut;
|
28
28
|
private _getValue;
|
29
|
-
constructor(props:
|
30
|
-
shouldComponentUpdate(nextProps:
|
29
|
+
constructor(props: IOptionsLineProps);
|
30
|
+
shouldComponentUpdate(nextProps: IOptionsLineProps, nextState: {
|
31
31
|
value: number;
|
32
32
|
}): boolean;
|
33
33
|
raiseOnPropertyChanged(newValue: number, previousValue: number): void;
|
@@ -4,7 +4,7 @@ import { copyCommandToClipboard, getClassNameWithNamespace } from "../copyComman
|
|
4
4
|
import copyIcon from "./copy.svg";
|
5
5
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
6
6
|
export const Null_Value = Number.MAX_SAFE_INTEGER;
|
7
|
-
export class
|
7
|
+
export class OptionsLine extends React.Component {
|
8
8
|
_remapValueIn(value) {
|
9
9
|
return this.props.allowNullValue && value === null ? Null_Value : value;
|
10
10
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"optionsLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/optionsLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAE9F,OAAO,QAAQ,MAAM,YAAY,CAA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,CAAC,CAE/C,CACZ,CAAC;wBACN,CAAC,CAAC,GACG,GACP,EACN,cAAK,SAAS,EAAC,gBAAgB,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,KAAK,EAAC,mBAAmB,YACxF,cAAK,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAC,MAAM,GAAG,GAC/B,IACJ,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport type { PropertyChangedEvent } from \"../propertyChangedEvent\";\r\nimport { copyCommandToClipboard, getClassNameWithNamespace } from \"../copyCommandToClipboard\";\r\nimport type { IInspectableOptions } from \"core/Misc/iInspectable\";\r\nimport copyIcon from \"./copy.svg\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const Null_Value = Number.MAX_SAFE_INTEGER;\r\n\r\nexport interface IOptionsLineComponentProps {\r\n label: string;\r\n target: any;\r\n propertyName: string;\r\n options: IInspectableOptions[];\r\n noDirectUpdate?: boolean;\r\n onSelect?: (value: number | string) => void;\r\n extractValue?: (target: any) => number | string;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n allowNullValue?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n className?: string;\r\n valuesAreStrings?: boolean;\r\n defaultIfNull?: number;\r\n}\r\n\r\nexport class OptionsLineComponent extends React.Component<IOptionsLineComponentProps, { value: number | string }> {\r\n private _localChange = false;\r\n\r\n private _remapValueIn(value: number | null): number {\r\n return this.props.allowNullValue && value === null ? Null_Value : value!;\r\n }\r\n\r\n private _remapValueOut(value: number): number | null {\r\n return this.props.allowNullValue && value === Null_Value ? null : value;\r\n }\r\n\r\n private _getValue(props: IOptionsLineComponentProps) {\r\n if (props.extractValue) {\r\n return props.extractValue(props.target);\r\n }\r\n return props.target && props.propertyName ? props.target[props.propertyName] : props.options[props.defaultIfNull || 0];\r\n }\r\n\r\n constructor(props: IOptionsLineComponentProps) {\r\n super(props);\r\n\r\n this.state = { value: this._remapValueIn(this._getValue(props)) };\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IOptionsLineComponentProps, nextState: { value: number }) {\r\n if (this._localChange) {\r\n this._localChange = false;\r\n return true;\r\n }\r\n\r\n const newValue = this._remapValueIn(nextProps.extractValue ? nextProps.extractValue(this.props.target) : nextProps.target[nextProps.propertyName]);\r\n if (newValue != null && newValue !== nextState.value) {\r\n nextState.value = newValue;\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n raiseOnPropertyChanged(newValue: number, previousValue: number) {\r\n if (!this.props.onPropertyChangedObservable) {\r\n return;\r\n }\r\n\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: this.props.target,\r\n property: this.props.propertyName,\r\n value: newValue,\r\n initialValue: previousValue,\r\n allowNullValue: this.props.allowNullValue,\r\n });\r\n }\r\n\r\n setValue(value: string | number) {\r\n this.setState({ value: value });\r\n }\r\n\r\n updateValue(valueString: string) {\r\n const value = this.props.valuesAreStrings ? valueString : parseInt(valueString);\r\n this._localChange = true;\r\n\r\n const store = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];\r\n\r\n if (!this.props.noDirectUpdate) {\r\n this.props.target[this.props.propertyName] = this._remapValueOut(value as number);\r\n }\r\n this.setState({ value: value });\r\n\r\n if (this.props.onSelect) {\r\n this.props.onSelect(value);\r\n }\r\n\r\n const newValue = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];\r\n\r\n this.raiseOnPropertyChanged(newValue, store);\r\n }\r\n\r\n // Copy to clipboard the code this option actually does\r\n // Example : material.sideOrientation = 1;\r\n onCopyClick() {\r\n if (this.props && this.props.target) {\r\n const { className, babylonNamespace } = getClassNameWithNamespace(this.props.target);\r\n const targetName = \"globalThis.debugNode\";\r\n const targetProperty = this.props.propertyName;\r\n const value = this.props.target[this.props.propertyName!];\r\n const strCommand = targetName + \".\" + targetProperty + \" = \" + value + \";// (debugNode as \" + babylonNamespace + className + \")\";\r\n copyCommandToClipboard(strCommand);\r\n } else {\r\n copyCommandToClipboard(\"undefined\");\r\n }\r\n }\r\n\r\n override render() {\r\n return (\r\n <div className={\"listLine\" + (this.props.className ? \" \" + this.props.className : \"\")}>\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} color=\"black\" className=\"icon\" />}\r\n <div className=\"label\" title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n <div className=\"options\">\r\n <select onChange={(evt) => this.updateValue(evt.target.value)} value={this.state.value ?? \"\"}>\r\n {this.props.options.map((option, i) => {\r\n return (\r\n <option selected={option.selected} key={option.label + i} value={option.value} title={option.label}>\r\n {option.label}\r\n </option>\r\n );\r\n })}\r\n </select>\r\n </div>\r\n <div className=\"copy hoverIcon\" onClick={() => this.onCopyClick()} title=\"Copy to clipboard\">\r\n <img src={copyIcon} alt=\"Copy\" />\r\n </div>\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
1
|
+
{"version":3,"file":"optionsLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/optionsLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAE9F,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC,gEAAgE;AAChE,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAmBlD,MAAM,OAAO,WAAY,SAAQ,KAAK,CAAC,SAAwD;IAGnF,aAAa,CAAC,KAAoB;QACtC,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAM,CAAC;IAC7E,CAAC;IAEO,cAAc,CAAC,KAAa;QAChC,OAAO,IAAI,CAAC,KAAK,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,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,aAChF,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,cAAK,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,EAAC,OAAO,EAAC,SAAS,EAAC,MAAM,GAAG,EACxI,cAAK,SAAS,EAAC,OAAO,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,YACzC,IAAI,CAAC,KAAK,CAAC,KAAK,GACf,EACN,cAAK,SAAS,EAAC,SAAS,YACpB,iBAAQ,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,YACvF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;4BAClC,OAAO,CACH,iBAAQ,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAyB,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,YAC7F,MAAM,CAAC,KAAK,IADuB,MAAM,CAAC,KAAK,GAAG,CAAC,CAE/C,CACZ,CAAC;wBACN,CAAC,CAAC,GACG,GACP,EACN,cAAK,SAAS,EAAC,gBAAgB,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,KAAK,EAAC,mBAAmB,YACxF,cAAK,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAC,MAAM,GAAG,GAC/B,IACJ,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport type { PropertyChangedEvent } from \"../propertyChangedEvent\";\r\nimport { copyCommandToClipboard, getClassNameWithNamespace } from \"../copyCommandToClipboard\";\r\nimport type { IInspectableOptions } from \"core/Misc/iInspectable\";\r\nimport copyIcon from \"./copy.svg\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const Null_Value = Number.MAX_SAFE_INTEGER;\r\n\r\nexport interface IOptionsLineProps {\r\n label: string;\r\n target: any;\r\n propertyName: string;\r\n options: IInspectableOptions[];\r\n noDirectUpdate?: boolean;\r\n onSelect?: (value: number | string) => void;\r\n extractValue?: (target: any) => number | string;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n allowNullValue?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n className?: string;\r\n valuesAreStrings?: boolean;\r\n defaultIfNull?: number;\r\n}\r\n\r\nexport class OptionsLine extends React.Component<IOptionsLineProps, { value: number | string }> {\r\n private _localChange = false;\r\n\r\n private _remapValueIn(value: number | null): number {\r\n return this.props.allowNullValue && value === null ? Null_Value : value!;\r\n }\r\n\r\n private _remapValueOut(value: number): number | null {\r\n return this.props.allowNullValue && value === Null_Value ? null : value;\r\n }\r\n\r\n private _getValue(props: IOptionsLineProps) {\r\n if (props.extractValue) {\r\n return props.extractValue(props.target);\r\n }\r\n return props.target && props.propertyName ? props.target[props.propertyName] : props.options[props.defaultIfNull || 0];\r\n }\r\n\r\n constructor(props: IOptionsLineProps) {\r\n super(props);\r\n\r\n this.state = { value: this._remapValueIn(this._getValue(props)) };\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IOptionsLineProps, nextState: { value: number }) {\r\n if (this._localChange) {\r\n this._localChange = false;\r\n return true;\r\n }\r\n\r\n const newValue = this._remapValueIn(nextProps.extractValue ? nextProps.extractValue(this.props.target) : nextProps.target[nextProps.propertyName]);\r\n if (newValue != null && newValue !== nextState.value) {\r\n nextState.value = newValue;\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n raiseOnPropertyChanged(newValue: number, previousValue: number) {\r\n if (!this.props.onPropertyChangedObservable) {\r\n return;\r\n }\r\n\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: this.props.target,\r\n property: this.props.propertyName,\r\n value: newValue,\r\n initialValue: previousValue,\r\n allowNullValue: this.props.allowNullValue,\r\n });\r\n }\r\n\r\n setValue(value: string | number) {\r\n this.setState({ value: value });\r\n }\r\n\r\n updateValue(valueString: string) {\r\n const value = this.props.valuesAreStrings ? valueString : parseInt(valueString);\r\n this._localChange = true;\r\n\r\n const store = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];\r\n\r\n if (!this.props.noDirectUpdate) {\r\n this.props.target[this.props.propertyName] = this._remapValueOut(value as number);\r\n }\r\n this.setState({ value: value });\r\n\r\n if (this.props.onSelect) {\r\n this.props.onSelect(value);\r\n }\r\n\r\n const newValue = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];\r\n\r\n this.raiseOnPropertyChanged(newValue, store);\r\n }\r\n\r\n // Copy to clipboard the code this option actually does\r\n // Example : material.sideOrientation = 1;\r\n onCopyClick() {\r\n if (this.props && this.props.target) {\r\n const { className, babylonNamespace } = getClassNameWithNamespace(this.props.target);\r\n const targetName = \"globalThis.debugNode\";\r\n const targetProperty = this.props.propertyName;\r\n const value = this.props.target[this.props.propertyName!];\r\n const strCommand = targetName + \".\" + targetProperty + \" = \" + value + \";// (debugNode as \" + babylonNamespace + className + \")\";\r\n copyCommandToClipboard(strCommand);\r\n } else {\r\n copyCommandToClipboard(\"undefined\");\r\n }\r\n }\r\n\r\n override render() {\r\n return (\r\n <div className={\"listLine\" + (this.props.className ? \" \" + this.props.className : \"\")}>\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} color=\"black\" className=\"icon\" />}\r\n <div className=\"label\" title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n <div className=\"options\">\r\n <select onChange={(evt) => this.updateValue(evt.target.value)} value={this.state.value ?? \"\"}>\r\n {this.props.options.map((option, i) => {\r\n return (\r\n <option selected={option.selected} key={option.label + i} value={option.value} title={option.label}>\r\n {option.label}\r\n </option>\r\n );\r\n })}\r\n </select>\r\n </div>\r\n <div className=\"copy hoverIcon\" onClick={() => this.onCopyClick()} title=\"Copy to clipboard\">\r\n <img src={copyIcon} alt=\"Copy\" />\r\n </div>\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
2
|
import * as React from "react";
|
3
|
-
import {
|
3
|
+
import { NumericInput } from "./numericInputComponent.js";
|
4
4
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
5
5
|
import { faMinus, faPlus } from "@fortawesome/free-solid-svg-icons";
|
6
6
|
export class Vector2LineComponent extends React.Component {
|
@@ -54,7 +54,7 @@ export class Vector2LineComponent extends React.Component {
|
|
54
54
|
}
|
55
55
|
render() {
|
56
56
|
const chevron = this.state.isExpanded ? _jsx(FontAwesomeIcon, { icon: faMinus }) : _jsx(FontAwesomeIcon, { icon: faPlus });
|
57
|
-
return (_jsxs("div", { className: "vector3Line", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), _jsxs("div", { className: "firstLine", title: this.props.label, children: [_jsx("div", { className: "label", children: this.props.label }), _jsx("div", { className: "vector", children: `X: ${this.state.value.x.toFixed(2)}, Y: ${this.state.value.y.toFixed(2)}` }), _jsx("div", { className: "expand hoverIcon", onClick: () => this.switchExpandState(), title: "Expand", children: chevron })] }), this.state.isExpanded && (_jsxs("div", { className: "secondLine", children: [_jsx(
|
57
|
+
return (_jsxs("div", { className: "vector3Line", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), _jsxs("div", { className: "firstLine", title: this.props.label, children: [_jsx("div", { className: "label", children: this.props.label }), _jsx("div", { className: "vector", children: `X: ${this.state.value.x.toFixed(2)}, Y: ${this.state.value.y.toFixed(2)}` }), _jsx("div", { className: "expand hoverIcon", onClick: () => this.switchExpandState(), title: "Expand", children: chevron })] }), this.state.isExpanded && (_jsxs("div", { className: "secondLine", children: [_jsx(NumericInput, { lockObject: this.props.lockObject, label: "x", step: this.props.step, value: this.state.value.x, onChange: (value) => this.updateStateX(value) }), _jsx(NumericInput, { lockObject: this.props.lockObject, label: "y", step: this.props.step, value: this.state.value.y, onChange: (value) => this.updateStateY(value) })] }))] }));
|
58
58
|
}
|
59
59
|
}
|
60
60
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"vector2LineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/vector2LineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"vector2LineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/vector2LineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAgBpE,MAAM,OAAO,oBAAqB,SAAQ,KAAK,CAAC,SAA8E;IAQ1H,YAAY,KAAiC;QACzC,KAAK,CAAC,KAAK,CAAC,CAAC;QAHT,iBAAY,GAAG,KAAK,CAAC;QAKzB,IAAI,CAAC,KAAK,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;IAClG,CAAC;IAEQ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EAAE,KAAK,EAAE,KAAK;CACrB,AAFkB,CAEjB","sourcesContent":["import * as React from \"react\";\r\nimport type { Vector2 } from \"core/Maths/math.vector\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\n\r\nimport { NumericInput } from \"./numericInputComponent\";\r\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\r\nimport { faMinus, faPlus } from \"@fortawesome/free-solid-svg-icons\";\r\nimport type { PropertyChangedEvent } from \"../propertyChangedEvent\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\n\r\ninterface IVector2LineComponentProps {\r\n label: string;\r\n target: any;\r\n propertyName: string;\r\n step?: number;\r\n onChange?: (newvalue: Vector2) => void;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n icon?: string;\r\n iconLabel?: string;\r\n lockObject: LockObject;\r\n}\r\n\r\nexport class Vector2LineComponent extends React.Component<IVector2LineComponentProps, { isExpanded: boolean; value: Vector2 }> {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n static defaultProps = {\r\n step: 0.001, // cm\r\n };\r\n\r\n private _localChange = false;\r\n\r\n constructor(props: IVector2LineComponentProps) {\r\n super(props);\r\n\r\n this.state = { isExpanded: false, value: this.props.target[this.props.propertyName].clone() };\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IVector2LineComponentProps, nextState: { isExpanded: boolean; value: Vector2 }) {\r\n const nextPropsValue = nextProps.target[nextProps.propertyName];\r\n\r\n if (!nextPropsValue.equals(nextState.value) || this._localChange) {\r\n nextState.value = nextPropsValue.clone();\r\n this._localChange = false;\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n switchExpandState() {\r\n this._localChange = true;\r\n this.setState({ isExpanded: !this.state.isExpanded });\r\n }\r\n\r\n raiseOnPropertyChanged(previousValue: Vector2) {\r\n if (this.props.onChange) {\r\n this.props.onChange(this.state.value);\r\n }\r\n\r\n if (!this.props.onPropertyChangedObservable) {\r\n return;\r\n }\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: this.props.target,\r\n property: this.props.propertyName,\r\n value: this.state.value,\r\n initialValue: previousValue,\r\n });\r\n }\r\n\r\n updateStateX(value: number) {\r\n this._localChange = true;\r\n\r\n const store = this.state.value.clone();\r\n this.props.target[this.props.propertyName].x = value;\r\n this.state.value.x = value;\r\n this.setState({ value: this.state.value });\r\n\r\n this.raiseOnPropertyChanged(store);\r\n }\r\n\r\n updateStateY(value: number) {\r\n this._localChange = true;\r\n\r\n const store = this.state.value.clone();\r\n this.props.target[this.props.propertyName].y = value;\r\n this.state.value.y = value;\r\n this.setState({ value: this.state.value });\r\n\r\n this.raiseOnPropertyChanged(store);\r\n }\r\n\r\n override render() {\r\n const chevron = this.state.isExpanded ? <FontAwesomeIcon icon={faMinus} /> : <FontAwesomeIcon icon={faPlus} />;\r\n\r\n return (\r\n <div className=\"vector3Line\">\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <div className=\"firstLine\" title={this.props.label}>\r\n <div className=\"label\">{this.props.label}</div>\r\n <div className=\"vector\">{`X: ${this.state.value.x.toFixed(2)}, Y: ${this.state.value.y.toFixed(2)}`}</div>\r\n <div className=\"expand hoverIcon\" onClick={() => this.switchExpandState()} title=\"Expand\">\r\n {chevron}\r\n </div>\r\n </div>\r\n {this.state.isExpanded && (\r\n <div className=\"secondLine\">\r\n <NumericInput\r\n lockObject={this.props.lockObject}\r\n label=\"x\"\r\n step={this.props.step}\r\n value={this.state.value.x}\r\n onChange={(value) => this.updateStateX(value)}\r\n />\r\n <NumericInput\r\n lockObject={this.props.lockObject}\r\n label=\"y\"\r\n step={this.props.step}\r\n value={this.state.value.y}\r\n onChange={(value) => this.updateStateY(value)}\r\n />\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|