unwrapPrimitives

  • experimental
  • Generate new texture coordinates (“UV mappings”) for Primitives. Useful for adding texture coordinates in scenes without existing UVs, or for creating a second set of texture coordinates for baked textures such as ambient occlusion maps and lightmaps. Operation may increase vertex count to accommodate UV seams.

    UV layouts may be grouped, reducing the number of textures required. Available groupings:

    • "primitive": Each primitive is given it's own texcoord atlas.
    • "mesh": All primitives in a mesh share a texcoord atlas. (default)
    • "scene": All primitives in the scene share a texcoord atlas.

    watlas must be initialized before calling this function.

    Example:

    import * as watlas from 'watlas';
    import { unwrapPrimitives } from '@gltf-transform/functions';
    
    // Initialize watlas.
    await watlas.Initialize();
    
    // Generate a TEXCOORD_1 attribute for the specified primitives.
    unwrapPrimitives(mesh.listPrimitives(), {
      watlas,
      texcoord: 1,
      overwrite: true
    });
    

    To create texture coordinates for an entire Document, see unwrap.

Function symbol, where the argument and output are a box labeled 'glTF'.

Made by Don McCurdy. Documentation built with greendoc and published under Creative Commons Attribution 3.0.