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
Add ability to add networked entity to non-networked parent #400
Comments
Your example is very abstract, so I'm not sure what you propose is really needed for your use case. Do you have dynamic number of children entities or is this a static number of children? If it's dynamic, your proposition may make sense. If not usually you can add networked component on a root parent and with a networked template that use selector you can sync only a child or even a grandchild properties. Anyway feel free to experiment, if you have a change in the code that is not too complex with an example, we can discuss on the PR and see if we merge it or not. |
Thank you for your response. Here is an example if it makes it more clear. Perhaps there is a better way to do things in NAF? // html
//js
You can see here I am adding nested My proposal is instead to add
|
Also I am trying to create a pull request but when I run:
I get:
Do you know what the fix here is by chance? I can succesfully run this:
|
The https url is different from the ssh url. If the ssh works, then use the ssh url: git@github.com:networked-aframe/networked-aframe.git |
Your example appears to be complex to just sync just 'position', 'rotation', 'random-color' of the avatar indeed. Not sure what your random-color component is, but it may be the wrong thing to sync, maybe you want to sync geometry color instead but that's a different issue. Did you look at using a template with selector? See documentation <a-scene
networked-scene="debug: true; connectOnLoad: false;"
>
<a-assets>
<template id="avatar-template">
<a-entity image-target-portal="name: portal">
<a-entity class="offset" position="0 -.7 0"> // I changed id="offset" by class="offset" here
<a-entity
class="avatar"
random-color
character-animation
gltf-model="#robot_model"
scale="0.08 0.08 0.08"
shadow>
</a-entity>
</a-entity>
</a-entity>
</template>
</a-assets>
<a-camera id="camera" position="0 1 0.5" rotation="-20 0 0"></a-camera>
<a-entity id="img-portal" networked="template:#avatar-template"></a-entity>
</a-scene> const addNAFSchemas = () => {
NAF.schemas.add({
template: '#avatar-template',
components: [
{
selector: '.avatar',
component: 'position'
},
{
selector: '.avatar',
component: 'rotation'
},
{
selector: '.avatar',
component: 'random-color'
},
],
})
}
addNAFSchemas() |
Hmm, is there a security setting that might need to be changed on the repo? Maybe you could add me as a contributor? I have tried the ssh url from two different computers but have not been able to run In regards to the example, yes I have seen selectors. However the complexity isn't around syncing childeren. It comes from the issue that the childeren are added to the root scene (unless there is a networked parent). From this logic: https://github.com/networked-aframe/networked-aframe/blob/master/src/NetworkEntities.js#L128 Anyways it might be easier if I open a PR :) |
Creating a fork and opening a PR is the way to go yes.
What you said is right. But for your use case is this really an issue? If you do something like I described in #400 (comment) doesn't it work properly? It's not obvious to me that your really need something else. If you create a runnable example on glitch, I may understand it better. |
What
From my understand there is no way to add a networked entity to a specific part in the DOM unless the networked entity has a networked parent. The way to work around this behavior is to create a nested list of networked components that are "no-ops" (ie don't sync any data), but this doesn't seem ideal API wise.
An example use case of why this feature may be beneficial is, I have a platform in my scene that I want entities to spawn to, but I don't want to have the platform itself have a networked component. You can imagine that this platform is deeply nested in my a-cene.
For example: The entity
two
here will end up as a child of the 'a-scene`.my client:
other client:
This can be done pretty easily it looks like from the current logic by adding another attribute to the
networked
component. Something likeattachToNonNetworkedParent
which if specified adds the networked component to the right place in the DOM using its parent'sid
to find who the parent in the other clients scene is.Let me know if this sounds good, and I can look into sending a PR :)
The text was updated successfully, but these errors were encountered: