JSFiddle - React, Tailwind, and code Playground
HTML
<script type="text/javascript" src="http://threejs.org/build/three.min.js"></script>
CSS
body {
background-color: #000;
margin: 0;
overflow: hidden;
}
JavaScript
var camera, scene, renderer;
function init() {
renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
camera = new THREE.PerspectiveCamera(75,
window.innerWidth / window.innerHeight, 1, 2000);
camera.position.z = 600;
scene = new THREE.Scene();
var buffer_geometry = new THREE.BufferGeometry();
buffer_geometry.dynamic = true;
var material = new THREE.LineBasicMaterial({
vertexColors: true
});
var lines = 1000;
buffer_geometry.attributes = {
position: {
itemSize: 3,
array: new Float32Array(lines * 3),
numItems: lines * 3
},
color: {
itemSize: 3,
array: new Float32Array(lines * 3),
numItems: lines * 3
}
};
var positions = buffer_geometry.attributes.position.array;
var colors = buffer_geometry.attributes.color.array;
var radius = 200;
for (var i = 0; i < lines; i++) {
var lat = Math.random() * 180 - 90;
var lng = Math.random() * 360 - 180;
var phi = (90.0 - lat) * Math.PI / 180.0;
var theta = (360.0 - lng) * Math.PI / 180.0;
var x = radius * Math.sin(phi) * Math.cos(theta);
var y = radius * Math.cos(phi);
var z = radius * Math.sin(phi) * Math.sin(theta);
//positions[i * 6 + 0] = 0;
//positions[i * 6 + 1] = 0;
//positions[i * 6 + 2] = 0;
positions[ i * 6 + 0 ] = x;
positions[ i * 6 + 1 ] = y;
positions[ i * 6 + 2 ] = z;
x = radius * 1.5 * Math.sin(phi) * Math.cos(theta);
y = radius * 1.5 * Math.cos(phi);
z = radius * 1.5 * Math.sin(phi) * Math.sin(theta);
positions[i * 6 + 3] = x;
positions[i * 6 + 4] = y;
positions[i * 6 + 5] = z;
colors[i * 6 + 0] = 1;
colors[i * 6 + 1] = 1;
colors[i * 6 + 2]...