npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

camera-spin

v3.0.1

Published

Mouse/touch-draggable first-person camera

Downloads

7

Readme

camera-spin

stable

Mouse/touch-draggable first-person camera. Useful for out-of-the-box Google Street View-style camera controls.

Usage

NPM

camera = Camera(element, origin, up)

Creates a new camera instance. All arguments are optional:

  • element is the DOM element to attach to and make interactive.
  • origin is a [x, y, z] array specifying the position of the camera. Defaults to [0, 0, 0].
  • up is a [x, y, z] array specifying the "up" vector to use. Defaults to [0, 1, 0].

view = camera.tick()

This function should be run once per frame in your requestAnimationFrame loop:

const raf = require('raf')

render()
function render () {
  camera.tick()
  raf(render)
}

It's responsible for updating the camera parameters in response to user input. Returns view, your 4x4 Float32Array view matrix to give your shaders.

view = camera.view()

Calculates and returns the 4x4 view matrix provided by camera.tick() without performing any of the user input handling.

camera.direction

A normalized [x, y, z] array specifying the direction the camera is currently looking as a vector. You can use this, for example, to move the camera forward in the direction it's looking:

camera.origin[0] += camera.direction[0] * distance
camera.origin[1] += camera.direction[1] * distance
camera.origin[2] += camera.direction[2] * distance

The value is read-only: it'll be updated each time you call camera.tick().

camera.rotation

An [x, y] array containing the horizontal and vertical rotation in radians. You can use this to manually point the camera in a specific direction.

camera.lookSpeed

Change this value to set the speed at which the camera moves around, i.e. its mouse sensitivity. Should be between 0 and 1. Defaults to 0.003.

camera.dragRate

Change this value to set the rate of interpolation between rotation values. Should be between 0 and 1 — lower values will result in smoother motion, higher values will increase responsiveness. Defaults to 0.2.

camera.dispose()

Tear everything down once you're no longer using the camera. Required if you need to clean up after yourself :)

License

MIT, see LICENSE.md for details.