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

sphere-viewer

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sphere-viewer - npm Package Compare versions

Comparing version 1.1.5 to 1.1.6

2

package.json
{
"name": "sphere-viewer",
"version": "1.1.5",
"version": "1.1.6",
"description": "A simple JavaScript library for displaying spherical images on desktop and mobile browsers",

@@ -5,0 +5,0 @@ "main": "dist/sphere-viewer.js",

@@ -46,20 +46,14 @@ /**

var ProgressiveImgLoader = function() { };
var ProgressiveImgLoader = function() {
var proto = ProgressiveImgLoader.prototype = Object.create( THREE_EventDispatcher.prototype );
proto.load = function(images) {
var self = this;
var texture = new THREE_Texture();
self.texture = new THREE_Texture();
// create an image object
var imageObj = self.imageObj = new Image(),
loadingIx = 0;
self.imageObj = new Image();
// this needs to be sit in order not to get "Tainted canvases may not be loaded." WebGL error
imageObj.crossOrigin = "anonymous";
self.imageObj.crossOrigin = "anonymous";
imageObj.onload = function() {
self.imageObj.onload = function() {

@@ -69,10 +63,10 @@ // [imageObj] is set to NULL when the object is disposed

texture.needsUpdate = true;
self.texture.needsUpdate = true;
if(loadingIx < images.length) {
self.dispatchEvent({type: 'progress', imageIndex: loadingIx});
if(self.loadingIx < self.images.length) {
self.dispatchEvent({type: 'progress', imageIndex: self.loadingIx});
// don't change the image [src] until the texture had a chance to update itself
window.setTimeout(function() {
imageObj.src = images[loadingIx++];
self.imageObj.src = self.images[self.loadingIx++];
}, 1000);

@@ -82,3 +76,2 @@

self.dispatchEvent({type: 'done'});
self.imageObj = null;
}

@@ -89,8 +82,20 @@

}; // imageObj.onload = function() {...}
self.texture.image = self.imageObj;
};
var proto = ProgressiveImgLoader.prototype = Object.create( THREE_EventDispatcher.prototype );
proto.load = function(images) {
var self = this;
self.images = images;
self.loadingIx = 0;
// the loading process will begin after we set the [src] property
imageObj.src = images[loadingIx++];
texture.image = imageObj;
self.imageObj.src = self.images[self.loadingIx++];
return(texture);
return(self.texture);

@@ -97,0 +102,0 @@ }; // proto.load = function(images) {...}

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

this.imgLoader = new ProgressiveImgLoader();
this.loader_onDone = this.loader_onDone.bind(this);
this.imgLoader.addEventListener('done', this.loader_onDone);
var geometry = new THREE_SphereGeometry(speherRadius, sphere_H_segments, sphere_V_segments);

@@ -387,3 +381,3 @@

new THREE_MeshBasicMaterial({
map: this.imgLoader.load(this.config.sphere),
map: this.loadImages(this.config.sphere),
side: THREE_FrontSide // displaying the texture on the outer side of the sphere

@@ -396,3 +390,2 @@ })

this.showLoader();
}; // proto.initSphere = function(imageUrls) {...}

@@ -521,2 +514,3 @@

proto.loader_onDone = function() {
console.log("loader_onDone");
this.loader_onDone = null; // loader mi više nije potreban

@@ -550,2 +544,25 @@ this.hideLoader();

/*-------------------------------------------------------------------------*//**
* Fetches the images from server and assignes them to a texture
*
* @param {Array} images array containg image URLs
* @return {Texture} Three.js texture on which the images will be painted
*/
proto.loadImages = function(images) {
if(!this.imgLoader) {
this.imgLoader = new ProgressiveImgLoader();
this.loader_onDone = this.loader_onDone.bind(this);
this.imgLoader.addEventListener('done', this.loader_onDone);
}
this.showLoader();
return(this.imgLoader.load(images));
}; // proto.loadImages = function(images) {...}
export { SphereViewer as Viewer }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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