Skip to content

API reference / @jsprismarine/protocol / CameraSplineDefinition

Class: CameraSplineDefinition ​

Defined in: protocol/src/structure/CameraSplineDefinition.ts:55

A CameraSplineDefinition: a named camera path a behavior pack defines and /camera plays back by name, as CameraSplinePacket lists them.

Protocol 2193 wire order: 0. name: string, "namespace:name".

  1. total_time: little-endian float, the playback length in seconds.
  2. spline_type: optional. A presence byte, then a CameraSplineType string when present. Catmull-Rom when absent.
  3. control_points: varuint32 count, then one position Vec3 per point, three little-endian floats.
  4. progress_key_frames: varuint32 count, then per frame progress and time as floats and easing as an optional string.
  5. rotation_key_frames: varuint32 count, then per frame rotation as a Vec3, time as a float and easing as an optional string.

Strings are a varuint32 byte length followed by UTF-8. The schema lists spline_type and both easing fields outside required, so each carries a presence byte. The key frames of CameraInstructionPacket differ: their easing is required and written bare. https://mojang.github.io/bedrock-protocol-docs/1.26.51/types/camera-spline-definition/

Extends ​

Constructors ​

Constructor ​

new CameraSplineDefinition(name?, totalTime?, splineType?, controlPoints?, progressKeyFrames?, rotationKeyFrames?): CameraSplineDefinition

Defined in: protocol/src/structure/CameraSplineDefinition.ts:66

Creates a definition. Every parameter has a default so the static deserialize can construct an instance before reading the stream.

Parameters ​

name? ​

string = ''

name, the namespaced spline identifier.

totalTime? ​

number = 0

total_time in seconds.

splineType? ​

string

spline_type. Omitted when undefined, which the client reads as Catmull-Rom.

controlPoints? ​

Vec3[] = []

control_points, the positions the path passes through, in order.

progressKeyFrames? ​

SplineDefinitionProgressKeyFrame[] = []

progress_key_frames, when the camera reaches each point of the path.

rotationKeyFrames? ​

SplineDefinitionRotationKeyFrame[] = []

rotation_key_frames, the camera rotation over time.

Returns ​

CameraSplineDefinition

Overrides ​

NetworkStructure.constructor

Properties ​

controlPoints ​

controlPoints: Vec3[] = []

Defined in: protocol/src/structure/CameraSplineDefinition.ts:70

control_points, the positions the path passes through, in order.


name ​

name: string = ''

Defined in: protocol/src/structure/CameraSplineDefinition.ts:67

name, the namespaced spline identifier.


progressKeyFrames ​

progressKeyFrames: SplineDefinitionProgressKeyFrame[] = []

Defined in: protocol/src/structure/CameraSplineDefinition.ts:71

progress_key_frames, when the camera reaches each point of the path.


rotationKeyFrames ​

rotationKeyFrames: SplineDefinitionRotationKeyFrame[] = []

Defined in: protocol/src/structure/CameraSplineDefinition.ts:72

rotation_key_frames, the camera rotation over time.


splineType? ​

optional splineType?: string

Defined in: protocol/src/structure/CameraSplineDefinition.ts:69

spline_type. Omitted when undefined, which the client reads as Catmull-Rom.


totalTime ​

totalTime: number = 0

Defined in: protocol/src/structure/CameraSplineDefinition.ts:68

total_time in seconds.

Methods ​

deserialize() ​

deserialize(stream): void

Defined in: protocol/src/structure/CameraSplineDefinition.ts:129

Reads the six fields in wire order.

Parameters ​

stream ​

NetworkBinaryStream

Returns ​

void

Throws ​

Error when a present easing string is not one of the docs' easing_function names.

Overrides ​

NetworkStructure.deserialize


serialize() ​

serialize(stream): void

Defined in: protocol/src/structure/CameraSplineDefinition.ts:100

Writes the six fields in wire order.

Parameters ​

stream ​

NetworkBinaryStream

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