import 'aframe';
import {Animation, Entity} from 'aframe-react';
import React from 'react';
import { translate, rand, vLog, objToArr,
  massToRadius, filterClose, vectorToString } from '../Helpers/VectorHelpers';
import { getNetAccel } from '../Helpers/AccelerationLogic';

const backwards = new THREE.Vector3(0, 0, 0.01);
const TIME_STEP = 1;

AFRAME.registerComponent('step', {
  schema: {
    chi: { default: new THREE.Vector3() },
  },

  tick: function (t) {
    let position = this.el.object3D.position;
    const radius = +this.el.attributes.radius.value;
    let velocity = new THREE.Vector3().fromArray(
      this.el.attributes.velocity.value.split(' ').map(i => +i)
    );
    let allDancers = objToArr(this.el.sceneEl.querySelectorAll('.dancer'))
      .filter(dancer => dancer !== this.el)
      .map(dancer => ({
        mass: +dancer.attributes.mass.value,
        position: dancer.object3D.position,
      }));
    const allOtherDancers = filterClose(allDancers, position, 2*radius);
    const netAccel = getNetAccel(position, allOtherDancers);
    velocity = velocity.add(netAccel.multiplyScalar(t)); // addScaledVector doesn't work. lol
    translate(this.el.object3D, velocity);
    const velocityString = velocity.toArray().join(' ')
    this.el.setAttribute('velocity', vectorToString(velocity));
  }
});

class Dancer extends React.Component {
  constructor(props) {
    super(props);
    this.mass = props.mass || rand(2, 1000);
  }

  render() {
    return (
      <a-sphere src="../assets/earth.jpg" radius={massToRadius(this.mass)}
        step class='dancer' mass={this.mass}
        velocity="0 0 0"
        position={this.props.position.join(' ')}
      />
    );
  }
}

module.exports = Dancer;

@@ -465,68 +465,86 @@
     
-let position = this.el.object3D.position;%0A    const
+const thisDancer = %7B%0A      mass: +this.el.attributes.mass.value,%0A     
  radius
- =
+:
  +th
@@ -572,17 +572,66 @@
 us.value
-;
+,%0A      position: this.el.object3D.position,%0A    %7D
 %0A    let
@@ -752,19 +752,21 @@
     let 
-all
+other
 Dancers 
@@ -930,24 +930,73 @@
 mass.value,%0A
+        radius: +dancer.attributes.radius.value,%0A
         posi
@@ -1078,19 +1078,21 @@
 erClose(
-all
+other
 Dancers,
@@ -1146,24 +1146,26 @@
 etAccel(
-position
+thisDancer
 , allOth

Reformat body to be object