Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webvr-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webvr-polyfill - npm Package Compare versions

Comparing version 0.9.24 to 0.9.25

2

package.json
{
"name": "webvr-polyfill",
"version": "0.9.24",
"version": "0.9.25",
"homepage": "https://github.com/googlevr/webvr-polyfill",

@@ -5,0 +5,0 @@ "authors": [

@@ -126,3 +126,7 @@ /*

FusionPoseSensor.prototype.onDeviceMotionChange_ = function(deviceMotion) {
FusionPoseSensor.prototype.onDeviceMotion_ = function(deviceMotion) {
this.updateDeviceMotion_(deviceMotion);
};
FusionPoseSensor.prototype.updateDeviceMotion_ = function(deviceMotion) {
var accGravity = deviceMotion.accelerationIncludingGravity;

@@ -159,7 +163,28 @@ var rotRate = deviceMotion.rotationRate;

FusionPoseSensor.prototype.onScreenOrientationChange_ =
function(screenOrientation) {
FusionPoseSensor.prototype.onOrientationChange_ = function(screenOrientation) {
this.setScreenTransform_();
};
/**
* This is only needed if we are in an cross origin iframe on iOS to work around
* this issue: https://bugs.webkit.org/show_bug.cgi?id=152299.
*/
FusionPoseSensor.prototype.onMessage_ = function(event) {
var message = event.data;
// If there's no message type, ignore it.
if (!message || !message.type) {
return;
}
// Ignore all messages that aren't devicemotion.
var type = message.type.toLowerCase();
if (type !== 'devicemotion') {
return;
}
// Update device motion.
this.updateDeviceMotion_(message.deviceMotionEvent);
};
FusionPoseSensor.prototype.setScreenTransform_ = function() {

@@ -185,7 +210,15 @@ this.worldToScreenQ.set(0, 0, 0, 1);

FusionPoseSensor.prototype.start = function() {
this.onDeviceMotionCallback_ = this.onDeviceMotionChange_.bind(this);
this.onScreenOrientationCallback_ = this.onScreenOrientationChange_.bind(this);
this.onDeviceMotionCallback_ = this.onDeviceMotion_.bind(this);
this.onOrientationChangeCallback_ = this.onOrientationChange_.bind(this);
this.onMessageCallback_ = this.onMessage_.bind(this);
// Only listen for postMessages if we're in an iOS and embedded inside a cross
// domain IFrame. In this case, the polyfill can still work if the containing
// page sends synthetic devicemotion events. For an example of this, see
// iframe-message-sender.js in VR View: https://goo.gl/XDtvFZ
if (Util.isIOS() && Util.isInsideCrossDomainIFrame()) {
window.addEventListener('message', this.onMessageCallback_);
}
window.addEventListener('orientationchange', this.onOrientationChangeCallback_);
window.addEventListener('devicemotion', this.onDeviceMotionCallback_);
window.addEventListener('orientationchange', this.onScreenOrientationCallback_);
};

@@ -195,5 +228,6 @@

window.removeEventListener('devicemotion', this.onDeviceMotionCallback_);
window.removeEventListener('orientationchange', this.onScreenOrientationCallback_);
window.removeEventListener('orientationchange', this.onOrientationChangeCallback_);
window.removeEventListener('message', this.onMessageCallback_);
};
module.exports = FusionPoseSensor;

@@ -405,2 +405,27 @@ /*

Util.isInsideCrossDomainIFrame = function() {
var isFramed = (window.self !== window.top);
var refDomain = Util.getDomainFromUrl(document.referrer);
var thisDomain = Util.getDomainFromUrl(window.location.href);
return isFramed && (refDomain !== thisDomain);
};
// From http://stackoverflow.com/a/23945027.
Util.getDomainFromUrl = function(url) {
var domain;
// Find & remove protocol (http, ftp, etc.) and get domain.
if (url.indexOf("://") > -1) {
domain = url.split('/')[2];
}
else {
domain = url.split('/')[0];
}
//find & remove port number
domain = domain.split(':')[0];
return domain;
}
module.exports = Util;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc