Constructor
new Camera(pos, dir, fov, worldopt, canvasopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pos |
Vector | {x,y} or a p5.Vector object | ||
dir |
Vector | {x,y} or a p5.Vector object, should be normalized | ||
fov |
number | |||
world |
World |
<optional> |
null | world that the camera is in |
canvas |
p5.Renderer |
<optional> |
null | the canvas this camera to draw on, can be the main p5 canvas or a p5.Graphics object |
Methods
attachToWorld(world)
Parameters:
Name | Type | Description |
---|---|---|
world |
World | the world to attach the camera |
closeDoor()
close the door the camera facing
move(movement)
move the camera in the world
Parameters:
Name | Type | Description |
---|---|---|
movement |
Vector | {x,y} or a p5.Vector object |
moveDoor()
move the door the camera facing
openDoor()
open the door (or push wall) the camera facing
removeFromWorld()
remove the camera to the attached world
renderFloorAndCeiling(flooropt, ceilingopt, canvasopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
floor |
boolean |
<optional> |
true | render ray casting floor ? |
ceiling |
boolean |
<optional> |
true | render ray casting ceiling? |
canvas |
p5.Renderer |
<optional> |
this.canvas | a p5.Renderer (for main canvas) or p5.Graphics |
renderFrame(canvas)
render sky box and ray casting content
Parameters:
Name | Type | Description |
---|---|---|
canvas |
p5.Renderer | the main canvas or a p5.Graphics object |
renderMiniMap(size, canvasX, canvasY, renderWidth, renderHeight, canvasopt)
minimap will always center around current camera position
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
size |
Vector | how many block around camera to be drawn {x:on left and right, y: on top and button} | ||
canvasX |
number | where to draw the minimap on canvas | ||
canvasY |
number | where to draw the minimap on canvas | ||
renderWidth |
number | size of the minimap on canvas | ||
renderHeight |
number | size of the minimap on canvas | ||
canvas |
p5.Renderer |
<optional> |
this.canvas | a p5.Renderer (for main canvas) or p5.Graphics |
renderRayCasting(noSpritesopt, canvasopt)
render the ray casting content
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
noSprites |
boolean |
<optional> |
false | if true, do not render sprites |
canvas |
p5.Renderer |
<optional> |
this.canvas | a p5.Renderer (for main canvas) or p5.Graphics |
renderSkyBox(skyopt, groundopt, canvasopt)
render sky box
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
sky |
boolean |
<optional> |
true | if true, render sky |
ground |
boolean |
<optional> |
true | if true, render ground |
canvas |
p5.Renderer |
<optional> |
this.canvas | a p5.Renderer (for main canvas) or p5.Graphics |
rotate(angle)
rotate the camera by an angle
Parameters:
Name | Type | Description |
---|---|---|
angle |
number |
setMiniMapRenderOptions(options)
set the option on how the minimap should be rendered
this function will not copy the options object
for all the options see the miniMapOption section on readme.md
Parameters:
Name | Type | Description |
---|---|---|
options |
object |
teleportTo(point, dir, worldopt)
teleport the camera to somewhere
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
point |
Vector | {x,y} or a p5.Vector object | ||
dir |
Vector | {x,y} or a p5.Vector object, optional | ||
world |
World |
<optional> |
null | optional |
tilt(angle)
tile the camera
Parameters:
Name | Type | Description |
---|---|---|
angle |
number |
updateTiltingRange(min, max)
Parameters:
Name | Type | Description |
---|---|---|
min |
number | |
max |
number |