backgroundMaterialPropertyGridComponent.tsx 4.2 KB

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