Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
orbit-camera
Advanced tools
Simple arcball camera built on top of gl-matrix
var shell = require("gl-now")()
var createMesh = require("gl-mesh")
var glm = require("gl-matrix")
var mat4 = glm.mat4
var simple3DShader = require("simple-3d-shader")
var createOrbitCamera = require("orbit-camera")
var camera = createOrbitCamera([0, 10, 20],
[0, 3, 0],
[0, 1, 0])
var shader, mesh
shell.on("gl-init", function() {
shader = simple3DShader(shell.gl)
mesh = createMesh(shell.gl, require("bunny"))
})
shell.on("gl-render", function(t) {
shader.bind()
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)
mesh.bind(shader)
mesh.draw()
mesh.unbind()
})
shell.on("tick", function() {
if(shell.wasDown("mouse-left")) {
camera.rotate([shell.mouseX/shell.width-0.5, shell.mouseY/shell.height-0.5],
[shell.prevMouseX/shell.width-0.5, shell.prevMouseY/shell.height-0.5])
}
if(shell.wasDown("mouse-right")) {
camera.pan([10*(shell.mouseX-shell.prevMouseX)/shell.width,
10*(shell.mouseY - shell.prevMouseY)/shell.height])
}
if(shell.scroll[1]) {
camera.zoom(shell.scroll[1] * 0.1)
}
})
npm install orbit-camera
var createOrbitCamera = require("orbit-camera")
var camera = createOrbitCamera(eye, center, up)
Creates an orbit camera looking at center
. This has the same semantics as gluLookAt
eye
is the eye vector of the cameracenter
is the target the camera is looking atup
is the up direction for the cameraReturns A new orbit camera object
camera.lookAt(eye, center, up)
Move the camera to look at the new position.
camera.pan(translation)
Moves the center of the camera by translation
. Note that translation must be an array of length either 2 or 3
camera.rotate(cur, prev)
Applies a rotation to the camera. cur
and prev
are the state of the previous locations. These can be pairs of 2D arrays representing the mouse coordinates in distance relative to the center of the sceen.
camera.zoom(delta)
Zooms in or out by some amount
camera.view([out])
Returns the current view matrix associated to the camera
(c) 2013 Mikola Lysenko. MIT License
FAQs
Orbiting 3D camera for WebGL
The npm package orbit-camera receives a total of 24 weekly downloads. As such, orbit-camera popularity was classified as not popular.
We found that orbit-camera demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.