mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-01 13:28:59 +08:00
Adding colormap customization on viewer (#272)
* set up logic for colormap defined by user on viewer * ooops typo * nit * done with defaults * lint
This commit is contained in:
1 parent
26a37e750a
commit
2d3452e5a2
6 files changed
+153
-31
No files matched your search
@@ -22,6 +22,12 @@ export function RenderControls() {
|
||||
const outputChoice = useSelector(
|
||||
(state) => state.renderingState.output_choice,
|
||||
);
|
||||
const colormapOptions = useSelector(
|
||||
(state) => state.renderingState.colormap_options,
|
||||
);
|
||||
const colormapChoice = useSelector(
|
||||
(state) => state.renderingState.colormap_choice,
|
||||
);
|
||||
const min_resolution = useSelector(
|
||||
(state) => state.renderingState.minResolution,
|
||||
);
|
||||
@@ -96,6 +102,25 @@ export function RenderControls() {
|
||||
}
|
||||
};
|
||||
|
||||
const set_colormap_choice = (value) => {
|
||||
if (websocket.readyState === WebSocket.OPEN) {
|
||||
dispatch({
|
||||
type: 'write',
|
||||
path: 'renderingState/colormap_choice',
|
||||
data: value,
|
||||
});
|
||||
const cmd = 'write';
|
||||
const path = 'renderingState/colormap_choice';
|
||||
const data = {
|
||||
type: cmd,
|
||||
path,
|
||||
data: value,
|
||||
};
|
||||
const message = msgpack.encode(data);
|
||||
websocket.send(message);
|
||||
}
|
||||
};
|
||||
|
||||
const set_fov = (value) => {
|
||||
if (websocket.readyState === WebSocket.OPEN) {
|
||||
dispatch({
|
||||
@@ -174,6 +199,16 @@ export function RenderControls() {
|
||||
set_output_choice(v);
|
||||
},
|
||||
},
|
||||
// colormap_options
|
||||
colormap_options: {
|
||||
label: 'Colormap',
|
||||
options: colormapOptions,
|
||||
value: colormapChoice,
|
||||
onChange: (v) => {
|
||||
set_colormap_choice(v);
|
||||
},
|
||||
disabled: colormapOptions.length === 1
|
||||
},
|
||||
// resolution
|
||||
min_resolution: {
|
||||
label: 'Min Res.',
|
||||
@@ -225,6 +260,8 @@ export function RenderControls() {
|
||||
isTraining,
|
||||
outputOptions,
|
||||
outputChoice,
|
||||
colormapOptions,
|
||||
colormapChoice,
|
||||
min_resolution,
|
||||
max_resolution,
|
||||
field_of_view,
|
||||
@@ -273,12 +310,15 @@ export function RenderControls() {
|
||||
setControls({ min_resolution });
|
||||
setControls({ max_resolution });
|
||||
setControls({ output_options: outputChoice });
|
||||
setControls({ colormap_options: colormapChoice });
|
||||
setControls({ 'Camera FoV': field_of_view });
|
||||
}, [
|
||||
setControls,
|
||||
isTraining,
|
||||
outputOptions,
|
||||
outputChoice,
|
||||
colormapOptions,
|
||||
colormapChoice,
|
||||
min_resolution,
|
||||
max_resolution,
|
||||
field_of_view,
|
||||
|
||||
@@ -4,3 +4,4 @@
|
||||
export const selectTrainingState = (state) =>
|
||||
state.shared.rendering.training_state;
|
||||
export const selectOutputOptions = (state) => state.shared.output_options;
|
||||
export const selectColormapOptions = (state) => state.shared.colormap_options;
|
||||
@@ -15,6 +15,8 @@ const initialState = {
|
||||
isTraining: true,
|
||||
output_options: ['rgb'], // populated by the possible Graph outputs
|
||||
output_choice: 'rgb', // the selected output
|
||||
colormap_options: ['default'], // populated by the output choice
|
||||
colormap_choice: 'default', // the selected colormap
|
||||
minResolution: 50,
|
||||
maxResolution: 512,
|
||||
field_of_view: 80,
|
||||
@@ -22,6 +24,7 @@ const initialState = {
|
||||
train_eta: 'Paused',
|
||||
vis_train_ratio: 'Paused',
|
||||
},
|
||||
|
||||
// the scene state
|
||||
sceneState: {
|
||||
sceneBounds: null,
|
||||
@@ -33,6 +36,9 @@ const initialState = {
|
||||
};
|
||||
|
||||
function setData(newState, state, path, data) {
|
||||
if (path === 'colormap_options') {
|
||||
newState.colormap_choice = 'default'; // eslint-disable-line no-param-reassign
|
||||
}
|
||||
if (path.length === 1) {
|
||||
newState[path[0]] = data; // eslint-disable-line no-param-reassign
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user