WebVR Polyfill Device Parameter Database
webvr-polyfill-dpdb is a JSON dataset containing device parameters crucial for the webvr-polyfill. It provides information like screen DPI, bezel width, and device identification rules (User-Agent, resolution, etc.) for various Android and iOS devices. This data is essential for the webvr-polyfill to accurately render stereoscopic scenes by correcting lens distortion on mobile devices, bridging the gap where web applications lack direct access to physical device characteristics. The package is currently at version 1.0.18, with its last recorded update in December 2020. Given that the underlying WebVR API has been deprecated in favor of WebXR, this database is largely superseded and serves a legacy purpose.
Common errors
-
Cannot find module 'webvr-polyfill-dpdb'
cause Attempting to import the package as a JavaScript module that exports symbols, or importing it in a Node.js environment without a bundler correctly resolving the JSON file.fixImport the specific JSON file directly: `import dpdb from 'webvr-polyfill-dpdb/dpdb.json';` or `const dpdb = require('webvr-polyfill-dpdb/dpdb.json');`. Ensure your build tool is configured to handle JSON imports. -
dpdb.devices is undefined (or similar error when accessing data)
cause The JSON file might not have been loaded correctly, or the structure of the data accessed is incorrect.fixVerify the import path is correct and that the JSON data is parsed. Ensure you are accessing `dpdb.devices` as an array, as indicated in the package's structure. Confirm the JSON itself is valid.
Warnings
- breaking The underlying WebVR API for which this database was designed has been deprecated and largely replaced by the WebXR Device API. Modern immersive web experiences should target WebXR.
- gotcha The device parameter database (`dpdb.json`) may be outdated. The last known update to this repository was in December 2020. Newer mobile VR devices released after this date might not be included or have inaccurate parameters, potentially leading to incorrect rendering with `webvr-polyfill`.
- deprecated This package primarily serves as a data source for the `webvr-polyfill`, which itself is considered deprecated. It is unlikely to receive further updates or new device entries.
Install
-
npm install webvr-polyfill-dpdb -
yarn add webvr-polyfill-dpdb -
pnpm add webvr-polyfill-dpdb
Imports
- dpdb.json
import { dpdb } from 'webvr-polyfill-dpdb';import dpdb from 'webvr-polyfill-dpdb/dpdb.json';
- dpdb-formatted.json
import { formattedDpdb } from 'webvr-polyfill-dpdb';import formattedDpdb from 'webvr-polyfill-dpdb/dpdb-formatted.json';
Quickstart
import dpdb from 'webvr-polyfill-dpdb/dpdb.json';
// In a real application, you would pass this data to the webvr-polyfill
// for its configuration. This example demonstrates accessing the data directly.
console.log('Total devices in DPDB:', dpdb.devices.length);
// Find a specific device entry, for example, based on a User-Agent rule
const searchUA = 'ASUS_Z00AD';
const asusDevice = dpdb.devices.find(device =>
device.rules.some(rule => rule.ua && rule.ua.includes(searchUA))
);
if (asusDevice) {
console.log(`Found device: ASUS_Z00AD with DPI ${asusDevice.dpi} and bezel width ${asusDevice.bw}mm.`);
} else {
console.log(`Device with UA '${searchUA}' not found in DPDB.`);
}
// Example of accessing a device from the raw formatted JSON (if available/desired)
// This would typically involve a separate build step or direct file access for customization
/*
fetch('node_modules/webvr-polyfill-dpdb/dpdb-formatted.json')
.then(response => response.json())
.then(formattedData => {
console.log('Example from formatted DPDB:', formattedData.devices[0]);
});
*/