Comments (3)
@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.
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.
@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)
- Errors when trying to swap out 3d forcegraph for 3d forcegraph VR HOT 2
- Graph disappears when in VR mode? HOT 1
- import ForceGraphVR in js module gives multiple instances of Three.js imported and A-frame <script>in head warnings HOT 2
- Adding <!DOCTYPE html> at the top of the source code causes basic example to fail HOT 2
- Nodes names not displayed HOT 4
- Text + Nodes causes errors HOT 1
- Not sure how to add a bg video HOT 4
- Movement doesn't work on Oculus HOT 1
- Differentiating same name nodes HOT 1
- Graph with ~150 nodes and ~300 crashes HOT 2
- How to render an image sprite and display text at the same time ?
- How to make the nodes look at the camera at all times without calling refresh ? HOT 4
- Node Labels not Displayed on Mobile HOT 4
- Background Image option instead of background color HOT 1
- Click to expand / collapse in VR?
- interaction to nodes
- Cannot read properties of undefined (reading 'xr') HOT 1
- Is there a way to render the passthrough background for XR headsets (e.g. Oculus Pro)? HOT 1
- Mobile navigation HOT 1
- Which combination to get started HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from 3d-force-graph-vr.