Skip to content

Commit 28a51d2

Browse files
committed
overlays: remove video and positionned overlays
1 parent 2f8d707 commit 28a51d2

File tree

9 files changed

+93
-379
lines changed

9 files changed

+93
-379
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ module.exports = {
2020
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
2121
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
2222
'@typescript-eslint/class-literal-property-style': 'off',
23+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }]
2324
},
2425
ignorePatterns: ['**/dist/**/*', '*.js'],
2526
};

docs/plugins/demos-src/overlays.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,6 @@ const viewer = new Viewer({
1515
id: 'xray',
1616
path: baseUrl + 'sphere-overlay.png',
1717
opacity: .8,
18-
zIndex: 1,
19-
},
20-
{
21-
path: baseUrl + 'pictos/tent.png',
22-
opacity: 1,
23-
yaw: -0.5,
24-
pitch: 0.1,
25-
width: 0.4,
26-
height: 0.3,
27-
zIndex: 2,
2818
},
2919
],
3020
}],

docs/plugins/overlays.md

Lines changed: 6 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,15 @@
44

55
::: module
66
<ApiButton page="modules/OverlaysPlugin.html"/>
7-
Display additional images and videos on top of the panorama.
7+
Display additional images on top of the panorama.
88

99
This plugin is available in the [@photo-sphere-viewer/overlays-plugin](https://www.npmjs.com/package/@photo-sphere-viewer/overlays-plugin) package.
1010
:::
1111

1212
## Usage
1313

14-
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.
15-
16-
Two kinds of overlays are supported :
17-
18-
- full size equirectangular/cubemap : will cover the entire panorama
19-
- positionned rectangle : the image/video has a defined position and size (always in radians/degrees)
14+
Overlays are images "glued" to the panorama. Contrary to [markers](./markers.md) they are part of the 3D scene and not drawn on top of the viewer.
15+
The images must have the same proportions of the base panorama and must be transparent. Both equirectangular (full or cropped) and cubemaps are supported.
2016

2117
```js
2218
import { OverlaysPlugin } from '@photo-sphere-viewer/overlays-plugin';
@@ -26,27 +22,9 @@ const viewer = new Viewer({
2622
[OverlaysPlugin, {
2723
overlays: [
2824
{
29-
id: 'fullsize',
25+
id: 'overlay',
3026
path: 'path/to/overlay.png',
3127
},
32-
{
33-
id: 'positionned',
34-
path: 'path/to/image.jpg',
35-
yaw: '-20deg',
36-
pitch: '10deg',
37-
width: '40deg',
38-
height: '20deg',
39-
opacity: 0.5,
40-
},
41-
{
42-
id: 'video',
43-
type: 'video',
44-
path: 'path/to/video.mp4',
45-
yaw: '20deg',
46-
pitch: '10deg',
47-
width: '40deg',
48-
height: '20deg',
49-
},
5028
],
5129
}],
5230
],
@@ -68,17 +46,6 @@ packages:
6846
6947
:::
7048
71-
::: tip Overlays vs. Markers
72-
Overlays seem very similar to image/video markers but serve different purposes:
73-
74-
- Markers are for "small" elements, generally interactive
75-
- Markers are highly configurable (style, tooltip, user events, etc.)
76-
- Overlays can cover the whole panorama
77-
- Overlays cannot have a tooltip, change size, etc. You can however listen to click events
78-
- Overlays are rendered over the panorama itself where markers are rendered flat over the viewer HTML element
79-
80-
:::
81-
8249
## Configuration
8350
8451
#### `overlays`
@@ -107,11 +74,6 @@ Overlays can be a single image/video for a spherical gerometry or six images for
10774

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

110-
#### `type`
111-
112-
- type: `image | video`
113-
- default: `image`
114-
11577
#### `opacity`
11678

11779
- type: `number`
@@ -128,55 +90,15 @@ Used to remove the overlay with `removeOverlay()` method.
12890

12991
- type: `string`
13092

131-
Path to the image or video.
132-
133-
#### `yaw`, `pitch`, `width`, `height`
134-
135-
- type: `number | string`
136-
137-
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.
138-
139-
#### `chromaKey`
140-
141-
- type: `object`
142-
- default: `{ enabled: false }`
143-
144-
Will make a color of the image/video transparent.
145-
146-
::: dialog "See details" "Marker chroma key"
147-
148-
The `chromaKey` marker option allows to define a color which will be transparent (green screen/blue screen).
149-
150-
```ts
151-
chromaKey: {
152-
/**
153-
* Enable the option
154-
*/
155-
enabled: true,
156-
/**
157-
* Select which color to make transparent (default is green)
158-
*/
159-
color: 0x00ff00,
160-
color: { r: 0, g: 255, 0 },
161-
/**
162-
* Customize the color detection (default is 0.2 / 0.2)
163-
*/
164-
similarity: 0.2,
165-
smoothness: 0.2,
166-
}
167-
```
168-
169-
:::
170-
171-
_(This option is only applicable to spherical overlays)._
93+
Path to the image.
17294

17395
#### Cube overlays
17496

17597
#### `path` (required)
17698

17799
- type: `CubemapPanorama`
178100

179-
Check the [cubemap adapter page](../guide/adapters/cubemap.md#panorama-options) for the possible syntaxes. All six faces are required.
101+
Check the [cubemap adapter page](../guide/adapters/cubemap.md#panorama-options) for the possible syntaxes. All six faces are required but some can be `null`.
180102

181103
## Methods
182104

@@ -192,14 +114,6 @@ Removes an overlay.
192114

193115
Removes all overlays.
194116

195-
#### `getVideo(id)`
196-
197-
Returns the controller of a video overlay (native HTMLVideoElement) in order to change its state, volume, etc.
198-
199-
```js
200-
overlaysPlugin.getVideo('my-video').muted = false;
201-
```
202-
203117
## Events
204118

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

examples/plugin-overlays-cubemap.html

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,6 @@
5858
opacity: .8,
5959
zIndex: 1,
6060
},
61-
// {
62-
// id: 'xray',
63-
// path: baseUrl + 'sphere-overlay.png',
64-
// opacity: .8,
65-
// zIndex: 1,
66-
// },
67-
{
68-
id: 'rick',
69-
path: baseUrl + 'pictos/rick.webm',
70-
type: 'video',
71-
yaw: 0,
72-
pitch: 0.21,
73-
width: 0.21,
74-
height: 0.42,
75-
zIndex: 3,
76-
},
7761
],
7862
}],
7963
],

examples/plugin-overlays.html

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -46,39 +46,6 @@
4646
opacity: .8,
4747
zIndex: 1,
4848
},
49-
{
50-
path: baseUrl + 'pictos/tent.png',
51-
opacity: 0.7,
52-
yaw: -0.5,
53-
pitch: 0.19,
54-
width: 0.4,
55-
height: 0.3,
56-
zIndex: 2,
57-
},
58-
{
59-
id: 'rick',
60-
path: baseUrl + 'pictos/rick.webm',
61-
type: 'video',
62-
yaw: 0,
63-
pitch: 0.21,
64-
width: 0.21,
65-
height: 0.42,
66-
zIndex: 3,
67-
},
68-
{
69-
id: 't-rex',
70-
path: baseUrl + 'pictos/t-rex.mp4',
71-
type: 'video',
72-
yaw: 0.25,
73-
pitch: 0.15,
74-
width: 0.3,
75-
height: 0.3,
76-
zIndex: 3,
77-
chromaKey: {
78-
enabled: true,
79-
similarity: 0.3,
80-
},
81-
},
8249
],
8350
}],
8451
],
@@ -112,15 +79,7 @@
11279
const overlays = viewer.getPlugin('overlays');
11380

11481
overlays.addEventListener('overlay-click', ({ overlayId }) => {
115-
console.log(`click ${overlayId}`);
116-
if (overlayId === 'rick') {
117-
const video = overlays.getVideo(overlayId);
118-
if (video.paused) {
119-
video.play();
120-
} else {
121-
video.pause();
122-
}
123-
}
82+
console.log(`click overlay ${overlayId}`);
12483
});
12584

12685
function setSphereOverlay(path) {

packages/core/src/adapters/EquirectangularAdapter.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ export class EquirectangularAdapter extends AbstractAdapter<string | Equirectang
7979

8080
private readonly config: EquirectangularAdapterConfig;
8181

82-
readonly SPHERE_SEGMENTS: number;
83-
readonly SPHERE_HORIZONTAL_SEGMENTS: number;
82+
// @internal
83+
public readonly SPHERE_SEGMENTS: number;
84+
// @internal
85+
public readonly SPHERE_HORIZONTAL_SEGMENTS: number;
8486

8587
constructor(viewer: Viewer, config?: EquirectangularAdapterConfig) {
8688
super(viewer);

packages/cubemap-adapter/src/CubemapAdapter.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -369,26 +369,28 @@ export class CubemapAdapter extends AbstractAdapter<CubemapPanorama, CubemapData
369369
}
370370

371371
setTexture(mesh: CubemapMesh, { texture, panoData }: CubemapTextureData) {
372-
for (let i = 0; i < 6; i++) {
372+
mesh.material.forEach((material, i) => {
373373
if (texture[i]) {
374374
if (panoData.flipTopBottom && (i === 2 || i === 3)) {
375375
texture[i].center = new Vector2(0.5, 0.5);
376376
texture[i].rotation = Math.PI;
377377
}
378378

379-
mesh.material[i].map = texture[i];
379+
material.map = texture[i];
380380
} else {
381-
mesh.material[i].opacity = 0;
382-
mesh.material[i].transparent = true;
381+
material.opacity = 0;
382+
material.transparent = true;
383383
}
384-
}
384+
});
385385
}
386386

387387
setTextureOpacity(mesh: CubemapMesh, opacity: number) {
388-
for (let i = 0; i < 6; i++) {
389-
mesh.material[i].opacity = opacity;
390-
mesh.material[i].transparent = opacity < 1;
391-
}
388+
mesh.material.forEach((material) => {
389+
if (material.map) {
390+
material.opacity = opacity;
391+
material.transparent = opacity < 1;
392+
}
393+
});
392394
}
393395

394396
disposeTexture({ texture }: CubemapTextureData): void {

0 commit comments

Comments
 (0)