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

aframe-frame-rate

v0.1.0

Published

Adjust WebXR frame rate for A-Frame applications

Downloads

5

Readme

frame-rate & adaptive-frame-rate

Overview

frame-rate

Set on any entity to adjust the WebXR frame rate requested for rendering.

The WebXR specs allow a page to request rendering at a particular frame rate. Requesting an appropriate frame rate is important to maximize performance.

WebXR rendering occurs at a fixed rate, like a metronome. This means that if an application attempts to run at 90fps, but takes more than 11msecs to render each frame, the best possible frame rate it can achieve is 45fps (half the target frame rate).

By reducing the target frame rate to 80, 72 or 60 fps, the application may be able to achieve a higher actual frame rate.

adaptive-frame-rate

Set on any entity to adjust the WebXR frame rate to suit the performance of the app.

The WebXR specs allow a page to request rendering at a particular frame rate. Requesting an appropriate frame rate is important to maximize performance.

WebXR rendering occurs at a fixed rate, like a metronome. This means that if an application attempts to run at 90fps, but takes more than 11msecs to render each frame, the best possible frame rate it can achieve is 45fps (half the target frame rate).

This component monitors the rendering frequency, and adjusts the requested frame rate up / down based on the performance of the application.

WebXR API

Both components use the WebXR API features described here: https://www.w3.org/TR/webxr/#dom-xrsession-updatetargetframerate

Installation

(this imports code for both frame-rate and adaptive-frame-rate components)

Via CDN

<script src="https://cdn.jsdelivr.net/gh/diarmidmackenzie/aframe-components@latest/components/frame-rate/index.min.js"></script>

Or via npm

npm install aframe-frame-rate

Schemas

frame-rate

| Property | Description | Default | | ------------------------ | ---------------------- | ------- | | (single property schema) | Frame rate to target72 | 72 |

adaptive-frame-rate

| Property | Description | Default | | ----------------- | ------------------------------------------------------------ | ------- | | initialRate | The starting frame rate on initializing the application. Note that this rate will not be applied until a WebXR session begins (e.g. the user entering VR). | 72 | | uprateInterval | The period in seconds over which monitoring for uprating occurs. | 10 | | uprateThreshold | The maximum number of frame misses allowed, to qualify for uprating. If the uprate interval passes, with fewer than this number of missed frames, the app is uprated to the next available frame rate. | 5 | | downrateInterval | The period in seconds over which monitoring for downrating occurs. | 5 | | downrateThreshold | The number of frame misses at which downrating is triggered. As soon as thing number of frames are missed in a downrate measurement interval, the app is downrated to the next available frame rate. | 10 | | framerateCap | This places a cap on the highest frame rate that will be considered for uprating to. | 100 |

Usage

These components can be set on any entity, but simplest & clearest to set this on your <a-scene>.

E.g.

<a-scene frame-rate="72">
  ...
  scene content here
  ...
</a-scene>

or:

<a-scene adaptive-frame-rate>
  ...
  scene content here
  ...
</a-scene>

The frame rate cannot be adjusted on the WebXR API until the user enters VR mode. However, this component takes care of listening for when that happens, and making the frame rate change at the appropriate time.

Methods & API

frame-rate

When this component is configured on an entity (or the scene), the following methods are also available:

getFrameRate()

Returns the current actual frame rate (a single number).

Typically this will be the most recently requested frame rate, but it may differ in some failure cases (for example if the most recently requested frame rate is unsupported)

This function should only be called when a WebXR Session is active (e.g. after entering Immersive Mode). If no WebXR session is active, it will generate warnings, and return an undefined value.

getAvailableFrameRates()

Returns an array indicating the set of frame rates available on this device.

This function should only be called when a WebXR Session is active (e.g. after entering Immersive Mode). If no WebXR session is active, it will generate warnings, and return an undefined value.

adaptive-frame-rate

This component uses the frame-rate component to actually adjust frame rate.

The frame rate currently chosen by this component can be queried on the frame-rate component

this.el.sceneEl.components['frame-rate'].data

The actual frame rate being used by the WebXR Session (should be the same, except in error cases) can be checked using the getFrameRate() method on that component:

this.el.sceneEl.components['frame-rate'].getFrameRate()

The following properties are also accessible on this component:

uprateMissedFrames   // The number of missed frames in the current uprate interval
downrateMissedFrames // The number of missed frames in the current downrate interval

Examples

frame-rate

adaptive-frame-rate

Code

frame-rate