@cesium/engine 8.0.0 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Build/ThirdParty/Workers/z-worker-pako.js +7 -10
- package/Build/Workers/{chunk-F4HFJMGM.js → chunk-2CSEEWHN.js} +6 -6
- package/Build/Workers/{chunk-7TC63SJW.js → chunk-34DGOKCO.js} +10 -12
- package/Build/Workers/{chunk-7ZFGPDJA.js → chunk-3RZK5NNV.js} +4 -4
- package/Build/Workers/{chunk-M7ERACJJ.js → chunk-3S2MFY4B.js} +13 -13
- package/Build/Workers/{chunk-BROJAZRZ.js → chunk-4AJGCQFX.js} +13 -13
- package/Build/Workers/{chunk-2FWRMUTY.js → chunk-4KIUON73.js} +4 -4
- package/Build/Workers/{chunk-5QULIR53.js → chunk-4PHPQRSH.js} +4 -4
- package/Build/Workers/{chunk-X4356LRH.js → chunk-66E3H2KU.js} +12 -12
- package/Build/Workers/{chunk-G43QFN4Q.js → chunk-6HCAQOVK.js} +6 -6
- package/Build/Workers/{chunk-23UFSGND.js → chunk-7LPEGKOF.js} +7 -7
- package/Build/Workers/{chunk-DDUQAJ4P.js → chunk-7VZNXIKG.js} +7 -7
- package/Build/Workers/{chunk-JURN7NPV.js → chunk-A6NCZSL3.js} +19 -19
- package/Build/Workers/{chunk-ZT7KWISZ.js → chunk-AOFMPKUB.js} +4 -4
- package/Build/Workers/{chunk-BIKA3NRA.js → chunk-AOIKO5Y7.js} +5 -5
- package/Build/Workers/{chunk-YWTJ2B4B.js → chunk-BDUJXBVF.js} +1 -1
- package/Build/Workers/{chunk-OGXZVPPM.js → chunk-C5CE4OG6.js} +469 -6
- package/Build/Workers/{chunk-FNIRWHJB.js → chunk-CE6GTZ4I.js} +11 -13
- package/Build/Workers/{chunk-SH5USDPI.js → chunk-CYAJYEKW.js} +6 -6
- package/Build/Workers/{chunk-Y5UQJLYE.js → chunk-FOZQIHZK.js} +6 -6
- package/Build/Workers/{chunk-2FRVPMCS.js → chunk-G7CJQKKD.js} +7 -7
- package/Build/Workers/{chunk-EERJKOAF.js → chunk-GIFJ77E4.js} +4 -4
- package/Build/Workers/{chunk-FJKNFAKQ.js → chunk-I5TDPPC4.js} +7197 -5096
- package/Build/Workers/{chunk-3VAZEH7M.js → chunk-IBXGK4WV.js} +2 -2
- package/Build/Workers/{chunk-VOXYEYJT.js → chunk-JI2445T5.js} +11 -11
- package/Build/Workers/{chunk-PGSJK77E.js → chunk-KPY4F4BW.js} +6 -6
- package/Build/Workers/{chunk-I46ZRR5W.js → chunk-LVJCR7DH.js} +17 -17
- package/Build/Workers/{chunk-T3XIFPYR.js → chunk-LW7WGHEU.js} +16 -16
- package/Build/Workers/{chunk-HU6N6EXB.js → chunk-MWYZ64MH.js} +12 -11
- package/Build/Workers/chunk-NI2R52QD.js +961 -0
- package/Build/Workers/{chunk-SOWMRMWA.js → chunk-PEABJLCK.js} +1 -1
- package/Build/Workers/{chunk-EG6PTBY2.js → chunk-PK7TEP3J.js} +15 -15
- package/Build/Workers/{chunk-GRC2ZTAF.js → chunk-POLFRINT.js} +14 -14
- package/Build/Workers/{chunk-Z3TIFFGF.js → chunk-PS6AEMBR.js} +7 -7
- package/Build/Workers/{chunk-Y2ME2IJV.js → chunk-PWF3YJJ5.js} +13 -13
- package/Build/Workers/{chunk-2A75IWRS.js → chunk-QKF7XXEQ.js} +7 -7
- package/Build/Workers/{chunk-4H7PY4U5.js → chunk-RL73GOEF.js} +2 -2
- package/Build/Workers/{chunk-MDWEGWPA.js → chunk-RR7EOKGZ.js} +10 -10
- package/Build/Workers/{chunk-F3YA3Y2Z.js → chunk-S4XDCPKD.js} +1 -1
- package/Build/Workers/{chunk-PPH7OFP3.js → chunk-TMMOULW3.js} +5 -5
- package/Build/Workers/{chunk-XGI5BXZY.js → chunk-U4IMCOF5.js} +2 -2
- package/Build/Workers/{chunk-4DO5W5XZ.js → chunk-UAJEGIWA.js} +6 -6
- package/Build/Workers/{chunk-BBWDMCVU.js → chunk-UCPPWV64.js} +1 -1
- package/Build/Workers/{chunk-FZRIVR7Y.js → chunk-V7JB576Q.js} +5 -5
- package/Build/Workers/{chunk-2UPKWTMJ.js → chunk-WEGCQ5DY.js} +6 -6
- package/Build/Workers/{chunk-STW2DGFI.js → chunk-WFICTTOE.js} +2 -2
- package/Build/Workers/{chunk-LPR3YNP2.js → chunk-WWP3I7R5.js} +5 -5
- package/Build/Workers/{chunk-A5DWLWCY.js → chunk-XHLDDE65.js} +10 -10
- package/Build/Workers/{chunk-UEXTBDBE.js → chunk-XWML5Y7N.js} +11 -13
- package/Build/Workers/{chunk-EHWHNOEX.js → chunk-YLZTCEBJ.js} +1 -1
- package/Build/Workers/{chunk-34FXV7D7.js → chunk-ZC4AGBZK.js} +2 -2
- package/Build/Workers/{chunk-GATZHF3K.js → chunk-ZDP32RQI.js} +2 -2
- package/Build/Workers/{chunk-KKCR2YOP.js → chunk-ZWPIM77Q.js} +11 -11
- package/Build/Workers/combineGeometry.js +22 -24
- package/Build/Workers/createBoxGeometry.js +16 -18
- package/Build/Workers/createBoxOutlineGeometry.js +14 -16
- package/Build/Workers/createCircleGeometry.js +24 -26
- package/Build/Workers/createCircleOutlineGeometry.js +17 -19
- package/Build/Workers/createCoplanarPolygonGeometry.js +33 -34
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -31
- package/Build/Workers/createCorridorGeometry.js +27 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +26 -28
- package/Build/Workers/createCylinderGeometry.js +18 -20
- package/Build/Workers/createCylinderOutlineGeometry.js +16 -18
- package/Build/Workers/createEllipseGeometry.js +24 -26
- package/Build/Workers/createEllipseOutlineGeometry.js +17 -19
- package/Build/Workers/createEllipsoidGeometry.js +17 -19
- package/Build/Workers/createEllipsoidOutlineGeometry.js +16 -18
- package/Build/Workers/createFrustumGeometry.js +16 -18
- package/Build/Workers/createFrustumOutlineGeometry.js +18 -19
- package/Build/Workers/createGeometry.js +23 -25
- package/Build/Workers/createGroundPolylineGeometry.js +23 -25
- package/Build/Workers/createPlaneGeometry.js +14 -16
- package/Build/Workers/createPlaneOutlineGeometry.js +13 -15
- package/Build/Workers/createPolygonGeometry.js +33 -35
- package/Build/Workers/createPolygonOutlineGeometry.js +28 -30
- package/Build/Workers/createPolylineGeometry.js +23 -25
- package/Build/Workers/createPolylineVolumeGeometry.js +29 -31
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +25 -27
- package/Build/Workers/createRectangleGeometry.js +27 -29
- package/Build/Workers/createRectangleOutlineGeometry.js +18 -20
- package/Build/Workers/createSimplePolylineGeometry.js +21 -23
- package/Build/Workers/createSphereGeometry.js +17 -19
- package/Build/Workers/createSphereOutlineGeometry.js +16 -18
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -16
- package/Build/Workers/createVectorTileGeometries.js +22 -24
- package/Build/Workers/createVectorTilePoints.js +12 -12
- package/Build/Workers/createVectorTilePolygons.js +20 -22
- package/Build/Workers/createVectorTilePolylines.js +14 -16
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +23 -25
- package/Build/Workers/createVerticesFromHeightmap.js +23 -25
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +19 -22
- package/Build/Workers/createWallGeometry.js +22 -24
- package/Build/Workers/createWallOutlineGeometry.js +21 -23
- package/Build/Workers/decodeDraco.js +11 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +10 -11
- package/Build/Workers/transcodeKTX2.js +8 -8
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -22
- package/Source/Core/Check.d.ts +127 -0
- package/Source/Core/Check.js +0 -1
- package/Source/Core/Geometry.js +1 -1
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/PixelFormat.js +1 -0
- package/Source/Core/PolygonGeometry.js +1 -1
- package/Source/Core/Rectangle.js +89 -0
- package/Source/Core/VerticalExaggeration.js +2 -1
- package/Source/DataSources/DataSourceDisplay.js +5 -0
- package/Source/Renderer/ShaderBuilder.js +6 -3
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Billboard.js +37 -3
- package/Source/Scene/BillboardCollection.js +1 -1
- package/Source/Scene/BingMapsImageryProvider.js +4 -0
- package/Source/Scene/Cesium3DTile.js +65 -0
- package/Source/Scene/Cesium3DTilesVoxelProvider.js +2 -9
- package/Source/Scene/Cesium3DTileset.js +52 -40
- package/Source/Scene/ClippingPolygon.js +212 -0
- package/Source/Scene/ClippingPolygonCollection.js +968 -0
- package/Source/Scene/Globe.js +14 -67
- package/Source/Scene/GlobeSurfaceShaderSet.js +81 -15
- package/Source/Scene/GlobeSurfaceTileProvider.js +81 -1
- package/Source/Scene/Label.js +33 -0
- package/Source/Scene/LabelCollection.js +2 -1
- package/Source/Scene/Model/Model.js +83 -0
- package/Source/Scene/Model/Model3DTileContent.js +21 -0
- package/Source/Scene/Model/ModelClippingPolygonsPipelineStage.js +92 -0
- package/Source/Scene/Model/ModelSceneGraph.js +5 -0
- package/Source/Scene/Primitive.js +0 -3
- package/Source/Scene/SensorVolumePortionToDisplay.js +1 -1
- package/Source/Scene/Terrain.js +2 -2
- package/Source/Scene/VoxelBoxShape.js +0 -15
- package/Source/Scene/VoxelCylinderShape.js +14 -131
- package/Source/Scene/VoxelEllipsoidShape.js +136 -227
- package/Source/Scene/VoxelPrimitive.js +106 -14
- package/Source/Scene/VoxelRenderResources.js +9 -3
- package/Source/Scene/VoxelShape.js +0 -10
- package/Source/Scene/processVoxelProperties.js +1 -0
- package/Source/Shaders/Builtin/CzmBuiltins.js +4 -0
- package/Source/Shaders/Builtin/Functions/clipPolygons.glsl +37 -0
- package/Source/Shaders/Builtin/Functions/clipPolygons.js +39 -0
- package/Source/Shaders/Builtin/Functions/unpackClippingExtents.glsl +14 -0
- package/Source/Shaders/Builtin/Functions/unpackClippingExtents.js +15 -0
- package/Source/Shaders/GlobeFS.glsl +12 -0
- package/Source/Shaders/GlobeFS.js +12 -0
- package/Source/Shaders/GlobeVS.glsl +32 -0
- package/Source/Shaders/GlobeVS.js +32 -0
- package/Source/Shaders/Model/GeometryStageVS.glsl +1 -1
- package/Source/Shaders/Model/GeometryStageVS.js +1 -1
- package/Source/Shaders/Model/ModelClippingPolygonsStageFS.glsl +6 -0
- package/Source/Shaders/Model/ModelClippingPolygonsStageFS.js +8 -0
- package/Source/Shaders/Model/ModelClippingPolygonsStageVS.glsl +27 -0
- package/Source/Shaders/Model/ModelClippingPolygonsStageVS.js +29 -0
- package/Source/Shaders/Model/ModelFS.glsl +6 -0
- package/Source/Shaders/Model/ModelFS.js +7 -1
- package/Source/Shaders/Model/ModelVS.glsl +4 -0
- package/Source/Shaders/Model/ModelVS.js +4 -0
- package/Source/Shaders/PolygonSignedDistanceFS.glsl +100 -0
- package/Source/Shaders/PolygonSignedDistanceFS.js +101 -0
- package/Source/Shaders/Voxels/IntersectBox.glsl +21 -47
- package/Source/Shaders/Voxels/IntersectBox.js +21 -47
- package/Source/Shaders/Voxels/IntersectClippingPlanes.glsl +1 -1
- package/Source/Shaders/Voxels/IntersectClippingPlanes.js +1 -1
- package/Source/Shaders/Voxels/IntersectCylinder.glsl +66 -96
- package/Source/Shaders/Voxels/IntersectCylinder.js +66 -96
- package/Source/Shaders/Voxels/IntersectEllipsoid.glsl +226 -154
- package/Source/Shaders/Voxels/IntersectEllipsoid.js +226 -154
- package/Source/Shaders/Voxels/IntersectionUtils.glsl +33 -11
- package/Source/Shaders/Voxels/IntersectionUtils.js +33 -11
- package/Source/Shaders/Voxels/Megatexture.glsl +1 -2
- package/Source/Shaders/Voxels/Megatexture.js +1 -2
- package/Source/Shaders/Voxels/Octree.glsl +14 -9
- package/Source/Shaders/Voxels/Octree.js +14 -9
- package/Source/Shaders/Voxels/VoxelFS.glsl +93 -43
- package/Source/Shaders/Voxels/VoxelFS.js +93 -43
- package/Source/Shaders/Voxels/VoxelUtils.glsl +31 -0
- package/Source/Shaders/Voxels/VoxelUtils.js +33 -0
- package/Source/Shaders/Voxels/convertUvToBox.glsl +24 -3
- package/Source/Shaders/Voxels/convertUvToBox.js +24 -4
- package/Source/Shaders/Voxels/convertUvToCylinder.glsl +50 -8
- package/Source/Shaders/Voxels/convertUvToCylinder.js +50 -8
- package/Source/Shaders/Voxels/convertUvToEllipsoid.glsl +82 -53
- package/Source/Shaders/Voxels/convertUvToEllipsoid.js +82 -53
- package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
- package/Source/Workers/createGeometry.js +1 -1
- package/index.d.ts +478 -35
- package/index.js +61 -52
- package/package.json +2 -2
- package/Build/Workers/chunk-BG4UCVXN.js +0 -73
- package/Build/Workers/chunk-TTUZP4BO.js +0 -501
- package/Build/Workers/chunk-YJEBABKH.js +0 -2977
|
@@ -22,6 +22,9 @@ import PolylineCollection from "./PolylineCollection.js";
|
|
|
22
22
|
import VoxelShapeType from "./VoxelShapeType.js";
|
|
23
23
|
import VoxelTraversal from "./VoxelTraversal.js";
|
|
24
24
|
import CustomShader from "./Model/CustomShader.js";
|
|
25
|
+
import Cartographic from "../Core/Cartographic.js";
|
|
26
|
+
import Ellipsoid from "../Core/Ellipsoid.js";
|
|
27
|
+
import VerticalExaggeration from "../Core/VerticalExaggeration.js";
|
|
25
28
|
|
|
26
29
|
/**
|
|
27
30
|
* A primitive that renders voxel data from a {@link VoxelProvider}.
|
|
@@ -231,6 +234,14 @@ function VoxelPrimitive(options) {
|
|
|
231
234
|
defaultValue(options.modelMatrix, Matrix4.IDENTITY)
|
|
232
235
|
);
|
|
233
236
|
|
|
237
|
+
/**
|
|
238
|
+
* Model matrix with vertical exaggeration applied. Only used for BOX shape type.
|
|
239
|
+
*
|
|
240
|
+
* @type {Matrix4}
|
|
241
|
+
* @private
|
|
242
|
+
*/
|
|
243
|
+
this._exaggeratedModelMatrix = Matrix4.clone(this._modelMatrix);
|
|
244
|
+
|
|
234
245
|
/**
|
|
235
246
|
* The primitive's model matrix multiplied by the provider's model matrix.
|
|
236
247
|
* This member is not known until the provider is ready.
|
|
@@ -320,18 +331,12 @@ function VoxelPrimitive(options) {
|
|
|
320
331
|
*/
|
|
321
332
|
this._transformNormalLocalToWorld = new Matrix3();
|
|
322
333
|
|
|
323
|
-
/**
|
|
324
|
-
* @type {number}
|
|
325
|
-
* @private
|
|
326
|
-
*/
|
|
327
|
-
this._stepSizeUv = 1.0;
|
|
328
|
-
|
|
329
334
|
// Rendering
|
|
330
335
|
/**
|
|
331
336
|
* @type {boolean}
|
|
332
337
|
* @private
|
|
333
338
|
*/
|
|
334
|
-
this._jitter =
|
|
339
|
+
this._jitter = false;
|
|
335
340
|
|
|
336
341
|
/**
|
|
337
342
|
* @type {boolean}
|
|
@@ -469,12 +474,25 @@ function initialize(primitive, provider) {
|
|
|
469
474
|
primitive.minClippingBounds = VoxelShapeType.getMinBounds(shapeType);
|
|
470
475
|
primitive.maxClippingBounds = VoxelShapeType.getMaxBounds(shapeType);
|
|
471
476
|
|
|
477
|
+
// Initialize the exaggerated versions of bounds and model matrix
|
|
478
|
+
primitive._exaggeratedMinBounds = Cartesian3.clone(
|
|
479
|
+
primitive._minBounds,
|
|
480
|
+
primitive._exaggeratedMinBounds
|
|
481
|
+
);
|
|
482
|
+
primitive._exaggeratedMaxBounds = Cartesian3.clone(
|
|
483
|
+
primitive._maxBounds,
|
|
484
|
+
primitive._exaggeratedMaxBounds
|
|
485
|
+
);
|
|
486
|
+
primitive._exaggeratedModelMatrix = Matrix4.clone(
|
|
487
|
+
primitive._modelMatrix,
|
|
488
|
+
primitive._exaggeratedModelMatrix
|
|
489
|
+
);
|
|
490
|
+
|
|
472
491
|
checkTransformAndBounds(primitive, provider);
|
|
473
492
|
|
|
474
493
|
// Create the shape object, and update it so it is valid for VoxelTraversal
|
|
475
494
|
const ShapeConstructor = VoxelShapeType.getShapeConstructor(shapeType);
|
|
476
495
|
primitive._shape = new ShapeConstructor();
|
|
477
|
-
updateVerticalExaggeration(primitive);
|
|
478
496
|
primitive._shapeVisible = updateShapeAndTransforms(
|
|
479
497
|
primitive,
|
|
480
498
|
primitive._shape,
|
|
@@ -1132,7 +1150,7 @@ VoxelPrimitive.prototype.update = function (frameState) {
|
|
|
1132
1150
|
cameraPositionWorld,
|
|
1133
1151
|
uniforms.cameraPositionUv
|
|
1134
1152
|
);
|
|
1135
|
-
uniforms.stepSize = this.
|
|
1153
|
+
uniforms.stepSize = this._stepSizeMultiplier;
|
|
1136
1154
|
|
|
1137
1155
|
// Render the primitive
|
|
1138
1156
|
const command = frameState.passes.pick
|
|
@@ -1144,11 +1162,16 @@ VoxelPrimitive.prototype.update = function (frameState) {
|
|
|
1144
1162
|
frameState.commandList.push(command);
|
|
1145
1163
|
};
|
|
1146
1164
|
|
|
1165
|
+
const scratchExaggerationScale = new Cartesian3();
|
|
1166
|
+
const scratchExaggerationCenter = new Cartesian3();
|
|
1167
|
+
const scratchCartographicCenter = new Cartographic();
|
|
1168
|
+
const scratchExaggerationTranslation = new Cartesian3();
|
|
1169
|
+
|
|
1147
1170
|
/**
|
|
1148
1171
|
* Update the exaggerated bounds of a primitive to account for vertical exaggeration
|
|
1149
1172
|
* Currently only applies to Ellipsoid shape type
|
|
1150
1173
|
* @param {VoxelPrimitive} primitive
|
|
1151
|
-
* @param {FrameState}
|
|
1174
|
+
* @param {FrameState} frameState
|
|
1152
1175
|
* @private
|
|
1153
1176
|
*/
|
|
1154
1177
|
function updateVerticalExaggeration(primitive, frameState) {
|
|
@@ -1160,16 +1183,87 @@ function updateVerticalExaggeration(primitive, frameState) {
|
|
|
1160
1183
|
primitive._maxBounds,
|
|
1161
1184
|
primitive._exaggeratedMaxBounds
|
|
1162
1185
|
);
|
|
1163
|
-
|
|
1186
|
+
|
|
1187
|
+
if (primitive.shape === VoxelShapeType.ELLIPSOID) {
|
|
1188
|
+
// Apply the exaggeration by stretching the height bounds
|
|
1164
1189
|
const relativeHeight = frameState.verticalExaggerationRelativeHeight;
|
|
1165
1190
|
const exaggeration = frameState.verticalExaggeration;
|
|
1166
1191
|
primitive._exaggeratedMinBounds.z =
|
|
1167
1192
|
(primitive._minBounds.z - relativeHeight) * exaggeration + relativeHeight;
|
|
1168
1193
|
primitive._exaggeratedMaxBounds.z =
|
|
1169
1194
|
(primitive._maxBounds.z - relativeHeight) * exaggeration + relativeHeight;
|
|
1195
|
+
} else if (primitive.shape === VoxelShapeType.BOX) {
|
|
1196
|
+
// Apply the exaggeration via the model matrix
|
|
1197
|
+
const exaggerationScale = Cartesian3.fromElements(
|
|
1198
|
+
1.0,
|
|
1199
|
+
1.0,
|
|
1200
|
+
frameState.verticalExaggeration,
|
|
1201
|
+
scratchExaggerationScale
|
|
1202
|
+
);
|
|
1203
|
+
primitive._exaggeratedModelMatrix = Matrix4.multiplyByScale(
|
|
1204
|
+
primitive._modelMatrix,
|
|
1205
|
+
exaggerationScale,
|
|
1206
|
+
primitive._exaggeratedModelMatrix
|
|
1207
|
+
);
|
|
1208
|
+
primitive._exaggeratedModelMatrix = Matrix4.multiplyByTranslation(
|
|
1209
|
+
primitive._exaggeratedModelMatrix,
|
|
1210
|
+
computeBoxExaggerationTranslation(primitive, frameState),
|
|
1211
|
+
primitive._exaggeratedModelMatrix
|
|
1212
|
+
);
|
|
1170
1213
|
}
|
|
1171
1214
|
}
|
|
1172
1215
|
|
|
1216
|
+
function computeBoxExaggerationTranslation(primitive, frameState) {
|
|
1217
|
+
// Compute translation based on box center, relative height, and exaggeration
|
|
1218
|
+
const {
|
|
1219
|
+
shapeTransform = Matrix4.IDENTITY,
|
|
1220
|
+
globalTransform = Matrix4.IDENTITY,
|
|
1221
|
+
} = primitive._provider;
|
|
1222
|
+
|
|
1223
|
+
// Find the Cartesian position of the center of the OBB
|
|
1224
|
+
const initialCenter = Matrix4.getTranslation(
|
|
1225
|
+
shapeTransform,
|
|
1226
|
+
scratchExaggerationCenter
|
|
1227
|
+
);
|
|
1228
|
+
const intermediateCenter = Matrix4.multiplyByPoint(
|
|
1229
|
+
primitive._modelMatrix,
|
|
1230
|
+
initialCenter,
|
|
1231
|
+
scratchExaggerationCenter
|
|
1232
|
+
);
|
|
1233
|
+
const transformedCenter = Matrix4.multiplyByPoint(
|
|
1234
|
+
globalTransform,
|
|
1235
|
+
intermediateCenter,
|
|
1236
|
+
scratchExaggerationCenter
|
|
1237
|
+
);
|
|
1238
|
+
|
|
1239
|
+
// Find the cartographic height
|
|
1240
|
+
const ellipsoid = Ellipsoid.WGS84;
|
|
1241
|
+
const centerCartographic = ellipsoid.cartesianToCartographic(
|
|
1242
|
+
transformedCenter,
|
|
1243
|
+
scratchCartographicCenter
|
|
1244
|
+
);
|
|
1245
|
+
|
|
1246
|
+
let centerHeight = 0.0;
|
|
1247
|
+
if (defined(centerCartographic)) {
|
|
1248
|
+
centerHeight = centerCartographic.height;
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
// Find the shift that will put the center in the right position relative
|
|
1252
|
+
// to relativeHeight, after it is scaled by verticalExaggeration
|
|
1253
|
+
const exaggeratedHeight = VerticalExaggeration.getHeight(
|
|
1254
|
+
centerHeight,
|
|
1255
|
+
frameState.verticalExaggeration,
|
|
1256
|
+
frameState.verticalExaggerationRelativeHeight
|
|
1257
|
+
);
|
|
1258
|
+
|
|
1259
|
+
return Cartesian3.fromElements(
|
|
1260
|
+
0.0,
|
|
1261
|
+
0.0,
|
|
1262
|
+
(exaggeratedHeight - centerHeight) / frameState.verticalExaggeration,
|
|
1263
|
+
scratchExaggerationTranslation
|
|
1264
|
+
);
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1173
1267
|
/**
|
|
1174
1268
|
* Initialize primitive properties that are derived from the voxel provider
|
|
1175
1269
|
* @param {VoxelPrimitive} primitive
|
|
@@ -1254,7 +1348,7 @@ function checkTransformAndBounds(primitive, provider) {
|
|
|
1254
1348
|
// Compound model matrix = global transform * model matrix * shape transform
|
|
1255
1349
|
Matrix4.multiplyTransformation(
|
|
1256
1350
|
globalTransform,
|
|
1257
|
-
primitive.
|
|
1351
|
+
primitive._exaggeratedModelMatrix,
|
|
1258
1352
|
primitive._compoundModelMatrix
|
|
1259
1353
|
);
|
|
1260
1354
|
Matrix4.multiplyTransformation(
|
|
@@ -1345,8 +1439,6 @@ function updateShapeAndTransforms(primitive, shape, provider) {
|
|
|
1345
1439
|
);
|
|
1346
1440
|
|
|
1347
1441
|
// Set member variables when the shape is dirty
|
|
1348
|
-
const dimensions = provider.dimensions;
|
|
1349
|
-
primitive._stepSizeUv = shape.computeApproximateStepSize(dimensions);
|
|
1350
1442
|
primitive._transformPositionWorldToUv = Matrix4.multiplyTransformation(
|
|
1351
1443
|
transformPositionLocalToUv,
|
|
1352
1444
|
transformPositionWorldToLocal,
|
|
@@ -3,6 +3,7 @@ import combine from "../Core/combine.js";
|
|
|
3
3
|
import defined from "../Core/defined.js";
|
|
4
4
|
import ShaderBuilder from "../Renderer/ShaderBuilder.js";
|
|
5
5
|
import ShaderDestination from "../Renderer/ShaderDestination.js";
|
|
6
|
+
import VoxelUtils from "../Shaders/Voxels/VoxelUtils.js";
|
|
6
7
|
import VoxelFS from "../Shaders/Voxels/VoxelFS.js";
|
|
7
8
|
import VoxelVS from "../Shaders/Voxels/VoxelVS.js";
|
|
8
9
|
import IntersectionUtils from "../Shaders/Voxels/IntersectionUtils.js";
|
|
@@ -89,6 +90,7 @@ function VoxelRenderResources(primitive) {
|
|
|
89
90
|
customShader.fragmentShaderText,
|
|
90
91
|
"#line 0",
|
|
91
92
|
Octree,
|
|
93
|
+
VoxelUtils,
|
|
92
94
|
IntersectionUtils,
|
|
93
95
|
Megatexture,
|
|
94
96
|
]);
|
|
@@ -124,7 +126,6 @@ function VoxelRenderResources(primitive) {
|
|
|
124
126
|
|
|
125
127
|
const shapeType = primitive._provider.shape;
|
|
126
128
|
if (shapeType === "BOX") {
|
|
127
|
-
shaderBuilder.addDefine("SHAPE_BOX", undefined, ShaderDestination.FRAGMENT);
|
|
128
129
|
shaderBuilder.addFragmentLines([
|
|
129
130
|
convertUvToBox,
|
|
130
131
|
IntersectBox,
|
|
@@ -132,17 +133,22 @@ function VoxelRenderResources(primitive) {
|
|
|
132
133
|
]);
|
|
133
134
|
} else if (shapeType === "CYLINDER") {
|
|
134
135
|
shaderBuilder.addFragmentLines([
|
|
136
|
+
convertUvToCylinder,
|
|
135
137
|
IntersectLongitude,
|
|
136
138
|
IntersectCylinder,
|
|
137
139
|
Intersection,
|
|
138
|
-
convertUvToCylinder,
|
|
139
140
|
]);
|
|
140
141
|
} else if (shapeType === "ELLIPSOID") {
|
|
142
|
+
shaderBuilder.addDefine(
|
|
143
|
+
"SHAPE_ELLIPSOID",
|
|
144
|
+
undefined,
|
|
145
|
+
ShaderDestination.FRAGMENT
|
|
146
|
+
);
|
|
141
147
|
shaderBuilder.addFragmentLines([
|
|
148
|
+
convertUvToEllipsoid,
|
|
142
149
|
IntersectLongitude,
|
|
143
150
|
IntersectEllipsoid,
|
|
144
151
|
Intersection,
|
|
145
|
-
convertUvToEllipsoid,
|
|
146
152
|
]);
|
|
147
153
|
}
|
|
148
154
|
|
|
@@ -130,16 +130,6 @@ VoxelShape.prototype.computeOrientedBoundingBoxForTile =
|
|
|
130
130
|
VoxelShape.prototype.computeOrientedBoundingBoxForSample =
|
|
131
131
|
DeveloperError.throwInstantiationError;
|
|
132
132
|
|
|
133
|
-
/**
|
|
134
|
-
* Computes an approximate step size for raymarching the root tile of a voxel grid.
|
|
135
|
-
* The update function must be called before calling this function.
|
|
136
|
-
*
|
|
137
|
-
* @param {Cartesian3} voxelDimensions The voxel grid dimensions for a tile.
|
|
138
|
-
* @returns {number} The step size.
|
|
139
|
-
*/
|
|
140
|
-
VoxelShape.prototype.computeApproximateStepSize =
|
|
141
|
-
DeveloperError.throwInstantiationError;
|
|
142
|
-
|
|
143
133
|
/**
|
|
144
134
|
* Defines the minimum bounds of the shape. The meaning can vary per-shape.
|
|
145
135
|
*
|
|
@@ -153,6 +153,7 @@ function processVoxelProperties(renderResources, primitive) {
|
|
|
153
153
|
shaderBuilder.addStructField(voxelStructId, "vec3", "viewDirWorld");
|
|
154
154
|
shaderBuilder.addStructField(voxelStructId, "vec3", "surfaceNormal");
|
|
155
155
|
shaderBuilder.addStructField(voxelStructId, "float", "travelDistance");
|
|
156
|
+
shaderBuilder.addStructField(voxelStructId, "int", "stepCount");
|
|
156
157
|
shaderBuilder.addStructField(voxelStructId, "int", "tileIndex");
|
|
157
158
|
shaderBuilder.addStructField(voxelStructId, "int", "sampleIndex");
|
|
158
159
|
|
|
@@ -64,6 +64,7 @@ import czm_cascadeColor from './Functions/cascadeColor.js'
|
|
|
64
64
|
import czm_cascadeDistance from './Functions/cascadeDistance.js'
|
|
65
65
|
import czm_cascadeMatrix from './Functions/cascadeMatrix.js'
|
|
66
66
|
import czm_cascadeWeights from './Functions/cascadeWeights.js'
|
|
67
|
+
import czm_clipPolygons from './Functions/clipPolygons.js'
|
|
67
68
|
import czm_columbusViewMorph from './Functions/columbusViewMorph.js'
|
|
68
69
|
import czm_computeAtmosphereColor from './Functions/computeAtmosphereColor.js'
|
|
69
70
|
import czm_computeGroundAtmosphereScattering from './Functions/computeGroundAtmosphereScattering.js'
|
|
@@ -127,6 +128,7 @@ import czm_transformPlane from './Functions/transformPlane.js'
|
|
|
127
128
|
import czm_translateRelativeToEye from './Functions/translateRelativeToEye.js'
|
|
128
129
|
import czm_translucentPhong from './Functions/translucentPhong.js'
|
|
129
130
|
import czm_transpose from './Functions/transpose.js'
|
|
131
|
+
import czm_unpackClippingExtents from './Functions/unpackClippingExtents.js'
|
|
130
132
|
import czm_unpackDepth from './Functions/unpackDepth.js'
|
|
131
133
|
import czm_unpackFloat from './Functions/unpackFloat.js'
|
|
132
134
|
import czm_unpackUint from './Functions/unpackUint.js'
|
|
@@ -203,6 +205,7 @@ export default {
|
|
|
203
205
|
czm_cascadeDistance : czm_cascadeDistance,
|
|
204
206
|
czm_cascadeMatrix : czm_cascadeMatrix,
|
|
205
207
|
czm_cascadeWeights : czm_cascadeWeights,
|
|
208
|
+
czm_clipPolygons : czm_clipPolygons,
|
|
206
209
|
czm_columbusViewMorph : czm_columbusViewMorph,
|
|
207
210
|
czm_computeAtmosphereColor : czm_computeAtmosphereColor,
|
|
208
211
|
czm_computeGroundAtmosphereScattering : czm_computeGroundAtmosphereScattering,
|
|
@@ -266,6 +269,7 @@ export default {
|
|
|
266
269
|
czm_translateRelativeToEye : czm_translateRelativeToEye,
|
|
267
270
|
czm_translucentPhong : czm_translucentPhong,
|
|
268
271
|
czm_transpose : czm_transpose,
|
|
272
|
+
czm_unpackClippingExtents : czm_unpackClippingExtents,
|
|
269
273
|
czm_unpackDepth : czm_unpackDepth,
|
|
270
274
|
czm_unpackFloat : czm_unpackFloat,
|
|
271
275
|
czm_unpackUint : czm_unpackUint,
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
float getSignedDistance(vec2 uv, highp sampler2D clippingDistance) {
|
|
2
|
+
float signedDistance = texture(clippingDistance, uv).r;
|
|
3
|
+
return (signedDistance - 0.5) * 2.0;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
void czm_clipPolygons(highp sampler2D clippingDistance, int extentsLength, vec2 clippingPosition, int regionIndex) {
|
|
7
|
+
// Position is completely outside of polygons bounds
|
|
8
|
+
vec2 rectUv = clippingPosition;
|
|
9
|
+
if (regionIndex < 0 || rectUv.x <= 0.0 || rectUv.y <= 0.0 || rectUv.x >= 1.0 || rectUv.y >= 1.0) {
|
|
10
|
+
#ifdef CLIPPING_INVERSE
|
|
11
|
+
discard;
|
|
12
|
+
#endif
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
vec2 clippingDistanceTextureDimensions = vec2(textureSize(clippingDistance, 0));
|
|
17
|
+
vec2 sampleOffset = max(1.0 / clippingDistanceTextureDimensions, vec2(0.005));
|
|
18
|
+
float dimension = float(extentsLength);
|
|
19
|
+
if (extentsLength > 2) {
|
|
20
|
+
dimension = ceil(log2(float(extentsLength)));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
vec2 textureOffset = vec2(mod(float(regionIndex), dimension), floor(float(regionIndex) / dimension)) / dimension;
|
|
24
|
+
vec2 uv = textureOffset + rectUv / dimension;
|
|
25
|
+
|
|
26
|
+
float signedDistance = getSignedDistance(uv, clippingDistance);
|
|
27
|
+
|
|
28
|
+
#ifdef CLIPPING_INVERSE
|
|
29
|
+
if (signedDistance > 0.0) {
|
|
30
|
+
discard;
|
|
31
|
+
}
|
|
32
|
+
#else
|
|
33
|
+
if (signedDistance < 0.0) {
|
|
34
|
+
discard;
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "float getSignedDistance(vec2 uv, highp sampler2D clippingDistance) {\n\
|
|
3
|
+
float signedDistance = texture(clippingDistance, uv).r;\n\
|
|
4
|
+
return (signedDistance - 0.5) * 2.0;\n\
|
|
5
|
+
}\n\
|
|
6
|
+
\n\
|
|
7
|
+
void czm_clipPolygons(highp sampler2D clippingDistance, int extentsLength, vec2 clippingPosition, int regionIndex) {\n\
|
|
8
|
+
// Position is completely outside of polygons bounds\n\
|
|
9
|
+
vec2 rectUv = clippingPosition;\n\
|
|
10
|
+
if (regionIndex < 0 || rectUv.x <= 0.0 || rectUv.y <= 0.0 || rectUv.x >= 1.0 || rectUv.y >= 1.0) {\n\
|
|
11
|
+
#ifdef CLIPPING_INVERSE \n\
|
|
12
|
+
discard;\n\
|
|
13
|
+
#endif\n\
|
|
14
|
+
return;\n\
|
|
15
|
+
}\n\
|
|
16
|
+
\n\
|
|
17
|
+
vec2 clippingDistanceTextureDimensions = vec2(textureSize(clippingDistance, 0));\n\
|
|
18
|
+
vec2 sampleOffset = max(1.0 / clippingDistanceTextureDimensions, vec2(0.005));\n\
|
|
19
|
+
float dimension = float(extentsLength);\n\
|
|
20
|
+
if (extentsLength > 2) {\n\
|
|
21
|
+
dimension = ceil(log2(float(extentsLength)));\n\
|
|
22
|
+
}\n\
|
|
23
|
+
\n\
|
|
24
|
+
vec2 textureOffset = vec2(mod(float(regionIndex), dimension), floor(float(regionIndex) / dimension)) / dimension;\n\
|
|
25
|
+
vec2 uv = textureOffset + rectUv / dimension;\n\
|
|
26
|
+
\n\
|
|
27
|
+
float signedDistance = getSignedDistance(uv, clippingDistance);\n\
|
|
28
|
+
\n\
|
|
29
|
+
#ifdef CLIPPING_INVERSE\n\
|
|
30
|
+
if (signedDistance > 0.0) {\n\
|
|
31
|
+
discard;\n\
|
|
32
|
+
}\n\
|
|
33
|
+
#else\n\
|
|
34
|
+
if (signedDistance < 0.0) {\n\
|
|
35
|
+
discard;\n\
|
|
36
|
+
}\n\
|
|
37
|
+
#endif\n\
|
|
38
|
+
}\n\
|
|
39
|
+
";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
vec2 getLookupUv(vec2 dimensions, int i) {
|
|
2
|
+
int pixY = i / int(dimensions.x);
|
|
3
|
+
int pixX = i - (pixY * int(dimensions.x));
|
|
4
|
+
float pixelWidth = 1.0 / dimensions.x;
|
|
5
|
+
float pixelHeight = 1.0 / dimensions.y;
|
|
6
|
+
float u = (float(pixX) + 0.5) * pixelWidth; // sample from center of pixel
|
|
7
|
+
float v = (float(pixY) + 0.5) * pixelHeight;
|
|
8
|
+
return vec2(u, v);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
vec4 czm_unpackClippingExtents(highp sampler2D extentsTexture, int index) {
|
|
12
|
+
vec2 textureDimensions = vec2(textureSize(extentsTexture, 0));
|
|
13
|
+
return texture(extentsTexture, getLookupUv(textureDimensions, index));
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "vec2 getLookupUv(vec2 dimensions, int i) {\n\
|
|
3
|
+
int pixY = i / int(dimensions.x);\n\
|
|
4
|
+
int pixX = i - (pixY * int(dimensions.x));\n\
|
|
5
|
+
float pixelWidth = 1.0 / dimensions.x;\n\
|
|
6
|
+
float pixelHeight = 1.0 / dimensions.y;\n\
|
|
7
|
+
float u = (float(pixX) + 0.5) * pixelWidth; // sample from center of pixel\n\
|
|
8
|
+
float v = (float(pixY) + 0.5) * pixelHeight;\n\
|
|
9
|
+
return vec2(u, v);\n\
|
|
10
|
+
}\n\
|
|
11
|
+
\n\
|
|
12
|
+
vec4 czm_unpackClippingExtents(highp sampler2D extentsTexture, int index) {\n\
|
|
13
|
+
vec2 textureDimensions = vec2(textureSize(extentsTexture, 0));\n\
|
|
14
|
+
return texture(extentsTexture, getLookupUv(textureDimensions, index));\n\
|
|
15
|
+
}";
|
|
@@ -77,6 +77,12 @@ uniform mat4 u_clippingPlanesMatrix;
|
|
|
77
77
|
uniform vec4 u_clippingPlanesEdgeStyle;
|
|
78
78
|
#endif
|
|
79
79
|
|
|
80
|
+
#ifdef ENABLE_CLIPPING_POLYGONS
|
|
81
|
+
uniform highp sampler2D u_clippingDistance;
|
|
82
|
+
in vec2 v_clippingPosition;
|
|
83
|
+
flat in int v_regionIndex;
|
|
84
|
+
#endif
|
|
85
|
+
|
|
80
86
|
#if defined(GROUND_ATMOSPHERE) || defined(FOG) && defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_VERTEX_LIGHTING) || defined(ENABLE_DAYNIGHT_SHADING))
|
|
81
87
|
uniform float u_minimumBrightness;
|
|
82
88
|
#endif
|
|
@@ -413,6 +419,12 @@ void main()
|
|
|
413
419
|
}
|
|
414
420
|
#endif
|
|
415
421
|
|
|
422
|
+
#ifdef ENABLE_CLIPPING_POLYGONS
|
|
423
|
+
vec2 clippingPosition = v_clippingPosition;
|
|
424
|
+
int regionIndex = v_regionIndex;
|
|
425
|
+
clipPolygons(u_clippingDistance, CLIPPING_POLYGON_REGIONS_LENGTH, clippingPosition, regionIndex);
|
|
426
|
+
#endif
|
|
427
|
+
|
|
416
428
|
#ifdef HIGHLIGHT_FILL_TILE
|
|
417
429
|
finalColor = vec4(mix(finalColor.rgb, u_fillHighlightColor.rgb, u_fillHighlightColor.a), finalColor.a);
|
|
418
430
|
#endif
|
|
@@ -78,6 +78,12 @@ uniform mat4 u_clippingPlanesMatrix;\n\
|
|
|
78
78
|
uniform vec4 u_clippingPlanesEdgeStyle;\n\
|
|
79
79
|
#endif\n\
|
|
80
80
|
\n\
|
|
81
|
+
#ifdef ENABLE_CLIPPING_POLYGONS\n\
|
|
82
|
+
uniform highp sampler2D u_clippingDistance;\n\
|
|
83
|
+
in vec2 v_clippingPosition;\n\
|
|
84
|
+
flat in int v_regionIndex;\n\
|
|
85
|
+
#endif\n\
|
|
86
|
+
\n\
|
|
81
87
|
#if defined(GROUND_ATMOSPHERE) || defined(FOG) && defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_VERTEX_LIGHTING) || defined(ENABLE_DAYNIGHT_SHADING))\n\
|
|
82
88
|
uniform float u_minimumBrightness;\n\
|
|
83
89
|
#endif\n\
|
|
@@ -414,6 +420,12 @@ void main()\n\
|
|
|
414
420
|
}\n\
|
|
415
421
|
#endif\n\
|
|
416
422
|
\n\
|
|
423
|
+
#ifdef ENABLE_CLIPPING_POLYGONS\n\
|
|
424
|
+
vec2 clippingPosition = v_clippingPosition;\n\
|
|
425
|
+
int regionIndex = v_regionIndex;\n\
|
|
426
|
+
clipPolygons(u_clippingDistance, CLIPPING_POLYGON_REGIONS_LENGTH, clippingPosition, regionIndex); \n\
|
|
427
|
+
#endif\n\
|
|
428
|
+
\n\
|
|
417
429
|
#ifdef HIGHLIGHT_FILL_TILE\n\
|
|
418
430
|
finalColor = vec4(mix(finalColor.rgb, u_fillHighlightColor.rgb, u_fillHighlightColor.a), finalColor.a);\n\
|
|
419
431
|
#endif\n\
|
|
@@ -46,6 +46,12 @@ out vec3 v_atmosphereMieColor;
|
|
|
46
46
|
out float v_atmosphereOpacity;
|
|
47
47
|
#endif
|
|
48
48
|
|
|
49
|
+
#ifdef ENABLE_CLIPPING_POLYGONS
|
|
50
|
+
uniform highp sampler2D u_clippingExtents;
|
|
51
|
+
out vec2 v_clippingPosition;
|
|
52
|
+
flat out int v_regionIndex;
|
|
53
|
+
#endif
|
|
54
|
+
|
|
49
55
|
// These functions are generated at runtime.
|
|
50
56
|
vec4 getPosition(vec3 position, float height, vec2 textureCoordinates);
|
|
51
57
|
float get2DYPositionFraction(vec2 textureCoordinates);
|
|
@@ -207,6 +213,32 @@ void main()
|
|
|
207
213
|
v_normalEC = czm_normal3D * v_normalMC;
|
|
208
214
|
#endif
|
|
209
215
|
|
|
216
|
+
#ifdef ENABLE_CLIPPING_POLYGONS
|
|
217
|
+
vec2 sphericalLatLong = czm_approximateSphericalCoordinates(position3DWC);
|
|
218
|
+
sphericalLatLong.y = czm_branchFreeTernary(sphericalLatLong.y < czm_pi, sphericalLatLong.y, sphericalLatLong.y - czm_twoPi);
|
|
219
|
+
|
|
220
|
+
vec2 minDistance = vec2(czm_infinity);
|
|
221
|
+
v_clippingPosition = vec2(czm_infinity);
|
|
222
|
+
v_regionIndex = -1;
|
|
223
|
+
|
|
224
|
+
for (int regionIndex = 0; regionIndex < CLIPPING_POLYGON_REGIONS_LENGTH; regionIndex++) {
|
|
225
|
+
vec4 extents = unpackClippingExtents(u_clippingExtents, regionIndex);
|
|
226
|
+
vec2 rectUv = (sphericalLatLong.yx - extents.yx) * extents.wz;
|
|
227
|
+
|
|
228
|
+
vec2 clamped = clamp(rectUv, vec2(0.0), vec2(1.0));
|
|
229
|
+
vec2 distance = abs(rectUv - clamped) * extents.wz;
|
|
230
|
+
|
|
231
|
+
float threshold = 0.01;
|
|
232
|
+
if (minDistance.x > distance.x || minDistance.y > distance.y) {
|
|
233
|
+
minDistance = distance;
|
|
234
|
+
v_clippingPosition = rectUv;
|
|
235
|
+
if (rectUv.x > threshold && rectUv.y > threshold && rectUv.x < 1.0 - threshold && rectUv.y < 1.0 - threshold) {
|
|
236
|
+
v_regionIndex = regionIndex;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
#endif
|
|
241
|
+
|
|
210
242
|
#if defined(FOG) || (defined(GROUND_ATMOSPHERE) && !defined(PER_FRAGMENT_GROUND_ATMOSPHERE))
|
|
211
243
|
|
|
212
244
|
bool dynamicLighting = false;
|
|
@@ -47,6 +47,12 @@ out vec3 v_atmosphereMieColor;\n\
|
|
|
47
47
|
out float v_atmosphereOpacity;\n\
|
|
48
48
|
#endif\n\
|
|
49
49
|
\n\
|
|
50
|
+
#ifdef ENABLE_CLIPPING_POLYGONS\n\
|
|
51
|
+
uniform highp sampler2D u_clippingExtents;\n\
|
|
52
|
+
out vec2 v_clippingPosition;\n\
|
|
53
|
+
flat out int v_regionIndex;\n\
|
|
54
|
+
#endif\n\
|
|
55
|
+
\n\
|
|
50
56
|
// These functions are generated at runtime.\n\
|
|
51
57
|
vec4 getPosition(vec3 position, float height, vec2 textureCoordinates);\n\
|
|
52
58
|
float get2DYPositionFraction(vec2 textureCoordinates);\n\
|
|
@@ -208,6 +214,32 @@ void main()\n\
|
|
|
208
214
|
v_normalEC = czm_normal3D * v_normalMC;\n\
|
|
209
215
|
#endif\n\
|
|
210
216
|
\n\
|
|
217
|
+
#ifdef ENABLE_CLIPPING_POLYGONS\n\
|
|
218
|
+
vec2 sphericalLatLong = czm_approximateSphericalCoordinates(position3DWC);\n\
|
|
219
|
+
sphericalLatLong.y = czm_branchFreeTernary(sphericalLatLong.y < czm_pi, sphericalLatLong.y, sphericalLatLong.y - czm_twoPi);\n\
|
|
220
|
+
\n\
|
|
221
|
+
vec2 minDistance = vec2(czm_infinity);\n\
|
|
222
|
+
v_clippingPosition = vec2(czm_infinity);\n\
|
|
223
|
+
v_regionIndex = -1;\n\
|
|
224
|
+
\n\
|
|
225
|
+
for (int regionIndex = 0; regionIndex < CLIPPING_POLYGON_REGIONS_LENGTH; regionIndex++) {\n\
|
|
226
|
+
vec4 extents = unpackClippingExtents(u_clippingExtents, regionIndex);\n\
|
|
227
|
+
vec2 rectUv = (sphericalLatLong.yx - extents.yx) * extents.wz;\n\
|
|
228
|
+
\n\
|
|
229
|
+
vec2 clamped = clamp(rectUv, vec2(0.0), vec2(1.0));\n\
|
|
230
|
+
vec2 distance = abs(rectUv - clamped) * extents.wz;\n\
|
|
231
|
+
\n\
|
|
232
|
+
float threshold = 0.01;\n\
|
|
233
|
+
if (minDistance.x > distance.x || minDistance.y > distance.y) {\n\
|
|
234
|
+
minDistance = distance;\n\
|
|
235
|
+
v_clippingPosition = rectUv;\n\
|
|
236
|
+
if (rectUv.x > threshold && rectUv.y > threshold && rectUv.x < 1.0 - threshold && rectUv.y < 1.0 - threshold) {\n\
|
|
237
|
+
v_regionIndex = regionIndex;\n\
|
|
238
|
+
}\n\
|
|
239
|
+
}\n\
|
|
240
|
+
}\n\
|
|
241
|
+
#endif\n\
|
|
242
|
+
\n\
|
|
211
243
|
#if defined(FOG) || (defined(GROUND_ATMOSPHERE) && !defined(PER_FRAGMENT_GROUND_ATMOSPHERE))\n\
|
|
212
244
|
\n\
|
|
213
245
|
bool dynamicLighting = false;\n\
|
|
@@ -16,7 +16,7 @@ vec4 geometryStage(inout ProcessedAttributes attributes, mat4 modelView, mat3 no
|
|
|
16
16
|
#endif
|
|
17
17
|
|
|
18
18
|
// Sometimes the custom shader and/or style needs this
|
|
19
|
-
#if defined(COMPUTE_POSITION_WC_CUSTOM_SHADER) || defined(COMPUTE_POSITION_WC_STYLE) || defined(COMPUTE_POSITION_WC_ATMOSPHERE)
|
|
19
|
+
#if defined(COMPUTE_POSITION_WC_CUSTOM_SHADER) || defined(COMPUTE_POSITION_WC_STYLE) || defined(COMPUTE_POSITION_WC_ATMOSPHERE) || defined(ENABLE_CLIPPING_POLYGONS)
|
|
20
20
|
// Note that this is a 32-bit position which may result in jitter on small
|
|
21
21
|
// scales.
|
|
22
22
|
v_positionWC = (czm_model * vec4(positionMC, 1.0)).xyz;
|
|
@@ -17,7 +17,7 @@ export default "vec4 geometryStage(inout ProcessedAttributes attributes, mat4 mo
|
|
|
17
17
|
#endif\n\
|
|
18
18
|
\n\
|
|
19
19
|
// Sometimes the custom shader and/or style needs this\n\
|
|
20
|
-
#if defined(COMPUTE_POSITION_WC_CUSTOM_SHADER) || defined(COMPUTE_POSITION_WC_STYLE) || defined(COMPUTE_POSITION_WC_ATMOSPHERE)\n\
|
|
20
|
+
#if defined(COMPUTE_POSITION_WC_CUSTOM_SHADER) || defined(COMPUTE_POSITION_WC_STYLE) || defined(COMPUTE_POSITION_WC_ATMOSPHERE) || defined(ENABLE_CLIPPING_POLYGONS)\n\
|
|
21
21
|
// Note that this is a 32-bit position which may result in jitter on small\n\
|
|
22
22
|
// scales.\n\
|
|
23
23
|
v_positionWC = (czm_model * vec4(positionMC, 1.0)).xyz;\n\
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "void modelClippingPolygonsStage()\n\
|
|
3
|
+
{\n\
|
|
4
|
+
vec2 clippingPosition = v_clippingPosition;\n\
|
|
5
|
+
int regionIndex = v_regionIndex;\n\
|
|
6
|
+
czm_clipPolygons(model_clippingDistance, CLIPPING_POLYGON_REGIONS_LENGTH, clippingPosition, regionIndex);\n\
|
|
7
|
+
}\n\
|
|
8
|
+
";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
void modelClippingPolygonsStage(ProcessedAttributes attributes)
|
|
2
|
+
{
|
|
3
|
+
vec2 sphericalLatLong = czm_approximateSphericalCoordinates(v_positionWC);
|
|
4
|
+
sphericalLatLong.y = czm_branchFreeTernary(sphericalLatLong.y < czm_pi, sphericalLatLong.y, sphericalLatLong.y - czm_twoPi);
|
|
5
|
+
|
|
6
|
+
vec2 minDistance = vec2(czm_infinity);
|
|
7
|
+
v_regionIndex = -1;
|
|
8
|
+
v_clippingPosition = vec2(czm_infinity);
|
|
9
|
+
|
|
10
|
+
for (int regionIndex = 0; regionIndex < CLIPPING_POLYGON_REGIONS_LENGTH; regionIndex++) {
|
|
11
|
+
vec4 extents = czm_unpackClippingExtents(model_clippingExtents, regionIndex);
|
|
12
|
+
vec2 rectUv = (sphericalLatLong.yx - extents.yx) * extents.wz;
|
|
13
|
+
|
|
14
|
+
vec2 clamped = clamp(rectUv, vec2(0.0), vec2(1.0));
|
|
15
|
+
vec2 distance = abs(rectUv - clamped) * extents.wz;
|
|
16
|
+
|
|
17
|
+
if (minDistance.x > distance.x || minDistance.y > distance.y) {
|
|
18
|
+
minDistance = distance;
|
|
19
|
+
v_clippingPosition = rectUv;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
float threshold = 0.01;
|
|
23
|
+
if (rectUv.x > threshold && rectUv.y > threshold && rectUv.x < 1.0 - threshold && rectUv.y < 1.0 - threshold) {
|
|
24
|
+
v_regionIndex = regionIndex;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
+
export default "void modelClippingPolygonsStage(ProcessedAttributes attributes)\n\
|
|
3
|
+
{\n\
|
|
4
|
+
vec2 sphericalLatLong = czm_approximateSphericalCoordinates(v_positionWC);\n\
|
|
5
|
+
sphericalLatLong.y = czm_branchFreeTernary(sphericalLatLong.y < czm_pi, sphericalLatLong.y, sphericalLatLong.y - czm_twoPi);\n\
|
|
6
|
+
\n\
|
|
7
|
+
vec2 minDistance = vec2(czm_infinity);\n\
|
|
8
|
+
v_regionIndex = -1;\n\
|
|
9
|
+
v_clippingPosition = vec2(czm_infinity);\n\
|
|
10
|
+
\n\
|
|
11
|
+
for (int regionIndex = 0; regionIndex < CLIPPING_POLYGON_REGIONS_LENGTH; regionIndex++) {\n\
|
|
12
|
+
vec4 extents = czm_unpackClippingExtents(model_clippingExtents, regionIndex);\n\
|
|
13
|
+
vec2 rectUv = (sphericalLatLong.yx - extents.yx) * extents.wz;\n\
|
|
14
|
+
\n\
|
|
15
|
+
vec2 clamped = clamp(rectUv, vec2(0.0), vec2(1.0));\n\
|
|
16
|
+
vec2 distance = abs(rectUv - clamped) * extents.wz;\n\
|
|
17
|
+
\n\
|
|
18
|
+
if (minDistance.x > distance.x || minDistance.y > distance.y) {\n\
|
|
19
|
+
minDistance = distance;\n\
|
|
20
|
+
v_clippingPosition = rectUv;\n\
|
|
21
|
+
}\n\
|
|
22
|
+
\n\
|
|
23
|
+
float threshold = 0.01;\n\
|
|
24
|
+
if (rectUv.x > threshold && rectUv.y > threshold && rectUv.x < 1.0 - threshold && rectUv.y < 1.0 - threshold) {\n\
|
|
25
|
+
v_regionIndex = regionIndex;\n\
|
|
26
|
+
}\n\
|
|
27
|
+
}\n\
|
|
28
|
+
}\n\
|
|
29
|
+
";
|