JSFiddle - React, Tailwind, and code Playground

by lighty1235

HTML

<script src="https://threejs.org/build/three.min.js"></script>

<script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>
<section class="main"></section>
   <section>
       <video id="video" type="video/mp4"  muted loop autoplay width="512" height="512" src="//dl.dropbox.com/s/931244iox7i0fpk/working-with-espresso.mp4" crossorigin="anonymous" ></video>
   </section>

CSS

:root {
  --main-color: #ff6f69;
}

* {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
*:before, *:after {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

*::-webkit-input-placeholder {
  color: #666;
  opacity: 1;
}

*:-moz-placeholder {
  color: #666;
  opacity: 1;
}

*::-moz-placeholder {
  color: #666;
  opacity: 1;
}

*:-ms-input-placeholder {
  color: #666;
  opacity: 1;
}

body input:focus:required:invalid,
body textarea:focus:required:invalid {
  color: #666;
}

body input:required:valid,
body textarea:required:valid {
  color: #666;
}

html, body {
  height: 100%;
}

body {
  font-size: 16px;
  min-width: 320px;
  position: relative;
  line-height: 1.65;
  overflow-x: hidden;
}

.img-responsive {
  display: block;
  max-width: 100%;
  height: auto;
}

::selection {
  background-color: #fff;
  color: #fff;
}

a, a:hover, a:focus, a:active {
  outline: none !important;
  text-decoration: none;
  color: #000;
}

.grid-container {
  display: grid;
  max-width: 1200px;
  margin: 0 auto;
}

/*min-height:32vh;*/
section {
  width: 100%;
  height: 100vh;
  display: grid;
  justify-items: center;
}

JavaScript

const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 45, window.innerWidth/window.innerHeight, 0.1, 1000 );




let renderer = new THREE.WebGLRenderer({  });
scene.background = new THREE.Color(0xdddddd);
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setClearColor(0xECF0F1);
let doc = document.querySelector('.main');
doc.appendChild( renderer.domElement );


window.addEventListener('resize', function () {
     let width = window.innerWidth;
     let height = window.innerHeight;
     renderer.setSize(width,height);
     camera.aspect = width / height;
     camera.updateProjectionMatrix();
});



let controls = new  THREE.OrbitControls(camera,renderer.domElement);

let x = 1; let y = 1; let width = 90; let height = 50; let radius = 10;
let shape = new THREE.Shape();
shape.moveTo( x, y + radius );
shape.lineTo( x, y + height - radius );
shape.quadraticCurveTo( x, y + height, x + radius, y + height );
shape.lineTo( x + width - radius, y + height );
shape.quadraticCurveTo( x + width, y + height, x + width, y + height - radius );
shape.lineTo( x + width, y + radius );
shape.quadraticCurveTo( x + width, y, x + width - radius, y );
shape.lineTo( x + radius, y );
shape.quadraticCurveTo( x, y, x, y + radius );

const video = document.getElementById( 'video' );
const texture = new THREE.VideoTexture( video );
const geometry = new THREE.PlaneGeometry(5, 2);
const material = new THREE.MeshBasicMaterial({ map: texture });

const mesh = new THREE.Mesh(geometry,material);
mesh.scale.multiplyScalar(2);
scene.add(mesh);

let localPlane = new THREE.Plane( new THREE.Vector3(  0.4, 0, 0 ), 1 );
renderer.localClippingEnabled = true;
material.clippingPlanes = [ localPlane ];
material.clipShadows = true;

document.addEventListener('DOMContentLoaded', function () {
    video.play();
});





camera.position.z = 10;

const animate = function () {
     requestAnimationFrame( animate );

     renderer.render( scene, camera );

};

animate();