oframe / ogl

Minimal WebGL Library
https://oframe.github.io/ogl/examples
3.71k stars 211 forks source link

Type definition for GLTF seems inaccurate #196

Closed RigoTamas closed 9 months ago

RigoTamas commented 9 months ago

The type definition for the GLTF interface seems to be inaccurate. Both the scene and scenes properties have type of: Transform[]. The JS source code however hints that scene is an index shallower than scenes, because scene is created by indexing into scenes. So the correct typing should be either this:

interface GLTF {
    ...
    scenes: Transform[][];
    scene: Transform[];
}

Or this:

interface GLTF {
    ...
    scenes: Transform[];
    scene: Transform;
}
pschroen commented 9 months ago

Hi @RigoTamas, are you getting a specific error in a project?

The scene property is a Transform[], for reference in the Load GLTF example you can see how it's expected to be an array: https://github.com/oframe/ogl/blob/32f7ec27c4ef528d8373a1719162aed2c0be0ae0/examples/load-gltf.html#L441-L449

Your first definition with scenes: Transform[][]; would be the correct one, good catch, I'll create a PR for that!

RigoTamas commented 9 months ago

Thanks for getting onto this issue so fast. I am not getting any errors in my project. I just wanted to add TypeScript to my project, and that's when I've found out that there is something off about this type definition.