All Products
Search
Document Center

PolarDB:ST_AsGlb

Last Updated:Mar 28, 2026

Converts an sfmesh object to GLB, the binary format of GL Transmission Format (glTF) 2.0. Returns NULL if the conversion fails.

Syntax

bytea ST_AsGlb(sfmesh sfmeshObject);

bytea ST_AsGlb(sfmesh sfmeshObject, json options);

Parameters

ParameterTypeDescription
sfmeshObjectsfmeshThe sfmesh object to convert.
optionsJSONglTF export options. See Options for details.

Options

Pass options as a JSON object. All fields are optional.

FieldTypeDefaultDescription
draco_compressbooleanfalseApplies Draco compression to the output. Use this to reduce file size when the client supports Draco-encoded GLB.
with_geometrybooleantrueIncludes the child meshgeom object in the output. Set to false to omit geometry data.
with_submeshbooleantrueIncludes child sfmesh objects in the output. Set to false to flatten the hierarchy.
enable_tile_optionbooleanfalseApplies the tile option to child objects. Configure tile behavior using ST_SetTileOption before conversion.

Examples

Basic conversion

Convert an sfmesh object to GLB with default settings.

SELECT ST_AsGlb(
  ST_MeshFromText(
    '{"version" : 1, "root" : 0, "meshgeoms" : ["MESHGEOM(PATCH(INDEXSURFACE Z (VERTEX(0 0 2,0 10 3,10 10 1,10 0 1),INDEX((0,1,2),(1,2,3)))))"], "primitives" : [{"meshgeom" : 0}], "nodes" : [{"primitive" : 0}]}'
  )
);

Result:

\x676c54460200000028040000a40300004a534f4e7b226163636573736f7273223a5 ......

With Draco compression

Apply Draco compression to reduce output size. The client must support Draco-encoded GLB.

SELECT ST_AsGlb(
  ST_MeshFromText(
    '{"version" : 1, "root" : 0, "meshgeoms" : ["MESHGEOM(PATCH(INDEXSURFACE Z (VERTEX(0 0 2,0 10 3,10 10 1,10 0 1),INDEX((0,1,2),(1,2,3)))))"], "primitives" : [{"meshgeom" : 0}], "nodes" : [{"primitive" : 0}]}'
  ),
  '{"draco_compress": true, "with_geometry": true}'
);

Result:

\x676c544602000000840300000c0300004a534f4e7b226173736574223a7b2276657273696f6e223a22322e3 ...

See also