You are not logged in.

Alexey Tkachenko

Professional

  • "Alexey Tkachenko" started this thread

Posts: 770

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

Professional

Posts: 583

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

Location: 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: 1,117

Location: Poland, Europe

Occupation: krpano developer : virtual tours : the cms4vr owner

  • Send private message

4

Wednesday, January 31st 2018, 10:22am

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

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

facebook page :: youtube :: wiki.cms4vr.com

cms4vr team *thumbsup*

Alexey Tkachenko

Professional

  • "Alexey Tkachenko" started this thread

Posts: 770

Location: 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,839

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*

Alexey Tkachenko

Professional

  • "Alexey Tkachenko" started this thread

Posts: 770

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

Professional

Posts: 583

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

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*

jordi

Professional

Posts: 583

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

Location: Netherlands

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

  • Send private message

Fernando

Intermediate

Posts: 330

Location: Habana, Cuba

Occupation: Architect, Photographer.

  • 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: 330

Location: Habana, Cuba

Occupation: Architect, Photographer.

  • 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