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
Deactivate synchronization for child nodes? #436
Comments
networked entities are synchronized if you own them. To temporarily disable, I guess you could set the owner to "scene" or anything that is not your But I didn't quite understand your use case, it seems you want a participant to control, so taking ownership and send the changes but forbid other participants to take ownership make changes? |
Thanks, we have components which control child elements:
We want the host to control the remote "controlNode", but not the child of this node, because controlNode already controls them without synchronization. |
All that is bit abstract. The above code is missing the networked template and schema. And I have no idea what controlschilds is doing. |
controlchilds is an aframe component that combines a-entities to construct an element such as a canopy. For example, it controls the position and size of the child nodes such as the height of the beam(s). If we write controlchilds="width:2; height:2.2", then controlchild sets this value for some children. When the controlchilds component is synchronized in the remote client, it is not necessary to synchronize the already controlled children. We want to specify that some children (and some attributes) are temporarily not synchronized because we know that other elements are already doing so. |
Maybe you can add controlchilds in the networked schema (with the correct selector), and add a prop synced:boolean to controlchilds. When a networked entity in synced, it will call the update method in your controlchilds component, if synced is false, then don't do any update of your children. |
Thanks, we did it this way:
Additional we have to remove the bufferInfo for the element. Otherwise it is in the remote client not possible to manipulate the component. It looks like this is one solution. When there is a way to avoid the messages from the host that may be a better solution. What do you think? But in the meantime it works this way. Many thanks! |
This is hacky but yeah that works and it avoid sending any changes at all. My proposed solution was still sending changes but ignored on the receiving side. If you want to disable sending update at the component level, you can define your own function to use in requiresNetworkUpdate for the component in your networked schema, like the vectorRequiresUpdate function, see https://github.com/networked-aframe/networked-aframe#syncing-components-optimization |
This is what I have in mind with a synced prop that you add to your controlchilds component (not tested): // Same function as in networked.js but it is not exported so we need to define again.
// You also need to define deepEqual (see DeepEquals.js:equal)
function defaultRequiresUpdate() {
let cachedData = null;
return (newData) => {
if (cachedData === null || !deepEqual(cachedData, newData)) {
cachedData = AFRAME.utils.clone(newData);
return true;
}
return false;
};
}
const componentRequiresUpdate = () => {
return data => {
return data.synced && defaultRequiresUpdate(data)
};
};
// schema
{
template: '#my-template',
components: [
{
component: 'controlchilds',
requiresNetworkUpdate: componentRequiresUpdate
}
]
} |
Ok, thanks, we will test it. |
Is it possible to temporarily deactivate synchronization for the children of a node?
Background:
We have components that control child elements. If this component is synchronized, its child elements should not be controlled on the remote side.
The text was updated successfully, but these errors were encountered: