aframe-forcegraph-component
Advanced tools
Comparing version 1.7.1 to 1.7.2
46
index.js
@@ -52,28 +52,36 @@ /* global AFRAME */ | ||
init: function () { | ||
this.state = {}; // Internal state | ||
var state = this.state = {}; // Internal state | ||
// Get camera dom element | ||
var cameraEl = document.querySelector('a-entity[camera], a-camera'); | ||
// Add info msg | ||
cameraEl.appendChild(this.state.infoEl = document.createElement('a-text')); | ||
this.state.infoEl.setAttribute('position', '0 -0.1 -1'); // Canvas center | ||
this.state.infoEl.setAttribute('width', 1); | ||
this.state.infoEl.setAttribute('align', 'center'); | ||
this.state.infoEl.setAttribute('color', 'lavender'); | ||
state.infoEl = document.createElement('a-text'); | ||
state.infoEl.setAttribute('position', '0 -0.1 -1'); // Canvas center | ||
state.infoEl.setAttribute('width', 1); | ||
state.infoEl.setAttribute('align', 'center'); | ||
state.infoEl.setAttribute('color', 'lavender'); | ||
// Setup tooltip (attached to camera) | ||
cameraEl.appendChild(this.state.tooltipEl = document.createElement('a-text')); | ||
this.state.tooltipEl.setAttribute('position', '0 -0.5 -1'); // Aligned to canvas bottom | ||
this.state.tooltipEl.setAttribute('width', 2); | ||
this.state.tooltipEl.setAttribute('align', 'center'); | ||
this.state.tooltipEl.setAttribute('color', 'lavender'); | ||
this.state.tooltipEl.setAttribute('value', ''); | ||
// Setup tooltip | ||
state.tooltipEl = document.createElement('a-text'); | ||
state.tooltipEl.setAttribute('position', '0 -0.5 -1'); // Aligned to canvas bottom | ||
state.tooltipEl.setAttribute('width', 2); | ||
state.tooltipEl.setAttribute('align', 'center'); | ||
state.tooltipEl.setAttribute('color', 'lavender'); | ||
state.tooltipEl.setAttribute('value', ''); | ||
// Get camera dom element and attach fixed view elements to camera | ||
var cameraEl = document.querySelector('a-entity[camera], a-camera'); | ||
cameraEl.appendChild(state.infoEl); | ||
cameraEl.appendChild(state.tooltipEl); | ||
// Keep reference to Three camera object | ||
this.cameraObj = cameraEl.object3D.children | ||
state.cameraObj = cameraEl.object3D.children | ||
.filter(function(child) { return child.type === 'PerspectiveCamera' })[0]; | ||
// On camera switch | ||
this.el.sceneEl.addEventListener('camera-set-active', function(evt) { | ||
// Switch camera reference | ||
state.cameraObj = evt.detail.cameraEl.components.camera.camera; | ||
}); | ||
// Add D3 force-directed layout | ||
this.state.d3ForceLayout = d3.forceSimulation() | ||
state.d3ForceLayout = d3.forceSimulation() | ||
.force('link', d3.forceLink()) | ||
@@ -278,3 +286,3 @@ .force('charge', d3.forceManyBody()) | ||
new THREE.Vector2(0, 0), // Canvas center | ||
this.cameraObj | ||
this.state.cameraObj | ||
); | ||
@@ -281,0 +289,0 @@ |
{ | ||
"name": "aframe-forcegraph-component", | ||
"version": "1.7.1", | ||
"version": "1.7.2", | ||
"description": "A 3D Force-Directed Graph component for A-Frame.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1650756
10233