JSFiddle - React, Tailwind, and code Playground

by marquizzo

CSS

body {
	  margin: 0;
}

JavaScript

import * as THREE from "https://cdn.skypack.dev/three@0.133";
import { OrbitControls } from 'https://cdn.skypack.dev/three@0.133/examples/jsm/controls/OrbitControls.js';

var camera, scene, renderer;
var geometry, material;
var mainBox, box;
const boxes = [];
function init() {
  camera = new THREE.PerspectiveCamera( 
    70, window.innerWidth / window.innerHeight, 0.01, 10 );
  camera.position.z = 0.5;
  scene = new THREE.Scene();
  geometry = new THREE.BoxGeometry( 0.2, 0.2, 0.2 );
  material = new THREE.MeshNormalMaterial();
  renderer = new THREE.WebGLRenderer( { antialias: true } );
  renderer.setSize( window.innerWidth, window.innerHeight );
  document.body.appendChild( renderer.domElement );
  mainBox = new THREE.Mesh( geometry, material );
  scene.add(mainBox);
  
  const controls = new OrbitControls(camera, renderer.domElement);

}

function animate() {
    requestAnimationFrame( animate );
    mainBox.rotation.x += 0.01;
    mainBox.rotation.y += 0.02;
    renderer.render( scene, camera );
}

init();
animate();