All Products
Search
Document Center

PolarDB:ST_AsGltf

Last Updated:Jun 12, 2024

This topic describes the ST_AsGltf function. This function converts an object from the sfmesh type to the GL Transmission Format (glTF) type. Data of the glTF type is well suited to web browsers.

Syntax

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

Parameter

Parameter

Description

sfmeshObject

The sfmesh object.

options

The glTF options that are in the JSON format. The following list describes the involved fields:

  • with_geometry: specifies whether to include the child meshgeom object. Default value: true.

  • with_submesh: specifies whether to include the child sfmesh object. Default value: true.

  • enable_tile_option: specifies whether to use the tile option. For child objects, you can configure this field by following the instructions described in ST_SetTileOption. Default value: false.

Description

This function converts an object from the sfmesh type to the text format of glTF 2.0. If the conversion fails, NULL is returned.

Example:

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

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

-- Parameter
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}');

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