backgroundMaterialPropertyGridComponent.tsx 4.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import * as React from "react";
  2. import { Observable } from "babylonjs/Misc/observable";
  3. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  4. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  5. import { PropertyChangedEvent } from "../../../../propertyChangedEvent";
  6. import { LineContainerComponent } from "../../../lineContainerComponent";
  7. import { Color3LineComponent } from "../../../lines/color3LineComponent";
  8. import { CheckBoxLineComponent } from "../../../lines/checkBoxLineComponent";
  9. import { SliderLineComponent } from "../../../lines/sliderLineComponent";
  10. import { CommonMaterialPropertyGridComponent } from "./commonMaterialPropertyGridComponent";
  11. import { TextureLinkLineComponent } from "../../../lines/textureLinkLineComponent";
  12. import { LockObject } from "../lockObject";
  13. import { GlobalState } from '../../../../globalState';
  14. interface IBackgroundMaterialPropertyGridComponentProps {
  15. globalState: GlobalState,
  16. material: BackgroundMaterial;
  17. lockObject: LockObject;
  18. onSelectionChangedObservable?: Observable<any>;
  19. onPropertyChangedObservable?: Observable<PropertyChangedEvent>;
  20. }
  21. export class BackgroundMaterialPropertyGridComponent extends React.Component<IBackgroundMaterialPropertyGridComponentProps> {
  22. private _onDebugSelectionChangeObservable = new Observable<BaseTexture>();
  23. constructor(props: IBackgroundMaterialPropertyGridComponentProps) {
  24. super(props);
  25. }
  26. renderTextures() {
  27. const material = this.props.material;
  28. const onDebugSelectionChangeObservable = this._onDebugSelectionChangeObservable;
  29. return (
  30. <LineContainerComponent globalState={this.props.globalState} title="TEXTURES">
  31. <TextureLinkLineComponent label="Diffuse" texture={material.diffuseTexture} material={material} onSelectionChangedObservable={this.props.onSelectionChangedObservable} onDebugSelectionChangeObservable={onDebugSelectionChangeObservable} />
  32. <TextureLinkLineComponent label="Reflection" texture={material.reflectionTexture} material={material} onSelectionChangedObservable={this.props.onSelectionChangedObservable} onDebugSelectionChangeObservable={onDebugSelectionChangeObservable} />
  33. {
  34. material.reflectionTexture &&
  35. <SliderLineComponent label="Reflection blur" target={material} propertyName="reflectionBlur" minimum={0} maximum={1} step={0.01} onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
  36. }
  37. </LineContainerComponent>
  38. );
  39. }
  40. render() {
  41. const material = this.props.material;
  42. return (
  43. <div className="pane">
  44. <CommonMaterialPropertyGridComponent globalState={this.props.globalState} lockObject={this.props.lockObject} material={material} onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
  45. <LineContainerComponent globalState={this.props.globalState} title="LIGHTING & COLORS">
  46. <Color3LineComponent label="Primary" target={material} propertyName="primaryColor" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
  47. <SliderLineComponent label="Shadow level" target={material} propertyName="primaryColorShadowLevel" minimum={0} maximum={1} step={0.01} onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
  48. <SliderLineComponent label="Highlight level" target={material} propertyName="primaryColorHighlightLevel" minimum={0} maximum={1} step={0.01} onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
  49. </LineContainerComponent>
  50. {this.renderTextures()}
  51. <LineContainerComponent globalState={this.props.globalState} title="RENDERING" closed={true}>
  52. <CheckBoxLineComponent label="Enable noise" target={material} propertyName="enableNoise" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
  53. <CheckBoxLineComponent label="Opacity fresnel" target={material} propertyName="opacityFresnel" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
  54. <CheckBoxLineComponent label="Reflection fresnel" target={material} propertyName="reflectionFresnel" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
  55. <SliderLineComponent label="Reflection amount" target={material} propertyName="reflectionAmount" minimum={0} maximum={1} step={0.01} onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
  56. </LineContainerComponent>
  57. </div>
  58. );
  59. }
  60. }