Simplifies a 3D model in a scene object based on a JSON rule set.
Syntax
scene ST_Simplify(scene sc, cstring rules);Parameters
| Parameter | Description |
|---|---|
sc | The scene object to simplify. |
rules | The simplification rule, in JSON format. See Rule fields for the full specification. |
Rule fields
Pass the rules parameter as a JSON object with the following fields:
{
"mothed": "percent",
"threshold": 0.5,
"blacklist": ["wall", "glass"],
"boundary": true,
"meshes": [
{"names": ["m0", "m1"], "threshold": 0.5},
{"names": ["m2", "m3"], "threshold": 0.001}
]
}| Field | Description |
|---|---|
mothed | The simplification method. Valid values: percent, error. Default value: percent. |
threshold | The simplification threshold. The valid range depends on the mothed value. Default value: 0.5. |
blacklist | The names of mesh objects to exclude from simplification. Mesh objects in this list are not simplified. |
boundary | Specifies whether to simplify the boundary of the model. Default value: true. |
meshes[].names | Groups mesh objects by name for independent simplification. |
meshes[].threshold | The simplification threshold for the mesh group. |
Simplification methods
percent — reduces the number of triangles to a percentage of the original count.
Valid values:
(0, 1)(exclusive)A value of
0.1retains 10% of the original triangles. Lower values produce more aggressive simplification.
error — controls simplification by the geometric error of the result, measured as the distance from the new vertex to the original vertex.
Valid values:
(0, +inf)(exclusive)Higher values produce more aggressive simplification.
Boundary simplification
Simplifying boundaries ("boundary": true) may cause the model to collapse or break. Disable boundary simplification for models where edge integrity is critical.
Per-mesh group thresholds
Use the meshes field to apply different thresholds to different parts of a model. For example, apply a higher threshold (less simplification) to high-precision meshes and a lower threshold (more simplification) to low-precision meshes.
Usage notes
Model simplification reduces storage size without affecting the visual appearance in rendering. The table below shows the effect on a sample model:
| Simplification setting | Storage size | Result |
|---|---|---|
| 100% (no simplification) | 96 MB | ![]() |
| 5% geometry + 25% image | 2.9 MB | ![]() |
Example
The following example simplifies a scene stored in table t. The global threshold is 10% (retaining 10% of triangles). Three meshes are excluded from simplification via the blocklist. Two mesh groups use independent thresholds.
SELECT ST_Simplify(data,
'{
"threshold": 0.1,
"mothed": "percent",
"blacklist":["Mesh.012", "Mesh.009", "Mesh.005"],
"meshes": [
{"names":["Mesh.007"], "threshold": 0.01},
{"names":["Mesh.004"], "threshold": 0.3}
]}') from t;
---------------------------
0x.....
