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

USDZExport creates an empty (visually) USDZ file from a GLTF created in the browser #22454

Closed
jeffscottward opened this issue Aug 29, 2021 · 14 comments
Assignees

Comments

@jeffscottward
Copy link

jeffscottward commented Aug 29, 2021

Continuation from previously filed issue

Describe the bug

Trying to create a GLTF in the browser and convert it to USDZ without needing to download a GLTF file first.
TLDR; On-the-fly-USDZ creation and download

It successfully creates a GLTF in memory, loads the GLTF after wrapping in blob, and exports the usdz file (in theory).

I can see the object as GLTF in the Three.js editor and Apple's Reality Convertor but not in any QuickLook view (phone or Finder)

gltf-w-r3f

rc

usdz-empty

Source of export here: https://github.com/jeffscottward/r3f-to-ar/blob/main/src/exporters/usdzExporter.js
Repo here: https://github.com/jeffscottward/r3f-to-ar

To Reproduce

git clone https://github.com/jeffscottward/r3f-to-ar/
yarn && yarn start

Click the model - it should download 2 files, 1 gltf and 1 usdz

Platform:

Device: Laptop
OS: MacOS
Browser: Chrome
Three.js version: "^0.132.2"

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 30, 2021

Do you mind sharing the USDZ file in this thread?

Besides, does it work if you import the glTF into the three.js editor and then export to USDZ? If so, there must be an issue inside your app and then it's better to ask at the forum for help.

@jeffscottward
Copy link
Author

jeffscottward commented Aug 30, 2021

Exporting from Three.js editor does not work. :(

(Had to send a link because the file uploader here doesn't like either file)

https://github.com/jeffscottward/r3f-to-ar/blob/82532378a626f78a766b5b543ed0b6f5997e4f9c/public/scene.gltf
https://github.com/jeffscottward/r3f-to-ar/blob/82532378a626f78a766b5b543ed0b6f5997e4f9c/public/scene.usdz

Again here is the exporter code for each.
GLTF is straight forward.
USDZ is doing the same as the first and then just wraping and loading via blobURLs.
I console logged each result value before I feed it to the USDZ convertor and all seems ok, I see the scene with UUID etc.

https://github.com/jeffscottward/r3f-to-ar/blob/main/src/exporters/gltfExporter.js
https://github.com/jeffscottward/r3f-to-ar/blob/main/src/exporters/usdzExporter.js

Screen Shot 2021-08-30 at 9 17 47 AM

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 30, 2021

It seems it does not work because you assign MeshBasicMaterial to the mesh. However, only MeshStandardMaterial is supported by USDZExporter. If I change the material type in the editor and then export to UDSZ, the preview works. Here is the resulting model:

model.usdz.zip

@mrdoob
Copy link
Owner

mrdoob commented Aug 30, 2021

I'll take care of this 👍

@mrdoob mrdoob self-assigned this Aug 30, 2021
@jeffscottward
Copy link
Author

Great! I figured it wasn't me given the simplicity.
I suspect there are other materials that could be problematic - I think I had a problem with phong too? Idk if that one makes sense. Forgive me on this, Im a super newbie with what actually makes sense to export. I just imagine this popping up more probably unless every base is covered.

@mrdoob
Copy link
Owner

mrdoob commented Aug 30, 2021

USDZ only supports MeshStandardMaterial.

@mrdoob
Copy link
Owner

mrdoob commented Aug 30, 2021

But we can fake MeshBasicMaterial support.

@jeffscottward
Copy link
Author

Hmm without docs, or a pointer to USDz native docs, I wouldn't know thats the case.

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 30, 2021

Maybe we can add a warning somewhere at the following place to inform users if they are exporting meshes with an unsupported material?

if ( object.isMesh && object.material.isMeshStandardMaterial ) {

@jeffscottward
Copy link
Author

that would be the best - feature detection warnings/errors in console.

@jeffscottward
Copy link
Author

jeffscottward commented Sep 1, 2021

@Mugen87 is this an enhancement (assuming meaning low priority) or a bug?
This is a showstopper (silent failures generally) for my intended use case. Would help expedite if I could.

@jeffscottward
Copy link
Author

Any progress on this?

@Skyswimsky
Copy link

Some sort of warnings or a bare-bone documentation would be nice. Does it help to voice my support for it?

I've had a similar issue with this. Had a MeshPhonMaterial and had to create a GLTFBlob to make the USDZExport not turn out empty. However, the (test) object in question is a group of multiple objects which, upon export, would reset their position back to 0, 0, 0 of the world coordinates. Or in other words instead of this:
image

I would get this:
image

Changing the material fixed pretty much everything. Though I spend a lot of time trying to fix it before checking the issues listed here.

Also rather new to most of this, so apologize for anything inappropriate.

@mrdoob
Copy link
Owner

mrdoob commented Nov 15, 2021

Maybe we can add a warning somewhere at the following place to inform users if they are exporting meshes with an unsupported material?

if ( object.isMesh && object.material.isMeshStandardMaterial ) {

Done. 6e4f7a5

@mrdoob mrdoob closed this as completed Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants