JSFiddle - React, Tailwind, and code Playground

by navinleon

HTML

<html lang="en">
<head>
		<title>three.js webgl - interactive lines</title>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
		<link type="text/css" rel="stylesheet" href="main.css">
		<style>
			body {
				background-color: #f0f0f0;
				color: #444;
			}
			a {
				color: #08f;
			}
		</style>
	</head>
	<body >

		<script type="module">

			import * as THREE from '../build/three.module.js';

			import Stats from './jsm/libs/stats.module.js';

			let container, stats;
			let camera, scene, raycaster, renderer, parentTransform, sphereInter;

			const mouse = new THREE.Vector2();
			const radius = 100;
			let theta = 0;

			init();
			animate();

			function init() {

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

				const info = document.createElement( 'div' );
				info.style.position = 'absolute';
				info.style.top = '10px';
				info.style.width = '100%';
				info.style.textAlign = 'center';
				info.innerHTML = '<a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> webgl - interactive lines';
				container.appendChild( info );

				camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 10000 );

				scene = new THREE.Scene();
				scene.background = new THREE.Color( 0xf0f0f0 );

				const geometry = new THREE.SphereBufferGeometry( 5 );
				const material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );

				sphereInter = new THREE.Mesh( geometry, material );
				sphereInter.visible = false;
				scene.add( sphereInter );

				const lineGeometry = new THREE.BufferGeometry();
				const points = [];

				const point = new THREE.Vector3();
				const direction = new THREE.Vector3();

				for ( let i = 0; i < 50; i ++ ) {

					direction.x += Math.random() - 0.5;
					direction.y += Math.random() - 0.5;
					direction.z += Math.random() -...