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

expose fov camera param

parent 1f77b19c
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,7 @@ Note that since we don't clearly distinguish between a public and private interf ...@@ -10,6 +10,7 @@ Note that since we don't clearly distinguish between a public and private interf
- Add custom labels to Confal pyramids - Add custom labels to Confal pyramids
- Improve naming of some internal types in Confal pyramids extension coordinate - Improve naming of some internal types in Confal pyramids extension coordinate
- Add example mmCIF file with categories necessary to display Confal pyramids - Add example mmCIF file with categories necessary to display Confal pyramids
- Add Field of View camera parameter
## [v3.13.0] - 2022-07-24 ## [v3.13.0] - 2022-07-24
......
...@@ -40,6 +40,7 @@ import { Passes } from './passes/passes'; ...@@ -40,6 +40,7 @@ import { Passes } from './passes/passes';
import { shallowEqual } from '../mol-util'; import { shallowEqual } from '../mol-util';
import { MarkingParams } from './passes/marking'; import { MarkingParams } from './passes/marking';
import { GraphicsRenderVariantsBlended, GraphicsRenderVariantsWboit } from '../mol-gl/webgl/render-item'; import { GraphicsRenderVariantsBlended, GraphicsRenderVariantsWboit } from '../mol-gl/webgl/render-item';
import { degToRad, radToDeg } from '../mol-math/misc';
export const Canvas3DParams = { export const Canvas3DParams = {
camera: PD.Group({ camera: PD.Group({
...@@ -49,6 +50,7 @@ export const Canvas3DParams = { ...@@ -49,6 +50,7 @@ export const Canvas3DParams = {
on: PD.Group(StereoCameraParams), on: PD.Group(StereoCameraParams),
off: PD.Group({}) off: PD.Group({})
}, { cycle: true, hideIf: p => p?.mode !== 'perspective' }), }, { cycle: true, hideIf: p => p?.mode !== 'perspective' }),
fov: PD.Numeric(45, { min: 10, max: 130, step: 1 }, { label: 'Field of View' }),
manualReset: PD.Boolean(false, { isHidden: true }), manualReset: PD.Boolean(false, { isHidden: true }),
}, { pivot: 'mode' }), }, { pivot: 'mode' }),
cameraFog: PD.MappedStatic('on', { cameraFog: PD.MappedStatic('on', {
...@@ -303,7 +305,7 @@ namespace Canvas3D { ...@@ -303,7 +305,7 @@ namespace Canvas3D {
position: Vec3.create(0, 0, 100), position: Vec3.create(0, 0, 100),
mode: p.camera.mode, mode: p.camera.mode,
fog: p.cameraFog.name === 'on' ? p.cameraFog.params.intensity : 0, fog: p.cameraFog.name === 'on' ? p.cameraFog.params.intensity : 0,
clipFar: p.cameraClipping.far fov: degToRad(p.camera.fov),
}, { x, y, width, height }, { pixelScale: attribs.pixelScale }); }, { x, y, width, height }, { pixelScale: attribs.pixelScale });
const stereoCamera = new StereoCamera(camera, p.camera.stereo.params); const stereoCamera = new StereoCamera(camera, p.camera.stereo.params);
...@@ -658,6 +660,7 @@ namespace Canvas3D { ...@@ -658,6 +660,7 @@ namespace Canvas3D {
mode: camera.state.mode, mode: camera.state.mode,
helper: { ...helper.camera.props }, helper: { ...helper.camera.props },
stereo: { ...p.camera.stereo }, stereo: { ...p.camera.stereo },
fov: Math.round(radToDeg(camera.state.fov)),
manualReset: !!p.camera.manualReset manualReset: !!p.camera.manualReset
}, },
cameraFog: camera.state.fog > 0 cameraFog: camera.state.fog > 0
...@@ -771,6 +774,10 @@ namespace Canvas3D { ...@@ -771,6 +774,10 @@ namespace Canvas3D {
if (props.camera && props.camera.mode !== undefined && props.camera.mode !== camera.state.mode) { if (props.camera && props.camera.mode !== undefined && props.camera.mode !== camera.state.mode) {
cameraState.mode = props.camera.mode; cameraState.mode = props.camera.mode;
} }
const oldFov = Math.round(radToDeg(camera.state.fov));
if (props.camera && props.camera.fov !== undefined && props.camera.fov !== oldFov) {
cameraState.fov = degToRad(props.camera.fov);
}
if (props.cameraFog !== undefined && props.cameraFog.params) { if (props.cameraFog !== undefined && props.cameraFog.params) {
const newFog = props.cameraFog.name === 'on' ? props.cameraFog.params.intensity : 0; const newFog = props.cameraFog.name === 'on' ? props.cameraFog.params.intensity : 0;
if (newFog !== camera.state.fog) cameraState.fog = newFog; if (newFog !== camera.state.fog) cameraState.fog = newFog;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment