ST_SceneFromGLTF

更新时间:
复制 MD 格式

Constructs a scene object from a GL Transmission Format (glTF) string.

Syntax

scene ST_SceneFromGltf(cstring gltf,
                       integer srid default 0,
                       integer lod default 0);

scene ST_SceneFromGltf(cstring gltf,
                       integer srid,
                       integer lod,
                       float8[] affine);

Parameters

ParameterDescription
gltfThe glTF string to construct the scene object from.
sridThe spatial reference identifier (SRID). Default value: 0.
lodThe LOD level. Default value: 0.
affineAn array of affine transformation values. Must contain 12 or 16 elements. If 16 elements are provided, the last 4 are ignored.

Description

ST_SceneFromGltf constructs a scene object from the input glTF string. Optionally, you can assign a spatial reference, set a level of detail, and apply an affine transformation to the scene coordinates.

When an affine array is provided, the function applies the following 3×4 transformation matrix to each coordinate:

/ p[1]   p[2]   p[3]    p[4] \
| p[5]   p[6]   p[7]    p[8]  |
\ p[9]   p[10]  p[11]   p[12] /

Each coordinate (x, y, z) is transformed to (x', y', z') as follows:

x' = p[1]*x + p[2]*y + p[3]*z + p[4]
y' = p[5]*x + p[6]*y + p[7]*z + p[8]
z' = p[9]*x + p[10]*y + p[11]*z + p[12]

Examples

Example 1: Construct a scene from a glTF string with default SRID and LOD.

SELECT ST_AsText(ST_sceneFromGLTF('{"accessors": ... }'));

Output:

{"type" : "gltf", "content" : {"accessors":...}}

Example 2: Construct a scene and assign SRID 4326 (WGS 84).

SELECT ST_AsText(ST_sceneFromGLTF('{"accessors": ... }', 4326));

Output:

{"type" : "gltf", "srid" : 4326, "content" : {"accessors":...}}

Example 3: Construct a scene with SRID 4326 and LOD level 1.

SELECT ST_AsText(ST_sceneFromGLTF('{"accessors": ... }', 4326, 1));

Output:

{"type" : "gltf", "srid" : 4326, "lod" : 1, "content" : {"accessors":...}}

Example 4: Construct a scene with SRID 4326, LOD level 1, and a 12-element affine transformation array that applies uniform scaling of 0.5 with translation of 1 on each axis.

SELECT ST_AsText(ST_sceneFromGLTF('{"accessors": ... }', 4326, 1,ARRAY[0.5, 0, 0, 1, 0, 0.5, 0, 1, 0, 0, 0.5, 1]::float8[]));

Output:

{"type" : "gltf", "srid" : 4326, "lod" : 1, "affine" : [0.5,0,0,1,0,0.5,0,1,0,0,0.5,1,0,0,0,1], "content" : {"accessors":...}}