Methods
createCamera(pos, dir, fov, worldopt, canvasopt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
pos |
Vector | camera position, {x,y} or a p5.Vector object | |
dir |
Vector | camera facing direction, {x,y} or a p5.Vector object, should be normalized | |
fov |
number | field of view of the camera | |
world |
World |
<optional> |
the world that the camera attached to |
canvas |
P5.Renderer |
<optional> |
the canvas that the camera render to, can be the main canvas or a p5.Graphics object |
- Source:
Returns:
a new camera object
createSkyBox(sky, ground, frontopt, middleopt, backopt)
create a skyBox object
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
sky |
string | a string notation of color or a p5.Image object | ||
ground |
string | a string notation of color or a p5.Image object | ||
front |
p5.Image |
<optional> |
null | can be a p5.Graphics object |
middle |
p5.Image |
<optional> |
null | can be a p5.Graphics object |
back |
p5.Image |
<optional> |
null | a p5.Graphics object |
- Source:
Returns:
a skyBox object
createSprite(spriteSourceImage, position, width, height, angleopt, yAdjustmentopt, animationGapopt, p5Instopt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
spriteSourceImage |
p5.Image | ||
position |
Vector | {x, y} or a p5.Vector object | |
width |
number | ||
height |
number | ||
angle |
number |
<optional> |
optional |
yAdjustment |
number |
<optional> |
optional [-0.5, 0.5] -0.5 ~ 0.5, negative number will make the sprite appear lower and positive number will make it appear higher |
animationGap |
number |
<optional> |
optional number of frame for before change to the next animation |
p5Inst |
p5 |
<optional> |
optional, needed when using p5 instance mode |
- Source:
Returns:
a Sprite object
createTextureMap(blockType, texture)
input should be pairs of number and p5.Image object
Parameters:
Name | Type | Description |
---|---|---|
blockType |
number | |
texture |
p5.Image | can also be p5.Graphics objects or a css string (single color) |
- Source:
Returns:
the texture map
createWorld(width, height, dataopt, textureMapopt, skyBoxopt, typeTableopt, optionsopt)
create a World object
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
width |
number | integer indicating the width of the world (number of block) | |||||||||||||||||||||||||
height |
number | integer indicating the height of the world (number of block) | |||||||||||||||||||||||||
data |
string |
<optional> |
block data for the world, e.g. "0,1,0,0,0,0,1,2,0,0,0,0...", can be an array of integer instead] | ||||||||||||||||||||||||
textureMap |
Map |
<optional> |
[[0, texture], [1, texture], ...] | ||||||||||||||||||||||||
skyBox |
object |
<optional> |
sky box
Properties
|
||||||||||||||||||||||||
typeTable |
object |
<optional> |
block type table to interpret the data, default to the default table | ||||||||||||||||||||||||
options |
object |
<optional> |
Properties
|
- Source:
Returns:
a new World object
initKeyboardControl(keyMapopt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
keyMap |
object |
<optional> |
- Source:
Returns:
a new keyboard control object
initMouseControl(eleopt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
ele |
HTMLElement |
<optional> |
element that the controller binds to |
- Source:
Returns:
a new mouse control object
initPointerLockControl(camera, ele)
Parameters:
Name | Type | Description |
---|---|---|
camera |
Camera | the camera to be controlled |
ele |
HTMLElement | element that the controller binds to |
- Source:
Returns:
a new pointerlock control object