forked from JeremyHeleine/Photo-Sphere-Viewer
-
-
Notifications
You must be signed in to change notification settings - Fork 695
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close #243 Support tiled panorama, externalize cubemap
- Loading branch information
Showing
32 changed files
with
1,555 additions
and
492 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Adapters | ||
|
||
Adapters are small pieces of code responsible to load the panorama texture(s) in the THREE.js scene. | ||
|
||
The supported adapters are: | ||
- `equirectangular`: the default adapter, used to load full or partial equirectangular panoramas | ||
- [cubemap](cubemap.md): used to load cubemaps projections (six textures) | ||
- [equirectangular tiles](tiles.md): used to load tiled equirectangular panoramas | ||
|
||
## Import an adapter | ||
|
||
Official adapters (listed on the left menu) are available in the the main `photo-sphere-viewer` package inside the `dist/adapters` directory. | ||
|
||
**Example for the Cubemap adapter:** | ||
|
||
:::: tabs | ||
|
||
::: tab Direct import | ||
```html | ||
<!-- base imports of PSV and dependencies --> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/photo-sphere-viewer@4/dist/adapters/cubemap.min.js"></script> | ||
``` | ||
::: | ||
|
||
::: tab ES import | ||
```js | ||
import CubemapAdapter from 'photo-sphere-viewer/dist/adapters/cubemap'; | ||
``` | ||
::: | ||
|
||
:::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Cubemap adapter | ||
|
||
> [Cube mapping](https://en.wikipedia.org/wiki/Cube_mapping) is a kind of projection where the environment is mapped to the six faces of a cube around the viewer. | ||
This adapter is available in the core `photo-sphere-viewer` package in `dist/adapters/cubemap.js`. | ||
|
||
Photo Sphere Viewer supports cubemaps as six distinct image files. The files can be provided as an object or an array. All features of Photo Sphere Viewer are fully supported when using cubemaps but the `fisheye` option gives funky results. | ||
|
||
```js | ||
new PhotoSphereViewer.Viewer({ | ||
adapter: PhotoSphereViewer.CubemapAdapter, | ||
panorama: { | ||
left: 'path/to/left.jpg', | ||
front: 'path/to/front.jpg', | ||
right: 'path/to/right.jpg', | ||
back: 'path/to/back.jpg', | ||
top: 'path/to/top.jpg', | ||
bottom: 'path/to/bottom.jpg', | ||
}, | ||
}); | ||
``` | ||
|
||
::: warning | ||
This adapter does not use `panoData` option. You can use `sphereCorrection` if the tilt/roll/pan needs to be corrected. | ||
::: | ||
|
||
|
||
## Example | ||
|
||
<iframe style="width: 100%; height: 600px;" src="//jsfiddle.net/mistic100/1jL5yc2r/embedded/result,js/dark" allowfullscreen="allowfullscreen" frameborder="0"></iframe> | ||
|
||
|
||
## Configuration | ||
|
||
When using this adapter the `panorama` option and the `setPanorama()` method accept an array or an object of six URLs. | ||
|
||
```js | ||
// Cubemap as array (order is important) : | ||
panorama: [ | ||
'path/to/left.jpg', | ||
'path/to/front.jpg', | ||
'path/to/right.jpg', | ||
'path/to/back.jpg', | ||
'path/to/top.jpg', | ||
'path/to/bottom.jpg', | ||
] | ||
|
||
// Cubemap as object : | ||
panorama: { | ||
left: 'path/to/left.jpg', | ||
front: 'path/to/front.jpg', | ||
right: 'path/to/right.jpg', | ||
back: 'path/to/back.jpg', | ||
top: 'path/to/top.jpg', | ||
bottom: 'path/to/bottom.jpg', | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Equirectangular tiles adapter | ||
|
||
> Reduce the initial loading time and used bandwidth by slicing big panoramas into many small tiles. | ||
This adapter is available in the core `photo-sphere-viewer` package in `dist/adapters/equirectangular-tiles.js`. | ||
|
||
```js | ||
new PhotoSphereViewer.Viewer({ | ||
adapter: PhotoSphereViewer.EquirectangularTilesAdapter, | ||
panorama: { | ||
width: 6000, | ||
cols: 16, | ||
rows: 8, | ||
baseUrl: 'low_res.jpg', | ||
tileUrl: (col, row) => { | ||
return `tile_${col}x${row}.jpg`; | ||
}, | ||
}, | ||
}); | ||
``` | ||
|
||
::: warning | ||
This adapter does not use `panoData` option. You can use `sphereCorrection` if the tilt/roll/pan needs to be corrected. | ||
::: | ||
|
||
|
||
## Example | ||
|
||
<iframe style="width: 100%; height: 600px;" src="//jsfiddle.net/mistic100/419yhpek/embedded/result,js/dark" allowfullscreen="allowfullscreen" frameborder="0"></iframe> | ||
|
||
|
||
## Configuration | ||
|
||
When using this adapter the `panorama` option and the `setPanorama()` method accept an object to configure the tiles. | ||
|
||
#### `width` (required) | ||
- type: `number` | ||
|
||
Total width of the panorama, the height is always width / 2. | ||
|
||
#### `cols` (required) | ||
- type: `number` | ||
|
||
Number of columns, must be power of two (4, 6, 16, 32, 64) and the maximum value is 64. | ||
|
||
#### `rows` (required) | ||
- type: `number` | ||
|
||
Number of rows, must be power of two (2, 4, 6, 16, 32) and the maximum value is 32. | ||
|
||
#### `tileUrl` (required) | ||
- type: `function: (col, row) => string` | ||
|
||
Function used to build the URL of a tile. | ||
|
||
#### `baseUrl` (recommended) | ||
- type: `string` | ||
|
||
URL of a low resolution complete panorama image to display while the tiles are loading. | ||
|
||
|
||
## Preparing the panorama | ||
|
||
The tiles can be easily generated using [ImageMagick](https://imagemagick.org) software. | ||
|
||
Let's say you have a 12.000x6.000 pixels panorama you want to split in 32 columns and 16 rows, use the following command: | ||
|
||
``` | ||
magick panorama.jpg -crop 375x375 tile_%04d.jpg | ||
``` | ||
|
||
You can also use this [online tool](https://pinetools.com/split-image). | ||
|
||
|
||
::: tip Performances | ||
It is recommanded to not exceed tiles with a size of 1024x1024 pixels, thus limiting the maximum panorama size to 65.536x32.768 pixels (a little more than 2 Gigapixels). | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.