-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
GLTF: export same mimetype as import #23592
Conversation
With this change, the export of DamagedHelmet.glb drops from 17.9 Mb to 3.1 Mb, very near the input of 2.9 Mb. I understand this method isn't perfect, but I also don't want to throw the baby out with the bath water. This has the additional advantage that one can now specify any output format for each texture simply by setting |
Clean up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a start this solution is okay!
@Mugen87 now that the |
Basically yes. However, looking at the code I think using |
Hmm, I still wonder though.... Isn't there a way to store the original image raw data in Recompressing jpgs/webms doesn't make me feel good 😅 |
For sure, this is a stop-gap solution. But honestly, recompressing a JPEG as a JPEG at the same resolution is pretty much lossless anyway (the high frequencies were already removed). And WebP to PNG is fine except for inflating the size (and it's a small use case at the moment). That's fixable by doing what @donmccurdy was suggesting. |
Thanks! |
* export same mimetype as import * Update GLTFLoader.js Clean up. * remove webp for now * fix webp in the proper place this time * fix bad revert * remove ?? * cleanup * addressing feedback * factor out function Co-authored-by: Michael Herzog <[email protected]>
Cherry-picked into |
Hi, Since this change I have problem when my textures come from a canvas element. Kind regards |
@bildekrokodil could you share the specific error and stack trace that is thrown when this error happens? All texture types should have texture.userData.mimeType = material.roughnessMap.userData.mimeType || material.metalnessMap.userData.mimeType || material.aoMap.userData.mimeType; This PR has since been restructured by #23616, so that issue is likely already fixed, but not yet published in a release. EDIT: Actually it was published as 0.138.2, so I'd be curious if the error still happens and what the full error message is. |
Oh, interesting; I thought |
All texture types do extend from Texture and so have |
Yeah, I sneaked in a robustness fix in that PR. I should have mentioned it but I was brain dead 😅 |
Hi, This is the error I got: I use the JS version in combination with A-Frame. I export an A-Frame model with canvas textures on it. It works until this commit. At this moment I use the previous version of the GLTFExporter to make it work. Kind regards |
@bildekrokodil Any change you can do a jsfiddle reproducing the issue? |
@mrdoob https://jsfiddle.net/bigcroco/xq6hacw5/1/ In the code I have the default a-frame scene. But added a canvas as a resource and another box that uses this canvas as a texture. When you run it it will give you that error. Kind regards |
@bildekrokodil Please, report the issue in the a-frame repo instead: https://github.com/aframevr/aframe |
Important to note that the demo above uses an A-Frame version pinned to three.js r125. Pulling a newer version of THREE.GLTFExporter in with an older version of three.js is not really supported by three.js or by A-Frame. It might be best to use a copy of GLTFExporter from r125 until A-Frame updates to a newer version of three.js. |
* export same mimetype as import * Update GLTFLoader.js Clean up. * remove webp for now * fix webp in the proper place this time * fix bad revert * remove ?? * cleanup * addressing feedback * factor out function Co-authored-by: Michael Herzog <[email protected]>
Fixes: #23587
Description
This allows GLTFExporter to create textures of the same mimeType as the input, so keep file size from growing. @donmccurdy @Mugen87