ST_MaterialN

更新时间:
复制 MD 格式

Returns the Nth material from an sfmesh object by zero-based index.

Syntax

material ST_MaterialN(sfmesh sfmeshObject, int4 index)

Parameters

ParameterDescription
sfmeshObjectThe sfmesh object to query.
indexThe zero-based index of the material to retrieve. The first material is at index 0.

Usage notes

  • The index parameter is zero-based: the first material is at index 0, not 1.

Example

Retrieve the first material (index 0) from an sfmesh object that references a material stored in a database table:

SELECT ST_MaterialN(
  '{
    "meshgeoms": ["MESHGEOM(PATCH(TRIANGLESTRIP(0 0,0 10,10 10,10 0)))"],
    "materials": [{"type": "db", "attributes": {"schema": "public", "table": "t_material", "column": "the_material", "key": "num=1"}}],
    "primitives": [{"meshgeom": 0, "material": 0}],
    "nodes": [{"primitive": 0}]
  }'::sfmesh,
  0
);

Output:

010102FFDDEEAA