-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from readyplayerme/feature/smooth-animations
Feature/smooth animations
- Loading branch information
Showing
12 changed files
with
324 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import { Sparkles, StatsGl } from '@react-three/drei'; | ||
|
||
import { Avatar } from 'src/components/Avatar'; | ||
import { EnvironmentModel } from 'src/components/Models'; | ||
|
||
import { SettingsPanel } from './SettingsPanel'; | ||
|
||
export const AvatarDevelop: React.FC = () => ( | ||
<> | ||
<SettingsPanel /> | ||
<Avatar | ||
modelSrc="https://models.readyplayer.me/64d61e9e17883fd73ebe5eb7.glb?morphTargets=ARKit,Eyes Extra&textureAtlas=none&lod=0" | ||
shadows | ||
animationSrc="/male-idle-2.fbx" | ||
style={{ background: 'rgb(9,20,26)' }} | ||
fov={45} | ||
effects={{ | ||
ambientOcclusion: true | ||
}} | ||
> | ||
<StatsGl /> | ||
<EnvironmentModel environment="spaceStation" scale={1} /> | ||
<Sparkles count={70} scale={3} size={3} speed={1} opacity={0.04} color="#ccff00" /> | ||
</Avatar> | ||
</> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from 'react'; | ||
import { StatsGl } from '@react-three/drei'; | ||
|
||
import { Avatar, CAMERA } from 'src/components/Avatar'; | ||
import { emotions } from 'src/services/Stories.service'; | ||
import { SettingsPanel } from './SettingsPanel'; | ||
|
||
const idleUrl = 'https://readyplayerme-assets.s3.amazonaws.com/animations/nova-male-idle.glb'; | ||
const victoryUrl = 'https://readyplayerme-assets.s3.amazonaws.com/animations/nova-victory-03.glb'; | ||
const modelUrl = | ||
'https://api.readyplayer.dev/v3/avatars/66e2cecfbd5d3e60f8cdbde5.glb?meshCompression=true&textureQuality=medium&meshSimplify=0&morphTargetsGroup=Editor+combined'; | ||
|
||
const animations: Record<string, string> = { | ||
idle: idleUrl, | ||
victory: victoryUrl | ||
}; | ||
|
||
export const AvatarNova: React.FC = () => { | ||
const [activeAnimation, setActiveAnimation] = React.useState<string>('idle'); | ||
|
||
return ( | ||
<> | ||
<SettingsPanel> | ||
<button type="button" onClick={() => setActiveAnimation('idle')}> | ||
Set idle animation | ||
</button> | ||
<button type="button" onClick={() => setActiveAnimation('victory')}> | ||
Set victory animation | ||
</button> | ||
</SettingsPanel> | ||
<Avatar | ||
modelSrc={modelUrl} | ||
emotion={emotions.smile} | ||
animations={animations} | ||
activeAnimation={activeAnimation} | ||
shadows | ||
style={{ background: 'rgb(9,20,26)' }} | ||
fov={45} | ||
cameraInitialDistance={CAMERA.CONTROLS.FULL_BODY.MAX_DISTANCE} | ||
> | ||
<StatsGl /> | ||
</Avatar> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
.settings { | ||
z-index: 2; | ||
position: fixed; | ||
top: 72px; | ||
right: 24px; | ||
width: 100%; | ||
max-width: 320px; | ||
background-color: rgba(243, 243, 243, 0.9); | ||
border: 1px solid #b9b9b9; | ||
border-radius: 4px; | ||
overflow: hidden; | ||
} | ||
|
||
.wrapper { | ||
position: relative; | ||
height: 100%; | ||
width: 100%; | ||
} | ||
|
||
.title { | ||
font-size: 18px; | ||
font-weight: 600; | ||
font-family: Arial, sans-serif; | ||
color: black; | ||
display: block; | ||
padding: 8px; | ||
margin: 0; | ||
border-bottom: 1px solid #b9b9b9; | ||
} | ||
|
||
.content { | ||
position: relative; | ||
padding: 8px; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 12px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
|
||
import styles from './SettingsPanel.module.scss'; | ||
|
||
export const SettingsPanel: React.FC<React.PropsWithChildren> = ({ | ||
children = 'Drop your content in there to test the avatar props without shrinking the canvas' | ||
}) => ( | ||
<div className={styles.settings}> | ||
<div className={styles.wrapper}> | ||
<h3 className={styles.title}>localhost playground</h3> | ||
<div className={styles.content}>{children}</div> | ||
</div> | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
|
||
import { Avatar, CAMERA } from 'src/components/Avatar'; | ||
|
||
export const AvatarTest: React.FC = () => { | ||
const urlParams = new URLSearchParams(window.location.search); | ||
const modelUrl = urlParams.get('modelUrl') | ||
? decodeURIComponent(urlParams.get('modelUrl') || '') | ||
: 'https://models.readyplayer.me/64d61e9e17883fd73ebe5eb7.glb?morphTargets=ARKit,Eyes Extra&textureAtlas=none&lod=0'; | ||
const zoomLevel = urlParams.get('zoomLevel') | ||
? parseFloat(urlParams.get('zoomLevel') || '1') | ||
: CAMERA.CONTROLS.FULL_BODY.MAX_DISTANCE; | ||
|
||
return ( | ||
<Avatar | ||
modelSrc={modelUrl} | ||
shadows | ||
style={{ background: 'rgb(9,20,26)' }} | ||
fov={45} | ||
cameraInitialDistance={zoomLevel} | ||
effects={{ | ||
ambientOcclusion: true | ||
}} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.