@babylonjs/shared-ui-components 7.4.0 → 7.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ export declare function copyCommandToClipboard(strCommand: string): void;
2
+ export declare function getClassNameWithNamespace(obj: any): {
3
+ className: string;
4
+ babylonNamespace: string;
5
+ };
@@ -0,0 +1,34 @@
1
+ import { GetClassName } from "@babylonjs/core/Misc/typeStore.js";
2
+ // Check if BABYLON namespace exists
3
+ let babylonNamespace = "";
4
+ const globalObject = typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : undefined;
5
+ if (typeof globalObject !== "undefined") {
6
+ if (typeof globalObject.BABYLON !== "undefined") {
7
+ babylonNamespace = "BABYLON.";
8
+ }
9
+ }
10
+ // Inspired by previous copyToClipboard() function which was copying Color3
11
+ // Copies strCommand to clipboard
12
+ export function copyCommandToClipboard(strCommand) {
13
+ const element = document.createElement("div");
14
+ element.textContent = strCommand;
15
+ document.body.appendChild(element);
16
+ if (window.getSelection) {
17
+ const range = document.createRange();
18
+ range.selectNode(element);
19
+ window.getSelection().removeAllRanges();
20
+ window.getSelection().addRange(range);
21
+ }
22
+ document.execCommand("copy");
23
+ element.remove();
24
+ }
25
+ // Return the class name of the considered target
26
+ // babylonNamespace is either "" (ES6) or "BABYLON."
27
+ export function getClassNameWithNamespace(obj) {
28
+ let className = GetClassName(obj);
29
+ if (className.includes("BABYLON.")) {
30
+ className = className.split("BABYLON.")[1];
31
+ }
32
+ return { className, babylonNamespace };
33
+ }
34
+ //# sourceMappingURL=copyCommandToClipboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copyCommandToClipboard.js","sourceRoot":"","sources":["../../../dev/sharedUiComponents/src/copyCommandToClipboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,0CAA4B;AAEnD,oCAAoC;AACpC,IAAI,gBAAgB,GAAG,EAAE,CAAC;AAC1B,MAAM,Y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ourcesContent":["import { GetClassName } from \"core/Misc/typeStore\";\r\n\r\n// Check if BABYLON namespace exists\r\nlet babylonNamespace = \"\";\r\nconst globalObject = typeof global !== \"undefined\" ? global : typeof window !== \"undefined\" ? window : undefined;\r\nif (typeof globalObject !== \"undefined\") {\r\n if (typeof (<any>globalObject).BABYLON !== \"undefined\") {\r\n babylonNamespace = \"BABYLON.\";\r\n }\r\n}\r\n\r\n// Inspired by previous copyToClipboard() function which was copying Color3\r\n// Copies strCommand to clipboard\r\nexport function copyCommandToClipboard(strCommand: string) {\r\n const element = document.createElement(\"div\");\r\n element.textContent = strCommand;\r\n document.body.appendChild(element);\r\n\r\n if (window.getSelection) {\r\n const range = document.createRange();\r\n range.selectNode(element);\r\n window.getSelection()!.removeAllRanges();\r\n window.getSelection()!.addRange(range);\r\n }\r\n\r\n document.execCommand(\"copy\");\r\n element.remove();\r\n}\r\n\r\n// Return the class name of the considered target\r\n// babylonNamespace is either \"\" (ES6) or \"BABYLON.\"\r\nexport function getClassNameWithNamespace(obj: any): { className: string; babylonNamespace: string } {\r\n let className = GetClassName(obj);\r\n if (className.includes(\"BABYLON.\")) {\r\n className = className.split(\"BABYLON.\")[1];\r\n }\r\n return { className, babylonNamespace };\r\n}\r\n"]}
@@ -32,5 +32,6 @@ export declare class CheckBoxLineComponent extends React.Component<ICheckBoxLine
32
32
  isConflict: boolean;
33
33
  }): boolean;
34
34
  onChange(): void;
35
+ onCopyClick(): void;
35
36
  render(): import("react/jsx-runtime").JSX.Element;
36
37
  }
@@ -1,7 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
+ import { copyCommandToClipboard, getClassNameWithNamespace } from "../copyCommandToClipboard.js";
3
4
  import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
4
5
  import { conflictingValuesPlaceholder } from "./targetsProxy.js";
6
+ import copyIcon from "./copy.svg";
5
7
  import toggleOnIcon40px from "../imgs/toggleOnIcon_40px.svg";
6
8
  import toggleOffIcon40px from "../imgs/toggleOffIcon_40px.svg";
7
9
  import toggleOnIcon30px from "../imgs/toggleOnIcon_30px.svg";
@@ -80,10 +82,25 @@ export class CheckBoxLineComponent extends React.Component {
80
82
  }
81
83
  this.setState({ isSelected: !this.state.isSelected, isConflict: false });
82
84
  }
85
+ // Copy to clipboard the code this checkbox actually does
86
+ // Example : mesh.checkCollisions = true;
87
+ onCopyClick() {
88
+ if (this.props && this.props.target) {
89
+ const { className, babylonNamespace } = getClassNameWithNamespace(this.props.target);
90
+ const targetName = "globalThis.debugNode";
91
+ const targetProperty = this.props.propertyName;
92
+ const value = this.props.target[this.props.propertyName];
93
+ const strCommand = targetName + "." + targetProperty + " = " + value + ";// (debugNode as " + babylonNamespace + className + ")";
94
+ copyCommandToClipboard(strCommand);
95
+ }
96
+ else {
97
+ copyCommandToClipboard("undefined");
98
+ }
99
+ }
83
100
  render() {
84
101
  const icons = this.props.large ? Icons.size40 : Icons.size30;
85
102
  const icon = this.state.isConflict ? icons.mixed : this.state.isSelected ? icons.on : icons.off;
86
- return (_jsxs("div", { className: "checkBoxLine", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), this.props.label && (_jsx("div", { className: "label", title: this.props.iconLabel, children: this.props.label })), this.props.faIcons && (_jsx(FontAwesomeIcon, { className: `cbx ${this.props.disabled ? "disabled" : ""}`, icon: this.state.isSelected ? this.props.faIcons.enabled : this.props.faIcons.disabled, onClick: () => !this.props.disabled && this.onChange() })), !this.props.faIcons && (_jsx("div", { className: "checkBox", children: _jsxs("label", { className: `container lbl${this.props.disabled ? " disabled" : ""} ${this.state.isSelected ? "checked" : ""}`, children: [_jsx("input", { type: "checkbox", className: `cbx hidden ${this.state.isConflict ? "conflict" : ""}`, checked: this.state.isSelected, onChange: () => this.onChange(), disabled: !!this.props.disabled }), _jsx("img", { className: "icon", src: icon, alt: this.props.label })] }) }))] }));
103
+ return (_jsxs("div", { className: "checkBoxLine", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), this.props.label && (_jsx("div", { className: "label", title: this.props.iconLabel, children: this.props.label })), this.props.faIcons && (_jsx(FontAwesomeIcon, { className: `cbx ${this.props.disabled ? "disabled" : ""}`, icon: this.state.isSelected ? this.props.faIcons.enabled : this.props.faIcons.disabled, onClick: () => !this.props.disabled && this.onChange() })), !this.props.faIcons && (_jsx("div", { className: "checkBox", children: _jsxs("label", { className: `container lbl${this.props.disabled ? " disabled" : ""} ${this.state.isSelected ? "checked" : ""}`, children: [_jsx("input", { type: "checkbox", className: `cbx hidden ${this.state.isConflict ? "conflict" : ""}`, checked: this.state.isSelected, onChange: () => this.onChange(), disabled: !!this.props.disabled }), _jsx("img", { className: "icon", src: icon, alt: this.props.label })] }) })), _jsx("div", { className: "copy hoverIcon", onClick: () => this.onCopyClick(), title: "Copy to clipboard", children: _jsx("img", { src: copyIcon, alt: "Copy" }) })] }));
87
104
  }
88
105
  }
