< Summary

Class:BIWFloorLoading
Assembly:BuilderInWorld
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/Scripts/BIWFloorLoading.cs
Covered lines:10
Uncovered lines:2
Coverable lines:12
Total lines:34
Line coverage:83.3% (10 of 12)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Initialize(...)0%2100%
LateUpdate()0%2.012088.89%
GetCameraPlaneDistance(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/Scripts/BIWFloorLoading.cs

#LineLine coverage
 1using System.Collections;
 2using System.Collections.Generic;
 3using UnityEngine;
 4
 5public class BIWFloorLoading : MonoBehaviour
 6{
 7    private Camera builderCamera = null;
 8
 9    private const float RELATIVE_SCALE_RATIO = 0.032f;
 10
 011    public void Initialize(Camera camera) { builderCamera = camera; }
 12
 13    private void LateUpdate()
 14    {
 215        if ( builderCamera == null )
 016            return;
 17
 218        Transform cameraTransform = builderCamera.transform;
 219        Quaternion cameraRotation = cameraTransform.rotation;
 220        Vector3 position = transform.position;
 21
 222        transform.LookAt(position + cameraRotation * Vector3.forward,
 23            cameraRotation * Vector3.up);
 24
 225        float dist = GetCameraPlaneDistance(builderCamera, position);
 226        transform.localScale = new Vector3(RELATIVE_SCALE_RATIO * dist, RELATIVE_SCALE_RATIO * dist, RELATIVE_SCALE_RATI
 227    }
 28
 29    private static float GetCameraPlaneDistance(Camera camera, Vector3 objectPosition)
 30    {
 231        Plane plane = new Plane(camera.transform.forward, camera.transform.position);
 232        return plane.GetDistanceToPoint(objectPosition);
 33    }
 34}