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

remove OffscreenCanvas to fix errors #24024

Closed
wants to merge 1 commit into from

Conversation

johnnyz2017
Copy link

Related issue: N/A

Description

When exporting a model with images to gltf format, an error occurs:
GLTFExporter.js:1134 Uncaught (in promise) TypeError: canvas.toDataURL is not a function
at GLTFWriter.processImage (GLTFExporter.js:1134:27)
at GLTFWriter.processTexture (GLTFExporter.js:1192:17)
at GLTFWriter.processMaterial (GLTFExporter.js:1274:42)
at GLTFWriter.processMesh (GLTFExporter.js:1665:26)
at GLTFWriter.processNode (GLTFExporter.js:1952:27)
at GLTFWriter.processNode (GLTFExporter.js:1974:29)
at GLTFWriter.processScene (GLTFExporter.js:2028:28)
at GLTFWriter.processInput (GLTFExporter.js:2084:10)
at GLTFWriter.write (GLTFExporter.js:437:8)
at GLTFExporter.parse (GLTFExporter.js:120:10)

The easiest solution is to remove OffscreenCanvas and use ordinary canvas uniformly.

@takahirox
Copy link
Collaborator

Hi, thanks for the problem report and PR.

Unfortunately I don't think removing OffscreenCanvas is a good solution because we use it to enable the exporter to even run in WebWorkers #23857

Probably finding an alternative of .toDataURL() for OffscreenCanvas is better.

@LeviPesin
Copy link
Contributor

LeviPesin commented May 8, 2022

Here is how to do that:
https://stackoverflow.com/a/56495103
I.e. it is await new FileReader().readAsDataURL( await canvas.convertToBlob() ).

@johnnyz2017
Copy link
Author

OK, got it.

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.

4 participants