@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 +0,0 @@
|
|
|
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,SAAS,GAAGN,MAAM,CAACgB,WAAnB;AACAT,IAAAA,MAAM,GAAGP,MAAM,CAACiB,oBAAP,CAA4BV,MAArC;AACAC,IAAAA,aAAa,GAAGE,kBAAkB,CAACF,aAAnC;AACAC,IAAAA,aAAa,GAAGC,kBAAkB,CAACD,aAAnC;AACD,GAND,MAMO;AA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,CAAb;AACD;AAED,OAAO,SAASE,0BAAT,CAAoCC,OAApC,EAA6CL,gBAA7C,EAA+D;AACpE,MAAIK,OAAO,CAACC,uBAAR,IAAmCD,OAAO,CAACE,sCAA/C,EAAuF;AACrF,UAAMN,OAAO,GAAGI,OAAO,CAACE,sCAAxB;AACA,UAAMC,MAAM,GAAGH,OAAO,CAACI,6BAAvB;AAEA,UAAMC,YAAY,GAAGX,GAAG,CAACC,gBAAD,EAAmBC,OAAnB,CAAH,GAAiCO,MAAtD;AACA,WAAOE,YAAP;AACD;;AAED,SAAO,CAAP;AACD;AAED,OAAO,SAASC,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,58 +0,0 @@
|
|
|
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
|
|
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
|
-
}
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=transform-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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","toFixedFrameMatr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IAAIvB,OAAJ,CAAYS,MAAZ,CAAxB;AAEAL,EAAAA,IAAI,CAACoB,oBAAL,GAA4Bd,WAA5B;AACAN,EAAAA,IAAI,CAACmB,eAAL,GAAuBA,eAAvB;AAGA,QAAME,kBAAkB,GAAG3B,SAAS,CAAC4B,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,36 +0,0 @@
|
|
|
1
|
-
import { Vector3 } from '@math.gl/core';
|
|
2
|
-
const WGS84_RADIUS_X = 6378137.0;
|
|
3
|
-
const WGS84_RADIUS_Y = 6378137.0;
|
|
4
|
-
const WGS84_RADIUS_Z = 6356752.3142451793;
|
|
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;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function getObbSize(halfAxes) {
|
|
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;
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=zoom.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,aAAa,GAAG,IAAIJ,OAAJ,EAAtB;AAOA,OAAO,SAASK,yBAAT,CAAmCC,cAAnC,EAAmD;AACxD,QAAM;AAACC,IAAAA,QAAD;AAAWC,IAAAA,MAAX;AAAmBC,IAAAA,KAAnB;AAA0BC,IAAAA;AAA1B,MAAoCJ,cAA1C;;AAEA,MAAIC,QAAJ,EAAc;AAEZ,UAAMI,OAAO,GAAGC,UAAU,CAACL,QAAD,CAA1B;AAEA,WAAOM,IAAI,CAACC,IAAL,CAAUX,cAAc,GAAGQ,OAA3B,CAAP;AACD,GALD,MAKO,IAAIH,MAAJ,EAAY;AAEjB,WAAOK,IAAI,CAACC,IAAL,CAAUX,cAAc,GAAGK,MAA3B,CAAP;AACD,GAHM,MAGA,IAAIE,MAAM,IAAID,KAAd,EAAqB;AAE1B,UAAMM,KAAK,GAAGF,IAAI,CAACC,IAAL,CAAUb,cAAc,GAAGQ,KAA3B,CAAd;AACA,UAAMO,KAAK,GAAGH,IAAI,CAACC,IAAL,CAAUZ,cAAc,GAAGQ,MAA3B,CAAd;AAEA,WAAO,CAACK,KAAK,GAAGC,KAAT,IAAkB,CAAzB;AACD;;AAED,SAAO,CAAP;AACD;;AAED,SAASJ,UAAT,CAAoBL,QAApB,EAA8B;AAC5BA,EAAAA,QAAQ,CAACU,SAAT,CAAmB,CAAnB,EAAsBb,aAAtB;AACA,QAAMc,IAAI,GAAGX,QAAQ,CAACU,SAAT,CAAmB,CAAnB,CAAb;AACA,QAAME,IAAI,GAAGZ,QAAQ,CAACU,SAAT,CAAmB,CAAnB,CAAb;AACA,QAAMG,cAAc,GAAGhB,aAAa,CAACiB,GAAd,CAAkBH,IAAlB,EAAwBG,GAAxB,CAA4BF,IAA5B,CAAvB;AACA,QAAMG,IAAI,GAAGF,cAAc,CAACG,GAAf,EAAb;AACA,SAAOD,IAAP;AACD","sourcesContent":["import {Vector3} from '@math.gl/core';\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 {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"}
|
|
@@ -1,537 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import { Vector3, Matrix4 } from '@math.gl/core';
|
|
3
|
-
import { CullingVolume } from '@math.gl/culling';
|
|
4
|
-
import { load } from '@loaders.gl/core';
|
|
5
|
-
import { TILE_REFINEMENT, TILE_CONTENT_STATE, TILESET_TYPE } from '../constants';
|
|
6
|
-
import { createBoundingVolume } from './helpers/bounding-volume';
|
|
7
|
-
import { getTiles3DScreenSpaceError } from './helpers/tiles-3d-lod';
|
|
8
|
-
import { getProjectedRadius } from './helpers/i3s-lod';
|
|
9
|
-
import { get3dTilesOptions } from './helpers/3d-tiles-options';
|
|
10
|
-
import TilesetTraverser from './traversers/tileset-traverser';
|
|
11
|
-
const scratchVector = new Vector3();
|
|
12
|
-
|
|
13
|
-
function defined(x) {
|
|
14
|
-
return x !== undefined && x !== null;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export default class TileHeader {
|
|
18
|
-
constructor(tileset, header, parentHeader, extendedId = '') {
|
|
19
|
-
_defineProperty(this, "tileset", void 0);
|
|
20
|
-
|
|
21
|
-
_defineProperty(this, "header", void 0);
|
|
22
|
-
|
|
23
|
-
_defineProperty(this, "id", void 0);
|
|
24
|
-
|
|
25
|
-
_defineProperty(this, "url", void 0);
|
|
26
|
-
|
|
27
|
-
_defineProperty(this, "parent", void 0);
|
|
28
|
-
|
|
29
|
-
_defineProperty(this, "refine", void 0);
|
|
30
|
-
|
|
31
|
-
_defineProperty(this, "type", void 0);
|
|
32
|
-
|
|
33
|
-
_defineProperty(this, "contentUrl", void 0);
|
|
34
|
-
|
|
35
|
-
_defineProperty(this, "lodMetricType", void 0);
|
|
36
|
-
|
|
37
|
-
_defineProperty(this, "lodMetricValue", void 0);
|
|
38
|
-
|
|
39
|
-
_defineProperty(this, "boundingVolume", void 0);
|
|
40
|
-
|
|
41
|
-
_defineProperty(this, "content", void 0);
|
|
42
|
-
|
|
43
|
-
_defineProperty(this, "contentState", void 0);
|
|
44
|
-
|
|
45
|
-
_defineProperty(this, "gpuMemoryUsageInBytes", void 0);
|
|
46
|
-
|
|
47
|
-
_defineProperty(this, "children", void 0);
|
|
48
|
-
|
|
49
|
-
_defineProperty(this, "depth", void 0);
|
|
50
|
-
|
|
51
|
-
_defineProperty(this, "viewportIds", void 0);
|
|
52
|
-
|
|
53
|
-
_defineProperty(this, "transform", void 0);
|
|
54
|
-
|
|
55
|
-
_defineProperty(this, "extensions", void 0);
|
|
56
|
-
|
|
57
|
-
_defineProperty(this, "userData", void 0);
|
|
58
|
-
|
|
59
|
-
_defineProperty(this, "computedTransform", void 0);
|
|
60
|
-
|
|
61
|
-
_defineProperty(this, "hasEmptyContent", void 0);
|
|
62
|
-
|
|
63
|
-
_defineProperty(this, "hasTilesetContent", void 0);
|
|
64
|
-
|
|
65
|
-
_defineProperty(this, "traverser", void 0);
|
|
66
|
-
|
|
67
|
-
_defineProperty(this, "_cacheNode", void 0);
|
|
68
|
-
|
|
69
|
-
_defineProperty(this, "_frameNumber", void 0);
|
|
70
|
-
|
|
71
|
-
_defineProperty(this, "_lodJudge", void 0);
|
|
72
|
-
|
|
73
|
-
_defineProperty(this, "_expireDate", void 0);
|
|
74
|
-
|
|
75
|
-
_defineProperty(this, "_expiredContent", void 0);
|
|
76
|
-
|
|
77
|
-
_defineProperty(this, "_shouldRefine", void 0);
|
|
78
|
-
|
|
79
|
-
_defineProperty(this, "_distanceToCamera", void 0);
|
|
80
|
-
|
|
81
|
-
_defineProperty(this, "_centerZDepth", void 0);
|
|
82
|
-
|
|
83
|
-
_defineProperty(this, "_screenSpaceError", void 0);
|
|
84
|
-
|
|
85
|
-
_defineProperty(this, "_visibilityPlaneMask", void 0);
|
|
86
|
-
|
|
87
|
-
_defineProperty(this, "_visible", void 0);
|
|
88
|
-
|
|
89
|
-
_defineProperty(this, "_inRequestVolume", void 0);
|
|
90
|
-
|
|
91
|
-
_defineProperty(this, "_stackLength", void 0);
|
|
92
|
-
|
|
93
|
-
_defineProperty(this, "_selectionDepth", void 0);
|
|
94
|
-
|
|
95
|
-
_defineProperty(this, "_touchedFrame", void 0);
|
|
96
|
-
|
|
97
|
-
_defineProperty(this, "_visitedFrame", void 0);
|
|
98
|
-
|
|
99
|
-
_defineProperty(this, "_selectedFrame", void 0);
|
|
100
|
-
|
|
101
|
-
_defineProperty(this, "_requestedFrame", void 0);
|
|
102
|
-
|
|
103
|
-
_defineProperty(this, "_priority", void 0);
|
|
104
|
-
|
|
105
|
-
_defineProperty(this, "_contentBoundingVolume", void 0);
|
|
106
|
-
|
|
107
|
-
_defineProperty(this, "_viewerRequestVolume", void 0);
|
|
108
|
-
|
|
109
|
-
_defineProperty(this, "_initialTransform", void 0);
|
|
110
|
-
|
|
111
|
-
this.header = header;
|
|
112
|
-
this.tileset = tileset;
|
|
113
|
-
this.id = extendedId || header.id;
|
|
114
|
-
this.url = header.url;
|
|
115
|
-
this.parent = parentHeader;
|
|
116
|
-
this.refine = this._getRefine(header.refine);
|
|
117
|
-
this.type = header.type;
|
|
118
|
-
this.contentUrl = header.contentUrl;
|
|
119
|
-
this.lodMetricType = 'geometricError';
|
|
120
|
-
this.lodMetricValue = 0;
|
|
121
|
-
this.boundingVolume = null;
|
|
122
|
-
this.content = null;
|
|
123
|
-
this.contentState = TILE_CONTENT_STATE.UNLOADED;
|
|
124
|
-
this.gpuMemoryUsageInBytes = 0;
|
|
125
|
-
this.children = [];
|
|
126
|
-
this.hasEmptyContent = false;
|
|
127
|
-
this.hasTilesetContent = false;
|
|
128
|
-
this.depth = 0;
|
|
129
|
-
this.viewportIds = [];
|
|
130
|
-
this.userData = {};
|
|
131
|
-
this.extensions = null;
|
|
132
|
-
this._priority = 0;
|
|
133
|
-
this._touchedFrame = 0;
|
|
134
|
-
this._visitedFrame = 0;
|
|
135
|
-
this._selectedFrame = 0;
|
|
136
|
-
this._requestedFrame = 0;
|
|
137
|
-
this._screenSpaceError = 0;
|
|
138
|
-
this._cacheNode = null;
|
|
139
|
-
this._frameNumber = null;
|
|
140
|
-
this._cacheNode = null;
|
|
141
|
-
this.traverser = new TilesetTraverser({});
|
|
142
|
-
this._shouldRefine = false;
|
|
143
|
-
this._distanceToCamera = 0;
|
|
144
|
-
this._centerZDepth = 0;
|
|
145
|
-
this._visible = undefined;
|
|
146
|
-
this._inRequestVolume = false;
|
|
147
|
-
this._stackLength = 0;
|
|
148
|
-
this._selectionDepth = 0;
|
|
149
|
-
this._initialTransform = new Matrix4();
|
|
150
|
-
this.transform = new Matrix4();
|
|
151
|
-
|
|
152
|
-
this._initializeLodMetric(header);
|
|
153
|
-
|
|
154
|
-
this._initializeTransforms(header);
|
|
155
|
-
|
|
156
|
-
this._initializeBoundingVolumes(header);
|
|
157
|
-
|
|
158
|
-
this._initializeContent(header);
|
|
159
|
-
|
|
160
|
-
this._initializeRenderingState(header);
|
|
161
|
-
|
|
162
|
-
this._lodJudge = null;
|
|
163
|
-
this._expireDate = null;
|
|
164
|
-
this._expiredContent = null;
|
|
165
|
-
Object.seal(this);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
destroy() {
|
|
169
|
-
this.header = null;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
isDestroyed() {
|
|
173
|
-
return this.header === null;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
get selected() {
|
|
177
|
-
return this._selectedFrame === this.tileset._frameNumber;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
get isVisible() {
|
|
181
|
-
return this._visible;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
get isVisibleAndInRequestVolume() {
|
|
185
|
-
return this._visible && this._inRequestVolume;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
get hasRenderContent() {
|
|
189
|
-
return !this.hasEmptyContent && !this.hasTilesetContent;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
get hasChildren() {
|
|
193
|
-
return this.children.length > 0 || this.header.children && this.header.children.length > 0;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
get contentReady() {
|
|
197
|
-
return this.contentState === TILE_CONTENT_STATE.READY || this.hasEmptyContent;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
get contentAvailable() {
|
|
201
|
-
return Boolean(this.contentReady && this.hasRenderContent || this._expiredContent && !this.contentFailed);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
get hasUnloadedContent() {
|
|
205
|
-
return this.hasRenderContent && this.contentUnloaded;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
get contentUnloaded() {
|
|
209
|
-
return this.contentState === TILE_CONTENT_STATE.UNLOADED;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
get contentExpired() {
|
|
213
|
-
return this.contentState === TILE_CONTENT_STATE.EXPIRED;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
get contentFailed() {
|
|
217
|
-
return this.contentState === TILE_CONTENT_STATE.FAILED;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
getScreenSpaceError(frameState, useParentLodMetric) {
|
|
221
|
-
switch (this.tileset.type) {
|
|
222
|
-
case TILESET_TYPE.I3S:
|
|
223
|
-
return getProjectedRadius(this, frameState);
|
|
224
|
-
|
|
225
|
-
case TILESET_TYPE.TILES3D:
|
|
226
|
-
return getTiles3DScreenSpaceError(this, frameState, useParentLodMetric);
|
|
227
|
-
|
|
228
|
-
default:
|
|
229
|
-
throw new Error('Unsupported tileset type');
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
_getPriority() {
|
|
234
|
-
const traverser = this.tileset._traverser;
|
|
235
|
-
const {
|
|
236
|
-
skipLevelOfDetail
|
|
237
|
-
} = traverser.options;
|
|
238
|
-
const maySkipTile = this.refine === TILE_REFINEMENT.ADD || skipLevelOfDetail;
|
|
239
|
-
|
|
240
|
-
if (maySkipTile && !this.isVisible && this._visible !== undefined) {
|
|
241
|
-
return -1;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
if (this.tileset._frameNumber - this._touchedFrame >= 1) {
|
|
245
|
-
return -1;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
if (this.contentState === TILE_CONTENT_STATE.UNLOADED) {
|
|
249
|
-
return -1;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
const parent = this.parent;
|
|
253
|
-
const useParentScreenSpaceError = parent && (!maySkipTile || this._screenSpaceError === 0.0 || parent.hasTilesetContent);
|
|
254
|
-
const screenSpaceError = useParentScreenSpaceError ? parent._screenSpaceError : this._screenSpaceError;
|
|
255
|
-
const rootScreenSpaceError = traverser.root ? traverser.root._screenSpaceError : 0.0;
|
|
256
|
-
return Math.max(rootScreenSpaceError - screenSpaceError, 0);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
async loadContent() {
|
|
260
|
-
if (this.hasEmptyContent) {
|
|
261
|
-
return false;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if (this.content) {
|
|
265
|
-
return true;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
const expired = this.contentExpired;
|
|
269
|
-
|
|
270
|
-
if (expired) {
|
|
271
|
-
this._expireDate = null;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
this.contentState = TILE_CONTENT_STATE.LOADING;
|
|
275
|
-
const requestToken = await this.tileset._requestScheduler.scheduleRequest(this.id, this._getPriority.bind(this));
|
|
276
|
-
|
|
277
|
-
if (!requestToken) {
|
|
278
|
-
this.contentState = TILE_CONTENT_STATE.UNLOADED;
|
|
279
|
-
return false;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
try {
|
|
283
|
-
const contentUrl = this.tileset.getTileUrl(this.contentUrl);
|
|
284
|
-
const loader = this.tileset.loader;
|
|
285
|
-
const options = { ...this.tileset.loadOptions,
|
|
286
|
-
[loader.id]: { ...this.tileset.loadOptions[loader.id],
|
|
287
|
-
isTileset: this.type === 'json',
|
|
288
|
-
...this._getLoaderSpecificOptions(loader.id)
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
this.content = await load(contentUrl, loader, options);
|
|
292
|
-
|
|
293
|
-
if (this.tileset.options.contentLoader) {
|
|
294
|
-
await this.tileset.options.contentLoader(this);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
if (this._isTileset()) {
|
|
298
|
-
this.tileset._initializeTileHeaders(this.content, this);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
this.contentState = TILE_CONTENT_STATE.READY;
|
|
302
|
-
|
|
303
|
-
this._onContentLoaded();
|
|
304
|
-
|
|
305
|
-
return true;
|
|
306
|
-
} catch (error) {
|
|
307
|
-
this.contentState = TILE_CONTENT_STATE.FAILED;
|
|
308
|
-
throw error;
|
|
309
|
-
} finally {
|
|
310
|
-
requestToken.done();
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
unloadContent() {
|
|
315
|
-
if (this.content && this.content.destroy) {
|
|
316
|
-
this.content.destroy();
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
this.content = null;
|
|
320
|
-
|
|
321
|
-
if (this.header.content && this.header.content.destroy) {
|
|
322
|
-
this.header.content.destroy();
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
this.header.content = null;
|
|
326
|
-
this.contentState = TILE_CONTENT_STATE.UNLOADED;
|
|
327
|
-
return true;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
updateVisibility(frameState, viewportIds) {
|
|
331
|
-
if (this._frameNumber === frameState.frameNumber) {
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
const parent = this.parent;
|
|
336
|
-
const parentVisibilityPlaneMask = parent ? parent._visibilityPlaneMask : CullingVolume.MASK_INDETERMINATE;
|
|
337
|
-
|
|
338
|
-
if (this.tileset._traverser.options.updateTransforms) {
|
|
339
|
-
const parentTransform = parent ? parent.computedTransform : this.tileset.modelMatrix;
|
|
340
|
-
|
|
341
|
-
this._updateTransform(parentTransform);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
this._distanceToCamera = this.distanceToTile(frameState);
|
|
345
|
-
this._screenSpaceError = this.getScreenSpaceError(frameState, false);
|
|
346
|
-
this._visibilityPlaneMask = this.visibility(frameState, parentVisibilityPlaneMask);
|
|
347
|
-
this._visible = this._visibilityPlaneMask !== CullingVolume.MASK_OUTSIDE;
|
|
348
|
-
this._inRequestVolume = this.insideViewerRequestVolume(frameState);
|
|
349
|
-
this._frameNumber = frameState.frameNumber;
|
|
350
|
-
this.viewportIds = viewportIds;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
visibility(frameState, parentVisibilityPlaneMask) {
|
|
354
|
-
const {
|
|
355
|
-
cullingVolume
|
|
356
|
-
} = frameState;
|
|
357
|
-
const {
|
|
358
|
-
boundingVolume
|
|
359
|
-
} = this;
|
|
360
|
-
return cullingVolume.computeVisibilityWithPlaneMask(boundingVolume, parentVisibilityPlaneMask);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
contentVisibility() {
|
|
364
|
-
return true;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
distanceToTile(frameState) {
|
|
368
|
-
const boundingVolume = this.boundingVolume;
|
|
369
|
-
return Math.sqrt(Math.max(boundingVolume.distanceSquaredTo(frameState.camera.position), 0));
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
cameraSpaceZDepth({
|
|
373
|
-
camera
|
|
374
|
-
}) {
|
|
375
|
-
const boundingVolume = this.boundingVolume;
|
|
376
|
-
scratchVector.subVectors(boundingVolume.center, camera.position);
|
|
377
|
-
return camera.direction.dot(scratchVector);
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
insideViewerRequestVolume(frameState) {
|
|
381
|
-
const viewerRequestVolume = this._viewerRequestVolume;
|
|
382
|
-
return !viewerRequestVolume || viewerRequestVolume.distanceSquaredTo(frameState.camera.position) <= 0;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
updateExpiration() {
|
|
386
|
-
if (defined(this._expireDate) && this.contentReady && !this.hasEmptyContent) {
|
|
387
|
-
const now = Date.now();
|
|
388
|
-
|
|
389
|
-
if (Date.lessThan(this._expireDate, now)) {
|
|
390
|
-
this.contentState = TILE_CONTENT_STATE.EXPIRED;
|
|
391
|
-
this._expiredContent = this.content;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
get extras() {
|
|
397
|
-
return this.header.extras;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
_initializeLodMetric(header) {
|
|
401
|
-
if ('lodMetricType' in header) {
|
|
402
|
-
this.lodMetricType = header.lodMetricType;
|
|
403
|
-
} else {
|
|
404
|
-
this.lodMetricType = this.parent && this.parent.lodMetricType || this.tileset.lodMetricType;
|
|
405
|
-
console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType");
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
if ('lodMetricValue' in header) {
|
|
409
|
-
this.lodMetricValue = header.lodMetricValue;
|
|
410
|
-
} else {
|
|
411
|
-
this.lodMetricValue = this.parent && this.parent.lodMetricValue || this.tileset.lodMetricValue;
|
|
412
|
-
console.warn('3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue');
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
_initializeTransforms(tileHeader) {
|
|
417
|
-
this.transform = tileHeader.transform ? new Matrix4(tileHeader.transform) : new Matrix4();
|
|
418
|
-
const parent = this.parent;
|
|
419
|
-
const tileset = this.tileset;
|
|
420
|
-
const parentTransform = parent && parent.computedTransform ? parent.computedTransform.clone() : tileset.modelMatrix.clone();
|
|
421
|
-
this.computedTransform = new Matrix4(parentTransform).multiplyRight(this.transform);
|
|
422
|
-
const parentInitialTransform = parent && parent._initialTransform ? parent._initialTransform.clone() : new Matrix4();
|
|
423
|
-
this._initialTransform = new Matrix4(parentInitialTransform).multiplyRight(this.transform);
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
_initializeBoundingVolumes(tileHeader) {
|
|
427
|
-
this._contentBoundingVolume = null;
|
|
428
|
-
this._viewerRequestVolume = null;
|
|
429
|
-
|
|
430
|
-
this._updateBoundingVolume(tileHeader);
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
_initializeContent(tileHeader) {
|
|
434
|
-
this.content = {
|
|
435
|
-
_tileset: this.tileset,
|
|
436
|
-
_tile: this
|
|
437
|
-
};
|
|
438
|
-
this.hasEmptyContent = true;
|
|
439
|
-
this.contentState = TILE_CONTENT_STATE.UNLOADED;
|
|
440
|
-
this.hasTilesetContent = false;
|
|
441
|
-
|
|
442
|
-
if (tileHeader.contentUrl) {
|
|
443
|
-
this.content = null;
|
|
444
|
-
this.hasEmptyContent = false;
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
_initializeRenderingState(header) {
|
|
449
|
-
this.depth = header.level || (this.parent ? this.parent.depth + 1 : 0);
|
|
450
|
-
this._shouldRefine = false;
|
|
451
|
-
this._distanceToCamera = 0;
|
|
452
|
-
this._centerZDepth = 0;
|
|
453
|
-
this._screenSpaceError = 0;
|
|
454
|
-
this._visibilityPlaneMask = CullingVolume.MASK_INDETERMINATE;
|
|
455
|
-
this._visible = undefined;
|
|
456
|
-
this._inRequestVolume = false;
|
|
457
|
-
this._stackLength = 0;
|
|
458
|
-
this._selectionDepth = 0;
|
|
459
|
-
this._frameNumber = 0;
|
|
460
|
-
this._touchedFrame = 0;
|
|
461
|
-
this._visitedFrame = 0;
|
|
462
|
-
this._selectedFrame = 0;
|
|
463
|
-
this._requestedFrame = 0;
|
|
464
|
-
this._priority = 0.0;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
_getRefine(refine) {
|
|
468
|
-
return refine || this.parent && this.parent.refine || TILE_REFINEMENT.REPLACE;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
_isTileset() {
|
|
472
|
-
return this.contentUrl.indexOf('.json') !== -1;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
_onContentLoaded() {
|
|
476
|
-
switch (this.content && this.content.type) {
|
|
477
|
-
case 'vctr':
|
|
478
|
-
case 'geom':
|
|
479
|
-
this.tileset._traverser.disableSkipLevelOfDetail = true;
|
|
480
|
-
break;
|
|
481
|
-
|
|
482
|
-
default:
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
if (this._isTileset()) {
|
|
486
|
-
this.hasTilesetContent = true;
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
_updateBoundingVolume(header) {
|
|
491
|
-
this.boundingVolume = createBoundingVolume(header.boundingVolume, this.computedTransform, this.boundingVolume);
|
|
492
|
-
const content = header.content;
|
|
493
|
-
|
|
494
|
-
if (!content) {
|
|
495
|
-
return;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
if (content.boundingVolume) {
|
|
499
|
-
this._contentBoundingVolume = createBoundingVolume(content.boundingVolume, this.computedTransform, this._contentBoundingVolume);
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
if (header.viewerRequestVolume) {
|
|
503
|
-
this._viewerRequestVolume = createBoundingVolume(header.viewerRequestVolume, this.computedTransform, this._viewerRequestVolume);
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
_updateTransform(parentTransform = new Matrix4()) {
|
|
508
|
-
const computedTransform = parentTransform.clone().multiplyRight(this.transform);
|
|
509
|
-
const didTransformChange = !computedTransform.equals(this.computedTransform);
|
|
510
|
-
|
|
511
|
-
if (!didTransformChange) {
|
|
512
|
-
return;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
this.computedTransform = computedTransform;
|
|
516
|
-
|
|
517
|
-
this._updateBoundingVolume(this.header);
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
_getLoaderSpecificOptions(loaderId) {
|
|
521
|
-
switch (loaderId) {
|
|
522
|
-
case 'i3s':
|
|
523
|
-
return { ...this.tileset.options.i3s,
|
|
524
|
-
tile: this.header,
|
|
525
|
-
tileset: this.tileset.tileset,
|
|
526
|
-
isTileHeader: false
|
|
527
|
-
};
|
|
528
|
-
|
|
529
|
-
case '3d-tiles':
|
|
530
|
-
case 'cesium-ion':
|
|
531
|
-
default:
|
|
532
|
-
return get3dTilesOptions(this.tileset.tileset);
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
}
|
|
537
|
-
//# sourceMappingURL=tile-3d.js.map
|