Skip to content

Commit

Permalink
fix ts
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzhenn committed Aug 7, 2024
1 parent 0893ed7 commit 15f606d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/geo/Position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ abstract class Position {

abstract add(x: any, y?: number): Point | Coordinate;

_sub(x: PositionLike): this;
_sub(x: PositionLike | PositionArray<number>): this;
_sub(x: number, y: number): this;
/**
* 对原数据的 x 和 y 与传入坐标相减
Expand Down
15 changes: 8 additions & 7 deletions src/map/Map.Camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import Point from '../geo/Point';
import Coordinate from '../geo/Coordinate';
import * as mat4 from '../core/util/mat4';
import { subtract, add, scale, normalize, dot, set, distance, angle } from '../core/util/vec3';
import { clamp, interpolate, isNumber, isNil, wrap, toDegree, toRadian, type Matrix4 } from '../core/util';
import { clamp, interpolate, isNumber, isNil, wrap, toDegree, toRadian, Matrix4 } from '../core/util';
import { applyMatrix, matrixToQuaternion, quaternionToMatrix, lookAt, setPosition } from '../core/util/math';
import Browser from '../core/Browser';


declare module "./Map" {
interface Map {
cameraPosition: Point;
cameraLookAt: number[];
export interface Map {
cameraPosition: [number, number, number];
cameraLookAt: [number, number, number];
projViewMatrix: Matrix4;
getFov(): number;
setFov(fov: number): this;
Expand All @@ -27,7 +27,8 @@ declare module "./Map" {
setCameraMovements(frameOptions: Array<MapViewType>, option?: { autoRotate: boolean });
setCameraOrientation(params: MapViewType): this;
setCameraPosition(coordinate: Coordinate);
getFitZoomForCamera(cameraPosition: Array<number>, pitch: number);
getFitZoomForCamera(cameraPosition: [number, number, number], pitch: number);
getFitZoomForAltitude(altitude: number);
isTransforming(): boolean;
getFrustumAltitude(): number;
updateCenterAltitude();
Expand Down Expand Up @@ -397,11 +398,11 @@ Map.include(/** @lends Map.prototype */{

const cameraToCenterDistance = cameraToGroundDistance + centerPointZ;

const zoom = this._getFitZoomForDistance(cameraToCenterDistance);
const zoom = this.getFitZoomForAltitude(cameraToCenterDistance);
return { zoom, cameraToGroundDistance };
},

_getFitZoomForDistance(distance) {
getFitZoomForAltitude(distance: number) {
const ratio = this._getFovRatio();
const scale = distance * ratio * 2 / (this.height || 1) * this.getGLRes();
const resolutions = this._getResolutions();
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/geometry/Painter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ class Painter extends Class {
const c = map.cameraLookAt;
const pos = map.cameraPosition;
//add [1px, 1px] towards camera's lookAt
TEMP_POINT0.set(pos.x, pos.y);
TEMP_POINT0.set(pos[0], pos[1]);
extent2D = extent2D._combine(TEMP_POINT0._add(sign(c[0] - pos[0]), sign(c[1] - pos[1])));
}
const e = this.get2DExtent(null, TEMP_CLIP_EXTENT1);
Expand Down

0 comments on commit 15f606d

Please sign in to comment.