Skip to main content

@voxelize/core

Enumerations

Core Classes

Effects Classes

Other Classes

Utils Classes

Interfaces

Type Aliases

ArmsOptions

Ƭ ArmsOptions: CanvasBoxOptions & { shoulderDrop?: number ; shoulderGap?: number }

Parameters to create a character's arms. Defaults to:

{
gap: 0.1 * CHARACTER_SCALE,
layers: 1,
side: THREE.DoubleSide,
width: 0.25 * CHARACTER_SCALE,
widthSegments: 8,
height: 0.5 * CHARACTER_SCALE,
heightSegments: 16,
depth: 0.25 * CHARACTER_SCALE,
depthSegments: 8,
shoulderGap: 0.05 * CHARACTER_SCALE,
shoulderDrop: 0.25 * CHARACTER_SCALE,
}

ArrowOptions

Ƭ ArrowOptions: Object

Parameters to create an arrow.

Type declaration

NameTypeDescription
colorstring | ColorThe color of the arrow. Defaults to red.
coneHeightnumberThe height of the head of the arrow. Defaults to 0.2.
coneRadiusnumberThe radius of the head of the arrow. Defaults to 0.2.
heightnumberThe height of the body of the arrow. Defaults to 0.8.
radiusnumberThe radius of the body of the arrow. Defaults to 0.1.

ArtFunction

Ƭ ArtFunction: (context: CanvasRenderingContext2D, canvas: HTMLCanvasElement) => void

Type declaration

▸ (context, canvas): void

A function to programmatically draw on a canvas.

Parameters
NameType
contextCanvasRenderingContext2D
canvasHTMLCanvasElement
Returns

void


Block

Ƭ Block: Object

A block type in the world. This is defined by the server.

Type declaration

NameTypeDescription
aabbsAABB[]A list of axis-aligned bounding boxes that this block has.
blueLightLevelnumberThe blue light level of the block.
dynamicFn(pos: Coords3) => { aabbs: Block["aabbs"] ; faces: Block["faces"] ; isTransparent: Block["isTransparent"] }If this block is dynamic, this function will be called to generate the faces and AABB's. By default, this just returns the faces and AABB's that are defined in the block data.
dynamicPatternsBlockDynamicPattern[]-
faces{ corners: { pos: [number, number, number] ; uv: number[] }[] ; dir: [number, number, number] ; independent: boolean ; isolated: boolean ; name: string ; range: UV }[]A list of block face data that this block has.
greenLightLevelnumberThe green light level of the block.
idnumberThe block id.
independentFacesSet<string>A set of block face names that are independent (high resolution or animated). This is generated on the client side.
isDynamicbooleanWhether or not does the block generate dynamic faces or AABB's. If this is true, the block will use dynamicFn to generate the faces and AABB's.
isEmptybooleanWhether or not is this block empty. By default, only "air" is empty.
isEntityboolean-
isFluidbooleanWhether or not is the block a fluid block.
isLightbooleanWhether or not is this block a light source.
isOpaquebooleanWhether or not is this block opaque (not transparent).
isPassablebooleanWhether or not should physics ignore this block.
isSeeThroughbooleanWhether or not is this block see-through (can be opaque and see-through at the same time).
isTransparent[boolean, boolean, boolean, boolean, boolean, boolean]Whether or not is this block transparent viewing from all six sides. The sides are defined as PX, PY, PZ, NX, NY, NZ.
isolatedFacesSet<string>-
lightReducebooleanWhether or not should light reduce by 1 going through this block.
namestringThe name of the block.
redLightLevelnumberThe red light level of the block.
rotatablebooleanWhether or not is the block rotatable.
transparentStandaloneboolean-
yRotatablebooleanWhether or not the block is rotatable around the y-axis (has to face either PX or NX).
yRotatableSegments"All" | "Eight" | "Four"-

BlockEntityUpdateData

Ƭ BlockEntityUpdateData<T>: Object

Type parameters

Name
T

Type declaration

NameType
idstring
newValueT | null
oldValueT | null
operationEntityOperation
voxelCoords3

BlockEntityUpdateListener

Ƭ BlockEntityUpdateListener<T>: (args: BlockEntityUpdateData<T>) => void

Type parameters

Name
T

Type declaration

▸ (args): void

