@arcgis/core 4.29.0 → 4.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/arcade/treeAnalysis.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{b43fde3e25d0c3b020b5.js → 039a872509872ce67ba4.js} +1 -1
- package/assets/esri/core/workers/chunks/{5243f9ff21e768c620c2.js → 23a5d750d93a7829174f.js} +1 -1
- package/assets/esri/core/workers/chunks/{47e6119be4a4a5ed640d.js → 2447a4d5886aeb0ff72a.js} +1 -1
- package/assets/esri/core/workers/chunks/{7f45a9e9bdbcffc2d6e0.js → 348bcc57b99a975902a8.js} +1 -1
- package/assets/esri/core/workers/chunks/{8c9fb2601488998013ba.js → 3523789a2948a4ab8cc8.js} +1 -1
- package/assets/esri/core/workers/chunks/{24649b410b757599a549.js → 48db6e0bbb1a9c043193.js} +1 -1
- package/assets/esri/core/workers/chunks/{752082be991f1cc8558f.js → 4984e2b79d862114d6a6.js} +1 -1
- package/assets/esri/core/workers/chunks/{8d9736fd15cdb54d9855.js → 5227f9eea6988aadad7f.js} +1 -1
- package/assets/esri/core/workers/chunks/58723274ef657fe212eb.js +1 -0
- package/assets/esri/core/workers/chunks/60ab18c6a04d4b2f1d4c.js +1 -0
- package/assets/esri/core/workers/chunks/647515801d94180b8402.js +1 -0
- package/assets/esri/core/workers/chunks/6c3ae96ec90e9ed7dd50.js +1 -0
- package/assets/esri/core/workers/chunks/7a8bba91769ee18cc39f.js +1 -0
- package/assets/esri/core/workers/chunks/7a98d2e026f63a581b1e.js +1 -0
- package/assets/esri/core/workers/chunks/8c360923cd1850767d3e.js +1 -0
- package/assets/esri/core/workers/chunks/{1a25ba411b89e050fbb7.js → a61f337802ae963d7f65.js} +1 -1
- package/assets/esri/core/workers/chunks/{d0c5318d7ef2e923aad0.js → a8ac511280f873960d46.js} +1 -1
- package/assets/esri/core/workers/chunks/b125ab84b7761e761734.js +1 -0
- package/assets/esri/core/workers/chunks/{b34d6e58b125fe111f91.js → b42a83db83851cb57d44.js} +1 -1
- package/assets/esri/core/workers/chunks/{1497dd943df7eede0704.js → b9c55ff1f21db198ce03.js} +1 -1
- package/assets/esri/core/workers/chunks/bb3322ddb89c0bd444f0.js +1 -0
- package/assets/esri/core/workers/chunks/becfdaeeb07f089d8be7.js +1 -0
- package/assets/esri/core/workers/chunks/{b26e39a399963c176d33.js → c527692694688a5b3b07.js} +2 -2
- package/assets/esri/core/workers/chunks/{210a93e0b96c5bff44a3.js → c556644bb0cf88770939.js} +1 -1
- package/assets/esri/core/workers/chunks/{a5e7b4acae17f88e2208.js → ce93027b6b81428ce9b0.js} +1 -1
- package/assets/esri/core/workers/chunks/{b8ece275abac93f3dccf.js → d14f16bfa6c12909929c.js} +1 -1
- package/assets/esri/core/workers/chunks/{1594f06a2d7d9439c62e.js → e2147c99cc5839654be1.js} +1 -1
- package/assets/esri/core/workers/chunks/{d33ed3a2a0d4b640bd4a.js → e4c7d8c69e4957c9d27c.js} +1 -1
- package/assets/esri/core/workers/chunks/{7709248f59520aee6f51.js → eceaa46f622f6fa31128.js} +1 -1
- package/assets/esri/core/workers/chunks/{2286db4c83ff1b6fb088.js → ef3e6209e6ac6a56960b.js} +1 -1
- package/assets/esri/core/workers/chunks/f59b5ea05caca8a1a398.js +1 -0
- package/chunks/Laserlines.glsl.js +3 -3
- package/chunks/Precipitation.glsl.js +1 -1
- package/chunks/SSAOBlur.glsl.js +2 -2
- package/chunks/boundedPlane.js +1 -1
- package/chunks/cameraUtilsSpherical.js +1 -1
- package/chunks/sphere.js +1 -1
- package/chunks/terrainUtilsPlanar.js +1 -1
- package/chunks/vec32.js +1 -1
- package/core/libs/gl-matrix-2/math/quat.js +1 -1
- package/core/libs/gl-matrix-2/math/vec3.js +1 -1
- package/core/libs/gl-matrix-2/vec3.js +1 -1
- package/geometry/support/axisAngleDegrees.js +1 -1
- package/geometry/support/coordinateSystem.js +1 -1
- package/geometry/support/lineSegment.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
- package/geometry/support/meshUtils/georeference.js +1 -1
- package/geometry/support/meshUtils/merge.js +1 -1
- package/geometry/support/meshUtils/rotate.js +1 -1
- package/geometry/support/meshUtils/scale.js +1 -1
- package/geometry/support/meshUtils/vertexSpaceConversion.js +5 -0
- package/geometry/support/meshVertexSpaceUtils.js +1 -1
- package/geometry/support/plane.js +1 -1
- package/geometry/support/ray.js +1 -1
- package/geometry/support/triangle.js +1 -1
- package/geometry/support/vector.js +1 -1
- package/interfaces.d.ts +6 -6
- package/kernel.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/layers/LinkChartLayer.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
- package/layers/mixins/FeatureReductionLayer.js +1 -1
- package/layers/orientedImagery/core/coverageUtils.js +1 -1
- package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
- package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
- package/layers/support/layerUtils.js +1 -1
- package/layers/video/VideoCameraSensorModel.js +1 -1
- package/layers/voxel/VoxelVolume.js +1 -1
- package/layers/voxel/voxelPlaneUtils.js +1 -1
- package/libs/linkchartlayout/LinkChartLayout.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/views/2d/arcade/callExpressionWithCursor.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/createTestMeshData.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/mesh/MeshWriterInputEvaluator.js +1 -1
- package/views/2d/interactive/editingTools/TransformTool.js +1 -1
- package/views/2d/interactive/editingTools/manipulations/ScaleManipulation.js +1 -1
- package/views/2d/layers/features/Processor.js +1 -1
- package/views/2d/layers/features/aggregation/GeohashSpatialIndex.js +1 -1
- package/views/2d/layers/features/aggregation/GridSpatialIndex.js +1 -1
- package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/StreamLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
- package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
- package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
- package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/DrillDownTileSourceChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/OverrideChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/PagedTileSourceChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/StreamSourceChunk.js +1 -1
- package/views/2d/layers/features/support/AttributeStore.js +1 -1
- package/views/2d/layers/features/support/FeatureMetadata.js +1 -1
- package/views/2d/layers/features/support/GraphicsReader.js +1 -1
- package/views/2d/layers/features/support/Tile.js +1 -1
- package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
- package/views/2d/tiling/TileKey.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionConstraintUtils.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
- package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementController.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
- package/views/3d/analysis/Slice/SliceTool.js +1 -1
- package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
- package/views/3d/analysis/support/measurementUtils.js +1 -1
- package/views/3d/animation/pointToPoint/Camera.js +1 -1
- package/views/3d/camera/constraintUtils/common.js +1 -1
- package/views/3d/camera/constraintUtils/distance.js +1 -1
- package/views/3d/camera/constraintUtils/tilt.js +1 -1
- package/views/3d/camera/intersectionUtils.js +1 -1
- package/views/3d/environment/ChapmanAtmosphere.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/environment/Fog.js +1 -1
- package/views/3d/environment/MarsAtmosphere.js +1 -1
- package/views/3d/environment/SceneViewEnvironmentManager.js +1 -1
- package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
- package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
- package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
- package/views/3d/interactive/editingTools/reshapeGraphic/edgeOffsetUtils.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ExtentScale.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/extentUtils.js +1 -1
- package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/support/Segment.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/PointCloudWorker.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/i3s/LoDUtil.js +1 -1
- package/views/3d/layers/i3s/PointRenderer.js +1 -1
- package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
- package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
- package/views/3d/layers/support/uvUtils.js +1 -1
- package/views/3d/state/Frustum.js +1 -1
- package/views/3d/state/NearFarHeuristic.js +1 -1
- package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
- package/views/3d/state/controllers/RotateController.js +1 -1
- package/views/3d/state/controllers/global/PinchAndPanController.js +1 -1
- package/views/3d/state/controllers/global/ZoomController.js +1 -1
- package/views/3d/state/controllers/global/ZoomStepController.js +1 -1
- package/views/3d/state/controllers/local/PinchAndPanController.js +1 -1
- package/views/3d/state/controllers/local/ZoomController.js +1 -1
- package/views/3d/state/controllers/local/ZoomStepController.js +1 -1
- package/views/3d/state/controllers/momentum/ZoomPlanarMomentumController.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/state/utils/viewUtils.js +1 -1
- package/views/3d/support/FrustumExtentIntersection.js +1 -1
- package/views/3d/support/cameraUtils.js +1 -1
- package/views/3d/support/cameraUtilsInternal.js +1 -1
- package/views/3d/support/intersectionUtils.js +1 -1
- package/views/3d/support/mathUtils.js +1 -1
- package/views/3d/support/orientedBoundingBox.js +1 -1
- package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/Focus.js +1 -1
- package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
- package/views/3d/support/sunUtils.js +1 -1
- package/views/3d/support/viewpointUtils.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/PatchRenderData.js +1 -1
- package/views/3d/terrain/SphericalPatch.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/webgl-engine/collections/Component/DepthRange.js +1 -1
- package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/core/util/TwoVectorPosition.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
- package/views/3d/webgl-engine/lib/BoundingInfo.js +1 -1
- package/views/3d/webgl-engine/lib/Camera.js +1 -1
- package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
- package/views/3d/webgl-engine/lib/Object3D.js +1 -1
- package/views/3d/webgl-engine/lib/Octree.js +1 -1
- package/views/3d/webgl-engine/lib/PathVertex.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js +1 -1
- package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
- package/views/3d/webgl-engine/lib/intersectorUtils.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
- package/views/3d/webgl-engine/lighting/SceneLighting.js +1 -1
- package/views/3d/webgl-engine/lighting/SphericalHarmonics.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/pbrUtils.js +1 -1
- package/views/SelectionManager.js +1 -1
- package/views/draw/support/createUtils.js +1 -1
- package/views/draw/support/surfaceCoordinateSystems.js +1 -1
- package/views/interactive/GraphicManipulator.js +1 -1
- package/views/interactive/SegmentLabels.js +1 -1
- package/views/interactive/coordinateHelper.js +1 -1
- package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
- package/views/interactive/editGeometry/support/editPlaneUtils.js +1 -1
- package/views/interactive/sketch/constraints.js +1 -1
- package/views/interactive/snapping/RightAngleSnapper.js +1 -1
- package/views/interactive/snapping/candidates/ParallelLineSnappingCandidate.js +1 -1
- package/views/interactive/snapping/candidates/RightAngleTriangleSnappingCandidate.js +1 -1
- package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.js +1 -1
- package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js +1 -1
- package/views/interactive/snapping/hints/IntersectionSnappingHint.js +1 -1
- package/views/interactive/snapping/hints/LineSnappingHint.js +1 -1
- package/views/interactive/snapping/hints/ParallelSnappingHint.js +1 -1
- package/views/interactive/snapping/hints/PointSnappingHint.js +1 -1
- package/views/interactive/snapping/hints/RightAngleSnappingHint.js +1 -1
- package/views/layers/FeatureLayerView.js +1 -1
- package/views/navigation/PanSphericalMomentumEstimator.js +1 -1
- package/views/support/angularMeasurementUtils.js +1 -1
- package/views/support/euclideanAreaMeasurementUtils.js +1 -1
- package/views/support/euclideanLengthMeasurementUtils.js +1 -1
- package/views/support/geometry3dUtils.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/Grid/Grid.js +1 -1
- package/widgets/FeatureTable/support/ColumnTemplateBase.js +1 -1
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
- package/widgets/PanoramicViewer/utils.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/support/Selector2D/SelectionOperation.js +1 -1
- package/widgets/support/Selector2D/selectorUtils.js +1 -1
- package/assets/esri/core/workers/chunks/0e83f3718a0b45652b5e.js +0 -1
- package/assets/esri/core/workers/chunks/1fa5c8af69a09a3730b3.js +0 -1
- package/assets/esri/core/workers/chunks/4736f79b5c94ce103d43.js +0 -1
- package/assets/esri/core/workers/chunks/65f7adaaf1f535310c11.js +0 -1
- package/assets/esri/core/workers/chunks/79c041b292648c5eaecc.js +0 -1
- package/assets/esri/core/workers/chunks/7c4c2c0beddabac672b6.js +0 -1
- package/assets/esri/core/workers/chunks/9307d485a9e5f9fa77d1.js +0 -1
- package/assets/esri/core/workers/chunks/9a758de08dfa57735879.js +0 -1
- package/assets/esri/core/workers/chunks/a4c3da057ec2a07bbbe8.js +0 -1
- package/assets/esri/core/workers/chunks/b252270b100351779f1f.js +0 -1
- package/assets/esri/core/workers/chunks/dc57aa9f2fc69e654559.js +0 -1
|
@@ -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};
|
|
@@ -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{isSome as t}from"../../../../../core/arrayUtils.js";import{destroyMaybe as r}from"../../../../../core/maybe.js";import{isAborted as a,throwIfAborted as s}from"../../../../../core/promiseUtils.js";import{property as n}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import{subclass as i}from"../../../../../core/accessorSupport/decorators/subclass.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{f as l,j as c,e as h}from"../../../../../chunks/vec32.js";import{create as d}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as u,fromValues as m}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{debugFlags as f}from"../../../support/debugFlags.js";import{glLayout as _}from"../../../support/buffer/glUtil.js";import{newLayout as p}from"../../../support/buffer/InterleavedLayout.js";import{ShaderOutput as g}from"../../core/shaderLibrary/ShaderOutput.js";import{ASyncPreparesRenderPlugin as I}from"../../effects/RenderPlugin.js";import{Camera as C}from"../Camera.js";import{Default3D as y}from"../DefaultVertexAttributeLocations.js";import{IntersectorType as v}from"../IntersectorInterfaces.js";import E from"../Octree.js";import{RenderSlot as A}from"../RenderSlot.js";import{assert as D}from"../Util.js";import{VertexAttribute as b}from"../VertexAttribute.js";import{InstanceData as R,StateFlags as T}from"./InstanceData.js";import{InstanceOctree as L}from"./InstanceOctree.js";import{LevelSelector as S}from"./LevelSelector.js";import{LodLevel as O}from"./LodLevel.js";import{RenderInstanceData as j}from"./RenderInstanceData.js";import{colorMixModes as x}from"../../materials/internal/MaterialUtil.js";import{encodeDoubleVec3 as N}from"../../materials/renderers/utils.js";import{DefaultMaterialDrawParameters as M}from"../../shaders/DefaultMaterialTechnique.js";import{TaskPriority as U,noBudget as w}from"../../../../support/Scheduler.js";import{bindVertexBufferLayout as F,unbindVertexBufferLayout as H}from"../../../../webgl/Util.js";const V=e=>{const t=e.baseBoundingSphere.radius,r=e.levels.map((e=>e.minScreenSpaceRadius));return new S(t,r)};let B=class extends I{constructor(e,t){super(e),this.type=v.LOD,this.isGround=!1,this._levels=[],this._defaultRenderInstanceData=[new Array],this._highlightRenderInstanceData=[new Array],this._allRenderInstanceData=[this._defaultRenderInstanceData[0],this._highlightRenderInstanceData[0]],this._instanceIndex=0,this._cycleStartIndex=0,this._slicePlane=!1,this._camera=new C,this._updateCyclesWithStaticCamera=-1,this._needFullCycle=!1,this.produces=new Map([[A.OPAQUE_MATERIAL,e=>this._produces(e)],[A.TRANSPARENT_MATERIAL,e=>!!this._hasTransparentLevels()&&this._produces(e)]]),this._instanceData=new R({shaderTransformation:e.shaderTransformation},e.optionalFields),this.addHandles(t.registerTask(U.LOD_RENDERER,this))}initialize(){this._instanceBufferLayout=q(this.optionalFields),this._glInstanceBufferLayout=_(this._instanceBufferLayout,1),this.addHandles([this._instanceData.events.on("instances-changed",(()=>this._requestUpdateCycle())),this._instanceData.events.on("instance-transform-changed",(({index:e})=>{this._requestUpdateCycle(),this.metadata.notifyGraphicGeometryChanged(e)})),this._instanceData.events.on("instance-visibility-changed",(({index:e})=>{this._requestUpdateCycle(!0),this.metadata.notifyGraphicVisibilityChanged(e)})),this._instanceData.events.on("instance-highlight-changed",(()=>this._requestUpdateCycle(!0)))])}get _enableLevelSelection(){return this.symbol.levels.length>1}get levels(){return this._levels}get baseBoundingBox(){return this._levels[this._levels.length-1].boundingBox}get baseBoundingSphere(){return this._levels[this._levels.length-1].boundingSphere}get baseMaterial(){return this._levels[this._levels.length-1].components[0].material}get slicePlaneEnabled(){return this._slicePlane}set slicePlaneEnabled(e){this._slicePlane=e}get layerUid(){return this.metadata.layerUid}get instanceData(){return this._instanceData}get usedMemory(){return this._allRenderInstanceData.reduce(((e,t)=>t.reduce(((e,t)=>e+t.usedMemory),e)),0)}get renderStats(){const e=this._instanceData.size,t=[];return this._levels.forEach(((e,r)=>{const a=this._allRenderInstanceData[0][r].size+this._allRenderInstanceData[1][r].size,s=e.triangleCount;t.push({renderedInstances:a,renderedTriangles:a*s,trianglesPerInstance:s})})),{totalInstances:e,renderedInstances:t.reduce(((e,t)=>e+t.renderedInstances),0),renderedTriangles:t.reduce(((e,t)=>e+t.renderedTriangles),0),levels:t}}async initializeRenderContext(e,r){this._context=e;const n=e.renderContext.rctx,i=await Promise.allSettled(this.symbol.levels.map((t=>(this._defaultRenderInstanceData[0].push(new j(n,this._instanceBufferLayout)),this._highlightRenderInstanceData[0].push(new j(n,this._instanceBufferLayout)),O.create(e,t,r))))),o=i.map((e=>"fulfilled"===e.status?e.value:null)).filter(t);if(a(r)||o.length!==i.length){o.forEach((e=>e.destroy())),s(r);for(const e of i)if("rejected"===e.status)throw e.reason}this._levels=o,this._levelSelector=V(this)}uninitializeRenderContext(){this._invalidateOctree(),this._levels.forEach((e=>e.destroy())),this._defaultRenderInstanceData[0].forEach((e=>e.destroy())),this._highlightRenderInstanceData[0].forEach((e=>e.destroy()))}_hasTransparentLevels(){return this._levels.some((e=>e.components.some((e=>{const t=e.material.produces.get(A.TRANSPARENT_MATERIAL);return t&&t(g.Color)}))))}hasHighlights(){return this._highlightRenderInstanceData[0].some((e=>e.size>0))}_produces(e){return e!==g.Highlight&&e!==g.ShadowHighlight||this.hasHighlights()}prepareRender(e){if(!f.LOD_INSTANCE_RENDERER_DISABLE_UPDATES){if(this._enableLevelSelection){const t=e.bindParameters.contentCamera.equals(this._camera);this._camera.copyFrom(e.bindParameters.contentCamera),t||this._requestUpdateCycle()}this._needFullCycle&&(this.runTask(w),this._needFullCycle=!1)}}prepareTechniques(e){if(!this.baseMaterial.isVisible()||!this.baseMaterial.isVisibleForOutput(e.output))return null;const t=this._getInstanceDatas(e.output);if(!t)return null;const r=new Array;return t.forEach((t=>this.levels.forEach(((a,s)=>{a.components.forEach((a=>r.push(this._beginComponent(e,t[s],a))))})))),r}renderNode(e,t){const r=this._getInstanceDatas(e.output);if(!r||null==t)return;let a=0;e.rctx.bindVAO(),r.forEach((r=>this.levels.forEach(((s,n)=>{s.components.forEach((s=>this._renderComponent(e,t[a++],r[n],s,n)))}))))}_getInstanceDatas(e){const t=e!==g.Highlight&&e!==g.ShadowHighlight,r=e!==g.ShadowExcludeHighlight;return t&&r?this._allRenderInstanceData:t?this._defaultRenderInstanceData:r?this._highlightRenderInstanceData:null}intersect(e,t,r,a){if(!this.baseMaterial.isVisible()||null==this._octree)return;const s=d();l(s,a,r);const n=s=>{this._instanceData.getCombinedModelTransform(s,W),e.transform.set(W),h(K,r,e.transform.inverse),h(Y,a,e.transform.inverse);const n=this._instanceData.getState(s),i=this._instanceData.getLodLevel(s),o=this._levels.length;D(0!=(n&T.ACTIVE),"invalid instance state"),D(i>=0&&i<o,"invaid lod level"),this._levels[i].intersect(e,t,K,Y,s,this.metadata,o)};this.baseMaterial.parameters.verticalOffset?this._octree.forEach(n):this._octree.forEachAlongRay(r,s,n)}notifyShaderTransformationChanged(){this._invalidateOctree(),this._requestUpdateCycle()}get _octree(){if(null==this._octreeCached){const e=this._instanceData,t=e.view?.state;if(!t)return null;this._octreeCached=new L(e,this.baseBoundingSphere);for(let r=0;r<e.capacity;++r)t.get(r)&T.ACTIVE&&this._octreeCached.addInstance(r)}return this._octreeCached}_invalidateOctree(){this._octreeCached=r(this._octreeCached)}queryDepthRange(e){if(null==this._octree)return{near:1/0,far:-1/0};const t=e.viewForward,r=this._octree.findClosest(t,E.DepthOrder.FRONT_TO_BACK,e.frustum),a=this._octree.findClosest(t,E.DepthOrder.BACK_TO_FRONT,e.frustum);if(null==r||null==a)return{near:1/0,far:-1/0};const s=e.eye,n=this._instanceData.view;n.boundingSphere.getVec(r,k),l(k,k,s);const i=c(k,t)-k[3];n.boundingSphere.getVec(a,k),l(k,k,s);const o=c(k,t)+k[3];return{near:Math.max(e.near,i),far:Math.min(e.far,o)}}_requestUpdateCycle(e=!1){this._updateCyclesWithStaticCamera=-1,this._cycleStartIndex=this._instanceIndex,e&&(this._needFullCycle=!0,this._context.requestRender())}_startUpdateCycle(){this._updateCyclesWithStaticCamera++,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.startUpdateCycle()))))}get running(){return this._instanceData.size>0&&this._updateCyclesWithStaticCamera<1}runTask(e){const{_enableLevelSelection:t,_camera:r,_levelSelector:a}=this;this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.beginUpdate()))));const s=this._instanceData,n=s.view;let i=s.size;const o=s.capacity;let l=this._instanceIndex;const c=Math.ceil(o/500);for(let h=0;h<i&&!e.done;++h){l===this._cycleStartIndex&&this._startUpdateCycle();const h=n.state.get(l);let d=0;if(!(h&T.ALLOCATED)){l=l+1===o?0:l+1,i++;continue}const u=n.lodLevel.get(l);if(h&T.DEFAULT_ACTIVE&&this._defaultRenderInstanceData[0][u].freeTail(),h&T.HIGHLIGHT_ACTIVE&&this._highlightRenderInstanceData[0][u].freeTail(),h&T.REMOVE)s.freeInstance(l);else if(h&T.VISIBLE){let e=0;t&&(n.modelOrigin.getVec(l,z),e=a.selectLevel(z,s.getCombinedMedianScaleFactor(l),r)),d=h&~(T.ACTIVE|T.TRANSFORM_CHANGED),e>=0&&(h&T.HIGHLIGHT?(P(this._highlightRenderInstanceData[0][e],n,l),d|=T.HIGHLIGHT_ACTIVE):(P(this._defaultRenderInstanceData[0][e],n,l),d|=T.DEFAULT_ACTIVE)),n.state.set(l,d),n.lodLevel.set(l,e)}else d=h&~(T.ACTIVE|T.TRANSFORM_CHANGED),n.state.set(l,d);if(null!=this._octreeCached){const e=!!(h&T.ACTIVE),t=!!(d&T.ACTIVE);!e&&t?this._octreeCached.addInstance(l):e&&!t?this._octreeCached.removeInstance(l):e&&t&&h&T.TRANSFORM_CHANGED&&(this._octreeCached.removeInstance(l),this._octreeCached.addInstance(l))}l=l+1===o?0:l+1,l%c==0&&e.madeProgress()}this._instanceIndex=l,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.endUpdate())))),this._context.requestRender()}_beginComponent(e,t,r){if(0===t.size)return null;const a=r.glMaterials.load(e.rctx,e.bindParameters.slot,e.output);return null!=a?a.beginSlot(e.bindParameters):null}_renderComponent(e,t,r,a,s){if(!t)return;const{bindParameters:n,rctx:i}=e;i.runAppleAmdDriverHelper();const o=i.bindTechnique(t,n,a.material.parameters,Q);i.bindVAO(a.vao),t.ensureAttributeLocations(a.vao),f.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL&&e.output===g.Color&&(o.setUniform4fv("externalColor",J[Math.min(s,J.length-1)]),o.setUniform1i("colorMixMode",x.replace));const l=r.capacity,c=r.headIndex,h=r.tailIndex,d=r.firstIndex,u=this._glInstanceBufferLayout,m=(e,s)=>{F(i,y,r.buffer,u,e),i.drawArraysInstanced(t.primitiveType,0,a.vertexCount,s-e),H(i,y,r.buffer,u)};a.material.parameters.transparent&&null!=d?c>h?(D(d>=h&&d<=c,"invalid firstIndex"),m(d,c),m(h,d)):c<h&&(d<=c?(D(d>=0&&d<=c,"invalid firstIndex"),m(d,c),m(h,l),m(0,d)):(D(d>=h&&d<=l,"invalid firstIndex"),m(d,l),m(0,c),m(h,d))):c>h?m(h,c):c<h&&(m(0,c),m(h,l)),i.bindVAO(null)}};function P(e,t,r){const a=e.allocateHead();G(t,r,e.view,a)}function G(e,t,r,a){N(e.modelOrigin,t,r.modelOriginHi,r.modelOriginLo,a),r.model.copyFrom(a,e.model,t),r.modelNormal.copyFrom(a,e.modelNormal,t),e.color&&r.color&&r.color.copyFrom(a,e.color,t),e.objectAndLayerIdColor&&r.objectAndLayerIdColor&&r.objectAndLayerIdColor.copyFrom(a,e.objectAndLayerIdColor,t),e.featureAttribute&&r.featureAttribute&&r.featureAttribute.copyFrom(a,e.featureAttribute,t)}function q(e){let t=p().vec3f(b.INSTANCEMODELORIGINHI).vec3f(b.INSTANCEMODELORIGINLO).mat3f(b.INSTANCEMODEL).mat3f(b.INSTANCEMODELNORMAL);return null!=e&&e.includes("featureAttribute")&&(t=t.vec4f(b.INSTANCEFEATUREATTRIBUTE)),null!=e&&e.includes("color")&&(t=t.vec4u8(b.INSTANCECOLOR)),null!=e&&e.includes("objectAndLayerIdColor")&&(t=t.vec4u8(b.INSTANCEOBJECTANDLAYERIDCOLOR)),t}e([n({constructOnly:!0})],B.prototype,"symbol",void 0),e([n({constructOnly:!0})],B.prototype,"optionalFields",void 0),e([n({constructOnly:!0})],B.prototype,"metadata",void 0),e([n({constructOnly:!0})],B.prototype,"shaderTransformation",void 0),e([n()],B.prototype,"_instanceData",void 0),e([n()],B.prototype,"_cycleStartIndex",void 0),e([n({readOnly:!0})],B.prototype,"_enableLevelSelection",null),e([n()],B.prototype,"_updateCyclesWithStaticCamera",void 0),e([n({readOnly:!0})],B.prototype,"running",null),B=e([i("esri.views.3d.webgl-engine.lib.lodRendering.LodRenderer")],B);const z=d(),k=u(),W=o(),K=d(),Y=d(),J=[m(1,0,1,1),m(0,0,1,1),m(0,1,0,1),m(1,1,0,1),m(1,0,0,1)],Q=new M;export{B as LodRenderer};
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{isSome as t}from"../../../../../core/arrayUtils.js";import{destroyMaybe as r}from"../../../../../core/maybe.js";import{isAborted as a,throwIfAborted as s}from"../../../../../core/promiseUtils.js";import{property as n}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import{subclass as i}from"../../../../../core/accessorSupport/decorators/subclass.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{f as l,k as c,e as h}from"../../../../../chunks/vec32.js";import{create as d}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as u,fromValues as m}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{debugFlags as f}from"../../../support/debugFlags.js";import{glLayout as _}from"../../../support/buffer/glUtil.js";import{newLayout as p}from"../../../support/buffer/InterleavedLayout.js";import{ShaderOutput as g}from"../../core/shaderLibrary/ShaderOutput.js";import{ASyncPreparesRenderPlugin as I}from"../../effects/RenderPlugin.js";import{Camera as C}from"../Camera.js";import{Default3D as y}from"../DefaultVertexAttributeLocations.js";import{IntersectorType as v}from"../IntersectorInterfaces.js";import E from"../Octree.js";import{RenderSlot as A}from"../RenderSlot.js";import{assert as D}from"../Util.js";import{VertexAttribute as b}from"../VertexAttribute.js";import{InstanceData as R,StateFlags as T}from"./InstanceData.js";import{InstanceOctree as L}from"./InstanceOctree.js";import{LevelSelector as S}from"./LevelSelector.js";import{LodLevel as O}from"./LodLevel.js";import{RenderInstanceData as j}from"./RenderInstanceData.js";import{colorMixModes as x}from"../../materials/internal/MaterialUtil.js";import{encodeDoubleVec3 as N}from"../../materials/renderers/utils.js";import{DefaultMaterialDrawParameters as M}from"../../shaders/DefaultMaterialTechnique.js";import{TaskPriority as U,noBudget as w}from"../../../../support/Scheduler.js";import{bindVertexBufferLayout as F,unbindVertexBufferLayout as H}from"../../../../webgl/Util.js";const V=e=>{const t=e.baseBoundingSphere.radius,r=e.levels.map((e=>e.minScreenSpaceRadius));return new S(t,r)};let B=class extends I{constructor(e,t){super(e),this.type=v.LOD,this.isGround=!1,this._levels=[],this._defaultRenderInstanceData=[new Array],this._highlightRenderInstanceData=[new Array],this._allRenderInstanceData=[this._defaultRenderInstanceData[0],this._highlightRenderInstanceData[0]],this._instanceIndex=0,this._cycleStartIndex=0,this._slicePlane=!1,this._camera=new C,this._updateCyclesWithStaticCamera=-1,this._needFullCycle=!1,this.produces=new Map([[A.OPAQUE_MATERIAL,e=>this._produces(e)],[A.TRANSPARENT_MATERIAL,e=>!!this._hasTransparentLevels()&&this._produces(e)]]),this._instanceData=new R({shaderTransformation:e.shaderTransformation},e.optionalFields),this.addHandles(t.registerTask(U.LOD_RENDERER,this))}initialize(){this._instanceBufferLayout=q(this.optionalFields),this._glInstanceBufferLayout=_(this._instanceBufferLayout,1),this.addHandles([this._instanceData.events.on("instances-changed",(()=>this._requestUpdateCycle())),this._instanceData.events.on("instance-transform-changed",(({index:e})=>{this._requestUpdateCycle(),this.metadata.notifyGraphicGeometryChanged(e)})),this._instanceData.events.on("instance-visibility-changed",(({index:e})=>{this._requestUpdateCycle(!0),this.metadata.notifyGraphicVisibilityChanged(e)})),this._instanceData.events.on("instance-highlight-changed",(()=>this._requestUpdateCycle(!0)))])}get _enableLevelSelection(){return this.symbol.levels.length>1}get levels(){return this._levels}get baseBoundingBox(){return this._levels[this._levels.length-1].boundingBox}get baseBoundingSphere(){return this._levels[this._levels.length-1].boundingSphere}get baseMaterial(){return this._levels[this._levels.length-1].components[0].material}get slicePlaneEnabled(){return this._slicePlane}set slicePlaneEnabled(e){this._slicePlane=e}get layerUid(){return this.metadata.layerUid}get instanceData(){return this._instanceData}get usedMemory(){return this._allRenderInstanceData.reduce(((e,t)=>t.reduce(((e,t)=>e+t.usedMemory),e)),0)}get renderStats(){const e=this._instanceData.size,t=[];return this._levels.forEach(((e,r)=>{const a=this._allRenderInstanceData[0][r].size+this._allRenderInstanceData[1][r].size,s=e.triangleCount;t.push({renderedInstances:a,renderedTriangles:a*s,trianglesPerInstance:s})})),{totalInstances:e,renderedInstances:t.reduce(((e,t)=>e+t.renderedInstances),0),renderedTriangles:t.reduce(((e,t)=>e+t.renderedTriangles),0),levels:t}}async initializeRenderContext(e,r){this._context=e;const n=e.renderContext.rctx,i=await Promise.allSettled(this.symbol.levels.map((t=>(this._defaultRenderInstanceData[0].push(new j(n,this._instanceBufferLayout)),this._highlightRenderInstanceData[0].push(new j(n,this._instanceBufferLayout)),O.create(e,t,r))))),o=i.map((e=>"fulfilled"===e.status?e.value:null)).filter(t);if(a(r)||o.length!==i.length){o.forEach((e=>e.destroy())),s(r);for(const e of i)if("rejected"===e.status)throw e.reason}this._levels=o,this._levelSelector=V(this)}uninitializeRenderContext(){this._invalidateOctree(),this._levels.forEach((e=>e.destroy())),this._defaultRenderInstanceData[0].forEach((e=>e.destroy())),this._highlightRenderInstanceData[0].forEach((e=>e.destroy()))}_hasTransparentLevels(){return this._levels.some((e=>e.components.some((e=>{const t=e.material.produces.get(A.TRANSPARENT_MATERIAL);return t&&t(g.Color)}))))}hasHighlights(){return this._highlightRenderInstanceData[0].some((e=>e.size>0))}_produces(e){return e!==g.Highlight&&e!==g.ShadowHighlight||this.hasHighlights()}prepareRender(e){if(!f.LOD_INSTANCE_RENDERER_DISABLE_UPDATES){if(this._enableLevelSelection){const t=e.bindParameters.contentCamera.equals(this._camera);this._camera.copyFrom(e.bindParameters.contentCamera),t||this._requestUpdateCycle()}this._needFullCycle&&(this.runTask(w),this._needFullCycle=!1)}}prepareTechniques(e){if(!this.baseMaterial.isVisible()||!this.baseMaterial.isVisibleForOutput(e.output))return null;const t=this._getInstanceDatas(e.output);if(!t)return null;const r=new Array;return t.forEach((t=>this.levels.forEach(((a,s)=>{a.components.forEach((a=>r.push(this._beginComponent(e,t[s],a))))})))),r}renderNode(e,t){const r=this._getInstanceDatas(e.output);if(!r||null==t)return;let a=0;e.rctx.bindVAO(),r.forEach((r=>this.levels.forEach(((s,n)=>{s.components.forEach((s=>this._renderComponent(e,t[a++],r[n],s,n)))}))))}_getInstanceDatas(e){const t=e!==g.Highlight&&e!==g.ShadowHighlight,r=e!==g.ShadowExcludeHighlight;return t&&r?this._allRenderInstanceData:t?this._defaultRenderInstanceData:r?this._highlightRenderInstanceData:null}intersect(e,t,r,a){if(!this.baseMaterial.isVisible()||null==this._octree)return;const s=d();l(s,a,r);const n=s=>{this._instanceData.getCombinedModelTransform(s,W),e.transform.set(W),h(K,r,e.transform.inverse),h(Y,a,e.transform.inverse);const n=this._instanceData.getState(s),i=this._instanceData.getLodLevel(s),o=this._levels.length;D(0!=(n&T.ACTIVE),"invalid instance state"),D(i>=0&&i<o,"invaid lod level"),this._levels[i].intersect(e,t,K,Y,s,this.metadata,o)};this.baseMaterial.parameters.verticalOffset?this._octree.forEach(n):this._octree.forEachAlongRay(r,s,n)}notifyShaderTransformationChanged(){this._invalidateOctree(),this._requestUpdateCycle()}get _octree(){if(null==this._octreeCached){const e=this._instanceData,t=e.view?.state;if(!t)return null;this._octreeCached=new L(e,this.baseBoundingSphere);for(let r=0;r<e.capacity;++r)t.get(r)&T.ACTIVE&&this._octreeCached.addInstance(r)}return this._octreeCached}_invalidateOctree(){this._octreeCached=r(this._octreeCached)}queryDepthRange(e){if(null==this._octree)return{near:1/0,far:-1/0};const t=e.viewForward,r=this._octree.findClosest(t,E.DepthOrder.FRONT_TO_BACK,e.frustum),a=this._octree.findClosest(t,E.DepthOrder.BACK_TO_FRONT,e.frustum);if(null==r||null==a)return{near:1/0,far:-1/0};const s=e.eye,n=this._instanceData.view;n.boundingSphere.getVec(r,k),l(k,k,s);const i=c(k,t)-k[3];n.boundingSphere.getVec(a,k),l(k,k,s);const o=c(k,t)+k[3];return{near:Math.max(e.near,i),far:Math.min(e.far,o)}}_requestUpdateCycle(e=!1){this._updateCyclesWithStaticCamera=-1,this._cycleStartIndex=this._instanceIndex,e&&(this._needFullCycle=!0,this._context.requestRender())}_startUpdateCycle(){this._updateCyclesWithStaticCamera++,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.startUpdateCycle()))))}get running(){return this._instanceData.size>0&&this._updateCyclesWithStaticCamera<1}runTask(e){const{_enableLevelSelection:t,_camera:r,_levelSelector:a}=this;this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.beginUpdate()))));const s=this._instanceData,n=s.view;let i=s.size;const o=s.capacity;let l=this._instanceIndex;const c=Math.ceil(o/500);for(let h=0;h<i&&!e.done;++h){l===this._cycleStartIndex&&this._startUpdateCycle();const h=n.state.get(l);let d=0;if(!(h&T.ALLOCATED)){l=l+1===o?0:l+1,i++;continue}const u=n.lodLevel.get(l);if(h&T.DEFAULT_ACTIVE&&this._defaultRenderInstanceData[0][u].freeTail(),h&T.HIGHLIGHT_ACTIVE&&this._highlightRenderInstanceData[0][u].freeTail(),h&T.REMOVE)s.freeInstance(l);else if(h&T.VISIBLE){let e=0;t&&(n.modelOrigin.getVec(l,z),e=a.selectLevel(z,s.getCombinedMedianScaleFactor(l),r)),d=h&~(T.ACTIVE|T.TRANSFORM_CHANGED),e>=0&&(h&T.HIGHLIGHT?(P(this._highlightRenderInstanceData[0][e],n,l),d|=T.HIGHLIGHT_ACTIVE):(P(this._defaultRenderInstanceData[0][e],n,l),d|=T.DEFAULT_ACTIVE)),n.state.set(l,d),n.lodLevel.set(l,e)}else d=h&~(T.ACTIVE|T.TRANSFORM_CHANGED),n.state.set(l,d);if(null!=this._octreeCached){const e=!!(h&T.ACTIVE),t=!!(d&T.ACTIVE);!e&&t?this._octreeCached.addInstance(l):e&&!t?this._octreeCached.removeInstance(l):e&&t&&h&T.TRANSFORM_CHANGED&&(this._octreeCached.removeInstance(l),this._octreeCached.addInstance(l))}l=l+1===o?0:l+1,l%c==0&&e.madeProgress()}this._instanceIndex=l,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.endUpdate())))),this._context.requestRender()}_beginComponent(e,t,r){if(0===t.size)return null;const a=r.glMaterials.load(e.rctx,e.bindParameters.slot,e.output);return null!=a?a.beginSlot(e.bindParameters):null}_renderComponent(e,t,r,a,s){if(!t)return;const{bindParameters:n,rctx:i}=e;i.runAppleAmdDriverHelper();const o=i.bindTechnique(t,n,a.material.parameters,Q);i.bindVAO(a.vao),t.ensureAttributeLocations(a.vao),f.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL&&e.output===g.Color&&(o.setUniform4fv("externalColor",J[Math.min(s,J.length-1)]),o.setUniform1i("colorMixMode",x.replace));const l=r.capacity,c=r.headIndex,h=r.tailIndex,d=r.firstIndex,u=this._glInstanceBufferLayout,m=(e,s)=>{F(i,y,r.buffer,u,e),i.drawArraysInstanced(t.primitiveType,0,a.vertexCount,s-e),H(i,y,r.buffer,u)};a.material.parameters.transparent&&null!=d?c>h?(D(d>=h&&d<=c,"invalid firstIndex"),m(d,c),m(h,d)):c<h&&(d<=c?(D(d>=0&&d<=c,"invalid firstIndex"),m(d,c),m(h,l),m(0,d)):(D(d>=h&&d<=l,"invalid firstIndex"),m(d,l),m(0,c),m(h,d))):c>h?m(h,c):c<h&&(m(0,c),m(h,l)),i.bindVAO(null)}};function P(e,t,r){const a=e.allocateHead();G(t,r,e.view,a)}function G(e,t,r,a){N(e.modelOrigin,t,r.modelOriginHi,r.modelOriginLo,a),r.model.copyFrom(a,e.model,t),r.modelNormal.copyFrom(a,e.modelNormal,t),e.color&&r.color&&r.color.copyFrom(a,e.color,t),e.objectAndLayerIdColor&&r.objectAndLayerIdColor&&r.objectAndLayerIdColor.copyFrom(a,e.objectAndLayerIdColor,t),e.featureAttribute&&r.featureAttribute&&r.featureAttribute.copyFrom(a,e.featureAttribute,t)}function q(e){let t=p().vec3f(b.INSTANCEMODELORIGINHI).vec3f(b.INSTANCEMODELORIGINLO).mat3f(b.INSTANCEMODEL).mat3f(b.INSTANCEMODELNORMAL);return null!=e&&e.includes("featureAttribute")&&(t=t.vec4f(b.INSTANCEFEATUREATTRIBUTE)),null!=e&&e.includes("color")&&(t=t.vec4u8(b.INSTANCECOLOR)),null!=e&&e.includes("objectAndLayerIdColor")&&(t=t.vec4u8(b.INSTANCEOBJECTANDLAYERIDCOLOR)),t}e([n({constructOnly:!0})],B.prototype,"symbol",void 0),e([n({constructOnly:!0})],B.prototype,"optionalFields",void 0),e([n({constructOnly:!0})],B.prototype,"metadata",void 0),e([n({constructOnly:!0})],B.prototype,"shaderTransformation",void 0),e([n()],B.prototype,"_instanceData",void 0),e([n()],B.prototype,"_cycleStartIndex",void 0),e([n({readOnly:!0})],B.prototype,"_enableLevelSelection",null),e([n()],B.prototype,"_updateCyclesWithStaticCamera",void 0),e([n({readOnly:!0})],B.prototype,"running",null),B=e([i("esri.views.3d.webgl-engine.lib.lodRendering.LodRenderer")],B);const z=d(),k=u(),W=o(),K=d(),Y=d(),J=[m(1,0,1,1),m(0,0,1,1),m(0,1,0,1),m(1,1,0,1),m(1,0,0,1)],Q=new M;export{B as LodRenderer};
|
|
@@ -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{normalFromMat4Legacy as t}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as r,transpose as e,copy as i,multiply as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as n,g as h,l as f,
|
|
5
|
+
import{normalFromMat4Legacy as t}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as r,transpose as e,copy as i,multiply as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as n,g as h,l as f,r as l,e as m}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{d as c,g as _}from"../../../../chunks/sphere.js";import{ViewingMode as u}from"../../../ViewingMode.js";import{Obb as g,computeOffsetObb as M}from"../../support/orientedBoundingBox.js";class v{constructor(){this._transform=a(),this._transformInverse=new b({value:this._transform},r,a),this._transformInverseTranspose=new b(this._transformInverse,e,a),this._transformTranspose=new b({value:this._transform},e,a),this._transformInverseRotation=new b({value:this._transform},t,s)}_invalidateLazyTransforms(){this._transformInverse.invalidate(),this._transformInverseTranspose.invalidate(),this._transformTranspose.invalidate(),this._transformInverseRotation.invalidate()}get transform(){return this._transform}get inverse(){return this._transformInverse.value}get inverseTranspose(){return this._transformInverseTranspose.value}get inverseRotation(){return this._transformInverseRotation.value}get transpose(){return this._transformTranspose.value}setTransformMatrix(t){i(this._transform,t)}multiplyTransform(t){o(this._transform,this._transform,t)}set(t){i(this._transform,t),this._invalidateLazyTransforms()}setAndInvalidateLazyTransforms(t,s){this.setTransformMatrix(t),this.multiplyTransform(s),this._invalidateLazyTransforms()}}class b{constructor(t,s,r){this._original=t,this._update=s,this._dirty=!0,this._transform=r()}invalidate(){this._dirty=!0}get value(){return this._dirty&&(this._update(this._transform,this._original.value),this._dirty=!1),this._transform}}class T{constructor(t=0){this.offset=t,this.tmpVertex=p()}applyToVertex(t,s,r){const e=n(q,t,s,r),i=h(z,e,this.localOrigin),o=this.offset/f(i);return l(this.tmpVertex,e,i,o),this.tmpVertex}applyToAabb(t){const s=A,r=R,e=B;for(let n=0;n<3;++n)s[n]=t[0+n]+this.localOrigin[n],r[n]=t[3+n]+this.localOrigin[n],e[n]=s[n];const i=this.applyToVertex(s[0],s[1],s[2]);for(let n=0;n<3;++n)t[n]=i[n],t[n+3]=i[n];const o=s=>{const r=this.applyToVertex(s[0],s[1],s[2]);for(let e=0;e<3;++e)t[e]=Math.min(t[e],r[e]),t[e+3]=Math.max(t[e+3],r[e])};for(let n=1;n<8;++n){for(let t=0;t<3;++t)e[t]=0==(n&1<<t)?s[t]:r[t];o(e)}let a=0;for(let n=0;n<3;++n){s[n]*r[n]<0&&(a|=1<<n)}if(0!==a&&7!==a)for(let n=0;n<8;++n)if(0==(a&n)){for(let t=0;t<3;++t)e[t]=0!=(a&1<<t)?0:0!=(n&1<<t)?s[t]:r[t];o(e)}for(let n=0;n<3;++n)t[n]-=this.localOrigin[n],t[n+3]-=this.localOrigin[n];return t}}class x{constructor(t=0){this.componentLocalOriginLength=0,this._totalOffset=0,this._offset=0,this._tmpVertex=p(),this._tmpMbs=c(),this._tmpObb=new g,this._resetOffset(t)}_resetOffset(t){this._offset=t,this._totalOffset=t}set offset(t){this._resetOffset(t)}get offset(){return this._offset}set componentOffset(t){this._totalOffset=this._offset+t}set localOrigin(t){this.componentLocalOriginLength=f(t)}applyToVertex(t,s,r){const e=n(q,t,s,r),i=n(z,t,s,r+this.componentLocalOriginLength),o=this._totalOffset/f(i);return l(this._tmpVertex,e,i,o),this._tmpVertex}applyToAabb(t){const s=this.componentLocalOriginLength,r=t[0],e=t[1],i=t[2]+s,o=t[3],a=t[4],n=t[5]+s,h=Math.abs(r),f=Math.abs(e),l=Math.abs(i),m=Math.abs(o),p=Math.abs(a),c=Math.abs(n),_=.5*(1+Math.sign(r*o))*Math.min(h,m),u=.5*(1+Math.sign(e*a))*Math.min(f,p),g=.5*(1+Math.sign(i*n))*Math.min(l,c),M=Math.max(h,m),v=Math.max(f,p),b=Math.max(l,c),T=Math.sqrt(_*_+u*u+g*g),x=Math.sign(h+r),O=Math.sign(f+e),y=Math.sign(l+i),d=Math.sign(m+o),V=Math.sign(p+a),L=Math.sign(c+n),j=this._totalOffset;if(T<j)return t[0]-=(1-x)*j,t[1]-=(1-O)*j,t[2]-=(1-y)*j,t[3]+=d*j,t[4]+=V*j,t[5]+=L*j,t;const I=j/Math.sqrt(M*M+v*v+b*b),w=j/T,q=w-I,z=-q;return t[0]+=r*(x*z+w),t[1]+=e*(O*z+w),t[2]+=i*(y*z+w),t[3]+=o*(d*q+I),t[4]+=a*(V*q+I),t[5]+=n*(L*q+I),t}applyToMbs(t){const s=f(_(t)),r=this._totalOffset/s;return l(_(this._tmpMbs),_(t),_(t),r),this._tmpMbs[3]=t[3]+t[3]*this._totalOffset/s,this._tmpMbs}applyToObb(t){return M(t,this._totalOffset,this._totalOffset,u.Global,this._tmpObb),this._tmpObb}}class O{constructor(t=0){this.offset=t,this.sphere=c(),this.tmpVertex=p()}applyToVertex(t,s,r){const e=this.objectTransform.transform,i=n(q,t,s,r),o=m(i,i,e),a=this.offset/f(o);l(o,o,o,a);const h=this.objectTransform.inverse;return m(this.tmpVertex,o,h),this.tmpVertex}applyToMinMax(t,s){const r=this.offset/f(t);l(t,t,t,r);const e=this.offset/f(s);l(s,s,s,e)}applyToAabb(t){const s=this.offset/Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]+=t[0]*s,t[1]+=t[1]*s,t[2]+=t[2]*s;const r=this.offset/Math.sqrt(t[3]*t[3]+t[4]*t[4]+t[5]*t[5]);return t[3]+=t[3]*r,t[4]+=t[4]*r,t[5]+=t[5]*r,t}applyToBoundingSphere(t){const s=f(_(t)),r=this.offset/s;return l(_(this.sphere),_(t),_(t),r),this.sphere[3]=t[3]+t[3]*this.offset/s,this.sphere}}const y=new O;function d(t){return null!=t?(y.offset=t,y):null}const V=new x;function L(t){return null!=t?(V.offset=t,V):null}const j=new T;function I(t){return null!=t?(j.offset=t,j):null}const w="terrain",q=p(),z=p(),A=p(),R=p(),B=p();export{x as I3SVerticalOffsetGlobalViewingMode,v as IntersectorTransform,O as Object3DVerticalOffsetGlobalViewingMode,T as TerrainVerticalOffsetGlobalViewingMode,L as getVerticalOffsetI3S,d as getVerticalOffsetObject3D,I as getVerticalOffsetTerrain,w as terrainId};
|
|
@@ -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{lerp as i}from"../../../../core/mathUtils.js";import{c as t,h as s,g as h,
|
|
5
|
+
import{lerp as i}from"../../../../core/mathUtils.js";import{c as t,h as s,g as h,m as r}from"../../../../chunks/vec32.js";import{create as n,fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{SphericalHarmonicsAmbientLight as o,MainLight as e}from"./Lightsources.js";import{combineLights as c}from"./SphericalHarmonics.js";class g{constructor(){this.color=n(),this.intensity=1}}class m{constructor(){this.direction=n(),this.ambient=new g,this.diffuse=new g}}const l=.4;class _{constructor(){this._shOrder=2,this._legacy=new m,this.globalFactor=.5,this.noonFactor=.5,this._sphericalHarmonics=new o,this._mainLight=new e(n(),a(1,0,0),!1)}get legacy(){return this._legacy}get sh(){return this._sphericalHarmonics}get mainLight(){return this._mainLight}set(i){c(i,this._shOrder,this._mainLight,this._sphericalHarmonics),t(this._legacy.direction,this._mainLight.direction);const r=1/Math.PI;this._legacy.ambient.color[0]=.282095*this._sphericalHarmonics.r[0]*r,this._legacy.ambient.color[1]=.282095*this._sphericalHarmonics.g[0]*r,this._legacy.ambient.color[2]=.282095*this._sphericalHarmonics.b[0]*r,s(this._legacy.diffuse.color,this._mainLight.intensity,r),t(L,this._legacy.diffuse.color),s(L,L,l*this.globalFactor),h(this._legacy.ambient.color,this._legacy.ambient.color,L)}copyFrom(i){this._sphericalHarmonics.r=Array.from(i.sh.r),this._sphericalHarmonics.g=Array.from(i.sh.g),this._sphericalHarmonics.b=Array.from(i.sh.b),t(this._mainLight.direction,i.mainLight.direction),t(this._mainLight.intensity,i.mainLight.intensity),this._mainLight.castShadows=i.mainLight.castShadows,this._mainLight.specularStrength=i.mainLight.specularStrength,this._mainLight.environmentStrength=i.mainLight.environmentStrength,this.globalFactor=i.globalFactor,this.noonFactor=i.noonFactor}lerpLighting(s,h,n){if(r(this._mainLight.intensity,s.mainLight.intensity,h.mainLight.intensity,n),this._mainLight.environmentStrength=i(s.mainLight.environmentStrength,h.mainLight.environmentStrength,n),this._mainLight.specularStrength=i(s.mainLight.specularStrength,h.mainLight.specularStrength,n),t(this._mainLight.direction,h.mainLight.direction),this._mainLight.castShadows=h.mainLight.castShadows,this.globalFactor=i(s.globalFactor,h.globalFactor,n),this.noonFactor=i(s.noonFactor,h.noonFactor,n),s.sh.r.length===h.sh.r.length)for(let t=0;t<h.sh.r.length;t++)this._sphericalHarmonics.r[t]=i(s.sh.r[t],h.sh.r[t],n),this._sphericalHarmonics.g[t]=i(s.sh.g[t],h.sh.g[t],n),this._sphericalHarmonics.b[t]=i(s.sh.b[t],h.sh.b[t],n);else for(let i=0;i<h.sh.r.length;i++)this._sphericalHarmonics.r[i]=h.sh.r[i],this._sphericalHarmonics.g[i]=h.sh.g[i],this._sphericalHarmonics.b[i]=h.sh.b[i]}}const L=n();export{_ as SceneLighting,m as SunLight,l as ambientBoost};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{clamp as t}from"../../../../core/mathUtils.js";import{
|
|
5
|
+
import{clamp as t}from"../../../../core/mathUtils.js";import{F as n,s as o,c as r}from"../../../../chunks/vec32.js";import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{elementwiseProduct as i,scalarProduct as s,add as c}from"../lib/LongVectorMath.js";import{MainLight as f,FillLight as h,AmbientLight as a,SphericalHarmonicsAmbientLight as g}from"./Lightsources.js";function u(t){return(t+1)*(t+1)}function l(n){return t(Math.floor(Math.sqrt(n)-1),0,2)}function m(t,n,o){const r=t[0],e=t[1],i=t[2],s=o||[];return s.length=u(n),n>=0&&(s[0]=.28209479177),n>=1&&(s[1]=.4886025119*r,s[2]=.4886025119*i,s[3]=.4886025119*e),n>=2&&(s[4]=1.09254843059*r*e,s[5]=1.09254843059*e*i,s[6]=.31539156525*(3*i*i-1),s[7]=1.09254843059*r*i,s[8]=.54627421529*(r*r-e*e)),s}function p(t,n){const o=u(t),r=n||{r:[],g:[],b:[]};r.r.length=r.g.length=r.b.length=o;for(let e=0;e<o;e++)r.r[e]=r.g[e]=r.b[e]=0;return r}function b(t,o){const r=l(o.r.length);for(const e of t)n(P,e.direction),m(P,r,v),i(v,w),s(v,e.intensity[0],I),c(o.r,I),s(v,e.intensity[1],I),c(o.g,I),s(v,e.intensity[2],I),c(o.b,I);return o}function y(t,n){m(P,0,v);for(const o of t)n.r[0]+=v[0]*w[0]*o.intensity[0]*4*Math.PI,n.g[0]+=v[0]*w[0]*o.intensity[1]*4*Math.PI,n.b[0]+=v[0]*w[0]*o.intensity[2]*4*Math.PI;return n}function M(t,n,e,i){p(n,i),o(e.intensity,0,0,0);let s=!1;const u=S,l=d,m=j;u.length=0,l.length=0,m.length=0;for(const o of t)o instanceof f&&!s?(r(e.direction,o.direction),r(e.intensity,o.intensity),e.specularStrength=o.specularStrength,e.environmentStrength=o.environmentStrength,e.castShadows=o.castShadows,s=!0):o instanceof f||o instanceof h?u.push(o):o instanceof a?l.push(o):o instanceof g&&m.push(o);b(u,i),y(l,i);for(const o of m)c(i.r,o.r),c(i.g,o.g),c(i.b,o.b)}const S=[],d=[],j=[],v=[0],I=[0],P=e(),w=[3.141593,2.094395,2.094395,2.094395,.785398,.785398,.785398,.785398,.785398];export{M as combineLights,m as computeCoefficients,p as initSHCoefficients,u as numberOfCoefficients,l as orderFromNumberOfCoefficients,y as projectAmbientLights,b as projectFillLights};
|
|
@@ -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{s as e,c as t,n as r,f as s,l as a,h as i,
|
|
5
|
+
import has from"../../../../core/has.js";import{s as e,c as t,n as r,f as s,l as a,h as i,k as o,t as n}from"../../../../chunks/vec32.js";import{create as h,fromValues as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ViewingMode as c}from"../../../ViewingMode.js";import{newLayout as u}from"../../support/buffer/InterleavedLayout.js";import{is3DGeometryOutput as m,isShadowRelatedOutput as p,ShaderOutput as f}from"../core/shaderLibrary/ShaderOutput.js";import{NormalType as d}from"../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{NormalsDoubleSidedMode as g}from"../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as T}from"../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{CullFaceOptions as _}from"../lib/basicInterfaces.js";import{GLTextureMaterial as x}from"../lib/GLTextureMaterial.js";import{Material as b}from"../lib/Material.js";import{OITPolygonOffsetLimit as v}from"../lib/OrderIndependentTransparency.js";import{RenderSlot as S}from"../lib/RenderSlot.js";import{VertexAttribute as O}from"../lib/VertexAttribute.js";import{getVerticalOffsetObject3D as w}from"../lib/verticalOffsetUtils.js";import{DefaultBufferWriter as M}from"./DefaultBufferWriter.js";import{verticalOffsetAtDistance as C,intersectTriangleGeometry as y}from"./internal/MaterialUtil.js";import{DefaultMaterialTechnique as A,DefaultMaterialPassParameters as R}from"../shaders/DefaultMaterialTechnique.js";import{DefaultMaterialTechniqueConfiguration as I}from"../shaders/DefaultMaterialTechniqueConfiguration.js";import{RealisticTreeTechnique as P}from"../shaders/RealisticTreeTechnique.js";class E extends b{constructor(e){super(e,D),this.supportsEdges=!0,this.produces=new Map([[S.OPAQUE_MATERIAL,e=>(m(e)||p(e))&&!this.parameters.transparent],[S.TRANSPARENT_MATERIAL,e=>(m(e)||p(e))&&this.parameters.transparent&&this.parameters.writeDepth],[S.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,e=>(m(e)||p(e))&&this.parameters.transparent&&!this.parameters.writeDepth]]),this._configuration=new I,this._vertexBufferLayout=N(this.parameters)}isVisibleForOutput(e){return e!==f.Shadow&&e!==f.ShadowExcludeHighlight&&e!==f.ShadowHighlight||this.parameters.castShadows}isVisible(){const e=this.parameters;if(!super.isVisible()||0===e.layerOpacity)return!1;const{hasInstancedColor:t,hasVertexColors:r,hasSymbolColors:s,vvColor:a}=e,i="replace"===e.colorMixMode,o=e.opacity>0,n=e.externalColor&&e.externalColor[3]>0,h=t||a||s;return r&&h?i||o:r?i?n:o:h?i||o:i?n:o}getConfiguration(e,t){return this._configuration.output=e,this._configuration.hasNormalTexture=!!this.parameters.normalTextureId,this._configuration.hasColorTexture=!!this.parameters.textureId,this._configuration.hasVertexTangents=this.parameters.hasVertexTangents,this._configuration.instanced=this.parameters.isInstanced,this._configuration.instancedDoublePrecision=this.parameters.instancedDoublePrecision,this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.hasVerticalOffset=null!=this.parameters.verticalOffset,this._configuration.hasScreenSizePerspective=null!=this.parameters.screenSizePerspective,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasSliceHighlight=this.parameters.hasSliceHighlight,this._configuration.alphaDiscardMode=this.parameters.textureAlphaMode,this._configuration.normalType=this.parameters.normalType,this._configuration.transparent=this.parameters.transparent,this._configuration.writeDepth=this.parameters.writeDepth,null!=this.parameters.customDepthTest&&(this._configuration.customDepthTest=this.parameters.customDepthTest),this._configuration.hasOccludees=this.parameters.hasOccludees,this._configuration.cullFace=this.parameters.hasSlicePlane?_.None:this.parameters.cullFace,this._configuration.multipassEnabled=t.multipassEnabled,this._configuration.cullAboveGround=t.multipassTerrain.cullAboveGround,this._configuration.hasModelTransformation=null!=this.parameters.modelTransformation,e!==f.Color&&e!==f.Alpha||(this._configuration.hasVertexColors=this.parameters.hasVertexColors,this._configuration.hasSymbolColors=this.parameters.hasSymbolColors,this.parameters.treeRendering?this._configuration.doubleSidedMode=g.WindingOrder:this._configuration.doubleSidedMode=this.parameters.doubleSided&&"normal"===this.parameters.doubleSidedType?g.View:this.parameters.doubleSided&&"winding-order"===this.parameters.doubleSidedType?g.WindingOrder:g.None,this._configuration.instancedColor=this.parameters.hasInstancedColor,this._configuration.receiveShadows=this.parameters.receiveShadows&&this.parameters.shadowMappingEnabled,this._configuration.receiveAmbientOcclusion=this.parameters.receiveAmbientOcclusion&&null!=t.ssao,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.textureAlphaPremultiplied=!!this.parameters.textureAlphaPremultiplied,this._configuration.pbrMode=this.parameters.usePBR?this.parameters.isSchematic?T.Schematic:T.Normal:T.Disabled,this._configuration.hasMetallicRoughnessTexture=!!this.parameters.metallicRoughnessTextureId,this._configuration.hasEmissionTexture=!!this.parameters.emissiveTextureId,this._configuration.hasOcclusionTexture=!!this.parameters.occlusionTextureId,this._configuration.offsetBackfaces=!(!this.parameters.transparent||!this.parameters.offsetTransparentBackfaces),this._configuration.transparencyPassType=t.transparencyPassType,this._configuration.enableOffset=t.camera.relativeElevation<v,this._configuration.snowCover=this.hasSnowCover(t),this._configuration.hasColorTextureTransform=!!this.parameters.colorTextureTransformMatrix,this._configuration.hasNormalTextureTransform=!!this.parameters.normalTextureTransformMatrix,this._configuration.hasEmissionTextureTransform=!!this.parameters.emissiveTextureTransformMatrix,this._configuration.hasOcclusionTextureTransform=!!this.parameters.occlusionTextureTransformMatrix,this._configuration.hasMetallicRoughnessTextureTransform=!!this.parameters.metallicRoughnessTextureTransformMatrix),this._configuration}hasSnowCover(e){return null!=e.weather&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}intersect(h,l,u,m,p,f){if(null!=this.parameters.verticalOffset){const h=u.camera;e(H,l[12],l[13],l[14]);let f=null;switch(u.viewingMode){case c.Global:f=r(G,H);break;case c.Local:f=t(G,z)}let d=0;const g=s(W,H,h.eye),T=a(g),_=i(g,g,1/T);let x=null;this.parameters.screenSizePerspective&&(x=o(f,_)),d+=C(h,T,this.parameters.verticalOffset,x??0,this.parameters.screenSizePerspective),i(f,f,d),n(k,f,u.transform.inverseRotation),m=s(V,m,k),p=s(B,p,k)}y(h,u,m,p,w(u.verticalOffset),f)}createGLMaterial(e){return new j(e)}createBufferWriter(){return new M(this._vertexBufferLayout)}}class j extends x{constructor(e){super({...e,...e.material.parameters})}_updateShadowState(e){e.shadowMap.enabled!==this._material.parameters.shadowMappingEnabled&&this._material.setParameters({shadowMappingEnabled:e.shadowMap.enabled})}_updateOccludeeState(e){e.hasOccludees!==this._material.parameters.hasOccludees&&this._material.setParameters({hasOccludees:e.hasOccludees})}beginSlot(t){this._output!==f.Color&&this._output!==f.Alpha||(this._updateShadowState(t),this._updateOccludeeState(t));const r=this._material.parameters;this.updateTexture(r.textureId);const s=t.camera.viewInverseTransposeMatrix;return e(r.origin,s[3],s[7],s[11]),this._material.setParameters(this.textureBindParameters),this.ensureTechnique(r.treeRendering?P:A,t)}}class L extends R{constructor(){super(...arguments),this.initTextureTransparent=!1,this.treeRendering=!1,this.hasVertexTangents=!1}}const D=new L;function N(e){const t=u().vec3f(O.POSITION);e.normalType===d.Compressed?t.vec2i16(O.NORMALCOMPRESSED,{glNormalized:!0}):t.vec3f(O.NORMAL),e.hasVertexTangents&&t.vec4f(O.TANGENT);return(e.textureId||e.normalTextureId||e.metallicRoughnessTextureId||e.emissiveTextureId||e.occlusionTextureId)&&t.vec2f(O.UV0),e.hasVertexColors&&t.vec4u8(O.COLOR),e.hasSymbolColors&&t.vec4u8(O.SYMBOLCOLOR),has("enable-feature:objectAndLayerId-rendering")&&t.vec4u8(O.OBJECTANDLAYERIDCOLOR),t}const V=h(),B=h(),z=l(0,0,1),G=h(),k=h(),H=h(),W=h();export{j as DefaultGLMaterial,E as DefaultMaterial,L as DefaultMaterialParameters};
|
|
@@ -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 e}from"../../../../core/mathUtils.js";import{fromMat4 as t}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as s}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as n,e as o,n as l,f as c,h as f,c as p,l as u,p as m,t as h,j as d,g}from"../../../../chunks/vec32.js";import{create as S,fromValues as O}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromArray as b,create as A,fromValues as T}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMat4 as v}from"../../../../core/libs/gl-matrix-2/types/mat4.js";import{create as E}from"../../../../geometry/support/aaBoundingRect.js";import{BufferViewVec4u8 as I}from"../../../../geometry/support/buffer/BufferView.js";import{evaluateModelTransformScale as _}from"../../layers/support/FastSymbolUpdates.js";import{debugFlags as y}from"../../support/debugFlags.js";import{newLayout as R}from"../../support/buffer/InterleavedLayout.js";import{isColorAlphaHighlightOrOID as x,ShaderOutput as P}from"../core/shaderLibrary/ShaderOutput.js";import{HUDVerticalPixelOffset as C}from"../core/shaderLibrary/hud/HUD.glsl.js";import{GLTextureMaterial as D,GLTextureMaterialBindParameters as j}from"../lib/GLTextureMaterial.js";import{Material as L,RenderOccludedFlag as N}from"../lib/Material.js";import{RenderSlot as U}from"../lib/RenderSlot.js";import{applyScaleFactor as w,applyPrecomputedScaleFactor as F,precomputeScaleFactor as M}from"../lib/screenSizePerspectiveUtils.js";import{assert as z}from"../lib/Util.js";import{VertexAttribute as V}from"../lib/VertexAttribute.js";import{ScaleInfo as B}from"./ScaleInfo.js";import{writePosition as G,writeNormal as W,writeColor as q,writeBufferVec4 as H,writeBufferVec4Zeros as X,writeObjectAndLayerIdColor as Y}from"./internal/bufferWriterUtils.js";import{verticalOffsetAtDistance as Z}from"./internal/MaterialUtil.js";import{c as k}from"../../../../chunks/HUDMaterial.glsl.js";import{HUDMaterialTechnique as J}from"../shaders/HUDMaterialTechnique.js";import{HUDMaterialTechniqueConfiguration as K}from"../shaders/HUDMaterialTechniqueConfiguration.js";class Q extends L{constructor(e){super(e,new Ae),this._configuration=new K,this.produces=new Map([[U.HUD_MATERIAL,e=>x(e)&&!this.parameters.drawInSecondSlot],[U.LABEL_MATERIAL,e=>x(e)&&this.parameters.drawInSecondSlot],[U.OCCLUSION_PIXELS,()=>this.parameters.occlusionTest],[U.DRAPED_MATERIAL,e=>x(e)]])}getConfiguration(e,t){return this._configuration.output=e,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasVerticalOffset=!!this.parameters.verticalOffset,this._configuration.hasScreenSizePerspective=!!this.parameters.screenSizePerspective,this._configuration.screenCenterOffsetUnitsEnabled="screen"===this.parameters.centerOffsetUnits,this._configuration.hasPolygonOffset=this.parameters.polygonOffset,this._configuration.draped=this.parameters.draped,this._configuration.occlusionTestEnabled=this.parameters.occlusionTest,this._configuration.pixelSnappingEnabled=this.parameters.pixelSnappingEnabled,this._configuration.signedDistanceFieldEnabled=this.parameters.textureIsSignedDistanceField,this._configuration.sampleSignedDistanceFieldTexelCenter=this.parameters.sampleSignedDistanceFieldTexelCenter,this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.occlusionPass=t.slot===U.OCCLUSION_PIXELS&&this.parameters.occlusionTest,e===P.Color&&(this._configuration.debugDrawLabelBorder=!!y.LABELS_SHOW_BORDER),this._configuration.depthEnabled=this.parameters.depthEnabled,this._configuration.transparencyPassType=t.transparencyPassType,this._configuration.multipassEnabled=t.multipassEnabled,this._configuration.cullAboveGround=t.multipassTerrain.cullAboveGround,this._configuration}intersect(e,r,i,a,h,d){if(!(i.options.selectionMode&&i.options.hud&&e.visible&&i.point))return;const g=this.parameters,O=i.point,b=i.camera;let{scaleX:A,scaleY:T}=this._getScreenScale(e);A*=b.pixelRatio,T*=b.pixelRatio,t(ce,r),e.attributes.has(V.FEATUREATTRIBUTE)&&te(ce);const v=e.attributes.get(V.POSITION),E=e.attributes.get(V.SIZE),I=e.attributes.get(V.NORMAL),_=e.attributes.get(V.CENTEROFFSETANDDISTANCE);z(v.size>=3);const y=k(g),R="screen"===this.parameters.centerOffsetUnits;for(let t=0;t<v.data.length/v.size;t++){const e=t*v.size;n(ie,v.data[e],v.data[e+1],v.data[e+2]),o(ie,ie,r);const a=t*E.size;Oe[0]=E.data[a]*A,Oe[1]=E.data[a+1]*T,o(ie,ie,b.viewMatrix);const h=t*_.size;if(n(ue,_.data[h],_.data[h+1],_.data[h+2]),!R&&(ie[0]+=ue[0],ie[1]+=ue[1],0!==ue[2])){const e=ue[2];l(ue,ie),c(ie,ie,f(ue,ue,e))}const x=t*I.size;if(n(ae,I.data[x],I.data[x+1],I.data[x+2]),this._normalAndViewAngle(ae,ce,b,de),this._applyVerticalOffsetTransformationView(ie,de,b,se),b.applyProjection(ie,ne),ne[0]>-1){R&&(ue[0]||ue[1])&&(ne[0]+=ue[0]*b.pixelRatio,0!==ue[1]&&(ne[1]+=w(ue[1],se.factorAlignment)*b.pixelRatio),b.unapplyProjection(ne,ie)),ne[0]+=this.parameters.screenOffset[0]*b.pixelRatio,ne[1]+=this.parameters.screenOffset[1]*b.pixelRatio,ne[0]=Math.floor(ne[0]),ne[1]=Math.floor(ne[1]),F(Oe,se.factor,Oe);const e=ge*b.pixelRatio;let t=0;if(g.textureIsSignedDistanceField&&(t=g.outlineSize*b.pixelRatio/2),re(O,ne[0],ne[1],Oe,e,t,g,y)){const e=i.ray;if(o(le,ie,s(pe,b.viewMatrix)),ne[0]=O[0],ne[1]=O[1],b.unprojectFromRenderScreen(ne,ie)){const t=S();p(t,e.direction);const r=1/u(t);f(t,t,r);d(m(e.origin,ie)*r,t,-1,!0,1,le)}}}}}intersectDraped(e,t,r,s,i,a){const n=e.attributes.get(V.POSITION),o=e.attributes.get(V.SIZE),l=this.parameters,c=k(l);let{scaleX:f,scaleY:p}=this._getScreenScale(e);f*=e.screenToWorldRatio,p*=e.screenToWorldRatio;const u=Se*e.screenToWorldRatio;for(let m=0;m<n.data.length/n.size;m++){const t=m*n.size,r=n.data[t],h=n.data[t+1],d=m*o.size;Oe[0]=o.data[d]*f,Oe[1]=o.data[d+1]*p;let g=0;l.textureIsSignedDistanceField&&(g=l.outlineSize*e.screenToWorldRatio/2),re(s,r,h,Oe,u,g,l,c)&&i(a.dist,a.normal,-1,!1)}}createBufferWriter(){return new Ee(this)}_normalAndViewAngle(e,r,s,i){return v(r)&&(r=t(fe,r)),h(i.normal,e,r),o(i.normal,i.normal,s.viewInverseTransposeMatrix),i.cosAngle=d(oe,be),i}_updateScaleInfo(e,t,r){const s=this.parameters;null!=s.screenSizePerspective?M(r,t,s.screenSizePerspective,e.factor):(e.factor.scale=1,e.factor.factor=0,e.factor.minScaleFactor=0),null!=s.screenSizePerspectiveAlignment?M(r,t,s.screenSizePerspectiveAlignment,e.factorAlignment):(e.factorAlignment.factor=e.factor.factor,e.factorAlignment.scale=e.factor.scale,e.factorAlignment.minScaleFactor=e.factor.minScaleFactor)}applyShaderOffsetsView(e,t,r,s,i,a,n){const o=this._normalAndViewAngle(t,r,i,de);return this._applyVerticalGroundOffsetView(e,o,i,n),this._applyVerticalOffsetTransformationView(n,o,i,a),this._applyPolygonOffsetView(n,o,s[3],i,n),this._applyCenterOffsetView(n,s,n),n}applyShaderOffsetsNDC(e,t,r,s,i){return this._applyCenterOffsetNDC(e,t,r,s),null!=i&&p(i,s),this._applyPolygonOffsetNDC(s,t,r,s),s}_applyPolygonOffsetView(t,r,s,i,a){const n=i.aboveGround?1:-1;let o=Math.sign(s);0===o&&(o=n);const l=n*o;if(this.parameters.shaderPolygonOffset<=0)return p(a,t);const c=e(Math.abs(r.cosAngle),.01,1),u=1-Math.sqrt(1-c*c)/c/i.viewport[2];return f(a,t,l>0?u:1/u),a}_applyVerticalGroundOffsetView(e,t,r,s){const i=u(e),a=r.aboveGround?1:-1,n=r.computeRenderPixelSizeAtDist(i)*C,o=f(ie,t.normal,a*n);return g(s,e,o),s}_applyVerticalOffsetTransformationView(e,t,r,s){const i=this.parameters;if(!i.verticalOffset?.screenLength){if(i.screenSizePerspective||i.screenSizePerspectiveAlignment){const r=u(e);this._updateScaleInfo(s,r,t.cosAngle)}else s.factor.scale=1,s.factorAlignment.scale=1;return e}const a=u(e),n=i.screenSizePerspectiveAlignment??i.screenSizePerspective,o=Z(r,a,i.verticalOffset,t.cosAngle,n);return this._updateScaleInfo(s,a,t.cosAngle),f(t.normal,t.normal,o),g(e,e,t.normal)}_applyCenterOffsetView(e,t,r){const s="screen"!==this.parameters.centerOffsetUnits;return r!==e&&p(r,e),s&&(r[0]+=t[0],r[1]+=t[1],t[2]&&(l(ae,r),g(r,r,f(ae,ae,t[2])))),r}_applyCenterOffsetNDC(e,t,r,s){const i="screen"!==this.parameters.centerOffsetUnits;return s!==e&&p(s,e),i||(s[0]+=t[0]/r.fullWidth*2,s[1]+=t[1]/r.fullHeight*2),s}_applyPolygonOffsetNDC(e,t,r,s){const i=this.parameters.shaderPolygonOffset;if(e!==s&&p(s,e),i){const e=r.aboveGround?1:-1,a=e*Math.sign(t[3]);s[2]-=(a||e)*i}return s}createGLMaterial(e){return new $(e)}calculateRelativeScreenBounds(e,t,r=E()){return ee(this.parameters,e,t,r),r[2]=r[0]+e[0],r[3]=r[1]+e[1],r}_getScreenScale(e){const t=e.attributes.get(V.FEATUREATTRIBUTE);if(null==t)return{scaleX:1,scaleY:1};const r=b(t.data,he),[s,i]=_(me,this.parameters,r);return{scaleX:s,scaleY:i}}}class $ extends D{constructor(e){super({...e,...e.material.parameters})}selectProgram(e){return this.ensureTechnique(J,e)}beginSlot(e){return this.updateTexture(this._material.parameters.textureId),this._material.setParameters(this.textureBindParameters),this.selectProgram(e)}}function ee(e,t,r,s){s[0]=e.anchorPosition[0]*-t[0]+e.screenOffset[0]*r,s[1]=e.anchorPosition[1]*-t[1]+e.screenOffset[1]*r}function te(e){const t=e[0],r=e[1],s=e[2],i=e[3],a=e[4],n=e[5],o=e[6],l=e[7],c=e[8],f=1/Math.sqrt(t*t+r*r+s*s),p=1/Math.sqrt(i*i+a*a+n*n),u=1/Math.sqrt(o*o+l*l+c*c);return e[0]=t*f,e[1]=r*f,e[2]=s*f,e[3]=i*p,e[4]=a*p,e[5]=n*p,e[6]=o*u,e[7]=l*u,e[8]=c*u,e}function re(e,t,r,s,i,a,n,o){let l=t-i-(o[0]>0?s[0]*o[0]:0),c=l+s[0]+2*i,f=r-i-(o[1]>0?s[1]*o[1]:0),p=f+s[1]+2*i;const u=n.distanceFieldBoundingBox;return n.textureIsSignedDistanceField&&null!=u&&(l+=s[0]*u[0],f+=s[1]*u[1],c-=s[0]*(1-u[2]),p-=s[1]*(1-u[3]),l-=a,c+=a,f-=a,p+=a),e[0]>l&&e[0]<c&&e[1]>f&&e[1]<p}const se=new B,ie=S(),ae=S(),ne=A(),oe=S(),le=S(),ce=r(),fe=r(),pe=i(),ue=S(),me=S(),he=A(),de={normal:oe,cosAngle:0},ge=1,Se=2,Oe=[0,0],be=O(0,0,1);class Ae extends j{constructor(){super(...arguments),this.renderOccluded=N.Occlude,this.isDecoration=!1,this.color=T(1,1,1,1),this.texCoordScale=[1,1],this.polygonOffset=!1,this.anchorPosition=a(.5,.5),this.screenOffset=[0,0],this.shaderPolygonOffset=1e-5,this.textureIsSignedDistanceField=!1,this.sampleSignedDistanceFieldTexelCenter=!1,this.outlineColor=T(1,1,1,1),this.outlineSize=0,this.vvSizeEnabled=!1,this.vvSize=null,this.vvColor=null,this.vvOpacity=null,this.vvSymbolAnchor=null,this.vvSymbolRotationMatrix=null,this.hasSlicePlane=!1,this.pixelSnappingEnabled=!0,this.occlusionTest=!0,this.centerOffsetUnits="world",this.drawInSecondSlot=!1,this.depthEnabled=!0,this.draped=!1}}const Te=R().vec3f(V.POSITION).vec3f(V.NORMAL).vec2f(V.UV0).vec4u8(V.COLOR).vec2f(V.SIZE).vec4f(V.CENTEROFFSETANDDISTANCE).vec4f(V.FEATUREATTRIBUTE),ve=Te.clone().vec4u8(V.OBJECTANDLAYERIDCOLOR);class Ee{constructor(e){this._material=e,this.vertexBufferLayout=has("enable-feature:objectAndLayerId-rendering")?ve:Te}elementCount(e){return 6*e.attributes.get(V.POSITION).indices.length}write(e,t,r,s,i){G(r.attributes.get(V.POSITION),e,s.position,i,6),W(r.attributes.get(V.NORMAL),t,s.normal,i,6);const a=r.attributes.get(V.UV0).data;let n,o,l,c;if(null==a||a.length<4){const e=this._material.parameters;n=0,o=0,l=e.texCoordScale[0],c=e.texCoordScale[1]}else n=a[0],o=a[1],l=a[2],c=a[3];l=Math.min(1.99999,l+1),c=Math.min(1.99999,c+1);let f=r.attributes.get(V.POSITION).indices.length,p=i;const u=s.uv0;for(let g=0;g<f;++g)u.set(p,0,n),u.set(p,1,o),p++,u.set(p,0,l),u.set(p,1,o),p++,u.set(p,0,l),u.set(p,1,c),p++,u.set(p,0,l),u.set(p,1,c),p++,u.set(p,0,n),u.set(p,1,c),p++,u.set(p,0,n),u.set(p,1,o),p++;q(r.attributes.get(V.COLOR),4,s.color,i,6);const{data:m,indices:h}=r.attributes.get(V.SIZE);f=h.length;const d=s.size;p=i;for(let g=0;g<f;++g){const e=m[2*h[g]],t=m[2*h[g]+1];for(let r=0;r<6;++r)d.set(p,0,e),d.set(p,1,t),p++}if(r.attributes.get(V.CENTEROFFSETANDDISTANCE)?H(r.attributes.get(V.CENTEROFFSETANDDISTANCE),s.centerOffsetAndDistance,i,6):X(s.centerOffsetAndDistance,i,6*f),r.attributes.get(V.FEATUREATTRIBUTE)?H(r.attributes.get(V.FEATUREATTRIBUTE),s.featureAttribute,i,6):X(s.featureAttribute,i,6*f),null!=r.objectAndLayerIdColor){const e=r.attributes.get(V.POSITION)?.indices;if(e){const t=e.length,a=s.getField(V.OBJECTANDLAYERIDCOLOR,I);Y(r.objectAndLayerIdColor,a,t,i,6)}}}}export{Q as HUDMaterial,Ae as Parameters};
|
|
5
|
+
import has from"../../../../core/has.js";import{clamp as e}from"../../../../core/mathUtils.js";import{fromMat4 as t}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as s}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as n,e as o,n as l,f as c,h as f,c as p,l as u,q as m,t as h,k as d,g}from"../../../../chunks/vec32.js";import{create as S,fromValues as O}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromArray as b,create as A,fromValues as T}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMat4 as v}from"../../../../core/libs/gl-matrix-2/types/mat4.js";import{create as E}from"../../../../geometry/support/aaBoundingRect.js";import{BufferViewVec4u8 as I}from"../../../../geometry/support/buffer/BufferView.js";import{evaluateModelTransformScale as _}from"../../layers/support/FastSymbolUpdates.js";import{debugFlags as y}from"../../support/debugFlags.js";import{newLayout as R}from"../../support/buffer/InterleavedLayout.js";import{isColorAlphaHighlightOrOID as x,ShaderOutput as P}from"../core/shaderLibrary/ShaderOutput.js";import{HUDVerticalPixelOffset as C}from"../core/shaderLibrary/hud/HUD.glsl.js";import{GLTextureMaterial as D,GLTextureMaterialBindParameters as j}from"../lib/GLTextureMaterial.js";import{Material as L,RenderOccludedFlag as N}from"../lib/Material.js";import{RenderSlot as U}from"../lib/RenderSlot.js";import{applyScaleFactor as w,applyPrecomputedScaleFactor as F,precomputeScaleFactor as M}from"../lib/screenSizePerspectiveUtils.js";import{assert as z}from"../lib/Util.js";import{VertexAttribute as V}from"../lib/VertexAttribute.js";import{ScaleInfo as B}from"./ScaleInfo.js";import{writePosition as G,writeNormal as q,writeColor as W,writeBufferVec4 as H,writeBufferVec4Zeros as X,writeObjectAndLayerIdColor as Y}from"./internal/bufferWriterUtils.js";import{verticalOffsetAtDistance as Z}from"./internal/MaterialUtil.js";import{c as k}from"../../../../chunks/HUDMaterial.glsl.js";import{HUDMaterialTechnique as J}from"../shaders/HUDMaterialTechnique.js";import{HUDMaterialTechniqueConfiguration as K}from"../shaders/HUDMaterialTechniqueConfiguration.js";class Q extends L{constructor(e){super(e,new Ae),this._configuration=new K,this.produces=new Map([[U.HUD_MATERIAL,e=>x(e)&&!this.parameters.drawInSecondSlot],[U.LABEL_MATERIAL,e=>x(e)&&this.parameters.drawInSecondSlot],[U.OCCLUSION_PIXELS,()=>this.parameters.occlusionTest],[U.DRAPED_MATERIAL,e=>x(e)]])}getConfiguration(e,t){return this._configuration.output=e,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasVerticalOffset=!!this.parameters.verticalOffset,this._configuration.hasScreenSizePerspective=!!this.parameters.screenSizePerspective,this._configuration.screenCenterOffsetUnitsEnabled="screen"===this.parameters.centerOffsetUnits,this._configuration.hasPolygonOffset=this.parameters.polygonOffset,this._configuration.draped=this.parameters.draped,this._configuration.occlusionTestEnabled=this.parameters.occlusionTest,this._configuration.pixelSnappingEnabled=this.parameters.pixelSnappingEnabled,this._configuration.signedDistanceFieldEnabled=this.parameters.textureIsSignedDistanceField,this._configuration.sampleSignedDistanceFieldTexelCenter=this.parameters.sampleSignedDistanceFieldTexelCenter,this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.occlusionPass=t.slot===U.OCCLUSION_PIXELS&&this.parameters.occlusionTest,e===P.Color&&(this._configuration.debugDrawLabelBorder=!!y.LABELS_SHOW_BORDER),this._configuration.depthEnabled=this.parameters.depthEnabled,this._configuration.transparencyPassType=t.transparencyPassType,this._configuration.multipassEnabled=t.multipassEnabled,this._configuration.cullAboveGround=t.multipassTerrain.cullAboveGround,this._configuration}intersect(e,r,i,a,h,d){if(!(i.options.selectionMode&&i.options.hud&&e.visible&&i.point))return;const g=this.parameters,O=i.point,b=i.camera;let{scaleX:A,scaleY:T}=this._getScreenScale(e);A*=b.pixelRatio,T*=b.pixelRatio,t(ce,r),e.attributes.has(V.FEATUREATTRIBUTE)&&te(ce);const v=e.attributes.get(V.POSITION),E=e.attributes.get(V.SIZE),I=e.attributes.get(V.NORMAL),_=e.attributes.get(V.CENTEROFFSETANDDISTANCE);z(v.size>=3);const y=k(g),R="screen"===this.parameters.centerOffsetUnits;for(let t=0;t<v.data.length/v.size;t++){const e=t*v.size;n(ie,v.data[e],v.data[e+1],v.data[e+2]),o(ie,ie,r);const a=t*E.size;Oe[0]=E.data[a]*A,Oe[1]=E.data[a+1]*T,o(ie,ie,b.viewMatrix);const h=t*_.size;if(n(ue,_.data[h],_.data[h+1],_.data[h+2]),!R&&(ie[0]+=ue[0],ie[1]+=ue[1],0!==ue[2])){const e=ue[2];l(ue,ie),c(ie,ie,f(ue,ue,e))}const x=t*I.size;if(n(ae,I.data[x],I.data[x+1],I.data[x+2]),this._normalAndViewAngle(ae,ce,b,de),this._applyVerticalOffsetTransformationView(ie,de,b,se),b.applyProjection(ie,ne),ne[0]>-1){R&&(ue[0]||ue[1])&&(ne[0]+=ue[0]*b.pixelRatio,0!==ue[1]&&(ne[1]+=w(ue[1],se.factorAlignment)*b.pixelRatio),b.unapplyProjection(ne,ie)),ne[0]+=this.parameters.screenOffset[0]*b.pixelRatio,ne[1]+=this.parameters.screenOffset[1]*b.pixelRatio,ne[0]=Math.floor(ne[0]),ne[1]=Math.floor(ne[1]),F(Oe,se.factor,Oe);const e=ge*b.pixelRatio;let t=0;if(g.textureIsSignedDistanceField&&(t=g.outlineSize*b.pixelRatio/2),re(O,ne[0],ne[1],Oe,e,t,g,y)){const e=i.ray;if(o(le,ie,s(pe,b.viewMatrix)),ne[0]=O[0],ne[1]=O[1],b.unprojectFromRenderScreen(ne,ie)){const t=S();p(t,e.direction);const r=1/u(t);f(t,t,r);d(m(e.origin,ie)*r,t,-1,!0,1,le)}}}}}intersectDraped(e,t,r,s,i,a){const n=e.attributes.get(V.POSITION),o=e.attributes.get(V.SIZE),l=this.parameters,c=k(l);let{scaleX:f,scaleY:p}=this._getScreenScale(e);f*=e.screenToWorldRatio,p*=e.screenToWorldRatio;const u=Se*e.screenToWorldRatio;for(let m=0;m<n.data.length/n.size;m++){const t=m*n.size,r=n.data[t],h=n.data[t+1],d=m*o.size;Oe[0]=o.data[d]*f,Oe[1]=o.data[d+1]*p;let g=0;l.textureIsSignedDistanceField&&(g=l.outlineSize*e.screenToWorldRatio/2),re(s,r,h,Oe,u,g,l,c)&&i(a.dist,a.normal,-1,!1)}}createBufferWriter(){return new Ee(this)}_normalAndViewAngle(e,r,s,i){return v(r)&&(r=t(fe,r)),h(i.normal,e,r),o(i.normal,i.normal,s.viewInverseTransposeMatrix),i.cosAngle=d(oe,be),i}_updateScaleInfo(e,t,r){const s=this.parameters;null!=s.screenSizePerspective?M(r,t,s.screenSizePerspective,e.factor):(e.factor.scale=1,e.factor.factor=0,e.factor.minScaleFactor=0),null!=s.screenSizePerspectiveAlignment?M(r,t,s.screenSizePerspectiveAlignment,e.factorAlignment):(e.factorAlignment.factor=e.factor.factor,e.factorAlignment.scale=e.factor.scale,e.factorAlignment.minScaleFactor=e.factor.minScaleFactor)}applyShaderOffsetsView(e,t,r,s,i,a,n){const o=this._normalAndViewAngle(t,r,i,de);return this._applyVerticalGroundOffsetView(e,o,i,n),this._applyVerticalOffsetTransformationView(n,o,i,a),this._applyPolygonOffsetView(n,o,s[3],i,n),this._applyCenterOffsetView(n,s,n),n}applyShaderOffsetsNDC(e,t,r,s,i){return this._applyCenterOffsetNDC(e,t,r,s),null!=i&&p(i,s),this._applyPolygonOffsetNDC(s,t,r,s),s}_applyPolygonOffsetView(t,r,s,i,a){const n=i.aboveGround?1:-1;let o=Math.sign(s);0===o&&(o=n);const l=n*o;if(this.parameters.shaderPolygonOffset<=0)return p(a,t);const c=e(Math.abs(r.cosAngle),.01,1),u=1-Math.sqrt(1-c*c)/c/i.viewport[2];return f(a,t,l>0?u:1/u),a}_applyVerticalGroundOffsetView(e,t,r,s){const i=u(e),a=r.aboveGround?1:-1,n=r.computeRenderPixelSizeAtDist(i)*C,o=f(ie,t.normal,a*n);return g(s,e,o),s}_applyVerticalOffsetTransformationView(e,t,r,s){const i=this.parameters;if(!i.verticalOffset?.screenLength){if(i.screenSizePerspective||i.screenSizePerspectiveAlignment){const r=u(e);this._updateScaleInfo(s,r,t.cosAngle)}else s.factor.scale=1,s.factorAlignment.scale=1;return e}const a=u(e),n=i.screenSizePerspectiveAlignment??i.screenSizePerspective,o=Z(r,a,i.verticalOffset,t.cosAngle,n);return this._updateScaleInfo(s,a,t.cosAngle),f(t.normal,t.normal,o),g(e,e,t.normal)}_applyCenterOffsetView(e,t,r){const s="screen"!==this.parameters.centerOffsetUnits;return r!==e&&p(r,e),s&&(r[0]+=t[0],r[1]+=t[1],t[2]&&(l(ae,r),g(r,r,f(ae,ae,t[2])))),r}_applyCenterOffsetNDC(e,t,r,s){const i="screen"!==this.parameters.centerOffsetUnits;return s!==e&&p(s,e),i||(s[0]+=t[0]/r.fullWidth*2,s[1]+=t[1]/r.fullHeight*2),s}_applyPolygonOffsetNDC(e,t,r,s){const i=this.parameters.shaderPolygonOffset;if(e!==s&&p(s,e),i){const e=r.aboveGround?1:-1,a=e*Math.sign(t[3]);s[2]-=(a||e)*i}return s}createGLMaterial(e){return new $(e)}calculateRelativeScreenBounds(e,t,r=E()){return ee(this.parameters,e,t,r),r[2]=r[0]+e[0],r[3]=r[1]+e[1],r}_getScreenScale(e){const t=e.attributes.get(V.FEATUREATTRIBUTE);if(null==t)return{scaleX:1,scaleY:1};const r=b(t.data,he),[s,i]=_(me,this.parameters,r);return{scaleX:s,scaleY:i}}}class $ extends D{constructor(e){super({...e,...e.material.parameters})}selectProgram(e){return this.ensureTechnique(J,e)}beginSlot(e){return this.updateTexture(this._material.parameters.textureId),this._material.setParameters(this.textureBindParameters),this.selectProgram(e)}}function ee(e,t,r,s){s[0]=e.anchorPosition[0]*-t[0]+e.screenOffset[0]*r,s[1]=e.anchorPosition[1]*-t[1]+e.screenOffset[1]*r}function te(e){const t=e[0],r=e[1],s=e[2],i=e[3],a=e[4],n=e[5],o=e[6],l=e[7],c=e[8],f=1/Math.sqrt(t*t+r*r+s*s),p=1/Math.sqrt(i*i+a*a+n*n),u=1/Math.sqrt(o*o+l*l+c*c);return e[0]=t*f,e[1]=r*f,e[2]=s*f,e[3]=i*p,e[4]=a*p,e[5]=n*p,e[6]=o*u,e[7]=l*u,e[8]=c*u,e}function re(e,t,r,s,i,a,n,o){let l=t-i-(o[0]>0?s[0]*o[0]:0),c=l+s[0]+2*i,f=r-i-(o[1]>0?s[1]*o[1]:0),p=f+s[1]+2*i;const u=n.distanceFieldBoundingBox;return n.textureIsSignedDistanceField&&null!=u&&(l+=s[0]*u[0],f+=s[1]*u[1],c-=s[0]*(1-u[2]),p-=s[1]*(1-u[3]),l-=a,c+=a,f-=a,p+=a),e[0]>l&&e[0]<c&&e[1]>f&&e[1]<p}const se=new B,ie=S(),ae=S(),ne=A(),oe=S(),le=S(),ce=r(),fe=r(),pe=i(),ue=S(),me=S(),he=A(),de={normal:oe,cosAngle:0},ge=1,Se=2,Oe=[0,0],be=O(0,0,1);class Ae extends j{constructor(){super(...arguments),this.renderOccluded=N.Occlude,this.isDecoration=!1,this.color=T(1,1,1,1),this.texCoordScale=[1,1],this.polygonOffset=!1,this.anchorPosition=a(.5,.5),this.screenOffset=[0,0],this.shaderPolygonOffset=1e-5,this.textureIsSignedDistanceField=!1,this.sampleSignedDistanceFieldTexelCenter=!1,this.outlineColor=T(1,1,1,1),this.outlineSize=0,this.vvSizeEnabled=!1,this.vvSize=null,this.vvColor=null,this.vvOpacity=null,this.vvSymbolAnchor=null,this.vvSymbolRotationMatrix=null,this.hasSlicePlane=!1,this.pixelSnappingEnabled=!0,this.occlusionTest=!0,this.centerOffsetUnits="world",this.drawInSecondSlot=!1,this.depthEnabled=!0,this.draped=!1}}const Te=R().vec3f(V.POSITION).vec3f(V.NORMAL).vec2f(V.UV0).vec4u8(V.COLOR).vec2f(V.SIZE).vec4f(V.CENTEROFFSETANDDISTANCE).vec4f(V.FEATUREATTRIBUTE),ve=Te.clone().vec4u8(V.OBJECTANDLAYERIDCOLOR);class Ee{constructor(e){this._material=e,this.vertexBufferLayout=has("enable-feature:objectAndLayerId-rendering")?ve:Te}elementCount(e){return 6*e.attributes.get(V.POSITION).indices.length}write(e,t,r,s,i){G(r.attributes.get(V.POSITION),e,s.position,i,6),q(r.attributes.get(V.NORMAL),t,s.normal,i,6);const a=r.attributes.get(V.UV0).data;let n,o,l,c;if(null==a||a.length<4){const e=this._material.parameters;n=0,o=0,l=e.texCoordScale[0],c=e.texCoordScale[1]}else n=a[0],o=a[1],l=a[2],c=a[3];l=Math.min(1.99999,l+1),c=Math.min(1.99999,c+1);let f=r.attributes.get(V.POSITION).indices.length,p=i;const u=s.uv0;for(let g=0;g<f;++g)u.set(p,0,n),u.set(p,1,o),p++,u.set(p,0,l),u.set(p,1,o),p++,u.set(p,0,l),u.set(p,1,c),p++,u.set(p,0,l),u.set(p,1,c),p++,u.set(p,0,n),u.set(p,1,c),p++,u.set(p,0,n),u.set(p,1,o),p++;W(r.attributes.get(V.COLOR),4,s.color,i,6);const{data:m,indices:h}=r.attributes.get(V.SIZE);f=h.length;const d=s.size;p=i;for(let g=0;g<f;++g){const e=m[2*h[g]],t=m[2*h[g]+1];for(let r=0;r<6;++r)d.set(p,0,e),d.set(p,1,t),p++}if(r.attributes.get(V.CENTEROFFSETANDDISTANCE)?H(r.attributes.get(V.CENTEROFFSETANDDISTANCE),s.centerOffsetAndDistance,i,6):X(s.centerOffsetAndDistance,i,6*f),r.attributes.get(V.FEATUREATTRIBUTE)?H(r.attributes.get(V.FEATUREATTRIBUTE),s.featureAttribute,i,6):X(s.featureAttribute,i,6*f),null!=r.objectAndLayerIdColor){const e=r.attributes.get(V.POSITION)?.indices;if(e){const t=e.length,a=s.getField(V.OBJECTANDLAYERIDCOLOR,I);Y(r.objectAndLayerIdColor,a,t,i,6)}}}}export{Q as HUDMaterial,Ae as Parameters};
|
|
@@ -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 e,
|
|
5
|
+
import{s as e,G as t,e as r}from"../../../../chunks/vec32.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newLayout as i}from"../../support/buffer/InterleavedLayout.js";import{ShaderOutput as s,isColorOrAlpha as n,isColorAlphaHighlightOrDepth as o}from"../core/shaderLibrary/ShaderOutput.js";import{GLTextureMaterial as h}from"../lib/GLTextureMaterial.js";import{Material as c,RenderOccludedFlag as u}from"../lib/Material.js";import{RenderSlot as p}from"../lib/RenderSlot.js";import{VertexAttribute as l}from"../lib/VertexAttribute.js";import{VisualVariablePassParameters as m}from"./VisualVariablePassParameters.js";import{vertexAttributeLocations as d,LineMarkerTechnique as T}from"../shaders/LineMarkerTechnique.js";import{LineMarkerTechniqueConfiguration as _,LineMarkerSpace as f,LineMarkerAnchor as A}from"../shaders/LineMarkerTechniqueConfiguration.js";import{CapType as E}from"../shaders/RibbonLineTechniqueConfiguration.js";class v extends c{constructor(e){super(e,new S),this.produces=new Map([[p.OPAQUE_MATERIAL,e=>e===s.Highlight||n(e)&&this.parameters.renderOccluded===u.OccludeAndTransparentStencil],[p.OPAQUE_NO_SSAO_DEPTH,e=>e===s.LinearDepth],[p.OCCLUDER_MATERIAL,e=>o(e)&&this.parameters.renderOccluded===u.OccludeAndTransparentStencil],[p.TRANSPARENT_OCCLUDER_MATERIAL,e=>o(e)&&this.parameters.renderOccluded===u.OccludeAndTransparentStencil],[p.TRANSPARENT_MATERIAL,e=>n(e)&&this.parameters.writeDepth],[p.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,e=>n(e)&&!this.parameters.writeDepth],[p.DRAPED_MATERIAL,e=>e===s.Color||e===s.Highlight]]),this._vertexAttributeLocations=d,this._configuration=new _,this._layout=this.createLayout()}getConfiguration(e,t){return this._configuration.output=e,this._configuration.space=t.slot===p.DRAPED_MATERIAL?f.Draped:this.parameters.worldSpace?f.World:f.Screen,this._configuration.hideOnShortSegments=this.parameters.hideOnShortSegments,this._configuration.hasCap=this.parameters.cap!==E.BUTT,this._configuration.anchor=this.parameters.anchor,this._configuration.hasTip=this.parameters.hasTip,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasOccludees=this.parameters.hasOccludees,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.vvOpacity=!!this.parameters.vvOpacity,this._configuration.occluder=this.parameters.renderOccluded===u.OccludeAndTransparentStencil,this._configuration.transparencyPassType=t.transparencyPassType,this._configuration.multipassEnabled=t.multipassEnabled,this._configuration.cullAboveGround=t.multipassTerrain.cullAboveGround,this._configuration}intersect(){}createLayout(){const e=i().vec3f(l.POSITION).vec3f(l.PREVPOSITION).vec2f(l.UV0);return this.parameters.worldSpace&&e.vec3f(l.NORMAL),this.parameters.vvSize?e.f32(l.SIZEFEATUREATTRIBUTE):e.f32(l.SIZE),this.parameters.vvColor?e.f32(l.COLORFEATUREATTRIBUTE):e.vec4f(l.COLOR),this.parameters.vvOpacity&&e.f32(l.OPACITYFEATUREATTRIBUTE),e}createBufferWriter(){return new g(this._layout,this.parameters)}createGLMaterial(e){return new O(e)}}class O extends h{constructor(){super(...arguments),this._markerPrimitive=null}dispose(){super.dispose(),this._markerTextureRepository.release(this._markerPrimitive),this._markerPrimitive=null}_updateParameters(e){const t=this._material.parameters.markerPrimitive;return t!==this._markerPrimitive&&(this._material.setParameters({markerTexture:this._markerTextureRepository.swap(t,this._markerPrimitive)}),this._markerPrimitive=t),this._material.setParameters(this.textureBindParameters),this.ensureTechnique(T,e)}_updateOccludeeState(e){e.hasOccludees!==this._material.parameters.hasOccludees&&this._material.setParameters({hasOccludees:e.hasOccludees})}beginSlot(e){return this._output!==s.Color&&this._output!==s.Alpha||this._updateOccludeeState(e),this._updateParameters(e)}}class S extends m{constructor(){super(...arguments),this.width=0,this.color=[1,1,1,1],this.markerPrimitive="arrow",this.placement="end",this.cap=E.BUTT,this.anchor=A.Center,this.hasTip=!1,this.worldSpace=!1,this.hideOnShortSegments=!1,this.writeDepth=!0,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.hasOccludees=!1,this.markerTexture=null}}class g{constructor(e,t){this.vertexBufferLayout=e,this._parameters=t}elementCount(){return"begin-end"===this._parameters.placement?12:6}write(a,i,s,n,o){const h=s.attributes.get(l.POSITION).data,c=h.length/3;let u=[1,0,0];const p=s.attributes.get(l.NORMAL);this._parameters.worldSpace&&null!=p&&(u=p.data);let m=1,d=0;this._parameters.vvSize?d=s.attributes.get(l.SIZEFEATUREATTRIBUTE).data[0]:s.attributes.has(l.SIZE)&&(m=s.attributes.get(l.SIZE).data[0]);let T=[1,1,1,1],_=0;this._parameters.vvColor?_=s.attributes.get(l.COLORFEATUREATTRIBUTE).data[0]:s.attributes.has(l.COLOR)&&(T=s.attributes.get(l.COLOR).data);let f=0;this._parameters.vvOpacity&&(f=s.attributes.get(l.OPACITYFEATUREATTRIBUTE).data[0]);const A=new Float32Array(n.buffer);let E=o*(this.vertexBufferLayout.stride/4);const v=(e,t,r,a)=>{if(A[E++]=e[0],A[E++]=e[1],A[E++]=e[2],A[E++]=t[0],A[E++]=t[1],A[E++]=t[2],A[E++]=r[0],A[E++]=r[1],this._parameters.worldSpace&&(A[E++]=u[0],A[E++]=u[1],A[E++]=u[2]),this._parameters.vvSize?A[E++]=d:A[E++]=m,this._parameters.vvColor)A[E++]=_;else{const e=Math.min(4*a,T.length-4);A[E++]=T[e],A[E++]=T[e+1],A[E++]=T[e+2],A[E++]=T[e+3]}this._parameters.vvOpacity&&(A[E++]=f)};let O;!function(e){e[e.ASCENDING=1]="ASCENDING",e[e.DESCENDING=-1]="DESCENDING"}(O||(O={}));const S=(i,s)=>{const n=e(R,h[3*i],h[3*i+1],h[3*i+2]),o=P;let u=i+s;do{e(o,h[3*u],h[3*u+1],h[3*u+2]),u+=s}while(t(n,o)&&u>=0&&u<c);a&&(r(n,n,a),r(o,o,a)),v(n,o,[-1,-1],i),v(n,o,[1,-1],i),v(n,o,[1,1],i),v(n,o,[-1,-1],i),v(n,o,[1,1],i),v(n,o,[-1,1],i)},g=this._parameters.placement;"begin"!==g&&"begin-end"!==g||S(0,O.ASCENDING),"end"!==g&&"begin-end"!==g||S(c-1,O.DESCENDING)}}const R=a(),P=a();export{v as LineMarkerMaterial,S as Parameters};
|
|
@@ -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,n as e,f as r,b as s,
|
|
5
|
+
import{s as t,n as e,f as r,b as s,q as o,e as i}from"../../../../chunks/vec32.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{newLayout as c}from"../../support/buffer/InterleavedLayout.js";import{ShaderOutput as l}from"../core/shaderLibrary/ShaderOutput.js";import u from"../lib/GLMaterial.js";import{Material as p,MaterialParameters as f}from"../lib/Material.js";import{RenderSlot as h}from"../lib/RenderSlot.js";import{VertexAttribute as m}from"../lib/VertexAttribute.js";import{MeasurementArrowAttributeLocations as g,MeasurementArrowTechniqueConfiguration as d,MeasurementArrowTechnique as b}from"../shaders/MeasurementArrowTechnique.js";class A extends p{constructor(t){super(t,new _),this._vertexAttributeLocations=g,this.produces=new Map([[h.OPAQUE_MATERIAL,t=>!this._transparent&&(t===l.Color||t===l.Alpha)],[h.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,t=>this._transparent&&(t===l.Color||t===l.Alpha)]]),this._configuration=new d}getConfiguration(t,e){return this._configuration.polygonOffsetEnabled=this.parameters.polygonOffset,this._configuration.transparent=this._transparent,this._configuration.transparencyPassType=e.transparencyPassType,this._configuration}intersect(){}createGLMaterial(t){return new O(t)}createBufferWriter(){return new j}get _transparent(){const{parameters:t}=this;return t.outlineColor[3]<1||t.stripeEvenColor[3]<1||t.stripeOddColor[3]<1}}class O extends u{beginSlot(t){return this.ensureTechnique(b,t)}}class _ extends f{constructor(){super(...arguments),this.width=32,this.outlineSize=.2,this.outlineColor=a(1,.5,0,1),this.stripeEvenColor=a(1,1,1,1),this.stripeOddColor=a(1,.5,0,1),this.stripeLength=1,this.polygonOffset=!1}}const T=c().vec3f(m.POSITION).vec3f(m.NORMAL).vec2f(m.UV0).f32(m.LENGTH),L=n(),v=n(),E=n(),I=n(),M=n();class j{constructor(){this.vertexBufferLayout=T}elementCount(t){return 2*(t.attributes.get(m.POSITION).indices.length/2+1)}write(n,a,c,l,u){const{data:p,indices:f}=c.attributes.get(m.POSITION),h=c.attributes.get(m.NORMAL).data,g=p.length/3;f&&f.length!==2*(g-1)&&console.warn("MeasurementArrowMaterial does not support indices");const d=L,b=v,A=E,O=I,_=M,T=l.position,j=l.normal,w=l.uv0;let y=0;for(let m=0;m<g;++m){const c=3*m;if(t(d,p[c],p[c+1],p[c+2]),m<g-1){const o=3*(m+1);t(b,p[o],p[o+1],p[o+2]),t(_,h[o],h[o+1],h[o+2]),e(_,_),r(A,b,d),e(A,A),s(O,_,A),e(O,O)}const l=o(d,b);n&&a&&(i(d,d,n),i(b,b,n),i(O,O,a));const f=u+2*m,L=f+1;T.setVec(f,d),T.setVec(L,d),j.setVec(f,O),j.setVec(L,O),w.set(f,0,y),w.set(f,1,-1),w.set(L,0,y),w.set(L,1,1),m<g-1&&(y+=l)}const C=l.length;for(let t=0;t<2*g;++t)C.set(u+t,y)}}export{A as MeasurementArrowMaterial,_ as Parameters};
|