Skip to content

Commit 67dc185

Browse files
Update scene schemas (#12)
Co-authored-by: imodeljs-admin <[email protected]>
1 parent e4abf12 commit 67dc185

2 files changed

Lines changed: 161 additions & 5 deletions

File tree

docs/schemas/CommonTypes.json

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,47 @@
1717
"pattern": "^[a-zA-Z0-9 ?!@+-.:=_/]*$",
1818
"description": "String containing only web safe characters"
1919
},
20+
"expressionString": {
21+
"type": "string",
22+
"isJsep": true,
23+
"description": "A JavaScript (JSEP) expression for frontend rendering that excludes potentially dangerous constructs. It's up to the frontend to validate and execute this expression safely."
24+
},
25+
"expressionOrConditions": {
26+
"description": "Expression that determines styling conditions or a single expression.",
27+
"oneOf": [
28+
{
29+
"$ref": "/schemas/CommonTypes#/definitions/expressionString",
30+
"description": "Single expression string"
31+
},
32+
{
33+
"type": "object",
34+
"additionalProperties": false,
35+
"required": [ "conditions" ],
36+
"properties": {
37+
"conditions": {
38+
"type": "array",
39+
"description": "Array of condition-value pairs for determining styling",
40+
"minItems": 1,
41+
"items": {
42+
"type": "array",
43+
"minItems": 2,
44+
"maxItems": 2,
45+
"items": [
46+
{
47+
"$ref": "/schemas/CommonTypes#/definitions/expressionString",
48+
"description": "Condition expression that evaluates to a boolean"
49+
},
50+
{
51+
"$ref": "/schemas/CommonTypes#/definitions/expressionString",
52+
"description": "Expression that returns a value when the condition is true"
53+
}
54+
]
55+
}
56+
}
57+
}
58+
}
59+
]
60+
},
2061
"dateTime": {
2162
"type": "string",
2263
"pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{3})?Z$",
@@ -49,7 +90,7 @@
4990
"description": "Z coordinate"
5091
}
5192
},
52-
"required": ["x", "y", "z"]
93+
"required": [ "x", "y", "z" ]
5394
},
5495
"transform": {
5596
"type": "array",
@@ -82,7 +123,7 @@
82123
"description": "Used by iTwin.Js. Interior planes should not generate edges when clipping geometry in the view."
83124
}
84125
},
85-
"required": []
126+
"required": [ ]
86127
},
87128
"clipPlaneSet": {
88129
"description": "Collection of ClipPlanes, often used for bounding regions of space.",
@@ -97,7 +138,7 @@
97138
}
98139
}
99140
},
100-
"required": ["planes"]
141+
"required": [ "planes" ]
101142
},
102143
"colorDef": {
103144
"description": "An unsigned 32-bit integer in 0xTTBBGGRR format.",
@@ -129,7 +170,7 @@
129170
"description": "Blue component of the color"
130171
}
131172
},
132-
"required": ["r", "g", "b"]
173+
"required": [ "r", "g", "b" ]
133174
},
134175
"linePixels": {
135176
"enum": [
@@ -163,7 +204,7 @@
163204
"description": "If defined and non-zero, the width of the edges in pixels. If undefined (or 0), edges are drawn using the element's line width.\n Non-integer values are truncated, and values are clamped to the range [1, 32]."
164205
}
165206
},
166-
"required": []
207+
"required": [ ]
167208
}
168209
}
169210
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
{
2+
"$id": "/schemas/FeatureStyling.1.0.0",
3+
"description": "Defines styling options for features.",
4+
"type": "object",
5+
"additionalProperties": false,
6+
"properties": {
7+
"stylingOptions": {
8+
"description": "Styling options for features.",
9+
"oneOf": [
10+
{
11+
"type": "object",
12+
"additionalProperties": false,
13+
"required": [ "styleType", "color" ],
14+
"properties": {
15+
"styleType": {
16+
"enum": [ "Expression" ],
17+
"description": "Specifies the type of styling: 'Expression' or 'Category'. This is used to differentiate between different styling methods."
18+
},
19+
"defines": {
20+
"type": "object",
21+
"description": "Named expressions that can be reused within other expressions",
22+
"additionalProperties": false,
23+
"patternProperties": {
24+
"^[a-zA-Z0-9 ?!@+-.:=_/]*$": {
25+
"$ref": "/schemas/CommonTypes#/definitions/expressionString",
26+
"description": "Expression string that can define conditions or calculations for styling"
27+
}
28+
}
29+
},
30+
"show": {
31+
"$ref": "/schemas/CommonTypes#/definitions/expressionOrConditions",
32+
"description": "Expression or conditions that determines if the feature is visible"
33+
},
34+
"color": {
35+
"description": "Expression or conditions that determine the feature's color, can also be a set of conditions",
36+
"$ref": "/schemas/CommonTypes#/definitions/expressionOrConditions"
37+
},
38+
"lineWeight": {
39+
"$ref": "/schemas/CommonTypes#/definitions/expressionString",
40+
"description": "Expression that determines the feature's line weight/thickness"
41+
},
42+
"lineColor": {
43+
"$ref": "/schemas/CommonTypes#/definitions/expressionOrConditions",
44+
"description": "Color definition for the feature's lines"
45+
}
46+
}
47+
},
48+
{
49+
"type": "object",
50+
"additionalProperties": false,
51+
"required": [ "styleType", "rules" ],
52+
"properties": {
53+
"styleType": {
54+
"enum": [ "Category" ],
55+
"description": "Specifies the type of styling: 'Expression' or 'Category'. This is used to differentiate between different styling methods."
56+
},
57+
"rules": {
58+
"type": "array",
59+
"description": "Array of Attribute rules",
60+
"items": {
61+
"type": "object",
62+
"additionalProperties": false,
63+
"required": [ "name", "value", "symbology" ],
64+
"properties": {
65+
"name": {
66+
"$ref": "/schemas/CommonTypes#/definitions/safeString",
67+
"description": "Name of the attribute to match"
68+
},
69+
"value": {
70+
"description": "Value of the attribute to match",
71+
"oneOf": [
72+
{
73+
"$ref": "/schemas/CommonTypes#/definitions/expressionString"
74+
},
75+
{
76+
"type": "number"
77+
},
78+
{
79+
"type": "boolean"
80+
}
81+
]
82+
},
83+
"symbology": {
84+
"type": "object",
85+
"description": "Symbology settings to apply when the rule matches",
86+
"additionalProperties": false,
87+
"required": [ "lineColor", "fillColor", "weight" ],
88+
"properties": {
89+
"lineColor": {
90+
"$ref": "/schemas/CommonTypes#/definitions/colorDef",
91+
"description": "Color of the feature's lines"
92+
},
93+
"fillColor": {
94+
"$ref": "/schemas/CommonTypes#/definitions/colorDef",
95+
"description": "Fill color of the feature"
96+
},
97+
"weight": {
98+
"type": "number",
99+
"description": "Thickness of the feature's lines"
100+
},
101+
"linePixels": {
102+
"$ref": "/schemas/CommonTypes#/definitions/linePixels",
103+
"description": "Line pattern for the feature's lines"
104+
}
105+
}
106+
}
107+
}
108+
}
109+
}
110+
}
111+
}
112+
]
113+
}
114+
}
115+
}

0 commit comments

Comments
 (0)