JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://threejs.org/build/three.min.js"></script>
<script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>
<script src="https://threejs.org/examples/js/renderers/CanvasRenderer.js"></script>
<script src="https://threejs.org/examples/js/renderers/Projector.js"></script>
CSS
body {
background-color: #000;
margin: 0px;
overflow: hidden;
}
JavaScript
// Simple three.js example
var mesh, renderer, scene, camera, controls;
init();
animate();
function init() {
// renderer
renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
// scene
scene = new THREE.Scene();
// camera
camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 10000 );
camera.position.set( 10, 10, 10 );
// controls
controls = new THREE.OrbitControls( camera );
// ambient
scene.add( new THREE.AmbientLight( 0x222222 ) );
// light
var light = new THREE.DirectionalLight( 0xffffff, 1 );
light.position.set( 20, 20, 0 );
scene.add( light );
// axes
scene.add( new THREE.AxisHelper( 20 ) );
// shape
shape = new THREE.Shape();
shape.moveTo( -20, 0 );
shape.lineTo( -6, -10 );
shape.lineTo( 8, 20 );
shape.lineTo( 0, 40 );
// geometry
var geometry = new THREE.ShapeGeometry( shape );
// material
var material = new THREE.LineBasicMaterial( {
color: 0xff0000,
linewidth: 30,
linecap: 'round',
linejoin: 'miter'
} );
// line
line = new THREE.Line( geometry, material );
scene.add( line );
}
function animate() {
requestAnimationFrame( animate );
//controls.update();
renderer.render( scene, camera );
}