Parameters
NameType
argsBlockEntityUpdateData<T>
Returns

void


BlockRule

Ƭ BlockRule: { type: "none" } | { type: "simple" } & BlockSimpleRule | { logic: BlockRuleLogic ; rules: BlockRule[] ; type: "combination" }


BlockSimpleRule

Ƭ BlockSimpleRule: Object

Type declaration

NameType
id?number
offsetCoords3
rotation?BlockRotation
stage?number

BlockUpdate

Ƭ BlockUpdate: Object

A block update to make on the server.

Type declaration

NameTypeDescription
rotation?numberThe optional rotation of the updated block.
typenumberThe voxel type.
vxnumberThe voxel x-coordinate.
vynumberThe voxel y-coordinate.
vznumberThe voxel z-coordinate.
yRotation?numberThe optional y-rotation of the updated block.

BlockUpdateListener

Ƭ BlockUpdateListener: (args: { newValue: number ; oldValue: number ; voxel: Coords3 }) => void

Type declaration

▸ (args): void

Parameters
NameType
argsObject
args.newValuenumber
args.oldValuenumber
args.voxelCoords3
Returns

void


BlockUpdateWithSource

Ƭ BlockUpdateWithSource: Object

Type declaration

NameType
source"client" | "server"
updateBlockUpdate

BodyOptions

Ƭ BodyOptions: CanvasBoxOptions

Parameters to create a character's body. Defaults to:

{
gap: 0.1 * CHARACTER_SCALE,
layers: 1,
side: THREE.DoubleSide,
width: 1 * CHARACTER_SCALE,
widthSegments: 16,
}

where CHARACTER_SCALE is 0.9.


BoxSides

Ƭ BoxSides: "back" | "front" | "top" | "bottom" | "left" | "right" | "sides" | "all"

The sides of a canvas box.

"all" means all six sides, and "sides" means all the sides except the top and bottom.


CSSMeasurement

Ƭ CSSMeasurement: `${number}${string}`

A CSS measurement. E.g. "30px", "51em"


CameraPerspective

Ƭ CameraPerspective: "px" | "nx" | "py" | "ny" | "pz" | "nz" | "pxy" | "nxy" | "pxz" | "nxz" | "pyz" | "nyz" | "pxyz" | "nxyz"


CanvasBoxOptions

Ƭ CanvasBoxOptions: Object

Parameters to create a canvas box.

Type declaration

NameTypeDescription
depth?numberThe depth of the box. Defaults to whatever width is.
depthSegments?numberThe depth segments of the box, which is the number of pixels of the canvases along the depth. Defaults to whatever widthSegments is.
gapnumberThe gap between the layers of the box. Defaults to 0.
height?numberThe height of the box. Defaults to whatever width is.
heightSegments?numberThe height segments of the box, which is the number of pixels of the canvases along the height. Defaults to whatever widthSegments is.
layersnumberThe number of layers of this box. Defaults to 1.
sideSideThe side of the box to render. Defaults to THREE.FrontSide.
transparent?booleanWhether or not should this canvas box be rendered as transparent. Defaults to false.
widthnumberTHe width of the box. Defaults to 1.
widthSegmentsnumberThe width segments of the box, which is the number of pixels of the canvases along the width. Defaults to 8.

CharacterOptions

Ƭ CharacterOptions: Object

Parameters to create a character.

Type declaration

NameTypeDescription
arms?Partial<ArmsOptions>Parameters to create the character's arms.
body?Partial<BodyOptions>Parameters to create the character's body.
head?Partial<HeadOptions>Parameters to create the character's head.
idleArmSwing?numberThe speed at which the arms swing when the character is idle. Defaults to 0.06.
legs?Partial<LegOptions>Parameters to create the character's legs.
nameTagOptions?Partial<NameTagOptions>-
positionLerp?numberThe lerp factor of the character's position change. Defaults to 0.7.
rotationLerp?numberThe lerp factor of the character's rotation change. Defaults to 0.2.
swingLerp?numberThe lerp factor of the swinging motion of the arms and legs. Defaults to 0.8.
walkingSpeed?numberThe speed at which the arms swing when the character is moving. Defaults to 1.4.

ClickType

Ƭ ClickType: "left" | "middle" | "right"

Three types of clicking for mouse input listening.


CloudsOptions

Ƭ CloudsOptions: Object

Parameters used to create a new Clouds instance.

Type declaration

NameTypeDescription
alphanumberThe opacity of the clouds. Defaults to 0.8.
cloudHeightnumberThe y-height at which the clouds are generated. Defaults to 256.
colorstringThe color of the clouds. Defaults to #fff.
countnumberThe number of cloud cells to generate, count * count. Defaults to 16.
dimensionsCoords3The dimension of each cloud block. Defaults to [20, 20, 20].
falloffnumberThe noise falloff factor used to generate the clouds. Defaults to 0.9.
heightnumberThe vertical count of how many cloud blocks are in a cloud cell. This is also used to determine the overall count of cloud blocks of all the clouds. Defaults to 3.
lerpFactornumberThe lerp factor used to translate cloud blocks from their original position to their new position. Defaults to 0.3.
noiseScalenumberThe scale of the noise used to generate the clouds. Defaults to 0.08.
octavesnumberThe number of octaves used to generate the noise. Defaults to 5.
seednumberThe seed used to generate the clouds. Defaults to -1.
speedFactornumberThe speed at which the clouds move. Defaults to 8.
thresholdnumberThe threshold at which noise values are considered to be "cloudy" and should generate a new cloud block. Defaults to 0.05.
uFogColor?{ value: Color }An object that is used as the uniform for the clouds fog color shader.
uFogColor.valueColor-
uFogFar?{ value: number }An object that is used as the uniform for the clouds fog far shader.
uFogFar.valuenumber-
uFogNear?{ value: number }An object that is used as the uniform for the clouds fog near shader.
uFogNear.valuenumber-
widthnumberThe horizontal count of how many cloud blocks are in a cloud cell. Defaults to 8.

CommandProcessor

Ƭ CommandProcessor: (rest: string) => void

Type declaration

▸ (rest): void

A process that gets run when a command is triggered.

Parameters
NameType
reststring
Returns

void


Coords2

Ƭ Coords2: [number, number]


Coords3

Ƭ Coords3: [number, number, number]


CullOptionsType

Ƭ CullOptionsType: Object

Type declaration

NameType
dimensionsCoords3
maxCoords3
minCoords3
realMaxCoords3
realMinCoords3

CustomChunkShaderMaterial

Ƭ CustomChunkShaderMaterial: ShaderMaterial & { map: Texture }

Custom shader material for chunks, simply a ShaderMaterial from ThreeJS with a map texture. Keep in mind that if you want to change its map, you also have to change its uniforms.map.


DebugOptions

Ƭ DebugOptions: Object

Parameters to create a Debug instance.

Type declaration

NameTypeDescription
asyncPeriodnumber-
dataClassstringA class to add to the wrapper of the top-left debug panel.
dataStylesPartial<CSSStyleDeclaration>Styles to apply to the wrapper of the top-left debug panel.
entriesClassstringA class to add to the wrapper of all debug entries.
entryStylesPartial<CSSStyleDeclaration>Styles to apply to the wrapper of all debug entries.
lineClassstringA class to add to each of the debug entry line (top left).
lineStylesPartial<CSSStyleDeclaration>Styles to apply to each of the debug entry line (top left).
onByDefaultbooleanWhether or not should the debug panel be displayed by default when the page loads. Defaults to true. You can toggle the debug panel by calling Debug.toggle.
showVoxelizebooleanWhether or not should Voxelize x.x.x be displayed in the top-left debug panel. Defaults to true.
statsbooleanWhether or not should stats.js be enabled. Defaults to true.

DeepPartial

Ƭ DeepPartial<T>: { [P in keyof T]?: DeepPartial<T[P]> }

Type parameters

Name
T

Event

Ƭ Event: Object

A Voxelize event from the server.

Type declaration

NameTypeDescription
namestringThe name to identify the event.
payload?anyAdditional information of the event.

EventHandler

Ƭ EventHandler: (payload: any | null) => void

Type declaration

▸ (payload): void

The handler for an event sent from the Voxelize server.

Parameters
NameType
payloadany | null
Returns

void


HeadOptions

Ƭ HeadOptions: CanvasBoxOptions & { neckGap?: number }

Parameters to create a character's head. Defaults to:

