### Start Local Web Server Source: https://github.com/mpetroff/pannellum/blob/master/readme.md Start a local HTTP server to view Pannellum examples or generated configurations. Ensure you are in the correct directory before running. ```bash cd ../.. python3 -m http.server ``` ```bash python3 -m http.server ``` -------------------------------- ### Copy Example Panorama Source: https://github.com/mpetroff/pannellum/blob/master/utils/multires/readme.md Copies an example panorama image to the current directory for processing. ```bash $ cp ../../examples/examplepano.jpg . ``` -------------------------------- ### touchstart Source: https://github.com/mpetroff/pannellum/blob/master/doc/events.md Fired when a touch starts. ```APIDOC ## touchstart ### Description Fired when a touch starts. ### Parameters - **event** (TouchEvent) - The TouchEvent object. ``` -------------------------------- ### Start Local HTTP Server Source: https://github.com/mpetroff/pannellum/blob/master/utils/multires/readme.md Starts a Python HTTP server in the project root to serve the generated panorama tiles and configuration. ```bash $ cd ../.. $ python3 -m http.server ``` -------------------------------- ### Install Local Dependencies for Tile Generation Source: https://github.com/mpetroff/pannellum/blob/master/utils/multires/readme.md Installs necessary Python packages and Hugin tools on Ubuntu for local tile generation. ```bash $ sudo apt install python3 python3-pil python3-numpy python3-pip hugin-tools $ pip3 install --user pyshtools ``` -------------------------------- ### Generate Tiles with Local Dependencies Source: https://github.com/mpetroff/pannellum/blob/master/utils/multires/readme.md Executes the `generate.py` script to create multi-resolution tiles from a panorama image using locally installed dependencies. ```bash python3 generate.py examplepano.jpg ``` -------------------------------- ### Build Docker Image for Tile Generation Source: https://github.com/mpetroff/pannellum/blob/master/utils/multires/readme.md Builds a Docker image named 'generate-panorama' to run the tile generation script without local dependency installation. ```bash $ docker build -t generate-panorama . ``` -------------------------------- ### HTTP Server Request Log Source: https://github.com/mpetroff/pannellum/blob/master/utils/multires/readme.md Example log output from the Python HTTP server showing requests for panorama assets. ```log 127.0.0.1 - - [09/Aug/2019 09:41:24] "GET /src/standalone/pannellum.htm HTTP/1.1" 200 - 127.0.0.1 - - [09/Aug/2019 09:41:24] "GET /src/css/pannellum.css HTTP/1.1" 200 - 127.0.0.1 - - [09/Aug/2019 09:41:24] "GET /src/standalone/standalone.css HTTP/1.1" 200 - 127.0.0.1 - - [09/Aug/2019 09:41:24] "GET /src/js/libpannellum.js HTTP/1.1" 200 - 127.0.0.1 - - [09/Aug/2019 09:41:24] "GET /src/js/pannellum.js HTTP/1.1" 200 - 127.0.0.1 - - [09/Aug/2019 09:41:24] "GET /src/standalone/standalone.js HTTP/1.1" 200 - 127.0.0.1 - - [09/Aug/2019 09:41:24] "GET /utils/multires/output/config.json HTTP/1.1" 200 - 127.0.0.1 - - [09/Aug/2019 09:41:24] "GET /src/css/img/background.svg HTTP/1.1" 200 - 127.0.0.1 - - [09/Aug/2019 09:41:24] "GET /src/css/img/sprites.svg HTTP/1.1" 200 - 127.0.0.1 - - [09/Aug/2019 09:41:24] "GET /src/css/img/compass.svg HTTP/1.1" 200 - 127.0.0.1 - - [09/Aug/2019 09:41:26] "GET /src/css/img/grab.svg HTTP/1.1" 200 - 127.0.0.1 - - [09/Aug/2019 09:41:27] "GET /utils/multires/output//1/r0_0.jpg HTTP/1.1" 200 - 127.0.0.1 - - [09/Aug/2019 09:41:27] "GET /utils/multires/output//1/f0_0.jpg HTTP/1.1" 200 - 127.0.0.1 - - [09/Aug/2019 09:41:27] "GET /utils/multires/output//1/u0_0.jpg HTTP/1.1" 200 - ... ``` -------------------------------- ### View Generated Panorama Source: https://github.com/mpetroff/pannellum/blob/master/utils/multires/readme.md URL to access the multi-resolution panorama in a browser after starting the HTTP server. ```html http://localhost:8000/src/standalone/pannellum.htm#config=../../utils/multires/output/config.json ``` -------------------------------- ### viewer.setYaw / getYaw / setYawBounds / getYawBounds Source: https://context7.com/mpetroff/pannellum/llms.txt Gets or sets the horizontal viewing angle (yaw) in degrees [-180, 180], animating via the shortest path. ```APIDOC ## viewer.setYaw / getYaw / setYawBounds / getYawBounds ### Description Gets or sets the horizontal viewing angle (yaw) in degrees [-180, 180], animating via the shortest path. ### Methods - **getYaw()**: Returns the current horizontal viewing angle. - **setYaw(yaw, animated, callback)**: Sets the horizontal viewing angle. - **getYawBounds()**: Returns the current yaw bounds `[minYaw, maxYaw]`. - **setYawBounds(bounds)**: Sets the yaw bounds. ### Parameters - **yaw** (number) - The horizontal viewing angle in degrees. - **animated** (number) - Optional - Duration in milliseconds for animation. - **callback** (function) - Optional - Function to call after animation completes. - **bounds** (array) - An array containing the minimum and maximum yaw values `[minYaw, maxYaw]`. ### Request Example ```javascript var viewer = pannellum.viewer('panorama', { type: 'equirectangular', panorama: 'pano.jpg', autoLoad: true, yaw: 0, minYaw: -90, maxYaw: 90 }); console.log(viewer.getYaw()); // Animated yaw change (800ms) viewer.setYaw(45, 800, function() { console.log('Yaw reached:', viewer.getYaw()); }); // Check yaw bounds console.log(viewer.getYawBounds()); // Expand yaw limits dynamically viewer.setYawBounds([-180, 180]); ``` ``` -------------------------------- ### Standalone viewer via ``` ``` -------------------------------- ### Display Help for generate.py Source: https://github.com/mpetroff/pannellum/blob/master/readme.md View all available options for the generate.py script by running the help command. ```bash python3 generate.py --help ``` -------------------------------- ### viewer.setHfov / getHfov / setHfovBounds / getHfovBounds Source: https://context7.com/mpetroff/pannellum/llms.txt Gets or sets the horizontal field of view (zoom level) in degrees. ```APIDOC ## viewer.setHfov / getHfov / setHfovBounds / getHfovBounds ### Description Gets or sets the horizontal field of view (zoom level) in degrees. ### Methods - **getHfov()**: Returns the current horizontal field of view. - **setHfov(hfov, animated, callback)**: Sets the horizontal field of view. - **getHfovBounds()**: Returns the current HFOV bounds `[minHfov, maxHfov]`. - **setHfovBounds(bounds)**: Sets the HFOV bounds. ### Parameters - **hfov** (number) - The horizontal field of view in degrees. - **animated** (number | boolean) - Optional - Duration in milliseconds or `false` for instant animation. - **callback** (function) - Optional - Function to call after animation completes. - **bounds** (array) - An array containing the minimum and maximum HFOV values `[minHfov, maxHfov]`. ### Request Example ```javascript var viewer = pannellum.viewer('panorama', { type: 'equirectangular', panorama: 'pano.jpg', autoLoad: true, hfov: 100, minHfov: 50, maxHfov: 150 }); console.log(viewer.getHfov()); console.log(viewer.getHfovBounds()); // Zoom in over 1 second viewer.setHfov(60, 1000, function() { console.log('Zoomed in, hfov:', viewer.getHfov()); }); // Zoom out instantly viewer.setHfov(120, false); // Adjust zoom limits viewer.setHfovBounds([40, 120]); ``` ``` -------------------------------- ### Control Dynamic Content Updates Source: https://context7.com/mpetroff/pannellum/llms.txt Use `setUpdate(true)` to enable continuous redrawing for dynamic panorama sources like video elements, and `setUpdate(false)` to disable it. This is often integrated with video playback events. ```javascript // Integrate with Video.js plugin for 360° video // Include videojs-pannellum-plugin.js and call: // player.pannellum({ northOffset: 0 }); // Or manually with a video element var vid = document.getElementById('pano-video'); var viewer = pannellum.viewer('container', { type: 'equirectangular', panorama: vid, // Pass the video element directly dynamic: true, dynamicUpdate: false, autoLoad: true, showZoomCtrl: false }); vid.addEventListener('play', function() { viewer.setUpdate(true); }); vid.addEventListener('pause', function() { viewer.setUpdate(false); }); ``` -------------------------------- ### Generate Tiles using Docker Source: https://github.com/mpetroff/pannellum/blob/master/utils/multires/readme.md Runs the Docker container to generate panorama tiles, mounting the current directory to '/data' for input and output. ```bash $ docker run -it -v $PWD:/data generate-panorama --output /data/output /data/examplepano.jpg ``` -------------------------------- ### viewer.setPitch / getPitch / setPitchBounds / getPitchBounds Source: https://context7.com/mpetroff/pannellum/llms.txt Gets or sets the vertical viewing angle (pitch) in degrees, with optional bounds clamping. ```APIDOC ## viewer.setPitch / getPitch / setPitchBounds / getPitchBounds ### Description Gets or sets the vertical viewing angle (pitch) in degrees, with optional bounds clamping. ### Methods - **getPitch()**: Returns the current vertical viewing angle. - **setPitch(pitch, animated, callback, callbackArgs)**: Sets the vertical viewing angle. - **getPitchBounds()**: Returns the current pitch bounds `[minPitch, maxPitch]`. - **setPitchBounds(bounds)**: Sets the pitch bounds. ### Parameters - **pitch** (number) - The vertical viewing angle in degrees. - **animated** (number) - Optional - Duration in milliseconds for animation. - **callback** (function) - Optional - Function to call after animation completes. - **callbackArgs** (object) - Optional - Custom arguments to pass to the callback. - **bounds** (array) - An array containing the minimum and maximum pitch values `[minPitch, maxPitch]`. ### Request Example ```javascript var viewer = pannellum.viewer('panorama', { type: 'equirectangular', panorama: 'pano.jpg', autoLoad: true, minPitch: -60, maxPitch: 30 }); // Read current pitch console.log(viewer.getPitch()); // Set pitch with 1.5 second animation + callback viewer.setPitch(-30, 1500, function(args) { console.log('setPitch done, args:', args); }, { info: 'custom' }); // Read allowed pitch range console.log(viewer.getPitchBounds()); // Dynamically update pitch bounds viewer.setPitchBounds([-45, 45]); ``` ``` -------------------------------- ### Utility Methods: getConfig, getContainer, isLoaded, resize Source: https://context7.com/mpetroff/pannellum/llms.txt These methods provide utilities for querying the viewer's state and managing its DOM container. `getConfig` retrieves the current configuration, `getContainer` returns the DOM element, `isLoaded` checks if the panorama is loaded, and `resize` handles programmatic resizing of the viewer. ```APIDOC ## viewer.getConfig / getContainer / isLoaded / resize ### Description Miscellaneous utility methods for querying viewer state and managing the DOM. ### Methods - `viewer.isLoaded()`: Returns `true` if the panorama is loaded, `false` otherwise. - `viewer.getConfig()`: Returns the full current configuration object. - `viewer.getContainer()`: Returns the DOM element that contains the viewer. - `viewer.resize()`: Notifies the viewer to resize, typically after its container has been programmatically resized. ### Request Example ```javascript var viewer = pannellum.viewer('panorama', { type: 'equirectangular', panorama: 'pano.jpg', autoLoad: true }); viewer.on('load', function() { // Check if panorama is loaded console.log(viewer.isLoaded()); // true // Get the full current configuration object var cfg = viewer.getConfig(); console.log(cfg.panorama); // 'pano.jpg' // Get container element var el = viewer.getContainer(); console.log(el.id); // 'panorama' }); // After programmatic resize of the container div, notify the viewer document.getElementById('resize-btn').addEventListener('click', function() { document.getElementById('panorama').style.height = '600px'; viewer.resize(); }); ``` ``` -------------------------------- ### Manage Scenes Dynamically Source: https://context7.com/mpetroff/pannellum/llms.txt Use `loadScene` to switch scenes, `getScene` to query the current scene, `addScene` to add new scenes, and `removeScene` to remove existing scenes. ```javascript var viewer = pannellum.viewer('panorama', { default: { firstScene: 'scene1', sceneFadeDuration: 1000 }, scenes: { scene1: { title: 'Scene 1', type: 'equirectangular', panorama: 'pano1.jpg', autoLoad: true }, scene2: { title: 'Scene 2', type: 'equirectangular', panorama: 'pano2.jpg' } } }); console.log(viewer.getScene()); // 'scene1' // Switch to scene2, landing at specific pitch/yaw/hfov viewer.loadScene('scene2', -5, 90, 100); // Add a new scene dynamically viewer.addScene('scene3', { title: 'Scene 3', type: 'equirectangular', panorama: 'pano3.jpg' }); // Navigate to the new scene viewer.loadScene('scene3'); // Remove a non-current scene var success = viewer.removeScene('scene2'); console.log('Removed scene2:', success); // true ``` -------------------------------- ### Build Pannellum Source: https://github.com/mpetroff/pannellum/blob/master/readme.md Execute the build script to create a minified version of Pannellum. This process requires Python 3.2+ and Java. ```bash cd utils/build ./build.sh ``` -------------------------------- ### Device Orientation: startOrientation, stopOrientation, isOrientationSupported, isOrientationActive Source: https://context7.com/mpetroff/pannellum/llms.txt Enable gyroscope/device-orientation–based panorama control on supported mobile devices. These methods allow you to start and stop the orientation control, and check if it is supported and active. ```APIDOC ## viewer.startOrientation / stopOrientation / isOrientationSupported / isOrientationActive ### Description Enable gyroscope/device-orientation–based panorama control on supported mobile devices (requires HTTPS). ### Methods - `viewer.startOrientation()`: Starts device orientation control. - `viewer.stopOrientation()`: Stops device orientation control. - `viewer.isOrientationSupported()`: Returns `true` if device orientation is supported, `false` otherwise. - `viewer.isOrientationActive()`: Returns `true` if device orientation is currently active, `false` otherwise. ### Request Example ```javascript var viewer = pannellum.viewer('panorama', { type: 'equirectangular', panorama: 'pano.jpg', autoLoad: true, orientationOnByDefault: false }); document.getElementById('gyro-btn').addEventListener('click', function() { if (viewer.isOrientationSupported()) { if (viewer.isOrientationActive()) { viewer.stopOrientation(); console.log('Gyro off'); } else { viewer.startOrientation(); console.log('Gyro on'); } } else { console.warn('Device orientation not supported'); } }); ``` ``` -------------------------------- ### Initialize Pannellum Viewer with Multiple Scenes Source: https://github.com/mpetroff/pannellum/blob/master/tests/tests.html Initializes the Pannellum viewer with default settings and defines multiple scenes, including cubemap and equirectangular types. Use this for setting up a multi-scene panorama viewer. ```javascript viewer = pannellum.viewer('panorama', { "default": { "author": "testauthor", "firstScene": "equirectangular", "autoLoad": true }, "scenes": { "cube": { "title": "cube title", "type": "cubemap", "cubeMap": [ "../examples/multires/1/f00.png", "../examples/multires/1/r00.png", "../examples/multires/1/b00.png", "../examples/multires/1/l00.png", "../examples/multires/1/u00.png", "../examples/multires/1/d00.png" ], "hotSpots": [ { "pitch": -12, "yaw": 170, "type": "info", "text": "info test" }, { "pitch": -10, "yaw": -50, "type": "info", "text": "link test", "URL": "https://github.com/mpetroff/pannellum" }, { "pitch": 0, "yaw": -10, "type": "scene", "text": "scene test", "sceneId": "multires" } ] }, "equirectangular": { "title": "equirectangular title", "panorama": "../examples/examplepano.jpg" }, "multires": { "title": "multires title", "type": "multires", "hfov": 85, "multiRes": { "basePath": "../examples/multires", "path": "/%l/%s%x%y", "fallbackPath": "/fallback/%s", "extension": "png", "tileResolution": 256, "maxLevel": 4, "cubeResolution": 2048 }, "hotSpots": [ { "pitch": 20, "yaw": 20, "type": "info", "text": "drag test", "draggable": true, "dragHandlerFunc": console.log } ] } } }); ``` -------------------------------- ### Orientation Correction: getNorthOffset, setNorthOffset, getHorizonPitch, setHorizonPitch, getHorizonRoll, setHorizonRoll Source: https://context7.com/mpetroff/pannellum/llms.txt These methods allow for correcting compass north offset and non-level panorama horizons. You can set and get the north offset, as well as adjust the pitch and roll of the horizon to correct for a tilted camera. ```APIDOC ## viewer.getNorthOffset / setNorthOffset / getHorizonPitch / setHorizonPitch / getHorizonRoll / setHorizonRoll ### Description Correct compass north offset and non-level panorama horizons. ### Methods - `viewer.setNorthOffset(offset)`: Sets the compass north offset in degrees. - `viewer.getNorthOffset()`: Returns the current compass north offset in degrees. - `viewer.setHorizonPitch(pitch)`: Sets the horizon pitch correction in degrees. - `viewer.getHorizonPitch()`: Returns the current horizon pitch correction in degrees. - `viewer.setHorizonRoll(roll)`: Sets the horizon roll correction in degrees. - `viewer.getHorizonRoll()`: Returns the current horizon roll correction in degrees. ### Request Example ```javascript var viewer = pannellum.viewer('panorama', { type: 'equirectangular', panorama: 'pano.jpg', autoLoad: true, compass: true, northOffset: 0, horizonPitch: 0, horizonRoll: 0 }); // Adjust compass north alignment viewer.setNorthOffset(135); console.log(viewer.getNorthOffset()); // 135 // Correct a tilted camera (horizon pitch/roll in degrees) viewer.setHorizonPitch(3.5); viewer.setHorizonRoll(-1.2); console.log(viewer.getHorizonPitch()); // 3.5 console.log(viewer.getHorizonRoll()); // -1.2 ``` ``` -------------------------------- ### load Source: https://github.com/mpetroff/pannellum/blob/master/doc/events.md Fired when a panorama finishes loading. ```APIDOC ## load ### Description Fired when a panorama finishes loading. ### Parameters This event does not pass any parameters to its handler. ``` -------------------------------- ### Query Viewer State and Manage DOM with Utility Methods Source: https://context7.com/mpetroff/pannellum/llms.txt Use these methods to check if a panorama is loaded, retrieve the current configuration, and access the viewer's container element. The `resize()` method should be called after programmatic changes to the container's dimensions. ```javascript var viewer = pannellum.viewer('panorama', { type: 'equirectangular', panorama: 'pano.jpg', autoLoad: true }); viewer.on('load', function() { // Check if panorama is loaded console.log(viewer.isLoaded()); // true // Get the full current configuration object var cfg = viewer.getConfig(); console.log(cfg.panorama); // 'pano.jpg' console.log(cfg.hfov); // 100 // Get container element var el = viewer.getContainer(); console.log(el.id); // 'panorama' el.style.border = '2px solid blue'; }); // After programmatic resize of the container div, notify the viewer document.getElementById('resize-btn').addEventListener('click', function() { document.getElementById('panorama').style.height = '600px'; viewer.resize(); }); ``` -------------------------------- ### Generate Multiresolution Tiles with Python Source: https://context7.com/mpetroff/pannellum/llms.txt Use `generate.py` to convert an equirectangular image into multiresolution tiles and a `config.json`. Requires `nona`, Pillow, and NumPy. Specify `nona` path, custom output directory, or use a Docker environment. ```bash # Basic usage — output goes to ./output/ cd utils/multires python3 generate.py pano_image.jpg ``` ```bash # Specify path to nona if not on PATH python3 generate.py -n /usr/local/bin/nona pano_image.jpg ``` ```bash # Specify custom output directory python3 generate.py --output /var/www/html/mypano pano_image.jpg ``` ```bash # Specify a Dockerfile-based environment instead docker build -t pannellum-generate . docker run --rm -v $(pwd):/data pannellum-generate pano_image.jpg ``` ```bash # View the result with Python's built-in server cd ../.. python3 -m http.server # Open: http://localhost:8000/src/standalone/pannellum.htm#config=../../utils/multires/output/config.json ``` -------------------------------- ### Generate Multiresolution Tiles Source: https://context7.com/mpetroff/pannellum/llms.txt Use this bash script to generate multiresolution tiles and a configuration file from a source equirectangular image. Navigate to the multires directory before running. ```bash cd utils/multires python3 generate.py pano_image.jpg ``` -------------------------------- ### Run Selenium Tests Source: https://github.com/mpetroff/pannellum/blob/master/readme.md Execute the Selenium-based test suite. This requires Python 3, Selenium bindings, Pillow, NumPy, and a WebDriver. ```bash python3 run_tests.py ``` ```bash python3 tests/run_tests.py --create-ref ``` ```bash python tests/run_tests.py --help ``` -------------------------------- ### Dynamic Content Updates: setUpdate Source: https://context7.com/mpetroff/pannellum/llms.txt For dynamic panorama sources like video elements, this method controls whether the viewer redraws continuously. Set to `true` for continuous updates (e.g., during video playback) and `false` to pause updates. ```APIDOC ## viewer.setUpdate(bool) ### Description For dynamic panorama sources such as `