@loaders.gl/tiles
Advanced tools
Comparing version 4.0.0-beta.2 to 4.0.0-beta.3
@@ -9,3 +9,3 @@ import { BoundingSphere, OrientedBoundingBox } from '@math.gl/culling'; | ||
*/ | ||
export declare function createBoundingVolume(boundingVolumeHeader: any, transform: any, result: any): any; | ||
export declare function createBoundingVolume(boundingVolumeHeader: any, transform: any, result?: any): any; | ||
/** [min, max] each in [longitude, latitude, altitude] */ | ||
@@ -12,0 +12,0 @@ export type CartographicBounds = [min: number[], max: number[]]; |
{ | ||
"name": "@loaders.gl/tiles", | ||
"version": "4.0.0-beta.2", | ||
"version": "4.0.0-beta.3", | ||
"description": "Common components for different tiles loaders.", | ||
"license": "MIT", | ||
"type": "module", | ||
"publishConfig": { | ||
@@ -23,4 +24,11 @@ "access": "public" | ||
"types": "dist/index.d.ts", | ||
"main": "dist/es5/index.js", | ||
"module": "dist/esm/index.js", | ||
"main": "dist/index.cjs", | ||
"module": "dist/index.js", | ||
"exports": { | ||
".": { | ||
"import": "./dist/index.js", | ||
"require": "./dist/index.cjs", | ||
"types": "./dist/index.d.ts" | ||
} | ||
}, | ||
"sideEffects": false, | ||
@@ -33,12 +41,12 @@ "files": [ | ||
"scripts": { | ||
"pre-build": "npm run build-bundle", | ||
"build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/dist.min.js" | ||
"pre-build": "npm run build-bundle && npm run build-bundle -- --env=dev", | ||
"build-bundle": "ocular-bundle ./src/index.ts" | ||
}, | ||
"dependencies": { | ||
"@loaders.gl/loader-utils": "4.0.0-beta.2", | ||
"@loaders.gl/math": "4.0.0-beta.2", | ||
"@math.gl/core": "^3.5.1", | ||
"@math.gl/culling": "^3.5.1", | ||
"@math.gl/geospatial": "^3.5.1", | ||
"@math.gl/web-mercator": "^3.5.1", | ||
"@loaders.gl/loader-utils": "4.0.0-beta.3", | ||
"@loaders.gl/math": "4.0.0-beta.3", | ||
"@math.gl/core": "^4.0.0", | ||
"@math.gl/culling": "^4.0.0", | ||
"@math.gl/geospatial": "^4.0.0", | ||
"@math.gl/web-mercator": "^4.0.0", | ||
"@probe.gl/stats": "^4.0.2" | ||
@@ -52,3 +60,3 @@ }, | ||
}, | ||
"gitHead": "79c2033f755e88e11bc30a04428e3666b177b8fc" | ||
"gitHead": "7ba9621cc51c7a26c407086ac86171f35b8712af" | ||
} |
@@ -21,2 +21,6 @@ // This file is derived from the Cesium code base under Apache 2 license | ||
const scratchSouthEast = new Vector3(); | ||
const scratchCenter = new Vector3(); | ||
const scratchXAxis = new Vector3(); | ||
const scratchYAxis = new Vector3(); | ||
const scratchZAxis = new Vector3(); | ||
// const scratchRectangle = new Rectangle(); | ||
@@ -33,3 +37,3 @@ // const scratchOrientedBoundingBox = new OrientedBoundingBox(); | ||
*/ | ||
export function createBoundingVolume(boundingVolumeHeader, transform, result) { | ||
export function createBoundingVolume(boundingVolumeHeader, transform, result?) { | ||
assert(boundingVolumeHeader, '3D Tile: boundingVolume must be defined'); | ||
@@ -43,24 +47,3 @@ | ||
if (boundingVolumeHeader.region) { | ||
// [west, south, east, north, minimum height, maximum height] | ||
// Latitudes and longitudes are in the WGS 84 datum as defined in EPSG 4979 and are in radians. | ||
// Heights are in meters above (or below) the WGS 84 ellipsoid. | ||
const [west, south, east, north, minHeight, maxHeight] = boundingVolumeHeader.region; | ||
const northWest = Ellipsoid.WGS84.cartographicToCartesian( | ||
[degrees(west), degrees(north), minHeight], | ||
scratchNorthWest | ||
); | ||
const southEast = Ellipsoid.WGS84.cartographicToCartesian( | ||
[degrees(east), degrees(south), maxHeight], | ||
scratchSouthEast | ||
); | ||
const centerInCartesian = new Vector3().addVectors(northWest, southEast).multiplyScalar(0.5); | ||
const radius = new Vector3().subVectors(northWest, southEast).len() / 2.0; | ||
// TODO improve region boundingVolume | ||
// for now, create a sphere as the boundingVolume instead of box | ||
return createSphere( | ||
[centerInCartesian[0], centerInCartesian[1], centerInCartesian[2], radius], | ||
new Matrix4() | ||
); | ||
return createObbFromRegion(boundingVolumeHeader.region); | ||
} | ||
@@ -112,3 +95,3 @@ | ||
function createBox(box, transform, result) { | ||
function createBox(box, transform, result?) { | ||
// https://math.gl/modules/culling/docs/api-reference/oriented-bounding-box | ||
@@ -244,2 +227,48 @@ // 1. A half-axes based representation. | ||
/** | ||
* Create OrientedBoundingBox instance from region 3D tiles bounding volume | ||
* @param region - region 3D tiles bounding volume | ||
* @returns OrientedBoundingBox instance | ||
*/ | ||
function createObbFromRegion(region: number[]): OrientedBoundingBox { | ||
// [west, south, east, north, minimum height, maximum height] | ||
// Latitudes and longitudes are in the WGS 84 datum as defined in EPSG 4979 and are in radians. | ||
// Heights are in meters above (or below) the WGS 84 ellipsoid. | ||
const [west, south, east, north, minHeight, maxHeight] = region; | ||
const northWest = Ellipsoid.WGS84.cartographicToCartesian( | ||
[degrees(west), degrees(north), minHeight], | ||
scratchNorthWest | ||
); | ||
const southEast = Ellipsoid.WGS84.cartographicToCartesian( | ||
[degrees(east), degrees(south), maxHeight], | ||
scratchSouthEast | ||
); | ||
const centerInCartesian = new Vector3().addVectors(northWest, southEast).multiplyByScalar(0.5); | ||
Ellipsoid.WGS84.cartesianToCartographic(centerInCartesian, scratchCenter); | ||
Ellipsoid.WGS84.cartographicToCartesian( | ||
[degrees(east), scratchCenter[1], scratchCenter[2]], | ||
scratchXAxis | ||
); | ||
Ellipsoid.WGS84.cartographicToCartesian( | ||
[scratchCenter[0], degrees(north), scratchCenter[2]], | ||
scratchYAxis | ||
); | ||
Ellipsoid.WGS84.cartographicToCartesian( | ||
[scratchCenter[0], scratchCenter[1], maxHeight], | ||
scratchZAxis | ||
); | ||
return createBox( | ||
[ | ||
...centerInCartesian, | ||
...scratchXAxis.subtract(centerInCartesian), | ||
...scratchYAxis.subtract(centerInCartesian), | ||
...scratchZAxis.subtract(centerInCartesian) | ||
], | ||
new Matrix4() | ||
); | ||
} | ||
/** | ||
* Convert a bounding volume defined by OrientedBoundingBox to cartographic bounds | ||
@@ -246,0 +275,0 @@ * @returns {CartographicBounds} |
@@ -74,10 +74,10 @@ // loaders.gl, MIT license | ||
) { | ||
const extentVertex = Ellipsoid.WGS84.cartographicToCartesian( | ||
Ellipsoid.WGS84.cartographicToCartesian( | ||
[fullExtent.xmax, fullExtent.ymax, fullExtent.zmax], | ||
new Vector3() | ||
scratchVector | ||
); | ||
const extentSize = Math.sqrt( | ||
Math.pow(extentVertex[0] - cartesianCenter[0], 2) + | ||
Math.pow(extentVertex[1] - cartesianCenter[1], 2) + | ||
Math.pow(extentVertex[2] - cartesianCenter[2], 2) | ||
Math.pow(scratchVector[0] - cartesianCenter[0], 2) + | ||
Math.pow(scratchVector[1] - cartesianCenter[1], 2) + | ||
Math.pow(scratchVector[2] - cartesianCenter[2], 2) | ||
); | ||
@@ -84,0 +84,0 @@ return Math.log2(WGS84_RADIUS_Z / (extentSize + cartorgraphicCenter[2])); |
@@ -105,3 +105,3 @@ // loaders.gl, MIT license | ||
private _boundingBox?: CartographicBounds; | ||
private _boundingBox?: CartographicBounds = undefined; | ||
@@ -108,0 +108,0 @@ /** updated every frame for tree traversal and rendering optimizations: */ |
@@ -607,6 +607,4 @@ // loaders.gl, MIT license | ||
); | ||
this.cartesianCenter = Ellipsoid.WGS84.cartographicToCartesian( | ||
this.cartographicCenter, | ||
new Vector3() | ||
); | ||
this.cartesianCenter = new Vector3(); | ||
Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter, this.cartesianCenter); | ||
this.zoom = getZoomFromFullExtent(fullExtent, this.cartographicCenter, this.cartesianCenter); | ||
@@ -620,6 +618,4 @@ return; | ||
this.cartographicCenter = new Vector3(xmin + (xmax - xmin) / 2, ymin + (ymax - ymin) / 2, 0); | ||
this.cartesianCenter = Ellipsoid.WGS84.cartographicToCartesian( | ||
this.cartographicCenter, | ||
new Vector3() | ||
); | ||
this.cartesianCenter = new Vector3(); | ||
Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter, this.cartesianCenter); | ||
this.zoom = getZoomFromExtent(extent, this.cartographicCenter, this.cartesianCenter); | ||
@@ -655,3 +651,4 @@ return; | ||
if (center[0] !== 0 || center[1] !== 0 || center[2] !== 0) { | ||
this.cartographicCenter = Ellipsoid.WGS84.cartesianToCartographic(center, new Vector3()); | ||
this.cartographicCenter = new Vector3(); | ||
Ellipsoid.WGS84.cartesianToCartographic(center, this.cartographicCenter); | ||
} else { | ||
@@ -658,0 +655,0 @@ this.cartographicCenter = new Vector3(0, 0, -Ellipsoid.WGS84.radii[0]); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Yes
840033
110
17208
+ Added@loaders.gl/images@4.0.0-beta.3(transitive)
+ Added@loaders.gl/loader-utils@4.0.0-beta.3(transitive)
+ Added@loaders.gl/math@4.0.0-beta.3(transitive)
+ Added@loaders.gl/worker-utils@4.0.0-beta.3(transitive)
+ Added@math.gl/core@4.0.1(transitive)
+ Added@math.gl/culling@4.0.1(transitive)
+ Added@math.gl/geospatial@4.0.1(transitive)
+ Added@math.gl/types@4.0.1(transitive)
+ Added@math.gl/web-mercator@4.0.1(transitive)
- Removed@loaders.gl/images@4.0.0-beta.2(transitive)
- Removed@loaders.gl/loader-utils@4.0.0-beta.2(transitive)
- Removed@loaders.gl/math@4.0.0-beta.2(transitive)
- Removed@loaders.gl/worker-utils@4.0.0-beta.2(transitive)
- Removed@math.gl/core@3.6.3(transitive)
- Removed@math.gl/culling@3.6.3(transitive)
- Removed@math.gl/geospatial@3.6.3(transitive)
- Removed@math.gl/types@3.6.3(transitive)
- Removed@math.gl/web-mercator@3.6.3(transitive)
- Removedgl-matrix@3.4.3(transitive)
Updated@math.gl/core@^4.0.0
Updated@math.gl/culling@^4.0.0
Updated@math.gl/geospatial@^4.0.0
Updated@math.gl/web-mercator@^4.0.0