@cesium/engine 20.0.2-ion.0 → 21.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/zip-web-worker.js +637 -0
- package/Build/Workers/{chunk-WZKTQZUW.js → chunk-2T4WAVWX.js} +6 -6
- package/Build/Workers/{chunk-6LULWCX3.js → chunk-3G5XEUPY.js} +1 -1
- package/Build/Workers/{chunk-OIMV4OE5.js → chunk-3MSNTCHW.js} +9 -9
- package/Build/Workers/{chunk-VZNF2GT7.js → chunk-3OPG2FGI.js} +4 -4
- package/Build/Workers/{chunk-MTBXKKSQ.js → chunk-3PUG3T2H.js} +12 -12
- package/Build/Workers/{chunk-XWRUYDF6.js → chunk-4PH27XAL.js} +2 -2
- package/Build/Workers/{chunk-P2V7PVDH.js → chunk-4VJYMLR6.js} +8 -8
- package/Build/Workers/{chunk-MFXTB5I4.js → chunk-5B3PGBQW.js} +11 -11
- package/Build/Workers/{chunk-USK6ZAY2.js → chunk-5GHCWGC4.js} +1 -1
- package/Build/Workers/{chunk-AHFTST3Q.js → chunk-5PEQUMCB.js} +12 -12
- package/Build/Workers/{chunk-23B3EYUM.js → chunk-64WSG7AT.js} +4 -4
- package/Build/Workers/{chunk-CEA3L7M7.js → chunk-6J6WGCWP.js} +4 -4
- package/Build/Workers/{chunk-VSMKMGX4.js → chunk-75B34CC6.js} +5 -5
- package/Build/Workers/{chunk-IS5FETN7.js → chunk-7PLX65MV.js} +5 -5
- package/Build/Workers/{chunk-FNUSHLOY.js → chunk-AR2FUSG6.js} +1 -1
- package/Build/Workers/{chunk-VLGVUVJY.js → chunk-ARYRHDEB.js} +6 -6
- package/Build/Workers/{chunk-FHLPYFIW.js → chunk-B7INTBBB.js} +13 -13
- package/Build/Workers/{chunk-BHAATGZA.js → chunk-BDPSQXLX.js} +5 -5
- package/Build/Workers/{chunk-QZGZIAK2.js → chunk-BU4CGMHO.js} +6 -6
- package/Build/Workers/{chunk-YNPZU55A.js → chunk-BUBVUXDO.js} +6 -6
- package/Build/Workers/{chunk-LS63ERFB.js → chunk-CF72FAKC.js} +4 -4
- package/Build/Workers/{chunk-D4XRQNUO.js → chunk-DJ4ROETJ.js} +5 -5
- package/Build/Workers/{chunk-ABTG74AR.js → chunk-E5XCZVIY.js} +1 -1
- package/Build/Workers/{chunk-AFKNTEMH.js → chunk-EAYW4CFP.js} +16 -16
- package/Build/Workers/{chunk-YXTWHLJA.js → chunk-EHFMZFVC.js} +4 -4
- package/Build/Workers/{chunk-H7HFDM3G.js → chunk-FFCKCQPK.js} +5 -5
- package/Build/Workers/{chunk-V6ZGOX4I.js → chunk-GKCZ2G36.js} +7 -7
- package/Build/Workers/{chunk-VODCZKV2.js → chunk-HJ7IZBEI.js} +4 -4
- package/Build/Workers/{chunk-66MGJQFZ.js → chunk-JJZWDROM.js} +2 -2
- package/Build/Workers/{chunk-F4PS6RFF.js → chunk-JUOEBO4F.js} +10 -10
- package/Build/Workers/{chunk-WORBFT5H.js → chunk-K4IDXMIZ.js} +9 -9
- package/Build/Workers/{chunk-Q3OWKSC5.js → chunk-LL6HN3W4.js} +10 -10
- package/Build/Workers/{chunk-YUHWFX5H.js → chunk-LNTUIO55.js} +2 -2
- package/Build/Workers/{chunk-VA7LWA5Q.js → chunk-LWOCFJEH.js} +9 -9
- package/Build/Workers/{chunk-5DF5RVIO.js → chunk-MMUISYW4.js} +16 -16
- package/Build/Workers/{chunk-K6THSIDU.js → chunk-MXYW4BQ3.js} +2 -2
- package/Build/Workers/{chunk-X55ZOYMS.js → chunk-N6DVKXZD.js} +12 -12
- package/Build/Workers/{chunk-NKKNQMEH.js → chunk-NP46ZIBY.js} +3 -3
- package/Build/Workers/{chunk-QID3DXQA.js → chunk-OW6F6CPZ.js} +7 -7
- package/Build/Workers/{chunk-CYC7JX3P.js → chunk-P6OAOFBU.js} +8 -8
- package/Build/Workers/{chunk-FYYP46TF.js → chunk-PXDMWXO5.js} +2 -2
- package/Build/Workers/{chunk-TZDR2BAP.js → chunk-QS7623NH.js} +6 -6
- package/Build/Workers/{chunk-D5X2LOJ2.js → chunk-ROH45IXJ.js} +7 -7
- package/Build/Workers/{chunk-UR36KLNW.js → chunk-S2P6LCIB.js} +4 -4
- package/Build/Workers/{chunk-Z2W7ZIGV.js → chunk-S4NZVXU6.js} +2 -2
- package/Build/Workers/{chunk-YSDOO7AG.js → chunk-SGGO5WVA.js} +5 -5
- package/Build/Workers/{chunk-H5IQLAJP.js → chunk-TG7N7TPY.js} +47 -50
- package/Build/Workers/{chunk-XIDMFHR4.js → chunk-TUZQG4RW.js} +14 -14
- package/Build/Workers/{chunk-JVG6T2WE.js → chunk-UHVE7V65.js} +12 -12
- package/Build/Workers/{chunk-FAQ2XNFV.js → chunk-UY2HVPDL.js} +5 -5
- package/Build/Workers/{chunk-CUU3WGXJ.js → chunk-YNLPRFUQ.js} +6 -6
- package/Build/Workers/{chunk-X6GXYB3M.js → chunk-ZYOHBCCE.js} +1 -1
- 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 +41 -49
- 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 +141 -139
- 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
|
@@ -4,9 +4,11 @@ import Cartesian3 from "../Core/Cartesian3.js";
|
|
|
4
4
|
import Cartesian4 from "../Core/Cartesian4.js";
|
|
5
5
|
import CesiumMath from "../Core/Math.js";
|
|
6
6
|
import Check from "../Core/Check.js";
|
|
7
|
+
import ClippingPlane from "./ClippingPlane.js";
|
|
7
8
|
import Matrix3 from "../Core/Matrix3.js";
|
|
8
9
|
import Matrix4 from "../Core/Matrix4.js";
|
|
9
10
|
import OrientedBoundingBox from "../Core/OrientedBoundingBox.js";
|
|
11
|
+
import VoxelBoundsCollection from "./VoxelBoundsCollection.js";
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* A cylinder {@link VoxelShape}.
|
|
@@ -22,111 +24,179 @@ import OrientedBoundingBox from "../Core/OrientedBoundingBox.js";
|
|
|
22
24
|
* @private
|
|
23
25
|
*/
|
|
24
26
|
function VoxelCylinderShape() {
|
|
27
|
+
this._orientedBoundingBox = new OrientedBoundingBox();
|
|
28
|
+
this._boundingSphere = new BoundingSphere();
|
|
29
|
+
this._boundTransform = new Matrix4();
|
|
30
|
+
this._shapeTransform = new Matrix4();
|
|
31
|
+
|
|
25
32
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
33
|
+
* The minimum bounds of the shape, corresponding to minimum radius, angle, and height.
|
|
34
|
+
* @type {Cartesian3}
|
|
28
35
|
* @private
|
|
29
|
-
* @type {OrientedBoundingBox}
|
|
30
|
-
* @readonly
|
|
31
36
|
*/
|
|
32
|
-
this.
|
|
37
|
+
this._minBounds = VoxelCylinderShape.DefaultMinBounds.clone();
|
|
33
38
|
|
|
34
39
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
40
|
+
* The maximum bounds of the shape, corresponding to maximum radius, angle, and height.
|
|
41
|
+
* @type {Cartesian3}
|
|
37
42
|
* @private
|
|
38
|
-
* @type {BoundingSphere}
|
|
39
|
-
* @readonly
|
|
40
43
|
*/
|
|
41
|
-
this.
|
|
44
|
+
this._maxBounds = VoxelCylinderShape.DefaultMaxBounds.clone();
|
|
45
|
+
|
|
46
|
+
const { DefaultMinBounds, DefaultMaxBounds } = VoxelCylinderShape;
|
|
47
|
+
const boundPlanes = [
|
|
48
|
+
new ClippingPlane(
|
|
49
|
+
Cartesian3.negate(Cartesian3.UNIT_Z, new Cartesian3()),
|
|
50
|
+
DefaultMinBounds.z,
|
|
51
|
+
),
|
|
52
|
+
new ClippingPlane(Cartesian3.UNIT_Z, -DefaultMaxBounds.z),
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
this._renderBoundPlanes = new VoxelBoundsCollection({ planes: boundPlanes });
|
|
56
|
+
|
|
57
|
+
this._shaderUniforms = {
|
|
58
|
+
cameraShapePosition: new Cartesian3(),
|
|
59
|
+
cylinderEcToRadialTangentUp: new Matrix3(),
|
|
60
|
+
cylinderRenderRadiusMinMax: new Cartesian2(),
|
|
61
|
+
cylinderRenderAngleMinMax: new Cartesian2(),
|
|
62
|
+
cylinderLocalToShapeUvRadius: new Cartesian2(),
|
|
63
|
+
cylinderLocalToShapeUvAngle: new Cartesian2(),
|
|
64
|
+
cylinderLocalToShapeUvHeight: new Cartesian2(),
|
|
65
|
+
cylinderShapeUvAngleRangeOrigin: 0.0,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
this._shaderDefines = {
|
|
69
|
+
CYLINDER_HAS_SHAPE_BOUNDS_ANGLE: undefined,
|
|
70
|
+
CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MIN: undefined,
|
|
71
|
+
CYLINDER_HAS_RENDER_BOUNDS_RADIUS_FLAT: undefined,
|
|
72
|
+
CYLINDER_HAS_RENDER_BOUNDS_ANGLE: undefined,
|
|
73
|
+
CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_EQUAL_ZERO: undefined,
|
|
74
|
+
CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_UNDER_HALF: undefined,
|
|
75
|
+
CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_OVER_HALF: undefined,
|
|
76
|
+
CYLINDER_INTERSECTION_INDEX_RADIUS_MAX: undefined,
|
|
77
|
+
CYLINDER_INTERSECTION_INDEX_RADIUS_MIN: undefined,
|
|
78
|
+
CYLINDER_INTERSECTION_INDEX_ANGLE: undefined,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
this._shaderMaximumIntersectionsLength = 0; // not known until update
|
|
82
|
+
}
|
|
42
83
|
|
|
84
|
+
Object.defineProperties(VoxelCylinderShape.prototype, {
|
|
43
85
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* @
|
|
47
|
-
* @type {
|
|
86
|
+
* An oriented bounding box containing the bounded shape.
|
|
87
|
+
*
|
|
88
|
+
* @memberof VoxelCylinderShape.prototype
|
|
89
|
+
* @type {OrientedBoundingBox}
|
|
48
90
|
* @readonly
|
|
91
|
+
* @private
|
|
49
92
|
*/
|
|
50
|
-
|
|
93
|
+
orientedBoundingBox: {
|
|
94
|
+
get: function () {
|
|
95
|
+
return this._orientedBoundingBox;
|
|
96
|
+
},
|
|
97
|
+
},
|
|
51
98
|
|
|
52
99
|
/**
|
|
53
|
-
* A
|
|
54
|
-
*
|
|
55
|
-
* @
|
|
56
|
-
* @type {Matrix4}
|
|
100
|
+
* A collection of planes used for the render bounds
|
|
101
|
+
* @memberof VoxelCylinderShape.prototype
|
|
102
|
+
* @type {VoxelBoundsCollection}
|
|
57
103
|
* @readonly
|
|
104
|
+
* @private
|
|
58
105
|
*/
|
|
59
|
-
|
|
106
|
+
renderBoundPlanes: {
|
|
107
|
+
get: function () {
|
|
108
|
+
return this._renderBoundPlanes;
|
|
109
|
+
},
|
|
110
|
+
},
|
|
60
111
|
|
|
61
112
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
113
|
+
* A bounding sphere containing the bounded shape.
|
|
114
|
+
*
|
|
115
|
+
* @memberof VoxelCylinderShape.prototype
|
|
116
|
+
* @type {BoundingSphere}
|
|
117
|
+
* @readonly
|
|
64
118
|
* @private
|
|
65
119
|
*/
|
|
66
|
-
|
|
120
|
+
boundingSphere: {
|
|
121
|
+
get: function () {
|
|
122
|
+
return this._boundingSphere;
|
|
123
|
+
},
|
|
124
|
+
},
|
|
67
125
|
|
|
68
126
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
127
|
+
* A transformation matrix containing the bounded shape.
|
|
128
|
+
*
|
|
129
|
+
* @memberof VoxelCylinderShape.prototype
|
|
130
|
+
* @type {Matrix4}
|
|
131
|
+
* @readonly
|
|
71
132
|
* @private
|
|
72
133
|
*/
|
|
73
|
-
|
|
134
|
+
boundTransform: {
|
|
135
|
+
get: function () {
|
|
136
|
+
return this._boundTransform;
|
|
137
|
+
},
|
|
138
|
+
},
|
|
74
139
|
|
|
75
140
|
/**
|
|
141
|
+
* A transformation matrix containing the shape, ignoring the bounds.
|
|
142
|
+
*
|
|
143
|
+
* @memberof VoxelCylinderShape.prototype
|
|
144
|
+
* @type {Matrix4}
|
|
145
|
+
* @readonly
|
|
76
146
|
* @private
|
|
147
|
+
*/
|
|
148
|
+
shapeTransform: {
|
|
149
|
+
get: function () {
|
|
150
|
+
return this._shapeTransform;
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @memberof VoxelCylinderShape.prototype
|
|
77
156
|
* @type {Object<string, any>}
|
|
78
157
|
* @readonly
|
|
158
|
+
* @private
|
|
79
159
|
*/
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
cylinderUvToShapeUvAngle: new Cartesian2(),
|
|
86
|
-
cylinderUvToShapeUvHeight: new Cartesian2(),
|
|
87
|
-
cylinderShapeUvAngleMinMax: new Cartesian2(),
|
|
88
|
-
cylinderShapeUvAngleRangeZeroMid: 0.0,
|
|
89
|
-
};
|
|
160
|
+
shaderUniforms: {
|
|
161
|
+
get: function () {
|
|
162
|
+
return this._shaderUniforms;
|
|
163
|
+
},
|
|
164
|
+
},
|
|
90
165
|
|
|
91
166
|
/**
|
|
92
|
-
* @
|
|
167
|
+
* @memberof VoxelCylinderShape.prototype
|
|
93
168
|
* @type {Object<string, any>}
|
|
94
169
|
* @readonly
|
|
170
|
+
* @private
|
|
95
171
|
*/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_UNDER_HALF: undefined,
|
|
102
|
-
CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_OVER_HALF: undefined,
|
|
103
|
-
|
|
104
|
-
CYLINDER_HAS_SHAPE_BOUNDS_RADIUS: undefined,
|
|
105
|
-
CYLINDER_HAS_SHAPE_BOUNDS_HEIGHT: undefined,
|
|
106
|
-
CYLINDER_HAS_SHAPE_BOUNDS_ANGLE: undefined,
|
|
107
|
-
CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_MIN_DISCONTINUITY: undefined,
|
|
108
|
-
CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_MAX_DISCONTINUITY: undefined,
|
|
109
|
-
CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_MIN_MAX_REVERSED: undefined,
|
|
110
|
-
|
|
111
|
-
CYLINDER_INTERSECTION_INDEX_RADIUS_MAX: undefined,
|
|
112
|
-
CYLINDER_INTERSECTION_INDEX_RADIUS_MIN: undefined,
|
|
113
|
-
CYLINDER_INTERSECTION_INDEX_ANGLE: undefined,
|
|
114
|
-
};
|
|
172
|
+
shaderDefines: {
|
|
173
|
+
get: function () {
|
|
174
|
+
return this._shaderDefines;
|
|
175
|
+
},
|
|
176
|
+
},
|
|
115
177
|
|
|
116
178
|
/**
|
|
117
179
|
* The maximum number of intersections against the shape for any ray direction.
|
|
118
|
-
* @
|
|
180
|
+
* @memberof VoxelCylinderShape.prototype
|
|
119
181
|
* @type {number}
|
|
120
182
|
* @readonly
|
|
183
|
+
* @private
|
|
121
184
|
*/
|
|
122
|
-
|
|
123
|
-
|
|
185
|
+
shaderMaximumIntersectionsLength: {
|
|
186
|
+
get: function () {
|
|
187
|
+
return this._shaderMaximumIntersectionsLength;
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
});
|
|
124
191
|
|
|
125
192
|
const scratchScale = new Cartesian3();
|
|
126
193
|
const scratchClipMinBounds = new Cartesian3();
|
|
127
194
|
const scratchClipMaxBounds = new Cartesian3();
|
|
128
195
|
const scratchRenderMinBounds = new Cartesian3();
|
|
129
196
|
const scratchRenderMaxBounds = new Cartesian3();
|
|
197
|
+
const scratchTransformPositionWorldToLocal = new Matrix4();
|
|
198
|
+
const scratchCameraPositionLocal = new Cartesian3();
|
|
199
|
+
const scratchCameraRadialPosition = new Cartesian2();
|
|
130
200
|
|
|
131
201
|
/**
|
|
132
202
|
* Update the shape's state.
|
|
@@ -158,15 +228,15 @@ VoxelCylinderShape.prototype.update = function (
|
|
|
158
228
|
maxBounds = Cartesian3.clone(maxBounds, this._maxBounds);
|
|
159
229
|
|
|
160
230
|
const { DefaultMinBounds, DefaultMaxBounds } = VoxelCylinderShape;
|
|
161
|
-
const defaultAngleRange = DefaultMaxBounds.y - DefaultMinBounds.y;
|
|
162
|
-
const defaultAngleRangeHalf = 0.5 * defaultAngleRange;
|
|
231
|
+
const defaultAngleRange = DefaultMaxBounds.y - DefaultMinBounds.y; // == 2 * PI
|
|
232
|
+
const defaultAngleRangeHalf = 0.5 * defaultAngleRange; // == PI
|
|
163
233
|
|
|
164
234
|
const epsilonZeroScale = CesiumMath.EPSILON10;
|
|
165
|
-
const epsilonAngleDiscontinuity = CesiumMath.EPSILON3; // 0.001 radians = 0.05729578 degrees
|
|
166
235
|
const epsilonAngle = CesiumMath.EPSILON10;
|
|
167
236
|
|
|
168
237
|
// Clamp the bounds to the valid range
|
|
169
238
|
minBounds.x = Math.max(0.0, minBounds.x);
|
|
239
|
+
// TODO: require maxBounds.x >= minBounds.x ?
|
|
170
240
|
maxBounds.x = Math.max(0.0, maxBounds.x);
|
|
171
241
|
minBounds.y = CesiumMath.negativePiToPi(minBounds.y);
|
|
172
242
|
maxBounds.y = CesiumMath.negativePiToPi(maxBounds.y);
|
|
@@ -174,6 +244,10 @@ VoxelCylinderShape.prototype.update = function (
|
|
|
174
244
|
clipMinBounds.y = CesiumMath.negativePiToPi(clipMinBounds.y);
|
|
175
245
|
clipMaxBounds.y = CesiumMath.negativePiToPi(clipMaxBounds.y);
|
|
176
246
|
|
|
247
|
+
// TODO: what does this do with partial volumes crossing the antimeridian?
|
|
248
|
+
// We could have minBounds.y = +PI/2 and maxBounds.y = -PI/2.
|
|
249
|
+
// Then clipMinBounds.y = +PI/4 and clipMaxBounds.y = -PI/4.
|
|
250
|
+
// This maximumByComponent would cancel the clipping.
|
|
177
251
|
const renderMinBounds = Cartesian3.maximumByComponent(
|
|
178
252
|
minBounds,
|
|
179
253
|
clipMinBounds,
|
|
@@ -205,57 +279,35 @@ VoxelCylinderShape.prototype.update = function (
|
|
|
205
279
|
return false;
|
|
206
280
|
}
|
|
207
281
|
|
|
208
|
-
|
|
282
|
+
// Update the render bounds planes
|
|
283
|
+
const renderBoundPlanes = this._renderBoundPlanes;
|
|
284
|
+
renderBoundPlanes.get(0).distance = renderMinBounds.z;
|
|
285
|
+
renderBoundPlanes.get(1).distance = -renderMaxBounds.z;
|
|
209
286
|
|
|
210
|
-
this.
|
|
287
|
+
this._shapeTransform = Matrix4.clone(modelMatrix, this._shapeTransform);
|
|
288
|
+
|
|
289
|
+
this._orientedBoundingBox = getCylinderChunkObb(
|
|
211
290
|
renderMinBounds,
|
|
212
291
|
renderMaxBounds,
|
|
213
|
-
this.
|
|
214
|
-
this.
|
|
292
|
+
this._shapeTransform,
|
|
293
|
+
this._orientedBoundingBox,
|
|
215
294
|
);
|
|
216
295
|
|
|
217
|
-
this.
|
|
218
|
-
this.
|
|
219
|
-
this.
|
|
220
|
-
this.
|
|
296
|
+
this._boundTransform = Matrix4.fromRotationTranslation(
|
|
297
|
+
this._orientedBoundingBox.halfAxes,
|
|
298
|
+
this._orientedBoundingBox.center,
|
|
299
|
+
this._boundTransform,
|
|
221
300
|
);
|
|
222
301
|
|
|
223
|
-
this.
|
|
224
|
-
this.
|
|
225
|
-
this.
|
|
302
|
+
this._boundingSphere = BoundingSphere.fromOrientedBoundingBox(
|
|
303
|
+
this._orientedBoundingBox,
|
|
304
|
+
this._boundingSphere,
|
|
226
305
|
);
|
|
227
306
|
|
|
228
|
-
const shapeIsDefaultRadius =
|
|
229
|
-
minBounds.x === DefaultMinBounds.x && maxBounds.x === DefaultMaxBounds.x;
|
|
230
307
|
const shapeIsAngleReversed = maxBounds.y < minBounds.y;
|
|
231
308
|
const shapeAngleRange =
|
|
232
309
|
maxBounds.y - minBounds.y + shapeIsAngleReversed * defaultAngleRange;
|
|
233
|
-
const shapeIsAngleRegular =
|
|
234
|
-
shapeAngleRange > defaultAngleRangeHalf + epsilonAngle &&
|
|
235
|
-
shapeAngleRange < defaultAngleRange - epsilonAngle;
|
|
236
|
-
const shapeIsAngleFlipped =
|
|
237
|
-
shapeAngleRange < defaultAngleRangeHalf - epsilonAngle;
|
|
238
|
-
const shapeIsAngleRangeHalf =
|
|
239
|
-
shapeAngleRange >= defaultAngleRangeHalf - epsilonAngle &&
|
|
240
|
-
shapeAngleRange <= defaultAngleRangeHalf + epsilonAngle;
|
|
241
|
-
const shapeHasAngle =
|
|
242
|
-
shapeIsAngleRegular || shapeIsAngleFlipped || shapeIsAngleRangeHalf;
|
|
243
|
-
const shapeIsMinAngleDiscontinuity = CesiumMath.equalsEpsilon(
|
|
244
|
-
minBounds.y,
|
|
245
|
-
DefaultMinBounds.y,
|
|
246
|
-
undefined,
|
|
247
|
-
epsilonAngleDiscontinuity,
|
|
248
|
-
);
|
|
249
|
-
const shapeIsMaxAngleDiscontinuity = CesiumMath.equalsEpsilon(
|
|
250
|
-
maxBounds.y,
|
|
251
|
-
DefaultMaxBounds.y,
|
|
252
|
-
undefined,
|
|
253
|
-
epsilonAngleDiscontinuity,
|
|
254
|
-
);
|
|
255
|
-
const shapeIsDefaultHeight =
|
|
256
|
-
minBounds.z === DefaultMinBounds.z && maxBounds.z === DefaultMaxBounds.z;
|
|
257
310
|
|
|
258
|
-
const renderIsDefaultMinRadius = renderMinBounds.x === DefaultMinBounds.x;
|
|
259
311
|
const renderIsAngleReversed = renderMaxBounds.y < renderMinBounds.y;
|
|
260
312
|
const renderAngleRange =
|
|
261
313
|
renderMaxBounds.y -
|
|
@@ -271,7 +323,8 @@ VoxelCylinderShape.prototype.update = function (
|
|
|
271
323
|
const renderHasAngle =
|
|
272
324
|
renderIsAngleRegular || renderIsAngleFlipped || renderIsAngleRangeZero;
|
|
273
325
|
|
|
274
|
-
const
|
|
326
|
+
const shaderUniforms = this._shaderUniforms;
|
|
327
|
+
const shaderDefines = this._shaderDefines;
|
|
275
328
|
|
|
276
329
|
// To keep things simple, clear the defines every time
|
|
277
330
|
for (const key in shaderDefines) {
|
|
@@ -286,7 +339,11 @@ VoxelCylinderShape.prototype.update = function (
|
|
|
286
339
|
shaderDefines["CYLINDER_INTERSECTION_INDEX_RADIUS_MAX"] = intersectionCount;
|
|
287
340
|
intersectionCount += 1;
|
|
288
341
|
|
|
289
|
-
if (
|
|
342
|
+
if (shapeAngleRange < defaultAngleRange - epsilonAngle) {
|
|
343
|
+
shaderDefines["CYLINDER_HAS_SHAPE_BOUNDS_ANGLE"] = true;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if (renderMinBounds.x !== DefaultMinBounds.x) {
|
|
290
347
|
shaderDefines["CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MIN"] = true;
|
|
291
348
|
shaderDefines["CYLINDER_INTERSECTION_INDEX_RADIUS_MIN"] = intersectionCount;
|
|
292
349
|
intersectionCount += 1;
|
|
@@ -300,65 +357,32 @@ VoxelCylinderShape.prototype.update = function (
|
|
|
300
357
|
if (renderMinBounds.x === renderMaxBounds.x) {
|
|
301
358
|
shaderDefines["CYLINDER_HAS_RENDER_BOUNDS_RADIUS_FLAT"] = true;
|
|
302
359
|
}
|
|
303
|
-
if (!shapeIsDefaultRadius) {
|
|
304
|
-
shaderDefines["CYLINDER_HAS_SHAPE_BOUNDS_RADIUS"] = true;
|
|
305
|
-
|
|
306
|
-
// delerp(radius, minRadius, maxRadius)
|
|
307
|
-
// (radius - minRadius) / (maxRadius - minRadius)
|
|
308
|
-
// radius / (maxRadius - minRadius) - minRadius / (maxRadius - minRadius)
|
|
309
|
-
// scale = 1.0 / (maxRadius - minRadius)
|
|
310
|
-
// offset = -minRadius / (maxRadius - minRadius)
|
|
311
|
-
// offset = minRadius / (minRadius - maxRadius)
|
|
312
|
-
const radiusRange = maxBounds.x - minBounds.x;
|
|
313
|
-
let scale = 0.0;
|
|
314
|
-
let offset = 1.0;
|
|
315
|
-
if (radiusRange !== 0.0) {
|
|
316
|
-
scale = 1.0 / radiusRange;
|
|
317
|
-
offset = -minBounds.x / radiusRange;
|
|
318
|
-
}
|
|
319
|
-
shaderUniforms.cylinderUvToShapeUvRadius = Cartesian2.fromElements(
|
|
320
|
-
scale,
|
|
321
|
-
offset,
|
|
322
|
-
shaderUniforms.cylinderUvToShapeUvRadius,
|
|
323
|
-
);
|
|
324
|
-
}
|
|
325
360
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
// scale = 1.0 / (maxHeightUv - minHeightUv)
|
|
333
|
-
// scale = 1.0 / ((maxHeight * 0.5 + 0.5) - (minHeight * 0.5 + 0.5))
|
|
334
|
-
// scale = 2.0 / (maxHeight - minHeight)
|
|
335
|
-
// offset = -minHeightUv / (maxHeightUv - minHeightUv)
|
|
336
|
-
// offset = -minHeightUv / ((maxHeight * 0.5 + 0.5) - (minHeight * 0.5 + 0.5))
|
|
337
|
-
// offset = -2.0 * (minHeight * 0.5 + 0.5) / (maxHeight - minHeight)
|
|
338
|
-
// offset = -(minHeight + 1.0) / (maxHeight - minHeight)
|
|
339
|
-
// offset = (minHeight + 1.0) / (minHeight - maxHeight)
|
|
340
|
-
const heightRange = maxBounds.z - minBounds.z;
|
|
341
|
-
let scale = 0.0;
|
|
342
|
-
let offset = 1.0;
|
|
343
|
-
if (heightRange !== 0.0) {
|
|
344
|
-
scale = 2.0 / heightRange;
|
|
345
|
-
offset = -(minBounds.z + 1.0) / heightRange;
|
|
346
|
-
}
|
|
347
|
-
shaderUniforms.cylinderUvToShapeUvHeight = Cartesian2.fromElements(
|
|
348
|
-
scale,
|
|
349
|
-
offset,
|
|
350
|
-
shaderUniforms.cylinderUvToShapeUvHeight,
|
|
351
|
-
);
|
|
361
|
+
const radiusRange = maxBounds.x - minBounds.x;
|
|
362
|
+
let radialScale = 0.0;
|
|
363
|
+
let radialOffset = 1.0;
|
|
364
|
+
if (radiusRange !== 0.0) {
|
|
365
|
+
radialScale = 1.0 / radiusRange;
|
|
366
|
+
radialOffset = -minBounds.x * radialScale;
|
|
352
367
|
}
|
|
353
|
-
shaderUniforms.
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
shaderUniforms.
|
|
368
|
+
shaderUniforms.cylinderLocalToShapeUvRadius = Cartesian2.fromElements(
|
|
369
|
+
radialScale,
|
|
370
|
+
radialOffset,
|
|
371
|
+
shaderUniforms.cylinderLocalToShapeUvRadius,
|
|
357
372
|
);
|
|
358
373
|
|
|
359
|
-
|
|
360
|
-
|
|
374
|
+
const heightRange = maxBounds.z - minBounds.z; // Default 2.0
|
|
375
|
+
let heightScale = 0.0;
|
|
376
|
+
let heightOffset = 1.0;
|
|
377
|
+
if (heightRange !== 0.0) {
|
|
378
|
+
heightScale = 1.0 / heightRange;
|
|
379
|
+
heightOffset = -minBounds.z * heightScale;
|
|
361
380
|
}
|
|
381
|
+
shaderUniforms.cylinderLocalToShapeUvHeight = Cartesian2.fromElements(
|
|
382
|
+
heightScale,
|
|
383
|
+
heightOffset,
|
|
384
|
+
shaderUniforms.cylinderLocalToShapeUvHeight,
|
|
385
|
+
);
|
|
362
386
|
|
|
363
387
|
if (renderHasAngle) {
|
|
364
388
|
shaderDefines["CYLINDER_HAS_RENDER_BOUNDS_ANGLE"] = true;
|
|
@@ -382,64 +406,151 @@ VoxelCylinderShape.prototype.update = function (
|
|
|
382
406
|
);
|
|
383
407
|
}
|
|
384
408
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
shaderDefines["CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_MIN_DISCONTINUITY"] = true;
|
|
389
|
-
}
|
|
390
|
-
if (shapeIsMaxAngleDiscontinuity) {
|
|
391
|
-
shaderDefines["CYLINDER_HAS_SHAPE_BOUNDS_ANGLE_MAX_DISCONTINUITY"] = true;
|
|
392
|
-
}
|
|
409
|
+
const uvMinAngle = (minBounds.y - DefaultMinBounds.y) / defaultAngleRange;
|
|
410
|
+
const uvMaxAngle = (maxBounds.y - DefaultMinBounds.y) / defaultAngleRange;
|
|
411
|
+
const uvAngleRangeZero = 1.0 - shapeAngleRange / defaultAngleRange;
|
|
393
412
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
413
|
+
// Translate the origin of UV angles (in [0,1]) to the center of the unoccupied space
|
|
414
|
+
const uvAngleRangeOrigin = (uvMaxAngle + 0.5 * uvAngleRangeZero) % 1.0;
|
|
415
|
+
shaderUniforms.cylinderShapeUvAngleRangeOrigin = uvAngleRangeOrigin;
|
|
397
416
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
417
|
+
if (shapeAngleRange <= epsilonAngle) {
|
|
418
|
+
shaderUniforms.cylinderLocalToShapeUvAngle = Cartesian2.fromElements(
|
|
419
|
+
0.0,
|
|
420
|
+
1.0,
|
|
421
|
+
shaderUniforms.cylinderLocalToShapeUvAngle,
|
|
422
|
+
);
|
|
423
|
+
} else {
|
|
424
|
+
const scale = defaultAngleRange / shapeAngleRange;
|
|
425
|
+
const shiftedMinAngle = uvMinAngle - uvAngleRangeOrigin;
|
|
426
|
+
const offset = -scale * (shiftedMinAngle - Math.floor(shiftedMinAngle));
|
|
427
|
+
shaderUniforms.cylinderLocalToShapeUvAngle = Cartesian2.fromElements(
|
|
428
|
+
scale,
|
|
429
|
+
offset,
|
|
430
|
+
shaderUniforms.cylinderLocalToShapeUvAngle,
|
|
402
431
|
);
|
|
403
|
-
shaderUniforms.cylinderShapeUvAngleRangeZeroMid =
|
|
404
|
-
(uvMaxAngle + 0.5 * uvAngleRangeZero) % 1.0;
|
|
405
|
-
|
|
406
|
-
// delerp(angleUv, uvMinAngle, uvMaxAngle)
|
|
407
|
-
// (angelUv - uvMinAngle) / (uvMaxAngle - uvMinAngle)
|
|
408
|
-
// angleUv / (uvMaxAngle - uvMinAngle) - uvMinAngle / (uvMaxAngle - uvMinAngle)
|
|
409
|
-
// scale = 1.0 / (uvMaxAngle - uvMinAngle)
|
|
410
|
-
// scale = 1.0 / (((maxAngle - pi) / (2.0 * pi)) - ((minAngle - pi) / (2.0 * pi)))
|
|
411
|
-
// scale = 2.0 * pi / (maxAngle - minAngle)
|
|
412
|
-
// offset = -uvMinAngle / (uvMaxAngle - uvMinAngle)
|
|
413
|
-
// offset = -((minAngle - pi) / (2.0 * pi)) / (((maxAngle - pi) / (2.0 * pi)) - ((minAngle - pi) / (2.0 * pi)))
|
|
414
|
-
// offset = -(minAngle - pi) / (maxAngle - minAngle)
|
|
415
|
-
if (shapeAngleRange <= epsilonAngle) {
|
|
416
|
-
shaderUniforms.cylinderUvToShapeUvAngle = Cartesian2.fromElements(
|
|
417
|
-
0.0,
|
|
418
|
-
1.0,
|
|
419
|
-
shaderUniforms.cylinderUvToShapeUvAngle,
|
|
420
|
-
);
|
|
421
|
-
} else {
|
|
422
|
-
const scale = defaultAngleRange / shapeAngleRange;
|
|
423
|
-
const offset = -(minBounds.y - DefaultMinBounds.y) / shapeAngleRange;
|
|
424
|
-
shaderUniforms.cylinderUvToShapeUvAngle = Cartesian2.fromElements(
|
|
425
|
-
scale,
|
|
426
|
-
offset,
|
|
427
|
-
shaderUniforms.cylinderUvToShapeUvAngle,
|
|
428
|
-
);
|
|
429
|
-
}
|
|
430
432
|
}
|
|
431
433
|
|
|
432
|
-
this.
|
|
434
|
+
this._shaderMaximumIntersectionsLength = intersectionCount;
|
|
433
435
|
|
|
434
436
|
return true;
|
|
435
437
|
};
|
|
436
438
|
|
|
439
|
+
const scratchRotateRtuToLocal = new Matrix3();
|
|
440
|
+
const scratchRtuRotation = new Matrix3();
|
|
441
|
+
const scratchTransformPositionViewToLocal = new Matrix4();
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Update any view-dependent transforms.
|
|
445
|
+
* @private
|
|
446
|
+
* @param {FrameState} frameState The frame state.
|
|
447
|
+
*/
|
|
448
|
+
VoxelCylinderShape.prototype.updateViewTransforms = function (frameState) {
|
|
449
|
+
const shaderUniforms = this._shaderUniforms;
|
|
450
|
+
// 1. Update camera position in cylindrical coordinates
|
|
451
|
+
const transformPositionWorldToLocal = Matrix4.inverse(
|
|
452
|
+
this._shapeTransform,
|
|
453
|
+
scratchTransformPositionWorldToLocal,
|
|
454
|
+
);
|
|
455
|
+
const cameraPositionLocal = Matrix4.multiplyByPoint(
|
|
456
|
+
transformPositionWorldToLocal,
|
|
457
|
+
frameState.camera.positionWC,
|
|
458
|
+
scratchCameraPositionLocal,
|
|
459
|
+
);
|
|
460
|
+
shaderUniforms.cameraShapePosition = Cartesian3.fromElements(
|
|
461
|
+
Cartesian2.magnitude(cameraPositionLocal),
|
|
462
|
+
Math.atan2(cameraPositionLocal.y, cameraPositionLocal.x),
|
|
463
|
+
cameraPositionLocal.z,
|
|
464
|
+
shaderUniforms.cameraShapePosition,
|
|
465
|
+
);
|
|
466
|
+
// 2. Find radial, tangent, and up components at camera position
|
|
467
|
+
const cameraRadialDirection = Cartesian2.normalize(
|
|
468
|
+
Cartesian2.fromCartesian3(cameraPositionLocal, scratchCameraRadialPosition),
|
|
469
|
+
scratchCameraRadialPosition,
|
|
470
|
+
);
|
|
471
|
+
// As row vectors, the radial, tangent, and up vectors constitute a rotation matrix from local to RTU.
|
|
472
|
+
const rotateLocalToRtu = Matrix3.fromRowMajorArray(
|
|
473
|
+
[
|
|
474
|
+
cameraRadialDirection.x,
|
|
475
|
+
cameraRadialDirection.y,
|
|
476
|
+
0.0,
|
|
477
|
+
-cameraRadialDirection.y,
|
|
478
|
+
cameraRadialDirection.x,
|
|
479
|
+
0.0,
|
|
480
|
+
0.0,
|
|
481
|
+
0.0,
|
|
482
|
+
1.0,
|
|
483
|
+
],
|
|
484
|
+
scratchRotateRtuToLocal,
|
|
485
|
+
);
|
|
486
|
+
// 3. Get rotation from eye to local coordinates
|
|
487
|
+
const transformPositionViewToWorld =
|
|
488
|
+
frameState.context.uniformState.inverseView;
|
|
489
|
+
const transformPositionViewToLocal = Matrix4.multiplyTransformation(
|
|
490
|
+
transformPositionWorldToLocal,
|
|
491
|
+
transformPositionViewToWorld,
|
|
492
|
+
scratchTransformPositionViewToLocal,
|
|
493
|
+
);
|
|
494
|
+
const transformDirectionViewToLocal = Matrix4.getMatrix3(
|
|
495
|
+
transformPositionViewToLocal,
|
|
496
|
+
scratchRtuRotation,
|
|
497
|
+
);
|
|
498
|
+
// 4. Multiply to get rotation from eye to RTU coordinates
|
|
499
|
+
shaderUniforms.cylinderEcToRadialTangentUp = Matrix3.multiply(
|
|
500
|
+
rotateLocalToRtu,
|
|
501
|
+
transformDirectionViewToLocal,
|
|
502
|
+
shaderUniforms.cylinderEcToRadialTangentUp,
|
|
503
|
+
);
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Convert a UV coordinate to the shape's UV space.
|
|
508
|
+
* @private
|
|
509
|
+
* @param {Cartesian3} positionLocal The local coordinate to convert.
|
|
510
|
+
* @param {Cartesian3} result The Cartesian3 to store the result in.
|
|
511
|
+
* @returns {Cartesian3} The converted UV coordinate.
|
|
512
|
+
*/
|
|
513
|
+
VoxelCylinderShape.prototype.convertLocalToShapeUvSpace = function (
|
|
514
|
+
positionLocal,
|
|
515
|
+
result,
|
|
516
|
+
) {
|
|
517
|
+
//>>includeStart('debug', pragmas.debug);
|
|
518
|
+
Check.typeOf.object("positionLocal", positionLocal);
|
|
519
|
+
Check.typeOf.object("result", result);
|
|
520
|
+
//>>includeEnd('debug');
|
|
521
|
+
|
|
522
|
+
let radius = Math.hypot(positionLocal.x, positionLocal.y);
|
|
523
|
+
let angle = Math.atan2(positionLocal.y, positionLocal.x);
|
|
524
|
+
let height = positionLocal.z;
|
|
525
|
+
|
|
526
|
+
const {
|
|
527
|
+
cylinderLocalToShapeUvRadius,
|
|
528
|
+
cylinderLocalToShapeUvAngle,
|
|
529
|
+
cylinderShapeUvAngleRangeOrigin,
|
|
530
|
+
cylinderLocalToShapeUvHeight,
|
|
531
|
+
} = this._shaderUniforms;
|
|
532
|
+
|
|
533
|
+
radius =
|
|
534
|
+
radius * cylinderLocalToShapeUvRadius.x + cylinderLocalToShapeUvRadius.y;
|
|
535
|
+
|
|
536
|
+
// Convert angle to a "UV" in [0,1] with 0 defined at the center of the unoccupied space.
|
|
537
|
+
angle = (angle + Math.PI) / (2.0 * Math.PI);
|
|
538
|
+
angle -= cylinderShapeUvAngleRangeOrigin;
|
|
539
|
+
angle = angle - Math.floor(angle);
|
|
540
|
+
// Scale and shift so [0,1] covers the occupied space.
|
|
541
|
+
angle = angle * cylinderLocalToShapeUvAngle.x + cylinderLocalToShapeUvAngle.y;
|
|
542
|
+
|
|
543
|
+
height =
|
|
544
|
+
height * cylinderLocalToShapeUvHeight.x + cylinderLocalToShapeUvHeight.y;
|
|
545
|
+
|
|
546
|
+
return Cartesian3.fromElements(radius, angle, height, result);
|
|
547
|
+
};
|
|
548
|
+
|
|
437
549
|
const scratchMinBounds = new Cartesian3();
|
|
438
550
|
const scratchMaxBounds = new Cartesian3();
|
|
439
551
|
|
|
440
552
|
/**
|
|
441
553
|
* Computes an oriented bounding box for a specified tile.
|
|
442
|
-
* The update function must be called before calling this function.
|
|
443
554
|
* @private
|
|
444
555
|
* @param {number} tileLevel The tile's level.
|
|
445
556
|
* @param {number} tileX The tile's x coordinate.
|
|
@@ -484,7 +595,7 @@ VoxelCylinderShape.prototype.computeOrientedBoundingBoxForTile = function (
|
|
|
484
595
|
return getCylinderChunkObb(
|
|
485
596
|
tileMinBounds,
|
|
486
597
|
tileMaxBounds,
|
|
487
|
-
this.
|
|
598
|
+
this._shapeTransform,
|
|
488
599
|
result,
|
|
489
600
|
);
|
|
490
601
|
};
|
|
@@ -493,7 +604,6 @@ const sampleSizeScratch = new Cartesian3();
|
|
|
493
604
|
|
|
494
605
|
/**
|
|
495
606
|
* Computes an oriented bounding box for a specified sample within a specified tile.
|
|
496
|
-
* The update function must be called before calling this function.
|
|
497
607
|
* @private
|
|
498
608
|
* @param {SpatialNode} spatialNode The spatial node containing the sample
|
|
499
609
|
* @param {Cartesian3} tileDimensions The size of the tile in number of samples, before padding
|
|
@@ -557,7 +667,7 @@ VoxelCylinderShape.prototype.computeOrientedBoundingBoxForSample = function (
|
|
|
557
667
|
return getCylinderChunkObb(
|
|
558
668
|
sampleMinBounds,
|
|
559
669
|
sampleMaxBounds,
|
|
560
|
-
this.
|
|
670
|
+
this._shapeTransform,
|
|
561
671
|
result,
|
|
562
672
|
);
|
|
563
673
|
};
|
|
@@ -639,6 +749,7 @@ function computeLooseOrientedBoundingBox(matrix, result) {
|
|
|
639
749
|
return OrientedBoundingBox.fromPoints(corners, result);
|
|
640
750
|
}
|
|
641
751
|
|
|
752
|
+
const scratchBoxScale = new Cartesian3();
|
|
642
753
|
/**
|
|
643
754
|
* Computes an {@link OrientedBoundingBox} for a subregion of the shape.
|
|
644
755
|
*
|
|
@@ -720,7 +831,7 @@ function getCylinderChunkObb(chunkMinBounds, chunkMaxBounds, matrix, result) {
|
|
|
720
831
|
extentX,
|
|
721
832
|
extentY,
|
|
722
833
|
extentZ,
|
|
723
|
-
|
|
834
|
+
scratchBoxScale,
|
|
724
835
|
);
|
|
725
836
|
|
|
726
837
|
const scaleMatrix = Matrix4.fromScale(scale, scratchScaleMatrix);
|