CesiumGS / cesium-unreal

Bringing the 3D geospatial ecosystem to Unreal Engine
https://cesium.com/platform/cesium-for-unreal/
Apache License 2.0
902 stars 287 forks source link

Cesium V2 doesn't support file:/// URLs #1345

Closed rpte closed 6 months ago

rpte commented 6 months ago

I have been using Cesium for unreal and now i can't load the tiles locally with file:/// since it was updated to version 2

j9liu commented 6 months ago

@rpte Can you please provide the following information:

rpte commented 6 months ago

What version of Unreal engine are you using? - V5.3.2 What exact version of Cesium for Unreal are you using? V2.2.0 Have you double-checked that the file URL adheres to these formatting conventions? Yes its file:///

rpte commented 6 months ago

Sorry it's loading from local network, like this: file:////server.company.com/Local/3dtiles/tileset.json

On UE5.2 was working fine, but on 5.3 never worked, the same with the newer version 2.2.0 on UE5.2, so we can't use UE5.3 in our projects.

kring commented 6 months ago

Ok, it sounds like you're not loading files locally. You're loading them from a network, via some unspecified protocol. Windows file sharing perhaps?

Here's the full story. Prior to UE 5.3, Unreal itself provided support for file URLs via its HTTP manager. It was provided by libcurl itself, I believe. It only worked on Windows, though. On other platforms, the support was disabled via libcurl compiler options.

Then, in UE 5.3, Epic disabled support for file URLs on Windows as well. Perhaps it was a mistake that it was enabled there (only) in the first place.

So, at that time, we added support for file URLs for Cesium for Unreal itself, so we no longer relied on Unreal's (spotty) support for them. That happened in Cesium for Unreal v2.0.0.

Our support works by extracting the file path from the URL by using uriparser's uriUriStringToWindowsFilenameA or uriUriStringToUnixFilenameA functions (depending on the platform) and then reading the resulting filename using Unreal's FFileHelper::LoadFileToArray. So presumably your network share paths aren't making it through that process for some reason.

Honestly it's mostly just luck that this worked in the first place. You're basically talking about a network share, pretending to be a file, pretending to be a URL. If you want to load a tileset over the network, the best answer is a web server, not a network share. For one thing, requests from a network share cannot benefit from HTTP caching.

But it might be possible to make it work. Try adding an extra slash at the start of the URL. Instead of:

file:////server.company.com/Local/3dtiles/tileset.json

Try this:

file://///server.company.com/Local/3dtiles/tileset.json

It seemed to work ok in my quick test.

yuxueliyuxl commented 6 months ago

v2.1+

kring commented 6 months ago

I don't know what you're saying with that comment, @yuxueliyuxl.

rpte commented 6 months ago

It works with the file://///server.company.com/Local/3dtiles/tileset.json thanks