Returns a texture[] array containing all textures in an sfmesh or material object.
Syntax
texture[] ST_Textures(sfmesh sfmeshObject);
texture[] ST_Textures(material material);Parameters
| Parameter | Description |
|---|---|
sfmeshObject | The sfmesh object. |
material | The material object. |
Description
ST_Textures returns all textures embedded in an sfmesh or material object as a texture[] array.
Array indexing is 1-based. To access the first texture, use (ST_Textures(...))[1].Examples
Return all textures from an sfmesh object
SELECT ST_Textures(
'{
"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"}}],
"textures": [{
"compressionType": "None",
"format": "JPEG",
"wrap": "Wrap",
"type": "DB",
"depth": 3,
"width": 256,
"height": 256,
"name": "texture_name3",
"size": 72,
"data": {"schema": "public", "table": "test", "column": "the_texture", "key": "num=1"}
}],
"primitives": [{"meshgeom": 0, "material": 0}],
"nodes": [{"primitive": 0}]
}'::sfmesh
);Result:
{01010001010303000100000001000005000000123456FFFF}Access a texture by index
Use array subscript notation to retrieve a specific texture from the result.
-- Array indices are 1-based
SELECT (ST_Textures(
'{
"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"}}],
"textures": [{
"compressionType": "None",
"format": "JPEG",
"wrap": "Wrap",
"type": "DB",
"depth": 3,
"width": 256,
"height": 256,
"name": "texture_name3",
"size": 72,
"data": {"schema": "public", "table": "test", "column": "the_texture", "key": "num=1"}
}],
"primitives": [{"meshgeom": 0, "material": 0}],
"nodes": [{"primitive": 0}]
}'::sfmesh
))[1];Result:
01010001010303000100000001000005000000123456FFFF该文章对您有帮助吗?