New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@gltf-transform/extensions

Package Overview
Dependencies
Maintainers
1
Versions
193
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gltf-transform/extensions - npm Package Compare versions

Comparing version 3.1.2 to 3.1.3

dist/khr-materials-anisotropy/anisotropy.d.ts

1

dist/constants.d.ts

@@ -7,2 +7,3 @@ export declare const EXT_MESH_GPU_INSTANCING = "EXT_mesh_gpu_instancing";

export declare const KHR_LIGHTS_PUNCTUAL = "KHR_lights_punctual";
export declare const KHR_MATERIALS_ANISOTROPY = "KHR_materials_anisotropy";
export declare const KHR_MATERIALS_CLEARCOAT = "KHR_materials_clearcoat";

@@ -9,0 +10,0 @@ export declare const KHR_MATERIALS_EMISSIVE_STRENGTH = "KHR_materials_emissive_strength";

6

dist/extensions.d.ts

@@ -8,2 +8,3 @@ /** @module extensions */

import { KHRLightsPunctual } from './khr-lights-punctual/index.js';
import { KHRMaterialsAnisotropy } from './khr-materials-anisotropy/index.js';
import { KHRMaterialsClearcoat } from './khr-materials-clearcoat/index.js';

@@ -24,4 +25,4 @@ import { KHRMaterialsEmissiveStrength } from './khr-materials-emissive-strength/index.js';

import { KHRXMP } from './khr-xmp-json-ld/index.js';
export declare const KHRONOS_EXTENSIONS: (typeof KHRDracoMeshCompression | typeof KHRLightsPunctual | typeof KHRMaterialsClearcoat | typeof KHRMaterialsEmissiveStrength | typeof KHRMaterialsIOR | typeof KHRMaterialsIridescence | typeof KHRMaterialsPBRSpecularGlossiness | typeof KHRMaterialsSpecular | typeof KHRMaterialsSheen | typeof KHRMaterialsTransmission | typeof KHRMaterialsUnlit | typeof KHRMaterialsVariants | typeof KHRMaterialsVolume | typeof KHRMeshQuantization | typeof KHRTextureBasisu | typeof KHRTextureTransform | typeof KHRXMP)[];
export declare const ALL_EXTENSIONS: (typeof KHRDracoMeshCompression | typeof KHRLightsPunctual | typeof KHRMaterialsClearcoat | typeof KHRMaterialsEmissiveStrength | typeof KHRMaterialsIOR | typeof KHRMaterialsIridescence | typeof KHRMaterialsPBRSpecularGlossiness | typeof KHRMaterialsSpecular | typeof KHRMaterialsSheen | typeof KHRMaterialsTransmission | typeof KHRMaterialsUnlit | typeof KHRMaterialsVariants | typeof KHRMaterialsVolume | typeof KHRMeshQuantization | typeof KHRTextureBasisu | typeof KHRTextureTransform | typeof KHRXMP | typeof EXTMeshGPUInstancing | typeof EXTMeshoptCompression | typeof EXTTextureAVIF | typeof EXTTextureWebP)[];
export declare const KHRONOS_EXTENSIONS: (typeof KHRDracoMeshCompression | typeof KHRLightsPunctual | typeof KHRMaterialsAnisotropy | typeof KHRMaterialsClearcoat | typeof KHRMaterialsEmissiveStrength | typeof KHRMaterialsIOR | typeof KHRMaterialsIridescence | typeof KHRMaterialsPBRSpecularGlossiness | typeof KHRMaterialsSpecular | typeof KHRMaterialsSheen | typeof KHRMaterialsTransmission | typeof KHRMaterialsUnlit | typeof KHRMaterialsVariants | typeof KHRMaterialsVolume | typeof KHRMeshQuantization | typeof KHRTextureBasisu | typeof KHRTextureTransform | typeof KHRXMP)[];
export declare const ALL_EXTENSIONS: (typeof KHRDracoMeshCompression | typeof KHRLightsPunctual | typeof KHRMaterialsAnisotropy | typeof KHRMaterialsClearcoat | typeof KHRMaterialsEmissiveStrength | typeof KHRMaterialsIOR | typeof KHRMaterialsIridescence | typeof KHRMaterialsPBRSpecularGlossiness | typeof KHRMaterialsSpecular | typeof KHRMaterialsSheen | typeof KHRMaterialsTransmission | typeof KHRMaterialsUnlit | typeof KHRMaterialsVariants | typeof KHRMaterialsVolume | typeof KHRMeshQuantization | typeof KHRTextureBasisu | typeof KHRTextureTransform | typeof KHRXMP | typeof EXTMeshGPUInstancing | typeof EXTMeshoptCompression | typeof EXTTextureAVIF | typeof EXTTextureWebP)[];
export * from './ext-mesh-gpu-instancing/index.js';

@@ -33,2 +34,3 @@ export * from './ext-meshopt-compression/index.js';

export * from './khr-lights-punctual/index.js';
export * from './khr-materials-anisotropy/index.js';
export * from './khr-materials-clearcoat/index.js';

@@ -35,0 +37,0 @@ export * from './khr-materials-emissive-strength/index.js';

@@ -1,2 +0,2 @@

