function drawSpline(beginning,end,clr){
	// Compute y sign to know which way to bend the wire
	let ySign = Math.sign((end.y+beginning.y)/2)
	// Compute the bending strength and multiply per Math.abs(beginning.y) to ensure it decreases as the bulb gets closer to the theta = 0 position, and also to ensure
	// that the shift is null if thete is null (no discontinuity in the wire movement)
	let appliedRatio = -shiftRatio*Math.abs(beginning.y)
	// Compute middle line position vector and the direction vector from the roof to the bulb
	let midVector = new THREE.Vector3( 0, (end.y+beginning.y)/2, (end.z+beginning.z)/2 )
	let positionVector = new THREE.Vector3(0,end.y-beginning.y,end.z-beginning.z)
	// Compute the orthogonal vector to the direction vector (opposite sense to the bending shift)
	let orthogVector = new THREE.Vector3(0,positionVector.z,-positionVector.y).normalize() 


	// Compute the curve passing by the three points
	var curve = new THREE.CatmullRomCurve3( [
		new THREE.Vector3( beginning.x, beginning.y, beginning.z ),
		midVector.clone().addScaledVector(orthogVector,ySign*appliedRatio),
		new THREE.Vector3( end.x, end.y, end.z ),
	]);

	// Build the curve line object
	var points = curve.getPoints( 20 );
	var geometry = new THREE.BufferGeometry().setFromPoints( points );
	var material = new THREE.LineBasicMaterial( { color : clr } );
	
	// Create the final object to add to the scene
	var curveObject = new THREE.Line( geometry, material );
	return curveObject;
}
// Build a spline representing the wire between the roof and the bulb. The new middle point is computed as the middle point shifted orthogonally from the lign by shiftRatio
Build a spline representing the wire between the roof and the bulb. The new middle point is computed as the middle point shifted orthogonally from the lign by shiftRatio
Build a spline representing the wire between the roof and the bulb . The new middle point is computed as the middle point shifted orthogonally from the lign by shiftRatio
function drawSpline(beginning,end,clr){
	let ySign = Math.sign((end.y+beginning.y)/2)
	let appliedRatio = -shiftRatio*Math.abs(beginning.y)
	let midVector = new THREE.Vector3( 0, (end.y+beginning.y)/2, (end.z+beginning.z)/2 )
	let positionVector = new THREE.Vector3(0,end.y-beginning.y,end.z-beginning.z)
	let orthogVector = new THREE.Vector3(0,positionVector.z,-positionVector.y).normalize() 
	var curve = new THREE.CatmullRomCurve3( [
		new THREE.Vector3( beginning.x, beginning.y, beginning.z ),
		midVector.clone().addScaledVector(orthogVector,ySign*appliedRatio),
		new THREE.Vector3( end.x, end.y, end.z ),
	]);
	var points = curve.getPoints( 20 );
	var geometry = new THREE.BufferGeometry().setFromPoints( points );
	var material = new THREE.LineBasicMaterial( { color : clr } );
	var curveObject = new THREE.Line( geometry, material );
	return curveObject;
}
function drawSpline ( beginning , end , clr ) { let ySign = Math . sign ( ( end . y + beginning . y ) / 2 ) let appliedRatio = - shiftRatio * Math . abs ( beginning . y ) let midVector = new THREE . Vector3 ( 0 , ( end . y + beginning . y ) / 2 , ( end . z + beginning . z ) / 2 ) let positionVector = new THREE . Vector3 ( 0 , end . y - beginning . y , end . z - beginning . z ) let orthogVector = new THREE . Vector3 ( 0 , positionVector . z , - positionVector . y ) . normalize ( ) var curve = new THREE . CatmullRomCurve3 ( [ new THREE . Vector3 ( beginning . x , beginning . y , beginning . z ) , midVector . clone ( ) . addScaledVector ( orthogVector , ySign * appliedRatio ) , new THREE . Vector3 ( end . x , end . y , end . z ) , ] ) ; var points = curve . getPoints ( 20 ) ; var geometry = new THREE . BufferGeometry ( ) . setFromPoints ( points ) ; var material = new THREE . LineBasicMaterial ( { color : clr } ) ; var curveObject = new THREE . Line ( geometry , material ) ; return curveObject ; }
Build a spline representing the wire between the roof and the bulb.
Build a spline representing the wire between the roof and the bulb .
// Compute y sign to know which way to bend the wire // Compute the bending strength and multiply per Math.abs(beginning.y) to ensure it decreases as the bulb gets closer to the theta = 0 position, and also to ensure // that the shift is null if thete is null (no discontinuity in the wire movement) // Compute middle line position vector and the direction vector from the roof to the bulb // Compute the orthogonal vector to the direction vector (opposite sense to the bending shift) // Compute the curve passing by the three points // Build the curve line object // Create the final object to add to the scene