# canvas-orbit-camera

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

Latest version **1.0.2** (published 2015-04-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install canvas-orbit-camera
pnpm add canvas-orbit-camera
yarn add canvas-orbit-camera
bun add canvas-orbit-camera
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2015-04-19 |
| First published | 2014-05-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 20 |
| Author | Hugh Kennedy |
| Maintainers | hughsk |
| Keywords | canvas, orbit, camera, webgl, 3d, arcball, rotation |

## Links

- npm: https://www.npmjs.com/package/canvas-orbit-camera
- Repository: https://github.com/hughsk/canvas-orbit-camera
- Issues: https://github.com/hughsk/canvas-orbit-camera/issues
- npm.io page: https://npm.io/package/canvas-orbit-camera

## Dependencies (5)

- [key-pressed](https://npm.io/package/key-pressed.md) 0.0.1
- [orbit-camera](https://npm.io/package/orbit-camera.md) 0.0.3
- [scroll-speed](https://npm.io/package/scroll-speed.md) ^1.0.0
- [mouse-pressed](https://npm.io/package/mouse-pressed.md) 0.0.1
- [mouse-position](https://npm.io/package/mouse-position.md) ^1.0.0

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2015-04-19
- 1.0.1 — 2014-11-10
- 1.0.0 — 2014-08-25
- 0.0.1 — 2014-07-29
- 0.0.0 — 2014-05-13

## README

# canvas-orbit-camera [![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges)

An alternative wrapper for
[orbit-camera](http://github.com/mikolalysenko/orbit-camera) that works
independently of [game-shell](http://github.com/mikolalysenko/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](http://github.com/mikolalysenko/game-shell-orbit-camera).

## Usage

[![NPM](https://nodei.co/npm/canvas-orbit-camera.png)](https://nodei.co/npm/canvas-orbit-camera/)

### 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](https://github.com/mikolalysenko/orbit-camera#readme)
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

``` javascript
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](http://github.com/hughsk/canvas-orbit-camera/blob/master/LICENSE.md) for details.

---
_Source: https://npm.io/package/canvas-orbit-camera · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
