Constructs a material object from its text representation.
Syntax
material ST_MaterialFromText(text text);Parameters
| Parameter | Description |
|---|---|
text | The material object in text representation, as returned by ST_AsText. Example: '{"type":"raw", "attributes": {"ambient":"#ffddeeaa"}}' |
Description
ST_MaterialFromText is the inverse of ST_AsText: it takes the JSON string that ST_AsText produces and reconstructs the original material object. For details on material object structure, see ST_MakeMaterial.
Examples
The following example passes a JSON literal directly to show the expected input format:
SELECT ST_MaterialFromText('{"type":"raw", "attributes": {"ambient":"#ffddeeaa"}}');The following example demonstrates a full round-trip: serialize a material object to text with ST_AsText, then reconstruct it with ST_MaterialFromText:
-- Serialize then deserialize
SELECT ST_AsText(
ST_MaterialFromText(
ST_AsText(ST_MakeMaterial(ambient => '#FFDDEEAA'))
)
);Output:
{"type":"raw", "attributes": {"ambient":"#ffddeeaa"}}See also
ST_AsText — serializes a material object to its text representation
ST_MakeMaterial — constructs a material object from individual attributes
该文章对您有帮助吗?