import{ExtensionProperty as e,PropertyType as t,Extension as s,BufferUtils as n,WriterContext as r,Primitive as o,Root as i,AnimationSampler as a,AnimationChannel as c,Accessor as u,MathUtils as l,GLB_BUFFER as h,ImageUtils as f,getBounds as g,ColorUtils as p,TextureInfo as x,TextureChannel as d}from"@gltf-transform/core";import{read as T,KHR_DF_MODEL_ETC1S as m,KHR_DF_MODEL_UASTC as E}from"ktx-parse";const I="INSTANCE_ATTRIBUTE";class R extends e{init(){this.extensionName="EXT_mesh_gpu_instancing",this.propertyType="InstancedMesh",this.parentTypes=[t.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:{}})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:"INSTANCE_ATTRIBUTE"})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}R.EXTENSION_NAME="EXT_mesh_gpu_instancing";const N="EXT_mesh_gpu_instancing";class _ extends s{constructor(...e){super(...e),this.extensionName=N,this.provideTypes=[t.NODE],this.prewriteTypes=[t.ACCESSOR]}createInstancedMesh(){return new R(this.document.getGraph())}read(e){return(e.jsonDoc.json.nodes||[]).forEach((t,s)=>{if(!t.extensions||!t.extensions[N])return;const n=t.extensions[N],r=this.createInstancedMesh();for(const t in n.attributes)r.setAttribute(t,e.accessors[n.attributes[t]]);e.nodes[s].setExtension(N,r)}),this}prewrite(e){e.accessorUsageGroupedByParent.add("INSTANCE_ATTRIBUTE");for(const t of this.properties)for(const s of t.listAttributes())e.addAccessorToUsageGroup(s,"INSTANCE_ATTRIBUTE");return this}write(e){const t=e.jsonDoc;return this.document.getRoot().listNodes().forEach(s=>{const n=s.getExtension(N);if(n){const r=e.nodeIndexMap.get(s),o=t.json.nodes[r],i={attributes:{}};n.listSemantics().forEach(t=>{const s=n.getAttribute(t);i.attributes[t]=e.accessorIndexMap.get(s)}),o.extensions=o.extensions||{},o.extensions[N]=i}}),this}}function y(){return(y=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e}).apply(this,arguments)}var S,A,C;_.EXTENSION_NAME=N,function(e){e.QUANTIZE="quantize",e.FILTER="filter"}(S||(S={})),function(e){e.ATTRIBUTES="ATTRIBUTES",e.TRIANGLES="TRIANGLES",e.INDICES="INDICES"}(A||(A={})),function(e){e.NONE="NONE",e.OCTAHEDRAL="OCTAHEDRAL",e.QUATERNION="QUATERNION",e.EXPONENTIAL="EXPONENTIAL"}(C||(C={}));const{BYTE:M,SHORT:O,FLOAT:w}=u.ComponentType,{encodeNormalizedInt:D,decodeNormalizedInt:b}=l;function F(e,t,s,r){const{filter:o,bits:i}=r,a={array:e.getArray(),byteStride:e.getElementSize()*e.getComponentSize(),componentType:e.getComponentType(),normalized:e.getNormalized()};if(s!==A.ATTRIBUTES)return a;if(o!==C.NONE){let s=e.getNormalized()?function(e){const t=e.getComponentType(),s=e.getArray(),n=new Float32Array(s.length);for(let e=0;e<s.length;e++)n[e]=b(s[e],t);return n}(e):new Float32Array(a.array);switch(o){case C.EXPONENTIAL:a.byteStride=4*e.getElementSize(),a.componentType=w,a.normalized=!1,a.array=t.encodeFilterExp(s,e.getCount(),a.byteStride,i);break;case C.OCTAHEDRAL:a.byteStride=i>8?8:4,a.componentType=i>8?O:M,a.normalized=!0,s=3===e.getElementSize()?function(e){const t=new Float32Array(4*e.length/3);for(let s=0,n=e.length/3;s<n;s++)t[4*s]=e[3*s],t[4*s+1]=e[3*s+1],t[4*s+2]=e[3*s+2];return t}(s):s,a.array=t.encodeFilterOct(s,e.getCount(),a.byteStride,i);break;case C.QUATERNION:a.byteStride=8,a.componentType=O,a.normalized=!0,a.array=t.encodeFilterQuat(s,e.getCount(),a.byteStride,i);break;default:throw new Error("Invalid filter.")}a.min=e.getMin([]),a.max=e.getMax([]),e.getNormalized()&&(a.min=a.min.map(t=>b(t,e.getComponentType())),a.max=a.max.map(t=>b(t,e.getComponentType()))),a.normalized&&(a.min=a.min.map(e=>D(e,a.componentType)),a.max=a.max.map(e=>D(e,a.componentType)))}else a.byteStride%4&&(a.array=function(e,t){const s=n.padNumber(e.BYTES_PER_ELEMENT*t)/e.BYTES_PER_ELEMENT,r=new e.constructor(e.length/t*s);for(let n=0;n*t<e.length;n++)for(let o=0;o<t;o++)r[n*s+o]=e[n*t+o];return r}(a.array,e.getElementSize()),a.byteStride=a.array.byteLength/e.getCount());return a}function j(e,t){return t===r.BufferViewUsage.ELEMENT_ARRAY_BUFFER?e.listParents().some(e=>e instanceof o&&e.getMode()===o.Mode.TRIANGLES)?A.TRIANGLES:A.INDICES:A.ATTRIBUTES}function v(e,t){const s=t.getGraph().listParentEdges(e).filter(e=>!(e.getParent()instanceof i));for(const t of s){const s=t.getName(),n=t.getAttributes().key||"";if("indices"===s)return{filter:C.NONE};if("attributes"===s){if("POSITION"===n)return{filter:C.NONE};if("TEXCOORD_0"===n)return{filter:C.NONE};if("NORMAL"===n)return{filter:C.OCTAHEDRAL,bits:8};if("TANGENT"===n)return{filter:C.OCTAHEDRAL,bits:8};if(n.startsWith("JOINTS_"))return{filter:C.NONE};if(n.startsWith("WEIGHTS_"))return{filter:C.NONE}}if("output"===s){const t=k(e);return"rotation"===t?{filter:C.QUATERNION,bits:16}:"translation"===t||"scale"===t?{filter:C.EXPONENTIAL,bits:12}:{filter:C.NONE}}if("input"===s)return{filter:C.NONE};if("inverseBindMatrices"===s)return{filter:C.NONE}}return{filter:C.NONE}}function k(e){for(const t of e.listParents())if(t instanceof a)for(const e of t.listParents())if(e instanceof c)return e.getTargetPath();return null}const B="EXT_meshopt_compression",G={method:S.QUANTIZE};class L extends s{constructor(...e){super(...e),this.extensionName=B,this.prereadTypes=[t.BUFFER,t.PRIMITIVE],this.prewriteTypes=[t.BUFFER,t.ACCESSOR],this.readDependencies=["meshopt.decoder"],this.writeDependencies=["meshopt.encoder"],this._decoder=null,this._decoderFallbackBufferMap=new Map,this._encoder=null,this._encoderOptions=G,this._encoderFallbackBuffer=null,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={}}install(e,t){return"meshopt.decoder"===e&&(this._decoder=t),"meshopt.encoder"===e&&(this._encoder=t),this}setEncoderOptions(e){return this._encoderOptions=y({},G,e),this}preread(e,s){if(!this._decoder){if(!this.isRequired())return this;throw new Error(`[${B}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw new Error(`[${B}]: Missing WASM support.`)}return s===t.BUFFER?this._prereadBuffers(e):s===t.PRIMITIVE&&this._prereadPrimitives(e),this}_prereadBuffers(e){const t=e.jsonDoc;(t.json.bufferViews||[]).forEach((s,r)=>{if(!s.extensions||!s.extensions[B])return;const o=s.extensions[B],i=o.byteOffset||0,a=o.byteLength||0,c=o.count,u=o.byteStride,l=new Uint8Array(c*u),f=t.json.buffers[o.buffer],g=n.toView(f.uri?t.resources[f.uri]:t.resources[h],i,a);this._decoder.decodeGltfBuffer(l,c,u,g,o.mode,o.filter),e.bufferViews[r]=l})}_prereadPrimitives(e){const t=e.jsonDoc;(t.json.bufferViews||[]).forEach(s=>{var n;s.extensions&&s.extensions[B]&&(n=t.json.buffers[s.buffer]).extensions&&n.extensions.EXT_meshopt_compression&&n.extensions.EXT_meshopt_compression.fallback&&this._decoderFallbackBufferMap.set(e.buffers[s.buffer],e.buffers[s.extensions[B].buffer])})}read(e){if(!this.isRequired())return this;for(const[e,t]of this._decoderFallbackBufferMap){for(const s of e.listParents())s instanceof u&&s.swap(e,t);e.dispose()}return this}prewrite(e,s){return s===t.ACCESSOR?this._prewriteAccessors(e):s===t.BUFFER&&this._prewriteBuffers(e),this}_prewriteAccessors(e){const t=e.jsonDoc.json,s=this._encoder,n=this._encoderOptions,o=this.document.createBuffer(),i=this.document.getRoot().listBuffers().indexOf(o);this._encoderFallbackBuffer=o,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(const o of this.document.getRoot().listAccessors()){if("weights"===k(o))continue;if(o.getSparse())continue;const a=e.getAccessorUsage(o),c=j(o,a),u=n.method===S.FILTER?v(o,this.document):{filter:C.NONE},l=F(o,s,c,u),{array:h,byteStride:f}=l,g=o.getBuffer();if(!g)throw new Error(`${B}: Missing buffer for accessor.`);const p=this.document.getRoot().listBuffers().indexOf(g),x=[a,c,u.filter,f,p].join(":");let d=this._encoderBufferViews[x],T=this._encoderBufferViewData[x],m=this._encoderBufferViewAccessors[x];d&&T||(m=this._encoderBufferViewAccessors[x]=[],T=this._encoderBufferViewData[x]=[],d=this._encoderBufferViews[x]={buffer:i,target:r.USAGE_TO_TARGET[a],byteOffset:0,byteLength:0,byteStride:a===r.BufferViewUsage.ARRAY_BUFFER?f:void 0,extensions:{[B]:{buffer:p,byteOffset:0,byteLength:0,mode:c,filter:u.filter!==C.NONE?u.filter:void 0,byteStride:f,count:0}}});const E=e.createAccessorDef(o);E.componentType=l.componentType,E.normalized=l.normalized,E.byteOffset=d.byteLength,E.min&&l.min&&(E.min=l.min),E.max&&l.max&&(E.max=l.max),e.accessorIndexMap.set(o,t.accessors.length),t.accessors.push(E),m.push(E),T.push(new Uint8Array(h.buffer,h.byteOffset,h.byteLength)),d.byteLength+=h.byteLength,d.extensions.EXT_meshopt_compression.count+=o.getCount()}}_prewriteBuffers(e){const t=this._encoder;for(const s in this._encoderBufferViews){const r=this._encoderBufferViews[s],o=this._encoderBufferViewData[s],i=this.document.getRoot().listBuffers()[r.extensions[B].buffer],a=e.otherBufferViews.get(i)||[],{count:c,byteStride:u,mode:l}=r.extensions[B],h=n.concat(o),f=t.encodeGltfBuffer(h,c,u,l),g=n.pad(f);r.extensions[B].byteLength=f.byteLength,o.length=0,o.push(g),a.push(g),e.otherBufferViews.set(i,a)}}write(e){let t=0;for(const s in this._encoderBufferViews){const r=this._encoderBufferViews[s],o=e.otherBufferViewsIndexMap.get(this._encoderBufferViewData[s][0]),i=this._encoderBufferViewAccessors[s];for(const e of i)e.bufferView=o;const a=e.jsonDoc.json.bufferViews[o],c=a.byteOffset||0;Object.assign(a,r),a.byteOffset=t,a.extensions[B].byteOffset=c,t+=n.padNumber(r.byteLength)}const s=this._encoderFallbackBuffer,r=e.bufferIndexMap.get(s),o=e.jsonDoc.json.buffers[r];return o.byteLength=t,o.extensions={[B]:{fallback:!0}},s.dispose(),this}}L.EXTENSION_NAME=B,L.EncoderMethod=S;const H="EXT_texture_avif";class U{match(e){return e.length>=12&&"ftypavif"===n.decodeText(e.slice(4,12))}getSize(e){if(!this.match(e))return null;const t=new DataView(e.buffer,e.byteOffset,e.byteLength);let s=P(t,0);if(!s)return null;let n=s.end;for(;s=P(t,n);)if("meta"===s.type)n=s.start+4;else if("iprp"===s.type||"ipco"===s.type)n=s.start;else{if("ispe"===s.type)return[t.getUint32(s.start+4),t.getUint32(s.start+8)];if("mdat"===s.type)break;n=s.end}return null}getChannels(e){return 4}}class V extends s{constructor(...e){super(...e),this.extensionName=H,this.prereadTypes=[t.TEXTURE]}static register(){f.registerFormat("image/avif",new U)}preread(e){return(e.jsonDoc.json.textures||[]).forEach(e=>{e.extensions&&e.extensions[H]&&(e.source=e.extensions[H].source)}),this}read(e){return this}write(e){const t=e.jsonDoc;return this.document.getRoot().listTextures().forEach(s=>{if("image/avif"===s.getMimeType()){const n=e.imageIndexMap.get(s);(t.json.textures||[]).forEach(e=>{e.source===n&&(e.extensions=e.extensions||{},e.extensions[H]={source:e.source},delete e.source)})}}),this}}function P(e,t){if(e.byteLength<4+t)return null;const s=e.getUint32(t);return e.byteLength<s+t||s<8?null:{type:n.decodeText(new Uint8Array(e.buffer,e.byteOffset+t+4,4)),start:t+8,end:t+s}}V.EXTENSION_NAME=H;const X="EXT_texture_webp";class K{match(e){return e.length>=12&&87===e[8]&&69===e[9]&&66===e[10]&&80===e[11]}getSize(e){const t=n.decodeText(e.slice(0,4)),s=n.decodeText(e.slice(8,12));if("RIFF"!==t||"WEBP"!==s)return null;const r=new DataView(e.buffer,e.byteOffset);let o=12;for(;o<r.byteLength;){const e=n.decodeText(new Uint8Array([r.getUint8(o),r.getUint8(o+1),r.getUint8(o+2),r.getUint8(o+3)])),t=r.getUint32(o+4,!0);if("VP8 "===e)return[16383&r.getInt16(o+14,!0),16383&r.getInt16(o+16,!0)];if("VP8L"===e){const e=r.getUint8(o+9),t=r.getUint8(o+10),s=r.getUint8(o+11);return[1+((63&t)<<8|e),1+((15&r.getUint8(o+12))<<10|s<<2|(192&t)>>6)]}o+=8+t+t%2}return null}getChannels(e){return 4}}class z extends s{constructor(...e){super(...e),this.extensionName=X,this.prereadTypes=[t.TEXTURE]}static register(){f.registerFormat("image/webp",new K)}preread(e){return(e.jsonDoc.json.textures||[]).forEach(e=>{e.extensions&&e.extensions[X]&&(e.source=e.extensions[X].source)}),this}read(e){return this}write(e){const t=e.jsonDoc;return this.document.getRoot().listTextures().forEach(s=>{if("image/webp"===s.getMimeType()){const n=e.imageIndexMap.get(s);(t.json.textures||[]).forEach(e=>{e.source===n&&(e.extensions=e.extensions||{},e.extensions[X]={source:e.source},delete e.source)})}}),this}}z.EXTENSION_NAME=X;const $="KHR_draco_mesh_compression";let q,Y,Q,W;function J(e,t){const s=new q.DecoderBuffer;try{if(s.Init(t,t.length),e.GetEncodedGeometryType(s)!==q.TRIANGULAR_MESH)throw new Error(`[${$}] Unknown geometry type.`);const n=new q.Mesh;if(!e.DecodeBufferToMesh(s,n).ok()||0===n.ptr)throw new Error(`[${$}] Decoding failure.`);return n}finally{q.destroy(s)}}function Z(e,t){const s=3*t.num_faces();let n,r;if(t.num_points()<=65534){const o=s*Uint16Array.BYTES_PER_ELEMENT;n=q._malloc(o),e.GetTrianglesUInt16Array(t,o,n),r=new Uint16Array(q.HEAPU16.buffer,n,s).slice()}else{const o=s*Uint32Array.BYTES_PER_ELEMENT;n=q._malloc(o),e.GetTrianglesUInt32Array(t,o,n),r=new Uint32Array(q.HEAPU32.buffer,n,s).slice()}return q._free(n),r}function ee(e,t,s,n){const r=Q[n.componentType],o=Y[n.componentType],i=s.num_components(),a=t.num_points()*i,c=a*o.BYTES_PER_ELEMENT,u=q._malloc(c);e.GetAttributeDataArrayForAllPoints(t,s,r,c,u);const l=new o(q.HEAPF32.buffer,u,a).slice();return q._free(u),l}var te,se;!function(e){e[e.EDGEBREAKER=1]="EDGEBREAKER",e[e.SEQUENTIAL=0]="SEQUENTIAL"}(te||(te={})),function(e){e.POSITION="POSITION",e.NORMAL="NORMAL",e.COLOR="COLOR",e.TEX_COORD="TEX_COORD",e.GENERIC="GENERIC"}(se||(se={}));const ne={[se.POSITION]:14,[se.NORMAL]:10,[se.COLOR]:8,[se.TEX_COORD]:12,[se.GENERIC]:12},re={decodeSpeed:5,encodeSpeed:5,method:te.EDGEBREAKER,quantizationBits:ne,quantizationVolume:"mesh"};function oe(e,t=re){const s=y({},re,t);s.quantizationBits=y({},ne,t.quantizationBits);const n=new W.Encoder,r=new W.MeshBuilder,o=new W.Mesh,i={},a=new W.DracoInt8Array,c=e.listTargets().length>0;let u=!1;for(const t of e.listSemantics()){const a=e.getAttribute(t);if(a.getSparse()){u=!0;continue}const c=ie(t),l=ae(r,a.getComponentType(),o,W[c],a.getCount(),a.getElementSize(),a.getArray());if(-1===l)throw new Error(`Error compressing "${t}" attribute.`);if(i[t]=l,"mesh"===s.quantizationVolume||"POSITION"!==t)n.SetAttributeQuantization(W[c],s.quantizationBits[c]);else{if("object"!=typeof s.quantizationVolume)throw new Error("Invalid quantization volume state.");{const{quantizationVolume:e}=s,t=Math.max(e.max[0]-e.min[0],e.max[1]-e.min[1],e.max[2]-e.min[2]);n.SetAttributeExplicitQuantization(W[c],s.quantizationBits[c],a.getElementSize(),e.min,t)}}}const l=e.getIndices();if(!l)throw new ce("Primitive must have indices.");r.AddFacesToMesh(o,l.getCount()/3,l.getArray()),n.SetSpeedOptions(s.encodeSpeed,s.decodeSpeed),n.SetTrackEncodedProperties(!0),n.SetEncodingMethod(s.method===te.SEQUENTIAL||c||u?W.MESH_SEQUENTIAL_ENCODING:W.MESH_EDGEBREAKER_ENCODING);const h=n.EncodeMeshToDracoBuffer(o,a);if(h<=0)throw new ce("Error applying Draco compression.");const f=new Uint8Array(h);for(let e=0;e<h;++e)f[e]=a.GetValue(e);const g=e.getAttribute("POSITION").getCount(),p=n.GetNumberOfEncodedPoints(),x=3*n.GetNumberOfEncodedFaces();if((c||u)&&p!==g)throw new ce('Compression reduced vertex count unexpectedly, corrupting mesh data. Applying the "weld" function before compression may resolve the issue. See: https://github.com/google/draco/issues/929');return W.destroy(a),W.destroy(o),W.destroy(r),W.destroy(n),{numVertices:p,numIndices:x,data:f,attributeIDs:i}}function ie(e){return"POSITION"===e?se.POSITION:"NORMAL"===e?se.NORMAL:e.startsWith("COLOR_")?se.COLOR:e.startsWith("TEXCOORD_")?se.TEX_COORD:se.GENERIC}function ae(e,t,s,n,r,o,i){switch(t){case u.ComponentType.UNSIGNED_BYTE:return e.AddUInt8Attribute(s,n,r,o,i);case u.ComponentType.BYTE:return e.AddInt8Attribute(s,n,r,o,i);case u.ComponentType.UNSIGNED_SHORT:return e.AddUInt16Attribute(s,n,r,o,i);case u.ComponentType.SHORT:return e.AddInt16Attribute(s,n,r,o,i);case u.ComponentType.UNSIGNED_INT:return e.AddUInt32Attribute(s,n,r,o,i);case u.ComponentType.FLOAT:return e.AddFloatAttribute(s,n,r,o,i);default:throw new Error(`Unexpected component type, "${t}".`)}}class ce extends Error{}const ue="KHR_draco_mesh_compression";class le extends s{constructor(...e){super(...e),this.extensionName=ue,this.prereadTypes=[t.PRIMITIVE],this.prewriteTypes=[t.ACCESSOR],this.readDependencies=["draco3d.decoder"],this.writeDependencies=["draco3d.encoder"],this._decoderModule=null,this._encoderModule=null,this._encoderOptions={}}install(e,t){return"draco3d.decoder"===e&&(this._decoderModule=t,q=this._decoderModule,Y={[u.ComponentType.FLOAT]:Float32Array,[u.ComponentType.UNSIGNED_INT]:Uint32Array,[u.ComponentType.UNSIGNED_SHORT]:Uint16Array,[u.ComponentType.UNSIGNED_BYTE]:Uint8Array,[u.ComponentType.SHORT]:Int16Array,[u.ComponentType.BYTE]:Int8Array},Q={[u.ComponentType.FLOAT]:q.DT_FLOAT32,[u.ComponentType.UNSIGNED_INT]:q.DT_UINT32,[u.ComponentType.UNSIGNED_SHORT]:q.DT_UINT16,[u.ComponentType.UNSIGNED_BYTE]:q.DT_UINT8,[u.ComponentType.SHORT]:q.DT_INT16,[u.ComponentType.BYTE]:q.DT_INT8}),"draco3d.encoder"===e&&(this._encoderModule=t,W=this._encoderModule),this}setEncoderOptions(e){return this._encoderOptions=e,this}preread(e){if(!this._decoderModule)throw new Error(`[${ue}] Please install extension dependency, "draco3d.decoder".`);const t=this.document.getLogger(),s=e.jsonDoc,r=new Map;try{const o=s.json.meshes||[];for(const i of o)for(const o of i.primitives){if(!o.extensions||!o.extensions[ue])continue;const i=o.extensions[ue];let[a,c]=r.get(i.bufferView)||[];if(!c||!a){const e=s.json.bufferViews[i.bufferView],o=s.json.buffers[e.buffer],u=n.toView(o.uri?s.resources[o.uri]:s.resources[h],e.byteOffset||0,e.byteLength);a=new this._decoderModule.Decoder,c=J(a,u),r.set(i.bufferView,[a,c]),t.debug(`[${ue}] Decompressed ${u.byteLength} bytes.`)}for(const t in o.attributes){const s=e.jsonDoc.json.accessors[o.attributes[t]],n=a.GetAttributeByUniqueId(c,i.attributes[t]),r=ee(a,c,n,s);e.accessors[o.attributes[t]].setArray(r)}void 0!==o.indices&&e.accessors[o.indices].setArray(Z(a,c))}}finally{for(const[e,t]of Array.from(r.values()))this._decoderModule.destroy(e),this._decoderModule.destroy(t)}return this}read(e){return this}prewrite(e,s){if(!this._encoderModule)throw new Error(`[${ue}] Please install extension dependency, "draco3d.encoder".`);const n=this.document.getLogger();n.debug(`[${ue}] Compression options: ${JSON.stringify(this._encoderOptions)}`);const r=function(e){const s=e.getLogger(),n=new Set,r=new Set;for(const t of e.getRoot().listMeshes())for(const e of t.listPrimitives())e.getIndices()?e.getMode()!==o.Mode.TRIANGLES?(r.add(e),s.warn(`[${ue}] Skipping Draco compression on non-TRIANGLES primitive.`)):n.add(e):(r.add(e),s.warn(`[${ue}] Skipping Draco compression on non-indexed primitive.`));const i=e.getRoot().listAccessors(),a=new Map;for(let e=0;e<i.length;e++)a.set(i[e],e);const c=new Map,u=new Set,l=new Map;for(const t of Array.from(n)){let s=he(t,a);if(u.has(s))l.set(t,s);else{if(c.has(t.getIndices())){const s=t.getIndices(),n=s.clone();a.set(n,e.getRoot().listAccessors().length-1),t.swap(s,n)}for(const s of t.listAttributes())if(c.has(s)){const n=s.clone();a.set(n,e.getRoot().listAccessors().length-1),t.swap(s,n)}s=he(t,a),u.add(s),l.set(t,s),c.set(t.getIndices(),s);for(const e of t.listAttributes())c.set(e,s)}}for(const e of Array.from(c.keys())){const s=new Set(e.listParents().map(e=>e.propertyType));if(2!==s.size||!s.has(t.PRIMITIVE)||!s.has(t.ROOT))throw new Error(`[${ue}] Compressed accessors must only be used as indices or vertex attributes.`)}for(const e of Array.from(n)){const t=l.get(e),s=e.getIndices();if(c.get(s)!==t||e.listAttributes().some(e=>c.get(e)!==t))throw new Error(`[${ue}] Draco primitives must share all, or no, accessors.`)}for(const e of Array.from(r)){const t=e.getIndices();if(c.has(t)||e.listAttributes().some(e=>c.has(e)))throw new Error(`[${ue}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return l}(this.document),i=new Map;let a="mesh";"scene"===this._encoderOptions.quantizationVolume&&(1!==this.document.getRoot().listScenes().length?n.warn(`[${ue}]: quantizationVolume=scene requires exactly 1 scene.`):a=g(this.document.getRoot().listScenes().pop()));for(const t of Array.from(r.keys())){const s=r.get(t);if(!s)throw new Error("Unexpected primitive.");if(i.has(s)){i.set(s,i.get(s));continue}const o=t.getIndices(),c=e.jsonDoc.json.accessors;let u;try{u=oe(t,y({},this._encoderOptions,{quantizationVolume:a}))}catch(e){if(e instanceof ce){n.warn(`[${ue}]: ${e.message} Skipping primitive compression.`);continue}throw e}i.set(s,u);const l=e.createAccessorDef(o);l.count=u.numIndices,e.accessorIndexMap.set(o,c.length),c.push(l);for(const s of t.listSemantics()){const n=t.getAttribute(s);if(void 0===u.attributeIDs[s])continue;const r=e.createAccessorDef(n);r.count=u.numVertices,e.accessorIndexMap.set(n,c.length),c.push(r)}const h=t.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];e.otherBufferViews.has(h)||e.otherBufferViews.set(h,[]),e.otherBufferViews.get(h).push(u.data)}return n.debug(`[${ue}] Compressed ${r.size} primitives.`),e.extensionData[ue]={primitiveHashMap:r,primitiveEncodingMap:i},this}write(e){const t=e.extensionData[ue];for(const s of this.document.getRoot().listMeshes()){const n=e.jsonDoc.json.meshes[e.meshIndexMap.get(s)];for(let r=0;r<s.listPrimitives().length;r++){const o=s.listPrimitives()[r],i=n.primitives[r],a=t.primitiveHashMap.get(o);if(!a)continue;const c=t.primitiveEncodingMap.get(a);c&&(i.extensions=i.extensions||{},i.extensions[ue]={bufferView:e.otherBufferViewsIndexMap.get(c.data),attributes:c.attributeIDs})}}if(!t.primitiveHashMap.size){const t=e.jsonDoc.json;t.extensionsUsed=(t.extensionsUsed||[]).filter(e=>e!==ue),t.extensionsRequired=(t.extensionsRequired||[]).filter(e=>e!==ue)}return this}}function he(e,t){const s=[],n=e.getIndices();s.push(t.get(n));for(const n of e.listAttributes())s.push(t.get(n));return s.sort().join("|")}le.EXTENSION_NAME=ue,le.EncoderMethod=te;class fe extends e{init(){this.extensionName="KHR_lights_punctual",this.propertyType="Light",this.parentTypes=[t.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:fe.Type.POINT,range:null,innerConeAngle:0,outerConeAngle:Math.PI/4})}getColor(){return this.get("color")}setColor(e){return this.set("color",e)}getColorHex(){return p.factorToHex(this.getColor())}setColorHex(e){const t=this.getColor().slice();return p.hexToFactor(e,t),this.setColor(t)}getIntensity(){return this.get("intensity")}setIntensity(e){return this.set("intensity",e)}getType(){return this.get("type")}setType(e){return this.set("type",e)}getRange(){return this.get("range")}setRange(e){return this.set("range",e)}getInnerConeAngle(){return this.get("innerConeAngle")}setInnerConeAngle(e){return this.set("innerConeAngle",e)}getOuterConeAngle(){return this.get("outerConeAngle")}setOuterConeAngle(e){return this.set("outerConeAngle",e)}}fe.EXTENSION_NAME="KHR_lights_punctual",fe.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};const ge="KHR_lights_punctual";class pe extends s{constructor(...e){super(...e),this.extensionName=ge}createLight(e=""){return new fe(this.document.getGraph(),e)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions[ge])return this;const s=(t.json.extensions[ge].lights||[]).map(e=>{var t,s;const n=this.createLight().setName(e.name||"").setType(e.type);return void 0!==e.color&&n.setColor(e.color),void 0!==e.intensity&&n.setIntensity(e.intensity),void 0!==e.range&&n.setRange(e.range),void 0!==(null==(t=e.spot)?void 0:t.innerConeAngle)&&n.setInnerConeAngle(e.spot.innerConeAngle),void 0!==(null==(s=e.spot)?void 0:s.outerConeAngle)&&n.setOuterConeAngle(e.spot.outerConeAngle),n});return t.json.nodes.forEach((t,n)=>{t.extensions&&t.extensions[ge]&&e.nodes[n].setExtension(ge,s[t.extensions[ge].light])}),this}write(e){const t=e.jsonDoc;if(0===this.properties.size)return this;const s=[],n=new Map;for(const e of this.properties){const t=e,r={type:t.getType()};l.eq(t.getColor(),[1,1,1])||(r.color=t.getColor()),1!==t.getIntensity()&&(r.intensity=t.getIntensity()),null!=t.getRange()&&(r.range=t.getRange()),t.getName()&&(r.name=t.getName()),t.getType()===fe.Type.SPOT&&(r.spot={innerConeAngle:t.getInnerConeAngle(),outerConeAngle:t.getOuterConeAngle()}),s.push(r),n.set(t,s.length-1)}return this.document.getRoot().listNodes().forEach(s=>{const r=s.getExtension(ge);if(r){const o=e.nodeIndexMap.get(s),i=t.json.nodes[o];i.extensions=i.extensions||{},i.extensions[ge]={light:n.get(r)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[ge]={lights:s},this}}pe.EXTENSION_NAME=ge;const{R:xe,G:de,B:Te}=d;class me extends e{init(){this.extensionName="KHR_materials_clearcoat",this.propertyType="Clearcoat",this.parentTypes=[t.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new x(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new x(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new x(this.graph,"clearcoatNormalTextureInfo")})}getClearcoatFactor(){return this.get("clearcoatFactor")}setClearcoatFactor(e){return this.set("clearcoatFactor",e)}getClearcoatTexture(){return this.getRef("clearcoatTexture")}getClearcoatTextureInfo(){return this.getRef("clearcoatTexture")?this.getRef("clearcoatTextureInfo"):null}setClearcoatTexture(e){return this.setRef("clearcoatTexture",e,{channels:xe})}getClearcoatRoughnessFactor(){return this.get("clearcoatRoughnessFactor")}setClearcoatRoughnessFactor(e){return this.set("clearcoatRoughnessFactor",e)}getClearcoatRoughnessTexture(){return this.getRef("clearcoatRoughnessTexture")}getClearcoatRoughnessTextureInfo(){return this.getRef("clearcoatRoughnessTexture")?this.getRef("clearcoatRoughnessTextureInfo"):null}setClearcoatRoughnessTexture(e){return this.setRef("clearcoatRoughnessTexture",e,{channels:de})}getClearcoatNormalScale(){return this.get("clearcoatNormalScale")}setClearcoatNormalScale(e){return this.set("clearcoatNormalScale",e)}getClearcoatNormalTexture(){return this.getRef("clearcoatNormalTexture")}getClearcoatNormalTextureInfo(){return this.getRef("clearcoatNormalTexture")?this.getRef("clearcoatNormalTextureInfo"):null}setClearcoatNormalTexture(e){return this.setRef("clearcoatNormalTexture",e,{channels:xe|de|Te})}}me.EXTENSION_NAME="KHR_materials_clearcoat";const Ee="KHR_materials_clearcoat";class Ie extends s{constructor(...e){super(...e),this.extensionName=Ee}createClearcoat(){return new me(this.document.getGraph())}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions[Ee]){const r=this.createClearcoat();e.materials[n].setExtension(Ee,r);const o=t.extensions[Ee];if(void 0!==o.clearcoatFactor&&r.setClearcoatFactor(o.clearcoatFactor),void 0!==o.clearcoatRoughnessFactor&&r.setClearcoatRoughnessFactor(o.clearcoatRoughnessFactor),void 0!==o.clearcoatTexture){const t=o.clearcoatTexture;r.setClearcoatTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getClearcoatTextureInfo(),t)}if(void 0!==o.clearcoatRoughnessTexture){const t=o.clearcoatRoughnessTexture;r.setClearcoatRoughnessTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getClearcoatRoughnessTextureInfo(),t)}if(void 0!==o.clearcoatNormalTexture){const t=o.clearcoatNormalTexture;r.setClearcoatNormalTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getClearcoatNormalTextureInfo(),t),void 0!==t.scale&&r.setClearcoatNormalScale(t.scale)}}}),this}write(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const n=s.getExtension(Ee);if(n){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{};const i=o.extensions[Ee]={clearcoatFactor:n.getClearcoatFactor(),clearcoatRoughnessFactor:n.getClearcoatRoughnessFactor()};if(n.getClearcoatTexture()){const t=n.getClearcoatTexture(),s=n.getClearcoatTextureInfo();i.clearcoatTexture=e.createTextureInfoDef(t,s)}if(n.getClearcoatRoughnessTexture()){const t=n.getClearcoatRoughnessTexture(),s=n.getClearcoatRoughnessTextureInfo();i.clearcoatRoughnessTexture=e.createTextureInfoDef(t,s)}if(n.getClearcoatNormalTexture()){const t=n.getClearcoatNormalTexture(),s=n.getClearcoatNormalTextureInfo();i.clearcoatNormalTexture=e.createTextureInfoDef(t,s),1!==n.getClearcoatNormalScale()&&(i.clearcoatNormalTexture.scale=n.getClearcoatNormalScale())}}}),this}}Ie.EXTENSION_NAME=Ee;class Re extends e{init(){this.extensionName="KHR_materials_emissive_strength",this.propertyType="EmissiveStrength",this.parentTypes=[t.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(e){return this.set("emissiveStrength",e)}}Re.EXTENSION_NAME="KHR_materials_emissive_strength";const Ne="KHR_materials_emissive_strength";class _e extends s{constructor(...e){super(...e),this.extensionName=Ne}createEmissiveStrength(){return new Re(this.document.getGraph())}read(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{if(t.extensions&&t.extensions[Ne]){const n=this.createEmissiveStrength();e.materials[s].setExtension(Ne,n);const r=t.extensions[Ne];void 0!==r.emissiveStrength&&n.setEmissiveStrength(r.emissiveStrength)}}),this}write(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const n=s.getExtension(Ne);if(n){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{},o.extensions[Ne]={emissiveStrength:n.getEmissiveStrength()}}}),this}}_e.EXTENSION_NAME=Ne;class ye extends e{init(){this.extensionName="KHR_materials_ior",this.propertyType="IOR",this.parentTypes=[t.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(e){return this.set("ior",e)}}ye.EXTENSION_NAME="KHR_materials_ior";const Se="KHR_materials_ior";class Ae extends s{constructor(...e){super(...e),this.extensionName=Se}createIOR(){return new ye(this.document.getGraph())}read(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{if(t.extensions&&t.extensions[Se]){const n=this.createIOR();e.materials[s].setExtension(Se,n);const r=t.extensions[Se];void 0!==r.ior&&n.setIOR(r.ior)}}),this}write(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const n=s.getExtension(Se);if(n){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{},o.extensions[Se]={ior:n.getIOR()}}}),this}}Ae.EXTENSION_NAME=Se;const{R:Ce,G:Me}=d;class Oe extends e{init(){this.extensionName="KHR_materials_iridescence",this.propertyType="Iridescence",this.parentTypes=[t.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new x(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new x(this.graph,"iridescenceThicknessTextureInfo")})}getIridescenceFactor(){return this.get("iridescenceFactor")}setIridescenceFactor(e){return this.set("iridescenceFactor",e)}getIridescenceTexture(){return this.getRef("iridescenceTexture")}getIridescenceTextureInfo(){return this.getRef("iridescenceTexture")?this.getRef("iridescenceTextureInfo"):null}setIridescenceTexture(e){return this.setRef("iridescenceTexture",e,{channels:Ce})}getIridescenceIOR(){return this.get("iridescenceIOR")}setIridescenceIOR(e){return this.set("iridescenceIOR",e)}getIridescenceThicknessMinimum(){return this.get("iridescenceThicknessMinimum")}setIridescenceThicknessMinimum(e){return this.set("iridescenceThicknessMinimum",e)}getIridescenceThicknessMaximum(){return this.get("iridescenceThicknessMaximum")}setIridescenceThicknessMaximum(e){return this.set("iridescenceThicknessMaximum",e)}getIridescenceThicknessTexture(){return this.getRef("iridescenceThicknessTexture")}getIridescenceThicknessTextureInfo(){return this.getRef("iridescenceThicknessTexture")?this.getRef("iridescenceThicknessTextureInfo"):null}setIridescenceThicknessTexture(e){return this.setRef("iridescenceThicknessTexture",e,{channels:Me})}}Oe.EXTENSION_NAME="KHR_materials_iridescence";const we="KHR_materials_iridescence";class De extends s{constructor(...e){super(...e),this.extensionName=we}createIridescence(){return new Oe(this.document.getGraph())}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions[we]){const r=this.createIridescence();e.materials[n].setExtension(we,r);const o=t.extensions[we];if(void 0!==o.iridescenceFactor&&r.setIridescenceFactor(o.iridescenceFactor),void 0!==o.iridescenceIor&&r.setIridescenceIOR(o.iridescenceIor),void 0!==o.iridescenceThicknessMinimum&&r.setIridescenceThicknessMinimum(o.iridescenceThicknessMinimum),void 0!==o.iridescenceThicknessMaximum&&r.setIridescenceThicknessMaximum(o.iridescenceThicknessMaximum),void 0!==o.iridescenceTexture){const t=o.iridescenceTexture;r.setIridescenceTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getIridescenceTextureInfo(),t)}if(void 0!==o.iridescenceThicknessTexture){const t=o.iridescenceThicknessTexture;r.setIridescenceThicknessTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getIridescenceThicknessTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const n=s.getExtension(we);if(n){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{};const i=o.extensions[we]={};if(n.getIridescenceFactor()>0&&(i.iridescenceFactor=n.getIridescenceFactor()),1.3!==n.getIridescenceIOR()&&(i.iridescenceIor=n.getIridescenceIOR()),100!==n.getIridescenceThicknessMinimum()&&(i.iridescenceThicknessMinimum=n.getIridescenceThicknessMinimum()),400!==n.getIridescenceThicknessMaximum()&&(i.iridescenceThicknessMaximum=n.getIridescenceThicknessMaximum()),n.getIridescenceTexture()){const t=n.getIridescenceTexture(),s=n.getIridescenceTextureInfo();i.iridescenceTexture=e.createTextureInfoDef(t,s)}if(n.getIridescenceThicknessTexture()){const t=n.getIridescenceThicknessTexture(),s=n.getIridescenceThicknessTextureInfo();i.iridescenceThicknessTexture=e.createTextureInfoDef(t,s)}}}),this}}De.EXTENSION_NAME=we;const{R:be,G:Fe,B:je,A:ve}=d;class ke extends e{init(){this.extensionName="KHR_materials_pbrSpecularGlossiness",this.propertyType="PBRSpecularGlossiness",this.parentTypes=[t.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new x(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new x(this.graph,"specularGlossinessTextureInfo")})}getDiffuseFactor(){return this.get("diffuseFactor")}setDiffuseFactor(e){return this.set("diffuseFactor",e)}getDiffuseHex(){return p.factorToHex(this.getDiffuseFactor())}setDiffuseHex(e){const t=this.getDiffuseFactor().slice();return this.setDiffuseFactor(p.hexToFactor(e,t))}getDiffuseTexture(){return this.getRef("diffuseTexture")}getDiffuseTextureInfo(){return this.getRef("diffuseTexture")?this.getRef("diffuseTextureInfo"):null}setDiffuseTexture(e){return this.setRef("diffuseTexture",e,{channels:be|Fe|je|ve})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(e){return this.set("specularFactor",e)}getGlossinessFactor(){return this.get("glossinessFactor")}setGlossinessFactor(e){return this.set("glossinessFactor",e)}getSpecularGlossinessTexture(){return this.getRef("specularGlossinessTexture")}getSpecularGlossinessTextureInfo(){return this.getRef("specularGlossinessTexture")?this.getRef("specularGlossinessTextureInfo"):null}setSpecularGlossinessTexture(e){return this.setRef("specularGlossinessTexture",e,{channels:be|Fe|je|ve})}}ke.EXTENSION_NAME="KHR_materials_pbrSpecularGlossiness";const Be="KHR_materials_pbrSpecularGlossiness";class Ge extends s{constructor(...e){super(...e),this.extensionName=Be}createPBRSpecularGlossiness(){return new ke(this.document.getGraph())}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions[Be]){const r=this.createPBRSpecularGlossiness();e.materials[n].setExtension(Be,r);const o=t.extensions[Be];if(void 0!==o.diffuseFactor&&r.setDiffuseFactor(o.diffuseFactor),void 0!==o.specularFactor&&r.setSpecularFactor(o.specularFactor),void 0!==o.glossinessFactor&&r.setGlossinessFactor(o.glossinessFactor),void 0!==o.diffuseTexture){const t=o.diffuseTexture;r.setDiffuseTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getDiffuseTextureInfo(),t)}if(void 0!==o.specularGlossinessTexture){const t=o.specularGlossinessTexture;r.setSpecularGlossinessTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getSpecularGlossinessTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const n=s.getExtension(Be);if(n){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{};const i=o.extensions[Be]={diffuseFactor:n.getDiffuseFactor(),specularFactor:n.getSpecularFactor(),glossinessFactor:n.getGlossinessFactor()};if(n.getDiffuseTexture()){const t=n.getDiffuseTexture(),s=n.getDiffuseTextureInfo();i.diffuseTexture=e.createTextureInfoDef(t,s)}if(n.getSpecularGlossinessTexture()){const t=n.getSpecularGlossinessTexture(),s=n.getSpecularGlossinessTextureInfo();i.specularGlossinessTexture=e.createTextureInfoDef(t,s)}}}),this}}Ge.EXTENSION_NAME=Be;const{R:Le,G:He,B:Ue,A:Ve}=d;class Pe extends e{init(){this.extensionName="KHR_materials_sheen",this.propertyType="Sheen",this.parentTypes=[t.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new x(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new x(this.graph,"sheenRoughnessTextureInfo")})}getSheenColorFactor(){return this.get("sheenColorFactor")}getSheenColorHex(){return p.factorToHex(this.getSheenColorFactor())}setSheenColorFactor(e){return this.set("sheenColorFactor",e)}setSheenColorHex(e){const t=this.getSheenColorFactor().slice();return this.set("sheenColorFactor",p.hexToFactor(e,t))}getSheenColorTexture(){return this.getRef("sheenColorTexture")}getSheenColorTextureInfo(){return this.getRef("sheenColorTexture")?this.getRef("sheenColorTextureInfo"):null}setSheenColorTexture(e){return this.setRef("sheenColorTexture",e,{channels:Le|He|Ue})}getSheenRoughnessFactor(){return this.get("sheenRoughnessFactor")}setSheenRoughnessFactor(e){return this.set("sheenRoughnessFactor",e)}getSheenRoughnessTexture(){return this.getRef("sheenRoughnessTexture")}getSheenRoughnessTextureInfo(){return this.getRef("sheenRoughnessTexture")?this.getRef("sheenRoughnessTextureInfo"):null}setSheenRoughnessTexture(e){return this.setRef("sheenRoughnessTexture",e,{channels:Ve})}}Pe.EXTENSION_NAME="KHR_materials_sheen";const Xe="KHR_materials_sheen";class Ke extends s{constructor(...e){super(...e),this.extensionName=Xe}createSheen(){return new Pe(this.document.getGraph())}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions[Xe]){const r=this.createSheen();e.materials[n].setExtension(Xe,r);const o=t.extensions[Xe];if(void 0!==o.sheenColorFactor&&r.setSheenColorFactor(o.sheenColorFactor),void 0!==o.sheenRoughnessFactor&&r.setSheenRoughnessFactor(o.sheenRoughnessFactor),void 0!==o.sheenColorTexture){const t=o.sheenColorTexture;r.setSheenColorTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getSheenColorTextureInfo(),t)}if(void 0!==o.sheenRoughnessTexture){const t=o.sheenRoughnessTexture;r.setSheenRoughnessTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getSheenRoughnessTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const n=s.getExtension(Xe);if(n){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{};const i=o.extensions[Xe]={sheenColorFactor:n.getSheenColorFactor(),sheenRoughnessFactor:n.getSheenRoughnessFactor()};if(n.getSheenColorTexture()){const t=n.getSheenColorTexture(),s=n.getSheenColorTextureInfo();i.sheenColorTexture=e.createTextureInfoDef(t,s)}if(n.getSheenRoughnessTexture()){const t=n.getSheenRoughnessTexture(),s=n.getSheenRoughnessTextureInfo();i.sheenRoughnessTexture=e.createTextureInfoDef(t,s)}}}),this}}Ke.EXTENSION_NAME=Xe;const{R:ze,G:$e,B:qe,A:Ye}=d;class Qe extends e{init(){this.extensionName="KHR_materials_specular",this.propertyType="Specular",this.parentTypes=[t.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new x(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new x(this.graph,"specularColorTextureInfo")})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(e){return this.set("specularFactor",e)}getSpecularColorFactor(){return this.get("specularColorFactor")}setSpecularColorFactor(e){return this.set("specularColorFactor",e)}getSpecularColorHex(){return p.factorToHex(this.getSpecularColorFactor())}setSpecularColorHex(e){const t=this.getSpecularColorFactor().slice();return this.set("specularColorFactor",p.hexToFactor(e,t))}getSpecularTexture(){return this.getRef("specularTexture")}getSpecularTextureInfo(){return this.getRef("specularTexture")?this.getRef("specularTextureInfo"):null}setSpecularTexture(e){return this.setRef("specularTexture",e,{channels:Ye})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(e){return this.setRef("specularColorTexture",e,{channels:ze|$e|qe})}}Qe.EXTENSION_NAME="KHR_materials_specular";const We="KHR_materials_specular";class Je extends s{constructor(...e){super(...e),this.extensionName=We}createSpecular(){return new Qe(this.document.getGraph())}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions[We]){const r=this.createSpecular();e.materials[n].setExtension(We,r);const o=t.extensions[We];if(void 0!==o.specularFactor&&r.setSpecularFactor(o.specularFactor),void 0!==o.specularColorFactor&&r.setSpecularColorFactor(o.specularColorFactor),void 0!==o.specularTexture){const t=o.specularTexture;r.setSpecularTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getSpecularTextureInfo(),t)}if(void 0!==o.specularColorTexture){const t=o.specularColorTexture;r.setSpecularColorTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getSpecularColorTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const n=s.getExtension(We);if(n){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{};const i=o.extensions[We]={};if(1!==n.getSpecularFactor()&&(i.specularFactor=n.getSpecularFactor()),l.eq(n.getSpecularColorFactor(),[1,1,1])||(i.specularColorFactor=n.getSpecularColorFactor()),n.getSpecularTexture()){const t=n.getSpecularTexture(),s=n.getSpecularTextureInfo();i.specularTexture=e.createTextureInfoDef(t,s)}if(n.getSpecularColorTexture()){const t=n.getSpecularColorTexture(),s=n.getSpecularColorTextureInfo();i.specularColorTexture=e.createTextureInfoDef(t,s)}}}),this}}Je.EXTENSION_NAME=We;const{R:Ze}=d;class et extends e{init(){this.extensionName="KHR_materials_transmission",this.propertyType="Transmission",this.parentTypes=[t.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new x(this.graph,"transmissionTextureInfo")})}getTransmissionFactor(){return this.get("transmissionFactor")}setTransmissionFactor(e){return this.set("transmissionFactor",e)}getTransmissionTexture(){return this.getRef("transmissionTexture")}getTransmissionTextureInfo(){return this.getRef("transmissionTexture")?this.getRef("transmissionTextureInfo"):null}setTransmissionTexture(e){return this.setRef("transmissionTexture",e,{channels:Ze})}}et.EXTENSION_NAME="KHR_materials_transmission";const tt="KHR_materials_transmission";class st extends s{constructor(...e){super(...e),this.extensionName=tt}createTransmission(){return new et(this.document.getGraph())}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions[tt]){const r=this.createTransmission();e.materials[n].setExtension(tt,r);const o=t.extensions[tt];if(void 0!==o.transmissionFactor&&r.setTransmissionFactor(o.transmissionFactor),void 0!==o.transmissionTexture){const t=o.transmissionTexture;r.setTransmissionTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getTransmissionTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const n=s.getExtension(tt);if(n){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{};const i=o.extensions[tt]={transmissionFactor:n.getTransmissionFactor()};if(n.getTransmissionTexture()){const t=n.getTransmissionTexture(),s=n.getTransmissionTextureInfo();i.transmissionTexture=e.createTextureInfoDef(t,s)}}}),this}}st.EXTENSION_NAME=tt;class nt extends e{init(){this.extensionName="KHR_materials_unlit",this.propertyType="Unlit",this.parentTypes=[t.MATERIAL]}}nt.EXTENSION_NAME="KHR_materials_unlit";const rt="KHR_materials_unlit";class ot extends s{constructor(...e){super(...e),this.extensionName=rt}createUnlit(){return new nt(this.document.getGraph())}read(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{t.extensions&&t.extensions[rt]&&e.materials[s].setExtension(rt,this.createUnlit())}),this}write(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{if(s.getExtension(rt)){const n=e.materialIndexMap.get(s),r=t.json.materials[n];r.extensions=r.extensions||{},r.extensions[rt]={}}}),this}}ot.EXTENSION_NAME=rt;class it extends e{init(){this.extensionName="KHR_materials_variants",this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:[]})}getMaterial(){return this.getRef("material")}setMaterial(e){return this.setRef("material",e)}addVariant(e){return this.addRef("variants",e)}removeVariant(e){return this.removeRef("variants",e)}listVariants(){return this.listRefs("variants")}}it.EXTENSION_NAME="KHR_materials_variants";class at extends e{init(){this.extensionName="KHR_materials_variants",this.propertyType="MappingList",this.parentTypes=[t.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:[]})}addMapping(e){return this.addRef("mappings",e)}removeMapping(e){return this.removeRef("mappings",e)}listMappings(){return this.listRefs("mappings")}}at.EXTENSION_NAME="KHR_materials_variants";class ct extends e{init(){this.extensionName="KHR_materials_variants",this.propertyType="Variant",this.parentTypes=["MappingList"]}}ct.EXTENSION_NAME="KHR_materials_variants";const ut="KHR_materials_variants";class lt extends s{constructor(...e){super(...e),this.extensionName=ut}createMappingList(){return new at(this.document.getGraph())}createVariant(e=""){return new ct(this.document.getGraph(),e)}createMapping(){return new it(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter(e=>e instanceof ct)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions[ut])return this;const s=(t.json.extensions[ut].variants||[]).map(e=>this.createVariant().setName(e.name||""));return(t.json.meshes||[]).forEach((t,n)=>{const r=e.meshes[n];(t.primitives||[]).forEach((t,n)=>{if(!t.extensions||!t.extensions[ut])return;const o=this.createMappingList(),i=t.extensions[ut];for(const t of i.mappings){const n=this.createMapping();void 0!==t.material&&n.setMaterial(e.materials[t.material]);for(const e of t.variants||[])n.addVariant(s[e]);o.addMapping(n)}r.listPrimitives()[n].setExtension(ut,o)})}),this}write(e){const t=e.jsonDoc,s=this.listVariants();if(!s.length)return this;const n=[],r=new Map;for(const t of s)r.set(t,n.length),n.push(e.createPropertyDef(t));for(const t of this.document.getRoot().listMeshes()){const s=e.meshIndexMap.get(t);t.listPrimitives().forEach((t,n)=>{const o=t.getExtension(ut);if(!o)return;const i=e.jsonDoc.json.meshes[s].primitives[n],a=o.listMappings().map(t=>{const s=e.createPropertyDef(t),n=t.getMaterial();return n&&(s.material=e.materialIndexMap.get(n)),s.variants=t.listVariants().map(e=>r.get(e)),s});i.extensions=i.extensions||{},i.extensions[ut]={mappings:a}})}return t.json.extensions=t.json.extensions||{},t.json.extensions[ut]={variants:n},this}}lt.EXTENSION_NAME=ut;const{G:ht}=d;class ft extends e{init(){this.extensionName="KHR_materials_volume",this.propertyType="Volume",this.parentTypes=[t.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new x(this.graph,"thicknessTexture"),attenuationDistance:Infinity,attenuationColor:[1,1,1]})}getThicknessFactor(){return this.get("thicknessFactor")}setThicknessFactor(e){return this.set("thicknessFactor",e)}getThicknessTexture(){return this.getRef("thicknessTexture")}getThicknessTextureInfo(){return this.getRef("thicknessTexture")?this.getRef("thicknessTextureInfo"):null}setThicknessTexture(e){return this.setRef("thicknessTexture",e,{channels:ht})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(e){return this.set("attenuationDistance",e)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(e){return this.set("attenuationColor",e)}getAttenuationColorHex(){return p.factorToHex(this.getAttenuationColor())}setAttenuationColorHex(e){const t=this.getAttenuationColor().slice();return this.set("attenuationColor",p.hexToFactor(e,t))}}ft.EXTENSION_NAME="KHR_materials_volume";const gt="KHR_materials_volume";class pt extends s{constructor(...e){super(...e),this.extensionName=gt}createVolume(){return new ft(this.document.getGraph())}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions[gt]){const r=this.createVolume();e.materials[n].setExtension(gt,r);const o=t.extensions[gt];if(void 0!==o.thicknessFactor&&r.setThicknessFactor(o.thicknessFactor),void 0!==o.attenuationDistance&&r.setAttenuationDistance(o.attenuationDistance),void 0!==o.attenuationColor&&r.setAttenuationColor(o.attenuationColor),void 0!==o.thicknessTexture){const t=o.thicknessTexture;r.setThicknessTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getThicknessTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const n=s.getExtension(gt);if(n){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{};const i=o.extensions[gt]={};if(n.getThicknessFactor()>0&&(i.thicknessFactor=n.getThicknessFactor()),Number.isFinite(n.getAttenuationDistance())&&(i.attenuationDistance=n.getAttenuationDistance()),l.eq(n.getAttenuationColor(),[1,1,1])||(i.attenuationColor=n.getAttenuationColor()),n.getThicknessTexture()){const t=n.getThicknessTexture(),s=n.getThicknessTextureInfo();i.thicknessTexture=e.createTextureInfoDef(t,s)}}}),this}}pt.EXTENSION_NAME=gt;const xt="KHR_mesh_quantization";class dt extends s{constructor(...e){super(...e),this.extensionName=xt}read(e){return this}write(e){return this}}dt.EXTENSION_NAME=xt;const Tt="KHR_texture_basisu";class mt{match(e){return 171===e[0]&&75===e[1]&&84===e[2]&&88===e[3]&&32===e[4]&&50===e[5]&&48===e[6]&&187===e[7]&&13===e[8]&&10===e[9]&&26===e[10]&&10===e[11]}getSize(e){const t=T(e);return[t.pixelWidth,t.pixelHeight]}getChannels(e){const t=T(e).dataFormatDescriptor[0];if(t.colorModel===m)return 2===t.samples.length&&15==(15&t.samples[1].channelType)?4:3;if(t.colorModel===E)return 3==(15&t.samples[0].channelType)?4:3;throw new Error(`Unexpected KTX2 colorModel, "${t.colorModel}".`)}getVRAMByteLength(e){const t=T(e),s=this.getChannels(e)>3;let n=0;for(let e=0;e<t.levels.length;e++){const r=t.levels[e];n+=r.uncompressedByteLength?r.uncompressedByteLength:Math.max(1,Math.floor(t.pixelWidth/Math.pow(2,e)))/4*(Math.max(1,Math.floor(t.pixelHeight/Math.pow(2,e)))/4)*(s?16:8)}return n}}class Et extends s{constructor(...e){super(...e),this.extensionName=Tt,this.prereadTypes=[t.TEXTURE]}static register(){f.registerFormat("image/ktx2",new mt)}preread(e){return e.jsonDoc.json.textures.forEach(e=>{e.extensions&&e.extensions[Tt]&&(e.source=e.extensions[Tt].source)}),this}read(e){return this}write(e){const t=e.jsonDoc;return this.document.getRoot().listTextures().forEach(s=>{if("image/ktx2"===s.getMimeType()){const n=e.imageIndexMap.get(s);t.json.textures.forEach(e=>{e.source===n&&(e.extensions=e.extensions||{},e.extensions[Tt]={source:e.source},delete e.source)})}}),this}}Et.EXTENSION_NAME=Tt;class It extends e{init(){this.extensionName="KHR_texture_transform",this.propertyType="Transform",this.parentTypes=[t.TEXTURE_INFO]}getDefaults(){return Object.assign(super.getDefaults(),{offset:[0,0],rotation:0,scale:[1,1],texCoord:null})}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getRotation(){return this.get("rotation")}setRotation(e){return this.set("rotation",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getTexCoord(){return this.get("texCoord")}setTexCoord(e){return this.set("texCoord",e)}}It.EXTENSION_NAME="KHR_texture_transform";const Rt="KHR_texture_transform";class Nt extends s{constructor(...e){super(...e),this.extensionName=Rt}createTransform(){return new It(this.document.getGraph())}read(e){for(const[t,s]of Array.from(e.textureInfos.entries())){if(!s.extensions||!s.extensions[Rt])continue;const e=this.createTransform(),n=s.extensions[Rt];void 0!==n.offset&&e.setOffset(n.offset),void 0!==n.rotation&&e.setRotation(n.rotation),void 0!==n.scale&&e.setScale(n.scale),void 0!==n.texCoord&&e.setTexCoord(n.texCoord),t.setExtension(Rt,e)}return this}write(e){const t=Array.from(e.textureInfoDefMap.entries());for(const[e,s]of t){const t=e.getExtension(Rt);if(!t)continue;s.extensions=s.extensions||{};const n={},r=l.eq;r(t.getOffset(),[0,0])||(n.offset=t.getOffset()),0!==t.getRotation()&&(n.rotation=t.getRotation()),r(t.getScale(),[1,1])||(n.scale=t.getScale()),null!=t.getTexCoord()&&(n.texCoord=t.getTexCoord()),s.extensions[Rt]=n}return this}}Nt.EXTENSION_NAME=Rt;const _t=[t.ROOT,t.SCENE,t.NODE,t.MESH,t.MATERIAL,t.TEXTURE,t.ANIMATION];class yt extends e{init(){this.extensionName="KHR_xmp_json_ld",this.propertyType="Packet",this.parentTypes=_t}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(e){return this.set("context",y({},e))}listProperties(){return Object.keys(this.get("properties"))}getProperty(e){const t=this.get("properties");return e in t?t[e]:null}setProperty(e,t){this._assertContext(e);const s=y({},this.get("properties"));return t?s[e]=t:delete s[e],this.set("properties",s)}toJSONLD(){return y({"@context":St(this.get("context"))},St(this.get("properties")))}fromJSONLD(e){const t=(e=St(e))["@context"];return t&&this.set("context",t),delete e["@context"],this.set("properties",e)}_assertContext(e){if(!(e.split(":")[0]in this.get("context")))throw new Error(`KHR_xmp_json_ld: Missing context for term, "${e}".`)}}function St(e){return JSON.parse(JSON.stringify(e))}yt.EXTENSION_NAME="KHR_xmp_json_ld";const At="KHR_xmp_json_ld";class Ct extends s{constructor(...e){super(...e),this.extensionName=At}createPacket(){return new yt(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(e){var t;const s=null==(t=e.jsonDoc.json.extensions)?void 0:t[At];if(!s||!s.packets)return this;const n=e.jsonDoc.json,r=this.document.getRoot(),o=s.packets.map(e=>this.createPacket().fromJSONLD(e)),i=[[n.asset],n.scenes,n.nodes,n.meshes,n.materials,n.images,n.animations],a=[[r],r.listScenes(),r.listNodes(),r.listMeshes(),r.listMaterials(),r.listTextures(),r.listAnimations()];for(let e=0;e<i.length;e++){const t=i[e]||[];for(let s=0;s<t.length;s++){const n=t[s];n.extensions&&n.extensions[At]&&a[e][s].setExtension(At,o[n.extensions[At].packet])}}return this}write(e){const{json:s}=e.jsonDoc,n=[];for(const r of this.properties){n.push(r.toJSONLD());for(const o of r.listParents()){let r;switch(o.propertyType){case t.ROOT:r=s.asset;break;case t.SCENE:r=s.scenes[e.sceneIndexMap.get(o)];break;case t.NODE:r=s.nodes[e.nodeIndexMap.get(o)];break;case t.MESH:r=s.meshes[e.meshIndexMap.get(o)];break;case t.MATERIAL:r=s.materials[e.materialIndexMap.get(o)];break;case t.TEXTURE:r=s.images[e.imageIndexMap.get(o)];break;case t.ANIMATION:r=s.animations[e.animationIndexMap.get(o)];break;default:r=null,this.document.getLogger().warn(`[${At}]: Unsupported parent property, "${o.propertyType}"`)}r&&(r.extensions=r.extensions||{},r.extensions[At]={packet:n.length-1})}}return n.length>0&&(s.extensions=s.extensions||{},s.extensions[At]={packets:n}),this}}Ct.EXTENSION_NAME=At;const Mt=[le,pe,Ie,_e,Ae,De,Ge,Je,Ke,st,ot,lt,pt,dt,Et,Nt,Ct],Ot=[_,L,V,z,...Mt];export{Ot as ALL_EXTENSIONS,me as Clearcoat,_ as EXTMeshGPUInstancing,L as EXTMeshoptCompression,V as EXTTextureAVIF,z as EXTTextureWebP,Re as EmissiveStrength,I as INSTANCE_ATTRIBUTE,ye as IOR,R as InstancedMesh,Oe as Iridescence,le as KHRDracoMeshCompression,pe as KHRLightsPunctual,Ie as KHRMaterialsClearcoat,_e as KHRMaterialsEmissiveStrength,Ae as KHRMaterialsIOR,De as KHRMaterialsIridescence,Ge as KHRMaterialsPBRSpecularGlossiness,Ke as KHRMaterialsSheen,Je as KHRMaterialsSpecular,st as KHRMaterialsTransmission,ot as KHRMaterialsUnlit,lt as KHRMaterialsVariants,pt as KHRMaterialsVolume,dt as KHRMeshQuantization,Mt as KHRONOS_EXTENSIONS,Et as KHRTextureBasisu,Nt as KHRTextureTransform,Ct as KHRXMP,fe as Light,it as Mapping,at as MappingList,ke as PBRSpecularGlossiness,yt as Packet,Pe as Sheen,Qe as Specular,It as Transform,et as Transmission,nt as Unlit,ct as Variant,ft as Volume};
import{ExtensionProperty as e,PropertyType as t,Extension as s,BufferUtils as n,WriterContext as r,Primitive as o,Root as i,AnimationSampler as a,AnimationChannel as c,Accessor as u,MathUtils as l,GLB_BUFFER as h,ImageUtils as f,getBounds as g,ColorUtils as p,TextureInfo as x,TextureChannel as d}from"@gltf-transform/core";import{read as T,KHR_DF_MODEL_ETC1S as m,KHR_DF_MODEL_UASTC as E}from"ktx-parse";const I="INSTANCE_ATTRIBUTE";class R extends e{init(){this.extensionName="EXT_mesh_gpu_instancing",this.propertyType="InstancedMesh",this.parentTypes=[t.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:{}})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:"INSTANCE_ATTRIBUTE"})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}R.EXTENSION_NAME="EXT_mesh_gpu_instancing";const N="EXT_mesh_gpu_instancing";class y extends s{constructor(...e){super(...e),this.extensionName=N,this.provideTypes=[t.NODE],this.prewriteTypes=[t.ACCESSOR]}createInstancedMesh(){return new R(this.document.getGraph())}read(e){return(e.jsonDoc.json.nodes||[]).forEach((t,s)=>{if(!t.extensions||!t.extensions[N])return;const n=t.extensions[N],r=this.createInstancedMesh();for(const t in n.attributes)r.setAttribute(t,e.accessors[n.attributes[t]]);e.nodes[s].setExtension(N,r)}),this}prewrite(e){e.accessorUsageGroupedByParent.add("INSTANCE_ATTRIBUTE");for(const t of this.properties)for(const s of t.listAttributes())e.addAccessorToUsageGroup(s,"INSTANCE_ATTRIBUTE");return this}write(e){const t=e.jsonDoc;return this.document.getRoot().listNodes().forEach(s=>{const n=s.getExtension(N);if(n){const r=e.nodeIndexMap.get(s),o=t.json.nodes[r],i={attributes:{}};n.listSemantics().forEach(t=>{const s=n.getAttribute(t);i.attributes[t]=e.accessorIndexMap.get(s)}),o.extensions=o.extensions||{},o.extensions[N]=i}}),this}}function _(){return(_=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e}).apply(this,arguments)}var A,S,C;y.EXTENSION_NAME=N,function(e){e.QUANTIZE="quantize",e.FILTER="filter"}(A||(A={})),function(e){e.ATTRIBUTES="ATTRIBUTES",e.TRIANGLES="TRIANGLES",e.INDICES="INDICES"}(S||(S={})),function(e){e.NONE="NONE",e.OCTAHEDRAL="OCTAHEDRAL",e.QUATERNION="QUATERNION",e.EXPONENTIAL="EXPONENTIAL"}(C||(C={}));const{BYTE:M,SHORT:O,FLOAT:w}=u.ComponentType,{encodeNormalizedInt:D,decodeNormalizedInt:b}=l;function F(e,t,s,r){const{filter:o,bits:i}=r,a={array:e.getArray(),byteStride:e.getElementSize()*e.getComponentSize(),componentType:e.getComponentType(),normalized:e.getNormalized()};if(s!==S.ATTRIBUTES)return a;if(o!==C.NONE){let s=e.getNormalized()?function(e){const t=e.getComponentType(),s=e.getArray(),n=new Float32Array(s.length);for(let e=0;e<s.length;e++)n[e]=b(s[e],t);return n}(e):new Float32Array(a.array);switch(o){case C.EXPONENTIAL:a.byteStride=4*e.getElementSize(),a.componentType=w,a.normalized=!1,a.array=t.encodeFilterExp(s,e.getCount(),a.byteStride,i);break;case C.OCTAHEDRAL:a.byteStride=i>8?8:4,a.componentType=i>8?O:M,a.normalized=!0,s=3===e.getElementSize()?function(e){const t=new Float32Array(4*e.length/3);for(let s=0,n=e.length/3;s<n;s++)t[4*s]=e[3*s],t[4*s+1]=e[3*s+1],t[4*s+2]=e[3*s+2];return t}(s):s,a.array=t.encodeFilterOct(s,e.getCount(),a.byteStride,i);break;case C.QUATERNION:a.byteStride=8,a.componentType=O,a.normalized=!0,a.array=t.encodeFilterQuat(s,e.getCount(),a.byteStride,i);break;default:throw new Error("Invalid filter.")}a.min=e.getMin([]),a.max=e.getMax([]),e.getNormalized()&&(a.min=a.min.map(t=>b(t,e.getComponentType())),a.max=a.max.map(t=>b(t,e.getComponentType()))),a.normalized&&(a.min=a.min.map(e=>D(e,a.componentType)),a.max=a.max.map(e=>D(e,a.componentType)))}else a.byteStride%4&&(a.array=function(e,t){const s=n.padNumber(e.BYTES_PER_ELEMENT*t)/e.BYTES_PER_ELEMENT,r=new e.constructor(e.length/t*s);for(let n=0;n*t<e.length;n++)for(let o=0;o<t;o++)r[n*s+o]=e[n*t+o];return r}(a.array,e.getElementSize()),a.byteStride=a.array.byteLength/e.getCount());return a}function j(e,t){return t===r.BufferViewUsage.ELEMENT_ARRAY_BUFFER?e.listParents().some(e=>e instanceof o&&e.getMode()===o.Mode.TRIANGLES)?S.TRIANGLES:S.INDICES:S.ATTRIBUTES}function v(e,t){const s=t.getGraph().listParentEdges(e).filter(e=>!(e.getParent()instanceof i));for(const t of s){const s=t.getName(),n=t.getAttributes().key||"";if("indices"===s)return{filter:C.NONE};if("attributes"===s){if("POSITION"===n)return{filter:C.NONE};if("TEXCOORD_0"===n)return{filter:C.NONE};if("NORMAL"===n)return{filter:C.OCTAHEDRAL,bits:8};if("TANGENT"===n)return{filter:C.OCTAHEDRAL,bits:8};if(n.startsWith("JOINTS_"))return{filter:C.NONE};if(n.startsWith("WEIGHTS_"))return{filter:C.NONE}}if("output"===s){const t=k(e);return"rotation"===t?{filter:C.QUATERNION,bits:16}:"translation"===t||"scale"===t?{filter:C.EXPONENTIAL,bits:12}:{filter:C.NONE}}if("input"===s)return{filter:C.NONE};if("inverseBindMatrices"===s)return{filter:C.NONE}}return{filter:C.NONE}}function k(e){for(const t of e.listParents())if(t instanceof a)for(const e of t.listParents())if(e instanceof c)return e.getTargetPath();return null}const B="EXT_meshopt_compression",G={method:A.QUANTIZE};class L extends s{constructor(...e){super(...e),this.extensionName=B,this.prereadTypes=[t.BUFFER,t.PRIMITIVE],this.prewriteTypes=[t.BUFFER,t.ACCESSOR],this.readDependencies=["meshopt.decoder"],this.writeDependencies=["meshopt.encoder"],this._decoder=null,this._decoderFallbackBufferMap=new Map,this._encoder=null,this._encoderOptions=G,this._encoderFallbackBuffer=null,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={}}install(e,t){return"meshopt.decoder"===e&&(this._decoder=t),"meshopt.encoder"===e&&(this._encoder=t),this}setEncoderOptions(e){return this._encoderOptions=_({},G,e),this}preread(e,s){if(!this._decoder){if(!this.isRequired())return this;throw new Error(`[${B}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw new Error(`[${B}]: Missing WASM support.`)}return s===t.BUFFER?this._prereadBuffers(e):s===t.PRIMITIVE&&this._prereadPrimitives(e),this}_prereadBuffers(e){const t=e.jsonDoc;(t.json.bufferViews||[]).forEach((s,r)=>{if(!s.extensions||!s.extensions[B])return;const o=s.extensions[B],i=o.byteOffset||0,a=o.byteLength||0,c=o.count,u=o.byteStride,l=new Uint8Array(c*u),f=t.json.buffers[o.buffer],g=n.toView(f.uri?t.resources[f.uri]:t.resources[h],i,a);this._decoder.decodeGltfBuffer(l,c,u,g,o.mode,o.filter),e.bufferViews[r]=l})}_prereadPrimitives(e){const t=e.jsonDoc;(t.json.bufferViews||[]).forEach(s=>{var n;s.extensions&&s.extensions[B]&&(n=t.json.buffers[s.buffer]).extensions&&n.extensions.EXT_meshopt_compression&&n.extensions.EXT_meshopt_compression.fallback&&this._decoderFallbackBufferMap.set(e.buffers[s.buffer],e.buffers[s.extensions[B].buffer])})}read(e){if(!this.isRequired())return this;for(const[e,t]of this._decoderFallbackBufferMap){for(const s of e.listParents())s instanceof u&&s.swap(e,t);e.dispose()}return this}prewrite(e,s){return s===t.ACCESSOR?this._prewriteAccessors(e):s===t.BUFFER&&this._prewriteBuffers(e),this}_prewriteAccessors(e){const t=e.jsonDoc.json,s=this._encoder,n=this._encoderOptions,o=this.document.createBuffer(),i=this.document.getRoot().listBuffers().indexOf(o);this._encoderFallbackBuffer=o,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(const o of this.document.getRoot().listAccessors()){if("weights"===k(o))continue;if(o.getSparse())continue;const a=e.getAccessorUsage(o),c=j(o,a),u=n.method===A.FILTER?v(o,this.document):{filter:C.NONE},l=F(o,s,c,u),{array:h,byteStride:f}=l,g=o.getBuffer();if(!g)throw new Error(`${B}: Missing buffer for accessor.`);const p=this.document.getRoot().listBuffers().indexOf(g),x=[a,c,u.filter,f,p].join(":");let d=this._encoderBufferViews[x],T=this._encoderBufferViewData[x],m=this._encoderBufferViewAccessors[x];d&&T||(m=this._encoderBufferViewAccessors[x]=[],T=this._encoderBufferViewData[x]=[],d=this._encoderBufferViews[x]={buffer:i,target:r.USAGE_TO_TARGET[a],byteOffset:0,byteLength:0,byteStride:a===r.BufferViewUsage.ARRAY_BUFFER?f:void 0,extensions:{[B]:{buffer:p,byteOffset:0,byteLength:0,mode:c,filter:u.filter!==C.NONE?u.filter:void 0,byteStride:f,count:0}}});const E=e.createAccessorDef(o);E.componentType=l.componentType,E.normalized=l.normalized,E.byteOffset=d.byteLength,E.min&&l.min&&(E.min=l.min),E.max&&l.max&&(E.max=l.max),e.accessorIndexMap.set(o,t.accessors.length),t.accessors.push(E),m.push(E),T.push(new Uint8Array(h.buffer,h.byteOffset,h.byteLength)),d.byteLength+=h.byteLength,d.extensions.EXT_meshopt_compression.count+=o.getCount()}}_prewriteBuffers(e){const t=this._encoder;for(const s in this._encoderBufferViews){const r=this._encoderBufferViews[s],o=this._encoderBufferViewData[s],i=this.document.getRoot().listBuffers()[r.extensions[B].buffer],a=e.otherBufferViews.get(i)||[],{count:c,byteStride:u,mode:l}=r.extensions[B],h=n.concat(o),f=t.encodeGltfBuffer(h,c,u,l),g=n.pad(f);r.extensions[B].byteLength=f.byteLength,o.length=0,o.push(g),a.push(g),e.otherBufferViews.set(i,a)}}write(e){let t=0;for(const s in this._encoderBufferViews){const r=this._encoderBufferViews[s],o=e.otherBufferViewsIndexMap.get(this._encoderBufferViewData[s][0]),i=this._encoderBufferViewAccessors[s];for(const e of i)e.bufferView=o;const a=e.jsonDoc.json.bufferViews[o],c=a.byteOffset||0;Object.assign(a,r),a.byteOffset=t,a.extensions[B].byteOffset=c,t+=n.padNumber(r.byteLength)}const s=this._encoderFallbackBuffer,r=e.bufferIndexMap.get(s),o=e.jsonDoc.json.buffers[r];return o.byteLength=t,o.extensions={[B]:{fallback:!0}},s.dispose(),this}}L.EXTENSION_NAME=B,L.EncoderMethod=A;const H="EXT_texture_avif";class U{match(e){return e.length>=12&&"ftypavif"===n.decodeText(e.slice(4,12))}getSize(e){if(!this.match(e))return null;const t=new DataView(e.buffer,e.byteOffset,e.byteLength);let s=P(t,0);if(!s)return null;let n=s.end;for(;s=P(t,n);)if("meta"===s.type)n=s.start+4;else if("iprp"===s.type||"ipco"===s.type)n=s.start;else{if("ispe"===s.type)return[t.getUint32(s.start+4),t.getUint32(s.start+8)];if("mdat"===s.type)break;n=s.end}return null}getChannels(e){return 4}}class V extends s{constructor(...e){super(...e),this.extensionName=H,this.prereadTypes=[t.TEXTURE]}static register(){f.registerFormat("image/avif",new U)}preread(e){return(e.jsonDoc.json.textures||[]).forEach(e=>{e.extensions&&e.extensions[H]&&(e.source=e.extensions[H].source)}),this}read(e){return this}write(e){const t=e.jsonDoc;return this.document.getRoot().listTextures().forEach(s=>{if("image/avif"===s.getMimeType()){const n=e.imageIndexMap.get(s);(t.json.textures||[]).forEach(e=>{e.source===n&&(e.extensions=e.extensions||{},e.extensions[H]={source:e.source},delete e.source)})}}),this}}function P(e,t){if(e.byteLength<4+t)return null;const s=e.getUint32(t);return e.byteLength<s+t||s<8?null:{type:n.decodeText(new Uint8Array(e.buffer,e.byteOffset+t+4,4)),start:t+8,end:t+s}}V.EXTENSION_NAME=H;const X="EXT_texture_webp";class K{match(e){return e.length>=12&&87===e[8]&&69===e[9]&&66===e[10]&&80===e[11]}getSize(e){const t=n.decodeText(e.slice(0,4)),s=n.decodeText(e.slice(8,12));if("RIFF"!==t||"WEBP"!==s)return null;const r=new DataView(e.buffer,e.byteOffset);let o=12;for(;o<r.byteLength;){const e=n.decodeText(new Uint8Array([r.getUint8(o),r.getUint8(o+1),r.getUint8(o+2),r.getUint8(o+3)])),t=r.getUint32(o+4,!0);if("VP8 "===e)return[16383&r.getInt16(o+14,!0),16383&r.getInt16(o+16,!0)];if("VP8L"===e){const e=r.getUint8(o+9),t=r.getUint8(o+10),s=r.getUint8(o+11);return[1+((63&t)<<8|e),1+((15&r.getUint8(o+12))<<10|s<<2|(192&t)>>6)]}o+=8+t+t%2}return null}getChannels(e){return 4}}class z extends s{constructor(...e){super(...e),this.extensionName=X,this.prereadTypes=[t.TEXTURE]}static register(){f.registerFormat("image/webp",new K)}preread(e){return(e.jsonDoc.json.textures||[]).forEach(e=>{e.extensions&&e.extensions[X]&&(e.source=e.extensions[X].source)}),this}read(e){return this}write(e){const t=e.jsonDoc;return this.document.getRoot().listTextures().forEach(s=>{if("image/webp"===s.getMimeType()){const n=e.imageIndexMap.get(s);(t.json.textures||[]).forEach(e=>{e.source===n&&(e.extensions=e.extensions||{},e.extensions[X]={source:e.source},delete e.source)})}}),this}}z.EXTENSION_NAME=X;const $="KHR_draco_mesh_compression";let q,Y,Q,W;function J(e,t){const s=new q.DecoderBuffer;try{if(s.Init(t,t.length),e.GetEncodedGeometryType(s)!==q.TRIANGULAR_MESH)throw new Error(`[${$}] Unknown geometry type.`);const n=new q.Mesh;if(!e.DecodeBufferToMesh(s,n).ok()||0===n.ptr)throw new Error(`[${$}] Decoding failure.`);return n}finally{q.destroy(s)}}function Z(e,t){const s=3*t.num_faces();let n,r;if(t.num_points()<=65534){const o=s*Uint16Array.BYTES_PER_ELEMENT;n=q._malloc(o),e.GetTrianglesUInt16Array(t,o,n),r=new Uint16Array(q.HEAPU16.buffer,n,s).slice()}else{const o=s*Uint32Array.BYTES_PER_ELEMENT;n=q._malloc(o),e.GetTrianglesUInt32Array(t,o,n),r=new Uint32Array(q.HEAPU32.buffer,n,s).slice()}return q._free(n),r}function ee(e,t,s,n){const r=Q[n.componentType],o=Y[n.componentType],i=s.num_components(),a=t.num_points()*i,c=a*o.BYTES_PER_ELEMENT,u=q._malloc(c);e.GetAttributeDataArrayForAllPoints(t,s,r,c,u);const l=new o(q.HEAPF32.buffer,u,a).slice();return q._free(u),l}var te,se;!function(e){e[e.EDGEBREAKER=1]="EDGEBREAKER",e[e.SEQUENTIAL=0]="SEQUENTIAL"}(te||(te={})),function(e){e.POSITION="POSITION",e.NORMAL="NORMAL",e.COLOR="COLOR",e.TEX_COORD="TEX_COORD",e.GENERIC="GENERIC"}(se||(se={}));const ne={[se.POSITION]:14,[se.NORMAL]:10,[se.COLOR]:8,[se.TEX_COORD]:12,[se.GENERIC]:12},re={decodeSpeed:5,encodeSpeed:5,method:te.EDGEBREAKER,quantizationBits:ne,quantizationVolume:"mesh"};function oe(e,t=re){const s=_({},re,t);s.quantizationBits=_({},ne,t.quantizationBits);const n=new W.Encoder,r=new W.MeshBuilder,o=new W.Mesh,i={},a=new W.DracoInt8Array,c=e.listTargets().length>0;let u=!1;for(const t of e.listSemantics()){const a=e.getAttribute(t);if(a.getSparse()){u=!0;continue}const c=ie(t),l=ae(r,a.getComponentType(),o,W[c],a.getCount(),a.getElementSize(),a.getArray());if(-1===l)throw new Error(`Error compressing "${t}" attribute.`);if(i[t]=l,"mesh"===s.quantizationVolume||"POSITION"!==t)n.SetAttributeQuantization(W[c],s.quantizationBits[c]);else{if("object"!=typeof s.quantizationVolume)throw new Error("Invalid quantization volume state.");{const{quantizationVolume:e}=s,t=Math.max(e.max[0]-e.min[0],e.max[1]-e.min[1],e.max[2]-e.min[2]);n.SetAttributeExplicitQuantization(W[c],s.quantizationBits[c],a.getElementSize(),e.min,t)}}}const l=e.getIndices();if(!l)throw new ce("Primitive must have indices.");r.AddFacesToMesh(o,l.getCount()/3,l.getArray()),n.SetSpeedOptions(s.encodeSpeed,s.decodeSpeed),n.SetTrackEncodedProperties(!0),n.SetEncodingMethod(s.method===te.SEQUENTIAL||c||u?W.MESH_SEQUENTIAL_ENCODING:W.MESH_EDGEBREAKER_ENCODING);const h=n.EncodeMeshToDracoBuffer(o,a);if(h<=0)throw new ce("Error applying Draco compression.");const f=new Uint8Array(h);for(let e=0;e<h;++e)f[e]=a.GetValue(e);const g=e.getAttribute("POSITION").getCount(),p=n.GetNumberOfEncodedPoints(),x=3*n.GetNumberOfEncodedFaces();if((c||u)&&p!==g)throw new ce('Compression reduced vertex count unexpectedly, corrupting mesh data. Applying the "weld" function before compression may resolve the issue. See: https://github.com/google/draco/issues/929');return W.destroy(a),W.destroy(o),W.destroy(r),W.destroy(n),{numVertices:p,numIndices:x,data:f,attributeIDs:i}}function ie(e){return"POSITION"===e?se.POSITION:"NORMAL"===e?se.NORMAL:e.startsWith("COLOR_")?se.COLOR:e.startsWith("TEXCOORD_")?se.TEX_COORD:se.GENERIC}function ae(e,t,s,n,r,o,i){switch(t){case u.ComponentType.UNSIGNED_BYTE:return e.AddUInt8Attribute(s,n,r,o,i);case u.ComponentType.BYTE:return e.AddInt8Attribute(s,n,r,o,i);case u.ComponentType.UNSIGNED_SHORT:return e.AddUInt16Attribute(s,n,r,o,i);case u.ComponentType.SHORT:return e.AddInt16Attribute(s,n,r,o,i);case u.ComponentType.UNSIGNED_INT:return e.AddUInt32Attribute(s,n,r,o,i);case u.ComponentType.FLOAT:return e.AddFloatAttribute(s,n,r,o,i);default:throw new Error(`Unexpected component type, "${t}".`)}}class ce extends Error{}const ue="KHR_draco_mesh_compression";class le extends s{constructor(...e){super(...e),this.extensionName=ue,this.prereadTypes=[t.PRIMITIVE],this.prewriteTypes=[t.ACCESSOR],this.readDependencies=["draco3d.decoder"],this.writeDependencies=["draco3d.encoder"],this._decoderModule=null,this._encoderModule=null,this._encoderOptions={}}install(e,t){return"draco3d.decoder"===e&&(this._decoderModule=t,q=this._decoderModule,Y={[u.ComponentType.FLOAT]:Float32Array,[u.ComponentType.UNSIGNED_INT]:Uint32Array,[u.ComponentType.UNSIGNED_SHORT]:Uint16Array,[u.ComponentType.UNSIGNED_BYTE]:Uint8Array,[u.ComponentType.SHORT]:Int16Array,[u.ComponentType.BYTE]:Int8Array},Q={[u.ComponentType.FLOAT]:q.DT_FLOAT32,[u.ComponentType.UNSIGNED_INT]:q.DT_UINT32,[u.ComponentType.UNSIGNED_SHORT]:q.DT_UINT16,[u.ComponentType.UNSIGNED_BYTE]:q.DT_UINT8,[u.ComponentType.SHORT]:q.DT_INT16,[u.ComponentType.BYTE]:q.DT_INT8}),"draco3d.encoder"===e&&(this._encoderModule=t,W=this._encoderModule),this}setEncoderOptions(e){return this._encoderOptions=e,this}preread(e){if(!this._decoderModule)throw new Error(`[${ue}] Please install extension dependency, "draco3d.decoder".`);const t=this.document.getLogger(),s=e.jsonDoc,r=new Map;try{const o=s.json.meshes||[];for(const i of o)for(const o of i.primitives){if(!o.extensions||!o.extensions[ue])continue;const i=o.extensions[ue];let[a,c]=r.get(i.bufferView)||[];if(!c||!a){const e=s.json.bufferViews[i.bufferView],o=s.json.buffers[e.buffer],u=n.toView(o.uri?s.resources[o.uri]:s.resources[h],e.byteOffset||0,e.byteLength);a=new this._decoderModule.Decoder,c=J(a,u),r.set(i.bufferView,[a,c]),t.debug(`[${ue}] Decompressed ${u.byteLength} bytes.`)}for(const t in o.attributes){const s=e.jsonDoc.json.accessors[o.attributes[t]],n=a.GetAttributeByUniqueId(c,i.attributes[t]),r=ee(a,c,n,s);e.accessors[o.attributes[t]].setArray(r)}void 0!==o.indices&&e.accessors[o.indices].setArray(Z(a,c))}}finally{for(const[e,t]of Array.from(r.values()))this._decoderModule.destroy(e),this._decoderModule.destroy(t)}return this}read(e){return this}prewrite(e,s){if(!this._encoderModule)throw new Error(`[${ue}] Please install extension dependency, "draco3d.encoder".`);const n=this.document.getLogger();n.debug(`[${ue}] Compression options: ${JSON.stringify(this._encoderOptions)}`);const r=function(e){const s=e.getLogger(),n=new Set,r=new Set;for(const t of e.getRoot().listMeshes())for(const e of t.listPrimitives())e.getIndices()?e.getMode()!==o.Mode.TRIANGLES?(r.add(e),s.warn(`[${ue}] Skipping Draco compression on non-TRIANGLES primitive.`)):n.add(e):(r.add(e),s.warn(`[${ue}] Skipping Draco compression on non-indexed primitive.`));const i=e.getRoot().listAccessors(),a=new Map;for(let e=0;e<i.length;e++)a.set(i[e],e);const c=new Map,u=new Set,l=new Map;for(const t of Array.from(n)){let s=he(t,a);if(u.has(s))l.set(t,s);else{if(c.has(t.getIndices())){const s=t.getIndices(),n=s.clone();a.set(n,e.getRoot().listAccessors().length-1),t.swap(s,n)}for(const s of t.listAttributes())if(c.has(s)){const n=s.clone();a.set(n,e.getRoot().listAccessors().length-1),t.swap(s,n)}s=he(t,a),u.add(s),l.set(t,s),c.set(t.getIndices(),s);for(const e of t.listAttributes())c.set(e,s)}}for(const e of Array.from(c.keys())){const s=new Set(e.listParents().map(e=>e.propertyType));if(2!==s.size||!s.has(t.PRIMITIVE)||!s.has(t.ROOT))throw new Error(`[${ue}] Compressed accessors must only be used as indices or vertex attributes.`)}for(const e of Array.from(n)){const t=l.get(e),s=e.getIndices();if(c.get(s)!==t||e.listAttributes().some(e=>c.get(e)!==t))throw new Error(`[${ue}] Draco primitives must share all, or no, accessors.`)}for(const e of Array.from(r)){const t=e.getIndices();if(c.has(t)||e.listAttributes().some(e=>c.has(e)))throw new Error(`[${ue}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return l}(this.document),i=new Map;let a="mesh";"scene"===this._encoderOptions.quantizationVolume&&(1!==this.document.getRoot().listScenes().length?n.warn(`[${ue}]: quantizationVolume=scene requires exactly 1 scene.`):a=g(this.document.getRoot().listScenes().pop()));for(const t of Array.from(r.keys())){const s=r.get(t);if(!s)throw new Error("Unexpected primitive.");if(i.has(s)){i.set(s,i.get(s));continue}const o=t.getIndices(),c=e.jsonDoc.json.accessors;let u;try{u=oe(t,_({},this._encoderOptions,{quantizationVolume:a}))}catch(e){if(e instanceof ce){n.warn(`[${ue}]: ${e.message} Skipping primitive compression.`);continue}throw e}i.set(s,u);const l=e.createAccessorDef(o);l.count=u.numIndices,e.accessorIndexMap.set(o,c.length),c.push(l);for(const s of t.listSemantics()){const n=t.getAttribute(s);if(void 0===u.attributeIDs[s])continue;const r=e.createAccessorDef(n);r.count=u.numVertices,e.accessorIndexMap.set(n,c.length),c.push(r)}const h=t.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];e.otherBufferViews.has(h)||e.otherBufferViews.set(h,[]),e.otherBufferViews.get(h).push(u.data)}return n.debug(`[${ue}] Compressed ${r.size} primitives.`),e.extensionData[ue]={primitiveHashMap:r,primitiveEncodingMap:i},this}write(e){const t=e.extensionData[ue];for(const s of this.document.getRoot().listMeshes()){const n=e.jsonDoc.json.meshes[e.meshIndexMap.get(s)];for(let r=0;r<s.listPrimitives().length;r++){const o=s.listPrimitives()[r],i=n.primitives[r],a=t.primitiveHashMap.get(o);if(!a)continue;const c=t.primitiveEncodingMap.get(a);c&&(i.extensions=i.extensions||{},i.extensions[ue]={bufferView:e.otherBufferViewsIndexMap.get(c.data),attributes:c.attributeIDs})}}if(!t.primitiveHashMap.size){const t=e.jsonDoc.json;t.extensionsUsed=(t.extensionsUsed||[]).filter(e=>e!==ue),t.extensionsRequired=(t.extensionsRequired||[]).filter(e=>e!==ue)}return this}}function he(e,t){const s=[],n=e.getIndices();s.push(t.get(n));for(const n of e.listAttributes())s.push(t.get(n));return s.sort().join("|")}le.EXTENSION_NAME=ue,le.EncoderMethod=te;class fe extends e{init(){this.extensionName="KHR_lights_punctual",this.propertyType="Light",this.parentTypes=[t.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:fe.Type.POINT,range:null,innerConeAngle:0,outerConeAngle:Math.PI/4})}getColor(){return this.get("color")}setColor(e){return this.set("color",e)}getColorHex(){return p.factorToHex(this.getColor())}setColorHex(e){const t=this.getColor().slice();return p.hexToFactor(e,t),this.setColor(t)}getIntensity(){return this.get("intensity")}setIntensity(e){return this.set("intensity",e)}getType(){return this.get("type")}setType(e){return this.set("type",e)}getRange(){return this.get("range")}setRange(e){return this.set("range",e)}getInnerConeAngle(){return this.get("innerConeAngle")}setInnerConeAngle(e){return this.set("innerConeAngle",e)}getOuterConeAngle(){return this.get("outerConeAngle")}setOuterConeAngle(e){return this.set("outerConeAngle",e)}}fe.EXTENSION_NAME="KHR_lights_punctual",fe.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};const ge="KHR_lights_punctual";class pe extends s{constructor(...e){super(...e),this.extensionName=ge}createLight(e=""){return new fe(this.document.getGraph(),e)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions[ge])return this;const s=(t.json.extensions[ge].lights||[]).map(e=>{var t,s;const n=this.createLight().setName(e.name||"").setType(e.type);return void 0!==e.color&&n.setColor(e.color),void 0!==e.intensity&&n.setIntensity(e.intensity),void 0!==e.range&&n.setRange(e.range),void 0!==(null==(t=e.spot)?void 0:t.innerConeAngle)&&n.setInnerConeAngle(e.spot.innerConeAngle),void 0!==(null==(s=e.spot)?void 0:s.outerConeAngle)&&n.setOuterConeAngle(e.spot.outerConeAngle),n});return t.json.nodes.forEach((t,n)=>{t.extensions&&t.extensions[ge]&&e.nodes[n].setExtension(ge,s[t.extensions[ge].light])}),this}write(e){const t=e.jsonDoc;if(0===this.properties.size)return this;const s=[],n=new Map;for(const e of this.properties){const t=e,r={type:t.getType()};l.eq(t.getColor(),[1,1,1])||(r.color=t.getColor()),1!==t.getIntensity()&&(r.intensity=t.getIntensity()),null!=t.getRange()&&(r.range=t.getRange()),t.getName()&&(r.name=t.getName()),t.getType()===fe.Type.SPOT&&(r.spot={innerConeAngle:t.getInnerConeAngle(),outerConeAngle:t.getOuterConeAngle()}),s.push(r),n.set(t,s.length-1)}return this.document.getRoot().listNodes().forEach(s=>{const r=s.getExtension(ge);if(r){const o=e.nodeIndexMap.get(s),i=t.json.nodes[o];i.extensions=i.extensions||{},i.extensions[ge]={light:n.get(r)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[ge]={lights:s},this}}pe.EXTENSION_NAME=ge;const{R:xe,G:de}=d;class Te extends e{init(){this.extensionName="KHR_materials_anisotropy",this.propertyType="Anisotropy",this.parentTypes=[t.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new x(this.graph,"anisotropyTextureInfo")})}getAnisotropyStrength(){return this.get("anisotropyStrength")}setAnisotropyStrength(e){return this.set("anisotropyStrength",e)}getAnisotropyRotation(){return this.get("anisotropyRotation")}setAnisotropyRotation(e){return this.set("anisotropyRotation",e)}getAnisotropyTexture(){return this.getRef("anisotropyTexture")}getAnisotropyTextureInfo(){return this.getRef("anisotropyTexture")?this.getRef("anisotropyTextureInfo"):null}setAnisotropyTexture(e){return this.setRef("anisotropyTexture",e,{channels:xe|de})}}Te.EXTENSION_NAME="KHR_materials_anisotropy";const me="KHR_materials_anisotropy";class Ee extends s{constructor(...e){super(...e),this.extensionName=me}createAnisotropy(){return new Te(this.document.getGraph())}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions[me]){const r=this.createAnisotropy();e.materials[n].setExtension(me,r);const o=t.extensions[me];if(void 0!==o.anisotropyStrength&&r.setAnisotropyStrength(o.anisotropyStrength),void 0!==o.anisotropyRotation&&r.setAnisotropyRotation(o.anisotropyRotation),void 0!==o.anisotropyTexture){const t=o.anisotropyTexture;r.setAnisotropyTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getAnisotropyTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const n=s.getExtension(me);if(n){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{};const i=o.extensions[me]={};if(n.getAnisotropyStrength()>0&&(i.anisotropyStrength=n.getAnisotropyStrength()),0!==n.getAnisotropyRotation()&&(i.anisotropyRotation=n.getAnisotropyRotation()),n.getAnisotropyTexture()){const t=n.getAnisotropyTexture(),s=n.getAnisotropyTextureInfo();i.anisotropyTexture=e.createTextureInfoDef(t,s)}}}),this}}Ee.EXTENSION_NAME=me;const{R:Ie,G:Re,B:Ne}=d;class ye extends e{init(){this.extensionName="KHR_materials_clearcoat",this.propertyType="Clearcoat",this.parentTypes=[t.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new x(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new x(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new x(this.graph,"clearcoatNormalTextureInfo")})}getClearcoatFactor(){return this.get("clearcoatFactor")}setClearcoatFactor(e){return this.set("clearcoatFactor",e)}getClearcoatTexture(){return this.getRef("clearcoatTexture")}getClearcoatTextureInfo(){return this.getRef("clearcoatTexture")?this.getRef("clearcoatTextureInfo"):null}setClearcoatTexture(e){return this.setRef("clearcoatTexture",e,{channels:Ie})}getClearcoatRoughnessFactor(){return this.get("clearcoatRoughnessFactor")}setClearcoatRoughnessFactor(e){return this.set("clearcoatRoughnessFactor",e)}getClearcoatRoughnessTexture(){return this.getRef("clearcoatRoughnessTexture")}getClearcoatRoughnessTextureInfo(){return this.getRef("clearcoatRoughnessTexture")?this.getRef("clearcoatRoughnessTextureInfo"):null}setClearcoatRoughnessTexture(e){return this.setRef("clearcoatRoughnessTexture",e,{channels:Re})}getClearcoatNormalScale(){return this.get("clearcoatNormalScale")}setClearcoatNormalScale(e){return this.set("clearcoatNormalScale",e)}getClearcoatNormalTexture(){return this.getRef("clearcoatNormalTexture")}getClearcoatNormalTextureInfo(){return this.getRef("clearcoatNormalTexture")?this.getRef("clearcoatNormalTextureInfo"):null}setClearcoatNormalTexture(e){return this.setRef("clearcoatNormalTexture",e,{channels:Ie|Re|Ne})}}ye.EXTENSION_NAME="KHR_materials_clearcoat";const _e="KHR_materials_clearcoat";class Ae extends s{constructor(...e){super(...e),this.extensionName=_e}createClearcoat(){return new ye(this.document.getGraph())}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions[_e]){const r=this.createClearcoat();e.materials[n].setExtension(_e,r);const o=t.extensions[_e];if(void 0!==o.clearcoatFactor&&r.setClearcoatFactor(o.clearcoatFactor),void 0!==o.clearcoatRoughnessFactor&&r.setClearcoatRoughnessFactor(o.clearcoatRoughnessFactor),void 0!==o.clearcoatTexture){const t=o.clearcoatTexture;r.setClearcoatTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getClearcoatTextureInfo(),t)}if(void 0!==o.clearcoatRoughnessTexture){const t=o.clearcoatRoughnessTexture;r.setClearcoatRoughnessTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getClearcoatRoughnessTextureInfo(),t)}if(void 0!==o.clearcoatNormalTexture){const t=o.clearcoatNormalTexture;r.setClearcoatNormalTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getClearcoatNormalTextureInfo(),t),void 0!==t.scale&&r.setClearcoatNormalScale(t.scale)}}}),this}write(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const n=s.getExtension(_e);if(n){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{};const i=o.extensions[_e]={clearcoatFactor:n.getClearcoatFactor(),clearcoatRoughnessFactor:n.getClearcoatRoughnessFactor()};if(n.getClearcoatTexture()){const t=n.getClearcoatTexture(),s=n.getClearcoatTextureInfo();i.clearcoatTexture=e.createTextureInfoDef(t,s)}if(n.getClearcoatRoughnessTexture()){const t=n.getClearcoatRoughnessTexture(),s=n.getClearcoatRoughnessTextureInfo();i.clearcoatRoughnessTexture=e.createTextureInfoDef(t,s)}if(n.getClearcoatNormalTexture()){const t=n.getClearcoatNormalTexture(),s=n.getClearcoatNormalTextureInfo();i.clearcoatNormalTexture=e.createTextureInfoDef(t,s),1!==n.getClearcoatNormalScale()&&(i.clearcoatNormalTexture.scale=n.getClearcoatNormalScale())}}}),this}}Ae.EXTENSION_NAME=_e;class Se extends e{init(){this.extensionName="KHR_materials_emissive_strength",this.propertyType="EmissiveStrength",this.parentTypes=[t.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(e){return this.set("emissiveStrength",e)}}Se.EXTENSION_NAME="KHR_materials_emissive_strength";const Ce="KHR_materials_emissive_strength";class Me extends s{constructor(...e){super(...e),this.extensionName=Ce}createEmissiveStrength(){return new Se(this.document.getGraph())}read(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{if(t.extensions&&t.extensions[Ce]){const n=this.createEmissiveStrength();e.materials[s].setExtension(Ce,n);const r=t.extensions[Ce];void 0!==r.emissiveStrength&&n.setEmissiveStrength(r.emissiveStrength)}}),this}write(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const n=s.getExtension(Ce);if(n){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{},o.extensions[Ce]={emissiveStrength:n.getEmissiveStrength()}}}),this}}Me.EXTENSION_NAME=Ce;class Oe extends e{init(){this.extensionName="KHR_materials_ior",this.propertyType="IOR",this.parentTypes=[t.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(e){return this.set("ior",e)}}Oe.EXTENSION_NAME="KHR_materials_ior";const we="KHR_materials_ior";class De extends s{constructor(...e){super(...e),this.extensionName=we}createIOR(){return new Oe(this.document.getGraph())}read(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{if(t.extensions&&t.extensions[we]){const n=this.createIOR();e.materials[s].setExtension(we,n);const r=t.extensions[we];void 0!==r.ior&&n.setIOR(r.ior)}}),this}write(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const n=s.getExtension(we);if(n){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{},o.extensions[we]={ior:n.getIOR()}}}),this}}De.EXTENSION_NAME=we;const{R:be,G:Fe}=d;class je extends e{init(){this.extensionName="KHR_materials_iridescence",this.propertyType="Iridescence",this.parentTypes=[t.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new x(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new x(this.graph,"iridescenceThicknessTextureInfo")})}getIridescenceFactor(){return this.get("iridescenceFactor")}setIridescenceFactor(e){return this.set("iridescenceFactor",e)}getIridescenceTexture(){return this.getRef("iridescenceTexture")}getIridescenceTextureInfo(){return this.getRef("iridescenceTexture")?this.getRef("iridescenceTextureInfo"):null}setIridescenceTexture(e){return this.setRef("iridescenceTexture",e,{channels:be})}getIridescenceIOR(){return this.get("iridescenceIOR")}setIridescenceIOR(e){return this.set("iridescenceIOR",e)}getIridescenceThicknessMinimum(){return this.get("iridescenceThicknessMinimum")}setIridescenceThicknessMinimum(e){return this.set("iridescenceThicknessMinimum",e)}getIridescenceThicknessMaximum(){return this.get("iridescenceThicknessMaximum")}setIridescenceThicknessMaximum(e){return this.set("iridescenceThicknessMaximum",e)}getIridescenceThicknessTexture(){return this.getRef("iridescenceThicknessTexture")}getIridescenceThicknessTextureInfo(){return this.getRef("iridescenceThicknessTexture")?this.getRef("iridescenceThicknessTextureInfo"):null}setIridescenceThicknessTexture(e){return this.setRef("iridescenceThicknessTexture",e,{channels:Fe})}}je.EXTENSION_NAME="KHR_materials_iridescence";const ve="KHR_materials_iridescence";class ke extends s{constructor(...e){super(...e),this.extensionName=ve}createIridescence(){return new je(this.document.getGraph())}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions[ve]){const r=this.createIridescence();e.materials[n].setExtension(ve,r);const o=t.extensions[ve];if(void 0!==o.iridescenceFactor&&r.setIridescenceFactor(o.iridescenceFactor),void 0!==o.iridescenceIor&&r.setIridescenceIOR(o.iridescenceIor),void 0!==o.iridescenceThicknessMinimum&&r.setIridescenceThicknessMinimum(o.iridescenceThicknessMinimum),void 0!==o.iridescenceThicknessMaximum&&r.setIridescenceThicknessMaximum(o.iridescenceThicknessMaximum),void 0!==o.iridescenceTexture){const t=o.iridescenceTexture;r.setIridescenceTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getIridescenceTextureInfo(),t)}if(void 0!==o.iridescenceThicknessTexture){const t=o.iridescenceThicknessTexture;r.setIridescenceThicknessTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getIridescenceThicknessTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const n=s.getExtension(ve);if(n){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{};const i=o.extensions[ve]={};if(n.getIridescenceFactor()>0&&(i.iridescenceFactor=n.getIridescenceFactor()),1.3!==n.getIridescenceIOR()&&(i.iridescenceIor=n.getIridescenceIOR()),100!==n.getIridescenceThicknessMinimum()&&(i.iridescenceThicknessMinimum=n.getIridescenceThicknessMinimum()),400!==n.getIridescenceThicknessMaximum()&&(i.iridescenceThicknessMaximum=n.getIridescenceThicknessMaximum()),n.getIridescenceTexture()){const t=n.getIridescenceTexture(),s=n.getIridescenceTextureInfo();i.iridescenceTexture=e.createTextureInfoDef(t,s)}if(n.getIridescenceThicknessTexture()){const t=n.getIridescenceThicknessTexture(),s=n.getIridescenceThicknessTextureInfo();i.iridescenceThicknessTexture=e.createTextureInfoDef(t,s)}}}),this}}ke.EXTENSION_NAME=ve;const{R:Be,G:Ge,B:Le,A:He}=d;class Ue extends e{init(){this.extensionName="KHR_materials_pbrSpecularGlossiness",this.propertyType="PBRSpecularGlossiness",this.parentTypes=[t.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new x(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new x(this.graph,"specularGlossinessTextureInfo")})}getDiffuseFactor(){return this.get("diffuseFactor")}setDiffuseFactor(e){return this.set("diffuseFactor",e)}getDiffuseHex(){return p.factorToHex(this.getDiffuseFactor())}setDiffuseHex(e){const t=this.getDiffuseFactor().slice();return this.setDiffuseFactor(p.hexToFactor(e,t))}getDiffuseTexture(){return this.getRef("diffuseTexture")}getDiffuseTextureInfo(){return this.getRef("diffuseTexture")?this.getRef("diffuseTextureInfo"):null}setDiffuseTexture(e){return this.setRef("diffuseTexture",e,{channels:Be|Ge|Le|He})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(e){return this.set("specularFactor",e)}getGlossinessFactor(){return this.get("glossinessFactor")}setGlossinessFactor(e){return this.set("glossinessFactor",e)}getSpecularGlossinessTexture(){return this.getRef("specularGlossinessTexture")}getSpecularGlossinessTextureInfo(){return this.getRef("specularGlossinessTexture")?this.getRef("specularGlossinessTextureInfo"):null}setSpecularGlossinessTexture(e){return this.setRef("specularGlossinessTexture",e,{channels:Be|Ge|Le|He})}}Ue.EXTENSION_NAME="KHR_materials_pbrSpecularGlossiness";const Ve="KHR_materials_pbrSpecularGlossiness";class Pe extends s{constructor(...e){super(...e),this.extensionName=Ve}createPBRSpecularGlossiness(){return new Ue(this.document.getGraph())}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions[Ve]){const r=this.createPBRSpecularGlossiness();e.materials[n].setExtension(Ve,r);const o=t.extensions[Ve];if(void 0!==o.diffuseFactor&&r.setDiffuseFactor(o.diffuseFactor),void 0!==o.specularFactor&&r.setSpecularFactor(o.specularFactor),void 0!==o.glossinessFactor&&r.setGlossinessFactor(o.glossinessFactor),void 0!==o.diffuseTexture){const t=o.diffuseTexture;r.setDiffuseTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getDiffuseTextureInfo(),t)}if(void 0!==o.specularGlossinessTexture){const t=o.specularGlossinessTexture;r.setSpecularGlossinessTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getSpecularGlossinessTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const n=s.getExtension(Ve);if(n){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{};const i=o.extensions[Ve]={diffuseFactor:n.getDiffuseFactor(),specularFactor:n.getSpecularFactor(),glossinessFactor:n.getGlossinessFactor()};if(n.getDiffuseTexture()){const t=n.getDiffuseTexture(),s=n.getDiffuseTextureInfo();i.diffuseTexture=e.createTextureInfoDef(t,s)}if(n.getSpecularGlossinessTexture()){const t=n.getSpecularGlossinessTexture(),s=n.getSpecularGlossinessTextureInfo();i.specularGlossinessTexture=e.createTextureInfoDef(t,s)}}}),this}}Pe.EXTENSION_NAME=Ve;const{R:Xe,G:Ke,B:ze,A:$e}=d;class qe extends e{init(){this.extensionName="KHR_materials_sheen",this.propertyType="Sheen",this.parentTypes=[t.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new x(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new x(this.graph,"sheenRoughnessTextureInfo")})}getSheenColorFactor(){return this.get("sheenColorFactor")}getSheenColorHex(){return p.factorToHex(this.getSheenColorFactor())}setSheenColorFactor(e){return this.set("sheenColorFactor",e)}setSheenColorHex(e){const t=this.getSheenColorFactor().slice();return this.set("sheenColorFactor",p.hexToFactor(e,t))}getSheenColorTexture(){return this.getRef("sheenColorTexture")}getSheenColorTextureInfo(){return this.getRef("sheenColorTexture")?this.getRef("sheenColorTextureInfo"):null}setSheenColorTexture(e){return this.setRef("sheenColorTexture",e,{channels:Xe|Ke|ze})}getSheenRoughnessFactor(){return this.get("sheenRoughnessFactor")}setSheenRoughnessFactor(e){return this.set("sheenRoughnessFactor",e)}getSheenRoughnessTexture(){return this.getRef("sheenRoughnessTexture")}getSheenRoughnessTextureInfo(){return this.getRef("sheenRoughnessTexture")?this.getRef("sheenRoughnessTextureInfo"):null}setSheenRoughnessTexture(e){return this.setRef("sheenRoughnessTexture",e,{channels:$e})}}qe.EXTENSION_NAME="KHR_materials_sheen";const Ye="KHR_materials_sheen";class Qe extends s{constructor(...e){super(...e),this.extensionName=Ye}createSheen(){return new qe(this.document.getGraph())}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions[Ye]){const r=this.createSheen();e.materials[n].setExtension(Ye,r);const o=t.extensions[Ye];if(void 0!==o.sheenColorFactor&&r.setSheenColorFactor(o.sheenColorFactor),void 0!==o.sheenRoughnessFactor&&r.setSheenRoughnessFactor(o.sheenRoughnessFactor),void 0!==o.sheenColorTexture){const t=o.sheenColorTexture;r.setSheenColorTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getSheenColorTextureInfo(),t)}if(void 0!==o.sheenRoughnessTexture){const t=o.sheenRoughnessTexture;r.setSheenRoughnessTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getSheenRoughnessTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const n=s.getExtension(Ye);if(n){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{};const i=o.extensions[Ye]={sheenColorFactor:n.getSheenColorFactor(),sheenRoughnessFactor:n.getSheenRoughnessFactor()};if(n.getSheenColorTexture()){const t=n.getSheenColorTexture(),s=n.getSheenColorTextureInfo();i.sheenColorTexture=e.createTextureInfoDef(t,s)}if(n.getSheenRoughnessTexture()){const t=n.getSheenRoughnessTexture(),s=n.getSheenRoughnessTextureInfo();i.sheenRoughnessTexture=e.createTextureInfoDef(t,s)}}}),this}}Qe.EXTENSION_NAME=Ye;const{R:We,G:Je,B:Ze,A:et}=d;class tt extends e{init(){this.extensionName="KHR_materials_specular",this.propertyType="Specular",this.parentTypes=[t.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new x(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new x(this.graph,"specularColorTextureInfo")})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(e){return this.set("specularFactor",e)}getSpecularColorFactor(){return this.get("specularColorFactor")}setSpecularColorFactor(e){return this.set("specularColorFactor",e)}getSpecularColorHex(){return p.factorToHex(this.getSpecularColorFactor())}setSpecularColorHex(e){const t=this.getSpecularColorFactor().slice();return this.set("specularColorFactor",p.hexToFactor(e,t))}getSpecularTexture(){return this.getRef("specularTexture")}getSpecularTextureInfo(){return this.getRef("specularTexture")?this.getRef("specularTextureInfo"):null}setSpecularTexture(e){return this.setRef("specularTexture",e,{channels:et})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(e){return this.setRef("specularColorTexture",e,{channels:We|Je|Ze})}}tt.EXTENSION_NAME="KHR_materials_specular";const st="KHR_materials_specular";class nt extends s{constructor(...e){super(...e),this.extensionName=st}createSpecular(){return new tt(this.document.getGraph())}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions[st]){const r=this.createSpecular();e.materials[n].setExtension(st,r);const o=t.extensions[st];if(void 0!==o.specularFactor&&r.setSpecularFactor(o.specularFactor),void 0!==o.specularColorFactor&&r.setSpecularColorFactor(o.specularColorFactor),void 0!==o.specularTexture){const t=o.specularTexture;r.setSpecularTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getSpecularTextureInfo(),t)}if(void 0!==o.specularColorTexture){const t=o.specularColorTexture;r.setSpecularColorTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getSpecularColorTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const n=s.getExtension(st);if(n){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{};const i=o.extensions[st]={};if(1!==n.getSpecularFactor()&&(i.specularFactor=n.getSpecularFactor()),l.eq(n.getSpecularColorFactor(),[1,1,1])||(i.specularColorFactor=n.getSpecularColorFactor()),n.getSpecularTexture()){const t=n.getSpecularTexture(),s=n.getSpecularTextureInfo();i.specularTexture=e.createTextureInfoDef(t,s)}if(n.getSpecularColorTexture()){const t=n.getSpecularColorTexture(),s=n.getSpecularColorTextureInfo();i.specularColorTexture=e.createTextureInfoDef(t,s)}}}),this}}nt.EXTENSION_NAME=st;const{R:rt}=d;class ot extends e{init(){this.extensionName="KHR_materials_transmission",this.propertyType="Transmission",this.parentTypes=[t.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new x(this.graph,"transmissionTextureInfo")})}getTransmissionFactor(){return this.get("transmissionFactor")}setTransmissionFactor(e){return this.set("transmissionFactor",e)}getTransmissionTexture(){return this.getRef("transmissionTexture")}getTransmissionTextureInfo(){return this.getRef("transmissionTexture")?this.getRef("transmissionTextureInfo"):null}setTransmissionTexture(e){return this.setRef("transmissionTexture",e,{channels:rt})}}ot.EXTENSION_NAME="KHR_materials_transmission";const it="KHR_materials_transmission";class at extends s{constructor(...e){super(...e),this.extensionName=it}createTransmission(){return new ot(this.document.getGraph())}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions[it]){const r=this.createTransmission();e.materials[n].setExtension(it,r);const o=t.extensions[it];if(void 0!==o.transmissionFactor&&r.setTransmissionFactor(o.transmissionFactor),void 0!==o.transmissionTexture){const t=o.transmissionTexture;r.setTransmissionTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getTransmissionTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const n=s.getExtension(it);if(n){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{};const i=o.extensions[it]={transmissionFactor:n.getTransmissionFactor()};if(n.getTransmissionTexture()){const t=n.getTransmissionTexture(),s=n.getTransmissionTextureInfo();i.transmissionTexture=e.createTextureInfoDef(t,s)}}}),this}}at.EXTENSION_NAME=it;class ct extends e{init(){this.extensionName="KHR_materials_unlit",this.propertyType="Unlit",this.parentTypes=[t.MATERIAL]}}ct.EXTENSION_NAME="KHR_materials_unlit";const ut="KHR_materials_unlit";class lt extends s{constructor(...e){super(...e),this.extensionName=ut}createUnlit(){return new ct(this.document.getGraph())}read(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{t.extensions&&t.extensions[ut]&&e.materials[s].setExtension(ut,this.createUnlit())}),this}write(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{if(s.getExtension(ut)){const n=e.materialIndexMap.get(s),r=t.json.materials[n];r.extensions=r.extensions||{},r.extensions[ut]={}}}),this}}lt.EXTENSION_NAME=ut;class ht extends e{init(){this.extensionName="KHR_materials_variants",this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:[]})}getMaterial(){return this.getRef("material")}setMaterial(e){return this.setRef("material",e)}addVariant(e){return this.addRef("variants",e)}removeVariant(e){return this.removeRef("variants",e)}listVariants(){return this.listRefs("variants")}}ht.EXTENSION_NAME="KHR_materials_variants";class ft extends e{init(){this.extensionName="KHR_materials_variants",this.propertyType="MappingList",this.parentTypes=[t.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:[]})}addMapping(e){return this.addRef("mappings",e)}removeMapping(e){return this.removeRef("mappings",e)}listMappings(){return this.listRefs("mappings")}}ft.EXTENSION_NAME="KHR_materials_variants";class gt extends e{init(){this.extensionName="KHR_materials_variants",this.propertyType="Variant",this.parentTypes=["MappingList"]}}gt.EXTENSION_NAME="KHR_materials_variants";const pt="KHR_materials_variants";class xt extends s{constructor(...e){super(...e),this.extensionName=pt}createMappingList(){return new ft(this.document.getGraph())}createVariant(e=""){return new gt(this.document.getGraph(),e)}createMapping(){return new ht(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter(e=>e instanceof gt)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions[pt])return this;const s=(t.json.extensions[pt].variants||[]).map(e=>this.createVariant().setName(e.name||""));return(t.json.meshes||[]).forEach((t,n)=>{const r=e.meshes[n];(t.primitives||[]).forEach((t,n)=>{if(!t.extensions||!t.extensions[pt])return;const o=this.createMappingList(),i=t.extensions[pt];for(const t of i.mappings){const n=this.createMapping();void 0!==t.material&&n.setMaterial(e.materials[t.material]);for(const e of t.variants||[])n.addVariant(s[e]);o.addMapping(n)}r.listPrimitives()[n].setExtension(pt,o)})}),this}write(e){const t=e.jsonDoc,s=this.listVariants();if(!s.length)return this;const n=[],r=new Map;for(const t of s)r.set(t,n.length),n.push(e.createPropertyDef(t));for(const t of this.document.getRoot().listMeshes()){const s=e.meshIndexMap.get(t);t.listPrimitives().forEach((t,n)=>{const o=t.getExtension(pt);if(!o)return;const i=e.jsonDoc.json.meshes[s].primitives[n],a=o.listMappings().map(t=>{const s=e.createPropertyDef(t),n=t.getMaterial();return n&&(s.material=e.materialIndexMap.get(n)),s.variants=t.listVariants().map(e=>r.get(e)),s});i.extensions=i.extensions||{},i.extensions[pt]={mappings:a}})}return t.json.extensions=t.json.extensions||{},t.json.extensions[pt]={variants:n},this}}xt.EXTENSION_NAME=pt;const{G:dt}=d;class Tt extends e{init(){this.extensionName="KHR_materials_volume",this.propertyType="Volume",this.parentTypes=[t.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new x(this.graph,"thicknessTexture"),attenuationDistance:Infinity,attenuationColor:[1,1,1]})}getThicknessFactor(){return this.get("thicknessFactor")}setThicknessFactor(e){return this.set("thicknessFactor",e)}getThicknessTexture(){return this.getRef("thicknessTexture")}getThicknessTextureInfo(){return this.getRef("thicknessTexture")?this.getRef("thicknessTextureInfo"):null}setThicknessTexture(e){return this.setRef("thicknessTexture",e,{channels:dt})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(e){return this.set("attenuationDistance",e)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(e){return this.set("attenuationColor",e)}getAttenuationColorHex(){return p.factorToHex(this.getAttenuationColor())}setAttenuationColorHex(e){const t=this.getAttenuationColor().slice();return this.set("attenuationColor",p.hexToFactor(e,t))}}Tt.EXTENSION_NAME="KHR_materials_volume";const mt="KHR_materials_volume";class Et extends s{constructor(...e){super(...e),this.extensionName=mt}createVolume(){return new Tt(this.document.getGraph())}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,n)=>{if(t.extensions&&t.extensions[mt]){const r=this.createVolume();e.materials[n].setExtension(mt,r);const o=t.extensions[mt];if(void 0!==o.thicknessFactor&&r.setThicknessFactor(o.thicknessFactor),void 0!==o.attenuationDistance&&r.setAttenuationDistance(o.attenuationDistance),void 0!==o.attenuationColor&&r.setAttenuationColor(o.attenuationColor),void 0!==o.thicknessTexture){const t=o.thicknessTexture;r.setThicknessTexture(e.textures[s[t.index].source]),e.setTextureInfo(r.getThicknessTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const n=s.getExtension(mt);if(n){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{};const i=o.extensions[mt]={};if(n.getThicknessFactor()>0&&(i.thicknessFactor=n.getThicknessFactor()),Number.isFinite(n.getAttenuationDistance())&&(i.attenuationDistance=n.getAttenuationDistance()),l.eq(n.getAttenuationColor(),[1,1,1])||(i.attenuationColor=n.getAttenuationColor()),n.getThicknessTexture()){const t=n.getThicknessTexture(),s=n.getThicknessTextureInfo();i.thicknessTexture=e.createTextureInfoDef(t,s)}}}),this}}Et.EXTENSION_NAME=mt;const It="KHR_mesh_quantization";class Rt extends s{constructor(...e){super(...e),this.extensionName=It}read(e){return this}write(e){return this}}Rt.EXTENSION_NAME=It;const Nt="KHR_texture_basisu";class yt{match(e){return 171===e[0]&&75===e[1]&&84===e[2]&&88===e[3]&&32===e[4]&&50===e[5]&&48===e[6]&&187===e[7]&&13===e[8]&&10===e[9]&&26===e[10]&&10===e[11]}getSize(e){const t=T(e);return[t.pixelWidth,t.pixelHeight]}getChannels(e){const t=T(e).dataFormatDescriptor[0];if(t.colorModel===m)return 2===t.samples.length&&15==(15&t.samples[1].channelType)?4:3;if(t.colorModel===E)return 3==(15&t.samples[0].channelType)?4:3;throw new Error(`Unexpected KTX2 colorModel, "${t.colorModel}".`)}getVRAMByteLength(e){const t=T(e),s=this.getChannels(e)>3;let n=0;for(let e=0;e<t.levels.length;e++){const r=t.levels[e];n+=r.uncompressedByteLength?r.uncompressedByteLength:Math.max(1,Math.floor(t.pixelWidth/Math.pow(2,e)))/4*(Math.max(1,Math.floor(t.pixelHeight/Math.pow(2,e)))/4)*(s?16:8)}return n}}class _t extends s{constructor(...e){super(...e),this.extensionName=Nt,this.prereadTypes=[t.TEXTURE]}static register(){f.registerFormat("image/ktx2",new yt)}preread(e){return e.jsonDoc.json.textures.forEach(e=>{e.extensions&&e.extensions[Nt]&&(e.source=e.extensions[Nt].source)}),this}read(e){return this}write(e){const t=e.jsonDoc;return this.document.getRoot().listTextures().forEach(s=>{if("image/ktx2"===s.getMimeType()){const n=e.imageIndexMap.get(s);t.json.textures.forEach(e=>{e.source===n&&(e.extensions=e.extensions||{},e.extensions[Nt]={source:e.source},delete e.source)})}}),this}}_t.EXTENSION_NAME=Nt;class At extends e{init(){this.extensionName="KHR_texture_transform",this.propertyType="Transform",this.parentTypes=[t.TEXTURE_INFO]}getDefaults(){return Object.assign(super.getDefaults(),{offset:[0,0],rotation:0,scale:[1,1],texCoord:null})}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getRotation(){return this.get("rotation")}setRotation(e){return this.set("rotation",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getTexCoord(){return this.get("texCoord")}setTexCoord(e){return this.set("texCoord",e)}}At.EXTENSION_NAME="KHR_texture_transform";const St="KHR_texture_transform";class Ct extends s{constructor(...e){super(...e),this.extensionName=St}createTransform(){return new At(this.document.getGraph())}read(e){for(const[t,s]of Array.from(e.textureInfos.entries())){if(!s.extensions||!s.extensions[St])continue;const e=this.createTransform(),n=s.extensions[St];void 0!==n.offset&&e.setOffset(n.offset),void 0!==n.rotation&&e.setRotation(n.rotation),void 0!==n.scale&&e.setScale(n.scale),void 0!==n.texCoord&&e.setTexCoord(n.texCoord),t.setExtension(St,e)}return this}write(e){const t=Array.from(e.textureInfoDefMap.entries());for(const[e,s]of t){const t=e.getExtension(St);if(!t)continue;s.extensions=s.extensions||{};const n={},r=l.eq;r(t.getOffset(),[0,0])||(n.offset=t.getOffset()),0!==t.getRotation()&&(n.rotation=t.getRotation()),r(t.getScale(),[1,1])||(n.scale=t.getScale()),null!=t.getTexCoord()&&(n.texCoord=t.getTexCoord()),s.extensions[St]=n}return this}}Ct.EXTENSION_NAME=St;const Mt=[t.ROOT,t.SCENE,t.NODE,t.MESH,t.MATERIAL,t.TEXTURE,t.ANIMATION];class Ot extends e{init(){this.extensionName="KHR_xmp_json_ld",this.propertyType="Packet",this.parentTypes=Mt}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(e){return this.set("context",_({},e))}listProperties(){return Object.keys(this.get("properties"))}getProperty(e){const t=this.get("properties");return e in t?t[e]:null}setProperty(e,t){this._assertContext(e);const s=_({},this.get("properties"));return t?s[e]=t:delete s[e],this.set("properties",s)}toJSONLD(){return _({"@context":wt(this.get("context"))},wt(this.get("properties")))}fromJSONLD(e){const t=(e=wt(e))["@context"];return t&&this.set("context",t),delete e["@context"],this.set("properties",e)}_assertContext(e){if(!(e.split(":")[0]in this.get("context")))throw new Error(`KHR_xmp_json_ld: Missing context for term, "${e}".`)}}function wt(e){return JSON.parse(JSON.stringify(e))}Ot.EXTENSION_NAME="KHR_xmp_json_ld";const Dt="KHR_xmp_json_ld";class bt extends s{constructor(...e){super(...e),this.extensionName=Dt}createPacket(){return new Ot(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(e){var t;const s=null==(t=e.jsonDoc.json.extensions)?void 0:t[Dt];if(!s||!s.packets)return this;const n=e.jsonDoc.json,r=this.document.getRoot(),o=s.packets.map(e=>this.createPacket().fromJSONLD(e)),i=[[n.asset],n.scenes,n.nodes,n.meshes,n.materials,n.images,n.animations],a=[[r],r.listScenes(),r.listNodes(),r.listMeshes(),r.listMaterials(),r.listTextures(),r.listAnimations()];for(let e=0;e<i.length;e++){const t=i[e]||[];for(let s=0;s<t.length;s++){const n=t[s];n.extensions&&n.extensions[Dt]&&a[e][s].setExtension(Dt,o[n.extensions[Dt].packet])}}return this}write(e){const{json:s}=e.jsonDoc,n=[];for(const r of this.properties){n.push(r.toJSONLD());for(const o of r.listParents()){let r;switch(o.propertyType){case t.ROOT:r=s.asset;break;case t.SCENE:r=s.scenes[e.sceneIndexMap.get(o)];break;case t.NODE:r=s.nodes[e.nodeIndexMap.get(o)];break;case t.MESH:r=s.meshes[e.meshIndexMap.get(o)];break;case t.MATERIAL:r=s.materials[e.materialIndexMap.get(o)];break;case t.TEXTURE:r=s.images[e.imageIndexMap.get(o)];break;case t.ANIMATION:r=s.animations[e.animationIndexMap.get(o)];break;default:r=null,this.document.getLogger().warn(`[${Dt}]: Unsupported parent property, "${o.propertyType}"`)}r&&(r.extensions=r.extensions||{},r.extensions[Dt]={packet:n.length-1})}}return n.length>0&&(s.extensions=s.extensions||{},s.extensions[Dt]={packets:n}),this}}bt.EXTENSION_NAME=Dt;const Ft=[le,pe,Ee,Ae,Me,De,ke,Pe,nt,Qe,at,lt,xt,Et,Rt,_t,Ct,bt],jt=[y,L,V,z,...Ft];export{jt as ALL_EXTENSIONS,Te as Anisotropy,ye as Clearcoat,y as EXTMeshGPUInstancing,L as EXTMeshoptCompression,V as EXTTextureAVIF,z as EXTTextureWebP,Se as EmissiveStrength,I as INSTANCE_ATTRIBUTE,Oe as IOR,R as InstancedMesh,je as Iridescence,le as KHRDracoMeshCompression,pe as KHRLightsPunctual,Ee as KHRMaterialsAnisotropy,Ae as KHRMaterialsClearcoat,Me as KHRMaterialsEmissiveStrength,De as KHRMaterialsIOR,ke as KHRMaterialsIridescence,Pe as KHRMaterialsPBRSpecularGlossiness,Qe as KHRMaterialsSheen,nt as KHRMaterialsSpecular,at as KHRMaterialsTransmission,lt as KHRMaterialsUnlit,xt as KHRMaterialsVariants,Et as KHRMaterialsVolume,Rt as KHRMeshQuantization,Ft as KHRONOS_EXTENSIONS,_t as KHRTextureBasisu,Ct as KHRTextureTransform,bt as KHRXMP,fe as Light,ht as Mapping,ft as MappingList,Ue as PBRSpecularGlossiness,Ot as Packet,qe as Sheen,tt as Specular,At as Transform,ot as Transmission,ct as Unlit,gt as Variant,Tt as Volume};
//# sourceMappingURL=extensions.modern.js.map
{
"name": "@gltf-transform/extensions",
"version": "3.1.2",
"version": "3.1.3",
"repository": "github:donmccurdy/glTF-Transform",

@@ -38,3 +38,3 @@ "homepage": "https://gltf-transform.donmccurdy.com/extensions.html",

"dependencies": {
"@gltf-transform/core": "^3.1.2",
"@gltf-transform/core": "^3.1.3",
"ktx-parse": "^0.5.0"

@@ -48,3 +48,3 @@ },

],
"gitHead": "7a7621cad44f8890233f7867841f8e039b49cd28"
"gitHead": "50786ecf3fd234f48cb61802343fd8c373d854c7"
}

@@ -7,2 +7,3 @@ export const EXT_MESH_GPU_INSTANCING = 'EXT_mesh_gpu_instancing';

export const KHR_LIGHTS_PUNCTUAL = 'KHR_lights_punctual';
export const KHR_MATERIALS_ANISOTROPY = 'KHR_materials_anisotropy';
export const KHR_MATERIALS_CLEARCOAT = 'KHR_materials_clearcoat';

@@ -9,0 +10,0 @@ export const KHR_MATERIALS_EMISSIVE_STRENGTH = 'KHR_materials_emissive_strength';

@@ -9,2 +9,3 @@ /** @module extensions */

import { KHRLightsPunctual } from './khr-lights-punctual/index.js';
import { KHRMaterialsAnisotropy } from './khr-materials-anisotropy/index.js';
import { KHRMaterialsClearcoat } from './khr-materials-clearcoat/index.js';

@@ -29,2 +30,3 @@ import { KHRMaterialsEmissiveStrength } from './khr-materials-emissive-strength/index.js';

KHRLightsPunctual,
KHRMaterialsAnisotropy,
KHRMaterialsClearcoat,

@@ -61,2 +63,3 @@ KHRMaterialsEmissiveStrength,

export * from './khr-lights-punctual/index.js';
export * from './khr-materials-anisotropy/index.js';
export * from './khr-materials-clearcoat/index.js';

@@ -63,0 +66,0 @@ export * from './khr-materials-emissive-strength/index.js';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc