JSFiddle - React, Tailwind, and code Playground

by kalverk

HTML

<script src="http://threejs.org/build/three.min.js"></script>

CSS

body {
	background-color: #000;
	margin: 0px;
	overflow: hidden;
}

JavaScript

// three.js animataed line using BufferGeometry and drawcalls

var renderer, scene, camera;

var line,lines;
var MAX_POINTS = 500;
var drawCount;
var mousePosition = new THREE.Vector3(0, 0, 0.5);
var geometry;

init();
animate();

function init() {

	// info
	var info = document.createElement( 'div' );
	info.style.position = 'absolute';
	info.style.top = '30px';
	info.style.width = '100%';
	info.style.textAlign = 'center';
	info.style.color = '#fff';
	info.style.fontWeight = 'bold';
	info.style.backgroundColor = 'transparent';
	info.style.zIndex = '1';
	info.style.fontFamily = 'Monospace';
	info.innerHTML = "three.js animataed line using BufferGeometry and drawcalls";
	document.body.appendChild( info );

	// renderer
	renderer = new THREE.WebGLRenderer();
	renderer.setPixelRatio( window.devicePixelRatio );
	renderer.setSize( window.innerWidth, window.innerHeight );
	document.body.appendChild( renderer.domElement );

	// scene
	scene = new THREE.Scene();

	// camera
	camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 );
	camera.position.set( 0, 0, 1000 );

	// geometry
	geometry = new THREE.Geometry();
    
    var x = y = z = 0;

	for ( var i = 0, l = MAX_POINTS; i < l; i ++ ) {
		x += ( Math.random() - 0.5 ) * 30;
		y += ( Math.random() - 0.5 ) * 30;
		z += ( Math.random() - 0.5 ) * 30;

        geometry.vertices.push(new THREE.Vector3(x, y, z));
	}

	// material
	var material = new THREE.LineBasicMaterial( { color: 0xff0000, linewidth: 2 } );
    material.originalColor = material.color;
	// line
    lines = new THREE.Object3D();
	line = new THREE.Line( geometry,  material );
    lines.add(line);
	scene.add(lines);
    
    document.onmousemove = function(event){
        mousePosition.x = 2 * (event.clientX / window.innerWidth) - 1;
        mousePosition.y = 1 - 2 * ( event.clientY / window.innerHeight);
        mousePosition.unproject(camera);
        var raycaster = new...