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 camera init #3585

Merged
merged 16 commits into from
Mar 20, 2019
Merged

Improve camera init #3585

merged 16 commits into from
Mar 20, 2019

Conversation

archmoj
Copy link
Contributor

@archmoj archmoj commented Feb 27, 2019

This PR would improve camera initialisation setup for gl3d plots.
First - it fixes bug #3576 by disabling undesirable rotation/pan when the click is done on the initial mouse location.

Second - it removes one extra expensive call to create camera object. This is done by improving gl-plot3d interface to also accept & reuse camera object created inside plotly.js scene. Also gl-plot3d's createCamera and createScene are revised and their mouse listeners are packed to be enabled by centralised functions.

Finally - all the previous gl3d jasmine tests with noCI flag could be run on CI.

@plotly/plotly_js

@archmoj archmoj added bug something broken status: reviewable labels Feb 27, 2019
@antoinerg
Copy link
Contributor

antoinerg commented Feb 27, 2019

@archmoj I checked out your branch locally and I can't rotate any of the gl3d mocks!

This mock does not rotate: http://localhost:3000/devtools/test_dashboard/#gl3d_surface_after_heatmap
whereas it used to: https://rreusser.github.io/plotly-mock-viewer/#gl3d_surface_after_heatmap

Maybe there is something wrong on my side... Please let me know if rotation does work for the mock above. Also, if it doesn't work, we really should have a test to catch this 😮 !

@archmoj
Copy link
Contributor Author

archmoj commented Feb 27, 2019

@antoinerg thanks for testing this. Interestingly it used to work without that so I thought it could be enabled by the gl-plot3d module. With that we may possibly enable it once the scene is complete.

@antoinerg
Copy link
Contributor

@archmoj so you do confirm that you also can't rotate the gl3d traces? If that is the case, I am really worried about the fact that no tests failed. Why is that?

@archmoj
Copy link
Contributor Author

archmoj commented Feb 27, 2019

@archmoj so you do confirm that you also can't rotate the gl3d traces?

@antoinerg Yes, I do confirm that.

package.json Outdated
@@ -80,7 +80,7 @@
"gl-mat4": "^1.2.0",
"gl-mesh3d": "^2.0.8",
"gl-plot2d": "^1.4.2",
"gl-plot3d": "^2.1.1",
"gl-plot3d": "git://github.com/gl-vis/gl-plot3d.git#5f28e06ac02b248e6990ef385d2df49bb3a7baf8",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@archmoj archmoj changed the title Bug fix: disable camera mouse listener before scene is complete Improve camera init Feb 28, 2019
@archmoj
Copy link
Contributor Author

archmoj commented Feb 28, 2019

@archmoj so you do confirm that you also can't rotate the gl3d traces? If that is the case, I am really worried about the fact that no tests failed. Why is that?

I added this test in respect to that.

.then(_clickOtherplace)
.then(delay(20))
.then(function() {
var cameraFinal = gd._fullLayout.scene._scene.glplot.camera;
expect(cameraFinal.up[0]).toBeCloseTo(0, 2, 'cameraFinal.up[0]');
expect(cameraFinal.up[1]).toBeCloseTo(0, 2, 'cameraFinal.up[1]');
expect(cameraFinal.up[2]).toBeCloseTo(1, 2, 'cameraFinal.up[2]');
expect(cameraFinal.center[0]).toBeCloseTo(0, 2, 'cameraFinal.center[0]');
expect(cameraFinal.center[1]).toBeCloseTo(0, 2, 'cameraFinal.center[1]');
expect(cameraFinal.center[2]).toBeCloseTo(0, 2, 'cameraFinal.center[2]');
expect(cameraFinal.eye[0]).not.toBeCloseTo(1.2, 2, 'cameraFinal.eye[0]');
expect(cameraFinal.eye[1]).not.toBeCloseTo(1.2, 2, 'cameraFinal.eye[1]');
expect(cameraFinal.eye[2]).not.toBeCloseTo(1.2, 2, 'cameraFinal.eye[2]');
expect(cameraFinal.mouseListener.enabled === true);
})

@antoinerg
Copy link
Contributor

I could reproduce the bug and confirm that this PR fixes it. Here's the Codepen with the fix: https://codepen.io/antoinerg/pen/rRMOox?editors=1010

@etpinard, I think it's ready to go but maybe we should wait before merging to master?

@etpinard
Copy link
Contributor

etpinard commented Mar 4, 2019

This looks good! I'm curious: how expansive was that extra call to create camera object?

I'm a little scared of releasing this in a patch release. Maybe we should wait for 1.46.0 🤔

@archmoj have you manually tested zoom/pan/rotate on multiple gl3d mocks?

@archmoj
Copy link
Contributor Author

archmoj commented Mar 4, 2019

This looks good! I'm curious: how expansive was that extra call to create camera object?

Console.time may not not show much difference in terms of milliseconds. But it was complicated to modify camera object or link other events after it is was created in plotly.js, mainly because it was recreated and re-linked by gl-plot3d.

I'm a little scared of releasing this in a patch release. Maybe we should wait for 1.46.0

Yes I totally agree.

@archmoj have you manually tested zoom/pan/rotate on multiple gl3d mocks?

Yes and they seem to be working.

@etpinard
Copy link
Contributor

etpinard commented Mar 4, 2019

Yes I totally agree.

Great. Let's put this under 1.46.0

@etpinard etpinard added this to the v1.46.0 milestone Mar 4, 2019
@archmoj
Copy link
Contributor Author

archmoj commented Mar 20, 2019

@etpinard This PR may be a good candidate to merge now that #3601 merged. What do you think?

@etpinard
Copy link
Contributor

This PR may be a good candidate to merge now that #3601 merged. What do you think?

It is! I'm testing it one last time now. 👌

@@ -313,7 +313,7 @@ describe('Test isosurface', function() {
});
});

describe('@noCI hover', function() {
describe('hover', function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not anything new, but I noticed this test

it('should clear *cauto* when restyle *cmin* and/or *cmax*', function(done) {

is missing a @gl tag.

@etpinard
Copy link
Contributor

etpinard commented Mar 20, 2019

@etpinard
Copy link
Contributor

💃 💃 let's get this in master 🍾

@archmoj archmoj merged commit 12ce725 into master Mar 20, 2019
@archmoj archmoj deleted the fix3576-no-rotate-camera-before-modebar branch March 20, 2019 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants