Skip to content

Instantly share code, notes, and snippets.

@bitbrain
Created December 30, 2015 13:27
Show Gist options
  • Save bitbrain/70582e62c18d1e009bd8 to your computer and use it in GitHub Desktop.
Save bitbrain/70582e62c18d1e009bd8 to your computer and use it in GitHub Desktop.
pan
private float calculatePanning(Vector3 position) {
if (camera != null) {
tmp.set(camera.up);
tmp.crs(camera.direction);
tmp.nor();
final float lenX = camera.position.x - position.x;
final float lenY = camera.position.y - position.y;
final float lenZ = camera.position.z - position.z;
final float clampX = tmp.dot(new Vector3(lenX, lenY, lenZ));
return MathUtils.clamp(clampX / MAX_PAN_DISTANCE, -1f, 1f);
} else {
return 0f;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment