@arcgis/core 4.27.0-next.20230521 → 4.27.0-next.20230522

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.
Files changed (173) hide show
  1. package/Graphic.js +1 -1
  2. package/arcade/featureset/actions/SpatialFilter.js +1 -1
  3. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  4. package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
  5. package/arcade/featureset/sources/FeatureLayerRelated.js +1 -1
  6. package/arcade/functions/featuresetbase.js +1 -1
  7. package/assets/esri/core/workers/RemoteClient.js +1 -1
  8. package/assets/esri/core/workers/chunks/0d02856e55d20b99fc8b.js +1 -0
  9. package/assets/esri/core/workers/chunks/{69242c66492717c7388c.js → 0fcb8d408696075338e2.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{1edc5c06874cb12c5478.js → 17f313e548281bb5db3e.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{b91c155de9a89e4e6971.js → 187c3b971ed0fc4363ef.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{85c6ce93aa41e6b65997.js → 18db07d739a713cc0465.js} +1 -1
  13. package/assets/esri/core/workers/chunks/28286014a575042619ee.js +1 -0
  14. package/assets/esri/core/workers/chunks/{692dfeb2e255fdc0ade2.js → 39288fa69561d21f04f8.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{2b9d3e60977934a6d471.js → 3bc6b5f0643364749ef8.js} +1 -1
  16. package/assets/esri/core/workers/chunks/45e5ad704d18dd0857ce.js +1 -0
  17. package/assets/esri/core/workers/chunks/{62d9d15f0d00a75da42c.js → 4670b17ae2ed3c13d344.js} +1 -1
  18. package/assets/esri/core/workers/chunks/4d24efa01d1accc5a5f0.js +1 -0
  19. package/assets/esri/core/workers/chunks/52575f021a14dd961de8.js +1 -0
  20. package/assets/esri/core/workers/chunks/{6312783626bacf52df7a.js → 55486c644e8b01326a0d.js} +1 -1
  21. package/assets/esri/core/workers/chunks/5576858f56314afcb4d5.js +1 -0
  22. package/assets/esri/core/workers/chunks/5a4c04bf4f57e74457c5.js +1 -0
  23. package/assets/esri/core/workers/chunks/70d6e5edf05ef7079fa8.js +1 -0
  24. package/assets/esri/core/workers/chunks/71bdf8f10aee0077f681.js +1 -0
  25. package/assets/esri/core/workers/chunks/72b2c3c8e76da699690c.js +1 -0
  26. package/assets/esri/core/workers/chunks/78ce0b1af62435d8ebf4.js +1 -0
  27. package/assets/esri/core/workers/chunks/791f529e90135398b3d5.js +1 -0
  28. package/assets/esri/core/workers/chunks/8d3abfe6fdc5ac8d6cb7.js +1 -0
  29. package/assets/esri/core/workers/chunks/96d339abcd917f1f0ae1.js +1 -0
  30. package/assets/esri/core/workers/chunks/97cdbec7532cfcdf9ad2.js +1 -0
  31. package/assets/esri/core/workers/chunks/{f3f6035a17f7dcd19675.js → 9ab400a89dd701778d2c.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{1488b3d48232844b8bb4.js → 9fe349f43d5ff5a4ac2d.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{22396dd3717d17a5d235.js → a1c31bb8c12831539328.js} +1 -1
  34. package/assets/esri/core/workers/chunks/b4e2dc6b3d06b426e596.js +1 -0
  35. package/assets/esri/core/workers/chunks/{48abcb2d88f22e6e9fde.js → c2cb9fa18c77f0c5104e.js} +1 -1
  36. package/assets/esri/core/workers/chunks/cad7a2092ea7f51dbd8b.js +1 -0
  37. package/assets/esri/core/workers/chunks/d725dbbdeb05322e6d88.js +1 -0
  38. package/assets/esri/core/workers/chunks/df3e497d12ed77bae168.js +1 -0
  39. package/assets/esri/core/workers/chunks/{4d5f71d84c85f45c97ea.js → ed6f6e539a915ba9e64d.js} +1 -1
  40. package/assets/esri/core/workers/chunks/fb080339bfaf32731ca6.js +1 -0
  41. package/assets/esri/themes/base/_core.scss +2 -0
  42. package/assets/esri/themes/base/widgets/_FloorFilter.scss +6 -0
  43. package/assets/esri/themes/base/widgets/_UtilityNetworkValidateTopology.scss +40 -0
  44. package/assets/esri/themes/dark/main.css +1 -1
  45. package/assets/esri/themes/light/main.css +1 -1
  46. package/assets/esri/themes/light/view.css +1 -1
  47. package/assets/esri/widgets/Editor/t9n/Editor_ar.json +1 -1
  48. package/assets/esri/widgets/Editor/t9n/Editor_bg.json +1 -1
  49. package/assets/esri/widgets/Editor/t9n/Editor_bs.json +1 -1
  50. package/assets/esri/widgets/Editor/t9n/Editor_ca.json +1 -1
  51. package/assets/esri/widgets/Editor/t9n/Editor_cs.json +1 -1
  52. package/assets/esri/widgets/Editor/t9n/Editor_da.json +1 -1
  53. package/assets/esri/widgets/Editor/t9n/Editor_de.json +1 -1
  54. package/assets/esri/widgets/Editor/t9n/Editor_el.json +1 -1
  55. package/assets/esri/widgets/Editor/t9n/Editor_es.json +1 -1
  56. package/assets/esri/widgets/Editor/t9n/Editor_et.json +1 -1
  57. package/assets/esri/widgets/Editor/t9n/Editor_fi.json +1 -1
  58. package/assets/esri/widgets/Editor/t9n/Editor_fr.json +1 -1
  59. package/assets/esri/widgets/Editor/t9n/Editor_he.json +1 -1
  60. package/assets/esri/widgets/Editor/t9n/Editor_hr.json +1 -1
  61. package/assets/esri/widgets/Editor/t9n/Editor_hu.json +1 -1
  62. package/assets/esri/widgets/Editor/t9n/Editor_id.json +1 -1
  63. package/assets/esri/widgets/Editor/t9n/Editor_it.json +1 -1
  64. package/assets/esri/widgets/Editor/t9n/Editor_ja.json +1 -1
  65. package/assets/esri/widgets/Editor/t9n/Editor_ko.json +1 -1
  66. package/assets/esri/widgets/Editor/t9n/Editor_lt.json +1 -1
  67. package/assets/esri/widgets/Editor/t9n/Editor_lv.json +1 -1
  68. package/assets/esri/widgets/Editor/t9n/Editor_nb.json +1 -1
  69. package/assets/esri/widgets/Editor/t9n/Editor_nl.json +1 -1
  70. package/assets/esri/widgets/Editor/t9n/Editor_pl.json +1 -1
  71. package/assets/esri/widgets/Editor/t9n/Editor_pt-BR.json +1 -1
  72. package/assets/esri/widgets/Editor/t9n/Editor_pt-PT.json +1 -1
  73. package/assets/esri/widgets/Editor/t9n/Editor_ro.json +1 -1
  74. package/assets/esri/widgets/Editor/t9n/Editor_ru.json +1 -1
  75. package/assets/esri/widgets/Editor/t9n/Editor_sk.json +1 -1
  76. package/assets/esri/widgets/Editor/t9n/Editor_sl.json +1 -1
  77. package/assets/esri/widgets/Editor/t9n/Editor_sr.json +1 -1
  78. package/assets/esri/widgets/Editor/t9n/Editor_sv.json +1 -1
  79. package/assets/esri/widgets/Editor/t9n/Editor_th.json +1 -1
  80. package/assets/esri/widgets/Editor/t9n/Editor_tr.json +1 -1
  81. package/assets/esri/widgets/Editor/t9n/Editor_uk.json +1 -1
  82. package/assets/esri/widgets/Editor/t9n/Editor_vi.json +1 -1
  83. package/assets/esri/widgets/Editor/t9n/Editor_zh-CN.json +1 -1
  84. package/assets/esri/widgets/Editor/t9n/Editor_zh-HK.json +1 -1
  85. package/assets/esri/widgets/Editor/t9n/Editor_zh-TW.json +1 -1
  86. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology.json +1 -1
  87. package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_en.json +1 -1
  88. package/chunks/mat4.js +1 -1
  89. package/core/accessorSupport/write.js +1 -1
  90. package/core/fontUtils.js +1 -1
  91. package/core/libs/gl-matrix-2/math/mat4.js +1 -1
  92. package/geometry/Mesh.js +1 -1
  93. package/geometry/support/MeshGeoreferencedRelativeVertexSpace.d.ts +4 -0
  94. package/geometry/support/MeshGeoreferencedRelativeVertexSpace.js +5 -0
  95. package/geometry/support/MeshGeoreferencedVertexSpace.d.ts +4 -0
  96. package/geometry/support/MeshGeoreferencedVertexSpace.js +5 -0
  97. package/geometry/support/MeshLocalVertexSpace.d.ts +4 -0
  98. package/geometry/support/MeshLocalVertexSpace.js +5 -0
  99. package/geometry/support/MeshTransform.d.ts +4 -0
  100. package/geometry/support/MeshTransform.js +1 -1
  101. package/geometry/support/meshUtils/ElevationSamplerWorker.js +1 -1
  102. package/geometry/support/meshUtils/centerAt.js +1 -1
  103. package/geometry/support/meshUtils/exporters/gltf/geometry.js +1 -1
  104. package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
  105. package/geometry/support/meshUtils/geographicUtils.js +1 -1
  106. package/geometry/support/meshUtils/georeference.js +1 -1
  107. package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
  108. package/geometry/support/meshUtils/merge.js +1 -1
  109. package/geometry/support/meshUtils/offset.js +1 -1
  110. package/geometry/support/meshUtils/primitives.js +1 -1
  111. package/geometry/support/meshUtils/rotate.js +1 -1
  112. package/geometry/support/meshUtils/scale.js +1 -1
  113. package/interfaces.d.ts +227 -1
  114. package/layers/VoxelWasmPerSceneView.js +1 -1
  115. package/layers/graphics/data/attributeSupport.js +1 -1
  116. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  117. package/networks/support/TopologyValidationJobInfo.js +1 -1
  118. package/package.json +1 -1
  119. package/popup/FieldInfo.js +1 -1
  120. package/portal/Portal.js +1 -1
  121. package/rest/support/FeatureSet.js +1 -1
  122. package/rest/support/meshFeatureSet.js +1 -1
  123. package/support/revision.js +1 -1
  124. package/symbols/cim/cimAnalyzer.js +1 -1
  125. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  126. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  127. package/views/3d/interactive/editingTools/meshFastUpdateUtils.js +1 -1
  128. package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
  129. package/views/3d/interactive/editingTools/transformGraphic/GraphicTransformTool.js +1 -1
  130. package/views/3d/interactive/editingTools/transformGraphic/ScaleRotateMeshAdapter.js +1 -1
  131. package/views/3d/interactive/editingTools/transformGraphic/undoRecords.js +1 -1
  132. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  133. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  134. package/views/3d/layers/graphics/Graphics3DMeshObject3DGraphicLayer.js +1 -1
  135. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  136. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  137. package/views/3d/state/utils/navigationUtils.js +1 -1
  138. package/views/3d/support/DisplayQualityProfile.js +1 -1
  139. package/views/3d/support/QualitySettings.js +1 -1
  140. package/views/3d/webgl-engine/lib/Camera.js +1 -1
  141. package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
  142. package/views/3d/webgl-engine/lib/RenderPluginManager.js +1 -1
  143. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  144. package/views/3d/webgl-engine/lib/TextRenderParameters.js +1 -1
  145. package/views/interactive/dragEventPipeline.js +1 -1
  146. package/widgets/BasemapGallery/support/PortalBasemapsSource.js +1 -1
  147. package/widgets/Editor/Edits.js +1 -1
  148. package/widgets/Editor/Upload.js +1 -1
  149. package/widgets/Editor/workflowUtils.js +1 -1
  150. package/widgets/Feature/support/featureUtils.js +1 -1
  151. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  152. package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +5 -0
  153. package/widgets/UtilityNetworkValidateTopology.js +5 -0
  154. package/assets/esri/core/workers/chunks/163bf2e13abbdd298374.js +0 -1
  155. package/assets/esri/core/workers/chunks/23f73f81aea461c0c6e6.js +0 -1
  156. package/assets/esri/core/workers/chunks/2640204c4655aa535ccb.js +0 -1
  157. package/assets/esri/core/workers/chunks/2bf42d060f877566b989.js +0 -1
  158. package/assets/esri/core/workers/chunks/34ec9623a1bece86a82b.js +0 -1
  159. package/assets/esri/core/workers/chunks/3bf52139340827794c3b.js +0 -1
  160. package/assets/esri/core/workers/chunks/52d02021e858820bc4fa.js +0 -1
  161. package/assets/esri/core/workers/chunks/64b8f65e2ef6cbf08380.js +0 -1
  162. package/assets/esri/core/workers/chunks/78aede1e114deefacb54.js +0 -1
  163. package/assets/esri/core/workers/chunks/7ef100158ca28631fcaf.js +0 -1
  164. package/assets/esri/core/workers/chunks/93ad67930aa7d4a4b0ac.js +0 -1
  165. package/assets/esri/core/workers/chunks/964795dfb57f0d0635d0.js +0 -1
  166. package/assets/esri/core/workers/chunks/99ce0a202dcd3d7dc290.js +0 -1
  167. package/assets/esri/core/workers/chunks/abe6c99a1a719543dbe8.js +0 -1
  168. package/assets/esri/core/workers/chunks/c3bf44146fddfe8990f7.js +0 -1
  169. package/assets/esri/core/workers/chunks/cbe817e966b57599bafd.js +0 -1
  170. package/assets/esri/core/workers/chunks/e15b5d7e46a834eacc57.js +0 -1
  171. package/assets/esri/core/workers/chunks/e1e0b3580e2c3098c9f4.js +0 -1
  172. package/assets/esri/core/workers/chunks/e305d20e4424451cab5b.js +0 -1
  173. package/assets/esri/core/workers/chunks/e6836c84470fb6bd25bf.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Logger.js";import{a as t,g as r}from"../../../chunks/vec3.js";import{c as n}from"../../../chunks/vec3f64.js";import o from"../MeshComponent.js";import s from"../MeshTransform.js";import{MeshVertexAttributes as i}from"../MeshVertexAttributes.js";import{georeferenceApplyTransform as l,ungeoreference as a}from"./georeference.js";const f=e.getLogger("esri.geometry.support.triangleMeshMerge");function u(e,t){if(0===e.length)return f.error("merge()","Must specify one more geometries to merge"),null;const r=e[0].spatialReference;for(const u of e){if(!u.spatialReference.equals(r))return f.error("merge()","Geometries must all be in the same spatial reference"),null;if(!u.loaded)return f.error("merge()","Geometries must all be loaded before merging"),null}const n=c(e);if(null==n)return null;const o=x(e),s=[],i={position:0,uv:0,normal:0,tangent:0,color:0},l=new Map,a=new Map;for(const f of e){const e=m(f,n);if(t&&t.reuseMaterials&&f.components)for(const t of f.components)t.material&&l.set(t.material,t.material);h(f,i,l,a,s),v("position",e,o,i,0),v("normal",e,o,i,0),v("tangent",e,o,i,0),v("uv",f.vertexAttributes,o,i,0),v("color",f.vertexAttributes,o,i,255)}return{vertexAttributes:o,components:s,transform:n.transform,spatialReference:r}}function c(e){let o=null,i=!0;const l=n();let a=0,u=!1;for(const r of e)if(null==o||null!=r.transform&&r.transform.equals(o)||(i=!1),null!=r.transform){if(o&&o.geographic!==r.transform.geographic)return f.error("merge()","Inconsistent geographic mode for provided geometries transform. Some are geographic while others are not, unable to merge geometries."),null;null==o&&(o=r.transform),r.transform.geographic&&(u=!0),a++,t(l,l,r.transform.origin)}if(null==o)return{transform:null,rebake:!1};if(i)return{transform:o.clone(),rebake:!1};const c=r(l,l,1/a);return{transform:new s({origin:c,geographic:u}),rebake:!0}}function m(e,t){if(!t.rebake)return e.vertexAttributes;const r=l(e.vertexAttributes,e.transform,e.spatialReference);return null!=t.transform?a(r,t.transform.getOriginPoint(e.spatialReference),{geographic:t.transform.geographic}):r}function g(e,t){return t.normal>0&&!e.vertexAttributes.normal}function p(e,t,r){g(e,t)&&"source"===r.shading&&(r.shading="flat")}function h(e,t,r,n,s){if(e.components)for(const o of e.components){const i=o.cloneWithDeduplication(r,n),l=t.position/3;if(i.faces)for(let e=0;e<i.faces.length;e++)i.faces[e]+=l;else{i.faces=new Uint32Array(e.vertexAttributes.position.length/3);for(let e=0;e<i.faces.length;e++)i.faces[e]=e+l}p(e,t,i),s.push(i)}else if(e.vertexAttributes&&e.vertexAttributes.position){const r=e.vertexAttributes.position.length/3,n=new Uint32Array(r),i=t.position/3;for(let e=0;e<r;e++)n[e]=e+i;const l=new o({faces:n});p(e,t,l),s.push(l)}}function v(e,t,r,n,o){if(!t)return;const s=t.position;if(!s)return;const i=t[e],l=r[e];if(null==i){let t=n[e];const r=w[e];if(null!=l){for(let e=0;e<s.length;e+=3)for(let n=0;n<r;n++)l[t++]=o;n[e]=t}}else null!=l&&null!=i&&(b(i,0,l,n[e],i.length),n[e]+=i.length)}function b(e,t,r,n,o){for(let s=0;s<o;s++)r[n++]=e[t++];return r}function A(e){let t=!1,r=!1,n=!1,o=!1;for(const s of e){const e=s.vertexAttributes;if(e&&e.position&&(e.uv&&(t=!0),e.normal&&(r=!0),e.tangent&&(o=!0),e.color&&(n=!0),r&&t&&n&&o))break}return{normal:r,uv:t,color:n,tangent:o}}function x(e){let t=0,r=0,n=0,o=0,s=0;const l=A(e);for(const i of e){const e=i.vertexAttributes;e&&e.position&&(t+=e.position.length,l.uv&&(r+=e.position.length/w.position*w.uv),l.normal&&(n+=e.position.length/w.position*w.normal),l.color&&(o+=e.position.length/w.position*w.color),l.tangent&&(s+=e.position.length/w.position*w.tangent))}return new i({position:new Float64Array(t),uv:r?new Float32Array(r):null,normal:n?new Float32Array(n):null,tangent:s?new Float32Array(s):null,color:o?new Uint8Array(o):null})}const w={position:3,normal:3,tangent:4,uv:2,color:4};export{u as merge};
5
+ import e from"../../../core/Logger.js";import{F as t,a as n,g as r}from"../../../chunks/vec3.js";import{c as o}from"../../../chunks/vec3f64.js";import i from"../MeshComponent.js";import s from"../MeshTransform.js";import{MeshVertexAttributes as l}from"../MeshVertexAttributes.js";import{georeferenceApplyTransform as a,ungeoreference as c}from"./georeference.js";const f=e.getLogger("esri.geometry.support.triangleMeshMerge");function u(e,t){if(0===e.length)return f.error("merge()","Must specify one more geometries to merge"),null;const n=e[0].spatialReference;for(const c of e){if(!c.spatialReference.equals(n))return f.error("merge()","Geometries must all be in the same spatial reference"),null;if(!c.loaded)return f.error("merge()","Geometries must all be loaded before merging"),null}const r=p(e);if(null==r)return null;const o=w(e),i=[],s={position:0,uv:0,normal:0,tangent:0,color:0},l=new Map,a=new Map;for(const c of e){const e=m(c,r);if(t&&t.reuseMaterials&&c.components)for(const t of c.components)t.material&&l.set(t.material,t.material);h(c,s,l,a,i),x("position",e,o,s,0),x("normal",e,o,s,0),x("tangent",e,o,s,0),x("uv",c.vertexAttributes,o,s,0),x("color",c.vertexAttributes,o,s,255)}return{vertexAttributes:o,components:i,vertexSpace:r.vertexSpace,transform:r.transform,spatialReference:n}}function p(e){let i=null,l=null,a=!0,c=!0,u=null;const p=o();let m=0;for(const r of e){const{vertexSpace:e,transform:o}=r;if(null==l&&(l=e,l.isRelative&&(u=l.origin)),l.type!==e.type)return f.error("merge()",`Inconsistent mesh vertex space for provided geometries. One was ${l.type} while another is ${e.type}. Unable to merge geometries.`),null;if(null==i||null!=o&&o.equals(i)||(a=!1),null!=o&&null==i&&(i=o),e.isRelative){const{origin:r}=e;u&&!t(r,u)&&(c=!1),m++,n(p,p,e.origin)}}if(null==l)throw new Error;const g=l.clone();if(!g.isRelative)return{transform:null,vertexSpace:g,rebake:!1};if(c&&a)return{transform:i?.clone(),vertexSpace:g,rebake:!1};const v=r(p,p,1/m);return g.origin=v,{transform:new s,vertexSpace:g,rebake:!0}}function m(e,t){if(!t.rebake)return e.vertexAttributes;const n=e.vertexSpace,r=t.vertexSpace;if(n.type!==r.type)throw new Error;const o=a(e.vertexAttributes,n,e.transform,e.spatialReference);return c(o,r.getOriginPoint(e.spatialReference),{geographic:!r.isGeoreferenced})}function g(e,t){return t.normal>0&&!e.vertexAttributes.normal}function v(e,t,n){g(e,t)&&"source"===n.shading&&(n.shading="flat")}function h(e,t,n,r,o){if(e.components)for(const i of e.components){const s=i.cloneWithDeduplication(n,r),l=t.position/3;if(s.faces)for(let e=0;e<s.faces.length;e++)s.faces[e]+=l;else{s.faces=new Uint32Array(e.vertexAttributes.position.length/3);for(let e=0;e<s.faces.length;e++)s.faces[e]=e+l}v(e,t,s),o.push(s)}else if(e.vertexAttributes&&e.vertexAttributes.position){const n=e.vertexAttributes.position.length/3,r=new Uint32Array(n),s=t.position/3;for(let e=0;e<n;e++)r[e]=e+s;const l=new i({faces:r});v(e,t,l),o.push(l)}}function x(e,t,n,r,o){if(!t)return;const i=t.position;if(!i)return;const s=t[e],l=n[e];if(null==s){let t=r[e];const n=y[e];if(null!=l){for(let e=0;e<i.length;e+=3)for(let r=0;r<n;r++)l[t++]=o;r[e]=t}}else null!=l&&null!=s&&(b(s,0,l,r[e],s.length),r[e]+=s.length)}function b(e,t,n,r,o){for(let i=0;i<o;i++)n[r++]=e[t++];return n}function A(e){let t=!1,n=!1,r=!1,o=!1;for(const i of e){const e=i.vertexAttributes;if(e&&e.position&&(e.uv&&(t=!0),e.normal&&(n=!0),e.tangent&&(o=!0),e.color&&(r=!0),n&&t&&r&&o))break}return{normal:n,uv:t,color:r,tangent:o}}function w(e){let t=0,n=0,r=0,o=0,i=0;const s=A(e);for(const l of e){const e=l.vertexAttributes;e&&e.position&&(t+=e.position.length,s.uv&&(n+=e.position.length/y.position*y.uv),s.normal&&(r+=e.position.length/y.position*y.normal),s.color&&(o+=e.position.length/y.position*y.color),s.tangent&&(i+=e.position.length/y.position*y.tangent))}return new l({position:new Float64Array(t),uv:n?new Float32Array(n):null,normal:r?new Float32Array(r):null,tangent:i?new Float32Array(i):null,color:o?new Uint8Array(o):null})}const y={position:3,normal:3,tangent:4,uv:2,color:4};export{u as merge};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../core/Logger.js";import{f as e}from"../../../chunks/mat3.js";import{c as r}from"../../../chunks/mat3f64.js";import{c as o}from"../../../chunks/mat4f64.js";import{a as n,t as i}from"../../../chunks/vec3.js";import{c as s}from"../../../chunks/vec3f64.js";import{computeTranslationToOriginAndRotation as l}from"../../projection.js";import{getSphericalPCPF as a}from"../../spatialReferenceEllipsoidUtils.js";import{isGeographicMesh as f}from"./geographicUtils.js";import{projectToPCPF as u,projectNormalToPCPF as c,projectTangentToPCPF as m,projectFromPCPF as p,projectNormalFromPCPF as g,projectTangentFromPCPF as h}from"./projection.js";function j(e,r,o){if(e.vertexAttributes&&e.vertexAttributes.position)if(null!=e.transform)null!=o?.geographic&&o.geographic!==e.transform.geographic&&t.getLogger("esri.geometry.support.meshUtils.offset").warn(`Specifying the 'geographic' parameter (${o.geographic}) different from the Mesh transform setting (${e.transform.geographic}) is not supported`),x(e.transform,r);else{f(e.spatialReference,o)?A(e,r):v(e,r)}}function x(t,e){const r=t.origin;t.origin=n(s(),r,e)}function A(t,r){const o=t.spatialReference,n=t.vertexAttributes.position,s=t.vertexAttributes.normal,f=t.vertexAttributes.tangent,j=new Float64Array(n.length),x=null!=s?new Float32Array(s.length):null,A=null!=f?new Float32Array(f.length):null,v=t.extent.center,w=y;l(o,[v.x,v.y,v.z],d,a(o)),e(k,d),i(w,r,k),u(n,o,j),null!=s&&null!=x&&c(s,n,j,o,x),null!=f&&null!=A&&m(f,n,j,o,A),b(j,w),p(j,n,o),null!=s&&null!=x&&g(x,n,j,o,s),null!=f&&null!=A&&h(A,n,j,o,f),t.vertexAttributesChanged()}function v(t,e){b(t.vertexAttributes.position,e),t.vertexAttributesChanged()}function b(t,e){if(t)for(let r=0;r<t.length;r+=3)for(let o=0;o<3;o++)t[r+o]+=e[o]}const y=s(),d=o(),k=r();export{j as offset};
5
+ import{f as t}from"../../../chunks/mat3.js";import{c as e}from"../../../chunks/mat3f64.js";import{c as r}from"../../../chunks/mat4f64.js";import{a as n,t as o}from"../../../chunks/vec3.js";import{c as i}from"../../../chunks/vec3f64.js";import{computeTranslationToOriginAndRotation as s}from"../../projection.js";import{getSphericalPCPF as l}from"../../spatialReferenceEllipsoidUtils.js";import{validateGeographicFlag as u,isGeographicMesh as a}from"./geographicUtils.js";import{projectToPCPF as c,projectNormalToPCPF as f,projectTangentToPCPF as m,projectFromPCPF as p,projectNormalFromPCPF as h,projectTangentFromPCPF as g}from"./projection.js";const v="esri.geometry.support.meshUtils.offset";function x(t,e,r){if(!t.vertexAttributes||!t.vertexAttributes.position)return;const{vertexSpace:n}=t;if(n.isRelative)u(n,v,r),j(n,e);else{a(t.spatialReference,r)?A(t,e):b(t,e)}}function j(t,e){const r=t.origin;t.origin=n(i(),r,e)}function A(e,r){const n=e.spatialReference,i=e.vertexAttributes.position,u=e.vertexAttributes.normal,a=e.vertexAttributes.tangent,v=new Float64Array(i.length),x=null!=u?new Float32Array(u.length):null,j=null!=a?new Float32Array(a.length):null,A=e.extent.center,b=y;s(n,[A.x,A.y,A.z],R,l(n)),t(d,R),o(b,r,d),c(i,n,v),null!=u&&null!=x&&f(u,i,v,n,x),null!=a&&null!=j&&m(a,i,v,n,j),k(v,b),p(v,i,n),null!=u&&null!=x&&h(x,i,v,n,u),null!=a&&null!=j&&g(j,i,v,n,a),e.vertexAttributesChanged()}function b(t,e){k(t.vertexAttributes.position,e),t.vertexAttributesChanged()}function k(t,e){if(t)for(let r=0;r<t.length;r+=3)for(let n=0;n<3;n++)t[r+n]+=e[n]}const y=i(),R=r(),d=e();export{x as offset};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{c as t}from"../../../chunks/mat3f64.js";import{t as e,n}from"../../../chunks/vec3.js";import{c as r}from"../../../chunks/vec3f64.js";import o from"../MeshComponent.js";import{MeshVertexAttributes as s}from"../MeshVertexAttributes.js";import{georeferenceByTransform as a}from"./georeference.js";function i(){const{faceDescriptions:t,faceVertexOffsets:e,uvScales:n}=x,r=4*t.length,o=new Float64Array(3*r),s=new Float32Array(3*r),a=new Float32Array(2*r),i=new Uint32Array(2*t.length*3);let l=0,c=0,f=0,u=0;for(let h=0;h<t.length;h++){const r=t[h],p=l/3;for(const t of e)i[u++]=p+t;const w=r.corners;for(let t=0;t<4;t++){const e=w[t];let i=0;a[f++]=.25*n[t][0]+r.uvOrigin[0],a[f++]=r.uvOrigin[1]-.25*n[t][1];for(let t=0;t<3;t++)0!==r.axis[t]?(o[l++]=.5*r.axis[t],s[c++]=r.axis[t]):(o[l++]=.5*e[i++],s[c++]=0)}}return{position:o,normal:s,uv:a,faces:i}}function l(t,e){const n=t.components[0],r=n.faces,s=d[e],a=6*s,i=new Array(6),l=new Array(r.length-6);let c=0,f=0;for(let o=0;o<r.length;o++)o>=a&&o<a+6?i[c++]=r[o]:l[f++]=r[o];if(null!=t.vertexAttributes.uv){const e=new Float32Array(t.vertexAttributes.uv),n=4*s*2,r=[0,1,1,1,1,0,0,0];for(let t=0;t<r.length;t++)e[n+t]=r[t];t.vertexAttributes.uv=e}return t.components=[new o({faces:i,material:n.material}),new o({faces:l})],t}function c(t=0){const e=Math.round(8*2**t),n=2*e,r=(e-1)*(n+1)+2*n,o=new Float64Array(3*r),s=new Float32Array(3*r),a=new Float32Array(2*r),i=new Uint32Array(3*((e-1)*n*2));let l=0,c=0,f=0,u=0;for(let h=0;h<=e;h++){const t=h/e*Math.PI+.5*Math.PI,r=Math.cos(t),p=Math.sin(t);M[2]=p;const w=0===h||h===e,m=w?n-1:n;for(let v=0;v<=m;v++){const t=v/m*2*Math.PI;M[0]=-Math.sin(t)*r,M[1]=Math.cos(t)*r;for(let e=0;e<3;e++)o[l]=.5*M[e],s[l]=M[e],++l;a[c++]=(v+(w?.5:0))/n,a[c++]=h/e,0!==h&&v!==n&&(h!==e&&(i[f++]=u,i[f++]=u+1,i[f++]=u-n),1!==h&&(i[f++]=u,i[f++]=u-n,i[f++]=u-n-1)),u++}}return{position:o,normal:s,uv:a,faces:i}}function f(t=0){const e=5,n=Math.round(16*2**t),r=(e-1)*(n+1)+2*n,o=new Float64Array(3*r),s=new Float32Array(3*r),a=new Float32Array(2*r),i=new Uint32Array(3*(4*n));let l=0,c=0,f=0,u=0,h=0;for(let p=0;p<=e;p++){const t=0===p||p===e,r=p<=1||p>=e-1,w=2===p||4===p,m=t?n-1:n;for(let v=0;v<=m;v++){const g=v/m*2*Math.PI,A=t?0:.5;M[0]=A*Math.sin(g),M[1]=A*-Math.cos(g),M[2]=p<=2?.5:-.5;for(let t=0;t<3;t++)o[l++]=M[t],s[c++]=r?2===t?p<=1?1:-1:0:2===t?0:M[t]/A;a[f++]=(v+(t?.5:0))/n,a[f++]=p<=1?1*p/3:p<=3?1*(p-2)/3+1/3:1*(p-4)/3+2/3,w||0===p||v===n||(p!==e&&(i[u++]=h,i[u++]=h+1,i[u++]=h-n),1!==p&&(i[u++]=h,i[u++]=h-n,i[u++]=h-n-1)),h++}}return{position:o,normal:s,uv:a,faces:i}}function u(t,e){const n="number"==typeof e?e:null!=e?e.width:1,r="number"==typeof e?e:null!=e?e.height:1;switch(t){case"up":case"down":return{width:n,depth:r};case"north":case"south":return{width:n,height:r};case"east":case"west":return{depth:n,height:r}}}function h(t){const e=v.facingAxisOrderSwap[t],n=v.position,r=v.normal,o=new Float64Array(n.length),s=new Float32Array(r.length);let a=0;for(let i=0;i<4;i++){const t=a;for(let i=0;i<3;i++){const l=e[i],c=Math.abs(l)-1,f=l>=0?1:-1;o[a]=n[t+c]*f,s[a]=r[t+c]*f,a++}}return{position:o,normal:s,uv:new Float32Array(v.uv),faces:new Uint32Array(v.faces),isPlane:!0}}const p=1,w=2,m=3,v={position:[-.5,-.5,0,.5,-.5,0,.5,.5,0,-.5,.5,0],normal:[0,0,1,0,0,1,0,0,1,0,0,1],uv:[0,1,1,1,1,0,0,0],faces:[0,1,2,0,2,3],facingAxisOrderSwap:{east:[m,p,w],west:[-m,-p,w],north:[-p,m,w],south:[p,-m,w],up:[p,w,m],down:[p,-w,-m]}};function g(t,e,n){t.isPlane||A(t),y(t,n?.size);const{vertexAttributes:r,transform:i}=a(t,e,n);return{vertexAttributes:new s({...r,uv:t.uv}),transform:i,components:[new o({faces:t.faces,material:n&&n.material||null})],spatialReference:e.spatialReference}}function A(t){for(let e=0;e<t.position.length;e+=3)t.position[e+2]+=.5}function y(t,r){if(null==r)return;const o="number"==typeof r?[r,r,r]:[null!=r.width?r.width:1,null!=r.depth?r.depth:1,null!=r.height?r.height:1];F[0]=o[0],F[4]=o[1],F[8]=o[2];for(let n=0;n<t.position.length;n+=3){for(let e=0;e<3;e++)M[e]=t.position[n+e];e(M,M,F);for(let e=0;e<3;e++)t.position[n+e]=M[e]}if(o[0]!==o[1]||o[1]!==o[2]){F[0]=1/o[0],F[4]=1/o[1],F[8]=1/o[2];for(let r=0;r<t.normal.length;r+=3){for(let e=0;e<3;e++)M[e]=t.normal[r+e];e(M,M,F),n(M,M);for(let e=0;e<3;e++)t.normal[r+e]=M[e]}}}const x={faceDescriptions:[{axis:[0,-1,0],uvOrigin:[0,.625],corners:[[-1,-1],[1,-1],[1,1],[-1,1]]},{axis:[1,0,0],uvOrigin:[.25,.625],corners:[[-1,-1],[1,-1],[1,1],[-1,1]]},{axis:[0,1,0],uvOrigin:[.5,.625],corners:[[1,-1],[-1,-1],[-1,1],[1,1]]},{axis:[-1,0,0],uvOrigin:[.75,.625],corners:[[1,-1],[-1,-1],[-1,1],[1,1]]},{axis:[0,0,1],uvOrigin:[0,.375],corners:[[-1,-1],[1,-1],[1,1],[-1,1]]},{axis:[0,0,-1],uvOrigin:[0,.875],corners:[[-1,1],[1,1],[1,-1],[-1,-1]]}],uvScales:[[0,0],[1,0],[1,1],[0,1]],faceVertexOffsets:[0,1,2,0,2,3]},d={south:0,east:1,north:2,west:3,up:4,down:5},M=r(),F=t();export{d as boxFaceOrder,u as convertPlaneSizeParameter,g as convertUnitGeometry,i as createUnitSizeBox,f as createUnitSizeCylinder,h as createUnitSizePlane,c as createUnitSizeSphere,l as extractSingleFaceOfBox};
5
+ import{c as t}from"../../../chunks/mat3f64.js";import{t as e,n}from"../../../chunks/vec3.js";import{c as r}from"../../../chunks/vec3f64.js";import o from"../MeshComponent.js";import{MeshVertexAttributes as s}from"../MeshVertexAttributes.js";import{georeferenceByTransform as a}from"./georeference.js";function i(){const{faceDescriptions:t,faceVertexOffsets:e,uvScales:n}=y,r=4*t.length,o=new Float64Array(3*r),s=new Float32Array(3*r),a=new Float32Array(2*r),i=new Uint32Array(2*t.length*3);let l=0,c=0,f=0,u=0;for(let h=0;h<t.length;h++){const r=t[h],p=l/3;for(const t of e)i[u++]=p+t;const w=r.corners;for(let t=0;t<4;t++){const e=w[t];let i=0;a[f++]=.25*n[t][0]+r.uvOrigin[0],a[f++]=r.uvOrigin[1]-.25*n[t][1];for(let t=0;t<3;t++)0!==r.axis[t]?(o[l++]=.5*r.axis[t],s[c++]=r.axis[t]):(o[l++]=.5*e[i++],s[c++]=0)}}return{position:o,normal:s,uv:a,faces:i}}function l(t,e){const n=t.components[0],r=n.faces,s=d[e],a=6*s,i=new Array(6),l=new Array(r.length-6);let c=0,f=0;for(let o=0;o<r.length;o++)o>=a&&o<a+6?i[c++]=r[o]:l[f++]=r[o];if(null!=t.vertexAttributes.uv){const e=new Float32Array(t.vertexAttributes.uv),n=4*s*2,r=[0,1,1,1,1,0,0,0];for(let t=0;t<r.length;t++)e[n+t]=r[t];t.vertexAttributes.uv=e}return t.components=[new o({faces:i,material:n.material}),new o({faces:l})],t}function c(t=0){const e=Math.round(8*2**t),n=2*e,r=(e-1)*(n+1)+2*n,o=new Float64Array(3*r),s=new Float32Array(3*r),a=new Float32Array(2*r),i=new Uint32Array(3*((e-1)*n*2));let l=0,c=0,f=0,u=0;for(let h=0;h<=e;h++){const t=h/e*Math.PI+.5*Math.PI,r=Math.cos(t),p=Math.sin(t);M[2]=p;const w=0===h||h===e,m=w?n-1:n;for(let v=0;v<=m;v++){const t=v/m*2*Math.PI;M[0]=-Math.sin(t)*r,M[1]=Math.cos(t)*r;for(let e=0;e<3;e++)o[l]=.5*M[e],s[l]=M[e],++l;a[c++]=(v+(w?.5:0))/n,a[c++]=h/e,0!==h&&v!==n&&(h!==e&&(i[f++]=u,i[f++]=u+1,i[f++]=u-n),1!==h&&(i[f++]=u,i[f++]=u-n,i[f++]=u-n-1)),u++}}return{position:o,normal:s,uv:a,faces:i}}function f(t=0){const e=5,n=Math.round(16*2**t),r=(e-1)*(n+1)+2*n,o=new Float64Array(3*r),s=new Float32Array(3*r),a=new Float32Array(2*r),i=new Uint32Array(3*(4*n));let l=0,c=0,f=0,u=0,h=0;for(let p=0;p<=e;p++){const t=0===p||p===e,r=p<=1||p>=e-1,w=2===p||4===p,m=t?n-1:n;for(let v=0;v<=m;v++){const g=v/m*2*Math.PI,A=t?0:.5;M[0]=A*Math.sin(g),M[1]=A*-Math.cos(g),M[2]=p<=2?.5:-.5;for(let t=0;t<3;t++)o[l++]=M[t],s[c++]=r?2===t?p<=1?1:-1:0:2===t?0:M[t]/A;a[f++]=(v+(t?.5:0))/n,a[f++]=p<=1?1*p/3:p<=3?1*(p-2)/3+1/3:1*(p-4)/3+2/3,w||0===p||v===n||(p!==e&&(i[u++]=h,i[u++]=h+1,i[u++]=h-n),1!==p&&(i[u++]=h,i[u++]=h-n,i[u++]=h-n-1)),h++}}return{position:o,normal:s,uv:a,faces:i}}function u(t,e){const n="number"==typeof e?e:null!=e?e.width:1,r="number"==typeof e?e:null!=e?e.height:1;switch(t){case"up":case"down":return{width:n,depth:r};case"north":case"south":return{width:n,height:r};case"east":case"west":return{depth:n,height:r}}}function h(t){const e=v.facingAxisOrderSwap[t],n=v.position,r=v.normal,o=new Float64Array(n.length),s=new Float32Array(r.length);let a=0;for(let i=0;i<4;i++){const t=a;for(let i=0;i<3;i++){const l=e[i],c=Math.abs(l)-1,f=l>=0?1:-1;o[a]=n[t+c]*f,s[a]=r[t+c]*f,a++}}return{position:o,normal:s,uv:new Float32Array(v.uv),faces:new Uint32Array(v.faces),isPlane:!0}}const p=1,w=2,m=3,v={position:[-.5,-.5,0,.5,-.5,0,.5,.5,0,-.5,.5,0],normal:[0,0,1,0,0,1,0,0,1,0,0,1],uv:[0,1,1,1,1,0,0,0],faces:[0,1,2,0,2,3],facingAxisOrderSwap:{east:[m,p,w],west:[-m,-p,w],north:[-p,m,w],south:[p,-m,w],up:[p,w,m],down:[p,-w,-m]}};function g(t,e,n){t.isPlane||A(t),x(t,n?.size);const{vertexAttributes:r,vertexSpace:i,transform:l}=a(t,e,n);return{vertexAttributes:new s({...r,uv:t.uv}),vertexSpace:i,transform:l,components:[new o({faces:t.faces,material:n&&n.material||null})],spatialReference:e.spatialReference}}function A(t){for(let e=0;e<t.position.length;e+=3)t.position[e+2]+=.5}function x(t,r){if(null==r)return;const o="number"==typeof r?[r,r,r]:[null!=r.width?r.width:1,null!=r.depth?r.depth:1,null!=r.height?r.height:1];F[0]=o[0],F[4]=o[1],F[8]=o[2];for(let n=0;n<t.position.length;n+=3){for(let e=0;e<3;e++)M[e]=t.position[n+e];e(M,M,F);for(let e=0;e<3;e++)t.position[n+e]=M[e]}if(o[0]!==o[1]||o[1]!==o[2]){F[0]=1/o[0],F[4]=1/o[1],F[8]=1/o[2];for(let r=0;r<t.normal.length;r+=3){for(let e=0;e<3;e++)M[e]=t.normal[r+e];e(M,M,F),n(M,M);for(let e=0;e<3;e++)t.normal[r+e]=M[e]}}}const y={faceDescriptions:[{axis:[0,-1,0],uvOrigin:[0,.625],corners:[[-1,-1],[1,-1],[1,1],[-1,1]]},{axis:[1,0,0],uvOrigin:[.25,.625],corners:[[-1,-1],[1,-1],[1,1],[-1,1]]},{axis:[0,1,0],uvOrigin:[.5,.625],corners:[[1,-1],[-1,-1],[-1,1],[1,1]]},{axis:[-1,0,0],uvOrigin:[.75,.625],corners:[[1,-1],[-1,-1],[-1,1],[1,1]]},{axis:[0,0,1],uvOrigin:[0,.375],corners:[[-1,-1],[1,-1],[1,1],[-1,1]]},{axis:[0,0,-1],uvOrigin:[0,.875],corners:[[-1,1],[1,1],[1,-1],[-1,-1]]}],uvScales:[[0,0],[1,0],[1,1],[0,1]],faceVertexOffsets:[0,1,2,0,2,3]},d={south:0,east:1,north:2,west:3,up:4,down:5},M=r(),F=t();export{d as boxFaceOrder,u as convertPlaneSizeParameter,g as convertUnitGeometry,i as createUnitSizeBox,f as createUnitSizeCylinder,h as createUnitSizePlane,c as createUnitSizeSphere,l as extractSingleFaceOfBox};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../core/Logger.js";import{f as e}from"../../../chunks/mat3.js";import{c as r}from"../../../chunks/mat3f64.js";import{d as o}from"../../../chunks/mat4.js";import{c as n}from"../../../chunks/mat4f64.js";import{s as i,b as s,a,t as l,m as c}from"../../../chunks/vec3.js";import{c as f,Z as p}from"../../../chunks/vec3f64.js";import{projectPointToVector as m,computeTranslationToOriginAndRotation as g}from"../../projection.js";import{getSphericalPCPF as u}from"../../spatialReferenceEllipsoidUtils.js";import{create as h,compose as j,axis as v,angleRad as x}from"../axisAngleDegrees.js";import{isGeographicMesh as A}from"./geographicUtils.js";import{projectToPCPF as d,projectNormalToPCPF as b,projectTangentToPCPF as k,projectFromPCPF as y,projectNormalFromPCPF as w,projectTangentFromPCPF as R}from"./projection.js";const F=t.getLogger("esri.geometry.support.meshUtils.rotate");function L(t,e,r){if(!t.vertexAttributes||!t.vertexAttributes.position||0===e[3])return;const o=t.spatialReference;if(null!=t.transform){null!=r?.geographic&&r.geographic!==t.transform.geographic&&F.warn(`Specifying the 'geographic' parameter (${r.geographic}) different from the Mesh transform setting (${t.transform.geographic}) is not supported`);const n=r?.origin??t.transform.getOriginPoint(o);$(t.transform,e,n)}else{const o=r?.origin??t.origin;A(t.spatialReference,r)?U(t,e,o):z(t,e,o)}}function $(t,e,r){const o=i(I,r.x,r.y,r.z),n=s(I,o,t.origin);t.applyLocalInverse(n,D),t.rotation=j(t.rotation,e,h()),t.applyLocalInverse(n,n),s(n,n,D),t.translation=a(f(),t.translation,n)}function U(t,r,o){const n=t.spatialReference,i=u(n),s=P;m(o,s,i)||m(t.origin,s,i);const a=t.vertexAttributes.position,c=t.vertexAttributes.normal,f=t.vertexAttributes.tangent,p=new Float64Array(a.length),h=null!=c?new Float32Array(c.length):null,j=null!=f?new Float32Array(f.length):null;g(i,s,M,i),e(O,M);const x=E;l(v(E),v(r),O),x[3]=r[3],d(a,n,p),null!=c&&null!=h&&b(c,a,p,n,h),null!=f&&null!=j&&k(f,a,p,n,j),C(p,x,3,s),y(p,a,n),null!=c&&null!=h&&(C(h,x,3),w(h,a,p,n,c)),null!=f&&null!=j&&(C(j,x,4),R(j,a,p,n,f)),t.vertexAttributesChanged()}function z(t,e,r){const o=P;if(!m(r,o,t.spatialReference)){const e=t.origin;o[0]=e.x,o[1]=e.y,o[2]=e.z,F.error(`Failed to project specified origin (wkid:${r.spatialReference.wkid}) to mesh spatial reference (wkid:${t.spatialReference.wkid}).`)}C(t.vertexAttributes.position,e,3,o),C(t.vertexAttributes.normal,e,3),C(t.vertexAttributes.tangent,e,4),t.vertexAttributesChanged()}function C(t,e,r,n=p){if(null!=t){o(M,x(e),v(e));for(let e=0;e<t.length;e+=r){for(let r=0;r<3;r++)I[r]=t[e+r]-n[r];c(I,I,M);for(let r=0;r<3;r++)t[e+r]=I[r]+n[r]}}}const I=f(),D=f(),E=h(),M=n(),O=r(),P=f();export{L as rotate};
5
+ import t from"../../../core/Logger.js";import{f as e}from"../../../chunks/mat3.js";import{c as r}from"../../../chunks/mat3f64.js";import{d as o}from"../../../chunks/mat4.js";import{c as n}from"../../../chunks/mat4f64.js";import{s as i,b as s,a,t as l,m as c}from"../../../chunks/vec3.js";import{c as f,Z as m}from"../../../chunks/vec3f64.js";import{projectPointToVector as p,computeTranslationToOriginAndRotation as u}from"../../projection.js";import{getSphericalPCPF as g}from"../../spatialReferenceEllipsoidUtils.js";import{create as h,compose as j,axis as v,angleRad as x}from"../axisAngleDegrees.js";import A from"../MeshTransform.js";import{validateGeographicFlag as b,isGeographicMesh as d}from"./geographicUtils.js";import{projectToPCPF as k,projectNormalToPCPF as w,projectTangentToPCPF as y,projectFromPCPF as R,projectNormalFromPCPF as F,projectTangentFromPCPF as L}from"./projection.js";const U="esri.geometry.support.meshUtils.rotate";function z(t,e,r){if(!t.vertexAttributes||!t.vertexAttributes.position||0===e[3])return;const{spatialReference:o,vertexSpace:n}=t;if(n.isRelative){b(n,U,r);const o=r?.origin??t.origin;t.transform??=new A,C(t.transform,n,e,o)}else{const n=r?.origin??t.origin;d(o,r)?I(t,e,n):$(t,e,n)}}function C(t,e,r,o){const n=e.origin,l=i(E,o.x,o.y,o.z??0),c=s(E,l,n);t.applyLocalInverse(c,M),t.rotation=j(t.rotation,r,h()),t.applyLocalInverse(c,c),s(c,c,M),t.translation=a(f(),t.translation,c)}function I(t,r,o){const n=t.spatialReference,i=g(n),s=q;p(o,s,i)||p(t.origin,s,i);const a=t.vertexAttributes.position,c=t.vertexAttributes.normal,f=t.vertexAttributes.tangent,m=new Float64Array(a.length),h=null!=c?new Float32Array(c.length):null,j=null!=f?new Float32Array(f.length):null;u(i,s,T,i),e(Z,T);const x=S;l(v(S),v(r),Z),x[3]=r[3],k(a,n,m),null!=c&&null!=h&&w(c,a,m,n,h),null!=f&&null!=j&&y(f,a,m,n,j),D(m,x,3,s),R(m,a,n),null!=c&&null!=h&&(D(h,x,3),F(h,a,m,n,c)),null!=f&&null!=j&&(D(j,x,4),L(j,a,m,n,f)),t.vertexAttributesChanged()}function $(e,r,o){const n=q;if(!p(o,n,e.spatialReference)){const r=e.origin;n[0]=r.x,n[1]=r.y,n[2]=r.z,t.getLogger(U).error(`Failed to project specified origin (wkid:${o.spatialReference.wkid}) to mesh spatial reference (wkid:${e.spatialReference.wkid}).`)}D(e.vertexAttributes.position,r,3,n),D(e.vertexAttributes.normal,r,3),D(e.vertexAttributes.tangent,r,4),e.vertexAttributesChanged()}function D(t,e,r,n=m){if(null!=t){o(T,x(e),v(e));for(let e=0;e<t.length;e+=r){for(let r=0;r<3;r++)E[r]=t[e+r]-n[r];c(E,E,T);for(let r=0;r<3;r++)t[e+r]=E[r]+n[r]}}}const E=f(),M=f(),S=h(),T=n(),Z=r(),q=f();export{z as rotate};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Logger.js";import{s as t,b as r,g as n,a as o}from"../../../chunks/vec3.js";import{c as i,Z as s}from"../../../chunks/vec3f64.js";import{projectPointToVector as l}from"../../projection.js";import{getSphericalPCPF as a}from"../../spatialReferenceEllipsoidUtils.js";import{isGeographicMesh as c}from"./geographicUtils.js";import{projectToPCPF as p,projectNormalToPCPF as f,projectTangentToPCPF as g,projectFromPCPF as u,projectNormalFromPCPF as m,projectTangentFromPCPF as h}from"./projection.js";const v=e.getLogger("esri.geometry.support.meshUtils.scale");function d(e,t,r){if(!e.vertexAttributes||!e.vertexAttributes.position)return;const n=e.spatialReference;if(null!=e.transform){null!=r?.geographic&&r.geographic!==e.transform.geographic&&v.warn(`Specifying the 'geographic' parameter (${r.geographic}) different from the Mesh transform setting (${e.transform.geographic}) is not supported`);const o=r?.origin??e.transform.getOriginPoint(n);x(e.transform,t,o)}else{const n=c(e.spatialReference,r),o=r&&r.origin||e.origin;n?A(e,t,o):j(e,t,o)}}function x(e,s,l){const a=t(y,l.x,l.y,l.z),c=r(y,a,e.origin);e.applyLocalInverse(c,w);const p=n(i(),e.scale,s);e.scale=p,e.applyLocalInverse(c,c),r(c,c,w),e.translation=o(i(),e.translation,c)}function A(e,t,r){const n=e.spatialReference,o=a(n),i=R;l(r,i,o)||l(e.origin,i,o);const s=e.vertexAttributes.position,c=e.vertexAttributes.normal,v=e.vertexAttributes.tangent,d=new Float64Array(s.length),x=null!=c?new Float32Array(c.length):null,A=null!=v?new Float32Array(v.length):null;p(s,n,d),null!=c&&null!=x&&f(c,s,d,n,x),null!=v&&null!=A&&g(v,s,d,n,A),b(d,t,i),u(d,s,n),null!=c&&null!=x&&m(x,s,d,n,c),null!=v&&null!=A&&h(A,s,d,n,v),e.vertexAttributesChanged()}function j(e,t,r){const n=R;if(!l(r,n,e.spatialReference)){const t=e.origin;n[0]=t.x,n[1]=t.y,n[2]=t.z,v.error(`Failed to project specified origin (wkid:${r.spatialReference.wkid}) to mesh spatial reference (wkid:${e.spatialReference.wkid}).`)}b(e.vertexAttributes.position,t,n),e.vertexAttributesChanged()}function b(e,t,r=s){if(e)for(let o=0;o<e.length;o+=3){for(let t=0;t<3;t++)y[t]=e[o+t]-r[t];n(y,y,t);for(let t=0;t<3;t++)e[o+t]=y[t]+r[t]}}const y=i(),w=i(),R=i();export{d as scale};
5
+ import e from"../../../core/Logger.js";import{s as t,b as r,g as n,a as o}from"../../../chunks/vec3.js";import{c as i,Z as s}from"../../../chunks/vec3f64.js";import{projectPointToVector as l}from"../../projection.js";import{getSphericalPCPF as a}from"../../spatialReferenceEllipsoidUtils.js";import c from"../MeshTransform.js";import{validateGeographicFlag as f,isGeographicMesh as p}from"./geographicUtils.js";import{projectToPCPF as u,projectNormalToPCPF as g,projectTangentToPCPF as m,projectFromPCPF as v,projectNormalFromPCPF as h,projectTangentFromPCPF as x}from"./projection.js";const j="esri.geometry.support.meshUtils.scale";function A(e,t,r){if(!e.vertexAttributes||!e.vertexAttributes.position)return;const{spatialReference:n,vertexSpace:o}=e;if(o.isRelative){f(o,j,r);const n=r?.origin??e.origin;e.transform??=new c,b(e.transform,o,t,n)}else{const o=p(n,r),i=r?.origin??e.origin;o?d(e,t,i):w(e,t,i)}}function b(e,s,l,a){const c=s.origin,f=t(R,a.x,a.y,a.z),p=r(R,f,c);e.applyLocalInverse(p,k);const u=n(i(),e.scale,l);e.scale=u,e.applyLocalInverse(p,p),r(p,p,k),e.translation=o(i(),e.translation,p)}function d(e,t,r){const n=e.spatialReference,o=a(n),i=F;l(r,i,o)||l(e.origin,i,o);const s=e.vertexAttributes.position,c=e.vertexAttributes.normal,f=e.vertexAttributes.tangent,p=new Float64Array(s.length),j=null!=c?new Float32Array(c.length):null,A=null!=f?new Float32Array(f.length):null;u(s,n,p),null!=c&&null!=j&&g(c,s,p,n,j),null!=f&&null!=A&&m(f,s,p,n,A),y(p,t,i),v(p,s,n),null!=c&&null!=j&&h(j,s,p,n,c),null!=f&&null!=A&&x(A,s,p,n,f),e.vertexAttributesChanged()}function w(t,r,n){const o=F;if(!l(n,o,t.spatialReference)){const r=t.origin;o[0]=r.x,o[1]=r.y,o[2]=r.z,e.getLogger(j).error(`Failed to project specified origin (wkid:${n.spatialReference.wkid}) to mesh spatial reference (wkid:${t.spatialReference.wkid}).`)}y(t.vertexAttributes.position,r,o),t.vertexAttributesChanged()}function y(e,t,r=s){if(e)for(let o=0;o<e.length;o+=3){for(let t=0;t<3;t++)R[t]=e[o+t]-r[t];n(R,R,t);for(let t=0;t<3;t++)e[o+t]=R[t]+r[t]}}const R=i(),k=i(),F=i();export{A as scale};
package/interfaces.d.ts CHANGED
@@ -5623,6 +5623,12 @@ declare namespace __esri {
5623
5623
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Mesh.html#components)
5624
5624
  */
5625
5625
  components: MeshComponent[];
5626
+ /**
5627
+ * The transform of the mesh.
5628
+ *
5629
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Mesh.html#transform)
5630
+ */
5631
+ transform: void;
5626
5632
  /**
5627
5633
  * The string value representing the type of geometry.
5628
5634
  *
@@ -5635,6 +5641,12 @@ declare namespace __esri {
5635
5641
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Mesh.html#vertexAttributes)
5636
5642
  */
5637
5643
  vertexAttributes: MeshVertexAttributes;
5644
+ /**
5645
+ * The vertex space of the mesh.
5646
+ *
5647
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Mesh.html#vertexSpace)
5648
+ */
5649
+ vertexSpace: MeshGeoreferencedVertexSpace | MeshGeoreferencedRelativeVertexSpace | MeshLocalVertexSpace;
5638
5650
  /**
5639
5651
  * A mesh is a general, client-side 3D [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html) type composed of [vertices with attributes](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Mesh.html#vertexAttributes).
5640
5652
  *
@@ -5744,12 +5756,26 @@ declare namespace __esri {
5744
5756
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Mesh.html#components)
5745
5757
  */
5746
5758
  components?: MeshComponentProperties[];
5759
+ /**
5760
+ * The transform of the mesh.
5761
+ *
5762
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Mesh.html#transform)
5763
+ */
5764
+ transform?: void;
5747
5765
  /**
5748
5766
  * Object describing the attributes of each vertex of the mesh.
5749
5767
  *
5750
5768
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Mesh.html#vertexAttributes)
5751
5769
  */
5752
5770
  vertexAttributes?: MeshVertexAttributesProperties;
5771
+ /**
5772
+ * The vertex space of the mesh.
5773
+ *
5774
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Mesh.html#vertexSpace)
5775
+ */
5776
+ vertexSpace?: | (MeshGeoreferencedVertexSpaceProperties & { type: "georeferenced" })
5777
+ | (MeshGeoreferencedRelativeVertexSpaceProperties & { type: "georeferenced-relative" })
5778
+ | (MeshLocalVertexSpaceProperties & { type: "local" });
5753
5779
  }
5754
5780
 
5755
5781
  export interface MeshCenterAtParams {
@@ -6963,6 +6989,105 @@ declare namespace __esri {
6963
6989
  shading?: "source" | "flat" | "smooth";
6964
6990
  }
6965
6991
 
6992
+ export interface MeshGeoreferencedRelativeVertexSpace extends Accessor, JSONSupport {
6993
+ }
6994
+
6995
+ export class MeshGeoreferencedRelativeVertexSpace {
6996
+ /**
6997
+ * Origin of the vertex space.
6998
+ *
6999
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshGeoreferencedRelativeVertexSpace.html#origin)
7000
+ */
7001
+ origin: number[];
7002
+ /**
7003
+ * Type of the vertex space.
7004
+ *
7005
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshGeoreferencedRelativeVertexSpace.html#type)
7006
+ */
7007
+ readonly type: "georeferenced-relative";
7008
+ /**
7009
+ * A georeferenced relative mesh vertex space.
7010
+ *
7011
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshGeoreferencedRelativeVertexSpace.html)
7012
+ */
7013
+ constructor(properties?: MeshGeoreferencedRelativeVertexSpaceProperties);
7014
+ static fromJSON(json: any): MeshGeoreferencedRelativeVertexSpace;
7015
+ }
7016
+
7017
+ /** @deprecated Import the MeshGeoreferencedRelativeVertexSpace class instead. */
7018
+ export type MeshGeoreferencedRelativeVertexSpaceConstructor = typeof MeshGeoreferencedRelativeVertexSpace;
7019
+
7020
+ interface MeshGeoreferencedRelativeVertexSpaceProperties {
7021
+ /**
7022
+ * Origin of the vertex space.
7023
+ *
7024
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshGeoreferencedRelativeVertexSpace.html#origin)
7025
+ */
7026
+ origin?: number[];
7027
+ }
7028
+
7029
+ export interface MeshGeoreferencedVertexSpace extends Accessor, JSONSupport {
7030
+ }
7031
+
7032
+ export class MeshGeoreferencedVertexSpace {
7033
+ /**
7034
+ * Type of the vertex space.
7035
+ *
7036
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshGeoreferencedVertexSpace.html#type)
7037
+ */
7038
+ readonly type: "georeferenced";
7039
+ /**
7040
+ * A georeferenced mesh vertex space.
7041
+ *
7042
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshGeoreferencedVertexSpace.html)
7043
+ */
7044
+ constructor(properties?: MeshGeoreferencedVertexSpaceProperties);
7045
+ static fromJSON(json: any): MeshGeoreferencedVertexSpace;
7046
+ }
7047
+
7048
+ /** @deprecated Import the MeshGeoreferencedVertexSpace class instead. */
7049
+ export type MeshGeoreferencedVertexSpaceConstructor = typeof MeshGeoreferencedVertexSpace;
7050
+
7051
+ interface MeshGeoreferencedVertexSpaceProperties {
7052
+ }
7053
+
7054
+ export interface MeshLocalVertexSpace extends Accessor, JSONSupport {
7055
+ }
7056
+
7057
+ export class MeshLocalVertexSpace {
7058
+ /**
7059
+ * Origin of the vertex space.
7060
+ *
7061
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshLocalVertexSpace.html#origin)
7062
+ */
7063
+ origin: number[];
7064
+ /**
7065
+ * Type of the vertex space.
7066
+ *
7067
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshLocalVertexSpace.html#type)
7068
+ */
7069
+ readonly type: "local";
7070
+ /**
7071
+ * A local mesh vertex space.
7072
+ *
7073
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshLocalVertexSpace.html)
7074
+ */
7075
+ constructor(properties?: MeshLocalVertexSpaceProperties);
7076
+ static fromJSON(json: any): MeshLocalVertexSpace;
7077
+ }
7078
+
7079
+ /** @deprecated Import the MeshLocalVertexSpace class instead. */
7080
+ export type MeshLocalVertexSpaceConstructor = typeof MeshLocalVertexSpace;
7081
+
7082
+ interface MeshLocalVertexSpaceProperties {
7083
+ /**
7084
+ * Origin of the vertex space.
7085
+ *
7086
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshLocalVertexSpace.html#origin)
7087
+ */
7088
+ origin?: number[];
7089
+ }
7090
+
6966
7091
  export class MeshMaterial extends Accessor {
6967
7092
  /**
6968
7093
  * Specifies how transparency on the object is handled.
@@ -7381,6 +7506,95 @@ declare namespace __esri {
7381
7506
  scale?: number[];
7382
7507
  }
7383
7508
 
7509
+ export interface MeshTransform extends Accessor, JSONSupport {
7510
+ }
7511
+
7512
+ export class MeshTransform {
7513
+ /**
7514
+ * Rotation angle in degrees.
7515
+ *
7516
+ * @default 0
7517
+ *
7518
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshTransform.html#rotationAngle)
7519
+ */
7520
+ rotationAngle: number;
7521
+ /**
7522
+ * Axis of rotation.
7523
+ *
7524
+ * @default [0, 0, 1]
7525
+ *
7526
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshTransform.html#rotationAxis)
7527
+ */
7528
+ rotationAxis: number[];
7529
+ /**
7530
+ * Scale.
7531
+ *
7532
+ * @default [1, 1, 1]
7533
+ *
7534
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshTransform.html#scale)
7535
+ */
7536
+ scale: number[];
7537
+ /**
7538
+ * Translation.
7539
+ *
7540
+ * @default [0, 0, 0]
7541
+ *
7542
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshTransform.html#translation)
7543
+ */
7544
+ translation: number[];
7545
+ /**
7546
+ * A mesh transform.
7547
+ *
7548
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshTransform.html)
7549
+ */
7550
+ constructor(properties?: MeshTransformProperties);
7551
+ /**
7552
+ * Creates a deep clone.
7553
+ *
7554
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshTransform.html#clone)
7555
+ */
7556
+ clone(): MeshTransform;
7557
+ static fromJSON(json: any): MeshTransform;
7558
+ }
7559
+
7560
+ /** @deprecated Import the MeshTransform class instead. */
7561
+ export type MeshTransformConstructor = typeof MeshTransform;
7562
+
7563
+ interface MeshTransformProperties {
7564
+ /**
7565
+ * Rotation angle in degrees.
7566
+ *
7567
+ * @default 0
7568
+ *
7569
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshTransform.html#rotationAngle)
7570
+ */
7571
+ rotationAngle?: number;
7572
+ /**
7573
+ * Axis of rotation.
7574
+ *
7575
+ * @default [0, 0, 1]
7576
+ *
7577
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshTransform.html#rotationAxis)
7578
+ */
7579
+ rotationAxis?: number[];
7580
+ /**
7581
+ * Scale.
7582
+ *
7583
+ * @default [1, 1, 1]
7584
+ *
7585
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshTransform.html#scale)
7586
+ */
7587
+ scale?: number[];
7588
+ /**
7589
+ * Translation.
7590
+ *
7591
+ * @default [0, 0, 0]
7592
+ *
7593
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshTransform.html#translation)
7594
+ */
7595
+ translation?: number[];
7596
+ }
7597
+
7384
7598
  /**
7385
7599
  * Various utilities and convenience functions for working with [Mesh](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Mesh.html) objects.
7386
7600
  *
@@ -35707,6 +35921,12 @@ declare namespace __esri {
35707
35921
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#urlKey)
35708
35922
  */
35709
35923
  urlKey: string;
35924
+ /**
35925
+ * When `false`, 3D basemaps are hidden from the [BasemapGallery](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html), regardless of the type of the view.
35926
+ *
35927
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#use3dBasemaps)
35928
+ */
35929
+ use3dBasemaps: boolean;
35710
35930
  /**
35711
35931
  * Information representing a registered user of the portal.
35712
35932
  *
@@ -36171,6 +36391,12 @@ declare namespace __esri {
36171
36391
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#urlKey)
36172
36392
  */
36173
36393
  urlKey?: string;
36394
+ /**
36395
+ * When `false`, 3D basemaps are hidden from the [BasemapGallery](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html), regardless of the type of the view.
36396
+ *
36397
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#use3dBasemaps)
36398
+ */
36399
+ use3dBasemaps?: boolean;
36174
36400
  /**
36175
36401
  * Information representing a registered user of the portal.
36176
36402
  *
@@ -36224,7 +36450,7 @@ declare namespace __esri {
36224
36450
  *
36225
36451
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#fetchBasemaps)
36226
36452
  */
36227
- fetchBasemaps3D?: boolean;
36453
+ include3d?: boolean;
36228
36454
  }
36229
36455
 
36230
36456
  export interface PortalFetchCategorySchemaOptions {
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../Graphic.js";import t from"../request.js";import has from"../core/has.js";import i from"../core/Logger.js";import{removeMaybe as s}from"../core/maybe.js";import{isAbortError as r}from"../core/promiseUtils.js";import{watch as a}from"../core/reactiveUtils.js";import{i as n}from"../chunks/vec3.js";import{c as o}from"../chunks/vec3f64.js";import{renderSRFromViewSR as l}from"../geometry/support/coordinateSystem.js";import{PointIndex as h,PlaneIndex as d}from"../geometry/support/frustum.js";import{WasmCullMode as _,VoxelRequestType as u,UpdateFlags as c,ContainerType as m}from"../libs/vxl/enums.js";import{loadVoxelWASM as g}from"../libs/vxl/VxlModule.js";import{ViewingMode as f}from"../views/ViewingMode.js";import{VoxelTarget as p}from"../views/3d/layers/i3s/Intersector.js";import{Frustum as x}from"../views/3d/state/Frustum.js";import{RenderCoordsHelper as y}from"../views/3d/support/RenderCoordsHelper.js";import{ShaderOutput as v}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{newIntersectorResult as b}from"../views/3d/webgl-engine/lib/Intersector.js";import{IntersectorType as w,StoreResults as T}from"../views/3d/webgl-engine/lib/IntersectorInterfaces.js";import{RenderFeature as R}from"../views/3d/webgl-engine/lib/RenderFeature.js";import{RenderSlot as L}from"../views/3d/webgl-engine/lib/RenderSlot.js";import{ContextType as E}from"../views/webgl/contextUtils.js";import{CompareFunction as C,Face as F,StencilOperation as V}from"../views/webgl/enums.js";const S=i.getLogger("esri.layers.VoxelWasmPerSceneView");var P;!function(e){e[e.Lifetime=1]="Lifetime",e[e.RequestResponse=2]="RequestResponse",e[e.Rendering=3]="Rendering",e[e.Error=4]="Error"}(P||(P={}));class U{constructor(e){this._halfIntTexturesAvailable=!1,this._textureFloatLinearAvailable=!1,this._havePreparedWithAllLayers=!1,this._readyWatchHandle=null,this._qualityWatchHandle=null,this._stationaryWatchHandle=null,this._timeExtentWatchHandle=null,this._renderPluginContext=null,this._vxlPromise=null,this._vxl=null,this._pluginIsActive=!1,this._moreToLoad=!1,this._viewportWidth=-1,this._viewportHeight=-1,this._newLayers=[],this._layers=new Map,this._shaderOutput=v.Color,this._renderSlot=L.VOXEL,this._rctx=null,this._renderTargetToRestore=null,this._lastFrameWasStationary=!1,this._wasmMemBlockSizes=[512,1024,2048,4096,8192,16384,32768,65536],this._wasmMemBlocks=new Map,this._dbgFlags=new Set,this._captureFrustum=!1,this._frustum=null,this._frustumRenderableId=-1,this._renderCoordsHelper=null,this.type=w.VOXEL,this.slicePlaneEnabled=!0,this.isGround=!1,this.layerUid=[],this._view=e,this._initialize()}get canRender(){return!!this._vxl&&"local"===this._view.viewingMode}_dbg(e,t){this._dbgFlags.has(e)&&(e===P.Error?S.error(t):S.warn(t))}_removeRenderPlugin(){this._pluginIsActive&&this._view._stage&&(this._dbg(P.Lifetime,"--removeRenderPlugin--"),this._view._stage.removeRenderPlugin(this)),this._pluginIsActive=!1}_initialize(){this._dbg(P.Lifetime,"--initialize--");for(const e of this._wasmMemBlockSizes)this._wasmMemBlocks.set(e,0);this._readyWatchHandle=a((()=>this._view.ready),(e=>{e&&"local"===this._view.viewingMode?(this._dbg(P.Lifetime,"view ready status changed to ready on a local view, calling addRenderPlugin"),this._view._stage.addRenderPlugin([this._renderSlot],this),this._pluginIsActive=!0):(this._dbg(P.Lifetime,"view ready status changed, not ready or not a local view!"),this._removeRenderPlugin())}),{initial:!0}),this._qualityWatchHandle=a((()=>this._view?.qualityProfile),(e=>{this._dbg(P.Rendering,"qualityProfile changed to "+e),this._vxl&&this._vxl.set_quality(this._toWasmQuality(e))}),{initial:!0}),this._timeExtentWatchHandle=a((()=>this._view?.timeExtent),(()=>{if(this._vxl){const e=this._getTimeArgs(this._view?.timeExtent);this._dbg(P.Rendering,"sceneView timeExtent changed to useTime="+e.useTime+" st="+e.startTime+" et="+e.endTime),this._vxl.set_scene_time_extent(e.startTime,e.endTime,e.useTime),this._renderPluginContext.requestRender()}}),{initial:!0}),this._stationaryWatchHandle=a((()=>this._view?.stationary),(e=>{this._vxl&&e&&!this._lastFrameWasStationary&&this._renderPluginContext.requestRender()}))}initializeRenderContext(e){this._dbg(P.Lifetime,"--initializeRenderContext--");const t=e.renderContext.rctx;t.type===E.WEBGL2?(this._renderPluginContext=e,this._rctx=e.renderContext.rctx,this._halfIntTexturesAvailable=!!this._rctx.capabilities.textureNorm16,this._textureFloatLinearAvailable=this._rctx.capabilities.textureFloatLinear,this._initializeWasm(t.gl)):this._dbg(P.Error,"WebGL 1 context only!")}uninitializeRenderContext(){this._renderPluginContext=null,this._rctx=null,this._dbg(P.Lifetime,"--uninitializeRenderContext--")}_restoreFramebuffer(){if(!this._renderTargetToRestore)return;const e=this._renderTargetToRestore.fbo;if(!!!this._rctx)return void this._dbg(P.Error,"no context in restoreFramebuffer!");this._rctx.bindFramebuffer(e,!0);const t=this._renderTargetToRestore.viewport;this._rctx.setViewport(t.x,t.y,t.width,t.height)}_bindPreviousDepthToSlot(e,t){const i=!!this._rctx,s=!!this._renderTargetToRestore;if(!i||!s)return 0;const r=this._renderTargetToRestore.fbo.depthStencilTexture;return r?(0===t?this._rctx.bindTexture(null,e,!0):this._rctx.bindTexture(r,e,!0),1):(this._dbg(P.Error,"no depth/stencil texture exists!"),0)}_modifyResourceCount(e,t,i){if(!this._rctx)return void this._dbg(P.Error,"modifyAllocation callback has no rendering context!");const s=e;1===i?this._rctx.instanceCounter.increment(s,t):this._rctx.instanceCounter.decrement(s,t)}_setBlendState(e,t,i,s){this._rctx?(this._rctx.setBlendingEnabled(1===e),this._rctx.setBlendFunction(t,i),this._rctx.setBlendEquation(s)):this._dbg(P.Error,"setBlendState callback has no rendering context!")}_setFrontFace(e){this._rctx?this._rctx.setFrontFace(e):this._dbg(P.Error,"setFrontFace callback has no rendering context!")}_setDepthStencilStateFunction(e,t,i){this._rctx?(this._rctx.setDepthFunction(i),this._rctx.setDepthTestEnabled(1===e),this._rctx.setDepthWriteEnabled(1===t),this._rctx.setStencilTestEnabled(!1),this._rctx.setStencilFunction(C.ALWAYS,0,255),this._rctx.setStencilOpSeparate(F.FRONT,V.KEEP,V.INCR,V.KEEP),this._rctx.setStencilOpSeparate(F.BACK,V.KEEP,V.DECR,V.KEEP)):this._dbg(P.Error,"setDepthStencilStateFunction callback has no rendering context!")}_setRasterizerState(e){if(this._rctx)switch(e){case _.None:this._rctx.setFaceCullingEnabled(!1);break;case _.Back:this._rctx.setCullFace(F.BACK),this._rctx.setFaceCullingEnabled(!0);break;case _.Front:this._rctx.setCullFace(F.FRONT),this._rctx.setFaceCullingEnabled(!0)}else this._dbg(P.Error,"setRasterizerState callback has no rendering context!")}_setViewport(e,t,i,s){this._rctx?this._rctx.setViewport(e,t,i,s):this._dbg(P.Error,"setViewport callback has no rendering context!")}_updateMemoryUsage(){this._layers.forEach(((e,t)=>{if(e.needMemoryUsageUpdate){const i=this._vxl.estimate_memory_usage(t);i>=0&&(e.needMemoryUsageUpdate=!1,e.layerView.setUsedMemory(i))}}))}_syncRequestsResponses(){this._layers.forEach(((e,i)=>{const s=[];e.responses.forEach(((t,r)=>{s.push(r),this._dbg(P.RequestResponse,"responding for requestID:"+r+" size:"+t.size),this._vxl.respond(i,r,t),t.requestType!==u.TreeIndex&&t.requestType!==u.Section||(e.needMemoryUsageUpdate=!0)}));const a=e.responses;for(const t of s)a.delete(t);const n=this._vxl.get_new_requests(i),o=e.abortController.signal;for(const l in n){e.outstandingRequestCount+=1,1===e.outstandingRequestCount&&e.layerView.updatingFlagChanged();const i=n[l],s={responseType:"array-buffer",signal:o};this._dbg(P.RequestResponse,"making requestID:"+l+" url:"+i.url),t(i.url,s).then((t=>{e.outstandingRequestCount-=1,0===e.outstandingRequestCount&&e.layerView.updatingFlagChanged(),this._dbg(P.RequestResponse,"have response for requestID:"+l);let s=0;if(t.data.byteLength>0){s=this._vxl._malloc(t.data.byteLength);const e=new Uint8Array(this._vxl.HEAPU8.buffer,s,t.data.byteLength),i=new Uint8Array(t.data);for(let s=0;s<t.data.byteLength;++s)e[s]=i[s]}a.set(+l,{responseType:i.responseType,ptr:s,size:t.data.byteLength,success:!0,requestType:i.requestType})})).catch((t=>{e.outstandingRequestCount-=1,0===e.outstandingRequestCount&&e.layerView.updatingFlagChanged(),r(t)||(this._dbg(P.Error,`requestID:${l} failed, error=${t.toString()}`),a.set(+l,{responseType:i.responseType,ptr:0,size:0,success:!1,requestType:i.requestType}))}))}}))}updateWasmCamera(e){this._vxl.set_projection_matrix.apply(this._vxl,e.projectionMatrix),this._vxl.set_view_matrix.apply(this._vxl,e.viewMatrix),this._vxl.set_near_far(e.near,e.far)}isUpdating(e){if(!this._vxl&&this._vxlPromise)return!0;const t=this._layers.get(e);return!!t&&t.outstandingRequestCount>0}getLayerTimes(e){const t=[];return this._layers.forEach(((i,s)=>{if(i.layerView.wasmLayerId===e.wasmLayerId){const i=this._vxl.get_layer_epoch_times(s,e.layer.currentVariableId);for(let e=0;e<i.length;++e)t.push(i[e])}})),t}getCurrentLayerTimeIndex(e){let t=0;return this._layers.forEach(((i,s)=>{i.layerView.wasmLayerId===e.wasmLayerId&&(t=this._vxl.get_layer_current_time_id(s))})),t}setEnabled(e,t){this._layers.forEach(((i,s)=>{i.layerView.wasmLayerId===e.wasmLayerId&&(this._vxl.set_enabled(s,t),i.needMemoryUsageUpdate=!0,this._renderPluginContext.requestRender())}))}setStaticSections(e,t){const i={mask:c.StaticSections,staticSections:t};return this._doMaskedUIUpdate(e,i,!0)}setCurrentVariable(e,t){const i={mask:c.CurrentVariable,currentVariable:t};return this._doMaskedUIUpdate(e,i,!0)}setRenderMode(e,t){const i={mask:c.RenderMode,renderMode:t};return this._doMaskedUIUpdate(e,i,!0)}setVerticalExaggerationAndOffset(e,t,i,s){const r={mask:c.ExaggerationAndOffset,volStyleDesc:{volumeId:t,verticalExaggeration:i,verticalOffset:s}};return this._doMaskedUIUpdate(e,r,!0)}setVariableStyles(e,t){const i={mask:c.VariableStyles,variableStyles:t};return this._doMaskedUIUpdate(e,i,!0)}setVolumeStyles(e,t){const i={mask:c.VolumeStyles,volumeStyles:t};return this._doMaskedUIUpdate(e,i,!0)}setEnableDynamicSections(e,t){const i={mask:c.ContainerVisibility,containerIsVisible:t,container:m.DynamicSections};return this._doMaskedUIUpdate(e,i,!0)}setEnableIsosurfaces(e,t){const i={mask:c.ContainerVisibility,containerIsVisible:t,container:m.Isosurfaces};return this._doMaskedUIUpdate(e,i,!0)}setEnableSections(e,t){const i={mask:c.ContainerVisibility,containerIsVisible:t,container:m.StaticSections};return this._doMaskedUIUpdate(e,i,!0)}setAnalysisSlice(e,t,i,s){const r={mask:c.AnalysisSlice,analysisSlice:{point:i,normal:s,enabled:t}};return this._doMaskedUIUpdate(e,r,!0)}_doMaskedUIUpdate(e,t,i){if(!this._vxl)return!1;let s=!1;return this._layers.forEach(((i,r)=>{if(i.layerView.wasmLayerId===e.wasmLayerId){const e={str:JSON.stringify(t),byteCount:0,ptr:0,isReusable:!1};this._allocateBlock(e)&&(s=1===this._vxl.handle_masked_ui_update(r,e.ptr,e.byteCount),e.isReusable||this._vxl._free(e.ptr))}})),s&&i&&this._renderPluginContext.requestRender(),s}_addTriangleToWasmBuffer(e,t,i,s,r){return e[3*t]=i[0],e[3*t+1]=i[1],e[3*t+2]=i[2],e[3*(t+=1)]=s[0],e[3*t+1]=s[1],e[3*t+2]=s[2],e[3*(t+=1)]=r[0],e[3*t+1]=r[1],e[3*t+2]=r[2],t+=1}_addNormalToWasmBuffer(e,t,i){return e[3*t]=i[0],e[3*t+1]=i[1],e[3*t+2]=i[2],t+=1}_doCaptureFrustum(){if(!this._vxl)return;const e=36,t=e/3,i=this._vxl._malloc(3*e*Float32Array.BYTES_PER_ELEMENT),s=new Float32Array(this._vxl.HEAPF32.buffer,i,3*e),r=this._vxl._malloc(3*t*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(this._vxl.HEAPF32.buffer,r,e),n=this._frustum.points[h.NEAR_BOTTOM_LEFT],o=this._frustum.points[h.NEAR_BOTTOM_RIGHT],l=this._frustum.points[h.NEAR_TOP_RIGHT],_=this._frustum.points[h.NEAR_TOP_LEFT],u=this._frustum.points[h.FAR_BOTTOM_LEFT],c=this._frustum.points[h.FAR_BOTTOM_RIGHT],m=this._frustum.points[h.FAR_TOP_RIGHT],g=this._frustum.points[h.FAR_TOP_LEFT];let f=0,p=0;const x=this._frustum.planes[d.NEAR];f=this._addTriangleToWasmBuffer(s,f,l,o,n),p=this._addNormalToWasmBuffer(a,p,x),f=this._addTriangleToWasmBuffer(s,f,n,_,l),p=this._addNormalToWasmBuffer(a,p,x);const y=this._frustum.planes[d.FAR];f=this._addTriangleToWasmBuffer(s,f,u,c,m),p=this._addNormalToWasmBuffer(a,p,y),f=this._addTriangleToWasmBuffer(s,f,m,g,u),p=this._addNormalToWasmBuffer(a,p,y);const v=this._frustum.planes[d.TOP];f=this._addTriangleToWasmBuffer(s,f,m,l,_),p=this._addNormalToWasmBuffer(a,p,v),f=this._addTriangleToWasmBuffer(s,f,_,g,m),p=this._addNormalToWasmBuffer(a,p,v);const b=this._frustum.planes[d.BOTTOM];f=this._addTriangleToWasmBuffer(s,f,n,o,c),p=this._addNormalToWasmBuffer(a,p,b),f=this._addTriangleToWasmBuffer(s,f,c,u,n),p=this._addNormalToWasmBuffer(a,p,b);const w=this._frustum.planes[d.LEFT];f=this._addTriangleToWasmBuffer(s,f,_,n,u),p=this._addNormalToWasmBuffer(a,p,w),f=this._addTriangleToWasmBuffer(s,f,u,g,_),p=this._addNormalToWasmBuffer(a,p,w);const T=this._frustum.planes[d.RIGHT];f=this._addTriangleToWasmBuffer(s,f,l,m,c),p=this._addNormalToWasmBuffer(a,p,T),f=this._addTriangleToWasmBuffer(s,f,c,o,l),p=this._addNormalToWasmBuffer(a,p,T),-1!==this._frustumRenderableId&&this._vxl.remove_generic_mesh(this._frustumRenderableId),this._frustumRenderableId=this._vxl.add_generic_mesh(i,3*e,r,e,255,0,0,64),this._vxl._free(i),this._vxl._free(r),this._captureFrustum=!1,this._renderPluginContext.requestRender()}captureFrustum(){null===this._renderCoordsHelper&&(this._renderCoordsHelper=y.create(f.Local,l(!1,this._view.spatialReference))),null===this._frustum&&(this._frustum=new x(this._renderCoordsHelper)),this._captureFrustum=!0,null!==this._renderPluginContext&&this._renderPluginContext.requestRender()}toggleFullVolumeExtentDraw(e){this._vxl&&this._layers.forEach(((t,i)=>{t.layerView.wasmLayerId===e.wasmLayerId&&(this._vxl.toggle_full_volume_extent_draw(i),this._renderPluginContext.requestRender())}))}addVoxelLayer(e){if(!this._vxl){const t={layerView:e,resolveCallback:null,rejectCallback:null},i=new Promise(((e,i)=>{t.resolveCallback=e,t.rejectCallback=i}));return this._newLayers.push(t),i}const t=this._addVoxelLayer(e);return t<0?Promise.reject(-1):Promise.resolve(t)}removeVoxelLayer(e){if(!this._vxl){const t=this._newLayers.findIndex((t=>e.uid===t.layerView.uid));t>=0&&(this._newLayers[t].resolveCallback(-1),this._newLayers.splice(t,1));const i=this._newLayers.length;return 0===i&&(this._dbg(P.Lifetime," no voxel layers left after removing a layer, removing RenderPlugin and destroying"),this.destroy()),i}let t=-1;this._layers.forEach(((i,s)=>{if(i.layerView.wasmLayerId===e.wasmLayerId){t=s,i.abortController.abort(),this._vxl.remove_layer(t);const r=this.layerUid.indexOf(e.layer.uid);-1!==r&&this.layerUid.splice(r,1)}})),t>=0&&this._layers.delete(t);const i=this._layers.size;return 0===i&&(this._dbg(P.Lifetime," no voxel layers left after removing a layer, removing RenderPlugin and destroying"),this.destroy()),i}_getBlockSize(e){for(const t of this._wasmMemBlockSizes)if(e<t)return t;return-1}_allocateBlock(e){e.byteCount=this._vxl.lengthBytesUTF8(e.str)+1;const t=this._getBlockSize(e.byteCount);return t<0?(e.isReusable=!1,e.ptr=this._vxl._malloc(e.byteCount)):(e.isReusable=!0,e.ptr=this._wasmMemBlocks.get(t),0===e.ptr&&(e.ptr=this._vxl._malloc(t),this._wasmMemBlocks.set(t,e.ptr))),0!==e.ptr&&(this._vxl.stringToUTF8(e.str,e.ptr,e.byteCount),!0)}_getTimeArgs(e){let t=-Number.MAX_VALUE,i=Number.MAX_VALUE,s=!1;return null!=e&&(e.isAllTime?s=!0:(null!=e.start&&(s=!0,t=e.start.getTime()/1e3),null!=e.end&&(s=!0,i=e.end.getTime()/1e3))),{startTime:t,endTime:i,useTime:s}}_addVoxelLayer(e){const t=e.layer;let i=-1;const s=t.getConfiguration();if(s.length<1)return-1;const r={str:s,byteCount:0,ptr:0,isReusable:!1};if(!this._allocateBlock(r))return-1;const a=this._getTimeArgs(this._view?.timeExtent),n=this._view.spatialReference.isWGS84&&t.spatialReference.isWGS84?111319.49079327357:1;if(i=this._vxl.add_layer(t.serviceRoot,r.ptr,r.byteCount,n,n,a.startTime,a.endTime,a.useTime,this._toWasmQuality(this._view.qualityProfile)),r.isReusable||this._vxl._free(r.ptr),i>=0){t.test?.constantUpscaling&&(this._setUpscalingLimits(0,.25,.25),this._setUpscalingLimits(1,.5,.5),this._setUpscalingLimits(2,.75,.75));const s=new AbortController;if(this._layers.set(i,{layerView:e,responses:new Map,outstandingRequestCount:0,abortController:s,needMemoryUsageUpdate:!1}),this.layerUid.push(e.layer.uid),!this._halfIntTexturesAvailable||has("mac")){const t=[];let i="";for(const s of e.layer.variables)"Int16"!==s.renderingFormat.type&&"UInt16"!==s.renderingFormat.type||(t.push(s.name),s.id===e.layer.currentVariableId&&(i=s.name));""!==i&&S.error("#addVoxelLayer_error()",e.layer,`The voxel layer '${e.layer.title}' cannot render the current variable '${i}' in this browser`),t.length>0&&S.warn("#addVoxelLayer_warning()",e.layer,`The voxel layer '${e.layer.title}' cannot render the variables '${t.toString()}' in this browser`)}if(!this._textureFloatLinearAvailable){const t=[];let i="";for(const s of e.layer.variables)"Float32"===s.renderingFormat.type&&(t.push(s.name),s.id===e.layer.currentVariableId&&(i=s.name));""!==i&&S.error("#addVoxelLayer_error()",e.layer,`The voxel layer '${e.layer.title}' cannot render the current variable '${i}' in this browser`),t.length>0&&S.warn("#addVoxelLayer_warning()",e.layer,`The voxel layer '${e.layer.title}' cannot render the variables '${t.toString()}' in this browser`)}return has("esri-mobile")&&S.warnOnce("Mobile support differs across devices. Voxel layer might not display as expected."),i}return-1}prepareRender(e){if(!this._vxl)return;const t=e.bindParameters.camera.viewForward,i=e.bindParameters.camera.eye;this._vxl.update_camera_pos_and_direction(i[0],i[1],i[2],t[0],t[1],t[2]);const s=this._vxl.cull();this._dbg(P.RequestResponse,"missingResourceCount="+s),this._moreToLoad=s>0,this._havePreparedWithAllLayers=0===this._newLayers.length,this._updateMemoryUsage()}render(e){if(!this._vxl||e.output!==this._shaderOutput||e.bindParameters.slot!==this._renderSlot)return;for(const i of this._newLayers){const e=this._addVoxelLayer(i.layerView);-1===e?i.rejectCallback(-1):i.resolveCallback(e)}if(this._newLayers=[],0===this._layers.size)return void this._dbg(P.Error,"No voxel layers but RenderPlugin instance is being asked to render!");this._lastFrameWasStationary=this._view.stationary,this._syncRequestsResponses(),this._beforeDraw(),this._vxl.begin_color_frame(!this._view._stage.renderer.isFeatureEnabled(R.HighQualityVoxel),e.bindParameters.lighting.mainLight.direction[0],e.bindParameters.lighting.mainLight.direction[1],e.bindParameters.lighting.mainLight.direction[2]);const t=this._renderTargetToRestore.viewport;t.width===this._viewportWidth&&t.height===this._viewportHeight||(this._viewportWidth=t.width,this._viewportHeight=t.height,this._vxl.set_viewport(t.width,t.height),this._layers.forEach((e=>{e.needMemoryUsageUpdate=!0}))),0===t.x&&0===t.y||this._dbg(P.Error,"Unsupported viewport parameters detected!"),this.updateWasmCamera(e.bindParameters.camera),this._captureFrustum&&(this._frustum.update(e.bindParameters.camera),this._doCaptureFrustum()),this._vxl.draw(),this._afterDraw(),(this._moreToLoad||!this._havePreparedWithAllLayers&&this._layers.size>0)&&this._renderPluginContext.requestRender()}destroy(){this._dbg(P.Lifetime,"--destroy--"),this._removeRenderPlugin(),this._readyWatchHandle=s(this._readyWatchHandle),this._qualityWatchHandle=s(this._qualityWatchHandle),this._timeExtentWatchHandle=s(this._timeExtentWatchHandle),this._stationaryWatchHandle=s(this._stationaryWatchHandle),this._vxl&&(this._layers.forEach((e=>{e.abortController.abort()})),this._wasmMemBlocks.forEach((e=>{0!==e&&this._vxl._free(e)})),this._vxl.uninitialize_voxel_wasm(),this._vxl=null)}_initializeWasm(e){return this._vxl?Promise.resolve():(this._vxlPromise||(this._vxlPromise=g(e).then((e=>{if(this._vxl=e,this._vxlPromise=null,this._newLayers.length<=0)return this._dbg(P.Lifetime," no voxel layers left after WASM downloaded, removing RenderPlugin and destroying"),void this.destroy();const t=this._getTimeArgs(this._view?.timeExtent),i=this._vxl.addFunction(this._restoreFramebuffer.bind(this),"v"),s=this._vxl.addFunction(this._setBlendState.bind(this),"viiii"),r=this._vxl.addFunction(this._setFrontFace.bind(this),"vi"),a=this._vxl.addFunction(this._setRasterizerState.bind(this),"vi"),n=this._vxl.addFunction(this._setDepthStencilStateFunction.bind(this),"viii"),o=this._vxl.addFunction(this._setViewport.bind(this),"viiii"),l=this._vxl.addFunction(this._bindPreviousDepthToSlot.bind(this),"iii"),h=this._vxl.addFunction(this._modifyResourceCount.bind(this),"viii"),d=this._halfIntTexturesAvailable&&!has("mac"),_=this._textureFloatLinearAvailable;this._vxl.initialize_voxel_wasm(i,s,r,a,n,o,l,h,t.startTime,t.endTime,t.useTime,d,_),this._renderPluginContext&&this._renderPluginContext.requestRender()})).catch((()=>{for(const e of this._newLayers)e.rejectCallback(-2);this._dbg(P.Error," WASM failed to download, removing RenderPlugin and destroying"),this.destroy()}))),this._vxlPromise)}pickDepth(e,t,i){if(!this._vxl||!this._rctx||0===this._layers.size)return null;const s=i.viewport[3]-t;if(e<0||e>i.viewport[2]||t<0||t>i.viewport[3])return this._dbg(P.Error,`[js] pickDepth: outOfRange, screenXY=[${e.toFixed(0)}, ${s.toFixed(0)}]]`),null;this._beforeDraw();const r=i.viewForward,a=i.eye;this._vxl.update_camera_pos_and_direction(a[0],a[1],a[2],r[0],r[1],r[2]),this.updateWasmCamera(i),this._vxl.begin_frame();const n=this._vxl.pick_depth(e,s);if(this._afterDraw(),n.success){return n.distanceToCamera}return null}pickObject(e,t,i,s){if(!this._vxl||!this._rctx||0===this._layers.size)return null;const r=Math.round(e),a=Math.round(t);if(r<0||r>i.viewport[2]||a<0||a>i.viewport[3])return this._dbg(P.Error,`[js] pickObject: outOfRange, screenXY=[${r}, ${a}], vp=[${i.viewport.toString()}]`),null;this._beforeDraw();const n=i.viewForward,o=i.eye;this._vxl.update_camera_pos_and_direction(o[0],o[1],o[2],n[0],n[1],n[2]),this.updateWasmCamera(i),this._vxl.begin_frame();let l=null;if(0===s.length)l=this._vxl.pick_object(r,a,0,0);else{const e={str:JSON.stringify({layerIds:s}),byteCount:0,ptr:0,isReusable:!1};this._allocateBlock(e)&&(l=this._vxl.pick_object(r,a,e.ptr,e.byteCount),e.isReusable||this._vxl._free(e.ptr))}return this._afterDraw(),l}_beforeDraw(){this._renderTargetToRestore={fbo:this._rctx.getBoundFramebufferObject(),viewport:this._rctx.getViewport()},this._rctx.setPolygonOffsetFillEnabled(!1),this._rctx.setScissorTestEnabled(!1),this._rctx.setColorMask(!0,!0,!0,!0)}_afterDraw(){this._renderTargetToRestore.fbo=null,this._rctx.externalTextureUnitUpdate(this._vxl.get_texture_units_bound_in_frame(),this._vxl.get_active_texture_unit()),this._rctx.externalVertexArrayObjectUpdate(),this._rctx.externalVertexBufferUpdate(),this._rctx.externalProgramUpdate()}intersect(e,t,i,s,r){if(!this._vxl||!this._rctx||0===this._layers.size||!e.options.selectionMode||e.options.isFiltered)return;if(r[0]<0||r[0]>e.camera.viewport[2]||r[1]<0||r[1]>e.camera.viewport[3])return this._dbg(P.Error,`[js] VoxelWasmPerScene.intersect: outOfRange, screenXY=[${r[0].toFixed(0)}, ${r[1].toFixed(0)}]`),null;const a=[];this._layers.forEach((t=>{e.options.filteredLayerUids.includes(t.layerView.layer.uid)&&a.push(t.layerView.wasmLayerId)}));const l=this.pickObject(r[0],r[1],e.camera,a);if(null==l||-1===l.layerId)return;const h=this._layers.get(l.layerId);if(h){const t=h.layerView.layer.uid,r=l.distanceToCamera/n(i,s),a=o();a[0]=l.worldX,a[1]=l.worldY,a[2]=l.worldZ;const d={};if(null!=l.continuousValue&&null!=l.continuousValueUnits?d["Voxel.ServiceValue"]=`${l.continuousValue.toLocaleString()} ${l.continuousValueUnits}`:null!=l.uniqueValueLabel&&null!=l.uniqueValue?d["Voxel.ServiceValue"]=`${l.uniqueValueLabel} (${l.uniqueValue})`:null!=l.uniqueValue&&(d["Voxel.ServiceValue"]=`${l.uniqueValue}`),d["Voxel.ServiceVariableLabel"]=l.variableLabel,d["Voxel.Position"]=l.voxelSpacePosition,null!=l.epochTime&&null!=l.nativeTime&&null!=l.nativeTimeUnits){const e=new Date(l.epochTime);d["Voxel.ServiceLocalTime"]=e.toString(),d["Voxel.ServiceNativeTime"]=`${l.nativeTime.toLocaleString()} ${l.nativeTimeUnits}`}null!=l.depth&&null!=l.depthUnits&&(d["Voxel.ServiceDepth"]=`${l.depth.toLocaleString()} ${l.depthUnits}`);const _=l.faceNormal;d["Voxel.WorldPosition"]=`[${a[0]}, ${a[1]}, ${a[2]}]`;const u=e=>{const i=new p(a,t,(()=>this._createVoxelGraphic(h.layerView.layer,d)));e.set(this.type,i,r,_)},c=e.results,m=e.options.store===T.ALL;if((null==c.min.dist||r<c.min.dist)&&u(c.min),(null==c.max.dist||r>c.max.dist)&&u(c.max),m){const t=b(e.ray);u(t),e.results.all.push(t)}}}_createVoxelGraphic(t,i){return new e({layer:t,sourceLayer:t,attributes:i})}_toWasmQuality(e){switch(e){case"low":return 0;case"medium":return 1;case"high":return 2}}_setUpscalingLimits(e,t,i){this._vxl&&this._vxl.set_upscaling_limits(e,t,i)}}export{U as default};
5
+ import e from"../Graphic.js";import t from"../request.js";import has from"../core/has.js";import i from"../core/Logger.js";import{removeMaybe as s}from"../core/maybe.js";import{isAbortError as r}from"../core/promiseUtils.js";import{watch as a}from"../core/reactiveUtils.js";import{i as n}from"../chunks/vec3.js";import{c as o}from"../chunks/vec3f64.js";import{renderSRFromViewSR as l}from"../geometry/support/coordinateSystem.js";import{PointIndex as h,PlaneIndex as d}from"../geometry/support/frustum.js";import{WasmCullMode as _,VoxelRequestType as u,UpdateFlags as c,ContainerType as m}from"../libs/vxl/enums.js";import{loadVoxelWASM as g}from"../libs/vxl/VxlModule.js";import{ViewingMode as f}from"../views/ViewingMode.js";import{VoxelTarget as p}from"../views/3d/layers/i3s/Intersector.js";import{Frustum as x}from"../views/3d/state/Frustum.js";import{RenderCoordsHelper as y}from"../views/3d/support/RenderCoordsHelper.js";import{ShaderOutput as v}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{newIntersectorResult as b}from"../views/3d/webgl-engine/lib/Intersector.js";import{IntersectorType as w,StoreResults as T}from"../views/3d/webgl-engine/lib/IntersectorInterfaces.js";import{RenderFeature as R}from"../views/3d/webgl-engine/lib/RenderFeature.js";import{RenderSlot as L}from"../views/3d/webgl-engine/lib/RenderSlot.js";import{ContextType as E}from"../views/webgl/contextUtils.js";import{CompareFunction as C,Face as F,StencilOperation as V}from"../views/webgl/enums.js";const S=i.getLogger("esri.layers.VoxelWasmPerSceneView");var P;!function(e){e[e.Lifetime=1]="Lifetime",e[e.RequestResponse=2]="RequestResponse",e[e.Rendering=3]="Rendering",e[e.Error=4]="Error"}(P||(P={}));class U{constructor(e){this._halfIntTexturesAvailable=!1,this._textureFloatLinearAvailable=!1,this._havePreparedWithAllLayers=!1,this._readyWatchHandle=null,this._qualityWatchHandle=null,this._stationaryWatchHandle=null,this._timeExtentWatchHandle=null,this._renderPluginContext=null,this._vxlPromise=null,this._vxl=null,this._pluginIsActive=!1,this._moreToLoad=!1,this._viewportWidth=-1,this._viewportHeight=-1,this._newLayers=[],this._layers=new Map,this._shaderOutput=v.Color,this._renderSlot=L.VOXEL,this._rctx=null,this._renderTargetToRestore=null,this._lastFrameWasStationary=!1,this._wasmMemBlockSizes=[512,1024,2048,4096,8192,16384,32768,65536],this._wasmMemBlocks=new Map,this._dbgFlags=new Set,this._captureFrustum=!1,this._frustum=null,this._frustumRenderableId=-1,this._renderCoordsHelper=null,this.type=w.VOXEL,this.slicePlaneEnabled=!0,this.isGround=!1,this.layerUid=[],this._view=e,this._initialize()}get canRender(){return!!this._vxl&&"local"===this._view.viewingMode}_dbg(e,t){this._dbgFlags.has(e)&&(e===P.Error?S.error(t):S.warn(t))}_removeRenderPlugin(){this._pluginIsActive&&this._view._stage&&(this._dbg(P.Lifetime,"--removeRenderPlugin--"),this._view._stage.removeRenderPlugin(this)),this._pluginIsActive=!1}_initialize(){this._dbg(P.Lifetime,"--initialize--");for(const e of this._wasmMemBlockSizes)this._wasmMemBlocks.set(e,0);this._readyWatchHandle=a((()=>this._view.ready),(e=>{e&&"local"===this._view.viewingMode?(this._dbg(P.Lifetime,"view ready status changed to ready on a local view, calling addRenderPlugin"),this._view._stage.addRenderPlugin([this._renderSlot],this),this._pluginIsActive=!0):(this._dbg(P.Lifetime,"view ready status changed, not ready or not a local view!"),this._removeRenderPlugin())}),{initial:!0}),this._qualityWatchHandle=a((()=>this._view?.qualityProfile),(e=>{this._dbg(P.Rendering,"qualityProfile changed to "+e),this._vxl&&this._vxl.set_quality(this._toWasmQuality(e))}),{initial:!0}),this._timeExtentWatchHandle=a((()=>this._view?.timeExtent),(()=>{if(this._vxl){const e=this._getTimeArgs(this._view?.timeExtent);this._dbg(P.Rendering,"sceneView timeExtent changed to useTime="+e.useTime+" st="+e.startTime+" et="+e.endTime),this._vxl.set_scene_time_extent(e.startTime,e.endTime,e.useTime),this._renderPluginContext.requestRender()}}),{initial:!0}),this._stationaryWatchHandle=a((()=>this._view?.stationary),(e=>{this._vxl&&e&&!this._lastFrameWasStationary&&this._renderPluginContext.requestRender()}))}initializeRenderContext(e){this._dbg(P.Lifetime,"--initializeRenderContext--");const t=e.renderContext.rctx;t.type===E.WEBGL2?(this._renderPluginContext=e,this._rctx=e.renderContext.rctx,this._halfIntTexturesAvailable=!!this._rctx.capabilities.textureNorm16,this._textureFloatLinearAvailable=this._rctx.capabilities.textureFloatLinear,this._initializeWasm(t.gl)):this._dbg(P.Error,"WebGL 1 context only!")}uninitializeRenderContext(){this._renderPluginContext=null,this._rctx=null,this._dbg(P.Lifetime,"--uninitializeRenderContext--")}_restoreFramebuffer(){if(!this._renderTargetToRestore)return;const e=this._renderTargetToRestore.fbo;if(!!!this._rctx)return void this._dbg(P.Error,"no context in restoreFramebuffer!");this._rctx.bindFramebuffer(e,!0);const t=this._renderTargetToRestore.viewport;this._rctx.setViewport(t.x,t.y,t.width,t.height)}_bindPreviousDepthToSlot(e,t){const i=!!this._rctx,s=!!this._renderTargetToRestore;if(!i||!s)return 0;const r=this._renderTargetToRestore.fbo.depthStencilTexture;return r?(0===t?this._rctx.bindTexture(null,e,!0):this._rctx.bindTexture(r,e,!0),1):(this._dbg(P.Error,"no depth/stencil texture exists!"),0)}_modifyResourceCount(e,t,i){if(!this._rctx)return void this._dbg(P.Error,"modifyAllocation callback has no rendering context!");const s=e;1===i?this._rctx.instanceCounter.increment(s,t):this._rctx.instanceCounter.decrement(s,t)}_setBlendState(e,t,i,s){this._rctx?(this._rctx.setBlendingEnabled(1===e),this._rctx.setBlendFunction(t,i),this._rctx.setBlendEquation(s)):this._dbg(P.Error,"setBlendState callback has no rendering context!")}_setFrontFace(e){this._rctx?this._rctx.setFrontFace(e):this._dbg(P.Error,"setFrontFace callback has no rendering context!")}_setDepthStencilStateFunction(e,t,i){this._rctx?(this._rctx.setDepthFunction(i),this._rctx.setDepthTestEnabled(1===e),this._rctx.setDepthWriteEnabled(1===t),this._rctx.setStencilTestEnabled(!1),this._rctx.setStencilFunction(C.ALWAYS,0,255),this._rctx.setStencilOpSeparate(F.FRONT,V.KEEP,V.INCR,V.KEEP),this._rctx.setStencilOpSeparate(F.BACK,V.KEEP,V.DECR,V.KEEP)):this._dbg(P.Error,"setDepthStencilStateFunction callback has no rendering context!")}_setRasterizerState(e){if(this._rctx)switch(e){case _.None:this._rctx.setFaceCullingEnabled(!1);break;case _.Back:this._rctx.setCullFace(F.BACK),this._rctx.setFaceCullingEnabled(!0);break;case _.Front:this._rctx.setCullFace(F.FRONT),this._rctx.setFaceCullingEnabled(!0)}else this._dbg(P.Error,"setRasterizerState callback has no rendering context!")}_setViewport(e,t,i,s){this._rctx?this._rctx.setViewport(e,t,i,s):this._dbg(P.Error,"setViewport callback has no rendering context!")}_updateMemoryUsage(){this._layers.forEach(((e,t)=>{if(e.needMemoryUsageUpdate){const i=this._vxl.estimate_memory_usage(t);i>=0&&(e.needMemoryUsageUpdate=!1,e.layerView.setUsedMemory(i))}}))}_syncRequestsResponses(){this._layers.forEach(((e,i)=>{const s=[];e.responses.forEach(((t,r)=>{s.push(r),this._dbg(P.RequestResponse,"responding for requestID:"+r+" size:"+t.size),this._vxl.respond(i,r,t),t.requestType!==u.TreeIndex&&t.requestType!==u.Section||(e.needMemoryUsageUpdate=!0)}));const a=e.responses;for(const t of s)a.delete(t);const n=this._vxl.get_new_requests(i),o=e.abortController.signal;for(const l in n){e.outstandingRequestCount+=1,1===e.outstandingRequestCount&&e.layerView.updatingFlagChanged();const i=n[l],s={responseType:"array-buffer",signal:o};this._dbg(P.RequestResponse,"making requestID:"+l+" url:"+i.url),t(i.url,s).then((t=>{e.outstandingRequestCount-=1,0===e.outstandingRequestCount&&e.layerView.updatingFlagChanged(),this._dbg(P.RequestResponse,"have response for requestID:"+l);let s=0;if(t.data.byteLength>0){s=this._vxl._malloc(t.data.byteLength);const e=new Uint8Array(this._vxl.HEAPU8.buffer,s,t.data.byteLength),i=new Uint8Array(t.data);for(let s=0;s<t.data.byteLength;++s)e[s]=i[s]}a.set(+l,{responseType:i.responseType,ptr:s,size:t.data.byteLength,success:!0,requestType:i.requestType})})).catch((t=>{e.outstandingRequestCount-=1,0===e.outstandingRequestCount&&e.layerView.updatingFlagChanged(),r(t)||(this._dbg(P.Error,`requestID:${l} failed, error=${t.toString()}`),a.set(+l,{responseType:i.responseType,ptr:0,size:0,success:!1,requestType:i.requestType}))}))}}))}updateWasmCamera(e){this._vxl.set_projection_matrix.apply(this._vxl,e.projectionMatrix),this._vxl.set_view_matrix.apply(this._vxl,e.viewMatrix),this._vxl.set_near_far(e.near,e.far)}isUpdating(e){if(!this._vxl&&this._vxlPromise)return!0;const t=this._layers.get(e);return!!t&&t.outstandingRequestCount>0}getLayerTimes(e){const t=[];return this._layers.forEach(((i,s)=>{if(i.layerView.wasmLayerId===e.wasmLayerId){const i=this._vxl.get_layer_epoch_times(s,e.layer.currentVariableId);for(let e=0;e<i.length;++e)t.push(i[e])}})),t}getCurrentLayerTimeIndex(e){let t=0;return this._layers.forEach(((i,s)=>{i.layerView.wasmLayerId===e.wasmLayerId&&(t=this._vxl.get_layer_current_time_id(s))})),t}setEnabled(e,t){this._layers.forEach(((i,s)=>{i.layerView.wasmLayerId===e.wasmLayerId&&(this._vxl.set_enabled(s,t),i.needMemoryUsageUpdate=!0,this._renderPluginContext.requestRender())}))}setStaticSections(e,t){const i={mask:c.StaticSections,staticSections:t};return this._doMaskedUIUpdate(e,i,!0)}setCurrentVariable(e,t){const i={mask:c.CurrentVariable,currentVariable:t};return this._doMaskedUIUpdate(e,i,!0)}setRenderMode(e,t){const i={mask:c.RenderMode,renderMode:t};return this._doMaskedUIUpdate(e,i,!0)}setVerticalExaggerationAndOffset(e,t,i,s){const r={mask:c.ExaggerationAndOffset,volStyleDesc:{volumeId:t,verticalExaggeration:i,verticalOffset:s}};return this._doMaskedUIUpdate(e,r,!0)}setVariableStyles(e,t){const i={mask:c.VariableStyles,variableStyles:t};return this._doMaskedUIUpdate(e,i,!0)}setVolumeStyles(e,t){const i={mask:c.VolumeStyles,volumeStyles:t};return this._doMaskedUIUpdate(e,i,!0)}setEnableDynamicSections(e,t){const i={mask:c.ContainerVisibility,containerIsVisible:t,container:m.DynamicSections};return this._doMaskedUIUpdate(e,i,!0)}setEnableIsosurfaces(e,t){const i={mask:c.ContainerVisibility,containerIsVisible:t,container:m.Isosurfaces};return this._doMaskedUIUpdate(e,i,!0)}setEnableSections(e,t){const i={mask:c.ContainerVisibility,containerIsVisible:t,container:m.StaticSections};return this._doMaskedUIUpdate(e,i,!0)}setAnalysisSlice(e,t,i,s){const r={mask:c.AnalysisSlice,analysisSlice:{point:i,normal:s,enabled:t}};return this._doMaskedUIUpdate(e,r,!0)}_doMaskedUIUpdate(e,t,i){if(!this._vxl)return!1;let s=!1;return this._layers.forEach(((i,r)=>{if(i.layerView.wasmLayerId===e.wasmLayerId){const e={str:JSON.stringify(t),byteCount:0,ptr:0,isReusable:!1};this._allocateBlock(e)&&(s=1===this._vxl.handle_masked_ui_update(r,e.ptr,e.byteCount),e.isReusable||this._vxl._free(e.ptr))}})),s&&i&&this._renderPluginContext.requestRender(),s}_addTriangleToWasmBuffer(e,t,i,s,r){return e[3*t]=i[0],e[3*t+1]=i[1],e[3*t+2]=i[2],e[3*(t+=1)]=s[0],e[3*t+1]=s[1],e[3*t+2]=s[2],e[3*(t+=1)]=r[0],e[3*t+1]=r[1],e[3*t+2]=r[2],t+=1}_addNormalToWasmBuffer(e,t,i){return e[3*t]=i[0],e[3*t+1]=i[1],e[3*t+2]=i[2],t+=1}_doCaptureFrustum(){if(!this._vxl)return;const e=36,t=e/3,i=this._vxl._malloc(3*e*Float32Array.BYTES_PER_ELEMENT),s=new Float32Array(this._vxl.HEAPF32.buffer,i,3*e),r=this._vxl._malloc(3*t*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(this._vxl.HEAPF32.buffer,r,e),n=this._frustum.points[h.NEAR_BOTTOM_LEFT],o=this._frustum.points[h.NEAR_BOTTOM_RIGHT],l=this._frustum.points[h.NEAR_TOP_RIGHT],_=this._frustum.points[h.NEAR_TOP_LEFT],u=this._frustum.points[h.FAR_BOTTOM_LEFT],c=this._frustum.points[h.FAR_BOTTOM_RIGHT],m=this._frustum.points[h.FAR_TOP_RIGHT],g=this._frustum.points[h.FAR_TOP_LEFT];let f=0,p=0;const x=this._frustum.planes[d.NEAR];f=this._addTriangleToWasmBuffer(s,f,l,o,n),p=this._addNormalToWasmBuffer(a,p,x),f=this._addTriangleToWasmBuffer(s,f,n,_,l),p=this._addNormalToWasmBuffer(a,p,x);const y=this._frustum.planes[d.FAR];f=this._addTriangleToWasmBuffer(s,f,u,c,m),p=this._addNormalToWasmBuffer(a,p,y),f=this._addTriangleToWasmBuffer(s,f,m,g,u),p=this._addNormalToWasmBuffer(a,p,y);const v=this._frustum.planes[d.TOP];f=this._addTriangleToWasmBuffer(s,f,m,l,_),p=this._addNormalToWasmBuffer(a,p,v),f=this._addTriangleToWasmBuffer(s,f,_,g,m),p=this._addNormalToWasmBuffer(a,p,v);const b=this._frustum.planes[d.BOTTOM];f=this._addTriangleToWasmBuffer(s,f,n,o,c),p=this._addNormalToWasmBuffer(a,p,b),f=this._addTriangleToWasmBuffer(s,f,c,u,n),p=this._addNormalToWasmBuffer(a,p,b);const w=this._frustum.planes[d.LEFT];f=this._addTriangleToWasmBuffer(s,f,_,n,u),p=this._addNormalToWasmBuffer(a,p,w),f=this._addTriangleToWasmBuffer(s,f,u,g,_),p=this._addNormalToWasmBuffer(a,p,w);const T=this._frustum.planes[d.RIGHT];f=this._addTriangleToWasmBuffer(s,f,l,m,c),p=this._addNormalToWasmBuffer(a,p,T),f=this._addTriangleToWasmBuffer(s,f,c,o,l),p=this._addNormalToWasmBuffer(a,p,T),-1!==this._frustumRenderableId&&this._vxl.remove_generic_mesh(this._frustumRenderableId),this._frustumRenderableId=this._vxl.add_generic_mesh(i,3*e,r,e,255,0,0,64),this._vxl._free(i),this._vxl._free(r),this._captureFrustum=!1,this._renderPluginContext.requestRender()}captureFrustum(){null===this._renderCoordsHelper&&(this._renderCoordsHelper=y.create(f.Local,l(!1,this._view.spatialReference))),null===this._frustum&&(this._frustum=new x(this._renderCoordsHelper)),this._captureFrustum=!0,null!==this._renderPluginContext&&this._renderPluginContext.requestRender()}toggleFullVolumeExtentDraw(e){this._vxl&&this._layers.forEach(((t,i)=>{t.layerView.wasmLayerId===e.wasmLayerId&&(this._vxl.toggle_full_volume_extent_draw(i),this._renderPluginContext.requestRender())}))}addVoxelLayer(e){if(!this._vxl){const t={layerView:e,resolveCallback:null,rejectCallback:null},i=new Promise(((e,i)=>{t.resolveCallback=e,t.rejectCallback=i}));return this._newLayers.push(t),i}const t=this._addVoxelLayer(e);return t<0?Promise.reject(-1):Promise.resolve(t)}removeVoxelLayer(e){if(!this._vxl){const t=this._newLayers.findIndex((t=>e.uid===t.layerView.uid));t>=0&&(this._newLayers[t].resolveCallback(-1),this._newLayers.splice(t,1));const i=this._newLayers.length;return 0===i&&(this._dbg(P.Lifetime," no voxel layers left after removing a layer, removing RenderPlugin and destroying"),this.destroy()),i}let t=-1;this._layers.forEach(((i,s)=>{if(i.layerView.wasmLayerId===e.wasmLayerId){t=s,i.abortController.abort(),this._vxl.remove_layer(t);const r=this.layerUid.indexOf(e.layer.uid);-1!==r&&this.layerUid.splice(r,1)}})),t>=0&&this._layers.delete(t);const i=this._layers.size;return 0===i&&(this._dbg(P.Lifetime," no voxel layers left after removing a layer, removing RenderPlugin and destroying"),this.destroy()),i}_getBlockSize(e){for(const t of this._wasmMemBlockSizes)if(e<t)return t;return-1}_allocateBlock(e){e.byteCount=this._vxl.lengthBytesUTF8(e.str)+1;const t=this._getBlockSize(e.byteCount);return t<0?(e.isReusable=!1,e.ptr=this._vxl._malloc(e.byteCount)):(e.isReusable=!0,e.ptr=this._wasmMemBlocks.get(t),0===e.ptr&&(e.ptr=this._vxl._malloc(t),this._wasmMemBlocks.set(t,e.ptr))),0!==e.ptr&&(this._vxl.stringToUTF8(e.str,e.ptr,e.byteCount),!0)}_getTimeArgs(e){let t=-Number.MAX_VALUE,i=Number.MAX_VALUE,s=!1;return null!=e&&(e.isAllTime?s=!0:(null!=e.start&&(s=!0,t=e.start.getTime()/1e3),null!=e.end&&(s=!0,i=e.end.getTime()/1e3))),{startTime:t,endTime:i,useTime:s}}_addVoxelLayer(e){const t=e.layer;let i=-1;const s=t.getConfiguration();if(s.length<1)return-1;const r={str:s,byteCount:0,ptr:0,isReusable:!1};if(!this._allocateBlock(r))return-1;const a=this._getTimeArgs(this._view?.timeExtent),n=this._view.spatialReference.isWGS84&&t.spatialReference.isWGS84?111319.49079327357:1;if(i=this._vxl.add_layer(t.serviceRoot,r.ptr,r.byteCount,n,n,a.startTime,a.endTime,a.useTime,this._toWasmQuality(this._view.qualityProfile)),r.isReusable||this._vxl._free(r.ptr),i>=0){t.test?.constantUpscaling&&(this._setUpscalingLimits(0,.25,.25),this._setUpscalingLimits(1,.5,.5),this._setUpscalingLimits(2,.75,.75));const s=new AbortController;if(this._layers.set(i,{layerView:e,responses:new Map,outstandingRequestCount:0,abortController:s,needMemoryUsageUpdate:!1}),this.layerUid.push(e.layer.uid),!this._halfIntTexturesAvailable||has("mac")){const t=[];let i="";for(const s of e.layer.variables)"Int16"!==s.renderingFormat.type&&"UInt16"!==s.renderingFormat.type||(t.push(s.name),s.id===e.layer.currentVariableId&&(i=s.name));""!==i&&S.error("#addVoxelLayer_error()",e.layer,`The voxel layer '${e.layer.title}' cannot render the current variable '${i}' in this browser`),t.length>0&&S.warn("#addVoxelLayer_warning()",e.layer,`The voxel layer '${e.layer.title}' cannot render the variables '${t.toString()}' in this browser`)}if(!this._textureFloatLinearAvailable){const t=[];let i="";for(const s of e.layer.variables)"Float32"===s.renderingFormat.type&&(t.push(s.name),s.id===e.layer.currentVariableId&&(i=s.name));""!==i&&S.error("#addVoxelLayer_error()",e.layer,`The voxel layer '${e.layer.title}' cannot render the current variable '${i}' in this browser`),t.length>0&&S.warn("#addVoxelLayer_warning()",e.layer,`The voxel layer '${e.layer.title}' cannot render the variables '${t.toString()}' in this browser`)}return has("esri-mobile")&&S.warnOnce("Mobile support differs across devices. Voxel layer might not display as expected."),i}return-1}prepareRender(e){if(!this._vxl)return;const t=e.bindParameters.camera.viewForward,i=e.bindParameters.camera.eye;this._vxl.update_camera_pos_and_direction(i[0],i[1],i[2],t[0],t[1],t[2]);const s=this._vxl.cull();this._dbg(P.RequestResponse,"missingResourceCount="+s),this._moreToLoad=s>0,this._havePreparedWithAllLayers=0===this._newLayers.length,this._updateMemoryUsage()}render(e){if(!this._vxl||e.output!==this._shaderOutput||e.bindParameters.slot!==this._renderSlot)return;for(const i of this._newLayers){const e=this._addVoxelLayer(i.layerView);-1===e?i.rejectCallback(-1):i.resolveCallback(e)}if(this._newLayers=[],0===this._layers.size)return void this._dbg(P.Error,"No voxel layers but RenderPlugin instance is being asked to render!");this._lastFrameWasStationary=this._view.stationary,this._syncRequestsResponses(),this._beforeDraw(),this._vxl.begin_color_frame(!this._view._stage.renderer.isFeatureEnabled(R.HighResolutionVoxel),e.bindParameters.lighting.mainLight.direction[0],e.bindParameters.lighting.mainLight.direction[1],e.bindParameters.lighting.mainLight.direction[2]);const t=this._renderTargetToRestore.viewport;t.width===this._viewportWidth&&t.height===this._viewportHeight||(this._viewportWidth=t.width,this._viewportHeight=t.height,this._vxl.set_viewport(t.width,t.height),this._layers.forEach((e=>{e.needMemoryUsageUpdate=!0}))),0===t.x&&0===t.y||this._dbg(P.Error,"Unsupported viewport parameters detected!"),this.updateWasmCamera(e.bindParameters.camera),this._captureFrustum&&(this._frustum.update(e.bindParameters.camera),this._doCaptureFrustum()),this._vxl.draw(),this._afterDraw(),(this._moreToLoad||!this._havePreparedWithAllLayers&&this._layers.size>0)&&this._renderPluginContext.requestRender()}destroy(){this._dbg(P.Lifetime,"--destroy--"),this._removeRenderPlugin(),this._readyWatchHandle=s(this._readyWatchHandle),this._qualityWatchHandle=s(this._qualityWatchHandle),this._timeExtentWatchHandle=s(this._timeExtentWatchHandle),this._stationaryWatchHandle=s(this._stationaryWatchHandle),this._vxl&&(this._layers.forEach((e=>{e.abortController.abort()})),this._wasmMemBlocks.forEach((e=>{0!==e&&this._vxl._free(e)})),this._vxl.uninitialize_voxel_wasm(),this._vxl=null)}_initializeWasm(e){return this._vxl?Promise.resolve():(this._vxlPromise||(this._vxlPromise=g(e).then((e=>{if(this._vxl=e,this._vxlPromise=null,this._newLayers.length<=0)return this._dbg(P.Lifetime," no voxel layers left after WASM downloaded, removing RenderPlugin and destroying"),void this.destroy();const t=this._getTimeArgs(this._view?.timeExtent),i=this._vxl.addFunction(this._restoreFramebuffer.bind(this),"v"),s=this._vxl.addFunction(this._setBlendState.bind(this),"viiii"),r=this._vxl.addFunction(this._setFrontFace.bind(this),"vi"),a=this._vxl.addFunction(this._setRasterizerState.bind(this),"vi"),n=this._vxl.addFunction(this._setDepthStencilStateFunction.bind(this),"viii"),o=this._vxl.addFunction(this._setViewport.bind(this),"viiii"),l=this._vxl.addFunction(this._bindPreviousDepthToSlot.bind(this),"iii"),h=this._vxl.addFunction(this._modifyResourceCount.bind(this),"viii"),d=this._halfIntTexturesAvailable&&!has("mac"),_=this._textureFloatLinearAvailable;this._vxl.initialize_voxel_wasm(i,s,r,a,n,o,l,h,t.startTime,t.endTime,t.useTime,d,_),this._renderPluginContext&&this._renderPluginContext.requestRender()})).catch((()=>{for(const e of this._newLayers)e.rejectCallback(-2);this._dbg(P.Error," WASM failed to download, removing RenderPlugin and destroying"),this.destroy()}))),this._vxlPromise)}pickDepth(e,t,i){if(!this._vxl||!this._rctx||0===this._layers.size)return null;const s=i.viewport[3]-t;if(e<0||e>i.viewport[2]||t<0||t>i.viewport[3])return this._dbg(P.Error,`[js] pickDepth: outOfRange, screenXY=[${e.toFixed(0)}, ${s.toFixed(0)}]]`),null;this._beforeDraw();const r=i.viewForward,a=i.eye;this._vxl.update_camera_pos_and_direction(a[0],a[1],a[2],r[0],r[1],r[2]),this.updateWasmCamera(i),this._vxl.begin_frame();const n=this._vxl.pick_depth(e,s);if(this._afterDraw(),n.success){return n.distanceToCamera}return null}pickObject(e,t,i,s){if(!this._vxl||!this._rctx||0===this._layers.size)return null;const r=Math.round(e),a=Math.round(t);if(r<0||r>i.viewport[2]||a<0||a>i.viewport[3])return this._dbg(P.Error,`[js] pickObject: outOfRange, screenXY=[${r}, ${a}], vp=[${i.viewport.toString()}]`),null;this._beforeDraw();const n=i.viewForward,o=i.eye;this._vxl.update_camera_pos_and_direction(o[0],o[1],o[2],n[0],n[1],n[2]),this.updateWasmCamera(i),this._vxl.begin_frame();let l=null;if(0===s.length)l=this._vxl.pick_object(r,a,0,0);else{const e={str:JSON.stringify({layerIds:s}),byteCount:0,ptr:0,isReusable:!1};this._allocateBlock(e)&&(l=this._vxl.pick_object(r,a,e.ptr,e.byteCount),e.isReusable||this._vxl._free(e.ptr))}return this._afterDraw(),l}_beforeDraw(){this._renderTargetToRestore={fbo:this._rctx.getBoundFramebufferObject(),viewport:this._rctx.getViewport()},this._rctx.setPolygonOffsetFillEnabled(!1),this._rctx.setScissorTestEnabled(!1),this._rctx.setColorMask(!0,!0,!0,!0)}_afterDraw(){this._renderTargetToRestore.fbo=null,this._rctx.externalTextureUnitUpdate(this._vxl.get_texture_units_bound_in_frame(),this._vxl.get_active_texture_unit()),this._rctx.externalVertexArrayObjectUpdate(),this._rctx.externalVertexBufferUpdate(),this._rctx.externalProgramUpdate()}intersect(e,t,i,s,r){if(!this._vxl||!this._rctx||0===this._layers.size||!e.options.selectionMode||e.options.isFiltered)return;if(r[0]<0||r[0]>e.camera.viewport[2]||r[1]<0||r[1]>e.camera.viewport[3])return this._dbg(P.Error,`[js] VoxelWasmPerScene.intersect: outOfRange, screenXY=[${r[0].toFixed(0)}, ${r[1].toFixed(0)}]`),null;const a=[];this._layers.forEach((t=>{e.options.filteredLayerUids.includes(t.layerView.layer.uid)&&a.push(t.layerView.wasmLayerId)}));const l=this.pickObject(r[0],r[1],e.camera,a);if(null==l||-1===l.layerId)return;const h=this._layers.get(l.layerId);if(h){const t=h.layerView.layer.uid,r=l.distanceToCamera/n(i,s),a=o();a[0]=l.worldX,a[1]=l.worldY,a[2]=l.worldZ;const d={};if(null!=l.continuousValue&&null!=l.continuousValueUnits?d["Voxel.ServiceValue"]=`${l.continuousValue.toLocaleString()} ${l.continuousValueUnits}`:null!=l.uniqueValueLabel&&null!=l.uniqueValue?d["Voxel.ServiceValue"]=`${l.uniqueValueLabel} (${l.uniqueValue})`:null!=l.uniqueValue&&(d["Voxel.ServiceValue"]=`${l.uniqueValue}`),d["Voxel.ServiceVariableLabel"]=l.variableLabel,d["Voxel.Position"]=l.voxelSpacePosition,null!=l.epochTime&&null!=l.nativeTime&&null!=l.nativeTimeUnits){const e=new Date(l.epochTime);d["Voxel.ServiceLocalTime"]=e.toString(),d["Voxel.ServiceNativeTime"]=`${l.nativeTime.toLocaleString()} ${l.nativeTimeUnits}`}null!=l.depth&&null!=l.depthUnits&&(d["Voxel.ServiceDepth"]=`${l.depth.toLocaleString()} ${l.depthUnits}`);const _=l.faceNormal;d["Voxel.WorldPosition"]=`[${a[0]}, ${a[1]}, ${a[2]}]`;const u=e=>{const i=new p(a,t,(()=>this._createVoxelGraphic(h.layerView.layer,d)));e.set(this.type,i,r,_)},c=e.results,m=e.options.store===T.ALL;if((null==c.min.dist||r<c.min.dist)&&u(c.min),(null==c.max.dist||r>c.max.dist)&&u(c.max),m){const t=b(e.ray);u(t),e.results.all.push(t)}}}_createVoxelGraphic(t,i){return new e({layer:t,sourceLayer:t,attributes:i})}_toWasmQuality(e){switch(e){case"low":return 0;case"medium":return 1;case"high":return 2}}_setUpscalingLimits(e,t,i){this._vxl&&this._vxl.set_upscaling_limits(e,t,i)}}export{U as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Error.js";import{JSONMap as s}from"../../../core/jsonMap.js";import{WhereClauseCache as n}from"../../../core/sql/WhereClauseCache.js";const i=new n(50,500),r="feature-store:unsupported-query",t=" as ",o=new s({esriFieldTypeString:"string"}),a=new s({esriFieldTypeOID:"oid",esriFieldTypeSmallInteger:"small-integer",esriFieldTypeInteger:"integer",esriFieldTypeSingle:"single",esriFieldTypeDouble:"double",esriFieldTypeLong:"long"}),l=new s({esriFieldTypeDate:"date"}),p=new Set([...a.jsonValues,...l.jsonValues,...o.jsonValues]),d=new Intl.ListFormat("en-US",{type:"conjunction"}).format([...a.apiValues,...l.apiValues,...o.apiValues]);function u(s,n,i={}){const t=f(s,n);if(!t)throw new e(r,"invalid SQL expression",{expression:s});const o=i.expressionName||"expression";if(i.validateStandardized&&!t.isStandardized)throw new e(r,`${o} is not standard`,{expression:s});if(i.validateAggregate&&!t.isAggregate)throw new e(r,`${o} does not contain a valid aggregate function`,{expression:s});return t.fieldNames}function g(e,s){if(!s)return!0;const n="where clause",i=u(s,e,{validateStandardized:!0,expressionName:n});return m(e,i,{expressionName:n}),x(e,i,{expressionName:n}),!0}function c(s,n,t){if(!n)return!0;const o="having",a=u(n,s,{validateAggregate:!0,expressionName:o});m(s,a,{expressionName:o}),x(s,a,{expressionName:o});const l=i.get(n,s),p=l?.getExpressions().every((e=>{const{aggregateType:n,field:i}=e,r=s.get(i)?.name;return t.some((e=>{const{onStatisticField:i,statisticType:t}=e,o=s.get(i)?.name;return o===r&&t.toLowerCase().trim()===n}))}));if(!p)throw new e(r,"expressions in having should also exist in outStatistics",{having:n});return!0}function f(e,s){return e?i.get(e,s):null}function m(e,s,n={}){n.errorMessage||(n.errorMessage=n.expressionName?`${n.expressionName} contains invalid fields`:"Fields are invalid"),h(e,s,((e,s)=>s.has(e)),n)}function x(e,s,n={}){n.errorMessage||(n.errorMessage=n.expressionName?`${n.expressionName} only supports ${d} field types`:`Only ${d} field types are supported`),h(e,s,((e,s)=>!v(e,s)),n)}function h(s,n,i,t={}){const o=t.verifyExpression??!0,a=[];for(const e of n){const n=i(e,s);if("*"!==e&&!n)if(o){const n=y(e);try{h(s,u(n,s,{validateStandardized:!0}),i,t)}catch(l){const s=l?.details;if(s?.expression)throw l;s?.invalidFields?a.push(...s.invalidFields):a.push(e)}}else a.push(e)}if(a.length)throw new e(r,t.errorMessage,{invalidFields:a})}function y(e){return e.split(t)[0]}function w(e){return e.split(t)[1]}function v(e,s,n=p){const i=s.get(e);return!!i&&!n.has(i.type)}export{w as getAliasFromFieldName,y as getExpressionFromFieldName,f as getWhereClause,v as hasInvalidFieldType,l as validDateTypesKebabDict,a as validNumericTypesKebabDict,x as validateFieldTypes,m as validateFields,c as validateHaving,g as validateWhere};
5
+ import e from"../../../core/Error.js";import{JSONMap as s}from"../../../core/jsonMap.js";import{WhereClauseCache as i}from"../../../core/sql/WhereClauseCache.js";const n=new i(50,500),r="feature-store:unsupported-query",t=" as ",o=new s({esriFieldTypeString:"string"}),a=new s({esriFieldTypeOID:"oid",esriFieldTypeSmallInteger:"small-integer",esriFieldTypeInteger:"integer",esriFieldTypeSingle:"single",esriFieldTypeDouble:"double",esriFieldTypeLong:"long"}),l=new s({esriFieldTypeDate:"date"}),d=new s({esriFieldTypeGUID:"guid",esriFieldTypeGlobalId:"global-id"}),p=new Set([...a.jsonValues,...l.jsonValues,...o.jsonValues,...d.jsonValues]),u=new Intl.ListFormat("en-US",{type:"conjunction"}).format([...a.apiValues,...l.apiValues,...o.apiValues,...d.apiValues]);function g(s,i,n={}){const t=m(s,i);if(!t)throw new e(r,"invalid SQL expression",{expression:s});const o=n.expressionName||"expression";if(n.validateStandardized&&!t.isStandardized)throw new e(r,`${o} is not standard`,{expression:s});if(n.validateAggregate&&!t.isAggregate)throw new e(r,`${o} does not contain a valid aggregate function`,{expression:s});return t.fieldNames}function c(e,s){if(!s)return!0;const i="where clause",n=g(s,e,{validateStandardized:!0,expressionName:i});return x(e,n,{expressionName:i}),y(e,n,{expressionName:i}),!0}function f(s,i,t){if(!i)return!0;const o="having",a=g(i,s,{validateAggregate:!0,expressionName:o});x(s,a,{expressionName:o}),y(s,a,{expressionName:o});const l=n.get(i,s),d=l?.getExpressions().every((e=>{const{aggregateType:i,field:n}=e,r=s.get(n)?.name;return t.some((e=>{const{onStatisticField:n,statisticType:t}=e,o=s.get(n)?.name;return o===r&&t.toLowerCase().trim()===i}))}));if(!d)throw new e(r,"expressions in having should also exist in outStatistics",{having:i});return!0}function m(e,s){return e?n.get(e,s):null}function x(e,s,i={}){i.errorMessage||(i.errorMessage=i.expressionName?`${i.expressionName} contains invalid fields`:"Fields are invalid"),h(e,s,((e,s)=>s.has(e)),i)}function y(e,s,i={}){i.errorMessage||(i.errorMessage=i.expressionName?`${i.expressionName} only supports ${u} field types`:`Only ${u} field types are supported`),h(e,s,((e,s)=>!F(e,s)),i)}function h(s,i,n,t={}){const o=t.verifyExpression??!0,a=[];for(const e of i){const i=n(e,s);if("*"!==e&&!i)if(o){const i=w(e);try{h(s,g(i,s,{validateStandardized:!0}),n,t)}catch(l){const s=l?.details;if(s?.expression)throw l;s?.invalidFields?a.push(...s.invalidFields):a.push(e)}}else a.push(e)}if(a.length)throw new e(r,t.errorMessage,{invalidFields:a})}function w(e){return e.split(t)[0]}function v(e){return e.split(t)[1]}function F(e,s,i=p){const n=s.get(e);return!!n&&!i.has(n.type)}export{v as getAliasFromFieldName,w as getExpressionFromFieldName,m as getWhereClause,F as hasInvalidFieldType,l as validDateTypesKebabDict,d as validGuidTypesKebabDict,a as validNumericTypesKebabDict,y as validateFieldTypes,x as validateFields,f as validateHaving,c as validateWhere};