You are not logged in.

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,822

Location: Netherlands

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

  • Send private message

1

Tuesday, May 30th 2023, 3:17pm

includexml

Hi,

I am looking for a way to include an xml (path) relative to the plugin (js) location that is calling this.

like:
krpano.actions.includexml("stickie_data.xml");

the stickie_data.xml is in the same folder as the js plugin calling the includexml.

%VIEWER% etc seems not a good option when people use basepath etc..
Any idea?


Tuur *thumbsup*

kme

Intermediate

Posts: 308

Location: Belgium

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

  • Send private message

2

Tuesday, May 30th 2023, 4:18pm

I see this in some files, have not tested it but seems what you are looking for


Source code

1
2
3
4
	<!-- save the url path of this xml file (the url value will be adjusted during xml parsing) -->
	<videointerfacexmlpath url="./" />

	<style name="skin_base" url="calc:videointerfacexmlpath.url + skin_settings.design_skin_images" />

kme

Intermediate

Posts: 308

Location: Belgium

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

  • Send private message

3

Tuesday, May 30th 2023, 4:27pm

Also, if from javascript, the threejs sample plugin

https://krpano.com/viewsource.html?plugi…krpanoplugin.js

has a resolve_url_path() function which may be of help.

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,822

Location: Netherlands

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

  • Send private message

4

Tuesday, May 30th 2023, 4:32pm

I think the includexml path is relative to the viewer /tour.js

I am looking for a way to includexml inside the js plugin. ( which works great) But i like the path to be relative to the js plugin it self.. where ever it is in the folder structure.

I'll try what you suggest but i don't think that works...

Edit: currentxml is xml file.. that is not the case

Tuur *thumbsup*

kme

Intermediate

Posts: 308

Location: Belgium

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

  • Send private message

5

Tuesday, May 30th 2023, 4:43pm

see my second post for a javascript solution (well, mabye)

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,822

Location: Netherlands

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

  • Send private message

6

Tuesday, May 30th 2023, 5:03pm

doesn't give me the wanted path.
Anybody else?

Tuur *thumbsup*

kme

Intermediate

Posts: 308

Location: Belgium

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

  • Send private message

7

Tuesday, May 30th 2023, 5:05pm

ok, here is a working thing, put it in the loading of your plugin:
assuming you have

Source code

1
	local.registerplugin = function(krpanointerface, pluginpath, pluginobject)


Source code

1
2
3
4
		var urlstr = pluginobject.loadingurl;
		var regex = /[^\/]*$/;
		var path = urlstr.replace(regex, ''); 
		krpano.actions.includexml(path + "stickie_data.xml");


apologies if my first answers were not tested or what you expected.

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,822

Location: Netherlands

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

  • Send private message

8

Tuesday, May 30th 2023, 5:25pm

Hi,

thanks that seems to work..
I'll test a bit more.

alternatively (from Indexofrefraction).. also seem to work and also thanks:

Source code

1
2
3
var path =  krpano.parsepath(pluginobj.url);
path = path.substring(0, path.lastIndexOf('/') + 1);
krpano.actions.includexml(path+"stickie_data.xml");  



Tuur *thumbsup*

9

Tuesday, May 30th 2023, 5:30pm

Source code

1
2
pluginobject.path = krpano.actions.parseurl(pluginobject.url).replace(/[^\/]*$/, ''); 
krpano.actions.includexml(pluginobject.path + "stickie_data.xml");


combo with kme's regex :)
parseurl() is probably needed depending on the given plugin url
(eg if %VIEWER% or another placeholder was used)

*squint* :)

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,822

Location: Netherlands

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

  • Send private message

10

Tuesday, May 30th 2023, 5:33pm

Ah yes, i think you're right... *wacko*
Thanks again!
I'll test.
Tuur *thumbsup*

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,822

Location: Netherlands

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

  • Send private message

11

Tuesday, May 30th 2023, 5:38pm

@kme (why always invisible?)
Where did you find that loadingurl thing?
Seems un-documented.. or?

Tuur *thumbsup*