Open In App

p5.js Lights, Camera Complete Reference

Improve
Improve
Like Article
Like
Save
Share
Report

Camera() Method: The camera() function sets the camera position for a 3D sketch. Its parameters define the position for the camera, the middle of the sketch (where the camera is pointing), and an up direction (the orientation of the camera).

This function simulates the movements of the camera, allowing objects to be viewed from various angles.

Syntax:

new camera([x], [y], [z], [centerX], [centerY], [centerZ], [upX], [upY], [upZ])

Lights() Function: The lights() function sets the default ambient and directional light. The default values are ambientLight(128, 128, 128) and directionalLight(128, 128, 128, 0, 0, -1)

Syntax:

lights()

Interaction

Description

orbitControl() It enables the movement around a 3D sketch using a mouse or trackpad.
noDebugMode() It disables the debug mode enabled by debugMode() function in a 3D sketch.

Lights

Description

ambientLight() ambientLight() function is used to create an ambient light with the specified color.
specularColor() It sets the color of the specular highlight when it is used with the specular material and highlight.
directionalLight() It creates a directional light with the specified color and direction.
pointLight() It creates a point lights with the specified color and position in the scene.
lights() It sets the default ambient and directional light in the scene.
lightFalloff() lightFalloff() function is used to set the falloff for point lights in the scene.
noLights() It removes all lights in the sketch for the materials that would be rendered after this function.

Material

Description

normalMaterial() normalMaterial() function is used to create a normal material for an object.
texture() texture() function is used to provide a texture for geometry objects.
ambientMaterial() It creates a ambient material for a geometry with the given color.
emissiveMaterial() It creates a emissive material for a geometry with the given color.
specularMaterial() It creates a specular material for a geometry with the given color.
shininess() It specifies the amount of gloss that would be present on the surface of shapes.

Camera:

Camera

Description

perspective() perspective() function is used to define a perspective projection for the camera in a 3D sketch.
createCamera() It creates a p5.Camera object and tell the renderer to use it as the current camera.
setCamera() setCamera() function is used to set the renderer’s current camera to the given p5.Camera object.

p5.Camera

Description

pan() It rotates the view, that is, pan the camera according to the given amount of rotation.
move() move() method is used to move the camera along its local axes by the specified amount.
tilt() It rotates the view, that is pan, of the camera according to the given amount of rotation.
setPosition() setPosition() method is used to set the position of the camera to the given point in world space.

Last Updated : 24 Aug, 2023
Like Article
Save Article
Share your thoughts in the comments
Similar Reads