From 9599567e02d02af3df51832d8fd568477264ad8f Mon Sep 17 00:00:00 2001 From: Elar Huik Date: Tue, 19 Sep 2023 13:56:42 +0300 Subject: [PATCH] feat: add fog when using reflection --- src/components/Avatar/Examples.stories.tsx | 15 +++-- .../FloorReflection.component.tsx | 57 +++++++++++-------- 2 files changed, 42 insertions(+), 30 deletions(-) diff --git a/src/components/Avatar/Examples.stories.tsx b/src/components/Avatar/Examples.stories.tsx index cc87801b..3c9856d4 100644 --- a/src/components/Avatar/Examples.stories.tsx +++ b/src/components/Avatar/Examples.stories.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { StoryFn } from '@storybook/react'; -import { Sparkles as SparklesDrei } from '@react-three/drei'; +import { Sparkles as SparklesDrei, StatsGl } from '@react-three/drei'; import type { Meta } from '@storybook/react'; import { Avatar as AvatarWrapper, CAMERA } from 'src/components/Avatar'; import { getStoryAssetPath } from 'src/services'; @@ -194,9 +194,12 @@ environmentModel.argTypes = { environment: { options: Object.keys(environmentPresets), control: { type: 'select' } } }; // @ts-ignore -export const ReflectiveFloor: StoryFn = (args: AvatarProps & FloorReflectionProps) => ( - +export const ReflectiveFloor: StoryFn = ( + args: AvatarProps & FloorReflectionProps & { debug: boolean } +) => ( + + {args?.debug && } ); ReflectiveFloor.args = { @@ -210,9 +213,8 @@ ReflectiveFloor.args = { /* eslint-disable no-console */ onLoaded: () => console.info('EVENT: environment model loaded'), /* eslint-enable no-console */ - style: { background: '#050B2D' }, // @ts-ignore - resolution: 2048, + resolution: 512, mixBlur: 0.8, mixStrength: 80, metalness: 0.5, @@ -226,7 +228,8 @@ ReflectiveFloor.args = { mixContrast: 1, reflectorOffset: 0, roughness: 1, - color: '#020411' + color: 'rgb(9,20,26)', + debug: false }; ReflectiveFloor.argTypes = { diff --git a/src/components/FloorReflection/FloorReflection.component.tsx b/src/components/FloorReflection/FloorReflection.component.tsx index fef3cd5a..f8f441c5 100644 --- a/src/components/FloorReflection/FloorReflection.component.tsx +++ b/src/components/FloorReflection/FloorReflection.component.tsx @@ -16,10 +16,13 @@ export interface FloorReflectionProps { mixContrast?: number; reflectorOffset?: number; roughness?: number; - color?: string; + /** + * The color should match the canvas background color to provide a seamless transition from background to the reflective plane. + */ + color: string; } export const FloorReflection: FC = ({ - resolution = 2048, + resolution = 512, mixBlur = 0.8, mixStrength = 80, metalness = 0.5, @@ -33,28 +36,34 @@ export const FloorReflection: FC = ({ mixContrast = 1, reflectorOffset = 0, roughness = 1, + color, ...props }) => ( - - - - - - + <> + + + + + + + + );