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

Sunday, March 26th 2023, 4:28pm

Disabling backgoundurl

Hello guys it possible to disable the depthmap.backgroundurl by onclick=" " ?

<depthmap url="panos/untitled2.obj" backgroundurl="panos/vid_main_optim2.jpg" scale="100" hittest="true" cull="front" />

This post has been edited 1 times, last edit by "Nikkben" (Mar 27th 2023, 8:27pm)


kme

Intermediate

Posts: 308

Location: Belgium

Occupation: Long time coder, product manager and 3D enthousiast

  • Send private message

2

Monday, April 10th 2023, 11:24am

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
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>


I hope Klaus will come with some better support to change the backgroundurl *cool*

This post has been edited 2 times, last edit by "kme" (Apr 10th 2023, 4:48pm)


kme

Intermediate

Posts: 308

Location: Belgium

Occupation: Long time coder, product manager and 3D enthousiast

  • Send private message

3

Monday, April 10th 2023, 11:35am

And now that I posted this, I think of another way: just duplicate your scene with and without a background and use loadscene to switch between the 2?


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>	



And then:

Source code

1
loadscene(scene_with_background,, MERGE|KEEPSCENES|PRELOAD, BLEND);


or

Source code

1
loadscene(scene_without_background,, MERGE|KEEPSCENES|PRELOAD, BLEND);


Which basically does the same as the action in the previous post, but then not dynamically.

4

Monday, April 10th 2023, 3:04pm

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 *cool*
Thank you very much, when calling change_background url(") it gives an error : ERROR: change_backgroundurl - TypeError: Cannot read properties of undefined (reading 'setAttribute')

kme

Intermediate

Posts: 308

Location: Belgium

Occupation: Long time coder, product manager and 3D enthousiast

  • Send private message

5

Monday, April 10th 2023, 3:09pm

Do you have a depthmap inside your <image> ?

the <scene> i have tested with looks like this:

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>


Is there an example online to simulate the error?

6

Monday, April 10th 2023, 3:28pm

here is my scene :


<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>
</scene>



kme

Intermediate

Posts: 308

Location: Belgium

Occupation: Long time coder, product manager and 3D enthousiast

  • Send private message

7

Monday, April 10th 2023, 3:41pm

looks good.

where are you calling the function?
the scene must be loaded before it can be called...

8

Monday, April 10th 2023, 3:51pm

onclick="change_backgroundurl('');

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>

kme

Intermediate

Posts: 308

Location: Belgium

Occupation: Long time coder, product manager and 3D enthousiast

  • Send private message

9

Monday, April 10th 2023, 4:41pm

I have updated the <action> in the second post to work with more <scene> tags :)

(I also added KEEPVIEW so the view stays the same even when a view is defined in the scene)

10

Tuesday, April 11th 2023, 4:50pm

Hi,

it should be even easier using loadpanoimage & image.reset:

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


Best regards,
Klaus

kme

Intermediate

Posts: 308

Location: Belgium

Occupation: Long time coder, product manager and 3D enthousiast

  • Send private message

11

Tuesday, April 11th 2023, 5:15pm

beauty in simplicity *thumbsup*