@cesium/engine 20.0.2-ion.0 → 21.0.1-ion.0
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/Build/ThirdParty/Workers/zip-web-worker.js +637 -0
- package/Build/Workers/{chunk-AFKNTEMH.js → chunk-26ZRRKTU.js} +16 -16
- package/Build/Workers/{chunk-NKKNQMEH.js → chunk-2PX2ULSM.js} +3 -3
- package/Build/Workers/{chunk-OIMV4OE5.js → chunk-3K4DRV7Y.js} +9 -9
- package/Build/Workers/{chunk-IS5FETN7.js → chunk-3XTJC4CV.js} +5 -5
- package/Build/Workers/{chunk-Z2W7ZIGV.js → chunk-6KX3IUUT.js} +2 -2
- package/Build/Workers/{chunk-BHAATGZA.js → chunk-75UG66GR.js} +5 -5
- package/Build/Workers/{chunk-YXTWHLJA.js → chunk-ADADBRLI.js} +4 -4
- package/Build/Workers/{chunk-CUU3WGXJ.js → chunk-AGT6W3JS.js} +6 -6
- package/Build/Workers/{chunk-QID3DXQA.js → chunk-AQ4A5CMC.js} +7 -7
- package/Build/Workers/{chunk-MTBXKKSQ.js → chunk-B56XVJRS.js} +12 -12
- package/Build/Workers/{chunk-VODCZKV2.js → chunk-DTYIUWZU.js} +4 -4
- package/Build/Workers/{chunk-VSMKMGX4.js → chunk-E6T4LSM6.js} +5 -5
- package/Build/Workers/{chunk-WZKTQZUW.js → chunk-EEDSGIH7.js} +6 -6
- package/Build/Workers/{chunk-FNUSHLOY.js → chunk-EHMAKCWQ.js} +1 -1
- package/Build/Workers/{chunk-CYC7JX3P.js → chunk-ESPNIYL5.js} +8 -8
- package/Build/Workers/{chunk-LS63ERFB.js → chunk-EZJXK2UP.js} +4 -4
- package/Build/Workers/{chunk-Q3OWKSC5.js → chunk-G5RX7BPJ.js} +10 -10
- package/Build/Workers/{chunk-FAQ2XNFV.js → chunk-G74UMFQ4.js} +5 -5
- package/Build/Workers/{chunk-YUHWFX5H.js → chunk-H3G7OYZY.js} +2 -2
- package/Build/Workers/{chunk-6LULWCX3.js → chunk-HDBIC7IL.js} +1 -1
- package/Build/Workers/{chunk-WORBFT5H.js → chunk-JESBYOH5.js} +9 -9
- package/Build/Workers/{chunk-P2V7PVDH.js → chunk-KGL66RWW.js} +8 -8
- package/Build/Workers/{chunk-USK6ZAY2.js → chunk-L73TRTIG.js} +1 -1
- package/Build/Workers/{chunk-VA7LWA5Q.js → chunk-LEFV6H2V.js} +9 -9
- package/Build/Workers/{chunk-23B3EYUM.js → chunk-LK7H6V2E.js} +4 -4
- package/Build/Workers/{chunk-JVG6T2WE.js → chunk-LSNF6CIP.js} +12 -12
- package/Build/Workers/{chunk-ABTG74AR.js → chunk-MBIUW42A.js} +1 -1
- package/Build/Workers/{chunk-VZNF2GT7.js → chunk-MFPT34BC.js} +4 -4
- package/Build/Workers/{chunk-X6GXYB3M.js → chunk-MIFUV36K.js} +1 -1
- package/Build/Workers/{chunk-K6THSIDU.js → chunk-MJWRSKJV.js} +2 -2
- package/Build/Workers/{chunk-FYYP46TF.js → chunk-NWJRIJQG.js} +2 -2
- package/Build/Workers/{chunk-H5IQLAJP.js → chunk-OLH67Z2S.js} +82 -54
- package/Build/Workers/{chunk-FHLPYFIW.js → chunk-OWCFUM4Z.js} +13 -13
- package/Build/Workers/{chunk-66MGJQFZ.js → chunk-PQW63B2T.js} +2 -2
- package/Build/Workers/{chunk-UR36KLNW.js → chunk-RFZAUDYZ.js} +4 -4
- package/Build/Workers/{chunk-XWRUYDF6.js → chunk-SDFGZML6.js} +2 -2
- package/Build/Workers/{chunk-AHFTST3Q.js → chunk-SF2XXYOB.js} +12 -12
- package/Build/Workers/{chunk-QZGZIAK2.js → chunk-SGEAS4NZ.js} +6 -6
- package/Build/Workers/{chunk-MFXTB5I4.js → chunk-T7WXNKIA.js} +11 -11
- package/Build/Workers/{chunk-H7HFDM3G.js → chunk-TXK2FF6N.js} +5 -5
- package/Build/Workers/{chunk-D4XRQNUO.js → chunk-UTL4WVC3.js} +5 -5
- package/Build/Workers/{chunk-V6ZGOX4I.js → chunk-UTTKH2UG.js} +7 -7
- package/Build/Workers/{chunk-X55ZOYMS.js → chunk-VIDWZGD6.js} +12 -12
- package/Build/Workers/{chunk-TZDR2BAP.js → chunk-WIPOMPA5.js} +6 -6
- package/Build/Workers/{chunk-CEA3L7M7.js → chunk-WJV24LAS.js} +4 -4
- package/Build/Workers/{chunk-F4PS6RFF.js → chunk-WMG6UOCJ.js} +10 -10
- package/Build/Workers/{chunk-XIDMFHR4.js → chunk-XFS2ORSO.js} +14 -14
- package/Build/Workers/{chunk-VLGVUVJY.js → chunk-XPTKQIVN.js} +6 -6
- package/Build/Workers/{chunk-D5X2LOJ2.js → chunk-XYBFMHXA.js} +7 -7
- package/Build/Workers/{chunk-YNPZU55A.js → chunk-YFZMB6FZ.js} +6 -6
- package/Build/Workers/{chunk-YSDOO7AG.js → chunk-ZOVMWDPW.js} +5 -5
- package/Build/Workers/{chunk-5DF5RVIO.js → chunk-ZTGZMKAB.js} +16 -16
- package/Build/Workers/combineGeometry.js +21 -21
- package/Build/Workers/createBoxGeometry.js +15 -15
- package/Build/Workers/createBoxOutlineGeometry.js +13 -13
- package/Build/Workers/createCircleGeometry.js +23 -23
- package/Build/Workers/createCircleOutlineGeometry.js +16 -16
- package/Build/Workers/createCoplanarPolygonGeometry.js +30 -30
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +28 -28
- package/Build/Workers/createCorridorGeometry.js +26 -26
- package/Build/Workers/createCorridorOutlineGeometry.js +25 -25
- package/Build/Workers/createCylinderGeometry.js +17 -17
- package/Build/Workers/createCylinderOutlineGeometry.js +15 -15
- package/Build/Workers/createEllipseGeometry.js +23 -23
- package/Build/Workers/createEllipseOutlineGeometry.js +16 -16
- package/Build/Workers/createEllipsoidGeometry.js +16 -16
- package/Build/Workers/createEllipsoidOutlineGeometry.js +15 -15
- package/Build/Workers/createFrustumGeometry.js +15 -15
- package/Build/Workers/createFrustumOutlineGeometry.js +15 -15
- package/Build/Workers/createGeometry.js +21 -21
- package/Build/Workers/createGroundPolylineGeometry.js +19 -19
- package/Build/Workers/createPlaneGeometry.js +13 -13
- package/Build/Workers/createPlaneOutlineGeometry.js +12 -12
- package/Build/Workers/createPolygonGeometry.js +29 -29
- package/Build/Workers/createPolygonOutlineGeometry.js +27 -27
- package/Build/Workers/createPolylineGeometry.js +22 -22
- package/Build/Workers/createPolylineVolumeGeometry.js +28 -28
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +24 -24
- package/Build/Workers/createRectangleGeometry.js +24 -24
- package/Build/Workers/createRectangleOutlineGeometry.js +17 -17
- package/Build/Workers/createSimplePolylineGeometry.js +20 -20
- package/Build/Workers/createSphereGeometry.js +16 -16
- package/Build/Workers/createSphereOutlineGeometry.js +15 -15
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +12 -12
- package/Build/Workers/createVectorTileGeometries.js +21 -21
- package/Build/Workers/createVectorTilePoints.js +11 -11
- package/Build/Workers/createVectorTilePolygons.js +19 -19
- package/Build/Workers/createVectorTilePolylines.js +12 -12
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +19 -19
- package/Build/Workers/createVerticesFromHeightmap.js +19 -19
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +16 -16
- package/Build/Workers/createWallGeometry.js +21 -21
- package/Build/Workers/createWallOutlineGeometry.js +20 -20
- package/Build/Workers/decodeDraco.js +10 -10
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +9 -9
- package/Build/Workers/gaussianSplatSorter.js +4 -4
- package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
- package/Build/Workers/transcodeKTX2.js +6 -6
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +19 -19
- package/Source/Core/Event.js +94 -53
- package/Source/Core/GoogleMaps.js +2 -2
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/IonResource.js +30 -4
- package/Source/Core/Resource.js +5 -1
- package/Source/DataSources/KmlDataSource.js +62 -63
- package/Source/DataSources/exportKml.js +27 -30
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Azure2DImageryProvider.js +308 -0
- package/Source/Scene/Billboard.js +4 -0
- package/Source/Scene/BillboardCollection.js +9 -2
- package/Source/Scene/ClippingPlaneCollection.js +3 -3
- package/Source/Scene/ClippingPolygon.js +91 -2
- package/Source/Scene/CreditDisplay.js +1 -1
- package/Source/Scene/GaussianSplat3DTileContent.js +54 -9
- package/Source/Scene/GaussianSplatPrimitive.js +49 -50
- package/Source/Scene/Google2DImageryProvider.js +614 -0
- package/Source/Scene/IonImageryProvider.js +22 -1
- package/Source/Scene/LabelCollection.js +1 -0
- package/Source/Scene/Material.js +248 -80
- package/Source/Scene/Primitive.js +6 -0
- package/Source/Scene/PrimitiveState.js +123 -0
- package/Source/Scene/Scene.js +2 -2
- package/Source/Scene/VoxelBoundsCollection.js +494 -0
- package/Source/Scene/VoxelBoxShape.js +236 -101
- package/Source/Scene/VoxelCylinderShape.js +315 -204
- package/Source/Scene/VoxelEllipsoidShape.js +402 -119
- package/Source/Scene/VoxelPrimitive.js +119 -84
- package/Source/Scene/VoxelRenderResources.js +17 -10
- package/Source/Scene/VoxelShape.js +21 -6
- package/Source/Scene/buildVoxelDrawCommands.js +61 -20
- package/Source/Scene/createGooglePhotorealistic3DTileset.js +1 -1
- package/Source/Scene/getClippingFunction.js +79 -88
- package/Source/Shaders/BillboardCollectionVS.glsl +2 -0
- package/Source/Shaders/BillboardCollectionVS.js +2 -0
- package/Source/Shaders/Voxels/IntersectBox.glsl +20 -33
- package/Source/Shaders/Voxels/IntersectBox.js +20 -33
- package/Source/Shaders/Voxels/IntersectCylinder.glsl +28 -32
- package/Source/Shaders/Voxels/IntersectCylinder.js +28 -32
- package/Source/Shaders/Voxels/IntersectDepth.glsl +1 -4
- package/Source/Shaders/Voxels/IntersectDepth.js +1 -4
- package/Source/Shaders/Voxels/IntersectEllipsoid.glsl +12 -20
- package/Source/Shaders/Voxels/IntersectEllipsoid.js +12 -20
- package/Source/Shaders/Voxels/IntersectLongitude.glsl +21 -9
- package/Source/Shaders/Voxels/IntersectLongitude.js +21 -9
- package/Source/Shaders/Voxels/{IntersectClippingPlanes.glsl → IntersectPlane.glsl} +5 -3
- package/Source/Shaders/Voxels/{IntersectClippingPlanes.js → IntersectPlane.js} +5 -3
- package/Source/Shaders/Voxels/Intersection.glsl +3 -3
- package/Source/Shaders/Voxels/Intersection.js +3 -3
- package/Source/Shaders/Voxels/Octree.glsl +46 -51
- package/Source/Shaders/Voxels/Octree.js +46 -51
- package/Source/Shaders/Voxels/VoxelFS.glsl +50 -48
- package/Source/Shaders/Voxels/VoxelFS.js +50 -48
- package/Source/Shaders/Voxels/VoxelUtils.glsl +0 -19
- package/Source/Shaders/Voxels/VoxelUtils.js +0 -19
- package/Source/Shaders/Voxels/convertLocalToBoxUv.glsl +30 -0
- package/Source/Shaders/Voxels/convertLocalToBoxUv.js +32 -0
- package/Source/Shaders/Voxels/convertLocalToCylinderUv.glsl +97 -0
- package/Source/Shaders/Voxels/convertLocalToCylinderUv.js +99 -0
- package/Source/Shaders/Voxels/convertLocalToEllipsoidUv.glsl +193 -0
- package/Source/Shaders/Voxels/convertLocalToEllipsoidUv.js +195 -0
- package/Source/ThirdParty/Workers/zip-web-worker.js +1 -0
- package/Source/ThirdParty/zip-module.wasm +0 -0
- package/index.d.ts +317 -14
- package/index.js +177 -175
- package/package.json +2 -2
- package/Build/ThirdParty/Workers/pako_deflate.min.js +0 -503
- package/Build/ThirdParty/Workers/pako_inflate.min.js +0 -698
- package/Build/ThirdParty/Workers/z-worker-pako.js +0 -601
- package/Source/Core/defaultValue.js +0 -48
- package/Source/Shaders/Voxels/convertUvToBox.glsl +0 -45
- package/Source/Shaders/Voxels/convertUvToBox.js +0 -46
- package/Source/Shaders/Voxels/convertUvToCylinder.glsl +0 -99
- package/Source/Shaders/Voxels/convertUvToCylinder.js +0 -101
- package/Source/Shaders/Voxels/convertUvToEllipsoid.glsl +0 -139
- package/Source/Shaders/Voxels/convertUvToEllipsoid.js +0 -141
- package/Source/ThirdParty/Workers/pako_deflate.min.js +0 -2
- package/Source/ThirdParty/Workers/pako_inflate.min.js +0 -2
- package/Source/ThirdParty/Workers/z-worker-pako.js +0 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
uniform vec2 u_cylinderLocalToShapeUvRadius; // x = scale, y = offset
|
|
2
|
+
uniform vec2 u_cylinderLocalToShapeUvHeight; // x = scale, y = offset
|
|
3
|
+
uniform vec2 u_cylinderLocalToShapeUvAngle; // x = scale, y = offset
|
|
4
|
+
uniform float u_cylinderShapeUvAngleRangeOrigin;
|
|
5
|
+
uniform mat3 u_cylinderEcToRadialTangentUp;
|
|
6
|
+
uniform ivec4 u_cameraTileCoordinates;
|
|
7
|
+
uniform vec3 u_cameraTileUv;
|
|
8
|
+
uniform vec3 u_cameraShapePosition; // (radial distance, angle, height) of camera in shape space
|
|
9
|
+
|
|
10
|
+
mat3 convertLocalToShapeSpaceDerivative(in vec3 position) {
|
|
11
|
+
vec3 radial = normalize(vec3(position.xy, 0.0));
|
|
12
|
+
vec3 z = vec3(0.0, 0.0, 1.0);
|
|
13
|
+
vec3 east = normalize(vec3(-position.y, position.x, 0.0));
|
|
14
|
+
return mat3(radial, east / length(position.xy), z);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
vec3 scaleShapeUvToShapeSpace(in vec3 shapeUv) {
|
|
18
|
+
float radius = shapeUv.x / u_cylinderLocalToShapeUvRadius.x;
|
|
19
|
+
float angle = shapeUv.y * czm_twoPi / u_cylinderLocalToShapeUvAngle.x;
|
|
20
|
+
float height = shapeUv.z / u_cylinderLocalToShapeUvHeight.x;
|
|
21
|
+
|
|
22
|
+
return vec3(radius, angle, height);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Computes the change in polar coordinates given a change in position.
|
|
27
|
+
* @param {vec2} dPosition The change in position in Cartesian coordinates.
|
|
28
|
+
* @param {float} cameraRadialDistance The radial distance of the camera from the origin.
|
|
29
|
+
* @return {vec2} The change in polar coordinates (radial distance, angle).
|
|
30
|
+
*/
|
|
31
|
+
vec2 computePolarChange(in vec2 dPosition, in float cameraRadialDistance) {
|
|
32
|
+
float dAngle = atan(dPosition.y, cameraRadialDistance + dPosition.x);
|
|
33
|
+
// Find the direction of the radial axis at the output angle, in Cartesian coordinates
|
|
34
|
+
vec2 outputRadialAxis = vec2(cos(dAngle), sin(dAngle));
|
|
35
|
+
float sinHalfAngle = sin(dAngle / 2.0);
|
|
36
|
+
float versine = 2.0 * sinHalfAngle * sinHalfAngle;
|
|
37
|
+
float dRadial = dot(dPosition, outputRadialAxis) - cameraRadialDistance * versine;
|
|
38
|
+
return vec2(dRadial, dAngle);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
vec3 convertEcToDeltaShape(in vec3 positionEC) {
|
|
42
|
+
// 1. Rotate to radial, tangent, and up coordinates
|
|
43
|
+
vec3 rtu = u_cylinderEcToRadialTangentUp * positionEC;
|
|
44
|
+
// 2. Compute change in angular and radial coordinates.
|
|
45
|
+
vec2 dPolar = computePolarChange(rtu.xy, u_cameraShapePosition.x);
|
|
46
|
+
return vec3(dPolar.xy, rtu.z);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
vec3 convertEcToDeltaTile(in vec3 positionEC) {
|
|
50
|
+
vec3 deltaShape = convertEcToDeltaShape(positionEC);
|
|
51
|
+
// Convert to tileset coordinates in [0, 1]
|
|
52
|
+
float dx = u_cylinderLocalToShapeUvRadius.x * deltaShape.x;
|
|
53
|
+
float dy = deltaShape.y / czm_twoPi;
|
|
54
|
+
#if defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE)
|
|
55
|
+
// Wrap to ensure dy is not crossing through the unoccupied angle range, where
|
|
56
|
+
// angle to tile coordinate conversions would be more complicated
|
|
57
|
+
float cameraUvAngle = (u_cameraShapePosition.y + czm_pi) / czm_twoPi;
|
|
58
|
+
float cameraUvAngleShift = fract(cameraUvAngle - u_cylinderShapeUvAngleRangeOrigin);
|
|
59
|
+
float rawOutputUvAngle = cameraUvAngleShift + dy;
|
|
60
|
+
float rotation = floor(rawOutputUvAngle);
|
|
61
|
+
dy -= rotation;
|
|
62
|
+
#endif
|
|
63
|
+
dy *= u_cylinderLocalToShapeUvAngle.x;
|
|
64
|
+
float dz = u_cylinderLocalToShapeUvHeight.x * deltaShape.z;
|
|
65
|
+
// Convert to tile coordinate changes
|
|
66
|
+
return vec3(dx, dy, dz) * float(1 << u_cameraTileCoordinates.w);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
TileAndUvCoordinate getTileAndUvCoordinate(in vec3 positionEC) {
|
|
70
|
+
vec3 deltaTileCoordinate = convertEcToDeltaTile(positionEC);
|
|
71
|
+
vec3 tileUvSum = u_cameraTileUv + deltaTileCoordinate;
|
|
72
|
+
ivec3 tileCoordinate = u_cameraTileCoordinates.xyz + ivec3(floor(tileUvSum));
|
|
73
|
+
int maxTileCoordinate = (1 << u_cameraTileCoordinates.w) - 1;
|
|
74
|
+
tileCoordinate.x = min(max(0, tileCoordinate.x), maxTileCoordinate);
|
|
75
|
+
tileCoordinate.z = min(max(0, tileCoordinate.z), maxTileCoordinate);
|
|
76
|
+
#if (!defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE))
|
|
77
|
+
ivec3 tileCoordinateChange = tileCoordinate - u_cameraTileCoordinates.xyz;
|
|
78
|
+
if (tileCoordinate.y < 0) {
|
|
79
|
+
tileCoordinate.y += (maxTileCoordinate + 1);
|
|
80
|
+
} else if (tileCoordinate.y > maxTileCoordinate) {
|
|
81
|
+
tileCoordinate.y -= (maxTileCoordinate + 1);
|
|
82
|
+
}
|
|
83
|
+
#else
|
|
84
|
+
tileCoordinate.y = min(max(0, tileCoordinate.y), maxTileCoordinate);
|
|
85
|
+
ivec3 tileCoordinateChange = tileCoordinate - u_cameraTileCoordinates.xyz;
|
|
86
|
+
#endif
|
|
87
|
+
vec3 tileUv = tileUvSum - vec3(tileCoordinateChange);
|
|
88
|
+
tileUv.x = clamp(tileUv.x, 0.0, 1.0);
|
|
89
|
+
#if (!defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE))
|
|
90
|
+
// If there is only one tile spanning 2*PI angle, the coordinate wraps around
|
|
91
|
+
tileUv.y = (u_cameraTileCoordinates.w == 0) ? fract(tileUv.y) : clamp(tileUv.y, 0.0, 1.0);
|
|
92
|
+
#else
|
|
93
|
+
tileUv.y = clamp(tileUv.y, 0.0, 1.0);
|
|
94
|
+
#endif
|
|
95
|
+
tileUv.z = clamp(tileUv.z, 0.0, 1.0);
|
|
96
|
+
return TileAndUvCoordinate(ivec4(tileCoordinate, u_cameraTileCoordinates.w), tileUv);
|
|
97
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "uniform vec2 u_cylinderLocalToShapeUvRadius; // x = scale, y = offset\n\
|
|
3
|
+
uniform vec2 u_cylinderLocalToShapeUvHeight; // x = scale, y = offset\n\
|
|
4
|
+
uniform vec2 u_cylinderLocalToShapeUvAngle; // x = scale, y = offset\n\
|
|
5
|
+
uniform float u_cylinderShapeUvAngleRangeOrigin;\n\
|
|
6
|
+
uniform mat3 u_cylinderEcToRadialTangentUp;\n\
|
|
7
|
+
uniform ivec4 u_cameraTileCoordinates;\n\
|
|
8
|
+
uniform vec3 u_cameraTileUv;\n\
|
|
9
|
+
uniform vec3 u_cameraShapePosition; // (radial distance, angle, height) of camera in shape space\n\
|
|
10
|
+
\n\
|
|
11
|
+
mat3 convertLocalToShapeSpaceDerivative(in vec3 position) {\n\
|
|
12
|
+
vec3 radial = normalize(vec3(position.xy, 0.0));\n\
|
|
13
|
+
vec3 z = vec3(0.0, 0.0, 1.0);\n\
|
|
14
|
+
vec3 east = normalize(vec3(-position.y, position.x, 0.0));\n\
|
|
15
|
+
return mat3(radial, east / length(position.xy), z);\n\
|
|
16
|
+
}\n\
|
|
17
|
+
\n\
|
|
18
|
+
vec3 scaleShapeUvToShapeSpace(in vec3 shapeUv) {\n\
|
|
19
|
+
float radius = shapeUv.x / u_cylinderLocalToShapeUvRadius.x;\n\
|
|
20
|
+
float angle = shapeUv.y * czm_twoPi / u_cylinderLocalToShapeUvAngle.x;\n\
|
|
21
|
+
float height = shapeUv.z / u_cylinderLocalToShapeUvHeight.x;\n\
|
|
22
|
+
\n\
|
|
23
|
+
return vec3(radius, angle, height);\n\
|
|
24
|
+
}\n\
|
|
25
|
+
\n\
|
|
26
|
+
/**\n\
|
|
27
|
+
* Computes the change in polar coordinates given a change in position.\n\
|
|
28
|
+
* @param {vec2} dPosition The change in position in Cartesian coordinates.\n\
|
|
29
|
+
* @param {float} cameraRadialDistance The radial distance of the camera from the origin.\n\
|
|
30
|
+
* @return {vec2} The change in polar coordinates (radial distance, angle).\n\
|
|
31
|
+
*/\n\
|
|
32
|
+
vec2 computePolarChange(in vec2 dPosition, in float cameraRadialDistance) {\n\
|
|
33
|
+
float dAngle = atan(dPosition.y, cameraRadialDistance + dPosition.x);\n\
|
|
34
|
+
// Find the direction of the radial axis at the output angle, in Cartesian coordinates\n\
|
|
35
|
+
vec2 outputRadialAxis = vec2(cos(dAngle), sin(dAngle));\n\
|
|
36
|
+
float sinHalfAngle = sin(dAngle / 2.0);\n\
|
|
37
|
+
float versine = 2.0 * sinHalfAngle * sinHalfAngle;\n\
|
|
38
|
+
float dRadial = dot(dPosition, outputRadialAxis) - cameraRadialDistance * versine;\n\
|
|
39
|
+
return vec2(dRadial, dAngle);\n\
|
|
40
|
+
}\n\
|
|
41
|
+
\n\
|
|
42
|
+
vec3 convertEcToDeltaShape(in vec3 positionEC) {\n\
|
|
43
|
+
// 1. Rotate to radial, tangent, and up coordinates\n\
|
|
44
|
+
vec3 rtu = u_cylinderEcToRadialTangentUp * positionEC;\n\
|
|
45
|
+
// 2. Compute change in angular and radial coordinates.\n\
|
|
46
|
+
vec2 dPolar = computePolarChange(rtu.xy, u_cameraShapePosition.x);\n\
|
|
47
|
+
return vec3(dPolar.xy, rtu.z);\n\
|
|
48
|
+
}\n\
|
|
49
|
+
\n\
|
|
50
|
+
vec3 convertEcToDeltaTile(in vec3 positionEC) {\n\
|
|
51
|
+
vec3 deltaShape = convertEcToDeltaShape(positionEC);\n\
|
|
52
|
+
// Convert to tileset coordinates in [0, 1]\n\
|
|
53
|
+
float dx = u_cylinderLocalToShapeUvRadius.x * deltaShape.x;\n\
|
|
54
|
+
float dy = deltaShape.y / czm_twoPi;\n\
|
|
55
|
+
#if defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE)\n\
|
|
56
|
+
// Wrap to ensure dy is not crossing through the unoccupied angle range, where\n\
|
|
57
|
+
// angle to tile coordinate conversions would be more complicated\n\
|
|
58
|
+
float cameraUvAngle = (u_cameraShapePosition.y + czm_pi) / czm_twoPi;\n\
|
|
59
|
+
float cameraUvAngleShift = fract(cameraUvAngle - u_cylinderShapeUvAngleRangeOrigin);\n\
|
|
60
|
+
float rawOutputUvAngle = cameraUvAngleShift + dy;\n\
|
|
61
|
+
float rotation = floor(rawOutputUvAngle);\n\
|
|
62
|
+
dy -= rotation;\n\
|
|
63
|
+
#endif\n\
|
|
64
|
+
dy *= u_cylinderLocalToShapeUvAngle.x;\n\
|
|
65
|
+
float dz = u_cylinderLocalToShapeUvHeight.x * deltaShape.z;\n\
|
|
66
|
+
// Convert to tile coordinate changes\n\
|
|
67
|
+
return vec3(dx, dy, dz) * float(1 << u_cameraTileCoordinates.w);\n\
|
|
68
|
+
}\n\
|
|
69
|
+
\n\
|
|
70
|
+
TileAndUvCoordinate getTileAndUvCoordinate(in vec3 positionEC) {\n\
|
|
71
|
+
vec3 deltaTileCoordinate = convertEcToDeltaTile(positionEC);\n\
|
|
72
|
+
vec3 tileUvSum = u_cameraTileUv + deltaTileCoordinate;\n\
|
|
73
|
+
ivec3 tileCoordinate = u_cameraTileCoordinates.xyz + ivec3(floor(tileUvSum));\n\
|
|
74
|
+
int maxTileCoordinate = (1 << u_cameraTileCoordinates.w) - 1;\n\
|
|
75
|
+
tileCoordinate.x = min(max(0, tileCoordinate.x), maxTileCoordinate);\n\
|
|
76
|
+
tileCoordinate.z = min(max(0, tileCoordinate.z), maxTileCoordinate);\n\
|
|
77
|
+
#if (!defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE))\n\
|
|
78
|
+
ivec3 tileCoordinateChange = tileCoordinate - u_cameraTileCoordinates.xyz;\n\
|
|
79
|
+
if (tileCoordinate.y < 0) {\n\
|
|
80
|
+
tileCoordinate.y += (maxTileCoordinate + 1);\n\
|
|
81
|
+
} else if (tileCoordinate.y > maxTileCoordinate) {\n\
|
|
82
|
+
tileCoordinate.y -= (maxTileCoordinate + 1);\n\
|
|
83
|
+
}\n\
|
|
84
|
+
#else\n\
|
|
85
|
+
tileCoordinate.y = min(max(0, tileCoordinate.y), maxTileCoordinate);\n\
|
|
86
|
+
ivec3 tileCoordinateChange = tileCoordinate - u_cameraTileCoordinates.xyz;\n\
|
|
87
|
+
#endif\n\
|
|
88
|
+
vec3 tileUv = tileUvSum - vec3(tileCoordinateChange);\n\
|
|
89
|
+
tileUv.x = clamp(tileUv.x, 0.0, 1.0);\n\
|
|
90
|
+
#if (!defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE))\n\
|
|
91
|
+
// If there is only one tile spanning 2*PI angle, the coordinate wraps around\n\
|
|
92
|
+
tileUv.y = (u_cameraTileCoordinates.w == 0) ? fract(tileUv.y) : clamp(tileUv.y, 0.0, 1.0);\n\
|
|
93
|
+
#else\n\
|
|
94
|
+
tileUv.y = clamp(tileUv.y, 0.0, 1.0);\n\
|
|
95
|
+
#endif\n\
|
|
96
|
+
tileUv.z = clamp(tileUv.z, 0.0, 1.0);\n\
|
|
97
|
+
return TileAndUvCoordinate(ivec4(tileCoordinate, u_cameraTileCoordinates.w), tileUv);\n\
|
|
98
|
+
}\n\
|
|
99
|
+
";
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/* Ellipsoid defines (set in Scene/VoxelEllipsoidShape.js)
|
|
2
|
+
#define ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_MIN_DISCONTINUITY
|
|
3
|
+
#define ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_MAX_DISCONTINUITY
|
|
4
|
+
#define ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE
|
|
5
|
+
#define ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE_MIN_MAX_REVERSED
|
|
6
|
+
#define ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
uniform vec3 u_cameraPositionCartographic; // (longitude, latitude, height) in radians and meters
|
|
10
|
+
uniform vec2 u_ellipsoidCurvatureAtLatitude;
|
|
11
|
+
uniform mat3 u_ellipsoidEcToEastNorthUp;
|
|
12
|
+
uniform vec3 u_ellipsoidRadii;
|
|
13
|
+
uniform vec2 u_evoluteScale; // (radii.x ^ 2 - radii.z ^ 2) * vec2(1.0, -1.0) / radii;
|
|
14
|
+
uniform vec3 u_ellipsoidInverseRadiiSquared;
|
|
15
|
+
#if defined(ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_MIN_DISCONTINUITY) || defined(ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_MAX_DISCONTINUITY) || defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE_MIN_MAX_REVERSED)
|
|
16
|
+
uniform vec3 u_ellipsoidShapeUvLongitudeMinMaxMid;
|
|
17
|
+
#endif
|
|
18
|
+
#if defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE)
|
|
19
|
+
uniform vec2 u_ellipsoidLocalToShapeUvLongitude; // x = scale, y = offset
|
|
20
|
+
uniform float u_ellipsoidShapeUvLongitudeRangeOrigin;
|
|
21
|
+
#endif
|
|
22
|
+
#if defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE)
|
|
23
|
+
uniform vec2 u_ellipsoidLocalToShapeUvLatitude; // x = scale, y = offset
|
|
24
|
+
#endif
|
|
25
|
+
uniform float u_ellipsoidInverseHeightDifference;
|
|
26
|
+
|
|
27
|
+
uniform ivec4 u_cameraTileCoordinates;
|
|
28
|
+
uniform vec3 u_cameraTileUv;
|
|
29
|
+
|
|
30
|
+
// robust iterative solution without trig functions
|
|
31
|
+
// https://github.com/0xfaded/ellipse_demo/issues/1
|
|
32
|
+
// https://stackoverflow.com/questions/22959698/distance-from-given-point-to-given-ellipse
|
|
33
|
+
// Extended to return radius of curvature along with the point
|
|
34
|
+
vec3 nearestPointAndRadiusOnEllipse(vec2 pos, vec2 radii) {
|
|
35
|
+
vec2 p = abs(pos);
|
|
36
|
+
vec2 inverseRadii = 1.0 / radii;
|
|
37
|
+
|
|
38
|
+
// We describe the ellipse parametrically: v = radii * vec2(cos(t), sin(t))
|
|
39
|
+
// but store the cos and sin of t in a vec2 for efficiency.
|
|
40
|
+
// Initial guess: t = pi/4
|
|
41
|
+
vec2 tTrigs = vec2(0.7071067811865476);
|
|
42
|
+
// Initial guess of point on ellipsoid
|
|
43
|
+
vec2 v = radii * tTrigs;
|
|
44
|
+
// Center of curvature of the ellipse at v
|
|
45
|
+
vec2 evolute = u_evoluteScale * tTrigs * tTrigs * tTrigs;
|
|
46
|
+
|
|
47
|
+
const int iterations = 3;
|
|
48
|
+
for (int i = 0; i < iterations; ++i) {
|
|
49
|
+
// Find the (approximate) intersection of p - evolute with the ellipsoid.
|
|
50
|
+
vec2 q = normalize(p - evolute) * length(v - evolute);
|
|
51
|
+
// Update the estimate of t.
|
|
52
|
+
tTrigs = (q + evolute) * inverseRadii;
|
|
53
|
+
tTrigs = normalize(clamp(tTrigs, 0.0, 1.0));
|
|
54
|
+
v = radii * tTrigs;
|
|
55
|
+
evolute = u_evoluteScale * tTrigs * tTrigs * tTrigs;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return vec3(v * sign(pos), length(v - evolute));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
mat3 convertLocalToShapeSpaceDerivative(in vec3 position) {
|
|
62
|
+
vec3 east = normalize(vec3(-position.y, position.x, 0.0));
|
|
63
|
+
|
|
64
|
+
// Convert the 3D position to a 2D position relative to the ellipse (radii.x, radii.z)
|
|
65
|
+
// (assume radii.y == radii.x) and find the nearest point on the ellipse and its normal
|
|
66
|
+
float distanceFromZAxis = length(position.xy);
|
|
67
|
+
vec2 posEllipse = vec2(distanceFromZAxis, position.z);
|
|
68
|
+
vec3 surfacePointAndRadius = nearestPointAndRadiusOnEllipse(posEllipse, u_ellipsoidRadii.xz);
|
|
69
|
+
vec2 surfacePoint = surfacePointAndRadius.xy;
|
|
70
|
+
|
|
71
|
+
vec2 normal2d = normalize(surfacePoint * u_ellipsoidInverseRadiiSquared.xz);
|
|
72
|
+
vec3 north = vec3(-normal2d.y * normalize(position.xy), abs(normal2d.x));
|
|
73
|
+
|
|
74
|
+
float heightSign = length(posEllipse) < length(surfacePoint) ? -1.0 : 1.0;
|
|
75
|
+
float height = heightSign * length(posEllipse - surfacePoint);
|
|
76
|
+
vec3 up = normalize(cross(east, north));
|
|
77
|
+
|
|
78
|
+
return mat3(east / distanceFromZAxis, north / (surfacePointAndRadius.z + height), up);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
vec3 scaleShapeUvToShapeSpace(in vec3 shapeUv) {
|
|
82
|
+
// Convert from [0, 1] to radians [-pi, pi]
|
|
83
|
+
float longitude = shapeUv.x * czm_twoPi;
|
|
84
|
+
#if defined (ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE)
|
|
85
|
+
longitude /= u_ellipsoidLocalToShapeUvLongitude.x;
|
|
86
|
+
#endif
|
|
87
|
+
|
|
88
|
+
// Convert from [0, 1] to radians [-pi/2, pi/2]
|
|
89
|
+
float latitude = shapeUv.y * czm_pi;
|
|
90
|
+
#if defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE)
|
|
91
|
+
latitude /= u_ellipsoidLocalToShapeUvLatitude.x;
|
|
92
|
+
#endif
|
|
93
|
+
|
|
94
|
+
float height = shapeUv.z / u_ellipsoidInverseHeightDifference;
|
|
95
|
+
|
|
96
|
+
return vec3(longitude, latitude, height);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
vec3 convertEcToDeltaShape(in vec3 positionEC) {
|
|
100
|
+
vec3 enu = u_ellipsoidEcToEastNorthUp * positionEC;
|
|
101
|
+
|
|
102
|
+
// 1. Compute the change in longitude from the camera to the ENU point
|
|
103
|
+
// First project the camera and ENU positions to the equatorial XY plane,
|
|
104
|
+
// positioning the camera on the +x axis, so that enu.x projects along the +y axis
|
|
105
|
+
float cosLatitude = cos(u_cameraPositionCartographic.y);
|
|
106
|
+
float sinLatitude = sin(u_cameraPositionCartographic.y);
|
|
107
|
+
float primeVerticalRadius = 1.0 / u_ellipsoidCurvatureAtLatitude.x;
|
|
108
|
+
vec2 cameraXY = vec2((primeVerticalRadius + u_cameraPositionCartographic.z) * cosLatitude, 0.0);
|
|
109
|
+
// Note precision loss in positionXY.x if length(enu) << length(cameraXY)
|
|
110
|
+
vec2 positionXY = cameraXY + vec2(-enu.y * sinLatitude + enu.z * cosLatitude, enu.x);
|
|
111
|
+
float dLongitude = atan(positionXY.y, positionXY.x);
|
|
112
|
+
|
|
113
|
+
// 2. Find the longitude component of positionXY, by rotating about Z until the y component is zero.
|
|
114
|
+
// Use the versine to compute the change in x directly from the change in angle:
|
|
115
|
+
// versine(angle) = 2 * sin^2(angle/2)
|
|
116
|
+
float sinHalfLongitude = sin(dLongitude / 2.0);
|
|
117
|
+
float dx = length(positionXY) * 2.0 * sinHalfLongitude * sinHalfLongitude;
|
|
118
|
+
// Rotate longitude component back to ENU North and Up, and remove from enu
|
|
119
|
+
enu += vec3(-enu.x, -dx * sinLatitude, dx * cosLatitude);
|
|
120
|
+
|
|
121
|
+
// 3. Compute the change in latitude from the camera to the ENU point.
|
|
122
|
+
// First project the camera and ENU positions to the meridional ZX plane,
|
|
123
|
+
// positioning the camera on the +Z axis, so that enu.y maps to the +X axis.
|
|
124
|
+
float meridionalRadius = 1.0 / u_ellipsoidCurvatureAtLatitude.y;
|
|
125
|
+
vec2 cameraZX = vec2(meridionalRadius + u_cameraPositionCartographic.z, 0.0);
|
|
126
|
+
vec2 positionZX = cameraZX + vec2(enu.z, enu.y);
|
|
127
|
+
float dLatitude = atan(positionZX.y, positionZX.x);
|
|
128
|
+
|
|
129
|
+
// 4. Compute the change in height above the ellipsoid
|
|
130
|
+
// Find the change in enu.z associated with rotating the point to the latitude of the camera
|
|
131
|
+
float sinHalfLatitude = sin(dLatitude / 2.0);
|
|
132
|
+
float dz = length(positionZX) * 2.0 * sinHalfLatitude * sinHalfLatitude;
|
|
133
|
+
// The remaining change in enu.z is the change in height above the ellipsoid
|
|
134
|
+
float dHeight = enu.z + dz;
|
|
135
|
+
|
|
136
|
+
return vec3(dLongitude, dLatitude, dHeight);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
vec3 convertEcToDeltaTile(in vec3 positionEC) {
|
|
140
|
+
vec3 deltaShape = convertEcToDeltaShape(positionEC);
|
|
141
|
+
// Convert to tileset coordinates in [0, 1]
|
|
142
|
+
float dx = deltaShape.x / czm_twoPi;
|
|
143
|
+
|
|
144
|
+
#if (defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE))
|
|
145
|
+
// Wrap to ensure dx is not crossing through the unoccupied angle range, where
|
|
146
|
+
// angle to tile coordinate conversions would be more complicated
|
|
147
|
+
float cameraUvLongitude = (u_cameraPositionCartographic.x + czm_pi) / czm_twoPi;
|
|
148
|
+
float cameraUvLongitudeShift = fract(cameraUvLongitude - u_ellipsoidShapeUvLongitudeRangeOrigin);
|
|
149
|
+
float rawOutputUvLongitude = cameraUvLongitudeShift + dx;
|
|
150
|
+
float rotation = floor(rawOutputUvLongitude);
|
|
151
|
+
dx -= rotation;
|
|
152
|
+
dx *= u_ellipsoidLocalToShapeUvLongitude.x;
|
|
153
|
+
#endif
|
|
154
|
+
|
|
155
|
+
float dy = deltaShape.y / czm_pi;
|
|
156
|
+
#if (defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE))
|
|
157
|
+
dy *= u_ellipsoidLocalToShapeUvLatitude.x;
|
|
158
|
+
#endif
|
|
159
|
+
|
|
160
|
+
float dz = u_ellipsoidInverseHeightDifference * deltaShape.z;
|
|
161
|
+
// Convert to tile coordinate changes
|
|
162
|
+
return vec3(dx, dy, dz) * float(1 << u_cameraTileCoordinates.w);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
TileAndUvCoordinate getTileAndUvCoordinate(in vec3 positionEC) {
|
|
166
|
+
vec3 deltaTileCoordinate = convertEcToDeltaTile(positionEC);
|
|
167
|
+
vec3 tileUvSum = u_cameraTileUv + deltaTileCoordinate;
|
|
168
|
+
ivec3 tileCoordinate = u_cameraTileCoordinates.xyz + ivec3(floor(tileUvSum));
|
|
169
|
+
int maxTileCoordinate = (1 << u_cameraTileCoordinates.w) - 1;
|
|
170
|
+
tileCoordinate.y = min(max(0, tileCoordinate.y), maxTileCoordinate);
|
|
171
|
+
tileCoordinate.z = min(max(0, tileCoordinate.z), maxTileCoordinate);
|
|
172
|
+
#if (!defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE))
|
|
173
|
+
ivec3 tileCoordinateChange = tileCoordinate - u_cameraTileCoordinates.xyz;
|
|
174
|
+
if (tileCoordinate.x < 0) {
|
|
175
|
+
tileCoordinate.x += (maxTileCoordinate + 1);
|
|
176
|
+
} else if (tileCoordinate.x > maxTileCoordinate) {
|
|
177
|
+
tileCoordinate.x -= (maxTileCoordinate + 1);
|
|
178
|
+
}
|
|
179
|
+
#else
|
|
180
|
+
tileCoordinate.x = min(max(0, tileCoordinate.x), maxTileCoordinate);
|
|
181
|
+
ivec3 tileCoordinateChange = tileCoordinate - u_cameraTileCoordinates.xyz;
|
|
182
|
+
#endif
|
|
183
|
+
vec3 tileUv = tileUvSum - vec3(tileCoordinateChange);
|
|
184
|
+
#if (!defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE))
|
|
185
|
+
// If there is only one tile spanning 2*PI angle, the coordinate wraps around
|
|
186
|
+
tileUv.x = (u_cameraTileCoordinates.w == 0) ? fract(tileUv.x) : clamp(tileUv.x, 0.0, 1.0);
|
|
187
|
+
#else
|
|
188
|
+
tileUv.x = clamp(tileUv.x, 0.0, 1.0);
|
|
189
|
+
#endif
|
|
190
|
+
tileUv.y = clamp(tileUv.y, 0.0, 1.0);
|
|
191
|
+
tileUv.z = clamp(tileUv.z, 0.0, 1.0);
|
|
192
|
+
return TileAndUvCoordinate(ivec4(tileCoordinate, u_cameraTileCoordinates.w), tileUv);
|
|
193
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "/* Ellipsoid defines (set in Scene/VoxelEllipsoidShape.js)\n\
|
|
3
|
+
#define ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_MIN_DISCONTINUITY\n\
|
|
4
|
+
#define ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_MAX_DISCONTINUITY\n\
|
|
5
|
+
#define ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE\n\
|
|
6
|
+
#define ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE_MIN_MAX_REVERSED\n\
|
|
7
|
+
#define ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE\n\
|
|
8
|
+
*/\n\
|
|
9
|
+
\n\
|
|
10
|
+
uniform vec3 u_cameraPositionCartographic; // (longitude, latitude, height) in radians and meters\n\
|
|
11
|
+
uniform vec2 u_ellipsoidCurvatureAtLatitude;\n\
|
|
12
|
+
uniform mat3 u_ellipsoidEcToEastNorthUp;\n\
|
|
13
|
+
uniform vec3 u_ellipsoidRadii;\n\
|
|
14
|
+
uniform vec2 u_evoluteScale; // (radii.x ^ 2 - radii.z ^ 2) * vec2(1.0, -1.0) / radii;\n\
|
|
15
|
+
uniform vec3 u_ellipsoidInverseRadiiSquared;\n\
|
|
16
|
+
#if defined(ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_MIN_DISCONTINUITY) || defined(ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_MAX_DISCONTINUITY) || defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE_MIN_MAX_REVERSED)\n\
|
|
17
|
+
uniform vec3 u_ellipsoidShapeUvLongitudeMinMaxMid;\n\
|
|
18
|
+
#endif\n\
|
|
19
|
+
#if defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE)\n\
|
|
20
|
+
uniform vec2 u_ellipsoidLocalToShapeUvLongitude; // x = scale, y = offset\n\
|
|
21
|
+
uniform float u_ellipsoidShapeUvLongitudeRangeOrigin;\n\
|
|
22
|
+
#endif\n\
|
|
23
|
+
#if defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE)\n\
|
|
24
|
+
uniform vec2 u_ellipsoidLocalToShapeUvLatitude; // x = scale, y = offset\n\
|
|
25
|
+
#endif\n\
|
|
26
|
+
uniform float u_ellipsoidInverseHeightDifference;\n\
|
|
27
|
+
\n\
|
|
28
|
+
uniform ivec4 u_cameraTileCoordinates;\n\
|
|
29
|
+
uniform vec3 u_cameraTileUv;\n\
|
|
30
|
+
\n\
|
|
31
|
+
// robust iterative solution without trig functions\n\
|
|
32
|
+
// https://github.com/0xfaded/ellipse_demo/issues/1\n\
|
|
33
|
+
// https://stackoverflow.com/questions/22959698/distance-from-given-point-to-given-ellipse\n\
|
|
34
|
+
// Extended to return radius of curvature along with the point\n\
|
|
35
|
+
vec3 nearestPointAndRadiusOnEllipse(vec2 pos, vec2 radii) {\n\
|
|
36
|
+
vec2 p = abs(pos);\n\
|
|
37
|
+
vec2 inverseRadii = 1.0 / radii;\n\
|
|
38
|
+
\n\
|
|
39
|
+
// We describe the ellipse parametrically: v = radii * vec2(cos(t), sin(t))\n\
|
|
40
|
+
// but store the cos and sin of t in a vec2 for efficiency.\n\
|
|
41
|
+
// Initial guess: t = pi/4\n\
|
|
42
|
+
vec2 tTrigs = vec2(0.7071067811865476);\n\
|
|
43
|
+
// Initial guess of point on ellipsoid\n\
|
|
44
|
+
vec2 v = radii * tTrigs;\n\
|
|
45
|
+
// Center of curvature of the ellipse at v\n\
|
|
46
|
+
vec2 evolute = u_evoluteScale * tTrigs * tTrigs * tTrigs;\n\
|
|
47
|
+
\n\
|
|
48
|
+
const int iterations = 3;\n\
|
|
49
|
+
for (int i = 0; i < iterations; ++i) {\n\
|
|
50
|
+
// Find the (approximate) intersection of p - evolute with the ellipsoid.\n\
|
|
51
|
+
vec2 q = normalize(p - evolute) * length(v - evolute);\n\
|
|
52
|
+
// Update the estimate of t.\n\
|
|
53
|
+
tTrigs = (q + evolute) * inverseRadii;\n\
|
|
54
|
+
tTrigs = normalize(clamp(tTrigs, 0.0, 1.0));\n\
|
|
55
|
+
v = radii * tTrigs;\n\
|
|
56
|
+
evolute = u_evoluteScale * tTrigs * tTrigs * tTrigs;\n\
|
|
57
|
+
}\n\
|
|
58
|
+
\n\
|
|
59
|
+
return vec3(v * sign(pos), length(v - evolute));\n\
|
|
60
|
+
}\n\
|
|
61
|
+
\n\
|
|
62
|
+
mat3 convertLocalToShapeSpaceDerivative(in vec3 position) {\n\
|
|
63
|
+
vec3 east = normalize(vec3(-position.y, position.x, 0.0));\n\
|
|
64
|
+
\n\
|
|
65
|
+
// Convert the 3D position to a 2D position relative to the ellipse (radii.x, radii.z)\n\
|
|
66
|
+
// (assume radii.y == radii.x) and find the nearest point on the ellipse and its normal\n\
|
|
67
|
+
float distanceFromZAxis = length(position.xy);\n\
|
|
68
|
+
vec2 posEllipse = vec2(distanceFromZAxis, position.z);\n\
|
|
69
|
+
vec3 surfacePointAndRadius = nearestPointAndRadiusOnEllipse(posEllipse, u_ellipsoidRadii.xz);\n\
|
|
70
|
+
vec2 surfacePoint = surfacePointAndRadius.xy;\n\
|
|
71
|
+
\n\
|
|
72
|
+
vec2 normal2d = normalize(surfacePoint * u_ellipsoidInverseRadiiSquared.xz);\n\
|
|
73
|
+
vec3 north = vec3(-normal2d.y * normalize(position.xy), abs(normal2d.x));\n\
|
|
74
|
+
\n\
|
|
75
|
+
float heightSign = length(posEllipse) < length(surfacePoint) ? -1.0 : 1.0;\n\
|
|
76
|
+
float height = heightSign * length(posEllipse - surfacePoint);\n\
|
|
77
|
+
vec3 up = normalize(cross(east, north));\n\
|
|
78
|
+
\n\
|
|
79
|
+
return mat3(east / distanceFromZAxis, north / (surfacePointAndRadius.z + height), up);\n\
|
|
80
|
+
}\n\
|
|
81
|
+
\n\
|
|
82
|
+
vec3 scaleShapeUvToShapeSpace(in vec3 shapeUv) {\n\
|
|
83
|
+
// Convert from [0, 1] to radians [-pi, pi]\n\
|
|
84
|
+
float longitude = shapeUv.x * czm_twoPi;\n\
|
|
85
|
+
#if defined (ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE)\n\
|
|
86
|
+
longitude /= u_ellipsoidLocalToShapeUvLongitude.x;\n\
|
|
87
|
+
#endif\n\
|
|
88
|
+
\n\
|
|
89
|
+
// Convert from [0, 1] to radians [-pi/2, pi/2]\n\
|
|
90
|
+
float latitude = shapeUv.y * czm_pi;\n\
|
|
91
|
+
#if defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE)\n\
|
|
92
|
+
latitude /= u_ellipsoidLocalToShapeUvLatitude.x;\n\
|
|
93
|
+
#endif\n\
|
|
94
|
+
\n\
|
|
95
|
+
float height = shapeUv.z / u_ellipsoidInverseHeightDifference;\n\
|
|
96
|
+
\n\
|
|
97
|
+
return vec3(longitude, latitude, height);\n\
|
|
98
|
+
}\n\
|
|
99
|
+
\n\
|
|
100
|
+
vec3 convertEcToDeltaShape(in vec3 positionEC) {\n\
|
|
101
|
+
vec3 enu = u_ellipsoidEcToEastNorthUp * positionEC;\n\
|
|
102
|
+
\n\
|
|
103
|
+
// 1. Compute the change in longitude from the camera to the ENU point\n\
|
|
104
|
+
// First project the camera and ENU positions to the equatorial XY plane,\n\
|
|
105
|
+
// positioning the camera on the +x axis, so that enu.x projects along the +y axis\n\
|
|
106
|
+
float cosLatitude = cos(u_cameraPositionCartographic.y);\n\
|
|
107
|
+
float sinLatitude = sin(u_cameraPositionCartographic.y);\n\
|
|
108
|
+
float primeVerticalRadius = 1.0 / u_ellipsoidCurvatureAtLatitude.x;\n\
|
|
109
|
+
vec2 cameraXY = vec2((primeVerticalRadius + u_cameraPositionCartographic.z) * cosLatitude, 0.0);\n\
|
|
110
|
+
// Note precision loss in positionXY.x if length(enu) << length(cameraXY)\n\
|
|
111
|
+
vec2 positionXY = cameraXY + vec2(-enu.y * sinLatitude + enu.z * cosLatitude, enu.x);\n\
|
|
112
|
+
float dLongitude = atan(positionXY.y, positionXY.x);\n\
|
|
113
|
+
\n\
|
|
114
|
+
// 2. Find the longitude component of positionXY, by rotating about Z until the y component is zero.\n\
|
|
115
|
+
// Use the versine to compute the change in x directly from the change in angle:\n\
|
|
116
|
+
// versine(angle) = 2 * sin^2(angle/2)\n\
|
|
117
|
+
float sinHalfLongitude = sin(dLongitude / 2.0);\n\
|
|
118
|
+
float dx = length(positionXY) * 2.0 * sinHalfLongitude * sinHalfLongitude;\n\
|
|
119
|
+
// Rotate longitude component back to ENU North and Up, and remove from enu\n\
|
|
120
|
+
enu += vec3(-enu.x, -dx * sinLatitude, dx * cosLatitude);\n\
|
|
121
|
+
\n\
|
|
122
|
+
// 3. Compute the change in latitude from the camera to the ENU point.\n\
|
|
123
|
+
// First project the camera and ENU positions to the meridional ZX plane,\n\
|
|
124
|
+
// positioning the camera on the +Z axis, so that enu.y maps to the +X axis.\n\
|
|
125
|
+
float meridionalRadius = 1.0 / u_ellipsoidCurvatureAtLatitude.y;\n\
|
|
126
|
+
vec2 cameraZX = vec2(meridionalRadius + u_cameraPositionCartographic.z, 0.0);\n\
|
|
127
|
+
vec2 positionZX = cameraZX + vec2(enu.z, enu.y);\n\
|
|
128
|
+
float dLatitude = atan(positionZX.y, positionZX.x);\n\
|
|
129
|
+
\n\
|
|
130
|
+
// 4. Compute the change in height above the ellipsoid\n\
|
|
131
|
+
// Find the change in enu.z associated with rotating the point to the latitude of the camera\n\
|
|
132
|
+
float sinHalfLatitude = sin(dLatitude / 2.0);\n\
|
|
133
|
+
float dz = length(positionZX) * 2.0 * sinHalfLatitude * sinHalfLatitude;\n\
|
|
134
|
+
// The remaining change in enu.z is the change in height above the ellipsoid\n\
|
|
135
|
+
float dHeight = enu.z + dz;\n\
|
|
136
|
+
\n\
|
|
137
|
+
return vec3(dLongitude, dLatitude, dHeight);\n\
|
|
138
|
+
}\n\
|
|
139
|
+
\n\
|
|
140
|
+
vec3 convertEcToDeltaTile(in vec3 positionEC) {\n\
|
|
141
|
+
vec3 deltaShape = convertEcToDeltaShape(positionEC);\n\
|
|
142
|
+
// Convert to tileset coordinates in [0, 1]\n\
|
|
143
|
+
float dx = deltaShape.x / czm_twoPi;\n\
|
|
144
|
+
\n\
|
|
145
|
+
#if (defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE))\n\
|
|
146
|
+
// Wrap to ensure dx is not crossing through the unoccupied angle range, where\n\
|
|
147
|
+
// angle to tile coordinate conversions would be more complicated\n\
|
|
148
|
+
float cameraUvLongitude = (u_cameraPositionCartographic.x + czm_pi) / czm_twoPi;\n\
|
|
149
|
+
float cameraUvLongitudeShift = fract(cameraUvLongitude - u_ellipsoidShapeUvLongitudeRangeOrigin);\n\
|
|
150
|
+
float rawOutputUvLongitude = cameraUvLongitudeShift + dx;\n\
|
|
151
|
+
float rotation = floor(rawOutputUvLongitude);\n\
|
|
152
|
+
dx -= rotation;\n\
|
|
153
|
+
dx *= u_ellipsoidLocalToShapeUvLongitude.x;\n\
|
|
154
|
+
#endif\n\
|
|
155
|
+
\n\
|
|
156
|
+
float dy = deltaShape.y / czm_pi;\n\
|
|
157
|
+
#if (defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE))\n\
|
|
158
|
+
dy *= u_ellipsoidLocalToShapeUvLatitude.x;\n\
|
|
159
|
+
#endif\n\
|
|
160
|
+
\n\
|
|
161
|
+
float dz = u_ellipsoidInverseHeightDifference * deltaShape.z;\n\
|
|
162
|
+
// Convert to tile coordinate changes\n\
|
|
163
|
+
return vec3(dx, dy, dz) * float(1 << u_cameraTileCoordinates.w);\n\
|
|
164
|
+
}\n\
|
|
165
|
+
\n\
|
|
166
|
+
TileAndUvCoordinate getTileAndUvCoordinate(in vec3 positionEC) {\n\
|
|
167
|
+
vec3 deltaTileCoordinate = convertEcToDeltaTile(positionEC);\n\
|
|
168
|
+
vec3 tileUvSum = u_cameraTileUv + deltaTileCoordinate;\n\
|
|
169
|
+
ivec3 tileCoordinate = u_cameraTileCoordinates.xyz + ivec3(floor(tileUvSum));\n\
|
|
170
|
+
int maxTileCoordinate = (1 << u_cameraTileCoordinates.w) - 1;\n\
|
|
171
|
+
tileCoordinate.y = min(max(0, tileCoordinate.y), maxTileCoordinate);\n\
|
|
172
|
+
tileCoordinate.z = min(max(0, tileCoordinate.z), maxTileCoordinate);\n\
|
|
173
|
+
#if (!defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE))\n\
|
|
174
|
+
ivec3 tileCoordinateChange = tileCoordinate - u_cameraTileCoordinates.xyz;\n\
|
|
175
|
+
if (tileCoordinate.x < 0) {\n\
|
|
176
|
+
tileCoordinate.x += (maxTileCoordinate + 1);\n\
|
|
177
|
+
} else if (tileCoordinate.x > maxTileCoordinate) {\n\
|
|
178
|
+
tileCoordinate.x -= (maxTileCoordinate + 1);\n\
|
|
179
|
+
}\n\
|
|
180
|
+
#else\n\
|
|
181
|
+
tileCoordinate.x = min(max(0, tileCoordinate.x), maxTileCoordinate);\n\
|
|
182
|
+
ivec3 tileCoordinateChange = tileCoordinate - u_cameraTileCoordinates.xyz;\n\
|
|
183
|
+
#endif\n\
|
|
184
|
+
vec3 tileUv = tileUvSum - vec3(tileCoordinateChange);\n\
|
|
185
|
+
#if (!defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE))\n\
|
|
186
|
+
// If there is only one tile spanning 2*PI angle, the coordinate wraps around\n\
|
|
187
|
+
tileUv.x = (u_cameraTileCoordinates.w == 0) ? fract(tileUv.x) : clamp(tileUv.x, 0.0, 1.0);\n\
|
|
188
|
+
#else\n\
|
|
189
|
+
tileUv.x = clamp(tileUv.x, 0.0, 1.0);\n\
|
|
190
|
+
#endif\n\
|
|
191
|
+
tileUv.y = clamp(tileUv.y, 0.0, 1.0);\n\
|
|
192
|
+
tileUv.z = clamp(tileUv.z, 0.0, 1.0);\n\
|
|
193
|
+
return TileAndUvCoordinate(ivec4(tileCoordinate, u_cameraTileCoordinates.w), tileUv);\n\
|
|
194
|
+
}\n\
|
|
195
|
+
";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(){"use strict";const{Array:e,Object:t,Number:n,Math:s,Error:r,Uint8Array:i,Uint16Array:a,Uint32Array:o,Int32Array:c,Map:l,DataView:u,Promise:h,TextEncoder:f,crypto:p,postMessage:d,TransformStream:w,ReadableStream:g,WritableStream:m,CompressionStream:_,DecompressionStream:y}=self,b=void 0,S="undefined",z="function",k=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)1&t?t=t>>>1^3988292384:t>>>=1;k[e]=t}class v{constructor(e){this.crc=e||-1}append(e){let t=0|this.crc;for(let n=0,s=0|e.length;s>n;n++)t=t>>>8^k[255&(t^e[n])];this.crc=t}get(){return~this.crc}}class H extends w{constructor(){let e;const t=new v;super({transform(e,n){t.append(e),n.enqueue(e)},flush(){const n=new i(4);new u(n.buffer).setUint32(0,t.get()),e.value=n}}),e=this}}const C={concat(e,t){if(0===e.length||0===t.length)return e.concat(t);const n=e[e.length-1],s=C.getPartial(n);return 32===s?e.concat(t):C._shiftRight(t,s,0|n,e.slice(0,e.length-1))},bitLength(e){const t=e.length;if(0===t)return 0;const n=e[t-1];return 32*(t-1)+C.getPartial(n)},clamp(e,t){if(32*e.length<t)return e;const n=(e=e.slice(0,s.ceil(t/32))).length;return t&=31,n>0&&t&&(e[n-1]=C.partial(t,e[n-1]&2147483648>>t-1,1)),e},partial:(e,t,n)=>32===e?t:(n?0|t:t<<32-e)+1099511627776*e,getPartial:e=>s.round(e/1099511627776)||32,_shiftRight(e,t,n,s){for(void 0===s&&(s=[]);t>=32;t-=32)s.push(n),n=0;if(0===t)return s.concat(e);for(let r=0;r<e.length;r++)s.push(n|e[r]>>>t),n=e[r]<<32-t;const r=e.length?e[e.length-1]:0,i=C.getPartial(r);return s.push(C.partial(t+i&31,t+i>32?n:s.pop(),1)),s}},B={bytes:{fromBits(e){const t=C.bitLength(e)/8,n=new i(t);let s;for(let r=0;t>r;r++)3&r||(s=e[r/4]),n[r]=s>>>24,s<<=8;return n},toBits(e){const t=[];let n,s=0;for(n=0;n<e.length;n++)s=s<<8|e[n],3&~n||(t.push(s),s=0);return 3&n&&t.push(C.partial(8*(3&n),s)),t}}},A=class{constructor(e){const t=this;t.blockSize=512,t._init=[1732584193,4023233417,2562383102,271733878,3285377520],t._key=[1518500249,1859775393,2400959708,3395469782],e?(t._h=e._h.slice(0),t._buffer=e._buffer.slice(0),t._length=e._length):t.reset()}reset(){const e=this;return e._h=e._init.slice(0),e._buffer=[],e._length=0,e}update(e){const t=this;"string"==typeof e&&(e=B.utf8String.toBits(e));const n=t._buffer=C.concat(t._buffer,e),s=t._length,i=t._length=s+C.bitLength(e);if(i>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const a=new o(n);let c=0;for(let e=t.blockSize+s-(t.blockSize+s&t.blockSize-1);i>=e;e+=t.blockSize)t._block(a.subarray(16*c,16*(c+1))),c+=1;return n.splice(0,16*c),t}finalize(){const e=this;let t=e._buffer;const n=e._h;t=C.concat(t,[C.partial(1,1)]);for(let e=t.length+2;15&e;e++)t.push(0);for(t.push(s.floor(e._length/4294967296)),t.push(0|e._length);t.length;)e._block(t.splice(0,16));return e.reset(),n}_f(e,t,n,s){return e>19?e>39?e>59?e>79?void 0:t^n^s:t&n|t&s|n&s:t^n^s:t&n|~t&s}_S(e,t){return t<<e|t>>>32-e}_block(t){const n=this,r=n._h,i=e(80);for(let e=0;16>e;e++)i[e]=t[e];let a=r[0],o=r[1],c=r[2],l=r[3],u=r[4];for(let e=0;79>=e;e++){16>e||(i[e]=n._S(1,i[e-3]^i[e-8]^i[e-14]^i[e-16]));const t=n._S(5,a)+n._f(e,o,c,l)+u+i[e]+n._key[s.floor(e/20)]|0;u=l,l=c,c=n._S(30,o),o=a,a=t}r[0]=r[0]+a|0,r[1]=r[1]+o|0,r[2]=r[2]+c|0,r[3]=r[3]+l|0,r[4]=r[4]+u|0}},R={getRandomValues(e){const t=new o(e.buffer),n=e=>{let t=987654321;const n=4294967295;return()=>(t=36969*(65535&t)+(t>>16)&n,(((t<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n)/4294967296+.5)*(s.random()>.5?1:-1))};for(let r,i=0;i<e.length;i+=4){const e=n(4294967296*(r||s.random()));r=987654071*e(),t[i/4]=4294967296*e()|0}return e}},I={importKey:e=>new I.hmacSha1(B.bytes.toBits(e)),pbkdf2(e,t,n,s){if(n=n||1e4,0>s||0>n)throw new r("invalid params to pbkdf2");const i=1+(s>>5)<<2;let a,o,c,l,h;const f=new ArrayBuffer(i),p=new u(f);let d=0;const w=C;for(t=B.bytes.toBits(t),h=1;(i||1)>d;h++){for(a=o=e.encrypt(w.concat(t,[h])),c=1;n>c;c++)for(o=e.encrypt(o),l=0;l<o.length;l++)a[l]^=o[l];for(c=0;(i||1)>d&&c<a.length;c++)p.setInt32(d,a[c]),d+=4}return f.slice(0,s/8)},hmacSha1:class{constructor(e){const t=this,n=t._hash=A,s=[[],[]];t._baseHash=[new n,new n];const r=t._baseHash[0].blockSize/32;e.length>r&&(e=(new n).update(e).finalize());for(let t=0;r>t;t++)s[0][t]=909522486^e[t],s[1][t]=1549556828^e[t];t._baseHash[0].update(s[0]),t._baseHash[1].update(s[1]),t._resultHash=new n(t._baseHash[0])}reset(){const e=this;e._resultHash=new e._hash(e._baseHash[0]),e._updated=!1}update(e){this._updated=!0,this._resultHash.update(e)}digest(){const e=this,t=e._resultHash.finalize(),n=new e._hash(e._baseHash[1]).update(t).finalize();return e.reset(),n}encrypt(e){if(this._updated)throw new r("encrypt on already updated hmac called!");return this.update(e),this.digest(e)}}},q=typeof p!=S&&typeof p.getRandomValues==z,K="Invalid password",P="Invalid signature",T="zipjs-abort-check-password";function V(e){return q?p.getRandomValues(e):R.getRandomValues(e)}const x=16,U={name:"PBKDF2"},W=t.assign({hash:{name:"HMAC"}},U),M=t.assign({iterations:1e3,hash:{name:"SHA-1"}},U),E=["deriveBits"],D=[8,12,16],L=[16,24,32],Z=10,F=[0,0,0,0],N=typeof p!=S,O=N&&p.subtle,j=N&&typeof O!=S,G=B.bytes,X=class{constructor(e){const t=this;t._tables=[[[],[],[],[],[]],[[],[],[],[],[]]],t._tables[0][0][0]||t._precompute();const n=t._tables[0][4],s=t._tables[1],i=e.length;let a,o,c,l=1;if(4!==i&&6!==i&&8!==i)throw new r("invalid aes key size");for(t._key=[o=e.slice(0),c=[]],a=i;4*i+28>a;a++){let e=o[a-1];(a%i===0||8===i&&a%i===4)&&(e=n[e>>>24]<<24^n[e>>16&255]<<16^n[e>>8&255]<<8^n[255&e],a%i===0&&(e=e<<8^e>>>24^l<<24,l=l<<1^283*(l>>7))),o[a]=o[a-i]^e}for(let e=0;a;e++,a--){const t=o[3&e?a:a-4];c[e]=4>=a||4>e?t:s[0][n[t>>>24]]^s[1][n[t>>16&255]]^s[2][n[t>>8&255]]^s[3][n[255&t]]}}encrypt(e){return this._crypt(e,0)}decrypt(e){return this._crypt(e,1)}_precompute(){const e=this._tables[0],t=this._tables[1],n=e[4],s=t[4],r=[],i=[];let a,o,c,l;for(let e=0;256>e;e++)i[(r[e]=e<<1^283*(e>>7))^e]=e;for(let u=a=0;!n[u];u^=o||1,a=i[a]||1){let i=a^a<<1^a<<2^a<<3^a<<4;i=i>>8^255&i^99,n[u]=i,s[i]=u,l=r[c=r[o=r[u]]];let h=16843009*l^65537*c^257*o^16843008*u,f=257*r[i]^16843008*i;for(let n=0;4>n;n++)e[n][u]=f=f<<24^f>>>8,t[n][i]=h=h<<24^h>>>8}for(let n=0;5>n;n++)e[n]=e[n].slice(0),t[n]=t[n].slice(0)}_crypt(e,t){if(4!==e.length)throw new r("invalid aes block size");const n=this._key[t],s=n.length/4-2,i=[0,0,0,0],a=this._tables[t],o=a[0],c=a[1],l=a[2],u=a[3],h=a[4];let f,p,d,w=e[0]^n[0],g=e[t?3:1]^n[1],m=e[2]^n[2],_=e[t?1:3]^n[3],y=4;for(let e=0;s>e;e++)f=o[w>>>24]^c[g>>16&255]^l[m>>8&255]^u[255&_]^n[y],p=o[g>>>24]^c[m>>16&255]^l[_>>8&255]^u[255&w]^n[y+1],d=o[m>>>24]^c[_>>16&255]^l[w>>8&255]^u[255&g]^n[y+2],_=o[_>>>24]^c[w>>16&255]^l[g>>8&255]^u[255&m]^n[y+3],y+=4,w=f,g=p,m=d;for(let e=0;4>e;e++)i[t?3&-e:e]=h[w>>>24]<<24^h[g>>16&255]<<16^h[m>>8&255]<<8^h[255&_]^n[y++],f=w,w=g,g=m,m=_,_=f;return i}},J=class{constructor(e,t){this._prf=e,this._initIv=t,this._iv=t}reset(){this._iv=this._initIv}update(e){return this.calculate(this._prf,e,this._iv)}incWord(e){if(255&~(e>>24))e+=1<<24;else{let t=e>>16&255,n=e>>8&255,s=255&e;255===t?(t=0,255===n?(n=0,255===s?s=0:++s):++n):++t,e=0,e+=t<<16,e+=n<<8,e+=s}return e}incCounter(e){0===(e[0]=this.incWord(e[0]))&&(e[1]=this.incWord(e[1]))}calculate(e,t,n){let s;if(!(s=t.length))return[];const r=C.bitLength(t);for(let r=0;s>r;r+=4){this.incCounter(n);const s=e.encrypt(n);t[r]^=s[0],t[r+1]^=s[1],t[r+2]^=s[2],t[r+3]^=s[3]}return C.clamp(t,r)}},Q=I.hmacSha1;let Y=N&&j&&typeof O.importKey==z,$=N&&j&&typeof O.deriveBits==z;class ee extends w{constructor({password:e,rawPassword:n,signed:s,encryptionStrength:a,checkPasswordOnly:o}){super({start(){t.assign(this,{ready:new h(e=>this.resolveReady=e),password:re(e,n),signed:s,strength:a-1,pending:new i})},async transform(e,t){const n=this,{password:s,strength:a,resolveReady:c,ready:l}=n;s?(await(async(e,t,n,s)=>{const i=await se(e,t,n,ae(s,0,D[t])),a=ae(s,D[t]);if(i[0]!=a[0]||i[1]!=a[1])throw new r(K)})(n,a,s,ae(e,0,D[a]+2)),e=ae(e,D[a]+2),o?t.error(new r(T)):c()):await l;const u=new i(e.length-Z-(e.length-Z)%x);t.enqueue(ne(n,e,u,0,Z,!0))},async flush(e){const{signed:t,ctr:n,hmac:s,pending:a,ready:o}=this;if(s&&n){await o;const c=ae(a,0,a.length-Z),l=ae(a,a.length-Z);let u=new i;if(c.length){const e=ce(G,c);s.update(e);const t=n.update(e);u=oe(G,t)}if(t){const e=ae(oe(G,s.digest()),0,Z);for(let t=0;Z>t;t++)if(e[t]!=l[t])throw new r(P)}e.enqueue(u)}}})}}class te extends w{constructor({password:e,rawPassword:n,encryptionStrength:s}){let r;super({start(){t.assign(this,{ready:new h(e=>this.resolveReady=e),password:re(e,n),strength:s-1,pending:new i})},async transform(e,t){const n=this,{password:s,strength:r,resolveReady:a,ready:o}=n;let c=new i;s?(c=await(async(e,t,n)=>{const s=V(new i(D[t]));return ie(s,await se(e,t,n,s))})(n,r,s),a()):await o;const l=new i(c.length+e.length-e.length%x);l.set(c,0),t.enqueue(ne(n,e,l,c.length,0))},async flush(e){const{ctr:t,hmac:n,pending:s,ready:a}=this;if(n&&t){await a;let o=new i;if(s.length){const e=t.update(ce(G,s));n.update(e),o=oe(G,e)}r.signature=oe(G,n.digest()).slice(0,Z),e.enqueue(ie(o,r.signature))}}}),r=this}}function ne(e,t,n,s,r,a){const{ctr:o,hmac:c,pending:l}=e,u=t.length-r;let h;for(l.length&&(t=ie(l,t),n=((e,t)=>{if(t&&t>e.length){const n=e;(e=new i(t)).set(n,0)}return e})(n,u-u%x)),h=0;u-x>=h;h+=x){const e=ce(G,ae(t,h,h+x));a&&c.update(e);const r=o.update(e);a||c.update(r),n.set(oe(G,r),h+s)}return e.pending=ae(t,h),n}async function se(n,s,r,a){n.password=null;const o=await(async(e,t,n,s,r)=>{if(!Y)return I.importKey(t);try{return await O.importKey("raw",t,n,!1,r)}catch{return Y=!1,I.importKey(t)}})(0,r,W,0,E),c=await(async(e,t,n)=>{if(!$)return I.pbkdf2(t,e.salt,M.iterations,n);try{return await O.deriveBits(e,t,n)}catch{return $=!1,I.pbkdf2(t,e.salt,M.iterations,n)}})(t.assign({salt:a},M),o,8*(2*L[s]+2)),l=new i(c),u=ce(G,ae(l,0,L[s])),h=ce(G,ae(l,L[s],2*L[s])),f=ae(l,2*L[s]);return t.assign(n,{keys:{key:u,authentication:h,passwordVerification:f},ctr:new J(new X(u),e.from(F)),hmac:new Q(h)}),f}function re(e,t){return t===b?(e=>{if(typeof f==S){const t=new i((e=unescape(encodeURIComponent(e))).length);for(let n=0;n<t.length;n++)t[n]=e.charCodeAt(n);return t}return(new f).encode(e)})(e):t}function ie(e,t){let n=e;return e.length+t.length&&(n=new i(e.length+t.length),n.set(e,0),n.set(t,e.length)),n}function ae(e,t,n){return e.subarray(t,n)}function oe(e,t){return e.fromBits(t)}function ce(e,t){return e.toBits(t)}class le extends w{constructor({password:e,passwordVerification:n,checkPasswordOnly:s}){super({start(){t.assign(this,{password:e,passwordVerification:n}),pe(this,e)},transform(e,t){const n=this;if(n.password){const t=he(n,e.subarray(0,12));if(n.password=null,t.at(-1)!=n.passwordVerification)throw new r(K);e=e.subarray(12)}s?t.error(new r(T)):t.enqueue(he(n,e))}})}}class ue extends w{constructor({password:e,passwordVerification:n}){super({start(){t.assign(this,{password:e,passwordVerification:n}),pe(this,e)},transform(e,t){const n=this;let s,r;if(n.password){n.password=null;const t=V(new i(12));t[11]=n.passwordVerification,s=new i(e.length+t.length),s.set(fe(n,t),0),r=12}else s=new i(e.length),r=0;s.set(fe(n,e),r),t.enqueue(s)}})}}function he(e,t){const n=new i(t.length);for(let s=0;s<t.length;s++)n[s]=we(e)^t[s],de(e,n[s]);return n}function fe(e,t){const n=new i(t.length);for(let s=0;s<t.length;s++)n[s]=we(e)^t[s],de(e,t[s]);return n}function pe(e,n){const s=[305419896,591751049,878082192];t.assign(e,{keys:s,crcKey0:new v(s[0]),crcKey2:new v(s[2])});for(let t=0;t<n.length;t++)de(e,n.charCodeAt(t))}function de(e,t){let[n,r,i]=e.keys;e.crcKey0.append([t]),n=~e.crcKey0.get(),r=me(s.imul(me(r+ge(n)),134775813)+1),e.crcKey2.append([r>>>24]),i=~e.crcKey2.get(),e.keys=[n,r,i]}function we(e){const t=2|e.keys[2];return ge(s.imul(t,1^t)>>>8)}function ge(e){return 255&e}function me(e){return 4294967295&e}class _e extends w{constructor(e,{chunkSize:t,CompressionStreamZlib:n,CompressionStream:s}){super({});const{compressed:r,encrypted:i,useCompressionStream:a,zipCrypto:o,signed:c,level:l}=e,h=this;let f,p,d=super.readable;i&&!o||!c||(f=new H,d=ze(d,f)),r&&(d=Se(d,a,{level:l,chunkSize:t},s,n,s)),i&&(o?d=ze(d,new ue(e)):(p=new te(e),d=ze(d,p))),be(h,d,()=>{let e;i&&!o&&(e=p.signature),i&&!o||!c||(e=new u(f.value.buffer).getUint32(0)),h.signature=e})}}class ye extends w{constructor(e,{chunkSize:t,DecompressionStreamZlib:n,DecompressionStream:s}){super({});const{zipCrypto:i,encrypted:a,signed:o,signature:c,compressed:l,useCompressionStream:h,deflate64:f}=e;let p,d,w=super.readable;a&&(i?w=ze(w,new le(e)):(d=new ee(e),w=ze(w,d))),l&&(w=Se(w,h,{chunkSize:t,deflate64:f},s,n,s)),a&&!i||!o||(p=new H,w=ze(w,p)),be(this,w,()=>{if((!a||i)&&o){const e=new u(p.value.buffer);if(c!=e.getUint32(0,!1))throw new r(P)}})}}function be(e,n,s){n=ze(n,new w({flush:s})),t.defineProperty(e,"readable",{get:()=>n})}function Se(e,t,n,s,r,i){const a=t&&s?s:r||i,o=n.deflate64?"deflate64-raw":"deflate-raw";try{e=ze(e,new a(o,n))}catch(s){if(!t)throw s;if(r)e=ze(e,new r(o,n));else{if(!i)throw s;e=ze(e,new i(o,n))}}return e}function ze(e,t){return e.pipeThrough(t)}const ke="data",ve="close";class He extends w{constructor(e,n){super({});const s=this,{codecType:i}=e;let a;i.startsWith("deflate")?a=_e:i.startsWith("inflate")&&(a=ye),s.outputSize=0;let o=0;const c=new a(e,n),l=super.readable,u=new w({transform(e,t){e&&e.length&&(o+=e.length,t.enqueue(e))},flush(){t.assign(s,{inputSize:o})}}),h=new w({transform(t,n){if(t&&t.length&&(n.enqueue(t),s.outputSize+=t.length,e.outputSize!==b&&s.outputSize>e.outputSize))throw new r("Invalid uncompressed size")},flush(){const{signature:e}=c;t.assign(s,{signature:e,inputSize:o})}});t.defineProperty(s,"readable",{get:()=>l.pipeThrough(u).pipeThrough(c).pipeThrough(h)})}}class Ce extends w{constructor(e){let t;super({transform:function n(s,r){if(t){const e=new i(t.length+s.length);e.set(t),e.set(s,t.length),s=e,t=null}s.length>e?(r.enqueue(s.slice(0,e)),n(s.slice(e),r)):t=s},flush(e){t&&t.length&&e.enqueue(t)}})}}const Be=new l,Ae=new l;let Re,Ie,qe,Ke,Pe,Te=0;async function Ve(e){try{const{options:t,config:s}=e;if(!t.useCompressionStream)try{await self.initModule(e.config)}catch{t.useCompressionStream=!0}s.CompressionStream=self.CompressionStream,s.DecompressionStream=self.DecompressionStream;const r={highWaterMark:1},i=e.readable||new g({async pull(e){const t=new h(e=>Be.set(Te,e));xe({type:"pull",messageId:Te}),Te=(Te+1)%n.MAX_SAFE_INTEGER;const{value:s,done:r}=await t;e.enqueue(s),r&&e.close()}},r),a=e.writable||new m({async write(e){let t;const s=new h(e=>t=e);Ae.set(Te,t),xe({type:ke,value:e,messageId:Te}),Te=(Te+1)%n.MAX_SAFE_INTEGER,await s}},r),o=new He(t,s);Re=new AbortController;const{signal:c}=Re;await i.pipeThrough(o).pipeThrough(new Ce(s.chunkSize)).pipeTo(a,{signal:c,preventClose:!0,preventAbort:!0}),await a.getWriter().close();const{signature:l,inputSize:u,outputSize:f}=o;xe({type:ve,result:{signature:l,inputSize:u,outputSize:f}})}catch(e){e.outputSize=0,Ue(e)}}function xe(e){let{value:t}=e;if(t)if(t.length)try{t=new i(t),e.value=t.buffer,d(e,[e.value])}catch{d(e)}else d(e);else d(e)}function Ue(e=new r("Unknown error")){const{message:t,stack:n,code:s,name:i,outputSize:a}=e;d({error:{message:t,stack:n,code:s,name:i,outputSize:a}})}function We(e,t,n={}){const a="number"==typeof n.level?n.level:-1,o="number"==typeof n.outBuffer?n.outBuffer:65536,c="number"==typeof n.inBufferSize?n.inBufferSize:65536;return new w({start(){let n;if(this.out=qe(o),this.in=qe(c),this.inBufferSize=c,this._scratch=new i(o),e?(this._process=Ie.deflate_process,this._last_consumed=Ie.deflate_last_consumed,this._end=Ie.deflate_end,this.streamHandle=Ie.deflate_new(),n="gzip"===t?Ie.deflate_init_gzip(this.streamHandle,a):"deflate-raw"===t?Ie.deflate_init_raw(this.streamHandle,a):Ie.deflate_init(this.streamHandle,a)):"deflate64-raw"===t?(this._process=Ie.inflate9_process,this._last_consumed=Ie.inflate9_last_consumed,this._end=Ie.inflate9_end,this.streamHandle=Ie.inflate9_new(),n=Ie.inflate9_init_raw(this.streamHandle)):(this._process=Ie.inflate_process,this._last_consumed=Ie.inflate_last_consumed,this._end=Ie.inflate_end,this.streamHandle=Ie.inflate_new(),n="deflate-raw"===t?Ie.inflate_init_raw(this.streamHandle):"gzip"===t?Ie.inflate_init_gzip(this.streamHandle):Ie.inflate_init(this.streamHandle)),0!==n)throw new r("init failed:"+n)},transform(t,n){try{const a=t,c=new i(Pe.buffer),l=this._process,u=this._last_consumed,h=this.out,f=this._scratch;let p=0;for(;p<a.length;){const t=s.min(a.length-p,32768);this.in&&this.inBufferSize>=t||(this.in&&Ke&&Ke(this.in),this.in=qe(t),this.inBufferSize=t),c.set(a.subarray(p,p+t),this.in);const i=l(this.streamHandle,this.in,t,h,o,0);if(!e&&0>i)throw new r("process error:"+i);const d=16777215&i;d&&(f.set(c.subarray(h,h+d),0),n.enqueue(f.slice(0,d)));const w=u(this.streamHandle);if(0===w)break;p+=w}}catch(e){this._end&&this.streamHandle&&this._end(this.streamHandle),this.in&&Ke&&Ke(this.in),this.out&&Ke&&Ke(this.out),n.error(e)}},flush(t){try{const n=new i(Pe.buffer),s=this._process,a=this.out,c=this._scratch;for(;;){const i=s(this.streamHandle,0,0,a,o,4);if(!e&&0>i)throw new r("process error:"+i);const l=16777215&i,u=i>>24&255;if(l&&(c.set(n.subarray(a,a+l),0),t.enqueue(c.slice(0,l))),1===u||0===l)break}}catch(e){t.error(e)}finally{if(this._end&&this.streamHandle){const e=this._end(this.streamHandle);0!==e&&t.error(new r("end error:"+e))}this.in&&Ke&&Ke(this.in),this.out&&Ke&&Ke(this.out)}}})}addEventListener("message",({data:e})=>{const{type:t,messageId:n,value:s,done:r}=e;try{if("start"==t&&Ve(e),t==ke){const e=Be.get(n);Be.delete(n),e({value:new i(s),done:r})}if("ack"==t){const e=Ae.get(n);Ae.delete(n),e()}t==ve&&Re.abort()}catch(e){Ue(e)}});class Me{constructor(e="deflate",t){return We(!0,e,t)}}class Ee{constructor(e="deflate",t){return We(!1,e,t)}}let De=!1;self.initModule=async e=>{try{const t=await(async(e,{baseURI:t})=>{if(!De){let n,s;try{try{s=new URL(e,t)}catch{}const r=await fetch(s);n=await r.arrayBuffer()}catch(t){if(!e.startsWith("data:application/wasm;base64,"))throw t;n=(e=>{const t=e.split(",")[1],n=atob(t),s=n.length,r=new i(s);for(let e=0;s>e;++e)r[e]=n.charCodeAt(e);return r.buffer})(e)}(e=>{if(Ie=e,({malloc:qe,free:Ke,memory:Pe}=Ie),"function"!=typeof qe||"function"!=typeof Ke||!Pe)throw Ie=qe=Ke=Pe=null,new r("Invalid WASM module")})((await WebAssembly.instantiate(n)).instance.exports),De=!0}})(e.wasmURI,e);return e.CompressionStreamZlib=Me,e.DecompressionStreamZlib=Ee,t}catch{}}}();
|
|
Binary file
|