All Products
Search
Document Center

PolarDB:ST_ImportGLTF

Last Updated:Mar 28, 2026

Imports a GL Transmission Format (glTF) file of the sfmesh type into a database.

Syntax

-- Import from object storage
boolean ST_ImportGLTF(text table_name, text url, text id, text options default '{}');

-- Import from binary content
boolean ST_ImportGLTF(text table_name, bytea content, text id, text options default '{}');

Parameters

ParameterTypeRequiredDescription
table_nametextYesThe name of the glTF primary table. Also used as the prefix for any sharded tables generated during import.
urltextYes (Syntax 1)The path to the glTF file in an object storage service such as an Object Storage Service (OSS) bucket. For path format details, see Object storage paths.
contentbyteaYes (Syntax 2)The binary content of the glTF file. Use this parameter instead of url to import directly from memory.
idtextYesA unique identifier for the glTF file being imported. When importing multiple models into the same table, each model must have a distinct ID.
optionstextNoA JSON string of import options. Defaults to '{}'. See Options for details.

Options

All fields are optional. Pass them as a JSON string.

FieldTypeDefaultDescription
schemaStringpublicThe schema of the target table.
flip_y_zBooleantrueSpecifies whether to swap values on the y-axis and z-axis. glTF uses a y-up coordinate system by default, while GanosBase uses z-up. Set this to false only if your data is already in z-up orientation.
split_meshgeomBooleanfalseSpecifies whether to split geometry data into a separate table named [table_name]_meshgeom. Enable this when individual records contain large numbers of complex geometries to prevent records from becoming too large. The primary table references the geometry table after the split.
split_textureBooleanfalseSpecifies whether to split embedded image textures into a separate table named [table_name]_texture. Enable this for data with many embedded textures, such as oblique photographs. The primary table references the texture table after the split. Has no effect when textures are stored as URLs or when the glTF file contains no embedded image textures.
sfmesh_columnStringgltf_dataThe name of the sfmesh data column in the primary table.
gltf_id_columnStringgltf_idThe name of the ID column in the primary table.

Limitations

The following limitations apply. Imports that do not meet these requirements fail.

  • Only sfmesh data is imported. Camera, skeleton, and animation data is ignored.

  • Only meshes generated with the triangulation method are supported.

  • Draco-compressed data is not supported.

  • Only the fully embedded mode is supported. Binary plug-ins and texture plug-ins are not supported.

Generated tables

A successful import creates the following tables in the database.

Primary table

FieldTypeDescription
idserialAuto-generated unique ID. Primary key.
[gltf_id_column]textThe glTF file ID. Configurable via gltf_id_column; defaults to gltf_id.
[sfmesh_column]sfmeshThe 3D mesh data. Configurable via sfmesh_column; defaults to gltf_data.

Only the [gltf_id_column] and [sfmesh_column] fields are writable. All other fields in the primary table are populated automatically.

Texture table ([table_name]_texture)

Created only when split_texture is true and the glTF file contains embedded image textures.

FieldTypeDescription
idserialAuto-generated unique ID. Primary key.
gltf_idtextThe glTF file ID. Must be set to gltf_id.
texture_idtextThe index of the texture in the original glTF file.
texturetextureThe texture data.

Geometry table ([table_name]_meshgeom)

Created only when split_meshgeom is true and the glTF file contains geometry data.

FieldTypeDescription
idserialAuto-generated unique ID. Primary key.
gltf_idtextThe glTF file ID. Must be set to gltf_id.
meshgeom_idtextThe index of the mesh in the original glTF file.
meshgeommeshgeomThe geometry data.
Geometry tables and texture tables can be split simultaneously without interfering with each other. If you import multiple models into the same table, use a different id for each model. Duplicate IDs produce duplicate geometry records.

Examples

Import a glTF file from OSS

SELECT ST_ImportGLTF(
  'test_gltf',
  'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/path_to_gltf.gltf',
  'my_gltf'
);

Returns t on success.

Import with texture and geometry splitting

For oblique photographs or models with many textures and complex geometries, split the data into separate tables to keep individual records from growing too large.

SELECT ST_ImportGLTF(
  'building_model',
  'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/building.gltf',
  'building_001',
  '{"split_texture": true, "split_meshgeom": true, "flip_y_z": false}'
);

This creates three tables: building_model (primary), building_model_texture, and building_model_meshgeom.