LibCamera-1.0 is an embedded library to keep track of where the player's camera is, relative to the world. Its most useful purpose is to position UI elements relative to the in-game world to simulate a 3D overlay.
Details
Implementation
Camera position information is retrieved through CVars saved using the SaveView() function. Those angles, relative to the player, are then transformed to world-relative coordinates using the world map's player direction arrow. Yaw offsets from FlipCameraYaw() are also taken into account.
User API
.GetCameraPosition()
Returns the pitch, yaw, and distance of the camera from the player.
Code:
Pitch, Yaw, Distance = LibStub( "LibCamera-1.0" ).GetCameraPosition();
PitchThe pitch of the camera, in radians. 0 represents parallel to the horizon, and looking downwards from there increases the pitch value. Note that pitch is only bounded by the pitchLimit console command, and can go above 2π and below -2π.
YawThe yaw of the camera, in radians. 0 represents due north, and the value increases as the camera looks counter-clockwise. Range of [0,2π).
DistanceThe distance from the camera to the player, in meters. Range of [0,∞).
.GetCameraDistance()
Returns only the distance of the camera from the player.
Code:
Distance = LibStub( "LibCamera-1.0" ).GetCameraDistance();
DistanceThe distance from the camera to the player, in meters. Range of [0,∞).
Note: Camera data will not be available unless at least one callback is registered to recieve either "LibCamera_Update" or "LibCamera_UpdateDistance" messages below.
CallbackHandler-1.0 Messages
"LibCamera_Update"Fired only when the player's camera moves relative to the world, and at most once per frame. The arguments provided are identical to the return values of .GetCameraPosition() above.
"LibCamera_UpdateDistance"Fired only when the player's camera zoom changes, and at most once per frame. The arguments provided are identical to the return values of .GetCameraDistance() above.