                     current = @camera.position
                     x = d3.interpolate(current.x, target.x)
                     y = d3.interpolate(current.y, target.y)
-                    z = d3.interpolate current.z, target.z + CAMERA_Z
+                    z = d3.interpolate current.z, target.z + z_offset
                     (t) =>
                         @camera.position.x = x(t)
                         @camera.position.y = y(t)

        .domain([0, 360])
        .range([0, Math.PI * 2])

    zoomToBoundingBoxWidth: (box, duration) ->
        width = Math.abs(box.min.x - box.max.x)

        distance_scale = 1.2

        v_fov = _radianScale @camera.fov

        # See: github.com/mrdoob/three.js/issues/1239
        h_fov = Math.atan( Math.tan(v_fov/2) * @camera.aspect )

        # See: stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene
        distance = (width / 2) / Math.tan(h_fov) * distance_scale

        target = new THREE.Vector3(0, 0, - distance)

        @zoomCameraToPosition target, duration

    getWordIndex = (line, word) ->
        expression = if word is "—" then word else "\\b#{word}\\b"

        lineObject._layout = line_layout
        lineObject

    panCameraToPosition3: (target, duration, ignoreGlobal) =>
        z_offset = if ignoreGlobal? then 0 else CAMERA_Z
        new Promise (resolve) =>
            d3.transition()
                .duration duration || 1000
