@arcgis/core 5.1.0-next.51 → 5.1.0-next.52
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/applications/Components/imageryUtils.d.ts +6 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/001492854799c35b53bb.js +1 -0
- package/assets/esri/core/workers/chunks/004f991251f09b36fb09.js +1 -0
- package/assets/esri/core/workers/chunks/027d733a99f50cadcf22.js +1 -0
- package/assets/esri/core/workers/chunks/03d85a706669aaf24d49.js +1 -0
- package/assets/esri/core/workers/chunks/0450133e81bce4b48b84.js +1 -0
- package/assets/esri/core/workers/chunks/07e791530677f7e70f32.js +30 -0
- package/assets/esri/core/workers/chunks/085778ecd39f46324a6b.js +1 -0
- package/assets/esri/core/workers/chunks/08dce0019b52042b01fa.js +1 -0
- package/assets/esri/core/workers/chunks/0d8294982853308225da.js +1 -0
- package/assets/esri/core/workers/chunks/156aecac067213642aae.js +1 -0
- package/assets/esri/core/workers/chunks/{942e4d69b140bc2f97c9.js → 15a45e26964c2eb381a6.js} +1 -1
- package/assets/esri/core/workers/chunks/184e9147f7a2f0ae5915.js +1 -0
- package/assets/esri/core/workers/chunks/19f59a2a97c33ff92650.js +1 -0
- package/assets/esri/core/workers/chunks/{54420b66fd53d6e19ba5.js → 278eecd729bed2832702.js} +1 -1
- package/assets/esri/core/workers/chunks/{a3174b23aabcef2fa98c.js → 29c91b5c9ddcea85f39a.js} +1 -1
- package/assets/esri/core/workers/chunks/2b7d020367cb4ebb3c3d.js +1 -0
- package/assets/esri/core/workers/chunks/30654845ca1334f1c206.js +1 -0
- package/assets/esri/core/workers/chunks/3104b10770903c265626.js +1 -0
- package/assets/esri/core/workers/chunks/33f00633131581e06328.js +1 -0
- package/assets/esri/core/workers/chunks/{32a51ce8e1a362115c89.js → 354b309c8225336bc1e5.js} +1 -1
- package/assets/esri/core/workers/chunks/{f8ff3c2dc00b0b27f72f.js → 35dbe1eeb6932b03aea2.js} +1 -1
- package/assets/esri/core/workers/chunks/386435341e949f5573b4.js +2 -0
- package/assets/esri/core/workers/chunks/3874362bf7d43adc41bb.js +1 -0
- package/assets/esri/core/workers/chunks/38dc1c4b8721efd4a165.js +1 -0
- package/assets/esri/core/workers/chunks/39f3bea123f20c816ab2.js +1 -0
- package/assets/esri/core/workers/chunks/{d527a57717d118c11311.js → 3fcc8c455af56ae89030.js} +1 -1
- package/assets/esri/core/workers/chunks/42f3fdad1728433b3510.js +1 -0
- package/assets/esri/core/workers/chunks/436941ec88439667022e.js +1 -0
- package/assets/esri/core/workers/chunks/{25946077568ab14c7bfc.js → 440f76c397a813b0dcf9.js} +1 -1
- package/assets/esri/core/workers/chunks/4812482f28f7205b0938.js +1 -0
- package/assets/esri/core/workers/chunks/5317cbef0aac29761575.js +1 -0
- package/assets/esri/core/workers/chunks/54a9e17d6c0fef6a9146.js +1 -0
- package/assets/esri/core/workers/chunks/55985c9c48b8e1d1c634.js +1 -0
- package/assets/esri/core/workers/chunks/55edd712c6d2d044e550.js +1 -0
- package/assets/esri/core/workers/chunks/5a573fa1012092328b88.js +1 -0
- package/assets/esri/core/workers/chunks/5f06a57b4f7d7de16bbf.js +1 -0
- package/assets/esri/core/workers/chunks/60ad54e5707d4414d8b9.js +1 -0
- package/assets/esri/core/workers/chunks/63b9e4a7dad358605c38.js +1 -0
- package/assets/esri/core/workers/chunks/{d0adf059085ddf7151dd.js → 64845b1f53eca9db1229.js} +1 -1
- package/assets/esri/core/workers/chunks/66d4cbb35d0c290150bf.js +1 -0
- package/assets/esri/core/workers/chunks/677d3674cb2c0c05fb7e.js +1 -0
- package/assets/esri/core/workers/chunks/7100c9038739121c2c4b.js +1 -0
- package/assets/esri/core/workers/chunks/{8d03d45a5ec65590019d.js → 720a33a7f118d2769133.js} +1 -1
- package/assets/esri/core/workers/chunks/{48267b67564107a7d901.js → 7480bd6f892abf444cac.js} +31 -31
- package/assets/esri/core/workers/chunks/{bde4edc4d21363e2163a.js → 792219a079c28bcdc003.js} +1 -1
- package/assets/esri/core/workers/chunks/794f604d4267e374f7dd.js +1 -0
- package/assets/esri/core/workers/chunks/7ae8f73c8e2afae98ecb.js +1 -0
- package/assets/esri/core/workers/chunks/7d4af7e2cb2f234e12eb.js +1 -0
- package/assets/esri/core/workers/chunks/807b12ace0099300b9b9.js +1 -0
- package/assets/esri/core/workers/chunks/{b98dd9fc9a7e3ff6bd49.js → 816a4b03f2ea49238a6c.js} +1 -1
- package/assets/esri/core/workers/chunks/842b442cc012d0797333.js +1 -0
- package/assets/esri/core/workers/chunks/8903ff28896bd6f34b0d.js +1 -0
- package/assets/esri/core/workers/chunks/89e9bc8789b100316136.js +1 -0
- package/assets/esri/core/workers/chunks/8afe32d3db9669f972bc.js +1 -0
- package/assets/esri/core/workers/chunks/91fd28f50477d16e294e.js +1 -0
- package/assets/esri/core/workers/chunks/{278409028bc5af45b507.js → 93ceb74ac88ef460fe5f.js} +1 -1
- package/assets/esri/core/workers/chunks/98011b93acf3d5f0b5a2.js +1 -0
- package/assets/esri/core/workers/chunks/{cd491c37ba1ac381178c.js → 987dc23fdc0a8c7150b9.js} +1 -1
- package/assets/esri/core/workers/chunks/{25509953f19fbc4949a1.js → 992e74570b76f3f9e52e.js} +1 -1
- package/assets/esri/core/workers/chunks/{b1c5f69bd1400e66c635.js → 9ae90a4b281d4103e8bb.js} +1 -1
- package/assets/esri/core/workers/chunks/9c7fd5db0813bdc38582.js +1 -0
- package/assets/esri/core/workers/chunks/9f272445c285ee9abb7b.js +1 -0
- package/assets/esri/core/workers/chunks/a2fee1611319665e6aed.js +1 -0
- package/assets/esri/core/workers/chunks/a644e30f65347ce846ed.js +1 -0
- package/assets/esri/core/workers/chunks/a64daa4945923a178fe5.js +1 -0
- package/assets/esri/core/workers/chunks/a85575a8d1da09280cd7.js +1 -0
- package/assets/esri/core/workers/chunks/ac4f7309a249132c22da.js +1 -0
- package/assets/esri/core/workers/chunks/aeb1900cfdd0e51cc5f8.js +1 -0
- package/assets/esri/core/workers/chunks/ba62f3aa811430787863.js +1 -0
- package/assets/esri/core/workers/chunks/{9e5f6ad08e54e4f49bf0.js → bb659dcd297b895830df.js} +1 -1
- package/assets/esri/core/workers/chunks/c03d0091a6f385b9ce8d.js +1 -0
- package/assets/esri/core/workers/chunks/c48d1ee37c207bfb0aac.js +1 -0
- package/assets/esri/core/workers/chunks/c4a9006cc6d2938570e0.js +1 -0
- package/assets/esri/core/workers/chunks/c692ea68509bddbf7b42.js +1 -0
- package/assets/esri/core/workers/chunks/{a4a4ce33de6432ba4dc3.js → c6a0e770c1a89d3b5913.js} +1 -1
- package/assets/esri/core/workers/chunks/{48033fa4b1b815bc9ece.js → cc1f3a2f281a2f6e0f94.js} +1 -1
- package/assets/esri/core/workers/chunks/{73e384fd93cf22503d84.js → cdf6ad970dc1893dac58.js} +1 -1
- package/assets/esri/core/workers/chunks/{5b5340312086d7b0ca97.js → daf65bccc45dc5c400ae.js} +1 -1
- package/assets/esri/core/workers/chunks/df3e79b56c37156e7895.js +1 -0
- package/assets/esri/core/workers/chunks/df8b80b17e371c9be4e6.js +1 -0
- package/assets/esri/core/workers/chunks/e77198f8ab47441423c5.js +1 -0
- package/assets/esri/core/workers/chunks/e786da40a1c87bed64ca.js +1 -0
- package/assets/esri/core/workers/chunks/e8aafef6342c50340a27.js +1 -0
- package/assets/esri/core/workers/chunks/ec00348d74e29f48613a.js +1 -0
- package/assets/esri/core/workers/chunks/{284ce99af7bdd73dc7e9.js → ec65c9c72507ef9a9cf9.js} +1 -1
- package/assets/esri/core/workers/chunks/{cdec811b66d98e76be9e.js → eedeff8b344ff699b0b9.js} +1 -1
- package/assets/esri/core/workers/chunks/f4201e7dcae224d0caf0.js +1 -0
- package/assets/esri/core/workers/chunks/f4d31d96681b649ddc95.js +1 -0
- package/assets/esri/core/workers/chunks/{6c3916517664c9e8398f.js → f5fd59291cb161fdc05b.js} +1 -1
- package/assets/esri/core/workers/chunks/f7cc05fbfc97b4d36eba.js +1 -0
- package/assets/esri/core/workers/chunks/{6aba8c3bce5f68568e3a.js → f7fb121169b7e5a5adbc.js} +1 -1
- package/assets/esri/core/workers/chunks/f9d369a4683f88ee9d76.js +1 -0
- package/assets/esri/core/workers/chunks/fc534c94d55331578195.js +1 -0
- package/assets/esri/core/workers/chunks/{3e61e7805dc6ff284831.js → fdf8fe0f50a9ae548c16.js} +1 -1
- package/chunks/Fog.glsl.js +1 -1
- package/chunks/GlowBlur.glsl.js +2 -2
- package/chunks/GlowComposition.glsl.js +6 -6
- package/chunks/HUDMaterial.glsl.js +1 -1
- package/chunks/OITBlend.glsl.js +9 -9
- package/config.js +1 -1
- package/geometry/support/aaBoundingBox.js +1 -1
- package/geometry/support/sphere.js +1 -1
- package/kernel.js +1 -1
- package/layers/raster/datasets/pixelReader.js +1 -1
- package/package.json +2 -2
- package/support/revision.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/support/Tiles3DBVH.js +2 -0
- package/views/3d/layers/support/Tiles3DMeshIntersectionHandler.js +1 -1
- package/views/3d/support/ElevationRange.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatFadeHelper.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatFadeTexture.js +1 -1
- package/views/3d/support/orientedBoundingBox.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterialGlobalParameters.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterialRepository.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutputConfiguration.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/output/Emissions.glsl.js +5 -5
- package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
- package/views/3d/webgl-engine/effects/fboFormatUtils.js +2 -0
- package/views/3d/webgl-engine/effects/fog/Fog.js +1 -1
- package/views/3d/webgl-engine/effects/fog/FogTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/effects/glow/GlowBlurTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/effects/glow/GlowCompositionTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/effects/glow/GlowRenderNode.js +1 -1
- package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
- package/views/3d/webgl-engine/effects/transparency/OITBlend.js +1 -1
- package/views/3d/webgl-engine/effects/transparency/OITBlendTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
- package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
- package/views/3d/webgl-engine/lib/Material.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/Dithering.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/OutputColorHighlightOLID.glsl.js +3 -3
- package/views/3d/webgl-engine/shaders/oitResolution.glsl.js +1 -1
- package/views/3d/webgl-engine/statistics/RendererPerformanceInfo.js +1 -1
- package/views/3d/webgl.js +1 -1
- package/views/SelectionManager.js +1 -1
- package/views/selection/types.d.ts +92 -1
- package/views/support/selectionUtils.js +1 -1
- package/views/webgl/InstanceCounter.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
- package/widgets/Editor/UpdateFeaturesWorkflowData.d.ts +2 -2
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/LayerList/ListItemPanel.js +1 -1
- package/widgets/Legend/LegendViewModel.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/support/SelectionList/FeatureItem.js +1 -1
- package/widgets/support/SelectionList/LayerItem.js +1 -1
- package/widgets/support/SelectionList/SelectionListViewModel.js +1 -1
- package/widgets/support/Selector2D/selectorUtils.js +1 -1
- package/assets/esri/core/workers/chunks/04b04548d4eb0941a01e.js +0 -1
- package/assets/esri/core/workers/chunks/06223d5d8281e5af14c5.js +0 -1
- package/assets/esri/core/workers/chunks/07bdcb622ea59fdbb3a6.js +0 -1
- package/assets/esri/core/workers/chunks/0eb57ef4a1b387c951d6.js +0 -1
- package/assets/esri/core/workers/chunks/136859ef29a3269c4128.js +0 -1
- package/assets/esri/core/workers/chunks/1e018de43becf66cceaa.js +0 -1
- package/assets/esri/core/workers/chunks/236b4ab3da0bc8f788a2.js +0 -1
- package/assets/esri/core/workers/chunks/2379c64b0ca30814a815.js +0 -1
- package/assets/esri/core/workers/chunks/333a019ea18d07f6a159.js +0 -1
- package/assets/esri/core/workers/chunks/35d115bde474c380c791.js +0 -1
- package/assets/esri/core/workers/chunks/3f6ebd82551c2000912e.js +0 -1
- package/assets/esri/core/workers/chunks/4577df99c92c7ec0f9de.js +0 -1
- package/assets/esri/core/workers/chunks/4869e2f35aaf6b058281.js +0 -1
- package/assets/esri/core/workers/chunks/4a4516bc5ec319c868cd.js +0 -2
- package/assets/esri/core/workers/chunks/4c6fc6d19fe519ce7bfc.js +0 -1
- package/assets/esri/core/workers/chunks/58f47dea6d8665611eff.js +0 -1
- package/assets/esri/core/workers/chunks/5b2fe488a461bc433f59.js +0 -1
- package/assets/esri/core/workers/chunks/5c0b3c76a7bc971c61dc.js +0 -1
- package/assets/esri/core/workers/chunks/5df9d2a255c9d63ae7df.js +0 -1
- package/assets/esri/core/workers/chunks/5f53d7d6bc9b67b2f357.js +0 -1
- package/assets/esri/core/workers/chunks/5ffe664eda334ad73175.js +0 -1
- package/assets/esri/core/workers/chunks/64fd3561bc94570ee954.js +0 -1
- package/assets/esri/core/workers/chunks/650614a9e4871714c42e.js +0 -1
- package/assets/esri/core/workers/chunks/66e35e38aea978f91a0c.js +0 -1
- package/assets/esri/core/workers/chunks/696f645349249f26090c.js +0 -1
- package/assets/esri/core/workers/chunks/6d5bb00157e20ad90fc0.js +0 -1
- package/assets/esri/core/workers/chunks/70f0d66e5e6d5d2163f3.js +0 -1
- package/assets/esri/core/workers/chunks/768bbc910be6c65ac107.js +0 -1
- package/assets/esri/core/workers/chunks/76effcc35b3962cd5535.js +0 -1
- package/assets/esri/core/workers/chunks/777390e820b3824dc265.js +0 -1
- package/assets/esri/core/workers/chunks/7948d6f14ae44d346d88.js +0 -1
- package/assets/esri/core/workers/chunks/797bf402489b3677a5f7.js +0 -1
- package/assets/esri/core/workers/chunks/7a4cc1133e4410271b00.js +0 -1
- package/assets/esri/core/workers/chunks/7dba4b04c148f03fdf21.js +0 -1
- package/assets/esri/core/workers/chunks/87c9a1fc9f2a392b78f5.js +0 -1
- package/assets/esri/core/workers/chunks/88426877d625ea333143.js +0 -1
- package/assets/esri/core/workers/chunks/8967a02f394a63f11030.js +0 -1
- package/assets/esri/core/workers/chunks/8c210529a28addb94ea0.js +0 -1
- package/assets/esri/core/workers/chunks/8d3c508995253cbe083f.js +0 -1
- package/assets/esri/core/workers/chunks/8e18ac7b22d8dca1e1e2.js +0 -1
- package/assets/esri/core/workers/chunks/8e3cb1c584951c3d1eb7.js +0 -1
- package/assets/esri/core/workers/chunks/908f171b9c512d738dea.js +0 -1
- package/assets/esri/core/workers/chunks/922484b43803ab4e4319.js +0 -1
- package/assets/esri/core/workers/chunks/947a715b608c8affd812.js +0 -1
- package/assets/esri/core/workers/chunks/9bd68abc6b5b07b2add3.js +0 -1
- package/assets/esri/core/workers/chunks/9e55f97291062985560b.js +0 -1
- package/assets/esri/core/workers/chunks/a90883ff02c0cc6450c2.js +0 -1
- package/assets/esri/core/workers/chunks/ac9722a7897c994f11ab.js +0 -1
- package/assets/esri/core/workers/chunks/b1ac09d8fa340d194aa2.js +0 -1
- package/assets/esri/core/workers/chunks/c04c457f5295febb3c39.js +0 -1
- package/assets/esri/core/workers/chunks/cb2fbe585c0827eecf70.js +0 -1
- package/assets/esri/core/workers/chunks/cf74d1605ad2f21699e7.js +0 -1
- package/assets/esri/core/workers/chunks/d50e6681ecb9612e4528.js +0 -1
- package/assets/esri/core/workers/chunks/d6eddb94f5f2e9759bd0.js +0 -1
- package/assets/esri/core/workers/chunks/dcc3285e4ab2c38709bd.js +0 -1
- package/assets/esri/core/workers/chunks/e25bbd7cc553b1d2e208.js +0 -1
- package/assets/esri/core/workers/chunks/e72ca52d930afb5650af.js +0 -30
- package/assets/esri/core/workers/chunks/e96529e144c3268a04f7.js +0 -1
- package/assets/esri/core/workers/chunks/f379f94adbe79dc305a2.js +0 -1
- package/assets/esri/core/workers/chunks/f4e5163efa2a0567ee19.js +0 -1
- package/assets/esri/core/workers/chunks/f76833254f842fb0cd9a.js +0 -1
- package/assets/esri/core/workers/chunks/f9abae8d07002fe04a08.js +0 -1
- package/assets/esri/core/workers/chunks/ff6c4f8420140b9f9577.js +0 -1
- package/assets/esri/core/workers/chunks/ffe9fa5111c149ddef49.js +0 -1
- /package/assets/esri/core/workers/chunks/{4a4516bc5ec319c868cd.js.LICENSE.txt → 386435341e949f5573b4.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{initial as o,watch as n,when as a}from"../../../core/reactiveUtils.js";import{schedule as l}from"../../../core/scheduling.js";import{property as c,subclass as d}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as m,fromQuat as u}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as p,IDENTITY as f}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as y,sub as _,dot as v,add as w,length as j,transformMat3 as x,set as C,abs as M,max as E}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as O,freeze as T,fromValues as R,clone as U,ZEROS as V}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as S,clone as A,fromValues as H}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMoon as L,isMars as k,getReferenceEllipsoid as P,SphericalECEFSpatialReferenceLike as I}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as F}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as D}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as G}from"../../../geometry/projection/projectVectorToVector.js";import{create as B}from"../../../geometry/support/aaBoundingRect.js";import{getContinuousIndexArray as z}from"../../../geometry/support/Indices.js";import{isCGCS2000 as N}from"../../../geometry/support/spatialReferenceUtils.js";import{BufferViewVec2f as q,BufferViewVec4f as W,BufferViewVec4u8 as $,BufferViewVec4u16 as Z,BufferViewVec3f as J,BufferViewVec3u8 as X,BufferViewVec3u16 as Y,BufferViewInt16 as K,BufferViewUint32 as Q,BufferViewUint16 as ee}from"../../../geometry/support/buffer/BufferView.js";import te from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as ie}from"../../../support/elevationInfoUtils.js";import{addNormals as se}from"./IntegratedMeshNormals.js";import{LayerView3D as re}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as oe}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as ne,removeLayerViewFromWasm as ae,getLyr3DWasm as le}from"./Lyr3DWasm.js";import{toWasmModification as ce}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as de}from"./i3s/LayerElevationProvider.js";import{IntegratedMesh3DTilesLayerView3DSymbol as he}from"./support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{primTypeConversion as me,alphaModeConversion as ue,faceCullingConversion as pe,wrapModeConversion as fe,lyr3DTypeToByteSize as be}from"./support/lyr3dTypeConversions.js";import{Tiles3DMeshIntersectionHandler as ge}from"./support/Tiles3DMeshIntersectionHandler.js";import{Frustum as ye}from"../state/Frustum.js";import{ElevationRange as _e}from"../support/ElevationRange.js";import{toBoundingRect as ve}from"../support/extentUtils.js";import{Obb as we,compute as je}from"../support/orientedBoundingBox.js";import{glLayout as xe}from"../support/buffer/glUtil.js";import{VertexBufferLayoutCreationParameters as Ce,createVertexBufferLayout as Me,ComponentGeometryParameters as Ee,SourceGeometry as Oe}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as Te}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Re}from"../webgl-engine/core/material/RenderTexture.js";import{Vertices as Ue,Attribute as Ve}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as Se}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as Ae}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as He}from"../webgl-engine/materials/pbrUtils.js";import{writeAttribute as Le,writeBufferVec2 as ke}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import Pe from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as Ie,isInEffectiveScaleRange as Fe,validateScaleRange as De}from"../../support/layerViewUtils.js";import{TaskPriority as Ge}from"../../support/Scheduler.js";import{TextureCompressionTracker as Be}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as ze}from"../../../webscene/support/AlphaCutoff.js";var Ne;let qe=class extends(re(Pe)){static{Ne=he}constructor(e){super(e),this[Ne]=!0,this.type="integrated-mesh-3dtiles",this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._replacesTerrain=!1,this._isUsedAsGroundLayer=!1,this._applySSAO=!has("disable-feature:im-ssao"),this._imShading=!!has("enable-feature:im-shading"),this._imVertexNormals=!!has("enable-feature:im-vertex-normals"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._compressionTracker=new Be,this._dbgFlags=new Set;const t=e.view.resourceController;this._memCache=t.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._replacesTerrain=e.layer.replacesTerrain,this._isUsedAsGroundLayer=e.layer.isUsedAsGroundLayer,this._frameTask=t.scheduler.registerTask(Ge.TILES3D),this._frustum=new ye(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{r(t);const i=this.layer.queryElevationCallback;this.layer=e,this.layer.queryElevationCallback=i}):null}canRecycleWith(e){return e.url===this.layer.url&&"integrated-mesh-3dtiles"===e.type&&e.replacesTerrain===this._replacesTerrain&&e.isUsedAsGroundLayer===this._isUsedAsGroundLayer}initialize(){this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw Ie("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=ne(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new ge(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged()),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),o),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),o),this._elevationProvider=new de({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler});const i=this._replacesTerrain?0:1;e.elevationProvider.register(i,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),a(()=>this.fullOpacity,()=>this._opacityChange()),n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)])});this.layer.queryElevationCallback=(e,t)=>this._wasm.queryElevation(this,e,t),this.addResolvingPromise(t)}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),ae(this),this.layer.queryElevationCallback=null,this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._frameTask.remove(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=s(this._visibleGeometryChangedSchedulerHandle)}get fullOpacity(){return this.layer.replacesTerrain?this.view.map.ground.opacity:1}get hasModifications(){return this._modifications&&this._modifications.length>0}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateObjectOpacity(t,e))}_cameraChanged(){const e=this._frustum;e.update(this.view.state.contentCamera);const t=this._visibleObjects;let i=!1;this._loadedObjects.forEach(s=>{const r=s.obb?.intersectsFrustum(e)??!1;r!==s.isVisible&&(s.isVisible=r,r?t.add(s):t.delete(s),s.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,r)),i||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(r,s.elevationRange))}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}_modificationsChanged(){const e=this.layer.spatialReference,t=ce(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=B();this._layerClippingArea=ve(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=l(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.layer.replacesTerrain),this.forEachComponentObject(t=>t.updateMaterial({slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,ie(e))}get _wasm(){return le(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||Fe(this.layer.effectiveScaleRange,this.view.scale)}canResume(){const e=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.layer.isUsedAsGroundLayer||De(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isLoaded?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,r++):(i+=n.textureMemoryUsage,s+=n.vboMemoryUsage,o++)}),new oe(this.usedMemory,r,o,Ze(t),Ze(e),Ze(s),Ze(i))}_canProjectWithoutEngine(){if(this.view.state.isLocal){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return ie(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new _e(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new _e;0===this._visibleObjects.size?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this._forEachRelevantVisibleTile(t=>e.expandElevationRange(t.elevationRange)),e.minElevation===1/0&&e.setElevationRangeValues(0,0));const t=this._get("visibleElevationRange");return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange("visibleElevationRange")}_forEachRelevantVisibleTile(e){const{view:t}=this,{spatialReference:i}=t,s=i.isWGS84||i.isWebMercator||N(i)||L(i)||k(i);if(this.view.state.isGlobal||!s)return this.forEachVisibleTile(e);const r=P(i).radius,{eye:o,viewForward:n,near:a}=t.state.camera,l=y(O(),n),c=500,d=Math.max(o[2],c),h=d+r,m=Math.sqrt(h**2-r**2),u=Math.abs(Math.atan2(m,r))*r,p=d>.5*r?.5*Math.PI*r:u,f=O();this.forEachVisibleTile(t=>{const{mbsRadius:i,mbsCenter:s}=t;if(i<0)return;_(f,s,o);const r=v(f,l);Math.abs(r)<p&&r+i>a&&r-i<p&&e(t)})}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachTile(e){for(const t of this._loadedObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const{componentObjects:i}of e)for(const e of i)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){return this._frameTask.schedule(()=>this._createRenderable(e))}async _createRenderable(e){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw this._dbg(3,e),new Error(e)}const{meshData:t}=e;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=T(...t.desc.origin),s=this.view.basemapTerrain.spatialReference;let r=f;if(this.view.state.isGlobal){const e=b();F(I,i,e,s),r=h(p(),e)}const o=O(),n=Ye(t.desc.obb);let a=0;const l={textureMemoryUsage:0},c=new Array,d=new Map,u=t.desc.prims.length,g=new Array,y=new _e;try{const e=this.view.state.isGlobal,h=e?P(this.view.spatialReference).radius:0,b=O();for(let g=0;g<u;g++){const u=t.desc.prims[g];this._dbg(2,JSON.stringify(u));if(null==me[u.ptype]||null==t.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+u.ptype+"). Skipping primitive.");continue}const _=t.desc?.materials&&null!=u.materialId?t.desc.materials[u.materialId]:null,v=null!=_?_.lightingModel:"Unlit",{positionView:M,positionAttr:E,normalsView:T,normalsAttr:V,colorAttr:L,texCoord0Attr:k,indicesView:P}=this.getBufferViews(u,t.data.buffer,r);if(null==E||null==M||null==P)continue;const I=M.count,F=(e,t)=>!e||e.data.length/e.size===I||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!F(k,"numTexcoord")||!F(L,"numColors")||!F(V,"normals"))continue;const B=new Ce(null!=L,null!=T,k?1:0),z=Me(B);for(let t=0;t<M.count;t++){M.getVec(t,o),w(o,o,i);const s=e?j(o)-h:o[2];y.expandElevationRangeValues(s,s)}if(n){et(n,b,new Ue(E.data,3),i)}const N=n?.clone()??Xe(E,i);if(r!==f)for(let e=0;e<M.count;e++)M.getVec(e,o),x(o,o,r),M.setVec(e,o);const W=z.createBuffer(I);if(Le("position",E,null,null,W,0),null!=k){const e=W.getField("uv0",q);ke(k,e,0)}null!=L&&Le("color",L,null,null,W,0),null!=V&&Le("normalCompressed",V,null,null,W,0);const $=new Uint32Array([0,P.typedBuffer.length]),Z=xe(z),J=this._imVertexNormals,X=r===f?f:m(p(),r)??f,Y=se(new Uint8Array(W.buffer),P.typedBuffer,Z,J,J?X:void 0),K=new Ee(Z,this._imShading?2:0,B.textureCoordinateType,r!==f?1:0,0),Q=new Oe({interleavedVertexData:Y.data,vertexCount:Y.data.byteLength/Z[0].stride,indexData:Y.indices},{positions:M.typedBuffer,indices:P.typedBuffer},$,K),ee=this.view.renderSpatialReference,te=O(),ie=[1,1,1];D(i,ee,ie,s)||this._dbg(3,"Unsupported coordinate system for IM overlay"),G(i,ee,te,s);let re=Promise.resolve(Qe),oe=S,ne=ze,ae=null,le=null,ce=null,de=null,he=null,fe=1,be=!1,ge=2,ye=!1,_e=R(0,0,0);const ve=U(He),we="Pbr"===v;if(_){const e=e=>this._getTexture(e,t,d,l);ae=e(_.baseColorTex),he=we?e(_.metalTex):null,le=we?e(_.emissiveTex):null,de=we?e(_.occlusionTex):null,ce=we?e(_.normalTex):null;const i=[ae,he,le,de,ce].map(e=>e?.loadPromise??null);re=Promise.all(i),oe=A(_.baseColorFactor),ne=_.alphaCutoff??ze,we&&(C(ve,_.metallicFactor,_.roughnessFactor,0),_.emissiveFactor&&(_e=_.emissiveFactor)),fe=ue[_.alphaMode],be=_.isDoubleSided,ge=pe[_.faceCulling??"NotSet"],ye=this.layer.replacesTerrain}const je=re.then(()=>()=>{if(this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}ae||this._dbg(3,"No colour texture 1");const e=this._collection.createObject({toMapSpace:H(te[0],te[1],ie[0],ie[1]),transform:new Te(i,X),obb:N,geometry:Q,elevationAlignable:!1},{isIntegratedMesh:!0,baseColor:oe,textureAlphaCutoff:ne,mrrFactors:ve,baseColorTexture:ae,metallicRoughnessTexture:he,normalTexture:ce,occlusionTexture:de,emissionTexture:le,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:fe,doubleSided:be,cullFace:ge,isGround:ye,emissiveBaseColor:_e,usePBR:we,slicePlaneEnabled:this.slicePlaneEnabled,opacity:this.fullOpacity,polygonOffsetEnabled:!1,ellipsoidMode:1,applySSAO:this._applySSAO});return l.textureMemoryUsage+=ae?.texture?.usedMemory??0,we&&(l.textureMemoryUsage+=(he?.texture?.usedMemory??0)+(le?.texture?.usedMemory??0)+(de?.texture?.usedMemory??0)+(ce?.texture?.usedMemory??0)),a+=this._collection.getObjectGPUMemoryUsage(e),e});c.push(je)}if(g.push(...await Promise.all(c)),this.destroyed){const e="IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call";throw this._dbg(3,e),new Error(e)}}catch(k){throw d.forEach(e=>this._stage.removeTexture(e)),k}const _=g.map(e=>e()),v=new Array;d.forEach(e=>v.push(e));const{fullExtent:M}=this.layer;M?.hasZ&&M.zmax&&M.zmin&&(y.minElevation=Math.max(y.minElevation,M.zmin),y.maxElevation=Math.min(y.maxElevation,M.zmax));const E=_.reduceRight((e,t)=>e+t.intersectionGeometry.usedMemory,0),V=new $e(e.handle,_,v,E,a,l.textureMemoryUsage,n,e.stableNodeId,e.nodeDepth,y);this._lyrHandleToObjects.set(e.handle,V),this._memCache.put(Ke(V.handle),V);const{usedMemory:L}=V;return this._cacheMemory+=L,{memUsageBytes:L}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){const t=Ke(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){if(this.destroyed||this.destroying)return;const s=this._frustum,r=new Array;let o=!1,n=!1;for(let a=0;a<i;++a){if(!t[a])continue;const i=e[a],l=this._lyrHandleToObjects.get(i);if(l){if(l.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${l.stableNodeId}`);continue}o=!0,l.isLoaded=!0,this._loadedObjects.add(l),this._usedMemory+=l.usedMemory,this._cacheMemory-=l.usedMemory;const e=l.obb?.intersectsFrustum(s)??!0;l.isVisible=e,e&&(this._visibleObjects.add(l),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,l.elevationRange)),e&&l.obb&&r.push(l.obb),l.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(Ke(i))}else this._dbg(3,`Tried to mark Non existent object ${i} as loaded`)}for(let a=0;a<i;++a){const i=e[a];if(t[a])continue;const s=this._lyrHandleToObjects.get(i);if(s){if(!s.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${s.stableNodeId}`);continue}const e=this._visibleObjects.delete(s);s.isVisible=!1,s.isLoaded=!1,this._loadedObjects.delete(s),e&&(this._visibleGeometryChanged(),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,s.elevationRange)),this._usedMemory-=s.usedMemory,this._cacheMemory+=s.usedMemory,e&&s.obb&&r.push(s.obb),s.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(Ke(i),s)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),this._elevationProvider.notifyObjectsChanged(r),n&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){const{visibleElevationRange:i}=this,{minElevation:s,maxElevation:r}=t;return e?s<i.minElevation||r>i.maxElevation:s===i.minElevation||r===i.maxElevation}_getTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=i.get(r)??this._createTexture(e,t,i,s);return o?new Re(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!r.mipCount||a>1,c=fe[e.wrapMode??"None"];let d=r.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,r.data.byteOffset,r.data.byteCount);let m=null,u=null,p=null;switch(r.format){case"Raw":"R8"===r.pixelFormat?(m=h,d=6403,u=""):"Rgb8"===r.pixelFormat?(m=h,d=6407,u=""):"Rgba8"===r.pixelFormat&&(m=h,d=6408,u="");break;case"Dxt1":m=h,d=6407,u="image/vnd-ms.dds";break;case"Dxt5":m=h,d=6408,u="image/vnd-ms.dds";break;case"Basis":m=h,d=6407,u="image/ktx2";break;case"Png":u="image/png",p=document.createElement("img");break;case"Jpeg":u="image/jpeg",p=document.createElement("img");break;case"Etc2":u="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&u){const e=new Blob([h],{type:u});p.src=URL.createObjectURL(e),m=p}if(m&&null!=u){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(s.textureMemoryUsage-=e)}}:void 0,t=new Se(m,{mipmap:l,maxAnisotropy:a,encoding:u,wrap:c,pixelFormat:d,compressionOptions:e,noUnpackFlip:!0,width:r.mip0Width,height:r.mip0Height});return this._stage.addTexture(t),i.set(r,t),t}return null}getBufferViews(e,t,i){let s,r,o,n,a,l,c,d=null;for(let m=0;m<e.atrbs.length;m++){const c=e.atrbs[m],{view:u}=c,p=void 0,f=u.byteOffset+u.byteCount,b=u.byteCount/be[u.type],g=z(b);try{switch(c.sem){case"Position":3!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(s=new J(t,u.byteOffset,p,f),r=new Ve(s.typedBuffer,g,3));break;case"Normal":if(3!==u.ncomp||"F32"!==u.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new J(t,u.byteOffset,p,f),s=Ae(e.typedBuffer,i);a=new K(s.buffer),l=new Ve(a.typedBuffer,g,2)}break;case"TexCoord":2!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===n&&(n=new Ve(new q(t,u.byteOffset,p,f).typedBuffer,g,2));break;case"Color":4===u.ncomp?("F32"===u.type&&(d=new W(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new $(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new Z(t,u.byteOffset,p,f))):3===u.ncomp&&("F32"===u.type&&(d=new J(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new X(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new Y(t,u.byteOffset,p,f))),null==d?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new Ve(d.typedBuffer,g,u.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":c=new ee(t,i.byteOffset,s,r);break;case"U32":c=new Q(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==c&&null!=s){const e=s.count;c=c=e<65535?new ee(new Uint16Array(e).buffer):new Q(new Uint32Array(e).buffer);for(let t=0;t<e;t++)c.set(t,t)}return{positionView:s,positionAttr:r,colorAttr:o,texCoord0Attr:n,indicesView:c,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.layer.isUsedAsGroundLayer&&"replace"!==e.type)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info("Ground layers only support replace modifications. Other modification types have been ignored.")},o),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([c()],qe.prototype,"fullOpacity",null),e([c({readOnly:!0})],qe.prototype,"ready",null),e([c({type:[te]})],qe.prototype,"_modifications",void 0),e([c()],qe.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([c()],qe.prototype,"layer",void 0),e([c({readOnly:!0})],qe.prototype,"visibleAtCurrentScale",null),e([c({readOnly:!0})],qe.prototype,"_collection",null),e([c()],qe.prototype,"elevationOffset",null),e([c({readOnly:!0})],qe.prototype,"visibleElevationRange",null),qe=e([d("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],qe);const We=qe;class $e{constructor(e,t,i,s,r,o,n,a,l,c){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=s,this.vboMemoryUsage=r,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.nodeDepth=l,this.elevationRange=c,this.isLoaded=!1,this.isVisible=!1;const d=O();n?.getCenter(d),this._obbCenterX=d[0],this._obbCenterY=d[1],this._obbCenterZ=d[2];const h=n?.radius??-1;this._obbRadius=h,this._obbRadiusSquared=h*h;const m=n?.halfSize;this._obbShortestHalfsize=m?Math.min(m[0],m[1],m[2]):0}get usedMemory(){return this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get mbsRadius(){return this._obbRadius}get mbsCenter(){return this.obb?.center??V}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const{_obbCenterX:i,_obbCenterY:s,_obbCenterZ:r}=this,o=i-e[0],n=s-e[1],a=r-e[2],l=o*t[0]+n*t[1]+a*t[2];return o*o+n*n+a*a-l*l<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){const t=this._obbRadius;if(t<0)return!0;const i=e.center,s=e.radius,r=t+s,o=this._obbCenterX-i[0];if(o>r)return!1;const n=this._obbCenterY-i[1];if(n>r)return!1;const a=this._obbCenterZ-i[2];if(a>r)return!1;const l=o*o+n*n+a*a;if(l>r*r)return!1;if(l<=(this._obbShortestHalfsize+s)**2)return!0;return Math.sqrt(l)+t<=s||(this.obb?.intersectSphere(e)??!0)}}function Ze(e){return Math.round(e/1048.576)/1e3}const Je=O();function Xe(e,t){const i=je(e);return w(Je,i.center,t),i.center=Je,i}function Ye(e){return e?new we(e.center,e.halfSize,g(...e.quaternion)):null}function Ke(e){return`${e}`}const Qe=new Array;function et(e,t,i,s){const{center:r}=e,o=u(st,e.quaternionConjugate),n=x(tt,r,o),{data:a}=i,l=a.length/i.stride,c=it;for(let d=0;d<l;++d){const e=3*d;for(let t=0;t<3;++t)c[t]=a[e+t]+s[t];x(c,c,o),_(c,c,n),M(c,c),E(t,t,c)}e.halfSize=t}const tt=O(),it=O(),st=p();export{We as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{initial as o,watch as n,when as a}from"../../../core/reactiveUtils.js";import{schedule as l}from"../../../core/scheduling.js";import{property as c,subclass as d}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as m,fromQuat as u}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as p,IDENTITY as f}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as y}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as g,sub as _,dot as v,add as w,length as j,transformMat3 as x,set as C,abs as M,max as E}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as O,freeze as T,fromValues as R,clone as U,ZEROS as V}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as S,clone as H,fromValues as A}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMoon as L,isMars as k,getReferenceEllipsoid as I,SphericalECEFSpatialReferenceLike as P}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as F}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as D}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as G}from"../../../geometry/projection/projectVectorToVector.js";import{create as B}from"../../../geometry/support/aaBoundingRect.js";import{getContinuousIndexArray as z}from"../../../geometry/support/Indices.js";import{isCGCS2000 as N}from"../../../geometry/support/spatialReferenceUtils.js";import{BufferViewVec2f as q,BufferViewVec4f as W,BufferViewVec4u8 as $,BufferViewVec4u16 as Z,BufferViewVec3f as J,BufferViewVec3u8 as X,BufferViewVec3u16 as Y,BufferViewInt16 as K,BufferViewUint32 as Q,BufferViewUint16 as ee}from"../../../geometry/support/buffer/BufferView.js";import te from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as ie}from"../../../support/elevationInfoUtils.js";import{addNormals as se}from"./IntegratedMeshNormals.js";import{LayerView3D as re}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as oe}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as ne,removeLayerViewFromWasm as ae,getLyr3DWasm as le}from"./Lyr3DWasm.js";import{toWasmModification as ce}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as de}from"./i3s/LayerElevationProvider.js";import{IntegratedMesh3DTilesLayerView3DSymbol as he}from"./support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{primTypeConversion as me,alphaModeConversion as ue,faceCullingConversion as pe,wrapModeConversion as fe,lyr3DTypeToByteSize as be}from"./support/lyr3dTypeConversions.js";import{Tiles3DMeshIntersectionHandler as ye}from"./support/Tiles3DMeshIntersectionHandler.js";import{Frustum as ge}from"../state/Frustum.js";import{ElevationRange as _e}from"../support/ElevationRange.js";import{toBoundingRect as ve}from"../support/extentUtils.js";import{Obb as we,compute as je}from"../support/orientedBoundingBox.js";import{glLayout as xe}from"../support/buffer/glUtil.js";import{VertexBufferLayoutCreationParameters as Ce,createVertexBufferLayout as Me,ComponentGeometryParameters as Ee,SourceGeometry as Oe}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as Te}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Re}from"../webgl-engine/core/material/RenderTexture.js";import{Vertices as Ue,Attribute as Ve}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as Se}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as He}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as Ae}from"../webgl-engine/materials/pbrUtils.js";import{writeAttribute as Le,writeBufferVec2 as ke}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import Ie from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as Pe,isInEffectiveScaleRange as Fe,validateScaleRange as De}from"../../support/layerViewUtils.js";import{TaskPriority as Ge}from"../../support/Scheduler.js";import{TextureCompressionTracker as Be}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as ze}from"../../../webscene/support/AlphaCutoff.js";var Ne;let qe=class extends(re(Ie)){static{Ne=he}constructor(e){super(e),this[Ne]=!0,this.type="integrated-mesh-3dtiles",this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._replacesTerrain=!1,this._isUsedAsGroundLayer=!1,this._applySSAO=!has("disable-feature:im-ssao"),this._imShading=!!has("enable-feature:im-shading"),this._imVertexNormals=!!has("enable-feature:im-vertex-normals"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._compressionTracker=new Be,this._dbgFlags=new Set;const t=e.view.resourceController;this._memCache=t.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._replacesTerrain=e.layer.replacesTerrain,this._isUsedAsGroundLayer=e.layer.isUsedAsGroundLayer,this._frameTask=t.scheduler.registerTask(Ge.TILES3D),this._frustum=new ge(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{r(t);const i=this.layer.queryElevationCallback;this.layer=e,this.layer.queryElevationCallback=i}):null}canRecycleWith(e){return e.url===this.layer.url&&"integrated-mesh-3dtiles"===e.type&&e.replacesTerrain===this._replacesTerrain&&e.isUsedAsGroundLayer===this._isUsedAsGroundLayer}initialize(){this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw Pe("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=ne(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new ye(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged()),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),o),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),o),this._elevationProvider=new de({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler});const i=this._replacesTerrain?0:1;e.elevationProvider.register(i,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),a(()=>this.fullOpacity,()=>this._opacityChange()),n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)])});this.layer.queryElevationCallback=(e,t)=>this._wasm.queryElevation(this,e,t),this.addResolvingPromise(t)}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),ae(this),this.layer.queryElevationCallback=null,this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler.destroy(),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._frameTask.remove(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=s(this._visibleGeometryChangedSchedulerHandle)}get fullOpacity(){return this.layer.replacesTerrain?this.view.map.ground.opacity:1}get hasModifications(){return this._modifications&&this._modifications.length>0}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateObjectOpacity(t,e))}_cameraChanged(){const e=this._frustum;e.update(this.view.state.contentCamera);const t=this._visibleObjects;let i=!1;this._loadedObjects.forEach(s=>{const r=s.obb?.intersectsFrustum(e)??!1;r!==s.isVisible&&(s.isVisible=r,r?t.add(s):t.delete(s),s.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,r)),i||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(r,s.elevationRange))}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}_modificationsChanged(){const e=this.layer.spatialReference,t=ce(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=B();this._layerClippingArea=ve(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=l(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.layer.replacesTerrain),this.forEachComponentObject(t=>t.updateMaterial({slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,ie(e))}get _wasm(){return le(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||Fe(this.layer.effectiveScaleRange,this.view.scale)}canResume(){const e=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.layer.isUsedAsGroundLayer||De(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isLoaded?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,r++):(i+=n.textureMemoryUsage,s+=n.vboMemoryUsage,o++)}),new oe(this.usedMemory,r,o,Ze(t),Ze(e),Ze(s),Ze(i))}_canProjectWithoutEngine(){if(this.view.state.isLocal){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return ie(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new _e(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new _e;0===this._visibleObjects.size?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this._forEachRelevantVisibleTile(t=>e.expandElevationRange(t.elevationRange)),e.minElevation===1/0&&e.setElevationRangeValues(0,0));const t=this._get("visibleElevationRange");return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange("visibleElevationRange")}_forEachRelevantVisibleTile(e){const{view:t}=this,{spatialReference:i}=t,s=i.isWGS84||i.isWebMercator||N(i)||L(i)||k(i);if(this.view.state.isGlobal||!s)return this.forEachVisibleTile(e);const r=I(i).radius,{eye:o,viewForward:n,near:a}=t.state.camera,l=g(O(),n),c=500,d=Math.max(o[2],c),h=d+r,m=Math.sqrt(h**2-r**2),u=Math.abs(Math.atan2(m,r))*r,p=d>.5*r?.5*Math.PI*r:u,f=O();this.forEachVisibleTile(t=>{const{mbsRadius:i,mbsCenter:s}=t;if(i<0)return;_(f,s,o);const r=v(f,l);Math.abs(r)<p&&r+i>a&&r-i<p&&e(t)})}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachTile(e){for(const t of this._loadedObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const{componentObjects:i}of e)for(const e of i)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){return this._frameTask.schedule(()=>this._createRenderable(e))}async _createRenderable(e){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw this._dbg(3,e),new Error(e)}const{meshData:t}=e;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=T(...t.desc.origin),s=this.view.basemapTerrain.spatialReference;let r=f;if(this.view.state.isGlobal){const e=b();F(P,i,e,s),r=h(p(),e)}const o=O(),n=Ye(t.desc.obb);let a=0;const l={textureMemoryUsage:0},c=new Array,d=new Map,u=t.desc.prims.length,y=new Array,g=new _e;try{const e=this.view.state.isGlobal,h=e?I(this.view.spatialReference).radius:0,b=O();for(let y=0;y<u;y++){const u=t.desc.prims[y];this._dbg(2,JSON.stringify(u));if(null==me[u.ptype]||null==t.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+u.ptype+"). Skipping primitive.");continue}const _=t.desc?.materials&&null!=u.materialId?t.desc.materials[u.materialId]:null,v=null!=_?_.lightingModel:"Unlit",{positionView:M,positionAttr:E,normalsView:T,normalsAttr:V,colorAttr:L,texCoord0Attr:k,indicesView:I}=this.getBufferViews(u,t.data.buffer,r);if(null==E||null==M||null==I)continue;const P=M.count,F=(e,t)=>!e||e.data.length/e.size===P||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!F(k,"numTexcoord")||!F(L,"numColors")||!F(V,"normals"))continue;const B=new Ce(null!=L,null!=T,k?1:0),z=Me(B);for(let t=0;t<M.count;t++){M.getVec(t,o),w(o,o,i);const s=e?j(o)-h:o[2];g.expandElevationRangeValues(s,s)}if(n){et(n,b,new Ue(E.data,3),i)}const N=n?.clone()??Xe(E,i);if(r!==f)for(let e=0;e<M.count;e++)M.getVec(e,o),x(o,o,r),M.setVec(e,o);const W=z.createBuffer(P);if(Le("position",E,null,null,W,0),null!=k){const e=W.getField("uv0",q);ke(k,e,0)}null!=L&&Le("color",L,null,null,W,0),null!=V&&Le("normalCompressed",V,null,null,W,0);const $=new Uint32Array([0,I.typedBuffer.length]),Z=xe(z),J=this._imVertexNormals,X=r===f?f:m(p(),r)??f,Y=se(new Uint8Array(W.buffer),I.typedBuffer,Z,J,J?X:void 0),K=new Ee(Z,this._imShading?2:0,B.textureCoordinateType,r!==f?1:0,0),Q=new Oe({interleavedVertexData:Y.data,vertexCount:Y.data.byteLength/Z[0].stride,indexData:Y.indices},{positions:M.typedBuffer,indices:I.typedBuffer},$,K),ee=this.view.renderSpatialReference,te=O(),ie=[1,1,1];D(i,ee,ie,s)||this._dbg(3,"Unsupported coordinate system for IM overlay"),G(i,ee,te,s);let re=Promise.resolve(Qe),oe=S,ne=ze,ae=null,le=null,ce=null,de=null,he=null,fe=1,be=!1,ye=2,ge=!1,_e=R(0,0,0);const ve=U(Ae),we="Pbr"===v;if(_){const e=e=>this._getTexture(e,t,d,l);ae=e(_.baseColorTex),he=we?e(_.metalTex):null,le=we?e(_.emissiveTex):null,de=we?e(_.occlusionTex):null,ce=we?e(_.normalTex):null;const i=[ae,he,le,de,ce].map(e=>e?.loadPromise??null);re=Promise.all(i),oe=H(_.baseColorFactor),ne=_.alphaCutoff??ze,we&&(C(ve,_.metallicFactor,_.roughnessFactor,0),_.emissiveFactor&&(_e=_.emissiveFactor)),fe=ue[_.alphaMode],be=_.isDoubleSided,ye=pe[_.faceCulling??"NotSet"],ge=this.layer.replacesTerrain}const je=re.then(()=>()=>{if(this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}ae||this._dbg(3,"No colour texture 1");const e=this._collection.createObject({toMapSpace:A(te[0],te[1],ie[0],ie[1]),transform:new Te(i,X),obb:N,geometry:Q,elevationAlignable:!1},{isIntegratedMesh:!0,baseColor:oe,textureAlphaCutoff:ne,mrrFactors:ve,baseColorTexture:ae,metallicRoughnessTexture:he,normalTexture:ce,occlusionTexture:de,emissionTexture:le,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:fe,doubleSided:be,cullFace:ye,isGround:ge,emissiveBaseColor:_e,usePBR:we,slicePlaneEnabled:this.slicePlaneEnabled,opacity:this.fullOpacity,polygonOffsetEnabled:!1,ellipsoidMode:1,applySSAO:this._applySSAO});return l.textureMemoryUsage+=ae?.texture?.usedMemory??0,we&&(l.textureMemoryUsage+=(he?.texture?.usedMemory??0)+(le?.texture?.usedMemory??0)+(de?.texture?.usedMemory??0)+(ce?.texture?.usedMemory??0)),a+=this._collection.getObjectGPUMemoryUsage(e),e});c.push(je)}if(y.push(...await Promise.all(c)),this.destroyed){const e="IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call";throw this._dbg(3,e),new Error(e)}}catch(k){throw d.forEach(e=>this._stage.removeTexture(e)),k}const _=y.map(e=>e()),v=new Array;d.forEach(e=>v.push(e));const{fullExtent:M}=this.layer;M?.hasZ&&M.zmax&&M.zmin&&(g.minElevation=Math.max(g.minElevation,M.zmin),g.maxElevation=Math.min(g.maxElevation,M.zmax));const E=_.reduceRight((e,t)=>e+t.intersectionGeometry.usedMemory,0),V=new $e(e.handle,_,v,E,a,l.textureMemoryUsage,n,e.stableNodeId,e.nodeDepth,g);this._lyrHandleToObjects.set(e.handle,V),this._memCache.put(Ke(V.handle),V);const{usedMemory:L}=V;return this._cacheMemory+=L,{memUsageBytes:L}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._intersectionHandler.removeTile(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){const t=Ke(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){if(this.destroyed||this.destroying)return;const s=this._frustum,r=new Array;let o=!1,n=!1;for(let a=0;a<i;++a){if(!t[a])continue;const i=e[a],l=this._lyrHandleToObjects.get(i);if(l){if(l.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${l.stableNodeId}`);continue}o=!0,l.isLoaded=!0,this._loadedObjects.add(l),this._intersectionHandler.addTile(l),this._usedMemory+=l.usedMemory,this._cacheMemory-=l.usedMemory;const e=l.obb?.intersectsFrustum(s)??!0;l.isVisible=e,e&&(this._visibleObjects.add(l),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,l.elevationRange)),e&&l.obb&&r.push(l.obb),l.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(Ke(i))}else this._dbg(3,`Tried to mark Non existent object ${i} as loaded`)}for(let a=0;a<i;++a){const i=e[a];if(t[a])continue;const s=this._lyrHandleToObjects.get(i);if(s){if(!s.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${s.stableNodeId}`);continue}const e=s.isVisible;this._visibleObjects.delete(s),s.isVisible=!1,s.isLoaded=!1,this._loadedObjects.delete(s),this._intersectionHandler.removeTile(s),e&&(this._visibleGeometryChanged(),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,s.elevationRange)),this._usedMemory-=s.usedMemory,this._cacheMemory+=s.usedMemory,e&&s.obb&&r.push(s.obb),s.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(Ke(i),s)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),this._elevationProvider.notifyObjectsChanged(r),n&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){const{visibleElevationRange:i}=this,{minElevation:s,maxElevation:r}=t;return e?s<i.minElevation||r>i.maxElevation:s===i.minElevation||r===i.maxElevation}_getTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=i.get(r)??this._createTexture(e,t,i,s);return o?new Re(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!r.mipCount||a>1,c=fe[e.wrapMode??"None"];let d=r.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,r.data.byteOffset,r.data.byteCount);let m=null,u=null,p=null;switch(r.format){case"Raw":"R8"===r.pixelFormat?(m=h,d=6403,u=""):"Rgb8"===r.pixelFormat?(m=h,d=6407,u=""):"Rgba8"===r.pixelFormat&&(m=h,d=6408,u="");break;case"Dxt1":m=h,d=6407,u="image/vnd-ms.dds";break;case"Dxt5":m=h,d=6408,u="image/vnd-ms.dds";break;case"Basis":m=h,d=6407,u="image/ktx2";break;case"Png":u="image/png",p=document.createElement("img");break;case"Jpeg":u="image/jpeg",p=document.createElement("img");break;case"Etc2":u="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&u){const e=new Blob([h],{type:u});p.src=URL.createObjectURL(e),m=p}if(m&&null!=u){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(s.textureMemoryUsage-=e)}}:void 0,t=new Se(m,{mipmap:l,maxAnisotropy:a,encoding:u,wrap:c,pixelFormat:d,compressionOptions:e,noUnpackFlip:!0,width:r.mip0Width,height:r.mip0Height});return this._stage.addTexture(t),i.set(r,t),t}return null}getBufferViews(e,t,i){let s,r,o,n,a,l,c,d=null;for(let m=0;m<e.atrbs.length;m++){const c=e.atrbs[m],{view:u}=c,p=void 0,f=u.byteOffset+u.byteCount,b=u.byteCount/be[u.type],y=z(b);try{switch(c.sem){case"Position":3!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(s=new J(t,u.byteOffset,p,f),r=new Ve(s.typedBuffer,y,3));break;case"Normal":if(3!==u.ncomp||"F32"!==u.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new J(t,u.byteOffset,p,f),s=He(e.typedBuffer,i);a=new K(s.buffer),l=new Ve(a.typedBuffer,y,2)}break;case"TexCoord":2!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===n&&(n=new Ve(new q(t,u.byteOffset,p,f).typedBuffer,y,2));break;case"Color":4===u.ncomp?("F32"===u.type&&(d=new W(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new $(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new Z(t,u.byteOffset,p,f))):3===u.ncomp&&("F32"===u.type&&(d=new J(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new X(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new Y(t,u.byteOffset,p,f))),null==d?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new Ve(d.typedBuffer,y,u.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":c=new ee(t,i.byteOffset,s,r);break;case"U32":c=new Q(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==c&&null!=s){const e=s.count;c=c=e<65535?new ee(new Uint16Array(e).buffer):new Q(new Uint32Array(e).buffer);for(let t=0;t<e;t++)c.set(t,t)}return{positionView:s,positionAttr:r,colorAttr:o,texCoord0Attr:n,indicesView:c,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.layer.isUsedAsGroundLayer&&"replace"!==e.type)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info("Ground layers only support replace modifications. Other modification types have been ignored.")},o),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([c()],qe.prototype,"fullOpacity",null),e([c({readOnly:!0})],qe.prototype,"ready",null),e([c({type:[te]})],qe.prototype,"_modifications",void 0),e([c()],qe.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([c()],qe.prototype,"layer",void 0),e([c({readOnly:!0})],qe.prototype,"visibleAtCurrentScale",null),e([c({readOnly:!0})],qe.prototype,"_collection",null),e([c()],qe.prototype,"elevationOffset",null),e([c({readOnly:!0})],qe.prototype,"visibleElevationRange",null),qe=e([d("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],qe);const We=qe;class $e{constructor(e,t,i,s,r,o,n,a,l,c){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=s,this.vboMemoryUsage=r,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.nodeDepth=l,this.elevationRange=c,this.bvhIntersectionGeneration=0,this.isLoaded=!1,this.isVisible=!1;const d=O();n?.getCenter(d),this._obbCenterX=d[0],this._obbCenterY=d[1],this._obbCenterZ=d[2];const h=n?.radius??-1;this._obbRadius=h,this._obbRadiusSquared=h*h;const m=n?.halfSize;this._obbShortestHalfsize=m?Math.min(m[0],m[1],m[2]):0,this._mbsCenter=n?U(n.center):V}get usedMemory(){return this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get mbsRadius(){return this._obbRadius}get mbsCenter(){return this._mbsCenter}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const{_obbCenterX:i,_obbCenterY:s,_obbCenterZ:r}=this,o=i-e[0],n=s-e[1],a=r-e[2],l=o*t[0]+n*t[1]+a*t[2];return o*o+n*n+a*a-l*l<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){const t=this._obbRadius;if(t<0)return!0;const i=e.center,s=e.radius,r=t+s,o=this._obbCenterX-i[0];if(o>r)return!1;const n=this._obbCenterY-i[1];if(n>r)return!1;const a=this._obbCenterZ-i[2];if(a>r)return!1;const l=o*o+n*n+a*a;if(l>r*r)return!1;if(l<=(this._obbShortestHalfsize+s)**2)return!0;return Math.sqrt(l)+t<=s||(this.obb?.intersectSphere(e)??!0)}}function Ze(e){return Math.round(e/1048.576)/1e3}const Je=O();function Xe(e,t){const i=je(e);return w(Je,i.center,t),i.center=Je,i}function Ye(e){return e?new we(e.center,e.halfSize,y(...e.quaternion)):null}function Ke(e){return`${e}`}const Qe=new Array;function et(e,t,i,s){const{center:r}=e,o=u(st,e.quaternionConjugate),n=x(tt,r,o),{data:a}=i,l=a.length/i.stride,c=it;for(let d=0;d<l;++d){const e=3*d;for(let t=0;t<3;++t)c[t]=a[e+t]+s[t];x(c,c,o),_(c,c,n),M(c,c),E(t,t,c)}e.halfSize=t}const tt=O(),it=O(),st=p();export{We as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
+
import e from"../../../../core/Logger.js";import{getOrCreateMapValue as t}from"../../../../core/MapUtils.js";import{sub as n,normalize as o,dot as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as r,create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as a,isEmpty as l,setEmpty as u,intersectsSphere as h,intersectsRay as c,copy as d,exactEquals as g}from"../../../../geometry/support/aaBoundingBox.js";import{fromValues as m}from"../../../../geometry/support/aaBoundingRect.js";import{earth as f}from"../../../../geometry/support/Ellipsoid.js";import{ElevationRange as p}from"../../support/ElevationRange.js";class w{static create(e,t){return"local"===e?new _(t):new b(t)}constructor(e,t){this.viewingMode=e,this.layerExtent=t,this._rootNode=null,this._intersectionGeneration=0,this._tileMap=new Map}destroy(){this._rootNode?.clear(),this._tileMap.clear()}_nextIntersectionGeneration(){return this._intersectionGeneration++,this._intersectionGeneration}addTile(e){const{mbsCenter:n,mbsRadius:o}=e,i=[this._ensureRootNode()],r=new Array,s=t(this._tileMap,e,()=>new Set),a=t=>{if(s.has(t))return;const n=t.addOwnTile(e);R(r,t.parent,n),s.add(t)};for(;i.length>0;){const t=i.pop();if(t.treeDepth>=H||e.mbsRadius>=.5*t.sideLength){a(t);continue}const{hPlane:r,vPlane:s}=t,l=V(n,o,r),u=V(n,o,s);0!==l||0!==u?M(t,l,u,(e,t)=>{i.push(this._ensureChild(e,t))}):a(t)}this._propagateSummaryUpdates(r)}removeTile(t){if(!this._rootNode)return void e.getLogger("Tiles3DBVH").error("Tiles3DBVH: Attempted to remove a tile that is not loaded (no root node)");const n=this._tileMap.get(t);if(!n||0===n.size)return void e.getLogger("Tiles3DBVH").error("Tiles3DBVH internal error: Attempted to remove a tile that is not loaded (not in tile map)");const o=new Array;this._tileMap.delete(t);for(const e of n){e.removeOwnTile(t);const n=e.updateOwnSummaries();R(o,e.parent,n)}this._propagateSummaryUpdates(o)}_propagateSummaryUpdates(e){if(0===e.length)return;e.sort((e,t)=>e.node.treeDepth-t.node.treeDepth);let t=new Map,n=-1;const o=()=>e.length>0?e[e.length-1].node.treeDepth:-1;for(;e.length>0||t.size>0;){const i=t.size>0?n:o(),r=t;for(t=new Map;e.length>0&&o()===i;){const{node:t,childrenUpdateKind:n}=e.pop();I(r,t,n)}for(const[e,n]of r){let o=0;for(let t=0;t<4;t++){const n=e.children[t];n&&n.isLeaf&&0===n.ownTiles.size&&(n.clear(),e.children[t]=null,o=3)}o|=e.updateSubtreeSummaries(n|o),I(t,e.parent,o)}t.size>0&&(n=i-1)}}forEachTileIntersectingRay(e,t,n,o){o?this._forEachTileIntersectingVerticalRay(e,t,n):this._forEachTileIntersectingRayGeneral(e,t,n)}_forEachTileIntersectingRayGeneral(e,t,i){const r=this._rootNode;if(!r)return;const s=this._nextIntersectionGeneration();n(j,t,e);const a=o(j,j),l=[{node:r,tRange:{tMin:0,tMax:Number.POSITIVE_INFINITY}}];for(;l.length>0;){const t=l.pop(),{node:n,tRange:o}=t,r=n.subtreeIntersectsRay(e,a,o);if(!r)continue;if(n.ownIntersectsRay(e,a,r))for(const l of n.ownTiles)l.bvhIntersectionGeneration!==s&&(l.bvhIntersectionGeneration=s,l.boundingVolumeIntersectsRay(e,a)&&i(l));const{hPlane:u,vPlane:h}=n;for(let i=0;i<4;i++){const t=n.children[i];if(null==t)continue;const r=0===i||1===i,s=y(e,a,y(e,a,o,h,!(0===i||2===i)),u,!r);s&&l.push({node:t,tRange:s})}}}_forEachTileIntersectingVerticalRay(e,t,i){if("global"!==this.viewingMode)return void this._forEachTileIntersectingRayGeneral(e,t,i);const r=this._rootNode;if(!r)return;const s=this._nextIntersectionGeneration();n(j,t,e);const a=o(j,j),l={tMin:0,tMax:Number.POSITIVE_INFINITY},u=(e,t)=>{const n=e.children[t];n&&h.push(n)},h=[r];for(;h.length>0;){const t=h.pop();if(!t.subtreeIntersectsRay(e,a,l))continue;if(null!=t.ownIntersectsRay(e,a,l))for(const n of t.ownTiles)n.bvhIntersectionGeneration!==s&&(n.bvhIntersectionGeneration=s,n.boundingVolumeIntersectsRay(e,a)&&i(n));if(t.isLeaf)continue;M(t,T(t.hPlane,e),T(t.vPlane,e),(t,n)=>{const o=t.children[n];o&&o.subtreeIntersectsRay(e,a,l)&&u(t,n)})}}getElevationRangeIntersectingSphere(e){const t=this._rootNode;if(!t||!t.subtreeIntersectsSphere(e))return null;const n=this._nextIntersectionGeneration();let o=null;const i=e=>{e.isEmpty||(o?o.expandElevationRange(e):o=new p(e.minElevation,e.maxElevation))},r=[t];for(;r.length>0;){const t=r.pop();if(!o?.contains(t.subtreeElevationRange))if(t.subtreeContainedBySphere(e))i(t.subtreeElevationRange);else{if(t.ownIntersectsSphere(e))for(const r of t.ownTiles){if(r.bvhIntersectionGeneration===n)continue;if(r.bvhIntersectionGeneration=n,!r.boundingVolumeIntersectsSphere(e))continue;const t=r.elevationRange;o?.contains(t)||i(t)}if(!t.isLeaf){M(t,V(e.center,e.radius,t.hPlane),V(e.center,e.radius,t.vPlane),(t,n)=>{const i=t.children[n];if(i&&i.subtreeIntersectsSphere(e)){if(o?.contains(i.subtreeElevationRange))return;r.push(i)}})}}}return o}}class _ extends w{constructor(e){super("local",e)}_ensureRootNode(){if(!this._rootNode){const e=this.layerExtent,t=Math.max(Math.abs(e[0]),Math.abs(e[1]),Math.abs(e[2]),Math.abs(e[3])),n=Math.log2(t),o=Math.ceil(n),i=2**Math.max(1,o),s=new v(null,0,m(-i,-i,i,i),new E(r(0,1,0),0),new E(r(1,0,0),0),2*i,a(-i,-i,-1/0,i,i,1/0));this._rootNode=s}return this._rootNode}_ensureChild(t,n){if(t.treeDepth>=H){const t="Internal error: attempted to create a child node for a node that is already at max depth";throw e.getLogger("Tiles3DBVH").error(t),new Error(t)}let o=t.children[n];if(null===o){const{extent:e,hPlane:i,vPlane:r,treeDepth:s,sideLength:l}=t,u=.5*(e[0]+e[2]),h=.5*(e[1]+e[3]),c=0===n||1===n,d=2===n||0===n,g=m(d?e[0]:u,c?e[1]:h,d?u:e[2],c?h:e[3]),f=new E(i.normal,-.5*(g[1]+g[3])),p=new E(r.normal,-.5*(g[0]+g[2]));o=new v(t,s+1,g,f,p,.5*l,a(g[0],g[1],-1/0,g[2],g[3],1/0)),t.children[n]=o}return o}}class b extends w{constructor(e){super("global",e)}_ensureRootNode(){if(!this._rootNode){const e=new v(null,0,m(-Math.PI,-Math.PI/2,Math.PI,Math.PI/2),new E(r(0,0,1),0),new E(r(1,0,0),0),Math.PI*f.radius,a(-1/0,-1/0,-1/0,1/0,1/0,1/0));this._rootNode=e}return this._rootNode}_ensureChild(t,n){if(t.treeDepth>=H){const t="Attempted to create a child node for a node that is already at max depth";throw e.getLogger("Tiles3DBVH").error(t),new Error(t)}let o=t.children[n];if(null===o){const{extent:e,treeDepth:i,sideLength:s}=t,a=.5*(e[0]+e[2]),l=.5*(e[1]+e[3]),u=0===n||1===n,h=2===n||0===n,c=m(h?e[0]:a,u?e[1]:l,h?a:e[2],u?l:e[3]),d=.5*(c[0]+c[2]),g=.5*(c[1]+c[3]),f=Math.cos(d),p=Math.sin(d),w=Math.cos(g),_=Math.sin(g),b=r(-_*f,-_*p,w),M=new E(b,0),R=new E(r(-p,f,0),0);o=new v(t,i+1,c,M,R,.5*s),t.children[n]=o}return o}}class v{constructor(e,t,n,o,i,r,s){this.parent=e,this._treeDepth=t,this.extent=n,this.hPlane=o,this.vPlane=i,this.sideLength=r,this.bounds=s,this._ownBoundingVolume=a(1/0,1/0,1/0,-1/0,-1/0,-1/0),this._subtreeBoundingVolume=a(1/0,1/0,1/0,-1/0,-1/0,-1/0),this._ownElevationRange=new p,this._subtreeElevationRange=new p,this.ownTiles=new Set,this.children=[null,null,null,null]}get ownBoundingVolume(){return this._ownBoundingVolume}get subtreeBoundingVolume(){return this._subtreeBoundingVolume}get subtreeElevationRange(){return this._subtreeElevationRange}subtreeContainedBySphere(e){const t=this._subtreeBoundingVolume;if(l(t))return!0;const{center:n,radius:o}=e,i=o**2;let r=0;for(let s=0;s<3;s++){if(r+=Math.max(Math.abs(t[s]-n[s]),Math.abs(t[s+3]-n[s]))**2,r>i)return!1}return!0}clear(){for(let e=0;e<4;e++)this.children[e]?.clear(),this.children[e]=null;this.ownTiles.clear(),u(this._ownBoundingVolume),u(this._subtreeBoundingVolume),this._ownElevationRange.initializeEmpty(),this._subtreeElevationRange.initializeEmpty()}get isLeaf(){return this.children.every(e=>null==e)}get treeDepth(){return this._treeDepth}subtreeIntersectsSphere(e){return h(this.subtreeBoundingVolume,e)}ownIntersectsSphere(e){return this.ownTiles.size>0&&h(this._ownBoundingVolume,e)}subtreeIntersectsRay(e,t,n){return c(this.subtreeBoundingVolume,e,t,n)}ownIntersectsRay(e,t,n){return this.ownTiles.size>0?c(this._ownBoundingVolume,e,t,n):null}addOwnTile(t){if(this.ownTiles.has(t)){const t="BVNode: Attempted to add a tile that is already in the node";return e.getLogger("Tiles3DBVH").error(t),0}this.ownTiles.add(t);return(x(this._ownBoundingVolume,t,this.bounds)&&B(this._subtreeBoundingVolume,this._ownBoundingVolume,this.bounds)?1:0)|(this._ownElevationRange.expandElevationRange(t.elevationRange)&&this._subtreeElevationRange.expandElevationRange(t.elevationRange)?2:0)}removeOwnTile(t){if(!this.ownTiles.has(t)){const t="BVNode: Attempted to remove a tile that is not in the node";return void e.getLogger("Tiles3DBVH").error(t)}this.ownTiles.delete(t)}updateOwnSummaries(){const e=(S(this._ownBoundingVolume,this.ownTiles,this.bounds)?1:0)|(D(this._ownElevationRange,this.ownTiles)?2:0);return this.updateSubtreeSummaries(e)}updateSubtreeSummaries(e){if(this.isLeaf&&0===this.ownTiles.size)return u(this._subtreeBoundingVolume),this._subtreeElevationRange.initializeEmpty(),3;let t=0;if(1&e){N(this._subtreeBoundingVolume,[this._ownBoundingVolume,...this.children.map(e=>e?.subtreeBoundingVolume).filter(e=>null!=e)],this.bounds)&&(t|=1)}if(2&e){P(this._subtreeElevationRange,[this._ownElevationRange,...this.children.filter(e=>null!=e).map(e=>e.subtreeElevationRange)])&&(t|=2)}return t}}function M(e,t,n,o){t<=0&&(n<=0&&o(e,0),n>=0&&o(e,1)),t>=0&&(n<=0&&o(e,2),n>=0&&o(e,3))}function R(e,t,n){null!=t&&0!==n&&e.push({node:t,childrenUpdateKind:n})}function I(e,t,n){if(null==t||0===n)return;const o=e.get(t)??0;e.set(t,o|n)}class E{constructor(e=[0,0,0],t=0){this.normal=e,this.distance=t}}function V(e,t,n){const o=i(n.normal,e)+n.distance;return o<0?Math.min(o+t,0):Math.max(o-t,0)}function T(e,t){return i(e.normal,t)+e.distance}function y(e,t,n,o,r){if(!n)return null;const s=1e-12,a=i(o.normal,t),l=T(o,e)+n.tMin*a;if(Math.abs(a)<s){return(r?l>=-s:l<=s)?n:null}const u=n.tMin-l/a,h=r===a>0?{tMin:Math.max(n.tMin,u),tMax:n.tMax}:{tMin:n.tMin,tMax:Math.min(n.tMax,u)};return h.tMin<=h.tMax?h:null}function x(e,t,n){const{mbsCenter:o,mbsRadius:i}=t;for(let r=0;r<3;r++)G[r]=o[r]-i,G[r+3]=o[r]+i;return B(e,G,n)}function B(e,t,n){if(l(t))return!1;let o=!1;for(let i=0;i<3;i++){const r=Math.max(n?.[i]??-1/0,t[i]),s=Math.min(n?.[i+3]??1/0,t[i+3]);r<e[i]&&(e[i]=r,o=!0),s>e[i+3]&&(e[i+3]=s,o=!0)}return o}function S(e,t,n){d(L,e),u(e);for(const o of t)x(e,o,n);return!g(e,L)}function N(e,t,n){d(L,e),u(e);for(const o of t)B(e,o,n);return!g(e,L)}function D(e,t){z.setElevationRange(e),e.initializeEmpty();for(const n of t)e.expandElevationRange(n.elevationRange);return!e.equals(z)}function P(e,t){z.setElevationRange(e),e.initializeEmpty();for(const n of t)e.expandElevationRange(n);return!e.equals(z)}const G=a(0,0,0,0,0,0),L=a(0,0,0,0,0,0),z=new p,j=s(),H=30;export{w as Tiles3DBVH};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{
|
|
2
|
+
import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{project as t}from"../../../../geometry/projectionUtils.js";import{fromExtent as i}from"../../../../geometry/support/aaBoundingRect.js";import{Tiles3DTarget as n}from"../i3s/Intersector.js";import{Tiles3DBVH as r}from"./Tiles3DBVH.js";import{ElevationRange as s}from"../../support/ElevationRange.js";import{IntersectorResult as o}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as l,computeInvDir as a,intersectAabbInvDir as c}from"../../webgl-engine/lib/RayIntersections.js";class d{constructor(e){this.layerView=e,this.type=8,this.slicePlaneEnabled=!1,this.isGround=!0,this.layerViewUid=e.uid;const n=e.view.viewingMode,s=e.layer.fullExtent,o=(s?t(s,e.view.renderSpatialReference):void 0)??e.view.extent,l=i(o);this._bvh=r.create(n,l)}destroy(){this._bvh.destroy()}addTile(e){this._bvh.addTile(e)}removeTile(e){this._bvh.removeTile(e)}intersect(e,t,i,r,s,d){if(e.options.filteredLayerViewUids.includes(this.layerView.uid))return;const{results:u,tolerance:h}=e,p=2===e.options.store,{componentObjectCollection:f}=this.layerView.view.stage.renderView,g=new l(h,d,e.options.normalRequired),v=a(i,r,m),w=(s,l,a)=>{if(l<0)return;if(null!=t&&!t(i,r,l))return;const c=e=>{const t=new n(this.layerView.uid);e.set(this.type,t,l,a)};if(this.isGround&&(null==u.ground.distance||l<u.ground.distance)&&c(u.ground),!e.options.isFiltered&&((null==u.min.distance||l<u.min.distance)&&c(u.min),(null==u.max.distance||l>u.max.distance)&&c(u.max),p)){const t=new o(e.ray);c(t),e.results.all.push(t)}};this._bvh.forEachTileIntersectingRay(i,r,e=>{const{componentObjects:t}=e;for(const n of t)c(n.aabbInWorldCoordinates,i,v,0)&&f.intersect(n,i,r,null,g,w)},d)}getElevationRange(e){return this._bvh.getElevationRangeIntersectingSphere(e)??new s(0,0)}}const m=e();export{d as Tiles3DMeshIntersectionHandler};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
class i{constructor(i=1/0,
|
|
2
|
+
class i{constructor(i=1/0,t=-1/0){this.minElevation=i,this.maxElevation=t}get elevationRangeValid(){return!Number.isNaN(this.minElevation)}get isEmpty(){return!(this.minElevation<=this.maxElevation)}contains(i){return this.minElevation<=i.minElevation&&this.maxElevation>=i.maxElevation}invalidateElevationRange(){this.minElevation=NaN}initializeEmpty(){this.minElevation=1/0,this.maxElevation=-1/0}expandElevationRange(i){const t=Math.min(this.minElevation,i.minElevation),a=Math.max(this.maxElevation,i.maxElevation),n=t!==this.minElevation||a!==this.maxElevation;return this.minElevation=t,this.maxElevation=a,n}expandElevationRangeValues(i,t){const a=Math.min(this.minElevation,i),n=Math.max(this.maxElevation,t),e=a!==this.minElevation||n!==this.maxElevation;return this.minElevation=a,this.maxElevation=n,e}setElevationRange(i){this.minElevation=i.minElevation,this.maxElevation=i.maxElevation}setElevationRangeValues(i,t){this.minElevation=i,this.maxElevation=t}equals(i){return this.minElevation===i.minElevation&&this.maxElevation===i.maxElevation}}export{i as ElevationRange};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{signal as
|
|
2
|
+
import{signal as e}from"../../../../core/signal.js";class i{static{this.fadeInEase=e=>e*(2-e)}static{this.fadeOutEase=e=>e*e}constructor(i){this.layerView=i,this._numFadingTiles=e(0),this._tmpFullyFadedOutTiles=new Array}get numFadingTiles(){return this._numFadingTiles.value}fadeTile(e,i){const t=this._getTargetOpacity(i);if(e.fadeDirection=i,0===this.fadeDuration)return void this._instantTileFading(e,t);const a=e.opacityModifier;if(a!==t){const i=1-Math.abs(t-a);this._startTileFading(e,i)}else this._stopTileFading(e)}updateAllTileFading(e){const i=this._tmpFullyFadedOutTiles;i.length=0,this.layerView.tileHandles.forEach(t=>{this._updateTileFading(t,e)&&i.push(t)});i.length>0&&(this.layerView.updateGaussians(),this.layerView.notifyTileObbsChanged(i)),this._numFadingTiles.value>0&&this.layerView.view.stage?.renderView.requestRender(2)}onFadeDurationChanged(e){0===e&&this.numFadingTiles>0&&this._instantlyFullyFadeAllTiles()}isTileFadingOut(e){return null!=e.fadeProgress&&1===e.fadeDirection}onTileDiscarded(e){null!=e.fadeProgress&&this._numFadingTiles.value--}get updating(){return this._numFadingTiles.value>0}get fadeDuration(){return this.layerView.view.qualitySettings.fadeDuration}get fadingEnabled(){return 0!==this.fadeDuration}_startTileFading(e,i){null==e.fadeProgress&&this._numFadingTiles.value++,e.fadeProgress=i}_stopTileFading(e){null!=e.fadeProgress&&(1===e.fadeDirection&&this._onTileFullyFadedOut(e),this._numFadingTiles.value--,e.fadeProgress=null)}_updateTileFading(e,t){const{fadeProgress:a,fadeDirection:s}=e;if(null==a)return!1;const n=this._fadeDirectionToSign(s),l=n*this.fadeDuration,d=this._getTargetOpacity(s),r=t/Math.abs(l||1),u=Math.min(a+r,1),o=n*(1-(0===s?i.fadeInEase:i.fadeOutEase)(u)),g=1===u;if(e.opacityModifier=g?d:d-o,g){const i=1===s;return this._stopTileFading(e),this._updateOpacityModifier(e),i}return e.fadeProgress=u,this._updateOpacityModifier(e),!1}_updateOpacityModifier(e){const i=255*e.opacityModifier;for(let t=0;t<e.pageIds.length;t++){const a=e.pageIds[t];this.layerView.data.fadingTexture.updateBuffer(i,a)}}_instantTileFading(e,i){e.fadeProgress=null,e.opacityModifier=i,this._updateOpacityModifier(e),1===e.fadeDirection&&this._onTileFullyFadedOut(e)}_instantlyFullyFadeAllTiles(){const e=this._tmpFullyFadedOutTiles;e.length=0,this.layerView.tileHandles.forEach(i=>{if(null!=i.fadeProgress){const t=1===i.fadeDirection;this._instantTileFading(i,this._getTargetOpacity(i.fadeDirection)),t&&e.push(i)}});e.length>0&&(this.layerView.updateGaussians(),this.layerView.notifyTileObbsChanged(e)),this._numFadingTiles.value=0}_onTileFullyFadedOut(e){e.isVisible=!1,this.layerView.moveTileToCache(e)}_fadeDirectionToSign(e){return 0===e?1:-1}_getTargetOpacity(e){return 0===e?1:0}}export{i as GaussianSplatFadeHelper};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import"../../../webgl/BufferObject.js";import"../../../webgl/FramebufferObject.js";import"../../../webgl/Program.js";import"../../../../core/has.js";import"../../../webgl/Renderbuffer.js";import r from"../../../webgl/Texture.js";import"../../../../core/Logger.js";import{PixelType as i,SizedPixelFormat as s}from"../../../webgl/enums.js";import"../../../webgl/Util.js";import{initialSplatAtlasTexturePages as a}from"./GaussianSplatAtlasPages.js";import{TextureDescriptor as u}from"../../../webgl/TextureDescriptor.js";class o{constructor(e){this.texture=null,this._fadeTextureCapacity=0,this._rctx=e}ensureCapacity(t){const o=this.texture;if(this._fadeTextureCapacity
|
|
2
|
+
import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import"../../../webgl/BufferObject.js";import"../../../webgl/FramebufferObject.js";import"../../../webgl/Program.js";import"../../../../core/has.js";import"../../../webgl/Renderbuffer.js";import r from"../../../webgl/Texture.js";import"../../../../core/Logger.js";import{PixelType as i,SizedPixelFormat as s}from"../../../webgl/enums.js";import"../../../webgl/Util.js";import{initialSplatAtlasTexturePages as a}from"./GaussianSplatAtlasPages.js";import{TextureDescriptor as u}from"../../../webgl/TextureDescriptor.js";class o{constructor(e){this.texture=null,this._fadeTextureCapacity=0,this._rctx=e}ensureCapacity(t){const o=this.texture;if(this._fadeTextureCapacity>=t&&o?.hasWebGLTextureObject)return;const f=Math.max(Math.ceil(t*e),a),[h,c]=this._evalTextureSize(f),p=h*c,l=this._fadeBuffer,m=new Uint8Array(p);l&&m.set(l.subarray(0,this._fadeTextureCapacity)),this._fadeBuffer=m,this._fadeTextureCapacity=p,this.texture?.dispose();const n=new u;n.width=h,n.height=c,n.pixelFormat=36244,n.dataType=i.UNSIGNED_BYTE,n.internalFormat=s.R8UI,n.unpackAlignment=1,n.wrapMode=33071,n.samplingMode=9728,n.isImmutable=!0,this.texture=new r(this._rctx,n)}updateTexture(e){this.ensureCapacity(e);const t=this.texture.descriptor.width,r=Math.ceil(e/t),i=t*r;this.texture.updateData(0,0,0,t,r,this._fadeBuffer.subarray(0,i))}updateBuffer(e,t){this.ensureCapacity(t+1),this._fadeBuffer&&(this._fadeBuffer[t]=e)}clear(){this._fadeBuffer=void 0,this._fadeTextureCapacity=0,this.texture?.dispose(),this.texture=null}destroy(){this.clear()}_evalTextureSize(e){const r=Math.ceil(Math.sqrt(e)),i=Math.ceil(e/r);return t(r,i)}}export{o as GaussianSplatFadeTexture};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{fromQuat as t,scale as e}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as a}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as s}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as r,conjugate as i,multiply as n}from"../../../core/libs/gl-matrix-2/math/quat.js";import{IDENTITY as o,create as h}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{set as c,transformQuat as f,dot as d,cross as u,len as l,scale as m,transformMat3 as _,add as g,sub as p,abs as b,max as M,min as j,length as S,scaleAndAdd as z,sign as x,multiply as y}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as C,freeze as q,create as A,UNIT_Z as P}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{transformMat4 as Q}from"../../../core/libs/gl-matrix-2/math/vec4.js";import{create as R}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as v}from"../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as w}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{computeTranslationToOriginAndRotation as D}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as H}from"../../../geometry/projection/projectBuffer.js";import{getProjector as F}from"../../../geometry/projection/projectors.js";import{getNormal as k}from"../../../geometry/support/plane.js";import{isPlateCarree as B}from"../../../geometry/support/spatialReferenceUtils.js";import{sv3d as U,sq4d as W}from"../../../geometry/support/vectorStacks.js";import{computeOBB as Z}from"./dito.js";import{Vertices as G}from"../webgl-engine/lib/Attribute.js";class O{constructor(t=C,e=pt,a=o){this._data=[t[0],t[1],t[2],e[0],e[1],e[2],a[0],a[1],a[2],a[3]]}clone(){return O.fromData(this._data)}invalidate(){this._data[3]=-1}get isValid(){return this._data[3]>=0}static fromData(t){const e=new O;return e._copyFromData(t),e}static fromJSON(t){return new O(t.center,t.halfSize,t.quaternion)}copy(t){this._copyFromData(t.data)}_copyFromData(t){for(let e=0;e<10;++e)this._data[e]=t[e]}get center(){return c(U.get(),this._data[0],this._data[1],this._data[2])}get centerX(){return this._data[0]}get centerY(){return this._data[1]}get centerZ(){return this._data[2]}getCenter(t){return t[0]=this._data[0],t[1]=this._data[1],t[2]=this._data[2],t}set center(t){this._data[0]=t[0],this._data[1]=t[1],this._data[2]=t[2]}setCenter(t,e,a){this._data[0]=t,this._data[1]=e,this._data[2]=a}get halfSize(){return c(U.get(),this._data[3],this._data[4],this._data[5])}get halfSizeX(){return this._data[3]}get halfSizeY(){return this._data[4]}get halfSizeZ(){return this._data[5]}getHalfSize(t){return t[0]=this._data[3],t[1]=this._data[4],t[2]=this._data[5],t}set halfSize(t){this._data[3]=t[0],this._data[4]=t[1],this._data[5]=t[2]}get quaternion(){return r(W.get(),this._data[6],this._data[7],this._data[8],this._data[9])}get quaternionConjugate(){return r(W.get(),-this._data[6],-this._data[7],-this._data[8],this._data[9])}getQuaternion(t){return t[0]=this._data[6],t[1]=this._data[7],t[2]=this._data[8],t[3]=this._data[9],t}set quaternion(t){this._data[6]=t[0],this._data[7]=t[1],this._data[8]=t[2],this._data[9]=t[3]}get data(){return this._data}getCorners(t){const e=this._data,a=r(T,e[6],e[7],e[8],e[9]);for(let s=0;s<8;++s){const r=t[s];r[0]=(1&s?-1:1)*e[3],r[1]=(2&s?-1:1)*e[4],r[2]=(4&s?-1:1)*e[5],f(r,r,a),r[0]+=e[0],r[1]+=e[1],r[2]+=e[2]}return t}getAxes(t){const e=this._data,a=r(T,e[6],e[7],e[8],e[9]);return f(t[0],[1,0,0],a),f(t[1],[0,1,0],a),f(t[2],[0,0,1],a),t}intersectsFrustum(t){const e=this.center,a=t.planes;for(const f of a){const t=k(f),a=this.projectedRadius(t);if(d(t,e)+f[3]-a>0)return!1}const s=this.getAxes(lt),r=t.points,i=this.halfSize;for(let f=0;f<3;++f){const t=s[f],a=-d(t,e),n=i[f];let o=!0,h=!0;for(const e of r){const s=d(e,t)+a;o&&=s>n,h&&=s<-n}if(o||h)return!1}if(this.getCorners(ut).some(e=>t.intersectsPoint(e)))return!0;const n=jt;for(let f=0;f<3;++f){const t=s[f];n[f]=d(t,e)}const o=t=>{for(let e=0;e<3;++e){const a=s[e],r=i[e],o=d(a,t)-n[e];if(o>r||o<-r)return!1}return!0};if(t.points.some(t=>o(t)))return!0;const h=t.lines,c=Mt;for(let f=0;f<8;++f){const t=h[f].direction;for(const a of s){u(c,t,a);const s=l(c);if(!(s>0))continue;m(c,c,1/s);const i=this.projectedRadius(c),n=d(e,c),o=n-i,h=n+i;let f=!1,_=!1,g=!0;for(const t of r){const e=d(c,t);if(e>h){if(_){g=!1;break}f=!0}else{if(!(e<o)){g=!1;break}if(f){g=!1;break}_=!0}}if(g)return!1}}return!0}intersectsFrustumConservativeApproximation(t){return this.intersectPlane(t[0])<=0&&this.intersectPlane(t[1])<=0&&this.intersectPlane(t[2])<=0&&this.intersectPlane(t[3])<=0&&this.intersectPlane(t[4])<=0&&this.intersectPlane(t[5])<=0}get radius(){const t=this._data[3],e=this._data[4],a=this._data[5];return Math.sqrt(t*t+e*e+a*a)}intersectsPoint(t){const e=this.getAxes(lt),a=this.halfSize,{center:s}=this;for(let r=0;r<3;++r){const i=e[r],n=a[r],o=d(i,t)-d(i,s);if(o>n||o<-n)return!1}return!0}intersectSphere(t){const{center:e,radius:a}=t,s=this._data,r=s[3],i=s[4],n=s[5],o=r+i+n+a,h=s[0]-e[0];if(Math.abs(h)>o)return!1;const c=s[1]-e[1];if(Math.abs(c)>o)return!1;const f=s[2]-e[2];if(Math.abs(f)>o)return!1;const d=-s[6],u=-s[7],l=-s[8],m=u*f-l*c,_=l*h-d*f,g=d*c-u*h,p=u*g-l*_,b=l*m-d*g,M=d*_-u*m,j=2*s[9],S=Math.abs(h+m*j+2*p),z=Math.abs(c+_*j+2*b),x=Math.abs(f+g*j+2*M),y=S-Math.min(S,r),C=z-Math.min(z,i),q=x-Math.min(x,n);return y*y+C*C+q*q<=a*a}intersectSphereWithMBS(t,e=this.radius){const a=this._data,{center:s,radius:r}=t,i=e+r,n=a[0]-s[0];if(n>i)return!1;const o=a[1]-s[1];if(o>i)return!1;const h=a[2]-s[2];if(h>i)return!1;if(n*n+o*o+h*h>i*i)return!1;const c=-a[6],f=-a[7],d=-a[8],u=f*h-d*o,l=d*n-c*h,m=c*o-f*n,_=f*m-d*l,g=d*u-c*m,p=c*l-f*u,b=2*a[9],M=Math.abs(n+u*b+2*_),j=Math.abs(o+l*b+2*g),S=Math.abs(h+m*b+2*p),z=M-Math.min(M,a[3]),x=j-Math.min(j,a[4]),y=S-Math.min(S,a[5]);return z*z+x*x+y*y<r*r}intersectPlane(t){const e=t[0]*this._data[0]+t[1]*this._data[1]+t[2]*this._data[2]+t[3],a=this.projectedRadius(k(t));return e>a?1:e<-a?-1:0}intersectRay(t,e,a=0){const s=this._data,r=T;r[0]=-s[6],r[1]=-s[7],r[2]=-s[8],r[3]=s[9],E[0]=t[0]-s[0],E[1]=t[1]-s[1],E[2]=t[2]-s[2];const i=f(E,E,T),n=f(I,e,T);let o=-1/0,h=1/0;const c=this.getHalfSize(ct);for(let f=0;f<3;f++){const t=i[f],e=n[f],s=c[f]+a;if(Math.abs(e)>1e-6){const a=(s-t)/e,r=(-s-t)/e;o=Math.max(o,Math.min(a,r)),h=Math.min(h,Math.max(a,r))}else if(t>s||t<-s)return!1}return o<=h}projectedArea(a,s,r,n){const o=this.getQuaternion(X);i(T,o),E[0]=a[0]-this._data[0],E[1]=a[1]-this._data[1],E[2]=a[2]-this._data[2],f(E,E,T);const h=this.getHalfSize(ct),d=E[0]<-h[0]?-1:E[0]>h[0]?1:0,u=E[1]<-h[1]?-1:E[1]>h[1]?1:0,l=E[2]<-h[2]?-1:E[2]>h[2]?1:0,m=Math.abs(d)+Math.abs(u)+Math.abs(l);if(0===m)return 1/0;const p=1===m?4:6,b=6*(d+3*u+9*l+13);t(ft,o),e(ft,ft,h);const M=this.getCenter(ot);for(let t=0;t<p;t++){const e=K[b+t];c(E,((1&e)<<1)-1,(2&e)-1,((4&e)>>1)-1),_(E,E,ft),g(J,M,E),J[3]=1,Q(J,J,s);const a=1/Math.max(1e-6,J[3]);V[2*t]=J[0]*a,V[2*t+1]=J[1]*a}const j=2*p-2;let S=V[0]*(V[3]-V[j+1])+V[j]*(V[1]-V[j-1]);for(let t=2;t<j;t+=2)S+=V[t]*(V[t+3]-V[t-1]);return Math.abs(S)*r*n*.125}projectedRadius(t){const e=this.getQuaternion(X);return i(T,e),f(E,t,T),Math.abs(E[0]*this._data[3])+Math.abs(E[1]*this._data[4])+Math.abs(E[2]*this._data[5])}minimumDistancePlane(t){return t[0]*this._data[0]+t[1]*this._data[1]+t[2]*this._data[2]+t[3]-this.projectedRadius(k(t))}maximumDistancePlane(t){return t[0]*this._data[0]+t[1]*this._data[1]+t[2]*this._data[2]+t[3]+this.projectedRadius(k(t))}toAaBoundingBox(e){const a=this.getQuaternion(X),s=t(ft,a),r=this._data[3]*Math.abs(s[0])+this._data[4]*Math.abs(s[3])+this._data[5]*Math.abs(s[6]),i=this._data[3]*Math.abs(s[1])+this._data[4]*Math.abs(s[4])+this._data[5]*Math.abs(s[7]),n=this._data[3]*Math.abs(s[2])+this._data[4]*Math.abs(s[5])+this._data[5]*Math.abs(s[8]);e[0]=this._data[0]-r,e[1]=this._data[1]-i,e[2]=this._data[2]-n,e[3]=this._data[0]+r,e[4]=this._data[1]+i,e[5]=this._data[2]+n}transform(t,e,a,s=0,r=w(a),i=w(e),n=F(e,i)){if(a===r)e.isGeographic?st(this,t,e,s,i):at(this,t,e,s,i,n);else if(e.isGeographic&&(a.isWebMercator||B(a)))$(e,this,a,t,s);else if(e.isWebMercator&&B(a))tt(e,this,a,t,s);else{const r=this.getCenter(ot);r[2]+=s,H(r,e,0,r,a,0),t.center=r,this!==t&&(t.quaternion=this.getQuaternion(X),t.halfSize=this.getHalfSize(ct))}}}const T=h(),X=h(),Y=h(),E=A(),I=A(),J=R();function N(t,e=new O){return Z(t,e),e}const V=[.1,.2,.3,.4,.5,.6,.7,.8,.9,1,1.1,1.2],K=(()=>{const t=new Int8Array(162);let e=0;const a=a=>{for(let s=0;s<a.length;s++)t[e+s]=a[s];e+=6};return a([6,2,3,1,5,4]),a([0,2,3,1,5,4]),a([0,2,3,7,5,4]),a([0,1,3,2,6,4]),a([0,1,3,2,0,0]),a([0,1,5,7,3,2]),a([0,1,3,7,6,4]),a([0,1,3,7,6,2]),a([0,1,5,7,6,2]),a([0,1,5,4,6,2]),a([0,1,5,4,0,0]),a([0,1,3,7,5,4]),a([0,2,6,4,0,0]),a([0,0,0,0,0,0]),a([1,3,7,5,0,0]),a([2,3,7,6,4,0]),a([2,3,7,6,0,0]),a([2,3,1,5,7,6]),a([0,1,5,7,6,2]),a([0,1,5,7,6,4]),a([0,1,3,7,6,4]),a([4,5,7,6,2,0]),a([4,5,7,6,0,0]),a([4,5,1,3,7,6]),a([0,2,3,7,5,4]),a([6,2,3,7,5,4]),a([6,2,3,1,5,4]),t})();function L(t,e,a,s,r){const n=t.getQuaternion(X);r.quaternion=n,i(T,n);const o=t.getCenter(ot),h=t.getHalfSize(ct);if(1===s){f(mt,o,T),b(_t,mt),j(gt,_t,h),p(gt,_t,gt);const s=S(gt);g(gt,_t,h);const i=S(gt);if(s<a)r.center=o,c(mt,a,a,a),r.halfSize=g(mt,h,mt);else{const n=i>0?1+e/i:1,o=s>0?1+a/s:1,c=(o+n)/2,d=(o-n)/2;m(gt,_t,d),r.halfSize=z(gt,gt,h,c),m(gt,_t,c),z(gt,gt,h,d),x(mt,mt),y(mt,gt,mt);const u=t.getQuaternion(Y);r.center=f(mt,mt,u)}}else{r.center=z(mt,o,P,(a+e)/2);const t=f(mt,P,T);b(t,t),r.halfSize=z(_t,h,t,(a-e)/2)}return r}function $(t,e,a,s,r){e.getCenter(ot),ot[2]+=r;const i=w(a);H(ot,t,0,ot,i,0),et(i,e,ot,a,s)}function tt(t,e,a,s,r){e.getCenter(ot),ot[2]+=r,et(t,e,ot,a,s)}function et(e,a,s,r,i){const n=a.getQuaternion(X),o=t(ft,n),h=a.getHalfSize(ct);for(let t=0;t<8;++t){for(let e=0;e<3;++e)nt[e]=h[e]*(t&1<<e?-1:1);for(let e=0;e<3;++e){let a=s[e];for(let t=0;t<3;++t)a+=nt[t]*o[3*t+e];rt[3*t+e]=a}}H(rt,e,0,rt,r,0,8),N(it,i)}function at(t,e,a,s,r=w(a),o=F(a,r)){t.getCorners(ut),t.getCenter(nt),nt[2]+=s,D(a,nt,dt,r),e.setCenter(dt[12],dt[13],dt[14]);const h=2*Math.sqrt(1+dt[0]+dt[5]+dt[10]);T[0]=(dt[6]-dt[9])/h,T[1]=(dt[8]-dt[2])/h,T[2]=(dt[1]-dt[4])/h,T[3]=.25*h;const d=t.getQuaternion(X);e.quaternion=n(T,T,d),i(T,T),c(_t,0,0,0);const u=e.getCenter(ht);for(const i of ut)i[2]+=s,o(i,0,i,0),p(mt,i,u),f(mt,mt,T),b(mt,mt),M(_t,_t,mt);e.halfSize=_t}function st(t,e,a,s,r=w(a)){const n=v(a),o=1+Math.max(0,s)/(n.radius+t.centerZ);t.getCenter(nt),nt[2]+=s,H(nt,a,0,nt,r,0),e.center=nt;const h=t.getQuaternion(X);e.quaternion=h,i(T,h),c(mt,0,0,1),f(mt,mt,T);const d=t.getHalfSize(ct);c(mt,d[0]*Math.abs(mt[0]),d[1]*Math.abs(mt[1]),d[2]*Math.abs(mt[2])),m(mt,mt,n.inverseFlattening),g(mt,d,mt),e.halfSize=m(mt,mt,o)}const rt=new Array(24),it=new G(rt,3),nt=A(),ot=A(),ht=A(),ct=A(),ft=a(),dt=s(),ut=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],lt=[A(),A(),A()],mt=A(),_t=A(),gt=A(),pt=q(-1,-1,-1);function bt(t){return Array.from(t)}const Mt=A(),jt=[0,0,0];export{O as Obb,N as compute,L as computeOffsetObb,bt as ensurePackedObbData};
|
|
2
|
+
import{fromQuat as t,scale as e}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as a}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as s}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as r,conjugate as i,multiply as n}from"../../../core/libs/gl-matrix-2/math/quat.js";import{IDENTITY as o,create as h}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{set as c,transformQuat as d,dot as f,cross as u,len as l,scale as m,transformMat3 as _,add as g,sub as p,abs as b,max as M,min as j,length as S,scaleAndAdd as z,sign as x,multiply as y}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as C,freeze as q,create as A,UNIT_Z as P}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{transformMat4 as Q}from"../../../core/libs/gl-matrix-2/math/vec4.js";import{create as R}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as v}from"../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as w}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{computeTranslationToOriginAndRotation as D}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as H}from"../../../geometry/projection/projectBuffer.js";import{getProjector as F}from"../../../geometry/projection/projectors.js";import{getNormal as k}from"../../../geometry/support/plane.js";import{isPlateCarree as B}from"../../../geometry/support/spatialReferenceUtils.js";import{sv3d as Z,sq4d as U}from"../../../geometry/support/vectorStacks.js";import{computeOBB as W}from"./dito.js";import{Vertices as X}from"../webgl-engine/lib/Attribute.js";class Y{constructor(t=C,e=pt,a=o){this._data=[t[0],t[1],t[2],e[0],e[1],e[2],a[0],a[1],a[2],a[3]]}clone(){return Y.fromData(this._data)}invalidate(){this._data[3]=-1}get isValid(){return this._data[3]>=0}static fromData(t){const e=new Y;return e._copyFromData(t),e}static fromJSON(t){return new Y(t.center,t.halfSize,t.quaternion)}copy(t){this._copyFromData(t.data)}_copyFromData(t){for(let e=0;e<10;++e)this._data[e]=t[e]}get center(){return c(Z.get(),this._data[0],this._data[1],this._data[2])}get centerX(){return this._data[0]}get centerY(){return this._data[1]}get centerZ(){return this._data[2]}getCenter(t){return t[0]=this._data[0],t[1]=this._data[1],t[2]=this._data[2],t}set center(t){this._data[0]=t[0],this._data[1]=t[1],this._data[2]=t[2]}setCenter(t,e,a){this._data[0]=t,this._data[1]=e,this._data[2]=a}get halfSize(){return c(Z.get(),this._data[3],this._data[4],this._data[5])}get halfSizeX(){return this._data[3]}get halfSizeY(){return this._data[4]}get halfSizeZ(){return this._data[5]}getHalfSize(t){return t[0]=this._data[3],t[1]=this._data[4],t[2]=this._data[5],t}set halfSize(t){this._data[3]=t[0],this._data[4]=t[1],this._data[5]=t[2]}get quaternion(){return r(U.get(),this._data[6],this._data[7],this._data[8],this._data[9])}get quaternionConjugate(){return r(U.get(),-this._data[6],-this._data[7],-this._data[8],this._data[9])}getQuaternion(t){return t[0]=this._data[6],t[1]=this._data[7],t[2]=this._data[8],t[3]=this._data[9],t}getQuaternionConjugate(t){return t[0]=-this._data[6],t[1]=-this._data[7],t[2]=-this._data[8],t[3]=this._data[9],t}set quaternion(t){this._data[6]=t[0],this._data[7]=t[1],this._data[8]=t[2],this._data[9]=t[3]}get data(){return this._data}getCorners(t){const e=this._data,a=r(G,e[6],e[7],e[8],e[9]);for(let s=0;s<8;++s){const r=t[s];r[0]=(1&s?-1:1)*e[3],r[1]=(2&s?-1:1)*e[4],r[2]=(4&s?-1:1)*e[5],d(r,r,a),r[0]+=e[0],r[1]+=e[1],r[2]+=e[2]}return t}getAxes(t){const e=this._data,a=r(G,e[6],e[7],e[8],e[9]);return d(t[0],[1,0,0],a),d(t[1],[0,1,0],a),d(t[2],[0,0,1],a),t}intersectsFrustum(t){const{centerX:e,centerY:a,centerZ:s}=this,r=t.planes;for(const f of r){const t=k(f),r=this.projectedRadius(t);if(e*t[0]+a*t[1]+s*t[2]+f[3]-r>0)return!1}const i=this.getAxes(lt),n=t.points,o=this.halfSize;for(let u=0;u<3;++u){const t=i[u],r=-t[0]*e-t[1]*a-t[2]*s,h=o[u];let c=!0,d=!0;for(const e of n){const a=f(e,t)+r;c&&=a>h,d&&=a<-h}if(c||d)return!1}if(this.getCorners(ut).some(e=>t.intersectsPoint(e)))return!0;const h=jt;for(let f=0;f<3;++f){const t=i[f];h[f]=t[0]*e+t[1]*a+t[2]*s}const c=t=>{for(let e=0;e<3;++e){const a=i[e],s=o[e],r=a[0]*t[0]+a[1]*t[1]+a[2]*t[2]-h[e];if(r>s||r<-s)return!1}return!0};if(t.points.some(t=>c(t)))return!0;const d=t.lines,_=Mt;for(let g=0;g<8;++g){const t=d[g].direction;for(const r of i){u(_,t,r);const i=l(_);if(!(i>0))continue;m(_,_,1/i);const o=this.projectedRadius(_),h=_[0]*e+_[1]*a+_[2]*s,c=h-o,d=h+o;let g=!1,p=!1,b=!0;for(const t of n){const e=f(_,t);if(e>d){if(p){b=!1;break}g=!0}else{if(!(e<c)){b=!1;break}if(g){b=!1;break}p=!0}}if(b)return!1}}return!0}intersectsFrustumConservativeApproximation(t){return this.intersectPlane(t[0])<=0&&this.intersectPlane(t[1])<=0&&this.intersectPlane(t[2])<=0&&this.intersectPlane(t[3])<=0&&this.intersectPlane(t[4])<=0&&this.intersectPlane(t[5])<=0}get radius(){const t=this._data[3],e=this._data[4],a=this._data[5];return Math.sqrt(t*t+e*e+a*a)}intersectsPoint(t){const e=this.getAxes(lt),a=this.halfSize,{center:s}=this;for(let r=0;r<3;++r){const i=e[r],n=a[r],o=f(i,t)-f(i,s);if(o>n||o<-n)return!1}return!0}intersectSphere(t){const{center:e,radius:a}=t,s=this._data,r=s[3],i=s[4],n=s[5],o=r+i+n+a,h=s[0]-e[0];if(Math.abs(h)>o)return!1;const c=s[1]-e[1];if(Math.abs(c)>o)return!1;const d=s[2]-e[2];if(Math.abs(d)>o)return!1;const f=-s[6],u=-s[7],l=-s[8],m=u*d-l*c,_=l*h-f*d,g=f*c-u*h,p=u*g-l*_,b=l*m-f*g,M=f*_-u*m,j=2*s[9],S=Math.abs(h+m*j+2*p),z=Math.abs(c+_*j+2*b),x=Math.abs(d+g*j+2*M),y=S-Math.min(S,r),C=z-Math.min(z,i),q=x-Math.min(x,n);return y*y+C*C+q*q<=a*a}intersectSphereWithMBS(t,e=this.radius){const a=this._data,{center:s,radius:r}=t,i=e+r,n=a[0]-s[0];if(n>i)return!1;const o=a[1]-s[1];if(o>i)return!1;const h=a[2]-s[2];if(h>i)return!1;if(n*n+o*o+h*h>i*i)return!1;const c=-a[6],d=-a[7],f=-a[8],u=d*h-f*o,l=f*n-c*h,m=c*o-d*n,_=d*m-f*l,g=f*u-c*m,p=c*l-d*u,b=2*a[9],M=Math.abs(n+u*b+2*_),j=Math.abs(o+l*b+2*g),S=Math.abs(h+m*b+2*p),z=M-Math.min(M,a[3]),x=j-Math.min(j,a[4]),y=S-Math.min(S,a[5]);return z*z+x*x+y*y<r*r}intersectPlane(t){const e=t[0]*this._data[0]+t[1]*this._data[1]+t[2]*this._data[2]+t[3],a=this.projectedRadius(k(t));return e>a?1:e<-a?-1:0}intersectRay(t,e,a=0){const s=this._data,r=G;r[0]=-s[6],r[1]=-s[7],r[2]=-s[8],r[3]=s[9],E[0]=t[0]-s[0],E[1]=t[1]-s[1],E[2]=t[2]-s[2];const i=d(E,E,G),n=d(I,e,G);let o=-1/0,h=1/0;const c=this.getHalfSize(ct);for(let d=0;d<3;d++){const t=i[d],e=n[d],s=c[d]+a;if(Math.abs(e)>1e-6){const a=(s-t)/e,r=(-s-t)/e;o=Math.max(o,Math.min(a,r)),h=Math.min(h,Math.max(a,r))}else if(t>s||t<-s)return!1}return o<=h}projectedArea(a,s,r,n){const o=this.getQuaternion(O);i(G,o),E[0]=a[0]-this._data[0],E[1]=a[1]-this._data[1],E[2]=a[2]-this._data[2],d(E,E,G);const h=this.getHalfSize(ct),f=E[0]<-h[0]?-1:E[0]>h[0]?1:0,u=E[1]<-h[1]?-1:E[1]>h[1]?1:0,l=E[2]<-h[2]?-1:E[2]>h[2]?1:0,m=Math.abs(f)+Math.abs(u)+Math.abs(l);if(0===m)return 1/0;const p=1===m?4:6,b=6*(f+3*u+9*l+13);t(dt,o),e(dt,dt,h);const M=this.getCenter(ot);for(let t=0;t<p;t++){const e=K[b+t];c(E,((1&e)<<1)-1,(2&e)-1,((4&e)>>1)-1),_(E,E,dt),g(J,M,E),J[3]=1,Q(J,J,s);const a=1/Math.max(1e-6,J[3]);V[2*t]=J[0]*a,V[2*t+1]=J[1]*a}const j=2*p-2;let S=V[0]*(V[3]-V[j+1])+V[j]*(V[1]-V[j-1]);for(let t=2;t<j;t+=2)S+=V[t]*(V[t+3]-V[t-1]);return Math.abs(S)*r*n*.125}projectedRadius(t){const e=this.getQuaternion(O);return i(G,e),d(E,t,G),Math.abs(E[0]*this._data[3])+Math.abs(E[1]*this._data[4])+Math.abs(E[2]*this._data[5])}minimumDistancePlane(t){return t[0]*this._data[0]+t[1]*this._data[1]+t[2]*this._data[2]+t[3]-this.projectedRadius(k(t))}maximumDistancePlane(t){return t[0]*this._data[0]+t[1]*this._data[1]+t[2]*this._data[2]+t[3]+this.projectedRadius(k(t))}toAaBoundingBox(e){const a=this.getQuaternion(O),s=t(dt,a),r=this._data[3]*Math.abs(s[0])+this._data[4]*Math.abs(s[3])+this._data[5]*Math.abs(s[6]),i=this._data[3]*Math.abs(s[1])+this._data[4]*Math.abs(s[4])+this._data[5]*Math.abs(s[7]),n=this._data[3]*Math.abs(s[2])+this._data[4]*Math.abs(s[5])+this._data[5]*Math.abs(s[8]);e[0]=this._data[0]-r,e[1]=this._data[1]-i,e[2]=this._data[2]-n,e[3]=this._data[0]+r,e[4]=this._data[1]+i,e[5]=this._data[2]+n}transform(t,e,a,s=0,r=w(a),i=w(e),n=F(e,i)){if(a===r)e.isGeographic?st(this,t,e,s,i):at(this,t,e,s,i,n);else if(e.isGeographic&&(a.isWebMercator||B(a)))$(e,this,a,t,s);else if(e.isWebMercator&&B(a))tt(e,this,a,t,s);else{const r=this.getCenter(ot);r[2]+=s,H(r,e,0,r,a,0),t.center=r,this!==t&&(t.quaternion=this.getQuaternion(O),t.halfSize=this.getHalfSize(ct))}}}const G=h(),O=h(),T=h(),E=A(),I=A(),J=R();function N(t,e=new Y){return W(t,e),e}const V=[.1,.2,.3,.4,.5,.6,.7,.8,.9,1,1.1,1.2],K=(()=>{const t=new Int8Array(162);let e=0;const a=a=>{for(let s=0;s<a.length;s++)t[e+s]=a[s];e+=6};return a([6,2,3,1,5,4]),a([0,2,3,1,5,4]),a([0,2,3,7,5,4]),a([0,1,3,2,6,4]),a([0,1,3,2,0,0]),a([0,1,5,7,3,2]),a([0,1,3,7,6,4]),a([0,1,3,7,6,2]),a([0,1,5,7,6,2]),a([0,1,5,4,6,2]),a([0,1,5,4,0,0]),a([0,1,3,7,5,4]),a([0,2,6,4,0,0]),a([0,0,0,0,0,0]),a([1,3,7,5,0,0]),a([2,3,7,6,4,0]),a([2,3,7,6,0,0]),a([2,3,1,5,7,6]),a([0,1,5,7,6,2]),a([0,1,5,7,6,4]),a([0,1,3,7,6,4]),a([4,5,7,6,2,0]),a([4,5,7,6,0,0]),a([4,5,1,3,7,6]),a([0,2,3,7,5,4]),a([6,2,3,7,5,4]),a([6,2,3,1,5,4]),t})();function L(t,e,a,s,r){const n=t.getQuaternion(O);r.quaternion=n,i(G,n);const o=t.getCenter(ot),h=t.getHalfSize(ct);if(1===s){d(mt,o,G),b(_t,mt),j(gt,_t,h),p(gt,_t,gt);const s=S(gt);g(gt,_t,h);const i=S(gt);if(s<a)r.center=o,c(mt,a,a,a),r.halfSize=g(mt,h,mt);else{const n=i>0?1+e/i:1,o=s>0?1+a/s:1,c=(o+n)/2,f=(o-n)/2;m(gt,_t,f),r.halfSize=z(gt,gt,h,c),m(gt,_t,c),z(gt,gt,h,f),x(mt,mt),y(mt,gt,mt);const u=t.getQuaternion(T);r.center=d(mt,mt,u)}}else{r.center=z(mt,o,P,(a+e)/2);const t=d(mt,P,G);b(t,t),r.halfSize=z(_t,h,t,(a-e)/2)}return r}function $(t,e,a,s,r){e.getCenter(ot),ot[2]+=r;const i=w(a);H(ot,t,0,ot,i,0),et(i,e,ot,a,s)}function tt(t,e,a,s,r){e.getCenter(ot),ot[2]+=r,et(t,e,ot,a,s)}function et(e,a,s,r,i){const n=a.getQuaternion(O),o=t(dt,n),h=a.getHalfSize(ct);for(let t=0;t<8;++t){for(let e=0;e<3;++e)nt[e]=h[e]*(t&1<<e?-1:1);for(let e=0;e<3;++e){let a=s[e];for(let t=0;t<3;++t)a+=nt[t]*o[3*t+e];rt[3*t+e]=a}}H(rt,e,0,rt,r,0,8),N(it,i)}function at(t,e,a,s,r=w(a),o=F(a,r)){t.getCorners(ut),t.getCenter(nt),nt[2]+=s,D(a,nt,ft,r),e.setCenter(ft[12],ft[13],ft[14]);const h=2*Math.sqrt(1+ft[0]+ft[5]+ft[10]);G[0]=(ft[6]-ft[9])/h,G[1]=(ft[8]-ft[2])/h,G[2]=(ft[1]-ft[4])/h,G[3]=.25*h;const f=t.getQuaternion(O);e.quaternion=n(G,G,f),i(G,G),c(_t,0,0,0);const u=e.getCenter(ht);for(const i of ut)i[2]+=s,o(i,0,i,0),p(mt,i,u),d(mt,mt,G),b(mt,mt),M(_t,_t,mt);e.halfSize=_t}function st(t,e,a,s,r=w(a)){const n=v(a),o=1+Math.max(0,s)/(n.radius+t.centerZ);t.getCenter(nt),nt[2]+=s,H(nt,a,0,nt,r,0),e.center=nt;const h=t.getQuaternion(O);e.quaternion=h,i(G,h),c(mt,0,0,1),d(mt,mt,G);const f=t.getHalfSize(ct);c(mt,f[0]*Math.abs(mt[0]),f[1]*Math.abs(mt[1]),f[2]*Math.abs(mt[2])),m(mt,mt,n.inverseFlattening),g(mt,f,mt),e.halfSize=m(mt,mt,o)}const rt=new Array(24),it=new X(rt,3),nt=A(),ot=A(),ht=A(),ct=A(),dt=a(),ft=s(),ut=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],lt=[A(),A(),A()],mt=A(),_t=A(),gt=A(),pt=q(-1,-1,-1);function bt(t){return Array.from(t)}const Mt=A(),jt=[0,0,0];export{Y as Obb,N as compute,L as computeOffsetObb,bt as ensurePackedObbData};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import{disposeMaybe as t}from"../../../core/maybe.js";import{MemCachePool as i}from"../../../core/MemCachePool.js";import r from"../../../core/ObjectPool.js";import{watch as s,sync as n}from"../../../core/reactiveUtils.js";import{property as a,subclass as l}from"../../../core/accessorSupport/decorators.js";import{subtract as o,set as c,dot as d}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as h,fromValues as u,create as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as g,ZEROS as f}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as p,set as m}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as y}from"../../../geometry/support/buffer/BufferView.js";import{overlayRenderOccludedFlag as b}from"./OverlayRenderer.js";import{PatchRenderData as x}from"./PatchRenderData.js";import{TerrainAttributesCache as T}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as R}from"./terrainUtils.js";import{TileRenderer as v}from"./TileRenderer.js";import{IteratorPreorder as O,fallsWithinLayerView as P,sortTiles as w,compareTiles as D}from"./tileUtils.js";import{getOverlayContentForOutputTerrain as S}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{SyncRenderPlugin as B}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as E}from"../webgl-engine/lib/Attribute.js";import{IntersectorResult as F}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as j,MeshIntersectionOptions as q,intersectTriangles as C}from"../webgl-engine/lib/RayIntersections.js";import{TriangleIntersectionData as A}from"../webgl-engine/lib/TriangleIntersectionData.js";import{terrainId as M,getVerticalOffsetTerrain as G}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as U}from"../webgl-engine/materials/DrawParameters.js";import{T as k}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as I}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as N}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as L}from"../../webgl/enums.js";const V=7,z=10,H=200,Q=p();let W=class extends B{get visibleTiles(){return Array.from(this._visiblePatchesByOrigin.values()).flat()}get _isGlobal(){return 1===this._stage.viewingMode}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}get renderOccludedFlags(){return this._overlayRenderer.renderOccludedFlags}constructor(e,t,s,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=s,this._compressionTracker=n,this.type=7,this.isGround=!0,this._passParameters=new k,this._drawParameters=new U,this._renderDataPool=new r(()=>new x),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new O,this._castShadows=!1,this._inViewshed=!1,this._cutFillEnabled=!1,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.produces=new Map([[1,()=>1===this._desiredSlot],[6,()=>6===this._desiredSlot],[8,()=>8===this._desiredSlot],[10,()=>this._produces()&&this.renderOccludedFlags===b]]),this._tileSize=256,this._configuration=new N(1===t.viewingMode),this._tileTextureCache=new i((e,t)=>a.newCache(e,t),"TileTexture"),this.tileGeometryCache=new T(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(s(()=>this._overlayRenderer.renderOccludedFlags,()=>this.setNeedsRender(),n))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}get _oitEnabled(){return this._stage.renderer.oitEnabled}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get layerViewUid(){return M}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,32)}reuseTextureFromParent(e){const{parent:t}=e;if(!this._canReuseTextureFromParent(t,e))return!1;const i=g(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}_canReuseTextureFromParent(e,t){if(!e)return!1;const{layerInfo:i,surface:r}=t;for(let s=0;s<i[1].length;s++){const i=r.layerViewByIndex(s,1);if(P(e,i)!==P(t,i))return!1}return!0}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,32===t?0:2),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[0])i.pendingUpdates&=-9;e.resetPendingUpdate(8);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=z-V,i=Math.max(0,Math.floor((e.level-t)/V)*V);if(this._isGlobal&&0===i)return h;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=1){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=1){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=1){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new v(this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=t(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&0!==this.transparency)return;const s=Z,n=J;o(s,r,i),c(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,l=e.results.max,h=e.results.ground,u=0===e.options.store,_=!!e.results.ground.target,g=G(e.verticalOffset),f=e.tolerance;let p,b=u&&null!=a.distance?a.distance:1/0;const x=e.options,T=x.normalRequired||!x.backfacesTerrain,R=new q(f,!1,T),v=c=>{const _=c.renderData;if(!_?.vao)return;const v=_.geometry;m(Q,v.boundingBox);const O=_.localOrigin;null!=g&&(g.localOrigin=O,g.applyToAabb(Q));const P=Q;if(K[0]=i[0]-O[0],K[1]=i[1]-O[1],K[2]=i[2]-O[2],!j(P,K,n,f,b))return;const w=(e,t,i)=>{e.set(this.type,c,t,i),b=u&&null!=a.distance?a.distance:1/0},D=(n,o,c)=>{if((!T||null!=c)&&n>=0&&(x.backfacesTerrain||d(c,s)<0)&&(x.invisibleTerrain||!x.selectionMode||null==t||t(i,r,n))){if((null==h.distance||n<h.distance)&&w(h,n,c),x.isFiltered)return;2===x.store&&(null==p?(p=new F(e.ray),w(p,n,c),e.results.all.push(p)):n<p.distance&&w(p,n,c)),(null==a.distance||n<a.distance)&&w(a,n,c),0!==x.store&&(null==l.distance||n>l.distance)&&w(l,n,c)}},S=X;o(S,r,O);const{indices:B,indexCount:q}=v,M=v.vertexAttributes,G=M.getField("position",y),U=new E(G.typedBuffer,3,M.stride/4),k=q/3;if(!g&&k>H){const e=c.renderData;e.intersectionData??=new A(B,k,U),e.intersectionData.intersectRay(K,S,R,D)}else C(K,S,0,k,B,U,g,R,D)},O=this._rootTiles;if(null!=O){(()=>{const t=this._tileIterator;t.reset(O);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==g&&!e.intersectsRay(i,s,f,b)||_&&this._useStencilForTile(e)?t.skipSubtree():v(e)})()}}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}get _desiredSlot(){if(!this._produces())return null;switch(this.transparency){case 0:return 1;case 1:case 2:return this._oitEnabled?8:6;case 3:case 4:return null}}acquireTechniques(e){const{shadowMap:t,viewshedEnabled:i,cutFillEnabled:r,slot:s,hasEmission:n,hasFloatOit:a}=e.bind,l=!!has("enable-feature:terrain-shadows")&&t.enabled;if(l!==this._castShadows&&(this._castShadows=l,this._patchesByOriginDirty=!0),this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),this._cutFillEnabled!==r&&(this._cutFillEnabled=r,this._patchesByOriginDirty=!0),3===this.transparency)return null;if(10===s){if(0===(e.renderOccludedMask&b))return null}else if(s!==this._desiredSlot)return null;const o=this._configuration;switch(o.screenSpaceReflections=o.cloudReflections=o.receiveShadows=o.receiveAmbientOcclusion=o.renderOccluded=o.hasHighlightMixTexture=o.hasEmission=!1,o.overlayMode=this._overlayRenderer.mode,o.hasFloatOit=a.value,e.output){case 0:case 1:case 2:{const{ssr:i,clouds:r,ssao:a}=e.bind;o.screenSpaceReflections=null!=i.lastFrameColor,o.cloudReflections=null!=r.data;const l=10===s;return o.receiveShadows=t.ready&&!l,o.renderOccluded=l,o.receiveAmbientOcclusion=!l&&null!=a,o.hasEmission=n,this._acquireTechnique(e.output)}case 5:case 7:return this._castShadows?this._acquireTechnique(5):null;case 8:return this._inViewshed?this._acquireTechnique(8):null;case 9:return this._cutFillEnabled?this._acquireTechnique(9):null;case 3:case 4:return this._acquireTechnique(e.output);case 11:return this._acquireTechnique(11);case 10:return o.hasHighlightMixTexture=null!=e.bind.highlightMixTexture,this._overlayRenderer.hasHighlights?this._acquireTechnique(10):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,this._passParameters.overlayContent=S(e.output,e.bind),e.output){case 0:case 1:case 2:return this._renderMaterialPass(e,t);case 3:case 4:case 11:return this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);case 10:{const i=e.bind.highlight?.name;i&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(2)&&this._overlayRenderer.hasHighlight(i)&&this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break}case 5:case 7:case 8:case 9:return this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const t=this._tileRenderer;let i;if(null!=e){const t=e.toUnitRGBA();i=u(t[0]||0,t[1]||0,t[2]||0)}t.setBackground(i),this._allTiles.forAll(e=>t.updateTileTexture(e,0)),this._configuration.tileBlendInput=t.backgroundIsGrid?2:null!=t.backgroundColor?1:0,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)w(i,t);e.sort((e,t)=>D(e[0],t[0])),this._visiblePatchesByOrigin=new Map(e.map(e=>[e[0].renderData.localOrigin,e])),this.notifyChange("visibleTiles"),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows||this._inViewshed||this._cutFillEnabled){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i){const{rctx:r,bind:s}=e;r.bindTechnique(t,s,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;i.forEach(i=>{this._drawParameters.origin=i[0].renderData.localOrigin,t.program.bindDraw(s,this._passParameters,this._drawParameters);for(let r=0;r<i.length;r++)this._renderPatch(e,t,i[r],L.TRIANGLES,n,null===this._passParameters.overlayContent)}),r.bindVAO(null)}_renderMaterialPass(e,t){const{rctx:i,bind:r}=e,s=i.bindTechnique(t,r,this._passParameters);this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const n=10===r.slot;n&&(s.bindTexture("tex",i.emptyTexture),s.setUniform3fv("textureOpacities",h),s.setUniform4fv("texOffsetAndScale",f));const a=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:h;1===this._configuration.tileBlendInput&&s.setUniform3fv("backgroundColor",a);const l=this._stencilEnabledLayerExtents.length>0,o=this.wireframe?L.LINES:L.TRIANGLES;this._configuration.textureFadingEnabled&&s.bindTexture("texNext",i.emptyTexture);const c=this._visiblePatchesByOrigin;for(const d of c.values()){const i=d[0].renderData.localOrigin;this._drawParameters.origin=i,t.program.bindDraw(r,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const r of d){const i=r.renderData,a=i.textureReference;if(null!=a){if(!n){s.setUniform4fv("texOffsetAndScale",a.offsetAndScale),s.bindTexture("tex",a.texture.texture);const e=i.textureFadeFactor,t=e<1?i.nextTextureReference:null;this._configuration.textureFadingEnabled&&t&&e<1?(s.setUniform1f("fadeFactor",e),s.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),s.setUniform3fv("nextTexOpacities",t.opacities),s.bindTexture("texNext",t.texture.texture)):s.setUniform1f("fadeFactor",1),i.textureIsFading&&this.setNeedsRender(2),s.setUniform3fv("textureOpacities",a.opacities)}this._renderPatch(e,t,r,o,l),r.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}i.bindVAO(null)}_renderPatch(e,t,i,r,s,n=!1){const a=i.renderData,l=a.vao,o=l?.indexBuffer;if(!l||null==o)return void(R&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const c=t.program;n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,a.overlay);const{rctx:d,bind:h}=e;s&&(t.useStencil=this._useStencilForTile(i),d.setPipelineState(t.getPipeline(h)));const u=a.geometry.indexCount;d.bindVAO(l),c.assertCompatibleVertexAttributeLocations(l),d.drawElements(r,u,o.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_acquireTechnique(e){return this._configuration.output=e,this._techniques.get(I,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([a({readOnly:!0})],W.prototype,"visibleTiles",null),e([a({readOnly:!0})],W.prototype,"_isGlobal",null),e([a()],W.prototype,"renderOccludedFlags",null),e([a({value:!1})],W.prototype,"renderingDisabled",null),e([a({value:!0})],W.prototype,"visible",null),e([a()],W.prototype,"renderPatchBorders",null),e([a()],W.prototype,"wireframe",null),W=e([l("esri.views.3d.terrain.TerrainRenderer")],W);const Z=_(),J=_(),K=_(),X=_();export{W as TerrainRenderer};
|
|
2
|
+
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import{disposeMaybe as t}from"../../../core/maybe.js";import{MemCachePool as i}from"../../../core/MemCachePool.js";import r from"../../../core/ObjectPool.js";import{watch as s,sync as n}from"../../../core/reactiveUtils.js";import{property as a,subclass as l}from"../../../core/accessorSupport/decorators.js";import{subtract as o,set as c,dot as d}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as h,fromValues as u,create as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as g,ZEROS as f}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as p,set as m}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as y}from"../../../geometry/support/buffer/BufferView.js";import{overlayRenderOccludedFlag as b}from"./OverlayRenderer.js";import{PatchRenderData as x}from"./PatchRenderData.js";import{TerrainAttributesCache as T}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as R}from"./terrainUtils.js";import{TileRenderer as v}from"./TileRenderer.js";import{IteratorPreorder as P,fallsWithinLayerView as O,sortTiles as w,compareTiles as D}from"./tileUtils.js";import{getOverlayContentForOutputTerrain as S}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{SyncRenderPlugin as B}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as E}from"../webgl-engine/lib/Attribute.js";import{IntersectorResult as F}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as j,MeshIntersectionOptions as q,intersectTriangles as C}from"../webgl-engine/lib/RayIntersections.js";import{TriangleIntersectionData as A}from"../webgl-engine/lib/TriangleIntersectionData.js";import{terrainId as M,getVerticalOffsetTerrain as G}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as U}from"../webgl-engine/materials/DrawParameters.js";import{T as k}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as I}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as N}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as L}from"../../webgl/enums.js";const V=7,z=10,H=200,Q=p();let W=class extends B{get visibleTiles(){return Array.from(this._visiblePatchesByOrigin.values()).flat()}get _isGlobal(){return 1===this._stage.viewingMode}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}get renderOccludedFlags(){return this._overlayRenderer.renderOccludedFlags}constructor(e,t,s,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=s,this._compressionTracker=n,this.type=7,this.isGround=!0,this._passParameters=new k,this._drawParameters=new U,this._renderDataPool=new r(()=>new x),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new P,this._castShadows=!1,this._inViewshed=!1,this._cutFillEnabled=!1,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.produces=new Map([[1,()=>1===this._desiredSlot],[6,()=>6===this._desiredSlot],[8,()=>8===this._desiredSlot],[10,()=>this._produces()&&this.renderOccludedFlags===b]]),this._tileSize=256,this._configuration=new N(1===t.viewingMode),this._tileTextureCache=new i((e,t)=>a.newCache(e,t),"TileTexture"),this.tileGeometryCache=new T(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(s(()=>this._overlayRenderer.renderOccludedFlags,()=>this.setNeedsRender(),n))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}get _oitEnabled(){return this._stage.renderer.oitEnabled}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get layerViewUid(){return M}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,32)}reuseTextureFromParent(e){const{parent:t}=e;if(!this._canReuseTextureFromParent(t,e))return!1;const i=g(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}_canReuseTextureFromParent(e,t){if(!e)return!1;const{layerInfo:i,surface:r}=t;for(let s=0;s<i[1].length;s++){const i=r.layerViewByIndex(s,1);if(O(e,i)!==O(t,i))return!1}return!0}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,32===t?0:2),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[0])i.pendingUpdates&=-9;e.resetPendingUpdate(8);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=z-V,i=Math.max(0,Math.floor((e.level-t)/V)*V);if(this._isGlobal&&0===i)return h;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=1){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=1){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=1){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new v(this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=t(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&0!==this.transparency)return;const s=Z,n=J;o(s,r,i),c(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,l=e.results.max,h=e.results.ground,u=0===e.options.store,_=!!e.results.ground.target,g=G(e.verticalOffset),f=e.tolerance;let p,b=u&&null!=a.distance?a.distance:1/0;const x=e.options,T=x.normalRequired||!x.backfacesTerrain,R=new q(f,!1,T),v=c=>{const _=c.renderData;if(!_?.vao)return;const v=_.geometry;m(Q,v.boundingBox);const P=_.localOrigin;null!=g&&(g.localOrigin=P,g.applyToAabb(Q));const O=Q;if(K[0]=i[0]-P[0],K[1]=i[1]-P[1],K[2]=i[2]-P[2],!j(O,K,n,f,b))return;const w=(e,t,i)=>{e.set(this.type,c,t,i),b=u&&null!=a.distance?a.distance:1/0},D=(n,o,c)=>{if((!T||null!=c)&&n>=0&&(x.backfacesTerrain||d(c,s)<0)&&(x.invisibleTerrain||!x.selectionMode||null==t||t(i,r,n))){if((null==h.distance||n<h.distance)&&w(h,n,c),x.isFiltered)return;2===x.store&&(null==p?(p=new F(e.ray),w(p,n,c),e.results.all.push(p)):n<p.distance&&w(p,n,c)),(null==a.distance||n<a.distance)&&w(a,n,c),0!==x.store&&(null==l.distance||n>l.distance)&&w(l,n,c)}},S=X;o(S,r,P);const{indices:B,indexCount:q}=v,M=v.vertexAttributes,G=M.getField("position",y),U=new E(G.typedBuffer,3,M.stride/4),k=q/3;if(!g&&k>H){const e=c.renderData;e.intersectionData??=new A(B,k,U),e.intersectionData.intersectRay(K,S,R,D)}else C(K,S,0,k,B,U,g,R,D)},P=this._rootTiles;if(null!=P){(()=>{const t=this._tileIterator;t.reset(P);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==g&&!e.intersectsRay(i,s,f,b)||_&&this._useStencilForTile(e)?t.skipSubtree():v(e)})()}}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}get _desiredSlot(){if(!this._produces())return null;switch(this.transparency){case 0:return 1;case 1:case 2:return this._oitEnabled?8:6;case 3:case 4:return null}}acquireTechniques(e){const{shadowMap:t,viewshedEnabled:i,cutFillEnabled:r,slot:s,hasEmission:n,useFloatBlend:a}=e.bind,l=!!has("enable-feature:terrain-shadows")&&t.enabled;if(l!==this._castShadows&&(this._castShadows=l,this._patchesByOriginDirty=!0),this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),this._cutFillEnabled!==r&&(this._cutFillEnabled=r,this._patchesByOriginDirty=!0),3===this.transparency)return null;if(10===s){if(0===(e.renderOccludedMask&b))return null}else if(s!==this._desiredSlot)return null;const o=this._configuration;switch(o.screenSpaceReflections=o.cloudReflections=o.receiveShadows=o.receiveAmbientOcclusion=o.renderOccluded=o.hasHighlightMixTexture=o.hasEmission=!1,o.overlayMode=this._overlayRenderer.mode,o.useFloatBlend=a.value,e.output){case 0:case 1:case 2:{const{ssr:i,clouds:r,ssao:a}=e.bind;o.screenSpaceReflections=null!=i.lastFrameColor,o.cloudReflections=null!=r.data;const l=10===s;return o.receiveShadows=t.ready&&!l,o.renderOccluded=l,o.receiveAmbientOcclusion=!l&&null!=a,o.hasEmission=n,this._acquireTechnique(e.output)}case 5:case 7:return this._castShadows?this._acquireTechnique(5):null;case 8:return this._inViewshed?this._acquireTechnique(8):null;case 9:return this._cutFillEnabled?this._acquireTechnique(9):null;case 3:case 4:return this._acquireTechnique(e.output);case 11:return this._acquireTechnique(11);case 10:return o.hasHighlightMixTexture=null!=e.bind.highlightMixTexture,this._overlayRenderer.hasHighlights?this._acquireTechnique(10):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,this._passParameters.overlayContent=S(e.output,e.bind),e.output){case 0:case 1:case 2:return this._renderMaterialPass(e,t);case 3:case 4:case 11:return this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);case 10:{const i=e.bind.highlight?.name;i&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(2)&&this._overlayRenderer.hasHighlight(i)&&this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break}case 5:case 7:case 8:case 9:return this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const t=this._tileRenderer;let i;if(null!=e){const t=e.toUnitRGBA();i=u(t[0]||0,t[1]||0,t[2]||0)}t.setBackground(i),this._allTiles.forAll(e=>t.updateTileTexture(e,0)),this._configuration.tileBlendInput=t.backgroundIsGrid?2:null!=t.backgroundColor?1:0,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)w(i,t);e.sort((e,t)=>D(e[0],t[0])),this._visiblePatchesByOrigin=new Map(e.map(e=>[e[0].renderData.localOrigin,e])),this.notifyChange("visibleTiles"),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows||this._inViewshed||this._cutFillEnabled){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i){const{rctx:r,bind:s}=e;r.bindTechnique(t,s,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;i.forEach(i=>{this._drawParameters.origin=i[0].renderData.localOrigin,t.program.bindDraw(s,this._passParameters,this._drawParameters);for(let r=0;r<i.length;r++)this._renderPatch(e,t,i[r],L.TRIANGLES,n,null===this._passParameters.overlayContent)}),r.bindVAO(null)}_renderMaterialPass(e,t){const{rctx:i,bind:r}=e,s=i.bindTechnique(t,r,this._passParameters);this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const n=10===r.slot;n&&(s.bindTexture("tex",i.emptyTexture),s.setUniform3fv("textureOpacities",h),s.setUniform4fv("texOffsetAndScale",f));const a=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:h;1===this._configuration.tileBlendInput&&s.setUniform3fv("backgroundColor",a);const l=this._stencilEnabledLayerExtents.length>0,o=this.wireframe?L.LINES:L.TRIANGLES;this._configuration.textureFadingEnabled&&s.bindTexture("texNext",i.emptyTexture);const c=this._visiblePatchesByOrigin;for(const d of c.values()){const i=d[0].renderData.localOrigin;this._drawParameters.origin=i,t.program.bindDraw(r,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const r of d){const i=r.renderData,a=i.textureReference;if(null!=a){if(!n){s.setUniform4fv("texOffsetAndScale",a.offsetAndScale),s.bindTexture("tex",a.texture.texture);const e=i.textureFadeFactor,t=e<1?i.nextTextureReference:null;this._configuration.textureFadingEnabled&&t&&e<1?(s.setUniform1f("fadeFactor",e),s.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),s.setUniform3fv("nextTexOpacities",t.opacities),s.bindTexture("texNext",t.texture.texture)):s.setUniform1f("fadeFactor",1),i.textureIsFading&&this.setNeedsRender(2),s.setUniform3fv("textureOpacities",a.opacities)}this._renderPatch(e,t,r,o,l),r.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}i.bindVAO(null)}_renderPatch(e,t,i,r,s,n=!1){const a=i.renderData,l=a.vao,o=l?.indexBuffer;if(!l||null==o)return void(R&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const c=t.program;n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,a.overlay);const{rctx:d,bind:h}=e;s&&(t.useStencil=this._useStencilForTile(i),d.setPipelineState(t.getPipeline(h)));const u=a.geometry.indexCount;d.bindVAO(l),c.assertCompatibleVertexAttributeLocations(l),d.drawElements(r,u,o.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_acquireTechnique(e){return this._configuration.output=e,this._techniques.get(I,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([a({readOnly:!0})],W.prototype,"visibleTiles",null),e([a({readOnly:!0})],W.prototype,"_isGlobal",null),e([a()],W.prototype,"renderOccludedFlags",null),e([a({value:!1})],W.prototype,"renderingDisabled",null),e([a({value:!0})],W.prototype,"visible",null),e([a()],W.prototype,"renderPatchBorders",null),e([a()],W.prototype,"wireframe",null),W=e([l("esri.views.3d.terrain.TerrainRenderer")],W);const Z=_(),J=_(),K=_(),X=_();export{W as TerrainRenderer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import"../../../../../core/has.js";import i from"../../../../../core/Logger.js";import n from"../../../../../core/PooledArray.js";import{watch as o,sync as s}from"../../../../../core/reactiveUtils.js";import{isTypedArray as r}from"../../../../../core/typedArrayUtil.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators/subclass.js";import{clone as l}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as c}from"../../../../../geometry/support/aaBoundingBox.js";import{compactIndices as m}from"../../../../../geometry/support/Indices.js";import{c as h}from"../../../../../chunks/vec3.js";import{c as p}from"../../../../../chunks/vec32.js";import{ComponentData as
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import"../../../../../core/has.js";import i from"../../../../../core/Logger.js";import n from"../../../../../core/PooledArray.js";import{watch as o,sync as s}from"../../../../../core/reactiveUtils.js";import{isTypedArray as r}from"../../../../../core/typedArrayUtil.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators/subclass.js";import{clone as l}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as c}from"../../../../../geometry/support/aaBoundingBox.js";import{compactIndices as m}from"../../../../../geometry/support/Indices.js";import{c as h}from"../../../../../chunks/vec3.js";import{c as p}from"../../../../../chunks/vec32.js";import{ComponentData as d}from"./ComponentData.js";import{defaultComponentParameters as g,ComponentDrawParametersImplementation as f}from"./ComponentDrawParameters.js";import{ComponentObject as u}from"./ComponentObject.js";import{IntersectionGeometry as b}from"./IntersectionGeometry.js";import{RenderableMeta as v,Renderable as _}from"./Renderable.js";import{RenderGeometry as y}from"./RenderGeometry.js";import{RenderSubmitSystem as j}from"./RenderSubmitSystem.js";import{ComponentMaterialRepository as C}from"./Material/ComponentMaterialRepository.js";import{VertexArrayObject as w}from"../../lib/VertexArrayObject.js";import{getVerticalOffsetI3S as M}from"../../lib/verticalOffsetUtils.js";import{BufferManager as R}from"../../lib/TextureBackedBuffer/BufferManager.js";import{getComponentDataLayout as O,IndexGlLayout as x}from"../../materials/DefaultLayouts.js";import{BufferObject as A}from"../../../../webgl/BufferObject.js";import{PrimitiveType as D}from"../../../../webgl/enums.js";import{SamplerRepository as E}from"../../../../webgl/Sampler.js";import{VertexBuffer as B}from"../../../../webgl/VertexBuffer.js";const H=()=>i.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");let V=class extends t{constructor(e,t,i){super({}),this._renderPassManager=e,this._viewingMode=t,this._elevationRangeCacheVerticalOffset=NaN,this._elevationRangeCacheMin=NaN,this._elevationRangeCacheMax=NaN,this._activeHighlightOptions=new Map,this._visible=new n,this._hidden=new n,this._renderSubmit=new j(this),this._renderPassManager.register(this._renderSubmit);const{rctx:r,bind:a}=e;this._componentBufferManager=new R(r,O());const l=2===this._viewingMode?0:i?1:2;this.materials=new C(a,l),this.samplers=new E(r.gl),this.addHandles(o(()=>a.useFloatBlend.value,()=>{this._visible.forAll(e=>e.updateMaterial(this.materials.globals)),this._hidden.forAll(e=>e.updateMaterial(this.materials.globals)),this._requestRender()},s))}destroy(){this._componentBufferManager.destroy(),this._componentBufferManager=null,this._visible.forAll(e=>e.destroy()),this._visible.prune(),this._hidden.forAll(e=>e.destroy()),this._hidden.prune(),this._renderSubmit.destroy(),this.samplers.dispose(),this.materials.destroy()}createObject(e,t){const{geometry:i}=e,n=new d(this._componentBufferManager,m(i.componentOffsets)),o=this._createRenderable(e,t,n),s=new b(this._viewingMode,i.positions,n,e.elevationAlignable),r=new u(this,e.transform,e.obb.clone(),n,o,s);return(r.visible?this._visible:this._hidden).push(r),r}destroyObject(e){const t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._requestRender()}setObjectVisibility(e,t){const i=e;t!==i.visible&&(t?(this._hidden.removeUnordered(i),this._visible.push(i)):(this._visible.removeUnordered(i),this._hidden.push(i)),i.visible=t,this._requestRender())}preSubmit(e){const{camera:t}=e;this._componentBufferManager.updateTextures(),this.visibleObjects.forAll(e=>e.updateCameraDerivedParameters(t))}getObjectOpacity(e){return e.renderable.drawParameters.opacity}updateObjectOpacity(e,t){const i=e;i.opacity!==t&&(i.updateOpacity(t),this._requestRender())}isSliceplaneEnabled(e){return e.renderable.material.slicePlaneEnabled}setAllComponentVisibilities(e,t){const i=e;i.componentData.visibility.reset(t),i.componentData.markVisibilityDirty(),this._requestRender()}forEachVisibleComponent(e,t){return e.componentData.visibility.forEachComponent(t)}getComponentCount(e){const t=e,{componentData:i}=t,n=i.visibility.componentCount;return{visible:n,invisible:i.count-n}}setComponentData(e,t){e.setComponentData(t,this._viewingMode),this._elevationRangeCacheVerticalOffset=NaN,this._requestRender()}getComponentAabb(e,t,i,n=!1){e.intersectionGeometry.getComponentAabb(t,i);const o=e,s=o.componentData.verticalOffsets;if(n||null==s)return i;const r=s[t];if(2===this._viewingMode||0===r)return i[2]+=r,i[5]+=r,i;const a=M(r);return a.localOrigin=o.transform.position,a.applyToAabb(i)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,i){return e.intersectionGeometry.getComponentPositions(t,i)}expandRangeWithComponentObjectElevationRange(e,t,i,n){Number.isNaN(this._elevationRangeCacheVerticalOffset)||this._elevationRangeCacheVerticalOffset!==t||n.expandElevationRangeValues(this._elevationRangeCacheMin,this._elevationRangeCacheMax);const o=e,{componentData:s}=o,r=s.count,{verticalOffsets:a}=s,{intersectionGeometry:l}=o,c=2===this._viewingMode,m=l.getComponentAabbs(),h=I;let p=1/0,d=-1/0;for(let g=0;g<r;g++){const e=6*g,s=a?.[g]??0;let r=1/0,l=-1/0;if(c)r=m[e+2]+s+t,l=m[e+5]+s+t;else{if(h[0]=m[e],h[1]=m[e+1],h[2]=m[e+2],h[3]=m[e+3],h[4]=m[e+4],h[5]=m[e+5],0!==s){const e=M(s);e.localOrigin=o.transform.position,e.applyToAabb(h)}const r=Math.max(Math.abs(h[3]),Math.abs(h[0])),a=Math.max(Math.abs(h[4]),Math.abs(h[1])),l=t+h[5]+i;n.expandElevationRangeValues(t+h[2],Math.sqrt(r*r+a*a+l*l)-i)}n.expandElevationRangeValues(r,l),p=Math.min(p,r),d=Math.max(d,l)}this._elevationRangeCacheVerticalOffset=t,this._elevationRangeCacheMin=p,this._elevationRangeCacheMax=d}intersect(e,t,i,n,o,s){const r=e,{transform:a,componentData:l,intersectionGeometry:c}=r;return null!=n&&(n.localOrigin=a.position),c.intersect(t,i,n,l.verticalOffsets,a,o,s)}addEdges(e,t,i,n,o){const s=e,{indices:r,positions:a}=s.intersectionGeometry,l=s.componentData.offsets;return t.addComponentObject(s,a,r,l,i,n,o)}async extractEdgeInformation(e,t,i){const n=e,o=n.componentData.visibility;if(o.allInvisible()){const{extractComponentsEdgeLocationsLayout:e}=await import("../../lib/edgeRendering/edgeProcessing.js");return{buffer:e.createBuffer(0),origin:[0,0,0]}}const{indices:s,positions:r}=n.intersectionGeometry,a=n.componentData.offsets,{EdgeInputBufferLayout:c}=await import("../../lib/edgeRendering/bufferLayouts.js"),m=c.createBuffer(r.length/3);p(m.position.typedBuffer,r,m.position.typedBufferStride,3),h(m.position,m.position,n.transform.rotationScale),this._setComponentIndices(m.componentIndex,s,a);const d=m.count,g=this._computeVisibilityIndices(s,o,a,d);return{origin:l(n.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:g,indicesLength:g.length,skipDeduplicate:!0,data:m,writerSettings:{reducedPrecision:!1,variants:0}},i)}}_setComponentIndices(e,t,i){let n=0;for(let o=0;o<i.length-1;o++){const s=i[o],r=i[o+1];for(let i=s;i<r;i++){const o=t?t[i]:i;e.set(o,n)}n++}}_computeVisibilityIndices(e,t,i,n){if(e&&t.allVisible())return e;let o=0;t.forEachComponentRange((e,t)=>(o+=i[t]-i[e],!0));const s=r(e)?2===e?.BYTES_PER_ELEMENT||n<=65536?new Uint16Array(o):new Uint32Array(o):new Array(o);let a=0;return t.forEachComponentRange((t,n)=>{const o=i[t],r=i[n];for(let i=o;i<r;i++)s[a++]=e?e[i]:i;return!0}),s}addHighlight(e,t,i){const n=e,o=this._activeHighlightOptions.get(i)??0;this._activeHighlightOptions.set(i,o+1);n.addHighlight(t,i)&&this._requestRender()}removeHighlight(e,t,i){const n=e.removeHighlight(t,i);"notfound"!==n&&(this._removeActiveHighlight(i),n&&this._requestRender())}_removeActiveHighlight(e,t=1){const i=this._activeHighlightOptions.get(e);if(void 0===i)H().warn(`Removing non-existing highlight "${e}".`);else{const n=i-t;n<0&&H().warn(`Removing non-existing highlight "${e}".`),n<=0?this._activeHighlightOptions.delete(e):this._activeHighlightOptions.set(e,n)}}clearHighlights(e){const t=e,{componentData:i}=t,{componentHighlights:n}=t.componentData;if(n.size>0){for(const e of n)this._removeActiveHighlight(e[0],e[1][i.count]);t.clearHighlights(),this._requestRender()}}hasHighlight(e){return this._activeHighlightOptions.has(e)}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t,i){const n=this._renderPassManager.rctx,o=e.geometry,s=o.parameters.layout,{interleavedVertexData:r,indexData:a,vertexCount:l}=o.renderGeometryData,c=new B(n,s,r),m=a?A.createIndex(n,35044,a):null;let h=0;const p=[["geometry",c]];if(!t.isIntegratedMesh){const e=new Uint16Array(l);for(let n=0;n<i.count;n++){const t=i.offsets[n],o=i.offsets[n+1],s=i.materialDataIndices[n];if(null!=a)for(let i=t;i<o;i++){e[a[i]]=s}else for(let i=t;i<o;i++)e[i]=s}const t=new B(n,x,e.buffer);h+=t.usedMemory,p.push(["componentIndices",t])}const d=new w(n,new Map(p),m),u=new y(d,D.TRIANGLES,o.parameters,null!=m),b=this.materials.acquire(t,u.parameters,g),j=new v(c.usedMemory+h+(m?.usedMemory??0)),C=this.samplers.addFromTexture(t.baseColorTexture?.texture),M=new f(e,t,C);return new _(b,M,u,j)}_requestRender(){this._renderPassManager.requestRender()}};V=e([a("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection")],V);const I=c();export{V as ComponentObjectCollection};
|
package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterialGlobalParameters.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import has from"../../../../../../core/has.js";class s{constructor(s,i){this._bind=s,this.sphericalSR=i,this.
|
|
2
|
+
import has from"../../../../../../core/has.js";class s{constructor(s,i){this._bind=s,this.sphericalSR=i,this._hasEmissiveOIT8Bit=!has("disable-feature:emissive-8bit")}get hasEmissionSupport(){return this.useFloatBlend||this._hasEmissiveOIT8Bit}get useFloatBlend(){return this._bind.useFloatBlend.value}}export{s as ComponentMaterialGlobalParameters};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import"../../../../../../core/has.js";import"../../../../../../core/Logger.js";import{ComponentMaterial as e,computeMaterialPass as
|
|
2
|
+
import"../../../../../../core/has.js";import"../../../../../../core/Logger.js";import{ComponentMaterial as e,computeMaterialPass as r,calculateHasEmissions as t,calculateEmissionSource as o}from"./ComponentMaterial.js";import{ComponentMaterialGlobalParameters as s}from"./ComponentMaterialGlobalParameters.js";class a{constructor(e,r){this._store=new Map,this.globals=new s(e,r)}destroy(){this._store.forEach(({material:e})=>e.destroy()),this._store.clear()}acquire(r,t,o){const s=this.globals,a=l(r,t,o,s),n=this._store.get(a);if(n)return n.refCount++,n.material.key,n.material;const i=new e(r,t,o,s,a);return this._store.set(a,{material:i,refCount:1}),i}release(e){const{key:r}=e,t=this._store.get(r);if(!t||t.refCount<1)throw new Error("Internal error in material repository");1===t.refCount?this._store.delete(r):t.refCount--}}function l(e,s,a,l){const n=r(e,a),i=t(e,a,l),u=o(e,a,l);return"|"+ +l.useFloatBlend+`|${+e.usePBR}|${+e.hasParametersFromSource}|${+e.isGround}`+`|${+e.slicePlaneEnabled}|${+e.isIntegratedMesh}|${+e.applySSAO}`+`|${+n}|${+a.componentDataType}|${+i}|${+u}`+`|${+e.sphereDepthInterpolate}|${+e.ellipsoidMode}|${+e.doubleSided}`+`|${+e.cullFace}|${+e.alphaDiscardMode}`+`|${+s.hasVertexColors}|${+s.textureCoordinateType}`+`|${+s.shadeNormals}|${+s.hasNormals}`+`|${+e.polygonOffsetEnabled}|${+s.vertexPositionRotationType}|${+s.vertexNormalRotationType}|`+ +(null!=e.baseColorTexture)+"|"+ +(null!=e.emissionTexture)+"|"+ +(null!=e.metallicRoughnessTexture)+"|"+ +(null!=e.occlusionTexture)+"|"+ +(null!=e.normalTexture)+"|"+ +a.emissiveOverride}export{a as ComponentMaterialRepository,l as makeMaterialKey};
|
package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as
|
|
2
|
+
import{__decorate as e}from"tslib";import{isColorHighlightOrOLID as t}from"../../../core/shaderLibrary/ShaderOutput.js";import{parameter as o}from"../../../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{SphereDepthInterpolateConfiguration as i}from"../../../shaders/SphereDepthInterpolate.glsl.js";class s extends i{constructor(e){super(),this.output=0,this.textureCoordinateType=0,this.componentDataType=0,this.cullFace=2,this.vertexDiscardMode=0,this.doubleSidedMode=2,this.alphaDiscardMode=1,this.integratedMeshMode=0,this.pbrMode=0,this.normalType=0,this.emissionSource=0,this.shadeNormals=1,this.hasEmission=!1,this.hasVertexColors=!1,this.hasSlicePlane=!1,this.isGroundSlice=!1,this.hasColorTexture=!1,this.hasHighlightMixTexture=!1,this.receiveAmbientOcclusion=!0,this.receiveShadows=!0,this.blendingEnabled=!0,this.screenSpaceReflections=!1,this.hasPolygonOffset=!1,this.hasMetallicRoughnessTexture=!1,this.hasOcclusionTexture=!1,this.hasNormalTexture=!1,this.hasOccludees=!1,this.terrainDepthTest=!1,this.cullAboveTerrain=!1,this.hasNormalTextureTransform=!1,this.cloudReflections=!0,this.snowCover=!1,this.renderOccluded=!1,this.sphereDepthInterpolate=!1,this.vertexPositionRotationType=1,this.vertexNormalRotationType=0,this.discardInvisibleFragments=!1,this.oitPremultipliedAlpha=!1,this.occlusionPass=!1,this.bindType=2,this.useCustomDTRExponentForWater=!1,this.hasVertexTangents=!1,this.hasSliceTranslatedView=!1,this.highStepCount=!1,this.instanced=!1,this.instancedDoublePrecision=!1,this.hasModelTransformation=!1,this.useFillLights=!0,this.draped=!1,this.useTransformationTexture=!0,this.sphericalSR=e.sphericalSR,this.useFloatBlend=e.useFloatBlend}get spherical(){return 0!==this.sphericalSR}get overlayEnabled(){return(2===this.integratedMeshMode||3===this.integratedMeshMode)&&t(this.output)}get hasWater(){return 3===this.pbrMode||4===this.pbrMode||6===this.pbrMode}}e([o()],s.prototype,"useFloatBlend",void 0),e([o({count:12})],s.prototype,"output",void 0),e([o({count:3})],s.prototype,"textureCoordinateType",void 0),e([o({count:2})],s.prototype,"componentDataType",void 0),e([o({count:3})],s.prototype,"cullFace",void 0),e([o({count:3})],s.prototype,"vertexDiscardMode",void 0),e([o({count:3})],s.prototype,"doubleSidedMode",void 0),e([o({count:4})],s.prototype,"alphaDiscardMode",void 0),e([o({count:4})],s.prototype,"integratedMeshMode",void 0),e([o({count:7})],s.prototype,"pbrMode",void 0),e([o({count:3})],s.prototype,"normalType",void 0),e([o({count:8})],s.prototype,"emissionSource",void 0),e([o({count:3})],s.prototype,"shadeNormals",void 0),e([o()],s.prototype,"hasEmission",void 0),e([o()],s.prototype,"hasVertexColors",void 0),e([o()],s.prototype,"hasSlicePlane",void 0),e([o()],s.prototype,"isGroundSlice",void 0),e([o()],s.prototype,"hasColorTexture",void 0),e([o()],s.prototype,"hasHighlightMixTexture",void 0),e([o()],s.prototype,"receiveAmbientOcclusion",void 0),e([o()],s.prototype,"receiveShadows",void 0),e([o()],s.prototype,"blendingEnabled",void 0),e([o()],s.prototype,"screenSpaceReflections",void 0),e([o()],s.prototype,"hasPolygonOffset",void 0),e([o()],s.prototype,"hasMetallicRoughnessTexture",void 0),e([o()],s.prototype,"hasOcclusionTexture",void 0),e([o()],s.prototype,"hasNormalTexture",void 0),e([o()],s.prototype,"hasOccludees",void 0),e([o()],s.prototype,"terrainDepthTest",void 0),e([o()],s.prototype,"cullAboveTerrain",void 0),e([o()],s.prototype,"hasNormalTextureTransform",void 0),e([o()],s.prototype,"cloudReflections",void 0),e([o()],s.prototype,"snowCover",void 0),e([o()],s.prototype,"renderOccluded",void 0),e([o()],s.prototype,"sphereDepthInterpolate",void 0),e([o({count:2})],s.prototype,"vertexPositionRotationType",void 0),e([o({count:2})],s.prototype,"vertexNormalRotationType",void 0);export{s as ComponentTechniqueConfiguration};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as o}from"tslib";import{ShaderTechniqueConfiguration as t,parameter as s}from"../shaderTechnique/ShaderTechniqueConfiguration.js";class
|
|
2
|
+
import{__decorate as o}from"tslib";import{ShaderTechniqueConfiguration as t,parameter as s}from"../shaderTechnique/ShaderTechniqueConfiguration.js";class e extends t{constructor(){super(...arguments),this.output=0,this.hasEmission=!1,this.useFloatBlend=!0}}o([s({count:12})],e.prototype,"output",void 0),o([s()],e.prototype,"hasEmission",void 0),o([s()],e.prototype,"useFloatBlend",void 0);export{e as ShaderOutputConfiguration};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{
|
|
2
|
+
import{clamp as e}from"../../../../../../core/mathUtils.js";import{isColor as s}from"../ShaderOutput.js";import{VertexTextureCoordinates as i}from"../attributes/VertexTextureCoordinates.glsl.js";import{Gamma as o}from"../shading/Gamma.glsl.js";import{Float3DrawUniform as r}from"../../shaderModules/Float3DrawUniform.js";import{Float3PassUniform as m}from"../../shaderModules/Float3PassUniform.js";import{FloatDrawUniform as t}from"../../shaderModules/FloatDrawUniform.js";import{FloatPassUniform as n}from"../../shaderModules/FloatPassUniform.js";import{If as a,glsl as l}from"../../shaderModules/glsl.js";import{Texture2DDrawUniform as v}from"../../shaderModules/Texture2DDrawUniform.js";import{Texture2DPassUniform as u}from"../../shaderModules/Texture2DPassUniform.js";import{floatBlendReductionFactor as f}from"../../../shaders/oitResolution.glsl.js";const d=1,c=1;function g(d,g){if(!s(g.output))return;d.fragment.include(o);const{emissionSource:x,hasEmissiveTextureTransform:p,bindType:h,useFloatBlend:j}=g,T=3===x||4===x||5===x;T&&(d.include(i,g),d.fragment.uniforms.add(1===h?new u("texEmission",e=>e.textureEmissive):new v("texEmission",e=>e.textureEmissive)));const w=2===x||T;w&&d.fragment.uniforms.add(1===h?new m("emissiveBaseColor",e=>e.emissiveBaseColor):new r("emissiveBaseColor",e=>e.emissiveBaseColor));const C=0!==x;if(C&&!(7===x||6===x||4===x||5===x)){const s=s=>null!=s?j?s:e(s,0,f):0;d.fragment.uniforms.add(1===h?new n("emissiveStrength",e=>s(e.emissiveStrength)):new t("emissiveStrength",e=>s(e.emissiveStrength)))}const F=7===x,b=5===x,S=1===x||6===x||F;d.fragment.code.add(l`
|
|
3
3
|
vec4 getEmissions(vec3 symbolColor) {
|
|
4
|
-
vec4 emissions = ${
|
|
5
|
-
${
|
|
6
|
-
${
|
|
4
|
+
vec4 emissions = ${w?b?"emissiveSource == 0 ? vec4(emissiveBaseColor, 1.0): vec4(linearizeGamma(symbolColor), 1.0)":"vec4(emissiveBaseColor, 1.0)":S?F?"emissiveSource == 0 ? vec4(0.0): vec4(linearizeGamma(symbolColor), 1.0)":"vec4(linearizeGamma(symbolColor), 1.0)":"vec4(0.0)"};
|
|
5
|
+
${a(T,`${a(b,`if(emissiveSource == 0) {\n vec4 emissiveFromTex = textureLookup(texEmission, ${p?"emissiveUV":"vuv0"});\n emissions *= vec4(linearizeGamma(emissiveFromTex.rgb), emissiveFromTex.a);\n }`,`vec4 emissiveFromTex = textureLookup(texEmission, ${p?"emissiveUV":"vuv0"});\n emissions *= vec4(linearizeGamma(emissiveFromTex.rgb), emissiveFromTex.a);`)}\n emissions.w = emissions.rgb == vec3(0.0) ? 0.0: emissions.w;`)}
|
|
6
|
+
${a(C,`emissions.rgb *= emissiveStrength * ${l.float(c)};`)}
|
|
7
7
|
return emissions;
|
|
8
8
|
}
|
|
9
|
-
`)}export{
|
|
9
|
+
`)}export{g as Emissions,c as emissiveStrengthBoost,d as emissiveStrengthDefault};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{releaseMaybe as t}from"../../../../../core/maybe.js";import{property as r,subclass as o}from"../../../../../core/accessorSupport/decorators.js";import{ZEROS as n}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderNodeOutput as i}from"../../../webgl.js";import s from"../../../webgl/RenderNode.js";import{If as a,glsl as c}from"../../core/shaderModules/glsl.js";import{Pos2Locations as l}from"../../lib/DefaultVertexBufferLayouts.js";import{
|
|
2
|
+
import{__decorate as e}from"tslib";import{releaseMaybe as t}from"../../../../../core/maybe.js";import{property as r,subclass as o}from"../../../../../core/accessorSupport/decorators.js";import{ZEROS as n}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderNodeOutput as i}from"../../../webgl.js";import s from"../../../webgl/RenderNode.js";import{If as a,glsl as c}from"../../core/shaderModules/glsl.js";import{Pos2Locations as l}from"../../lib/DefaultVertexBufferLayouts.js";import{floatBlendReductionFactor as u}from"../../shaders/oitResolution.glsl.js";import{checkWebGLError as h}from"../../../../webgl/checkWebGLError.js";import{ColorAttachment0 as p,SizedPixelFormat as d,DataType as f}from"../../../../webgl/enums.js";let m=class extends s{constructor(e){super(e),this.destroyedCB=null,this.produces=i.FINAL,this.consumes={required:[i.FINAL]},this.clearColor=n,this._focusedFBOType=7,this._programs=new Map}destroy(){this._programs.clear(),this.destroyedCB()}render(e){const t=e.find(({name:e})=>e===i.FINAL);if(!this._focusedTexture)return t;const r=this.renderingContext;r.bindFramebuffer(t.fbo),r.setClearColor(0,0,0,0),r.clear(16384);const o=this._focusedTexture.attachment,n=[v(o)],s=this._ensureProgram(r,!1,n);return r.useProgram(s),r.bindTexture(o,0),s.setUniform1i("colorTex0",0),s.setUniform1i("inputType",this._focusedFBOType),3===this._focusedFBOType&&s.setUniform2fv("nearFar",this.camera.nearFar),r.screen.draw(),t}getDownscaledFBO(e,t,r,o,n){t&&(o=e.width,n=e.height);const i="linear depth"===r||r.includes("shadow"),s="overlay highlight"===r||"highlights"===r||"highlight mix"===r,a="highlight coverage"===r,c=e.colorTexture?.descriptor,l=c?.internalFormat,u=[],d=new Array,f=new Array;e.colorAttachments.forEach((t,r)=>{const o=e.getColorTexture(t);if(o){const e=v(o);u.push(e);const{descriptor:t}=o;"float"!==e||t.hasMipmap||t.isImmutable||(o.generateMipmap(),d[r]=!0)}if(r>0){const r=e.getColorTexture(t)?.descriptor.internalFormat;return void f.push(F(r))}f.push(i?0:s?1:a?2:F(l))});const m=this.renderingContext,{depthStencilTexture:g}=e,x=this._ensureProgram(m,null!=g,u),T=this.fboCache.acquire(o,n,"fbo visualizer");m.useProgram(x),m.bindFramebuffer(T.fbo);const b=[];e.colorAttachments.forEach((t,r)=>{const o=`colorTex${r.toFixed()}`;m.bindTexture(e.getColorTexture(t),r),x.setUniform1i(o,r),r>0&&T.acquireColor(p+r,5,"fbo visualizer"),b.push(t)});const C=g?.descriptor.linearFilterDepth??!1;if(g){const t=e.colorAttachments.length;g.setShadowFiltering(!1),m.bindTexture(g,t),x.setUniform1i("depthTex",t);const r=p+t;r>p&&T.acquireColor(r,5,"fbo visualizer"),b.push(r)}m.gl.drawBuffers(b),h(m.gl);const R=m.getViewport();return m.setViewport(0,0,o,n),m.setClearColor(0,0,0,0),m.clear(16384),m.setBlendingEnabled(!0),m.setBlendFunction(1,771),x.setUniform1iv("inputTypes",f.length>0?f:[7]),x.setUniform2fv("nearFar",this.camera.nearFar),m.screen.draw(),h(m.gl),m.bindFramebuffer(null),m.setViewport(R.x,R.y,R.width,R.height),t&&(this._focusedTexture?.release(),this._focusedTexture=T.getAttachment(p),this._focusedTexture?.retain(),this._focusedFBOType=f[0]),e.colorAttachments.forEach((t,r)=>{if(d[r]){const r=e.getColorTexture(t);r?.clearMipmap()}}),g&&g.setShadowFiltering(C),T}clearFocusedFBO(){this._focusedTexture=t(this._focusedTexture)}getPreviewContent(e,t,r,o){const n=this.renderingContext,i=o.includes("\ndepth"),s=this.fboCache.acquire(e,t,"fbo visualizer");n.bindFramebuffer(s?.fbo);const a=n.getViewport();n.setViewport(0,0,e,t),n.setClearColor(this.clearColor[0],this.clearColor[1],this.clearColor[2],this.clearColor[3]),n.clear(16384),n.setBlendingEnabled(!0),n.setBlendFunction(1,771);const c=r.attachment,l=this._ensureProgram(n,!1,[v(c)]);n.useProgram(l),n.bindTexture(c,0),l.setUniform1i("colorTex0",0),l.setUniform1iv("inputTypes",[i||c.descriptor.internalFormat!==d.RGBA16F?7:5]),n.screen.draw();const u=new ImageData(new Uint8ClampedArray(e*t*4),e,t);return n.gl.readPixels(0,0,e,t,6408,f.UNSIGNED_BYTE,new Uint8Array(u.data.buffer)),h(n.gl),n.bindFramebuffer(null),n.setViewport(a.x,a.y,a.width,a.height),s?.release(),u}_ensureProgram(e,t,r){const o=x({hasDepthAttachment:t,colorSamplerTypes:r}),n=this._programs.get(o);if(n)return n;const i="#version 300 es\n in vec2 position;\n out vec2 uv;\n\n void main() {\n gl_Position = vec4(position, 0.0, 1.0);\n uv = position * 0.5 + vec2(0.5);\n }",s=e=>{let t="";for(let r=0;r<e.length;++r){const o=e[r];t+=`layout(location = ${c.int(r)}) out vec4 fragColor${c.int(r)};\n uniform ${g(o)} colorTex${c.int(r)};`}return t},h=e=>e.reduce((e,t,r)=>e+`{\n int inputType = inputTypes[${r}];\n if (inputType == ${3..toFixed()}) {\n fragColor${r} = vec4(vec3(texture(colorTex${r}, uv).r), 1.0);\n } else if (inputType == ${4..toFixed()}) {\n fragColor${r} = vec4(texture(colorTex${r}, uv).rg, 0.0, 1.0);\n } else if (inputType == ${(0).toFixed()}) {\n float depth = 1.0 - ((-linearDepthFromTexture(colorTex${r}, uv) - nearFar[0]) / (nearFar[1] - nearFar[0]));\n fragColor${r} = vec4(vec3(depth), depth >= 0.999 ? 0.0 : 1.0);\n } else if (inputType == ${5..toFixed()}) {\n // Divide F16 by floatBlendOutputScale to get similar previews as in the OIT8 pipeline\n fragColor${r} = vec4(texture(colorTex${r}, uv).rgb, 1.0) / ${u.toFixed(1)};\n } else if (inputType == ${1..toFixed()}) {\n fragColor${r} = vec4(texture(colorTex${r}, uv)) * 255.0;\n fragColor${r} = vec4(fragColor${r}.rgb / fragColor${r}.a, fragColor${r}.a);\n } else if(inputType == ${2..toFixed()}) {\n vec2 texDim = vec2(textureSize(colorTex${r}, 0));\n ivec2 iuv = ivec2(uv*texDim);\n uvec2 hh = uvec2(texelFetch(colorTex${r},iuv,0).rg);\n fragColor${r} = vec4(\n ((hh & uvec2(0x55u)) != uvec2(0u)) ? 1.0 : 0.0,\n ((hh & uvec2(0xaau)) != uvec2(0u)) ? 1.0 : 0.0,\n 0.0,\n 1.0);\n } else {\n fragColor${r} = vec4(texture(colorTex${r}, uv));\n }\n }`,""),p=r.length,d=`#version 300 es\n precision highp float;\n precision highp usampler2D;\n\n in vec2 uv;\n ${s(r)}\n ${a(t,`layout(location = ${c.int(p)}) out vec4 fragDepth;\n uniform sampler2D depthTex;`)}\n\n uniform int inputTypes[${r.length||1}];\n uniform vec2 nearFar;\n\n // Factors to convert rgba back to float\n const vec4 RGBA_2_FLOAT_FACTORS = vec4(\n 255.0 / (256.0),\n 255.0 / (256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0 * 256.0)\n );\n\n\n float rgbaToFloat(vec4 rgba) {\n // Convert components from 0->1 back to 0->255 and then add the components together with their corresponding\n // fixed point factors, i.e. (256^1, 256^2, 256^3, 256^4)\n return dot(rgba, RGBA_2_FLOAT_FACTORS);\n }\n\n float linearDepthFromFloat(float depth) {\n depth = pow(depth, 0.2);\n return -(depth * (nearFar[1] - nearFar[0]) + nearFar[0]);\n }\n\n float linearDepthFromRGBA(vec4 depth) {\n return linearDepthFromFloat(rgbaToFloat(depth));\n }\n\n ${"float"===r[0]?"float linearDepthFromTexture(sampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(texelFetch(depthTex, iuv, 0));\n }":"float linearDepthFromTexture(usampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(vec4(texelFetch(depthTex, iuv, 0)) * 255.0);\n }"}\n\n void main() {\n ${h(r)}\n ${a(t,"float depth = 1.0 - pow(texture(depthTex, uv).r, 10.0);\n fragDepth = vec4(vec3(depth), depth < 0.000001 ? 0.0 : 1.0);")}\n }`,f=e.programCache.get(i,d,l);return this._programs.set(o,f),f}};function g(e){switch(e){case"float":return"sampler2D";case"uint":return"usampler2D";case"int":return"isampler2D"}}function v(e){if(!e)return"float";const{internalFormat:t}=e.descriptor;switch(t){case d.R8I:case d.R16I:case d.R32I:case d.RG8I:case d.RG16I:case d.RG32I:case d.RGB8I:case d.RGB16I:case d.RGB32I:case d.RGBA8I:case d.RGBA16I:case d.RGBA32I:return"int";case d.R8UI:case d.R16UI:case d.R32UI:case d.RG8UI:case d.RG16UI:case d.RG32UI:case d.RGB8UI:case d.RGB16UI:case d.RGB32UI:case d.RGBA8UI:case d.RGBA16UI:case d.RGBA32UI:return"uint";default:return"float"}}function x(e){const{hasDepthAttachment:t,colorSamplerTypes:r}=e;return`${t?"Depth":""}${r.reduceRight((e,t)=>e+`|C${t}`,"")}`}function F(e){switch(e){case d.R16F:case d.R32F:case d.R8:return 3;case d.RG8:return 4;case d.RGBA16F:return 5;case d.RG8UI:return 6;default:return 7}}e([r()],m.prototype,"destroyedCB",void 0),e([r()],m.prototype,"produces",void 0),e([r()],m.prototype,"consumes",void 0),e([r()],m.prototype,"clearColor",void 0),m=e([o("esri.views.3d.webgl-engine.effects.debug.RenderNodeVisualizerNode")],m);export{m as RenderNodeVisualizerNode};
|