From 915b5937df95ac903af986d0188a0181e8718707 Mon Sep 17 00:00:00 2001 From: hnn0003 <18196761+hnn0003@users.noreply.github.com> Date: Thu, 27 Jun 2024 11:01:02 -0500 Subject: [PATCH] Add thematic & hline to displayStyles as well as more viewFlags (#81) --- .../src/models/savedViews/DisplayStyles.ts | 128 ++++++++++++++---- .../src/translation/displayStyleExtractor.ts | 79 +++++++++++ 2 files changed, 184 insertions(+), 23 deletions(-) diff --git a/packages/saved-views-client/src/models/savedViews/DisplayStyles.ts b/packages/saved-views-client/src/models/savedViews/DisplayStyles.ts index 726c478a..e2813cb5 100644 --- a/packages/saved-views-client/src/models/savedViews/DisplayStyles.ts +++ b/packages/saved-views-client/src/models/savedViews/DisplayStyles.ts @@ -11,6 +11,8 @@ export interface DisplayStyle3dSettingsProps extends DisplayStyleSettingsProps { solarShadows?: SolarShadowSettingsProps; lights?: LightSettingsProps; planProjections?: { [modelId: string]: PlanProjectionSettingsProps; }; + thematic?: ThematicDisplaySettingsProps; + hiddenLine?: HiddenLineSettingsProps; } export interface AmbientOcclusionProps { @@ -34,8 +36,8 @@ export interface EnvironmentProps { export interface GroundPlaneProps { display?: boolean; elevation?: number; - aboveColor?: RgbColorProps; - belowColor?: RgbColorProps; + aboveColor?: RgbatColorProps; + belowColor?: RgbatColorProps; } /** @@ -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; /** @@ -93,7 +95,7 @@ export interface SkyCubeProps { /** JSON representation of SolarShadowSettings. */ export interface SolarShadowSettingsProps { - color?: RgbColorProps; + color?: RgbatColorProps; } /** @@ -134,7 +136,7 @@ export interface FresnelSettingsProps { * all surfaces in the scene. */ export interface AmbientLightProps { - color?: RgbColorProps; + color?: RgbatColorProps; intensity?: number; } @@ -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 @@ -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; /** @@ -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; } /** @@ -289,8 +299,8 @@ export interface DisplayStyleSubCategoryProps } export interface SubCategoryAppearanceProps { - color?: RgbColorProps; - fill?: RgbColorProps; + color?: RgbatColorProps; + fill?: RgbatColorProps; invisible?: boolean; weight?: number; style?: string; @@ -362,7 +372,6 @@ export interface SpatialClassifierProps { isActive?: boolean; } - /** JSON representation of SpatialClassifierFlags. */ export interface SpatialClassifierFlagsProps { inside: SpatialClassifierInsideDisplay; @@ -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)[]; } @@ -491,7 +500,7 @@ export interface DisplayStyleModelAppearanceProps /** Wire format describing a ClipIntersectionStyle. */ export interface ClipIntersectionStyleProps { - color?: RgbColorProps; + color?: RgbatColorProps; width?: number; } @@ -499,8 +508,8 @@ export interface ClipIntersectionStyleProps { export interface ClipStyleProps { produceCutGeometry?: boolean; cutStyle?: CutStyleProps; - insideColor?: RgbColorProps; - outsideColor?: RgbColorProps; + insideColor?: RgbatColorProps; + outsideColor?: RgbatColorProps; colorizeIntersection?: boolean; intersectionStyle?: ClipIntersectionStyleProps; } @@ -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; @@ -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; @@ -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. */ @@ -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; } diff --git a/packages/saved-views-react/src/translation/displayStyleExtractor.ts b/packages/saved-views-react/src/translation/displayStyleExtractor.ts index 8fa2c602..b4907460 100644 --- a/packages/saved-views-react/src/translation/displayStyleExtractor.ts +++ b/packages/saved-views-react/src/translation/displayStyleExtractor.ts @@ -34,6 +34,14 @@ const viewFlagMappings: ExtractionFunc[] = [ 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[] = [ @@ -54,6 +62,14 @@ const viewFlagLegacyMappings: ExtractionFunc[] = [ 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[] = [ @@ -367,6 +383,65 @@ const hiddenLineSettingsLegacyMappings: ExtractionFunc[] = [ extractNumber("transThreshold", "transparencyThreshold"), ]; +const keyColorPropsMappings: ExtractionFunc[] = [ + extractNumber("value"), + extractColor("color"), +]; + +const keyColorPropsLegacyMappings: ExtractionFunc[] = [ + extractNumber("value"), + extractColorLegacy("color"), +]; + +const thematicGradientSettingsPropsMappings: ExtractionFunc[] = [ + extractNumber("mode"), + extractNumber("stepCount"), + extractColor("marginColor"), + extractNumber("colorScheme"), + extractArray(keyColorPropsMappings, "customKeys"), + extractNumber("colorMix"), + extractNumber("transparencyMode"), +]; + +const thematicGradientSettingsPropsLegacyMappings: ExtractionFunc[] = [ + extractNumber("mode"), + extractNumber("stepCount"), + extractColorLegacy("marginColor"), + extractNumber("colorScheme"), + extractArray(keyColorPropsLegacyMappings, "customKeys"), + extractNumber("colorMix"), + extractNumber("transparencyMode"), +]; + +const thematicDisplaySensorPropsMappings: ExtractionFunc[] = [ + extractSimpleArray(simpleTypeOf("number"), "position"), + extractNumber("value"), +]; + +const thematicDisplaySensorSettingsPropsMappings: ExtractionFunc[] = + [ + extractArray(thematicDisplaySensorPropsMappings, "sensors"), + extractNumber("distanceCutoff"), + ]; + +const thematicDisplaySettingsMappings: ExtractionFunc[] = [ + extractNumber("displayMode"), + extractObject(thematicGradientSettingsPropsMappings, "gradientSettings"), + extractSimpleArray(simpleTypeOf("number"), "range"), + extractSimpleArray(simpleTypeOf("number"), "axis"), + extractSimpleArray(simpleTypeOf("number"), "sunDirection"), + extractObject(thematicDisplaySensorSettingsPropsMappings, "gradientSettings"), +]; + +const thematicDisplaySettingsLegacyMappings: ExtractionFunc[] = [ + extractNumber("displayMode"), + extractObject(thematicGradientSettingsPropsLegacyMappings, "gradientSettings"), + extractSimpleArray(simpleTypeOf("number"), "range"), + extractSimpleArray(simpleTypeOf("number"), "axis"), + extractSimpleArray(simpleTypeOf("number"), "sunDirection"), + extractObject(thematicDisplaySensorSettingsPropsMappings, "gradientSettings"), +]; + const cutStyleMappings: ExtractionFunc[] = [ extractObject(viewFlagOverridesMapping, "viewflags"), extractObject(hiddenLineSettingsMappings, "hiddenLine"), @@ -632,6 +707,8 @@ const displayStyle3dMapping: ExtractionFunc[] = [ simpleTypeOf("string"), "planProjections", ), + extractObject(thematicDisplaySettingsMappings, "thematic"), + extractObject(hiddenLineSettingsMappings, "hiddenLine", "hline"), ]; const displayStyle3dLegacyMapping: ExtractionFunc[] = [ @@ -641,6 +718,8 @@ const displayStyle3dLegacyMapping: ExtractionFunc[] = [ extractObject(solarShadowLegacyMappings, "solarShadows"), extractObject(lightsLegacyMappings, "lights"), extractPlainTypedMap(planProjectionSettingsMappings, simpleTypeOf("string"), "planProjections"), + extractObject(thematicDisplaySettingsLegacyMappings, "thematic"), + extractObject(hiddenLineSettingsLegacyMappings, "hline", "hiddenLine"), ]; /**