Skip to content

API reference / @jsprismarine/protocol / CameraPreset

Class: CameraPreset ​

Defined in: protocol/src/structure/CameraPreset.ts:168

One camera preset, the docs' CameraPresets type, as CameraPresetsPacket lists them.

Protocol 2193 wire order: Name and Inherit From as strings (a varuint32 byte length, then UTF-8), then fields 2 to 21 each as a presence byte followed by the value when the byte is 1: Pos X, Pos Y, Pos Z, Rot X, Rot Y and Rotation Speed as float LE; Snap to Target as a boolean; Horizontal Rotation Limit and Vertical Rotation Limit as Vec2; Continue Targeting as a boolean; Block Listening Radius as float LE; View Offset as Vec2; Entity Offset as Vec3; Radius, Yaw Limit Min and Yaw Limit Max as float LE; Listener as a uint8; Player Effects as a boolean; Aim Assist as its own four optional fields (Preset Id string, Target Mode uint8, View Angle Vec2, Distance float LE); Control Scheme as a uint8. Then Apply Inherited Starting Rotation as a boolean with no presence byte, and Starting Rotation as an optional Vec2.

The 1.26.51 schema lists every field as required, but the client reads a presence byte before each of the fields above (gophertunnel and PocketMine agree), and the 1.26.60 preview schema marks the same fields optional. https://mojang.github.io/bedrock-protocol-docs/1.26.51/types/camera-presets/

Extends ​

Constructors ​

Constructor ​

new CameraPreset(data?): CameraPreset

Defined in: protocol/src/structure/CameraPreset.ts:174

Creates a preset. The default is an unnamed root preset with no optional field, so the static deserialize can construct an instance before reading the stream.

Parameters ​

data? ​

CameraPresetData = ...

The preset's fields.

Returns ​

CameraPreset

Overrides ​

NetworkStructure.constructor

Properties ​

data ​

data: CameraPresetData

Defined in: protocol/src/structure/CameraPreset.ts:175

The preset's fields.

Methods ​

deserialize() ​

deserialize(stream): void

Defined in: protocol/src/structure/CameraPreset.ts:230

Reads the preset in wire order. An absent optional field is left undefined.

Parameters ​

stream ​

BinaryStream

Returns ​

void

Overrides ​

NetworkStructure.deserialize


serialize() ​

serialize(stream): void

Defined in: protocol/src/structure/CameraPreset.ts:197

Writes the preset in wire order, one presence byte per optional field.

Parameters ​

stream ​

BinaryStream

Returns ​

void

Overrides ​

NetworkStructure.serialize


deserialize() ​

static deserialize<T>(this, stream): T

Defined in: protocol/src/NetworkStructure.ts:28

Deserializes the network structure from a binary stream. The constructor runs with no arguments before the stream is read, so the class must tolerate that.

Type Parameters ​

T ​

T extends NetworkStructure

Parameters ​

this ​

Constructor<T>

stream ​

NetworkBinaryStream

The binary stream to deserialize from.

Returns ​

T

An instance of the class T.

Inherited from ​

NetworkStructure.deserialize