@cesium/engine 8.0.0 → 9.1.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/z-worker-pako.js +7 -10
- package/Build/Workers/{chunk-F4HFJMGM.js → chunk-2CSEEWHN.js} +6 -6
- package/Build/Workers/{chunk-7TC63SJW.js → chunk-34DGOKCO.js} +10 -12
- package/Build/Workers/{chunk-7ZFGPDJA.js → chunk-3RZK5NNV.js} +4 -4
- package/Build/Workers/{chunk-M7ERACJJ.js → chunk-3S2MFY4B.js} +13 -13
- package/Build/Workers/{chunk-BROJAZRZ.js → chunk-4AJGCQFX.js} +13 -13
- package/Build/Workers/{chunk-2FWRMUTY.js → chunk-4KIUON73.js} +4 -4
- package/Build/Workers/{chunk-5QULIR53.js → chunk-4PHPQRSH.js} +4 -4
- package/Build/Workers/{chunk-X4356LRH.js → chunk-66E3H2KU.js} +12 -12
- package/Build/Workers/{chunk-G43QFN4Q.js → chunk-6HCAQOVK.js} +6 -6
- package/Build/Workers/{chunk-23UFSGND.js → chunk-7LPEGKOF.js} +7 -7
- package/Build/Workers/{chunk-DDUQAJ4P.js → chunk-7VZNXIKG.js} +7 -7
- package/Build/Workers/{chunk-JURN7NPV.js → chunk-A6NCZSL3.js} +19 -19
- package/Build/Workers/{chunk-ZT7KWISZ.js → chunk-AOFMPKUB.js} +4 -4
- package/Build/Workers/{chunk-BIKA3NRA.js → chunk-AOIKO5Y7.js} +5 -5
- package/Build/Workers/{chunk-YWTJ2B4B.js → chunk-BDUJXBVF.js} +1 -1
- package/Build/Workers/{chunk-OGXZVPPM.js → chunk-C5CE4OG6.js} +469 -6
- package/Build/Workers/{chunk-FNIRWHJB.js → chunk-CE6GTZ4I.js} +11 -13
- package/Build/Workers/{chunk-SH5USDPI.js → chunk-CYAJYEKW.js} +6 -6
- package/Build/Workers/{chunk-Y5UQJLYE.js → chunk-FOZQIHZK.js} +6 -6
- package/Build/Workers/{chunk-2FRVPMCS.js → chunk-G7CJQKKD.js} +7 -7
- package/Build/Workers/{chunk-EERJKOAF.js → chunk-GIFJ77E4.js} +4 -4
- package/Build/Workers/{chunk-FJKNFAKQ.js → chunk-I5TDPPC4.js} +7197 -5096
- package/Build/Workers/{chunk-3VAZEH7M.js → chunk-IBXGK4WV.js} +2 -2
- package/Build/Workers/{chunk-VOXYEYJT.js → chunk-JI2445T5.js} +11 -11
- package/Build/Workers/{chunk-PGSJK77E.js → chunk-KPY4F4BW.js} +6 -6
- package/Build/Workers/{chunk-I46ZRR5W.js → chunk-LVJCR7DH.js} +17 -17
- package/Build/Workers/{chunk-T3XIFPYR.js → chunk-LW7WGHEU.js} +16 -16
- package/Build/Workers/{chunk-HU6N6EXB.js → chunk-MWYZ64MH.js} +12 -11
- package/Build/Workers/chunk-NI2R52QD.js +961 -0
- package/Build/Workers/{chunk-SOWMRMWA.js → chunk-PEABJLCK.js} +1 -1
- package/Build/Workers/{chunk-EG6PTBY2.js → chunk-PK7TEP3J.js} +15 -15
- package/Build/Workers/{chunk-GRC2ZTAF.js → chunk-POLFRINT.js} +14 -14
- package/Build/Workers/{chunk-Z3TIFFGF.js → chunk-PS6AEMBR.js} +7 -7
- package/Build/Workers/{chunk-Y2ME2IJV.js → chunk-PWF3YJJ5.js} +13 -13
- package/Build/Workers/{chunk-2A75IWRS.js → chunk-QKF7XXEQ.js} +7 -7
- package/Build/Workers/{chunk-4H7PY4U5.js → chunk-RL73GOEF.js} +2 -2
- package/Build/Workers/{chunk-MDWEGWPA.js → chunk-RR7EOKGZ.js} +10 -10
- package/Build/Workers/{chunk-F3YA3Y2Z.js → chunk-S4XDCPKD.js} +1 -1
- package/Build/Workers/{chunk-PPH7OFP3.js → chunk-TMMOULW3.js} +5 -5
- package/Build/Workers/{chunk-XGI5BXZY.js → chunk-U4IMCOF5.js} +2 -2
- package/Build/Workers/{chunk-4DO5W5XZ.js → chunk-UAJEGIWA.js} +6 -6
- package/Build/Workers/{chunk-BBWDMCVU.js → chunk-UCPPWV64.js} +1 -1
- package/Build/Workers/{chunk-FZRIVR7Y.js → chunk-V7JB576Q.js} +5 -5
- package/Build/Workers/{chunk-2UPKWTMJ.js → chunk-WEGCQ5DY.js} +6 -6
- package/Build/Workers/{chunk-STW2DGFI.js → chunk-WFICTTOE.js} +2 -2
- package/Build/Workers/{chunk-LPR3YNP2.js → chunk-WWP3I7R5.js} +5 -5
- package/Build/Workers/{chunk-A5DWLWCY.js → chunk-XHLDDE65.js} +10 -10
- package/Build/Workers/{chunk-UEXTBDBE.js → chunk-XWML5Y7N.js} +11 -13
- package/Build/Workers/{chunk-EHWHNOEX.js → chunk-YLZTCEBJ.js} +1 -1
- package/Build/Workers/{chunk-34FXV7D7.js → chunk-ZC4AGBZK.js} +2 -2
- package/Build/Workers/{chunk-GATZHF3K.js → chunk-ZDP32RQI.js} +2 -2
- package/Build/Workers/{chunk-KKCR2YOP.js → chunk-ZWPIM77Q.js} +11 -11
- package/Build/Workers/combineGeometry.js +22 -24
- package/Build/Workers/createBoxGeometry.js +16 -18
- package/Build/Workers/createBoxOutlineGeometry.js +14 -16
- package/Build/Workers/createCircleGeometry.js +24 -26
- package/Build/Workers/createCircleOutlineGeometry.js +17 -19
- package/Build/Workers/createCoplanarPolygonGeometry.js +33 -34
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -31
- package/Build/Workers/createCorridorGeometry.js +27 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +26 -28
- package/Build/Workers/createCylinderGeometry.js +18 -20
- package/Build/Workers/createCylinderOutlineGeometry.js +16 -18
- package/Build/Workers/createEllipseGeometry.js +24 -26
- package/Build/Workers/createEllipseOutlineGeometry.js +17 -19
- package/Build/Workers/createEllipsoidGeometry.js +17 -19
- package/Build/Workers/createEllipsoidOutlineGeometry.js +16 -18
- package/Build/Workers/createFrustumGeometry.js +16 -18
- package/Build/Workers/createFrustumOutlineGeometry.js +18 -19
- package/Build/Workers/createGeometry.js +23 -25
- package/Build/Workers/createGroundPolylineGeometry.js +23 -25
- package/Build/Workers/createPlaneGeometry.js +14 -16
- package/Build/Workers/createPlaneOutlineGeometry.js +13 -15
- package/Build/Workers/createPolygonGeometry.js +33 -35
- package/Build/Workers/createPolygonOutlineGeometry.js +28 -30
- package/Build/Workers/createPolylineGeometry.js +23 -25
- package/Build/Workers/createPolylineVolumeGeometry.js +29 -31
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +25 -27
- package/Build/Workers/createRectangleGeometry.js +27 -29
- package/Build/Workers/createRectangleOutlineGeometry.js +18 -20
- package/Build/Workers/createSimplePolylineGeometry.js +21 -23
- package/Build/Workers/createSphereGeometry.js +17 -19
- package/Build/Workers/createSphereOutlineGeometry.js +16 -18
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -16
- package/Build/Workers/createVectorTileGeometries.js +22 -24
- package/Build/Workers/createVectorTilePoints.js +12 -12
- package/Build/Workers/createVectorTilePolygons.js +20 -22
- package/Build/Workers/createVectorTilePolylines.js +14 -16
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +23 -25
- package/Build/Workers/createVerticesFromHeightmap.js +23 -25
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +19 -22
- package/Build/Workers/createWallGeometry.js +22 -24
- package/Build/Workers/createWallOutlineGeometry.js +21 -23
- package/Build/Workers/decodeDraco.js +11 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +10 -11
- package/Build/Workers/transcodeKTX2.js +8 -8
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -22
- package/Source/Core/Check.d.ts +127 -0
- package/Source/Core/Check.js +0 -1
- package/Source/Core/Geometry.js +1 -1
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/PixelFormat.js +1 -0
- package/Source/Core/PolygonGeometry.js +1 -1
- package/Source/Core/Rectangle.js +89 -0
- package/Source/Core/VerticalExaggeration.js +2 -1
- package/Source/DataSources/DataSourceDisplay.js +5 -0
- package/Source/Renderer/ShaderBuilder.js +6 -3
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Billboard.js +37 -3
- package/Source/Scene/BillboardCollection.js +1 -1
- package/Source/Scene/BingMapsImageryProvider.js +4 -0
- package/Source/Scene/Cesium3DTile.js +65 -0
- package/Source/Scene/Cesium3DTilesVoxelProvider.js +2 -9
- package/Source/Scene/Cesium3DTileset.js +52 -40
- package/Source/Scene/ClippingPolygon.js +212 -0
- package/Source/Scene/ClippingPolygonCollection.js +968 -0
- package/Source/Scene/Globe.js +14 -67
- package/Source/Scene/GlobeSurfaceShaderSet.js +81 -15
- package/Source/Scene/GlobeSurfaceTileProvider.js +81 -1
- package/Source/Scene/Label.js +33 -0
- package/Source/Scene/LabelCollection.js +2 -1
- package/Source/Scene/Model/Model.js +83 -0
- package/Source/Scene/Model/Model3DTileContent.js +21 -0
- package/Source/Scene/Model/ModelClippingPolygonsPipelineStage.js +92 -0
- package/Source/Scene/Model/ModelSceneGraph.js +5 -0
- package/Source/Scene/Primitive.js +0 -3
- package/Source/Scene/SensorVolumePortionToDisplay.js +1 -1
- package/Source/Scene/Terrain.js +2 -2
- package/Source/Scene/VoxelBoxShape.js +0 -15
- package/Source/Scene/VoxelCylinderShape.js +14 -131
- package/Source/Scene/VoxelEllipsoidShape.js +136 -227
- package/Source/Scene/VoxelPrimitive.js +106 -14
- package/Source/Scene/VoxelRenderResources.js +9 -3
- package/Source/Scene/VoxelShape.js +0 -10
- package/Source/Scene/processVoxelProperties.js +1 -0
- package/Source/Shaders/Builtin/CzmBuiltins.js +4 -0
- package/Source/Shaders/Builtin/Functions/clipPolygons.glsl +37 -0
- package/Source/Shaders/Builtin/Functions/clipPolygons.js +39 -0
- package/Source/Shaders/Builtin/Functions/unpackClippingExtents.glsl +14 -0
- package/Source/Shaders/Builtin/Functions/unpackClippingExtents.js +15 -0
- package/Source/Shaders/GlobeFS.glsl +12 -0
- package/Source/Shaders/GlobeFS.js +12 -0
- package/Source/Shaders/GlobeVS.glsl +32 -0
- package/Source/Shaders/GlobeVS.js +32 -0
- package/Source/Shaders/Model/GeometryStageVS.glsl +1 -1
- package/Source/Shaders/Model/GeometryStageVS.js +1 -1
- package/Source/Shaders/Model/ModelClippingPolygonsStageFS.glsl +6 -0
- package/Source/Shaders/Model/ModelClippingPolygonsStageFS.js +8 -0
- package/Source/Shaders/Model/ModelClippingPolygonsStageVS.glsl +27 -0
- package/Source/Shaders/Model/ModelClippingPolygonsStageVS.js +29 -0
- package/Source/Shaders/Model/ModelFS.glsl +6 -0
- package/Source/Shaders/Model/ModelFS.js +7 -1
- package/Source/Shaders/Model/ModelVS.glsl +4 -0
- package/Source/Shaders/Model/ModelVS.js +4 -0
- package/Source/Shaders/PolygonSignedDistanceFS.glsl +100 -0
- package/Source/Shaders/PolygonSignedDistanceFS.js +101 -0
- package/Source/Shaders/Voxels/IntersectBox.glsl +21 -47
- package/Source/Shaders/Voxels/IntersectBox.js +21 -47
- package/Source/Shaders/Voxels/IntersectClippingPlanes.glsl +1 -1
- package/Source/Shaders/Voxels/IntersectClippingPlanes.js +1 -1
- package/Source/Shaders/Voxels/IntersectCylinder.glsl +66 -96
- package/Source/Shaders/Voxels/IntersectCylinder.js +66 -96
- package/Source/Shaders/Voxels/IntersectEllipsoid.glsl +226 -154
- package/Source/Shaders/Voxels/IntersectEllipsoid.js +226 -154
- package/Source/Shaders/Voxels/IntersectionUtils.glsl +33 -11
- package/Source/Shaders/Voxels/IntersectionUtils.js +33 -11
- package/Source/Shaders/Voxels/Megatexture.glsl +1 -2
- package/Source/Shaders/Voxels/Megatexture.js +1 -2
- package/Source/Shaders/Voxels/Octree.glsl +14 -9
- package/Source/Shaders/Voxels/Octree.js +14 -9
- package/Source/Shaders/Voxels/VoxelFS.glsl +93 -43
- package/Source/Shaders/Voxels/VoxelFS.js +93 -43
- package/Source/Shaders/Voxels/VoxelUtils.glsl +31 -0
- package/Source/Shaders/Voxels/VoxelUtils.js +33 -0
- package/Source/Shaders/Voxels/convertUvToBox.glsl +24 -3
- package/Source/Shaders/Voxels/convertUvToBox.js +24 -4
- package/Source/Shaders/Voxels/convertUvToCylinder.glsl +50 -8
- package/Source/Shaders/Voxels/convertUvToCylinder.js +50 -8
- package/Source/Shaders/Voxels/convertUvToEllipsoid.glsl +82 -53
- package/Source/Shaders/Voxels/convertUvToEllipsoid.js +82 -53
- package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
- package/Source/Workers/createGeometry.js +1 -1
- package/index.d.ts +478 -35
- package/index.js +61 -52
- package/package.json +2 -2
- package/Build/Workers/chunk-BG4UCVXN.js +0 -73
- package/Build/Workers/chunk-TTUZP4BO.js +0 -501
- package/Build/Workers/chunk-YJEBABKH.js +0 -2977
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
// See IntersectionUtils.glsl for the definitions of Ray, NO_HIT,
|
|
2
|
-
//
|
|
1
|
+
// See IntersectionUtils.glsl for the definitions of Ray, NO_HIT, Intersections,
|
|
2
|
+
// RayShapeIntersection, setSurfaceIntersection, setShapeIntersection,
|
|
3
|
+
// intersectIntersections
|
|
3
4
|
// See IntersectLongitude.glsl for the definitions of intersectHalfPlane,
|
|
4
5
|
// intersectFlippedWedge, intersectRegularWedge
|
|
5
6
|
|
|
6
7
|
/* Cylinder defines (set in Scene/VoxelCylinderShape.js)
|
|
7
8
|
#define CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MIN
|
|
8
|
-
#define CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MAX
|
|
9
9
|
#define CYLINDER_HAS_RENDER_BOUNDS_RADIUS_FLAT
|
|
10
|
-
#define CYLINDER_HAS_RENDER_BOUNDS_HEIGHT
|
|
11
|
-
#define CYLINDER_HAS_RENDER_BOUNDS_HEIGHT_FLAT
|
|
12
10
|
#define CYLINDER_HAS_RENDER_BOUNDS_ANGLE
|
|
13
11
|
#define CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_UNDER_HALF
|
|
14
12
|
#define CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_OVER_HALF
|
|
@@ -20,114 +18,87 @@
|
|
|
20
18
|
*/
|
|
21
19
|
|
|
22
20
|
// Cylinder uniforms
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
uniform vec3 u_cylinderUvToRenderBoundsTranslate;
|
|
26
|
-
#endif
|
|
27
|
-
#if defined(CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MIN) && !defined(CYLINDER_HAS_RENDER_BOUNDS_RADIUS_FLAT)
|
|
28
|
-
uniform float u_cylinderUvToRenderRadiusMin;
|
|
29
|
-
#endif
|
|
21
|
+
uniform vec2 u_cylinderRenderRadiusMinMax;
|
|
22
|
+
uniform vec2 u_cylinderRenderHeightMinMax;
|
|
30
23
|
#if defined(CYLINDER_HAS_RENDER_BOUNDS_ANGLE)
|
|
31
24
|
uniform vec2 u_cylinderRenderAngleMinMax;
|
|
32
25
|
#endif
|
|
33
26
|
|
|
34
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Find the intersection of a ray with the volume defined by two planes of constant z
|
|
29
|
+
*/
|
|
30
|
+
RayShapeIntersection intersectHeightBounds(in Ray ray, in vec2 minMaxHeight, in bool convex)
|
|
35
31
|
{
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
float zPosition = ray.pos.z;
|
|
33
|
+
float zDirection = ray.dir.z;
|
|
38
34
|
|
|
39
|
-
float
|
|
40
|
-
float
|
|
41
|
-
float c = dot(o.xy, o.xy) - 1.0;
|
|
42
|
-
float det = b * b - a * c;
|
|
35
|
+
float tmin = (minMaxHeight.x - zPosition) / zDirection;
|
|
36
|
+
float tmax = (minMaxHeight.y - zPosition) / zDirection;
|
|
43
37
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
// Normals point outside the volume
|
|
39
|
+
float signFlip = convex ? 1.0 : -1.0;
|
|
40
|
+
vec4 intersectMin = vec4(0.0, 0.0, -1.0 * signFlip, tmin);
|
|
41
|
+
vec4 intersectMax = vec4(0.0, 0.0, 1.0 * signFlip, tmax);
|
|
47
42
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
float t1 = min(ta, tb);
|
|
52
|
-
float t2 = max(ta, tb);
|
|
43
|
+
bool topEntry = zDirection < 0.0;
|
|
44
|
+
vec4 entry = topEntry ? intersectMax : intersectMin;
|
|
45
|
+
vec4 exit = topEntry ? intersectMin : intersectMax;
|
|
53
46
|
|
|
54
|
-
|
|
55
|
-
float z2 = o.z + t2 * d.z;
|
|
56
|
-
|
|
57
|
-
if (abs(z1) >= 1.0)
|
|
58
|
-
{
|
|
59
|
-
float tCap = (sign(z1) - o.z) / d.z;
|
|
60
|
-
t1 = abs(b + a * tCap) < det ? tCap : NO_HIT;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (abs(z2) >= 1.0)
|
|
64
|
-
{
|
|
65
|
-
float tCap = (sign(z2) - o.z) / d.z;
|
|
66
|
-
t2 = abs(b + a * tCap) < det ? tCap : NO_HIT;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return vec2(t1, t2);
|
|
47
|
+
return RayShapeIntersection(entry, exit);
|
|
70
48
|
}
|
|
71
49
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Find the intersection of a ray with a right cylindrical surface of a given radius
|
|
52
|
+
* about the z-axis.
|
|
53
|
+
*/
|
|
54
|
+
RayShapeIntersection intersectCylinder(in Ray ray, in float radius, in bool convex)
|
|
55
|
+
{
|
|
56
|
+
vec2 position = ray.pos.xy;
|
|
57
|
+
vec2 direction = ray.dir.xy;
|
|
75
58
|
|
|
76
|
-
float
|
|
77
|
-
|
|
78
|
-
float
|
|
59
|
+
float a = dot(direction, direction);
|
|
60
|
+
float b = dot(position, direction);
|
|
61
|
+
float c = dot(position, position) - radius * radius;
|
|
62
|
+
float determinant = b * b - a * c;
|
|
79
63
|
|
|
80
|
-
if (
|
|
81
|
-
|
|
64
|
+
if (determinant < 0.0) {
|
|
65
|
+
vec4 miss = vec4(normalize(ray.dir), NO_HIT);
|
|
66
|
+
return RayShapeIntersection(miss, miss);
|
|
82
67
|
}
|
|
83
68
|
|
|
84
|
-
|
|
69
|
+
determinant = sqrt(determinant);
|
|
70
|
+
float t1 = (-b - determinant) / a;
|
|
71
|
+
float t2 = (-b + determinant) / a;
|
|
72
|
+
float signFlip = convex ? 1.0 : -1.0;
|
|
73
|
+
vec4 intersect1 = vec4(normalize(position + t1 * direction) * signFlip, 0.0, t1);
|
|
74
|
+
vec4 intersect2 = vec4(normalize(position + t2 * direction) * signFlip, 0.0, t2);
|
|
75
|
+
|
|
76
|
+
return RayShapeIntersection(intersect1, intersect2);
|
|
85
77
|
}
|
|
86
78
|
|
|
87
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Find the intersection of a ray with a right cylindrical solid of given
|
|
81
|
+
* radius and height bounds. NOTE: The shape is assumed to be convex.
|
|
82
|
+
*/
|
|
83
|
+
RayShapeIntersection intersectBoundedCylinder(in Ray ray, in float radius, in vec2 minMaxHeight)
|
|
88
84
|
{
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
float a = dot(d.xy, d.xy);
|
|
93
|
-
float b = dot(o.xy, d.xy);
|
|
94
|
-
float c = dot(o.xy, o.xy) - 1.0;
|
|
95
|
-
float det = b * b - a * c;
|
|
96
|
-
|
|
97
|
-
if (det < 0.0) {
|
|
98
|
-
return vec2(NO_HIT);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
det = sqrt(det);
|
|
102
|
-
float t1 = (-b - det) / a;
|
|
103
|
-
float t2 = (-b + det) / a;
|
|
104
|
-
float tmin = min(t1, t2);
|
|
105
|
-
float tmax = max(t1, t2);
|
|
106
|
-
|
|
107
|
-
return vec2(tmin, tmax);
|
|
85
|
+
RayShapeIntersection cylinderIntersection = intersectCylinder(ray, radius, true);
|
|
86
|
+
RayShapeIntersection heightBoundsIntersection = intersectHeightBounds(ray, minMaxHeight, true);
|
|
87
|
+
return intersectIntersections(ray, cylinderIntersection, heightBoundsIntersection);
|
|
108
88
|
}
|
|
109
89
|
|
|
110
90
|
void intersectShape(Ray ray, inout Intersections ix)
|
|
111
91
|
{
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
// Position is converted from [0,1] to [-1,+1] because shape intersections assume unit space is [-1,+1].
|
|
117
|
-
// Direction is scaled as well to be in sync with position.
|
|
118
|
-
ray.pos = ray.pos * 2.0 - 1.0;
|
|
119
|
-
ray.dir *= 2.0;
|
|
120
|
-
#endif
|
|
92
|
+
// Position is converted from [0,1] to [-1,+1] because shape intersections assume unit space is [-1,+1].
|
|
93
|
+
// Direction is scaled as well to be in sync with position.
|
|
94
|
+
ray.pos = ray.pos * 2.0 - 1.0;
|
|
95
|
+
ray.dir *= 2.0;
|
|
121
96
|
|
|
122
|
-
|
|
123
|
-
vec2 outerIntersect = intersectUnitCircle(ray);
|
|
124
|
-
#else
|
|
125
|
-
vec2 outerIntersect = intersectUnitCylinder(ray);
|
|
126
|
-
#endif
|
|
97
|
+
RayShapeIntersection outerIntersect = intersectBoundedCylinder(ray, u_cylinderRenderRadiusMinMax.y, u_cylinderRenderHeightMinMax);
|
|
127
98
|
|
|
128
|
-
|
|
99
|
+
setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_RADIUS_MAX, outerIntersect);
|
|
129
100
|
|
|
130
|
-
if (outerIntersect.
|
|
101
|
+
if (outerIntersect.entry.w == NO_HIT) {
|
|
131
102
|
return;
|
|
132
103
|
}
|
|
133
104
|
|
|
@@ -148,15 +119,14 @@ void intersectShape(Ray ray, inout Intersections ix)
|
|
|
148
119
|
|
|
149
120
|
// Note: If initializeIntersections() changes its sorting function
|
|
150
121
|
// from bubble sort to something else, this code may need to change.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
122
|
+
RayShapeIntersection innerIntersect = intersectCylinder(ray, 1.0, false);
|
|
123
|
+
setSurfaceIntersection(ix, 0, outerIntersect.entry, true, true); // positive, enter
|
|
124
|
+
setSurfaceIntersection(ix, 1, innerIntersect.entry, false, true); // negative, enter
|
|
125
|
+
setSurfaceIntersection(ix, 2, innerIntersect.exit, false, false); // negative, exit
|
|
126
|
+
setSurfaceIntersection(ix, 3, outerIntersect.exit, true, false); // positive, exit
|
|
156
127
|
#elif defined(CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MIN)
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
setIntersectionPair(ix, CYLINDER_INTERSECTION_INDEX_RADIUS_MIN, innerIntersect);
|
|
128
|
+
RayShapeIntersection innerIntersect = intersectCylinder(ray, u_cylinderRenderRadiusMinMax.x, false);
|
|
129
|
+
setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_RADIUS_MIN, innerIntersect);
|
|
160
130
|
#endif
|
|
161
131
|
|
|
162
132
|
#if defined(CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_UNDER_HALF)
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
-
export default "// See IntersectionUtils.glsl for the definitions of Ray, NO_HIT,\n\
|
|
3
|
-
//
|
|
2
|
+
export default "// See IntersectionUtils.glsl for the definitions of Ray, NO_HIT, Intersections,\n\
|
|
3
|
+
// RayShapeIntersection, setSurfaceIntersection, setShapeIntersection,\n\
|
|
4
|
+
// intersectIntersections\n\
|
|
4
5
|
// See IntersectLongitude.glsl for the definitions of intersectHalfPlane,\n\
|
|
5
6
|
// intersectFlippedWedge, intersectRegularWedge\n\
|
|
6
7
|
\n\
|
|
7
8
|
/* Cylinder defines (set in Scene/VoxelCylinderShape.js)\n\
|
|
8
9
|
#define CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MIN\n\
|
|
9
|
-
#define CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MAX\n\
|
|
10
10
|
#define CYLINDER_HAS_RENDER_BOUNDS_RADIUS_FLAT\n\
|
|
11
|
-
#define CYLINDER_HAS_RENDER_BOUNDS_HEIGHT\n\
|
|
12
|
-
#define CYLINDER_HAS_RENDER_BOUNDS_HEIGHT_FLAT\n\
|
|
13
11
|
#define CYLINDER_HAS_RENDER_BOUNDS_ANGLE\n\
|
|
14
12
|
#define CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_UNDER_HALF\n\
|
|
15
13
|
#define CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_OVER_HALF\n\
|
|
@@ -21,114 +19,87 @@ export default "// See IntersectionUtils.glsl for the definitions of Ray, NO_HIT
|
|
|
21
19
|
*/\n\
|
|
22
20
|
\n\
|
|
23
21
|
// Cylinder uniforms\n\
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
uniform vec3 u_cylinderUvToRenderBoundsTranslate;\n\
|
|
27
|
-
#endif\n\
|
|
28
|
-
#if defined(CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MIN) && !defined(CYLINDER_HAS_RENDER_BOUNDS_RADIUS_FLAT)\n\
|
|
29
|
-
uniform float u_cylinderUvToRenderRadiusMin;\n\
|
|
30
|
-
#endif\n\
|
|
22
|
+
uniform vec2 u_cylinderRenderRadiusMinMax;\n\
|
|
23
|
+
uniform vec2 u_cylinderRenderHeightMinMax;\n\
|
|
31
24
|
#if defined(CYLINDER_HAS_RENDER_BOUNDS_ANGLE)\n\
|
|
32
25
|
uniform vec2 u_cylinderRenderAngleMinMax;\n\
|
|
33
26
|
#endif\n\
|
|
34
27
|
\n\
|
|
35
|
-
|
|
28
|
+
/**\n\
|
|
29
|
+
* Find the intersection of a ray with the volume defined by two planes of constant z\n\
|
|
30
|
+
*/\n\
|
|
31
|
+
RayShapeIntersection intersectHeightBounds(in Ray ray, in vec2 minMaxHeight, in bool convex)\n\
|
|
36
32
|
{\n\
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
float zPosition = ray.pos.z;\n\
|
|
34
|
+
float zDirection = ray.dir.z;\n\
|
|
39
35
|
\n\
|
|
40
|
-
float
|
|
41
|
-
float
|
|
42
|
-
float c = dot(o.xy, o.xy) - 1.0;\n\
|
|
43
|
-
float det = b * b - a * c;\n\
|
|
36
|
+
float tmin = (minMaxHeight.x - zPosition) / zDirection;\n\
|
|
37
|
+
float tmax = (minMaxHeight.y - zPosition) / zDirection;\n\
|
|
44
38
|
\n\
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
// Normals point outside the volume\n\
|
|
40
|
+
float signFlip = convex ? 1.0 : -1.0;\n\
|
|
41
|
+
vec4 intersectMin = vec4(0.0, 0.0, -1.0 * signFlip, tmin);\n\
|
|
42
|
+
vec4 intersectMax = vec4(0.0, 0.0, 1.0 * signFlip, tmax);\n\
|
|
48
43
|
\n\
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
float t1 = min(ta, tb);\n\
|
|
53
|
-
float t2 = max(ta, tb);\n\
|
|
44
|
+
bool topEntry = zDirection < 0.0;\n\
|
|
45
|
+
vec4 entry = topEntry ? intersectMax : intersectMin;\n\
|
|
46
|
+
vec4 exit = topEntry ? intersectMin : intersectMax;\n\
|
|
54
47
|
\n\
|
|
55
|
-
|
|
56
|
-
float z2 = o.z + t2 * d.z;\n\
|
|
57
|
-
\n\
|
|
58
|
-
if (abs(z1) >= 1.0)\n\
|
|
59
|
-
{\n\
|
|
60
|
-
float tCap = (sign(z1) - o.z) / d.z;\n\
|
|
61
|
-
t1 = abs(b + a * tCap) < det ? tCap : NO_HIT;\n\
|
|
62
|
-
}\n\
|
|
63
|
-
\n\
|
|
64
|
-
if (abs(z2) >= 1.0)\n\
|
|
65
|
-
{\n\
|
|
66
|
-
float tCap = (sign(z2) - o.z) / d.z;\n\
|
|
67
|
-
t2 = abs(b + a * tCap) < det ? tCap : NO_HIT;\n\
|
|
68
|
-
}\n\
|
|
69
|
-
\n\
|
|
70
|
-
return vec2(t1, t2);\n\
|
|
48
|
+
return RayShapeIntersection(entry, exit);\n\
|
|
71
49
|
}\n\
|
|
72
50
|
\n\
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
51
|
+
/**\n\
|
|
52
|
+
* Find the intersection of a ray with a right cylindrical surface of a given radius\n\
|
|
53
|
+
* about the z-axis.\n\
|
|
54
|
+
*/\n\
|
|
55
|
+
RayShapeIntersection intersectCylinder(in Ray ray, in float radius, in bool convex)\n\
|
|
56
|
+
{\n\
|
|
57
|
+
vec2 position = ray.pos.xy;\n\
|
|
58
|
+
vec2 direction = ray.dir.xy;\n\
|
|
76
59
|
\n\
|
|
77
|
-
float
|
|
78
|
-
|
|
79
|
-
float
|
|
60
|
+
float a = dot(direction, direction);\n\
|
|
61
|
+
float b = dot(position, direction);\n\
|
|
62
|
+
float c = dot(position, position) - radius * radius;\n\
|
|
63
|
+
float determinant = b * b - a * c;\n\
|
|
80
64
|
\n\
|
|
81
|
-
if (
|
|
82
|
-
|
|
65
|
+
if (determinant < 0.0) {\n\
|
|
66
|
+
vec4 miss = vec4(normalize(ray.dir), NO_HIT);\n\
|
|
67
|
+
return RayShapeIntersection(miss, miss);\n\
|
|
83
68
|
}\n\
|
|
84
69
|
\n\
|
|
85
|
-
|
|
70
|
+
determinant = sqrt(determinant);\n\
|
|
71
|
+
float t1 = (-b - determinant) / a;\n\
|
|
72
|
+
float t2 = (-b + determinant) / a;\n\
|
|
73
|
+
float signFlip = convex ? 1.0 : -1.0;\n\
|
|
74
|
+
vec4 intersect1 = vec4(normalize(position + t1 * direction) * signFlip, 0.0, t1);\n\
|
|
75
|
+
vec4 intersect2 = vec4(normalize(position + t2 * direction) * signFlip, 0.0, t2);\n\
|
|
76
|
+
\n\
|
|
77
|
+
return RayShapeIntersection(intersect1, intersect2);\n\
|
|
86
78
|
}\n\
|
|
87
79
|
\n\
|
|
88
|
-
|
|
80
|
+
/**\n\
|
|
81
|
+
* Find the intersection of a ray with a right cylindrical solid of given\n\
|
|
82
|
+
* radius and height bounds. NOTE: The shape is assumed to be convex.\n\
|
|
83
|
+
*/\n\
|
|
84
|
+
RayShapeIntersection intersectBoundedCylinder(in Ray ray, in float radius, in vec2 minMaxHeight)\n\
|
|
89
85
|
{\n\
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
float a = dot(d.xy, d.xy);\n\
|
|
94
|
-
float b = dot(o.xy, d.xy);\n\
|
|
95
|
-
float c = dot(o.xy, o.xy) - 1.0;\n\
|
|
96
|
-
float det = b * b - a * c;\n\
|
|
97
|
-
\n\
|
|
98
|
-
if (det < 0.0) {\n\
|
|
99
|
-
return vec2(NO_HIT);\n\
|
|
100
|
-
}\n\
|
|
101
|
-
\n\
|
|
102
|
-
det = sqrt(det);\n\
|
|
103
|
-
float t1 = (-b - det) / a;\n\
|
|
104
|
-
float t2 = (-b + det) / a;\n\
|
|
105
|
-
float tmin = min(t1, t2);\n\
|
|
106
|
-
float tmax = max(t1, t2);\n\
|
|
107
|
-
\n\
|
|
108
|
-
return vec2(tmin, tmax);\n\
|
|
86
|
+
RayShapeIntersection cylinderIntersection = intersectCylinder(ray, radius, true);\n\
|
|
87
|
+
RayShapeIntersection heightBoundsIntersection = intersectHeightBounds(ray, minMaxHeight, true);\n\
|
|
88
|
+
return intersectIntersections(ray, cylinderIntersection, heightBoundsIntersection);\n\
|
|
109
89
|
}\n\
|
|
110
90
|
\n\
|
|
111
91
|
void intersectShape(Ray ray, inout Intersections ix)\n\
|
|
112
92
|
{\n\
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
// Position is converted from [0,1] to [-1,+1] because shape intersections assume unit space is [-1,+1].\n\
|
|
118
|
-
// Direction is scaled as well to be in sync with position.\n\
|
|
119
|
-
ray.pos = ray.pos * 2.0 - 1.0;\n\
|
|
120
|
-
ray.dir *= 2.0;\n\
|
|
121
|
-
#endif\n\
|
|
93
|
+
// Position is converted from [0,1] to [-1,+1] because shape intersections assume unit space is [-1,+1].\n\
|
|
94
|
+
// Direction is scaled as well to be in sync with position.\n\
|
|
95
|
+
ray.pos = ray.pos * 2.0 - 1.0;\n\
|
|
96
|
+
ray.dir *= 2.0;\n\
|
|
122
97
|
\n\
|
|
123
|
-
|
|
124
|
-
vec2 outerIntersect = intersectUnitCircle(ray);\n\
|
|
125
|
-
#else\n\
|
|
126
|
-
vec2 outerIntersect = intersectUnitCylinder(ray);\n\
|
|
127
|
-
#endif\n\
|
|
98
|
+
RayShapeIntersection outerIntersect = intersectBoundedCylinder(ray, u_cylinderRenderRadiusMinMax.y, u_cylinderRenderHeightMinMax);\n\
|
|
128
99
|
\n\
|
|
129
|
-
|
|
100
|
+
setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_RADIUS_MAX, outerIntersect);\n\
|
|
130
101
|
\n\
|
|
131
|
-
if (outerIntersect.
|
|
102
|
+
if (outerIntersect.entry.w == NO_HIT) {\n\
|
|
132
103
|
return;\n\
|
|
133
104
|
}\n\
|
|
134
105
|
\n\
|
|
@@ -149,15 +120,14 @@ void intersectShape(Ray ray, inout Intersections ix)\n\
|
|
|
149
120
|
\n\
|
|
150
121
|
// Note: If initializeIntersections() changes its sorting function\n\
|
|
151
122
|
// from bubble sort to something else, this code may need to change.\n\
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
123
|
+
RayShapeIntersection innerIntersect = intersectCylinder(ray, 1.0, false);\n\
|
|
124
|
+
setSurfaceIntersection(ix, 0, outerIntersect.entry, true, true); // positive, enter\n\
|
|
125
|
+
setSurfaceIntersection(ix, 1, innerIntersect.entry, false, true); // negative, enter\n\
|
|
126
|
+
setSurfaceIntersection(ix, 2, innerIntersect.exit, false, false); // negative, exit\n\
|
|
127
|
+
setSurfaceIntersection(ix, 3, outerIntersect.exit, true, false); // positive, exit\n\
|
|
157
128
|
#elif defined(CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MIN)\n\
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
setIntersectionPair(ix, CYLINDER_INTERSECTION_INDEX_RADIUS_MIN, innerIntersect);\n\
|
|
129
|
+
RayShapeIntersection innerIntersect = intersectCylinder(ray, u_cylinderRenderRadiusMinMax.x, false);\n\
|
|
130
|
+
setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_RADIUS_MIN, innerIntersect);\n\
|
|
161
131
|
#endif\n\
|
|
162
132
|
\n\
|
|
163
133
|
#if defined(CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_UNDER_HALF)\n\
|