Panolens.js Panorama Viewer

0.12.1 · active · verified Sun Apr 19

Panolens.js is a lightweight, event-driven, and WebGL-based JavaScript library designed for creating interactive 360-degree panorama viewers in web applications. Built on top of Three.JS, it provides robust capabilities for displaying spherical images and videos, including features like infospots, linking between panoramas, and various control mechanisms. The current stable version is 0.12.1, with releases occurring on an irregular basis, often bundling multiple fixes and new features within minor versions, and occasionally introducing significant breaking changes (e.g., the v0.10.0 ES Module refactor). Its key differentiators include its tight integration with Three.JS, emphasis on performance through WebGL, and an event-driven architecture that allows for highly customizable interactions.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a Panolens.js viewer, load an equirectangular image panorama, and add it to the viewer. It also shows how to conceptually link two panoramas, and ensures the viewer is attached to a pre-existing DOM element.

import { Viewer, ImagePanorama } from 'panolens';
import * as THREE from 'three';

// Ensure a DOM element exists for the viewer
const appContainer = document.createElement('div');
appContainer.id = 'panorama-container';
appContainer.style.width = '100vw';
appContainer.style.height = '100vh';
document.body.appendChild(appContainer);

// Create a new panorama from an image
const panorama = new ImagePanorama('https://pchen66.github.io/Panolens/examples/asset/textures/equirectangular/cabin.jpg');

// Create the viewer instance, attaching it to the container
const viewer = new Viewer({
    container: appContainer,
    autoRotate: true,
    autoRotateSpeed: 0.5
});

// Add the panorama to the viewer
viewer.add(panorama);

// Example of linking another panorama (dummy link for demonstration)
const otherPanorama = new ImagePanorama('https://pchen66.github.io/Panolens/examples/asset/textures/equirectangular/field.jpg');
viewer.add(otherPanorama);

// Link the first panorama to the second one at a specific 3D coordinate
panorama.link(otherPanorama, new THREE.Vector3(0, 0, -500), 100);

view raw JSON →