@itwin/core-frontend 5.0.0-dev.106 → 5.0.0-dev.109

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.
Files changed (51) hide show
  1. package/lib/cjs/BriefcaseConnection.d.ts +1 -1
  2. package/lib/cjs/BriefcaseConnection.d.ts.map +1 -1
  3. package/lib/cjs/BriefcaseConnection.js.map +1 -1
  4. package/lib/cjs/CatalogConnection.d.ts +71 -0
  5. package/lib/cjs/CatalogConnection.d.ts.map +1 -0
  6. package/lib/cjs/CatalogConnection.js +95 -0
  7. package/lib/cjs/CatalogConnection.js.map +1 -0
  8. package/lib/cjs/IpcApp.d.ts +1 -1
  9. package/lib/cjs/IpcApp.d.ts.map +1 -1
  10. package/lib/cjs/IpcApp.js.map +1 -1
  11. package/lib/cjs/NativeApp.d.ts +2 -1
  12. package/lib/cjs/NativeApp.d.ts.map +1 -1
  13. package/lib/cjs/NativeApp.js +1 -0
  14. package/lib/cjs/NativeApp.js.map +1 -1
  15. package/lib/cjs/core-frontend.d.ts +1 -0
  16. package/lib/cjs/core-frontend.d.ts.map +1 -1
  17. package/lib/cjs/core-frontend.js +1 -0
  18. package/lib/cjs/core-frontend.js.map +1 -1
  19. package/lib/cjs/internal/render/webgl/SolarShadowMap.js +2 -2
  20. package/lib/cjs/internal/render/webgl/SolarShadowMap.js.map +1 -1
  21. package/lib/cjs/tile/map/CesiumTerrainProvider.d.ts +1 -1
  22. package/lib/cjs/tile/map/CesiumTerrainProvider.d.ts.map +1 -1
  23. package/lib/cjs/tile/map/CesiumTerrainProvider.js +2 -3
  24. package/lib/cjs/tile/map/CesiumTerrainProvider.js.map +1 -1
  25. package/lib/esm/BriefcaseConnection.d.ts +1 -1
  26. package/lib/esm/BriefcaseConnection.d.ts.map +1 -1
  27. package/lib/esm/BriefcaseConnection.js.map +1 -1
  28. package/lib/esm/CatalogConnection.d.ts +71 -0
  29. package/lib/esm/CatalogConnection.d.ts.map +1 -0
  30. package/lib/esm/CatalogConnection.js +92 -0
  31. package/lib/esm/CatalogConnection.js.map +1 -0
  32. package/lib/esm/IpcApp.d.ts +1 -1
  33. package/lib/esm/IpcApp.d.ts.map +1 -1
  34. package/lib/esm/IpcApp.js.map +1 -1
  35. package/lib/esm/NativeApp.d.ts +2 -1
  36. package/lib/esm/NativeApp.d.ts.map +1 -1
  37. package/lib/esm/NativeApp.js +1 -0
  38. package/lib/esm/NativeApp.js.map +1 -1
  39. package/lib/esm/core-frontend.d.ts +1 -0
  40. package/lib/esm/core-frontend.d.ts.map +1 -1
  41. package/lib/esm/core-frontend.js +1 -0
  42. package/lib/esm/core-frontend.js.map +1 -1
  43. package/lib/esm/internal/render/webgl/SolarShadowMap.js +2 -2
  44. package/lib/esm/internal/render/webgl/SolarShadowMap.js.map +1 -1
  45. package/lib/esm/tile/map/CesiumTerrainProvider.d.ts +1 -1
  46. package/lib/esm/tile/map/CesiumTerrainProvider.d.ts.map +1 -1
  47. package/lib/esm/tile/map/CesiumTerrainProvider.js +3 -4
  48. package/lib/esm/tile/map/CesiumTerrainProvider.js.map +1 -1
  49. package/lib/public/scripts/parse-imdl-worker.js +1 -1
  50. package/lib/workers/webpack/parse-imdl-worker.js +1 -1
  51. package/package.json +16 -16
@@ -1 +1 @@
1
- {"version":3,"file":"core-frontend.js","sourceRoot":"","sources":["../../src/core-frontend.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAA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AIG;AACH;;;;GAIG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;;GAIG;AACH;;;;GAIG;AACH;;;;GAIG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;;GAIG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;;GAIG;AACH;;;GAGG;AACH;;;EAGE","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nexport * from \"./AccuDraw\";\nexport * from \"./AccuSnap\";\nexport * from \"./AuxCoordSys\";\nexport * from \"./BingLocation\";\nexport * from \"./BriefcaseConnection\";\nexport * from \"./BriefcaseTxns\";\nexport * from \"./CategorySelectorState\";\nexport * from \"./ChangeFlags\";\nexport * from \"./CheckpointConnection\";\nexport * from \"./common\";\nexport * from \"./ContextRealityModelState\";\nexport * from \"./CoordSystem\";\nexport * from \"./DecorationsCache\";\nexport * from \"./DevTools\";\nexport * from \"./DisplayStyleState\";\nexport * from \"./DrawingViewState\";\nexport * from \"./ElementLocateManager\";\nexport * from \"./EmphasizeElements\";\nexport * from \"./EntityState\";\nexport * from \"./EnvironmentDecorations\";\nexport * from \"./FeatureOverrideProvider\";\nexport * from \"./FlashSettings\";\nexport * from \"./FrontendHubAccess\";\nexport * from \"./Frustum2d\";\nexport * from \"./FrustumAnimator\";\nexport * from \"./FuzzySearch\";\nexport * from \"./GeoServices\";\nexport * from \"./GlobeAnimator\";\nexport * from \"./GraphicalEditingScope\";\nexport * from \"./HitDetail\";\nexport * from \"./IModelApp\";\nexport * from \"./IModelConnection\";\nexport * from \"./IModelRoutingContext\";\nexport * from \"./IpcApp\";\nexport * from \"./LinePlaneIntersect\";\nexport * from \"./MarginPercent\";\nexport * from \"./Marker\";\nexport * from \"./ModelSelectorState\";\nexport * from \"./ModelState\";\nexport * from \"./NativeApp\";\nexport * from \"./NativeAppLogger\";\nexport * from \"./NoRenderApp\";\nexport * from \"./NotificationManager\";\nexport * from \"./PerModelCategoryVisibility\";\nexport * from \"./PlanarClipMaskState\";\nexport * from \"./SelectionSet\";\nexport * from \"./SheetViewState\";\nexport * from \"./SpatialClassifiersState\";\nexport * from \"./SpatialViewState\";\nexport * from \"./Sprites\";\nexport * from \"./StandardView\";\nexport * from \"./SubCategoriesCache\";\nexport * from \"./TentativePoint\";\nexport * from \"./Tiles\";\nexport * from \"./UserPreferences\";\nexport * from \"./ViewAnimation\";\nexport * from \"./ViewContext\";\nexport * from \"./ViewGlobalLocation\";\nexport * from \"./ViewingSpace\";\nexport * from \"./ViewManager\";\nexport * from \"./Viewport\";\nexport * from \"./ViewportSync\";\nexport * from \"./ViewPose\";\nexport * from \"./ViewState\";\nexport * from \"./ViewStatus\";\nexport * from \"./extension/Extension\";\nexport * from \"./extension/providers/LocalExtensionProvider\";\nexport * from \"./extension/providers/RemoteExtensionProvider\";\nexport * from \"./properties/AngleDescription\";\nexport * from \"./properties/FormattedQuantityDescription\";\nexport * from \"./properties/LengthDescription\";\nexport * from \"./quantity-formatting/QuantityFormatter\";\nexport * from \"./quantity-formatting/BaseUnitFormattingSettingsProvider\";\nexport * from \"./quantity-formatting/LocalUnitFormatProvider\";\nexport * from \"./quantity-formatting/QuantityTypesEditorSpecs\";\nexport * from \"./render/CanvasDecoration\";\nexport * from \"./render/CreateRenderMaterialArgs\";\nexport * from \"./render/CreateTextureArgs\";\nexport * from \"./render/Decorations\";\nexport * from \"./render/FeatureSymbology\";\nexport * from \"./render/FrameStats\";\nexport * from \"./render/GraphicBranch\";\nexport * from \"./render/GraphicBuilder\";\nexport * from \"./render/GraphicTemplate\";\nexport * from \"./render/MeshArgs\";\nexport * from \"./render/ParticleCollectionBuilder\";\nexport * from \"./render/Pixel\";\nexport * from \"./render/PolylineArgs\";\nexport * from \"./render/RealityMeshParams\";\nexport * from \"./render/RenderClipVolume\";\nexport * from \"./render/RenderGraphic\";\nexport * from \"./render/RenderMemory\";\nexport * from \"./render/RenderSystem\";\nexport * from \"./render/RenderTarget\";\nexport * from \"./render/Scene\";\nexport * from \"./render/ScreenSpaceEffectBuilder\";\nexport * from \"./render/VisibleFeature\";\nexport * from \"./internal/render/webgl/IModelFrameLifecycle\";\nexport type {\n TxnEntityChange,\n TxnEntityChangeIterable,\n TxnEntityChangeType,\n TxnEntityChanges,\n TxnEntityChangesFilterOptions,\n TxnEntityMetadata,\n TxnEntityMetadataCriterion,\n} from \"./TxnEntityChanges\";\nexport {\n type TileTreeDiscloser, DisclosedTileTreeSet,\n type ReadGltfGraphicsArgs, type GltfGraphic, type GltfTemplate, readGltfGraphics, readGltfTemplate, readGltf,\n readElementGraphics,\n type BatchTableProperties, RealityTileTree,\n type RealityTileGeometry, RealityTile,\n type RenderGraphicTileTreeArgs,\n type GpuMemoryLimit, type GpuMemoryLimits, TileAdmin,\n type TileContent,\n type TiledGraphicsProvider,\n type TileDrawArgParams, TileDrawArgs,\n type CollectTileStatus, type TileGeometryCollectorOptions, TileGeometryCollector, type GeometryTileTreeReference,\n type TileParams,\n TileRequestChannels,\n type TileContentDecodingStatistics, TileRequestChannelStatistics, TileRequestChannel,\n TileRequest,\n type TileTreeOwner,\n type TileTreeParams,\n TileGraphicType, TileTreeReference,\n type TileTreeSupplier,\n TileTreeLoadStatus, TileTree,\n Tile, TileLoadStatus, TileVisibility, TileLoadPriority, TileBoundingBoxes,\n TileUsageMarker,\n TileUser,\n BingElevationProvider,\n QuadId,\n MapTilingScheme, GeographicTilingScheme, WebMercatorProjection, WebMercatorTilingScheme,\n type MapLayerIndex,\n MapTileProjection, MapTile,\n MapLayerTileTreeReference,\n MapLayerSourceStatus, type MapLayerSourceProps, MapLayerSource, MapLayerSources,\n MapLayerImageryProviderStatus, MapLayerImageryProvider,\n ImageryMapLayerFormat,\n MapLayerFormat, type ValidateSourceArgs, type MapLayerFormatType, type MapLayerSourceValidation, type MapLayerOptions, MapLayerFormatRegistry,\n type MapLayerTokenEndpoint, type MapLayerAuthenticationInfo, type MapLayerAccessToken, type MapLayerAccessTokenParams, type MapLayerAccessClient,\n type MapFeatureInfoOptions, MapFeatureInfoRecord, type MapFeatureInfo, type MapLayerFeatureInfo, type MapSubLayerFeatureInfo, type MapLayerFeature, type MapLayerFeatureGeometry, type MapLayerFeatureAttribute, MapLayerFeatureRecord,\n MapCartoRectangle,\n ImageryMapLayerTreeReference,\n EllipsoidTerrainProvider,\n getCesiumAssetUrl,\n MapTileTreeScaleRangeVisibility, MapTileTree,\n type TerrainMeshProviderOptions, type RequestMeshDataArgs, type ReadMeshArgs, TerrainMeshProvider,\n type TerrainProvider, TerrainProviderRegistry,\n} from \"./tile/internal\";\nexport * from \"./tools/AccuDrawTool\";\nexport * from \"./tools/AccuDrawViewportUI\";\nexport * from \"./tools/ClipViewTool\";\nexport * from \"./tools/EditManipulator\";\nexport * from \"./tools/ElementSetTool\";\nexport * from \"./tools/EventController\";\nexport * from \"./tools/IdleTool\";\nexport * from \"./tools/MeasureTool\";\nexport * from \"./tools/PrimitiveTool\";\nexport * from \"./tools/SelectTool\";\nexport * from \"./tools/Tool\";\nexport * from \"./tools/ToolSettings\";\nexport * from \"./tools/ToolAdmin\";\nexport * from \"./tools/ToolAssistance\";\nexport * from \"./tools/ViewTool\";\nexport * from \"./workers/RegisterWorker\";\nexport * from \"./BackgroundMapGeometry\";\nexport * from \"./ViewCreator2d\";\nexport * from \"./ViewCreator3d\";\nexport * from \"./LocalhostIpcApp\";\nexport * from \"./request/utils\";\nexport * from \"./RealityDataSource\";\n\nexport * from \"./internal/cross-package\";\n\n// TODO/FIX: \"./extension/ExtensionRuntime\" import has to be last to avoid circular dependency errors.\nimport \"./extension/ExtensionRuntime\";\n\n/** @docs-package-description\n * The core-frontend package always runs in a web browser. It contains classes for [querying iModels and showing views]($docs/learning/frontend/index.md).\n */\n\n/**\n * @docs-group-description IModelApp\n * Classes for configuring and administering an iTwin.js application.\n * See [the learning articles]($docs/learning/frontend/index.md).\n */\n/**\n * @docs-group-description IModelConnection\n * Classes for working with a connection to an [iModel briefcase]($docs/learning/IModels.md)\n */\n/**\n * @docs-group-description ElementState\n * Classes for working with the *state* of Elements in the frontend.\n * See [the learning articles]($docs/learning/frontend/index.md).\n */\n/**\n * @docs-group-description ModelState\n * Classes for working with the *state* of Models in the frontend.\n * See [the learning articles]($docs/learning/frontend/index.md).\n */\n/**\n * @docs-group-description Tools\n * Classes for [working with Tools]($docs/learning/frontend/Tools.md)\n */\n/**\n * @docs-group-description Measure\n * Classes for reporting point to point distances and mass properties of elements.\n */\n/**\n * @docs-group-description Views\n * Classes for [working with Views]($docs/learning/frontend/Views.md)\n */\n/**\n * @docs-group-description LocatingElements\n * Classes for locating and snapping to elements in views.\n * See [the learning articles]($docs/learning/frontend/index.md).\n */\n/**\n * @docs-group-description AccuDraw\n * AccuDraw provides helpful assistance for creating and modifying elements in a view.\n * See [the learning articles]($docs/learning/frontend/index.md).\n */\n/**\n * @docs-group-description Notifications\n * Notifications provide feedback to the user of something of interest.\n * See [the learning articles]($docs/learning/frontend/index.md).\n */\n/**\n * @docs-group-description Extensions\n * Classes for creating and managing Extensions.\n */\n/**\n * @docs-group-description Properties\n * Classes for working with property records and descriptions.\n */\n/**\n * @docs-group-description Rendering\n * Classes for rendering the contents of views.\n */\n/**\n * @docs-group-description SelectionSet\n * Classes for working with the set of selected elements.\n * See [the learning articles]($docs/learning/frontend/index.md).\n */\n/**\n * @docs-group-description NativeApp\n * Classes for working with Native Applications\n */\n/**\n * @docs-group-description Utils\n * Miscellaneous utility classes.\n */\n/**\n * @docs-group-description Logging\n * Logger categories used by this package\n */\n/**\n * @docs-group-description QuantityFormatting\n * Classes for formatting and parsing quantity values.\n */\n/**\n * @docs-group-description Tiles\n * Classes representing graphics as [hierarchical 3d tiles](https://github.com/CesiumGS/3d-tiles).\n */\n/**\n * @docs-group-description HubAccess\n * APIs for working with IModelHub\n */\n/**\n * @docs-group-description UserPreferences\n * APIs for working with user preferences in an iModelApp.\n * See [the learning articles]($docs/learning/frontend/preferences.md).\n */\n/**\n * @docs-group-description MapLayers\n * Classes supporting map layers display.\n */\n/**\n * @docs-group-description TileStorage\n * Class for working with cloud storage using iTwin/object-storage cloud providers\n*/\n"]}
1
+ {"version":3,"file":"core-frontend.js","sourceRoot":"","sources":["../../src/core-frontend.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;A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,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AAEpC,cAAc,0BAA0B,CAAC;AAEzC,sGAAsG;AACtG,OAAO,8BAA8B,CAAC;AAEtC;;GAEG;AAEH;;;;GAIG;AACH;;;GAGG;AACH;;;;GAIG;AACH;;;;GAIG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;;GAIG;AACH;;;;GAIG;AACH;;;;GAIG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;;GAIG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;;GAIG;AACH;;;GAGG;AACH;;;EAGE","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nexport * from \"./AccuDraw\";\nexport * from \"./AccuSnap\";\nexport * from \"./AuxCoordSys\";\nexport * from \"./BingLocation\";\nexport * from \"./BriefcaseConnection\";\nexport * from \"./BriefcaseTxns\";\nexport * from \"./CatalogConnection\";\nexport * from \"./CategorySelectorState\";\nexport * from \"./ChangeFlags\";\nexport * from \"./CheckpointConnection\";\nexport * from \"./common\";\nexport * from \"./ContextRealityModelState\";\nexport * from \"./CoordSystem\";\nexport * from \"./DecorationsCache\";\nexport * from \"./DevTools\";\nexport * from \"./DisplayStyleState\";\nexport * from \"./DrawingViewState\";\nexport * from \"./ElementLocateManager\";\nexport * from \"./EmphasizeElements\";\nexport * from \"./EntityState\";\nexport * from \"./EnvironmentDecorations\";\nexport * from \"./FeatureOverrideProvider\";\nexport * from \"./FlashSettings\";\nexport * from \"./FrontendHubAccess\";\nexport * from \"./Frustum2d\";\nexport * from \"./FrustumAnimator\";\nexport * from \"./FuzzySearch\";\nexport * from \"./GeoServices\";\nexport * from \"./GlobeAnimator\";\nexport * from \"./GraphicalEditingScope\";\nexport * from \"./HitDetail\";\nexport * from \"./IModelApp\";\nexport * from \"./IModelConnection\";\nexport * from \"./IModelRoutingContext\";\nexport * from \"./IpcApp\";\nexport * from \"./LinePlaneIntersect\";\nexport * from \"./MarginPercent\";\nexport * from \"./Marker\";\nexport * from \"./ModelSelectorState\";\nexport * from \"./ModelState\";\nexport * from \"./NativeApp\";\nexport * from \"./NativeAppLogger\";\nexport * from \"./NoRenderApp\";\nexport * from \"./NotificationManager\";\nexport * from \"./PerModelCategoryVisibility\";\nexport * from \"./PlanarClipMaskState\";\nexport * from \"./SelectionSet\";\nexport * from \"./SheetViewState\";\nexport * from \"./SpatialClassifiersState\";\nexport * from \"./SpatialViewState\";\nexport * from \"./Sprites\";\nexport * from \"./StandardView\";\nexport * from \"./SubCategoriesCache\";\nexport * from \"./TentativePoint\";\nexport * from \"./Tiles\";\nexport * from \"./UserPreferences\";\nexport * from \"./ViewAnimation\";\nexport * from \"./ViewContext\";\nexport * from \"./ViewGlobalLocation\";\nexport * from \"./ViewingSpace\";\nexport * from \"./ViewManager\";\nexport * from \"./Viewport\";\nexport * from \"./ViewportSync\";\nexport * from \"./ViewPose\";\nexport * from \"./ViewState\";\nexport * from \"./ViewStatus\";\nexport * from \"./extension/Extension\";\nexport * from \"./extension/providers/LocalExtensionProvider\";\nexport * from \"./extension/providers/RemoteExtensionProvider\";\nexport * from \"./properties/AngleDescription\";\nexport * from \"./properties/FormattedQuantityDescription\";\nexport * from \"./properties/LengthDescription\";\nexport * from \"./quantity-formatting/QuantityFormatter\";\nexport * from \"./quantity-formatting/BaseUnitFormattingSettingsProvider\";\nexport * from \"./quantity-formatting/LocalUnitFormatProvider\";\nexport * from \"./quantity-formatting/QuantityTypesEditorSpecs\";\nexport * from \"./render/CanvasDecoration\";\nexport * from \"./render/CreateRenderMaterialArgs\";\nexport * from \"./render/CreateTextureArgs\";\nexport * from \"./render/Decorations\";\nexport * from \"./render/FeatureSymbology\";\nexport * from \"./render/FrameStats\";\nexport * from \"./render/GraphicBranch\";\nexport * from \"./render/GraphicBuilder\";\nexport * from \"./render/GraphicTemplate\";\nexport * from \"./render/MeshArgs\";\nexport * from \"./render/ParticleCollectionBuilder\";\nexport * from \"./render/Pixel\";\nexport * from \"./render/PolylineArgs\";\nexport * from \"./render/RealityMeshParams\";\nexport * from \"./render/RenderClipVolume\";\nexport * from \"./render/RenderGraphic\";\nexport * from \"./render/RenderMemory\";\nexport * from \"./render/RenderSystem\";\nexport * from \"./render/RenderTarget\";\nexport * from \"./render/Scene\";\nexport * from \"./render/ScreenSpaceEffectBuilder\";\nexport * from \"./render/VisibleFeature\";\nexport * from \"./internal/render/webgl/IModelFrameLifecycle\";\nexport type {\n TxnEntityChange,\n TxnEntityChangeIterable,\n TxnEntityChangeType,\n TxnEntityChanges,\n TxnEntityChangesFilterOptions,\n TxnEntityMetadata,\n TxnEntityMetadataCriterion,\n} from \"./TxnEntityChanges\";\nexport {\n type TileTreeDiscloser, DisclosedTileTreeSet,\n type ReadGltfGraphicsArgs, type GltfGraphic, type GltfTemplate, readGltfGraphics, readGltfTemplate, readGltf,\n readElementGraphics,\n type BatchTableProperties, RealityTileTree,\n type RealityTileGeometry, RealityTile,\n type RenderGraphicTileTreeArgs,\n type GpuMemoryLimit, type GpuMemoryLimits, TileAdmin,\n type TileContent,\n type TiledGraphicsProvider,\n type TileDrawArgParams, TileDrawArgs,\n type CollectTileStatus, type TileGeometryCollectorOptions, TileGeometryCollector, type GeometryTileTreeReference,\n type TileParams,\n TileRequestChannels,\n type TileContentDecodingStatistics, TileRequestChannelStatistics, TileRequestChannel,\n TileRequest,\n type TileTreeOwner,\n type TileTreeParams,\n TileGraphicType, TileTreeReference,\n type TileTreeSupplier,\n TileTreeLoadStatus, TileTree,\n Tile, TileLoadStatus, TileVisibility, TileLoadPriority, TileBoundingBoxes,\n TileUsageMarker,\n TileUser,\n BingElevationProvider,\n QuadId,\n MapTilingScheme, GeographicTilingScheme, WebMercatorProjection, WebMercatorTilingScheme,\n type MapLayerIndex,\n MapTileProjection, MapTile,\n MapLayerTileTreeReference,\n MapLayerSourceStatus, type MapLayerSourceProps, MapLayerSource, MapLayerSources,\n MapLayerImageryProviderStatus, MapLayerImageryProvider,\n ImageryMapLayerFormat,\n MapLayerFormat, type ValidateSourceArgs, type MapLayerFormatType, type MapLayerSourceValidation, type MapLayerOptions, MapLayerFormatRegistry,\n type MapLayerTokenEndpoint, type MapLayerAuthenticationInfo, type MapLayerAccessToken, type MapLayerAccessTokenParams, type MapLayerAccessClient,\n type MapFeatureInfoOptions, MapFeatureInfoRecord, type MapFeatureInfo, type MapLayerFeatureInfo, type MapSubLayerFeatureInfo, type MapLayerFeature, type MapLayerFeatureGeometry, type MapLayerFeatureAttribute, MapLayerFeatureRecord,\n MapCartoRectangle,\n ImageryMapLayerTreeReference,\n EllipsoidTerrainProvider,\n getCesiumAssetUrl,\n MapTileTreeScaleRangeVisibility, MapTileTree,\n type TerrainMeshProviderOptions, type RequestMeshDataArgs, type ReadMeshArgs, TerrainMeshProvider,\n type TerrainProvider, TerrainProviderRegistry,\n} from \"./tile/internal\";\nexport * from \"./tools/AccuDrawTool\";\nexport * from \"./tools/AccuDrawViewportUI\";\nexport * from \"./tools/ClipViewTool\";\nexport * from \"./tools/EditManipulator\";\nexport * from \"./tools/ElementSetTool\";\nexport * from \"./tools/EventController\";\nexport * from \"./tools/IdleTool\";\nexport * from \"./tools/MeasureTool\";\nexport * from \"./tools/PrimitiveTool\";\nexport * from \"./tools/SelectTool\";\nexport * from \"./tools/Tool\";\nexport * from \"./tools/ToolSettings\";\nexport * from \"./tools/ToolAdmin\";\nexport * from \"./tools/ToolAssistance\";\nexport * from \"./tools/ViewTool\";\nexport * from \"./workers/RegisterWorker\";\nexport * from \"./BackgroundMapGeometry\";\nexport * from \"./ViewCreator2d\";\nexport * from \"./ViewCreator3d\";\nexport * from \"./LocalhostIpcApp\";\nexport * from \"./request/utils\";\nexport * from \"./RealityDataSource\";\n\nexport * from \"./internal/cross-package\";\n\n// TODO/FIX: \"./extension/ExtensionRuntime\" import has to be last to avoid circular dependency errors.\nimport \"./extension/ExtensionRuntime\";\n\n/** @docs-package-description\n * The core-frontend package always runs in a web browser. It contains classes for [querying iModels and showing views]($docs/learning/frontend/index.md).\n */\n\n/**\n * @docs-group-description IModelApp\n * Classes for configuring and administering an iTwin.js application.\n * See [the learning articles]($docs/learning/frontend/index.md).\n */\n/**\n * @docs-group-description IModelConnection\n * Classes for working with a connection to an [iModel briefcase]($docs/learning/IModels.md)\n */\n/**\n * @docs-group-description ElementState\n * Classes for working with the *state* of Elements in the frontend.\n * See [the learning articles]($docs/learning/frontend/index.md).\n */\n/**\n * @docs-group-description ModelState\n * Classes for working with the *state* of Models in the frontend.\n * See [the learning articles]($docs/learning/frontend/index.md).\n */\n/**\n * @docs-group-description Tools\n * Classes for [working with Tools]($docs/learning/frontend/Tools.md)\n */\n/**\n * @docs-group-description Measure\n * Classes for reporting point to point distances and mass properties of elements.\n */\n/**\n * @docs-group-description Views\n * Classes for [working with Views]($docs/learning/frontend/Views.md)\n */\n/**\n * @docs-group-description LocatingElements\n * Classes for locating and snapping to elements in views.\n * See [the learning articles]($docs/learning/frontend/index.md).\n */\n/**\n * @docs-group-description AccuDraw\n * AccuDraw provides helpful assistance for creating and modifying elements in a view.\n * See [the learning articles]($docs/learning/frontend/index.md).\n */\n/**\n * @docs-group-description Notifications\n * Notifications provide feedback to the user of something of interest.\n * See [the learning articles]($docs/learning/frontend/index.md).\n */\n/**\n * @docs-group-description Extensions\n * Classes for creating and managing Extensions.\n */\n/**\n * @docs-group-description Properties\n * Classes for working with property records and descriptions.\n */\n/**\n * @docs-group-description Rendering\n * Classes for rendering the contents of views.\n */\n/**\n * @docs-group-description SelectionSet\n * Classes for working with the set of selected elements.\n * See [the learning articles]($docs/learning/frontend/index.md).\n */\n/**\n * @docs-group-description NativeApp\n * Classes for working with Native Applications\n */\n/**\n * @docs-group-description Utils\n * Miscellaneous utility classes.\n */\n/**\n * @docs-group-description Logging\n * Logger categories used by this package\n */\n/**\n * @docs-group-description QuantityFormatting\n * Classes for formatting and parsing quantity values.\n */\n/**\n * @docs-group-description Tiles\n * Classes representing graphics as [hierarchical 3d tiles](https://github.com/CesiumGS/3d-tiles).\n */\n/**\n * @docs-group-description HubAccess\n * APIs for working with IModelHub\n */\n/**\n * @docs-group-description UserPreferences\n * APIs for working with user preferences in an iModelApp.\n * See [the learning articles]($docs/learning/frontend/preferences.md).\n */\n/**\n * @docs-group-description MapLayers\n * Classes supporting map layers display.\n */\n/**\n * @docs-group-description TileStorage\n * Class for working with cloud storage using iTwin/object-storage cloud providers\n*/\n"]}
@@ -317,13 +317,13 @@ export class SolarShadowMap {
317
317
  scratchFrustumPlanes.init(this._shadowFrustum);
318
318
  for (const ref of view.getTileTreeRefs()) {
319
319
  if (!ref.castsShadows)
320
- return;
320
+ continue;
321
321
  const drawArgs = createDrawArgs(context, this, ref, scratchFrustumPlanes, (tiles) => {
322
322
  for (const tile of tiles)
323
323
  tileRange.extendRange(tileToMapTransform.multiplyRange(tile.range, this._scratchRange));
324
324
  });
325
325
  if (undefined === drawArgs)
326
- return;
326
+ continue;
327
327
  const tileToMapTransform = worldToMapTransform.multiplyTransformTransform(drawArgs.location, this._scratchTransform);
328
328
  drawArgs.tree.draw(drawArgs);
329
329
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SolarShadowMap.js","sourceRoot":"","sources":["../../../../../src/internal/render/webgl/SolarShadowMap.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,QAAQ,EAAoB,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACvK,OAAO,EACL,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAuB,mBAAmB,EAAE,SAAS,GACvG,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAQ,YAAY,EAAqB,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAK/F,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAc,WAAW,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAInD,SAAS,cAAc,CAAC,YAA0B,EAAE,cAA8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ourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module WebGL\n */\n\nimport { assert, dispose } from \"@itwin/core-bentley\";\nimport { ClipUtilities, ConvexClipPlaneSet, Geometry, GrowableXYZArray, Map4d, Matrix3d, Matrix4d, Point3d, Range3d, Transform, Vector3d } from \"@itwin/core-geometry\";\nimport {\n Frustum, FrustumPlanes, RenderMode, RenderTexture, SolarShadowSettings, TextureTransparency, ViewFlags,\n} from \"@itwin/core-common\";\nimport { RenderType } from \"@itwin/webgl-compatibility\";\nimport { Tile, TileDrawArgs, TileTreeReference, TileVisibility } from \"../../../tile/internal\";\nimport { SceneContext } from \"../../../ViewContext\";\nimport { RenderGraphic } from \"../../../render/RenderGraphic\";\nimport { RenderMemory } from \"../../../render/RenderMemory\";\nimport { BranchStack } from \"./BranchStack\";\nimport { BatchState } from \"./BatchState\";\nimport { EVSMGeometry } from \"./CachedGeometry\";\nimport { WebGLDisposable } from \"./Disposable\";\nimport { FrameBuffer } from \"./FrameBuffer\";\nimport { GL } from \"./GL\";\nimport { RenderCommands } from \"./RenderCommands\";\nimport { RenderPass, TextureUnit } from \"./RenderFlags\";\nimport { RenderState } from \"./RenderState\";\nimport { getDrawParams } from \"./ScratchDrawParams\";\nimport { System } from \"./System\";\nimport { Target } from \"./Target\";\nimport { Texture, TextureHandle } from \"./Texture\";\n\ntype ProcessTiles = (tiles: Tile[]) => void;\n\nfunction createDrawArgs(sceneContext: SceneContext, solarShadowMap: SolarShadowMap, tree: TileTreeReference, frustumPlanes: FrustumPlanes, processTiles: ProcessTiles): TileDrawArgs | undefined {\n class SolarShadowMapDrawArgs extends TileDrawArgs {\n private _useViewportMap?: boolean;\n private readonly _processTiles: ProcessTiles;\n\n constructor(private _mapFrustumPlanes: FrustumPlanes, private _shadowMap: SolarShadowMap, args: TileDrawArgs, process: ProcessTiles) {\n super(args);\n this._processTiles = process;\n }\n\n // The solar shadow projection is parallel - which can cause excessive tile selection if it is along an axis of an unbounded tile\n // tree such as the OSM buildings. Rev limit the selection here.\n public override get maxRealityTreeSelectionCount(): undefined | number { return 500; }\n\n public override processSelectedTiles(tiles: Tile[]): void {\n this._processTiles(tiles);\n }\n\n public override get frustumPlanes(): FrustumPlanes {\n if (true === this._useViewportMap)\n return super.frustumPlanes;\n else\n return this._mapFrustumPlanes;\n }\n\n public override get worldToViewMap(): Map4d {\n if (true === this._useViewportMap)\n return super.worldToViewMap;\n else\n return this._shadowMap.worldToViewMap;\n }\n\n public override drawGraphics(): void {\n const graphics = this.produceGraphics();\n if (graphics)\n this._shadowMap.addGraphic(graphics);\n }\n\n public override getPixelSize(tile: Tile): number {\n // For tiles that are part of the scene, size them based on the viewport frustum so that shadow map uses same resolution tiles as scene\n // - otherwise artifacts like shadow acne may result.\n // For tiles that are NOT part of the scene, size them based on the shadow frustum, not the viewport frustum\n // - otherwise excessive numbers of excessively detailed may be requested for the shadow map.\n if (undefined === this._useViewportMap) {\n this._useViewportMap = true;\n const vis = tile.computeVisibility(this);\n this._useViewportMap = TileVisibility.OutsideFrustum !== vis;\n }\n\n const size = super.getPixelSize(tile);\n this._useViewportMap = undefined;\n return size;\n }\n\n public static create(context: SceneContext, shadowMap: SolarShadowMap, tileTree: TileTreeReference, planes: FrustumPlanes, process: ProcessTiles) {\n const args = tileTree.createDrawArgs(context);\n return undefined !== args ? new SolarShadowMapDrawArgs(planes, shadowMap, args, process) : undefined;\n }\n }\n\n return SolarShadowMapDrawArgs.create(sceneContext, solarShadowMap, tree, frustumPlanes, processTiles);\n}\n\nconst shadowMapWidth = 4096; // size of original depth buffer map\nconst shadowMapHeight = shadowMapWidth; // TBD - Adjust for aspect ratio.\nconst evsmWidth = shadowMapWidth / 2; // EVSM buffer is 1/2 size each direction\nconst evsmHeight = shadowMapHeight / 2;\nconst postProjectionMatrixNpc = Matrix4d.createRowValues(/* Row 1 */ 0, 1, 0, 0, /* Row 2 */ 0, 0, 1, 0, /* Row 3 */ 1, 0, 0, 0, /* Row 4 */ 0, 0, 0, 1);\n\n// Bundles up the disposable, create-once-and-reuse members of a SolarShadowMap.\nclass Bundle implements WebGLDisposable {\n private constructor(\n public readonly depthTexture: Texture,\n public readonly shadowMapTexture: Texture,\n public readonly fbo: FrameBuffer,\n public readonly fboSM: FrameBuffer,\n public readonly evsmGeom: EVSMGeometry,\n public readonly renderCommands: RenderCommands) {\n }\n\n public static create(target: Target, stack: BranchStack, batch: BatchState): Bundle | undefined {\n const depthTextureHandle = System.instance.createDepthBuffer(shadowMapWidth, shadowMapHeight) as TextureHandle;\n if (undefined === depthTextureHandle)\n return undefined;\n\n let pixelDataType = GL.Texture.DataType.Float;\n switch (System.instance.maxRenderType) {\n case RenderType.TextureFloat:\n break;\n case RenderType.TextureHalfFloat:\n pixelDataType = System.instance.context.HALF_FLOAT;\n break;\n /* falls through */\n default:\n return undefined;\n }\n\n const colorTextures: TextureHandle[] = [];\n\n const fbo = FrameBuffer.create(colorTextures, depthTextureHandle);\n if (undefined === fbo)\n return undefined;\n\n // shadowMap texture is 1/4 size the depth texture (and averaged down when converting)\n const shadowMapTextureHandle = TextureHandle.createForAttachment(evsmWidth, evsmHeight, GL.Texture.Format.Rgba, pixelDataType);\n if (undefined === shadowMapTextureHandle)\n return undefined;\n\n const fboSM = FrameBuffer.create([shadowMapTextureHandle]);\n if (undefined === fboSM)\n return undefined;\n\n const depthTexture = new Texture({ ownership: \"external\", type: RenderTexture.Type.TileSection, handle: depthTextureHandle, transparency: TextureTransparency.Opaque });\n const evsmGeom = EVSMGeometry.createGeometry(depthTexture.texture.getHandle()!, shadowMapWidth, shadowMapHeight);\n if (undefined === evsmGeom)\n return undefined;\n\n const shadowMapTexture = new Texture({ type: RenderTexture.Type.Normal, ownership: \"external\", handle: shadowMapTextureHandle, transparency: TextureTransparency.Opaque });\n const renderCommands = new RenderCommands(target, stack, batch);\n return new Bundle(depthTexture, shadowMapTexture, fbo, fboSM, evsmGeom, renderCommands);\n }\n\n public get isDisposed(): boolean {\n return this.depthTexture.isDisposed\n && this.shadowMapTexture.isDisposed\n && this.fbo.isDisposed\n && this.fboSM.isDisposed\n && this.evsmGeom.isDisposed;\n }\n\n public [Symbol.dispose](): void {\n dispose(this.depthTexture);\n dispose(this.shadowMapTexture);\n dispose(this.fbo);\n dispose(this.fboSM);\n dispose(this.evsmGeom);\n }\n}\n\n/** Describes the set of parameters which, when they change, require us to recreate the shadow map. */\nclass ShadowMapParams {\n public readonly direction = new Vector3d();\n public readonly viewFrustum = new Frustum();\n public settings: SolarShadowSettings;\n\n public constructor(viewFrustum: Frustum, direction: Vector3d, settings: SolarShadowSettings) {\n direction.clone(this.direction);\n this.viewFrustum.setFrom(viewFrustum);\n this.settings = settings;\n }\n\n public update(viewFrustum: Frustum, direction: Vector3d, settings: SolarShadowSettings): void {\n this.settings = settings;\n this.viewFrustum.setFrom(viewFrustum);\n direction.clone(this.direction);\n }\n}\n\nconst defaultSunDirection = Vector3d.create(-1, -1, -1).normalize()!;\nconst scratchFrustum = new Frustum();\nconst scratchFrustumPlanes = FrustumPlanes.createEmpty();\n\nexport class SolarShadowMap implements RenderMemory.Consumer, WebGLDisposable {\n private _bundle?: Bundle;\n private _projectionMatrix = Matrix4d.createIdentity();\n private _graphics: RenderGraphic[] = [];\n private _shadowFrustum = new Frustum();\n private _isReady = false;\n private _isDrawing = false;\n private _enabled = false;\n private _params?: ShadowMapParams;\n private readonly _scratchRange = Range3d.createNull();\n private readonly _scratchTransform = Transform.createIdentity();\n\n private readonly _scratchViewFlags = new ViewFlags();\n private readonly _renderState: RenderState;\n private readonly _noZRenderState: RenderState;\n private readonly _batchState: BatchState;\n private _worldToViewMap = Map4d.createIdentity();\n private readonly _target: Target;\n\n // This exists chiefly for debugging. See ToggleShadowMapTilesTool.\n public onGraphicsChanged?: (graphics: RenderGraphic[]) => void;\n\n private getBundle(target: Target): Bundle | undefined {\n if (undefined === this._bundle) {\n this._bundle = Bundle.create(target, target.uniforms.branch.stack, this._batchState);\n assert(undefined !== this._bundle);\n }\n\n return this._bundle;\n }\n\n public get isReady() { return this._isReady; }\n public get isDrawing() { return this._isDrawing; }\n public get isEnabled() { return this._enabled; }\n public get projectionMatrix(): Matrix4d { return this._projectionMatrix; }\n public get depthTexture(): Texture | undefined { return undefined !== this._bundle ? this._bundle.depthTexture : undefined; }\n public get shadowMapTexture(): Texture | undefined { return undefined !== this._bundle ? this._bundle.shadowMapTexture : undefined; }\n public get settings(): SolarShadowSettings | undefined { return undefined !== this._params ? this._params.settings : undefined; }\n public get direction(): Vector3d | undefined { return undefined !== this._params ? this._params.direction : undefined; }\n public get frustum(): Frustum { return this._shadowFrustum; }\n public get worldToViewMap(): Map4d { return this._worldToViewMap; }\n public addGraphic(graphic: RenderGraphic) { this._graphics.push(graphic); }\n\n public constructor(target: Target) {\n this._target = target;\n this._renderState = new RenderState();\n this._renderState.flags.depthMask = true;\n this._renderState.flags.blend = false;\n this._renderState.flags.depthTest = true;\n\n this._noZRenderState = new RenderState();\n this._noZRenderState.flags.depthMask = false;\n\n this._batchState = new BatchState(target.uniforms.branch.stack);\n }\n\n public disable() {\n this._enabled = this._isReady = false;\n this._bundle = dispose(this._bundle);\n this.clearGraphics(true);\n this._target.uniforms.shadow.update();\n }\n\n public collectStatistics(stats: RenderMemory.Statistics): void {\n const bundle = this._bundle;\n if (undefined !== bundle)\n stats.addShadowMap(bundle.depthTexture.bytesUsed + bundle.shadowMapTexture.bytesUsed);\n }\n\n public get isDisposed(): boolean { return undefined === this._bundle && 0 === this._graphics.length; }\n\n public [Symbol.dispose]() {\n this._bundle = dispose(this._bundle);\n this.clearGraphics(true);\n }\n\n private clearGraphics(notify: boolean) {\n for (const graphic of this._graphics)\n graphic[Symbol.dispose]();\n\n this._graphics.length = 0;\n if (notify)\n this.notifyGraphicsChanged();\n }\n\n private notifyGraphicsChanged(): void {\n if (undefined !== this.onGraphicsChanged)\n this.onGraphicsChanged(this._graphics);\n }\n\n public update(context: SceneContext | undefined) {\n this._isReady = false;\n this.clearGraphics(false);\n\n if (undefined === context || !context.viewport.view.isSpatialView()) {\n this.disable();\n this.notifyGraphicsChanged();\n return;\n }\n\n const view = context.viewport.view;\n const style = view.getDisplayStyle3d();\n const sunDirection = style.sunDirection ?? defaultSunDirection;\n\n const minimumHorizonDirection = -.01;\n if (sunDirection.z > minimumHorizonDirection) {\n this.notifyGraphicsChanged();\n return;\n }\n\n this._enabled = true;\n const viewFrustum = context.viewingSpace.getFrustum();\n const settings = style.settings.solarShadows;\n if (undefined === this._params)\n this._params = new ShadowMapParams(viewFrustum, sunDirection, settings);\n else\n this._params.update(viewFrustum, sunDirection, settings);\n\n const iModel = view.iModel;\n\n const worldToMapTransform = Transform.createRefs(Point3d.createZero(), Matrix3d.createRigidHeadsUp(this._params.direction.negate()).inverse()!);\n const worldToMap = Matrix4d.createTransform(worldToMapTransform);\n const mapToWorld = worldToMap.createInverse()!;\n\n // Start with entire project.\n const shadowRange = worldToMapTransform.multiplyRange(iModel.projectExtents);\n\n // Limit the map to only displayed models.\n const viewTileRange = Range3d.createNull();\n for (const ref of view.getTileTreeRefs()) {\n if (ref.castsShadows) {\n if (ref.isGlobal) {\n // A shadow-casting tile tree that spans the globe. Limit its range to the viewed extents.\n for (const p3 of viewFrustum.points) {\n const p4 = worldToMap.multiplyPoint3d(p3, 1);\n if (p4.w > 0.0001)\n viewTileRange.extendXYZW(p4.x, p4.y, p4.z, p4.w);\n else\n viewTileRange.high.z = Math.max(1.0, viewTileRange.high.z); // behind eye plane.\n }\n } else {\n ref.accumulateTransformedRange(viewTileRange, worldToMap, undefined);\n }\n }\n }\n\n if (!viewTileRange.isNull)\n viewTileRange.clone(shadowRange);\n\n // Expand shadow range to include both the shadowers and shadowed portion of background map.\n scratchFrustum.initFromRange(shadowRange);\n mapToWorld.multiplyPoint3dArrayQuietNormalize(scratchFrustum.points); // This frustum represents the shadowing geometry. Intersect it with background geometry and expand the range depth to include that intersection.\n const backgroundMapGeometry = context.viewport.view.displayStyle.getBackgroundMapGeometry();\n if (undefined !== backgroundMapGeometry) {\n const backgroundDepthRange = backgroundMapGeometry.getFrustumIntersectionDepthRange(this._shadowFrustum, iModel.projectExtents);\n if (!backgroundDepthRange.isNull)\n shadowRange.low.z = Math.min(shadowRange.low.z, backgroundDepthRange.low);\n }\n\n this._params.viewFrustum.transformBy(worldToMapTransform, scratchFrustum);\n scratchFrustumPlanes.init(scratchFrustum);\n\n const viewIntersectShadowRange = Range3d.createNull();\n const viewClipPlanes = ConvexClipPlaneSet.createPlanes(scratchFrustumPlanes.planes);\n ClipUtilities.announceLoopsOfConvexClipPlaneSetIntersectRange(viewClipPlanes, shadowRange, (points: GrowableXYZArray) => {\n for (const point of points.getPoint3dArray())\n viewIntersectShadowRange.extendPoint(point);\n });\n if (viewIntersectShadowRange.isNull) {\n this.notifyGraphicsChanged();\n return;\n }\n viewIntersectShadowRange.high.z = shadowRange.high.z; // We need to include shadowing geometry that may be outside view (along the solar axis).\n\n this._shadowFrustum.initFromRange(viewIntersectShadowRange);\n mapToWorld.multiplyPoint3dArrayQuietNormalize(this._shadowFrustum.points);\n\n const tileRange = Range3d.createNull();\n scratchFrustumPlanes.init(this._shadowFrustum);\n for (const ref of view.getTileTreeRefs()) {\n if (!ref.castsShadows)\n return;\n\n const drawArgs = createDrawArgs(context, this, ref, scratchFrustumPlanes, (tiles: Tile[]) => {\n for (const tile of tiles)\n tileRange.extendRange(tileToMapTransform.multiplyRange(tile.range, this._scratchRange));\n });\n\n if (undefined === drawArgs)\n return;\n\n const tileToMapTransform = worldToMapTransform.multiplyTransformTransform(drawArgs.location, this._scratchTransform);\n drawArgs.tree.draw(drawArgs);\n }\n\n if (tileRange.isNull) {\n this.clearGraphics(true);\n } else if (this._graphics.length > 0) {\n // Avoid an uninvertible matrix on empty range...\n if (Geometry.isAlmostEqualNumber(shadowRange.low.x, shadowRange.high.x) ||\n Geometry.isAlmostEqualNumber(shadowRange.low.y, shadowRange.high.y) ||\n Geometry.isAlmostEqualNumber(shadowRange.low.z, shadowRange.high.z)) {\n this.clearGraphics(true);\n return;\n }\n\n const frustumMap = this._shadowFrustum.toMap4d();\n if (undefined === frustumMap) {\n this.clearGraphics(true);\n assert(false);\n return;\n }\n\n this._projectionMatrix = frustumMap.transform0.clone();\n\n const worldToNpc = postProjectionMatrixNpc.multiplyMatrixMatrix(this._projectionMatrix);\n const npcToView = Map4d.createBoxMap(Point3d.create(0, 0, 0), Point3d.create(1, 1, 1), Point3d.create(0, 0, 0), Point3d.create(shadowMapWidth, shadowMapHeight, 1))!;\n const npcToWorld = worldToNpc.createInverse();\n if (undefined === npcToWorld) {\n this.clearGraphics(true);\n return;\n }\n\n const worldToNpcMap = Map4d.createRefs(worldToNpc, npcToWorld);\n this._worldToViewMap = npcToView.multiplyMapMap(worldToNpcMap);\n }\n\n this._target.uniforms.shadow.update();\n this.notifyGraphicsChanged();\n }\n\n public draw(target: Target) {\n assert(this.isEnabled);\n\n if (this.isReady || 0 === this._graphics.length)\n return;\n\n const bundle = this.getBundle(target);\n if (undefined === bundle)\n return;\n\n this._isDrawing = true;\n\n const prevState = System.instance.currentRenderState.clone();\n const gl = System.instance.context;\n gl.viewport(0, 0, shadowMapWidth, shadowMapHeight);\n\n // NB: textures and materials are needed because their transparencies affect whether or not a surface casts shadows\n const viewFlags = target.currentViewFlags.copy({\n renderMode: RenderMode.SmoothShade,\n wiremesh: false,\n transparency: false,\n lighting: false,\n shadows: false,\n monochrome: false,\n ambientOcclusion: false,\n visibleEdges: false,\n hiddenEdges: false,\n });\n\n System.instance.applyRenderState(this._renderState);\n const prevPlan = target.plan;\n\n target.changeFrustum(this._shadowFrustum, this._shadowFrustum.getFraction(), true);\n target.uniforms.branch.changeRenderPlan(viewFlags, target.plan.is3d, target.plan.hline);\n\n const renderCommands = bundle.renderCommands;\n renderCommands.reset(target, target.uniforms.branch.stack, this._batchState);\n renderCommands.addGraphics(this._graphics);\n\n System.instance.frameBufferStack.execute(bundle.fbo, true, false, () => {\n System.instance.context.clearDepth(1.0);\n System.instance.context.clear(GL.BufferBit.Depth);\n target.techniques.execute(target, renderCommands.getCommands(RenderPass.OpaquePlanar), RenderPass.PlanarClassification); // Draw these with RenderPass.PlanarClassification (rather than Opaque...) so that the pick ordering is avoided.\n target.techniques.execute(target, renderCommands.getCommands(RenderPass.OpaqueGeneral), RenderPass.PlanarClassification); // Draw these with RenderPass.PlanarClassification (rather than Opaque...) so that the pick ordering is avoided.\n });\n\n // copy depth buffer to EVSM shadow buffer and average down for AA effect\n gl.viewport(0, 0, evsmWidth, evsmHeight);\n System.instance.frameBufferStack.execute(bundle.fboSM, true, false, () => {\n System.instance.applyRenderState(this._noZRenderState);\n const params = getDrawParams(target, bundle.evsmGeom);\n target.techniques.draw(params);\n });\n\n // mipmap resulting EVSM texture and set filtering options\n System.instance.activateTexture2d(TextureUnit.ShadowMap, bundle.shadowMapTexture.texture.getHandle());\n gl.generateMipmap(gl.TEXTURE_2D);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n\n System.instance.setMaxAnisotropy(undefined);\n // target.recordPerformanceMetric(\"Compute EVSM\");\n\n this._batchState.reset(); // Reset the batch Ids...\n target.changeRenderPlan(prevPlan);\n\n System.instance.applyRenderState(prevState);\n System.instance.context.viewport(0, 0, target.viewRect.width, target.viewRect.height); // Restore viewport\n this.clearGraphics(false);\n this._isDrawing = false;\n this._isReady = true;\n }\n}\n"]}
1
+ {"version":3,"file":"SolarShadowMap.js","sourceRoot":"","sources":["../../../../../src/internal/render/webgl/SolarShadowMap.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EA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MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;QACtG,EAAE,CAAC,cAAc,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;QACjC,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,kBAAkB,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC;QAChF,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,kBAAkB,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;QAElE,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAC5C,kDAAkD;QAElD,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAG,yBAAyB;QACrD,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAElC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAC5C,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,mBAAmB;QAC1G,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module WebGL\n */\n\nimport { assert, dispose } from \"@itwin/core-bentley\";\nimport { ClipUtilities, ConvexClipPlaneSet, Geometry, GrowableXYZArray, Map4d, Matrix3d, Matrix4d, Point3d, Range3d, Transform, Vector3d } from \"@itwin/core-geometry\";\nimport {\n Frustum, FrustumPlanes, RenderMode, RenderTexture, SolarShadowSettings, TextureTransparency, ViewFlags,\n} from \"@itwin/core-common\";\nimport { RenderType } from \"@itwin/webgl-compatibility\";\nimport { Tile, TileDrawArgs, TileTreeReference, TileVisibility } from \"../../../tile/internal\";\nimport { SceneContext } from \"../../../ViewContext\";\nimport { RenderGraphic } from \"../../../render/RenderGraphic\";\nimport { RenderMemory } from \"../../../render/RenderMemory\";\nimport { BranchStack } from \"./BranchStack\";\nimport { BatchState } from \"./BatchState\";\nimport { EVSMGeometry } from \"./CachedGeometry\";\nimport { WebGLDisposable } from \"./Disposable\";\nimport { FrameBuffer } from \"./FrameBuffer\";\nimport { GL } from \"./GL\";\nimport { RenderCommands } from \"./RenderCommands\";\nimport { RenderPass, TextureUnit } from \"./RenderFlags\";\nimport { RenderState } from \"./RenderState\";\nimport { getDrawParams } from \"./ScratchDrawParams\";\nimport { System } from \"./System\";\nimport { Target } from \"./Target\";\nimport { Texture, TextureHandle } from \"./Texture\";\n\ntype ProcessTiles = (tiles: Tile[]) => void;\n\nfunction createDrawArgs(sceneContext: SceneContext, solarShadowMap: SolarShadowMap, tree: TileTreeReference, frustumPlanes: FrustumPlanes, processTiles: ProcessTiles): TileDrawArgs | undefined {\n class SolarShadowMapDrawArgs extends TileDrawArgs {\n private _useViewportMap?: boolean;\n private readonly _processTiles: ProcessTiles;\n\n constructor(private _mapFrustumPlanes: FrustumPlanes, private _shadowMap: SolarShadowMap, args: TileDrawArgs, process: ProcessTiles) {\n super(args);\n this._processTiles = process;\n }\n\n // The solar shadow projection is parallel - which can cause excessive tile selection if it is along an axis of an unbounded tile\n // tree such as the OSM buildings. Rev limit the selection here.\n public override get maxRealityTreeSelectionCount(): undefined | number { return 500; }\n\n public override processSelectedTiles(tiles: Tile[]): void {\n this._processTiles(tiles);\n }\n\n public override get frustumPlanes(): FrustumPlanes {\n if (true === this._useViewportMap)\n return super.frustumPlanes;\n else\n return this._mapFrustumPlanes;\n }\n\n public override get worldToViewMap(): Map4d {\n if (true === this._useViewportMap)\n return super.worldToViewMap;\n else\n return this._shadowMap.worldToViewMap;\n }\n\n public override drawGraphics(): void {\n const graphics = this.produceGraphics();\n if (graphics)\n this._shadowMap.addGraphic(graphics);\n }\n\n public override getPixelSize(tile: Tile): number {\n // For tiles that are part of the scene, size them based on the viewport frustum so that shadow map uses same resolution tiles as scene\n // - otherwise artifacts like shadow acne may result.\n // For tiles that are NOT part of the scene, size them based on the shadow frustum, not the viewport frustum\n // - otherwise excessive numbers of excessively detailed may be requested for the shadow map.\n if (undefined === this._useViewportMap) {\n this._useViewportMap = true;\n const vis = tile.computeVisibility(this);\n this._useViewportMap = TileVisibility.OutsideFrustum !== vis;\n }\n\n const size = super.getPixelSize(tile);\n this._useViewportMap = undefined;\n return size;\n }\n\n public static create(context: SceneContext, shadowMap: SolarShadowMap, tileTree: TileTreeReference, planes: FrustumPlanes, process: ProcessTiles) {\n const args = tileTree.createDrawArgs(context);\n return undefined !== args ? new SolarShadowMapDrawArgs(planes, shadowMap, args, process) : undefined;\n }\n }\n\n return SolarShadowMapDrawArgs.create(sceneContext, solarShadowMap, tree, frustumPlanes, processTiles);\n}\n\nconst shadowMapWidth = 4096; // size of original depth buffer map\nconst shadowMapHeight = shadowMapWidth; // TBD - Adjust for aspect ratio.\nconst evsmWidth = shadowMapWidth / 2; // EVSM buffer is 1/2 size each direction\nconst evsmHeight = shadowMapHeight / 2;\nconst postProjectionMatrixNpc = Matrix4d.createRowValues(/* Row 1 */ 0, 1, 0, 0, /* Row 2 */ 0, 0, 1, 0, /* Row 3 */ 1, 0, 0, 0, /* Row 4 */ 0, 0, 0, 1);\n\n// Bundles up the disposable, create-once-and-reuse members of a SolarShadowMap.\nclass Bundle implements WebGLDisposable {\n private constructor(\n public readonly depthTexture: Texture,\n public readonly shadowMapTexture: Texture,\n public readonly fbo: FrameBuffer,\n public readonly fboSM: FrameBuffer,\n public readonly evsmGeom: EVSMGeometry,\n public readonly renderCommands: RenderCommands) {\n }\n\n public static create(target: Target, stack: BranchStack, batch: BatchState): Bundle | undefined {\n const depthTextureHandle = System.instance.createDepthBuffer(shadowMapWidth, shadowMapHeight) as TextureHandle;\n if (undefined === depthTextureHandle)\n return undefined;\n\n let pixelDataType = GL.Texture.DataType.Float;\n switch (System.instance.maxRenderType) {\n case RenderType.TextureFloat:\n break;\n case RenderType.TextureHalfFloat:\n pixelDataType = System.instance.context.HALF_FLOAT;\n break;\n /* falls through */\n default:\n return undefined;\n }\n\n const colorTextures: TextureHandle[] = [];\n\n const fbo = FrameBuffer.create(colorTextures, depthTextureHandle);\n if (undefined === fbo)\n return undefined;\n\n // shadowMap texture is 1/4 size the depth texture (and averaged down when converting)\n const shadowMapTextureHandle = TextureHandle.createForAttachment(evsmWidth, evsmHeight, GL.Texture.Format.Rgba, pixelDataType);\n if (undefined === shadowMapTextureHandle)\n return undefined;\n\n const fboSM = FrameBuffer.create([shadowMapTextureHandle]);\n if (undefined === fboSM)\n return undefined;\n\n const depthTexture = new Texture({ ownership: \"external\", type: RenderTexture.Type.TileSection, handle: depthTextureHandle, transparency: TextureTransparency.Opaque });\n const evsmGeom = EVSMGeometry.createGeometry(depthTexture.texture.getHandle()!, shadowMapWidth, shadowMapHeight);\n if (undefined === evsmGeom)\n return undefined;\n\n const shadowMapTexture = new Texture({ type: RenderTexture.Type.Normal, ownership: \"external\", handle: shadowMapTextureHandle, transparency: TextureTransparency.Opaque });\n const renderCommands = new RenderCommands(target, stack, batch);\n return new Bundle(depthTexture, shadowMapTexture, fbo, fboSM, evsmGeom, renderCommands);\n }\n\n public get isDisposed(): boolean {\n return this.depthTexture.isDisposed\n && this.shadowMapTexture.isDisposed\n && this.fbo.isDisposed\n && this.fboSM.isDisposed\n && this.evsmGeom.isDisposed;\n }\n\n public [Symbol.dispose](): void {\n dispose(this.depthTexture);\n dispose(this.shadowMapTexture);\n dispose(this.fbo);\n dispose(this.fboSM);\n dispose(this.evsmGeom);\n }\n}\n\n/** Describes the set of parameters which, when they change, require us to recreate the shadow map. */\nclass ShadowMapParams {\n public readonly direction = new Vector3d();\n public readonly viewFrustum = new Frustum();\n public settings: SolarShadowSettings;\n\n public constructor(viewFrustum: Frustum, direction: Vector3d, settings: SolarShadowSettings) {\n direction.clone(this.direction);\n this.viewFrustum.setFrom(viewFrustum);\n this.settings = settings;\n }\n\n public update(viewFrustum: Frustum, direction: Vector3d, settings: SolarShadowSettings): void {\n this.settings = settings;\n this.viewFrustum.setFrom(viewFrustum);\n direction.clone(this.direction);\n }\n}\n\nconst defaultSunDirection = Vector3d.create(-1, -1, -1).normalize()!;\nconst scratchFrustum = new Frustum();\nconst scratchFrustumPlanes = FrustumPlanes.createEmpty();\n\nexport class SolarShadowMap implements RenderMemory.Consumer, WebGLDisposable {\n private _bundle?: Bundle;\n private _projectionMatrix = Matrix4d.createIdentity();\n private _graphics: RenderGraphic[] = [];\n private _shadowFrustum = new Frustum();\n private _isReady = false;\n private _isDrawing = false;\n private _enabled = false;\n private _params?: ShadowMapParams;\n private readonly _scratchRange = Range3d.createNull();\n private readonly _scratchTransform = Transform.createIdentity();\n\n private readonly _scratchViewFlags = new ViewFlags();\n private readonly _renderState: RenderState;\n private readonly _noZRenderState: RenderState;\n private readonly _batchState: BatchState;\n private _worldToViewMap = Map4d.createIdentity();\n private readonly _target: Target;\n\n // This exists chiefly for debugging. See ToggleShadowMapTilesTool.\n public onGraphicsChanged?: (graphics: RenderGraphic[]) => void;\n\n private getBundle(target: Target): Bundle | undefined {\n if (undefined === this._bundle) {\n this._bundle = Bundle.create(target, target.uniforms.branch.stack, this._batchState);\n assert(undefined !== this._bundle);\n }\n\n return this._bundle;\n }\n\n public get isReady() { return this._isReady; }\n public get isDrawing() { return this._isDrawing; }\n public get isEnabled() { return this._enabled; }\n public get projectionMatrix(): Matrix4d { return this._projectionMatrix; }\n public get depthTexture(): Texture | undefined { return undefined !== this._bundle ? this._bundle.depthTexture : undefined; }\n public get shadowMapTexture(): Texture | undefined { return undefined !== this._bundle ? this._bundle.shadowMapTexture : undefined; }\n public get settings(): SolarShadowSettings | undefined { return undefined !== this._params ? this._params.settings : undefined; }\n public get direction(): Vector3d | undefined { return undefined !== this._params ? this._params.direction : undefined; }\n public get frustum(): Frustum { return this._shadowFrustum; }\n public get worldToViewMap(): Map4d { return this._worldToViewMap; }\n public addGraphic(graphic: RenderGraphic) { this._graphics.push(graphic); }\n\n public constructor(target: Target) {\n this._target = target;\n this._renderState = new RenderState();\n this._renderState.flags.depthMask = true;\n this._renderState.flags.blend = false;\n this._renderState.flags.depthTest = true;\n\n this._noZRenderState = new RenderState();\n this._noZRenderState.flags.depthMask = false;\n\n this._batchState = new BatchState(target.uniforms.branch.stack);\n }\n\n public disable() {\n this._enabled = this._isReady = false;\n this._bundle = dispose(this._bundle);\n this.clearGraphics(true);\n this._target.uniforms.shadow.update();\n }\n\n public collectStatistics(stats: RenderMemory.Statistics): void {\n const bundle = this._bundle;\n if (undefined !== bundle)\n stats.addShadowMap(bundle.depthTexture.bytesUsed + bundle.shadowMapTexture.bytesUsed);\n }\n\n public get isDisposed(): boolean { return undefined === this._bundle && 0 === this._graphics.length; }\n\n public [Symbol.dispose]() {\n this._bundle = dispose(this._bundle);\n this.clearGraphics(true);\n }\n\n private clearGraphics(notify: boolean) {\n for (const graphic of this._graphics)\n graphic[Symbol.dispose]();\n\n this._graphics.length = 0;\n if (notify)\n this.notifyGraphicsChanged();\n }\n\n private notifyGraphicsChanged(): void {\n if (undefined !== this.onGraphicsChanged)\n this.onGraphicsChanged(this._graphics);\n }\n\n public update(context: SceneContext | undefined) {\n this._isReady = false;\n this.clearGraphics(false);\n\n if (undefined === context || !context.viewport.view.isSpatialView()) {\n this.disable();\n this.notifyGraphicsChanged();\n return;\n }\n\n const view = context.viewport.view;\n const style = view.getDisplayStyle3d();\n const sunDirection = style.sunDirection ?? defaultSunDirection;\n\n const minimumHorizonDirection = -.01;\n if (sunDirection.z > minimumHorizonDirection) {\n this.notifyGraphicsChanged();\n return;\n }\n\n this._enabled = true;\n const viewFrustum = context.viewingSpace.getFrustum();\n const settings = style.settings.solarShadows;\n if (undefined === this._params)\n this._params = new ShadowMapParams(viewFrustum, sunDirection, settings);\n else\n this._params.update(viewFrustum, sunDirection, settings);\n\n const iModel = view.iModel;\n\n const worldToMapTransform = Transform.createRefs(Point3d.createZero(), Matrix3d.createRigidHeadsUp(this._params.direction.negate()).inverse()!);\n const worldToMap = Matrix4d.createTransform(worldToMapTransform);\n const mapToWorld = worldToMap.createInverse()!;\n\n // Start with entire project.\n const shadowRange = worldToMapTransform.multiplyRange(iModel.projectExtents);\n\n // Limit the map to only displayed models.\n const viewTileRange = Range3d.createNull();\n for (const ref of view.getTileTreeRefs()) {\n if (ref.castsShadows) {\n if (ref.isGlobal) {\n // A shadow-casting tile tree that spans the globe. Limit its range to the viewed extents.\n for (const p3 of viewFrustum.points) {\n const p4 = worldToMap.multiplyPoint3d(p3, 1);\n if (p4.w > 0.0001)\n viewTileRange.extendXYZW(p4.x, p4.y, p4.z, p4.w);\n else\n viewTileRange.high.z = Math.max(1.0, viewTileRange.high.z); // behind eye plane.\n }\n } else {\n ref.accumulateTransformedRange(viewTileRange, worldToMap, undefined);\n }\n }\n }\n\n if (!viewTileRange.isNull)\n viewTileRange.clone(shadowRange);\n\n // Expand shadow range to include both the shadowers and shadowed portion of background map.\n scratchFrustum.initFromRange(shadowRange);\n mapToWorld.multiplyPoint3dArrayQuietNormalize(scratchFrustum.points); // This frustum represents the shadowing geometry. Intersect it with background geometry and expand the range depth to include that intersection.\n const backgroundMapGeometry = context.viewport.view.displayStyle.getBackgroundMapGeometry();\n if (undefined !== backgroundMapGeometry) {\n const backgroundDepthRange = backgroundMapGeometry.getFrustumIntersectionDepthRange(this._shadowFrustum, iModel.projectExtents);\n if (!backgroundDepthRange.isNull)\n shadowRange.low.z = Math.min(shadowRange.low.z, backgroundDepthRange.low);\n }\n\n this._params.viewFrustum.transformBy(worldToMapTransform, scratchFrustum);\n scratchFrustumPlanes.init(scratchFrustum);\n\n const viewIntersectShadowRange = Range3d.createNull();\n const viewClipPlanes = ConvexClipPlaneSet.createPlanes(scratchFrustumPlanes.planes);\n ClipUtilities.announceLoopsOfConvexClipPlaneSetIntersectRange(viewClipPlanes, shadowRange, (points: GrowableXYZArray) => {\n for (const point of points.getPoint3dArray())\n viewIntersectShadowRange.extendPoint(point);\n });\n if (viewIntersectShadowRange.isNull) {\n this.notifyGraphicsChanged();\n return;\n }\n viewIntersectShadowRange.high.z = shadowRange.high.z; // We need to include shadowing geometry that may be outside view (along the solar axis).\n\n this._shadowFrustum.initFromRange(viewIntersectShadowRange);\n mapToWorld.multiplyPoint3dArrayQuietNormalize(this._shadowFrustum.points);\n\n const tileRange = Range3d.createNull();\n scratchFrustumPlanes.init(this._shadowFrustum);\n for (const ref of view.getTileTreeRefs()) {\n if (!ref.castsShadows)\n continue;\n\n const drawArgs = createDrawArgs(context, this, ref, scratchFrustumPlanes, (tiles: Tile[]) => {\n for (const tile of tiles)\n tileRange.extendRange(tileToMapTransform.multiplyRange(tile.range, this._scratchRange));\n });\n\n if (undefined === drawArgs)\n continue;\n\n const tileToMapTransform = worldToMapTransform.multiplyTransformTransform(drawArgs.location, this._scratchTransform);\n drawArgs.tree.draw(drawArgs);\n }\n\n if (tileRange.isNull) {\n this.clearGraphics(true);\n } else if (this._graphics.length > 0) {\n // Avoid an uninvertible matrix on empty range...\n if (Geometry.isAlmostEqualNumber(shadowRange.low.x, shadowRange.high.x) ||\n Geometry.isAlmostEqualNumber(shadowRange.low.y, shadowRange.high.y) ||\n Geometry.isAlmostEqualNumber(shadowRange.low.z, shadowRange.high.z)) {\n this.clearGraphics(true);\n return;\n }\n\n const frustumMap = this._shadowFrustum.toMap4d();\n if (undefined === frustumMap) {\n this.clearGraphics(true);\n assert(false);\n return;\n }\n\n this._projectionMatrix = frustumMap.transform0.clone();\n\n const worldToNpc = postProjectionMatrixNpc.multiplyMatrixMatrix(this._projectionMatrix);\n const npcToView = Map4d.createBoxMap(Point3d.create(0, 0, 0), Point3d.create(1, 1, 1), Point3d.create(0, 0, 0), Point3d.create(shadowMapWidth, shadowMapHeight, 1))!;\n const npcToWorld = worldToNpc.createInverse();\n if (undefined === npcToWorld) {\n this.clearGraphics(true);\n return;\n }\n\n const worldToNpcMap = Map4d.createRefs(worldToNpc, npcToWorld);\n this._worldToViewMap = npcToView.multiplyMapMap(worldToNpcMap);\n }\n\n this._target.uniforms.shadow.update();\n this.notifyGraphicsChanged();\n }\n\n public draw(target: Target) {\n assert(this.isEnabled);\n\n if (this.isReady || 0 === this._graphics.length)\n return;\n\n const bundle = this.getBundle(target);\n if (undefined === bundle)\n return;\n\n this._isDrawing = true;\n\n const prevState = System.instance.currentRenderState.clone();\n const gl = System.instance.context;\n gl.viewport(0, 0, shadowMapWidth, shadowMapHeight);\n\n // NB: textures and materials are needed because their transparencies affect whether or not a surface casts shadows\n const viewFlags = target.currentViewFlags.copy({\n renderMode: RenderMode.SmoothShade,\n wiremesh: false,\n transparency: false,\n lighting: false,\n shadows: false,\n monochrome: false,\n ambientOcclusion: false,\n visibleEdges: false,\n hiddenEdges: false,\n });\n\n System.instance.applyRenderState(this._renderState);\n const prevPlan = target.plan;\n\n target.changeFrustum(this._shadowFrustum, this._shadowFrustum.getFraction(), true);\n target.uniforms.branch.changeRenderPlan(viewFlags, target.plan.is3d, target.plan.hline);\n\n const renderCommands = bundle.renderCommands;\n renderCommands.reset(target, target.uniforms.branch.stack, this._batchState);\n renderCommands.addGraphics(this._graphics);\n\n System.instance.frameBufferStack.execute(bundle.fbo, true, false, () => {\n System.instance.context.clearDepth(1.0);\n System.instance.context.clear(GL.BufferBit.Depth);\n target.techniques.execute(target, renderCommands.getCommands(RenderPass.OpaquePlanar), RenderPass.PlanarClassification); // Draw these with RenderPass.PlanarClassification (rather than Opaque...) so that the pick ordering is avoided.\n target.techniques.execute(target, renderCommands.getCommands(RenderPass.OpaqueGeneral), RenderPass.PlanarClassification); // Draw these with RenderPass.PlanarClassification (rather than Opaque...) so that the pick ordering is avoided.\n });\n\n // copy depth buffer to EVSM shadow buffer and average down for AA effect\n gl.viewport(0, 0, evsmWidth, evsmHeight);\n System.instance.frameBufferStack.execute(bundle.fboSM, true, false, () => {\n System.instance.applyRenderState(this._noZRenderState);\n const params = getDrawParams(target, bundle.evsmGeom);\n target.techniques.draw(params);\n });\n\n // mipmap resulting EVSM texture and set filtering options\n System.instance.activateTexture2d(TextureUnit.ShadowMap, bundle.shadowMapTexture.texture.getHandle());\n gl.generateMipmap(gl.TEXTURE_2D);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n\n System.instance.setMaxAnisotropy(undefined);\n // target.recordPerformanceMetric(\"Compute EVSM\");\n\n this._batchState.reset(); // Reset the batch Ids...\n target.changeRenderPlan(prevPlan);\n\n System.instance.applyRenderState(prevState);\n System.instance.context.viewport(0, 0, target.viewRect.width, target.viewRect.height); // Restore viewport\n this.clearGraphics(false);\n this._isDrawing = false;\n this._isReady = true;\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { TerrainMeshProvider, TerrainMeshProviderOptions } from "../internal";
2
- /** Return the URL for a Cesium ION asset from its asset ID and request Key.
2
+ /** Return the URL for a Cesium ion asset from its asset ID and request Key.
3
3
  * @public
4
4
  */
5
5
  export declare function getCesiumAssetUrl(osmAssetId: number, requestKey: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"CesiumTerrainProvider.d.ts","sourceRoot":"","sources":["../../../../src/tile/map/CesiumTerrainProvider.ts"],"names":[],"mappings":"AAgBA,OAAO,EACwF,mBAAmB,EAChH,0BAA0B,EAC3B,MAAM,aAAa,CAAC;AAUrB;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAEhF;AACD,gBAAgB;AAChB,wBAAgB,wBAAwB,IAAI,MAAM,GAAG,SAAS,CAO7D;AAED,gBAAgB;AAChB,wBAAsB,kCAAkC,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAqBxI;AAaD,gBAAgB;AAChB,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,0BAA0B,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAiDzH"}
1
+ {"version":3,"file":"CesiumTerrainProvider.d.ts","sourceRoot":"","sources":["../../../../src/tile/map/CesiumTerrainProvider.ts"],"names":[],"mappings":"AAgBA,OAAO,EACwF,mBAAmB,EAChH,0BAA0B,EAC3B,MAAM,aAAa,CAAC;AAUrB;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAEhF;AAED,gBAAgB;AAChB,wBAAgB,wBAAwB,IAAI,MAAM,GAAG,SAAS,CAM7D;AAED,gBAAgB;AAChB,wBAAsB,kCAAkC,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAqBxI;AAaD,gBAAgB;AAChB,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,0BAA0B,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAiDzH"}
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { assert, BeDuration, BeTimePoint, ByteStream, JsonUtils, utf8ToString } from "@itwin/core-bentley";
9
9
  import { Point2d, Point3d, Range1d, Vector3d } from "@itwin/core-geometry";
10
- import { CesiumTerrainAssetId, nextPoint3d64FromByteStream, OctEncodedNormal, QPoint2d } from "@itwin/core-common";
10
+ import { CesiumIonAssetId, CesiumTerrainAssetId, nextPoint3d64FromByteStream, OctEncodedNormal, QPoint2d } from "@itwin/core-common";
11
11
  import { MessageSeverity } from "@itwin/appui-abstract";
12
12
  import { request } from "../../request/Request";
13
13
  import { ApproximateTerrainHeights } from "../../ApproximateTerrainHeights";
@@ -21,7 +21,7 @@ var QuantizedMeshExtensionIds;
21
21
  QuantizedMeshExtensionIds[QuantizedMeshExtensionIds["WaterMask"] = 2] = "WaterMask";
22
22
  QuantizedMeshExtensionIds[QuantizedMeshExtensionIds["Metadata"] = 4] = "Metadata";
23
23
  })(QuantizedMeshExtensionIds || (QuantizedMeshExtensionIds = {}));
