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

How to load multi file assets? #7

Closed
kungfooman opened this issue Jul 17, 2020 · 10 comments
Closed

How to load multi file assets? #7

kungfooman opened this issue Jul 17, 2020 · 10 comments
Labels
enhancement New feature or request

Comments

@kungfooman
Copy link
Contributor

I am not sure how the API is supposed to work:

viewer.load([
"http://127.0.0.1/libwebgame_assets/gltf/AppleTree/AppleTree.gltf",
"http://127.0.0.1/libwebgame_assets/gltf/AppleTree/AppleTree.bin"
]);

The AppleTree got these files:

image

Result:

playcanvas.js:24239 failed to load uri=AppleTree.bin

image

@slimbuck
Copy link
Member

Hi @kungfooman ,

Try specifying the files as objects with url and filename properties. The filename is used to match internal references. Check out the drop handler.

Hope that helps!

@kungfooman
Copy link
Contributor Author

Hi @slimbuck, thanks for the info!

Got it working like this now:

viewer.load([{
    url: "http://127.0.0.1/libwebgame_assets/gltf/AppleTree/AppleTree.gltf",
    filename: "AppleTree.gltf"
}, {
    url: "http://127.0.0.1/libwebgame_assets/gltf/AppleTree/AppleTree.bin",
    filename: "AppleTree.bin",
}, {
    url: "http://127.0.0.1/libwebgame_assets/gltf/AppleTree/AppleTree_baseColor.png",
    filename: "AppleTree_baseColor.png",
}, {
    url: "http://127.0.0.1/libwebgame_assets/gltf/AppleTree/AppleTree_roughnessMetallic.png",
    filename: "AppleTree_roughnessMetallic.png",
}, {
    url: "http://127.0.0.1/libwebgame_assets/gltf/AppleTree/AppleTree_normal.png",
    filename: "AppleTree_normal.png",
}, {
    url: "http://127.0.0.1/libwebgame_assets/gltf/AppleTree/AppleTree_baseColor1.png",
    filename: "AppleTree_baseColor1.png",
}, {
    url: "http://127.0.0.1/libwebgame_assets/gltf/AppleTree/AppleTree_roughnessMetallic1.png",
    filename: "AppleTree_roughnessMetallic1.png",
}, {
    url: "http://127.0.0.1/libwebgame_assets/gltf/AppleTree/AppleTree_normal1.png",
    filename: "AppleTree_normal1.png",
}, {
    url: "http://127.0.0.1/libwebgame_assets/gltf/AppleTree/AppleTree_baseColor2.png",
    filename: "AppleTree_baseColor2.png",
}, {
    url: "http://127.0.0.1/libwebgame_assets/gltf/AppleTree/AppleTree_roughnessMetallic2.png",
    filename: "AppleTree_roughnessMetallic2.png",
}, {
    url: "http://127.0.0.1/libwebgame_assets/gltf/AppleTree/AppleTree_normal2.png",
    filename: "AppleTree_normal2.png",
}]);

Isn't it a bit strange that people have to reference every single file? In playcanvas-gltf people only have to define basePath (which even can be derived from a single URL in lots of cases)

@slimbuck
Copy link
Member

Hi @kungfooman,

The next release of the viewer is a big change which includes the ability to load a gltf using its URL alone. The basePath is derived from the URL though, it can't be specified.

Hope this helps!

@willeastcott
Copy link
Contributor

I think this is now supported, right? So we can close this?

@willeastcott willeastcott added the enhancement New feature or request label Jul 25, 2020
@kungfooman
Copy link
Contributor Author

Just built HEAD and it doesn't work with Viewer#load at least:

image

@willeastcott
Copy link
Contributor

How are you even able to see viewer using the latest codebase?

image

Now that the viewer is built with Webpack, that variable is not visible from the JS console.

@kungfooman
Copy link
Contributor Author

window.pc = pc;

function startViewer() {
    var viewer = new Viewer(document.getElementById("application-canvas"), onSceneReset, onAnimationsLoaded, onMorphTargetsLoaded);
    registerElementEvents(viewer);
    window.viewer = viewer;
}

@willeastcott
Copy link
Contributor

Ah ok, so you've exposed the variable yourself. I also see the problem now:

image

Looks like dependencies aren't loaded for unpacked glTF scenes still. I think it's best to wait for @slimbuck to comment.

@slimbuck
Copy link
Member

Hi @kungfooman, @willeastcott,

This will work correctly once the next version of engine has been released, as it requires playcanvas/engine#2312.

Thanks!

@slimbuck
Copy link
Member

https://github.com/playcanvas/engine/releases/tag/v1.32.3

This should now be fixed! (Please reopen if you any further issues).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants