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
| Parameter | Description |
|---|---|
sfmeshObject | The sfmesh object to convert. |
options | Export options in JSON format. See the options fields below. |
options fields
| Field | Default | Description |
|---|---|---|
with_geometry | true | Specifies whether to include child meshgeom objects. |
with_submesh | true | Specifies whether to include child sfmesh objects. |
enable_tile_option | false | Specifies 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":[{}]}