Convert Figma logo to code with AI

pchen66 logopanolens.js

Javascript panorama viewer based on Three.js

2,784
497
2,784
145

Top Related Projects

101,622

JavaScript 3D Library.

Easily display interactive 3D models on the web and in AR!

16,566

:a: Web framework for building virtual reality experiences.

36,911

Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.

Babylon.js is a powerful, beautiful, simple, and open game and rendering engine packed into a friendly JavaScript framework.

🇨🇭 A React renderer for Three.js

Quick Overview

Panolens.js is a JavaScript library for creating immersive 360-degree panorama viewers and virtual tours. It provides an easy-to-use API for developers to create interactive panoramic experiences on the web, supporting various types of panoramas including equirectangular, cubic, and little planet projections.

Pros

  • Easy to use with a simple and intuitive API
  • Supports multiple panorama types and formats
  • Built on top of Three.js, providing powerful 3D rendering capabilities
  • Responsive and works well on both desktop and mobile devices

Cons

  • Limited documentation and examples compared to some other panorama libraries
  • Dependency on Three.js may increase the overall file size of projects
  • May have performance issues with very large or complex panoramas on low-end devices

Code Examples

Creating a basic panorama viewer:

const panorama = new PANOLENS.ImagePanorama('path/to/image.jpg');
const viewer = new PANOLENS.Viewer();
viewer.add(panorama);

Adding hotspots to a panorama:

const infospot = new PANOLENS.Infospot(300, PANOLENS.DataImage.Info);
infospot.position.set(0, 0, -5000);
infospot.addHoverText('Hello, world!');
panorama.add(infospot);

Creating a virtual tour with multiple panoramas:

const panorama1 = new PANOLENS.ImagePanorama('path/to/image1.jpg');
const panorama2 = new PANOLENS.ImagePanorama('path/to/image2.jpg');

const viewer = new PANOLENS.Viewer();
viewer.add(panorama1, panorama2);

const link = new PANOLENS.Infospot(300, PANOLENS.DataImage.Link);
link.position.set(0, 0, -5000);
link.addEventListener('click', () => {
  viewer.setPanorama(panorama2);
});
panorama1.add(link);

Getting Started

  1. Include the Panolens.js library in your HTML file:
<script src="https://cdn.jsdelivr.net/npm/panolens@0.12.1/build/panolens.min.js"></script>
  1. Create a container element for the panorama viewer:
<div id="panorama-container"></div>
  1. Initialize a panorama and viewer in your JavaScript:
const panorama = new PANOLENS.ImagePanorama('path/to/your/panorama.jpg');
const viewer = new PANOLENS.Viewer({
  container: document.querySelector('#panorama-container')
});
viewer.add(panorama);

This will create a basic panorama viewer with your specified image. You can then add interactivity, hotspots, and additional features as needed.

Competitor Comparisons

101,622

JavaScript 3D Library.

Pros of three.js

  • More comprehensive and versatile for general 3D graphics
  • Larger community and ecosystem, with extensive documentation
  • Offers greater control and customization for complex 3D scenes

Cons of three.js

  • Steeper learning curve for beginners
  • Requires more code and setup for simple panoramic views
  • Higher complexity for basic panorama projects

Code Comparison

three.js:

const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

panolens.js:

const panorama = new PANOLENS.ImagePanorama('path/to/image.jpg');
const viewer = new PANOLENS.Viewer();
viewer.add(panorama);

three.js is a powerful 3D graphics library that provides a wide range of features for creating complex 3D scenes and animations. It offers more flexibility and control but requires more setup and knowledge to use effectively.

panolens.js, built on top of three.js, simplifies the process of creating panoramic and virtual tour experiences. It abstracts away much of the complexity, making it easier for developers to quickly implement panoramic views with less code.

While three.js is more versatile for general 3D graphics, panolens.js is more specialized and user-friendly for panoramic projects.

Easily display interactive 3D models on the web and in AR!

Pros of model-viewer

  • Built-in AR support for mobile devices
  • Easier integration with web components
  • More extensive documentation and examples

Cons of model-viewer

  • Limited to 3D models, not suitable for panoramic images
  • Heavier file size due to additional features
  • Steeper learning curve for customization

Code Comparison

model-viewer:

<model-viewer
  src="model.glb"
  ar
  auto-rotate
  camera-controls
  shadow-intensity="1"
  exposure="1"
>
</model-viewer>

panolens.js:

const panorama = new PANOLENS.ImagePanorama('panorama.jpg');
const viewer = new PANOLENS.Viewer({
  container: document.querySelector('#viewer')
});
viewer.add(panorama);

Summary

model-viewer excels in 3D model visualization with AR capabilities, while panolens.js specializes in panoramic image display. model-viewer offers easier integration but has a larger file size and is limited to 3D models. panolens.js provides more flexibility for panoramic content but requires more setup. Choose based on your specific needs: 3D models with AR support (model-viewer) or panoramic image visualization (panolens.js).

16,566

:a: Web framework for building virtual reality experiences.

Pros of A-Frame

  • More comprehensive VR/AR framework with a larger ecosystem
  • Entity-Component-System architecture for better extensibility
  • Wider browser and device support, including mobile VR

Cons of A-Frame

  • Steeper learning curve for beginners
  • Potentially heavier and slower for simple panoramic experiences
  • Requires more setup for basic panorama viewing

Code Comparison

Panolens.js:

const viewer = new PANOLENS.Viewer();
const panorama = new PANOLENS.ImagePanorama('path/to/image.jpg');
viewer.add(panorama);

A-Frame:

<a-scene>
  <a-sky src="path/to/image.jpg"></a-sky>
  <a-camera></a-camera>
</a-scene>

Summary

A-Frame is a more robust and versatile framework for creating VR/AR experiences, offering greater extensibility and a wider range of features. However, it may be overkill for simple panoramic viewing tasks. Panolens.js, on the other hand, is more focused on panoramic experiences and easier to set up for basic use cases. A-Frame's code is HTML-based, while Panolens.js uses JavaScript for initialization. Choose A-Frame for complex VR/AR projects, and Panolens.js for straightforward panoramic viewing.

36,911

Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.

Pros of Phaser

  • More comprehensive game development framework with a wider range of features
  • Larger community and ecosystem, providing better support and resources
  • Suitable for creating various types of 2D games, not limited to panoramic experiences

Cons of Phaser

  • Steeper learning curve due to its broader scope and complexity
  • Potentially overkill for simple panoramic or VR projects
  • Larger file size and potentially higher performance overhead

Code Comparison

Panolens.js (creating a simple panorama):

const panorama = new PANOLENS.ImagePanorama('path/to/image.jpg');
const viewer = new PANOLENS.Viewer();
viewer.add(panorama);

Phaser (creating a simple game scene):

const config = { type: Phaser.AUTO, width: 800, height: 600, scene: { preload, create, update } };
const game = new Phaser.Game(config);

function preload() {
    this.load.image('sky', 'assets/sky.png');
}

While Panolens.js focuses on creating panoramic and VR experiences with minimal code, Phaser provides a more extensive framework for game development, requiring more setup but offering greater flexibility for various game types.

Babylon.js is a powerful, beautiful, simple, and open game and rendering engine packed into a friendly JavaScript framework.

Pros of Babylon.js

  • More comprehensive 3D engine with advanced features like physics, animations, and particle systems
  • Larger community and ecosystem, with extensive documentation and examples
  • Better performance for complex 3D scenes and games

Cons of Babylon.js

  • Steeper learning curve due to its extensive feature set
  • Larger file size, which may impact load times for simpler projects
  • Potentially overkill for basic panoramic or VR experiences

Code Comparison

Babylon.js (creating a basic scene):

const canvas = document.getElementById("renderCanvas");
const engine = new BABYLON.Engine(canvas, true);
const scene = new BABYLON.Scene(engine);
const camera = new BABYLON.FreeCamera("camera", new BABYLON.Vector3(0, 5, -10), scene);
const light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(0, 1, 0), scene);

Panolens.js (creating a basic panorama):

const panorama = new PANOLENS.ImagePanorama('path/to/image.jpg');
const viewer = new PANOLENS.Viewer({
  container: document.querySelector('#container')
});
viewer.add(panorama);

Babylon.js offers a more powerful and versatile 3D engine suitable for complex applications, while Panolens.js provides a simpler, more focused solution for panoramic and VR experiences. The choice between them depends on the specific requirements of your project.

🇨🇭 A React renderer for Three.js

Pros of react-three-fiber

  • Seamless integration with React ecosystem and state management
  • Declarative approach to 3D scene creation, aligning with React's philosophy
  • Extensive community support and regular updates

Cons of react-three-fiber

  • Steeper learning curve for developers unfamiliar with React
  • Potentially higher performance overhead due to React's reconciliation process
  • Less focused on panoramic experiences compared to panolens.js

Code Comparison

react-three-fiber:

function Scene() {
  return (
    <Canvas>
      <mesh>
        <sphereGeometry args={[1, 32, 32]} />
        <meshStandardMaterial color="red" />
      </mesh>
    </Canvas>
  );
}

panolens.js:

const panorama = new PANOLENS.ImagePanorama('path/to/image.jpg');
const viewer = new PANOLENS.Viewer({
  container: document.querySelector('#container')
});
viewer.add(panorama);

react-three-fiber offers a more React-centric approach to 3D development, making it easier for React developers to create complex 3D scenes. However, panolens.js provides a more straightforward API for creating panoramic experiences, with less setup required for basic panoramas. The choice between the two depends on the specific project requirements and the development team's expertise.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Deprecated

This repository will be deprecated due to the rapidly evolving JavaScript ecosystem and the increasing difficulty of keeping up with the changes in the Three.js API.

Over the years, the Three.js library has undergone significant updates and improvements, introducing new features and optimizations. However, these advancements have also led to changes in the API, making it challenging for us to maintain this repository effectively.

We understand that this may be disappointing news for those who have relied on this repository for their projects. We apologize for any inconvenience this may cause.

To ensure that you can continue to benefit from the latest updates and improvements in the Three.js library, we recommend using the official Three.js documentation and resources. The official documentation provides comprehensive guides, examples, and API references to help you leverage the full potential of Three.js in your projects.

Here are some alternative resources that we recommend:

We want to express our gratitude to the community for your support and contributions to this repository. We encourage you to migrate your projects to alternative solutions as there are many more Javascript-based panorama viewer nowadays compared to 2015.

This repository will remain available for historical purposes, but no further updates or bug fixes will be provided. We encourage you to fork this repository if you wish to continue maintaining it independently.

Thank you for your understanding and continued support.

Panolens.js

NPM package License Bundle Size Build Status Dependencies Dev Dependencies Language Grade Coverage

Javascript 360 Panorama Viewer

Panolens.js is an event-driven and WebGL based panorama viewer. Lightweight and flexible. It's built on top of Three.JS.

ExamplesDocumentationMigrationFAQ

Panorama Demo

Usage

Include three.min.js and panolens.min.js

To find the correct supported versions, please check dependencies section in package.json or acess PANOLENS.VERSION or PANOLENS.THREE_VERSION at runtime.

<script src="js/three.min.js"></script>
<script src="js/panolens.min.js"></script>

The following code generates a 360 image panorama. The first panorama added to the viewer will be the entry point. To link panoramas, use panorama.link( other_panorama, new THREE.Vector3( X, Y, Z ) ) to connect the two.

const panorama = new PANOLENS.ImagePanorama( 'asset/equirectangular.jpg' );
const viewer = new PANOLENS.Viewer();
viewer.add( panorama );

Dependency

Panolens.js includes Tween.js by default, meaning TWEEN will be available with window object

How to contribute

Always make your contributions for the latest dev branch, not master, so it can be tracked for the next release.

Development

npm start

Build

npm run build-closure

NPM DownloadsLast 30 Days