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

react-native-ar-viewer

v0.1.17

Published

AR viewer for react native that uses Sceneform on Android and ARKit on iOS

Downloads

33

Readme

react-native-ar-viewer

npm version

AR viewer for react native that uses Sceneform on Android and ARKit on iOS

Installation

npm install react-native-ar-viewer

Android

Required AR features:

  • Add the following to your AndroidManifest.xml:
<meta-data android:name="com.google.ar.core" android:value="required" tools:replace="android:value" />
  • If you already have <meta-data android:name="com.google.ar.core" android:value="required" /> don't forget to add the tools:replace="android:value" attribute.

  • Check that your <manifest> tag contains xmlns:tools="http://schemas.android.com/tools" attribute.

iOS

  • Remember to add NSCameraUsageDescription entry in your Info.plist with a text explaining why you request camera permission.

  • In XCode file tree, go to Pods > Development pods > react-native-ar-viewer, right-click on "Add Files to Pods"... Then select the environment.skybox folder in your node_modules/react-native-ar-viewer/ios folder. In add file window, check "react-native-ar-viewer-ARViewerBundle". It should appear with a blue icon on the file tree. Check if res.hdr is present inside, if not, add it manually. It should look like that:

File formats

The viewer only supports USDZ files for iOS and GLB for Android. Other formats may work, but are not officialy supported.

Usage

You should download your model locally using for example React Native File System in order to run the viewer on iOS. Android supports natively file URL (https:// instead of file://)

import { ArViewerView } from "react-native-ar-viewer";
import { Platform } from 'react-native';
// ...

<ArViewerView 
    style={{flex: 1}}
    model={Platform.OS === 'android' ? 'dice.glb' : 'dice.usdz'}
    lightEstimation
    manageDepth
    allowRotate
    allowScale
    allowTranslate
    disableInstantPlacement
    onStarted={() => console.log('started')}
    onEnded={() => console.log('ended')}
    onModelPlaced={() => console.log('model displayed')}
    onModelRemoved={() => console.log('model not visible anymore')}
    planeOrientation="both" />

Props

| Prop | Type | Description | Required | |---|---|---|---| | model| string | Enables ambient light estimation (see below) | Yes | | lightEstimation| bool | Enables ambient light estimation (see below) | No | | manageDepth | bool | Enables depth estimation and occlusion (only iOS, see below) | No | | allowRotate | bool | Allows to rotate model | No | | allowScale | bool | Allows to scale model | No | | allowTranslate | bool | Allows to translate model | No | | disableInstructions | bool | Disables instructions view | No | | disableInstantPlacement | bool | Disables placement on load | No | | planeOrientation | "horizontal", "vertical", "both" or "none" | Sets plane orientation (default: both) | No |

lightEstimation:

| With | Without | |---|---| |||

manageDepth:

| With | Without | |---|---| |||

Others:

| allowRotate | allowScale | planeOrientation: both | |---|---|---| ||||

Events

| Prop | Parameter | Description | |---|---|---| | onStarted | none | Triggers on AR session started | | onEnded | none | Triggers on AR session ended | | onModelPlaced | none | Triggers when model is placed | | onModelRemoved | none | Triggers when model is removed | | onError | { message: string } | Triggers on any error and returns an object containing the error message |

Commands

Commands are sent using refs like the following example:

  // ...
  const ref = React.useRef() as React.MutableRefObject<ArViewerView>;
  
  const reset = () => {
    ref.current?.reset();
  };
  
  return (
    <ArViewerView
      model={yourModel}
      ref={ref} />
  );
  // ...

| Command | Args | Return | Description | |---|---|---|---| | reset() | none | void | Removes model from plane | | rotate() | x, y, z | void | Manually rotates the model using yaw as x, pitch as y and roll as z in degrees | | takeScreenshot() | none | Promise<String> | Takes a screenshot of the current view (camera + model) and returns a base64 jpeg string as a promise |

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT