From 13c1d7941a2b7d84288d516fc9411fabd0c17770 Mon Sep 17 00:00:00 2001 From: Jeremie Allard Date: Wed, 29 Nov 2017 18:51:21 +0100 Subject: [PATCH] Add proposed additions in KHR_draco_mesh_compression to support morph targets --- .../KHR_draco_mesh_compression/README.md | 34 ++++++++++++++++--- ...ode.KHR_draco_mesh_compression.schema.json | 13 +++++++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/extensions/Khronos/KHR_draco_mesh_compression/README.md b/extensions/Khronos/KHR_draco_mesh_compression/README.md index 4556a5d971..10e533be11 100644 --- a/extensions/Khronos/KHR_draco_mesh_compression/README.md +++ b/extensions/Khronos/KHR_draco_mesh_compression/README.md @@ -7,6 +7,7 @@ * Frank Galligan, Google, * Kai Ninomiya, Google, * Patrick Cozzi, Cesium, [@pjcozzi](https://twitter.com/pjcozzi) +* Jeremie Allard, InSimo, [@JeremieA](https://twitter.com/JeremieAllard) Copyright (C) 2013-2017 The Khronos Group Inc. All Rights Reserved. glTF is a trademark of The Khronos Group Inc. See [Appendix](#appendix-full-khronos-copyright-statement) for full Khronos Copyright Statement. @@ -67,8 +68,18 @@ Below is an example of what a part of a glTF file my look like if the Draco exte "WEIGHTS_0" : 14, "JOINTS_0" : 15, }, + "targets" : [ + { + "POSITION" : 16, + "NORMAL" : 17 + }, + { + "POSITION" : 18, + "NORMAL" : 19 + } + ], "indices" : 10, - "mode" : 4 + "mode" : 4, "extensions" : { "KHR_draco_mesh_compression" : { "bufferView" : 5, @@ -79,9 +90,19 @@ Below is an example of what a part of a glTF file my look like if the Draco exte "WEIGHTS_0" : 3, "JOINTS_0" : 4 }, + "targets" : [ + { + "POSITION" : 5, + "NORMAL" : 6 + }, + { + "POSITION" : 7, + "NORMAL" : 8 + } + ] } } - }, + } ] } @@ -103,6 +124,11 @@ The `bufferView` property points to the buffer containing compressed data. The d ### attributes `attributes` defines the attributes stored in the decompressed geometry. E.g, in the example above, `POSITION`, `NORMAL`, `TEXCOORD_0`, `WEIGHTS_0` and `JOINTS_0`. Each attribute is associated with an attribute id which is its unique id in the compressed data. The `attributes` defined in the extension must be a subset of the attributes of the primitive. To request an attribute, loaders must be able to use the correspondent attribute id specified in the `attributes` to get the attribute from the compressed data. +### targets +For mesh primitives defining Morph Targets, `targets` defines the Morph Targets attributes stored in the decompressed geometry. E.g, in the example above, `POSITION` and `NORMAL` for two morph targets. If present in this extension, `targets` must be an array with the same number of items as the targets array within the primitive. +Within each target array item, each attribute is associated with an attribute id which is its unique id in the compressed data. The `targets` attributes defined in the extension must be a subset of the targets attributes of the primitive. To request an target attribute, loaders must be able to use the correspondent target index and attribute id specified in the `targets` to get the attribute from the compressed data. +Note that it is allowed for an item within `targets` of this extension to be empty, indicating that there is no attribute stored in the compressed data for the corresponding Morph Target. + #### Restrictions on geometry type When using this extension, the `mode` of `primitive` must be either `TRIANGLES` or `TRIANGLE_STRIP` and the mesh data will be decoded accordingly. @@ -121,8 +147,8 @@ Below is the recommended process when a loader encounters a glTF asset with the * If the loader does support the Draco extension, but will not process `KHR_draco_mesh_compression`, then the loader must load the glTF asset ignoring `KHR_draco_mesh_compression` in `primitive`. * If the loader does support the Draco extension, and will process `KHR_draco_mesh_compression` then: * The loader must process `KHR_draco_mesh_compression` first. The loader must get the data from `KHR_draco_mesh_compression`'s `bufferView` property and decompress the data using a Draco decoder to a Draco geometry. - * Then the loader must process `attributes` and `indices` properties of the `primitive`. When loading each `accessor`, you must ignore the `bufferView` and go to the previously decoded Draco geometry in the `primitive` to get the data of indices and attributes. A loader must use the decompressed data to fill the `accessors` or render the decompressed Draco geometry directly (e.g. [ThreeJS (non-normative)](https://github.com/mrdoob/three.js/blob/dev/examples/js/loaders/draco/DRACOLoader.js)). - * If additional attributes are defined in `primitive`'s `attributes`, but not defined in `KHR_draco_mesh_compression`'s `attributes`, then the loader must process the additional attributes as usual. + * Then the loader must process `attributes`, `targets` (if present), and `indices` properties of the `primitive`. When loading each `accessor`, you must ignore the `bufferView` and go to the previously decoded Draco geometry in the `primitive` to get the data of indices and attributes. A loader must use the decompressed data to fill the `accessors` or render the decompressed Draco geometry directly (e.g. [ThreeJS (non-normative)](https://github.com/mrdoob/three.js/blob/dev/examples/js/loaders/draco/DRACOLoader.js)). + * If additional attributes are defined in `primitive`'s `attributes` or within an item in `targets` (if present), but not defined in `KHR_draco_mesh_compression`'s `attributes` or corresponding `targets` item, then the loader must process the additional attributes as usual. ## Implementation note diff --git a/extensions/Khronos/KHR_draco_mesh_compression/schema/node.KHR_draco_mesh_compression.schema.json b/extensions/Khronos/KHR_draco_mesh_compression/schema/node.KHR_draco_mesh_compression.schema.json index 3fb581a43c..cb080f4700 100644 --- a/extensions/Khronos/KHR_draco_mesh_compression/schema/node.KHR_draco_mesh_compression.schema.json +++ b/extensions/Khronos/KHR_draco_mesh_compression/schema/node.KHR_draco_mesh_compression.schema.json @@ -14,6 +14,19 @@ "$ref": "glTFid.schema.json" }, "description": "A dictionary object, where each key corresponds to an attribute and its unique attribute id stored in the compressed geometry." + }, + "targets": { + "type": "array", + "description": "An array of compressed Morph Targets, each compressed Morph Target is a dictionary mapping attributes (only `POSITION`, `NORMAL`, and `TANGENT` supported) to their deviations in the Morph Target.", + "items": { + "type": "object", + "minProperties": 0, + "additionalProperties": { + "$ref": "glTFid.schema.json" + }, + "description": "A dictionary object, where each key corresponds to an attribute and its unique attribute id stored in the compressed geometry." + }, + "minItems": 1 } }, "additionalProperties": false,