JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//cdn.rawgit.com/mrdoob/three.js/master/build/three.min.js"></script>
<script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>
JavaScript
var camera, scene, renderer;
var geometry, material, mesh;
init();
animate();
function init() {
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 10 );
camera.position.z = 4;
scene = new THREE.Scene();
scene.add( camera );
geometry = new THREE.BoxBufferGeometry();
material = new THREE.MeshStandardMaterial();
mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
var controls = new THREE.OrbitControls( camera, renderer.domElement );
// lights
var ambientLight = new THREE.AmbientLight( 0xffffff, 0.4 );
// ambientLight.wrapAround = true; this proeprty does not exist
scene.add(ambientLight);
var directionalLightColor = new THREE.Color( 0xffffff );
var directionalLight = new THREE.DirectionalLight( directionalLightColor, 0.6 );
directionalLight.castShadow = true;
directionalLight.shadow.camera.near = 1;
directionalLight.shadow.camera.far = 10;
directionalLight.shadow.camera.left = -5;
directionalLight.shadow.camera.right = 5;
directionalLight.shadow.camera.top = 5;
directionalLight.shadow.camera.bottom = -5;
// directionalLight.distance = 10; this proeprty does not exist
// directionalLight.intensity = 14.0; the value 14 is way too high
directionalLight.shadow.mapSize.height = 1024;
directionalLight.shadow.mapSize.width = 1024;
camera.add( directionalLight );
}
function animate() {
requestAnimationFrame( animate );
renderer.render( scene, camera );
}