@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,529 @@
|
|
|
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 BufferPolyline from "./BufferPolyline.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 BufferPolylineMaterialVS from "../Shaders/BufferPolylineMaterialVS.js";
|
|
19
|
+
import BufferPolylineMaterialFS from "../Shaders/BufferPolylineMaterialFS.js";
|
|
20
|
+
import EncodedCartesian3 from "../Core/EncodedCartesian3.js";
|
|
21
|
+
import AttributeCompression from "../Core/AttributeCompression.js";
|
|
22
|
+
import IndexDatatype from "../Core/IndexDatatype.js";
|
|
23
|
+
import PolylineCommon from "../Shaders/PolylineCommon.js";
|
|
24
|
+
import Matrix4 from "../Core/Matrix4.js";
|
|
25
|
+
import BoundingSphere from "../Core/BoundingSphere.js";
|
|
26
|
+
import BufferPolylineMaterial from "./BufferPolylineMaterial.js";
|
|
27
|
+
|
|
28
|
+
/** @import FrameState from "./FrameState.js"; */
|
|
29
|
+
/** @import BufferPolylineCollection from "./BufferPolylineCollection.js"; */
|
|
30
|
+
/** @import {Destroyable, TypedArray} from "../Core/globalTypes.js"; */
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* TODO(PR#13211): Need 'keyof' syntax to avoid duplicating attribute names.
|
|
34
|
+
* @typedef {'positionHigh' | 'positionLow' | 'prevPositionHigh' | 'prevPositionLow' | 'nextPositionHigh' | 'nextPositionLow' | 'pickColor' | 'showColorWidthAndTexCoord'} BufferPolylineAttribute
|
|
35
|
+
* @ignore
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @type {Record<BufferPolylineAttribute, number>}
|
|
40
|
+
* @ignore
|
|
41
|
+
*/
|
|
42
|
+
const BufferPolylineAttributeLocations = {
|
|
43
|
+
positionHigh: 0,
|
|
44
|
+
positionLow: 1,
|
|
45
|
+
prevPositionHigh: 2,
|
|
46
|
+
prevPositionLow: 3,
|
|
47
|
+
nextPositionHigh: 4,
|
|
48
|
+
nextPositionLow: 5,
|
|
49
|
+
pickColor: 6,
|
|
50
|
+
showColorWidthAndTexCoord: 7,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @typedef {object} BufferPolylineRenderContext
|
|
55
|
+
* @property {VertexArray} [vertexArray]
|
|
56
|
+
* @property {Record<BufferPolylineAttribute, TypedArray>} [attributeArrays]
|
|
57
|
+
* @property {TypedArray} [indexArray]
|
|
58
|
+
* @property {RenderState} [renderState]
|
|
59
|
+
* @property {ShaderProgram} [shaderProgram]
|
|
60
|
+
* @property {DrawCommand} [command]
|
|
61
|
+
* @property {Destroyable[]} [pickIds]
|
|
62
|
+
* @property {Function} destroy
|
|
63
|
+
* @ignore
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
// Scratch variables.
|
|
67
|
+
const polyline = new BufferPolyline();
|
|
68
|
+
const material = new BufferPolylineMaterial();
|
|
69
|
+
const pickColor = new Color();
|
|
70
|
+
const cartesian = new Cartesian3();
|
|
71
|
+
const prevCartesian = new Cartesian3();
|
|
72
|
+
const nextCartesian = new Cartesian3();
|
|
73
|
+
const cartesianEnc = new EncodedCartesian3();
|
|
74
|
+
const prevCartesianEnc = new EncodedCartesian3();
|
|
75
|
+
const nextCartesianEnc = new EncodedCartesian3();
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Renders line segments as quads, each composed of two triangles. Writes each
|
|
79
|
+
* vertex twice, extruding the pairs in opposing directions outward.
|
|
80
|
+
*
|
|
81
|
+
* Tips:
|
|
82
|
+
* - # segments in polyline primitive = vertexCount - 1
|
|
83
|
+
* - # segments in collection = vertexCount - primitiveCount
|
|
84
|
+
* - # vertices rendered = vertexCount * 2
|
|
85
|
+
* - # indices = segmentCount * 6
|
|
86
|
+
*
|
|
87
|
+
* 0 - 2 - 4 - 6 - 8
|
|
88
|
+
* | \ | \ | \ | \ | ...
|
|
89
|
+
* 1 - 3 - 5 - 7 - 9
|
|
90
|
+
*
|
|
91
|
+
* @param {BufferPolylineCollection} collection
|
|
92
|
+
* @param {FrameState} frameState
|
|
93
|
+
* @param {BufferPolylineRenderContext} [renderContext]
|
|
94
|
+
* @returns {BufferPolylineRenderContext}
|
|
95
|
+
* @ignore
|
|
96
|
+
*/
|
|
97
|
+
function renderBufferPolylineCollection(collection, frameState, renderContext) {
|
|
98
|
+
const context = frameState.context;
|
|
99
|
+
renderContext = renderContext || { destroy: destroyRenderContext };
|
|
100
|
+
|
|
101
|
+
if (
|
|
102
|
+
!defined(renderContext.attributeArrays) ||
|
|
103
|
+
!defined(renderContext.indexArray)
|
|
104
|
+
) {
|
|
105
|
+
// Number of primitives can only increase, which _decreases_ remaining
|
|
106
|
+
// segment capacity: use `primitiveCount` here, not `primitiveCountMax`.
|
|
107
|
+
const segmentCountMax =
|
|
108
|
+
collection.vertexCountMax - collection.primitiveCount;
|
|
109
|
+
const vertexCountMax = collection.vertexCountMax * 2;
|
|
110
|
+
|
|
111
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
112
|
+
renderContext.indexArray = IndexDatatype.createTypedArray(
|
|
113
|
+
vertexCountMax,
|
|
114
|
+
segmentCountMax * 6,
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
renderContext.attributeArrays = {
|
|
118
|
+
positionHigh: new Float32Array(vertexCountMax * 3),
|
|
119
|
+
positionLow: new Float32Array(vertexCountMax * 3),
|
|
120
|
+
prevPositionHigh: new Float32Array(vertexCountMax * 3),
|
|
121
|
+
prevPositionLow: new Float32Array(vertexCountMax * 3),
|
|
122
|
+
nextPositionHigh: new Float32Array(vertexCountMax * 3),
|
|
123
|
+
nextPositionLow: new Float32Array(vertexCountMax * 3),
|
|
124
|
+
pickColor: new Uint8Array(vertexCountMax * 4),
|
|
125
|
+
showColorWidthAndTexCoord: new Float32Array(vertexCountMax * 4),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (!defined(renderContext.pickIds)) {
|
|
130
|
+
renderContext.pickIds = [];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (collection._dirtyCount > 0) {
|
|
134
|
+
const { _dirtyOffset, _dirtyCount } = collection;
|
|
135
|
+
const { attributeArrays, pickIds } = renderContext;
|
|
136
|
+
|
|
137
|
+
const indexArray = renderContext.indexArray;
|
|
138
|
+
const positionHighArray = attributeArrays.positionHigh;
|
|
139
|
+
const positionLowArray = attributeArrays.positionLow;
|
|
140
|
+
const prevPositionHighArray = attributeArrays.prevPositionHigh;
|
|
141
|
+
const prevPositionLowArray = attributeArrays.prevPositionLow;
|
|
142
|
+
const nextPositionHighArray = attributeArrays.nextPositionHigh;
|
|
143
|
+
const nextPositionLowArray = attributeArrays.nextPositionLow;
|
|
144
|
+
const pickColorArray = attributeArrays.pickColor;
|
|
145
|
+
const showColorWidthAndTexCoordArray =
|
|
146
|
+
attributeArrays.showColorWidthAndTexCoord;
|
|
147
|
+
|
|
148
|
+
for (let i = _dirtyOffset, il = _dirtyOffset + _dirtyCount; i < il; i++) {
|
|
149
|
+
collection.get(i, polyline);
|
|
150
|
+
|
|
151
|
+
if (!polyline._dirty) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (collection._allowPicking && polyline._pickId === 0) {
|
|
156
|
+
const pickId = context.createPickId({
|
|
157
|
+
collection,
|
|
158
|
+
index: i,
|
|
159
|
+
get primitive() {
|
|
160
|
+
// Cannot reuse primitives; scene.drillPick() appends to a list.
|
|
161
|
+
return collection.get(i, new BufferPolyline());
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
polyline._pickId = pickId.key;
|
|
165
|
+
pickIds.push(pickId);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const cartesianArray = polyline.getPositions();
|
|
169
|
+
polyline.getMaterial(material);
|
|
170
|
+
const encodedColor = AttributeCompression.encodeRGB8(material.color);
|
|
171
|
+
Color.fromRgba(polyline._pickId, pickColor);
|
|
172
|
+
const show = polyline.show;
|
|
173
|
+
|
|
174
|
+
let vOffset = polyline.vertexOffset * 2; // vertex offset
|
|
175
|
+
let iOffset = (polyline.vertexOffset - i) * 6; // index offset
|
|
176
|
+
|
|
177
|
+
for (let j = 0, jl = polyline.vertexCount; j < jl; j++) {
|
|
178
|
+
const isFirstSegment = j === 0;
|
|
179
|
+
const isLastSegment = j === jl - 1;
|
|
180
|
+
|
|
181
|
+
// For first/last vertices, infer missing vertices by mirroring the segment.
|
|
182
|
+
// @ts-expect-error TODO(tsd-jsdoc): See https://github.com/CesiumGS/cesium/pull/13302.
|
|
183
|
+
Cartesian3.fromArray(cartesianArray, j * 3, cartesian);
|
|
184
|
+
if (isFirstSegment) {
|
|
185
|
+
// @ts-expect-error TODO(tsd-jsdoc): See https://github.com/CesiumGS/cesium/pull/13302.
|
|
186
|
+
Cartesian3.fromArray(cartesianArray, (j + 1) * 3, nextCartesian);
|
|
187
|
+
Cartesian3.subtract(cartesian, nextCartesian, prevCartesian);
|
|
188
|
+
Cartesian3.add(cartesian, prevCartesian, prevCartesian);
|
|
189
|
+
} else if (isLastSegment) {
|
|
190
|
+
// @ts-expect-error TODO(tsd-jsdoc): See https://github.com/CesiumGS/cesium/pull/13302.
|
|
191
|
+
Cartesian3.fromArray(cartesianArray, (j - 1) * 3, prevCartesian);
|
|
192
|
+
Cartesian3.subtract(cartesian, prevCartesian, nextCartesian);
|
|
193
|
+
Cartesian3.add(cartesian, nextCartesian, nextCartesian);
|
|
194
|
+
} else {
|
|
195
|
+
// @ts-expect-error TODO(tsd-jsdoc): See https://github.com/CesiumGS/cesium/pull/13302.
|
|
196
|
+
Cartesian3.fromArray(cartesianArray, (j - 1) * 3, prevCartesian);
|
|
197
|
+
// @ts-expect-error TODO(tsd-jsdoc): See https://github.com/CesiumGS/cesium/pull/13302.
|
|
198
|
+
Cartesian3.fromArray(cartesianArray, (j + 1) * 3, nextCartesian);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// For each segment, draw two triangles.
|
|
202
|
+
if (!isLastSegment) {
|
|
203
|
+
indexArray[iOffset] = vOffset;
|
|
204
|
+
indexArray[iOffset + 1] = vOffset + 1;
|
|
205
|
+
indexArray[iOffset + 2] = vOffset + 2;
|
|
206
|
+
|
|
207
|
+
indexArray[iOffset + 3] = vOffset + 2;
|
|
208
|
+
indexArray[iOffset + 4] = vOffset + 1;
|
|
209
|
+
indexArray[iOffset + 5] = vOffset + 3;
|
|
210
|
+
|
|
211
|
+
iOffset += 6;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
EncodedCartesian3.fromCartesian(cartesian, cartesianEnc);
|
|
215
|
+
EncodedCartesian3.fromCartesian(prevCartesian, prevCartesianEnc);
|
|
216
|
+
EncodedCartesian3.fromCartesian(nextCartesian, nextCartesianEnc);
|
|
217
|
+
|
|
218
|
+
// TODO(donmccurdy): Diverging from PolylineCollection.js, which writes
|
|
219
|
+
// internal vertices to buffer 4x, not 2x. Not sure that's needed?
|
|
220
|
+
for (let k = 0; k < 2; k++) {
|
|
221
|
+
// Position.
|
|
222
|
+
positionHighArray[vOffset * 3] = cartesianEnc.high.x;
|
|
223
|
+
positionHighArray[vOffset * 3 + 1] = cartesianEnc.high.y;
|
|
224
|
+
positionHighArray[vOffset * 3 + 2] = cartesianEnc.high.z;
|
|
225
|
+
|
|
226
|
+
positionLowArray[vOffset * 3] = cartesianEnc.low.x;
|
|
227
|
+
positionLowArray[vOffset * 3 + 1] = cartesianEnc.low.y;
|
|
228
|
+
positionLowArray[vOffset * 3 + 2] = cartesianEnc.low.z;
|
|
229
|
+
|
|
230
|
+
// Previous position.
|
|
231
|
+
prevPositionHighArray[vOffset * 3] = prevCartesianEnc.high.x;
|
|
232
|
+
prevPositionHighArray[vOffset * 3 + 1] = prevCartesianEnc.high.y;
|
|
233
|
+
prevPositionHighArray[vOffset * 3 + 2] = prevCartesianEnc.high.z;
|
|
234
|
+
|
|
235
|
+
prevPositionLowArray[vOffset * 3] = prevCartesianEnc.low.x;
|
|
236
|
+
prevPositionLowArray[vOffset * 3 + 1] = prevCartesianEnc.low.y;
|
|
237
|
+
prevPositionLowArray[vOffset * 3 + 2] = prevCartesianEnc.low.z;
|
|
238
|
+
|
|
239
|
+
// Next position.
|
|
240
|
+
nextPositionHighArray[vOffset * 3] = nextCartesianEnc.high.x;
|
|
241
|
+
nextPositionHighArray[vOffset * 3 + 1] = nextCartesianEnc.high.y;
|
|
242
|
+
nextPositionHighArray[vOffset * 3 + 2] = nextCartesianEnc.high.z;
|
|
243
|
+
|
|
244
|
+
nextPositionLowArray[vOffset * 3] = nextCartesianEnc.low.x;
|
|
245
|
+
nextPositionLowArray[vOffset * 3 + 1] = nextCartesianEnc.low.y;
|
|
246
|
+
nextPositionLowArray[vOffset * 3 + 2] = nextCartesianEnc.low.z;
|
|
247
|
+
|
|
248
|
+
// Pick ID.
|
|
249
|
+
pickColorArray[vOffset * 4] = Color.floatToByte(pickColor.red);
|
|
250
|
+
pickColorArray[vOffset * 4 + 1] = Color.floatToByte(pickColor.green);
|
|
251
|
+
pickColorArray[vOffset * 4 + 2] = Color.floatToByte(pickColor.blue);
|
|
252
|
+
pickColorArray[vOffset * 4 + 3] = Color.floatToByte(pickColor.alpha);
|
|
253
|
+
|
|
254
|
+
// Properties.
|
|
255
|
+
showColorWidthAndTexCoordArray[vOffset * 4] = show ? 1 : 0;
|
|
256
|
+
showColorWidthAndTexCoordArray[vOffset * 4 + 1] = encodedColor;
|
|
257
|
+
showColorWidthAndTexCoordArray[vOffset * 4 + 2] = material.width;
|
|
258
|
+
showColorWidthAndTexCoordArray[vOffset * 4 + 3] = j / (jl - 1); // texcoord.s
|
|
259
|
+
|
|
260
|
+
vOffset++;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
polyline._dirty = false;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if (!defined(renderContext.vertexArray)) {
|
|
269
|
+
const attributeArrays = renderContext.attributeArrays;
|
|
270
|
+
|
|
271
|
+
renderContext.vertexArray = new VertexArray({
|
|
272
|
+
context,
|
|
273
|
+
|
|
274
|
+
indexBuffer: Buffer.createIndexBuffer({
|
|
275
|
+
context,
|
|
276
|
+
typedArray: renderContext.indexArray,
|
|
277
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
278
|
+
usage: BufferUsage.STATIC_DRAW,
|
|
279
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
280
|
+
indexDatatype: IndexDatatype.fromTypedArray(renderContext.indexArray),
|
|
281
|
+
}),
|
|
282
|
+
|
|
283
|
+
attributes: [
|
|
284
|
+
{
|
|
285
|
+
index: BufferPolylineAttributeLocations.positionHigh,
|
|
286
|
+
componentDatatype: ComponentDatatype.FLOAT,
|
|
287
|
+
componentsPerAttribute: 3,
|
|
288
|
+
vertexBuffer: Buffer.createVertexBuffer({
|
|
289
|
+
typedArray: attributeArrays.positionHigh,
|
|
290
|
+
context,
|
|
291
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
292
|
+
usage: BufferUsage.STATIC_DRAW,
|
|
293
|
+
}),
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
index: BufferPolylineAttributeLocations.positionLow,
|
|
297
|
+
componentDatatype: ComponentDatatype.FLOAT,
|
|
298
|
+
componentsPerAttribute: 3,
|
|
299
|
+
vertexBuffer: Buffer.createVertexBuffer({
|
|
300
|
+
typedArray: attributeArrays.positionLow,
|
|
301
|
+
context,
|
|
302
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
303
|
+
usage: BufferUsage.STATIC_DRAW,
|
|
304
|
+
}),
|
|
305
|
+
},
|
|
306
|
+
|
|
307
|
+
{
|
|
308
|
+
index: BufferPolylineAttributeLocations.prevPositionHigh,
|
|
309
|
+
componentDatatype: ComponentDatatype.FLOAT,
|
|
310
|
+
componentsPerAttribute: 3,
|
|
311
|
+
vertexBuffer: Buffer.createVertexBuffer({
|
|
312
|
+
typedArray: attributeArrays.prevPositionHigh,
|
|
313
|
+
context,
|
|
314
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
315
|
+
usage: BufferUsage.STATIC_DRAW,
|
|
316
|
+
}),
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
index: BufferPolylineAttributeLocations.prevPositionLow,
|
|
320
|
+
componentDatatype: ComponentDatatype.FLOAT,
|
|
321
|
+
componentsPerAttribute: 3,
|
|
322
|
+
vertexBuffer: Buffer.createVertexBuffer({
|
|
323
|
+
typedArray: attributeArrays.prevPositionLow,
|
|
324
|
+
context,
|
|
325
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
326
|
+
usage: BufferUsage.STATIC_DRAW,
|
|
327
|
+
}),
|
|
328
|
+
},
|
|
329
|
+
|
|
330
|
+
{
|
|
331
|
+
index: BufferPolylineAttributeLocations.nextPositionHigh,
|
|
332
|
+
componentDatatype: ComponentDatatype.FLOAT,
|
|
333
|
+
componentsPerAttribute: 3,
|
|
334
|
+
vertexBuffer: Buffer.createVertexBuffer({
|
|
335
|
+
typedArray: attributeArrays.nextPositionHigh,
|
|
336
|
+
context,
|
|
337
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
338
|
+
usage: BufferUsage.STATIC_DRAW,
|
|
339
|
+
}),
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
index: BufferPolylineAttributeLocations.nextPositionLow,
|
|
343
|
+
componentDatatype: ComponentDatatype.FLOAT,
|
|
344
|
+
componentsPerAttribute: 3,
|
|
345
|
+
vertexBuffer: Buffer.createVertexBuffer({
|
|
346
|
+
typedArray: attributeArrays.nextPositionLow,
|
|
347
|
+
context,
|
|
348
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
349
|
+
usage: BufferUsage.STATIC_DRAW,
|
|
350
|
+
}),
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
index: BufferPolylineAttributeLocations.pickColor,
|
|
354
|
+
componentDatatype: ComponentDatatype.UNSIGNED_BYTE,
|
|
355
|
+
componentsPerAttribute: 4,
|
|
356
|
+
vertexBuffer: Buffer.createVertexBuffer({
|
|
357
|
+
typedArray: attributeArrays.pickColor,
|
|
358
|
+
context,
|
|
359
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
360
|
+
usage: BufferUsage.STATIC_DRAW,
|
|
361
|
+
}),
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
index: BufferPolylineAttributeLocations.showColorWidthAndTexCoord,
|
|
365
|
+
componentDatatype: ComponentDatatype.FLOAT,
|
|
366
|
+
componentsPerAttribute: 4,
|
|
367
|
+
vertexBuffer: Buffer.createVertexBuffer({
|
|
368
|
+
typedArray: attributeArrays.showColorWidthAndTexCoord,
|
|
369
|
+
context,
|
|
370
|
+
// @ts-expect-error Requires https://github.com/CesiumGS/cesium/pull/13203.
|
|
371
|
+
usage: BufferUsage.STATIC_DRAW,
|
|
372
|
+
}),
|
|
373
|
+
},
|
|
374
|
+
],
|
|
375
|
+
});
|
|
376
|
+
} else if (collection._dirtyCount > 0) {
|
|
377
|
+
const { indexOffset, indexCount, vertexOffset, vertexCount } =
|
|
378
|
+
getPolylineDirtyRanges(collection);
|
|
379
|
+
|
|
380
|
+
renderContext.vertexArray.copyIndexFromRange(
|
|
381
|
+
renderContext.indexArray,
|
|
382
|
+
indexOffset,
|
|
383
|
+
indexCount,
|
|
384
|
+
);
|
|
385
|
+
|
|
386
|
+
for (const key in BufferPolylineAttributeLocations) {
|
|
387
|
+
if (Object.hasOwn(BufferPolylineAttributeLocations, key)) {
|
|
388
|
+
const attribute = /** @type {BufferPolylineAttribute} */ (key);
|
|
389
|
+
renderContext.vertexArray.copyAttributeFromRange(
|
|
390
|
+
BufferPolylineAttributeLocations[attribute],
|
|
391
|
+
renderContext.attributeArrays[attribute],
|
|
392
|
+
vertexOffset,
|
|
393
|
+
vertexCount,
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
if (!defined(renderContext.renderState)) {
|
|
400
|
+
renderContext.renderState = RenderState.fromCache({
|
|
401
|
+
blending: BlendingState.DISABLED,
|
|
402
|
+
depthTest: { enabled: true },
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
if (!defined(renderContext.shaderProgram)) {
|
|
407
|
+
renderContext.shaderProgram = ShaderProgram.fromCache({
|
|
408
|
+
context,
|
|
409
|
+
vertexShaderSource: new ShaderSource({
|
|
410
|
+
sources: [PolylineCommon, BufferPolylineMaterialVS],
|
|
411
|
+
}),
|
|
412
|
+
fragmentShaderSource: new ShaderSource({
|
|
413
|
+
sources: [BufferPolylineMaterialFS],
|
|
414
|
+
}),
|
|
415
|
+
attributeLocations: BufferPolylineAttributeLocations,
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
if (
|
|
420
|
+
!defined(renderContext.command) ||
|
|
421
|
+
isCommandDirty(collection, renderContext.command)
|
|
422
|
+
) {
|
|
423
|
+
renderContext.command = new DrawCommand({
|
|
424
|
+
vertexArray: renderContext.vertexArray,
|
|
425
|
+
renderState: renderContext.renderState,
|
|
426
|
+
shaderProgram: renderContext.shaderProgram,
|
|
427
|
+
primitiveType: PrimitiveType.TRIANGLES,
|
|
428
|
+
pass: Pass.OPAQUE,
|
|
429
|
+
pickId: "v_pickColor",
|
|
430
|
+
owner: collection,
|
|
431
|
+
count: getDrawIndexCount(collection),
|
|
432
|
+
modelMatrix: collection.modelMatrix,
|
|
433
|
+
boundingVolume: collection.boundingVolumeWC,
|
|
434
|
+
debugShowBoundingVolume: collection.debugShowBoundingVolume,
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
frameState.commandList.push(renderContext.command);
|
|
439
|
+
|
|
440
|
+
collection._dirtyCount = 0;
|
|
441
|
+
collection._dirtyOffset = 0;
|
|
442
|
+
|
|
443
|
+
return renderContext;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Returns true if DrawCommand is out of date for given collection.
|
|
448
|
+
* @param {BufferPolylineCollection} collection
|
|
449
|
+
* @param {DrawCommand} command
|
|
450
|
+
* @ignore
|
|
451
|
+
*/
|
|
452
|
+
function isCommandDirty(collection, command) {
|
|
453
|
+
const isModelMatrixEqual = Matrix4.equals(
|
|
454
|
+
collection.modelMatrix,
|
|
455
|
+
command._modelMatrix,
|
|
456
|
+
);
|
|
457
|
+
|
|
458
|
+
const isBoundingVolumeEqual = BoundingSphere.equals(
|
|
459
|
+
collection.boundingVolumeWC,
|
|
460
|
+
command._boundingVolume,
|
|
461
|
+
);
|
|
462
|
+
|
|
463
|
+
return (
|
|
464
|
+
getDrawIndexCount(collection) !== command._count ||
|
|
465
|
+
collection.debugShowBoundingVolume !== command.debugShowBoundingVolume ||
|
|
466
|
+
!isModelMatrixEqual ||
|
|
467
|
+
!isBoundingVolumeEqual
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Returns number of drawn (not allocated) indices for given collection.
|
|
473
|
+
* @param {BufferPolylineCollection} collection
|
|
474
|
+
* @ignore
|
|
475
|
+
*/
|
|
476
|
+
function getDrawIndexCount(collection) {
|
|
477
|
+
return (collection.vertexCount - collection.primitiveCount) * 6;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Computes dirty ranges for attribute and index buffers in a collection.
|
|
482
|
+
* @param {BufferPolylineCollection} collection
|
|
483
|
+
* @ignore
|
|
484
|
+
*/
|
|
485
|
+
function getPolylineDirtyRanges(collection) {
|
|
486
|
+
const { _dirtyOffset, _dirtyCount } = collection;
|
|
487
|
+
|
|
488
|
+
collection.get(_dirtyOffset, polyline);
|
|
489
|
+
const vertexOffset = polyline.vertexOffset * 2;
|
|
490
|
+
const segmentOffset = polyline.vertexOffset - _dirtyOffset;
|
|
491
|
+
const indexOffset = segmentOffset * 6;
|
|
492
|
+
|
|
493
|
+
collection.get(_dirtyOffset + _dirtyCount - 1, polyline);
|
|
494
|
+
const vertexCount =
|
|
495
|
+
(polyline.vertexOffset + polyline.vertexCount) * 2 - vertexOffset;
|
|
496
|
+
const segmentCount = vertexCount / 2 - _dirtyCount;
|
|
497
|
+
const indexCount = segmentCount * 6;
|
|
498
|
+
|
|
499
|
+
return { indexOffset, indexCount, vertexOffset, vertexCount };
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Destroys render context resources. Deleting properties from the context
|
|
504
|
+
* object isn't necessary, as collection.destroy() will discard the object.
|
|
505
|
+
* @ignore
|
|
506
|
+
*/
|
|
507
|
+
function destroyRenderContext() {
|
|
508
|
+
const context = /** @type {BufferPolylineRenderContext} */ (this);
|
|
509
|
+
|
|
510
|
+
if (defined(context.vertexArray)) {
|
|
511
|
+
context.vertexArray.destroy();
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
if (defined(context.shaderProgram)) {
|
|
515
|
+
context.shaderProgram.destroy();
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
if (defined(context.renderState)) {
|
|
519
|
+
RenderState.removeFromCache(context.renderState);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
if (defined(context.pickIds)) {
|
|
523
|
+
for (const pickId of context.pickIds) {
|
|
524
|
+
pickId.destroy();
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
export default renderBufferPolylineCollection;
|
|
@@ -20,16 +20,6 @@ in vec4 v_compressed; // x: eyeDepth, y: applyTran
|
|
|
20
20
|
const float SHIFT_LEFT1 = 2.0;
|
|
21
21
|
const float SHIFT_RIGHT1 = 1.0 / 2.0;
|
|
22
22
|
|
|
23
|
-
#ifdef FS_THREE_POINT_DEPTH_CHECK
|
|
24
|
-
in vec4 v_textureCoordinateBounds; // the min and max x and y values for the texture coordinates
|
|
25
|
-
in vec4 v_originTextureCoordinateAndTranslate; // texture coordinate at the origin, billboard translate (used for label glyphs)
|
|
26
|
-
in mat2 v_rotationMatrix;
|
|
27
|
-
|
|
28
|
-
const float SHIFT_LEFT12 = 4096.0;
|
|
29
|
-
|
|
30
|
-
const float SHIFT_RIGHT12 = 1.0 / 4096.0;
|
|
31
|
-
#endif
|
|
32
|
-
|
|
33
23
|
float getGlobeDepthAtCoords(vec2 st)
|
|
34
24
|
{
|
|
35
25
|
float logDepthOrDepth = czm_unpackDepth(texture(czm_globeDepthTexture, st));
|
|
@@ -42,27 +32,6 @@ float getGlobeDepthAtCoords(vec2 st)
|
|
|
42
32
|
return eyeCoordinate.z / eyeCoordinate.w;
|
|
43
33
|
}
|
|
44
34
|
|
|
45
|
-
#ifdef FS_THREE_POINT_DEPTH_CHECK
|
|
46
|
-
float getGlobeDepth(vec2 adjustedST, vec2 depthLookupST, bool applyTranslate, vec2 dimensions, vec2 imageSize)
|
|
47
|
-
{
|
|
48
|
-
vec2 lookupVector = imageSize * (depthLookupST - adjustedST);
|
|
49
|
-
lookupVector = v_rotationMatrix * lookupVector;
|
|
50
|
-
vec2 labelOffset = (dimensions - imageSize) * (depthLookupST - vec2(0.0, v_originTextureCoordinateAndTranslate.y)); // aligns label glyph with bounding rectangle. Will be zero for billboards because dimensions and imageSize will be equal
|
|
51
|
-
|
|
52
|
-
vec2 translation = v_originTextureCoordinateAndTranslate.zw;
|
|
53
|
-
|
|
54
|
-
if (applyTranslate)
|
|
55
|
-
{
|
|
56
|
-
// this is only needed for labels where the horizontal origin is not LEFT
|
|
57
|
-
// it moves the label back to where the "origin" should be since all label glyphs are set to HorizontalOrigin.LEFT
|
|
58
|
-
translation += (dimensions * v_originTextureCoordinateAndTranslate.xy * vec2(1.0, 0.0));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
vec2 st = ((lookupVector - translation + labelOffset) + gl_FragCoord.xy) / czm_viewport.zw;
|
|
62
|
-
return getGlobeDepthAtCoords(st);
|
|
63
|
-
}
|
|
64
|
-
#endif
|
|
65
|
-
|
|
66
35
|
#ifdef SDF
|
|
67
36
|
|
|
68
37
|
// Get the distance from the edge of a glyph at a given position sampling an SDF texture.
|
|
@@ -93,44 +62,6 @@ vec4 getSDFColor(vec2 position, float outlineWidth, vec4 outlineColor, float smo
|
|
|
93
62
|
}
|
|
94
63
|
#endif
|
|
95
64
|
|
|
96
|
-
#ifdef FS_THREE_POINT_DEPTH_CHECK
|
|
97
|
-
void doThreePointDepthTest(float eyeDepth, bool applyTranslate) {
|
|
98
|
-
|
|
99
|
-
if (eyeDepth < -u_threePointDepthTestDistance) return;
|
|
100
|
-
float temp = v_compressed.z;
|
|
101
|
-
temp = temp * SHIFT_RIGHT12;
|
|
102
|
-
|
|
103
|
-
vec2 dimensions;
|
|
104
|
-
dimensions.y = (temp - floor(temp)) * SHIFT_LEFT12;
|
|
105
|
-
dimensions.x = floor(temp);
|
|
106
|
-
|
|
107
|
-
temp = v_compressed.w;
|
|
108
|
-
temp = temp * SHIFT_RIGHT12;
|
|
109
|
-
|
|
110
|
-
vec2 imageSize;
|
|
111
|
-
imageSize.y = (temp - floor(temp)) * SHIFT_LEFT12;
|
|
112
|
-
imageSize.x = floor(temp);
|
|
113
|
-
|
|
114
|
-
vec2 adjustedST = v_textureCoordinates - v_textureCoordinateBounds.xy;
|
|
115
|
-
adjustedST = adjustedST / vec2(v_textureCoordinateBounds.z - v_textureCoordinateBounds.x, v_textureCoordinateBounds.w - v_textureCoordinateBounds.y);
|
|
116
|
-
|
|
117
|
-
float epsilonEyeDepth = v_compressed.x + czm_epsilon1;
|
|
118
|
-
float globeDepth1 = getGlobeDepth(adjustedST, v_originTextureCoordinateAndTranslate.xy, applyTranslate, dimensions, imageSize);
|
|
119
|
-
|
|
120
|
-
// negative values go into the screen
|
|
121
|
-
if (globeDepth1 == 0.0 || globeDepth1 < epsilonEyeDepth) return;
|
|
122
|
-
|
|
123
|
-
float globeDepth2 = getGlobeDepth(adjustedST, vec2(0.0, 1.0), applyTranslate, dimensions, imageSize); // top left corner
|
|
124
|
-
if (globeDepth2 == 0.0 || globeDepth2 < epsilonEyeDepth) return;
|
|
125
|
-
|
|
126
|
-
float globeDepth3 = getGlobeDepth(adjustedST, vec2(1.0, 1.0), applyTranslate, dimensions, imageSize); // top right corner
|
|
127
|
-
if (globeDepth3 == 0.0 || globeDepth3 < epsilonEyeDepth) return;
|
|
128
|
-
|
|
129
|
-
// All three key points are occluded, discard the fragment (and by extension the entire billboard)
|
|
130
|
-
discard;
|
|
131
|
-
}
|
|
132
|
-
#endif
|
|
133
|
-
|
|
134
65
|
bool getDepthTestEnabled() {
|
|
135
66
|
float temp = v_compressed.y;
|
|
136
67
|
temp = temp * SHIFT_RIGHT1;
|
|
@@ -153,13 +84,7 @@ float getRelativeEyeDepth(float eyeDepth, float distanceToEllipsoid, float epsil
|
|
|
153
84
|
// by the globe when near and far from the camera.
|
|
154
85
|
void doDepthTest(float eyeDepth, float globeDepth) {
|
|
155
86
|
|
|
156
|
-
#ifdef
|
|
157
|
-
// If the billboard is clamped to the ground and within a given distance, we do a 3-point depth test. This test is performed in the vertex shader, unless
|
|
158
|
-
// vertex texture sampling is not supported, in which case we do it here.
|
|
159
|
-
bool applyTranslate = floor(temp) != 0.0;
|
|
160
|
-
doThreePointDepthTest(eyeDepth, applyTranslate);
|
|
161
|
-
|
|
162
|
-
#elif defined(VS_THREE_POINT_DEPTH_CHECK)
|
|
87
|
+
#ifdef VS_THREE_POINT_DEPTH_CHECK
|
|
163
88
|
// Since discarding vertices is not possible, the vertex shader sets eyeDepth to 0 to indicate the depth test failed. Apply the discard here.
|
|
164
89
|
if (eyeDepth > -u_threePointDepthTestDistance) {
|
|
165
90
|
if (eyeDepth == 0.0) {
|
|
@@ -188,7 +113,7 @@ void writeDepth(float eyeDepth, float globeDepth, float distanceToEllipsoid) {
|
|
|
188
113
|
|
|
189
114
|
float depthArg = v_depthFromNearPlusOne;
|
|
190
115
|
|
|
191
|
-
if (globeDepth != 0.0 && getRelativeEyeDepth(eyeDepth, distanceToEllipsoid, czm_epsilon3) > 0.0) {
|
|
116
|
+
if (globeDepth != 0.0 && getRelativeEyeDepth(eyeDepth, distanceToEllipsoid, czm_epsilon3) > 0.0) {
|
|
192
117
|
float globeDepthFromNearPlusOne = (-globeDepth - czm_currentFrustum.x) + 1.0;
|
|
193
118
|
float nudge = max(globeDepthFromNearPlusOne * 5e-6, czm_epsilon7);
|
|
194
119
|
float globeOnTop = max(1.0, globeDepthFromNearPlusOne - nudge);
|