@arcgis/core 4.29.0 → 4.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/arcade/treeAnalysis.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{b43fde3e25d0c3b020b5.js → 039a872509872ce67ba4.js} +1 -1
- package/assets/esri/core/workers/chunks/{5243f9ff21e768c620c2.js → 23a5d750d93a7829174f.js} +1 -1
- package/assets/esri/core/workers/chunks/{47e6119be4a4a5ed640d.js → 2447a4d5886aeb0ff72a.js} +1 -1
- package/assets/esri/core/workers/chunks/{7f45a9e9bdbcffc2d6e0.js → 348bcc57b99a975902a8.js} +1 -1
- package/assets/esri/core/workers/chunks/{8c9fb2601488998013ba.js → 3523789a2948a4ab8cc8.js} +1 -1
- package/assets/esri/core/workers/chunks/{24649b410b757599a549.js → 48db6e0bbb1a9c043193.js} +1 -1
- package/assets/esri/core/workers/chunks/{752082be991f1cc8558f.js → 4984e2b79d862114d6a6.js} +1 -1
- package/assets/esri/core/workers/chunks/{8d9736fd15cdb54d9855.js → 5227f9eea6988aadad7f.js} +1 -1
- package/assets/esri/core/workers/chunks/58723274ef657fe212eb.js +1 -0
- package/assets/esri/core/workers/chunks/60ab18c6a04d4b2f1d4c.js +1 -0
- package/assets/esri/core/workers/chunks/647515801d94180b8402.js +1 -0
- package/assets/esri/core/workers/chunks/6c3ae96ec90e9ed7dd50.js +1 -0
- package/assets/esri/core/workers/chunks/7a8bba91769ee18cc39f.js +1 -0
- package/assets/esri/core/workers/chunks/7a98d2e026f63a581b1e.js +1 -0
- package/assets/esri/core/workers/chunks/8c360923cd1850767d3e.js +1 -0
- package/assets/esri/core/workers/chunks/{1a25ba411b89e050fbb7.js → a61f337802ae963d7f65.js} +1 -1
- package/assets/esri/core/workers/chunks/{d0c5318d7ef2e923aad0.js → a8ac511280f873960d46.js} +1 -1
- package/assets/esri/core/workers/chunks/b125ab84b7761e761734.js +1 -0
- package/assets/esri/core/workers/chunks/{b34d6e58b125fe111f91.js → b42a83db83851cb57d44.js} +1 -1
- package/assets/esri/core/workers/chunks/{1497dd943df7eede0704.js → b9c55ff1f21db198ce03.js} +1 -1
- package/assets/esri/core/workers/chunks/bb3322ddb89c0bd444f0.js +1 -0
- package/assets/esri/core/workers/chunks/becfdaeeb07f089d8be7.js +1 -0
- package/assets/esri/core/workers/chunks/{b26e39a399963c176d33.js → c527692694688a5b3b07.js} +2 -2
- package/assets/esri/core/workers/chunks/{210a93e0b96c5bff44a3.js → c556644bb0cf88770939.js} +1 -1
- package/assets/esri/core/workers/chunks/{a5e7b4acae17f88e2208.js → ce93027b6b81428ce9b0.js} +1 -1
- package/assets/esri/core/workers/chunks/{b8ece275abac93f3dccf.js → d14f16bfa6c12909929c.js} +1 -1
- package/assets/esri/core/workers/chunks/{1594f06a2d7d9439c62e.js → e2147c99cc5839654be1.js} +1 -1
- package/assets/esri/core/workers/chunks/{d33ed3a2a0d4b640bd4a.js → e4c7d8c69e4957c9d27c.js} +1 -1
- package/assets/esri/core/workers/chunks/{7709248f59520aee6f51.js → eceaa46f622f6fa31128.js} +1 -1
- package/assets/esri/core/workers/chunks/{2286db4c83ff1b6fb088.js → ef3e6209e6ac6a56960b.js} +1 -1
- package/assets/esri/core/workers/chunks/f59b5ea05caca8a1a398.js +1 -0
- package/chunks/Laserlines.glsl.js +3 -3
- package/chunks/Precipitation.glsl.js +1 -1
- package/chunks/SSAOBlur.glsl.js +2 -2
- package/chunks/boundedPlane.js +1 -1
- package/chunks/cameraUtilsSpherical.js +1 -1
- package/chunks/sphere.js +1 -1
- package/chunks/terrainUtilsPlanar.js +1 -1
- package/chunks/vec32.js +1 -1
- package/core/libs/gl-matrix-2/math/quat.js +1 -1
- package/core/libs/gl-matrix-2/math/vec3.js +1 -1
- package/core/libs/gl-matrix-2/vec3.js +1 -1
- package/geometry/support/axisAngleDegrees.js +1 -1
- package/geometry/support/coordinateSystem.js +1 -1
- package/geometry/support/lineSegment.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
- package/geometry/support/meshUtils/georeference.js +1 -1
- package/geometry/support/meshUtils/merge.js +1 -1
- package/geometry/support/meshUtils/rotate.js +1 -1
- package/geometry/support/meshUtils/scale.js +1 -1
- package/geometry/support/meshUtils/vertexSpaceConversion.js +5 -0
- package/geometry/support/meshVertexSpaceUtils.js +1 -1
- package/geometry/support/plane.js +1 -1
- package/geometry/support/ray.js +1 -1
- package/geometry/support/triangle.js +1 -1
- package/geometry/support/vector.js +1 -1
- package/interfaces.d.ts +6 -6
- package/kernel.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/layers/LinkChartLayer.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
- package/layers/mixins/FeatureReductionLayer.js +1 -1
- package/layers/orientedImagery/core/coverageUtils.js +1 -1
- package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
- package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
- package/layers/support/layerUtils.js +1 -1
- package/layers/video/VideoCameraSensorModel.js +1 -1
- package/layers/voxel/VoxelVolume.js +1 -1
- package/layers/voxel/voxelPlaneUtils.js +1 -1
- package/libs/linkchartlayout/LinkChartLayout.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/views/2d/arcade/callExpressionWithCursor.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/createTestMeshData.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/mesh/MeshWriterInputEvaluator.js +1 -1
- package/views/2d/interactive/editingTools/TransformTool.js +1 -1
- package/views/2d/interactive/editingTools/manipulations/ScaleManipulation.js +1 -1
- package/views/2d/layers/features/Processor.js +1 -1
- package/views/2d/layers/features/aggregation/GeohashSpatialIndex.js +1 -1
- package/views/2d/layers/features/aggregation/GridSpatialIndex.js +1 -1
- package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/StreamLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
- package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
- package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
- package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/DrillDownTileSourceChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/OverrideChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/PagedTileSourceChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/StreamSourceChunk.js +1 -1
- package/views/2d/layers/features/support/AttributeStore.js +1 -1
- package/views/2d/layers/features/support/FeatureMetadata.js +1 -1
- package/views/2d/layers/features/support/GraphicsReader.js +1 -1
- package/views/2d/layers/features/support/Tile.js +1 -1
- package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
- package/views/2d/tiling/TileKey.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionConstraintUtils.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
- package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementController.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
- package/views/3d/analysis/Slice/SliceTool.js +1 -1
- package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
- package/views/3d/analysis/support/measurementUtils.js +1 -1
- package/views/3d/animation/pointToPoint/Camera.js +1 -1
- package/views/3d/camera/constraintUtils/common.js +1 -1
- package/views/3d/camera/constraintUtils/distance.js +1 -1
- package/views/3d/camera/constraintUtils/tilt.js +1 -1
- package/views/3d/camera/intersectionUtils.js +1 -1
- package/views/3d/environment/ChapmanAtmosphere.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/environment/Fog.js +1 -1
- package/views/3d/environment/MarsAtmosphere.js +1 -1
- package/views/3d/environment/SceneViewEnvironmentManager.js +1 -1
- package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
- package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
- package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
- package/views/3d/interactive/editingTools/reshapeGraphic/edgeOffsetUtils.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ExtentScale.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/extentUtils.js +1 -1
- package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/support/Segment.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/PointCloudWorker.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/i3s/LoDUtil.js +1 -1
- package/views/3d/layers/i3s/PointRenderer.js +1 -1
- package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
- package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
- package/views/3d/layers/support/uvUtils.js +1 -1
- package/views/3d/state/Frustum.js +1 -1
- package/views/3d/state/NearFarHeuristic.js +1 -1
- package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
- package/views/3d/state/controllers/RotateController.js +1 -1
- package/views/3d/state/controllers/global/PinchAndPanController.js +1 -1
- package/views/3d/state/controllers/global/ZoomController.js +1 -1
- package/views/3d/state/controllers/global/ZoomStepController.js +1 -1
- package/views/3d/state/controllers/local/PinchAndPanController.js +1 -1
- package/views/3d/state/controllers/local/ZoomController.js +1 -1
- package/views/3d/state/controllers/local/ZoomStepController.js +1 -1
- package/views/3d/state/controllers/momentum/ZoomPlanarMomentumController.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/state/utils/viewUtils.js +1 -1
- package/views/3d/support/FrustumExtentIntersection.js +1 -1
- package/views/3d/support/cameraUtils.js +1 -1
- package/views/3d/support/cameraUtilsInternal.js +1 -1
- package/views/3d/support/intersectionUtils.js +1 -1
- package/views/3d/support/mathUtils.js +1 -1
- package/views/3d/support/orientedBoundingBox.js +1 -1
- package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/Focus.js +1 -1
- package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
- package/views/3d/support/sunUtils.js +1 -1
- package/views/3d/support/viewpointUtils.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/PatchRenderData.js +1 -1
- package/views/3d/terrain/SphericalPatch.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/webgl-engine/collections/Component/DepthRange.js +1 -1
- package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/core/util/TwoVectorPosition.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
- package/views/3d/webgl-engine/lib/BoundingInfo.js +1 -1
- package/views/3d/webgl-engine/lib/Camera.js +1 -1
- package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
- package/views/3d/webgl-engine/lib/Object3D.js +1 -1
- package/views/3d/webgl-engine/lib/Octree.js +1 -1
- package/views/3d/webgl-engine/lib/PathVertex.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js +1 -1
- package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
- package/views/3d/webgl-engine/lib/intersectorUtils.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
- package/views/3d/webgl-engine/lighting/SceneLighting.js +1 -1
- package/views/3d/webgl-engine/lighting/SphericalHarmonics.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/pbrUtils.js +1 -1
- package/views/SelectionManager.js +1 -1
- package/views/draw/support/createUtils.js +1 -1
- package/views/draw/support/surfaceCoordinateSystems.js +1 -1
- package/views/interactive/GraphicManipulator.js +1 -1
- package/views/interactive/SegmentLabels.js +1 -1
- package/views/interactive/coordinateHelper.js +1 -1
- package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
- package/views/interactive/editGeometry/support/editPlaneUtils.js +1 -1
- package/views/interactive/sketch/constraints.js +1 -1
- package/views/interactive/snapping/RightAngleSnapper.js +1 -1
- package/views/interactive/snapping/candidates/ParallelLineSnappingCandidate.js +1 -1
- package/views/interactive/snapping/candidates/RightAngleTriangleSnappingCandidate.js +1 -1
- package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.js +1 -1
- package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js +1 -1
- package/views/interactive/snapping/hints/IntersectionSnappingHint.js +1 -1
- package/views/interactive/snapping/hints/LineSnappingHint.js +1 -1
- package/views/interactive/snapping/hints/ParallelSnappingHint.js +1 -1
- package/views/interactive/snapping/hints/PointSnappingHint.js +1 -1
- package/views/interactive/snapping/hints/RightAngleSnappingHint.js +1 -1
- package/views/layers/FeatureLayerView.js +1 -1
- package/views/navigation/PanSphericalMomentumEstimator.js +1 -1
- package/views/support/angularMeasurementUtils.js +1 -1
- package/views/support/euclideanAreaMeasurementUtils.js +1 -1
- package/views/support/euclideanLengthMeasurementUtils.js +1 -1
- package/views/support/geometry3dUtils.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/Grid/Grid.js +1 -1
- package/widgets/FeatureTable/support/ColumnTemplateBase.js +1 -1
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
- package/widgets/PanoramicViewer/utils.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/support/Selector2D/SelectionOperation.js +1 -1
- package/widgets/support/Selector2D/selectorUtils.js +1 -1
- package/assets/esri/core/workers/chunks/0e83f3718a0b45652b5e.js +0 -1
- package/assets/esri/core/workers/chunks/1fa5c8af69a09a3730b3.js +0 -1
- package/assets/esri/core/workers/chunks/4736f79b5c94ce103d43.js +0 -1
- package/assets/esri/core/workers/chunks/65f7adaaf1f535310c11.js +0 -1
- package/assets/esri/core/workers/chunks/79c041b292648c5eaecc.js +0 -1
- package/assets/esri/core/workers/chunks/7c4c2c0beddabac672b6.js +0 -1
- package/assets/esri/core/workers/chunks/9307d485a9e5f9fa77d1.js +0 -1
- package/assets/esri/core/workers/chunks/9a758de08dfa57735879.js +0 -1
- package/assets/esri/core/workers/chunks/a4c3da057ec2a07bbbe8.js +0 -1
- package/assets/esri/core/workers/chunks/b252270b100351779f1f.js +0 -1
- package/assets/esri/core/workers/chunks/dc57aa9f2fc69e654559.js +0 -1
package/views/3d/terrain/Tile.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{clamp as e}from"../../../core/mathUtils.js";import{abortMaybe as t}from"../../../core/maybe.js";import i from"../../../core/ObjectPool.js";import{f as s,o as n,j as r,h as a,g as o,l,c as h}from"../../../chunks/vec32.js";import{create as u,unitZ as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getEpsilon as c}from"../../../core/libs/gl-matrix-2/math/common.js";import{getReferenceEllipsoid as g}from"../../../geometry/ellipsoidUtils.js";import{create as p,equals as f}from"../../../geometry/support/aaBoundingRect.js";import{d as _,g as m}from"../../../chunks/sphere.js";import{isGroupLayer as y}from"../../../layers/support/layerUtils.js";import{VectorTile as A}from"../../2d/engine/vectorTiles/VectorTile.js";import{ImageWithType as M}from"../support/StreamDataLoader.js";import{ElevationBounds as T}from"./ElevationBounds.js";import{ElevationTileAgent as v}from"./ElevationTileAgent.js";import{TextureUpdate as E}from"./interfaces.js";import{TileFrustumVisibility as I,NeighborIndex as D}from"./ITile.js";import{LayerClasses as L,LayerClass as x}from"./LayerClass.js";import{MapTileAgent as S}from"./MapTileAgent.js";import{RasterTile as O}from"./RasterTile.js";import{maxPatchTesselation as N,getElevationDesiredResolutionLevel as b}from"./TerrainConst.js";import{weakAssert as j,getLayerWithExtentRange as U,isBlendableLayerView as C,oppositeCorner as B,internalAssert as P,enableTerrainInternalChecks as R,neighborEdgeIndices as V,oppositeEdge as w,neighborCornerIndices as G,isNorth as W,isSouth as q,isWest as F,isEast as H,enableWaterproofnessTests as k,almostEquals as X,isWestCorner as Y,isNorthCorner as z}from"./terrainUtils.js";import{tileAgentDone as $}from"./TileAgent.js";import{TilePerLayerInfo as J}from"./TilePerLayerInfo.js";import Q from"./TileTexture.js";import{TileUpdate as K}from"./TileUpdate.js";import{fallsWithinLayer as Z}from"./tileUtils.js";const ee=.1;class te{constructor(){this._lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this.renderData=null,this._dirty=!0,this._previouslyRendered=!1,this.extent=p(),this._elevationBoundsMin=NaN,this._elevationBoundsMax=0,this.layerInfo=[[],[]],this.extentInRadians=p(),this.centerAtSeaLevel=u(),this._center=[u(),_(),u()],this.up=d(),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=null,this._mapTileMemoryInternal=0,this._mapDataRefCount=0,this.screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0,this.extentMidX=0,this.extentMidY=0,this.distanceToPOI=-1,this._lastPOI=u(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0}get lij(){return this._lij}static prune(){ne.prune(0),re.prune(0),J.prune()}get _isCached(){return!this.isLeaf&&this._mapDataRefCount<=0}get maxTesselation(){return this._maxTesselation}get isWithinClippingArea(){return this._isWithinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBoundsMin(){return this._elevationBoundsMin}get elevationBoundsMax(){return this._elevationBoundsMax}get level(){return this._lij[0]}get key(){return`${this._lij[0]}/${this._lij[1]}/${this._lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[oe.MIDDLE][3]}get visible(){return this._dirty&&this.computeVisibility(),this._visible}get frustumVisibility(){return this._dirty&&this.computeVisibility(),this._frustumVisibility}computeVisibility(){this._dirty=!1;const e=this.parent,t=e?.frustumVisibility??I.INTERSECTS;this._frustumVisibility=t===I.INSIDE?I.INSIDE:t===I.OUTSIDE?I.OUTSIDE:this._calculateFrustumVisibilityStatus(this.surface.frustum);const i=this._frustumVisibility!==I.OUTSIDE&&this._intersectsClippingArea;i!==this._visible&&(this._visible=i,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setDirty(),this.updateAgentSuspension())}get loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}init(e,t,i,s,n){this._lij[0]=e,this._lij[1]=t,this._lij[2]=i,this.ellipsoid=g(n.tilingScheme.spatialReference),n.tilingScheme.getExtent(e,t,i,this.extent),n.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this.extentMidX=.5*(this.extent[0]+this.extent[2]),this.extentMidY=.5*(this.extent[1]+this.extent[3]),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,n.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[oe.MIDDLE][3]=0,this.elevationLevel=e,s&&!Number.isNaN(s.elevationBoundsMin)?(this._elevationBoundsMin=s.elevationBoundsMin,this._elevationBoundsMax=s.elevationBoundsMax):(this._elevationBoundsMin=0,this._elevationBoundsMax=0),this._pendingUpdates=0,this.renderData=null,this.screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=s,this.unsetChildren(),this._surface=n,this.updateVisibility(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0;for(const r of L){const e=n.numLayers(r),t=this.layerInfo[r];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=J.acquire(this._surface.upsampleInfoPool),r===x.ELEVATION&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(n.tilingScheme.pixelSize,N)}dispose(){j(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key);for(const e of L){for(const t of this.layerInfo[e])t.release();this.layerInfo[e].length=0}this._parent=null;for(let e=0;e<4;++e)this._children[e]=null;this._surface=null,this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this._isCached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){if(--this._mapDataRefCount,this._isCached){this.setMemoryDirty();const e=this._cachedMemory;e>0&&this._surface.upsampleMapCache.put(this.key,this,e)}}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this._ensureUsedMemory()+(this._isCached?0:this._mapTileMemoryInternal)}get _cachedMemory(){return this._isCached?this._mapTileMemory:0}get _mapTileMemory(){return this._ensureUsedMemory(),this.layerInfo[x.MAP].reduce(((e,t)=>e+(t instanceof A?t.usedMemory/t.referenced:0)),this._mapTileMemoryInternal)}get _cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(null!=this._usedMemory)return this._usedMemory;this._usedMemory=this._baseUsedMemory,this._mapTileMemoryInternal=0;let e=0;for(const{data:i}of this.layerInfo[x.MAP])i instanceof A?e+=this._getTerrainDataMemory(i):this._mapTileMemoryInternal+=this._getTerrainDataMemory(i);const t=this._cpuImageMemorySize;for(const i of this.layerInfo[x.ELEVATION])this._usedMemory+=i.data?t:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._mapTileMemoryInternal+=this.renderData.texture?.usedMemory??0),this._isCached&&this._surface.upsampleMapCache.updateSize(this.key,this,this._mapTileMemoryInternal+e),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?e===x.MAP?this._isCached?0:this._getTerrainDataMemory(i.data):e===x.ELEVATION?this._cpuImageMemorySize:0:0}_getTerrainDataMemory(e){return e instanceof Q?e.texture.usedMemory:e instanceof HTMLImageElement||e instanceof M?this._cpuImageMemorySize:e instanceof O?e.memoryUsage:e instanceof A?e.usedMemory/e.referenced:0}updateScreenDepth(e){const t=this._center[oe.MIDDLE],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this.screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,t,i){if(!this.visible)return K.NONE;if(e.frustum&&(!this._intersectsClippingArea||this._calculateFrustumVisibilityStatus(e.frustum)===I.OUTSIDE))return K.NONE;const h=this.level;s(pe,m(this._center[oe.MIDDLE]),t);let u=n(pe),d=pe,c=m(this._center[oe.MIDDLE]);s(fe,this._center[oe.TOP],t);const g=n(fe);g<u&&(u=g,d=fe,c=this._center[oe.TOP]),s(_e,this._center[oe.BOTTOM],t);const p=n(_e);if(p<u&&(u=p,d=_e,c=this._center[oe.BOTTOM]),this._edgeLen2>u&&h<e.maxLod)return K.SPLIT;const f=Math.sqrt(u),_=e.fovX*f*2,y=this._edgeLen/_,A=()=>{if(h<e.maxLod)return this.elevationLevel=h,K.NONE;const t=h+Math.ceil(-Math.log2(e.relativeWidthLimit/y));return t!==this.elevationLevel?(this.elevationLevel=t,K.ELEVATION):K.NONE},M=null!=i?i-h:1/0;if(M<=.5)return A();const T=r(this.up,pe),v=this._elevationBoundsMax-this._elevationBoundsMin,E=v/this.edgeLen;if(e.aboveGround&&T>0&&E<.001){if(T/f-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-E>0)return K.NONE}const D=null!=i?3-Math.min(M,2):1;if(y*D<e.relativeWidthLimit||h>=e.maxLod)return A();if(h<7)return K.SPLIT;a(me,this.up,T),s(me,me,d);const L=n(me);if(L<=this.radius*this.radius)return K.SPLIT;a(me,me,this.radius/Math.sqrt(L)),o(me,me,c),s(me,t,me);const x=Math.min(1,(Math.abs(r(me,this.up))+.5*v+this._curvatureHeight)/l(me)),S=ee/e.angledSplitBias,O=e.fovY*f*2;return x*(this._edgeLen/O*D)<S*e.relativeHeightLimit?K.NONE:K.SPLIT}setChildren(e,t,i,s){j(!!(e&&t&&i&&s),"Null child passed");const n=this._children;return n[0]=e,n[1]=t,n[2]=i,n[3]=s,n}unsetChildren(){this._children[0]=null,this._children[1]=null,this._children[2]=null,this._children[3]=null}get isLoaded(){return this.renderData?.hasGeometry??!1}load(){this.refMapData();for(const e of L)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(e){e.unloadTile(this);for(const t of L){const e=this.layerInfo[t];for(const t of e)t.loadingAgent&&t.loadingAgent!==$&&(se(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0}this.resetPendingUpdate(K.GEOMETRY),this.resetPendingUpdate(K.TEXTURE_NOFADING),this.resetPendingUpdate(K.TEXTURE_FADING),this.unrefMapData()}unloadMapData(){const e=this.layerInfo[x.MAP];for(const t of e)t.loadingAgent&&t.loadingAgent!==$&&(se(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0;this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(f(e,this._clippingArea))return!1;const t=this._intersectsClippingArea,i=this._isWithinClippingArea;null!=e?(this._intersectsClippingArea=this.intersectsExtent(e),this._isWithinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._isWithinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const s=i&&this._isWithinClippingArea,n=!(i||t||this._isWithinClippingArea||this._intersectsClippingArea);return!this.renderData||s||n||this.setPendingUpdate(K.GEOMETRY),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i?.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of L){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==$&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(K.SPLIT)||e!==x.ELEVATION&&!this.loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){const t=this._pendingUpdates;return this._pendingUpdates|=e,e===K.SPLIT||e===K.MERGE?this._surface.setTileTreeDirty():this._surface.requestUpdate(),t!==this._pendingUpdates}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,i,s){const n=this.layerInfo[i][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated){console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e);const t=n.data&&"type"in n.data&&"vector-tile"===n.data.type;return s.dataArrived(this,t),!0}if(n.requestPromise)return!0;t(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,i,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get isLeaf(){return null==this._children[0]}hasLij(e){return this._lij[0]===e[0]&&this._lij[1]===e[1]&&this._lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;const t=this._children;if(!t[0])return null;return t[0].findByLij(e)||t[1].findByLij(e)||t[2].findByLij(e)||t[3].findByLij(e)}distanceToSquared(e){return n(s(me,m(this._center[oe.MIDDLE]),e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}containsPointXY(e,t){const i=this.extent;return e>=i[0]&&t>=i[1]&&e<=i[2]&&t<=i[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);j(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=null!=i&&"type"in i&&"vector-tile"===i.type,n=this.layerInfo[t][e];n.data=i,n.dataInvalidated=!1,n.waitingAgents.forAll((e=>e.dataArrived(this,s))),n.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t,i){i.notInTilemap||console.error(`Tile ${this._lij.toString()} layer ${t}/${e} error ${i}`);const s=this.layerInfo[t][e];s.dataMissing=!0,s.waitingAgents.forAll((e=>e.dataMissing())),s.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t,i){switch(i&&this.forEachLoadedNeighbor((i=>i.updateRenderData(e,t))),e){case x.MAP:return this._updateTexture(t);case x.ELEVATION:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===E.FADING?K.TEXTURE_NOFADING:K.TEXTURE_FADING),this.setPendingUpdate(e===E.FADING?K.TEXTURE_FADING:K.TEXTURE_NOFADING))}_updateGeometry(){this.setPendingUpdate(K.GEOMETRY);for(const e of this.layerInfo[x.ELEVATION])e.pendingUpdates|=K.GEOMETRY}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax;let i=1/0,s=-1/0;const n=this.layerInfo[x.ELEVATION];let r=!0;for(const a of n)null!=a.elevationBounds&&(i=Math.min(i,a.elevationBounds.min),s=Math.max(s,a.elevationBounds.max),a.elevationBounds.hasNoDataValues||(r=!1));r&&(i=Math.min(i,0),s=Math.max(s,0)),e===i&&t===s||(this._elevationBoundsMin=i,this._elevationBoundsMax=s,this.updateRadiusAndCenter(),this._surface.setTileTreeDirty())}_updateCenter(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax,i=.5*(e+t),s=this._center;a(me,this.up,i),o(m(s[oe.MIDDLE]),this.centerAtSeaLevel,me),a(me,this.up,e),o(s[oe.TOP],this.centerAtSeaLevel,me),a(me,this.up,t),o(s[oe.BOTTOM],this.centerAtSeaLevel,me)}findElevationBoundsForLayer(e,t){const i=this.layerInfo[x.ELEVATION][e],s=b(this.level),n=Math.max(this.elevationLevel-s,0),r=i.elevationBounds;if(null!=r&&r.level>=t&&r.level<=n)return;const a=this._surface.layerViewByIndex(e,x.ELEVATION),o=U(a);if(!Z(this,o,!1))return;const l=ae;let h=!1;const u=i.data;if(u&&u.level<=n){const e=i.data;l.min=e.samplerData.data.minValue,l.max=e.samplerData.data.maxValue,l.hasNoDataValues=e.samplerData.data.hasNoDataValues,l.level=this.level,h=!0}else{let t,i,r=0;for(let a=this._parent;a&&(!i||r<s)&&(r=this.elevationLevel-a.level,t=i||t,i=a.layerInfo[x.ELEVATION][e].data,!(!i&&t&&a.level<=n));a=a.parent);i=i||t,i&&(i.computeMinMaxValue(this._lij[0],this._lij[1],this._lij[2],l),l.min!==1/0&&(l.level=i.level,h=!0))}h&&(null==i.elevationBounds&&(i.elevationBounds=new T),i.elevationBounds.copyFrom(l))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==$&&(se(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:J.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,E.FADING))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===$&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of L){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==$&&(i.loadingAgent.setSuspension(t),i.loadingAgent===$&&this.updateRenderData(e,E.FADING))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==$&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=$,i.data||null!=i.upsampleInfo||this._createOrUpdateAgents(e+1,t)}_hasBlendableAncestor(e){return"normal"!==e.blendMode||y(e.parent)&&this._hasBlendableAncestor(e.parent)}_hasBlendModes(e,t,i){for(let s=e;s<t;++s){const e=this._surface.layerViewByIndex(s,i);if(C(e)&&"normal"!==e?.layer?.blendMode||y(e?.layer?.parent)&&this._hasBlendableAncestor(e?.layer?.parent))return!0}return!1}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=this._isSuspended(t);for(let n=e;n<i.length;++n){const r=i[n];let a=!1;const o=this._surface.layerViewByIndex(n,t),l=U(o);if(r.loadingAgent?Z(this,l,!1)?(r.loadingAgent!==$&&r.loadingAgent.setSuspension(s),r.loadingAgent!==$&&(a=r.loadingAgent.update())):r.dispose():Z(this,l,!1)&&(r.loadingAgent=ie(this,n,t,s),a=r.loadingAgent.startLoading(),a?r.loadingAgent===$&&this.setPendingUpdate(K.GEOMETRY):(se(r.loadingAgent),r.loadingAgent=$)),r.loadingAgent===$&&this.updateRenderData(t,E.FADING),!this._hasBlendModes(e,i.length,t)&&a&&o.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationVerticesPerSide(t){const i=this.elevationLevel-this.level,s=Math.max(this.level-t,b(this.level)-i),n=e(1+(this.maxTesselation>>s),2,this.maxTesselation+1),r=this.getDefaultVerticesPerSide();return Math.max(n,r)}get test(){return{cachedMemory:this._cachedMemory}}_findLIJ(e,t){if(!e)return null;const i=this.surface.rootTiles;if(null!=i)for(const s of i)if(le(s,e)){let i=s,n=e[0]-i.level-1;for(;n>=0&&!i.isLeaf&&!t(i);){const t=e[1]>>n&1,s=e[2]>>n&1;i=i.children[2*t+s],n--}return t(i)?i:null}return null}findNeighborTile(e,t){const i=this._lij,s=this.getNeighborLIJ(i,e);return s?he(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=e===D.NORTH_EAST?1:e===D.NORTH_WEST?0:e===D.SOUTH_WEST?2:3;let s=this;for(;s.children[0]&&(!t||!t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,(e=>t(e)||e.level===this.level))?.findCorner(B(e),t)||null}forAllSubtreeOnSide(e,t){const i=e===D.NORTH?[0,1]:e===D.NORTH_EAST?[1]:e===D.EAST?[1,3]:e===D.SOUTH_EAST?[3]:e===D.SOUTH?[2,3]:e===D.SOUTH_WEST?[2]:e===D.WEST?[0,2]:[0],s=e=>{const n=e.children;!t(e)&&n[0]&&i.forEach((e=>s(n[e])))};s(this)}getNeighborEdgeStartVertexIndex(e,t){if(!t)return 0;const i=this.level-t.level;if(P(!R||i>=0),0===i)return 0;const s=2**i,n=1==(1&e),r=n?0:1,a=t.lij[r+1]*s,o=this._lij[r+1],l=o-a,h=n?s-1-l:l;return R&&(P(a<=o&&o<a+s),P(0<=h&&h<s)),h}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.isLoaded;V.forEach((t=>{const s=this.findNeighborTile(t,i);null!=s&&s!==this&&s.forAllSubtreeOnSide(w(t),(i=>!!i.isLoaded&&(e(i,t),!0)))})),G.forEach((t=>{const s=this.findNeighborTile(t,i)?.findCorner(B(t),(e=>e.isLoaded));P(!s||de(this,s,t)),s?.isLoaded&&e(s,t)}))}getNeighborLIJ(e,t){const i=W(t)?-1:q(t)?1:0,s=F(t)?-1:H(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this.wrapLIJ(n):n[2]<0?null:n}wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}get westNeighborWestExtent(){return this.extent[0]*(this.isWestEnd?-1:1)}get eastNeighborEastExtent(){return this.extent[2]*(this.isEastEnd?-1:1)}get isEastEnd(){return this._lij[2]===this.surface.lijEastEnd(this.level)-1}get isWestEnd(){return 0===this._lij[2]}get isNorthEnd(){return 0===this._lij[1]}get isSouthEnd(){const e=this.surface.extent,t=e?.[1]??null;return null!=t&&this.extent[1]+c()>=t}checkGeometryWaterproofness(){k&&(P(this.isLoaded),this.renderData?.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(W(e)&&t[3]+s>=i[3])return!1;if(q(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&F(e)&&t[0]-s<=i[0])&&!(!n&&H(e)&&t[2]+s>=i[2])}updateDistanceToPOI(e){const t=this._lastPOI;if(this.distanceToPOI>=0&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return;h(this._lastPOI,e);const i=this._center[oe.MIDDLE],s=e[0]-i[0],n=e[1]-i[1],r=e[2]-i[2];this.distanceToPOI=s*s+n*n+r*r}}function ie(e,t,i,s){const n=i===x.ELEVATION?re.acquire():ne.acquire();return n.init(e,t,i,s),n}function se(e){e.dispose(),e instanceof v?re.release(e):e instanceof S&&ne.release(e)}const ne=new i(S),re=new i(v),ae=new T;var oe;function le(e,t){const i=e.lij,s=t[0]-i[0];return!(s<0)&&(t[1]>>s===i[1]&&t[2]>>s===i[2])}function he(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function ue(e,t,i){if(null==e||null==t)return!1;if(0===e.level&&0===t.level){if(e.isEastEnd&&t.isWestEnd&&i===D.EAST)return!0;if(e.isWestEnd&&t.isEastEnd&&i===D.WEST)return!0}const s=Math.max(1e-6*(e.extent[2]-e.extent[0]),1);switch(i){case D.NORTH:return X(e.extent[3],t.extent[1],s);case D.SOUTH:return X(e.extent[1],t.extent[3],s);case D.EAST:return X(e.extent[2],t.extent[0],s)||X(e.extent[2],-t.extent[0],s);case D.WEST:return X(e.extent[0],t.extent[2],s)||X(e.extent[0],-t.extent[2],s)}}function de(e,t,i){return null!=e&&null!=t&&t!==e&&(e.level>=t.level?ce(e,t,i):ce(t,e,B(i)))}function ce(e,t,i){P(e.level>=t.level);const s=Y(i),n=z(i),r=e.extent,a=t.extent,o=[s?r[0]:r[2],n?r[3]:r[1]],l=[s?a[2]:a[0],n?a[1]:a[3]],h=1e-5*(r[2]-r[0]),u=X(o[0],l[0],h)||e.surface.isGlobal&&X(o[0],-l[0],h),d=X(o[1],l[1],h);if(u&&d)return!0;if(e.level===t.level)return P(!1),!1;if(!u&&!d)return P(!1),!1;const c=u?ge(a[1],a[3],r[1],r[3],h):ge(a[0],a[2],r[0],r[2],h);return P(c),c}function ge(e,t,i,s,n){return e-n<=i&&i<=s&&s<=t+n}!function(e){e[e.TOP=0]="TOP",e[e.MIDDLE=1]="MIDDLE",e[e.BOTTOM=2]="BOTTOM"}(oe||(oe={}));const pe=u(),fe=u(),_e=u(),me=u();export{oe as CenterPosition,te as Tile,de as isCornerNeighbor,ue as isEdgeNeighbor,he as lijEquals};
|
|
5
|
+
import{clamp as e}from"../../../core/mathUtils.js";import{abortMaybe as t}from"../../../core/maybe.js";import i from"../../../core/ObjectPool.js";import{f as s,p as n,k as r,h as a,g as o,l,c as h}from"../../../chunks/vec32.js";import{create as u,unitZ as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getEpsilon as c}from"../../../core/libs/gl-matrix-2/math/common.js";import{getReferenceEllipsoid as g}from"../../../geometry/ellipsoidUtils.js";import{create as p,equals as f}from"../../../geometry/support/aaBoundingRect.js";import{d as _,g as m}from"../../../chunks/sphere.js";import{isGroupLayer as y}from"../../../layers/support/layerUtils.js";import{VectorTile as A}from"../../2d/engine/vectorTiles/VectorTile.js";import{ImageWithType as M}from"../support/StreamDataLoader.js";import{ElevationBounds as T}from"./ElevationBounds.js";import{ElevationTileAgent as v}from"./ElevationTileAgent.js";import{TextureUpdate as E}from"./interfaces.js";import{TileFrustumVisibility as I,NeighborIndex as D}from"./ITile.js";import{LayerClasses as L,LayerClass as x}from"./LayerClass.js";import{MapTileAgent as S}from"./MapTileAgent.js";import{RasterTile as O}from"./RasterTile.js";import{maxPatchTesselation as N,getElevationDesiredResolutionLevel as b}from"./TerrainConst.js";import{weakAssert as j,getLayerWithExtentRange as U,isBlendableLayerView as C,oppositeCorner as B,internalAssert as P,enableTerrainInternalChecks as R,neighborEdgeIndices as V,oppositeEdge as w,neighborCornerIndices as G,isNorth as W,isSouth as q,isWest as F,isEast as H,enableWaterproofnessTests as k,almostEquals as X,isWestCorner as Y,isNorthCorner as z}from"./terrainUtils.js";import{tileAgentDone as $}from"./TileAgent.js";import{TilePerLayerInfo as J}from"./TilePerLayerInfo.js";import Q from"./TileTexture.js";import{TileUpdate as K}from"./TileUpdate.js";import{fallsWithinLayer as Z}from"./tileUtils.js";const ee=.1;class te{constructor(){this._lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this.renderData=null,this._dirty=!0,this._previouslyRendered=!1,this.extent=p(),this._elevationBoundsMin=NaN,this._elevationBoundsMax=0,this.layerInfo=[[],[]],this.extentInRadians=p(),this.centerAtSeaLevel=u(),this._center=[u(),_(),u()],this.up=d(),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=null,this._mapTileMemoryInternal=0,this._mapDataRefCount=0,this.screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0,this.extentMidX=0,this.extentMidY=0,this.distanceToPOI=-1,this._lastPOI=u(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0}get lij(){return this._lij}static prune(){ne.prune(0),re.prune(0),J.prune()}get _isCached(){return!this.isLeaf&&this._mapDataRefCount<=0}get maxTesselation(){return this._maxTesselation}get isWithinClippingArea(){return this._isWithinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBoundsMin(){return this._elevationBoundsMin}get elevationBoundsMax(){return this._elevationBoundsMax}get level(){return this._lij[0]}get key(){return`${this._lij[0]}/${this._lij[1]}/${this._lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[oe.MIDDLE][3]}get visible(){return this._dirty&&this.computeVisibility(),this._visible}get frustumVisibility(){return this._dirty&&this.computeVisibility(),this._frustumVisibility}computeVisibility(){this._dirty=!1;const e=this.parent,t=e?.frustumVisibility??I.INTERSECTS;this._frustumVisibility=t===I.INSIDE?I.INSIDE:t===I.OUTSIDE?I.OUTSIDE:this._calculateFrustumVisibilityStatus(this.surface.frustum);const i=this._frustumVisibility!==I.OUTSIDE&&this._intersectsClippingArea;i!==this._visible&&(this._visible=i,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setDirty(),this.updateAgentSuspension())}get loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}init(e,t,i,s,n){this._lij[0]=e,this._lij[1]=t,this._lij[2]=i,this.ellipsoid=g(n.tilingScheme.spatialReference),n.tilingScheme.getExtent(e,t,i,this.extent),n.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this.extentMidX=.5*(this.extent[0]+this.extent[2]),this.extentMidY=.5*(this.extent[1]+this.extent[3]),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,n.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[oe.MIDDLE][3]=0,this.elevationLevel=e,s&&!Number.isNaN(s.elevationBoundsMin)?(this._elevationBoundsMin=s.elevationBoundsMin,this._elevationBoundsMax=s.elevationBoundsMax):(this._elevationBoundsMin=0,this._elevationBoundsMax=0),this._pendingUpdates=0,this.renderData=null,this.screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=s,this.unsetChildren(),this._surface=n,this.updateVisibility(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0;for(const r of L){const e=n.numLayers(r),t=this.layerInfo[r];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=J.acquire(this._surface.upsampleInfoPool),r===x.ELEVATION&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(n.tilingScheme.pixelSize,N)}dispose(){j(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key);for(const e of L){for(const t of this.layerInfo[e])t.release();this.layerInfo[e].length=0}this._parent=null;for(let e=0;e<4;++e)this._children[e]=null;this._surface=null,this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this._isCached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){if(--this._mapDataRefCount,this._isCached){this.setMemoryDirty();const e=this._cachedMemory;e>0&&this._surface.upsampleMapCache.put(this.key,this,e)}}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this._ensureUsedMemory()+(this._isCached?0:this._mapTileMemoryInternal)}get _cachedMemory(){return this._isCached?this._mapTileMemory:0}get _mapTileMemory(){return this._ensureUsedMemory(),this.layerInfo[x.MAP].reduce(((e,t)=>e+(t instanceof A?t.usedMemory/t.referenced:0)),this._mapTileMemoryInternal)}get _cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(null!=this._usedMemory)return this._usedMemory;this._usedMemory=this._baseUsedMemory,this._mapTileMemoryInternal=0;let e=0;for(const{data:i}of this.layerInfo[x.MAP])i instanceof A?e+=this._getTerrainDataMemory(i):this._mapTileMemoryInternal+=this._getTerrainDataMemory(i);const t=this._cpuImageMemorySize;for(const i of this.layerInfo[x.ELEVATION])this._usedMemory+=i.data?t:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._mapTileMemoryInternal+=this.renderData.texture?.usedMemory??0),this._isCached&&this._surface.upsampleMapCache.updateSize(this.key,this,this._mapTileMemoryInternal+e),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?e===x.MAP?this._isCached?0:this._getTerrainDataMemory(i.data):e===x.ELEVATION?this._cpuImageMemorySize:0:0}_getTerrainDataMemory(e){return e instanceof Q?e.texture.usedMemory:e instanceof HTMLImageElement||e instanceof M?this._cpuImageMemorySize:e instanceof O?e.memoryUsage:e instanceof A?e.usedMemory/e.referenced:0}updateScreenDepth(e){const t=this._center[oe.MIDDLE],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this.screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,t,i){if(!this.visible)return K.NONE;if(e.frustum&&(!this._intersectsClippingArea||this._calculateFrustumVisibilityStatus(e.frustum)===I.OUTSIDE))return K.NONE;const h=this.level;s(pe,m(this._center[oe.MIDDLE]),t);let u=n(pe),d=pe,c=m(this._center[oe.MIDDLE]);s(fe,this._center[oe.TOP],t);const g=n(fe);g<u&&(u=g,d=fe,c=this._center[oe.TOP]),s(_e,this._center[oe.BOTTOM],t);const p=n(_e);if(p<u&&(u=p,d=_e,c=this._center[oe.BOTTOM]),this._edgeLen2>u&&h<e.maxLod)return K.SPLIT;const f=Math.sqrt(u),_=e.fovX*f*2,y=this._edgeLen/_,A=()=>{if(h<e.maxLod)return this.elevationLevel=h,K.NONE;const t=h+Math.ceil(-Math.log2(e.relativeWidthLimit/y));return t!==this.elevationLevel?(this.elevationLevel=t,K.ELEVATION):K.NONE},M=null!=i?i-h:1/0;if(M<=.5)return A();const T=r(this.up,pe),v=this._elevationBoundsMax-this._elevationBoundsMin,E=v/this.edgeLen;if(e.aboveGround&&T>0&&E<.001){if(T/f-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-E>0)return K.NONE}const D=null!=i?3-Math.min(M,2):1;if(y*D<e.relativeWidthLimit||h>=e.maxLod)return A();if(h<7)return K.SPLIT;a(me,this.up,T),s(me,me,d);const L=n(me);if(L<=this.radius*this.radius)return K.SPLIT;a(me,me,this.radius/Math.sqrt(L)),o(me,me,c),s(me,t,me);const x=Math.min(1,(Math.abs(r(me,this.up))+.5*v+this._curvatureHeight)/l(me)),S=ee/e.angledSplitBias,O=e.fovY*f*2;return x*(this._edgeLen/O*D)<S*e.relativeHeightLimit?K.NONE:K.SPLIT}setChildren(e,t,i,s){j(!!(e&&t&&i&&s),"Null child passed");const n=this._children;return n[0]=e,n[1]=t,n[2]=i,n[3]=s,n}unsetChildren(){this._children[0]=null,this._children[1]=null,this._children[2]=null,this._children[3]=null}get isLoaded(){return this.renderData?.hasGeometry??!1}load(){this.refMapData();for(const e of L)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(e){e.unloadTile(this);for(const t of L){const e=this.layerInfo[t];for(const t of e)t.loadingAgent&&t.loadingAgent!==$&&(se(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0}this.resetPendingUpdate(K.GEOMETRY),this.resetPendingUpdate(K.TEXTURE_NOFADING),this.resetPendingUpdate(K.TEXTURE_FADING),this.unrefMapData()}unloadMapData(){const e=this.layerInfo[x.MAP];for(const t of e)t.loadingAgent&&t.loadingAgent!==$&&(se(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0;this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(f(e,this._clippingArea))return!1;const t=this._intersectsClippingArea,i=this._isWithinClippingArea;null!=e?(this._intersectsClippingArea=this.intersectsExtent(e),this._isWithinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._isWithinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const s=i&&this._isWithinClippingArea,n=!(i||t||this._isWithinClippingArea||this._intersectsClippingArea);return!this.renderData||s||n||this.setPendingUpdate(K.GEOMETRY),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i?.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of L){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==$&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(K.SPLIT)||e!==x.ELEVATION&&!this.loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){const t=this._pendingUpdates;return this._pendingUpdates|=e,e===K.SPLIT||e===K.MERGE?this._surface.setTileTreeDirty():this._surface.requestUpdate(),t!==this._pendingUpdates}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,i,s){const n=this.layerInfo[i][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated){console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e);const t=n.data&&"type"in n.data&&"vector-tile"===n.data.type;return s.dataArrived(this,t),!0}if(n.requestPromise)return!0;t(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,i,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get isLeaf(){return null==this._children[0]}hasLij(e){return this._lij[0]===e[0]&&this._lij[1]===e[1]&&this._lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;const t=this._children;if(!t[0])return null;return t[0].findByLij(e)||t[1].findByLij(e)||t[2].findByLij(e)||t[3].findByLij(e)}distanceToSquared(e){return n(s(me,m(this._center[oe.MIDDLE]),e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}containsPointXY(e,t){const i=this.extent;return e>=i[0]&&t>=i[1]&&e<=i[2]&&t<=i[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);j(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=null!=i&&"type"in i&&"vector-tile"===i.type,n=this.layerInfo[t][e];n.data=i,n.dataInvalidated=!1,n.waitingAgents.forAll((e=>e.dataArrived(this,s))),n.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t,i){i.notInTilemap||console.error(`Tile ${this._lij.toString()} layer ${t}/${e} error ${i}`);const s=this.layerInfo[t][e];s.dataMissing=!0,s.waitingAgents.forAll((e=>e.dataMissing())),s.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t,i){switch(i&&this.forEachLoadedNeighbor((i=>i.updateRenderData(e,t))),e){case x.MAP:return this._updateTexture(t);case x.ELEVATION:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===E.FADING?K.TEXTURE_NOFADING:K.TEXTURE_FADING),this.setPendingUpdate(e===E.FADING?K.TEXTURE_FADING:K.TEXTURE_NOFADING))}_updateGeometry(){this.setPendingUpdate(K.GEOMETRY);for(const e of this.layerInfo[x.ELEVATION])e.pendingUpdates|=K.GEOMETRY}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax;let i=1/0,s=-1/0;const n=this.layerInfo[x.ELEVATION];let r=!0;for(const a of n)null!=a.elevationBounds&&(i=Math.min(i,a.elevationBounds.min),s=Math.max(s,a.elevationBounds.max),a.elevationBounds.hasNoDataValues||(r=!1));r&&(i=Math.min(i,0),s=Math.max(s,0)),e===i&&t===s||(this._elevationBoundsMin=i,this._elevationBoundsMax=s,this.updateRadiusAndCenter(),this._surface.setTileTreeDirty())}_updateCenter(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax,i=.5*(e+t),s=this._center;a(me,this.up,i),o(m(s[oe.MIDDLE]),this.centerAtSeaLevel,me),a(me,this.up,e),o(s[oe.TOP],this.centerAtSeaLevel,me),a(me,this.up,t),o(s[oe.BOTTOM],this.centerAtSeaLevel,me)}findElevationBoundsForLayer(e,t){const i=this.layerInfo[x.ELEVATION][e],s=b(this.level),n=Math.max(this.elevationLevel-s,0),r=i.elevationBounds;if(null!=r&&r.level>=t&&r.level<=n)return;const a=this._surface.layerViewByIndex(e,x.ELEVATION),o=U(a);if(!Z(this,o,!1))return;const l=ae;let h=!1;const u=i.data;if(u&&u.level<=n){const e=i.data;l.min=e.samplerData.data.minValue,l.max=e.samplerData.data.maxValue,l.hasNoDataValues=e.samplerData.data.hasNoDataValues,l.level=this.level,h=!0}else{let t,i,r=0;for(let a=this._parent;a&&(!i||r<s)&&(r=this.elevationLevel-a.level,t=i||t,i=a.layerInfo[x.ELEVATION][e].data,!(!i&&t&&a.level<=n));a=a.parent);i=i||t,i&&(i.computeMinMaxValue(this._lij[0],this._lij[1],this._lij[2],l),l.min!==1/0&&(l.level=i.level,h=!0))}h&&(null==i.elevationBounds&&(i.elevationBounds=new T),i.elevationBounds.copyFrom(l))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==$&&(se(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:J.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,E.FADING))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===$&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of L){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==$&&(i.loadingAgent.setSuspension(t),i.loadingAgent===$&&this.updateRenderData(e,E.FADING))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==$&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=$,i.data||null!=i.upsampleInfo||this._createOrUpdateAgents(e+1,t)}_hasBlendableAncestor(e){return"normal"!==e.blendMode||y(e.parent)&&this._hasBlendableAncestor(e.parent)}_hasBlendModes(e,t,i){for(let s=e;s<t;++s){const e=this._surface.layerViewByIndex(s,i);if(C(e)&&"normal"!==e?.layer?.blendMode||y(e?.layer?.parent)&&this._hasBlendableAncestor(e?.layer?.parent))return!0}return!1}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=this._isSuspended(t);for(let n=e;n<i.length;++n){const r=i[n];let a=!1;const o=this._surface.layerViewByIndex(n,t),l=U(o);if(r.loadingAgent?Z(this,l,!1)?(r.loadingAgent!==$&&r.loadingAgent.setSuspension(s),r.loadingAgent!==$&&(a=r.loadingAgent.update())):r.dispose():Z(this,l,!1)&&(r.loadingAgent=ie(this,n,t,s),a=r.loadingAgent.startLoading(),a?r.loadingAgent===$&&this.setPendingUpdate(K.GEOMETRY):(se(r.loadingAgent),r.loadingAgent=$)),r.loadingAgent===$&&this.updateRenderData(t,E.FADING),!this._hasBlendModes(e,i.length,t)&&a&&o.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationVerticesPerSide(t){const i=this.elevationLevel-this.level,s=Math.max(this.level-t,b(this.level)-i),n=e(1+(this.maxTesselation>>s),2,this.maxTesselation+1),r=this.getDefaultVerticesPerSide();return Math.max(n,r)}get test(){return{cachedMemory:this._cachedMemory}}_findLIJ(e,t){if(!e)return null;const i=this.surface.rootTiles;if(null!=i)for(const s of i)if(le(s,e)){let i=s,n=e[0]-i.level-1;for(;n>=0&&!i.isLeaf&&!t(i);){const t=e[1]>>n&1,s=e[2]>>n&1;i=i.children[2*t+s],n--}return t(i)?i:null}return null}findNeighborTile(e,t){const i=this._lij,s=this.getNeighborLIJ(i,e);return s?he(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=e===D.NORTH_EAST?1:e===D.NORTH_WEST?0:e===D.SOUTH_WEST?2:3;let s=this;for(;s.children[0]&&(!t||!t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,(e=>t(e)||e.level===this.level))?.findCorner(B(e),t)||null}forAllSubtreeOnSide(e,t){const i=e===D.NORTH?[0,1]:e===D.NORTH_EAST?[1]:e===D.EAST?[1,3]:e===D.SOUTH_EAST?[3]:e===D.SOUTH?[2,3]:e===D.SOUTH_WEST?[2]:e===D.WEST?[0,2]:[0],s=e=>{const n=e.children;!t(e)&&n[0]&&i.forEach((e=>s(n[e])))};s(this)}getNeighborEdgeStartVertexIndex(e,t){if(!t)return 0;const i=this.level-t.level;if(P(!R||i>=0),0===i)return 0;const s=2**i,n=1==(1&e),r=n?0:1,a=t.lij[r+1]*s,o=this._lij[r+1],l=o-a,h=n?s-1-l:l;return R&&(P(a<=o&&o<a+s),P(0<=h&&h<s)),h}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.isLoaded;V.forEach((t=>{const s=this.findNeighborTile(t,i);null!=s&&s!==this&&s.forAllSubtreeOnSide(w(t),(i=>!!i.isLoaded&&(e(i,t),!0)))})),G.forEach((t=>{const s=this.findNeighborTile(t,i)?.findCorner(B(t),(e=>e.isLoaded));P(!s||de(this,s,t)),s?.isLoaded&&e(s,t)}))}getNeighborLIJ(e,t){const i=W(t)?-1:q(t)?1:0,s=F(t)?-1:H(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this.wrapLIJ(n):n[2]<0?null:n}wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}get westNeighborWestExtent(){return this.extent[0]*(this.isWestEnd?-1:1)}get eastNeighborEastExtent(){return this.extent[2]*(this.isEastEnd?-1:1)}get isEastEnd(){return this._lij[2]===this.surface.lijEastEnd(this.level)-1}get isWestEnd(){return 0===this._lij[2]}get isNorthEnd(){return 0===this._lij[1]}get isSouthEnd(){const e=this.surface.extent,t=e?.[1]??null;return null!=t&&this.extent[1]+c()>=t}checkGeometryWaterproofness(){k&&(P(this.isLoaded),this.renderData?.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(W(e)&&t[3]+s>=i[3])return!1;if(q(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&F(e)&&t[0]-s<=i[0])&&!(!n&&H(e)&&t[2]+s>=i[2])}updateDistanceToPOI(e){const t=this._lastPOI;if(this.distanceToPOI>=0&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return;h(this._lastPOI,e);const i=this._center[oe.MIDDLE],s=e[0]-i[0],n=e[1]-i[1],r=e[2]-i[2];this.distanceToPOI=s*s+n*n+r*r}}function ie(e,t,i,s){const n=i===x.ELEVATION?re.acquire():ne.acquire();return n.init(e,t,i,s),n}function se(e){e.dispose(),e instanceof v?re.release(e):e instanceof S&&ne.release(e)}const ne=new i(S),re=new i(v),ae=new T;var oe;function le(e,t){const i=e.lij,s=t[0]-i[0];return!(s<0)&&(t[1]>>s===i[1]&&t[2]>>s===i[2])}function he(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function ue(e,t,i){if(null==e||null==t)return!1;if(0===e.level&&0===t.level){if(e.isEastEnd&&t.isWestEnd&&i===D.EAST)return!0;if(e.isWestEnd&&t.isEastEnd&&i===D.WEST)return!0}const s=Math.max(1e-6*(e.extent[2]-e.extent[0]),1);switch(i){case D.NORTH:return X(e.extent[3],t.extent[1],s);case D.SOUTH:return X(e.extent[1],t.extent[3],s);case D.EAST:return X(e.extent[2],t.extent[0],s)||X(e.extent[2],-t.extent[0],s);case D.WEST:return X(e.extent[0],t.extent[2],s)||X(e.extent[0],-t.extent[2],s)}}function de(e,t,i){return null!=e&&null!=t&&t!==e&&(e.level>=t.level?ce(e,t,i):ce(t,e,B(i)))}function ce(e,t,i){P(e.level>=t.level);const s=Y(i),n=z(i),r=e.extent,a=t.extent,o=[s?r[0]:r[2],n?r[3]:r[1]],l=[s?a[2]:a[0],n?a[1]:a[3]],h=1e-5*(r[2]-r[0]),u=X(o[0],l[0],h)||e.surface.isGlobal&&X(o[0],-l[0],h),d=X(o[1],l[1],h);if(u&&d)return!0;if(e.level===t.level)return P(!1),!1;if(!u&&!d)return P(!1),!1;const c=u?ge(a[1],a[3],r[1],r[3],h):ge(a[0],a[2],r[0],r[2],h);return P(c),c}function ge(e,t,i,s,n){return e-n<=i&&i<=s&&s<=t+n}!function(e){e[e.TOP=0]="TOP",e[e.MIDDLE=1]="MIDDLE",e[e.BOTTOM=2]="BOTTOM"}(oe||(oe={}));const pe=u(),fe=u(),_e=u(),me=u();export{oe as CenterPosition,te as Tile,de as isCornerNeighbor,ue as isEdgeNeighbor,he as lijEquals};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../../../../core/PooledArray.js";import{fromQuat as
|
|
5
|
+
import t from"../../../../../core/PooledArray.js";import{fromQuat as e,scale as r}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{conjugate as n}from"../../../../../core/libs/gl-matrix-2/math/quat.js";import{create as a}from"../../../../../core/libs/gl-matrix-2/factories/quatf64.js";import{k as s,z as c,u as l,s as f,m as i,c as u,t as m,g as b}from"../../../../../chunks/vec32.js";import{create as h}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{signedDistance as p}from"../../../../../geometry/support/plane.js";import{empty as g,within as d,union as j}from"../../lib/depthRange.js";function w(t,e){const r=g(),{eye:o,frustum:n,viewForward:a}=t;e.forAll((t=>{const e=null!=t.offsetObb?t.offsetObb:t.obb,l=s(c(C,e.center,o),a),f=e.projectedRadius(a);if(d(r,l-f)&&d(r,l+f))return;const i=M(e,n);if(-1===i)return;if(0===i)return k.far=l+f,k.near=l-f,void j(r,k);const u=x.pushNew();u.near=l-f,u.far=l+f,u.mask=i,u.object=t}));for(let l=0;l<x.length;l++){const t=x.data[l];if(d(r,t.near)&&d(r,t.far))continue;k.far=t.far,k.near=1/0;const e=R(null!=t.object.offsetObb?t.object.offsetObb:t.object.obb,o,y,(e=>{let r=O;for(let o=0;o<F&&e.length>0;o++){if(0==(t.mask&1<<o))continue;z(n[o],e,r);const a=e;e=r,r=a}for(let t=0;t<e.length;t+=3){f(q,e.data[t],e.data[t+1],e.data[t+2]);const r=s(c(q,q,o),a);k.near=Math.min(k.near,r)}}));0===e&&(k.near=0),j(r,k)}return x.length=0,r}const x=new t({allocator:t=>t||{near:1/0,far:-1/0,mask:0,object:null},deallocator:t=>(t.object=null,t)}),k=g(),q=h(),v=h(),y=new t({deallocator:null}),O=new t({deallocator:null});function z(t,e,r){r.length=0;const o=e.length-3;A(q,e,o);const n=p(t,q);n<=0&&(r.push(q[0]),r.push(q[1]),r.push(q[2]));let a=0,s=n;for(;a<o;a+=3){A(v,e,a);const o=p(t,v);if(s*o<0){i(q,v,q,o/(o-s)),P(r,q)}o<=0&&P(r,v),s=o,u(q,v)}if(s*n<0){A(v,e,o);i(q,v,q,n/(n-s)),P(r,q)}}function A(t,e,r){return f(t,e.data[r],e.data[r+1],e.data[r+2])}function P(t,e){t.push(e[0]),t.push(e[1]),t.push(e[2])}function R(t,o,a,s){n(B,t.quaternion),c(C,o,t.center),l(C,C,B);const i=t.halfSize,u=8*((C[0]<-i[0]?-1:C[0]>i[0]?1:0)+3*(C[1]<-i[1]?-1:C[1]>i[1]?1:0)+9*(C[2]<-i[2]?-1:C[2]>i[2]?1:0)+13),h=S[u];if(0===h)return h;e(N,t.quaternion),r(N,N,t.halfSize);const p=(e,r)=>{const o=S[u+r+1];return f(e,((1&o)<<1)-1,(2&o)-1,((4&o)>>1)-1),m(e,e,N),b(e,t.center,e)};return a.length=0,P(a,p(D,0)),P(a,p(E,1)),P(a,p(C,2)),P(a,p(G,3)),s(a),1===h?h:(a.length=0,P(a,D),P(a,G),P(a,p(C,4)),P(a,p(H,5)),s(a),2===h||(a.length=0,P(a,D),P(a,H),P(a,p(C,6)),P(a,E),s(a)),h)}const S=(()=>{const t=new Array(216);let e=0;const r=r=>{for(let o=0;o<r.length;o++)t[e+o]=r[o];e+=8};return r([3,0,6,2,3,1,5,4]),r([2,0,2,3,1,5,4,0]),r([3,1,0,2,3,7,5,4]),r([2,0,1,3,2,6,4,0]),r([1,0,1,3,2,0,0,0]),r([2,1,5,7,3,2,0,0]),r([3,2,0,1,3,7,6,4]),r([2,2,0,1,3,7,6,0]),r([3,3,0,1,5,7,6,2]),r([2,0,1,5,4,6,2,0]),r([1,0,1,5,4,0,0,0]),r([2,1,3,7,5,4,0,0]),r([1,0,2,6,4,0,0,0]),r([0,0,0,0,0,0,0,0]),r([1,1,3,7,5,0,0,0]),r([2,2,3,7,6,4,0,0]),r([1,2,3,7,6,0,0,0]),r([2,3,1,5,7,6,2,0]),r([3,4,0,1,5,7,6,2]),r([2,5,7,6,4,0,1,0]),r([3,5,0,1,3,7,6,4]),r([2,4,5,7,6,2,0,0]),r([1,4,5,7,6,0,0,0]),r([2,5,1,3,7,6,4,0]),r([3,6,0,2,3,7,5,4]),r([2,6,2,3,7,5,4,0]),r([3,7,6,2,3,1,5,4]),t})(),F=4;function M(t,e){let r=0;for(let o=0;o<F;o++){const n=t.intersectPlane(e[o]);if(n>0)return-1;0===n&&(r|=1<<o)}return r}const N=o(),B=a(),C=h(),D=h(),E=h(),G=h(),H=h();export{w as computeDepthRange};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{invert as t,transpose as n}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as
|
|
5
|
+
import{invert as t,transpose as n}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{z as e,t as s,F as i,s as a,n as m,c,k as p,b as r,o as h}from"../../../../../chunks/vec32.js";import{create as d}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as l}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as x}from"../../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as b}from"../../../../../geometry/support/FloatArray.js";import{compactIndices as _,getContinuousIndexArray as I}from"../../../../../geometry/support/Indices.js";import{ViewingMode as f}from"../../../../ViewingMode.js";import{componentMinimalSizeForIntersectionData as C,ComponentIntersectionData as u}from"./ComponentIntersectionData.js";import{Vertices as M}from"../../lib/Attribute.js";import{getVisibility as g}from"../../lib/ComponentUtils.js";import{computeInvDir as A,intersectAabbInvDir as j,intersectTriangles as y}from"../../materials/internal/MaterialUtil.js";class B{constructor(t,n,o){this.viewingMode=t,this.positionData=n,this._components=o,this._planetCenter=d(),this._planetNorth=d(),this._componentIndicesForBsp=null,this._componentBspNodes=[],this._aabb=[0,0,0,0,0,0],this._indices=n.indices?_(n.indices):I(n.positions.length/3),this._positions=n.positions,this._componentIntersectionData=new Array(o.count)}destroy(){this._positions=null,this._indices=null,this._componentIntersectionData.length=0,this._perComponentAabbs=null}getComponentAabb(t,n){const o=this._ensureComponentAabbs(),e=6*t;return n[0]=o[e],n[1]=o[e+1],n[2]=o[e+2],n[3]=o[e+3],n[4]=o[e+4],n[5]=o[e+5],n}getComponentAabbs(){return this._ensureComponentAabbs()}_ensureComponentAabbs(){return this._perComponentAabbs||(this._perComponentAabbs=this._computePerComponentAabbs()),this._perComponentAabbs}getComponentPositions(t,n){n.indices=this._indices,n.data=this._positions,n.stride=3,n.startIndex=this._components.offsets[t],n.endIndex=this._components.offsets[t+1]}intersect(o,p,r,h,d,l,x,b){const{position:_}=x,I=e(D,o,_),g=e(F,p,_),B=t(P,x.rotationScale);s(I,I,B),s(g,g,B);const v=n(R,B),k=new M(this._positions,3),z=this._indices,E=this._components.offsets,G=A(I,g,w);if(this.viewingMode===f.Global){const t=this._planetCenter;i(t,_),s(t,t,B);const n=this._planetNorth;a(n,0,0,1),s(n,n,B),m(n,n)}const L=c(U,I),O=c(V,g),S=e(q,g,I);m(S,S);const T=t=>{const n=this.getComponentAabb(t,N);if(null!=d){const n=d[t];null==h||b?(I[2]=L[2]-n,g[2]=O[2]-n):h.componentOffset=n}if(null==h||b||h.applyToAabb(n),!j(n,I,G,r))return;const o=E[t]/3,e=E[t+1]/3,i=(n,o,e)=>l(t,n,s(o,o,v),e);(null==h||b)&&e-o>C?(null==this._componentIntersectionData[t]&&(this._componentIntersectionData[t]=new u(this._indices,o,e,k)),this._componentIntersectionData[t].intersectRay(I,g,i)):y(I,g,o,e,z,k,void 0,h,i)};this._intersectComponents(T,b,I,g)}_intersectComponents(t,n,o,s){const i=this._components.pickability,a=this._components.visibility;if(this._components.visibility.componentCount<H){const n=n=>(g(i,n)&&t(n),!0);return void a.forEachComponent(n)}0===this._componentBspNodes.length&&this._generateComponentBspRoot();const c=this._componentIndicesForBsp,r=n=>{g(i,n)&&a.isVisible(n)&&t(n)},h=(t,n)=>{for(let o=t;o<n;++o)r(c[o])};if(n){let t=0;for(;t>=0;){const n=this._componentBspNodes[t],e=n.plane;if(!e||-1===n.child0&&-1===n.child1){h(n.minComponentIndexIndex,n.maxComponentIndexIndex);break}{h(n.minMidComponentIndexIndex,n.maxMidComponentIndexIndex);const s=p(e,o)-e[3];if(s<0){if(-1===n.child0){h(n.minComponentIndexIndex,n.minMidComponentIndexIndex);break}t=n.child0}else{if(!(s>0))break;if(-1===n.child1){h(n.maxMidComponentIndexIndex,n.maxComponentIndexIndex);break}t=n.child1}}}}else{const t=J;e(t,s,o),m(t,t);const n=this._componentBspNodes,i=e=>{const s=n[e],a=s.plane;if(!a||-1===s.child0&&-1===s.child1)h(s.minComponentIndexIndex,s.maxComponentIndexIndex);else{const n=p(a,o)-a[3],e=p(a,t);s.minComponentIndexIndex<s.minMidComponentIndexIndex&&(n<=0||e<0)&&(-1!==s.child0?i(s.child0):h(s.minComponentIndexIndex,s.minMidComponentIndexIndex)),h(s.minMidComponentIndexIndex,s.maxMidComponentIndexIndex),s.maxMidComponentIndexIndex<s.maxComponentIndexIndex&&(n>=0||e>0)&&(-1!==s.child1?i(s.child1):h(s.maxMidComponentIndexIndex,s.maxComponentIndexIndex))}};i(0)}}_generateComponentBspRoot(){const t=this._components.count,n=new Uint16Array(t);this._componentIndicesForBsp=n;for(let e=0;e<t;++e)n[e]=e;const o=this._ensureComponentAabbs(),s=this._planetCenter,d=this._planetNorth,x=G;i(x,s),m(x,x);r(L,d,x);const b=this._aabb,_=b[2],I=[];let C=0;const u=this._componentBspNodes;u.length=0;const M=(t,n)=>{const e=6*t,s=o[e],i=o[e+1],m=o[e+2],c=o[e+3],r=o[e+4],h=o[e+5],d=a(O,.5*(s+c),.5*(i+r),.5*(m+h)),l=.5*(c-s),x=.5*(r-i),b=.5*(h-m),_=Math.sqrt(l*l+x*x+b*b),I=n,f=n[3],C=p(I,d)-f;return Math.abs(C)>_?Math.sign(C):0},g=(t,e,s)=>{let i=1/0,a=1/0,m=1/0,c=-1/0,p=-1/0,r=-1/0;for(let h=e;h<s;++h){const t=6*n[h];i=Math.min(i,o[t]),c=Math.max(c,o[t+3]),a=Math.min(a,o[t+1]),p=Math.max(p,o[t+4]),m=Math.min(m,o[t+2]),r=Math.max(r,o[t+5])}t[0]=i,t[1]=a,t[2]=m,t[3]=c,t[4]=p,t[5]=r},A=this.viewingMode===f.Local;let j=!1;if(!A){const t=a(O,.5*(b[0]+b[3]),.5*(b[1]+b[4]),.5*(b[2]+b[5])),n=h(s,t);j=_>.5*n}const y=(t,o,i,h,x)=>{const b=u.length;let _;if(j||i>=T||o-t<S)_=new v(t,o,o,o,null);else{g(k,t,o);const h=k[0],x=k[1],f=k[2],C=k[3],u=k[4],j=C-h,B=u-x,w=l(),N=w;if(A)j>=B?(a(N,1,0,0),w[3]=-.5*(h+C)):(a(N,0,1,0),w[3]=-.5*(x+u));else{const t=z,n=E;a(t,.5*(h+C),.5*(x+u),f),e(t,t,s),m(t,t),r(n,t,d),m(n,n),j>=B?c(N,n):(r(N,n,t),m(N,N)),w[3]=p(N,s)}let D,F;{let e=t,s=o;for(;e<s;){const t=n[e];M(t,w)<0?++e:(--s,n[e]=n[s],n[s]=t)}D=e;let i=e;for(s=o;i<s;){const t=n[s-1];M(t,w)>0?--s:(n[s-1]=n[i],n[i]=t,++i)}F=s}_=new v(t,D,F,o,w),D>=t+S&&I.push((()=>y(t,D,i+1,b,!0))),o>=F+S&&I.push((()=>y(F,o,i+1,b,!1)))}if(u.push(_),-1!==h){const t=u[h];x?t.child0=b:t.child1=b}};for(I.push((()=>y(0,t,0,-1,!1)));C<I.length;){(0,I[C])(),++C}}_computePerComponentAabbs(){const t=this._components.count,n=b(6*t),o=this._indices,e=this._positions,s=this._components.offsets;let i=0,a=1/0,m=1/0,c=1/0,p=-1/0,r=-1/0,h=-1/0;for(let d=0;d<t;d++){const t=s[d],l=s[d+1];let x=1/0,b=1/0,_=1/0,I=-1/0,f=-1/0,C=-1/0;for(let n=t;n<l;n++){const t=3*o[n],s=e[t],i=e[t+1],a=e[t+2];x=Math.min(x,s),b=Math.min(b,i),_=Math.min(_,a),I=Math.max(I,s),f=Math.max(f,i),C=Math.max(C,a)}n[i++]=x,n[i++]=b,n[i++]=_,n[i++]=I,n[i++]=f,n[i++]=C,a=Math.min(a,x),m=Math.min(m,b),c=Math.min(c,_),p=Math.max(p,I),r=Math.max(r,f),h=Math.max(h,C)}return this._aabb[0]=a,this._aabb[1]=m,this._aabb[2]=c,this._aabb[3]=p,this._aabb[4]=r,this._aabb[5]=h,n}get positions(){return this._positions}get indices(){return this._indices}get aabb(){return this._ensureComponentAabbs(),this._aabb}}class v{constructor(t,n,o,e,s){this.minComponentIndexIndex=t,this.minMidComponentIndexIndex=n,this.maxMidComponentIndexIndex=o,this.maxComponentIndexIndex=e,this.plane=s,this.child0=-1,this.child1=-1}}const w=d(),N=x(),k=[0,0,0,0,0,0],D=d(),F=d(),P=o(),R=o(),U=d(),V=d(),q=d(),z=d(),E=d(),G=d(),L=d(),O=d(),S=5,T=10,H=7,J=d();export{B as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../../chunks/tslib.es6.js";import has from"../../../../../../core/has.js";import{releaseMaybe as t}from"../../../../../../core/maybe.js";import{invert as r,transpose as o}from"../../../../../../core/libs/gl-matrix-2/math/mat3.js";import{clone as s}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{H as a}from"../../../../../../chunks/vec32.js";import{fromArray as i,fromValues as l}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{v as n}from"../../../../../../chunks/vec42.js";import{fromValues as u}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ColorMixModeEnum as h}from"../../../../layers/support/symbolColorUtils.js";import{OverlayContent as p}from"../../../../terrain/OverlayContent.js";import{ComponentTechnique as c}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as d,IntegratedMeshMode as m}from"./ComponentTechniqueConfiguration.js";import{ComponentDataType as g}from"./shader/ComponentData.glsl.js";import{VertexDiscardMode as x}from"./shader/VertexDiscardByOpacity.glsl.js";import{MaterialBase as y,parameter as f,parameterBlock as b,MaterialParameterBlock as T}from"../../../core/material/MaterialBase.js";import{RenderPassIdentifier as v}from"../../../core/renderPasses/AllRenderPasses.js";import{ShaderOutput as M}from"../../../core/shaderLibrary/ShaderOutput.js";import{NormalType as O}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{NormalsDoubleSidedMode as C}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as w}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as S}from"../../../core/shaderLibrary/util/AlphaCutoff.js";import{EllipsoidMode as P}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{TwoVectorPosition as j}from"../../../core/util/TwoVectorPosition.js";import{AlphaDiscardMode as q,CullFaceOptions as N}from"../../../lib/basicInterfaces.js";import{TransparencyPassType as A}from"../../../lib/TransparencyPassType.js";import{defaultAdvancedMRRFactors as D}from"../../../materials/pbrUtils.js";class R extends y{constructor(e,t){super(),this.toMapSpace=t,this.baseColor=u(1,1,1,1),this.usePBR=!1,this.hasParametersFromSource=!1,this.mrrFactors=i(D),this.emissiveFactor=l(0,0,0),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null,this.objectOpacity=1,this.commonMaterialParameters=new W,this.componentParameters=new _,this.textureAlphaCutoff=S,this.alphaDiscardMode=q.Opaque,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=P.Earth,this.hasOccludees=!1,this._techniqueConfiguration=new d;const a=new j(e.position),n=s(e.rotationScale);r(n,n),o(n,n),this.transformNormalGlobalFromModel=n,this.transformWorldFromModelTL=a.low,this.transformWorldFromModelTH=a.high,this.transformWorldFromModelRS=e.rotationScale}dispose(){this._technique=t(this._technique),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null}get texture(){return null!=this.baseColorTexture?this.baseColorTexture.glTexture:null}get textureMetallicRoughness(){return null!=this.metallicRoughnessTexture?this.metallicRoughnessTexture.glTexture:null}get textureEmissive(){return null!=this.emissionTexture?this.emissionTexture.glTexture:null}get textureOcclusion(){return null!=this.occlusionTexture?this.occlusionTexture.glTexture:null}get textureNormal(){return null!=this.normalTexture?this.normalTexture.glTexture:null}prepareTechnique(e,t,r,o){const s=this._techniqueConfiguration;s.hasVertexColors=o.colors,s.hasNormals=o.hasNormals,s.textureCoordinateType=o.textureCoordinates,s.hasMetallicRoughnessTexture=null!=this.metallicRoughnessTexture,s.hasEmissionTexture=null!=this.emissionTexture,s.hasOcclusionTexture=null!=this.occlusionTexture,s.hasNormalTexture=null!=this.normalTexture,s.transparencyPassType=t.identifier===v.Material&&null!=r.transparencyPassType?r.transparencyPassType:A.NONE,s.multipassEnabled=t.identifier===v.Material&&r.multipassEnabled,s.cullAboveGround=t.identifier===v.Material&&r.multipassTerrain.cullAboveGround,s.ellipsoidMode=this.ellipsoidMode,s.componentData=this.componentParameters.type,s.cullFace=this.commonMaterialParameters.cullFace,s.doubleSidedMode=this.commonMaterialParameters.doubleSided?C.View:C.None,s.hasColorTexture=null!=this.baseColorTexture;const a=this._computeWhichMaterialPass();if(s.blendingEnabled=a===F.Transparent||a===F.OpaqueAndTransparent,s.alphaDiscardMode=this.alphaDiscardMode,s.integratedMeshMode=this.isIntegratedMesh?L(r)?B(r)?m.ColorOverlayWithWater:m.ColorOverlay:m.NoOverlay:m.None,s.hasPolygonOffset=this.polygonOffsetEnabled,s.pbrMode=s.integratedMeshMode===m.ColorOverlayWithWater?w.WaterOnIntegratedMesh:this.usePBR?this.hasParametersFromSource?has("enable-feature:im-shading")&&this.isIntegratedMesh?w.Simplified:w.Schematic:w.Normal:w.Disabled,s.normalType=o.needsNormals?s.hasNormals?O.Compressed:O.ScreenDerivative:O.Ground,s.hasSlicePlane=null!=r.slicePlane&&this.commonMaterialParameters.hasSlicePlane,t.identifier===v.ShadowMap)s.output=M.Shadow,s.vertexDiscardMode=x.None;else if(t.identifier===v.Highlight)s.output=M.Highlight,s.vertexDiscardMode=x.None;else{switch(a===F.OpaqueAndTransparent?s.vertexDiscardMode=t.transparent?x.Opaque:x.Transparent:s.vertexDiscardMode=x.None,s.output=t.output,s.receiveAmbientOcclusion=!1,s.receiveShadows=!1,t.output){case M.Color:s.receiveAmbientOcclusion=null!=r.ssao,s.hasOccludees=r.hasOccludees,s.receiveShadows=r.shadowMap.ready,s.hasScreenSpaceReflections=null!=r.ssr.lastFrameColor,s.hasCloudsReflections=null!=r.cloudsFade.data;break;case M.Alpha:s.hasOccludees=r.hasOccludees;break;case M.ObjectAndLayerIdColor:s.objectAndLayerIdColor=!0}s.snowCover=this.hasSnowCover(r)}return this._technique=e.releaseAndAcquire(c,s,this._technique),this._setClean(),this._technique}hasSnowCover(e){return null!=e.weather&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}submit(e,t,r){if(0===this.objectOpacity)return;const o=r.renderable.geometry,s=r.components,a=r.renderable.meta.cameraDepthSquared,i=s.geometryRanges,l=s.highlightRanges,n=s.defaultShadowMapRanges;switch(this._computeWhichMaterialPass()){case F.Opaque:e.materialOpaque.submitDraw(this,o,i,a);break;case F.Transparent:e.materialTransparent.submitDraw(this,o,i,a);break;case F.OpaqueAndTransparent:e.materialOpaque.submitDraw(this,o,i,a),e.materialTransparent.submitDraw(this,o,i,a);break;case F.IntegratedMesh:e.materialIntegratedMesh.submitDraw(this,o,i,a),k(t)&&e.highlightIntegratedMesh.submitDraw(this,o,i,a)}const u=this.componentParameters.castShadows!==I.None;u&&e.shadowMap.submitDraw(this,o,i,a),null!=l&&(e.highlight.submitDraw(this,o,l,a),u&&e.highlightShadowMap.submitDraw(this,o,l,a)),u&&null!=n&&e.defaultShadowMap.submitDraw(this,o,n,a)}_computeWhichMaterialPass(){return this.isIntegratedMesh?F.IntegratedMesh:this.objectOpacity<1?F.Transparent:this.componentParameters.opaqueOverride===I.All?F.Opaque:this.baseColor[3]<1||this.alphaDiscardMode===q.Blend||this.alphaDiscardMode===q.MaskBlend?F.Transparent:this.componentParameters.transparent===I.None?F.Opaque:this.componentParameters.transparent===I.All?F.Transparent:F.OpaqueAndTransparent}}var F,I;e([f({vectorOps:n})],R.prototype,"baseColor",void 0),e([f()],R.prototype,"usePBR",void 0),e([f()],R.prototype,"hasParametersFromSource",void 0),e([f({vectorOps:a})],R.prototype,"mrrFactors",void 0),e([f({vectorOps:a})],R.prototype,"emissiveFactor",void 0),e([f({dispose:!0})],R.prototype,"baseColorTexture",void 0),e([f({dispose:!0})],R.prototype,"metallicRoughnessTexture",void 0),e([f({dispose:!0})],R.prototype,"emissionTexture",void 0),e([f({dispose:!0})],R.prototype,"occlusionTexture",void 0),e([f({dispose:!0})],R.prototype,"normalTexture",void 0),e([f()],R.prototype,"objectOpacity",void 0),e([b()],R.prototype,"commonMaterialParameters",void 0),e([b()],R.prototype,"componentParameters",void 0),e([f()],R.prototype,"textureAlphaCutoff",void 0),e([f()],R.prototype,"alphaDiscardMode",void 0),e([f()],R.prototype,"isIntegratedMesh",void 0),e([f()],R.prototype,"polygonOffsetEnabled",void 0),e([f()],R.prototype,"ellipsoidMode",void 0),e([f()],R.prototype,"hasOccludees",void 0),function(e){e[e.Opaque=0]="Opaque",e[e.Transparent=1]="Transparent",e[e.OpaqueAndTransparent=2]="OpaqueAndTransparent",e[e.IntegratedMesh=3]="IntegratedMesh"}(F||(F={}));class W extends T{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=N.Back,this.hasSlicePlane=!0}}e([f()],W.prototype,"doubleSided",void 0),e([f()],W.prototype,"cullFace",void 0),e([f()],W.prototype,"hasSlicePlane",void 0);class _ extends T{constructor(){super(...arguments),this.externalColor=u(1,1,1,1),this.externalColorMixMode=h.Multiply,this.castShadows=I.All}get transparent(){return this.externalColor[3]<1?I.All:I.None}get opaqueOverride(){return this.externalColorMixMode===h.Replace&&1===this.externalColor[3]?I.All:I.None}get visible(){return this.externalColor[3]>0?I.All:I.None}get type(){return g.Uniform}}e([f({vectorOps:n})],_.prototype,"externalColor",void 0),e([f()],_.prototype,"externalColorMixMode",void 0),e([f()],_.prototype,"castShadows",void 0),function(e){e[e.All=0]="All",e[e.Some=1]="Some",e[e.None=2]="None"}(I||(I={}));class E extends T{constructor(){super(...arguments),this.texture=null,this.transparent=I.None,this.opaqueOverride=I.None,this.castShadows=I.None}get type(){return g.Varying}}function k(e){return null!=e.overlay?.getTexture(p.Highlight)}function B(e){return null!=e.overlay?.getTexture(p.WaterNormal)}function L(e){return null!=e.overlay?.getTexture(p.ColorNoRasterImage)}e([f()],E.prototype,"texture",void 0),e([f()],E.prototype,"transparent",void 0),e([f()],E.prototype,"opaqueOverride",void 0),e([f()],E.prototype,"castShadows",void 0);export{W as CommonMaterialParameters,R as ComponentMaterial,I as ComponentParameterSummary,_ as ComponentParametersUniform,E as ComponentParametersVarying};
|
|
5
|
+
import{_ as e}from"../../../../../../chunks/tslib.es6.js";import has from"../../../../../../core/has.js";import{releaseMaybe as t}from"../../../../../../core/maybe.js";import{invert as r,transpose as o}from"../../../../../../core/libs/gl-matrix-2/math/mat3.js";import{clone as s}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{I as a}from"../../../../../../chunks/vec32.js";import{fromArray as i,fromValues as l}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{v as n}from"../../../../../../chunks/vec42.js";import{fromValues as u}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ColorMixModeEnum as h}from"../../../../layers/support/symbolColorUtils.js";import{OverlayContent as p}from"../../../../terrain/OverlayContent.js";import{ComponentTechnique as c}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as d,IntegratedMeshMode as m}from"./ComponentTechniqueConfiguration.js";import{ComponentDataType as g}from"./shader/ComponentData.glsl.js";import{VertexDiscardMode as x}from"./shader/VertexDiscardByOpacity.glsl.js";import{MaterialBase as y,parameter as f,parameterBlock as b,MaterialParameterBlock as T}from"../../../core/material/MaterialBase.js";import{RenderPassIdentifier as v}from"../../../core/renderPasses/AllRenderPasses.js";import{ShaderOutput as M}from"../../../core/shaderLibrary/ShaderOutput.js";import{NormalType as O}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{NormalsDoubleSidedMode as C}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as w}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as S}from"../../../core/shaderLibrary/util/AlphaCutoff.js";import{EllipsoidMode as P}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{TwoVectorPosition as j}from"../../../core/util/TwoVectorPosition.js";import{AlphaDiscardMode as q,CullFaceOptions as N}from"../../../lib/basicInterfaces.js";import{TransparencyPassType as A}from"../../../lib/TransparencyPassType.js";import{defaultAdvancedMRRFactors as D}from"../../../materials/pbrUtils.js";class R extends y{constructor(e,t){super(),this.toMapSpace=t,this.baseColor=u(1,1,1,1),this.usePBR=!1,this.hasParametersFromSource=!1,this.mrrFactors=i(D),this.emissiveFactor=l(0,0,0),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null,this.objectOpacity=1,this.commonMaterialParameters=new W,this.componentParameters=new _,this.textureAlphaCutoff=S,this.alphaDiscardMode=q.Opaque,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=P.Earth,this.hasOccludees=!1,this._techniqueConfiguration=new d;const a=new j(e.position),n=s(e.rotationScale);r(n,n),o(n,n),this.transformNormalGlobalFromModel=n,this.transformWorldFromModelTL=a.low,this.transformWorldFromModelTH=a.high,this.transformWorldFromModelRS=e.rotationScale}dispose(){this._technique=t(this._technique),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null}get texture(){return null!=this.baseColorTexture?this.baseColorTexture.glTexture:null}get textureMetallicRoughness(){return null!=this.metallicRoughnessTexture?this.metallicRoughnessTexture.glTexture:null}get textureEmissive(){return null!=this.emissionTexture?this.emissionTexture.glTexture:null}get textureOcclusion(){return null!=this.occlusionTexture?this.occlusionTexture.glTexture:null}get textureNormal(){return null!=this.normalTexture?this.normalTexture.glTexture:null}prepareTechnique(e,t,r,o){const s=this._techniqueConfiguration;s.hasVertexColors=o.colors,s.hasNormals=o.hasNormals,s.textureCoordinateType=o.textureCoordinates,s.hasMetallicRoughnessTexture=null!=this.metallicRoughnessTexture,s.hasEmissionTexture=null!=this.emissionTexture,s.hasOcclusionTexture=null!=this.occlusionTexture,s.hasNormalTexture=null!=this.normalTexture,s.transparencyPassType=t.identifier===v.Material&&null!=r.transparencyPassType?r.transparencyPassType:A.NONE,s.multipassEnabled=t.identifier===v.Material&&r.multipassEnabled,s.cullAboveGround=t.identifier===v.Material&&r.multipassTerrain.cullAboveGround,s.ellipsoidMode=this.ellipsoidMode,s.componentData=this.componentParameters.type,s.cullFace=this.commonMaterialParameters.cullFace,s.doubleSidedMode=this.commonMaterialParameters.doubleSided?C.View:C.None,s.hasColorTexture=null!=this.baseColorTexture;const a=this._computeWhichMaterialPass();if(s.blendingEnabled=a===F.Transparent||a===F.OpaqueAndTransparent,s.alphaDiscardMode=this.alphaDiscardMode,s.integratedMeshMode=this.isIntegratedMesh?L(r)?B(r)?m.ColorOverlayWithWater:m.ColorOverlay:m.NoOverlay:m.None,s.hasPolygonOffset=this.polygonOffsetEnabled,s.pbrMode=s.integratedMeshMode===m.ColorOverlayWithWater?w.WaterOnIntegratedMesh:this.usePBR?this.hasParametersFromSource?has("enable-feature:im-shading")&&this.isIntegratedMesh?w.Simplified:w.Schematic:w.Normal:w.Disabled,s.normalType=o.needsNormals?s.hasNormals?O.Compressed:O.ScreenDerivative:O.Ground,s.hasSlicePlane=null!=r.slicePlane&&this.commonMaterialParameters.hasSlicePlane,t.identifier===v.ShadowMap)s.output=M.Shadow,s.vertexDiscardMode=x.None;else if(t.identifier===v.Highlight)s.output=M.Highlight,s.vertexDiscardMode=x.None;else{switch(a===F.OpaqueAndTransparent?s.vertexDiscardMode=t.transparent?x.Opaque:x.Transparent:s.vertexDiscardMode=x.None,s.output=t.output,s.receiveAmbientOcclusion=!1,s.receiveShadows=!1,t.output){case M.Color:s.receiveAmbientOcclusion=null!=r.ssao,s.hasOccludees=r.hasOccludees,s.receiveShadows=r.shadowMap.ready,s.hasScreenSpaceReflections=null!=r.ssr.lastFrameColor,s.hasCloudsReflections=null!=r.cloudsFade.data;break;case M.Alpha:s.hasOccludees=r.hasOccludees;break;case M.ObjectAndLayerIdColor:s.objectAndLayerIdColor=!0}s.snowCover=this.hasSnowCover(r)}return this._technique=e.releaseAndAcquire(c,s,this._technique),this._setClean(),this._technique}hasSnowCover(e){return null!=e.weather&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}submit(e,t,r){if(0===this.objectOpacity)return;const o=r.renderable.geometry,s=r.components,a=r.renderable.meta.cameraDepthSquared,i=s.geometryRanges,l=s.highlightRanges,n=s.defaultShadowMapRanges;switch(this._computeWhichMaterialPass()){case F.Opaque:e.materialOpaque.submitDraw(this,o,i,a);break;case F.Transparent:e.materialTransparent.submitDraw(this,o,i,a);break;case F.OpaqueAndTransparent:e.materialOpaque.submitDraw(this,o,i,a),e.materialTransparent.submitDraw(this,o,i,a);break;case F.IntegratedMesh:e.materialIntegratedMesh.submitDraw(this,o,i,a),k(t)&&e.highlightIntegratedMesh.submitDraw(this,o,i,a)}const u=this.componentParameters.castShadows!==I.None;u&&e.shadowMap.submitDraw(this,o,i,a),null!=l&&(e.highlight.submitDraw(this,o,l,a),u&&e.highlightShadowMap.submitDraw(this,o,l,a)),u&&null!=n&&e.defaultShadowMap.submitDraw(this,o,n,a)}_computeWhichMaterialPass(){return this.isIntegratedMesh?F.IntegratedMesh:this.objectOpacity<1?F.Transparent:this.componentParameters.opaqueOverride===I.All?F.Opaque:this.baseColor[3]<1||this.alphaDiscardMode===q.Blend||this.alphaDiscardMode===q.MaskBlend?F.Transparent:this.componentParameters.transparent===I.None?F.Opaque:this.componentParameters.transparent===I.All?F.Transparent:F.OpaqueAndTransparent}}var F,I;e([f({vectorOps:n})],R.prototype,"baseColor",void 0),e([f()],R.prototype,"usePBR",void 0),e([f()],R.prototype,"hasParametersFromSource",void 0),e([f({vectorOps:a})],R.prototype,"mrrFactors",void 0),e([f({vectorOps:a})],R.prototype,"emissiveFactor",void 0),e([f({dispose:!0})],R.prototype,"baseColorTexture",void 0),e([f({dispose:!0})],R.prototype,"metallicRoughnessTexture",void 0),e([f({dispose:!0})],R.prototype,"emissionTexture",void 0),e([f({dispose:!0})],R.prototype,"occlusionTexture",void 0),e([f({dispose:!0})],R.prototype,"normalTexture",void 0),e([f()],R.prototype,"objectOpacity",void 0),e([b()],R.prototype,"commonMaterialParameters",void 0),e([b()],R.prototype,"componentParameters",void 0),e([f()],R.prototype,"textureAlphaCutoff",void 0),e([f()],R.prototype,"alphaDiscardMode",void 0),e([f()],R.prototype,"isIntegratedMesh",void 0),e([f()],R.prototype,"polygonOffsetEnabled",void 0),e([f()],R.prototype,"ellipsoidMode",void 0),e([f()],R.prototype,"hasOccludees",void 0),function(e){e[e.Opaque=0]="Opaque",e[e.Transparent=1]="Transparent",e[e.OpaqueAndTransparent=2]="OpaqueAndTransparent",e[e.IntegratedMesh=3]="IntegratedMesh"}(F||(F={}));class W extends T{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=N.Back,this.hasSlicePlane=!0}}e([f()],W.prototype,"doubleSided",void 0),e([f()],W.prototype,"cullFace",void 0),e([f()],W.prototype,"hasSlicePlane",void 0);class _ extends T{constructor(){super(...arguments),this.externalColor=u(1,1,1,1),this.externalColorMixMode=h.Multiply,this.castShadows=I.All}get transparent(){return this.externalColor[3]<1?I.All:I.None}get opaqueOverride(){return this.externalColorMixMode===h.Replace&&1===this.externalColor[3]?I.All:I.None}get visible(){return this.externalColor[3]>0?I.All:I.None}get type(){return g.Uniform}}e([f({vectorOps:n})],_.prototype,"externalColor",void 0),e([f()],_.prototype,"externalColorMixMode",void 0),e([f()],_.prototype,"castShadows",void 0),function(e){e[e.All=0]="All",e[e.Some=1]="Some",e[e.None=2]="None"}(I||(I={}));class E extends T{constructor(){super(...arguments),this.texture=null,this.transparent=I.None,this.opaqueOverride=I.None,this.castShadows=I.None}get type(){return g.Varying}}function k(e){return null!=e.overlay?.getTexture(p.Highlight)}function B(e){return null!=e.overlay?.getTexture(p.WaterNormal)}function L(e){return null!=e.overlay?.getTexture(p.ColorNoRasterImage)}e([f()],E.prototype,"texture",void 0),e([f()],E.prototype,"transparent",void 0),e([f()],E.prototype,"opaqueOverride",void 0),e([f()],E.prototype,"castShadows",void 0);export{W as CommonMaterialParameters,R as ComponentMaterial,I as ComponentParameterSummary,_ as ComponentParametersUniform,E as ComponentParametersVarying};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{c as t,
|
|
5
|
+
import{c as t,z as s,g as i,h as r}from"../../../../../chunks/vec32.js";import{create as h}from"../../../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";class e{constructor(t){this._low=o(),this._high=o(),t&&this.set(t)}get low(){return this._low}get high(){return this._high}set(i){t(this._low,t(c,i));const r=s(c,i,this._low);t(this._high,r)}get(t){return i(t,this._low,this._high)}getLowScaled(t){return r(t,this._low,1)}}const c=h();export{e as TwoVectorPosition};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../../../chunks/tslib.es6.js";import{unitRGBAFromColor as e}from"../../../../../core/colorUtils.js";import{smoothstep as i,clamp as s}from"../../../../../core/mathUtils.js";import{watch as a,syncAndInitial as r}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{n as c,s as n,
|
|
5
|
+
import{_ as t}from"../../../../../chunks/tslib.es6.js";import{unitRGBAFromColor as e}from"../../../../../core/colorUtils.js";import{smoothstep as i,clamp as s}from"../../../../../core/mathUtils.js";import{watch as a,syncAndInitial as r}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{n as c,s as n,k as p}from"../../../../../chunks/vec32.js";import{create as d}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ViewingMode as m}from"../../../../ViewingMode.js";import{SyncRenderPlugin as l,ConsumesHighlight as _}from"../RenderPlugin.js";import{defaultShadowOpacity as u,defaultShadowDifference as g,defaultShadowColor as f}from"./HighlightDefaults.js";import{ShadowHighlightPassParameters as w,ShadowHighlightTechnique as y}from"./ShadowHighlightTechnique.js";import{RenderSlot as x}from"../../lib/RenderSlot.js";const O=.001953125,b=4e4,v=5e4;let P=class extends l{constructor(t){super(t),this._maxOpacity=1,this._passParameters=new w,this._shadowDifference=.2,this._context=null,this.produces=new Map([[x.SHADOW_HIGHLIGHT,()=>this._isVisible]])}consumes(){return _}initializeRenderContext(t){this._context=t,this.addHandles([a((()=>this.view.highlightOptions.shadowOpacity),(t=>{this._passParameters.shadowOpacity=t??u,this._updateOccludedShadowOpacity(),this._updateMaxOpacity()}),r),a((()=>this.view.highlightOptions.shadowDifference),(t=>{this._shadowDifference=t??g,this._updateOccludedShadowOpacity(),this._updateMaxOpacity()}),r),a((()=>this.view.highlightOptions.shadowColor),(t=>{this._passParameters.shadowColor=e(t??f),this._updateMaxOpacity()}),r)])}_updateOccludedShadowOpacity(){this._passParameters.occludedShadowOpacity=this._passParameters.shadowOpacity*(1-this._shadowDifference)}_updateMaxOpacity(){const t=Math.max(this._passParameters.shadowOpacity,this._passParameters.occludedShadowOpacity);this._maxOpacity=t*this._passParameters.shadowColor[3]}uninitializeRenderContext(){this._context=null}enable(){this._context&&null==this._technique&&(this._technique=this._context.techniqueRepository.acquire(y))}renderNode(t,e,i,s){const a=i?.get("highlights")?.getTexture();if(!this._context||!a||!this._isVisible)return;if(!this._technique?.compiled)return void this._context.requestRender();const r=t.bindParameters;if(!r.shadowMap.enabled||!r.linearDepth)return;this._passParameters.highlight=a,this._passParameters.origin=r.camera.center;const o=t.rctx;o.bindFramebuffer(s?.fbo),o.bindTechnique(this._technique,r,this._passParameters),o.screen.draw()}updateParameters(t,e){this._passParameters.opacityElevation=1-i(b,v,t.relativeElevation);const a=this.viewingMode===m.Global?c(j,t.center):n(j,0,0,1),r=p(a,e);this._passParameters.dayNightTerminator=i(0,1,s(30*r,0,1)),this._isVisible&&this.enable()}get _isVisible(){const{opacityElevation:t,dayNightTerminator:e}=this._passParameters;return this._maxOpacity*t*e>=O}};t([o()],P.prototype,"_context",void 0),t([o()],P.prototype,"view",void 0),t([o()],P.prototype,"viewingMode",void 0),P=t([h("esri.views.3d.webgl-engine.effects.highlight.ShadowHighlight")],P);const j=d();export{P as ShadowHighlight};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import i from"../../../../core/PooledArray.js";import{
|
|
5
|
+
import i from"../../../../core/PooledArray.js";import{m as t,a as e}from"../../../../chunks/vec32.js";import{fromValues as s,clone as r,create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{assert as h}from"./Util.js";class o{constructor(i,e,o){this.primitiveIndices=i,this._numIndexPerPrimitive=e,this.position=o,this._children=void 0,h(i.length>=1),h(3===o.size||4===o.size);const{data:c,size:l,indices:m}=o;h(m.length%this._numIndexPerPrimitive==0),h(m.length>=i.length*this._numIndexPerPrimitive);const d=i.length;let u=l*m[this._numIndexPerPrimitive*i[0]];a.clear(),a.push(u);const f=s(c[u],c[u+1],c[u+2]),x=r(f);for(let t=0;t<d;++t){const e=this._numIndexPerPrimitive*i[t];for(let i=0;i<this._numIndexPerPrimitive;++i){u=l*m[e+i],a.push(u);let t=c[u];f[0]=Math.min(t,f[0]),x[0]=Math.max(t,x[0]),t=c[u+1],f[1]=Math.min(t,f[1]),x[1]=Math.max(t,x[1]),t=c[u+2],f[2]=Math.min(t,f[2]),x[2]=Math.max(t,x[2])}}this.bbMin=f,this.bbMax=x;const P=t(n(),this.bbMin,this.bbMax,.5);this.radius=.5*Math.max(Math.max(x[0]-f[0],x[1]-f[1]),x[2]-f[2]);let v=this.radius*this.radius;for(let t=0;t<a.length;++t){u=a.at(t);const i=c[u]-P[0],e=c[u+1]-P[1],s=c[u+2]-P[2],r=i*i+e*e+s*s;if(r<=v)continue;const n=Math.sqrt(r),h=.5*(n-this.radius);this.radius=this.radius+h,v=this.radius*this.radius;const o=h/n;P[0]+=i*o,P[1]+=e*o,P[2]+=s*o}this.center=P,a.clear()}getChildren(){if(this._children||e(this.bbMin,this.bbMax)<=1)return this._children;const i=t(n(),this.bbMin,this.bbMax,.5),s=this.primitiveIndices.length,r=new Uint8Array(s),h=new Array(8);for(let t=0;t<8;++t)h[t]=0;const{data:a,size:c,indices:l}=this.position;for(let t=0;t<s;++t){let e=0;const s=this._numIndexPerPrimitive*this.primitiveIndices[t];let n=c*l[s],o=a[n],m=a[n+1],d=a[n+2];for(let i=1;i<this._numIndexPerPrimitive;++i){n=c*l[s+i];const t=a[n],e=a[n+1],r=a[n+2];t<o&&(o=t),e<m&&(m=e),r<d&&(d=r)}o<i[0]&&(e|=1),m<i[1]&&(e|=2),d<i[2]&&(e|=4),r[t]=e,++h[e]}let m=0;for(let t=0;t<8;++t)h[t]>0&&++m;if(m<2)return;const d=new Array(8);for(let t=0;t<8;++t)d[t]=h[t]>0?new Uint32Array(h[t]):void 0;for(let t=0;t<8;++t)h[t]=0;for(let t=0;t<s;++t){const i=r[t];d[i][h[i]++]=this.primitiveIndices[t]}this._children=new Array;for(let t=0;t<8;++t)void 0!==d[t]&&this._children.push(new o(d[t],this._numIndexPerPrimitive,this.position));return this._children}static prune(){a.prune()}}const a=new i({deallocator:null});export{o as BoundingInfo};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../../chunks/tslib.es6.js";import i from"../../../../core/Accessor.js";import e from"../../../../core/Logger.js";import{lerp as r}from"../../../../core/mathUtils.js";import{createScreenPointArray as s,createRenderScreenPointArray3 as o}from"../../../../core/screenUtils.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{copy as a,multiply as p,frustum as u,equals as _,invert as l,transpose as c,lookAt as v}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as w}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{copy as d,exactEquals as y}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as g}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{f as m,s as f,p as x,c as M,i as T,y as D,j,w as R,v as P,h as F,l as O,b as V,n as C,D as b}from"../../../../chunks/vec32.js";import{create as S}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{d as I,e as E,a as L,c as H,f as G,t as B}from"../../../../chunks/vec42.js";import{fromValues as A,create as U}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as k,copy as z,fromMatrix as W}from"../../../../geometry/support/frustum.js";import{create as X}from"../../../../geometry/support/ray.js";import{projectPointSignedLength as Y}from"../../../../geometry/support/vector.js";import{ViewingMode as q}from"../../../ViewingMode.js";import{fovd2fovx as N,fovx2fovd as J,fovd2fovy as K,fovy2fovd as Q}from"./fov.js";var Z;let $=Z=class extends i{constructor(t){super(t),this._ray=X(),this._viewport=A(0,0,1,1),this._padding=A(0,0,0,0),this._fov=55/180*Math.PI,this._nearFar=g(1,1e3),this._viewDirty=!0,this._viewMatrix=w(),this._viewProjectionDirty=!0,this._viewProjectionMatrix=w(),this._viewInverseTransposeMatrixDirty=!0,this._viewInverseTransposeMatrix=w(),this._frustumDirty=!0,this._frustum=k(),this._fullViewport=U(),this._pixelRatio=1,this.row=0,this.column=0,this._rows=1,this._columns=1,this._center=S(),this._up=S(),this.relativeElevation=0}get pixelRatio(){return this._pixelRatio}set pixelRatio(t){this._pixelRatio=t>0?t:1}get rows(){return this._rows}set rows(t){this._rows=Math.max(1,t)}get columns(){return this._columns}set columns(t){this._columns=Math.max(1,t)}get eye(){return this._ray.origin}set eye(t){this._compareAndSetView(t,this._ray.origin)}get center(){return this._center}set center(t){this._compareAndSetView(t,this._center,"_center")}get ray(){return m(this._ray.direction,this.center,this.eye),this._ray}get up(){return this._up}set up(t){this._compareAndSetView(t,this._up,"_up")}get viewMatrix(){return this._ensureViewClean(),this._viewMatrix}set viewMatrix(t){a(this._viewMatrix,t),this.notifyChange("_viewMatrix"),this._viewDirty=!1,this._viewInverseTransposeMatrixDirty=!0,this._viewProjectionDirty=!0,this._frustumDirty=!0}get viewForward(){return this._ensureViewClean(),f(S(),-this._viewMatrix[2],-this._viewMatrix[6],-this._viewMatrix[10])}get viewUp(){return this._ensureViewClean(),f(S(),this._viewMatrix[1],this._viewMatrix[5],this._viewMatrix[9])}get viewRight(){return this._ensureViewClean(),f(S(),this._viewMatrix[0],this._viewMatrix[4],this._viewMatrix[8])}get nearFar(){return this._nearFar}get near(){return this._nearFar[0]}set near(t){this._nearFar[0]!==t&&(this._nearFar[0]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_nearFar"))}get far(){return this._nearFar[1]}set far(t){this._nearFar[1]!==t&&(this._nearFar[1]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_nearFar"))}get viewport(){return this._viewport}set viewport(t){this.x=t[0],this.y=t[1],this.width=t[2],this.height=t[3]}get screenViewport(){if(1===this.pixelRatio)return this._viewport;const t=I(U(),this._viewport,1/this.pixelRatio),i=this._get("screenViewport");return i&&E(t,i)?i:t}get screenPadding(){if(1===this.pixelRatio)return this._padding;const t=I(U(),this._padding,1/this.pixelRatio),i=this._get("screenPadding");return i&&E(t,i)?i:t}get x(){return this._viewport[0]}set x(t){t+=this._padding[ot.LEFT],this._viewport[0]!==t&&(this._viewport[0]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get y(){return this._viewport[1]}set y(t){t+=this._padding[ot.BOTTOM],this._viewport[1]!==t&&(this._viewport[1]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get width(){return this._viewport[2]}set width(t){this._viewport[2]!==t&&(this._viewport[2]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get height(){return this._viewport[3]}set height(t){this._viewport[3]!==t&&(this._viewport[3]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get fullWidth(){return this._viewport[2]+this._padding[ot.RIGHT]+this._padding[ot.LEFT]}set fullWidth(t){this.width=t-(this._padding[ot.RIGHT]+this._padding[ot.LEFT])}get fullHeight(){return this._viewport[3]+this._padding[ot.TOP]+this._padding[ot.BOTTOM]}set fullHeight(t){this.height=t-(this._padding[ot.TOP]+this._padding[ot.BOTTOM])}get fullViewport(){return this._fullViewport[0]=this._viewport[0]-this._padding[ot.LEFT],this._fullViewport[1]=this._viewport[1]-this._padding[ot.BOTTOM],this._fullViewport[2]=this.fullWidth,this._fullViewport[3]=this.fullHeight,this._fullViewport}get _aspect(){return this.width/this.height}get padding(){return this._padding}set padding(t){L(this._padding,t)||(this._viewport[0]+=t[ot.LEFT]-this._padding[ot.LEFT],this._viewport[1]+=t[ot.BOTTOM]-this._padding[ot.BOTTOM],this._viewport[2]-=t[ot.RIGHT]+t[ot.LEFT]-(this._padding[ot.RIGHT]+this._padding[ot.LEFT]),this._viewport[3]-=t[ot.TOP]+t[ot.BOTTOM]-(this._padding[ot.TOP]+this._padding[ot.BOTTOM]),H(this._padding,t),this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_padding"),this.notifyChange("_viewport"))}get viewProjectionMatrix(){return this._viewProjectionDirty&&(p(this._viewProjectionMatrix,this.projectionMatrix,this.viewMatrix),this._viewProjectionDirty=!1),this._viewProjectionMatrix}get projectionMatrix(){const t=this.width,i=this.height,e=this.near*Math.tan(this.fovY/2)*2,r=e*this._aspect,s=e/this.rows,o=r/this.columns,n=-r/2+this.column*o,h=n+o,a=-e/2+this.row*s,p=a+s,l=u(w(),n*(1+2*this._padding[ot.LEFT]/t),h*(1+2*this._padding[ot.RIGHT]/t),a*(1+2*this._padding[ot.BOTTOM]/i),p*(1+2*this._padding[ot.TOP]/i),this.near,this.far),c=this._get("projectionMatrix");return c&&_(c,l)?c:l}get inverseProjectionMatrix(){return l(w(),this.projectionMatrix)||this._get("inverseProjectionMatrix")||w()}get fov(){return this._fov}set fov(t){this._fov=t,this._viewProjectionDirty=!0,this._frustumDirty=!0}get fovX(){return N(this._fov,this.width,this.height)}set fovX(t){this._fov=J(t,this.width,this.height),this._viewProjectionDirty=!0,this._frustumDirty=!0}get fovY(){return K(this._fov,this.width,this.height)}set fovY(t){this._fov=Q(t,this.width,this.height),this._viewProjectionDirty=!0,this._frustumDirty=!0}get distance(){return x(this.center,this.eye)}get frustum(){return this._recomputeFrustum(),this._frustum}get viewInverseTransposeMatrix(){return(this._viewInverseTransposeMatrixDirty||this._viewDirty)&&(l(this._viewInverseTransposeMatrix,this.viewMatrix),c(this._viewInverseTransposeMatrix,this._viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1),this._viewInverseTransposeMatrix}depthNDCToWorld(t){const i=2*t-1;return 2*this.near*this.far/(this.far+this.near-i*(this.far-this.near))}get perRenderPixelRatio(){return Math.tan(this.fovX/2)/(this.width/2)}get perScreenPixelRatio(){return this.perRenderPixelRatio*this.pixelRatio}get aboveGround(){return null!=this.relativeElevation&&this.relativeElevation>=0}copyFrom(t){M(this._ray.origin,t.eye),this.center=t.center,this.up=t.up,H(this._viewport,t.viewport),this.notifyChange("_viewport"),H(this._padding,t.padding),this.notifyChange("_padding"),d(this._nearFar,t.nearFar),this.notifyChange("_nearFar"),this._fov=t.fov,this.row=t.row,this.column=t.column,this.rows=t.rows,this.columns=t.columns,this.relativeElevation=t.relativeElevation;const i=t;return this._viewDirty=i._viewDirty,this._viewDirty||(a(this._viewMatrix,t.viewMatrix),this.notifyChange("_viewMatrix")),this._viewProjectionDirty=!0,this._frustumDirty=i._frustumDirty,this._frustumDirty||(z(this._frustum,t.frustum),this._frustumDirty=!1),i._viewInverseTransposeMatrixDirty?this._viewInverseTransposeMatrixDirty=!0:(a(this._viewInverseTransposeMatrix,t.viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1),H(this._fullViewport,t.fullViewport),this.pixelRatio=t.pixelRatio,this}copyViewFrom(t){this.eye=t.eye,this.center=t.center,this.up=t.up}clone(){return(new Z).copyFrom(this)}equals(t){return T(this.eye,t.eye)&&T(this.center,t.center)&&T(this.up,t.up)&&L(this._viewport,t.viewport)&&L(this._padding,t.padding)&&y(this.nearFar,t.nearFar)&&this._fov===t.fov&&this.pixelRatio===t.pixelRatio&&this.relativeElevation===t.relativeElevation&&this.row===t.row&&this.column===t.column&&this.rows===t.rows&&this.columns===t.columns}almostEquals(t){const i=Math.max(1,1/this.pixelRatio,1/t.pixelRatio);if(Math.abs(t.fov-this._fov)>=.001||G(t.screenPadding,this.screenPadding)>=i||G(this.screenViewport,t.screenViewport)>=i||this.row!==t.row||this.column!==t.column||this.rows!==t.rows||this.columns!==t.columns)return!1;D(et,t.eye,t.center),D(rt,this.eye,this.center);const e=j(et,rt),r=R(et),s=R(rt),o=5e-4;return e*e>=(1-1e-10)*r*s&&P(t.eye,this.eye)<Math.max(r,s)*o*o}computeRenderPixelSizeAt(t){return this.computeRenderPixelSizeAtDist(this._viewDirectionDistance(t))}computeRenderPixelSizeAtDist(t){return t*this.perRenderPixelRatio}computeScreenPixelSizeAt(t){return this.computeScreenPixelSizeAtDist(this._viewDirectionDistance(t))}_viewDirectionDistance(t){return Math.abs(Y(this.viewForward,m(et,t,this.eye)))}computeScreenPixelSizeAtDist(t){return t*this.perScreenPixelRatio}computeDistanceFromRadius(t,i){return t/Math.tan(Math.min(this.fovX,this.fovY)/(2*(i||1)))}getScreenCenter(t=s()){return t[0]=(this.padding[ot.LEFT]+this.width/2)/this.pixelRatio,t[1]=(this.padding[ot.TOP]+this.height/2)/this.pixelRatio,t}getRenderCenter(t,i=.5,e=.5){return t[0]=this.padding[ot.LEFT]+this.width*i,t[1]=this.padding[ot.BOTTOM]+this.height*e,t[2]=.5,t}setGLViewport(t){const i=this.viewport,e=this.padding;t.setViewport(i[0]-e[3],i[1]-e[2],i[2]+e[1]+e[3],i[3]+e[0]+e[2])}applyProjection(t,i){t!==tt&&M(tt,t),tt[3]=1,B(tt,tt,this.projectionMatrix);const e=Math.abs(tt[3]);F(tt,tt,1/e);const s=this.fullViewport;i[0]=r(0,s[0]+s[2],.5+.5*tt[0]),i[1]=r(0,s[1]+s[3],.5+.5*tt[1]),i[2]=.5*(tt[2]+1),i[3]=e}unapplyProjection(t,i){const e=this.fullViewport;tt[0]=(t[0]/(e[0]+e[2])*2-1)*t[3],tt[1]=(t[1]/(e[1]+e[3])*2-1)*t[3],tt[2]=(2*t[2]-1)*t[3],tt[3]=t[3],null!=this.inverseProjectionMatrix&&(B(tt,tt,this.inverseProjectionMatrix),i[0]=tt[0],i[1]=tt[1],i[2]=tt[2])}projectToScreen(t,i){return this.projectToRenderScreen(t,st),this.renderToScreen(st,i),i}projectToRenderScreen(t,i){if(tt[0]=t[0],tt[1]=t[1],tt[2]=t[2],tt[3]=1,B(tt,tt,this.viewProjectionMatrix),0===tt[3])return null;const e=tt;F(e,e,1/Math.abs(tt[3]));const s=this.fullViewport,o=r(0,s[0]+s[2],.5+.5*e[0]),n=r(0,s[1]+s[3],.5+.5*e[1]);return"x"in i?(i.x=o,i.y=n):(i[0]=o,i[1]=n,i.length>2&&(i[2]=.5*(e[2]+1))),i}unprojectFromScreen(t,i){return this.unprojectFromRenderScreen(this.screenToRender(t,st),i)}unprojectFromRenderScreen(t,i){if(p(it,this.projectionMatrix,this.viewMatrix),!l(it,it))return null;const e=this.fullViewport;return tt[0]=2*(t[0]-e[0])/e[2]-1,tt[1]=2*(t[1]-e[1])/e[3]-1,tt[2]=2*t[2]-1,tt[3]=1,B(tt,tt,it),0===tt[3]?null:(i[0]=tt[0]/tt[3],i[1]=tt[1]/tt[3],i[2]=tt[2]/tt[3],i)}constrainWindowSize(t,i,e,r){const s=t*this.pixelRatio,o=i*this.pixelRatio,n=Math.max(s-e/2,0),h=Math.max(this.fullHeight-o-r/2,0),a=-Math.min(s-e/2,0),p=-Math.min(this.fullHeight-o-r/2,0),u=e-a- -Math.min(this.fullWidth-s-e/2,0),_=r-p- -Math.min(o-r/2,0);return[Math.round(n),Math.round(h),Math.round(u),Math.round(_)]}computeUp(t){t===q.Global?this._computeUpGlobal():this._computeUpLocal()}screenToRender(t,i){const e=t[0]*this.pixelRatio,r=this.fullHeight-t[1]*this.pixelRatio;return i[0]=e,i[1]=r,i}renderToScreen(t,i){const e=t[0]/this.pixelRatio,r=(this.fullHeight-t[1])/this.pixelRatio;i[0]=e,i[1]=r}_computeUpGlobal(){m(et,this.center,this.eye);const t=O(this.center);t<1?(f(this._up,0,0,1),this._markViewDirty(),this.notifyChange("_up")):Math.abs(j(et,this.center))>.9999*O(et)*t||(V(this._up,et,this.center),V(this._up,this._up,et),C(this._up,this._up),this.notifyChange("_up"),this._markViewDirty())}_computeUpLocal(){b(et,this.eye,this.center),Math.abs(et[2])<=.9999&&(F(et,et,et[2]),f(this._up,-et[0],-et[1],1-et[2]),C(this._up,this._up),this.notifyChange("_up"),this._markViewDirty())}_compareAndSetView(t,i,r=""){"number"==typeof t[0]&&isFinite(t[0])&&"number"==typeof t[1]&&isFinite(t[1])&&"number"==typeof t[2]&&isFinite(t[2])?T(t,i)||(M(i,t),this._markViewDirty(),r.length&&this.notifyChange(r)):e.getLogger("esri.views.3d.webgl-engine.lib.Camera").warn("Camera vector contains invalid number, ignoring value")}_markViewDirty(){this._viewDirty=!0,this._frustumDirty=!0,this._viewProjectionDirty=!0}_recomputeFrustum(){this._frustumDirty&&(W(this.viewMatrix,this.projectionMatrix,this._frustum),this._frustumDirty=!1)}_ensureViewClean(){this._viewDirty&&(v(this._viewMatrix,this.eye,this.center,this.up),this.notifyChange("_viewMatrix"),this._viewDirty=!1,this._viewInverseTransposeMatrixDirty=!0)}};t([n()],$.prototype,"_viewport",void 0),t([n()],$.prototype,"_padding",void 0),t([n()],$.prototype,"_fov",void 0),t([n()],$.prototype,"_nearFar",void 0),t([n()],$.prototype,"_viewDirty",void 0),t([n()],$.prototype,"_viewMatrix",void 0),t([n()],$.prototype,"_pixelRatio",void 0),t([n()],$.prototype,"pixelRatio",null),t([n()],$.prototype,"row",void 0),t([n()],$.prototype,"column",void 0),t([n()],$.prototype,"_rows",void 0),t([n()],$.prototype,"rows",null),t([n()],$.prototype,"_columns",void 0),t([n()],$.prototype,"columns",null),t([n()],$.prototype,"eye",null),t([n()],$.prototype,"center",null),t([n()],$.prototype,"_center",void 0),t([n()],$.prototype,"up",null),t([n()],$.prototype,"_up",void 0),t([n({readOnly:!0})],$.prototype,"viewForward",null),t([n({readOnly:!0})],$.prototype,"viewUp",null),t([n({readOnly:!0})],$.prototype,"viewRight",null),t([n({readOnly:!0})],$.prototype,"nearFar",null),t([n()],$.prototype,"near",null),t([n()],$.prototype,"far",null),t([n()],$.prototype,"viewport",null),t([n({readOnly:!0})],$.prototype,"screenViewport",null),t([n({readOnly:!0})],$.prototype,"screenPadding",null),t([n()],$.prototype,"x",null),t([n()],$.prototype,"y",null),t([n()],$.prototype,"width",null),t([n()],$.prototype,"height",null),t([n()],$.prototype,"fullWidth",null),t([n()],$.prototype,"fullHeight",null),t([n({readOnly:!0})],$.prototype,"_aspect",null),t([n()],$.prototype,"padding",null),t([n({readOnly:!0})],$.prototype,"projectionMatrix",null),t([n({readOnly:!0})],$.prototype,"inverseProjectionMatrix",null),t([n()],$.prototype,"fov",null),t([n()],$.prototype,"fovX",null),t([n()],$.prototype,"fovY",null),$=Z=t([h("esri.views.3d.webgl-engine.lib.Camera")],$);const tt=U(),it=w(),et=S(),rt=S(),st=o();var ot;!function(t){t[t.TOP=0]="TOP",t[t.RIGHT=1]="RIGHT",t[t.BOTTOM=2]="BOTTOM",t[t.LEFT=3]="LEFT"}(ot||(ot={}));export{$ as Camera,ot as PaddingSide};
|
|
5
|
+
import{_ as t}from"../../../../chunks/tslib.es6.js";import i from"../../../../core/Accessor.js";import e from"../../../../core/Logger.js";import{lerp as r}from"../../../../core/mathUtils.js";import{createScreenPointArray as s,createRenderScreenPointArray3 as o}from"../../../../core/screenUtils.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{copy as a,multiply as p,frustum as u,equals as _,invert as l,transpose as c,lookAt as v}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as w}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{copy as d,exactEquals as y}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as g}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{f as m,s as f,q as x,c as M,j as T,z as D,k as j,x as R,w as P,h as F,l as O,b as V,n as C,E as b}from"../../../../chunks/vec32.js";import{create as S}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{d as I,e as E,a as L,c as H,f as G,t as B}from"../../../../chunks/vec42.js";import{fromValues as A,create as k}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as U,copy as z,fromMatrix as W}from"../../../../geometry/support/frustum.js";import{create as q}from"../../../../geometry/support/ray.js";import{projectPointSignedLength as X}from"../../../../geometry/support/vector.js";import{ViewingMode as Y}from"../../../ViewingMode.js";import{fovd2fovx as N,fovx2fovd as J,fovd2fovy as K,fovy2fovd as Q}from"./fov.js";var Z;let $=Z=class extends i{constructor(t){super(t),this._ray=q(),this._viewport=A(0,0,1,1),this._padding=A(0,0,0,0),this._fov=55/180*Math.PI,this._nearFar=g(1,1e3),this._viewDirty=!0,this._viewMatrix=w(),this._viewProjectionDirty=!0,this._viewProjectionMatrix=w(),this._viewInverseTransposeMatrixDirty=!0,this._viewInverseTransposeMatrix=w(),this._frustumDirty=!0,this._frustum=U(),this._fullViewport=k(),this._pixelRatio=1,this.row=0,this.column=0,this._rows=1,this._columns=1,this._center=S(),this._up=S(),this.relativeElevation=0}get pixelRatio(){return this._pixelRatio}set pixelRatio(t){this._pixelRatio=t>0?t:1}get rows(){return this._rows}set rows(t){this._rows=Math.max(1,t)}get columns(){return this._columns}set columns(t){this._columns=Math.max(1,t)}get eye(){return this._ray.origin}set eye(t){this._compareAndSetView(t,this._ray.origin)}get center(){return this._center}set center(t){this._compareAndSetView(t,this._center,"_center")}get ray(){return m(this._ray.direction,this.center,this.eye),this._ray}get up(){return this._up}set up(t){this._compareAndSetView(t,this._up,"_up")}get viewMatrix(){return this._ensureViewClean(),this._viewMatrix}set viewMatrix(t){a(this._viewMatrix,t),this.notifyChange("_viewMatrix"),this._viewDirty=!1,this._viewInverseTransposeMatrixDirty=!0,this._viewProjectionDirty=!0,this._frustumDirty=!0}get viewForward(){return this._ensureViewClean(),f(S(),-this._viewMatrix[2],-this._viewMatrix[6],-this._viewMatrix[10])}get viewUp(){return this._ensureViewClean(),f(S(),this._viewMatrix[1],this._viewMatrix[5],this._viewMatrix[9])}get viewRight(){return this._ensureViewClean(),f(S(),this._viewMatrix[0],this._viewMatrix[4],this._viewMatrix[8])}get nearFar(){return this._nearFar}get near(){return this._nearFar[0]}set near(t){this._nearFar[0]!==t&&(this._nearFar[0]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_nearFar"))}get far(){return this._nearFar[1]}set far(t){this._nearFar[1]!==t&&(this._nearFar[1]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_nearFar"))}get viewport(){return this._viewport}set viewport(t){this.x=t[0],this.y=t[1],this.width=t[2],this.height=t[3]}get screenViewport(){if(1===this.pixelRatio)return this._viewport;const t=I(k(),this._viewport,1/this.pixelRatio),i=this._get("screenViewport");return i&&E(t,i)?i:t}get screenPadding(){if(1===this.pixelRatio)return this._padding;const t=I(k(),this._padding,1/this.pixelRatio),i=this._get("screenPadding");return i&&E(t,i)?i:t}get x(){return this._viewport[0]}set x(t){t+=this._padding[ot.LEFT],this._viewport[0]!==t&&(this._viewport[0]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get y(){return this._viewport[1]}set y(t){t+=this._padding[ot.BOTTOM],this._viewport[1]!==t&&(this._viewport[1]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get width(){return this._viewport[2]}set width(t){this._viewport[2]!==t&&(this._viewport[2]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get height(){return this._viewport[3]}set height(t){this._viewport[3]!==t&&(this._viewport[3]=t,this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_viewport"))}get fullWidth(){return this._viewport[2]+this._padding[ot.RIGHT]+this._padding[ot.LEFT]}set fullWidth(t){this.width=t-(this._padding[ot.RIGHT]+this._padding[ot.LEFT])}get fullHeight(){return this._viewport[3]+this._padding[ot.TOP]+this._padding[ot.BOTTOM]}set fullHeight(t){this.height=t-(this._padding[ot.TOP]+this._padding[ot.BOTTOM])}get fullViewport(){return this._fullViewport[0]=this._viewport[0]-this._padding[ot.LEFT],this._fullViewport[1]=this._viewport[1]-this._padding[ot.BOTTOM],this._fullViewport[2]=this.fullWidth,this._fullViewport[3]=this.fullHeight,this._fullViewport}get _aspect(){return this.width/this.height}get padding(){return this._padding}set padding(t){L(this._padding,t)||(this._viewport[0]+=t[ot.LEFT]-this._padding[ot.LEFT],this._viewport[1]+=t[ot.BOTTOM]-this._padding[ot.BOTTOM],this._viewport[2]-=t[ot.RIGHT]+t[ot.LEFT]-(this._padding[ot.RIGHT]+this._padding[ot.LEFT]),this._viewport[3]-=t[ot.TOP]+t[ot.BOTTOM]-(this._padding[ot.TOP]+this._padding[ot.BOTTOM]),H(this._padding,t),this._viewProjectionDirty=!0,this._frustumDirty=!0,this.notifyChange("_padding"),this.notifyChange("_viewport"))}get viewProjectionMatrix(){return this._viewProjectionDirty&&(p(this._viewProjectionMatrix,this.projectionMatrix,this.viewMatrix),this._viewProjectionDirty=!1),this._viewProjectionMatrix}get projectionMatrix(){const t=this.width,i=this.height,e=this.near*Math.tan(this.fovY/2)*2,r=e*this._aspect,s=e/this.rows,o=r/this.columns,n=-r/2+this.column*o,h=n+o,a=-e/2+this.row*s,p=a+s,l=u(w(),n*(1+2*this._padding[ot.LEFT]/t),h*(1+2*this._padding[ot.RIGHT]/t),a*(1+2*this._padding[ot.BOTTOM]/i),p*(1+2*this._padding[ot.TOP]/i),this.near,this.far),c=this._get("projectionMatrix");return c&&_(c,l)?c:l}get inverseProjectionMatrix(){return l(w(),this.projectionMatrix)||this._get("inverseProjectionMatrix")||w()}get fov(){return this._fov}set fov(t){this._fov=t,this._viewProjectionDirty=!0,this._frustumDirty=!0}get fovX(){return N(this._fov,this.width,this.height)}set fovX(t){this._fov=J(t,this.width,this.height),this._viewProjectionDirty=!0,this._frustumDirty=!0}get fovY(){return K(this._fov,this.width,this.height)}set fovY(t){this._fov=Q(t,this.width,this.height),this._viewProjectionDirty=!0,this._frustumDirty=!0}get distance(){return x(this.center,this.eye)}get frustum(){return this._recomputeFrustum(),this._frustum}get viewInverseTransposeMatrix(){return(this._viewInverseTransposeMatrixDirty||this._viewDirty)&&(l(this._viewInverseTransposeMatrix,this.viewMatrix),c(this._viewInverseTransposeMatrix,this._viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1),this._viewInverseTransposeMatrix}depthNDCToWorld(t){const i=2*t-1;return 2*this.near*this.far/(this.far+this.near-i*(this.far-this.near))}get perRenderPixelRatio(){return Math.tan(this.fovX/2)/(this.width/2)}get perScreenPixelRatio(){return this.perRenderPixelRatio*this.pixelRatio}get aboveGround(){return null!=this.relativeElevation&&this.relativeElevation>=0}copyFrom(t){M(this._ray.origin,t.eye),this.center=t.center,this.up=t.up,H(this._viewport,t.viewport),this.notifyChange("_viewport"),H(this._padding,t.padding),this.notifyChange("_padding"),d(this._nearFar,t.nearFar),this.notifyChange("_nearFar"),this._fov=t.fov,this.row=t.row,this.column=t.column,this.rows=t.rows,this.columns=t.columns,this.relativeElevation=t.relativeElevation;const i=t;return this._viewDirty=i._viewDirty,this._viewDirty||(a(this._viewMatrix,t.viewMatrix),this.notifyChange("_viewMatrix")),this._viewProjectionDirty=!0,this._frustumDirty=i._frustumDirty,this._frustumDirty||(z(this._frustum,t.frustum),this._frustumDirty=!1),i._viewInverseTransposeMatrixDirty?this._viewInverseTransposeMatrixDirty=!0:(a(this._viewInverseTransposeMatrix,t.viewInverseTransposeMatrix),this._viewInverseTransposeMatrixDirty=!1),H(this._fullViewport,t.fullViewport),this.pixelRatio=t.pixelRatio,this}copyViewFrom(t){this.eye=t.eye,this.center=t.center,this.up=t.up}clone(){return(new Z).copyFrom(this)}equals(t){return T(this.eye,t.eye)&&T(this.center,t.center)&&T(this.up,t.up)&&L(this._viewport,t.viewport)&&L(this._padding,t.padding)&&y(this.nearFar,t.nearFar)&&this._fov===t.fov&&this.pixelRatio===t.pixelRatio&&this.relativeElevation===t.relativeElevation&&this.row===t.row&&this.column===t.column&&this.rows===t.rows&&this.columns===t.columns}almostEquals(t){const i=Math.max(1,1/this.pixelRatio,1/t.pixelRatio);if(Math.abs(t.fov-this._fov)>=.001||G(t.screenPadding,this.screenPadding)>=i||G(this.screenViewport,t.screenViewport)>=i||this.row!==t.row||this.column!==t.column||this.rows!==t.rows||this.columns!==t.columns)return!1;D(et,t.eye,t.center),D(rt,this.eye,this.center);const e=j(et,rt),r=R(et),s=R(rt),o=5e-4;return e*e>=(1-1e-10)*r*s&&P(t.eye,this.eye)<Math.max(r,s)*o*o}computeRenderPixelSizeAt(t){return this.computeRenderPixelSizeAtDist(this._viewDirectionDistance(t))}computeRenderPixelSizeAtDist(t){return t*this.perRenderPixelRatio}computeScreenPixelSizeAt(t){return this.computeScreenPixelSizeAtDist(this._viewDirectionDistance(t))}_viewDirectionDistance(t){return Math.abs(X(this.viewForward,m(et,t,this.eye)))}computeScreenPixelSizeAtDist(t){return t*this.perScreenPixelRatio}computeDistanceFromRadius(t,i){return t/Math.tan(Math.min(this.fovX,this.fovY)/(2*(i||1)))}getScreenCenter(t=s()){return t[0]=(this.padding[ot.LEFT]+this.width/2)/this.pixelRatio,t[1]=(this.padding[ot.TOP]+this.height/2)/this.pixelRatio,t}getRenderCenter(t,i=.5,e=.5){return t[0]=this.padding[ot.LEFT]+this.width*i,t[1]=this.padding[ot.BOTTOM]+this.height*e,t[2]=.5,t}setGLViewport(t){const i=this.viewport,e=this.padding;t.setViewport(i[0]-e[3],i[1]-e[2],i[2]+e[1]+e[3],i[3]+e[0]+e[2])}applyProjection(t,i){t!==tt&&M(tt,t),tt[3]=1,B(tt,tt,this.projectionMatrix);const e=Math.abs(tt[3]);F(tt,tt,1/e);const s=this.fullViewport;i[0]=r(0,s[0]+s[2],.5+.5*tt[0]),i[1]=r(0,s[1]+s[3],.5+.5*tt[1]),i[2]=.5*(tt[2]+1),i[3]=e}unapplyProjection(t,i){const e=this.fullViewport;tt[0]=(t[0]/(e[0]+e[2])*2-1)*t[3],tt[1]=(t[1]/(e[1]+e[3])*2-1)*t[3],tt[2]=(2*t[2]-1)*t[3],tt[3]=t[3],null!=this.inverseProjectionMatrix&&(B(tt,tt,this.inverseProjectionMatrix),i[0]=tt[0],i[1]=tt[1],i[2]=tt[2])}projectToScreen(t,i){return this.projectToRenderScreen(t,st),this.renderToScreen(st,i),i}projectToRenderScreen(t,i){if(tt[0]=t[0],tt[1]=t[1],tt[2]=t[2],tt[3]=1,B(tt,tt,this.viewProjectionMatrix),0===tt[3])return null;const e=tt;F(e,e,1/Math.abs(tt[3]));const s=this.fullViewport,o=r(0,s[0]+s[2],.5+.5*e[0]),n=r(0,s[1]+s[3],.5+.5*e[1]);return"x"in i?(i.x=o,i.y=n):(i[0]=o,i[1]=n,i.length>2&&(i[2]=.5*(e[2]+1))),i}unprojectFromScreen(t,i){return this.unprojectFromRenderScreen(this.screenToRender(t,st),i)}unprojectFromRenderScreen(t,i){if(p(it,this.projectionMatrix,this.viewMatrix),!l(it,it))return null;const e=this.fullViewport;return tt[0]=2*(t[0]-e[0])/e[2]-1,tt[1]=2*(t[1]-e[1])/e[3]-1,tt[2]=2*t[2]-1,tt[3]=1,B(tt,tt,it),0===tt[3]?null:(i[0]=tt[0]/tt[3],i[1]=tt[1]/tt[3],i[2]=tt[2]/tt[3],i)}constrainWindowSize(t,i,e,r){const s=t*this.pixelRatio,o=i*this.pixelRatio,n=Math.max(s-e/2,0),h=Math.max(this.fullHeight-o-r/2,0),a=-Math.min(s-e/2,0),p=-Math.min(this.fullHeight-o-r/2,0),u=e-a- -Math.min(this.fullWidth-s-e/2,0),_=r-p- -Math.min(o-r/2,0);return[Math.round(n),Math.round(h),Math.round(u),Math.round(_)]}computeUp(t){t===Y.Global?this._computeUpGlobal():this._computeUpLocal()}screenToRender(t,i){const e=t[0]*this.pixelRatio,r=this.fullHeight-t[1]*this.pixelRatio;return i[0]=e,i[1]=r,i}renderToScreen(t,i){const e=t[0]/this.pixelRatio,r=(this.fullHeight-t[1])/this.pixelRatio;i[0]=e,i[1]=r}_computeUpGlobal(){m(et,this.center,this.eye);const t=O(this.center);t<1?(f(this._up,0,0,1),this._markViewDirty(),this.notifyChange("_up")):Math.abs(j(et,this.center))>.9999*O(et)*t||(V(this._up,et,this.center),V(this._up,this._up,et),C(this._up,this._up),this.notifyChange("_up"),this._markViewDirty())}_computeUpLocal(){b(et,this.eye,this.center),Math.abs(et[2])<=.9999&&(F(et,et,et[2]),f(this._up,-et[0],-et[1],1-et[2]),C(this._up,this._up),this.notifyChange("_up"),this._markViewDirty())}_compareAndSetView(t,i,r=""){"number"==typeof t[0]&&isFinite(t[0])&&"number"==typeof t[1]&&isFinite(t[1])&&"number"==typeof t[2]&&isFinite(t[2])?T(t,i)||(M(i,t),this._markViewDirty(),r.length&&this.notifyChange(r)):e.getLogger("esri.views.3d.webgl-engine.lib.Camera").warn("Camera vector contains invalid number, ignoring value")}_markViewDirty(){this._viewDirty=!0,this._frustumDirty=!0,this._viewProjectionDirty=!0}_recomputeFrustum(){this._frustumDirty&&(W(this.viewMatrix,this.projectionMatrix,this._frustum),this._frustumDirty=!1)}_ensureViewClean(){this._viewDirty&&(v(this._viewMatrix,this.eye,this.center,this.up),this.notifyChange("_viewMatrix"),this._viewDirty=!1,this._viewInverseTransposeMatrixDirty=!0)}};t([n()],$.prototype,"_viewport",void 0),t([n()],$.prototype,"_padding",void 0),t([n()],$.prototype,"_fov",void 0),t([n()],$.prototype,"_nearFar",void 0),t([n()],$.prototype,"_viewDirty",void 0),t([n()],$.prototype,"_viewMatrix",void 0),t([n()],$.prototype,"_pixelRatio",void 0),t([n()],$.prototype,"pixelRatio",null),t([n()],$.prototype,"row",void 0),t([n()],$.prototype,"column",void 0),t([n()],$.prototype,"_rows",void 0),t([n()],$.prototype,"rows",null),t([n()],$.prototype,"_columns",void 0),t([n()],$.prototype,"columns",null),t([n()],$.prototype,"eye",null),t([n()],$.prototype,"center",null),t([n()],$.prototype,"_center",void 0),t([n()],$.prototype,"up",null),t([n()],$.prototype,"_up",void 0),t([n({readOnly:!0})],$.prototype,"viewForward",null),t([n({readOnly:!0})],$.prototype,"viewUp",null),t([n({readOnly:!0})],$.prototype,"viewRight",null),t([n({readOnly:!0})],$.prototype,"nearFar",null),t([n()],$.prototype,"near",null),t([n()],$.prototype,"far",null),t([n()],$.prototype,"viewport",null),t([n({readOnly:!0})],$.prototype,"screenViewport",null),t([n({readOnly:!0})],$.prototype,"screenPadding",null),t([n()],$.prototype,"x",null),t([n()],$.prototype,"y",null),t([n()],$.prototype,"width",null),t([n()],$.prototype,"height",null),t([n()],$.prototype,"fullWidth",null),t([n()],$.prototype,"fullHeight",null),t([n({readOnly:!0})],$.prototype,"_aspect",null),t([n()],$.prototype,"padding",null),t([n({readOnly:!0})],$.prototype,"projectionMatrix",null),t([n({readOnly:!0})],$.prototype,"inverseProjectionMatrix",null),t([n()],$.prototype,"fov",null),t([n()],$.prototype,"fovX",null),t([n()],$.prototype,"fovY",null),$=Z=t([h("esri.views.3d.webgl-engine.lib.Camera")],$);const tt=k(),it=w(),et=S(),rt=S(),st=o();var ot;!function(t){t[t.TOP=0]="TOP",t[t.RIGHT=1]="RIGHT",t[t.BOTTOM=2]="BOTTOM",t[t.LEFT=3]="LEFT"}(ot||(ot={}));export{$ as Camera,ot as PaddingSide};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{create as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{f as n,b as e,n as o,h as s,g as r,j as l,s as h,c as u,e as c}from"../../../../chunks/vec32.js";import{fromValues as a,create as f,clone as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{clone as i,create as g,fromValues as w}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newDoubleArray as m}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as O,floatArrayFrom as M}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as A,getContinuousIndexArray as I}from"../../../../geometry/support/Indices.js";import{create as y,fromPositionAndNormal as N,intersectRay as P}from"../../../../geometry/support/plane.js";import{wrap as T}from"../../../../geometry/support/ray.js";import{Attribute as S}from"./Attribute.js";import{Vec3Compact as b}from"./BufferVectorMath.js";import{ContentObjectType as R}from"./ContentObjectType.js";import{Geometry as j}from"./Geometry.js";import{assert as L}from"./Util.js";import{VertexAttribute as d}from"./VertexAttribute.js";const E=b,x=[[-.5,-.5,.5],[.5,-.5,.5],[.5,.5,.5],[-.5,.5,.5],[-.5,-.5,-.5],[.5,-.5,-.5],[.5,.5,-.5],[-.5,.5,-.5]],U=[0,0,1,-1,0,0,1,0,0,0,-1,0,0,1,0,0,0,-1],V=[0,0,1,0,1,1,0,1],v=[0,1,2,2,3,0,4,0,3,3,7,4,1,5,6,6,2,1,1,0,4,4,5,1,3,2,6,6,7,3,5,4,7,7,6,5],F=new Array(36);for(let Nt=0;Nt<6;Nt++)for(let t=0;t<6;t++)F[6*Nt+t]=Nt;const C=new Array(36);for(let Nt=0;Nt<6;Nt++)C[6*Nt]=0,C[6*Nt+1]=1,C[6*Nt+2]=2,C[6*Nt+3]=2,C[6*Nt+4]=3,C[6*Nt+5]=0;function G(t,n){Array.isArray(n)||(n=[n,n,n]);const e=new Array(24);for(let o=0;o<8;o++)e[3*o]=x[o][0]*n[0],e[3*o+1]=x[o][1]*n[1],e[3*o+2]=x[o][2]*n[2];return new j(t,[[d.POSITION,new S(e,v,3,!0)],[d.NORMAL,new S(U,F,3)],[d.UV0,new S(V,C,2)]])}const D=[[-.5,0,-.5],[.5,0,-.5],[.5,0,.5],[-.5,0,.5],[0,-.5,0],[0,.5,0]],q=[0,1,-1,1,1,0,0,1,1,-1,1,0,0,-1,-1,1,-1,0,0,-1,1,-1,-1,0],B=[5,1,0,5,2,1,5,3,2,5,0,3,4,0,1,4,1,2,4,2,3,4,3,0],k=[0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7];function z(t,n){Array.isArray(n)||(n=[n,n,n]);const e=new Array(18);for(let o=0;o<6;o++)e[3*o]=D[o][0]*n[0],e[3*o+1]=D[o][1]*n[1],e[3*o+2]=D[o][2]*n[2];return new j(t,[[d.POSITION,new S(e,B,3,!0)],[d.NORMAL,new S(q,k,3)]])}const Z=a(-.5,0,-.5),H=a(.5,0,-.5),J=a(0,0,.5),K=a(0,.5,0),Q=f(),W=f(),X=f(),Y=f(),$=f();n(Q,Z,K),n(W,Z,H),e(X,Q,W),o(X,X),n(Q,H,K),n(W,H,J),e(Y,Q,W),o(Y,Y),n(Q,J,K),n(W,J,Z),e($,Q,W),o($,$);const _=[Z,H,J,K],tt=[0,-1,0,X[0],X[1],X[2],Y[0],Y[1],Y[2],$[0],$[1],$[2]],nt=[0,1,2,3,1,0,3,2,1,3,0,2],et=[0,0,0,1,1,1,2,2,2,3,3,3];function ot(t,n){Array.isArray(n)||(n=[n,n,n]);const e=new Array(12);for(let o=0;o<4;o++)e[3*o]=_[o][0]*n[0],e[3*o+1]=_[o][1]*n[1],e[3*o+2]=_[o][2]*n[2];return new j(t,[[d.POSITION,new S(e,nt,3,!0)],[d.NORMAL,new S(tt,et,3)]])}function st(t,n,e,o,s={uv:!0}){const r=-Math.PI,l=2*Math.PI,h=-Math.PI/2,u=Math.PI,c=Math.max(3,Math.floor(e)),a=Math.max(2,Math.floor(o)),f=(c+1)*(a+1),p=O(3*f),i=O(3*f),g=O(2*f),w=[];let m=0;for(let O=0;O<=a;O++){const t=[],e=O/a,o=h+e*u,s=Math.cos(o);for(let h=0;h<=c;h++){const u=h/c,a=r+u*l,f=Math.cos(a)*s,w=Math.sin(o),O=-Math.sin(a)*s;p[3*m]=f*n,p[3*m+1]=w*n,p[3*m+2]=O*n,i[3*m]=f,i[3*m+1]=w,i[3*m+2]=O,g[2*m]=u,g[2*m+1]=e,t.push(m),++m}w.push(t)}const M=new Array;for(let O=0;O<a;O++)for(let t=0;t<c;t++){const n=w[O][t],e=w[O][t+1],o=w[O+1][t+1],s=w[O+1][t];0===O?(M.push(n),M.push(o),M.push(s)):O===a-1?(M.push(n),M.push(e),M.push(o)):(M.push(n),M.push(e),M.push(o),M.push(o),M.push(s),M.push(n))}const I=[[d.POSITION,new S(p,M,3,!0)],[d.NORMAL,new S(i,M,3,!0)]];return s.uv&&I.push([d.UV0,new S(g,M,2,!0)]),s.offset&&(I[0][0]=d.OFFSET,I.push([d.POSITION,new S(Float64Array.from(s.offset),A(M.length),3,!0)])),new j(t,I)}function rt(t,n,e,o){const s=lt(n,e,o);return new j(t,s)}function lt(t,n,e){const o=t;let s,r;if(e)s=[0,-1,0,1,0,0,0,0,1,-1,0,0,0,0,-1,0,1,0],r=[0,1,2,0,2,3,0,3,4,0,4,1,1,5,2,2,5,3,3,5,4,4,5,1];else{const t=o*(1+Math.sqrt(5))/2;s=[-o,t,0,o,t,0,-o,-t,0,o,-t,0,0,-o,t,0,o,t,0,-o,-t,0,o,-t,t,0,-o,t,0,o,-t,0,-o,-t,0,o],r=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1]}for(let c=0;c<s.length;c+=3)E.scale(s,c,t/E.length(s,c));let l={};function h(n,e){n>e&&([n,e]=[e,n]);const o=n.toString()+"."+e.toString();if(l[o])return l[o];let r=s.length;return s.length+=3,E.add(s,3*n,s,3*e,s,r),E.scale(s,r,t/E.length(s,r)),r/=3,l[o]=r,r}for(let c=0;c<n;c++){const t=r.length,n=new Array(4*t);for(let e=0;e<t;e+=3){const t=r[e],o=r[e+1],s=r[e+2],l=h(t,o),u=h(o,s),c=h(s,t),a=4*e;n[a]=t,n[a+1]=l,n[a+2]=c,n[a+3]=o,n[a+4]=u,n[a+5]=l,n[a+6]=s,n[a+7]=c,n[a+8]=u,n[a+9]=l,n[a+10]=u,n[a+11]=c}r=n,l={}}const u=M(s);for(let c=0;c<u.length;c+=3)E.normalize(u,c);return[[d.POSITION,new S(M(s),r,3,!0)],[d.NORMAL,new S(u,r,3,!0)]]}function ht(n,e,o,s,r,l,h,u,c=null){const a=o?i(o):g(),f=e?i(e):w(0,0,1);h??=t();const p=s?[255*s[0],255*s[1],255*s[2],s.length>3?255*s[3]:255]:[255,255,255,255],m=null!=r&&2===r.length?r:[1,1],O=A(1),M=[[d.POSITION,new S(a,O,3,!0)],[d.NORMAL,new S(f,O,3,!0)],[d.UV0,new S(h,O,h.length)],[d.COLOR,new S(p,O,4,!0)],[d.SIZE,new S(m,O,2)]];if(null!=l&&(l=[l[0],l[1],l[2],l[3]],M.push([d.CENTEROFFSETANDDISTANCE,new S(l,O,4)])),u){const t=[u[0],u[1],u[2],u[3]];M.push([d.FEATUREATTRIBUTE,new S(t,O,4)])}return new j(n,M,null,R.Point,c)}const ut=[[-1,-1,0],[1,-1,0],[1,1,0],[-1,1,0]];function ct(t,n=ut){const e=new Array(12);for(let c=0;c<4;c++)for(let t=0;t<3;t++)e[3*c+t]=n[c][t];const o=[0,1,2,2,3,0],s=[0,0,1],r=[0,0,0,0,0,0],l=[0,0,1,0,1,1,0,1],h=[255,255,255,255],u=[[d.POSITION,new S(e,o,3,!0)],[d.NORMAL,new S(s,r,3,!0)],[d.UV0,new S(l,o,2,!0)],[d.COLOR,new S(h,r,4,!0)]];return new j(t,u)}function at(t,n,e,o,s,r=!0,l=!0){let h=0;const u=e,c=n;let f=a(0,h,0),p=a(0,h+c,0),i=a(0,-1,0),g=a(0,1,0);s&&(h=c,p=a(0,0,0),f=a(0,h,0),i=a(0,1,0),g=a(0,-1,0));const w=[p,f],m=[i,g],M=o+2,A=Math.sqrt(c*c+u*u);if(s)for(let O=o-1;O>=0;O--){const t=O*(2*Math.PI/o),n=a(Math.cos(t)*u,h,Math.sin(t)*u);w.push(n);const e=a(c*Math.cos(t)/A,-u/A,c*Math.sin(t)/A);m.push(e)}else for(let O=0;O<o;O++){const t=O*(2*Math.PI/o),n=a(Math.cos(t)*u,h,Math.sin(t)*u);w.push(n);const e=a(c*Math.cos(t)/A,u/A,c*Math.sin(t)/A);m.push(e)}const I=new Array,y=new Array;if(r){for(let t=3;t<w.length;t++)I.push(1),I.push(t-1),I.push(t),y.push(0),y.push(0),y.push(0);I.push(w.length-1),I.push(2),I.push(1),y.push(0),y.push(0),y.push(0)}if(l){for(let t=3;t<w.length;t++)I.push(t),I.push(t-1),I.push(0),y.push(t),y.push(t-1),y.push(1);I.push(0),I.push(2),I.push(w.length-1),y.push(1),y.push(2),y.push(m.length-1)}const N=O(3*M);for(let a=0;a<M;a++)N[3*a]=w[a][0],N[3*a+1]=w[a][1],N[3*a+2]=w[a][2];const P=O(3*M);for(let a=0;a<M;a++)P[3*a]=m[a][0],P[3*a+1]=m[a][1],P[3*a+2]=m[a][2];const T=[[d.POSITION,new S(N,I,3,!0)],[d.NORMAL,new S(P,y,3,!0)]];return new j(t,T)}function ft(t,n,u,c,i,g,w){const m=i?p(i):a(1,0,0),M=g?p(g):a(0,0,0);w??=!0;const A=f();o(A,m);const I=f();s(I,A,Math.abs(n));const y=f();s(y,I,-.5),r(y,y,M);const N=a(0,1,0);Math.abs(1-l(A,N))<.2&&h(N,0,0,1);const P=f();e(P,A,N),o(P,P),e(N,P,A);const T=2*c+(w?2:0),b=c+(w?2:0),R=O(3*T),L=O(3*b),E=O(2*T),x=new Array(3*c*(w?4:2)),U=new Array(3*c*(w?4:2));w&&(R[3*(T-2)]=y[0],R[3*(T-2)+1]=y[1],R[3*(T-2)+2]=y[2],E[2*(T-2)]=0,E[2*(T-2)+1]=0,R[3*(T-1)]=R[3*(T-2)]+I[0],R[3*(T-1)+1]=R[3*(T-2)+1]+I[1],R[3*(T-1)+2]=R[3*(T-2)+2]+I[2],E[2*(T-1)]=1,E[2*(T-1)+1]=1,L[3*(b-2)]=-A[0],L[3*(b-2)+1]=-A[1],L[3*(b-2)+2]=-A[2],L[3*(b-1)]=A[0],L[3*(b-1)+1]=A[1],L[3*(b-1)+2]=A[2]);const V=(t,n,e)=>{x[t]=n,U[t]=e};let v=0;const F=f(),C=f();for(let e=0;e<c;e++){const t=e*(2*Math.PI/c);s(F,N,Math.sin(t)),s(C,P,Math.cos(t)),r(F,F,C),L[3*e]=F[0],L[3*e+1]=F[1],L[3*e+2]=F[2],s(F,F,u),r(F,F,y),R[3*e]=F[0],R[3*e+1]=F[1],R[3*e+2]=F[2],E[2*e]=e/c,E[2*e+1]=0,R[3*(e+c)]=R[3*e]+I[0],R[3*(e+c)+1]=R[3*e+1]+I[1],R[3*(e+c)+2]=R[3*e+2]+I[2],E[2*(e+c)]=e/c,E[2*e+1]=1;const n=(e+1)%c;V(v++,e,e),V(v++,e+c,e),V(v++,n,n),V(v++,n,n),V(v++,e+c,e),V(v++,n+c,n)}if(w){for(let t=0;t<c;t++){const n=(t+1)%c;V(v++,T-2,b-2),V(v++,t,b-2),V(v++,n,b-2)}for(let t=0;t<c;t++){const n=(t+1)%c;V(v++,t+c,b-1),V(v++,T-1,b-1),V(v++,n+c,b-1)}}const G=[[d.POSITION,new S(R,x,3,!0)],[d.NORMAL,new S(L,U,3,!0)],[d.UV0,new S(E,x,2,!0)]];return new j(t,G)}function pt(t,n,e,o,s,r){o=o||10,s=null==s||s,L(n.length>1);const l=[[0,0,0]],h=[],u=[];for(let c=0;c<o;c++){h.push([0,-c-1,-(c+1)%o-1]);const t=c/o*2*Math.PI;u.push([Math.cos(t)*e,Math.sin(t)*e])}return it(t,u,n,l,h,s,r)}function it(t,l,c,f,p,i,w=a(0,0,0)){const m=l.length,M=O(c.length*m*3+(6*f.length||0)),A=O(c.length*m*3+(f?6:0)),I=new Array,b=new Array;let R=0,L=0;const E=g(),x=g(),U=g(),V=g(),v=g(),F=g(),C=g(),G=g(),D=g(),q=g(),B=g(),k=g(),z=g(),Z=y();h(D,0,1,0),n(x,c[1],c[0]),o(x,x),i?(r(G,c[0],w),o(U,G)):h(U,0,0,1),At(x,U,D,D,v,U,It),u(V,U),u(k,v);for(let n=0;n<f.length;n++)s(F,v,f[n][0]),s(G,U,f[n][2]),r(F,F,G),r(F,F,c[0]),M[R++]=F[0],M[R++]=F[1],M[R++]=F[2];A[L++]=-x[0],A[L++]=-x[1],A[L++]=-x[2];for(let n=0;n<p.length;n++)I.push(p[n][0]>0?p[n][0]:-p[n][0]-1+f.length),I.push(p[n][1]>0?p[n][1]:-p[n][1]-1+f.length),I.push(p[n][2]>0?p[n][2]:-p[n][2]-1+f.length),b.push(0),b.push(0),b.push(0);let H=f.length;const J=f.length-1;for(let h=0;h<c.length;h++){let t=!1;if(h>0){u(E,x),h<c.length-1?(n(x,c[h+1],c[h]),o(x,x)):t=!0,r(q,E,x),o(q,q),r(B,c[h-1],V),N(c[h],q,Z);P(Z,T(B,E),G)?(n(G,G,c[h]),o(U,G),e(v,q,U),o(v,v)):At(q,V,k,D,v,U,It),u(V,U),u(k,v)}i&&(r(G,c[h],w),o(z,G));for(let n=0;n<m;n++)if(s(F,v,l[n][0]),s(G,U,l[n][1]),r(F,F,G),o(C,F),A[L++]=C[0],A[L++]=C[1],A[L++]=C[2],r(F,F,c[h]),M[R++]=F[0],M[R++]=F[1],M[R++]=F[2],!t){const t=(n+1)%m;I.push(H+n),I.push(H+m+n),I.push(H+t),I.push(H+t),I.push(H+m+n),I.push(H+m+t);for(let n=0;n<6;n++){const t=I.length-6;b.push(I[t+n]-J)}}H+=m}const K=c[c.length-1];for(let n=0;n<f.length;n++)s(F,v,f[n][0]),s(G,U,f[n][1]),r(F,F,G),r(F,F,K),M[R++]=F[0],M[R++]=F[1],M[R++]=F[2];const Q=L/3;A[L++]=x[0],A[L++]=x[1],A[L++]=x[2];const W=H-m;for(let n=0;n<p.length;n++)I.push(p[n][0]>=0?H+p[n][0]:-p[n][0]-1+W),I.push(p[n][2]>=0?H+p[n][2]:-p[n][2]-1+W),I.push(p[n][1]>=0?H+p[n][1]:-p[n][1]-1+W),b.push(Q),b.push(Q),b.push(Q);const X=[[d.POSITION,new S(M,I,3,!0)],[d.NORMAL,new S(A,b,3,!0)]];return new j(t,X)}function gt(t,n,e,o){L(n.length>1,"createPolylineGeometry(): polyline needs at least 2 points"),L(3===n[0].length,"createPolylineGeometry(): malformed vertex"),L(null==e||e.length===n.length,"createPolylineGeometry: need same number of points and normals"),L(null==e||3===e[0].length,"createPolylineGeometry(): malformed normal");const s=m(3*n.length),r=new Array(2*(n.length-1));let l=0,h=0;for(let c=0;c<n.length;c++){for(let t=0;t<3;t++)s[l++]=n[c][t];c>0&&(r[h++]=c-1,r[h++]=c)}const u=[[d.POSITION,new S(s,r,3,!0)]];if(e){const t=O(3*e.length);let o=0;for(let s=0;s<n.length;s++)for(let n=0;n<3;n++)t[o++]=e[s][n];u.push([d.NORMAL,new S(t,r,3,!0)])}return o&&u.push([d.COLOR,new S(o,I(o.length/4),4)]),new j(t,u,null,R.Line)}function wt(t,n,e,o,s,r=0){const l=new Array(18),h=[[-e,r,s/2],[o,r,s/2],[0,n+r,s/2],[-e,r,-s/2],[o,r,-s/2],[0,n+r,-s/2]],u=[0,1,2,3,0,2,2,5,3,1,4,5,5,2,1,1,0,3,3,4,1,4,3,5];for(let c=0;c<6;c++)l[3*c]=h[c][0],l[3*c+1]=h[c][1],l[3*c+2]=h[c][2];return new j(t,[[d.POSITION,new S(l,u,3,!0)]])}function mt(t,n){const e=t.getMutableAttribute(d.POSITION).data;for(let o=0;o<e.length;o+=3){const t=e[o],s=e[o+1],r=e[o+2];h(yt,t,s,r),c(yt,yt,n),e[o]=yt[0],e[o+1]=yt[1],e[o+2]=yt[2]}}function Ot(t,n=t){const e=t.attributes,o=e.get(d.POSITION).data,s=e.get(d.NORMAL).data;if(s){const t=n.getMutableAttribute(d.NORMAL).data;for(let n=0;n<s.length;n+=3){const e=s[n+1];t[n+1]=-s[n+2],t[n+2]=e}}if(o){const t=n.getMutableAttribute(d.POSITION).data;for(let n=0;n<o.length;n+=3){const e=o[n+1];t[n+1]=-o[n+2],t[n+2]=e}}}function Mt(t,n,s,r,h){return!(Math.abs(l(n,t))>h)&&(e(s,t,n),o(s,s),e(r,s,t),o(r,r),!0)}function At(t,n,e,o,s,r,l){return Mt(t,n,s,r,l)||Mt(t,e,s,r,l)||Mt(t,o,s,r,l)}const It=.99619469809,yt=g();export{Ot as cgToGIS,G as createBoxGeometry,at as createConeGeometry,ft as createCylinderGeometry,z as createDiamondGeometry,wt as createExtrudedTriangle,it as createPathExtrusionGeometry,ht as createPointGeometry,lt as createPolySphereData,rt as createPolySphereGeometry,gt as createPolylineGeometry,st as createSphereGeometry,ct as createSquareGeometry,ot as createTetrahedronGeometry,pt as createTubeGeometry,At as makeOrthoBasisDirUpFallback,mt as transformInPlace};
|
|
5
|
+
import{create as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{f as n,b as e,n as o,h as s,g as r,k as l,s as h,c as u,e as c}from"../../../../chunks/vec32.js";import{fromValues as a,create as f,clone as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{clone as i,create as g,fromValues as w}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newDoubleArray as m}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as O,floatArrayFrom as M}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as A,getContinuousIndexArray as I}from"../../../../geometry/support/Indices.js";import{create as y,fromPositionAndNormal as N,intersectRay as P}from"../../../../geometry/support/plane.js";import{wrap as T}from"../../../../geometry/support/ray.js";import{Attribute as S}from"./Attribute.js";import{Vec3Compact as b}from"./BufferVectorMath.js";import{ContentObjectType as R}from"./ContentObjectType.js";import{Geometry as L}from"./Geometry.js";import{assert as j}from"./Util.js";import{VertexAttribute as d}from"./VertexAttribute.js";const E=b,x=[[-.5,-.5,.5],[.5,-.5,.5],[.5,.5,.5],[-.5,.5,.5],[-.5,-.5,-.5],[.5,-.5,-.5],[.5,.5,-.5],[-.5,.5,-.5]],U=[0,0,1,-1,0,0,1,0,0,0,-1,0,0,1,0,0,0,-1],V=[0,0,1,0,1,1,0,1],v=[0,1,2,2,3,0,4,0,3,3,7,4,1,5,6,6,2,1,1,0,4,4,5,1,3,2,6,6,7,3,5,4,7,7,6,5],F=new Array(36);for(let Nt=0;Nt<6;Nt++)for(let t=0;t<6;t++)F[6*Nt+t]=Nt;const C=new Array(36);for(let Nt=0;Nt<6;Nt++)C[6*Nt]=0,C[6*Nt+1]=1,C[6*Nt+2]=2,C[6*Nt+3]=2,C[6*Nt+4]=3,C[6*Nt+5]=0;function G(t,n){Array.isArray(n)||(n=[n,n,n]);const e=new Array(24);for(let o=0;o<8;o++)e[3*o]=x[o][0]*n[0],e[3*o+1]=x[o][1]*n[1],e[3*o+2]=x[o][2]*n[2];return new L(t,[[d.POSITION,new S(e,v,3,!0)],[d.NORMAL,new S(U,F,3)],[d.UV0,new S(V,C,2)]])}const D=[[-.5,0,-.5],[.5,0,-.5],[.5,0,.5],[-.5,0,.5],[0,-.5,0],[0,.5,0]],k=[0,1,-1,1,1,0,0,1,1,-1,1,0,0,-1,-1,1,-1,0,0,-1,1,-1,-1,0],q=[5,1,0,5,2,1,5,3,2,5,0,3,4,0,1,4,1,2,4,2,3,4,3,0],B=[0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7];function z(t,n){Array.isArray(n)||(n=[n,n,n]);const e=new Array(18);for(let o=0;o<6;o++)e[3*o]=D[o][0]*n[0],e[3*o+1]=D[o][1]*n[1],e[3*o+2]=D[o][2]*n[2];return new L(t,[[d.POSITION,new S(e,q,3,!0)],[d.NORMAL,new S(k,B,3)]])}const Z=a(-.5,0,-.5),H=a(.5,0,-.5),J=a(0,0,.5),K=a(0,.5,0),Q=f(),W=f(),X=f(),Y=f(),$=f();n(Q,Z,K),n(W,Z,H),e(X,Q,W),o(X,X),n(Q,H,K),n(W,H,J),e(Y,Q,W),o(Y,Y),n(Q,J,K),n(W,J,Z),e($,Q,W),o($,$);const _=[Z,H,J,K],tt=[0,-1,0,X[0],X[1],X[2],Y[0],Y[1],Y[2],$[0],$[1],$[2]],nt=[0,1,2,3,1,0,3,2,1,3,0,2],et=[0,0,0,1,1,1,2,2,2,3,3,3];function ot(t,n){Array.isArray(n)||(n=[n,n,n]);const e=new Array(12);for(let o=0;o<4;o++)e[3*o]=_[o][0]*n[0],e[3*o+1]=_[o][1]*n[1],e[3*o+2]=_[o][2]*n[2];return new L(t,[[d.POSITION,new S(e,nt,3,!0)],[d.NORMAL,new S(tt,et,3)]])}function st(t,n,e,o,s={uv:!0}){const r=-Math.PI,l=2*Math.PI,h=-Math.PI/2,u=Math.PI,c=Math.max(3,Math.floor(e)),a=Math.max(2,Math.floor(o)),f=(c+1)*(a+1),p=O(3*f),i=O(3*f),g=O(2*f),w=[];let m=0;for(let O=0;O<=a;O++){const t=[],e=O/a,o=h+e*u,s=Math.cos(o);for(let h=0;h<=c;h++){const u=h/c,a=r+u*l,f=Math.cos(a)*s,w=Math.sin(o),O=-Math.sin(a)*s;p[3*m]=f*n,p[3*m+1]=w*n,p[3*m+2]=O*n,i[3*m]=f,i[3*m+1]=w,i[3*m+2]=O,g[2*m]=u,g[2*m+1]=e,t.push(m),++m}w.push(t)}const M=new Array;for(let O=0;O<a;O++)for(let t=0;t<c;t++){const n=w[O][t],e=w[O][t+1],o=w[O+1][t+1],s=w[O+1][t];0===O?(M.push(n),M.push(o),M.push(s)):O===a-1?(M.push(n),M.push(e),M.push(o)):(M.push(n),M.push(e),M.push(o),M.push(o),M.push(s),M.push(n))}const I=[[d.POSITION,new S(p,M,3,!0)],[d.NORMAL,new S(i,M,3,!0)]];return s.uv&&I.push([d.UV0,new S(g,M,2,!0)]),s.offset&&(I[0][0]=d.OFFSET,I.push([d.POSITION,new S(Float64Array.from(s.offset),A(M.length),3,!0)])),new L(t,I)}function rt(t,n,e,o){const s=lt(n,e,o);return new L(t,s)}function lt(t,n,e){const o=t;let s,r;if(e)s=[0,-1,0,1,0,0,0,0,1,-1,0,0,0,0,-1,0,1,0],r=[0,1,2,0,2,3,0,3,4,0,4,1,1,5,2,2,5,3,3,5,4,4,5,1];else{const t=o*(1+Math.sqrt(5))/2;s=[-o,t,0,o,t,0,-o,-t,0,o,-t,0,0,-o,t,0,o,t,0,-o,-t,0,o,-t,t,0,-o,t,0,o,-t,0,-o,-t,0,o],r=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1]}for(let c=0;c<s.length;c+=3)E.scale(s,c,t/E.length(s,c));let l={};function h(n,e){n>e&&([n,e]=[e,n]);const o=n.toString()+"."+e.toString();if(l[o])return l[o];let r=s.length;return s.length+=3,E.add(s,3*n,s,3*e,s,r),E.scale(s,r,t/E.length(s,r)),r/=3,l[o]=r,r}for(let c=0;c<n;c++){const t=r.length,n=new Array(4*t);for(let e=0;e<t;e+=3){const t=r[e],o=r[e+1],s=r[e+2],l=h(t,o),u=h(o,s),c=h(s,t),a=4*e;n[a]=t,n[a+1]=l,n[a+2]=c,n[a+3]=o,n[a+4]=u,n[a+5]=l,n[a+6]=s,n[a+7]=c,n[a+8]=u,n[a+9]=l,n[a+10]=u,n[a+11]=c}r=n,l={}}const u=M(s);for(let c=0;c<u.length;c+=3)E.normalize(u,c);return[[d.POSITION,new S(M(s),r,3,!0)],[d.NORMAL,new S(u,r,3,!0)]]}function ht(n,e,o,s,r,l,h,u,c=null){const a=o?i(o):g(),f=e?i(e):w(0,0,1);h??=t();const p=s?[255*s[0],255*s[1],255*s[2],s.length>3?255*s[3]:255]:[255,255,255,255],m=null!=r&&2===r.length?r:[1,1],O=A(1),M=[[d.POSITION,new S(a,O,3,!0)],[d.NORMAL,new S(f,O,3,!0)],[d.UV0,new S(h,O,h.length)],[d.COLOR,new S(p,O,4,!0)],[d.SIZE,new S(m,O,2)]];if(null!=l&&(l=[l[0],l[1],l[2],l[3]],M.push([d.CENTEROFFSETANDDISTANCE,new S(l,O,4)])),u){const t=[u[0],u[1],u[2],u[3]];M.push([d.FEATUREATTRIBUTE,new S(t,O,4)])}return new L(n,M,null,R.Point,c)}const ut=[[-1,-1,0],[1,-1,0],[1,1,0],[-1,1,0]];function ct(t,n=ut){const e=new Array(12);for(let c=0;c<4;c++)for(let t=0;t<3;t++)e[3*c+t]=n[c][t];const o=[0,1,2,2,3,0],s=[0,0,1],r=[0,0,0,0,0,0],l=[0,0,1,0,1,1,0,1],h=[255,255,255,255],u=[[d.POSITION,new S(e,o,3,!0)],[d.NORMAL,new S(s,r,3,!0)],[d.UV0,new S(l,o,2,!0)],[d.COLOR,new S(h,r,4,!0)]];return new L(t,u)}function at(t,n,e,o,s,r=!0,l=!0){let h=0;const u=e,c=n;let f=a(0,h,0),p=a(0,h+c,0),i=a(0,-1,0),g=a(0,1,0);s&&(h=c,p=a(0,0,0),f=a(0,h,0),i=a(0,1,0),g=a(0,-1,0));const w=[p,f],m=[i,g],M=o+2,A=Math.sqrt(c*c+u*u);if(s)for(let O=o-1;O>=0;O--){const t=O*(2*Math.PI/o),n=a(Math.cos(t)*u,h,Math.sin(t)*u);w.push(n);const e=a(c*Math.cos(t)/A,-u/A,c*Math.sin(t)/A);m.push(e)}else for(let O=0;O<o;O++){const t=O*(2*Math.PI/o),n=a(Math.cos(t)*u,h,Math.sin(t)*u);w.push(n);const e=a(c*Math.cos(t)/A,u/A,c*Math.sin(t)/A);m.push(e)}const I=new Array,y=new Array;if(r){for(let t=3;t<w.length;t++)I.push(1),I.push(t-1),I.push(t),y.push(0),y.push(0),y.push(0);I.push(w.length-1),I.push(2),I.push(1),y.push(0),y.push(0),y.push(0)}if(l){for(let t=3;t<w.length;t++)I.push(t),I.push(t-1),I.push(0),y.push(t),y.push(t-1),y.push(1);I.push(0),I.push(2),I.push(w.length-1),y.push(1),y.push(2),y.push(m.length-1)}const N=O(3*M);for(let a=0;a<M;a++)N[3*a]=w[a][0],N[3*a+1]=w[a][1],N[3*a+2]=w[a][2];const P=O(3*M);for(let a=0;a<M;a++)P[3*a]=m[a][0],P[3*a+1]=m[a][1],P[3*a+2]=m[a][2];const T=[[d.POSITION,new S(N,I,3,!0)],[d.NORMAL,new S(P,y,3,!0)]];return new L(t,T)}function ft(t,n,u,c,i,g,w){const m=i?p(i):a(1,0,0),M=g?p(g):a(0,0,0);w??=!0;const A=f();o(A,m);const I=f();s(I,A,Math.abs(n));const y=f();s(y,I,-.5),r(y,y,M);const N=a(0,1,0);Math.abs(1-l(A,N))<.2&&h(N,0,0,1);const P=f();e(P,A,N),o(P,P),e(N,P,A);const T=2*c+(w?2:0),b=c+(w?2:0),R=O(3*T),j=O(3*b),E=O(2*T),x=new Array(3*c*(w?4:2)),U=new Array(3*c*(w?4:2));w&&(R[3*(T-2)]=y[0],R[3*(T-2)+1]=y[1],R[3*(T-2)+2]=y[2],E[2*(T-2)]=0,E[2*(T-2)+1]=0,R[3*(T-1)]=R[3*(T-2)]+I[0],R[3*(T-1)+1]=R[3*(T-2)+1]+I[1],R[3*(T-1)+2]=R[3*(T-2)+2]+I[2],E[2*(T-1)]=1,E[2*(T-1)+1]=1,j[3*(b-2)]=-A[0],j[3*(b-2)+1]=-A[1],j[3*(b-2)+2]=-A[2],j[3*(b-1)]=A[0],j[3*(b-1)+1]=A[1],j[3*(b-1)+2]=A[2]);const V=(t,n,e)=>{x[t]=n,U[t]=e};let v=0;const F=f(),C=f();for(let e=0;e<c;e++){const t=e*(2*Math.PI/c);s(F,N,Math.sin(t)),s(C,P,Math.cos(t)),r(F,F,C),j[3*e]=F[0],j[3*e+1]=F[1],j[3*e+2]=F[2],s(F,F,u),r(F,F,y),R[3*e]=F[0],R[3*e+1]=F[1],R[3*e+2]=F[2],E[2*e]=e/c,E[2*e+1]=0,R[3*(e+c)]=R[3*e]+I[0],R[3*(e+c)+1]=R[3*e+1]+I[1],R[3*(e+c)+2]=R[3*e+2]+I[2],E[2*(e+c)]=e/c,E[2*e+1]=1;const n=(e+1)%c;V(v++,e,e),V(v++,e+c,e),V(v++,n,n),V(v++,n,n),V(v++,e+c,e),V(v++,n+c,n)}if(w){for(let t=0;t<c;t++){const n=(t+1)%c;V(v++,T-2,b-2),V(v++,t,b-2),V(v++,n,b-2)}for(let t=0;t<c;t++){const n=(t+1)%c;V(v++,t+c,b-1),V(v++,T-1,b-1),V(v++,n+c,b-1)}}const G=[[d.POSITION,new S(R,x,3,!0)],[d.NORMAL,new S(j,U,3,!0)],[d.UV0,new S(E,x,2,!0)]];return new L(t,G)}function pt(t,n,e,o,s,r){o=o||10,s=null==s||s,j(n.length>1);const l=[[0,0,0]],h=[],u=[];for(let c=0;c<o;c++){h.push([0,-c-1,-(c+1)%o-1]);const t=c/o*2*Math.PI;u.push([Math.cos(t)*e,Math.sin(t)*e])}return it(t,u,n,l,h,s,r)}function it(t,l,c,f,p,i,w=a(0,0,0)){const m=l.length,M=O(c.length*m*3+(6*f.length||0)),A=O(c.length*m*3+(f?6:0)),I=new Array,b=new Array;let R=0,j=0;const E=g(),x=g(),U=g(),V=g(),v=g(),F=g(),C=g(),G=g(),D=g(),k=g(),q=g(),B=g(),z=g(),Z=y();h(D,0,1,0),n(x,c[1],c[0]),o(x,x),i?(r(G,c[0],w),o(U,G)):h(U,0,0,1),At(x,U,D,D,v,U,It),u(V,U),u(B,v);for(let n=0;n<f.length;n++)s(F,v,f[n][0]),s(G,U,f[n][2]),r(F,F,G),r(F,F,c[0]),M[R++]=F[0],M[R++]=F[1],M[R++]=F[2];A[j++]=-x[0],A[j++]=-x[1],A[j++]=-x[2];for(let n=0;n<p.length;n++)I.push(p[n][0]>0?p[n][0]:-p[n][0]-1+f.length),I.push(p[n][1]>0?p[n][1]:-p[n][1]-1+f.length),I.push(p[n][2]>0?p[n][2]:-p[n][2]-1+f.length),b.push(0),b.push(0),b.push(0);let H=f.length;const J=f.length-1;for(let h=0;h<c.length;h++){let t=!1;if(h>0){u(E,x),h<c.length-1?(n(x,c[h+1],c[h]),o(x,x)):t=!0,r(k,E,x),o(k,k),r(q,c[h-1],V),N(c[h],k,Z);P(Z,T(q,E),G)?(n(G,G,c[h]),o(U,G),e(v,k,U),o(v,v)):At(k,V,B,D,v,U,It),u(V,U),u(B,v)}i&&(r(G,c[h],w),o(z,G));for(let n=0;n<m;n++)if(s(F,v,l[n][0]),s(G,U,l[n][1]),r(F,F,G),o(C,F),A[j++]=C[0],A[j++]=C[1],A[j++]=C[2],r(F,F,c[h]),M[R++]=F[0],M[R++]=F[1],M[R++]=F[2],!t){const t=(n+1)%m;I.push(H+n),I.push(H+m+n),I.push(H+t),I.push(H+t),I.push(H+m+n),I.push(H+m+t);for(let n=0;n<6;n++){const t=I.length-6;b.push(I[t+n]-J)}}H+=m}const K=c[c.length-1];for(let n=0;n<f.length;n++)s(F,v,f[n][0]),s(G,U,f[n][1]),r(F,F,G),r(F,F,K),M[R++]=F[0],M[R++]=F[1],M[R++]=F[2];const Q=j/3;A[j++]=x[0],A[j++]=x[1],A[j++]=x[2];const W=H-m;for(let n=0;n<p.length;n++)I.push(p[n][0]>=0?H+p[n][0]:-p[n][0]-1+W),I.push(p[n][2]>=0?H+p[n][2]:-p[n][2]-1+W),I.push(p[n][1]>=0?H+p[n][1]:-p[n][1]-1+W),b.push(Q),b.push(Q),b.push(Q);const X=[[d.POSITION,new S(M,I,3,!0)],[d.NORMAL,new S(A,b,3,!0)]];return new L(t,X)}function gt(t,n,e,o){j(n.length>1,"createPolylineGeometry(): polyline needs at least 2 points"),j(3===n[0].length,"createPolylineGeometry(): malformed vertex"),j(null==e||e.length===n.length,"createPolylineGeometry: need same number of points and normals"),j(null==e||3===e[0].length,"createPolylineGeometry(): malformed normal");const s=m(3*n.length),r=new Array(2*(n.length-1));let l=0,h=0;for(let c=0;c<n.length;c++){for(let t=0;t<3;t++)s[l++]=n[c][t];c>0&&(r[h++]=c-1,r[h++]=c)}const u=[[d.POSITION,new S(s,r,3,!0)]];if(e){const t=O(3*e.length);let o=0;for(let s=0;s<n.length;s++)for(let n=0;n<3;n++)t[o++]=e[s][n];u.push([d.NORMAL,new S(t,r,3,!0)])}return o&&u.push([d.COLOR,new S(o,I(o.length/4),4)]),new L(t,u,null,R.Line)}function wt(t,n,e,o,s,r=0){const l=new Array(18),h=[[-e,r,s/2],[o,r,s/2],[0,n+r,s/2],[-e,r,-s/2],[o,r,-s/2],[0,n+r,-s/2]],u=[0,1,2,3,0,2,2,5,3,1,4,5,5,2,1,1,0,3,3,4,1,4,3,5];for(let c=0;c<6;c++)l[3*c]=h[c][0],l[3*c+1]=h[c][1],l[3*c+2]=h[c][2];return new L(t,[[d.POSITION,new S(l,u,3,!0)]])}function mt(t,n){const e=t.getMutableAttribute(d.POSITION).data;for(let o=0;o<e.length;o+=3){const t=e[o],s=e[o+1],r=e[o+2];h(yt,t,s,r),c(yt,yt,n),e[o]=yt[0],e[o+1]=yt[1],e[o+2]=yt[2]}}function Ot(t,n=t){const e=t.attributes,o=e.get(d.POSITION).data,s=e.get(d.NORMAL).data;if(s){const t=n.getMutableAttribute(d.NORMAL).data;for(let n=0;n<s.length;n+=3){const e=s[n+1];t[n+1]=-s[n+2],t[n+2]=e}}if(o){const t=n.getMutableAttribute(d.POSITION).data;for(let n=0;n<o.length;n+=3){const e=o[n+1];t[n+1]=-o[n+2],t[n+2]=e}}}function Mt(t,n,s,r,h){return!(Math.abs(l(n,t))>h)&&(e(s,t,n),o(s,s),e(r,s,t),o(r,r),!0)}function At(t,n,e,o,s,r,l){return Mt(t,n,s,r,l)||Mt(t,e,s,r,l)||Mt(t,o,s,r,l)}const It=.99619469809,yt=g();export{Ot as cgToGIS,G as createBoxGeometry,at as createConeGeometry,ft as createCylinderGeometry,z as createDiamondGeometry,wt as createExtrudedTriangle,it as createPathExtrusionGeometry,ht as createPointGeometry,lt as createPolySphereData,rt as createPolySphereGeometry,gt as createPolylineGeometry,st as createSphereGeometry,ct as createSquareGeometry,ot as createTetrahedronGeometry,pt as createTubeGeometry,At as makeOrthoBasisDirUpFallback,mt as transformInPlace};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{copy as t,multiply as e,hasIdentityRotation as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as s,create as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{
|
|
5
|
+
import{copy as t,multiply as e,hasIdentityRotation as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as s,create as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{m as o,e as a,q as n,s as m,g as h,j as c,c as l}from"../../../../chunks/vec32.js";import{fromValues as d,create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{g,d as f}from"../../../../chunks/sphere.js";import{maxScale as b}from"../../support/mathUtils.js";import{Object3DState as _}from"./basicInterfaces.js";import{ContentObject as p}from"./ContentObject.js";import{ContentObjectType as v}from"./ContentObjectType.js";import{Object3DStateID as j}from"./Object3DStateID.js";import{assert as y}from"./Util.js";import{affectsGeometry as S}from"./VertexAttribute.js";import{addObject3DStateID as x,removeObject3DStateID as V}from"../materials/renderers/utils.js";class O extends p{get geometries(){return this._geometries}get transformation(){return this._transformation??s}set transformation(e){this._transformation=t(this._transformation??r(),e),this._invalidateBoundingVolume(),this._emit("transformationChanged",this)}get shaderTransformation(){return this._shaderTransformation}set shaderTransformation(e){this._shaderTransformation=e?t(this._shaderTransformation??r(),e):null,this._invalidateBoundingVolume(),this._emit("shaderTransformationChanged",this)}get effectiveTransformation(){return this.shaderTransformation??this.transformation}constructor(t={}){super(),this.type=v.Object,this._shaderTransformation=null,this._parentLayer=null,this._visible=!0,this.castShadow=t.castShadow??!0,this.usesVerticalDistanceToGround=t.usesVerticalDistanceToGround??!1,this.graphicUid=t.graphicUid,this.layerUid=t.layerUid,t.isElevationSource&&(this.lastValidElevationBB=new A),this._geometries=t.geometries?Array.from(t.geometries):new Array}dispose(){this._geometries.length=0}get parentLayer(){return this._parentLayer}set parentLayer(t){y(null==this._parentLayer||null==t,"Object3D can only be added to a single Layer"),this._parentLayer=t}addGeometry(t){t.visible=this._visible,this._geometries.push(t),this._emit("geometryAdded",{object:this,geometry:t}),this._invalidateBoundingVolume()}removeGeometry(t){const e=this._geometries.splice(t,1)[0];e&&(this._emit("geometryRemoved",{object:this,geometry:e}),this._invalidateBoundingVolume())}removeAllGeometries(){for(;this._geometries.length>0;)this.removeGeometry(0)}geometryVertexAttributeUpdated(t,e,i=!1){this._emit("attributesChanged",{object:this,geometry:t,attribute:e,sync:i}),S(e)&&this._invalidateBoundingVolume()}get visible(){return this._visible}set visible(t){if(this._visible!==t){this._visible=t;for(const t of this._geometries)t.visible=this._visible;this._emit("visibilityChanged",this)}}maskOccludee(){const t=new j(_.MaskOccludee);for(const e of this._geometries)e.occludees=x(e.occludees,t);return this._emit("occlusionChanged",this),t}removeOcclude(t){for(const e of this._geometries)e.occludees=V(e.occludees,t);this._emit("occlusionChanged",this)}highlight(){const t=new j(_.Highlight);for(const e of this._geometries)e.highlights=x(e.highlights,t);return this._emit("highlightChanged",this),t}removeHighlight(t){for(const e of this._geometries)e.highlights=V(e.highlights,t);this._emit("highlightChanged",this)}getCombinedStaticTransformation(t,i){return e(i,this.transformation,t.transformation)}getCombinedShaderTransformation(t,i=r()){return e(i,this.effectiveTransformation,t.transformation)}get boundingVolumeWorldSpace(){return this._bvWorldSpace||(this._bvWorldSpace=this._bvWorldSpace||new M,this._validateBoundingVolume(this._bvWorldSpace,W.WorldSpace)),this._bvWorldSpace}get boundingVolumeObjectSpace(){return this._bvObjectSpace||(this._bvObjectSpace=this._bvObjectSpace||new M,this._validateBoundingVolume(this._bvObjectSpace,W.ObjectSpace)),this._bvObjectSpace}_validateBoundingVolume(t,e){const i=e===W.ObjectSpace;for(const s of this._geometries){const e=s.boundingInfo;e&&L(e,t,i?s.transformation:this.getCombinedShaderTransformation(s))}o(g(t.bounds),t.min,t.max,.5);for(const s of this._geometries){const e=s.boundingInfo;if(null==e)continue;const r=i?s.transformation:this.getCombinedShaderTransformation(s),o=b(r);a(U,e.center,r);const m=n(U,g(t.bounds)),h=e.radius*o;t.bounds[3]=Math.max(t.bounds[3],m+h)}}_invalidateBoundingVolume(){const t=this._bvWorldSpace?.bounds;this._bvObjectSpace=this._bvWorldSpace=void 0,this._parentLayer&&t&&this._parentLayer.notifyObjectBBChanged(this,t)}_emit(t,e){this._parentLayer&&this._parentLayer.events.emit(t,e)}get test(){const t=this;return{hasGeometry:e=>t._geometries.includes(e),getGeometryIndex:e=>t._geometries.indexOf(e)}}}class A{constructor(){this.min=d(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this.max=d(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE)}isEmpty(){return this.max[0]<this.min[0]&&this.max[1]<this.min[1]&&this.max[2]<this.min[2]}}class M extends A{constructor(){super(...arguments),this.bounds=f()}}function L(t,e,s){const r=t.bbMin,o=t.bbMax;if(i(s)){const t=m(T,s[12],s[13],s[14]);h(C,r,t),h(B,o,t);for(let i=0;i<3;++i)e.min[i]=Math.min(e.min[i],C[i]),e.max[i]=Math.max(e.max[i],B[i])}else if(a(C,r,s),c(r,o))for(let i=0;i<3;++i)e.min[i]=Math.min(e.min[i],C[i]),e.max[i]=Math.max(e.max[i],C[i]);else{a(B,o,s);for(let t=0;t<3;++t)e.min[t]=Math.min(e.min[t],C[t],B[t]),e.max[t]=Math.max(e.max[t],C[t],B[t]);for(let t=0;t<3;++t){l(C,r),l(B,o),C[t]=o[t],B[t]=r[t],a(C,C,s),a(B,B,s);for(let t=0;t<3;++t)e.min[t]=Math.min(e.min[t],C[t],B[t]),e.max[t]=Math.max(e.max[t],C[t],B[t])}}}const T=u(),C=u(),B=u(),U=u();var W;!function(t){t[t.WorldSpace=0]="WorldSpace",t[t.ObjectSpace=1]="ObjectSpace"}(W||(W={}));export{O as Object3D};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../core/ObjectPool.js";import t from"../../../../core/PooledArray.js";import{h as o,g as n,a as i,c as s,k as r}from"../../../../chunks/vec32.js";import{create as h,fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as d}from"../../../../geometry/support/frustum.js";import{wrap as l}from"../../../../geometry/support/ray.js";import{c as u,g as c,a as f,i as m,d as _}from"../../../../chunks/sphere.js";import{rayBoxTest as p}from"./Util.js";class b{get bounds(){return this._root.bounds}get halfSize(){return this._root.halfSize}get root(){return this._root.node}get maximumObjectsPerNode(){return this._maximumObjectsPerNode}get maximumDepth(){return this._maximumDepth}get objectCount(){return this._objectCount}constructor(e,t){this.objectToBoundingSphere=e,this._maximumObjectsPerNode=10,this._maximumDepth=20,this._degenerateObjects=new Set,this._root=new g,this._objectCount=0,t&&(void 0!==t.maximumObjectsPerNode&&(this._maximumObjectsPerNode=t.maximumObjectsPerNode),void 0!==t.maximumDepth&&(this._maximumDepth=t.maximumDepth))}destroy(){this._degenerateObjects.clear(),g.clearPool(),B[0]=null,P.prune(),H.prune()}add(e,t=e.length){this._objectCount+=t,this._grow(e,t);const o=g.acquire();for(let n=0;n<t;n++){const t=e[n];this._isDegenerate(t)?this._degenerateObjects.add(t):(o.init(this._root),this._add(t,o))}g.release(o)}remove(e,t=null){this._objectCount-=e.length;const o=g.acquire();for(const n of e){const e=t??u(this.objectToBoundingSphere(n),w);E(e[3])?(o.init(this._root),this._remove(n,e,o)):this._degenerateObjects.delete(n)}g.release(o),this._shrink()}update(e,t){if(!E(t[3])&&this._isDegenerate(e))return;const o=R(e);this.remove(o,t),this.add(o)}forEachAlongRay(e,t,o){const n=l(e,t);this._forEachNode(this._root,(e=>{if(!this._intersectsNode(n,e))return!1;const t=e.node;return t.terminals.forAll((e=>{this._intersectsObject(n,e)&&o(e)})),null!==t.residents&&t.residents.forAll((e=>{this._intersectsObject(n,e)&&o(e)})),!0}))}forEachAlongRayWithVerticalOffset(e,t,o,n){const i=l(e,t);this._forEachNode(this._root,(e=>{if(!this._intersectsNodeWithOffset(i,e,n))return!1;const t=e.node;return t.terminals.forAll((e=>{this._intersectsObjectWithOffset(i,e,n)&&o(e)})),null!==t.residents&&t.residents.forAll((e=>{this._intersectsObjectWithOffset(i,e,n)&&o(e)})),!0}))}forEach(e){this._forEachNode(this._root,(t=>{const o=t.node;return o.terminals.forAll(e),null!==o.residents&&o.residents.forAll(e),!0})),this._degenerateObjects.forEach(e)}forEachDegenerateObject(e){this._degenerateObjects.forEach(e)}findClosest(e,t,i,s=(()=>!0),r=1/0){let h=1/0,a=1/0,l=null;const u=T(e,t),f=o=>{if(--r,!s(o))return;const n=this.objectToBoundingSphere(o);if(!d(i,n))return;const u=z(e,t,c(n)),f=u-n[3],m=u+n[3];f<h&&(h=f,a=m,l=o)};return this._forEachNodeDepthOrdered(this._root,(s=>{if(r<=0||!d(i,s.bounds))return!1;o(v,u,s.halfSize),n(v,v,c(s.bounds));if(z(e,t,v)>a)return!1;const h=s.node;return h.terminals.forAll((e=>f(e))),null!==h.residents&&h.residents.forAll((e=>f(e))),!0}),e,t),l}forEachInDepthRange(e,t,i,s,r,h,a){let l=-1/0,u=1/0;const f={setRange:e=>{i===b.DepthOrder.FRONT_TO_BACK?(l=Math.max(l,e.near),u=Math.min(u,e.far)):(l=Math.max(l,-e.far),u=Math.min(u,-e.near))}};f.setRange(s);const m=z(t,i,e),_=T(t,i),p=T(t,-i),g=e=>{if(!a(e))return;const o=this.objectToBoundingSphere(e),n=c(o),s=z(t,i,n)-m,_=s-o[3],p=s+o[3];_>u||p<l||!d(h,o)||r(e,f)};this._forEachNodeDepthOrdered(this._root,(e=>{if(!d(h,e.bounds))return!1;o(v,_,e.halfSize),n(v,v,c(e.bounds));if(z(t,i,v)-m>u)return!1;o(v,p,e.halfSize),n(v,v,c(e.bounds));if(z(t,i,v)-m<l)return!1;const s=e.node;return s.terminals.forAll((e=>g(e))),null!==s.residents&&s.residents.forAll((e=>g(e))),!0}),t,i)}forEachNode(e){this._forEachNode(this._root,(t=>e(t.node,t.bounds,t.halfSize,t.depth)))}forEachNeighbor(e,t){const o=f(t),n=c(t),s=t=>{const s=this.objectToBoundingSphere(t),r=f(s),h=o+r;return!(i(c(s),n)-h*h<=0)||e(t)};let r=!0;const h=e=>{r&&(r=s(e))};this._forEachNode(this._root,(e=>{const t=f(e.bounds),s=o+t;if(i(c(e.bounds),n)-s*s>0)return!1;const a=e.node;return a.terminals.forAll(h),r&&null!==a.residents&&a.residents.forAll(h),r})),r&&this.forEachDegenerateObject(h)}_intersectsNode(e,t){return j(c(t.bounds),2*-t.halfSize,C),j(c(t.bounds),2*t.halfSize,y),p(e.origin,e.direction,C,y)}_intersectsNodeWithOffset(e,t,o){return j(c(t.bounds),2*-t.halfSize,C),j(c(t.bounds),2*t.halfSize,y),o.applyToMinMax(C,y),p(e.origin,e.direction,C,y)}_intersectsObject(e,t){const o=this.objectToBoundingSphere(t);return!(o[3]>0)||m(o,e)}_intersectsObjectWithOffset(e,t,o){const n=this.objectToBoundingSphere(t);return!(n[3]>0)||m(o.applyToBoundingSphere(n),e)}_forEachNode(e,t){let o=g.acquire().init(e);const n=[o];for(;0!==n.length;){if(o=n.pop(),t(o)&&!o.isLeaf())for(let e=0;e<o.node.children.length;e++){o.node.children[e]&&n.push(g.acquire().init(o).advance(e))}g.release(o)}}_forEachNodeDepthOrdered(e,t,o,n=b.DepthOrder.FRONT_TO_BACK){let i=g.acquire().init(e);const s=[i];for(N(o,n,K);0!==s.length;){if(i=s.pop(),t(i)&&!i.isLeaf())for(let e=7;e>=0;--e){const t=K[e];i.node.children[t]&&s.push(g.acquire().init(i).advance(t))}g.release(i)}}_remove(e,t,o){P.clear();const n=o.advanceTo(t,((e,t)=>{P.push(e.node),P.push(t)}))?o.node.terminals:o.node.residents;if(n.removeUnordered(e),0===n.length)for(let i=P.length-2;i>=0;i-=2){const e=P.data[i],t=P.data[i+1];if(!this._purge(e,t))break}}_nodeIsEmpty(e){if(0!==e.terminals.length)return!1;if(null!==e.residents)return 0===e.residents.length;for(let t=0;t<e.children.length;t++)if(e.children[t])return!1;return!0}_purge(e,o){return o>=0&&(e.children[o]=null),!!this._nodeIsEmpty(e)&&(null===e.residents&&(e.residents=new t({shrink:!0})),!0)}_add(e,t){t.advanceTo(this.objectToBoundingSphere(e))?t.node.terminals.push(e):(t.node.residents.push(e),t.node.residents.length>this._maximumObjectsPerNode&&t.depth<this._maximumDepth&&this._split(t))}_split(e){const t=e.node.residents;e.node.residents=null;for(let o=0;o<t.length;o++){const n=g.acquire().init(e);this._add(t.at(o),n),g.release(n)}}_grow(e,t){if(0!==t&&(x(e,t,(e=>this.objectToBoundingSphere(e)),k),E(k[3])&&!this._fitsInsideTree(k)))if(this._nodeIsEmpty(this._root.node))u(k,this._root.bounds),this._root.halfSize=1.25*this._root.bounds[3],this._root.updateBoundsRadiusFromHalfSize();else{const e=this._rootBoundsForRootAsSubNode(k);this._placingRootViolatesMaxDepth(e)?this._rebuildTree(k,e):this._growRootAsSubNode(e),g.release(e)}}_rebuildTree(e,t){s(c(q),c(t.bounds)),q[3]=t.halfSize,x([e,q],2,(e=>e),I);const o=g.acquire().init(this._root);this._root.initFrom(null,I,I[3]),this._root.increaseHalfSize(1.25),this._forEachNode(o,(e=>(this.add(e.node.terminals.data,e.node.terminals.length),null!==e.node.residents&&this.add(e.node.residents.data,e.node.residents.length),!0))),g.release(o)}_placingRootViolatesMaxDepth(e){const t=Math.log(e.halfSize/this._root.halfSize)*Math.LOG2E;let o=0;return this._forEachNode(this._root,(e=>(o=Math.max(o,e.depth),o+t<=this._maximumDepth))),o+t>this._maximumDepth}_rootBoundsForRootAsSubNode(e){const t=e[3],o=e;let n=-1/0;const i=this._root.bounds,s=this._root.halfSize;for(let h=0;h<3;h++){const e=i[h]-s-(o[h]-t),r=o[h]+t-(i[h]+s),a=Math.max(0,Math.ceil(e/(2*s))),d=Math.max(0,Math.ceil(r/(2*s)))+1,l=2**Math.ceil(Math.log(a+d)*Math.LOG2E);n=Math.max(n,l),L[h].min=a,L[h].max=d}for(let h=0;h<3;h++){let e=L[h].min,t=L[h].max;const o=(n-(e+t))/2;e+=Math.ceil(o),t+=Math.floor(o);const r=i[h]-s-e*s*2;F[h]=r+(t+e)*s}const r=n*s;return F[3]=r*A,g.acquire().initFrom(null,F,r,0)}_growRootAsSubNode(e){const t=this._root.node;s(c(k),c(this._root.bounds)),k[3]=this._root.halfSize,this._root.init(e),e.advanceTo(k,null,!0),e.node.children=t.children,e.node.residents=t.residents,e.node.terminals=t.terminals}_shrink(){for(;;){const e=this._findShrinkIndex();if(-1===e)break;this._root.advance(e),this._root.depth=0}}_findShrinkIndex(){if(0!==this._root.node.terminals.length||this._root.isLeaf())return-1;let e=null;const t=this._root.node.children;let o=0,n=0;for(;n<t.length&&null==e;)o=n++,e=t[o];for(;n<t.length;)if(t[n++])return-1;return o}_isDegenerate(e){return!E(this.objectToBoundingSphere(e)[3])}_fitsInsideTree(e){const t=this._root.bounds,o=this._root.halfSize;return e[3]<=o&&e[0]>=t[0]-o&&e[0]<=t[0]+o&&e[1]>=t[1]-o&&e[1]<=t[1]+o&&e[2]>=t[2]-o&&e[2]<=t[2]+o}toJSON(){const{maximumDepth:e,maximumObjectsPerNode:t,_objectCount:o}=this,n=this._nodeToJSON(this._root.node);return{maximumDepth:e,maximumObjectsPerNode:t,objectCount:o,root:{bounds:this._root.bounds,halfSize:this._root.halfSize,depth:this._root.depth,node:n}}}_nodeToJSON(e){const t=e.children.map((e=>e?this._nodeToJSON(e):null)),o=e.residents?.map((e=>this.objectToBoundingSphere(e))),n=e.terminals?.map((e=>this.objectToBoundingSphere(e)));return{children:t,residents:o,terminals:n}}static fromJSON(e){const t=new b((e=>e),{maximumDepth:e.maximumDepth,maximumObjectsPerNode:e.maximumObjectsPerNode});return t._objectCount=e.objectCount,t._root.initFrom(e.root.node,e.root.bounds,e.root.halfSize,e.root.depth),t}}class g{constructor(){this.bounds=_(),this.halfSize=0,this.initFrom(null,null,0,0)}init(e){return this.initFrom(e.node,e.bounds,e.halfSize,e.depth)}initFrom(e,t,o,n=this.depth){return this.node=null!=e?e:g.createEmptyNode(),t&&u(t,this.bounds),this.halfSize=o,this.depth=n,this}increaseHalfSize(e){this.halfSize*=e,this.updateBoundsRadiusFromHalfSize()}updateBoundsRadiusFromHalfSize(){this.bounds[3]=this.halfSize*A}advance(e){let t=this.node.children[e];t||(t=g.createEmptyNode(),this.node.children[e]=t),this.node=t,this.halfSize/=2,this.depth++;const o=M[e];return this.bounds[0]+=o[0]*this.halfSize,this.bounds[1]+=o[1]*this.halfSize,this.bounds[2]+=o[2]*this.halfSize,this.updateBoundsRadiusFromHalfSize(),this}advanceTo(e,t,o=!1){for(;;){if(this.isTerminalFor(e))return t&&t(this,-1),!0;if(this.isLeaf()){if(!o)return t&&t(this,-1),!1;this.node.residents=null}const n=this._childIndex(e);t&&t(this,n),this.advance(n)}}isLeaf(){return null!=this.node.residents}isTerminalFor(e){return e[3]>this.halfSize/2}_childIndex(e){const t=this.bounds;return(t[0]<e[0]?1:0)+(t[1]<e[1]?2:0)+(t[2]<e[2]?4:0)}static createEmptyNode(){return{children:[null,null,null,null,null,null,null,null],terminals:new t({shrink:!0}),residents:new t({shrink:!0})}}static acquire(){return g._pool.acquire()}static release(e){g._pool.release(e)}static clearPool(){g._pool.prune()}}function S(e,t){e[0]=Math.min(e[0],t[0]-t[3]),e[1]=Math.min(e[1],t[1]-t[3]),e[2]=Math.min(e[2],t[2]-t[3])}function O(e,t){e[0]=Math.max(e[0],t[0]+t[3]),e[1]=Math.max(e[1],t[1]+t[3]),e[2]=Math.max(e[2],t[2]+t[3])}function j(e,t,o){o[0]=e[0]+t,o[1]=e[1]+t,o[2]=e[2]+t}function x(e,t,o,n){if(1===t){const t=o(e[0]);u(t,n)}else{C[0]=1/0,C[1]=1/0,C[2]=1/0,y[0]=-1/0,y[1]=-1/0,y[2]=-1/0;for(let n=0;n<t;n++){const t=o(e[n]);E(t[3])&&(S(C,t),O(y,t))}r(c(n),C,y,.5),n[3]=Math.max(y[0]-C[0],y[1]-C[1],y[2]-C[2])/2}}function N(e,t,o){if(!H.length)for(let n=0;n<8;++n)H.push({index:0,distance:0});for(let n=0;n<8;++n){const o=M[n];H.data[n].index=n,H.data[n].distance=z(e,t,o)}H.sort(((e,t)=>e.distance-t.distance));for(let n=0;n<8;++n)o[n]=H.data[n].index}function T(e,t){let o,n=1/0;for(let i=0;i<8;++i){const s=z(e,t,D[i]);s<n&&(n=s,o=D[i])}return o}function z(e,t,o){return t*(e[0]*o[0]+e[1]*o[1]+e[2]*o[2])}function E(e){return!isNaN(e)&&e!==-1/0&&e!==1/0&&e>0}g._pool=new e(g),function(e){var t;(t=e.DepthOrder||(e.DepthOrder={}))[t.FRONT_TO_BACK=1]="FRONT_TO_BACK",t[t.BACK_TO_FRONT=-1]="BACK_TO_FRONT"}(b||(b={}));const M=[a(-1,-1,-1),a(1,-1,-1),a(-1,1,-1),a(1,1,-1),a(-1,-1,1),a(1,-1,1),a(-1,1,1),a(1,1,1)],D=[a(-1,-1,-1),a(-1,-1,1),a(-1,1,-1),a(-1,1,1),a(1,-1,-1),a(1,-1,1),a(1,1,-1),a(1,1,1)],A=Math.sqrt(3),B=[null];function R(e){return B[0]=e,B}const F=_(),v=h(),C=h(),y=h(),P=new t,w=_(),k=_(),q=_(),I=_(),L=[{min:0,max:0},{min:0,max:0},{min:0,max:0}],H=new t,K=[0,0,0,0,0,0,0,0],W=b;export{W as default};
|
|
5
|
+
import e from"../../../../core/ObjectPool.js";import t from"../../../../core/PooledArray.js";import{h as o,g as n,a as i,c as s,m as r}from"../../../../chunks/vec32.js";import{create as h,fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as d}from"../../../../geometry/support/frustum.js";import{wrap as l}from"../../../../geometry/support/ray.js";import{c as u,g as c,a as f,i as m,d as _}from"../../../../chunks/sphere.js";import{rayBoxTest as p}from"./Util.js";class b{get bounds(){return this._root.bounds}get halfSize(){return this._root.halfSize}get root(){return this._root.node}get maximumObjectsPerNode(){return this._maximumObjectsPerNode}get maximumDepth(){return this._maximumDepth}get objectCount(){return this._objectCount}constructor(e,t){this.objectToBoundingSphere=e,this._maximumObjectsPerNode=10,this._maximumDepth=20,this._degenerateObjects=new Set,this._root=new g,this._objectCount=0,t&&(void 0!==t.maximumObjectsPerNode&&(this._maximumObjectsPerNode=t.maximumObjectsPerNode),void 0!==t.maximumDepth&&(this._maximumDepth=t.maximumDepth))}destroy(){this._degenerateObjects.clear(),g.clearPool(),B[0]=null,P.prune(),H.prune()}add(e,t=e.length){this._objectCount+=t,this._grow(e,t);const o=g.acquire();for(let n=0;n<t;n++){const t=e[n];this._isDegenerate(t)?this._degenerateObjects.add(t):(o.init(this._root),this._add(t,o))}g.release(o)}remove(e,t=null){this._objectCount-=e.length;const o=g.acquire();for(const n of e){const e=t??u(this.objectToBoundingSphere(n),w);E(e[3])?(o.init(this._root),this._remove(n,e,o)):this._degenerateObjects.delete(n)}g.release(o),this._shrink()}update(e,t){if(!E(t[3])&&this._isDegenerate(e))return;const o=R(e);this.remove(o,t),this.add(o)}forEachAlongRay(e,t,o){const n=l(e,t);this._forEachNode(this._root,(e=>{if(!this._intersectsNode(n,e))return!1;const t=e.node;return t.terminals.forAll((e=>{this._intersectsObject(n,e)&&o(e)})),null!==t.residents&&t.residents.forAll((e=>{this._intersectsObject(n,e)&&o(e)})),!0}))}forEachAlongRayWithVerticalOffset(e,t,o,n){const i=l(e,t);this._forEachNode(this._root,(e=>{if(!this._intersectsNodeWithOffset(i,e,n))return!1;const t=e.node;return t.terminals.forAll((e=>{this._intersectsObjectWithOffset(i,e,n)&&o(e)})),null!==t.residents&&t.residents.forAll((e=>{this._intersectsObjectWithOffset(i,e,n)&&o(e)})),!0}))}forEach(e){this._forEachNode(this._root,(t=>{const o=t.node;return o.terminals.forAll(e),null!==o.residents&&o.residents.forAll(e),!0})),this._degenerateObjects.forEach(e)}forEachDegenerateObject(e){this._degenerateObjects.forEach(e)}findClosest(e,t,i,s=(()=>!0),r=1/0){let h=1/0,a=1/0,l=null;const u=T(e,t),f=o=>{if(--r,!s(o))return;const n=this.objectToBoundingSphere(o);if(!d(i,n))return;const u=z(e,t,c(n)),f=u-n[3],m=u+n[3];f<h&&(h=f,a=m,l=o)};return this._forEachNodeDepthOrdered(this._root,(s=>{if(r<=0||!d(i,s.bounds))return!1;o(v,u,s.halfSize),n(v,v,c(s.bounds));if(z(e,t,v)>a)return!1;const h=s.node;return h.terminals.forAll((e=>f(e))),null!==h.residents&&h.residents.forAll((e=>f(e))),!0}),e,t),l}forEachInDepthRange(e,t,i,s,r,h,a){let l=-1/0,u=1/0;const f={setRange:e=>{i===b.DepthOrder.FRONT_TO_BACK?(l=Math.max(l,e.near),u=Math.min(u,e.far)):(l=Math.max(l,-e.far),u=Math.min(u,-e.near))}};f.setRange(s);const m=z(t,i,e),_=T(t,i),p=T(t,-i),g=e=>{if(!a(e))return;const o=this.objectToBoundingSphere(e),n=c(o),s=z(t,i,n)-m,_=s-o[3],p=s+o[3];_>u||p<l||!d(h,o)||r(e,f)};this._forEachNodeDepthOrdered(this._root,(e=>{if(!d(h,e.bounds))return!1;o(v,_,e.halfSize),n(v,v,c(e.bounds));if(z(t,i,v)-m>u)return!1;o(v,p,e.halfSize),n(v,v,c(e.bounds));if(z(t,i,v)-m<l)return!1;const s=e.node;return s.terminals.forAll((e=>g(e))),null!==s.residents&&s.residents.forAll((e=>g(e))),!0}),t,i)}forEachNode(e){this._forEachNode(this._root,(t=>e(t.node,t.bounds,t.halfSize,t.depth)))}forEachNeighbor(e,t){const o=f(t),n=c(t),s=t=>{const s=this.objectToBoundingSphere(t),r=f(s),h=o+r;return!(i(c(s),n)-h*h<=0)||e(t)};let r=!0;const h=e=>{r&&(r=s(e))};this._forEachNode(this._root,(e=>{const t=f(e.bounds),s=o+t;if(i(c(e.bounds),n)-s*s>0)return!1;const a=e.node;return a.terminals.forAll(h),r&&null!==a.residents&&a.residents.forAll(h),r})),r&&this.forEachDegenerateObject(h)}_intersectsNode(e,t){return j(c(t.bounds),2*-t.halfSize,C),j(c(t.bounds),2*t.halfSize,y),p(e.origin,e.direction,C,y)}_intersectsNodeWithOffset(e,t,o){return j(c(t.bounds),2*-t.halfSize,C),j(c(t.bounds),2*t.halfSize,y),o.applyToMinMax(C,y),p(e.origin,e.direction,C,y)}_intersectsObject(e,t){const o=this.objectToBoundingSphere(t);return!(o[3]>0)||m(o,e)}_intersectsObjectWithOffset(e,t,o){const n=this.objectToBoundingSphere(t);return!(n[3]>0)||m(o.applyToBoundingSphere(n),e)}_forEachNode(e,t){let o=g.acquire().init(e);const n=[o];for(;0!==n.length;){if(o=n.pop(),t(o)&&!o.isLeaf())for(let e=0;e<o.node.children.length;e++){o.node.children[e]&&n.push(g.acquire().init(o).advance(e))}g.release(o)}}_forEachNodeDepthOrdered(e,t,o,n=b.DepthOrder.FRONT_TO_BACK){let i=g.acquire().init(e);const s=[i];for(N(o,n,K);0!==s.length;){if(i=s.pop(),t(i)&&!i.isLeaf())for(let e=7;e>=0;--e){const t=K[e];i.node.children[t]&&s.push(g.acquire().init(i).advance(t))}g.release(i)}}_remove(e,t,o){P.clear();const n=o.advanceTo(t,((e,t)=>{P.push(e.node),P.push(t)}))?o.node.terminals:o.node.residents;if(n.removeUnordered(e),0===n.length)for(let i=P.length-2;i>=0;i-=2){const e=P.data[i],t=P.data[i+1];if(!this._purge(e,t))break}}_nodeIsEmpty(e){if(0!==e.terminals.length)return!1;if(null!==e.residents)return 0===e.residents.length;for(let t=0;t<e.children.length;t++)if(e.children[t])return!1;return!0}_purge(e,o){return o>=0&&(e.children[o]=null),!!this._nodeIsEmpty(e)&&(null===e.residents&&(e.residents=new t({shrink:!0})),!0)}_add(e,t){t.advanceTo(this.objectToBoundingSphere(e))?t.node.terminals.push(e):(t.node.residents.push(e),t.node.residents.length>this._maximumObjectsPerNode&&t.depth<this._maximumDepth&&this._split(t))}_split(e){const t=e.node.residents;e.node.residents=null;for(let o=0;o<t.length;o++){const n=g.acquire().init(e);this._add(t.at(o),n),g.release(n)}}_grow(e,t){if(0!==t&&(x(e,t,(e=>this.objectToBoundingSphere(e)),q),E(q[3])&&!this._fitsInsideTree(q)))if(this._nodeIsEmpty(this._root.node))u(q,this._root.bounds),this._root.halfSize=1.25*this._root.bounds[3],this._root.updateBoundsRadiusFromHalfSize();else{const e=this._rootBoundsForRootAsSubNode(q);this._placingRootViolatesMaxDepth(e)?this._rebuildTree(q,e):this._growRootAsSubNode(e),g.release(e)}}_rebuildTree(e,t){s(c(k),c(t.bounds)),k[3]=t.halfSize,x([e,k],2,(e=>e),I);const o=g.acquire().init(this._root);this._root.initFrom(null,I,I[3]),this._root.increaseHalfSize(1.25),this._forEachNode(o,(e=>(this.add(e.node.terminals.data,e.node.terminals.length),null!==e.node.residents&&this.add(e.node.residents.data,e.node.residents.length),!0))),g.release(o)}_placingRootViolatesMaxDepth(e){const t=Math.log(e.halfSize/this._root.halfSize)*Math.LOG2E;let o=0;return this._forEachNode(this._root,(e=>(o=Math.max(o,e.depth),o+t<=this._maximumDepth))),o+t>this._maximumDepth}_rootBoundsForRootAsSubNode(e){const t=e[3],o=e;let n=-1/0;const i=this._root.bounds,s=this._root.halfSize;for(let h=0;h<3;h++){const e=i[h]-s-(o[h]-t),r=o[h]+t-(i[h]+s),a=Math.max(0,Math.ceil(e/(2*s))),d=Math.max(0,Math.ceil(r/(2*s)))+1,l=2**Math.ceil(Math.log(a+d)*Math.LOG2E);n=Math.max(n,l),L[h].min=a,L[h].max=d}for(let h=0;h<3;h++){let e=L[h].min,t=L[h].max;const o=(n-(e+t))/2;e+=Math.ceil(o),t+=Math.floor(o);const r=i[h]-s-e*s*2;F[h]=r+(t+e)*s}const r=n*s;return F[3]=r*A,g.acquire().initFrom(null,F,r,0)}_growRootAsSubNode(e){const t=this._root.node;s(c(q),c(this._root.bounds)),q[3]=this._root.halfSize,this._root.init(e),e.advanceTo(q,null,!0),e.node.children=t.children,e.node.residents=t.residents,e.node.terminals=t.terminals}_shrink(){for(;;){const e=this._findShrinkIndex();if(-1===e)break;this._root.advance(e),this._root.depth=0}}_findShrinkIndex(){if(0!==this._root.node.terminals.length||this._root.isLeaf())return-1;let e=null;const t=this._root.node.children;let o=0,n=0;for(;n<t.length&&null==e;)o=n++,e=t[o];for(;n<t.length;)if(t[n++])return-1;return o}_isDegenerate(e){return!E(this.objectToBoundingSphere(e)[3])}_fitsInsideTree(e){const t=this._root.bounds,o=this._root.halfSize;return e[3]<=o&&e[0]>=t[0]-o&&e[0]<=t[0]+o&&e[1]>=t[1]-o&&e[1]<=t[1]+o&&e[2]>=t[2]-o&&e[2]<=t[2]+o}toJSON(){const{maximumDepth:e,maximumObjectsPerNode:t,_objectCount:o}=this,n=this._nodeToJSON(this._root.node);return{maximumDepth:e,maximumObjectsPerNode:t,objectCount:o,root:{bounds:this._root.bounds,halfSize:this._root.halfSize,depth:this._root.depth,node:n}}}_nodeToJSON(e){const t=e.children.map((e=>e?this._nodeToJSON(e):null)),o=e.residents?.map((e=>this.objectToBoundingSphere(e))),n=e.terminals?.map((e=>this.objectToBoundingSphere(e)));return{children:t,residents:o,terminals:n}}static fromJSON(e){const t=new b((e=>e),{maximumDepth:e.maximumDepth,maximumObjectsPerNode:e.maximumObjectsPerNode});return t._objectCount=e.objectCount,t._root.initFrom(e.root.node,e.root.bounds,e.root.halfSize,e.root.depth),t}}class g{constructor(){this.bounds=_(),this.halfSize=0,this.initFrom(null,null,0,0)}init(e){return this.initFrom(e.node,e.bounds,e.halfSize,e.depth)}initFrom(e,t,o,n=this.depth){return this.node=null!=e?e:g.createEmptyNode(),t&&u(t,this.bounds),this.halfSize=o,this.depth=n,this}increaseHalfSize(e){this.halfSize*=e,this.updateBoundsRadiusFromHalfSize()}updateBoundsRadiusFromHalfSize(){this.bounds[3]=this.halfSize*A}advance(e){let t=this.node.children[e];t||(t=g.createEmptyNode(),this.node.children[e]=t),this.node=t,this.halfSize/=2,this.depth++;const o=M[e];return this.bounds[0]+=o[0]*this.halfSize,this.bounds[1]+=o[1]*this.halfSize,this.bounds[2]+=o[2]*this.halfSize,this.updateBoundsRadiusFromHalfSize(),this}advanceTo(e,t,o=!1){for(;;){if(this.isTerminalFor(e))return t&&t(this,-1),!0;if(this.isLeaf()){if(!o)return t&&t(this,-1),!1;this.node.residents=null}const n=this._childIndex(e);t&&t(this,n),this.advance(n)}}isLeaf(){return null!=this.node.residents}isTerminalFor(e){return e[3]>this.halfSize/2}_childIndex(e){const t=this.bounds;return(t[0]<e[0]?1:0)+(t[1]<e[1]?2:0)+(t[2]<e[2]?4:0)}static createEmptyNode(){return{children:[null,null,null,null,null,null,null,null],terminals:new t({shrink:!0}),residents:new t({shrink:!0})}}static acquire(){return g._pool.acquire()}static release(e){g._pool.release(e)}static clearPool(){g._pool.prune()}}function S(e,t){e[0]=Math.min(e[0],t[0]-t[3]),e[1]=Math.min(e[1],t[1]-t[3]),e[2]=Math.min(e[2],t[2]-t[3])}function O(e,t){e[0]=Math.max(e[0],t[0]+t[3]),e[1]=Math.max(e[1],t[1]+t[3]),e[2]=Math.max(e[2],t[2]+t[3])}function j(e,t,o){o[0]=e[0]+t,o[1]=e[1]+t,o[2]=e[2]+t}function x(e,t,o,n){if(1===t){const t=o(e[0]);u(t,n)}else{C[0]=1/0,C[1]=1/0,C[2]=1/0,y[0]=-1/0,y[1]=-1/0,y[2]=-1/0;for(let n=0;n<t;n++){const t=o(e[n]);E(t[3])&&(S(C,t),O(y,t))}r(c(n),C,y,.5),n[3]=Math.max(y[0]-C[0],y[1]-C[1],y[2]-C[2])/2}}function N(e,t,o){if(!H.length)for(let n=0;n<8;++n)H.push({index:0,distance:0});for(let n=0;n<8;++n){const o=M[n];H.data[n].index=n,H.data[n].distance=z(e,t,o)}H.sort(((e,t)=>e.distance-t.distance));for(let n=0;n<8;++n)o[n]=H.data[n].index}function T(e,t){let o,n=1/0;for(let i=0;i<8;++i){const s=z(e,t,D[i]);s<n&&(n=s,o=D[i])}return o}function z(e,t,o){return t*(e[0]*o[0]+e[1]*o[1]+e[2]*o[2])}function E(e){return!isNaN(e)&&e!==-1/0&&e!==1/0&&e>0}g._pool=new e(g),function(e){var t;(t=e.DepthOrder||(e.DepthOrder={}))[t.FRONT_TO_BACK=1]="FRONT_TO_BACK",t[t.BACK_TO_FRONT=-1]="BACK_TO_FRONT"}(b||(b={}));const M=[a(-1,-1,-1),a(1,-1,-1),a(-1,1,-1),a(1,1,-1),a(-1,-1,1),a(1,-1,1),a(-1,1,1),a(1,1,1)],D=[a(-1,-1,-1),a(-1,-1,1),a(-1,1,-1),a(-1,1,1),a(1,-1,-1),a(1,-1,1),a(1,1,-1),a(1,1,1)],A=Math.sqrt(3),B=[null];function R(e){return B[0]=e,B}const F=_(),v=h(),C=h(),y=h(),P=new t,w=_(),q=_(),k=_(),I=_(),L=[{min:0,max:0},{min:0,max:0},{min:0,max:0}],H=new t,K=[0,0,0,0,0,0,0,0],W=b;export{W as default};
|