{
gap: 0.1 * CHARACTER_SCALE,
layers: 1,
side: THREE.DoubleSide,
width: 0.5 * CHARACTER_SCALE,
widthSegments: 16,
height: 0.25 * CHARACTER_SCALE,
heightSegments: 8,
depth: 0.5 * CHARACTER_SCALE,
depthSegments: 16,
neckGap: 0.05 * CHARACTER_SCALE,
}

where CHARACTER_SCALE is 0.9.


HudOptions

Ƭ HudOptions: Object

Type declaration

NameType
armColor?string
armMesh?THREE.Object3D
armPosition?THREE.Vector3
armQuaternion?THREE.Quaternion
blockPosition?THREE.Vector3
blockQuaternion?THREE.Quaternion

InputOccasion

Ƭ InputOccasion: "keydown" | "keypress" | "keyup"

The occasion that the input should be fired.


InputSpecifics

Ƭ InputSpecifics: Object

The specific options of the key to listen to.

Type declaration

NameTypeDescription
checkType?"key" | "code"The type of key to check for. Defaults to key.
identifier?stringA special identifier to tag this input with. This is useful for removing specific inputs from the input listener later on.
occasion?InputOccasionThe occasion that the input should be fired. Defaults to keydown.

ItemSlotsOptions

Ƭ ItemSlotsOptions: Object

Type declaration

NameType
activatedByDefaultboolean
focusFirstByDefaultboolean
horizontalCountnumber
perspectiveCameraPerspective
scrollable?boolean
slotClassstring
slotFocusClassstring
slotHeightnumber
slotHoverClassstring
slotMarginnumber
slotPaddingnumber
slotStylesPartial<CSSStyleDeclaration>
slotSubscriptClassstring
slotSubscriptStylesPartial<CSSStyleDeclaration>
slotWidthnumber
verticalCountnumber
wrapperClassstring
wrapperStylesPartial<CSSStyleDeclaration>
zoomnumber

LegOptions

Ƭ LegOptions: CanvasBoxOptions & { betweenLegsGap?: number }

Parameters to create the legs of a character. Defaults to:

{
gap: 0.1 * CHARACTER_SCALE,
layers: 1,
side: THREE.DoubleSide,
width: 0.25 * CHARACTER_SCALE,
widthSegments: 3,
height: 0.25 * CHARACTER_SCALE,
heightSegments: 3,
depth: 0.25 * CHARACTER_SCALE,
depthSegments: 3,
betweenLegsGap: 0.2 * CHARACTER_SCALE,
}

where CHARACTER_SCALE is 0.9.


LightColor

Ƭ LightColor: "RED" | "GREEN" | "BLUE" | "SUNLIGHT"

Sunlight or the color of torch light.


LightNode

Ƭ LightNode: Object

Type declaration

NameType
levelnumber
voxelCoords3

LightShinedOptions

Ƭ LightShinedOptions: Object

Parameters to create a light shine effect.

Type declaration

NameTypeDescription
lerpFactornumberThe lerping factor of the brightness of each mesh. Defaults to 0.1.

MeshResultType

Ƭ MeshResultType: Object

Type declaration

NameType
indicesFloat32Array
normalsFloat32Array
positionsFloat32Array

NameTagOptions

Ƭ NameTagOptions: Object

Parameters to create a name tag.

Type declaration

NameTypeDescription
backgroundColor?stringThe background color of the name tag. Defaults to 0x00000077.
color?stringThe color of the name tag. Defaults to 0xffffff.
fontFace?stringThe font face to create the name tag. Defaults to "monospace".
fontSize?numberThe font size to create the name tag. Defaults to 0.1.
yOffset?numberThe y-offset of the nametag moved upwards. Defaults to 0.

NetworkConnectionOptions

Ƭ NetworkConnectionOptions: Object

Parameters to customize the connection to a Voxelize server. For example, setting a secret key to authenticate the connection with the server.

Type declaration

NameTypeDescription
reconnectTimeout?numberOn disconnection, the timeout to attempt to reconnect. Defaults to 5000.
secret?stringThe secret to joining a server, a key that if set on the server, then must be provided to connect to the server successfully.

NetworkOptions

Ƭ NetworkOptions: Object

Type declaration

NameType
maxPacketsPerTicknumber

PartialRecord

Ƭ PartialRecord<K, T>: { [P in K]?: T }

