GithubHelp home page GithubHelp logo

Comments (3)

vasturiano avatar vasturiano commented on July 22, 2024

@aadityavaze thanks for reaching out. There are some pieces of functionality that are available on 3d-force-graph but not on 3d-force-graph-vr. d3Force is one of those such cases.
The main reason is because aframe (the underlying VR rendering engine) does not allow for
methods to be invoked on its components. All the communication should flow as props, and while it's possible to have the child invoke actions in the parent via callbacks, it's not possible for the parent to signal an action to the child. Further, every prop needs to be serialized into a primitive, which then is passed via the DOM to the component. Thus, serializing functions actually lose their scope during the serialization and you would not be able to share references to objects/functions, and so they would not be able to run inside the aframe component. This is the case with adding a new d3 force, it requires maintaining a reference to the force function itself which will not be available at runtime.

This is indeed unfortunate and I would very much like to find a working solution for this.

For reference, here is where the props are being serialized into the underlying aframe component:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#Syntax

from 3d-force-graph-vr.

vasturiano avatar vasturiano commented on July 22, 2024

On second glance at the aframe docs, turns out there is a way to access the internal methods: https://aframe.io/docs/0.8.0/core/component.html#accessing-a-component%E2%80%99s-members-and-methods

This is great, I have now exposed the d3Force method using that internal access method. So, you can now use it in the same way as 3d-force-graph.

myGraph.d3Force(...)

Here's an example: https://vasturiano.github.io/3d-force-graph-vr/example/collision-detection/

Make sure to use the latest version (1.22.0).

from 3d-force-graph-vr.

thisisvaze avatar thisisvaze commented on July 22, 2024

@vasturiano Thanks a lot for explaining it so well and going through all the trouble to making it work. It seemed like a much-needed functionality to this awesome library.

Thanks again!

from 3d-force-graph-vr.

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.