@cesium/engine 8.0.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Build/ThirdParty/Workers/z-worker-pako.js +1 -5
- package/Build/Workers/{chunk-UEXTBDBE.js → chunk-24YTYWNB.js} +10 -10
- package/Build/Workers/{chunk-2A75IWRS.js → chunk-2632RVPI.js} +7 -7
- package/Build/Workers/{chunk-TTUZP4BO.js → chunk-2KACWKS4.js} +4 -4
- package/Build/Workers/{chunk-YJEBABKH.js → chunk-2XPLH3JY.js} +7 -7
- package/Build/Workers/{chunk-7TC63SJW.js → chunk-2ZBL3MVO.js} +8 -8
- package/Build/Workers/{chunk-GRC2ZTAF.js → chunk-3NCVAGDA.js} +14 -14
- package/Build/Workers/{chunk-PGSJK77E.js → chunk-5R6VWLMH.js} +6 -6
- package/Build/Workers/{chunk-BROJAZRZ.js → chunk-5TIV3L26.js} +13 -13
- package/Build/Workers/{chunk-MDWEGWPA.js → chunk-6WF3KIF5.js} +10 -10
- package/Build/Workers/{chunk-BIKA3NRA.js → chunk-73FKKY52.js} +5 -5
- package/Build/Workers/{chunk-FJKNFAKQ.js → chunk-7COR472O.js} +10 -10
- package/Build/Workers/{chunk-OGXZVPPM.js → chunk-ADOVHYWO.js} +5 -5
- package/Build/Workers/{chunk-HU6N6EXB.js → chunk-BCU2LH5T.js} +12 -11
- package/Build/Workers/{chunk-I46ZRR5W.js → chunk-C3XBUYBO.js} +17 -17
- package/Build/Workers/{chunk-EHWHNOEX.js → chunk-C6OI26DR.js} +1 -1
- package/Build/Workers/{chunk-EERJKOAF.js → chunk-CO35JNNE.js} +4 -4
- package/Build/Workers/{chunk-SH5USDPI.js → chunk-DGDUKCJJ.js} +6 -6
- package/Build/Workers/{chunk-2UPKWTMJ.js → chunk-DPUSFA7S.js} +6 -6
- package/Build/Workers/{chunk-Z3TIFFGF.js → chunk-E6WXPSJS.js} +7 -7
- package/Build/Workers/{chunk-4H7PY4U5.js → chunk-EOXYZ34O.js} +2 -2
- package/Build/Workers/{chunk-FZRIVR7Y.js → chunk-EPKE7GE3.js} +5 -5
- package/Build/Workers/{chunk-VOXYEYJT.js → chunk-GFA4SMXV.js} +11 -11
- package/Build/Workers/{chunk-F3YA3Y2Z.js → chunk-GXUXEOE2.js} +1 -1
- package/Build/Workers/{chunk-X4356LRH.js → chunk-HBQPB6IH.js} +12 -12
- package/Build/Workers/{chunk-SOWMRMWA.js → chunk-I37B3MZ2.js} +1 -1
- package/Build/Workers/{chunk-2FRVPMCS.js → chunk-L4BW3RUA.js} +7 -7
- package/Build/Workers/{chunk-34FXV7D7.js → chunk-LAQP3SCC.js} +2 -2
- package/Build/Workers/{chunk-FNIRWHJB.js → chunk-LQJ5FFFR.js} +10 -10
- package/Build/Workers/{chunk-Y2ME2IJV.js → chunk-M2AYBTNH.js} +13 -13
- package/Build/Workers/{chunk-DDUQAJ4P.js → chunk-MWV7IZK4.js} +7 -7
- package/Build/Workers/{chunk-STW2DGFI.js → chunk-N4KXMWQU.js} +2 -2
- package/Build/Workers/{chunk-Y5UQJLYE.js → chunk-NP2GYYE5.js} +6 -6
- package/Build/Workers/{chunk-PPH7OFP3.js → chunk-NZWNZA6S.js} +5 -5
- package/Build/Workers/{chunk-EG6PTBY2.js → chunk-P2YAAMT2.js} +15 -15
- package/Build/Workers/{chunk-LPR3YNP2.js → chunk-P4XKB3QZ.js} +5 -5
- package/Build/Workers/{chunk-4DO5W5XZ.js → chunk-PXB7T27O.js} +6 -6
- package/Build/Workers/{chunk-5QULIR53.js → chunk-QCQUZGXI.js} +4 -4
- package/Build/Workers/{chunk-7ZFGPDJA.js → chunk-QKBGRKKG.js} +4 -4
- package/Build/Workers/{chunk-3VAZEH7M.js → chunk-RMOEYCZW.js} +2 -2
- package/Build/Workers/{chunk-GATZHF3K.js → chunk-RSJXEO2A.js} +2 -2
- package/Build/Workers/{chunk-M7ERACJJ.js → chunk-RV7ZOSS6.js} +13 -13
- package/Build/Workers/{chunk-JURN7NPV.js → chunk-SE4PXOEA.js} +17 -17
- package/Build/Workers/{chunk-XGI5BXZY.js → chunk-SS4ESNE3.js} +2 -2
- package/Build/Workers/{chunk-G43QFN4Q.js → chunk-TJBU6GML.js} +6 -6
- package/Build/Workers/{chunk-BBWDMCVU.js → chunk-TZORKRNK.js} +1 -1
- package/Build/Workers/{chunk-23UFSGND.js → chunk-VR5RBW52.js} +7 -7
- package/Build/Workers/{chunk-A5DWLWCY.js → chunk-WHUSTDIB.js} +10 -10
- package/Build/Workers/{chunk-T3XIFPYR.js → chunk-X2F6BEPY.js} +13 -13
- package/Build/Workers/{chunk-BG4UCVXN.js → chunk-X6XOMPWL.js} +3 -3
- package/Build/Workers/{chunk-YWTJ2B4B.js → chunk-YDVSBWEO.js} +1 -1
- package/Build/Workers/{chunk-2FWRMUTY.js → chunk-YV4H2Y7M.js} +4 -4
- package/Build/Workers/{chunk-ZT7KWISZ.js → chunk-Z7FQLK6N.js} +4 -4
- package/Build/Workers/{chunk-F4HFJMGM.js → chunk-ZNVSKMQ2.js} +6 -6
- package/Build/Workers/{chunk-KKCR2YOP.js → chunk-ZYPTP7GS.js} +11 -11
- package/Build/Workers/combineGeometry.js +24 -24
- package/Build/Workers/createBoxGeometry.js +18 -18
- package/Build/Workers/createBoxOutlineGeometry.js +16 -16
- package/Build/Workers/createCircleGeometry.js +26 -26
- package/Build/Workers/createCircleOutlineGeometry.js +19 -19
- package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
- package/Build/Workers/createCorridorGeometry.js +29 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
- package/Build/Workers/createCylinderGeometry.js +20 -20
- package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
- package/Build/Workers/createEllipseGeometry.js +26 -26
- package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
- package/Build/Workers/createEllipsoidGeometry.js +19 -19
- package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
- package/Build/Workers/createFrustumGeometry.js +18 -18
- package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
- package/Build/Workers/createGeometry.js +25 -25
- package/Build/Workers/createGroundPolylineGeometry.js +22 -22
- package/Build/Workers/createPlaneGeometry.js +16 -16
- package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
- package/Build/Workers/createPolygonGeometry.js +33 -33
- package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
- package/Build/Workers/createPolylineGeometry.js +25 -25
- package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
- package/Build/Workers/createRectangleGeometry.js +27 -27
- package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
- package/Build/Workers/createSimplePolylineGeometry.js +23 -23
- package/Build/Workers/createSphereGeometry.js +19 -19
- package/Build/Workers/createSphereOutlineGeometry.js +18 -18
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
- package/Build/Workers/createVectorTileGeometries.js +24 -24
- package/Build/Workers/createVectorTilePoints.js +12 -12
- package/Build/Workers/createVectorTilePolygons.js +22 -22
- package/Build/Workers/createVectorTilePolylines.js +14 -14
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
- package/Build/Workers/createVerticesFromHeightmap.js +22 -22
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +19 -19
- package/Build/Workers/createWallGeometry.js +24 -24
- package/Build/Workers/createWallOutlineGeometry.js +23 -23
- package/Build/Workers/decodeDraco.js +11 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +11 -11
- package/Build/Workers/transcodeKTX2.js +7 -7
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -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/PolygonGeometry.js +1 -1
- package/Source/Core/VerticalExaggeration.js +2 -1
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Billboard.js +32 -0
- package/Source/Scene/BillboardCollection.js +1 -1
- package/Source/Scene/BingMapsImageryProvider.js +4 -0
- package/Source/Scene/Cesium3DTilesVoxelProvider.js +2 -9
- package/Source/Scene/Cesium3DTileset.js +4 -39
- package/Source/Scene/Globe.js +0 -67
- package/Source/Scene/Label.js +33 -0
- package/Source/Scene/LabelCollection.js +2 -1
- package/Source/Scene/Primitive.js +0 -3
- package/Source/Scene/SensorVolumePortionToDisplay.js +1 -1
- 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/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 +251 -34
- package/index.js +77 -76
- package/package.json +2 -2
|
@@ -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
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// See IntersectionUtils.glsl for the definitions of Ray
|
|
2
|
-
//
|
|
1
|
+
// See IntersectionUtils.glsl for the definitions of Ray, RayShapeIntersection,
|
|
2
|
+
// NO_HIT, Intersections
|
|
3
3
|
|
|
4
4
|
/* Box defines (set in Scene/VoxelBoxShape.js)
|
|
5
5
|
#define BOX_INTERSECTION_INDEX ### // always 0
|
|
@@ -8,66 +8,40 @@
|
|
|
8
8
|
uniform vec3 u_renderMinBounds;
|
|
9
9
|
uniform vec3 u_renderMaxBounds;
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
vec3 p0;
|
|
13
|
-
vec3 p1;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
Box constructVoxelBox(in ivec4 octreeCoords, in vec3 tileUv)
|
|
17
|
-
{
|
|
18
|
-
// Find the min/max cornerpoints of the voxel in tile coordinates
|
|
19
|
-
vec3 tileOrigin = vec3(octreeCoords.xyz);
|
|
20
|
-
vec3 numSamples = vec3(u_dimensions);
|
|
21
|
-
vec3 voxelSize = 1.0 / numSamples;
|
|
22
|
-
vec3 coordP0 = floor(tileUv * numSamples) * voxelSize + tileOrigin;
|
|
23
|
-
vec3 coordP1 = coordP0 + voxelSize;
|
|
24
|
-
|
|
25
|
-
// Transform to the UV coordinates of the scaled tileset
|
|
26
|
-
float tileSize = 1.0 / pow(2.0, float(octreeCoords.w));
|
|
27
|
-
vec3 p0 = convertShapeUvToUvSpace(coordP0 * tileSize);
|
|
28
|
-
vec3 p1 = convertShapeUvToUvSpace(coordP1 * tileSize);
|
|
29
|
-
|
|
30
|
-
return Box(p0, p1);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
vec3 getBoxNormal(in Box box, in Ray ray, in float t)
|
|
34
|
-
{
|
|
35
|
-
vec3 hitPoint = ray.pos + t * ray.dir;
|
|
36
|
-
vec3 lower = step(hitPoint, box.p0);
|
|
37
|
-
vec3 upper = step(box.p1, hitPoint);
|
|
38
|
-
return normalize(upper - lower);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Find the distances along a ray at which the ray intersects an axis-aligned box
|
|
42
|
-
// See https://tavianator.com/2011/ray_box.html
|
|
43
|
-
RayShapeIntersection intersectBox(in Ray ray, in Box box)
|
|
11
|
+
RayShapeIntersection intersectBox(in Ray ray, in vec3 minBound, in vec3 maxBound)
|
|
44
12
|
{
|
|
45
13
|
// Consider the box as the intersection of the space between 3 pairs of parallel planes
|
|
46
14
|
// Compute the distance along the ray to each plane
|
|
47
|
-
vec3 t0 = (
|
|
48
|
-
vec3 t1 = (
|
|
15
|
+
vec3 t0 = (minBound - ray.pos) / ray.dir;
|
|
16
|
+
vec3 t1 = (maxBound - ray.pos) / ray.dir;
|
|
49
17
|
|
|
50
18
|
// Identify candidate entries/exits based on distance from ray.pos
|
|
51
19
|
vec3 entries = min(t0, t1);
|
|
52
20
|
vec3 exits = max(t0, t1);
|
|
53
21
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
22
|
+
vec3 directions = sign(ray.dir);
|
|
23
|
+
|
|
24
|
+
// The actual intersection points are the furthest entry and the closest exit
|
|
25
|
+
float lastEntry = maxComponent(entries);
|
|
26
|
+
bvec3 isLastEntry = equal(entries, vec3(lastEntry));
|
|
27
|
+
vec3 entryNormal = -1.0 * vec3(isLastEntry) * directions;
|
|
28
|
+
vec4 entry = vec4(entryNormal, lastEntry);
|
|
57
29
|
|
|
58
|
-
|
|
59
|
-
|
|
30
|
+
float firstExit = minComponent(exits);
|
|
31
|
+
bvec3 isFirstExit = equal(exits, vec3(firstExit));
|
|
32
|
+
vec3 exitNormal = vec3(isLastEntry) * directions;
|
|
33
|
+
vec4 exit = vec4(exitNormal, firstExit);
|
|
60
34
|
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
35
|
+
if (entry.w > exit.w) {
|
|
36
|
+
entry.w = NO_HIT;
|
|
37
|
+
exit.w = NO_HIT;
|
|
64
38
|
}
|
|
65
39
|
|
|
66
|
-
return RayShapeIntersection(
|
|
40
|
+
return RayShapeIntersection(entry, exit);
|
|
67
41
|
}
|
|
68
42
|
|
|
69
43
|
void intersectShape(in Ray ray, inout Intersections ix)
|
|
70
44
|
{
|
|
71
|
-
RayShapeIntersection intersection = intersectBox(ray,
|
|
45
|
+
RayShapeIntersection intersection = intersectBox(ray, u_renderMinBounds, u_renderMaxBounds);
|
|
72
46
|
setShapeIntersection(ix, BOX_INTERSECTION_INDEX, intersection);
|
|
73
47
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//This file is automatically rebuilt by the Cesium build process.
|
|
2
|
-
export default "// See IntersectionUtils.glsl for the definitions of Ray
|
|
3
|
-
//
|
|
2
|
+
export default "// See IntersectionUtils.glsl for the definitions of Ray, RayShapeIntersection,\n\
|
|
3
|
+
// NO_HIT, Intersections\n\
|
|
4
4
|
\n\
|
|
5
5
|
/* Box defines (set in Scene/VoxelBoxShape.js)\n\
|
|
6
6
|
#define BOX_INTERSECTION_INDEX ### // always 0\n\
|
|
@@ -9,67 +9,41 @@ export default "// See IntersectionUtils.glsl for the definitions of Ray and NO_
|
|
|
9
9
|
uniform vec3 u_renderMinBounds;\n\
|
|
10
10
|
uniform vec3 u_renderMaxBounds;\n\
|
|
11
11
|
\n\
|
|
12
|
-
|
|
13
|
-
vec3 p0;\n\
|
|
14
|
-
vec3 p1;\n\
|
|
15
|
-
};\n\
|
|
16
|
-
\n\
|
|
17
|
-
Box constructVoxelBox(in ivec4 octreeCoords, in vec3 tileUv)\n\
|
|
18
|
-
{\n\
|
|
19
|
-
// Find the min/max cornerpoints of the voxel in tile coordinates\n\
|
|
20
|
-
vec3 tileOrigin = vec3(octreeCoords.xyz);\n\
|
|
21
|
-
vec3 numSamples = vec3(u_dimensions);\n\
|
|
22
|
-
vec3 voxelSize = 1.0 / numSamples;\n\
|
|
23
|
-
vec3 coordP0 = floor(tileUv * numSamples) * voxelSize + tileOrigin;\n\
|
|
24
|
-
vec3 coordP1 = coordP0 + voxelSize;\n\
|
|
25
|
-
\n\
|
|
26
|
-
// Transform to the UV coordinates of the scaled tileset\n\
|
|
27
|
-
float tileSize = 1.0 / pow(2.0, float(octreeCoords.w));\n\
|
|
28
|
-
vec3 p0 = convertShapeUvToUvSpace(coordP0 * tileSize);\n\
|
|
29
|
-
vec3 p1 = convertShapeUvToUvSpace(coordP1 * tileSize);\n\
|
|
30
|
-
\n\
|
|
31
|
-
return Box(p0, p1);\n\
|
|
32
|
-
}\n\
|
|
33
|
-
\n\
|
|
34
|
-
vec3 getBoxNormal(in Box box, in Ray ray, in float t)\n\
|
|
35
|
-
{\n\
|
|
36
|
-
vec3 hitPoint = ray.pos + t * ray.dir;\n\
|
|
37
|
-
vec3 lower = step(hitPoint, box.p0);\n\
|
|
38
|
-
vec3 upper = step(box.p1, hitPoint);\n\
|
|
39
|
-
return normalize(upper - lower);\n\
|
|
40
|
-
}\n\
|
|
41
|
-
\n\
|
|
42
|
-
// Find the distances along a ray at which the ray intersects an axis-aligned box\n\
|
|
43
|
-
// See https://tavianator.com/2011/ray_box.html\n\
|
|
44
|
-
RayShapeIntersection intersectBox(in Ray ray, in Box box)\n\
|
|
12
|
+
RayShapeIntersection intersectBox(in Ray ray, in vec3 minBound, in vec3 maxBound)\n\
|
|
45
13
|
{\n\
|
|
46
14
|
// Consider the box as the intersection of the space between 3 pairs of parallel planes\n\
|
|
47
15
|
// Compute the distance along the ray to each plane\n\
|
|
48
|
-
vec3 t0 = (
|
|
49
|
-
vec3 t1 = (
|
|
16
|
+
vec3 t0 = (minBound - ray.pos) / ray.dir;\n\
|
|
17
|
+
vec3 t1 = (maxBound - ray.pos) / ray.dir;\n\
|
|
50
18
|
\n\
|
|
51
19
|
// Identify candidate entries/exits based on distance from ray.pos\n\
|
|
52
20
|
vec3 entries = min(t0, t1);\n\
|
|
53
21
|
vec3 exits = max(t0, t1);\n\
|
|
54
22
|
\n\
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
23
|
+
vec3 directions = sign(ray.dir);\n\
|
|
24
|
+
\n\
|
|
25
|
+
// The actual intersection points are the furthest entry and the closest exit\n\
|
|
26
|
+
float lastEntry = maxComponent(entries);\n\
|
|
27
|
+
bvec3 isLastEntry = equal(entries, vec3(lastEntry));\n\
|
|
28
|
+
vec3 entryNormal = -1.0 * vec3(isLastEntry) * directions;\n\
|
|
29
|
+
vec4 entry = vec4(entryNormal, lastEntry);\n\
|
|
58
30
|
\n\
|
|
59
|
-
|
|
60
|
-
|
|
31
|
+
float firstExit = minComponent(exits);\n\
|
|
32
|
+
bvec3 isFirstExit = equal(exits, vec3(firstExit));\n\
|
|
33
|
+
vec3 exitNormal = vec3(isLastEntry) * directions;\n\
|
|
34
|
+
vec4 exit = vec4(exitNormal, firstExit);\n\
|
|
61
35
|
\n\
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
|
|
36
|
+
if (entry.w > exit.w) {\n\
|
|
37
|
+
entry.w = NO_HIT;\n\
|
|
38
|
+
exit.w = NO_HIT;\n\
|
|
65
39
|
}\n\
|
|
66
40
|
\n\
|
|
67
|
-
return RayShapeIntersection(
|
|
41
|
+
return RayShapeIntersection(entry, exit);\n\
|
|
68
42
|
}\n\
|
|
69
43
|
\n\
|
|
70
44
|
void intersectShape(in Ray ray, inout Intersections ix)\n\
|
|
71
45
|
{\n\
|
|
72
|
-
RayShapeIntersection intersection = intersectBox(ray,
|
|
46
|
+
RayShapeIntersection intersection = intersectBox(ray, u_renderMinBounds, u_renderMaxBounds);\n\
|
|
73
47
|
setShapeIntersection(ix, BOX_INTERSECTION_INDEX, intersection);\n\
|
|
74
48
|
}\n\
|
|
75
49
|
";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//This file is automatically rebuilt by the Cesium build process.
|
|
2
2
|
export default "// See IntersectionUtils.glsl for the definitions of Ray, Intersections, INF_HIT,\n\
|
|
3
|
-
// NO_HIT,
|
|
3
|
+
// NO_HIT, setShapeIntersection\n\
|
|
4
4
|
\n\
|
|
5
5
|
/* Clipping plane defines (set in Scene/VoxelRenderResources.js)\n\
|
|
6
6
|
#define CLIPPING_PLANES_UNION\n\
|