Experience-Monks/360-image-viewer is a JavaScript project with 291 stars. A standalone panorama viewer with WebGL
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
A standalone panorama WebGL image viewer for desktop and mobile. This uses regl as the WebGL wrapper, and comes in at a total of 140kb uglified, or 46kb gzipped. This is useful if you need a panorama viewer but don't want to embed all of ThreeJS (which is around 500kb uglified).
Install
npm install 360-image-viewer --save
Live Demo
Click here to see a demo of this module in action. The source code is in demo/index.js.
Example
The code below sets up a full-screen 360 image viewer. For a more complete example, see demo/index.js.
const create360Viewer = require('360-image-viewer');
const canvasFit = require('canvas-fit');
// load your image
const image = new Image();
image.src = 'panosphere.jpg';
image.onload = () => {
// when the image is loaded, setup the viewer
const viewer = create360Viewer({
image: image
});
// attach canvas to body
document.body.appendChild(viewer.canvas);
// setup fullscreen canvas sizing
const fit = canvasFit(viewer.canvas, window, window.devicePixelRatio);
window.addEventListener('resize', fit, false);
fit();
// start the render loop
viewer.start();
};
Usage
viewer = create360Viewer([opt])
Creates and returns a new WebGL canvas viewer with the specified opt options object.
Options:
image — the HTMLImageElement, if not specified it can be set later
canvas — a <canvas> tag to use, otherwise creates a new one
fov — a field of view, in radians, defaults to 45 degrees
rotateSpeed — a scalar for the drag rotation speed, default 0.15
damping — a scalar for damping/spring, default 0.275
You can also pass orbit-controls options, for example phi as the initial rotation, or passing { rotate: fale } to ignore mouse/touch rotation.
The image should be a DOM Image or Video element, and should already be loaded.
viewer.start()
Start the requestAnimationFrame render loop.
viewer.stop()
Stop the requestAnimationFrame render loop.
viewer.render()
Render a single frame. This may be useful if, say, you change the canvas size when the requestAnimationFrame is not running.
viewer.enableControls()
Enable the input controls, attaching mouse/touch events to the canvas. Has no effect if the controls are already enabled.
viewer.disableControls()
Disable the input controls, detaching mouse/touch events from the canvas. Has no effect if the controls are already disabled.
viewer.texture(image)
Changes the current image to the specified DOM image. This can be an image, video, or an options object for regl#texture(). By default, min and mag filter will use 'linear' for smoother filtering.
viewer.destroy()
Stop the render loop, disable the input controls, and destroy the WebGL context. The viewer will no longer be usable after this point.
viewer.canvas
The canvas the viewer will render into.
viewer.fov
The current field of view of the perspective camera in radians. Can be altered at run-time.
viewer.phi
The current horizontal rotation angle in radians.
viewer.theta
The current vertical rotation angle in radians.
viewer.on('tick', fn)
Attach a frame listener to the viewer, where fn accepts the dt (delta time) parameter per frame. You can remove this with viewer.removeListener('tick', fn).
Yes — Experience-Monks/360-image-viewer ships under the MIT license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/Experience-Monks/360-image-viewer.
What is Experience-Monks/360-image-viewer?
Experience-Monks/360-image-viewer (Experience-Monks/360-image-viewer) is a JavaScript project on GitHub. From the project's own README: A standalone panorama viewer with WebGL
Where do I read more about Experience-Monks/360-image-viewer?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/Experience-Monks/360-image-viewer is the definitive source.
Read full README in the tab above.
Want a second opinion on 360-image-viewer?
Ask an AI that can read this page — one click and you get its take on 360-image-viewer.