Convert c# to Js?

Hello,

I have this C# script. Can someone translate it to Js?
I’m afraid I can’t do it myself :frowning:

    // calculate desired camera position
     
                Vector3 position = target.position - (rotation * Vector3.forward * desiredDistance + new Vector3(0, -targetHeight, 0));
     
         
     
                // check for collision using the true target's desired registration point as set by user using height
     
                RaycastHit collisionHit;
     
                Vector3 trueTargetPosition = new Vector3(target.position.x, target.position.y + targetHeight, target.position.z);
     
         
     
                // if there was a collision, correct the camera position and calculate the corrected distance
     
                bool isCorrected = false;
     
                if (Physics.Linecast(trueTargetPosition, position, out collisionHit))
     
                {
     
                    position = collisionHit.point;
     
                    correctedDistance = Vector3.Distance(trueTargetPosition, position);
     
                    isCorrected = true;
     
                }
     
               
     
                // For smoothing, lerp distance only if either distance wasn't corrected, or correctedDistance is more than currentDistance
     
                currentDistance = !isCorrected || correctedDistance > currentDistance ? Mathf.Lerp(currentDistance, correctedDistance, Time.deltaTime * zoomDampening) : correctedDistance;
     
         
     
                // recalculate position based on the new currentDistance
     
                position = target.position - (rotation * Vector3.forward * currentDistance + new Vector3(0, -targetHeight, 0));
     
     
                transform.position = position;

most of it are the same . you just need to change the definition of the variables . in C# it’s like

Vector3 position = ...

but in javascript you can do this like :

var position:Vector3;

or simply :

var position;