@arcgis/core 6.0.0-next.48 → 6.0.0-next.49
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/Ground.js +1 -1
- package/analysis/AreaMeasurementAnalysis.d.ts +12 -10
- package/analysis/AreaMeasurementAnalysis.js +1 -1
- package/applications/Components/formatUtils.d.ts +3 -2
- package/applications/MapViewer/templateUtils.d.ts +4 -1
- package/applications/SceneViewer/sceneViewerUtils.d.ts +12 -1
- package/applications/SceneViewer/sceneViewerUtils.js +1 -1
- package/arcade/featureset/actions/SpatialFilter.js +1 -1
- package/arcade/functions/featuresetgeom.js +1 -1
- package/arcade/functions/geomasync.js +1 -1
- package/arcade/geometry/operatorsWorker.js +1 -1
- package/arcade/geometry/operatorsWorkerConnection.js +1 -1
- package/arcgisGlobal.d.ts +4 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/063cc462524646cd45e8.js +1 -0
- package/assets/esri/core/workers/chunks/119c62e9c9c7440a6129.js +1 -0
- package/assets/esri/core/workers/chunks/14c04fde8d33b739b415.js +1 -0
- package/assets/esri/core/workers/chunks/27a91b52d1bee92b6f20.js +1 -0
- package/assets/esri/core/workers/chunks/31eb09e96f31bced71ad.js +1 -0
- package/assets/esri/core/workers/chunks/{056a815273653271bf75.js → 3236e18921955450fc0d.js} +5 -5
- package/assets/esri/core/workers/chunks/3ce7120056040af3bab1.js +1 -0
- package/assets/esri/core/workers/chunks/435dacf493aec07ff6e3.js +1 -0
- package/assets/esri/core/workers/chunks/4c26d6408ee7a3b9d163.js +1 -0
- package/assets/esri/core/workers/chunks/{73bf76a3a0418edb26a5.js → 506954fb374ea528d020.js} +1 -1
- package/assets/esri/core/workers/chunks/55db28616f810ca063b7.js +1 -0
- package/assets/esri/core/workers/chunks/59ae5bd0ee1bae7a9fb3.js +1 -0
- package/assets/esri/core/workers/chunks/630a36c4817f33f4cad2.js +1 -0
- package/assets/esri/core/workers/chunks/6779afc2d6ee46c301b5.js +1 -0
- package/assets/esri/core/workers/chunks/6a509ffb4852d694a097.js +1 -0
- package/assets/esri/core/workers/chunks/6d25a7071fceb707858a.js +1 -0
- package/assets/esri/core/workers/chunks/7a97eec9823941fd210f.js +29 -0
- package/assets/esri/core/workers/chunks/82bbf0c5e18fc1c795f4.js +1 -0
- package/assets/esri/core/workers/chunks/91019e9dff63107f8cb4.js +1 -0
- package/assets/esri/core/workers/chunks/{1345413ec0b4128849b1.js → 954f9854a9bf4a852b81.js} +1 -1
- package/assets/esri/core/workers/chunks/9846abf2d3991a15b2b5.js +1 -0
- package/assets/esri/core/workers/chunks/9f74b3f0f453bc957e3a.js +1 -0
- package/assets/esri/core/workers/chunks/a0e2a1c6f37454547193.js +1 -0
- package/assets/esri/core/workers/chunks/a1c45e8f5bba471b3905.js +1 -0
- package/assets/esri/core/workers/chunks/a2825285d46f8cd5d814.js +1 -0
- package/assets/esri/core/workers/chunks/{d4f6be8290ad0243e1b8.js → b511b5c68defefccde0b.js} +1 -1
- package/assets/esri/core/workers/chunks/bf81b3670b5323621e2d.js +1 -0
- package/assets/esri/core/workers/chunks/c4794d692934098988e7.js +1 -0
- package/assets/esri/core/workers/chunks/d0900a901197948bd7df.js +1 -0
- package/assets/esri/core/workers/chunks/d2ed93bbfa98395bbed7.js +1 -0
- package/assets/esri/core/workers/chunks/d486a8a61ff993f8202a.js +1 -0
- package/assets/esri/core/workers/chunks/e06036392a982dbf3ae3.js +1 -0
- package/assets/esri/core/workers/chunks/{773ba0909ccd3a034c31.js → ed1db6571b0c61fe4f91.js} +1 -1
- package/chunks/BlendWeights.glsl.js +4 -5
- package/chunks/Blur.glsl.js +10 -7
- package/chunks/BlurEmission.glsl.js +27 -7
- package/chunks/Clouds.glsl.js +2 -2
- package/chunks/Component.glsl.js +1 -1
- package/chunks/EdgeDetect.glsl.js +1 -1
- package/chunks/EdgeShader.glsl.js +1 -1
- package/chunks/EmissionComposite.glsl.js +2 -2
- package/chunks/Fog.glsl.js +4 -4
- package/chunks/GlobalIlluminationBlur.glsl.js +1 -1
- package/chunks/HighlightSharpApply.glsl.js +4 -1
- package/chunks/LineMarker.glsl.js +4 -4
- package/chunks/Magnifier.glsl.js +1 -1
- package/chunks/NoiseTextureAtlas.glsl.js +3 -3
- package/chunks/Pattern.glsl.js +35 -32
- package/chunks/{ChapmanAtmosphere.glsl.js → RealisticAtmosphere.glsl.js} +18 -9
- package/chunks/RealisticAtmosphereCompositing.glsl.js +35 -0
- package/chunks/SSAO.glsl.js +2 -2
- package/chunks/SimpleAtmosphere.glsl.js +1 -1
- package/config.js +1 -1
- package/core/accessorSupport/ObservableBase.js +1 -1
- package/core/accessorSupport/tracking/ObservationHandle.js +1 -1
- package/core/accessorSupport/tracking/SimpleObservable.js +1 -1
- package/core/accessorSupport/tracking/SimpleTrackingTarget.js +1 -1
- package/core/accessorSupport/tracking/TrackingTarget.js +1 -1
- package/core/quantity.js +1 -1
- package/core/timeUtils.js +1 -1
- package/geometry/coordinateConversion/CoordinateConversionModel.d.ts +258 -0
- package/geometry/coordinateConversion/CoordinateConversionModel.js +2 -0
- package/geometry/coordinateConversion/support/Conversion.d.ts +73 -0
- package/geometry/coordinateConversion/support/Conversion.js +2 -0
- package/geometry/coordinateConversion/support/Format.d.ts +131 -0
- package/geometry/coordinateConversion/support/Format.js +2 -0
- package/geometry/coordinateConversion/support/coordinateConversionUtils.js +2 -0
- package/geometry/coordinateConversion/support/formatUtils.js +2 -0
- package/geometry/coordinateConversion/types.d.ts +116 -0
- package/kernel.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/layers/IntegratedMeshLayer.js +1 -1
- package/layers/catalog/CatalogFootprintLayer.d.ts +2 -2
- package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
- package/layers/knowledgeGraph/cypherUtils.js +1 -1
- package/layers/mixins/FeatureLayerBase.d.ts +2 -2
- package/layers/raster/formats/Lzw.js +1 -1
- package/layers/raster/formats/TiffDecoder.js +1 -1
- package/layers/raster/formats/tiffParser.js +1 -1
- package/layers/raster/formats/tiffTag.js +1 -1
- package/layers/support/IntegratedMeshSemantics.js +2 -0
- package/layers/support/VideoElement.js +1 -1
- package/legend/ActiveLayerInfo.js +1 -1
- package/package.json +2 -2
- package/symbols/FillSymbol3DLayer.d.ts +1 -4
- package/time/daylightUtils.d.ts +29 -0
- package/time/daylightUtils.js +2 -0
- package/time/timeZoneUtils.js +1 -1
- package/time/types.d.ts +57 -1
- package/views/2d/analysis/AreaMeasurement/AreaMeasurementTool.js +1 -1
- package/views/2d/analysis/AreaMeasurementAnalysisView2D.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
- package/views/2d/layers/GeospatialPDFLayerView2D.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/3d/GroundView3D.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementVisualization.js +1 -1
- package/views/3d/analysis/AreaMeasurementAnalysisView3D.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
- package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementController.js +1 -1
- package/views/3d/interactive/Manipulator3D.js +1 -1
- package/views/3d/interactive/Manipulator3DBase.js +2 -0
- package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbol.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWebStyleSymbol.js +1 -1
- package/views/3d/layers/graphics/SymbolComplexity.js +1 -1
- package/views/3d/layers/graphics/webStyleUtils.js +1 -1
- package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
- package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
- package/views/3d/layers/support/Tiles3DMeshIntersectionHandler.js +1 -1
- package/views/3d/layers/support/patternUtils.js +1 -1
- package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
- package/views/3d/support/GroundAndIMSurface.js +1 -1
- package/views/3d/support/engineContent/line.js +1 -1
- package/views/3d/support/hitTest.js +1 -1
- package/views/3d/support/pointsOfInterest/StableSurfaceCenter.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/PatchGeometryFactory.js +1 -1
- package/views/3d/terrain/PatchRenderDataWaterproofness.js +1 -1
- package/views/3d/terrain/SphericalPatch.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterialInitParameters.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterialRepository.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPass.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceRayMarching.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterColor.glsl.js +6 -4
- package/views/3d/webgl-engine/core/shaderLibrary/util/BlendModes.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/CloudsParallaxShading.glsl.js +10 -9
- package/views/3d/webgl-engine/core/shaderLibrary/util/GaussianSplatUnpacking.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/cameraUniforms.js +1 -1
- package/views/3d/webgl-engine/effects/WeatherFader.js +1 -1
- package/views/3d/webgl-engine/effects/atmosphere/ChapmanApproximation.glsl.js +3 -3
- package/views/3d/webgl-engine/effects/atmosphere/{ChapmanAtmosphere.glsl.js → RealisticAtmosphere.glsl.js} +1 -1
- package/views/3d/webgl-engine/effects/atmosphere/RealisticAtmosphere.js +2 -0
- package/views/3d/webgl-engine/effects/atmosphere/RealisticAtmosphereCompositing.glsl.js +2 -0
- package/views/3d/webgl-engine/effects/atmosphere/RealisticAtmosphereCompositingTechnique.js +2 -0
- package/views/3d/webgl-engine/effects/atmosphere/RealisticAtmosphereTechnique.js +2 -0
- package/views/3d/webgl-engine/effects/fog/Fog.js +1 -1
- package/views/3d/webgl-engine/effects/glow/BlurEmission.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/glow/applyEmissiveGlow.glsl.js +87 -41
- package/views/3d/webgl-engine/effects/precipitation/Precipitation.js +1 -1
- package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
- package/views/3d/webgl-engine/lib/EmissionComposite.glsl.js +1 -1
- package/views/3d/webgl-engine/lib/EmissionComposite.js +1 -1
- package/views/3d/webgl-engine/lib/ManagedTexture.js +1 -1
- package/views/3d/webgl-engine/lib/Octree.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/lib/intersectorUtilsConversions.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/InstanceOctree.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/shaders/Pattern.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/PatternLayouts.js +1 -1
- package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/PatternTechniqueConfiguration.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/VideoView.js +1 -1
- package/views/interactive/Tooltip.js +1 -1
- package/views/interactive/snapping/RightAngleTriangleSnapper.js +1 -1
- package/views/interactive/snapping/SnappingAlgorithm.js +1 -1
- package/views/interactive/tooltip/content/TooltipContent.js +1 -1
- package/widgets/CoordinateConversion/CoordinateConversionViewModel.d.ts +3 -0
- package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
- package/widgets/CoordinateConversion.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/022565ef98a702ab952f.js +0 -1
- package/assets/esri/core/workers/chunks/163e97987e1f75610009.js +0 -1
- package/assets/esri/core/workers/chunks/1d57b1445afec89a7941.js +0 -1
- package/assets/esri/core/workers/chunks/3654672d772d11484883.js +0 -1
- package/assets/esri/core/workers/chunks/3af0ff5a0b82872aac38.js +0 -1
- package/assets/esri/core/workers/chunks/3b9415dfd7546aeec261.js +0 -1
- package/assets/esri/core/workers/chunks/5109b48666138df14038.js +0 -1
- package/assets/esri/core/workers/chunks/6b73dfc9252b32f1eae2.js +0 -1
- package/assets/esri/core/workers/chunks/6e4698879e7d8fbc4d12.js +0 -1
- package/assets/esri/core/workers/chunks/71295afd21fc5bc5ddbc.js +0 -1
- package/assets/esri/core/workers/chunks/794a9f116c4700bb1210.js +0 -1
- package/assets/esri/core/workers/chunks/8e0ecc7f55dd8bf2cf16.js +0 -1
- package/assets/esri/core/workers/chunks/9dece842ada6278c33ef.js +0 -1
- package/assets/esri/core/workers/chunks/a12e29f2cb78fdaa0753.js +0 -1
- package/assets/esri/core/workers/chunks/b70af9fb974ef9836efd.js +0 -1
- package/assets/esri/core/workers/chunks/c0f2b6a10bcc766318f5.js +0 -1
- package/assets/esri/core/workers/chunks/c248db5e4d92cfb3c4d1.js +0 -1
- package/assets/esri/core/workers/chunks/ce02adb527389b90223d.js +0 -1
- package/assets/esri/core/workers/chunks/d8eea5ffe05c620fac9e.js +0 -1
- package/assets/esri/core/workers/chunks/d997d81d0965c05447d4.js +0 -1
- package/assets/esri/core/workers/chunks/e1645882f54818c4036a.js +0 -1
- package/assets/esri/core/workers/chunks/e44679a0d271c1efb60d.js +0 -1
- package/assets/esri/core/workers/chunks/f11f40017ec97a2a6b5f.js +0 -29
- package/assets/esri/core/workers/chunks/f7f5d8256e63d303cbcb.js +0 -1
- package/assets/esri/core/workers/chunks/f87d5450190896e61ff8.js +0 -1
- package/assets/esri/core/workers/chunks/fdee2255f49b43056e9d.js +0 -1
- package/assets/esri/core/workers/chunks/ff1e614fde01781360fa.js +0 -1
- package/chunks/AtmosphereCompositing.glsl.js +0 -25
- package/views/3d/analysis/ShadowCast/sunlightUtils.js +0 -2
- package/views/3d/webgl-engine/effects/atmosphere/ChapmanAtmosphere.js +0 -2
- package/views/3d/webgl-engine/effects/atmosphere/ChapmanAtmosphereTechnique.js +0 -2
- package/views/3d/webgl-engine/shaders/AtmosphereCompositing.glsl.js +0 -2
- package/views/3d/webgl-engine/shaders/AtmosphereCompositingTechnique.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
+
import{__decorate as e}from"tslib";import has from"../../../../../core/has.js";import{lerp as t}from"../../../../../core/mathUtils.js";import{disposeMaybe as n}from"../../../../../core/maybe.js";import{watch as r,syncAndInitial as i,initial as a}from"../../../../../core/reactiveUtils.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators.js";import{copy as s,set as c}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{set as l,length as u}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as d}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{earth as f}from"../../../../../geometry/support/Ellipsoid.js";import{OpaqueEnvironment as p}from"../OpaqueEnvironment.js";import{computeInnerAltitudeFade as m,innerAtmosphereDepth as h}from"./atmosphereUtils.js";import{R as g}from"../../../../../chunks/RealisticAtmosphereCompositing.glsl.js";import{RealisticAtmosphereCompositingTechnique as _}from"./RealisticAtmosphereCompositingTechnique.js";import{RealisticAtmosphereConfiguration as v}from"./RealisticAtmosphereConfiguration.js";import{RealisticAtmospherePassParameters as y,RealisticAtmosphereTechnique as b}from"./RealisticAtmosphereTechnique.js";import{createQuadVAO as x}from"../../lib/glUtil3D.js";import{applyTextureResizeModulo as S}from"../../lib/textureUtils.js";import{DepthStencilAttachment as C,ColorAttachment0 as w,PrimitiveType as T}from"../../../../webgl/enums.js";import E from"../../../../../webscene/background/ColorBackground.js";let D=class extends p{constructor(){super(...arguments),this._emissionDisabled=!!has(`disable-feature:emissive-sun`),this._passParameters=new y,this._compositingPassParameters=new g,this._configuration=new v}initialize(){this.addHandles([r(()=>this.view.environment.background,e=>{let t=e instanceof E?e.color.toUnitRGBA():d;l(this._passParameters.backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3])},i),r(()=>this.view.stage?.renderer?.highResolutionAtmosphere,e=>this._passParameters.reduced=!e,i),r(()=>this.view.map.ground.undergroundColor,e=>{this._passParameters.undergroundColor=e?.toUnitRGBA()??d,this.requestRender(1)},a),r(()=>this.view.environment.atmosphereEnabled,e=>e?this._enable():this._disable(),i)])}destroy(){this._vao=n(this._vao)}precompile(){this._configuration.hasClouds=!!this.bindParameters.clouds.data?.cubeMap?.colorTexture,this._configuration.hasEmissive=this._hasEmissive&&!this._passParameters.reduced,this._configuration.useFloatBlend=this.bindParameters.useFloatBlend.value,this.techniques.precompile(b,this._configuration),this._passParameters.reduced&&(this._configuration.hasEmissive=this._hasEmissive,this.techniques.precompile(_,this._configuration))}render(){let e=this.input;if(!this.bindParameters.mainDepth)return e;let n=this.renderingContext,r=e.getAttachment(C);this._update(),this._vao??=x(n,1),this.bindParameters.clouds?.isFading&&this.requestRender(2),this._configuration.hasEmissive=this._hasEmissive&&!this._passParameters.reduced;let i=this.techniques.get(b,this._configuration);if(!this._passParameters.reduced)return e.detachDepth(),n.bindFramebuffer(e.fbo),n.bindTechnique(i,this.bindParameters,this._passParameters),n.bindVAO(this._vao),this._emissionDisabled&&n.setDrawBuffers([w]),n.drawArrays(T.TRIANGLE_STRIP,0,4),e.attachDepth(r),e;let a=n.getViewport(),o=this.bindParameters.camera,c=u(o.eye)-f.radius,l,d=f.atmosphereHeight;if(c<d){let e=Math.min(1,Math.max(0,c/d));l=t(.2,.3,e)}else{let e=Math.min(1,Math.max(0,(c-d)/(15*d)));l=t(.3,.6,e)}let p=this.renderingContext.parameters.maxTextureSize,m=S(Math.round(l*o.fullViewport[2]),p),h=S(Math.round(l*o.fullViewport[3]),p);n.setViewport(0,0,m,h);let g=this.fboCache.acquire(m,h,`chapman`);n.bindFramebuffer(g.fbo),n.clearFramebuffer([0,0,0,1],!0,!0),n.bindTechnique(i,this.bindParameters,this._passParameters),n.bindVAO(this._vao),n.drawArrays(T.TRIANGLE_STRIP,0,4),n.setViewport(a.x,a.y,a.width,a.height),this._configuration.hasEmissive=this.bindParameters.emissions!==0;let v=this.techniques.get(_,this._configuration);return s(this._compositingPassParameters.radii,this._passParameters.radii),this._compositingPassParameters.color=g.getTexture(),e.detachDepth(),n.bindFramebuffer(e.fbo),n.bindTechnique(v,this.bindParameters,this._compositingPassParameters),this._emissionDisabled&&n.setDrawBuffers([w]),n.screen.draw(),e.attachDepth(r),g.release(),e}_update(){let e=this.view.basemapTerrain?.getLowerBoundRadius()??0;c(this._passParameters.radii,e,e+f.atmosphereHeight);let t=u(this.bindParameters.camera.eye);this._passParameters.altitudeFade=m(t-e),this._passParameters.innerFadeDistance=2*Math.sqrt((2*e-h)*h)}get _hasEmissive(){return this.bindParameters.emissions!==0&&!this._emissionDisabled}};D=e([o(`esri.views.3d.webgl-engine.effects.atmosphere.RealisticAtmosphere`)],D);export{D as RealisticAtmosphere};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
+
import"../../core/shaderLibrary/bindUniforms.js";import"../../core/shaderLibrary/shading/Gamma.glsl.js";import"../../core/shaderLibrary/shading/lightingUniforms.js";import"../../core/shaderLibrary/util/cameraUniforms.js";import"../../core/shaderLibrary/util/CloudsParallaxShading.glsl.js";import"../../core/shaderLibrary/util/ColorConversion.glsl.js";import"../../core/shaderModules/FloatBindUniform.js";import"../../core/shaderModules/glsl.js";import"../../core/shaderModules/Texture2DPassUniform.js";import"./ChapmanApproximation.glsl.js";import"../../shaders/ditherNoise.glsl.js";import"../../shaders/floatBlendScale.glsl.js";import"../../shaders/ScreenSpacePassAtmosphere.glsl.js";import"../../shaders/ToneMapping.glsl.js";import"../../../../webgl/ShaderBuilder.js";export{R as RealisticAtmosphereCompositingPassParameters,b as build}from"../../../../../chunks/RealisticAtmosphereCompositing.glsl.js";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
+
import{__decorate as e}from"tslib";import{subclass as t}from"../../../../../core/accessorSupport/decorators.js";import{ReloadableShader as n}from"../../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as r}from"../../core/shaderTechnique/ShaderTechnique.js";import{a as i}from"../../../../../chunks/RealisticAtmosphereCompositing.glsl.js";import{makePipelineState as a,defaultColorWrite as o,simpleBlendingParams as s}from"../../../../webgl/renderState.js";let c=class extends r{constructor(){super(...arguments),this.shader=new n(i,()=>import(`./RealisticAtmosphereCompositing.glsl.js`)),this.ignoreUnused=!0}initializePipeline(){return a({blending:s(1,771),depthTest:{func:519},colorWrite:o})}};c=e([t(`esri.views.3d.webgl-engine.effects.atmosphere.RealisticAtmosphereCompositingTechnique`)],c);export{c as RealisticAtmosphereCompositingTechnique};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
+
import{__decorate as e}from"tslib";import{subclass as t}from"../../../../../core/accessorSupport/decorators.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as r}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ReloadableShader as i}from"../../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as a}from"../../core/shaderTechnique/ShaderTechnique.js";import{ChapmanApproximationPassParameters as o}from"./ChapmanApproximation.glsl.js";import{R as s}from"../../../../../chunks/RealisticAtmosphere.glsl.js";import{Pos2TexF16 as c}from"../../lib/DefaultVertexBufferLayouts.js";import{makePipelineState as l,defaultColorWrite as u,copySource as d,simpleBlendingParams as f}from"../../../../webgl/renderState.js";class p extends o{constructor(){super(...arguments),this.reduced=!1,this.innerFadeDistance=0,this.altitudeFade=0,this.backgroundColor=n(),this.undergroundColor=r()}}let m=class extends a{constructor(e,t){super(e,t,c),this.shader=new i(s,()=>import(`./RealisticAtmosphere.glsl.js`)),this._reducedPipeline=l({blending:d,depthTest:{func:519},colorWrite:u})}initializePipeline(){return l({blending:f(1,771),depthTest:{func:515},colorWrite:u})}getPipeline(e,t){return t.reduced?this._reducedPipeline:super.getPipeline(e,t)}};m=e([t(`esri.views.3d.webgl-engine.effects.atmosphere.RealisticAtmosphereTechnique`)],m);export{p as RealisticAtmospherePassParameters,m as RealisticAtmosphereTechnique};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{smoothstep as t,lerp as n}from"../../../../../core/mathUtils.js";import{releaseMaybe as r}from"../../../../../core/maybe.js";import{watch as i,syncAndInitial as a}from"../../../../../core/reactiveUtils.js";import{signal as o}from"../../../../../core/signal.js";import{subclass as s}from"../../../../../core/accessorSupport/decorators.js";import{property as c}from"../../../../../core/accessorSupport/decorators/property.js";import{add as l,normalize as u,length as d,dot as f,scale as p,lerp as m}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as h,fromValues as g}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as _}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{heightLimit as v}from"../../../environment/weather.js";import{betaRayleigh as y,betaCombined as b}from"../atmosphere/atmosphereUtils.js";import{F as x}from"../../../../../chunks/Fog.glsl.js";import{FogTechnique as S}from"./FogTechnique.js";import{BlurEmission as C}from"../glow/BlurEmission.js";import{EmissiveTechniqueConfiguration as w}from"../../shaders/EmissiveTechniqueConfiguration.js";import{floatBlendReductionFactor as T}from"../../shaders/floatBlendScale.glsl.js";import{ColorAttachment1 as E,SizedPixelFormat as D,ColorAttachment0 as O,DepthStencilAttachment as k}from"../../../../webgl/enums.js";const A=.9*v,j=1.1*v;let M=class extends C{constructor(){super(...arguments),this._configuration=new w,this._newParameters=new N,this._oldParameters=new N,this._fadedParameters=new N,this._parameters=this._newParameters,this._passParameters=new x}initialize(){this._configuration.
|
|
2
|
+
import{__decorate as e}from"tslib";import{smoothstep as t,lerp as n}from"../../../../../core/mathUtils.js";import{releaseMaybe as r}from"../../../../../core/maybe.js";import{watch as i,syncAndInitial as a}from"../../../../../core/reactiveUtils.js";import{signal as o}from"../../../../../core/signal.js";import{subclass as s}from"../../../../../core/accessorSupport/decorators.js";import{property as c}from"../../../../../core/accessorSupport/decorators/property.js";import{add as l,normalize as u,length as d,dot as f,scale as p,lerp as m}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as h,fromValues as g}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as _}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{heightLimit as v}from"../../../environment/weather.js";import{betaRayleigh as y,betaCombined as b}from"../atmosphere/atmosphereUtils.js";import{F as x}from"../../../../../chunks/Fog.glsl.js";import{FogTechnique as S}from"./FogTechnique.js";import{BlurEmission as C}from"../glow/BlurEmission.js";import{EmissiveTechniqueConfiguration as w}from"../../shaders/EmissiveTechniqueConfiguration.js";import{floatBlendReductionFactor as T}from"../../shaders/floatBlendScale.glsl.js";import{ColorAttachment1 as E,SizedPixelFormat as D,ColorAttachment0 as O,DepthStencilAttachment as k}from"../../../../webgl/enums.js";const A=.9*v,j=1.1*v;let M=class extends C{constructor(){super(...arguments),this._configuration=new w,this._newParameters=new N,this._oldParameters=new N,this._fadedParameters=new N,this._parameters=this._newParameters,this._passParameters=new x}initialize(){this._configuration.computeScatteredIllumination=!0,this.addHandles([i(()=>this.view.environmentView.weather!=null,e=>e?this._enable():this._disable(),a),i(()=>this._fogParameters,e=>this._updateFogParameters(e),a),i(()=>this._fadeFactor,e=>this._fade(e),a)])}get _fadeFactor(){return this.view.stage?.renderer.renderContext.bind.clouds.fadeFactor??1}_fade(e){let{_newParameters:t,_oldParameters:n}=this;e>=1?(this._parameters=t,this._oldParameters.copy(this._newParameters)):e<=0?this._parameters=n:(this._fadedParameters.lerp(n,t,e),this._parameters=this._fadedParameters)}get _fogParameters(){let e=new N,{weather:t}=this.view.environmentView,n=t?.type===`foggy`||t?.type===`snowy`||t?.type===`rainy`;switch(e.strength.value=t?.scattering??0,e.amount.value=+!!n,e.fogBrightness=this._newParameters.fogBrightness,t?.type){case`foggy`:case`snowy`:e.fogBrightness=B;break;case`rainy`:e.fogBrightness=z}let r=this._get(`_fogParameters`);return e.equals(r)?r:e}_updateFogParameters(e){this._newParameters.copy(e),this._fadeFactor>=1&&this._oldParameters.copy(this._newParameters),this.requestRender(2)}get strength(){return this._parameters.strength.value*this._heightFade}get amount(){return this._parameters.amount.value*this._heightFade}get _heightFade(){let e=d(this.bindParameters.camera.eye);return 1-t(A,j,Math.abs(e-this._ellipsoid.radius))}precompile(){this._update(),this._passParameters.amount>0&&(super.precompile(),this.techniques.precompile(S,this._configuration))}get _needsEmissionBlur(){return this._configuration.hasEmissive}render(){let e=this.input,t=this._getTechnique();if(!t)return e;this._passParameters.emission=e.obtainAttachment(E),this._passParameters.inputScale=this._passParameters.emission?.attachment.descriptor.internalFormat===D.RGBA8?T:1;let n=this.renderingContext;this._passParameters.emission&&(this._renderEmissionMipMap(),this._configuration.useFloatBlend?(e.acquireColor(E,8,`emissive`),n.clearBuffer(1,_)):(this._passParameters.color=e.obtainAttachment(O),e.acquireColor(O,5),e.acquireColor(E,8,`emissive`)));let i=e.getAttachment(k);return e.attachDepth(null),n.bindFramebuffer(e.fbo),n.bindTechnique(t,this.bindParameters,this._passParameters),n.screen.draw(),this._passParameters.color=r(this._passParameters.color),this._passParameters.emission=r(this._passParameters.emission),this._passParameters.mipmapTexture=r(this._passParameters.mipmapTexture),e.attachDepth(i),this.fboCache.debugCallback?.(`fog-color`,e.fbo),e}_getTechnique(){return this.renders?this.techniques.get(S,this._configuration):null}get renders(){return this._update(),this._passParameters.amount>0}_update(){let e=this.bindParameters.camera;u(P,e.eye);let t=Math.max(0,f(P,this.bindParameters.lighting.mainLight.direction)),n=this._parameters.fogBrightness;p(this._passParameters.fogColor,L,n),p(F,L,n*.1),m(this._passParameters.fogColor,F,this._passParameters.fogColor,t);let r=d(e.eye);this._passParameters.atmosphereC=r**2-this._atmosphereRadius**2,this._passParameters.amount=this.amount,this._passParameters.strength=this._passParameters.scattering=this.strength,this._configuration.hasEmissive=this.bindParameters.hasEmission,this._configuration.useFloatBlend=this.bindParameters.useFloatBlend.value}get test(){return{parameters:this._passParameters}}};e([c()],M.prototype,`_fogParameters`,null),M=e([s(`esri.views.3d.webgl-engine.effects.fog.Fog`)],M);class N{constructor(){this.fogBrightness=0,this.strength=o(0),this.amount=o(0)}equals(e){return e!=null&&this.fogBrightness===e.fogBrightness&&this.strength.value===e.strength.value&&this.amount.value===e.amount.value}copy(e){this.fogBrightness=e.fogBrightness,this.strength.value=e.strength.value,this.amount.value=e.amount.value}lerp(e,t,r){this.fogBrightness=n(e.fogBrightness,t.fogBrightness,r),this.strength.value=n(e.strength.value,t.strength.value,r),this.amount.value=n(e.amount.value,t.amount.value,r)}}const P=h(),F=h(),I=g(3e-4,3e-4,3e-4),L=h();l(L,b,y),l(L,L,I),u(L,L);const R=L.reduce((e,t)=>e+t,0)/3,z=.5/R,B=1.5/R;export{M as Fog,N as FogParameters};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import"../../../../../core/arrayUtils.js";import"../../../../../core/mathUtils.js";import"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import"../../core/shaderLibrary/ScreenSpacePass.glsl.js";import"../../core/shaderLibrary/shading/Gamma.glsl.js";import"../../core/shaderModules/BooleanDrawUniform.js";import"../../core/shaderModules/Float2DrawUniform.js";import"../../core/shaderModules/FloatDrawUniform.js";import"../../core/shaderModules/glsl.js";import"../../core/shaderModules/Texture2DDrawUniform.js";import"../../../../webgl/NoParameters.js";import"../../../../webgl/ShaderBuilder.js";export{B as BlurEmissionDrawParameters,b as build}from"../../../../../chunks/BlurEmission.glsl.js";
|
|
2
|
+
import"../../../../../core/arrayUtils.js";import"../../../../../core/mathUtils.js";import"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import"../../core/shaderLibrary/bindUniforms.js";import"../../core/shaderLibrary/ScreenSpacePass.glsl.js";import"../../core/shaderLibrary/output/ReadDepth.glsl.js";import"../../core/shaderLibrary/shading/Gamma.glsl.js";import"../../core/shaderLibrary/util/cameraUniforms.js";import"../../core/shaderModules/BooleanDrawUniform.js";import"../../core/shaderModules/Float2DrawUniform.js";import"../../core/shaderModules/FloatDrawUniform.js";import"../../core/shaderModules/glsl.js";import"../../core/shaderModules/Texture2DDrawUniform.js";import"../../../../webgl/NoParameters.js";import"../../../../webgl/ShaderBuilder.js";export{B as BlurEmissionDrawParameters,b as build}from"../../../../../chunks/BlurEmission.glsl.js";
|
|
@@ -1,42 +1,88 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../environment/FoggyWeather.js";import{mainDepth as n}from"../../core/shaderLibrary/bindUniforms.js";import{ReadDepth as r}from"../../core/shaderLibrary/output/ReadDepth.glsl.js";import{
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
float
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
float
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
float
|
|
32
|
-
|
|
33
|
-
float
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../environment/FoggyWeather.js";import{mainDepth as n}from"../../core/shaderLibrary/bindUniforms.js";import{ReadDepth as r}from"../../core/shaderLibrary/output/ReadDepth.glsl.js";import{nearFar as i}from"../../core/shaderLibrary/util/cameraUniforms.js";import{FloatBindUniform as a}from"../../core/shaderModules/FloatBindUniform.js";import{FloatPassUniform as o}from"../../core/shaderModules/FloatPassUniform.js";import{If as s,glsl as c}from"../../core/shaderModules/glsl.js";import{Texture2DPassUniform as l}from"../../core/shaderModules/Texture2DPassUniform.js";import{parameter as u}from"../../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{DistanceFalloffPassParameters as d,getDistanceFalloff as f}from"../raymarching/DistanceFalloff.glsl.js";import{FloatBlendScaleConfiguration as p,floatBlendScale as m}from"../../shaders/floatBlendScale.glsl.js";import{ToneMapping as h}from"../../shaders/ToneMapping.glsl.js";class g extends d{constructor(){super(...arguments),this.mipmapLevels=1,this.boost=1,this.scattering=1e-4}}class _ extends p{constructor(){super(...arguments),this.computeScatteredIllumination=!1}}e([u()],_.prototype,`computeScatteredIllumination`,void 0);function v(e,u){e.include(m,u),e.include(f),e.include(r),e.include(h),e.uniforms.add(new l(`emissionTexture`,({emission:e})=>e?.attachment),new a(`emissionFade`,e=>e.emissionFade),n,i,new o(`scattering`,({scattering:e})=>e),new o(`boost`,({boost:e})=>1+e*.5),new o(`levels`,({mipmapLevels:e},{camera:t})=>e+1+Math.log2(t.pixelScale)),new a(`pixelRatioCorrection`,({camera:e})=>Math.log2(e.pixelScale)),new l(`mipmapTexture`,({mipmapTexture:e})=>e?.getTexture())).constants.add(`maxScattering`,`float`,t.maxScattering).code.add(c`
|
|
3
|
+
struct EmissiveGlowResult {
|
|
4
|
+
vec3 transmittedEmission;
|
|
5
|
+
vec3 scatteredIllumination;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
vec4 readEmission(float level, float depth) {
|
|
9
|
+
level *= levels;
|
|
10
|
+
level = max(0.0, level - pixelRatioCorrection);
|
|
11
|
+
if (level < 1.0) {
|
|
12
|
+
vec3 emission = texture(emissionTexture, uv).rgb * floatBlendInputScale;
|
|
13
|
+
vec4 unblurred = vec4(emission, depth * dot(emission, vec3(1.0 / 3.0)));
|
|
14
|
+
return unblurred * (1.0 - level) + textureLod(mipmapTexture, uv, 0.0) * level * 0.5;
|
|
15
|
+
}
|
|
16
|
+
return textureLod(mipmapTexture, uv, level - 1.0) / pow(2.0, level);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
float gauss(float x, float sigmaSq) {
|
|
20
|
+
float expon = -(pow(x, 2.0) / (2.0 * sigmaSq));
|
|
21
|
+
return exp(expon) / sqrt(6.283185307179586 * sigmaSq);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
float emissionWeight(float point, float mainPoint, float sigmaSq) {
|
|
25
|
+
// Keep scattering from widening the kernel back into sharp levels (#27433).
|
|
26
|
+
float minPoint = mainPoint - 0.5;
|
|
27
|
+
float fullPoint = (minPoint + mainPoint) * 0.5;
|
|
28
|
+
return gauss(point - mainPoint, sigmaSq) * smoothstep(minPoint, fullPoint, point);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
EmissiveGlowResult applyEmissiveGlow(float extinctionAmount, float maxDispersion) {
|
|
32
|
+
float normalizedDepth = 1.0;
|
|
33
|
+
float depthSample = depthFromTexture(mainDepth, uv);
|
|
34
|
+
if(depthSample < 1.0 && depthSample > 0.0){
|
|
35
|
+
normalizedDepth = -linearizeDepth(depthSample) / nearFar.y;
|
|
36
|
+
}
|
|
37
|
+
vec3 rayDir = normalize(worldRay);
|
|
38
|
+
float depthToDistance = nearFar.y / abs(normalize(eyeDir).z);
|
|
39
|
+
|
|
40
|
+
vec3 transmittedEmission = vec3(0.0);
|
|
41
|
+
vec3 scatteredIllumination = vec3(0.0);
|
|
42
|
+
${s(u.computeScatteredIllumination,c`
|
|
43
|
+
float illuminationWeights = 0.0;
|
|
44
|
+
float backgroundDistance = depthSample > 0.0 && depthSample < 1.0 ? normalizedDepth * depthToDistance : -1.0;
|
|
45
|
+
float backgroundDispersion = getDistanceFalloff(backgroundDistance, rayDir, scattering * 0.5);
|
|
46
|
+
float illuminationMainPoint = pow(backgroundDispersion, 4.0) * maxDispersion;
|
|
47
|
+
`)}
|
|
48
|
+
float weights = 0.0; // accumulated weights for renormalization
|
|
49
|
+
float baseSigmaSq = 0.003 + 0.03 * (boost - 1.0); // boost spreads out glow
|
|
50
|
+
float sigmaSq = baseSigmaSq + 0.1 * scattering / maxScattering;
|
|
51
|
+
|
|
52
|
+
for(float level = 0.0; level < levels; ++level) {
|
|
53
|
+
float point = level / levels;
|
|
54
|
+
vec4 emissionSample = readEmission(point, normalizedDepth);
|
|
55
|
+
float intensity = dot(emissionSample.rgb, vec3(1.0 / 3.0));
|
|
56
|
+
float averageDepth = intensity > 0.0 ? emissionSample.a / intensity : 0.0;
|
|
57
|
+
float emitterDistance = averageDepth * depthToDistance;
|
|
58
|
+
float dispersion = getDistanceFalloff(emitterDistance, rayDir, scattering * 0.5);
|
|
59
|
+
float mainPoint = pow(dispersion, 4.0) * maxDispersion;
|
|
60
|
+
|
|
61
|
+
float weight = emissionWeight(point, mainPoint, sigmaSq);
|
|
62
|
+
if (extinctionAmount > 0.0 && averageDepth > 0.0) {
|
|
63
|
+
// Approximate the fraction of the emitter's scattering path in front of the visible surface.
|
|
64
|
+
emissionSample.rgb *= min(1.0, normalizedDepth / averageDepth);
|
|
65
|
+
}
|
|
66
|
+
${s(u.computeScatteredIllumination,c`
|
|
67
|
+
float illuminationWeight = emissionWeight(point, illuminationMainPoint, sigmaSq);
|
|
68
|
+
scatteredIllumination += emissionSample.rgb * illuminationWeight;
|
|
69
|
+
illuminationWeights += illuminationWeight;
|
|
70
|
+
`)}
|
|
71
|
+
if(weight > 0.0) {
|
|
72
|
+
if (extinctionAmount > 0.0) {
|
|
73
|
+
float pathDistance = min(normalizedDepth, averageDepth) * depthToDistance;
|
|
74
|
+
float extinction = extinctionAmount * getDistanceFalloff(pathDistance, rayDir, scattering);
|
|
75
|
+
float damping = extinction < 1.0 ? min(-log(1.0 - extinction) * 0.1, 16.0) : 16.0;
|
|
76
|
+
transmittedEmission += max(emissionSample.rgb * boost * emissionFade - damping, 0.0) * weight;
|
|
77
|
+
} else {
|
|
78
|
+
transmittedEmission += emissionSample.rgb * weight;
|
|
79
|
+
}
|
|
80
|
+
weights += weight;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
transmittedEmission = extinctionAmount > 0.0 ?
|
|
84
|
+
transmittedEmission / weights : transmittedEmission * boost / weights * emissionFade;
|
|
85
|
+
${s(u.computeScatteredIllumination,`scatteredIllumination = scatteredIllumination * boost / illuminationWeights * emissionFade;`)}
|
|
86
|
+
return EmissiveGlowResult(transmittedEmission, scatteredIllumination);
|
|
87
|
+
}
|
|
88
|
+
`)}export{_ as EmissiveGlowConfiguration,g as EmissiveGlowPassParameters,v as applyEmissiveGlow};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import"../../../../../core/has.js";import{lerp as t}from"../../../../../core/mathUtils.js";import{disposeMaybe as n}from"../../../../../core/maybe.js";import{watch as r,syncAndInitial as i,sync as a}from"../../../../../core/reactiveUtils.js";import{secondsFromMilliseconds as o}from"../../../../../core/time.js";import{property as s,subclass as c}from"../../../../../core/accessorSupport/decorators.js";import{getReferenceEllipsoid as l}from"../../../../../geometry/ellipsoidUtils.js";import{getContinuousIndexArray as u}from"../../../../../geometry/support/Indices.js";import{InternalRenderCategory as d}from"../../../webgl.js";import{
|
|
2
|
+
import{__decorate as e}from"tslib";import"../../../../../core/has.js";import{lerp as t}from"../../../../../core/mathUtils.js";import{disposeMaybe as n}from"../../../../../core/maybe.js";import{watch as r,syncAndInitial as i,sync as a}from"../../../../../core/reactiveUtils.js";import{secondsFromMilliseconds as o}from"../../../../../core/time.js";import{property as s,subclass as c}from"../../../../../core/accessorSupport/decorators.js";import{getReferenceEllipsoid as l}from"../../../../../geometry/ellipsoidUtils.js";import{getContinuousIndexArray as u}from"../../../../../geometry/support/Indices.js";import{InternalRenderCategory as d}from"../../../webgl.js";import{debugFlags as f}from"../../../support/debugFlags.js";import{glLayout as p}from"../../../support/buffer/glUtil.js";import{newLayout as m}from"../../../support/buffer/InterleavedLayout.js";import{TransparentEnvironment as h}from"../TransparentEnvironment.js";import{PrecipitationPassParameters as g,PrecipitationTechnique as _}from"./PrecipitationTechnique.js";import{PrecipitationTechniqueConfiguration as v}from"./PrecipitationTechniqueConfiguration.js";import{VertexArrayObject as y}from"../../lib/VertexArrayObject.js";import{PrimitiveType as b}from"../../../../webgl/enums.js";import{bindVertexBufferLayout as x}from"../../../../webgl/Util.js";import{fromLayout as S}from"../../../../webgl/VertexAttributeLocations.js";import{VertexBuffer as C}from"../../../../webgl/VertexBuffer.js";let w=class extends h{constructor(e){super(e),this._hasSnowCover=!1,this._rainSpeed=.1,this._snowSpeed=.01,this._numParticles=0,this._passParameters=new g,this._configuration=new v,this._forcedTime=null;let{view:t,type:n}=e;this._configuration.type=n===`rainy`?0:1,this._passParameters.time=0,this._passParameters.radius=l(t.spatialReference).radius,this.addHandles([r(()=>t.environment.weather,e=>{e.type===n&&this.addHandles([r(()=>e.precipitation,e=>this._adjustParticles(e),i),r(()=>e.type===`snowy`&&e.snowCover===`enabled`,e=>this._hasSnowCover=e,i)])},i)]),this.addHandles(r(()=>t.stage?.renderer.renderContext.bind.clouds.fadeFactor??1,e=>{this._passParameters.opacity=e,e===1&&(this.removeHandles(`opacity`),this.addHandles(r(()=>t.stage?.renderer.renderContext.bind.clouds.opacity??1,e=>this._passParameters.opacity=e,i),`opacity`))},a),`opacity`)}initialize(){this.addHandles([r(()=>this.view.environment.atmosphereEnabled,e=>e?this._enable():this._disable(),i)])}_adjustParticles(e){let n=.35,r=e<.5?t(0,n,e*2):t(n,1,(e-.5)*2);this._numParticles=E*r}destroy(){this._numParticles=0,this._vao=n(this._vao),this._instanceIdBuffer=n(this._instanceIdBuffer)}fadeOut(e){this.removeAllHandles(),this.produces===`disabled`?e():this.addHandles(r(()=>this.renderContext?.bind.clouds.fadeFactor??1,t=>{this._passParameters.opacity=1-t,t===1&&(this.removeAllHandles(),e())},a))}get snowCover(){return this._hasSnowCover?this._passParameters.opacity:null}updateAnimation(e){let t=(this.type===`rainy`?this._rainSpeed:this._snowSpeed)*o(this._forcedTime??e.time)%1e5;return this._passParameters.time!==t&&(this._passParameters.time=t,!0)}precompile(){this._numParticlesRendered>0&&(this._configuration.hasEmissive=this.bindParameters.emissions!==0,this.techniques.precompile(_,this._configuration))}render(e){let t=e.find(({name:e})=>e===d.TRANSPARENT_ENVIRONMENT);if(this._numParticlesRendered<1)return t;let n=this.renderingContext,r=this.techniques.get(_,this._configuration),i=n.bindTechnique(r,this.bindParameters,this._passParameters);return this._vao??=T(n),n.bindVAO(this._vao),this._bindInstanceIdBuffer(i.locations),f.ENABLE_OPTIMIZATIONS||i.assertCompatibleVertexAttributeLocations(this._vao,S(O)),n.drawArraysInstanced(b.TRIANGLES,0,3,this._numParticlesRendered),n.unbindBuffer(34962),t}get _numParticlesRendered(){return Math.round(this._numParticles*this._passParameters.opacity)}_bindInstanceIdBuffer(e){let t=this.renderingContext;if(this._instanceIdBuffer){t.bindBuffer(this._instanceIdBuffer);return}let n=u(E);this._instanceIdBuffer=new C(t,O,new Float32Array(n)),x(t,e,this._instanceIdBuffer,0)}get test(){}};e([s({constructOnly:!0})],w.prototype,`type`,void 0),w=e([c(`esri.views.3d.webgl-engine.effects.precipitation.Precipitation`)],w);function T(e){let t=new Float32Array([-1,0,1,1,0,-1,1,0,1]);return new y(e,new C(e,p(D),t))}const E=25e4,D=m().vec3f(`position`).freeze(),O=p(m().f32(`instanceFeatureAttribute`),1);export{w as Precipitation};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{releaseMaybe as e}from"../../../../core/maybe.js";import{signal as t}from"../../../../core/signal.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import r from"../../webgl/RenderCamera.js";import{isColor as i}from"../core/shaderLibrary/ShaderOutput.js";import{CloudsParameters as a}from"../effects/clouds/CloudsParameters.js";import{enableOITOffset as o}from"./OrderIndependentTransparency.js";import{ReprojectionUniforms as s}from"./ReprojectionUniforms.js";import{ScreenSpaceReflectionsUniforms as c}from"./ScreenSpaceReflectionsUniforms.js";import{SceneLighting as l}from"../lighting/SceneLighting.js";class u{constructor(e,t){this.width=e,this.height=t}}class d{constructor(e){this.shadowMap=e,this.output=0,this.slot=2,this.planarDistanceToGroundRatio=1,this.metersPerRenderUnit=1,this.hasOccludees=!1,this._emissions=t(0),this.emissionFade=1,this.transparentWithoutDepthEmissionDimmingPass=!1,this.useFloatBlend=t(!0),this.enableFillLights=!0,this.alignPixelEnabled=!1,this.decorations=!0,this.frameRendererTarget=0,this.overlayStretch=1,this.viewshedEnabled=!1,this.laserlinesEnabled=!1,this.shadowAnalysisEnabled=!1,this.cutFillComputationEnabled=!1,this.cutFillVisualizationEnabled=!1,this._camera=t(new r),this._inverseViewport=n(),this._oldLighting=new l,this._newLighting=new l,this._fadedLighting=new l,this._lighting=this._newLighting,this.screenSpaceReflections=new c,this.reprojection=new s,this.highlights=[],this.highlightMixOrigin=n(),this.globalIlluminationEnabled=!1,this.hudRenderStyle=0,this.snowCover=0,this.clouds=new a,this.hasShadowHighlights=!1}destroy(){this._camera=this.contentCamera=null,this.mainDepth=this.overlay=this.ssao=this.shadowHighlight=null,this.depth=e(this.depth),this.shadowMap?.dispose()}get emissions(){return this._emissions.value}set emissions(e){this._emissions.value=e}get hasEmission(){switch(this.output){case 0:return this.hasOpaqueEmission;case 1:case 2:return this.hasTransparentEmission;default:return!1}}get hasOpaqueEmission(){return this.emissions===1||this.emissions===3}get hasTransparentEmission(){return this.emissions===2||this.emissions===3}get hasEmissions(){return this.emissions!==0}get camera(){return this._camera.value}set camera(e){this._camera.value=e,this._inverseViewport[0]=1/e.fullViewport[2],this._inverseViewport[1]=1/e.fullViewport[3]}get enableOITOffset(){return o(this.output,this.camera)}get inverseViewport(){return this._inverseViewport}get lighting(){return this._lighting}fadeLighting(){switch(this.clouds.fadeFactor){case 0:this._lighting=this._oldLighting;break;default:this._fadedLighting.lerpLighting(this._oldLighting,this._newLighting,this.clouds.fadeFactor),this._lighting=this._fadedLighting;break;case 1:this._lighting=this._newLighting,this._oldLighting.copyFrom(this._newLighting)}}updateLighting(e,t,n,r){this._oldLighting.copyFrom(this.lighting),this._newLighting.noonFactor=t,this._newLighting.globalFactor=n,this._newLighting.set(e),this._oldLighting.updateLegacy(),r===1&&this.clouds.requestFade(),this.fadeLighting()}get hasScreenSpaceReflections(){return this.frameRendererTarget!==3&&i(this.output)&&this.screenSpaceReflections.enabled&&this.reprojection.lastFrameColor!=null}get highlight(){return this.highlightLevel==null?null:this.highlights[this.highlightLevel]}get depth(){return this._depth}set depth(e){e&&(e.name=`geometry depth`),this._depth=e}get occluder(){return this.slot===10||this.slot===11?this.slot:null}}export{d as BindParameters,u as ViewportSize};
|
|
2
|
+
import{releaseMaybe as e}from"../../../../core/maybe.js";import{signal as t}from"../../../../core/signal.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import r from"../../webgl/RenderCamera.js";import{isColor as i}from"../core/shaderLibrary/ShaderOutput.js";import{CloudsParameters as a}from"../effects/clouds/CloudsParameters.js";import{enableOITOffset as o}from"./OrderIndependentTransparency.js";import{ReprojectionUniforms as s}from"./ReprojectionUniforms.js";import{ScreenSpaceReflectionsUniforms as c}from"./ScreenSpaceReflectionsUniforms.js";import{SceneLighting as l}from"../lighting/SceneLighting.js";class u{constructor(e,t){this.width=e,this.height=t}}class d{constructor(e){this.shadowMap=e,this.output=0,this.slot=2,this.planarDistanceToGroundRatio=1,this.metersPerRenderUnit=1,this.hasOccludees=!1,this._emissions=t(0),this.emissionFade=1,this.transparentWithoutDepthEmissionDimmingPass=!1,this.useFloatBlend=t(!0),this.enableFillLights=!0,this.alignPixelEnabled=!1,this.decorations=!0,this.frameRendererTarget=0,this.overlayStretch=1,this.viewshedEnabled=!1,this.laserlinesEnabled=!1,this.shadowAnalysisEnabled=!1,this.cutFillComputationEnabled=!1,this.cutFillVisualizationEnabled=!1,this._camera=t(new r),this._inverseViewport=n(),this._oldLighting=new l,this._newLighting=new l,this._fadedLighting=new l,this._lighting=this._newLighting,this.screenSpaceReflections=new c,this.reprojection=new s,this.highlights=[],this.highlightMixOrigin=n(),this.globalIlluminationEnabled=!1,this.hudRenderStyle=0,this.snowCover=0,this.clouds=new a,this.hasShadowHighlights=!1}destroy(){this._camera=this.contentCamera=this.viewCamera=null,this.mainDepth=this.overlay=this.ssao=this.shadowHighlight=null,this.depth=e(this.depth),this.shadowMap?.dispose()}get emissions(){return this._emissions.value}set emissions(e){this._emissions.value=e}get hasEmission(){switch(this.output){case 0:return this.hasOpaqueEmission;case 1:case 2:return this.hasTransparentEmission;default:return!1}}get hasOpaqueEmission(){return this.emissions===1||this.emissions===3}get hasTransparentEmission(){return this.emissions===2||this.emissions===3}get hasEmissions(){return this.emissions!==0}get camera(){return this._camera.value}set camera(e){this._camera.value=e,this._inverseViewport[0]=1/e.fullViewport[2],this._inverseViewport[1]=1/e.fullViewport[3]}get enableOITOffset(){return o(this.output,this.camera)}get inverseViewport(){return this._inverseViewport}get lighting(){return this._lighting}fadeLighting(){switch(this.clouds.fadeFactor){case 0:this._lighting=this._oldLighting;break;default:this._fadedLighting.lerpLighting(this._oldLighting,this._newLighting,this.clouds.fadeFactor),this._lighting=this._fadedLighting;break;case 1:this._lighting=this._newLighting,this._oldLighting.copyFrom(this._newLighting)}}updateLighting(e,t,n,r){this._oldLighting.copyFrom(this.lighting),this._newLighting.noonFactor=t,this._newLighting.globalFactor=n,this._newLighting.set(e),this._oldLighting.updateLegacy(),r===1&&this.clouds.requestFade(),this.fadeLighting()}get hasScreenSpaceReflections(){return this.frameRendererTarget!==3&&i(this.output)&&this.screenSpaceReflections.enabled&&this.reprojection.lastFrameColor!=null}get highlight(){return this.highlightLevel==null?null:this.highlights[this.highlightLevel]}get depth(){return this._depth}set depth(e){e&&(e.name=`geometry depth`),this._depth=e}get occluder(){return this.slot===10||this.slot===11?this.slot:null}}export{d as BindParameters,u as ViewportSize};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import"tslib";import"../core/shaderLibrary/shading/Gamma.glsl.js";import"../core/shaderModules/FloatBindUniform.js";import"../core/shaderModules/glsl.js";import"../core/shaderModules/Texture2DPassUniform.js";import"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import"../effects/glow/applyEmissiveGlow.glsl.js";import"../shaders/floatBlendScale.glsl.js";import"../shaders/ScreenSpacePassAtmosphere.glsl.js";import"../shaders/ToneMapping.glsl.js";import"../../../webgl/ShaderBuilder.js";export{a as EmissionCompositePassParameters,E as EmissionCompositeTechniqueConfiguration,c as build}from"../../../../chunks/EmissionComposite.glsl.js";
|
|
2
|
+
import"tslib";import"../core/shaderLibrary/shading/Gamma.glsl.js";import"../core/shaderModules/FloatBindUniform.js";import"../core/shaderModules/FloatPassUniform.js";import"../core/shaderModules/glsl.js";import"../core/shaderModules/Texture2DPassUniform.js";import"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import"../effects/glow/applyEmissiveGlow.glsl.js";import"../shaders/floatBlendScale.glsl.js";import"../shaders/ScreenSpacePassAtmosphere.glsl.js";import"../shaders/ToneMapping.glsl.js";import"../../../webgl/ShaderBuilder.js";export{a as EmissionCompositePassParameters,E as EmissionCompositeTechniqueConfiguration,c as build}from"../../../../chunks/EmissionComposite.glsl.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{releaseMaybe as t}from"../../../../core/maybe.js";import{watch as n,syncAndInitial as r}from"../../../../core/reactiveUtils.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";import{length as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{RenderNodeOutput as s}from"../../webgl.js";import{BlurEmission as c}from"../effects/glow/BlurEmission.js";import{E as l,a as u}from"../../../../chunks/EmissionComposite.glsl.js";import{EmissionCompositeTechnique as d}from"./EmissionCompositeTechnique.js";import{ColorAttachment1 as f,ColorAttachment0 as p}from"../../../webgl/enums.js";let m=class extends c{constructor(){super(...arguments),this.produces=s.COMPOSITE,this.consumes={required:[s.COMPOSITE]},this._configuration=new l,this._passParameters=new u}initialize(){this.addHandles([n(()=>this.bindParameters.emissions!==0,e=>this.produces=e?s.COMPOSITE:`disabled`,r)])}precompile(){this.bindParameters.emissions!==0&&(this._configuration.
|
|
2
|
+
import{__decorate as e}from"tslib";import{releaseMaybe as t}from"../../../../core/maybe.js";import{watch as n,syncAndInitial as r}from"../../../../core/reactiveUtils.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";import{length as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{RenderNodeOutput as s}from"../../webgl.js";import{BlurEmission as c}from"../effects/glow/BlurEmission.js";import{E as l,a as u}from"../../../../chunks/EmissionComposite.glsl.js";import{EmissionCompositeTechnique as d}from"./EmissionCompositeTechnique.js";import{ColorAttachment1 as f,ColorAttachment0 as p}from"../../../webgl/enums.js";let m=class extends c{constructor(){super(...arguments),this.produces=s.COMPOSITE,this.consumes={required:[s.COMPOSITE]},this._configuration=new l,this._passParameters=new u}initialize(){this.addHandles([n(()=>this.bindParameters.emissions!==0,e=>this.produces=e?s.COMPOSITE:`disabled`,r)])}precompile(){this.bindParameters.emissions!==0&&(this._configuration.applyBlur=!this.view.stage.renderView.fog?.renders&&this._hasBlur,super.precompile(),this._configuration.useFloatBlend=this.bindParameters.useFloatBlend.value,this.techniques.precompile(d,this._configuration))}get _needsEmissionBlur(){return this._configuration.applyBlur}render(){let e=this.input,n=e.getAttachment(f);if(!n?.attachment)return e;let r=o(this.bindParameters.camera.eye);this._passParameters.atmosphereC=r**2-this._atmosphereRadius**2,this._passParameters.color=e.getAttachment(p)?.attachment,this._passParameters.emission=n,this._passParameters.emissionFade=this.view.stage.renderView.fog?.renders?1:this.bindParameters.emissionFade,this._passParameters.scattering=this._configuration.applyBlur&&this.view.environmentView.weather?this.view.stage.renderView.fog?.strength??this.view.environment.weather.scattering:0,this._configuration.applyBlur&&this._renderEmissionMipMap();let i=this.renderingContext,a=this.techniques.get(d,this._configuration),s=this.acquireOutputFramebuffer();return i.clear(16384),i.bindTechnique(a,this.bindParameters,this._passParameters),i.screen.draw(),this._passParameters.mipmapTexture=t(this._passParameters.mipmapTexture),s.moveAttachments(e),s}};e([i()],m.prototype,`produces`,void 0),e([i()],m.prototype,`consumes`,void 0),m=e([a(`esri.views.3d.webgl-engine.lib.EmissionComposite`)],m);export{m as EmissionComposite};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import e from"../../../../core/Error.js";import{EventEmitter as t}from"../../../../core/Evented.js";import has from"../../../../core/has.js";import{
|
|
2
|
+
import e from"../../../../core/Error.js";import{EventEmitter as t}from"../../../../core/Evented.js";import{makeHandle as n}from"../../../../core/handleUtils.js";import has from"../../../../core/has.js";import{removeMaybe as r,disposeMaybe as i}from"../../../../core/maybe.js";import{throwIfAborted as a,onAbort as o,createAbortError as s}from"../../../../core/promiseUtils.js";import{isUint8Array as c,isArrayBuffer as l,isTypedArray as u}from"../../../../core/typedArrayUtil.js";import{generateUID as d}from"../../../../core/uid.js";import{isBlobProtocol as f,isDataProtocol as p}from"../../../../core/urlUtils.js";import{whenVideoPlayable as m}from"../../../../layers/support/videoUtils.js";import{requestImage as h}from"../../../../request/image.js";import{loadImage as g}from"../../../../request/loadImage.js";import{createTextureKTX1 as _,createTextureKTX2 as v,createTextureBasis as y,estimateMemoryKTX2 as b,estimateMemoryBasis as x}from"./BasisUtil.js";import{createDDSTexture as S}from"./DDSUtil.js";import{ensureImageMaxSize as C}from"./textureUtils.js";import{assert as w}from"./Util.js";import{Texture as T}from"../../../webgl/Texture.js";import{TextureDescriptor as E}from"../../../webgl/TextureDescriptor.js";import{isCompressedFormat as D,isSizedPixelFormat as O,isSizedDepthFormat as k,isSizedDepthStencilFormat as A}from"../../../webgl/textureUtils.js";import{getFormatComponents as j}from"../../../webgl/Util.js";const M=!!has(`esri-tests-disable-gpu-memory-measurements`);class N{constructor(e,n){this._data=e,this.id=d(),this.events=new t,this._videoFrameHandle=null,this._videoFrameToken=-1,this._parameters={...I,...n},this._startPreload(e)}dispose(){this.unload(),this._data=this.update=void 0}_startPreload(e){e instanceof HTMLVideoElement?(this.update=t=>this._update(e,t),this._startPreloadVideoElement(e)):e instanceof HTMLImageElement&&this._startPreloadImageElement(e)}_startPreloadVideoElement(e){if(e.srcObject==null&&!f(e.src)&&(e.preload!==`auto`||!e.crossOrigin)&&(e.preload=`auto`,e.crossOrigin=`anonymous`,e.src=e.src,e.paused&&e.autoplay)){let t=[];m(e,e=>t.push(e)).then(()=>{e.play()}).finally(()=>t.forEach(e=>e.remove()))}}_startPreloadImageElement(e){p(e.src)||f(e.src)||e.crossOrigin||(e.crossOrigin=`anonymous`,e.src=e.src)}_createDescriptor(e){let t=new E;return t.wrapMode=this._parameters.wrap??10497,t.flipped=!this._parameters.noUnpackFlip,t.samplingMode=this._parameters.mipmap?9987:9729,t.hasMipmap=!!this._parameters.mipmap,t.preMultiplyAlpha=!!this._parameters.preMultiplyAlpha,t.maxAnisotropy=this._parameters.maxAnisotropy??(this._parameters.mipmap?e.parameters.maxMaxAnisotropy:1),t.dataType=this._parameters.dataType??t.dataType,t.pixelFormat=this._parameters.pixelFormat??t.pixelFormat,t.internalFormat=this._parameters.internalFormat??t.internalFormat,t.isImmutable=this._parameters.immutable===!0&&L(this._parameters.internalFormat),t}get texture(){return this._texture??this._emptyTexture}get loaded(){return this._texture!=null}get usedMemory(){return M?0:this._texture?.usedMemory??P(this._data,this._parameters)}load(e){if(this._loadingPromise)return this._loadingPromise;if(this._texture)return this._texture;let t=this._data;return t==null?(this._texture=new T(e,this._createDescriptor(e),null),this._texture):(this._emptyTexture=e.emptyTexture,this._parameters.reloadable||(this._data=void 0),typeof t==`string`?this._loadFromURL(e,t):t instanceof Image?this._loadFromImageElement(e,t):t instanceof HTMLVideoElement?this._loadFromVideoElement(e,t):t instanceof ImageData||t instanceof HTMLCanvasElement?this._loadFromImage(e,t):c(t)&&this._parameters.encoding===`image/vnd-ms.dds`?this._loadFromDDSData(e,t):l(t)&&this._parameters.encoding===`image/vnd-ms.dds`?this._loadFromDDSData(e,new Uint8Array(t)):c(t)&&this._parameters.encoding===`image/ktx`?this._loadFromKTX1(e,t):l(t)&&this._parameters.encoding===`image/ktx`?this._loadFromKTX1(e,new Uint8Array(t)):(l(t)||c(t))&&this._parameters.encoding===`image/ktx2`?this._loadFromKTX2(e,t):(l(t)||c(t))&&this._parameters.encoding===`image/x.basis`?this._loadFromBasis(e,t):l(t)?this._loadFromPixelData(e,new Uint8Array(t)):u(t)?this._loadFromPixelData(e,t):null)}_update(e,t){return this._texture==null||t===this._videoFrameToken||e.readyState<HTMLMediaElement.HAVE_CURRENT_DATA?t:(this._texture.setData(e),this._parameters.updateCallback&&this._parameters.updateCallback(),this._videoFrameToken)}_trackVideoFrames(e){let t=()=>{this._videoFrameToken++,r=e.requestVideoFrameCallback(t)},r=e.requestVideoFrameCallback(t);this._videoFrameHandle=n(()=>e.cancelVideoFrameCallback(r))}_loadFromDDSData(e,t){return this._texture=S(e,this._createDescriptor(e),t),this._emptyTexture=null,this._texture}_loadFromKTX1(e,t){return this._texture=_(e,this._createDescriptor(e),t),this._emptyTexture=null,this._texture}_loadFromKTX2(e,t){return this._loadAsync(()=>v(e,this._createDescriptor(e),t).then(e=>(this._texture=e,e)))}_loadFromBasis(e,t){return this._loadAsync(()=>y(e,this._createDescriptor(e),t).then(e=>(this._texture=e,e)))}_loadFromPixelData(e,t){w(this._parameters.width>0&&this._parameters.height>0);let n=this._createDescriptor(e);return(n.pixelFormat===6407||n.pixelFormat===6408)&&(n.compress=this._parameters.compressionOptions),n.width=this._parameters.width??0,n.height=this._parameters.height??0,this._texture=new T(e,n,t),this._texture}_loadFromURL(e,t){return this._loadAsync(async n=>{let r=await h(t,{signal:n});return a(n),this._loadFromImage(e,r)})}_loadFromImageElement(e,t){return t.complete?this._loadFromImage(e,t):this._loadAsync(async n=>{let r=await g(t,t.src,!1,n);return a(n),this._loadFromImage(e,r)})}_loadFromVideoElement(e,t){return t.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA?this._loadFromImage(e,t):this._loadFromVideoElementAsync(e,t)}_loadFromVideoElementAsync(t,n){return this._loadAsync(i=>new Promise((a,c)=>{let l=()=>{n.removeEventListener(`loadeddata`,u),n.removeEventListener(`error`,d),r(f)},u=()=>{n.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA&&(l(),a(this._loadFromImage(t,n)))},d=t=>{l(),c(t||new e(`texture:load-error`,`Failed to load video`))};n.addEventListener(`loadeddata`,u),n.addEventListener(`error`,d);let f=o(i,()=>d(s()))}))}_loadFromImage(e,t){let n=t instanceof HTMLVideoElement,r=n?t:C(t,e.parameters),i=F(r);this._parameters.width=i.width,this._parameters.height=i.height;let a=this._createDescriptor(e);return a.width=i.width,a.height=i.height,a.compress=this._parameters.compressionOptions,this._texture=new T(e,a,r),n&&this._trackVideoFrames(t),this._emptyTexture=null,this.events.emit(`loaded`),this._texture}_loadAsync(e){let t=new AbortController;this._loadingController=t;let n=e(t.signal);this._loadingPromise=n;let r=()=>{this._loadingController===t&&(this._loadingController=null),this._loadingPromise===n&&(this._loadingPromise=null),this._emptyTexture=null};return n.then(r,r),n}unload(){if(this._videoFrameHandle=r(this._videoFrameHandle),this._videoFrameToken=-1,this._texture=i(this._texture),this._emptyTexture=null,this._loadingController!=null){let e=this._loadingController;this._loadingController=null,this._loadingPromise=null,e.abort()}this.events.emit(`unloaded`)}get parameters(){return this._parameters}}function P(e,t){if(e==null)return 0;if(l(e)||c(e))return t.encoding===`image/ktx2`?b(e,!!t.mipmap):t.encoding===`image/x.basis`?x(e,!!t.mipmap):e.byteLength;let{width:n,height:r}=e instanceof Image||e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement?F(e):t,i=t.pixelFormat??6408,a=j(i);return(t.mipmap?4/3:1)*n*r*a||0}function F(e){return e instanceof HTMLVideoElement?{width:e.videoWidth,height:e.videoHeight}:e}const I={wrap:{s:10497,t:10497},mipmap:!0,noUnpackFlip:!1,preMultiplyAlpha:!1};function L(e){return e!=null&&(D(e)||O(e)||k(e)||A(e))}export{N as ManagedTexture};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import e from"../../../../core/ObjectPool.js";import t from"../../../../core/PooledArray.js";import{lerp as n,scale as r,add as i,squaredDistance as a}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as o,create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphereCenterRadius as c,intersectsSphere as l}from"../../../../geometry/support/frustumPlanes.js";import{wrap as u}from"../../../../geometry/support/ray.js";import{Sphere as d}from"../../../../geometry/support/sphere.js";import{rayBoxTest as f}from"./Util.js";class p{get bounds(){return this._root.bounds}get halfSize(){return this._root.halfSize}get root(){return this._root.node}get maximumObjectsPerNode(){return this._maximumObjectsPerNode}get maximumDepth(){return this._maximumDepth}get objectCount(){return this._objectCount}constructor(e,t){this.objectToBoundingSphere=e,this._maximumObjectsPerNode=10,this._maximumDepth=20,this._degenerateObjects=new Set,this._root=new m,this._objectCount=0,t&&(t.maximumObjectsPerNode!==void 0&&(this._maximumObjectsPerNode=t.maximumObjectsPerNode),t.maximumDepth!==void 0&&(this._maximumDepth=t.maximumDepth))}destroy(){this._degenerateObjects.clear(),m.clearPool(),P[0]=null,B.prune(),G.prune()}add(e){let t=Array.from(e);this._grow(t);let n=m.acquire();for(let e of t)++this._objectCount,this._isDegenerate(e)?this._degenerateObjects.add(e):(n.init(this._root),this._add(e,n));m.release(n)}remove(e,t=null){this._objectCount-=e.length;let n=m.acquire();for(let r of e){let e=t??this.objectToBoundingSphere(r);A(e.radius)?(n.init(this._root),v(r,e,n)):this._degenerateObjects.delete(r)}m.release(n),this._shrink()}update(e,t){if(!A(t.radius)&&this._isDegenerate(e))return;let n=F(e);this.remove(n,t),this.add(n)}forEachAlongRay(e,t,n){let r=u(e,t);g(this._root,e=>{if(!b(r,e))return!1;let t=e.node;return t.terminals.forAll(e=>{this._intersectsObject(r,e)&&n(e)}),t.residents!==null&&t.residents.forAll(e=>{this._intersectsObject(r,e)&&n(e)}),!0})}forEachAlongRayWithVerticalOffset(e,t,n,r){let i=u(e,t);g(this._root,e=>{if(!x(i,e,r))return!1;let t=e.node;return t.terminals.forAll(e=>{this._intersectsObjectWithOffset(i,e,r)&&n(e)}),t.residents!==null&&t.residents.forAll(e=>{this._intersectsObjectWithOffset(i,e,r)&&n(e)}),!0})}forEach(e){for(let t of this.values())e(t)}*values(){for(let e of this._nodeIteratorValues()){let t=e.node;yield*t.terminals,t.residents!==null&&(yield*t.residents)}yield*this.degenerateObjectValues()}forEachDegenerateObject(e){this._degenerateObjects.forEach(e)}*degenerateObjectValues(){yield*this._degenerateObjects.values()}findClosest(e,t,n,a=()=>!0,o=1/0){let s=1/0,u=1/0,d=null,f=O(e,t),p=r=>{if(--o,!a(r))return;let i=this.objectToBoundingSphere(r);if(!l(n,i))return;let c=k(e,t,i.center),f=c-i.radius,p=c+i.radius;f<s&&(s=f,u=p,d=r)};return _(this._root,a=>{if(o<=0||!c(n,a.bounds.center,a.bounds.radius*2)||(r(L,f,a.halfSize*2),i(L,L,a.bounds.center),k(e,t,L)>u))return!1;let s=a.node;return s.terminals.forAll(e=>p(e)),s.residents!==null&&s.residents.forAll(e=>p(e)),!0},e,t),d}forEachInDepthRange(e,t,n,a,o,s,u){let d=-1/0,f=1/0,p={setRange:e=>{n===1?(d=Math.max(d,e.near),f=Math.min(f,e.far)):(d=Math.max(d,-e.far),f=Math.min(f,-e.near))}};p.setRange(a);let m=k(t,n,e),h=O(t,n),g=O(t,-n),v=e=>{if(!u(e))return;let r=this.objectToBoundingSphere(e),i=k(t,n,r.center)-m,a=i-r.radius,c=i+r.radius;a>f||c<d||!l(s,r)||o(e,p)};_(this._root,e=>{if(!c(s,e.bounds.center,e.bounds.radius*2)||(r(L,h,e.halfSize*2),i(L,L,e.bounds.center),k(t,n,L)-m>f)||(r(L,g,e.halfSize*2),i(L,L,e.bounds.center),k(t,n,L)-m<d))return!1;let a=e.node;return a.terminals.forAll(e=>v(e)),a.residents!==null&&a.residents.forAll(e=>v(e)),!0},t,n)}forEachNode(e){g(this._root,t=>e(t.node,t.bounds,t.halfSize,t.depth))}forEachIntersectingFrustum(e,t,n=()=>!0){for(let r of this.intersectingFrustumValues(e,n))t(r)}*intersectingFrustumValues(e,t=()=>!0){for(let n of this._nodeIteratorValues(t=>c(e,t.bounds.center,t.bounds.radius*2))){let r=n.node;for(let n of r.terminals)t(n)&&l(e,this.objectToBoundingSphere(n))&&(yield n);if(r.residents!==null)for(let n of r.residents)t(n)&&l(e,this.objectToBoundingSphere(n))&&(yield n)}}*_nodeIteratorValues(e=()=>!0){yield*h(this._root,e)}forEachNeighbor(e,t){let n=t.radius,r=t.center,i=n=>{let r=this.objectToBoundingSphere(n);return!t.intersects(r)||e(n)},o=!0,s=e=>{o&&=i(e)};g(this._root,e=>{let t=e.bounds.radius*2,i=n+t;if(a(e.bounds.center,r)-i*i>0)return!1;let c=e.node;return c.terminals.forAll(s),o&&c.residents!==null&&c.residents.forAll(s),o}),o&&this.forEachDegenerateObject(s)}_intersectsObject(e,t){let n=this.objectToBoundingSphere(t);return n.radius>0?n.intersectRay(e):!0}_intersectsObjectWithOffset(e,t,n){let r=this.objectToBoundingSphere(t);return r.radius>0?n.applyToBoundingSphere(r).intersectRay(e):!0}_add(e,t){t.advanceTo(this.objectToBoundingSphere(e))?t.node.terminals.push(e):(t.node.residents.push(e),t.node.residents.length>this._maximumObjectsPerNode&&t.depth<this._maximumDepth&&this._split(t))}_split(e){let t=e.node.residents;e.node.residents=null;for(let n=0;n<t.length;n++){let r=m.acquire().init(e);this._add(t.at(n),r),m.release(r)}}_grow(e){if(E(e,e=>this.objectToBoundingSphere(e),V),A(V.radius)&&!this._fitsInsideTree(V)){if(S(this._root.node))this._root.bounds.copyFrom(V),this._root.halfSize=this._root.bounds.radius*1.25,this._root.updateBoundsRadiusFromHalfSize();else{let e=this._rootBoundsForRootAsSubNode(V);this._placingRootViolatesMaxDepth(e)?this._rebuildTree(V,e):this._growRootAsSubNode(e),m.release(e)}}}_rebuildTree(e,t){H.center=t.bounds.center,H.radius=t.halfSize,E([e,H],e=>e,U);let n=m.acquire().init(this._root);this._root.initFrom(null,U,U.radius),this._root.increaseHalfSize(1.25),g(n,e=>(this.add(e.node.terminals.data),e.node.residents!==null&&this.add(e.node.residents.data),!0)),m.release(n)}_placingRootViolatesMaxDepth(e){let t=Math.log(e.halfSize/this._root.halfSize)*Math.LOG2E,n=0;return g(this._root,e=>(n=Math.max(n,e.depth),n+t<=this._maximumDepth)),n+t>this._maximumDepth}_rootBoundsForRootAsSubNode(e){let t=e.radius,n=e.center,r=-1/0,i=this._root.bounds.center,a=this._root.halfSize;for(let e=0;e<3;e++){let o=i[e]-a-(n[e]-t),s=n[e]+t-(i[e]+a),c=Math.max(0,Math.ceil(o/(a*2))),l=Math.max(0,Math.ceil(s/(a*2)))+1,u=2**Math.ceil(Math.log(c+l)*Math.LOG2E);r=Math.max(r,u),W[e].min=c,W[e].max=l}for(let e=0;e<3;e++){let t=W[e].min,n=W[e].max,o=(r-(t+n))/2;t+=Math.ceil(o),n+=Math.floor(o);let s=i[e]-a-t*a*2;I.center[e]=s+(n+t)*a}let o=r*a;return I.radius=o*N,m.acquire().initFrom(null,I,o,0)}_growRootAsSubNode(e){let t=this._root.node;V.center=this._root.bounds.center,V.radius=this._root.halfSize,this._root.init(e),e.advanceTo(V,null,!0),e.node.children=t.children,e.node.residents=t.residents,e.node.terminals=t.terminals}_shrink(){for(;;){let e=this._findShrinkIndex();if(e===-1)break;this._root.advance(e),this._root.depth=0}}_findShrinkIndex(){if(this._root.node.terminals.length!==0||this._root.isLeaf())return-1;let e=null,t=this._root.node.children,n=0,r=0;for(;r<t.length&&e==null;)n=r++,e=t[n];for(;r<t.length;)if(t[r++])return-1;return n}_isDegenerate(e){return!A(this.objectToBoundingSphere(e).radius)}_fitsInsideTree(e){let t=this._root.bounds,n=this._root.halfSize;return e.radius<=n&&e.center[0]>=t.center[0]-n&&e.center[0]<=t.center[0]+n&&e.center[1]>=t.center[1]-n&&e.center[1]<=t.center[1]+n&&e.center[2]>=t.center[2]-n&&e.center[2]<=t.center[2]+n}_nodeToJSON(e){return{children:e.children.map(e=>e?this._nodeToJSON(e):null),residents:e.residents?.map(e=>this.objectToBoundingSphere(e)),terminals:e.terminals?.map(e=>this.objectToBoundingSphere(e))}}}class m{constructor(){this.bounds=new d,this.halfSize=0,this.initFrom(null,null,0,0)}init(e){return this.initFrom(e.node,e.bounds,e.halfSize,e.depth)}initFrom(e,t,n,r=this.depth){return this.node=e??m.createEmptyNode(),t&&this.bounds.copyFrom(t),this.halfSize=n,this.depth=r,this}increaseHalfSize(e){this.halfSize*=e,this.updateBoundsRadiusFromHalfSize()}updateBoundsRadiusFromHalfSize(){this.bounds.radius=this.halfSize*N}advance(e){let t=this.node.children[e];t||(t=m.createEmptyNode(),this.node.children[e]=t),this.node=t,this.halfSize/=2,this.depth++;let n=j[e];return this.bounds.center[0]+=n[0]*this.halfSize,this.bounds.center[1]+=n[1]*this.halfSize,this.bounds.center[2]+=n[2]*this.halfSize,this.updateBoundsRadiusFromHalfSize(),this}advanceTo(e,t,n=!1){for(;;){if(this.isTerminalFor(e))return t?.(this,-1),!0;if(this.isLeaf()){if(!n)return t?.(this,-1),!1;this.node.residents=null}let r=this._childIndex(e);t?.(this,r),this.advance(r)}}isLeaf(){return this.node.residents!=null}isTerminalFor(e){return e.radius>this.halfSize/2}_childIndex(e){let t=this.bounds.center;return+(t[0]<e.center[0])+(t[1]<e.center[1]?2:0)+(t[2]<e.center[2]?4:0)}static createEmptyNode(){return{children:[null,null,null,null,null,null,null,null],terminals:new t({shrink:!0}),residents:new t({shrink:!0})}}static{this._pool=new e(()=>new m)}static acquire(){return m._pool.acquire()}static release(e){m._pool.release(e)}static clearPool(){m._pool.prune()}}function*h(e,t=()=>!0){let n=[m.acquire().init(e)];for(;n.length!==0;){let e=n.pop();if(t(e)){if(yield e,!e.isLeaf())for(let t=0;t<e.node.children.length;t++)e.node.children[t]&&n.push(m.acquire().init(e).advance(t));m.release(e)}}}function g(e,t){let n=h(e,t);for(let e of n);}function _(e,t,n,r=1){let i=m.acquire().init(e),a=[i];for(D(n,r,K);a.length!==0;){if(i=a.pop(),t(i)&&!i.isLeaf())for(let e=7;e>=0;--e){let t=K[e];i.node.children[t]&&a.push(m.acquire().init(i).advance(t))}m.release(i)}}function v(e,t,n){B.clear();let r=n.advanceTo(t,(e,t)=>{B.push(e.node),B.push(t)})?n.node.terminals:n.node.residents;if(r.removeUnordered(e),r.length===0)for(let e=B.length-2;e>=0&&y(B.data[e],B.data[e+1]);e-=2);}function y(e,n){return n>=0&&(e.children[n]=null),S(e)?(e.residents===null&&(e.residents=new t({shrink:!0})),!0):!1}function b(e,t){return T(t.bounds.center,-t.halfSize*2,R),T(t.bounds.center,t.halfSize*2,z),f(e.origin,e.direction,R,z)}function x(e,t,n){return T(t.bounds.center,-t.halfSize*2,R),T(t.bounds.center,t.halfSize*2,z),n.applyToMinMax(R,z),f(e.origin,e.direction,R,z)}function S(e){if(e.terminals.length!==0)return!1;if(e.residents!==null)return e.residents.length===0;for(let t=0;t<e.children.length;t++)if(e.children[t])return!1;return!0}function C(e,t){e[0]=Math.min(e[0],t.center[0]-t.radius),e[1]=Math.min(e[1],t.center[1]-t.radius),e[2]=Math.min(e[2],t.center[2]-t.radius)}function w(e,t){e[0]=Math.max(e[0],t.center[0]+t.radius),e[1]=Math.max(e[1],t.center[1]+t.radius),e[2]=Math.max(e[2],t.center[2]+t.radius)}function T(e,t,n){n[0]=e[0]+t,n[1]=e[1]+t,n[2]=e[2]+t}function E(e,t,r){R[0]=1/0,R[1]=1/0,R[2]=1/0,z[0]=-1/0,z[1]=-1/0,z[2]=-1/0;for(let n of e){let e=t(n);A(e.radius)&&(C(R,e),w(z,e))}n(r.center,R,z,.5),r.radius=Math.max(z[0]-R[0],z[1]-R[1],z[2]-R[2])/2}function D(e,t,n){if(!G.length)for(let e=0;e<8;++e)G.push({index:0,distance:0});for(let n=0;n<8;++n){let r=j[n];G.data[n].index=n,G.data[n].distance=k(e,t,r)}G.sort((e,t)=>e.distance-t.distance);for(let e=0;e<8;++e)n[e]=G.data[e].index}function O(e,t){let n=1/0,r;for(let i=0;i<8;++i){let a=k(e,t,M[i]);a<n&&(n=a,r=M[i])}return r}function k(e,t,n){return t*(e[0]*n[0]+e[1]*n[1]+e[2]*n[2])}function A(e){return!isNaN(e)&&e!==-1/0&&e!==1/0&&e>0}const j=[o(-1,-1,-1),o(1,-1,-1),o(-1,1,-1),o(1,1,-1),o(-1,-1,1),o(1,-1,1),o(-1,1,1),o(1,1,1)],M=[o(-1,-1,-1),o(-1,-1,1),o(-1,1,-1),o(-1,1,1),o(1,-1,-1),o(1,-1,1),o(1,1,-1),o(1,1,1)],N=Math.sqrt(3),P=[null];function F(e){return P[0]=e,P}const I=new d,L=s(),R=s(),z=s(),B=new t,V=new d,H=new d,U=new d,W=[{min:0,max:0},{min:0,max:0},{min:0,max:0}],G=new t,K=[0,0,0,0,0,0,0,0];export{p as Octree};
|
|
2
|
+
import e from"../../../../core/ObjectPool.js";import t from"../../../../core/PooledArray.js";import{lerp as n,scale as r,add as i,squaredDistance as a}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as o,create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphereCenterRadius as c,intersectsSphere as l}from"../../../../geometry/support/frustumPlanes.js";import{wrap as u}from"../../../../geometry/support/ray.js";import{Sphere as d}from"../../../../geometry/support/sphere.js";import{rayBoxTest as f}from"./Util.js";class p{get bounds(){return this._root.bounds}get halfSize(){return this._root.halfSize}get root(){return this._root.node}get maximumObjectsPerNode(){return this._maximumObjectsPerNode}get maximumDepth(){return this._maximumDepth}get objectCount(){return this._objectCount}constructor(e,t){this.objectToBoundingSphere=e,this._maximumObjectsPerNode=10,this._maximumDepth=20,this._degenerateObjects=new Set,this._root=new m,this._objectCount=0,t&&(t.maximumObjectsPerNode!==void 0&&(this._maximumObjectsPerNode=t.maximumObjectsPerNode),t.maximumDepth!==void 0&&(this._maximumDepth=t.maximumDepth))}destroy(){this._degenerateObjects.clear(),m.clearPool(),P[0]=null,B.prune(),G.prune()}add(e){let t=Array.from(e);this._grow(t);let n=m.acquire();for(let e of t)++this._objectCount,this._isDegenerate(e)?this._degenerateObjects.add(e):(n.init(this._root),this._add(e,n));m.release(n)}remove(e,t=null){this._objectCount-=e.length;let n=m.acquire();for(let r of e){let e=t??this.objectToBoundingSphere(r);A(e.radius)?(n.init(this._root),v(r,e,n)):this._degenerateObjects.delete(r)}m.release(n),this._shrink()}update(e,t){if(!A(t.radius)&&this._isDegenerate(e))return;let n=F(e);this.remove(n,t),this.add(n)}forEachAlongRay(e,t,n){let r=u(e,t);g(this._root,e=>{if(!b(r,e))return!1;let t=e.node;return t.terminals.forAll(e=>{this._intersectsObject(r,e)&&n(e)}),t.residents!==null&&t.residents.forAll(e=>{this._intersectsObject(r,e)&&n(e)}),!0})}forEachAlongRayWithVerticalOffset(e,t,n,r){let i=u(e,t);g(this._root,e=>{if(!x(i,e,r))return!1;let t=e.node;return t.terminals.forAll(e=>{this._intersectsObjectWithOffset(i,e,r)&&n(e)}),t.residents!==null&&t.residents.forAll(e=>{this._intersectsObjectWithOffset(i,e,r)&&n(e)}),!0})}forEach(e){for(let t of this.values())e(t)}*values(){for(let e of this._nodeIteratorValues()){let t=e.node;yield*t.terminals,t.residents!==null&&(yield*t.residents)}yield*this.degenerateObjectValues()}forEachDegenerateObject(e){this._degenerateObjects.forEach(e)}*degenerateObjectValues(){yield*this._degenerateObjects.values()}findClosest(e,t,n,a=()=>!0,o=1/0){let s=1/0,u=1/0,f=null,p=O(e,t),m=new d,h=r=>{if(--o,!a(r))return;let i=this.objectToBoundingSphere(r,m);if(!l(n,i))return;let c=k(e,t,i.center),d=c-i.radius,p=c+i.radius;d<s&&(s=d,u=p,f=r)};return _(this._root,a=>{if(o<=0||!c(n,a.bounds.center,a.bounds.radius*2)||(r(L,p,a.halfSize*2),i(L,L,a.bounds.center),k(e,t,L)>u))return!1;let s=a.node;return s.terminals.forAll(h),s.residents!==null&&s.residents.forAll(h),!0},e,t),f}forEachInDepthRange(e,t,n,a,o,s,u){let f=-1/0,p=1/0,m={setRange:e=>{n===1?(f=Math.max(f,e.near),p=Math.min(p,e.far)):(f=Math.max(f,-e.far),p=Math.min(p,-e.near))}};m.setRange(a);let h=k(t,n,e),g=O(t,n),v=O(t,-n),y=new d,b=e=>{if(!u(e))return;let r=this.objectToBoundingSphere(e,y),i=k(t,n,r.center)-h,a=i-r.radius,c=i+r.radius;a>p||c<f||!l(s,r)||o(e,m)};_(this._root,e=>{if(!c(s,e.bounds.center,e.bounds.radius*2)||(r(L,g,e.halfSize*2),i(L,L,e.bounds.center),k(t,n,L)-h>p)||(r(L,v,e.halfSize*2),i(L,L,e.bounds.center),k(t,n,L)-h<f))return!1;let a=e.node;return a.terminals.forAll(b),a.residents!==null&&a.residents.forAll(b),!0},t,n)}forEachNode(e){g(this._root,t=>e(t.node,t.bounds,t.halfSize,t.depth))}forEachIntersectingFrustum(e,t,n=()=>!0){for(let r of this.intersectingFrustumValues(e,n))t(r)}*intersectingFrustumValues(e,t=()=>!0){for(let n of this._nodeIteratorValues(t=>c(e,t.bounds.center,t.bounds.radius*2))){let r=n.node;for(let n of r.terminals)t(n)&&l(e,this.objectToBoundingSphere(n))&&(yield n);if(r.residents!==null)for(let n of r.residents)t(n)&&l(e,this.objectToBoundingSphere(n))&&(yield n)}}*_nodeIteratorValues(e=()=>!0){yield*h(this._root,e)}forEachNeighbor(e,t){let n=t.radius,r=t.center,i=n=>{let r=this.objectToBoundingSphere(n);return!t.intersects(r)||e(n)},o=!0,s=e=>{o&&=i(e)};g(this._root,e=>{let t=e.bounds.radius*2,i=n+t;if(a(e.bounds.center,r)-i*i>0)return!1;let c=e.node;return c.terminals.forAll(s),o&&c.residents!==null&&c.residents.forAll(s),o}),o&&this.forEachDegenerateObject(s)}_intersectsObject(e,t){let n=this.objectToBoundingSphere(t);return n.radius>0?n.intersectRay(e):!0}_intersectsObjectWithOffset(e,t,n){let r=this.objectToBoundingSphere(t);return r.radius>0?n.applyToBoundingSphere(r).intersectRay(e):!0}_add(e,t){t.advanceTo(this.objectToBoundingSphere(e))?t.node.terminals.push(e):(t.node.residents.push(e),t.node.residents.length>this._maximumObjectsPerNode&&t.depth<this._maximumDepth&&this._split(t))}_split(e){let t=e.node.residents;e.node.residents=null;for(let n=0;n<t.length;n++){let r=m.acquire().init(e);this._add(t.at(n),r),m.release(r)}}_grow(e){if(E(e,e=>this.objectToBoundingSphere(e),V),A(V.radius)&&!this._fitsInsideTree(V)){if(S(this._root.node))this._root.bounds.copyFrom(V),this._root.halfSize=this._root.bounds.radius*1.25,this._root.updateBoundsRadiusFromHalfSize();else{let e=this._rootBoundsForRootAsSubNode(V);this._placingRootViolatesMaxDepth(e)?this._rebuildTree(V,e):this._growRootAsSubNode(e),m.release(e)}}}_rebuildTree(e,t){H.center=t.bounds.center,H.radius=t.halfSize,E([e,H],e=>e,U);let n=m.acquire().init(this._root);this._root.initFrom(null,U,U.radius),this._root.increaseHalfSize(1.25),g(n,e=>(this.add(e.node.terminals.data),e.node.residents!==null&&this.add(e.node.residents.data),!0)),m.release(n)}_placingRootViolatesMaxDepth(e){let t=Math.log(e.halfSize/this._root.halfSize)*Math.LOG2E,n=0;return g(this._root,e=>(n=Math.max(n,e.depth),n+t<=this._maximumDepth)),n+t>this._maximumDepth}_rootBoundsForRootAsSubNode(e){let t=e.radius,n=e.center,r=-1/0,i=this._root.bounds.center,a=this._root.halfSize;for(let e=0;e<3;e++){let o=i[e]-a-(n[e]-t),s=n[e]+t-(i[e]+a),c=Math.max(0,Math.ceil(o/(a*2))),l=Math.max(0,Math.ceil(s/(a*2)))+1,u=2**Math.ceil(Math.log(c+l)*Math.LOG2E);r=Math.max(r,u),W[e].min=c,W[e].max=l}for(let e=0;e<3;e++){let t=W[e].min,n=W[e].max,o=(r-(t+n))/2;t+=Math.ceil(o),n+=Math.floor(o);let s=i[e]-a-t*a*2;I.center[e]=s+(n+t)*a}let o=r*a;return I.radius=o*N,m.acquire().initFrom(null,I,o,0)}_growRootAsSubNode(e){let t=this._root.node;V.center=this._root.bounds.center,V.radius=this._root.halfSize,this._root.init(e),e.advanceTo(V,null,!0),e.node.children=t.children,e.node.residents=t.residents,e.node.terminals=t.terminals}_shrink(){for(;;){let e=this._findShrinkIndex();if(e===-1)break;this._root.advance(e),this._root.depth=0}}_findShrinkIndex(){if(this._root.node.terminals.length!==0||this._root.isLeaf())return-1;let e=null,t=this._root.node.children,n=0,r=0;for(;r<t.length&&e==null;)n=r++,e=t[n];for(;r<t.length;)if(t[r++])return-1;return n}_isDegenerate(e){return!A(this.objectToBoundingSphere(e).radius)}_fitsInsideTree(e){let t=this._root.bounds,n=this._root.halfSize;return e.radius<=n&&e.center[0]>=t.center[0]-n&&e.center[0]<=t.center[0]+n&&e.center[1]>=t.center[1]-n&&e.center[1]<=t.center[1]+n&&e.center[2]>=t.center[2]-n&&e.center[2]<=t.center[2]+n}_nodeToJSON(e){return{children:e.children.map(e=>e?this._nodeToJSON(e):null),residents:e.residents?.map(e=>this.objectToBoundingSphere(e)),terminals:e.terminals?.map(e=>this.objectToBoundingSphere(e))}}}class m{constructor(){this.bounds=new d,this.halfSize=0,this.initFrom(null,null,0,0)}init(e){return this.initFrom(e.node,e.bounds,e.halfSize,e.depth)}initFrom(e,t,n,r=this.depth){return this.node=e??m.createEmptyNode(),t&&this.bounds.copyFrom(t),this.halfSize=n,this.depth=r,this}increaseHalfSize(e){this.halfSize*=e,this.updateBoundsRadiusFromHalfSize()}updateBoundsRadiusFromHalfSize(){this.bounds.radius=this.halfSize*N}advance(e){let t=this.node.children[e];t||(t=m.createEmptyNode(),this.node.children[e]=t),this.node=t,this.halfSize/=2,this.depth++;let n=j[e];return this.bounds.center[0]+=n[0]*this.halfSize,this.bounds.center[1]+=n[1]*this.halfSize,this.bounds.center[2]+=n[2]*this.halfSize,this.updateBoundsRadiusFromHalfSize(),this}advanceTo(e,t,n=!1){for(;;){if(this.isTerminalFor(e))return t?.(this,-1),!0;if(this.isLeaf()){if(!n)return t?.(this,-1),!1;this.node.residents=null}let r=this._childIndex(e);t?.(this,r),this.advance(r)}}isLeaf(){return this.node.residents!=null}isTerminalFor(e){return e.radius>this.halfSize/2}_childIndex(e){let t=this.bounds.center;return+(t[0]<e.center[0])+(t[1]<e.center[1]?2:0)+(t[2]<e.center[2]?4:0)}static createEmptyNode(){return{children:[null,null,null,null,null,null,null,null],terminals:new t({shrink:!0}),residents:new t({shrink:!0})}}static{this._pool=new e(()=>new m)}static acquire(){return m._pool.acquire()}static release(e){m._pool.release(e)}static clearPool(){m._pool.prune()}}function*h(e,t=()=>!0){let n=[m.acquire().init(e)];for(;n.length!==0;){let e=n.pop();if(t(e)){if(yield e,!e.isLeaf())for(let t=0;t<e.node.children.length;t++)e.node.children[t]&&n.push(m.acquire().init(e).advance(t));m.release(e)}}}function g(e,t){let n=h(e,t);for(let e of n);}function _(e,t,n,r=1){let i=m.acquire().init(e),a=[i];for(D(n,r,K);a.length!==0;){if(i=a.pop(),t(i)&&!i.isLeaf())for(let e=7;e>=0;--e){let t=K[e];i.node.children[t]&&a.push(m.acquire().init(i).advance(t))}m.release(i)}}function v(e,t,n){B.clear();let r=n.advanceTo(t,(e,t)=>{B.push(e.node),B.push(t)})?n.node.terminals:n.node.residents;if(r.removeUnordered(e),r.length===0)for(let e=B.length-2;e>=0&&y(B.data[e],B.data[e+1]);e-=2);}function y(e,n){return n>=0&&(e.children[n]=null),S(e)?(e.residents===null&&(e.residents=new t({shrink:!0})),!0):!1}function b(e,t){return T(t.bounds.center,-t.halfSize*2,R),T(t.bounds.center,t.halfSize*2,z),f(e.origin,e.direction,R,z)}function x(e,t,n){return T(t.bounds.center,-t.halfSize*2,R),T(t.bounds.center,t.halfSize*2,z),n.applyToMinMax(R,z),f(e.origin,e.direction,R,z)}function S(e){if(e.terminals.length!==0)return!1;if(e.residents!==null)return e.residents.length===0;for(let t=0;t<e.children.length;t++)if(e.children[t])return!1;return!0}function C(e,t){e[0]=Math.min(e[0],t.center[0]-t.radius),e[1]=Math.min(e[1],t.center[1]-t.radius),e[2]=Math.min(e[2],t.center[2]-t.radius)}function w(e,t){e[0]=Math.max(e[0],t.center[0]+t.radius),e[1]=Math.max(e[1],t.center[1]+t.radius),e[2]=Math.max(e[2],t.center[2]+t.radius)}function T(e,t,n){n[0]=e[0]+t,n[1]=e[1]+t,n[2]=e[2]+t}function E(e,t,r){R[0]=1/0,R[1]=1/0,R[2]=1/0,z[0]=-1/0,z[1]=-1/0,z[2]=-1/0;for(let n of e){let e=t(n);A(e.radius)&&(C(R,e),w(z,e))}n(r.center,R,z,.5),r.radius=Math.max(z[0]-R[0],z[1]-R[1],z[2]-R[2])/2}function D(e,t,n){if(!G.length)for(let e=0;e<8;++e)G.push({index:0,distance:0});for(let n=0;n<8;++n){let r=j[n];G.data[n].index=n,G.data[n].distance=k(e,t,r)}G.sort((e,t)=>e.distance-t.distance);for(let e=0;e<8;++e)n[e]=G.data[e].index}function O(e,t){let n=1/0,r;for(let i=0;i<8;++i){let a=k(e,t,M[i]);a<n&&(n=a,r=M[i])}return r}function k(e,t,n){return t*(e[0]*n[0]+e[1]*n[1]+e[2]*n[2])}function A(e){return!isNaN(e)&&e!==-1/0&&e!==1/0&&e>0}const j=[o(-1,-1,-1),o(1,-1,-1),o(-1,1,-1),o(1,1,-1),o(-1,-1,1),o(1,-1,1),o(-1,1,1),o(1,1,1)],M=[o(-1,-1,-1),o(-1,-1,1),o(-1,1,-1),o(-1,1,1),o(1,-1,-1),o(1,-1,1),o(1,1,-1),o(1,1,1)],N=Math.sqrt(3),P=[null];function F(e){return P[0]=e,P}const I=new d,L=s(),R=s(),z=s(),B=new t,V=new d,H=new d,U=new d,W=[{min:0,max:0},{min:0,max:0},{min:0,max:0}],G=new t,K=[0,0,0,0,0,0,0,0];export{p as Octree};
|