From c54e52183a8cf77765fd3cc06c1843443a09f0e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Dahlstr=C3=B6m?= Date: Thu, 21 Oct 2021 14:34:14 +0200 Subject: [PATCH 1/3] Initial MAXAR_mesh_variants extension draft --- .../2.0/Vendor/MAXAR_mesh_variants/README.md | 134 ++++++++++++++++++ .../glTF.MAXAR_mesh_variants.schema.json | 51 +++++++ .../node.MAXAR_mesh_variants.schema.json | 63 ++++++++ 3 files changed, 248 insertions(+) create mode 100644 extensions/2.0/Vendor/MAXAR_mesh_variants/README.md create mode 100644 extensions/2.0/Vendor/MAXAR_mesh_variants/schema/glTF.MAXAR_mesh_variants.schema.json create mode 100644 extensions/2.0/Vendor/MAXAR_mesh_variants/schema/node.MAXAR_mesh_variants.schema.json diff --git a/extensions/2.0/Vendor/MAXAR_mesh_variants/README.md b/extensions/2.0/Vendor/MAXAR_mesh_variants/README.md new file mode 100644 index 0000000000..d308c6b10c --- /dev/null +++ b/extensions/2.0/Vendor/MAXAR_mesh_variants/README.md @@ -0,0 +1,134 @@ +# MAXAR_mesh_variants + +## Dependencies + +Written against the glTF 2.0 spec. + +## Overview + +This extension allows for a compact glTF representation of multiple mesh variants of an asset. + +## Variants + +For a glTF asset, a mesh `variant` represents a combination of meshes that are selected for rendering by a set of nodes based on _mappings_. + +All available _variants_ are defined at the glTF root object extension as an array of objects, each with a _name_ property. + +The _default_ property represents the index of the variant that is selected by default. The meshes that are mapped to the default variant must represent the set of meshes initially selected by the nodes for rendering, as per vanilla glTF behavior. + +## Mappings + +For a given node, each entry in the mappings array represents a mesh that should be selected for rendering when one of its variants is active. Each entry in the mappings array is an object that specifies a mesh by its index in the root level `meshes` array and and array of variants, each by their respective indices in the root level `variants` array. + +A variant may only be used once across all the entries in the mappings array. + +When the active variant is referenced in a mapping, a compliant viewer will select its meshes for +rendering. Application-specific logic may allow the activation of different variants per-node, enabling different runtime configurations of the model. + +## Example + +_This section is non-normative._ + +The following example illustrates the representation of a car model with varying states of damage applied to the model. + +| Variants | +| ---------------------- | +| `Pristine` - _default_ | +| `Damaged` | +| `Destroyed` | + +At the root level, this will be described as follows: + +```javascript +{ + "asset": {"version": "2.0"}, + "extensions": { + "MAXAR_mesh_variants": { + "default": 0, + "variants": [ + {"name": "Pristine" }, + {"name": "Damaged" }, + {"name": "Destroyed" }, + ] + } + } +} +``` + +For the purposes of illustration, let's consider that the model consists of 3 nodes - body, wheels and lights. + +```javascript +"nodes": [ + { + "name": "Car Body", + "mesh": 0, + "extensions": { + "MAXAR_mesh_variants" : { + "mappings": [ + { + "mesh": 0, + "variants": [0] + }, + { + "mesh": 1, + "variants": [1] + }, + { + "mesh": 2, + "variants": [2] + } + ], + } + } + }, + { + "name": "Car Wheels", + "mesh": 3, + "extensions": { + "MAXAR_mesh_variants" : { + "mappings": [ + { + "mesh": 3, + "variants": [0] + }, + { + "mesh": 4, + "variants": [1] + }, + { + "mesh": 5, + "variants": [2] + } + ], + } + } + }, + { + "name": "Car Lights", + "mesh": 6, + "extensions": { + "MAXAR_mesh_variants" : { + "mappings": [ + { + "mesh": 6, + "variants": [0] + }, + { + "mesh": 7, + "variants": [1, 2] + }, + ], + } + } + } +] +``` + +## Optional vs. Required + +This extension is considered optional, meaning it should be placed in the glTF root's `extensionsUsed` list, but not in the `extensionsRequired` list. + +## Schema Updates + +- **glTF extension JSON schema**: [MAXAR_mesh_variants.schema.json](./schema/glTF.MAXAR_mesh_variants.schema.json) +- **glTF node extension JSON schema**: [node.MAXAR_mesh_variants.schema.json](./schema/node.MAXAR_mesh_variants.schema.json) diff --git a/extensions/2.0/Vendor/MAXAR_mesh_variants/schema/glTF.MAXAR_mesh_variants.schema.json b/extensions/2.0/Vendor/MAXAR_mesh_variants/schema/glTF.MAXAR_mesh_variants.schema.json new file mode 100644 index 0000000000..abf61e5cb9 --- /dev/null +++ b/extensions/2.0/Vendor/MAXAR_mesh_variants/schema/glTF.MAXAR_mesh_variants.schema.json @@ -0,0 +1,51 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema", + "title": "MAXAR_mesh_variants glTF extension", + "type": "object", + "description": "glTF extension that defines mesh variants for nodes", + "allOf": [ + { + "$ref": "glTFProperty.schema.json" + } + ], + "properties": { + "default": { + "allOf": [ + { + "$ref": "glTFid.schema.json" + } + ], + "description": "The index of the variant to load by default. The meshes that are mapped to the default variant must represent the set of meshes initially selected by the nodes for rendering, as per vanilla glTF behavior." + }, + "variants": { + "type": "array", + "items": { + "type": "object", + "allOf": [ + { + "$ref": "glTFChildOfRootProperty.schema.json" + } + ], + "description": "An object defining a valid mesh variant", + "properties": { + "name": { + "type": "string", + "description": "The name of the mesh variant" + }, + "extras": {}, + "extensions": {} + }, + "required": [ + "name" + ] + }, + "minItems": 1 + }, + "extensions": {}, + "extras": {} + }, + "required": [ + "variants", + "default" + ] +} \ No newline at end of file diff --git a/extensions/2.0/Vendor/MAXAR_mesh_variants/schema/node.MAXAR_mesh_variants.schema.json b/extensions/2.0/Vendor/MAXAR_mesh_variants/schema/node.MAXAR_mesh_variants.schema.json new file mode 100644 index 0000000000..ba42661e10 --- /dev/null +++ b/extensions/2.0/Vendor/MAXAR_mesh_variants/schema/node.MAXAR_mesh_variants.schema.json @@ -0,0 +1,63 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema", + "title": "MAXAR_mesh_variants node extension", + "type": "object", + "allOf": [ + { + "$ref": "glTFProperty.schema.json" + } + ], + "properties": { + "mappings": { + "type": "array", + "description": "A list of mesh to variant mappings", + "items": { + "type": "object", + "allOf": [ + { + "$ref": "glTFProperty.schema.json" + } + ], + "properties": { + "variants": { + "uniqueItems": true, + "type": "array", + "description": "An array of variant index values.", + "items": { + "allOf": [ + { + "$ref": "glTFid.schema.json" + } + ] + }, + "minItems": 1 + }, + "mesh": { + "allOf": [ + { + "$ref": "glTFid.schema.json" + } + ], + "description": "The mesh associated with the set of variants." + }, + "name": { + "type": "string", + "description": "The user-defined name of this variant mesh mapping." + }, + "extras": {}, + "extensions": {} + }, + "required": [ + "variants", + "mesh" + ] + }, + "minItems": 1 + }, + "extensions": {}, + "extras": {} + }, + "required": [ + "mappings" + ] +} \ No newline at end of file From ae55312322144823cfdd36dddec41cfae2a69d17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Dahlstr=C3=B6m?= Date: Fri, 22 Oct 2021 11:05:51 +0200 Subject: [PATCH 2/3] Add status: draft --- extensions/2.0/Vendor/MAXAR_mesh_variants/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/extensions/2.0/Vendor/MAXAR_mesh_variants/README.md b/extensions/2.0/Vendor/MAXAR_mesh_variants/README.md index d308c6b10c..1733cfde7a 100644 --- a/extensions/2.0/Vendor/MAXAR_mesh_variants/README.md +++ b/extensions/2.0/Vendor/MAXAR_mesh_variants/README.md @@ -1,5 +1,9 @@ # MAXAR_mesh_variants +## Status + +Draft + ## Dependencies Written against the glTF 2.0 spec. From fabda55e9a3a28a9ed771d4b87188bb287e627eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Dahlstr=C3=B6m?= Date: Wed, 27 Oct 2021 13:23:23 +0200 Subject: [PATCH 3/3] Add contributors --- extensions/2.0/Vendor/MAXAR_mesh_variants/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/extensions/2.0/Vendor/MAXAR_mesh_variants/README.md b/extensions/2.0/Vendor/MAXAR_mesh_variants/README.md index 1733cfde7a..c5bd95002a 100644 --- a/extensions/2.0/Vendor/MAXAR_mesh_variants/README.md +++ b/extensions/2.0/Vendor/MAXAR_mesh_variants/README.md @@ -1,5 +1,10 @@ # MAXAR_mesh_variants +## Contributors + +* Erik Dahlström, Maxar, [@erikdahlstrom](https://github.com/erikdahlstrom) +* Sam Suhag, Cesium, [@sanjeetsuhag](https://github.com/sanjeetsuhag) + ## Status Draft