Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hughsk/canvas-orbit-camera
An alternative wrapper for orbit-camera that works independently of game-shell.
https://github.com/hughsk/canvas-orbit-camera
Last synced: 12 days ago
JSON representation
An alternative wrapper for orbit-camera that works independently of game-shell.
- Host: GitHub
- URL: https://github.com/hughsk/canvas-orbit-camera
- Owner: hughsk
- License: other
- Created: 2014-05-13T21:27:08.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-04-18T21:05:37.000Z (over 6 years ago)
- Last Synced: 2024-10-17T16:40:52.201Z (22 days ago)
- Language: JavaScript
- Size: 162 KB
- Stars: 20
- Watchers: 4
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
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 clickBased 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.