Type parameters

NameType
Kextends keyof any
TT

PeersOptions

Ƭ PeersOptions: Object

Parameters to customize the peers manager.

Type declaration

NameTypeDescription
countSelfbooleanWhether or not should the client themselves be counted as "updated". In other words, whether or not should the update function be called on the client's own data. Defaults to false.
updateChildrenbooleanWhether or not should the peers manager automatically call update on any children mesh. Defaults to true.

PerspectiveOptions

Ƭ PerspectiveOptions: Object

Parameters to create a new Perspective instance.

Type declaration

NameTypeDescription
blockMarginnumberThe margin between the camera and any block that the camera is colliding with. This prevents the camera from clipping into blocks. Defaults to 0.3.
ignoreFluidsbooleanWhether or not should the camera ignore fluid block collisions. Defaults to true.
ignoreSeeThroughbooleanWhether or not should the camera ignore see-through block collisions. Defaults to true.
lerpFactornumberThe lerping factor for the camera's position. Defaults to 0.5.
maxDistancenumberThe maximum distance the camera can go from the player's center. Defaults to 5.

PortraitOptions

Ƭ PortraitOptions: Object

Parameters to create a portrait with.

Type declaration

NameTypeDescription
heightnumberThe height of the portrait canvas. Defaults to 100 pixels.
lightRotationOffsetnumberThe rotation around the y axis about the camera. This is used to calculate the position of the light. Defaults to -Math.PI / 8.
perspectiveCameraPerspectiveThe position of where the camera should be looking at. Defaults to pxyz, which means that the camera will be looking at the center of the object from the positive x, y, and z axis scaled by the zoom.
renderOncebooleanWhether or not should this portrait only render once. Defaults to false.
widthnumberThe width of the portrait canvas. Defaults to 100 pixels.
zoomnumberThe arbitrary zoom from the camera to the object. This is used to calculate the zoom of the camera. Defaults to 1.

ProtocolWS

Ƭ ProtocolWS: WebSocket & { sendEvent: (event: any) => void }

A custom WebSocket type that supports protocol buffer sending.


RigidControlState

Ƭ RigidControlState: Object

The state of which a Voxelize Controls is in.

Type declaration

NameTypeDescription
crouchingbooleanWhether if the client is attempting to crouch, if the crouch key is pressed. Defaults to false.
currentJumpTimenumberThe current amount of time spent in the air from jump. Defaults to 0.
headingnumberIn radians, the heading y-rotation of the client. Defaults to 0.
isJumpingbooleanWhether or not is the client jumping, in the air. Defaults to false.
jumpCountnumberHow many times has the client jumped. Defaults to 0.
jumpingbooleanWhether if the client is attempting to jump, if the jump key is pressed. Defaults to false.
runningbooleanWhether if the client is running. Defaults to false.
sprintingbooleanWhether if the client is attempting to sprint, if the sprint key is pressed. Defaults to false.

RigidControlsOptions

Ƭ RigidControlsOptions: Object

Parameters to initialize the Voxelize Controls.

Type declaration

NameTypeDescription
airJumpsnumberHow many times can a client jump in the air. Defaults to 0.
airMoveMultnumberThe factor applied to the movements of the client in air, such as while half-jump. Defaults to 0.7.
alwaysSprintbooleanSprint factor would be on always. Defaults to false.
bodyDepthnumberThe depth of the client's avatar. Defaults to 0.8 blocks.
bodyHeightnumberThe height of the client's avatar. Defaults to 1.55 blocks.
bodyWidthnumberThe width of the client's avatar. Defaults to 0.8 blocks.
crouchFactornumberThe factor to the movement speed when crouch is applied. Defaults to 0.6.
eyeHeightnumberThe ratio to bodyHeight at which the camera is placed from the ground. Defaults at 0.9193548387096774.
fluidPushForcenumberThe force upwards when a client tries to jump in water. Defaults to 0.3.
flyForcenumberThe level of force at which a client flies at. Defaults to 80.
flyImpulsenumberThe level impulse of which a client flies at. Defaults to 2.5.
flyInertianumberThe inertia of a client when they're flying. Defaults to 6.
flySpeednumberThe level of speed at which a client flies at. Defaults to 40.
initialDirectionCoords3-
initialPositionCoords3Initial position of the client. Defaults to (0, 80, 10).
jumpForcenumberThe level of force applied to the client when jumping. Defaults to 1.
jumpImpulsenumberThe level of impulse at which the client jumps upwards. Defaults to 8.
jumpTimenumberThe time, in milliseconds, that a client can be jumping. Defaults to 50ms.
maxPolarAnglenumberMaximum polar angle that camera can look up to. Defaults to Math.PI * 0.99
maxSpeednumberThe maximum level of speed of a client. Default is 6 .
minPolarAnglenumberMinimum polar angle that camera can look down to. Defaults to Math.PI * 0.01.
moveForcenumberThe level of force of which the client can move at. Default is 30.
positionLerpnumberThe interpolation factor of the client's position. Defaults to 1.0.
responsivenessnumberThe level of responsiveness of a client to movements. Default is 240.
rotationLerpnumberThe interpolation factor of the client's rotation. Defaults to 0.9.
runningFrictionnumberDefault running friction of a client. Defaults to 0.1.
sensitivitynumberThe mouse sensitivity. Defaults to 100.
sprintFactornumberThe factor to the movement speed when sprint is applied. Defaults to 1.4.
standingFrictionnumberDefault standing friction of a client. Defaults to 4.
stepHeightnumberHow tall a client can step up. Defaults to 0.5.
stepLerpnumberThe interpolation factor when the client is auto-stepping. Defaults to 0.6.

ShadowOptions

Ƭ ShadowOptions: Object

Parameters to create a shadow.

Type declaration

NameTypeDescription
maxDistancenumberThe maximum distance from the object to the ground to cast a shadow. The shadow's scale scales inversely with distance. Defaults to 10.
maxRadiusnumberThe maximum radius the shadow can have. That is, the radius of the shadow when the object is on the ground. Defaults to 0.5.

SharedWorkerPoolJob

Ƭ SharedWorkerPoolJob: Object

A worker pool job is queued to a worker pool and is executed by a worker.

Type declaration

NameTypeDescription
buffers?ArrayBufferLike[]Any array buffers (transferable) that are passed to the worker.
messageanyA JSON serializable object that is passed to the worker.
resolve(value: any) => voidA callback that is called when the worker has finished executing the job.

SharedWorkerPoolOptions

Ƭ SharedWorkerPoolOptions: Object

Parameters to create a worker pool.

Type declaration

NameTypeDescription
maxWorkernumberThe maximum number of workers to create. Defaults to 8.

SkyOptions

Ƭ SkyOptions: Object

Type declaration

NameTypeDescription
dimensionnumberThe dimension of the dodecahedron sky. The inner canvas box is 0.8 times this dimension.
lerpFactornumberThe lerp factor for the sky gradient. The sky gradient is updated every frame by lerping the current color to the target color. set by the setTopColor, setMiddleColor, and setBottomColor methods.
transitionSpannumber-

SkyShadingCycleData

Ƭ SkyShadingCycleData: Object

Type declaration

NameType
color{ bottom: Color | string ; middle: Color | string ; top: Color | string }
color.bottomColor | string
color.middleColor | string
color.topColor | string
namestring
skyOffsetnumber
startnumber
voidOffsetnumber

TargetType

Ƭ TargetType: "All" | "Player" | "Entity"


UV

Ƭ UV: Object

The UV range of a texture on the texture atlas.

Type declaration

NameTypeDescription
endUnumberThe ending U coordinate of the texture.
endVnumberThe ending V coordinate of the texture.
startUnumberThe starting U coordinate of the texture.
startVnumberThe starting V coordinate of the texture.

VoxelInteractOptions

Ƭ VoxelInteractOptions: Object

Parameters to customize the VoxelInteract instance.

Type declaration

NameTypeDescription
highlightColorColorThe color of the highlight. Defaults to 0xffffff.
highlightLerpnumberThe lerping factor of the highlight. Defaults to 0.8.
highlightOpacitynumberThe opacity of the highlight. Defaults to 0.8.
highlightScalenumberThe scale of the block highlight. Defaults to 1.002.
highlightType"box" | "outline"The type of the block highlight. Box would be a semi-transparent box, while outline would be 12 lines that outline the block's AABB union. Defaults to "box".
ignoreFluidsbooleanWhether or not should the VoxelInteract instance ignore fluids when raycasting. Defaults to true.
inverseDirectionbooleanWhether or not should the VoxelInteract instance reverse the raycasting direction. Defaults to false.
potentialVisualsbooleanDebug Whether or not should there be arrows indicating the potential block placement's orientations. Defaults to false.
reachDistancenumberThe maximum distance of reach for the VoxelInteract instance. Defaults to 32.

