-
-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add concrete types to the image
and mipmaps
properties of Texture
#124
Comments
The image field for a Texture can actually be a lot of different things. Just the raw types that WebGL can accept as a texture source alone are:
There is a type in But Three.js also has a few hacks in place where they use the image field to track the dimensions of the texture without actually storing a It seems, in all cases except Perhaps it is necessary to break from trying to 1-to-1 mirror the exported Texture types of Three.js and introduce a new interface, some kind of |
Potential fix for issue three-types#124
IDK, maybe something like this? I added some generic type parameters to Texture, that should be able to accept any of those hack cases, plus with a default setting of TexImageSource. The other subclasses of Texture then define a more meaningful value for their case. I'm not too sure about the mipmaps field, so I haven't submitted this as a PR. Maybe someone else has some insight here? |
Potential fix for issue three-types#124
Describe the feature you'd like:
three-ts-types/types/three/src/textures/Texture.d.ts
Line 52 in 6a5f781
three-ts-types/types/three/src/textures/Texture.d.ts
Line 57 in 6a5f781
If it's certain that these are the only types they can have, then they can be added to the type declaration itself.
However, note that this is a breaking change for the transpilation of TS code which directly uses any sub-properties of these properties (except
.image.width
and.image.height
, which are always present) or casts one of them to an unrelated type.Suggested implementation:
This is based on my understanding that if it's a 2D texture, then all of its mipmaps are of type
ImageData
, and if it's a cube texture, then all of its mipmaps are of typeCubeTexture
. If I'm wrong, then it should bemipmaps: (ImageData | CubeTexture)[]
instead.The text was updated successfully, but these errors were encountered: