@loaders.gl/tiles 3.3.0-alpha.5 → 3.3.0-alpha.6
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/dist/dist.min.js +823 -1298
- package/dist/es5/bundle.js +0 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/constants.js +2 -1
- package/dist/es5/constants.js.map +1 -1
- package/dist/es5/index.js +26 -36
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/tileset/helpers/3d-tiles-options.js +0 -1
- package/dist/es5/tileset/helpers/3d-tiles-options.js.map +1 -1
- package/dist/es5/tileset/helpers/bounding-volume.js +7 -26
- package/dist/es5/tileset/helpers/bounding-volume.js.map +1 -1
- package/dist/es5/tileset/helpers/frame-state.js +22 -42
- package/dist/es5/tileset/helpers/frame-state.js.map +1 -1
- package/dist/es5/tileset/helpers/i3s-lod.js +0 -13
- package/dist/es5/tileset/helpers/i3s-lod.js.map +1 -1
- package/dist/es5/tileset/helpers/tiles-3d-lod.js +7 -16
- package/dist/es5/tileset/helpers/tiles-3d-lod.js.map +1 -1
- package/dist/es5/tileset/helpers/transform-utils.js +2 -11
- package/dist/es5/tileset/helpers/transform-utils.js.map +1 -1
- package/dist/es5/tileset/helpers/zoom.js +6 -16
- package/dist/es5/tileset/helpers/zoom.js.map +1 -1
- package/dist/es5/tileset/tile-3d.js +95 -96
- package/dist/es5/tileset/tile-3d.js.map +1 -1
- package/dist/es5/tileset/tileset-3d.js +78 -185
- package/dist/es5/tileset/tileset-3d.js.map +1 -1
- package/dist/es5/tileset/tileset-cache.js +1 -14
- package/dist/es5/tileset/tileset-cache.js.map +1 -1
- package/dist/es5/tileset/traversers/i3s-pending-tiles-register.js +8 -13
- package/dist/es5/tileset/traversers/i3s-pending-tiles-register.js.map +1 -1
- package/dist/es5/tileset/traversers/i3s-tile-manager.js +20 -24
- package/dist/es5/tileset/traversers/i3s-tile-manager.js.map +1 -1
- package/dist/es5/tileset/traversers/i3s-tileset-traverser.js +7 -48
- package/dist/es5/tileset/traversers/i3s-tileset-traverser.js.map +1 -1
- package/dist/es5/tileset/traversers/tileset-3d-traverser.js +0 -22
- package/dist/es5/tileset/traversers/tileset-3d-traverser.js.map +1 -1
- package/dist/es5/tileset/traversers/tileset-traverser.js +53 -76
- package/dist/es5/tileset/traversers/tileset-traverser.js.map +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/utils/doubly-linked-list-node.js +3 -7
- package/dist/es5/utils/doubly-linked-list-node.js.map +1 -1
- package/dist/es5/utils/doubly-linked-list.js +9 -17
- package/dist/es5/utils/doubly-linked-list.js.map +1 -1
- package/dist/es5/utils/managed-array.js +29 -30
- package/dist/es5/utils/managed-array.js.map +1 -1
- package/dist/esm/bundle.js +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/constants.js +3 -0
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/tileset/helpers/3d-tiles-options.js.map +1 -1
- package/dist/esm/tileset/helpers/bounding-volume.js +4 -10
- package/dist/esm/tileset/helpers/bounding-volume.js.map +1 -1
- package/dist/esm/tileset/helpers/frame-state.js +16 -16
- package/dist/esm/tileset/helpers/frame-state.js.map +1 -1
- package/dist/esm/tileset/helpers/i3s-lod.js +4 -4
- package/dist/esm/tileset/helpers/i3s-lod.js.map +1 -1
- package/dist/esm/tileset/helpers/tiles-3d-lod.js +11 -8
- package/dist/esm/tileset/helpers/tiles-3d-lod.js.map +1 -1
- package/dist/esm/tileset/helpers/transform-utils.js +1 -3
- package/dist/esm/tileset/helpers/transform-utils.js.map +1 -1
- package/dist/esm/tileset/helpers/zoom.js +3 -2
- package/dist/esm/tileset/helpers/zoom.js.map +1 -1
- package/dist/esm/tileset/tile-3d.js +31 -107
- package/dist/esm/tileset/tile-3d.js.map +1 -1
- package/dist/esm/tileset/tileset-3d.js +21 -155
- package/dist/esm/tileset/tileset-3d.js.map +1 -1
- package/dist/esm/tileset/tileset-cache.js +2 -18
- package/dist/esm/tileset/tileset-cache.js.map +1 -1
- package/dist/esm/tileset/traversers/i3s-pending-tiles-register.js +0 -5
- package/dist/esm/tileset/traversers/i3s-pending-tiles-register.js.map +1 -1
- package/dist/esm/tileset/traversers/i3s-tile-manager.js +2 -4
- package/dist/esm/tileset/traversers/i3s-tile-manager.js.map +1 -1
- package/dist/esm/tileset/traversers/i3s-tileset-traverser.js +4 -17
- package/dist/esm/tileset/traversers/i3s-tileset-traverser.js.map +1 -1
- package/dist/esm/tileset/traversers/tileset-3d-traverser.js +2 -9
- package/dist/esm/tileset/traversers/tileset-3d-traverser.js.map +1 -1
- package/dist/esm/tileset/traversers/tileset-traverser.js +18 -57
- package/dist/esm/tileset/traversers/tileset-traverser.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/doubly-linked-list-node.js +1 -4
- package/dist/esm/utils/doubly-linked-list-node.js.map +1 -1
- package/dist/esm/utils/doubly-linked-list.js +2 -11
- package/dist/esm/utils/doubly-linked-list.js.map +1 -1
- package/dist/esm/utils/managed-array.js +4 -22
- package/dist/esm/utils/managed-array.js.map +1 -1
- package/dist/tileset/helpers/frame-state.d.ts +4 -4
- package/dist/tileset/helpers/frame-state.d.ts.map +1 -1
- package/dist/tileset/helpers/frame-state.js +1 -0
- package/dist/tileset/tileset-3d.d.ts.map +1 -1
- package/dist/types.d.ts +18 -10
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/tileset/helpers/frame-state.ts +6 -5
- package/src/tileset/tileset-3d.ts +2 -2
- package/src/types.ts +19 -10
|
@@ -7,25 +7,23 @@ const extraVertexEnu = new Vector3();
|
|
|
7
7
|
const projectedOriginVector = new Vector3();
|
|
8
8
|
const enuToCartesianMatrix = new Matrix4();
|
|
9
9
|
const cartesianToEnuMatrix = new Matrix4();
|
|
10
|
+
|
|
10
11
|
export function getLodStatus(tile, frameState) {
|
|
11
12
|
if (tile.lodMetricValue === 0 || isNaN(tile.lodMetricValue)) {
|
|
12
13
|
return 'DIG';
|
|
13
14
|
}
|
|
14
|
-
|
|
15
15
|
const screenSize = 2 * getProjectedRadius(tile, frameState);
|
|
16
|
-
|
|
17
16
|
if (screenSize < 2) {
|
|
18
17
|
return 'OUT';
|
|
19
18
|
}
|
|
20
|
-
|
|
21
19
|
if (!tile.header.children || screenSize <= tile.lodMetricValue) {
|
|
22
20
|
return 'DRAW';
|
|
23
21
|
} else if (tile.header.children) {
|
|
24
22
|
return 'DIG';
|
|
25
23
|
}
|
|
26
|
-
|
|
27
24
|
return 'OUT';
|
|
28
25
|
}
|
|
26
|
+
|
|
29
27
|
export function getProjectedRadius(tile, frameState) {
|
|
30
28
|
const {
|
|
31
29
|
topDownViewport: viewport
|
|
@@ -37,6 +35,7 @@ export function getProjectedRadius(tile, frameState) {
|
|
|
37
35
|
const mbsCenterCartesian = [...tile.boundingVolume.center];
|
|
38
36
|
const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
|
|
39
37
|
Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, cameraPositionCartesian);
|
|
38
|
+
|
|
40
39
|
toEye.copy(cameraPositionCartesian).subtract(mbsCenterCartesian).normalize();
|
|
41
40
|
Ellipsoid.WGS84.eastNorthUpToFixedFrame(mbsCenterCartesian, enuToCartesianMatrix);
|
|
42
41
|
cartesianToEnuMatrix.copy(enuToCartesianMatrix).invert();
|
|
@@ -49,6 +48,7 @@ export function getProjectedRadius(tile, frameState) {
|
|
|
49
48
|
const radiusVector = toEye.cross(extraVectorCartesian).normalize().scale(mbsR);
|
|
50
49
|
const sphereMbsBorderVertexCartesian = radiusVector.add(mbsCenterCartesian);
|
|
51
50
|
const sphereMbsBorderVertexCartographic = Ellipsoid.WGS84.cartesianToCartographic(sphereMbsBorderVertexCartesian);
|
|
51
|
+
|
|
52
52
|
const projectedOrigin = viewport.project([mbsLon, mbsLat, mbsZ]);
|
|
53
53
|
const projectedMbsBorderVertex = viewport.project(sphereMbsBorderVertexCartographic);
|
|
54
54
|
const projectedRadius = projectedOriginVector.copy(projectedOrigin).subtract(projectedMbsBorderVertex).magnitude();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"i3s-lod.js","names":["Matrix4","Vector3","Ellipsoid","cameraPositionCartesian","toEye","cameraPositionEnu","extraVertexEnu","projectedOriginVector","enuToCartesianMatrix","cartesianToEnuMatrix","getLodStatus","tile","frameState","lodMetricValue","isNaN","screenSize","getProjectedRadius","header","children","topDownViewport","viewport","mbsLat","mbs","mbsLon","mbsZ","mbsR","mbsCenterCartesian","boundingVolume","center","cameraPositionCartographic","unprojectPosition","cameraPosition","WGS84","cartographicToCartesian","copy","subtract","normalize","eastNorthUpToFixedFrame","invert","transform","projection","Math","sqrt","extraZ","extraVertexCartesian","extraVectorCartesian","radiusVector","cross","scale","sphereMbsBorderVertexCartesian","add","sphereMbsBorderVertexCartographic","cartesianToCartographic","projectedOrigin","project","projectedMbsBorderVertex","projectedRadius","magnitude"],"sources":["../../../../src/tileset/helpers/i3s-lod.ts"],"sourcesContent":["import {Matrix4, Vector3} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport Tile3D from '../tile-3d';\nimport {FrameState} from './frame-state';\n\nconst cameraPositionCartesian = new Vector3();\nconst toEye = new Vector3();\nconst cameraPositionEnu = new Vector3();\nconst extraVertexEnu = new Vector3();\nconst projectedOriginVector = new Vector3();\nconst enuToCartesianMatrix = new Matrix4();\nconst cartesianToEnuMatrix = new Matrix4();\n\n/**\n * For the maxScreenThreshold error metric, maxError means that you should replace the node with it's children\n as soon as the nodes bounding sphere has a screen radius larger than maxError pixels.\n In this sense a value of 0 means you should always load it's children,\n or if it's a leaf node, you should always display it.\n * @param tile \n * @param frameState \n * @returns \n */\nexport function getLodStatus(tile: Tile3D, frameState: FrameState): 'DIG' | 'OUT' | 'DRAW' {\n if (tile.lodMetricValue === 0 || isNaN(tile.lodMetricValue)) {\n return 'DIG';\n }\n const screenSize = 2 * getProjectedRadius(tile, frameState);\n if (screenSize < 2) {\n return 'OUT';\n }\n if (!tile.header.children || screenSize <= tile.lodMetricValue) {\n return 'DRAW';\n } else if (tile.header.children) {\n return 'DIG';\n }\n return 'OUT';\n}\n\n/**\n * Calculate size of MBS radius projected on the screen plane\n * @param tile\n * @param frameState\n * @returns\n */\n// eslint-disable-next-line max-statements\nexport function getProjectedRadius(tile: Tile3D, frameState: FrameState): number {\n const {topDownViewport: viewport} = frameState;\n const mbsLat = tile.header.mbs[1];\n const mbsLon = tile.header.mbs[0];\n const mbsZ = tile.header.mbs[2];\n const mbsR = tile.header.mbs[3];\n const mbsCenterCartesian = [...tile.boundingVolume.center];\n const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);\n Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, cameraPositionCartesian);\n\n // ---------------------------\n // Calculate mbs border vertex\n // ---------------------------\n toEye.copy(cameraPositionCartesian).subtract(mbsCenterCartesian).normalize();\n // Add extra vector to form plane\n Ellipsoid.WGS84.eastNorthUpToFixedFrame(mbsCenterCartesian, enuToCartesianMatrix);\n cartesianToEnuMatrix.copy(enuToCartesianMatrix).invert();\n cameraPositionEnu.copy(cameraPositionCartesian).transform(cartesianToEnuMatrix);\n // Mean Proportionals in Right Triangles - Altitude rule\n // https://mathbitsnotebook.com/Geometry/RightTriangles/RTmeanRight.html\n const projection = Math.sqrt(\n cameraPositionEnu[0] * cameraPositionEnu[0] + cameraPositionEnu[1] * cameraPositionEnu[1]\n );\n const extraZ = (projection * projection) / cameraPositionEnu[2];\n extraVertexEnu.copy([cameraPositionEnu[0], cameraPositionEnu[1], extraZ]);\n const extraVertexCartesian = extraVertexEnu.transform(enuToCartesianMatrix);\n const extraVectorCartesian = extraVertexCartesian.subtract(mbsCenterCartesian).normalize();\n // We need radius vector orthogonal to toEye vector\n const radiusVector = toEye.cross(extraVectorCartesian).normalize().scale(mbsR);\n const sphereMbsBorderVertexCartesian = radiusVector.add(mbsCenterCartesian);\n const sphereMbsBorderVertexCartographic = Ellipsoid.WGS84.cartesianToCartographic(\n sphereMbsBorderVertexCartesian\n );\n // ---------------------------\n\n // Project center vertex and border vertex and calculate projected radius of MBS\n const projectedOrigin = viewport.project([mbsLon, mbsLat, mbsZ]);\n const projectedMbsBorderVertex = viewport.project(\n sphereMbsBorderVertexCartographic as [number, number, number]\n );\n const projectedRadius = projectedOriginVector\n .copy(projectedOrigin)\n .subtract(projectedMbsBorderVertex)\n .magnitude();\n return projectedRadius;\n}\n"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,OAAO,QAAO,eAAe;AAC9C,SAAQC,SAAS,QAAO,qBAAqB;AAI7C,MAAMC,uBAAuB,GAAG,IAAIF,OAAO,EAAE;AAC7C,MAAMG,KAAK,GAAG,IAAIH,OAAO,EAAE;AAC3B,MAAMI,iBAAiB,GAAG,IAAIJ,OAAO,EAAE;AACvC,MAAMK,cAAc,GAAG,IAAIL,OAAO,EAAE;AACpC,MAAMM,qBAAqB,GAAG,IAAIN,OAAO,EAAE;AAC3C,MAAMO,oBAAoB,GAAG,IAAIR,OAAO,EAAE;AAC1C,MAAMS,oBAAoB,GAAG,IAAIT,OAAO,EAAE;;AAW1C,OAAO,SAASU,YAAY,CAACC,IAAY,EAAEC,UAAsB,EAA0B;EACzF,IAAID,IAAI,CAACE,cAAc,KAAK,CAAC,IAAIC,KAAK,CAACH,IAAI,CAACE,cAAc,CAAC,EAAE;IAC3D,OAAO,KAAK;EACd;EACA,MAAME,UAAU,GAAG,CAAC,GAAGC,kBAAkB,CAACL,IAAI,EAAEC,UAAU,CAAC;EAC3D,IAAIG,UAAU,GAAG,CAAC,EAAE;IAClB,OAAO,KAAK;EACd;EACA,IAAI,CAACJ,IAAI,CAACM,MAAM,CAACC,QAAQ,IAAIH,UAAU,IAAIJ,IAAI,CAACE,cAAc,EAAE;IAC9D,OAAO,MAAM;EACf,CAAC,MAAM,IAAIF,IAAI,CAACM,MAAM,CA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iBAAiB,CAAC,CAAC,CAAC,CAC1F;EACD,MAAMsC,MAAM,GAAIH,UAAU,GAAGA,UAAU,GAAInC,iBAAiB,CAAC,CAAC,CAAC;EAC/DC,cAAc,CAAC4B,IAAI,CAAC,CAAC7B,iBAAiB,CAAC,CAAC,CAAC,EAAEA,iBAAiB,CAAC,CAAC,CAAC,EAAEsC,MAAM,CAAC,CAAC;EACzE,MAAMC,oBAAoB,GAAGtC,cAAc,CAACiC,SAAS,CAAC/B,oBAAoB,CAAC;EAC3E,MAAMqC,oBAAoB,GAAGD,oBAAoB,CAACT,QAAQ,CAACT,kBAAkB,CAAC,CAACU,SAAS,EAAE;EAE1F,MAAMU,YAAY,GAAG1C,KAAK,CAAC2C,KAAK,CAACF,oBAAoB,CAAC,CAACT,SAAS,EAAE,CAACY,KAAK,CAACvB,IAAI,CAAC;EAC9E,MAAMwB,8BAA8B,GAAGH,YAAY,CAACI,GAAG,CAACxB,kBAAkB,CAAC;EAC3E,MAAMyB,iCAAiC,GAAGjD,SAAS,CAAC8B,KAAK,CAACoB,uBAAuB,CAC/EH,8BAA8B,CAC/B;;EAID,MAAMI,eAAe,GAAGjC,QAAQ,CAACkC,OAAO,CAAC,CAAC/B,MAAM,EAAEF,MAAM,EAAEG,IAAI,CAAC,CAAC;EAChE,MAAM+B,wBAAwB,GAAGnC,QAAQ,CAACkC,OAAO,CAC/CH,iCAAiC,CAClC;EACD,MAAMK,eAAe,GAAGjD,qBAAqB,CAC1C2B,IAAI,CAACmB,eAAe,CAAC,CACrBlB,QAAQ,CAACoB,wBAAwB,CAAC,CAClCE,SAAS,EAAE;EACd,OAAOD,eAAe;AACxB"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
1
3
|
import { Matrix4, Vector3, clamp } from '@math.gl/core';
|
|
2
4
|
const scratchPositionNormal = new Vector3();
|
|
3
5
|
const scratchCartographic = new Vector3();
|
|
@@ -5,10 +7,13 @@ const scratchMatrix = new Matrix4();
|
|
|
5
7
|
const scratchCenter = new Vector3();
|
|
6
8
|
const scratchPosition = new Vector3();
|
|
7
9
|
const scratchDirection = new Vector3();
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
|
|
11
|
+
export function calculateDynamicScreenSpaceError(root, _ref) {
|
|
12
|
+
let {
|
|
13
|
+
camera,
|
|
14
|
+
mapProjection
|
|
15
|
+
} = _ref;
|
|
16
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
12
17
|
const {
|
|
13
18
|
dynamicScreenSpaceErrorHeightFalloff = 0.25,
|
|
14
19
|
dynamicScreenSpaceErrorDensity = 0.00278
|
|
@@ -19,7 +24,6 @@ export function calculateDynamicScreenSpaceError(root, {
|
|
|
19
24
|
let minimumHeight;
|
|
20
25
|
let maximumHeight;
|
|
21
26
|
const tileBoundingVolume = root.contentBoundingVolume;
|
|
22
|
-
|
|
23
27
|
if (tileBoundingVolume instanceof TileBoundingRegion) {
|
|
24
28
|
up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);
|
|
25
29
|
direction = camera.directionWC;
|
|
@@ -31,7 +35,6 @@ export function calculateDynamicScreenSpaceError(root, {
|
|
|
31
35
|
const ellipsoid = mapProjection.ellipsoid;
|
|
32
36
|
const boundingVolume = tileBoundingVolume.boundingVolume;
|
|
33
37
|
const centerLocal = Matrix4.multiplyByPoint(transformLocal, boundingVolume.center, scratchCenter);
|
|
34
|
-
|
|
35
38
|
if (Cartesian3.magnitude(centerLocal) > ellipsoid.minimumRadius) {
|
|
36
39
|
const centerCartographic = Cartographic.fromCartesian(centerLocal, ellipsoid, scratchCartographic);
|
|
37
40
|
up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);
|
|
@@ -45,7 +48,6 @@ export function calculateDynamicScreenSpaceError(root, {
|
|
|
45
48
|
direction = Matrix4.multiplyByPointAsVector(transformLocal, camera.directionWC, scratchDirection);
|
|
46
49
|
direction = Cartesian3.normalize(direction, direction);
|
|
47
50
|
height = positionLocal.z;
|
|
48
|
-
|
|
49
51
|
if (tileBoundingVolume instanceof TileOrientedBoundingBox) {
|
|
50
52
|
const boxHeight = root._header.boundingVolume.box[11];
|
|
51
53
|
minimumHeight = centerLocal.z - boxHeight;
|
|
@@ -62,8 +64,10 @@ export function calculateDynamicScreenSpaceError(root, {
|
|
|
62
64
|
const heightClose = minimumHeight + (maximumHeight - minimumHeight) * heightFalloff;
|
|
63
65
|
const heightFar = maximumHeight;
|
|
64
66
|
const t = clamp((height - heightClose) / (heightFar - heightClose), 0.0, 1.0);
|
|
67
|
+
|
|
65
68
|
const dot = Math.abs(Cartesian3.dot(direction, up));
|
|
66
69
|
let horizonFactor = 1.0 - dot;
|
|
70
|
+
|
|
67
71
|
horizonFactor = horizonFactor * (1.0 - t);
|
|
68
72
|
return dynamicScreenSpaceErrorDensity * horizonFactor;
|
|
69
73
|
}
|
|
@@ -78,7 +82,6 @@ export function getDynamicScreenSpaceError(tileset, distanceToCamera) {
|
|
|
78
82
|
const dynamicError = fog(distanceToCamera, density) * factor;
|
|
79
83
|
return dynamicError;
|
|
80
84
|
}
|
|
81
|
-
|
|
82
85
|
return 0;
|
|
83
86
|
}
|
|
84
87
|
export function getTiles3DScreenSpaceError(tile, frameState, useParentLodMetric) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/tileset/helpers/tiles-3d-lod.ts"],"names":["Matrix4","Vector3","clamp","scratchPositionNormal","scratchCartographic","scratchMatrix","scratchCenter","scratchPosition","scratchDirection","calculateDynamicScreenSpaceError","root","camera","mapProjection","options","dynamicScreenSpaceErrorHeightFalloff","dynamicScreenSpaceErrorDensity","up","direction","height","minimumHeight","maximumHeight","tileBoundingVolume","contentBoundingVolume","TileBoundingRegion","Cartesian3","normalize","positionWC","directionWC","positionCartographic","transformLocal","inverseTransformation","computedTransform","ellipsoid","boundingVolume","centerLocal","multiplyByPoint","center","magnitude","minimumRadius","centerCartographic","Cartographic","fromCartesian","positionLocal","UNIT_Z","multiplyByPointAsVector","z","TileOrientedBoundingBox","boxHeight","_header","box","TileBoundingSphere","radius","heightFalloff","heightClose","heightFar","t","dot","Math","abs","horizonFactor","fog","distanceToCamera","density","scalar","exp","getDynamicScreenSpaceError","tileset","dynamicScreenSpaceError","dynamicScreenSpaceErrorComputedDensity","factor","dynamicScreenSpaceErrorFactor","dynamicError","getTiles3DScreenSpaceError","tile","frameState","useParentLodMetric","parentLodMetricValue","parent","lodMetricValue","distance","max","_distanceToCamera","sseDenominator","viewDistanceScale","error"],"mappings":"AAQA,SAAQA,OAAR,EAAiBC,OAAjB,EAA0BC,KAA1B,QAAsC,eAAtC;AAEA,MAAMC,qBAAqB,GAAG,IAAIF,OAAJ,EAA9B;AACA,MAAMG,mBAAmB,GAAG,IAAIH,OAAJ,EAA5B;AACA,MAAMI,aAAa,GAAG,IAAIL,OAAJ,EAAtB;AACA,MAAMM,aAAa,GAAG,IAAIL,OAAJ,EAAtB;AACA,MAAMM,eAAe,GAAG,IAAIN,OAAJ,EAAxB;AACA,MAAMO,gBAAgB,GAAG,IAAIP,OAAJ,EAAzB;AAGA,OAAO,SAASQ,gCAAT,CAA0CC,IAA1C,EAAgD;AAACC,EAAAA,MAAD;AAASC,EAAAA;AAAT,CAAhD,EAAyEC,OAAO,GAAG,EAAnF,EAAuF;AAC5F,QAAM;AAACC,IAAAA,oCAAoC,GAAG,IAAxC;AAA8CC,IAAAA,8BAA8B,GAAG;AAA/E,MACJF,OADF;AAGA,MAAIG,EAAJ;AACA,MAAIC,SAAJ;AACA,MAAIC,MAAJ;AACA,MAAIC,aAAJ;AACA,MAAIC,aAAJ;AAEA,QAAMC,kBAAkB,GAAGX,IAAI,CAACY,qBAAhC;;AAEA,MAAID,kBAAkB,YAAYE,kBAAlC,EAAsD;AACpDP,IAAAA,EAAE,GAAGQ,UAAU,CAACC,SAAX,CAAqBd,MAAM,CAACe,UAA5B,EAAwCvB,qBAAxC,CAAL;AACAc,IAAAA,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iE,iBAAiB,IAAI,GAAhD,CAAD,IAA0DJ,QAAQ,GAAGG,cAArE,CAAZ;AAEAE,EAAAA,KAAK,IAAInB,0BAA0B,CAACC,OAAD,EAAUa,QAAV,CAAnC;AAEA,SAAOK,KAAP;AACD","sourcesContent":["// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n// TODO - Dynamic screen space error provides an optimization when looking at\n// tilesets from above\n\n/* eslint-disable */\n// @ts-nocheck\nimport {Matrix4, Vector3, clamp} from '@math.gl/core';\n\nconst scratchPositionNormal = new Vector3();\nconst scratchCartographic = new Vector3();\nconst scratchMatrix = new Matrix4();\nconst scratchCenter = new Vector3();\nconst scratchPosition = new Vector3();\nconst scratchDirection = new Vector3();\n\n// eslint-disable-next-line max-statements, complexity\nexport function calculateDynamicScreenSpaceError(root, {camera, mapProjection}, options = {}) {\n const {dynamicScreenSpaceErrorHeightFalloff = 0.25, dynamicScreenSpaceErrorDensity = 0.00278} =\n options;\n\n let up;\n let direction;\n let height;\n let minimumHeight;\n let maximumHeight;\n\n const tileBoundingVolume = root.contentBoundingVolume;\n\n if (tileBoundingVolume instanceof TileBoundingRegion) {\n up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);\n direction = camera.directionWC;\n height = camera.positionCartographic.height;\n minimumHeight = tileBoundingVolume.minimumHeight;\n maximumHeight = tileBoundingVolume.maximumHeight;\n } else {\n // Transform camera position and direction into the local coordinate system of the tileset\n const transformLocal = Matrix4.inverseTransformation(root.computedTransform, scratchMatrix);\n const ellipsoid = mapProjection.ellipsoid;\n const boundingVolume = tileBoundingVolume.boundingVolume;\n const centerLocal = Matrix4.multiplyByPoint(\n transformLocal,\n boundingVolume.center,\n scratchCenter\n );\n if (Cartesian3.magnitude(centerLocal) > ellipsoid.minimumRadius) {\n // The tileset is defined in WGS84. Approximate the minimum and maximum height.\n const centerCartographic = Cartographic.fromCartesian(\n centerLocal,\n ellipsoid,\n scratchCartographic\n );\n up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);\n direction = camera.directionWC;\n height = camera.positionCartographic.height;\n minimumHeight = 0.0;\n maximumHeight = centerCartographic.height * 2.0;\n } else {\n // The tileset is defined in local coordinates (z-up)\n const positionLocal = Matrix4.multiplyByPoint(\n transformLocal,\n camera.positionWC,\n scratchPosition\n );\n up = Cartesian3.UNIT_Z;\n direction = Matrix4.multiplyByPointAsVector(\n transformLocal,\n camera.directionWC,\n scratchDirection\n );\n direction = Cartesian3.normalize(direction, direction);\n height = positionLocal.z;\n if (tileBoundingVolume instanceof TileOrientedBoundingBox) {\n // Assuming z-up, the last component stores the half-height of the box\n const boxHeight = root._header.boundingVolume.box[11];\n minimumHeight = centerLocal.z - boxHeight;\n maximumHeight = centerLocal.z + boxHeight;\n } else if (tileBoundingVolume instanceof TileBoundingSphere) {\n const radius = boundingVolume.radius;\n minimumHeight = centerLocal.z - radius;\n maximumHeight = centerLocal.z + radius;\n }\n }\n }\n\n // The range where the density starts to lessen. Start at the quarter height of the tileset.\n const heightFalloff = dynamicScreenSpaceErrorHeightFalloff;\n const heightClose = minimumHeight + (maximumHeight - minimumHeight) * heightFalloff;\n const heightFar = maximumHeight;\n\n const t = clamp((height - heightClose) / (heightFar - heightClose), 0.0, 1.0);\n\n // Increase density as the camera tilts towards the horizon\n const dot = Math.abs(Cartesian3.dot(direction, up));\n\n let horizonFactor = 1.0 - dot;\n\n // Weaken the horizon factor as the camera height increases, implying the camera is further away from the tileset.\n // The goal is to increase density for the \"street view\", not when viewing the tileset from a distance.\n horizonFactor = horizonFactor * (1.0 - t);\n\n return dynamicScreenSpaceErrorDensity * horizonFactor;\n}\n\nexport function fog(distanceToCamera, density) {\n const scalar = distanceToCamera * density;\n return 1.0 - Math.exp(-(scalar * scalar));\n}\n\nexport function getDynamicScreenSpaceError(tileset, distanceToCamera) {\n if (tileset.dynamicScreenSpaceError && tileset.dynamicScreenSpaceErrorComputedDensity) {\n const density = tileset.dynamicScreenSpaceErrorComputedDensity;\n const factor = tileset.dynamicScreenSpaceErrorFactor;\n // TODO: Refined screen space error that minimizes tiles in non-first-person\n const dynamicError = fog(distanceToCamera, density) * factor;\n return dynamicError;\n }\n\n return 0;\n}\n\nexport function getTiles3DScreenSpaceError(tile, frameState, useParentLodMetric) {\n const tileset = tile.tileset;\n const parentLodMetricValue = (tile.parent && tile.parent.lodMetricValue) || tile.lodMetricValue;\n const lodMetricValue = useParentLodMetric ? parentLodMetricValue : tile.lodMetricValue;\n\n // Leaf tiles do not have any error so save the computation\n if (lodMetricValue === 0.0) {\n return 0.0;\n }\n\n // TODO: Orthographic Frustum needs special treatment?\n // this._getOrthograhicScreenSpaceError();\n\n // Avoid divide by zero when viewer is inside the tile\n const distance = Math.max(tile._distanceToCamera, 1e-7);\n const {height, sseDenominator} = frameState;\n const {viewDistanceScale} = tileset.options;\n let error = (lodMetricValue * height * (viewDistanceScale || 1.0)) / (distance * sseDenominator);\n\n error -= getDynamicScreenSpaceError(tileset, distance);\n\n return error;\n}\n"],"file":"tiles-3d-lod.js"}
|
|
1
|
+
{"version":3,"file":"tiles-3d-lod.js","names":["Matrix4","Vector3","clamp","scratchPositionNormal","scratchCartographic","scratchMatrix","scratchCenter","scratchPosition","scratchDirection","calculateDynamicScreenSpaceError","root","camera","mapProjection","options","dynamicScreenSpaceErrorHeightFalloff","dynamicScreenSpaceErrorDensity","up","direction","height","minimumHeight","maximumHeight","tileBoundingVolume","contentBoundingVolume","TileBoundingRegion","Cartesian3","normalize","positionWC","directionWC","positionCartographic","transformLocal","inverseTransformation","computedTransform","ellipsoid","boundingVolume","centerLocal","multiplyByPoint","center","magnitude","minimumRadius","centerCartographic","Cartographic","fromCartesian","positionLocal","UNIT_Z","multiplyByPointAsVector","z","TileOrientedBoundingBox","boxHeight","_header","box","TileBoundingSphere","radius","heightFalloff","heightClose","heightFar","t","dot","Math","abs","horizonFactor","fog","distanceToCamera","density","scalar","exp","getDynamicScreenSpaceError","tileset","dynamicScreenSpaceError","dynamicScreenSpaceErrorComputedDensity","factor","dynamicScreenSpaceErrorFactor","dynamicError","getTiles3DScreenSpaceError","tile","frameState","useParentLodMetric","parentLodMetricValue","parent","lodMetricValue","distance","max","_distanceToCamera","sseDenominator","viewDistanceScale","error"],"sources":["../../../../src/tileset/helpers/tiles-3d-lod.ts"],"sourcesContent":["// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n// TODO - Dynamic screen space error provides an optimization when looking at\n// tilesets from above\n\n/* eslint-disable */\n// @ts-nocheck\nimport {Matrix4, Vector3, clamp} from '@math.gl/core';\n\nconst scratchPositionNormal = new Vector3();\nconst scratchCartographic = new Vector3();\nconst scratchMatrix = new Matrix4();\nconst scratchCenter = new Vector3();\nconst scratchPosition = new Vector3();\nconst scratchDirection = new Vector3();\n\n// eslint-disable-next-line max-statements, complexity\nexport function calculateDynamicScreenSpaceError(root, {camera, mapProjection}, options = {}) {\n const {dynamicScreenSpaceErrorHeightFalloff = 0.25, dynamicScreenSpaceErrorDensity = 0.00278} =\n options;\n\n let up;\n let direction;\n let height;\n let minimumHeight;\n let maximumHeight;\n\n const tileBoundingVolume = root.contentBoundingVolume;\n\n if (tileBoundingVolume instanceof TileBoundingRegion) {\n up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);\n direction = camera.directionWC;\n height = camera.positionCartographic.height;\n minimumHeight = tileBoundingVolume.minimumHeight;\n maximumHeight = tileBoundingVolume.maximumHeight;\n } else {\n // Transform camera position and direction into the local coordinate system of the tileset\n const transformLocal = Matrix4.inverseTransformation(root.computedTransform, scratchMatrix);\n const ellipsoid = mapProjection.ellipsoid;\n const boundingVolume = tileBoundingVolume.boundingVolume;\n const centerLocal = Matrix4.multiplyByPoint(\n transformLocal,\n boundingVolume.center,\n scratchCenter\n );\n if (Cartesian3.magnitude(centerLocal) > ellipsoid.minimumRadius) {\n // The tileset is defined in WGS84. Approximate the minimum and maximum height.\n const centerCartographic = Cartographic.fromCartesian(\n centerLocal,\n ellipsoid,\n scratchCartographic\n );\n up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);\n direction = camera.directionWC;\n height = camera.positionCartographic.height;\n minimumHeight = 0.0;\n maximumHeight = centerCartographic.height * 2.0;\n } else {\n // The tileset is defined in local coordinates (z-up)\n const positionLocal = Matrix4.multiplyByPoint(\n transformLocal,\n camera.positionWC,\n scratchPosition\n );\n up = Cartesian3.UNIT_Z;\n direction = Matrix4.multiplyByPointAsVector(\n transformLocal,\n camera.directionWC,\n scratchDirection\n );\n direction = Cartesian3.normalize(direction, direction);\n height = positionLocal.z;\n if (tileBoundingVolume instanceof TileOrientedBoundingBox) {\n // Assuming z-up, the last component stores the half-height of the box\n const boxHeight = root._header.boundingVolume.box[11];\n minimumHeight = centerLocal.z - boxHeight;\n maximumHeight = centerLocal.z + boxHeight;\n } else if (tileBoundingVolume instanceof TileBoundingSphere) {\n const radius = boundingVolume.radius;\n minimumHeight = centerLocal.z - radius;\n maximumHeight = centerLocal.z + radius;\n }\n }\n }\n\n // The range where the density starts to lessen. Start at the quarter height of the tileset.\n const heightFalloff = dynamicScreenSpaceErrorHeightFalloff;\n const heightClose = minimumHeight + (maximumHeight - minimumHeight) * heightFalloff;\n const heightFar = maximumHeight;\n\n const t = clamp((height - heightClose) / (heightFar - heightClose), 0.0, 1.0);\n\n // Increase density as the camera tilts towards the horizon\n const dot = Math.abs(Cartesian3.dot(direction, up));\n\n let horizonFactor = 1.0 - dot;\n\n // Weaken the horizon factor as the camera height increases, implying the camera is further away from the tileset.\n // The goal is to increase density for the \"street view\", not when viewing the tileset from a distance.\n horizonFactor = horizonFactor * (1.0 - t);\n\n return dynamicScreenSpaceErrorDensity * horizonFactor;\n}\n\nexport function fog(distanceToCamera, density) {\n const scalar = distanceToCamera * density;\n return 1.0 - Math.exp(-(scalar * scalar));\n}\n\nexport function getDynamicScreenSpaceError(tileset, distanceToCamera) {\n if (tileset.dynamicScreenSpaceError && tileset.dynamicScreenSpaceErrorComputedDensity) {\n const density = tileset.dynamicScreenSpaceErrorComputedDensity;\n const factor = tileset.dynamicScreenSpaceErrorFactor;\n // TODO: Refined screen space error that minimizes tiles in non-first-person\n const dynamicError = fog(distanceToCamera, density) * factor;\n return dynamicError;\n }\n\n return 0;\n}\n\nexport function getTiles3DScreenSpaceError(tile, frameState, useParentLodMetric) {\n const tileset = tile.tileset;\n const parentLodMetricValue = (tile.parent && tile.parent.lodMetricValue) || tile.lodMetricValue;\n const lodMetricValue = useParentLodMetric ? parentLodMetricValue : tile.lodMetricValue;\n\n // Leaf tiles do not have any error so save the computation\n if (lodMetricValue === 0.0) {\n return 0.0;\n }\n\n // TODO: Orthographic Frustum needs special treatment?\n // this._getOrthograhicScreenSpaceError();\n\n // Avoid divide by zero when viewer is inside the tile\n const distance = Math.max(tile._distanceToCamera, 1e-7);\n const {height, sseDenominator} = frameState;\n const {viewDistanceScale} = tileset.options;\n let error = (lodMetricValue * height * (viewDistanceScale || 1.0)) / (distance * sseDenominator);\n\n error -= getDynamicScreenSpaceError(tileset, distance);\n\n return error;\n}\n"],"mappings":";;AAQA,SAAQA,OAAO,EAAEC,OAAO,EAAEC,KAAK,QAAO,eAAe;AAErD,MAAMC,qBAAqB,GAAG,IAAIF,OAAO,EAAE;AAC3C,MAAMG,mBAAmB,GAAG,IAAIH,OAAO,EAAE;AACzC,MAAMI,aAAa,GAAG,IAAIL,OAAO,EAAE;AACnC,MAAMM,aAAa,GAAG,IAAIL,OAAO,EAAE;AACnC,MAAMM,eAAe,GAAG,IAAIN,OAAO,EAAE;AACrC,MAAMO,gBAAgB,GAAG,IAAIP,OAAO,EAAE;;AAGtC,OAAO,SAASQ,gCAAgC,CAACC,IAAI,QAAyC;EAAA,IAAvC;IAACC,MAAM;IAAEC;EAAa,CAAC;EAAA,IAAEC,OAAO,uEAAG,CAAC,CAAC;EAC1F,MAAM;IAACC,oCAAoC,GAAG,IAAI;IAAEC,8BA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E;EAAc,CAAC,GAAGR,UAAU;EAC3C,MAAM;IAACS;EAAiB,CAAC,GAAGjB,OAAO,CAACrD,OAAO;EAC3C,IAAIuE,KAAK,GAAIN,cAAc,GAAG5D,MAAM,IAAIiE,iBAAiB,IAAI,GAAG,CAAC,IAAKJ,QAAQ,GAAGG,cAAc,CAAC;EAEhGE,KAAK,IAAInB,0BAA0B,CAACC,OAAO,EAAEa,QAAQ,CAAC;EAEtD,OAAOK,KAAK;AACd"}
|
|
@@ -23,17 +23,14 @@ export function calculateTransformProps(tileHeader, tile) {
|
|
|
23
23
|
switch (gltfUpAxis) {
|
|
24
24
|
case 'Z':
|
|
25
25
|
break;
|
|
26
|
-
|
|
27
26
|
case 'Y':
|
|
28
27
|
const rotationY = new Matrix4().rotateX(Math.PI / 2);
|
|
29
28
|
modelMatrix = modelMatrix.multiplyRight(rotationY);
|
|
30
29
|
break;
|
|
31
|
-
|
|
32
30
|
case 'X':
|
|
33
31
|
const rotationX = new Matrix4().rotateY(-Math.PI / 2);
|
|
34
32
|
modelMatrix = modelMatrix.multiplyRight(rotationX);
|
|
35
33
|
break;
|
|
36
|
-
|
|
37
34
|
default:
|
|
38
35
|
break;
|
|
39
36
|
}
|
|
@@ -45,6 +42,7 @@ export function calculateTransformProps(tileHeader, tile) {
|
|
|
45
42
|
const cartesianOrigin = new Vector3(center);
|
|
46
43
|
tile.cartesianModelMatrix = modelMatrix;
|
|
47
44
|
tile.cartesianOrigin = cartesianOrigin;
|
|
45
|
+
|
|
48
46
|
const cartographicOrigin = Ellipsoid.WGS84.cartesianToCartographic(cartesianOrigin, new Vector3());
|
|
49
47
|
const fromFixedFrameMatrix = Ellipsoid.WGS84.eastNorthUpToFixedFrame(cartesianOrigin);
|
|
50
48
|
const toFixedFrameMatrix = fromFixedFrameMatrix.invert();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"transform-utils.js","names":["Ellipsoid","Matrix4","Vector3","assert","calculateTransformProps","tileHeader","tile","rtcCenter","gltfUpAxis","computedTransform","boundingVolume","center","modelMatrix","translate","rotationY","rotateX","Math","PI","multiplyRight","rotationX","rotateY","isQuantized","quantizedVolumeOffset","scale","quantizedVolumeScale","cartesianOrigin","cartesianModelMatrix","cartographicOrigin","WGS84","cartesianToCartographic","fromFixedFrameMatrix","eastNorthUpToFixedFrame","toFixedFrameMatrix","invert","cartographicModelMatrix","coordinateSystem"],"sources":["../../../../src/tileset/helpers/transform-utils.ts"],"sourcesContent":["import {Ellipsoid} from '@math.gl/geospatial';\nimport {Matrix4, Vector3} from '@math.gl/core';\nimport {assert} from '@loaders.gl/loader-utils';\n\nexport function calculateTransformProps(tileHeader, tile) {\n assert(tileHeader);\n assert(tile);\n\n const {rtcCenter, gltfUpAxis} = tile;\n const {\n computedTransform,\n boundingVolume: {center}\n } = tileHeader;\n\n let modelMatrix = new Matrix4(computedTransform);\n\n // Translate if appropriate\n if (rtcCenter) {\n modelMatrix.translate(rtcCenter);\n }\n\n // glTF models need to be rotated from Y to Z up\n // https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#y-up-to-z-up\n switch (gltfUpAxis) {\n case 'Z':\n break;\n case 'Y':\n const rotationY = new Matrix4().rotateX(Math.PI / 2);\n modelMatrix = modelMatrix.multiplyRight(rotationY);\n break;\n case 'X':\n const rotationX = new Matrix4().rotateY(-Math.PI / 2);\n modelMatrix = modelMatrix.multiplyRight(rotationX);\n break;\n default:\n break;\n }\n\n // Scale/offset positions if normalized integers\n if (tile.isQuantized) {\n modelMatrix.translate(tile.quantizedVolumeOffset).scale(tile.quantizedVolumeScale);\n }\n\n // Option 1: Cartesian matrix and origin\n const cartesianOrigin = new Vector3(center);\n\n tile.cartesianModelMatrix = modelMatrix;\n tile.cartesianOrigin = cartesianOrigin;\n\n // Option 2: Cartographic matrix and origin\n const cartographicOrigin = Ellipsoid.WGS84.cartesianToCartographic(\n cartesianOrigin,\n new Vector3()\n );\n const fromFixedFrameMatrix = Ellipsoid.WGS84.eastNorthUpToFixedFrame(cartesianOrigin);\n const toFixedFrameMatrix = fromFixedFrameMatrix.invert();\n\n tile.cartographicModelMatrix = toFixedFrameMatrix.multiplyRight(modelMatrix);\n tile.cartographicOrigin = cartographicOrigin;\n\n // Deprecated, drop\n if (!tile.coordinateSystem) {\n tile.modelMatrix = tile.cartographicModelMatrix;\n }\n}\n"],"mappings":"AAAA,SAAQA,SAAS,QAAO,qBAAqB;AAC7C,SAAQC,OAAO,EAAEC,OAAO,QAAO,eAAe;AAC9C,SAAQC,MAAM,QAAO,0BAA0B;AAE/C,OAAO,SAASC,uBAAuB,CAACC,UAAU,EAAEC,IAAI,EAAE;EACxDH,MAAM,CAACE,UAAU,CAAC;EAClBF,MAAM,CAACG,IAAI,CAAC;EAEZ,MAAM;IAACC,SAAS;IAAEC;EAAU,CAAC,GAAGF,IAAI;EACpC,MAAM;IACJG,iBAAiB;IACjBC,cAAc,EAAE;MAACC;IAAM;EACzB,CAAC,GAAGN,UAAU;EAEd,IAAIO,WAAW,GAAG,IAAIX,OAAO,CAACQ,iBAAiB,CAAC;;EAGhD,IAAIF,SAAS,EAAE;IACbK,WAAW,CAACC,SAAS,CAACN,SAAS,CAAC;EAClC;;EAIA,QAAQC,UAAU;IAChB,KAAK,GAAG;MACN;IACF,KAAK,GAAG;MACN,MAAMM,SAAS,GAAG,IAAIb,OAAO,EAAE,CAACc,OAAO,CAACC,IAAI,CAACC,EAAE,GAAG,CAAC,CAAC;MACpDL,WAAW,GAAGA,WAAW,CAACM,aAAa,CAACJ,SAAS,CAAC;MAClD;IACF,KAAK,GAAG;MACN,MAAMK,SAAS,GAAG,IAAIlB,OAAO,EAAE,CAACmB,OAAO,CAAC,CAACJ,IAAI,CAACC,EAAE,GAAG,CAAC,CAAC;MACrDL,WAAW,GAAGA,WAAW,CAACM,aAAa,CAACC,SAAS,CAAC;MAClD;IACF;MACE;EAAM;;EAIV,IAAIb,IAAI,CAACe,WAAW,EAAE;IACpBT,WAAW,CAACC,SAAS,CAACP,IAAI,CAACgB,qBAAqB,CAAC,CAACC,KAAK,CAACjB,IAAI,CAACkB,oBAAoB,CAAC;EACpF;;EAGA,MAAMC,eAAe,GAAG,IAAIvB,OAAO,CAACS,MAAM,CAAC;EAE3CL,IAAI,CAACoB,oBAAoB,GAAGd,WAAW;EACvCN,IAAI,CAACmB,eAAe,GAAGA,eAAe;;EAGtC,MAAME,kBAAkB,GAAG3B,SAAS,CAAC4B,KAAK,CAACC,uBAAuB,CAChEJ,eAAe,EACf,IAAIvB,OAAO,EAAE,CACd;EACD,MAAM4B,oBAAoB,GAAG9B,SAAS,CAAC4B,KAAK,CAACG,uBAAuB,CAACN,eAAe,CAAC;EACrF,MAAMO,kBAAkB,GAAGF,oBAAoB,CAACG,MAAM,EAAE;EAExD3B,IAAI,CAAC4B,uBAAuB,GAAGF,kBAAkB,CAACd,aAAa,CAACN,WAAW,CAAC;EAC5EN,IAAI,CAACqB,kBAAkB,GAAGA,kBAAkB;;EAG5C,IAAI,CAACrB,IAAI,CAAC6B,gBAAgB,EAAE;IAC1B7B,IAAI,CAACM,WAAW,GAAGN,IAAI,CAAC4B,uBAAuB;EACjD;AACF"}
|
|
@@ -5,6 +5,7 @@ const WGS84_RADIUS_X = 6378137.0;
|
|
|
5
5
|
const WGS84_RADIUS_Y = 6378137.0;
|
|
6
6
|
const WGS84_RADIUS_Z = 6356752.3142451793;
|
|
7
7
|
const scratchVector = new Vector3();
|
|
8
|
+
|
|
8
9
|
export function getZoomFromBoundingVolume(boundingVolume, cartorgraphicCenter) {
|
|
9
10
|
if (boundingVolume instanceof OrientedBoundingBox) {
|
|
10
11
|
const {
|
|
@@ -26,14 +27,15 @@ export function getZoomFromBoundingVolume(boundingVolume, cartorgraphicCenter) {
|
|
|
26
27
|
const zoomY = Math.log2(WGS84_RADIUS_Y / height);
|
|
27
28
|
return (zoomX + zoomY) / 2;
|
|
28
29
|
}
|
|
29
|
-
|
|
30
30
|
return 1;
|
|
31
31
|
}
|
|
32
|
+
|
|
32
33
|
export function getZoomFromFullExtent(fullExtent, cartorgraphicCenter, cartesianCenter) {
|
|
33
34
|
const extentVertex = Ellipsoid.WGS84.cartographicToCartesian([fullExtent.xmax, fullExtent.ymax, fullExtent.zmax], new Vector3());
|
|
34
35
|
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));
|
|
35
36
|
return Math.log2(WGS84_RADIUS_Z / (extentSize + cartorgraphicCenter[2]));
|
|
36
37
|
}
|
|
38
|
+
|
|
37
39
|
export function getZoomFromExtent(extent, cartorgraphicCenter, cartesianCenter) {
|
|
38
40
|
const [xmin, ymin, xmax, ymax] = extent;
|
|
39
41
|
return getZoomFromFullExtent({
|
|
@@ -45,7 +47,6 @@ export function getZoomFromExtent(extent, cartorgraphicCenter, cartesianCenter)
|
|
|
45
47
|
zmax: 0
|
|
46
48
|
}, cartorgraphicCenter, cartesianCenter);
|
|
47
49
|
}
|
|
48
|
-
|
|
49
50
|
function getObbSize(halfAxes) {
|
|
50
51
|
halfAxes.getColumn(0, scratchVector);
|
|
51
52
|
const axeY = halfAxes.getColumn(1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"zoom.js","names":["Vector3","BoundingSphere","OrientedBoundingBox","Ellipsoid","WGS84_RADIUS_X","WGS84_RADIUS_Y","WGS84_RADIUS_Z","scratchVector","getZoomFromBoundingVolume","boundingVolume","cartorgraphicCenter","halfAxes","obbSize","getObbSize","Math","log2","radius","width","height","zoomX","zoomY","getZoomFromFullExtent","fullExtent","cartesianCenter","extentVertex","WGS84","cartographicToCartesian","xmax","ymax","zmax","extentSize","sqrt","pow","getZoomFromExtent","extent","xmin","ymin","zmin","getColumn","axeY","axeZ","farthestVertex","add","size","len"],"sources":["../../../../src/tileset/helpers/zoom.ts"],"sourcesContent":["import {Vector3} from '@math.gl/core';\nimport {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {BoundingRectangle} from '../../types';\n\nconst WGS84_RADIUS_X = 6378137.0;\nconst WGS84_RADIUS_Y = 6378137.0;\nconst WGS84_RADIUS_Z = 6356752.3142451793;\n\nconst scratchVector = new Vector3();\n\n/**\n * Calculate appropriate zoom value for a particular boundingVolume\n * @param boundingVolume - the instance of bounding volume\n * @param cartorgraphicCenter - cartographic center of the bounding volume\n * @returns {number} - zoom value\n */\nexport function getZoomFromBoundingVolume(\n boundingVolume: BoundingSphere | OrientedBoundingBox | BoundingRectangle,\n cartorgraphicCenter: Vector3\n) {\n if (boundingVolume instanceof OrientedBoundingBox) {\n // OrientedBoundingBox\n const {halfAxes} = boundingVolume;\n const obbSize = getObbSize(halfAxes);\n // Use WGS84_RADIUS_Z to allign with BoundingSphere algorithm\n // Add the tile elevation value for correct zooming to elevated tiles\n return Math.log2(WGS84_RADIUS_Z / (obbSize + cartorgraphicCenter[2]));\n } else if (boundingVolume instanceof BoundingSphere) {\n // BoundingSphere\n const {radius} = boundingVolume;\n // Add the tile elevation value for correct zooming to elevated tiles\n return Math.log2(WGS84_RADIUS_Z / (radius + cartorgraphicCenter[2]));\n } else if (boundingVolume.width && boundingVolume.height) {\n // BoundingRectangle\n const {width, height} = boundingVolume;\n const zoomX = Math.log2(WGS84_RADIUS_X / width);\n const zoomY = Math.log2(WGS84_RADIUS_Y / height);\n\n return (zoomX + zoomY) / 2;\n }\n\n return 1;\n}\n\n/**\n * Calculate initial zoom for the tileset from 3D `fullExtent` defined in\n * the tileset metadata\n * @param fullExtent - 3D extent of the tileset\n * @param fullExtent.xmin - minimal longitude in decimal degrees\n * @param fullExtent.xmax - maximal longitude in decimal degrees\n * @param fullExtent.ymin - minimal latitude in decimal degrees\n * @param fullExtent.ymax - maximal latitude in decimal degrees\n * @param fullExtent.zmin - minimal elevation in meters\n * @param fullExtent.zmax - maximal elevation in meters\n * @param cartorgraphicCenter - tileset center in cartographic coordinate system\n * @param cartesianCenter - tileset center in cartesian coordinate system\n * @returns - initial zoom for the tileset\n */\nexport function getZoomFromFullExtent(\n fullExtent: {\n xmin: number;\n xmax: number;\n ymin: number;\n ymax: number;\n zmin: number;\n zmax: number;\n },\n cartorgraphicCenter: Vector3,\n cartesianCenter: Vector3\n) {\n const extentVertex = Ellipsoid.WGS84.cartographicToCartesian(\n [fullExtent.xmax, fullExtent.ymax, fullExtent.zmax],\n new Vector3()\n );\n const extentSize = Math.sqrt(\n Math.pow(extentVertex[0] - cartesianCenter[0], 2) +\n Math.pow(extentVertex[1] - cartesianCenter[1], 2) +\n Math.pow(extentVertex[2] - cartesianCenter[2], 2)\n );\n return Math.log2(WGS84_RADIUS_Z / (extentSize + cartorgraphicCenter[2]));\n}\n\n/**\n * Calculate initial zoom for the tileset from 2D `extent` defined in\n * the tileset metadata\n * @param extent - 2D extent of the tileset. It is array of 4 elements [xmin, ymin, xmax, ymax]\n * @param extent[0] - minimal longitude in decimal degrees\n * @param extent[1] - minimal latitude in decimal degrees\n * @param extent[2] - maximal longitude in decimal degrees\n * @param extent[3] - maximal latitude in decimal degrees\n * @param cartorgraphicCenter - tileset center in cartographic coordinate system\n * @param cartesianCenter - tileset center in cartesian coordinate system\n * @returns - initial zoom for the tileset\n */\nexport function getZoomFromExtent(\n extent: [number, number, number, number],\n cartorgraphicCenter: Vector3,\n cartesianCenter: Vector3\n) {\n const [xmin, ymin, xmax, ymax] = extent;\n return getZoomFromFullExtent(\n {xmin, xmax, ymin, ymax, zmin: 0, zmax: 0},\n cartorgraphicCenter,\n cartesianCenter\n );\n}\n\nfunction getObbSize(halfAxes) {\n halfAxes.getColumn(0, scratchVector);\n const axeY = halfAxes.getColumn(1);\n const axeZ = halfAxes.getColumn(2);\n const farthestVertex = scratchVector.add(axeY).add(axeZ);\n const size = farthestVertex.len();\n return size;\n}\n"],"mappings":"AAAA,SAAQA,OAAO,QAAO,eAAe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