@cesium/engine 23.0.0 → 24.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/Workers/{chunk-QTOHIXGF.js → chunk-2N4KDHS3.js} +10 -10
- package/Build/Workers/{chunk-SQTRWKO2.js → chunk-44EMEGKW.js} +5 -5
- package/Build/Workers/{chunk-OHBM4YG4.js → chunk-4TIG36AW.js} +12 -12
- package/Build/Workers/{chunk-BNBD2YZK.js → chunk-5A2SW66E.js} +16 -16
- package/Build/Workers/{chunk-52K3GJKG.js → chunk-5GXYJQ2K.js} +3 -3
- package/Build/Workers/{chunk-NQCAZU7S.js → chunk-63SIWPLS.js} +13 -13
- package/Build/Workers/{chunk-UEEGWJJP.js → chunk-6MPGQEHA.js} +2 -2
- package/Build/Workers/{chunk-PQVNT5CJ.js → chunk-6RMS4S72.js} +6 -6
- package/Build/Workers/{chunk-HYTFXWMY.js → chunk-6WLHJFD3.js} +7 -7
- package/Build/Workers/{chunk-DT5SJBKA.js → chunk-72VYSVEW.js} +9 -9
- package/Build/Workers/{chunk-JUGY5AZN.js → chunk-7MDYBRYJ.js} +4 -4
- package/Build/Workers/{chunk-6SLGTBB2.js → chunk-7O5XJTVE.js} +5 -5
- package/Build/Workers/{chunk-4UNQX2MP.js → chunk-7QRFIKWQ.js} +2 -2
- package/Build/Workers/{chunk-GN5NEUDT.js → chunk-7TYLCBGK.js} +8 -8
- package/Build/Workers/{chunk-SGKTBHFQ.js → chunk-7X322WP2.js} +13 -13
- package/Build/Workers/{chunk-T43FXHNC.js → chunk-A47HVBC5.js} +7 -7
- package/Build/Workers/{chunk-FSDVXW7M.js → chunk-AF3MU2RL.js} +5 -5
- package/Build/Workers/{chunk-3B65YFXC.js → chunk-AJLTU6PF.js} +1 -1
- package/Build/Workers/{chunk-OQ3EAJNW.js → chunk-AMIHNSST.js} +2 -2
- package/Build/Workers/{chunk-N4AWE7TZ.js → chunk-B6SCUUFP.js} +10 -10
- package/Build/Workers/{chunk-OMXN7YF4.js → chunk-BJD6QGXZ.js} +12 -12
- package/Build/Workers/{chunk-APDKMX7W.js → chunk-C6P4IG5P.js} +6 -6
- package/Build/Workers/{chunk-QA24Q62E.js → chunk-D4EJ2NXG.js} +17 -17
- package/Build/Workers/{chunk-HYLEKKO5.js → chunk-DHKPFLSJ.js} +1 -1
- package/Build/Workers/{chunk-MQJG522T.js → chunk-DVB56LG7.js} +6 -6
- package/Build/Workers/{chunk-Y5AJSEEN.js → chunk-EDXL4W76.js} +2 -2
- package/Build/Workers/{chunk-QQX7S5QT.js → chunk-EV3VGO6Y.js} +17 -17
- package/Build/Workers/{chunk-IFA7VHHP.js → chunk-GOQBUCXH.js} +10 -10
- package/Build/Workers/{chunk-5A7YSAXT.js → chunk-GQUNK2XC.js} +14 -14
- package/Build/Workers/{chunk-36LBFITA.js → chunk-HKUES6UG.js} +12 -12
- package/Build/Workers/{chunk-OC6X22PG.js → chunk-HRHRYFHS.js} +9 -9
- package/Build/Workers/{chunk-L7RDJ4V7.js → chunk-HXJMS2ZI.js} +1 -1
- package/Build/Workers/{chunk-NAYRNPEP.js → chunk-ILMFADZA.js} +4 -4
- package/Build/Workers/{chunk-AA33B6PU.js → chunk-ISY4EZCA.js} +4 -4
- package/Build/Workers/{chunk-7KRN6JPQ.js → chunk-J6AW5YHS.js} +14 -14
- package/Build/Workers/{chunk-OQBPOKPZ.js → chunk-JCI63T3K.js} +6 -6
- package/Build/Workers/{chunk-2WI4HGJU.js → chunk-KLPGTXS3.js} +6 -6
- package/Build/Workers/{chunk-5R7SBUTW.js → chunk-LIB2H534.js} +10 -10
- package/Build/Workers/{chunk-IYVDOB5V.js → chunk-LXMCPFFS.js} +4 -4
- package/Build/Workers/{chunk-NUYLNQKV.js → chunk-MKM27KGV.js} +2 -2
- package/Build/Workers/{chunk-R7M4XNPP.js → chunk-N65BAKSH.js} +8 -8
- package/Build/Workers/{chunk-4LGFX2P5.js → chunk-NKT5K3K3.js} +11 -11
- package/Build/Workers/{chunk-NNHU33JK.js → chunk-NPF7SSHZ.js} +7 -7
- package/Build/Workers/{chunk-LDQWNMEC.js → chunk-PVV64VFW.js} +1 -1
- package/Build/Workers/{chunk-WKXDCVBO.js → chunk-Q3C6VQH6.js} +4 -4
- package/Build/Workers/{chunk-ARCFIOKA.js → chunk-RQNJD3O4.js} +12 -12
- package/Build/Workers/{chunk-G3YT7M7A.js → chunk-UIGVOKKI.js} +1 -1
- package/Build/Workers/{chunk-ZIW5FCIW.js → chunk-UQU4RXLT.js} +27 -19
- package/Build/Workers/{chunk-MT5M7RLZ.js → chunk-VLDEUTOP.js} +2 -2
- package/Build/Workers/{chunk-5JP5FG7U.js → chunk-VMVOUQ5J.js} +7 -7
- package/Build/Workers/{chunk-2GL2EUEE.js → chunk-XJRBB253.js} +11 -11
- package/Build/Workers/{chunk-ESD4IEOU.js → chunk-XY6HMDGI.js} +5 -5
- package/Build/Workers/{chunk-56OHFSLH.js → chunk-Y7HNNPNK.js} +10 -10
- package/Build/Workers/{chunk-6FVFM2KB.js → chunk-YAOZMOFL.js} +5 -5
- package/Build/Workers/{chunk-AP6XWET5.js → chunk-YJZGW74L.js} +8 -8
- package/Build/Workers/{chunk-KPYU6YZG.js → chunk-YQFTYQMZ.js} +1 -1
- package/Build/Workers/{chunk-5VKZVPO5.js → chunk-ZBZRTRJB.js} +10 -10
- 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 +24 -24
- 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 +32 -32
- 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 +13 -13
- package/Build/Workers/createVectorTilePolygons.js +22 -22
- package/Build/Workers/createVectorTilePolylines.js +14 -14
- package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
- package/Build/Workers/createVerticesFromHeightmap.js +22 -22
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
- package/Build/Workers/createWallGeometry.js +25 -25
- package/Build/Workers/createWallOutlineGeometry.js +24 -24
- package/Build/Workers/decodeDraco.js +10 -10
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +12 -12
- package/Build/Workers/gaussianSplatSorter.js +4 -4
- package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
- package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
- package/Build/Workers/transcodeKTX2.js +6 -6
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
- package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Source/Core/BoundingSphere.js +1 -1
- package/Source/Core/Cartesian2.js +7 -5
- package/Source/Core/Cartesian3.js +8 -6
- package/Source/Core/Cartesian4.js +8 -6
- package/Source/Core/Color.js +5 -3
- package/Source/Core/DeveloperError.js +2 -1
- package/Source/Core/ITwinPlatform.js +1 -0
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/S2Cell.js +2 -2
- package/Source/Core/TerrainMesh.js +10 -1
- package/Source/Core/TerrainPicker.js +1 -0
- package/Source/Core/WallGeometry.js +1 -1
- package/Source/Core/WallOutlineGeometry.js +1 -1
- package/Source/Core/assert.js +27 -0
- package/Source/Core/globalTypes.js +4 -0
- package/Source/DataSources/CzmlDataSource.js +9 -0
- package/Source/DataSources/PathGraphics.js +13 -0
- package/Source/DataSources/PathVisualizer.js +330 -18
- package/Source/DataSources/StaticGeometryColorBatch.js +7 -2
- package/Source/DataSources/StaticGeometryPerMaterialBatch.js +7 -2
- package/Source/DataSources/StaticGroundGeometryPerMaterialBatch.js +3 -1
- package/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js +3 -1
- package/Source/Renderer/Context.js +1 -1
- package/Source/Renderer/RenderState.js +2 -2
- package/Source/Renderer/VertexArray.js +80 -0
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/BillboardCollection.js +65 -364
- package/Source/Scene/BufferPoint.js +148 -0
- package/Source/Scene/BufferPointCollection.js +135 -0
- package/Source/Scene/BufferPointMaterial.js +95 -0
- package/Source/Scene/BufferPolygon.js +516 -0
- package/Source/Scene/BufferPolygonCollection.js +368 -0
- package/Source/Scene/BufferPolygonMaterial.js +41 -0
- package/Source/Scene/BufferPolyline.js +185 -0
- package/Source/Scene/BufferPolylineCollection.js +136 -0
- package/Source/Scene/BufferPolylineMaterial.js +93 -0
- package/Source/Scene/BufferPrimitive.js +347 -0
- package/Source/Scene/BufferPrimitiveCollection.js +702 -0
- package/Source/Scene/BufferPrimitiveMaterial.js +140 -0
- package/Source/Scene/Cesium3DTileContent.js +5 -1
- package/Source/Scene/Cesium3DTileContentFactory.js +9 -0
- package/Source/Scene/Cesium3DTileStyle.js +22 -0
- package/Source/Scene/Cesium3DTileset.js +1 -0
- package/Source/Scene/ClippingPolygonCollection.js +270 -101
- package/Source/Scene/CubeMapPanorama.js +4 -4
- package/Source/Scene/GaussianSplat3DTileContent.js +40 -46
- package/Source/Scene/GaussianSplatPrimitive.js +413 -70
- package/Source/Scene/GetFeatureInfoFormat.js +3 -3
- package/Source/Scene/GltfLoader.js +227 -34
- package/Source/Scene/GltfSpzLoader.js +109 -0
- package/Source/Scene/ITwinData.js +1 -0
- package/Source/Scene/Label.js +32 -0
- package/Source/Scene/LabelCollection.js +14 -13
- package/Source/Scene/Material.js +2 -0
- package/Source/Scene/Megatexture.js +1 -0
- package/Source/Scene/MetadataClassProperty.js +24 -10
- package/Source/Scene/MetadataComponentType.js +115 -23
- package/Source/Scene/Model/CustomShaderPipelineStage.js +3 -1
- package/Source/Scene/Model/EdgeVisibilityPipelineStage.js +761 -263
- package/Source/Scene/Model/MaterialPipelineStage.js +147 -0
- package/Source/Scene/Model/MetadataPipelineStage.js +3 -3
- package/Source/Scene/Model/ModelDrawCommand.js +6 -0
- package/Source/Scene/Model/ModelReader.js +1 -1
- package/Source/Scene/Model/ModelUtility.js +3 -1
- package/Source/Scene/Model/createVectorTileBuffersFromModelComponents.js +330 -0
- package/Source/Scene/ModelComponents.js +1632 -1542
- package/Source/Scene/PickedMetadataInfo.js +1 -0
- package/Source/Scene/ScreenSpaceCameraController.js +13 -0
- package/Source/Scene/SkyBox.js +17 -8
- package/Source/Scene/TileBoundingRegion.js +1 -1
- package/Source/Scene/TileBoundingS2Cell.js +1 -1
- package/Source/Scene/TileBoundingSphere.js +1 -1
- package/Source/Scene/TweenCollection.js +7 -0
- package/Source/Scene/VectorGltf3DTileContent.js +382 -0
- package/Source/Scene/VertexAttributeSemantic.js +14 -0
- package/Source/Scene/WebMapServiceImageryProvider.js +2 -2
- package/Source/Scene/WebMapTileServiceImageryProvider.js +366 -131
- package/Source/Scene/parseStructuralMetadata.js +97 -37
- package/Source/Scene/renderBufferPointCollection.js +334 -0
- package/Source/Scene/renderBufferPolygonCollection.js +386 -0
- package/Source/Scene/renderBufferPolylineCollection.js +529 -0
- package/Source/Shaders/BillboardCollectionFS.glsl +2 -77
- package/Source/Shaders/BillboardCollectionFS.js +2 -77
- package/Source/Shaders/BillboardCollectionVS.glsl +2 -60
- package/Source/Shaders/BillboardCollectionVS.js +2 -60
- package/Source/Shaders/BufferPointMaterialFS.glsl +27 -0
- package/Source/Shaders/BufferPointMaterialFS.js +29 -0
- package/Source/Shaders/BufferPointMaterialVS.glsl +48 -0
- package/Source/Shaders/BufferPointMaterialVS.js +50 -0
- package/Source/Shaders/BufferPolygonMaterialFS.glsl +13 -0
- package/Source/Shaders/BufferPolygonMaterialFS.js +15 -0
- package/Source/Shaders/BufferPolygonMaterialVS.glsl +30 -0
- package/Source/Shaders/BufferPolygonMaterialVS.js +32 -0
- package/Source/Shaders/BufferPolylineMaterialFS.glsl +13 -0
- package/Source/Shaders/BufferPolylineMaterialFS.js +15 -0
- package/Source/Shaders/BufferPolylineMaterialVS.glsl +49 -0
- package/Source/Shaders/BufferPolylineMaterialVS.js +51 -0
- package/Source/Shaders/Model/EdgeVisibilityStageFS.glsl +34 -48
- package/Source/Shaders/Model/EdgeVisibilityStageFS.js +34 -49
- package/Source/Shaders/Model/EdgeVisibilityStageVS.glsl +98 -0
- package/Source/Shaders/Model/EdgeVisibilityStageVS.js +100 -0
- package/Source/Shaders/Model/ModelFS.glsl +15 -0
- package/Source/Shaders/Model/ModelFS.js +15 -0
- package/Source/Shaders/Model/ModelVS.glsl +8 -0
- package/Source/Shaders/Model/ModelVS.js +8 -0
- package/Source/Shaders/PolygonSignedDistanceFS.glsl +64 -33
- package/Source/Shaders/PolygonSignedDistanceFS.js +64 -33
- package/Source/Shaders/PrimitiveGaussianSplatVS.glsl +9 -2
- package/Source/Shaders/PrimitiveGaussianSplatVS.js +9 -2
- package/Source/Shaders/Voxels/VoxelFS.glsl +1 -1
- package/Source/Shaders/Voxels/VoxelFS.js +1 -1
- package/Source/Workers/decodeDraco.js +3 -0
- package/Source/Workers/decodeI3S.js +5 -2
- package/index.d.ts +1007 -111
- package/index.js +368 -343
- package/package.json +2 -2
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import defined from "../Core/defined.js";
|
|
4
|
+
import Cartesian3 from "../Core/Cartesian3.js";
|
|
5
|
+
import Color from "../Core/Color.js";
|
|
6
|
+
import BufferPolygon from "./BufferPolygon.js";
|
|
7
|
+
import Buffer from "../Renderer/Buffer.js";
|
|
8
|
+
import BufferUsage from "../Renderer/BufferUsage.js";
|
|
9
|
+
import VertexArray from "../Renderer/VertexArray.js";
|
|
10
|
+
import ComponentDatatype from "../Core/ComponentDatatype.js";
|
|
11
|
+
import RenderState from "../Renderer/RenderState.js";
|
|
12
|
+
import BlendingState from "./BlendingState.js";
|
|
13
|
+
import ShaderSource from "../Renderer/ShaderSource.js";
|
|
14
|
+
import ShaderProgram from "../Renderer/ShaderProgram.js";
|
|
15
|
+
import DrawCommand from "../Renderer/DrawCommand.js";
|
|
16
|
+
import Pass from "../Renderer/Pass.js";
|
|
17
|
+
import PrimitiveType from "../Core/PrimitiveType.js";
|
|
18
|
+
import BufferPolygonMaterialVS from "../Shaders/BufferPolygonMaterialVS.js";
|
|
19
|
+
import BufferPolygonMaterialFS from "../Shaders/BufferPolygonMaterialFS.js";
|
|
20
|
+
import EncodedCartesian3 from "../Core/EncodedCartesian3.js";
|
|
21
|
+
import AttributeCompression from "../Core/AttributeCompression.js";
|
|
22
|
+
import IndexDatatype from "../Core/IndexDatatype.js";
|
|
23
|
+
import BoundingSphere from "../Core/BoundingSphere.js";
|
|
24
|
+
import Matrix4 from "../Core/Matrix4.js";
|
|
25
|
+
import BufferPolygonMaterial from "./BufferPolygonMaterial.js";
|
|
26
|
+
|
|
27
|
+
/** @import {Destroyable, TypedArray} from "../Core/globalTypes.js"; */
|
|
28
|
+
/** @import FrameState from "./FrameState.js"; */
|
|
29
|
+
/** @import BufferPolygonCollection from "./BufferPolygonCollection.js"; */
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* TODO(PR#13211): Need 'keyof' syntax to avoid duplicating attribute names.
|
|
33
|
+
* @typedef {'positionHigh' | 'positionLow' | 'pickColor' | 'showAndColor'} BufferPolygonAttribute
|
|
34
|
+
* @ignore
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @type {Record<BufferPolygonAttribute, number>}
|
|
39
|
+
* @ignore
|
|
40
|
+
*/
|
|
41
|
+
const BufferPolygonAttributeLocations = {
|
|
42
|
+
positionHigh: 0,
|
|
43
|
+
positionLow: 1,
|
|
44
|
+
pickColor: 2,
|
|
45
|
+
showAndColor: 3,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @typedef {object} BufferPolygonRenderContext
|
|
50
|
+
* @property {VertexArray} [vertexArray]
|
|
51
|
+
* @property {Record<BufferPolygonAttribute, TypedArray>} [attributeArrays]
|
|
52
|
+
* @property {TypedArray} [indexArray]
|
|
53
|
+
* @property {RenderState} [renderState]
|
|
54
|
+
* @property {ShaderProgram} [shaderProgram]
|
|
55
|
+
* @property {DrawCommand} [command]
|
|
56
|
+
* @property {Destroyable[]} [pickIds]
|
|
57
|
+
* @property {Function} destroy
|
|
58
|
+
* @ignore
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
// Scratch variables.
|
|
62
|
+
const polygon = new BufferPolygon();
|
|
63
|
+
const material = new BufferPolygonMaterial();
|
|
64
|
+
const pickColor = new Color();
|
|
65
|
+
const cartesian = new Cartesian3();
|
|
66
|
+
const encodedCartesian = new EncodedCartesian3();
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @param {BufferPolygonCollection} collection
|
|
70
|
+
* @param {FrameState} frameState
|
|
71
|
+
* @param {BufferPolygonRenderContext} [renderContext]
|
|
72
|
+
* @returns {BufferPolygonRenderContext}
|
|
73
|
+
* @ignore
|
|
74
|
+
*/
|
|
75
|
+
function renderBufferPolygonCollection(collection, frameState, renderContext) {
|
|
76
|
+
const context = frameState.context;
|
|
77
|
+
renderContext = renderContext || { destroy: destroyRenderContext };
|
|
78
|
+
|
|
79
|
+
if (
|
|
80
|
+
!defined(renderContext.attributeArrays) ||
|
|
81
|
+
!defined(renderContext.indexArray)
|
|
82
|
+
) {
|
|
83
|
+
const { vertexCountMax, triangleCountMax } = collection;
|
|
84
|
+
|
|
85
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
86
|
+
renderContext.indexArray = IndexDatatype.createTypedArray(
|
|
87
|
+
vertexCountMax,
|
|
88
|
+
triangleCountMax * 3,
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
renderContext.attributeArrays = {
|
|
92
|
+
positionHigh: new Float32Array(vertexCountMax * 3),
|
|
93
|
+
positionLow: new Float32Array(vertexCountMax * 3),
|
|
94
|
+
pickColor: new Uint8Array(vertexCountMax * 4),
|
|
95
|
+
showAndColor: new Float32Array(vertexCountMax * 2),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (!defined(renderContext.pickIds)) {
|
|
100
|
+
renderContext.pickIds = [];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (collection._dirtyCount > 0) {
|
|
104
|
+
const { attributeArrays, pickIds } = renderContext;
|
|
105
|
+
const { _dirtyOffset, _dirtyCount } = collection;
|
|
106
|
+
|
|
107
|
+
const indexArray = renderContext.indexArray;
|
|
108
|
+
const positionHighArray = attributeArrays.positionHigh;
|
|
109
|
+
const positionLowArray = attributeArrays.positionLow;
|
|
110
|
+
const pickColorArray = attributeArrays.pickColor;
|
|
111
|
+
const showAndColorArray = attributeArrays.showAndColor;
|
|
112
|
+
|
|
113
|
+
for (let i = _dirtyOffset, il = _dirtyOffset + _dirtyCount; i < il; i++) {
|
|
114
|
+
collection.get(i, polygon);
|
|
115
|
+
|
|
116
|
+
if (!polygon._dirty) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (collection._allowPicking && polygon._pickId === 0) {
|
|
121
|
+
const pickId = context.createPickId({
|
|
122
|
+
collection,
|
|
123
|
+
index: i,
|
|
124
|
+
get primitive() {
|
|
125
|
+
// Cannot reuse primitives; scene.drillPick() appends to a list.
|
|
126
|
+
return collection.get(i, new BufferPolygon());
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
polygon._pickId = pickId.key;
|
|
130
|
+
pickIds.push(pickId);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
let tOffset = polygon.triangleOffset;
|
|
134
|
+
let vOffset = polygon.vertexOffset;
|
|
135
|
+
|
|
136
|
+
const polygonIndexArray = polygon.getTriangles();
|
|
137
|
+
|
|
138
|
+
// Update index.
|
|
139
|
+
for (let j = 0, jl = polygon.triangleCount; j < jl; j++) {
|
|
140
|
+
indexArray[tOffset * 3] = vOffset + polygonIndexArray[j * 3];
|
|
141
|
+
indexArray[tOffset * 3 + 1] = vOffset + polygonIndexArray[j * 3 + 1];
|
|
142
|
+
indexArray[tOffset * 3 + 2] = vOffset + polygonIndexArray[j * 3 + 2];
|
|
143
|
+
|
|
144
|
+
tOffset++;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const show = polygon.show;
|
|
148
|
+
const cartesianArray = polygon.getPositions();
|
|
149
|
+
polygon.getMaterial(material);
|
|
150
|
+
const encodedColor = AttributeCompression.encodeRGB8(material.color);
|
|
151
|
+
Color.fromRgba(polygon._pickId, pickColor);
|
|
152
|
+
|
|
153
|
+
// Update vertex arrays.
|
|
154
|
+
for (let j = 0, jl = polygon.vertexCount; j < jl; j++) {
|
|
155
|
+
// @ts-expect-error TODO(tsd-jsdoc): See https://github.com/CesiumGS/cesium/pull/13302.
|
|
156
|
+
Cartesian3.fromArray(cartesianArray, j * 3, cartesian);
|
|
157
|
+
EncodedCartesian3.fromCartesian(cartesian, encodedCartesian);
|
|
158
|
+
|
|
159
|
+
positionHighArray[vOffset * 3] = encodedCartesian.high.x;
|
|
160
|
+
positionHighArray[vOffset * 3 + 1] = encodedCartesian.high.y;
|
|
161
|
+
positionHighArray[vOffset * 3 + 2] = encodedCartesian.high.z;
|
|
162
|
+
|
|
163
|
+
positionLowArray[vOffset * 3] = encodedCartesian.low.x;
|
|
164
|
+
positionLowArray[vOffset * 3 + 1] = encodedCartesian.low.y;
|
|
165
|
+
positionLowArray[vOffset * 3 + 2] = encodedCartesian.low.z;
|
|
166
|
+
|
|
167
|
+
pickColorArray[vOffset * 4] = Color.floatToByte(pickColor.red);
|
|
168
|
+
pickColorArray[vOffset * 4 + 1] = Color.floatToByte(pickColor.green);
|
|
169
|
+
pickColorArray[vOffset * 4 + 2] = Color.floatToByte(pickColor.blue);
|
|
170
|
+
pickColorArray[vOffset * 4 + 3] = Color.floatToByte(pickColor.alpha);
|
|
171
|
+
|
|
172
|
+
showAndColorArray[vOffset * 2] = show ? 1 : 0;
|
|
173
|
+
showAndColorArray[vOffset * 2 + 1] = encodedColor;
|
|
174
|
+
|
|
175
|
+
vOffset++;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
polygon._dirty = false;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (!defined(renderContext.vertexArray)) {
|
|
183
|
+
const { attributeArrays } = renderContext;
|
|
184
|
+
|
|
185
|
+
renderContext.vertexArray = new VertexArray({
|
|
186
|
+
context,
|
|
187
|
+
|
|
188
|
+
indexBuffer: Buffer.createIndexBuffer({
|
|
189
|
+
context,
|
|
190
|
+
typedArray: renderContext.indexArray,
|
|
191
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
192
|
+
usage: BufferUsage.STATIC_DRAW,
|
|
193
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
194
|
+
indexDatatype: IndexDatatype.fromTypedArray(renderContext.indexArray),
|
|
195
|
+
}),
|
|
196
|
+
|
|
197
|
+
attributes: [
|
|
198
|
+
{
|
|
199
|
+
index: BufferPolygonAttributeLocations.positionHigh,
|
|
200
|
+
componentDatatype: ComponentDatatype.FLOAT,
|
|
201
|
+
componentsPerAttribute: 3,
|
|
202
|
+
vertexBuffer: Buffer.createVertexBuffer({
|
|
203
|
+
typedArray: attributeArrays.positionHigh,
|
|
204
|
+
context,
|
|
205
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
206
|
+
usage: BufferUsage.STATIC_DRAW,
|
|
207
|
+
}),
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
index: BufferPolygonAttributeLocations.positionLow,
|
|
211
|
+
componentDatatype: ComponentDatatype.FLOAT,
|
|
212
|
+
componentsPerAttribute: 3,
|
|
213
|
+
vertexBuffer: Buffer.createVertexBuffer({
|
|
214
|
+
typedArray: attributeArrays.positionLow,
|
|
215
|
+
context,
|
|
216
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
217
|
+
usage: BufferUsage.STATIC_DRAW,
|
|
218
|
+
}),
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
index: BufferPolygonAttributeLocations.pickColor,
|
|
222
|
+
componentDatatype: ComponentDatatype.UNSIGNED_BYTE,
|
|
223
|
+
componentsPerAttribute: 4,
|
|
224
|
+
vertexBuffer: Buffer.createVertexBuffer({
|
|
225
|
+
typedArray: attributeArrays.pickColor,
|
|
226
|
+
context,
|
|
227
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
228
|
+
usage: BufferUsage.STATIC_DRAW,
|
|
229
|
+
}),
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
index: BufferPolygonAttributeLocations.showAndColor,
|
|
233
|
+
componentDatatype: ComponentDatatype.FLOAT,
|
|
234
|
+
componentsPerAttribute: 2,
|
|
235
|
+
vertexBuffer: Buffer.createVertexBuffer({
|
|
236
|
+
typedArray: attributeArrays.showAndColor,
|
|
237
|
+
context,
|
|
238
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
239
|
+
usage: BufferUsage.STATIC_DRAW,
|
|
240
|
+
}),
|
|
241
|
+
},
|
|
242
|
+
],
|
|
243
|
+
});
|
|
244
|
+
} else if (collection._dirtyCount > 0) {
|
|
245
|
+
const { indexOffset, indexCount, vertexOffset, vertexCount } =
|
|
246
|
+
getPolygonDirtyRanges(collection);
|
|
247
|
+
|
|
248
|
+
renderContext.vertexArray.copyIndexFromRange(
|
|
249
|
+
renderContext.indexArray,
|
|
250
|
+
indexOffset,
|
|
251
|
+
indexCount,
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
for (const key in BufferPolygonAttributeLocations) {
|
|
255
|
+
if (Object.hasOwn(BufferPolygonAttributeLocations, key)) {
|
|
256
|
+
const attribute = /** @type {BufferPolygonAttribute} */ (key);
|
|
257
|
+
renderContext.vertexArray.copyAttributeFromRange(
|
|
258
|
+
BufferPolygonAttributeLocations[attribute],
|
|
259
|
+
renderContext.attributeArrays[attribute],
|
|
260
|
+
vertexOffset,
|
|
261
|
+
vertexCount,
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (!defined(renderContext.renderState)) {
|
|
268
|
+
renderContext.renderState = RenderState.fromCache({
|
|
269
|
+
blending: BlendingState.DISABLED,
|
|
270
|
+
depthTest: { enabled: true },
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (!defined(renderContext.shaderProgram)) {
|
|
275
|
+
renderContext.shaderProgram = ShaderProgram.fromCache({
|
|
276
|
+
context,
|
|
277
|
+
vertexShaderSource: new ShaderSource({
|
|
278
|
+
sources: [BufferPolygonMaterialVS],
|
|
279
|
+
}),
|
|
280
|
+
fragmentShaderSource: new ShaderSource({
|
|
281
|
+
sources: [BufferPolygonMaterialFS],
|
|
282
|
+
}),
|
|
283
|
+
attributeLocations: BufferPolygonAttributeLocations,
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
if (
|
|
288
|
+
!defined(renderContext.command) ||
|
|
289
|
+
isCommandDirty(collection, renderContext.command)
|
|
290
|
+
) {
|
|
291
|
+
renderContext.command = new DrawCommand({
|
|
292
|
+
vertexArray: renderContext.vertexArray,
|
|
293
|
+
renderState: renderContext.renderState,
|
|
294
|
+
shaderProgram: renderContext.shaderProgram,
|
|
295
|
+
primitiveType: PrimitiveType.TRIANGLES,
|
|
296
|
+
pass: Pass.OPAQUE,
|
|
297
|
+
pickId: "v_pickColor",
|
|
298
|
+
owner: collection,
|
|
299
|
+
count: collection.triangleCount * 3,
|
|
300
|
+
modelMatrix: collection.modelMatrix,
|
|
301
|
+
boundingVolume: collection.boundingVolumeWC,
|
|
302
|
+
debugShowBoundingVolume: collection.debugShowBoundingVolume,
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
frameState.commandList.push(renderContext.command);
|
|
307
|
+
|
|
308
|
+
collection._dirtyCount = 0;
|
|
309
|
+
collection._dirtyOffset = 0;
|
|
310
|
+
|
|
311
|
+
return renderContext;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Returns true if DrawCommand is out of date for the given collection.
|
|
316
|
+
* @param {BufferPolygonCollection} collection
|
|
317
|
+
* @param {DrawCommand} command
|
|
318
|
+
* @ignore
|
|
319
|
+
*/
|
|
320
|
+
function isCommandDirty(collection, command) {
|
|
321
|
+
const isModelMatrixEqual = Matrix4.equals(
|
|
322
|
+
collection.modelMatrix,
|
|
323
|
+
command._modelMatrix,
|
|
324
|
+
);
|
|
325
|
+
|
|
326
|
+
const isBoundingVolumeEqual = BoundingSphere.equals(
|
|
327
|
+
collection.boundingVolumeWC,
|
|
328
|
+
command._boundingVolume,
|
|
329
|
+
);
|
|
330
|
+
|
|
331
|
+
return (
|
|
332
|
+
collection.triangleCount * 3 !== command._count ||
|
|
333
|
+
collection.debugShowBoundingVolume !== command.debugShowBoundingVolume ||
|
|
334
|
+
!isModelMatrixEqual ||
|
|
335
|
+
!isBoundingVolumeEqual
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Computes dirty ranges for attribute and index buffers in a collection.
|
|
341
|
+
* @param {BufferPolygonCollection} collection
|
|
342
|
+
* @ignore
|
|
343
|
+
*/
|
|
344
|
+
function getPolygonDirtyRanges(collection) {
|
|
345
|
+
const { _dirtyOffset, _dirtyCount } = collection;
|
|
346
|
+
|
|
347
|
+
collection.get(_dirtyOffset, polygon);
|
|
348
|
+
const vertexOffset = polygon.vertexOffset;
|
|
349
|
+
const indexOffset = polygon.triangleOffset * 3;
|
|
350
|
+
|
|
351
|
+
collection.get(_dirtyOffset + _dirtyCount - 1, polygon);
|
|
352
|
+
const vertexCount = polygon.vertexOffset + polygon.vertexCount - vertexOffset;
|
|
353
|
+
const indexCount =
|
|
354
|
+
(polygon.triangleOffset + polygon.triangleCount) * 3 - indexOffset;
|
|
355
|
+
|
|
356
|
+
return { indexOffset, indexCount, vertexOffset, vertexCount };
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Destroys render context resources. Deleting properties from the context
|
|
361
|
+
* object isn't necessary, as collection.destroy() will discard the object.
|
|
362
|
+
* @ignore
|
|
363
|
+
*/
|
|
364
|
+
function destroyRenderContext() {
|
|
365
|
+
const context = /** @type {BufferPolygonRenderContext} */ (this);
|
|
366
|
+
|
|
367
|
+
if (defined(context.vertexArray)) {
|
|
368
|
+
context.vertexArray.destroy();
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
if (defined(context.shaderProgram)) {
|
|
372
|
+
context.shaderProgram.destroy();
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if (defined(context.renderState)) {
|
|
376
|
+
RenderState.removeFromCache(context.renderState);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if (defined(context.pickIds)) {
|
|
380
|
+
for (const pickId of context.pickIds) {
|
|
381
|
+
pickId.destroy();
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export default renderBufferPolygonCollection;
|