|
@@ -33,24 +33,35 @@ export class ViewportControls extends PluginComponent {
|
|
|
e.currentTarget.blur();
|
|
|
}
|
|
|
|
|
|
- hideSettings = () => {
|
|
|
- this.setState({ isSettingsExpanded: false });
|
|
|
- }
|
|
|
+ // hideSettings = () => {
|
|
|
+ // this.setState({ isSettingsExpanded: false });
|
|
|
+ // }
|
|
|
|
|
|
setSettings = (p: { param: PD.Base<any>, name: string, value: any }) => {
|
|
|
- this.plugin.canvas3d.setProps({ [p.name]: p.value })
|
|
|
- this.setState({ settings: this.plugin.canvas3d.props })
|
|
|
+ PluginCommands.Canvas3D.SetSettings.dispatch(this.plugin, { settings: { [p.name]: p.value } });
|
|
|
+ }
|
|
|
+
|
|
|
+ componentDidMount() {
|
|
|
+ if (this.plugin.canvas3d) {
|
|
|
+ this.setState({ settings: this.plugin.canvas3d.props });
|
|
|
+ }
|
|
|
+
|
|
|
+ this.subscribe(this.plugin.events.canvad3d.settingsUpdated, e => {
|
|
|
+ this.setState({ settings: this.plugin.canvas3d.props });
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
+ // TODO: show some icons dimmed etc..
|
|
|
return <div className={'msp-viewport-controls'}>
|
|
|
<div className='msp-viewport-controls-buttons'>
|
|
|
- <button className='msp-btn msp-btn-link' title='Reset Camera' onClick={this.toggleSettingsExpanded}><span className='msp-icon msp-icon-settings'/></button>
|
|
|
- <button className='msp-btn msp-btn-link' onClick={this.resetCamera}><span className='msp-icon msp-icon-reset-scene'/></button>
|
|
|
+ <button className='msp-btn msp-btn-link' onClick={this.toggleSettingsExpanded}><span className='msp-icon msp-icon-settings'/></button>
|
|
|
+ <button className='msp-btn msp-btn-link' title='Reset Camera' onClick={this.resetCamera}><span className='msp-icon msp-icon-reset-scene'/></button>
|
|
|
</div>
|
|
|
- <div onMouseLeave={this.hideSettings} className='msp-viewport-controls-scene-options' style={{ display: this.state.isSettingsExpanded ? 'block' : 'none' }}>
|
|
|
+ {this.state.isSettingsExpanded &&
|
|
|
+ <div className='msp-viewport-controls-scene-options'>
|
|
|
<ParameterControls params={Canvas3DParams} values={this.state.settings} onChange={this.setSettings} />
|
|
|
- </div>
|
|
|
+ </div>}
|
|
|
</div>
|
|
|
}
|
|
|
}
|