Discussion on the Reference Viewer API
See original GitHub issueThere was a discussion on ux3d/glTF-WebGL-PBR
which I would like to bring over to the main repo so that it can be discussed and handled when we have time (or if somebody in the community is willing to contribute to it). It’s regarding how a user would interface with the reference viewer programmatically, and how such an API should look like (and what sort of things we should support). Right now we can load a set of glTF scenes into the reference viewer and view them in a web browser, or render to an image by using a CLI via the build-in headless mode. However it would be a very powerful to be able to control the reference viewer via an API (entirely) as well, and to make it as easy as possible to the user. Right now, this is already possible, but the API is not very user friendly for that, and some things are quite hard to do.
Instead, we would like to be able to write something along these lines:
let viewer = new gltfViewer(canvas);
viewer.loadEnvironment("field.hdr");
viewer.useIBL = true;
viewer.lookAt([0,0,0], [0,1,0], 45);
viewer.load("/assets/BoomBox.gltf");
viewer.render().save("BoomBox.png");
// or hook it to your own callbacks!
This is just an example of course.
This issue is here to brainstorm on how the syntax for something like this should look like, and what sort of things the community would like to be able to control via such an API in the reference viewer that is being developed in the reference-viewer
branch. It’s a wish list (to glTF Santa?), that we will integrate (or the community) when we have a good idea on how this should look like, and when we finally have time to integrate this.
Anyway, feel free to come up with ideas 😃
I’ll see if I can dig up Ed’s and Don’s ideas on this since they had some good ones in the previous issue.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:25 (14 by maintainers)
Top GitHub Comments
Fixed here: https://github.com/KhronosGroup/glTF-Sample-Viewer/blob/master/API.md
I stumbled into this yesterday, as I put out a version of FBX2glTF and lamented to myself how difficult it is to write end-to-end regression tests for a glTF generator. I have a few ways to test in place already (running the validator, for example). But what I really want is to image-diff (e.g. PSNR or MMSIM) actual renders.
Does anyone have a working example of referencing this repo in a node package.json and executing a remote render? I will admit that the many revolving parts are a bit beyond my web programming fu –– can Electron run in a pre-existing Node process, for example, or does it need to be treated essentially as just another binary executable?
In an ideal world I’d love to see an API like the ones @donmccurdy outlines above. In the shorter term, though, I’m fine with a pragmatic solution. I am just a bit at a loss how to elegantly pull this repo in as a NPM submodule and execute it. I’m fine writing a little bit of wrapping JS.