Skip to content

Commit d02a17a

Browse files
committed
fix "sphereCorrection" type & update doc about panoData
1 parent 9e731f2 commit d02a17a

File tree

7 files changed

+86
-59
lines changed

7 files changed

+86
-59
lines changed

docs/.vuepress/components/CropPlayground.vue

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<div class="md-layout-item">
6666
<label class="md-caption">Pose Heading</label>
6767
<vue-slider
68-
v-model="panoData.poseHeading"
68+
v-model="sphereCorrection.pan"
6969
:min="0"
7070
:max="360"
7171
:marks="[0, 90, 180, 270, 360]"
@@ -76,7 +76,7 @@
7676
<div class="md-layout-item">
7777
<label class="md-caption">Pose Pitch</label>
7878
<vue-slider
79-
v-model="panoData.posePitch"
79+
v-model="sphereCorrection.pitch"
8080
:min="-90"
8181
:max="90"
8282
:marks="[-90, 0, 90]"
@@ -87,7 +87,7 @@
8787
<div class="md-layout-item">
8888
<label class="md-caption">Pose Roll</label>
8989
<vue-slider
90-
v-model="panoData.poseRoll"
90+
v-model="sphereCorrection.roll"
9191
:min="-180"
9292
:max="180"
9393
:marks="[-180, -90, 0, 90, 180]"
@@ -138,10 +138,12 @@ export default {
138138
croppedHeight: null,
139139
croppedX: null,
140140
croppedY: null,
141-
poseHeading: null,
142-
posePitch: null,
143-
poseRoll: null,
144141
},
142+
sphereCorrection: {
143+
pan: null,
144+
pitch: null,
145+
roll: null,
146+
}
145147
}),
146148
mounted() {
147149
// ugly hack to load PSV from jsdelivr as an ES module
@@ -227,9 +229,9 @@ __s.remove();
227229
this.panoData.croppedHeight = height;
228230
this.panoData.croppedX = croppedX;
229231
this.panoData.croppedY = croppedY;
230-
this.panoData.poseHeading = 0;
231-
this.panoData.posePitch = 0;
232-
this.panoData.poseRoll = 0;
232+
this.sphereCorrection.pan = 0;
233+
this.sphereCorrection.pitch = 0;
234+
this.sphereCorrection.roll = 0;
233235
},
234236
235237
updateOutput() {
@@ -244,25 +246,35 @@ __s.remove();
244246
<GPano:CroppedAreaImageHeightPixels>${this.panoData.croppedHeight}</GPano:CroppedAreaImageHeightPixels>
245247
<GPano:CroppedAreaLeftPixels>${this.panoData.croppedX}</GPano:CroppedAreaLeftPixels>
246248
<GPano:CroppedAreaTopPixels>${this.panoData.croppedY}</GPano:CroppedAreaTopPixels>
247-
<GPano:PoseHeadingDegrees>${this.panoData.poseHeading}</GPano:PoseHeadingDegrees>
248-
<GPano:PosePitchDegrees>${this.panoData.posePitch}</GPano:PosePitchDegrees>
249-
<GPano:PoseRollDegrees>${this.panoData.poseRoll}</GPano:PoseRollDegrees>
249+
<GPano:PoseHeadingDegrees>${this.sphereCorrection.pan}</GPano:PoseHeadingDegrees>
250+
<GPano:PosePitchDegrees>${this.sphereCorrection.pitch}</GPano:PosePitchDegrees>
251+
<GPano:PoseRollDegrees>${this.sphereCorrection.roll}</GPano:PoseRollDegrees>
250252
</rdf:Description>
251253
</rdf:RDF>
252254
</x:xmpmeta>
253255
<?xpacket end="r"?>`;
254256
},
255257
256258
loadViewer() {
259+
const sphereCorrection = {
260+
pan: -this.sphereCorrection.pan,
261+
pitch: -this.sphereCorrection.pitch,
262+
roll: -this.sphereCorrection.roll,
263+
};
264+
257265
if (this.viewer) {
258-
this.viewer.setPanorama(this.imageData, { panoData: this.panoData });
266+
this.viewer.setPanorama(this.imageData, {
267+
panoData: this.panoData,
268+
sphereCorrection: sphereCorrection,
269+
});
259270
} else {
260271
this.viewer = new this.Viewer({
261272
panorama: this.imageData,
262273
container: 'viewer',
263274
loadingImg: 'https://photo-sphere-viewer-data.netlify.app/assets/loader.gif',
264275
panoData: this.panoData,
265-
navbar: ['zoom', 'fullscreen'],
276+
sphereCorrection: sphereCorrection,
277+
navbar: ['zoom', 'move', 'fullscreen'],
266278
size: {
267279
height: 500,
268280
},

docs/guide/adapters/equirectangular.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ The data can also contains angular values:
8282
- Pose Heading
8383
- Pose Pitch
8484
- Pose Roll
85+
- Initial View Heading
86+
- Initial View Pitch
87+
- Initial Horizontal FOV
8588

8689
![XMP_pano_pixels](../../images/XMP_pano_pixels.png)
8790

@@ -101,15 +104,21 @@ The XMP payload is as follow:
101104
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
102105
<rdf:Description rdf:about="" xmlns:GPano="http://ns.google.com/photos/1.0/panorama/">
103106
<GPano:ProjectionType>equirectangular</GPano:ProjectionType>
107+
<!-- cropping information -->
104108
<GPano:FullPanoWidthPixels>6000</GPano:FullPanoWidthPixels>
105109
<GPano:FullPanoHeightPixels>3000</GPano:FullPanoHeightPixels>
106110
<GPano:CroppedAreaImageWidthPixels>4000</GPano:CroppedAreaImageWidthPixels>
107111
<GPano:CroppedAreaImageHeightPixels>2000</GPano:CroppedAreaImageHeightPixels>
108112
<GPano:CroppedAreaLeftPixels>1000</GPano:CroppedAreaLeftPixels>
109113
<GPano:CroppedAreaTopPixels>500</GPano:CroppedAreaTopPixels>
114+
<!-- pose information -->
110115
<GPano:PoseHeadingDegrees>0</GPano:PoseHeadingDegrees>
111116
<GPano:PosePitchDegrees>0</GPano:PosePitchDegrees>
112117
<GPano:PoseRollDegrees>0</GPano:PoseRollDegrees>
118+
<!-- initial view information -->
119+
<GPano:InitialViewHeadingDegrees>0</GPano:InitialViewHeadingDegrees>
120+
<GPano:InitialViewPitchDegrees>0</GPano:InitialViewPitchDegrees>
121+
<GPano:InitialHorizontalFOVDegrees>0</GPano:InitialHorizontalFOVDegrees>
113122
</rdf:Description>
114123
</rdf:RDF>
115124
</x:xmpmeta>
@@ -130,17 +139,28 @@ You can also directly pass the values to Photo Sphere Viewer with the `panoData`
130139
const viewer = new PhotoSphereViewer.Viewer({
131140
container: 'viewer',
132141
panorama: 'path/to/panorama.jpg',
142+
143+
// cropping information
133144
panoData: {
134145
fullWidth: 6000,
135146
fullHeight: 3000,
136147
croppedWidth: 4000,
137148
croppedHeight: 2000,
138149
croppedX: 1000,
139150
croppedY: 500,
140-
poseHeading: 0, // 0 to 360
141-
posePitch: 0, // -90 to 90
142-
poseRoll: 0, // -180 to 180
143151
},
152+
153+
// pose information
154+
// sphereCorrection: {
155+
// pan: '0deg',
156+
// tilt: '0deg',
157+
// roll: '0deg',
158+
// },
159+
160+
// initial view information
161+
// defaultYaw: '0deg',
162+
// defaultPitch: '0deg',
163+
// defaultZoomLvl: 50,
144164
});
145165
```
146166

docs/guide/config.md

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -205,29 +205,15 @@ Requires two fingers to rotate the panorama. This allows standard touch-scroll n
205205

206206
#### `sphereCorrection`
207207

208-
- type: `{ pan: double, tilt: double, roll: double }`
208+
- type: `{ pan: double | string, tilt: double | string, roll: double | string }`
209209
- default: `{ pan:0, tilt:0, roll: 0 }`
210210

211-
Allows to rotate the panorama sphere. Angles are in radians.
211+
Allows to fix the panorama orientation.
212212

213-
**Note:** if the XMP data and/or `panoData` contains heading/pitch/roll data, they will be applied before `sphereCorrection`.
213+
**Note:** if the XMP data contains pose heading/pitch/roll data, they will be applied before `sphereCorrection`.
214214

215215
![pan-tilt-toll](../images/pan-tilt-roll.png)
216216

217-
#### `moveSpeed`
218-
219-
- type: `double`
220-
- default `1`
221-
222-
Speed multiplicator for panorama moves. Used for click move, touch move and navbar buttons.
223-
224-
#### `zoomSpeed`
225-
226-
- type: `double`
227-
- default `1`
228-
229-
Speed multiplicator for panorama zooms. Used for mouse wheel, touch pinch and navbar buttons.
230-
231217
#### `panoData`
232218

233219
- type: `object | function<Image, PanoData, PanoData>`
@@ -243,9 +229,6 @@ panoData: {
243229
croppedHeight: 2000,
244230
croppedX: 1000,
245231
croppedY: 500,
246-
poseHeading: 270, // 0 to 360
247-
posePitch: 0, // -90 to 90
248-
poseRoll: 0, // -180 to 180
249232
}
250233
```
251234

@@ -262,12 +245,24 @@ panoData: (image, xmpData) => ({
262245
});
263246
```
264247

265-
**Note:** if the XMP data and/or `panoData` contains heading/pitch/roll data, they will be applied before `sphereCorrection`.
266-
267248
::: warning
268-
Only the default [equirectangular](./adapters/equirectangular.md) adapter and low-resolution panorama of [equirectangular-tiles](./adapters/equirectangular-tiles.md) supports `panoData`, for other adapters you can only use [`sphereCorrection`](#spherecorrection) if the tilt/roll/pan needs to be corrected.
249+
Only the default [equirectangular](./adapters/equirectangular.md) adapter supports `panoData`.
269250
:::
270251

252+
#### `moveSpeed`
253+
254+
- type: `double`
255+
- default `1`
256+
257+
Speed multiplicator for panorama moves. Used for click move, touch move and navbar buttons.
258+
259+
#### `zoomSpeed`
260+
261+
- type: `double`
262+
- default `1`
263+
264+
Speed multiplicator for panorama zooms. Used for mouse wheel, touch pinch and navbar buttons.
265+
271266
#### `requestHeaders`
272267

273268
- type: `object | function<string, object>`

docs/plugins/virtual-tour.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ virtualTour.setNodes([
155155
links: [{ nodeId: '2' }],
156156
markers: [markerLighthouse],
157157
gps: [-80.156479, 25.666725, 3],
158-
panoData: { poseHeading: 327 },
158+
sphereCorrection: { pan: '33deg' },
159159
},
160160
{
161161
id: '2',
@@ -166,7 +166,7 @@ virtualTour.setNodes([
166166
links: [{ nodeId: '3' }, { nodeId: '1' }],
167167
markers: [markerLighthouse],
168168
gps: [-80.156168, 25.666623, 3],
169-
panoData: { poseHeading: 318 },
169+
sphereCorrection: { pan: '42deg' },
170170
},
171171
{
172172
id: '3',
@@ -176,7 +176,7 @@ virtualTour.setNodes([
176176
caption: `[3] ${caption}`,
177177
links: [{ nodeId: '4' }, { nodeId: '2' }, { nodeId: '5' }],
178178
gps: [-80.155932, 25.666498, 5],
179-
panoData: { poseHeading: 310 },
179+
sphereCorrection: { pan: '50deg' },
180180
},
181181
{
182182
id: '4',
@@ -186,7 +186,7 @@ virtualTour.setNodes([
186186
caption: `[4] ${caption}`,
187187
links: [{ nodeId: '3' }, { nodeId: '5' }],
188188
gps: [-80.156089, 25.666357, 3],
189-
panoData: { poseHeading: 78 },
189+
sphereCorrection: { pan: '-78deg' },
190190
},
191191
{
192192
id: '5',
@@ -196,7 +196,7 @@ virtualTour.setNodes([
196196
caption: `[5] ${caption}`,
197197
links: [{ nodeId: '6' }, { nodeId: '3' }, { nodeId: '4' }],
198198
gps: [-80.156292, 25.666446, 2],
199-
panoData: { poseHeading: 190 },
199+
sphereCorrection: { pan: '170deg' },
200200
},
201201
{
202202
id: '6',
@@ -206,7 +206,7 @@ virtualTour.setNodes([
206206
caption: `[6] ${caption}`,
207207
links: [{ nodeId: '5' }, { nodeId: '7' }],
208208
gps: [-80.156465, 25.666496, 2],
209-
panoData: { poseHeading: 295 },
209+
sphereCorrection: { pan: '65deg' },
210210
},
211211
{
212212
id: '7',
@@ -216,7 +216,7 @@ virtualTour.setNodes([
216216
caption: `[7] ${caption}`,
217217
links: [{ nodeId: '6' }],
218218
gps: [-80.15707, 25.6665, 3],
219-
panoData: { poseHeading: 250, posePitch: 3 },
219+
sphereCorrection: { pan: '110deg', pitch: -3 },
220220
},
221221
], '2');
222222
```

examples/plugin-virtual-tour.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
},
7474
],
7575
gps: [-80.15635, 25.66675, 3],
76-
panoData: { poseHeading: 327 },
76+
sphereCorrection: { pan: '33deg' },
7777
map: { x: 660, y: 570, color: '#fffd99' },
7878
plan: { color: '#fffd99' },
7979
},
@@ -94,7 +94,7 @@
9494
},
9595
],
9696
gps: [-80.15611, 25.6667, 5],
97-
panoData: { poseHeading: 318 },
97+
sphereCorrection: { pan: '42deg' },
9898
map: { x: 750, y: 590, color: '#ffb075' },
9999
plan: { color: '#ffb075' },
100100
},
@@ -110,7 +110,7 @@
110110
{ nodeId: '5', position: { pitch: 0, yaw: '270deg' }, linkOffset: { depth: 2 } },
111111
],
112112
gps: [-80.15593, 25.66659, 5],
113-
panoData: { poseHeading: 310 },
113+
sphereCorrection: { pan: '50deg' },
114114
map: { x: 815, y: 640, color: '#b7c1ff' },
115115
plan: { color: '#b7c1ff' },
116116
},
@@ -125,7 +125,7 @@
125125
{ nodeId: '5', position: { pitch: 0, yaw: '300deg' } },
126126
],
127127
gps: [-80.15611, 25.666435, 3],
128-
panoData: { poseHeading: 78 },
128+
sphereCorrection: { pan: '-78deg' },
129129
map: { x: 750, y: 705, color: '#64dbdb' },
130130
plan: { color: '#64dbdb' },
131131
},
@@ -141,7 +141,7 @@
141141
{ nodeId: '4', position: { pitch: 0, yaw: '150deg' } },
142142
],
143143
gps: [-80.15628, 25.666485, 3],
144-
panoData: { poseHeading: 190 },
144+
sphereCorrection: { pan: '170deg' },
145145
map: { x: 685, y: 685, color: '#9c9af9' },
146146
plan: { color: '#9c9af9' },
147147
},
@@ -156,7 +156,7 @@
156156
{ nodeId: '5', position: { pitch: 0, yaw: '130deg' } },
157157
],
158158
gps: [-80.156465, 25.666486, 2],
159-
panoData: { poseHeading: 295 },
159+
sphereCorrection: { pan: '65deg' },
160160
map: { x: 615, y: 685, color: '#de91f2' },
161161
plan: { color: '#de91f2' },
162162
},
@@ -168,7 +168,7 @@
168168
caption: `[7] ${caption}`,
169169
links: [{ nodeId: '6', position: { pitch: 0, yaw: '80deg' } }],
170170
gps: [-80.15709, 25.66634, 3],
171-
panoData: { poseHeading: 250, posePitch: 3 },
171+
sphereCorrection: { pan: '110deg', pitch: -3 },
172172
map: { x: 385, y: 745, color: '#8bed82' },
173173
plan: { color: '#8bed82' },
174174
},

packages/core/src/model.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ export type CssSize = {
3737
/**
3838
* Object defining angular corrections to a sphere
3939
*/
40-
export type SphereCorrection = {
41-
pan?: number;
42-
tilt?: number;
43-
roll?: number;
40+
export type SphereCorrection<T = number | string> = {
41+
pan?: T;
42+
tilt?: T;
43+
roll?: T;
4444
};
4545

4646
/**

packages/core/src/services/DataHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ export class DataHelper extends AbstractService {
285285
/**
286286
* Ensure a SphereCorrection object is valid
287287
*/
288-
cleanSphereCorrection(sphereCorrection: SphereCorrection): SphereCorrection {
288+
cleanSphereCorrection(sphereCorrection: SphereCorrection): SphereCorrection<number> {
289289
return {
290290
pan: parseAngle(sphereCorrection?.pan || 0),
291291
tilt: parseAngle(sphereCorrection?.tilt || 0, true),

0 commit comments

Comments
 (0)