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

[GLTF Serializer] Allow GLTF Exporter to export WebP images #13062

Conversation

christaggart
Copy link
Contributor

@christaggart christaggart commented Oct 4, 2022

Adds JPEG and WEBP as valid optional mimetype options when serializing to a GLB.

Usage:
Add this to the dev host scene's button:

button1.onPointerUpObservable.add(function () {
        GLTF2Export.GLBAsync(scene, "webp.glb", {mimeType: ImageMimeType.WEBP}).then((glb) => {
            glb.downloadFiles();
          });
    });

Output as per gltf-transform inspect
PNG

TEXTURES
 ────────────────────────────────────────────
┌───┬─────────────────────────────────────┬─────┬──────────────────────────┬───────────┬───────────┬────────────┬───────────┬──────────┐
│ # │ name                                │ uri │ slots                    │ instances │ mimeType  │ resolution │ size      │ gpuSize¹ │
├───┼─────────────────────────────────────┼─────┼──────────────────────────┼───────────┼───────────┼────────────┼───────────┼──────────┤
│ 0 │ Material (Base Color) image         │     │ baseColorTexture         │ 1         │ image/png │ 1024x1024  │ 380.17 KB │ 5.59 MB  │
├───┼─────────────────────────────────────┼─────┼──────────────────────────┼───────────┼───────────┼────────────┼───────────┼──────────┤
│ 1 │ Material (Metallic Roughness) image │     │ metallicRoughnessTexture │ 1         │ image/png │ 1024x1024  │ 2.66 MB   │ 5.59 MB  │
├───┼─────────────────────────────────────┼─────┼──────────────────────────┼───────────┼───────────┼────────────┼───────────┼──────────┤
│ 2 │ Material (Normal) image             │     │ normalTexture            │ 1         │ image/png │ 1024x1024  │ 2.89 MB   │ 5.59 MB  │
└───┴─────────────────────────────────────┴─────┴──────────────────────────┴───────────┴───────────┴────────────┴───────────┴──────────┘

JPEG*

TEXTURES
 ────────────────────────────────────────────
┌───┬─────────────────────────────────────┬─────┬──────────────────────────┬───────────┬────────────┬────────────┬───────────┬──────────┐
│ # │ name                                │ uri │ slots                    │ instances │ mimeType   │ resolution │ size      │ gpuSize¹ │
├───┼─────────────────────────────────────┼─────┼──────────────────────────┼───────────┼────────────┼────────────┼───────────┼──────────┤
│ 0 │ Material (Base Color) image         │     │ baseColorTexture         │ 1         │ image/jpeg │ 1024x1024  │ 42.62 KB  │ 5.59 MB  │
├───┼─────────────────────────────────────┼─────┼──────────────────────────┼───────────┼────────────┼────────────┼───────────┼──────────┤
│ 1 │ Material (Metallic Roughness) image │     │ metallicRoughnessTexture │ 1         │ image/jpeg │ 1024x1024  │ 537.51 KB │ 5.59 MB  │
├───┼─────────────────────────────────────┼─────┼──────────────────────────┼───────────┼────────────┼────────────┼───────────┼──────────┤
│ 2 │ Material (Normal) image             │     │ normalTexture            │ 1         │ image/jpeg │ 1024x1024  │ 584.05 KB │ 5.59 MB  │
└───┴─────────────────────────────────────┴─────┴──────────────────────────┴───────────┴────────────┴────────────┴───────────┴──────────┘

WEBP

TEXTURES
 ────────────────────────────────────────────
┌───┬─────────────────────────────────────┬─────┬──────────────────────────┬───────────┬────────────┬────────────┬───────────┬──────────┐
│ # │ name                                │ uri │ slots                    │ instances │ mimeType   │ resolution │ size      │ gpuSize¹ │
├───┼─────────────────────────────────────┼─────┼──────────────────────────┼───────────┼────────────┼────────────┼───────────┼──────────┤
│ 0 │ Material (Base Color) image         │     │ baseColorTexture         │ 1         │ image/webp │ 1024x1024  │ 12.19 KB  │ 5.59 MB  │
├───┼─────────────────────────────────────┼─────┼──────────────────────────┼───────────┼────────────┼────────────┼───────────┼──────────┤
│ 1 │ Material (Metallic Roughness) image │     │ metallicRoughnessTexture │ 1         │ image/webp │ 1024x1024  │ 375.18 KB │ 5.59 MB  │
├───┼─────────────────────────────────────┼─────┼──────────────────────────┼───────────┼────────────┼────────────┼───────────┼──────────┤
│ 2 │ Material (Normal) image             │     │ normalTexture            │ 1         │ image/webp │ 1024x1024  │ 418.08 KB │ 5.59 MB  │
└───┴─────────────────────────────────────┴─────┴──────────────────────────┴───────────┴────────────┴────────────┴───────────┴──────────┘

My first PR for this project, so let me know if I'm missing anything.

@azure-pipelines
Copy link

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@christaggart christaggart force-pushed the feat-allow-specifying-mimetype-glb-serializer branch from db26b8a to 1b26914 Compare October 4, 2022 20:29
@azure-pipelines
Copy link

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@christaggart christaggart changed the title [GLTF Serializer] Allow GLTF Exporter to export supported mimetypes [GLTF Serializer] Allow GLTF Exporter to export WebP images Oct 5, 2022
@christaggart christaggart force-pushed the feat-allow-specifying-mimetype-glb-serializer branch from bfda702 to 6b57bf0 Compare October 5, 2022 17:41
@azure-pipelines
Copy link

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@azure-pipelines
Copy link

@sebavan
Copy link
Member

sebavan commented Oct 5, 2022

just a tiny lint issue you can fix with npm run format:fix && npm run lint:fix and good to go

@christaggart christaggart force-pushed the feat-allow-specifying-mimetype-glb-serializer branch from 6b57bf0 to 02f3a07 Compare October 5, 2022 20:14
@bghgary bghgary merged commit 86849d2 into BabylonJS:master Oct 5, 2022
RaananW pushed a commit that referenced this pull request Dec 9, 2022
Former-commit-id: cd1c62df09be4c24be4cf853c6f64b6a018e8a5f
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