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.

Alexey Tkachenko

Professional

  • "Alexey Tkachenko" started this thread

Posts: 757

Location: Sevastopol, Crimea, Russian Federation

Occupation: Interpreting, Building virtual tours

  • Send private message

1

Wednesday, January 31st 2018, 9:53am

Is it possible to add <scene> dynamically?

Hi eveyone!

I remember from this thread https://krpano.com/forum/wbb/index.php?p…scene#post58626 that it's possible ro remove the <scene> dynamically.
But is it possible to add a scene dynamically? For example, I have 'tour.xml' with no <scene> nodes at all and I want to add them dynamically at startup and then load them using 'loadscene();' action.

I tried using scene.createarrayitem('scene0'); action and it seems that it adds the scene (scene.count increases and I can trace 'scene[0].name' in the log), but when I try to load that scene via 'loadscene();' action, it says 'ERROR: loadscene() - scene "scene0" not found"...
Regards,

Alexey

jordi

Intermediate

Posts: 465

Location: Barcelona

Occupation: creating ideas & coding them

  • Send private message

2

Wednesday, January 31st 2018, 10:16am

Yes you can .

you do not need to do it via createarrayitem.

just do :

set(scene[yourName or index].name, yourName);

and then the same with the content


set(scene[yourName or index].content, view - image - hotspots .... the normal content of a pano, which of course can be dynamically generated via txtadd or calc...);
everpano.com step beyond 360

Alexey Tkachenko

Professional

  • "Alexey Tkachenko" started this thread

Posts: 757

Location: Sevastopol, Crimea, Russian Federation

Occupation: Interpreting, Building virtual tours

  • Send private message

3

Wednesday, January 31st 2018, 10:19am

Thanks, Jordi!

I will try that ;-)
Regards,

Alexey

spacerywirtualne

Professional

Posts: 909

Location: Poland, Europe

Occupation: krpano developer : virtual tours

  • Send private message

4

Wednesday, January 31st 2018, 10:22am

Hi
Is it possible to add <scene> dynamically?
Look here

Piotr
Your own online, cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: youtube

cms4vr team *thumbsup*

Alexey Tkachenko

Professional

  • "Alexey Tkachenko" started this thread

Posts: 757

Location: Sevastopol, Crimea, Russian Federation

Occupation: Interpreting, Building virtual tours

  • Send private message

5

Wednesday, January 31st 2018, 10:30am

Thanks, guys!

It works! *tongue*


Source code

1
set(scene[0].name, 'scene0');		set(scene[0].content, 			<preview url="panos/bisque/bisque_marble01.tiles/preview.jpg" />						<image>				<cube url="panos/bisque/bisque_marble01.tiles/pano_%s.jpg" />			</image>		);



Source code

1
scene.createarrayitem('scene0');
works also.

P.S. Why the forum always screws up the 'source code' insertion? *blink*
Regards,

Alexey

Tuur

Sage

Posts: 3,173

Location: Netherlands

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

  • Send private message

6

Wednesday, January 31st 2018, 10:37am

Hi,

just a question..
Why would you want/need to add a scene dynamically?
I can hardly think of any reason.
Can you explain?

Tuur *thumbsup*
http://www.virtualtuur.com
Skype:studiotuur

Alexey Tkachenko

Professional

  • "Alexey Tkachenko" started this thread

Posts: 757

Location: Sevastopol, Crimea, Russian Federation

Occupation: Interpreting, Building virtual tours

  • Send private message

7

Wednesday, January 31st 2018, 10:47am

Yep, sure.

The idea was to change tour structure (amount of panos, their order etc.) 'on the fly' without need to go into tour.xml and copy-paste or delete <scene> nodes. Just experimenting with this though...
Regards,

Alexey

8

Wednesday, January 31st 2018, 11:32am

Hi,

just:

Source code

1
set(scene[NAME].content, '...');
would be enough.

When adding some custom attribute to all <scene> element, it would be also possible to use that for sorting - e.g.

Source code

1
scene.sortby(customattributename);

See here about 'sortby':
https://krpano.com/docu/actions/#array.sortby

Best regards,
Klaus

jordi

Intermediate

Posts: 465

Location: Barcelona

Occupation: creating ideas & coding them

  • Send private message

9

Wednesday, January 31st 2018, 1:04pm

Why would you want/need to add a scene dynamically?
you can generate the tour from an array, so dynamically generate a new tour depending on variables, it's about flexibility.
everpano.com step beyond 360

Tuur

Sage

Posts: 3,173

Location: Netherlands

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

  • Send private message

10

Wednesday, January 31st 2018, 1:05pm

Still don't see the point.. but is php not your friend here?

Tuur *thumbsup*
http://www.virtualtuur.com
Skype:studiotuur

jordi

Intermediate

Posts: 465

Location: Barcelona

Occupation: creating ideas & coding them

  • Send private message

11

Wednesday, January 31st 2018, 1:08pm

PHP is a good friend, but can not come with you all the time
everpano.com step beyond 360

Tuur

Sage

Posts: 3,173

Location: Netherlands

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

  • Send private message

12

Wednesday, January 31st 2018, 1:20pm

true
http://www.virtualtuur.com
Skype:studiotuur

Fernando

Intermediate

Posts: 205

Location: Habana, Cuba

Occupation: Architect, Photographer, Programmer.

  • Send private message

13

Sunday, May 20th 2018, 4:23pm

question for idea to copy content for external .xml

How to create scene content for external xml?
for example: set(scene[myscenename].content,.... --> "...copy from first scene of mypanos/tour.xml"
It is possible???

Best Regards,
Fdo

14

Wednesday, May 23rd 2018, 9:32am

Hi,

if you just want to load a scene from a different xml you could use the 'loadpanoscene' action:
https://krpano.com/docu/actions/#loadpanoscene

But for loading an other xml, extracting the scene and adding it, that would need to be coded manually - here a quick and simplified sample how such could be eventually done:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<action name="loadfirstscenefromotherxml" type="Javascript"><![CDATA[

    krpano.loadFile("othertour.xml", function(loader)
    {
        var xmlstring = String(loader.data);

        var i_scenebegin = xmlstring.indexOf(">", xmlstring.indexOf("<scene")) + 1;
        var i_scenend = xmlstring.indexOf("</scene>", i_scenebegin);

        var scene_xml = xmlstring.slice(i_scenebegin, i_scenend);

        krpano.set("scene[test].content", scene_xml);
    });

]]></action>


Best regards,
Klaus

Fernando

Intermediate

Posts: 205

Location: Habana, Cuba

Occupation: Architect, Photographer, Programmer.

  • Send private message

15

Thursday, May 24th 2018, 5:46am

Thank you but it seems like I didn't explain myself right.
My intention is designing a project with a combobox that creates hotspots dinamically. Those hotspots will appear located in a map. With a "Make Scene" button a new scene must be created containing all the previously selected places from the combobox. All the scenes are already located in folders named like the places, for example, if I select from the combobox "Office" and then "House" two hotspot will be created on the map named "Office" and "Hotel" and if I press "Make Scene" a new scene will be created with the content (scene[name].content) of the "Office" and "Hotel" scenes wich are located at folders named "office/tour.xml" and "hotel/tour.xml". That way the user can navigate through the selected sites in only one scene, that makes it ideal for a VR tour.
I attach a picture with a sketch to make it clearer.
Best regards.
Fernando.
Fernando has attached the following image:
  • abstract.jpg