Created
February 1, 2015 16:13
-
-
Save AVGP/59d1bd84a816f4b3f04d to your computer and use it in GitHub Desktop.
Three.js livecoding arena - WebcamTexture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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