@Override
  public boolean touchDragged(int x, int y, int pointer) {
    Ray ray = camera.getPickRay(x, y);
    Intersector.intersectRayPlane(ray, plane, curr);

    if (!(last.x == -1 && last.y == -1 && last.z == -1)) {
      ray = camera.getPickRay(last.x, last.y);
      Intersector.intersectRayPlane(ray, plane, delta);
      delta.sub(curr);
      camera.position.add(delta.x, delta.y, delta.z);
    }
    last.set(x, y, 0);
    return false;
  }
  private int getObject(int screenX, int screenY) {
    Ray ray = cam.getPickRay(screenX, screenY);

    int result = -1;
    float distance = -1;

    for (int i = 0; i < instances.size; ++i) {
      final ObjectInstance instance = (ObjectInstance) instances.get(i);
      if (instance.equals(pitchInstance)) continue;
      instance.transform.getTranslation(position);
      position.add(instance.center);

      final float len =
          ray.direction.dot(
              position.x - ray.origin.x, position.y - ray.origin.y, position.z - ray.origin.z);
      if (len < 0f) continue;

      float dist2 =
          position.dst2(
              ray.origin.x + ray.direction.x * len,
              ray.origin.y + ray.direction.y * len,
              ray.origin.z + ray.direction.z * len);

      if (distance >= 0f && dist2 > distance) continue;
      if (dist2 <= instance.radius * instance.radius) {
        result = i;
        distance = dist2;
      }
    }
    return result;
  }
 public void shoot(final float x, final float y) {
   // Shoot a box
   Ray ray = camera.getPickRay(x, y);
   Entity entity = world.add("box", ray.origin.x, ray.origin.y, ray.origin.z);
   entity.color.set(
       0.5f + 0.5f * (float) Math.random(),
       0.5f + 0.5f * (float) Math.random(),
       0.5f + 0.5f * (float) Math.random(),
       1f);
   entity.body.applyCentralImpulse(ray.direction.mul(30f));
 }