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

GLTFExporter: add onError parameter to parse #22774

Merged
merged 4 commits into from
Nov 11, 2021

Conversation

marcofugaro
Copy link
Contributor

Related issue: #22755 (comment)

Description

This allows us to correctly catch errors, even in the promise after this.pending.

I did this by converting GLTFWriter.write() to async since it was cleaner.

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 3, 2021

This change introduces a syntax error which breaks the exporter:

Uncaught SyntaxError: Identifier 'options' has already been declared

https://raw.githack.com/marcofugaro/three.js/gltfexporter-errors/examples/misc_exporter_gltf.html

@marcofugaro
Copy link
Contributor Author

Ups, thanks for checking!

Fixed now.

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 3, 2021

It seems the documentation page also needs a small update: https://threejs.org/docs/index.html#examples/en/exporters/GLTFExporter

@marcofugaro
Copy link
Contributor Author

Okay, will do. What should this example become?

Is it okay like this?

// Parse the input and generate the glTF output
exporter.parse(
  scene,
  // called when the gltf has been generated
  function ( gltf ) {
    console.log( gltf );
    downloadJSON( gltf );
  },
  // called when there are some error in the generations
  function ( error ) {
    console.log( 'An error happened' );
  },
  options
);

Otherwise I can just put null instead of the function.

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 3, 2021

Is it okay like this?

That looks good to me!

@marcofugaro
Copy link
Contributor Author

Cool, all done.

@Mugen87 Mugen87 added this to the r135 milestone Nov 8, 2021
@mrdoob mrdoob merged commit 429b3d3 into mrdoob:dev Nov 11, 2021
@mrdoob
Copy link
Owner

mrdoob commented Nov 11, 2021

Thanks!

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.

3 participants