function avoidObstacleSpeed(boid,minDistanceLight,continuityRatio){
	// Compute Next Bulb Position
	let length = view.length
	let z0 = view.z0
	let w0 = Math.sqrt(g/length)
	let theta = Math.PI/180*view.theta0*Math.cos(w0*(t+1)*1/20)
	var NextBulbPosition = new THREE.Vector3(0,length*Math.sin(theta),z0-length*Math.cos(theta))

	// Compute Next Boid Position : continuityRatio is the proportion of old speed vector kept in new speed vector
	var boidPosition = new THREE.Vector3(boid.position.x,boid.position.y,boid.position.z)
	var NextBoidSpeed = ((NextBulbPosition.clone().addScaledVector(boidPosition,-1)).multiplyScalar(1-continuityRatio)).addScaledVector(boid.speed,continuityRatio).normalize()
	var NextBoidPosition = boidPosition.clone().addScaledVector(NextBoidSpeed,SpeedScale)

	 // Check if there is no collision with bulb
	if (NextBoidPosition.distanceTo(NextBulbPosition)<=minDistanceLight){
		NextBoidSpeed = boidPosition.clone().addScaledVector(NextBulbPosition,-continuityRatio).addScaledVector(boid.speed,continuityRatio).normalize()
	}
	return [NextBoidSpeed, NextBulbPosition]
}
// First rule : follow the bulb if it doesn't lead to collision, otherwise, flee the bulb
First rule : follow the bulb if it doesn't lead to collision, otherwise, flee the bulb
First rule : follow the bulb if it doesn ' t lead to collision otherwise flee the bulb
function avoidObstacleSpeed(boid,minDistanceLight,continuityRatio){
	let length = view.length
	let z0 = view.z0
	let w0 = Math.sqrt(g/length)
	let theta = Math.PI/180*view.theta0*Math.cos(w0*(t+1)*1/20)
	var NextBulbPosition = new THREE.Vector3(0,length*Math.sin(theta),z0-length*Math.cos(theta))
	var boidPosition = new THREE.Vector3(boid.position.x,boid.position.y,boid.position.z)
	var NextBoidSpeed = ((NextBulbPosition.clone().addScaledVector(boidPosition,-1)).multiplyScalar(1-continuityRatio)).addScaledVector(boid.speed,continuityRatio).normalize()
	var NextBoidPosition = boidPosition.clone().addScaledVector(NextBoidSpeed,SpeedScale)
	if (NextBoidPosition.distanceTo(NextBulbPosition)<=minDistanceLight){
		NextBoidSpeed = boidPosition.clone().addScaledVector(NextBulbPosition,-continuityRatio).addScaledVector(boid.speed,continuityRatio).normalize()
	}
	return [NextBoidSpeed, NextBulbPosition]
}
function avoidObstacleSpeed ( boid , minDistanceLight , continuityRatio ) { let length = view . length let z0 = view . z0 let w0 = Math . sqrt ( g / length ) let theta = Math . PI / 180 * view . theta0 * Math . cos ( w0 * ( t + 1 ) * 1 / 20 ) var NextBulbPosition = new THREE . Vector3 ( 0 , length * Math . sin ( theta ) , z0 - length * Math . cos ( theta ) ) var boidPosition = new THREE . Vector3 ( boid . position . x , boid . position . y , boid . position . z ) var NextBoidSpeed = ( ( NextBulbPosition . clone ( ) . addScaledVector ( boidPosition , - 1 ) ) . multiplyScalar ( 1 - continuityRatio ) ) . addScaledVector ( boid . speed , continuityRatio ) . normalize ( ) var NextBoidPosition = boidPosition . clone ( ) . addScaledVector ( NextBoidSpeed , SpeedScale ) if ( NextBoidPosition . distanceTo ( NextBulbPosition ) <= minDistanceLight ) { NextBoidSpeed = boidPosition . clone ( ) . addScaledVector ( NextBulbPosition , - continuityRatio ) . addScaledVector ( boid . speed , continuityRatio ) . normalize ( ) } return [ NextBoidSpeed , NextBulbPosition ] }
First rule : follow the bulb if it doesn't lead to collision, otherwise, flee the bulb
First rule : follow the bulb if it doesn ' t lead to collision otherwise flee the bulb
// Compute Next Bulb Position // Compute Next Boid Position : continuityRatio is the proportion of old speed vector kept in new speed vector // Check if there is no collision with bulb