Converts a sfmesh object into 3D Tiles format and stores the result in your database.
Syntax
boolean ST_As3dTiles(sfmesh sfmesh_object, cstring table_name, cstring options default '{}');Prerequisites
Before calling ST_As3dTiles, import the sfmesh object using ST_ImportIFC.
Parameters
| Parameter | Description |
|---|---|
sfmesh_object | The sfmesh object to convert. |
table_name | The name of the output table. |
options | Conversion options as a JSON string. Default value: '{}'. |
Return values
| Value | Description |
|---|---|
true | The data was exported successfully. |
false | The export failed. |
Options
| Option | Type | Default | Description |
|---|---|---|---|
schema | String | public | The schema of the output table. |
project | String | — | The project name. Stored as the project_name field in each record. |
parallel | Integer | 1 | The degree of parallelism (DOP). Higher values speed up processing but consume more memory. Maximum value: 16. |
size_threshold | Integer | 2048 | The tile splitting threshold, in KB. Geometric objects larger than this value are split until each tile falls below the threshold. |
srid | Integer | — | The spatial reference identifier (SRID) of the target sfmesh object. If the SRID of the source and target objects differ, an error is returned. If not specified, the output has no SRID. |
method | String | oct | The splitting method. Valid values: oct (octree), quad (quadtree), bsp (BSP tree). |
filter_percent | Float | 0.1 | The filtering ratio. Valid values: 0 to 1. For each non-leaf node tile, objects whose volume is less than this ratio of the tile volume are excluded. |
tileset_prefix | String | — | The prefix of the 3D Tiles tileset endpoint URL. |
enable_tile_option | Boolean | false | Specifies whether to enable the built-in tile attributes of the sfmesh object. |
merge_material | Boolean | true | Specifies whether to merge geometry that shares the same material. Enabling this option can reduce output file size. |
with_extension | Boolean | false | Specifies whether to add a suffix to the URI of B3DM and tileset in the generated tileset file. |
vertex_threshold | Float | 0.0001 | The vertex merge threshold. Set to 0 to skip vertex merging. Otherwise, vertices within each tile whose spacing is less than this value are merged. |
update_normal | Boolean | false | Specifies whether to recalculate normal data after vertex merging. |
divide_factor | Float | 5 | The geometricError calculation factor. Doubling this value halves geometricError for non-leaf nodes. |
Usage notes for options
Vertex merging and normal data
When threshold-based vertex merging is enabled:
Original normal data is deleted.
Enable
update_normalto recalculate normals after merging, preserving accurate shading and lighting.The visual result varies depending on the vertex merge threshold.
Recalculating normals for objects that had no normal data increases the output volume.
`geometricError` tuning
If geometricError for non-leaf nodes is too large, increase divide_factor. Doubling divide_factor halves geometricError.
Output tables
The function creates three tables in your database:
[table_name] — primary table (tile metadata)
| Field | Type | Description |
|---|---|---|
project_id | uuid | The project ID. Auto-generated. |
project_name | text | The project name. Empty if the project option is not specified. In most cases, the table is used to store the tables of multiple sub-projects. |
srid | integer | Not used. |
anchor | geometry | The 3D anchor point of the project. The center point of the sfmesh project projected into the WGS 84 coordinate system. |
extent | geometry | Not used. |
aux | text | Not used. |
tiletable | varchar(64) | Not used. |
[table_name]_tile — tile table (all tile data)
| Field | Type | Description |
|---|---|---|
project_id | uuid | The project ID. Same as in [table_name]. |
project_name | text | The project name. Same as in [table_name]. |
uid | uuid | The tile ID. Auto-generated. |
lod | integer | Not used. |
parent | uuid | Not used. |
children | uuid[] | Not used. |
aux | jsonb | Not used. |
tile | scene | The tile entity. |
[table_name]_tileset — tileset table (tileset.json details)
| Field | Type | Description |
|---|---|---|
project_id | uuid | The project ID. Same as in [table_name]. |
project_name | text | The project name. Same as in [table_name]. |
uid | uuid | The ID of the tileset.json entry. For the project root node, this equals project_id. |
tileset | jsonb | The tileset.json entity. |
Examples
Basic conversion
SELECT ST_As3dTiles(sfmesh_obj, 'test_table')
FROM t_sfmesh
WHERE id = 1;
---------
tEnable parallel processing
SELECT ST_As3dTiles(sfmesh_obj, 'test_table', '{"parallel": 2}')
FROM t_sfmesh
WHERE id = 1;
---------
tSet project name, splitting method, and size threshold
SELECT ST_As3dTiles(sfmesh_obj, 'test_table', '{"project":"test_proj", "method":"oct", "size_threshold":20}')
FROM t_sfmesh
WHERE id = 1;
---------
t