24
- /** Return the URL for a Cesium ION asset from its asset ID and request Key.
24
+ /** Return the URL for a Cesium ion asset from its asset ID and request Key.
25
25
  * @public
26
26
  */
27
27
  export function getCesiumAssetUrl(osmAssetId, requestKey) {
@@ -32,8 +32,7 @@ export function getCesiumOSMBuildingsUrl() {
32
32
  const key = IModelApp.tileAdmin.cesiumIonKey;
33
33
  if (undefined === key)
34
34
  return undefined;
35
- const osmBuildingAssetId = 96188;
36
- return getCesiumAssetUrl(osmBuildingAssetId, key);
35
+ return getCesiumAssetUrl(+CesiumIonAssetId.OSMBuildings, key);
37
36
  }
38
37
  /** @internal */
39
38
  export async function getCesiumAccessTokenAndEndpointUrl(assetId, requestKey) {
@@ -1 +1 @@
1
- {"version":3,"file":"CesiumTerrainProvider.js","sourceRoot":"","sources":["../../../../src/tile/map/CesiumTerrainProvider.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AACH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC3G,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,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AC,CAAC,CAAC,WAAW,CAAC;IAC/D,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Tiles\n */\nimport { assert, BeDuration, BeTimePoint, ByteStream, JsonUtils, utf8ToString } from \"@itwin/core-bentley\";\nimport { Point2d, Point3d, Range1d, Vector3d } from \"@itwin/core-geometry\";\nimport { CesiumTerrainAssetId, nextPoint3d64FromByteStream, OctEncodedNormal, QPoint2d } from \"@itwin/core-common\";\nimport { MessageSeverity } from \"@itwin/appui-abstract\";\nimport { request, RequestOptions } from \"../../request/Request\";\nimport { ApproximateTerrainHeights } from \"../../ApproximateTerrainHeights\";\nimport { IModelApp } from \"../../IModelApp\";\nimport { RealityMeshParams, RealityMeshParamsBuilder } from \"../../render/RealityMeshParams\";\nimport {\n GeographicTilingScheme, MapTile, MapTilingScheme, QuadId, ReadMeshArgs, RequestMeshDataArgs, TerrainMeshProvider,\n TerrainMeshProviderOptions, Tile, TileAvailability,\n} from \"../internal\";\nimport { ScreenViewport } from \"../../Viewport\";\n\n/** @internal */\nenum QuantizedMeshExtensionIds {\n OctEncodedNormals = 1,\n WaterMask = 2,\n Metadata = 4,\n}\n\n/** Return the URL for a Cesium ION asset from its asset ID and request Key.\n * @public\n */\nexport function getCesiumAssetUrl(osmAssetId: number, requestKey: string): string {\n return `$CesiumIonAsset=${osmAssetId}:${requestKey}`;\n}\n/** @internal */\nexport function getCesiumOSMBuildingsUrl(): string | undefined {\n const key = IModelApp.tileAdmin.cesiumIonKey;\n if (undefined === key)\n return undefined;\n\n const osmBuildingAssetId = 96188;\n return getCesiumAssetUrl(osmBuildingAssetId, key);\n}\n\n/** @internal */\nexport async function getCesiumAccessTokenAndEndpointUrl(assetId: string, requestKey?: string): Promise<{ token?: string, url?: string }> {\n if (undefined === requestKey) {\n requestKey = IModelApp.tileAdmin.cesiumIonKey;\n if (undefined === requestKey)\n return {};\n }\n\n const requestTemplate = `https://api.cesium.com/v1/assets/${assetId}/endpoint?access_token={CesiumRequestToken}`;\n const apiUrl: string = requestTemplate.replace(\"{CesiumRequestToken}\", requestKey);\n\n try {\n const apiResponse = await request(apiUrl, \"json\");\n if (undefined === apiResponse || undefined === apiResponse.url) {\n assert(false);\n return {};\n }\n return { token: apiResponse.accessToken, url: apiResponse.url };\n } catch {\n assert(false);\n return {};\n }\n}\n\nlet notifiedTerrainError = false;\n\n// Notify - once per session - of failure to obtain Cesium terrain provider.\nfunction notifyTerrainError(detailedDescription?: string): void {\n if (notifiedTerrainError)\n return;\n\n notifiedTerrainError = true;\n IModelApp.notifications.displayMessage(MessageSeverity.Information, IModelApp.localization.getLocalizedString(`iModelJs:BackgroundMap.CannotObtainTerrain`), detailedDescription);\n}\n\n/** @internal */\nexport async function getCesiumTerrainProvider(opts: TerrainMeshProviderOptions): Promise<TerrainMeshProvider | undefined> {\n const accessTokenAndEndpointUrl = await getCesiumAccessTokenAndEndpointUrl(opts.dataSource || CesiumTerrainAssetId.Default);\n if (!accessTokenAndEndpointUrl.token || !accessTokenAndEndpointUrl.url) {\n notifyTerrainError(IModelApp.localization.getLocalizedString(`iModelJs:BackgroundMap.MissingCesiumToken`));\n return undefined;\n }\n\n let layers;\n try {\n const layerRequestOptions: RequestOptions = { headers: { authorization: `Bearer ${accessTokenAndEndpointUrl.token}` } };\n const layerUrl = `${accessTokenAndEndpointUrl.url}layer.json`;\n layers = await request(layerUrl, \"json\", layerRequestOptions);\n } catch {\n notifyTerrainError();\n return undefined;\n }\n\n if (undefined === layers || undefined === layers.tiles || undefined === layers.version) {\n notifyTerrainError();\n return undefined;\n }\n\n const tilingScheme = new GeographicTilingScheme();\n let tileAvailability;\n // When collecting tiles, only the highest resolution tiles are downloaded.\n // Because of that, the tile availability is often only populated by the\n // \"layer\" metadata. (i.e. not from higher resolution tiles metadata).\n // Unfortunately the \"layer\" metadata only cover the first 16 levels,\n // preventing the geometry collector from accessing to higher resolution tiles.\n // For now, the solution is to turn off tile availability check when collecting geometries.\n if (undefined !== layers.available && !opts.produceGeometry) {\n const availableTiles = layers.available;\n tileAvailability = new TileAvailability(tilingScheme, availableTiles.length);\n for (let level = 0; level < layers.available.length; level++) {\n const rangesAtLevel = availableTiles[level];\n for (const range of rangesAtLevel) {\n tileAvailability.addAvailableTileRange(level, range.startX, range.startY, range.endX, range.endY);\n }\n }\n }\n\n let tileUrlTemplate = accessTokenAndEndpointUrl.url + layers.tiles[0].replace(\"{version}\", layers.version);\n if (opts.wantNormals)\n tileUrlTemplate = tileUrlTemplate.replace(\"?\", \"?extensions=octvertexnormals-watermask-metadata&\");\n\n const maxDepth = JsonUtils.asInt(layers.maxzoom, 19);\n\n // TBD -- When we have an API extract the heights for the project from the terrain tiles - for use temporary Bing elevation.\n return new CesiumTerrainProvider(opts, accessTokenAndEndpointUrl.token, tileUrlTemplate, maxDepth, tilingScheme, tileAvailability, layers.metadataAvailability);\n}\n\nfunction zigZagDecode(value: number) {\n return (value >> 1) ^ (-(value & 1));\n}\n\n/**\n * Decodes delta and ZigZag encoded vertices. This modifies the buffers in place.\n *\n * @see {@link https://github.com/AnalyticalGraphicsInc/quantized-mesh|quantized-mesh-1.0 terrain format}\n */\nfunction zigZagDeltaDecode(uBuffer: Uint16Array, vBuffer: Uint16Array, heightBuffer: Uint16Array) {\n const count = uBuffer.length;\n let u = 0;\n let v = 0;\n let height = 0;\n\n for (let i = 0; i < count; ++i) {\n u += zigZagDecode(uBuffer[i]);\n v += zigZagDecode(vBuffer[i]);\n\n uBuffer[i] = u;\n vBuffer[i] = v;\n\n height += zigZagDecode(heightBuffer[i]);\n heightBuffer[i] = height;\n }\n}\n\n/** @internal */\nclass CesiumTerrainProvider extends TerrainMeshProvider {\n private _accessToken: string;\n private readonly _tileUrlTemplate: string;\n private readonly _maxDepth: number;\n private readonly _wantSkirts: boolean;\n private readonly _tilingScheme: MapTilingScheme;\n private readonly _tileAvailability?: TileAvailability;\n private readonly _metaDataAvailableLevel?: number;\n private readonly _exaggeration: number;\n private readonly _assetId: string;\n\n private static _scratchQPoint2d = QPoint2d.fromScalars(0, 0);\n private static _scratchPoint2d = Point2d.createZero();\n private static _scratchPoint = Point3d.createZero();\n private static _scratchNormal = Vector3d.createZero();\n private static _scratchHeightRange = Range1d.createNull();\n private static _tokenTimeoutInterval = BeDuration.fromSeconds(60 * 30); // Request a new access token every 30 minutes...\n private _tokenTimeOut: BeTimePoint;\n\n public override forceTileLoad(tile: Tile): boolean {\n // Force loading of the metadata availability tiles as these are required for determining the availability of descendants.\n const mapTile = tile as MapTile;\n return undefined !== this._metaDataAvailableLevel && mapTile.quadId.level === this._metaDataAvailableLevel && !mapTile.everLoaded;\n }\n\n constructor(opts: TerrainMeshProviderOptions, accessToken: string, tileUrlTemplate: string, maxDepth: number, tilingScheme: MapTilingScheme,\n tileAvailability: TileAvailability | undefined, metaDataAvailableLevel: number | undefined) {\n super();\n this._wantSkirts = opts.wantSkirts;\n this._exaggeration = opts.exaggeration;\n\n this._accessToken = accessToken;\n this._tileUrlTemplate = tileUrlTemplate;\n this._maxDepth = maxDepth;\n this._tilingScheme = tilingScheme;\n this._tileAvailability = tileAvailability;\n this._metaDataAvailableLevel = metaDataAvailableLevel;\n this._assetId = opts.dataSource || CesiumTerrainAssetId.Default;\n\n this._tokenTimeOut = BeTimePoint.now().plus(CesiumTerrainProvider._tokenTimeoutInterval);\n }\n\n /** @deprecated in 5.0 Use [addAttributions] instead. */\n public override addLogoCards(cards: HTMLTableElement): void {\n if (cards.dataset.cesiumIonLogoCard)\n return;\n\n cards.dataset.cesiumIonLogoCard = \"true\";\n let notice = IModelApp.localization.getLocalizedString(\"iModelJs:BackgroundMap.CesiumWorldTerrainAttribution\");\n if (this._assetId === CesiumTerrainAssetId.Bathymetry)\n notice = `${notice}\\n${IModelApp.localization.getLocalizedString(\"iModelJs:BackgroundMap.CesiumBathymetryAttribution\")}`;\n\n const card = IModelApp.makeLogoCard({ iconSrc: `${IModelApp.publicPath}images/cesium-ion.svg`, heading: \"Cesium Ion\", notice });\n cards.appendChild(card);\n }\n\n public override async addAttributions(cards: HTMLTableElement, _vp: ScreenViewport): Promise<void> {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return Promise.resolve(this.addLogoCards(cards));\n }\n\n\n public get maxDepth(): number { return this._maxDepth; }\n public get tilingScheme(): MapTilingScheme { return this._tilingScheme; }\n\n public override isTileAvailable(quadId: QuadId) {\n if (quadId.level > this.maxDepth)\n return false;\n\n return this._tileAvailability ? this._tileAvailability.isTileAvailable(quadId.level, quadId.column, quadId.row) : true;\n }\n\n public override async requestMeshData(args: RequestMeshDataArgs): Promise<Uint8Array | undefined> {\n const tile = args.tile;\n const quadId = tile.quadId;\n const tileUrl = this.constructUrl(quadId.row, quadId.column, quadId.level);\n const requestOptions: RequestOptions = {\n headers: {\n authorization: `Bearer ${this._accessToken}`,\n accept: \"application/vnd.quantized-mesh;\" /* extensions=octvertexnormals, */ + \"application/octet-stream;q=0.9,*/*;q=0.01\",\n },\n };\n\n try {\n const response = await request(tileUrl, \"arraybuffer\", requestOptions);\n return new Uint8Array(response);\n } catch {\n return undefined;\n }\n }\n\n public override async readMesh(args: ReadMeshArgs): Promise<RealityMeshParams | undefined> {\n // ###TODO why does he update the access token when reading the mesh instead of when requesting it?\n // This function only returns undefined if it fails to acquire token - but it doesn't need the token...\n if (BeTimePoint.now().milliseconds > this._tokenTimeOut.milliseconds) {\n const accessTokenAndEndpointUrl = await getCesiumAccessTokenAndEndpointUrl(this._assetId);\n if (!accessTokenAndEndpointUrl.token || args.isCanceled())\n return undefined;\n\n this._accessToken = accessTokenAndEndpointUrl.token;\n this._tokenTimeOut = BeTimePoint.now().plus(CesiumTerrainProvider._tokenTimeoutInterval);\n }\n\n const { data, tile } = args;\n assert(data instanceof Uint8Array);\n assert(tile instanceof MapTile);\n\n const blob = data;\n const streamBuffer = ByteStream.fromUint8Array(blob);\n const center = nextPoint3d64FromByteStream(streamBuffer);\n const quadId = QuadId.createFromContentId(tile.contentId);\n const skirtHeight = this.getLevelMaximumGeometricError(quadId.level + 1) * 10.0; // Add 1 to level to restore height calculation to before the quadId level was from root. (4326 unification)\n const minHeight = this._exaggeration * streamBuffer.readFloat32();\n const maxHeight = this._exaggeration * streamBuffer.readFloat32();\n const boundCenter = nextPoint3d64FromByteStream(streamBuffer);\n const boundRadius = streamBuffer.readFloat64();\n const horizonOcclusion = nextPoint3d64FromByteStream(streamBuffer);\n const terrainTile = tile;\n\n terrainTile.adjustHeights(minHeight, maxHeight);\n\n if (undefined === center || undefined === boundCenter || undefined === boundRadius || undefined === horizonOcclusion) { }\n const pointCount = streamBuffer.readUint32();\n const encodedVertexBuffer = new Uint16Array(blob.buffer, streamBuffer.curPos, pointCount * 3);\n streamBuffer.advance(pointCount * 6);\n\n const uBuffer = encodedVertexBuffer.subarray(0, pointCount);\n const vBuffer = encodedVertexBuffer.subarray(pointCount, 2 * pointCount);\n const heightBuffer = encodedVertexBuffer.subarray(pointCount * 2, 3 * pointCount);\n\n zigZagDeltaDecode(uBuffer, vBuffer, heightBuffer);\n\n // ###TODO: This alleges to handle 32-bit indices, but RealityMeshParams uses a Uint16Array to store indices...\n const typedArray = pointCount > 0xffff ? Uint32Array : Uint16Array;\n const bytesPerIndex = typedArray.BYTES_PER_ELEMENT;\n const triangleElements = 3;\n\n // skip over any additional padding that was added for 2/4 byte alignment\n if (streamBuffer.curPos % bytesPerIndex !== 0)\n streamBuffer.advance(bytesPerIndex - (streamBuffer.curPos % bytesPerIndex));\n\n const triangleCount = streamBuffer.readUint32();\n const indexCount = triangleCount * triangleElements;\n\n const getIndexArray = (numIndices: number) => {\n const indexArray = new typedArray(streamBuffer.arrayBuffer, streamBuffer.curPos, numIndices);\n streamBuffer.advance(numIndices * bytesPerIndex);\n return indexArray;\n };\n\n const indices = getIndexArray(indexCount);\n\n // High water mark decoding based on decompressIndices_ in webgl-loader's loader.js.\n // https://code.google.com/p/webgl-loader/source/browse/trunk/samples/loader.js?r=99#55\n // Copyright 2012 Google Inc., Apache 2.0 license.\n let highest = 0;\n const length = indices.length;\n for (let i = 0; i < length; ++i) {\n const code = indices[i];\n indices[i] = highest - code;\n if (code === 0) {\n ++highest;\n }\n }\n\n CesiumTerrainProvider._scratchHeightRange.low = minHeight - skirtHeight;\n CesiumTerrainProvider._scratchHeightRange.high = maxHeight;\n const projection = terrainTile.getProjection(CesiumTerrainProvider._scratchHeightRange);\n const uvScale = 1.0 / 32767.0;\n const heightScale = uvScale * (maxHeight - minHeight);\n\n const westCount = streamBuffer.readUint32(),\n westIndices = getIndexArray(westCount),\n southCount = streamBuffer.readUint32(),\n southIndices = getIndexArray(southCount),\n eastCount = streamBuffer.readUint32(),\n eastIndices = getIndexArray(eastCount),\n northCount = streamBuffer.readUint32(),\n northIndices = getIndexArray(northCount);\n\n // Extensions...\n let encodedNormalsBuffer;\n while (streamBuffer.curPos < streamBuffer.length) {\n const extensionId = streamBuffer.readUint8();\n const extensionLength = streamBuffer.readUint32();\n switch (extensionId) {\n case QuantizedMeshExtensionIds.OctEncodedNormals:\n assert(pointCount * 2 === extensionLength);\n encodedNormalsBuffer = new Uint8Array(streamBuffer.arrayBuffer, streamBuffer.curPos, extensionLength);\n streamBuffer.advance(extensionLength);\n break;\n\n case QuantizedMeshExtensionIds.Metadata:\n const stringLength = streamBuffer.readUint32();\n if (stringLength > 0) {\n const strData = streamBuffer.nextBytes(stringLength);\n const str = utf8ToString(strData);\n if (undefined !== str) {\n const metaData = JSON.parse(str);\n if (undefined !== metaData.available && undefined !== this._tileAvailability) {\n const availableTiles = metaData.available;\n for (let offset = 0; offset < availableTiles.length; ++offset) {\n const availableLevel = tile.depth + offset; // Our depth is includes root (1 + cesium Depth)\n const rangesAtLevel = availableTiles[offset];\n\n for (const range of rangesAtLevel)\n this._tileAvailability.addAvailableTileRange(availableLevel, range.startX, range.startY, range.endX, range.endY);\n }\n }\n }\n }\n\n break;\n default:\n streamBuffer.advance(extensionLength);\n break;\n }\n }\n\n let initialIndexCapacity = indexCount;\n let initialVertexCapacity = pointCount;\n if (this._wantSkirts) {\n initialIndexCapacity += 6 * (Math.max(0, northCount - 1) + Math.max(0, southCount - 1) + Math.max(0, eastCount - 1) + Math.max(0, westCount - 1));\n initialVertexCapacity += (northCount + southCount + eastCount + westCount);\n }\n\n const wantNormals = undefined !== encodedNormalsBuffer;\n const builder = new RealityMeshParamsBuilder({\n positionRange: projection.localRange,\n initialIndexCapacity,\n initialVertexCapacity,\n wantNormals,\n });\n\n for (let i = 0; i < indexCount; i += 3)\n builder.addTriangle(indices[i], indices[i + 1], indices[i + 2]);\n\n const position = new Point3d();\n const uv = new QPoint2d();\n const normal = new Vector3d();\n const worldToEcef = tile.iModel.getEcefTransform().matrix;\n for (let i = 0; i < pointCount; i++) {\n const u = uBuffer[i];\n const v = vBuffer[i];\n projection.getPoint(uvScale * u, uvScale * v, minHeight + heightBuffer[i] * heightScale, position);\n uv.setFromScalars(u * 2, v * 2);\n let oen;\n if (encodedNormalsBuffer) {\n const normalIndex = i * 2;\n OctEncodedNormal.decodeValue(encodedNormalsBuffer[normalIndex + 1] << 8 | encodedNormalsBuffer[normalIndex], normal);\n worldToEcef.multiplyTransposeVector(normal, normal);\n oen = OctEncodedNormal.encode(normal);\n }\n\n builder.addVertex(position, uv, oen);\n }\n\n if (!this._wantSkirts)\n return builder.finish();\n\n westIndices.sort((a, b) => vBuffer[a] - vBuffer[b]);\n eastIndices.sort((a, b) => vBuffer[a] - vBuffer[b]);\n northIndices.sort((a, b) => uBuffer[a] - uBuffer[b]);\n southIndices.sort((a, b) => uBuffer[a] - uBuffer[b]);\n\n const generateSkirts = (indexes: Uint16Array | Uint32Array) => {\n const quv = new QPoint2d();\n const param = new Point2d();\n for (let i = 0; i < indexes.length; i++) {\n const index = indexes[i];\n const uvIndex = index * 2;\n const height = minHeight + heightBuffer[index] * heightScale;\n\n quv.setFromScalars(builder.uvs.buffer.at(uvIndex), builder.uvs.buffer.at(uvIndex + 1));\n builder.uvs.params.unquantize(quv.x, quv.y, param);\n\n const oen = wantNormals && builder.normals ? builder.normals.at(index) : undefined;\n builder.addVertex(projection.getPoint(param.x, param.y, height - skirtHeight), quv, oen);\n\n if (i !== 0) {\n const nextPointIndex = builder.positions.length;\n builder.addTriangle(index, indexes[i - 1], nextPointIndex - 2);\n builder.addTriangle(index, nextPointIndex - 2, nextPointIndex - 1);\n }\n }\n };\n\n generateSkirts(westIndices);\n generateSkirts(eastIndices);\n generateSkirts(southIndices);\n generateSkirts(northIndices);\n\n return builder.finish();\n }\n\n public constructUrl(row: number, column: number, zoomLevel: number): string {\n return this._tileUrlTemplate.replace(\"{z}\", zoomLevel.toString()).replace(\"{x}\", column.toString()).replace(\"{y}\", row.toString());\n }\n\n /**\n * Specifies the quality of terrain created from heightmaps. A value of 1.0 will\n * ensure that adjacent heightmap vertices are separated by no more than\n * screen pixels and will probably go very slowly.\n * A value of 0.5 will cut the estimated level zero geometric error in half, allowing twice the\n * screen pixels between adjacent heightmap vertices and thus rendering more quickly.\n * @type {Number}\n */\n public readonly heightmapTerrainQuality = 0.25;\n\n /**\n * Determines an appropriate geometric error estimate when the geometry comes from a heightmap.\n *\n * @param {Ellipsoid} ellipsoid The ellipsoid to which the terrain is attached.\n * @param {Number} tileImageWidth The width, in pixels, of the heightmap associated with a single tile.\n * @param {Number} numberOfTilesAtLevelZero The number of tiles in the horizontal direction at tile level zero.\n * @returns {Number} An estimated geometric error.\n */\n public getEstimatedLevelZeroGeometricErrorForAHeightmap(ellipsoidMaximumRadius = 6378137, tileImageWidth = 65, numberOfTilesAtLevelZero = 2) {\n return ellipsoidMaximumRadius * 2 * Math.PI * this.heightmapTerrainQuality / (tileImageWidth * numberOfTilesAtLevelZero);\n }\n\n public getLevelMaximumGeometricError(level: number) {\n return this.getEstimatedLevelZeroGeometricErrorForAHeightmap() / (1 << level);\n }\n\n public getHeightRange(parentRange: Range1d, quadId: QuadId): Range1d {\n const heightRange = quadId.level <= 6 ? ApproximateTerrainHeights.instance.getTileHeightRange(quadId) : undefined;\n\n return undefined === heightRange ? parentRange : heightRange;\n }\n}\n"]}
1
+ {"version":3,"file":"CesiumTerrainProvider.js","sourceRoot":"","sources":["../../../../src/tile/map/CesiumTerrainProvider.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AACH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC3G,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACrI,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAkB,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAqB,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC7F,OAAO,EACL,sBAAsB,EAAE,OAAO,EAAmB,MAAM,EAAqC,mBAAmB,EAC9E,gBAAgB,GACnD,MAAM,aAAa,CAAC;AAGrB,gBAAgB;AAChB,IAAK,yBAIJ;AAJD,WAAK,yBAAyB;IAC5B,mGAAqB,CAAA;IACrB,mFAAa,CAAA;IACb,iFAAY,CAAA;AACd,CAAC,EAJI,yBAAyB,KAAzB,yBAAyB,QAI7B;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAkB,EAAE,UAAkB;IACtE,OAAO,mBAAmB,UAAU,IAAI,UAAU,EAAE,CAAC;AACvD,CAAC;AAED,gBAAgB;AAChB,MAAM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AG,IAAI,CAAC,uBAAuB,GAAG,CAAC,cAAc,GAAG,wBAAwB,CAAC,CAAC;IAC3H,CAAC;IAEM,6BAA6B,CAAC,KAAa;QAChD,OAAO,IAAI,CAAC,gDAAgD,EAAE,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC;IAChF,CAAC;IAEM,cAAc,CAAC,WAAoB,EAAE,MAAc;QACxD,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,yBAAyB,CAAC,QAAQ,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAElH,OAAO,SAAS,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC;IAC/D,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Tiles\n */\nimport { assert, BeDuration, BeTimePoint, ByteStream, JsonUtils, utf8ToString } from \"@itwin/core-bentley\";\nimport { Point2d, Point3d, Range1d, Vector3d } from \"@itwin/core-geometry\";\nimport { CesiumIonAssetId, CesiumTerrainAssetId, nextPoint3d64FromByteStream, OctEncodedNormal, QPoint2d } from \"@itwin/core-common\";\nimport { MessageSeverity } from \"@itwin/appui-abstract\";\nimport { request, RequestOptions } from \"../../request/Request\";\nimport { ApproximateTerrainHeights } from \"../../ApproximateTerrainHeights\";\nimport { IModelApp } from \"../../IModelApp\";\nimport { RealityMeshParams, RealityMeshParamsBuilder } from \"../../render/RealityMeshParams\";\nimport {\n GeographicTilingScheme, MapTile, MapTilingScheme, QuadId, ReadMeshArgs, RequestMeshDataArgs, TerrainMeshProvider,\n TerrainMeshProviderOptions, Tile, TileAvailability,\n} from \"../internal\";\nimport { ScreenViewport } from \"../../Viewport\";\n\n/** @internal */\nenum QuantizedMeshExtensionIds {\n OctEncodedNormals = 1,\n WaterMask = 2,\n Metadata = 4,\n}\n\n/** Return the URL for a Cesium ion asset from its asset ID and request Key.\n * @public\n */\nexport function getCesiumAssetUrl(osmAssetId: number, requestKey: string): string {\n return `$CesiumIonAsset=${osmAssetId}:${requestKey}`;\n}\n\n/** @internal */\nexport function getCesiumOSMBuildingsUrl(): string | undefined {\n const key = IModelApp.tileAdmin.cesiumIonKey;\n if (undefined === key)\n return undefined;\n\n return getCesiumAssetUrl(+CesiumIonAssetId.OSMBuildings, key);\n}\n\n/** @internal */\nexport async function getCesiumAccessTokenAndEndpointUrl(assetId: string, requestKey?: string): Promise<{ token?: string, url?: string }> {\n if (undefined === requestKey) {\n requestKey = IModelApp.tileAdmin.cesiumIonKey;\n if (undefined === requestKey)\n return {};\n }\n\n const requestTemplate = `https://api.cesium.com/v1/assets/${assetId}/endpoint?access_token={CesiumRequestToken}`;\n const apiUrl: string = requestTemplate.replace(\"{CesiumRequestToken}\", requestKey);\n\n try {\n const apiResponse = await request(apiUrl, \"json\");\n if (undefined === apiResponse || undefined === apiResponse.url) {\n assert(false);\n return {};\n }\n return { token: apiResponse.accessToken, url: apiResponse.url };\n } catch {\n assert(false);\n return {};\n }\n}\n\nlet notifiedTerrainError = false;\n\n// Notify - once per session - of failure to obtain Cesium terrain provider.\nfunction notifyTerrainError(detailedDescription?: string): void {\n if (notifiedTerrainError)\n return;\n\n notifiedTerrainError = true;\n IModelApp.notifications.displayMessage(MessageSeverity.Information, IModelApp.localization.getLocalizedString(`iModelJs:BackgroundMap.CannotObtainTerrain`), detailedDescription);\n}\n\n/** @internal */\nexport async function getCesiumTerrainProvider(opts: TerrainMeshProviderOptions): Promise<TerrainMeshProvider | undefined> {\n const accessTokenAndEndpointUrl = await getCesiumAccessTokenAndEndpointUrl(opts.dataSource || CesiumTerrainAssetId.Default);\n if (!accessTokenAndEndpointUrl.token || !accessTokenAndEndpointUrl.url) {\n notifyTerrainError(IModelApp.localization.getLocalizedString(`iModelJs:BackgroundMap.MissingCesiumToken`));\n return undefined;\n }\n\n let layers;\n try {\n const layerRequestOptions: RequestOptions = { headers: { authorization: `Bearer ${accessTokenAndEndpointUrl.token}` } };\n const layerUrl = `${accessTokenAndEndpointUrl.url}layer.json`;\n layers = await request(layerUrl, \"json\", layerRequestOptions);\n } catch {\n notifyTerrainError();\n return undefined;\n }\n\n if (undefined === layers || undefined === layers.tiles || undefined === layers.version) {\n notifyTerrainError();\n return undefined;\n }\n\n const tilingScheme = new GeographicTilingScheme();\n let tileAvailability;\n // When collecting tiles, only the highest resolution tiles are downloaded.\n // Because of that, the tile availability is often only populated by the\n // \"layer\" metadata. (i.e. not from higher resolution tiles metadata).\n // Unfortunately the \"layer\" metadata only cover the first 16 levels,\n // preventing the geometry collector from accessing to higher resolution tiles.\n // For now, the solution is to turn off tile availability check when collecting geometries.\n if (undefined !== layers.available && !opts.produceGeometry) {\n const availableTiles = layers.available;\n tileAvailability = new TileAvailability(tilingScheme, availableTiles.length);\n for (let level = 0; level < layers.available.length; level++) {\n const rangesAtLevel = availableTiles[level];\n for (const range of rangesAtLevel) {\n tileAvailability.addAvailableTileRange(level, range.startX, range.startY, range.endX, range.endY);\n }\n }\n }\n\n let tileUrlTemplate = accessTokenAndEndpointUrl.url + layers.tiles[0].replace(\"{version}\", layers.version);\n if (opts.wantNormals)\n tileUrlTemplate = tileUrlTemplate.replace(\"?\", \"?extensions=octvertexnormals-watermask-metadata&\");\n\n const maxDepth = JsonUtils.asInt(layers.maxzoom, 19);\n\n // TBD -- When we have an API extract the heights for the project from the terrain tiles - for use temporary Bing elevation.\n return new CesiumTerrainProvider(opts, accessTokenAndEndpointUrl.token, tileUrlTemplate, maxDepth, tilingScheme, tileAvailability, layers.metadataAvailability);\n}\n\nfunction zigZagDecode(value: number) {\n return (value >> 1) ^ (-(value & 1));\n}\n\n/**\n * Decodes delta and ZigZag encoded vertices. This modifies the buffers in place.\n *\n * @see {@link https://github.com/AnalyticalGraphicsInc/quantized-mesh|quantized-mesh-1.0 terrain format}\n */\nfunction zigZagDeltaDecode(uBuffer: Uint16Array, vBuffer: Uint16Array, heightBuffer: Uint16Array) {\n const count = uBuffer.length;\n let u = 0;\n let v = 0;\n let height = 0;\n\n for (let i = 0; i < count; ++i) {\n u += zigZagDecode(uBuffer[i]);\n v += zigZagDecode(vBuffer[i]);\n\n uBuffer[i] = u;\n vBuffer[i] = v;\n\n height += zigZagDecode(heightBuffer[i]);\n heightBuffer[i] = height;\n }\n}\n\n/** @internal */\nclass CesiumTerrainProvider extends TerrainMeshProvider {\n private _accessToken: string;\n private readonly _tileUrlTemplate: string;\n private readonly _maxDepth: number;\n private readonly _wantSkirts: boolean;\n private readonly _tilingScheme: MapTilingScheme;\n private readonly _tileAvailability?: TileAvailability;\n private readonly _metaDataAvailableLevel?: number;\n private readonly _exaggeration: number;\n private readonly _assetId: string;\n\n private static _scratchQPoint2d = QPoint2d.fromScalars(0, 0);\n private static _scratchPoint2d = Point2d.createZero();\n private static _scratchPoint = Point3d.createZero();\n private static _scratchNormal = Vector3d.createZero();\n private static _scratchHeightRange = Range1d.createNull();\n private static _tokenTimeoutInterval = BeDuration.fromSeconds(60 * 30); // Request a new access token every 30 minutes...\n private _tokenTimeOut: BeTimePoint;\n\n public override forceTileLoad(tile: Tile): boolean {\n // Force loading of the metadata availability tiles as these are required for determining the availability of descendants.\n const mapTile = tile as MapTile;\n return undefined !== this._metaDataAvailableLevel && mapTile.quadId.level === this._metaDataAvailableLevel && !mapTile.everLoaded;\n }\n\n constructor(opts: TerrainMeshProviderOptions, accessToken: string, tileUrlTemplate: string, maxDepth: number, tilingScheme: MapTilingScheme,\n tileAvailability: TileAvailability | undefined, metaDataAvailableLevel: number | undefined) {\n super();\n this._wantSkirts = opts.wantSkirts;\n this._exaggeration = opts.exaggeration;\n\n this._accessToken = accessToken;\n this._tileUrlTemplate = tileUrlTemplate;\n this._maxDepth = maxDepth;\n this._tilingScheme = tilingScheme;\n this._tileAvailability = tileAvailability;\n this._metaDataAvailableLevel = metaDataAvailableLevel;\n this._assetId = opts.dataSource || CesiumTerrainAssetId.Default;\n\n this._tokenTimeOut = BeTimePoint.now().plus(CesiumTerrainProvider._tokenTimeoutInterval);\n }\n\n /** @deprecated in 5.0 Use [addAttributions] instead. */\n public override addLogoCards(cards: HTMLTableElement): void {\n if (cards.dataset.cesiumIonLogoCard)\n return;\n\n cards.dataset.cesiumIonLogoCard = \"true\";\n let notice = IModelApp.localization.getLocalizedString(\"iModelJs:BackgroundMap.CesiumWorldTerrainAttribution\");\n if (this._assetId === CesiumTerrainAssetId.Bathymetry)\n notice = `${notice}\\n${IModelApp.localization.getLocalizedString(\"iModelJs:BackgroundMap.CesiumBathymetryAttribution\")}`;\n\n const card = IModelApp.makeLogoCard({ iconSrc: `${IModelApp.publicPath}images/cesium-ion.svg`, heading: \"Cesium Ion\", notice });\n cards.appendChild(card);\n }\n\n public override async addAttributions(cards: HTMLTableElement, _vp: ScreenViewport): Promise<void> {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return Promise.resolve(this.addLogoCards(cards));\n }\n\n\n public get maxDepth(): number { return this._maxDepth; }\n public get tilingScheme(): MapTilingScheme { return this._tilingScheme; }\n\n public override isTileAvailable(quadId: QuadId) {\n if (quadId.level > this.maxDepth)\n return false;\n\n return this._tileAvailability ? this._tileAvailability.isTileAvailable(quadId.level, quadId.column, quadId.row) : true;\n }\n\n public override async requestMeshData(args: RequestMeshDataArgs): Promise<Uint8Array | undefined> {\n const tile = args.tile;\n const quadId = tile.quadId;\n const tileUrl = this.constructUrl(quadId.row, quadId.column, quadId.level);\n const requestOptions: RequestOptions = {\n headers: {\n authorization: `Bearer ${this._accessToken}`,\n accept: \"application/vnd.quantized-mesh;\" /* extensions=octvertexnormals, */ + \"application/octet-stream;q=0.9,*/*;q=0.01\",\n },\n };\n\n try {\n const response = await request(tileUrl, \"arraybuffer\", requestOptions);\n return new Uint8Array(response);\n } catch {\n return undefined;\n }\n }\n\n public override async readMesh(args: ReadMeshArgs): Promise<RealityMeshParams | undefined> {\n // ###TODO why does he update the access token when reading the mesh instead of when requesting it?\n // This function only returns undefined if it fails to acquire token - but it doesn't need the token...\n if (BeTimePoint.now().milliseconds > this._tokenTimeOut.milliseconds) {\n const accessTokenAndEndpointUrl = await getCesiumAccessTokenAndEndpointUrl(this._assetId);\n if (!accessTokenAndEndpointUrl.token || args.isCanceled())\n return undefined;\n\n this._accessToken = accessTokenAndEndpointUrl.token;\n this._tokenTimeOut = BeTimePoint.now().plus(CesiumTerrainProvider._tokenTimeoutInterval);\n }\n\n const { data, tile } = args;\n assert(data instanceof Uint8Array);\n assert(tile instanceof MapTile);\n\n const blob = data;\n const streamBuffer = ByteStream.fromUint8Array(blob);\n const center = nextPoint3d64FromByteStream(streamBuffer);\n const quadId = QuadId.createFromContentId(tile.contentId);\n const skirtHeight = this.getLevelMaximumGeometricError(quadId.level + 1) * 10.0; // Add 1 to level to restore height calculation to before the quadId level was from root. (4326 unification)\n const minHeight = this._exaggeration * streamBuffer.readFloat32();\n const maxHeight = this._exaggeration * streamBuffer.readFloat32();\n const boundCenter = nextPoint3d64FromByteStream(streamBuffer);\n const boundRadius = streamBuffer.readFloat64();\n const horizonOcclusion = nextPoint3d64FromByteStream(streamBuffer);\n const terrainTile = tile;\n\n terrainTile.adjustHeights(minHeight, maxHeight);\n\n if (undefined === center || undefined === boundCenter || undefined === boundRadius || undefined === horizonOcclusion) { }\n const pointCount = streamBuffer.readUint32();\n const encodedVertexBuffer = new Uint16Array(blob.buffer, streamBuffer.curPos, pointCount * 3);\n streamBuffer.advance(pointCount * 6);\n\n const uBuffer = encodedVertexBuffer.subarray(0, pointCount);\n const vBuffer = encodedVertexBuffer.subarray(pointCount, 2 * pointCount);\n const heightBuffer = encodedVertexBuffer.subarray(pointCount * 2, 3 * pointCount);\n\n zigZagDeltaDecode(uBuffer, vBuffer, heightBuffer);\n\n // ###TODO: This alleges to handle 32-bit indices, but RealityMeshParams uses a Uint16Array to store indices...\n const typedArray = pointCount > 0xffff ? Uint32Array : Uint16Array;\n const bytesPerIndex = typedArray.BYTES_PER_ELEMENT;\n const triangleElements = 3;\n\n // skip over any additional padding that was added for 2/4 byte alignment\n if (streamBuffer.curPos % bytesPerIndex !== 0)\n streamBuffer.advance(bytesPerIndex - (streamBuffer.curPos % bytesPerIndex));\n\n const triangleCount = streamBuffer.readUint32();\n const indexCount = triangleCount * triangleElements;\n\n const getIndexArray = (numIndices: number) => {\n const indexArray = new typedArray(streamBuffer.arrayBuffer, streamBuffer.curPos, numIndices);\n streamBuffer.advance(numIndices * bytesPerIndex);\n return indexArray;\n };\n\n const indices = getIndexArray(indexCount);\n\n // High water mark decoding based on decompressIndices_ in webgl-loader's loader.js.\n // https://code.google.com/p/webgl-loader/source/browse/trunk/samples/loader.js?r=99#55\n // Copyright 2012 Google Inc., Apache 2.0 license.\n let highest = 0;\n const length = indices.length;\n for (let i = 0; i < length; ++i) {\n const code = indices[i];\n indices[i] = highest - code;\n if (code === 0) {\n ++highest;\n }\n }\n\n CesiumTerrainProvider._scratchHeightRange.low = minHeight - skirtHeight;\n CesiumTerrainProvider._scratchHeightRange.high = maxHeight;\n const projection = terrainTile.getProjection(CesiumTerrainProvider._scratchHeightRange);\n const uvScale = 1.0 / 32767.0;\n const heightScale = uvScale * (maxHeight - minHeight);\n\n const westCount = streamBuffer.readUint32(),\n westIndices = getIndexArray(westCount),\n southCount = streamBuffer.readUint32(),\n southIndices = getIndexArray(southCount),\n eastCount = streamBuffer.readUint32(),\n eastIndices = getIndexArray(eastCount),\n northCount = streamBuffer.readUint32(),\n northIndices = getIndexArray(northCount);\n\n // Extensions...\n let encodedNormalsBuffer;\n while (streamBuffer.curPos < streamBuffer.length) {\n const extensionId = streamBuffer.readUint8();\n const extensionLength = streamBuffer.readUint32();\n switch (extensionId) {\n case QuantizedMeshExtensionIds.OctEncodedNormals:\n assert(pointCount * 2 === extensionLength);\n encodedNormalsBuffer = new Uint8Array(streamBuffer.arrayBuffer, streamBuffer.curPos, extensionLength);\n streamBuffer.advance(extensionLength);\n break;\n\n case QuantizedMeshExtensionIds.Metadata:\n const stringLength = streamBuffer.readUint32();\n if (stringLength > 0) {\n const strData = streamBuffer.nextBytes(stringLength);\n const str = utf8ToString(strData);\n if (undefined !== str) {\n const metaData = JSON.parse(str);\n if (undefined !== metaData.available && undefined !== this._tileAvailability) {\n const availableTiles = metaData.available;\n for (let offset = 0; offset < availableTiles.length; ++offset) {\n const availableLevel = tile.depth + offset; // Our depth is includes root (1 + cesium Depth)\n const rangesAtLevel = availableTiles[offset];\n\n for (const range of rangesAtLevel)\n this._tileAvailability.addAvailableTileRange(availableLevel, range.startX, range.startY, range.endX, range.endY);\n }\n }\n }\n }\n\n break;\n default:\n streamBuffer.advance(extensionLength);\n break;\n }\n }\n\n let initialIndexCapacity = indexCount;\n let initialVertexCapacity = pointCount;\n if (this._wantSkirts) {\n initialIndexCapacity += 6 * (Math.max(0, northCount - 1) + Math.max(0, southCount - 1) + Math.max(0, eastCount - 1) + Math.max(0, westCount - 1));\n initialVertexCapacity += (northCount + southCount + eastCount + westCount);\n }\n\n const wantNormals = undefined !== encodedNormalsBuffer;\n const builder = new RealityMeshParamsBuilder({\n positionRange: projection.localRange,\n initialIndexCapacity,\n initialVertexCapacity,\n wantNormals,\n });\n\n for (let i = 0; i < indexCount; i += 3)\n builder.addTriangle(indices[i], indices[i + 1], indices[i + 2]);\n\n const position = new Point3d();\n const uv = new QPoint2d();\n const normal = new Vector3d();\n const worldToEcef = tile.iModel.getEcefTransform().matrix;\n for (let i = 0; i < pointCount; i++) {\n const u = uBuffer[i];\n const v = vBuffer[i];\n projection.getPoint(uvScale * u, uvScale * v, minHeight + heightBuffer[i] * heightScale, position);\n uv.setFromScalars(u * 2, v * 2);\n let oen;\n if (encodedNormalsBuffer) {\n const normalIndex = i * 2;\n OctEncodedNormal.decodeValue(encodedNormalsBuffer[normalIndex + 1] << 8 | encodedNormalsBuffer[normalIndex], normal);\n worldToEcef.multiplyTransposeVector(normal, normal);\n oen = OctEncodedNormal.encode(normal);\n }\n\n builder.addVertex(position, uv, oen);\n }\n\n if (!this._wantSkirts)\n return builder.finish();\n\n westIndices.sort((a, b) => vBuffer[a] - vBuffer[b]);\n eastIndices.sort((a, b) => vBuffer[a] - vBuffer[b]);\n northIndices.sort((a, b) => uBuffer[a] - uBuffer[b]);\n southIndices.sort((a, b) => uBuffer[a] - uBuffer[b]);\n\n const generateSkirts = (indexes: Uint16Array | Uint32Array) => {\n const quv = new QPoint2d();\n const param = new Point2d();\n for (let i = 0; i < indexes.length; i++) {\n const index = indexes[i];\n const uvIndex = index * 2;\n const height = minHeight + heightBuffer[index] * heightScale;\n\n quv.setFromScalars(builder.uvs.buffer.at(uvIndex), builder.uvs.buffer.at(uvIndex + 1));\n builder.uvs.params.unquantize(quv.x, quv.y, param);\n\n const oen = wantNormals && builder.normals ? builder.normals.at(index) : undefined;\n builder.addVertex(projection.getPoint(param.x, param.y, height - skirtHeight), quv, oen);\n\n if (i !== 0) {\n const nextPointIndex = builder.positions.length;\n builder.addTriangle(index, indexes[i - 1], nextPointIndex - 2);\n builder.addTriangle(index, nextPointIndex - 2, nextPointIndex - 1);\n }\n }\n };\n\n generateSkirts(westIndices);\n generateSkirts(eastIndices);\n generateSkirts(southIndices);\n generateSkirts(northIndices);\n\n return builder.finish();\n }\n\n public constructUrl(row: number, column: number, zoomLevel: number): string {\n return this._tileUrlTemplate.replace(\"{z}\", zoomLevel.toString()).replace(\"{x}\", column.toString()).replace(\"{y}\", row.toString());\n }\n\n /**\n * Specifies the quality of terrain created from heightmaps. A value of 1.0 will\n * ensure that adjacent heightmap vertices are separated by no more than\n * screen pixels and will probably go very slowly.\n * A value of 0.5 will cut the estimated level zero geometric error in half, allowing twice the\n * screen pixels between adjacent heightmap vertices and thus rendering more quickly.\n * @type {Number}\n */\n public readonly heightmapTerrainQuality = 0.25;\n\n /**\n * Determines an appropriate geometric error estimate when the geometry comes from a heightmap.\n *\n * @param {Ellipsoid} ellipsoid The ellipsoid to which the terrain is attached.\n * @param {Number} tileImageWidth The width, in pixels, of the heightmap associated with a single tile.\n * @param {Number} numberOfTilesAtLevelZero The number of tiles in the horizontal direction at tile level zero.\n * @returns {Number} An estimated geometric error.\n */\n public getEstimatedLevelZeroGeometricErrorForAHeightmap(ellipsoidMaximumRadius = 6378137, tileImageWidth = 65, numberOfTilesAtLevelZero = 2) {\n return ellipsoidMaximumRadius * 2 * Math.PI * this.heightmapTerrainQuality / (tileImageWidth * numberOfTilesAtLevelZero);\n }\n\n public getLevelMaximumGeometricError(level: number) {\n return this.getEstimatedLevelZeroGeometricErrorForAHeightmap() / (1 << level);\n }\n\n public getHeightRange(parentRange: Range1d, quadId: QuadId): Range1d {\n const heightRange = quadId.level <= 6 ? ApproximateTerrainHeights.instance.getTileHeightRange(quadId) : undefined;\n\n return undefined === heightRange ? parentRange : heightRange;\n }\n}\n"]}