コード例 #1
0
        public void ClampCameraToBounds(LookAtSurfaceCamera camera)
        {
            var maxY = boundsCenter.y + (boundsSize.y * .5f);
            var minY = boundsCenter.y - (boundsSize.y * .5f);
            var distanceToTarget = camera.GetDistanceToTarget();
            if (distanceToTarget >= maxY)
                camera.SetDistanceToTarget(maxY);
            else if (distanceToTarget <= minY)
                camera.SetDistanceToTarget(minY);

            var minX = boundsCenter.x - (boundsSize.x * .5f);
            var lookTarget = camera.GetLookTarget();
            var delta = lookTarget - boundsCenter;
            if (lookTarget.x <= minX)
                camera.TranslateLookTargetTo(new Vector3(minX, lookTarget.y, lookTarget.z));
        }
コード例 #2
0
        public void SetUp()
        {
            surfaceOrigin = Vector3.zero;
            surfaceNormal = Vector3.up;
            surfaceUp = Vector3.forward;
            surface = new PlaneSurface(surfaceOrigin, surfaceNormal, surfaceUp);

            initialCameraDistance = 100f;
            initialLookTarget = Vector3.zero;
            timeDelta = .25f;
            camera = Substitute.For<LookAtSurfaceCamera>();
            camera.GetDistanceToTarget().Returns(initialCameraDistance);
            camera.GetLookTarget().Returns(initialLookTarget);

            zoomSpeed = 5f;
            panSpeed = 10f;
            testObj = new PlaneMover(camera, surface, zoomSpeed, panSpeed);
        }