89
106
  //# sourceMappingURL=checkBoxLineComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkBoxLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/checkBoxLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAiB9D,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,iBAAiB,MAAM,gCAAgC,CAAC;AAC/D,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,mBAAmB,MAAM,kCAAkC,CAAC;AACnE,OAAO,iBAAiB,MAAM,gCAAgC,CAAC;AAE/D,MAAM,KAAK,GAAG;IACV,MAAM,EAAE;QACJ,EAAE,EAAE,gBAAgB;QACpB,KA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,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,EACzD,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EACtF,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAAE,GACxD,CACL,EACA,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CACpB,cAAK,SAAS,EAAC,UAAU,YACrB,iBAAO,SAAS,EAAE,gBAAgB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,aAChH,gBACI,IAAI,EAAC,UAAU,EACf,SAAS,EAAE,cAAc,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,EAClE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAC9B,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,EAC/B,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GACjC,EACF,cAAK,SAAS,EAAC,MAAM,EAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAI,IACtD,GACN,CACT,IACC,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 type { IconDefinition } from \"@fortawesome/fontawesome-common-types\";\r\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\r\nimport { conflictingValuesPlaceholder } from \"./targetsProxy\";\r\n\r\nexport interface ICheckBoxLineComponentProps {\r\n label?: string;\r\n target?: any;\r\n propertyName?: string;\r\n isSelected?: () => boolean;\r\n onSelect?: (value: boolean) => void;\r\n onValueChanged?: () => void;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n disabled?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n faIcons?: { enabled: IconDefinition; disabled: IconDefinition };\r\n large?: boolean;\r\n}\r\n\r\nimport toggleOnIcon40px from \"../imgs/toggleOnIcon_40px.svg\";\r\nimport toggleOffIcon40px from \"../imgs/toggleOffIcon_40px.svg\";\r\nimport toggleOnIcon30px from \"../imgs/toggleOnIcon_30px.svg\";\r\nimport toggleMixedIcon30px from \"../imgs/toggleMixedIcon_30px.svg\";\r\nimport toggleOffIcon30px from \"../imgs/toggleOffIcon_30px.svg\";\r\n\r\nconst Icons = {\r\n size30: {\r\n on: toggleOnIcon30px,\r\n mixed: toggleMixedIcon30px,\r\n off: toggleOffIcon30px,\r\n },\r\n size40: {\r\n on: toggleOnIcon40px,\r\n mixed: \"\", // unneeded\r\n off: toggleOffIcon40px,\r\n },\r\n};\r\n\r\nexport class CheckBoxLineComponent extends React.Component<ICheckBoxLineComponentProps, { isSelected: boolean; isDisabled?: boolean; isConflict: boolean }> {\r\n private _localChange = false;\r\n constructor(props: ICheckBoxLineComponentProps) {\r\n super(props);\r\n\r\n if (this.props.isSelected) {\r\n this.state = { isSelected: this.props.isSelected(), isConflict: false };\r\n } else {\r\n this.state = {\r\n isSelected: this.props.target[this.props.propertyName!] === true,\r\n isConflict: this.props.target[this.props.propertyName!] === conflictingValuesPlaceholder,\r\n };\r\n }\r\n\r\n if (this.props.disabled) {\r\n this.state = { ...this.state, isDisabled: this.props.disabled };\r\n }\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: ICheckBoxLineComponentProps, nextState: { isSelected: boolean; isDisabled: boolean; isConflict: boolean }) {\r\n let selected: boolean;\r\n\r\n if (nextProps.isSelected) {\r\n selected = nextProps.isSelected!();\r\n } else {\r\n selected = nextProps.target[nextProps.propertyName!] === true;\r\n if (nextProps.target[nextProps.propertyName!] === conflictingValuesPlaceholder) {\r\n nextState.isConflict = true;\r\n }\r\n }\r\n\r\n if (selected !== nextState.isSelected || this._localChange) {\r\n nextState.isSelected = selected;\r\n this._localChange = false;\r\n return true;\r\n }\r\n\r\n if (nextProps.disabled !== nextState.isDisabled) {\r\n return true;\r\n }\r\n\r\n return nextProps.label !== this.props.label || nextProps.target !== this.props.target || nextState.isConflict !== this.state.isConflict;\r\n }\r\n\r\n onChange() {\r\n this._localChange = true;\r\n if (this.props.onSelect) {\r\n this.props.onSelect(!this.state.isSelected);\r\n } else {\r\n if (this.props.onPropertyChangedObservable) {\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: this.props.target,\r\n property: this.props.propertyName!,\r\n value: !this.state.isSelected,\r\n initialValue: this.state.isSelected,\r\n });\r\n }\r\n\r\n if (this.props.target && this.props.propertyName) {\r\n this.props.target[this.props.propertyName!] = !this.state.isSelected;\r\n }\r\n }\r\n\r\n if (this.props.onValueChanged) {\r\n this.props.onValueChanged();\r\n }\r\n\r\n this.setState({ isSelected: !this.state.isSelected, isConflict: false });\r\n }\r\n\r\n override render() {\r\n const icons = this.props.large ? Icons.size40 : Icons.size30;\r\n const icon = this.state.isConflict ? icons.mixed : this.state.isSelected ? icons.on : icons.off;\r\n return (\r\n <div className=\"checkBoxLine\">\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=\"label\" title={this.props.iconLabel}>\r\n {this.props.label}\r\n </div>\r\n )}\r\n {this.props.faIcons && (\r\n <FontAwesomeIcon\r\n className={`cbx ${this.props.disabled ? \"disabled\" : \"\"}`}\r\n icon={this.state.isSelected ? this.props.faIcons.enabled : this.props.faIcons.disabled}\r\n onClick={() => !this.props.disabled && this.onChange()}\r\n />\r\n )}\r\n {!this.props.faIcons && (\r\n <div className=\"checkBox\">\r\n <label className={`container lbl${this.props.disabled ? \" disabled\" : \"\"} ${this.state.isSelected ? \"checked\" : \"\"}`}>\r\n <input\r\n type=\"checkbox\"\r\n className={`cbx hidden ${this.state.isConflict ? \"conflict\" : \"\"}`}\r\n checked={this.state.isSelected}\r\n onChange={() => this.onChange()}\r\n disabled={!!this.props.disabled}\r\n />\r\n <img className=\"icon\" src={icon} alt={this.props.label} />\r\n </label>\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"checkBoxLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/checkBoxLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAE9F,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,QAAQ,MAAM,YAAY,CAAC;AAiBlC,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,iBAAiB,MAAM,gCAAgC,CAAC;AAC/D,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,mBAAmB,MAAM,kCAAkC,CAAC;AACnE,OAAO,iBAAiB,MAAM,gCAAgC,CAAC;AAE/D,MAAM,KAAK,GAAG;IACV,MAAM,EAAE;QACJ,EAAE,EAAE,gBAAgB;QACpB,KAAK,EAAE,mBAAmB;QAC1B,GAAG,EAAE,iBAAiB;KACzB;IACD,MAAM,EAAE;QACJ,EAAE,EAAE,gBAAgB;QACpB,KAAK,EAAE,EAAE;QACT,GAAG,EAAE,iBAAiB;KACzB;CACJ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,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,EAClE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAC9B,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,EAC/B,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GACjC,EACF,cAAK,SAAS,EAAC,MAAM,EAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAI,IACtD,GACN,CACT,EACD,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 { IconDefinition } from \"@fortawesome/fontawesome-common-types\";\r\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\r\nimport { conflictingValuesPlaceholder } from \"./targetsProxy\";\r\nimport copyIcon from \"./copy.svg\";\r\n\r\nexport interface ICheckBoxLineComponentProps {\r\n label?: string;\r\n target?: any;\r\n propertyName?: string;\r\n isSelected?: () => boolean;\r\n onSelect?: (value: boolean) => void;\r\n onValueChanged?: () => void;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n disabled?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n faIcons?: { enabled: IconDefinition; disabled: IconDefinition };\r\n large?: boolean;\r\n}\r\n\r\nimport toggleOnIcon40px from \"../imgs/toggleOnIcon_40px.svg\";\r\nimport toggleOffIcon40px from \"../imgs/toggleOffIcon_40px.svg\";\r\nimport toggleOnIcon30px from \"../imgs/toggleOnIcon_30px.svg\";\r\nimport toggleMixedIcon30px from \"../imgs/toggleMixedIcon_30px.svg\";\r\nimport toggleOffIcon30px from \"../imgs/toggleOffIcon_30px.svg\";\r\n\r\nconst Icons = {\r\n size30: {\r\n on: toggleOnIcon30px,\r\n mixed: toggleMixedIcon30px,\r\n off: toggleOffIcon30px,\r\n },\r\n size40: {\r\n on: toggleOnIcon40px,\r\n mixed: \"\", // unneeded\r\n off: toggleOffIcon40px,\r\n },\r\n};\r\n\r\nexport class CheckBoxLineComponent extends React.Component<ICheckBoxLineComponentProps, { isSelected: boolean; isDisabled?: boolean; isConflict: boolean }> {\r\n private _localChange = false;\r\n constructor(props: ICheckBoxLineComponentProps) {\r\n super(props);\r\n\r\n if (this.props.isSelected) {\r\n this.state = { isSelected: this.props.isSelected(), isConflict: false };\r\n } else {\r\n this.state = {\r\n isSelected: this.props.target[this.props.propertyName!] === true,\r\n isConflict: this.props.target[this.props.propertyName!] === conflictingValuesPlaceholder,\r\n };\r\n }\r\n\r\n if (this.props.disabled) {\r\n this.state = { ...this.state, isDisabled: this.props.disabled };\r\n }\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: ICheckBoxLineComponentProps, nextState: { isSelected: boolean; isDisabled: boolean; isConflict: boolean }) {\r\n let selected: boolean;\r\n\r\n if (nextProps.isSelected) {\r\n selected = nextProps.isSelected!();\r\n } else {\r\n selected = nextProps.target[nextProps.propertyName!] === true;\r\n if (nextProps.target[nextProps.propertyName!] === conflictingValuesPlaceholder) {\r\n nextState.isConflict = true;\r\n }\r\n }\r\n\r\n if (selected !== nextState.isSelected || this._localChange) {\r\n nextState.isSelected = selected;\r\n this._localChange = false;\r\n return true;\r\n }\r\n\r\n if (nextProps.disabled !== nextState.isDisabled) {\r\n return true;\r\n }\r\n\r\n return nextProps.label !== this.props.label || nextProps.target !== this.props.target || nextState.isConflict !== this.state.isConflict;\r\n }\r\n\r\n onChange() {\r\n this._localChange = true;\r\n if (this.props.onSelect) {\r\n this.props.onSelect(!this.state.isSelected);\r\n } else {\r\n if (this.props.onPropertyChangedObservable) {\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: this.props.target,\r\n property: this.props.propertyName!,\r\n value: !this.state.isSelected,\r\n initialValue: this.state.isSelected,\r\n });\r\n }\r\n\r\n if (this.props.target && this.props.propertyName) {\r\n this.props.target[this.props.propertyName!] = !this.state.isSelected;\r\n }\r\n }\r\n\r\n if (this.props.onValueChanged) {\r\n this.props.onValueChanged();\r\n }\r\n\r\n this.setState({ isSelected: !this.state.isSelected, isConflict: false });\r\n }\r\n\r\n // Copy to clipboard the code this checkbox actually does\r\n // Example : mesh.checkCollisions = true;\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 const icons = this.props.large ? Icons.size40 : Icons.size30;\r\n const icon = this.state.isConflict ? icons.mixed : this.state.isSelected ? icons.on : icons.off;\r\n return (\r\n <div className=\"checkBoxLine\">\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=\"label\" title={this.props.iconLabel}>\r\n {this.props.label}\r\n </div>\r\n )}\r\n {this.props.faIcons && (\r\n <FontAwesomeIcon\r\n className={`cbx ${this.props.disabled ? \"disabled\" : \"\"}`}\r\n icon={this.state.isSelected ? this.props.faIcons.enabled : this.props.faIcons.disabled}\r\n onClick={() => !this.props.disabled && this.onChange()}\r\n />\r\n )}\r\n {!this.props.faIcons && (\r\n <div className=\"checkBox\">\r\n <label className={`container lbl${this.props.disabled ? \" disabled\" : \"\"} ${this.state.isSelected ? \"checked\" : \"\"}`}>\r\n <input\r\n type=\"checkbox\"\r\n className={`cbx hidden ${this.state.isConflict ? \"conflict\" : \"\"}`}\r\n checked={this.state.isSelected}\r\n onChange={() => this.onChange()}\r\n disabled={!!this.props.disabled}\r\n />\r\n <img className=\"icon\" src={icon} alt={this.props.label} />\r\n </label>\r\n </div>\r\n )}\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"]}
@@ -32,9 +32,9 @@ export declare class ColorLineComponent extends React.Component<IColorLineCompon
32
32
  updateStateG(value: number): void;
33
33
  updateStateB(value: number): void;
34
34
  updateStateA(value: number): void;
35
- copyToClipboard(): void;
36
35
  private _convertToColor;
37
36
  private _toColor3;
37
+ onCopyClick(): void;
38
38
  render(): import("react/jsx-runtime").JSX.Element;
39
39
  }
40
40
  export {};
@@ -4,6 +4,7 @@ import { Color3, Color4 } from "@babylonjs/core/Maths/math.color.js";
4
4
  import { NumericInputComponent } from "./numericInputComponent.js";
5
5
  import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
6
6
  import { faMinus, faPlus } from "@fortawesome/free-solid-svg-icons";
7
+ import { copyCommandToClipboard, getClassNameWithNamespace } from "../copyCommandToClipboard.js";
7
8
  import { ColorPickerLineComponent } from "./colorPickerComponent.js";
8
9
  import { conflictingValuesPlaceholder } from "./targetsProxy.js";
9
10
  import copyIcon from "./copy.svg";
@@ -96,19 +97,6 @@ export class ColorLineComponent extends React.Component {
96
97
  }
97
98
  this.setColor(new Color4(this.state.color.r, this.state.color.g, this.state.color.b, value));
98
99
  }
99
- copyToClipboard() {
100
- const element = document.createElement("div");
101
- element.textContent = this.state.color.toHexString();
102
- document.body.appendChild(element);
103
- if (window.getSelection) {
104
- const range = document.createRange();
105
- range.selectNode(element);
106
- window.getSelection().removeAllRanges();
107
- window.getSelection().addRange(range);
108
- }
109
- document.execCommand("copy");
110
- element.remove();
111
- }
112
100
  _convertToColor(color) {
113
101
  if (color === "" || color === "transparent") {
114
102
  return emptyColor;
@@ -135,11 +123,35 @@ export class ColorLineComponent extends React.Component {
135
123
  _toColor3(color) {
136
124
  return new Color3(color.r, color.g, color.b);
137
125
  }
126
+ // Copy to clipboard the code this Color3 actually does
127
+ // Example : material.diffuseColor = new BABYLON.Vector3(0,1,0);
128
+ onCopyClick() {
129
+ if (this.props && this.props.target) {
130
+ const { className, babylonNamespace } = getClassNameWithNamespace(this.props.target);
131
+ const targetName = "globalThis.debugNode";
132
+ const targetProperty = this.props.propertyName;
133
+ const value = this.props.target[this.props.propertyName];
134
+ const hex = this.state.color.toHexString();
135
+ let strColor;
136
+ if (value.a) {
137
+ strColor = "new " + babylonNamespace + "Color4(" + value.r + ", " + value.g + ", " + value.b + ", " + value.a + ")";
138
+ }
139
+ else {
140
+ strColor = "new " + babylonNamespace + "Color3(" + value.r + ", " + value.g + ", " + value.b + ")";
141
+ }
142
+ strColor += ";// (HEX : " + hex;
143
+ const strCommand = targetName + "." + targetProperty + " = " + strColor + " , debugNode as " + babylonNamespace + className + ")";
144
+ copyCommandToClipboard(strCommand);
145
+ }
146
+ else {
147
+ copyCommandToClipboard("undefined");
148
+ }
149
+ }
138
150
  render() {
139
151
  const chevron = this.state.isExpanded ? _jsx(FontAwesomeIcon, { icon: faMinus }) : _jsx(FontAwesomeIcon, { icon: faPlus });
140
152
  return (_jsxs("div", { className: "color3Line", children: [_jsxs("div", { className: "firstLine", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), _jsx("div", { className: "label", title: this.props.label, children: this.props.label }), _jsx("div", { className: "color3", children: _jsx(ColorPickerLineComponent, { lockObject: this.props.lockObject, linearHint: this.props.isLinear, value: this.props.disableAlpha ? this._toColor3(this.state.color) : this.state.color, onColorChanged: (colorString) => {
141
153
  this.setColorFromString(colorString);
142
- } }) }), _jsx("div", { className: "copy hoverIcon", onClick: () => this.copyToClipboard(), title: "Copy to clipboard", children: _jsx("img", { src: copyIcon, alt: "Copy" }) }), _jsx("div", { className: "expand hoverIcon", onClick: () => this.switchExpandState(), title: "Expand", children: chevron })] }), this.state.isExpanded && (_jsxs("div", { className: "secondLine", children: [_jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "r", value: this.state.color.r, onChange: (value) => this.updateStateR(value) }), _jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "g", value: this.state.color.g, onChange: (value) => this.updateStateG(value) }), _jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "b", value: this.state.color.b, onChange: (value) => this.updateStateB(value) }), this.props.disableAlpha || (_jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "a", value: this.state.color.a, onChange: (value) => this.updateStateA(value) }))] }))] }));
154
+ } }) }), _jsx("div", { className: "expand hoverIcon", onClick: () => this.switchExpandState(), title: "Expand", children: chevron }), _jsx("div", { className: "copy hoverIcon", onClick: () => this.onCopyClick(), title: "Copy to clipboard", children: _jsx("img", { src: copyIcon, alt: "Copy" }) })] }), this.state.isExpanded && (_jsxs("div", { className: "secondLine", children: [_jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "r", value: this.state.color.r, onChange: (value) => this.updateStateR(value) }), _jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "g", value: this.state.color.g, onChange: (value) => this.updateStateG(value) }), _jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "b", value: this.state.color.b, onChange: (value) => this.updateStateB(value) }), this.props.disableAlpha || (_jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "a", value: this.state.color.a, onChange: (value) => this.updateStateA(value) }))] }))] }));
143
155
  }
144
156
  }
145
157
  //# sourceMappingURL=colorLineComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"colorLineComponent.js","sourceRoot":"","sources":["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AAE,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 { ColorPickerLineComponent } from \"./colorPickerComponent\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\nimport { conflictingValuesPlaceholder } from \"./targetsProxy\";\r\n\r\nimport copyIcon from \"./copy.svg\";\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 copyToClipboard() {\r\n const element = document.createElement(\"div\");\r\n element.textContent = this.state.color.toHexString();\r\n document.body.appendChild(element);\r\n\r\n if (window.getSelection) {\r\n const range = document.createRange();\r\n range.selectNode(element);\r\n window.getSelection()!.removeAllRanges();\r\n window.getSelection()!.addRange(range);\r\n }\r\n\r\n document.execCommand(\"copy\");\r\n element.remove();\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 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=\"copy hoverIcon\" onClick={() => this.copyToClipboard()} title=\"Copy to clipboard\">\r\n <img src={copyIcon} alt=\"Copy\" />\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 {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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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"]}
@@ -46,6 +46,7 @@ export declare class FloatLineComponent extends React.Component<IFloatLineCompon
46
46
  unlock(): void;
47
47
  incrementValue(amount: number, processStep?: boolean): void;
48
48
  onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void;
49
+ onCopyClick(): void;
49
50
  render(): import("react/jsx-runtime").JSX.Element;
50
51
  }
51
52
  export {};
@@ -4,6 +4,8 @@ import { SliderLineComponent } from "./sliderLineComponent.js";
4
4
  import { Tools } from "@babylonjs/core/Misc/tools.js";
5
5
  import { conflictingValuesPlaceholder } from "./targetsProxy.js";
6
6
  import { InputArrowsComponent } from "./inputArrowsComponent.js";
7
+ import { copyCommandToClipboard, getClassNameWithNamespace } from "../copyCommandToClipboard.js";
8
+ import copyIcon from "./copy.svg";
7
9
  export class FloatLineComponent extends React.Component {
8
10
  constructor(props) {
9
11
  super(props);
@@ -138,6 +140,21 @@ export class FloatLineComponent extends React.Component {
138
140
  this.props.onEnter(this._store);
139
141
  }
140
142
  }
143
+ // Copy to clipboard the code this slider actually does
144
+ // Example : BaseParticleSystem.minScaleX = 1.0;
145
+ onCopyClick() {
146
+ if (this.props && this.props.target) {
147
+ const { className, babylonNamespace } = getClassNameWithNamespace(this.props.target);
148
+ const targetName = "globalThis.debugNode";
149
+ const targetProperty = this.props.propertyName;
150
+ const value = this.props.target[this.props.propertyName];
151
+ const strCommand = targetName + "." + targetProperty + " = " + value + ";// (debugNode as " + babylonNamespace + className + ")";
152
+ copyCommandToClipboard(strCommand);
153
+ }
154
+ else {
155
+ copyCommandToClipboard("undefined");
156
+ }
157
+ }
141
158
  render() {
142
159
  let valueAsNumber;
143
160
  if (this.props.isInteger) {
@@ -170,7 +187,7 @@ export class FloatLineComponent extends React.Component {
170
187
  this.props.onDragStop(valueAsNumber);
171
188
  }
172
189
  this.setState({ dragging: newDragging });
173
- } }))] }), this.props.unit] })), this.props.useEuler && (_jsx(SliderLineComponent, { lockObject: this.props.lockObject, label: this.props.label, minimum: 0, maximum: 360, step: 0.1, directValue: Tools.ToDegrees(valueAsNumber), onChange: (value) => this.updateValue(Tools.ToRadians(value).toString()) }))] }));
190
+ } }))] }), this.props.unit, _jsx("div", { className: "copy hoverIcon", onClick: () => this.onCopyClick(), title: "Copy to clipboard", children: _jsx("img", { src: copyIcon, alt: "Copy" }) })] })), this.props.useEuler && (_jsx(SliderLineComponent, { lockObject: this.props.lockObject, label: this.props.label, minimum: 0, maximum: 360, step: 0.1, directValue: Tools.ToDegrees(valueAsNumber), onChange: (value) => this.updateValue(Tools.ToRadians(value).toString()) }))] }));
174
191
  }
175
192
  }
176
193
  //# sourceMappingURL=floatLineComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"floatLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/floatLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,sCAAwB;AACxC,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AA4B9D,MAAM,OAAO,kBAAmB,SAAQ,KAAK,CAAC,SAAyE;IAInH,YAAY,KAA+B;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC;QAJT,iBAAY,GAAG,KAAK,CAAC;QAMzB,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAChE,IAAI,CAAC,KAAK,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QACvF,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC;IAC/B,CAAC;IAEQ,oBAAoB;QACzB,IAAI,CAAC,MAAM,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AAC,GACH,CACL,IACC,EACL,IAAI,CAAC,KAAK,CAAC,IAAI,IACd,CACT,EACA,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,CACpB,KAAC,mBAAmB,IAChB,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,OAAO,EAAE,CAAC,EACV,OAAO,EAAE,GAAG,EACZ,IAAI,EAAE,GAAG,EACT,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,EAC3C,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,GAC1E,CACL,IACF,CACN,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\n\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport type { PropertyChangedEvent } from \"../propertyChangedEvent\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\nimport { SliderLineComponent } from \"./sliderLineComponent\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { conflictingValuesPlaceholder } from \"./targetsProxy\";\r\nimport { InputArrowsComponent } from \"./inputArrowsComponent\";\r\n\r\ninterface IFloatLineComponentProps {\r\n label: string;\r\n target: any;\r\n propertyName: string;\r\n lockObject: LockObject;\r\n onChange?: (newValue: number) => void;\r\n isInteger?: boolean;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n additionalClass?: string;\r\n step?: string;\r\n digits?: number;\r\n useEuler?: boolean;\r\n min?: number;\r\n max?: number;\r\n smallUI?: boolean;\r\n onEnter?: (newValue: number) => void;\r\n icon?: string;\r\n iconLabel?: string;\r\n defaultValue?: number;\r\n arrows?: boolean;\r\n unit?: React.ReactNode;\r\n onDragStart?: (newValue: number) => void;\r\n onDragStop?: (newValue: number) => void;\r\n disabled?: boolean;\r\n}\r\n\r\nexport class FloatLineComponent extends React.Component<IFloatLineComponentProps, { value: string; dragging: boolean }> {\r\n private _localChange = false;\r\n private _store: number;\r\n\r\n constructor(props: IFloatLineComponentProps) {\r\n super(props);\r\n\r\n const currentValue = this.props.target[this.props.propertyName];\r\n this.state = { value: this.getValueString(currentValue, this.props), dragging: false };\r\n this._store = currentValue;\r\n }\r\n\r\n override componentWillUnmount() {\r\n this.unlock();\r\n }\r\n\r\n getValueString(value: any, props: IFloatLineComponentProps): string {\r\n if (value) {\r\n if (value === conflictingValuesPlaceholder) {\r\n return conflictingValuesPlaceholder;\r\n } else if (props.isInteger) {\r\n return value.toFixed(0);\r\n } else {\r\n return value.toFixed(props.digits || 4);\r\n }\r\n }\r\n return \"0\";\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IFloatLineComponentProps, nextState: { value: string; dragging: boolean }) {\r\n if (this._localChange) {\r\n this._localChange = false;\r\n return true;\r\n }\r\n\r\n const newValue = nextProps.target[nextProps.propertyName];\r\n const newValueString = this.getValueString(newValue, nextProps);\r\n\r\n if (newValueString !== nextState.value) {\r\n nextState.value = newValueString;\r\n return true;\r\n }\r\n\r\n if (nextState.dragging != this.state.dragging || nextProps.unit !== this.props.unit || nextProps.isInteger !== this.props.isInteger) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n raiseOnPropertyChanged(newValue: number, previousValue: number) {\r\n if (this.props.onChange) {\r\n this.props.onChange(newValue);\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: newValue,\r\n initialValue: previousValue,\r\n });\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 let valueAsNumber: number;\r\n\r\n if (this.props.isInteger) {\r\n valueAsNumber = parseInt(valueString);\r\n } else {\r\n valueAsNumber = parseFloat(valueString);\r\n }\r\n\r\n if (!isNaN(valueAsNumber)) {\r\n if (this.props.min !== undefined) {\r\n if (valueAsNumber < this.props.min) {\r\n valueAsNumber = this.props.min;\r\n valueString = valueAsNumber.toString();\r\n }\r\n }\r\n if (this.props.max !== undefined) {\r\n if (valueAsNumber > this.props.max) {\r\n valueAsNumber = this.props.max;\r\n valueString = valueAsNumber.toString();\r\n }\r\n }\r\n } else if (this.props.defaultValue != null) {\r\n valueAsNumber = this.props.defaultValue;\r\n }\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.target[this.props.propertyName] = valueAsNumber;\r\n this.raiseOnPropertyChanged(valueAsNumber, this._store);\r\n\r\n this._store = valueAsNumber;\r\n }\r\n\r\n lock() {\r\n if (this.props.lockObject) {\r\n this.props.lockObject.lock = true;\r\n }\r\n }\r\n\r\n unlock() {\r\n if (this.props.lockObject) {\r\n this.props.lockObject.lock = false;\r\n }\r\n }\r\n\r\n incrementValue(amount: number, processStep: boolean = true) {\r\n if (processStep && this.props.step) {\r\n amount *= parseFloat(this.props.step);\r\n }\r\n\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(2));\r\n }\r\n\r\n onKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {\r\n const step = parseFloat(this.props.step || this.props.isInteger ? \"1\" : \"0.01\");\r\n const handleArrowKey = (sign: number) => {\r\n if (event.shiftKey) {\r\n sign *= 10;\r\n if (event.ctrlKey || event.metaKey) {\r\n sign *= 10;\r\n }\r\n }\r\n\r\n this.incrementValue(sign * step, false);\r\n event.preventDefault();\r\n };\r\n\r\n if (event.key === \"ArrowUp\") {\r\n handleArrowKey(1);\r\n } else if (event.key === \"ArrowDown\") {\r\n handleArrowKey(-1);\r\n }\r\n if (event.key === \"Enter\" && this.props.onEnter) {\r\n this.props.onEnter(this._store);\r\n }\r\n }\r\n\r\n override render() {\r\n let valueAsNumber: number;\r\n\r\n if (this.props.isInteger) {\r\n valueAsNumber = parseInt(this.state.value);\r\n } else {\r\n valueAsNumber = parseFloat(this.state.value);\r\n }\r\n\r\n let className = this.props.smallUI ? \"short\" : \"value\";\r\n if (this.state.dragging) {\r\n className += \" dragging\";\r\n }\r\n if (this.props.arrows) {\r\n className += \" hasArrows\";\r\n }\r\n\r\n const value = this.state.value === conflictingValuesPlaceholder ? \"\" : this.state.value;\r\n const placeholder = this.state.value === conflictingValuesPlaceholder ? conflictingValuesPlaceholder : \"\";\r\n return (\r\n <>\r\n {!this.props.useEuler && (\r\n <div className={this.props.additionalClass ? this.props.additionalClass + \" floatLine\" : \"floatLine\"}>\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n {(!this.props.icon || this.props.label != \"\") && (\r\n <div className=\"label\" title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n )}\r\n <div className={className}>\r\n <input\r\n type={\"number\"}\r\n step={this.props.step || this.props.isInteger ? \"1\" : \"0.01\"}\r\n className=\"numeric-input\"\r\n onKeyDown={(evt) => this.onKeyDown(evt)}\r\n value={value}\r\n onBlur={() => {\r\n this.unlock();\r\n if (this.props.onEnter) {\r\n this.props.onEnter(this._store);\r\n }\r\n }}\r\n placeholder={placeholder}\r\n onFocus={() => this.lock()}\r\n onChange={(evt) => this.updateValue(evt.target.value)}\r\n disabled={this.props.disabled}\r\n />\r\n {this.props.arrows && (\r\n <InputArrowsComponent\r\n incrementValue={(amount) => this.incrementValue(amount)}\r\n setDragging={(newDragging) => {\r\n const currentDragging = this.state.dragging;\r\n // drag stopped\r\n if (!currentDragging && newDragging && this.props.onDragStart) {\r\n this.props.onDragStart(valueAsNumber);\r\n } else if (currentDragging && !newDragging && this.props.onDragStop) {\r\n this.props.onDragStop(valueAsNumber);\r\n }\r\n this.setState({ dragging: newDragging });\r\n }}\r\n />\r\n )}\r\n </div>\r\n {this.props.unit}\r\n </div>\r\n )}\r\n {this.props.useEuler && (\r\n <SliderLineComponent\r\n lockObject={this.props.lockObject}\r\n label={this.props.label}\r\n minimum={0}\r\n maximum={360}\r\n step={0.1}\r\n directValue={Tools.ToDegrees(valueAsNumber)}\r\n onChange={(value) => this.updateValue(Tools.ToRadians(value).toString())}\r\n />\r\n )}\r\n </>\r\n );\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"floatLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/floatLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,sCAAwB;AACxC,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAC9F,OAAO,QAAQ,MAAM,YAAY,CAAC;AA4BlC,MAAM,OAAO,kBAAmB,SAAQ,KAAK,CAAC,SAAyE;IAInH,YAAY,KAA+B;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC;QAJT,iBAAY,GAAG,KAAK,CAAC;QAMzB,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAChE,IAAI,CAAC,KAAK,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QACvF,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC;IAC/B,CAAC;IAEQ,oBAAoB;QACzB,IAAI,CAAC,MAAM,EAAE,CAAC;IAClB,CAAC;IAED,c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WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,GAC1E,CACL,IACF,CACN,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 type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\nimport { SliderLineComponent } from \"./sliderLineComponent\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { conflictingValuesPlaceholder } from \"./targetsProxy\";\r\nimport { InputArrowsComponent } from \"./inputArrowsComponent\";\r\nimport { copyCommandToClipboard, getClassNameWithNamespace } from \"../copyCommandToClipboard\";\r\nimport copyIcon from \"./copy.svg\";\r\n\r\ninterface IFloatLineComponentProps {\r\n label: string;\r\n target: any;\r\n propertyName: string;\r\n lockObject: LockObject;\r\n onChange?: (newValue: number) => void;\r\n isInteger?: boolean;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n additionalClass?: string;\r\n step?: string;\r\n digits?: number;\r\n useEuler?: boolean;\r\n min?: number;\r\n max?: number;\r\n smallUI?: boolean;\r\n onEnter?: (newValue: number) => void;\r\n icon?: string;\r\n iconLabel?: string;\r\n defaultValue?: number;\r\n arrows?: boolean;\r\n unit?: React.ReactNode;\r\n onDragStart?: (newValue: number) => void;\r\n onDragStop?: (newValue: number) => void;\r\n disabled?: boolean;\r\n}\r\n\r\nexport class FloatLineComponent extends React.Component<IFloatLineComponentProps, { value: string; dragging: boolean }> {\r\n private _localChange = false;\r\n private _store: number;\r\n\r\n constructor(props: IFloatLineComponentProps) {\r\n super(props);\r\n\r\n const currentValue = this.props.target[this.props.propertyName];\r\n this.state = { value: this.getValueString(currentValue, this.props), dragging: false };\r\n this._store = currentValue;\r\n }\r\n\r\n override componentWillUnmount() {\r\n this.unlock();\r\n }\r\n\r\n getValueString(value: any, props: IFloatLineComponentProps): string {\r\n if (value) {\r\n if (value === conflictingValuesPlaceholder) {\r\n return conflictingValuesPlaceholder;\r\n } else if (props.isInteger) {\r\n return value.toFixed(0);\r\n } else {\r\n return value.toFixed(props.digits || 4);\r\n }\r\n }\r\n return \"0\";\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IFloatLineComponentProps, nextState: { value: string; dragging: boolean }) {\r\n if (this._localChange) {\r\n this._localChange = false;\r\n return true;\r\n }\r\n\r\n const newValue = nextProps.target[nextProps.propertyName];\r\n const newValueString = this.getValueString(newValue, nextProps);\r\n\r\n if (newValueString !== nextState.value) {\r\n nextState.value = newValueString;\r\n return true;\r\n }\r\n\r\n if (nextState.dragging != this.state.dragging || nextProps.unit !== this.props.unit || nextProps.isInteger !== this.props.isInteger) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n raiseOnPropertyChanged(newValue: number, previousValue: number) {\r\n if (this.props.onChange) {\r\n this.props.onChange(newValue);\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: newValue,\r\n initialValue: previousValue,\r\n });\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 let valueAsNumber: number;\r\n\r\n if (this.props.isInteger) {\r\n valueAsNumber = parseInt(valueString);\r\n } else {\r\n valueAsNumber = parseFloat(valueString);\r\n }\r\n\r\n if (!isNaN(valueAsNumber)) {\r\n if (this.props.min !== undefined) {\r\n if (valueAsNumber < this.props.min) {\r\n valueAsNumber = this.props.min;\r\n valueString = valueAsNumber.toString();\r\n }\r\n }\r\n if (this.props.max !== undefined) {\r\n if (valueAsNumber > this.props.max) {\r\n valueAsNumber = this.props.max;\r\n valueString = valueAsNumber.toString();\r\n }\r\n }\r\n } else if (this.props.defaultValue != null) {\r\n valueAsNumber = this.props.defaultValue;\r\n }\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.target[this.props.propertyName] = valueAsNumber;\r\n this.raiseOnPropertyChanged(valueAsNumber, this._store);\r\n\r\n this._store = valueAsNumber;\r\n }\r\n\r\n lock() {\r\n if (this.props.lockObject) {\r\n this.props.lockObject.lock = true;\r\n }\r\n }\r\n\r\n unlock() {\r\n if (this.props.lockObject) {\r\n this.props.lockObject.lock = false;\r\n }\r\n }\r\n\r\n incrementValue(amount: number, processStep: boolean = true) {\r\n if (processStep && this.props.step) {\r\n amount *= parseFloat(this.props.step);\r\n }\r\n\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(2));\r\n }\r\n\r\n onKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {\r\n const step = parseFloat(this.props.step || this.props.isInteger ? \"1\" : \"0.01\");\r\n const handleArrowKey = (sign: number) => {\r\n if (event.shiftKey) {\r\n sign *= 10;\r\n if (event.ctrlKey || event.metaKey) {\r\n sign *= 10;\r\n }\r\n }\r\n\r\n this.incrementValue(sign * step, false);\r\n event.preventDefault();\r\n };\r\n\r\n if (event.key === \"ArrowUp\") {\r\n handleArrowKey(1);\r\n } else if (event.key === \"ArrowDown\") {\r\n handleArrowKey(-1);\r\n }\r\n if (event.key === \"Enter\" && this.props.onEnter) {\r\n this.props.onEnter(this._store);\r\n }\r\n }\r\n\r\n // Copy to clipboard the code this slider actually does\r\n // Example : BaseParticleSystem.minScaleX = 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 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 let valueAsNumber: number;\r\n\r\n if (this.props.isInteger) {\r\n valueAsNumber = parseInt(this.state.value);\r\n } else {\r\n valueAsNumber = parseFloat(this.state.value);\r\n }\r\n\r\n let className = this.props.smallUI ? \"short\" : \"value\";\r\n if (this.state.dragging) {\r\n className += \" dragging\";\r\n }\r\n if (this.props.arrows) {\r\n className += \" hasArrows\";\r\n }\r\n\r\n const value = this.state.value === conflictingValuesPlaceholder ? \"\" : this.state.value;\r\n const placeholder = this.state.value === conflictingValuesPlaceholder ? conflictingValuesPlaceholder : \"\";\r\n return (\r\n <>\r\n {!this.props.useEuler && (\r\n <div className={this.props.additionalClass ? this.props.additionalClass + \" floatLine\" : \"floatLine\"}>\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n {(!this.props.icon || this.props.label != \"\") && (\r\n <div className=\"label\" title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n )}\r\n <div className={className}>\r\n <input\r\n type={\"number\"}\r\n step={this.props.step || this.props.isInteger ? \"1\" : \"0.01\"}\r\n className=\"numeric-input\"\r\n onKeyDown={(evt) => this.onKeyDown(evt)}\r\n value={value}\r\n onBlur={() => {\r\n this.unlock();\r\n if (this.props.onEnter) {\r\n this.props.onEnter(this._store);\r\n }\r\n }}\r\n placeholder={placeholder}\r\n onFocus={() => this.lock()}\r\n onChange={(evt) => this.updateValue(evt.target.value)}\r\n disabled={this.props.disabled}\r\n />\r\n {this.props.arrows && (\r\n <InputArrowsComponent\r\n incrementValue={(amount) => this.incrementValue(amount)}\r\n setDragging={(newDragging) => {\r\n const currentDragging = this.state.dragging;\r\n // drag stopped\r\n if (!currentDragging && newDragging && this.props.onDragStart) {\r\n this.props.onDragStart(valueAsNumber);\r\n } else if (currentDragging && !newDragging && this.props.onDragStop) {\r\n this.props.onDragStop(valueAsNumber);\r\n }\r\n this.setState({ dragging: newDragging });\r\n }}\r\n />\r\n )}\r\n </div>\r\n {this.props.unit}\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 {this.props.useEuler && (\r\n <SliderLineComponent\r\n lockObject={this.props.lockObject}\r\n label={this.props.label}\r\n minimum={0}\r\n maximum={360}\r\n step={0.1}\r\n directValue={Tools.ToDegrees(valueAsNumber)}\r\n onChange={(value) => this.updateValue(Tools.ToRadians(value).toString())}\r\n />\r\n )}\r\n </>\r\n );\r\n }\r\n}\r\n"]}
@@ -33,5 +33,6 @@ export declare class OptionsLineComponent extends React.Component<IOptionsLineCo
33
33
  raiseOnPropertyChanged(newValue: number, previousValue: number): void;
34
34
  setValue(value: string | number): void;
35
35
  updateValue(valueString: string): void;
36
+ onCopyClick(): void;
36
37
  render(): import("react/jsx-runtime").JSX.Element;
37
38
  }
@@ -1,5 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
+ import { copyCommandToClipboard, getClassNameWithNamespace } from "../copyCommandToClipboard.js";
4
+ import copyIcon from "./copy.svg";
3
5
  // eslint-disable-next-line @typescript-eslint/naming-convention
4
6
  export const Null_Value = Number.MAX_SAFE_INTEGER;
5
7
  export class OptionsLineComponent extends React.Component {
@@ -61,10 +63,25 @@ export class OptionsLineComponent extends React.Component {
61
63
  const newValue = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];
62
64
  this.raiseOnPropertyChanged(newValue, store);
63
65
  }
66
+ // Copy to clipboard the code this option actually does
67
+ // Example : material.sideOrientation = 1;
68
+ onCopyClick() {
69
+ if (this.props && this.props.target) {
70
+ const { className, babylonNamespace } = getClassNameWithNamespace(this.props.target);
71
+ const targetName = "globalThis.debugNode";
72
+ const targetProperty = this.props.propertyName;
73
+ const value = this.props.target[this.props.propertyName];
74
+ const strCommand = targetName + "." + targetProperty + " = " + value + ";// (debugNode as " + babylonNamespace + className + ")";
75
+ copyCommandToClipboard(strCommand);
76
+ }
77
+ else {
78
+ copyCommandToClipboard("undefined");
79
+ }
80
+ }
64
81
  render() {
65
82
  return (_jsxs("div", { className: "listLine" + (this.props.className ? " " + this.props.className : ""), children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, color: "black", className: "icon" }), _jsx("div", { className: "label", title: this.props.label, children: this.props.label }), _jsx("div", { className: "options", children: _jsx("select", { onChange: (evt) => this.updateValue(evt.target.value), value: this.state.value ?? "", children: this.props.options.map((option, i) => {
66
83
  return (_jsx("option", { selected: option.selected, value: option.value, title: option.label, children: option.label }, option.label + i));
67
- }) }) })] }));
84
+ }) }) }), _jsx("div", { className: "copy hoverIcon", onClick: () => this.onCopyClick(), title: "Copy to clipboard", children: _jsx("img", { src: copyIcon, alt: "Copy" }) })] }));
68
85
  }
69
86
  }
70
87
  //# sourceMappingURL=optionsLineComponent.js.map
@@ -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;AAK/B,gEAAgE;AAChE,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAmBlD,MAAM,OAAO,oBAAqB,SAAQ,KAAK,CAAC,SAAiE;IAGrG,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,CAAC,cAAc,IAAI,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IA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AyB,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,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 type { IInspectableOptions } from \"core/Misc/iInspectable\";\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 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>\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,oBAAqB,SAAQ,KAAK,CAAC,SAAiE;IAGrG,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,CAAC,cAAc,IAAI,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5E,CAAC;IAEO,SAAS,CAAC,KAAiC;QAC/C,IAAI,KAAK,CAAC,YAAY,EAAE;YACpB,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SAC3C;QACD,OAAO,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,CAAC,CAAC;IAC3H,CAAC;IAED,YAAY,KAAiC;QACzC,KAAK,CAAC,KAAK,CAAC,CAAC;QAlBT,iBAAY,GAAG,KAAK,CAAC;QAoBzB,IAAI,CAAC,KAAK,GAAG,EAAE,KAAK,EAAE,I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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 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"]}
@@ -32,6 +32,7 @@ export declare class SliderLineComponent extends React.Component<ISliderLineComp
32
32
  onChange(newValueString: any): void;
33
33
  onInput(newValueString: any): void;
34
34
  prepareDataToRead(value: number): number;
35
+ onCopyClick(): void;
35
36
  render(): import("react/jsx-runtime").JSX.Element;
36
37
  }
37
38
  export {};
@@ -1,7 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
+ import { copyCommandToClipboard, getClassNameWithNamespace } from "../copyCommandToClipboard.js";
3
4
  import { Tools } from "@babylonjs/core/Misc/tools.js";
4
5
  import { FloatLineComponent } from "./floatLineComponent.js";
6
+ import copyIcon from "./copy.svg";
5
7
  export class SliderLineComponent extends React.Component {
6
8
  constructor(props) {
7
9
  super(props);
@@ -80,6 +82,21 @@ export class SliderLineComponent extends React.Component {
80
82
  }
81
83
  return value;
82
84
  }
85
+ // Copy to clipboard the code this slider actually does
86
+ // Example : ImageProcessingConfiguration.contrast = 1;
87
+ onCopyClick() {
88
+ if (this.props && this.props.target) {
89
+ const { className, babylonNamespace } = getClassNameWithNamespace(this.props.target);
90
+ const targetName = "globalThis.debugNode";
91
+ const targetProperty = this.props.propertyName;
92
+ const value = this.props.target[this.props.propertyName];
93
+ const strCommand = targetName + "." + targetProperty + " = " + value + ";// (debugNode as " + babylonNamespace + className + ")";
94
+ copyCommandToClipboard(strCommand);
95
+ }
96
+ else {
97
+ copyCommandToClipboard("undefined");
98
+ }
99
+ }
83
100
  render() {
84
101
  return (_jsxs("div", { className: "sliderLine", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), (!this.props.icon || this.props.label != "") && (_jsx("div", { className: this.props.margin ? "label withMargins" : "label", title: this.props.label, children: this.props.label })), _jsx(FloatLineComponent, { lockObject: this.props.lockObject, isInteger: this.props.decimalCount === 0, smallUI: true, label: "", target: this.state, digits: this.props.decimalCount === undefined ? 4 : this.props.decimalCount, propertyName: "value", min: this.props.minimum, max: this.props.maximum, onEnter: () => {
85
102
  const changed = this.prepareDataToRead(this.state.value);
@@ -87,7 +104,7 @@ export class SliderLineComponent extends React.Component {
87
104
  }, onChange: () => {
88
105
  const changed = this.prepareDataToRead(this.state.value);
89
106
  this.onChange(changed);
90
- }, onPropertyChangedObservable: this.props.onPropertyChangedObservable, unit: this.props.unit }), _jsx("div", { className: "slider", children: _jsx("input", { className: "range", type: "range", step: this.props.step, min: this.prepareDataToRead(this.props.minimum), max: this.prepareDataToRead(this.props.maximum), value: this.prepareDataToRead(this.state.value), onInput: (evt) => this.onInput(evt.target.value), onChange: (evt) => this.onChange(evt.target.value) }) })] }));
107
+ }, onPropertyChangedObservable: this.props.onPropertyChangedObservable, unit: this.props.unit }), _jsx("div", { className: "slider", children: _jsx("input", { className: "range", type: "range", step: this.props.step, min: this.prepareDataToRead(this.props.minimum), max: this.prepareDataToRead(this.props.maximum), value: this.prepareDataToRead(this.state.value), onInput: (evt) => this.onInput(evt.target.value), onChange: (evt) => this.onChange(evt.target.value) }) }), _jsx("div", { className: "copy hoverIcon", onClick: () => this.onCopyClick(), title: "Copy to clipboard", children: _jsx("img", { src: copyIcon, alt: "Copy" }) })] }));
91
108
  }
92
109
  }
