When my raycaster intersects an object for 2 seconds, I want to update the object's texture.
I attempted to use the clock function, but I am unsure of how to properly implement it.
var clock = new THREE.Clock();
clock.autoStart = true;
var intersects = raycaster.intersectObjects( pickable, true );
if ( intersects.length > 0 ) {
if (!clock.running) clock.start()
if (clock.getElapsedTime() > 2) {
if (intersects[0].object.name === "btn_meeting_01") {
mesh_sphere.material.map = THREE.ImageUtils.loadTexture( "textures/DIVE_IMMO_00004.jpg");
}
if (intersects[0].object.name === "btn_lobby_01") {
mesh_sphere.material.map = THREE.ImageUtils.loadTexture( "textures/DIVE_IMMO_00003.jpg");
}
if (intersects[0].object.name === "btn_restaurant_01") {
mesh_sphere.material.map = THREE.ImageUtils.loadTexture( "textures/DIVE_IMMO_00002.jpg");
}
if (intersects[0].object.name === "btn_entrance_01") {
mesh_sphere.material.map = THREE.ImageUtils.loadTexture( "textures/DIVE_IMMO_00001.jpg");
}
if (intersects[0].object.name === "btn_exterior") {
mesh_sphere.material.map = THREE.ImageUtils.loadTexture( "textures/DIVE_IMMO_00000.jpg");
};
}
}
Could you please point out any issues with this code snippet?