Skip to content

Commit

Permalink
Add thematic & hline to displayStyles as well as more viewFlags (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
hnn0003 authored Jun 27, 2024
1 parent c490674 commit 915b593
Show file tree
Hide file tree
Showing 2 changed files with 184 additions and 23 deletions.
128 changes: 105 additions & 23 deletions packages/saved-views-client/src/models/savedViews/DisplayStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export interface DisplayStyle3dSettingsProps extends DisplayStyleSettingsProps {
solarShadows?: SolarShadowSettingsProps;
lights?: LightSettingsProps;
planProjections?: { [modelId: string]: PlanProjectionSettingsProps; };
thematic?: ThematicDisplaySettingsProps;
hiddenLine?: HiddenLineSettingsProps;
}

export interface AmbientOcclusionProps {
Expand All @@ -34,8 +36,8 @@ export interface EnvironmentProps {
export interface GroundPlaneProps {
display?: boolean;
elevation?: number;
aboveColor?: RgbColorProps;
belowColor?: RgbColorProps;
aboveColor?: RgbatColorProps;
belowColor?: RgbatColorProps;
}

/**
Expand All @@ -59,10 +61,10 @@ export interface GroundPlaneProps {
export interface SkyBoxProps {
display?: boolean;
twoColor?: boolean;
skyColor?: RgbColorProps;
groundColor?: RgbColorProps;
zenithColor?: RgbColorProps;
nadirColor?: RgbColorProps;
skyColor?: RgbatColorProps;
groundColor?: RgbatColorProps;
zenithColor?: RgbatColorProps;
nadirColor?: RgbatColorProps;
skyExponent?: number;
groundExponent?: number;
/**
Expand Down Expand Up @@ -93,7 +95,7 @@ export interface SkyCubeProps {

/** JSON representation of SolarShadowSettings. */
export interface SolarShadowSettingsProps {
color?: RgbColorProps;
color?: RgbatColorProps;
}

/**
Expand Down Expand Up @@ -134,7 +136,7 @@ export interface FresnelSettingsProps {
* all surfaces in the scene.
*/
export interface AmbientLightProps {
color?: RgbColorProps;
color?: RgbatColorProps;
intensity?: number;
}

Expand All @@ -145,12 +147,11 @@ export interface AmbientLightProps {
* sky colors of the SkyBox.
*/
export interface HemisphereLightsProps {
upperColor?: RgbColorProps;
lowerColor?: RgbColorProps;
upperColor?: RgbatColorProps;
lowerColor?: RgbatColorProps;
intensity?: number;
}


/**
* Wire format for the solar directional light associated with a {@linkcode LightSettingsProps}. The light is colored
* white and oriented in any direction in world coordinates. It will cast shadows if it is above the world XY plane and
Expand Down Expand Up @@ -181,8 +182,8 @@ export interface PlanProjectionSettingsProps {
/** JSON representation of the display style settings. */
export interface DisplayStyleSettingsProps {
viewflags?: ViewFlagProps;
backgroundColor?: RgbColorProps;
monochromeColor?: RgbColorProps;
backgroundColor?: RgbatColorProps;
monochromeColor?: RgbatColorProps;
monochromeMode?: MonochromeMode;
renderTimeline?: string;
/**
Expand Down Expand Up @@ -230,6 +231,15 @@ export interface ViewFlagProps {
renderMode?: RenderMode;
backgroundMap?: boolean;
ambientOcclusion?: boolean;
acs?: boolean;
noSolarLight?: boolean;
noSourceLights?: boolean;
noCameraLights?: boolean;
grid?: boolean;
thematicDisplay?: boolean;
wiremesh?: boolean;
forceSurfaceDiscard?: boolean;
noWhiteOnWhiteReversal?: boolean;
}

/**
Expand Down Expand Up @@ -289,8 +299,8 @@ export interface DisplayStyleSubCategoryProps
}

export interface SubCategoryAppearanceProps {
color?: RgbColorProps;
fill?: RgbColorProps;
color?: RgbatColorProps;
fill?: RgbatColorProps;
invisible?: boolean;
weight?: number;
style?: string;
Expand Down Expand Up @@ -362,7 +372,6 @@ export interface SpatialClassifierProps {
isActive?: boolean;
}


/** JSON representation of SpatialClassifierFlags. */
export interface SpatialClassifierFlagsProps {
inside: SpatialClassifierInsideDisplay;
Expand Down Expand Up @@ -421,7 +430,7 @@ export interface RealityDataSourceKey {
* generated by 2d projection of model geomety, typically from a model that is generated from two dimensional GIS data.
*/
export interface MapImageryProps {
backgroundBase?: BaseMapLayerProps | RgbColorProps;
backgroundBase?: BaseMapLayerProps | RgbatColorProps;
backgroundLayers?: (ImageMapLayerProps | ModelMapLayerProps)[];
overlayLayers?: (ImageMapLayerProps | ModelMapLayerProps)[];
}
Expand Down Expand Up @@ -491,16 +500,16 @@ export interface DisplayStyleModelAppearanceProps

/** Wire format describing a ClipIntersectionStyle. */
export interface ClipIntersectionStyleProps {
color?: RgbColorProps;
color?: RgbatColorProps;
width?: number;
}

/** Wire format describing a ClipStyle. */
export interface ClipStyleProps {
produceCutGeometry?: boolean;
cutStyle?: CutStyleProps;
insideColor?: RgbColorProps;
outsideColor?: RgbColorProps;
insideColor?: RgbatColorProps;
outsideColor?: RgbatColorProps;
colorizeIntersection?: boolean;
intersectionStyle?: ClipIntersectionStyleProps;
}
Expand Down Expand Up @@ -543,7 +552,7 @@ export interface ViewFlagOverrides {

/** Properties used to initialize a Feature Appearance. */
export interface FeatureAppearanceProps {
rgb?: RgbColorProps;
rgb?: RgbatColorProps;
weight?: number;
transparency?: number;
linePixels?: LinePixels;
Expand All @@ -552,6 +561,77 @@ export interface FeatureAppearanceProps {
emphasized?: true | undefined;
}

/** The thematic display mode. This determines how to apply the thematic color gradient to the geometry. */
export enum ThematicDisplayMode {
Height = 0,
InverseDistanceWeightedSensors = 1,
Slope = 2,
HillShade = 3,
}

/** A thematic gradient mode used to generate and apply a thematic effect to a scene. */
export enum ThematicGradientMode {
Smooth = 0,
Stepped = 1,
SteppedWithDelimiter = 2,
IsoLines = 3,
}

/** A color scheme used to generate the colors of a thematic gradient within an applied range.*/
export enum ThematicGradientColorScheme {
BlueRed = 0,
RedBlue = 1,
Monochrome = 2,
Topographic = 3,
SeaMountain = 4,
Custom = 5,
}

/** The margin color used at the extremes of the gradient, when outside the applied range. Defaults to a black color with no arguments. */
export interface KeyColorProps {
value: number;
color: RgbatColorProps;
}

/** Describes how transparency is computed when applying a thematic gradient to a surface. */
export enum ThematicGradientTransparencyMode {
SurfaceOnly = 0,
MultiplySurfaceAndGradient = 1,
}

/** The settings used to create a color gradient applied to the geometry. */
export interface ThematicGradientSettingsProps {
mode?: ThematicGradientMode;
stepCount?: number;
marginColor?: RgbatColorProps;
colorScheme?: ThematicGradientColorScheme;
customKeys?: KeyColorProps[];
colorMix?: number;
transparencyMode?: ThematicGradientTransparencyMode;
}

/** JSON representation of a ThematicDisplaySensor. */
export interface ThematicDisplaySensorProps {
position?: [x: number, y: number, z: number]; // XYZProps
value?: number;
}

/** JSON representation of a ThematicDisplaySensorSettings for InverseDistanceWeightedSensors. */
export interface ThematicDisplaySensorSettingsProps {
sensors?: ThematicDisplaySensorProps[];
distanceCutoff?: number;
}

/** Settings controlling thematic display. */
export interface ThematicDisplaySettingsProps {
displayMode?: ThematicDisplayMode;
gradientSettings?: ThematicGradientSettingsProps;
range?: [low: number, high: number]; // Range1dProps
axis?: [x: number, y: number, z: number]; // XYZProps
sunDirection?: [x: number, y: number, z: number]; // XYZProps
sensorSettings?: ThematicDisplaySensorSettingsProps;
}

/** Describes the settings for hidden lines. */
export interface HiddenLineSettingsProps {
visible?: HiddenLineStyleProps;
Expand All @@ -573,7 +653,7 @@ export interface HiddenLineStyleProps {
* - width is overridden if width != undefined and width != 0
* - pattern is overridden if pattern != undefined and pattern != LinePixels.Invalid */
overrideColor?: boolean;
color?: RgbColorProps;
color?: RgbatColorProps;
pattern?: LinePixels;
/** If defined, the width of the edges in pixels.
* If undefined (or 0), edges are drawn using the element's line width. */
Expand Down Expand Up @@ -668,8 +748,10 @@ export enum PlanarClipMaskMode {
}

/** JSON representation of an RGB color, with each component in the range [0, 255]. */
export interface RgbColorProps {
export interface RgbatColorProps {
red: number;
green: number;
blue: number;
alpha?: number;
tranparency?: number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ const viewFlagMappings: ExtractionFunc<void, void>[] = [
extractBoolean("monochrome"),
extractBoolean("backgroundMap"),
extractBoolean("ambientOcclusion"),
extractBoolean("acs"),
extractBoolean("thematicDisplay"),
extractBoolean("wiremesh"),
extractBoolean("forceSurfaceDiscard"),
extractBoolean("noWhiteOnWhiteReversal"),
extractBoolean("noSolarLight"),
extractBoolean("noSourceLights"),
extractBoolean("noCameraLights"),
];

const viewFlagLegacyMappings: ExtractionFunc<void, void>[] = [
Expand All @@ -54,6 +62,14 @@ const viewFlagLegacyMappings: ExtractionFunc<void, void>[] = [
extractBoolean("monochrome"),
extractBoolean("backgroundMap"),
extractBoolean("ambientOcclusion"),
extractBoolean("acs"),
extractBoolean("thematicDisplay"),
extractBoolean("wiremesh"),
extractBoolean("forceSurfaceDiscard"),
extractBoolean("noWhiteOnWhiteReversal"),
extractBoolean("noSolarLight"),
extractBoolean("noSourceLights"),
extractBoolean("noCameraLights"),
];

const planarClipMaskMappings: ExtractionFunc<void, void>[] = [
Expand Down Expand Up @@ -367,6 +383,65 @@ const hiddenLineSettingsLegacyMappings: ExtractionFunc<void, void>[] = [
extractNumber("transThreshold", "transparencyThreshold"),
];

const keyColorPropsMappings: ExtractionFunc<void, void>[] = [
extractNumber("value"),
extractColor("color"),
];

const keyColorPropsLegacyMappings: ExtractionFunc<void, void>[] = [
extractNumber("value"),
extractColorLegacy("color"),
];

const thematicGradientSettingsPropsMappings: ExtractionFunc<void, void>[] = [
extractNumber("mode"),
extractNumber("stepCount"),
extractColor("marginColor"),
extractNumber("colorScheme"),
extractArray(keyColorPropsMappings, "customKeys"),
extractNumber("colorMix"),
extractNumber("transparencyMode"),
];

const thematicGradientSettingsPropsLegacyMappings: ExtractionFunc<void, void>[] = [
extractNumber("mode"),
extractNumber("stepCount"),
extractColorLegacy("marginColor"),
extractNumber("colorScheme"),
extractArray(keyColorPropsLegacyMappings, "customKeys"),
extractNumber("colorMix"),
extractNumber("transparencyMode"),
];

const thematicDisplaySensorPropsMappings: ExtractionFunc<void, void>[] = [
extractSimpleArray(simpleTypeOf("number"), "position"),
extractNumber("value"),
];

const thematicDisplaySensorSettingsPropsMappings: ExtractionFunc<void, void>[] =
[
extractArray(thematicDisplaySensorPropsMappings, "sensors"),
extractNumber("distanceCutoff"),
];

const thematicDisplaySettingsMappings: ExtractionFunc<void, void>[] = [
extractNumber("displayMode"),
extractObject(thematicGradientSettingsPropsMappings, "gradientSettings"),
extractSimpleArray(simpleTypeOf("number"), "range"),
extractSimpleArray(simpleTypeOf("number"), "axis"),
extractSimpleArray(simpleTypeOf("number"), "sunDirection"),
extractObject(thematicDisplaySensorSettingsPropsMappings, "gradientSettings"),
];

const thematicDisplaySettingsLegacyMappings: ExtractionFunc<void, void>[] = [
extractNumber("displayMode"),
extractObject(thematicGradientSettingsPropsLegacyMappings, "gradientSettings"),
extractSimpleArray(simpleTypeOf("number"), "range"),
extractSimpleArray(simpleTypeOf("number"), "axis"),
extractSimpleArray(simpleTypeOf("number"), "sunDirection"),
extractObject(thematicDisplaySensorSettingsPropsMappings, "gradientSettings"),
];

const cutStyleMappings: ExtractionFunc<void, void>[] = [
extractObject(viewFlagOverridesMapping, "viewflags"),
extractObject(hiddenLineSettingsMappings, "hiddenLine"),
Expand Down Expand Up @@ -632,6 +707,8 @@ const displayStyle3dMapping: ExtractionFunc<void, void>[] = [
simpleTypeOf("string"),
"planProjections",
),
extractObject(thematicDisplaySettingsMappings, "thematic"),
extractObject(hiddenLineSettingsMappings, "hiddenLine", "hline"),
];

const displayStyle3dLegacyMapping: ExtractionFunc<void, void>[] = [
Expand All @@ -641,6 +718,8 @@ const displayStyle3dLegacyMapping: ExtractionFunc<void, void>[] = [
extractObject(solarShadowLegacyMappings, "solarShadows"),
extractObject(lightsLegacyMappings, "lights"),
extractPlainTypedMap(planProjectionSettingsMappings, simpleTypeOf("string"), "planProjections"),
extractObject(thematicDisplaySettingsLegacyMappings, "thematic"),
extractObject(hiddenLineSettingsLegacyMappings, "hline", "hiddenLine"),
];

/**
Expand Down

0 comments on commit 915b593

Please sign in to comment.