93
110
  //# sourceMappingURL=sliderLineComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sliderLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/sliderLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,KAAK,EAAE,sCAAwB;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAuB1D,MAAM,OAAO,mBAAoB,SAAQ,KAAK,CAAC,SAAuD;IAElG,YAAY,KAAgC;QACxC,KAAK,CAAC,KAAK,CAAC,CAAC;QAFT,iBAAY,GAAG,KAAK,CAAC;QAIzB,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,KAAK,SAAS,EAAE;YACtC,IAAI,CAAC,KAAK,GAAG;gBACT,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW;aAChC,CAAC;SACL;aAAM;YACH,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAO,CAAC,IAAI,CAAC,KAAK,CAAC,YAAa,CAAC,CAAC;YAEzD,IAAI,KAAK,KAAK,SAAS,EAAE;gBACrB,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,O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,CAAC,KAAK,CAAC,CAAC;wBACzD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;oBAC3B,CAAC,EACD,2BAA2B,EAAE,IAAI,CAAC,KAAK,CAAC,2BAA2B,EACnE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GACvB,EACF,cAAK,SAAS,EAAC,QAAQ,YACnB,gBACI,SAAS,EAAC,OAAO,EACjB,IAAI,EAAC,OAAO,EACZ,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EACrB,GAAG,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAC/C,GAAG,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAC/C,KAAK,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAC/C,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAE,GAAG,CAAC,MAA2B,CAAC,KAAK,CAAC,EACtE,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GACpD,GACA,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 { Tools } from \"core/Misc/tools\";\r\nimport { FloatLineComponent } from \"./floatLineComponent\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\n\r\ninterface ISliderLineComponentProps {\r\n label: string;\r\n target?: any;\r\n propertyName?: string;\r\n minimum: number;\r\n maximum: number;\r\n step: number;\r\n directValue?: number;\r\n useEuler?: boolean;\r\n onChange?: (value: number) => void;\r\n onInput?: (value: number) => void;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n decimalCount?: number;\r\n margin?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n lockObject: LockObject;\r\n unit?: React.ReactNode;\r\n}\r\n\r\nexport class SliderLineComponent extends React.Component<ISliderLineComponentProps, { value: number }> {\r\n private _localChange = false;\r\n constructor(props: ISliderLineComponentProps) {\r\n super(props);\r\n\r\n if (this.props.directValue !== undefined) {\r\n this.state = {\r\n value: this.props.directValue,\r\n };\r\n } else {\r\n let value = this.props.target![this.props.propertyName!];\r\n\r\n if (value === undefined) {\r\n value = this.props.maximum;\r\n }\r\n this.state = { value: value };\r\n }\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: ISliderLineComponentProps, nextState: { value: number }) {\r\n if (nextProps.directValue !== undefined) {\r\n nextState.value = nextProps.directValue;\r\n return true;\r\n }\r\n\r\n if (nextProps.label !== this.props.label) {\r\n return true;\r\n }\r\n\r\n let currentState = nextProps.target![nextProps.propertyName!];\r\n if (currentState === undefined) {\r\n currentState = nextProps.maximum;\r\n }\r\n\r\n if (currentState !== nextState.value || this._localChange || nextProps.maximum !== this.props.maximum || nextProps.minimum !== this.props.minimum) {\r\n nextState.value = currentState;\r\n this._localChange = false;\r\n return true;\r\n }\r\n\r\n if (nextProps.unit !== this.props.unit) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n onChange(newValueString: any) {\r\n if (newValueString === \"—\") return;\r\n this._localChange = true;\r\n let newValue = parseFloat(newValueString);\r\n\r\n if (this.props.useEuler) {\r\n newValue = Tools.ToRadians(newValue);\r\n }\r\n\r\n if (this.props.target) {\r\n if (this.props.onPropertyChangedObservable) {\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: this.state.value,\r\n });\r\n }\r\n\r\n this.props.target[this.props.propertyName!] = newValue;\r\n }\r\n\r\n if (this.props.onChange) {\r\n this.props.onChange(newValue);\r\n }\r\n\r\n this.setState({ value: newValue });\r\n }\r\n\r\n onInput(newValueString: any) {\r\n const newValue = parseFloat(newValueString);\r\n if (this.props.onInput) {\r\n this.props.onInput(newValue);\r\n }\r\n }\r\n\r\n prepareDataToRead(value: number) {\r\n if (value === null) {\r\n value = 0;\r\n }\r\n\r\n if (this.props.useEuler) {\r\n return Tools.ToDegrees(value);\r\n }\r\n\r\n return value;\r\n }\r\n\r\n override render() {\r\n return (\r\n <div className=\"sliderLine\">\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n {(!this.props.icon || this.props.label != \"\") && (\r\n <div className={this.props.margin ? \"label withMargins\" : \"label\"} title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n )}\r\n <FloatLineComponent\r\n lockObject={this.props.lockObject}\r\n isInteger={this.props.decimalCount === 0}\r\n smallUI={true}\r\n label=\"\"\r\n target={this.state}\r\n digits={this.props.decimalCount === undefined ? 4 : this.props.decimalCount}\r\n propertyName=\"value\"\r\n min={this.props.minimum}\r\n max={this.props.maximum}\r\n onEnter={() => {\r\n const changed = this.prepareDataToRead(this.state.value);\r\n this.onChange(changed);\r\n }}\r\n onChange={() => {\r\n const changed = this.prepareDataToRead(this.state.value);\r\n this.onChange(changed);\r\n }}\r\n onPropertyChangedObservable={this.props.onPropertyChangedObservable}\r\n unit={this.props.unit}\r\n />\r\n <div className=\"slider\">\r\n <input\r\n className=\"range\"\r\n type=\"range\"\r\n step={this.props.step}\r\n min={this.prepareDataToRead(this.props.minimum)}\r\n max={this.prepareDataToRead(this.props.maximum)}\r\n value={this.prepareDataToRead(this.state.value)}\r\n onInput={(evt) => this.onInput((evt.target as HTMLInputElement).value)}\r\n onChange={(evt) => this.onChange(evt.target.value)}\r\n />\r\n </div>\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"sliderLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/sliderLineComponent.tsx"],"names":[],"mappings":";AAAA,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\r\nimport type { PropertyChangedEvent } from \"../propertyChangedEvent\";\r\nimport { copyCommandToClipboard, getClassNameWithNamespace } from \"../copyCommandToClipboard\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { FloatLineComponent } from \"./floatLineComponent\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\nimport copyIcon from \"./copy.svg\";\r\n\r\ninterface ISliderLineComponentProps {\r\n label: string;\r\n target?: any;\r\n propertyName?: string;\r\n minimum: number;\r\n maximum: number;\r\n step: number;\r\n directValue?: number;\r\n useEuler?: boolean;\r\n onChange?: (value: number) => void;\r\n onInput?: (value: number) => void;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n decimalCount?: number;\r\n margin?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n lockObject: LockObject;\r\n unit?: React.ReactNode;\r\n}\r\n\r\nexport class SliderLineComponent extends React.Component<ISliderLineComponentProps, { value: number }> {\r\n private _localChange = false;\r\n constructor(props: ISliderLineComponentProps) {\r\n super(props);\r\n\r\n if (this.props.directValue !== undefined) {\r\n this.state = {\r\n value: this.props.directValue,\r\n };\r\n } else {\r\n let value = this.props.target![this.props.propertyName!];\r\n\r\n if (value === undefined) {\r\n value = this.props.maximum;\r\n }\r\n this.state = { value: value };\r\n }\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: ISliderLineComponentProps, nextState: { value: number }) {\r\n if (nextProps.directValue !== undefined) {\r\n nextState.value = nextProps.directValue;\r\n return true;\r\n }\r\n\r\n if (nextProps.label !== this.props.label) {\r\n return true;\r\n }\r\n\r\n let currentState = nextProps.target![nextProps.propertyName!];\r\n if (currentState === undefined) {\r\n currentState = nextProps.maximum;\r\n }\r\n\r\n if (currentState !== nextState.value || this._localChange || nextProps.maximum !== this.props.maximum || nextProps.minimum !== this.props.minimum) {\r\n nextState.value = currentState;\r\n this._localChange = false;\r\n return true;\r\n }\r\n\r\n if (nextProps.unit !== this.props.unit) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n onChange(newValueString: any) {\r\n if (newValueString === \"—\") return;\r\n this._localChange = true;\r\n let newValue = parseFloat(newValueString);\r\n\r\n if (this.props.useEuler) {\r\n newValue = Tools.ToRadians(newValue);\r\n }\r\n\r\n if (this.props.target) {\r\n if (this.props.onPropertyChangedObservable) {\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: this.state.value,\r\n });\r\n }\r\n\r\n this.props.target[this.props.propertyName!] = newValue;\r\n }\r\n\r\n if (this.props.onChange) {\r\n this.props.onChange(newValue);\r\n }\r\n\r\n this.setState({ value: newValue });\r\n }\r\n\r\n onInput(newValueString: any) {\r\n const newValue = parseFloat(newValueString);\r\n if (this.props.onInput) {\r\n this.props.onInput(newValue);\r\n }\r\n }\r\n\r\n prepareDataToRead(value: number) {\r\n if (value === null) {\r\n value = 0;\r\n }\r\n\r\n if (this.props.useEuler) {\r\n return Tools.ToDegrees(value);\r\n }\r\n\r\n return value;\r\n }\r\n\r\n // Copy to clipboard the code this slider actually does\r\n // Example : ImageProcessingConfiguration.contrast = 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=\"sliderLine\">\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n {(!this.props.icon || this.props.label != \"\") && (\r\n <div className={this.props.margin ? \"label withMargins\" : \"label\"} title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n )}\r\n <FloatLineComponent\r\n lockObject={this.props.lockObject}\r\n isInteger={this.props.decimalCount === 0}\r\n smallUI={true}\r\n label=\"\"\r\n target={this.state}\r\n digits={this.props.decimalCount === undefined ? 4 : this.props.decimalCount}\r\n propertyName=\"value\"\r\n min={this.props.minimum}\r\n max={this.props.maximum}\r\n onEnter={() => {\r\n const changed = this.prepareDataToRead(this.state.value);\r\n this.onChange(changed);\r\n }}\r\n onChange={() => {\r\n const changed = this.prepareDataToRead(this.state.value);\r\n this.onChange(changed);\r\n }}\r\n onPropertyChangedObservable={this.props.onPropertyChangedObservable}\r\n unit={this.props.unit}\r\n />\r\n <div className=\"slider\">\r\n <input\r\n className=\"range\"\r\n type=\"range\"\r\n step={this.props.step}\r\n min={this.prepareDataToRead(this.props.minimum)}\r\n max={this.prepareDataToRead(this.props.maximum)}\r\n value={this.prepareDataToRead(this.state.value)}\r\n onInput={(evt) => this.onInput((evt.target as HTMLInputElement).value)}\r\n onChange={(evt) => this.onChange(evt.target.value)}\r\n />\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"]}
@@ -36,6 +36,7 @@ export declare class Vector3LineComponent extends React.Component<IVector3LineCo
36
36
  updateStateX(value: number): void;
37
37
  updateStateY(value: number): void;
38
38
  updateStateZ(value: number): void;
39
+ onCopyClick(): void;
39
40
  render(): import("react/jsx-runtime").JSX.Element;
