<commit_before>import React, { Component } from "react";
import TacticalIcon from "./TacticalIcon";
import Selection from "./select";
import * as THREE from "three";

function distance3d(coord2, coord1) {
  const { x: x1, y: y1, z: z1 } = coord1;
  let { x: x2, y: y2, z: z2 } = coord2;
  return Math.sqrt((x2 -= x1) * x2 + (y2 -= y1) * y2 + (z2 -= z1) * z2);
}

class Objects extends Component {
  state = { flash: false, locations: null, movements: {} };
  flashing = true;
  loopInterval = 30;
  componentDidMount() {
    this.looping = true;
    this.flashLoop();
    this.moveLoop();
    document.addEventListener("keydown", this.deleteKey);
  }
  componentWillUnmount() {
    this.looping = false;
    document.removeEventListener("keydown", this.deleteKey);
  }
  deleteKey = e => {
    if (e.which === 8 && e.target instanceof window.HTMLBodyElement) {
      e.preventDefault();
      const selected = this.state.selected || [];
      const objectId = this.props.objectId || null;
      []
        .concat(selected)
        .concat(objectId)
        .filter(i => i)
        .forEach(c => this.props.removeObject(c, this.props.id));
    }
  };
  flashLoop = () => {
    if (!this.looping) return;
    this.setState({
      flash: !this.state.flash
    });
    if (this.state.flash) {
      setTimeout(this.flashLoop, 250);
    } else {
      setTimeout(this.flashLoop, 500);
    }
  };
  moveLoop = () => {
    if (!this.looping) return;
    setTimeout(this.moveLoop, this.loopInterval);
    this.setState({<commit_msg>Closes #797<commit_after>import React, { Component } from "react";
import TacticalIcon from "./TacticalIcon";
import Selection from "./select";
import * as THREE from "three";

function distance3d(coord2, coord1) {
  const { x: x1, y: y1, z: z1 } = coord1;
  let { x: x2, y: y2, z: z2 } = coord2;
  return Math.sqrt((x2 -= x1) * x2 + (y2 -= y1) * y2 + (z2 -= z1) * z2);
}

class Objects extends Component {
  state = { flash: false, locations: null, movements: {} };
  flashing = true;
  loopInterval = 30;
  componentDidMount() {
    this.looping = true;
    this.flashLoop();
    this.moveLoop();
    document.addEventListener("keydown", this.deleteKey);
  }
  componentWillUnmount() {
    this.looping = false;
    document.removeEventListener("keydown", this.deleteKey);
  }
  deleteKey = e => {
    if (e.which === 8 && e.target instanceof window.HTMLBodyElement) {
      e.preventDefault();
      const selected = this.state.selected || [];
      const objectId = this.props.objectId || null;
      []
        .concat(selected)
        .concat(objectId)
        .filter(i => i)
        .forEach(c => this.props.removeObject(c, this.props.id));
    }
  };

  flashLoop = () => {
    if (!this.looping) return;
    this.setState({
      flash: !this.state.flash
    });
    if (this.state.flash) {
      setTimeout(this.flashLoop, 250);
    } else {
      setTimeout(this.flashLoop, 500);
    }
  };
  moveLoop = () => {
    if (!this.looping) return;
    setTimeout(this.moveLoop, this.loopInterval);
    this.setState({
{'fraction_non_alphanumeric': 0.16027531956735497, 'fraction_numerical': 0.019993444772205833, 'mean_word_length': 2.838993710691824, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4554305', 'n_tokens_mistral': 1041, 'n_tokens_neox': 1027, 'n_words': 234}