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

feature proposal: Support for Restful uris #523

Open
nodermatt opened this issue Nov 28, 2019 · 0 comments
Open

feature proposal: Support for Restful uris #523

nodermatt opened this issue Nov 28, 2019 · 0 comments
Assignees

Comments

@nodermatt
Copy link

I'd like to suggest the following addition to the GLTFComponent script to support Restful resource fetching.

Currently, the WebRequestLoader is used to download gltf models with a filename, such as: http://localhost/some/path/Avocado.gltf

This assumes the client knows the name of the entity beforehand and that the resource is available by its name. If a rest API exposes a dynamic model on a URI such as api/v1/scene/ the following problem occurs:
GLTF passes the baseURI ("http://localhost/api/v1/scene/") to the WebRequestLoader:

string directoryPath = URIHelper.GetDirectoryName(GLTFUri);
loader = new WebRequestLoader(directoryPath);

and passes the folder name ("scene") to the SceneImporter object:

sceneImporter = new GLTFSceneImporter(
	URIHelper.GetFileFromUri(new Uri(GLTFUri)),
	loader,
	asyncCoroutineHelper
);

Leading to a concatenated URL that causes a 404 on the webserver: http://localhost/api/v1/scene/scene

Proposal: Add a new boolean flag to GLTF called "UseRest" to denote that URIs have trailing slashes but no filename. The default behaviour will continue to work as expected, only if the checkbox is ticked in the inspector, the specialized behaviour will come into action.

// Do not attach file name to URI for rest interfaces
string uri = "";
if(!UseRest)
{
          uri = URIHelper.GetFileFromUri(new Uri(GLTFUri));
}

sceneImporter = Factory.CreateSceneImporter(
	uri,
	loader,
	asyncCoroutineHelper
	);

Stay tuned for the link to the pull request. Am glad to hear thoughts on this.

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

2 participants