npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@readyplayerme/rpm-react-sdk

v0.1.5

Published

Ready Player Me React SDK

Downloads

1,170

Readme

⚠️ This package is deprecated and will not receive new updates.

Please use the following packages instead:

  • Ready Player Me - React Avatar Creator package here: https://github.com/readyplayerme/rpm-react-avatar-creator

  • Ready Player Me - Visage package here: https://github.com/readyplayerme/visage

Ready Player Me React SDK

Ready Player Me React SDK is a set of components and helper methods to help implementing Ready Player Me into React projects. With this SDK you can display Ready Player Me editor in your React project, create, edit and display avatars.

You can visit SDK Storybook and test the components here: https://readyplayerme.github.io/rpm-react-sdk

Codesandbox examples are available here: https://codesandbox.io/s/rpm-react-sdk-yii76z

Installation

Ready Player Me React SDK is available as an npm package.

npm i @readyplayerme/rpm-react-sdk

Usage

import { AvatarCreatorViewer } from '@readyplayerme/rpm-react-sdk';

export default function App() {
  return (
    <div>
      <AvatarCreatorViewer subdomain="demo"/>
    </div>
  );
}

https://user-images.githubusercontent.com/3163281/235168912-a9dacd91-af3a-4b35-81c3-b025e12e333a.mp4


Components

AvatarCreator

AvatarCreator component helps you load Ready Player Me in an iframe where you can edit your avatar and receive your avatar URL as a post message once your avatar is exported.

Parameters

subdomain [required]: string

editorConfig [optional]: EditorConfig

avatarConfig [optional]: AvatarConfig

  • Avatar Configuration is that changes the optimization properties of the generated GLB avatar model. Read more about these options in Ready Player Me documentations.

onAvatarExported [required]: (url: string) => void

  • Callback function that is called when avatar is exported.

onUserSet [optional]: (userId: string) => void

  • Callback function that is called when user id is set.

Example

const config: EditorConfig  = {
  clearCache: true;
  bodyType: 'halfbody';
  quickStart: 'false';
  language: 'tr';
}

const avatarConfig: AvatarConfig = {
  meshLod: 2,
  textureAtlas: 512,
  morphTargets: 'ARKit',
  pose: 'T',
};

const handleOnUserSet = (userId: string) => {
  console.log(`User ID is: ${userId}`)
}

const handleOnAvatarExported = (url;: string) => {
  console.log(`Avatar URL is: ${url}`)
}

<AvatarCreator subdomain="demo" editorConfig={config} avatarConfig={avatarConfig} 
  onUserSet={handleOnUserSet} onAvatarExported={handleOnAvatarExported}/>

AvatarCreatorViewer

Avatar Creator component is the combination of AvatarCreator component and Ready Player Me Visage components that helps load the generated avatar with the given configurations into a 3D canvas where you can display it.

Parameters

subdomain [required]: string

editorConfig [optional]: EditorConfig

avatarConfig [optional]: AvatarConfig

  • Avatar Configurations that changes the optimization properties of the generated GLB avatar model. Read more about these options in Ready Player Me documentations.

viewerConfig [optional]: ViewerConfig

  • Viewer Configurations that changes the properties of the 3D canvas where the avatar is displayed.

loadingNode [optional]: JSX.Element | string

  • Loading node that is displayed while avatar is loading.

onUserSet [optional]: (id: string) => void

  • Callback function that is called when user id is set.

onAvatarLoaded [optional]: () => void

  • Callback function that is called when avatar is loaded.

onAvatarExported [optional]: (url: string) => void

  • Callback function that is called when avatar is exported.

Example

const editorConfig: EditorConfig  = {
  clearCache: true;
  bodyType: 'halfbody';
  quickStart: 'false';
  language: 'tr';
};

const avatarConfig: AvatarConfig = {
  meshLod: 2,
  textureAtlas: 512,
  morphTargets: 'ARKit',
  pose: 'T',
};

const viewerConfig: ViewerConfig = {
  animationUrl: "...",
  style: {backgroundColor: "#ddd"}
};

const handleOnUserSet = (id: string) => {
  console.log(`User ID is: ${id}`)
}

const handleOnAvatarExported = (url: string) => {
  console.log(`Avatar URL is: ${url}`)
}

const handleOnAvatarLoaded = () => {
  console.log(`Avatar is loaded`)
}

<AvatarCreatorViewer subdomain="demo" 
  editorConfig={editorConfig} avatarConfig={avatarConfig} viewerConfig={viewerConfig} 
  onUserSet={handleOnUserSet} onAvatarExported={handleOnAvatarExported} onAvatarLoaded={handleOnAvatarLoaded}/>

Using AvatarCreator with Visage

If you would like to use Visage with it's full capability to edit camera and light properties of the scene and more, you can use AvatarCreator component and Visage components together.

import { Avatar } from '@readyplayerme/visage';
import { AvatarEditor, AvatarViewer } from '@readyplayerme/rpm-react-sdk';

const subdomain = 'demo';

const editorConfig: EditorConfig  = {
  clearCache: true;
  bodyType: 'fullbody';
  quickStart: 'false';
  language: 'tr';
};

export const YourCustomComponent = () => {
  const [url, setUrl] = useState<string | undefined>(undefined);

  const handleOnAvatarExported = (url: string) => {
    setUrl(url);
  }

  return <div>
    <AvatarCreator subdomain={subdomain} editorConnfig={editorConfig} onAvatarExported={handleOnAvatarExported} />
    <Avatar modelSrc={url} />
  </div>
}