Socket
Book a DemoInstallSign in
Socket

canvas-orbit-camera

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

canvas-orbit-camera

An alternative wrapper for orbit-camera that works independently of game-shell.

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
283
-11.84%
Maintainers
1
Weekly downloads
 
Created
Source

canvas-orbit-camera experimental

An alternative wrapper for orbit-camera that works independently of game-shell.

Controls are as follows:

  • Rotate - Left click
  • Pan - Right click or Control + Left click
  • Zoom - Scroll or Shift + Left click

Based heavily on game-shell-orbit-camera.

Usage

NPM

camera = createCamera(canvas[, options])

Attaches a modified orbit-camera instance to the canvas – attaching the required event listeners for interaction.

The following options are available:

  • rotate: disable rotation interactions by passing false.
  • scale: disable scaling interactions by passing false.
  • pan: disable panning interactions by passing false.

See the orbit-camera documentation for a full list of available methods.

camera.tick()

Call this at the beginning of each frame to update the current position of the camera.

camera.view([out])

Returns the current view matrix associated by the camera: a 16-element (4x4) Float32Array instance. Optionally, you can pass in your own array out here too.

Example

var canvas = document.body.appendChild(document.createElement('canvas'))
var createCamera = require('canvas-orbit-camera')
var raf = require('raf')

var camera = createCamera(canvas)

update()
function update() {
  raf(update)

  // Returns your view matrix for you
  var view = camera.view()

  camera.tick()
}

License

MIT. See LICENSE.md for details.

Keywords

canvas

FAQs

Package last updated on 19 Apr 2015

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.