You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Thursday, August 11th 2011, 9:03pm

changing scenes via javascript

So I'm having difficulty doing something that seems rather easy. I know within the krpano, it's easy to put hotspots and move to other hotspots. Well I have a map outside of the krpano and I want to make a javascript call to the krpano to change the scene. Sounds simple, right? I've tried two different strategies, both of which are giving me problems. The first one, loads up a new krpano each time i call selectpano(id):

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
var viewer;
function selectpano(id){

	$('#panoholder').hide();//hide the view while we load the pano
	$('#viewport').html('');//clear out the krpano object
	
		viewer = createPanoViewer({swf:"includes/krpano.swf", xml:"includes/panos-fla-kiosk.xml", target:"viewport"});
		if (viewer.isHTML5possible() ){
			viewer.useHTML5("always");
			viewer.embed();
			document.getElementById("krpanoSWFObject").set('scenename','scene_'+id);
		}

		//wait a second for it to load and then show it
		setTimeout(function(){$('#panoholder').show();},1000);
}


This seems to not be good after a while of navigating from pano to pano to pano. It just gets bogged down and slows significantly after extended use. So I tried another method. This one keeps the same krpano, but just changes the scene within it. *Conceptually* this seems like it's more light weight:

Source code

1
2
3
4
5
6
7
8
9
10
function selectpano(id){
	$('#viewport').hide();

	//the krpanoSWFObject was already initialized onload
	document.getElementById("krpanoSWFObject").call('lookto(0,0,get("view.fov")); loadscene("scene_'+id+'", null, MERGE); wait(LOAD); js(showpano("'+id+'"));');
}

function showpano(id){//this is called after the scene has loaded, so show the pano now
	$('#viewport').show();
}


But I get the same problem here. In the beginning it takes about 4-5 seconds to load the pano on the selectpano(id) call. Each subsequent call of that function for a different pano slows the load time until, ultimately, the showpano() (the function that gets called after the loadscene call is completed, never gets called.

Can somebody help me? It seems that changing scenes via javascript should be a very fundamental and easy thing to accomplish. What am I doing wrong? Has anybody else run into this problem before?

Posts: 1,850

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

2

Thursday, August 11th 2011, 9:55pm

probably should post a link...
did you try without using the viewport stuff?
I don't see anything inherently wrong with just calling loadscene via js.
Maybe try this instead...
var krpano = document.getElementById("krpanoSWFObject");
krpano.call("");
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

3

Thursday, August 11th 2011, 10:19pm

Yeah, I guess that's a good idea :)

Here's the link:
http://archive.cyark.org/iphone/sat.php

It obviously wasn't meant to display in safari as an end product, but it works the same. Just click Virtual Tour, then select one of the missions, and then select a blue dot to load a pano. It takes forever to load. If you want to view the js file, it is at:

http://archive.cyark.org/iphone/includes/application-sat.js

Hopefully this can help shed some light on my problem .....

Posts: 1,850

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

4

Friday, August 12th 2011, 3:40am

Jeepers that's slot of js code.
I think it must be in some of your code.
Try breaking your project down to bare minimum and then build it back up until you repro the problem since I don't think it's in just js(loadscene
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

5

Friday, August 12th 2011, 6:36pm

Well I disagree with that statement. That's not that much code at all. All of it is necessary. And most of the functions don't even get called until the user specifically requests that feature. Or, in other words, if the user just goes straight to the pano and doesn't play audio, use the accelerometer/compass, or use gps, most of the javascript isn't even called.

So, as most of the functions in that js file have nothing to do with the pano itself, they really don't have any bearing on this issue. I just want to know how to change scenes in my krpano object using javascript in a reasonable time. I've attempted to write two selectpano() functions, neither of which perform very well. How can I better write this function?

Posts: 1,850

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

6

Saturday, August 13th 2011, 12:29am

what device is this tour for?
I tried the iPad and never got into a problem except for the interface.
on the iphone4, everything is off the screen and the interface doesn't respond even in landscape.
Oh i see. On the Iphone the tours do not load at all of take freaking forever!
There must be some memory issue. Try smaller cubefaces or building your interface in krpano instead.. and just utilize the bare bones html. My complex interfaces work fine in krpano..
You don't really need to use outside js for anything here.. Everything can be done with JS and krpano XML.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

7

Monday, August 15th 2011, 1:37am

The app is for ipads and iphones. And I package it with phonegap, so any issues you see with layout are because you're viewing it in safari, not in it's packaged form. There are no formatting/layout issues with this when it gets packaged.

My images are 1000px square jpgs, and there are six of them (obviously). Is that too big. Would sizing them down improve performance? What size do you use?

And to your point of building my interface in krpano, my application requires playing/controlling audio, using the hardware to control the view heading (i know krpano can do this), and having a map that is panable and zoomable, among other things. I don't think krpano can do much of this, so how can I build my app in krpano?

Posts: 1,850

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

8

Monday, August 15th 2011, 4:17am

Well maybe, but you can always send your krpano back to your pan-able zoom-able page.. no need to share memory.
Also on each of your cube faces i can see the seam. You should be able to make a great tour with just a few hours of fixing!
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

9

Monday, August 15th 2011, 6:35am

Well maybe, but you can always send your krpano back to your pan-able zoom-able page.. no need to share memory.
What do you mean by send my krpano back? Do you mean destroy that object in memory?

And how exactly do I fix those seams? What causes those? Is there any documentation on this site to fix that? I couldn't find any.

10

Monday, August 15th 2011, 6:49am

Try updating the .js files with the latest beta. That should fix the seams. Better to use the update tool and update the .swf and .js

11

Wednesday, August 17th 2011, 1:00am

I just did both of the suggestions from jarred and sasha.

I tried the new beta of the js. That didn't have any impact on the seams. Note that my previous version was 1.0.8.14 (build 2011-04-01). So I didn't have a really old version to start with. I didn't really notice any other changes in my brief demoing of it

I also tried to downsize my images from 1000px to 512px. I did notice *some* improvement in load time. Previously, with the 1000px images, it took perhaps 5 seconds to load the new pano. With the 512px images, it took maybe 4 seconds. So that doesn't give me the mammoth improvement I'm looking for. How can I load these panos faster? Or is this pano viewer supposed to take a handful of seconds to load a pano?