This post has been edited 1 times, last edit by "Nikkben" (Mar 27th 2023, 8:27pm)
![]() |
Source code |
1 |
change_backgroundurl('skybox.jpg'); |
![]() |
Source code |
1 |
change_backgroundurl(''); |
![]() |
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<action name="change_backgroundurl" type="javascript" args="url" scope="local"><![CDATA[ var url = args[1]; var parser = new DOMParser(); var scene = krpano.get('scene[get(xml.scene)]'); var xml = '<scene>' + scene.content + '</scene>'; var xmlDoc = parser.parseFromString(xml,"text/xml"); var depthmap = xmlDoc.getElementsByTagName("depthmap")[0]; depthmap.setAttribute("backgroundurl", url); scene.content = xmlDoc.documentElement.innerHTML; krpano.call("loadscene(get(xml.scene),, MERGE|KEEPVIEW|KEEPSCENES|PRELOAD, BLEND);"); ]]> </action> |
This post has been edited 2 times, last edit by "kme" (Apr 10th 2023, 4:48pm)
![]() |
Source code |
1 2 3 4 5 6 7 8 9 10 11 |
<scene name="scene_with_background" autoload="true" title="hello" onstart="" > <image> <depthmap backgroundurl="skybox.jpg" id="depthmap" url="models/gallery_06.obj" subdiv="0" rendermode="3dmodel" hittest="true" scale="100" textured="true" waitforload="true" center="0,0,0" axis="+x+y+z"/> </image> </scene> <scene name="scene_without_background" autoload="true" title="hello" onstart="" > <image> <depthmap id="depthmap" url="models/gallery_06.obj" subdiv="0" rendermode="3dmodel" hittest="true" scale="100" textured="true" waitforload="true" center="0,0,0" axis="+x+y+z"/> </image> </scene> |
![]() |
Source code |
1 |
loadscene(scene_with_background,, MERGE|KEEPSCENES|PRELOAD, BLEND); |
![]() |
Source code |
1 |
loadscene(scene_without_background,, MERGE|KEEPSCENES|PRELOAD, BLEND); |
Thank you very much, when calling change_background url(") it gives an error : ERROR: change_backgroundurl - TypeError: Cannot read properties of undefined (reading 'setAttribute')Hi,
The action below allows for changing the background URL.
You can use it to set the url of the skybox, for example:
![]()
Source code
1 change_backgroundurl('skybox.jpg');
or to clear the backgroundurl:
![]()
Source code
1 change_backgroundurl('');
Action code:
![]()
Source code
1
I hope Klaus will come with some better support to change the backgroundurl![]()
![]() |
Source code |
1 2 3 4 5 |
<scene name="scene_with_background" autoload="true" title="hello" onstart="" > <image> <depthmap id="depthmap" url="models/gallery_06.obj" subdiv="0" rendermode="3dmodel" hittest="true" scale="100" textured="true" waitforload="true" center="0,0,0" axis="+x+y+z"/> </image> </scene> |
![]() |
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
<scene name="model" minpixelzoom="0" autoload="true" > <view hlookat="90" vlookat="0" fovtype="MFOV" fov="140.000" maxpixelzoom="1" minpixelzoom="0" fovmin="70" fovmax="140" limitview="lookat" vlookatmin="-90" vlookatmax="90" /> <image prealign="-0.0|-0.0|-0.0" ox="0" oy="25" oz="0" > <depthmap id="depthmap" url="panos/untitled2.obj" backgroundurl="panos/vid_main_optim2.jpg" scale="100" hittest="true" waitforload="true" cull="front" subdiv="0" /> </image> <layer name="dron_container" type="container" bgalpha="1" bgborder="0 0x000000 0" alpha="1" align="bottom" keep="true" x="-37.5" y="90" scale="1" scale.mobile="1" visible="true" bgcapture="false" onover="set(layer[podpis_dron].visible,true); " onout="set(layer[podpis_dron].visible,false); "> <layer name="dron_knopka" type="image" url="skin/dron.svg" width="75" height="75" onclick="change_backgroundurl(''); dollhouse_view(); set(layer[dron_container].visible,false); " onover=" " onout=" " visible="true" scale.mobile="0.6" y.mobile="65" x.mobile="-7" bgcapture="false"/> </layer> </scene> |
![]() |
Source code |
1 2 3 |
image.reset('copy'); // copy the current image settings image.depthmap.backgroundurl = ''; // clear the backgroundurl loadpanoimage(KEEPVIEW|PRELOAD,BLEND(0.5)); // load the new image |