Quick start

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.

Below you find a test tool and code generator to get an easy start

Installation

You can integrate the viewer with webpack and use the declaration file
install by Go to NPM js to get the 360 viewer @3dweb/360javascriptviewer
Or include the latest version of the script directly on your page.
Copy
current version of the 360 javascript viewer current usage of the 360 javascript viewer current usage of the 360 javascript viewer

Starting with 360 images

First you need images, a lot of images.
More images means smoother rotations but also more CPU and RAM usage for your clients.
Consider a number which can split 360 to a whole number. 36 Images means 10 degrees rotation and 72 means 5 degrees. You can speed up the image loading by putting your images on a CDN. For image hosting we use Cloud Image, it has a great free tier.

screenshot of explorer with named images

If you need to rename the files there are several free utilities out there.
Check this article over renaming files for some inspiration.

Implementation of your 360 images

After you created the product images (and you renamed the files with a number in it) it's time to put them online.
Just like you do with all your images put them in an accessible folder online. If you can reach the images in your browser so does the viewer. Install the viewer and customize it with an intro animation, a custom progressbar or some other fancy things for a good integration on your website. You can also collect analytics data about dragging etc to measure the interest of your visitors. If you need help with the implementation, contact us for more information.

New 360 product images

After the initial setup it's only a matter of adding more images to your folder.

API

Constructor

property type description default
mainImageId string ID of the image which is the base for all the frames jsv-image
mainHolderId string ID of the div where the presentation runs in jsv-holder
totalFrames number Amount of frames in the presentation, more images means smoother rotations 72
imageUrls string[] Array of image urls, overrides totalFrames and imageUrlFormat 72
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 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. 0 is no rotation and 10 is 10 rotations at start. 0
autoRotateSpeed number Use this setting for changing the speed of the auto rotating. null
autoRotateReverse boolean Use this setting for changing the direction of the auto rotating. false
autoRotateReverse boolean Use this setting for changing the direction of the auto rotating. false
enableImageEvents boolean Use this setting for enabling click pinch and wheel events on images. false
zoom boolean Use this setting for enabling zoom functions. Zoom on wheel event or pinch. false
zoomMax number If zoom is enabled this is the max zoom factor. 2
zoomWheelSpeed number Change the speed of zooming with the mousewheel. 50
stopAtEdges boolean Blocks repeating images after reaching last image. false
enableChangeImageEvent boolean Enable changeImage event on rotation, could be CPU heavy. false
cursorConfig ICursorConfig Change the cursors for the presentation { default: 'grab', drag: 'grabbing', zoomIn: 'zoom-in', zoomOut: 'zoom-out', pan: 'move' }

Methods

  • 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.
  • setSpeed(speed:number):void
    Set the current speed of rotating for the viewer instance
  • setInertia(inertia:number):void
    Set the current inertia of the viewer
  • events():IEvents
    Use this to register events.

Events

  • 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 })

  • endAutoRotate:IStatus
    Fires when autorotate stops
    viewer.events().endAutoRotate.
    on((status) => { // console.log('you are looking at image: '+ status.currentImage.id; })

  • click:IClick
    Fires when the user clicks on a image, works in combination with enableImageEvents: true
    viewer.events().click.
    on((status) => { // console.log('you are clicking on image: ' + status.currentImage.id; })

  • 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((status) => { // console.log('you are pinch on image with scale: ' + status.scale; })

  • changeImage:IStatus
    Fires when a new image becomes visible, works in combination with enableChangeImageEvent:true
    viewer.events().changeImage.
    on((status) => { // console.log('you are watching at image ${status.currentImage.sequence}`; })