loaders.gl icon indicating copy to clipboard operation
loaders.gl copied to clipboard

GLTF post processed types

Open dionysiusmarquis opened this issue 4 years ago • 6 comments

I couldn't find any corresponding types if you load a gltf file with postProcess: true.

const gltf = await load(url, GLTFLoader, {
  DracoLoader,
  gltf: { postProcess: true },
});

A Node will have the mesh typed as number, for examaple:

{
  id: "node-0"
  mesh: {name: 'mesh-name', primitives: Array(1), id: 'mesh-0'} // mesh will be typed `number`
  …
}

Following: /src/lib/types/gltf-postprocessed-schema.ts#L498

dionysiusmarquis avatar Dec 09 '21 16:12 dionysiusmarquis

It looks like you output is from console.log. primitives: Array(1) should contain a primitive with a number of attributes where the geometry is stored.

belom88 avatar Feb 07 '22 13:02 belom88

@dionysiusmarquis Updating loaders.gl to TypeScript has been a truly epic task and you have found a corner we didn't yet get around to. We should address it. I will assign a 3.2 milestone to this, which is likely too optimistic unless someone contributes, but at least a declaration of intent.

ibgreen avatar Feb 07 '22 15:02 ibgreen

An update for those piecing this together like myself, please correct me if I'm mistaken. It seems that the current npm release (3.1.8) has a WIP version of gltf-postprocessed-schema.ts. The most recent version in the repo is more complete, but still WIP, ie bufferView properties are currently still GlTfId: /src/lib/types/gltf-postprocessed-schema.ts

For now I'm copying pasting this into my projects.

mrchantey avatar Apr 08 '22 04:04 mrchantey

The particular typing of mesh has been fixed: https://github.com/visgl/loaders.gl/blob/f030d39d5cdedb137e43e757a9da10dd637857fd/modules/gltf/src/lib/types/gltf-postprocessed-schema.ts#L518 I've done it down the road. There are other objects that should have another type other then GlTfId. By the way 3.2.0 has been just published and typing for mesh object is there.

belom88 avatar May 12 '22 15:05 belom88

@ibgreen shall we close it or move to the next official release milestone?

belom88 avatar May 12 '22 15:05 belom88

Moved it to backlog

ibgreen avatar May 12 '22 15:05 ibgreen

In v4.0, postProcessing is broken out from the glTF loader and the output of postProcessGLTF should be fully typed

ibgreen avatar Oct 24 '23 10:10 ibgreen