commonLightPropertyGridComponent.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import * as React from "react";
  2. import { Observable } from "babylonjs/Misc/observable";
  3. import { Light } from "babylonjs/Lights/light";
  4. import { PropertyChangedEvent } from "../../../../propertyChangedEvent";
  5. import { LineContainerComponent } from "../../../lineContainerComponent";
  6. import { FloatLineComponent } from "../../../lines/floatLineComponent";
  7. import { TextLineComponent } from "../../../lines/textLineComponent";
  8. import { LockObject } from "../lockObject";
  9. import { GlobalState } from '../../../../globalState';
  10. import { CustomPropertyGridComponent } from '../customPropertyGridComponent';
  11. import { ButtonLineComponent } from '../../../lines/buttonLineComponent';
  12. import { TextInputLineComponent } from '../../../lines/textInputLineComponent';
  13. interface ICommonLightPropertyGridComponentProps {
  14. globalState: GlobalState,
  15. light: Light,
  16. lockObject: LockObject,
  17. onPropertyChangedObservable?: Observable<PropertyChangedEvent>
  18. }
  19. export class CommonLightPropertyGridComponent extends React.Component<ICommonLightPropertyGridComponentProps> {
  20. constructor(props: ICommonLightPropertyGridComponentProps) {
  21. super(props);
  22. }
  23. render() {
  24. const light = this.props.light;
  25. return (
  26. <div>
  27. <CustomPropertyGridComponent globalState={this.props.globalState} target={light}
  28. lockObject={this.props.lockObject}
  29. onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
  30. <LineContainerComponent globalState={this.props.globalState} title="GENERAL">
  31. <TextLineComponent label="ID" value={light.id} />
  32. <TextInputLineComponent lockObject={this.props.lockObject} label="Name" target={light} propertyName="name" onPropertyChangedObservable={this.props.onPropertyChangedObservable}/>
  33. <TextLineComponent label="Unique ID" value={light.uniqueId.toString()} />
  34. <TextLineComponent label="Class" value={light.getClassName()} />
  35. <FloatLineComponent lockObject={this.props.lockObject} label="Intensity" target={light} propertyName="intensity" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
  36. <ButtonLineComponent label="Dispose" onClick={() => {
  37. light.dispose();
  38. this.props.globalState.onSelectionChangedObservable.notifyObservers(null);
  39. }} />
  40. </LineContainerComponent>
  41. </div>
  42. );
  43. }
  44. }