lightPropertyTabComponent.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import * as React from "react";
  2. import { TextLineComponent } from '../../sharedComponents/textLineComponent';
  3. import { LineContainerComponent } from '../../sharedComponents/lineContainerComponent';
  4. import { TextInputLineComponent } from '../../sharedComponents/textInputLineComponent';
  5. import { OptionsLineComponent } from '../../sharedComponents/optionsLineComponent';
  6. import { IPropertyComponentProps } from './propertyComponentProps';
  7. import { LightBlock } from 'babylonjs/Materials/Node/Blocks/Dual/lightBlock';
  8. export class LightPropertyTabComponent extends React.Component<IPropertyComponentProps> {
  9. render() {
  10. let scene = this.props.globalState.nodeMaterial!.getScene();
  11. var lightOptions = scene.lights.map(l => {
  12. return { label: l.name, value: l.name }
  13. });
  14. lightOptions.splice(0, 0, { label: "All", value: "" })
  15. let lightBlock = this.props.block as LightBlock;
  16. return (
  17. <div>
  18. <LineContainerComponent title="GENERAL">
  19. <TextLineComponent label="Type" value="LightBlock" />
  20. <TextInputLineComponent globalState={this.props.globalState} label="Name" propertyName="name" target={lightBlock} onChange={() => this.props.globalState.onUpdateRequiredObservable.notifyObservers()} />
  21. </LineContainerComponent>
  22. <LineContainerComponent title="PROPERTIES">
  23. <OptionsLineComponent label="Light" defaultIfNull={0} noDirectUpdate={true} valuesAreStrings={true} options={lightOptions} target={lightBlock} propertyName="name" onSelect={(name: any) => {
  24. if (name === "") {
  25. lightBlock.light = null;
  26. } else {
  27. lightBlock.light = scene.getLightByName(name);
  28. }
  29. this.forceUpdate();
  30. this.props.globalState.onRebuildRequiredObservable.notifyObservers();
  31. }} />
  32. </LineContainerComponent>
  33. </div>
  34. );
  35. }
  36. }