Converts an sfmesh object to the GLB 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, text options);Parameters
| Parameter | Description |
|---|---|
sfmeshObject | The sfmesh object to convert. |
options | The glTF export options in JSON format. See the following table for supported fields. |
Options fields
| Field | Description | Default |
|---|---|---|
draco_compress | Specifies whether to compress the output using Draco. | false |
with_geometry | Specifies whether to include child meshgeom objects. | true |
with_submesh | Specifies whether to include child sfmesh objects. | true |
enable_tile_option | Specifies whether to apply the tile option. Configure this field for child objects using ST_SetTileOption. | false |
Examples
Convert an sfmesh object to 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}]}'
)
);
------------------------------------------------------------------------------
\x676c54460200000028040000a40300004a534f4e7b226163636573736f7273223a5 ......Convert with Draco compression enabled:
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}'
);
---------------------------------
\x676c544602000000840300000c0300004a534f4e7b226173736574223a7b2276657273696f6e223a22322e3 ...