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

Wednesday, October 30th 2019, 6:11pm

How can I turn off infinity increase or decrease hlookat?

Hi,

is it possible to block decrease(turn left) and increase(turn right) horizontal value (view.hlookat). Currentlly, when I turn left, hlookat decreasing for infinity!! I would like obtain value for turn left ( 0 -179) and for turn right ( 0 179) and whenever value beyound -179 or 179 the value toggle from positive to negative or negative to positive. I hope I explained well enought for you to understand.

Greetings!

Alexey Tkachenko

Professional

Posts: 760

Location: Sevastopol, Crimea, Russian Federation

Occupation: Interpreting, Building virtual tours

  • Send private message

2

Thursday, October 31st 2019, 8:37am

Hi)

I guess it might be like this:

Source code

1
<events name="update_hlookat_values_event" keep="true" onviewchanged="update_hlookat_values();" />



and action

Source code

1
<action name="update_hlookat_values" >		if(view.hlookat GT 180, set(view.hlookat, -179));		if(view.hlookat LT -179, set(view.hlookat, 180));		trace(view.hlookat);	</action>
Regards,

Alexey

Tuur

Sage

Posts: 3,339

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

3

Thursday, October 31st 2019, 10:49am

Hi,

adjust hlookat is your friend here.
https://krpano.com/docu/actions/#adjusthlookat

Depends how you want to use it of course ... but something like this:
https://www.virtualtuur.com/krpano/120/e…/adjusthlookat/

Source code

1
2
3
4
5
6
7
8
9
10
11
    <layer name="adjustedhlookat" keep="true" type="text" align="right" html="" />

    <events name="fixview" keep="true" onviewchanged="DoLookat();" /> 
    <action name="DoLookat" type="Javascript"><![CDATA[
        
        krpano.call("adjusthlookat(0);");
        var hl = krpano.get("view.hlookat");
        var h = hl.toFixed(0);
        krpano.call("set(layer[adjustedhlookat].html, " + h + ");");
    
    ]]></action>


Hope it helps!
Tuur *thumbsup*
http://www.virtualtuur.com
Skype:studiotuur

4

Thursday, October 31st 2019, 11:45am

modulo is your friend :)

trace('hlookat = ', view.hlookat, ' = ', calc(view.hlookat % 180));
... ups seems calc does not support modulo and its not completely right anyway ...

but you can also do it with action code

mod(myhlookat, view.hlookat, 360);
if(myhlookat LT 0, add(myhlookat, 360)); // limit to 0-360
if(myhlookat GE 180, sub(myhlookat, 360)); // shift value to ±180 (optional)

uh, hope that's right *g* *rolleyes*

This post has been edited 7 times, last edit by "indexofrefraction" (Oct 31st 2019, 1:39pm)


5

Friday, November 1st 2019, 12:30am

thanks you guys :) I got it :))

Cheers

6

Friday, November 1st 2019, 7:46am

i think tuur was right :
adjustlookat(0); will directly set view.hlookat to ±180
that is the perfect solution