@xgis/xgis3d 0.3.55 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,47 +1,13 @@
1
- export declare function epsg3301ToWgs84(x: number, y: number): [number, number];
2
- export declare function wgs84ToEpsg3301(lon: number, lat: number): [number, number];
3
- /**
4
- * Pixel span that Cesium's `frustum.fov` covers: the horizontal axis when the canvas is landscape,
5
- * the vertical one otherwise — the same rule `PerspectiveFrustum` uses to derive `fovy`. At nadir a
6
- * perspective camera's ground scale is isotropic, so pairing `fov` with its own axis is exact.
7
- */
1
+ import type { EpsgCode } from '@xgis/xgis-common';
2
+ export declare function mapToWgs84(projection: EpsgCode, x: number, y: number): [number, number];
3
+ export declare function wgs84ToMap(projection: EpsgCode, lon: number, lat: number): [number, number];
4
+ export declare function metresPerMapUnit(projection: EpsgCode, lon: number, lat: number): number;
8
5
  export declare function fovSpanPx(viewportWidthPx: number, viewportHeightPx: number): number;
9
- /**
10
- * Camera→focus range at which the 3D ground scale around the focus point equals the 2D map's
11
- * resolution at `zoom` — the inverse of `rangeToZoom`, and what makes a 2D↔3D switch keep its scale.
12
- *
13
- * Necessarily viewport-dependent: a perspective camera at range `d` spreads `2 d tan(fov/2)` metres
14
- * across `spanPx` pixels, while `resolutionForZoom` is canvas-independent (as OpenLayers defines
15
- * it). Assuming a fixed span instead mis-scales the 3D view against the 2D map by exactly
16
- * `spanPx / assumedSpan`, which is invisible at one window size and wrong at every other.
17
- */
18
- export declare function zoomToRange(zoom: number, spanPx: number, fov: number): number;
19
- export declare function rangeToZoom(range: number, spanPx: number, fov: number): number;
20
- /**
21
- * Effective camera range to feed `rangeToZoom` for the synced 2D view. The slant range to the
22
- * focus point grows as the camera tilts, so the 2D view zooms out to match the larger ground area
23
- * the oblique 3D view covers. It is capped at `maxRangeFactor` x the vertical height so a grazing
24
- * tilt plateaus instead of running the 2D view out toward the whole map. When the focus point is
25
- * undefined (screen centre above the horizon — a near first-person tilt) the capped maximum is
26
- * returned, not the vertical height: this holds the zoom at the plateau so a near-horizon tilt
27
- * never snaps the 2D view back in.
28
- */
6
+ export declare function zoomToRange(zoom: number, spanPx: number, fov: number, metresPerUnit: number): number;
7
+ export declare function rangeToZoom(range: number, spanPx: number, fov: number, metresPerUnit: number): number;
29
8
  export declare function focusRangeForZoom(height: number, focusRange: number | undefined, maxRangeFactor: number): number;
30
- /**
31
- * Bridge the two angle conventions in play: Cesium's `camera.heading` is the way the view
32
- * faces, clockwise from north, while `mapViewStore.rotation` (OpenLayers `view.getRotation`)
33
- * turns the map clockwise, which faces the view counter-clockwise of north. The conversion is
34
- * a negation normalised to [0, 2π), and is its own inverse — hence the two aliases for
35
- * readable call sites.
36
- */
37
9
  declare function flipAngleDirection(radians: number): number;
38
10
  export declare const cesiumHeadingToRotation: typeof flipAngleDirection;
39
11
  export declare const rotationToCesiumHeading: typeof flipAngleDirection;
40
- /**
41
- * Fallback extent when Cesium cannot compute a view rectangle (e.g. horizon/space visible).
42
- * Centred on the camera sub-point (degrees), sized by the zoom resolution. Assumes a nadir
43
- * footprint (viewport-proportioned), so it under-represents the deep trapezoid of an oblique
44
- * camera — acceptable for the degraded "approximate area" path this only runs on.
45
- */
46
- export declare function cameraFallbackExtent3301(centerLon: number, centerLat: number, zoom: number, viewportWidthPx: number, viewportHeightPx: number): [number, number, number, number];
12
+ export declare function cameraFootprint(projection: EpsgCode, centerLon: number, centerLat: number, zoom: number, viewportWidthPx: number, viewportHeightPx: number): [number, number, number, number];
47
13
  export {};
@@ -1,3 +1,6 @@
1
1
  import type { Viewer as CesiumViewer } from 'cesium';
2
- /** Cesium has no extent constraint, so the topic bbox is enforced by a per-frame camera guard. */
2
+ /**
3
+ * Cesium has no extent constraint, so the topic bbox and zoom ceiling are enforced by a per-frame
4
+ * camera guard.
5
+ */
3
6
  export declare function useCesiumViewBounds(viewer: CesiumViewer): void;
@@ -1,4 +1,4 @@
1
- import type { KmlParams } from '@xgis/xgis-common';
1
+ import type { IKmlParams } from '@xgis/xgis-common';
2
2
  import type { Camera } from 'cesium';
3
3
  import { KmlDataSource } from 'cesium';
4
4
  import type { KmlOpacitySlot } from './kmlEntityOpacity';
@@ -6,4 +6,4 @@ export interface CreatedKml {
6
6
  dataSource: KmlDataSource;
7
7
  opacitySlots: KmlOpacitySlot[];
8
8
  }
