@math.gl/geospatial 3.4.0-alpha.1 → 3.4.4
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.
- package/README.md +1 -1
- package/dist/es6/ellipsoid/ellipsoid.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
[math.gl](https://math.gl/docs) is a suite of math modules for 3D and geospatial applications.
|
|
4
4
|
|
|
5
|
-
This module contains geospatial math, for dealing with the WGS84 (World Geodetic System) coordinate system
|
|
5
|
+
This module contains geospatial math, primarly ellipsoid math for dealing with the WGS84 (World Geodetic System) coordinate system.
|
|
6
6
|
|
|
7
7
|
For documentation please visit the [website](https://math.gl).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ellipsoid/ellipsoid.js"],"names":["Vector3","Matrix4","toRadians","toDegrees","assert","equals","_MathUtils","vec3","WGS84_RADIUS_X","WGS84_RADIUS_Y","WGS84_RADIUS_Z","fromCartographicToRadians","toCartographicFromRadians","scaleToGeodeticSurface","localFrameToFixedFrame","scratchVector","scratchNormal","scratchK","scratchPosition","scratchHeight","scratchCartesian","wgs84","Ellipsoid","WGS84","constructor","x","y","z","radii","radiiSquared","radiiToTheFourth","oneOverRadii","oneOverRadiiSquared","minimumRadius","Math","min","maximumRadius","max","centerToleranceSquared","EPSILON1","squaredXOverSquaredZ","Object","freeze","right","Boolean","toString","cartographicToCartesian","cartographic","result","normal","k","height","geodeticSurfaceNormalCartographic","copy","scale","gamma","sqrt","dot","add","to","cartesianToCartographic","cartesian","from","point","undefined","geodeticSurfaceNormal","h","subtract","longitude","atan2","latitude","asin","sign","length","eastNorthUpToFixedFrame","origin","firstAxis","secondAxis","thirdAxis","geocentricSurfaceNormal","normalize","cartographicVectorRadians","cosLatitude","cos","set","sin","scaleToGeocentricSurface","positionX","positionY","positionZ","beta","multiplyScalar","transformPositionToScaledSpace","position","transform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A,MAAM,CAACC,MAAM,CAAC,KAAKuB,KAAL,CAAWH,CAAZ,EAAe,KAAKG,KAAL,CAAWF,CAA1B,EAA6BpB,UAAU,CAAC2F,SAAxC,CAAP,CAAN;AACA7F,IAAAA,MAAM,CAAC,KAAKwB,KAAL,CAAWD,CAAX,GAAe,CAAhB,CAAN;AAEAT,IAAAA,eAAe,CAAC4C,IAAhB,CAAqB+B,QAArB;AACA,UAAMlE,CAAC,GAAGT,eAAe,CAACS,CAAhB,IAAqB,IAAI,KAAKa,oBAA9B,CAAV;;AAEA,QAAIN,IAAI,CAACgE,GAAL,CAASvE,CAAT,KAAe,KAAKC,KAAL,CAAWD,CAAX,GAAeqE,MAAlC,EAA0C;AACxC,aAAOhC,SAAP;AACD;;AAED,WAAO9C,eAAe,CAACkE,GAAhB,CAAoB,GAApB,EAAyB,GAAzB,EAA8BzD,CAA9B,EAAiCgC,EAAjC,CAAoCX,MAApC,CAAP;AACD;;AAzM4B","sourcesContent":["// This file is derived from the Cesium math library under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n/* eslint-disable */\nimport {Vector3, Matrix4, toRadians, toDegrees, assert, equals, _MathUtils} from '@math.gl/core';\nimport * as vec3 from 'gl-matrix/vec3';\n\nimport {WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z} from '../constants';\nimport {fromCartographicToRadians, toCartographicFromRadians} from '../type-utils';\n\nimport scaleToGeodeticSurface from './helpers/scale-to-geodetic-surface';\nimport localFrameToFixedFrame from './helpers/ellipsoid-transform';\n\nconst scratchVector = new Vector3();\nconst scratchNormal = new Vector3();\nconst scratchK = new Vector3();\nconst scratchPosition = new Vector3();\nconst scratchHeight = new Vector3();\nconst scratchCartesian = new Vector3();\n\nlet wgs84;\n\n// A quadratic surface defined in Cartesian coordinates by the equation\n// <code>(x / a)^2 + (y / b)^2 + (z / c)^2 = 1</code>. Primarily used\n// to represent the shape of planetary bodies.\nexport default class Ellipsoid {\n // An Ellipsoid instance initialized to the WGS84 standard.\n static get WGS84() {\n wgs84 = wgs84 || new Ellipsoid(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z);\n return wgs84;\n }\n\n // Creates an Ellipsoid from a Cartesian specifying the radii in x, y, and z directions.\n constructor(x = 0.0, y = 0.0, z = 0.0) {\n assert(x >= 0.0);\n assert(y >= 0.0);\n assert(z >= 0.0);\n\n this.radii = new Vector3(x, y, z);\n\n this.radiiSquared = new Vector3(x * x, y * y, z * z);\n\n this.radiiToTheFourth = new Vector3(x * x * x * x, y * y * y * y, z * z * z * z);\n\n this.oneOverRadii = new Vector3(\n x === 0.0 ? 0.0 : 1.0 / x,\n y === 0.0 ? 0.0 : 1.0 / y,\n z === 0.0 ? 0.0 : 1.0 / z\n );\n\n this.oneOverRadiiSquared = new Vector3(\n x === 0.0 ? 0.0 : 1.0 / (x * x),\n y === 0.0 ? 0.0 : 1.0 / (y * y),\n z === 0.0 ? 0.0 : 1.0 / (z * z)\n );\n\n this.minimumRadius = Math.min(x, y, z);\n\n this.maximumRadius = Math.max(x, y, z);\n\n this.centerToleranceSquared = _MathUtils.EPSILON1;\n\n if (this.radiiSquared.z !== 0) {\n this.squaredXOverSquaredZ = this.radiiSquared.x / this.radiiSquared.z;\n }\n\n Object.freeze(this);\n }\n\n // Compares this Ellipsoid against the provided Ellipsoid componentwise and returns\n equals(right) {\n return this === right || Boolean(right && this.radii.equals(right.radii));\n }\n\n // Creates a string representing this Ellipsoid in the format '(radii.x, radii.y, radii.z)'.\n toString() {\n return this.radii.toString();\n }\n\n // Converts the provided cartographic to Cartesian representation.\n cartographicToCartesian(cartographic, result = [0, 0, 0]) {\n const normal = scratchNormal;\n const k = scratchK;\n\n const [, , height] = cartographic;\n this.geodeticSurfaceNormalCartographic(cartographic, normal);\n k.copy(this.radiiSquared).scale(normal);\n\n const gamma = Math.sqrt(normal.dot(k));\n k.scale(1 / gamma);\n\n normal.scale(height);\n\n k.add(normal);\n\n return k.to(result);\n }\n\n // Converts the provided cartesian to cartographic (lng/lat/z) representation.\n // The cartesian is undefined at the center of the ellipsoid.\n cartesianToCartographic(cartesian, result = [0, 0, 0]) {\n scratchCartesian.from(cartesian);\n const point = this.scaleToGeodeticSurface(scratchCartesian, scratchPosition);\n\n if (!point) {\n return undefined;\n }\n\n const normal = this.geodeticSurfaceNormal(point, scratchNormal);\n\n const h = scratchHeight;\n h.copy(scratchCartesian).subtract(point);\n\n const longitude = Math.atan2(normal.y, normal.x);\n const latitude = Math.asin(normal.z);\n const height = Math.sign(vec3.dot(h, scratchCartesian)) * vec3.length(h);\n\n return toCartographicFromRadians([longitude, latitude, height], result);\n }\n\n // Computes a 4x4 transformation matrix from a reference frame with an east-north-up axes\n // centered at the provided origin to the provided ellipsoid's fixed reference frame.\n eastNorthUpToFixedFrame(origin, result = new Matrix4()) {\n return localFrameToFixedFrame(this, 'east', 'north', 'up', origin, result);\n }\n\n // Computes a 4x4 transformation matrix from a reference frame centered at\n // the provided origin to the ellipsoid's fixed reference frame.\n localFrameToFixedFrame(firstAxis, secondAxis, thirdAxis, origin, result = new Matrix4()) {\n return localFrameToFixedFrame(this, firstAxis, secondAxis, thirdAxis, origin, result);\n }\n\n // Computes the unit vector directed from the center of this ellipsoid toward\n // the provided Cartesian position.\n geocentricSurfaceNormal(cartesian, result = [0, 0, 0]) {\n return scratchVector\n .from(cartesian)\n .normalize()\n .to(result);\n }\n\n // Computes the normal of the plane tangent to the surface of the ellipsoid at provided position.\n geodeticSurfaceNormalCartographic(cartographic, result = [0, 0, 0]) {\n const cartographicVectorRadians = fromCartographicToRadians(cartographic);\n\n const longitude = cartographicVectorRadians[0];\n const latitude = cartographicVectorRadians[1];\n\n const cosLatitude = Math.cos(latitude);\n\n scratchVector\n .set(cosLatitude * Math.cos(longitude), cosLatitude * Math.sin(longitude), Math.sin(latitude))\n .normalize();\n\n return scratchVector.to(result);\n }\n\n // Computes the normal of the plane tangent to the surface of the ellipsoid at the provided position.\n geodeticSurfaceNormal(cartesian, result = [0, 0, 0]) {\n return scratchVector\n .from(cartesian)\n .scale(this.oneOverRadiiSquared)\n .normalize()\n .to(result);\n }\n\n // Scales the provided Cartesian position along the geodetic surface normal\n // so that it is on the surface of this ellipsoid. If the position is\n // at the center of the ellipsoid, this function returns undefined.\n scaleToGeodeticSurface(cartesian, result) {\n return scaleToGeodeticSurface(cartesian, this, result);\n }\n\n // Scales the provided Cartesian position along the geocentric surface normal\n // so that it is on the surface of this ellipsoid.\n scaleToGeocentricSurface(cartesian, result = [0, 0, 0]) {\n scratchPosition.from(cartesian);\n\n const positionX = scratchPosition.x;\n const positionY = scratchPosition.y;\n const positionZ = scratchPosition.z;\n const oneOverRadiiSquared = this.oneOverRadiiSquared;\n\n const beta =\n 1.0 /\n Math.sqrt(\n positionX * positionX * oneOverRadiiSquared.x +\n positionY * positionY * oneOverRadiiSquared.y +\n positionZ * positionZ * oneOverRadiiSquared.z\n );\n\n return scratchPosition.multiplyScalar(beta).to(result);\n }\n\n // Transforms a Cartesian X, Y, Z position to the ellipsoid-scaled space by multiplying\n // its components by the result of `Ellipsoid#oneOverRadii`\n transformPositionToScaledSpace(position, result = [0, 0, 0]) {\n return scratchPosition\n .from(position)\n .scale(this.oneOverRadii)\n .to(result);\n }\n\n // Transforms a Cartesian X, Y, Z position from the ellipsoid-scaled space by multiplying\n // its components by the result of `Ellipsoid#radii`.\n transformPositionFromScaledSpace(position, result = [0, 0, 0]) {\n return scratchPosition\n .from(position)\n .scale(this.radii)\n .to(result);\n }\n\n // Computes a point which is the intersection of the surface normal with the z-axis.\n getSurfaceNormalIntersectionWithZAxis(position, buffer = 0.0, result = [0, 0, 0]) {\n // Ellipsoid must be an ellipsoid of revolution (radii.x == radii.y)\n assert(equals(this.radii.x, this.radii.y, _MathUtils.EPSILON15));\n assert(this.radii.z > 0);\n\n scratchPosition.from(position);\n const z = scratchPosition.z * (1 - this.squaredXOverSquaredZ);\n\n if (Math.abs(z) >= this.radii.z - buffer) {\n return undefined;\n }\n\n return scratchPosition.set(0.0, 0.0, z).to(result);\n }\n}\n"],"file":"ellipsoid.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/ellipsoid/ellipsoid.js"],"names":["Vector3","Matrix4","toRadians","toDegrees","assert","equals","_MathUtils","vec3","WGS84_RADIUS_X","WGS84_RADIUS_Y","WGS84_RADIUS_Z","fromCartographicToRadians","toCartographicFromRadians","scaleToGeodeticSurface","localFrameToFixedFrame","scratchVector","scratchNormal","scratchK","scratchPosition","scratchHeight","scratchCartesian","wgs84","Ellipsoid","WGS84","constructor","x","y","z","radii","radiiSquared","radiiToTheFourth","oneOverRadii","oneOverRadiiSquared","minimumRadius","Math","min","maximumRadius","max","centerToleranceSquared","EPSILON1","squaredXOverSquaredZ","Object","freeze","right","Boolean","toString","cartographicToCartesian","cartographic","result","normal","k","height","geodeticSurfaceNormalCartographic","copy","scale","gamma","sqrt","dot","add","to","cartesianToCartographic","cartesian","from","point","undefined","geodeticSurfaceNormal","h","subtract","longitude","atan2","latitude","asin","sign","length","eastNorthUpToFixedFrame","origin","firstAxis","secondAxis","thirdAxis","geocentricSurfaceNormal","normalize","cartographicVectorRadians","cosLatitude","cos","set","sin","scaleToGeocentricSurface","positionX","positionY","positionZ","beta","multiplyScalar","transformPositionToScaledSpace","position","transformPositionFromScaledSpace","getSurfaceNormalIntersectionWithZAxis","buffer","EPSILON15","abs"],"mappings":"AAIA,SAAQA,OAAR,EAAiBC,OAAjB,EAA0BC,SAA1B,EAAqCC,SAArC,EAAgDC,MAAhD,EAAwDC,MAAxD,EAAgEC,UAAhE,QAAiF,eAAjF;AACA,OAAO,KAAKC,IAAZ,MAAsB,gBAAtB;AAEA,SAAQC,cAAR,EAAwBC,cAAxB,EAAwCC,cAAxC,QAA6D,cAA7D;AACA,SAAQC,yBAAR,EAAmCC,yBAAnC,QAAmE,eAAnE;AAEA,OAAOC,sBAAP,MAAmC,qCAAnC;AACA,OAAOC,sBAAP,MAAmC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AAX,GAAeqE,MAAlC,EAA0C;AACxC,aAAOhC,SAAP;AACD;;AAED,WAAO9C,eAAe,CAACkE,GAAhB,CAAoB,GAApB,EAAyB,GAAzB,EAA8BzD,CAA9B,EAAiCgC,EAAjC,CAAoCX,MAApC,CAAP;AACD;;AAzM4B","sourcesContent":["// This file is derived from the Cesium math library under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n/* eslint-disable */\nimport {Vector3, Matrix4, toRadians, toDegrees, assert, equals, _MathUtils} from '@math.gl/core';\nimport * as vec3 from 'gl-matrix/vec3';\n\nimport {WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z} from '../constants';\nimport {fromCartographicToRadians, toCartographicFromRadians} from '../type-utils';\n\nimport scaleToGeodeticSurface from './helpers/scale-to-geodetic-surface';\nimport localFrameToFixedFrame from './helpers/ellipsoid-transform';\n\nconst scratchVector = new Vector3();\nconst scratchNormal = new Vector3();\nconst scratchK = new Vector3();\nconst scratchPosition = new Vector3();\nconst scratchHeight = new Vector3();\nconst scratchCartesian = new Vector3();\n\nlet wgs84;\n\n// A quadratic surface defined in Cartesian coordinates by the equation\n// <code>(x / a)^2 + (y / b)^2 + (z / c)^2 = 1</code>. Primarily used\n// to represent the shape of planetary bodies.\nexport default class Ellipsoid {\n // An Ellipsoid instance initialized to the WGS84 standard.\n static get WGS84() {\n wgs84 = wgs84 || new Ellipsoid(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z);\n return wgs84;\n }\n\n // Creates an Ellipsoid from a Cartesian specifying the radii in x, y, and z directions.\n constructor(x = 0.0, y = 0.0, z = 0.0) {\n assert(x >= 0.0);\n assert(y >= 0.0);\n assert(z >= 0.0);\n\n this.radii = new Vector3(x, y, z);\n\n this.radiiSquared = new Vector3(x * x, y * y, z * z);\n\n this.radiiToTheFourth = new Vector3(x * x * x * x, y * y * y * y, z * z * z * z);\n\n this.oneOverRadii = new Vector3(\n x === 0.0 ? 0.0 : 1.0 / x,\n y === 0.0 ? 0.0 : 1.0 / y,\n z === 0.0 ? 0.0 : 1.0 / z\n );\n\n this.oneOverRadiiSquared = new Vector3(\n x === 0.0 ? 0.0 : 1.0 / (x * x),\n y === 0.0 ? 0.0 : 1.0 / (y * y),\n z === 0.0 ? 0.0 : 1.0 / (z * z)\n );\n\n this.minimumRadius = Math.min(x, y, z);\n\n this.maximumRadius = Math.max(x, y, z);\n\n this.centerToleranceSquared = _MathUtils.EPSILON1;\n\n if (this.radiiSquared.z !== 0) {\n this.squaredXOverSquaredZ = this.radiiSquared.x / this.radiiSquared.z;\n }\n\n Object.freeze(this);\n }\n\n // Compares this Ellipsoid against the provided Ellipsoid componentwise and returns\n equals(right) {\n return this === right || Boolean(right && this.radii.equals(right.radii));\n }\n\n // Creates a string representing this Ellipsoid in the format '(radii.x, radii.y, radii.z)'.\n toString() {\n return this.radii.toString();\n }\n\n // Converts the provided cartographic to Cartesian representation.\n cartographicToCartesian(cartographic, result = [0, 0, 0]) {\n const normal = scratchNormal;\n const k = scratchK;\n\n const [, , height] = cartographic;\n this.geodeticSurfaceNormalCartographic(cartographic, normal);\n k.copy(this.radiiSquared).scale(normal);\n\n const gamma = Math.sqrt(normal.dot(k));\n k.scale(1 / gamma);\n\n normal.scale(height);\n\n k.add(normal);\n\n return k.to(result);\n }\n\n // Converts the provided cartesian to cartographic (lng/lat/z) representation.\n // The cartesian is undefined at the center of the ellipsoid.\n cartesianToCartographic(cartesian, result = [0, 0, 0]) {\n scratchCartesian.from(cartesian);\n const point = this.scaleToGeodeticSurface(scratchCartesian, scratchPosition);\n\n if (!point) {\n return undefined;\n }\n\n const normal = this.geodeticSurfaceNormal(point, scratchNormal);\n\n const h = scratchHeight;\n h.copy(scratchCartesian).subtract(point);\n\n const longitude = Math.atan2(normal.y, normal.x);\n const latitude = Math.asin(normal.z);\n const height = Math.sign(vec3.dot(h, scratchCartesian)) * vec3.length(h);\n\n return toCartographicFromRadians([longitude, latitude, height], result);\n }\n\n // Computes a 4x4 transformation matrix from a reference frame with an east-north-up axes\n // centered at the provided origin to the provided ellipsoid's fixed reference frame.\n eastNorthUpToFixedFrame(origin, result = new Matrix4()) {\n return localFrameToFixedFrame(this, 'east', 'north', 'up', origin, result);\n }\n\n // Computes a 4x4 transformation matrix from a reference frame centered at\n // the provided origin to the ellipsoid's fixed reference frame.\n localFrameToFixedFrame(firstAxis, secondAxis, thirdAxis, origin, result = new Matrix4()) {\n return localFrameToFixedFrame(this, firstAxis, secondAxis, thirdAxis, origin, result);\n }\n\n // Computes the unit vector directed from the center of this ellipsoid toward\n // the provided Cartesian position.\n geocentricSurfaceNormal(cartesian, result = [0, 0, 0]) {\n return scratchVector\n .from(cartesian)\n .normalize()\n .to(result);\n }\n\n // Computes the normal of the plane tangent to the surface of the ellipsoid at provided position.\n geodeticSurfaceNormalCartographic(cartographic, result = [0, 0, 0]) {\n const cartographicVectorRadians = fromCartographicToRadians(cartographic);\n\n const longitude = cartographicVectorRadians[0];\n const latitude = cartographicVectorRadians[1];\n\n const cosLatitude = Math.cos(latitude);\n\n scratchVector\n .set(cosLatitude * Math.cos(longitude), cosLatitude * Math.sin(longitude), Math.sin(latitude))\n .normalize();\n\n return scratchVector.to(result);\n }\n\n // Computes the normal of the plane tangent to the surface of the ellipsoid at the provided position.\n geodeticSurfaceNormal(cartesian, result = [0, 0, 0]) {\n return scratchVector\n .from(cartesian)\n .scale(this.oneOverRadiiSquared)\n .normalize()\n .to(result);\n }\n\n // Scales the provided Cartesian position along the geodetic surface normal\n // so that it is on the surface of this ellipsoid. If the position is\n // at the center of the ellipsoid, this function returns undefined.\n scaleToGeodeticSurface(cartesian, result) {\n return scaleToGeodeticSurface(cartesian, this, result);\n }\n\n // Scales the provided Cartesian position along the geocentric surface normal\n // so that it is on the surface of this ellipsoid.\n scaleToGeocentricSurface(cartesian, result = [0, 0, 0]) {\n scratchPosition.from(cartesian);\n\n const positionX = scratchPosition.x;\n const positionY = scratchPosition.y;\n const positionZ = scratchPosition.z;\n const oneOverRadiiSquared = this.oneOverRadiiSquared;\n\n const beta =\n 1.0 /\n Math.sqrt(\n positionX * positionX * oneOverRadiiSquared.x +\n positionY * positionY * oneOverRadiiSquared.y +\n positionZ * positionZ * oneOverRadiiSquared.z\n );\n\n return scratchPosition.multiplyScalar(beta).to(result);\n }\n\n // Transforms a Cartesian X, Y, Z position to the ellipsoid-scaled space by multiplying\n // its components by the result of `Ellipsoid#oneOverRadii`\n transformPositionToScaledSpace(position, result = [0, 0, 0]) {\n return scratchPosition\n .from(position)\n .scale(this.oneOverRadii)\n .to(result);\n }\n\n // Transforms a Cartesian X, Y, Z position from the ellipsoid-scaled space by multiplying\n // its components by the result of `Ellipsoid#radii`.\n transformPositionFromScaledSpace(position, result = [0, 0, 0]) {\n return scratchPosition\n .from(position)\n .scale(this.radii)\n .to(result);\n }\n\n // Computes a point which is the intersection of the surface normal with the z-axis.\n getSurfaceNormalIntersectionWithZAxis(position, buffer = 0.0, result = [0, 0, 0]) {\n // Ellipsoid must be an ellipsoid of revolution (radii.x == radii.y)\n assert(equals(this.radii.x, this.radii.y, _MathUtils.EPSILON15));\n assert(this.radii.z > 0);\n\n scratchPosition.from(position);\n const z = scratchPosition.z * (1 - this.squaredXOverSquaredZ);\n\n if (Math.abs(z) >= this.radii.z - buffer) {\n return undefined;\n }\n\n return scratchPosition.set(0.0, 0.0, z).to(result);\n }\n}\n"],"file":"ellipsoid.js"}
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
|
-
"version": "3.4.
|
|
8
|
+
"version": "3.4.4",
|
|
9
9
|
"keywords": [
|
|
10
10
|
"webgl",
|
|
11
11
|
"javascript",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"src"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@babel/runtime": "^7.
|
|
36
|
-
"@math.gl/core": "3.4.
|
|
35
|
+
"@babel/runtime": "^7.12.0",
|
|
36
|
+
"@math.gl/core": "3.4.4",
|
|
37
37
|
"gl-matrix": "^3.0.0"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "13a7e26f5243beca891164e4c9ce1607de46bcbf"
|
|
40
40
|
}
|