|
@@ -10,6 +10,7 @@ import { GlobalState } from '../../../../globalState';
|
|
|
import { OptionsLineComponent } from '../../../lines/optionsLineComponent';
|
|
|
import { ShadowGenerator } from 'babylonjs/Lights/Shadows/shadowGenerator';
|
|
|
import { SliderLineComponent } from '../../../lines/sliderLineComponent';
|
|
|
+import { ButtonLineComponent } from '../../../lines/buttonLineComponent';
|
|
|
|
|
|
interface ICommonShadowLightPropertyGridComponentProps {
|
|
|
globalState: GlobalState,
|
|
@@ -23,6 +24,19 @@ export class CommonShadowLightPropertyGridComponent extends React.Component<ICom
|
|
|
super(props);
|
|
|
}
|
|
|
|
|
|
+ createShadowGenerator() {
|
|
|
+ const light = this.props.light;
|
|
|
+ const scene = light.getScene();
|
|
|
+ let generator = new ShadowGenerator(512, light);
|
|
|
+
|
|
|
+ scene.meshes.forEach(m => {
|
|
|
+ generator.addShadowCaster(m);
|
|
|
+ m.receiveShadows = true;
|
|
|
+ });
|
|
|
+
|
|
|
+ this.forceUpdate();
|
|
|
+ }
|
|
|
+
|
|
|
render() {
|
|
|
const light = this.props.light;
|
|
|
const generator = light.getShadowGenerator() as ShadowGenerator || null;
|
|
@@ -54,6 +68,12 @@ export class CommonShadowLightPropertyGridComponent extends React.Component<ICom
|
|
|
<FloatLineComponent lockObject={this.props.lockObject} label="Shadows far plane" target={light} propertyName="shadowMaxZ" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
|
|
|
</LineContainerComponent>
|
|
|
{
|
|
|
+ generator == null &&
|
|
|
+ <LineContainerComponent globalState={this.props.globalState} title="SHADOW GENERATOR">
|
|
|
+ <ButtonLineComponent label="Normalize scene" onClick={() => this.createShadowGenerator()} />
|
|
|
+ </LineContainerComponent>
|
|
|
+ }
|
|
|
+ {
|
|
|
generator !== null &&
|
|
|
<LineContainerComponent globalState={this.props.globalState} title="SHADOW GENERATOR">
|
|
|
<FloatLineComponent lockObject={this.props.lockObject} label="Bias" target={generator} propertyName="bias" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
|