KhronosGroup / KhronosGroup/glTF
Using the "node.extras" property to serialize game entity component data
- Dominant language
- HTML
- Stars
- 7.8k
- Forks
- 1.2k
- Avg merge
- 17h 26m
- Merged PRs (30d)
- 5
Description
At the [Silicon Valley WebGL/WebVR meetup](https://www.meetup.com/Silicon-Valley-HTML5-WebGL-Meetup/events/249872707/) I presented how we are using glTF as a scene serialization format in Mozilla Hubs.
My slides for the talk are available [here](https://docs.google.com/presentation/d/1suM_42_rigkV39zfAHmOEIzb0zVAV0fjXpsvE-pBMtI/edit#slide=id.g25275a8168_0_386)
After the talk I received some feedback about how we are using the `node.extras` property to serialize our entity component data. @sbtron suggested that we should be using vendor extensions instead of extras for this purpose. Our team has been thinking about this for a while now and there's still some confusion on when we should be using extras or vendor extensions that I'd like to get cleared up.
The entity component data that we are serializing is essentially a 1 to 1 mapping to AFrame components. After loading our glTF scene with the THREE.GLTFLoader, we pull that component data off of the generated object3D's `userData` property. We then use that data to attach AFrame components to the associated nodes.
### Example:
This glTF node:
```
"nodes": [
{
"name": "fan",
"translation": [1, 3, 0],
"extras": {
"MOZ_shadow": {
"castShadow": true,
"receiveShadow": true
},
"MOZ_loopAnimation": {
"clip": "Fan01"
}
}
}
]
}
```
Becomes this AFrame entity:
```
```
In Saurabh's [presentation](https://onedrive.live.com/view.aspx?resid=52B1DDAE0BF63BA3!106131&ithint=file%2cpptx&app=PowerPoint&authkey=!AI4LZBCb8rEgt1U) (on slide 16) he states that if your extension will only be used by your application then you should use a vendor extension:
In the spec, `extras` are defined as "application-specific data".
I'd like to know if our entity component data falls into the bucket of vendor extensions or application-specific data.
We don't intend for these components to be used outside of Mozilla Hubs in their current form. Many components are specific to our own application, are still changing, and definitely aren't applicable to the majority of the glTF community at this time. We do however want to ship our entity component data with the glTF scene.
Should we be writing specs and submitting PRs for every component we write or are we using `node.extras` for its intended purpose?
Contributor guide
Research direction
Start by reviewing the glTF extras and vendor-extension guidance referenced in the issue, along with the Mozilla Hubs examples and linked presentations. Clarify whether entity component data belongs in node.extras or a vendor extension, and document the recommendation and any required specification process.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- three.js
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100