Repository navigation
Fix angle getters that lost the sign of negative angles - #756
Merged
Merged
Conversation
Member
|
Hey, thanks for contributing! I'd be more in favor of doing it like this: postprocessing/src/effects/HalftoneEffect.ts Lines 177 to 189 in db532e4 The original values should be saved in private backing data, i.e. |
Author
|
Done in |
Member
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue: none
Description
Four angle getters read the angle back with
Math.acosof one stored component, so they return the absolute value and lose the sign:The same happens for
DotScreenEffect.angle,HueSaturationEffect.hueandTiltShiftBlurMaterial.rotation. The uniforms themselves are right, since the setters store both the cosine and the sine, so only reading the value back is wrong. It matters for code that reads the property to adjust it, e.g.effect.rotation -= 0.1past zero, or UI controls bound to it.The getters now use
Math.atan2with both stored components:TiltShiftEffect.rotation,TiltShiftBlurMaterial.rotation:atan2(y, x)of the stored(cos, sin).DotScreenEffect.angle:atan2(x, y)of the stored(sin, cos).HueSaturationEffect.hue: the cosine is(3x - 1) / 2as before, and the sine is(z - y) * sqrt(3) / 2, from the setter'sy = (-sqrt(3) s - c + 1) / 3andz = (sqrt(3) s - c + 1) / 3.Values come back in (-PI, PI], so an angle outside that range is returned as its equivalent inside it, where
acosreturned [0, PI].Tests: a round-trip test for each of the four (set -2.5, -0.5, 0, 0.5, 2.5 and read it back). All four fail before the change (
set -2.5, got 2.5) and pass after.pnpm avapasses (106 tests) afterpnpm build:js, and ESLint is clean on the changed files.