Camera - Camera Presets
anvil.api.camera.camera
Camera presets.
CameraPreset
Bases: JsonFile[_CameraPresetFile]
A custom camera preset, used with the /camera command or the Script API. Settings
it does not set are inherited from the preset it is based on.
Written to the behavior pack's cameras/presets/ folder.
Documentation reference
identifier
property
The file's identifier.
name
property
The identifier's name, without its namespace.
__init__(name, inherit_from)
Initializes the CameraPreset instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The preset's name, also its file name. The identifier is
|
required |
inherit_from
|
CameraPresets | CameraPreset | str
|
The preset to inherit settings
from: a vanilla |
required |
__schema__()
classmethod
The JSON Schema (draft 2020-12) of this file: the schema of its _document_type, with
the file's type as title and where it is written under x-anvil-file.
Raises:
| Type | Description |
|---|---|
TypeError
|
When the class is an abstract file base, with no document type. |
aim_assist(preset, target_mode=AimAssistTargetMode.Distance, angle=(30.0, 30.0), distance=8.0, replace_reticle=False)
Uses an aim assist preset while the camera preset is active. It overrides the
/aimassist command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
preset
|
AimAssistPreset
|
The aim assist preset. |
required |
target_mode
|
AimAssistTargetMode
|
What is evaluated first. Defaults to Distance. |
Distance
|
angle
|
tuple[float, float]
|
The horizontal and vertical angles of the targeting cone, each from 10 to 90 degrees. Defaults to (30, 30). |
(30.0, 30.0)
|
distance
|
float
|
How far targets are searched, from 1 to 16 blocks. Defaults to 8. |
8.0
|
replace_reticle
|
bool
|
Copies |
False
|
control_scheme(value)
Sets how player input moves the player while the preset is active.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ControlSchemes
|
The control scheme. |
required |
entity_offset(x_offset, y_offset, z_offset)
Sets the offset from the tracked entity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_offset
|
float
|
The X offset. |
required |
y_offset
|
float
|
The Y offset. |
required |
z_offset
|
float
|
The Z offset. |
required |
extend_player_rendering(value=True)
Renders the player, their ride and leashed entities at further distances, so the camera can move far from the player.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
bool
|
If rendering is extended. Defaults to True. |
True
|
focus_target(rotation_speed=0.0, snap_to_target=False, horizontal_rotation_limit=(0.0, 360.0), vertical_rotation_limit=(0.0, 180.0), continue_targeting=False, tracking_radius=50.0)
Tracks a target entity, set with /camera @s target_entity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rotation_speed
|
float
|
The tracking speed in degrees per second, 0 for perfect tracking. Defaults to 0. |
0.0
|
snap_to_target
|
bool
|
Snaps to the target on the first frame, then
tracks at |
False
|
horizontal_rotation_limit
|
tuple[float, float]
|
How far the camera turns left and right from where it first looked, adding up to 360 degrees at most. Defaults to (0, 360). |
(0.0, 360.0)
|
vertical_rotation_limit
|
tuple[float, float]
|
The lowest and highest pitch, 0 straight down and 180 straight up, adding up to 180 degrees at most. Defaults to (0, 180). |
(0.0, 180.0)
|
continue_targeting
|
bool
|
Keeps tracking a target that leaves the limits or the radius. Defaults to False. |
False
|
tracking_radius
|
float
|
The distance targets are tracked within, in blocks. Defaults to 50. |
50.0
|
listener(value)
Sets where sounds are heard from.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
bool | Literal['player']
|
True or |
required |
player_effects(value)
Sets if effects on the player, such as night vision or blindness, change how the game renders while the preset is active.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
bool
|
If player effects render. |
required |
position(x=None, y=None, z=None)
Sets the camera position. Coordinates left out keep the inherited value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The X position. |
None
|
y
|
float
|
The Y position. |
None
|
z
|
float
|
The Z position. |
None
|
queue()
Queues the camera preset for export.
radius(radius)
Sets the distance from the target of boom, follow and orbit cameras.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
float
|
The distance, from 0.1 to 100 blocks. |
required |
rotation(x=None, y=None)
Sets the camera rotation. Angles left out keep the inherited value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The pitch, from -90 to 90 degrees. Positive looks down. |
None
|
y
|
float
|
The yaw, in degrees. |
None
|
starting_rotation(x=None, y=None)
Sets the rotation the camera starts with. Angles left out keep the inherited value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The pitch, from -90 to 90 degrees. |
None
|
y
|
float
|
The yaw, in degrees. |
None
|
view_offset(x_offset, y_offset)
Sets the view offset from the camera position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_offset
|
float
|
The X offset. |
required |
y_offset
|
float
|
The Y offset. |
required |