Skip to content
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

ToneMappingMode is not re-exported. This can lead to confusion due to how Typescript handles enums #265

Open
DanielSturk opened this issue Feb 14, 2024 · 0 comments

Comments

@DanielSturk
Copy link

React-postprocessing does not re-export the ToneMappingMode enum from postprocessing, requiring the user to also add the postprocessing library as well.

This can lead to confusion because of how TypeScript handles enums. Both the three.js ToneMapping enum and the postprocessing ToneMappingMode enum are integers, and thus TypeScript views them as compatible. Therefore, the following will not produce a Typescript error, and flipping through the different options will change the tonemapping, making it appear to work while being incorrect:

import { ACESFilmicToneMapping } from 'three';
<ToneMapping mode={ACESFilmicToneMapping}/>

Screenshot of how this looks in a typical VS Code project, to illustrate why it's easy to make this mistake:
image

It took me a while to figure out the issue, I only knew something was wrong because I had reference material to compare against, but others may not be as diligent. I knew my co-worker was using this library as well for another project independently of my work, so I searched through his projects and found that he had made the same mistake as well. Thus, I feel that this issue may be common, but under-reported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant