Class: Camera

Camera(pos, dir, fov, worldopt, canvasopt)

class for camera

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
Source:

Methods

attachToWorld(world)

Parameters:
Name Type Description
world World the world to attach the camera
Source:

closeDoor()

close the door the camera facing
Source:

move(movement)

move the camera in the world
Parameters:
Name Type Description
movement Vector {x,y} or a p5.Vector object
Source:

moveDoor()

move the door the camera facing
Source:

openDoor()

open the door (or push wall) the camera facing
Source:

removeFromWorld()

remove the camera to the attached world
Source:

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
Source:

renderFrame(canvas)

render sky box and ray casting content
Parameters:
Name Type Description
canvas p5.Renderer the main canvas or a p5.Graphics object
Source:

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
Source:

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
Source:

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
Source:

rotate(angle)

rotate the camera by an angle
Parameters:
Name Type Description
angle number
Source:

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
Source:

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
Source:

tilt(angle)

tile the camera
Parameters:
Name Type Description
angle number
Source:

updateTiltingRange(min, max)

Parameters:
Name Type Description
min number
max number
Source: