{"size": 2100, "ext": "js", "max_stars_repo_path": "src/App.js", "max_stars_repo_name": "gladishd/PoseRunner", "max_stars_repo_stars_event_min_datetime": "2021-03-20T16:36:09.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-20T16:36:09.000Z", "max_issues_repo_path": "src/App.js", "max_issues_repo_name": "gladishd/PoseRunner", "max_issues_repo_issues_event_min_datetime": "2021-03-08T17:17:53.000Z", "max_issues_repo_issues_event_max_datetime": "2021-03-20T13:48:26.000Z", "max_forks_repo_path": "src/App.js", "max_forks_repo_name": "gladishd/PoseRunner", "max_forks_repo_forks_event_min_datetime": "2021-04-16T04:02:43.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-28T00:47:23.000Z"}
{"max_stars_count": 1, "max_issues_count": 34, "max_forks_count": 3, "avg_line_length": 31.3432835821, "max_line_length": 173, "alphanum_fraction": 0.6395238095}
import React from 'react';
import Game from './Components/Game';
import StartScreen from './Components/StartScreen';
import CalibrateScreen from "./Components/Calibrate";
import EndScreen from './Components/EndScreen';
import { Switch, Route } from "react-router-dom";
import { CircularProgress } from '@material-ui/core';
import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader';

import Aj from './assets/Aj.fbx';
import will from "./assets/icon.jpg";
import bg from "./assets/skies/bg8.jpg";
import txt from "./assets/skies/tile02.png";
import leftArrow from './assets/arrows/left.png';
import rightArrow from './assets/arrows/right.png';
import upArrow from './assets/arrows/up.png';

class App extends React.Component{
  
  constructor(props){
    super(props);
    this.state={
      character: null,
      posenet: false,
    }
  }

  onAjLoad = async (object3d) => {
    if(object3d){
      this.setState({character: object3d});
    }
  }

  loadHandler = async () => {
    let CharLoader = new FBXLoader();
    await CharLoader.load(Aj, this.onAjLoad);
  }

  handlePoseNetChange = (value) => {
    this.setState({ ...this.state, posenet: value });
  }

  render(){
    return(
      <Switch>
        <Route path="/" exact>
          {this.state.character?
          <StartScreen Aj={this.state.character} handlePoseNet={this.handlePoseNetChange}/>:
          <CircularProgress style={{position:'absolute', top: '50%', left:'50%'}}>{this.loadHandler()}</CircularProgress>}
        </Route>
        <Route path="/calibrate" exact>
          <CalibrateScreen />
        </Route>
        <Route path="/game" exact>
          {this.state.character?
          <Game player={this.state.character} usePoseNet={this.state.posenet} backGrd={bg} willImg={will} leftA={leftArrow} rightA={rightArrow} jumpA={upArrow} txtr={txt}/>:
          <CircularProgress style={{position:'absolute', top: '50%', left:'50%'}}>{this.loadHandler()}</CircularProgress>}
        </Route>
        <Route path="/over" exact>
          <EndScreen />
        </Route>
      </Switch>
    )
  }
}

export default App;