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

Implement toBlob function on ModelViewerElementBase #861

Merged
merged 12 commits into from
Nov 5, 2019
Merged

Implement toBlob function on ModelViewerElementBase #861

merged 12 commits into from
Nov 5, 2019

Conversation

maaslalani
Copy link
Contributor

Reference Issue

Fixes #858

Adds toBlob to the ModelViewerElementBase.

https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob

General Approach

The general approach was to delegate the toBlob on the model-viewer to the canvas. Instead of using callbacks like HTMLCanvasElement does with toBlob, I used promises so that it is possible to use async/await syntax. We can change this back if needed.

Copy link
Contributor

@cdata cdata left a comment

Choose a reason for hiding this comment

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

Great work, thanks for the contribution @maaslalani !

Mostly minor feedback.

src/model-viewer-base.ts Show resolved Hide resolved
src/model-viewer-base.ts Outdated Show resolved Hide resolved
src/utilities/data-conversion.ts Outdated Show resolved Hide resolved
src/utilities/data-conversion.ts Outdated Show resolved Hide resolved
index.html Show resolved Hide resolved
src/model-viewer-base.ts Show resolved Hide resolved
@cdata
Copy link
Contributor

cdata commented Nov 1, 2019

src/test/model-viewer-base-spec.ts Show resolved Hide resolved
src/test/model-viewer-base-spec.ts Outdated Show resolved Hide resolved
@maaslalani maaslalani requested a review from cdata November 4, 2019 22:34
@cdata
Copy link
Contributor

cdata commented Nov 5, 2019

Thanks for the great work on this @maaslalani LGTM 💯

@cdata cdata merged commit ba7fbe7 into google:master Nov 5, 2019
@cdata cdata added this to the v0.8.0 milestone Dec 19, 2019
elalish pushed a commit to elalish/model-viewer that referenced this pull request Feb 4, 2020
* Implement toBlob function on model-viewer-base

* Update documentation to specify qualityArgument is only available on Chrome Desktop and Firefox

* Prefer Url over URL casing

* Add License, Descriptive comment, and adjusted style guide to match other utility functions.

* Utility function dataUrlToBlob async

* Use spy helper to emulate unsupported browser and add test for equivalency between supported and unsupported browsers

* Add support for msToBlob for IE

* Remove .only from test suite

* Compare arrayBuffers

* Try and catch errors because spy toBlob will throw on edge

* Skip test on IE11 and add comment on using Response

* Remove https?: from objectUrlMatcher
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.

Improving the screenshot API using toBlob instead of toDataURL
3 participants