WorkerPoolJob

Ƭ WorkerPoolJob: Object

A worker pool job is queued to a worker pool and is executed by a worker.

Type declaration

NameTypeDescription
buffers?ArrayBufferLike[]Any array buffers (transferable) that are passed to the worker.
messageanyA JSON serializable object that is passed to the worker.
resolve(value: any) => voidA callback that is called when the worker has finished executing the job.

WorkerPoolOptions

Ƭ WorkerPoolOptions: Object

Parameters to create a worker pool.

Type declaration

NameTypeDescription
maxWorkernumberThe maximum number of workers to create. Defaults to 8.

WorldClientOptions

Ƭ WorldClientOptions: Object

The client-side options to create a world. These are client-side only and can be customized to specific use.

Type declaration

NameTypeDescription
chunkLoadExponentnumberThe exponent applied to the ratio that chunks are loaded, which would then be used to determine whether an angle to a chunk is worth loading. Defaults to 8.
chunkRerequestIntervalnumberThe interval between each time a chunk is re-requested to the server. Defaults to 300 updates.
chunkUniformsOverwritePartial<Chunks["uniforms"]>The uniforms to overwrite the default chunk material uniforms. Defaults to {}.
cloudsOptionsPartial<CloudsOptions>The options to create the clouds. Defaults to {}.
defaultRenderRadiusnumberThe default render radius of the world, in chunks. Change this through world.renderRadius. Defaults to 8 chunks.
maxChunkRequestsPerUpdatenumberThe maximum chunk requests this world can request from the server per world update. Defaults to 12 chunks.
maxLightsUpdateTimenumber-
maxMeshesPerUpdatenumber-
maxProcessesPerUpdatenumberThe maximum amount of chunks received from the server that can be processed per world update. By process, it means to be turned into a Chunk instance. Defaults to 8 chunks.
maxUpdatesPerUpdatenumberThe maximum voxel updates that can be sent to the server per world update. Defaults to 1000 updates.
minLightLevelnumberThe minimum light level even when sunlight and torch light levels are at zero. Defaults to 0.04.
shouldGenerateChunkMeshesbooleanWhether or not should the world generate ThreeJS meshes. Defaults to true.
skyOptionsPartial<SkyOptions>The options to create the sky. Defaults to {}.
statsSyncIntervalnumberThe interval between each time the world requests the server for its stats. Defaults to 500ms.
sunlightChangeSpannumberThe fraction of the day that sunlight takes to change from appearing to disappearing or disappearing to appearing. Defaults to 0.1.
sunlightEndTimeFracnumberThe fraction of the day that sunlight starts to disappear. Defaults to 0.7.
sunlightStartTimeFracnumberThe fraction of the day that sunlight starts to appear. Defaults to 0.25.
textureUnitDimensionnumberThe default dimension to a single unit of a block face texture. If any texture loaded is greater, it will be downscaled to this resolution. Defaults to 8 pixels.
timeForceThresholdnumberThe threshold to force the server's time to the client's time. Defaults to 0.1.

WorldOptions

Ƭ WorldOptions: WorldClientOptions & WorldServerOptions

The options to create a world. This consists of WorldClientOptions and WorldServerOptions.


WorldServerOptions

Ƭ WorldServerOptions: Object

The options defined on the server-side, passed to the client on network joining.

Type declaration

NameTypeDescription
airDragnumberThe air drag of everything physical.
chunkSizenumberThe width and depth of a chunk, in blocks.
doesTickTimeboolean-
fluidDensitynumberThe density of the fluid in this world.
fluidDragnumberThe fluid drag of everything physical.
gravitynumber[]The gravity of everything physical in this world.
maxChunk[number, number]The maximum chunk coordinate of this world, inclusive.
maxHeightnumberThe height of a chunk, in blocks.
maxLightLevelnumberThe maximum light level that propagates in this world, including sunlight and torch light.
minBounceImpulsenumberThe minimum bouncing impulse of everything physical in this world.
minChunk[number, number]The minimum chunk coordinate of this world, inclusive.
subChunksnumberThe number of sub-chunks that divides a chunk vertically.
timePerDaynumberThe time per day in seconds.

Variables

ARM_COLOR

Const ARM_COLOR: "#548ca8"


BLUE_LIGHT

Const BLUE_LIGHT: "BLUE"

The string representation of blue light.


BOX_SIDES

Const BOX_SIDES: BoxSides[]

The six default faces of a canvas box.


DEFAULT_CHUNK_SHADERS

Const DEFAULT_CHUNK_SHADERS: Object

This is the default shaders used for the chunks.

Type declaration

NameType
fragmentstring
vertexstring

GREEN_LIGHT

Const GREEN_LIGHT: "GREEN"

The string representation of green light.


NX_ROTATION

Const NX_ROTATION: 3

The numerical representation of the negative X rotation.


NY_ROTATION

Const NY_ROTATION: 1

The numerical representation of the negative Y rotation.


NZ_ROTATION

Const NZ_ROTATION: 5

The numerical representation of the negative Z rotation.


OPAQUE_RENDER_ORDER

Const OPAQUE_RENDER_ORDER: 100


PX_ROTATION

Const PX_ROTATION: 2

The numerical representation of the positive X rotation.


PY_ROTATION

Const PY_ROTATION: 0

The numerical representation of the positive Y rotation.


PZ_ROTATION

Const PZ_ROTATION: 4

The numerical representation of the positive Z rotation.


RED_LIGHT

Const RED_LIGHT: "RED"

The string representation of red light.


SUNLIGHT

Const SUNLIGHT: "SUNLIGHT"

The string representation of sunlight.


TRANSPARENT_RENDER_ORDER

Const TRANSPARENT_RENDER_ORDER: 100000


Y_ROT_MAP

Const Y_ROT_MAP: [number, number][] = []

A rotational map used to get the closest y-rotation representation to a y-rotation value.

Rotation value -> index


Y_ROT_MAP_EIGHT

Const Y_ROT_MAP_EIGHT: [number, number][] = []


Y_ROT_MAP_FOUR

Const Y_ROT_MAP_FOUR: [number, number][] = []


Y_ROT_SEGMENTS

Const Y_ROT_SEGMENTS: 16

The amount of Y-rotation segments should be allowed for y-rotatable blocks. In other words, the amount of times the block can be rotated around the y-axis within 360 degrees.

The accepted Y-rotation values will be from 0 to Y_ROTATION_SEGMENTS - 1.


artFunctions

Const artFunctions: Object

A preset of art functions to draw on canvas boxes.

Type declaration

NameType
drawCrownArtFunction
drawMoon(moonRadius: number, moonColor: string, phase: number) => (context: CanvasRenderingContext2D, canvas: HTMLCanvasElement) => void
drawStars(starCount: number, starColors: string[]) => (context: CanvasRenderingContext2D, canvas: HTMLCanvasElement) => void
drawSun(sunRadius: number, sunColor: string) => (context: CanvasRenderingContext2D, canvas: HTMLCanvasElement) => void

customShaders

Const customShaders: Object

Type declaration

NameType
sway(options: Partial<{ amplitude: number ; rooted: boolean ; scale: number ; speed: number ; yScale: number }>) => { fragmentShader: string = DEFAULT_CHUNK_SHADERS.fragment; vertexShader: string }

Functions

TRANSPARENT_SORT

TRANSPARENT_SORT(object): (a: any, b: any) => number

Parameters

NameType
objectObject3D<Object3DEventMap>

Returns

fn

▸ (a, b): number

Parameters
NameType
aany
bany
Returns

number


cull

cull(array, options): Promise<MeshResultType>

Parameters

NameType
arrayNdArray<number[] | TypedArray | GenericArray<number>>
optionsCullOptionsType

Returns

Promise<MeshResultType>


requestWorkerAnimationFrame

requestWorkerAnimationFrame(callback): number

Parameters

NameType
callback() => void

Returns

number


setWorkerInterval

setWorkerInterval(func, interval): () => void

Parameters

NameType
func() => void
intervalnumber

Returns

fn

▸ (): void

Returns

void