1) Hands-on: SPFx Web Part com Photo Sphere Viewer

Aqui vai um esqueleto mínimo de Web Part SPFx que integra o Photo Sphere Viewer (PSV) com o adaptador equiretangular e o plugin de marcadores.

Passo 1 – Instalação

No projeto SPFx já criado:

npm install @photo-sphere-viewer/core @photo-sphere-viewer/equirectangular-adapter @photo-sphere-viewer/markers-plugin three

Passo 2 – Código da Web Part

360ViewerWebPart.ts

import { Version } from '@microsoft/sp-core-library';
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
import { SPComponentLoader } from '@microsoft/sp-loader';

import { Viewer } from '@photo-sphere-viewer/core';
import { EquirectangularAdapter } from '@photo-sphere-viewer/equirectangular-adapter';
import { MarkersPlugin } from '@photo-sphere-viewer/markers-plugin';

export interface I360ViewerWebPartProps {
  imageUrl: string;
}

export default class Viewer360WebPart extends BaseClientSideWebPart<I360ViewerWebPartProps> {
  private viewer: Viewer | undefined;

  public render(): void {
    this.domElement.innerHTML = `
      <div id="psv-container" style="width:100%;height:500px;"></div>
    `;

    const container = this.domElement.querySelector('#psv-container') as HTMLElement;

    this.viewer = new Viewer({
      container,
      adapter: EquirectangularAdapter,
      panorama: this.properties.imageUrl || 
                'https://example.com/pano-sample.jpg',
      navbar: ['zoom', 'fullscreen'],
      plugins: [
        [MarkersPlugin, {
          markers: [
            {
              id: 'marker-1',
              position: { yaw: '45deg', pitch: '10deg' },
              image: 'https://cdn-icons-png.flaticon.com/512/25/25694.png',
              size: { width: 32, height: 32 },
              tooltip: 'Machine 01'
            }
          ]
        }]
      ]
    });
  }

  protected onDispose(): void {
    if (this.viewer) {
      this.viewer.destroy();
      this.viewer = undefined;
    }
  }

  protected get dataVersion(): Version {
    return Version.parse('1.0');
  }
}

Isso já monta um viewer funcional dentro de uma página do SharePoint, permitindo abrir imagens 360° hospedadas em qualquer biblioteca/documento.


Photo Sphere Viewer in SPFx: Quick Integration Guide

  • Library: Photo Sphere Viewer is a modular JavaScript library built on top of Three.js for rendering equirectangular and cubemap panoramas, as well as 360° video.
  • Adapters: select how textures are projected (sphere or cube).
  • Plugins: add interactive features like markers, maps, plans, compass, and even virtual tours.
  • SPFx integration:
    1. Install @photo-sphere-viewer/core and chosen adapter/plugins.
    2. Render into a div inside render() of your Web Part.
    3. Use onDispose() to call viewer.destroy().
  • Use cases: Digital twins, training portals, interactive site tours, facility maintenance overlays.
  • Alternatives: Pannellum (lightweight), Marzipano (toolchain), A-Frame (VR/3D scenes).

Summary Table

FeatureHow it Works in PSVWhy it Matters
RenderingWebGL via Three.jsHardware-accelerated 360° viewing
FormatsEquirectangular & CubemapFlexibility depending on capture pipeline
PluginsMarkers, Compass, Map, Plan, Virtual TourBuild interactive tours with metadata
SPFx IntegrationImport via npm, mount in render(), dispose on teardownNative SharePoint support
LicenseMITFree for commercial use

Edvaldo Guimrães Filho Avatar

Published by