JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//cdn.rawgit.com/mrdoob/three.js/master/build/three.min.js"></script>
<div id="container">
</div>
JavaScript
var container, stats;
var camera, scene, renderer;
var mouseX = 0, mouseY = 0;
var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2;
init();
animate();
function init() {
container = document.getElementById( 'container' );
camera = new THREE.PerspectiveCamera( 20, window.innerWidth / window.innerHeight, 1, 10000 );
camera.position.z = 1800;
scene = new THREE.Scene();
scene.background = new THREE.Color( 0xffffff );
var light = new THREE.DirectionalLight( 0xffffff );
light.position.set( 0, 0, 1 );
scene.add( light );
// shadow
var canvas = document.createElement( 'canvas' );
canvas.width = 128;
canvas.height = 128;
var context = canvas.getContext( '2d' );
var gradient = context.createRadialGradient( canvas.width / 2, canvas.height / 2, 0, canvas.width / 2, canvas.height / 2, canvas.width / 2 );
gradient.addColorStop( 0.1, 'rgba(210,210,210,1)' );
gradient.addColorStop( 1, 'rgba(255,255,255,1)' );
context.fillStyle = gradient;
context.fillRect( 0, 0, canvas.width, canvas.height );
var shadowTexture = new THREE.CanvasTexture( canvas );
var shadowMaterial = new THREE.MeshBasicMaterial( { map: shadowTexture } );
var shadowGeo = new THREE.PlaneBufferGeometry( 300, 300, 1, 1 );
var shadowMesh;
shadowMesh = new THREE.Mesh( shadowGeo, shadowMaterial );
shadowMesh.position.y = - 250;
shadowMesh.rotation.x = - Math.PI / 2;
scene.add( shadowMesh );
shadowMesh = new THREE.Mesh( shadowGeo, shadowMaterial );
shadowMesh.position.y = - 250;
shadowMesh.position.x = - 400;
shadowMesh.rotation.x = - Math.PI / 2;
scene.add( shadowMesh );
shadowMesh = new THREE.Mesh( shadowGeo, shadowMaterial );
shadowMesh.position.y = - 250;
shadowMesh.position.x = 400;
shadowMesh.rotation.x = - Math.PI / 2;
scene.add( shadowMesh );
var radius = 200;
var geometry1 = new THREE.IcosahedronBufferGeometry( radius, 1 );
var count = geometry1.attributes.position.count;
...