@arcgis/core 4.32.0-next.20241111 → 4.32.0-next.20241113

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/10a2b8c562c56653b1e0.js +1 -0
  3. package/assets/esri/core/workers/chunks/310aedf8800cf7fbee23.js +1 -0
  4. package/assets/esri/core/workers/chunks/39accea1f8c9a75058fc.js +1 -0
  5. package/assets/esri/core/workers/chunks/{695e8174dc6bab4256e5.js → 3bc3a78ce8de37f5c546.js} +23 -23
  6. package/assets/esri/core/workers/chunks/3daf5edc6641d2fedac3.js +1 -0
  7. package/assets/esri/core/workers/chunks/48235ecd4923bba7a5ff.js +1 -0
  8. package/assets/esri/core/workers/chunks/4ac695f065f48009ff28.js +51 -0
  9. package/assets/esri/core/workers/chunks/54ec7ef66430cdbbfee3.js +1 -0
  10. package/assets/esri/core/workers/chunks/610d621a8296b77fb16c.js +1 -0
  11. package/assets/esri/core/workers/chunks/80d17e1e77e116319367.js +1 -0
  12. package/assets/esri/core/workers/chunks/8be3a985e9a9de39c4fa.js +1 -0
  13. package/assets/esri/core/workers/chunks/aa1af5e799697b876b7b.js +1 -0
  14. package/assets/esri/core/workers/chunks/{ab6dd330da1f058f7296.js → ad44b0f749e5ca5a9772.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{7ef61b70338afa0b5573.js → e93f863337e1fedf1803.js} +1 -1
  16. package/assets/esri/core/workers/chunks/edcc00babfed0a80c0bd.js +1 -0
  17. package/assets/esri/core/workers/chunks/fb6f6093f16e9be1fcd0.js +1 -0
  18. package/chunks/BlendWeights.glsl.js +5 -8
  19. package/chunks/LineMarker.glsl.js +39 -39
  20. package/chunks/vec3.js +1 -1
  21. package/chunks/vec4.js +1 -1
  22. package/colorUtils.js +1 -1
  23. package/geometry/support/buffer/math/vec3.js +1 -1
  24. package/geometry/support/buffer/math/vec4.js +1 -1
  25. package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
  26. package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
  27. package/interfaces.d.ts +40685 -49782
  28. package/layers/WCSLayer.js +1 -1
  29. package/layers/mixins/ImageryTileMixin.js +1 -1
  30. package/package.json +1 -1
  31. package/support/revision.js +1 -1
  32. package/views/2d/engine/webgl/shaderGraph/techniques/markers/ComputedMarkerParams.js +1 -1
  33. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  34. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  35. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +15 -15
  36. package/views/3d/webgl-engine/core/shaderLibrary/shading/TerrainDepthTest.glsl.js +4 -4
  37. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  38. package/widgets/BatchAttributeForm/ReactiveGraphic.js +1 -1
  39. package/widgets/BatchAttributeForm/inputs/BatchFormInputs.js +1 -1
  40. package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
  41. package/widgets/BatchAttributeForm/inputs/support/createBatchFormInputs.js +1 -1
  42. package/widgets/BatchAttributeForm/inputs/support/inputUtils.js +1 -1
  43. package/widgets/BatchAttributeForm.js +1 -1
  44. package/widgets/Editor/Edits.js +1 -1
  45. package/widgets/FeatureForm/FieldInput.js +1 -1
  46. package/widgets/FeatureForm/featureFormUtils.js +1 -1
  47. package/widgets/FeatureForm.js +1 -1
  48. package/widgets/support/forms/formUtils.js +1 -1
  49. package/assets/esri/core/workers/chunks/03192a2af5707c30b5bb.js +0 -1
  50. package/assets/esri/core/workers/chunks/0da3cf883a2c00800f30.js +0 -1
  51. package/assets/esri/core/workers/chunks/2909b3a6b71b34e30695.js +0 -1
  52. package/assets/esri/core/workers/chunks/2a9667166327be968064.js +0 -1
  53. package/assets/esri/core/workers/chunks/40d98cab2a88dcdeb783.js +0 -1
  54. package/assets/esri/core/workers/chunks/434ae6a5db87b5364eed.js +0 -51
  55. package/assets/esri/core/workers/chunks/485907740fd791f9b307.js +0 -1
  56. package/assets/esri/core/workers/chunks/5cdc601c5e1769741105.js +0 -1
  57. package/assets/esri/core/workers/chunks/baafc01c75774103bbed.js +0 -1
  58. package/assets/esri/core/workers/chunks/bf83852bd12b6d157b15.js +0 -1
  59. package/assets/esri/core/workers/chunks/bfc0c262e5a1e81a7717.js +0 -1
  60. package/assets/esri/core/workers/chunks/c76174977ac5059e5cdd.js +0 -1
  61. package/assets/esri/core/workers/chunks/de1fcf2a928e8ccb270d.js +0 -1
  62. package/views/3d/webgl-engine/materials/DefaultMaterial_COLOR_GAMMA.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../core/Logger.js";import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import{deg2rad as s}from"../../../../../core/mathUtils.js";import{exactEquals as r}from"../../../../../core/libs/gl-matrix-2/math/quat.js";import{IDENTITY as i,clone as a}from"../../../../../core/libs/gl-matrix-2/factories/quatf64.js";import{p as o}from"../../../../../chunks/vec32.js";import{ZEROS as n,clone as l,ONES as c}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import u from"../../../MeshMaterialMetallicRoughness.js";import{convertVertexSpace as h}from"../../vertexSpaceConversion.js";import{Buffer as f}from"./buffer.js";import{smoothNormals as m}from"./geometry.js";import{BufferOutputType as p,ImageOutputType as d,AttributeType as g,TargetBuffer as x,AlphaMode as _}from"./types.js";import{imageToArrayBuffer as T,imageToDataURI as R}from"./imageutils.js";import{isEncodedMeshTexture as A}from"../../../../../views/3d/glTF/internal/resourceUtils.js";import{DataType as b,TextureWrapMode as E}from"../../../../../views/webgl/enums.js";const M=()=>e.getLogger("esri.geometry.support.meshUtils.exporters.gltf.gltf");class O{constructor(e,t){this.options=t,this._materialMap=new Array,this._imageMap=new Map,this._textureMap=new Map,this.gltf={asset:{version:"2.0",copyright:e.copyright,generator:e.generator},extras:{output:t.output,binChunkBuffer:null,promises:[]}},this._addScenes(e)}_addScenes(e){this.gltf.scene=e.defaultScene;const t=this.gltf.extras,s=t.output.buffer===p.GLB||t.output.image===d.GLB;s&&(t.binChunkBuffer=new f(this.gltf)),e.forEachScene((e=>{this._addScene(e)})),s&&t.binChunkBuffer.finalize()}_addScene(e){this.gltf.scenes||(this.gltf.scenes=[]);const t={};e.name&&(t.name=e.name),e.forEachNode((e=>{t.nodes||(t.nodes=[]),t.nodes.push(...this._addNodes(e))})),this.gltf.scenes.push(t)}_addNodes(e){this.gltf.nodes||(this.gltf.nodes=[]);const t={};e.name&&(t.name=e.name);const s=e.translation;o(s,n)||(t.translation=l(s));const u=e.rotation;r(u,i)||(t.rotation=a(u));const h=e.scale;o(h,c)||(t.scale=l(h));const f=this.gltf.nodes.length;if(this.gltf.nodes.push(t),e.mesh&&e.mesh.vertexAttributes.position){const s=this._createMeshes(e.mesh),r=[f];if(1===s.length)this._addMesh(t,s[0]);else for(const e of s){const t={};this._addMesh(t,e),r.push(this.gltf.nodes.length),this.gltf.nodes.push(t)}return r}return e.forEachNode((e=>{t.children||(t.children=[]),t.children.push(...this._addNodes(e))})),[f]}_addMesh(e,t){this.gltf.meshes??=[];const s=this.gltf.meshes.length;this.gltf.meshes.push(t),e.mesh=s}_createMeshes(e){const t=this.gltf.extras,s=t.output.buffer===p.GLB;let r;r=s?t.binChunkBuffer:new f(this.gltf);const i=this.options.origin,a=e.vertexSpace.clone();a.origin=[i.x,i.y,i.z??0];const o=h({vertexAttributes:e.vertexAttributes,vertexSpace:e.vertexSpace,transform:this.options?.ignoreLocalTransform?null:e.transform,spatialReference:e.spatialReference},a,{targetUnit:this.options.unitConversionDisabled?void 0:"meters"});if(!o)return[];m(e,o),w(o);const{position:n,normal:l,tangent:c}=o,{uv:u,color:d}=e.vertexAttributes,_=r.addBufferView(b.FLOAT,g.VEC3,x.ARRAY_BUFFER);let T,R,A,E;l&&(T=r.addBufferView(b.FLOAT,g.VEC3,x.ARRAY_BUFFER)),u&&(R=r.addBufferView(b.FLOAT,g.VEC2,x.ARRAY_BUFFER)),c&&(A=r.addBufferView(b.FLOAT,g.VEC4,x.ARRAY_BUFFER)),d&&(E=r.addBufferView(b.UNSIGNED_BYTE,g.VEC4,x.ARRAY_BUFFER)),_.startAccessor("POSITION"),T&&T.startAccessor("NORMAL"),R&&R.startAccessor("TEXCOORD_0"),A&&A.startAccessor("TANGENT"),E&&E.startAccessor("COLOR_0");const M=o.position.length/3;for(let h=0;h<M;++h)_.push(n[3*h]),_.push(n[3*h+1]),_.push(n[3*h+2]),T&&null!=l&&(T.push(l[3*h]),T.push(l[3*h+1]),T.push(l[3*h+2])),R&&null!=u&&(R.push(u[2*h]),R.push(u[2*h+1])),A&&null!=c&&(A.push(c[4*h]),A.push(c[4*h+1]),A.push(c[4*h+2]),A.push(c[4*h+3])),E&&null!=d&&(E.push(d[4*h]),E.push(d[4*h+1]),E.push(d[4*h+2]),E.push(d[4*h+3]));const O=_.endAccessor(),v=this._addAccessor(_.index,O);let C,I,N,S,B;if(T){const e=T.endAccessor();C=this._addAccessor(T.index,e)}if(R){const e=R.endAccessor();I=this._addAccessor(R.index,e)}if(A){const e=A.endAccessor();N=this._addAccessor(A.index,e)}if(E){const e=E.endAccessor();S=this._addAccessor(E.index,e)}const L=[];return e.components&&e.components.length>0&&e.components[0].faces?(B=r.addBufferView(b.UNSIGNED_INT,g.SCALAR,x.ELEMENT_ARRAY_BUFFER),this._addMeshVertexIndexed(B,e.components,L,v,C,I,N,S)):this._addMeshVertexNonIndexed(e.components,L,v,C,I,N,S),_.finalize(),T&&T.finalize(),R&&R.finalize(),A&&A.finalize(),B&&B.finalize(),E&&E.finalize(),s||r.finalize(),L}_addMaterial(e){if(null===e)return;const t=this._materialMap.indexOf(e);if(-1!==t)return t;this.gltf.materials||(this.gltf.materials=[]);const s={};switch(e.alphaMode){case"mask":s.alphaMode=_.MASK;break;case"auto":case"blend":s.alphaMode=_.BLEND}s.alphaCutoff=e.alphaCutoff,e.doubleSided&&(s.doubleSided=e.doubleSided),s.pbrMetallicRoughness={};const r=e=>e**2.1,i=e=>{const t=e.toRgba();return t[0]=r(t[0]/255),t[1]=r(t[1]/255),t[2]=r(t[2]/255),t};if(null!=e.color&&(s.pbrMetallicRoughness.baseColorFactor=i(e.color)),null!=e.colorTexture&&(s.pbrMetallicRoughness.baseColorTexture=this._createTextureInfo(e.colorTexture,e.colorTextureTransform)),null!=e.normalTexture&&(s.normalTexture=this._createTextureInfo(e.normalTexture,e.normalTextureTransform)),e instanceof u){if(null!=e.emissiveTexture&&(s.emissiveTexture=this._createTextureInfo(e.emissiveTexture,e.emissiveTextureTransform)),null!=e.emissiveColor){const t=i(e.emissiveColor);s.emissiveFactor=[t[0],t[1],t[2]]}null!=e.occlusionTexture&&(s.occlusionTexture=this._createTextureInfo(e.occlusionTexture,e.occlusionTextureTransform)),null!=e.metallicRoughnessTexture&&(s.pbrMetallicRoughness.metallicRoughnessTexture=this._createTextureInfo(e.metallicRoughnessTexture,e.metallicRoughnessTextureTransform)),s.pbrMetallicRoughness.metallicFactor=e.metallic,s.pbrMetallicRoughness.roughnessFactor=e.roughness}else s.pbrMetallicRoughness.metallicFactor=1,s.pbrMetallicRoughness.roughnessFactor=1,M().warnOnce("Meshes exported to GLTF without MeshMaterialMetallicRoughness material will appear different when imported back.");const a=this.gltf.materials.length;return this.gltf.materials.push(s),this._materialMap.push(e),a}_createTextureInfo(e,t){const r={index:this._addTexture(e)};return t?(r.extensions||(r.extensions={}),r.extensions.KHR_texture_transform={scale:t.scale,offset:t.offset,rotation:s(t.rotation)},r):r}_addTexture(e){const s=this.gltf.textures??[];return this.gltf.textures=s,t(this._textureMap,e,(()=>{const t={sampler:this._addSampler(e),source:this._addImage(e)},r=s.length;return s.push(t),r}))}_addImage(e){const t=this._imageMap.get(e);if(null!=t)return t;this.gltf.images||(this.gltf.images=[]);const s={};if(e.url)s.uri=e.url;else{const t=e.data;s.extras=t;for(let e=0;e<this.gltf.images.length;++e)if(t===this.gltf.images[e].extras)return e;const r=this.gltf.extras;switch(r.output.image){case d.GLB:{const e=r.binChunkBuffer.addBufferView(b.UNSIGNED_BYTE,g.SCALAR);if(A(t))null!=t.data&&e.writeOutToBuffer(t.data,0);else{const i=T(t,this.options.signal).then((({data:e,type:t})=>(s.mimeType=t,e)));r.promises.push(e.writeAsync(i).then((()=>{e.finalize()})))}s.bufferView=e.index;break}case d.DataURI:if(A(t)){M().warnOnce("Image export for basis compressed textures not available.");break}s.uri=R(t);break;default:if(A(t)){M().warnOnce("Image export for basis compressed textures not available.");break}r.promises.push(T(t,this.options.signal).then((({data:e,type:t})=>{s.uri=e,s.mimeType=t})))}}const r=this.gltf.images.length;return this.gltf.images.push(s),this._imageMap.set(e,r),r}_addSampler(e){this.gltf.samplers||(this.gltf.samplers=[]);let t=E.REPEAT,s=E.REPEAT;if("string"==typeof e.wrap)switch(e.wrap){case"clamp":t=E.CLAMP_TO_EDGE,s=E.CLAMP_TO_EDGE;break;case"mirror":t=E.MIRRORED_REPEAT,s=E.MIRRORED_REPEAT}else{switch(e.wrap.vertical){case"clamp":s=E.CLAMP_TO_EDGE;break;case"mirror":s=E.MIRRORED_REPEAT}switch(e.wrap.horizontal){case"clamp":t=E.CLAMP_TO_EDGE;break;case"mirror":t=E.MIRRORED_REPEAT}}const r={wrapS:t,wrapT:s};for(let a=0;a<this.gltf.samplers.length;++a)if(JSON.stringify(r)===JSON.stringify(this.gltf.samplers[a]))return a;const i=this.gltf.samplers.length;return this.gltf.samplers.push(r),i}_addAccessor(e,t){this.gltf.accessors||(this.gltf.accessors=[]);const s={bufferView:e,byteOffset:t.byteOffset,componentType:t.componentType,count:t.count,type:t.type,min:t.min,max:t.max,name:t.name};t.normalized&&(s.normalized=!0);const r=this.gltf.accessors.length;return this.gltf.accessors.push(s),r}_addMeshVertexIndexed(e,t,s,r,i,a,o,n){const l=new Map;for(const c of t){e.startAccessor("INDICES");for(let s=0;s<c.faces.length;++s)e.push(c.faces[s]);const t=e.endAccessor(),u={attributes:{POSITION:r},indices:this._addAccessor(e.index,t),material:this._addMaterial(c.material)};i&&"flat"!==c.shading&&(u.attributes.NORMAL=i),a&&(u.attributes.TEXCOORD_0=a),o&&"flat"!==c.shading&&(u.attributes.TANGENT=o),n&&(u.attributes.COLOR_0=n);const h=l.get(c.name);if(h)h.primitives.push(u);else{const e={name:c.name,primitives:[u]};l.set(c.name,e),s.push(e)}}}_addMeshVertexNonIndexed(e,t,s,r,i,a,o){const n={primitives:[]};t.push(n);const l={attributes:{POSITION:s}};r&&(l.attributes.NORMAL=r),i&&(l.attributes.TEXCOORD_0=i),a&&(l.attributes.TANGENT=a),o&&(l.attributes.COLOR_0=o),e&&(l.material=this._addMaterial(e[0].material)),n.primitives.push(l)}}function w({position:e,normal:t,tangent:s}){v(e,3),v(t,3),v(s,4)}function v(e,t){if(null!=e)for(let s=1,r=2;s<e.length;s+=t,r+=t){const t=e[s],i=e[r];e[s]=i,e[r]=-t}}export{O as GLTF};
5
+ import{colorGamma as e}from"../../../../../colorUtils.js";import t from"../../../../../core/Logger.js";import{getOrCreateMapValue as s}from"../../../../../core/MapUtils.js";import{deg2rad as r}from"../../../../../core/mathUtils.js";import{exactEquals as i}from"../../../../../core/libs/gl-matrix-2/math/quat.js";import{IDENTITY as o,clone as a}from"../../../../../core/libs/gl-matrix-2/factories/quatf64.js";import{p as n}from"../../../../../chunks/vec32.js";import{ZEROS as l,clone as c,ONES as u}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import h from"../../../MeshMaterialMetallicRoughness.js";import{convertVertexSpace as f}from"../../vertexSpaceConversion.js";import{Buffer as m}from"./buffer.js";import{smoothNormals as p}from"./geometry.js";import{BufferOutputType as d,ImageOutputType as g,AttributeType as x,TargetBuffer as _,AlphaMode as T}from"./types.js";import{imageToArrayBuffer as R,imageToDataURI as A}from"./imageutils.js";import{isEncodedMeshTexture as b}from"../../../../../views/3d/glTF/internal/resourceUtils.js";import{DataType as M,TextureWrapMode as E}from"../../../../../views/webgl/enums.js";const O=()=>t.getLogger("esri.geometry.support.meshUtils.exporters.gltf.gltf");class w{constructor(e,t){this.options=t,this._materialMap=new Array,this._imageMap=new Map,this._textureMap=new Map,this.gltf={asset:{version:"2.0",copyright:e.copyright,generator:e.generator},extras:{output:t.output,binChunkBuffer:null,promises:[]}},this._addScenes(e)}_addScenes(e){this.gltf.scene=e.defaultScene;const t=this.gltf.extras,s=t.output.buffer===d.GLB||t.output.image===g.GLB;s&&(t.binChunkBuffer=new m(this.gltf)),e.forEachScene((e=>{this._addScene(e)})),s&&t.binChunkBuffer.finalize()}_addScene(e){this.gltf.scenes||(this.gltf.scenes=[]);const t={};e.name&&(t.name=e.name),e.forEachNode((e=>{t.nodes||(t.nodes=[]),t.nodes.push(...this._addNodes(e))})),this.gltf.scenes.push(t)}_addNodes(e){this.gltf.nodes||(this.gltf.nodes=[]);const t={};e.name&&(t.name=e.name);const s=e.translation;n(s,l)||(t.translation=c(s));const r=e.rotation;i(r,o)||(t.rotation=a(r));const h=e.scale;n(h,u)||(t.scale=c(h));const f=this.gltf.nodes.length;if(this.gltf.nodes.push(t),e.mesh&&e.mesh.vertexAttributes.position){const s=this._createMeshes(e.mesh),r=[f];if(1===s.length)this._addMesh(t,s[0]);else for(const e of s){const t={};this._addMesh(t,e),r.push(this.gltf.nodes.length),this.gltf.nodes.push(t)}return r}return e.forEachNode((e=>{t.children||(t.children=[]),t.children.push(...this._addNodes(e))})),[f]}_addMesh(e,t){this.gltf.meshes??=[];const s=this.gltf.meshes.length;this.gltf.meshes.push(t),e.mesh=s}_createMeshes(e){const t=this.gltf.extras,s=t.output.buffer===d.GLB;let r;r=s?t.binChunkBuffer:new m(this.gltf);const i=this.options.origin,o=e.vertexSpace.clone();o.origin=[i.x,i.y,i.z??0];const a=f({vertexAttributes:e.vertexAttributes,vertexSpace:e.vertexSpace,transform:this.options?.ignoreLocalTransform?null:e.transform,spatialReference:e.spatialReference},o,{targetUnit:this.options.unitConversionDisabled?void 0:"meters"});if(!a)return[];p(e,a),v(a);const{position:n,normal:l,tangent:c}=a,{uv:u,color:h}=e.vertexAttributes,g=r.addBufferView(M.FLOAT,x.VEC3,_.ARRAY_BUFFER);let T,R,A,b;l&&(T=r.addBufferView(M.FLOAT,x.VEC3,_.ARRAY_BUFFER)),u&&(R=r.addBufferView(M.FLOAT,x.VEC2,_.ARRAY_BUFFER)),c&&(A=r.addBufferView(M.FLOAT,x.VEC4,_.ARRAY_BUFFER)),h&&(b=r.addBufferView(M.FLOAT,x.VEC4,_.ARRAY_BUFFER)),g.startAccessor("POSITION"),T&&T.startAccessor("NORMAL"),R&&R.startAccessor("TEXCOORD_0"),A&&A.startAccessor("TANGENT"),b&&b.startAccessor("COLOR_0");const E=a.position.length/3;for(let f=0;f<E;++f)g.push(n[3*f]),g.push(n[3*f+1]),g.push(n[3*f+2]),T&&null!=l&&(T.push(l[3*f]),T.push(l[3*f+1]),T.push(l[3*f+2])),R&&null!=u&&(R.push(u[2*f]),R.push(u[2*f+1])),A&&null!=c&&(A.push(c[4*f]),A.push(c[4*f+1]),A.push(c[4*f+2]),A.push(c[4*f+3])),b&&null!=h&&(b.push(I(h[4*f]/255)),b.push(I(h[4*f+1]/255)),b.push(I(h[4*f+2]/255)),b.push(h[4*f+3]/255));const O=g.endAccessor(),w=this._addAccessor(g.index,O);let C,N,L,S,B;if(T){const e=T.endAccessor();C=this._addAccessor(T.index,e)}if(R){const e=R.endAccessor();N=this._addAccessor(R.index,e)}if(A){const e=A.endAccessor();L=this._addAccessor(A.index,e)}if(b){const e=b.endAccessor();S=this._addAccessor(b.index,e)}const F=[];return e.components&&e.components.length>0&&e.components[0].faces?(B=r.addBufferView(M.UNSIGNED_INT,x.SCALAR,_.ELEMENT_ARRAY_BUFFER),this._addMeshVertexIndexed(B,e.components,F,w,C,N,L,S)):this._addMeshVertexNonIndexed(e.components,F,w,C,N,L,S),g.finalize(),T&&T.finalize(),R&&R.finalize(),A&&A.finalize(),B&&B.finalize(),b&&b.finalize(),s||r.finalize(),F}_addMaterial(e){if(null===e)return;const t=this._materialMap.indexOf(e);if(-1!==t)return t;this.gltf.materials||(this.gltf.materials=[]);const s={};switch(e.alphaMode){case"mask":s.alphaMode=T.MASK;break;case"auto":case"blend":s.alphaMode=T.BLEND}s.alphaCutoff=e.alphaCutoff,e.doubleSided&&(s.doubleSided=e.doubleSided),s.pbrMetallicRoughness={};const r=e=>{const t=e.toRgba();return t[0]=I(t[0]/255),t[1]=I(t[1]/255),t[2]=I(t[2]/255),t};if(null!=e.color&&(s.pbrMetallicRoughness.baseColorFactor=r(e.color)),null!=e.colorTexture&&(s.pbrMetallicRoughness.baseColorTexture=this._createTextureInfo(e.colorTexture,e.colorTextureTransform)),null!=e.normalTexture&&(s.normalTexture=this._createTextureInfo(e.normalTexture,e.normalTextureTransform)),e instanceof h){if(null!=e.emissiveTexture&&(s.emissiveTexture=this._createTextureInfo(e.emissiveTexture,e.emissiveTextureTransform)),null!=e.emissiveColor){const t=r(e.emissiveColor);s.emissiveFactor=[t[0],t[1],t[2]]}null!=e.occlusionTexture&&(s.occlusionTexture=this._createTextureInfo(e.occlusionTexture,e.occlusionTextureTransform)),null!=e.metallicRoughnessTexture&&(s.pbrMetallicRoughness.metallicRoughnessTexture=this._createTextureInfo(e.metallicRoughnessTexture,e.metallicRoughnessTextureTransform)),s.pbrMetallicRoughness.metallicFactor=e.metallic,s.pbrMetallicRoughness.roughnessFactor=e.roughness}else s.pbrMetallicRoughness.metallicFactor=1,s.pbrMetallicRoughness.roughnessFactor=1,O().warnOnce("Meshes exported to GLTF without MeshMaterialMetallicRoughness material will appear different when imported back.");const i=this.gltf.materials.length;return this.gltf.materials.push(s),this._materialMap.push(e),i}_createTextureInfo(e,t){const s={index:this._addTexture(e)};return t?(s.extensions||(s.extensions={}),s.extensions.KHR_texture_transform={scale:t.scale,offset:t.offset,rotation:r(t.rotation)},s):s}_addTexture(e){const t=this.gltf.textures??[];return this.gltf.textures=t,s(this._textureMap,e,(()=>{const s={sampler:this._addSampler(e),source:this._addImage(e)},r=t.length;return t.push(s),r}))}_addImage(e){const t=this._imageMap.get(e);if(null!=t)return t;this.gltf.images||(this.gltf.images=[]);const s={};if(e.url)s.uri=e.url;else{const t=e.data;s.extras=t;for(let e=0;e<this.gltf.images.length;++e)if(t===this.gltf.images[e].extras)return e;const r=this.gltf.extras;switch(r.output.image){case g.GLB:{const e=r.binChunkBuffer.addBufferView(M.UNSIGNED_BYTE,x.SCALAR);if(b(t))null!=t.data&&e.writeOutToBuffer(t.data,0);else{const i=R(t,this.options.signal).then((({data:e,type:t})=>(s.mimeType=t,e)));r.promises.push(e.writeAsync(i).then((()=>{e.finalize()})))}s.bufferView=e.index;break}case g.DataURI:if(b(t)){O().warnOnce("Image export for basis compressed textures not available.");break}s.uri=A(t);break;default:if(b(t)){O().warnOnce("Image export for basis compressed textures not available.");break}r.promises.push(R(t,this.options.signal).then((({data:e,type:t})=>{s.uri=e,s.mimeType=t})))}}const r=this.gltf.images.length;return this.gltf.images.push(s),this._imageMap.set(e,r),r}_addSampler(e){this.gltf.samplers||(this.gltf.samplers=[]);let t=E.REPEAT,s=E.REPEAT;if("string"==typeof e.wrap)switch(e.wrap){case"clamp":t=E.CLAMP_TO_EDGE,s=E.CLAMP_TO_EDGE;break;case"mirror":t=E.MIRRORED_REPEAT,s=E.MIRRORED_REPEAT}else{switch(e.wrap.vertical){case"clamp":s=E.CLAMP_TO_EDGE;break;case"mirror":s=E.MIRRORED_REPEAT}switch(e.wrap.horizontal){case"clamp":t=E.CLAMP_TO_EDGE;break;case"mirror":t=E.MIRRORED_REPEAT}}const r={wrapS:t,wrapT:s};for(let o=0;o<this.gltf.samplers.length;++o)if(JSON.stringify(r)===JSON.stringify(this.gltf.samplers[o]))return o;const i=this.gltf.samplers.length;return this.gltf.samplers.push(r),i}_addAccessor(e,t){this.gltf.accessors||(this.gltf.accessors=[]);const s={bufferView:e,byteOffset:t.byteOffset,componentType:t.componentType,count:t.count,type:t.type,min:t.min,max:t.max,name:t.name};t.normalized&&(s.normalized=!0);const r=this.gltf.accessors.length;return this.gltf.accessors.push(s),r}_addMeshVertexIndexed(e,t,s,r,i,o,a,n){const l=new Map;for(const c of t){e.startAccessor("INDICES");for(let s=0;s<c.faces.length;++s)e.push(c.faces[s]);const t=e.endAccessor(),u={attributes:{POSITION:r},indices:this._addAccessor(e.index,t),material:this._addMaterial(c.material)};i&&"flat"!==c.shading&&(u.attributes.NORMAL=i),o&&(u.attributes.TEXCOORD_0=o),a&&"flat"!==c.shading&&(u.attributes.TANGENT=a),n&&(u.attributes.COLOR_0=n);const h=l.get(c.name);if(h)h.primitives.push(u);else{const e={name:c.name,primitives:[u]};l.set(c.name,e),s.push(e)}}}_addMeshVertexNonIndexed(e,t,s,r,i,o,a){const n={primitives:[]};t.push(n);const l={attributes:{POSITION:s}};r&&(l.attributes.NORMAL=r),i&&(l.attributes.TEXCOORD_0=i),o&&(l.attributes.TANGENT=o),a&&(l.attributes.COLOR_0=a),e&&(l.material=this._addMaterial(e[0].material)),n.primitives.push(l)}}function v({position:e,normal:t,tangent:s}){C(e,3),C(t,3),C(s,4)}function C(e,t){if(null!=e)for(let s=1,r=2;s<e.length;s+=t,r+=t){const t=e[s],i=e[r];e[s]=i,e[r]=-t}}function I(t){return t**e}export{w as GLTF};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../Color.js";import t from"../../../request.js";import r from"../../../core/Error.js";import{getOrCreateMapValue as o}from"../../../core/MapUtils.js";import{hasScaling as n,rad2deg as s}from"../../../core/mathUtils.js";import{normalFromMat4 as a,fromMat4 as i}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as l}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromValues as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as u}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import f from"../MeshComponent.js";import m from"../MeshMaterialMetallicRoughness.js";import p from"../MeshTexture.js";import d from"../MeshTextureTransform.js";import{MeshVertexAttributes as g}from"../MeshVertexAttributes.js";import{selectVertexSpace as x}from"../meshVertexSpaceUtils.js";import{BufferViewVec4f as h,BufferViewVec4u8 as T,BufferViewVec4u16 as v,BufferViewVec3u8 as w,BufferViewVec3f as j,BufferViewVec3u16 as b,BufferViewVec3f64 as y,BufferViewVec2f as C}from"../buffer/BufferView.js";import{d as M,c as R,e as A,s as E}from"../../../chunks/vec3.js";import{a as B,n as F,s as $}from"../../../chunks/vec4.js";import{createBuffer as S}from"../buffer/utils.js";import{convertVertexSpace as U}from"./vertexSpaceConversion.js";import{DefaultLoadingContext as O}from"../../../views/3d/glTF/DefaultLoadingContext.js";import{loadGLTF as k}from"../../../views/3d/glTF/loader.js";import{convertPrimitiveToTriangles as D}from"../../../views/3d/glTF/internal/indexUtils.js";import{isEncodedMeshTexture as V}from"../../../views/3d/glTF/internal/resourceUtils.js";import{colorGamma as L}from"../../../views/3d/webgl-engine/materials/DefaultMaterial_COLOR_GAMMA.js";import{TextureWrapMode as _}from"../../../views/webgl/enums.js";import{f as I,a as P}from"../../../chunks/vec33.js";import{f as q,c as G}from"../../../chunks/vec43.js";import{n as N,f as z}from"../../../chunks/vec2.js";async function K(e,t,o){const n=new O(Q(o)),s=(await k(n,t,o,!0)).model,a=s.lods.shift(),i=new Map,l=new Map;s.textures.forEach(((e,t)=>i.set(t,X(e)))),s.materials.forEach(((e,t)=>l.set(t,Y(e,i))));const c=W(a);for(const r of c.parts)Z(c,r,l);const{position:u,normal:f,tangent:m,color:p,texCoord0:d}=c.vertexAttributes,h=x(e,o),T=e.spatialReference.isGeographic?x(e):h,v=U({vertexAttributes:{position:u.typedBuffer,normal:f?.typedBuffer,tangent:m?.typedBuffer},vertexSpace:T,spatialReference:e.spatialReference},h,{allowBufferReuse:!0,sourceUnit:o?.unitConversionDisabled?void 0:"meters"});if(!v)throw new r("load-gltf-mesh:vertex-space-projection",`Failed to load mesh from glTF because we could not convert the vertex space from ${T.type} to ${h.type}`);return{transform:null,vertexSpace:h,components:c.components,spatialReference:e.spatialReference,vertexAttributes:new g({...v,color:p?.typedBuffer,uv:d?.typedBuffer})}}function Q(e){const r=e?.resolveFile;return r?{busy:!1,request:async(e,o,n)=>{const s=r?.(e)??e,a="image"===o?"image":"binary"===o||"image+type"===o?"array-buffer":"json";return(await t(s,{responseType:a,signal:n?.signal,timeout:0})).data}}:null}function H(e,t){if(null==e)return"-";const r=e.typedBuffer;return`${o(t,r.buffer,(()=>t.size))}/${r.byteOffset}/${r.byteLength}`}function J(e){return null!=e?e.toString():"-"}function W(e){let t=0;const has={color:!1,tangent:!1,normal:!1,texCoord0:!1},r=new Map,n=new Map,s=[];for(const a of e.parts){const{attributes:{position:e,normal:i,color:l,tangent:c,texCoord0:u}}=a,f=`\n ${H(e,r)}/\n ${H(i,r)}/\n ${H(l,r)}/\n ${H(c,r)}/\n ${H(u,r)}/\n ${J(a.transform)}\n `;let m=!1;const p=o(n,f,(()=>(m=!0,{start:t,length:e.count})));m&&(t+=e.count),i&&(has.normal=!0),l&&(has.color=!0),c&&(has.tangent=!0),u&&(has.texCoord0=!0),s.push({gltf:a,writeVertices:m,region:p})}return{vertexAttributes:{position:S(y,t),normal:has.normal?S(j,t):null,tangent:has.tangent?S(h,t):null,color:has.color?S(T,t):null,texCoord0:has.texCoord0?S(C,t):null},parts:s,components:[]}}function X(e){return new p({data:(V(e.data),e.data),wrap:re(e.parameters.wrap)})}function Y(t,r){const o=new e(se(t.color,t.opacity)),n=t.emissiveFactor?new e(ae(t.emissiveFactor)):null,a=e=>e?new d({scale:e.scale?[e.scale[0],e.scale[1]]:[1,1],rotation:s(e.rotation??0),offset:e.offset?[e.offset[0],e.offset[1]]:[0,0]}):null;return new m({color:o,colorTexture:r.get(t.textureColor),normalTexture:r.get(t.textureNormal),emissiveColor:n,emissiveTexture:r.get(t.textureEmissive),occlusionTexture:r.get(t.textureOcclusion),alphaMode:te(t.alphaMode),alphaCutoff:t.alphaCutoff,doubleSided:t.doubleSided,metallic:t.metallicFactor,roughness:t.roughnessFactor,metallicRoughnessTexture:r.get(t.textureMetallicRoughness),colorTextureTransform:a(t.colorTextureTransform),normalTextureTransform:a(t.normalTextureTransform),occlusionTextureTransform:a(t.occlusionTextureTransform),emissiveTextureTransform:a(t.emissiveTextureTransform),metallicRoughnessTextureTransform:a(t.metallicRoughnessTextureTransform)})}function Z(e,t,r){t.writeVertices&&ee(e,t);const{indices:o,attributes:n,primitiveType:s,material:a}=t.gltf;let i=D(o||n.position.count,s);const l=t.region.start;if(l){const e=new Uint32Array(i);for(let t=0;t<i.length;t++)e[t]+=l;i=e}e.components.push(new f({name:t.gltf.name,faces:i,material:r.get(a),shading:n.normal?"source":"flat",trustSourceNormals:!0}))}function ee(e,t){const{position:r,normal:o,tangent:s,color:c,texCoord0:u}=e.vertexAttributes,f=t.region.start,{attributes:m,transform:p}=t.gltf,d=m.position.count;if(M(r.slice(f,d),m.position,p),null!=m.normal&&null!=o){const e=a(l(),p),t=o.slice(f,d);R(t,m.normal,e),n(e)&&A(t,t)}else null!=o&&I(o,0,0,1,{dstIndex:f,count:d});if(null!=m.tangent&&null!=s){const e=i(l(),p),t=s.slice(f,d);B(t,m.tangent,e),n(e)&&F(t,t)}else null!=s&&q(s,0,0,1,1,{dstIndex:f,count:d});if(null!=m.texCoord0&&null!=u?N(u.slice(f,d),m.texCoord0):null!=u&&z(u,0,0,{dstIndex:f,count:d}),null!=m.color&&null!=c){const e=m.color,t=c.slice(f,d);if(4===e.elementCount)e instanceof h?$(t,e,255):e instanceof T?G(t,e):e instanceof v&&$(t,e,1/256);else{q(t,255,255,255,255);const r=w.fromTypedArray(t.typedBuffer,t.typedBufferStride);e instanceof j?E(r,e,255):e instanceof w?P(r,e):e instanceof b&&E(r,e,1/256)}}else null!=c&&q(c.slice(f,d),255,255,255,255)}function te(e){switch(e){case"OPAQUE":return"opaque";case"MASK":return"mask";case"BLEND":return"blend"}}function re(e){return{horizontal:oe(e.s),vertical:oe(e.t)}}function oe(e){switch(e){case _.CLAMP_TO_EDGE:return"clamp";case _.MIRRORED_REPEAT:return"mirror";case _.REPEAT:return"repeat"}}function ne(e){return e**(1/L)*255}function se(e,t){return u(ne(e[0]),ne(e[1]),ne(e[2]),t)}function ae(e){return c(ne(e[0]),ne(e[1]),ne(e[2]))}export{K as loadGLTFMesh};
5
+ import e from"../../../Color.js";import{colorGamma as t}from"../../../colorUtils.js";import r from"../../../request.js";import o from"../../../core/Error.js";import{getOrCreateMapValue as n}from"../../../core/MapUtils.js";import{hasScaling as s,rad2deg as i}from"../../../core/mathUtils.js";import{normalFromMat4 as a,fromMat4 as l}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as c}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromValues as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as f}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import m from"../MeshComponent.js";import p from"../MeshMaterialMetallicRoughness.js";import d from"../MeshTexture.js";import x from"../MeshTextureTransform.js";import{MeshVertexAttributes as g}from"../MeshVertexAttributes.js";import{selectVertexSpace as h}from"../meshVertexSpaceUtils.js";import{BufferViewVec4f as T,BufferViewVec4u8 as v,BufferViewVec4u16 as w,BufferViewVec3u8 as j,BufferViewVec3f as b,BufferViewVec3u16 as y,BufferViewVec3f64 as C,BufferViewVec2f as M}from"../buffer/BufferView.js";import{d as R,c as A,e as E,l as B}from"../../../chunks/vec3.js";import{a as F,n as $,l as S}from"../../../chunks/vec4.js";import{createBuffer as U}from"../buffer/utils.js";import{convertVertexSpace as k}from"./vertexSpaceConversion.js";import{DefaultLoadingContext as V}from"../../../views/3d/glTF/DefaultLoadingContext.js";import{loadGLTF as D}from"../../../views/3d/glTF/loader.js";import{convertPrimitiveToTriangles as O}from"../../../views/3d/glTF/internal/indexUtils.js";import{isEncodedMeshTexture as I}from"../../../views/3d/glTF/internal/resourceUtils.js";import{TextureWrapMode as L}from"../../../views/webgl/enums.js";import{f as P}from"../../../chunks/vec33.js";import{f as q}from"../../../chunks/vec43.js";import{n as N,f as _}from"../../../chunks/vec2.js";async function z(e,t,r){const n=new V(G(r)),s=(await D(n,t,r,!0)).model,i=s.lods.shift(),a=new Map,l=new Map;s.textures.forEach(((e,t)=>a.set(t,J(e)))),s.materials.forEach(((e,t)=>l.set(t,W(e,a))));const c=H(i);for(const o of c.parts)X(c,o,l);const{position:u,normal:f,tangent:m,color:p,texCoord0:d}=c.vertexAttributes,x=h(e,r),T=e.spatialReference.isGeographic?h(e):x,v=k({vertexAttributes:{position:u.typedBuffer,normal:f?.typedBuffer,tangent:m?.typedBuffer},vertexSpace:T,spatialReference:e.spatialReference},x,{allowBufferReuse:!0,sourceUnit:r?.unitConversionDisabled?void 0:"meters"});if(!v)throw new o("load-gltf-mesh:vertex-space-projection",`Failed to load mesh from glTF because we could not convert the vertex space from ${T.type} to ${x.type}`);return{transform:null,vertexSpace:x,components:c.components,spatialReference:e.spatialReference,vertexAttributes:new g({...v,color:p?.typedBuffer,uv:d?.typedBuffer})}}function G(e){const t=e?.resolveFile;return t?{busy:!1,request:async(e,o,n)=>{const s=t?.(e)??e,i="image"===o?"image":"binary"===o||"image+type"===o?"array-buffer":"json";return(await r(s,{responseType:i,signal:n?.signal,timeout:0})).data}}:null}function K(e,t){if(null==e)return"-";const r=e.typedBuffer;return`${n(t,r.buffer,(()=>t.size))}/${r.byteOffset}/${r.byteLength}`}function Q(e){return null!=e?e.toString():"-"}function H(e){let t=0;const has={color:!1,tangent:!1,normal:!1,texCoord0:!1},r=new Map,o=new Map,s=[];for(const i of e.parts){const{attributes:{position:e,normal:a,color:l,tangent:c,texCoord0:u}}=i,f=`\n ${K(e,r)}/\n ${K(a,r)}/\n ${K(l,r)}/\n ${K(c,r)}/\n ${K(u,r)}/\n ${Q(i.transform)}\n `;let m=!1;const p=n(o,f,(()=>(m=!0,{start:t,length:e.count})));m&&(t+=e.count),a&&(has.normal=!0),l&&(has.color=!0),c&&(has.tangent=!0),u&&(has.texCoord0=!0),s.push({gltf:i,writeVertices:m,region:p})}return{vertexAttributes:{position:U(C,t),normal:has.normal?U(b,t):null,tangent:has.tangent?U(T,t):null,color:has.color?U(v,t):null,texCoord0:has.texCoord0?U(M,t):null},parts:s,components:[]}}function J(e){return new d({data:(I(e.data),e.data),wrap:ee(e.parameters.wrap)})}function W(t,r){const o=new e(oe(t.color,t.opacity)),n=t.emissiveFactor?new e(ne(t.emissiveFactor)):null,s=e=>e?new x({scale:e.scale?[e.scale[0],e.scale[1]]:[1,1],rotation:i(e.rotation??0),offset:e.offset?[e.offset[0],e.offset[1]]:[0,0]}):null;return new p({color:o,colorTexture:r.get(t.textureColor),normalTexture:r.get(t.textureNormal),emissiveColor:n,emissiveTexture:r.get(t.textureEmissive),occlusionTexture:r.get(t.textureOcclusion),alphaMode:Z(t.alphaMode),alphaCutoff:t.alphaCutoff,doubleSided:t.doubleSided,metallic:t.metallicFactor,roughness:t.roughnessFactor,metallicRoughnessTexture:r.get(t.textureMetallicRoughness),colorTextureTransform:s(t.colorTextureTransform),normalTextureTransform:s(t.normalTextureTransform),occlusionTextureTransform:s(t.occlusionTextureTransform),emissiveTextureTransform:s(t.emissiveTextureTransform),metallicRoughnessTextureTransform:s(t.metallicRoughnessTextureTransform)})}function X(e,t,r){t.writeVertices&&Y(e,t);const{indices:o,attributes:n,primitiveType:s,material:i}=t.gltf;let a=O(o||n.position.count,s);const l=t.region.start;if(l){const e=new Uint32Array(a);for(let t=0;t<a.length;t++)e[t]+=l;a=e}e.components.push(new m({name:t.gltf.name,faces:a,material:r.get(i),shading:n.normal?"source":"flat",trustSourceNormals:!0}))}function Y(e,t){const{position:r,normal:o,tangent:n,color:i,texCoord0:u}=e.vertexAttributes,f=t.region.start,{attributes:m,transform:p}=t.gltf,d=m.position.count;if(R(r.slice(f,d),m.position,p),null!=m.normal&&null!=o){const e=a(c(),p),t=o.slice(f,d);A(t,m.normal,e),s(e)&&E(t,t)}else null!=o&&P(o,0,0,1,{dstIndex:f,count:d});if(null!=m.tangent&&null!=n){const e=l(c(),p),t=n.slice(f,d);F(t,m.tangent,e),s(e)&&$(t,t)}else null!=n&&q(n,0,0,1,1,{dstIndex:f,count:d});if(null!=m.texCoord0&&null!=u?N(u.slice(f,d),m.texCoord0):null!=u&&_(u,0,0,{dstIndex:f,count:d}),null!=m.color&&null!=i){const e=m.color,t=i.slice(f,d);if(4===e.elementCount)e instanceof T?S(t,e,1,255):(e instanceof v||e instanceof w)&&S(t,e,1/255,255);else{q(t,255,255,255,255);const r=j.fromTypedArray(t.typedBuffer,t.typedBufferStride);e instanceof b?B(r,e,1,255):(e instanceof j||e instanceof y)&&B(r,e,1/255,255)}}else null!=i&&q(i.slice(f,d),255,255,255,255)}function Z(e){switch(e){case"OPAQUE":return"opaque";case"MASK":return"mask";case"BLEND":return"blend"}}function ee(e){return{horizontal:te(e.s),vertical:te(e.t)}}function te(e){switch(e){case L.CLAMP_TO_EDGE:return"clamp";case L.MIRRORED_REPEAT:return"mirror";case L.REPEAT:return"repeat"}}function re(e){return e**(1/t)*255}function oe(e,t){return f(re(e[0]),re(e[1]),re(e[2]),t)}function ne(e){return u(re(e[0]),re(e[1]),re(e[2]))}export{z as loadGLTFMesh};