aframe-forcegraph-component
Advanced tools
Comparing version 2.13.0 to 2.14.0
28
index.js
@@ -87,2 +87,17 @@ /* global AFRAME */ | ||
// Bind component methods | ||
d3Force: function() { | ||
if (!this.forceGraph) { | ||
// Got here before component init -> initialize forceGraph | ||
this.forceGraph = new ThreeForceGraph(); | ||
} | ||
const forceGraph = this.forceGraph; | ||
const returnVal = forceGraph.d3Force.apply(forceGraph, arguments); | ||
return returnVal === forceGraph | ||
? this // return self, not the inner forcegraph component | ||
: returnVal; | ||
}, | ||
init: function () { | ||
@@ -131,5 +146,6 @@ var state = this.state = {}; // Internal state | ||
// setup FG object | ||
this.el.object3D.add(state.forceGraph = new ThreeForceGraph()); | ||
if (!this.forceGraph) this.forceGraph = new ThreeForceGraph(); // initialize forceGraph if it doesn't exist yet | ||
this.el.object3D.add(this.forceGraph); | ||
state.forceGraph | ||
this.forceGraph | ||
.onLoading(function() { | ||
@@ -201,6 +217,6 @@ state.infoEl.setAttribute('value', 'Loading...'); // Add loading msg | ||
.filter(function(p) { return p in diff; }) | ||
.forEach(function(p) { comp.state.forceGraph[p](elData[p] !== '' ? elData[p] : null); }); // Convert blank values into nulls | ||
.forEach(function(p) { comp.forceGraph[p](elData[p] !== '' ? elData[p] : null); }); // Convert blank values into nulls | ||
if ('nodes' in diff || 'links' in diff) { | ||
comp.state.forceGraph.graphData({ | ||
comp.forceGraph.graphData({ | ||
nodes: elData.nodes, | ||
@@ -221,3 +237,3 @@ links: elData.links | ||
var intersects = centerRaycaster.intersectObjects(this.state.forceGraph.children) | ||
var intersects = centerRaycaster.intersectObjects(this.forceGraph.children) | ||
.filter(function(o) { // Check only node/link objects | ||
@@ -254,4 +270,4 @@ return ['node', 'link'].indexOf(o.object.__graphObjType) !== -1; | ||
// Run force-graph ticker | ||
this.state.forceGraph.tickFrame(); | ||
this.forceGraph.tickFrame(); | ||
} | ||
}); |
{ | ||
"name": "aframe-forcegraph-component", | ||
"version": "2.13.0", | ||
"version": "2.14.0", | ||
"description": "A 3D Force-Directed Graph component for A-Frame.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -71,2 +71,8 @@ ## aframe-forcegraph-component | ||
There are also internal methods that can be invoked via the [components object](https://aframe.io/docs/0.8.0/core/component.html#accessing-a-component%E2%80%99s-members-and-methods): | ||
| Method | Arguments | Description | | ||
| --- | --- | --- | | ||
| d3Force | id: <i>string</i>, [force: <i>function</i>] | Getter/setter for the internal forces that control the d3 simulation engine. Follows the same interface as `d3-force-3d`'s [simulation.force](https://github.com/vasturiano/d3-force-3d#simulation_force). Three forces are included by default: `'link'` (based on [forceLink](https://github.com/vasturiano/d3-force-3d#forceLink)), `'charge'` (based on [forceManyBody](https://github.com/vasturiano/d3-force-3d#forceManyBody)) and `'center'` (based on [forceCenter](https://github.com/vasturiano/d3-force-3d#forceCenter)). Each of these forces can be reconfigured, or new forces can be added to the system. This method is only applicable if using the d3 simulation engine. | | ||
### Installation | ||
@@ -73,0 +79,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2053383
10534
120