Skip to content

Commit 992f501

Browse files
igorDykhtabdjulbicCopilotIhor Dykhta
authored
fix(effects): fixes for effects regressions (#3376)
* fix: fixes for effects regressions Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com> * possible fixes Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com> Signed-off-by: Ihor Dykhta <ihordykhta@Ihors-MacBook-Pro.local> * fix: update allow hover tooltip (#3377) * update allow hover tooltip Signed-off-by: bdjulbic <bdjulbic@foursquare.com> * Update src/constants/src/layers.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: bdjulbic <bdjulbic@foursquare.com> * update allow hover tooltip Signed-off-by: bdjulbic <bdjulbic@foursquare.com> --------- Signed-off-by: bdjulbic <bdjulbic@foursquare.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ihor Dykhta <ihordykhta@Ihors-MacBook-Pro.local> * fix: video export fixes (#3378) * fix: video export fixes Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com> * cleanup; patch on mount Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com> * tests Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com> --------- Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com> Signed-off-by: Ihor Dykhta <ihordykhta@Ihors-MacBook-Pro.local> * revert extra Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com> Signed-off-by: Ihor Dykhta <ihordykhta@Ihors-MacBook-Pro.local> * color fixes Signed-off-by: Ihor Dykhta <ihordykhta@Ihors-MacBook-Pro.local> * fix video export and tiled layers Signed-off-by: Ihor Dykhta <ihordykhta@Ihors-MacBook-Pro.local> * fix light intensity Signed-off-by: Ihor Dykhta <ihordykhta@Ihors-MacBook-Pro.local> * extend far frustum - prevent cutting off far geometries Signed-off-by: Ihor Dykhta <ihordykhta@Ihors-MacBook-Pro.local> * animate fog/sea level Signed-off-by: Ihor Dykhta <ihordykhta@Ihors-MacBook-Pro.local> * get 'water leve' animation Signed-off-by: Ihor Dykhta <ihordykhta@Ihors-MacBook-Pro.local> * lint Signed-off-by: Ihor Dykhta <ihordykhta@Ihors-MacBook-Pro.local> * fix attribution Signed-off-by: Ihor Dykhta <ihordykhta@Ihors-MacBook-Pro.local> * follow ups Signed-off-by: Ihor Dykhta <ihordykhta@Ihors-MacBook-Pro.local> * follow up fixes Signed-off-by: Ihor Dykhta <ihordykhta@Ihors-MacBook-Pro.local> * minor follow up Signed-off-by: Ihor Dykhta <ihordykhta@Ihors-MacBook-Pro.local> * refactor and follow ups Signed-off-by: Ihor Dykhta <ihordykhta@Ihors-MacBook-Pro.local> --------- Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com> Signed-off-by: Ihor Dykhta <ihordykhta@Ihors-MacBook-Pro.local> Signed-off-by: bdjulbic <bdjulbic@foursquare.com> Co-authored-by: bdjulbic <157624032+bdjulbic@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Ihor Dykhta <ihordykhta@Ihors-MacBook-Pro.local>
1 parent 806a32d commit 992f501

25 files changed

Lines changed: 1118 additions & 96 deletions

src/components/src/effects/effect-configurator.tsx

Lines changed: 96 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ import {Effect, EffectUpdateProps} from '@kepler.gl/types';
1111

1212
import RangeSliderFactory from '../common/range-slider';
1313
import {ArrowDownSmall} from '../common/icons';
14+
import {Tooltip} from '../common/styled-components';
1415
import EffectTimeConfiguratorFactory from './effect-time-configurator';
1516
import CompactColorPicker from './compact-color-picker';
17+
import SurfaceFogElevationSectionFactory, {ELEVATION_SECTION_TYPE} from './surface-fog-section';
1618

1719
export type EffectConfiguratorProps = {
1820
effect: Effect;
@@ -160,6 +162,35 @@ const StyledCheckboxLabel = styled.label`
160162
white-space: nowrap;
161163
`;
162164

165+
const StyledHintTooltip = styled(Tooltip)`
166+
&.__react_component_tooltip {
167+
max-width: 220px;
168+
white-space: normal;
169+
line-height: 1.4;
170+
text-align: left;
171+
}
172+
`;
173+
174+
const StyledHintIcon = styled.span`
175+
display: inline-flex;
176+
align-items: center;
177+
justify-content: center;
178+
width: 14px;
179+
height: 14px;
180+
margin-left: 6px;
181+
border-radius: 50%;
182+
font-size: 9px;
183+
font-weight: 600;
184+
line-height: 1;
185+
color: ${props => props.theme.labelColor};
186+
border: 1px solid ${props => props.theme.labelColor};
187+
cursor: help;
188+
&:hover {
189+
color: ${props => props.theme.textColorHl};
190+
border-color: ${props => props.theme.textColorHl};
191+
}
192+
`;
193+
163194
const StyledColorCheckboxRow = styled.div`
164195
display: flex;
165196
align-items: center;
@@ -178,17 +209,23 @@ type EffectParameterDescriptionFlattened = {
178209
name: string;
179210
type?: 'number' | 'array' | 'color' | 'checkbox';
180211
label?: string | false | (string | false)[];
212+
tooltip?: string;
181213
min: number;
182214
max: number;
183215
defaultValue?: number | number[] | boolean;
184216
index?: number;
185217
};
186218

187-
EffectConfiguratorFactory.deps = [RangeSliderFactory, EffectTimeConfiguratorFactory];
219+
EffectConfiguratorFactory.deps = [
220+
RangeSliderFactory,
221+
EffectTimeConfiguratorFactory,
222+
SurfaceFogElevationSectionFactory
223+
];
188224

189225
export default function EffectConfiguratorFactory(
190226
RangeSlider: ReturnType<typeof RangeSliderFactory>,
191-
EffectTimeConfigurator: ReturnType<typeof EffectTimeConfiguratorFactory>
227+
EffectTimeConfigurator: ReturnType<typeof EffectTimeConfiguratorFactory>,
228+
SurfaceFogElevationSection: ReturnType<typeof SurfaceFogElevationSectionFactory>
192229
): React.FC<EffectConfiguratorProps> {
193230
const ShadowEffectConfigurator: React.FC<EffectConfiguratorProps> = ({
194231
effect,
@@ -198,17 +235,21 @@ export default function EffectConfiguratorFactory(
198235

199236
const sliderProps = useMemo(() => {
200237
const propNames = ['shadowIntensity', 'ambientLightIntensity', 'sunLightIntensity'];
238+
const descriptions = effect.getParameterDescriptions();
201239
return propNames.map(propName => {
240+
const desc = descriptions.find(d => d.name === propName);
241+
const min = desc?.min ?? 0;
242+
const max = desc?.max ?? 1;
202243
return {
203244
value1: parameters[propName],
204-
range: [0, 1],
205-
value0: 0,
245+
range: [min, max],
246+
value0: min,
206247
onChange: (value: number[], event?: Event | null) => {
207248
updateEffectConfig(event, id, {parameters: {[propName]: value[1]}});
208249
}
209250
};
210251
});
211-
}, [id, parameters, updateEffectConfig]);
252+
}, [id, effect, parameters, updateEffectConfig]);
212253

213254
const onTimeParametersChanged = useCallback(
214255
parameters => {
@@ -309,20 +350,30 @@ export default function EffectConfiguratorFactory(
309350
};
310351
const defaultUniforms = {};
311352

353+
const ELEVATION_EXTRA_PARAMS = new Set(['heightEnd', 'animateHeight', 'linearEasing']);
354+
312355
const PostProcessingEffectConfigurator: React.FC<EffectConfiguratorProps> = ({
313356
effect,
314357
updateEffectConfig
315358
}) => {
316359
const uniforms = effect.deckEffect?.module.propTypes || defaultUniforms;
317360
const parameterDescriptions = effect.getParameterDescriptions();
318361
const {parameters, id} = effect;
362+
363+
const hasElevationSection = parameterDescriptions.some(d => d.name === 'animateHeight');
364+
319365
const flatParameterDescriptions = useMemo(() => {
320366
return parameterDescriptions.reduce((acc, description) => {
367+
if (hasElevationSection && ELEVATION_EXTRA_PARAMS.has(description.name)) return acc;
368+
369+
if (hasElevationSection && description.name === 'height') {
370+
acc.push({...description, type: ELEVATION_SECTION_TYPE as any});
371+
return acc;
372+
}
373+
321374
if (description.type === 'color') {
322-
// color parameters are rendered separately via CompactColorPicker
323375
acc.push(description);
324376
} else if (description.type === 'array') {
325-
// split arrays of controls into a separate controls for each component
326377
if (Array.isArray(description.defaultValue)) {
327378
description.defaultValue.forEach((_, index) => {
328379
acc.push({
@@ -338,10 +389,14 @@ export default function EffectConfiguratorFactory(
338389

339390
return acc;
340391
}, [] as EffectParameterDescriptionFlattened[]);
341-
}, [parameterDescriptions]);
392+
}, [parameterDescriptions, hasElevationSection]);
342393

343394
const controls = useMemo(() => {
344395
return flatParameterDescriptions.map(desc => {
396+
if ((desc.type as string) === ELEVATION_SECTION_TYPE) {
397+
return {isElevationSection: true as const};
398+
}
399+
345400
if (desc.type === 'color') {
346401
return {
347402
isColor: true as const,
@@ -354,11 +409,13 @@ export default function EffectConfiguratorFactory(
354409
}
355410

356411
if (desc.type === 'checkbox') {
412+
const label = typeof desc.label === 'string' ? desc.label : desc.name;
357413
return {
358414
isCheckbox: true as const,
359-
label: typeof desc.label === 'string' ? desc.label : desc.name,
415+
label,
360416
paramName: desc.name,
361417
checked: Boolean(parameters[desc.name]),
418+
tooltip: desc.tooltip,
362419
onChange: () =>
363420
updateEffectConfig(null, id, {parameters: {[desc.name]: !parameters[desc.name]}})
364421
};
@@ -428,7 +485,6 @@ export default function EffectConfiguratorFactory(
428485
};
429486
}
430487
// Parameter defined in effect description but not in shader propTypes
431-
// (e.g. user-facing props that the effect maps to different GLSL uniforms)
432488
else if (desc.min !== undefined && desc.max !== undefined) {
433489
const rangeSpan = desc.max - desc.min;
434490
const step = rangeSpan > 10 ? 1 : 0.001;
@@ -464,6 +520,9 @@ export default function EffectConfiguratorFactory(
464520
if ('isColor' in control) {
465521
const nextControl = i + 1 < controls.length ? controls[i + 1] : null;
466522
if (nextControl && 'isCheckbox' in nextControl) {
523+
const cbTooltipId = nextControl.tooltip
524+
? `effect-cb-hint-${effect.id}-${i}`
525+
: undefined;
467526
elements.push(
468527
<StyledColorCheckboxRow key={`${effect.id}-${i}`}>
469528
<CompactColorPicker
@@ -487,6 +546,20 @@ export default function EffectConfiguratorFactory(
487546
onClick={e => e.stopPropagation()}
488547
/>
489548
<StyledCheckboxLabel>{nextControl.label}</StyledCheckboxLabel>
549+
{nextControl.tooltip ? (
550+
<>
551+
<StyledHintIcon
552+
data-tip
553+
data-for={cbTooltipId}
554+
onClick={e => e.stopPropagation()}
555+
>
556+
?
557+
</StyledHintIcon>
558+
<StyledHintTooltip id={cbTooltipId} effect="solid" delayShow={200}>
559+
{nextControl.tooltip}
560+
</StyledHintTooltip>
561+
</>
562+
) : null}
490563
</StyledCheckboxWrapper>
491564
</StyledColorCheckboxRow>
492565
);
@@ -533,6 +606,18 @@ export default function EffectConfiguratorFactory(
533606
continue;
534607
}
535608

609+
if ('isElevationSection' in control) {
610+
elements.push(
611+
<SurfaceFogElevationSection
612+
key={`${effect.id}-elevation`}
613+
effect={effect}
614+
updateEffectConfig={updateEffectConfig}
615+
/>
616+
);
617+
i++;
618+
continue;
619+
}
620+
536621
elements.push(
537622
<RegularOuterWrapper key={`${effect.id}-${i}`}>
538623
{control.label ? (
@@ -545,6 +630,7 @@ export default function EffectConfiguratorFactory(
545630
);
546631
i++;
547632
}
633+
548634
return elements;
549635
})()}
550636
</StyledEffectConfigurator>

0 commit comments

Comments
 (0)