You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue submitted in three.js first link
And also submitted in definitely typed at second link
Here are the classes that currently use the userData property in three.js.
(captured from @types/three r155.1)
Object3D
BufferGeometry
Material
Texture
(UserDataNode, GLTF)
But as you can see, Object3D, BufferGeometry and Material, Texture have different userData types.
This situation caused me the following type issue.
type UserDataWrappedObject3D = Object3D & {
userData: { myCustomValue: number }
}
type UserDataWrappedMaterial = Material & {
userData: { myCustomValue: number }
}
let a: UserDataWrappedObject3D
let b: UserDataWrappedMaterial
a.userData.myCustomValue
b.userData.myCustomValue // error from userData inferred as any
Solution
If we want to allow wrapping of userData in the above manner, I suggest replacing the userData type of Materials and Textures with Object3D or BufferGeometry's userData type.
// in Material class
...
userData: { [key: string]: any };
...
Alternatives
Or we can apply Record type for userData as it commented in code.
Additional context
No response
The text was updated successfully, but these errors were encountered:
Description
Issue submitted in three.js first
link
And also submitted in definitely typed at second
link
Here are the classes that currently use the userData property in three.js.
(captured from @types/three r155.1)
But as you can see, Object3D, BufferGeometry and Material, Texture have different userData types.
This situation caused me the following type issue.
Solution
If we want to allow wrapping of userData in the above manner, I suggest replacing the userData type of Materials and Textures with Object3D or BufferGeometry's userData type.
Alternatives
Or we can apply
Record
type for userData as it commented in code.Additional context
No response
The text was updated successfully, but these errors were encountered: