OverviewFilesCommitsIssuesDocsReleasesPeers

gltf-extensions commits / 8c5d0e9

Remove defaults, use required fields based on type, add isTrigger to collider
8c5d0e9465791826fac33c7a1e560e06a827db81
by mauve <ranger@mauve.moe> · 2022-03-04T00:00:33.000Z

Changed files (1) +103 -33

extensions/2.0/OMI_collider/README.md +103 -33
……@@ -21,7 +21,8 @@ This extension allows for the addition of colliders to gLTF scenes.
2121
2222Colliders can be added to GLTF nodes along with information about the "type" of collider it is representing.
2323
24This extension does not perscribe what Colliders should do within a scene.
24This extension does not perscribe what Colliders should do within a scene, but engines may choose to treat colliders as Static physics bodies by default.
25For a more thorough physics body specification, implement the `OMI_physics_body` extension.
2526
2627### Example:
2728
……@@ -69,6 +70,10 @@ The extension must also be added to the glTF's `extensionsUsed` array and becaus
6970}
7071```
7172
73### `isTrigger`
74
75Specifying `isTrigger: true` in the collider hints to engines that this collider should not be used for physics interactions and should exist as a "trigger volume" which emits events when an entity intersects with it.
76By default an engine may assume that the collider is a static (or rigid) physics body.
7277
7378### Collider Types
7479
……@@ -89,6 +94,7 @@ Here is a table of what the shapes can be represented with in different game eng
8994| Mesh | Mesh | ConcavePolygonShape | Mesh | Mesh |
9095| Compound | Compound | Add mutiple colliders | ??? | ??? |
9196
97
9298#### Box
9399
94100This represents a "box" shape which can either be a cube or an arbitrary rectangular prism. You can specify an `extents` property which is an array that contains the `[x, y, z]` sizes.
……@@ -131,47 +137,111 @@ A `Node` set to be a `compund` collider will use any direct child nodes with the
131137### JSON Schema
132138```json=
133139{
134 "$schema": "http://json-schema.org/draft-04/schema",
135 "title": "Collider",
136 "type": "object",
137 "required": ["type"]
138 "properties": {
140 "$schema": "http://json-schema.org/draft-04/schema",
141 "title": "Collider",
142 "type": "object",
143 "required": [
144 "type"
145 ],
146 "properties": {
147 "type": {
148 "type": "string",
149 "description": "The type of collider this node represents",
150 "enum": [
151 "box",
152 "sphere",
153 "capsule",
154 "hull",
155 "mesh",
156 "compound"
157 ]
158 },
159 "isTrigger": {
160 "type": "boolean",
161 "description": "When true this collider will not collide with physics bodies in the scene",
162 "default": false
163 }
164 },
165 "oneOf": [
166 {
167 "properties": {
168 "required": [
169 "type",
170 "extents"
171 ],
139172 "type": {
140 "type": "string",
141 "description": "The type of collider this node represents",
142 "enum": [
143 "box",
144 "sphere",
145 "capsule",
146 "hull",
147 "mesh",
148 "compound"
149 ]
150 },
151 "radius": {
152 "type": "number",
153 "description": "The radius to use for the collision shape. Applies to sphere/capsule",
154 "default": 0.5
173 "const": "box"
155174 },
156175 "extents": {
157 "type": "array",
158 "description": "half-extents for a Box (x, y, z).",
159 "default": [0.5, 0.5, 0.5]
176 "type": "array",
177 "description": "half-extents for a Box (x, y, z)."
178 }
179 }
180 },
181 {
182 "properties": {
183 "required": [
184 "type",
185 "radius",
186 "height"
187 ],
188 "type": {
189 "const": "sphere"
190 },
191 "radius": {
192 "type": "number",
193 "description": "The radius to use for the collision shape. Applies to sphere/capsule"
160194 },
161195 "height": {
162 "type": "number",
163 "description": "The height of the capsule shape.",
164 "default": 1
196 "type": "number",
197 "description": "The height of the capsule shape."
198 }
199 }
200 },
201 {
202 "properties": {
203 "required": [
204 "type",
205 "mesh"
206 ],
207 "type": {
208 "const": "capsule"
209 }
210 }
211 },
212 {
213 "properties": {
214 "required": [
215 "type",
216 "mesh"
217 ],
218 "type": {
219 "enum": [
220 "mesh",
221 "hull"
222 ]
165223 },
166224 "mesh": {
167 "description": "A reference to the mesh from the `meshes` array to use for either the Hull or Mesh shapes. The mesh MUST be a trimesh. Make sure your mesh is actually a convex hull if you use Hull, and try to avoid a full Mesh since they are very slow.",
168 "allOf": [
169 {
170 "$ref": "glTFid.schema.json"
171 }
172 ]
225 "description": "A reference to the mesh from the `meshes` array to use for either the Hull or Mesh shapes. The mesh MUST be a trimesh. Make sure your mesh is actually a convex hull if you use Hull, and try to avoid a full Mesh since they are very slow.",
226 "allOf": [
227 {
228 "$ref": "glTFid.schema.json"
229 }
230 ]
231 }
232 }
233 },
234 {
235 "properties": {
236 "required": [
237 "type"
238 ],
239 "type": {
240 "const": "compound"
173241 }
242 }
174243 }
244 ]
175245}
176246```
177247