![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
This module is a generic interface which synchronizes several existing view interactions
Each camera controller proceeds by appending events onto a log. The current camera state is obtained by interpolating between these events.
var now = require('right-now')
var bunny = require('bunny')
var perspective = require('gl-mat4/perspective')
var fit = require('canvas-fit')
var createContext = require('gl-context')
var createAxes = require('gl-axes')
var createMesh = require('gl-simplicial-complex')
var createCamera = require('3d-view')
//Set up WebGL
var canvas = document.createElement('canvas')
document.body.appendChild(canvas)
window.addEventListener('resize', fit(canvas), false)
var gl = createContext(canvas, {}, render)
//Create objects for rendering
var bounds = [[-10,-10,-10], [10,10,10]]
var mesh = createMesh(gl, {
cells: bunny.cells,
positions: bunny.positions,
colormap: 'jet'
})
var axes = createAxes(gl, {
bounds: bounds,
tickSpacing: [1,1,1],
textSize: 0.05
})
//Set up camera
var projectionMatrix = new Array(16)
var camera = createCamera({
center: [
0.5*(bounds[0][0]+bounds[1][0]),
0.5*(bounds[0][1]+bounds[1][1]),
0.5*(bounds[0][2]+bounds[1][2]) ],
eye: [0, 0, bounds[1][2]],
distanceLimits: [1, 1000]
})
//Create mode drop down
var modeSelect = document.createElement('select')
camera.modes.forEach(function(mode) {
modeSelect.add(new Option(mode, mode))
})
modeSelect.style.position = 'absolute'
modeSelect.style.left = '10px'
modeSelect.style.top = '10px'
modeSelect.style['z-index'] = 10
document.body.appendChild(modeSelect)
//Hook event listeners
var lastX = 0, lastY = 0
document.oncontextmenu = function(e) {
e.preventDefault()
e.stopPropagation()
return false
}
modeSelect.addEventListener('change', function(ev) {
camera.setMode(modeSelect.value)
})
canvas.addEventListener('mousemove', function(ev) {
var dx = (ev.clientX - lastX) / gl.drawingBufferWidth
var dy = -(ev.clientY - lastY) / gl.drawingBufferHeight
if(ev.which === 1) {
if(ev.shiftKey) {
//zoom
camera.rotate(now(), 0, 0, dx)
} else {
//rotate
camera.rotate(now(), dx, dy)
}
} else if(ev.which === 3) {
//pan
camera.pan(now(), dx, dy)
}
lastX = ev.clientX
lastY = ev.clientY
})
canvas.addEventListener('wheel', function(e) {
camera.pan(now(), 0, 0, e.deltaY)
})
//Redraw frame
function render() {
//Update camera parameters
var t = now()
camera.idle(t - 20)
camera.flush(t - 100)
camera.recalcMatrix(t-25)
//Compute parameters
var cameraParams = {
view: camera.computedMatrix,
projection: perspective(
[],
Math.PI/4.0,
gl.drawingBufferWidth/gl.drawingBufferHeight,
0.1,
1000.0)
}
//Draw everything
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight)
gl.enable(gl.DEPTH_TEST)
axes.draw(cameraParams)
mesh.draw(cameraParams)
}
var camera = require('3d-view')([options])
camera.idle(t)
Idles the camera at time t
t
is the time to idle atcamera.flush(t)
Flush all events in camera state before time t
t
is the cut off time for the flushcamera.modes
An array of modes supported by the camera
camera.setMode(mode)
Sets the camera mode
mode
is the new mode. Must be either turntable
, orbit
or matrix
camera.getMode()
Retrieves the current camera mode
camera.lookAt(t, eye, center, up)
Reset camera position to focus on a specified target
t
is the time of the eventeye
is the position of the cameracenter
is the target of the cameraup
is a vector pointing upcamera.rotate(t, yaw, pitch, roll)
Rotates the camera incrementally by some amount
t
is the time of the input eventyaw
is the amount to rotate by along y-axis in radianspitch
is the amount to rotate by along x-axis in radiansroll
is the amount to rotate by along z-axis in radianscamera.pan(t, dx, dy, dz)
Pans the camera in local (view relative) coordinates
t
is the time of the eventdx,dy,dz
is the amount to movecamera.translate(t, dx, dy, dz)
Translates the camera in world (absolute global) coordinates
t
is the time of the eventdx,dy,dz
is the amount to movecamera.setMatrix(t, matrix)
Sets the camera matrix to some fixed 4x4 matrix
t
is the time of the eventmatrix
is the new camera matrixcamera.setDistance(t, r)
Sets camera distance at time t
t
is the time of the eventr
is the new camera distancecamera.setDistanceLimits(lo, hi)
Sets bounds on the camera distance
camera.getDistanceLimits([out])
Retrieves the camera limits
camera.recalcMatrix(t)
Recomputes all matrix properties at time t
camera.computedMatrix
The computed 4x4 matrix of the camera
camera.computedEye
The computed 3d eye vector for the camera
camera.computedUp
Computed up vector (initialized when calling recalcMatrix)
camera.computedCenter
Computed camera center point
camera.computedRadius
Computed log(radius)
(c) 2015 Mikola Lysenko. MIT License
FAQs
3D camera view controller
The npm package 3d-view receives a total of 13,141 weekly downloads. As such, 3d-view popularity was classified as popular.
We found that 3d-view 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
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.