In krpano this xml load no images, is nothing shown, what can be the cause? <krpano…
- User
In krpano this xml load no images, is nothing shown, what can be the cause?
- Assistant
In krpano this xml load no images, is nothing shown, what can be the cause?
The issue arises because the variables and dynamic layer names in your XML are not being correctly processed. In your <layer> definitions and attribute assignments, expressions like %i and %[imgname] are taken literally, and not evaluated as variables during the XML parsing phase.
Here's the problem areas:
Defining layers with variable names in XML:
<layer name='tile_%i' ... />
The %i here is not evaluated and remains as 'tile_%i', which is not the intended layer name. Since %i is not replaced with actual values (like tile_0, tile_1, etc.), the layers with the correct names do not exist.
Assigning variables in attributes in XML:
url='%[imgname]'
Similarly, %[imgname] is not evaluated to the value of imgname variable; it is taken as the literal string '%[imgname]'.
Modifying properties of undefined layers:
In your action add_images, you're trying to set properties on layers like layer[tile_%i], but since these layers were not correctly defined due to the variable name issue, these operations have no effect.
Solution:
You need to create the layers dynamically within the add_images action using the addlayer action and properly reference variables and layer names using the correct syntax. Here's how you can modify your code:
<krpano version='1.20' title='5x10 Image Sphere'>
<view hlookat='0'
vlookat='0'
fovtype='MFOV'
fov='120'
maxpixelzoom='2.0'
fisheye='0'
stereo='false'/>
<scene name='sphere' title='5x10 Image Sphere'>
<!-- Define the grid layout -->
<display
type='grid'
rows='5'
cols='10'
tilesize='640 360'
hfov='72'
vfov='72'
/>
<!-- Action to add images dynamically -->
<action name='add_images'>
for(set(i,0), i LT 50, inc(i),
set(imgname, get(image_prefix) + i + '.jpg');
addlayer('tile_' + i);
set(layer['tile_' + i].parent, 'texture_layer');
set(layer['tile_' + i].url, imgname);
set(layer['tile_' + i].align, 'center');
set(layer['tile_' + i].width, '640');
set(layer['tile_' + i].height, '360');
set(layer['tile_' + i].distorted, true);
set(layer['tile_' + i].scale, '0.5');
set(layer['tile_' + i].ath, (i % 10) * 36 - 180);
set(layer['tile_' + i].atv, int(i / 10) * 18 - 90);
set(layer['tile_' + i].visible, true);
);
</action>
<events name='onstart' onenter='add_images();'/>
<data name='image_prefix' value='images/img_'/> <!-- Prefix for your images -->
<!-- Define a container for layers -->
<layer name='texture_layer'
type='container'
align='center'
width='100%'
height='100%'/>
</scene>
</krpano>
Key changes:
addlayer('tile_' + i); within the loop to dynamically create layers with names like tile_0, tile_1, ..., tile_49.get(image_prefix) and directly concatenate variables without get(), as i is a local variable.layer['tile_' + i].url.By making these changes, you create the layers at runtime, and the variables are correctly evaluated, so your images should now load and display properly.
Answer:
Because the layers for displaying the images aren’t properly created—the XML uses variables incorrectly, so the image layers never get defined or shown; to fix this, the layers should be created dynamically in the action using the correct syntax for variables and layer names.
Not yet included in a published release.