title: How to organize imports in a React App with three.js (without using the window object)?
body: <p><strong>Problem:</strong></p>
  
  <p>Let's say I want to create a React App with a 3D component on the left and some other UI components on the right.</p>
  
  <p>The 3D stuff is done with three.js and let's say I want to clone this 3D app: <a href="https://threejs.org/examples/?q=edit#webgl_geometry_spline_editor" rel="nofollow noreferrer">https://threejs.org/examples/?q=edit#webgl_geometry_spline_editor</a></p>
  
  <p>Currently I am globally including the scripts in my index.html that are needed for the 3D app like this:</p>
  
  <pre><code>&lt;script src="../build/three.js"&gt;&lt;/script&gt;
  &lt;script src="js/controls/DragControls.js"&gt;&lt;/script&gt;
  &lt;script src="js/controls/OrbitControls.js"&gt;&lt;/script&gt;
  &lt;script src="js/controls/TransformControls.js"&gt;&lt;/script&gt;
  &lt;script src="js/libs/stats.min.js"&gt;&lt;/script&gt;
  &lt;script src="js/libs/dat.gui.min.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>(Leaving out %PUBLIC_URL% for brevity).</p>
  
  <p>Now in my React 3DComponent I can use the objects and methods in these scripts by using the global window object, like this:</p>
  
  <pre><code>controls = new window.THREE.OrbitControls(camera, renderer.domElement);
  var clock = new window.THREE.Clock();
  </code></pre>
  
  <p><strong>Questions:</strong></p>
  
  <ol>
  <li><p>Is there a more elegant way for importing these scripts so I don't have to import the scripts to the global space? I could import three.js as a module, but some of the other scripts (DragControls, OrbitControls) require the objects in the main Three.js file so I have to keep it in global space.</p></li>
  <li><p>Is there any way to shorten these calls by leaving out the call to the global window object? Without this I could copy and paste the sample codes for the 3d scenes without having to call ".window." before every method and object calls.</p></li>
  </ol>
  
  <p>Sorry if these questions are somewhat nooby but I'm new to React and Three.js. </p>