JSFiddle - React, Tailwind, and code Playground
by grano
HTML
<script src="https://threejs.org/build/three.min.js"></script>
<script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>
CSS
body {
margin: 0;
}
JavaScript
let camera, scene, renderer;
init();
animate();
function init() {
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 10 );
scene = new THREE.Scene();
geometry = new THREE.PlaneBufferGeometry();
material = new THREE.MeshNormalMaterial( { side: THREE.DoubleSide } );
const count = 4;
const radius = 2;
for ( let i = 0; i < count; i ++ ) {
const mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
var s = i / count * Math.PI * 2;
mesh.position.x = radius * Math.sin( s );
mesh.position.z = radius * Math.cos( s );
mesh.lookAt( scene.position );
}
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
const controls = new THREE.OrbitControls( camera, renderer.domElement );
controls.target.z -= 0.01;
}
function animate() {
requestAnimationFrame( animate );
renderer.render( scene, camera );
}