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

cardboard-vr-display

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cardboard-vr-display - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

24

licenses.txt

@@ -58,1 +58,25 @@ /**

*/
/**
* @license
* nosleep.js
* Copyright (c) 2017, Rich Tibbett
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

3

package.json
{
"name": "cardboard-vr-display",
"version": "1.0.2",
"version": "1.0.3",
"homepage": "https://github.com/googlevr/cardboard-vr-display",

@@ -36,4 +36,5 @@ "authors": [

"gl-preserve-state": "^1.0.0",
"nosleep.js": "^0.7.0",
"webvr-polyfill-dpdb": "^1.0.3"
}
}

@@ -30,2 +30,7 @@ # cardboard-vr-display

### I-Frames
On iOS, cross-origin iframes do not have access to the `devicemotion` events. The CardboardVRDisplay however
does respond to events passed in from a parent frame via `postMessage`. See the [iframe example][iframe-example] to see how the events must be formatted.
## Installation

@@ -135,2 +140,3 @@

[example]: https://googlevr.github.io/cardboard-vr-display/examples
[iframe-example]: examples/iframe.html
[index.html]: https://googlevr.github.io/cardboard-vr-display

@@ -17,3 +17,3 @@ /*

var Util = require('./util.js');
var WakeLock = require('./wakelock.js');
var NoSleep = require('nosleep.js');

@@ -42,3 +42,6 @@ // Start at a higher number to reduce chance of conflict.

*/
function VRDisplay() {
function VRDisplay(config) {
config = config || {};
var USE_WAKELOCK = 'wakelock' in config ? config.wakelock : true;
this.isPolyfilled = true;

@@ -78,3 +81,7 @@ this.displayId = nextDisplayId++;

this.wakelock_ = new WakeLock();
// Get an appropriate wakelock for Android or iOS if MOBILE_WAKE_LOCK
// is true.
if (USE_WAKELOCK && Util.isMobile()) {
this.wakelock_ = new NoSleep();
}
}

@@ -278,3 +285,3 @@

self.removeFullscreenWrapper();
self.wakelock_.release();
self.disableWakeLock();
self.endPresent_();

@@ -293,3 +300,3 @@ self.removeFullscreenListeners_();

self.wakelock_.release();
self.disableWakeLock();
self.waitingForPresent_ = false;

@@ -305,7 +312,7 @@ self.isPresenting = false;

if (Util.requestFullscreen(fullscreenElement)) {
self.wakelock_.request();
self.enableWakeLock();
self.waitingForPresent_ = true;
} else if (Util.isIOS() || Util.isWebViewAndroid()) {
// *sigh* Just fake it.
self.wakelock_.request();
self.enableWakeLock();
self.isPresenting = true;

@@ -330,3 +337,3 @@ self.beginPresent_();

this.layer_ = null;
this.wakelock_.release();
this.disableWakeLock();

@@ -436,2 +443,14 @@ return new Promise(function(resolve, reject) {

VRDisplay.prototype.enableWakeLock = function() {
if (this.wakelock_) {
this.wakelock_.enable();
}
}
VRDisplay.prototype.disableWakeLock = function() {
if (this.wakelock_) {
this.wakelock_.disable();
}
}
VRDisplay.prototype.beginPresent_ = function() {

@@ -438,0 +457,0 @@ // Override to add custom behavior when presentation begins.

@@ -37,4 +37,10 @@ /*

var defaults = Util.extend({}, Options);
this.config = Util.extend(defaults, config || {});
config = Util.extend(defaults, config || {});
VRDisplay.call(this, {
wakelock: config.MOBILE_WAKE_LOCK,
});
this.config = config;
this.displayName = 'Cardboard VRDisplay';

@@ -73,3 +79,3 @@

}
CardboardVRDisplay.prototype = new VRDisplay();
CardboardVRDisplay.prototype = Object.create(VRDisplay.prototype);

@@ -76,0 +82,0 @@ CardboardVRDisplay.prototype.getImmediatePose = function() {

@@ -17,2 +17,8 @@ /*

module.exports = {
// By default, on mobile, a wakelock is necessary to prevent the device's screen
// from turning off without user input. Disable if you're keeping the screen awake through
// other means on mobile. A wakelock is never used on desktop.
// Added in 1.0.3.
MOBILE_WAKE_LOCK: true,
// Whether or not CardboardVRDisplay is in debug mode. Logs extra

@@ -19,0 +25,0 @@ // messages. Added in 1.0.2.

@@ -221,6 +221,6 @@ /*

// 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
// origin 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()) {
// the iframe example in the repo at `examples/iframe.html`
if (Util.isIOS() && Util.isInsideCrossOriginIFrame()) {
window.addEventListener('message', this.onMessageCallback_);

@@ -227,0 +227,0 @@ }

@@ -445,27 +445,27 @@ /*

Util.isInsideCrossDomainIFrame = function() {
// via https://github.com/googlevr/webvr-polyfill/issues/271
Util.isInsideCrossOriginIFrame = function() {
var isFramed = (window.self !== window.top);
var refDomain = Util.getDomainFromUrl(document.referrer);
var thisDomain = Util.getDomainFromUrl(window.location.href);
var refOrigin = Util.getOriginFromUrl(document.referrer);
var thisOrigin = Util.getOriginFromUrl(window.location.href);
return isFramed && (refDomain !== thisDomain);
return isFramed && (refOrigin !== thisOrigin);
};
// 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];
// via https://github.com/googlevr/webvr-polyfill/issues/271
Util.getOriginFromUrl = function(url) {
var domainIdx;
var protoSepIdx = url.indexOf("://");
if (protoSepIdx !== -1) {
domainIdx = protoSepIdx + 3;
} else {
domainIdx = 0;
}
else {
domain = url.split('/')[0];
var domainEndIdx = url.indexOf('/', domainIdx);
if (domainEndIdx === -1) {
domainEndIdx = url.length;
}
return url.substring(0, domainEndIdx)
};
//find & remove port number
domain = domain.split(':')[0];
return domain;
}
Util.getQuaternionAngle = function(quat) {

@@ -472,0 +472,0 @@ // angle = 2 * acos(qw)

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