JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdn.jsdelivr.net/npm/three@0.125/build/three.js"></script>
<video id="video" loop muted crossOrigin="anonymous" playsinline style="display:none">
<source src="https://threejs.org/examples/textures/sintel.ogv" type='video/ogg; codecs="theora, vorbis"'>
<source src="https://threejs.org/examples/textures/sintel.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
</video>
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 = 1;
scene = new THREE.Scene();
const loader = new THREE.TextureLoader();
const texture = loader.load( 'https://threejs.org/examples/textures/uv_grid_opengl.jpg' );
const video = document.getElementById( 'video' );
const videoTexture = new THREE.VideoTexture( video );
geometry = new THREE.PlaneGeometry();
material = new THREE.MeshBasicMaterial( { map: texture } );
setTimeout( function() {
material.map = videoTexture;
video.play();
}, 2000 );
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 );
}
function animate() {
requestAnimationFrame( animate );
renderer.render( scene, camera );
}