40
41
  }
41
42
  export {};
@@ -4,8 +4,10 @@ import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
4
4
  import { NumericInputComponent } from "../lines/numericInputComponent.js";
5
5
  import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
6
6
  import { faMinus, faPlus } from "@fortawesome/free-solid-svg-icons";
7
+ import { copyCommandToClipboard, getClassNameWithNamespace } from "../copyCommandToClipboard.js";
7
8
  import { SliderLineComponent } from "../lines/sliderLineComponent.js";
8
9
  import { Tools } from "@babylonjs/core/Misc/tools.js";
10
+ import copyIcon from "./copy.svg";
9
11
  export class Vector3LineComponent extends React.Component {
10
12
  constructor(props) {
11
13
  super(props);
@@ -64,10 +66,26 @@ export class Vector3LineComponent extends React.Component {
64
66
  this.state.value.z = value;
65
67
  this.updateVector3();
66
68
  }
69
+ // Copy to clipboard the code this Vector3 actually does
70
+ // Example : Mesh.position = new BABYLON.Vector3(0, 1, 0);
71
+ onCopyClick() {
72
+ if (this.props && this.props.target) {
73
+ const { className, babylonNamespace } = getClassNameWithNamespace(this.props.target);
74
+ const targetName = "globalThis.debugNode";
75
+ const targetProperty = this.props.propertyName;
76
+ const value = this.props.target[this.props.propertyName];
77
+ const strVector = "new " + babylonNamespace + "Vector3(" + value.x + ", " + value.y + ", " + value.z + ")";
78
+ const strCommand = targetName + "." + targetProperty + " = " + strVector + ";// (debugNode as " + babylonNamespace + className + ")";
79
+ copyCommandToClipboard(strCommand);
80
+ }
81
+ else {
82
+ copyCommandToClipboard("undefined");
83
+ }
84
+ }
67
85
  render() {
68
86
  const chevron = this.state.isExpanded ? _jsx(FontAwesomeIcon, { icon: faMinus }) : _jsx(FontAwesomeIcon, { icon: faPlus });
69
87
  return (_jsxs("div", { className: "vector3Line", children: [_jsxs("div", { className: "firstLine", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), _jsx("div", { className: "label", title: this.props.label, children: this.props.label }), _jsxs("div", { className: "vector", children: [!this.props.useEuler && `X: ${this.state.value.x.toFixed(2)}, Y: ${this.state.value.y.toFixed(2)}, Z: ${this.state.value.z.toFixed(2)}`, this.props.useEuler &&
70
- `X: ${Tools.ToDegrees(this.state.value.x).toFixed(2)}, Y: ${Tools.ToDegrees(this.state.value.y).toFixed(2)}, Z: ${Tools.ToDegrees(this.state.value.z).toFixed(2)}`] }), _jsx("div", { className: "expand hoverIcon", onClick: () => this.switchExpandState(), title: "Expand", children: chevron })] }), this.state.isExpanded && !this.props.useEuler && (_jsxs("div", { className: "secondLine", children: [_jsx(NumericInputComponent, { label: "x", lockObject: this.props.lockObject, step: this.props.step, value: this.state.value.x, onChange: (value) => this.updateStateX(value) }), _jsx(NumericInputComponent, { label: "y", lockObject: this.props.lockObject, step: this.props.step, value: this.state.value.y, onChange: (value) => this.updateStateY(value) }), _jsx(NumericInputComponent, { label: "z", lockObject: this.props.lockObject, step: this.props.step, value: this.state.value.z, onChange: (value) => this.updateStateZ(value) })] })), this.state.isExpanded && this.props.useEuler && !this.props.noSlider && (_jsxs("div", { className: "secondLine", children: [_jsx(SliderLineComponent, { lockObject: this.props.lockObject, margin: true, label: "x", minimum: 0, maximum: 360, step: 0.1, directValue: Tools.ToDegrees(this.state.value.x), onChange: (value) => this.updateStateX(Tools.ToRadians(value)) }), _jsx(SliderLineComponent, { lockObject: this.props.lockObject, margin: true, label: "y", minimum: 0, maximum: 360, step: 0.1, directValue: Tools.ToDegrees(this.state.value.y), onChange: (value) => this.updateStateY(Tools.ToRadians(value)) }), _jsx(SliderLineComponent, { lockObject: this.props.lockObject, margin: true, label: "z", minimum: 0, maximum: 360, step: 0.1, directValue: Tools.ToDegrees(this.state.value.z), onChange: (value) => this.updateStateZ(Tools.ToRadians(value)) })] })), this.state.isExpanded && this.props.useEuler && this.props.noSlider && (_jsxs("div", { className: "secondLine", children: [_jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "x", step: this.props.step, value: Tools.ToDegrees(this.state.value.x), onChange: (value) => this.updateStateX(Tools.ToRadians(value)) }), _jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "y", step: this.props.step, value: Tools.ToDegrees(this.state.value.y), onChange: (value) => this.updateStateY(Tools.ToRadians(value)) }), _jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "z", step: this.props.step, value: Tools.ToDegrees(this.state.value.z), onChange: (value) => this.updateStateZ(Tools.ToRadians(value)) })] }))] }));
88
+ `X: ${Tools.ToDegrees(this.state.value.x).toFixed(2)}, Y: ${Tools.ToDegrees(this.state.value.y).toFixed(2)}, Z: ${Tools.ToDegrees(this.state.value.z).toFixed(2)}`] }), _jsx("div", { className: "expand hoverIcon", onClick: () => this.switchExpandState(), title: "Expand", children: chevron }), _jsx("div", { className: "copy hoverIcon", onClick: () => this.onCopyClick(), title: "Copy to clipboard", children: _jsx("img", { src: copyIcon, alt: "Copy" }) })] }), this.state.isExpanded && !this.props.useEuler && (_jsxs("div", { className: "secondLine", children: [_jsx(NumericInputComponent, { label: "x", lockObject: this.props.lockObject, step: this.props.step, value: this.state.value.x, onChange: (value) => this.updateStateX(value) }), _jsx(NumericInputComponent, { label: "y", lockObject: this.props.lockObject, step: this.props.step, value: this.state.value.y, onChange: (value) => this.updateStateY(value) }), _jsx(NumericInputComponent, { label: "z", lockObject: this.props.lockObject, step: this.props.step, value: this.state.value.z, onChange: (value) => this.updateStateZ(value) })] })), this.state.isExpanded && this.props.useEuler && !this.props.noSlider && (_jsxs("div", { className: "secondLine", children: [_jsx(SliderLineComponent, { lockObject: this.props.lockObject, margin: true, label: "x", minimum: 0, maximum: 360, step: 0.1, directValue: Tools.ToDegrees(this.state.value.x), onChange: (value) => this.updateStateX(Tools.ToRadians(value)) }), _jsx(SliderLineComponent, { lockObject: this.props.lockObject, margin: true, label: "y", minimum: 0, maximum: 360, step: 0.1, directValue: Tools.ToDegrees(this.state.value.y), onChange: (value) => this.updateStateY(Tools.ToRadians(value)) }), _jsx(SliderLineComponent, { lockObject: this.props.lockObject, margin: true, label: "z", minimum: 0, maximum: 360, step: 0.1, directValue: Tools.ToDegrees(this.state.value.z), onChange: (value) => this.updateStateZ(Tools.ToRadians(value)) })] })), this.state.isExpanded && this.props.useEuler && this.props.noSlider && (_jsxs("div", { className: "secondLine", children: [_jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "x", step: this.props.step, value: Tools.ToDegrees(this.state.value.x), onChange: (value) => this.updateStateX(Tools.ToRadians(value)) }), _jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "y", step: this.props.step, value: Tools.ToDegrees(this.state.value.y), onChange: (value) => this.updateStateY(Tools.ToRadians(value)) }), _jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "z", step: this.props.step, value: Tools.ToDegrees(this.state.value.z), onChange: (value) => this.updateStateZ(Tools.ToRadians(value)) })] }))] }));
71
89
  }
72
90
  }
73
91
  // eslint-disable-next-line @typescript-eslint/naming-convention
@@ -1 +1 @@
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;AAGjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAEpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAiBxC,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,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;IACtF,CAAC;IAED,eAAe;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACtD,CAAC;IA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AC1C,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,GAChE,EACF,KAAC,qBAAqB,IAClB,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,EACF,KAAC,qBAAqB,IAClB,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;;AA3LD,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\n\r\nimport { NumericInputComponent } 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 { SliderLineComponent } from \"../lines/sliderLineComponent\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\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 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>\r\n {this.state.isExpanded && !this.props.useEuler && (\r\n <div className=\"secondLine\">\r\n <NumericInputComponent\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 <NumericInputComponent\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 <NumericInputComponent\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 <NumericInputComponent\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 <NumericInputComponent\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 <NumericInputComponent\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,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,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,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;IACtF,CAAC;IAED,eAAe;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACtD,CAAC;IAEQ,qBAAqB,CAAC,SAAqC,EAAE,SAAkD;QACpH,MAAM,cAAc,GAAG,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QAEhE,IAAI,CAAC,cA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C,EAC1C,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,GAChE,EACF,KAAC,qBAAqB,IAClB,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 { NumericInputComponent } 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 <NumericInputComponent\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 <NumericInputComponent\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 <NumericInputComponent\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 <NumericInputComponent\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 <NumericInputComponent\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 <NumericInputComponent\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs/shared-ui-components",
3
- "version": "7.4.0",
3
+ "version": "7.6.0",
4
4
  "main": "index.js",
5
5
  "module": "index.js",
6
6
  "types": "index.d.ts",