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

Support output groups #2

Open
donmccurdy opened this issue Apr 12, 2022 · 1 comment
Open

Support output groups #2

donmccurdy opened this issue Apr 12, 2022 · 1 comment
Labels
enhancement New feature or request P2

Comments

@donmccurdy
Copy link
Contributor

In the current implementation, if the end-user wants to load different models on desktop and mobile, they have to provide both models as inputs. Processing on each (if it needs to be different) would then be configured with the plugin's include flag, like include: "**/*.mobile.glb".

Alternatively, it could be interesting to explore having the plugin generate multiple groups of outputs, each with different optimization settings, like...

const DEFAULTS = [ mozjpeg(), oxipng() ];

export default defineConfig({
  // ...
  plugins: [
    gltf({
      output: [
        { name: 'hi', transforms: [ textureResize({size: [2048, 2048]}), ...DEFAULTS ] },
        { name: 'lo', transforms: [ textureResize({size: [1024, 1024]}), ...DEFAULTS ] },
      ]
    });
  ]
});

... and then the application might choose which to import based on device type or other considerations:

import { lo, hi } from 'path/to/content.glb';

export const models = [
  // NOTE: Example only. 'prefers-reduced-data' is not widely supported.
  { name: 'content', type: 'glb', url: matchMedia('prefers-reduced-data') ? lo : hi }
];
@donmccurdy donmccurdy added the enhancement New feature or request label Apr 12, 2022
@juniorxsound
Copy link
Contributor

This would be incredibly neat! Got me thinking of how nicely this could integrate into things like THREE.LOD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P2
Projects
None yet
Development

No branches or pull requests

2 participants