@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
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
import Cartesian2 from "../Core/Cartesian2.js";
|
|
2
|
+
import Cartesian3 from "../Core/Cartesian3.js";
|
|
3
|
+
import Cartesian4 from "../Core/Cartesian4.js";
|
|
4
|
+
import Check from "../Core/Check.js";
|
|
5
|
+
import ClippingPlane from "./ClippingPlane.js";
|
|
6
|
+
import ContextLimits from "../Renderer/ContextLimits.js";
|
|
7
|
+
import defined from "../Core/defined.js";
|
|
8
|
+
import destroyObject from "../Core/destroyObject.js";
|
|
9
|
+
import Event from "../Core/Event.js";
|
|
10
|
+
import Frozen from "../Core/Frozen.js";
|
|
11
|
+
import Intersect from "../Core/Intersect.js";
|
|
12
|
+
import Matrix4 from "../Core/Matrix4.js";
|
|
13
|
+
import PixelFormat from "../Core/PixelFormat.js";
|
|
14
|
+
import PixelDatatype from "../Renderer/PixelDatatype.js";
|
|
15
|
+
import Plane from "../Core/Plane.js";
|
|
16
|
+
import Sampler from "../Renderer/Sampler.js";
|
|
17
|
+
import Texture from "../Renderer/Texture.js";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Specifies a set of clipping planes defining rendering bounds for a {@link VoxelPrimitive}.
|
|
21
|
+
*
|
|
22
|
+
* @alias VoxelBoundsCollection
|
|
23
|
+
* @constructor
|
|
24
|
+
*
|
|
25
|
+
* @param {object} [options] Object with the following properties:
|
|
26
|
+
* @param {ClippingPlane[]} [options.planes=[]] An array of {@link ClippingPlane} objects used to selectively disable rendering on the outside of each plane.
|
|
27
|
+
* @param {Matrix4} [options.modelMatrix=Matrix4.IDENTITY] The 4x4 transformation matrix specifying an additional transform relative to the clipping planes original coordinate system.
|
|
28
|
+
* @param {boolean} [options.unionClippingRegions=false] If true, a region will be clipped if it is on the outside of any plane in the collection. Otherwise, a region will only be clipped if it is on the outside of every plane.
|
|
29
|
+
*
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
function VoxelBoundsCollection(options) {
|
|
33
|
+
const {
|
|
34
|
+
planes,
|
|
35
|
+
modelMatrix = Matrix4.IDENTITY,
|
|
36
|
+
unionClippingRegions = false,
|
|
37
|
+
} = options ?? Frozen.EMPTY_OBJECT;
|
|
38
|
+
|
|
39
|
+
this._planes = [];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The 4x4 transformation matrix specifying an additional transform relative to the clipping planes
|
|
43
|
+
* original coordinate system.
|
|
44
|
+
*
|
|
45
|
+
* @type {Matrix4}
|
|
46
|
+
* @default Matrix4.IDENTITY
|
|
47
|
+
*/
|
|
48
|
+
this.modelMatrix = Matrix4.clone(modelMatrix);
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* An event triggered when a new clipping plane is added to the collection. Event handlers
|
|
52
|
+
* are passed the new plane and the index at which it was added.
|
|
53
|
+
* @type {Event}
|
|
54
|
+
* @readonly
|
|
55
|
+
*/
|
|
56
|
+
this.planeAdded = new Event();
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* An event triggered when a new clipping plane is removed from the collection. Event handlers
|
|
60
|
+
* are passed the new plane and the index from which it was removed.
|
|
61
|
+
* @type {Event}
|
|
62
|
+
* @readonly
|
|
63
|
+
*/
|
|
64
|
+
this.planeRemoved = new Event();
|
|
65
|
+
|
|
66
|
+
this._unionClippingRegions = unionClippingRegions;
|
|
67
|
+
this._testIntersection = unionClippingRegions
|
|
68
|
+
? unionIntersectFunction
|
|
69
|
+
: defaultIntersectFunction;
|
|
70
|
+
|
|
71
|
+
this._float32View = undefined;
|
|
72
|
+
|
|
73
|
+
this._clippingPlanesTexture = undefined;
|
|
74
|
+
|
|
75
|
+
// Add each ClippingPlane object.
|
|
76
|
+
if (defined(planes)) {
|
|
77
|
+
for (let i = 0; i < planes.length; ++i) {
|
|
78
|
+
this.add(planes[i]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function unionIntersectFunction(value) {
|
|
84
|
+
return value === Intersect.OUTSIDE;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function defaultIntersectFunction(value) {
|
|
88
|
+
return value === Intersect.INSIDE;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
Object.defineProperties(VoxelBoundsCollection.prototype, {
|
|
92
|
+
/**
|
|
93
|
+
* Returns the number of planes in this collection. This is commonly used with
|
|
94
|
+
* {@link VoxelBoundsCollection#get} to iterate over all the planes
|
|
95
|
+
* in the collection.
|
|
96
|
+
*
|
|
97
|
+
* @memberof VoxelBoundsCollection.prototype
|
|
98
|
+
* @type {number}
|
|
99
|
+
* @readonly
|
|
100
|
+
*/
|
|
101
|
+
length: {
|
|
102
|
+
get: function () {
|
|
103
|
+
return this._planes.length;
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* If true, a region will be clipped if it is on the outside of any plane in the
|
|
109
|
+
* collection. Otherwise, a region will only be clipped if it is on the
|
|
110
|
+
* outside of every plane.
|
|
111
|
+
*
|
|
112
|
+
* @memberof VoxelBoundsCollection.prototype
|
|
113
|
+
* @type {boolean}
|
|
114
|
+
* @default false
|
|
115
|
+
*/
|
|
116
|
+
unionClippingRegions: {
|
|
117
|
+
get: function () {
|
|
118
|
+
return this._unionClippingRegions;
|
|
119
|
+
},
|
|
120
|
+
set: function (value) {
|
|
121
|
+
//>>includeStart('debug', pragmas.debug);
|
|
122
|
+
Check.typeOf.bool("value", value);
|
|
123
|
+
//>>includeEnd('debug');
|
|
124
|
+
if (this._unionClippingRegions === value) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
this._unionClippingRegions = value;
|
|
128
|
+
this._testIntersection = value
|
|
129
|
+
? unionIntersectFunction
|
|
130
|
+
: defaultIntersectFunction;
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Returns a texture containing packed, untransformed clipping planes.
|
|
136
|
+
*
|
|
137
|
+
* @memberof VoxelBoundsCollection.prototype
|
|
138
|
+
* @type {Texture}
|
|
139
|
+
* @readonly
|
|
140
|
+
* @private
|
|
141
|
+
*/
|
|
142
|
+
texture: {
|
|
143
|
+
get: function () {
|
|
144
|
+
return this._clippingPlanesTexture;
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Returns a Number encapsulating the state for this VoxelBoundsCollection.
|
|
150
|
+
*
|
|
151
|
+
* Clipping mode is encoded in the sign of the number, which is just the plane count.
|
|
152
|
+
* If this value changes, then shader regeneration is necessary.
|
|
153
|
+
*
|
|
154
|
+
* @memberof VoxelBoundsCollection.prototype
|
|
155
|
+
* @returns {number} A Number that describes the VoxelBoundsCollection's state.
|
|
156
|
+
* @readonly
|
|
157
|
+
* @private
|
|
158
|
+
*/
|
|
159
|
+
clippingPlanesState: {
|
|
160
|
+
get: function () {
|
|
161
|
+
return this._unionClippingRegions
|
|
162
|
+
? this._planes.length
|
|
163
|
+
: -this._planes.length;
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Adds the specified {@link ClippingPlane} to the collection to be used to selectively disable rendering
|
|
170
|
+
* on the outside of each plane. Use {@link VoxelBoundsCollection#unionClippingRegions} to modify
|
|
171
|
+
* how modify the clipping behavior of multiple planes.
|
|
172
|
+
*
|
|
173
|
+
* @param {ClippingPlane} plane The ClippingPlane to add to the collection.
|
|
174
|
+
*
|
|
175
|
+
* @see VoxelBoundsCollection#unionClippingRegions
|
|
176
|
+
* @see VoxelBoundsCollection#remove
|
|
177
|
+
* @see VoxelBoundsCollection#removeAll
|
|
178
|
+
*/
|
|
179
|
+
VoxelBoundsCollection.prototype.add = function (plane) {
|
|
180
|
+
const newPlaneIndex = this._planes.length;
|
|
181
|
+
plane.index = newPlaneIndex;
|
|
182
|
+
this._planes.push(plane);
|
|
183
|
+
this.planeAdded.raiseEvent(plane, newPlaneIndex);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Returns the plane in the collection at the specified index. Indices are zero-based
|
|
188
|
+
* and increase as planes are added. Removing a plane shifts all planes after
|
|
189
|
+
* it to the left, changing their indices. This function is commonly used with
|
|
190
|
+
* {@link VoxelBoundsCollection#length} to iterate over all the planes
|
|
191
|
+
* in the collection.
|
|
192
|
+
*
|
|
193
|
+
* @param {number} index The zero-based index of the plane.
|
|
194
|
+
* @returns {ClippingPlane} The ClippingPlane at the specified index.
|
|
195
|
+
*
|
|
196
|
+
* @see VoxelBoundsCollection#length
|
|
197
|
+
*/
|
|
198
|
+
VoxelBoundsCollection.prototype.get = function (index) {
|
|
199
|
+
//>>includeStart('debug', pragmas.debug);
|
|
200
|
+
Check.typeOf.number("index", index);
|
|
201
|
+
//>>includeEnd('debug');
|
|
202
|
+
|
|
203
|
+
return this._planes[index];
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
function indexOf(planes, plane) {
|
|
207
|
+
for (let i = 0; i < planes.length; ++i) {
|
|
208
|
+
if (Plane.equals(planes[i], plane)) {
|
|
209
|
+
return i;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return -1;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Checks whether this collection contains a ClippingPlane equal to the given ClippingPlane.
|
|
217
|
+
*
|
|
218
|
+
* @param {ClippingPlane} [clippingPlane] The ClippingPlane to check for.
|
|
219
|
+
* @returns {boolean} true if this collection contains the ClippingPlane, false otherwise.
|
|
220
|
+
*
|
|
221
|
+
* @see VoxelBoundsCollection#get
|
|
222
|
+
*/
|
|
223
|
+
VoxelBoundsCollection.prototype.contains = function (clippingPlane) {
|
|
224
|
+
return indexOf(this._planes, clippingPlane) !== -1;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Removes the first occurrence of the given ClippingPlane from the collection.
|
|
229
|
+
*
|
|
230
|
+
* @param {ClippingPlane} clippingPlane
|
|
231
|
+
* @returns {boolean} <code>true</code> if the plane was removed; <code>false</code> if the plane was not found in the collection.
|
|
232
|
+
*
|
|
233
|
+
* @see VoxelBoundsCollection#add
|
|
234
|
+
* @see VoxelBoundsCollection#contains
|
|
235
|
+
* @see VoxelBoundsCollection#removeAll
|
|
236
|
+
*/
|
|
237
|
+
VoxelBoundsCollection.prototype.remove = function (clippingPlane) {
|
|
238
|
+
const planes = this._planes;
|
|
239
|
+
const index = indexOf(planes, clippingPlane);
|
|
240
|
+
|
|
241
|
+
if (index === -1) {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Unlink this VoxelBoundsCollection from the ClippingPlane
|
|
246
|
+
if (clippingPlane instanceof ClippingPlane) {
|
|
247
|
+
clippingPlane.onChangeCallback = undefined;
|
|
248
|
+
clippingPlane.index = -1;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Shift and update indices
|
|
252
|
+
const length = planes.length - 1;
|
|
253
|
+
for (let i = index; i < length; ++i) {
|
|
254
|
+
const planeToKeep = planes[i + 1];
|
|
255
|
+
planes[i] = planeToKeep;
|
|
256
|
+
if (planeToKeep instanceof ClippingPlane) {
|
|
257
|
+
planeToKeep.index = i;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
planes.length = length;
|
|
262
|
+
|
|
263
|
+
this.planeRemoved.raiseEvent(clippingPlane, index);
|
|
264
|
+
|
|
265
|
+
return true;
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Removes all planes from the collection.
|
|
270
|
+
*
|
|
271
|
+
* @see VoxelBoundsCollection#add
|
|
272
|
+
* @see VoxelBoundsCollection#remove
|
|
273
|
+
*/
|
|
274
|
+
VoxelBoundsCollection.prototype.removeAll = function () {
|
|
275
|
+
// Dereference this VoxelBoundsCollection from all ClippingPlanes
|
|
276
|
+
const planes = this._planes;
|
|
277
|
+
for (let i = 0; i < planes.length; ++i) {
|
|
278
|
+
const plane = planes[i];
|
|
279
|
+
if (plane instanceof ClippingPlane) {
|
|
280
|
+
plane.onChangeCallback = undefined;
|
|
281
|
+
plane.index = -1;
|
|
282
|
+
}
|
|
283
|
+
this.planeRemoved.raiseEvent(plane, i);
|
|
284
|
+
}
|
|
285
|
+
this._planes = [];
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
const scratchPlane = new Plane(Cartesian3.fromElements(1.0, 0.0, 0.0), 0.0);
|
|
289
|
+
|
|
290
|
+
// Pack starting at the beginning of the buffer to allow partial update
|
|
291
|
+
function transformAndPackPlanes(clippingPlaneCollection, transform) {
|
|
292
|
+
const float32View = clippingPlaneCollection._float32View;
|
|
293
|
+
const planes = clippingPlaneCollection._planes;
|
|
294
|
+
|
|
295
|
+
let floatIndex = 0;
|
|
296
|
+
for (let i = 0; i < planes.length; ++i) {
|
|
297
|
+
const { normal, distance } = transformPlane(
|
|
298
|
+
planes[i],
|
|
299
|
+
transform,
|
|
300
|
+
scratchPlane,
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
float32View[floatIndex] = normal.x;
|
|
304
|
+
float32View[floatIndex + 1] = normal.y;
|
|
305
|
+
float32View[floatIndex + 2] = normal.z;
|
|
306
|
+
float32View[floatIndex + 3] = distance;
|
|
307
|
+
|
|
308
|
+
floatIndex += 4; // each plane is 4 floats
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const scratchPlaneCartesian4 = new Cartesian4();
|
|
313
|
+
const scratchTransformedNormal = new Cartesian3();
|
|
314
|
+
|
|
315
|
+
function transformPlane(plane, transform, result) {
|
|
316
|
+
//>>includeStart('debug', pragmas.debug);
|
|
317
|
+
Check.typeOf.object("plane", plane);
|
|
318
|
+
Check.typeOf.object("transform", transform);
|
|
319
|
+
//>>includeEnd('debug');
|
|
320
|
+
|
|
321
|
+
const { normal, distance } = plane;
|
|
322
|
+
const planeAsCartesian4 = Cartesian4.fromElements(
|
|
323
|
+
normal.x,
|
|
324
|
+
normal.y,
|
|
325
|
+
normal.z,
|
|
326
|
+
distance,
|
|
327
|
+
scratchPlaneCartesian4,
|
|
328
|
+
);
|
|
329
|
+
let transformedPlane = Matrix4.multiplyByVector(
|
|
330
|
+
transform,
|
|
331
|
+
planeAsCartesian4,
|
|
332
|
+
scratchPlaneCartesian4,
|
|
333
|
+
);
|
|
334
|
+
|
|
335
|
+
// Convert the transformed plane to Hessian Normal Form
|
|
336
|
+
const transformedNormal = Cartesian3.fromCartesian4(
|
|
337
|
+
transformedPlane,
|
|
338
|
+
scratchTransformedNormal,
|
|
339
|
+
);
|
|
340
|
+
transformedPlane = Cartesian4.divideByScalar(
|
|
341
|
+
transformedPlane,
|
|
342
|
+
Cartesian3.magnitude(transformedNormal),
|
|
343
|
+
scratchPlaneCartesian4,
|
|
344
|
+
);
|
|
345
|
+
|
|
346
|
+
return Plane.fromCartesian4(transformedPlane, result);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function computeTextureResolution(pixelsNeeded, result) {
|
|
350
|
+
result.x = Math.min(pixelsNeeded, ContextLimits.maximumTextureSize);
|
|
351
|
+
result.y = Math.ceil(pixelsNeeded / result.x);
|
|
352
|
+
return result;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
const textureResolutionScratch = new Cartesian2();
|
|
356
|
+
/**
|
|
357
|
+
* Called when {@link Viewer} or {@link CesiumWidget} render the scene to
|
|
358
|
+
* build the resources for clipping planes.
|
|
359
|
+
* <p>
|
|
360
|
+
* Do not call this function directly.
|
|
361
|
+
* </p>
|
|
362
|
+
*/
|
|
363
|
+
VoxelBoundsCollection.prototype.update = function (frameState, transform) {
|
|
364
|
+
let clippingPlanesTexture = this._clippingPlanesTexture;
|
|
365
|
+
|
|
366
|
+
// Compute texture requirements for current planes
|
|
367
|
+
// In RGBA FLOAT, a plane is 4 floats packed to a single RGBA pixel.
|
|
368
|
+
const pixelsNeeded = this.length;
|
|
369
|
+
|
|
370
|
+
if (defined(clippingPlanesTexture)) {
|
|
371
|
+
const currentPixelCount =
|
|
372
|
+
clippingPlanesTexture.width * clippingPlanesTexture.height;
|
|
373
|
+
// Recreate the texture to double current requirement if it isn't big enough or is 4 times larger than it needs to be.
|
|
374
|
+
// Optimization note: this isn't exactly the classic resizeable array algorithm
|
|
375
|
+
// * not necessarily checking for resize after each add/remove operation
|
|
376
|
+
// * random-access deletes instead of just pops
|
|
377
|
+
// * alloc ops likely more expensive than demonstrable via big-O analysis
|
|
378
|
+
if (
|
|
379
|
+
currentPixelCount < pixelsNeeded ||
|
|
380
|
+
pixelsNeeded < 0.25 * currentPixelCount
|
|
381
|
+
) {
|
|
382
|
+
clippingPlanesTexture.destroy();
|
|
383
|
+
clippingPlanesTexture = undefined;
|
|
384
|
+
this._clippingPlanesTexture = undefined;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// If there are no bound planes, there's nothing to update.
|
|
389
|
+
if (this.length === 0) {
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
if (!defined(clippingPlanesTexture)) {
|
|
394
|
+
const requiredResolution = computeTextureResolution(
|
|
395
|
+
pixelsNeeded,
|
|
396
|
+
textureResolutionScratch,
|
|
397
|
+
);
|
|
398
|
+
// Allocate twice as much space as needed to avoid frequent texture reallocation.
|
|
399
|
+
// Allocate in the Y direction, since texture may be as wide as context texture support.
|
|
400
|
+
requiredResolution.y *= 2;
|
|
401
|
+
|
|
402
|
+
clippingPlanesTexture = new Texture({
|
|
403
|
+
context: frameState.context,
|
|
404
|
+
width: requiredResolution.x,
|
|
405
|
+
height: requiredResolution.y,
|
|
406
|
+
pixelFormat: PixelFormat.RGBA,
|
|
407
|
+
pixelDatatype: PixelDatatype.FLOAT,
|
|
408
|
+
sampler: Sampler.NEAREST,
|
|
409
|
+
flipY: false,
|
|
410
|
+
});
|
|
411
|
+
this._float32View = new Float32Array(
|
|
412
|
+
requiredResolution.x * requiredResolution.y * 4,
|
|
413
|
+
);
|
|
414
|
+
|
|
415
|
+
this._clippingPlanesTexture = clippingPlanesTexture;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
const { width, height } = clippingPlanesTexture;
|
|
419
|
+
transformAndPackPlanes(this, transform);
|
|
420
|
+
clippingPlanesTexture.copyFrom({
|
|
421
|
+
source: {
|
|
422
|
+
width: width,
|
|
423
|
+
height: height,
|
|
424
|
+
arrayBufferView: this._float32View,
|
|
425
|
+
},
|
|
426
|
+
});
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Function for getting the clipping plane collection's texture resolution.
|
|
431
|
+
* If the VoxelBoundsCollection hasn't been updated, returns the resolution that will be
|
|
432
|
+
* allocated based on the current plane count.
|
|
433
|
+
*
|
|
434
|
+
* @param {VoxelBoundsCollection} clippingPlaneCollection The clipping plane collection
|
|
435
|
+
* @param {Context} context The rendering context
|
|
436
|
+
* @param {Cartesian2} result A Cartesian2 for the result.
|
|
437
|
+
* @returns {Cartesian2} The required resolution.
|
|
438
|
+
* @private
|
|
439
|
+
*/
|
|
440
|
+
VoxelBoundsCollection.getTextureResolution = function (
|
|
441
|
+
clippingPlaneCollection,
|
|
442
|
+
context,
|
|
443
|
+
result,
|
|
444
|
+
) {
|
|
445
|
+
const texture = clippingPlaneCollection.texture;
|
|
446
|
+
if (defined(texture)) {
|
|
447
|
+
result.x = texture.width;
|
|
448
|
+
result.y = texture.height;
|
|
449
|
+
return result;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
const pixelsNeeded = clippingPlaneCollection.length;
|
|
453
|
+
const requiredResolution = computeTextureResolution(pixelsNeeded, result);
|
|
454
|
+
|
|
455
|
+
// Allocate twice as much space as needed to avoid frequent texture reallocation.
|
|
456
|
+
requiredResolution.y *= 2;
|
|
457
|
+
return requiredResolution;
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Returns true if this object was destroyed; otherwise, false.
|
|
462
|
+
* <br /><br />
|
|
463
|
+
* If this object was destroyed, it should not be used; calling any function other than
|
|
464
|
+
* <code>isDestroyed</code> will result in a {@link DeveloperError} exception.
|
|
465
|
+
*
|
|
466
|
+
* @returns {boolean} <code>true</code> if this object was destroyed; otherwise, <code>false</code>.
|
|
467
|
+
*
|
|
468
|
+
* @see VoxelBoundsCollection#destroy
|
|
469
|
+
*/
|
|
470
|
+
VoxelBoundsCollection.prototype.isDestroyed = function () {
|
|
471
|
+
return false;
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Destroys the WebGL resources held by this object. Destroying an object allows for deterministic
|
|
476
|
+
* release of WebGL resources, instead of relying on the garbage collector to destroy this object.
|
|
477
|
+
* <br />
|
|
478
|
+
* Once an object is destroyed, it should not be used; calling any function other than
|
|
479
|
+
* <code>isDestroyed</code> will result in a {@link DeveloperError} exception. Therefore,
|
|
480
|
+
* assign the return value (<code>undefined</code>) to the object as done in the example.
|
|
481
|
+
*
|
|
482
|
+
* @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
|
|
483
|
+
*
|
|
484
|
+
* @example
|
|
485
|
+
* voxelBounds = voxelBounds && voxelBounds.destroy();
|
|
486
|
+
*
|
|
487
|
+
* @see VoxelBoundsCollection#isDestroyed
|
|
488
|
+
*/
|
|
489
|
+
VoxelBoundsCollection.prototype.destroy = function () {
|
|
490
|
+
this._clippingPlanesTexture =
|
|
491
|
+
this._clippingPlanesTexture && this._clippingPlanesTexture.destroy();
|
|
492
|
+
return destroyObject(this);
|
|
493
|
+
};
|
|
494
|
+
export default VoxelBoundsCollection;
|