Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXT_animation_map extension proposal #1137

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Next Next commit
Add EXT_animation_map extension spec
  • Loading branch information
msfeldstein committed Oct 26, 2017
commit 730df4e94f2b7e0cee5c4e0e3166bd8f52fa4932
83 changes: 83 additions & 0 deletions extensions/Vendor/EXT_animation_map/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# EXT_animation_map

## Contributors

* Michael Feldstein, Facebook, [@msfeldstein](https://twitter.com/msfeldstein)
* Ocean Quigley, Facebook, [@oceanquigley](https://twitter.com/oceanquigley)

## Status

Draft

## Dependencies

Written against the glTF draft 2.0 spec.

## Overview

This extensions maps optional semantic meaning to animations so that client applications can attach interactive and reactive behaviors to the 3d models and scenes. This can be useful to let a client know to play a certain animation when the model first enters a scene, or when a model is about to leave.

Facebook uses it to play animations when a model enters/leaves the feed, or scrubs an animation as the user scrolls the model through the screen.
It is also used to respond to user events, such as tapping, or horizontal panning

It maps a semantic, which can be any string a client wishes to bind, to an array of animation indices, pointing to a list of gltf Animation.

##### Example Semantics

* **ENTER**: Trigger a single shot animation when the object first enters the scene or viewport
* **LEAVE**: Trigger a single shot animation as the object is leaving the scene or viewport
* **ALWAYS**: Constantly loop an animation
* **TRIGGER**: A user triggering a single shot animation on Touch, Tap, Click, or any other way of activating
* **GRAB**: Triggered when an object is picked up, for example grabbed in vr, or dragged in WebGL.
* **HELD**: Looped during the entire duration an object is grabbed.
* **RELEASED**: Triggered when an object is released from a grab.
* **GAZE_ENTER**: Triggered when an object is first looked at
* **GAZE**: Looped while an object is being looked at
* **GAZE_LEAVE**: Triggered when an object stops being looked at
* **PROXIMITY_ENTER**: Triggered when a viewer gets close to an object
* **PROXIMITY**: Looped while a viewer is near to an object
* **PROXIMITY_LEAVE**: Triggered when a viewer gets further from an object

## glTF Schema Updates

The new EXT_animation_map property is a root glTF level optional extension object. The **bindings** array is a list of objects with a semantic, and an array of animations mapped to that semantic.

**Listing 1**: An animation map that binds animations 0 and 3 to the ENTER event, 1 to the LEAVE event, and 2 to loop continuously for the life of the object.

```javascript
{
"extensionsUsed": {
"EXT_animation_map"
},
"extensions" : {
"EXT_animation_map" : {
"bindings": [
{
"semantic": "ENTER",
"animations": [0, 3]
},
{
"semantic": "LEAVE",
"animations": [1]
},
{
"semantic": "ALWAYS",
"animations": [2]
}
]
}
}
}
```

### JSON Schema

TODO: Links to the JSON schema for the new extension properties.

## Known Implementations

* None yet, will be implemented in Facebook 3d Posts

## Resources

*
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema" : "http://json-schema.org/draft-04/schema",
"title" : "EXT_animation_map extension",
"type" : "object",
"definitions": {
"semanticBinding": {
"type": "object",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how to read these schema definitions so I'll just ask... can a bindings object have extras?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believe anything in a gltf schema can have extras right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, semanticBinding definition needs to contain

"allOf": [ { "$ref": "glTFProperty.schema.json" } ],

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, thanks

"properties": {
"semantic": {
"type": "string"
},
"animations": {
"type": "array",
"items": {
"type": "number",
"minimum": 0
}
}
}
}
},
"properties" : {
"bindings" : {
"type" : "array",
"description" : "A list of bindings between event or state semantics and animation indexes",
"items": { "$ref": "#/definitions/semanticBinding" }
}
},
"required" : ["bindings"]
}