Class Media360View

All Implemented Interfaces:
Animation, Editable, StyleListener, Iterable<Component>

public class Media360View extends Container

A 360 degree panorama viewer: renders an equirectangular image onto the inside of a sphere with drag-to-look navigation and optional gyroscope look. Works everywhere Display#isGpuSupported() is true; on platforms without a GPU backend it degrades to the standard "3D not supported" placeholder without crashing.

Mono mode fills the component; #setStereo(boolean) renders the same viewpoint side by side for cardboard-style viewers. Photo spheres are captured from a single point, so stereo intentionally uses a zero eye separation - there is no parallax information in the image to reproduce.

360 video is not supported directly because the platform has no path from media frames to GPU textures yet; #setTextureSource(TextureSource) is the extension point for dynamic content.

Media360View pano = new Media360View();
pano.setImage(EncodedImage.create("/panorama.jpg"));
form.add(BorderLayout.CENTER, pano);
  • Constructor Details

    • Media360View

      public Media360View()
      Creates an empty viewer; supply content with #setImage(Image) or #setTextureSource(TextureSource).
  • Method Details

    • isSupported

      public boolean isSupported()
      True when the current platform provides a 3D backend.
    • setImage

      public void setImage(Image image)

      Shows an equirectangular panorama image (the format produced by 360 cameras and phone panorama modes: longitude maps to X, latitude to Y). Replaces any previous image or texture source.

      Parameters
      • image: the panorama to display
    • setTextureSource

      public void setTextureSource(TextureSource source)

      Installs a dynamic texture source, replacing any static image. The extension point for procedural or (future) video content.

      Parameters
      • source: the source, or null to remove it
    • setStereo

      public void setStereo(boolean stereo)
      Switches between a full-viewport mono view (the default) and side-by-side stereo for cardboard-style viewers.
    • isStereo

      public boolean isStereo()
      True when rendering side-by-side stereo.
    • setHeadTrackingEnabled

      public void setHeadTrackingEnabled(boolean enabled)
      Enables gyroscope look-around, composed with drag navigation. When the device has no motion sensors this quietly stays drag-only.
    • isHeadTrackingEnabled

      public boolean isHeadTrackingEnabled()
      True when gyroscope look-around is enabled.
    • getYaw

      public float getYaw()
      The horizontal look angle in degrees; positive turns right.
    • setYaw

      public void setYaw(float yawDegrees)
      Sets the horizontal look angle in degrees.
    • getPitch

      public float getPitch()
      The vertical look angle in degrees, clamped so the view cannot flip over the poles; positive looks up.
    • setPitch

      public void setPitch(float pitchDegrees)
      Sets the vertical look angle in degrees. Clamped to stay off the poles.
    • reset

      public void reset()
      Resets the view to look straight ahead and recenters the gyroscope.
    • getRenderView

      public RenderView getRenderView()
      The underlying render view, exposed for advanced integration.
    • initComponent

      protected void initComponent()
      Description copied from class: Component
      Allows subclasses to bind functionality that relies on fully initialized and "ready for action" component state
      Overrides:
      initComponent in class Component
    • deinitialize

      protected void deinitialize()
      Description copied from class: Component
      Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy. This allows the component to deregister animators and cleanup after itself. This method is the opposite of the initComponent() method.
      Overrides:
      deinitialize in class Component
    • pointerPressed

      public void pointerPressed(int x, int y)
      Description copied from class: Container

      If this Component is focused, the pointer pressed event will call this method

      Parameters
      • x: the pointer x coordinate

      • y: the pointer y coordinate

      Overrides:
      pointerPressed in class Container
    • pointerDragged

      public void pointerDragged(int x, int y)
      Description copied from class: Component

      If this Component is focused, the pointer dragged event will call this method

      Parameters
      • x: the pointer x coordinate

      • y: the pointer y coordinate

      Overrides:
      pointerDragged in class Component
    • pointerReleased

      public void pointerReleased(int x, int y)
      Description copied from class: Component

      If this Component is focused, the pointer released event will call this method

      Parameters
      • x: the pointer x coordinate

      • y: the pointer y coordinate

      Overrides:
      pointerReleased in class Component