@babylonjs/shared-ui-components 7.29.0 → 7.30.1
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/lines/vector2LineComponent.d.ts +1 -1
- package/lines/vector2LineComponent.js +3 -1
- package/lines/vector2LineComponent.js.map +1 -1
- package/lines/vector3LineComponent.js +1 -1
- package/lines/vector3LineComponent.js.map +1 -1
- package/lines/vector4LineComponent.d.ts +1 -1
- package/lines/vector4LineComponent.js +3 -1
- package/lines/vector4LineComponent.js.map +1 -1
- package/package.json +1 -1
@@ -1,5 +1,5 @@
|
|
1
1
|
import * as React from "react";
|
2
|
-
import
|
2
|
+
import { Vector2 } from "@babylonjs/core/Maths/math.vector.js";
|
3
3
|
import type { Observable } from "@babylonjs/core/Misc/observable.js";
|
4
4
|
import type { PropertyChangedEvent } from "../propertyChangedEvent";
|
5
5
|
import type { LockObject } from "../tabs/propertyGrids/lockObject";
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
2
|
import * as React from "react";
|
3
|
+
import { Vector2 } from "@babylonjs/core/Maths/math.vector.js";
|
3
4
|
import { NumericInput } from "./numericInputComponent.js";
|
4
5
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
5
6
|
import { faMinus, faPlus } from "@fortawesome/free-solid-svg-icons";
|
@@ -7,7 +8,8 @@ export class Vector2LineComponent extends React.Component {
|
|
7
8
|
constructor(props) {
|
8
9
|
super(props);
|
9
10
|
this._localChange = false;
|
10
|
-
|
11
|
+
const value = this.props.target[this.props.propertyName];
|
12
|
+
this.state = { isExpanded: false, value: value && value.clone ? value.clone() : Vector2.Zero() };
|
11
13
|
}
|
12
14
|
shouldComponentUpdate(nextProps, nextState) {
|
13
15
|
const nextPropsValue = nextProps.target[nextProps.propertyName];
|
@@ -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;
|
1
|
+
{"version":3,"file":"vector2LineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/vector2LineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,6CAA+B;AAGjD,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,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACzD,IAAI,CAAC,KAAK,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;IACrG,CAAC;IAEQ,qBAAqB,CAAC,SAAqC,EAAE,SAAkD;QACpH,MAAM,cAAc,GAAG,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QAEhE,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,YAAY,EAAE;YAC9D,SAAS,CAAC,KAAK,GAAG,cAAc,CAAC,KAAK,EAAE,CAAC;YACzC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;YAC1B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AAO,CAAC,CAAC,CAAC,EAAE,GAAO,EAC1G,cAAK,SAAS,EAAC,kBAAkB,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAC,QAAQ,YACpF,OAAO,GACN,IACJ,EACL,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,CACtB,eAAK,SAAS,EAAC,YAAY,aACvB,KAAC,YAAY,IACT,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,KAAK,EAAC,GAAG,EACT,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EACrB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAC/C,EACF,KAAC,YAAY,IACT,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,KAAK,EAAC,GAAG,EACT,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EACrB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAC/C,IACA,CACT,IACC,CACT,CAAC;IACN,CAAC;;AArGD,gEAAgE;AACzD,iCAAY,GAAG;IAClB,IAAI,EAAE,KAAK,EAAE,KAAK;CACrB,AAFkB,CAEjB","sourcesContent":["import * as React from \"react\";\r\nimport { 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 const value = this.props.target[this.props.propertyName];\r\n this.state = { isExpanded: false, value: value && value.clone ? value.clone() : Vector2.Zero() };\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"]}
|
@@ -13,7 +13,7 @@ export class Vector3LineComponent extends React.Component {
|
|
13
13
|
super(props);
|
14
14
|
this._localChange = false;
|
15
15
|
const value = this.getCurrentValue();
|
16
|
-
this.state = { isExpanded: false, value: value ? value.clone() : Vector3.Zero() };
|
16
|
+
this.state = { isExpanded: false, value: value && value.clone ? value.clone() : Vector3.Zero() };
|
17
17
|
}
|
18
18
|
getCurrentValue() {
|
19
19
|
return this.props.target[this.props.propertyName];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"vector3LineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/vector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YAAY,IACT,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,KAAK,EAAC,GAAG,EACT,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EACrB,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAC1C,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,GAChE,IACA,CACT,IACC,CACT,CAAC;IACN,CAAC;;AA9MD,gEAAgE;AACzD,iCAAY,GAAG;IAClB,IAAI,EAAE,KAAK,EAAE,KAAK;CACrB,AAFkB,CAEjB","sourcesContent":["import * as React from \"react\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport { NumericInput } from \"../lines/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 { SliderLineComponent } from \"../lines/sliderLineComponent\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\nimport copyIcon from \"./copy.svg\";\r\n\r\ninterface IVector3LineComponentProps {\r\n label: string;\r\n target: any;\r\n propertyName: string;\r\n step?: number;\r\n onChange?: (newvalue: Vector3) => void;\r\n useEuler?: boolean;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n noSlider?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n lockObject: LockObject;\r\n}\r\n\r\nexport class Vector3LineComponent extends React.Component<IVector3LineComponentProps, { isExpanded: boolean; value: Vector3 }> {\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: IVector3LineComponentProps) {\r\n super(props);\r\n\r\n const value = this.getCurrentValue();\r\n this.state = { isExpanded: false, value: value ? value.clone() : Vector3.Zero() };\r\n }\r\n\r\n getCurrentValue() {\r\n return this.props.target[this.props.propertyName];\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IVector3LineComponentProps, nextState: { isExpanded: boolean; value: Vector3 }) {\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: 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 updateVector3() {\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 updateStateX(value: number) {\r\n this._localChange = true;\r\n\r\n this.state.value.x = value;\r\n this.updateVector3();\r\n }\r\n\r\n updateStateY(value: number) {\r\n this._localChange = true;\r\n\r\n this.state.value.y = value;\r\n this.updateVector3();\r\n }\r\n\r\n updateStateZ(value: number) {\r\n this._localChange = true;\r\n\r\n this.state.value.z = value;\r\n this.updateVector3();\r\n }\r\n\r\n // Copy to clipboard the code this Vector3 actually does\r\n // Example : Mesh.position = 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 strVector = \"new \" + babylonNamespace + \"Vector3(\" + value.x + \", \" + value.y + \", \" + value.z + \")\";\r\n const strCommand = targetName + \".\" + targetProperty + \" = \" + strVector + \";// (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=\"vector3Line\">\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=\"vector\">\r\n {!this.props.useEuler && `X: ${this.state.value.x.toFixed(2)}, Y: ${this.state.value.y.toFixed(2)}, Z: ${this.state.value.z.toFixed(2)}`}\r\n {this.props.useEuler &&\r\n `X: ${Tools.ToDegrees(this.state.value.x).toFixed(2)}, Y: ${Tools.ToDegrees(this.state.value.y).toFixed(2)}, Z: ${Tools.ToDegrees(\r\n this.state.value.z\r\n ).toFixed(2)}`}\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 && !this.props.useEuler && (\r\n <div className=\"secondLine\">\r\n <NumericInput\r\n label=\"x\"\r\n lockObject={this.props.lockObject}\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 label=\"y\"\r\n lockObject={this.props.lockObject}\r\n step={this.props.step}\r\n value={this.state.value.y}\r\n onChange={(value) => this.updateStateY(value)}\r\n />\r\n <NumericInput\r\n label=\"z\"\r\n lockObject={this.props.lockObject}\r\n step={this.props.step}\r\n value={this.state.value.z}\r\n onChange={(value) => this.updateStateZ(value)}\r\n />\r\n </div>\r\n )}\r\n {this.state.isExpanded && this.props.useEuler && !this.props.noSlider && (\r\n <div className=\"secondLine\">\r\n <SliderLineComponent\r\n lockObject={this.props.lockObject}\r\n margin={true}\r\n label=\"x\"\r\n minimum={0}\r\n maximum={360}\r\n step={0.1}\r\n directValue={Tools.ToDegrees(this.state.value.x)}\r\n onChange={(value) => this.updateStateX(Tools.ToRadians(value))}\r\n />\r\n <SliderLineComponent\r\n lockObject={this.props.lockObject}\r\n margin={true}\r\n label=\"y\"\r\n minimum={0}\r\n maximum={360}\r\n step={0.1}\r\n directValue={Tools.ToDegrees(this.state.value.y)}\r\n onChange={(value) => this.updateStateY(Tools.ToRadians(value))}\r\n />\r\n <SliderLineComponent\r\n lockObject={this.props.lockObject}\r\n margin={true}\r\n label=\"z\"\r\n minimum={0}\r\n maximum={360}\r\n step={0.1}\r\n directValue={Tools.ToDegrees(this.state.value.z)}\r\n onChange={(value) => this.updateStateZ(Tools.ToRadians(value))}\r\n />\r\n </div>\r\n )}\r\n {this.state.isExpanded && this.props.useEuler && this.props.noSlider && (\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={Tools.ToDegrees(this.state.value.x)}\r\n onChange={(value) => this.updateStateX(Tools.ToRadians(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={Tools.ToDegrees(this.state.value.y)}\r\n onChange={(value) => this.updateStateY(Tools.ToRadians(value))}\r\n />\r\n <NumericInput\r\n lockObject={this.props.lockObject}\r\n label=\"z\"\r\n step={this.props.step}\r\n value={Tools.ToDegrees(this.state.value.z)}\r\n onChange={(value) => this.updateStateZ(Tools.ToRadians(value))}\r\n />\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
1
|
+
{"version":3,"file":"vector3LineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/vector3LineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,6CAA+B;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,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,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAExC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAgBlC,MAAM,OAAO,oBAAqB,SAAQ,KAAK,CAAC,SAA8E;IAQ1H,YAAY,KAAiC;QACzC,KAAK,CAAC,KAAK,CAAC,CAAC;QAHT,iBAAY,GAAG,KAAK,CAAC;QAKzB,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;IACrG,CAAC;IAED,eAAe;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACtD,CAAC;IAEQ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,IAAI,CAAC,KAAK,CAAC,IAAI,EACrB,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAC1C,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,GAChE,EACF,KAAC,YAAY,IACT,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,KAAK,EAAC,GAAG,EACT,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EACrB,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAC1C,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,GAChE,IACA,CACT,IACC,CACT,CAAC;IACN,CAAC;;AA9MD,gEAAgE;AACzD,iCAAY,GAAG;IAClB,IAAI,EAAE,KAAK,EAAE,KAAK;CACrB,AAFkB,CAEjB","sourcesContent":["import * as React from \"react\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport { NumericInput } from \"../lines/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 { SliderLineComponent } from \"../lines/sliderLineComponent\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\nimport copyIcon from \"./copy.svg\";\r\n\r\ninterface IVector3LineComponentProps {\r\n label: string;\r\n target: any;\r\n propertyName: string;\r\n step?: number;\r\n onChange?: (newvalue: Vector3) => void;\r\n useEuler?: boolean;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n noSlider?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n lockObject: LockObject;\r\n}\r\n\r\nexport class Vector3LineComponent extends React.Component<IVector3LineComponentProps, { isExpanded: boolean; value: Vector3 }> {\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: IVector3LineComponentProps) {\r\n super(props);\r\n\r\n const value = this.getCurrentValue();\r\n this.state = { isExpanded: false, value: value && value.clone ? value.clone() : Vector3.Zero() };\r\n }\r\n\r\n getCurrentValue() {\r\n return this.props.target[this.props.propertyName];\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IVector3LineComponentProps, nextState: { isExpanded: boolean; value: Vector3 }) {\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: 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 updateVector3() {\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 updateStateX(value: number) {\r\n this._localChange = true;\r\n\r\n this.state.value.x = value;\r\n this.updateVector3();\r\n }\r\n\r\n updateStateY(value: number) {\r\n this._localChange = true;\r\n\r\n this.state.value.y = value;\r\n this.updateVector3();\r\n }\r\n\r\n updateStateZ(value: number) {\r\n this._localChange = true;\r\n\r\n this.state.value.z = value;\r\n this.updateVector3();\r\n }\r\n\r\n // Copy to clipboard the code this Vector3 actually does\r\n // Example : Mesh.position = 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 strVector = \"new \" + babylonNamespace + \"Vector3(\" + value.x + \", \" + value.y + \", \" + value.z + \")\";\r\n const strCommand = targetName + \".\" + targetProperty + \" = \" + strVector + \";// (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=\"vector3Line\">\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=\"vector\">\r\n {!this.props.useEuler && `X: ${this.state.value.x.toFixed(2)}, Y: ${this.state.value.y.toFixed(2)}, Z: ${this.state.value.z.toFixed(2)}`}\r\n {this.props.useEuler &&\r\n `X: ${Tools.ToDegrees(this.state.value.x).toFixed(2)}, Y: ${Tools.ToDegrees(this.state.value.y).toFixed(2)}, Z: ${Tools.ToDegrees(\r\n this.state.value.z\r\n ).toFixed(2)}`}\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 && !this.props.useEuler && (\r\n <div className=\"secondLine\">\r\n <NumericInput\r\n label=\"x\"\r\n lockObject={this.props.lockObject}\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 label=\"y\"\r\n lockObject={this.props.lockObject}\r\n step={this.props.step}\r\n value={this.state.value.y}\r\n onChange={(value) => this.updateStateY(value)}\r\n />\r\n <NumericInput\r\n label=\"z\"\r\n lockObject={this.props.lockObject}\r\n step={this.props.step}\r\n value={this.state.value.z}\r\n onChange={(value) => this.updateStateZ(value)}\r\n />\r\n </div>\r\n )}\r\n {this.state.isExpanded && this.props.useEuler && !this.props.noSlider && (\r\n <div className=\"secondLine\">\r\n <SliderLineComponent\r\n lockObject={this.props.lockObject}\r\n margin={true}\r\n label=\"x\"\r\n minimum={0}\r\n maximum={360}\r\n step={0.1}\r\n directValue={Tools.ToDegrees(this.state.value.x)}\r\n onChange={(value) => this.updateStateX(Tools.ToRadians(value))}\r\n />\r\n <SliderLineComponent\r\n lockObject={this.props.lockObject}\r\n margin={true}\r\n label=\"y\"\r\n minimum={0}\r\n maximum={360}\r\n step={0.1}\r\n directValue={Tools.ToDegrees(this.state.value.y)}\r\n onChange={(value) => this.updateStateY(Tools.ToRadians(value))}\r\n />\r\n <SliderLineComponent\r\n lockObject={this.props.lockObject}\r\n margin={true}\r\n label=\"z\"\r\n minimum={0}\r\n maximum={360}\r\n step={0.1}\r\n directValue={Tools.ToDegrees(this.state.value.z)}\r\n onChange={(value) => this.updateStateZ(Tools.ToRadians(value))}\r\n />\r\n </div>\r\n )}\r\n {this.state.isExpanded && this.props.useEuler && this.props.noSlider && (\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={Tools.ToDegrees(this.state.value.x)}\r\n onChange={(value) => this.updateStateX(Tools.ToRadians(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={Tools.ToDegrees(this.state.value.y)}\r\n onChange={(value) => this.updateStateY(Tools.ToRadians(value))}\r\n />\r\n <NumericInput\r\n lockObject={this.props.lockObject}\r\n label=\"z\"\r\n step={this.props.step}\r\n value={Tools.ToDegrees(this.state.value.z)}\r\n onChange={(value) => this.updateStateZ(Tools.ToRadians(value))}\r\n />\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import * as React from "react";
|
2
|
-
import
|
2
|
+
import { Vector4 } from "@babylonjs/core/Maths/math.vector.js";
|
3
3
|
import type { Observable } from "@babylonjs/core/Misc/observable.js";
|
4
4
|
import type { PropertyChangedEvent } from "../propertyChangedEvent";
|
5
5
|
import type { LockObject } from "../tabs/propertyGrids/lockObject";
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
2
|
import * as React from "react";
|
3
|
+
import { Vector4 } from "@babylonjs/core/Maths/math.vector.js";
|
3
4
|
import { NumericInput } from "./numericInputComponent.js";
|
4
5
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
5
6
|
import { faMinus, faPlus } from "@fortawesome/free-solid-svg-icons";
|
@@ -7,7 +8,8 @@ export class Vector4LineComponent extends React.Component {
|
|
7
8
|
constructor(props) {
|
8
9
|
super(props);
|
9
10
|
this._localChange = false;
|
10
|
-
|
11
|
+
const value = this.getCurrentValue();
|
12
|
+
this.state = { isExpanded: false, value: value && value.clone ? value.clone() : Vector4.Zero() };
|
11
13
|
}
|
12
14
|
getCurrentValue() {
|
13
15
|
return this.props.value || this.props.target[this.props.propertyName];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"v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CAAC,KAAK,CAAC,CAAC,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAC/C,EACF,KAAC,YAAY,IACT,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,KAAK,EAAC,GAAG,EACT,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EACrB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAC/C,IACA,IAER,CACT,CAAC;IACN,CAAC;;AA9ID,gEAAgE;AACzD,iCAAY,GAAG;IAClB,IAAI,EAAE,KAAK,EAAE,KAAK;CACrB,AAFkB,CAEjB","sourcesContent":["import * as React from \"react\";\r\nimport type { Vector4 } 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 IVector4LineComponentProps {\r\n label: string;\r\n target?: any;\r\n propertyName?: string;\r\n step?: number;\r\n onChange?: (newvalue: Vector4) => void;\r\n useEuler?: boolean;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n icon?: string;\r\n iconLabel?: string;\r\n value?: Vector4;\r\n lockObject: LockObject;\r\n}\r\n\r\nexport class Vector4LineComponent extends React.Component<IVector4LineComponentProps, { isExpanded: boolean; value: Vector4 }> {\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: IVector4LineComponentProps) {\r\n super(props);\r\n\r\n this.state = { isExpanded: false, value: this.getCurrentValue().clone() };\r\n }\r\n\r\n getCurrentValue() {\r\n return this.props.value || this.props.target[this.props.propertyName!];\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IVector4LineComponentProps, nextState: { isExpanded: boolean; value: Vector4 }) {\r\n const nextPropsValue = nextProps.value || 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: Vector4) {\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 updateVector4() {\r\n const store = this.getCurrentValue().clone();\r\n\r\n if (this.props.value) {\r\n this.props.value.copyFrom(this.state.value);\r\n } else {\r\n this.props.target[this.props.propertyName!] = this.state.value;\r\n }\r\n\r\n this.setState({ value: store });\r\n\r\n this.raiseOnPropertyChanged(store);\r\n }\r\n\r\n updateStateX(value: number) {\r\n this._localChange = true;\r\n\r\n this.state.value.x = value;\r\n this.updateVector4();\r\n }\r\n\r\n updateStateY(value: number) {\r\n this._localChange = true;\r\n\r\n this.state.value.y = value;\r\n this.updateVector4();\r\n }\r\n\r\n updateStateZ(value: number) {\r\n this._localChange = true;\r\n\r\n this.state.value.z = value;\r\n this.updateVector4();\r\n }\r\n\r\n updateStateW(value: number) {\r\n this._localChange = true;\r\n\r\n this.state.value.w = value;\r\n this.updateVector4();\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 <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=\"vector\">\r\n {`X: ${this.state.value.x.toFixed(2)}, Y: ${this.state.value.y.toFixed(2)}, Z: ${this.state.value.z.toFixed(2)}, W: ${this.state.value.w.toFixed(2)}`}\r\n </div>\r\n <div className=\"expand hoverIcon\" onClick={() => this.switchExpandState()} title=\"Expand\">\r\n {chevron}\r\n </div>\r\n </div>\r\n {\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 <NumericInput\r\n lockObject={this.props.lockObject}\r\n label=\"z\"\r\n step={this.props.step}\r\n value={this.state.value.z}\r\n onChange={(value) => this.updateStateZ(value)}\r\n />\r\n <NumericInput\r\n lockObject={this.props.lockObject}\r\n label=\"w\"\r\n step={this.props.step}\r\n value={this.state.value.w}\r\n onChange={(value) => this.updateStateW(value)}\r\n />\r\n </div>\r\n }\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
1
|
+
{"version":3,"file":"vector4LineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/vector4LineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,6CAA+B;AAGjD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,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AC,YAAY,CAAC,KAAK,CAAC,GAC/C,EACF,KAAC,YAAY,IACT,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,KAAK,EAAC,GAAG,EACT,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EACrB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAC/C,IACA,IAER,CACT,CAAC;IACN,CAAC;;AA/ID,gEAAgE;AACzD,iCAAY,GAAG;IAClB,IAAI,EAAE,KAAK,EAAE,KAAK;CACrB,AAFkB,CAEjB","sourcesContent":["import * as React from \"react\";\r\nimport { Vector4 } 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 IVector4LineComponentProps {\r\n label: string;\r\n target?: any;\r\n propertyName?: string;\r\n step?: number;\r\n onChange?: (newvalue: Vector4) => void;\r\n useEuler?: boolean;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n icon?: string;\r\n iconLabel?: string;\r\n value?: Vector4;\r\n lockObject: LockObject;\r\n}\r\n\r\nexport class Vector4LineComponent extends React.Component<IVector4LineComponentProps, { isExpanded: boolean; value: Vector4 }> {\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: IVector4LineComponentProps) {\r\n super(props);\r\n\r\n const value = this.getCurrentValue();\r\n this.state = { isExpanded: false, value: value && value.clone ? value.clone() : Vector4.Zero() };\r\n }\r\n\r\n getCurrentValue() {\r\n return this.props.value || this.props.target[this.props.propertyName!];\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IVector4LineComponentProps, nextState: { isExpanded: boolean; value: Vector4 }) {\r\n const nextPropsValue = nextProps.value || 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: Vector4) {\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 updateVector4() {\r\n const store = this.getCurrentValue().clone();\r\n\r\n if (this.props.value) {\r\n this.props.value.copyFrom(this.state.value);\r\n } else {\r\n this.props.target[this.props.propertyName!] = this.state.value;\r\n }\r\n\r\n this.setState({ value: store });\r\n\r\n this.raiseOnPropertyChanged(store);\r\n }\r\n\r\n updateStateX(value: number) {\r\n this._localChange = true;\r\n\r\n this.state.value.x = value;\r\n this.updateVector4();\r\n }\r\n\r\n updateStateY(value: number) {\r\n this._localChange = true;\r\n\r\n this.state.value.y = value;\r\n this.updateVector4();\r\n }\r\n\r\n updateStateZ(value: number) {\r\n this._localChange = true;\r\n\r\n this.state.value.z = value;\r\n this.updateVector4();\r\n }\r\n\r\n updateStateW(value: number) {\r\n this._localChange = true;\r\n\r\n this.state.value.w = value;\r\n this.updateVector4();\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 <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=\"vector\">\r\n {`X: ${this.state.value.x.toFixed(2)}, Y: ${this.state.value.y.toFixed(2)}, Z: ${this.state.value.z.toFixed(2)}, W: ${this.state.value.w.toFixed(2)}`}\r\n </div>\r\n <div className=\"expand hoverIcon\" onClick={() => this.switchExpandState()} title=\"Expand\">\r\n {chevron}\r\n </div>\r\n </div>\r\n {\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 <NumericInput\r\n lockObject={this.props.lockObject}\r\n label=\"z\"\r\n step={this.props.step}\r\n value={this.state.value.z}\r\n onChange={(value) => this.updateStateZ(value)}\r\n />\r\n <NumericInput\r\n lockObject={this.props.lockObject}\r\n label=\"w\"\r\n step={this.props.step}\r\n value={this.state.value.w}\r\n onChange={(value) => this.updateStateW(value)}\r\n />\r\n </div>\r\n }\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|