@loaders.gl/tiles 3.1.3 → 4.0.0-alpha.5
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/bundle.js +2 -2
- package/dist/bundle.js.map +1 -0
- package/dist/constants.js +26 -29
- package/dist/constants.js.map +1 -0
- package/dist/dist.min.js +45 -264
- package/dist/index.js +10 -28
- package/dist/index.js.map +1 -0
- package/dist/tileset/helpers/3d-tiles-options.js +5 -8
- package/dist/tileset/helpers/3d-tiles-options.js.map +1 -0
- package/dist/tileset/helpers/bounding-volume.js +70 -159
- package/dist/tileset/helpers/bounding-volume.js.map +1 -0
- package/dist/tileset/helpers/frame-state.js +48 -67
- package/dist/tileset/helpers/frame-state.js.map +1 -0
- package/dist/tileset/helpers/i3s-lod.js +64 -80
- package/dist/tileset/helpers/i3s-lod.js.map +1 -0
- package/dist/tileset/helpers/tiles-3d-lod.js +100 -111
- package/dist/tileset/helpers/tiles-3d-lod.js.map +1 -0
- package/dist/tileset/helpers/transform-utils.js +56 -50
- package/dist/tileset/helpers/transform-utils.js.map +1 -0
- package/dist/tileset/helpers/zoom.js +30 -36
- package/dist/tileset/helpers/zoom.js.map +1 -0
- package/dist/tileset/tile-3d.js +533 -551
- package/dist/tileset/tile-3d.js.map +1 -0
- package/dist/tileset/tileset-3d.js +649 -576
- package/dist/tileset/tileset-3d.js.map +1 -0
- package/dist/tileset/tileset-cache.js +71 -71
- package/dist/tileset/tileset-cache.js.map +1 -0
- package/dist/tileset/traversers/i3s-tile-manager.js +40 -31
- package/dist/tileset/traversers/i3s-tile-manager.js.map +1 -0
- package/dist/tileset/traversers/i3s-tileset-traverser.js +76 -81
- package/dist/tileset/traversers/i3s-tileset-traverser.js.map +1 -0
- package/dist/tileset/traversers/tileset-3d-traverser.js +49 -51
- package/dist/tileset/traversers/tileset-3d-traverser.js.map +1 -0
- package/dist/tileset/traversers/tileset-traverser.js +276 -274
- package/dist/tileset/traversers/tileset-traverser.js.map +1 -0
- package/dist/utils/doubly-linked-list-node.js +15 -16
- package/dist/utils/doubly-linked-list-node.js.map +1 -0
- package/dist/utils/doubly-linked-list.js +75 -94
- package/dist/utils/doubly-linked-list.js.map +1 -0
- package/dist/utils/managed-array.js +109 -143
- package/dist/utils/managed-array.js.map +1 -0
- package/package.json +7 -7
- package/dist/es5/bundle.js +0 -7
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/constants.js +0 -44
- package/dist/es5/constants.js.map +0 -1
- package/dist/es5/index.js +0 -104
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/tileset/helpers/3d-tiles-options.js +0 -13
- package/dist/es5/tileset/helpers/3d-tiles-options.js.map +0 -1
- package/dist/es5/tileset/helpers/bounding-volume.js +0 -114
- package/dist/es5/tileset/helpers/bounding-volume.js.map +0 -1
- package/dist/es5/tileset/helpers/frame-state.js +0 -65
- package/dist/es5/tileset/helpers/frame-state.js.map +0 -1
- package/dist/es5/tileset/helpers/i3s-lod.js +0 -86
- package/dist/es5/tileset/helpers/i3s-lod.js.map +0 -1
- package/dist/es5/tileset/helpers/tiles-3d-lod.js +0 -119
- package/dist/es5/tileset/helpers/tiles-3d-lod.js.map +0 -1
- package/dist/es5/tileset/helpers/transform-utils.js +0 -65
- package/dist/es5/tileset/helpers/transform-utils.js.map +0 -1
- package/dist/es5/tileset/helpers/zoom.js +0 -43
- package/dist/es5/tileset/helpers/zoom.js.map +0 -1
- package/dist/es5/tileset/tile-3d.js +0 -605
- package/dist/es5/tileset/tile-3d.js.map +0 -1
- package/dist/es5/tileset/tileset-3d.js +0 -838
- package/dist/es5/tileset/tileset-3d.js.map +0 -1
- package/dist/es5/tileset/tileset-cache.js +0 -101
- package/dist/es5/tileset/tileset-cache.js.map +0 -1
- package/dist/es5/tileset/traversers/i3s-tile-manager.js +0 -69
- package/dist/es5/tileset/traversers/i3s-tile-manager.js.map +0 -1
- package/dist/es5/tileset/traversers/i3s-tileset-traverser.js +0 -185
- package/dist/es5/tileset/traversers/i3s-tileset-traverser.js.map +0 -1
- package/dist/es5/tileset/traversers/tileset-3d-traverser.js +0 -94
- package/dist/es5/tileset/traversers/tileset-3d-traverser.js.map +0 -1
- package/dist/es5/tileset/traversers/tileset-traverser.js +0 -377
- package/dist/es5/tileset/traversers/tileset-traverser.js.map +0 -1
- package/dist/es5/utils/doubly-linked-list-node.js +0 -25
- package/dist/es5/utils/doubly-linked-list-node.js.map +0 -1
- package/dist/es5/utils/doubly-linked-list.js +0 -104
- package/dist/es5/utils/doubly-linked-list.js.map +0 -1
- package/dist/es5/utils/managed-array.js +0 -147
- package/dist/es5/utils/managed-array.js.map +0 -1
- package/dist/esm/bundle.js +0 -5
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/constants.js +0 -32
- package/dist/esm/constants.js.map +0 -1
- package/dist/esm/index.js +0 -10
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/tileset/helpers/3d-tiles-options.js +0 -6
- package/dist/esm/tileset/helpers/3d-tiles-options.js.map +0 -1
- package/dist/esm/tileset/helpers/bounding-volume.js +0 -88
- package/dist/esm/tileset/helpers/bounding-volume.js.map +0 -1
- package/dist/esm/tileset/helpers/frame-state.js +0 -51
- package/dist/esm/tileset/helpers/frame-state.js.map +0 -1
- package/dist/esm/tileset/helpers/i3s-lod.js +0 -67
- package/dist/esm/tileset/helpers/i3s-lod.js.map +0 -1
- package/dist/esm/tileset/helpers/tiles-3d-lod.js +0 -105
- package/dist/esm/tileset/helpers/tiles-3d-lod.js.map +0 -1
- package/dist/esm/tileset/helpers/transform-utils.js +0 -58
- package/dist/esm/tileset/helpers/transform-utils.js.map +0 -1
- package/dist/esm/tileset/helpers/zoom.js +0 -36
- package/dist/esm/tileset/helpers/zoom.js.map +0 -1
- package/dist/esm/tileset/tile-3d.js +0 -537
- package/dist/esm/tileset/tile-3d.js.map +0 -1
- package/dist/esm/tileset/tileset-3d.js +0 -674
- package/dist/esm/tileset/tileset-3d.js.map +0 -1
- package/dist/esm/tileset/tileset-cache.js +0 -79
- package/dist/esm/tileset/tileset-cache.js.map +0 -1
- package/dist/esm/tileset/traversers/i3s-tile-manager.js +0 -45
- package/dist/esm/tileset/traversers/i3s-tile-manager.js.map +0 -1
- package/dist/esm/tileset/traversers/i3s-tileset-traverser.js +0 -80
- package/dist/esm/tileset/traversers/i3s-tileset-traverser.js.map +0 -1
- package/dist/esm/tileset/traversers/tileset-3d-traverser.js +0 -53
- package/dist/esm/tileset/traversers/tileset-3d-traverser.js.map +0 -1
- package/dist/esm/tileset/traversers/tileset-traverser.js +0 -296
- package/dist/esm/tileset/traversers/tileset-traverser.js.map +0 -1
- package/dist/esm/utils/doubly-linked-list-node.js +0 -16
- package/dist/esm/utils/doubly-linked-list-node.js.map +0 -1
- package/dist/esm/utils/doubly-linked-list.js +0 -81
- package/dist/esm/utils/doubly-linked-list.js.map +0 -1
- package/dist/esm/utils/managed-array.js +0 -117
- package/dist/esm/utils/managed-array.js.map +0 -1
|
@@ -1,116 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
import { Matrix4, Vector3, clamp } from '@math.gl/core';
|
|
2
|
+
const scratchPositionNormal = new Vector3();
|
|
3
|
+
const scratchCartographic = new Vector3();
|
|
4
|
+
const scratchMatrix = new Matrix4();
|
|
5
|
+
const scratchCenter = new Vector3();
|
|
6
|
+
const scratchPosition = new Vector3();
|
|
7
|
+
const scratchDirection = new Vector3();
|
|
8
|
+
export function calculateDynamicScreenSpaceError(root, {
|
|
9
|
+
camera,
|
|
10
|
+
mapProjection
|
|
11
|
+
}, options = {}) {
|
|
12
|
+
const {
|
|
13
|
+
dynamicScreenSpaceErrorHeightFalloff = 0.25,
|
|
14
|
+
dynamicScreenSpaceErrorDensity = 0.00278
|
|
15
|
+
} = options;
|
|
16
|
+
let up;
|
|
17
|
+
let direction;
|
|
18
|
+
let height;
|
|
19
|
+
let minimumHeight;
|
|
20
|
+
let maximumHeight;
|
|
21
|
+
const tileBoundingVolume = root.contentBoundingVolume;
|
|
22
|
+
|
|
23
|
+
if (tileBoundingVolume instanceof TileBoundingRegion) {
|
|
24
|
+
up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);
|
|
25
|
+
direction = camera.directionWC;
|
|
26
|
+
height = camera.positionCartographic.height;
|
|
27
|
+
minimumHeight = tileBoundingVolume.minimumHeight;
|
|
28
|
+
maximumHeight = tileBoundingVolume.maximumHeight;
|
|
29
|
+
} else {
|
|
30
|
+
const transformLocal = Matrix4.inverseTransformation(root.computedTransform, scratchMatrix);
|
|
31
|
+
const ellipsoid = mapProjection.ellipsoid;
|
|
32
|
+
const boundingVolume = tileBoundingVolume.boundingVolume;
|
|
33
|
+
const centerLocal = Matrix4.multiplyByPoint(transformLocal, boundingVolume.center, scratchCenter);
|
|
34
|
+
|
|
35
|
+
if (Cartesian3.magnitude(centerLocal) > ellipsoid.minimumRadius) {
|
|
36
|
+
const centerCartographic = Cartographic.fromCartesian(centerLocal, ellipsoid, scratchCartographic);
|
|
37
|
+
up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);
|
|
38
|
+
direction = camera.directionWC;
|
|
39
|
+
height = camera.positionCartographic.height;
|
|
40
|
+
minimumHeight = 0.0;
|
|
41
|
+
maximumHeight = centerCartographic.height * 2.0;
|
|
42
|
+
} else {
|
|
43
|
+
const positionLocal = Matrix4.multiplyByPoint(transformLocal, camera.positionWC, scratchPosition);
|
|
44
|
+
up = Cartesian3.UNIT_Z;
|
|
45
|
+
direction = Matrix4.multiplyByPointAsVector(transformLocal, camera.directionWC, scratchDirection);
|
|
46
|
+
direction = Cartesian3.normalize(direction, direction);
|
|
47
|
+
height = positionLocal.z;
|
|
48
|
+
|
|
49
|
+
if (tileBoundingVolume instanceof TileOrientedBoundingBox) {
|
|
50
|
+
const boxHeight = root._header.boundingVolume.box[11];
|
|
51
|
+
minimumHeight = centerLocal.z - boxHeight;
|
|
52
|
+
maximumHeight = centerLocal.z + boxHeight;
|
|
53
|
+
} else if (tileBoundingVolume instanceof TileBoundingSphere) {
|
|
54
|
+
const radius = boundingVolume.radius;
|
|
55
|
+
minimumHeight = centerLocal.z - radius;
|
|
56
|
+
maximumHeight = centerLocal.z + radius;
|
|
57
|
+
}
|
|
32
58
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
direction = camera.directionWC;
|
|
44
|
-
height = camera.positionCartographic.height;
|
|
45
|
-
minimumHeight = 0.0;
|
|
46
|
-
maximumHeight = centerCartographic.height * 2.0;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
// The tileset is defined in local coordinates (z-up)
|
|
50
|
-
const positionLocal = core_1.Matrix4.multiplyByPoint(transformLocal, camera.positionWC, scratchPosition);
|
|
51
|
-
up = Cartesian3.UNIT_Z;
|
|
52
|
-
direction = core_1.Matrix4.multiplyByPointAsVector(transformLocal, camera.directionWC, scratchDirection);
|
|
53
|
-
direction = Cartesian3.normalize(direction, direction);
|
|
54
|
-
height = positionLocal.z;
|
|
55
|
-
if (tileBoundingVolume instanceof TileOrientedBoundingBox) {
|
|
56
|
-
// Assuming z-up, the last component stores the half-height of the box
|
|
57
|
-
const boxHeight = root._header.boundingVolume.box[11];
|
|
58
|
-
minimumHeight = centerLocal.z - boxHeight;
|
|
59
|
-
maximumHeight = centerLocal.z + boxHeight;
|
|
60
|
-
}
|
|
61
|
-
else if (tileBoundingVolume instanceof TileBoundingSphere) {
|
|
62
|
-
const radius = boundingVolume.radius;
|
|
63
|
-
minimumHeight = centerLocal.z - radius;
|
|
64
|
-
maximumHeight = centerLocal.z + radius;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
// The range where the density starts to lessen. Start at the quarter height of the tileset.
|
|
69
|
-
const heightFalloff = dynamicScreenSpaceErrorHeightFalloff;
|
|
70
|
-
const heightClose = minimumHeight + (maximumHeight - minimumHeight) * heightFalloff;
|
|
71
|
-
const heightFar = maximumHeight;
|
|
72
|
-
const t = (0, core_1.clamp)((height - heightClose) / (heightFar - heightClose), 0.0, 1.0);
|
|
73
|
-
// Increase density as the camera tilts towards the horizon
|
|
74
|
-
const dot = Math.abs(Cartesian3.dot(direction, up));
|
|
75
|
-
let horizonFactor = 1.0 - dot;
|
|
76
|
-
// Weaken the horizon factor as the camera height increases, implying the camera is further away from the tileset.
|
|
77
|
-
// The goal is to increase density for the "street view", not when viewing the tileset from a distance.
|
|
78
|
-
horizonFactor = horizonFactor * (1.0 - t);
|
|
79
|
-
return dynamicScreenSpaceErrorDensity * horizonFactor;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const heightFalloff = dynamicScreenSpaceErrorHeightFalloff;
|
|
62
|
+
const heightClose = minimumHeight + (maximumHeight - minimumHeight) * heightFalloff;
|
|
63
|
+
const heightFar = maximumHeight;
|
|
64
|
+
const t = clamp((height - heightClose) / (heightFar - heightClose), 0.0, 1.0);
|
|
65
|
+
const dot = Math.abs(Cartesian3.dot(direction, up));
|
|
66
|
+
let horizonFactor = 1.0 - dot;
|
|
67
|
+
horizonFactor = horizonFactor * (1.0 - t);
|
|
68
|
+
return dynamicScreenSpaceErrorDensity * horizonFactor;
|
|
80
69
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return 1.0 - Math.exp(-(scalar * scalar));
|
|
70
|
+
export function fog(distanceToCamera, density) {
|
|
71
|
+
const scalar = distanceToCamera * density;
|
|
72
|
+
return 1.0 - Math.exp(-(scalar * scalar));
|
|
85
73
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return 0;
|
|
74
|
+
export function getDynamicScreenSpaceError(tileset, distanceToCamera) {
|
|
75
|
+
if (tileset.dynamicScreenSpaceError && tileset.dynamicScreenSpaceErrorComputedDensity) {
|
|
76
|
+
const density = tileset.dynamicScreenSpaceErrorComputedDensity;
|
|
77
|
+
const factor = tileset.dynamicScreenSpaceErrorFactor;
|
|
78
|
+
const dynamicError = fog(distanceToCamera, density) * factor;
|
|
79
|
+
return dynamicError;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return 0;
|
|
96
83
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
84
|
+
export function getTiles3DScreenSpaceError(tile, frameState, useParentLodMetric) {
|
|
85
|
+
const tileset = tile.tileset;
|
|
86
|
+
const parentLodMetricValue = tile.parent && tile.parent.lodMetricValue || tile.lodMetricValue;
|
|
87
|
+
const lodMetricValue = useParentLodMetric ? parentLodMetricValue : tile.lodMetricValue;
|
|
88
|
+
|
|
89
|
+
if (lodMetricValue === 0.0) {
|
|
90
|
+
return 0.0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const distance = Math.max(tile._distanceToCamera, 1e-7);
|
|
94
|
+
const {
|
|
95
|
+
height,
|
|
96
|
+
sseDenominator
|
|
97
|
+
} = frameState;
|
|
98
|
+
const {
|
|
99
|
+
viewDistanceScale
|
|
100
|
+
} = tileset.options;
|
|
101
|
+
let error = lodMetricValue * height * (viewDistanceScale || 1.0) / (distance * sseDenominator);
|
|
102
|
+
error -= getDynamicScreenSpaceError(tileset, distance);
|
|
103
|
+
return error;
|
|
115
104
|
}
|
|
116
|
-
|
|
105
|
+
//# sourceMappingURL=tiles-3d-lod.js.map
|
|
@@ -0,0 +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,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ASC,0BAAT,CAAoCC,IAApC,EAA0CC,UAA1C,EAAsDC,kBAAtD,EAA0E;AAC/E,QAAMT,OAAO,GAAGO,IAAI,CAACP,OAArB;AACA,QAAMU,oBAAoB,GAAIH,IAAI,CAACI,MAAL,IAAeJ,IAAI,CAACI,MAAL,CAAYC,cAA5B,IAA+CL,IAAI,CAACK,cAAjF;AACA,QAAMA,cAAc,GAAGH,kBAAkB,GAAGC,oBAAH,GAA0BH,IAAI,CAACK,cAAxE;;AAGA,MAAIA,cAAc,KAAK,GAAvB,EAA4B;AAC1B,WAAO,GAAP;AACD;;AAMD,QAAMC,QAAQ,GAAGtB,IAAI,CAACuB,GAAL,CAASP,IAAI,CAACQ,iBAAd,EAAiC,IAAjC,CAAjB;AACA,QAAM;AAAC/D,IAAAA,MAAD;AAASgE,IAAAA;AAAT,MAA2BR,UAAjC;AACA,QAAM;AAACS,IAAAA;AAAD,MAAsBjB,OAAO,CAACrD,OAApC;AACA,MAAIuE,KAAK,GAAIN,cAAc,GAAG5D,MAAjB,IAA2BiE,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,52 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
modelMatrix.translate(rtcCenter);
|
|
16
|
-
}
|
|
17
|
-
// glTF models need to be rotated from Y to Z up
|
|
18
|
-
// https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#y-up-to-z-up
|
|
19
|
-
switch (gltfUpAxis) {
|
|
20
|
-
case 'Z':
|
|
21
|
-
break;
|
|
22
|
-
case 'Y':
|
|
23
|
-
const rotationY = new core_1.Matrix4().rotateX(Math.PI / 2);
|
|
24
|
-
modelMatrix = modelMatrix.multiplyRight(rotationY);
|
|
25
|
-
break;
|
|
26
|
-
case 'X':
|
|
27
|
-
const rotationX = new core_1.Matrix4().rotateY(-Math.PI / 2);
|
|
28
|
-
modelMatrix = modelMatrix.multiplyRight(rotationX);
|
|
29
|
-
break;
|
|
30
|
-
default:
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
// Scale/offset positions if normalized integers
|
|
34
|
-
if (tile.isQuantized) {
|
|
35
|
-
modelMatrix.translate(tile.quantizedVolumeOffset).scale(tile.quantizedVolumeScale);
|
|
36
|
-
}
|
|
37
|
-
// Option 1: Cartesian matrix and origin
|
|
38
|
-
const cartesianOrigin = new core_1.Vector3(center);
|
|
39
|
-
tile.cartesianModelMatrix = modelMatrix;
|
|
40
|
-
tile.cartesianOrigin = cartesianOrigin;
|
|
41
|
-
// Option 2: Cartographic matrix and origin
|
|
42
|
-
const cartographicOrigin = geospatial_1.Ellipsoid.WGS84.cartesianToCartographic(cartesianOrigin, new core_1.Vector3());
|
|
43
|
-
const fromFixedFrameMatrix = geospatial_1.Ellipsoid.WGS84.eastNorthUpToFixedFrame(cartesianOrigin);
|
|
44
|
-
const toFixedFrameMatrix = fromFixedFrameMatrix.invert();
|
|
45
|
-
tile.cartographicModelMatrix = toFixedFrameMatrix.multiplyRight(modelMatrix);
|
|
46
|
-
tile.cartographicOrigin = cartographicOrigin;
|
|
47
|
-
// Deprecated, drop
|
|
48
|
-
if (!tile.coordinateSystem) {
|
|
49
|
-
tile.modelMatrix = tile.cartographicModelMatrix;
|
|
1
|
+
import { Ellipsoid } from '@math.gl/geospatial';
|
|
2
|
+
import { Matrix4, Vector3 } from '@math.gl/core';
|
|
3
|
+
import { assert } from '@loaders.gl/loader-utils';
|
|
4
|
+
export function calculateTransformProps(tileHeader, tile) {
|
|
5
|
+
assert(tileHeader);
|
|
6
|
+
assert(tile);
|
|
7
|
+
const {
|
|
8
|
+
rtcCenter,
|
|
9
|
+
gltfUpAxis
|
|
10
|
+
} = tile;
|
|
11
|
+
const {
|
|
12
|
+
computedTransform,
|
|
13
|
+
boundingVolume: {
|
|
14
|
+
center
|
|
50
15
|
}
|
|
16
|
+
} = tileHeader;
|
|
17
|
+
let modelMatrix = new Matrix4(computedTransform);
|
|
18
|
+
|
|
19
|
+
if (rtcCenter) {
|
|
20
|
+
modelMatrix.translate(rtcCenter);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
switch (gltfUpAxis) {
|
|
24
|
+
case 'Z':
|
|
25
|
+
break;
|
|
26
|
+
|
|
27
|
+
case 'Y':
|
|
28
|
+
const rotationY = new Matrix4().rotateX(Math.PI / 2);
|
|
29
|
+
modelMatrix = modelMatrix.multiplyRight(rotationY);
|
|
30
|
+
break;
|
|
31
|
+
|
|
32
|
+
case 'X':
|
|
33
|
+
const rotationX = new Matrix4().rotateY(-Math.PI / 2);
|
|
34
|
+
modelMatrix = modelMatrix.multiplyRight(rotationX);
|
|
35
|
+
break;
|
|
36
|
+
|
|
37
|
+
default:
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (tile.isQuantized) {
|
|
42
|
+
modelMatrix.translate(tile.quantizedVolumeOffset).scale(tile.quantizedVolumeScale);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const cartesianOrigin = new Vector3(center);
|
|
46
|
+
tile.cartesianModelMatrix = modelMatrix;
|
|
47
|
+
tile.cartesianOrigin = cartesianOrigin;
|
|
48
|
+
const cartographicOrigin = Ellipsoid.WGS84.cartesianToCartographic(cartesianOrigin, new Vector3());
|
|
49
|
+
const fromFixedFrameMatrix = Ellipsoid.WGS84.eastNorthUpToFixedFrame(cartesianOrigin);
|
|
50
|
+
const toFixedFrameMatrix = fromFixedFrameMatrix.invert();
|
|
51
|
+
tile.cartographicModelMatrix = toFixedFrameMatrix.multiplyRight(modelMatrix);
|
|
52
|
+
tile.cartographicOrigin = cartographicOrigin;
|
|
53
|
+
|
|
54
|
+
if (!tile.coordinateSystem) {
|
|
55
|
+
tile.modelMatrix = tile.cartographicModelMatrix;
|
|
56
|
+
}
|
|
51
57
|
}
|
|
52
|
-
|
|
58
|
+
//# sourceMappingURL=transform-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/tileset/helpers/transform-utils.ts"],"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"],"mappings":"AAAA,SAAQA,SAAR,QAAwB,qBAAxB;AACA,SAAQC,OAAR,EAAiBC,OAAjB,QAA+B,eAA/B;AACA,SAAQC,MAAR,QAAqB,0BAArB;AAEA,OAAO,SAASC,uB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AAC4B,KAAV,CAAgBC,uBAAhB,CACzBJ,eADyB,EAEzB,IAAIvB,OAAJ,EAFyB,CAA3B;AAIA,QAAM4B,oBAAoB,GAAG9B,SAAS,CAAC4B,KAAV,CAAgBG,uBAAhB,CAAwCN,eAAxC,CAA7B;AACA,QAAMO,kBAAkB,GAAGF,oBAAoB,CAACG,MAArB,EAA3B;AAEA3B,EAAAA,IAAI,CAAC4B,uBAAL,GAA+BF,kBAAkB,CAACd,aAAnB,CAAiCN,WAAjC,CAA/B;AACAN,EAAAA,IAAI,CAACqB,kBAAL,GAA0BA,kBAA1B;;AAGA,MAAI,CAACrB,IAAI,CAAC6B,gBAAV,EAA4B;AAC1B7B,IAAAA,IAAI,CAACM,WAAL,GAAmBN,IAAI,CAAC4B,uBAAxB;AACD;AACF","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"],"file":"transform-utils.js"}
|
|
@@ -1,42 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getZoomFromBoundingVolume = void 0;
|
|
4
|
-
const core_1 = require("@math.gl/core");
|
|
1
|
+
import { Vector3 } from '@math.gl/core';
|
|
5
2
|
const WGS84_RADIUS_X = 6378137.0;
|
|
6
3
|
const WGS84_RADIUS_Y = 6378137.0;
|
|
7
4
|
const WGS84_RADIUS_Z = 6356752.3142451793;
|
|
8
|
-
const scratchVector = new
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const zoomY = Math.log2(WGS84_RADIUS_Y / height);
|
|
30
|
-
return (zoomX + zoomY) / 2;
|
|
31
|
-
}
|
|
32
|
-
return 1;
|
|
5
|
+
const scratchVector = new Vector3();
|
|
6
|
+
export function getZoomFromBoundingVolume(boundingVolume) {
|
|
7
|
+
const {
|
|
8
|
+
halfAxes,
|
|
9
|
+
radius,
|
|
10
|
+
width,
|
|
11
|
+
height
|
|
12
|
+
} = boundingVolume;
|
|
13
|
+
|
|
14
|
+
if (halfAxes) {
|
|
15
|
+
const obbSize = getObbSize(halfAxes);
|
|
16
|
+
return Math.log2(WGS84_RADIUS_Z / obbSize);
|
|
17
|
+
} else if (radius) {
|
|
18
|
+
return Math.log2(WGS84_RADIUS_Z / radius);
|
|
19
|
+
} else if (height && width) {
|
|
20
|
+
const zoomX = Math.log2(WGS84_RADIUS_X / width);
|
|
21
|
+
const zoomY = Math.log2(WGS84_RADIUS_Y / height);
|
|
22
|
+
return (zoomX + zoomY) / 2;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return 1;
|
|
33
26
|
}
|
|
34
|
-
|
|
27
|
+
|
|
35
28
|
function getObbSize(halfAxes) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
halfAxes.getColumn(0, scratchVector);
|
|
30
|
+
const axeY = halfAxes.getColumn(1);
|
|
31
|
+
const axeZ = halfAxes.getColumn(2);
|
|
32
|
+
const farthestVertex = scratchVector.add(axeY).add(axeZ);
|
|
33
|
+
const size = farthestVertex.len();
|
|
34
|
+
return size;
|
|
42
35
|
}
|
|
36
|
+
//# sourceMappingURL=zoom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/tileset/helpers/zoom.ts"],"names":["Vector3","WGS84_RADIUS_X","WGS84_RADIUS_Y","WGS84_RADIUS_Z","scratchVector","getZoomFromBoundingVolume","boundingVolume","halfAxes","radius","width","height","obbSize","getObbSize","Math","log2","zoomX","zoomY","getColumn","axeY","axeZ","farthestVertex","add","size","len"],"mappings":"AAAA,SAAQA,OAAR,QAAsB,eAAtB;AAEA,MAAMC,cAAc,GAAG,SAAvB;AACA,MAAMC,cAAc,GAAG,SAAvB;AACA,MAAMC,cAAc,GAAG,kBAAvB;AAEA,MAAMC,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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 {BoundingSphere, OrientedBoundingBox} boundingVolume - the instance of bounding volume\n * @returns {number} - zoom value\n */\nexport function getZoomFromBoundingVolume(boundingVolume) {\n const {halfAxes, radius, width, height} = boundingVolume;\n\n if (halfAxes) {\n // OrientedBoundingBox\n const obbSize = getObbSize(halfAxes);\n // Use WGS84_RADIUS_Z to allign with BoundingSphere algorithm\n return Math.log2(WGS84_RADIUS_Z / obbSize);\n } else if (radius) {\n // BoundingSphere\n return Math.log2(WGS84_RADIUS_Z / radius);\n } else if (height && width) {\n // BoundingRectangle\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\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"],"file":"zoom.js"}
|