Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

camera-2d-simple

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

camera-2d-simple

2D camera for WebGL

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
896
increased by19.15%
Maintainers
1
Weekly downloads
 
Created
Source

2D Camera

Build Status

Simple camera built on top of gl-matrix for 2D scenes. Heavily inspired by Mikola's Orbit Camera.

Also see:

Install

npm install camera-2d-simple

API

import createCamera from 'camera-2d-simple';

const camera = createCamera(target = [0, 0], distance = 1)

Creates a 2d camera looking at target from a certain distance.

  • target is the 2d vector the camera is looking at.
  • distance is the distance between the target and the camera.

Returns A new 2d camera object

camera.lookAt(target = [0, 0], distance = 1)

Move the camera to look at the new position.

camera.pan(translation)

Moves the center of the camera by translation. Note that translation must be an array of length 2.

camera.zoom(delta)

Zooms in or out by some amount. I.e., the new distance is defined as distance * delta.

camera.view([out])

Returns the current view matrix associated to the camera.

camera.position

Is an array of length 3 comprised of the target (x, y) and distance (z) of the camera.

camera.transformation

Is the current transformation mat3 associated to the camera.

Keywords

FAQs

Package last updated on 12 Oct 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc