Skip to content

Commit

Permalink
Merge branch 'main' into ACT-1219-performance-optimisations
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarvv committed Dec 19, 2024
2 parents 26e9c27 + 0bd3b55 commit 8527e1f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/App/components/Nova.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export const AvatarNova: FC = () => {
))}
</SettingsPanel>
<Avatar
controlsMinDistance={CAMERA.CONTROLS.FULL_BODY.MAX_DISTANCE}
controlsMaxDistance={CAMERA.CONTROLS.FULL_BODY.MAX_DISTANCE}
modelSrc={modelSrc}
emotion={emotions.smile}
animations={animations}
Expand Down
22 changes: 20 additions & 2 deletions src/components/Avatar/Avatar.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ export interface AvatarProps extends LightingProps, EnvironmentProps, Omit<BaseM
*/
materialConfig?: MaterialConfiguration;
onAnimationEnd?: (action: AnimationAction) => void;
controlsMinDistance?: number;
controlsMaxDistance?: number;
/**
* Control properties of the BaseCanvas.
*/
Expand Down Expand Up @@ -211,6 +213,8 @@ const Avatar: FC<AvatarProps> = ({
fov = 50,
onAnimationEnd,
materialConfig,
controlsMinDistance,
controlsMaxDistance,
canvasConfig
}) => {
const setSpawnState = useSetAtom(spawnState);
Expand Down Expand Up @@ -315,6 +319,20 @@ const Avatar: FC<AvatarProps> = ({
useEffect(() => triggerCallback(onLoading), [modelSrc, animationSrc, onLoading]);

const enablePostProcessing = Boolean(effects?.ambientOcclusion || effects?.bloom || effects?.vignette);
const cameraControlsMinDistance = useMemo(() => {
if (controlsMinDistance) {
return controlsMinDistance;
}

return halfBody ? CAMERA.CONTROLS.HALF_BODY.MIN_DISTANCE : CAMERA.CONTROLS.FULL_BODY.MIN_DISTANCE;
}, [controlsMinDistance, halfBody]);
const cameraControlsMaxDistance = useMemo(() => {
if (controlsMaxDistance) {
return controlsMaxDistance;
}

return halfBody ? CAMERA.CONTROLS.HALF_BODY.MAX_DISTANCE : CAMERA.CONTROLS.FULL_BODY.MAX_DISTANCE;
}, [controlsMaxDistance, halfBody]);

return (
<BaseCanvas
Expand All @@ -331,8 +349,8 @@ const Avatar: FC<AvatarProps> = ({
cameraTarget={cameraTarget}
cameraInitialDistance={cameraInitialDistance}
cameraZoomTarget={cameraZoomTarget}
controlsMinDistance={halfBody ? CAMERA.CONTROLS.HALF_BODY.MIN_DISTANCE : CAMERA.CONTROLS.FULL_BODY.MIN_DISTANCE}
controlsMaxDistance={halfBody ? CAMERA.CONTROLS.HALF_BODY.MAX_DISTANCE : CAMERA.CONTROLS.FULL_BODY.MAX_DISTANCE}
controlsMinDistance={cameraControlsMinDistance}
controlsMaxDistance={cameraControlsMaxDistance}
updateCameraTargetOnZoom={!halfBody}
/>
{AvatarModel}
Expand Down

0 comments on commit 8527e1f

Please sign in to comment.