Skip to content

Instantly share code, notes, and snippets.

@AVGP
Created February 1, 2015 16:13
Show Gist options
  • Save AVGP/59d1bd84a816f4b3f04d to your computer and use it in GitHub Desktop.
Save AVGP/59d1bd84a816f4b3f04d to your computer and use it in GitHub Desktop.
Three.js livecoding arena - WebcamTexture
// Setup your scene here
var tex = null;
var mat = new THREE.MeshBasicMaterial({});
var box = new THREE.Mesh(
new THREE.BoxGeometry(100, 100, 100),
mat
);
window.THREE = THREE;
var script = document.createElement("script");
script.src = "http://jeromeetienne.github.io/threex.videotexture/threex.webcamtexture.js";
script.onload = function() {
tex = new THREEx.WebcamTexture();
mat.map = tex.texture;
};
document.body.appendChild(script);
scene.add(box);
onRender = function() {
// Updates to the scene go here
if(tex) tex.update();
box.rotation.x += Math.PI / 100;
box.rotation.y += Math.PI / 100;
box.rotation.z += Math.PI / 100;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment