Skip to content

Commit

Permalink
use better default schema with the requiresNetworkUpdate optimization…
Browse files Browse the repository at this point in the history
… for position and rotation (#367)
  • Loading branch information
vincentfretin committed Sep 17, 2022
1 parent 8ca8d57 commit d4e80ae
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 11 deletions.
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,17 +327,19 @@ and rotation precision of 0.5 degree, use it like this:
template: '#avatar-template',
components: [
{
component: "position",
component: 'position',
requiresNetworkUpdate: NAF.utils.vectorRequiresUpdate(0.001)
},
{
component: "rotation",
component: 'rotation',
requiresNetworkUpdate: NAF.utils.vectorRequiresUpdate(0.5)
}
]
}
```

The default schema that sync position and rotation uses the above optimization since version 0.11.0.

### Syncing nested templates - eg. hands

To sync nested templates setup your HTML nodes like so:
Expand Down Expand Up @@ -404,16 +406,28 @@ Default templates and networked schemas are already defined as follow:
NAF.schemas.add({
template: '#left-hand-default-template'
components: [
'position',
'rotation',
{
component: 'position',
requiresNetworkUpdate: NAF.utils.vectorRequiresUpdate(0.001)
},
{
component: 'rotation',
requiresNetworkUpdate: NAF.utils.vectorRequiresUpdate(0.5)
},
'networked-hand-controls'
]
});
NAF.schemas.add({
template: '#right-hand-default-template'
components: [
'position',
'rotation',
{
component: 'position',
requiresNetworkUpdate: NAF.utils.vectorRequiresUpdate(0.001)
},
{
component: 'rotation',
requiresNetworkUpdate: NAF.utils.vectorRequiresUpdate(0.5)
},
'networked-hand-controls'
]
});
Expand Down
10 changes: 8 additions & 2 deletions src/Schemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ class Schemas {
return {
template: name,
components: [
'position',
'rotation',
{
component: 'position',
requiresNetworkUpdate: NAF.utils.vectorRequiresUpdate(0.001)
},
{
component: 'rotation',
requiresNetworkUpdate: NAF.utils.vectorRequiresUpdate(0.5)
}
]
}
}
Expand Down
12 changes: 9 additions & 3 deletions src/components/networked-hand-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@ function addHandTemplate(hand) {
NAF.schemas.schemaDict[refTemplateId] = {
template: refTemplateId,
components: [
'position',
'rotation',
'networked-hand-controls',
{
component: 'position',
requiresNetworkUpdate: NAF.utils.vectorRequiresUpdate(0.001)
},
{
component: 'rotation',
requiresNetworkUpdate: NAF.utils.vectorRequiresUpdate(0.5)
},
'networked-hand-controls'
]
};
NAF.schemas.templateCache[refTemplateId] = templateOuter;
Expand Down

0 comments on commit d4e80ae

Please sign in to comment.