@@ -16,7 +16,7 @@ import type {
16
16
} from '../data/array_types' ;
17
17
import { WritingMode } from '../symbol/shaping' ;
18
18
19
- export { updateLineLabels , hideGlyphs , getLabelPlaneMatrix , getGlCoordMatrix , project , placeFirstAndLastGlyph , placeGlyphAlongLine , xyTransformMat4 } ;
19
+ export { updateLineLabels , hideGlyphs , getLabelPlaneMatrix , getGlCoordMatrix , project , getPerspectiveRatio , placeFirstAndLastGlyph , placeGlyphAlongLine , xyTransformMat4 } ;
20
20
21
21
/*
22
22
* # Overview of coordinate spaces
@@ -113,6 +113,10 @@ function project(point: Point, matrix: mat4) {
113
113
} ;
114
114
}
115
115
116
+ function getPerspectiveRatio ( cameraToCenterDistance : number , signedDistanceFromCamera : number ) : number {
117
+ return 0.5 + 0.5 * ( cameraToCenterDistance / signedDistanceFromCamera ) ;
118
+ }
119
+
116
120
function isVisible ( anchorPos : [ number , number , number , number ] ,
117
121
clippingBuffer : [ number , number ] ) {
118
122
const x = anchorPos [ 0 ] / anchorPos [ 3 ] ;
@@ -178,7 +182,7 @@ function updateLineLabels(bucket: SymbolBucket,
178
182
}
179
183
180
184
const cameraToAnchorDistance = anchorPos [ 3 ] ;
181
- const perspectiveRatio = 0.5 + 0.5 * ( painter . transform . cameraToCenterDistance / cameraToAnchorDistance ) ;
185
+ const perspectiveRatio = getPerspectiveRatio ( painter . transform . cameraToCenterDistance , cameraToAnchorDistance ) ;
182
186
183
187
const fontSize = symbolSize . evaluateSizeForFeature ( sizeData , partiallyEvaluatedSize , symbol ) ;
184
188
const pitchScaledFontSize = pitchWithMap ? fontSize / perspectiveRatio : fontSize * perspectiveRatio ;
0 commit comments