|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<layer name="inf_l" type="text" keep="true" edge="bottom" oy="-20" enabled="false" bgalpha="0.3" onloaded="show_distance(); delayedcall(0.01, onloaded());" /> <action name="show_distance" scope="local" > screentodepth( mouse.x, mouse.y, hit); copy(caller.x, mouse.x); copy(caller.y, mouse.y); calc(caller.html, 'mouse hit.d=' + roundval(hit.d, 1)); </action> <style name="hs" type="text" keep="true" distorted="false" depth="0" depthbuffer="false" rotationorder="zxy" bg="true" padding="2 5 2 5" html="hs" onclick="show_distance2()" /> <hotspot name="hs1" style="hs" tx="-100" ty="300" tz="300" /> <hotspot name="hs2" style="hs" tx="-300" ty="0" tz="200" /> <action name="show_distance2" scope="local" > raycastdepth(view.tx, view.ty, view.tz, caller.tx, caller.ty, caller.tz, hit ); calc(caller.html,'hit.d='+ roundval(hit.d, 1)); trace(caller.html); </action> |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »San7« (2. März 2023, 04:29)
Benutzerinformationen überspringen
Wohnort: Netherlands
Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer
: https://pame.virtualtuur.comBeen looking at it a bit and no idea yet but i noticed 2 things:
- when starting from the origin and moving UP ONLY, the distance on hs1 stays the same, while it does change on hs2
- when starting form the origin and moving BACK ONLY, the distance on hs2 changes, but not on hs2
Something to do with ty/tz values somewhere, but still puzzling, but wanted to share this finding, maybe it gives someone else a hint.
There is an example below that states
raycastdepth(view.tx, view.ty, view.tz, view.dir.x, view.dir.y, view.dir.z, hit);
This means we can determine the distance from any point in the view, in this example in the forward direction
|
|
Quellcode |
1 2 3 4 5 6 7 8 9 |
<action name="show_distance2" scope="local" > raycastdepth(view.tx, view.ty, view.tz, caller.tx, caller.ty, caller.tz, hit ); raycastdepth(view.tx, view.ty, view.tz, view.dir.x, view.dir.y, view.dir.z, hitv); trace(caller.name); trace(caller.tx, "|", caller.ty, "|", caller.tz); calc(caller.html,'hit.d='+ roundval(hit.d, 1) + '|' + roundval(hitv.d, 1)); trace(caller.html); </action> |
Been debugging it a bit, the only thing I can think of is that the raycastdepth is not requesting a LOCATION for the distance, but a DIRECTION.
See documentation: https://krpano.com/docu/actions/#raycastdepth
mentions: 3D direction vector of the ray.
Not sure how to translate the "current view to hotspot location" to "current view to view direction".
Or do you mean that you need to specify the delta dx dy dz ?
|
|
Quellcode |
1 2 3 |
trace(view.dir.x); trace(view.dir.y); trace(view.dir.z); |
|
|
Quellcode |
1 2 3 |
INFO: -0.9417157173156738 INFO: 0.02299703285098076 INFO: 0.3356228470802307 |
|
|
Quellcode |
1 |
raycastdepth(view.tx, view.ty, view.tz, caller.tx, caller.ty, caller.tz, hit ); |
|
|
Quellcode |
1 |
raycastdepth(view.tx, view.ty, view.tz, (caller.tx - view.tx), (caller.ty - view.ty), (caller.tz - view.tz), hit ); |
Hi,
right, you need a direction vector, e.g. between the hotspot and the view.
E.g. instead of:
![]()
Quellcode
1 raycastdepth(view.tx, view.ty, view.tz, caller.tx, caller.ty, caller.tz, hit );
try this:
![]()
Quellcode
1 raycastdepth(view.tx, view.ty, view.tz, (caller.tx - view.tx), (caller.ty - view.ty), (caller.tz - view.tz), hit );
Best regards,
Klaus