JSFiddle - React, Tailwind, and code Playground

CSS

body {
	  margin: 0;
}

JavaScript

import * as THREE from 'https://threejs.org/build/three.module.js';
import Stats from 'https://threejs.org/examples/jsm/libs/stats.module.js';
import {
  GUI
} from 'https://threejs.org/examples/jsm/libs/dat.gui.module.js';
import {
  OrbitControls
} from 'https://threejs.org/examples/jsm/controls/OrbitControls.js';
import {
  Line2
} from 'https://threejs.org/examples/jsm/lines/Line2.js';
import {
  LineMaterial
} from 'https://threejs.org/examples/jsm/lines/LineMaterial.js';
import {
  LineGeometry
} from 'https://threejs.org/examples/jsm/lines/LineGeometry.js';
import {
  GeometryUtils
} from 'https://threejs.org/examples/jsm/utils/GeometryUtils.js';

// Question Reference: discourse.threejs.org/t/how-to-draw-line-in-diffrent-parent/20839

let three = {
  scene: null,
  camera: null,
  renderer: null,
  orbitcontrols: null,
  dragcontrols: null,
}

let matLine;
let line;
let cube1;
let cube2;

initThreeJS();
createObject();
animate();

function initThreeJS() {
  three.scene = new THREE.Scene();
  three.camera = new THREE.PerspectiveCamera(
    75,
    window.innerWidth / window.innerHeight,
    0.1,
    10000
  );
  three.renderer = new THREE.WebGLRenderer();
  three.renderer.setSize(window.innerWidth, window.innerHeight);

  three.camera.position.z = 5000;
  three.camera.position.y = 2000;
  three.orbitcontrols = new OrbitControls(three.camera, three.renderer.domElement);

  document.body.appendChild(three.renderer.domElement);
  
  window.addEventListener("keydown", (e) => {
  
    if(event.keyCode === 81){ //Key Q 
    	line.material.color.setHex( 0xffffff);	//White
      console.log("change line color")
		}
    else if(event.keyCode === 87){ //Key Q
    	line.material.color.setHex( 0xff0000);	//Red
      console.log("change line color")
		}
    else if(event.keyCode === 69){ //Key E
    	line.material.color.setHex( 0x0059ff);	//Blue
      console.log("change line color")
		}
  })
  
}

function createObject() {
	let geometry = new THREE.BoxGeometry(50, 50,...