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

fix lighting example

- adjust to new light & material handling
parent fe5f841a
Branches
No related tags found
No related merge requests found
/** /**
* Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
* *
* @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Alexander Rose <alexander.rose@weirdbyte.de>
*/ */
...@@ -17,44 +17,46 @@ require('mol-plugin-ui/skin/light.scss'); ...@@ -17,44 +17,46 @@ require('mol-plugin-ui/skin/light.scss');
type LoadParams = { url: string, format?: BuiltInTrajectoryFormat, isBinary?: boolean, assemblyId?: string } type LoadParams = { url: string, format?: BuiltInTrajectoryFormat, isBinary?: boolean, assemblyId?: string }
type _Preset = Pick<Canvas3DProps, 'multiSample' | 'postprocessing' | 'renderer'> type _Preset = Pick<Canvas3DProps, 'postprocessing' | 'renderer'>
type Preset = { [K in keyof _Preset]: Partial<_Preset[K]> } type Preset = { [K in keyof _Preset]: Partial<_Preset[K]> }
const Canvas3DPresets = { const Canvas3DPresets = {
illustrative: <Preset>{ illustrative: {
multiSample: { canvas3d: <Preset>{
mode: 'temporal' as Canvas3DProps['multiSample']['mode'] postprocessing: {
}, occlusion: { name: 'on', params: { samples: 32, radius: 6, bias: 1.4, blurKernelSize: 15 } },
postprocessing: { outline: { name: 'on', params: { scale: 1, threshold: 0.33, color: Color(0x000000) } }
occlusion: { name: 'on', params: { samples: 32, radius: 6, bias: 1.4, blurKernelSize: 15 } }, },
outline: { name: 'on', params: { scale: 1, threshold: 0.1, color: Color(0x000000) } } renderer: {
}, ambientIntensity: 1.0,
renderer: { light: []
style: { name: 'flat', params: {} } }
} }
}, },
occlusion: <Preset>{ occlusion: {
multiSample: { canvas3d: <Preset>{
mode: 'temporal' as Canvas3DProps['multiSample']['mode'] postprocessing: {
}, occlusion: { name: 'on', params: { samples: 32, radius: 6, bias: 1.4, blurKernelSize: 15 } },
postprocessing: { outline: { name: 'off', params: {} }
occlusion: { name: 'on', params: { samples: 32, radius: 6, bias: 1.4, blurKernelSize: 15 } }, },
outline: { name: 'off', params: {} } renderer: {
}, ambientIntensity: 0.4,
renderer: { light: [{ inclination: 180, azimuth: 0, color: Color.fromNormalizedRgb(1.0, 1.0, 1.0),
style: { name: 'matte', params: {} } intensity: 0.6 }]
}
} }
}, },
standard: <Preset>{ standard: {
multiSample: { canvas3d: <Preset>{
mode: 'off' as Canvas3DProps['multiSample']['mode'] postprocessing: {
}, occlusion: { name: 'off', params: {} },
postprocessing: { outline: { name: 'off', params: {} }
occlusion: { name: 'off', params: {} }, },
outline: { name: 'off', params: {} } renderer: {
}, ambientIntensity: 0.4,
renderer: { light: [{ inclination: 180, azimuth: 0, color: Color.fromNormalizedRgb(1.0, 1.0, 1.0),
style: { name: 'matte', params: {} } intensity: 0.6 }]
}
} }
} }
}; };
...@@ -88,24 +90,20 @@ class LightingDemo { ...@@ -88,24 +90,20 @@ class LightingDemo {
setPreset(preset: Canvas3DPreset) { setPreset(preset: Canvas3DPreset) {
const props = Canvas3DPresets[preset]; const props = Canvas3DPresets[preset];
if (props.postprocessing.occlusion?.name === 'on') { if (props.canvas3d.postprocessing.occlusion?.name === 'on') {
props.postprocessing.occlusion.params.radius = this.radius; props.canvas3d.postprocessing.occlusion.params.radius = this.radius;
props.postprocessing.occlusion.params.bias = this.bias; props.canvas3d.postprocessing.occlusion.params.bias = this.bias;
} }
PluginCommands.Canvas3D.SetSettings(this.plugin, { PluginCommands.Canvas3D.SetSettings(this.plugin, {
settings: { settings: {
...props, ...props,
multiSample: {
...this.plugin.canvas3d!.props.multiSample,
...props.multiSample
},
renderer: { renderer: {
...this.plugin.canvas3d!.props.renderer, ...this.plugin.canvas3d!.props.renderer,
...props.renderer ...props.canvas3d.renderer
}, },
postprocessing: { postprocessing: {
...this.plugin.canvas3d!.props.postprocessing, ...this.plugin.canvas3d!.props.postprocessing,
...props.postprocessing ...props.canvas3d.postprocessing
}, },
} }
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment