Skip to content

Commit

Permalink
new overlays plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic100 committed Oct 27, 2023
1 parent b5c102d commit b22c7cb
Show file tree
Hide file tree
Showing 27 changed files with 988 additions and 232 deletions.
17 changes: 2 additions & 15 deletions docs/guide/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,22 +200,9 @@ Requires two fingers to rotate the panorama. This allows standard touch-scroll n

## Advanced options

#### `overlay`
#### ~~`overlay`~~

- type: `*`

Path to an additional transparent panorama which will be displayed on top of the main one. The overlay can also be changed with the `setOverlay()` method or within the options of the `setPanorama()` method.

::: warning
Only the default [equirectangular](./adapters/equirectangular.md) and the [cubemap](./adapters/cubemap.md) adapters support this feature.
:::

#### `overlayOpacity`

- type: `number`
- default: `1`

Opacity of the `overlay`.
This option will be removed in a future version, please migrate to the [Overlays plugin](../plugins/overlays.md).

#### `sphereCorrection`

Expand Down
3 changes: 1 addition & 2 deletions docs/plugins/gallery.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ gallery.setItems([

#### `items`

- type: `array`
- default: `GalleryItem[]`
- type: `GalleryItem[]`
- updatable: no, use `setItems()` method

The list of items, see bellow.
Expand Down
161 changes: 161 additions & 0 deletions docs/plugins/overlays.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# OverlaysPlugin <Badge text="NEW"/>

<Badges module="overlays-plugin"/>

::: module
<ApiButton page="modules/OverlaysPlugin.html"/>
Display additional images and videos on top of the panorama.
:::

[[toc]]

## Usage

Overlays are images and videos "glued" to the panorama. Contrary to [markers](./markers.md) they are part of the 3D scene and not drawn on top of the viewer.

Two kinds of overlays are supported :

- full size equirectangular/cubemap : will cover the entire panorama
- positionned rectangle : the image/video has a defined position and size (always in radians/degrees)

```js
const viewer = new PhotoSphereViewer.Viewer({
plugins: [
[PhotoSphereViewer.OverlaysPlugin, {
overlays: [
{
id: 'fullsize',
path: 'path/to/overlay.png',
},
{
id: 'positionned',
path: 'path/to/image.jpg',
yaw: '-20deg',
pitch: '10deg',
width: '40deg',
height: '20deg',
opacity: 0.5,
},
{
id: 'video',
type: 'video',
path: 'path/to/video.mp4',
yaw: '20deg',
pitch: '10deg',
width: '40deg',
height: '20deg',
},
],
}],
],
});
```

## Example

TODO

### Comparison with markers

This example show the difference between a positionned overlay and `image` and `imageLayer` markers.

TODO

## Configuration

#### `overlays`

- type: `OverlayConfig[]`
- updatable: no

The list of overlays, see bellow. Can be updated with various [methods](#methods).

#### `autoclear`

- type: `boolean`
- default: `true`
- updatable: yes

Automatically remove all overlays when the panorama changes.

### Overlays

Overlays can be a single image/video for a spherical gerometry or six images for a cube geometry (no videos).

#### `id` (recommended)

- type: `string`
- default: random value

Used to remove the overlay with `removeOverlay()` method.

#### `type`

- type: `image | video`
- default: `image`

#### `opacity`

- type: `number`
- default: `1`

#### `zIndex`

- type: `number`
- default: `0`

#### Spherical overlays

#### `path` (required)

- type: `string`

Path to the image or video.

#### `yaw`, `pitch`, `width`, `height`

- type: `number | string`

Definition of the position and size of the overlay, if none of the four properties are configured, the overlay will cover the full sphere, respecting the [panorama data](../guide/adapters/equirectangular.md#cropped-panorama) if applicable.

#### Cube overlays

#### `path` (required)

- type: `CubemapPanorama`

Check the [cubemap adapter page](../guide/adapters/cubemap.md#panorama-options) for the possible syntaxes. All six faces are required.

## Methods

#### `addOverlay(config)`

Adds a new overlay.

#### `removeOverlay(id)`

Removes an overlay.

#### `clearOverlays()`

Removes all overlays.

#### `getVideo(id)`

Returns the controller of a video overlay (native HTMLVideoElement) in order to change its state, volume, etc.

```js
overlaysPlugin.getVideo('my-video').muted = false;
```

## Events

#### `overlay-click(overlayId)`

Triggered when an overlay is clicked.

```js
overlaysPlugin.addEventListener('overlay-click', ({ overlayId }) => {
console.log(`Clicked on overlay ${overlayId}`);
});
```
4 changes: 2 additions & 2 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ <h5 class="card-title">Plugins</h5>
<a href="plugin-markers.html" class="list-group-item list-group-item-action">Markers</a>
<a href="plugin-markers-layers.html" class="list-group-item list-group-item-action">Markers layers</a>
<a href="plugin-markers-cubemap.html" class="list-group-item list-group-item-action">Markers (cubemap)</a>
<a href="plugin-overlays.html" class="list-group-item list-group-item-action">Overlays</a>
<a href="plugin-overlays-cubemap.html" class="list-group-item list-group-item-action">Overlays (cubemap)</a>
<a href="plugin-resolution.html" class="list-group-item list-group-item-action">Resolution</a>
<a href="plugin-settings.html" class="list-group-item list-group-item-action">Settings</a>
<a href="adapter-equirectangular-video.html" class="list-group-item list-group-item-action">Video</a>
Expand All @@ -79,8 +81,6 @@ <h5 class="card-title">Misc</h5>
<div class="list-group list-group-flush">
<a href="misc-components.html" class="list-group-item list-group-item-action">Components</a>
<a href="misc-equirectangular-cropped.html" class="list-group-item list-group-item-action">Cropped panorama</a>
<a href="misc-equirectangular-overlay.html" class="list-group-item list-group-item-action">Overlay (equirectangular)</a>
<a href="misc-cubemap-overlay.html" class="list-group-item list-group-item-action">Overlay (cubemap)</a>
</div>
</div>
</div>
Expand Down
111 changes: 0 additions & 111 deletions examples/misc-cubemap-overlay.html

This file was deleted.

Loading

0 comments on commit b22c7cb

Please sign in to comment.