Skip to content

Improve camera init - #3585

Merged
archmoj merged 16 commits into
masterfrom
fix3576-no-rotate-camera-before-modebar
Mar 20, 2019
Merged

Improve camera init #3585
archmoj merged 16 commits into
masterfrom
fix3576-no-rotate-camera-before-modebar

Conversation

@archmoj

@archmojarchmoj commented Feb 27, 2019

Copy link
Copy Markdown
Contributor

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

@antoinerg

antoinerg commented Feb 27, 2019

Copy link
Copy Markdown
Contributor

@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
Copy Markdown
ContributorAuthor

@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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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

@antoinerg Yes, I do confirm that.

Comment threadpackage.json Outdated
"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
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

@archmojarchmoj changed the title Bug fix: disable camera mouse listener before scene is completeImprove camera init Feb 28, 2019
@archmoj

Copy link
Copy Markdown
ContributorAuthor

@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(){
varcameraFinal=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);
})

Comment threadtest/jasmine/tests/gl3d_plot_interact_test.js
@antoinerg

Copy link
Copy Markdown
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
Copy Markdown
Contributor

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

archmoj commented Mar 4, 2019

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
Contributor

Yes I totally agree.

Great. Let's put this under 1.46.0

@etpinardetpinard added this to the v1.46.0 milestone Mar 4, 2019
@archmoj

Copy link
Copy Markdown
ContributorAuthor

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

@etpinard

Copy link
Copy Markdown
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. 👌

});

describe('@noCI hover', function() {
describe('hover', function() {

Copy link
Copy Markdown
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

etpinard commented Mar 20, 2019

Copy link
Copy Markdown
Contributor

@etpinard

Copy link
Copy Markdown
Contributor

💃 💃 let's get this in master 🍾

@archmoj
archmoj merged commit 12ce725 into masterMar 20, 2019
@archmoj
archmoj deleted the fix3576-no-rotate-camera-before-modebar branch March 20, 2019 15:44
@archmojarchmoj mentioned this pull request Mar 22, 2019
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugsomething broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@archmoj@antoinerg@etpinard