9
- export declare function createKML(params: KmlParams, camera: Camera, canvas: HTMLCanvasElement): Promise<CreatedKml>;
9
+ export declare function createKML(params: IKmlParams, camera: Camera, canvas: HTMLCanvasElement): Promise<CreatedKml>;
@@ -1,3 +1,3 @@
1
1
  import type { LayerPresentation, WmsSource } from '@xgis/xgis-common';
2
- import type { ImageryProvider } from 'cesium';
3
- export declare function createWMS(source: WmsSource, presentation: LayerPresentation, capabilities?: string): ImageryProvider | null;
2
+ import type { ImageryProvider, Rectangle } from 'cesium';
3
+ export declare function createWMS(source: WmsSource, presentation: LayerPresentation, capabilities?: string, rectangle?: Rectangle): ImageryProvider | null;
@@ -1,3 +1,4 @@
1
1
  import type { LayerPresentation, WmtsSource } from '@xgis/xgis-common';
2
2
  import type { ImageryProvider } from 'cesium';
3
- export declare function createWMTS(source: WmtsSource, presentation: LayerPresentation, capabilitiesText: string): ImageryProvider | null;
3
+ import { Rectangle } from 'cesium';
4
+ export declare function createWMTS(source: WmtsSource, presentation: LayerPresentation, capabilitiesText: string, rectangle?: Rectangle): ImageryProvider | null;
@@ -1,4 +1,4 @@
1
- import type { KmlParams } from '@xgis/xgis-common';
1
+ import type { IKmlParams } from '@xgis/xgis-common';
2
2
  import type { EntityCollection } from 'cesium';
3
3
  export declare function normaliseKmlEntities(entities: EntityCollection, clampToGround: boolean): void;
4
- export declare function applyKmlStyle(entities: EntityCollection, params: KmlParams, clampToGround: boolean): void;
4
+ export declare function applyKmlStyle(entities: EntityCollection, params: IKmlParams, clampToGround: boolean): void;
@@ -1,5 +1,5 @@
1
1
  import type { BasemapPlanEntry } from '@xgis/xgis-common';
2
- import { ImageryProvider, Viewer as CesiumViewer } from 'cesium';
2
+ import { ImageryProvider, Rectangle, Viewer as CesiumViewer } from 'cesium';
3
3
  import type { Created3DTileset } from './create3DTilesetLayer';
4
4
  import type { CreatedKml } from './createKMLLayer';
5
5
  export type CesiumBaseLayer = {
@@ -12,4 +12,4 @@ export type CesiumBaseLayer = {
12
12
  kind: 'tileset';
13
13
  tileset: Promise<Created3DTileset | null>;
14
14
  };
15
- export declare function createCesiumBaseLayer(entry: BasemapPlanEntry, viewer: CesiumViewer): CesiumBaseLayer | null;
15
+ export declare function createCesiumBaseLayer(entry: BasemapPlanEntry, viewer: CesiumViewer, rectangle?: Rectangle): CesiumBaseLayer | null;
@@ -0,0 +1,3 @@
1
+ import type { EpsgCode, MapExtent } from '@xgis/xgis-common';
2
+ import { Rectangle } from 'cesium';
3
+ export declare function topicRectangle(bbox: MapExtent | null, projection: EpsgCode): Rectangle | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xgis/xgis3d",
3
- "version": "0.3.55",
3
+ "version": "0.4.1",
4
4
  "description": "XGIS 3D map engine, built on CesiumJS.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "peerDependencies": {
21
21
  "react": "^18.3.1 || ^19.0.0",
22
- "@xgis/xgis-common": "^0.3.55"
22
+ "@xgis/xgis-common": "^0.4.1"
23
23
  },
24
24
  "peerDependenciesMeta": {},
25
25
  "dependencies": {
@@ -35,7 +35,6 @@
35
35
  "@types/node": "^22.20.1",
36
36
  "@types/react": "^19.2.15",
37
37
  "@vitejs/plugin-react": "^4.7.0",
38
- "@vitest/coverage-v8": "^4.1.12",
39
38
  "react": "^19.2.6",
40
39
  "react-dom": "^19.2.6",
41
40
  "typescript": "^6.0.3",
@@ -44,8 +43,8 @@
44
43
  "@xgis/eslint-config": "0.0.0",
45
44
  "@xgis/tsconfig": "0.0.0",
46
45
  "@xgis/vitest-config": "0.0.0",
47
- "@xgis/xgis-common": "0.3.55",
48
- "@xgis/xgis3d-build": "0.3.55"
46
+ "@xgis/xgis-common": "0.4.1",
47
+ "@xgis/xgis3d-build": "0.4.1"
49
48
  },
50
49
  "scripts": {
51
50
  "dev": "vite --port 4202",
@@ -54,7 +53,6 @@
54
53
  "lint": "eslint src",
55
54
  "typecheck": "tsc --noEmit",
56
55
  "test": "vitest run",
57
- "test:coverage": "vitest run --coverage",
58
56
  "build:lib": "vite build --config vite.lib.config.ts && tsc -p tsconfig.build.json"
59
57
  },
60
58
  "main": "./dist/index.js",
@@ -1,2 +0,0 @@
1
- import type { Viewer as CesiumViewer } from 'cesium';
2
- export declare function useCesiumLayerReconciler(viewer: CesiumViewer): void;