Skip to content

Instantly share code, notes, and snippets.

@evejweinberg
Created November 1, 2016 16:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evejweinberg/6deb97dc99a1ea20a50d072082c8580a to your computer and use it in GitHub Desktop.
Save evejweinberg/6deb97dc99a1ea20a50d072082c8580a to your computer and use it in GitHub Desktop.
3js video texture
video = document.createElement( 'video' );
video.height = 172;
video.width = 308;
video.src = "../asset_src/closer.mp4";
video.load(); // must call after setting/changing source
video.play();
videoImage = document.createElement( 'canvas' );
videoImageContext = videoImage.getContext( '2d' );
// background color if no video present
videoImageContext.fillStyle = '#ffffff';
videoImageContext.fillRect( 0, 0, video.width, video.height );
videoTexture = new THREE.Texture( videoImage );
videoTexture.minFilter = THREE.LinearFilter;
videoTexture.magFilter = THREE.LinearFilter;
videoTexture.format = THREE.RGBFormat;
videoTexture.needsUpdate = true;
var xCenter = Math.cos(toRadians(350)) * 72;
var zCenter = Math.sin(toRadians(350)) * 72;
var geo = new THREE.BoxGeometry(20.6,12,.01)
var mat = new THREE.MeshStandardMaterial({overdraw: 0.5, color: mint, map: videoTexture,roughness: 1})
//global variable
mainVidLady = new THREE.Mesh(geo,mat)
mainVidLady.position.set(xCenter,2,zCenter)
mainVidLady.name = "target";
mainVidLady.rotation.y = 1.5708
mainVidLady.castShadow = true;
mainVidLady.receiveShadow = true;
scene.add(mainVidLady)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment