Skip to content

Support output groups #2

@donmccurdy

Description

@donmccurdy

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 }
];

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions