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 🙏

© 2026 – Pkg Stats / Ryan Hefner

facely

v0.0.14

Published

A browser library for generating 3d faces from 2d images of people

Readme

Facely

Facely is an npm library for creating 3D face meshes from 2D images in the browser. It combines TensorFlow.js for face landmarks and depth estimation with Three.js for rendering, allowing you to transform standard portrait images into fully textured, 3D UV meshes.


Table of Contents


Features

  • AI-Powered Face Landmark Detection: Utilizes TensorFlow.js models for accurate 2D face landmarking.
  • Depth Map Generation: Leverages Depth Estimation to reconstruct a pseudo-3D mesh from your 2D images.
  • Three.js Integration: Directly add the generated 3D assets into your Three.js scene or download them for offline use.
  • Progress Tracking: Receive real-time progress updates during model loading and image processing.
  • One-Click Asset Download: Export your 3D mesh and associated textures with a single function call.

Installation

Install Facely using your favorite package manager:

npm install facely

Facely will automatically load required TensorFlow.js models when needed. You do not need to install or configure these models manually in most cases.


Quick Start

Below is a minimal example showing how to import Facely and process a single portrait image.

import { facely } from 'facely';

async function handleImageUpload(imageFile) {
    const face = await facely(imageFile);
    console.log(face);
    return face;
}

Note: Large images or low-performance devices may lead to longer processing times.


Usage

1. Basic Image Processing

You can pass various image types to facely (e.g., File, Blob in the browser, or Buffer in Node). For example, in a web application with a file input:

<input type="file" accept="image/*" onchange="uploadImage(event)" />

<script type="module">
    import { facely } from 'facely';

    async function uploadImage(event) {
        const file = event.target.files[0];
        if (!file) return;

        const face = await facely(file);
        console.log(face);
        // face now contains data to generate a 3D mesh, textures, etc.
    }
</script>

2. Progress Updates

Processing can take a bit of time, especially if TensorFlow models are being loaded or if the device is resource-limited. Facely provides an optional progress callback to help track the current stage of processing:

import { facely } from 'facely';

let progressData = null;

function handleProgress(p) {
    // p has fields like: { stage: string, message: string, percent: number }
    progressData = p;
    console.log(p.stage, p.message, p.percent);
}

async function handleImageUpload(imageFile) {
    const face = await facely(imageFile, handleProgress);
    return face;
}

3. Downloading Assets

After processing the image, you can directly download all generated 3D assets (mesh, texture, etc.):

const face = await facely(imageFile);

// Downloads a ZIP file containing the mesh and related images
face.download();

4. Integration with Three.js

Facely is built around Three.js. Once you have a face object from Facely, you can add different 3D representations to your own Three.js scene:

import * as THREE from 'three';
import { facely } from 'facely';

let mainScene = new THREE.Scene();

async function handleImageUpload(imageFile) {
    const face = await facely(imageFile);

    face.add.image(mainScene);      // Adds the plane with the original or generated texture
    face.add.wireframe(mainScene);  // Wireframe version of the face mesh
    face.add.edges(mainScene);      // Edges geometry
    face.add.vertices(mainScene);   // Points representing the vertices of the mesh
    face.add.faces(mainScene);      // Face geometry
    face.add.uvFace(mainScene);     // UV-textured face mesh
}

Examples

Below is a broader snippet showcasing file input handling, progress updates, and a download button:

<input type="file" accept="image/*" onchange="{handleFileUpload}" />

<script type="module">
    import { facely } from 'facely';

    let faceResult = null;
    let progress = null;

    async function handleFileUpload(event) {
        const file = event.target.files[0];
        if (!file) return;

        faceResult = await facely(file, (p) => (progress = p));
    }

    function downloadFaceAssets() {
        if (faceResult) {
            faceResult.download();
        }
    }
</script>

<button onclick="downloadFaceAssets()">Download 3D Face</button>
<p>Progress: {progress && progress.percent} %</p>

Browser Support

Facely relies on modern JavaScript features and TensorFlow.js, which may not be fully supported on some older or mobile browsers. For best results, use the latest versions of Chrome, Firefox, Safari, or Edge.

  • Desktop Browsers: Latest Chrome, Firefox, Edge, Safari.
  • Mobile Browsers: Varies by device; performance may degrade on lower-end hardware.

Contributing

Contributions, issues, and feature requests are always welcome!

  1. Fork the repository.
  2. Create a new feature branch (git checkout -b feature/new-feature).
  3. Commit your changes (git commit -m 'Add some feature').
  4. Push to the branch (git push origin feature/new-feature).
  5. Open a Pull Request to the main branch in the Facely repository.

License

This project is licensed under the MIT License. You are free to use it in personal or commercial projects.


Happy Face-Meshing! Have questions or need help? Check out the GitHub Issues or open a new one.