diff --git a/README.md b/README.md index 0718f120..6b43e518 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ Name | Type | Parameter description `height` | String | String value for the iframe's height attribute. `preview` | String | (Optional) URL to a preview image for a 360° image file. `is_stereo` | Boolean | (Optional) Indicates whether the content at the image or video URL is stereo or not. +`is_sbs` | Boolean | (Optional) Indicates whether the content at image or video URL is Side-By-Side or Over-Under. Defaults to Over-Under (false). +`is_180` | Boolean | (Optional) Indicates whether the content at image or video URL is VR180 or VR360. Defaults to VR360 (false). `is_debug` | Boolean | (Optional) When true, turns on debug features like rendering hotspots ad showing the FPS meter. `is_vr_off` | Boolean | (Optional) When true, disables the VR mode button. `is_autopan_off` | Boolean | (Optional) When true, disables the autopan introduction on desktop. diff --git a/src/embed/scene-info.js b/src/embed/scene-info.js index d283b576..646714da 100644 --- a/src/embed/scene-info.js +++ b/src/embed/scene-info.js @@ -28,7 +28,9 @@ var CAMEL_TO_UNDERSCORE = { isDebug: 'is_debug', isVROff: 'is_vr_off', isAutopanOff: 'is_autopan_off', - hideFullscreenButton: 'hide_fullscreen_button' + hideFullscreenButton: 'hide_fullscreen_button', + isSideBySide: 'is_sbs', + is180: 'is_180' }; /** @@ -48,6 +50,8 @@ function SceneInfo(opt_params) { this.defaultYaw = THREE.Math.degToRad(params.defaultYaw || 0); this.isStereo = Util.parseBoolean(params.isStereo); + this.isSideBySide = Util.parseBoolean(params.isSideBySide); + this.is180 = Util.parseBoolean(params.is180); this.isYawOnly = Util.parseBoolean(params.isYawOnly); this.isDebug = Util.parseBoolean(params.isDebug); this.isVROff = Util.parseBoolean(params.isVROff); diff --git a/src/embed/sphere-renderer.js b/src/embed/sphere-renderer.js index f454d727..5556ab76 100644 --- a/src/embed/sphere-renderer.js +++ b/src/embed/sphere-renderer.js @@ -39,6 +39,8 @@ SphereRenderer.prototype.setPhotosphere = function(src, opt_params) { var params = opt_params || {}; this.isStereo = !!params.isStereo; + this.isSideBySide = !!params.isSideBySide; + this.is180 = !!params.is180; this.src = src; // Load texture. @@ -52,7 +54,7 @@ SphereRenderer.prototype.setPhotosphere = function(src, opt_params) { /** * @return {Promise} Yeah. */ -SphereRenderer.prototype.set360Video = function (videoElement, videoType, opt_params) { +SphereRenderer.prototype.setVideo = function (videoElement, videoType, opt_params) { return new Promise(function(resolve, reject) { this.resolve = resolve; this.reject = reject; @@ -60,6 +62,8 @@ SphereRenderer.prototype.set360Video = function (videoElement, videoType, opt_pa var params = opt_params || {}; this.isStereo = !!params.isStereo; + this.isSideBySide = !!params.isSideBySide; + this.is180 = !!params.is180; // Load the video texture. var videoTexture = new THREE.VideoTexture(videoElement); @@ -110,8 +114,13 @@ SphereRenderer.prototype.onTextureLoaded_ = function(texture) { var sphereLeft; var sphereRight; if (this.isStereo) { - sphereLeft = this.createPhotosphere_(texture, {offsetY: 0.5, scaleY: 0.5}); - sphereRight = this.createPhotosphere_(texture, {offsetY: 0, scaleY: 0.5}); + if (this.isSideBySide) { + sphereLeft = this.createPhotosphere_(texture, {offsetX: 0.5, scaleX: 0.5}); + sphereRight = this.createPhotosphere_(texture, {offsetX: 0, scaleX: 0.5}); + } else { + sphereLeft = this.createPhotosphere_(texture, {offsetY: 0.5, scaleY: 0.5}); + sphereRight = this.createPhotosphere_(texture, {offsetY: 0, scaleY: 0.5}); + } } else { sphereLeft = this.createPhotosphere_(texture); sphereRight = this.createPhotosphere_(texture); @@ -125,8 +134,7 @@ SphereRenderer.prototype.onTextureLoaded_ = function(texture) { sphereRight.eye = Eyes.RIGHT; sphereRight.name = 'eyeRight'; - - this.scene.getObjectByName('photo').children = [sphereLeft, sphereRight]; + this.scene.getObjectByName('photo').children = [sphereLeft, sphereRight]; this.resolve(); }; @@ -142,8 +150,8 @@ SphereRenderer.prototype.createPhotosphere_ = function(texture, opt_params) { p.scaleY = p.scaleY || 1; p.offsetX = p.offsetX || 0; p.offsetY = p.offsetY || 0; - p.phiStart = p.phiStart || 0; - p.phiLength = p.phiLength || Math.PI * 2; + p.phiStart = p.phiStart || this.is180 ? Math.PI * 0.5 : 0; + p.phiLength = p.phiLength || Math.PI * (this.is180 ? 1 : 2); p.thetaStart = p.thetaStart || 0; p.thetaLength = p.thetaLength || Math.PI; diff --git a/src/embed/world-renderer.js b/src/embed/world-renderer.js index 92ebebfb..08f31ecc 100644 --- a/src/embed/world-renderer.js +++ b/src/embed/world-renderer.js @@ -83,6 +83,8 @@ WorldRenderer.prototype.setScene = function(scene) { var params = { isStereo: scene.isStereo, + isSideBySide: scene.isSideBySide, + is180: scene.is180, loop: scene.loop, volume: scene.volume, muted: scene.muted @@ -142,7 +144,7 @@ WorldRenderer.prototype.setScene = function(scene) { } else { this.player = new AdaptivePlayer(params); this.player.on('load', function(videoElement, videoType) { - self.sphereRenderer.set360Video(videoElement, videoType, params).then(function() { + self.sphereRenderer.setVideo(videoElement, videoType, params).then(function() { self.didLoad_({videoElement: videoElement}); }).catch(self.didLoadFail_.bind(self)); });