Skip to main content

Class: BlockRotation

A block rotation consists of two rotations: one is the axis this block is pointing towards, and the other is the rotation around that axis (y-rotation). Y-rotation is only applicable to the positive and negative x-axis.

Constructors​

constructor​

• new BlockRotation(value?, yRotation?): BlockRotation

Create a new block rotation.

Parameters​

NameTypeDefault valueDescription
valuenumberPY_ROTATIONThe axis this block is pointing towards.
yRotationnumber0The rotation around the axis this block is pointing towards, rounded to the nearest (360 / 16) degrees.

Returns​

BlockRotation

Properties​

value​

• value: number

The axis this block is pointing towards.


yRotation​

• yRotation: number

The rotation around the axis this block is pointing towards, rounded to the nearest (360 / 16) degrees.

Methods​

decode​

▸ decode(rotation): number[]

Decode a block rotation into two rotations.

Parameters​

NameTypeDescription
rotationBlockRotationThe block rotation to decode.

Returns​

number[]

Two values, the first is the axis this block is pointing towards, and the second is the rotation around that axis.


encode​

▸ encode(value, yRotation?): BlockRotation

Encode two rotations into a new block rotation instance.

Parameters​

NameTypeDefault valueDescription
valuenumberundefinedThe axis this block is pointing towards.
yRotationnumber0The rotation around the axis this block is pointing towards.

Returns​

BlockRotation

A new block rotation.


fromServerRotation​

▸ fromServerRotation(rotation): BlockRotation

Resolve a rotation that may still be in its server-serialized rule shape ({ "PX": angle }) into a block rotation instance. Server-authored block rules arrive as raw JSON and are handed to the wasm mesher untouched, so they are normalized here at evaluation time instead of at parse time.

Parameters​

NameType
rotationSerializedBlockRotation | BlockRotation

Returns​

BlockRotation


rotateAABB​

▸ rotateAABB(aabb, yRotate?, translate?): AABB

Rotate an axis aligned bounding box by this block rotation, recalculating the new maximum and minimum coordinates to this AABB.

Parameters​

NameTypeDefault valueDescription
aabbAABBundefinedThe axis aligned bounding box to be rotated.
yRotatebooleantrueWhether or not should the y-rotation be applied.
translatebooleantrueWhether or not should the translation be applied.

Returns​

AABB

A new axis aligned bounding box.


rotateNode​

▸ rotateNode(node, yRotate?, translate?): void

Rotate a 3D coordinate by this block rotation.

Parameters​

NameTypeDefault valueDescription
nodeCoords3undefinedA 3D coordinate in the form of [x, y, z] to be rotated by this block rotation.
yRotatebooleantrueWhether or not should the y-rotation be applied.
translatebooleantrueWhether or not should the translation be applied.

Returns​

void


rotateTransparency​

▸ rotateTransparency(«destructured»): boolean[]

Parameters​

NameType
«destructured»[boolean, boolean, boolean, boolean, boolean, boolean]

Returns​

boolean[]