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

USDZExporter: Throw exception when processing textures with no image data. #25093

Merged
merged 3 commits into from
Dec 9, 2022

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Dec 7, 2022

Related issue: #25022 (comment)

Description

USDZExporter reports a warning now when users try to export an asset with textures holding no image data (image=null).

@hybridherbst
Copy link
Contributor

This is worse than before now. Without knowing what data that single pixel should contain it's very easy to get entirely broken results and no way for users to see that. Either correct results should be exported or nothing, not knowingly broken results.

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Dec 7, 2022

If @mrdoob is okay then I just throw an exception when no image data are available (which of course aborts the export).

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Dec 8, 2022

I've added a new commit so the exporter throws an exception now. There is now one commit for each approach (warning or abort) so it's easier to review the PR.

@Mugen87 Mugen87 changed the title USDZExporter: Add warning when processing textures with no image data. USDZExporter: Throw exception when processing textures with no image data. Dec 8, 2022
@mrdoob mrdoob added this to the r148 milestone Dec 9, 2022
@mrdoob mrdoob merged commit dd5d429 into mrdoob:dev Dec 9, 2022
@mrdoob
Copy link
Owner

mrdoob commented Dec 9, 2022

Throwing an error sounds good to me 👍

@LeviPesin
Copy link
Contributor

LeviPesin commented Apr 19, 2023

I suggest to reconsider this in favor of just logging a warning -- because missing image data isn't an error of such kind that should abort export and forbid it.
Also, loaders (IIRC) do the same -- they log a warning if a loaded model is missing a texture, but use DEFAULT_IMAGE then as a replacement and continue loading.

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Apr 19, 2023

The app has full access on the asset before it is being exported so a comparison to how loaders work isn't valid. The issue is that problems in the asset like invalid texture data should be fixed before the export happens and throwing an error is the most effective way to ensure proper exported data.

@donmccurdy
Copy link
Collaborator

Of the two choices, I would also prefer throwing an error. Applications cannot see console warnings, but may need to handle this case. Some libraries balance these needs by allowing the user to provide a logger. For example:

exporter.setLogger({
  warn: (message) => {
    throw new Error(message);
  },
  ...
});

This can be helpful to increase error severity, to display the errors somewhere other than a JS console, etc.

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.

5 participants