All Products
Search
Document Center

PolarDB:ST_AsGltf

Last Updated:Mar 28, 2026

Converts an sfmesh object to GL Transmission Format (glTF) 2.0 text. Returns NULL if the conversion fails.

Syntax

text ST_AsGltf(sfmesh sfmeshObject);
text ST_AsGltf(sfmesh mesh, cstring optins);

Parameters

ParameterDescription
sfmeshObjectThe sfmesh object to convert.
optionsExport options in JSON format. See the options fields below.

options fields

FieldDefaultDescription
with_geometrytrueSpecifies whether to include child meshgeom objects.
with_submeshtrueSpecifies whether to include child sfmesh objects.
enable_tile_optionfalseSpecifies whether to apply tile options to child objects. Configure tile options using ST_SetTileOption.

Examples

The following examples use ST_MeshFromText to create an sfmesh object from a JSON string, then export it as glTF 2.0.

Example 1: Export with default options

All child meshgeom and sfmesh objects are included in the output.

SELECT ST_AsGltf(
  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}]}'
  )
);

Output (truncated):

{"accessors":[{"bufferView":0,"componentType":5121,"count":6,"max" ....

Example 2: Export without geometry data

Setting with_geometry to false omits meshgeom objects from the output.

SELECT ST_AsGltf(
  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}]}'
  ),
  '{"with_geometry":false}'
);

Output:

{"asset":{"generator":"ganos","version":"2.0"},"nodes":[{}]}