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
Less confusing doc with the new introduced networked-hand-controls #362
Conversation
…ates and the new networked-hand-controls
I recently came across the term of principle of least surprise when designing an API. For example here the You could also prefer using one rig schema that is synchronizing the rig position/rotation, avatar model y rotation (set from camera rotation via a specific component for local avatar) as a child of the rig, and hands, so not using nested networked entities. That's actually what I did in a previous project. The current behavior of auto creating things prevents you now from doing this, because if you specify to sync hands with the new
with:
|
With what I said above, I would prefer reverting the auto creation of the template, schema, networked component and properly document how to specify it in the documentation like I just did in the PR. |
I am familiar with the principle of least surprise, but of course there's always a balance; the least surprise is attained by doing everything manually from scratch. :)
That's an interesting thought. I think the real problem is that we should consider overhauling our schema adding API. Originally I was going to include instructions for doing it manually, but it seemed like bad design to have to just have developers duplicate the same settings in multiple places to make it work. I also wanted this component to match the networked-audio-source as just being a 'set it and it is done' setup. I'm not sure if there are really so many use cases where one would want to do this manually; the schema you give an example of is a good example, but perhaps we should just build that in to the default, and maybe add a property to allow configuring the update rates? I also might suggest that I'm surprised anyone was confused by this, as the instruction and demo is pretty clear. But by adding it behind a flag like I would like to see an improved/optimized default template added though, with parameters for precision on the component, perhaps--maybe a single number from 0 to 1 that scales your defaults down? |
If you have something concrete in mind, you can create a draft PR with some code changes so we can discuss it further.
The I may be wrong, but from our exchange here, it seems you have in mind a more granular way to sync data, more at the component level instead of the entity level with a networked schema? This is unfortunately not how naf currently work.
The update rates can already be configured with For the default schema syncing position and rotation networked-aframe/src/Schemas.js Lines 13 to 16 in fec4c84
could be replaced by a better default components: [
{
component: "position",
requiresNetworkUpdate: NAF.utils.vectorRequiresUpdate(0.001)
},
{
component: "rotation",
requiresNetworkUpdate: NAF.utils.vectorRequiresUpdate(0.5)
}
] I'm not against it, PR welcome and some wording in the README needs to be changed as well.
Yes we can probably do that. I have another idea of changes in the current code that could fix the issue of overriding template with same id and not auto creating the networked component. I'll test that shortly.
This is more or less what |
With the latest commit, I think I fixed my main concerns, which are:
I also fixed some issues I had because the |
@@ -201,17 +203,19 @@ AFRAME.registerComponent('networked-hand-controls', { | |||
this.el.setObject3D(this.str.mesh, newMesh); | |||
|
|||
const handMaterial = newMesh.children[1].material; | |||
handMaterial.color = new THREE.Color(this.data.handColor); | |||
handMaterial.color = new THREE.Color(this.data.color); | |||
this.el.sceneEl.systems.renderer.applyColorCorrection(handMaterial.color); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why duplicate this code instead of calling updateHandMeshColor()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have the handMaterial variable here and we set the color already, calling updateHandMeshColor()
to get again the mesh, setting the color that didn't change just to convert the color with applyColorCorrection seems the real duplication to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I defined this.rendererSystem
is init for better readability.
} | ||
else { | ||
this.el.classList.add('naf-remote-hand'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can I ask why we remove this? this makes it easier to view in the a-frame inspector at a glance, if nothing else. I am a fan of things getting classes and IDs where possible to make things more viewable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't see it used anywhere so I removed it. I almost never use the aframe inspector, so I didn't see the value of it, but you make a good point. I'll put it back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
components: [ | ||
'position', | ||
'rotation', | ||
'networked-hand-controls', | ||
] | ||
}; | ||
NAF.schemas.templateCache[`#${hand}-hand-template`] = templateOuter; | ||
NAF.schemas.templateCache[`#${hand}-hand-default-template`] = templateOuter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should have done this, but good to fix now: this should probably be
NAF.schemas.templateCache[`#${templateOuter.id}] = templateOuter;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I introduced
const refTemplateId = `#${templateOuter.id}`;
and used it everywhere.
|
||
if (this.local) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by removing this condition, we do the binding unnecessarily for networked entities that don't respond to events. not a huge deal, but it's an unnecessary inefficiency. Since you moved/improved the this.local detection, you could move these method bindings to be async / done after line 91.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Overall these changes look good and the fixes correct, though I noticed a few small things. However, for the default template that is added, I was wondering if it made sense to update this: NAF.schemas.schemaDict[`#${hand}-hand-default-template`] = {
template: `#${hand}-hand-default-template`,
components: [
'position',
'rotation',
'networked-hand-controls',
]
}; to also include values like these: {
component: "position",
requiresNetworkUpdate: NAF.utils.vectorRequiresUpdate(0.001)
},
{
component: "rotation",
requiresNetworkUpdate: NAF.utils.vectorRequiresUpdate(0.5)
},
```
by default; and _perhaps_ in this component to have a value that allows tweaking them _all_ with a single factor. So, you'd get something like this, maybe:
```html
<a-entity class="right-controller" networked-hand-controls="hand:right; precision:.5"></a-entity> where This is what I was trying to communicate before when I wrote
Just a thought--if you feel like including it, great, but these changes are also worthwhile as-is. |
How interesting, I missed that talk. Lots of interesting things to think about. |
For position and rotation with requiresNetworkUpdate, definitely make sense, but I'll make that change in another PR with also the same change in the default schema and the corresponding section in the documentation. |
The networked-hand-controls component introduced in #355 and #358 is auto creating the template, networked schema and networked component on the corresponding entity. This was apparently confusing for some users, who mixed the old approach and the new component.
I already committed directly on master moving the new section up without changes e81604b and fixed wrong param custom hand model param 32651f3
In this PR I added some explanation to better understand the difference between hand-controls with custom templates and the new networked-hand-controls.
But thinking about it, We maybe shouldn't auto create the template, schema, networked component if the user specified it themself, but the way we create it it's not actually possible to check if the user defined it themself. They may want to add additional component to the networked schema, and currently I don't think it's possible.
I'm not sure auto creating all that to simplify the developer experience is actually good, because we actually need to explain in the documentation what's going on behind the scene, otherwise the developer is attaching the networked component and creating the templates themself and not understanding why they have issues.
What's your thoughts @kylebakerio on this?