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

Refactor gl3d scene #4360

Merged
merged 12 commits into from
Jan 29, 2020
Merged

Refactor gl3d scene #4360

merged 12 commits into from
Jan 29, 2020

Conversation

archmoj
Copy link
Contributor

@archmoj archmoj commented Nov 18, 2019

This PR adds setters to gl-plot3d and refactors functions/methods of gl3d/scene.js file to use gl-plot3d functions to change camera attributes and avoid two camera instances, etc.

@plotly/plotly_js
Please review this PR commit by commit.

After all, this PR does NOT f_i_x #4236 by passing a different config (premultipliedAlpha: false) to gl-plot3d module. As used to be suggested in this demo {to compare before and after effects on Windows(7/10) using Chrome/Firefox/Opera as well as on Ubuntu using Firefox}.
That may be addressed in separated PR in future.

@@ -97,7 +97,7 @@ proto.tryCreatePlot = function() {
gl: scene.gl,
glOptions: {
preserveDrawingBuffer: isMobile,
premultipliedAlpha: true,
premultipliedAlpha: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. Does this lead to any changes in performance ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. It shouldn't. Anyway I would double check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We decided not to change this config in this PR for now: ade22a6.

@etpinard
Copy link
Contributor

Fix #4236 by passing different config to gl-plot3d module.

Is the only change in the WebGL config the premultipliedAlpha value?

@archmoj
Copy link
Contributor Author

archmoj commented Nov 19, 2019

Fix #4236 by passing different config to gl-plot3d module.

Is the only change in the WebGL config the premultipliedAlpha value?

Yes that is the only change in the config.

@archmoj archmoj changed the title Refactor gl3d scene and camera Refactor gl3d scene and disable premultipliedAlpha Nov 20, 2019
@archmoj
Copy link
Contributor Author

archmoj commented Nov 20, 2019

before vs after windows10+chrome78

beforeAfter_windows10_chrome78b

@archmoj
Copy link
Contributor Author

archmoj commented Nov 20, 2019

before vs after windows10+chrome78

beforeAfter_windows10_chrome78

@archmoj
Copy link
Contributor Author

archmoj commented Nov 20, 2019

before vs after windows10+firefox70

beforeAfter_windows10_firefox70

@archmoj
Copy link
Contributor Author

archmoj commented Nov 20, 2019

Also added a codepen to the PR description to help compare the two options.
After figuring out which premultipliedAlpha option to use as the default, it may be best to provide both options in the API.
Anyway applying premultipliedAlpha: false would make the graphs render similar to save as png version.
cc: @alexcjohnson @antoinerg

@archmoj
Copy link
Contributor Author

archmoj commented Nov 21, 2019

Then in order to keep the best view and consistent png results we could default layout.scene.bgcolor to white instead of rgba(0,0,0,0).

@archmoj archmoj removed the bug something broken label Jan 28, 2020
@archmoj
Copy link
Contributor Author

archmoj commented Jan 28, 2020

@etpinard all the tests passed and this PR should be ready to merge.

Comment on lines +98 to +102
glOptions: {
preserveDrawingBuffer: isMobile,
premultipliedAlpha: true,
antialias: true
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Can I ask why you're now passing these options from plotly.js? The corresponding option object current on master is:

    var glplotOptions = {
        canvas: canvas,
        gl: gl,
        container: scene.container,
        axes: scene.axesOptions,
        spikes: scene.spikeOptions,
        pickRadius: 10,
        snapToData: true,
        autoScale: true,
        autoBounds: false,
        cameraObject: cameraObject,
        pixelRatio: pixelRatio
    };

that is, the glOptions container is new.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Where is that set on master?

Copy link
Contributor

Choose a reason for hiding this comment

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

var glplotOptions = {
canvas: canvas,
gl: gl,
container: scene.container,
axes: scene.axesOptions,
spikes: scene.spikeOptions,
pickRadius: 10,
snapToData: true,
autoScale: true,
autoBounds: false,
cameraObject: cameraObject,
pixelRatio: pixelRatio
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://github.com/gl-vis/gl-plot3d/blob/d206f1f110d427b2baae0462964bc59cf7f59dae/scene.js#L80-L87
The glOptions used to be left undefined and hidden to plolty.js developers.
Now that are explicitly defined, it should be easier to figure out what the differences between static & interactive plots are.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, that's fair. But then is-mobile becomes a top-level dependency for plotly.js and we should add it to our package.json.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. OK if I add it to package.json?

Copy link
Contributor

Choose a reason for hiding this comment

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

OK if I add it to package.json

yes please!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simply listed in ff2ecc7.
But also noticed that it was added in package-lock before which is not clear why?
75de9e5dea

Copy link
Contributor

@etpinard etpinard Jan 28, 2020

Choose a reason for hiding this comment

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

But also noticed that it was added in package-lock before which is not clear why?

Yeah it was in the package-lock before, because the package-lock lists all the dependencies not just the top-level ones. It's a best practice to include all the top-level dependencies in the package.json, and make npm handles the nested dependencies part in the package-lock.

@etpinard
Copy link
Contributor

etpinard commented Jan 29, 2020

💃 - nicely done!

Before merging, could you change the PR title to something like "Refactor gl3d scene" as this PR no longer disables premultipliedAlpha.

@archmoj archmoj changed the title Refactor gl3d scene and disable premultipliedAlpha Refactor gl3d scene Jan 29, 2020
@archmoj archmoj merged commit 453e70e into master Jan 29, 2020
@archmoj archmoj deleted the revise-gl3d-scene branch January 29, 2020 15:07
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