@cesium/engine 7.0.0 → 9.0.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 +1 -5
- package/Build/Workers/{chunk-7XEAYGZK.js → chunk-24YTYWNB.js} +10 -10
- package/Build/Workers/{chunk-IQBYFRVW.js → chunk-2632RVPI.js} +7 -7
- package/Build/Workers/chunk-2KACWKS4.js +501 -0
- package/Build/Workers/{chunk-QZAD5O7I.js → chunk-2XPLH3JY.js} +7 -7
- package/Build/Workers/{chunk-JY5YEZFA.js → chunk-2ZBL3MVO.js} +8 -8
- package/Build/Workers/{chunk-ZK5JOS3D.js → chunk-3NCVAGDA.js} +14 -14
- package/Build/Workers/{chunk-AR5DNBJ4.js → chunk-5R6VWLMH.js} +6 -6
- package/Build/Workers/{chunk-PTQQUQC3.js → chunk-5TIV3L26.js} +13 -13
- package/Build/Workers/{chunk-BZP4T2JJ.js → chunk-6WF3KIF5.js} +10 -10
- package/Build/Workers/{chunk-5WQ523AW.js → chunk-73FKKY52.js} +5 -5
- package/Build/Workers/{chunk-F6SE42BK.js → chunk-7COR472O.js} +15 -472
- package/Build/Workers/{chunk-72SANQJV.js → chunk-ADOVHYWO.js} +9 -5
- package/Build/Workers/{chunk-5YLJ77FF.js → chunk-BCU2LH5T.js} +12 -11
- package/Build/Workers/{chunk-4EBHOMFX.js → chunk-C3XBUYBO.js} +17 -17
- package/Build/Workers/{chunk-IX2JCCNM.js → chunk-C6OI26DR.js} +1 -1
- package/Build/Workers/{chunk-2HJWSU7B.js → chunk-CO35JNNE.js} +4 -4
- package/Build/Workers/{chunk-OVLG3FRS.js → chunk-DGDUKCJJ.js} +6 -6
- package/Build/Workers/{chunk-DTAIXKTO.js → chunk-DPUSFA7S.js} +6 -6
- package/Build/Workers/{chunk-R5X4OQT4.js → chunk-E6WXPSJS.js} +7 -7
- package/Build/Workers/{chunk-VK3EJHWI.js → chunk-EOXYZ34O.js} +2 -2
- package/Build/Workers/{chunk-RAEV7K66.js → chunk-EPKE7GE3.js} +5 -5
- package/Build/Workers/{chunk-GV56Q4LU.js → chunk-GFA4SMXV.js} +11 -11
- package/Build/Workers/{chunk-NKPBIX7F.js → chunk-GXUXEOE2.js} +1 -1
- package/Build/Workers/{chunk-NY3K4IM3.js → chunk-HBQPB6IH.js} +12 -12
- package/Build/Workers/{chunk-6HZQPRUS.js → chunk-I37B3MZ2.js} +1 -1
- package/Build/Workers/{chunk-VRGFV2UO.js → chunk-L4BW3RUA.js} +10 -10
- package/Build/Workers/{chunk-6VJVYK2V.js → chunk-LAQP3SCC.js} +2 -2
- package/Build/Workers/{chunk-PNBGBETF.js → chunk-LQJ5FFFR.js} +10 -10
- package/Build/Workers/{chunk-UAEW6HKG.js → chunk-M2AYBTNH.js} +13 -13
- package/Build/Workers/{chunk-YUCVWAY6.js → chunk-MWV7IZK4.js} +7 -7
- package/Build/Workers/{chunk-JXDC723O.js → chunk-N4KXMWQU.js} +2 -2
- package/Build/Workers/{chunk-XWXM2O2R.js → chunk-NP2GYYE5.js} +6 -6
- package/Build/Workers/{chunk-GEJTYLCO.js → chunk-NZWNZA6S.js} +5 -5
- package/Build/Workers/{chunk-LZGHD6NY.js → chunk-P2YAAMT2.js} +15 -15
- package/Build/Workers/{chunk-S6SKF6DT.js → chunk-P4XKB3QZ.js} +5 -5
- package/Build/Workers/{chunk-U2VCRRQW.js → chunk-PXB7T27O.js} +6 -6
- package/Build/Workers/{chunk-RV7ZYPFT.js → chunk-QCQUZGXI.js} +4 -4
- package/Build/Workers/{chunk-JJ4VBOQ3.js → chunk-QKBGRKKG.js} +4 -4
- package/Build/Workers/{chunk-ODW7WYM4.js → chunk-RMOEYCZW.js} +2 -2
- package/Build/Workers/{chunk-ZUA2UUNV.js → chunk-RSJXEO2A.js} +2 -2
- package/Build/Workers/{chunk-UDO6BFSF.js → chunk-RV7ZOSS6.js} +13 -13
- package/Build/Workers/{chunk-LZ7JIV3K.js → chunk-SE4PXOEA.js} +17 -17
- package/Build/Workers/{chunk-S4MAZ3SS.js → chunk-SS4ESNE3.js} +2 -2
- package/Build/Workers/{chunk-AIPU2VSX.js → chunk-TJBU6GML.js} +6 -6
- package/Build/Workers/{chunk-5M3U6ZMA.js → chunk-TZORKRNK.js} +1 -1
- package/Build/Workers/{chunk-MY3VNFGQ.js → chunk-VR5RBW52.js} +7 -7
- package/Build/Workers/{chunk-FP6GYBFX.js → chunk-WHUSTDIB.js} +10 -10
- package/Build/Workers/{chunk-5HDYHG3F.js → chunk-X2F6BEPY.js} +13 -13
- package/Build/Workers/{chunk-WZU2YLWG.js → chunk-X6XOMPWL.js} +3 -3
- package/Build/Workers/{chunk-UGK3FCDY.js → chunk-YDVSBWEO.js} +1 -1
- package/Build/Workers/{chunk-46UD5ABS.js → chunk-YV4H2Y7M.js} +4 -4
- package/Build/Workers/{chunk-WBQCVXR3.js → chunk-Z7FQLK6N.js} +4 -4
- package/Build/Workers/{chunk-L2ZN645J.js → chunk-ZNVSKMQ2.js} +6 -6
- package/Build/Workers/{chunk-JCNXK6EL.js → chunk-ZYPTP7GS.js} +11 -11
- package/Build/Workers/combineGeometry.js +24 -23
- package/Build/Workers/createBoxGeometry.js +18 -17
- package/Build/Workers/createBoxOutlineGeometry.js +16 -15
- package/Build/Workers/createCircleGeometry.js +26 -25
- package/Build/Workers/createCircleOutlineGeometry.js +19 -18
- package/Build/Workers/createCoplanarPolygonGeometry.js +33 -32
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -30
- package/Build/Workers/createCorridorGeometry.js +29 -28
- package/Build/Workers/createCorridorOutlineGeometry.js +28 -27
- package/Build/Workers/createCylinderGeometry.js +20 -19
- package/Build/Workers/createCylinderOutlineGeometry.js +18 -17
- package/Build/Workers/createEllipseGeometry.js +26 -25
- package/Build/Workers/createEllipseOutlineGeometry.js +19 -18
- package/Build/Workers/createEllipsoidGeometry.js +19 -18
- package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -17
- package/Build/Workers/createFrustumGeometry.js +18 -17
- package/Build/Workers/createFrustumOutlineGeometry.js +18 -17
- package/Build/Workers/createGeometry.js +54 -33
- package/Build/Workers/createGroundPolylineGeometry.js +22 -21
- package/Build/Workers/createPlaneGeometry.js +16 -15
- package/Build/Workers/createPlaneOutlineGeometry.js +15 -14
- package/Build/Workers/createPolygonGeometry.js +33 -32
- package/Build/Workers/createPolygonOutlineGeometry.js +30 -29
- package/Build/Workers/createPolylineGeometry.js +25 -24
- package/Build/Workers/createPolylineVolumeGeometry.js +31 -30
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -26
- package/Build/Workers/createRectangleGeometry.js +27 -26
- package/Build/Workers/createRectangleOutlineGeometry.js +20 -19
- package/Build/Workers/createSimplePolylineGeometry.js +23 -22
- package/Build/Workers/createSphereGeometry.js +19 -18
- package/Build/Workers/createSphereOutlineGeometry.js +18 -17
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
- package/Build/Workers/createVectorTileGeometries.js +24 -23
- package/Build/Workers/createVectorTilePoints.js +12 -12
- package/Build/Workers/createVectorTilePolygons.js +22 -21
- package/Build/Workers/createVectorTilePolylines.js +14 -14
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -21
- package/Build/Workers/createVerticesFromHeightmap.js +22 -21
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +19 -18
- package/Build/Workers/createWallGeometry.js +24 -23
- package/Build/Workers/createWallOutlineGeometry.js +23 -22
- package/Build/Workers/decodeDraco.js +11 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +601 -92
- package/Build/Workers/transcodeKTX2.js +7 -7
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -21
- package/Source/Core/Check.d.ts +127 -0
- package/Source/Core/Check.js +0 -1
- package/Source/Core/Ellipsoid.js +6 -0
- package/Source/Core/Geometry.js +1 -1
- package/Source/Core/IntersectionTests.js +6 -3
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/PixelFormat.js +5 -0
- package/Source/Core/PolygonGeometry.js +1 -1
- package/Source/Core/Transforms.js +3 -0
- package/Source/Core/VerticalExaggeration.js +2 -1
- package/Source/Core/srgbToLinear.js +32 -0
- package/Source/DataSources/CzmlDataSource.js +51 -23
- package/Source/DataSources/DataSourceDisplay.js +27 -0
- package/Source/DataSources/Entity.js +20 -2
- package/Source/DataSources/GeometryUpdaterSet.js +114 -0
- package/Source/DataSources/GeometryVisualizer.js +19 -83
- package/Source/Renderer/Context.js +10 -0
- package/Source/Renderer/ContextLimits.js +2 -0
- package/Source/Renderer/demodernizeShader.js +4 -1
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Axis.js +12 -7
- package/Source/Scene/Billboard.js +32 -0
- package/Source/Scene/BillboardCollection.js +1 -1
- package/Source/Scene/BingMapsImageryProvider.js +4 -0
- package/Source/Scene/Camera.js +46 -4
- package/Source/Scene/Cesium3DTilesVoxelProvider.js +2 -9
- package/Source/Scene/Cesium3DTileset.js +10 -7
- package/Source/Scene/Cesium3DTilesetBaseTraversal.js +2 -4
- package/Source/Scene/FrameState.js +5 -0
- package/Source/Scene/Globe.js +0 -67
- package/Source/Scene/GlobeTranslucencyState.js +1 -1
- package/Source/Scene/GltfPipeline/updateVersion.js +69 -68
- package/Source/Scene/I3SDataProvider.js +270 -53
- package/Source/Scene/I3SDecoder.js +8 -1
- package/Source/Scene/I3SFeature.js +2 -5
- package/Source/Scene/I3SField.js +136 -31
- package/Source/Scene/I3SGeometry.js +70 -2
- package/Source/Scene/I3SLayer.js +55 -10
- package/Source/Scene/I3SNode.js +175 -18
- package/Source/Scene/I3SStatistics.js +94 -0
- package/Source/Scene/I3SSublayer.js +176 -0
- package/Source/Scene/I3SSymbology.js +337 -0
- package/Source/Scene/KeyframeNode.js +1 -1
- package/Source/Scene/Label.js +33 -0
- package/Source/Scene/LabelCollection.js +2 -1
- package/Source/Scene/Model/pickModel.js +25 -7
- package/Source/Scene/PickFramebuffer.js +37 -2
- package/Source/Scene/Picking.js +113 -39
- package/Source/Scene/Primitive.js +6 -5
- package/Source/Scene/Scene.js +126 -42
- package/Source/Scene/ScreenSpaceCameraController.js +21 -7
- package/Source/Scene/SensorVolumePortionToDisplay.js +69 -0
- package/Source/Scene/SpatialNode.js +12 -19
- package/Source/Scene/StructuralMetadata.js +1 -1
- package/Source/Scene/VoxelBoxShape.js +67 -6
- package/Source/Scene/VoxelCell.js +273 -0
- package/Source/Scene/VoxelCylinderShape.js +117 -163
- package/Source/Scene/VoxelEllipsoidShape.js +255 -304
- package/Source/Scene/VoxelPrimitive.js +109 -15
- package/Source/Scene/VoxelRenderResources.js +12 -3
- package/Source/Scene/VoxelShape.js +7 -4
- package/Source/Scene/VoxelTraversal.js +76 -54
- package/Source/Scene/buildVoxelDrawCommands.js +23 -0
- package/Source/Scene/createGooglePhotorealistic3DTileset.js +1 -0
- package/Source/Scene/processVoxelProperties.js +3 -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 +76 -203
- package/Source/Shaders/Voxels/IntersectCylinder.js +76 -203
- package/Source/Shaders/Voxels/IntersectEllipsoid.glsl +220 -229
- package/Source/Shaders/Voxels/IntersectEllipsoid.js +220 -229
- package/Source/Shaders/Voxels/IntersectLongitude.glsl +102 -0
- package/Source/Shaders/Voxels/IntersectLongitude.js +104 -0
- 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 +128 -40
- package/Source/Shaders/Voxels/VoxelFS.js +128 -40
- 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 +64 -40
- package/Source/Shaders/Voxels/convertUvToCylinder.js +64 -40
- package/Source/Shaders/Voxels/convertUvToEllipsoid.glsl +100 -91
- package/Source/Shaders/Voxels/convertUvToEllipsoid.js +100 -91
- package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
- package/Source/Workers/createGeometry.js +40 -11
- package/Source/Workers/decodeI3S.js +720 -94
- package/index.d.ts +542 -40
- package/index.js +75 -66
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// See IntersectionUtils.glsl for the definitions of Ray
|
|
2
|
-
//
|
|
1
|
+
// See IntersectionUtils.glsl for the definitions of Ray, RayShapeIntersection,
|
|
2
|
+
// NO_HIT, Intersections
|
|
3
3
|
|
|
4
4
|
/* Box defines (set in Scene/VoxelBoxShape.js)
|
|
5
5
|
#define BOX_INTERSECTION_INDEX ### // always 0
|
|
@@ -8,66 +8,40 @@
|
|
|
8
8
|
uniform vec3 u_renderMinBounds;
|
|
9
9
|
uniform vec3 u_renderMaxBounds;
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
vec3 p0;
|
|
13
|
-
vec3 p1;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
Box constructVoxelBox(in ivec4 octreeCoords, in vec3 tileUv)
|
|
17
|
-
{
|
|
18
|
-
// Find the min/max cornerpoints of the voxel in tile coordinates
|
|
19
|
-
vec3 tileOrigin = vec3(octreeCoords.xyz);
|
|
20
|
-
vec3 numSamples = vec3(u_dimensions);
|
|
21
|
-
vec3 voxelSize = 1.0 / numSamples;
|
|
22
|
-
vec3 coordP0 = floor(tileUv * numSamples) * voxelSize + tileOrigin;
|
|
23
|
-
vec3 coordP1 = coordP0 + voxelSize;
|
|
24
|
-
|
|
25
|
-
// Transform to the UV coordinates of the scaled tileset
|
|
26
|
-
float tileSize = 1.0 / pow(2.0, float(octreeCoords.w));
|
|
27
|
-
vec3 p0 = convertShapeUvToUvSpace(coordP0 * tileSize);
|
|
28
|
-
vec3 p1 = convertShapeUvToUvSpace(coordP1 * tileSize);
|
|
29
|
-
|
|
30
|
-
return Box(p0, p1);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
vec3 getBoxNormal(in Box box, in Ray ray, in float t)
|
|
34
|
-
{
|
|
35
|
-
vec3 hitPoint = ray.pos + t * ray.dir;
|
|
36
|
-
vec3 lower = step(hitPoint, box.p0);
|
|
37
|
-
vec3 upper = step(box.p1, hitPoint);
|
|
38
|
-
return normalize(upper - lower);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Find the distances along a ray at which the ray intersects an axis-aligned box
|
|
42
|
-
// See https://tavianator.com/2011/ray_box.html
|
|
43
|
-
RayShapeIntersection intersectBox(in Ray ray, in Box box)
|
|
11
|
+
RayShapeIntersection intersectBox(in Ray ray, in vec3 minBound, in vec3 maxBound)
|
|
44
12
|
{
|
|
45
13
|
// Consider the box as the intersection of the space between 3 pairs of parallel planes
|
|
46
14
|
// Compute the distance along the ray to each plane
|
|
47
|
-
vec3 t0 = (
|
|
48
|
-
vec3 t1 = (
|
|
15
|
+
vec3 t0 = (minBound - ray.pos) / ray.dir;
|
|
16
|
+
vec3 t1 = (maxBound - ray.pos) / ray.dir;
|
|
49
17
|
|
|
50
18
|
// Identify candidate entries/exits based on distance from ray.pos
|
|
51
19
|
vec3 entries = min(t0, t1);
|
|
52
20
|
vec3 exits = max(t0, t1);
|
|
53
21
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
22
|
+
vec3 directions = sign(ray.dir);
|
|
23
|
+
|
|
24
|
+
// The actual intersection points are the furthest entry and the closest exit
|
|
25
|
+
float lastEntry = maxComponent(entries);
|
|
26
|
+
bvec3 isLastEntry = equal(entries, vec3(lastEntry));
|
|
27
|
+
vec3 entryNormal = -1.0 * vec3(isLastEntry) * directions;
|
|
28
|
+
vec4 entry = vec4(entryNormal, lastEntry);
|
|
57
29
|
|
|
58
|
-
|
|
59
|
-
|
|
30
|
+
float firstExit = minComponent(exits);
|
|
31
|
+
bvec3 isFirstExit = equal(exits, vec3(firstExit));
|
|
32
|
+
vec3 exitNormal = vec3(isLastEntry) * directions;
|
|
33
|
+
vec4 exit = vec4(exitNormal, firstExit);
|
|
60
34
|
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
35
|
+
if (entry.w > exit.w) {
|
|
36
|
+
entry.w = NO_HIT;
|
|
37
|
+
exit.w = NO_HIT;
|
|
64
38
|
}
|
|
65
39
|
|
|
66
|
-
return RayShapeIntersection(
|
|
40
|
+
return RayShapeIntersection(entry, exit);
|
|
67
41
|
}
|
|
68
42
|
|
|
69
43
|
void intersectShape(in Ray ray, inout Intersections ix)
|
|
70
44
|
{
|
|
71
|
-
RayShapeIntersection intersection = intersectBox(ray,
|
|
45
|
+
RayShapeIntersection intersection = intersectBox(ray, u_renderMinBounds, u_renderMaxBounds);
|
|
72
46
|
setShapeIntersection(ix, BOX_INTERSECTION_INDEX, intersection);
|
|
73
47
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
-
export default "// See IntersectionUtils.glsl for the definitions of Ray
|
|
3
|
-
//
|
|
2
|
+
export default "// See IntersectionUtils.glsl for the definitions of Ray, RayShapeIntersection,\n\
|
|
3
|
+
// NO_HIT, Intersections\n\
|
|
4
4
|
\n\
|
|
5
5
|
/* Box defines (set in Scene/VoxelBoxShape.js)\n\
|
|
6
6
|
#define BOX_INTERSECTION_INDEX ### // always 0\n\
|
|
@@ -9,67 +9,41 @@ export default "// See IntersectionUtils.glsl for the definitions of Ray and NO_
|
|
|
9
9
|
uniform vec3 u_renderMinBounds;\n\
|
|
10
10
|
uniform vec3 u_renderMaxBounds;\n\
|
|
11
11
|
\n\
|
|
12
|
-
|
|
13
|
-
vec3 p0;\n\
|
|
14
|
-
vec3 p1;\n\
|
|
15
|
-
};\n\
|
|
16
|
-
\n\
|
|
17
|
-
Box constructVoxelBox(in ivec4 octreeCoords, in vec3 tileUv)\n\
|
|
18
|
-
{\n\
|
|
19
|
-
// Find the min/max cornerpoints of the voxel in tile coordinates\n\
|
|
20
|
-
vec3 tileOrigin = vec3(octreeCoords.xyz);\n\
|
|
21
|
-
vec3 numSamples = vec3(u_dimensions);\n\
|
|
22
|
-
vec3 voxelSize = 1.0 / numSamples;\n\
|
|
23
|
-
vec3 coordP0 = floor(tileUv * numSamples) * voxelSize + tileOrigin;\n\
|
|
24
|
-
vec3 coordP1 = coordP0 + voxelSize;\n\
|
|
25
|
-
\n\
|
|
26
|
-
// Transform to the UV coordinates of the scaled tileset\n\
|
|
27
|
-
float tileSize = 1.0 / pow(2.0, float(octreeCoords.w));\n\
|
|
28
|
-
vec3 p0 = convertShapeUvToUvSpace(coordP0 * tileSize);\n\
|
|
29
|
-
vec3 p1 = convertShapeUvToUvSpace(coordP1 * tileSize);\n\
|
|
30
|
-
\n\
|
|
31
|
-
return Box(p0, p1);\n\
|
|
32
|
-
}\n\
|
|
33
|
-
\n\
|
|
34
|
-
vec3 getBoxNormal(in Box box, in Ray ray, in float t)\n\
|
|
35
|
-
{\n\
|
|
36
|
-
vec3 hitPoint = ray.pos + t * ray.dir;\n\
|
|
37
|
-
vec3 lower = step(hitPoint, box.p0);\n\
|
|
38
|
-
vec3 upper = step(box.p1, hitPoint);\n\
|
|
39
|
-
return normalize(upper - lower);\n\
|
|
40
|
-
}\n\
|
|
41
|
-
\n\
|
|
42
|
-
// Find the distances along a ray at which the ray intersects an axis-aligned box\n\
|
|
43
|
-
// See https://tavianator.com/2011/ray_box.html\n\
|
|
44
|
-
RayShapeIntersection intersectBox(in Ray ray, in Box box)\n\
|
|
12
|
+
RayShapeIntersection intersectBox(in Ray ray, in vec3 minBound, in vec3 maxBound)\n\
|
|
45
13
|
{\n\
|
|
46
14
|
// Consider the box as the intersection of the space between 3 pairs of parallel planes\n\
|
|
47
15
|
// Compute the distance along the ray to each plane\n\
|
|
48
|
-
vec3 t0 = (
|
|
49
|
-
vec3 t1 = (
|
|
16
|
+
vec3 t0 = (minBound - ray.pos) / ray.dir;\n\
|
|
17
|
+
vec3 t1 = (maxBound - ray.pos) / ray.dir;\n\
|
|
50
18
|
\n\
|
|
51
19
|
// Identify candidate entries/exits based on distance from ray.pos\n\
|
|
52
20
|
vec3 entries = min(t0, t1);\n\
|
|
53
21
|
vec3 exits = max(t0, t1);\n\
|
|
54
22
|
\n\
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
23
|
+
vec3 directions = sign(ray.dir);\n\
|
|
24
|
+
\n\
|
|
25
|
+
// The actual intersection points are the furthest entry and the closest exit\n\
|
|
26
|
+
float lastEntry = maxComponent(entries);\n\
|
|
27
|
+
bvec3 isLastEntry = equal(entries, vec3(lastEntry));\n\
|
|
28
|
+
vec3 entryNormal = -1.0 * vec3(isLastEntry) * directions;\n\
|
|
29
|
+
vec4 entry = vec4(entryNormal, lastEntry);\n\
|
|
58
30
|
\n\
|
|
59
|
-
|
|
60
|
-
|
|
31
|
+
float firstExit = minComponent(exits);\n\
|
|
32
|
+
bvec3 isFirstExit = equal(exits, vec3(firstExit));\n\
|
|
33
|
+
vec3 exitNormal = vec3(isLastEntry) * directions;\n\
|
|
34
|
+
vec4 exit = vec4(exitNormal, firstExit);\n\
|
|
61
35
|
\n\
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
|
|
36
|
+
if (entry.w > exit.w) {\n\
|
|
37
|
+
entry.w = NO_HIT;\n\
|
|
38
|
+
exit.w = NO_HIT;\n\
|
|
65
39
|
}\n\
|
|
66
40
|
\n\
|
|
67
|
-
return RayShapeIntersection(
|
|
41
|
+
return RayShapeIntersection(entry, exit);\n\
|
|
68
42
|
}\n\
|
|
69
43
|
\n\
|
|
70
44
|
void intersectShape(in Ray ray, inout Intersections ix)\n\
|
|
71
45
|
{\n\
|
|
72
|
-
RayShapeIntersection intersection = intersectBox(ray,
|
|
46
|
+
RayShapeIntersection intersection = intersectBox(ray, u_renderMinBounds, u_renderMaxBounds);\n\
|
|
73
47
|
setShapeIntersection(ix, BOX_INTERSECTION_INDEX, intersection);\n\
|
|
74
48
|
}\n\
|
|
75
49
|
";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//This file is automatically rebuilt by the Cesium build process.
|
|
2
2
|
export default "// See IntersectionUtils.glsl for the definitions of Ray, Intersections, INF_HIT,\n\
|
|
3
|
-
// NO_HIT,
|
|
3
|
+
// NO_HIT, setShapeIntersection\n\
|
|
4
4
|
\n\
|
|
5
5
|
/* Clipping plane defines (set in Scene/VoxelRenderResources.js)\n\
|
|
6
6
|
#define CLIPPING_PLANES_UNION\n\
|
|
@@ -1,229 +1,104 @@
|
|
|
1
|
-
// See IntersectionUtils.glsl for the definitions of Ray,
|
|
2
|
-
//
|
|
1
|
+
// See IntersectionUtils.glsl for the definitions of Ray, NO_HIT, Intersections,
|
|
2
|
+
// RayShapeIntersection, setSurfaceIntersection, setShapeIntersection,
|
|
3
|
+
// intersectIntersections
|
|
4
|
+
// See IntersectLongitude.glsl for the definitions of intersectHalfPlane,
|
|
5
|
+
// intersectFlippedWedge, intersectRegularWedge
|
|
3
6
|
|
|
4
7
|
/* Cylinder defines (set in Scene/VoxelCylinderShape.js)
|
|
5
8
|
#define CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MIN
|
|
6
|
-
#define CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MAX
|
|
7
9
|
#define CYLINDER_HAS_RENDER_BOUNDS_RADIUS_FLAT
|
|
8
|
-
#define CYLINDER_HAS_RENDER_BOUNDS_HEIGHT
|
|
9
|
-
#define CYLINDER_HAS_RENDER_BOUNDS_HEIGHT_FLAT
|
|
10
10
|
#define CYLINDER_HAS_RENDER_BOUNDS_ANGLE
|
|
11
11
|
#define CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_UNDER_HALF
|
|
12
12
|
#define CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_OVER_HALF
|
|
13
|
-
#define CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_EQUAL_HALF
|
|
14
13
|
#define CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_EQUAL_ZERO
|
|
15
14
|
|
|
16
|
-
#define CYLINDER_HAS_SHAPE_BOUNDS_RADIUS
|
|
17
|
-
#define CYLINDER_HAS_SHAPE_BOUNDS_RADIUS_FLAT
|
|
18
|
-
#define CYLINDER_HAS_SHAPE_BOUNDS_HEIGHT
|
|
19
|
-
#define CYLINDER_HAS_SHAPE_BOUNDS_HEIGHT_FLAT
|
|
20
|
-
#define CYLINDER_HAS_SHAPE_BOUNDS_ANGLE
|
|
21
|
-
#define CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_RANGE_EQUAL_ZERO
|
|
22
|
-
#define CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_MIN_DISCONTINUITY
|
|
23
|
-
#define CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_MAX_DISCONTINUITY
|
|
24
|
-
#define CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_MIN_MAX_REVERSED
|
|
25
|
-
|
|
26
15
|
#define CYLINDER_INTERSECTION_INDEX_RADIUS_MAX
|
|
27
16
|
#define CYLINDER_INTERSECTION_INDEX_RADIUS_MIN
|
|
28
17
|
#define CYLINDER_INTERSECTION_INDEX_ANGLE
|
|
29
18
|
*/
|
|
30
19
|
|
|
31
20
|
// Cylinder uniforms
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
uniform vec3 u_cylinderUvToRenderBoundsTranslate;
|
|
35
|
-
#endif
|
|
36
|
-
#if defined(CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MIN) && !defined(CYLINDER_HAS_RENDER_BOUNDS_RADIUS_FLAT)
|
|
37
|
-
uniform float u_cylinderUvToRenderRadiusMin;
|
|
38
|
-
#endif
|
|
21
|
+
uniform vec2 u_cylinderRenderRadiusMinMax;
|
|
22
|
+
uniform vec2 u_cylinderRenderHeightMinMax;
|
|
39
23
|
#if defined(CYLINDER_HAS_RENDER_BOUNDS_ANGLE)
|
|
40
24
|
uniform vec2 u_cylinderRenderAngleMinMax;
|
|
41
25
|
#endif
|
|
42
26
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
vec2 planeNormal = vec2(planeDirection.y, -planeDirection.x);
|
|
48
|
-
|
|
49
|
-
float a = dot(o, planeNormal);
|
|
50
|
-
float b = dot(d, planeNormal);
|
|
51
|
-
float t = -a / b;
|
|
52
|
-
|
|
53
|
-
vec2 p = o + t * d;
|
|
54
|
-
bool outside = dot(p, planeDirection) < 0.0;
|
|
55
|
-
if (outside) return vec4(-INF_HIT, +INF_HIT, NO_HIT, NO_HIT);
|
|
56
|
-
|
|
57
|
-
return vec4(-INF_HIT, t, t, +INF_HIT);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
#define POSITIVE_HIT vec2(t, +INF_HIT);
|
|
61
|
-
#define NEGATIVE_HIT vec2(-INF_HIT, t);
|
|
62
|
-
|
|
63
|
-
vec2 intersectHalfSpace(Ray ray, float angle)
|
|
64
|
-
{
|
|
65
|
-
vec2 o = ray.pos.xy;
|
|
66
|
-
vec2 d = ray.dir.xy;
|
|
67
|
-
vec2 n = vec2(sin(angle), -cos(angle));
|
|
68
|
-
|
|
69
|
-
float a = dot(o, n);
|
|
70
|
-
float b = dot(d, n);
|
|
71
|
-
float t = -a / b;
|
|
72
|
-
float s = sign(a);
|
|
73
|
-
|
|
74
|
-
// Half space cuts right through the camera, pick the side to intersect
|
|
75
|
-
if (a == 0.0) {
|
|
76
|
-
if (b >= 0.0) {
|
|
77
|
-
return POSITIVE_HIT;
|
|
78
|
-
} else {
|
|
79
|
-
return NEGATIVE_HIT;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (t >= 0.0 != s >= 0.0) {
|
|
84
|
-
return POSITIVE_HIT;
|
|
85
|
-
} else {
|
|
86
|
-
return NEGATIVE_HIT;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
vec2 intersectRegularWedge(Ray ray, float minAngle, float maxAngle)
|
|
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)
|
|
91
31
|
{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
vec2 n1 = vec2(sin(minAngle), -cos(minAngle));
|
|
95
|
-
vec2 n2 = vec2(-sin(maxAngle), cos(maxAngle));
|
|
96
|
-
|
|
97
|
-
float a1 = dot(o, n1);
|
|
98
|
-
float a2 = dot(o, n2);
|
|
99
|
-
float b1 = dot(d, n1);
|
|
100
|
-
float b2 = dot(d, n2);
|
|
32
|
+
float zPosition = ray.pos.z;
|
|
33
|
+
float zDirection = ray.dir.z;
|
|
101
34
|
|
|
102
|
-
float
|
|
103
|
-
float
|
|
104
|
-
float s1 = sign(a1);
|
|
105
|
-
float s2 = sign(a2);
|
|
35
|
+
float tmin = (minMaxHeight.x - zPosition) / zDirection;
|
|
36
|
+
float tmax = (minMaxHeight.y - zPosition) / zDirection;
|
|
106
37
|
|
|
107
|
-
|
|
108
|
-
float
|
|
109
|
-
|
|
110
|
-
|
|
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);
|
|
111
42
|
|
|
112
|
-
bool
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
bool h = smax >= 0.0;
|
|
43
|
+
bool topEntry = zDirection < 0.0;
|
|
44
|
+
vec4 entry = topEntry ? intersectMax : intersectMin;
|
|
45
|
+
vec4 exit = topEntry ? intersectMin : intersectMax;
|
|
116
46
|
|
|
117
|
-
|
|
118
|
-
else if (e == g && f == h) return vec2(-INF_HIT, tmin);
|
|
119
|
-
else if (e != g && f != h) return vec2(tmax, +INF_HIT);
|
|
120
|
-
else return vec2(NO_HIT);
|
|
47
|
+
return RayShapeIntersection(entry, exit);
|
|
121
48
|
}
|
|
122
49
|
|
|
123
|
-
|
|
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)
|
|
124
55
|
{
|
|
125
|
-
vec2
|
|
126
|
-
vec2
|
|
127
|
-
return vec4(planeIntersectMin, planeIntersectMax);
|
|
128
|
-
}
|
|
56
|
+
vec2 position = ray.pos.xy;
|
|
57
|
+
vec2 direction = ray.dir.xy;
|
|
129
58
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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;
|
|
134
63
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
float det = b * b - a * c;
|
|
139
|
-
|
|
140
|
-
if (det < 0.0) {
|
|
141
|
-
return vec2(NO_HIT);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
det = sqrt(det);
|
|
145
|
-
float ta = (-b - det) / a;
|
|
146
|
-
float tb = (-b + det) / a;
|
|
147
|
-
float t1 = min(ta, tb);
|
|
148
|
-
float t2 = max(ta, tb);
|
|
149
|
-
|
|
150
|
-
float z1 = o.z + t1 * d.z;
|
|
151
|
-
float z2 = o.z + t2 * d.z;
|
|
152
|
-
|
|
153
|
-
if (abs(z1) >= 1.0)
|
|
154
|
-
{
|
|
155
|
-
float tCap = (sign(z1) - o.z) / d.z;
|
|
156
|
-
t1 = abs(b + a * tCap) < det ? tCap : NO_HIT;
|
|
64
|
+
if (determinant < 0.0) {
|
|
65
|
+
vec4 miss = vec4(normalize(ray.dir), NO_HIT);
|
|
66
|
+
return RayShapeIntersection(miss, miss);
|
|
157
67
|
}
|
|
158
68
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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);
|
|
164
75
|
|
|
165
|
-
return
|
|
76
|
+
return RayShapeIntersection(intersect1, intersect2);
|
|
166
77
|
}
|
|
167
78
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
vec2 zPlanePos = o.xy + d.xy * t;
|
|
174
|
-
float distSqr = dot(zPlanePos, zPlanePos);
|
|
175
|
-
|
|
176
|
-
if (distSqr > 1.0) {
|
|
177
|
-
return vec2(NO_HIT);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return vec2(t, t);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
vec2 intersectInfiniteUnitCylinder(Ray ray)
|
|
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)
|
|
184
84
|
{
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
float a = dot(d.xy, d.xy);
|
|
189
|
-
float b = dot(o.xy, d.xy);
|
|
190
|
-
float c = dot(o.xy, o.xy) - 1.0;
|
|
191
|
-
float det = b * b - a * c;
|
|
192
|
-
|
|
193
|
-
if (det < 0.0) {
|
|
194
|
-
return vec2(NO_HIT);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
det = sqrt(det);
|
|
198
|
-
float t1 = (-b - det) / a;
|
|
199
|
-
float t2 = (-b + det) / a;
|
|
200
|
-
float tmin = min(t1, t2);
|
|
201
|
-
float tmax = max(t1, t2);
|
|
202
|
-
|
|
203
|
-
return vec2(tmin, tmax);
|
|
85
|
+
RayShapeIntersection cylinderIntersection = intersectCylinder(ray, radius, true);
|
|
86
|
+
RayShapeIntersection heightBoundsIntersection = intersectHeightBounds(ray, minMaxHeight, true);
|
|
87
|
+
return intersectIntersections(ray, cylinderIntersection, heightBoundsIntersection);
|
|
204
88
|
}
|
|
205
89
|
|
|
206
90
|
void intersectShape(Ray ray, inout Intersections ix)
|
|
207
91
|
{
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
// Position is converted from [0,1] to [-1,+1] because shape intersections assume unit space is [-1,+1].
|
|
213
|
-
// Direction is scaled as well to be in sync with position.
|
|
214
|
-
ray.pos = ray.pos * 2.0 - 1.0;
|
|
215
|
-
ray.dir *= 2.0;
|
|
216
|
-
#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;
|
|
217
96
|
|
|
218
|
-
|
|
219
|
-
vec2 outerIntersect = intersectUnitCircle(ray);
|
|
220
|
-
#else
|
|
221
|
-
vec2 outerIntersect = intersectUnitCylinder(ray);
|
|
222
|
-
#endif
|
|
97
|
+
RayShapeIntersection outerIntersect = intersectBoundedCylinder(ray, u_cylinderRenderRadiusMinMax.y, u_cylinderRenderHeightMinMax);
|
|
223
98
|
|
|
224
|
-
|
|
99
|
+
setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_RADIUS_MAX, outerIntersect);
|
|
225
100
|
|
|
226
|
-
if (outerIntersect.
|
|
101
|
+
if (outerIntersect.entry.w == NO_HIT) {
|
|
227
102
|
return;
|
|
228
103
|
}
|
|
229
104
|
|
|
@@ -244,30 +119,28 @@ void intersectShape(Ray ray, inout Intersections ix)
|
|
|
244
119
|
|
|
245
120
|
// Note: If initializeIntersections() changes its sorting function
|
|
246
121
|
// from bubble sort to something else, this code may need to change.
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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
|
|
252
127
|
#elif defined(CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MIN)
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
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);
|
|
256
130
|
#endif
|
|
257
131
|
|
|
258
132
|
#if defined(CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_UNDER_HALF)
|
|
259
|
-
|
|
260
|
-
|
|
133
|
+
RayShapeIntersection wedgeIntersect = intersectRegularWedge(ray, u_cylinderRenderAngleMinMax);
|
|
134
|
+
setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_ANGLE, wedgeIntersect);
|
|
261
135
|
#elif defined(CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_OVER_HALF)
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
vec2 wedgeIntersect = intersectHalfSpace(ray, u_cylinderRenderAngleMinMax.x);
|
|
267
|
-
setIntersectionPair(ix, CYLINDER_INTERSECTION_INDEX_ANGLE, wedgeIntersect);
|
|
136
|
+
RayShapeIntersection wedgeIntersects[2];
|
|
137
|
+
intersectFlippedWedge(ray, u_cylinderRenderAngleMinMax, wedgeIntersects);
|
|
138
|
+
setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_ANGLE + 0, wedgeIntersects[0]);
|
|
139
|
+
setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_ANGLE + 1, wedgeIntersects[1]);
|
|
268
140
|
#elif defined(CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_EQUAL_ZERO)
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
141
|
+
RayShapeIntersection wedgeIntersects[2];
|
|
142
|
+
intersectHalfPlane(ray, u_cylinderRenderAngleMinMax.x, wedgeIntersects);
|
|
143
|
+
setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_ANGLE + 0, wedgeIntersects[0]);
|
|
144
|
+
setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_ANGLE + 1, wedgeIntersects[1]);
|
|
272
145
|
#endif
|
|
273
146
|
}
|