Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sphere.js #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions lib/sphere.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
// Usage: new Photosphere("image.jpg").loadPhotosphere(document.getElementById("myPhotosphereID"));
// myPhotosphereID must have width/height specified!


function Photosphere(image){
// 2014-03-03 ericball - added optional vertical field of view parameter
function Photosphere(image, vFoV){
this.image = image;
this.vFov = (typeof vFoV === "undefined") ? 75 : vFoV;
//this.worker = new Worker("worker.js");
}

Expand Down Expand Up @@ -108,7 +109,8 @@ Photosphere.prototype.start3D = function(image){
this.lat = 0; this.lon = 90;
this.onMouseDownMouseX = 0, this.onMouseDownMouseY = 0, this.isUserInteracting = false, this.onMouseDownLon = 0, this.onMouseDownLat = 0;

this.camera = new THREE.PerspectiveCamera( 75, parseInt(this.holder.offsetWidth) / parseInt(this.holder.offsetHeight), 1, 1100 );
// 2014-03-03 ericball - added optional vertical field of view parameter
this.camera = new THREE.PerspectiveCamera( this.vFoV, parseInt(this.holder.offsetWidth) / parseInt(this.holder.offsetHeight), 1, 1100 );
this.scene = new THREE.Scene();
mesh = new THREE.Mesh( new THREE.SphereGeometry( 200, 20, 40 ), this.loadTexture( image ) );
mesh.scale.x = - 1;
Expand Down Expand Up @@ -147,7 +149,7 @@ Photosphere.prototype.start3D = function(image){
Photosphere.prototype.startMoving = function(){
self = this;
this.interval = setInterval(function(){
self.lon = self.lon - 0.1;
self.lon = self.lon + 0.1;

if( -3 < self.lat && self.lat < 3){}
else if(self.lat > 10){ self.lat -= 0.1 }
Expand Down Expand Up @@ -338,9 +340,11 @@ Photosphere.prototype.loadEXIF = function(callback){
xmpEnd = "</x:xmpmeta>";
xmpp = data.substring(data.indexOf("<x:xmpmeta"), data.indexOf(xmpEnd) + xmpEnd.length);

// 2014-02-26 ericball - modified getAttr to handle exiftool tags e.g. <GPano:FullPanoWidthPixels>3000</GPano:FullPanoWidthPixels>
getAttr = function(attr){
x = xmpp.indexOf(attr+'="') + attr.length + 2;
return xmpp.substring( x, xmpp.indexOf('"', x) );
x = xmpp.indexOf(attr) + attr.length;
s = xmpp.substring( x );
return s.match(/[0-9]+/)[0];
};

self.exif = {
Expand Down