
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
A simple 2D camera suited for games and visualizations.
$ npm install camera-2d
var camera = createCamera({
left: 0,
right: 640,
top: 0,
bottom: 480
})
camera.setTranslation(64, 64)
camera.setRotation(Math.PI / 4)
camera.setScale(0.5)
var matrix = camera.getMatrix()
console.dir(matrix)
outputs a 3x3 matrix compatible with gl-mat3:
Float32Array {
'0': 0.0011048543965443969,
'1': -0.001473139156587422,
'2': 0,
'3': -0.0011048543965443969,
'4': -0.001473139156587422,
'5': 0,
'6': 0,
'7': 0.18856181204319,
'8': 1 }
Creates a new camera object. The options object contains the following
optional parameters:
left - the coordinate of the left side of the screen.right - the coordinate of the right side of the screen.top - the coordinate of the top of the screen.bottom - the coordinate of the bottom of the screen.x - the X coordinate to centre the camera on.y - the Y coordinate to centre the camera on.angle - the rotation to apply around the screen centre.scale - the scaling factor to apply.Width and height of the camera viewport, in units.
The camera's current X/Y offset from the origin.
The rotation of the camera viewport, in radians.
The scaling factor of the camera.
Retrieves the current state of the camera matrix.
out is a length 9 array which receives the result of the computation if not
otherwise specified.
Returns The resulting camera matrix
Sets the X/Y offset from the origin for the camera to be centred on.
Sets the rotation around the translation coordinates, in radians.
Sets the scaling factor of the camera at the translation coordinates.
Heavily inspired by Mikola Lysenko's camera-2d module.
I really liked the idea of a lightweight 2D camera that spits out a 3x3 transformation matrix, but wanted an API that made both absolute and relative operations easy.
FAQs
2D camera controller for games and visualizations
We found that camera-2d demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.