@arcgis/core 5.2.0-next.63 → 5.2.0-next.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/arcade/Feature.js +1 -1
- package/arcade/ImmutableArray.js +1 -1
- package/arcade/ImmutablePathArray.js +1 -1
- package/arcade/ImmutablePointArray.js +1 -1
- package/arcade/Pixel.js +1 -1
- package/arcade/Voxel.js +1 -1
- package/arcade/arcadeAsyncRuntime.js +1 -1
- package/arcade/arcadeCompiler.js +1 -1
- package/arcade/arcadeRuntime.js +1 -1
- package/arcade/containerUtils.js +1 -1
- package/arcade/debug.js +1 -1
- package/arcade/deepClone.js +1 -1
- package/arcade/functions/convertdirection.js +1 -1
- package/arcade/functions/date.js +1 -1
- package/arcade/functions/feature.js +1 -1
- package/arcade/functions/featuresetbase.js +1 -1
- package/arcade/functions/featuresetgeom.js +1 -1
- package/arcade/functions/featuresetstats.js +1 -1
- package/arcade/functions/featuresetstring.js +1 -1
- package/arcade/functions/fieldStats.js +1 -1
- package/arcade/functions/geomasync.js +1 -1
- package/arcade/functions/geometry.js +1 -1
- package/arcade/functions/geomsync.js +1 -1
- package/arcade/functions/knowledgegraph.js +1 -1
- package/arcade/functions/maths.js +1 -1
- package/arcade/functions/stats.js +1 -1
- package/arcade/functions/string.js +1 -1
- package/arcade/functions/track.js +1 -1
- package/arcade/geometry/functions.js +1 -1
- package/arcade/languageUtils.js +1 -1
- package/arcade.js +1 -1
- package/arcgisGlobal.d.ts +9 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{bb95922cd4631d6f17fb.js → 04ac5ac6f592d8c34bbd.js} +1 -1
- package/assets/esri/core/workers/chunks/{44e64186318728d1be51.js → 067b00498ae85f635f60.js} +1 -1
- package/assets/esri/core/workers/chunks/{62f3ca0719ac6bc76512.js → 09c43bcb09aad02e83a9.js} +1 -1
- package/assets/esri/core/workers/chunks/0b20f92bae2b4c40d299.js +1 -0
- package/assets/esri/core/workers/chunks/0c3c311400ee352187ea.js +1 -0
- package/assets/esri/core/workers/chunks/0c582abc8d25249eb530.js +1 -0
- package/assets/esri/core/workers/chunks/0d6776055e9b34c14151.js +1 -0
- package/assets/esri/core/workers/chunks/0d7d54e74b5639a0be6e.js +1 -0
- package/assets/esri/core/workers/chunks/0da5b27b070ab780f8b3.js +1 -0
- package/assets/esri/core/workers/chunks/0e6b6fcc55cc43ede1fc.js +1 -0
- package/assets/esri/core/workers/chunks/{bcb5017500d144b73908.js → 126f1f6b355723db6c4f.js} +1 -1
- package/assets/esri/core/workers/chunks/12a64eca4c571926d9d4.js +1 -0
- package/assets/esri/core/workers/chunks/{b2c0262c4a76b8a86200.js → 149284464115981694ff.js} +1 -1
- package/assets/esri/core/workers/chunks/1642fa1263d8f4a45101.js +1 -0
- package/assets/esri/core/workers/chunks/1840d74ebae777a0200b.js +1 -0
- package/assets/esri/core/workers/chunks/19bf6826e7d9a4d52035.js +1 -0
- package/assets/esri/core/workers/chunks/1bfbdec791e19f5a2534.js +1 -0
- package/assets/esri/core/workers/chunks/1d8280f63a6698e74f20.js +1 -0
- package/assets/esri/core/workers/chunks/{a12803108c3b12808698.js → 242cad472fbc38b24dbc.js} +2 -2
- package/assets/esri/core/workers/chunks/25197ecb324d6f08e03e.js +1 -0
- package/assets/esri/core/workers/chunks/253c231b5a52f1d2d3a5.js +1 -0
- package/assets/esri/core/workers/chunks/25999b6f96ec305a7679.js +1 -0
- package/assets/esri/core/workers/chunks/259bdacfb7b0f866a8d0.js +1 -0
- package/assets/esri/core/workers/chunks/28565756f884d0851003.js +1 -0
- package/assets/esri/core/workers/chunks/2a5a165848413764381b.js +1 -0
- package/assets/esri/core/workers/chunks/2e7a5bb740281ef59199.js +1 -0
- package/assets/esri/core/workers/chunks/{285a5bd708f0fe1c620c.js → 2ea3ca68cfa4d34e8f3b.js} +1 -1
- package/assets/esri/core/workers/chunks/2f87a49bdd00f899d81d.js +1 -0
- package/assets/esri/core/workers/chunks/{37a95f097533bad1b338.js → 302d91b7c480c6c9304b.js} +1 -1
- package/assets/esri/core/workers/chunks/{3d6d2b42ba2ad7086d5d.js → 3b493e8043ec1a2a5d96.js} +1 -1
- package/assets/esri/core/workers/chunks/3ddd717ea12d9823eee2.js +1 -0
- package/assets/esri/core/workers/chunks/40e48b720d89cd067892.js +1 -0
- package/assets/esri/core/workers/chunks/{a833fc9250635eb4152f.js → 41f7f3615d3ecb87c59a.js} +1 -1
- package/assets/esri/core/workers/chunks/{95b3b8fe45ef4ac6b277.js → 450bc48a7389607bce1e.js} +1 -1
- package/assets/esri/core/workers/chunks/465a050fd838ee8eddf3.js +1 -0
- package/assets/esri/core/workers/chunks/{0d61c8d348b09179777a.js → 46d8a1d6f7341ad20749.js} +1 -1
- package/assets/esri/core/workers/chunks/4710f21b138a2c9a0345.js +1 -0
- package/assets/esri/core/workers/chunks/48a0dfaabb9b4bce4191.js +1 -0
- package/assets/esri/core/workers/chunks/49a3888bf9e2481642ac.js +1 -0
- package/assets/esri/core/workers/chunks/{4ee900e5dbb130fa0c7b.js → 4a40b894ec89b0a4f9bf.js} +1 -1
- package/assets/esri/core/workers/chunks/{d847c3cb2043a983145b.js → 4addea2e35b0c845743e.js} +1 -1
- package/assets/esri/core/workers/chunks/{e0a4d0288abd334b0673.js → 4ae626868e14bedd7fc5.js} +1 -1
- package/assets/esri/core/workers/chunks/529ee4670940720e888b.js +1 -0
- package/assets/esri/core/workers/chunks/{a3c882fe7599dc0f4f27.js → 59d1708ae13c6e7e6e55.js} +1 -1
- package/assets/esri/core/workers/chunks/59dd83e5aee2908c7eca.js +1 -0
- package/assets/esri/core/workers/chunks/{b5c7813495657f844171.js → 5adf16c034a590b5e9f5.js} +1 -1
- package/assets/esri/core/workers/chunks/{b8bdacebd4d24ba90f3f.js → 5fde1234c5cccaee6763.js} +1 -1
- package/assets/esri/core/workers/chunks/60f9b37dd738d884c48d.js +1 -0
- package/assets/esri/core/workers/chunks/62c8413f3bbc1378273d.js +1 -0
- package/assets/esri/core/workers/chunks/6501ee40bf25f9f75d02.js +1 -0
- package/assets/esri/core/workers/chunks/663cf8bff17c894cd5f8.js +1 -0
- package/assets/esri/core/workers/chunks/6d1371b521c7f94fd77e.js +1 -0
- package/assets/esri/core/workers/chunks/6d5038d4351fe29e2718.js +1 -0
- package/assets/esri/core/workers/chunks/6f102c90908c9900cdaa.js +1 -0
- package/assets/esri/core/workers/chunks/6f39545710d1b35d922c.js +1 -0
- package/assets/esri/core/workers/chunks/7278fdf6bfcdffa10a7f.js +1 -0
- package/assets/esri/core/workers/chunks/72eb0ac55026a4f5d6a7.js +1 -0
- package/assets/esri/core/workers/chunks/73cb499d7d68c59ba34e.js +1 -0
- package/assets/esri/core/workers/chunks/{b8d788e110c212a879ab.js → 73f228d966b89c73c9e9.js} +1 -1
- package/assets/esri/core/workers/chunks/76bccc318d7cc33829a7.js +1 -0
- package/assets/esri/core/workers/chunks/777eafdb86b26b35c803.js +1 -0
- package/assets/esri/core/workers/chunks/7821aeba3e414b318a75.js +1 -0
- package/assets/esri/core/workers/chunks/7b531feba4fd662575f9.js +1 -0
- package/assets/esri/core/workers/chunks/7c57354d026e27e056d4.js +1 -0
- package/assets/esri/core/workers/chunks/7d163d9d90393e491ee5.js +1 -0
- package/assets/esri/core/workers/chunks/7d4c65311064a5c2e0b1.js +1 -0
- package/assets/esri/core/workers/chunks/{0474af7687466d8befd2.js → 7e2794705b4e679fcb3f.js} +1 -1
- package/assets/esri/core/workers/chunks/7ebbb90d80600d9ba889.js +1 -0
- package/assets/esri/core/workers/chunks/7f125963555dc1ce63ad.js +1 -0
- package/assets/esri/core/workers/chunks/{763cbb6716e398436a6d.js → 7f6eee102871769fdf8f.js} +1 -1
- package/assets/esri/core/workers/chunks/805c97b875d3066fb8df.js +1 -0
- package/assets/esri/core/workers/chunks/8566449c39eba55147f5.js +1 -0
- package/assets/esri/core/workers/chunks/86ed75b7169b8ee43025.js +1 -0
- package/assets/esri/core/workers/chunks/{9482a6d7baa24bbf5693.js → 89132395eca329b9ab92.js} +1 -1
- package/assets/esri/core/workers/chunks/{28bc5e8e82f188b30eb9.js → 894343e415639df88243.js} +1 -1
- package/assets/esri/core/workers/chunks/8b4759cef5ae5e43253b.js +1 -0
- package/assets/esri/core/workers/chunks/8ba4175f5e9a24ffecf7.js +1 -0
- package/assets/esri/core/workers/chunks/8be707044d992ef5f1d8.js +1 -0
- package/assets/esri/core/workers/chunks/{bd862382f72ebd446b46.js → 8d2cac1952e817daaf1f.js} +1 -1
- package/assets/esri/core/workers/chunks/8e38c5e63aae42bdf5a4.js +29 -0
- package/assets/esri/core/workers/chunks/{02ab09285a5c4ca98066.js → 8f785b722b1a131bf370.js} +1 -1
- package/assets/esri/core/workers/chunks/8f9874f42f21a4cb3acd.js +1 -0
- package/assets/esri/core/workers/chunks/{57824ecc10b25e3ad794.js → 903e1cd8b76eff19ebdf.js} +1 -1
- package/assets/esri/core/workers/chunks/90f4b81c6034253b70d7.js +1 -0
- package/assets/esri/core/workers/chunks/917c11cb40a7742d7f98.js +1 -0
- package/assets/esri/core/workers/chunks/93ab247ff34694ac60eb.js +1 -0
- package/assets/esri/core/workers/chunks/93c0a620a147cbf4a0ba.js +1 -0
- package/assets/esri/core/workers/chunks/{6e45d0db97ffa4509177.js → 94bf7f0da6ad3f7ea277.js} +1 -1
- package/assets/esri/core/workers/chunks/9be6827e5756031a56c1.js +1 -0
- package/assets/esri/core/workers/chunks/9c57161ad48d8d546dc7.js +1 -0
- package/assets/esri/core/workers/chunks/{b2cf1d3f0d48eac23a84.js → 9c5dff4f13102871786e.js} +1 -1
- package/assets/esri/core/workers/chunks/9d0bda096cdbd7e22f4b.js +1 -0
- package/assets/esri/core/workers/chunks/9dfb7d120195991e9672.js +1 -0
- package/assets/esri/core/workers/chunks/9ed5e6b06afea6c85330.js +1 -0
- package/assets/esri/core/workers/chunks/{79b857bb301f9c4169d6.js → 9fee8441fbac9f723f77.js} +1 -1
- package/assets/esri/core/workers/chunks/a108f276659d5f25352c.js +1 -0
- package/assets/esri/core/workers/chunks/{b32ede7805c7c6644e4c.js → a3bf8aa81ee398da5b52.js} +1 -1
- package/assets/esri/core/workers/chunks/{5b30231ae0a8f4b8435f.js → a504fa17d83facf1c01f.js} +1 -1
- package/assets/esri/core/workers/chunks/a52c88e2d837b525ff6c.js +1 -0
- package/assets/esri/core/workers/chunks/{23a3d8f91caf3136b2aa.js → a5fdb02b1714e93fa69e.js} +1 -1
- package/assets/esri/core/workers/chunks/{538fe46dfd685a490e23.js → a7f42ada0aa69873a938.js} +1 -1
- package/assets/esri/core/workers/chunks/a97e0b9b057664911c14.js +1 -0
- package/assets/esri/core/workers/chunks/{cb58aff1ff186fa18345.js → a9f616f22042b0dce8b9.js} +1 -1
- package/assets/esri/core/workers/chunks/afd63c18ce4656271c8e.js +1 -0
- package/assets/esri/core/workers/chunks/{f04cb48fc73635d0572f.js → b059dabb1c732829487c.js} +1 -1
- package/assets/esri/core/workers/chunks/b313464b987db8a3987a.js +1 -0
- package/assets/esri/core/workers/chunks/b318823aefcefad6fad5.js +1 -0
- package/assets/esri/core/workers/chunks/b378e504a5b1afc8d0ce.js +1 -0
- package/assets/esri/core/workers/chunks/{9fb87a7dba62b527c0ba.js → b3a1a93c6dc9247cb048.js} +1 -1
- package/assets/esri/core/workers/chunks/b4e5ee81b9eb171499a6.js +1 -0
- package/assets/esri/core/workers/chunks/b5397dc03fa0bd654ba6.js +1 -0
- package/assets/esri/core/workers/chunks/b5b698008b8f3f4d5d61.js +1 -0
- package/assets/esri/core/workers/chunks/b7bcb31737b01d7736d0.js +1 -0
- package/assets/esri/core/workers/chunks/b9a1046ca2cd0cca5da5.js +1 -0
- package/assets/esri/core/workers/chunks/{cda04571d7623c17ada2.js → b9c7aa04861f545a559c.js} +1 -1
- package/assets/esri/core/workers/chunks/{7df795bc4fa1d433463b.js → ba030767cf935f967454.js} +1 -1
- package/assets/esri/core/workers/chunks/{53d165b4f30fd64e5d8a.js → bd311c85437743cf7d2f.js} +1 -1
- package/assets/esri/core/workers/chunks/bd88228f781a0399d8bd.js +1 -0
- package/assets/esri/core/workers/chunks/bece22668622a9a6bfe2.js +1 -0
- package/assets/esri/core/workers/chunks/bfb626805405646a0419.js +1 -0
- package/assets/esri/core/workers/chunks/c02ae1d40c1fe95ae6c5.js +1 -0
- package/assets/esri/core/workers/chunks/c203df41f9d2e4b80889.js +1 -0
- package/assets/esri/core/workers/chunks/{278409028bc5af45b507.js → c4c83b5129c279c3615b.js} +1 -1
- package/assets/esri/core/workers/chunks/c6ef0636073e28350c91.js +1 -0
- package/assets/esri/core/workers/chunks/c7e391df714839484cd1.js +1 -0
- package/assets/esri/core/workers/chunks/cded485ad893a7dd2948.js +1 -0
- package/assets/esri/core/workers/chunks/{1cf8fb704c48ac3d3b15.js → cf360767310fb45660a8.js} +1 -1
- package/assets/esri/core/workers/chunks/{8f2fecd8a0a972d68590.js → cf8ce63711488f2e677c.js} +1 -1
- package/assets/esri/core/workers/chunks/d214ac457ac970479536.js +1 -0
- package/assets/esri/core/workers/chunks/d4058352db1e8255b52e.js +1 -0
- package/assets/esri/core/workers/chunks/d4d385d19e62ef1c286f.js +1 -0
- package/assets/esri/core/workers/chunks/d4f005dadba75422b401.js +1 -0
- package/assets/esri/core/workers/chunks/d583bcea4d1a21da9147.js +1 -0
- package/assets/esri/core/workers/chunks/{52c4b4dabcb0d162be72.js → d5e15021928e95c11463.js} +1 -1
- package/assets/esri/core/workers/chunks/{fc639c730115e07a4a1a.js → d6500f6b2ff115d9eb09.js} +1 -1
- package/assets/esri/core/workers/chunks/{3f775deea48e268411f1.js → d7267f429a051943187b.js} +1 -1
- package/assets/esri/core/workers/chunks/d9c78c2db04a06ee83ed.js +1 -0
- package/assets/esri/core/workers/chunks/{e65ee26feca0564aeb9b.js → dc7e4f7879debf557e46.js} +145 -97
- package/assets/esri/core/workers/chunks/e1492d2404c3ed82931e.js +1 -0
- package/assets/esri/core/workers/chunks/e34ed3b818b2eb4116c5.js +1 -0
- package/assets/esri/core/workers/chunks/e7149d23615fee31ab7e.js +1 -0
- package/assets/esri/core/workers/chunks/ec774f5d6ea5c29536e5.js +1 -0
- package/assets/esri/core/workers/chunks/ed71a4e353715db0a6e9.js +1 -0
- package/assets/esri/core/workers/chunks/{1e342d532925569daadb.js → f475672ff4c2ec9367c2.js} +1 -1
- package/assets/esri/core/workers/chunks/{cc414fd2e313d89d524d.js → f54eba484f40d5eeb590.js} +1 -1
- package/assets/esri/core/workers/chunks/{04ffe788d2efc0a076dd.js → f5c9659fc5d571d501c9.js} +1 -1
- package/assets/esri/core/workers/chunks/f622b27ebdf1c918fd6d.js +1 -0
- package/assets/esri/core/workers/chunks/{dd95f50dac3f33cdb6d2.js → f6a13f07a5f7b781a9a8.js} +1 -1
- package/assets/esri/core/workers/chunks/{d849bdaf5bdfdc37531a.js → f6f7d885b4d6080e3f58.js} +1 -1
- package/assets/esri/core/workers/chunks/f8b8d3d2710c83acccf3.js +1 -0
- package/assets/esri/core/workers/chunks/f95870bb4d8e4e13e69e.js +1 -0
- package/assets/esri/core/workers/chunks/fa59f10ed0f182a2a7f3.js +1 -0
- package/assets/esri/core/workers/chunks/faa55265020591fd2224.js +1 -0
- package/assets/esri/core/workers/chunks/fc827f58db3194922056.js +1 -0
- package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
- package/chunks/Component.glsl.js +60 -62
- package/chunks/DefaultMaterial.glsl.js +27 -28
- package/chunks/GaussianSplat.glsl.js +7 -7
- package/chunks/GaussianSplatShadow.glsl.js +9 -9
- package/chunks/GlobalIllumination.glsl.js +35 -15
- package/chunks/Path.glsl.js +7 -6
- package/chunks/RealisticTree.glsl.js +22 -24
- package/chunks/SSAO.glsl.js +1 -1
- package/chunks/Terrain.glsl.js +3 -2
- package/chunks/Water.glsl.js +20 -11
- package/chunks/aiServices.js +1 -1
- package/chunks/array.js +1 -1
- package/chunks/bundle2.js +1 -1
- package/chunks/languageUtils.js +1 -1
- package/config.js +1 -1
- package/form/ExpressionInfo.d.ts +1 -1
- package/form/ExpressionInfo.js +1 -1
- package/form/elements/FieldElement.d.ts +3 -2
- package/form/elements/inputs/ComboBoxInput.d.ts +4 -15
- package/form/elements/inputs/ComboBoxInput.js +1 -1
- package/form/elements/inputs/DynamicChoiceInput.d.ts +31 -0
- package/form/elements/inputs/DynamicChoiceInput.js +2 -0
- package/form/elements/inputs/Input.d.ts +1 -1
- package/form/elements/inputs/RadioButtonsInput.d.ts +4 -15
- package/form/elements/inputs/RadioButtonsInput.js +1 -1
- package/form/elements/inputs/SingleChoiceInput.d.ts +18 -0
- package/form/elements/inputs/SingleChoiceInput.js +2 -0
- package/form/elements/inputs.d.ts +11 -2
- package/form/elements/inputs.js +1 -1
- package/geometry/support/normalizeUtils.d.ts +1 -1
- package/kernel.js +1 -1
- package/layers/ImageryTileLayer.d.ts +1 -1
- package/layers/RouteLayer.d.ts +1 -1
- package/layers/graphics/sources/ParquetSource.js +1 -1
- package/layers/graphics/sources/parquet/FileProvider.js +1 -1
- package/layers/graphics/sources/parquet/ParquetFileInfo.js +1 -1
- package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
- package/layers/mixins/ArcGISImageService.d.ts +24 -24
- package/layers/mixins/TiledImagery.d.ts +1 -1
- package/layers/orientedImagery/transformations/rectifyMapPoint.js +1 -1
- package/layers/raster/datasets/EphemeralBlockCache.js +1 -1
- package/layers/raster/datasets/RawBlockCache.js +1 -1
- package/layers/support/KMLSublayer.js +1 -1
- package/libs/parquet/parquet.js +1 -1
- package/networks/support/CircuitExportJobInfo.d.ts +1 -1
- package/networks/support/CircuitVerifyJobInfo.d.ts +1 -1
- package/networks/support/TopologyValidationJobInfo.d.ts +1 -1
- package/networks/support/TraceJobInfo.d.ts +1 -1
- package/package.json +2 -2
- package/portal/jsonTypes.d.ts +1 -1
- package/rest/closestFacility.d.ts +1 -1
- package/rest/find.d.ts +1 -1
- package/rest/geometryService.d.ts +21 -21
- package/rest/geoprocessor.d.ts +2 -2
- package/rest/identify.d.ts +1 -1
- package/rest/imageService.d.ts +19 -19
- package/rest/lastMileDelivery.d.ts +8 -8
- package/rest/locator.d.ts +4 -4
- package/rest/networkService.d.ts +1 -1
- package/rest/networks/queryAssociations.d.ts +1 -1
- package/rest/networks/synthesizeAssociationGeometries.d.ts +1 -1
- package/rest/networks/trace.d.ts +1 -1
- package/rest/networks/traverseAssociations.d.ts +1 -1
- package/rest/places.d.ts +3 -3
- package/rest/print.d.ts +1 -1
- package/rest/query.d.ts +11 -11
- package/rest/route.d.ts +1 -1
- package/rest/serviceArea.d.ts +1 -1
- package/rest/support/JobInfo.d.ts +5 -5
- package/rest/support/Query.js +1 -1
- package/rest/symbolService.d.ts +1 -1
- package/support/revision.js +1 -1
- package/symbols/LabelSymbol3D.js +1 -1
- package/symbols/LineSymbol3D.js +1 -1
- package/symbols/MeshSymbol3D.js +1 -1
- package/symbols/PointSymbol3D.js +1 -1
- package/symbols/PolygonSymbol3D.js +1 -1
- package/views/2d/layers/features/sources/strategies/ParquetTileLoadStrategy.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightReshapeTool3D.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementShiftTool.js +1 -1
- package/views/3d/interactive/editingTools/transform/TransformTool3D.js +1 -1
- package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPathSymbolLayerConstants.js +1 -1
- package/views/3d/layers/graphics/defaultSymbolComplexity.js +1 -1
- package/views/3d/state/controllers/RotateController.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatFadeHelper.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/PathEvaluate.glsl.js +49 -32
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/PathVertexInfo.glsl.js +5 -5
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/PathVertexPosition.glsl.js +23 -23
- package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +24 -16
- package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialExternalColor.glsl.js +25 -0
- package/views/3d/webgl-engine/lib/GaussianSplatRenderUtils.js +2 -0
- package/views/3d/webgl-engine/lib/GaussianSplatRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/GaussianSplatShadows.js +1 -1
- package/views/3d/webgl-engine/lib/PathBuilder.js +1 -1
- package/views/3d/webgl-engine/lib/PathEvaluator.js +1 -1
- package/views/3d/webgl-engine/lib/PathExtruder.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/GaussianSplat.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/GaussianSplatPassParameters.js +2 -0
- package/views/3d/webgl-engine/shaders/GaussianSplatShadow.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/GaussianSplatShadowTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/GaussianSplatTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/RealisticTree.glsl.js +1 -1
- package/views/draw/support/InteractiveHandle.js +1 -1
- package/views/draw/support/managers/SurfaceManager.js +1 -1
- package/views/interactive/Tooltip.d.ts +3 -3
- package/views/interactive/Tooltip.js +1 -1
- package/views/interactive/options/ElevationOptions.d.ts +20 -0
- package/views/interactive/options/ElevationOptions.js +2 -0
- package/views/interactive/options/LabelOptions.d.ts +74 -0
- package/views/interactive/options/LabelOptions.js +2 -0
- package/views/interactive/options/SnappingOptions.d.ts +157 -0
- package/views/interactive/options/SnappingOptions.js +2 -0
- package/views/interactive/options/TooltipOptions.d.ts +152 -0
- package/views/interactive/options/TooltipOptions.js +2 -0
- package/views/interactive/options/TooltipVisibleElements.d.ts +105 -0
- package/views/interactive/options/TooltipVisibleElements.js +2 -0
- package/views/interactive/options/ValueOptions.d.ts +63 -0
- package/views/interactive/options/ValueOptions.js +2 -0
- package/views/interactive/sketch/SketchLabelOptions.d.ts +7 -9
- package/views/interactive/sketch/SketchLabelOptions.js +1 -1
- package/views/interactive/sketch/SketchTooltipElevationOptions.js +1 -1
- package/views/interactive/sketch/SketchTooltipOptions.d.ts +8 -50
- package/views/interactive/sketch/SketchTooltipOptions.js +1 -1
- package/views/interactive/sketch/SketchTooltipVisibleElements.d.ts +10 -95
- package/views/interactive/sketch/SketchTooltipVisibleElements.js +1 -1
- package/views/interactive/sketch/SketchValueOptions.d.ts +7 -45
- package/views/interactive/sketch/SketchValueOptions.js +1 -1
- package/views/interactive/sketch/Units.d.ts +10 -29
- package/views/interactive/sketch/Units.js +1 -1
- package/views/interactive/snapping/SnappingOptions.d.ts +7 -78
- package/views/interactive/snapping/SnappingOptions.js +1 -1
- package/views/interactive/support/Units.d.ts +33 -0
- package/views/interactive/support/Units.js +2 -0
- package/views/interactive/support/types.d.ts +33 -0
- package/views/interactive/tooltip/types.d.ts +6 -2
- package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
- package/widgets/BatchAttributeForm/expressions/ExpressionsManager.js +1 -1
- package/widgets/BatchAttributeForm/expressions/ExpressionsModel.js +1 -1
- package/widgets/LayerList/ListItem.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/services/SuperimposeService.js +1 -1
- package/widgets/OrientedImageryViewer/services/TransformationService.js +1 -1
- package/widgets/OrientedImageryViewer/support/superimposeUtils.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/TableList/ListItem.js +1 -1
- package/assets/esri/core/workers/chunks/02dd79beb13eff6be85e.js +0 -1
- package/assets/esri/core/workers/chunks/0623acb2bd14a61b65c9.js +0 -29
- package/assets/esri/core/workers/chunks/069b6d8bdb34ee88d437.js +0 -1
- package/assets/esri/core/workers/chunks/0790bf0eb276cd9166f6.js +0 -1
- package/assets/esri/core/workers/chunks/08c2bf9defcece9e049a.js +0 -1
- package/assets/esri/core/workers/chunks/0ae0483b72f5e8d00d55.js +0 -1
- package/assets/esri/core/workers/chunks/0d1224693a62a26a0e72.js +0 -1
- package/assets/esri/core/workers/chunks/10b367563f894ceb9864.js +0 -1
- package/assets/esri/core/workers/chunks/11e00ca5ac1b004f4ecc.js +0 -1
- package/assets/esri/core/workers/chunks/13033178de9f637a2356.js +0 -1
- package/assets/esri/core/workers/chunks/13c893e448bedc5c1cef.js +0 -1
- package/assets/esri/core/workers/chunks/14cd8bb1ad4da8d1d2ca.js +0 -1
- package/assets/esri/core/workers/chunks/15c2d9bec0455fc363a9.js +0 -1
- package/assets/esri/core/workers/chunks/246cd372d4184233f48e.js +0 -1
- package/assets/esri/core/workers/chunks/268ab65afc3fce775ad2.js +0 -1
- package/assets/esri/core/workers/chunks/279a9a38b04a21cdfd11.js +0 -1
- package/assets/esri/core/workers/chunks/2a1c6df073e6ca6a6365.js +0 -1
- package/assets/esri/core/workers/chunks/3406a01dad6338e3c548.js +0 -1
- package/assets/esri/core/workers/chunks/36781219ca9ba5d7fe52.js +0 -1
- package/assets/esri/core/workers/chunks/36999a2e383c8eb3c398.js +0 -1
- package/assets/esri/core/workers/chunks/36f8a912842181e1f0aa.js +0 -1
- package/assets/esri/core/workers/chunks/3f1a7f8a9ead64bf0b7b.js +0 -1
- package/assets/esri/core/workers/chunks/41e821ce229bc56dc1a1.js +0 -1
- package/assets/esri/core/workers/chunks/43b39abd49c4a8ce891f.js +0 -1
- package/assets/esri/core/workers/chunks/456e616f32e7de696d38.js +0 -1
- package/assets/esri/core/workers/chunks/478540265c86436da05e.js +0 -1
- package/assets/esri/core/workers/chunks/479f486ec1797629ec70.js +0 -1
- package/assets/esri/core/workers/chunks/484b3e2a220c440ccbb4.js +0 -1
- package/assets/esri/core/workers/chunks/4a340836ddbc856993f2.js +0 -1
- package/assets/esri/core/workers/chunks/54b9667450d066c6f6ce.js +0 -1
- package/assets/esri/core/workers/chunks/57b07448da06d0302a46.js +0 -1
- package/assets/esri/core/workers/chunks/5a9ff50fdcc99ae28cce.js +0 -1
- package/assets/esri/core/workers/chunks/5dbd8ca7e7b8eb9a0bf7.js +0 -1
- package/assets/esri/core/workers/chunks/5dc17b76c6ecc24e7b9a.js +0 -1
- package/assets/esri/core/workers/chunks/5e3d5347223f0111f40f.js +0 -1
- package/assets/esri/core/workers/chunks/5eb6f37c74a217772eca.js +0 -1
- package/assets/esri/core/workers/chunks/6210fb6cd31844f23964.js +0 -1
- package/assets/esri/core/workers/chunks/638ed1297efdb24f4711.js +0 -1
- package/assets/esri/core/workers/chunks/63ede7295938f7010808.js +0 -1
- package/assets/esri/core/workers/chunks/661a59133ae34f172174.js +0 -1
- package/assets/esri/core/workers/chunks/687cf21e027f49b44d22.js +0 -1
- package/assets/esri/core/workers/chunks/6c2b5087a9df65267f4e.js +0 -1
- package/assets/esri/core/workers/chunks/6c98a64d92c9bca78203.js +0 -1
- package/assets/esri/core/workers/chunks/6d247ff53421d27628ce.js +0 -1
- package/assets/esri/core/workers/chunks/700c08dd2e734c15e621.js +0 -1
- package/assets/esri/core/workers/chunks/70452f6d63e9be8d03dd.js +0 -1
- package/assets/esri/core/workers/chunks/733b2e181683d5fc7c95.js +0 -1
- package/assets/esri/core/workers/chunks/7659391f952d134164cf.js +0 -1
- package/assets/esri/core/workers/chunks/7889f4a17cf249f2acc5.js +0 -1
- package/assets/esri/core/workers/chunks/7a2dcd57849048c6e00d.js +0 -1
- package/assets/esri/core/workers/chunks/7a2dfa42610fe8414ed7.js +0 -1
- package/assets/esri/core/workers/chunks/7ce52b850dd785bfa33f.js +0 -1
- package/assets/esri/core/workers/chunks/7d85048c6cd6ad84faf9.js +0 -1
- package/assets/esri/core/workers/chunks/7fdd6a5fa062778be55d.js +0 -1
- package/assets/esri/core/workers/chunks/81accb1820e2735fa376.js +0 -1
- package/assets/esri/core/workers/chunks/8210fc9e072209e26fa9.js +0 -1
- package/assets/esri/core/workers/chunks/8369edafab7bdc59b95a.js +0 -1
- package/assets/esri/core/workers/chunks/84fa102a93b2144c28fb.js +0 -1
- package/assets/esri/core/workers/chunks/85ce7673d42526a79fd2.js +0 -1
- package/assets/esri/core/workers/chunks/8722e2790272e90a1897.js +0 -1
- package/assets/esri/core/workers/chunks/8a1970e68bc1e833cb7f.js +0 -1
- package/assets/esri/core/workers/chunks/8bb20ef549ec1c86b38e.js +0 -1
- package/assets/esri/core/workers/chunks/8c535c6a39d2be2ed655.js +0 -1
- package/assets/esri/core/workers/chunks/9008090a5d8431ddfa22.js +0 -1
- package/assets/esri/core/workers/chunks/92696cce2b980373f9ad.js +0 -1
- package/assets/esri/core/workers/chunks/98b27cf8acbfa4259758.js +0 -1
- package/assets/esri/core/workers/chunks/9a6208ab670ad74e6f7d.js +0 -1
- package/assets/esri/core/workers/chunks/a09ce34fc7c8abe64ed5.js +0 -1
- package/assets/esri/core/workers/chunks/a10f63a08d976be058be.js +0 -1
- package/assets/esri/core/workers/chunks/a5f058567419ea70dff6.js +0 -1
- package/assets/esri/core/workers/chunks/a965d151515b76dd7566.js +0 -1
- package/assets/esri/core/workers/chunks/afeeb11b39e140303b5a.js +0 -1
- package/assets/esri/core/workers/chunks/b7170816736769d3b7b0.js +0 -1
- package/assets/esri/core/workers/chunks/b8e5d7aefddddbd0a10c.js +0 -1
- package/assets/esri/core/workers/chunks/b958f87f23f984131d09.js +0 -1
- package/assets/esri/core/workers/chunks/b9f40681af1fa00b5bbe.js +0 -1
- package/assets/esri/core/workers/chunks/c4c25db769a78e677e33.js +0 -1
- package/assets/esri/core/workers/chunks/c85ba0700eafdc8d6f9e.js +0 -1
- package/assets/esri/core/workers/chunks/c97451f75c23be979476.js +0 -1
- package/assets/esri/core/workers/chunks/ca118c42c0f609ca7912.js +0 -1
- package/assets/esri/core/workers/chunks/cb17cd8aaf77238c0236.js +0 -1
- package/assets/esri/core/workers/chunks/d03f427442bb0c287d05.js +0 -1
- package/assets/esri/core/workers/chunks/d08d3c6f21e6ba8268ca.js +0 -1
- package/assets/esri/core/workers/chunks/d37a72111dffc4c4db70.js +0 -1
- package/assets/esri/core/workers/chunks/d41ab2abcfacc87809b5.js +0 -1
- package/assets/esri/core/workers/chunks/d4ed094962a41d756c95.js +0 -1
- package/assets/esri/core/workers/chunks/d83ea3e4e9ab45334068.js +0 -1
- package/assets/esri/core/workers/chunks/d9b83d7dd7d1f7729a91.js +0 -1
- package/assets/esri/core/workers/chunks/dbcec48c4ba104a6d0b5.js +0 -1
- package/assets/esri/core/workers/chunks/dc24e80d061f7b063608.js +0 -1
- package/assets/esri/core/workers/chunks/df30053a10d4930924d5.js +0 -1
- package/assets/esri/core/workers/chunks/e5bb7ee670a3ba5ba3fe.js +0 -1
- package/assets/esri/core/workers/chunks/e5c75459de85a6dd2f14.js +0 -1
- package/assets/esri/core/workers/chunks/e798ca23f02a2dd65bd4.js +0 -1
- package/assets/esri/core/workers/chunks/f1299b4fc760ccca1518.js +0 -1
- package/assets/esri/core/workers/chunks/f65adaaa33d9f3b131f6.js +0 -1
- package/assets/esri/core/workers/chunks/f6715b8765cd36d81ec8.js +0 -1
- package/assets/esri/core/workers/chunks/f7fa932ade85cb2847b6.js +0 -1
- package/assets/esri/core/workers/chunks/f9a4f4efd63b8189a4eb.js +0 -1
- package/assets/esri/core/workers/chunks/f9b654f801cb416e9e17.js +0 -1
- package/assets/esri/core/workers/chunks/fa1c58e5b582d61a03ab.js +0 -1
- package/assets/esri/core/workers/chunks/fdec3a2e100688c42e41.js +0 -1
- package/assets/esri/core/workers/chunks/fefbde2c2e527bb716ee.js +0 -1
- /package/assets/esri/core/workers/chunks/{a12803108c3b12808698.js.LICENSE.txt → 242cad472fbc38b24dbc.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{abortMaybe as i,removeMaybe as s,destroyMaybe as r}from"../../../core/maybe.js";import{throwIfAborted as a}from"../../../core/promiseUtils.js";import{watch as n,initial as l}from"../../../core/reactiveUtils.js";import{unitFromRESTJSON as o,convertUnit as h}from"../../../core/units.js";import{property as d,subclass as u}from"../../../core/accessorSupport/decorators.js";import{fromValues as c}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{getReferenceEllipsoid as p}from"../../../geometry/ellipsoidUtils.js";import m from"../../../geometry/HeightModelInfo.js";import{create as f}from"../../../geometry/support/aaBoundingBox.js";import{isCompatible as g}from"../../../geometry/support/heightModelInfoUtils.js";import{isPlateCarree as _,isWebMercator as y,equals as w,isGeographic as b}from"../../../geometry/support/spatialReferenceUtils.js";import v from"../../../geometry/support/WKIDUnitConversion.js";import{validateMeshData as S,makeCacheKey as C,getHeightModelInfoFromVCS as M}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as x}from"../../../support/elevationInfoUtils.js";import{getMetersPerUnit as T}from"../../../symbols/support/unitConversionUtils.js";import{GaussianSplatLayerViewPerformanceInfo as H}from"./GaussianSplatLayerViewPerformanceInfo.js";import{LayerView3D as I}from"./LayerView3D.js";import{addLayerViewToWasm as A,getLyr3DWasm as P,removeLayerViewFromWasm as F}from"./Lyr3DWasm.js";import{LayerElevationProvider as V}from"./i3s/LayerElevationProvider.js";import{ElevationRange as R}from"../support/ElevationRange.js";import{projectToBoundingBox as j}from"../support/extentUtils.js";import{Obb as E}from"../support/orientedBoundingBox.js";import{splatPageSizeInU32 as G,gaussiansPerPage as O,packedGaussianSizeInU32 as U,splatAtlasTextureWidth as D}from"../support/gaussianSplatting/GaussianSplatAtlasPages.js";import{GaussianSplatDataStore as z}from"../support/gaussianSplatting/GaussianSplatDataStore.js";import{GaussianSplatFadeHelper as B}from"../support/gaussianSplatting/GaussianSplatFadeHelper.js";import{GaussianSplatIntersectionHandler as L}from"../support/gaussianSplatting/GaussianSplatIntersectionHandler.js";import{GaussianTile as k}from"../support/gaussianSplatting/GaussianTile.js";import{GaussianSplatRenderer as q}from"../webgl-engine/lib/GaussianSplatRenderer.js";import{GaussianSplatShadows as W}from"../webgl-engine/lib/GaussianSplatShadows.js";import N from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as $,isInEffectiveScaleRange as X}from"../../support/layerViewUtils.js";import{TaskPriority as Z}from"../../support/Scheduler.js";var K;const Y=()=>t.getLogger("esri.views.3d.layers.GaussianSplatLayerView3D"),J=3,Q=J*J,ee=255,te=(()=>{const e=new Int16Array(ee+1);e[0]=-255;for(let t=1;t<e.length;t++)e[t]=Math.round(16*Math.log(t/ee));return e})();let ie=class extends(I(N)){static{K=this}static{this.createRenderableBatchSize=64}constructor(e){super(e),this.type="gaussian-splat-3d",this.ignoresMemoryFactor=!1,this._tileHandles=new Map,this._pageBuffer=new Uint32Array(G),this._tmpTilesWithChangedVisibility=new Array,this._renderablesBeingCreated=new Set,this._currentLyr3dVisibilityChange=0,this._tileFadeInsAwaitingInitialSort=new Map,this._tileFadeOutsAwaitingInitialSort=new Map,this._fadeDurationPerVisibilityChange=new Map,this._tmpSortedTileHandles=new Set,this._createRenderableAbortController=new AbortController,this._initializationController=null,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this._usedTileMemory=0,this._cacheTileMemory=0,this._useEsriCrs=!1,this.fullExtentInLocalViewSpatialReference=null,this._suspendedHandle=null,this._conversionBuffer=new ArrayBuffer(4),this._u32View=new Uint32Array(this._conversionBuffer),this._f32View=new Float32Array(this._conversionBuffer);const t=e.view.resourceController;this._memCache=t.memoryController.newCache(`GaussianSplat-${this.uid}`,e=>this._deleteTile(e)),this._frameTask=t.scheduler.registerTask(Z.GAUSSIAN_SPLAT_TEXTURE_ATLAS)}get _clippingBox(){if(!this.view?.clippingArea)return null;const e=f();return j(this.view.clippingArea,e,this.view.renderSpatialReference)?e:null}get clippingBox(){return this._renderer?.clippingBox??null}initialize(){if(!this._canProjectWithoutEngine())throw $("layer",this.layer.spatialReference.wkid,this.view.renderSpatialReference?.wkid);this._initializationController=new AbortController;const e=A(this,this._initializationController.signal).then(e=>{a(this._initializationController.signal),this._wasmLayerId=e,this._renderer=new q({view:this.view,layerView:this}),this.data=new z(this._renderer,(e,t)=>this._onSortComplete(e,t),()=>this._freeInvisibleTiles()),this._shadows=new W({view:this.view,layerView:this}),this.fadeHelper=new B(this),this._intersectionHandler=new L(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._elevationProvider=new V({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this.view.elevationProvider.register(2,this._elevationProvider),this.addHandles([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),n(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChanged(e),l)]),this._suspendedHandle=n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),l),this.addHandles([n(()=>this._clippingBox,e=>{this._renderer&&(this._renderer.clippingBox=e)},l)]),this.setMaximumGaussianCount(this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians),this._initializationController=null});this.addHandles([n(()=>this.view.qualitySettings.fadeDuration,e=>{const t=this.data;t&&(this.fadeHelper.onFadeDurationChanged(e),t.fadingTexture.updateTexture(t.textureAtlas.pageAllocator.pageCount))}),n(()=>this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians,e=>this.setMaximumGaussianCount(e*this.view.quality)),n(()=>this.view.quality,e=>this.setMaximumGaussianCount(this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians*e))]),this.addResolvingPromise(e)}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get tileHandles(){return this._tileHandles}get _wasm(){return P(this.view)}get usedMemory(){return this._usedTileMemory+(this.data?.usedMemory??0)}get cachedMemory(){return this._cacheTileMemory}get unloadedMemory(){return 0}get useEsriCrs(){return this._useEsriCrs}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return x(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new R(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get fullExtent(){return this.layer.fullExtent}get visibleAtCurrentScale(){return X(this.layer.effectiveScaleRange,this.view.scale)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&(e.isUpdating(this._wasmLayerId)||this.data.updating||this.fadeHelper.updating)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed||this.destroying)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy");const{meshData:t}=e;if(!S(t))throw new Error("meshData not valid");const i=t.desc.prims[0],s=i.vertexCount;if(0===s)return Y().warnOnce("encountered tile with zero Gaussians"),()=>({memUsageBytes:0,numGaussians:0});const r=i.atrbs[0].view,a=i.atrbs[0].view.byteCount,n=i.atrbs[0].view.byteOffset;let l=null;if("U32"!==r.type)throw new Error("unexpected meshData.data format");l=new Uint32Array(t.data.buffer,n,a/4);const o=this.extractHeader(l),h=2.048,d=o.tileOrigin.x*h,u=o.tileOrigin.y*h,m=o.tileOrigin.z*h,f=t.desc;if(null==f.obb)throw new Error("meshData.desc.obb undefined");const g=f.obb.quaternion,_=new E(f.obb.center,f.obb.halfSize,c(...g)),y=this.view.state.isGlobal,w=y?p(this.view.spatialReference).radius:0,b={handle:e.handle,bufferView:l,totalGaussians:s,packedHeader:o.packedHeader,tileOrigin:{x:d,y:u,z:m},invPosScale:o.invPosScale,obb:_,origin:{x:_.centerX,y:_.centerY,z:_.centerZ},isGlobal:y,ellipsoidRadius:w};let v;this._renderablesBeingCreated.add(e.handle);try{v=await this._frameTask.scheduleGenerator(e=>this._createRenderableTask(b,e),this._createRenderableAbortController.signal)}catch(C){throw this._renderablesBeingCreated.delete(e.handle),C}return this._renderablesBeingCreated.delete(e.handle),()=>v}*_createRenderableTask(e,t){const{handle:i,bufferView:s,totalGaussians:r,packedHeader:a,tileOrigin:n,invPosScale:l,obb:o,origin:h,isGlobal:d,ellipsoidRadius:u}=e,c=n.x,p=n.y,m=n.z,f=h.x,g=h.y,_=h.z,y=new Uint32Array(r),w=new Float32Array(3*r),b=new Uint32Array(r),v=new Uint32Array(r),S=new Array,C=Math.ceil(r/O);let M=1/0,x=-1/0,T=1/0,H=-1/0,I=0,A=-1,P=0,F=0;for(let R=0;R<r;R++){const e=R*U,i=s[e],r=s[e+1],a=s[e+2],n=s[e+3],o=16383&r,h=r>>>14&16383,u=r>>>28&15|(1023&a)<<4,y=n>>>24,S=te[y],C=(a>>>10&255)+S,V=(a>>>18&255)+S,j=(a>>>26&63|(3&n)<<6)+S,E=C>0?C:0,G=V>0?V:0,O=j>0?j:0,D=E|G<<8|O<<16,z=Math.max(E,G,O),B=o*l+c,L=h*l+p,k=u*l+m;if(w[I]=B-f,w[I+1]=L-g,w[I+2]=k-_,d){const e=B*B+L*L+k*k;T=Math.min(T,e),H=Math.max(H,e)}else M=Math.min(M,k),x=Math.max(x,k);b[R]=i,v[R]=D,z>A&&(A=z),y>P&&(P=y),I+=3,F++,F===K.createRenderableBatchSize&&(F=0,t.madeProgress()&&(t=yield))}F>0&&t.madeProgress(),d&&(M=Math.sqrt(T)-u,x=Math.sqrt(H)-u);const V=this._extractGaussianSplatMbsRadiusSquared(A),{fullExtent:j}=this.layer;j?.hasZ&&j.zmax&&j.zmin&&(M=Math.max(M,j.zmin),x=Math.min(x,j.zmax));const E=new R(M,x);try{for(let e=0;e<C;e++){let t=this.data.textureAtlas.allocatePage();if(null===t&&(this._freeInvisibleTiles(),t=this.data.textureAtlas.allocatePage()),null===t)throw new Error("ran out of gaussian splat memory");S.push(t);const i=r-e*O,n=Math.min(i,O),l=e*O,o=t*O;for(let e=0;e<n;e++)y[l+e]=o+e;const h=e*G,d=n*U;this._pageBuffer.set(s.subarray(h,h+d));const u=o%D,c=Math.floor(o/D);this.data.textureAtlas.update(u,c,this._pageBuffer),this.data.headerTexture.update(t,a)}}catch(B){throw this.data.textureAtlas.freePages(S),B}const z=new k(i,o,y,S,w,b,v,r,V,P/ee,E);return this._tileHandles.set(i,z),this._cacheTileMemory+=z.usedMemory,this._memCache.put(`${z.handle}`,z),{memUsageBytes:z.usedMemory,numGaussians:r}}_extractGaussianSplatMbsRadiusSquared(e){return Math.exp(e/8-20)*Q}freeRenderable(e){this._tileFadeInsAwaitingInitialSort.delete(e),this._tileFadeOutsAwaitingInitialSort.delete(e);const t=this.data?.textureAtlas;let i=!1;const s=this._tileHandles.get(e);if(s){0!==s.lifecycleState?(i=!0,this.fadeHelper.onTileDiscarded(s),this._usedTileMemory-=s.usedMemory,this._intersectionHandler.removeTile(s)):this._cacheTileMemory-=s.usedMemory,t&&s.pageIds.forEach(e=>t.freePage(e)),this.freeObject(s),this._tileHandles.delete(e)}i&&this.updateGaussians()}freeObject(e){this._memCache.pop(`${e.handle}`)}notifyTileObbsChanged(e){this._elevationProvider&&this._elevationProvider.notifyObjectsChangedFunctional(e.length,t=>{for(const{obb:i}of e)if(!t(i))break})}setRenderableVisibility(e,t,i){const s=this._currentLyr3dVisibilityChange+1,r=this.fadeHelper.updateFadeDuration();this._fadeDurationPerVisibilityChange.set(s,r);let a=!1;for(let n=0;n<i;n++){const i=this._tileHandles.get(e[n]);if(!i)continue;const l=t[n]?this._prepareTileFadeIn(i,s,r):this._prepareTileFadeOut(i,s);a||=l}a?(this._currentLyr3dVisibilityChange=s,this.updateGaussians()):this._fadeDurationPerVisibilityChange.delete(s)}_prepareTileFadeIn(e,t,i){const s=this._tileFadeOutsAwaitingInitialSort.delete(e.handle);return 2===e.lifecycleState?(this.fadeHelper.fadeTile(e,0,i),!1):this._tileFadeInsAwaitingInitialSort.get(e.handle)!==t?(0===e.lifecycleState&&this._popTileFromCache(e),e.lifecycleState=1,this._tileFadeInsAwaitingInitialSort.set(e.handle,t),!0):s}_prepareTileFadeOut(e,t){const i=this._tileFadeInsAwaitingInitialSort.delete(e.handle);return i&&1===e.lifecycleState&&(this.moveTileToCache(e),e.lifecycleState=0),2!==e.lifecycleState?i:this._tileFadeOutsAwaitingInitialSort.get(e.handle)!==t?(this._tileFadeOutsAwaitingInitialSort.set(e.handle,t),!0):i}_onSortComplete(e,t){const i=this._tmpTilesWithChangedVisibility;i.length=0;const s=this._tmpSortedTileHandles;s.clear();for(let a=0;a<e.length;a++){const t=e[a];s.add(t.handle)}this._triggerFadeIns(t,s,i);const r=this._triggerFadeOuts(t,i);s.clear(),i.length>0&&this.notifyTileObbsChanged(i),r&&this.updateGaussians(),this._cleanupVisibilityChangeFadeDurations(t)}_triggerFadeIns(e,t,i){for(const[s,r]of this._tileFadeInsAwaitingInitialSort){if(r>e||!t.has(s))continue;const a=this._tileHandles.get(s);if(!a){this._tileFadeInsAwaitingInitialSort.delete(s);continue}const n=this._getFadeDurationForPendingVisibilityChange(r),l=0===a.lifecycleState;2!==a.lifecycleState&&(a.lifecycleState=2,l&&this._popTileFromCache(a),i.push(a)),this.fadeHelper.fadeTile(a,0,n),this._tileFadeInsAwaitingInitialSort.delete(s)}}_triggerFadeOuts(e,t){let i=!1;for(const[s,r]of this._tileFadeOutsAwaitingInitialSort){if(r>e)continue;const a=this._tileHandles.get(s);if(a){const e=2===a.lifecycleState,s=this._getFadeDurationForPendingVisibilityChange(r);this.fadeHelper.fadeTile(a,1,s),e&&0===a.lifecycleState&&(t.push(a),i=!0)}this._tileFadeOutsAwaitingInitialSort.delete(s)}return i}_getFadeDurationForPendingVisibilityChange(e){return this._fadeDurationPerVisibilityChange.get(e)??this.fadeHelper.baseFadeDuration}_cleanupVisibilityChangeFadeDurations(e){if(0!==this._fadeDurationPerVisibilityChange.size)for(const t of this._fadeDurationPerVisibilityChange.keys())t<=e&&this._fadeDurationPerVisibilityChange.delete(t)}_popTileFromCache(e){this._usedTileMemory+=e.usedMemory,this._cacheTileMemory-=e.usedMemory,this._intersectionHandler.addTile(e),this._memCache.pop(C(e.handle))}moveTileToCache(e){this._usedTileMemory-=e.usedMemory,this._cacheTileMemory+=e.usedMemory,this._intersectionHandler.removeTile(e),this._memCache.put(C(e.handle),e)}destroy(){this._initializationController=i(this._initializationController),this._createRenderableAbortController.abort(),F(this),this._suspendedHandle&&(this._suspendedHandle=s(this._suspendedHandle)),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&this.view.elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(this._tileHandles.size,e=>{for(const{obb:t}of this._tileHandles.values())if(!e(t))break}),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._frameTask.remove(),this._shadows=r(this._shadows),this._renderer=r(this._renderer),this._memCache.destroy(),this.data=r(this.data)}_canProjectWithoutEngine(){if(1===this.view.state.viewingMode)return!0;if(_(this.view.renderSpatialReference)||y(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&w(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){if(115700===this.layer.esriCrsSpatialReference.vcsWkid)return!1;let e=M(this.layer.esriCrsSpatialReference);if(!e){const t=this.layer.esriCrsSpatialReference;let i="meters";!b(t)&&t.wkid&&-1!==t.wkid&&(i=o(v.units[v[t.wkid]])),i&&(e=new m({heightModel:"gravity-related-height",heightUnit:i}))}const t=this.view.heightModelInfo;return this._useEsriCrs=0===g(e,t,!1),this._useEsriCrs&&(e&&(this._metersPerVCSUnit=h(1,e.heightUnit,"meters")),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}_elevationInfoChanged(e){if(e?.offset)if(this._useEsriCrs){const t=T(e?.unit)/this._metersPerVCSUnit,i=e?.offset??0;this._wasm?.setLayerOffset(this,i*t)}else this._wasm?.setLayerOffset(this,x(e));else this._wasm?.setLayerOffset(this,0)}_slicePlaneEnabledChanged(e){this._renderer&&(this._renderer.slicePlaneEnabled=e),this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e)}updateGaussians(){const e=new Array;for(const t of this._tileHandles.values())0!==t.lifecycleState&&e.push(t);this.data.updateGaussianVisibility(e,this._currentLyr3dVisibilityChange),this.notifyChange("updating")}setMaximumGaussianCount(e){const t=Math.min(e,this.data.textureAtlas.maximumSupportedVisibleGaussians);this._wasm?.setMaximumGaussianSplatCount(t)}_freeInvisibleTiles(){for(const e of this._tileHandles.values())0!==e.lifecycleState||this._renderablesBeingCreated.has(e.handle)||this._deleteTile(e)}extractHeader(e){const t=e.length-4,i=this.reinterpretU32AsFloat(e[t]),s=this.reinterpretU32AsFloat(e[t+1]),r=this.reinterpretU32AsFloat(e[t+2]),a=1/(1<<(255&e[t+3]));return{packedHeader:e.subarray(t,t+4),tileOrigin:{x:i,y:s,z:r},invPosScale:a}}_deleteTile(e){this._renderablesBeingCreated.has(e.handle)||this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}reinterpretU32AsFloat(e){return this._u32View[0]=e,this._f32View[0]}get performanceInfo(){let e=0,t=0;this._tileHandles.forEach(i=>{0===i.lifecycleState?t++:e++});const i=this.data?.textureAtlasMemory??0,s=this.data?.headerTextureMemory??0,r=this.data?.orderTextureMemory??0,a=this.data?.fadingTextureMemory??0,n=this.data?.sortBufferMemory??0;return new H(this.usedMemory,e,this._usedTileMemory,t,this._cacheTileMemory,i,s,r,a,n)}get test(){}};e([d()],ie.prototype,"layer",void 0),e([d({readOnly:!0})],ie.prototype,"_clippingBox",null),e([d()],ie.prototype,"elevationOffset",null),e([d({readOnly:!0})],ie.prototype,"visibleAtCurrentScale",null),e([d()],ie.prototype,"fullExtentInLocalViewSpatialReference",void 0),ie=K=e([u("esri.views.3d.layers.GaussianSplatLayerView3D")],ie);const se=ie;export{se as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{abortMaybe as i,removeMaybe as s,destroyMaybe as a}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{watch as n,initial as l}from"../../../core/reactiveUtils.js";import{unitFromRESTJSON as o,convertUnit as h}from"../../../core/units.js";import{property as d,subclass as u}from"../../../core/accessorSupport/decorators.js";import{fromValues as c}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{getReferenceEllipsoid as p}from"../../../geometry/ellipsoidUtils.js";import m from"../../../geometry/HeightModelInfo.js";import{create as f}from"../../../geometry/support/aaBoundingBox.js";import{isCompatible as g}from"../../../geometry/support/heightModelInfoUtils.js";import{isPlateCarree as _,isWebMercator as y,equals as w,isGeographic as b}from"../../../geometry/support/spatialReferenceUtils.js";import v from"../../../geometry/support/WKIDUnitConversion.js";import{validateMeshData as S,makeCacheKey as C,getHeightModelInfoFromVCS as x}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as M}from"../../../support/elevationInfoUtils.js";import{getMetersPerUnit as T}from"../../../symbols/support/unitConversionUtils.js";import{GaussianSplatLayerViewPerformanceInfo as H}from"./GaussianSplatLayerViewPerformanceInfo.js";import{LayerView3D as I}from"./LayerView3D.js";import{addLayerViewToWasm as A,getLyr3DWasm as F,removeLayerViewFromWasm as P}from"./Lyr3DWasm.js";import{LayerElevationProvider as V}from"./i3s/LayerElevationProvider.js";import{ElevationRange as R}from"../support/ElevationRange.js";import{projectToBoundingBox as j}from"../support/extentUtils.js";import{Obb as E}from"../support/orientedBoundingBox.js";import{splatPageSizeInU32 as G,gaussiansPerPage as O,packedGaussianSizeInU32 as U,splatAtlasTextureWidth as D}from"../support/gaussianSplatting/GaussianSplatAtlasPages.js";import{GaussianSplatDataStore as z}from"../support/gaussianSplatting/GaussianSplatDataStore.js";import{GaussianSplatFadeHelper as B}from"../support/gaussianSplatting/GaussianSplatFadeHelper.js";import{GaussianSplatIntersectionHandler as L}from"../support/gaussianSplatting/GaussianSplatIntersectionHandler.js";import{GaussianTile as k}from"../support/gaussianSplatting/GaussianTile.js";import{GaussianSplatRenderer as q}from"../webgl-engine/lib/GaussianSplatRenderer.js";import{GaussianSplatShadows as W}from"../webgl-engine/lib/GaussianSplatShadows.js";import N from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as $,isInEffectiveScaleRange as X}from"../../support/layerViewUtils.js";import{TaskPriority as Z}from"../../support/Scheduler.js";var K;const Y=()=>t.getLogger("esri.views.3d.layers.GaussianSplatLayerView3D"),J=3,Q=J*J,ee=255,te=(()=>{const e=new Int16Array(ee+1);e[0]=-255;for(let t=1;t<e.length;t++)e[t]=Math.round(16*Math.log(t/ee));return e})();let ie=class extends(I(N)){static{K=this}static{this.createRenderableBatchSize=64}constructor(e){super(e),this.type="gaussian-splat-3d",this.ignoresMemoryFactor=!1,this._tileHandles=new Map,this._pageBuffer=new Uint32Array(G),this._tmpTilesWithChangedVisibility=new Array,this._renderablesBeingCreated=new Set,this._currentLyr3dVisibilityChange=0,this._tileFadeInsAwaitingInitialSort=new Map,this._tileFadeOutsAwaitingInitialSort=new Map,this._fadeDurationPerVisibilityChange=new Map,this._tmpSortedTileHandles=new Set,this._createRenderableAbortController=new AbortController,this._initializationController=null,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this._usedTileMemory=0,this._cacheTileMemory=0,this._useEsriCrs=!1,this.fullExtentInLocalViewSpatialReference=null,this._suspendedHandle=null,this._conversionBuffer=new ArrayBuffer(4),this._u32View=new Uint32Array(this._conversionBuffer),this._f32View=new Float32Array(this._conversionBuffer);const t=e.view.resourceController;this._memCache=t.memoryController.newCache(`GaussianSplat-${this.uid}`,e=>this._deleteTile(e)),this._frameTask=t.scheduler.registerTask(Z.GAUSSIAN_SPLAT_TEXTURE_ATLAS)}get _clippingBox(){if(!this.view?.clippingArea)return null;const e=f();return j(this.view.clippingArea,e,this.view.renderSpatialReference)?e:null}get clippingBox(){return this._renderer?.clippingBox??null}initialize(){if(!this._canProjectWithoutEngine())throw $("layer",this.layer.spatialReference.wkid,this.view.renderSpatialReference?.wkid);this._initializationController=new AbortController;const e=A(this,this._initializationController.signal).then(e=>{r(this._initializationController.signal),this._wasmLayerId=e,this._renderer=new q({view:this.view,layerView:this}),this.data=new z(this._renderer,(e,t)=>this._onSortComplete(e,t),()=>this._freeInvisibleTiles()),this._shadows=new W({view:this.view,layerView:this}),this.fadeHelper=new B(this),this._intersectionHandler=new L(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._elevationProvider=new V({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this.view.elevationProvider.register(2,this._elevationProvider),this.addHandles([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),n(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChanged(e),l)]),this._suspendedHandle=n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),l),this.addHandles([n(()=>this._clippingBox,e=>{this._renderer&&(this._renderer.clippingBox=e)},l)]),this.setMaximumGaussianCount(this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians),this._initializationController=null});this.addHandles([n(()=>this.view.qualitySettings.fadeDuration,e=>{this.data&&(this.fadeHelper.onFadeDurationChanged(e),this.updateFadingTexture())}),n(()=>this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians,e=>this.setMaximumGaussianCount(e*this.view.quality)),n(()=>this.view.quality,e=>this.setMaximumGaussianCount(this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians*e))]),this.addResolvingPromise(e)}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get tileHandles(){return this._tileHandles}updateFadingTexture(){this.data.fadingTexture.updateTexture(this.data.textureAtlas.pageAllocator.pageCount)}get _wasm(){return F(this.view)}get usedMemory(){return this._usedTileMemory+(this.data?.usedMemory??0)}get cachedMemory(){return this._cacheTileMemory}get unloadedMemory(){return 0}get useEsriCrs(){return this._useEsriCrs}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return M(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new R(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get fullExtent(){return this.layer.fullExtent}get visibleAtCurrentScale(){return X(this.layer.effectiveScaleRange,this.view.scale)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&(e.isUpdating(this._wasmLayerId)||this.data.updating||this.fadeHelper.updating)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed||this.destroying)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy");const{meshData:t}=e;if(!S(t))throw new Error("meshData not valid");const i=t.desc.prims[0],s=i.vertexCount;if(0===s)return Y().warnOnce("encountered tile with zero Gaussians"),()=>({memUsageBytes:0,numGaussians:0});const a=i.atrbs[0].view,r=i.atrbs[0].view.byteCount,n=i.atrbs[0].view.byteOffset;let l=null;if("U32"!==a.type)throw new Error("unexpected meshData.data format");l=new Uint32Array(t.data.buffer,n,r/4);const o=this.extractHeader(l),h=2.048,d=o.tileOrigin.x*h,u=o.tileOrigin.y*h,m=o.tileOrigin.z*h,f=t.desc;if(null==f.obb)throw new Error("meshData.desc.obb undefined");const g=f.obb.quaternion,_=new E(f.obb.center,f.obb.halfSize,c(...g)),y=this.view.state.isGlobal,w=y?p(this.view.spatialReference).radius:0,b={handle:e.handle,bufferView:l,totalGaussians:s,packedHeader:o.packedHeader,tileOrigin:{x:d,y:u,z:m},invPosScale:o.invPosScale,obb:_,origin:{x:_.centerX,y:_.centerY,z:_.centerZ},isGlobal:y,ellipsoidRadius:w};let v;this._renderablesBeingCreated.add(e.handle);try{v=await this._frameTask.scheduleGenerator(e=>this._createRenderableTask(b,e),this._createRenderableAbortController.signal)}catch(C){throw this._renderablesBeingCreated.delete(e.handle),C}return this._renderablesBeingCreated.delete(e.handle),()=>v}*_createRenderableTask(e,t){const{handle:i,bufferView:s,totalGaussians:a,packedHeader:r,tileOrigin:n,invPosScale:l,obb:o,origin:h,isGlobal:d,ellipsoidRadius:u}=e,c=n.x,p=n.y,m=n.z,f=h.x,g=h.y,_=h.z,y=new Uint32Array(a),w=new Float32Array(3*a),b=new Uint32Array(a),v=new Uint32Array(a),S=new Array,C=Math.ceil(a/O);let x=1/0,M=-1/0,T=1/0,H=-1/0,I=0,A=-1,F=0,P=0;for(let R=0;R<a;R++){const e=R*U,i=s[e],a=s[e+1],r=s[e+2],n=s[e+3],o=16383&a,h=a>>>14&16383,u=a>>>28&15|(1023&r)<<4,y=n>>>24,S=te[y],C=(r>>>10&255)+S,V=(r>>>18&255)+S,j=(r>>>26&63|(3&n)<<6)+S,E=C>0?C:0,G=V>0?V:0,O=j>0?j:0,D=E|G<<8|O<<16,z=Math.max(E,G,O),B=o*l+c,L=h*l+p,k=u*l+m;if(w[I]=B-f,w[I+1]=L-g,w[I+2]=k-_,d){const e=B*B+L*L+k*k;T=Math.min(T,e),H=Math.max(H,e)}else x=Math.min(x,k),M=Math.max(M,k);b[R]=i,v[R]=D,z>A&&(A=z),y>F&&(F=y),I+=3,P++,P===K.createRenderableBatchSize&&(P=0,t.madeProgress()&&(t=yield))}P>0&&t.madeProgress(),d&&(x=Math.sqrt(T)-u,M=Math.sqrt(H)-u);const V=this._extractGaussianSplatMbsRadiusSquared(A),{fullExtent:j}=this.layer;j?.hasZ&&j.zmax&&j.zmin&&(x=Math.max(x,j.zmin),M=Math.min(M,j.zmax));const E=new R(x,M);try{for(let e=0;e<C;e++){let t=this.data.textureAtlas.allocatePage();if(null===t&&(this._freeInvisibleTiles(),t=this.data.textureAtlas.allocatePage()),null===t)throw new Error("ran out of gaussian splat memory");S.push(t);const i=a-e*O,n=Math.min(i,O),l=e*O,o=t*O;for(let e=0;e<n;e++)y[l+e]=o+e;const h=e*G,d=n*U;this._pageBuffer.set(s.subarray(h,h+d));const u=o%D,c=Math.floor(o/D);this.data.textureAtlas.update(u,c,this._pageBuffer),this.data.headerTexture.update(t,r)}}catch(B){throw this.data.textureAtlas.freePages(S),B}const z=new k(i,o,y,S,w,b,v,a,V,F/ee,E);return this._tileHandles.set(i,z),this._cacheTileMemory+=z.usedMemory,this._memCache.put(`${z.handle}`,z),{memUsageBytes:z.usedMemory,numGaussians:a}}_extractGaussianSplatMbsRadiusSquared(e){return Math.exp(e/8-20)*Q}freeRenderable(e){this._tileFadeInsAwaitingInitialSort.delete(e),this._tileFadeOutsAwaitingInitialSort.delete(e);const t=this.data?.textureAtlas;let i=!1;const s=this._tileHandles.get(e);if(s){0!==s.lifecycleState?(i=!0,this.fadeHelper.onTileDiscarded(s),this._usedTileMemory-=s.usedMemory,this._intersectionHandler.removeTile(s)):this._cacheTileMemory-=s.usedMemory,t&&s.pageIds.forEach(e=>t.freePage(e)),this.freeObject(s),this._tileHandles.delete(e)}i&&this.updateGaussians()}freeObject(e){this._memCache.pop(`${e.handle}`)}notifyTileObbsChanged(e){this._elevationProvider&&this._elevationProvider.notifyObjectsChangedFunctional(e.length,t=>{for(const{obb:i}of e)if(!t(i))break})}setRenderableVisibility(e,t,i){const s=this._currentLyr3dVisibilityChange+1,a=this.fadeHelper.updateFadeDuration();this._fadeDurationPerVisibilityChange.set(s,a);let r=!1;for(let n=0;n<i;n++){const i=this._tileHandles.get(e[n]);if(!i)continue;const l=t[n]?this._prepareTileFadeIn(i,s,a):this._prepareTileFadeOut(i,s);r||=l}r?(this._currentLyr3dVisibilityChange=s,this.updateGaussians()):this._fadeDurationPerVisibilityChange.delete(s)}_prepareTileFadeIn(e,t,i){const s=this._tileFadeOutsAwaitingInitialSort.delete(e.handle);return 2===e.lifecycleState?(this.fadeHelper.fadeTile(e,0,i),!1):this._tileFadeInsAwaitingInitialSort.get(e.handle)!==t?(0===e.lifecycleState&&this._popTileFromCache(e),e.lifecycleState=1,this._tileFadeInsAwaitingInitialSort.set(e.handle,t),!0):s}_prepareTileFadeOut(e,t){const i=this._tileFadeInsAwaitingInitialSort.delete(e.handle);return i&&1===e.lifecycleState&&(this.moveTileToCache(e),e.lifecycleState=0),2!==e.lifecycleState?i:this._tileFadeOutsAwaitingInitialSort.get(e.handle)!==t?(this._tileFadeOutsAwaitingInitialSort.set(e.handle,t),!0):i}_onSortComplete(e,t){const i=this._tmpTilesWithChangedVisibility;i.length=0;const s=this._tmpSortedTileHandles;s.clear();for(let r=0;r<e.length;r++){const t=e[r];s.add(t.handle)}this._triggerFadeIns(t,s,i);const a=this._triggerFadeOuts(t,i);s.clear(),i.length>0&&this.notifyTileObbsChanged(i),a&&this.updateGaussians(),this._cleanupVisibilityChangeFadeDurations(t)}_triggerFadeIns(e,t,i){for(const[s,a]of this._tileFadeInsAwaitingInitialSort){if(a>e||!t.has(s))continue;const r=this._tileHandles.get(s);if(!r){this._tileFadeInsAwaitingInitialSort.delete(s);continue}const n=this._getFadeDurationForPendingVisibilityChange(a),l=0===r.lifecycleState;2!==r.lifecycleState&&(r.lifecycleState=2,l&&this._popTileFromCache(r),i.push(r)),this.fadeHelper.fadeTile(r,0,n),this._tileFadeInsAwaitingInitialSort.delete(s)}}_triggerFadeOuts(e,t){let i=!1;for(const[s,a]of this._tileFadeOutsAwaitingInitialSort){if(a>e)continue;const r=this._tileHandles.get(s);if(r){const e=2===r.lifecycleState,s=this._getFadeDurationForPendingVisibilityChange(a);this.fadeHelper.fadeTile(r,1,s),e&&0===r.lifecycleState&&(t.push(r),i=!0)}this._tileFadeOutsAwaitingInitialSort.delete(s)}return i}_getFadeDurationForPendingVisibilityChange(e){return this._fadeDurationPerVisibilityChange.get(e)??this.fadeHelper.baseFadeDuration}_cleanupVisibilityChangeFadeDurations(e){if(0!==this._fadeDurationPerVisibilityChange.size)for(const t of this._fadeDurationPerVisibilityChange.keys())t<=e&&this._fadeDurationPerVisibilityChange.delete(t)}_popTileFromCache(e){this._usedTileMemory+=e.usedMemory,this._cacheTileMemory-=e.usedMemory,this._intersectionHandler.addTile(e),this._memCache.pop(C(e.handle))}moveTileToCache(e){this._usedTileMemory-=e.usedMemory,this._cacheTileMemory+=e.usedMemory,this._intersectionHandler.removeTile(e),this._memCache.put(C(e.handle),e)}destroy(){this._initializationController=i(this._initializationController),this._createRenderableAbortController.abort(),P(this),this._suspendedHandle&&(this._suspendedHandle=s(this._suspendedHandle)),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&this.view.elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(this._tileHandles.size,e=>{for(const{obb:t}of this._tileHandles.values())if(!e(t))break}),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._frameTask.remove(),this._shadows=a(this._shadows),this._renderer=a(this._renderer),this._memCache.destroy(),this.data=a(this.data)}_canProjectWithoutEngine(){if(1===this.view.state.viewingMode)return!0;if(_(this.view.renderSpatialReference)||y(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&w(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){if(115700===this.layer.esriCrsSpatialReference.vcsWkid)return!1;let e=x(this.layer.esriCrsSpatialReference);if(!e){const t=this.layer.esriCrsSpatialReference;let i="meters";!b(t)&&t.wkid&&-1!==t.wkid&&(i=o(v.units[v[t.wkid]])),i&&(e=new m({heightModel:"gravity-related-height",heightUnit:i}))}const t=this.view.heightModelInfo;return this._useEsriCrs=0===g(e,t,!1),this._useEsriCrs&&(e&&(this._metersPerVCSUnit=h(1,e.heightUnit,"meters")),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}_elevationInfoChanged(e){if(e?.offset)if(this._useEsriCrs){const t=T(e?.unit)/this._metersPerVCSUnit,i=e?.offset??0;this._wasm?.setLayerOffset(this,i*t)}else this._wasm?.setLayerOffset(this,M(e));else this._wasm?.setLayerOffset(this,0)}_slicePlaneEnabledChanged(e){this._renderer&&(this._renderer.slicePlaneEnabled=e),this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e)}updateGaussians(){const e=new Array;for(const t of this._tileHandles.values())0!==t.lifecycleState&&e.push(t);this.data.updateGaussianVisibility(e,this._currentLyr3dVisibilityChange),this.notifyChange("updating")}setMaximumGaussianCount(e){const t=Math.min(e,this.data.textureAtlas.maximumSupportedVisibleGaussians);this._wasm?.setMaximumGaussianSplatCount(t)}_freeInvisibleTiles(){for(const e of this._tileHandles.values())0!==e.lifecycleState||this._renderablesBeingCreated.has(e.handle)||this._deleteTile(e)}extractHeader(e){const t=e.length-4,i=this.reinterpretU32AsFloat(e[t]),s=this.reinterpretU32AsFloat(e[t+1]),a=this.reinterpretU32AsFloat(e[t+2]),r=1/(1<<(255&e[t+3]));return{packedHeader:e.subarray(t,t+4),tileOrigin:{x:i,y:s,z:a},invPosScale:r}}_deleteTile(e){this._renderablesBeingCreated.has(e.handle)||this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}reinterpretU32AsFloat(e){return this._u32View[0]=e,this._f32View[0]}get performanceInfo(){let e=0,t=0;this._tileHandles.forEach(i=>{0===i.lifecycleState?t++:e++});const i=this.data?.textureAtlasMemory??0,s=this.data?.headerTextureMemory??0,a=this.data?.orderTextureMemory??0,r=this.data?.fadingTextureMemory??0,n=this.data?.sortBufferMemory??0;return new H(this.usedMemory,e,this._usedTileMemory,t,this._cacheTileMemory,i,s,a,r,n)}get test(){}};e([d()],ie.prototype,"layer",void 0),e([d({readOnly:!0})],ie.prototype,"_clippingBox",null),e([d()],ie.prototype,"elevationOffset",null),e([d({readOnly:!0})],ie.prototype,"visibleAtCurrentScale",null),e([d()],ie.prototype,"fullExtentInLocalViewSpatialReference",void 0),ie=K=e([u("esri.views.3d.layers.GaussianSplatLayerView3D")],ie);const se=ie;export{se as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{abortMaybe as i,destroyMaybe as r,removeMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as o,createAbortError as n}from"../../../core/promiseUtils.js";import{initial as a,watch as l,when as c}from"../../../core/reactiveUtils.js";import{schedule as h}from"../../../core/scheduling.js";import{unitFromRESTJSON as d,convertUnit as u}from"../../../core/units.js";import{property as m,subclass as p}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as f,invert as b}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as y,IDENTITY as g}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as _}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as v}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as w,sub as C,dot as x,set as T}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as j,freeze as E,clone as R,ZEROS as M,fromValues as O}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as S,clone as V,ONES as U}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMoon as H,isMars as D,getReferenceEllipsoid as P,SphericalECEFSpatialReferenceLike as I}from"../../../geometry/ellipsoidUtils.js";import k from"../../../geometry/HeightModelInfo.js";import{computeTranslationToOriginAndRotation as L}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as A}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as F}from"../../../geometry/projection/projectVectorToVector.js";import{create as G}from"../../../geometry/support/aaBoundingRect.js";import{isCompatible as z}from"../../../geometry/support/heightModelInfoUtils.js";import{isPlateCarree as B,isWebMercator as N,equals as W,isGeographic as q,isCGCS2000 as X}from"../../../geometry/support/spatialReferenceUtils.js";import $ from"../../../geometry/support/WKIDUnitConversion.js";import{BufferViewVec4f as Z,BufferViewVec4u8 as Y,BufferViewVec4u16 as J,BufferViewVec3f as K,BufferViewVec3u8 as Q,BufferViewVec3u16 as ee,BufferViewVec2f as te,BufferViewUint32 as ie,BufferViewUint16 as re}from"../../../geometry/support/buffer/BufferView.js";import se from"../../../layers/support/SceneModification.js";import{getHeightModelInfoFromVCS as oe,validateMeshData as ne,makeCacheKey as ae}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as le}from"../../../support/elevationInfoUtils.js";import{IntegratedMesh3DTilesLayerWorkerHandle as ce}from"./IntegratedMesh3DTilesLayerWorkerHandle.js";import{LayerView3D as he}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as de}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as ue,removeLayerViewFromWasm as me,getLyr3DWasm as pe}from"./Lyr3DWasm.js";import{toWasmModification as fe}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as be}from"./i3s/LayerElevationProvider.js";import{IntegratedMesh3DTilesLayerView3DSymbol as ye}from"./support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{primTypeConversion as ge,alphaModeConversion as _e,faceCullingConversion as ve,wrapModeConversion as we}from"./support/lyr3dTypeConversions.js";import{makeScheduleFunction as Ce}from"./support/makeScheduleFunction.js";import{Tiles3DMeshIntersectionHandler as xe}from"./support/Tiles3DMeshIntersectionHandler.js";import{Frustum as Te}from"../state/Frustum.js";import{ElevationRange as je}from"../support/ElevationRange.js";import{toBoundingRect as Ee}from"../support/extentUtils.js";import{Obb as Re}from"../support/orientedBoundingBox.js";import{glLayout as Me}from"../support/buffer/glUtil.js";import{ComponentGeometryParameters as Oe,SourceGeometry as Se}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as Ve}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Ue}from"../webgl-engine/core/material/RenderTexture.js";import{ManagedTexture as He}from"../webgl-engine/lib/ManagedTexture.js";import{compressNormals as De}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as Pe}from"../webgl-engine/materials/pbrUtils.js";import Ie from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as ke,isInEffectiveScaleRange as Le,validateScaleRange as Ae}from"../../support/layerViewUtils.js";import{TaskPriority as Fe}from"../../support/Scheduler.js";import{TextureCompressionTracker as Ge}from"../../support/TextureCompressionTracker.js";import{CompressedTextureFormat as ze,SizedPixelFormat as Be}from"../../webgl/enums.js";import{alphaCutoff as Ne}from"../../../webscene/support/AlphaCutoff.js";var We;function qe(e,t,i){if("image/vnd-ms.dds"===t)switch(i){case"Dxt1":return ze.COMPRESSED_RGB_S3TC_DXT1_EXT;case"Dxt5":return ze.COMPRESSED_RGBA_S3TC_DXT5_EXT;default:return null}if("image/ktx2"===t)return null;switch(e){case 33319:return Be.RG8;case 6407:return Be.RGB8;case 6408:return Be.RGBA8;case 6403:return Be.R8;default:return null}}let Xe=class extends(he(Ie)){static{We=ye}constructor(e){super(e),this[We]=!0,this.type="integrated-mesh-3dtiles",this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._initializationController=null,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this._useEsriCrs=!1,this.drapeTargetType=1,this.fullExtentInLocalViewSpatialReference=null,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 Ge,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(Fe.TILES3D,this),this._frustum=new Te(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{o(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._workerHandle=new ce(Ce(e.resourceController)),this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),a),!this._canProjectWithoutEngine())throw ke("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);this._initializationController=new AbortController;const t=ue(this,this._initializationController.signal).then(t=>{o(this._initializationController.signal),this._wasmLayerId=t,this._intersectionHandler=new xe(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(),a),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),a),this._elevationProvider=new be({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([l(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),c(()=>this.fullOpacity,()=>this._opacityChange()),l(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),a)]),this._initializationController=null,this.addHandles(c(()=>this._replacesTerrain&&this._wasm?.isTerrainReady,()=>{this.layer.queryElevationCallback=(e,t)=>this._queryElevation(e,t)}))});this.addResolvingPromise(t)}destroy(){if(this._initializationController=i(this._initializationController),this._dbg(2,"Tiles3DLayerView3D destroy() called"),this._workerHandle?.destroyContextAndSelf(this.uid),me(this),this.layer.queryElevationCallback=null,this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler.destroy(),this._intersectionHandler=null),this._elevationProvider){const e=Array.from(this._lyrHandleToObjects.values()),t=e.reduce((e,{componentObjects:t})=>e+t.length,0);this._elevationProvider.notifyObjectsChangedFunctional(t,t=>{for(const{componentObjects:i}of e)for(const{obb:e}of i)if(!t(e))return}),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=r(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(r=>{const s=r.obb?.intersectsFrustum(e)??!1;s!==r.isVisible&&(r.isVisible=s,s?t.add(r):t.delete(r),r.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,s)),i||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(s,r.elevationRange))}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,r){this._intersectionHandler.intersectRay(e,t,i,r,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}_modificationsChanged(){const e=this.useEsriCrs?this.layer.supportedSpatialReferences[1]:this.layer.supportedSpatialReferences[0],t=fe(this._layerClippingArea,this._modifications,e,this.view.state.isGlobal);this._wasm?.setMeshModifications(this,t)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=G();this._layerClippingArea=Ee(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=h(()=>{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,le(e))}get _wasm(){return pe(this.view)}_queryElevation(e,t){return this.destroying||this.destroyed?Promise.reject(n()):this._wasm?.queryElevation(this,e,t)??Promise.reject(n())}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get useEsriCrs(){return this._useEsriCrs}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||Le(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||Ae(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,r=0,s=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isLoaded?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,s++):(i+=n.textureMemoryUsage,r+=n.vboMemoryUsage,o++)}),new de(this.usedMemory,s,o,Ye(t),Ye(e),Ye(r),Ye(i))}_canProjectWithoutEngine(){if(1===this.view.state.viewingMode)return!0;if(B(this.view.renderSpatialReference)||N(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&W(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){if(115700===this.layer.esriCrsSpatialReference.vcsWkid)return!1;let e=oe(this.layer.esriCrsSpatialReference);if(!e){const t=this.layer.esriCrsSpatialReference;let i="meters";!q(t)&&t.wkid&&-1!==t.wkid&&(i=d($.units[$[t.wkid]])),i&&(e=new k({heightModel:"gravity-related-height",heightUnit:i}))}const t=this.view.heightModelInfo;return this._useEsriCrs=0===z(e,t,!1),this._useEsriCrs&&(e&&(this._metersPerVCSUnit=u(1,e.heightUnit,"meters")),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return le(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new je(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new je;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,r=i.isWGS84||i.isWebMercator||X(i)||H(i)||D(i);if(this.view.state.isGlobal||!r)return this.forEachVisibleTile(e);const s=P(i).radius,{eye:o,viewForward:n,near:a}=t.state.contentCamera,l=w(j(),n),c=500,h=Math.max(o[2],c),d=h+s,u=Math.sqrt(d**2-s**2),m=Math.abs(Math.atan2(u,s))*s,p=h>.5*s?.5*Math.PI*s:m,f=j();this.forEachVisibleTile(t=>{const{mbsRadius:i,mbsCenter:r}=t;if(i<0)return;C(f,r,o);const s=x(f,l);Math.abs(s)<p&&s+i>a&&s-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)}get readyToRun(){return!!this._frameTask?.readyToRun}runTask(e){this._frameTask.processQueue(e)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed||this.destroying)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy");const{meshData:t}=e;if(!ne(t))throw new Error("meshData not valid");const i=new Map;let r;try{r=this._createPrimitiveTextureBundles(t,i)}catch(o){throw i.forEach(e=>this._stage?.removeTexture(e)),o}let s=null;try{if(s=await this._createRenderableMain(t,r),this.destroyed)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable aborted due to destroyed instance");const{tileObb:o,componentObjects:n,elevationRange:a}=s;let l=0,c=0,h=0;for(const e of n){const{texture:t,textureMetallicRoughness:i,textureEmissive:r,textureOcclusion:s,textureNormal:o}=e.renderable.drawParameters;l+=(t?.usedMemory??0)+(i?.usedMemory??0)+(r?.usedMemory??0)+(s?.usedMemory??0)+(o?.usedMemory??0),c+=this._collection.getObjectGPUMemoryUsage(e),h+=e.intersectionGeometry.usedMemory}const d=Array.from(i.values()),u=new Ze(e.handle,n,d,h,c,l,o,e.stableNodeId,e.nodeDepth,a);return this._lyrHandleToObjects.set(e.handle,u),()=>{this._memCache.put(ae(u.handle),u);const{usedMemory:e}=u;return this._cacheMemory+=e,{memUsageBytes:e}}}catch(o){throw r.forEach(e=>e.cleanup()),s?.componentObjects.forEach(e=>this._collection.destroyObject(e)),i.forEach(e=>this._stage?.removeTexture(e)),o}}_createPrimitiveTextureBundles(e,t){const i=new Array,r=e.desc.prims.length;try{const s=e.desc;for(let o=0;o<r;o++){const r=s.prims[o].materialId,n=s.materials&&null!=r?s.materials[r]:null;let a=Promise.resolve(Ke),l=null,c=null,h=null,d=null,u=null;if(n){const i="Pbr"===n.lightingModel;l=this._getTexture(n.baseColorTex,e,t),c=i?this._getTexture(n.metalTex,e,t):null,h=i?this._getTexture(n.emissiveTex,e,t):null,d=i?this._getTexture(n.occlusionTex,e,t):null,u=i?this._getTexture(n.normalTex,e,t):null;const r=[l,c,h,d,u].map(e=>e?.loadPromise??null);a=Promise.all(r)}i.push(new Qe(a,l,c,h,d,u))}}catch(s){throw i.forEach(e=>e.cleanup()),s}return i}async _createRenderableMain(e,t){if(this.destroyed||this.destroying)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderableMain called after destroy");const i=new Array,r=e.desc,s=e.data.buffer,o=r.prims.length,n=E(...r.origin),a=this.view.basemapTerrain.spatialReference,l=this.view.state.isGlobal;let c=g;if(l){const e=_();L(I,n,e,a),c=f(y(),e)}if(null==r.obb)throw new Error("meshData.desc.obb undefined");const h=Je(r.obb),d=l?P(this.view.spatialReference).radius:0,u=new Array;try{for(let i=0;i<o;i++){const e=r.prims[i],o=t[i];this._dbgFlags.has(2)&&this._dbg(2,JSON.stringify(e));if(null==ge[e.ptype]){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+e.ptype+"). Skipping primitive."),o.cleanup();continue}const{positionView:n,normalsData:a,colorView:l,texCoord0Data:c,indicesView:h}=this.getBufferViews(e,s);if(null==n||null==h){o.cleanup();continue}const d=n.count,m=(e,t)=>null==e||e===d||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);m(null!=c?c.length/2:void 0,"numTexcoord")&&m(l?.count,"numColors")&&m(a?.length,"normals")?u.push({componentIndex:i,positionView:n,indicesView:h,texCoord0Data:c,colorView:l,normalsData:a}):o.cleanup()}const e=c!==g,m=e?b(y(),c)??g:g,{vertexProcessingOutputs:p,obbHalfSizeAccumulator:f,elevationRange:_}=await this._workerHandle.processTiles3DVertices(u,n,d,l,c,h,this._imVertexNormals&&!this._isUsedAsGroundLayer);if(this.destroyed)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance");const v=r.materials;if(await Promise.all(t.map(e=>e.materialPromise)),this.destroyed)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance");p.length>0&&h.setHalfSize(f);for(const s of p){const{componentIndex:o,positionView:l,indicesView:c,layout:d,textureCoordinateType:u,interleavedVertexData:p,indices:f}=s,b=r.prims[o],y=t[o],g=h.clone(),_=Me(d),w=new Uint32Array([0,c.typedBuffer.length]),C=new Oe(_,this._imShading?2:0,u,e?2:0),x=new Se({interleavedVertexData:p,vertexCount:p.byteLength/_[0].stride,indexData:f},{positions:l.typedBuffer,indices:c.typedBuffer},w,C),T=this.view.renderSpatialReference,E=j(),R=[1,1,1];A(n,T,R,a)||this._dbg(3,"Unsupported coordinate system for IM overlay"),F(n,T,E,a);const M=v&&null!=b.materialId?v[b.materialId]:null,O=this._createComponentMaterialInitParameters(M,y);O.baseColorTexture||this._dbg(3,"No colour texture 1");const V=this._collection.createObject({toMapSpace:S(E[0],E[1],R[0],R[1]),transform:new Ve(n,m),obb:g,geometry:x,elevationAlignable:!1},O);i.push(V)}const{fullExtent:w}=this.layer;return w?.hasZ&&w.zmax&&w.zmin&&(_.minElevation=Math.max(_.minElevation,w.zmin),_.maxElevation=Math.min(_.maxElevation,w.zmax)),{tileObb:h,componentObjects:i,elevationRange:_}}catch(m){throw i.forEach(e=>this._collection.destroyObject(e)),m}}_createComponentMaterialInitParameters(e,t){const i="Pbr"===(null!=e?e.lightingModel:"Unlit");let r=U,s=Ne,o=1,n=!1,a=2,l=O(0,0,0);const c=R(Pe),h=t.baseColorTexture,d=t.metallicRoughnessTexture,u=t.emissionTexture,m=t.occlusionTexture,p=t.normalTexture;return e&&(r=V(e.baseColorFactor),s=e.alphaCutoff??Ne,i&&(T(c,e.metallicFactor,e.roughnessFactor,0),e.emissiveFactor&&(l=e.emissiveFactor)),o=_e[e.alphaMode],n=e.isDoubleSided,a=ve[e.faceCulling??"NotSet"]),{isIntegratedMesh:!0,baseColor:r,textureAlphaCutoff:s,mrrFactors:c,baseColorTexture:h,metallicRoughnessTexture:d,normalTexture:p,occlusionTexture:m,emissionTexture:u,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:o,doubleSided:n,cullFace:a,isGround:this.layer.replacesTerrain,emissiveBaseColor:l,usePBR:i,slicePlaneEnabled:this.slicePlaneEnabled,opacity:this.fullOpacity,polygonOffset:0,ellipsoidMode:1,applySSAO:this._applySSAO}}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=ae(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 r=this._frustum,s=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(r)??!0;l.isVisible=e,e&&(this._visibleObjects.add(l),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,l.elevationRange)),s.push(l.obb),l.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(ae(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 r=this._lyrHandleToObjects.get(i);if(r){if(!r.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${r.stableNodeId}`);continue}const e=r.isVisible;this._visibleObjects.delete(r),r.isVisible=!1,r.isLoaded=!1,this._loadedObjects.delete(r),this._intersectionHandler.removeTile(r),e&&(this._visibleGeometryChanged(),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,r.elevationRange)),this._usedMemory-=r.usedMemory,this._cacheMemory+=r.usedMemory,s.push(r.obb),r.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(ae(i),r)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),s.length>0&&this._elevationProvider.notifyObjectsChanged(s),n&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){const{visibleElevationRange:i}=this,{minElevation:r,maxElevation:s}=t;return e?r<i.minElevation||s>i.maxElevation:r===i.minElevation||s===i.maxElevation}_getTexture(e,t,i){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const s=i.get(r)??this._createTexture(e,t,i);return s?new Ue(this._stage.renderView.textures,s.id):null}_createTexture(e,t,i){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const s=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,o=!!r.mipCount||s>1,n=we[e.wrapMode??"None"];let a=r.alpha?6408:6407;const l=new Uint8Array(t.data.buffer,r.data.byteOffset,r.data.byteCount);let c=null,h=null,d=null;switch(r.format){case"Raw":"R8"===r.pixelFormat?(c=l,a=6403,h=""):"Rg8"===r.pixelFormat||"Ga8"===r.pixelFormat?(c=l,a=33319,h=""):"Rgb8"===r.pixelFormat?(c=l,a=6407,h=""):"Rgba8"===r.pixelFormat&&(c=l,a=6408,h="");break;case"Dxt1":c=l,a=6407,h="image/vnd-ms.dds";break;case"Dxt5":c=l,a=6408,h="image/vnd-ms.dds";break;case"Basis":c=l,a=6407,h="image/ktx2";break;case"Png":h="image/png",d=document.createElement("img");break;case"Jpeg":h="image/jpeg",d=document.createElement("img");break;case"Etc2":h="image/ktx",d=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(d&&h){const e=new Blob([l],{type:h});d.src=URL.createObjectURL(e),c=d}if(c&&null!=h){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker}:void 0,t=qe(a,h,r.format),l=new He(c,{mipmap:o,maxAnisotropy:s,encoding:h,wrap:n,pixelFormat:a,internalFormat:t??void 0,immutable:null!=t,compressionOptions:e,noUnpackFlip:!0,width:r.mip0Width,height:r.mip0Height});return this._stage.addTexture(l),i.set(r,l),l}return null}getBufferViews(e,t){let i,r,s,o,n;for(let l=0;l<e.atrbs.length;l++){const n=e.atrbs[l],{view:c}=n,h=void 0,d=c.byteOffset+c.byteCount;try{switch(n.sem){case"Position":3!==c.ncomp||"F32"!==c.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+c+")"):i=new K(t,c.byteOffset,h,d);break;case"Normal":if(3!==c.ncomp||"F32"!==c.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+c+")");else{const e=new K(t,c.byteOffset,h,d);o=new Uint32Array(e.count),De(e.typedBuffer,new Int16Array(o.buffer,o.byteOffset,2*o.length))}break;case"TexCoord":2!==c.ncomp||"F32"!==c.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+c+")"):void 0===s&&(s=new te(t,c.byteOffset,h,d).typedBuffer);break;case"Color":4===c.ncomp?("F32"===c.type&&(r=new Z(t,c.byteOffset,h,d)),"U8"===c.type&&(r=new Y(t,c.byteOffset,h,d)),"U16"===c.type&&(r=new J(t,c.byteOffset,h,d))):3===c.ncomp&&("F32"===c.type&&(r=new K(t,c.byteOffset,h,d)),"U8"===c.type&&(r=new Q(t,c.byteOffset,h,d)),"U16"===c.type&&(r=new ee(t,c.byteOffset,h,d))),null==r&&this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+c+")");break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+n.sem+"). Skipping vertex attribute.")}}catch(a){this._dbg(2,"Error Creating buffer ("+a+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,r=void 0,s=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":n=new re(t,i.byteOffset,r,s);break;case"U32":n=new ie(t,i.byteOffset,r,s);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==n&&null!=i){const e=i.count;n=n=e<65535?new re(new Uint16Array(e).buffer):new ie(new Uint32Array(e).buffer);for(let t=0;t<e;t++)n.set(t,t)}return{positionView:i,colorView:r,texCoord0Data:s,indicesView:n,normalsData:o}}_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.")},a),"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([m()],Xe.prototype,"fullOpacity",null),e([m({readOnly:!0})],Xe.prototype,"ready",null),e([m({type:[se]})],Xe.prototype,"_modifications",void 0),e([m()],Xe.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([m()],Xe.prototype,"layer",void 0),e([m({readOnly:!0})],Xe.prototype,"visibleAtCurrentScale",null),e([m({readOnly:!0})],Xe.prototype,"_collection",null),e([m()],Xe.prototype,"elevationOffset",null),e([m({readOnly:!0})],Xe.prototype,"visibleElevationRange",null),e([m()],Xe.prototype,"fullExtentInLocalViewSpatialReference",void 0),Xe=e([p("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Xe);const $e=Xe;class Ze{constructor(e,t,i,r,s,o,n,a,l,c){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=r,this.vboMemoryUsage=s,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 h=j();n?.getCenter(h),this._obbCenterX=h[0],this._obbCenterY=h[1],this._obbCenterZ=h[2];const d=n?.radius??-1;this._obbRadius=d,this._obbRadiusSquared=d*d,this._obbShortestHalfsize=n?Math.min(n.halfSizeX,n.halfSizeY,n.halfSizeZ):0,this._mbsCenter=n?n.getCenter(j()):M}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:r,_obbCenterZ:s}=this,o=i-e[0],n=r-e[1],a=s-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,r=e.radius,s=t+r,o=this._obbCenterX-i[0];if(o>s)return!1;const n=this._obbCenterY-i[1];if(n>s)return!1;const a=this._obbCenterZ-i[2];if(a>s)return!1;const l=o*o+n*n+a*a;if(l>s*s)return!1;if(l<=(this._obbShortestHalfsize+r)**2)return!0;const c=r-t;return c>0&&l<=c*c||(this.obb?.intersectSphere(e)??!0)}}function Ye(e){return Math.round(e/1048.576)/1e3}function Je(e){return new Re(e.center,e.halfSize,v(...e.quaternion))}const Ke=new Array;class Qe{constructor(e,t,i,r,s,o){this.materialPromise=e,this.baseColorTexture=t,this.metallicRoughnessTexture=i,this.emissionTexture=r,this.occlusionTexture=s,this.normalTexture=o}cleanup(){this.baseColorTexture?.dispose(),this.metallicRoughnessTexture?.dispose(),this.emissionTexture?.dispose(),this.occlusionTexture?.dispose(),this.normalTexture?.dispose()}}export{$e as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{abortMaybe as i,destroyMaybe as r,removeMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as o,createAbortError as n}from"../../../core/promiseUtils.js";import{initial as a,watch as l,when as c}from"../../../core/reactiveUtils.js";import{schedule as h}from"../../../core/scheduling.js";import{unitFromRESTJSON as d,convertUnit as u}from"../../../core/units.js";import{property as m,subclass as p}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as f,invert as b}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as y,IDENTITY as g}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as _}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as v}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as w,sub as C,dot as x,set as T}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as j,freeze as E,clone as R,ZEROS as M,fromValues as O}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as S,clone as V,ONES as U}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMoon as H,isMars as D,getReferenceEllipsoid as P,SphericalECEFSpatialReferenceLike as I}from"../../../geometry/ellipsoidUtils.js";import k from"../../../geometry/HeightModelInfo.js";import{computeTranslationToOriginAndRotation as L}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as A}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as F}from"../../../geometry/projection/projectVectorToVector.js";import{create as G}from"../../../geometry/support/aaBoundingRect.js";import{isCompatible as z}from"../../../geometry/support/heightModelInfoUtils.js";import{isPlateCarree as B,isWebMercator as N,equals as W,isGeographic as q,isCGCS2000 as X}from"../../../geometry/support/spatialReferenceUtils.js";import $ from"../../../geometry/support/WKIDUnitConversion.js";import{BufferViewVec4f as Z,BufferViewVec4u8 as Y,BufferViewVec4u16 as J,BufferViewVec3f as K,BufferViewVec3u8 as Q,BufferViewVec3u16 as ee,BufferViewVec2f as te,BufferViewUint32 as ie,BufferViewUint16 as re}from"../../../geometry/support/buffer/BufferView.js";import se from"../../../layers/support/SceneModification.js";import{getHeightModelInfoFromVCS as oe,validateMeshData as ne,makeCacheKey as ae}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as le}from"../../../support/elevationInfoUtils.js";import{IntegratedMesh3DTilesLayerWorkerHandle as ce}from"./IntegratedMesh3DTilesLayerWorkerHandle.js";import{LayerView3D as he}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as de}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as ue,removeLayerViewFromWasm as me,getLyr3DWasm as pe}from"./Lyr3DWasm.js";import{toWasmModification as fe}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as be}from"./i3s/LayerElevationProvider.js";import{IntegratedMesh3DTilesLayerView3DSymbol as ye}from"./support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{primTypeConversion as ge,alphaModeConversion as _e,faceCullingConversion as ve,wrapModeConversion as we}from"./support/lyr3dTypeConversions.js";import{makeScheduleFunction as Ce}from"./support/makeScheduleFunction.js";import{Tiles3DMeshIntersectionHandler as xe}from"./support/Tiles3DMeshIntersectionHandler.js";import{Frustum as Te}from"../state/Frustum.js";import{ElevationRange as je}from"../support/ElevationRange.js";import{toBoundingRect as Ee}from"../support/extentUtils.js";import{Obb as Re}from"../support/orientedBoundingBox.js";import{glLayout as Me}from"../support/buffer/glUtil.js";import{ComponentGeometryParameters as Oe,SourceGeometry as Se}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as Ve}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Ue}from"../webgl-engine/core/material/RenderTexture.js";import{ManagedTexture as He}from"../webgl-engine/lib/ManagedTexture.js";import{compressNormals as De}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as Pe}from"../webgl-engine/materials/pbrUtils.js";import Ie from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as ke,isInEffectiveScaleRange as Le,validateScaleRange as Ae}from"../../support/layerViewUtils.js";import{TaskPriority as Fe}from"../../support/Scheduler.js";import{TextureCompressionTracker as Ge}from"../../support/TextureCompressionTracker.js";import{CompressedTextureFormat as ze,SizedPixelFormat as Be}from"../../webgl/enums.js";import{alphaCutoff as Ne}from"../../../webscene/support/AlphaCutoff.js";var We;function qe(e,t,i){if("image/vnd-ms.dds"===t)switch(i){case"Dxt1":return ze.COMPRESSED_RGB_S3TC_DXT1_EXT;case"Dxt5":return ze.COMPRESSED_RGBA_S3TC_DXT5_EXT;default:return null}if("image/ktx2"===t)return null;switch(e){case 33319:return Be.RG8;case 6407:return Be.RGB8;case 6408:return Be.RGBA8;case 6403:return Be.R8;default:return null}}let Xe=class extends(he(Ie)){static{We=ye}constructor(e){super(e),this[We]=!0,this.type="integrated-mesh-3dtiles",this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._initializationController=null,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this._useEsriCrs=!1,this.fullExtentInLocalViewSpatialReference=null,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 Ge,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(Fe.TILES3D,this),this._frustum=new Te(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{o(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._workerHandle=new ce(Ce(e.resourceController)),this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),a),!this._canProjectWithoutEngine())throw ke("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);this._initializationController=new AbortController;const t=ue(this,this._initializationController.signal).then(t=>{o(this._initializationController.signal),this._wasmLayerId=t,this._intersectionHandler=new xe(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(),a),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),a),this._elevationProvider=new be({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([l(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),c(()=>this.fullOpacity,()=>this._opacityChange()),l(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),a)]),this._initializationController=null,this.addHandles(c(()=>this._replacesTerrain&&this._wasm?.isTerrainReady,()=>{this.layer.queryElevationCallback=(e,t)=>this._queryElevation(e,t)}))});this.addResolvingPromise(t)}destroy(){if(this._initializationController=i(this._initializationController),this._dbg(2,"Tiles3DLayerView3D destroy() called"),this._workerHandle?.destroyContextAndSelf(this.uid),me(this),this.layer.queryElevationCallback=null,this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler.destroy(),this._intersectionHandler=null),this._elevationProvider){const e=Array.from(this._lyrHandleToObjects.values()),t=e.reduce((e,{componentObjects:t})=>e+t.length,0);this._elevationProvider.notifyObjectsChangedFunctional(t,t=>{for(const{componentObjects:i}of e)for(const{obb:e}of i)if(!t(e))return}),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=r(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(r=>{const s=r.obb?.intersectsFrustum(e)??!1;s!==r.isVisible&&(r.isVisible=s,s?t.add(r):t.delete(r),r.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,s)),i||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(s,r.elevationRange))}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,r){this._intersectionHandler.intersectRay(e,t,i,r,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}_modificationsChanged(){const e=this.useEsriCrs?this.layer.supportedSpatialReferences[1]:this.layer.supportedSpatialReferences[0],t=fe(this._layerClippingArea,this._modifications,e,this.view.state.isGlobal);this._wasm?.setMeshModifications(this,t)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=G();this._layerClippingArea=Ee(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=h(()=>{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,le(e))}get _wasm(){return pe(this.view)}_queryElevation(e,t){return this.destroying||this.destroyed?Promise.reject(n()):this._wasm?.queryElevation(this,e,t)??Promise.reject(n())}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get useEsriCrs(){return this._useEsriCrs}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||Le(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||Ae(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,r=0,s=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isLoaded?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,s++):(i+=n.textureMemoryUsage,r+=n.vboMemoryUsage,o++)}),new de(this.usedMemory,s,o,Ye(t),Ye(e),Ye(r),Ye(i))}_canProjectWithoutEngine(){if(1===this.view.state.viewingMode)return!0;if(B(this.view.renderSpatialReference)||N(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&W(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){if(115700===this.layer.esriCrsSpatialReference.vcsWkid)return!1;let e=oe(this.layer.esriCrsSpatialReference);if(!e){const t=this.layer.esriCrsSpatialReference;let i="meters";!q(t)&&t.wkid&&-1!==t.wkid&&(i=d($.units[$[t.wkid]])),i&&(e=new k({heightModel:"gravity-related-height",heightUnit:i}))}const t=this.view.heightModelInfo;return this._useEsriCrs=0===z(e,t,!1),this._useEsriCrs&&(e&&(this._metersPerVCSUnit=u(1,e.heightUnit,"meters")),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return le(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new je(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new je;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,r=i.isWGS84||i.isWebMercator||X(i)||H(i)||D(i);if(this.view.state.isGlobal||!r)return this.forEachVisibleTile(e);const s=P(i).radius,{eye:o,viewForward:n,near:a}=t.state.contentCamera,l=w(j(),n),c=500,h=Math.max(o[2],c),d=h+s,u=Math.sqrt(d**2-s**2),m=Math.abs(Math.atan2(u,s))*s,p=h>.5*s?.5*Math.PI*s:m,f=j();this.forEachVisibleTile(t=>{const{mbsRadius:i,mbsCenter:r}=t;if(i<0)return;C(f,r,o);const s=x(f,l);Math.abs(s)<p&&s+i>a&&s-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)}get drapeTargetType(){return this._replacesTerrain?0:1}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}get readyToRun(){return!!this._frameTask?.readyToRun}runTask(e){this._frameTask.processQueue(e)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed||this.destroying)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy");const{meshData:t}=e;if(!ne(t))throw new Error("meshData not valid");const i=new Map;let r;try{r=this._createPrimitiveTextureBundles(t,i)}catch(o){throw i.forEach(e=>this._stage?.removeTexture(e)),o}let s=null;try{if(s=await this._createRenderableMain(t,r),this.destroyed)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable aborted due to destroyed instance");const{tileObb:o,componentObjects:n,elevationRange:a}=s;let l=0,c=0,h=0;for(const e of n){const{texture:t,textureMetallicRoughness:i,textureEmissive:r,textureOcclusion:s,textureNormal:o}=e.renderable.drawParameters;l+=(t?.usedMemory??0)+(i?.usedMemory??0)+(r?.usedMemory??0)+(s?.usedMemory??0)+(o?.usedMemory??0),c+=this._collection.getObjectGPUMemoryUsage(e),h+=e.intersectionGeometry.usedMemory}const d=Array.from(i.values()),u=new Ze(e.handle,n,d,h,c,l,o,e.stableNodeId,e.nodeDepth,a);return this._lyrHandleToObjects.set(e.handle,u),()=>{this._memCache.put(ae(u.handle),u);const{usedMemory:e}=u;return this._cacheMemory+=e,{memUsageBytes:e}}}catch(o){throw r.forEach(e=>e.cleanup()),s?.componentObjects.forEach(e=>this._collection.destroyObject(e)),i.forEach(e=>this._stage?.removeTexture(e)),o}}_createPrimitiveTextureBundles(e,t){const i=new Array,r=e.desc.prims.length;try{const s=e.desc;for(let o=0;o<r;o++){const r=s.prims[o].materialId,n=s.materials&&null!=r?s.materials[r]:null;let a=Promise.resolve(Ke),l=null,c=null,h=null,d=null,u=null;if(n){const i="Pbr"===n.lightingModel;l=this._getTexture(n.baseColorTex,e,t),c=i?this._getTexture(n.metalTex,e,t):null,h=i?this._getTexture(n.emissiveTex,e,t):null,d=i?this._getTexture(n.occlusionTex,e,t):null,u=i?this._getTexture(n.normalTex,e,t):null;const r=[l,c,h,d,u].map(e=>e?.loadPromise??null);a=Promise.all(r)}i.push(new Qe(a,l,c,h,d,u))}}catch(s){throw i.forEach(e=>e.cleanup()),s}return i}async _createRenderableMain(e,t){if(this.destroyed||this.destroying)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderableMain called after destroy");const i=new Array,r=e.desc,s=e.data.buffer,o=r.prims.length,n=E(...r.origin),a=this.view.basemapTerrain.spatialReference,l=this.view.state.isGlobal;let c=g;if(l){const e=_();L(I,n,e,a),c=f(y(),e)}if(null==r.obb)throw new Error("meshData.desc.obb undefined");const h=Je(r.obb),d=l?P(this.view.spatialReference).radius:0,u=new Array;try{for(let i=0;i<o;i++){const e=r.prims[i],o=t[i];this._dbgFlags.has(2)&&this._dbg(2,JSON.stringify(e));if(null==ge[e.ptype]){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+e.ptype+"). Skipping primitive."),o.cleanup();continue}const{positionView:n,normalsData:a,colorView:l,texCoord0Data:c,indicesView:h}=this.getBufferViews(e,s);if(null==n||null==h){o.cleanup();continue}const d=n.count,m=(e,t)=>null==e||e===d||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);m(null!=c?c.length/2:void 0,"numTexcoord")&&m(l?.count,"numColors")&&m(a?.length,"normals")?u.push({componentIndex:i,positionView:n,indicesView:h,texCoord0Data:c,colorView:l,normalsData:a}):o.cleanup()}const e=c!==g,m=e?b(y(),c)??g:g,{vertexProcessingOutputs:p,obbHalfSizeAccumulator:f,elevationRange:_}=await this._workerHandle.processTiles3DVertices(u,n,d,l,c,h,this._imVertexNormals&&!this._isUsedAsGroundLayer);if(this.destroyed)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance");const v=r.materials;if(await Promise.all(t.map(e=>e.materialPromise)),this.destroyed)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance");p.length>0&&h.setHalfSize(f);for(const s of p){const{componentIndex:o,positionView:l,indicesView:c,layout:d,textureCoordinateType:u,interleavedVertexData:p,indices:f}=s,b=r.prims[o],y=t[o],g=h.clone(),_=Me(d),w=new Uint32Array([0,c.typedBuffer.length]),C=new Oe(_,this._imShading?2:0,u,e?2:0),x=new Se({interleavedVertexData:p,vertexCount:p.byteLength/_[0].stride,indexData:f},{positions:l.typedBuffer,indices:c.typedBuffer},w,C),T=this.view.renderSpatialReference,E=j(),R=[1,1,1];A(n,T,R,a)||this._dbg(3,"Unsupported coordinate system for IM overlay"),F(n,T,E,a);const M=v&&null!=b.materialId?v[b.materialId]:null,O=this._createComponentMaterialInitParameters(M,y);O.baseColorTexture||this._dbg(3,"No colour texture 1");const V=this._collection.createObject({toMapSpace:S(E[0],E[1],R[0],R[1]),transform:new Ve(n,m),obb:g,geometry:x,elevationAlignable:!1},O);i.push(V)}const{fullExtent:w}=this.layer;return w?.hasZ&&w.zmax&&w.zmin&&(_.minElevation=Math.max(_.minElevation,w.zmin),_.maxElevation=Math.min(_.maxElevation,w.zmax)),{tileObb:h,componentObjects:i,elevationRange:_}}catch(m){throw i.forEach(e=>this._collection.destroyObject(e)),m}}_createComponentMaterialInitParameters(e,t){const i="Pbr"===(null!=e?e.lightingModel:"Unlit");let r=U,s=Ne,o=1,n=!1,a=2,l=O(0,0,0);const c=R(Pe),h=t.baseColorTexture,d=t.metallicRoughnessTexture,u=t.emissionTexture,m=t.occlusionTexture,p=t.normalTexture;return e&&(r=V(e.baseColorFactor),s=e.alphaCutoff??Ne,i&&(T(c,e.metallicFactor,e.roughnessFactor,0),e.emissiveFactor&&(l=e.emissiveFactor)),o=_e[e.alphaMode],n=e.isDoubleSided,a=ve[e.faceCulling??"NotSet"]),{isIntegratedMesh:!0,baseColor:r,textureAlphaCutoff:s,mrrFactors:c,baseColorTexture:h,metallicRoughnessTexture:d,normalTexture:p,occlusionTexture:m,emissionTexture:u,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:o,doubleSided:n,cullFace:a,isGround:this.layer.replacesTerrain,emissiveBaseColor:l,usePBR:i,slicePlaneEnabled:this.slicePlaneEnabled,opacity:this.fullOpacity,polygonOffset:0,ellipsoidMode:1,applySSAO:this._applySSAO}}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=ae(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 r=this._frustum,s=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(r)??!0;l.isVisible=e,e&&(this._visibleObjects.add(l),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,l.elevationRange)),s.push(l.obb),l.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(ae(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 r=this._lyrHandleToObjects.get(i);if(r){if(!r.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${r.stableNodeId}`);continue}const e=r.isVisible;this._visibleObjects.delete(r),r.isVisible=!1,r.isLoaded=!1,this._loadedObjects.delete(r),this._intersectionHandler.removeTile(r),e&&(this._visibleGeometryChanged(),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,r.elevationRange)),this._usedMemory-=r.usedMemory,this._cacheMemory+=r.usedMemory,s.push(r.obb),r.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(ae(i),r)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),s.length>0&&this._elevationProvider.notifyObjectsChanged(s),n&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){const{visibleElevationRange:i}=this,{minElevation:r,maxElevation:s}=t;return e?r<i.minElevation||s>i.maxElevation:r===i.minElevation||s===i.maxElevation}_getTexture(e,t,i){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const s=i.get(r)??this._createTexture(e,t,i);return s?new Ue(this._stage.renderView.textures,s.id):null}_createTexture(e,t,i){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const s=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,o=!!r.mipCount||s>1,n=we[e.wrapMode??"None"];let a=r.alpha?6408:6407;const l=new Uint8Array(t.data.buffer,r.data.byteOffset,r.data.byteCount);let c=null,h=null,d=null;switch(r.format){case"Raw":"R8"===r.pixelFormat?(c=l,a=6403,h=""):"Rg8"===r.pixelFormat||"Ga8"===r.pixelFormat?(c=l,a=33319,h=""):"Rgb8"===r.pixelFormat?(c=l,a=6407,h=""):"Rgba8"===r.pixelFormat&&(c=l,a=6408,h="");break;case"Dxt1":c=l,a=6407,h="image/vnd-ms.dds";break;case"Dxt5":c=l,a=6408,h="image/vnd-ms.dds";break;case"Basis":c=l,a=6407,h="image/ktx2";break;case"Png":h="image/png",d=document.createElement("img");break;case"Jpeg":h="image/jpeg",d=document.createElement("img");break;case"Etc2":h="image/ktx",d=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(d&&h){const e=new Blob([l],{type:h});d.src=URL.createObjectURL(e),c=d}if(c&&null!=h){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker}:void 0,t=qe(a,h,r.format),l=new He(c,{mipmap:o,maxAnisotropy:s,encoding:h,wrap:n,pixelFormat:a,internalFormat:t??void 0,immutable:null!=t,compressionOptions:e,noUnpackFlip:!0,width:r.mip0Width,height:r.mip0Height});return this._stage.addTexture(l),i.set(r,l),l}return null}getBufferViews(e,t){let i,r,s,o,n;for(let l=0;l<e.atrbs.length;l++){const n=e.atrbs[l],{view:c}=n,h=void 0,d=c.byteOffset+c.byteCount;try{switch(n.sem){case"Position":3!==c.ncomp||"F32"!==c.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+c+")"):i=new K(t,c.byteOffset,h,d);break;case"Normal":if(3!==c.ncomp||"F32"!==c.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+c+")");else{const e=new K(t,c.byteOffset,h,d);o=new Uint32Array(e.count),De(e.typedBuffer,new Int16Array(o.buffer,o.byteOffset,2*o.length))}break;case"TexCoord":2!==c.ncomp||"F32"!==c.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+c+")"):void 0===s&&(s=new te(t,c.byteOffset,h,d).typedBuffer);break;case"Color":4===c.ncomp?("F32"===c.type&&(r=new Z(t,c.byteOffset,h,d)),"U8"===c.type&&(r=new Y(t,c.byteOffset,h,d)),"U16"===c.type&&(r=new J(t,c.byteOffset,h,d))):3===c.ncomp&&("F32"===c.type&&(r=new K(t,c.byteOffset,h,d)),"U8"===c.type&&(r=new Q(t,c.byteOffset,h,d)),"U16"===c.type&&(r=new ee(t,c.byteOffset,h,d))),null==r&&this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+c+")");break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+n.sem+"). Skipping vertex attribute.")}}catch(a){this._dbg(2,"Error Creating buffer ("+a+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,r=void 0,s=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":n=new re(t,i.byteOffset,r,s);break;case"U32":n=new ie(t,i.byteOffset,r,s);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==n&&null!=i){const e=i.count;n=n=e<65535?new re(new Uint16Array(e).buffer):new ie(new Uint32Array(e).buffer);for(let t=0;t<e;t++)n.set(t,t)}return{positionView:i,colorView:r,texCoord0Data:s,indicesView:n,normalsData:o}}_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.")},a),"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([m()],Xe.prototype,"fullOpacity",null),e([m({readOnly:!0})],Xe.prototype,"ready",null),e([m({type:[se]})],Xe.prototype,"_modifications",void 0),e([m()],Xe.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([m()],Xe.prototype,"layer",void 0),e([m({readOnly:!0})],Xe.prototype,"visibleAtCurrentScale",null),e([m({readOnly:!0})],Xe.prototype,"_collection",null),e([m()],Xe.prototype,"elevationOffset",null),e([m({readOnly:!0})],Xe.prototype,"visibleElevationRange",null),e([m()],Xe.prototype,"fullExtentInLocalViewSpatialReference",void 0),Xe=e([p("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Xe);const $e=Xe;class Ze{constructor(e,t,i,r,s,o,n,a,l,c){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=r,this.vboMemoryUsage=s,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 h=j();n?.getCenter(h),this._obbCenterX=h[0],this._obbCenterY=h[1],this._obbCenterZ=h[2];const d=n?.radius??-1;this._obbRadius=d,this._obbRadiusSquared=d*d,this._obbShortestHalfsize=n?Math.min(n.halfSizeX,n.halfSizeY,n.halfSizeZ):0,this._mbsCenter=n?n.getCenter(j()):M}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:r,_obbCenterZ:s}=this,o=i-e[0],n=r-e[1],a=s-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,r=e.radius,s=t+r,o=this._obbCenterX-i[0];if(o>s)return!1;const n=this._obbCenterY-i[1];if(n>s)return!1;const a=this._obbCenterZ-i[2];if(a>s)return!1;const l=o*o+n*n+a*a;if(l>s*s)return!1;if(l<=(this._obbShortestHalfsize+r)**2)return!0;const c=r-t;return c>0&&l<=c*c||(this.obb?.intersectSphere(e)??!0)}}function Ye(e){return Math.round(e/1048.576)/1e3}function Je(e){return new Re(e.center,e.halfSize,v(...e.quaternion))}const Ke=new Array;class Qe{constructor(e,t,i,r,s,o){this.materialPromise=e,this.baseColorTexture=t,this.metallicRoughnessTexture=i,this.emissionTexture=r,this.occlusionTexture=s,this.normalTexture=o}cleanup(){this.baseColorTexture?.dispose(),this.metallicRoughnessTexture?.dispose(),this.emissionTexture?.dispose(),this.occlusionTexture?.dispose(),this.normalTexture?.dispose()}}export{$e as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__addDisposableResource as e,__disposeResources as t}from"tslib";import r from"../../../../core/Error.js";import{disposable as i}from"../../../../core/handleUtils.js";import{translate as s}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as a,create as o}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as n,scale as l,multiply as h}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as c,fromArray as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as m}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromArray as u,create as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBuffer as f}from"../../../../geometry/projection/projectBuffer.js";import{create as g,fromSubBuffer as _,intersectsClippingArea as y}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as b,doubleArrayFrom as v}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as x}from"../../../../geometry/support/FloatArray.js";import{getCoordinateEquals as w}from"../../../../geometry/support/geometryUtils.js";import{isDrivenOpacityFallbackAlwaysOpaque as P}from"../../../../renderers/visualVariables/support/visualVariableUtils.js";import{needsElevationUpdates3D as S,evaluateElevationAlignmentAtPoint as D,SampleElevationInfo as j}from"./elevationAlignmentUtils.js";import{Graphics3DObject3DGraphicLayer as V}from"./Graphics3DObject3DGraphicLayer.js";import{maxPathLength as C,pathNumRoundJoinSubdivisions as A}from"./Graphics3DPathSymbolLayerConstants.js";import{Graphics3DSymbolLayer as z,nanFallbackColor as U}from"./Graphics3DSymbolLayer.js";import{isValidSize as E}from"./graphicUtils.js";import{ConvertOptions as R,initFastSymbolUpdatesState as B,updateFastSymbolUpdatesState as L,getSizeAttributeValue as G,getAttributeValue as O}from"../support/FastSymbolUpdates.js";import{SamplePosition as k}from"../../support/ElevationProvider.js";import{Object3D as I}from"../../webgl-engine/lib/Object3D.js";import{Path as F}from"../../webgl-engine/lib/Path.js";import{PathBuilder as M}from"../../webgl-engine/lib/PathBuilder.js";import{RoundCapBuilder as q,TriangulationCapBuilder as H,NoCapBuilder as T}from"../../webgl-engine/lib/PathCapBuilder.js";import{MiterExtruder as Z}from"../../webgl-engine/lib/PathExtruder.js";import{PathGeometry as J,isPathGeometry as $}from"../../webgl-engine/lib/PathGeometry.js";import{computeMinimumRotationTangentFrame as K}from"../../webgl-engine/lib/pathGeometryUtils.js";import{quadProfiles as N,circleProfiles as Q}from"../../webgl-engine/lib/PathProfile.js";import{newPathVertex as W}from"../../webgl-engine/lib/PathVertex.js";import{PathMaterial as X}from"../../webgl-engine/materials/PathMaterial.js";const Y=["polyline"];class ee extends z{constructor(e,t,r,i){super(e,t,r,i,P(t)),this._intrinsicSize=c(1,1),this._upVectorAlignment=1,this.ensureDrapedStatus(!1)}_validateGeometry(e,t,r){return!!super._validateGeometry(e,t,r)&&("polyline"===e.type&&(!e.paths.some(e=>e.length>C)||(this.logger.warn(`Geometry has a path longer than ${C} vertices and cannot be displayed by PathSymbol3DLayer`),!1)))}async doLoad(){const e=this.symbolLayer,t=null!=e.width?e.width:e.height,i=null!=e.height?e.height:t;this._vvConvertOptions=new R({supports:{size:!0,color:!0,rotation:!1,opacity:!0},modelSize:[1,1,1],symbolSize:[t,1,i],unitInMeters:this._context.renderCoordsHelper.unitInMeters,fallbackColor:this._getFallbackOpacityAndColor(U),fallbackSize:[t,1,i]});const s=this._context.renderer?.visualVariables;this._fastUpdates=s?.length?B(this._context.renderer,this._vvConvertOptions):null;const a=e.anchor||"center";this._upVectorAlignment="heading"===e.profileRotation?0:1;const o=e.profile||"circle";switch(o){default:case"circle":this._profile=Q[a];break;case"quad":this._profile=N[a]}switch(e.join){case"round":this._extruder=new Z(0,A);break;default:case"bevel":this._extruder=new Z(0,1);break;case"miter":this._extruder=new Z(.8*Math.PI,1)}switch(this._cap){case"none":this._capBuilder=new T;break;case"butt":default:this._capBuilder=new H(this._profile,1);break;case"square":this._capBuilder=new H(this._profile,2);break;case"round":{const e="quad"===o;this._capBuilder=new q(this._profile,e);break}}const h=this._materialColor,c=this._getCombinedOpacityAndColor(h),m=u(c),d=c[3],f=this.needsDrivenTransparentPass,g=e.material?.emissive,_={diffuse:m,ambient:m,emissiveStrengthFromSymbol:("color"===g?.source?g?.strength:void 0)??0,emissiveSource:1,opacity:d,drivenOpacity:f,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows};if(!this._drivenProperties.size&&(n(this._intrinsicSize,t,i),!E(this._intrinsicSize[0])||!E(this._intrinsicSize[1])))throw new r("graphics3dpathsymbollayer:invalid-size","Symbol sizes may not be negative values");this._fastUpdates?.visualVariables.size||l(this._intrinsicSize,this._intrinsicSize,1/this._context.renderCoordsHelper.unitInMeters);const y=null!=this._fastUpdates,b=new X({..._,...this._fastUpdates?.materialParameters,size:p(this._intrinsicSize),upVectorAlignment:this._upVectorAlignment,profile:this._profile,pathCapType:this._capBuilder.type,cutoffAngle:this._extruder.cutoffAngle,numJoinSubdivisions:this._extruder.numBendSubdivisions,hasPathColor:!y&&this._drivenProperties.color,hasPathOpacity:!y&&this._drivenProperties.opacity&&!this._drivenProperties.color,hasPathSize:!y&&this._drivenProperties.size,usePBR:this._context.physicalBasedRenderingEnabled},this._context);this._materials[0]=b,this._updateTransparentDepedentMaterialParameters()}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Y,this.symbolLayer.type))return null;const r=this.createElevationContextForGraphic(t);return this._createAs3DShape(e,r)}layerOpacityChanged(){const e=this._materialColor,t=this._getCombinedOpacity(e),r=this._materials[0];r&&(r.setParameters({opacity:t}),this._updateTransparentDepedentMaterialParameters())}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,S)}slicePlaneEnabledChanged(){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return this._materials[0]?.setParameters({usePBR:this._context.physicalBasedRenderingEnabled}),!0}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return 0;if(!L(this._fastUpdates,t,this._vvConvertOptions))return 0;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return 2}_getVertexData(r){let i=0;const s=r.paths,a=[],o=r.spatialReference,n=this._context.elevationProvider.spatialReference,l=this._context.renderCoordsHelper.spatialReference,h=w(r.hasZ),c=s.map(r=>{const i={stack:[],error:void 0,hasError:!1};try{const t=ne;e(i,le,!1);for(let e=1;e<r.length;++e)h(r[e],r[e-1])&&t.add(e);return 0===t.size?r:r.filter((e,r)=>!t.has(r))}catch(s){i.error=s,i.hasError=!0}finally{t(i)}});for(const e of c)i+=e.length;const p=b(3*i);let m,u=0;for(const e of c){a.push({offset:u,numVertices:e.length});for(const t of e)p[u++]=t[0],p[u++]=t[1],p[u++]=r.hasZ?t[2]:0}return null==n||o.equals(n)||f(p,o,0,p,n,0,i)?(null==n||n.equals(l)?m=v(p):(m=b(3*i),f(p,n,0,m,l,0,i)),{pathVertexDataInfos:a,vertexDataES:p,vertexDataRS:m}):null}_createAs3DShape(e,t){const{graphic:r,renderingInfo:i}=e,n=r.geometry,l=this._getVertexData(n);if(null==l)return this.logger.warn("PathSymbol3DLayer geometry failed to be created (failed to project geometry to view spatial reference)"),null;if(0===l.pathVertexDataInfos.length)return 0!==n.paths.length&&n.paths.some(e=>e.length>0)||this.logger.warn("PathSymbol3DLayer geometry failed to be created (no paths were defined)"),null;const h=new Array,c=g(),p=this._context.renderCoordsHelper,u=new k(l.vertexDataES),d=r.uid,f=x(l.vertexDataRS.length);for(const g of l.pathVertexDataInfos){const e=g.numVertices;if(e<2)continue;const r=g.offset;if(null!=this._context.clippingExtent&&(_(l.vertexDataES,r,e,c),!y(c,this._context.clippingExtent)))continue;const n=new Array,b=r+3*e;for(let i=r;i<b;i+=3){u.offset=i;const e=D(u,this._context.elevationProvider,t,p);m(ae,l.vertexDataRS[i],l.vertexDataRS[i+1],l.vertexDataRS[i+2]),p.setAltitude(ae,e),l.vertexDataRS[i]=ae[0],l.vertexDataRS[i+1]=ae[1],l.vertexDataRS[i+2]=ae[2],n.push(W(this._upVectorAlignment))}const v=new F(n,l.vertexDataES,l.vertexDataRS,r,f);te(v,this._upVectorAlignment,this._context.renderCoordsHelper);const x=new M(v,this._profile,this._extruder,this._capBuilder,this._upVectorAlignment),w=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:d,layerViewUid:this._context.layerViewUid}),P=new J(this._materials[0],x,this._getVisualVariableData(i),w);P.transformation=s(o(),a,x.path.origin),h.push(P)}if(0===h.length)return null;const b=new I({geometries:h,layerViewUid:this._context.layerViewUid,graphicUid:d}),v=new V(this,b,null,(e,t,r,i,s)=>se(e,t,i,s,this._upVectorAlignment),t,null);return v.alignedSampledElevation=0,v.needsElevationUpdates=S(t.mode),v}_getVisualVariableData(e){if(this._fastUpdates){const{size:t,color:r,opacity:i}=this._fastUpdates.visualVariables;return{sizeAttributeValue:G(t,e.size),colorAttributeValue:O(r,e.color),opacityAttributeValue:O(i,e.opacity)}}return{size:this._getDrivenSize(e),color:this._getDrivenColor(e),opacity:this._getDrivenOpacity(e)}}_getDrivenSize(e){if(!this._drivenProperties.size)return null;const t=e.size?.output??["symbol-value","symbol-value","symbol-value"],r=c(re(t[0],"symbol-value"===t[2]?this.symbolLayer.height||0:t[2],this.symbolLayer.width||0),re(t[2],"symbol-value"===t[0]?this.symbolLayer.width||0:t[0],this.symbolLayer.height||0));return h(r,r,this._intrinsicSize),r}_getDrivenColor(e){return this._drivenProperties.color?this._getDrivenUInt8Color(e,this._materialColor,!1):null}_getDrivenOpacity(e){return this._drivenProperties.opacity&&!this._drivenProperties.color?e.opacity?.output??this._materialColor?.a??0:null}get _materialColor(){return this.symbolLayer.material?.color}_getFallbackOpacityAndColor(e){return this._materialColor?.toUnitRGBA()??e}get _cap(){return this.symbolLayer.cap||"butt"}_updateTransparentDepedentMaterialParameters(){const e=this._materials[0];e&&e.setParameters({cullFace:e.transparent||"none"===this._cap?0:2})}}function te(e,t,r){const{origin:i,positions:s}=e;let a=e.offset;switch(t){default:case 0:for(const t of e.vertices)ae[0]=s[a++]+i[0],ae[1]=s[a++]+i[1],ae[2]=s[a++]+i[2],r.worldUpAtPosition(ae,ae),t.setFrameFromUpVector(ae);break;case 1:ae[0]=s[a]+i[0],ae[1]=s[a+1]+i[1],ae[2]=s[a+2]+i[2],r.worldUpAtPosition(ae,ae),K(e,ae)}}function re(e,t,r){switch(e){case"symbol-value":return r;case"proportional":return t;default:return e}}function ie(e,t,r,i){let s=0;const{origin:a,vertices:o,positions:n,positionsES:l}=e,h=e.offset+3*o.length;for(let c=e.offset;c<h;c+=3)m(ae,l[c],l[c+1],l[c+2]),r(ae,oe),s+=oe.sampledElevation,ae[0]=n[c]+a[0],ae[1]=n[c+1]+a[1],ae[2]=n[c+2]+a[2],i.setAltitude(ae,oe.z),n[c]=ae[0]-a[0],n[c+1]=ae[1]-a[1],n[c+2]=ae[2]-a[2];return e.updatePathVertexInformation(),s/o.length}function se(e,t,r,i,s){const a=e.stageObject,o=a.geometries;let n=0;for(const l of o){if(!$(l))continue;const e=l.builder.path;n+=ie(e,t,r,i),0!==s&&te(e,s,i),l.onPathChanged(),a.geometryVertexAttributeUpdated(l,"position")}return n/o.length}const ae=d(),oe=new j,ne=new Set,le=i({remove:()=>ne.clear()});export{ee as Graphics3DPathSymbolLayer};
|
|
2
|
+
import{__addDisposableResource as e,__disposeResources as t}from"tslib";import r from"../../../../core/Error.js";import{disposable as i}from"../../../../core/handleUtils.js";import{translate as s}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as a,create as o}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as n,scale as l,multiply as h}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as c,fromArray as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as m}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromArray as u,create as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBuffer as f}from"../../../../geometry/projection/projectBuffer.js";import{create as g,fromSubBuffer as _,intersectsClippingArea as y}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as b,doubleArrayFrom as v}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as x}from"../../../../geometry/support/FloatArray.js";import{getCoordinateEquals as w}from"../../../../geometry/support/geometryUtils.js";import{isDrivenOpacityFallbackAlwaysOpaque as P}from"../../../../renderers/visualVariables/support/visualVariableUtils.js";import{needsElevationUpdates3D as S,evaluateElevationAlignmentAtPoint as D,SampleElevationInfo as j}from"./elevationAlignmentUtils.js";import{Graphics3DObject3DGraphicLayer as V}from"./Graphics3DObject3DGraphicLayer.js";import{maxPathLength as C}from"./Graphics3DPathSymbolLayerConstants.js";import{Graphics3DSymbolLayer as A,nanFallbackColor as z}from"./Graphics3DSymbolLayer.js";import{isValidSize as U}from"./graphicUtils.js";import{ConvertOptions as E,initFastSymbolUpdatesState as R,updateFastSymbolUpdatesState as B,getSizeAttributeValue as L,getAttributeValue as G}from"../support/FastSymbolUpdates.js";import{SamplePosition as O}from"../../support/ElevationProvider.js";import{Object3D as k}from"../../webgl-engine/lib/Object3D.js";import{Path as I}from"../../webgl-engine/lib/Path.js";import{PathBuilder as F}from"../../webgl-engine/lib/PathBuilder.js";import{RoundCapBuilder as M,TriangulationCapBuilder as T,NoCapBuilder as q}from"../../webgl-engine/lib/PathCapBuilder.js";import{PathExtruder as H}from"../../webgl-engine/lib/PathExtruder.js";import{PathGeometry as Z,isPathGeometry as J}from"../../webgl-engine/lib/PathGeometry.js";import{computeMinimumRotationTangentFrame as $}from"../../webgl-engine/lib/pathGeometryUtils.js";import{quadProfiles as K,circleProfiles as N}from"../../webgl-engine/lib/PathProfile.js";import{newPathVertex as Q}from"../../webgl-engine/lib/PathVertex.js";import{PathMaterial as W}from"../../webgl-engine/materials/PathMaterial.js";const X=["polyline"];class Y extends A{constructor(e,t,r,i){super(e,t,r,i,P(t)),this._intrinsicSize=c(1,1),this._upVectorAlignment=1,this.ensureDrapedStatus(!1)}_validateGeometry(e,t,r){return!!super._validateGeometry(e,t,r)&&("polyline"===e.type&&(!e.paths.some(e=>e.length>C)||(this.logger.warn(`Geometry has a path longer than ${C} vertices and cannot be displayed by PathSymbol3DLayer`),!1)))}async doLoad(){const e=this.symbolLayer,t=null!=e.width?e.width:e.height,i=null!=e.height?e.height:t;this._vvConvertOptions=new E({supports:{size:!0,color:!0,rotation:!1,opacity:!0},modelSize:[1,1,1],symbolSize:[t,1,i],unitInMeters:this._context.renderCoordsHelper.unitInMeters,fallbackColor:this._getFallbackOpacityAndColor(z),fallbackSize:[t,1,i]});const s=this._context.renderer?.visualVariables;this._fastUpdates=s?.length?R(this._context.renderer,this._vvConvertOptions):null;const a=e.anchor||"center";this._upVectorAlignment="heading"===e.profileRotation?0:1;const o=e.profile||"circle";switch(o){default:case"circle":this._profile=N[a];break;case"quad":this._profile=K[a]}switch(e.join){case"round":this._extruder=new H(2);break;default:case"bevel":this._extruder=new H(1);break;case"miter":this._extruder=new H(0)}switch(this._cap){case"none":this._capBuilder=new q;break;case"butt":default:this._capBuilder=new T(this._profile,1);break;case"square":this._capBuilder=new T(this._profile,2);break;case"round":{const e="quad"===o;this._capBuilder=new M(this._profile,e);break}}const h=this._materialColor,c=this._getCombinedOpacityAndColor(h),m=u(c),d=c[3],f=this.needsDrivenTransparentPass,g=e.material?.emissive,_={diffuse:m,ambient:m,emissiveStrengthFromSymbol:("color"===g?.source?g?.strength:void 0)??0,emissiveSource:1,opacity:d,drivenOpacity:f,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows};if(!this._drivenProperties.size&&(n(this._intrinsicSize,t,i),!U(this._intrinsicSize[0])||!U(this._intrinsicSize[1])))throw new r("graphics3dpathsymbollayer:invalid-size","Symbol sizes may not be negative values");this._fastUpdates?.visualVariables.size||l(this._intrinsicSize,this._intrinsicSize,1/this._context.renderCoordsHelper.unitInMeters);const y=null!=this._fastUpdates,b=new W({..._,...this._fastUpdates?.materialParameters,size:p(this._intrinsicSize),upVectorAlignment:this._upVectorAlignment,profile:this._profile,pathCapType:this._capBuilder.type,cutoffAngle:this._extruder.cutoffAngle,pathJoinType:this._extruder.join,hasPathColor:!y&&this._drivenProperties.color,hasPathOpacity:!y&&this._drivenProperties.opacity&&!this._drivenProperties.color,hasPathSize:!y&&this._drivenProperties.size,usePBR:this._context.physicalBasedRenderingEnabled},this._context);this._materials[0]=b,this._updateTransparentDepedentMaterialParameters()}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,X,this.symbolLayer.type))return null;const r=this.createElevationContextForGraphic(t);return this._createAs3DShape(e,r)}layerOpacityChanged(){const e=this._materialColor,t=this._getCombinedOpacity(e),r=this._materials[0];r&&(r.setParameters({opacity:t}),this._updateTransparentDepedentMaterialParameters())}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,S)}slicePlaneEnabledChanged(){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return this._materials[0]?.setParameters({usePBR:this._context.physicalBasedRenderingEnabled}),!0}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return 0;if(!B(this._fastUpdates,t,this._vvConvertOptions))return 0;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return 2}_getVertexData(r){let i=0;const s=r.paths,a=[],o=r.spatialReference,n=this._context.elevationProvider.spatialReference,l=this._context.renderCoordsHelper.spatialReference,h=w(r.hasZ),c=s.map(r=>{const i={stack:[],error:void 0,hasError:!1};try{const t=oe;e(i,ne,!1);for(let e=1;e<r.length;++e)h(r[e],r[e-1])&&t.add(e);return 0===t.size?r:r.filter((e,r)=>!t.has(r))}catch(s){i.error=s,i.hasError=!0}finally{t(i)}});for(const e of c)i+=e.length;const p=b(3*i);let m,u=0;for(const e of c){a.push({offset:u,numVertices:e.length});for(const t of e)p[u++]=t[0],p[u++]=t[1],p[u++]=r.hasZ?t[2]:0}return null==n||o.equals(n)||f(p,o,0,p,n,0,i)?(null==n||n.equals(l)?m=v(p):(m=b(3*i),f(p,n,0,m,l,0,i)),{pathVertexDataInfos:a,vertexDataES:p,vertexDataRS:m}):null}_createAs3DShape(e,t){const{graphic:r,renderingInfo:i}=e,n=r.geometry,l=this._getVertexData(n);if(null==l)return this.logger.warn("PathSymbol3DLayer geometry failed to be created (failed to project geometry to view spatial reference)"),null;if(0===l.pathVertexDataInfos.length)return 0!==n.paths.length&&n.paths.some(e=>e.length>0)||this.logger.warn("PathSymbol3DLayer geometry failed to be created (no paths were defined)"),null;const h=new Array,c=g(),p=this._context.renderCoordsHelper,u=new O(l.vertexDataES),d=r.uid,f=x(l.vertexDataRS.length);for(const g of l.pathVertexDataInfos){const e=g.numVertices;if(e<2)continue;const r=g.offset;if(null!=this._context.clippingExtent&&(_(l.vertexDataES,r,e,c),!y(c,this._context.clippingExtent)))continue;const n=new Array,b=r+3*e;for(let i=r;i<b;i+=3){u.offset=i;const e=D(u,this._context.elevationProvider,t,p);m(se,l.vertexDataRS[i],l.vertexDataRS[i+1],l.vertexDataRS[i+2]),p.setAltitude(se,e),l.vertexDataRS[i]=se[0],l.vertexDataRS[i+1]=se[1],l.vertexDataRS[i+2]=se[2],n.push(Q(this._upVectorAlignment))}const v=new I(n,l.vertexDataES,l.vertexDataRS,r,f);ee(v,this._upVectorAlignment,this._context.renderCoordsHelper);const x=new F(v,this._profile,this._extruder,this._capBuilder,this._upVectorAlignment),w=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:d,layerViewUid:this._context.layerViewUid}),P=new Z(this._materials[0],x,this._getVisualVariableData(i),w);P.transformation=s(o(),a,x.path.origin),h.push(P)}if(0===h.length)return null;const b=new k({geometries:h,layerViewUid:this._context.layerViewUid,graphicUid:d}),v=new V(this,b,null,(e,t,r,i,s)=>ie(e,t,i,s,this._upVectorAlignment),t,null);return v.alignedSampledElevation=0,v.needsElevationUpdates=S(t.mode),v}_getVisualVariableData(e){if(this._fastUpdates){const{size:t,color:r,opacity:i}=this._fastUpdates.visualVariables;return{sizeAttributeValue:L(t,e.size),colorAttributeValue:G(r,e.color),opacityAttributeValue:G(i,e.opacity)}}return{size:this._getDrivenSize(e),color:this._getDrivenColor(e),opacity:this._getDrivenOpacity(e)}}_getDrivenSize(e){if(!this._drivenProperties.size)return null;const t=e.size?.output??["symbol-value","symbol-value","symbol-value"],r=c(te(t[0],"symbol-value"===t[2]?this.symbolLayer.height||0:t[2],this.symbolLayer.width||0),te(t[2],"symbol-value"===t[0]?this.symbolLayer.width||0:t[0],this.symbolLayer.height||0));return h(r,r,this._intrinsicSize),r}_getDrivenColor(e){return this._drivenProperties.color?this._getDrivenUInt8Color(e,this._materialColor,!1):null}_getDrivenOpacity(e){return this._drivenProperties.opacity&&!this._drivenProperties.color?e.opacity?.output??this._materialColor?.a??0:null}get _materialColor(){return this.symbolLayer.material?.color}_getFallbackOpacityAndColor(e){return this._materialColor?.toUnitRGBA()??e}get _cap(){return this.symbolLayer.cap||"butt"}_updateTransparentDepedentMaterialParameters(){const e=this._materials[0];e&&e.setParameters({cullFace:e.transparent||"none"===this._cap?0:2})}}function ee(e,t,r){const{origin:i,positions:s}=e;let a=e.offset;switch(t){default:case 0:for(const t of e.vertices)se[0]=s[a++]+i[0],se[1]=s[a++]+i[1],se[2]=s[a++]+i[2],r.worldUpAtPosition(se,se),t.setFrameFromUpVector(se);break;case 1:se[0]=s[a]+i[0],se[1]=s[a+1]+i[1],se[2]=s[a+2]+i[2],r.worldUpAtPosition(se,se),$(e,se)}}function te(e,t,r){switch(e){case"symbol-value":return r;case"proportional":return t;default:return e}}function re(e,t,r,i){let s=0;const{origin:a,vertices:o,positions:n,positionsES:l}=e,h=e.offset+3*o.length;for(let c=e.offset;c<h;c+=3)m(se,l[c],l[c+1],l[c+2]),r(se,ae),s+=ae.sampledElevation,se[0]=n[c]+a[0],se[1]=n[c+1]+a[1],se[2]=n[c+2]+a[2],i.setAltitude(se,ae.z),n[c]=se[0]-a[0],n[c+1]=se[1]-a[1],n[c+2]=se[2]-a[2];return e.updatePathVertexInformation(),s/o.length}function ie(e,t,r,i,s){const a=e.stageObject,o=a.geometries;let n=0;for(const l of o){if(!J(l))continue;const e=l.builder.path;n+=re(e,t,r,i),0!==s&&ee(e,s,i),l.onPathChanged(),a.geometryVertexAttributeUpdated(l,"position")}return n/o.length}const se=d(),ae=new j,oe=new Set,ne=i({remove:()=>oe.clear()});export{Y as Graphics3DPathSymbolLayer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
const o=3,t=
|
|
2
|
+
const o=3,t=o+1,c=3,e=10,n=2**24,p=n-1;export{p as maxPathFrameIndex,n as maxPathLength,e as pathNumCircleProfileSubdivisions,o as pathNumJoinSubdivisions,t as pathNumProfilesPerJoin,c as pathNumRoundCapExtrusionSubdivisions};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import has from"../../../../core/has.js";import{defaultObjectPrimitive as e}from"../../../../symbols/support/primitives.js";import{
|
|
2
|
+
import has from"../../../../core/has.js";import{defaultObjectPrimitive as e}from"../../../../symbols/support/primitives.js";import{pathNumJoinSubdivisions as r,pathNumCircleProfileSubdivisions as t,pathNumRoundCapExtrusionSubdivisions as a}from"./Graphics3DPathSymbolLayerConstants.js";import{primitiveLodResources as s}from"./primitiveObjectSymbolUtils.js";import{EstimatedSymbolComplexity as u,AggregateSymbolComplexity as o,SymbolComplexity as b}from"./SymbolComplexity.js";import{hasEdges as y}from"../support/edgeUtils.js";import{DefaultMaterial as c}from"../../webgl-engine/materials/DefaultMaterial.js";const P=new u({});function i(e){if("web-style"===e.type)return P;const r=new o;return e.symbolLayers.forEach(t=>n(F(e,t),r)),r}function n(e,r){e&&(r.verticesPerFeature+=e.verticesPerFeature,r.verticesPerCoordinate+=e.verticesPerCoordinate,r.drawCallsPerFeature+=e.drawCallsPerFeature,r.memory.bytesPerFeature+=e.memory.bytesPerFeature,r.memory.bytesPerFeatureLabel+=e.memory.bytesPerFeatureLabel,r.memory.resourceBytes+=e.memory.resourceBytes,r.memory.draped.bytesPerFeature+=e.memory.bytesPerFeature,r.memory.draped.bytesPerFeatureLabel+=e.memory.bytesPerFeatureLabel,r.estimated||=e.estimated,r.numComplexities++)}const l={};function F(s,o){const c=d(s,o),P=y(o)?2:0;switch(o.type){case"extrude":return new b({verticesPerFeature:-12,verticesPerCoordinate:12,drawCallsPerFeature:P,memory:c});case"fill":if("mesh-3d"===s.type)return new b({drawCallsPerFeature:P,memory:c});if(null!=o.outline&&o.outline.size>0)return new b({verticesPerFeature:-12,verticesPerCoordinate:9,memory:c});case"water":return new b({verticesPerFeature:-6,verticesPerCoordinate:3,memory:c});case"line":return new b({verticesPerFeature:-6,verticesPerCoordinate:6,memory:c});case"object":return o.resource?.href?new u({verticesPerFeature:100,memory:c}):{...m(o.resource?.primitive??e),memory:c};case"path":{let e=0;switch(o.profile){case"circle":e=t;break;case"quad":e=4;break;default:return void o.profile}const s=2*e,u=e*r*2,y=u+s;let P=-2*u-s;switch(o.cap){case"none":break;case"butt":case"square":P+=2*(e-1);break;case"round":P+=2*(e*(a-1)*2+e);break;default:return}return new b({verticesPerFeature:P,verticesPerCoordinate:y,memory:c})}case"text":{const e="label-3d"===s.type?0:2;return new b({verticesPerFeature:6,memory:c,drawCallsPerFeature:e})}case"icon":return new b({verticesPerFeature:6,memory:c});default:return}}function d(e,r){const t="point-3d"===e.type;switch(r.type){case"extrude":return r.edges&&r.edges.size>0?p.EXTRUDE_EDGES:p.EXTRUDE;case"fill":return null!=r.outline&&r.outline.size>0?p.FILL_OUTLINE:p.FILL;case"water":return p.FILL;case"line":return"round"===r.join?p.LINE_ROUND:p.LINE_MITER;case"path":switch(r.join){case"round":switch(r.profile){case"circle":return p.PATH_ROUND_CIRCLE;case"quad":return p.PATH_ROUND_QUAD;default:return void r.profile}case"miter":case"bevel":switch(r.profile){case"circle":return p.PATH_MITER_CIRCLE;case"quad":return p.PATH_MITER_QUAD;default:return void r.profile}default:return}case"object":return t?p.OBJECT_POINT:p.OBJECT_POLYGON;case"icon":case"text":return t?p.ICON_POINT:p.ICON_POLYGON;default:return}}function m(e){const r=l[e];if(r)return r;const t=L(s(e,new c({},{spherical:!0})).levels);return l[e]=new b({verticesPerFeature:t}),l[e]}function L(e){return e.reduce((e,r,t)=>e+r.numVertices*(1/10**t),0)/e.reduce((e,r,t)=>e+1/10**t,0)}const p={ICON_POINT:{bytesPerFeature:2604,bytesPerFeatureLabel:3465,resourceBytes:0,draped:{bytesPerFeature:1781,bytesPerFeatureLabel:3456}},ICON_POLYGON:{bytesPerFeature:3198,bytesPerFeatureLabel:2941,resourceBytes:0,draped:{bytesPerFeature:2308,bytesPerFeatureLabel:3006}},OBJECT_POINT:{bytesPerFeature:877,bytesPerFeatureLabel:2952,resourceBytes:0,draped:{bytesPerFeature:877,bytesPerFeatureLabel:2952}},OBJECT_POLYGON:{bytesPerFeature:1307,bytesPerFeatureLabel:2520,resourceBytes:0,draped:{bytesPerFeature:1307,bytesPerFeatureLabel:2520}},LINE_MITER:{bytesPerFeature:2544,bytesPerFeatureLabel:2677,resourceBytes:0,draped:{bytesPerFeature:1924,bytesPerFeatureLabel:2664}},LINE_ROUND:{bytesPerFeature:2564,bytesPerFeatureLabel:2679,resourceBytes:0,draped:{bytesPerFeature:1928,bytesPerFeatureLabel:2673}},PATH_MITER_CIRCLE:{bytesPerFeature:13378,bytesPerFeatureLabel:2656,resourceBytes:0,draped:{bytesPerFeature:13378,bytesPerFeatureLabel:2656}},PATH_ROUND_CIRCLE:{bytesPerFeature:13524,bytesPerFeatureLabel:2686,resourceBytes:0,draped:{bytesPerFeature:13524,bytesPerFeatureLabel:2686}},PATH_MITER_QUAD:{bytesPerFeature:15185,bytesPerFeatureLabel:2993,resourceBytes:0,draped:{bytesPerFeature:15185,bytesPerFeatureLabel:2993}},PATH_ROUND_QUAD:{bytesPerFeature:13151,bytesPerFeatureLabel:2986,resourceBytes:0,draped:{bytesPerFeature:13151,bytesPerFeatureLabel:2986}},FILL:{bytesPerFeature:3514,bytesPerFeatureLabel:2845,resourceBytes:0,draped:{bytesPerFeature:2733,bytesPerFeatureLabel:2837}},FILL_OUTLINE:{bytesPerFeature:3618,bytesPerFeatureLabel:2593,resourceBytes:0,draped:{bytesPerFeature:2828,bytesPerFeatureLabel:2583}},EXTRUDE:{bytesPerFeature:5657,bytesPerFeatureLabel:2569,resourceBytes:0,draped:{bytesPerFeature:5657,bytesPerFeatureLabel:2569}},EXTRUDE_EDGES:{bytesPerFeature:3074,bytesPerFeatureLabel:2172,resourceBytes:0,draped:{bytesPerFeature:3074,bytesPerFeatureLabel:2172}}};if(has("esri-tests-disable-symbol-memory-estimators"))for(const f in p){const e=p[f];e.bytesPerFeature=0,e.bytesPerFeatureLabel=0,e.draped.bytesPerFeature=0,e.draped.bytesPerFeatureLabel=0}export{n as aggregateSymbolComplexity,i as defaultSymbolComplexity,F as defaultSymbolLayerComplexity,d as defaultSymbolLayerMemoryComplexity,P as emptySymbolComplexity,L as estimateNumVerticesForLods,p as memoryEstimators};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as t}from"tslib";import{acosClamped as i,clamp as s}from"../../../../core/mathUtils.js";import{createScreenPointArray as r}from"../../../../core/screenUtils.js";import{property as e,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{fromRotation as a,rotate as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as h}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{copy as p}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{
|
|
2
|
+
import{__decorate as t}from"tslib";import{acosClamped as i,clamp as s}from"../../../../core/mathUtils.js";import{createScreenPointArray as r}from"../../../../core/screenUtils.js";import{property as e,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{fromRotation as a,rotate as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as h}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{copy as p}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{exactEquals as c,copy as l,subtract as _,length as v,normalize as P,add as f,scale as w,dot as u,cross as C,transformMat4 as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{applyAll as x}from"../../camera/constraintUtils.js";import{ConstraintOptions as y}from"../../camera/constraintUtils/ConstraintOptions.js";import{getVoxelWasm as b}from"../../layers/VoxelWasm.js";import{TiltRange as j}from"../Constraints.js";import{InteractiveController as R}from"./InteractiveController.js";import{excludeTerrain as M,normalizeCoordinate as U,getTiltScaleFactor as V,maxRotatePivotDistanceModifier as D,minRotatePivotDistance as O,inferNavigationMode as T,rotatePivotSearchAreaSize as A}from"../utils/navigationUtils.js";let H=class extends R{get _intersectionHelper(){return this.view.sceneIntersectionHelper}constructor(t){super(t),this.pivot=0,this._rotScale=0,this._lastPoint=m(),this._tmpWorldUp=g(),this._tmpViewDir=g(),this._tmpRotCurPoint=m(),this._tmpTransf=h(),this._tmpAxis=g(),this._tmpPivotPoint=g(),this._pivotPos=g(),this._constraintOptions=new y(15,2,0,this.startCamera)}initialize(){this._rotScale=0===this.pivot?3:1.5}begin(t){if(this.running){switch(this.pivot){case 1:l(this._pivotPos,this.startCamera.eye),this._constraintOptions.interactionType=3,this._constraintOptions.tiltMode=1,this._constraintOptions.selection=0;break;case 0:{const i=this._intersectionHelper.intersectRayFreePointFallback(this.startCamera.ray,this._pivotPos,this.view.basemapTerrain.invisible?M:{})&&!c(this.startCamera.eye,this._pivotPos);i||l(this._pivotPos,this.startCamera.center),this._constrainPivotPoint(t,i),this.startCamera.center=this._pivotPos,this._constraintOptions.interactionType=2,this._constraintOptions.tiltMode=0,this._constraintOptions.selection=11;break}}U(this.startCamera,t,this._lastPoint)}}_constrainPivotPoint(t,i){const s=this.startCamera,e=g();_(e,this._pivotPos,s.eye);const o=v(e),a=Math.abs(this.view.camera.position.z);this.view.renderCoordsHelper.worldUpAtPosition(s.eye,F);let n=Math.max(V(F,s.viewForward,D)*a,O);i&&(n=Math.min(o,n));const h=r(s.width/s.pixelRatio*.5,s.height/s.pixelRatio*.5),p=T(this.startCamera,h,this.view.renderCoordsHelper,this.view.viewingMode);let m=this.view.stage.renderView.getMinimalDepthForArea(b(this.view),s.fullWidth/s.pixelRatio*.5,s.fullHeight/s.pixelRatio*.5,s,2.5*A,A),c=this.view.stage.renderView.getMinimalDepthForArea(b(this.view),t[0],t[1],s,A);null==m&&null==c||(m=m??c??0,c=null==c||1===p?m:c,n=m>c?c:m,n=i?Math.min(n,o):n),P(e,e),l(this._pivotPos,f(this._tmpPivotPoint,s.eye,w(this._tmpPivotPoint,e,n)))}update(t){if(this.running){switch(this.pivot){case 1:this.currentCamera.center=this._applyRotation(this.currentCamera,t,this.currentCamera.center,this._pivotPos);break;case 0:this.currentCamera.center=this._pivotPos,this.currentCamera.eye=this._applyRotation(this.currentCamera,t,this.currentCamera.eye,this._pivotPos)}x(this.view,this.currentCamera,this._constraintOptions),this.commitCamera()}}end(){this.running&&this.finishController()}_applyRotation(t,r,e,o){this.view.renderCoordsHelper.worldUpAtPosition(o,this._tmpWorldUp),U(t,r,this._tmpRotCurPoint);let h=(this._lastPoint[1]-this._tmpRotCurPoint[1])*this._rotScale,m=(this._tmpRotCurPoint[0]-this._lastPoint[0])*this._rotScale;_(this._tmpViewDir,e,o);const c=v(this._tmpViewDir),l=i(u(this._tmpViewDir,this._tmpWorldUp)/c);if(1===this.pivot){h*=-.5;const t=.5*Math.PI-l,i=.5*Math.PI*.99;h=t-Math.max(-i,Math.min(i,t+h))}return h=s(h+l,j.min,j.max)-l,C(this._tmpAxis,t.up,this._tmpViewDir),0===this.pivot&&(m=-m),a(this._tmpTransf,m,this._tmpWorldUp),n(this._tmpTransf,this._tmpTransf,h,this._tmpAxis),d(this._tmpViewDir,this._tmpViewDir,this._tmpTransf),t.up=d(W,t.up,this._tmpTransf),f(W,o,this._tmpViewDir),p(this._lastPoint,this._tmpRotCurPoint),W}};t([e()],H.prototype,"pivot",void 0),H=t([o("esri.views.3d.state.controllers.RotateController")],H);const W=g(),F=g();export{H as RotateController};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{cyclicalPI as t}from"../../../../core/Cyclical.js";import{deg2rad as e,clamp as n,acosClamped as r,asinClamped as o}from"../../../../core/mathUtils.js";import{createScreenPointArray as i}from"../../../../core/screenUtils.js";import{fromRotation as a,exactEquals as s,rotate as c,multiply as u}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as l,create as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as f}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{length as h,dot as M,subtract as g,normalize as y,squaredDistance as d,copy as b,transformMat4 as x,add as j,distance as v,cross as w,scale as P,lerp as z,crossAndNormalize as I,scaleAndAdd as S,set as T}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as A}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as R,axis as q,fromPoints as F,wrapAxisAngle as H}from"../../../../geometry/support/axisAngle.js";import{coordinateSystemFromOneAxisAndNormalVector as U,vectorCoordinates as G}from"../../../../geometry/support/coordinateSystem.js";import{create as k,fromNormalAndOffset as E,intersectRay as C,fromPositionAndNormal as O,distance as W,projectPoint as B,projectVector as D}from"../../../../geometry/support/plane.js";import{create as J}from"../../../../geometry/support/ray.js";import{Sphere as K}from"../../../../geometry/support/sphere.js";import{sm4d as L,sv3d as N}from"../../../../geometry/support/vectorStacks.js";import{fromScreenAtEye as Q,fromScreen as V}from"../../support/geometryUtils/ray.js";import{intersectScreen as X}from"../../support/geometryUtils/sphere.js";import Y from"../../webgl/RenderCamera.js";import{terrainId as Z}from"../../webgl-engine/lib/verticalOffsetUtils.js";const $=30,_=[1,3e8],tt=8,et=[200,1508e5],nt=5,rt=50,ot=5,it=10,at=80,st=90,ct=1e-6,ut={exclude:new Set([Z])};function lt(t,e,n){return n[0]=e[0]/(t.fullWidth/t.pixelRatio),n[1]=e[1]/(t.fullHeight/t.pixelRatio),n}function mt(t){for(;t>Math.PI;)t-=2*Math.PI;for(;t<-Math.PI;)t+=2*Math.PI;return t}function ft(t,e,n){const r=a(L.get(),n[3],q(n));null==r||s(r,l)||(g(Fe,t.eye,e),x(Fe,Fe,r),t.eye=j(Fe,Fe,e),g(Fe,t.center,e),x(Fe,Fe,r),t.center=j(Fe,Fe,e),t.up=x(Fe,t.up,r))}function pt(t,e,n,r){return C(t,V(e,n,Ce),r)}function ht(t,e,n,r){return C(t,Q(e,n,Ce),r)}function Mt(t,e,n,r){const o=N.get();let i=1-n;g(o,e,t.eye);const a=h(o);let s=a*(1-i);i>=0&&s<r&&(s=r,i=-(s-a)/a),Math.abs(a-s)<ct||(P(o,o,i),t.eye=j(Fe,t.eye,o),t.center=z(Fe,t.center,e,i))}function gt(t,e,n){e.getScreenCenter(yt),X(t,e,yt,Fe)&&(e.center=Fe);const r=e.distance,o=r*n;if(Math.abs(r-o)<ct)return;const i=P(N.get(),e.viewForward,o);e.eye=g(Fe,e.center,i)}const yt=i();function dt(t,e){T(e,0,0,0);for(const n of t)j(e,e,n);P(e,e,1/t.length)}function bt(t,e,n,r){return Math.sin(t/h(e))*(n+r.radius)}function xt(t,e,n,r){return bt(Math.PI/2,e,n,r)+(t-Math.PI/2)}const jt={Elevation:3e4,Angle:e(16)},vt=e(80);function wt(t,e,n,r,o,i){const a=A(),s=new K;let c=!0,u=!0;const{eye:l}=e;return t.intersectScreen(n,a,i)&&ye(l,a,r)?s.radius=h(a):(u=!1,e.aboveGround&&0!==o?s.radius=Math.max(h(e.center),.9*r):s.radius=h(e.eye)-e.relativeElevation,1===o?St(s,e,n,a):c=X(s,e,n,a)),{sphere:s,scenePickPoint:c?a:null,hasGeometryIntersection:u}}function Pt(t,e,n,r){const o=t.relativeElevation;if(o>jt.Elevation&&"global"===r)return 1;Q(t,e,Oe);const i=Math.sign(o),a=n.worldUpAtPosition(t.eye,Fe);return-i*M(a,Oe.direction)<Math.sin(jt.Angle)*h(Oe.direction)?0:1}function zt(t,e,n){g(It,n,e),t.eye=g(Fe,t.eye,It),t.center=g(Fe,t.center,It)}const It=A();function St(t,e,n,r){const o=Q(e,n,Ce);return null!=o&&(t.closestPointOnSilhouette(o,Tt),t.intersectRay(o,r)?!(d(Tt,o.origin)<d(r,o.origin))||(b(r,Tt),!1):(g(At,e.eye,e.center),y(At,At),E(At,-M(y(At,At),Tt),Rt),C(Rt,o,r),!1))}const Tt=A(),At=A(),Rt=k(),qt=A(),Ft=A(),Ht=i();function Ut(t,e){return D(e,t.viewForward,qt),j(Ft,t.eye,qt),t.projectToScreen(Ft,Ht),Ht[1]}const Gt=A(),kt=k(),Et=A(),Ct=A(),Ot=A(),Wt=A(),Bt=A(),Dt=A(),Jt=A(),Kt=A(),Lt=i(),Nt=J();function Qt(t,e,n){const r=t.eye;if(v(e.center,r)<e.radius)return null;const o=t.up;Q(t,n,Nt);const i=e.radius;if(I(Gt,o,Nt.direction),O(r,Gt,kt),W(kt,e.center)>i)return null;B(kt,e.center,Et);const a=v(e.center,Et),s=Math.sqrt(i**2-a**2);g(Ct,r,Et),y(Ot,Ct),I(Wt,Gt,Ot);const c=M(Ct,Ot),u=M(Ct,Wt),l=Math.sqrt(c**2+u**2),m=s**2/l**2,f=s/l**2*Math.sqrt(l**2-s**2),p=m*c,h=f*-u,d=m*u,b=f*c,x=p-h,w=d+b,z=d-b;j(Bt,Et,S(Bt,P(Bt,Ot,p+h),Wt,w)),j(Dt,Et,S(Dt,P(Dt,Ot,x),Wt,z)),g(Jt,Bt,r),y(Jt,Jt),g(Kt,Dt,r),y(Kt,Kt);return M(t.viewForward,Jt)>=M(t.viewForward,Kt)?t.projectToScreen(Bt,Lt):t.projectToScreen(Dt,Lt),Lt[1]}function Vt(t,e,n){return e?t>n:t<n}const Xt=.05,Yt=12;function Zt(t,e){const n=t.fullHeight/t.pixelRatio,r=Math.max(e,n-e);return Math.max(Yt,Xt*r)}function $t(t,e){const n=t.fullHeight/t.pixelRatio;return Math.min(n,e+Zt(t,e))}function _t(t,e){return Math.max(0,e-Zt(t,e))}function te(i,a,s,c,u,l){let m=0;if(w(Ge,i,a),g(He,i,a),h(i)<=u||!c.aboveGround){w(s,He,c.eye);const f=M(i,a)/(h(i)*h(a));if(f<.9999)m=r(f);else{const t=h(w(A(),i,a))/(h(i)*h(a));m=o(t)}const p=Math.cos(n(t.normalize(e(l)),0,vt));m=-m-Math.max(0,h(a)-u)/(p*u)}else g(ee,c.eye,c.center),w(s,He,ee),m=-h(He)/u;return y(s,s),P(s,s,h(Ge)),m}const ee=A();function ne(o,i,a,s){let c,u;const l=Math.cos(n(t.normalize(e(s)),0,vt));return c=i>a?-(i-a)/(l*a):i<-a?Math.PI-(i+a)/(l*a):r(i/a),u=o>a?-(o-a)/(l*a):o<-a?Math.PI-(o+a)/(l*a):r(o/a),(u-c)*a}function re(t,e,n,r,o,i,a,s,c,u){const l=ne(t[2],e[2],i.radius,s),m=c?ne(t[0],e[0],i.radius,180):e[0]-t[0],p=Math.sin(a)*m-Math.cos(a)*l,h=Math.cos(a)*m+Math.sin(a)*l;y(Fe,o);const g=c?p/Math.sqrt(Math.abs(i.radius**2-M(n,Fe)**2)):p/i.radius,d=h/Math.sqrt(Math.abs(i.radius**2-M(n,r)**2));f(u,g,d)}function oe(t,e,n,r,o,i,a,s,c,u){w(Ge,t,e),U(i.up,i.eye,je,ve,we),U([0,0,1],i.eye,de,be,xe),b(n,be),b(r,de),y(n,n),P(n,n,h(Ge)),G(t,y(ve,ve),y(we,we),y(je,je),Pe),G(e,ve,we,je,ze),re(Pe,ze,t,de,be,a,s,c,u,o)}function ie(t,e,n,r,o,i,s){a(Te,o,r),a(Ae,s,i),u(Re,Te,Ae),g(e,t,n),x(e,e,Re),j(e,e,n)}function ae(t,e,n,r,o,i){a(Te,r,n),a(Ae,i,o),u(Re,Te,Ae),g(Fe,t.eye,e),x(Fe,Fe,Re),t.eye=j(Fe,Fe,e),g(Fe,t.center,e),x(Fe,Fe,Re),t.center=j(Fe,Fe,e),g(Fe,t.up,e),x(Fe,Fe,Re),t.up=j(Fe,Fe,e)}const se={Pole:.95,Angle:e(18),Tilt:45,TiltHysteresisMargin:1e-7};let ce=!1;function ue(t,e,n,r,o,i){const a=Math.abs(r)>Math.PI-se.Angle||Math.abs(r)<se.Angle,s=(Math.abs(t[2])<n*se.Pole||Math.abs(e)>n)&&i;return a&&s?!ce&&o<se.Tilt-se.TiltHysteresisMargin?ce=!0:ce&&o>se.Tilt+se.TiltHysteresisMargin&&(ce=!1):ce=!1,ce}function le(t,e,n,r,o,i){if(i)F(n,r,Se),ft(e,t.center,Se);else{const i=te(n,r,ke,e,t.radius,o);ft(e,t.center,H(ke,i))}}function me(t,e,n,r,o,i,a){const s=a?20:1,c=1e-12;let u,l;b(qe,r),Ue.copyFrom(e);for(let m=0;m<s&&d(n,qe)>c&&(u=d(n,qe),oe(n,qe,be,de,Ie,Ue,t,o,i,a),ae(Ue,t.center,de,Ie[1],be,Ie[0]),ie(qe,qe,t.center,de,Ie[1],be,Ie[0]),l=d(n,qe),l<u||0===m);m++)e.copyFrom(Ue)}function fe(n,r,o,i,a,s,c){ue(o,M(r.up,o),n.radius,-t.normalize(e(a)),s,r.aboveGround)?me(n,r,o,i,-t.normalize(e(a)),s,c):le(n,r,o,i,s,c)}function pe(t,e,n,r,o,i){const{eye:a}=t;U([0,0,1],a,de,be,xe);const s=e.translation[0]*n.pan,u="zoom"===o.mode?0:e.translation[1]*n.pan,l=Math.max(Math.sqrt(Math.abs(1-M(t.center,de)**2/h(t.center)**2)),.5),m=(Math.sin(i)*u+Math.cos(i)*s)/l,f=-Math.cos(i)*u+Math.sin(i)*s;switch(c(r.pan.matrix,r.pan.matrix,m,de),r.pan.enabled=!0,o.mode){case"pan":c(r.pan.matrix,r.pan.matrix,f,be),r.pan.enabled=!0;break;case"zoom":r.zoom=-e.translation[1]*n.zoom}}function he(t,e,n,r,o){const{eye:i,viewRight:a}=t,s=w(N.get(),a,i),u=e.translation[0]*n.pan;switch(0!==u&&(c(r.pan.matrix,r.pan.matrix,-u,s),r.pan.enabled=!0),o.mode){case"pan":{const t=e.translation[1]*n.pan;0!==t&&(c(r.pan.matrix,r.pan.matrix,t,a),r.pan.enabled=!0);break}case"zoom":r.zoom=-e.translation[1]*n.zoom}}function Me(n,r,o,i,a,s,c,u,l){ue(n.center,M(n.up,n.center),h(n.center),-t.normalize(e(s)),c,r.aboveGround)?pe(r,o,i,u,l,-t.normalize(e(a))):he(r,o,i,u,l)}function ge(t,e,n=1/0){const r=Math.abs(M(t,e));return Math.min(n,1/r)}function ye(t,e,n){const r=v(t,e),o=h(t);return r<Math.max(o,n)}const de=A(),be=A(),xe=A(),je=A(),ve=A(),we=A(),Pe=A(),ze=A(),Ie=p(),Se=R(),Te=m(),Ae=m(),Re=m(),qe=A(),Fe=A(),He=A();let Ue=new Y;const Ge=A(),ke=A();function Ee(){Ue=new Y}const Ce={origin:A(),direction:A()},Oe={origin:A(),direction:A()};export{vt as TiltThresholdPanningSpeed,jt as VerticalPanTresholds,zt as applyPanPlanar,le as applyPanSphericalDirectRotation,me as applyPanSphericalPreserveHeading,ft as applyRotation,ae as applyRotationWithTwoAxes,gt as applyZoomOnSphere,Mt as applyZoomToPoint,dt as centroid,Ee as cleanupNavigationUtils,_t as computeHorizonDownLimitScreenY,Zt as computeHorizonPadding,$t as computeHorizonUpLimitScreenY,ct as distanceComparisonTolerance,ut as excludeTerrain,Ut as findPlaneHorizonY,Qt as findSphereHorizonY,ge as getTiltScaleFactor,Pt as inferNavigationMode,pt as intersectPlaneFromScreenPoint,ht as intersectPlaneFromScreenPointAtEye,ye as isHitOnSamePlanetSide,ne as lengthFromPoints,nt as maxPanDistanceModifier,ot as maxRotatePivotDistanceModifier,$ as maxZoomPivotDistanceModifier,tt as maxZoomStepDistanceModifier,rt as minPinchAndPanCameraHeight,it as minRotatePivotDistance,lt as normalizeCoordinate,mt as normalizeRotationDelta,xt as offSurfaceTiltToEyeTiltGlobal,bt as onSurfaceTiltToEyeTiltGlobal,Me as panMotionToRotationMatrix,fe as panToPosition,wt as pickPointAndInitSphere,at as pivotSearchAreaSize,se as preservingHeadingThresholds,Xt as relativeHorizonPanPadding,st as rotatePivotSearchAreaSize,ie as rotatePointAroundTwoAxes,te as rotationAngleAndAxisDirectRotation,oe as rotationAnglesAndAxesHeadingPreserving,re as rotationAnglesHeadingPreserving,Vt as shouldClampScreenY,ue as shouldPreserveHeading,St as sphereOrPlanePointFromScreenPoint,_ as zoomPivotDistanceClamp,et as zoomStepDistanceClamp};
|
|
2
|
+
import{cyclicalPI as t}from"../../../../core/Cyclical.js";import{deg2rad as e,clamp as n,acosClamped as r,asinClamped as o}from"../../../../core/mathUtils.js";import{createScreenPointArray as i}from"../../../../core/screenUtils.js";import{fromRotation as a,exactEquals as s,rotate as c,multiply as u}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as l,create as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as f}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{exactEquals as h,length as M,dot as g,subtract as y,normalize as d,squaredDistance as b,copy as x,transformMat4 as j,add as v,distance as w,cross as P,scale as z,lerp as I,crossAndNormalize as S,scaleAndAdd as T,set as R}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as q}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as A,axis as F,fromPoints as H,wrapAxisAngle as U}from"../../../../geometry/support/axisAngle.js";import{coordinateSystemFromOneAxisAndNormalVector as E,vectorCoordinates as G}from"../../../../geometry/support/coordinateSystem.js";import{create as k,fromNormalAndOffset as C,intersectRay as O,fromPositionAndNormal as W,distance as B,projectPoint as D,projectVector as J}from"../../../../geometry/support/plane.js";import{create as K}from"../../../../geometry/support/ray.js";import{Sphere as L}from"../../../../geometry/support/sphere.js";import{sm4d as N,sv3d as Q}from"../../../../geometry/support/vectorStacks.js";import{fromScreenAtEye as V,fromScreen as X}from"../../support/geometryUtils/ray.js";import{intersectScreen as Y}from"../../support/geometryUtils/sphere.js";import Z from"../../webgl/RenderCamera.js";import{terrainId as $}from"../../webgl-engine/lib/verticalOffsetUtils.js";const _=30,tt=[1,3e8],et=8,nt=[200,1508e5],rt=5,ot=50,it=5,at=10,st=80,ct=90,ut=1e-6,lt={exclude:new Set([$])};function mt(t,e,n){return n[0]=e[0]/(t.fullWidth/t.pixelRatio),n[1]=e[1]/(t.fullHeight/t.pixelRatio),n}function ft(t){for(;t>Math.PI;)t-=2*Math.PI;for(;t<-Math.PI;)t+=2*Math.PI;return t}function pt(t,e,n){const r=a(N.get(),n[3],F(n));null==r||s(r,l)||(y(Ee,t.eye,e),j(Ee,Ee,r),t.eye=v(Ee,Ee,e),y(Ee,t.center,e),j(Ee,Ee,r),t.center=v(Ee,Ee,e),t.up=j(Ee,t.up,r))}function ht(t,e,n,r){return O(t,X(e,n,Be),r)}function Mt(t,e,n,r){return O(t,V(e,n,Be),r)}function gt(t,e,n,r){const o=Q.get();let i=1-n;y(o,e,t.eye);const a=M(o);let s=a*(1-i);i>=0&&s<r&&(s=r,i=-(s-a)/a),Math.abs(a-s)<ut||(z(o,o,i),t.eye=v(Ee,t.eye,o),t.center=I(Ee,t.center,e,i))}function yt(t,e,n){e.getScreenCenter(dt),Y(t,e,dt,Ee)&&(e.center=Ee);const r=e.distance,o=r*n;if(Math.abs(r-o)<ut)return;const i=z(Q.get(),e.viewForward,o);e.eye=y(Ee,e.center,i)}const dt=i();function bt(t,e){R(e,0,0,0);for(const n of t)v(e,e,n);z(e,e,1/t.length)}function xt(t,e,n,r){return Math.sin(t/M(e))*(n+r.radius)}function jt(t,e,n,r){return xt(Math.PI/2,e,n,r)+(t-Math.PI/2)}const vt={Elevation:3e4,Angle:e(16)},wt=e(80);function Pt(t,e,n,r,o,i){const a=q(),s=new L;let c=!0,u=!0;const{eye:l}=e;return t.intersectScreen(n,a,i)&&!h(l,a)&&xe(l,a,r)?s.radius=M(a):(u=!1,e.aboveGround&&0!==o?s.radius=Math.max(M(e.center),.9*r):s.radius=M(e.eye)-e.relativeElevation,1===o?Tt(s,e,n,a):c=Y(s,e,n,a)),{sphere:s,scenePickPoint:c?a:null,hasGeometryIntersection:u}}function zt(t,e,n,r){const o=t.relativeElevation;if(o>vt.Elevation&&"global"===r)return 1;V(t,e,De);const i=Math.sign(o),a=n.worldUpAtPosition(t.eye,Ee);return-i*g(a,De.direction)<Math.sin(vt.Angle)*M(De.direction)?0:1}function It(t,e,n){y(St,n,e),t.eye=y(Ee,t.eye,St),t.center=y(Ee,t.center,St)}const St=q();function Tt(t,e,n,r){const o=V(e,n,Be);return null!=o&&(t.closestPointOnSilhouette(o,Rt),t.intersectRay(o,r)?!(b(Rt,o.origin)<b(r,o.origin))||(x(r,Rt),!1):(y(qt,e.eye,e.center),d(qt,qt),C(qt,-g(d(qt,qt),Rt),At),O(At,o,r),!1))}const Rt=q(),qt=q(),At=k(),Ft=q(),Ht=q(),Ut=i();function Et(t,e){return J(e,t.viewForward,Ft),v(Ht,t.eye,Ft),t.projectToScreen(Ht,Ut),Ut[1]}const Gt=q(),kt=k(),Ct=q(),Ot=q(),Wt=q(),Bt=q(),Dt=q(),Jt=q(),Kt=q(),Lt=q(),Nt=q(),Qt=q(),Vt=i(),Xt=K();function Yt(t,e,n){const r=t.eye;if(w(e.center,r)<e.radius)return d(Dt,r),P(Jt,Dt,t.viewRight),v(Ht,r,Jt),t.projectToScreen(Ht,Vt),Vt[1];const o=t.up;V(t,n,Xt);const i=e.radius;if(S(Gt,o,Xt.direction),W(r,Gt,kt),B(kt,e.center)>i)return null;D(kt,e.center,Ct);const a=w(e.center,Ct),s=Math.sqrt(i**2-a**2);y(Ot,r,Ct),d(Wt,Ot),S(Bt,Gt,Wt);const c=g(Ot,Wt),u=g(Ot,Bt),l=Math.sqrt(c**2+u**2),m=s**2/l**2,f=s/l**2*Math.sqrt(l**2-s**2),p=m*c,h=f*-u,M=m*u,b=f*c,x=p-h,j=M+b,I=M-b;v(Kt,Ct,T(Kt,z(Kt,Wt,p+h),Bt,j)),v(Lt,Ct,T(Lt,z(Lt,Wt,x),Bt,I)),y(Nt,Kt,r),d(Nt,Nt),y(Qt,Lt,r),d(Qt,Qt);return g(t.viewForward,Nt)>=g(t.viewForward,Qt)?t.projectToScreen(Kt,Vt):t.projectToScreen(Lt,Vt),Vt[1]}function Zt(t,e,n){return e?t>n:t<n}const $t=.05,_t=12;function te(t,e){const n=t.fullHeight/t.pixelRatio,r=Math.max(e,n-e);return Math.max(_t,$t*r)}function ee(t,e){const n=t.fullHeight/t.pixelRatio;return Math.min(n,e+te(t,e))}function ne(t,e){return Math.max(0,e-te(t,e))}function re(i,a,s,c,u,l){let m=0;if(P(Ce,i,a),y(Ge,i,a),M(i)<=u||!c.aboveGround){P(s,Ge,c.eye);const f=g(i,a)/(M(i)*M(a));if(f<.9999)m=r(f);else{const t=M(P(q(),i,a))/(M(i)*M(a));m=o(t)}const p=Math.cos(n(t.normalize(e(l)),0,wt));m=-m-Math.max(0,M(a)-u)/(p*u)}else y(oe,c.eye,c.center),P(s,Ge,oe),m=-M(Ge)/u;return d(s,s),z(s,s,M(Ce)),m}const oe=q();function ie(o,i,a,s){let c,u;const l=Math.cos(n(t.normalize(e(s)),0,wt));return c=i>a?-(i-a)/(l*a):i<-a?Math.PI-(i+a)/(l*a):r(i/a),u=o>a?-(o-a)/(l*a):o<-a?Math.PI-(o+a)/(l*a):r(o/a),(u-c)*a}function ae(t,e,n,r,o,i,a,s,c,u){const l=ie(t[2],e[2],i.radius,s),m=c?ie(t[0],e[0],i.radius,180):e[0]-t[0],p=Math.sin(a)*m-Math.cos(a)*l,h=Math.cos(a)*m+Math.sin(a)*l;d(Ee,o);const M=c?p/Math.sqrt(Math.abs(i.radius**2-g(n,Ee)**2)):p/i.radius,y=h/Math.sqrt(Math.abs(i.radius**2-g(n,r)**2));f(u,M,y)}function se(t,e,n,r,o,i,a,s,c,u){P(Ce,t,e),E(i.up,i.eye,Pe,ze,Ie),E([0,0,1],i.eye,je,ve,we),x(n,ve),x(r,je),d(n,n),z(n,n,M(Ce)),G(t,d(ze,ze),d(Ie,Ie),d(Pe,Pe),Se),G(e,ze,Ie,Pe,Te),ae(Se,Te,t,je,ve,a,s,c,u,o)}function ce(t,e,n,r,o,i,s){a(Ae,o,r),a(Fe,s,i),u(He,Ae,Fe),y(e,t,n),j(e,e,He),v(e,e,n)}function ue(t,e,n,r,o,i){a(Ae,r,n),a(Fe,i,o),u(He,Ae,Fe),y(Ee,t.eye,e),j(Ee,Ee,He),t.eye=v(Ee,Ee,e),y(Ee,t.center,e),j(Ee,Ee,He),t.center=v(Ee,Ee,e),y(Ee,t.up,e),j(Ee,Ee,He),t.up=v(Ee,Ee,e)}const le={Pole:.95,Angle:e(18),Tilt:45,TiltHysteresisMargin:1e-7};let me=!1;function fe(t,e,n,r,o,i){const a=Math.abs(r)>Math.PI-le.Angle||Math.abs(r)<le.Angle,s=(Math.abs(t[2])<n*le.Pole||Math.abs(e)>n)&&i;return a&&s?!me&&o<le.Tilt-le.TiltHysteresisMargin?me=!0:me&&o>le.Tilt+le.TiltHysteresisMargin&&(me=!1):me=!1,me}function pe(t,e,n,r,o,i){if(i)H(n,r,qe),pt(e,t.center,qe);else{const i=re(n,r,Oe,e,t.radius,o);pt(e,t.center,U(Oe,i))}}function he(t,e,n,r,o,i,a){const s=a?20:1,c=1e-12;let u,l;x(Ue,r),ke.copyFrom(e);for(let m=0;m<s&&b(n,Ue)>c&&(u=b(n,Ue),se(n,Ue,ve,je,Re,ke,t,o,i,a),ue(ke,t.center,je,Re[1],ve,Re[0]),ce(Ue,Ue,t.center,je,Re[1],ve,Re[0]),l=b(n,Ue),l<u||0===m);m++)e.copyFrom(ke)}function Me(n,r,o,i,a,s,c){fe(o,g(r.up,o),n.radius,-t.normalize(e(a)),s,r.aboveGround)?he(n,r,o,i,-t.normalize(e(a)),s,c):pe(n,r,o,i,s,c)}function ge(t,e,n,r,o,i){const{eye:a}=t;E([0,0,1],a,je,ve,we);const s=e.translation[0]*n.pan,u="zoom"===o.mode?0:e.translation[1]*n.pan,l=Math.max(Math.sqrt(Math.abs(1-g(t.center,je)**2/M(t.center)**2)),.5),m=(Math.sin(i)*u+Math.cos(i)*s)/l,f=-Math.cos(i)*u+Math.sin(i)*s;switch(c(r.pan.matrix,r.pan.matrix,m,je),r.pan.enabled=!0,o.mode){case"pan":c(r.pan.matrix,r.pan.matrix,f,ve),r.pan.enabled=!0;break;case"zoom":r.zoom=-e.translation[1]*n.zoom}}function ye(t,e,n,r,o){const{eye:i,viewRight:a}=t,s=P(Q.get(),a,i),u=e.translation[0]*n.pan;switch(0!==u&&(c(r.pan.matrix,r.pan.matrix,-u,s),r.pan.enabled=!0),o.mode){case"pan":{const t=e.translation[1]*n.pan;0!==t&&(c(r.pan.matrix,r.pan.matrix,t,a),r.pan.enabled=!0);break}case"zoom":r.zoom=-e.translation[1]*n.zoom}}function de(n,r,o,i,a,s,c,u,l){fe(n.center,g(n.up,n.center),M(n.center),-t.normalize(e(s)),c,r.aboveGround)?ge(r,o,i,u,l,-t.normalize(e(a))):ye(r,o,i,u,l)}function be(t,e,n=1/0){const r=Math.abs(g(t,e));return Math.min(n,1/r)}function xe(t,e,n){const r=w(t,e),o=M(t);return r<Math.max(o,n)}const je=q(),ve=q(),we=q(),Pe=q(),ze=q(),Ie=q(),Se=q(),Te=q(),Re=p(),qe=A(),Ae=m(),Fe=m(),He=m(),Ue=q(),Ee=q(),Ge=q();let ke=new Z;const Ce=q(),Oe=q();function We(){ke=new Z}const Be={origin:q(),direction:q()},De={origin:q(),direction:q()};export{wt as TiltThresholdPanningSpeed,vt as VerticalPanTresholds,It as applyPanPlanar,pe as applyPanSphericalDirectRotation,he as applyPanSphericalPreserveHeading,pt as applyRotation,ue as applyRotationWithTwoAxes,yt as applyZoomOnSphere,gt as applyZoomToPoint,bt as centroid,We as cleanupNavigationUtils,ne as computeHorizonDownLimitScreenY,te as computeHorizonPadding,ee as computeHorizonUpLimitScreenY,ut as distanceComparisonTolerance,lt as excludeTerrain,Et as findPlaneHorizonY,Yt as findSphereHorizonY,be as getTiltScaleFactor,zt as inferNavigationMode,ht as intersectPlaneFromScreenPoint,Mt as intersectPlaneFromScreenPointAtEye,xe as isHitOnSamePlanetSide,ie as lengthFromPoints,rt as maxPanDistanceModifier,it as maxRotatePivotDistanceModifier,_ as maxZoomPivotDistanceModifier,et as maxZoomStepDistanceModifier,ot as minPinchAndPanCameraHeight,at as minRotatePivotDistance,mt as normalizeCoordinate,ft as normalizeRotationDelta,jt as offSurfaceTiltToEyeTiltGlobal,xt as onSurfaceTiltToEyeTiltGlobal,de as panMotionToRotationMatrix,Me as panToPosition,Pt as pickPointAndInitSphere,st as pivotSearchAreaSize,le as preservingHeadingThresholds,$t as relativeHorizonPanPadding,ct as rotatePivotSearchAreaSize,ce as rotatePointAroundTwoAxes,re as rotationAngleAndAxisDirectRotation,se as rotationAnglesAndAxesHeadingPreserving,ae as rotationAnglesHeadingPreserving,Zt as shouldClampScreenY,fe as shouldPreserveHeading,Tt as sphereOrPlanePointFromScreenPoint,tt as zoomPivotDistanceClamp,nt as zoomStepDistanceClamp};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import{abortMaybe as t}from"../../../../core/maybe.js";import{estimateNumberArrayMemory as s}from"../../../../core/memoryEstimations.js";import{isAbortError as i}from"../../../../core/promiseUtils.js";import{signal as r}from"../../../../core/signal.js";import{Milliseconds as a,now as o}from"../../../../core/time.js";import{exactEquals as n,copy as l,normalize as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as d,exactEquals as _,intersects as c,copy as p}from"../../../../geometry/support/aaBoundingBox.js";import{makeScheduleFunction as f}from"../../layers/support/makeScheduleFunction.js";import{GaussianSplatSortWorkerHandle as m}from"../GaussianSplatWorkerHandle.js";import{GaussianSplatFadeTexture as g}from"./GaussianSplatFadeTexture.js";import{GaussianSplatHeaderTexture as T}from"./GaussianSplatHeaderTexture.js";import{GaussianSplatOrderTexture as b}from"./GaussianSplatOrderTexture.js";import{GaussianSplatTextureAtlas as S}from"./GaussianSplatTextureAtlas.js";import{DepthRange as y}from"../../webgl-engine/lib/DepthRange.js";import{TaskPriority as x}from"../../../support/Scheduler.js";class C{constructor(e,t,s){this._updating=r(!1),this._useDeterministicSort=!1,this._sortBufferMemory=0,this.visibleGaussians=0,this._visibleTileDepthRange=new y,this._previousVisibleTileDepthRangeEye=u(),this._previousVisibleTileDepthRangeViewForward=u(),this._previousVisibleTileDepthRangeClippingBox=d(),this._latestSortedGaussianTilesVersion=0,this._previousVisibleTileDepthRangeTilesVersion=-1,this._previousVisibleTileDepthRangeHasClippingBox=!1,this._bufferCapacity=0,this._requestedLyr3dVisibilityChange=0,this._latestCompletedLyr3dVisibilityChange=0,this._latestUpdatedGaussianTiles=new Array,this._latestSortedGaussianTiles=new Array,this._nextCommittedVisibleGaussianTiles=new Array,this._cameraDirectionNormalized=u(),this._frameTask=null,this._workerHandle=null,this._sortAbortController=null,this._isSorting=!1,this._pendingSortTask=!1,this._scheduledSortStartTimeout=null,this._lastSortStartTime=a(-1/0),this._sortInterval=a(80),this._renderer=e,this._onSortComplete=t,this._orderTexture=new b(this._renderer.renderingContext),this._fadingTexture=new g(this._renderer.renderingContext),this._headerTexture=new T(this._renderer.renderingContext),this._textureAtlas=new S(this._renderer.renderingContext,this._renderer.view.resourceController.memoryController,this._renderer.fboCache,s);const{resourceController:i}=this._renderer.view;this._workerHandle=new m(f(i)),this._frameTask=i.scheduler.registerTask(x.GAUSSIAN_SPLAT_SORTING)}get textureAtlas(){return this._textureAtlas}get orderTexture(){return this._orderTexture}get fadingTexture(){return this._fadingTexture}get headerTexture(){return this._headerTexture}get textureAtlasMemory(){return this._textureAtlas.usedMemory}get orderTextureMemory(){return this._orderTexture.usedMemory}get fadingTextureMemory(){return this._fadingTexture.usedMemory}get headerTextureMemory(){return this._headerTexture.usedMemory}get sortBufferMemory(){return this._sortBufferMemory}get usedMemory(){return this.textureAtlasMemory+this.headerTextureMemory+this.orderTextureMemory+this.fadingTextureMemory+this.sortBufferMemory}queryVisibleTileDepthRange(e,t){if(0===this.visibleGaussians)return null;const{eye:s,viewForward:i}=e,r=s[0],a=s[1],o=s[2],h=i[0],u=i[1],d=i[2],f=this._visibleTileDepthRange;if(this._previousVisibleTileDepthRangeTilesVersion===this._latestSortedGaussianTilesVersion&&n(this._previousVisibleTileDepthRangeEye,s)&&n(this._previousVisibleTileDepthRangeViewForward,i)&&(null==t?!this._previousVisibleTileDepthRangeHasClippingBox:this._previousVisibleTileDepthRangeHasClippingBox&&_(this._previousVisibleTileDepthRangeClippingBox,t)))return f.near<=f.far?f:null;let m=1/0,g=-1/0;const T=this._latestSortedGaussianTiles;for(let n=0;n<T.length;n++){const e=T[n];if(null!=t){const s=e.boundingBox;if(!c(s,t))continue}const s=h*(e.obbCenterX-r)+u*(e.obbCenterY-a)+d*(e.obbCenterZ-o),i=e.paddedMbsRadius,l=s-i;l<m&&(m=l);const _=s+i;_>g&&(g=_)}const b=m<=g;return b?f.set(m,g):f.set(1/0,-1/0),this._previousVisibleTileDepthRangeTilesVersion=this._latestSortedGaussianTilesVersion,this._previousVisibleTileDepthRangeHasClippingBox=null!=t,l(this._previousVisibleTileDepthRangeEye,s),l(this._previousVisibleTileDepthRangeViewForward,i),null!=t&&p(this._previousVisibleTileDepthRangeClippingBox,t),b?f:null}updateGaussianVisibility(e,t){this._latestUpdatedGaussianTiles=e,this._requestedLyr3dVisibilityChange=t,this.requestSort()}get updating(){return this._updating.value}destroy(){this._sortAbortController=t(this._sortAbortController),this._pendingSortTask=!1,this._updating.value=!1,null!=this._scheduledSortStartTimeout&&(clearTimeout(this._scheduledSortStartTimeout),this._scheduledSortStartTimeout=null),this._frameTask.remove(),this._workerHandle?.destroyWorkerAndSelf(),this._textureAtlas.destroy(),this._headerTexture.destroy(),this._orderTexture.destroy(),this._fadingTexture.destroy()}requestSort(){return this._updating.value=!0,!this._pendingSortTask&&(this._pendingSortTask=!0,this._scheduleSortStart(),!0)}_scheduleSortStart(){if(this._isSorting)return;const e=o()-this._lastSortStartTime,t=this._sortInterval-e;t<=0?this._startSortIfRequired():null==this._scheduledSortStartTimeout&&(this._scheduledSortStartTimeout=setTimeout(()=>{this._scheduledSortStartTimeout=null,this._pendingSortTask&&!this._isSorting&&this._scheduleSortStart()},t))}_startSortIfRequired(){if(this._isSorting||!this._pendingSortTask)return;const e=new AbortController;this._sortAbortController=e,this._isSorting=!0,this._pendingSortTask=!1,this._lastSortStartTime=o(),this._sortOnWorker(e.signal).finally(()=>{this._sortAbortController===e&&(this._sortAbortController=null),this._handleSortComplete()})}_handleSortComplete(){this._isSorting=!1,this._pendingSortTask?this._scheduleSortStart():this._updating.value=!1}_clearBuffersAndTextures(){this._atlasIndicesBuffer=void 0,this._sortedAtlasIndicesBuffer=void 0,this._distancesBuffer=void 0,this._bufferCapacity=0,this._sortBufferMemory=0,this._orderTexture.clear(),this._textureAtlas.clear(),this._headerTexture.clear()}_computeExpandedCapacity(t,s){let i=Math.max(1,t);for(;i<s;)i=Math.ceil(i*e);return i}_ensureSortBufferCapacities(e){if(this._bufferCapacity<e){const t=this._computeExpandedCapacity(this._bufferCapacity,e);this._atlasIndicesBuffer=new Uint32Array(t),this._sortedAtlasIndicesBuffer=new Uint32Array(t),this._distancesBuffer=new Float64Array(t),this._bufferCapacity=t,this._sortBufferMemory=s(this._atlasIndicesBuffer,this._sortedAtlasIndicesBuffer,this._distancesBuffer)}}_clearAllBuffersAndTextures(){this._clearBuffersAndTextures(),this._latestSortedGaussianTiles.length=0,this._nextCommittedVisibleGaussianTiles.length=0,this._previousVisibleTileDepthRangeTilesVersion=-1,this._workerHandle?.clear()}async _sortOnWorker(e){try{if(0===this._latestUpdatedGaussianTiles.length)return this.visibleGaussians=0,this._clearAllBuffersAndTextures(),this._latestCompletedLyr3dVisibilityChange=this._requestedLyr3dVisibilityChange,this._onSortComplete(this._latestSortedGaussianTiles,this._latestCompletedLyr3dVisibilityChange),void this._renderer.requestRender(1);this._useDeterministicSort&&this._latestUpdatedGaussianTiles.sort((e,t)=>e.obb.centerX-t.obb.centerX||e.obb.centerY-t.obb.centerY||e.obb.centerZ-t.obb.centerZ);const t=this._latestUpdatedGaussianTiles,s=t.length,i=this._requestedLyr3dVisibilityChange;let r=0;for(let e=0;e<s;e++)r+=t[e].gaussianCount;this._ensureSortBufferCapacities(r),this._textureAtlas.ensureTextureAtlas(),this._headerTexture.ensureCapacity(this._textureAtlas.pageAllocator.pageCount);const a=this._renderer.camera;h(this._cameraDirectionNormalized,a.ray.direction);const o=this._cameraDirectionNormalized[0],n=this._cameraDirectionNormalized[1],l=this._cameraDirectionNormalized[2];let u=0;const d=this._atlasIndicesBuffer,_=this._distancesBuffer,p=this._renderer.clippingBox,f=this._nextCommittedVisibleGaussianTiles;f.length=0;let m=0;const{frustum:g}=a,T=this._renderer.tileCullingRevision,b=g[0],S=g[1],y=g[2],x=g[3],C=g[4],A=g[5];for(let e=0;e<s;e++){const s=t[e],{gaussianAtlasIndices:i,relativePositions:r,obbCenterX:a,obbCenterY:h,obbCenterZ:g,paddedMbsRadius:V}=s,v=s.gaussianCount;if(s.cullingRevision!==T){let e=null==p||c(s.boundingBox,p);if(e){const t=1.5*V;e=b[0]*a+b[1]*h+b[2]*g+b[3]<t&&S[0]*a+S[1]*h+S[2]*g+S[3]<t&&y[0]*a+y[1]*h+y[2]*g+y[3]<t&&x[0]*a+x[1]*h+x[2]*g+x[3]<t&&C[0]*a+C[1]*h+C[2]*g+C[3]<t&&A[0]*a+A[1]*h+A[2]*g+A[3]<t}s.cullingRevision=T,s.cullingVisible=e}if(!s.cullingVisible)continue;d.set(i,u),f[m++]=s;const B=o*a+n*h+l*g,G=u+v;for(let e=u,t=0;e<G;e++,t+=3){const s=r[t],i=r[t+1],a=r[t+2];_[e]=s*o+i*n+a*l+B}u=G}if(f.length=m,0===u)return this.visibleGaussians=0,this._clearAllBuffersAndTextures(),this._latestCompletedLyr3dVisibilityChange=i,this._onSortComplete(this._latestSortedGaussianTiles,this._latestCompletedLyr3dVisibilityChange),void this._renderer.requestRender(1);const V={distances:this._distancesBuffer,atlasIndices:this._atlasIndicesBuffer,sortedAtlasIndices:this._sortedAtlasIndicesBuffer,numGaussians:u,preciseSort:this._useDeterministicSort},v=await(this._workerHandle?.sort(V,e));if(e.aborted)return;v&&(this._distancesBuffer=v.distances,this._atlasIndicesBuffer=v.atlasIndices,this._sortedAtlasIndicesBuffer=v.sortedAtlasIndices);const B=async e=>{this._orderTexture.setData(this._sortedAtlasIndicesBuffer,u);const t=this._latestSortedGaussianTiles;this._latestSortedGaussianTiles=f,this._nextCommittedVisibleGaussianTiles=t,this._latestSortedGaussianTilesVersion++,this._latestCompletedLyr3dVisibilityChange=i,this.visibleGaussians=u,this._onSortComplete(this._latestSortedGaussianTiles,this._latestCompletedLyr3dVisibilityChange),this._renderer.requestRender(1),e.madeProgress()};await this._frameTask.schedule(B,e)}catch(t){if(i(t))return}}set useDeterministicSort(e){this._useDeterministicSort=e}}export{C as GaussianSplatDataStore};
|
|
2
|
+
import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import{abortMaybe as t}from"../../../../core/maybe.js";import{estimateNumberArrayMemory as s}from"../../../../core/memoryEstimations.js";import{isAbortError as i}from"../../../../core/promiseUtils.js";import{signal as r}from"../../../../core/signal.js";import{Milliseconds as a,now as o}from"../../../../core/time.js";import{exactEquals as n,copy as l,normalize as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as d,exactEquals as _,intersects as c,copy as p}from"../../../../geometry/support/aaBoundingBox.js";import{makeScheduleFunction as f}from"../../layers/support/makeScheduleFunction.js";import{GaussianSplatSortWorkerHandle as m}from"../GaussianSplatWorkerHandle.js";import{GaussianSplatFadeTexture as g}from"./GaussianSplatFadeTexture.js";import{GaussianSplatHeaderTexture as T}from"./GaussianSplatHeaderTexture.js";import{GaussianSplatOrderTexture as b}from"./GaussianSplatOrderTexture.js";import{GaussianSplatTextureAtlas as S}from"./GaussianSplatTextureAtlas.js";import{DepthRange as y}from"../../webgl-engine/lib/DepthRange.js";import{TaskPriority as x}from"../../../support/Scheduler.js";class C{constructor(e,t,s){this._updating=r(!1),this._useDeterministicSort=!1,this._sortBufferMemory=0,this.visibleGaussians=0,this._visibleTileDepthRange=new y,this._previousVisibleTileDepthRangeEye=u(),this._previousVisibleTileDepthRangeViewForward=u(),this._previousVisibleTileDepthRangeClippingBox=d(),this._latestSortedGaussianTilesVersion=0,this._previousVisibleTileDepthRangeTilesVersion=-1,this._previousVisibleTileDepthRangeHasClippingBox=!1,this._bufferCapacity=0,this._requestedLyr3dVisibilityChange=0,this._latestCompletedLyr3dVisibilityChange=0,this._latestUpdatedGaussianTiles=new Array,this._latestSortedGaussianTiles=new Array,this._nextCommittedVisibleGaussianTiles=new Array,this._cameraDirectionNormalized=u(),this._frameTask=null,this._workerHandle=null,this._sortAbortController=null,this._isSorting=!1,this._pendingSortTask=!1,this._scheduledSortStartTimeout=null,this._lastSortStartTime=a(-1/0),this._sortInterval=a(80),this._renderer=e,this._onSortComplete=t,this._orderTexture=new b(this._renderer.renderingContext),this._fadingTexture=new g(this._renderer.renderingContext),this._headerTexture=new T(this._renderer.renderingContext),this._textureAtlas=new S(this._renderer.renderingContext,this._renderer.view.resourceController.memoryController,this._renderer.fboCache,s);const{resourceController:i}=this._renderer.view;this._workerHandle=new m(f(i)),this._frameTask=i.scheduler.registerTask(x.GAUSSIAN_SPLAT_SORTING)}get textureAtlas(){return this._textureAtlas}get orderTexture(){return this._orderTexture}get fadingTexture(){return this._fadingTexture}get headerTexture(){return this._headerTexture}get textureAtlasMemory(){return this._textureAtlas.usedMemory}get orderTextureMemory(){return this._orderTexture.usedMemory}get fadingTextureMemory(){return this._fadingTexture.usedMemory}get headerTextureMemory(){return this._headerTexture.usedMemory}get sortBufferMemory(){return this._sortBufferMemory}get usedMemory(){return this.textureAtlasMemory+this.headerTextureMemory+this.orderTextureMemory+this.fadingTextureMemory+this.sortBufferMemory}queryVisibleTileDepthRange(e,t){if(0===this.visibleGaussians)return null;const{eye:s,viewForward:i}=e,r=s[0],a=s[1],o=s[2],h=i[0],u=i[1],d=i[2],f=this._visibleTileDepthRange;if(this._previousVisibleTileDepthRangeTilesVersion===this._latestSortedGaussianTilesVersion&&n(this._previousVisibleTileDepthRangeEye,s)&&n(this._previousVisibleTileDepthRangeViewForward,i)&&(null==t?!this._previousVisibleTileDepthRangeHasClippingBox:this._previousVisibleTileDepthRangeHasClippingBox&&_(this._previousVisibleTileDepthRangeClippingBox,t)))return f.near<=f.far?f:null;let m=1/0,g=-1/0;const T=this._latestSortedGaussianTiles;for(let n=0;n<T.length;n++){const e=T[n];if(null!=t){const s=e.boundingBox;if(!c(s,t))continue}const s=h*(e.obbCenterX-r)+u*(e.obbCenterY-a)+d*(e.obbCenterZ-o),i=e.paddedMbsRadius,l=s-i;l<m&&(m=l);const _=s+i;_>g&&(g=_)}const b=m<=g;return b?f.set(m,g):f.set(1/0,-1/0),this._previousVisibleTileDepthRangeTilesVersion=this._latestSortedGaussianTilesVersion,this._previousVisibleTileDepthRangeHasClippingBox=null!=t,l(this._previousVisibleTileDepthRangeEye,s),l(this._previousVisibleTileDepthRangeViewForward,i),null!=t&&p(this._previousVisibleTileDepthRangeClippingBox,t),b?f:null}updateGaussianVisibility(e,t){this._latestUpdatedGaussianTiles=e,this._requestedLyr3dVisibilityChange=t,this.requestSort()}get updating(){return this._updating.value}destroy(){this._sortAbortController=t(this._sortAbortController),this._pendingSortTask=!1,this._updating.value=!1,null!=this._scheduledSortStartTimeout&&(clearTimeout(this._scheduledSortStartTimeout),this._scheduledSortStartTimeout=null),this._frameTask.remove(),this._workerHandle?.destroyWorkerAndSelf(),this._textureAtlas.destroy(),this._headerTexture.destroy(),this._orderTexture.destroy(),this._fadingTexture.destroy()}requestSort(){this._updating.value=!0,this._pendingSortTask||(this._pendingSortTask=!0,this._scheduleSortStart())}_scheduleSortStart(){if(this._isSorting)return;const e=o()-this._lastSortStartTime,t=this._sortInterval-e;t<=0?this._startSortIfRequired():null==this._scheduledSortStartTimeout&&(this._scheduledSortStartTimeout=setTimeout(()=>{this._scheduledSortStartTimeout=null,this._pendingSortTask&&!this._isSorting&&this._scheduleSortStart()},t))}_startSortIfRequired(){if(this._isSorting||!this._pendingSortTask)return;const e=new AbortController;this._sortAbortController=e,this._isSorting=!0,this._pendingSortTask=!1,this._lastSortStartTime=o(),this._sortOnWorker(e.signal).finally(()=>{this._sortAbortController===e&&(this._sortAbortController=null),this._handleSortComplete()})}_handleSortComplete(){this._isSorting=!1,this._pendingSortTask?this._scheduleSortStart():this._updating.value=!1}_clearBuffersAndTextures(){this._atlasIndicesBuffer=void 0,this._sortedAtlasIndicesBuffer=void 0,this._distancesBuffer=void 0,this._bufferCapacity=0,this._sortBufferMemory=0,this._orderTexture.clear(),this._textureAtlas.clear(),this._headerTexture.clear()}_computeExpandedCapacity(t,s){let i=Math.max(1,t);for(;i<s;)i=Math.ceil(i*e);return i}_ensureSortBufferCapacities(e){if(this._bufferCapacity<e){const t=this._computeExpandedCapacity(this._bufferCapacity,e);this._atlasIndicesBuffer=new Uint32Array(t),this._sortedAtlasIndicesBuffer=new Uint32Array(t),this._distancesBuffer=new Float64Array(t),this._bufferCapacity=t,this._sortBufferMemory=s(this._atlasIndicesBuffer,this._sortedAtlasIndicesBuffer,this._distancesBuffer)}}_clearAllBuffersAndTextures(){this._clearBuffersAndTextures(),this._latestSortedGaussianTiles.length=0,this._nextCommittedVisibleGaussianTiles.length=0,this._previousVisibleTileDepthRangeTilesVersion=-1,this._workerHandle?.clear()}async _sortOnWorker(e){try{if(0===this._latestUpdatedGaussianTiles.length)return this.visibleGaussians=0,this._clearAllBuffersAndTextures(),this._latestCompletedLyr3dVisibilityChange=this._requestedLyr3dVisibilityChange,this._onSortComplete(this._latestSortedGaussianTiles,this._latestCompletedLyr3dVisibilityChange),void this._renderer.requestRender(1);this._useDeterministicSort&&this._latestUpdatedGaussianTiles.sort((e,t)=>e.obb.centerX-t.obb.centerX||e.obb.centerY-t.obb.centerY||e.obb.centerZ-t.obb.centerZ);const t=this._latestUpdatedGaussianTiles,s=t.length,i=this._requestedLyr3dVisibilityChange;let r=0;for(let e=0;e<s;e++)r+=t[e].gaussianCount;this._ensureSortBufferCapacities(r),this._textureAtlas.ensureTextureAtlas(),this._headerTexture.ensureCapacity(this._textureAtlas.pageAllocator.pageCount);const a=this._renderer.camera;h(this._cameraDirectionNormalized,a.ray.direction);const o=this._cameraDirectionNormalized[0],n=this._cameraDirectionNormalized[1],l=this._cameraDirectionNormalized[2];let u=0;const d=this._atlasIndicesBuffer,_=this._distancesBuffer,p=this._renderer.clippingBox,f=this._nextCommittedVisibleGaussianTiles;f.length=0;let m=0;const{frustum:g}=a,T=this._renderer.tileCullingRevision,b=g[0],S=g[1],y=g[2],x=g[3],C=g[4],A=g[5];for(let e=0;e<s;e++){const s=t[e],{gaussianAtlasIndices:i,relativePositions:r,obbCenterX:a,obbCenterY:h,obbCenterZ:g,paddedMbsRadius:V}=s,v=s.gaussianCount;if(s.cullingRevision!==T){let e=null==p||c(s.boundingBox,p);if(e){const t=1.5*V;e=b[0]*a+b[1]*h+b[2]*g+b[3]<t&&S[0]*a+S[1]*h+S[2]*g+S[3]<t&&y[0]*a+y[1]*h+y[2]*g+y[3]<t&&x[0]*a+x[1]*h+x[2]*g+x[3]<t&&C[0]*a+C[1]*h+C[2]*g+C[3]<t&&A[0]*a+A[1]*h+A[2]*g+A[3]<t}s.cullingRevision=T,s.cullingVisible=e}if(!s.cullingVisible)continue;d.set(i,u),f[m++]=s;const B=o*a+n*h+l*g,G=u+v;for(let e=u,t=0;e<G;e++,t+=3){const s=r[t],i=r[t+1],a=r[t+2];_[e]=s*o+i*n+a*l+B}u=G}if(f.length=m,0===u)return this.visibleGaussians=0,this._clearAllBuffersAndTextures(),this._latestCompletedLyr3dVisibilityChange=i,this._onSortComplete(this._latestSortedGaussianTiles,this._latestCompletedLyr3dVisibilityChange),void this._renderer.requestRender(1);const V={distances:this._distancesBuffer,atlasIndices:this._atlasIndicesBuffer,sortedAtlasIndices:this._sortedAtlasIndicesBuffer,numGaussians:u,preciseSort:this._useDeterministicSort},v=await(this._workerHandle?.sort(V,e));if(e.aborted)return;v&&(this._distancesBuffer=v.distances,this._atlasIndicesBuffer=v.atlasIndices,this._sortedAtlasIndicesBuffer=v.sortedAtlasIndices);const B=async e=>{this._orderTexture.setData(this._sortedAtlasIndicesBuffer,u);const t=this._latestSortedGaussianTiles;this._latestSortedGaussianTiles=f,this._nextCommittedVisibleGaussianTiles=t,this._latestSortedGaussianTilesVersion++,this._latestCompletedLyr3dVisibilityChange=i,this.visibleGaussians=u,this._onSortComplete(this._latestSortedGaussianTiles,this._latestCompletedLyr3dVisibilityChange),this._renderer.requestRender(1),e.madeProgress()};await this._frameTask.schedule(B,e)}catch(t){if(i(t))return}}set useDeterministicSort(e){this._useDeterministicSort=e}}export{C as GaussianSplatDataStore};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{signal as
|
|
2
|
+
import{signal as i}from"../../../../core/signal.js";import{Milliseconds as e}from"../../../../core/time.js";import{getGaussianSplatAlphaCutoffValue as t}from"../../webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js";class a{static{this.fadeInEase=i=>i*(2-i)}static{this.fadeOutEase=i=>i*i}static{this.inverseFadeInEase=i=>1-Math.sqrt(1-i)}static{this.inverseFadeOutEase=i=>Math.sqrt(1-i)}static{this.minimumFadeDuration=e(80)}static{this.resetFadeDurationInterval=e(1e3)}constructor(t){this._view=t,this._numFadingTiles=i(0),this._tmpFullyFadedOutTiles=new Array,this._previousNumFadingTiles=0,this._lastStoppedFading=e(0),this._currentFadeDuration=this.baseFadeDuration}get numFadingTiles(){return this._numFadingTiles.value}updateForFrame(i){if(i!==this._lastUpdatedFrameStart){if(this._lastUpdatedFrameStart=i,0===this.numFadingTiles)this._previousFrameStart=null;else{const t=e(null==this._previousFrameStart?0:i-this._previousFrameStart);this.updateAllTileFading(t),this._previousFrameStart=i}this._view.updateFadingTexture()}}fadeTile(i,e,t){const a=this._getTargetOpacity(e);if(i.fadeDirection=e,!this.fadingEnabled)return void this._instantTileFading(i,a);const s=i.opacityModifier;if(s!==a){const a=this._getFadeProgressFromOpacity(s,e);this._startTileFading(i,a,t)}else this._stopTileFading(i)}updateAllTileFading(i){const e=this._tmpFullyFadedOutTiles;e.length=0,this._view.tileHandles.forEach(t=>{this._updateTileFading(t,i)&&e.push(t)});e.length>0&&(this._view.notifyTileObbsChanged(e),0===this._numFadingTiles.value&&this._view.updateGaussians()),this._numFadingTiles.value>0&&this._view.view.stage?.renderView.requestRender(2)}onFadeDurationChanged(i){0===i&&this.numFadingTiles>0&&this._instantlyFullyFadeAllTiles()}isTileFadingOut(i){return null!=i.fadeProgress&&1===i.fadeDirection}onTileDiscarded(i){null!=i.fadeProgress&&(this._numFadingTiles.value--,0===this._numFadingTiles.value&&(this._lastStoppedFading=e(performance.now())))}updateFadeDuration(){if(this.numFadingTiles&&this.numFadingTiles>=this._previousNumFadingTiles){const i=.95*this._currentFadeDuration;this._currentFadeDuration=e(Math.max(i,a.minimumFadeDuration))}else 0===this.numFadingTiles&&performance.now()-this._lastStoppedFading>a.resetFadeDurationInterval&&(this._currentFadeDuration=this.baseFadeDuration);return this._previousNumFadingTiles=this.numFadingTiles,this._currentFadeDuration}get updating(){return this._numFadingTiles.value>0}get baseFadeDuration(){return this._view.view.qualitySettings.fadeDuration}get fadingEnabled(){return 0!==this.baseFadeDuration}_startTileFading(i,e,t){null==i.fadeProgress&&this._numFadingTiles.value++,i.fadeDuration=t,i.fadeProgress=e}_stopTileFading(i){null!=i.fadeProgress&&(1===i.fadeDirection&&this._onTileFullyFadedOut(i),this._numFadingTiles.value--,0===this._numFadingTiles.value&&(this._lastStoppedFading=e(performance.now())),i.fadeDuration=null,i.fadeProgress=null)}_updateTileFading(i,e){const{fadeProgress:t,fadeDirection:s}=i;if(null==t)return!1;const n=this._fadeDirectionToSign(s),r=i.fadeDuration,d=this._getTargetOpacity(s),u=e/Math.abs(r||1),l=Math.min(t+u,1),o=d-n*(1-(0===s?a.fadeInEase:a.fadeOutEase)(l)),h=1===l||this._tileReachedFadeOutCutoff(i,o);if(i.opacityModifier=h?d:o,h){const e=1===s;return this._stopTileFading(i),this._updateOpacityModifier(i),e}return i.fadeProgress=l,this._updateOpacityModifier(i),!1}_updateOpacityModifier(i){for(let e=0;e<i.pageIds.length;e++){const t=i.pageIds[e];this._view.data.fadingTexture.updateBuffer(i.opacityModifier,t)}}_tileReachedFadeOutCutoff(i,e){if(1!==i.fadeDirection)return!1;const a=t(this._view.view.qualitySettings.gaussianSplat.nonIdleMinimumOpacity);return e*i.maxGaussianOpacity<=a}_instantTileFading(i,e){i.fadeDuration=null,i.fadeProgress=null,i.opacityModifier=e,this._updateOpacityModifier(i),1===i.fadeDirection&&this._onTileFullyFadedOut(i)}_instantlyFullyFadeAllTiles(){const i=this._tmpFullyFadedOutTiles;i.length=0,this._view.tileHandles.forEach(e=>{if(null!=e.fadeProgress){const t=1===e.fadeDirection;this._instantTileFading(e,this._getTargetOpacity(e.fadeDirection)),t&&i.push(e)}});i.length>0&&(this._view.updateGaussians(),this._view.notifyTileObbsChanged(i)),this._numFadingTiles.value=0}_onTileFullyFadedOut(i){i.lifecycleState=0,this._view.moveTileToCache(i)}_fadeDirectionToSign(i){return 0===i?1:-1}_getTargetOpacity(i){return 0===i?1:0}_getFadeProgressFromOpacity(i,e){const t=Math.max(0,Math.min(i,1));return 0===e?a.inverseFadeInEase(t):a.inverseFadeOutEase(t)}}export{a as GaussianSplatFadeHelper};
|