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

#865 upgrade three js legacy lights #1037

Merged
merged 20 commits into from
May 24, 2024

Conversation

ppillot
Copy link
Collaborator

@ppillot ppillot commented Apr 11, 2024

This PR upgrades the Three.js dependency to a more recent version, which still supports the legacy color management. It derives from the #1002 PR which was attempting at migrating the internal color management to a complete linear workflow.

As the current version of Three.js in the codebase raises (unjustified) alerts from npm audit and other dependency alert bots, this intermediary upgrade is somehow necessary.

The standard library dev dependency has been upgraded as well as 'Jest'. standard is seldom used at the moment, as it does not lint ts files.

Known issues

  • This creates a discrepancy with regard to the lights. The default values for ambient lighting (ambientIntensity) and directional lighting (lightIntensity) have been increased to mimic the previous rendering (respectively 0.2 --> 0.3, 1 --> 1.2). This means that users who have custom lighting presets will have to tweak them after the update.
  • Linting fails with the latest update to standard. This is because the linter does not find any js file in the src directory. I've commented-out the linting commands for now.

Only BufferGeometry is supported.
Every BufferGeometry helper (e.g. BoxBufferGeometry) has
been renamed to shorter name (e.g. BoxGeometry)
As it leverages many deprecated methods
replace with copy() + invert()
critical and high vulnerabilities were caused by dependencies
related with Jest
Previous code was setting `_position` to an empty array.
This was causing some bugs where the _position array was not filled
with the proper values and remained empty.
`ALPHATEST` was previously used as a flag and a value in three.js `alphatest_fragment` chunk.
It was superseded by the `USE_ALPHATEST` flag and the `alphaTest` value passed as a uniform.
The declaration of the `alphaTest` uniform is made in the `alphatest_pars_fragment` chunk.
A SpotLight must have its distance set in real world coordinates.
This was resulting in very dark scenes, where the position of the light or its intensity must take into account the bounding box.
Directional Lights do not require this settings. They light the scene in a uniform manner from afar.
Changes in Three.js regarding light computation even with the `renderer.useLegacyLights` parameter enabled.
A banding effect was due to a loss of precision when copying the texture between render targets.
@ppillot ppillot requested a review from fredludlow April 11, 2024 19:55
standard is a linter for js files. Note that it does not work on ts file, which makes the `npm run lint` command inneffective, except for the example files.
With the upgrade, standard breaks when it can't find any files, and it reports many warnings for the example files (stylistic warnings). So it is also disabled for now.
@ppillot ppillot force-pushed the #865-upgrade-three-js-legacy-lights branch from cfc6fe7 to c23b753 Compare April 11, 2024 20:14
@fredludlow
Copy link
Collaborator

This is a massive amount of work - thank you!

I have tried every demo etc and I can't spot regressions between here and master. I did notice some other uncaught regressions that slipped in somewhere earlier - have created a separate issue for those.

@ppillot ppillot merged commit 62ac286 into nglviewer:master May 24, 2024
2 checks passed
@ppillot ppillot deleted the #865-upgrade-three-js-legacy-lights branch May 24, 2024 15:36
@ppillot ppillot mentioned this pull request Jun 23, 2024
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

Successfully merging this pull request may close these issues.

2 participants