My jQuery:
<script type="text/javascript">
$(document).ready(function(){
$("#button").click(function(){
cube[0].mesh.material.uniforms.texture.value = THREE.ImageUtils.loadTexture("textures/envmap.png");
cube[0].mesh.material.uniforms.texture.needsUpdate = true;
});
});
</script>
I have an array of cubes, and I want to be able to change the texture of the cube when clicking on the #button div.
I get this error in chrome when clicking on the div:
Uncaught TypeError: Cannot read property 'material' of undefined
How is it possible to change the texture or color for cube[0] that is a THREE.CubeGeometry object.
I have a JS fiddle here: http://jsfiddle.net/SCXNQ/559/