Gltf.scene.traverse => Property 'isMesh' does not exist on type 'Object3D'

Hi!
I have a project in Typescript (Angular) that load a simple gltf.
Everything works fine except when I try to use of RoughnessMipmapper, by traversing the gltf’s scene.

Does anyone have an idea?

image

image

although ‘child’ is a THREE.Object3D…
image

Unfortunately, three.js’ isFoo properties are difficult to use with TypeScript, just due to the nature of the type checking. Two workarounds you could use:

  1. if ((child as Mesh).isMesh) { ... }
  2. if (child instanceof Mesh) { ... }

For certain classes instanceof is not helpful (e.g. InterleavedBufferAttribute is not a subclass of BufferAttribute) but for this case it’s fine.

3 Likes

It works :+1:
Thanks a lot @donmccurdy

1 Like

i’m stuck again :hugs:

this time with OrbitControls

ok my bad…

it has to be : this.controls.target

image