webots icon indicating copy to clipboard operation
webots copied to clipboard

Fix streaming of simulations with relatively defined assets

Open ad-daniel opened this issue 2 years ago • 1 comments

Description

The way assets are served to webotsjs has been reworked so as to remove the reliance on an internal map. The changes comprise:

  • assets are encoded in the x3d relative to the world
  • when streaming, webotsjs knows the path of the world and by combining the two can request webots a url that is relative to the project.
  • assets that lay behind the project are not served, so if they want to be provided (either relatively or absolutely), they need to be manually relocated.
  • the material for local (webots://) cadshapes sent to webotsjs has now the same prefix of the obj itself.
  • since the x3d writer already expresses assets relative to the world, the same logic can be re-used when converting to basenode

For testing, I've prepared 6 worlds for the different assets (backgrounds/mesh/textures) and different situations, namely: basenode (assets relative to world) o internal to a proto (assets relative to the proto): urls.zip Note:

  • the black vehicle should not be visible when streaming as it's outside of the scope of the project
  • the absolute urls need to be adapted to your computer

ad-daniel avatar Aug 05 '22 13:08 ad-daniel

I tried some configurations and it seems to work well. I just have two remarks:

  • The streaming viewer is not able to load the meshes of bed.proto
  • Is it a good idea to have assets that are loadable by webots but not by webotsjs (namely local assets that are outside the current project)? It doesn't seem very user friendly to have two different behaviors.

I will test more exhaustively (with docker and so) when this PR is ready for review

BenjaminDeleze avatar Aug 10 '22 07:08 BenjaminDeleze

The streaming viewer is not able to load the meshes of bed.proto

Should be fixed now. In the description above, in the repo I mention (under urls/mixed) there are 3 worlds that test different combinations of this additional case (relative proto -> relative asset, web proto -> relative asset, etc. for cadshape, backgrounds, meshes and textures). If you use these worlds for testing note that the behavior of the webots:// ones varies depending on whether you copy the project inside/outside your webots folder.

Is it a good idea to have assets that are loadable by webots but not by webotsjs (namely local assets that are outside the current project)? It doesn't seem very user friendly to have two different behaviors.

It's odd I agree, especially since the web interface side lacks an active console where to notify the user (except F12) about why it's missing. However anything behind the current project cannot be requested to webots regardless (whether it's the current or previous approach) since all the ../../ would be consumed before they reach webots. Given the feature choices made with this approach it's just not possible to allow it

I'll wait for the test to finish but in principle the PR can be reviewed

ad-daniel avatar Aug 10 '22 14:08 ad-daniel

If you use these worlds for testing note that the behavior of the webots:// ones varies depending on whether you copy the project inside/outside your webots folder.

In practice we should never have world with "webots://" outside of the webots folder right?

It's odd I agree, especially since the web interface side lacks an active console where to notify the user (except F12)

I will work on a web console (non-interactive) when I have some time, most of the requirement are already done.

BenjaminDeleze avatar Aug 10 '22 14:08 BenjaminDeleze

In practice we should never have world with "webots://" outside of the webots folder right?

Officially, no. A distribution would not be able to open such a world. If however you are in development mode technically it works anyway by chance, but it isn't really a good way of doing things

It's odd I agree, especially since the web interface side lacks an active console where to notify the user (except F12)

Awesome!

ad-daniel avatar Aug 10 '22 14:08 ad-daniel

It works well!

Just one remark: When exporting webots_urls_proto/world/webots_proto.wbt and webots_urls_basenode/worlds/webots_basenode.wbt to a local scene, a texture folder is created with the textures of the forklift. However I think it should not be the case as the textures are taken from a webots:// cadShape.

BenjaminDeleze avatar Aug 11 '22 07:08 BenjaminDeleze

When exporting webots_urls_proto/world/webots_proto.wbt and webots_urls_basenode/worlds/webots_basenode.wbt to a local scene, a texture folder is created with the textures of the forklift. However I think it should not be the case as the textures are taken from a webots:// cadShape.

That's indeed the case, I forgot to remove the export also from the shallow node, the textures were exported but not actually being used

ad-daniel avatar Aug 11 '22 09:08 ad-daniel