Skip to content
Snippets Groups Projects
Commit 34989ce3 authored by Alexander Rose's avatar Alexander Rose
Browse files

wip, quick canvas3d settings ui

parent b29428e4
Branches
Tags
No related merge requests found
...@@ -29,16 +29,17 @@ import { Camera } from './camera'; ...@@ -29,16 +29,17 @@ import { Camera } from './camera';
import { ParamDefinition as PD } from 'mol-util/param-definition'; import { ParamDefinition as PD } from 'mol-util/param-definition';
import { BoundingSphereHelper } from './helper/bounding-sphere-helper'; import { BoundingSphereHelper } from './helper/bounding-sphere-helper';
export const Canvas3DParams = { export const Canvas3DParams: PD.Params = {
// TODO: FPS cap? // TODO: FPS cap?
// maxFps: PD.Numeric(30), // maxFps: PD.Numeric(30),
cameraPosition: PD.Vec3(Vec3.create(0, 0, 50)), // TODO or should it be in a seperate 'state' property? cameraPosition: PD.Vec3(Vec3.create(0, 0, 50)), // TODO or should it be in a seperate 'state' property?
cameraMode: PD.Select('perspective', [['perspective', 'Perspective'], ['orthographic', 'Orthographic']]),
backgroundColor: PD.Color(Color(0x000000)),
pickingAlphaThreshold: PD.Numeric(0.5, { min: 0.0, max: 1.0, step: 0.01 }, { description: 'The minimum opacity value needed for an object to be pickable.' }), pickingAlphaThreshold: PD.Numeric(0.5, { min: 0.0, max: 1.0, step: 0.01 }, { description: 'The minimum opacity value needed for an object to be pickable.' }),
debug: PD.Group({ backgroundColor: PD.Color(Color(0x000000)),
showBoundingSpheres: PD.Boolean(true, { description: 'Show bounding spheres of render objects.' }), cameraMode: PD.Select('perspective', [['perspective', 'Perspective'], ['orthographic', 'Orthographic']]),
}) showBoundingSpheres: PD.Boolean(true, { description: 'Show bounding spheres of render objects.' }),
// debug: PD.Group({
// showBoundingSpheres: PD.Boolean(true, { description: 'Show bounding spheres of render objects.' }),
// })
} }
export type Canvas3DParams = typeof Canvas3DParams export type Canvas3DParams = typeof Canvas3DParams
...@@ -126,7 +127,7 @@ namespace Canvas3D { ...@@ -126,7 +127,7 @@ namespace Canvas3D {
let drawPending = false let drawPending = false
let lastRenderTime = -1 let lastRenderTime = -1
const boundingSphereHelper = new BoundingSphereHelper(scene, p.debug.showBoundingSpheres) const boundingSphereHelper = new BoundingSphereHelper(scene, p.showBoundingSpheres)
function getLoci(pickingId: PickingId) { function getLoci(pickingId: PickingId) {
let loci: Loci = EmptyLoci let loci: Loci = EmptyLoci
...@@ -377,8 +378,8 @@ namespace Canvas3D { ...@@ -377,8 +378,8 @@ namespace Canvas3D {
if (props.pickingAlphaThreshold !== undefined && props.pickingAlphaThreshold !== renderer.props.pickingAlphaThreshold) { if (props.pickingAlphaThreshold !== undefined && props.pickingAlphaThreshold !== renderer.props.pickingAlphaThreshold) {
renderer.setPickingAlphaThreshold(props.pickingAlphaThreshold) renderer.setPickingAlphaThreshold(props.pickingAlphaThreshold)
} }
if (props.debug && props.debug.showBoundingSpheres) { if (props.showBoundingSpheres !== undefined) {
boundingSphereHelper.visible = props.debug.showBoundingSpheres boundingSphereHelper.visible = props.showBoundingSpheres
} }
requestDraw(true) requestDraw(true)
}, },
...@@ -389,9 +390,7 @@ namespace Canvas3D { ...@@ -389,9 +390,7 @@ namespace Canvas3D {
cameraMode: camera.state.mode, cameraMode: camera.state.mode,
backgroundColor: renderer.props.clearColor, backgroundColor: renderer.props.clearColor,
pickingAlphaThreshold: renderer.props.pickingAlphaThreshold, pickingAlphaThreshold: renderer.props.pickingAlphaThreshold,
debug: { showBoundingSpheres: boundingSphereHelper.visible
showBoundingSpheres: boundingSphereHelper.visible
}
} }
}, },
get input() { get input() {
......
...@@ -5,11 +5,11 @@ ...@@ -5,11 +5,11 @@
right: 0; right: 0;
bottom: 0; bottom: 0;
background: black; background: black;
.msp-btn-link { .msp-btn-link {
background: rgba(0,0,0,0.2); background: rgba(0,0,0,0.2);
} }
} }
.msp-viewport-expanded { .msp-viewport-expanded {
...@@ -31,30 +31,31 @@ ...@@ -31,30 +31,31 @@
.msp-viewport-controls { .msp-viewport-controls {
position: absolute; position: absolute;
right: $control-spacing; right: $control-spacing;
top: $control-spacing; top: $control-spacing;
width: 290px;
} }
.msp-viewport-controls-buttons { .msp-viewport-controls-buttons {
text-align: right; text-align: right;
> button { > button {
padding: 0; padding: 0;
text-align: center; text-align: center;
width: $row-height; width: $row-height;
} }
> button:last-child { > button:last-child {
margin-left: $control-spacing; margin-left: $control-spacing;
} }
.msp-btn-link, .msp-btn-link-toggle-on { .msp-btn-link, .msp-btn-link-toggle-on {
color: #eee; color: #eee;
} }
.msp-btn-link-toggle-off { .msp-btn-link-toggle-off {
color: $msp-btn-link-toggle-off-font-color; color: $msp-btn-link-toggle-off-font-color;
} }
.msp-btn-link:hover { .msp-btn-link:hover {
color: $hover-font-color; color: $hover-font-color;
} }
...@@ -68,18 +69,18 @@ ...@@ -68,18 +69,18 @@
/* highlight */ /* highlight */
.msp-highlight-info { .msp-highlight-info {
color: $highlight-info-font-color; color: $highlight-info-font-color;
padding: $info-vertical-padding $control-spacing; padding: $info-vertical-padding $control-spacing;
background: $default-background; //$highlight-info-background; background: $default-background; //$highlight-info-background;
position: absolute; position: absolute;
top: $control-spacing; top: $control-spacing;
left: $control-spacing; left: $control-spacing;
text-align: left; text-align: left;
min-height: $row-height; min-height: $row-height;
max-width: 95%; max-width: 95%;
//border-bottom-right-radius: 6px; //border-bottom-right-radius: 6px;
z-index: 10000; z-index: 10000;
@include non-selectable; @include non-selectable;
...@@ -90,4 +91,3 @@ ...@@ -90,4 +91,3 @@
display: inline-block; display: inline-block;
color: $highlight-info-additional-font-color; color: $highlight-info-additional-font-color;
} }
...@@ -10,19 +10,45 @@ import { ButtonsType } from 'mol-util/input/input-observer'; ...@@ -10,19 +10,45 @@ import { ButtonsType } from 'mol-util/input/input-observer';
import { Canvas3dIdentifyHelper } from 'mol-plugin/util/canvas3d-identify'; import { Canvas3dIdentifyHelper } from 'mol-plugin/util/canvas3d-identify';
import { PluginComponent } from './base'; import { PluginComponent } from './base';
import { PluginCommands } from 'mol-plugin/command'; import { PluginCommands } from 'mol-plugin/command';
import { ParamDefinition as PD } from 'mol-util/param-definition';
import { ParameterControls } from './controls/parameters';
import { Canvas3DParams } from 'mol-canvas3d/canvas3d';
interface ViewportState { interface ViewportState {
noWebGl: boolean noWebGl: boolean
} }
export class ViewportControls extends PluginComponent { export class ViewportControls extends PluginComponent {
state = {
isSettingsExpanded: false,
settings: PD.getDefaultValues(Canvas3DParams)
}
resetCamera = () => { resetCamera = () => {
PluginCommands.Camera.Reset.dispatch(this.plugin, {}); PluginCommands.Camera.Reset.dispatch(this.plugin, {});
} }
toggleSettingsExpanded = (e: React.MouseEvent<HTMLButtonElement>) => {
this.setState({ isSettingsExpanded: !this.state.isSettingsExpanded });
e.currentTarget.blur();
}
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 })
}
render() { render() {
return <div style={{ position: 'absolute', right: '10px', top: '10px', height: '100%', color: 'white' }}> return <div className={'msp-viewport-controls'}>
<button className='msp-btn msp-btn-link' onClick={this.resetCamera}>↻ Camera</button> <div className={'msp-row'}>
<button className='msp-btn msp-btn-link' onClick={this.resetCamera}>↻ Camera</button>
<div>
<button className='msp-btn msp-btn-link'onClick={this.toggleSettingsExpanded}>Settings</button>
<div className='msp-control-offset' style={{ display: this.state.isSettingsExpanded ? 'block' : 'none' }}>
<ParameterControls params={Canvas3DParams} values={this.state.settings} onChange={this.setSettings} />
</div>
</div>
</div>
</div> </div>
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment