@arcgis/core 4.29.0-next.20240222 → 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/0bc21d2a0b65bd4e9d76.js +1 -0
- 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/{e7b26c7e9e24dc6255be.js → cacf97b0a7a1057b9f79.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/config.js +1 -1
- package/copyright.txt +56 -28
- 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 +12 -12
- 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/CameraOrientation.js +1 -1
- package/layers/orientedImagery/core/ElevationSourceDefinitions.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 +5 -0
- package/layers/orientedImagery/transformations/updateElevation.js +5 -0
- package/layers/orientedImagery/transformations/updateElevationUtils.js +5 -0
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/layers/orientedImagery/transformations/worldToImage.js +5 -0
- package/layers/support/EditingCapabilities.js +1 -1
- package/layers/support/editableLayers.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/smartMapping/renderers/pieChart.js +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/I3SOverrides.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/layers/support/editableLayerViews.js +5 -0
- 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/Editor/support/EditorEditingCapabilities.js +1 -1
- package/widgets/Editor/support/EditorItem.js +1 -1
- package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
- package/widgets/FeatureForm.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/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer.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/UtilityNetworkTrace.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/25f73748df0ee82d06cb.js +0 -1
- package/assets/esri/core/workers/chunks/2d7a18f8c540269ecee9.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/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
|
@@ -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};
|
|
@@ -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{acosClamped as t,reciprocalClamped as i}from"../../../../core/mathUtils.js";import{set as r}from"../../../../core/libs/gl-matrix-2/math/mat2.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat2f64.js";import{set as e,transformMat2 as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{UNIT_X as h,create as o}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{c as n,g as m,n as g,h as f,
|
|
5
|
+
import{acosClamped as t,reciprocalClamped as i}from"../../../../core/mathUtils.js";import{set as r}from"../../../../core/libs/gl-matrix-2/math/mat2.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat2f64.js";import{set as e,transformMat2 as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{UNIT_X as h,create as o}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{c as n,g as m,n as g,h as f,k as c,f as u,b as l,F as p}from"../../../../chunks/vec32.js";import{create as v}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Frame2D as M}from"./PathExtruder.js";import{UpVectorAlignment as b}from"./PathGeometry.js";class R{constructor(){this.vLeft=v(),this.vRight=v(),this.vMinSiblingLength=0,this.frame=new M}setFrameFromUpVector(t){n(this.frame.up,t),m(k,this.vLeft,this.vRight),g(k,k),f(I,this.frame.up,c(k,this.frame.up)),u(D,k,I),g(D,D),l(this.frame.right,D,this.frame.up)}get foldingAngle(){return Math.PI-this.rotationAngle}}class x extends R{get rotationFrameUp(){return this.frame.up}get rotationRight(){return h}get rotationAngle(){f(w,this.frame.up,c(this.frame.up,this.vLeft)),u(w,this.vLeft,w),p(w,w),g(w,w),f(y,this.frame.up,c(this.frame.up,this.vRight)),u(y,this.vRight,y),g(y,y),l(U,this.rotationFrameUp,this.vLeft);return Math.sign(c(U,this.vRight))*(Math.PI-t(c(w,y)))}get maxStretchDistance(){return Math.abs(this.vMinSiblingLength/Math.cos(.5*this.foldingAngle))}applyMiterStretch(t,r){const s=this.rotationAngle;if(Math.abs(s)<=0)return r;const a=i(Math.cos(.5*s));return e(t,(a-1+1)*r[0],r[1])}}class L extends R{get rotationFrameUp(){const t=Math.sign(c(this.frame.right,this.vRight));return l(d,this.vRight,this.vLeft),f(d,d,t),g(d,d)}get rotationRight(){const t=this.rotationFrameUp,i=c(t,this.frame.up),r=c(t,this.frame.right);return f(S,this.frame.up,-r),f(P,this.frame.right,i),m(S,S,P),g(S,S),j(F,this.frame,S),F}get rotationAngle(){const i=Math.sign(c(this.frame.right,this.vRight));return p(U,this.vLeft),-i*(Math.PI-t(c(U,this.vRight)))}get maxStretchDistance(){return Math.abs(this.vMinSiblingLength*i(Math.cos(.5*this.foldingAngle)))}applyMiterStretch(t,s){const e=this.rotationAngle;if(0===Math.abs(e))return s;const h=i(Math.cos(.5*e)),o=this.rotationRight,n=r(E,1+(h-1)*o[0]*o[0],(h-1)*o[0]*o[1],(h-1)*o[0]*o[1],1+(h-1)*o[1]*o[1]);return a(t,s,n)}}function j(t,i,r){e(t,c(r,i.right),c(r,i.up))}function A(t){switch(t){case b.World:return new x;case b.Path:return new L}}const d=v(),F=o(),S=v(),P=v(),U=v(),w=v(),y=v(),I=v(),k=v(),D=v(),E=s();export{R as PathVertex,A as newPathVertex};
|
|
@@ -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 t from"../../../../core/Accessor.js";import{equals as i}from"../../../../core/arrayUtils.js";import{smoothstep as r}from"../../../../core/mathUtils.js";import{disposeMaybe as s,releaseMaybe as o}from"../../../../core/maybe.js";import{watch as a,syncAndInitial as n,sync as h}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import{subclass as _}from"../../../../core/accessorSupport/decorators/subclass.js";import{
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{equals as i}from"../../../../core/arrayUtils.js";import{smoothstep as r}from"../../../../core/mathUtils.js";import{disposeMaybe as s,releaseMaybe as o}from"../../../../core/maybe.js";import{watch as a,syncAndInitial as n,sync as h}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import{subclass as _}from"../../../../core/accessorSupport/decorators/subclass.js";import{G as u,c as l}from"../../../../chunks/vec32.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ReadShadowMapPassParameters as d}from"../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{BindParameters as p}from"./BindParameters.js";import{zero as g}from"./depthRange.js";import{createQuadVAO as f}from"./glUtil3D.js";import{ShadowCastRenderer as b,shadowCastDisabledElevationThreshold as v,shadowCastDisableElevationMax as w,shadowCastDisableElevationMin as A}from"./ShadowCastRenderer.js";import{ShadowMap as R}from"./ShadowMap.js";import{S as y}from"../../../../chunks/ShadowCastAccumulate.glsl.js";import{ShadowCastAccumulateTechnique as C}from"../shaders/ShadowCastAccumulateTechnique.js";import{TaskPriority as D}from"../../../support/Scheduler.js";import{PixelFormat as F,PixelType as S,SizedPixelFormat as j,TextureWrapMode as x,ClearBufferBit as P}from"../../../webgl/enums.js";import{FramebufferObject as T}from"../../../webgl/FramebufferObject.js";import{TextureDescriptor as q}from"../../../webgl/TextureDescriptor.js";import{vertexCount as E}from"../../../webgl/Util.js";let M=class extends t{constructor(e,t,i,r,s,o){super({}),this.fbos=e,this._stage=i,this._prepareForShadowMapPass=r,this._renderToShadowMap=s,this._requestRender=o,this._progress=0,this._sampleCount=0,this._passParameters=new d,this._cachedLightDirections=[],this._depthRange=g,this._previewing=!1,this._cameraForcedForScreenshot=!1,this._shadowAccumulatorKey="shadowAccumulator",this._rctx=e.rctx,this._bindParameters=new p(new R(e,i.viewingMode),null),this._bindParameters.shadowMap.enabled=!0,this._vao=f(this._rctx),this._accumulationRenderer=new b(t,this._rctx,this,o);const c=this._stage.view.resourceController.scheduler;this.addHandles([c.registerTask(D.SHADOW_ACCUMULATOR,this),a((()=>i.renderView),(e=>{this.removeHandles(L),null!=e&&this.addHandles(e.events.on("force-camera-for-screenshot",(()=>this._cameraForcedForScreenshot=!0)),L)}),n),a((()=>this._previewing),(()=>this._requestRenderIfEnabled()),h)],this._shadowAccumulatorKey)}normalizeCtorArgs(){return{}}dispose(){this._disable(),this.removeHandles(this._shadowAccumulatorKey),this._accumulationRenderer=s(this._accumulationRenderer),this._bindParameters.shadowMap.dispose(),this._fbo=s(this._fbo),this._vao=s(this._vao),this._accumulationTechniqueCached=o(this._accumulationTechniqueCached),this._cachedLightDirections.length=0,this._sampleCount=0}get computedSamples(){return this._progress}get shadowCastTexture(){return this._fbo?.colorTexture}get isAccumulating(){return this._isPreviewing||this._isRefining}get _accumulationTechnique(){if(null==this._accumulationTechniqueCached){const e={rctx:this._rctx,viewingMode:this._stage.viewingMode};this._accumulationTechniqueCached=new C(e)}return this._accumulationTechniqueCached}get _isRefining(){return this._isActive&&!this._isDoneAccumulating&&!this._previewing}get _isPreviewing(){return this._isActive&&this._previewing}get _isActive(){return null!=this._fbo&&this._sampleCount>0}get canAccumulate(){return null!==this._bindParameters.linearDepth?.getTexture()&&this._depthRange!==g&&this._opacityFromElevation>v}get _isDoneAccumulating(){return this._progress>=this._sampleCount}get _lightDirections(){return this._cachedLightDirections}set _lightDirections(e){const t=this._cachedLightDirections;if(i(t,e,u))return;const r=Math.min(y,e.length);t.length=r,this._sampleCount=r;for(let i=0;i<r;++i)t[i]=l(t[i]??m(),e[i]);this._invalidate()}get _opacityFromElevation(){return this._accumulationRenderer.opacityFromElevation}set _opacityFromElevation(e){this._accumulationRenderer.opacityFromElevation=e}get running(){return this._isRefining&&this.canAccumulate&&this._progress>0}runTask(e){for(this._prepareForShadowMapPass(this._bindParameters);!e.done&&!this._isDoneAccumulating;)this._accumulateShadow(),e.madeProgress();this._requestRender()}renderAccumulation(e,t,i,r){if(this._depthRange=t,this._updateCamera(i),this._bindParameters.contentCamera=r,this._bindParameters.linearDepth=e,this._passParameters.origin=this._bindParameters.camera.center,this.notifyChange("canAccumulate"),!this.isAccumulating||!this.canAccumulate)return;(this._previewing||0===this._progress||this._cameraForcedForScreenshot)&&this._clear();const s=this._cameraForcedForScreenshot?this._sampleCount:Math.min(U,this._sampleCount-this._progress);for(let o=0;o<s;++o)this._accumulateShadow();this._cameraForcedForScreenshot=!1,this._requestRender()}render(e){this._accumulationRenderer.render(e)}setOptions(e){if(void 0!==e.enabled){const t=null!=this._fbo;e.enabled!==t&&(e.enabled?this._enable():this._disable())}void 0!==e.previewing&&(this._previewing=e.previewing),void 0!==e.lightDirections&&(this._lightDirections=e.lightDirections),this._accumulationRenderer.setOptions(e)}readAccumulatedShadow(e,t){return!this._isActive||!this._fbo||this._progress<1||e<0||e>=this._fbo.width||t<0||t>=this._fbo.height?0:(this._fbo.readPixels(e,t,1,1,F.RED,S.UNSIGNED_BYTE,O),O[0]/this._progress)}_enable(){this._progress=0;const e=new q;e.pixelFormat=F.RED,e.internalFormat=j.R8,e.wrapMode=x.CLAMP_TO_EDGE,this._fbo=new T(this._rctx,e),this._requestRender()}_disable(){this._fbo=s(this._fbo),this._requestRender()}_invalidate(){this._progress=0,this._requestRenderIfEnabled()}_clear(){this._rctx.bindFramebuffer(this._fbo),this._rctx.setClearColor(0,0,0,0),this._rctx.clearSafe(P.COLOR_BUFFER_BIT),this._progress=0}_accumulateShadow(){this._renderToShadowMap(this._bindParameters,this._lightDirections[this._progress++],this._depthRange);const e=this._accumulationTechnique;this._rctx.bindFramebuffer(this._fbo),this._rctx.bindTechnique(e,this._bindParameters,this._passParameters),this._rctx.bindVAO(this._vao),this._rctx.drawArrays(e.primitiveType,0,E(this._vao,"geometry"))}_updateCamera(e){const t=this._fbo;if(null==t)return;const i=this._bindParameters.camera;e.equals(i)||i.copyFrom(e),t.resize(e.fullWidth,e.fullHeight),this._opacityFromElevation=1-r(A,w,e.relativeElevation)}_requestRenderIfEnabled(){this._fbo&&this._requestRender()}get test(){const e=this;return{lightDirections:this._lightDirections,get isDone(){return e._isDoneAccumulating},get isActive(){return e._isActive}}}};e([c()],M.prototype,"_progress",void 0),e([c()],M.prototype,"_sampleCount",void 0),e([c()],M.prototype,"_fbo",void 0),e([c()],M.prototype,"_depthRange",void 0),e([c()],M.prototype,"_previewing",void 0),e([c()],M.prototype,"_accumulationRenderer",void 0),e([c()],M.prototype,"_isRefining",null),e([c()],M.prototype,"_isActive",null),e([c()],M.prototype,"canAccumulate",null),e([c()],M.prototype,"_isDoneAccumulating",null),e([c()],M.prototype,"_opacityFromElevation",null),e([c()],M.prototype,"running",null),M=e([_("esri.views.3d.webgl-engine.lib.ShadowAccumulator")],M);const U=6,L="renderView",O=new Uint8Array(1);export{M as ShadowAccumulator};
|
|
@@ -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 has from"../../../../core/has.js";import{clamp as t,lerp as s,acosClamped as e}from"../../../../core/mathUtils.js";import{releaseMaybe as i}from"../../../../core/maybe.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as r,multiply as h,invert as o,lookAt as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as c,create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as d,add as _,scale as u,lerp as m,squaredDistance as g,subtract as f,dot as p,negate as x,normalize as b,copy as w}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as M}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{
|
|
5
|
+
import has from"../../../../core/has.js";import{clamp as t,lerp as s,acosClamped as e}from"../../../../core/mathUtils.js";import{releaseMaybe as i}from"../../../../core/maybe.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as r,multiply as h,invert as o,lookAt as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as c,create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as d,add as _,scale as u,lerp as m,squaredDistance as g,subtract as f,dot as p,negate as x,normalize as b,copy as w}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as M}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{j as C,c as j,F as T,e as y,s as H}from"../../../../chunks/vec32.js";import{create as D}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as v,t as S}from"../../../../chunks/vec42.js";import{create as F}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ViewingMode as R}from"../../../ViewingMode.js";import{ColorFormat as E,DepthFormat as O}from"../../webgl/formats.js";import{CascadeCamera as U}from"./CascadeCamera.js";import{applyTextureResizeModulo as B,applyTextureResizeFloorModulo as L}from"./textureUtils.js";import{assert as N,logWithBase as Q,verify as V,rayRay2D as I}from"./Util.js";import{TextureType as A,ClearBufferBit as W}from"../../../webgl/enums.js";import{Texture as z}from"../../../webgl/Texture.js";var P;!function(t){t[t.Highlight=0]="Highlight",t[t.ExcludeHighlight=1]="ExcludeHighlight"}(P||(P={}));class q{constructor(){this.camera=new U,this.lightMat=l()}}class G{constructor(){this.maxNumCascadesHighQuality=4,this.maxNumCascadesLowQuality=4,this.textureSizeModHighQuality=1.3,this.textureSizeModLowQuality=.9,this.splitSchemeLambda=0}}class X{constructor(t,s){this._fbos=t,this._viewingMode=s,this._enabled=!1,this._snapshots=new Array,this._textureHeight=0,this._numCascades=1,this.settings=new G,this._projectionView=l(),this._projectionViewInverse=l(),this._modelViewLight=l(),this._cascadeDistances=[0,0,0,0,0],this._usedCascadeDistances=F(),this._cascades=[new q,new q,new q,new q],this._lastOrigin=null,this._maxTextureWidth=Math.min(has("esri-mobile")?4096:16384,t.rctx.parameters.maxTextureSize)}dispose(){this.enabled=!1,this.disposeOffscreenBuffers()}get depthTexture(){return this._handle?.getTexture()}get _textureWidth(){return this._textureHeight*this._numCascades}get numCascades(){return this._numCascades}get cascadeDistances(){return v(this._usedCascadeDistances,this._cascadeDistances[0],this._numCascades>1?this._cascadeDistances[1]:1/0,this._numCascades>2?this._cascadeDistances[2]:1/0,this._numCascades>3?this._cascadeDistances[3]:1/0)}disposeOffscreenBuffers(){this._handle=i(this._handle),this._discardSnapshots()}set maxCascades(s){this.settings.maxNumCascadesHighQuality=t(Math.floor(s),1,4)}get maxCascades(){return this.settings.maxNumCascadesHighQuality}set enabled(t){this._enabled=t,t||this.disposeOffscreenBuffers()}get enabled(){return this._enabled}get ready(){return this._enabled&&null!=this.depthTexture}get cascades(){for(let t=0;t<this._numCascades;++t)it[t]=this._cascades[t];return it.length=this._numCascades,it}start(t,s,e,i,a){N(this.enabled);const{near:r,far:h}=this._clampNearFar(e);this._computeCascadeDistances(r,h,i),this._textureHeight=this._computeTextureHeight(t,a,i),this._setupMatrices(t,s);const{viewMatrix:o,projectionMatrix:n}=t;for(let c=0;c<this._numCascades;++c)this._constructCascade(c,n,o,s);this._lastOrigin=null,this.clear()}finish(){N(this.enabled),this._handle?.detachDepth()}getShadowMapMatrices(t){if(!this._lastOrigin||!C(t,this._lastOrigin)){this._lastOrigin=this._lastOrigin||D(),j(this._lastOrigin,t);for(let s=0;s<this._numCascades;++s){r(at,this._cascades[s].lightMat,t);for(let t=0;t<16;++t)rt[16*s+t]=at[t]}}return rt}moveSnapshot(t){N(this.enabled),this._handle?.detachDepth(),this._snapshots[t]?.release(),this._snapshots[t]=this._handle,this._handle=null,this.clear()}copySnapshot(t){const s=this._handle?.getTexture()?.descriptor;if(!this.enabled||!s)return;this._snapshots[t]?.release();const{width:e,height:i}=s,a=t===P.Highlight?"shadow highlight snapshot":"shadow no highlight snapshot";this._snapshots[t]=this._fbos.acquire(e,i,a,E.RGBA4);const r=this._fbos.rctx;this._bindFbo();const h=r.bindTexture(this._snapshots[t]?.getTexture(),z.TEXTURE_UNIT_FOR_UPDATES);r.gl.copyTexSubImage2D(A.TEXTURE_2D,0,0,0,0,0,e,i),r.bindTexture(h,z.TEXTURE_UNIT_FOR_UPDATES)}getSnapshot(t){return this.enabled?this._snapshots[t]?.getTexture():null}clear(){const t=this._fbos.rctx;this._ensureFbo(),this._bindFbo(),t.setClearColor(1,1,1,1),t.clearSafe(W.COLOR_BUFFER_BIT|W.DEPTH_BUFFER_BIT)}_computeTextureHeight(t,s,e){const i=Math.min(window.devicePixelRatio,s)/t.pixelRatio,a=e?this.settings.textureSizeModHighQuality:this.settings.textureSizeModLowQuality,r=B(Math.floor(Math.max(t.fullWidth,t.fullHeight)*i*a)),h=Math.min(this._maxTextureWidth,this._numCascades*r);return L(h/this._numCascades)}_ensureFbo(){this._handle?.fbo.width===this._textureWidth&&this._handle?.fbo.height===this._textureHeight||(this._handle?.release(),this._handle=this._fbos.acquire(this._textureWidth,this._textureHeight,"shadow map",E.RGBA4)),this._handle?.acquireDepth(O.DEPTH16_BUFFER)}_discardSnapshot(t){this._snapshots[t]=i(this._snapshots[t])}_discardSnapshots(){for(let t=0;t<this._snapshots.length;++t)this._discardSnapshot(t);this._snapshots.length=0}_bindFbo(){const t=this._fbos.rctx;t.unbindTexture(this.depthTexture),t.bindFramebuffer(this._handle?.fbo)}_constructCascade(t,s,e,i){const a=this._cascades[t],o=-this._cascadeDistances[t],n=-this._cascadeDistances[t+1],c=(s[10]*o+s[14])/Math.abs(s[11]*o+s[15]),l=(s[10]*n+s[14])/Math.abs(s[11]*n+s[15]);N(c<l);for(let r=0;r<8;++r){v(J,r%4==0||r%4==3?-1:1,r%4==0||r%4==1?-1:1,r<4?c:l,1);const t=K[r];S(t,J,this._projectionViewInverse),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3]}T(et,K[0]),a.camera.viewMatrix=r(k,this._modelViewLight,et);for(let r=0;r<8;++r)y(K[r],K[r],a.camera.viewMatrix);let d=K[0][2],_=K[0][2];for(let r=1;r<8;++r)d=Math.min(d,K[r][2]),_=Math.max(_,K[r][2]);d-=200,_+=200,a.camera.near=-_,a.camera.far=-d,jt(e,i,d,_,a.camera),h(a.lightMat,a.camera.projectionMatrix,a.camera.viewMatrix);const u=this._textureHeight;a.camera.viewport=[t*u,0,u,u]}_setupMatrices(t,s){h(this._projectionView,t.projectionMatrix,t.viewMatrix),o(this._projectionViewInverse,this._projectionView);const e=this._viewingMode===R.Global?t.eye:H(et,0,0,1);n(this._modelViewLight,[0,0,0],[-s[0],-s[1],-s[2]],e)}_clampNearFar(t){let{near:s,far:e}=t;return s<2&&(s=2),e<2&&(e=2),s>=e&&(s=2,e=4),{near:s,far:e}}_computeCascadeDistances(t,e,i){const a=i?this.settings.maxNumCascadesHighQuality:this.settings.maxNumCascadesLowQuality;this._numCascades=Math.min(1+Math.floor(Q(e/t,4)),a);const r=(e-t)/this._numCascades,h=(e/t)**(1/this._numCascades);let o=t,n=t;for(let c=0;c<this._numCascades+1;++c)this._cascadeDistances[c]=s(o,n,this.settings.splitSchemeLambda),o*=h,n+=r}get test(){return{cascades:this._cascades,textureHeight:this._textureHeight}}}const k=l(),J=F(),K=[];for(let Tt=0;Tt<8;++Tt)K.push(F());const Y=M(),Z=M(),$=M(),tt=M(),st=M(),et=D(),it=[],at=l(),rt=c.concat(c,c,c,c),ht=M(),ot=M(),nt=[M(),M(),M(),M()],ct=M(),lt=M(),dt=M(),_t=M(),ut=M(),mt=M(),gt=M();function ft(t,s,e,i,a,r,h,o){d(ht,0,0);for(let d=0;d<4;++d)_(ht,ht,t[d]);u(ht,ht,.25),d(ot,0,0);for(let d=4;d<8;++d)_(ot,ot,t[d]);u(ot,ot,.25),m(nt[0],t[4],t[5],.5),m(nt[1],t[5],t[6],.5),m(nt[2],t[6],t[7],.5),m(nt[3],t[7],t[4],.5);let n=0,c=g(nt[0],ht);for(let d=1;d<4;++d){const t=g(nt[d],ht);t<c&&(c=t,n=d)}f(ct,nt[n],t[n+4]);const l=ct[0];let M,C;ct[0]=-ct[1],ct[1]=l,f(lt,ot,ht),p(lt,ct)<0&&x(ct,ct),m(ct,ct,lt,e),b(ct,ct),M=C=p(f(dt,t[0],ht),ct);for(let d=1;d<8;++d){const s=p(f(dt,t[d],ht),ct);s<M?M=s:s>C&&(C=s)}w(i,ht),u(dt,ct,M-s),_(i,i,dt);let j=-1,T=1,y=0,H=0;for(let d=0;d<8;++d){f(_t,t[d],i),b(_t,_t);const s=ct[0]*_t[1]-ct[1]*_t[0];s>0?s>j&&(j=s,y=d):s<T&&(T=s,H=d)}V(j>0,"leftArea"),V(T<0,"rightArea"),u(ut,ct,M),_(ut,ut,ht),u(mt,ct,C),_(mt,mt,ht),gt[0]=-ct[1],gt[1]=ct[0];const D=I(i,t[H],mt,_(dt,mt,gt),1,a),v=I(i,t[y],mt,dt,1,r),S=I(i,t[y],ut,_(dt,ut,gt),1,h),F=I(i,t[H],ut,dt,1,o);V(D,"rayRay"),V(v,"rayRay"),V(S,"rayRay"),V(F,"rayRay")}function pt(t,s){return 3*s+t}const xt=M();function bt(t,s){return d(xt,t[s],t[s+3]),xt}const wt=M(),Mt=a();function Ct(t,s,e,i,a){f(wt,e,i),u(wt,wt,.5),Mt[0]=wt[0],Mt[1]=wt[1],Mt[2]=0,Mt[3]=wt[1],Mt[4]=-wt[0],Mt[5]=0,Mt[6]=wt[0]*wt[0]+wt[1]*wt[1],Mt[7]=wt[0]*wt[1]-wt[1]*wt[0],Mt[8]=1,Mt[pt(0,2)]=-p(bt(Mt,0),t),Mt[pt(1,2)]=-p(bt(Mt,1),t);let r=p(bt(Mt,0),e)+Mt[pt(0,2)],h=p(bt(Mt,1),e)+Mt[pt(1,2)],o=p(bt(Mt,0),i)+Mt[pt(0,2)],n=p(bt(Mt,1),i)+Mt[pt(1,2)];r=-(r+o)/(h+n),Mt[pt(0,0)]+=Mt[pt(1,0)]*r,Mt[pt(0,1)]+=Mt[pt(1,1)]*r,Mt[pt(0,2)]+=Mt[pt(1,2)]*r,r=1/(p(bt(Mt,0),e)+Mt[pt(0,2)]),h=1/(p(bt(Mt,1),e)+Mt[pt(1,2)]),Mt[pt(0,0)]*=r,Mt[pt(0,1)]*=r,Mt[pt(0,2)]*=r,Mt[pt(1,0)]*=h,Mt[pt(1,1)]*=h,Mt[pt(1,2)]*=h,Mt[pt(2,0)]=Mt[pt(1,0)],Mt[pt(2,1)]=Mt[pt(1,1)],Mt[pt(2,2)]=Mt[pt(1,2)],Mt[pt(1,2)]+=1,r=p(bt(Mt,1),s)+Mt[pt(1,2)],h=p(bt(Mt,2),s)+Mt[pt(2,2)],o=p(bt(Mt,1),e)+Mt[pt(1,2)],n=p(bt(Mt,2),e)+Mt[pt(2,2)],r=-.5*(r/h+o/n),Mt[pt(1,0)]+=Mt[pt(2,0)]*r,Mt[pt(1,1)]+=Mt[pt(2,1)]*r,Mt[pt(1,2)]+=Mt[pt(2,2)]*r,r=p(bt(Mt,1),s)+Mt[pt(1,2)],h=p(bt(Mt,2),s)+Mt[pt(2,2)],o=-h/r,Mt[pt(1,0)]*=o,Mt[pt(1,1)]*=o,Mt[pt(1,2)]*=o,a[0]=Mt[0],a[1]=Mt[1],a[2]=0,a[3]=Mt[2],a[4]=Mt[3],a[5]=Mt[4],a[6]=0,a[7]=Mt[5],a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=Mt[6],a[13]=Mt[7],a[14]=0,a[15]=Mt[8]}function jt(t,s,i,a,r){const h=1/K[0][3],o=1/K[4][3];N(h<o);let n=h+Math.sqrt(h*o);const c=Math.sin(e(t[2]*s[0]+t[6]*s[1]+t[10]*s[2]));n/=c,ft(K,n,c,Y,Z,$,tt,st),Ct(Y,Z,tt,st,r.projectionMatrix),r.projectionMatrix[10]=2/(i-a),r.projectionMatrix[14]=-(i+a)/(i-a)}export{X as ShadowMap,P as SnapshotSlot};
|
|
@@ -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 t from"../../../../../core/Accessor.js";import{equals as r,binaryIndexOf as s}from"../../../../../core/arrayUtils.js";import n from"../../../../../core/Logger.js";import{clamp as o}from"../../../../../core/mathUtils.js";import{disposeMaybe as i,destroyMaybe as a}from"../../../../../core/maybe.js";import{property as c}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as d,transpose as u,invert as h}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as g}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as p,c as f,y as _,j as b}from"../../../../../chunks/vec32.js";import{create as y,clone as j}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as O}from"../../../../../core/support/UpdatingHandles.js";import{g as w,a as E}from"../../../../../chunks/sphere.js";import{c as R}from"../../../../../chunks/vec33.js";import{ViewingMode as v}from"../../../../ViewingMode.js";import{encodeElevationOffset as x}from"../../collections/Component/Material/shader/ComponentData.glsl.js";import{TwoVectorPosition as M}from"../../core/util/TwoVectorPosition.js";import{Attribute as T}from"../Attribute.js";import{GridLocalOriginFactory as C}from"../GridLocalOriginFactory.js";import{applyToModelMatrix as D}from"../localOriginHelper.js";import{LocalOriginManager as P}from"../LocalOriginManager.js";import{Object3D as S}from"../Object3D.js";import{VertexArrayObject as A}from"../VertexArrayObject.js";import{VertexAttribute as B}from"../VertexAttribute.js";import{VertexLayout as L,EdgeInputBufferLayout as U,EdgeShaderAttributeLocations as I,glVertexLayout as k}from"./bufferLayouts.js";import{RegularEdgeBufferWriter as H,SilhouetteEdgeBufferWriter as V}from"./edgeBufferWriters.js";import{EdgeType as N}from"./edgePreprocessing.js";import{EdgeRenderer as G,lineWidthFractionFactor as W,extensionLengthOffset as q}from"./EdgeRenderer.js";import{EdgePassParameters as z}from"./EdgeShaderParameters.js";import{EdgeWorkerHandle as K}from"./EdgeWorkerHandle.js";import{Transparency as F}from"./interfaces.js";import{generateStrokesTexture as Q}from"./strokes.js";import{determineRendererType as J,determineEdgeTransparency as X,determineObjectTransparency as Y,fillComponenBufferIndices as Z}from"./util.js";import{BufferManager as $}from"../TextureBackedBuffer/BufferManager.js";import{EdgeSilhouette as ee}from"../../shaders/sources/edgeRenderer/EdgeUtil.glsl.js";import{BufferObject as te}from"../../../../webgl/BufferObject.js";import{Usage as re}from"../../../../webgl/enums.js";let se=class extends t{constructor(e){super(e),this._updatingHandles=new O,this._perObjectData=new Map,this._perObjectDataEvictionCache=new Set,this._renderers=new Map,this._gpuMemoryUsage=0,this._workerAbort=new AbortController,this._tmpModelPosition=y(),this._localOrigins=new P(new C(e.renderSR))}initialize(){this._worker=new K(this.schedule),this._componentColorManager=new $(this.rctx,3);const e=L.createBuffer(4);for(let t=0;t<4;t++)e.sideness.set(t,0,0===t||3===t?0:1),e.sideness.set(t,1,0===t||1===t?0:1);this._verticesBufferObject=te.createVertex(this.rctx,re.STATIC_DRAW,e.buffer)}destroy(){this.destroyed||(this._perObjectData.forEach((e=>this._discardObjectEntry(e))),this._perObjectData.clear(),this._strokesTexture=i(this._strokesTexture),this._componentColorManager=a(this._componentColorManager),this._workerAbort.abort(),this._worker.destroy(),this._verticesBufferObject=i(this._verticesBufferObject),this._renderers.clear(),this._updatingHandles.destroy(),this._set("schedule",be))}get updating(){return this._updatingHandles.updating}get usedMemory(){return this._gpuMemoryUsage}shouldRender(){return this._renderers.size>0}async addComponentObject(e,t,r,s,n,o){if(this.hasObject(e))return this.getObjectMemoryUsage(e);let i;const a=new ie(new Promise((e=>i=e)),e.obb.center,e.obb.radius);this._perObjectData.set(e,a);const c=await this._updatingHandles.addPromise(this._addComponentGeometry(e.transform,a,t,r,s,n,o));return this.setNeedsRender(),i(),c}async addOrUpdateObject3D(e,t,r,s){if(this.destroyed)return void n.getLogger(this).warn("Attempt to add an object to a destroyed instance");const o=this._perObjectData.get(e);let i;o?.renderables.length>0&&this._perObjectDataEvictionCache.add(o);const a=e.boundingVolumeWorldSpace.bounds,c=new ie(new Promise((e=>i=e)),w(a),E(a));this._perObjectData.set(e,c);const l=new Array;if(r.mergeGeometries&&e.geometries.length>1&&oe(e))l.push(this._addObjectMergedGeometries(e,c,t,r,s));else for(let n=0;n<e.geometries.length;n++){const o=e.geometries[n];o.material.supportsEdges&&l.push(this._addGeometry(e,c,o,t[0],r,s))}await this._updatingHandles.addPromise(Promise.all(l)),this._perObjectDataEvictionCache.delete(c),this._discardObjectEntry(o),this.setNeedsRender(),i()}fastUpdateObject3DEdgesTransform(e){if(this.destroyed)return!1;const t=this._perObjectData.get(e);if(!t)return!1;const{geometries:r}=e,{renderables:s}=t;if(0===r.length||0===s.length)return!0;if(s.length>1)return!1;const[n]=s,o=n.transform;if(!(o instanceof le))return!1;const[i]=r;if(i.localOrigin!==o.origin.origin)return!1;const a=g(),c=this._computeModelTransformWithLocalOrigin(e,i,a);return n.transform=new le(a,c),this.setNeedsRender(),!0}_discardObjectEntry(e){e&&(e.renderables.length&&(e.renderables.forEach((e=>this._removeRenderable(e))),this.setNeedsRender()),e.loaded=null)}hasObject(e){return this._perObjectData.has(e)}async updateAllComponentOpacities(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));if(null==r)return;const s=t instanceof Array?e=>t[e]:()=>t;r.renderables.forEach((e=>{const t=e.components.meta.length;for(let r=0;r<t;r++){const t=s(r),n=e.components.meta[r],o=n.index;n.material.opacity=t,e.components.buffer.textureBuffer.setDataElement(o,1,3,255*t)}this._updateTransparency(e)})),this.setNeedsRender()}async getObjectMemoryUsage(e){const t=await this._getObjectEntry(e);return null!=t?t.renderables.reduce(((e,t)=>e+t.statistics.gpuMemoryUsage),0):0}async updateAllComponentMaterials(e,t,r,s){const n=e instanceof S,o=!!r.hasSlicePlane,i=J(t),a=G.getKey(i,o,n),c=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=c&&(c.renderables.forEach((e=>{if(a!==e.rendererKey){const t=this._renderers.get(e.rendererKey),r=this._acquireRenderer(i,o,n);t.removeRenderable(e),--t.refCount,e.rendererKey=a,r.addRenderable(e)}for(let r=0;r<t.length;r++)e.components.meta[r].material=t[r];s&&this._updateComponentBuffer(e.components),this._updateTransparency(e)})),this.setNeedsRender())}async updateAllVerticalOffsets(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&(r.renderables.forEach((e=>{const r=e.components.meta;for(let s=0;s<r.length;s++)e.components.meta[s].verticalOffset=t?.[s]??0;this._updateComponentBuffer(e.components)})),this.setNeedsRender())}async updateObjectVisibility(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&(r.renderables.forEach((e=>e.visible=t)),this.setNeedsRender())}removeObject(e){const t=this._perObjectData.get(e);t&&(this._perObjectData.delete(e),this._discardObjectEntry(t))}async _getObjectEntry(e){const t=this._perObjectData.get(e);if(!t)throw new Error("no object");return await t.loaded,null==t.loaded?null:t}render(e,t){if(null==this._componentColorManager)return;this._localOrigins.updateViewMatrices(e.camera.viewMatrix);const r=e.camera.viewInverseTransposeMatrix,s=y(),n=new M;let o=0,i=0;if(this._renderers.forEach((r=>{if(0===r.refCount)return this._renderers.delete(r.key),void r.dispose();let s=!0,n=!0;r.forEachRenderable((t=>{t.visible&&(o+=t.statistics.averageEdgeLength,i++,s&&t.regular&&(r.updateTechnique(e,!1),s=!1),n&&t.silhouette&&(r.updateTechnique(e,!0),n=!1))}),t)})),this._componentColorManager.garbageCollect(),this._componentColorManager.updateTextures(),0===i)return;const a=new z(40*o/i,t);p(s,r[3],r[7],r[11]),n.set(s),f(a.transformWorldFromViewTH,n.high),f(a.transformWorldFromViewTL,n.low),d(a.transformViewFromCameraRelativeRS,e.camera.viewMatrix),u(_e,a.transformViewFromCameraRelativeRS),h(a.transformNormalViewFromGlobal,_e),a.transformProjFromView=e.camera.projectionMatrix,this._updateObjectCameraDistances(e),this._renderers.forEach((t=>{this._renderRegularEdges(t,e,a),this._renderSilhouetteEdges(t,e,a)}))}_updateTransparency(e){const t=X(e.components.meta),r=Y(e.components.meta);t===e.edgeTransparency&&r===e.objectTransparency||(e.edgeTransparency=t,e.objectTransparency=r,this._renderers.get(e.rendererKey).setRenderablesDirty())}_computeModelTransformWithLocalOrigin(e,t,r){e.getCombinedShaderTransformation(t,r);const s=null!=t.localOrigin?this._localOrigins.register(t.localOrigin):this._localOrigins.acquire(p(this._tmpModelPosition,r[12],r[13],r[14]));return t.localOrigin=s.origin,D(s.origin.vec3,r),s}_updateComponentBuffer(e){const{meta:t,buffer:r}=e,s=new Uint8Array(4);for(let n=0;n<t.length;n++){const e=t[n].material,i=t[n].index,a=o(Math.round(e.size*W),0,255),c=o(e.extensionLength,-q,255-q)+q,l="solid"===e.type?N.SOLID:N.SKETCH,d=255*e.opacity,u=e.color,h=255*u[0],m=255*u[1],g=255*u[2],p=255*u[3];r.textureBuffer.setData(i,0,h,m,g,p),r.textureBuffer.setData(i,1,a,c,l,d),x(t[n].verticalOffset,s),r.textureBuffer.setData(i,2,s[0],s[1],s[2],s[3])}}_createComponentBuffers(e){if(null==this._componentColorManager)return null;const t=new Array,r=this._componentColorManager.getBuffer(e.length);for(let n=0;n<e.length;n++){const s=e[n],o=r.acquireIndex();t.push({index:o,verticalOffset:0,material:s})}const s=new ae(r,t);return this._updateComponentBuffer(s),s}_extractEdges(e,t,r,s,n,o=n.length){return this._worker.process({data:t,indices:n,indicesLength:o,writerSettings:e,skipDeduplicate:r},this._workerAbort.signal,s)}_createRenderable(e,t,r,s,n){const o=t=>null!=this._verticesBufferObject?new ce(new A(this.rctx,I,{vertices:k,instances:t===ee.REGULAR?H.glLayout:V.glLayout},{vertices:this._verticesBufferObject,instances:te.createVertex(this.rctx,re.STATIC_DRAW,t===ee.REGULAR?e.regular.instancesData.buffer:e.silhouette.instancesData.buffer)}),t===ee.REGULAR?e.regular.lodInfo:e.silhouette.lodInfo):null,i=e.regular.lodInfo.lengths.length>0?o(ee.REGULAR):null,a=e.silhouette.lodInfo.lengths.length>0?o(ee.SILHOUETTE):null,c=(i?.vao.usedMemory??0)+(a?.vao.usedMemory??0);return new de(i,a,{gpuMemoryUsage:c,externalMemoryUsage:n,averageEdgeLength:e.averageEdgeLength},r,X(t.meta),Y(t.meta),t,s)}async _addGeometry(e,t,r,s,n,o){if(r.edgeIndicesLength<=0)return;const i=r.attributes.get(B.POSITION),a=g(),c=this._computeModelTransformWithLocalOrigin(e,r,a),l=new fe(i,a,c);return this._addPositionData(t,l,r.edgeIndicesLength,s,n,o)}async _addPositionData(e,t,r,s,n,o=!1){if(null==e.loaded)return;const i=this._createComponentBuffers([s]);if(null==i)return;const a=this._acquireRenderer(s.type,!!n.hasSlicePlane,!0),{modelTransform:c,origin:l}=t,d=t.position.indices,u=t.position,h=u.data.length/u.size,m=U.createBuffer(h);for(let f=0;f<h;f++)m.position.set(f,0,u.data[f*u.size]),m.position.set(f,1,u.data[f*u.size+1]),m.position.set(f,2,u.data[f*u.size+2]);Z(i.meta,[0,m.componentIndex.count],m.componentIndex);const g=await this._updatingHandles.addPromise(this._extractEdges(a.writerSettings,m,!1,o,d,r));if(null==e.loaded)return;const p=this._createRenderable(g,i,new le(c,l),a.key,!1);e.renderables.push(p),a.addRenderable(p),this._gpuMemoryUsage+=p.statistics.gpuMemoryUsage}async _addComponentGeometry(e,t,r,s,n,o,i){if(null==t.loaded)return 0;const a=this._createComponentBuffers(o);if(null==a)return 0;const c=J(o),l=this._acquireRenderer(c,i.hasSlicePlane||!1,!1),d=U.createBuffer(r.length/3);R(d.position.typedBuffer,r,d.position.typedBufferStride,3),Z(a.meta,n,d.componentIndex,s);const u=!0,h=l.writerSettings,m=await this._updatingHandles.addPromise(this._extractEdges(h,d,u,!1,s));if(null==t.loaded)return 0;const g=this._createRenderable(m,a,e,l.key,!0);return t.renderables.push(g),l.addRenderable(g),g.statistics.gpuMemoryUsage}async _addObjectMergedGeometries(e,t,r,s,n){const o=new Map;let i=0,a=null,c=0;const l=e.geometries.filter((e=>{if(e.edgeIndicesLength<=0||!e.material.supportsEdges)return!1;!a&&e.localOrigin&&(a=e);const t=e.attributes.get(B.POSITION);return c+=t.data.length/t.size,i+=e.edgeIndicesLength,!0}));if(0===l.length)return;const d=c>=65536?Uint32Array:Uint16Array,u=i?new d(i):null,h=[];let m=0;l.forEach((e=>{const t=e.attributes.get(B.POSITION),r=t.indices;let s=o.get(t.data);if(null==s){s=h.length/3;for(let e=0;e<t.data.length;e+=t.size)h.push(t.data[e]),h.push(t.data[e+1]),h.push(t.data[e+2]);o.set(t.data,s)}for(let n=0;n<e.edgeIndicesLength;n++)u[m++]=s+r[n]}));const p=a||e.geometries[0],f=g(),_=this._computeModelTransformWithLocalOrigin(e,p,f);for(let g=0;g<e.geometries.length;g++)e.geometries[g].localOrigin=_.origin;const b=new fe(new T(h,u,3),f,_);await this._updatingHandles.addPromise(this._addPositionData(t,b,u.length,r[0],s,n))}_acquireRenderer(e,t,r){const s=G.getKey(e,t,r);let n=this._renderers.get(s);return null==this._strokesTexture&&(this._strokesTexture=Q(this.rctx)),n||(n=new G(this.rctx,this.techniqueRepository,{type:e,hasSlicePlane:t,strokesTexture:this._strokesTexture,legacy:r,spherical:this.viewingMode===v.Global}),this._renderers.set(s,n)),++n.refCount,n}_removeRenderable(e){ne(e.regular),ne(e.silhouette);const t=this._renderers.get(e.rendererKey);if(t){t.removeRenderable(e),--t.refCount,"origin"in e.transform&&this._localOrigins.release(e.transform.origin),this._gpuMemoryUsage-=e.statistics.externalMemoryUsage?0:e.statistics.gpuMemoryUsage;for(const t of e.components.meta)e.components.buffer.releaseIndex(t.index)}}_updateObjectCameraDistances(e){const t=e.camera.eye,r=e.camera.viewForward,s=y(),n=e=>{_(s,e.center,t);const n=b(s,r),o=e.radius,i=n<-o?1/0:n<o?0:n-o;e.renderables.forEach((e=>e.distanceToCamera=i))};this._perObjectData.forEach(n),this._perObjectDataEvictionCache.forEach(n)}_renderRegularEdges(e,t,r){const s=e.bindRegularEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!he(n)||!n.visible)return;const i=pe(n.regular.lod.lengths,n.distanceToCamera,o);e.renderRegularEdges(s,n,r,t,i)}),n)}_renderSilhouetteEdges(e,t,r){const s=e.bindSilhouetteEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!ge(n)||!n.visible)return;const i=pe(n.silhouette.lod.lengths,n.distanceToCamera,o);e.renderSilhouetteEdges(s,n,r,t,i)}),n)}get test(){return{hasRenderedPrimitives:e=>{let t=!1;const r=e.perScreenPixelRatio,s=(e,s)=>e.forEachRenderable((e=>{e.visible&&!t&&(he(e)&&(t=pe(e.regular.lod.lengths,e.distanceToCamera,r)>0),!t&&ge(e)&&(t=pe(e.silhouette.lod.lengths,e.distanceToCamera,r)>0))}),s);return this._renderers.forEach((e=>{t||(s(e,F.OPAQUE),s(e,F.TRANSPARENT))})),t},getObjectData:e=>this._perObjectData.get(e)}}};function ne(e){null!=e&&(e.vao.vertexBuffers.instances.dispose(),e.vao.disposeVAOOnly(),e.vao=null)}function oe(e){let t=null,s=null;for(let n=0;n<e.geometries.length;n++){const o=e.geometries[n];if(o.material.supportsEdges){if(t){if(!r(t,o.transformation))return!1}else t=o.transformation;if(s||null==o.localOrigin){if(null!=s?.localOrigin&&null!=o.localOrigin&&s.localOrigin.id!==o.localOrigin.id)return!1}else s=o}}return!0}e([c({constructOnly:!0})],se.prototype,"rctx",void 0),e([c({constructOnly:!0})],se.prototype,"renderSR",void 0),e([c({constructOnly:!0})],se.prototype,"viewingMode",void 0),e([c({constructOnly:!0})],se.prototype,"techniqueRepository",void 0),e([c({constructOnly:!0})],se.prototype,"setNeedsRender",void 0),e([c({constructOnly:!0})],se.prototype,"schedule",void 0),e([c({readOnly:!0})],se.prototype,"_updatingHandles",void 0),e([c({readOnly:!0})],se.prototype,"updating",null),se=e([l("esri.views.3d.webgl-engine.lib.edgeRendering.EdgeView")],se);class ie{constructor(e,t,r){this.radius=r,this.renderables=new Array,this.loaded=e,this.loaded.then((()=>{null!=this.loaded&&(this.loaded=!0)})),this.center=j(t)}}class ae{constructor(e,t){this.buffer=e,this.meta=t}}class ce{constructor(e,t){this.vao=e,this.lod=t}}class le{constructor(e,t){this.modelMatrix=e,this.origin=t}}class de{constructor(e,t,r,s,n,o,i,a){this.regular=e,this.silhouette=t,this.statistics=r,this.transform=s,this.edgeTransparency=n,this.objectTransparency=o,this.components=i,this.rendererKey=a,this.distanceToCamera=0,this.visible=!0}}class ue extends de{}function he(e){return null!=e.regular}class me extends de{}function ge(e){return null!=e.silhouette}function pe(e,t,r){const n=t*r,o=s(e,n,!0);return-1===o?n<e[0]?e.length:0:e.length-o}class fe{constructor(e,t,r){this.position=e,this.modelTransform=t,this.origin=r}}const _e=m(),be=()=>Promise.reject();export{se as EdgeView,le as LegacyTransform,ue as RegularRenderable,de as Renderable,me as SilhouetteRenderable};
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{equals as r,binaryIndexOf as s}from"../../../../../core/arrayUtils.js";import n from"../../../../../core/Logger.js";import{clamp as o}from"../../../../../core/mathUtils.js";import{disposeMaybe as i,destroyMaybe as a}from"../../../../../core/maybe.js";import{property as c}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as d,transpose as u,invert as h}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as g}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as p,c as f,z as _,k as b}from"../../../../../chunks/vec32.js";import{create as y,clone as j}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as O}from"../../../../../core/support/UpdatingHandles.js";import{g as w,a as E}from"../../../../../chunks/sphere.js";import{c as R}from"../../../../../chunks/vec33.js";import{ViewingMode as v}from"../../../../ViewingMode.js";import{encodeElevationOffset as x}from"../../collections/Component/Material/shader/ComponentData.glsl.js";import{TwoVectorPosition as M}from"../../core/util/TwoVectorPosition.js";import{Attribute as T}from"../Attribute.js";import{GridLocalOriginFactory as C}from"../GridLocalOriginFactory.js";import{applyToModelMatrix as D}from"../localOriginHelper.js";import{LocalOriginManager as P}from"../LocalOriginManager.js";import{Object3D as S}from"../Object3D.js";import{VertexArrayObject as A}from"../VertexArrayObject.js";import{VertexAttribute as B}from"../VertexAttribute.js";import{VertexLayout as L,EdgeInputBufferLayout as U,EdgeShaderAttributeLocations as I,glVertexLayout as k}from"./bufferLayouts.js";import{RegularEdgeBufferWriter as H,SilhouetteEdgeBufferWriter as V}from"./edgeBufferWriters.js";import{EdgeType as N}from"./edgePreprocessing.js";import{EdgeRenderer as G,lineWidthFractionFactor as W,extensionLengthOffset as q}from"./EdgeRenderer.js";import{EdgePassParameters as z}from"./EdgeShaderParameters.js";import{EdgeWorkerHandle as K}from"./EdgeWorkerHandle.js";import{Transparency as F}from"./interfaces.js";import{generateStrokesTexture as Q}from"./strokes.js";import{determineRendererType as J,determineEdgeTransparency as X,determineObjectTransparency as Y,fillComponenBufferIndices as Z}from"./util.js";import{BufferManager as $}from"../TextureBackedBuffer/BufferManager.js";import{EdgeSilhouette as ee}from"../../shaders/sources/edgeRenderer/EdgeUtil.glsl.js";import{BufferObject as te}from"../../../../webgl/BufferObject.js";import{Usage as re}from"../../../../webgl/enums.js";let se=class extends t{constructor(e){super(e),this._updatingHandles=new O,this._perObjectData=new Map,this._perObjectDataEvictionCache=new Set,this._renderers=new Map,this._gpuMemoryUsage=0,this._workerAbort=new AbortController,this._tmpModelPosition=y(),this._localOrigins=new P(new C(e.renderSR))}initialize(){this._worker=new K(this.schedule),this._componentColorManager=new $(this.rctx,3);const e=L.createBuffer(4);for(let t=0;t<4;t++)e.sideness.set(t,0,0===t||3===t?0:1),e.sideness.set(t,1,0===t||1===t?0:1);this._verticesBufferObject=te.createVertex(this.rctx,re.STATIC_DRAW,e.buffer)}destroy(){this.destroyed||(this._perObjectData.forEach((e=>this._discardObjectEntry(e))),this._perObjectData.clear(),this._strokesTexture=i(this._strokesTexture),this._componentColorManager=a(this._componentColorManager),this._workerAbort.abort(),this._worker.destroy(),this._verticesBufferObject=i(this._verticesBufferObject),this._renderers.clear(),this._updatingHandles.destroy(),this._set("schedule",be))}get updating(){return this._updatingHandles.updating}get usedMemory(){return this._gpuMemoryUsage}shouldRender(){return this._renderers.size>0}async addComponentObject(e,t,r,s,n,o){if(this.hasObject(e))return this.getObjectMemoryUsage(e);let i;const a=new ie(new Promise((e=>i=e)),e.obb.center,e.obb.radius);this._perObjectData.set(e,a);const c=await this._updatingHandles.addPromise(this._addComponentGeometry(e.transform,a,t,r,s,n,o));return this.setNeedsRender(),i(),c}async addOrUpdateObject3D(e,t,r,s){if(this.destroyed)return void n.getLogger(this).warn("Attempt to add an object to a destroyed instance");const o=this._perObjectData.get(e);let i;o?.renderables.length>0&&this._perObjectDataEvictionCache.add(o);const a=e.boundingVolumeWorldSpace.bounds,c=new ie(new Promise((e=>i=e)),w(a),E(a));this._perObjectData.set(e,c);const l=new Array;if(r.mergeGeometries&&e.geometries.length>1&&oe(e))l.push(this._addObjectMergedGeometries(e,c,t,r,s));else for(let n=0;n<e.geometries.length;n++){const o=e.geometries[n];o.material.supportsEdges&&l.push(this._addGeometry(e,c,o,t[0],r,s))}await this._updatingHandles.addPromise(Promise.all(l)),this._perObjectDataEvictionCache.delete(c),this._discardObjectEntry(o),this.setNeedsRender(),i()}fastUpdateObject3DEdgesTransform(e){if(this.destroyed)return!1;const t=this._perObjectData.get(e);if(!t)return!1;const{geometries:r}=e,{renderables:s}=t;if(0===r.length||0===s.length)return!0;if(s.length>1)return!1;const[n]=s,o=n.transform;if(!(o instanceof le))return!1;const[i]=r;if(i.localOrigin!==o.origin.origin)return!1;const a=g(),c=this._computeModelTransformWithLocalOrigin(e,i,a);return n.transform=new le(a,c),this.setNeedsRender(),!0}_discardObjectEntry(e){e&&(e.renderables.length&&(e.renderables.forEach((e=>this._removeRenderable(e))),this.setNeedsRender()),e.loaded=null)}hasObject(e){return this._perObjectData.has(e)}async updateAllComponentOpacities(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));if(null==r)return;const s=t instanceof Array?e=>t[e]:()=>t;r.renderables.forEach((e=>{const t=e.components.meta.length;for(let r=0;r<t;r++){const t=s(r),n=e.components.meta[r],o=n.index;n.material.opacity=t,e.components.buffer.textureBuffer.setDataElement(o,1,3,255*t)}this._updateTransparency(e)})),this.setNeedsRender()}async getObjectMemoryUsage(e){const t=await this._getObjectEntry(e);return null!=t?t.renderables.reduce(((e,t)=>e+t.statistics.gpuMemoryUsage),0):0}async updateAllComponentMaterials(e,t,r,s){const n=e instanceof S,o=!!r.hasSlicePlane,i=J(t),a=G.getKey(i,o,n),c=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=c&&(c.renderables.forEach((e=>{if(a!==e.rendererKey){const t=this._renderers.get(e.rendererKey),r=this._acquireRenderer(i,o,n);t.removeRenderable(e),--t.refCount,e.rendererKey=a,r.addRenderable(e)}for(let r=0;r<t.length;r++)e.components.meta[r].material=t[r];s&&this._updateComponentBuffer(e.components),this._updateTransparency(e)})),this.setNeedsRender())}async updateAllVerticalOffsets(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&(r.renderables.forEach((e=>{const r=e.components.meta;for(let s=0;s<r.length;s++)e.components.meta[s].verticalOffset=t?.[s]??0;this._updateComponentBuffer(e.components)})),this.setNeedsRender())}async updateObjectVisibility(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&(r.renderables.forEach((e=>e.visible=t)),this.setNeedsRender())}removeObject(e){const t=this._perObjectData.get(e);t&&(this._perObjectData.delete(e),this._discardObjectEntry(t))}async _getObjectEntry(e){const t=this._perObjectData.get(e);if(!t)throw new Error("no object");return await t.loaded,null==t.loaded?null:t}render(e,t){if(null==this._componentColorManager)return;this._localOrigins.updateViewMatrices(e.camera.viewMatrix);const r=e.camera.viewInverseTransposeMatrix,s=y(),n=new M;let o=0,i=0;if(this._renderers.forEach((r=>{if(0===r.refCount)return this._renderers.delete(r.key),void r.dispose();let s=!0,n=!0;r.forEachRenderable((t=>{t.visible&&(o+=t.statistics.averageEdgeLength,i++,s&&t.regular&&(r.updateTechnique(e,!1),s=!1),n&&t.silhouette&&(r.updateTechnique(e,!0),n=!1))}),t)})),this._componentColorManager.garbageCollect(),this._componentColorManager.updateTextures(),0===i)return;const a=new z(40*o/i,t);p(s,r[3],r[7],r[11]),n.set(s),f(a.transformWorldFromViewTH,n.high),f(a.transformWorldFromViewTL,n.low),d(a.transformViewFromCameraRelativeRS,e.camera.viewMatrix),u(_e,a.transformViewFromCameraRelativeRS),h(a.transformNormalViewFromGlobal,_e),a.transformProjFromView=e.camera.projectionMatrix,this._updateObjectCameraDistances(e),this._renderers.forEach((t=>{this._renderRegularEdges(t,e,a),this._renderSilhouetteEdges(t,e,a)}))}_updateTransparency(e){const t=X(e.components.meta),r=Y(e.components.meta);t===e.edgeTransparency&&r===e.objectTransparency||(e.edgeTransparency=t,e.objectTransparency=r,this._renderers.get(e.rendererKey).setRenderablesDirty())}_computeModelTransformWithLocalOrigin(e,t,r){e.getCombinedShaderTransformation(t,r);const s=null!=t.localOrigin?this._localOrigins.register(t.localOrigin):this._localOrigins.acquire(p(this._tmpModelPosition,r[12],r[13],r[14]));return t.localOrigin=s.origin,D(s.origin.vec3,r),s}_updateComponentBuffer(e){const{meta:t,buffer:r}=e,s=new Uint8Array(4);for(let n=0;n<t.length;n++){const e=t[n].material,i=t[n].index,a=o(Math.round(e.size*W),0,255),c=o(e.extensionLength,-q,255-q)+q,l="solid"===e.type?N.SOLID:N.SKETCH,d=255*e.opacity,u=e.color,h=255*u[0],m=255*u[1],g=255*u[2],p=255*u[3];r.textureBuffer.setData(i,0,h,m,g,p),r.textureBuffer.setData(i,1,a,c,l,d),x(t[n].verticalOffset,s),r.textureBuffer.setData(i,2,s[0],s[1],s[2],s[3])}}_createComponentBuffers(e){if(null==this._componentColorManager)return null;const t=new Array,r=this._componentColorManager.getBuffer(e.length);for(let n=0;n<e.length;n++){const s=e[n],o=r.acquireIndex();t.push({index:o,verticalOffset:0,material:s})}const s=new ae(r,t);return this._updateComponentBuffer(s),s}_extractEdges(e,t,r,s,n,o=n.length){return this._worker.process({data:t,indices:n,indicesLength:o,writerSettings:e,skipDeduplicate:r},this._workerAbort.signal,s)}_createRenderable(e,t,r,s,n){const o=t=>null!=this._verticesBufferObject?new ce(new A(this.rctx,I,{vertices:k,instances:t===ee.REGULAR?H.glLayout:V.glLayout},{vertices:this._verticesBufferObject,instances:te.createVertex(this.rctx,re.STATIC_DRAW,t===ee.REGULAR?e.regular.instancesData.buffer:e.silhouette.instancesData.buffer)}),t===ee.REGULAR?e.regular.lodInfo:e.silhouette.lodInfo):null,i=e.regular.lodInfo.lengths.length>0?o(ee.REGULAR):null,a=e.silhouette.lodInfo.lengths.length>0?o(ee.SILHOUETTE):null,c=(i?.vao.usedMemory??0)+(a?.vao.usedMemory??0);return new de(i,a,{gpuMemoryUsage:c,externalMemoryUsage:n,averageEdgeLength:e.averageEdgeLength},r,X(t.meta),Y(t.meta),t,s)}async _addGeometry(e,t,r,s,n,o){if(r.edgeIndicesLength<=0)return;const i=r.attributes.get(B.POSITION),a=g(),c=this._computeModelTransformWithLocalOrigin(e,r,a),l=new fe(i,a,c);return this._addPositionData(t,l,r.edgeIndicesLength,s,n,o)}async _addPositionData(e,t,r,s,n,o=!1){if(null==e.loaded)return;const i=this._createComponentBuffers([s]);if(null==i)return;const a=this._acquireRenderer(s.type,!!n.hasSlicePlane,!0),{modelTransform:c,origin:l}=t,d=t.position.indices,u=t.position,h=u.data.length/u.size,m=U.createBuffer(h);for(let f=0;f<h;f++)m.position.set(f,0,u.data[f*u.size]),m.position.set(f,1,u.data[f*u.size+1]),m.position.set(f,2,u.data[f*u.size+2]);Z(i.meta,[0,m.componentIndex.count],m.componentIndex);const g=await this._updatingHandles.addPromise(this._extractEdges(a.writerSettings,m,!1,o,d,r));if(null==e.loaded)return;const p=this._createRenderable(g,i,new le(c,l),a.key,!1);e.renderables.push(p),a.addRenderable(p),this._gpuMemoryUsage+=p.statistics.gpuMemoryUsage}async _addComponentGeometry(e,t,r,s,n,o,i){if(null==t.loaded)return 0;const a=this._createComponentBuffers(o);if(null==a)return 0;const c=J(o),l=this._acquireRenderer(c,i.hasSlicePlane||!1,!1),d=U.createBuffer(r.length/3);R(d.position.typedBuffer,r,d.position.typedBufferStride,3),Z(a.meta,n,d.componentIndex,s);const u=!0,h=l.writerSettings,m=await this._updatingHandles.addPromise(this._extractEdges(h,d,u,!1,s));if(null==t.loaded)return 0;const g=this._createRenderable(m,a,e,l.key,!0);return t.renderables.push(g),l.addRenderable(g),g.statistics.gpuMemoryUsage}async _addObjectMergedGeometries(e,t,r,s,n){const o=new Map;let i=0,a=null,c=0;const l=e.geometries.filter((e=>{if(e.edgeIndicesLength<=0||!e.material.supportsEdges)return!1;!a&&e.localOrigin&&(a=e);const t=e.attributes.get(B.POSITION);return c+=t.data.length/t.size,i+=e.edgeIndicesLength,!0}));if(0===l.length)return;const d=c>=65536?Uint32Array:Uint16Array,u=i?new d(i):null,h=[];let m=0;l.forEach((e=>{const t=e.attributes.get(B.POSITION),r=t.indices;let s=o.get(t.data);if(null==s){s=h.length/3;for(let e=0;e<t.data.length;e+=t.size)h.push(t.data[e]),h.push(t.data[e+1]),h.push(t.data[e+2]);o.set(t.data,s)}for(let n=0;n<e.edgeIndicesLength;n++)u[m++]=s+r[n]}));const p=a||e.geometries[0],f=g(),_=this._computeModelTransformWithLocalOrigin(e,p,f);for(let g=0;g<e.geometries.length;g++)e.geometries[g].localOrigin=_.origin;const b=new fe(new T(h,u,3),f,_);await this._updatingHandles.addPromise(this._addPositionData(t,b,u.length,r[0],s,n))}_acquireRenderer(e,t,r){const s=G.getKey(e,t,r);let n=this._renderers.get(s);return null==this._strokesTexture&&(this._strokesTexture=Q(this.rctx)),n||(n=new G(this.rctx,this.techniqueRepository,{type:e,hasSlicePlane:t,strokesTexture:this._strokesTexture,legacy:r,spherical:this.viewingMode===v.Global}),this._renderers.set(s,n)),++n.refCount,n}_removeRenderable(e){ne(e.regular),ne(e.silhouette);const t=this._renderers.get(e.rendererKey);if(t){t.removeRenderable(e),--t.refCount,"origin"in e.transform&&this._localOrigins.release(e.transform.origin),this._gpuMemoryUsage-=e.statistics.externalMemoryUsage?0:e.statistics.gpuMemoryUsage;for(const t of e.components.meta)e.components.buffer.releaseIndex(t.index)}}_updateObjectCameraDistances(e){const t=e.camera.eye,r=e.camera.viewForward,s=y(),n=e=>{_(s,e.center,t);const n=b(s,r),o=e.radius,i=n<-o?1/0:n<o?0:n-o;e.renderables.forEach((e=>e.distanceToCamera=i))};this._perObjectData.forEach(n),this._perObjectDataEvictionCache.forEach(n)}_renderRegularEdges(e,t,r){const s=e.bindRegularEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!he(n)||!n.visible)return;const i=pe(n.regular.lod.lengths,n.distanceToCamera,o);e.renderRegularEdges(s,n,r,t,i)}),n)}_renderSilhouetteEdges(e,t,r){const s=e.bindSilhouetteEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!ge(n)||!n.visible)return;const i=pe(n.silhouette.lod.lengths,n.distanceToCamera,o);e.renderSilhouetteEdges(s,n,r,t,i)}),n)}get test(){return{hasRenderedPrimitives:e=>{let t=!1;const r=e.perScreenPixelRatio,s=(e,s)=>e.forEachRenderable((e=>{e.visible&&!t&&(he(e)&&(t=pe(e.regular.lod.lengths,e.distanceToCamera,r)>0),!t&&ge(e)&&(t=pe(e.silhouette.lod.lengths,e.distanceToCamera,r)>0))}),s);return this._renderers.forEach((e=>{t||(s(e,F.OPAQUE),s(e,F.TRANSPARENT))})),t},getObjectData:e=>this._perObjectData.get(e)}}};function ne(e){null!=e&&(e.vao.vertexBuffers.instances.dispose(),e.vao.disposeVAOOnly(),e.vao=null)}function oe(e){let t=null,s=null;for(let n=0;n<e.geometries.length;n++){const o=e.geometries[n];if(o.material.supportsEdges){if(t){if(!r(t,o.transformation))return!1}else t=o.transformation;if(s||null==o.localOrigin){if(null!=s?.localOrigin&&null!=o.localOrigin&&s.localOrigin.id!==o.localOrigin.id)return!1}else s=o}}return!0}e([c({constructOnly:!0})],se.prototype,"rctx",void 0),e([c({constructOnly:!0})],se.prototype,"renderSR",void 0),e([c({constructOnly:!0})],se.prototype,"viewingMode",void 0),e([c({constructOnly:!0})],se.prototype,"techniqueRepository",void 0),e([c({constructOnly:!0})],se.prototype,"setNeedsRender",void 0),e([c({constructOnly:!0})],se.prototype,"schedule",void 0),e([c({readOnly:!0})],se.prototype,"_updatingHandles",void 0),e([c({readOnly:!0})],se.prototype,"updating",null),se=e([l("esri.views.3d.webgl-engine.lib.edgeRendering.EdgeView")],se);class ie{constructor(e,t,r){this.radius=r,this.renderables=new Array,this.loaded=e,this.loaded.then((()=>{null!=this.loaded&&(this.loaded=!0)})),this.center=j(t)}}class ae{constructor(e,t){this.buffer=e,this.meta=t}}class ce{constructor(e,t){this.vao=e,this.lod=t}}class le{constructor(e,t){this.modelMatrix=e,this.origin=t}}class de{constructor(e,t,r,s,n,o,i,a){this.regular=e,this.silhouette=t,this.statistics=r,this.transform=s,this.edgeTransparency=n,this.objectTransparency=o,this.components=i,this.rendererKey=a,this.distanceToCamera=0,this.visible=!0}}class ue extends de{}function he(e){return null!=e.regular}class me extends de{}function ge(e){return null!=e.silhouette}function pe(e,t,r){const n=t*r,o=s(e,n,!0);return-1===o?n<e[0]?e.length:0:e.length-o}class fe{constructor(e,t,r){this.position=e,this.modelTransform=t,this.origin=r}}const _e=m(),be=()=>Promise.reject();export{se as EdgeView,le as LegacyTransform,ue as RegularRenderable,de as Renderable,me as SilhouetteRenderable};
|
|
@@ -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{range as e}from"../../../../../core/arrayUtils.js";import{deg2rad as t,acosClamped as n}from"../../../../../core/mathUtils.js";import{
|
|
5
|
+
import{range as e}from"../../../../../core/arrayUtils.js";import{deg2rad as t,acosClamped as n}from"../../../../../core/mathUtils.js";import{q as o,s as r,c,k as s,E as a,b as i,f as l,n as f}from"../../../../../chunks/vec32.js";import{create as g}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";const m=-1;var p;function u(n,a,i,l=E){const f=n.vertices.position,g=n.vertices.componentIndex,p=t(l.anglePlanar),u=t(l.angleSignificantEdge),y=Math.cos(u),V=Math.cos(p),x=I.edge,N=x.position0,S=x.position1,j=x.faceNormal0,D=x.faceNormal1,F=w(n),b=d(n),L=b.length/4,k=a.allocate(L);let C=0;const H=L,K=i.allocate(H);let M=0,O=0,P=0;const T=e(0,L),U=new Float32Array(L);U.forEach(((e,t,n)=>{f.getVec(b[4*t],N),f.getVec(b[4*t+1],S),n[t]=o(N,S)})),T.sort(((e,t)=>U[t]-U[e]));const q=new Array,z=new Array;for(let e=0;e<L;e++){const t=T[e],n=U[t],o=b[4*t],l=b[4*t+1],u=b[4*t+2],d=b[4*t+3],w=d===m;if(f.getVec(o,N),f.getVec(l,S),w)r(j,F[3*u],F[3*u+1],F[3*u+2]),c(D,j),x.componentIndex=g.get(o),x.cosAngle=s(j,D);else{if(r(j,F[3*u],F[3*u+1],F[3*u+2]),r(D,F[3*d],F[3*d+1],F[3*d+2]),x.componentIndex=g.get(o),x.cosAngle=s(j,D),v(x,V))continue;x.cosAngle<-.9999&&c(D,j)}O+=n,P++,w||h(x,y)?(a.write(k,C++,x),q.push(n)):A(x,p)&&(i.write(K,M++,x),z.push(n))}const B=new Float32Array(q.reverse()),G=new Float32Array(z.reverse());return{regular:{instancesData:a.trim(k,C),lodInfo:{lengths:B}},silhouette:{instancesData:i.trim(K,M),lodInfo:{lengths:G}},averageEdgeLength:O/P}}function h(e,t){return e.cosAngle<t}function v(e,t){return e.cosAngle>t}function A(e,t){const o=n(e.cosAngle),r=I.fwd,c=I.ortho;a(r,e.position1,e.position0);return o*(s(i(c,e.faceNormal0,e.faceNormal1),r)>0?-1:1)>t}function d(e){const t=e.faces.length/3,n=e.faces,o=e.neighbors;let r=0;for(let a=0;a<t;a++){const e=o[3*a],t=o[3*a+1],c=o[3*a+2],s=n[3*a],i=n[3*a+1],l=n[3*a+2];r+=e===m||s<i?1:0,r+=t===m||i<l?1:0,r+=c===m||l<s?1:0}const c=new Int32Array(4*r);let s=0;for(let a=0;a<t;a++){const e=o[3*a],t=o[3*a+1],r=o[3*a+2],i=n[3*a],l=n[3*a+1],f=n[3*a+2];(e===m||i<l)&&(c[s++]=i,c[s++]=l,c[s++]=a,c[s++]=e),(t===m||l<f)&&(c[s++]=l,c[s++]=f,c[s++]=a,c[s++]=t),(r===m||f<i)&&(c[s++]=f,c[s++]=i,c[s++]=a,c[s++]=r)}return c}function w(e){const t=e.faces.length/3,n=e.vertices.position,o=e.faces,r=y.v0,c=y.v1,s=y.v2,a=new Float32Array(3*t);for(let g=0;g<t;g++){const e=o[3*g],t=o[3*g+1],m=o[3*g+2];n.getVec(e,r),n.getVec(t,c),n.getVec(m,s),l(c,c,r),l(s,s,r),i(r,c,s),f(r,r),a[3*g]=r[0],a[3*g+1]=r[1],a[3*g+2]=r[2]}return a}!function(e){e[e.SOLID=0]="SOLID",e[e.SKETCH=1]="SKETCH"}(p||(p={}));const I={edge:{position0:g(),position1:g(),faceNormal0:g(),faceNormal1:g(),componentIndex:0,cosAngle:0},ortho:g(),fwd:g()},y={v0:g(),v1:g(),v2:g()},E={anglePlanar:4,angleSignificantEdge:35};export{p as EdgeType,u as extractEdges};
|
|
@@ -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{s as t,g as e,h as n,
|
|
5
|
+
import{s as t,g as e,h as n,o as r}from"../../../../chunks/vec32.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{areaPoints3d as s}from"../../../../geometry/support/triangle.js";function i(r,o){if(!r)return!1;const{size:i,data:c,indices:f}=r;t(o,0,0,0),t(m,0,0,0);let g=0,d=0;for(let p=0;p<f.length-2;p+=3){const r=f[p]*i,h=f[p+1]*i,j=f[p+2]*i;t(a,c[r],c[r+1],c[r+2]),t(l,c[h],c[h+1],c[h+2]),t(u,c[j],c[j+1],c[j+2]);const z=s(a,l,u);z?(e(a,a,l),e(a,a,u),n(a,a,1/3*z),e(o,o,a),g+=z):(e(m,m,a),e(m,m,l),e(m,m,u),d+=3)}return(0!==d||0!==g)&&(0!==g?(n(o,o,1/g),!0):0!==d&&(n(o,m,1/d),!0))}function c(e,r){if(!e)return!1;const{size:o,data:s,indices:i}=e;t(r,0,0,0);let c=-1,f=0;for(let t=0;t<i.length;t++){const e=i[t]*o;c!==e&&(r[0]+=s[e],r[1]+=s[e+1],r[2]+=s[e+2],f++),c=e}return f>1&&n(r,r,1/f),f>0}function f(o,s,i){if(!o)return!1;t(i,0,0,0),t(m,0,0,0);let c=0,f=0;const{size:u,data:g,indices:d}=o,p=d.length-1,h=p+(s?2:0);for(let t=0;t<h;t+=2){const o=t<p?t+1:0,s=d[t<p?t:p]*u,h=d[o]*u;a[0]=g[s],a[1]=g[s+1],a[2]=g[s+2],l[0]=g[h],l[1]=g[h+1],l[2]=g[h+2],n(a,e(a,a,l),.5);const j=r(a,l);j>0?(e(i,i,n(a,a,j)),c+=j):0===c&&(e(m,m,a),f++)}return 0!==c?(n(i,i,1/c),!0):0!==f&&(n(i,m,1/f),!0)}const a=o(),l=o(),u=o(),m=o();export{f as computeAttachmentOriginLines,c as computeAttachmentOriginPoints,i as computeAttachmentOriginTriangles};
|
|
@@ -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{
|
|
5
|
+
import{m as t}from"../../../../chunks/vec32.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{e}from"../../../../chunks/boundedPlane.js";import{IntersectorType as n}from"./IntersectorInterfaces.js";function o(t){return null!=t?.dist}function c(r){return(n,o,c)=>(t(u,n,o,c),!e(r,u))}function s(t){return o(t)&&t.intersector===n.OBJECT&&!!t.target}function i(t){return o(t)&&t.intersector===n.HUD&&!!t.target&&"center"in t.target&&null!=t.target.center}const u=r();export{i as isHudIntersectorResult,s as isObjectIntersectorResult,o as isValidIntersectorResult,c as sliceFilterPredicate};
|