A 360 javascript viewer working with images

Usage no npm install needed!

<script type="module">
  import 3dweb360javascriptviewer from 'https://cdn.skypack.dev/@3dweb/360javascriptviewer';


360 Javascript Viewer

A flexible light responsive 360 image viewer with zoom functions. You can use it with npm (typescript support) or include the script on your page. Autorotate, batch loading of images, inertia and speed control. Events for making custom progress bars, intro animations and custom zoom functions. Several methods for navigation from outside which return promises for easy chaining of actions. Use all kind of images from any location with flexible start numbering and filenames.

Check for examples on 360-javascriptviewer.com


using npm with typescript declaration file:

npm i @3dweb/360javascriptviewer

import {JavascriptViewer} from "@3dweb/360javascriptviewer";

or use the CDN to get the latest version

<script src="https://unpkg.com/@3dweb/360javascriptviewer"></script>

Basic usage

First create a div where the 360 presentation will be created. We use the size of this div to calculate zoom positions. The events for dragging and zooming are also added to this div (default #jsv-holder). Insert a image in it which is often the first image of the 360 image serie. This image will be replaced by the 360 presentation when it's fully loaded. If you don't specify otherwise this image is used to determine the other image filenames. If the main image is product.jpg, the other images in the same folder must be called product_1.jpg, product_2.jpg and so on. But if you have other filenames/locations for your 360 images, you can change this naming format behaviour with the imageUrlFormat parameter.

    <div id="jsv-holder">
        <img id="jsv-image" alt="example" src="https://360-javascriptviewer.com/images/ipod/ipod.jpg">
        const viewer = new JavascriptViewer({
            mainHolderId: 'jsv-holder',
            mainImageId: 'jsv-image',
            totalFrames: 72,
            speed: 70,
            defaultProgressBar: true
        // use events for example
        viewer.events().loadImage.on((progress) => {
            // use this for your own progress bar    
            console.log(`loading ${progress.percentage}%`)
         viewer.events().started.on((result) => {
            // use a promise or a start event to trigger things    
         viewer.start().then(() => {
            viewer.rotateDegrees(180).then(() => {
                // continue with your amazing intro



property type description default
mainImageId string ID of the image which is the base for all the frames. You can also use mainImageUrl jsv-image
mainHolderId string ID of the div where the presentation runs in. jsv-holder
mainImageUrl string URl of the first image, doesn't have to be in the document. mainImageId is not necessary with this option
totalFrames number Amount of frames in the presentation, more images means smoother rotations. 72
imageUrls string[] Array of image urls, overrides totalFrames and imageUrlFormat []
firstImageNumber number After loading the presentation this is the first frame visible. 1
reverse boolean Invert the rotation direction when dragging. false
speed number Speed of rotating. -199 to 100 80
inertia number Delay when stop dragging. 20
defaultProgressBar boolean Disable the build in progress bar, use this when you have implemented your own loader or don't like this one. true
imageUrlFormat string Format for determining the filenames of the frames {filename}_xx.{extension} is the default ipod_x.jpg => ipod_1.jpg ipod_xx.jpg => ipod_01.jpg https://other.cdn/images/ipod_xx.jpg => https://other.cdn/images/ipod_01.jpg {filename}_xx.{extension}
startFrameNo number Use this setting in combination with imageUrlFormat startFrameNo: 4 => first file is ipod_04.jpg 1
autoRotate number Use this setting for rotating the view at start. Rotation stops when user drags the model or another animation method is called. 1
autoRotateSpeed number Speed of autorotation. -199 to 100 1
autoRotateReverse boolean Use this setting for changing the direction of the auto rotating. 1
enableImageEvents boolean Use this setting for enabling click pinch and wheel events on images. 0
zoom boolean Use this setting for enabling zoom functions. Zoom on wheel event or pinch. 0
zoomWheelSpeed number Change the speed of zooming with the mousewheel. 50
zoomMax number If zoom is enabled this is the max zoom factor. 2
stopAtEdges boolean Blocks repeating images after reaching last image. 0
autoCDNResizer boolean Set the query params height and width for use with an image resizer. 0
enableChangeImageEvent boolean Enable changeImage event on rotation, could be CPU heavy 0
cursorConfig ICursorConfig Change the cursors for the presentation
notificationConfig InotificationConfig Configure the default notifications


  • start():Promise
    Start the presentation, loading all images and replace the main image with a 360 presentation.
  • destroy():Promise
    Destroys the presentation and returns to previous state
  • rotateDegrees(degree: number):Promise
    Set the desired rotation and the 360 model is rotating to it.
  • rotateToDegree(targetDegree: number, shortestWay?: boolean, useEasing?: boolean)):Promise
    Rotate to a certain degree. Frame nr 1 is 0 degrees.
  • rotateToFrame(frame: number, shortestWay?: boolean, useEasing?: boolean)):Promise
    Rotate to a certain frame.
  • setSpeed(speed:number):void Zoom and pan in the image.
  • zoomTo(factor: number, x: number, y: number):Promise
    Zoom with a factor and pan in percentage from the middle -1-0 and 0-1.
  • setInertia(inertia:number):void
    Set the current inertia of the viewer
  • events():IEvents
    Use this to register events.-
    isZoomedIn():boolean Checks if the presentation is zoomed.


  • loadImage:IProgress Use this event to create your own progress bar
    viewer.events().loadImage.on((progress) => { // use the progress object for your own loader })

  • started:boolean Use this event to trigger other actions when the viewer is ready
    viewer.events().started.on((boolean) => { // start intro animations or other creative ideas })

  • startDragging:IHandle Use this event to capture the user drag movement. viewer.events().startDragging.on((handle) => { // show or hide information on the viewer or send statistics })

  • changeImage:IStatus Fires when a new image becomes visible, works in combination with enableChangeImageEvent:true viewer.events().changeImage.on((handle) => { // show or hide information on the viewer or send statistics })

  • endAutoRotate:IStatus Fires when autorotate stops viewer.events().endAutoRotate.on((status) => { // show or hide information on the viewer or send statistics })

  • click:IClick Fires when the user clicks on a image, works in combination with enableImageEvents: true viewer.events().click.on((click) => { // Use this event for zoom functions })

  • pinch:IPinch Fires when the user pinch on a image (zoom on mobile with 2 fingers), works in combination with enableImageEvents: true viewer.events().pinch.on((click) => { // Use this event for zoom functions })

  • scroll:IScroll Fires when the user use the mouse scroll, works in combination with enableImageEvents: true viewer.events().pinch.on((click) => { // Use this event for zoom functions })

  • doubleClick:IClick Fires when the user double clicks on a image, works in combination with enableImageEvents: true viewer.events().pinch.on((click) => { // Use this event for zoom functions })


  • IResponse {
      currentDegree: number;

  • notificationConfig {
      dragToRotate: {
       showStartToRotateDefaultNotification: boolean,
       imageUrl: string,
       languages: ITranslation[],
       mainColor: string //hex,rgb or rgba color
       textColor: string //hex,rgb or rgba color

  • ITranslation { [
      language: string, //ISO Language Code (en-US,nl-NL)
      text: string