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

@alaneu/react-native-nitro-vto

v0.7.1

Published

React Native library for glasses virtual try-on using ARCore and Filament

Downloads

2,211

Readme

React Native Nitro VTO

A React Native library for glasses virtual try-on using ARCore (Android) and ARKit (iOS) face tracking with Filament 3D rendering. Built with Nitro Modules for high-performance native integration.

Features

  • Real-time face tracking with ARCore (Android) and ARKit (iOS)
  • High-quality 3D rendering with Filament
  • GLB model loading from URLs with automatic caching
  • Runtime model switching
  • Callback when model is loaded
  • World-space positioning with proper perspective projection
  • Face occlusion support (glasses appear behind face when appropriate)

Requirements

  • React Native >= 0.78.0
  • react-native-nitro-modules >= 0.23.0
  • Android: Device with ARCore support
  • iOS: Device with ARKit support

Installation

npm install @alaneu/react-native-nitro-vto react-native-nitro-modules

Usage

import React, { useState, useEffect } from "react";
import { View } from "react-native";
import { NitroVtoView } from "@alaneu/react-native-nitro-vto";
import { callback } from "react-native-nitro-modules";
import { Camera } from "react-native-vision-camera"; // or your preferred camera permission library

function App() {
  const [hasPermission, setHasPermission] = useState(false);

  useEffect(() => {
    async function requestPermission() {
      const status = await Camera.requestCameraPermission();
      setHasPermission(status === "granted");
    }
    requestPermission();
  }, []);

  if (!hasPermission) return null;

  return (
    <View style={{ flex: 1 }}>
      <NitroVtoView
        style={{ flex: 1 }}
        modelUrl="https://example.com/glasses.glb"
        isActive={true}
        occlusion={{ faceMesh: true, backPlane: true }}
        onModelLoaded={callback((url) => console.log("Model loaded:", url))}
      />
    </View>
  );
}

Note: Callback props must be wrapped with callback() from react-native-nitro-modules due to React Native renderer limitations.

API

Props

| Prop | Type | Description | | --------------- | ---------------------------- | ---------------------------------------------------------------------------------------------- | | modelUrl | string | URL to the GLB model file. Models should be authored in meters at real-world size. | | isActive | boolean | Whether the AR session is active | | occlusion | OcclusionSettings | Optional. Controls face occlusion behavior. See below. | | onModelLoaded | (modelUrl: string) => void | Callback when model loading completes (wrap with callback()) | | style | ViewStyle | Standard React Native view styles |

OcclusionSettings

| Property | Type | Default | Description | | ----------- | --------- | ------- | --------------------------------------------------------------------------- | | faceMesh | boolean | true | Enable face mesh occlusion (glasses appear behind face edges) | | backPlane | boolean | true | Enable back plane occlusion (clips glasses temples extending behind head) |

Methods

Access methods via hybridRef:

import { useRef } from "react";
import {
  NitroVtoView,
  type NitroVtoViewMethods,
  type HybridRef,
} from "@alaneu/react-native-nitro-vto";

type VtoRef = HybridRef<NitroVtoViewProps, NitroVtoViewMethods>;

function App() {
  const vtoRef = useRef<VtoRef>(null);

  const switchGlasses = () => {
    vtoRef.current?.switchModel("https://example.com/other.glb");
  };

  return (
    <NitroVtoView
      modelUrl="https://example.com/glasses.glb"
      isActive={true}
      hybridRef={(ref) => {
        vtoRef.current = ref;
      }}
    />
  );
}

| Method | Description | | ----------------------------- | ---------------------------------------------- | | switchModel(modelUrl: string) | Switch to a different glasses model at runtime | | resetSession() | Reset the AR session and face tracking |

Technical Details

Filament matc and cmgen tools

Version 1.67.1 for Android and 1.56.6 for iOS.

Compile Materials for Android

For Android, compile materials with OpenGL and Vulkan backends:

matc --api opengl --api vulkan --platform mobile -o output.filamat input.mat

Compile Materials for iOS

For iOS, compile materials with Metal backend:

matc --api metal --platform mobile -o output.filamat input.mat

Generate IBL from HDR env

Download the Filament tools and generate the IBL from the HDR env:

cmgen --format=ktx --size=256 --deploy=./output/path/ ./input/path/your_env.hdr

Head Rotation Axes

  • X axis (Roll): Tilt head left/right
  • Y axis (Pitch): Look up/down
  • Z axis (Yaw): Turn left/right

Transform Pipeline

The glasses positioning uses world-space coordinates with ARKit/ARCore perspective camera:

  1. Camera: Filament camera uses ARKit/ARCore view and projection matrices directly
  2. Position: World-space coordinates from face mesh nose bridge vertices
    • Android (ARCore): vertices 351 and 122
    • iOS (ARKit): vertices 818 and 366
  3. Rotation: Face transform rotation quaternion in world space
  4. Smoothing: Kalman filters applied to position and rotation for stability

Models should be authored in meters at real-world size (e.g., a glasses frame width of ~0.135m). This world-space approach ensures correct perspective projection and natural glasses behavior when moving the head.

License

MIT