| … | … | @@ -21,7 +21,8 @@ This extension allows for the addition of colliders to gLTF scenes. |
| 21 | 21 | |
| 22 | 22 | Colliders can be added to GLTF nodes along with information about the "type" of collider it is representing. |
| 23 | 23 | |
| 24 | | This extension does not perscribe what Colliders should do within a scene. |
| 24 | This extension does not perscribe what Colliders should do within a scene, but engines may choose to treat colliders as Static physics bodies by default. |
| 25 | For a more thorough physics body specification, implement the `OMI_physics_body` extension. |
| 25 | 26 | |
| 26 | 27 | ### Example: |
| 27 | 28 | |
| … | … | @@ -69,6 +70,10 @@ The extension must also be added to the glTF's `extensionsUsed` array and becaus |
| 69 | 70 | } |
| 70 | 71 | ``` |
| 71 | 72 | |
| 73 | ### `isTrigger` |
| 74 | |
| 75 | Specifying `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. |
| 76 | By default an engine may assume that the collider is a static (or rigid) physics body. |
| 72 | 77 | |
| 73 | 78 | ### Collider Types |
| 74 | 79 | |
| … | … | @@ -89,6 +94,7 @@ Here is a table of what the shapes can be represented with in different game eng |
| 89 | 94 | | Mesh | Mesh | ConcavePolygonShape | Mesh | Mesh | |
| 90 | 95 | | Compound | Compound | Add mutiple colliders | ??? | ??? | |
| 91 | 96 | |
| 97 | |
| 92 | 98 | #### Box |
| 93 | 99 | |
| 94 | 100 | This 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 |
| 131 | 137 | ### JSON Schema |
| 132 | 138 | ```json= |
| 133 | 139 | { |
| 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 | ], |
| 139 | 172 | "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" |
| 155 | 174 | }, |
| 156 | 175 | "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" |
| 160 | 194 | }, |
| 161 | 195 | "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 | ] |
| 165 | 223 | }, |
| 166 | 224 | "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" |
| 173 | 241 | } |
| 242 | } |
| 174 | 243 | } |
| 244 | ] |
| 175 | 245 | } |
| 176 | 246 | ``` |
| 177 | 247 | |