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

Improve precision of surface3d worldPosition calculation #6999

Merged

Conversation

hborchardt
Copy link
Contributor

When the objectOffset is very large compared to the values in the localCoordinate, adding it to the localCoordinate loses precision in the localCoordinate. As the addition of the objectOffset was immediately undone by application of the model matrix, it is better to combine the model matrix and the translation by the objectOffset into one matrix and apply it directly to the localCoordinate.

Again, it's an issue mostly present when rendering data from a small time range.

Before:
image

After:
image

When the objectOffset is very large compared to the values in the
localCoordinate, adding it to the localCoordinate loses precision in the
localCoordinate. As the addition of the objectOffset was immediately
undone by application of the model matrix, it is better to combine the
model matrix and the translation by the objectOffset into one matrix and
apply it directly to the localCoordinate.
@archmoj
Copy link
Contributor

archmoj commented May 16, 2024

Awesome. I was thinking about this. Thank you very much!

@archmoj
Copy link
Contributor

archmoj commented May 16, 2024

Please download and extract baselines.tar from https://app.circleci.com/pipelines/github/plotly/plotly.js/10479/workflows/4c357002-3abe-4fe6-8cda-e8f17a07c65f/jobs/229960/artifacts into test/image/baselines.
Thank you!

@@ -28,7 +28,7 @@
"gl-spikes2d": "^1.0.2",
"gl-spikes3d": "^1.0.11",
"gl-streamtube3d": "^1.4.2",
"gl-surface3d": "^1.6.1",
"gl-surface3d": "github:hborchardt/gl-surface3d#6c75a5b44781c2aaec543237312df1f14274feac",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please open a PR to gl-vis/gl-surface3d and provide the link here.
Thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gl-surface3d@1.6.2 is published. Please install new patch.

@archmoj
Copy link
Contributor

archmoj commented May 16, 2024

Some tests are failing.
Please download and replace new baselines from https://app.circleci.com/pipelines/github/plotly/plotly.js/10480/workflows/d5a9d293-c4d0-43aa-a838-3743b9609162/jobs/229984/artifacts this time.
Thank you!

@hborchardt hborchardt force-pushed the hborchardt/3dsurface_offset_precision branch from c9ac34b to e12bb74 Compare May 16, 2024 19:13
@archmoj
Copy link
Contributor

archmoj commented May 16, 2024

To lock this bug from happening again, I suggest you add a new mock inside test/image/mock forlder. Something similar to what posted into the PR description should be enough.
Please start the name of your new mock with zz-gl3d_ (e.g. zz-gl3d_surface_big-number.json``) so that it does not change the order of rendering of parallel runs on CircleCI. After you pushed you could collect the baseline from the arftifactstab oftest-baselinesand commit it insidetest/image/baselines` folder.
Thank you!

@hborchardt
Copy link
Contributor Author

Some tests are failing. Please download and replace new baselines from https://app.circleci.com/pipelines/github/plotly/plotly.js/10480/workflows/d5a9d293-c4d0-43aa-a838-3743b9609162/jobs/229984/artifacts this time. Thank you!

I accidentally reverted the change to the stackgl_modules/index.js file in the last commit. Now it should be fine.

@@ -0,0 +1 @@
- Fix numerical precision in 3D surface plots [[6999](https://github.com/plotly/plotly.js/pull/6999)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Fix numerical precision in 3D surface plots [[6999](https://github.com/plotly/plotly.js/pull/6999)]
- Fix numerical precision of drawing surface trace [[6999](https://github.com/plotly/plotly.js/pull/6999)],
with thanks to @hborchardt for the contribution!

@archmoj
Copy link
Contributor

archmoj commented May 17, 2024

I'd love to include this PR in the upcoming plotly.js release.
@hborchardt Wondering if you are going to complete this PR today?
I.e. install new gl-surface3d package and if possible adding a test.
If not, I may add those commits.
Thank you!

@hborchardt
Copy link
Contributor Author

hborchardt commented May 17, 2024 via email

@archmoj
Copy link
Contributor

archmoj commented May 17, 2024

Thanks for the quick reply.
Yes let's keep these PRs focused.
So yeah this looks ready to merge when you install gl-surface3d patch.
But no need to rush it as I could simply wait for 3 hours.
Thank you!

@hborchardt
Copy link
Contributor Author

For reference, this is the added test image rendered with current dist/plotly.js
image

@archmoj
Copy link
Contributor

archmoj commented May 17, 2024

Excellent bug fix!
Nicely done.
💃

@archmoj archmoj merged commit 380fa8c into plotly:master May 17, 2024
1 check passed
@archmoj
Copy link
Contributor

archmoj commented May 29, 2024

Plotly.js v2.33.0 is out: https://github.com/plotly/plotly.js/releases/tag/v2.33.0
Thanks for your contribution.

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

Successfully merging this pull request may close these issues.

None yet

2 participants