JSFiddle - React, Tailwind, and code Playground

HTML

<script src="//cdn.rawgit.com/mrdoob/three.js/master/build/three.min.js"></script>

JavaScript

const displayCollisionLines = false
let container
let camera, scene, renderer;
const PI = Math.PI
const mouse  = new THREE.Vector3()
let touchRaycaster = new THREE.Raycaster()
let cone
var prevTime;
let keys = []
let deltaX=0,deltaY=0,theta=0,phi=0,yaw=0

const indexMod = 5
const dots = 5 
let spatialIndex = []
let collisionObjects = []
var vertex = new THREE.Vector3();
var color = new THREE.Color();
let controls 


function init() {

container = document.createElement( 'div' );
document.body.appendChild( container );

// camera

scene = new THREE.Scene();

scene.background = new THREE.Color( 0x00a0f0 );

const ambient = new THREE.AmbientLight( 0xaaaaaa );
    scene.add( ambient );

    const light = new THREE.DirectionalLight( 0xaaaaaa );
    light.position.set( 30, 100, 40 );
    light.target.position.set( 0, 0, 0 );

    light.castShadow = true;

const lightSize = 500;
    light.shadow.camera.near = 1;
    light.shadow.camera.far = 500;
light.shadow.camera.left = light.shadow.camera.bottom = -lightSize;
light.shadow.camera.right = light.shadow.camera.top = lightSize;

light.shadow.bias = 0.0039;
light.shadow.mapSize.width = 1024;
light.shadow.mapSize.height = 1024;
scene.add(light)
camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 10, 200000  );

camera.cameraTarget = new THREE.Vector3();

clock = new THREE.Clock();

// lights

const hemiLight = new THREE.HemisphereLight( 0xffffff, 0x444444, 0.4 );
hemiLight.position.set( 0, 100, 0 );
scene.add( hemiLight );

const dirLight = new THREE.DirectionalLight( 0xffffff, 0.8 );
dirLight.position.set( - 700, 1000, - 750 );
scene.add( dirLight );


renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.shadowMap.enabled = true;
container.appendChild( renderer.domElement );

window.addEventListener( 'resize', onWindowResize, false );
var helper = undefined
var geo = new THREE.ConeBufferGeometry( 2, 10, 3 );
//...