Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basePath doesn't seem to work when loading glTF content #5319

Closed
HowardWolosky opened this issue May 12, 2017 · 7 comments
Closed

basePath doesn't seem to work when loading glTF content #5319

HowardWolosky opened this issue May 12, 2017 · 7 comments

Comments

@HowardWolosky
Copy link

new Cesium.Model lets you specify basePath to indicate the base path that any relative paths in the glTF JSON are referring to. Unfortunately, it doesn't seem to work.

I attempted to use the glTF 1.0 boxTextured sample model. I copied the files to c:\sample\ and did something like this:
var gltfContent = ""; // insert the full content of the .glTF file here. model = scene.primitives.add(new Cesium.Model({ gltf: gltfContent, basePath: "c:\\sample" // I also tried "c:\\sample\\" and had same result }));
Nothing ends up rendering.

Now, if I modify the uris within gltfContent and make all of those paths absolute, it all renders just fine. So, it appears that basePath functionality has an issue.

@emackey
Copy link
Contributor

emackey commented May 15, 2017

I presume you were trying this within the context of gltf-vscode where there is a need to load these files off the local filesystem. Cesium is of course designed and tested for loading the files from a remote server, and I'm sure basePath is meant to be a URL, not a filesystem path.

I plan to investigate this issue as part of the review of AnalyticalGraphicsInc/gltf-vscode#6.

@HowardWolosky
Copy link
Author

Precisely. I found a workaround, but I think it makes sense to support local rootpaths as well since you might want to implement an app/game that can run off Cesium locally.

@mramato
Copy link
Contributor

mramato commented May 15, 2017

I presume you were trying this within the context of gltf-vscode where there is a need to load these files off the local filesystem. Cesium is of course designed and tested for loading the files from a remote server, and I'm sure basePath is meant to be a URL, not a filesystem path.

This is most likely to loadWithXhr usage under Node and related to #5138, @emackey if you are interested in finishing that up, I'd be happy to help point you in the right direction (should actually be pretty straightforward if you read that PR.).

@emackey
Copy link
Contributor

emackey commented May 15, 2017

@mramato This is kind of the opposite problem. In this particular case, Cesium is executing inside an HTML preview sandbox with relaxed security that allows reading arbitrary files off the local filesystem.

Actually I wonder if just slapping file:/// on the front of the value passed to basePath would fix this. basePath is handed off to new Uri(...), so I would expect that putting the file protocol on it would work so long as the file security isn't in play.

@mramato
Copy link
Contributor

mramato commented May 15, 2017

Ahh, that makes perfect sense, and I expect making sure you use a file:// uri should make things work as expected.

@HowardWolosky
Copy link
Author

HowardWolosky commented May 15, 2017

Great catch. That does indeed fix it. I missed this because Babylon doesn't want the file://. I'll need to have that as logic handling when switching between the two renderers. Feel free to close this. I'd recommend just updating the documentation to reflect the need for the file:// protocol when referencing local files.

@emackey
Copy link
Contributor

emackey commented May 15, 2017

Great, thanks!

@emackey emackey closed this as completed May 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants