Is it possible to add scenes dynamically?

  • Hi, everyone.

    I'm trying to add scenes at runtime.

    I searched the forums and found similar threads and tried to do this, but it didn't work.

    I tried something like the code below:


    The log output is as follows:

    The output of debugvar(scene[0]) shows that it is set correctly in the scene.

    However, the loadscene function says that livingroom_0 does not found.


    I coded like this to solve this problem.


    Similar to the log results shown earlier, but the loadscene function does not fail.


    Is it not possible to add a scene with the set function in krpano?

  • Hi,

    when creating a new array item by setting an item with index 0 to some values, an automatic name for the item will be created.

    The setting of the name will then actually change the name, but don't update the index/name mapping.

    Changing the name of an array item is only possible by using renamearrayitem().

    But you could do it different - direct create the scene item with the name it should have:

    Code
    set(scene[livingroom_0],
       title = 'livingroom',
       onstart = '',
       thumburl = '%VIEWER%/panos/104b_0_on/desktop/livingroom_0.tiles/thumb.jpg',
       ...
    );
    loadscene('livingroom_0', ...);			


    Or if index 0 is mandatory - first create the item (and don't set the name) and then rename it:

    Code
    set(scene[0],
       title = 'livingroom',
       onstart = '',
       thumburl = '%VIEWER%/panos/104b_0_on/desktop/livingroom_0.tiles/thumb.jpg',
       ...
    );
    scene.renamearrayitem(get(scene[0].name), 'livingroom_0');
    loadscene(0, ...);	


    Best regards,
    Klaus

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!