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

webvr-helper

v1.0.8

Published

A three.js helper library to check and run VR sessions on web with a stereo-effect-view backup

Downloads

14

Readme

A three.js helper library to check and run VR sessions on web with a stereo-effect-view backup.

Greenkeeper badge

Features

This library provides features to

  • Check weather VR is available in a loose and synchronous way (you can use this to decide weather to load other VR specific resources)
  • Check weather VR is available in a stronger, feature-based and asynchronous way (more reliable)
  • Setup necessary components depending on which VR type is available
  • Setup necessary callbacks and methods to inform your app about the state of VR sessions

The availability check is done in the following order

  • WebXR API
  • Legacy WebVR API
  • Fallback threejs stereo-effect to simulate VR view for Cardboard-style headsets

Usage

npm

import WebVRHelper from 'webvr-helper';

let anyVRAvailable = WebVRHelper.checkAvailabilityLoose();
WebVRHelper.checkAvailabilityFull((anyVRAvailable) => {});
...

self-host

<script src="build/webvrhelper.min.js"></script>

let WebVRHelper = window.WebVRHelper.default;

let anyVRAvailable = WebVRHelper.checkAvailabilityLoose();
WebVRHelper.checkAvailabilityFull((anyVRAvailable) => {});
...

Example code

let container = document.createElement('div');
document.body.appendChild(container);

let scene = new THREE.Scene();
scene.background = new THREE.Color(0x505050);

let camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.1, 10);
scene.add(camera);

let renderer = new THREE.WebGLRenderer();
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.xr.enabled = true;
container.appendChild(renderer.domElement);

window.addEventListener('resize', () => {
    WebVRHelper.onResize();
    renderer.setSize(window.innerWidth, window.innerHeight);
}, false);

// Check VR availability
console.log('Loose sync availability check', WebVRHelper.checkAvailabilityLoose());
// Strong and async feature check
WebVRHelper.checkAvailabilityFull((anyVRAvailable) => {
    if (anyVRAvailable) {
        // setup renderer
        WebVRHelper.postAvailabilitySetup(renderer, THREE.StereoEffect, () => {
            console.log('VR session has changed');
        });
    }
    // start the render
    animate();
});

let animate = () => {
    renderer.setAnimationLoop(render);
};
let render = () => {
    // Render on WebVRHelper if VR is supported
    if (WebVRHelper.isAnyVRSupported()) {
        WebVRHelper.render(scene, camera);
    } else {
        renderer.render(scene, camera);
    }
};
...

Note: Check the example in demo folder for a more detailed working example.

Build

git clone https://github.com/axaq/webvr-helper.git
npm install
npm run build