I'm currently working on implementing a click event for a mesh (cube) in order to perform some processing tasks.
var cubeFor3D = new THREE.Mesh(new THREE.CubeGeometry(40,80,40),img3D);
scene.add(cubeFor3D);
//
renderer.render(scene,camera);
//
animate();
//Track the click on cube3d
cubeFor3D.on('click', function(){
// response to click...
console.log('you have clicked on cube 2D');
});
Upon running the code, I encountered an error in the web console:
TypeError: cubeFor3D.on is not a function
The API documentation suggests using the following syntax:
mesh.on('click',..
However, it seems like I should replace mesh
with the actual name of my mesh. I am probably making a mistake somewhere. Any help would be appreciated.
I have included the API JS file in my document:
<script src='threex.domevent.js'></script>