JSFiddle - React, Tailwind, and code Playground

by Paul West

HTML

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

CSS

body {
    overflow: hidden;
	  margin: 0;
}

JavaScript

var camera, scene, renderer;

var coords = {"Bays":[{"Bay":[
{"x":"-55.5286163110079","y":"32.9576486807176"},
{"x":"-55.9670763177218","y":"32.9576486807176"},
{"x":"-55.9670763177218","y":"32.6576486807176"},
{"x":"-55.5286163110079","y":"32.6576486807176"}
]}]};

init();
animate();

function init() {

    camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 10 );
    camera.position.x = -55;
    camera.position.y = 32;
    camera.position.z = 1;

    scene = new THREE.Scene();

    for (const bay of coords.Bays) {
			const boxPoints = [];
			for (const coord of bay.Bay) {
				boxPoints.push(new THREE.Vector2(parseFloat(coord.x), parseFloat(coord.y)));
			}
      console.log(boxPoints)
			const boxShape = new THREE.Shape(boxPoints);
      console.log(boxShape);
			const geometry = new THREE.ShapeBufferGeometry(boxShape);
      console.log(geometry);
			const mesh = new THREE.Mesh(geometry, new THREE.MeshBasicMaterial({ color: 0xffffff }));
			scene.add(mesh);
      
      var box = new THREE.Box3().setFromObject(mesh);
      box.getCenter(camera.position);
      console.log(camera.position);
      camera.position.z = 1;
      
		}

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

}

function animate() {

    requestAnimationFrame( animate );
    renderer.render( scene, camera );

}