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

@sarge/avatar-view

v0.3.4-rc.0

Published

[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/sgt3v.svg?style=social&label=Follow%20%40sgt3v)](https://twitter.com/sgt3v) [![npm version](https://badge.fury.io/js/%40sarge%2Favatar-view.svg)](https://badge.fury.io/js/%40sarge%2Favatar-

Downloads

33

Readme

Twitter npm version

3D Profile Avatars

Add your website a 3D Profile Avatar using Ready Player Me with a single line of code!

Test it on CodeSandbox: https://codesandbox.io/s/avatar-view-wrn2u


Install

  • Run npm i @sarge/avatar-view

Example

  • First visit https://readyplayer.me and create a half-body avatar.

  • Copy the url of the .glb file of the avatar you created.

  • Import AvatarView to your file.

  • Add <AvatarView type={type} url={url}/> component yo your return content

import { AvatarView } from "@sarge/avatar-view";

const type = "3D";
const url = "https://models.readyplayer.me/62ea7bc28a6d28ec134bbcce.glb";

export default function App()
{
  return <AvatarView type={type} url={url}/>
}

If you are using Next.js make sure to import the component dynamically using ssr: false parameter.

const AvatarView = dynamic(async () => (await import('@sarge/avatar-view')).AvatarView, { ssr: false })

Parameters of AvatarView

  • type ("2D" | "3D"):

    Type of the avatar 2D image or 3D model avatar.

  • url (string):

    Url of the Ready Player Me avatar to load. This parameter is mandatory.

  • style (React.CSSProperties) [optional]:

    Style of the avatar view canvas. Here you can change the border style, background color or image, width, height and other style options.

  • options2D (Options2D) [optional]:

    Options for type "2D" avatar.

    • scale (Vector2) [optional]:

      Scale of the 2D avatar image.

    • position (Vector2) [optional]:

      Position of the 2D avatar in pixels.

  • options3D (Options3D) [optional]:

    Options for type "3D" avatar.

    • quality (Quality) [optional]:

      Avatar quality option to help reduce the size of the 3D model. Can be High, Medium or Low.

    • camera (CameraOptions) [optional]:

      Ortographic camera options.

    • transform (Transform) [optional]:

      Position, rotation and scale of the 3D avatar.

    • blinkEyes (boolean) [optional]:

      Enables eye blinking in random intervals.

    • followCursor (boolean) [optional]:

      When enabled, head and eyes of the avatar will follow of the cursor. Cursor must be moving on the 3D canvas. When cursor is out of the canvas, avatar goes back to initial stance.

    • orbitControl (boolean) [optional]:

      Enables use of orbit controls for the 3D scene, which helps you rotate the avatar via mouse drag.

  • onLoaded (void) [optional]:

    Callback method get notified when 2D or 3D avatar is loaded.

  • onFailed (void) [optional]:

    Callback method get notified when 2D or 3D avatar is failed to load.

  • fallback (React.ReactNode) [optional]:

    Fallback content to display if avatar fails to load.