Socket
Book a DemoInstallSign in
Socket

@spiffcommerce/preview-ar-plugin

Package Overview
Dependencies
Maintainers
3
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spiffcommerce/preview-ar-plugin

Spiff Commerce Preview plugin for Augmented Reality

1.5.0
latest
npmnpm
Version published
Maintainers
3
Created
Source

Preview AR Plugin

This is a plugin for Preview for enabling ARKit and ARCore support, using the Google Model Viewer.

Usage

  • Install preview and this plugin: yarn add @spiffcommerce/preview @spiffcommerce/preview-ar-plugin
  • Import the plugin and register it with preview:
import { ARPlugin } from '@spiffcommerce/preview-ar-plugin';

// Create the preview service
const previewService = new SpiffCommerce3DPreviewService({
    // ... preview options
});

const arPlugin = new ARPlugin({
    // This function should parse the elementString and return a promise that resolves to an HTMLElement
    createModelViewer: (elementString: string): Promise<HTMLElement> => {},
    // Optional array of mesh names to ignore when exporting the model
    ignoredMeshNames: ['mesh1', 'mesh2'],
    // Optional map of metadata fields to ignore when exporting the model. The key is the field name, and the value is an array of values to ignore.
    ignoredMetadataFields: new Map([['field1', ['value1']], ['field2', ['value2']]]),
    // This function should insert the given scripts into the DOM
    insertScripts: (sources: string[]): void => {},
    // This function should upload the given file to your server and return a promise that resolves to the url of the uploaded file
    storeFile: (file: File): Promise<string> => {},
});

// Initialize the preview service
await previewService.initialize({
    // ... preview initialization options
});

// Plugin can be registered before or after the preview service is initialized
previewService.registerPlugin(arPlugin);

if (arPlugin.arSupported()) {
    await arPlugin.generateModel(true);
    arPlugin.launchAR();
}

FAQs

Package last updated on 06 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.