Converts an sfmesh object into the 3D Tiles format and stores the result in your database.
Syntax
boolean ST_As3dTiles(sfmesh sfmesh_object, cstring table_name, cstring options default '{}');Parameters
| Parameter | Description |
|---|---|
sfmesh_object | The sfmesh object to convert. |
table_name | The name of the output table. |
options | A JSON string of configuration options. Defaults to {}. |
Return values
| Value | Description |
|---|---|
true | The object was exported successfully. |
false | The export failed. |
Usage notes
Before calling ST_As3dTiles, import the sfmesh object using ST_ImportIFC.
Options
| Option | Type | Default | Description | Example |
|---|---|---|---|---|
schema | String | public | The schema of the output table. | ganos |
project | String | — | The project name. Used as the project_name field in each record. | project_1 |
parallel | Integer | 1 | The degree of parallelism (DOP). Higher values speed up export but increase memory usage. Set this based on your data size and database load. Maximum value: 16. | 16 |
size_threshold | Integer | 2048 | The splitting threshold in KB. Geometric objects larger than this size are split until each tile is smaller than the threshold. | 4096 |
srid | Integer | — | The spatial reference identifier (SRID) of the output sfmesh object. If the source and output SRIDs differ, an error is returned. If not specified, the output has no SRID. | 2326 |
method | String | oct | The splitting method. Valid values: oct (octree), quad (quadtree), bsp (BSP tree). | bsp |
filter_percent | Float | 0.1 | The filtering ratio. Valid values: 0 to 1. At 0.1, objects whose volume is less than 10% of the tile volume are excluded from each non-leaf node tile. | 0.01 |
tileset_prefix | String | — | The prefix of the 3D Tiles tileset endpoint. | http://your_server/foo/bar |
enable_tile_option | Boolean | false | Specifies whether to enable the built-in tile attributes of the sfmesh object. | true |
merge_material | Boolean | true | Specifies whether to merge geometry that shares the same material. Setting this to true may reduce file size. | false |
with_extension | Boolean | false | Specifies whether to add a file extension to B3DM and tileset URIs in the generated tileset file. | true |
vertex_threshold | Float | 0.0001 | The vertex merge threshold. Set to 0 to disable vertex merging. Otherwise, vertices within each tile whose spacing is less than this threshold are merged. | 0.01 |
update_normal | Boolean | false | Specifies whether to recalculate normal data. | true |
divide_factor | Float | 5 | The calculation factor for geometricError. | 10 |
Vertex merging and normal data
Enabling threshold-based vertex merging deletes the original normal data. To preserve correct shading and lighting after merging, set update_normal to true to recalculate normals. Note that:
The visual result may vary depending on the vertex merge threshold.
Recalculating normals for an object that has no normal data increases the generated file size.
geometricError tuning
If geometricError values for non-leaf nodes are too large, reduce them by increasing divide_factor. Doubling divide_factor halves the resulting geometricError.
Generated tables
After the export completes, ST_As3dTiles creates three tables in your database:
[table_name]— the primary table storing tile metadata[table_name]_tile— stores all tile data for the project[table_name]_tileset— stores thetileset.jsondetails for the project
`[table_name]` table structure:
| Field | Type | Description | Remarks |
|---|---|---|---|
project_id | uuid | The project ID. | Auto-generated. |
project_name | text | The project name. | Blank if the project option was not specified. Typically used when the table holds multiple sub-projects. |
srid | integer | — | Left blank. |
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 | — | Left blank. |
aux | text | — | Left blank. |
tiletable | varchar(64) | — | Left blank. |
`[table_name]_tile` table structure:
| Field | Type | Description | Remarks |
|---|---|---|---|
project_id | uuid | The project ID. | Same as in the [table_name] table. |
project_name | text | The project name. | Same as in the [table_name] table. |
uid | uuid | The tile ID. | Auto-generated. |
lod | integer | — | Left blank. |
parent | uuid | — | Left blank. |
children | uuid[] | — | Left blank. |
aux | jsonb | — | Left blank. |
tile | scene | The tile entity. | — |
`[table_name]_tileset` table structure:
| Field | Type | Description | Remarks |
|---|---|---|---|
project_id | uuid | The project ID. | Same as in the [table_name] table. |
project_name | text | The project name. | Same as in the [table_name] table. |
uid | uuid | The ID of tileset.json. | For the root node, this value equals project_id. |
tileset | jsonb | The entity of tileset.json. | — |
Examples
Basic export:
SELECT ST_As3dTiles(sfmesh_obj, 'test_table')
FROM t_sfmesh
WHERE id = 1;
---------
tExport with parallelism:
SELECT ST_As3dTiles(sfmesh_obj, 'test_table', '{"parallel": 2}')
FROM t_sfmesh
WHERE id = 1;
---------
tExport with multiple options:
SELECT ST_As3dTiles(sfmesh_obj, 'test_table', '{"project":"test_proj", "method":"oct", "size_threshold":20}')
FROM t_sfmesh
WHERE id = 1;
---------
t