webvr-polyfill
Advanced tools
Comparing version 0.9.23 to 0.9.24
{ | ||
"name": "webvr-polyfill", | ||
"version": "0.9.23", | ||
"version": "0.9.24", | ||
"homepage": "https://github.com/googlevr/webvr-polyfill", | ||
@@ -11,2 +11,3 @@ "authors": [ | ||
"dependencies": { | ||
"eventemitter3": "^2.0.2", | ||
"object-assign": "^4.0.1" | ||
@@ -26,10 +27,10 @@ }, | ||
"scripts": { | ||
"build": "browserify src/main.js | derequire > build/webvr-polyfill.js", | ||
"watch": "watchify src/main.js -v -d -o 'derequire > build/webvr-polyfill.js'", | ||
"copy": "cp build/webvr-polyfill.js ../webvr-boilerplate/node_modules/webvr-polyfill/build/webvr-polyfill.js" | ||
"watch": "watchify src/main.js --standalone WebVRPolyfill -v -d -o 'derequire > build/webvr-polyfill.js'", | ||
"build": "browserify src/main.js --standalone WebVRPolyfill | derequire > build/webvr-polyfill.js", | ||
"min": "browserify src/main.js --standalone WebVRPolyfill | derequire | uglifyjs -c > build/webvr-polyfill.min.js" | ||
}, | ||
"repository": "borismus/webvr-polyfill", | ||
"repository": "googlevr/webvr-polyfill", | ||
"bugs": { | ||
"url": "https://github.com/borismus/webvr-polyfill/issues" | ||
"url": "https://github.com/googlevr/webvr-polyfill/issues" | ||
} | ||
} |
@@ -106,3 +106,5 @@ /* | ||
CardboardVRDisplay.prototype.onDeviceParamsUpdated_ = function(newParams) { | ||
console.log('DPDB reported that device params were updated.'); | ||
if (Util.isDebug()) { | ||
console.log('DPDB reported that device params were updated.'); | ||
} | ||
this.deviceInfo_.updateDeviceParams(newParams); | ||
@@ -219,4 +221,2 @@ | ||
CardboardVRDisplay.prototype.onOrientationChange_ = function(e) { | ||
console.log('onOrientationChange_'); | ||
// Hide the viewer selector. | ||
@@ -223,0 +223,0 @@ this.viewerSelector_.hide(); |
@@ -45,3 +45,2 @@ /* | ||
console.log('Fetching DPDB...'); | ||
var xhr = new XMLHttpRequest(); | ||
@@ -54,3 +53,2 @@ var obj = this; | ||
// Success. | ||
console.log('Successfully loaded online DPDB.'); | ||
obj.dpdb = JSON.parse(xhr.response); | ||
@@ -74,6 +72,3 @@ obj.recalculateDeviceParams_(); | ||
Dpdb.prototype.recalculateDeviceParams_ = function() { | ||
console.log('Recalculating device params.'); | ||
var newDeviceParams = this.calcDeviceParams_(); | ||
console.log('New device parameters:'); | ||
console.log(newDeviceParams); | ||
if (newDeviceParams) { | ||
@@ -112,5 +107,2 @@ this.deviceParams = newDeviceParams; | ||
var height = Util.getScreenHeight(); | ||
console.log('User agent: ' + userAgent); | ||
console.log('Pixel width: ' + width); | ||
console.log('Pixel height: ' + height); | ||
@@ -142,4 +134,2 @@ if (!db.devices) { | ||
if (this.matchRule_(rule, userAgent, width, height)) { | ||
console.log('Rule matched:'); | ||
console.log(rule); | ||
matched = true; | ||
@@ -194,2 +184,2 @@ break; | ||
module.exports = Dpdb; | ||
module.exports = Dpdb; |
@@ -66,3 +66,8 @@ /* | ||
// and gl.TEXTURE_BINDING_2D for texture unit 0. | ||
DIRTY_SUBMIT_FRAME_BINDINGS: false | ||
DIRTY_SUBMIT_FRAME_BINDINGS: false, | ||
// When set to true, this will cause a polyfilled VRDisplay to always be | ||
// appended to the list returned by navigator.getVRDisplays(), even if that | ||
// list includes a native VRDisplay. | ||
ALWAYS_APPEND_POLYFILL_DISPLAY: false | ||
}, window.WebVRConfig); | ||
@@ -69,0 +74,0 @@ |
@@ -20,4 +20,2 @@ /* | ||
var DEBUG = false; | ||
/** | ||
@@ -121,3 +119,3 @@ * An implementation of a simple complementary filter, which fuses gyroscope and | ||
if (DEBUG) { | ||
if (Util.isDebug()) { | ||
console.log('Delta: %d deg, G_est: (%s, %s, %s), G_meas: (%s, %s, %s)', | ||
@@ -124,0 +122,0 @@ MathUtil.radToDeg * Util.getQuaternionAngle(deltaQ), |
@@ -31,4 +31,3 @@ /* | ||
window.addEventListener('devicemotion', this.onDeviceMotionChange_.bind(this)); | ||
window.addEventListener('orientationchange', this.onScreenOrientationChange_.bind(this)); | ||
this.start(); | ||
@@ -184,2 +183,15 @@ this.filter = new ComplementaryFilter(WebVRConfig.K_FILTER); | ||
FusionPoseSensor.prototype.start = function() { | ||
this.onDeviceMotionCallback_ = this.onDeviceMotionChange_.bind(this); | ||
this.onScreenOrientationCallback_ = this.onScreenOrientationChange_.bind(this); | ||
window.addEventListener('devicemotion', this.onDeviceMotionCallback_); | ||
window.addEventListener('orientationchange', this.onScreenOrientationCallback_); | ||
}; | ||
FusionPoseSensor.prototype.stop = function() { | ||
window.removeEventListener('devicemotion', this.onDeviceMotionCallback_); | ||
window.removeEventListener('orientationchange', this.onScreenOrientationCallback_); | ||
}; | ||
module.exports = FusionPoseSensor; |
@@ -15,4 +15,4 @@ /* | ||
*/ | ||
var MathUtil = require('../math-util.js'); | ||
var DEBUG = false; | ||
var MathUtil = require('../math-util'); | ||
var Util = require('../util'); | ||
@@ -58,3 +58,3 @@ /** | ||
if (angularSpeed < MathUtil.degToRad * 20) { | ||
if (DEBUG) { | ||
if (Util.isDebug()) { | ||
console.log('Moving slowly, at %s deg/s: no prediction', | ||
@@ -61,0 +61,0 @@ (MathUtil.radToDeg * angularSpeed).toFixed(1)); |
@@ -205,5 +205,3 @@ /* | ||
canvas.style.height = (parseInt(height)) + 'px'; | ||
console.log('Resetting width to...', width); | ||
setTimeout(function() { | ||
console.log('Done. Width is now', width); | ||
canvas.style.width = width; | ||
@@ -219,2 +217,13 @@ canvas.style.height = height; | ||
Util.isDebug = function() { | ||
return Util.getQueryParameter('debug'); | ||
}; | ||
Util.getQueryParameter = function(name) { | ||
var name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); | ||
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), | ||
results = regex.exec(location.search); | ||
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); | ||
}; | ||
Util.frameDataFromPose = (function() { | ||
@@ -318,3 +327,3 @@ var piOver180 = Math.PI / 180.0; | ||
mat4_invert = function(out, a) { | ||
function mat4_invert(out, a) { | ||
var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3], | ||
@@ -321,0 +330,0 @@ a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7], |
@@ -16,5 +16,5 @@ /* | ||
var Emitter = require('./emitter.js'); | ||
var DeviceInfo = require('./device-info.js'); | ||
var EventEmitter3 = require('eventemitter3'); | ||
var Util = require('./util.js'); | ||
var DeviceInfo = require('./device-info.js'); | ||
@@ -41,3 +41,3 @@ var DEFAULT_VIEWER = 'CardboardV1'; | ||
} | ||
ViewerSelector.prototype = new Emitter(); | ||
ViewerSelector.prototype = new EventEmitter3(); | ||
@@ -48,3 +48,2 @@ ViewerSelector.prototype.show = function(root) { | ||
root.appendChild(this.dialog); | ||
//console.log('ViewerSelector.show'); | ||
@@ -63,3 +62,2 @@ // Ensure the currently selected item is checked. | ||
} | ||
//console.log('ViewerSelector.hide'); | ||
this.dialog.style.display = 'none'; | ||
@@ -66,0 +64,0 @@ }; |
@@ -34,7 +34,8 @@ /* | ||
this.nativeLegacyWebVRAvailable = this.isDeprecatedWebVRAvailable(); | ||
this.nativeGetVRDisplaysFunc = this.nativeWebVRAvailable ? | ||
navigator.getVRDisplays : | ||
null; | ||
if (!this.nativeLegacyWebVRAvailable) { | ||
if (!this.nativeWebVRAvailable) { | ||
this.enablePolyfill(); | ||
} | ||
this.enablePolyfill(); | ||
if (WebVRConfig.ENABLE_DEPRECATED_API) { | ||
@@ -110,11 +111,10 @@ this.enableDeprecatedPolyfill(); | ||
return self.isCardboardCompatible() && | ||
(document.fullscreenEnabled || | ||
document.mozFullScreenEnabled || | ||
document.webkitFullscreenEnabled || | ||
false); | ||
(self.isFullScreenAvailable() || Util.isIOS()); | ||
} | ||
}); | ||
// Provide the VRFrameData object. | ||
window.VRFrameData = VRFrameData; | ||
if (!'VRFrameData' in window) { | ||
// Provide the VRFrameData object. | ||
window.VRFrameData = VRFrameData; | ||
} | ||
}; | ||
@@ -133,10 +133,21 @@ | ||
this.populateDevices(); | ||
var displays = this.displays; | ||
return new Promise(function(resolve, reject) { | ||
try { | ||
resolve(displays); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
}); | ||
var polyfillDisplays = this.displays; | ||
if (this.nativeWebVRAvailable) { | ||
return this.nativeGetVRDisplaysFunc.call(navigator).then(function(nativeDisplays) { | ||
if (WebVRConfig.ALWAYS_APPEND_POLYFILL_DISPLAY) { | ||
return nativeDisplays.concat(polyfillDisplays); | ||
} else { | ||
return nativeDisplays.length > 0 ? nativeDisplays : polyfillDisplays; | ||
} | ||
}); | ||
} else { | ||
return new Promise(function(resolve, reject) { | ||
try { | ||
resolve(polyfillDisplays); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
}); | ||
} | ||
}; | ||
@@ -199,2 +210,9 @@ | ||
WebVRPolyfill.prototype.isFullScreenAvailable = function() { | ||
return (document.fullscreenEnabled || | ||
document.mozFullScreenEnabled || | ||
document.webkitFullscreenEnabled || | ||
false); | ||
}; | ||
// Installs a shim that updates a WebVR 1.0 spec implementation to WebVR 1.1 | ||
@@ -201,0 +219,0 @@ function InstallWebVRSpecShim() { |
Sorry, the diff of this file is too big to display
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
657590
2
32
11414
2
11
+ Addedeventemitter3@^2.0.2
+ Addedeventemitter3@2.0.3(transitive)