three-stdlib
three-stdlib copied to clipboard
GLTFReference type out of date
threeversion: 0.136.0three-stdlibversion: 2.6.4
Problem description:
The current GLTFReference type is out of date since version 2.6.4 where loaders were updated.
Relevant code:
const reference = parser.associations.get(object.material)
if (reference?.materials) {
// TS error: Property 'materials' does not exist on type 'GLTFReference'
object.material = copiedMaterials[reference.materials]
object.material.needsUpdate = true
}
Suggested solution:
I have fixed this temporarily like this:
interface GlTFMaterialReference {
materials: number
}
const reference = parser.associations.get(object.material) as
| GlTFMaterialReference
| undefined
I think to handle this type properly in the library it will need something like generics because the type will change depending on what is passed to parser.associations.get
Extra notes
The type currently looks like this, which is now out of date:
// GLTFLoader.d.ts
export interface GLTFReference {
type: 'materials' | 'nodes' | 'textures';
index: number;
}