Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikolalysenko/game-shell-orbit-camera
Attaches an orbit-camera to a game-shell instance with default key bindings
https://github.com/mikolalysenko/game-shell-orbit-camera
Last synced: about 2 months ago
JSON representation
Attaches an orbit-camera to a game-shell instance with default key bindings
- Host: GitHub
- URL: https://github.com/mikolalysenko/game-shell-orbit-camera
- Owner: mikolalysenko
- License: mit
- Created: 2013-07-07T02:48:18.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-05-21T12:06:39.000Z (over 10 years ago)
- Last Synced: 2024-10-20T14:28:20.689Z (2 months ago)
- Language: JavaScript
- Size: 141 KB
- Stars: 10
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
game-shell-orbit-camera
=======================
Creates a default orbit camera controller for a [game-shell](https://github.com/mikolalysenko/game-shell) instance. The controls for this are as follows:* Rotate - Left click
* Pan - Right click or Control + Left click
* Zoom - Scroll or Shift + Left click## Example
"use strict"
```javascript
var shell = require("gl-now")()
var createMesh = require("gl-mesh")
var simple3DShader = require("simple-3d-shader")
var attachCamera = require("game-shell-orbit-camera")
var glm = require("gl-matrix")
var mat4 = glm.mat4var shader, mesh
var camera = attachCamera(shell)camera.lookAt([0, 3, 20], [0, 3, 0], [0, 1, 0])
shell.on("gl-init", function() {
shader = simple3DShader(shell.gl)
mesh = createMesh(shell.gl, require("bunny"))
})shell.on("gl-render", function(t) {
//Bind shader
shader.bind()//Set camera parameters
var scratch = mat4.create()
shader.uniforms.model = scratch
shader.uniforms.projection = mat4.perspective(scratch, Math.PI/4.0, shell.width/shell.height, 0.1, 1000.0)
shader.uniforms.view = camera.view(scratch)
//Draw object
mesh.bind(shader)
mesh.draw()
mesh.unbind()
})
```## Install
npm install game-shell-orbit-camera
### `require("game-shell-orbit-camera")(shell)`
Attaches a camera to the game-shell instance**Returns** An instance of [`orbit-camera`](https://github.com/mikolalysenko/orbit-camera)
## Credits
(c) 2013 Mikola Lysenko. MIT License