Blinking Objects

i have a scene with several spheres and cubes with different colors and dimensions. I want the spheres to blink each 4 seconds and I need your help to control the timing.
thank you

If you use a THREE.Clock (there’s many examples that use one) you can have a time variable in seconds:

var clock = new THREE.Clock();
var time = 0;
var previousFrameBlinked = false;
// In render():
	var deltaTime = clock.getDelta();

	var blink = Math.floor( time / 4 ) & 1;

	if ( previousFrameBlinked !== blink )



	previousFrameBlinked = blink;

	time += deltaTime;

1 Like

Can i know what is the approach used to blink that spheres in the above mentioned example function blinkSpheres();
I need a similar kind of approach in my project where I have number of mesh in a scene and on click of any mesh, I need to blink that mesh for user to know which mesh he clicked and perform other actions like Delete, Copy, etc.

I need your help to proceed.

Thank you.

After lot of research and experimenting. i could notice the RequestAnimationFrame would consume most of CPU energy making the computer slow. Due to which i could come up with a solution to blink is as below.
Created wireframe all objects in scene and change color of wireframe, But not calling RequestAnimationFrame instead using SetInterval function, which does not impact speed of the screen.
function blink_effect() {
if (select_color == 0x000000) {
select_color = 0xFFFFFF;
} else {
select_color = 0x000000;
for (var i = 0; i < INTERSECTED.length; i++) {
var myVar;
var select_color = 0x000000;

function render_animate_selected() {
myVar = setInterval(function () {blink_effect()}, 500);