How to set different view directions in a tour?

  • I'd like to set the view direction for a pano depending on which pano the user comes from. For example, if a user is in pano A and clicks to see pano B, they arrive in pano B looking in one direction. But if they are in pano C and click to see pano B they arrive in pano B looking in a different direction.

    This sort of thing seems fairly important for creating cross-linked tours. I tried using a variable to set a specific pan parameter in the onclick() part of a hostpost and then using that variable as the first part of the lookto() instructions in an action - but this gives me a black pano. Peeking into the options plugin display shows that lookat is NaN/NaN (not a number)... so I'm obviously messing this up completely! *smile*

    (I must admit that I'm guessing wildly about how to use variables - that's not helping!)

    Can anyone offer any advice?

    Keith

  • Sounds brilliant, and SO much simpler than the process I was trying!
    The only problem seems to be... that it doesn't work for me. here's my onclick line:

    Code
    onclick="loadpano(9.xml, view.lookat(180,-1,80), MERGE, BLEND(0.5));"

    I simply replaced the NULL with view.lookat(180,-1,80), removed the onstart item that set the initial view, and tried it out. This is what I get:

    Code
    ERROR: unknown attriubate/path - view.lookat(180,-1,80)


    Any suggestions very gratefully received! This seems like the ideal way forward, I just need to find out why the error happens and kill it off.

    (BTW, Klaus? The error message contains a spelling mistake. "attriubate" rather than "attribute". *smile*

  • Using lookat() rather than view.lookat() stops the error from popping up, but I get odd results still.

    With MERGE in place the pan setting in the destination comes directly from the previous pano. With it set to NULL instead the pan is always 0, no matter what I put in lookat(). So perhaps all that does is stop the error - but not actually *work*! Hmm...

    Keith

  • take a look at the example virtual tours here... http://www.krpano.com/examples/vtour/

    specifically the group under "via hotspots connected panoramas"

    The xml's for each are listed and accessible as well... but here's a clip of code that would do what you wanted...

    Code
    onClick="set(view.fovmin,6);lookto(8.8165,-3.4802,6,smooth());loadpano(keller.xml,null,KEEPBASE|NOPREVIEW,BLEND(2), lookat(188.92,1.51,40);wait(blend);lookto(335.66,7.98,90,smooth(100,100,100)))"

    specifically this part...

    Code
    loadpano(keller.xml,null,KEEPBASE|NOPREVIEW,BLEND(2), lookat(188.92,1.51,40);wait(blend);lookto(335.66,7.98,90,smooth(100,100,100)))

    The loadpano format is...

    loadpano(xmlpath,parameters,flags,blend,onstart)

    ... and you must keep the "null" in place for items that you don't want to specify... so after the xmlpath, if there are no parameters, then you need to keep the null there.

    Your code would look like this...

    Code
    onclick="loadpano(9.xml, null, MERGE, BLEND(0.5), lookat(180,-1,80));"
  • Hi,

    sorry, the documentation is not fully up to date

    you don't need to use the "onstart" parameter anymore, you can just place other commands
    after the loadpano() call, they will be executed after the pano was loaded,

    e.g.

    Code
    onclick="loadpano(pano2.xml,null,MERGE,BLEND(1)); lookat(180,-1,80);"

    but the view direction (or any other value) can be also set direct:

    Code
    onclick="loadpano(pano2.xml,view.hlookat=180&view.vlookat=-1&view.fov=98,MERGE,BLEND(1));"

    best regards,
    Klaus

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!