All Products
Search
Document Center

:ST_ImportGLTF

Last Updated:Jun 28, 2023

This topic describes the ST_ImportGLTF function. This function imports a GL Transmission Format (glTF) file into a database.

Syntax

  • Syntax 1

    boolean ST_ImportGLTF(text table_name, text url,  text id, text options default '{}');
  • Syntax 2

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

Parameters

Parameter

Description

table_name

The name of the glTF table and the prefix of the sharded tables of the glTF table.

url

If the gIFC file is stored in an object storage service, such as an Object Storage Service (OSS) bucket, use this parameter. For more information, see Object storage paths.

id

The ID of the gIFC file.

content

If you want to import the gIFC file by using its binary representation, use this parameter. Alternatively, you can use the url parameter.

options

The options for the import. Valid values:

  • schema

  • flip_y_z

  • split_meshgeom

  • split_texture

  • sfmesh_column

  • gltf_id_column

The following table describes the fields of the options parameter.

Field

Type

Description

Default value

Example value

schema

String

The schema of the required table.

public

postgres

flip_y_z

Boolean

Specifies whether to exchange values on the y-axis and z-axis.

Note

By default, the y-axis of glTF is vertical while the z-axis is vertical in Ganos. If you set this parameter to true, take note of the following points:

  • Values on the y-axis and z-axis are exchanged.

  • You can exchange values on the y-axis and z-axis only when glTF files are stored and the y-axis is vertical.

true

false

split_meshgeom

Boolean

Specifies whether to divide geometry data.

Note

If you want to divide geometry data, take note of the following items:

  • If geometry data exists, the geometry table named [Primary table name]_meshgeom is generated. The texture geometry in the primary table points to the corresponding data in the referenced table after referencing is complete. This facilitates the division of the data records that have a large number of complex geometries and prevents excessive size of a single record.

  • If you want to import multiple models into one table, make sure that the IDs of the imported models are different. If duplicate IDs exist, duplicate geometries are generated.

  • Geometry tables and texture tables can be divided at the same time without interfering with each other.

false

true

split_texture

Boolean

Specifies whether to divide texture data.

Note

If you want to divide texture data, take note of the following items:

  • If an embedded image texture exists, the texture table named[Primary table name]_texture is generated. The texture data in the primary table points to the corresponding data in the referenced table after referencing is complete. This facilitates the division of data records that have a large number of textures and prevents excessive size of a single record. For example, oblique photographs can be divided in an efficient manner.

  • If you want to divide texture data but the texture data is in the URL format, the reference mode is unavailable.

  • If you want to divide texture data but the data does not contain any embedded image textures, no texture table is generated.

  • If you want to import multiple models into one table, make sure that the IDs of the imported models are different. If duplicate IDs exist, duplicate geometries are generated.

  • Geometry tables and texture tables can be divided at the same time without interfering with each other.

false

true

sfmesh_column

String

The data field of the primary table.

gltf_data

my_data

gltf_id_column

String

The data ID field of the primary table.

gltf_id

my_id

Description

This function imports a glTF file of the sfmesh type into a database.

Note
  • The function can be called to import a glTF file that is stored in an object storage service, such as an OSS bucket, into a database.

  • The function can be called to read the binary data of a glTF file to the memory and then import the data into a database.

The following lists describe the data limits:

  • Only data of the sfmesh type is supported. Data that is captured by cameras and obtained from skeletons and animations is ignored.

  • Only data that is obtained by using the triangulation method is supported.

  • Data that is compressed by Draco is not supported.

  • Only the fully embedded mode is supported. Binary plug-ins or texture plug-ins are not supported. If the preceding limits are not met, failures occur.

After the import is successful, the following tables are generated in the database:

glTF primary table

You can import data into your business tables by specifying the data field and the primary key field of the primary table. Make sure that only the data field and the primary key field can be inserted into the primary table and the other required fields in the primary table are automatically configured.

The following table describes the schema of the primary table.

Field

Type

Description

Remarks

id

serial

The unique ID.

Primary key

[gltf_id_column]

text

The data ID.

You can specify this field.

Default value: gltf_id.

[sfmesh_column]

sfmesh

The data.

You can specify this field.

Default value: gltf_data.

glTF texture table

The following table describes the schema of the texture table.

Field

Type

Description

Remarks

id

serial

The unique ID.

The primary key of the table.

gltf_id

text

The data ID.

You must set this field to gltf_id.

texture_id

text

The ID of the texture.

The value of this field is the index of the texture in the original glTF file.

texture

texture

The data.

-

glTF geometry table

The following table describes the schema of the geometry table.

Field

Type

Description

Remarks

id

serial

The unique ID.

The primary key of the table.

gltf_id

text

The data ID.

You must set this field to gltf_id.

meshgeom_id

text

The geometry ID.

The value of this field is the index of the mesh in the original glTF file.

meshgeom

meshgeom

The data.

-

Examples

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

---------
t