Skip to content

Commit

Permalink
fix: avatar view add suspense
Browse files Browse the repository at this point in the history
  • Loading branch information
nzambello committed Sep 24, 2024
1 parent a641461 commit b3d21ca
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/components/Avatar/AvatarView/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { CSSProperties } from 'react';
import React from 'react';
import React, { Suspense } from 'react';
import FullbodyAvatar from './components/fullbodyAvatar';
import { Canvas } from '@react-three/fiber';
import { OrbitControls, SpotLight, Environment } from '@react-three/drei';
import { isAndroid, isiOS } from '../../../helpers/utils';
import { useState, useEffect } from 'react';
import AnimationControlPanel from './components/controls';
import HalfBodyAvatar from './components/halfbodyAvatar';
import Loader from './components/loader';

interface BaseAction {
weight: number;
Expand Down Expand Up @@ -221,6 +222,8 @@ export default function ContainerAvatarView({
eyeBlink,
headMovement,
speaking,
fallback,
fallbackImg,
halfBody = true,
loading,
animation,
Expand All @@ -233,19 +236,21 @@ export default function ContainerAvatarView({
}
camera={getCameraSettings(halfBody) as any}
>
{getLightingComponent()}
{rotateAvatar && <OrbitControls enablePan={false} enableZoom={false} />}
<AvatarView
halfBody={halfBody}
url={url}
sex={sex}
eyeBlink={eyeBlink}
headMovement={headMovement}
speaking={speaking}
loading={loading}
animation={animation}
showControls={showControls}
/>
<Suspense fallback={fallback || <Loader fallbackImg={fallbackImg} />}>
{getLightingComponent()}
{rotateAvatar && <OrbitControls enablePan={false} enableZoom={false} />}
<AvatarView
halfBody={halfBody}
url={url}
sex={sex}
eyeBlink={eyeBlink}
headMovement={headMovement}
speaking={speaking}
loading={loading}
animation={animation}
showControls={showControls}
/>
</Suspense>
</Canvas>
);
}

0 comments on commit b3d21ca

Please sign in to comment.