VoxelShape
Source: aabb.ts:324
Basically, a VoxelShape it a set of multiple AABB.
For example, a VoxelShape of a stair is constructed from 2 AABB, lower half and upper half.
Constructors
new VoxelShape(
xs: number[],
ys: number[],
zs: number[],
cells: BitSet | boolean[][][],
): VoxelShape
Parameters
xs(number[])ys(number[])zs(number[])cells(BitSet | boolean[][][])
Returns
VoxelShape
Properties
xs: number[]
ys: number[]
zs: number[]
Methods
clip(from: Vec3, to: Vec3, pos: BaseVec3): BlockHitResult | null
Clipping math
I don't know how to explain this either D:
Parameters
Returns
BlockHitResult | null
collide(axis: BaseAxis, moving: AABB, distance: number): number
Collision math.
The purpos of this function is to "rotate" the axis then feed to collideX function
Parameters
Returns
number
- See:
- VoxelShape.collideX
collideX(
transform: AxisCycle,
moving: AABB,
distance: number,
): number
Collision math.
I don't know how to explain this D:
Parameters
transform(AxisCycle)moving(AABB)distance(number)
Returns
number
copy(): VoxelShape
Make a copy
Returns
findIndex(axis: BaseAxis, coords: number): number
Real-world to cells index.
The binary search mean: Find the smallest number that larger than the provided coords
Parameters
axis(BaseAxis)coords(number)
Returns
number
get(axis: BaseAxis, index: number): number
Cells index to real world position
Parameters
axis(BaseAxis)index(number)
Returns
number
getCoords(axis: BaseAxis): number[]
Get coords acording to each axis
Parameters
axis(BaseAxis)
Returns
number[]
getSize(axis: BaseAxis): number
Get the number of cells of an axis
Parameters
axis(BaseAxis)
Returns
number
isEmpty(): boolean
Is the whole shape is empty
One cells filled, or return true, mean this is not empty
Returns
boolean
isFullWide
Is the cell at these index filled
isFullWide(
transform: AxisCycle,
x: number,
y: number,
z: number,
): booleanParameters
transform(AxisCycle)x(number)y(number)z(number)
Returns
boolean
isFullWide(x: number, y: number, z: number): booleanIs the cell at these index filled
Parameters
x(number)y(number)z(number)
Returns
boolean
move
Shift this Voxel shape by a given vector, or on the other word, shift each axis by given value
move(x: number, y: number, z: number): VoxelShapeParameters
x(number)y(number)z(number)
Returns
move(position: BaseVec3): VoxelShapeShift this Voxel shape by a given vector, or on the other word, shift each axis by given value
Parameters
position(BaseVec3)
Returns
toAABBs(): AABB[]
Convert this VoxelShape into AABBs
Returns
AABB[]
Static Properties
Empty: VoxelShape
Static Methods
createMerger(first: number[], second: number[]): IndexMerger
Parameters
first(number[])second(number[])
Returns
IndexMerger
fromBox(bb: BaseAABB): VoxelShape
Construct VoxelShape from an AABB
Parameters
bb(BaseAABB)
Returns
or(a: VoxelShape, b: VoxelShape): VoxelShape
Merge two VoxelShape using OR operatior
Parameters
a(VoxelShape)b(VoxelShape)
Returns