Socket
Socket
Sign inDemoInstall

@loaders.gl/tiles

Package Overview
Dependencies
17
Maintainers
9
Versions
252
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.0-beta.2 to 4.0.0-beta.3

dist/constants.js

2

dist/tileset/helpers/bounding-volume.d.ts

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc