Giter Site home page Giter Site logo

Comments (9)

vincentfretin avatar vincentfretin commented on May 24, 2024

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 NAF.clientId.

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?

from networked-aframe.

Dirk-27 avatar Dirk-27 commented on May 24, 2024

Thanks, we have components which control child elements:

<a-entity networked>
  <a-entity id="controlNode" ... controlchilds="">
     <a-entity id="child1" ... >
     </a-entity>
     <a-entity id="child2" ... >
     </a-entity>
  </a-entity>
</a-entity>

We want the host to control the remote "controlNode", but not the child of this node, because controlNode already controls them without synchronization.

from networked-aframe.

vincentfretin avatar vincentfretin commented on May 24, 2024

All that is bit abstract. The above code is missing the networked template and schema. And I have no idea what controlschilds is doing.
Did I answer your question about the ownership? If not, please provide a more complete example to discuss it further.

from networked-aframe.

Dirk-27 avatar Dirk-27 commented on May 24, 2024

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.

from networked-aframe.

vincentfretin avatar vincentfretin commented on May 24, 2024

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.

from networked-aframe.

Dirk-27 avatar Dirk-27 commented on May 24, 2024

Thanks, we did it this way:

AFRAME.components.networked.Component.prototype.updateNetworkedComponents = function(components) {
      for (var componentIndex = 0, l = this.componentSchemas.length; componentIndex < l; componentIndex++) {
        var componentData = components[componentIndex];
        var componentSchema = this.componentSchemas[componentIndex];
        var componentElement = this.getCachedElement(componentIndex);


        if (this.skipComponentUpdate) {
          /*
            Some kind of check to skip updates for specific elements and components.
            To allow manual component updates the bufferInfo entry needs to be removed.
          */
          continue;
        }
(...)

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!

from networked-aframe.

vincentfretin avatar vincentfretin commented on May 24, 2024

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

from networked-aframe.

vincentfretin avatar vincentfretin commented on May 24, 2024

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
    }
  ]
}

from networked-aframe.

Dirk-27 avatar Dirk-27 commented on May 24, 2024

Ok, thanks, we will test it.

from networked-aframe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.