@cesium/engine 6.1.1 → 7.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 +568 -407
- package/Build/Workers/{chunk-FRG2Z7DE.js → chunk-2HJWSU7B.js} +4 -4
- package/Build/Workers/{chunk-ZTYE74E2.js → chunk-46UD5ABS.js} +4 -4
- package/Build/Workers/{chunk-VODWDCX6.js → chunk-4EBHOMFX.js} +18 -20
- package/Build/Workers/{chunk-N7TYCDTR.js → chunk-5HDYHG3F.js} +13 -13
- package/Build/Workers/{chunk-C53JYYKX.js → chunk-5M3U6ZMA.js} +1 -1
- package/Build/Workers/{chunk-GTEXWEAP.js → chunk-5WQ523AW.js} +5 -5
- package/Build/Workers/{chunk-SEFDWMCW.js → chunk-5YLJ77FF.js} +31 -21
- package/Build/Workers/{chunk-VNRUVNIK.js → chunk-6HZQPRUS.js} +1 -1
- package/Build/Workers/{chunk-PB7BIXHI.js → chunk-6VJVYK2V.js} +2 -2
- package/Build/Workers/{chunk-PHQVHDVI.js → chunk-72SANQJV.js} +325 -5
- package/Build/Workers/{chunk-D325WRAY.js → chunk-7XEAYGZK.js} +35 -11
- package/Build/Workers/{chunk-FGUP2QEP.js → chunk-AIPU2VSX.js} +6 -6
- package/Build/Workers/{chunk-QUXSQQEF.js → chunk-AR5DNBJ4.js} +6 -6
- package/Build/Workers/{chunk-ZVUAJKAL.js → chunk-BZP4T2JJ.js} +11 -13
- package/Build/Workers/{chunk-K6Q5IRBK.js → chunk-DTAIXKTO.js} +6 -6
- package/Build/Workers/{chunk-D4YHO4NZ.js → chunk-F6SE42BK.js} +133 -101
- package/Build/Workers/{chunk-QY2WY5XJ.js → chunk-FP6GYBFX.js} +11 -11
- package/Build/Workers/{chunk-Z6LPXA7S.js → chunk-GEJTYLCO.js} +5 -5
- package/Build/Workers/{chunk-VKTKOIYG.js → chunk-GV56Q4LU.js} +11 -11
- package/Build/Workers/{chunk-KUB2HQXR.js → chunk-IQBYFRVW.js} +8 -8
- package/Build/Workers/{chunk-235MRXLH.js → chunk-IX2JCCNM.js} +1 -1
- package/Build/Workers/{chunk-3FCUUN6M.js → chunk-JCNXK6EL.js} +11 -11
- package/Build/Workers/{chunk-364TQORK.js → chunk-JJ4VBOQ3.js} +5 -7
- package/Build/Workers/{chunk-66CXKODF.js → chunk-JXDC723O.js} +2 -2
- package/Build/Workers/{chunk-OTBRPBCC.js → chunk-JY5YEZFA.js} +9 -9
- package/Build/Workers/{chunk-LSGUCCKJ.js → chunk-L2ZN645J.js} +6 -6
- package/Build/Workers/{chunk-VLDDXYKI.js → chunk-LZ7JIV3K.js} +18 -18
- package/Build/Workers/{chunk-36ESDRIZ.js → chunk-LZGHD6NY.js} +16 -16
- package/Build/Workers/{chunk-PXLFBN2Q.js → chunk-MY3VNFGQ.js} +7 -7
- package/Build/Workers/{chunk-W7F5VTH6.js → chunk-NKPBIX7F.js} +1 -1
- package/Build/Workers/{chunk-XBZSOW3F.js → chunk-NY3K4IM3.js} +12 -12
- package/Build/Workers/{chunk-AI3KSNM6.js → chunk-ODW7WYM4.js} +2 -2
- package/Build/Workers/{chunk-6PWSSCRA.js → chunk-OVLG3FRS.js} +6 -6
- package/Build/Workers/{chunk-MOLGJDJV.js → chunk-PNBGBETF.js} +11 -11
- package/Build/Workers/{chunk-T73B27DG.js → chunk-PTQQUQC3.js} +13 -13
- package/Build/Workers/{chunk-RSWBNJPT.js → chunk-QZAD5O7I.js} +8 -304
- package/Build/Workers/{chunk-I6TVJ6T7.js → chunk-R5X4OQT4.js} +8 -8
- package/Build/Workers/{chunk-DTNN3ODA.js → chunk-RAEV7K66.js} +5 -5
- package/Build/Workers/{chunk-IZED7ODV.js → chunk-RV7ZYPFT.js} +4 -4
- package/Build/Workers/{chunk-7FEGZO3D.js → chunk-S4MAZ3SS.js} +2 -2
- package/Build/Workers/{chunk-J3U6Z5YQ.js → chunk-S6SKF6DT.js} +5 -5
- package/Build/Workers/{chunk-CHDJ66UM.js → chunk-U2VCRRQW.js} +6 -6
- package/Build/Workers/{chunk-R22RQAAM.js → chunk-UAEW6HKG.js} +13 -13
- package/Build/Workers/{chunk-S7IBK36I.js → chunk-UDO6BFSF.js} +14 -16
- package/Build/Workers/{chunk-YS4KPNLC.js → chunk-UGK3FCDY.js} +1 -1
- package/Build/Workers/{chunk-SJDXMQSP.js → chunk-VK3EJHWI.js} +2 -2
- package/Build/Workers/{chunk-HEROVJML.js → chunk-VRGFV2UO.js} +7 -7
- package/Build/Workers/{chunk-VOAZN4IP.js → chunk-WBQCVXR3.js} +4 -4
- package/Build/Workers/{chunk-HSW63JN4.js → chunk-WZU2YLWG.js} +3 -3
- package/Build/Workers/{chunk-4EYB62WJ.js → chunk-XWXM2O2R.js} +6 -6
- package/Build/Workers/{chunk-ZGMOBRTG.js → chunk-YUCVWAY6.js} +7 -7
- package/Build/Workers/{chunk-CLVEIRXT.js → chunk-ZK5JOS3D.js} +15 -17
- package/Build/Workers/{chunk-5NZTU5YL.js → chunk-ZUA2UUNV.js} +2 -2
- package/Build/Workers/combineGeometry.js +23 -23
- package/Build/Workers/createBoxGeometry.js +17 -17
- package/Build/Workers/createBoxOutlineGeometry.js +15 -15
- package/Build/Workers/createCircleGeometry.js +25 -25
- package/Build/Workers/createCircleOutlineGeometry.js +18 -18
- package/Build/Workers/createCoplanarPolygonGeometry.js +33 -34
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +30 -30
- package/Build/Workers/createCorridorGeometry.js +28 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +27 -28
- package/Build/Workers/createCylinderGeometry.js +19 -19
- package/Build/Workers/createCylinderOutlineGeometry.js +18 -19
- package/Build/Workers/createEllipseGeometry.js +25 -25
- package/Build/Workers/createEllipseOutlineGeometry.js +18 -18
- package/Build/Workers/createEllipsoidGeometry.js +18 -18
- package/Build/Workers/createEllipsoidOutlineGeometry.js +17 -17
- package/Build/Workers/createFrustumGeometry.js +17 -17
- package/Build/Workers/createFrustumOutlineGeometry.js +17 -17
- package/Build/Workers/createGeometry.js +23 -23
- package/Build/Workers/createGroundPolylineGeometry.js +22 -22
- package/Build/Workers/createPlaneGeometry.js +15 -15
- package/Build/Workers/createPlaneOutlineGeometry.js +14 -14
- package/Build/Workers/createPolygonGeometry.js +32 -167
- package/Build/Workers/createPolygonOutlineGeometry.js +29 -29
- package/Build/Workers/createPolylineGeometry.js +24 -24
- package/Build/Workers/createPolylineVolumeGeometry.js +32 -35
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -29
- package/Build/Workers/createRectangleGeometry.js +27 -27
- package/Build/Workers/createRectangleOutlineGeometry.js +21 -23
- package/Build/Workers/createSimplePolylineGeometry.js +22 -22
- package/Build/Workers/createSphereGeometry.js +18 -18
- package/Build/Workers/createSphereOutlineGeometry.js +17 -17
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
- package/Build/Workers/createVectorTileGeometries.js +23 -23
- package/Build/Workers/createVectorTilePoints.js +12 -12
- package/Build/Workers/createVectorTilePolygons.js +21 -21
- 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 +23 -23
- package/Build/Workers/createWallOutlineGeometry.js +22 -22
- package/Build/Workers/decodeDraco.js +11 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +9 -9
- package/Build/Workers/transcodeKTX2.js +7 -7
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
- package/LICENSE.md +1 -1
- package/Source/Assets/approximateTerrainHeights.json +1 -1
- package/Source/Core/Ellipsoid.js +45 -0
- package/Source/Core/GregorianDate.js +85 -0
- package/Source/Core/HeadingPitchRange.js +2 -2
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/PolygonGeometry.js +0 -169
- package/Source/Core/Quaternion.js +6 -2
- package/Source/Core/RectangleOutlineGeometry.js +2 -4
- package/Source/Core/RequestScheduler.js +3 -9
- package/Source/Core/Resource.js +30 -69
- package/Source/Core/TerrainEncoding.js +2 -2
- package/Source/Core/Transforms.js +27 -18
- package/Source/Core/VerticalExaggeration.js +69 -0
- package/Source/Core/createWorldBathymetryAsync.js +45 -0
- package/Source/DataSources/EllipsoidGeometryUpdater.js +3 -4
- package/Source/DataSources/Entity.js +8 -5
- package/Source/DataSources/EntityCollection.js +1 -2
- package/Source/DataSources/GeometryUpdater.js +1 -2
- package/Source/DataSources/GroundGeometryUpdater.js +6 -3
- package/Source/DataSources/ModelVisualizer.js +19 -98
- package/Source/DataSources/PolygonGeometryUpdater.js +14 -2
- package/Source/DataSources/PolylineGeometryUpdater.js +9 -8
- package/Source/DataSources/TerrainOffsetProperty.js +15 -23
- package/Source/Renderer/AutomaticUniforms.js +173 -0
- package/Source/Renderer/UniformState.js +246 -1
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Atmosphere.js +127 -0
- package/Source/Scene/Billboard.js +29 -26
- package/Source/Scene/BillboardCollection.js +3 -3
- package/Source/Scene/Camera.js +1 -1
- package/Source/Scene/Cesium3DTile.js +123 -10
- package/Source/Scene/Cesium3DTileContent.js +14 -0
- package/Source/Scene/Cesium3DTileset.js +326 -45
- package/Source/Scene/Cesium3DTilesetTraversal.js +4 -0
- package/Source/Scene/Composite3DTileContent.js +42 -0
- package/Source/Scene/DynamicAtmosphereLightingType.js +56 -0
- package/Source/Scene/Empty3DTileContent.js +4 -0
- package/Source/Scene/Fog.js +1 -0
- package/Source/Scene/FrameState.js +13 -5
- package/Source/Scene/Geometry3DTileContent.js +4 -0
- package/Source/Scene/Globe.js +69 -21
- package/Source/Scene/GlobeSurfaceTile.js +4 -4
- package/Source/Scene/GlobeSurfaceTileProvider.js +24 -22
- package/Source/Scene/GltfLoader.js +15 -5
- package/Source/Scene/GroundPrimitive.js +5 -5
- package/Source/Scene/HeightReference.js +59 -2
- package/Source/Scene/ImageryLayer.js +3 -3
- package/Source/Scene/Implicit3DTileContent.js +4 -0
- package/Source/Scene/LabelCollection.js +2 -2
- package/Source/Scene/MapboxImageryProvider.js +2 -2
- package/Source/Scene/Megatexture.js +1 -1
- package/Source/Scene/Model/AtmospherePipelineStage.js +59 -0
- package/Source/Scene/Model/B3dmLoader.js +4 -0
- package/Source/Scene/Model/FeatureIdPipelineStage.js +25 -2
- package/Source/Scene/Model/I3dmLoader.js +4 -0
- package/Source/Scene/Model/InstancingPipelineStage.js +24 -6
- package/Source/Scene/Model/MetadataPipelineStage.js +31 -3
- package/Source/Scene/Model/Model.js +93 -32
- package/Source/Scene/Model/Model3DTileContent.js +31 -0
- package/Source/Scene/Model/ModelAnimationChannel.js +16 -15
- package/Source/Scene/Model/ModelRuntimePrimitive.js +6 -0
- package/Source/Scene/Model/ModelSceneGraph.js +6 -0
- package/Source/Scene/Model/VerticalExaggerationPipelineStage.js +60 -0
- package/Source/Scene/Model/pickModel.js +408 -0
- package/Source/Scene/Multiple3DTileContent.js +42 -0
- package/Source/Scene/QuadtreePrimitive.js +1 -1
- package/Source/Scene/Scene.js +226 -19
- package/Source/Scene/ScreenSpaceCameraController.js +14 -25
- package/Source/Scene/SkyAtmosphere.js +5 -6
- package/Source/Scene/Terrain.js +49 -0
- package/Source/Scene/TerrainFillMesh.js +2 -2
- package/Source/Scene/TileBoundingS2Cell.js +2 -2
- package/Source/Scene/TileOrientedBoundingBox.js +1 -1
- package/Source/Scene/Tileset3DTileContent.js +4 -0
- package/Source/Scene/Vector3DTileContent.js +4 -0
- package/Source/Scene/VoxelPrimitive.js +73 -2
- package/Source/Shaders/AtmosphereCommon.glsl +3 -11
- package/Source/Shaders/AtmosphereCommon.js +3 -11
- package/Source/Shaders/Builtin/CzmBuiltins.js +12 -0
- package/Source/Shaders/Builtin/Functions/applyHSBShift.glsl +32 -0
- package/Source/Shaders/Builtin/Functions/applyHSBShift.js +34 -0
- package/Source/Shaders/Builtin/Functions/approximateTanh.glsl +10 -0
- package/Source/Shaders/Builtin/Functions/approximateTanh.js +12 -0
- package/Source/Shaders/Builtin/Functions/computeAtmosphereColor.glsl +44 -0
- package/Source/Shaders/Builtin/Functions/computeAtmosphereColor.js +46 -0
- package/Source/Shaders/Builtin/Functions/computeGroundAtmosphereScattering.glsl +30 -0
- package/Source/Shaders/Builtin/Functions/computeGroundAtmosphereScattering.js +32 -0
- package/Source/Shaders/Builtin/Functions/computeScattering.glsl +150 -0
- package/Source/Shaders/Builtin/Functions/computeScattering.js +152 -0
- package/Source/Shaders/Builtin/Functions/getDynamicAtmosphereLightDirection.glsl +22 -0
- package/Source/Shaders/Builtin/Functions/getDynamicAtmosphereLightDirection.js +24 -0
- package/Source/Shaders/Builtin/Functions/translateRelativeToEye.glsl +5 -0
- package/Source/Shaders/Builtin/Functions/translateRelativeToEye.js +5 -0
- package/Source/Shaders/GlobeFS.glsl +16 -25
- package/Source/Shaders/GlobeFS.js +16 -25
- package/Source/Shaders/GlobeVS.glsl +4 -4
- package/Source/Shaders/GlobeVS.js +4 -4
- package/Source/Shaders/Model/AtmosphereStageFS.glsl +111 -0
- package/Source/Shaders/Model/AtmosphereStageFS.js +113 -0
- package/Source/Shaders/Model/AtmosphereStageVS.glsl +12 -0
- package/Source/Shaders/Model/AtmosphereStageVS.js +14 -0
- package/Source/Shaders/Model/GeometryStageFS.glsl +1 -1
- package/Source/Shaders/Model/GeometryStageFS.js +1 -1
- package/Source/Shaders/Model/GeometryStageVS.glsl +4 -4
- package/Source/Shaders/Model/GeometryStageVS.js +4 -4
- package/Source/Shaders/Model/ModelColorStageFS.glsl +1 -1
- package/Source/Shaders/Model/ModelColorStageFS.js +2 -1
- package/Source/Shaders/Model/ModelFS.glsl +4 -0
- package/Source/Shaders/Model/ModelFS.js +4 -0
- package/Source/Shaders/Model/ModelVS.glsl +13 -4
- package/Source/Shaders/Model/ModelVS.js +13 -4
- package/Source/Shaders/Model/VerticalExaggerationStageVS.glsl +39 -0
- package/Source/Shaders/Model/VerticalExaggerationStageVS.js +41 -0
- package/Source/Shaders/SkyAtmosphereCommon.glsl +3 -13
- package/Source/Shaders/SkyAtmosphereCommon.js +3 -13
- package/Source/Shaders/SkyAtmosphereFS.glsl +5 -10
- package/Source/Shaders/SkyAtmosphereFS.js +5 -10
- package/Source/Shaders/SkyAtmosphereVS.glsl +3 -2
- package/Source/Shaders/SkyAtmosphereVS.js +3 -2
- package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
- package/Source/ThirdParty/draco_decoder.wasm +0 -0
- package/index.d.ts +318 -83
- package/index.js +77 -62
- package/package.json +3 -3
- package/Build/Workers/chunk-7ONRI7T4.js +0 -55
- package/Source/Core/TerrainExaggeration.js +0 -49
|
@@ -366,7 +366,7 @@ Megatexture.getApproximateTextureMemoryByteLength = function (
|
|
|
366
366
|
const voxelCountTotal =
|
|
367
367
|
tileCount * dimensions.x * dimensions.y * dimensions.z;
|
|
368
368
|
|
|
369
|
-
const sliceCountPerRegionX = Math.ceil(Math.sqrt(dimensions.
|
|
369
|
+
const sliceCountPerRegionX = Math.ceil(Math.sqrt(dimensions.x));
|
|
370
370
|
const sliceCountPerRegionY = Math.ceil(dimensions.z / sliceCountPerRegionX);
|
|
371
371
|
const voxelCountPerRegionX = sliceCountPerRegionX * dimensions.x;
|
|
372
372
|
const voxelCountPerRegionY = sliceCountPerRegionY * dimensions.y;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import Cartesian3 from "../../Core/Cartesian3.js";
|
|
2
|
+
import CesiumMath from "../../Core/Math.js";
|
|
3
|
+
import ShaderDestination from "../../Renderer/ShaderDestination.js";
|
|
4
|
+
import AtmosphereStageFS from "../../Shaders/Model/AtmosphereStageFS.js";
|
|
5
|
+
import AtmosphereStageVS from "../../Shaders/Model/AtmosphereStageVS.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The atmosphere pipeline stage applies all earth atmosphere effects that apply
|
|
9
|
+
* to models, including fog.
|
|
10
|
+
*
|
|
11
|
+
* @namespace AtmospherePipelineStage
|
|
12
|
+
*
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
const AtmospherePipelineStage = {
|
|
16
|
+
name: "AtmospherePipelineStage", // Helps with debugging
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
AtmospherePipelineStage.process = function (
|
|
20
|
+
renderResources,
|
|
21
|
+
model,
|
|
22
|
+
frameState
|
|
23
|
+
) {
|
|
24
|
+
const shaderBuilder = renderResources.shaderBuilder;
|
|
25
|
+
|
|
26
|
+
shaderBuilder.addDefine("HAS_ATMOSPHERE", undefined, ShaderDestination.BOTH);
|
|
27
|
+
shaderBuilder.addDefine(
|
|
28
|
+
"COMPUTE_POSITION_WC_ATMOSPHERE",
|
|
29
|
+
undefined,
|
|
30
|
+
ShaderDestination.BOTH
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
shaderBuilder.addVarying("vec3", "v_atmosphereRayleighColor");
|
|
34
|
+
shaderBuilder.addVarying("vec3", "v_atmosphereMieColor");
|
|
35
|
+
shaderBuilder.addVarying("float", "v_atmosphereOpacity");
|
|
36
|
+
|
|
37
|
+
shaderBuilder.addVertexLines([AtmosphereStageVS]);
|
|
38
|
+
shaderBuilder.addFragmentLines([AtmosphereStageFS]);
|
|
39
|
+
|
|
40
|
+
// Add a uniform so fog is only calculated when the efcfect would
|
|
41
|
+
// be non-negligible For example when the camera is in space, fog density decreases
|
|
42
|
+
// to 0 so fog shouldn't be rendered. Since this state may change rapidly if
|
|
43
|
+
// the camera is moving, this is implemented as a uniform, not a define.
|
|
44
|
+
shaderBuilder.addUniform("bool", "u_isInFog", ShaderDestination.FRAGMENT);
|
|
45
|
+
renderResources.uniformMap.u_isInFog = function () {
|
|
46
|
+
// We only need a rough measure of distance to the model, so measure
|
|
47
|
+
// from the camera to the bounding sphere center.
|
|
48
|
+
const distance = Cartesian3.distance(
|
|
49
|
+
frameState.camera.positionWC,
|
|
50
|
+
model.boundingSphere.center
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
CesiumMath.fog(distance, frameState.fog.density) > CesiumMath.EPSILON3
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export default AtmospherePipelineStage;
|
|
@@ -50,6 +50,7 @@ const FeatureIdAttribute = ModelComponents.FeatureIdAttribute;
|
|
|
50
50
|
* @param {Axis} [options.forwardAxis=Axis.X] The forward-axis of the glTF model.
|
|
51
51
|
* @param {boolean} [options.loadAttributesAsTypedArray=false] If <code>true</code>, load all attributes as typed arrays instead of GPU buffers. If the attributes are interleaved in the glTF they will be de-interleaved in the typed array.
|
|
52
52
|
* @param {boolean} [options.loadAttributesFor2D=false] If <code>true</code>, load the positions buffer and any instanced attribute buffers as typed arrays for accurately projecting models to 2D.
|
|
53
|
+
* @param {boolean} [options.enablePick=false] If <code>true</code>, load the positions buffer, any instanced attribute buffers, and index buffer as typed arrays for CPU-enabled picking in WebGL1.
|
|
53
54
|
* @param {boolean} [options.loadIndicesForWireframe=false] If <code>true</code>, load the index buffer as a typed array. This is useful for creating wireframe indices in WebGL1.
|
|
54
55
|
* @param {boolean} [options.loadPrimitiveOutline=true] If <code>true</code>, load outlines from the {@link https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/CESIUM_primitive_outline|CESIUM_primitive_outline} extension. This can be set false to avoid post-processing geometry at load time.
|
|
55
56
|
* @param {boolean} [options.loadForClassification=false] If <code>true</code> and if the model has feature IDs, load the feature IDs and indices as typed arrays. This is useful for batching features for classification.
|
|
@@ -74,6 +75,7 @@ function B3dmLoader(options) {
|
|
|
74
75
|
false
|
|
75
76
|
);
|
|
76
77
|
const loadAttributesFor2D = defaultValue(options.loadAttributesFor2D, false);
|
|
78
|
+
const enablePick = defaultValue(options.enablePick, false);
|
|
77
79
|
const loadIndicesForWireframe = defaultValue(
|
|
78
80
|
options.loadIndicesForWireframe,
|
|
79
81
|
false
|
|
@@ -102,6 +104,7 @@ function B3dmLoader(options) {
|
|
|
102
104
|
this._forwardAxis = forwardAxis;
|
|
103
105
|
this._loadAttributesAsTypedArray = loadAttributesAsTypedArray;
|
|
104
106
|
this._loadAttributesFor2D = loadAttributesFor2D;
|
|
107
|
+
this._enablePick = enablePick;
|
|
105
108
|
this._loadIndicesForWireframe = loadIndicesForWireframe;
|
|
106
109
|
this._loadPrimitiveOutline = loadPrimitiveOutline;
|
|
107
110
|
this._loadForClassification = loadForClassification;
|
|
@@ -223,6 +226,7 @@ B3dmLoader.prototype.load = function () {
|
|
|
223
226
|
incrementallyLoadTextures: this._incrementallyLoadTextures,
|
|
224
227
|
loadAttributesAsTypedArray: this._loadAttributesAsTypedArray,
|
|
225
228
|
loadAttributesFor2D: this._loadAttributesFor2D,
|
|
229
|
+
enablePick: this._enablePick,
|
|
226
230
|
loadIndicesForWireframe: this._loadIndicesForWireframe,
|
|
227
231
|
loadPrimitiveOutline: this._loadPrimitiveOutline,
|
|
228
232
|
loadForClassification: this._loadForClassification,
|
|
@@ -9,6 +9,7 @@ import FeatureIdStageVS from "../../Shaders/Model/FeatureIdStageVS.js";
|
|
|
9
9
|
import ModelComponents from "../ModelComponents.js";
|
|
10
10
|
import VertexAttributeSemantic from "../VertexAttributeSemantic.js";
|
|
11
11
|
import ModelUtility from "./ModelUtility.js";
|
|
12
|
+
import Matrix3 from "../../Core/Matrix3.js";
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* The feature ID pipeline stage is responsible for processing feature IDs
|
|
@@ -387,10 +388,32 @@ function processTexture(
|
|
|
387
388
|
ShaderDestination.FRAGMENT
|
|
388
389
|
);
|
|
389
390
|
|
|
391
|
+
// Get a GLSL expression for the texture coordinates
|
|
392
|
+
const texCoord = textureReader.texCoord;
|
|
393
|
+
const texCoordVariable = `v_texCoord_${texCoord}`;
|
|
394
|
+
let texCoordVariableExpression = texCoordVariable;
|
|
395
|
+
|
|
396
|
+
// Check if the texture defines a `transform` from a `KHR_texture_transform`
|
|
397
|
+
const transform = textureReader.transform;
|
|
398
|
+
if (defined(transform) && !Matrix3.equals(transform, Matrix3.IDENTITY)) {
|
|
399
|
+
// Add a uniform for the transformation matrix
|
|
400
|
+
const transformUniformName = `${uniformName}Transform`;
|
|
401
|
+
shaderBuilder.addUniform(
|
|
402
|
+
"mat3",
|
|
403
|
+
transformUniformName,
|
|
404
|
+
ShaderDestination.FRAGMENT
|
|
405
|
+
);
|
|
406
|
+
uniformMap[transformUniformName] = function () {
|
|
407
|
+
return transform;
|
|
408
|
+
};
|
|
409
|
+
// Update the expression for the texture coordinates
|
|
410
|
+
// with one that transforms the texture coordinates
|
|
411
|
+
// with the transform matrix first
|
|
412
|
+
texCoordVariableExpression = `vec2(${transformUniformName} * vec3(${texCoordVariable}, 1.0))`;
|
|
413
|
+
}
|
|
390
414
|
// Read one or more channels from the texture
|
|
391
415
|
// example: texture(u_featureIdTexture_0, v_texCoord_1).rg
|
|
392
|
-
const
|
|
393
|
-
const textureRead = `texture(${uniformName}, ${texCoord}).${channels}`;
|
|
416
|
+
const textureRead = `texture(${uniformName}, ${texCoordVariableExpression}).${channels}`;
|
|
394
417
|
|
|
395
418
|
// Finally, assign to the struct field. Example:
|
|
396
419
|
// featureIds.featureId_0 = unpacked;
|
|
@@ -64,6 +64,7 @@ const Instances = ModelComponents.Instances;
|
|
|
64
64
|
* @param {Axis} [options.upAxis=Axis.Y] The up-axis of the glTF model.
|
|
65
65
|
* @param {Axis} [options.forwardAxis=Axis.X] The forward-axis of the glTF model.
|
|
66
66
|
* @param {boolean} [options.loadAttributesAsTypedArray=false] Load all attributes as typed arrays instead of GPU buffers. If the attributes are interleaved in the glTF they will be de-interleaved in the typed array.
|
|
67
|
+
* @param {boolean} [options.enablePick=false] If <code>true</code>, load the positions buffer, any instanced attribute buffers, and index buffer as typed arrays for CPU-enabled picking in WebGL1.
|
|
67
68
|
* @param {boolean} [options.loadIndicesForWireframe=false] Load the index buffer as a typed array so wireframe indices can be created for WebGL1.
|
|
68
69
|
* @param {boolean} [options.loadPrimitiveOutline=true] If true, load outlines from the {@link https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/CESIUM_primitive_outline|CESIUM_primitive_outline} extension. This can be set false to avoid post-processing geometry at load time.
|
|
69
70
|
*/
|
|
@@ -91,6 +92,7 @@ function I3dmLoader(options) {
|
|
|
91
92
|
false
|
|
92
93
|
);
|
|
93
94
|
const loadPrimitiveOutline = defaultValue(options.loadPrimitiveOutline, true);
|
|
95
|
+
const enablePick = defaultValue(options.enablePick, false);
|
|
94
96
|
|
|
95
97
|
//>>includeStart('debug', pragmas.debug);
|
|
96
98
|
Check.typeOf.object("options.i3dmResource", i3dmResource);
|
|
@@ -111,6 +113,7 @@ function I3dmLoader(options) {
|
|
|
111
113
|
this._loadAttributesAsTypedArray = loadAttributesAsTypedArray;
|
|
112
114
|
this._loadIndicesForWireframe = loadIndicesForWireframe;
|
|
113
115
|
this._loadPrimitiveOutline = loadPrimitiveOutline;
|
|
116
|
+
this._enablePick = enablePick;
|
|
114
117
|
|
|
115
118
|
this._state = I3dmLoaderState.NOT_LOADED;
|
|
116
119
|
this._promise = undefined;
|
|
@@ -240,6 +243,7 @@ I3dmLoader.prototype.load = function () {
|
|
|
240
243
|
releaseGltfJson: this._releaseGltfJson,
|
|
241
244
|
incrementallyLoadTextures: this._incrementallyLoadTextures,
|
|
242
245
|
loadAttributesAsTypedArray: this._loadAttributesAsTypedArray,
|
|
246
|
+
enablePick: this._enablePick,
|
|
243
247
|
loadIndicesForWireframe: this._loadIndicesForWireframe,
|
|
244
248
|
loadPrimitiveOutline: this._loadPrimitiveOutline,
|
|
245
249
|
};
|
|
@@ -73,6 +73,7 @@ InstancingPipelineStage.process = function (renderResources, node, frameState) {
|
|
|
73
73
|
frameState.mode !== SceneMode.SCENE3D &&
|
|
74
74
|
!frameState.scene3DOnly &&
|
|
75
75
|
model._projectTo2D;
|
|
76
|
+
const keepTypedArray = model._enablePick && !frameState.context.webgl2;
|
|
76
77
|
|
|
77
78
|
const instancingVertexAttributes = [];
|
|
78
79
|
|
|
@@ -81,7 +82,8 @@ InstancingPipelineStage.process = function (renderResources, node, frameState) {
|
|
|
81
82
|
frameState,
|
|
82
83
|
instances,
|
|
83
84
|
instancingVertexAttributes,
|
|
84
|
-
use2D
|
|
85
|
+
use2D,
|
|
86
|
+
keepTypedArray
|
|
85
87
|
);
|
|
86
88
|
|
|
87
89
|
processFeatureIdAttributes(
|
|
@@ -697,7 +699,8 @@ function processTransformAttributes(
|
|
|
697
699
|
frameState,
|
|
698
700
|
instances,
|
|
699
701
|
instancingVertexAttributes,
|
|
700
|
-
use2D
|
|
702
|
+
use2D,
|
|
703
|
+
keepTypedArray
|
|
701
704
|
) {
|
|
702
705
|
const rotationAttribute = ModelUtility.getAttributeBySemantic(
|
|
703
706
|
instances,
|
|
@@ -711,7 +714,8 @@ function processTransformAttributes(
|
|
|
711
714
|
instances,
|
|
712
715
|
instancingVertexAttributes,
|
|
713
716
|
frameState,
|
|
714
|
-
use2D
|
|
717
|
+
use2D,
|
|
718
|
+
keepTypedArray
|
|
715
719
|
);
|
|
716
720
|
} else {
|
|
717
721
|
processTransformVec3Attributes(
|
|
@@ -729,7 +733,8 @@ function processTransformMatrixAttributes(
|
|
|
729
733
|
instances,
|
|
730
734
|
instancingVertexAttributes,
|
|
731
735
|
frameState,
|
|
732
|
-
use2D
|
|
736
|
+
use2D,
|
|
737
|
+
keepTypedArray
|
|
733
738
|
) {
|
|
734
739
|
const shaderBuilder = renderResources.shaderBuilder;
|
|
735
740
|
const count = instances.attributes[0].count;
|
|
@@ -755,6 +760,10 @@ function processTransformMatrixAttributes(
|
|
|
755
760
|
buffer = createVertexBuffer(transformsTypedArray, frameState);
|
|
756
761
|
model._modelResources.push(buffer);
|
|
757
762
|
|
|
763
|
+
if (keepTypedArray) {
|
|
764
|
+
runtimeNode.transformsTypedArray = transformsTypedArray;
|
|
765
|
+
}
|
|
766
|
+
|
|
758
767
|
runtimeNode.instancingTransformsBuffer = buffer;
|
|
759
768
|
}
|
|
760
769
|
|
|
@@ -812,7 +821,8 @@ function processTransformVec3Attributes(
|
|
|
812
821
|
instances,
|
|
813
822
|
instancingVertexAttributes,
|
|
814
823
|
frameState,
|
|
815
|
-
use2D
|
|
824
|
+
use2D,
|
|
825
|
+
keepTypedArray
|
|
816
826
|
) {
|
|
817
827
|
const shaderBuilder = renderResources.shaderBuilder;
|
|
818
828
|
const runtimeNode = renderResources.runtimeNode;
|
|
@@ -872,7 +882,7 @@ function processTransformVec3Attributes(
|
|
|
872
882
|
attributeString
|
|
873
883
|
);
|
|
874
884
|
|
|
875
|
-
if (!use2D) {
|
|
885
|
+
if (!use2D && !keepTypedArray) {
|
|
876
886
|
return;
|
|
877
887
|
}
|
|
878
888
|
|
|
@@ -898,6 +908,10 @@ function processTransformVec3Attributes(
|
|
|
898
908
|
);
|
|
899
909
|
const projectedTypedArray = translationsToTypedArray(projectedTranslations);
|
|
900
910
|
|
|
911
|
+
if (keepTypedArray) {
|
|
912
|
+
runtimeNode.transformsTypedArray = projectedTypedArray;
|
|
913
|
+
}
|
|
914
|
+
|
|
901
915
|
// This memory is counted during the statistics stage at the end
|
|
902
916
|
// of the pipeline.
|
|
903
917
|
buffer2D = createVertexBuffer(projectedTypedArray, frameState);
|
|
@@ -906,6 +920,10 @@ function processTransformVec3Attributes(
|
|
|
906
920
|
runtimeNode.instancingTranslationBuffer2D = buffer2D;
|
|
907
921
|
}
|
|
908
922
|
|
|
923
|
+
if (!use2D) {
|
|
924
|
+
return;
|
|
925
|
+
}
|
|
926
|
+
|
|
909
927
|
const byteOffset = 0;
|
|
910
928
|
const byteStride = undefined;
|
|
911
929
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Matrix3 from "../../Core/Matrix3.js";
|
|
1
2
|
import defined from "../../Core/defined.js";
|
|
2
3
|
import ShaderDestination from "../../Renderer/ShaderDestination.js";
|
|
3
4
|
import MetadataStageFS from "../../Shaders/Model/MetadataStageFS.js";
|
|
@@ -430,7 +431,13 @@ function addPropertyTexturePropertyMetadata(renderResources, propertyInfo) {
|
|
|
430
431
|
const { shaderBuilder, uniformMap } = renderResources;
|
|
431
432
|
const { metadataVariable, glslType, property } = propertyInfo;
|
|
432
433
|
|
|
433
|
-
const {
|
|
434
|
+
const {
|
|
435
|
+
texCoord,
|
|
436
|
+
channels,
|
|
437
|
+
index,
|
|
438
|
+
texture,
|
|
439
|
+
transform,
|
|
440
|
+
} = property.textureReader;
|
|
434
441
|
const textureUniformName = `u_propertyTexture_${index}`;
|
|
435
442
|
|
|
436
443
|
// Property texture properties may share the same physical texture, so only
|
|
@@ -450,9 +457,30 @@ function addPropertyTexturePropertyMetadata(renderResources, propertyInfo) {
|
|
|
450
457
|
metadataVariable
|
|
451
458
|
);
|
|
452
459
|
|
|
453
|
-
// Get a GLSL expression for the
|
|
460
|
+
// Get a GLSL expression for the texture coordinates of the property.
|
|
461
|
+
// By default, this will be taken directly from the attributes.
|
|
454
462
|
const texCoordVariable = `attributes.texCoord_${texCoord}`;
|
|
455
|
-
|
|
463
|
+
let texCoordVariableExpression = texCoordVariable;
|
|
464
|
+
|
|
465
|
+
// Check if the texture defines a `transform` from a `KHR_texture_transform`
|
|
466
|
+
if (defined(transform) && !Matrix3.equals(transform, Matrix3.IDENTITY)) {
|
|
467
|
+
// Add a uniform for the transformation matrix
|
|
468
|
+
const transformUniformName = `${textureUniformName}Transform`;
|
|
469
|
+
shaderBuilder.addUniform(
|
|
470
|
+
"mat3",
|
|
471
|
+
transformUniformName,
|
|
472
|
+
ShaderDestination.FRAGMENT
|
|
473
|
+
);
|
|
474
|
+
uniformMap[transformUniformName] = function () {
|
|
475
|
+
return transform;
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
// Update the expression for the texture coordinates
|
|
479
|
+
// with one that transforms the texture coordinates
|
|
480
|
+
// with the transform matrix first
|
|
481
|
+
texCoordVariableExpression = `vec2(${transformUniformName} * vec3(${texCoordVariable}, 1.0))`;
|
|
482
|
+
}
|
|
483
|
+
const valueExpression = `texture(${textureUniformName}, ${texCoordVariableExpression}).${channels}`;
|
|
456
484
|
|
|
457
485
|
// Some types need an unpacking step or two. For example, since texture reads
|
|
458
486
|
// are always normalized, UINT8 (not normalized) properties need to be
|
|
@@ -9,6 +9,7 @@ import defaultValue from "../../Core/defaultValue.js";
|
|
|
9
9
|
import DeveloperError from "../../Core/DeveloperError.js";
|
|
10
10
|
import destroyObject from "../../Core/destroyObject.js";
|
|
11
11
|
import DistanceDisplayCondition from "../../Core/DistanceDisplayCondition.js";
|
|
12
|
+
import Ellipsoid from "../../Core/Ellipsoid.js";
|
|
12
13
|
import Event from "../../Core/Event.js";
|
|
13
14
|
import Matrix3 from "../../Core/Matrix3.js";
|
|
14
15
|
import Matrix4 from "../../Core/Matrix4.js";
|
|
@@ -18,7 +19,9 @@ import Pass from "../../Renderer/Pass.js";
|
|
|
18
19
|
import ClippingPlaneCollection from "../ClippingPlaneCollection.js";
|
|
19
20
|
import ColorBlendMode from "../ColorBlendMode.js";
|
|
20
21
|
import GltfLoader from "../GltfLoader.js";
|
|
21
|
-
import HeightReference
|
|
22
|
+
import HeightReference, {
|
|
23
|
+
isHeightReferenceRelative,
|
|
24
|
+
} from "../HeightReference.js";
|
|
22
25
|
import ImageBasedLighting from "../ImageBasedLighting.js";
|
|
23
26
|
import PointCloudShading from "../PointCloudShading.js";
|
|
24
27
|
import SceneMode from "../SceneMode.js";
|
|
@@ -37,6 +40,7 @@ import ModelUtility from "./ModelUtility.js";
|
|
|
37
40
|
import oneTimeWarning from "../../Core/oneTimeWarning.js";
|
|
38
41
|
import PntsLoader from "./PntsLoader.js";
|
|
39
42
|
import StyleCommandsNeeded from "./StyleCommandsNeeded.js";
|
|
43
|
+
import pickModel from "./pickModel.js";
|
|
40
44
|
|
|
41
45
|
/**
|
|
42
46
|
* <div class="notice">
|
|
@@ -112,7 +116,7 @@ import StyleCommandsNeeded from "./StyleCommandsNeeded.js";
|
|
|
112
116
|
* @internalConstructor
|
|
113
117
|
*
|
|
114
118
|
* @privateParam {ResourceLoader} options.loader The loader used to load resources for this model.
|
|
115
|
-
* @privateParam {ModelType} options.type Type of this model, to distinguish individual glTF files from 3D Tiles internally.
|
|
119
|
+
* @privateParam {ModelType} options.type Type of this model, to distinguish individual glTF files from 3D Tiles internally.
|
|
116
120
|
* @privateParam {object} options Object with the following properties:
|
|
117
121
|
* @privateParam {Resource} options.resource The Resource to the 3D model.
|
|
118
122
|
* @privateParam {boolean} [options.show=true] Whether or not to render the model.
|
|
@@ -150,11 +154,12 @@ import StyleCommandsNeeded from "./StyleCommandsNeeded.js";
|
|
|
150
154
|
* @privateParam {boolean} [options.showCreditsOnScreen=false] Whether to display the credits of this model on screen.
|
|
151
155
|
* @privateParam {SplitDirection} [options.splitDirection=SplitDirection.NONE] The {@link SplitDirection} split to apply to this model.
|
|
152
156
|
* @privateParam {boolean} [options.projectTo2D=false] Whether to accurately project the model's positions in 2D. If this is true, the model will be projected accurately to 2D, but it will use more memory to do so. If this is false, the model will use less memory and will still render in 2D / CV mode, but its positions may be inaccurate. This disables minimumPixelSize and prevents future modification to the model matrix. This also cannot be set after the model has loaded.
|
|
157
|
+
* @privateParam {boolean} [options.enablePick=false] Whether to allow CPU picking with <code>pick</code> when not using WebGL 2 or above. If using WebGL 2 or above, this option will be ignored. If using WebGL 1 and this is true, the <code>pick</code> operation will work correctly, but it will use more memory to do so. If running with WebGL 1 and this is false, the model will use less memory, but <code>pick</code> will always return <code>undefined</code>. This cannot be set after the model has loaded.
|
|
153
158
|
* @privateParam {string|number} [options.featureIdLabel="featureId_0"] Label of the feature ID set to use for picking and styling. For EXT_mesh_features, this is the feature ID's label property, or "featureId_N" (where N is the index in the featureIds array) when not specified. EXT_feature_metadata did not have a label field, so such feature ID sets are always labeled "featureId_N" where N is the index in the list of all feature Ids, where feature ID attributes are listed before feature ID textures. If featureIdLabel is an integer N, it is converted to the string "featureId_N" automatically. If both per-primitive and per-instance feature IDs are present, the instance feature IDs take priority.
|
|
154
159
|
* @privateParam {string|number} [options.instanceFeatureIdLabel="instanceFeatureId_0"] Label of the instance feature ID set used for picking and styling. If instanceFeatureIdLabel is set to an integer N, it is converted to the string "instanceFeatureId_N" automatically. If both per-primitive and per-instance feature IDs are present, the instance feature IDs take priority.
|
|
155
160
|
* @privateParam {object} [options.pointCloudShading] Options for constructing a {@link PointCloudShading} object to control point attenuation based on geometric error and lighting.
|
|
156
161
|
* @privateParam {ClassificationType} [options.classificationType] Determines whether terrain, 3D Tiles or both will be classified by this model. This cannot be set after the model has loaded.
|
|
157
|
-
|
|
162
|
+
|
|
158
163
|
*
|
|
159
164
|
* @see Model.fromGltfAsync
|
|
160
165
|
*
|
|
@@ -192,7 +197,7 @@ function Model(options) {
|
|
|
192
197
|
* When this is the identity matrix, the model is drawn in world coordinates, i.e., Earth's Cartesian WGS84 coordinates.
|
|
193
198
|
* Local reference frames can be used by providing a different transformation matrix, like that returned
|
|
194
199
|
* by {@link Transforms.eastNorthUpToFixedFrame}.
|
|
195
|
-
*
|
|
200
|
+
*
|
|
196
201
|
* @type {Matrix4}
|
|
197
202
|
|
|
198
203
|
* @default {@link Matrix4.IDENTITY}
|
|
@@ -333,15 +338,16 @@ function Model(options) {
|
|
|
333
338
|
this._heightDirty = this._heightReference !== HeightReference.NONE;
|
|
334
339
|
this._removeUpdateHeightCallback = undefined;
|
|
335
340
|
|
|
341
|
+
this._verticalExaggerationOn = false;
|
|
342
|
+
|
|
336
343
|
this._clampedModelMatrix = undefined; // For use with height reference
|
|
337
344
|
|
|
338
345
|
const scene = options.scene;
|
|
339
346
|
if (defined(scene) && defined(scene.terrainProviderChanged)) {
|
|
340
347
|
this._terrainProviderChangedCallback = scene.terrainProviderChanged.addEventListener(
|
|
341
|
-
|
|
348
|
+
() => {
|
|
342
349
|
this._heightDirty = true;
|
|
343
|
-
}
|
|
344
|
-
this
|
|
350
|
+
}
|
|
345
351
|
);
|
|
346
352
|
}
|
|
347
353
|
this._scene = scene;
|
|
@@ -453,6 +459,9 @@ function Model(options) {
|
|
|
453
459
|
|
|
454
460
|
this._sceneMode = undefined;
|
|
455
461
|
this._projectTo2D = defaultValue(options.projectTo2D, false);
|
|
462
|
+
this._enablePick = defaultValue(options.enablePick, false);
|
|
463
|
+
|
|
464
|
+
this._fogRenderable = undefined;
|
|
456
465
|
|
|
457
466
|
this._skipLevelOfDetail = false;
|
|
458
467
|
this._ignoreCommands = defaultValue(options.ignoreCommands, false);
|
|
@@ -1548,11 +1557,15 @@ Object.defineProperties(Model.prototype, {
|
|
|
1548
1557
|
* <li>The glTF cannot contain morph targets, skins, or animations.</li>
|
|
1549
1558
|
* <li>The glTF cannot contain the <code>EXT_mesh_gpu_instancing</code> extension.</li>
|
|
1550
1559
|
* <li>Only meshes with TRIANGLES can be used to classify other assets.</li>
|
|
1551
|
-
* <li>The
|
|
1560
|
+
* <li>The meshes must be watertight.</li>
|
|
1561
|
+
* <li>The POSITION attribute is required.</li>
|
|
1552
1562
|
* <li>If feature IDs and an index buffer are both present, all indices with the same feature id must occupy contiguous sections of the index buffer.</li>
|
|
1553
1563
|
* <li>If feature IDs are present without an index buffer, all positions with the same feature id must occupy contiguous sections of the position buffer.</li>
|
|
1554
1564
|
* </ul>
|
|
1555
1565
|
* </p>
|
|
1566
|
+
* <p>
|
|
1567
|
+
* The 3D Tiles or terrain receiving the classification must be opaque.
|
|
1568
|
+
* </p>
|
|
1556
1569
|
*
|
|
1557
1570
|
* @memberof Model.prototype
|
|
1558
1571
|
*
|
|
@@ -1789,6 +1802,8 @@ Model.prototype.update = function (frameState) {
|
|
|
1789
1802
|
updateSkipLevelOfDetail(this, frameState);
|
|
1790
1803
|
updateClippingPlanes(this, frameState);
|
|
1791
1804
|
updateSceneMode(this, frameState);
|
|
1805
|
+
updateFog(this, frameState);
|
|
1806
|
+
updateVerticalExaggeration(this, frameState);
|
|
1792
1807
|
|
|
1793
1808
|
this._defaultTexture = frameState.context.defaultTexture;
|
|
1794
1809
|
|
|
@@ -1983,6 +1998,22 @@ function updateSceneMode(model, frameState) {
|
|
|
1983
1998
|
}
|
|
1984
1999
|
}
|
|
1985
2000
|
|
|
2001
|
+
function updateFog(model, frameState) {
|
|
2002
|
+
const fogRenderable = frameState.fog.enabled && frameState.fog.renderable;
|
|
2003
|
+
if (fogRenderable !== model._fogRenderable) {
|
|
2004
|
+
model.resetDrawCommands();
|
|
2005
|
+
model._fogRenderable = fogRenderable;
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
function updateVerticalExaggeration(model, frameState) {
|
|
2010
|
+
const verticalExaggerationNeeded = frameState.verticalExaggeration !== 1.0;
|
|
2011
|
+
if (model._verticalExaggerationOn !== verticalExaggerationNeeded) {
|
|
2012
|
+
model.resetDrawCommands();
|
|
2013
|
+
model._verticalExaggerationOn = verticalExaggerationNeeded;
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
|
|
1986
2017
|
function buildDrawCommands(model, frameState) {
|
|
1987
2018
|
if (!model._drawCommandsBuilt) {
|
|
1988
2019
|
model.destroyPipelineResources();
|
|
@@ -2025,15 +2056,11 @@ function updateClamping(model) {
|
|
|
2025
2056
|
}
|
|
2026
2057
|
|
|
2027
2058
|
const scene = model._scene;
|
|
2028
|
-
if (
|
|
2029
|
-
!defined(scene) ||
|
|
2030
|
-
!defined(scene.globe) ||
|
|
2031
|
-
model.heightReference === HeightReference.NONE
|
|
2032
|
-
) {
|
|
2059
|
+
if (!defined(scene) || model.heightReference === HeightReference.NONE) {
|
|
2033
2060
|
//>>includeStart('debug', pragmas.debug);
|
|
2034
2061
|
if (model.heightReference !== HeightReference.NONE) {
|
|
2035
2062
|
throw new DeveloperError(
|
|
2036
|
-
"Height reference is not supported without a scene
|
|
2063
|
+
"Height reference is not supported without a scene."
|
|
2037
2064
|
);
|
|
2038
2065
|
}
|
|
2039
2066
|
//>>includeEnd('debug');
|
|
@@ -2042,7 +2069,7 @@ function updateClamping(model) {
|
|
|
2042
2069
|
}
|
|
2043
2070
|
|
|
2044
2071
|
const globe = scene.globe;
|
|
2045
|
-
const ellipsoid = globe.
|
|
2072
|
+
const ellipsoid = defaultValue(globe?.ellipsoid, Ellipsoid.WGS84);
|
|
2046
2073
|
|
|
2047
2074
|
// Compute cartographic position so we don't recompute every update
|
|
2048
2075
|
const modelMatrix = model.modelMatrix;
|
|
@@ -2056,14 +2083,14 @@ function updateClamping(model) {
|
|
|
2056
2083
|
}
|
|
2057
2084
|
|
|
2058
2085
|
// Install callback to handle updating of terrain tiles
|
|
2059
|
-
|
|
2060
|
-
model._removeUpdateHeightCallback = surface.updateHeight(
|
|
2086
|
+
model._removeUpdateHeightCallback = scene.updateHeight(
|
|
2061
2087
|
cartoPosition,
|
|
2062
|
-
getUpdateHeightCallback(model, ellipsoid, cartoPosition)
|
|
2088
|
+
getUpdateHeightCallback(model, ellipsoid, cartoPosition),
|
|
2089
|
+
model.heightReference
|
|
2063
2090
|
);
|
|
2064
2091
|
|
|
2065
2092
|
// Set the correct height now
|
|
2066
|
-
const height =
|
|
2093
|
+
const height = scene.getHeight(cartoPosition, model.heightReference);
|
|
2067
2094
|
if (defined(height)) {
|
|
2068
2095
|
// Get callback with cartoPosition being the non-clamped position
|
|
2069
2096
|
const callback = getUpdateHeightCallback(model, ellipsoid, cartoPosition);
|
|
@@ -2071,8 +2098,7 @@ function updateClamping(model) {
|
|
|
2071
2098
|
// Compute the clamped cartesian and call updateHeight callback
|
|
2072
2099
|
Cartographic.clone(cartoPosition, scratchCartographic);
|
|
2073
2100
|
scratchCartographic.height = height;
|
|
2074
|
-
|
|
2075
|
-
callback(scratchPosition);
|
|
2101
|
+
callback(scratchCartographic);
|
|
2076
2102
|
}
|
|
2077
2103
|
|
|
2078
2104
|
model._heightDirty = false;
|
|
@@ -2329,24 +2355,25 @@ function scaleInPixels(positionWC, radius, frameState) {
|
|
|
2329
2355
|
);
|
|
2330
2356
|
}
|
|
2331
2357
|
|
|
2332
|
-
|
|
2358
|
+
const scratchUpdateHeightCartesian = new Cartesian3();
|
|
2359
|
+
function getUpdateHeightCallback(model, ellipsoid, originalPostition) {
|
|
2333
2360
|
return function (clampedPosition) {
|
|
2334
|
-
if (model.heightReference
|
|
2335
|
-
|
|
2336
|
-
clampedPosition,
|
|
2337
|
-
scratchCartographic
|
|
2338
|
-
);
|
|
2339
|
-
clampedCart.height += cartoPosition.height;
|
|
2340
|
-
ellipsoid.cartographicToCartesian(clampedCart, clampedPosition);
|
|
2361
|
+
if (isHeightReferenceRelative(model.heightReference)) {
|
|
2362
|
+
clampedPosition.height += originalPostition.height;
|
|
2341
2363
|
}
|
|
2342
2364
|
|
|
2365
|
+
ellipsoid.cartographicToCartesian(
|
|
2366
|
+
clampedPosition,
|
|
2367
|
+
scratchUpdateHeightCartesian
|
|
2368
|
+
);
|
|
2369
|
+
|
|
2343
2370
|
const clampedModelMatrix = model._clampedModelMatrix;
|
|
2344
2371
|
|
|
2345
2372
|
// Modify clamped model matrix to use new height
|
|
2346
2373
|
Matrix4.clone(model.modelMatrix, clampedModelMatrix);
|
|
2347
|
-
clampedModelMatrix[12] =
|
|
2348
|
-
clampedModelMatrix[13] =
|
|
2349
|
-
clampedModelMatrix[14] =
|
|
2374
|
+
clampedModelMatrix[12] = scratchUpdateHeightCartesian.x;
|
|
2375
|
+
clampedModelMatrix[13] = scratchUpdateHeightCartesian.y;
|
|
2376
|
+
clampedModelMatrix[14] = scratchUpdateHeightCartesian.z;
|
|
2350
2377
|
|
|
2351
2378
|
model._heightDirty = true;
|
|
2352
2379
|
};
|
|
@@ -2481,6 +2508,35 @@ Model.prototype.isClippingEnabled = function () {
|
|
|
2481
2508
|
);
|
|
2482
2509
|
};
|
|
2483
2510
|
|
|
2511
|
+
/**
|
|
2512
|
+
* Find an intersection between a ray and the model surface that was rendered. The ray must be given in world coordinates.
|
|
2513
|
+
*
|
|
2514
|
+
* @param {Ray} ray The ray to test for intersection.
|
|
2515
|
+
* @param {FrameState} frameState The frame state.
|
|
2516
|
+
* @param {number} [verticalExaggeration=1.0] A scalar used to exaggerate the height of a position relative to the ellipsoid. If the value is 1.0 there will be no effect.
|
|
2517
|
+
* @param {number} [relativeHeight=0.0] The height above the ellipsoid relative to which a position is exaggerated. If the value is 0.0 the position will be exaggerated relative to the ellipsoid surface.
|
|
2518
|
+
* @param {Cartesian3|undefined} [result] The intersection or <code>undefined</code> if none was found.
|
|
2519
|
+
* @returns {Cartesian3|undefined} The intersection or <code>undefined</code> if none was found.
|
|
2520
|
+
*
|
|
2521
|
+
* @private
|
|
2522
|
+
*/
|
|
2523
|
+
Model.prototype.pick = function (
|
|
2524
|
+
ray,
|
|
2525
|
+
frameState,
|
|
2526
|
+
verticalExaggeration,
|
|
2527
|
+
relativeHeight,
|
|
2528
|
+
result
|
|
2529
|
+
) {
|
|
2530
|
+
return pickModel(
|
|
2531
|
+
this,
|
|
2532
|
+
ray,
|
|
2533
|
+
frameState,
|
|
2534
|
+
verticalExaggeration,
|
|
2535
|
+
relativeHeight,
|
|
2536
|
+
result
|
|
2537
|
+
);
|
|
2538
|
+
};
|
|
2539
|
+
|
|
2484
2540
|
/**
|
|
2485
2541
|
* Returns true if this object was destroyed; otherwise, false.
|
|
2486
2542
|
* <br /><br />
|
|
@@ -2640,6 +2696,7 @@ Model.prototype.destroyModelResources = function () {
|
|
|
2640
2696
|
* @param {boolean} [options.showCreditsOnScreen=false] Whether to display the credits of this model on screen.
|
|
2641
2697
|
* @param {SplitDirection} [options.splitDirection=SplitDirection.NONE] The {@link SplitDirection} split to apply to this model.
|
|
2642
2698
|
* @param {boolean} [options.projectTo2D=false] Whether to accurately project the model's positions in 2D. If this is true, the model will be projected accurately to 2D, but it will use more memory to do so. If this is false, the model will use less memory and will still render in 2D / CV mode, but its positions may be inaccurate. This disables minimumPixelSize and prevents future modification to the model matrix. This also cannot be set after the model has loaded.
|
|
2699
|
+
* @param {boolean} [options.enablePick=false] Whether to allow with CPU picking with <code>pick</code> when not using WebGL 2 or above. If using WebGL 2 or above, this option will be ignored. If using WebGL 1 and this is true, the <code>pick</code> operation will work correctly, but it will use more memory to do so. If running with WebGL 1 and this is false, the model will use less memory, but <code>pick</code> will always return <code>undefined</code>. This cannot be set after the model has loaded.
|
|
2643
2700
|
* @param {string|number} [options.featureIdLabel="featureId_0"] Label of the feature ID set to use for picking and styling. For EXT_mesh_features, this is the feature ID's label property, or "featureId_N" (where N is the index in the featureIds array) when not specified. EXT_feature_metadata did not have a label field, so such feature ID sets are always labeled "featureId_N" where N is the index in the list of all feature Ids, where feature ID attributes are listed before feature ID textures. If featureIdLabel is an integer N, it is converted to the string "featureId_N" automatically. If both per-primitive and per-instance feature IDs are present, the instance feature IDs take priority.
|
|
2644
2701
|
* @param {string|number} [options.instanceFeatureIdLabel="instanceFeatureId_0"] Label of the instance feature ID set used for picking and styling. If instanceFeatureIdLabel is set to an integer N, it is converted to the string "instanceFeatureId_N" automatically. If both per-primitive and per-instance feature IDs are present, the instance feature IDs take priority.
|
|
2645
2702
|
* @param {object} [options.pointCloudShading] Options for constructing a {@link PointCloudShading} object to control point attenuation and lighting.
|
|
@@ -2734,6 +2791,7 @@ Model.fromGltfAsync = async function (options) {
|
|
|
2734
2791
|
upAxis: options.upAxis,
|
|
2735
2792
|
forwardAxis: options.forwardAxis,
|
|
2736
2793
|
loadAttributesFor2D: options.projectTo2D,
|
|
2794
|
+
enablePick: options.enablePick,
|
|
2737
2795
|
loadIndicesForWireframe: options.enableDebugWireframe,
|
|
2738
2796
|
loadPrimitiveOutline: options.enableShowOutline,
|
|
2739
2797
|
loadForClassification: defined(options.classificationType),
|
|
@@ -2810,6 +2868,7 @@ Model.fromB3dm = async function (options) {
|
|
|
2810
2868
|
upAxis: options.upAxis,
|
|
2811
2869
|
forwardAxis: options.forwardAxis,
|
|
2812
2870
|
loadAttributesFor2D: options.projectTo2D,
|
|
2871
|
+
enablePick: options.enablePick,
|
|
2813
2872
|
loadIndicesForWireframe: options.enableDebugWireframe,
|
|
2814
2873
|
loadPrimitiveOutline: options.enableShowOutline,
|
|
2815
2874
|
loadForClassification: defined(options.classificationType),
|
|
@@ -2865,6 +2924,7 @@ Model.fromI3dm = async function (options) {
|
|
|
2865
2924
|
upAxis: options.upAxis,
|
|
2866
2925
|
forwardAxis: options.forwardAxis,
|
|
2867
2926
|
loadAttributesFor2D: options.projectTo2D,
|
|
2927
|
+
enablePick: options.enablePick,
|
|
2868
2928
|
loadIndicesForWireframe: options.enableDebugWireframe,
|
|
2869
2929
|
loadPrimitiveOutline: options.enableShowOutline,
|
|
2870
2930
|
};
|
|
@@ -2998,6 +3058,7 @@ function makeModelOptions(loader, modelType, options) {
|
|
|
2998
3058
|
showCreditsOnScreen: options.showCreditsOnScreen,
|
|
2999
3059
|
splitDirection: options.splitDirection,
|
|
3000
3060
|
projectTo2D: options.projectTo2D,
|
|
3061
|
+
enablePick: options.enablePick,
|
|
3001
3062
|
featureIdLabel: options.featureIdLabel,
|
|
3002
3063
|
instanceFeatureIdLabel: options.instanceFeatureIdLabel,
|
|
3003
3064
|
pointCloudShading: options.pointCloudShading,
|