@@ -195,9 +195,7 @@ export class PanService {
195
195
0 ,
196
196
2 * Math . PI ) ;
197
197
198
- const currentProjectedPoints : number [ ] [ ] = this . _computeProjectedPoints ( currentTransform ) ;
199
-
200
- const currentHFov : number = this . _computeHorizontalFov ( currentProjectedPoints ) / 180 * Math . PI ;
198
+ const currentHFov : number = this . _computeHorizontalFov ( currentTransform ) / 180 * Math . PI ;
201
199
202
200
const preferredOverlap : number = Math . PI / 8 ;
203
201
let left : [ number , Image , Transform , number ] = undefined ;
@@ -210,8 +208,7 @@ export class PanService {
210
208
reference ) ;
211
209
212
210
const transform : Transform = this . _createTransform ( a , translation ) ;
213
- const projectedPoints : number [ ] [ ] = this . _computeProjectedPoints ( transform ) ;
214
- const hFov : number = this . _computeHorizontalFov ( projectedPoints ) / 180 * Math . PI ;
211
+ const hFov : number = this . _computeHorizontalFov ( transform ) / 180 * Math . PI ;
215
212
216
213
const direction : THREE . Vector3 = this . _spatial . viewingDirection ( a . rotation ) ;
217
214
const azimuthal : number = this . _spatial . wrap (
@@ -367,34 +364,20 @@ export class PanService {
367
364
image . cameraParameters ) ) ;
368
365
}
369
366
370
- private _computeProjectedPoints ( transform : Transform ) : number [ ] [ ] {
367
+ private _computeHorizontalFov ( transform : Transform ) : number {
371
368
const vertices : number [ ] [ ] = [ [ 1 , 0 ] ] ;
372
369
const directions : number [ ] [ ] = [ [ 0 , 0.5 ] ] ;
373
- const pointsPerLine : number = 20 ;
374
-
375
- return Geo
376
- . computeProjectedPoints (
377
- transform ,
378
- vertices ,
379
- directions ,
380
- pointsPerLine ,
381
- this . _viewportCoords )
382
- . map ( ( [ x , y ] ) => [ Math . abs ( x ) , Math . abs ( y ) ] ) ;
383
- }
370
+ const pointsPerLine : number = 12 ;
384
371
385
- private _computeHorizontalFov ( projectedPoints : number [ ] [ ] ) : number {
386
- const fovs : number [ ] = projectedPoints
387
- . map (
388
- ( projectedPoint : number [ ] ) : number => {
389
- return this . _coordToFov ( projectedPoint [ 0 ] ) ;
390
- } ) ;
372
+ const bearings = Geo . computeBearings (
373
+ transform , vertices , directions , pointsPerLine , this . _viewportCoords ) ;
374
+ const projections = bearings
375
+ . map ( b => this . _spatial . projectToPlane ( b , [ 0 , 1 , 0 ] ) )
376
+ . map ( p => [ p [ 0 ] , - p [ 2 ] ] ) ;
391
377
392
- const fov : number = Math . min ( ...fovs ) ;
393
-
394
- return fov ;
395
- }
378
+ const angles = projections . map ( p => Math . abs ( Math . atan2 ( p [ 0 ] , p [ 1 ] ) ) ) ;
379
+ const fov = 2 * Math . max ( ...angles ) ;
396
380
397
- private _coordToFov ( x : number ) : number {
398
- return 2 * Math . atan ( x ) * 180 / Math . PI ;
381
+ return this . _spatial . radToDeg ( fov ) ;
399
382
}
400
383
}
0 commit comments