Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

ImageLoader.load fails if URL is relative path and image URL is no-cache #204

Closed
claytonrothschild opened this issue Oct 19, 2019 · 3 comments
Assignees
Labels
Stale Stale - Subject to be deleted

Comments

@claytonrothschild
Copy link

claytonrothschild commented Oct 19, 2019

I noticed a breaking change in R9 to v0.11. Infospots sometimes dont appear on a scene if they use a relative image path and that image path has not been downloaded previously or is not cached. I'm on latest master.

I typically load hotspots like so:

new PANOLENS.Infospot(350, '/public/hotspot-icon-black.png');

Note the relative url.

When we get to ImageLoader.load, we try to find the url in cache like so:

cached = THREE.Cache.get( reference ? reference : url );
		
	        if ( cached !== undefined ) {
				console.log('found in cache',cached) 
		
	            if ( onLoad ) {
		
	                setTimeout( function () {
		
	                    onProgress( { loaded: 1, total: 1 } );
	                    onLoad( cached );
		
	                }, 0 );
		
	            }
		
	            return cached;
		
	        }

For some reason, if I have a scene with three or more hotspots, all with the same relative URL, the second hotspot never shows on the panorama if I'm loading the viewer instance for the first time. (Page refresh). I've tried many scenes and many scenarios. The panorama has the object as a child, but it just doesn't show, even when I try to show() it.

If i'm setting to the scene and I've already downloaded the asset, there is no problem.

It's something to do with a cached image.

My solution is to replace:

cached = THREE.Cache.get( reference ? reference : url );

with:

validatedUrl = url.indexOf('http') != -1 ? url : null; // make sure not relative, perhaps allow for blob as well
	        cached = THREE.Cache.get( reference ? reference : validatedUrl );

I'm happy to make a pull request if you want to give guidance here. I will work on an example when I have a moment. Otherwise, feel free to close this issue.

Thank you,
Clayton

@claytonrothschild claytonrothschild changed the title ImageLoader.load fails if URL is relative path and image URL is ImageLoader.load fails if URL is relative path and image URL is no-cache Oct 19, 2019
@ghost
Copy link

ghost commented Apr 23, 2020

oh man, thanks! I've been looking for a solution for so long. And it's so easy! Thank you!

@flyandi flyandi added the Stale Stale - Subject to be deleted label Feb 18, 2021
@flyandi flyandi closed this as completed Mar 21, 2021
@deborah-bude
Copy link

Hello, I don't understand the solution, do you need a specific file to do it?

@emilaz
Copy link

emilaz commented Apr 20, 2022

I'm having the same issue here. I currently need to create copies of my used infospot image for them to show. Could we reopen this issue?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Stale Stale - Subject to be deleted
Projects
None yet
Development

No branches or pull requests

5 participants