@arcgis/core 4.34.0-next.85 → 4.34.0-next.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Basemap.js +1 -1
- package/arcade/functions/measures.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/06c389283ee5b60573f2.js +1 -0
- package/assets/esri/core/workers/chunks/0b679d5a1bfdbd006d6e.js +1 -0
- package/assets/esri/core/workers/chunks/1537b02e674f8ef77f4a.js +1 -0
- package/assets/esri/core/workers/chunks/{9eb1bfcb9b05f2a36748.js → 1f2d13466c60a6b57717.js} +1 -1
- package/assets/esri/core/workers/chunks/{7a23b127f551bf13ef54.js → 268f5b233640a9dbbf89.js} +2 -2
- package/assets/esri/core/workers/chunks/2896ada406074f754b00.js +1 -0
- package/assets/esri/core/workers/chunks/28d30be414e59eabd963.js +1 -0
- package/assets/esri/core/workers/chunks/29471e0b3f7296dee096.js +1 -0
- package/assets/esri/core/workers/chunks/{3192b68675ff2afcb1d6.js → 2d3ae187f8aa3495d4ae.js} +1 -1
- package/assets/esri/core/workers/chunks/336b54144afec0c7d396.js +2 -0
- package/assets/esri/core/workers/chunks/42bc1e981624ce9844a4.js +1 -0
- package/assets/esri/core/workers/chunks/436bbe99bedd7b331edb.js +1 -0
- package/assets/esri/core/workers/chunks/{d66cdb9bb494da19696b.js → 47e4f66c33bb697fbe6b.js} +2 -2
- package/assets/esri/core/workers/chunks/4840bd93d8fe15c7aefd.js +1 -0
- package/assets/esri/core/workers/chunks/4a06ab00d095f63598b5.js +1 -0
- package/assets/esri/core/workers/chunks/4d4db6854aff7656f6e1.js +1 -0
- package/assets/esri/core/workers/chunks/5c585b338a9e9aa0e205.js +1 -0
- package/assets/esri/core/workers/chunks/655a878ddea4907d830e.js +1 -0
- package/assets/esri/core/workers/chunks/68f5a2d2666636c3f807.js +1 -0
- package/assets/esri/core/workers/chunks/6c36cef0b58b87a1f17f.js +316 -0
- package/assets/esri/core/workers/chunks/72fe4f1f789abb5b4035.js +1 -0
- package/assets/esri/core/workers/chunks/8307f635a5c0c4a95825.js +1 -0
- package/assets/esri/core/workers/chunks/{afb76f9d6abedef771df.js → 8380a092ffc8e92ede7a.js} +1 -1
- package/assets/esri/core/workers/chunks/{f8f85207b382c1ea038c.js → 97489bf16a1d327992b2.js} +3 -3
- package/assets/esri/core/workers/chunks/9d7a22746dae1451deaf.js +1 -0
- package/assets/esri/core/workers/chunks/a2652d10bb0bc41c9a8d.js +1 -0
- package/assets/esri/core/workers/chunks/a845c68e76382a73da5e.js +1 -0
- package/assets/esri/core/workers/chunks/{9c64b78c5c9b35b31d98.js → aa78b69219d9a0ef1c54.js} +2 -2
- package/assets/esri/core/workers/chunks/{1859a11df9f579b993d7.js → b2fbb44e219232e61cbd.js} +1 -1
- package/assets/esri/core/workers/chunks/b4349db7155673329432.js +1 -0
- package/assets/esri/core/workers/chunks/{d153b29c542c37ae1636.js → c50e8d5f554cf151865c.js} +2 -2
- package/assets/esri/core/workers/chunks/c5cc0fc652432a9264cc.js +1 -0
- package/assets/esri/core/workers/chunks/cab2a1382bdd32bb34d8.js +1 -0
- package/assets/esri/core/workers/chunks/ce937ff0dd1147ea297e.js +1 -0
- package/assets/esri/core/workers/chunks/d142a42755a78bb157ed.js +1 -0
- package/assets/esri/core/workers/chunks/{280af3640f8e93c1024e.js → d6e0528eacee7ea4c1ce.js} +2 -2
- package/assets/esri/core/workers/chunks/d9d86cf0500fa29d1d43.js +1 -0
- package/assets/esri/core/workers/chunks/{b15ff6c9ef2de8a49853.js → f651c05604eab83aef5f.js} +2 -2
- package/assets/esri/core/workers/chunks/{ed773dab5965e42a2879.js → f6e18668f728dfd8ba5e.js} +2 -2
- package/assets/esri/core/workers/chunks/ff8e2f998169ca3a7a68.js +1 -0
- package/assets/esri/libs/dracoMeshDecoder/draco_mesh_decoder.wasm +0 -0
- package/assets/esri/libs/i3s/i3s.wasm +0 -0
- package/chunks/CloudsComposition.glsl.js +2 -2
- package/chunks/HUDMaterial.glsl.js +49 -50
- package/chunks/LineMarker.glsl.js +34 -34
- package/chunks/PointRenderer.glsl.js +4 -4
- package/chunks/ShadowHighlight.glsl.js +3 -3
- package/chunks/draco_mesh_decoder.js +1 -1
- package/config.js +1 -1
- package/core/NestedMap.js +1 -1
- package/core/iteratorUtils.js +1 -1
- package/editing/geometry/lineUtils.js +1 -1
- package/interfaces.d.ts +55 -7
- package/kernel.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/layers/IntegratedMeshLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
- package/layers/knowledgeGraph/cypherUtils.js +1 -1
- package/layers/support/layerUtils.js +1 -1
- package/package.json +5 -5
- package/support/basemapEnsureType.js +1 -1
- package/support/revision.js +1 -1
- package/support/userTypeGuards/isBasemap.js +5 -0
- package/symbols/support/previewSymbol2D.js +1 -1
- package/views/3d/FocusAreasView.js +1 -1
- package/views/3d/environment/CloudsComposition.glsl.js +1 -1
- package/views/3d/glTF/internal/Resource.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
- package/views/3d/support/engineContent/marker.js +1 -1
- package/views/3d/support/engineContent/sdfPrimitives.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +11 -11
- package/views/3d/webgl-engine/lib/BasisUtil.js +1 -1
- package/views/3d/webgl-engine/lib/Texture.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/InstancedCommandVAO.js +5 -0
- package/views/3d/webgl-engine/materials/renderers/InstancedCommandVAOs.js +5 -0
- package/views/3d/webgl-engine/materials/renderers/PerBufferData.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/PerOriginData.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/VaoRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
- package/views/3d/webgl-engine/shaders/AnimatedLine.glsl.js +14 -9
- package/views/3d/webgl-engine/shaders/HUDMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/LineMarker.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/PointRenderer.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowHighlight.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/LineOffset.glsl.js +8 -8
- package/views/BasemapView.js +1 -1
- package/views/GroundView.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/View.js +1 -1
- package/views/View2D.js +1 -1
- package/views/support/LayerViewManager.js +1 -1
- package/views/webgl/RenderbufferDescriptor.js +1 -1
- package/views/webgl/TextureDescriptor.js +1 -1
- package/views/webgl/Util.js +1 -1
- package/views/webgl/VertexArrayObject.js +1 -1
- package/webscene/Slide.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
- package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
- package/widgets/Editor/support/SketchController.js +1 -1
- package/widgets/Editor/support/splitFeatureUtils.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Sketch/adapters/layer/GraphicsLayerAdapter.js +5 -0
- package/widgets/Sketch/adapters/layer/MapNotesLayerAdapter.js +5 -0
- package/assets/esri/core/workers/chunks/25ea02dd7d45a90cbb3b.js +0 -1
- package/assets/esri/core/workers/chunks/264a9a916e1e972b69d7.js +0 -1
- package/assets/esri/core/workers/chunks/30c85a1a4f118cc45a25.js +0 -1
- package/assets/esri/core/workers/chunks/3ef8a7468d7e3b2f0b69.js +0 -351
- package/assets/esri/core/workers/chunks/5c1cdc2ec06c4c6bd0b3.js +0 -1
- package/assets/esri/core/workers/chunks/609abf071c4ea24955c2.js +0 -1
- package/assets/esri/core/workers/chunks/71c2a8e5a17803d3e949.js +0 -1
- package/assets/esri/core/workers/chunks/7889a909394c61a9d3e0.js +0 -1
- package/assets/esri/core/workers/chunks/99ac292a858bbedc6a89.js +0 -1
- package/assets/esri/core/workers/chunks/9a6fa91dd204f64d2590.js +0 -1
- package/assets/esri/core/workers/chunks/9cdeead9d444e8d95477.js +0 -1
- package/assets/esri/core/workers/chunks/aa1eb7b4d9ccda725da5.js +0 -1
- package/assets/esri/core/workers/chunks/b4a053063e6022080d31.js +0 -1
- package/assets/esri/core/workers/chunks/b4b26cc2ba3ff30e1d03.js +0 -1
- package/assets/esri/core/workers/chunks/bbb585f0b484ab5eabb3.js +0 -1
- package/assets/esri/core/workers/chunks/c2bc70b65f5c2a2c9671.js +0 -1
- package/assets/esri/core/workers/chunks/cd1869e183001266c4c1.js +0 -2
- package/assets/esri/core/workers/chunks/d2fe403d6ab237bc89c2.js +0 -1
- package/assets/esri/core/workers/chunks/d51e8eeb1e1eb0605cc9.js +0 -1
- package/assets/esri/core/workers/chunks/e080628ac6e1cf25dc72.js +0 -1
- package/assets/esri/core/workers/chunks/e8e0f73fb94e63e2abc3.js +0 -1
- package/assets/esri/core/workers/chunks/f45c343527709f6f91c2.js +0 -1
- package/assets/esri/core/workers/chunks/fcac475e4e82911b3126.js +0 -1
- /package/assets/esri/core/workers/chunks/{7a23b127f551bf13ef54.js.LICENSE.txt → 268f5b233640a9dbbf89.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{cd1869e183001266c4c1.js.LICENSE.txt → 336b54144afec0c7d396.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{280af3640f8e93c1024e.js.LICENSE.txt → 47e4f66c33bb697fbe6b.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{9c64b78c5c9b35b31d98.js.LICENSE.txt → aa78b69219d9a0ef1c54.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{d153b29c542c37ae1636.js.LICENSE.txt → c50e8d5f554cf151865c.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{b15ff6c9ef2de8a49853.js.LICENSE.txt → d6e0528eacee7ea4c1ce.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{d66cdb9bb494da19696b.js.LICENSE.txt → f651c05604eab83aef5f.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{ed773dab5965e42a2879.js.LICENSE.txt → f6e18668f728dfd8ba5e.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
const n=Symbol("BasemapInstance");function t(t){return null!=t&&"object"==typeof t&&n in t}export{n as BasemapSymbol,t as isBasemap};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../Color.js";import{getColorLuminance as e}from"../../core/colorUtils.js";import o from"../../core/Error.js";import{loadFont as i}from"../../core/fontUtils.js";import{pt2px as n}from"../../core/screenUtils.js";import{quantizePolygon as
|
|
5
|
+
import t from"../../Color.js";import{getColorLuminance as e}from"../../core/colorUtils.js";import o from"../../core/Error.js";import{loadFont as i}from"../../core/fontUtils.js";import{pt2px as n}from"../../core/screenUtils.js";import{quantizePolygon as a,quantizePolyline as l}from"../../geometry/support/quantizationUtils.js";import{isCurvedGeometry as s}from"../../geometry/support/curves/curveUtils.js";import{densifyCurvedGeometry as r}from"../../geometry/support/curves/densifyCurvedGeometry.js";import{getFill as h,getStroke as c,getDashArray as m,getPatternUrlWithColor as u}from"./gfxUtils.js";import{shapes as p,adjustColorBrightness as d}from"./previewUtils.js";import{renderSymbol as f}from"./renderUtils.js";import{backgroundPadding as g}from"./textUtils.js";const y="picture-fill",w="picture-marker",x="simple-fill",v="simple-line",b="simple-marker",M="text",k="Aa",z=22,L=120,S=80,C=50,j=225,B=document.createElement("canvas");function P(t,e,o){const{extent:i}=t;if(!i)return"";const n=i.width||1,h=i.height||1;if("polygon"===t.type){const l=t.clone();s(l)&&(l.rings=r(l,{minSegmentsPerCurve:128}).rings),a({originPosition:"upperLeft",scale:[n/e,h/o],translate:[i.xmin,i.ymax]},l,l);let c="";for(let t=0;t<l.rings.length;t++){const e=l.rings[t];for(let t=0;t<e.length;t++){const o=e[t][0],i=e[t][1],n=0===t?"M":"l",a=t===e.length-1?" Z":"";c+=`${""!==c?" ":""}${n}${o.toString()} ${i.toString()}${a}`}}return c}if("polyline"===t.type){const a=t.clone();s(a)&&(a.paths=r(a,{minSegmentsPerCurve:128}).paths),l({originPosition:"upperLeft",scale:[n/e,h/o],translate:[i.xmin,i.ymax]},a,a);let c="";for(let t=0;t<a.paths.length;t++){const e=a.paths[t];for(let t=0;t<e.length;t++){const o=e[t][0],i=e[t][1];c+=`${""!==c?" ":""}${0===t?"M":"l"}${o.toString()} ${i.toString()}`}}return c}return""}function $(t,e){const o=B.getContext("2d"),i=[];e&&(e.weight&&i.push(e.weight),e.size&&i.push(e.size+"px"),e.family&&i.push(e.family)),o.font=i.join(" ");const{width:n,actualBoundingBoxLeft:a,actualBoundingBoxRight:l,actualBoundingBoxAscent:s,actualBoundingBoxDescent:r}=o.measureText(t);return{width:Math.ceil(Math.max(n,a+l)),height:Math.ceil(s+r),x:Math.floor(a),y:Math.floor((s-r)/2)}}function E(t){const e=t?.size;return{width:null!=e&&"object"==typeof e&&"width"in e?n(e.width):null,height:null!=e&&"object"==typeof e&&"height"in e?n(e.height):null}}async function U(t,e){const o=e.fill,i=t.color;if("pattern"===o?.type&&i&&t.type!==y){const t=await u(o.src,i.toCss(!0));o.src=t,e.fill=o}}async function F(t,e,o,n){if(!("font"in t)||!t.font||"text"!==e.shape.type)return;try{await i(t.font)}catch{}const{width:a,height:l}=E(n);if(!/[\uE600-\uE6FF]/.test(e.shape.text)){const{width:i,height:s,x:r,y:h}=$(e.shape.text,{weight:e.font?.weight,size:e.font?.size,family:e.font?.family});o[0]=a??i,o[1]=l??s,e.shape.x=r,e.shape.y=h;let c="angle"in t?t.angle:null;if(null!=n?.rotation&&(c=(c??0)+n.rotation),c){const t=c*(Math.PI/180),e=Math.abs(Math.sin(t)),i=Math.abs(Math.cos(t));o[1]=o[0]*e+o[1]*i}}}function A(t,e,o,i,a){if(null!=t.haloColor&&null!=t.haloSize){a.masking??=o.map(()=>[]);const l=n(t.haloSize);i[0]+=l,i[1]+=l,o.unshift([{...e,fill:null,stroke:{color:t.haloColor,width:2*l,join:"round",cap:"round"}}]),a.masking.unshift([{shape:{type:"rect",x:0,y:0,width:i[0]+2*g,height:i[1]+2*g},fill:[255,255,255],stroke:null},{...e,fill:[0,0,0,0],stroke:null}])}null==t.backgroundColor&&null==t.borderLineColor||(i[0]+=2*g,i[1]+=2*g,o.unshift([{shape:{type:"rect",x:0,y:0,width:i[0],height:i[1]},fill:t.backgroundColor,stroke:{color:t.borderLineColor,width:n(t.borderLineSize)}}]),a.masking?.unshift([]))}function Z(t,e){return t>e?"dark":"light"}function D(t,e){const o="number"==typeof e?.size?e?.size:null,i=null!=o?n(o):null,a=null!=e?.maxSize?n(e.maxSize):null;let l="angle"in t?t.angle:null;null!=e?.rotation&&(l=(l??0)+e.rotation);const s=h(t);let r=c(t);"dark"!==T(t,245)||e?.ignoreWhiteSymbols||(r={width:.75,...r,color:"#bdc3c7"});let u=null;const d={shape:null,fill:s,stroke:r,offset:[0,0]};r?.width&&(r.width=Math.min(r.width,S));const f=r?.width||0;let g=null!=e?.size&&(null==e?.scale||e?.scale),j=0,B=0,U=!1;switch(t.type){case b:{const o=t.style,{width:s,height:r}=E(e);let h=s===r&&null!=s?s:null!=i?i:Math.min(n(t.size),a||L);if(!0===e?.useMarkerSymbolSize&&null!==s&&null!==r){const e=Math.min(n(t.size),a||L);h=e>s&&e>r?Math.min(s,r):e}switch(j=h,B=h,o){case"circle":d.shape={type:"circle",cx:0,cy:0,r:.5*h},g||(j+=f,B+=f);break;case"cross":d.shape={type:"path",path:[{command:"M",values:[0,.5*B]},{command:"L",values:[j,.5*B]},{command:"M",values:[.5*j,0]},{command:"L",values:[.5*j,B]}]};break;case"diamond":d.shape={type:"path",path:[{command:"M",values:[0,.5*B]},{command:"L",values:[.5*j,0]},{command:"L",values:[j,.5*B]},{command:"L",values:[.5*j,B]},{command:"Z",values:[]}]},g||(j+=f,B+=f);break;case"square":d.shape={type:"path",path:[{command:"M",values:[0,0]},{command:"L",values:[j,0]},{command:"L",values:[j,B]},{command:"L",values:[0,B]},{command:"Z",values:[]}]},g||(j+=f,B+=f),l&&(U=!0);break;case"triangle":d.shape={type:"path",path:[{command:"M",values:[.5*j,0]},{command:"L",values:[j,B]},{command:"L",values:[0,B]},{command:"Z",values:[]}]},g||(j+=f,B+=f),l&&(U=!0);break;case"x":d.shape={type:"path",path:[{command:"M",values:[0,0]},{command:"L",values:[j,B]},{command:"M",values:[j,0]},{command:"L",values:[0,B]}]},l&&(U=!0);break;case"path":d.shape={type:"path",path:t.path||""},g||(j+=f,B+=f),l&&(U=!0),g=!0}break}case v:{const{width:t,height:o}=E(e),n=m(r).reduce((t,e)=>t+e,0),a=n&&Math.ceil(C/n),l=o??i??f,s=t??(n*a||C);if(g=!0,"polyline"===e?.geometry?.type&&e?.geometry?.extent){j=s,B=o??j;const t=1e3,i=.15*t;u=[j,B],B=u[0]>u[1]?t*u[1]/u[0]:t,j=u[0]>u[1]?t:t*u[0]/u[1],r?.width&&(r.width=r.width*t/(u[1]>u[0]?u[1]:u[0]),r.width>i&&(r.width=i)),d.shape={type:"path",path:P(e.geometry,j,B)}}else j=null!=e?.maxSize?Math.min(s,e.maxSize):s,B=l,r&&(r.width=l),d.shape={type:"path",path:[{command:"M",values:[l/2,B/2]},{command:"L",values:[j-l/2,B/2]}]};break}case y:case x:{const t="object"==typeof e?.symbolConfig&&!!e?.symbolConfig?.isSquareFill,{width:o,height:n}=E(e);j=!t&&o!==n||null==o?null!=i?i:z:o,B=!t&&o!==n||null==n?j:n,g||(j+=f,B+=f),g=!0,e?.geometry?.extent&&"polygon"===e?.geometry?.type?(u=[j,B],B=u[0]>u[1]?1e3*u[1]/u[0]:1e3,j=u[0]>u[1]?1e3:1e3*u[0]/u[1],d.shape={type:"path",path:P(e.geometry,j,B)}):d.shape=t?{type:"path",path:[{command:"M",values:[0,0]},{command:"L",values:[j,0]},{command:"L",values:[j,B]},{command:"L",values:[0,B]},{command:"L",values:[0,0]},{command:"Z",values:[]}]}:p.fill[0];break}case w:{const o=Math.min(n(t.width),a||L),s=Math.min(n(t.height),a||L),{width:r,height:h}=E(e),c=r===h&&null!=r?r:null!=i?i:Math.max(o,s),m=t.width/t.height;j=m<=1?Math.ceil(c*m):c,B=m<=1?c:Math.ceil(c/m),d.shape={type:"image",x:-Math.round(j/2),y:-Math.round(B/2),width:j,height:B,src:t.url||""},l&&(U=!0);break}case M:{const o=t,l=e?.overrideText||o.text||k,s=o.font,{width:r,height:h}=E(e),c=null!=h?h:null!=i?i:Math.min(n(s.size),a||L),{width:m,height:u}=$(l,{weight:s.weight,size:c,family:s.family}),p=/[\uE600-\uE6FF]/.test(l);j=r??(p?c:m),B=p?c:u;let f=.5*(p?c:u);p&&(f+=5),d.shape={type:"text",text:l,x:o.xoffset||0,y:o.yoffset||f,align:"middle",alignBaseline:o.verticalAlignment,decoration:s&&s.decoration,rotated:o.rotated,kerning:o.kerning},d.font=s&&{size:c,style:s.style,decoration:s.decoration,weight:s.weight,family:s.family};break}}return{shapeDescriptor:d,size:[j,B],outputSize:u,renderOptions:{node:e?.node,scale:g,opacity:e?.opacity,rotations:[l],useRotationSize:U,cssEffectFilter:e?.cssEffectFilter,ariaLabel:e?.ariaLabel,clipBloomEffect:e?.clipBloomEffect}}}async function q(t,e){const{shapeDescriptor:i,size:n,renderOptions:a,outputSize:l}=D(t,e);if(!i.shape)throw new o("symbolPreview: renderPreviewHTML2D","symbol not supported.");await U(t,i),await F(t,i,n,e);const s=[[i]];if("object"==typeof e?.symbolConfig&&e?.symbolConfig?.applyColorModulation){const t=.6*n[0];s.unshift([{...i,offset:[-t,0],fill:d(i.fill,-.3)}]),s.push([{...i,offset:[t,0],fill:d(i.fill,.3)}]),n[0]+=2*t,a.scale=!1}"text"===t.type&&A(t,i,s,n,a);const r=f(s,n,a);if(l&&r){const t="img"===r.nodeName.toLowerCase()?r:r.firstChild;"svg"===t.nodeName.toLowerCase()&&t.setAttribute("viewBox",`0 0 ${n[0].toString()} ${n[1].toString()}`),t.setAttribute("width",l[0].toString()),t.setAttribute("height",l[1].toString()),l.length>2&&(t.style.setProperty("padding-left",l[2]?.toString()+"px"),t.style.setProperty("padding-right",l[2]?.toString()+"px"),t.style.setProperty("padding-top",l[3]?.toString()+"px"),t.style.setProperty("padding-bottom",l[3]?.toString()+"px"),t.style.setProperty("box-sizing","border-box"))}return r}function T(o,i=j){const n=h(o),a=c(o),l=!n||"type"in n?null:new t(n),s=a?.color?new t(a?.color):null,r=l?Z(e(l),i):null,m=s?Z(e(s),i):null;return m?r?r===m?r:i>=j?"light":"dark":m:r}export{T as getContrastingBackgroundTheme,D as getRenderSymbolParameters,q as previewSymbol2D};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import o from"../../core/Accessor.js";import{equals as r}from"../../core/arrayUtils.js";import t from"../../core/Collection.js";import s from"../../core/Error.js";import i from"../../core/Logger.js";import{mapCollection as n}from"../../core/mapCollectionUtils.js";import{watch as a,
|
|
5
|
+
import{__decorate as e}from"tslib";import o from"../../core/Accessor.js";import{equals as r}from"../../core/arrayUtils.js";import t from"../../core/Collection.js";import s from"../../core/Error.js";import i from"../../core/Logger.js";import{mapCollection as n}from"../../core/mapCollectionUtils.js";import{watch as a,initial as m}from"../../core/reactiveUtils.js";import{convertToSpatialReferenceUnit as c,convertFromSpatialReferenceUnit as l}from"../../core/unitUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import{e as h}from"../../chunks/earcut.js";import{create as d}from"../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as f}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as g}from"../../geometry/ellipsoidUtils.js";import y from"../../geometry/Point.js";import{project as w}from"../../geometry/projectionUtils.js";import{execute as j}from"../../geometry/operators/gx/operatorDensify.js";import{execute as v}from"../../geometry/operators/gx/operatorSimplify.js";import{fromSpatialReference as _,fromPolygon as A,toPolygon as x}from"../../geometry/operators/support/apiConverter.js";import{computeTranslationToOriginAndRotation as b}from"../../geometry/projection/computeTranslationToOriginAndRotation.js";import{newDoubleArray as R}from"../../geometry/support/DoubleArray.js";import{earth as N}from"../../geometry/support/Ellipsoid.js";import{newIndexArray as M}from"../../geometry/support/Indices.js";import{t as C}from"../../chunks/vec3.js";import{ElevationContext as U}from"./layers/graphics/ElevationContext.js";import{extrudePolygon as k}from"./layers/graphics/Graphics3DExtrudeSymbolLayer.js";import{computeCentroid as V}from"./layers/graphics/graphicUtils.js";import{geometryToRenderInfo as H}from"./support/renderInfoUtils/polygon.js";import{FocusAreaColorNode as E}from"./webgl-engine/effects/focusArea/FocusAreaColorNode.js";import{FocusAreaMaskNode as F}from"./webgl-engine/effects/focusArea/FocusAreaMaskNode.js";import{FocusAreaOutlineItem as G}from"./webgl-engine/effects/focusArea/FocusAreaOutlineItem.js";const I=2e4;let P=class extends o{constructor(e){super(e),this._volumes=new Map,this._elevationContext=new U,this._outlineMap=new t}initialize(){this.addHandles([a(()=>({polygons:this.polygons,ready:this.view.basemapTerrain?.ready}),({polygons:e,ready:o})=>{o&&this._updateVolumes(e)},m)]),this._outlineMap=n(()=>this.areas?.areas,e=>new G({area:e,view:this.view}),{recycleItems:!0})}destroy(){this.removeAllHandles(),this._outlineMap.destroy()}get areas(){return this.view.map?.focusAreas}get enabledAreas(){return this.areas?.areas.toArray().filter(({enabled:e})=>e)??[]}get style(){return this.areas?.style??"bright"}get polygons(){return this.enabledAreas.reduce((e,o)=>e.concat(o.geometries.toArray()),new Array)}containsGeometry(e){if(0===this.polygons.length)return!0;const o=new y(e);return this.polygons.some(e=>e.contains(o))}_updateVolumes(e){this._extrude(e),this._ensureRenderNodes()}_extrude(e){if(!this.view.renderCoordsHelper||r(Array.from(this._volumes.keys()),e))return;const o=this.view.renderCoordsHelper,t=f(),n=1===o.viewingMode,a=d(),m=d(),p=this.view.spatialReference,u=_(p),y=g(p).radius/N.radius,U=c(5e5*y,"meters",p,!0);n||o.worldUpAtPosition([0,0,0],t);const E=new Map;for(const r of e){const e=this._volumes.get(r);if(e)E.set(r,e);else try{const e=p.equals(r.spatialReference)?r:w(r,p),s=Math.max(e.extent.width,e.extent.height),i=l(s,p,"meters",!0),c=Math.max(5*i,I*y),d=n?y/10:y,f=this._reduceGeometryHeight(e,c,d),g=V(f);if(null==g)continue;const _=A(f),N=v(_,u,!1)??_,F=j(N,U,0,0),G=x(F,p);if(null==G)continue;b(p,[g.x,g.y,0],a,o.spatialReference),m[12]=-a[12],m[13]=-a[13],m[14]=-a[14];const P=H(G,this.view.elevationProvider,o,this._elevationContext),{polygons:z,mapPositions:D,position:L}=P,T=new Array,q=new O(T,[a[12],a[13],a[14]]);for(const o of z){const e=o.count,r=h(o.mapPositions,o.holeIndices,3);if(0===r.length)continue;const s=r.length,i=6*e,a=i+s,l=R(3*i),p=M(a),u=M(s);k(L,D,r,o,l,null,null,null,p,u,c,t,n),C(l,l,m);const d=new S(l,u,p,c);T.push(d)}E.set(r,q)}catch(F){i.getLogger(this).error(new s("focusareasview:projection-failed","Failed to project focus area geometry to view spatial reference",{geometry:r,error:F}))}}this._volumes=E,0!==this.volumes.size&&this._maskRenderNode?.updateGeometries()}_ensureRenderNodes(){if(this.view.stage)if(0===this.volumes.size){const{_maskRenderNode:e,_colorRenderNode:o}=this;this._maskRenderNode=this._colorRenderNode=null,o?.fadeOut(()=>{e?.destroy(),o?.destroy()})}else this._maskRenderNode??=new F({focusAreasView:this}),this._colorRenderNode??=new E({focusAreasView:this}),this.view.stage.renderView.requestRender()}_reduceGeometryHeight(e,o,r){const t=-12e5*r,s=Math.max(-o/2,t),i=e.rings.map(e=>e.map(e=>[e[0],e[1],s])),n=e.clone();return n.rings=i,n.hasZ=!0,n}get volumes(){return this._volumes}};e([p()],P.prototype,"_volumes",void 0),e([p({constructOnly:!0})],P.prototype,"view",void 0),P=e([u("esri.views.3d.FocusAreasView")],P);class O{constructor(e,o){this.geometryVolumes=e,this.origin=o}}class S{constructor(e,o,r,t){this.positions=e,this.indicesBottom=o,this.indicesExtruded=r,this.height=t}}export{P as FocusAreasView};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../webgl-engine/core/shaderLibrary/shading/EvaluateAmbientLighting.glsl.js";import"../webgl-engine/core/shaderLibrary/shading/Gamma.glsl.js";import"../webgl-engine/core/shaderLibrary/shading/PiUtils.glsl.js";import"../webgl-engine/core/shaderLibrary/util/CloudsParallaxShading.glsl.js";import"../webgl-engine/core/shaderLibrary/util/ColorConversion.glsl.js";import"../webgl-engine/core/
|
|
5
|
+
import"../webgl-engine/core/shaderLibrary/shading/EvaluateAmbientLighting.glsl.js";import"../webgl-engine/core/shaderLibrary/shading/Gamma.glsl.js";import"../webgl-engine/core/shaderLibrary/shading/PiUtils.glsl.js";import"../webgl-engine/core/shaderLibrary/util/CloudsParallaxShading.glsl.js";import"../webgl-engine/core/shaderLibrary/util/ColorConversion.glsl.js";import"../webgl-engine/core/shaderModules/Float3BindUniform.js";import"../webgl-engine/core/shaderModules/FloatBindUniform.js";import"../webgl-engine/core/shaderModules/glsl.js";import"../webgl-engine/shaders/ScreenSpacePassAtmosphere.glsl.js";import"../../webgl/ShaderBuilder.js";export{b as build}from"../../../chunks/CloudsComposition.glsl.js";
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../core/Error.js";import t from"../../../../core/Logger.js";import{getOrCreateMapValue as r}from"../../../../core/MapUtils.js";import{getKey as o}from"../../../../core/object.js";import{allSettledValues as n}from"../../../../core/promiseUtils.js";import{isDataProtocol as s,dataComponents as a,dataToArrayBuffer as i,makeAbsolute as u}from"../../../../core/urlUtils.js";import{Version as f}from"../../../../core/Version.js";import{fromXRotation as c,multiply as d,translate as l,rotate as p,scale as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as h,clone as b}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{getAxisAngle as w}from"../../../../core/libs/gl-matrix-2/math/quat.js";import{create as y}from"../../../../core/libs/gl-matrix-2/factories/quatf64.js";import{BufferViewVec2f as g,BufferViewVec2u32 as T,BufferViewVec2u16 as _,BufferViewVec2i16 as x,BufferViewVec2u8 as O,BufferViewVec2i8 as N,BufferViewUint32 as S,BufferViewUint16 as C,BufferViewUint8 as A,BufferViewVec3f as L,BufferViewVec4f as E,BufferViewVec4u8 as R,BufferViewVec4u16 as v,BufferViewVec3u8 as I,BufferViewVec3u16 as D}from"../../../../geometry/support/buffer/BufferView.js";import{m as B}from"../../../../chunks/scalar.js";import"../../../../core/has.js";import{getDracoMeshDecoder as U}from"../../../../libs/dracoMeshDecoder/dracoMeshDecoder.js";import{BinaryStreamReader as M}from"./BinaryStreamReader.js";import{material as j,textureSampler as G}from"./fillDefaults.js";import{splitURI as F}from"./pathUtils.js";import{jsonFromBinaryData as H,EncodedMeshTexture as P,imageFromBinaryData as V,isEncodedMeshTexture as z}from"./resourceUtils.js";import{DataType as K}from"../../../webgl/enums.js";const k={MAGIC:1179937895,CHUNK_TYPE_JSON:1313821514,CHUNK_TYPE_BIN:5130562};class Y{constructor(t,r,o,n){if(this._context=t,this.uri=r,this.json=o,this._glbBuffer=n,this._bufferLoaders=new Map,this._textureLoaders=new Map,this._dracoBuffersSize=0,this._textureCache=new Map,this._materialCache=new Map,this._nodeParentMap=new Map,this._nodeTransformCache=new Map,this._supportedExtensions=["KHR_texture_basisu","KHR_texture_transform","KHR_draco_mesh_compression"],this._baseUri=F(this.uri).dirPart,this._checkVersionSupported(),this._checkRequiredExtensionsSupported(),null==o.scenes)throw new e("gltf-loader-unsupported-feature","Scenes must be defined.");if(null==o.meshes)throw new e("gltf-loader-unsupported-feature","Meshes must be defined");if(null==o.nodes)throw new e("gltf-loader-unsupported-feature","Nodes must be defined.");this._computeNodeParents()}static async load(t,r,o){if(s(r)){const e=a(r);if(e&&"model/gltf-binary"!==e.mediaType)try{const o=JSON.parse(e.isBase64?atob(e.data):e.data);return new Y(t,r,o)}catch{}const o=i(r);if(Y._isGLBData(o))return this._fromGLBData(t,r,o)}if(te.test(r)||"gltf"===o?.expectedType){const e=await t.loadJSON(r,o);return new Y(t,r,e)}const n=await t.loadBinary(r,o);if(Y._isGLBData(n))return this._fromGLBData(t,r,n);if(re.test(r)||"glb"===o?.expectedType)throw new e("gltf-loader-invalid-glb","This is not a valid glb file.");const u=await t.loadJSON(r,o);return new Y(t,r,u)}static _isGLBData(e){if(null==e)return!1;const t=new M(e);return t.remainingBytes()>=4&&t.readUint32()===k.MAGIC}static async _fromGLBData(e,t,r){const o=await Y._parseGLBData(r);return new Y(e,t,o.json,o.binaryData)}static async _parseGLBData(r){const o=new M(r);if(o.remainingBytes()<12)throw new e("gltf-loader-error","glb binary data is insufficiently large.");const n=o.readUint32(),s=o.readUint32(),a=o.readUint32();if(n!==k.MAGIC)throw new e("gltf-loader-error","Magic first 4 bytes do not fit to expected glb value.");if(r.byteLength<a)throw new e("gltf-loader-error","glb binary data is smaller than header specifies.");if(2!==s)throw new e("gltf-loader-unsupported-feature","An unsupported glb container version was detected. Only version 2 is supported.");let i,u,f=0;for(;o.remainingBytes()>=8;){const r=o.readUint32(),n=o.readUint32();if(0===f){if(n!==k.CHUNK_TYPE_JSON)throw new e("gltf-loader-error","First glb chunk must be JSON.");if(r<0)throw new e("gltf-loader-error","No JSON data found.");i=await H(o.readUint8Array(r))}else if(1===f){if(n!==k.CHUNK_TYPE_BIN)throw new e("gltf-loader-unsupported-feature","Second glb chunk expected to be BIN.");u=o.readUint8Array(r)}else t.getLogger("esri.views.3d.glTF").warn("[Unsupported Feature] More than 2 glb chunks detected. Skipping.");f+=1}if(!i)throw new e("gltf-loader-error","No glb JSON chunk detected.");return{json:i,binaryData:u}}async getBuffer(t,r){const o=this.json.buffers[t];if(null==o.uri){if(null==this._glbBuffer)throw new e("gltf-loader-error","glb buffer not present");return this._glbBuffer}const n=await this._getBufferLoader(t,r);if(n.byteLength!==o.byteLength)throw new e("gltf-loader-error","Buffer byte lengths should match.");return n}async _getBufferLoader(e,t){const r=this._bufferLoaders.get(e);if(r)return r;const o=this.json.buffers[e].uri,n=this._context.loadBinary(this._resolveUri(o),t).then(e=>new Uint8Array(e));return this._bufferLoaders.set(e,n),n}_validateAccessor(t){if(!this.json.accessors)throw new e("gltf-loader-unsupported-feature","Accessors missing.");const r=this.json.accessors[t];if(r.type in["MAT2","MAT3","MAT4"])throw new e("gltf-loader-unsupported-feature",`AttributeType ${r.type} is not supported`);return r}_getComponentInfo(e){const t=$[e.type],r=W[e.componentType];return{componentCount:t,componentByteSize:r,denseByteStride:t*r}}getDracoAccessor(e,t,r=!1){const o=this._validateAccessor(e),{componentCount:n,componentByteSize:s,denseByteStride:a}=this._getComponentInfo(o),i=t.offsets.get(e);return{raw:t.buffer.buffer,byteStride:a,byteOffset:t.buffer.byteOffset+(i||0),entryCount:o.count,isDenselyPacked:!0,componentCount:n,componentByteSize:s,componentType:r?t.indexComponentType:o.componentType,min:o.min,max:o.max,normalized:!!o.normalized}}async getAccessor(t,r){const o=this._validateAccessor(t);if(null==o?.bufferView)throw new e("gltf-loader-unsupported-feature","Some accessor does not specify a bufferView.");const{componentCount:n,componentByteSize:s,denseByteStride:a}=this._getComponentInfo(o),i=this.json.bufferViews[o.bufferView],u=await this.getBuffer(i.buffer,r),f=i.byteStride||a;return{raw:u.buffer,byteStride:f,byteOffset:u.byteOffset+(i.byteOffset||0)+(o.byteOffset||0),entryCount:o.count,isDenselyPacked:f===a,componentCount:n,componentByteSize:s,componentType:o.componentType,min:o.min,max:o.max,normalized:!!o.normalized}}async getIndexData(e,t,r){if(null==e.indices)return;const o=e.indices,n=r?this.getDracoAccessor(o,r,!0):await this.getAccessor(o,t);if(n.isDenselyPacked)switch(n.componentType){case K.UNSIGNED_BYTE:return new Uint8Array(n.raw,n.byteOffset,n.entryCount);case K.UNSIGNED_SHORT:return new Uint16Array(n.raw,n.byteOffset,n.entryCount);case K.UNSIGNED_INT:return new Uint32Array(n.raw,n.byteOffset,n.entryCount)}else switch(n.componentType){case K.UNSIGNED_BYTE:return B(Z(A,n));case K.UNSIGNED_SHORT:return B(Z(C,n));case K.UNSIGNED_INT:return B(Z(S,n))}}async getPositionData(t,r,n){if(null==t.attributes.POSITION)throw new e("gltf-loader-unsupported-feature","No POSITION vertex data found.");const s=t.attributes.POSITION,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(a.componentType!==K.FLOAT)throw new e("gltf-loader-unsupported-feature","Expected type FLOAT for POSITION vertex attribute, but found "+o(K,a.componentType));if(3!==a.componentCount)throw new e("gltf-loader-unsupported-feature","POSITION vertex attribute must have 3 components, but found "+a.componentCount.toFixed());return Z(L,a)}async getNormalData(t,r,n){if(null==t.attributes.NORMAL)throw new e("gltf-loader-error","No NORMAL vertex data found.");const s=t.attributes.NORMAL,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(a.componentType!==K.FLOAT)throw new e("gltf-loader-unsupported-feature","Expected type FLOAT for NORMAL vertex attribute, but found "+o(K,a.componentType));if(3!==a.componentCount)throw new e("gltf-loader-unsupported-feature","NORMAL vertex attribute must have 3 components, but found "+a.componentCount.toFixed());return Z(L,a)}async getTangentData(t,r,n){if(null==t.attributes.TANGENT)throw new e("gltf-loader-error","No TANGENT vertex data found.");const s=t.attributes.TANGENT,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(a.componentType!==K.FLOAT)throw new e("gltf-loader-unsupported-feature","Expected type FLOAT for TANGENT vertex attribute, but found "+o(K,a.componentType));if(4!==a.componentCount)throw new e("gltf-loader-unsupported-feature","TANGENT vertex attribute must have 4 components, but found "+a.componentCount.toFixed());return Z(E,a)}async getTextureCoordinates(t,r,o){if(null==t.attributes.TEXCOORD_0)throw new e("gltf-loader-error","No TEXCOORD_0 vertex data found.");const n=t.attributes.TEXCOORD_0,s=o?this.getDracoAccessor(n,o):await this.getAccessor(n,r);if(2!==s.componentCount)throw new e("gltf-loader-unsupported-feature","TEXCOORD_0 vertex attribute must have 2 components, but found "+s.componentCount.toFixed());if(s.componentType===K.FLOAT)return Z(g,s);if(!s.normalized)throw new e("gltf-loader-unsupported-feature","Integer component types are only supported for a normalized accessor for TEXCOORD_0.");return Q(s)}async getVertexColors(t,r,n){if(null==t.attributes.COLOR_0)throw new e("gltf-loader-error","No COLOR_0 vertex data found.");const s=t.attributes.COLOR_0,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(4!==a.componentCount&&3!==a.componentCount)throw new e("gltf-loader-unsupported-feature","COLOR_0 attribute must have 3 or 4 components, but found "+a.componentCount.toFixed());if(4===a.componentCount){if(a.componentType===K.FLOAT)return Z(E,a);if(a.componentType===K.UNSIGNED_BYTE)return Z(R,a);if(a.componentType===K.UNSIGNED_SHORT)return Z(v,a)}else if(3===a.componentCount){if(a.componentType===K.FLOAT)return Z(L,a);if(a.componentType===K.UNSIGNED_BYTE)return Z(I,a);if(a.componentType===K.UNSIGNED_SHORT)return Z(D,a)}throw new e("gltf-loader-unsupported-feature","Unsupported component type for COLOR_0 attribute: "+o(K,a.componentType))}hasPositions(e){return void 0!==e.attributes.POSITION}hasNormals(e){return void 0!==e.attributes.NORMAL}hasVertexColors(e){return void 0!==e.attributes.COLOR_0}hasTextureCoordinates(e){return void 0!==e.attributes.TEXCOORD_0}hasTangents(e){return void 0!==e.attributes.TANGENT}async getMaterial(e,t,r){let o=e.material?this._materialCache.get(e.material):void 0;if(!o){const n=null!=e.material?j(this.json.materials[e.material]):j(),s=n.pbrMetallicRoughness,a=this.hasVertexColors(e),i=this.getTexture(s.baseColorTexture,t),u=this.getTexture(n.normalTexture,t),f=r?this.getTexture(n.occlusionTexture,t):void 0,c=r?this.getTexture(n.emissiveTexture,t):void 0,d=r?this.getTexture(s.metallicRoughnessTexture,t):void 0,l=null!=e.material?e.material:-1;o={alphaMode:n.alphaMode,alphaCutoff:n.alphaCutoff,color:s.baseColorFactor,doubleSided:!!n.doubleSided,colorTexture:await i,normalTexture:await u,name:n.name,id:l,occlusionTexture:await f,emissiveTexture:await c,emissiveFactor:n.emissiveFactor,metallicFactor:s.metallicFactor,roughnessFactor:s.roughnessFactor,metallicRoughnessTexture:await d,hasVertexColors:a,ESRI_externalColorMixMode:n.extras.ESRI_externalColorMixMode,colorTextureTransform:s?.baseColorTexture?.extensions?.KHR_texture_transform,normalTextureTransform:n.normalTexture?.extensions?.KHR_texture_transform,occlusionTextureTransform:n.occlusionTexture?.extensions?.KHR_texture_transform,emissiveTextureTransform:n.emissiveTexture?.extensions?.KHR_texture_transform,metallicRoughnessTextureTransform:s?.metallicRoughnessTexture?.extensions?.KHR_texture_transform,receiveAmbientOcclusion:n.extras.ESRI_receiveAmbientOcclusion,receiveShadows:n.extras.ESRI_receiveShadows}}return o}async decode(t,r){const o=t.extensions?.KHR_draco_mesh_compression;if(!o)return;if(null==t.indices)throw new e("gltf-loader-error","Found Draco compressed primitive without indices.");const n=this.json.bufferViews[o.bufferView],s=await this.getBuffer(n.buffer,r),a=(await U()).decode(new Uint8Array(s.buffer,n.byteOffset,n.byteLength));this._bufferLoaders.delete(n.buffer);const i=new Map([[t.indices,a.indexOffset],[t.attributes.POSITION,a.positionOffset]]);return t.attributes.TEXCOORD_0&&i.set(t.attributes.TEXCOORD_0,a.uvOffset),t.attributes.NORMAL&&i.set(t.attributes.NORMAL,a.normalOffset),t.attributes.COLOR_0&&i.set(t.attributes.COLOR_0,a.colorOffset),t.attributes.TANGENT&&i.set(t.attributes.TANGENT,a.tangentOffset),this._dracoBuffersSize+=a.buffer.byteLength,{buffer:a.buffer,indexComponentType:a.indexComponentType,offsets:i}}async getTexture(t,o){if(!t)return;if(0!==(t.texCoord||0))throw new e("gltf-loader-unsupported-feature","Only TEXCOORD with index 0 is supported.");const n=t.index,s=this.json.textures[n],a=G(null!=s.sampler?this.json.samplers[s.sampler]:{}),i=ee(s),u=this.json.images[i],f=await this._loadTextureImageData(n,s,o);return r(this._textureCache,n,()=>{const t=e=>33071===e||33648===e||10497===e,r=t=>{throw new e("gltf-loader-error",`Unexpected TextureSampler WrapMode: ${t}`)};return{data:f,wrapS:t(a.wrapS)?a.wrapS:r(a.wrapS),wrapT:t(a.wrapT)?a.wrapT:r(a.wrapT),minFilter:a.minFilter,name:u.name,id:n}})}getNodeTransform(e){if(void 0===e)return X;let t=this._nodeTransformCache.get(e);if(!t){const r=this.getNodeTransform(this._getNodeParent(e)),o=this.json.nodes[e];o.matrix?t=d(h(),r,o.matrix):o.translation||o.rotation||o.scale?(t=b(r),o.translation&&l(t,t,o.translation),o.rotation&&(J[3]=w(J,o.rotation),p(t,t,J[3],J)),o.scale&&m(t,t,o.scale)):t=b(r),this._nodeTransformCache.set(e,t)}return t}_resolveUri(e){return u(e,this._baseUri)}_getNodeParent(e){return this._nodeParentMap.get(e)}_checkVersionSupported(){const e=f.parse(this.json.asset.version,"glTF");q.validate(e)}_checkRequiredExtensionsSupported(){const t=this.json;if(t.extensionsRequired){if(!t.extensionsRequired.every(e=>this._supportedExtensions.includes(e)))throw new e("gltf-loader-unsupported-feature","gltf loader was not able to load unsupported feature. Required extensions: "+t.extensionsRequired.join(", "))}}_computeNodeParents(){this.json.nodes.forEach((e,t)=>{e.children&&e.children.forEach(e=>{this._nodeParentMap.set(e,t)})})}async _loadTextureImageData(e,t,r){const o=this._textureLoaders.get(e);if(o)return o;const n=this._createTextureLoader(t,r);return this._textureLoaders.set(e,n),n}async _createTextureLoader(t,r){const o=ee(t),n=this.json.images[o];if(n.uri){if(n.uri.endsWith(".ktx2")){const e=await this._context.loadBinary(this._resolveUri(n.uri),r);return new P(new Uint8Array(e))}return this._context.loadImage(this._resolveUri(n.uri),r)}if(null==n.bufferView)throw new e("gltf-loader-unsupported-feature","Image bufferView must be defined.");if(null==n.mimeType)throw new e("gltf-loader-unsupported-feature","Image mimeType must be defined.");const s=this.json.bufferViews[n.bufferView],a=await this.getBuffer(s.buffer,r);if(null!=s.byteStride)throw new e("gltf-loader-unsupported-feature","byteStride not supported for image buffer");const i=a.byteOffset+(s.byteOffset||0);return V(new Uint8Array(a.buffer,i,s.byteLength),n.mimeType)}async getLoadedBuffersSize(){if(this._glbBuffer)return this._glbBuffer.byteLength;const e=await n(Array.from(this._bufferLoaders.values())),t=await n(Array.from(this._textureLoaders.values()));return e.reduce((e,t)=>e+(t?.byteLength??0),0)+this._dracoBuffersSize+t.reduce((e,t)=>e+(t?z(t)?t.data.byteLength:t.width*t.height*4:0),0)}}const X=c(h(),Math.PI/2),q=new f(2,0,"glTF"),J=y(),$={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},W={[K.BYTE]:1,[K.UNSIGNED_BYTE]:1,[K.SHORT]:2,[K.UNSIGNED_SHORT]:2,[K.HALF_FLOAT]:2,[K.FLOAT]:4,[K.INT]:4,[K.UNSIGNED_INT]:4};function Q(e){switch(e.componentType){case K.BYTE:return new N(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.UNSIGNED_BYTE:return new O(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.SHORT:return new x(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.UNSIGNED_SHORT:return new _(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.UNSIGNED_INT:return new T(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.FLOAT:return new g(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount)}}function Z(e,t){return new e(t.raw,t.byteOffset,t.byteStride,t.byteOffset+t.byteStride*(t.entryCount-1)+t.componentByteSize*t.componentCount)}function ee(t){if(null!=t.extensions?.KHR_texture_basisu)return t.extensions.KHR_texture_basisu.source;if(null!==t.source)return t.source;throw new e("gltf-loader-unsupported-feature","Source is expected to be defined for a texture. It can also be omitted in favour of an KHR_texture_basisu extension tag.")}const te=/\.gltf$/i,re=/\.glb$/i;export{Y as GLTFResource,X as transformGltfToEngine};
|
|
5
|
+
import e from"../../../../core/Error.js";import t from"../../../../core/Logger.js";import{getOrCreateMapValue as r}from"../../../../core/MapUtils.js";import{getKey as o}from"../../../../core/object.js";import{allSettledValues as n}from"../../../../core/promiseUtils.js";import{isDataProtocol as s,dataComponents as a,dataToArrayBuffer as i,makeAbsolute as u}from"../../../../core/urlUtils.js";import{Version as f}from"../../../../core/Version.js";import{fromXRotation as c,multiply as d,translate as l,rotate as p,scale as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as h,clone as b}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{getAxisAngle as w}from"../../../../core/libs/gl-matrix-2/math/quat.js";import{create as y}from"../../../../core/libs/gl-matrix-2/factories/quatf64.js";import{BufferViewVec2f as g,BufferViewVec2u32 as T,BufferViewVec2u16 as _,BufferViewVec2i16 as x,BufferViewVec2u8 as O,BufferViewVec2i8 as N,BufferViewUint32 as S,BufferViewUint16 as C,BufferViewUint8 as A,BufferViewVec3f as L,BufferViewVec4f as E,BufferViewVec4u8 as R,BufferViewVec4u16 as I,BufferViewVec3u8 as v,BufferViewVec3u16 as D}from"../../../../geometry/support/buffer/BufferView.js";import{m as B}from"../../../../chunks/scalar.js";import"../../../../core/has.js";import{getDracoMeshDecoder as U}from"../../../../libs/dracoMeshDecoder/dracoMeshDecoder.js";import{BinaryStreamReader as M}from"./BinaryStreamReader.js";import{material as j,textureSampler as G}from"./fillDefaults.js";import{splitURI as F}from"./pathUtils.js";import{jsonFromBinaryData as H,EncodedMeshTexture as P,imageFromBinaryData as V,isEncodedMeshTexture as z}from"./resourceUtils.js";import{DataType as K}from"../../../webgl/enums.js";const k={MAGIC:1179937895,CHUNK_TYPE_JSON:1313821514,CHUNK_TYPE_BIN:5130562};class Y{constructor(t,r,o,n){if(this._context=t,this.uri=r,this.json=o,this._glbBuffer=n,this._bufferLoaders=new Map,this._textureLoaders=new Map,this._dracoBuffersSize=0,this._textureCache=new Map,this._materialCache=new Map,this._nodeParentMap=new Map,this._nodeTransformCache=new Map,this._supportedExtensions=["KHR_texture_basisu","KHR_texture_transform","KHR_draco_mesh_compression"],this._baseUri=F(this.uri).dirPart,this._checkVersionSupported(),this._checkRequiredExtensionsSupported(),null==o.scenes)throw new e("gltf-loader-unsupported-feature","Scenes must be defined.");if(null==o.meshes)throw new e("gltf-loader-unsupported-feature","Meshes must be defined");if(null==o.nodes)throw new e("gltf-loader-unsupported-feature","Nodes must be defined.");this._computeNodeParents()}static async load(t,r,o){if(s(r)){const e=a(r);if(e&&"model/gltf-binary"!==e.mediaType)try{const o=JSON.parse(e.isBase64?atob(e.data):e.data);return new Y(t,r,o)}catch{}const o=i(r);if(Y._isGLBData(o))return this._fromGLBData(t,r,o)}if(te.test(r)||"gltf"===o?.expectedType){const e=await t.loadJSON(r,o);return new Y(t,r,e)}const n=await t.loadBinary(r,o);if(Y._isGLBData(n))return this._fromGLBData(t,r,n);if(re.test(r)||"glb"===o?.expectedType)throw new e("gltf-loader-invalid-glb","This is not a valid glb file.");const u=await t.loadJSON(r,o);return new Y(t,r,u)}static _isGLBData(e){if(null==e)return!1;const t=new M(e);return t.remainingBytes()>=4&&t.readUint32()===k.MAGIC}static async _fromGLBData(e,t,r){const o=await Y._parseGLBData(r);return new Y(e,t,o.json,o.binaryData)}static async _parseGLBData(r){const o=new M(r);if(o.remainingBytes()<12)throw new e("gltf-loader-error","glb binary data is insufficiently large.");const n=o.readUint32(),s=o.readUint32(),a=o.readUint32();if(n!==k.MAGIC)throw new e("gltf-loader-error","Magic first 4 bytes do not fit to expected glb value.");if(r.byteLength<a)throw new e("gltf-loader-error","glb binary data is smaller than header specifies.");if(2!==s)throw new e("gltf-loader-unsupported-feature","An unsupported glb container version was detected. Only version 2 is supported.");let i,u,f=0;for(;o.remainingBytes()>=8;){const r=o.readUint32(),n=o.readUint32();if(0===f){if(n!==k.CHUNK_TYPE_JSON)throw new e("gltf-loader-error","First glb chunk must be JSON.");if(r<0)throw new e("gltf-loader-error","No JSON data found.");i=await H(o.readUint8Array(r))}else if(1===f){if(n!==k.CHUNK_TYPE_BIN)throw new e("gltf-loader-unsupported-feature","Second glb chunk expected to be BIN.");u=o.readUint8Array(r)}else t.getLogger("esri.views.3d.glTF").warn("[Unsupported Feature] More than 2 glb chunks detected. Skipping.");f+=1}if(!i)throw new e("gltf-loader-error","No glb JSON chunk detected.");return{json:i,binaryData:u}}async getBuffer(t,r){const o=this.json.buffers[t];if(null==o.uri){if(null==this._glbBuffer)throw new e("gltf-loader-error","glb buffer not present");return this._glbBuffer}const n=await this._getBufferLoader(t,r);if(n.byteLength!==o.byteLength)throw new e("gltf-loader-error","Buffer byte lengths should match.");return n}async _getBufferLoader(e,t){const r=this._bufferLoaders.get(e);if(r)return r;const o=this.json.buffers[e].uri,n=this._context.loadBinary(this._resolveUri(o),t).then(e=>new Uint8Array(e));return this._bufferLoaders.set(e,n),n}_validateAccessor(t){if(!this.json.accessors)throw new e("gltf-loader-unsupported-feature","Accessors missing.");const r=this.json.accessors[t];if(r.type in["MAT2","MAT3","MAT4"])throw new e("gltf-loader-unsupported-feature",`AttributeType ${r.type} is not supported`);return r}_getComponentInfo(e,t){const r=$[e.type],o=t?.componentType||e.componentType,n=W[o];return{componentType:o,componentCount:r,componentByteSize:n,denseByteStride:r*n}}getDracoAccessor(e,t){const r=this._validateAccessor(e),o=t.accessorInfos.get(e),{componentType:n,componentCount:s,componentByteSize:a,denseByteStride:i}=this._getComponentInfo(r,o);return{raw:t.data.buffer,byteStride:i,byteOffset:t.data.byteOffset+(o?.byteOffset||0),entryCount:o?.count??r.count,isDenselyPacked:!0,componentCount:s,componentByteSize:a,componentType:n,min:r.min,max:r.max,normalized:!!r.normalized}}async getAccessor(t,r){const o=this._validateAccessor(t);if(null==o?.bufferView)throw new e("gltf-loader-unsupported-feature","Some accessor does not specify a bufferView.");const{componentCount:n,componentByteSize:s,denseByteStride:a}=this._getComponentInfo(o),i=this.json.bufferViews[o.bufferView],u=await this.getBuffer(i.buffer,r),f=i.byteStride||a;return{raw:u.buffer,byteStride:f,byteOffset:u.byteOffset+(i.byteOffset||0)+(o.byteOffset||0),entryCount:o.count,isDenselyPacked:f===a,componentCount:n,componentByteSize:s,componentType:o.componentType,min:o.min,max:o.max,normalized:!!o.normalized}}async getIndexData(e,t,r){if(null==e.indices)return;const o=e.indices,n=r?this.getDracoAccessor(o,r):await this.getAccessor(o,t);if(n.isDenselyPacked)switch(n.componentType){case K.UNSIGNED_BYTE:return new Uint8Array(n.raw,n.byteOffset,n.entryCount);case K.UNSIGNED_SHORT:return new Uint16Array(n.raw,n.byteOffset,n.entryCount);case K.UNSIGNED_INT:return new Uint32Array(n.raw,n.byteOffset,n.entryCount)}else switch(n.componentType){case K.UNSIGNED_BYTE:return B(Z(A,n));case K.UNSIGNED_SHORT:return B(Z(C,n));case K.UNSIGNED_INT:return B(Z(S,n))}}async getPositionData(t,r,n){if(null==t.attributes.POSITION)throw new e("gltf-loader-unsupported-feature","No POSITION vertex data found.");const s=t.attributes.POSITION,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(a.componentType!==K.FLOAT)throw new e("gltf-loader-unsupported-feature","Expected type FLOAT for POSITION vertex attribute, but found "+o(K,a.componentType));if(3!==a.componentCount)throw new e("gltf-loader-unsupported-feature","POSITION vertex attribute must have 3 components, but found "+a.componentCount.toFixed());return Z(L,a)}async getNormalData(t,r,n){if(null==t.attributes.NORMAL)throw new e("gltf-loader-error","No NORMAL vertex data found.");const s=t.attributes.NORMAL,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(a.componentType!==K.FLOAT)throw new e("gltf-loader-unsupported-feature","Expected type FLOAT for NORMAL vertex attribute, but found "+o(K,a.componentType));if(3!==a.componentCount)throw new e("gltf-loader-unsupported-feature","NORMAL vertex attribute must have 3 components, but found "+a.componentCount.toFixed());return Z(L,a)}async getTangentData(t,r,n){if(null==t.attributes.TANGENT)throw new e("gltf-loader-error","No TANGENT vertex data found.");const s=t.attributes.TANGENT,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(a.componentType!==K.FLOAT)throw new e("gltf-loader-unsupported-feature","Expected type FLOAT for TANGENT vertex attribute, but found "+o(K,a.componentType));if(4!==a.componentCount)throw new e("gltf-loader-unsupported-feature","TANGENT vertex attribute must have 4 components, but found "+a.componentCount.toFixed());return Z(E,a)}async getTextureCoordinates(t,r,o){if(null==t.attributes.TEXCOORD_0)throw new e("gltf-loader-error","No TEXCOORD_0 vertex data found.");const n=t.attributes.TEXCOORD_0,s=o?this.getDracoAccessor(n,o):await this.getAccessor(n,r);if(2!==s.componentCount)throw new e("gltf-loader-unsupported-feature","TEXCOORD_0 vertex attribute must have 2 components, but found "+s.componentCount.toFixed());if(s.componentType===K.FLOAT)return Z(g,s);if(!s.normalized)throw new e("gltf-loader-unsupported-feature","Integer component types are only supported for a normalized accessor for TEXCOORD_0.");return Q(s)}async getVertexColors(t,r,n){if(null==t.attributes.COLOR_0)throw new e("gltf-loader-error","No COLOR_0 vertex data found.");const s=t.attributes.COLOR_0,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(4!==a.componentCount&&3!==a.componentCount)throw new e("gltf-loader-unsupported-feature","COLOR_0 attribute must have 3 or 4 components, but found "+a.componentCount.toFixed());if(4===a.componentCount){if(a.componentType===K.FLOAT)return Z(E,a);if(a.componentType===K.UNSIGNED_BYTE)return Z(R,a);if(a.componentType===K.UNSIGNED_SHORT)return Z(I,a)}else if(3===a.componentCount){if(a.componentType===K.FLOAT)return Z(L,a);if(a.componentType===K.UNSIGNED_BYTE)return Z(v,a);if(a.componentType===K.UNSIGNED_SHORT)return Z(D,a)}throw new e("gltf-loader-unsupported-feature","Unsupported component type for COLOR_0 attribute: "+o(K,a.componentType))}hasPositions(e){return void 0!==e.attributes.POSITION}hasNormals(e){return void 0!==e.attributes.NORMAL}hasVertexColors(e){return void 0!==e.attributes.COLOR_0}hasTextureCoordinates(e){return void 0!==e.attributes.TEXCOORD_0}hasTangents(e){return void 0!==e.attributes.TANGENT}async getMaterial(e,t,r){let o=e.material?this._materialCache.get(e.material):void 0;if(!o){const n=null!=e.material?j(this.json.materials[e.material]):j(),s=n.pbrMetallicRoughness,a=this.hasVertexColors(e),i=this.getTexture(s.baseColorTexture,t),u=this.getTexture(n.normalTexture,t),f=r?this.getTexture(n.occlusionTexture,t):void 0,c=r?this.getTexture(n.emissiveTexture,t):void 0,d=r?this.getTexture(s.metallicRoughnessTexture,t):void 0,l=null!=e.material?e.material:-1;o={alphaMode:n.alphaMode,alphaCutoff:n.alphaCutoff,color:s.baseColorFactor,doubleSided:!!n.doubleSided,colorTexture:await i,normalTexture:await u,name:n.name,id:l,occlusionTexture:await f,emissiveTexture:await c,emissiveFactor:n.emissiveFactor,metallicFactor:s.metallicFactor,roughnessFactor:s.roughnessFactor,metallicRoughnessTexture:await d,hasVertexColors:a,ESRI_externalColorMixMode:n.extras.ESRI_externalColorMixMode,colorTextureTransform:s?.baseColorTexture?.extensions?.KHR_texture_transform,normalTextureTransform:n.normalTexture?.extensions?.KHR_texture_transform,occlusionTextureTransform:n.occlusionTexture?.extensions?.KHR_texture_transform,emissiveTextureTransform:n.emissiveTexture?.extensions?.KHR_texture_transform,metallicRoughnessTextureTransform:s?.metallicRoughnessTexture?.extensions?.KHR_texture_transform,receiveAmbientOcclusion:n.extras.ESRI_receiveAmbientOcclusion,receiveShadows:n.extras.ESRI_receiveShadows}}return o}async decode(t,r){const o=t.extensions?.KHR_draco_mesh_compression;if(!o)return;if(null==t.indices)throw new e("gltf-loader-error","Found Draco compressed primitive without indices.");const n=this.json.bufferViews[o.bufferView],s=await this.getBuffer(n.buffer,r),a=(await U()).decode(new Uint8Array(s.buffer,n.byteOffset,n.byteLength));this._bufferLoaders.delete(n.buffer);const i=new Map([[t.indices,a.indices],[t.attributes.POSITION,a.positions]]);return t.attributes.TEXCOORD_0&&i.set(t.attributes.TEXCOORD_0,a.uvs),t.attributes.NORMAL&&i.set(t.attributes.NORMAL,a.normals),t.attributes.COLOR_0&&i.set(t.attributes.COLOR_0,a.colors),t.attributes.TANGENT&&i.set(t.attributes.TANGENT,a.tangents),this._dracoBuffersSize+=a.buffer.byteLength,{data:a.buffer,accessorInfos:i}}async getTexture(t,o){if(!t)return;if(0!==(t.texCoord||0))throw new e("gltf-loader-unsupported-feature","Only TEXCOORD with index 0 is supported.");const n=t.index,s=this.json.textures[n],a=G(null!=s.sampler?this.json.samplers[s.sampler]:{}),i=ee(s),u=this.json.images[i],f=await this._loadTextureImageData(n,s,o);return r(this._textureCache,n,()=>{const t=e=>33071===e||33648===e||10497===e,r=t=>{throw new e("gltf-loader-error",`Unexpected TextureSampler WrapMode: ${t}`)};return{data:f,wrapS:t(a.wrapS)?a.wrapS:r(a.wrapS),wrapT:t(a.wrapT)?a.wrapT:r(a.wrapT),minFilter:a.minFilter,name:u.name,id:n}})}getNodeTransform(e){if(void 0===e)return X;let t=this._nodeTransformCache.get(e);if(!t){const r=this.getNodeTransform(this._getNodeParent(e)),o=this.json.nodes[e];o.matrix?t=d(h(),r,o.matrix):o.translation||o.rotation||o.scale?(t=b(r),o.translation&&l(t,t,o.translation),o.rotation&&(J[3]=w(J,o.rotation),p(t,t,J[3],J)),o.scale&&m(t,t,o.scale)):t=b(r),this._nodeTransformCache.set(e,t)}return t}_resolveUri(e){return u(e,this._baseUri)}_getNodeParent(e){return this._nodeParentMap.get(e)}_checkVersionSupported(){const e=f.parse(this.json.asset.version,"glTF");q.validate(e)}_checkRequiredExtensionsSupported(){const t=this.json;if(t.extensionsRequired){if(!t.extensionsRequired.every(e=>this._supportedExtensions.includes(e)))throw new e("gltf-loader-unsupported-feature","gltf loader was not able to load unsupported feature. Required extensions: "+t.extensionsRequired.join(", "))}}_computeNodeParents(){this.json.nodes.forEach((e,t)=>{e.children&&e.children.forEach(e=>{this._nodeParentMap.set(e,t)})})}async _loadTextureImageData(e,t,r){const o=this._textureLoaders.get(e);if(o)return o;const n=this._createTextureLoader(t,r);return this._textureLoaders.set(e,n),n}async _createTextureLoader(t,r){const o=ee(t),n=this.json.images[o];if(n.uri){if(n.uri.endsWith(".ktx2")){const e=await this._context.loadBinary(this._resolveUri(n.uri),r);return new P(new Uint8Array(e))}return this._context.loadImage(this._resolveUri(n.uri),r)}if(null==n.bufferView)throw new e("gltf-loader-unsupported-feature","Image bufferView must be defined.");if(null==n.mimeType)throw new e("gltf-loader-unsupported-feature","Image mimeType must be defined.");const s=this.json.bufferViews[n.bufferView],a=await this.getBuffer(s.buffer,r);if(null!=s.byteStride)throw new e("gltf-loader-unsupported-feature","byteStride not supported for image buffer");const i=a.byteOffset+(s.byteOffset||0);return V(new Uint8Array(a.buffer,i,s.byteLength),n.mimeType)}async getLoadedBuffersSize(){if(this._glbBuffer)return this._glbBuffer.byteLength;const e=await n(Array.from(this._bufferLoaders.values())),t=await n(Array.from(this._textureLoaders.values()));return e.reduce((e,t)=>e+(t?.byteLength??0),0)+this._dracoBuffersSize+t.reduce((e,t)=>e+(t?z(t)?t.data.byteLength:t.width*t.height*4:0),0)}}const X=c(h(),Math.PI/2),q=new f(2,0,"glTF"),J=y(),$={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},W={[K.BYTE]:1,[K.UNSIGNED_BYTE]:1,[K.SHORT]:2,[K.UNSIGNED_SHORT]:2,[K.HALF_FLOAT]:2,[K.FLOAT]:4,[K.INT]:4,[K.UNSIGNED_INT]:4};function Q(e){switch(e.componentType){case K.BYTE:return new N(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.UNSIGNED_BYTE:return new O(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.SHORT:return new x(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.UNSIGNED_SHORT:return new _(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.UNSIGNED_INT:return new T(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.FLOAT:return new g(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount)}}function Z(e,t){return new e(t.raw,t.byteOffset,t.byteStride,t.byteOffset+t.byteStride*(t.entryCount-1)+t.componentByteSize*t.componentCount)}function ee(t){if(null!=t.extensions?.KHR_texture_basisu)return t.extensions.KHR_texture_basisu.source;if(null!==t.source)return t.source;throw new e("gltf-loader-unsupported-feature","Source is expected to be defined for a texture. It can also be omitted in favour of an KHR_texture_basisu extension tag.")}const te=/\.gltf$/i,re=/\.glb$/i;export{Y as GLTFResource,X as transformGltfToEngine};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i}from"../../../core/maybe.js";import{initial as s,watch as r,when as o}from"../../../core/reactiveUtils.js";import{schedule as a}from"../../../core/scheduling.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as c,invert as d}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m,IDENTITY as h}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as u}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as p}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{f,o as g}from"../../../chunks/vec32.js";import{fromArray as y,clone as b,create as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as w}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as v}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as j}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as x}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as C}from"../../../geometry/projection/projectVectorToVector.js";import{create as M}from"../../../geometry/support/aaBoundingRect.js";import{BufferViewVec2f as T,BufferViewVec4f as O,BufferViewVec4u8 as U,BufferViewVec4u16 as P,BufferViewVec3f as H,BufferViewVec3u8 as E,BufferViewVec3u16 as S,BufferViewInt16 as F,BufferViewUint32 as R,BufferViewUint16 as A}from"../../../geometry/support/buffer/BufferView.js";import k from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as V}from"../../../support/elevationInfoUtils.js";import{toWasmModification as I}from"./I3SMeshWorkerHandle.js";import{LayerView3D as D}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as L}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as B,removeLayerViewFromWasm as G,getLyr3DWasm as z}from"./Lyr3DWasm.js";import{LayerElevationProvider as N}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as W,alphaModeConversion as $,faceCullingConversion as J,wrapModeConversion as q,lyr3DTypeToByteSize as K}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as Q}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as X}from"../support/ElevationRange.js";import{toBoundingRect as Y}from"../support/extentUtils.js";import{Obb as Z,compute as ee}from"../support/orientedBoundingBox.js";import{ObjectParameters as te}from"../webgl-engine/collections/Component/ObjectParameters.js";import{GeometryParameters as ie,createVertexBufferLayout as se}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as re}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as oe}from"../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as ae}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as ne}from"../webgl-engine/lib/Attribute.js";import{compressAndTransformNormals as le}from"../webgl-engine/lib/Normals.js";import{Texture as ce}from"../webgl-engine/lib/Texture.js";import{writeAttribute as de,writeBufferVec2 as me}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import he from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as ue,isInEffectiveScaleRange as pe}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as fe}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as ge}from"../../../webscene/support/AlphaCutoff.js";class ye{constructor(e,t,i,s,r,o){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=s,this.vboMemoryUsage=r,this.textureMemoryUsage=o,this.isVisible=!1,this.usedMemory=this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}}function be(e){return Math.round(e/1048.576)/1e3}let _e=class extends(D(he)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new fe,this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._initialCullFace=new Map,this._suspendedHandle=null,this._dbgFlags=new Set,this._memCache=e.view.resourceController.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e))}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),s),!this._canProjectWithoutEngine())throw ue("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=B(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new Q(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),s),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),s),this._elevationProvider=new N({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),e.elevationProvider.register(1,this._elevationProvider),e.basemapTerrain.overlayManager.registerDrapeTarget(this),this.addHandles([r(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e))]),this._suspendedHandle=r(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),s)});this.addResolvingPromise(t),this._replacesTerrain&&this.addHandles(o(()=>this.view.map.ground.opacity,()=>{this._opacityChange()}))}get _replacesTerrain(){return this.layer.replacesTerrain&&!!this.view.map.basemap?.groundLayers.includes(this.layer)}get opacity(){return this.fullOpacity*(this._replacesTerrain?this.view.map.ground.opacity:1)}_opacityChange(){const{opacity:e}=this;this.forEachComponentObject(t=>{this._collection.getMaterial(t).objectOpacity=e})}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),G(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.basemapTerrain.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._initialCullFace.clear(),this._visibleObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null)}_modificationsChanged(){const e=this.layer.spatialReference,t=I(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=M();this._layerClippingArea=Y(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=a(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),this.forEachComponentObject(t=>{const i=this._collection.getMaterial(t);i.commonMaterialParameters.hasSlicePlane=e,i.commonMaterialParameters.cullFace=e?0:this._initialCullFace.get(t)})}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,V(e))}get _wasm(){return z(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return pe(this.layer.effectiveScaleRange,this.view.scale)}get performanceInfo(){let e=0,t=0,i=0,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(a=>{a.isVisible?(e+=a.textureMemoryUsage,t+=a.vboMemoryUsage,r++):(i+=a.textureMemoryUsage,s+=a.vboMemoryUsage,o++)}),new L(this.usedMemory,r,o,be(t),be(e),be(s),be(i))}_canProjectWithoutEngine(){if(2===this.view.state.viewingMode){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationOffset(){return V(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new X(e.zmin,e.zmax):null}getElevationRange(e){return null}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const i of e)for(const e of i.componentObjects)t(e)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=y(t.desc.origin),s=new Array,r=this.view.basemapTerrain.spatialReference;let o,a;if("global"===this.view.viewingMode){const e=u();j(v,i,e,r),o=c(m(),e),a=d(m(),o)}else o=h,a=h;const n=b(i);let l=null;const M=_();if(t.desc.obb){const e=t.desc.obb.quaternion;l=new Z(t.desc.obb.center,t.desc.obb.halfSize,p(e[0],e[1],e[2],e[3]))}let O=0,U=0;const P={textureMemoryUsage:0},H=new Array,E=new Map;for(let c=0;c<t.desc.prims.length;c++){const e=t.desc.prims[c];this._dbg(2,JSON.stringify(e));if(null==W[e.ptype]||null==t.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+e.ptype+"). Skipping primitive.");continue}const d=t.desc?.materials&&null!=e.materialId?t.desc.materials[e.materialId]:null,m=null!=d?d.lightingModel:"Unlit",{positionView:u,positionAttr:p,normalsView:y,normalsAttr:b,colorAttr:v,texCoord0Attr:j,indicesView:S}=this.getBufferViews(e,t.data.buffer,o);if(null==p||null==u||null==S)continue;const F=new ie(null!=v,j?1:0,null!=y,this._shadeNormals||this._replacesTerrain,this._applySSAO),R=p.data.length/p.size,A=(e,t)=>!e||e.data.length/e.size===R||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!A(j,"numTexcoord")||!A(v,"numColors")||!A(b,"normals"))continue;const k=se(F);if(null!=l?l=l.clone():(l=ee(p),f(M,l.center,i),l.center=M),o!==h)for(let t=0;t<u.count;t++)u.getVec(t,M),g(M,M,o),u.setVec(t,M);const V=k.createBuffer(p.data.length);if(de("position",p,null,null,V,0),null!=j){const e=V.getField("uv0",T);me(j,e,0)}null!=v&&de("color",v,null,null,V,0),null!=b&&de("normalCompressed",b,null,null,V,0);const I=new Uint32Array([0,S.typedBuffer.length]),D={vertices:{data:V.buffer,count:V.byteLength/k.stride,layoutParameters:F},positionData:{positions:u.typedBuffer,indices:S.typedBuffer},indices:S.typedBuffer,componentOffsets:I};O+=u.count+S.count;const L=this.view.renderSpatialReference,B=_(),G=[1,1,1];x(n,L,G,r)||this._dbg(3,"Unsupported coordinate system for IM overlay"),C(n,L,B,r);const z=this._collection.createObject(new te(w(B[0],B[1],G[0],G[1]),new re(n,a),l,D));d&&this._collection.updateMaterial(z,e=>{e.baseColor=d.baseColorFactor,e.usePBR="Pbr"===m,e.hasParametersFromSource=!1,e.baseColorTexture=this._getTexture(d.baseColorTex,t,E,P),e.usePBR&&(e.mrrFactors=[d.metallicFactor,d.roughnessFactor,0],e.emissiveBaseColor=d.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=this._getTexture(d.metalTex,t,E,P),e.emissionTexture=this._getTexture(d.emissiveTex,t,E,P),e.occlusionTexture=this._getTexture(d.occlusionTex,t,E,P),e.normalTexture=this._getTexture(d.normalTex,t,E,P)),e.objectOpacity=0,e.alphaDiscardMode=2;const i=[];e.baseColorTexture&&i.push(e.baseColorTexture.loadPromise),e.usePBR&&(e.metallicRoughnessTexture&&i.push(e.metallicRoughnessTexture.loadPromise),e.emissionTexture&&i.push(e.emissionTexture.loadPromise),e.occlusionTexture&&i.push(e.occlusionTexture.loadPromise),e.normalTexture&&i.push(e.normalTexture.loadPromise));const r=Promise.all(i);s.push(r),r.then(()=>{e.alphaDiscardMode=$[d.alphaMode],e.objectOpacity=this.opacity,P.textureMemoryUsage+=e.baseColorTexture?.glTexture?.usedMemory??0,e.usePBR&&(P.textureMemoryUsage+=(e.metallicRoughnessTexture?.glTexture?.usedMemory??0)+(e.emissionTexture?.glTexture?.usedMemory??0)+(e.occlusionTexture?.glTexture?.usedMemory??0)+(e.normalTexture?.glTexture?.usedMemory??0))}),e.commonMaterialParameters.doubleSided=d.isDoubleSided,e.commonMaterialParameters.cullFace=d.faceCulling?J[d.faceCulling]:2,this._initialCullFace.set(z,e.commonMaterialParameters.cullFace),e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=0,e.textureAlphaCutoff=d.alphaCutoff??ge,e.alphaDiscardMode=$[d.alphaMode],e.isIntegratedMesh=!0,e.sphereDepthInterpolate=this.layer.replacesTerrain,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=ae(this.view.spatialReference)}),H.push(z),U+=this._collection.getObjectGPUMemoryUsage(z)}await Promise.all(s);const S=new Array;E.forEach(e=>{S.push(e)});const F=new ye(e.handle,H,S,O,U,P.textureMemoryUsage);return this._memCache.put(`${F.handle}`,F),this._lyrHandleToObjects.set(e.handle,F),this._cacheMemory+=F.usedMemory,{memUsageBytes:F.usedMemory}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(t.isVisible?(this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){this._memCache.pop(`${e.handle}`),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>{this._collection.destroyObject(e),this._initialCullFace.delete(e)})}setRenderableVisibility(e,t,i){for(let s=0;s<i;++s){const i=t[s];if(!i)continue;const r=e[s],o=this._lyrHandleToObjects.get(r);if(o){if(o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!0,this._visibleObjects.add(o),this._usedMemory+=o.usedMemory,this._cacheMemory-=o.usedMemory,o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,i),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.pop(`${r}`)}}for(let s=0;s<i;++s){const i=e[s],r=t[s];if(r)continue;const o=this._lyrHandleToObjects.get(i);if(o){if(!o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!1,this._visibleObjects.delete(o),this._usedMemory-=o.usedMemory,this._cacheMemory+=o.usedMemory,o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,r),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.put(`${i}`,o)}}}_getTexture(e,t,i,s){let r=null;if(e&&t.desc?.images&&t.data?.buffer){const o=t.desc.images[e?.imageId];if(r=i.get(o),!r&&o){const a=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,n=!!o.mipCount||a>1,l=q[e.wrapMode??"None"];let c=o.alpha?4:3;const d=new Uint8Array(t.data.buffer,o.data.byteOffset,o.data.byteCount);let m=null,h=null,u=null;switch(o.format){case"Raw":"R8"===o.pixelFormat?(m=d,c=1,h=""):"Rgb8"===o.pixelFormat?(m=d,c=3,h=""):"Rgba8"===o.pixelFormat&&(m=d,c=4,h="");break;case"Dxt1":m=d,c=3,h="image/vnd-ms.dds";break;case"Dxt5":m=d,c=4,h="image/vnd-ms.dds";break;case"Basis":m=d,c=3,h="image/ktx2";break;case"Png":h="image/png",u=document.createElement("img");break;case"Jpeg":h="image/jpeg",u=document.createElement("img");break;case"Etc2":h="image/ktx",u=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(u&&h){const e=new Blob([d],{type:h});u.src=URL.createObjectURL(e),m=u}if(m&&null!=h){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(s.textureMemoryUsage-=e)}}:void 0;r=new ce(m,{mipmap:n,maxAnisotropy:a,encoding:h,wrap:l,components:c,compressionOptions:e,noUnpackFlip:!0,width:o.mip0Width,height:o.mip0Height}),this._stage.addTexture(r),i.set(o,r)}}}return r?new oe(this.view.stage.renderView.textures,r.id):null}getBufferViews(e,t,i){let s,r,o,a,n,l,c,d=null;for(let h=0;h<e.atrbs.length;h++){const c=e.atrbs[h],u=c.view,p=void 0,f=u.byteOffset+u.byteCount,g=u.byteCount/K[u.type],y=[...Array(g).keys()].map(e=>e);try{switch(c.sem){case"Position":3!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(s=new H(t,u.byteOffset,p,f),r=new ne(s.typedBuffer,y,3));break;case"Normal":if(3!==u.ncomp||"F32"!==u.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new H(t,u.byteOffset,p,f),s=le(e.typedBuffer,i);n=new F(s.buffer),l=new ne(n.typedBuffer,y,2)}break;case"TexCoord":2!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===a&&(a=new ne(new T(t,u.byteOffset,p,f).typedBuffer,y,2));break;case"Color":4===u.ncomp?("F32"===u.type&&(d=new O(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new U(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new P(t,u.byteOffset,p,f))):3===u.ncomp&&("F32"===u.type&&(d=new H(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new E(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new S(t,u.byteOffset,p,f))),null==d?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new ne(d.typedBuffer,y,u.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(m){this._dbg(2,"Error Creating buffer ("+m+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":c=new A(t,i.byteOffset,s,r);break;case"U32":c=new R(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==c&&null!=s){const e=s.count;if(e<65535){const t=new Uint16Array(e);c=new A(t.buffer)}else{const t=new Uint32Array(e);c=new R(t.buffer)}for(let t=0;t<e;t++)c.set(t,t)}return{positionView:s,positionAttr:r,colorAttr:o,texCoord0Attr:a,indicesView:c,normalsView:n,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>this._modifications=e.toArray(),s),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([n({type:[k]})],_e.prototype,"_modifications",void 0),e([n()],_e.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([n()],_e.prototype,"layer",void 0),e([n({readOnly:!0})],_e.prototype,"visibleAtCurrentScale",null),e([n()],_e.prototype,"elevationOffset",null),_e=e([l("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],_e);const we=_e;export{we as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i}from"../../../core/maybe.js";import{initial as s,watch as r,when as o}from"../../../core/reactiveUtils.js";import{schedule as a}from"../../../core/scheduling.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as c,invert as d}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m,IDENTITY as h}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as u}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as p}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{f,o as g}from"../../../chunks/vec32.js";import{fromArray as y,clone as b,create as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as w}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as v}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as j}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as x}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as C}from"../../../geometry/projection/projectVectorToVector.js";import{create as M}from"../../../geometry/support/aaBoundingRect.js";import{BufferViewVec2f as T,BufferViewVec4f as O,BufferViewVec4u8 as U,BufferViewVec4u16 as P,BufferViewVec3f as H,BufferViewVec3u8 as E,BufferViewVec3u16 as F,BufferViewInt16 as S,BufferViewUint32 as R,BufferViewUint16 as A}from"../../../geometry/support/buffer/BufferView.js";import k from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as V}from"../../../support/elevationInfoUtils.js";import{toWasmModification as I}from"./I3SMeshWorkerHandle.js";import{LayerView3D as D}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as L}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as B,removeLayerViewFromWasm as G,getLyr3DWasm as z}from"./Lyr3DWasm.js";import{LayerElevationProvider as N}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as W,alphaModeConversion as $,faceCullingConversion as J,wrapModeConversion as q,lyr3DTypeToByteSize as K}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as Q}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as X}from"../support/ElevationRange.js";import{toBoundingRect as Y}from"../support/extentUtils.js";import{Obb as Z,compute as ee}from"../support/orientedBoundingBox.js";import{ObjectParameters as te}from"../webgl-engine/collections/Component/ObjectParameters.js";import{GeometryParameters as ie,createVertexBufferLayout as se}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as re}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as oe}from"../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as ae}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as ne}from"../webgl-engine/lib/Attribute.js";import{compressAndTransformNormals as le}from"../webgl-engine/lib/Normals.js";import{Texture as ce}from"../webgl-engine/lib/Texture.js";import{writeAttribute as de,writeBufferVec2 as me}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import he from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as ue,isInEffectiveScaleRange as pe}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as fe}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as ge}from"../../../webscene/support/AlphaCutoff.js";class ye{constructor(e,t,i,s,r,o){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=s,this.vboMemoryUsage=r,this.textureMemoryUsage=o,this.isVisible=!1,this.usedMemory=this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}}function be(e){return Math.round(e/1048.576)/1e3}let _e=class extends(D(he)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new fe,this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._initialCullFace=new Map,this._suspendedHandle=null,this._dbgFlags=new Set,this._memCache=e.view.resourceController.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e))}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),s),!this._canProjectWithoutEngine())throw ue("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=B(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new Q(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),s),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),s),this._elevationProvider=new N({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),e.elevationProvider.register(1,this._elevationProvider),e.basemapTerrain.overlayManager.registerDrapeTarget(this),this.addHandles([r(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e))]),this._suspendedHandle=r(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),s)});this.addResolvingPromise(t),this._replacesTerrain&&this.addHandles(o(()=>this.view.map.ground.opacity,()=>{this._opacityChange()}))}get _replacesTerrain(){return this.layer.replacesTerrain&&!!this.view.map.basemap?.groundLayers.includes(this.layer)}get opacity(){return this.fullOpacity*(this._replacesTerrain?this.view.map.ground.opacity:1)}_opacityChange(){const{opacity:e}=this;this.forEachComponentObject(t=>{this._collection.getMaterial(t).objectOpacity=e})}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),G(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.basemapTerrain.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._initialCullFace.clear(),this._visibleObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null)}_modificationsChanged(){const e=this.layer.spatialReference,t=I(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=M();this._layerClippingArea=Y(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=a(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),this.forEachComponentObject(t=>{const i=this._collection.getMaterial(t);i.commonMaterialParameters.hasSlicePlane=e,i.commonMaterialParameters.cullFace=e?0:this._initialCullFace.get(t)})}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,V(e))}get _wasm(){return z(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return pe(this.layer.effectiveScaleRange,this.view.scale)}get performanceInfo(){let e=0,t=0,i=0,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(a=>{a.isVisible?(e+=a.textureMemoryUsage,t+=a.vboMemoryUsage,r++):(i+=a.textureMemoryUsage,s+=a.vboMemoryUsage,o++)}),new L(this.usedMemory,r,o,be(t),be(e),be(s),be(i))}_canProjectWithoutEngine(){if(2===this.view.state.viewingMode){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationOffset(){return V(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new X(e.zmin,e.zmax):null}getElevationRange(e){return null}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const i of e)for(const e of i.componentObjects)t(e)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=y(t.desc.origin),s=new Array,r=this.view.basemapTerrain.spatialReference;let o,a;if("global"===this.view.viewingMode){const e=u();j(v,i,e,r),o=c(m(),e),a=d(m(),o)}else o=h,a=h;const n=b(i);let l=null;const M=_();if(t.desc.obb){const e=t.desc.obb.quaternion;l=new Z(t.desc.obb.center,t.desc.obb.halfSize,p(e[0],e[1],e[2],e[3]))}let O=0,U=0;const P={textureMemoryUsage:0},H=new Array,E=new Map;for(let c=0;c<t.desc.prims.length;c++){const e=t.desc.prims[c];this._dbg(2,JSON.stringify(e));if(null==W[e.ptype]||null==t.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+e.ptype+"). Skipping primitive.");continue}const d=t.desc?.materials&&null!=e.materialId?t.desc.materials[e.materialId]:null,m=null!=d?d.lightingModel:"Unlit",{positionView:u,positionAttr:p,normalsView:y,normalsAttr:b,colorAttr:v,texCoord0Attr:j,indicesView:F}=this.getBufferViews(e,t.data.buffer,o);if(null==p||null==u||null==F)continue;const S=new ie(null!=v,j?1:0,null!=y,this._shadeNormals||this._replacesTerrain,this._applySSAO),R=p.data.length/p.size,A=(e,t)=>!e||e.data.length/e.size===R||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!A(j,"numTexcoord")||!A(v,"numColors")||!A(b,"normals"))continue;const k=se(S);if(null!=l?l=l.clone():(l=ee(p),f(M,l.center,i),l.center=M),o!==h)for(let t=0;t<u.count;t++)u.getVec(t,M),g(M,M,o),u.setVec(t,M);const V=k.createBuffer(p.data.length);if(de("position",p,null,null,V,0),null!=j){const e=V.getField("uv0",T);me(j,e,0)}null!=v&&de("color",v,null,null,V,0),null!=b&&de("normalCompressed",b,null,null,V,0);const I=new Uint32Array([0,F.typedBuffer.length]),D={vertices:{data:V.buffer,count:V.byteLength/k.stride,layoutParameters:S},positionData:{positions:u.typedBuffer,indices:F.typedBuffer},indices:F.typedBuffer,componentOffsets:I};O+=u.count+F.count;const L=this.view.renderSpatialReference,B=_(),G=[1,1,1];x(n,L,G,r)||this._dbg(3,"Unsupported coordinate system for IM overlay"),C(n,L,B,r);const z=this._collection.createObject(new te(w(B[0],B[1],G[0],G[1]),new re(n,a),l,D));d&&this._collection.updateMaterial(z,e=>{e.baseColor=d.baseColorFactor,e.usePBR="Pbr"===m,e.hasParametersFromSource=!1,e.baseColorTexture=this._getTexture(d.baseColorTex,t,E,P),e.usePBR&&(e.mrrFactors=[d.metallicFactor,d.roughnessFactor,0],e.emissiveBaseColor=d.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=this._getTexture(d.metalTex,t,E,P),e.emissionTexture=this._getTexture(d.emissiveTex,t,E,P),e.occlusionTexture=this._getTexture(d.occlusionTex,t,E,P),e.normalTexture=this._getTexture(d.normalTex,t,E,P)),e.objectOpacity=0,e.alphaDiscardMode=2;const i=[];e.baseColorTexture&&i.push(e.baseColorTexture.loadPromise),e.usePBR&&(e.metallicRoughnessTexture&&i.push(e.metallicRoughnessTexture.loadPromise),e.emissionTexture&&i.push(e.emissionTexture.loadPromise),e.occlusionTexture&&i.push(e.occlusionTexture.loadPromise),e.normalTexture&&i.push(e.normalTexture.loadPromise));const r=Promise.all(i);s.push(r),r.then(()=>{e.alphaDiscardMode=$[d.alphaMode],e.objectOpacity=this.opacity,P.textureMemoryUsage+=e.baseColorTexture?.glTexture?.usedMemory??0,e.usePBR&&(P.textureMemoryUsage+=(e.metallicRoughnessTexture?.glTexture?.usedMemory??0)+(e.emissionTexture?.glTexture?.usedMemory??0)+(e.occlusionTexture?.glTexture?.usedMemory??0)+(e.normalTexture?.glTexture?.usedMemory??0))}),e.commonMaterialParameters.doubleSided=d.isDoubleSided,e.commonMaterialParameters.cullFace=d.faceCulling?J[d.faceCulling]:2,this._initialCullFace.set(z,e.commonMaterialParameters.cullFace),e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=0,e.textureAlphaCutoff=d.alphaCutoff??ge,e.alphaDiscardMode=$[d.alphaMode],e.isIntegratedMesh=!0,e.sphereDepthInterpolate=this.layer.replacesTerrain,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=ae(this.view.spatialReference)}),H.push(z),U+=this._collection.getObjectGPUMemoryUsage(z)}await Promise.all(s);const F=new Array;E.forEach(e=>{F.push(e)});const S=new ye(e.handle,H,F,O,U,P.textureMemoryUsage);return this._memCache.put(`${S.handle}`,S),this._lyrHandleToObjects.set(e.handle,S),this._cacheMemory+=S.usedMemory,{memUsageBytes:S.usedMemory}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(t.isVisible?(this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){this._memCache.pop(`${e.handle}`),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>{this._collection.destroyObject(e),this._initialCullFace.delete(e)})}setRenderableVisibility(e,t,i){for(let s=0;s<i;++s){const i=t[s];if(!i)continue;const r=e[s],o=this._lyrHandleToObjects.get(r);if(o){if(o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!0,this._visibleObjects.add(o),this._usedMemory+=o.usedMemory,this._cacheMemory-=o.usedMemory,o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,i),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.pop(`${r}`)}}for(let s=0;s<i;++s){const i=e[s],r=t[s];if(r)continue;const o=this._lyrHandleToObjects.get(i);if(o){if(!o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!1,this._visibleObjects.delete(o),this._usedMemory-=o.usedMemory,this._cacheMemory+=o.usedMemory,o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,r),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.put(`${i}`,o)}}}_getTexture(e,t,i,s){let r=null;if(e&&t.desc?.images&&t.data?.buffer){const o=t.desc.images[e?.imageId];if(r=i.get(o),!r&&o){const a=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,n=!!o.mipCount||a>1,l=q[e.wrapMode??"None"];let c=o.alpha?6408:6407;const d=new Uint8Array(t.data.buffer,o.data.byteOffset,o.data.byteCount);let m=null,h=null,u=null;switch(o.format){case"Raw":"R8"===o.pixelFormat?(m=d,c=6403,h=""):"Rgb8"===o.pixelFormat?(m=d,c=6407,h=""):"Rgba8"===o.pixelFormat&&(m=d,c=6408,h="");break;case"Dxt1":m=d,c=6407,h="image/vnd-ms.dds";break;case"Dxt5":m=d,c=6408,h="image/vnd-ms.dds";break;case"Basis":m=d,c=6407,h="image/ktx2";break;case"Png":h="image/png",u=document.createElement("img");break;case"Jpeg":h="image/jpeg",u=document.createElement("img");break;case"Etc2":h="image/ktx",u=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(u&&h){const e=new Blob([d],{type:h});u.src=URL.createObjectURL(e),m=u}if(m&&null!=h){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(s.textureMemoryUsage-=e)}}:void 0;r=new ce(m,{mipmap:n,maxAnisotropy:a,encoding:h,wrap:l,pixelFormat:c,compressionOptions:e,noUnpackFlip:!0,width:o.mip0Width,height:o.mip0Height}),this._stage.addTexture(r),i.set(o,r)}}}return r?new oe(this.view.stage.renderView.textures,r.id):null}getBufferViews(e,t,i){let s,r,o,a,n,l,c,d=null;for(let h=0;h<e.atrbs.length;h++){const c=e.atrbs[h],u=c.view,p=void 0,f=u.byteOffset+u.byteCount,g=u.byteCount/K[u.type],y=[...Array(g).keys()].map(e=>e);try{switch(c.sem){case"Position":3!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(s=new H(t,u.byteOffset,p,f),r=new ne(s.typedBuffer,y,3));break;case"Normal":if(3!==u.ncomp||"F32"!==u.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new H(t,u.byteOffset,p,f),s=le(e.typedBuffer,i);n=new S(s.buffer),l=new ne(n.typedBuffer,y,2)}break;case"TexCoord":2!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===a&&(a=new ne(new T(t,u.byteOffset,p,f).typedBuffer,y,2));break;case"Color":4===u.ncomp?("F32"===u.type&&(d=new O(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new U(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new P(t,u.byteOffset,p,f))):3===u.ncomp&&("F32"===u.type&&(d=new H(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new E(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new F(t,u.byteOffset,p,f))),null==d?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new ne(d.typedBuffer,y,u.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(m){this._dbg(2,"Error Creating buffer ("+m+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":c=new A(t,i.byteOffset,s,r);break;case"U32":c=new R(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==c&&null!=s){const e=s.count;if(e<65535){const t=new Uint16Array(e);c=new A(t.buffer)}else{const t=new Uint32Array(e);c=new R(t.buffer)}for(let t=0;t<e;t++)c.set(t,t)}return{positionView:s,positionAttr:r,colorAttr:o,texCoord0Attr:a,indicesView:c,normalsView:n,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>this._modifications=e.toArray(),s),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([n({type:[k]})],_e.prototype,"_modifications",void 0),e([n()],_e.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([n()],_e.prototype,"layer",void 0),e([n({readOnly:!0})],_e.prototype,"visibleAtCurrentScale",null),e([n()],_e.prototype,"elevationOffset",null),_e=e([l("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],_e);const we=_e;export{we 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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{validateColorAndOpacity as e,validateColor as r}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{clamp as o}from"../../../../core/mathUtils.js";import{uncompressedFormats as a,compressibleUsages as s}from"./enums.js";import{RenderTexture as t}from"../../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as
|
|
5
|
+
import{validateColorAndOpacity as e,validateColor as r}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{clamp as o}from"../../../../core/mathUtils.js";import{uncompressedFormats as a,compressibleUsages as s}from"./enums.js";import{RenderTexture as t}from"../../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as l}from"../../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Texture as n}from"../../webgl-engine/lib/Texture.js";import{useSchematicPBRI3S as i,useSchematicPBR as u,schematicMRRFactors as c,advancedMRRFactors as m}from"../../webgl-engine/materials/pbrUtils.js";import{alphaCutoff as d}from"../../../../webscene/support/AlphaCutoff.js";function g(r,o,a){const s=new Map,t=(e,r)=>{if(null==e)return-1;const o=s.get(e.id);if(o)return o.usage|=r,o.id;const a=s.size;return s.set(e.id,{id:a,usage:r}),a},l=o.pbrMetallicRoughness,n=l?.baseColorFactor?e(l.baseColorFactor):null,d=o.emissiveFactor,g=has("disable-feature:diffuse-rendering-i3s")||a?i({normalTexture:o.normalTexture,emissiveTexture:o.emissiveTexture,emissiveFactor:o.emissiveFactor,occlusionTexture:o.occlusionTexture,metallicRoughnessTexture:l?.metallicRoughnessTexture,metallicFactor:l?.metallicFactor,roughnessFactor:l?.roughnessFactor}):u({normalTexture:o.normalTexture,emissiveTexture:o.emissiveTexture,emissiveFactor:o.emissiveFactor,occlusionTexture:o.occlusionTexture,metallicRoughnessTexture:l?.metallicRoughnessTexture,metallicFactor:l?.metallicFactor,roughnessFactor:l?.roughnessFactor}),f=g?c[0]:l?.metallicFactor??m[0],h=g?c[1]:l?.roughnessFactor??m[1],F="mask"===o.alphaMode?33:1,T={baseColorFactor:n?[n[0],n[1],n[2],n[3]]:[1,1,1,1],baseColorTextureId:t(l?.baseColorTexture,F),metallicRoughnessTextureId:t(l?.metallicRoughnessTexture,2),metallicFactor:f,roughnessFactor:h},b={alphaMode:o.alphaMode,alphaCutoff:o.alphaCutoff,doubleSided:o.doubleSided,cullFace:"none"===o.cullFace?0:"back"===o.cullFace?2:"front"===o.cullFace?1:0,normalTextureId:t(o.normalTexture,4),emissiveTextureId:t(o.emissiveTexture,16),occlusionTextureId:t(o.occlusionTexture,8),emissiveFactor:d?[d[0],d[1],d[2]]:[0,0,0],metallicRoughness:T,wrapTextures:!1,hasParametersFromSource:g},C=[];return s.forEach(({usage:e},o)=>{const a=null!=r&&r[o]&&r[o].formats,s=a?p(a.map(({name:e,format:r})=>({name:e,encoding:x[r]}))):[];C.push({id:o,usage:e,encodings:s})}),{material:b,textures:C}}function p(e){return e.sort((e,r)=>e.encoding-r.encoding)}const x={ktx2:1,basis:2,dds:4,png:8,jpg:16,"ktx-etc2":32},f={"image/ktx2":2,"image/x.basis":2,"image/vnd-ms.dds":4,"image/png":8,"image/jpg":16,"image/jpeg":16,"image/ktx":32};function h(e){const a=e?.materialDefinitions?Object.keys(e.materialDefinitions)[0]:null,s=e?.textureDefinitions?Object.keys(e.textureDefinitions)[0]:null,t=a?e.materialDefinitions?.[a]:null,l=s?e.textureDefinitions?.[s]:null,n=F();if(null!=t){const e=t.params;e.diffuse&&(r(e.diffuse),n.metallicRoughness.baseColorFactor=[e.diffuse[0],e.diffuse[1],e.diffuse[2],1]),null!=e.doubleSided&&(n.doubleSided=e.doubleSided,n.cullFace=e.doubleSided?0:2),"none"!==e.cullFace&&"front"!==e.cullFace&&"back"!==e.cullFace||(n.cullFace="none"===e.cullFace?0:"back"===e.cullFace?2:1),e.transparency&&(n.metallicRoughness.baseColorFactor[3]=o(1-e.transparency,0,1)),(e.useVertexColorAlpha||n.metallicRoughness.baseColorFactor[3]<1)&&(n.alphaMode="blend")}const i=[];if(null!=l){const e=0;!l.wrap||"repeat"!==l.wrap[0]&&"repeat"!==l.wrap[1]||(n.wrapTextures=!0);let r=1;"rgba"===l.channels&&(n.alphaMode="blend",r|=32);const o=l.images.length-1,a=l.images[o],s=e=>e?.split("/").pop(),t=Array.isArray(l.encoding)?p(l.encoding.map((e,r)=>({name:s(a.href[r]),encoding:f[e]||0}))):[{name:s(a.href),encoding:f[l.encoding]||0}];i.push({id:e,usage:r,encodings:t}),n.metallicRoughness.baseColorTextureId=e}return{material:n,textures:i}}const F=()=>({alphaMode:"opaque",alphaCutoff:d,doubleSided:!0,cullFace:0,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[.8,.8,.8,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6},wrapTextures:!1,hasParametersFromSource:!0});function T(e,r,o,a,s,t){if(null==e?.data)return null;const l=e.data,i=a.renderingContext.parameters.maxMaxAnisotropy,u=i>1,c=o||!r.wrapTextures?b:C,m=k(e.encoding),d=1&e.usage?"opaque"===r.alphaMode?6407:6408:6407,g=P(e.encoding,e.usage)?{compressionTracker:s,compressionCallback:t}:void 0;return new n(l,{mipmap:u,maxAnisotropy:i,encoding:m,wrap:c,pixelFormat:d,compressionOptions:g,noUnpackFlip:!0})}const b={s:33071,t:33071},C={s:10497,t:10497};function R(r,o,a,s,n,i){const u=i.rendererTextureUsage,g=e=>v(s,a,e&u),p=e(o.metallicRoughness.baseColorFactor);r.baseColor=[p[0],p[1],p[2],p[3]],r.hasParametersFromSource=!!o.hasParametersFromSource,r.usePBR=i.usePBR,r.mrrFactors=[o.metallicRoughness.metallicFactor,o.metallicRoughness.roughnessFactor,o.hasParametersFromSource?c[2]:m[2]],r.emissiveBaseColor=o.emissiveFactor,r.isIntegratedMesh=i.isIntegratedMesh,r.textureAlphaCutoff="mask"===o.alphaMode?o.alphaCutoff:d,r.alphaDiscardMode="opaque"===o.alphaMode?1:"mask"===o.alphaMode?2:3;const x=[],f=g(33);null!=f&&(r.baseColorTexture=new t(n,f),x.push(r.baseColorTexture.loadPromise));const h=g(2);null!=h&&(r.metallicRoughnessTexture=new t(n,h),x.push(r.metallicRoughnessTexture.loadPromise));const F=g(16);null!=F&&(r.emissionTexture=new t(n,F),x.push(r.emissionTexture.loadPromise));const T=g(8);null!=T&&(r.occlusionTexture=new t(n,T),x.push(r.occlusionTexture.loadPromise));const b=g(4);return null!=b&&(r.normalTexture=new t(n,b),x.push(r.normalTexture.loadPromise)),r.commonMaterialParameters.hasSlicePlane=i.slicePlaneEnabled,r.commonMaterialParameters.doubleSided=o.doubleSided,r.commonMaterialParameters.cullFace=o.cullFace,r.ellipsoidMode=l(i.viewSpatialReference),Promise.all(x)}function w(e){const r=!!e.compressedTextureS3TC,o=!!e.compressedTextureETC,a=has("disable-feature:i3s-basis")?0:3;return 24|(r?4|a:0)|(o?a:0)}function M(e,r){if(null!=r)return e.find(e=>0!==(e.encoding&r))}function v(e,r,o){if(null==e||0===o)return null;for(let a=0;a<e.length;a++){const s=e[a];if(null!=s&&0!==(s.usage&o)){const e=r[a];return null!=e?e.id:null}}return null}function P(e,r){return!!has("enable-feature:esri-compress-IM-textures")&&(0!==(e&a)&&!(r&~s))}function k(e){switch(e){case 1:return"image/ktx2";case 2:return"image/x.basis";case 4:return"image/vnd-ms.dds";case 8:return"image/png";case 16:return"image/jpeg";case 32:return"image/ktx";default:return""}}export{R as configureMaterial,T as createTexture,F as defaultMaterial,g as getMaterialAndTextures,h as getMaterialAndTexturesFromShared,w as getSupportedEncodings,M as selectEncoding};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{createPrimitive as r}from"./sdfPrimitives.js";import{
|
|
5
|
+
import{createPrimitive as r}from"./sdfPrimitives.js";import{SizedPixelFormat as e,PixelType as t}from"../../../webgl/enums.js";import{Texture as o}from"../../../webgl/Texture.js";import{TextureDescriptor as m}from"../../../webgl/TextureDescriptor.js";const i=64,s=i/2,n=s/5,p=i/n,a=.25;function f(p,a){const f=r(p,i,s,n),u=new m(i);return u.internalFormat=e.R16F,u.dataType=t.FLOAT,u.pixelFormat=6403,u.wrapMode=33071,new o(a,u,f)}export{f as createMarkerTexture,p as markerSizePerLineWidth,s as markerSymbolSize,i as markerTextureSize,n as markerThickness,a as markerTipThicknessFactor};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../../core/has.js";import{
|
|
5
|
+
import"../../../../core/has.js";import{freeze as t}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{Texture as r}from"../../webgl-engine/lib/Texture.js";import{SizedPixelFormat as n,PixelType as e}from"../../../webgl/enums.js";const a=128,o=.5,u=t(o/2,o/2,1-o/2,1-o/2);function s(t){return"cross"===t||"x"===t}function c(t,n=a,e=n*o,u=0){const{data:s,parameters:c}=i(t,n,e,u);return new r(s,c)}function i(t,r=a,u=r*o,s=0){return{data:f(t,r,u,s),parameters:{mipmap:!1,wrap:{s:33071,t:33071},width:r,height:r,noUnpackFlip:!0,dataType:e.FLOAT,pixelFormat:6403,internalFormat:n.R16F,reloadable:!0}}}function f(t,r=a,n=r*o,e=0){switch(t){case"circle":default:return h(r,n);case"square":return M(r,n);case"cross":return m(r,n,e);case"x":return p(r,n,e);case"kite":return l(r,n);case"triangle":return b(r,n);case"arrow":return x(r,n)}}function h(t,r){const n=t/2-.5;return g(t,R(n,n,r/2))}function M(t,r){return T(t,r,!1)}function l(t,r){return T(t,r,!0)}function m(t,r,n=0){return w(t,r,!1,n)}function p(t,r,n=0){return w(t,r,!0,n)}function b(t,r){return g(t,d(t/2,r,r/2))}function x(t,r){const n=r,e=r/2,a=t/2,o=.8*n,u=R(a,(t-r)/2-o,Math.sqrt(o*o+e*e)),s=d(a,n,e);return g(t,(t,r)=>Math.max(s(t,r),-u(t,r)))}function T(t,r,n){return n&&(r/=Math.SQRT2),g(t,(e,a)=>{let o=e-.5*t+.25,u=.5*t-a-.75;if(n){const t=(o+u)/Math.SQRT2;u=(u-o)/Math.SQRT2,o=t}return Math.max(Math.abs(o),Math.abs(u))-.5*r})}function w(t,r,n,e=0){r-=e,n&&(r*=Math.SQRT2);const a=.5*r;return g(t,(r,o)=>{let u,s=r-.5*t,c=.5*t-o-1;if(n){const t=(s+c)/Math.SQRT2;c=(c-s)/Math.SQRT2,s=t}return s=Math.abs(s),c=Math.abs(c),u=s>c?s>a?Math.sqrt((s-a)*(s-a)+c*c):c:c>a?Math.sqrt(s*s+(c-a)*(c-a)):s,u-=e/2,u})}function R(t,r,n){return(e,a)=>{const o=e-t,u=a-r;return Math.sqrt(o*o+u*u)-n}}function d(t,r,n){const e=Math.sqrt(r*r+n*n);return(a,o)=>{const u=Math.abs(a-t)-n,s=o-t+r/2+.75,c=(r*u+n*s)/e,i=-s;return Math.max(c,i)}}function g(t,r){const n=new Float32Array(t*t);for(let e=0;e<t;e++)for(let a=0;a<t;a++){n[a+t*e]=r(a,e)/t}return n}export{x as createArrow,h as createCircle,m as createCross,l as createKite,f as createPrimitive,M as createSquare,c as createTexture,i as createTextureInfo,b as createTriangle,p as createX,u as defaultBoundingBox,o as defaultSymbolSizeRatio,a as defaultTexSize,s as requiresHalfTexelOffset};
|
|
@@ -2,27 +2,27 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{NoPerspectiveRead as e}from"../util/NoPerspective.glsl.js";import{
|
|
5
|
+
import{NoPerspectiveRead as e}from"../util/NoPerspective.glsl.js";import{addCameraPosition as t,addPixelRatio as o}from"../util/View.glsl.js";import{Float4PassUniform as r}from"../../shaderModules/Float4PassUniform.js";import{FloatBindUniform as i}from"../../shaderModules/FloatBindUniform.js";import{FloatPassUniform as l}from"../../shaderModules/FloatPassUniform.js";import{glsl as a,If as s}from"../../shaderModules/glsl.js";import{Texture2DPassUniform as n}from"../../shaderModules/Texture2DPassUniform.js";import{computeTextureSize as p}from"../../../materials/stippleTextureRepository.js";import{ensureColor4 as d}from"../../../shaders/ensureColor4.js";function c(p,c){if(!c.stippleEnabled)return void p.fragment.code.add(a`float getStippleAlpha(float lineWidth) { return 1.0; }
|
|
6
6
|
void discardByStippleAlpha(float stippleAlpha, float threshold) {}
|
|
7
|
-
vec4 blendStipple(vec4 color, float stippleAlpha) { return color; }`);const
|
|
7
|
+
vec4 blendStipple(vec4 color, float stippleAlpha) { return color; }`);const u=!(c.draped&&c.stipplePreferContinuous),{vertex:S,fragment:h}=p;c.draped||(t(S,c),S.uniforms.add(new i("worldToScreenPerDistanceRatio",({camera:e})=>1/e.perScreenPixelRatio)).code.add(a`float computeWorldToScreenRatio(vec3 segmentCenter) {
|
|
8
8
|
float segmentDistanceToCamera = length(segmentCenter - cameraPosition);
|
|
9
9
|
return worldToScreenPerDistanceRatio / segmentDistanceToCamera;
|
|
10
|
-
}`)),
|
|
10
|
+
}`)),p.varyings.add("vStippleDistance","float"),p.varyings.add("vStippleDistanceLimits","vec2"),p.varyings.add("vStipplePatternStretch","float"),S.code.add(a`
|
|
11
11
|
float discretizeWorldToScreenRatio(float worldToScreenRatio) {
|
|
12
|
-
float step = ${
|
|
12
|
+
float step = ${a.float(m)};
|
|
13
13
|
|
|
14
14
|
float discreteWorldToScreenRatio = log(worldToScreenRatio);
|
|
15
15
|
discreteWorldToScreenRatio = ceil(discreteWorldToScreenRatio / step) * step;
|
|
16
16
|
discreteWorldToScreenRatio = exp(discreteWorldToScreenRatio);
|
|
17
17
|
return discreteWorldToScreenRatio;
|
|
18
18
|
}
|
|
19
|
-
`),
|
|
19
|
+
`),o(S),S.code.add(a`
|
|
20
20
|
vec2 computeStippleDistanceLimits(float startPseudoScreen, float segmentLengthPseudoScreen, float segmentLengthScreen, float patternLength) {
|
|
21
21
|
|
|
22
22
|
// First check if the segment is long enough to support fully screen space patterns.
|
|
23
23
|
// Force sparse mode for segments that are very large in screen space even if it is not allowed,
|
|
24
24
|
// to avoid imprecision from calculating with large floats.
|
|
25
|
-
if (segmentLengthPseudoScreen >= ${
|
|
25
|
+
if (segmentLengthPseudoScreen >= ${u?"patternLength":"1e4"}) {
|
|
26
26
|
// Round the screen length to get an integer number of pattern repetitions (minimum 1).
|
|
27
27
|
float repetitions = segmentLengthScreen / (patternLength * pixelRatio);
|
|
28
28
|
float flooredRepetitions = max(1.0, floor(repetitions + 0.5));
|
|
@@ -38,7 +38,7 @@ return worldToScreenPerDistanceRatio / segmentDistanceToCamera;
|
|
|
38
38
|
}
|
|
39
39
|
return vec2(startPseudoScreen, startPseudoScreen + segmentLengthPseudoScreen);
|
|
40
40
|
}
|
|
41
|
-
`),h.uniforms.add(new
|
|
41
|
+
`),h.uniforms.add(new n("stipplePatternTexture",e=>e.stippleTexture),new l("stipplePatternPixelSizeInv",e=>1/f(e))),c.stippleOffColorEnabled&&h.uniforms.add(new r("stippleOffColor",e=>d(e.stippleOffColor))),p.include(e),h.code.add(a`float getStippleSDF(out bool isClamped) {
|
|
42
42
|
float stippleDistanceClamped = noPerspectiveRead(clamp(vStippleDistance, vStippleDistanceLimits.x, vStippleDistanceLimits.y));
|
|
43
43
|
float lineSizeInv = noPerspectiveRead(vLineSizeInv);
|
|
44
44
|
vec2 aaCorrectedLimits = vStippleDistanceLimits + vec2(1.0, -1.0) / gl_FragCoord.w;
|
|
@@ -57,12 +57,12 @@ bool isClamped;
|
|
|
57
57
|
float stippleSDF = getStippleSDF(isClamped);
|
|
58
58
|
float antiAliasedResult = clamp(stippleSDF * lineWidth + 0.5, 0.0, 1.0);
|
|
59
59
|
return isClamped ? floor(antiAliasedResult + 0.5) : antiAliasedResult;
|
|
60
|
-
}`),h.code.add(
|
|
60
|
+
}`),h.code.add(a`
|
|
61
61
|
void discardByStippleAlpha(float stippleAlpha, float threshold) {
|
|
62
|
-
${
|
|
62
|
+
${s(!c.stippleOffColorEnabled,"if (stippleAlpha < threshold) { discard; }")}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
vec4 blendStipple(vec4 color, float stippleAlpha) {
|
|
66
|
-
return ${
|
|
66
|
+
return ${c.stippleOffColorEnabled?"mix(color, stippleOffColor, stippleAlpha)":"vec4(color.rgb, color.a * stippleAlpha)"};
|
|
67
67
|
}
|
|
68
|
-
`)}function
|
|
68
|
+
`)}function f(e){const t=e.stipplePattern;return t?p(e.stipplePattern)/t.pixelRatio:1}const m=.4;export{c as LineStipple,f as computePixelSize};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{getBasisTranscoder as e}from"../../../../libs/basisu/BasisUTranscoder.js";import{CompressedTextureFormat as t}from"../../../webgl/enums.js";import{Texture as n}from"../../../webgl/Texture.js";import{
|
|
5
|
+
import{getBasisTranscoder as e}from"../../../../libs/basisu/BasisUTranscoder.js";import{CompressedTextureFormat as t}from"../../../webgl/enums.js";import{Texture as n}from"../../../webgl/Texture.js";import{getFormatBytesPerElement as s}from"../../../webgl/Util.js";let r=null,i=null;async function a(){return null==i&&(i=e(),r=await i),i}function l(e,t){if(null==r)return e.byteLength;const n=new r.BasisFile(new Uint8Array(e)),s=u(n)?o(n.getNumLevels(0),n.getHasAlpha(),n.getImageWidth(0,0),n.getImageHeight(0,0),t):0;return n.close(),n.delete(),s}function g(e,t){if(null==r)return e.byteLength;const n=new r.KTX2File(new Uint8Array(e)),s=c(n)?o(n.getLevels(),n.getHasAlpha(),n.getWidth(),n.getHeight(),t):0;return n.close(),n.delete(),s}function o(e,n,r,i,a){const l=s(n?t.COMPRESSED_RGBA8_ETC2_EAC:t.COMPRESSED_RGB8_ETC2),g=a&&e>1?(4**e-1)/(3*4**(e-1)):1;return Math.ceil(r*i*l*g)}function u(e){return e.getNumImages()>=1&&!e.isUASTC()}function c(e){return e.getFaces()>=1&&e.isETC1S()}async function m(e,t,n){null==r&&(r=await a());const s=new r.BasisFile(new Uint8Array(n));if(!u(s))return null;s.startTranscoding();const i=h(e,t,s.getNumLevels(0),s.getHasAlpha(),s.getImageWidth(0,0),s.getImageHeight(0,0),(e,t)=>s.getImageTranscodedSizeInBytes(0,e,t),(e,t,n)=>s.transcodeImage(n,0,e,t,0,0));return s.close(),s.delete(),i}async function T(e,t,n){null==r&&(r=await a());const s=new r.KTX2File(new Uint8Array(n));if(!c(s))return null;s.startTranscoding();const i=h(e,t,s.getLevels(),s.getHasAlpha(),s.getWidth(),s.getHeight(),(e,t)=>s.getImageTranscodedSizeInBytes(e,0,0,t),(e,t,n)=>s.transcodeImage(n,e,0,0,t,0,-1,-1));return s.close(),s.delete(),i}function h(e,s,r,i,a,l,g,o){const{compressedTextureETC:u,compressedTextureS3TC:c}=e.capabilities,[m,T]=u?i?[1,t.COMPRESSED_RGBA8_ETC2_EAC]:[0,t.COMPRESSED_RGB8_ETC2]:c?i?[3,t.COMPRESSED_RGBA_S3TC_DXT5_EXT]:[2,t.COMPRESSED_RGB_S3TC_DXT1_EXT]:[13,6408],h=s.hasMipmap?r:Math.min(1,r),d=[];for(let t=0;t<h;t++)d.push(new Uint8Array(g(t,m))),o(t,m,d[t]);return s.internalFormat=T,s.hasMipmap=d.length>1,s.samplingMode=s.hasMipmap?9987:9729,s.width=a,s.height=l,new n(e,s,{type:"compressed",levels:d})}export{c as checkKTX2,m as createTextureBasis,T as createTextureKTX2,l as estimateMemoryBasis,g as estimateMemoryKTX2,a as loadBasisTranscoder};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../../core/has.js";import e from"../../../../core/Error.js";import{EventEmitter as t}from"../../../../core/Evented.js";import{disposeMaybe as r,removeMaybe as
|
|
5
|
+
import"../../../../core/has.js";import e from"../../../../core/Error.js";import{EventEmitter as t}from"../../../../core/Evented.js";import{disposeMaybe as r,removeMaybe as i}from"../../../../core/maybe.js";import{throwIfAborted as a,onAbort as s,createAbortError as o}from"../../../../core/promiseUtils.js";import{isUint8Array as n,isArrayBuffer as l,isTypedArray as m}from"../../../../core/typedArrayUtil.js";import{generateUID as h}from"../../../../core/uid.js";import{isBlobProtocol as p,isDataProtocol as d}from"../../../../core/urlUtils.js";import{whenVideoPlayable as _}from"../../../../layers/support/videoUtils.js";import{requestImage as u}from"../../../../support/requestImageUtils.js";import{loadImageAsync as c}from"../../../../support/requestUtils.js";import{createTextureKTX2 as g,createTextureBasis as T,estimateMemoryKTX2 as x,estimateMemoryBasis as y}from"./BasisUtil.js";import{createDDSTexture as f}from"./DDSUtil.js";import{ensureImageMaxSize as F}from"./textureUtils.js";import{assert as E}from"./Util.js";import{Texture as D}from"../../../webgl/Texture.js";import{TextureDescriptor as w}from"../../../webgl/TextureDescriptor.js";import{getFormatComponents as A}from"../../../webgl/Util.js";class M{constructor(e,r){this._data=e,this.id=h(),this.events=new t,this._parameters={...j,...r},this._startPreload(e)}dispose(){this.unload(),this._data=this.update=void 0}_startPreload(e){e instanceof HTMLVideoElement?(this.update=t=>this._update(e,t),this._startPreloadVideoElement(e)):e instanceof HTMLImageElement&&this._startPreloadImageElement(e)}_startPreloadVideoElement(e){if(!(p(e.src)||"auto"===e.preload&&e.crossOrigin)&&(e.preload="auto",e.crossOrigin="anonymous",e.src=e.src,e.paused&&e.autoplay)){const t=[];_(e,e=>t.push(e)).then(()=>{e.play()}).finally(()=>t.forEach(e=>e.remove()))}}_startPreloadImageElement(e){d(e.src)||p(e.src)||e.crossOrigin||(e.crossOrigin="anonymous",e.src=e.src)}_createDescriptor(e){const t=new w;return t.wrapMode=this._parameters.wrap??10497,t.flipped=!this._parameters.noUnpackFlip,t.samplingMode=this._parameters.mipmap?9987:9729,t.hasMipmap=!!this._parameters.mipmap,t.preMultiplyAlpha=!!this._parameters.preMultiplyAlpha,t.maxAnisotropy=this._parameters.maxAnisotropy??(this._parameters.mipmap?e.parameters.maxMaxAnisotropy:1),t.dataType=this._parameters.dataType??t.dataType,t.pixelFormat=this._parameters.pixelFormat??t.pixelFormat,t.internalFormat=this._parameters.internalFormat??t.internalFormat,t}get glTexture(){return this._glTexture??this._emptyTexture}get loaded(){return null!=this._glTexture}get usedMemory(){return this._glTexture?.usedMemory||v(this._data,this._parameters)}load(e){if(this._loadingPromise)return this._loadingPromise;if(this._glTexture)return this._glTexture;const t=this._data;return null==t?(this._glTexture=new D(e,this._createDescriptor(e),null),this._glTexture):(this._emptyTexture=e.emptyTexture,this._parameters.reloadable||(this._data=void 0),"string"==typeof t?this._loadFromURL(e,t):t instanceof Image?this._loadFromImageElement(e,t):t instanceof HTMLVideoElement?this._loadFromVideoElement(e,t):t instanceof ImageData||t instanceof HTMLCanvasElement?this._loadFromImage(e,t):n(t)&&"image/vnd-ms.dds"===this._parameters.encoding?this._loadFromDDSData(e,t):l(t)&&"image/vnd-ms.dds"===this._parameters.encoding?this._loadFromDDSData(e,new Uint8Array(t)):(l(t)||n(t))&&"image/ktx2"===this._parameters.encoding?this._loadFromKTX2(e,t):(l(t)||n(t))&&"image/x.basis"===this._parameters.encoding?this._loadFromBasis(e,t):l(t)?this._loadFromPixelData(e,new Uint8Array(t)):m(t)?this._loadFromPixelData(e,t):null)}_update(e,t){return null==this._glTexture||e.readyState<HTMLMediaElement.HAVE_CURRENT_DATA||t===e.currentTime?t:(this._glTexture.setData(e),this._glTexture.descriptor.hasMipmap&&this._glTexture.generateMipmap(),this._parameters.updateCallback&&this._parameters.updateCallback(),e.currentTime)}_loadFromDDSData(e,t){return this._glTexture=f(e,this._createDescriptor(e),t),this._emptyTexture=null,this._glTexture}_loadFromKTX2(e,t){return this._loadAsync(()=>g(e,this._createDescriptor(e),t).then(e=>(this._glTexture=e,e)))}_loadFromBasis(e,t){return this._loadAsync(()=>T(e,this._createDescriptor(e),t).then(e=>(this._glTexture=e,e)))}_loadFromPixelData(e,t){E(this._parameters.width>0&&this._parameters.height>0);const r=this._createDescriptor(e);return 6407!==r.pixelFormat&&6408!==r.pixelFormat||(r.compress=this._parameters.compressionOptions),r.width=this._parameters.width??0,r.height=this._parameters.height??0,this._glTexture=new D(e,r,t),this._glTexture}_loadFromURL(e,t){return this._loadAsync(async r=>{const i=await u(t,{signal:r});return a(r),this._loadFromImage(e,i)})}_loadFromImageElement(e,t){return t.complete?this._loadFromImage(e,t):this._loadAsync(async r=>{const i=await c(t,t.src,!1,r);return a(r),this._loadFromImage(e,i)})}_loadFromVideoElement(e,t){return t.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA?this._loadFromImage(e,t):this._loadFromVideoElementAsync(e,t)}_loadFromVideoElementAsync(t,r){return this._loadAsync(a=>new Promise((n,l)=>{const m=()=>{r.removeEventListener("loadeddata",h),r.removeEventListener("error",p),i(d)},h=()=>{r.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA&&(m(),n(this._loadFromImage(t,r)))},p=t=>{m(),l(t||new e("texture:load-error","Failed to load video"))};r.addEventListener("loadeddata",h),r.addEventListener("error",p);const d=s(a,()=>p(o()))}))}_loadFromImage(e,t){let r=t;r instanceof HTMLVideoElement||(r=F(r,e.parameters));const i=U(r);this._parameters.width=i.width,this._parameters.height=i.height;const a=this._createDescriptor(e);return a.width=i.width,a.height=i.height,a.compress=this._parameters.compressionOptions,this._glTexture=new D(e,a,r),this._emptyTexture=null,this.events.emit("loaded"),this._glTexture}_loadAsync(e){const t=new AbortController;this._loadingController=t;const r=e(t.signal);this._loadingPromise=r;const i=()=>{this._loadingController===t&&(this._loadingController=null),this._loadingPromise===r&&(this._loadingPromise=null),this._emptyTexture=null};return r.then(i,i),r}unload(){if(this._glTexture=r(this._glTexture),this._emptyTexture=null,null!=this._loadingController){const e=this._loadingController;this._loadingController=null,this._loadingPromise=null,e.abort()}this.events.emit("unloaded")}get parameters(){return this._parameters}}function v(e,t){if(null==e)return 0;if(l(e)||n(e))return"image/ktx2"===t.encoding?x(e,!!t.mipmap):"image/x.basis"===t.encoding?y(e,!!t.mipmap):e.byteLength;const{width:r,height:i}=e instanceof Image||e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement?U(e):t,a=t.pixelFormat??6408,s=A(a);return(t.mipmap?4/3:1)*r*i*s||0}function U(e){return e instanceof HTMLVideoElement?{width:e.videoWidth,height:e.videoHeight}:e}const j={wrap:{s:10497,t:10497},mipmap:!0,noUnpackFlip:!1,preMultiplyAlpha:!1};export{M as Texture};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
class s{constructor(s,o){this.vao=s,this.instanceCount=o}dispose(){this.vao.disposeVAOOnly()}}export{s as InstancedCommandVAO};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{NestedMap as s}from"../../../../../core/NestedMap.js";class a{constructor(){this.commandVAOs=new s,this.drawCommandsDefault=new Array,this.drawCommandsHighlights=new Map,this.drawCommandsOccludees=new Array,this.drawCommandsShadowHighlightRest=new Array}clear(){this.commandVAOs.clear(),this.drawCommandsDefault.length=0,this.drawCommandsHighlights.clear(),this.drawCommandsOccludees.length=0,this.drawCommandsShadowHighlightRest.length=0}dispose(){for(const s of this.commandVAOs.values())s.dispose();this.clear()}}export{a as InstancedCommandVAOs};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{getOrCreateMapValue as
|
|
5
|
+
import{getOrCreateMapValue as s}from"../../../../../core/MapUtils.js";import t from"../../../../../core/PooledArray.js";import{BufferRange as e}from"./BufferRange.js";import{DrawCommand as n}from"./DrawCommand.js";import{InstancedCommandVAO as a}from"./InstancedCommandVAO.js";import{InstancedCommandVAOs as i}from"./InstancedCommandVAOs.js";import{defaultHighlightName as o}from"../../../../support/HighlightDefaults.js";class h{constructor(s){this.targetBuffer=s,this.vaoEndElement=0,this._numElements=0,this._instances=new Map,this.holes=new t({allocator:s=>s||new e,deallocator:null}),this.hasHiddenInstances=!1,this.hasOccludees=!1,this.drawCommandsDirty=!0,this.highlightNames=new Set,this.drawCommandsDefault=d(),this.drawCommandsHighlights=new Map,this.drawCommandsOccludees=d(),this.drawCommandsShadowHighlightRest=d(),this._instancedCommandVAOs=null}get numElements(){return this._numElements}get instances(){return this._instances}get writeableInstances(){return this._instances}get hasHighlights(){return this.highlightNames.size>0}get instancedCommandVAOs(){return this._instancedCommandVAOs}resetInstanceSummary(){this.hasHiddenInstances=!1,this.hasOccludees=!1,this.highlightNames.clear()}updateIfDrawCommandsDirty(s){if(this.drawCommandsDirty){this.resetInstanceSummary();for(const s of this.instances.values())this.updateDrawState(s);this.updateDrawCommands(s)}}addInstance(s,t){this.deleteInstance(s),this._instances.set(s,t),this._numElements+=t.numElements}deleteInstance(s){const t=this._instances.get(s);t&&(this._numElements-=t.numElements,this._instances.delete(s))}updateInstances(){let s=0;for(const t of this._instances.values())s+=t.numElements,this.updateDrawState(t);this._numElements=s}updateDrawState(s){if(s.isVisible){const{highlightName:t}=s;t&&this.highlightNames.add(t),s.hasOccludees&&(this.hasOccludees=!0)}else this.hasHiddenInstances=!0}updateDrawCommands(s){this._updateDrawCommands(s),this._updateInstancedCommandVAOs()}_updateDrawCommands(s){if(this.drawCommandsDefault.clear(),this.drawCommandsOccludees.clear(),this.drawCommandsDirty=!1,0===this._instances.size)return;const{sortedInstances:t}=this;if(this._updateHighlightDrawCommands(s,t),!this.needsMultipleCommands){const s=this.drawCommandsDefault.pushNew(),t=this.holes.front();return this.vao&&1===this.holes.length&&t.to===this.vaoEndElement?(s.first=0,void(s.count=t.from)):(s.first=1/0,s.count=0,this._instances.forEach(t=>{s.first=Math.min(s.first,t.from),s.count=Math.max(s.count,t.to)}),void(s.count-=s.first))}for(const e of t)e.isVisible&&c(e.hasOccludees?this.drawCommandsOccludees:this.drawCommandsDefault,e)}get sortedInstances(){return Array.from(this._instances.values()).sort((s,t)=>s.from===t.from?s.to-t.to:s.from-t.from)}updateHighlights(s){this.highlightNames.clear();const t=this.sortedInstances;for(const e of t)e.updateHighlightOptions(s),e.isVisible&&e.highlightName&&this.highlightNames.add(e.highlightName);this._updateHighlightDrawCommands(s),this._updateInstancedCommandVAOs()}_updateHighlightDrawCommands(t,e=this.sortedInstances){const{drawCommandsHighlights:n,drawCommandsShadowHighlightRest:a}=this;n.clear(),a.clear();for(const i of e){if(i.updateHighlightOptions(t),!i.isVisible)continue;const{highlightName:e}=i;if(e){this.highlightNames.add(e);c(s(n,e,d),i)}e&&e===o||c(a,i)}}_updateInstancedCommandVAOs(){const s=this.vao;if("geometry"===this.targetBuffer||null==s)return;this._instancedCommandVAOs??=new i;const t=this._instancedCommandVAOs,e=t.commandVAOs.copy();t.clear();const n=t.commandVAOs,o=(t,i)=>{for(const o of t){const{first:t,count:h}=o,m=n.get(t,h)??e.pop(t,h)??new a(s.shallowCloneWithBaseInstances(new Map([["instances",o.first]])),o.count);n.set(t,h,m),i.push(m)}};o(this.drawCommandsDefault,t.drawCommandsDefault);for(const[a,i]of this.drawCommandsHighlights){const s=new Array;o(i,s),t.drawCommandsHighlights.set(a,s)}o(this.drawCommandsOccludees,t.drawCommandsOccludees),o(this.drawCommandsShadowHighlightRest,t.drawCommandsShadowHighlightRest);for(const a of e.values())a.dispose();e.clear()}get needsMultipleCommands(){return this.hasOccludees||this.hasHighlights||this.hasHiddenInstances}}function m(s){return null!=s.vao}function r(s){return s?"instances":"geometry"}function d(){return new t({allocator:s=>s||new n,deallocator:s=>s})}function c(s,t){const e=s.back();if(null==e){const e=s.pushNew();return e.first=t.from,void(e.count=t.numElements)}if(l(e,t)){const s=t.from-e.first+t.numElements;e.count=s}else{const e=s.pushNew();e.first=t.from,e.count=t.numElements}}function l(s,t){return s.first+s.count>=t.from}export{h as PerBufferData,r as getTargetBuffer,m as hasVao};
|