
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
regl-camera
Advanced tools
A basic reusable "turntable" camera component for regl. (Secretly just spherical coordinates.)
const regl = require('regl')()
const camera = require('regl-camera')(regl, {
center: [0, 2.5, 0]
})
const bunny = require('bunny')
const normals = require('angle-normals')
const drawBunny = regl({
frag: `
precision mediump float;
varying vec3 vnormal;
void main () {
gl_FragColor = vec4(abs(vnormal), 1.0);
}`,
vert: `
precision mediump float;
uniform mat4 projection, view;
attribute vec3 position, normal;
varying vec3 vnormal;
void main () {
vnormal = normal;
gl_Position = projection * view * vec4(position, 1.0);
}`,
attributes: {
position: bunny.positions,
normal: normals(bunny.cells, bunny.positions)
},
elements: bunny.cells
})
regl.frame(() => {
regl.clear({
color: [0, 0, 0, 1]
})
camera(() => {
drawBunny()
})
})
npm i regl-camera
var camera = require('regl-camera')(regl[, options])module.exports of regl-camera is a constructor for the camera. It takes the following arguments:
regl is a handle to the regl instanceoptions is an object with the following optional properties:
center which is the center of the cameratheta the theta angle for the cameraphi the phi angle for the cameradistance the distance from the camera eye to the centerup the up vector for the cameracamera(block)regl-camera sets up an environment with the following variables in both the context and uniform blocks:
| Variable | Type | Description |
|---|---|---|
view | mat4 | The view matrix for the camera |
projection | mat4 | The projection matrix for the camera |
center | vec3 | The center of the camera |
eye | vec3 | The eye coordinates of the camera |
up | vec3 | The up vector for the camera matrix |
theta | float | Latitude angle parameter in radians |
phi | float | Longitude angle parameter in radians |
distance | float | Distance from camera to center of objective |
Note These properties can also be accessed and modified directly by accessing the object
(c) 2016 Mikola Lysenko. MIT License
FAQs
Camera for regl
The npm package regl-camera receives a total of 40 weekly downloads. As such, regl-camera popularity was classified as not popular.
We found that regl-camera demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

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.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.