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

cordova-plugin-device-sensor-fusion

v0.0.3

Published

Use Sensor-Fusion for more stable sensor data on Android. Based on a Alexander Pachas Master Thesis "Sensor fusion for robust outdoor Augmented Reality tracking on mobile devices".

Downloads

6

Readme

npm version

cordova-plugin-device-sensor-fusion

A cordova plugin using sensor fusion to offer more precise orientation data. It is based on a work of Alexander Pacha (https://bitbucket.org/apacha/sensor-fusion-demo).

DEMO: https://github.com/adirtyshame/threecordova

Access is via a global navigator.fusion object.

Although the object is attached to the global scoped navigator, it is not available until after the deviceready event.

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    console.log(navigator.fusion);
}

Installation

Install via cordova CLI:

cordova plugin add https://github.com/adirtyshame/cordova-plugin-device-sensor-fusion.git

Supported Platforms

  • Android

Methods

  • navigator.fusion.setMode
  • navigator.fusion.getCurrentSensorFusion
  • navigator.fusion.watchSensorFusion
  • navigator.fusion.clearWatch

navigator.fusion.setMode

Set the operation-mode for the plugin.

navigator.fusion.setMode(success, err, mode);

Available modes are (from '0' to '5'):

  • 0: Improved Orientation Sensor 1 (Sensor fusion of Android Rotation Vector and Calibrated Gyroscope - less stable but more accurate)
  • 1: Improved Orientation Sensor 2 (Sensor fusion of Android Rotation Vector and Calibrated Gyroscope - more stable but less accurate)
  • 2: Android Rotation Vector (Kalman filter fusion of Accelerometer + Gyroscope + Compass)
  • 3: Calibrated Gyroscope (Separate result of Kalman filter fusion of Accelerometer + Gyroscope + Compass)
  • 4: Gravity + Compass
  • 5: Accelerometer + Compass

Example

function success(result) {
    alert('new Mode: ' + result);
};

function err(error) {
    alert('Error: ' + error);
};

// Set operation mode to 'Android Rotation Vector'
navigator.fusion.setMode(onSuccess, onError, 2);

navigator.fusion.getCurrentSensorFusion

Get the current sensor fusion. The result is returned via a FusionResult object using the fusionSuccess callback function.

navigator.fusion.getCurrentSensorFusion(fusionSuccess, fusionError);

Example

function onSuccess(result) {
    alert('x: ' + result.x);
};

function onError(error) {
    alert('FusionError: ' + error.code);
};

navigator.fusion.getCurrentSensorFusion(onSuccess, onError);

navigator.fusion.watchSensorFusion

Gets the device's current sensor fusion data at a regular interval. Each time the data is retrieved, the fusionSuccess callback function is executed.

The returned watch ID references the sensor fusion watch interval. The watch ID can be used with navigator.fusion.clearWatch to stop watching the navigator.fusion.

var watchID = navigator.fusion.watchSensorFusion(fusionSuccess, fusionError, [fusionOptions]);

fusionOptions may contain the following keys:

  • frequency: How often to retrieve the sensor fusion data in milliseconds. (Number) (Default: 100)

Example

function onSuccess(result) {
    var element = document.getElementById('result');
    element.innerHTML = 'Result.x: ' + result.x;
};

function onError(fusionError) {
    alert('Fusion error: ' + fusionError.code);
};

var options = {
    frequency: 3000
}; // Update every 3 seconds

var watchID = navigator.fusion.watchSensorFusion(onSuccess, onError, options);

navigator.fusion.clearWatch

Stop watching the sensor fusion referenced by the watch ID parameter.

navigator.fusion.clearWatch(watchID);
  • watchID: The ID returned by navigator.fusion.watchSensorFusion.

Example

var watchID = navigator.fusion.watchSensorFusion(onSuccess, onError, options);

// ... later on ...

navigator.fusion.clearWatch(watchID);

FusionResult

A FusionResult object is returned to the fusionSuccess callback function.

Properties

  • FusionResult. (ATTENTION: will be deprecated soon)

    • x: The x-component of the resulting quaternion. (Number)
    • y: The y-component of the resulting quaternion. (Number)
    • z: The z-component of the resulting quaternion. (Number)
    • w: The w-component of the resulting quaternion. (Number)
  • FusionResult.quaternion.

    • x: The x-component of the resulting quaternion. (Number)
    • y: The y-component of the resulting quaternion. (Number)
    • z: The z-component of the resulting quaternion. (Number)
    • w: The w-component of the resulting quaternion. (Number)
  • FusionResult.eulerAngles.

    • yaw: The Euler-Angles yaw component. (Number)
    • pitch: The Euler-Angles pitch component. (Number)
    • roll: The Euler-Angles roll component. (Number)
  • FusionResult.timestamp: The time at which the data was determined. (milliseconds)

Changelog

  • 0.0.1
    • initial commit
  • 0.0.2
    • README.md updated
  • 0.0.3
    • FusionResult extended (see 'Properties') !!!ATTENTION: DEPRECATION!!!