Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
[feat] Effects: shadow color picker; use animation & current time (#2387)
Igor Dykhta87df1197a259
diff --git a/src/components/src/effects/effect-configurator.tsx b/src/components/src/effects/effect-configurator.tsxindex 3aeb138eb..10823113e 100644--- a/src/components/src/effects/effect-configurator.tsx+++ b/src/components/src/effects/effect-configurator.tsx@@ -94,17 +94,17 @@ export default function EffectConfiguratorFactory([effect, updateEffectConfig]);- const onUseCurrentTimeChange = useCallback(+ const onTimeModeChange = useCallback(value => {updateEffectConfig(null, effect.id, {- params: {useCurrentTime: value}+ params: {timeMode: value}});},[effect, updateEffectConfig]);const colorPickerProps = useMemo(() => {- const propNames = ['ambientLightColor', 'sunLightColor'];+ const propNames = ['ambientLightColor', 'sunLightColor', 'shadowColor'];return propNames.map(propName => {return {colorSets: [@@ -125,14 +125,20 @@ export default function EffectConfiguratorFactory(<EffectTimeConfiguratortimestamp={config.params.timestamp}onDateTimeChange={onDateTimeChange}- useCurrentTime={config.params.useCurrentTime}- onUseCurrentTimeChange={onUseCurrentTimeChange}+ timeMode={config.params.timeMode}+ onTimeModeChange={onTimeModeChange}intl={intl}/><PanelLabelWrapper><PanelLabel>{'Shadow intensity'}</PanelLabel></PanelLabelWrapper><RangeSlider {...COMMON_SLIDER_PROPS} {...sliderProps[0]} />+ <PanelLabelWrapper>+ <PanelLabel>{'Shadow color'}</PanelLabel>+ </PanelLabelWrapper>+ <StyledColorSelectorWrapper>+ <ColorSelector {...colorPickerProps[2]} />+ </StyledColorSelectorWrapper><PanelLabelWrapper><PanelLabel>{'Ambient light intensity'}</PanelLabel></PanelLabelWrapper>@@ -165,7 +171,7 @@ export default function EffectConfiguratorFactory(const slidersForProps = useMemo(() => {return propNames.map(propName => {const uniform = uniforms[propName];- if (!uniform || uniform.private) {+ if ((!uniform && uniform !== 0) || uniform.private) {return null;}@@ -201,7 +207,7 @@ export default function EffectConfiguratorFactory(}});}- // the uniform plain number without any desc+ // the uniform is a plain number without any descriptionelse if (isNumber(uniform)) {sliders.push({value1: prevValue || 0,diff --git a/src/components/src/effects/effect-time-configurator.tsx b/src/components/src/effects/effect-time-configurator.tsxindex 794c9eafd..1d0cd378e 100644--- a/src/components/src/effects/effect-time-configurator.tsx+++ b/src/components/src/effects/effect-time-configurator.tsx@@ -4,6 +4,10 @@ import styled from 'styled-components';import {FormattedMessage} from '@kepler.gl/localization';import {clamp} from '@kepler.gl/utils';+import {+ LIGHT_AND_SHADOW_EFFECT_TIME_MODES,+ LightAndShadowEffectTimeMode+} from '@kepler.gl/constants';import {StyledTimePicker, StyledDatePicker, Tooltip} from '../common/styled-components';import RangeSliderFactory from '../common/range-slider';@@ -16,8 +20,8 @@ const DAY_SLIDER_RANGE = 1000 * 60 * 60 * 24;export type EffectTimeConfiguratorProps = {timestamp: string;onDateTimeChange: (time: number) => void;- useCurrentTime: boolean;- onUseCurrentTimeChange: (value: boolean) => void;+ timeMode: LightAndShadowEffectTimeMode;+ onTimeModeChange: (newMode: LightAndShadowEffectTimeMode) => void;intl: IntlShape;};@@ -83,9 +87,9 @@ export default function EffectTimeConfiguratorFactory(): React.FC<EffectTimeConfiguratorProps> {const EffectTimeConfigurator = ({timestamp,- useCurrentTime,onDateTimeChange,- onUseCurrentTimeChange,+ timeMode,+ onTimeModeChange,intl}: EffectTimeConfiguratorProps) => {const [selectedDate, selectedTimeString] = useMemo(() => {@@ -139,22 +143,24 @@ export default function EffectTimeConfiguratorFactory(onDateTimeChange(new Date().valueOf());}, [onDateTimeChange]);+ const disableDateTimePick = timeMode !== LIGHT_AND_SHADOW_EFFECT_TIME_MODES.pick;+return (<StyledEffectTimeConfigurator><StyledWrapper><StyledRadiotype="radio"- checked={!useCurrentTime}- id={`effect-time-toggle-use-pick`}+ checked={timeMode === LIGHT_AND_SHADOW_EFFECT_TIME_MODES.pick}+ id={`effect-time-toggle-use-pick-time`}label={intl.formatMessage({id: 'effectManager.pickDateTime'})}onChange={() => {- onUseCurrentTimeChange(false);+ onTimeModeChange(LIGHT_AND_SHADOW_EFFECT_TIME_MODES.pick);}}/></StyledWrapper>- <StyledWrapper disabled={useCurrentTime}>+ <StyledWrapper disabled={disableDateTimePick}><StyledButton onClick={setCurrentDateTime} data-for="pick-time-button" data-tip><Pin height="15px" /><Tooltip id="pick-time-button" effect="solid" place="top" delayShow={500}>@@ -173,20 +179,32 @@ export default function EffectTimeConfiguratorFactory(</StyledLabelWrapper></StyledWrapper>- <SliderWrapper disabled={useCurrentTime}>+ <SliderWrapper disabled={disableDateTimePick}><RangeSlider {...timeSliderProps} /></SliderWrapper><StyledWrapper><StyledRadiotype="radio"- checked={useCurrentTime}- id={`effect-time-toggle-use-current`}+ checked={timeMode === LIGHT_AND_SHADOW_EFFECT_TIME_MODES.current}+ id={`effect-time-toggle-use-current-time`}label={intl.formatMessage({id: 'effectManager.currentTime'})}onChange={() => {- onUseCurrentTimeChange(true);+ onTimeModeChange(LIGHT_AND_SHADOW_EFFECT_TIME_MODES.current);+ }}+ />+ </StyledWrapper>++ <StyledWrapper>+ <StyledRadio+ type="radio"+ checked={timeMode === LIGHT_AND_SHADOW_EFFECT_TIME_MODES.animation}+ id={`effect-time-toggle-use-animation-time`}+ label={'Animation time'}+ onChange={() => {+ onTimeModeChange(LIGHT_AND_SHADOW_EFFECT_TIME_MODES.animation);}}/></StyledWrapper>diff --git a/src/components/src/index.ts b/src/components/src/index.tsindex 86b43d23e..255f63ede 100644--- a/src/components/src/index.ts+++ b/src/components/src/index.ts@@ -261,6 +261,10 @@ export {export {default as FilterPanelHeaderFactory} from './side-panel/filter-panel/filter-panel-header';export {default as EffectManagerFactory} from './effects/effect-manager';+export {default as EffectListFactory} from './effects/effect-list';+export {default as SidePanelTitleFactory} from './effects/side-panel-title';+export {default as EffectTypeSelectorFactory} from './effects/effect-type-selector';+export {default as EffectConfiguratorFactory} from './effects/effect-configurator';export {default as HowToButton} from './side-panel/layer-panel/how-to-button';// eslint-disable-next-line prettier/prettierdiff --git a/src/components/src/kepler-gl.tsx b/src/components/src/kepler-gl.tsxindex 13ad4ad64..fc138873c 100644--- a/src/components/src/kepler-gl.tsx+++ b/src/components/src/kepler-gl.tsx@@ -63,6 +63,7 @@ import ModalContainerFactory from './modal-container';import PlotContainerFactory from './plot-container';import NotificationPanelFactory from './notification-panel';import GeoCoderPanelFactory from './geocoder-panel';+import EffectManagerFactory from './effects/effect-manager';import DndContextFactory from './dnd-context';import {@@ -348,7 +349,8 @@ KeplerGlFactory.deps = [SidePanelFactory,PlotContainerFactory,NotificationPanelFactory,- DndContextFactory+ DndContextFactory,+ EffectManagerFactory];function KeplerGlFactory(diff --git a/src/constants/src/default-settings.ts b/src/constants/src/default-settings.tsindex b1b25d2fc..871a93dcd 100644--- a/src/constants/src/default-settings.ts+++ b/src/constants/src/default-settings.ts@@ -1150,16 +1150,31 @@ export const dataTestIds: Record<string, string> = {// Effects-export const DEFAULT_EFFECT_TYPE = 'ink';+export const DEFAULT_POST_PROCESSING_EFFECT_TYPE: string = 'ink';export const DEFAULT_LIGHT_COLOR: [number, number, number] = [255, 255, 255];export const DEFAULT_LIGHT_INTENSITY = 1;export const DEFAULT_SHADOW_INTENSITY = 0.5;export const DEFAULT_SHADOW_COLOR: [number, number, number] = [0, 0, 0];export const LIGHT_AND_SHADOW_EFFECT = {type: 'lightAndShadow', name: 'Light & Shadow'};-export const DEFAULT_LIGHT_AND_SHADOW_PROPS = {+export const LIGHT_AND_SHADOW_EFFECT_TIME_MODES = {+ pick: 'pick' as 'pick',+ current: 'current' as 'current',+ animation: 'animation' as 'animation'+};+export type LightAndShadowEffectTimeMode = 'pick' | 'current' | 'animation';+export const DEFAULT_LIGHT_AND_SHADOW_PROPS: {+ timestamp: number;+ timeMode: LightAndShadowEffectTimeMode;+ shadowIntensity: number;+ shadowColor: [number, number, number];+ sunLightColor: [number, number, number];+ sunLightIntensity: number;+ ambientLightColor: [number, number, number];+ ambientLightIntensity: number;+} = {timestamp: Date.now(),- useCurrentTime: false,+ timeMode: LIGHT_AND_SHADOW_EFFECT_TIME_MODES.pick as LightAndShadowEffectTimeMode,shadowIntensity: DEFAULT_SHADOW_INTENSITY,shadowColor: [...DEFAULT_SHADOW_COLOR] as [number, number, number],sunLightColor: [...DEFAULT_LIGHT_COLOR] as [number, number, number],diff --git a/src/effects/src/effect.ts b/src/effects/src/effect.tsindex 3b80ccaeb..91b99e37f 100644--- a/src/effects/src/effect.ts+++ b/src/effects/src/effect.ts@@ -1,186 +1,31 @@-import {- PostProcessEffect,- LightingEffect,- AmbientLight,- _SunLight as SunLight-} from '@deck.gl/core';-import {- brightnessContrast,- ink,- triangleBlur,- hueSaturation,- vibrance,- colorHalftone,- dotScreen,- edgeWork,- noise,- sepia,- tiltShift,- vignette,- zoomBlur,- magnify,- hexagonalPixelate-} from '@luma.gl/shadertools';-import {generateHashId} from '@kepler.gl/utils';-import {- LIGHT_AND_SHADOW_EFFECT,- POSTPROCESSING_EFFECTS,- EFFECT_DESCS,- DEFAULT_LIGHT_AND_SHADOW_PROPS,- DEFAULT_EFFECT_TYPE-} from '@kepler.gl/constants';import {Effect as EffectInterface, EffectConfig, EffectParamsPartial} from '@kepler.gl/types';-const LIGHT_AND_SHADOW_EFFECT_DESC: {- type: string;- name: string;- class: null;-} = {- ...LIGHT_AND_SHADOW_EFFECT,- class: null-};--const POSTPROCESSING_EFFECTS_DESCS = [- {- ...POSTPROCESSING_EFFECTS.ink,- class: ink- },- {- ...POSTPROCESSING_EFFECTS.brightnessContrast,- class: brightnessContrast- },- {- ...POSTPROCESSING_EFFECTS.hueSaturation,- class: hueSaturation- },- {- ...POSTPROCESSING_EFFECTS.vibrance,- class: vibrance- },- {- ...POSTPROCESSING_EFFECTS.sepia,- class: sepia- },- {- ...POSTPROCESSING_EFFECTS.dotScreen,- class: dotScreen- },- {- ...POSTPROCESSING_EFFECTS.colorHalftone,- class: colorHalftone- },- {- ...POSTPROCESSING_EFFECTS.noise,- class: noise- },- {- ...POSTPROCESSING_EFFECTS.triangleBlur,- class: triangleBlur- },- {- ...POSTPROCESSING_EFFECTS.zoomBlur,- class: zoomBlur- },- {- ...POSTPROCESSING_EFFECTS.tiltShift,- class: tiltShift- },- {- ...POSTPROCESSING_EFFECTS.edgeWork,- class: edgeWork- },- {- ...POSTPROCESSING_EFFECTS.vignette,- class: vignette- },- {- ...POSTPROCESSING_EFFECTS.magnify,- class: magnify- },- {- ...POSTPROCESSING_EFFECTS.hexagonalPixelate,- class: hexagonalPixelate- }-];--export function createDeckEffectFromConfig(params: Partial<EffectParamsPartial>): EffectInterface {- return new Effect(params);-}-export class Effect implements EffectInterface {id: string;config: EffectConfig;- deckEffect: PostProcessEffect | LightingEffect | null;+ deckEffect: any;constructor(props: EffectParamsPartial = {}) {this.id = props.id || `e_${generateHashId(6)}`;- this.config = this.getDefaultEffectConfig(props.config);+ this.config = this._getDefaultEffectConfig(props.config);this.deckEffect = null;- // TODO move to a separate class- // Special case for shadow effect- if (this.config.type === LIGHT_AND_SHADOW_EFFECT_DESC.type) {- this._initializeLightAndShadowEffect();- } else {- this._initializePostProcessingEffect();- }+ this.deckEffect = null;+ this._initializeEffect();}- _initializePostProcessingEffect() {- // All other effects are PostProcessEffects- const effectDesc = POSTPROCESSING_EFFECTS_DESCS.find(desc => desc.type === this.config.type);- if (effectDesc) {- this.deckEffect = new PostProcessEffect(effectDesc.class, this.config.params);-- // @ts-expect-error- const uniforms = this.deckEffect?.module?.uniforms;- if (uniforms) {- // get default params- const keys = Object.keys(uniforms);- const defaultParams = {};- keys.forEach(key => {- defaultParams[key] = uniforms[key].value ?? uniforms[key];- });- this.config.params = {...defaultParams, ...this.config.params};- }- }+ _initializeEffect() {+ // implemented in subclasses}- _initializeLightAndShadowEffect() {- this.config.params = {...DEFAULT_LIGHT_AND_SHADOW_PROPS, ...this.config.params};-- const ambientLight = new AmbientLight({- color: this.config.params.ambientLightColor,- intensity: this.config.params.ambientLightIntensity- });-- const sunLight = new SunLight({- timestamp: this.config.params.timestamp,- color: this.config.params.sunLightColor,- intensity: this.config.params.sunLightIntensity,- _shadow: true- });-- this.deckEffect = new LightingEffect({- ambientLight,- sunLight- });- if (this.deckEffect) {- // @ts-expect-error- this.deckEffect.shadowColor[3] = this.config.params.shadowIntensity;- }+ _onUpdateConfig() {+ // implemented in subclasses}- getDefaultEffectConfig(config: Partial<EffectConfig> = {}) {- const type = config.type || DEFAULT_EFFECT_TYPE;- return {- type,- name: config.name || EFFECT_DESCS.find(desc => desc.type === type)?.name || 'Effect',- isEnabled: config.isEnabled ?? true,- isConfigActive: config.isConfigActive ?? true,- params: {...(config.params || {})}- };+ _getDefaultEffectConfig(config: Partial<EffectConfig> = {}) {+ // implemented in subclasses+ return this.config;}updateConfig(config: Partial<EffectConfig>) {@@ -189,34 +34,6 @@ export class Effect implements EffectInterface {...config,params: {...this.config.params, ...(config.params || {})}};-- // any uniform updated?- if (config.params) {- const {params} = this.config;-- if (this.config.type === LIGHT_AND_SHADOW_EFFECT_DESC.type) {- const effect = this.deckEffect as LightingEffect;- if (effect) {- // @ts-expect-error not typed- effect.shadowColor[3] = params.shadowIntensity;- // @ts-expect-error not typed- effect.ambientLight.intensity = params.ambientLightIntensity;- // @ts-expect-error not typed- effect.ambientLight.color = params.ambientLightColor.slice();-- // @ts-expect-error not typed- const sunLight = effect.directionalLights[0];- if (sunLight) {- sunLight.intensity = params.sunLightIntensity;- sunLight.color = params.sunLightColor.slice();- sunLight.timestamp = params.timestamp;- }- }- } else {- // @ts-expect-error not typed- this.deckEffect?.setProps(params);- }- }}isValidToSave() {diff --git a/src/effects/src/index.ts b/src/effects/src/index.tsindex 2f9fb1725..197affa6f 100644--- a/src/effects/src/index.ts+++ b/src/effects/src/index.ts@@ -1 +1,2 @@-export {Effect, createDeckEffectFromConfig} from './effect';+export {Effect} from './effect';+export {createDeckEffectFromConfig} from './utils';diff --git a/src/effects/src/lighting-effect.ts b/src/effects/src/lighting-effect.tsnew file mode 100644index 000000000..9376f93da--- /dev/null+++ b/src/effects/src/lighting-effect.ts@@ -0,0 +1,89 @@+import {+ LightingEffect as DeckLightingEffect,+ AmbientLight,+ _SunLight as SunLight+} from '@deck.gl/core';++import {LIGHT_AND_SHADOW_EFFECT, DEFAULT_LIGHT_AND_SHADOW_PROPS} from '@kepler.gl/constants';+import {normalizeColor} from '@kepler.gl/utils';+import {EffectConfig, EffectParamsPartial} from '@kepler.gl/types';++import Effect from './effect';++const LIGHT_AND_SHADOW_EFFECT_DESC = {+ ...LIGHT_AND_SHADOW_EFFECT,+ class: null+};++class LightingEffect extends Effect {+ // deckEffect: PostProcessEffect | LightingEffect | null;++ constructor(props: EffectParamsPartial) {+ super(props);+ }++ _initializeEffect() {+ this.config.params = {...DEFAULT_LIGHT_AND_SHADOW_PROPS, ...this.config.params};+ const {params} = this.config;++ const ambientLight = new AmbientLight({+ color: params.ambientLightColor,+ intensity: params.ambientLightIntensity+ });++ const sunLight = new SunLight({+ timestamp: params.timestamp,+ color: params.sunLightColor,+ intensity: params.sunLightIntensity,+ _shadow: true+ });++ this.deckEffect = new DeckLightingEffect({+ ambientLight,+ sunLight+ });+ if (this.deckEffect) {+ this.deckEffect.shadowColor = [...normalizeColor(params.shadowColor), params.shadowIntensity];+ }+ }++ _getDefaultEffectConfig(config: Partial<EffectConfig> = {}) {+ const type = config.type || LIGHT_AND_SHADOW_EFFECT_DESC.type;+ return {+ type,+ name: config.name || LIGHT_AND_SHADOW_EFFECT_DESC.name,+ isEnabled: config.isEnabled ?? true,+ isConfigActive: config.isConfigActive ?? true,+ params: {...(config.params || {})}+ };+ }++ updateConfig(config: Partial<EffectConfig>) {+ super.updateConfig(config);++ // any uniform updated?+ if (config.params) {+ const {params} = this.config;++ if (this.config.type === LIGHT_AND_SHADOW_EFFECT_DESC.type) {+ /** @type {LightingEffect} */+ const effect = this.deckEffect;+ if (effect) {+ effect.shadowColor = [...normalizeColor(params.shadowColor), params.shadowIntensity];++ effect.ambientLight.intensity = params.ambientLightIntensity;+ effect.ambientLight.color = params.ambientLightColor.slice();++ const sunLight = effect.directionalLights[0];+ if (sunLight) {+ sunLight.intensity = params.sunLightIntensity;+ sunLight.color = params.sunLightColor.slice();+ sunLight.timestamp = params.timestamp;+ }+ }+ }+ }+ }+}++export default LightingEffect;diff --git a/src/effects/src/post-processing-effect.ts b/src/effects/src/post-processing-effect.tsnew file mode 100644index 000000000..5b1f6253b--- /dev/null+++ b/src/effects/src/post-processing-effect.ts@@ -0,0 +1,138 @@+import {PostProcessEffect as DeckPostProcessEffect} from '@deck.gl/core';+import {+ brightnessContrast,+ ink,+ triangleBlur,+ hueSaturation,+ vibrance,+ colorHalftone,+ dotScreen,+ edgeWork,+ noise,+ sepia,+ tiltShift,+ vignette,+ zoomBlur,+ magnify,+ hexagonalPixelate+} from '@luma.gl/shadertools';++import {+ POSTPROCESSING_EFFECTS,+ EFFECT_DESCS,+ DEFAULT_POST_PROCESSING_EFFECT_TYPE+} from '@kepler.gl/constants';+import {EffectConfig, EffectParamsPartial} from '@kepler.gl/types';++import Effect from './effect';++const POSTPROCESSING_EFFECTS_DESCS = [+ {+ ...POSTPROCESSING_EFFECTS.ink,+ class: ink+ },+ {+ ...POSTPROCESSING_EFFECTS.brightnessContrast,+ class: brightnessContrast+ },+ {+ ...POSTPROCESSING_EFFECTS.hueSaturation,+ class: hueSaturation+ },+ {+ ...POSTPROCESSING_EFFECTS.vibrance,+ class: vibrance+ },+ {+ ...POSTPROCESSING_EFFECTS.sepia,+ class: sepia+ },+ {+ ...POSTPROCESSING_EFFECTS.dotScreen,+ class: dotScreen+ },+ {+ ...POSTPROCESSING_EFFECTS.colorHalftone,+ class: colorHalftone+ },+ {+ ...POSTPROCESSING_EFFECTS.noise,+ class: noise+ },+ {+ ...POSTPROCESSING_EFFECTS.triangleBlur,+ class: triangleBlur+ },+ {+ ...POSTPROCESSING_EFFECTS.zoomBlur,+ class: zoomBlur+ },+ {+ ...POSTPROCESSING_EFFECTS.tiltShift,+ class: tiltShift+ },+ {+ ...POSTPROCESSING_EFFECTS.edgeWork,+ class: edgeWork+ },+ {+ ...POSTPROCESSING_EFFECTS.vignette,+ class: vignette+ },+ {+ ...POSTPROCESSING_EFFECTS.magnify,+ class: magnify+ },+ {+ ...POSTPROCESSING_EFFECTS.hexagonalPixelate,+ class: hexagonalPixelate+ }+];++class PostProcessingEffect extends Effect {+ // deckEffect: PostProcessEffect | LightingEffect | null;++ constructor(props: EffectParamsPartial) {+ super(props);+ }++ _initializeEffect() {+ const effectDesc = POSTPROCESSING_EFFECTS_DESCS.find(desc => desc.type === this.config.type);+ if (effectDesc) {+ this.deckEffect = new DeckPostProcessEffect(effectDesc.class, this.config.params);++ const uniforms = this.deckEffect?.module?.uniforms;+ if (uniforms) {+ // get default params+ const keys = Object.keys(uniforms);+ const defaultParams = {};+ keys.forEach(key => {+ defaultParams[key] = uniforms[key].value ?? uniforms[key];+ });+ this.config.params = {...defaultParams, ...this.config.params};+ }+ }+ }++ _getDefaultEffectConfig(config: Partial<EffectConfig> = {}) {+ const type = config.type || DEFAULT_POST_PROCESSING_EFFECT_TYPE;+ return {+ type,+ name: config.name || EFFECT_DESCS.find(desc => desc.type === type)?.name || 'Effect',+ isEnabled: config.isEnabled ?? true,+ isConfigActive: config.isConfigActive ?? true,+ params: {...(config.params || {})}+ };+ }++ updateConfig(config: Partial<EffectConfig>) {+ super.updateConfig(config);++ // any uniform updated?+ if (config.params) {+ this.deckEffect?.setProps(this.config.params);+ }+ }+}++export default PostProcessingEffect;diff --git a/src/effects/src/utils.ts b/src/effects/src/utils.tsnew file mode 100644index 000000000..45533bbdb--- /dev/null+++ b/src/effects/src/utils.ts@@ -0,0 +1,13 @@+import {Effect as EffectInterface, EffectParamsPartial} from '@kepler.gl/types';+import {LIGHT_AND_SHADOW_EFFECT} from '@kepler.gl/constants';++import LightingEffect from './lighting-effect';+import PostProcessEffect from './post-processing-effect';++export function createDeckEffectFromConfig(params: Partial<EffectParamsPartial>): EffectInterface {+ if (params?.config?.type === LIGHT_AND_SHADOW_EFFECT.type) {+ return new LightingEffect(params);+ } else {+ return new PostProcessEffect(params);+ }+}diff --git a/src/reducers/src/vis-state-merger.ts b/src/reducers/src/vis-state-merger.tsindex 802377b16..19ab334df 100644--- a/src/reducers/src/vis-state-merger.ts+++ b/src/reducers/src/vis-state-merger.ts@@ -21,13 +21,13 @@import uniq from 'lodash.uniq';import pick from 'lodash.pick';import flattenDeep from 'lodash.flattendeep';+import deepmerge from 'deepmerge';import {arrayInsert,getInitialMapLayersForSplitMap,applyFiltersToDatasets,validateFiltersUpdateDatasets,- findById,- mergeEffectParams+ findById} from '@kepler.gl/utils';import {getLayerOrderFromLayers} from '@kepler.gl/reducers';@@ -465,11 +465,7 @@ export function mergeEffects<S extends VisState>(.map(effect =>fromConfig? // collapse all panels when loading effects-- createDeckEffectFromConfig(- // @ts-expect-error- mergeEffectParams(effect, {config: {isConfigActive: false}})- )+ createDeckEffectFromConfig(deepmerge(effect, {config: {isConfigActive: false}})): (effect as EffectType)).filter(effect => {diff --git a/src/types/effects.d.ts b/src/types/effects.d.tsindex eaa2851e2..3b351a848 100644--- a/src/types/effects.d.ts+++ b/src/types/effects.d.ts@@ -22,7 +22,7 @@ export interface Effect {config: EffectConfig;deckEffect: any;- getDefaultEffectConfig(config: Partial<EffectConfig>): EffectConfig;+ _getDefaultEffectConfig(config: Partial<EffectConfig>): EffectConfig;updateConfig(config: Partial<EffectConfig>): void;isValidToSave(): boolean;get type(): string;diff --git a/src/utils/src/color-utils.ts b/src/utils/src/color-utils.tsindex 11bda2c45..d06946a5e 100644--- a/src/utils/src/color-utils.ts+++ b/src/utils/src/color-utils.ts@@ -139,3 +139,10 @@ export function isRgbColor(color: unknown): boolean {color.every(n => Number.isFinite(n) && n <= 255 && n >= 0));}++/**+ * Take color values in 0-255 range and map to [0, 1]+ */+export function normalizeColor(color: number[]): number[] {+ return color.map(component => component / 255.0);+}diff --git a/src/utils/src/effect-utils.ts b/src/utils/src/effect-utils.tsindex 007b22817..861379e15 100644--- a/src/utils/src/effect-utils.ts+++ b/src/utils/src/effect-utils.ts@@ -3,10 +3,10 @@ import SunCalc from 'suncalc';import {PostProcessEffect} from '@deck.gl/core/typed';-import {LIGHT_AND_SHADOW_EFFECT} from '@kepler.gl/constants';+import {LIGHT_AND_SHADOW_EFFECT, LIGHT_AND_SHADOW_EFFECT_TIME_MODES} from '@kepler.gl/constants';import {findById} from './utils';import {VisState} from '@kepler.gl/schemas';-import {MapState, EffectParams, Effect} from '@kepler.gl/types';+import {MapState, Effect} from '@kepler.gl/types';export function computeDeckEffects({visState,@@ -15,6 +15,7 @@ export function computeDeckEffects({visState: VisState;mapState: MapState;}): PostProcessEffect[] {+ // TODO: 1) deck effects per deck context 2) preserved between drawslet effects = visState.effectOrder.map(effectId => {return findById(effectId)(visState.effects);@@ -23,7 +24,18 @@ export function computeDeckEffects({const lightShadowEffect = effects.find(effect => effect.type === LIGHT_AND_SHADOW_EFFECT.type);if (lightShadowEffect) {- const {timestamp} = lightShadowEffect.config.params;+ const {timestamp, timeMode} = lightShadowEffect.config.params;++ if (timeMode === LIGHT_AND_SHADOW_EFFECT_TIME_MODES.current) {+ lightShadowEffect.deckEffect.directionalLights[0].timestamp = Date.now();+ } else if (timeMode === LIGHT_AND_SHADOW_EFFECT_TIME_MODES.animation) {+ // TODO: find an easy way to get current animation time+ const filter = visState.filters.find(filter => filter.fieldType === 'timestamp');+ if (filter) {+ lightShadowEffect.deckEffect.directionalLights[0].timestamp = filter.value?.[0] ?? 0;+ }+ }+if (!isDaytime(mapState.latitude, mapState.longitude, timestamp)) {// TODO: interpolate for dusk/dawn// TODO: Should we avoid mutating the effect? (didn't work when tried defensive copying)@@ -33,23 +45,6 @@ export function computeDeckEffects({return effects.map(effect => effect.deckEffect);}-export function mergeEffectParams(- params: Partial<EffectParams>,- extraParams: Partial<EffectParams>-): Partial<EffectParams> {- const p1 = params || {};- const p2 = extraParams || {};- return {- ...p1,- ...p2,- // @ts-expect-error- config: {- ...(p1.config || {}),- ...(p2.config || {})- }- };-}-/*** Always keep light & shadow effect at the top*/diff --git a/src/utils/src/index.ts b/src/utils/src/index.tsindex 10e32be99..3736c23a0 100644--- a/src/utils/src/index.ts+++ b/src/utils/src/index.ts@@ -28,7 +28,8 @@ export {reverseColorRange,createLinearGradient,colorMaybeToRGB,- isRgbColor+ isRgbColor,+ normalizeColor} from './color-utils';export {errorNotification} from './notifications-utils';@@ -97,7 +98,7 @@ export * from './utils';export * from './split-map-utils';export {snapToMarks} from './plot';-export {computeDeckEffects, fixEffectOrder, mergeEffectParams, reorderEffectOrder} from './effect-utils';+export {computeDeckEffects, fixEffectOrder, reorderEffectOrder} from './effect-utils';// Mapboxexport {transformRequest, isStyleUsingMapboxTiles} from './map-style-utils/mapbox-utils';diff --git a/test/browser/components/effects/effect-configurator-test.js b/test/browser/components/effects/effect-configurator-test.jsnew file mode 100644index 000000000..f7471c8bd--- /dev/null+++ b/test/browser/components/effects/effect-configurator-test.js@@ -0,0 +1,103 @@+// Copyright (c) 2023 Uber Technologies, Inc.+//+// Permission is hereby granted, free of charge, to any person obtaining a copy+// of this software and associated documentation files (the "Software"), to deal+// in the Software without restriction, including without limitation the rights+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+// copies of the Software, and to permit persons to whom the Software is+// furnished to do so, subject to the following conditions:+//+// The above copyright notice and this permission notice shall be included in+// all copies or substantial portions of the Software.+//+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+// THE SOFTWARE.++import React from 'react';+import test from 'tape';++import {appInjector, EffectConfiguratorFactory} from '@kepler.gl/components';+import {VisStateActions} from '@kepler.gl/actions';+import {visStateReducer} from '@kepler.gl/reducers';++import {mountWithTheme, IntlWrapper} from 'test/helpers/component-utils';+import {StateWEffects, InitialState} from 'test/helpers/mock-state';++const EffectConfigurator = appInjector.get(EffectConfiguratorFactory);++test('Components -> EffectConfigurator -> render -> post processing effect', t => {+ const testCases = [+ {+ // configurator for magnify effect with [x, y] and plain number uniforms+ effect: StateWEffects.visState.effects[2],+ expectedSliders: 5+ },+ {+ // configurator for ink effect with uniforom.value+ effect: StateWEffects.visState.effects[1],+ expectedSliders: 1+ }+ ];++ testCases.forEach(({effect, expectedSliders}) => {+ let wrapper;+ t.doesNotThrow(() => {+ wrapper = mountWithTheme(+ <IntlWrapper>+ <EffectConfigurator+ {...{+ effect,+ updateEffectConfig: () => {}+ }}+ />+ </IntlWrapper>+ );+ }, `EffectConfigurator for ${effect.type} should not fail`);++ t.equal(+ wrapper.find('RangeSlider').length,+ expectedSliders,+ `should render ${expectedSliders} RangeSlider(s)`+ );+ });++ t.end();+});++test('Components -> EffectConfigurator -> render -> light & shadow effect', t => {+ let nextState = visStateReducer(+ InitialState.visState,+ VisStateActions.addEffect({+ config: {type: 'lightAndShadow'}+ })+ );++ let wrapper;+ t.doesNotThrow(() => {+ wrapper = mountWithTheme(+ <IntlWrapper>+ <EffectConfigurator+ {...{+ effect: nextState.effects[0],+ updateEffectConfig: () => {}+ }}+ />+ </IntlWrapper>+ );+ }, `EffectConfigurator for ${nextState.effects[0].type} should not fail`);++ t.equal(wrapper.find('RangeSlider').length, 4, `should render 4 RangeSliders`);+ t.equal(wrapper.find('ColorSelector').length, 3, `should render 3 ColorSelectors`);+ t.equal(+ wrapper.find('EffectTimeConfigurator').length,+ 1,+ `should render 1 EffectTimeConfigurator`+ );++ t.end();+});diff --git a/test/browser/components/effects/effect-manager-test.js b/test/browser/components/effects/effect-manager-test.jsnew file mode 100644index 000000000..737f57fe9--- /dev/null+++ b/test/browser/components/effects/effect-manager-test.js@@ -0,0 +1,77 @@+// Copyright (c) 2023 Uber Technologies, Inc.+//+// Permission is hereby granted, free of charge, to any person obtaining a copy+// of this software and associated documentation files (the "Software"), to deal+// in the Software without restriction, including without limitation the rights+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+// copies of the Software, and to permit persons to whom the Software is+// furnished to do so, subject to the following conditions:+//+// The above copyright notice and this permission notice shall be included in+// all copies or substantial portions of the Software.+//+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+// THE SOFTWARE.++import React from 'react';+import test from 'tape';+import {Provider} from 'react-redux';+import configureStore from 'redux-mock-store';++import {+ EffectManagerFactory,+ EffectListFactory,+ SidePanelTitleFactory,+ EffectTypeSelectorFactory,+ appInjector+} from '@kepler.gl/components';++import {mountWithTheme, IntlWrapper} from 'test/helpers/component-utils';+import {StateWEffects} from 'test/helpers/mock-state';++const EffectManager = appInjector.get(EffectManagerFactory);+const EffectList = appInjector.get(EffectListFactory);+const SidePanelTitle = appInjector.get(SidePanelTitleFactory);+const EffectTypeSelector = appInjector.get(EffectTypeSelectorFactory);++const mockStore = configureStore();+const initialState = {+ demo: {+ keplerGl: {+ map: {+ visState: {+ effects: StateWEffects.visState.effects,+ effectOrder: StateWEffects.visState.effectOrder+ }+ }+ }+ }+};++test('Components -> EffectManager -> render', t => {+ let store = mockStore(initialState);++ // mount+ let wrapper;+ t.doesNotThrow(() => {+ wrapper = mountWithTheme(+ <IntlWrapper>+ <Provider store={store}>+ <EffectManager />+ </Provider>+ </IntlWrapper>+ );+ }, 'EffectManager should not fail');++ t.equal(wrapper.find(EffectList).length, 1, 'should render EffectList');+ t.equal(wrapper.find(SidePanelTitle).length, 1, 'should render SidePanelTitle');+ t.equal(wrapper.find(EffectTypeSelector).length, 1, 'should render EffectTypeSelector');+ t.equal(wrapper.find('EffectPanel').length, 3, 'should render 3 EffectPanels');++ t.end();+});diff --git a/test/browser/components/effects/index.js b/test/browser/components/effects/index.jsnew file mode 100644index 000000000..734f8d75e--- /dev/null+++ b/test/browser/components/effects/index.js@@ -0,0 +1,2 @@+import './effect-manager-test';+import './effect-configurator-test';diff --git a/test/browser/components/index.js b/test/browser/components/index.jsindex d729923d7..df18d13bf 100644--- a/test/browser/components/index.js+++ b/test/browser/components/index.js@@ -34,3 +34,4 @@ import './geocoder-panel-test';import './tooltip-config-test';import './bottom-widget-test';import './plot-container-test';+import './effects';diff --git a/test/helpers/comparison-utils.js b/test/helpers/comparison-utils.jsindex ae993175d..be10bc6d8 100644--- a/test/helpers/comparison-utils.js+++ b/test/helpers/comparison-utils.js@@ -201,6 +201,52 @@ export function cmpSavedLayers(t, expectedLayer, actualLayer, opt = {}, idx = ''}}+export function cmpEffects(t, expectedEffect, actualEffect, opts = {}) {+ if (Array.isArray(expectedEffect) && Array.isArray(actualEffect)) {+ t.equal(actualEffect.length, expectedEffect.length, 'should have same number of effects');+ expectedEffect.forEach((_, i) => {+ cmpEffects(t, expectedEffect[i], actualEffect[i], opt, String(i));+ });+ } else {+ if (!expectedEffect || !actualEffect) {+ t.equal(actualEffect, expectedEffect, `Effects don't match`);+ return;+ }++ if (opts.id) {+ t.equal(actualEffect.id, expectedEffect.id, `${actualEffect.type} effect.id should be same`);+ }++ cmpObjectKeys(+ t,+ expectedEffect.config,+ actualEffect.config,+ `${actualEffect.type} effect.config`+ );++ Object.keys(expectedEffect.config).forEach(key => {+ // test everything except id, which can be auto generated+ switch (key) {+ case 'params':+ t.deepEqual(+ actualEffect.config[key],+ expectedEffect.config[key],+ `${actualEffect.type} effect.config.${key} values should be identical`+ );+ break;+ default:+ if (typeof expectedEffect.config[key] !== 'function') {+ t.deepEqual(+ actualEffect.config[key],+ expectedEffect.config[key],+ `${actualEffect.type} effect.config.${key} should be correct`+ );+ }+ }+ });+ }+}+export function cmpDatasetData(t, expectedDatasetData, actualDatasetData, datasetId = '') {if (expectedDatasetData && actualDatasetData) {cmpObjectKeys(diff --git a/test/helpers/mock-state.js b/test/helpers/mock-state.jsindex 0154ecfc3..b7de1b88a 100644--- a/test/helpers/mock-state.js+++ b/test/helpers/mock-state.js@@ -248,6 +248,26 @@ function mockStateWithMultiFilters() {return prepareState;}+function mockStateWithEffects() {+ const initialState = cloneDeep(InitialState);++ let prepareState = applyActions(keplerGlReducer, initialState, [+ {+ action: VisStateActions.addEffect,+ payload: [{id: 'e_1'}]+ },+ {+ action: VisStateActions.addEffect,+ payload: [{id: 'e_2', config: {type: 'sepia'}}]+ },+ {+ action: VisStateActions.addEffect,+ payload: [{id: 'e_3', config: {type: 'magnify'}}]+ }+ ]);+ return prepareState;+}+function mockStateWithH3Layer() {const initialState = cloneDeep(InitialState);@@ -881,6 +901,7 @@ export const expectedLoadedLayer2 = {export const StateWFiles = mockStateWithFileUpload();export const StateWFilters = mockStateWithFilters();+export const StateWEffects = mockStateWithEffects();export const StateWFilesFiltersLayerColor = mockStateWithLayerDimensions(StateWFilters);export const StateWMultiFilters = mockStateWithMultiFilters();diff --git a/test/node/reducers/vis-state-test.js b/test/node/reducers/vis-state-test.jsindex f0385e1c0..b3bbd8242 100644--- a/test/node/reducers/vis-state-test.js+++ b/test/node/reducers/vis-state-test.js@@ -75,6 +75,7 @@ import {mockPolygonFeature, mockPolygonFeature2, mockPolygonData} from 'test/fiximport {cmpFilters,cmpLayers,+ cmpEffects,cmpDatasets,cmpDataset,cmpObjectKeys,@@ -5484,3 +5485,140 @@ test('VisStateUpdater -> applyLayerConfig', t => {t.end();});++test('#VisStateUpdater -> addEffect', t => {+ const initialState = InitialState.visState;++ let nextState = reducer(initialState, VisStateActions.addEffect({}));++ t.equal(nextState.effects.length, 1, 'should add a default effect');++ const expectedEffect = {+ config: {+ type: 'ink',+ name: 'Ink',+ isEnabled: true,+ isConfigActive: true,+ params: {strength: 0.25}+ }+ };++ cmpEffects(t, expectedEffect, nextState.effects[0]);++ nextState = reducer(+ nextState,+ VisStateActions.addEffect({+ id: 'e_shadow',+ config: {type: 'lightAndShadow', params: {timestamp: 1689280466362}}+ })+ );++ t.equal(nextState.effects.length, 2, 'should add second effect');++ const expectedEffect2 = {+ id: 'e_shadow',+ config: {+ isConfigActive: true,+ isEnabled: true,+ name: 'Light & Shadow',+ params: {+ timestamp: 1689280466362,+ timeMode: 'pick',+ shadowIntensity: 0.5,+ shadowColor: [0, 0, 0],+ sunLightColor: [255, 255, 255],+ sunLightIntensity: 1,+ ambientLightColor: [255, 255, 255],+ ambientLightIntensity: 1+ },+ type: 'lightAndShadow'+ }+ };++ cmpEffects(t, expectedEffect2, nextState.effects[1], {id: true});++ t.equal(+ nextState.effects[0].config.isConfigActive,+ false,+ "first effect's config should be collapsed"+ );++ nextState = reducer(nextState, VisStateActions.addEffect({}));++ t.equal(nextState.effectOrder.length, 3, 'should be 3 ids in effectOrder');++ t.equal(nextState.effectOrder[0], 'e_shadow', 'shadow effect should stay as first effect');++ t.end();+});++test('#VisStateUpdater -> updateEffect', t => {+ const initialState = InitialState.visState;++ let nextState = reducer(initialState, VisStateActions.addEffect({id: 'e_1'}));+ nextState = reducer(nextState, VisStateActions.addEffect({}));++ const expectedEffect = {+ id: 'e_1',+ config: {+ type: 'ink',+ name: 'changed name',+ isEnabled: false,+ isConfigActive: false,+ params: {+ strength: 0.06+ }+ }+ };++ nextState = reducer(nextState, VisStateActions.updateEffect('e_1', expectedEffect.config));++ cmpEffects(t, expectedEffect, nextState.effects[0], {id: true});++ // bad id, shouldn't fail+ nextState = reducer(nextState, VisStateActions.updateEffect('fake_id', {}));++ t.end();+});++test('#VisStateUpdater -> reorderEffect', t => {+ const initialState = InitialState.visState;++ let nextState = reducer(initialState, VisStateActions.addEffect({id: 'e_1'}));+ nextState = reducer(nextState, VisStateActions.addEffect({id: 'e_2'}));+ nextState = reducer(nextState, VisStateActions.addEffect({id: 'e_3'}));++ t.deepEqual(nextState.effectOrder, ['e_3', 'e_2', 'e_1'], 'effect order should be correct order');++ nextState = reducer(nextState, VisStateActions.reorderEffect(['e_2', 'e_1', 'e_3']));++ t.deepEqual(+ nextState.effectOrder,+ ['e_2', 'e_1', 'e_3'],+ 'effect order should be correct after '+ );++ t.end();+});++test('#VisStateUpdater -> removeEffect', t => {+ const initialState = InitialState.visState;++ let nextState = reducer(initialState, VisStateActions.addEffect({id: 'e_1'}));+ nextState = reducer(nextState, VisStateActions.addEffect({id: 'e_2'}));+ nextState = reducer(nextState, VisStateActions.addEffect({id: 'e_3'}));++ nextState = reducer(nextState, VisStateActions.removeEffect('e_2'));++ t.deepEqual(nextState.effects.length, 2, 'effect should be removed');++ t.deepEqual(nextState.effects[0].id, 'e_1', 'e_1 effect should be available');+ t.deepEqual(nextState.effects[1].id, 'e_3', 'e_3 effect should be available');++ // bad id, shouldn't fail+ nextState = reducer(nextState, VisStateActions.removeEffect('e_2'));++ t.equal(nextState.effectOrder.length, 2, 'should be 2 ids in effectOrder');++ t.end();+});diff --git a/test/node/schemas/vis-state-schema-test.js b/test/node/schemas/vis-state-schema-test.jsindex 9cc8889bd..5c6a0a3a9 100644--- a/test/node/schemas/vis-state-schema-test.js+++ b/test/node/schemas/vis-state-schema-test.js@@ -26,6 +26,7 @@ import SchemaManager, {CURRENT_VERSION, visStateSchema} from '@kepler.gl/schemasimport {StateWFiles,StateWFilesFiltersLayerColor,+ StateWEffects,StateWTooltipFormat,expectedSavedLayer0,expectedLoadedLayer0,@@ -341,3 +342,43 @@ test('visStateSchema -> saving with a null column value does not throw an error't.end();});++test('#visStateSchema -> v1 -> save load effects', t => {+ const expectedEffects = [+ {+ id: 'e_3',+ config: {+ type: 'magnify',+ isEnabled: true,+ params: {+ screenXY: [0, 0],+ radiusPixels: 200,+ zoom: 2,+ borderWidthPixels: 0,+ borderColor: [255, 255, 255, 255]+ }+ }+ },+ {+ id: 'e_2',+ config: {type: 'sepia', isEnabled: true, params: {amount: 0.5}}+ },+ {+ id: 'e_1',+ config: {type: 'ink', isEnabled: true, params: {strength: 0.25}}+ }+ ];++ const initialState = cloneDeep(StateWEffects);++ const savedState = SchemaManager.getConfigToSave(initialState);+ const savedEffects = savedState.config.visState.effects;++ const loadedState = SchemaManager.parseSavedConfig(savedState);+ const loadedEffects = loadedState.visState.effects;++ t.deepEqual(savedEffects, expectedEffects, 'Effects should be saved as expected');+ t.deepEqual(loadedEffects, expectedEffects, 'Effects should be loaded as expected');++ t.end();+});diff --git a/test/node/utils/effect-utils-test.js b/test/node/utils/effect-utils-test.jsnew file mode 100644index 000000000..9c46052f9--- /dev/null+++ b/test/node/utils/effect-utils-test.js@@ -0,0 +1,58 @@+import {LightingEffect, PostProcessEffect} from '@deck.gl/core';+import test from 'tape';++import {computeDeckEffects} from '@kepler.gl/utils';+import {VisStateActions} from '@kepler.gl/actions';+import {visStateReducer} from '@kepler.gl/reducers';+import {createDeckEffectFromConfig} from '@kepler.gl/effects';++import {InitialState} from 'test/helpers/mock-state';++test('effectUtils -> computeDeckEffects', t => {+ const initialState = InitialState.visState;+ let nextState = visStateReducer(+ initialState,+ VisStateActions.addEffect({id: 'e_1', config: {type: 'sepia', isEnabled: false}})+ );+ nextState = visStateReducer(+ initialState,+ VisStateActions.addEffect({id: 'e_1', config: {type: 'ink'}})+ );+ nextState = visStateReducer(+ nextState,+ VisStateActions.addEffect({+ id: 'e_shadow',+ config: {type: 'lightAndShadow', params: {timestamp: 1689383452635}}+ })+ );++ let deckEffects = computeDeckEffects({+ visState: nextState,+ mapState: {latitude: 51.033105, longitude: 0.348512}+ });++ t.equal(deckEffects.length, 2, "disabled deck effects aren't not generated");+ t.ok(deckEffects[0] instanceof LightingEffect, 'lighting effect should be generated');+ t.ok(deckEffects[1] instanceof PostProcessEffect, 'post-processing effect should be generated');++ t.equal(deckEffects[0].shadowColor[3], 0, 'shadows should be disabled');++ nextState.effects[1].updateConfig({params: {timestamp: 1689415852635}});+ deckEffects = computeDeckEffects({+ visState: nextState,+ mapState: {latitude: 51.033105, longitude: 0.348512}+ });+ t.equal(deckEffects[0].shadowColor[3], 0.5, 'shadows should be enabled');++ t.end();+});++test('effectUtils -> createDeckEffectFromConfig', t => {+ const ppEffect = createDeckEffectFromConfig({});+ const lasEffect = createDeckEffectFromConfig({config: {type: 'lightAndShadow'}});++ t.equal(ppEffect.config.type, 'ink', 'should create default ink effect');+ t.equal(lasEffect.config.type, 'lightAndShadow', 'should create lightAndShadow effect');++ t.end();+});diff --git a/test/node/utils/index.js b/test/node/utils/index.jsindex f5df834c6..9eadc4d8a 100644--- a/test/node/utils/index.js+++ b/test/node/utils/index.js@@ -40,3 +40,4 @@ import './kepler-gl-utils-test';import './timeline-test';import './composer-helpers-test';import './dom-to-image';+import './effect-utils-test';