@@ -47,10 +47,16 @@ pub struct EntityProperties {
4747 pub visible_history : ExtraQueryHistory ,
4848 pub interactive : bool ,
4949
50+ /// Enable color mapping?
51+ ///
52+ /// See [`Self::color_mapper`] to select an actual mapping.
53+ pub color_mapping : bool ,
54+ /// What kind of color mapping should be applied (none, map, texture, transfer..)?
55+ pub color_mapper : EditableAutoValue < ColorMapper > ,
56+
5057 /// Distance of the projection plane (frustum far plane).
5158 ///
5259 /// Only applies to pinhole cameras when in a spatial view, using 3D navigation.
53- ///
5460 pub pinhole_image_plane_distance : EditableAutoValue < f32 > ,
5561
5662 /// Should the depth texture be backprojected into a point cloud?
@@ -76,10 +82,15 @@ impl EntityProperties {
7682 visible : self . visible && child. visible ,
7783 visible_history : self . visible_history . with_child ( & child. visible_history ) ,
7884 interactive : self . interactive && child. interactive ,
85+
86+ color_mapping : self . color_mapping || child. color_mapping ,
87+ color_mapper : self . color_mapper . or ( & child. color_mapper ) . clone ( ) ,
88+
7989 pinhole_image_plane_distance : self
8090 . pinhole_image_plane_distance
8191 . or ( & child. pinhole_image_plane_distance )
8292 . clone ( ) ,
93+
8394 backproject_depth : self . backproject_depth || child. backproject_depth ,
8495 backproject_pinhole_ent_path : self
8596 . backproject_pinhole_ent_path
@@ -101,6 +112,8 @@ impl Default for EntityProperties {
101112 visible : true ,
102113 visible_history : ExtraQueryHistory :: default ( ) ,
103114 interactive : true ,
115+ color_mapping : false ,
116+ color_mapper : EditableAutoValue :: default ( ) ,
104117 pinhole_image_plane_distance : EditableAutoValue :: default ( ) ,
105118 backproject_depth : false ,
106119 backproject_pinhole_ent_path : None ,
@@ -133,6 +146,53 @@ impl ExtraQueryHistory {
133146 sequences : self . sequences . max ( child. sequences ) ,
134147 }
135148 }
149+ } // ----------------------------------------------------------------------------
150+
151+ #[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
152+ #[ cfg_attr( feature = "serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
153+ pub enum ColorMap {
154+ Grayscale ,
155+ Turbo ,
156+ Viridis ,
157+ Plasma ,
158+ Magma ,
159+ Inferno ,
160+ }
161+
162+ impl std:: fmt:: Display for ColorMap {
163+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
164+ f. write_str ( match self {
165+ ColorMap :: Grayscale => "Grayscale" ,
166+ ColorMap :: Turbo => "Turbo" ,
167+ ColorMap :: Viridis => "Viridis" ,
168+ ColorMap :: Plasma => "Plasma" ,
169+ ColorMap :: Magma => "Magma" ,
170+ ColorMap :: Inferno => "Inferno" ,
171+ } )
172+ }
173+ }
174+
175+ #[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
176+ #[ cfg_attr( feature = "serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
177+ pub enum ColorMapper {
178+ /// Use a well-known color map, pre-implemented as a wgsl module.
179+ ColorMap ( ColorMap ) ,
180+ // TODO(cmc): support textures.
181+ // TODO(cmc): support custom transfer functions.
182+ }
183+
184+ impl std:: fmt:: Display for ColorMapper {
185+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
186+ match self {
187+ ColorMapper :: ColorMap ( colormap) => colormap. fmt ( f) ,
188+ }
189+ }
190+ }
191+
192+ impl Default for ColorMapper {
193+ fn default ( ) -> Self {
194+ Self :: ColorMap ( ColorMap :: Grayscale )
195+ }
136196}
137197
138198// ----------------------------------------------------------------------------
0 commit comments