Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gltf-transform/extensions

Package Overview
Dependencies
Maintainers
1
Versions
191
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 0.8.1 to 0.8.4

2

dist/extensions.js

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

var e=require("@gltf-transform/core");function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function n(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function s(e){var t=0;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,t){if(e){if("string"==typeof e)return o(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,void 0):void 0}}(e)))return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}var i,a,u,c,l,h,p,f,x="EXT_texture_webp",g=function(t){function n(){var r;return(r=t.apply(this,arguments)||this).extensionName=x,r.prereadTypes=[e.PropertyType.TEXTURE],r}r(n,t);var o=n.prototype;return o.preread=function(e){return e.jsonDoc.json.textures.forEach(function(e){e.extensions&&e.extensions[x]&&(e.source=e.extensions[x].source)}),this},o.read=function(e){return this},o.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listTextures().forEach(function(r){if("image/webp"===r.getMimeType()){var n=e.imageIndexMap.get(r);t.json.textures.forEach(function(e){e.source===n&&(e.extensions=e.extensions||{},e.extensions[x]={source:e.source},delete e.source)})}}),this},n}(e.Extension);function T(e,t){var r;try{if((r=new i.DecoderBuffer).Init(new Int8Array(t),t.byteLength),e.GetEncodedGeometryType(r)!==i.TRIANGULAR_MESH)throw new Error("Unknown geometry type.");var n=new i.Mesh;if(!e.DecodeBufferToMesh(r,n).ok()||0===n.ptr)throw new Error("Decoding failure.");return n}finally{i.destroy(r)}}function d(e,t){var r=3*t.num_faces(),n=r*Uint32Array.BYTES_PER_ELEMENT,o=i._malloc(n);e.GetTrianglesUInt32Array(t,n,o);var s=new Uint32Array(i.HEAP32.buffer,o,r).slice();return i._free(o),s}function v(e,t,r,n){var o=u[n.componentType],s=a[n.componentType],c=r.num_components(),l=t.num_points()*c,h=l*s.BYTES_PER_ELEMENT,p=i._malloc(h);e.GetAttributeDataArrayForAllPoints(t,r,o,h,p);var f=new s(i.HEAPF32.buffer,p,l).slice();return i._free(p),f}g.EXTENSION_NAME=x,function(e){e[e.EDGEBREAKER=1]="EDGEBREAKER",e[e.SEQUENTIAL=0]="SEQUENTIAL"}(p||(p={})),function(e){e.POSITION="POSITION",e.NORMAL="NORMAL",e.COLOR="COLOR",e.TEX_COORD="TEX_COORD",e.GENERIC="GENERIC"}(f||(f={}));var m=((c={})[f.POSITION]=14,c[f.NORMAL]=10,c[f.COLOR]=8,c[f.TEX_COORD]=12,c[f.GENERIC]=12,c),y={decodeSpeed:5,encodeSpeed:5,method:p.EDGEBREAKER,quantizationBits:m};function _(e,r){void 0===r&&(r=y);var n=t(t({},y),r);n.quantizationBits=t(t({},m),r.quantizationBits);for(var o,i=new h.Encoder,a=new h.MeshBuilder,u=new h.Mesh,c={},l=new h.DracoInt8Array,f=s(e.listSemantics());!(o=f()).done;){var x=o.value,g=e.getAttribute(x),T=I(x),d=a[E[g.getComponentType()]](u,h[T],g.getCount(),g.getElementSize(),g.getArray());if(-1===d)throw new Error('Error compressing "'+x+'" attribute.');c[x]=d,i.SetAttributeQuantization(h[T],n.quantizationBits[T])}a.AddFacesToMesh(u,e.getIndices().getCount()/3,e.getIndices().getArray()),i.SetSpeedOptions(n.encodeSpeed,n.decodeSpeed),i.SetTrackEncodedProperties(!0),e.listTargets().length>0||n.method===p.SEQUENTIAL?i.SetEncodingMethod(h.MESH_SEQUENTIAL_ENCODING):i.SetEncodingMethod(h.MESH_EDGEBREAKER_ENCODING);var v=i.EncodeMeshToDracoBuffer(u,l);if(v<=0)throw new Error("Error applying Draco compression.");for(var _=new Uint8Array(v),C=0;C<v;++C)_[C]=l.GetValue(C);var N=i.GetNumberOfEncodedPoints(),R=3*i.GetNumberOfEncodedFaces();return h.destroy(l),h.destroy(u),h.destroy(a),h.destroy(i),{numVertices:N,numIndices:R,data:_,attributeIDs:c}}function I(e){return"POSITION"===e?f.POSITION:"NORMAL"===e?f.NORMAL:e.startsWith("COLOR_")?f.COLOR:e.startsWith("TEXCOORD_")?f.TEX_COORD:f.GENERIC}var C,E=((l={})[e.Accessor.ComponentType.UNSIGNED_BYTE]="AddUInt8Attribute",l[e.Accessor.ComponentType.BYTE]="AddInt8Attribute",l[e.Accessor.ComponentType.UNSIGNED_SHORT]="AddUInt16Attribute",l[e.Accessor.ComponentType.SHORT]="AddInt16Attribute",l[e.Accessor.ComponentType.UNSIGNED_INT]="AddUInt32Attribute",l[e.Accessor.ComponentType.FLOAT]="AddFloatAttribute",l),N="KHR_draco_mesh_compression",R=function(t){function n(){var r;return(r=t.apply(this,arguments)||this).extensionName=N,r.prereadTypes=[e.PropertyType.PRIMITIVE],r.prewriteTypes=[e.PropertyType.ACCESSOR],r.dependencies=["draco3d.decoder","draco3d.encoder"],r._encoderOptions={},r}r(n,t);var o=n.prototype;return o.install=function(e,t){var r,n;return"draco3d.decoder"===e&&(this._decoderModule=t,i=this._decoderModule,(r={})[5126]=Float32Array,r[5125]=Uint32Array,r[5123]=Uint16Array,r[5121]=Uint8Array,r[5122]=Int16Array,r[5120]=Int8Array,a=r,(n={})[5126]=i.DT_FLOAT32,n[5125]=i.DT_UINT32,n[5123]=i.DT_UINT16,n[5121]=i.DT_UINT8,n[5122]=i.DT_INT16,n[5120]=i.DT_INT8,u=n),"draco3d.encoder"===e&&(this._encoderModule=t,h=this._encoderModule),this},o.setEncoderOptions=function(e){return this._encoderOptions=e,this},o.preread=function(t){if(!this._decoderModule)throw new Error('Please install extension dependency, "draco3d.decoder".');for(var r,n=this.doc.getLogger(),o=t.jsonDoc,i=new this._decoderModule.Decoder,a=new Map,u=s(o.json.meshes);!(r=u()).done;){for(var c,l=s(r.value.primitives);!(c=l()).done;){var h=c.value;if(h.extensions&&h.extensions[N]){var p=h.extensions[N],f=a.get(p.bufferView);if(!f){var x=o.json.bufferViews[p.bufferView],g=o.json.buffers[x.buffer],m=new Uint8Array(g.uri?o.resources[g.uri]:o.resources[e.GLB_BUFFER],x.byteOffset||0,x.byteLength);f=T(i,m),a.set(p.bufferView,f),n.debug("Decompressed "+m.byteLength+" bytes.")}for(var y in h.attributes){var _=t.jsonDoc.json.accessors[h.attributes[y]],I=i.GetAttributeByUniqueId(f,p.attributes[y]),C=v(i,f,I,_);t.accessors[h.attributes[y]].setArray(C)}var E=d(i,f);t.accessors[h.indices].setArray(E)}}this._decoderModule.destroy(i);for(var R=0,S=Array.from(a.values());R<S.length;R++)this._decoderModule.destroy(S[R])}return this},o.read=function(e){return this},o.prewrite=function(e,t){if(!this._encoderModule)throw new Error('Please install extension dependency, "draco3d.encoder".');var r=this.doc.getLogger();r.debug("Draco compression options: "+JSON.stringify(this._encoderOptions));for(var n=function(e){for(var t,r=e.getLogger(),n=new Set,o=new Set,i=s(e.getRoot().listMeshes());!(t=i()).done;)for(var a,u=s(t.value.listPrimitives());!(a=u()).done;){var c=a.value;c.getIndices()?4!==c.getMode()?(o.add(c),r.warn("Skipping Draco compression on non-TRIANGLES primitive.")):n.add(c):(o.add(c),r.warn("Skipping Draco compression on non-indexed primitive."))}for(var l=e.getRoot().listAccessors(),h=new Map,p=0;p<l.length;p++)h.set(l[p],p);for(var f=new Map,x=new Map,g=0,T=Array.from(n);g<T.length;g++){var d=T[g],v=[];v.push(h.get(d.getIndices()));for(var m,y=s(d.listAttributes());!(m=y()).done;)v.push(h.get(m.value));var _=v.sort().join("|");x.set(d,_),f.set(d.getIndices(),_);for(var I,C=s(d.listAttributes());!(I=C()).done;)f.set(I.value,_)}for(var E=0,N=Array.from(f.keys());E<N.length;E++){var R=new Set(N[E].listParents().map(function(e){return e.propertyType}));if(2!==R.size||!R.has("Primitive")||!R.has("Root"))throw new Error("Compressed accessors must only be used as indices or vertex attributes.")}for(var S=function(){var e=F[A],t=x.get(e);if(f.get(e.getIndices())!==t||e.listAttributes().some(function(e){return f.get(e)!==t}))throw new Error("Draco primitives must share all, or no, accessors.")},A=0,F=Array.from(n);A<F.length;A++)S();for(var M=0,O=Array.from(o);M<O.length;M++){var D=O[M];if(f.has(D.getIndices())||D.listAttributes().some(function(e){return f.has(e)}))throw new Error("Accessor cannot be shared by compressed and uncompressed primitives.")}return x}(this.doc),o=new Map,i=0,a=Array.from(n.keys());i<a.length;i++){var u=a[i],c=n.get(u);if(o.has(c))o.set(c,o.get(c));else{var l=_(u,this._encoderOptions);o.set(c,l);var h=e.createAccessorDef(u.getIndices());h.count=l.numIndices,e.accessorIndexMap.set(u.getIndices(),e.jsonDoc.json.accessors.length),e.jsonDoc.json.accessors.push(h);for(var p,f=s(u.listSemantics());!(p=f()).done;){var x=u.getAttribute(p.value),g=e.createAccessorDef(x);g.count=l.numVertices,e.accessorIndexMap.set(x,e.jsonDoc.json.accessors.length),e.jsonDoc.json.accessors.push(g)}var T=u.getAttribute("POSITION").getBuffer()||this.doc.getRoot().listBuffers()[0];e.otherBufferViews.has(T)||e.otherBufferViews.set(T,[]),e.otherBufferViews.get(T).push(l.data)}}return r.debug("Compressed "+n.size+" primitives."),e.extensionData[N]={primitiveHashMap:n,primitiveEncodingMap:o},this},o.write=function(e){for(var t,r=e.extensionData[N],n=s(this.doc.getRoot().listMeshes());!(t=n()).done;)for(var o=t.value,i=e.jsonDoc.json.meshes[e.meshIndexMap.get(o)],a=0;a<o.listPrimitives().length;a++){var u=o.listPrimitives()[a],c=i.primitives[a],l=r.primitiveHashMap.get(u);if(l){var h=r.primitiveEncodingMap.get(l);c.extensions=c.extensions||{},c.extensions[N]={bufferView:e.otherBufferViewsIndexMap.get(h.data),attributes:h.attributeIDs}}}return this},n}(e.Extension);R.EXTENSION_NAME=N,R.EncoderMethod=p,(C=exports.LightType||(exports.LightType={})).POINT="point",C.SPOT="spot",C.DIRECTIONAL="directional";var S=function(t){function n(){var r;return(r=t.apply(this,arguments)||this).propertyType="Light",r.parentTypes=[e.PropertyType.NODE],r.extensionName="KHR_lights_punctual",r._color=[1,1,1],r._intensity=1,r._range=void 0,r._innerConeAngle=0,r._outerConeAngle=Math.PI/4,r}r(n,t);var o=n.prototype;return o.copy=function(r,n){return void 0===n&&(n=e.COPY_IDENTITY),t.prototype.copy.call(this,r,n),this._color=[].concat(r._color),this._intensity=r._intensity,this._type=r._type,this._range=r._range,this._innerConeAngle=r._innerConeAngle,this._outerConeAngle=r._outerConeAngle,this},o.getColor=function(){return this._color},o.setColor=function(e){return this._color=e,this},o.getColorHex=function(){return e.ColorUtils.factorToHex(this._color)},o.setColorHex=function(t){return e.ColorUtils.hexToFactor(t,this._color),this},o.getIntensity=function(){return this._intensity},o.setIntensity=function(e){return this._intensity=e,this},o.getType=function(){return this._type},o.setType=function(e){return this._type=e,this},o.getRange=function(){return this._range},o.setRange=function(e){return this._range=e,this},o.getInnerConeAngle=function(){return this._innerConeAngle},o.setInnerConeAngle=function(e){return this._innerConeAngle=e,this},o.getOuterConeAngle=function(){return this._outerConeAngle},o.setOuterConeAngle=function(e){return this._outerConeAngle=e,this},n}(e.ExtensionProperty);S.EXTENSION_NAME="KHR_lights_punctual";var A="KHR_lights_punctual",F=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=A,t}r(t,e);var n=t.prototype;return n.createLight=function(){return new S(this.doc.getGraph(),this)},n.read=function(e){var t=this,r=e.jsonDoc;if(!r.json.extensions||!r.json.extensions[A])return this;var n=(r.json.extensions[A].lights||[]).map(function(e){var r=t.createLight().setName(e.name||"").setType(e.type);return void 0!==e.color&&r.setColor(e.color),void 0!==e.intensity&&r.setIntensity(e.intensity),void 0!==e.range&&r.setRange(e.range),void 0!==e.innerConeAngle&&r.setInnerConeAngle(e.innerConeAngle),void 0!==e.outerConeAngle&&r.setOuterConeAngle(e.outerConeAngle),r});return r.json.nodes.forEach(function(t,r){t.extensions&&t.extensions[A]&&e.nodes[r].setExtension(A,n[t.extensions[A].light])}),this},n.write=function(e){var t=e.jsonDoc;if(0===this.properties.size)return this;for(var r,n=[],o=new Map,i=s(this.properties);!(r=i()).done;){var a=r.value,u={type:a.getType(),color:a.getColor(),intensity:a.getIntensity(),range:a.getRange()};a.getName()&&(u.name=a.getName()),a.getType()===exports.LightType.SPOT&&(u.innerConeAngle=a.getInnerConeAngle(),u.outerConeAngle=a.getOuterConeAngle()),n.push(u),o.set(a,n.length-1)}return this.doc.getRoot().listNodes().forEach(function(r){var n=r.getExtension(A);if(n){var s=e.nodeIndexMap.get(r),i=t.json.nodes[s];i.extensions=i.extensions||{},i.extensions[A]={light:o.get(n)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[A]={lights:n},this},t}(e.Extension);function M(e,t,r,n){var o,s=arguments.length,i=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(i=(s<3?o(i):s>3?o(t,r,i):o(t,r))||i);return s>3&&i&&Object.defineProperty(t,r,i),i}F.EXTENSION_NAME=A;var O=function(t){function o(){var r;return(r=t.apply(this,arguments)||this).propertyType="Clearcoat",r.parentTypes=[e.PropertyType.MATERIAL],r.extensionName="KHR_materials_clearcoat",r._clearcoatFactor=0,r._clearcoatRoughnessFactor=0,r._clearcoatNormalScale=1,r.clearcoatTexture=null,r.clearcoatTextureInfo=r.graph.link("clearcoatTextureInfo",n(r),new e.TextureInfo(r.graph)),r.clearcoatRoughnessTexture=null,r.clearcoatRoughnessTextureInfo=r.graph.link("clearcoatRoughnessTextureInfo",n(r),new e.TextureInfo(r.graph)),r.clearcoatNormalTexture=null,r.clearcoatNormalTextureInfo=r.graph.link("clearcoatNormalTextureInfo",n(r),new e.TextureInfo(r.graph)),r}r(o,t);var s=o.prototype;return s.copy=function(r,n){return void 0===n&&(n=e.COPY_IDENTITY),t.prototype.copy.call(this,r,n),this._clearcoatFactor=r._clearcoatFactor,this._clearcoatRoughnessFactor=r._clearcoatRoughnessFactor,this._clearcoatNormalScale=r._clearcoatNormalScale,r.clearcoatTexture&&(this.setClearcoatTexture(n(r.clearcoatTexture.getChild())),this.getClearcoatTextureInfo().copy(n(r.clearcoatTextureInfo.getChild()),n)),r.clearcoatRoughnessTexture&&(this.setClearcoatRoughnessTexture(n(r.clearcoatRoughnessTexture.getChild())),this.getClearcoatRoughnessTextureInfo().copy(n(r.clearcoatRoughnessTextureInfo.getChild()),n)),r.clearcoatNormalTexture&&(this.setClearcoatNormalTexture(n(r.clearcoatNormalTexture.getChild())),this.getClearcoatNormalTextureInfo().copy(n(r.clearcoatNormalTextureInfo.getChild()),n)),this},s.dispose=function(){this.clearcoatTextureInfo.getChild().dispose(),this.clearcoatRoughnessTextureInfo.getChild().dispose(),this.clearcoatNormalTextureInfo.getChild().dispose(),t.prototype.dispose.call(this)},s.getClearcoatFactor=function(){return this._clearcoatFactor},s.setClearcoatFactor=function(e){return this._clearcoatFactor=e,this},s.getClearcoatTexture=function(){return this.clearcoatTexture?this.clearcoatTexture.getChild():null},s.getClearcoatTextureInfo=function(){return this.clearcoatTexture?this.clearcoatTextureInfo.getChild():null},s.setClearcoatTexture=function(e){return this.clearcoatTexture=this.graph.link("clearcoatTexture",this,e),this},s.getClearcoatRoughnessFactor=function(){return this._clearcoatRoughnessFactor},s.setClearcoatRoughnessFactor=function(e){return this._clearcoatRoughnessFactor=e,this},s.getClearcoatRoughnessTexture=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.getChild():null},s.getClearcoatRoughnessTextureInfo=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTextureInfo.getChild():null},s.setClearcoatRoughnessTexture=function(e){return this.clearcoatRoughnessTexture=this.graph.link("clearcoatRoughnessTexture",this,e),this},s.getClearcoatNormalScale=function(){return this._clearcoatNormalScale},s.setClearcoatNormalScale=function(e){return this._clearcoatNormalScale=e,this},s.getClearcoatNormalTexture=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTexture.getChild():null},s.getClearcoatNormalTextureInfo=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTextureInfo.getChild():null},s.setClearcoatNormalTexture=function(e){return this.clearcoatNormalTexture=this.graph.link("clearcoatNormalTexture",this,e),this},o}(e.ExtensionProperty);O.EXTENSION_NAME="KHR_materials_clearcoat",M([e.GraphChild],O.prototype,"clearcoatTexture",void 0),M([e.GraphChild],O.prototype,"clearcoatTextureInfo",void 0),M([e.GraphChild],O.prototype,"clearcoatRoughnessTexture",void 0),M([e.GraphChild],O.prototype,"clearcoatRoughnessTextureInfo",void 0),M([e.GraphChild],O.prototype,"clearcoatNormalTexture",void 0),M([e.GraphChild],O.prototype,"clearcoatNormalTextureInfo",void 0);var D="KHR_materials_clearcoat",G=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=D,t}r(t,e);var n=t.prototype;return n.createClearcoat=function(){return new O(this.doc.getGraph(),this)},n.read=function(e){var t=this,r=e.jsonDoc,n=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,o){if(r.extensions&&r.extensions[D]){var s=t.createClearcoat();if(e.materials[o].setExtension(D,s),void 0!==r.extensions[D].clearcoatFactor&&s.setClearcoatFactor(r.extensions[D].clearcoatFactor),void 0!==r.extensions[D].clearcoatRoughnessFactor&&s.setClearcoatRoughnessFactor(r.extensions[D].clearcoatRoughnessFactor),void 0!==r.extensions[D].clearcoatTexture){var i=r.extensions[D].clearcoatTexture;s.setClearcoatTexture(e.textures[n[i.index].source]),e.setTextureInfo(s.getClearcoatTextureInfo(),i)}if(void 0!==r.extensions[D].clearcoatRoughnessTexture){var a=r.extensions[D].clearcoatRoughnessTexture;s.setClearcoatRoughnessTexture(e.textures[n[a.index].source]),e.setTextureInfo(s.getClearcoatRoughnessTextureInfo(),a)}if(void 0!==r.extensions[D].clearcoatNormalTexture){var u=r.extensions[D].clearcoatNormalTexture;s.setClearcoatNormalTexture(e.textures[n[u.index].source]),e.setTextureInfo(s.getClearcoatNormalTextureInfo(),u),void 0!==u.scale&&s.setClearcoatNormalScale(u.scale)}}}),this},n.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var n=r.getExtension(D);if(n){var o=e.materialIndexMap.get(r),s=t.json.materials[o];if(s.extensions=s.extensions||{},s.extensions[D]={clearcoatFactor:n.getClearcoatFactor(),clearcoatRoughnessFactor:n.getClearcoatRoughnessFactor()},n.getClearcoatTexture()){var i=n.getClearcoatTexture(),a=n.getClearcoatTextureInfo();s.extensions[D].clearcoatTexture=e.createTextureInfoDef(i,a)}if(n.getClearcoatRoughnessTexture()){var u=n.getClearcoatRoughnessTexture(),c=n.getClearcoatRoughnessTextureInfo();s.extensions[D].clearcoatRoughnessTexture=e.createTextureInfoDef(u,c)}if(n.getClearcoatNormalTexture()){var l=n.getClearcoatNormalTexture(),h=n.getClearcoatNormalTextureInfo();s.extensions[D].clearcoatNormalTexture=e.createTextureInfoDef(l,h),1!==n.getClearcoatNormalScale()&&(s.extensions[D].clearcoatNormalTexture.scale=n.getClearcoatNormalScale())}}}),this},t}(e.Extension);G.EXTENSION_NAME=D;var w=function(t){function n(){var r;return(r=t.apply(this,arguments)||this).propertyType="IOR",r.parentTypes=[e.PropertyType.MATERIAL],r.extensionName="KHR_materials_ior",r._ior=0,r}r(n,t);var o=n.prototype;return o.copy=function(r,n){return void 0===n&&(n=e.COPY_IDENTITY),t.prototype.copy.call(this,r,n),this._ior=r._ior,this},o.getIOR=function(){return this._ior},o.setIOR=function(e){return this._ior=e,this},n}(e.ExtensionProperty);w.EXTENSION_NAME="KHR_materials_ior";var j="KHR_materials_ior",P=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=j,t}r(t,e);var n=t.prototype;return n.createIOR=function(){return new w(this.doc.getGraph(),this)},n.read=function(e){var t=this;return(e.jsonDoc.json.materials||[]).forEach(function(r,n){if(r.extensions&&r.extensions[j]){var o=t.createIOR();e.materials[n].setExtension(j,o),void 0!==r.extensions[j].ior&&o.setIOR(r.extensions[j].ior)}}),this},n.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var n=r.getExtension(j);if(n){var o=e.materialIndexMap.get(r),s=t.json.materials[o];s.extensions=s.extensions||{},s.extensions[j]={ior:n.getIOR()}}}),this},t}(e.Extension);P.EXTENSION_NAME=j;var b=function(t){function o(){var r;return(r=t.apply(this,arguments)||this).propertyType="PBRSpecularGlossiness",r.parentTypes=[e.PropertyType.MATERIAL],r.extensionName="KHR_materials_pbrSpecularGlossiness",r._diffuseFactor=[1,1,1,1],r._specularFactor=[1,1,1],r._glossinessFactor=1,r.diffuseTexture=null,r.diffuseTextureInfo=r.graph.link("diffuseTextureInfo",n(r),new e.TextureInfo(r.graph)),r.specularGlossinessTexture=null,r.specularGlossinessTextureInfo=r.graph.link("specularGlossinessTextureInfo",n(r),new e.TextureInfo(r.graph)),r}r(o,t);var s=o.prototype;return s.copy=function(r,n){return void 0===n&&(n=e.COPY_IDENTITY),t.prototype.copy.call(this,r,n),this._diffuseFactor=r._diffuseFactor,this._specularFactor=r._specularFactor,this._glossinessFactor=r._glossinessFactor,r.diffuseTexture&&(this.setDiffuseTexture(n(r.diffuseTexture.getChild())),this.getDiffuseTextureInfo().copy(n(r.diffuseTextureInfo.getChild()),n)),r.specularGlossinessTexture&&(this.setSpecularGlossinessTexture(n(r.specularGlossinessTexture.getChild())),this.getSpecularGlossinessTextureInfo().copy(n(r.specularGlossinessTextureInfo.getChild()),n)),this},s.dispose=function(){this.diffuseTextureInfo.getChild().dispose(),this.specularGlossinessTextureInfo.getChild().dispose(),t.prototype.dispose.call(this)},s.getDiffuseFactor=function(){return this._diffuseFactor},s.setDiffuseFactor=function(e){return this._diffuseFactor=e,this},s.getDiffuseHex=function(){return e.ColorUtils.factorToHex(this._diffuseFactor)},s.setDiffuseHex=function(t){return e.ColorUtils.hexToFactor(t,this._diffuseFactor),this},s.getDiffuseTexture=function(){return this.diffuseTexture?this.diffuseTexture.getChild():null},s.getDiffuseTextureInfo=function(){return this.diffuseTexture?this.diffuseTextureInfo.getChild():null},s.setDiffuseTexture=function(e){return this.diffuseTexture=this.graph.link("diffuseTexture",this,e),this},s.getSpecularFactor=function(){return this._specularFactor},s.setSpecularFactor=function(e){return this._specularFactor=e,this},s.getGlossinessFactor=function(){return this._glossinessFactor},s.setGlossinessFactor=function(e){return this._glossinessFactor=e,this},s.getSpecularGlossinessTexture=function(){return this.specularGlossinessTexture?this.specularGlossinessTexture.getChild():null},s.getSpecularGlossinessTextureInfo=function(){return this.specularGlossinessTexture?this.specularGlossinessTextureInfo.getChild():null},s.setSpecularGlossinessTexture=function(e){return this.specularGlossinessTexture=this.graph.link("specularGlossinessTexture",this,e),this},o}(e.ExtensionProperty);b.EXTENSION_NAME="KHR_materials_pbrSpecularGlossiness",M([e.GraphChild],b.prototype,"diffuseTexture",void 0),M([e.GraphChild],b.prototype,"diffuseTextureInfo",void 0),M([e.GraphChild],b.prototype,"specularGlossinessTexture",void 0),M([e.GraphChild],b.prototype,"specularGlossinessTextureInfo",void 0);var H="KHR_materials_pbrSpecularGlossiness",L=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=H,t}r(t,e);var n=t.prototype;return n.createPBRSpecularGlossiness=function(){return new b(this.doc.getGraph(),this)},n.read=function(e){var t=this,r=e.jsonDoc,n=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,o){if(r.extensions&&r.extensions[H]){var s=t.createPBRSpecularGlossiness();if(e.materials[o].setExtension(H,s),void 0!==r.extensions[H].diffuseFactor&&s.setDiffuseFactor(r.extensions[H].diffuseFactor),void 0!==r.extensions[H].specularFactor&&s.setSpecularFactor(r.extensions[H].specularFactor),void 0!==r.extensions[H].glossinessFactor&&s.setGlossinessFactor(r.extensions[H].glossinessFactor),void 0!==r.extensions[H].diffuseTexture){var i=r.extensions[H].diffuseTexture;s.setDiffuseTexture(e.textures[n[i.index].source]),e.setTextureInfo(s.getDiffuseTextureInfo(),i)}if(void 0!==r.extensions[H].specularGlossinessTexture){var a=r.extensions[H].specularGlossinessTexture;s.setSpecularGlossinessTexture(e.textures[n[a.index].source]),e.setTextureInfo(s.getSpecularGlossinessTextureInfo(),a)}}}),this},n.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var n=r.getExtension(H);if(n){var o=e.materialIndexMap.get(r),s=t.json.materials[o];if(s.extensions=s.extensions||{},s.extensions[H]={diffuseFactor:n.getDiffuseFactor(),specularFactor:n.getSpecularFactor(),glossinessFactor:n.getGlossinessFactor()},n.getDiffuseTexture()){var i=n.getDiffuseTexture(),a=n.getDiffuseTextureInfo();s.extensions[H].diffuseTexture=e.createTextureInfoDef(i,a)}if(n.getSpecularGlossinessTexture()){var u=n.getSpecularGlossinessTexture(),c=n.getSpecularGlossinessTextureInfo();s.extensions[H].specularGlossinessTexture=e.createTextureInfoDef(u,c)}}}),this},t}(e.Extension);L.EXTENSION_NAME=H;var K=function(t){function o(){var r;return(r=t.apply(this,arguments)||this).propertyType="Sheen",r.parentTypes=[e.PropertyType.MATERIAL],r.extensionName="KHR_materials_sheen",r._sheenColorFactor=[0,0,0],r._sheenRoughnessFactor=0,r.sheenColorTexture=null,r.sheenColorTextureInfo=r.graph.link("sheenColorTextureInfo",n(r),new e.TextureInfo(r.graph)),r.sheenRoughnessTexture=null,r.sheenRoughnessTextureInfo=r.graph.link("sheenRoughnessTextureInfo",n(r),new e.TextureInfo(r.graph)),r}r(o,t);var s=o.prototype;return s.copy=function(r,n){return void 0===n&&(n=e.COPY_IDENTITY),t.prototype.copy.call(this,r,n),this._sheenColorFactor=r._sheenColorFactor,this._sheenRoughnessFactor=r._sheenRoughnessFactor,r.sheenColorTexture&&(this.setSheenColorTexture(n(r.sheenColorTexture.getChild())),this.getSheenColorTextureInfo().copy(n(r.sheenColorTextureInfo.getChild()),n)),r.sheenRoughnessTexture&&(this.setSheenRoughnessTexture(n(r.sheenRoughnessTexture.getChild())),this.getSheenRoughnessTextureInfo().copy(n(r.sheenRoughnessTextureInfo.getChild()),n)),this},s.dispose=function(){this.sheenColorTextureInfo.getChild().dispose(),this.sheenRoughnessTextureInfo.getChild().dispose(),t.prototype.dispose.call(this)},s.getSheenColorFactor=function(){return this._sheenColorFactor},s.getSheenColorHex=function(){return e.ColorUtils.factorToHex(this._sheenColorFactor)},s.setSheenColorFactor=function(e){return this._sheenColorFactor=e,this},s.setSheenColorHex=function(t){return e.ColorUtils.hexToFactor(t,this._sheenColorFactor),this},s.getSheenColorTexture=function(){return this.sheenColorTexture?this.sheenColorTexture.getChild():null},s.getSheenColorTextureInfo=function(){return this.sheenColorTexture?this.sheenColorTextureInfo.getChild():null},s.setSheenColorTexture=function(e){return this.sheenColorTexture=this.graph.link("sheenColorTexture",this,e),this},s.getSheenRoughnessFactor=function(){return this._sheenRoughnessFactor},s.setSheenRoughnessFactor=function(e){return this._sheenRoughnessFactor=e,this},s.getSheenRoughnessTexture=function(){return this.sheenRoughnessTexture?this.sheenRoughnessTexture.getChild():null},s.getSheenRoughnessTextureInfo=function(){return this.sheenRoughnessTexture?this.sheenRoughnessTextureInfo.getChild():null},s.setSheenRoughnessTexture=function(e){return this.sheenRoughnessTexture=this.graph.link("sheenRoughnessTexture",this,e),this},o}(e.ExtensionProperty);K.EXTENSION_NAME="KHR_materials_sheen",M([e.GraphChild],K.prototype,"sheenColorTexture",void 0),M([e.GraphChild],K.prototype,"sheenColorTextureInfo",void 0),M([e.GraphChild],K.prototype,"sheenRoughnessTexture",void 0),M([e.GraphChild],K.prototype,"sheenRoughnessTextureInfo",void 0);var U="KHR_materials_sheen",X=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=U,t}r(t,e);var n=t.prototype;return n.createSheen=function(){return new K(this.doc.getGraph(),this)},n.read=function(e){var t=this,r=e.jsonDoc,n=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,o){if(r.extensions&&r.extensions[U]){var s=t.createSheen();if(e.materials[o].setExtension(U,s),void 0!==r.extensions[U].sheenColorFactor&&s.setSheenColorFactor(r.extensions[U].sheenColorFactor),void 0!==r.extensions[U].sheenRoughnessFactor&&s.setSheenRoughnessFactor(r.extensions[U].sheenRoughnessFactor),void 0!==r.extensions[U].sheenColorTexture){var i=r.extensions[U].sheenColorTexture;s.setSheenColorTexture(e.textures[n[i.index].source]),e.setTextureInfo(s.getSheenColorTextureInfo(),i)}if(void 0!==r.extensions[U].sheenRoughnessTexture){var a=r.extensions[U].sheenRoughnessTexture;s.setSheenRoughnessTexture(e.textures[n[a.index].source]),e.setTextureInfo(s.getSheenRoughnessTextureInfo(),a)}}}),this},n.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var n=r.getExtension(U);if(n){var o=e.materialIndexMap.get(r),s=t.json.materials[o];if(s.extensions=s.extensions||{},s.extensions[U]={sheenColorFactor:n.getSheenColorFactor(),sheenRoughnessFactor:n.getSheenRoughnessFactor()},n.getSheenColorTexture()){var i=n.getSheenColorTexture(),a=n.getSheenColorTextureInfo();s.extensions[U].sheenColorTexture=e.createTextureInfoDef(i,a)}if(n.getSheenRoughnessTexture()){var u=n.getSheenRoughnessTexture(),c=n.getSheenRoughnessTextureInfo();s.extensions[U].sheenRoughnessTexture=e.createTextureInfoDef(u,c)}}}),this},t}(e.Extension);X.EXTENSION_NAME=U;var B=function(t){function o(){var r;return(r=t.apply(this,arguments)||this).propertyType="Specular",r.parentTypes=[e.PropertyType.MATERIAL],r.extensionName="KHR_materials_specular",r._specularFactor=1,r._specularColorFactor=[1,1,1],r.specularTexture=null,r.specularTextureInfo=r.graph.link("specularTextureInfo",n(r),new e.TextureInfo(r.graph)),r}r(o,t);var s=o.prototype;return s.copy=function(r,n){return void 0===n&&(n=e.COPY_IDENTITY),t.prototype.copy.call(this,r,n),this._specularFactor=r._specularFactor,r.specularTexture&&(this.setSpecularTexture(n(r.specularTexture.getChild())),this.getSpecularTextureInfo().copy(n(r.specularTextureInfo.getChild()),n)),this},s.dispose=function(){this.specularTextureInfo.getChild().dispose(),t.prototype.dispose.call(this)},s.getSpecularFactor=function(){return this._specularFactor},s.setSpecularFactor=function(e){return this._specularFactor=e,this},s.getSpecularColorFactor=function(){return this._specularColorFactor},s.setSpecularColorFactor=function(e){return this._specularColorFactor=e,this},s.getSpecularColorHex=function(){return e.ColorUtils.factorToHex(this._specularColorFactor)},s.setSpecularColorHex=function(t){return e.ColorUtils.hexToFactor(t,this._specularColorFactor),this},s.getSpecularTexture=function(){return this.specularTexture?this.specularTexture.getChild():null},s.getSpecularTextureInfo=function(){return this.specularTexture?this.specularTextureInfo.getChild():null},s.setSpecularTexture=function(e){return this.specularTexture=this.graph.link("specularTexture",this,e),this},o}(e.ExtensionProperty);B.EXTENSION_NAME="KHR_materials_specular",M([e.GraphChild],B.prototype,"specularTexture",void 0),M([e.GraphChild],B.prototype,"specularTextureInfo",void 0);var k="KHR_materials_specular",V=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=k,t}r(t,e);var n=t.prototype;return n.createSpecular=function(){return new B(this.doc.getGraph(),this)},n.read=function(e){var t=this,r=e.jsonDoc,n=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,o){if(r.extensions&&r.extensions[k]){var s=t.createSpecular();if(e.materials[o].setExtension(k,s),void 0!==r.extensions[k].specularFactor&&s.setSpecularFactor(r.extensions[k].specularFactor),void 0!==r.extensions[k].specularColorFactor&&s.setSpecularColorFactor(r.extensions[k].specularColorFactor),void 0!==r.extensions[k].specularTexture){var i=r.extensions[k].specularTexture;s.setSpecularTexture(e.textures[n[i.index].source]),e.setTextureInfo(s.getSpecularTextureInfo(),i)}}}),this},n.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var n=r.getExtension(k);if(n){var o=e.materialIndexMap.get(r),s=t.json.materials[o];if(s.extensions=s.extensions||{},s.extensions[k]={specularFactor:n.getSpecularFactor(),specularColorFactor:n.getSpecularColorFactor()},n.getSpecularTexture()){var i=n.getSpecularTexture(),a=n.getSpecularTextureInfo();s.extensions[k].specularTexture=e.createTextureInfoDef(i,a)}}}),this},t}(e.Extension);V.EXTENSION_NAME=k;var Y=function(t){function o(){var r;return(r=t.apply(this,arguments)||this).propertyType="Transmission",r.parentTypes=[e.PropertyType.MATERIAL],r.extensionName="KHR_materials_transmission",r._transmissionFactor=0,r.transmissionTexture=null,r.transmissionTextureInfo=r.graph.link("transmissionTextureInfo",n(r),new e.TextureInfo(r.graph)),r}r(o,t);var s=o.prototype;return s.copy=function(r,n){return void 0===n&&(n=e.COPY_IDENTITY),t.prototype.copy.call(this,r,n),this._transmissionFactor=r._transmissionFactor,r.transmissionTexture&&(this.setTransmissionTexture(n(r.transmissionTexture.getChild())),this.getTransmissionTextureInfo().copy(n(r.transmissionTextureInfo.getChild()),n)),this},s.dispose=function(){this.transmissionTextureInfo.getChild().dispose(),t.prototype.dispose.call(this)},s.getTransmissionFactor=function(){return this._transmissionFactor},s.setTransmissionFactor=function(e){return this._transmissionFactor=e,this},s.getTransmissionTexture=function(){return this.transmissionTexture?this.transmissionTexture.getChild():null},s.getTransmissionTextureInfo=function(){return this.transmissionTexture?this.transmissionTextureInfo.getChild():null},s.setTransmissionTexture=function(e){return this.transmissionTexture=this.graph.link("transmissionTexture",this,e),this},o}(e.ExtensionProperty);Y.EXTENSION_NAME="KHR_materials_transmission",M([e.GraphChild],Y.prototype,"transmissionTexture",void 0),M([e.GraphChild],Y.prototype,"transmissionTextureInfo",void 0);var z="KHR_materials_transmission",q=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=z,t}r(t,e);var n=t.prototype;return n.createTransmission=function(){return new Y(this.doc.getGraph(),this)},n.read=function(e){var t=this,r=e.jsonDoc,n=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,o){if(r.extensions&&r.extensions[z]){var s=t.createTransmission();if(e.materials[o].setExtension(z,s),void 0!==r.extensions[z].transmissionFactor&&s.setTransmissionFactor(r.extensions[z].transmissionFactor),void 0!==r.extensions[z].transmissionTexture){var i=r.extensions[z].transmissionTexture;s.setTransmissionTexture(e.textures[n[i.index].source]),e.setTextureInfo(s.getTransmissionTextureInfo(),i)}}}),this},n.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var n=r.getExtension(z);if(n){var o=e.materialIndexMap.get(r),s=t.json.materials[o];if(s.extensions=s.extensions||{},s.extensions[z]={transmissionFactor:n.getTransmissionFactor()},n.getTransmissionTexture()){var i=n.getTransmissionTexture(),a=n.getTransmissionTextureInfo();s.extensions[z].transmissionTexture=e.createTextureInfoDef(i,a)}}}),this},t}(e.Extension);q.EXTENSION_NAME=z;var Q=function(t){function n(){var r;return(r=t.apply(this,arguments)||this).propertyType="Unlit",r.parentTypes=[e.PropertyType.MATERIAL],r.extensionName="KHR_materials_unlit",r}return r(n,t),n}(e.ExtensionProperty);Q.EXTENSION_NAME="KHR_materials_unlit";var W="KHR_materials_unlit",J=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=W,t}r(t,e);var n=t.prototype;return n.createUnlit=function(){return new Q(this.doc.getGraph(),this)},n.read=function(e){var t=this;return(e.jsonDoc.json.materials||[]).forEach(function(r,n){r.extensions&&r.extensions[W]&&e.materials[n].setExtension(W,t.createUnlit())}),this},n.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){if(r.getExtension(W)){var n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{},o.extensions[W]={}}}),this},t}(e.Extension);J.EXTENSION_NAME=W;var $=function(t){function n(){var e;return(e=t.apply(this,arguments)||this).propertyType="Mapping",e.parentTypes=["MappingList"],e.extensionName="KHR_materials_variants",e.material=null,e.variants=[],e}r(n,t);var o=n.prototype;return o.copy=function(r,n){var o=this;return void 0===n&&(n=e.COPY_IDENTITY),t.prototype.copy.call(this,r,n),r.material&&this.setMaterial(n(r.material.getChild())),this.clearGraphChildList(this.variants),r.variants.forEach(function(e){return o.addVariant(n(e.getChild()))}),this},o.getMaterial=function(){return this.material?this.material.getChild():null},o.setMaterial=function(e){return this.material=this.graph.link("material",this,e),this},o.addVariant=function(e){var t=this.graph.link("variant",this,e);return this.addGraphChild(this.variants,t)},o.removeVariant=function(e){return this.removeGraphChild(this.variants,e)},o.listVariants=function(){return this.variants.map(function(e){return e.getChild()})},n}(e.ExtensionProperty);$.EXTENSION_NAME="KHR_materials_variants",M([e.GraphChild],$.prototype,"material",void 0),M([e.GraphChildList],$.prototype,"variants",void 0);var Z=function(t){function n(){var r;return(r=t.apply(this,arguments)||this).propertyType="MappingList",r.parentTypes=[e.PropertyType.PRIMITIVE],r.extensionName="KHR_materials_variants",r.mappings=[],r}r(n,t);var o=n.prototype;return o.copy=function(r,n){var o=this;return void 0===n&&(n=e.COPY_IDENTITY),t.prototype.copy.call(this,r,n),this.clearGraphChildList(this.mappings),r.mappings.forEach(function(e){return o.addMapping(n(e.getChild()))}),this},o.addMapping=function(e){var t=this.graph.link("mapping",this,e);return this.addGraphChild(this.mappings,t)},o.removeMapping=function(e){return this.removeGraphChild(this.mappings,e)},o.listMappings=function(){return this.mappings.map(function(e){return e.getChild()})},n}(e.ExtensionProperty);Z.EXTENSION_NAME="KHR_materials_variants",M([e.GraphChildList],Z.prototype,"mappings",void 0);var ee=function(t){function n(){var r;return(r=t.apply(this,arguments)||this).propertyType="Variant",r.parentTypes=[e.PropertyType.ROOT,"MappingList"],r.extensionName="KHR_materials_variants",r}return r(n,t),n}(e.ExtensionProperty);ee.EXTENSION_NAME="KHR_materials_variants";var te="KHR_materials_variants",re=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=te,t}r(t,e);var n=t.prototype;return n.createMappingList=function(){return new Z(this.doc.getGraph(),this)},n.createVariant=function(e){return void 0===e&&(e=""),new ee(this.doc.getGraph(),this).setName(e)},n.createMapping=function(){return new $(this.doc.getGraph(),this)},n.listVariants=function(){return Array.from(this.properties).filter(function(e){return e instanceof ee})},n.read=function(e){var t=this,r=e.jsonDoc;if(!r.json.extensions||!r.json.extensions[te])return this;var n=(r.json.extensions[te].variants||[]).map(function(e){return t.createVariant().setName(e.name||"")});return(r.json.meshes||[]).forEach(function(r,o){var i=e.meshes[o];(r.primitives||[]).forEach(function(r,o){if(r.extensions&&r.extensions[te]){for(var a,u=t.createMappingList(),c=s(r.extensions[te].mappings);!(a=c()).done;){var l=a.value,h=t.createMapping();void 0!==l.material&&h.setMaterial(e.materials[l.material]);for(var p,f=s(l.variants||[]);!(p=f()).done;)h.addVariant(n[p.value]);u.addMapping(h)}i.listPrimitives()[o].setExtension(te,u)}})}),this},n.write=function(e){var t=e.jsonDoc,r=this.listVariants();if(!r.length)return this;for(var n,o=[],i=new Map,a=s(r);!(n=a()).done;){var u=n.value;i.set(u,o.length),o.push(e.createPropertyDef(u))}for(var c,l=function(){var t=c.value,r=e.meshIndexMap.get(t);t.listPrimitives().forEach(function(t,n){if(t.getExtension(te)){var o=e.jsonDoc.json.meshes[r].primitives[n],s=t.getExtension(te).listMappings().map(function(t){var r=e.createPropertyDef(t);return t.getMaterial()&&(r.material=e.materialIndexMap.get(t.getMaterial())),r.variants=t.listVariants().map(function(e){return i.get(e)}),r});o.extensions=o.extensions||{},o.extensions[te]={mappings:s}}})},h=s(this.doc.getRoot().listMeshes());!(c=h()).done;)l();return t.json.extensions=t.json.extensions||{},t.json.extensions[te]={variants:o},this},t}(e.Extension);re.EXTENSION_NAME=te;var ne="KHR_mesh_quantization",oe=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=ne,t}r(t,e);var n=t.prototype;return n.read=function(e){return this},n.write=function(e){return this},t}(e.Extension);oe.EXTENSION_NAME=ne;var se="KHR_texture_basisu",ie=function(t){function n(){var r;return(r=t.apply(this,arguments)||this).extensionName=se,r.prereadTypes=[e.PropertyType.TEXTURE],r}r(n,t);var o=n.prototype;return o.preread=function(e){return e.jsonDoc.json.textures.forEach(function(e){e.extensions&&e.extensions[se]&&(e.source=e.extensions[se].source)}),this},o.read=function(e){return this},o.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listTextures().forEach(function(r){if("image/ktx2"===r.getMimeType()){var n=e.imageIndexMap.get(r);t.json.textures.forEach(function(e){e.source===n&&(e.extensions=e.extensions||{},e.extensions[se]={source:e.source},delete e.source)})}}),this},n}(e.Extension);ie.EXTENSION_NAME=se;var ae=function(t){function n(){var r;return(r=t.apply(this,arguments)||this).propertyType="Transform",r.parentTypes=[e.PropertyType.TEXTURE_INFO],r.extensionName="KHR_texture_transform",r._offset=[0,0],r._rotation=0,r._scale=[1,1],r._texCoord=void 0,r}r(n,t);var o=n.prototype;return o.copy=function(r,n){return void 0===n&&(n=e.COPY_IDENTITY),t.prototype.copy.call(this,r,n),this._offset=r._offset,this._rotation=r._rotation,this._scale=r._scale,this._texCoord=r._texCoord,this},o.getOffset=function(){return this._offset},o.setOffset=function(e){return this._offset=e,this},o.getRotation=function(){return this._rotation},o.setRotation=function(e){return this._rotation=e,this},o.getScale=function(){return this._scale},o.setScale=function(e){return this._scale=e,this},o.getTexCoord=function(){return this._texCoord},o.setTexCoord=function(e){return this._texCoord=e,this},n}(e.ExtensionProperty);ae.EXTENSION_NAME="KHR_texture_transform";var ue="KHR_texture_transform",ce=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=ue,t}r(t,e);var n=t.prototype;return n.createTransform=function(){return new ae(this.doc.getGraph(),this)},n.read=function(e){for(var t=0,r=Array.from(e.textureInfos.entries());t<r.length;t++){var n=r[t],o=n[0],s=n[1];if(s.extensions&&s.extensions[ue]){var i=this.createTransform(),a=s.extensions[ue];void 0!==a.offset&&i.setOffset(a.offset),void 0!==a.rotation&&i.setRotation(a.rotation),void 0!==a.scale&&i.setScale(a.scale),void 0!==a.texCoord&&i.setTexCoord(a.texCoord),o.setExtension(ue,i)}}return this},n.write=function(e){for(var t=0,r=Array.from(e.textureInfoDefMap.entries());t<r.length;t++){var n=r[t],o=n[1],s=n[0].getExtension(ue);s&&(o.extensions=o.extensions||{},o.extensions[ue]={offset:s.getOffset(),rotation:s.getRotation(),scale:s.getScale(),texCoord:s.getTexCoord()})}return this},t}(e.Extension);ce.EXTENSION_NAME=ue;var le=[R,F,G,P,L,V,X,q,J,re,oe,ie,ce],he=[g].concat(le);exports.ALL_EXTENSIONS=he,exports.Clearcoat=O,exports.DracoMeshCompression=R,exports.IOR=w,exports.KHRONOS_EXTENSIONS=le,exports.Light=S,exports.LightsPunctual=F,exports.Mapping=$,exports.MappingList=Z,exports.MaterialsClearcoat=G,exports.MaterialsIOR=P,exports.MaterialsPBRSpecularGlossiness=L,exports.MaterialsSheen=X,exports.MaterialsSpecular=V,exports.MaterialsTransmission=q,exports.MaterialsUnlit=J,exports.MaterialsVariants=re,exports.MeshQuantization=oe,exports.PBRSpecularGlossiness=b,exports.Sheen=K,exports.Specular=B,exports.TextureBasisu=ie,exports.TextureTransform=ce,exports.TextureWebP=g,exports.Transform=ae,exports.Transmission=Y,exports.Unlit=Q,exports.Variant=ee;
var e=require("@gltf-transform/core");function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function n(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function s(e){var t=0;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,t){if(e){if("string"==typeof e)return o(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,void 0):void 0}}(e)))return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}var i="EXT_texture_webp",a=function(t){function n(){var r;return(r=t.apply(this,arguments)||this).extensionName=i,r.prereadTypes=[e.PropertyType.TEXTURE],r}r(n,t);var o=n.prototype;return o.preread=function(e){return e.jsonDoc.json.textures.forEach(function(e){e.extensions&&e.extensions[i]&&(e.source=e.extensions[i].source)}),this},o.read=function(e){return this},o.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listTextures().forEach(function(r){if("image/webp"===r.getMimeType()){var n=e.imageIndexMap.get(r);t.json.textures.forEach(function(e){e.source===n&&(e.extensions=e.extensions||{},e.extensions[i]={source:e.source},delete e.source)})}}),this},n}(e.Extension);a.EXTENSION_NAME=i;var u,c,l,h,p,f,x,g,T="KHR_draco_mesh_compression";function d(e,t){var r;try{if((r=new u.DecoderBuffer).Init(t,t.length),e.GetEncodedGeometryType(r)!==u.TRIANGULAR_MESH)throw new Error("["+T+"] Unknown geometry type.");var n=new u.Mesh;if(!e.DecodeBufferToMesh(r,n).ok()||0===n.ptr)throw new Error("["+T+"] Decoding failure.");return n}finally{u.destroy(r)}}function v(e,t){var r=3*t.num_faces(),n=r*Uint32Array.BYTES_PER_ELEMENT,o=u._malloc(n);e.GetTrianglesUInt32Array(t,n,o);var s=new Uint32Array(u.HEAP32.buffer,o,r).slice();return u._free(o),s}function m(e,t,r,n){var o=l[n.componentType],s=c[n.componentType],i=r.num_components(),a=t.num_points()*i,h=a*s.BYTES_PER_ELEMENT,p=u._malloc(h);e.GetAttributeDataArrayForAllPoints(t,r,o,h,p);var f=new s(u.HEAPF32.buffer,p,a).slice();return u._free(p),f}!function(e){e[e.EDGEBREAKER=1]="EDGEBREAKER",e[e.SEQUENTIAL=0]="SEQUENTIAL"}(x||(x={})),function(e){e.POSITION="POSITION",e.NORMAL="NORMAL",e.COLOR="COLOR",e.TEX_COORD="TEX_COORD",e.GENERIC="GENERIC"}(g||(g={}));var y=((h={})[g.POSITION]=14,h[g.NORMAL]=10,h[g.COLOR]=8,h[g.TEX_COORD]=12,h[g.GENERIC]=12,h),_={decodeSpeed:5,encodeSpeed:5,method:x.EDGEBREAKER,quantizationBits:y};function I(e,r){void 0===r&&(r=_);var n=t(t({},_),r);n.quantizationBits=t(t({},y),r.quantizationBits);for(var o,i=new f.Encoder,a=new f.MeshBuilder,u=new f.Mesh,c={},l=new f.DracoInt8Array,h=s(e.listSemantics());!(o=h()).done;){var p=o.value,g=e.getAttribute(p),T=C(p),d=a[R[g.getComponentType()]](u,f[T],g.getCount(),g.getElementSize(),g.getArray());if(-1===d)throw new Error('Error compressing "'+p+'" attribute.');c[p]=d,i.SetAttributeQuantization(f[T],n.quantizationBits[T])}a.AddFacesToMesh(u,e.getIndices().getCount()/3,e.getIndices().getArray()),i.SetSpeedOptions(n.encodeSpeed,n.decodeSpeed),i.SetTrackEncodedProperties(!0),e.listTargets().length>0||n.method===x.SEQUENTIAL?i.SetEncodingMethod(f.MESH_SEQUENTIAL_ENCODING):i.SetEncodingMethod(f.MESH_EDGEBREAKER_ENCODING);var v=i.EncodeMeshToDracoBuffer(u,l);if(v<=0)throw new Error("Error applying Draco compression.");for(var m=new Uint8Array(v),I=0;I<v;++I)m[I]=l.GetValue(I);var E=i.GetNumberOfEncodedPoints(),N=3*i.GetNumberOfEncodedFaces();return f.destroy(l),f.destroy(u),f.destroy(a),f.destroy(i),{numVertices:E,numIndices:N,data:m,attributeIDs:c}}function C(e){return"POSITION"===e?g.POSITION:"NORMAL"===e?g.NORMAL:e.startsWith("COLOR_")?g.COLOR:e.startsWith("TEXCOORD_")?g.TEX_COORD:g.GENERIC}var E,R=((p={})[e.Accessor.ComponentType.UNSIGNED_BYTE]="AddUInt8Attribute",p[e.Accessor.ComponentType.BYTE]="AddInt8Attribute",p[e.Accessor.ComponentType.UNSIGNED_SHORT]="AddUInt16Attribute",p[e.Accessor.ComponentType.SHORT]="AddInt16Attribute",p[e.Accessor.ComponentType.UNSIGNED_INT]="AddUInt32Attribute",p[e.Accessor.ComponentType.FLOAT]="AddFloatAttribute",p),N="KHR_draco_mesh_compression",S=function(t){function n(){var r;return(r=t.apply(this,arguments)||this).extensionName=N,r.prereadTypes=[e.PropertyType.PRIMITIVE],r.prewriteTypes=[e.PropertyType.ACCESSOR],r.dependencies=["draco3d.decoder","draco3d.encoder"],r._encoderOptions={},r}r(n,t);var o=n.prototype;return o.install=function(e,t){var r,n;return"draco3d.decoder"===e&&(this._decoderModule=t,u=this._decoderModule,(r={})[5126]=Float32Array,r[5125]=Uint32Array,r[5123]=Uint16Array,r[5121]=Uint8Array,r[5122]=Int16Array,r[5120]=Int8Array,c=r,(n={})[5126]=u.DT_FLOAT32,n[5125]=u.DT_UINT32,n[5123]=u.DT_UINT16,n[5121]=u.DT_UINT8,n[5122]=u.DT_INT16,n[5120]=u.DT_INT8,l=n),"draco3d.encoder"===e&&(this._encoderModule=t,f=this._encoderModule),this},o.setEncoderOptions=function(e){return this._encoderOptions=e,this},o.preread=function(t){if(!this._decoderModule)throw new Error("["+N+'] Please install extension dependency, "draco3d.decoder".');var r=this.doc.getLogger(),n=t.jsonDoc,o=new Map;try{for(var i,a=s(n.json.meshes);!(i=a()).done;)for(var u,c=s(i.value.primitives);!(u=c()).done;){var l=u.value;if(l.extensions&&l.extensions[N]){var h=l.extensions[N],p=o.get(h.bufferView)||[],f=p[0],x=p[1];if(!x){var g=n.json.bufferViews[h.bufferView],T=n.json.buffers[g.buffer],y=new Int8Array(T.uri?n.resources[T.uri]:n.resources[e.GLB_BUFFER],g.byteOffset||0,g.byteLength);x=d(f=new this._decoderModule.Decoder,y),o.set(h.bufferView,[f,x]),r.debug("["+N+"] Decompressed "+y.byteLength+" bytes.")}for(var _ in l.attributes){var I=t.jsonDoc.json.accessors[l.attributes[_]],C=f.GetAttributeByUniqueId(x,h.attributes[_]),E=m(f,x,C,I);t.accessors[l.attributes[_]].setArray(E)}var R=v(f,x);t.accessors[l.indices].setArray(R)}}}finally{for(var S=0,A=Array.from(o.values());S<A.length;S++){var F=A[S],M=F[1];this._decoderModule.destroy(F[0]),this._decoderModule.destroy(M)}}return this},o.read=function(e){return this},o.prewrite=function(e,t){if(!this._encoderModule)throw new Error("["+N+'] Please install extension dependency, "draco3d.encoder".');var r=this.doc.getLogger();r.debug("["+N+"] Compression options: "+JSON.stringify(this._encoderOptions));for(var n=function(e){for(var t,r=e.getLogger(),n=new Set,o=new Set,i=s(e.getRoot().listMeshes());!(t=i()).done;)for(var a,u=s(t.value.listPrimitives());!(a=u()).done;){var c=a.value;c.getIndices()?4!==c.getMode()?(o.add(c),r.warn("["+N+"] Skipping Draco compression on non-TRIANGLES primitive.")):n.add(c):(o.add(c),r.warn("["+N+"] Skipping Draco compression on non-indexed primitive."))}for(var l=e.getRoot().listAccessors(),h=new Map,p=0;p<l.length;p++)h.set(l[p],p);for(var f=new Map,x=new Map,g=0,T=Array.from(n);g<T.length;g++){var d=T[g],v=[];v.push(h.get(d.getIndices()));for(var m,y=s(d.listAttributes());!(m=y()).done;)v.push(h.get(m.value));var _=v.sort().join("|");x.set(d,_),f.set(d.getIndices(),_);for(var I,C=s(d.listAttributes());!(I=C()).done;)f.set(I.value,_)}for(var E=0,R=Array.from(f.keys());E<R.length;E++){var S=new Set(R[E].listParents().map(function(e){return e.propertyType}));if(2!==S.size||!S.has("Primitive")||!S.has("Root"))throw new Error("["+N+"] Compressed accessors must only be used as indices or vertex attributes.")}for(var A=function(){var e=M[F],t=x.get(e);if(f.get(e.getIndices())!==t||e.listAttributes().some(function(e){return f.get(e)!==t}))throw new Error("["+N+"] Draco primitives must share all, or no, accessors.")},F=0,M=Array.from(n);F<M.length;F++)A();for(var O=0,D=Array.from(o);O<D.length;O++){var G=D[O];if(f.has(G.getIndices())||G.listAttributes().some(function(e){return f.has(e)}))throw new Error("["+N+"] Accessor cannot be shared by compressed and uncompressed primitives.")}return x}(this.doc),o=new Map,i=0,a=Array.from(n.keys());i<a.length;i++){var u=a[i],c=n.get(u);if(o.has(c))o.set(c,o.get(c));else{var l=I(u,this._encoderOptions);o.set(c,l);var h=e.createAccessorDef(u.getIndices());h.count=l.numIndices,e.accessorIndexMap.set(u.getIndices(),e.jsonDoc.json.accessors.length),e.jsonDoc.json.accessors.push(h);for(var p,f=s(u.listSemantics());!(p=f()).done;){var x=u.getAttribute(p.value),g=e.createAccessorDef(x);g.count=l.numVertices,e.accessorIndexMap.set(x,e.jsonDoc.json.accessors.length),e.jsonDoc.json.accessors.push(g)}var T=u.getAttribute("POSITION").getBuffer()||this.doc.getRoot().listBuffers()[0];e.otherBufferViews.has(T)||e.otherBufferViews.set(T,[]),e.otherBufferViews.get(T).push(l.data)}}return r.debug("["+N+"] Compressed "+n.size+" primitives."),e.extensionData[N]={primitiveHashMap:n,primitiveEncodingMap:o},this},o.write=function(e){for(var t,r=e.extensionData[N],n=s(this.doc.getRoot().listMeshes());!(t=n()).done;)for(var o=t.value,i=e.jsonDoc.json.meshes[e.meshIndexMap.get(o)],a=0;a<o.listPrimitives().length;a++){var u=o.listPrimitives()[a],c=i.primitives[a],l=r.primitiveHashMap.get(u);if(l){var h=r.primitiveEncodingMap.get(l);c.extensions=c.extensions||{},c.extensions[N]={bufferView:e.otherBufferViewsIndexMap.get(h.data),attributes:h.attributeIDs}}}return this},n}(e.Extension);S.EXTENSION_NAME=N,S.EncoderMethod=x,(E=exports.LightType||(exports.LightType={})).POINT="point",E.SPOT="spot",E.DIRECTIONAL="directional";var A=function(t){function n(){var r;return(r=t.apply(this,arguments)||this).propertyType="Light",r.parentTypes=[e.PropertyType.NODE],r.extensionName="KHR_lights_punctual",r._color=[1,1,1],r._intensity=1,r._range=void 0,r._innerConeAngle=0,r._outerConeAngle=Math.PI/4,r}r(n,t);var o=n.prototype;return o.copy=function(r,n){return void 0===n&&(n=e.COPY_IDENTITY),t.prototype.copy.call(this,r,n),this._color=[].concat(r._color),this._intensity=r._intensity,this._type=r._type,this._range=r._range,this._innerConeAngle=r._innerConeAngle,this._outerConeAngle=r._outerConeAngle,this},o.getColor=function(){return this._color},o.setColor=function(e){return this._color=e,this},o.getColorHex=function(){return e.ColorUtils.factorToHex(this._color)},o.setColorHex=function(t){return e.ColorUtils.hexToFactor(t,this._color),this},o.getIntensity=function(){return this._intensity},o.setIntensity=function(e){return this._intensity=e,this},o.getType=function(){return this._type},o.setType=function(e){return this._type=e,this},o.getRange=function(){return this._range},o.setRange=function(e){return this._range=e,this},o.getInnerConeAngle=function(){return this._innerConeAngle},o.setInnerConeAngle=function(e){return this._innerConeAngle=e,this},o.getOuterConeAngle=function(){return this._outerConeAngle},o.setOuterConeAngle=function(e){return this._outerConeAngle=e,this},n}(e.ExtensionProperty);A.EXTENSION_NAME="KHR_lights_punctual";var F="KHR_lights_punctual",M=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=F,t}r(t,e);var n=t.prototype;return n.createLight=function(){return new A(this.doc.getGraph(),this)},n.read=function(e){var t=this,r=e.jsonDoc;if(!r.json.extensions||!r.json.extensions[F])return this;var n=(r.json.extensions[F].lights||[]).map(function(e){var r=t.createLight().setName(e.name||"").setType(e.type);return void 0!==e.color&&r.setColor(e.color),void 0!==e.intensity&&r.setIntensity(e.intensity),void 0!==e.range&&r.setRange(e.range),void 0!==e.innerConeAngle&&r.setInnerConeAngle(e.innerConeAngle),void 0!==e.outerConeAngle&&r.setOuterConeAngle(e.outerConeAngle),r});return r.json.nodes.forEach(function(t,r){t.extensions&&t.extensions[F]&&e.nodes[r].setExtension(F,n[t.extensions[F].light])}),this},n.write=function(e){var t=e.jsonDoc;if(0===this.properties.size)return this;for(var r,n=[],o=new Map,i=s(this.properties);!(r=i()).done;){var a=r.value,u={type:a.getType(),color:a.getColor(),intensity:a.getIntensity(),range:a.getRange()};a.getName()&&(u.name=a.getName()),a.getType()===exports.LightType.SPOT&&(u.innerConeAngle=a.getInnerConeAngle(),u.outerConeAngle=a.getOuterConeAngle()),n.push(u),o.set(a,n.length-1)}return this.doc.getRoot().listNodes().forEach(function(r){var n=r.getExtension(F);if(n){var s=e.nodeIndexMap.get(r),i=t.json.nodes[s];i.extensions=i.extensions||{},i.extensions[F]={light:o.get(n)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[F]={lights:n},this},t}(e.Extension);function O(e,t,r,n){var o,s=arguments.length,i=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(i=(s<3?o(i):s>3?o(t,r,i):o(t,r))||i);return s>3&&i&&Object.defineProperty(t,r,i),i}M.EXTENSION_NAME=F;var D=function(t){function o(){var r;return(r=t.apply(this,arguments)||this).propertyType="Clearcoat",r.parentTypes=[e.PropertyType.MATERIAL],r.extensionName="KHR_materials_clearcoat",r._clearcoatFactor=0,r._clearcoatRoughnessFactor=0,r._clearcoatNormalScale=1,r.clearcoatTexture=null,r.clearcoatTextureInfo=r.graph.link("clearcoatTextureInfo",n(r),new e.TextureInfo(r.graph)),r.clearcoatRoughnessTexture=null,r.clearcoatRoughnessTextureInfo=r.graph.link("clearcoatRoughnessTextureInfo",n(r),new e.TextureInfo(r.graph)),r.clearcoatNormalTexture=null,r.clearcoatNormalTextureInfo=r.graph.link("clearcoatNormalTextureInfo",n(r),new e.TextureInfo(r.graph)),r}r(o,t);var s=o.prototype;return s.copy=function(r,n){return void 0===n&&(n=e.COPY_IDENTITY),t.prototype.copy.call(this,r,n),this._clearcoatFactor=r._clearcoatFactor,this._clearcoatRoughnessFactor=r._clearcoatRoughnessFactor,this._clearcoatNormalScale=r._clearcoatNormalScale,r.clearcoatTexture&&(this.setClearcoatTexture(n(r.clearcoatTexture.getChild())),this.getClearcoatTextureInfo().copy(n(r.clearcoatTextureInfo.getChild()),n)),r.clearcoatRoughnessTexture&&(this.setClearcoatRoughnessTexture(n(r.clearcoatRoughnessTexture.getChild())),this.getClearcoatRoughnessTextureInfo().copy(n(r.clearcoatRoughnessTextureInfo.getChild()),n)),r.clearcoatNormalTexture&&(this.setClearcoatNormalTexture(n(r.clearcoatNormalTexture.getChild())),this.getClearcoatNormalTextureInfo().copy(n(r.clearcoatNormalTextureInfo.getChild()),n)),this},s.dispose=function(){this.clearcoatTextureInfo.getChild().dispose(),this.clearcoatRoughnessTextureInfo.getChild().dispose(),this.clearcoatNormalTextureInfo.getChild().dispose(),t.prototype.dispose.call(this)},s.getClearcoatFactor=function(){return this._clearcoatFactor},s.setClearcoatFactor=function(e){return this._clearcoatFactor=e,this},s.getClearcoatTexture=function(){return this.clearcoatTexture?this.clearcoatTexture.getChild():null},s.getClearcoatTextureInfo=function(){return this.clearcoatTexture?this.clearcoatTextureInfo.getChild():null},s.setClearcoatTexture=function(e){return this.clearcoatTexture=this.graph.link("clearcoatTexture",this,e),this},s.getClearcoatRoughnessFactor=function(){return this._clearcoatRoughnessFactor},s.setClearcoatRoughnessFactor=function(e){return this._clearcoatRoughnessFactor=e,this},s.getClearcoatRoughnessTexture=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.getChild():null},s.getClearcoatRoughnessTextureInfo=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTextureInfo.getChild():null},s.setClearcoatRoughnessTexture=function(e){return this.clearcoatRoughnessTexture=this.graph.link("clearcoatRoughnessTexture",this,e),this},s.getClearcoatNormalScale=function(){return this._clearcoatNormalScale},s.setClearcoatNormalScale=function(e){return this._clearcoatNormalScale=e,this},s.getClearcoatNormalTexture=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTexture.getChild():null},s.getClearcoatNormalTextureInfo=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTextureInfo.getChild():null},s.setClearcoatNormalTexture=function(e){return this.clearcoatNormalTexture=this.graph.link("clearcoatNormalTexture",this,e),this},o}(e.ExtensionProperty);D.EXTENSION_NAME="KHR_materials_clearcoat",O([e.GraphChild],D.prototype,"clearcoatTexture",void 0),O([e.GraphChild],D.prototype,"clearcoatTextureInfo",void 0),O([e.GraphChild],D.prototype,"clearcoatRoughnessTexture",void 0),O([e.GraphChild],D.prototype,"clearcoatRoughnessTextureInfo",void 0),O([e.GraphChild],D.prototype,"clearcoatNormalTexture",void 0),O([e.GraphChild],D.prototype,"clearcoatNormalTextureInfo",void 0);var G="KHR_materials_clearcoat",w=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=G,t}r(t,e);var n=t.prototype;return n.createClearcoat=function(){return new D(this.doc.getGraph(),this)},n.read=function(e){var t=this,r=e.jsonDoc,n=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,o){if(r.extensions&&r.extensions[G]){var s=t.createClearcoat();if(e.materials[o].setExtension(G,s),void 0!==r.extensions[G].clearcoatFactor&&s.setClearcoatFactor(r.extensions[G].clearcoatFactor),void 0!==r.extensions[G].clearcoatRoughnessFactor&&s.setClearcoatRoughnessFactor(r.extensions[G].clearcoatRoughnessFactor),void 0!==r.extensions[G].clearcoatTexture){var i=r.extensions[G].clearcoatTexture;s.setClearcoatTexture(e.textures[n[i.index].source]),e.setTextureInfo(s.getClearcoatTextureInfo(),i)}if(void 0!==r.extensions[G].clearcoatRoughnessTexture){var a=r.extensions[G].clearcoatRoughnessTexture;s.setClearcoatRoughnessTexture(e.textures[n[a.index].source]),e.setTextureInfo(s.getClearcoatRoughnessTextureInfo(),a)}if(void 0!==r.extensions[G].clearcoatNormalTexture){var u=r.extensions[G].clearcoatNormalTexture;s.setClearcoatNormalTexture(e.textures[n[u.index].source]),e.setTextureInfo(s.getClearcoatNormalTextureInfo(),u),void 0!==u.scale&&s.setClearcoatNormalScale(u.scale)}}}),this},n.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var n=r.getExtension(G);if(n){var o=e.materialIndexMap.get(r),s=t.json.materials[o];if(s.extensions=s.extensions||{},s.extensions[G]={clearcoatFactor:n.getClearcoatFactor(),clearcoatRoughnessFactor:n.getClearcoatRoughnessFactor()},n.getClearcoatTexture()){var i=n.getClearcoatTexture(),a=n.getClearcoatTextureInfo();s.extensions[G].clearcoatTexture=e.createTextureInfoDef(i,a)}if(n.getClearcoatRoughnessTexture()){var u=n.getClearcoatRoughnessTexture(),c=n.getClearcoatRoughnessTextureInfo();s.extensions[G].clearcoatRoughnessTexture=e.createTextureInfoDef(u,c)}if(n.getClearcoatNormalTexture()){var l=n.getClearcoatNormalTexture(),h=n.getClearcoatNormalTextureInfo();s.extensions[G].clearcoatNormalTexture=e.createTextureInfoDef(l,h),1!==n.getClearcoatNormalScale()&&(s.extensions[G].clearcoatNormalTexture.scale=n.getClearcoatNormalScale())}}}),this},t}(e.Extension);w.EXTENSION_NAME=G;var j=function(t){function n(){var r;return(r=t.apply(this,arguments)||this).propertyType="IOR",r.parentTypes=[e.PropertyType.MATERIAL],r.extensionName="KHR_materials_ior",r._ior=0,r}r(n,t);var o=n.prototype;return o.copy=function(r,n){return void 0===n&&(n=e.COPY_IDENTITY),t.prototype.copy.call(this,r,n),this._ior=r._ior,this},o.getIOR=function(){return this._ior},o.setIOR=function(e){return this._ior=e,this},n}(e.ExtensionProperty);j.EXTENSION_NAME="KHR_materials_ior";var P="KHR_materials_ior",b=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=P,t}r(t,e);var n=t.prototype;return n.createIOR=function(){return new j(this.doc.getGraph(),this)},n.read=function(e){var t=this;return(e.jsonDoc.json.materials||[]).forEach(function(r,n){if(r.extensions&&r.extensions[P]){var o=t.createIOR();e.materials[n].setExtension(P,o),void 0!==r.extensions[P].ior&&o.setIOR(r.extensions[P].ior)}}),this},n.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var n=r.getExtension(P);if(n){var o=e.materialIndexMap.get(r),s=t.json.materials[o];s.extensions=s.extensions||{},s.extensions[P]={ior:n.getIOR()}}}),this},t}(e.Extension);b.EXTENSION_NAME=P;var H=function(t){function o(){var r;return(r=t.apply(this,arguments)||this).propertyType="PBRSpecularGlossiness",r.parentTypes=[e.PropertyType.MATERIAL],r.extensionName="KHR_materials_pbrSpecularGlossiness",r._diffuseFactor=[1,1,1,1],r._specularFactor=[1,1,1],r._glossinessFactor=1,r.diffuseTexture=null,r.diffuseTextureInfo=r.graph.link("diffuseTextureInfo",n(r),new e.TextureInfo(r.graph)),r.specularGlossinessTexture=null,r.specularGlossinessTextureInfo=r.graph.link("specularGlossinessTextureInfo",n(r),new e.TextureInfo(r.graph)),r}r(o,t);var s=o.prototype;return s.copy=function(r,n){return void 0===n&&(n=e.COPY_IDENTITY),t.prototype.copy.call(this,r,n),this._diffuseFactor=r._diffuseFactor,this._specularFactor=r._specularFactor,this._glossinessFactor=r._glossinessFactor,r.diffuseTexture&&(this.setDiffuseTexture(n(r.diffuseTexture.getChild())),this.getDiffuseTextureInfo().copy(n(r.diffuseTextureInfo.getChild()),n)),r.specularGlossinessTexture&&(this.setSpecularGlossinessTexture(n(r.specularGlossinessTexture.getChild())),this.getSpecularGlossinessTextureInfo().copy(n(r.specularGlossinessTextureInfo.getChild()),n)),this},s.dispose=function(){this.diffuseTextureInfo.getChild().dispose(),this.specularGlossinessTextureInfo.getChild().dispose(),t.prototype.dispose.call(this)},s.getDiffuseFactor=function(){return this._diffuseFactor},s.setDiffuseFactor=function(e){return this._diffuseFactor=e,this},s.getDiffuseHex=function(){return e.ColorUtils.factorToHex(this._diffuseFactor)},s.setDiffuseHex=function(t){return e.ColorUtils.hexToFactor(t,this._diffuseFactor),this},s.getDiffuseTexture=function(){return this.diffuseTexture?this.diffuseTexture.getChild():null},s.getDiffuseTextureInfo=function(){return this.diffuseTexture?this.diffuseTextureInfo.getChild():null},s.setDiffuseTexture=function(e){return this.diffuseTexture=this.graph.link("diffuseTexture",this,e),this},s.getSpecularFactor=function(){return this._specularFactor},s.setSpecularFactor=function(e){return this._specularFactor=e,this},s.getGlossinessFactor=function(){return this._glossinessFactor},s.setGlossinessFactor=function(e){return this._glossinessFactor=e,this},s.getSpecularGlossinessTexture=function(){return this.specularGlossinessTexture?this.specularGlossinessTexture.getChild():null},s.getSpecularGlossinessTextureInfo=function(){return this.specularGlossinessTexture?this.specularGlossinessTextureInfo.getChild():null},s.setSpecularGlossinessTexture=function(e){return this.specularGlossinessTexture=this.graph.link("specularGlossinessTexture",this,e),this},o}(e.ExtensionProperty);H.EXTENSION_NAME="KHR_materials_pbrSpecularGlossiness",O([e.GraphChild],H.prototype,"diffuseTexture",void 0),O([e.GraphChild],H.prototype,"diffuseTextureInfo",void 0),O([e.GraphChild],H.prototype,"specularGlossinessTexture",void 0),O([e.GraphChild],H.prototype,"specularGlossinessTextureInfo",void 0);var L="KHR_materials_pbrSpecularGlossiness",K=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=L,t}r(t,e);var n=t.prototype;return n.createPBRSpecularGlossiness=function(){return new H(this.doc.getGraph(),this)},n.read=function(e){var t=this,r=e.jsonDoc,n=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,o){if(r.extensions&&r.extensions[L]){var s=t.createPBRSpecularGlossiness();if(e.materials[o].setExtension(L,s),void 0!==r.extensions[L].diffuseFactor&&s.setDiffuseFactor(r.extensions[L].diffuseFactor),void 0!==r.extensions[L].specularFactor&&s.setSpecularFactor(r.extensions[L].specularFactor),void 0!==r.extensions[L].glossinessFactor&&s.setGlossinessFactor(r.extensions[L].glossinessFactor),void 0!==r.extensions[L].diffuseTexture){var i=r.extensions[L].diffuseTexture;s.setDiffuseTexture(e.textures[n[i.index].source]),e.setTextureInfo(s.getDiffuseTextureInfo(),i)}if(void 0!==r.extensions[L].specularGlossinessTexture){var a=r.extensions[L].specularGlossinessTexture;s.setSpecularGlossinessTexture(e.textures[n[a.index].source]),e.setTextureInfo(s.getSpecularGlossinessTextureInfo(),a)}}}),this},n.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var n=r.getExtension(L);if(n){var o=e.materialIndexMap.get(r),s=t.json.materials[o];if(s.extensions=s.extensions||{},s.extensions[L]={diffuseFactor:n.getDiffuseFactor(),specularFactor:n.getSpecularFactor(),glossinessFactor:n.getGlossinessFactor()},n.getDiffuseTexture()){var i=n.getDiffuseTexture(),a=n.getDiffuseTextureInfo();s.extensions[L].diffuseTexture=e.createTextureInfoDef(i,a)}if(n.getSpecularGlossinessTexture()){var u=n.getSpecularGlossinessTexture(),c=n.getSpecularGlossinessTextureInfo();s.extensions[L].specularGlossinessTexture=e.createTextureInfoDef(u,c)}}}),this},t}(e.Extension);K.EXTENSION_NAME=L;var U=function(t){function o(){var r;return(r=t.apply(this,arguments)||this).propertyType="Sheen",r.parentTypes=[e.PropertyType.MATERIAL],r.extensionName="KHR_materials_sheen",r._sheenColorFactor=[0,0,0],r._sheenRoughnessFactor=0,r.sheenColorTexture=null,r.sheenColorTextureInfo=r.graph.link("sheenColorTextureInfo",n(r),new e.TextureInfo(r.graph)),r.sheenRoughnessTexture=null,r.sheenRoughnessTextureInfo=r.graph.link("sheenRoughnessTextureInfo",n(r),new e.TextureInfo(r.graph)),r}r(o,t);var s=o.prototype;return s.copy=function(r,n){return void 0===n&&(n=e.COPY_IDENTITY),t.prototype.copy.call(this,r,n),this._sheenColorFactor=r._sheenColorFactor,this._sheenRoughnessFactor=r._sheenRoughnessFactor,r.sheenColorTexture&&(this.setSheenColorTexture(n(r.sheenColorTexture.getChild())),this.getSheenColorTextureInfo().copy(n(r.sheenColorTextureInfo.getChild()),n)),r.sheenRoughnessTexture&&(this.setSheenRoughnessTexture(n(r.sheenRoughnessTexture.getChild())),this.getSheenRoughnessTextureInfo().copy(n(r.sheenRoughnessTextureInfo.getChild()),n)),this},s.dispose=function(){this.sheenColorTextureInfo.getChild().dispose(),this.sheenRoughnessTextureInfo.getChild().dispose(),t.prototype.dispose.call(this)},s.getSheenColorFactor=function(){return this._sheenColorFactor},s.getSheenColorHex=function(){return e.ColorUtils.factorToHex(this._sheenColorFactor)},s.setSheenColorFactor=function(e){return this._sheenColorFactor=e,this},s.setSheenColorHex=function(t){return e.ColorUtils.hexToFactor(t,this._sheenColorFactor),this},s.getSheenColorTexture=function(){return this.sheenColorTexture?this.sheenColorTexture.getChild():null},s.getSheenColorTextureInfo=function(){return this.sheenColorTexture?this.sheenColorTextureInfo.getChild():null},s.setSheenColorTexture=function(e){return this.sheenColorTexture=this.graph.link("sheenColorTexture",this,e),this},s.getSheenRoughnessFactor=function(){return this._sheenRoughnessFactor},s.setSheenRoughnessFactor=function(e){return this._sheenRoughnessFactor=e,this},s.getSheenRoughnessTexture=function(){return this.sheenRoughnessTexture?this.sheenRoughnessTexture.getChild():null},s.getSheenRoughnessTextureInfo=function(){return this.sheenRoughnessTexture?this.sheenRoughnessTextureInfo.getChild():null},s.setSheenRoughnessTexture=function(e){return this.sheenRoughnessTexture=this.graph.link("sheenRoughnessTexture",this,e),this},o}(e.ExtensionProperty);U.EXTENSION_NAME="KHR_materials_sheen",O([e.GraphChild],U.prototype,"sheenColorTexture",void 0),O([e.GraphChild],U.prototype,"sheenColorTextureInfo",void 0),O([e.GraphChild],U.prototype,"sheenRoughnessTexture",void 0),O([e.GraphChild],U.prototype,"sheenRoughnessTextureInfo",void 0);var X="KHR_materials_sheen",B=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=X,t}r(t,e);var n=t.prototype;return n.createSheen=function(){return new U(this.doc.getGraph(),this)},n.read=function(e){var t=this,r=e.jsonDoc,n=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,o){if(r.extensions&&r.extensions[X]){var s=t.createSheen();if(e.materials[o].setExtension(X,s),void 0!==r.extensions[X].sheenColorFactor&&s.setSheenColorFactor(r.extensions[X].sheenColorFactor),void 0!==r.extensions[X].sheenRoughnessFactor&&s.setSheenRoughnessFactor(r.extensions[X].sheenRoughnessFactor),void 0!==r.extensions[X].sheenColorTexture){var i=r.extensions[X].sheenColorTexture;s.setSheenColorTexture(e.textures[n[i.index].source]),e.setTextureInfo(s.getSheenColorTextureInfo(),i)}if(void 0!==r.extensions[X].sheenRoughnessTexture){var a=r.extensions[X].sheenRoughnessTexture;s.setSheenRoughnessTexture(e.textures[n[a.index].source]),e.setTextureInfo(s.getSheenRoughnessTextureInfo(),a)}}}),this},n.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var n=r.getExtension(X);if(n){var o=e.materialIndexMap.get(r),s=t.json.materials[o];if(s.extensions=s.extensions||{},s.extensions[X]={sheenColorFactor:n.getSheenColorFactor(),sheenRoughnessFactor:n.getSheenRoughnessFactor()},n.getSheenColorTexture()){var i=n.getSheenColorTexture(),a=n.getSheenColorTextureInfo();s.extensions[X].sheenColorTexture=e.createTextureInfoDef(i,a)}if(n.getSheenRoughnessTexture()){var u=n.getSheenRoughnessTexture(),c=n.getSheenRoughnessTextureInfo();s.extensions[X].sheenRoughnessTexture=e.createTextureInfoDef(u,c)}}}),this},t}(e.Extension);B.EXTENSION_NAME=X;var k=function(t){function o(){var r;return(r=t.apply(this,arguments)||this).propertyType="Specular",r.parentTypes=[e.PropertyType.MATERIAL],r.extensionName="KHR_materials_specular",r._specularFactor=1,r._specularColorFactor=[1,1,1],r.specularTexture=null,r.specularTextureInfo=r.graph.link("specularTextureInfo",n(r),new e.TextureInfo(r.graph)),r}r(o,t);var s=o.prototype;return s.copy=function(r,n){return void 0===n&&(n=e.COPY_IDENTITY),t.prototype.copy.call(this,r,n),this._specularFactor=r._specularFactor,r.specularTexture&&(this.setSpecularTexture(n(r.specularTexture.getChild())),this.getSpecularTextureInfo().copy(n(r.specularTextureInfo.getChild()),n)),this},s.dispose=function(){this.specularTextureInfo.getChild().dispose(),t.prototype.dispose.call(this)},s.getSpecularFactor=function(){return this._specularFactor},s.setSpecularFactor=function(e){return this._specularFactor=e,this},s.getSpecularColorFactor=function(){return this._specularColorFactor},s.setSpecularColorFactor=function(e){return this._specularColorFactor=e,this},s.getSpecularColorHex=function(){return e.ColorUtils.factorToHex(this._specularColorFactor)},s.setSpecularColorHex=function(t){return e.ColorUtils.hexToFactor(t,this._specularColorFactor),this},s.getSpecularTexture=function(){return this.specularTexture?this.specularTexture.getChild():null},s.getSpecularTextureInfo=function(){return this.specularTexture?this.specularTextureInfo.getChild():null},s.setSpecularTexture=function(e){return this.specularTexture=this.graph.link("specularTexture",this,e),this},o}(e.ExtensionProperty);k.EXTENSION_NAME="KHR_materials_specular",O([e.GraphChild],k.prototype,"specularTexture",void 0),O([e.GraphChild],k.prototype,"specularTextureInfo",void 0);var V="KHR_materials_specular",Y=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=V,t}r(t,e);var n=t.prototype;return n.createSpecular=function(){return new k(this.doc.getGraph(),this)},n.read=function(e){var t=this,r=e.jsonDoc,n=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,o){if(r.extensions&&r.extensions[V]){var s=t.createSpecular();if(e.materials[o].setExtension(V,s),void 0!==r.extensions[V].specularFactor&&s.setSpecularFactor(r.extensions[V].specularFactor),void 0!==r.extensions[V].specularColorFactor&&s.setSpecularColorFactor(r.extensions[V].specularColorFactor),void 0!==r.extensions[V].specularTexture){var i=r.extensions[V].specularTexture;s.setSpecularTexture(e.textures[n[i.index].source]),e.setTextureInfo(s.getSpecularTextureInfo(),i)}}}),this},n.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var n=r.getExtension(V);if(n){var o=e.materialIndexMap.get(r),s=t.json.materials[o];if(s.extensions=s.extensions||{},s.extensions[V]={specularFactor:n.getSpecularFactor(),specularColorFactor:n.getSpecularColorFactor()},n.getSpecularTexture()){var i=n.getSpecularTexture(),a=n.getSpecularTextureInfo();s.extensions[V].specularTexture=e.createTextureInfoDef(i,a)}}}),this},t}(e.Extension);Y.EXTENSION_NAME=V;var z=function(t){function o(){var r;return(r=t.apply(this,arguments)||this).propertyType="Transmission",r.parentTypes=[e.PropertyType.MATERIAL],r.extensionName="KHR_materials_transmission",r._transmissionFactor=0,r.transmissionTexture=null,r.transmissionTextureInfo=r.graph.link("transmissionTextureInfo",n(r),new e.TextureInfo(r.graph)),r}r(o,t);var s=o.prototype;return s.copy=function(r,n){return void 0===n&&(n=e.COPY_IDENTITY),t.prototype.copy.call(this,r,n),this._transmissionFactor=r._transmissionFactor,r.transmissionTexture&&(this.setTransmissionTexture(n(r.transmissionTexture.getChild())),this.getTransmissionTextureInfo().copy(n(r.transmissionTextureInfo.getChild()),n)),this},s.dispose=function(){this.transmissionTextureInfo.getChild().dispose(),t.prototype.dispose.call(this)},s.getTransmissionFactor=function(){return this._transmissionFactor},s.setTransmissionFactor=function(e){return this._transmissionFactor=e,this},s.getTransmissionTexture=function(){return this.transmissionTexture?this.transmissionTexture.getChild():null},s.getTransmissionTextureInfo=function(){return this.transmissionTexture?this.transmissionTextureInfo.getChild():null},s.setTransmissionTexture=function(e){return this.transmissionTexture=this.graph.link("transmissionTexture",this,e),this},o}(e.ExtensionProperty);z.EXTENSION_NAME="KHR_materials_transmission",O([e.GraphChild],z.prototype,"transmissionTexture",void 0),O([e.GraphChild],z.prototype,"transmissionTextureInfo",void 0);var q="KHR_materials_transmission",Q=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=q,t}r(t,e);var n=t.prototype;return n.createTransmission=function(){return new z(this.doc.getGraph(),this)},n.read=function(e){var t=this,r=e.jsonDoc,n=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,o){if(r.extensions&&r.extensions[q]){var s=t.createTransmission();if(e.materials[o].setExtension(q,s),void 0!==r.extensions[q].transmissionFactor&&s.setTransmissionFactor(r.extensions[q].transmissionFactor),void 0!==r.extensions[q].transmissionTexture){var i=r.extensions[q].transmissionTexture;s.setTransmissionTexture(e.textures[n[i.index].source]),e.setTextureInfo(s.getTransmissionTextureInfo(),i)}}}),this},n.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var n=r.getExtension(q);if(n){var o=e.materialIndexMap.get(r),s=t.json.materials[o];if(s.extensions=s.extensions||{},s.extensions[q]={transmissionFactor:n.getTransmissionFactor()},n.getTransmissionTexture()){var i=n.getTransmissionTexture(),a=n.getTransmissionTextureInfo();s.extensions[q].transmissionTexture=e.createTextureInfoDef(i,a)}}}),this},t}(e.Extension);Q.EXTENSION_NAME=q;var W=function(t){function n(){var r;return(r=t.apply(this,arguments)||this).propertyType="Unlit",r.parentTypes=[e.PropertyType.MATERIAL],r.extensionName="KHR_materials_unlit",r}return r(n,t),n}(e.ExtensionProperty);W.EXTENSION_NAME="KHR_materials_unlit";var J="KHR_materials_unlit",$=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=J,t}r(t,e);var n=t.prototype;return n.createUnlit=function(){return new W(this.doc.getGraph(),this)},n.read=function(e){var t=this;return(e.jsonDoc.json.materials||[]).forEach(function(r,n){r.extensions&&r.extensions[J]&&e.materials[n].setExtension(J,t.createUnlit())}),this},n.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){if(r.getExtension(J)){var n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{},o.extensions[J]={}}}),this},t}(e.Extension);$.EXTENSION_NAME=J;var Z=function(t){function n(){var e;return(e=t.apply(this,arguments)||this).propertyType="Mapping",e.parentTypes=["MappingList"],e.extensionName="KHR_materials_variants",e.material=null,e.variants=[],e}r(n,t);var o=n.prototype;return o.copy=function(r,n){var o=this;return void 0===n&&(n=e.COPY_IDENTITY),t.prototype.copy.call(this,r,n),r.material&&this.setMaterial(n(r.material.getChild())),this.clearGraphChildList(this.variants),r.variants.forEach(function(e){return o.addVariant(n(e.getChild()))}),this},o.getMaterial=function(){return this.material?this.material.getChild():null},o.setMaterial=function(e){return this.material=this.graph.link("material",this,e),this},o.addVariant=function(e){var t=this.graph.link("variant",this,e);return this.addGraphChild(this.variants,t)},o.removeVariant=function(e){return this.removeGraphChild(this.variants,e)},o.listVariants=function(){return this.variants.map(function(e){return e.getChild()})},n}(e.ExtensionProperty);Z.EXTENSION_NAME="KHR_materials_variants",O([e.GraphChild],Z.prototype,"material",void 0),O([e.GraphChildList],Z.prototype,"variants",void 0);var ee=function(t){function n(){var r;return(r=t.apply(this,arguments)||this).propertyType="MappingList",r.parentTypes=[e.PropertyType.PRIMITIVE],r.extensionName="KHR_materials_variants",r.mappings=[],r}r(n,t);var o=n.prototype;return o.copy=function(r,n){var o=this;return void 0===n&&(n=e.COPY_IDENTITY),t.prototype.copy.call(this,r,n),this.clearGraphChildList(this.mappings),r.mappings.forEach(function(e){return o.addMapping(n(e.getChild()))}),this},o.addMapping=function(e){var t=this.graph.link("mapping",this,e);return this.addGraphChild(this.mappings,t)},o.removeMapping=function(e){return this.removeGraphChild(this.mappings,e)},o.listMappings=function(){return this.mappings.map(function(e){return e.getChild()})},n}(e.ExtensionProperty);ee.EXTENSION_NAME="KHR_materials_variants",O([e.GraphChildList],ee.prototype,"mappings",void 0);var te=function(t){function n(){var r;return(r=t.apply(this,arguments)||this).propertyType="Variant",r.parentTypes=[e.PropertyType.ROOT,"MappingList"],r.extensionName="KHR_materials_variants",r}return r(n,t),n}(e.ExtensionProperty);te.EXTENSION_NAME="KHR_materials_variants";var re="KHR_materials_variants",ne=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=re,t}r(t,e);var n=t.prototype;return n.createMappingList=function(){return new ee(this.doc.getGraph(),this)},n.createVariant=function(e){return void 0===e&&(e=""),new te(this.doc.getGraph(),this).setName(e)},n.createMapping=function(){return new Z(this.doc.getGraph(),this)},n.listVariants=function(){return Array.from(this.properties).filter(function(e){return e instanceof te})},n.read=function(e){var t=this,r=e.jsonDoc;if(!r.json.extensions||!r.json.extensions[re])return this;var n=(r.json.extensions[re].variants||[]).map(function(e){return t.createVariant().setName(e.name||"")});return(r.json.meshes||[]).forEach(function(r,o){var i=e.meshes[o];(r.primitives||[]).forEach(function(r,o){if(r.extensions&&r.extensions[re]){for(var a,u=t.createMappingList(),c=s(r.extensions[re].mappings);!(a=c()).done;){var l=a.value,h=t.createMapping();void 0!==l.material&&h.setMaterial(e.materials[l.material]);for(var p,f=s(l.variants||[]);!(p=f()).done;)h.addVariant(n[p.value]);u.addMapping(h)}i.listPrimitives()[o].setExtension(re,u)}})}),this},n.write=function(e){var t=e.jsonDoc,r=this.listVariants();if(!r.length)return this;for(var n,o=[],i=new Map,a=s(r);!(n=a()).done;){var u=n.value;i.set(u,o.length),o.push(e.createPropertyDef(u))}for(var c,l=function(){var t=c.value,r=e.meshIndexMap.get(t);t.listPrimitives().forEach(function(t,n){if(t.getExtension(re)){var o=e.jsonDoc.json.meshes[r].primitives[n],s=t.getExtension(re).listMappings().map(function(t){var r=e.createPropertyDef(t);return t.getMaterial()&&(r.material=e.materialIndexMap.get(t.getMaterial())),r.variants=t.listVariants().map(function(e){return i.get(e)}),r});o.extensions=o.extensions||{},o.extensions[re]={mappings:s}}})},h=s(this.doc.getRoot().listMeshes());!(c=h()).done;)l();return t.json.extensions=t.json.extensions||{},t.json.extensions[re]={variants:o},this},t}(e.Extension);ne.EXTENSION_NAME=re;var oe="KHR_mesh_quantization",se=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=oe,t}r(t,e);var n=t.prototype;return n.read=function(e){return this},n.write=function(e){return this},t}(e.Extension);se.EXTENSION_NAME=oe;var ie="KHR_texture_basisu",ae=function(t){function n(){var r;return(r=t.apply(this,arguments)||this).extensionName=ie,r.prereadTypes=[e.PropertyType.TEXTURE],r}r(n,t);var o=n.prototype;return o.preread=function(e){return e.jsonDoc.json.textures.forEach(function(e){e.extensions&&e.extensions[ie]&&(e.source=e.extensions[ie].source)}),this},o.read=function(e){return this},o.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listTextures().forEach(function(r){if("image/ktx2"===r.getMimeType()){var n=e.imageIndexMap.get(r);t.json.textures.forEach(function(e){e.source===n&&(e.extensions=e.extensions||{},e.extensions[ie]={source:e.source},delete e.source)})}}),this},n}(e.Extension);ae.EXTENSION_NAME=ie;var ue=function(t){function n(){var r;return(r=t.apply(this,arguments)||this).propertyType="Transform",r.parentTypes=[e.PropertyType.TEXTURE_INFO],r.extensionName="KHR_texture_transform",r._offset=[0,0],r._rotation=0,r._scale=[1,1],r._texCoord=void 0,r}r(n,t);var o=n.prototype;return o.copy=function(r,n){return void 0===n&&(n=e.COPY_IDENTITY),t.prototype.copy.call(this,r,n),this._offset=r._offset,this._rotation=r._rotation,this._scale=r._scale,this._texCoord=r._texCoord,this},o.getOffset=function(){return this._offset},o.setOffset=function(e){return this._offset=e,this},o.getRotation=function(){return this._rotation},o.setRotation=function(e){return this._rotation=e,this},o.getScale=function(){return this._scale},o.setScale=function(e){return this._scale=e,this},o.getTexCoord=function(){return this._texCoord},o.setTexCoord=function(e){return this._texCoord=e,this},n}(e.ExtensionProperty);ue.EXTENSION_NAME="KHR_texture_transform";var ce="KHR_texture_transform",le=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=ce,t}r(t,e);var n=t.prototype;return n.createTransform=function(){return new ue(this.doc.getGraph(),this)},n.read=function(e){for(var t=0,r=Array.from(e.textureInfos.entries());t<r.length;t++){var n=r[t],o=n[0],s=n[1];if(s.extensions&&s.extensions[ce]){var i=this.createTransform(),a=s.extensions[ce];void 0!==a.offset&&i.setOffset(a.offset),void 0!==a.rotation&&i.setRotation(a.rotation),void 0!==a.scale&&i.setScale(a.scale),void 0!==a.texCoord&&i.setTexCoord(a.texCoord),o.setExtension(ce,i)}}return this},n.write=function(e){for(var t=0,r=Array.from(e.textureInfoDefMap.entries());t<r.length;t++){var n=r[t],o=n[1],s=n[0].getExtension(ce);s&&(o.extensions=o.extensions||{},o.extensions[ce]={offset:s.getOffset(),rotation:s.getRotation(),scale:s.getScale(),texCoord:s.getTexCoord()})}return this},t}(e.Extension);le.EXTENSION_NAME=ce;var he=[S,M,w,b,K,Y,B,Q,$,ne,se,ae,le],pe=[a].concat(he);exports.ALL_EXTENSIONS=pe,exports.Clearcoat=D,exports.DracoMeshCompression=S,exports.IOR=j,exports.KHRONOS_EXTENSIONS=he,exports.Light=A,exports.LightsPunctual=M,exports.Mapping=Z,exports.MappingList=ee,exports.MaterialsClearcoat=w,exports.MaterialsIOR=b,exports.MaterialsPBRSpecularGlossiness=K,exports.MaterialsSheen=B,exports.MaterialsSpecular=Y,exports.MaterialsTransmission=Q,exports.MaterialsUnlit=$,exports.MaterialsVariants=ne,exports.MeshQuantization=se,exports.PBRSpecularGlossiness=H,exports.Sheen=U,exports.Specular=k,exports.TextureBasisu=ae,exports.TextureTransform=le,exports.TextureWebP=a,exports.Transform=ue,exports.Transmission=z,exports.Unlit=W,exports.Variant=te;
//# sourceMappingURL=extensions.js.map

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

import{Extension as e,PropertyType as t,Accessor as s,GLB_BUFFER as r,ExtensionProperty as o,COPY_IDENTITY as n,ColorUtils as i,TextureInfo as a,GraphChild as c,GraphChildList as u}from"@gltf-transform/core";const h="EXT_texture_webp";class l extends e{constructor(){super(...arguments),this.extensionName=h,this.prereadTypes=[t.TEXTURE]}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.doc.getRoot().listTextures().forEach(s=>{if("image/webp"===s.getMimeType()){const r=e.imageIndexMap.get(s);t.json.textures.forEach(e=>{e.source===r&&(e.extensions=e.extensions||{},e.extensions[h]={source:e.source},delete e.source)})}}),this}}let x,p,g,f;function d(e,t){let s;try{if(s=new x.DecoderBuffer,s.Init(new Int8Array(t),t.byteLength),e.GetEncodedGeometryType(s)!==x.TRIANGULAR_MESH)throw new Error("Unknown geometry type.");const r=new x.Mesh;if(!e.DecodeBufferToMesh(s,r).ok()||0===r.ptr)throw new Error("Decoding failure.");return r}finally{x.destroy(s)}}function T(e,t){const s=3*t.num_faces(),r=s*Uint32Array.BYTES_PER_ELEMENT,o=x._malloc(r);e.GetTrianglesUInt32Array(t,r,o);const n=new Uint32Array(x.HEAP32.buffer,o,s).slice();return x._free(o),n}function m(e,t,s,r){const o=g[r.componentType],n=p[r.componentType],i=s.num_components(),a=t.num_points()*i,c=a*n.BYTES_PER_ELEMENT,u=x._malloc(c);e.GetAttributeDataArrayForAllPoints(t,s,o,c,u);const h=new n(x.HEAPF32.buffer,u,a).slice();return x._free(u),h}var _,I;l.EXTENSION_NAME=h,function(e){e[e.EDGEBREAKER=1]="EDGEBREAKER",e[e.SEQUENTIAL=0]="SEQUENTIAL"}(_||(_={})),function(e){e.POSITION="POSITION",e.NORMAL="NORMAL",e.COLOR="COLOR",e.TEX_COORD="TEX_COORD",e.GENERIC="GENERIC"}(I||(I={}));const C={[I.POSITION]:14,[I.NORMAL]:10,[I.COLOR]:8,[I.TEX_COORD]:12,[I.GENERIC]:12},E={decodeSpeed:5,encodeSpeed:5,method:_.EDGEBREAKER,quantizationBits:C};function R(e,t=E){const s={...E,...t};s.quantizationBits={...C,...t.quantizationBits};const r=new f.Encoder,o=new f.MeshBuilder,n=new f.Mesh,i={},a=new f.DracoInt8Array;for(const t of e.listSemantics()){const a=e.getAttribute(t),c=N(t),u=o[y[a.getComponentType()]](n,f[c],a.getCount(),a.getElementSize(),a.getArray());if(-1===u)throw new Error(`Error compressing "${t}" attribute.`);i[t]=u,r.SetAttributeQuantization(f[c],s.quantizationBits[c])}o.AddFacesToMesh(n,e.getIndices().getCount()/3,e.getIndices().getArray()),r.SetSpeedOptions(s.encodeSpeed,s.decodeSpeed),r.SetTrackEncodedProperties(!0),e.listTargets().length>0||s.method===_.SEQUENTIAL?r.SetEncodingMethod(f.MESH_SEQUENTIAL_ENCODING):r.SetEncodingMethod(f.MESH_EDGEBREAKER_ENCODING);const c=r.EncodeMeshToDracoBuffer(n,a);if(c<=0)throw new Error("Error applying Draco compression.");const u=new Uint8Array(c);for(let e=0;e<c;++e)u[e]=a.GetValue(e);const h=r.GetNumberOfEncodedPoints(),l=3*r.GetNumberOfEncodedFaces();return f.destroy(a),f.destroy(n),f.destroy(o),f.destroy(r),{numVertices:h,numIndices:l,data:u,attributeIDs:i}}function N(e){return"POSITION"===e?I.POSITION:"NORMAL"===e?I.NORMAL:e.startsWith("COLOR_")?I.COLOR:e.startsWith("TEXCOORD_")?I.TEX_COORD:I.GENERIC}const y={[s.ComponentType.UNSIGNED_BYTE]:"AddUInt8Attribute",[s.ComponentType.BYTE]:"AddInt8Attribute",[s.ComponentType.UNSIGNED_SHORT]:"AddUInt16Attribute",[s.ComponentType.SHORT]:"AddInt16Attribute",[s.ComponentType.UNSIGNED_INT]:"AddUInt32Attribute",[s.ComponentType.FLOAT]:"AddFloatAttribute"},S="KHR_draco_mesh_compression";class A extends e{constructor(){super(...arguments),this.extensionName=S,this.prereadTypes=[t.PRIMITIVE],this.prewriteTypes=[t.ACCESSOR],this.dependencies=["draco3d.decoder","draco3d.encoder"],this._encoderOptions={}}install(e,t){return"draco3d.decoder"===e&&(this._decoderModule=t,x=this._decoderModule,p={5126:Float32Array,5125:Uint32Array,5123:Uint16Array,5121:Uint8Array,5122:Int16Array,5120:Int8Array},g={5126:x.DT_FLOAT32,5125:x.DT_UINT32,5123:x.DT_UINT16,5121:x.DT_UINT8,5122:x.DT_INT16,5120:x.DT_INT8}),"draco3d.encoder"===e&&(this._encoderModule=t,f=this._encoderModule),this}setEncoderOptions(e){return this._encoderOptions=e,this}preread(e){if(!this._decoderModule)throw new Error('Please install extension dependency, "draco3d.decoder".');const t=this.doc.getLogger(),s=e.jsonDoc,o=new this._decoderModule.Decoder,n=new Map;for(const i of s.json.meshes){for(const a of i.primitives){if(!a.extensions||!a.extensions[S])continue;const i=a.extensions[S];let c=n.get(i.bufferView);if(!c){const e=s.json.bufferViews[i.bufferView],a=s.json.buffers[e.buffer],u=new Uint8Array(a.uri?s.resources[a.uri]:s.resources[r],e.byteOffset||0,e.byteLength);c=d(o,u),n.set(i.bufferView,c),t.debug(`Decompressed ${u.byteLength} bytes.`)}for(const t in a.attributes){const s=e.jsonDoc.json.accessors[a.attributes[t]],r=o.GetAttributeByUniqueId(c,i.attributes[t]),n=m(o,c,r,s);e.accessors[a.attributes[t]].setArray(n)}const u=T(o,c);e.accessors[a.indices].setArray(u)}this._decoderModule.destroy(o);for(const e of Array.from(n.values()))this._decoderModule.destroy(e)}return this}read(e){return this}prewrite(e,t){if(!this._encoderModule)throw new Error('Please install extension dependency, "draco3d.encoder".');const s=this.doc.getLogger();s.debug("Draco compression options: "+JSON.stringify(this._encoderOptions));const r=function(e){const t=e.getLogger(),s=new Set,r=new Set;for(const o of e.getRoot().listMeshes())for(const e of o.listPrimitives())e.getIndices()?4!==e.getMode()?(r.add(e),t.warn("Skipping Draco compression on non-TRIANGLES primitive.")):s.add(e):(r.add(e),t.warn("Skipping Draco compression on non-indexed primitive."));const o=e.getRoot().listAccessors(),n=new Map;for(let e=0;e<o.length;e++)n.set(o[e],e);const i=new Map,a=new Map;for(const e of Array.from(s)){const t=[];t.push(n.get(e.getIndices()));for(const s of e.listAttributes())t.push(n.get(s));const s=t.sort().join("|");a.set(e,s),i.set(e.getIndices(),s);for(const t of e.listAttributes())i.set(t,s)}for(const e of Array.from(i.keys())){const t=new Set(e.listParents().map(e=>e.propertyType));if(2!==t.size||!t.has("Primitive")||!t.has("Root"))throw new Error("Compressed accessors must only be used as indices or vertex attributes.")}for(const e of Array.from(s)){const t=a.get(e);if(i.get(e.getIndices())!==t||e.listAttributes().some(e=>i.get(e)!==t))throw new Error("Draco primitives must share all, or no, accessors.")}for(const e of Array.from(r))if(i.has(e.getIndices())||e.listAttributes().some(e=>i.has(e)))throw new Error("Accessor cannot be shared by compressed and uncompressed primitives.");return a}(this.doc),o=new Map;for(const t of Array.from(r.keys())){const s=r.get(t);if(o.has(s)){o.set(s,o.get(s));continue}const n=R(t,this._encoderOptions);o.set(s,n);const i=e.createAccessorDef(t.getIndices());i.count=n.numIndices,e.accessorIndexMap.set(t.getIndices(),e.jsonDoc.json.accessors.length),e.jsonDoc.json.accessors.push(i);for(const s of t.listSemantics()){const r=t.getAttribute(s),o=e.createAccessorDef(r);o.count=n.numVertices,e.accessorIndexMap.set(r,e.jsonDoc.json.accessors.length),e.jsonDoc.json.accessors.push(o)}const a=t.getAttribute("POSITION").getBuffer()||this.doc.getRoot().listBuffers()[0];e.otherBufferViews.has(a)||e.otherBufferViews.set(a,[]),e.otherBufferViews.get(a).push(n.data)}return s.debug(`Compressed ${r.size} primitives.`),e.extensionData[S]={primitiveHashMap:r,primitiveEncodingMap:o},this}write(e){const t=e.extensionData[S];for(const s of this.doc.getRoot().listMeshes()){const r=e.jsonDoc.json.meshes[e.meshIndexMap.get(s)];for(let o=0;o<s.listPrimitives().length;o++){const n=s.listPrimitives()[o],i=r.primitives[o],a=t.primitiveHashMap.get(n);if(!a)continue;const c=t.primitiveEncodingMap.get(a);i.extensions=i.extensions||{},i.extensions[S]={bufferView:e.otherBufferViewsIndexMap.get(c.data),attributes:c.attributeIDs}}}return this}}var F;A.EXTENSION_NAME=S,A.EncoderMethod=_,function(e){e.POINT="point",e.SPOT="spot",e.DIRECTIONAL="directional"}(F||(F={}));class M extends o{constructor(){super(...arguments),this.propertyType="Light",this.parentTypes=[t.NODE],this.extensionName="KHR_lights_punctual",this._color=[1,1,1],this._intensity=1,this._range=void 0,this._innerConeAngle=0,this._outerConeAngle=Math.PI/4}copy(e,t=n){return super.copy(e,t),this._color=[...e._color],this._intensity=e._intensity,this._type=e._type,this._range=e._range,this._innerConeAngle=e._innerConeAngle,this._outerConeAngle=e._outerConeAngle,this}getColor(){return this._color}setColor(e){return this._color=e,this}getColorHex(){return i.factorToHex(this._color)}setColorHex(e){return i.hexToFactor(e,this._color),this}getIntensity(){return this._intensity}setIntensity(e){return this._intensity=e,this}getType(){return this._type}setType(e){return this._type=e,this}getRange(){return this._range}setRange(e){return this._range=e,this}getInnerConeAngle(){return this._innerConeAngle}setInnerConeAngle(e){return this._innerConeAngle=e,this}getOuterConeAngle(){return this._outerConeAngle}setOuterConeAngle(e){return this._outerConeAngle=e,this}}M.EXTENSION_NAME="KHR_lights_punctual";const O="KHR_lights_punctual";class v extends e{constructor(){super(...arguments),this.extensionName=O}createLight(){return new M(this.doc.getGraph(),this)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions[O])return this;const s=(t.json.extensions[O].lights||[]).map(e=>{const t=this.createLight().setName(e.name||"").setType(e.type);return void 0!==e.color&&t.setColor(e.color),void 0!==e.intensity&&t.setIntensity(e.intensity),void 0!==e.range&&t.setRange(e.range),void 0!==e.innerConeAngle&&t.setInnerConeAngle(e.innerConeAngle),void 0!==e.outerConeAngle&&t.setOuterConeAngle(e.outerConeAngle),t});return t.json.nodes.forEach((t,r)=>{t.extensions&&t.extensions[O]&&e.nodes[r].setExtension(O,s[t.extensions[O].light])}),this}write(e){const t=e.jsonDoc;if(0===this.properties.size)return this;const s=[],r=new Map;for(const e of this.properties){const t=e,o={type:t.getType(),color:t.getColor(),intensity:t.getIntensity(),range:t.getRange()};t.getName()&&(o.name=t.getName()),t.getType()===F.SPOT&&(o.innerConeAngle=t.getInnerConeAngle(),o.outerConeAngle=t.getOuterConeAngle()),s.push(o),r.set(t,s.length-1)}return this.doc.getRoot().listNodes().forEach(s=>{const o=s.getExtension(O);if(o){const n=e.nodeIndexMap.get(s),i=t.json.nodes[n];i.extensions=i.extensions||{},i.extensions[O]={light:r.get(o)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[O]={lights:s},this}}function D(e,t,s,r){var o,n=arguments.length,i=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,s,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(i=(n<3?o(i):n>3?o(t,s,i):o(t,s))||i);return n>3&&i&&Object.defineProperty(t,s,i),i}v.EXTENSION_NAME=O;class w extends o{constructor(){super(...arguments),this.propertyType="Clearcoat",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_clearcoat",this._clearcoatFactor=0,this._clearcoatRoughnessFactor=0,this._clearcoatNormalScale=1,this.clearcoatTexture=null,this.clearcoatTextureInfo=this.graph.link("clearcoatTextureInfo",this,new a(this.graph)),this.clearcoatRoughnessTexture=null,this.clearcoatRoughnessTextureInfo=this.graph.link("clearcoatRoughnessTextureInfo",this,new a(this.graph)),this.clearcoatNormalTexture=null,this.clearcoatNormalTextureInfo=this.graph.link("clearcoatNormalTextureInfo",this,new a(this.graph))}copy(e,t=n){return super.copy(e,t),this._clearcoatFactor=e._clearcoatFactor,this._clearcoatRoughnessFactor=e._clearcoatRoughnessFactor,this._clearcoatNormalScale=e._clearcoatNormalScale,e.clearcoatTexture&&(this.setClearcoatTexture(t(e.clearcoatTexture.getChild())),this.getClearcoatTextureInfo().copy(t(e.clearcoatTextureInfo.getChild()),t)),e.clearcoatRoughnessTexture&&(this.setClearcoatRoughnessTexture(t(e.clearcoatRoughnessTexture.getChild())),this.getClearcoatRoughnessTextureInfo().copy(t(e.clearcoatRoughnessTextureInfo.getChild()),t)),e.clearcoatNormalTexture&&(this.setClearcoatNormalTexture(t(e.clearcoatNormalTexture.getChild())),this.getClearcoatNormalTextureInfo().copy(t(e.clearcoatNormalTextureInfo.getChild()),t)),this}dispose(){this.clearcoatTextureInfo.getChild().dispose(),this.clearcoatRoughnessTextureInfo.getChild().dispose(),this.clearcoatNormalTextureInfo.getChild().dispose(),super.dispose()}getClearcoatFactor(){return this._clearcoatFactor}setClearcoatFactor(e){return this._clearcoatFactor=e,this}getClearcoatTexture(){return this.clearcoatTexture?this.clearcoatTexture.getChild():null}getClearcoatTextureInfo(){return this.clearcoatTexture?this.clearcoatTextureInfo.getChild():null}setClearcoatTexture(e){return this.clearcoatTexture=this.graph.link("clearcoatTexture",this,e),this}getClearcoatRoughnessFactor(){return this._clearcoatRoughnessFactor}setClearcoatRoughnessFactor(e){return this._clearcoatRoughnessFactor=e,this}getClearcoatRoughnessTexture(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.getChild():null}getClearcoatRoughnessTextureInfo(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTextureInfo.getChild():null}setClearcoatRoughnessTexture(e){return this.clearcoatRoughnessTexture=this.graph.link("clearcoatRoughnessTexture",this,e),this}getClearcoatNormalScale(){return this._clearcoatNormalScale}setClearcoatNormalScale(e){return this._clearcoatNormalScale=e,this}getClearcoatNormalTexture(){return this.clearcoatNormalTexture?this.clearcoatNormalTexture.getChild():null}getClearcoatNormalTextureInfo(){return this.clearcoatNormalTexture?this.clearcoatNormalTextureInfo.getChild():null}setClearcoatNormalTexture(e){return this.clearcoatNormalTexture=this.graph.link("clearcoatNormalTexture",this,e),this}}w.EXTENSION_NAME="KHR_materials_clearcoat",D([c],w.prototype,"clearcoatTexture",void 0),D([c],w.prototype,"clearcoatTextureInfo",void 0),D([c],w.prototype,"clearcoatRoughnessTexture",void 0),D([c],w.prototype,"clearcoatRoughnessTextureInfo",void 0),D([c],w.prototype,"clearcoatNormalTexture",void 0),D([c],w.prototype,"clearcoatNormalTextureInfo",void 0);const j="KHR_materials_clearcoat";class G extends e{constructor(){super(...arguments),this.extensionName=j}createClearcoat(){return new w(this.doc.getGraph(),this)}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,r)=>{if(t.extensions&&t.extensions[j]){const o=this.createClearcoat();if(e.materials[r].setExtension(j,o),void 0!==t.extensions[j].clearcoatFactor&&o.setClearcoatFactor(t.extensions[j].clearcoatFactor),void 0!==t.extensions[j].clearcoatRoughnessFactor&&o.setClearcoatRoughnessFactor(t.extensions[j].clearcoatRoughnessFactor),void 0!==t.extensions[j].clearcoatTexture){const r=t.extensions[j].clearcoatTexture;o.setClearcoatTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getClearcoatTextureInfo(),r)}if(void 0!==t.extensions[j].clearcoatRoughnessTexture){const r=t.extensions[j].clearcoatRoughnessTexture;o.setClearcoatRoughnessTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getClearcoatRoughnessTextureInfo(),r)}if(void 0!==t.extensions[j].clearcoatNormalTexture){const r=t.extensions[j].clearcoatNormalTexture;o.setClearcoatNormalTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getClearcoatNormalTextureInfo(),r),void 0!==r.scale&&o.setClearcoatNormalScale(r.scale)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(j);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[j]={clearcoatFactor:r.getClearcoatFactor(),clearcoatRoughnessFactor:r.getClearcoatRoughnessFactor()},r.getClearcoatTexture()){const t=r.getClearcoatTexture(),s=r.getClearcoatTextureInfo();n.extensions[j].clearcoatTexture=e.createTextureInfoDef(t,s)}if(r.getClearcoatRoughnessTexture()){const t=r.getClearcoatRoughnessTexture(),s=r.getClearcoatRoughnessTextureInfo();n.extensions[j].clearcoatRoughnessTexture=e.createTextureInfoDef(t,s)}if(r.getClearcoatNormalTexture()){const t=r.getClearcoatNormalTexture(),s=r.getClearcoatNormalTextureInfo();n.extensions[j].clearcoatNormalTexture=e.createTextureInfoDef(t,s),1!==r.getClearcoatNormalScale()&&(n.extensions[j].clearcoatNormalTexture.scale=r.getClearcoatNormalScale())}}}),this}}G.EXTENSION_NAME=j;class H extends o{constructor(){super(...arguments),this.propertyType="IOR",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_ior",this._ior=0}copy(e,t=n){return super.copy(e,t),this._ior=e._ior,this}getIOR(){return this._ior}setIOR(e){return this._ior=e,this}}H.EXTENSION_NAME="KHR_materials_ior";const b="KHR_materials_ior";class L extends e{constructor(){super(...arguments),this.extensionName=b}createIOR(){return new H(this.doc.getGraph(),this)}read(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{if(t.extensions&&t.extensions[b]){const r=this.createIOR();e.materials[s].setExtension(b,r),void 0!==t.extensions[b].ior&&r.setIOR(t.extensions[b].ior)}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(b);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];n.extensions=n.extensions||{},n.extensions[b]={ior:r.getIOR()}}}),this}}L.EXTENSION_NAME=b;class K extends o{constructor(){super(...arguments),this.propertyType="PBRSpecularGlossiness",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_pbrSpecularGlossiness",this._diffuseFactor=[1,1,1,1],this._specularFactor=[1,1,1],this._glossinessFactor=1,this.diffuseTexture=null,this.diffuseTextureInfo=this.graph.link("diffuseTextureInfo",this,new a(this.graph)),this.specularGlossinessTexture=null,this.specularGlossinessTextureInfo=this.graph.link("specularGlossinessTextureInfo",this,new a(this.graph))}copy(e,t=n){return super.copy(e,t),this._diffuseFactor=e._diffuseFactor,this._specularFactor=e._specularFactor,this._glossinessFactor=e._glossinessFactor,e.diffuseTexture&&(this.setDiffuseTexture(t(e.diffuseTexture.getChild())),this.getDiffuseTextureInfo().copy(t(e.diffuseTextureInfo.getChild()),t)),e.specularGlossinessTexture&&(this.setSpecularGlossinessTexture(t(e.specularGlossinessTexture.getChild())),this.getSpecularGlossinessTextureInfo().copy(t(e.specularGlossinessTextureInfo.getChild()),t)),this}dispose(){this.diffuseTextureInfo.getChild().dispose(),this.specularGlossinessTextureInfo.getChild().dispose(),super.dispose()}getDiffuseFactor(){return this._diffuseFactor}setDiffuseFactor(e){return this._diffuseFactor=e,this}getDiffuseHex(){return i.factorToHex(this._diffuseFactor)}setDiffuseHex(e){return i.hexToFactor(e,this._diffuseFactor),this}getDiffuseTexture(){return this.diffuseTexture?this.diffuseTexture.getChild():null}getDiffuseTextureInfo(){return this.diffuseTexture?this.diffuseTextureInfo.getChild():null}setDiffuseTexture(e){return this.diffuseTexture=this.graph.link("diffuseTexture",this,e),this}getSpecularFactor(){return this._specularFactor}setSpecularFactor(e){return this._specularFactor=e,this}getGlossinessFactor(){return this._glossinessFactor}setGlossinessFactor(e){return this._glossinessFactor=e,this}getSpecularGlossinessTexture(){return this.specularGlossinessTexture?this.specularGlossinessTexture.getChild():null}getSpecularGlossinessTextureInfo(){return this.specularGlossinessTexture?this.specularGlossinessTextureInfo.getChild():null}setSpecularGlossinessTexture(e){return this.specularGlossinessTexture=this.graph.link("specularGlossinessTexture",this,e),this}}K.EXTENSION_NAME="KHR_materials_pbrSpecularGlossiness",D([c],K.prototype,"diffuseTexture",void 0),D([c],K.prototype,"diffuseTextureInfo",void 0),D([c],K.prototype,"specularGlossinessTexture",void 0),D([c],K.prototype,"specularGlossinessTextureInfo",void 0);const P="KHR_materials_pbrSpecularGlossiness";class X extends e{constructor(){super(...arguments),this.extensionName=P}createPBRSpecularGlossiness(){return new K(this.doc.getGraph(),this)}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,r)=>{if(t.extensions&&t.extensions[P]){const o=this.createPBRSpecularGlossiness();if(e.materials[r].setExtension(P,o),void 0!==t.extensions[P].diffuseFactor&&o.setDiffuseFactor(t.extensions[P].diffuseFactor),void 0!==t.extensions[P].specularFactor&&o.setSpecularFactor(t.extensions[P].specularFactor),void 0!==t.extensions[P].glossinessFactor&&o.setGlossinessFactor(t.extensions[P].glossinessFactor),void 0!==t.extensions[P].diffuseTexture){const r=t.extensions[P].diffuseTexture;o.setDiffuseTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getDiffuseTextureInfo(),r)}if(void 0!==t.extensions[P].specularGlossinessTexture){const r=t.extensions[P].specularGlossinessTexture;o.setSpecularGlossinessTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getSpecularGlossinessTextureInfo(),r)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(P);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[P]={diffuseFactor:r.getDiffuseFactor(),specularFactor:r.getSpecularFactor(),glossinessFactor:r.getGlossinessFactor()},r.getDiffuseTexture()){const t=r.getDiffuseTexture(),s=r.getDiffuseTextureInfo();n.extensions[P].diffuseTexture=e.createTextureInfoDef(t,s)}if(r.getSpecularGlossinessTexture()){const t=r.getSpecularGlossinessTexture(),s=r.getSpecularGlossinessTextureInfo();n.extensions[P].specularGlossinessTexture=e.createTextureInfoDef(t,s)}}}),this}}X.EXTENSION_NAME=P;class U extends o{constructor(){super(...arguments),this.propertyType="Sheen",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_sheen",this._sheenColorFactor=[0,0,0],this._sheenRoughnessFactor=0,this.sheenColorTexture=null,this.sheenColorTextureInfo=this.graph.link("sheenColorTextureInfo",this,new a(this.graph)),this.sheenRoughnessTexture=null,this.sheenRoughnessTextureInfo=this.graph.link("sheenRoughnessTextureInfo",this,new a(this.graph))}copy(e,t=n){return super.copy(e,t),this._sheenColorFactor=e._sheenColorFactor,this._sheenRoughnessFactor=e._sheenRoughnessFactor,e.sheenColorTexture&&(this.setSheenColorTexture(t(e.sheenColorTexture.getChild())),this.getSheenColorTextureInfo().copy(t(e.sheenColorTextureInfo.getChild()),t)),e.sheenRoughnessTexture&&(this.setSheenRoughnessTexture(t(e.sheenRoughnessTexture.getChild())),this.getSheenRoughnessTextureInfo().copy(t(e.sheenRoughnessTextureInfo.getChild()),t)),this}dispose(){this.sheenColorTextureInfo.getChild().dispose(),this.sheenRoughnessTextureInfo.getChild().dispose(),super.dispose()}getSheenColorFactor(){return this._sheenColorFactor}getSheenColorHex(){return i.factorToHex(this._sheenColorFactor)}setSheenColorFactor(e){return this._sheenColorFactor=e,this}setSheenColorHex(e){return i.hexToFactor(e,this._sheenColorFactor),this}getSheenColorTexture(){return this.sheenColorTexture?this.sheenColorTexture.getChild():null}getSheenColorTextureInfo(){return this.sheenColorTexture?this.sheenColorTextureInfo.getChild():null}setSheenColorTexture(e){return this.sheenColorTexture=this.graph.link("sheenColorTexture",this,e),this}getSheenRoughnessFactor(){return this._sheenRoughnessFactor}setSheenRoughnessFactor(e){return this._sheenRoughnessFactor=e,this}getSheenRoughnessTexture(){return this.sheenRoughnessTexture?this.sheenRoughnessTexture.getChild():null}getSheenRoughnessTextureInfo(){return this.sheenRoughnessTexture?this.sheenRoughnessTextureInfo.getChild():null}setSheenRoughnessTexture(e){return this.sheenRoughnessTexture=this.graph.link("sheenRoughnessTexture",this,e),this}}U.EXTENSION_NAME="KHR_materials_sheen",D([c],U.prototype,"sheenColorTexture",void 0),D([c],U.prototype,"sheenColorTextureInfo",void 0),D([c],U.prototype,"sheenRoughnessTexture",void 0),D([c],U.prototype,"sheenRoughnessTextureInfo",void 0);const k="KHR_materials_sheen";class B extends e{constructor(){super(...arguments),this.extensionName=k}createSheen(){return new U(this.doc.getGraph(),this)}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,r)=>{if(t.extensions&&t.extensions[k]){const o=this.createSheen();if(e.materials[r].setExtension(k,o),void 0!==t.extensions[k].sheenColorFactor&&o.setSheenColorFactor(t.extensions[k].sheenColorFactor),void 0!==t.extensions[k].sheenRoughnessFactor&&o.setSheenRoughnessFactor(t.extensions[k].sheenRoughnessFactor),void 0!==t.extensions[k].sheenColorTexture){const r=t.extensions[k].sheenColorTexture;o.setSheenColorTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getSheenColorTextureInfo(),r)}if(void 0!==t.extensions[k].sheenRoughnessTexture){const r=t.extensions[k].sheenRoughnessTexture;o.setSheenRoughnessTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getSheenRoughnessTextureInfo(),r)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(k);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[k]={sheenColorFactor:r.getSheenColorFactor(),sheenRoughnessFactor:r.getSheenRoughnessFactor()},r.getSheenColorTexture()){const t=r.getSheenColorTexture(),s=r.getSheenColorTextureInfo();n.extensions[k].sheenColorTexture=e.createTextureInfoDef(t,s)}if(r.getSheenRoughnessTexture()){const t=r.getSheenRoughnessTexture(),s=r.getSheenRoughnessTextureInfo();n.extensions[k].sheenRoughnessTexture=e.createTextureInfoDef(t,s)}}}),this}}B.EXTENSION_NAME=k;class V extends o{constructor(){super(...arguments),this.propertyType="Specular",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_specular",this._specularFactor=1,this._specularColorFactor=[1,1,1],this.specularTexture=null,this.specularTextureInfo=this.graph.link("specularTextureInfo",this,new a(this.graph))}copy(e,t=n){return super.copy(e,t),this._specularFactor=e._specularFactor,e.specularTexture&&(this.setSpecularTexture(t(e.specularTexture.getChild())),this.getSpecularTextureInfo().copy(t(e.specularTextureInfo.getChild()),t)),this}dispose(){this.specularTextureInfo.getChild().dispose(),super.dispose()}getSpecularFactor(){return this._specularFactor}setSpecularFactor(e){return this._specularFactor=e,this}getSpecularColorFactor(){return this._specularColorFactor}setSpecularColorFactor(e){return this._specularColorFactor=e,this}getSpecularColorHex(){return i.factorToHex(this._specularColorFactor)}setSpecularColorHex(e){return i.hexToFactor(e,this._specularColorFactor),this}getSpecularTexture(){return this.specularTexture?this.specularTexture.getChild():null}getSpecularTextureInfo(){return this.specularTexture?this.specularTextureInfo.getChild():null}setSpecularTexture(e){return this.specularTexture=this.graph.link("specularTexture",this,e),this}}V.EXTENSION_NAME="KHR_materials_specular",D([c],V.prototype,"specularTexture",void 0),D([c],V.prototype,"specularTextureInfo",void 0);const z="KHR_materials_specular";class q extends e{constructor(){super(...arguments),this.extensionName=z}createSpecular(){return new V(this.doc.getGraph(),this)}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,r)=>{if(t.extensions&&t.extensions[z]){const o=this.createSpecular();if(e.materials[r].setExtension(z,o),void 0!==t.extensions[z].specularFactor&&o.setSpecularFactor(t.extensions[z].specularFactor),void 0!==t.extensions[z].specularColorFactor&&o.setSpecularColorFactor(t.extensions[z].specularColorFactor),void 0!==t.extensions[z].specularTexture){const r=t.extensions[z].specularTexture;o.setSpecularTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getSpecularTextureInfo(),r)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(z);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[z]={specularFactor:r.getSpecularFactor(),specularColorFactor:r.getSpecularColorFactor()},r.getSpecularTexture()){const t=r.getSpecularTexture(),s=r.getSpecularTextureInfo();n.extensions[z].specularTexture=e.createTextureInfoDef(t,s)}}}),this}}q.EXTENSION_NAME=z;class Q extends o{constructor(){super(...arguments),this.propertyType="Transmission",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_transmission",this._transmissionFactor=0,this.transmissionTexture=null,this.transmissionTextureInfo=this.graph.link("transmissionTextureInfo",this,new a(this.graph))}copy(e,t=n){return super.copy(e,t),this._transmissionFactor=e._transmissionFactor,e.transmissionTexture&&(this.setTransmissionTexture(t(e.transmissionTexture.getChild())),this.getTransmissionTextureInfo().copy(t(e.transmissionTextureInfo.getChild()),t)),this}dispose(){this.transmissionTextureInfo.getChild().dispose(),super.dispose()}getTransmissionFactor(){return this._transmissionFactor}setTransmissionFactor(e){return this._transmissionFactor=e,this}getTransmissionTexture(){return this.transmissionTexture?this.transmissionTexture.getChild():null}getTransmissionTextureInfo(){return this.transmissionTexture?this.transmissionTextureInfo.getChild():null}setTransmissionTexture(e){return this.transmissionTexture=this.graph.link("transmissionTexture",this,e),this}}Q.EXTENSION_NAME="KHR_materials_transmission",D([c],Q.prototype,"transmissionTexture",void 0),D([c],Q.prototype,"transmissionTextureInfo",void 0);const Y="KHR_materials_transmission";class $ extends e{constructor(){super(...arguments),this.extensionName=Y}createTransmission(){return new Q(this.doc.getGraph(),this)}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,r)=>{if(t.extensions&&t.extensions[Y]){const o=this.createTransmission();if(e.materials[r].setExtension(Y,o),void 0!==t.extensions[Y].transmissionFactor&&o.setTransmissionFactor(t.extensions[Y].transmissionFactor),void 0!==t.extensions[Y].transmissionTexture){const r=t.extensions[Y].transmissionTexture;o.setTransmissionTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getTransmissionTextureInfo(),r)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(Y);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[Y]={transmissionFactor:r.getTransmissionFactor()},r.getTransmissionTexture()){const t=r.getTransmissionTexture(),s=r.getTransmissionTextureInfo();n.extensions[Y].transmissionTexture=e.createTextureInfoDef(t,s)}}}),this}}$.EXTENSION_NAME=Y;class W extends o{constructor(){super(...arguments),this.propertyType="Unlit",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_unlit"}}W.EXTENSION_NAME="KHR_materials_unlit";const J="KHR_materials_unlit";class Z extends e{constructor(){super(...arguments),this.extensionName=J}createUnlit(){return new W(this.doc.getGraph(),this)}read(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{t.extensions&&t.extensions[J]&&e.materials[s].setExtension(J,this.createUnlit())}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{if(s.getExtension(J)){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{},o.extensions[J]={}}}),this}}Z.EXTENSION_NAME=J;class ee extends o{constructor(){super(...arguments),this.propertyType="Mapping",this.parentTypes=["MappingList"],this.extensionName="KHR_materials_variants",this.material=null,this.variants=[]}copy(e,t=n){return super.copy(e,t),e.material&&this.setMaterial(t(e.material.getChild())),this.clearGraphChildList(this.variants),e.variants.forEach(e=>this.addVariant(t(e.getChild()))),this}getMaterial(){return this.material?this.material.getChild():null}setMaterial(e){return this.material=this.graph.link("material",this,e),this}addVariant(e){const t=this.graph.link("variant",this,e);return this.addGraphChild(this.variants,t)}removeVariant(e){return this.removeGraphChild(this.variants,e)}listVariants(){return this.variants.map(e=>e.getChild())}}ee.EXTENSION_NAME="KHR_materials_variants",D([c],ee.prototype,"material",void 0),D([u],ee.prototype,"variants",void 0);class te extends o{constructor(){super(...arguments),this.propertyType="MappingList",this.parentTypes=[t.PRIMITIVE],this.extensionName="KHR_materials_variants",this.mappings=[]}copy(e,t=n){return super.copy(e,t),this.clearGraphChildList(this.mappings),e.mappings.forEach(e=>this.addMapping(t(e.getChild()))),this}addMapping(e){const t=this.graph.link("mapping",this,e);return this.addGraphChild(this.mappings,t)}removeMapping(e){return this.removeGraphChild(this.mappings,e)}listMappings(){return this.mappings.map(e=>e.getChild())}}te.EXTENSION_NAME="KHR_materials_variants",D([u],te.prototype,"mappings",void 0);class se extends o{constructor(){super(...arguments),this.propertyType="Variant",this.parentTypes=[t.ROOT,"MappingList"],this.extensionName="KHR_materials_variants"}}se.EXTENSION_NAME="KHR_materials_variants";const re="KHR_materials_variants";class oe extends e{constructor(){super(...arguments),this.extensionName=re}createMappingList(){return new te(this.doc.getGraph(),this)}createVariant(e=""){return new se(this.doc.getGraph(),this).setName(e)}createMapping(){return new ee(this.doc.getGraph(),this)}listVariants(){return Array.from(this.properties).filter(e=>e instanceof se)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions[re])return this;const s=(t.json.extensions[re].variants||[]).map(e=>this.createVariant().setName(e.name||""));return(t.json.meshes||[]).forEach((t,r)=>{const o=e.meshes[r];(t.primitives||[]).forEach((t,r)=>{if(!t.extensions||!t.extensions[re])return;const n=this.createMappingList();for(const r of t.extensions[re].mappings){const t=this.createMapping();void 0!==r.material&&t.setMaterial(e.materials[r.material]);for(const e of r.variants||[])t.addVariant(s[e]);n.addMapping(t)}o.listPrimitives()[r].setExtension(re,n)})}),this}write(e){const t=e.jsonDoc,s=this.listVariants();if(!s.length)return this;const r=[],o=new Map;for(const t of s)o.set(t,r.length),r.push(e.createPropertyDef(t));for(const t of this.doc.getRoot().listMeshes()){const s=e.meshIndexMap.get(t);t.listPrimitives().forEach((t,r)=>{if(!t.getExtension(re))return;const n=e.jsonDoc.json.meshes[s].primitives[r],i=t.getExtension(re).listMappings().map(t=>{const s=e.createPropertyDef(t);return t.getMaterial()&&(s.material=e.materialIndexMap.get(t.getMaterial())),s.variants=t.listVariants().map(e=>o.get(e)),s});n.extensions=n.extensions||{},n.extensions[re]={mappings:i}})}return t.json.extensions=t.json.extensions||{},t.json.extensions[re]={variants:r},this}}oe.EXTENSION_NAME=re;const ne="KHR_mesh_quantization";class ie extends e{constructor(){super(...arguments),this.extensionName=ne}read(e){return this}write(e){return this}}ie.EXTENSION_NAME=ne;const ae="KHR_texture_basisu";class ce extends e{constructor(){super(...arguments),this.extensionName=ae,this.prereadTypes=[t.TEXTURE]}preread(e){return e.jsonDoc.json.textures.forEach(e=>{e.extensions&&e.extensions[ae]&&(e.source=e.extensions[ae].source)}),this}read(e){return this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listTextures().forEach(s=>{if("image/ktx2"===s.getMimeType()){const r=e.imageIndexMap.get(s);t.json.textures.forEach(e=>{e.source===r&&(e.extensions=e.extensions||{},e.extensions[ae]={source:e.source},delete e.source)})}}),this}}ce.EXTENSION_NAME=ae;class ue extends o{constructor(){super(...arguments),this.propertyType="Transform",this.parentTypes=[t.TEXTURE_INFO],this.extensionName="KHR_texture_transform",this._offset=[0,0],this._rotation=0,this._scale=[1,1],this._texCoord=void 0}copy(e,t=n){return super.copy(e,t),this._offset=e._offset,this._rotation=e._rotation,this._scale=e._scale,this._texCoord=e._texCoord,this}getOffset(){return this._offset}setOffset(e){return this._offset=e,this}getRotation(){return this._rotation}setRotation(e){return this._rotation=e,this}getScale(){return this._scale}setScale(e){return this._scale=e,this}getTexCoord(){return this._texCoord}setTexCoord(e){return this._texCoord=e,this}}ue.EXTENSION_NAME="KHR_texture_transform";const he="KHR_texture_transform";class le extends e{constructor(){super(...arguments),this.extensionName=he}createTransform(){return new ue(this.doc.getGraph(),this)}read(e){for(const[t,s]of Array.from(e.textureInfos.entries())){if(!s.extensions||!s.extensions[he])continue;const e=this.createTransform(),r=s.extensions[he];void 0!==r.offset&&e.setOffset(r.offset),void 0!==r.rotation&&e.setRotation(r.rotation),void 0!==r.scale&&e.setScale(r.scale),void 0!==r.texCoord&&e.setTexCoord(r.texCoord),t.setExtension(he,e)}return this}write(e){const t=Array.from(e.textureInfoDefMap.entries());for(const[e,s]of t){const t=e.getExtension(he);t&&(s.extensions=s.extensions||{},s.extensions[he]={offset:t.getOffset(),rotation:t.getRotation(),scale:t.getScale(),texCoord:t.getTexCoord()})}return this}}le.EXTENSION_NAME=he;const xe=[A,v,G,L,X,q,B,$,Z,oe,ie,ce,le],pe=[l,...xe];export{pe as ALL_EXTENSIONS,w as Clearcoat,A as DracoMeshCompression,H as IOR,xe as KHRONOS_EXTENSIONS,M as Light,F as LightType,v as LightsPunctual,ee as Mapping,te as MappingList,G as MaterialsClearcoat,L as MaterialsIOR,X as MaterialsPBRSpecularGlossiness,B as MaterialsSheen,q as MaterialsSpecular,$ as MaterialsTransmission,Z as MaterialsUnlit,oe as MaterialsVariants,ie as MeshQuantization,K as PBRSpecularGlossiness,U as Sheen,V as Specular,ce as TextureBasisu,le as TextureTransform,l as TextureWebP,ue as Transform,Q as Transmission,W as Unlit,se as Variant};
import{Extension as e,PropertyType as t,Accessor as s,GLB_BUFFER as r,ExtensionProperty as o,COPY_IDENTITY as n,ColorUtils as i,TextureInfo as a,GraphChild as c,GraphChildList as u}from"@gltf-transform/core";const h="EXT_texture_webp";class l extends e{constructor(){super(...arguments),this.extensionName=h,this.prereadTypes=[t.TEXTURE]}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.doc.getRoot().listTextures().forEach(s=>{if("image/webp"===s.getMimeType()){const r=e.imageIndexMap.get(s);t.json.textures.forEach(e=>{e.source===r&&(e.extensions=e.extensions||{},e.extensions[h]={source:e.source},delete e.source)})}}),this}}l.EXTENSION_NAME=h;const x="KHR_draco_mesh_compression";let p,g,f,d;function T(e,t){let s;try{if(s=new p.DecoderBuffer,s.Init(t,t.length),e.GetEncodedGeometryType(s)!==p.TRIANGULAR_MESH)throw new Error(`[${x}] Unknown geometry type.`);const r=new p.Mesh;if(!e.DecodeBufferToMesh(s,r).ok()||0===r.ptr)throw new Error(`[${x}] Decoding failure.`);return r}finally{p.destroy(s)}}function m(e,t){const s=3*t.num_faces(),r=s*Uint32Array.BYTES_PER_ELEMENT,o=p._malloc(r);e.GetTrianglesUInt32Array(t,r,o);const n=new Uint32Array(p.HEAP32.buffer,o,s).slice();return p._free(o),n}function _(e,t,s,r){const o=f[r.componentType],n=g[r.componentType],i=s.num_components(),a=t.num_points()*i,c=a*n.BYTES_PER_ELEMENT,u=p._malloc(c);e.GetAttributeDataArrayForAllPoints(t,s,o,c,u);const h=new n(p.HEAPF32.buffer,u,a).slice();return p._free(u),h}var I,C;!function(e){e[e.EDGEBREAKER=1]="EDGEBREAKER",e[e.SEQUENTIAL=0]="SEQUENTIAL"}(I||(I={})),function(e){e.POSITION="POSITION",e.NORMAL="NORMAL",e.COLOR="COLOR",e.TEX_COORD="TEX_COORD",e.GENERIC="GENERIC"}(C||(C={}));const E={[C.POSITION]:14,[C.NORMAL]:10,[C.COLOR]:8,[C.TEX_COORD]:12,[C.GENERIC]:12},R={decodeSpeed:5,encodeSpeed:5,method:I.EDGEBREAKER,quantizationBits:E};function N(e,t=R){const s={...R,...t};s.quantizationBits={...E,...t.quantizationBits};const r=new d.Encoder,o=new d.MeshBuilder,n=new d.Mesh,i={},a=new d.DracoInt8Array;for(const t of e.listSemantics()){const a=e.getAttribute(t),c=y(t),u=o[S[a.getComponentType()]](n,d[c],a.getCount(),a.getElementSize(),a.getArray());if(-1===u)throw new Error(`Error compressing "${t}" attribute.`);i[t]=u,r.SetAttributeQuantization(d[c],s.quantizationBits[c])}o.AddFacesToMesh(n,e.getIndices().getCount()/3,e.getIndices().getArray()),r.SetSpeedOptions(s.encodeSpeed,s.decodeSpeed),r.SetTrackEncodedProperties(!0),e.listTargets().length>0||s.method===I.SEQUENTIAL?r.SetEncodingMethod(d.MESH_SEQUENTIAL_ENCODING):r.SetEncodingMethod(d.MESH_EDGEBREAKER_ENCODING);const c=r.EncodeMeshToDracoBuffer(n,a);if(c<=0)throw new Error("Error applying Draco compression.");const u=new Uint8Array(c);for(let e=0;e<c;++e)u[e]=a.GetValue(e);const h=r.GetNumberOfEncodedPoints(),l=3*r.GetNumberOfEncodedFaces();return d.destroy(a),d.destroy(n),d.destroy(o),d.destroy(r),{numVertices:h,numIndices:l,data:u,attributeIDs:i}}function y(e){return"POSITION"===e?C.POSITION:"NORMAL"===e?C.NORMAL:e.startsWith("COLOR_")?C.COLOR:e.startsWith("TEXCOORD_")?C.TEX_COORD:C.GENERIC}const S={[s.ComponentType.UNSIGNED_BYTE]:"AddUInt8Attribute",[s.ComponentType.BYTE]:"AddInt8Attribute",[s.ComponentType.UNSIGNED_SHORT]:"AddUInt16Attribute",[s.ComponentType.SHORT]:"AddInt16Attribute",[s.ComponentType.UNSIGNED_INT]:"AddUInt32Attribute",[s.ComponentType.FLOAT]:"AddFloatAttribute"},A="KHR_draco_mesh_compression";class F extends e{constructor(){super(...arguments),this.extensionName=A,this.prereadTypes=[t.PRIMITIVE],this.prewriteTypes=[t.ACCESSOR],this.dependencies=["draco3d.decoder","draco3d.encoder"],this._encoderOptions={}}install(e,t){return"draco3d.decoder"===e&&(this._decoderModule=t,p=this._decoderModule,g={5126:Float32Array,5125:Uint32Array,5123:Uint16Array,5121:Uint8Array,5122:Int16Array,5120:Int8Array},f={5126:p.DT_FLOAT32,5125:p.DT_UINT32,5123:p.DT_UINT16,5121:p.DT_UINT8,5122:p.DT_INT16,5120:p.DT_INT8}),"draco3d.encoder"===e&&(this._encoderModule=t,d=this._encoderModule),this}setEncoderOptions(e){return this._encoderOptions=e,this}preread(e){if(!this._decoderModule)throw new Error(`[${A}] Please install extension dependency, "draco3d.decoder".`);const t=this.doc.getLogger(),s=e.jsonDoc,o=new Map;try{for(const n of s.json.meshes)for(const i of n.primitives){if(!i.extensions||!i.extensions[A])continue;const n=i.extensions[A];let[a,c]=o.get(n.bufferView)||[];if(!c){const e=s.json.bufferViews[n.bufferView],i=s.json.buffers[e.buffer],u=new Int8Array(i.uri?s.resources[i.uri]:s.resources[r],e.byteOffset||0,e.byteLength);a=new this._decoderModule.Decoder,c=T(a,u),o.set(n.bufferView,[a,c]),t.debug(`[${A}] Decompressed ${u.byteLength} bytes.`)}for(const t in i.attributes){const s=e.jsonDoc.json.accessors[i.attributes[t]],r=a.GetAttributeByUniqueId(c,n.attributes[t]),o=_(a,c,r,s);e.accessors[i.attributes[t]].setArray(o)}const u=m(a,c);e.accessors[i.indices].setArray(u)}}finally{for(const[e,t]of Array.from(o.values()))this._decoderModule.destroy(e),this._decoderModule.destroy(t)}return this}read(e){return this}prewrite(e,t){if(!this._encoderModule)throw new Error(`[${A}] Please install extension dependency, "draco3d.encoder".`);const s=this.doc.getLogger();s.debug(`[${A}] Compression options: ${JSON.stringify(this._encoderOptions)}`);const r=function(e){const t=e.getLogger(),s=new Set,r=new Set;for(const o of e.getRoot().listMeshes())for(const e of o.listPrimitives())e.getIndices()?4!==e.getMode()?(r.add(e),t.warn(`[${A}] Skipping Draco compression on non-TRIANGLES primitive.`)):s.add(e):(r.add(e),t.warn(`[${A}] Skipping Draco compression on non-indexed primitive.`));const o=e.getRoot().listAccessors(),n=new Map;for(let e=0;e<o.length;e++)n.set(o[e],e);const i=new Map,a=new Map;for(const e of Array.from(s)){const t=[];t.push(n.get(e.getIndices()));for(const s of e.listAttributes())t.push(n.get(s));const s=t.sort().join("|");a.set(e,s),i.set(e.getIndices(),s);for(const t of e.listAttributes())i.set(t,s)}for(const e of Array.from(i.keys())){const t=new Set(e.listParents().map(e=>e.propertyType));if(2!==t.size||!t.has("Primitive")||!t.has("Root"))throw new Error(`[${A}] Compressed accessors must only be used as indices or vertex attributes.`)}for(const e of Array.from(s)){const t=a.get(e);if(i.get(e.getIndices())!==t||e.listAttributes().some(e=>i.get(e)!==t))throw new Error(`[${A}] Draco primitives must share all, or no, accessors.`)}for(const e of Array.from(r))if(i.has(e.getIndices())||e.listAttributes().some(e=>i.has(e)))throw new Error(`[${A}] Accessor cannot be shared by compressed and uncompressed primitives.`);return a}(this.doc),o=new Map;for(const t of Array.from(r.keys())){const s=r.get(t);if(o.has(s)){o.set(s,o.get(s));continue}const n=N(t,this._encoderOptions);o.set(s,n);const i=e.createAccessorDef(t.getIndices());i.count=n.numIndices,e.accessorIndexMap.set(t.getIndices(),e.jsonDoc.json.accessors.length),e.jsonDoc.json.accessors.push(i);for(const s of t.listSemantics()){const r=t.getAttribute(s),o=e.createAccessorDef(r);o.count=n.numVertices,e.accessorIndexMap.set(r,e.jsonDoc.json.accessors.length),e.jsonDoc.json.accessors.push(o)}const a=t.getAttribute("POSITION").getBuffer()||this.doc.getRoot().listBuffers()[0];e.otherBufferViews.has(a)||e.otherBufferViews.set(a,[]),e.otherBufferViews.get(a).push(n.data)}return s.debug(`[${A}] Compressed ${r.size} primitives.`),e.extensionData[A]={primitiveHashMap:r,primitiveEncodingMap:o},this}write(e){const t=e.extensionData[A];for(const s of this.doc.getRoot().listMeshes()){const r=e.jsonDoc.json.meshes[e.meshIndexMap.get(s)];for(let o=0;o<s.listPrimitives().length;o++){const n=s.listPrimitives()[o],i=r.primitives[o],a=t.primitiveHashMap.get(n);if(!a)continue;const c=t.primitiveEncodingMap.get(a);i.extensions=i.extensions||{},i.extensions[A]={bufferView:e.otherBufferViewsIndexMap.get(c.data),attributes:c.attributeIDs}}}return this}}var M;F.EXTENSION_NAME=A,F.EncoderMethod=I,function(e){e.POINT="point",e.SPOT="spot",e.DIRECTIONAL="directional"}(M||(M={}));class O extends o{constructor(){super(...arguments),this.propertyType="Light",this.parentTypes=[t.NODE],this.extensionName="KHR_lights_punctual",this._color=[1,1,1],this._intensity=1,this._range=void 0,this._innerConeAngle=0,this._outerConeAngle=Math.PI/4}copy(e,t=n){return super.copy(e,t),this._color=[...e._color],this._intensity=e._intensity,this._type=e._type,this._range=e._range,this._innerConeAngle=e._innerConeAngle,this._outerConeAngle=e._outerConeAngle,this}getColor(){return this._color}setColor(e){return this._color=e,this}getColorHex(){return i.factorToHex(this._color)}setColorHex(e){return i.hexToFactor(e,this._color),this}getIntensity(){return this._intensity}setIntensity(e){return this._intensity=e,this}getType(){return this._type}setType(e){return this._type=e,this}getRange(){return this._range}setRange(e){return this._range=e,this}getInnerConeAngle(){return this._innerConeAngle}setInnerConeAngle(e){return this._innerConeAngle=e,this}getOuterConeAngle(){return this._outerConeAngle}setOuterConeAngle(e){return this._outerConeAngle=e,this}}O.EXTENSION_NAME="KHR_lights_punctual";const v="KHR_lights_punctual";class D extends e{constructor(){super(...arguments),this.extensionName=v}createLight(){return new O(this.doc.getGraph(),this)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions[v])return this;const s=(t.json.extensions[v].lights||[]).map(e=>{const t=this.createLight().setName(e.name||"").setType(e.type);return void 0!==e.color&&t.setColor(e.color),void 0!==e.intensity&&t.setIntensity(e.intensity),void 0!==e.range&&t.setRange(e.range),void 0!==e.innerConeAngle&&t.setInnerConeAngle(e.innerConeAngle),void 0!==e.outerConeAngle&&t.setOuterConeAngle(e.outerConeAngle),t});return t.json.nodes.forEach((t,r)=>{t.extensions&&t.extensions[v]&&e.nodes[r].setExtension(v,s[t.extensions[v].light])}),this}write(e){const t=e.jsonDoc;if(0===this.properties.size)return this;const s=[],r=new Map;for(const e of this.properties){const t=e,o={type:t.getType(),color:t.getColor(),intensity:t.getIntensity(),range:t.getRange()};t.getName()&&(o.name=t.getName()),t.getType()===M.SPOT&&(o.innerConeAngle=t.getInnerConeAngle(),o.outerConeAngle=t.getOuterConeAngle()),s.push(o),r.set(t,s.length-1)}return this.doc.getRoot().listNodes().forEach(s=>{const o=s.getExtension(v);if(o){const n=e.nodeIndexMap.get(s),i=t.json.nodes[n];i.extensions=i.extensions||{},i.extensions[v]={light:r.get(o)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[v]={lights:s},this}}function w(e,t,s,r){var o,n=arguments.length,i=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,s,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(i=(n<3?o(i):n>3?o(t,s,i):o(t,s))||i);return n>3&&i&&Object.defineProperty(t,s,i),i}D.EXTENSION_NAME=v;class j extends o{constructor(){super(...arguments),this.propertyType="Clearcoat",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_clearcoat",this._clearcoatFactor=0,this._clearcoatRoughnessFactor=0,this._clearcoatNormalScale=1,this.clearcoatTexture=null,this.clearcoatTextureInfo=this.graph.link("clearcoatTextureInfo",this,new a(this.graph)),this.clearcoatRoughnessTexture=null,this.clearcoatRoughnessTextureInfo=this.graph.link("clearcoatRoughnessTextureInfo",this,new a(this.graph)),this.clearcoatNormalTexture=null,this.clearcoatNormalTextureInfo=this.graph.link("clearcoatNormalTextureInfo",this,new a(this.graph))}copy(e,t=n){return super.copy(e,t),this._clearcoatFactor=e._clearcoatFactor,this._clearcoatRoughnessFactor=e._clearcoatRoughnessFactor,this._clearcoatNormalScale=e._clearcoatNormalScale,e.clearcoatTexture&&(this.setClearcoatTexture(t(e.clearcoatTexture.getChild())),this.getClearcoatTextureInfo().copy(t(e.clearcoatTextureInfo.getChild()),t)),e.clearcoatRoughnessTexture&&(this.setClearcoatRoughnessTexture(t(e.clearcoatRoughnessTexture.getChild())),this.getClearcoatRoughnessTextureInfo().copy(t(e.clearcoatRoughnessTextureInfo.getChild()),t)),e.clearcoatNormalTexture&&(this.setClearcoatNormalTexture(t(e.clearcoatNormalTexture.getChild())),this.getClearcoatNormalTextureInfo().copy(t(e.clearcoatNormalTextureInfo.getChild()),t)),this}dispose(){this.clearcoatTextureInfo.getChild().dispose(),this.clearcoatRoughnessTextureInfo.getChild().dispose(),this.clearcoatNormalTextureInfo.getChild().dispose(),super.dispose()}getClearcoatFactor(){return this._clearcoatFactor}setClearcoatFactor(e){return this._clearcoatFactor=e,this}getClearcoatTexture(){return this.clearcoatTexture?this.clearcoatTexture.getChild():null}getClearcoatTextureInfo(){return this.clearcoatTexture?this.clearcoatTextureInfo.getChild():null}setClearcoatTexture(e){return this.clearcoatTexture=this.graph.link("clearcoatTexture",this,e),this}getClearcoatRoughnessFactor(){return this._clearcoatRoughnessFactor}setClearcoatRoughnessFactor(e){return this._clearcoatRoughnessFactor=e,this}getClearcoatRoughnessTexture(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.getChild():null}getClearcoatRoughnessTextureInfo(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTextureInfo.getChild():null}setClearcoatRoughnessTexture(e){return this.clearcoatRoughnessTexture=this.graph.link("clearcoatRoughnessTexture",this,e),this}getClearcoatNormalScale(){return this._clearcoatNormalScale}setClearcoatNormalScale(e){return this._clearcoatNormalScale=e,this}getClearcoatNormalTexture(){return this.clearcoatNormalTexture?this.clearcoatNormalTexture.getChild():null}getClearcoatNormalTextureInfo(){return this.clearcoatNormalTexture?this.clearcoatNormalTextureInfo.getChild():null}setClearcoatNormalTexture(e){return this.clearcoatNormalTexture=this.graph.link("clearcoatNormalTexture",this,e),this}}j.EXTENSION_NAME="KHR_materials_clearcoat",w([c],j.prototype,"clearcoatTexture",void 0),w([c],j.prototype,"clearcoatTextureInfo",void 0),w([c],j.prototype,"clearcoatRoughnessTexture",void 0),w([c],j.prototype,"clearcoatRoughnessTextureInfo",void 0),w([c],j.prototype,"clearcoatNormalTexture",void 0),w([c],j.prototype,"clearcoatNormalTextureInfo",void 0);const G="KHR_materials_clearcoat";class H extends e{constructor(){super(...arguments),this.extensionName=G}createClearcoat(){return new j(this.doc.getGraph(),this)}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,r)=>{if(t.extensions&&t.extensions[G]){const o=this.createClearcoat();if(e.materials[r].setExtension(G,o),void 0!==t.extensions[G].clearcoatFactor&&o.setClearcoatFactor(t.extensions[G].clearcoatFactor),void 0!==t.extensions[G].clearcoatRoughnessFactor&&o.setClearcoatRoughnessFactor(t.extensions[G].clearcoatRoughnessFactor),void 0!==t.extensions[G].clearcoatTexture){const r=t.extensions[G].clearcoatTexture;o.setClearcoatTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getClearcoatTextureInfo(),r)}if(void 0!==t.extensions[G].clearcoatRoughnessTexture){const r=t.extensions[G].clearcoatRoughnessTexture;o.setClearcoatRoughnessTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getClearcoatRoughnessTextureInfo(),r)}if(void 0!==t.extensions[G].clearcoatNormalTexture){const r=t.extensions[G].clearcoatNormalTexture;o.setClearcoatNormalTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getClearcoatNormalTextureInfo(),r),void 0!==r.scale&&o.setClearcoatNormalScale(r.scale)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(G);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[G]={clearcoatFactor:r.getClearcoatFactor(),clearcoatRoughnessFactor:r.getClearcoatRoughnessFactor()},r.getClearcoatTexture()){const t=r.getClearcoatTexture(),s=r.getClearcoatTextureInfo();n.extensions[G].clearcoatTexture=e.createTextureInfoDef(t,s)}if(r.getClearcoatRoughnessTexture()){const t=r.getClearcoatRoughnessTexture(),s=r.getClearcoatRoughnessTextureInfo();n.extensions[G].clearcoatRoughnessTexture=e.createTextureInfoDef(t,s)}if(r.getClearcoatNormalTexture()){const t=r.getClearcoatNormalTexture(),s=r.getClearcoatNormalTextureInfo();n.extensions[G].clearcoatNormalTexture=e.createTextureInfoDef(t,s),1!==r.getClearcoatNormalScale()&&(n.extensions[G].clearcoatNormalTexture.scale=r.getClearcoatNormalScale())}}}),this}}H.EXTENSION_NAME=G;class b extends o{constructor(){super(...arguments),this.propertyType="IOR",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_ior",this._ior=0}copy(e,t=n){return super.copy(e,t),this._ior=e._ior,this}getIOR(){return this._ior}setIOR(e){return this._ior=e,this}}b.EXTENSION_NAME="KHR_materials_ior";const L="KHR_materials_ior";class K extends e{constructor(){super(...arguments),this.extensionName=L}createIOR(){return new b(this.doc.getGraph(),this)}read(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{if(t.extensions&&t.extensions[L]){const r=this.createIOR();e.materials[s].setExtension(L,r),void 0!==t.extensions[L].ior&&r.setIOR(t.extensions[L].ior)}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(L);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];n.extensions=n.extensions||{},n.extensions[L]={ior:r.getIOR()}}}),this}}K.EXTENSION_NAME=L;class P extends o{constructor(){super(...arguments),this.propertyType="PBRSpecularGlossiness",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_pbrSpecularGlossiness",this._diffuseFactor=[1,1,1,1],this._specularFactor=[1,1,1],this._glossinessFactor=1,this.diffuseTexture=null,this.diffuseTextureInfo=this.graph.link("diffuseTextureInfo",this,new a(this.graph)),this.specularGlossinessTexture=null,this.specularGlossinessTextureInfo=this.graph.link("specularGlossinessTextureInfo",this,new a(this.graph))}copy(e,t=n){return super.copy(e,t),this._diffuseFactor=e._diffuseFactor,this._specularFactor=e._specularFactor,this._glossinessFactor=e._glossinessFactor,e.diffuseTexture&&(this.setDiffuseTexture(t(e.diffuseTexture.getChild())),this.getDiffuseTextureInfo().copy(t(e.diffuseTextureInfo.getChild()),t)),e.specularGlossinessTexture&&(this.setSpecularGlossinessTexture(t(e.specularGlossinessTexture.getChild())),this.getSpecularGlossinessTextureInfo().copy(t(e.specularGlossinessTextureInfo.getChild()),t)),this}dispose(){this.diffuseTextureInfo.getChild().dispose(),this.specularGlossinessTextureInfo.getChild().dispose(),super.dispose()}getDiffuseFactor(){return this._diffuseFactor}setDiffuseFactor(e){return this._diffuseFactor=e,this}getDiffuseHex(){return i.factorToHex(this._diffuseFactor)}setDiffuseHex(e){return i.hexToFactor(e,this._diffuseFactor),this}getDiffuseTexture(){return this.diffuseTexture?this.diffuseTexture.getChild():null}getDiffuseTextureInfo(){return this.diffuseTexture?this.diffuseTextureInfo.getChild():null}setDiffuseTexture(e){return this.diffuseTexture=this.graph.link("diffuseTexture",this,e),this}getSpecularFactor(){return this._specularFactor}setSpecularFactor(e){return this._specularFactor=e,this}getGlossinessFactor(){return this._glossinessFactor}setGlossinessFactor(e){return this._glossinessFactor=e,this}getSpecularGlossinessTexture(){return this.specularGlossinessTexture?this.specularGlossinessTexture.getChild():null}getSpecularGlossinessTextureInfo(){return this.specularGlossinessTexture?this.specularGlossinessTextureInfo.getChild():null}setSpecularGlossinessTexture(e){return this.specularGlossinessTexture=this.graph.link("specularGlossinessTexture",this,e),this}}P.EXTENSION_NAME="KHR_materials_pbrSpecularGlossiness",w([c],P.prototype,"diffuseTexture",void 0),w([c],P.prototype,"diffuseTextureInfo",void 0),w([c],P.prototype,"specularGlossinessTexture",void 0),w([c],P.prototype,"specularGlossinessTextureInfo",void 0);const X="KHR_materials_pbrSpecularGlossiness";class k extends e{constructor(){super(...arguments),this.extensionName=X}createPBRSpecularGlossiness(){return new P(this.doc.getGraph(),this)}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,r)=>{if(t.extensions&&t.extensions[X]){const o=this.createPBRSpecularGlossiness();if(e.materials[r].setExtension(X,o),void 0!==t.extensions[X].diffuseFactor&&o.setDiffuseFactor(t.extensions[X].diffuseFactor),void 0!==t.extensions[X].specularFactor&&o.setSpecularFactor(t.extensions[X].specularFactor),void 0!==t.extensions[X].glossinessFactor&&o.setGlossinessFactor(t.extensions[X].glossinessFactor),void 0!==t.extensions[X].diffuseTexture){const r=t.extensions[X].diffuseTexture;o.setDiffuseTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getDiffuseTextureInfo(),r)}if(void 0!==t.extensions[X].specularGlossinessTexture){const r=t.extensions[X].specularGlossinessTexture;o.setSpecularGlossinessTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getSpecularGlossinessTextureInfo(),r)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(X);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[X]={diffuseFactor:r.getDiffuseFactor(),specularFactor:r.getSpecularFactor(),glossinessFactor:r.getGlossinessFactor()},r.getDiffuseTexture()){const t=r.getDiffuseTexture(),s=r.getDiffuseTextureInfo();n.extensions[X].diffuseTexture=e.createTextureInfoDef(t,s)}if(r.getSpecularGlossinessTexture()){const t=r.getSpecularGlossinessTexture(),s=r.getSpecularGlossinessTextureInfo();n.extensions[X].specularGlossinessTexture=e.createTextureInfoDef(t,s)}}}),this}}k.EXTENSION_NAME=X;class U extends o{constructor(){super(...arguments),this.propertyType="Sheen",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_sheen",this._sheenColorFactor=[0,0,0],this._sheenRoughnessFactor=0,this.sheenColorTexture=null,this.sheenColorTextureInfo=this.graph.link("sheenColorTextureInfo",this,new a(this.graph)),this.sheenRoughnessTexture=null,this.sheenRoughnessTextureInfo=this.graph.link("sheenRoughnessTextureInfo",this,new a(this.graph))}copy(e,t=n){return super.copy(e,t),this._sheenColorFactor=e._sheenColorFactor,this._sheenRoughnessFactor=e._sheenRoughnessFactor,e.sheenColorTexture&&(this.setSheenColorTexture(t(e.sheenColorTexture.getChild())),this.getSheenColorTextureInfo().copy(t(e.sheenColorTextureInfo.getChild()),t)),e.sheenRoughnessTexture&&(this.setSheenRoughnessTexture(t(e.sheenRoughnessTexture.getChild())),this.getSheenRoughnessTextureInfo().copy(t(e.sheenRoughnessTextureInfo.getChild()),t)),this}dispose(){this.sheenColorTextureInfo.getChild().dispose(),this.sheenRoughnessTextureInfo.getChild().dispose(),super.dispose()}getSheenColorFactor(){return this._sheenColorFactor}getSheenColorHex(){return i.factorToHex(this._sheenColorFactor)}setSheenColorFactor(e){return this._sheenColorFactor=e,this}setSheenColorHex(e){return i.hexToFactor(e,this._sheenColorFactor),this}getSheenColorTexture(){return this.sheenColorTexture?this.sheenColorTexture.getChild():null}getSheenColorTextureInfo(){return this.sheenColorTexture?this.sheenColorTextureInfo.getChild():null}setSheenColorTexture(e){return this.sheenColorTexture=this.graph.link("sheenColorTexture",this,e),this}getSheenRoughnessFactor(){return this._sheenRoughnessFactor}setSheenRoughnessFactor(e){return this._sheenRoughnessFactor=e,this}getSheenRoughnessTexture(){return this.sheenRoughnessTexture?this.sheenRoughnessTexture.getChild():null}getSheenRoughnessTextureInfo(){return this.sheenRoughnessTexture?this.sheenRoughnessTextureInfo.getChild():null}setSheenRoughnessTexture(e){return this.sheenRoughnessTexture=this.graph.link("sheenRoughnessTexture",this,e),this}}U.EXTENSION_NAME="KHR_materials_sheen",w([c],U.prototype,"sheenColorTexture",void 0),w([c],U.prototype,"sheenColorTextureInfo",void 0),w([c],U.prototype,"sheenRoughnessTexture",void 0),w([c],U.prototype,"sheenRoughnessTextureInfo",void 0);const B="KHR_materials_sheen";class V extends e{constructor(){super(...arguments),this.extensionName=B}createSheen(){return new U(this.doc.getGraph(),this)}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,r)=>{if(t.extensions&&t.extensions[B]){const o=this.createSheen();if(e.materials[r].setExtension(B,o),void 0!==t.extensions[B].sheenColorFactor&&o.setSheenColorFactor(t.extensions[B].sheenColorFactor),void 0!==t.extensions[B].sheenRoughnessFactor&&o.setSheenRoughnessFactor(t.extensions[B].sheenRoughnessFactor),void 0!==t.extensions[B].sheenColorTexture){const r=t.extensions[B].sheenColorTexture;o.setSheenColorTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getSheenColorTextureInfo(),r)}if(void 0!==t.extensions[B].sheenRoughnessTexture){const r=t.extensions[B].sheenRoughnessTexture;o.setSheenRoughnessTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getSheenRoughnessTextureInfo(),r)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(B);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[B]={sheenColorFactor:r.getSheenColorFactor(),sheenRoughnessFactor:r.getSheenRoughnessFactor()},r.getSheenColorTexture()){const t=r.getSheenColorTexture(),s=r.getSheenColorTextureInfo();n.extensions[B].sheenColorTexture=e.createTextureInfoDef(t,s)}if(r.getSheenRoughnessTexture()){const t=r.getSheenRoughnessTexture(),s=r.getSheenRoughnessTextureInfo();n.extensions[B].sheenRoughnessTexture=e.createTextureInfoDef(t,s)}}}),this}}V.EXTENSION_NAME=B;class $ extends o{constructor(){super(...arguments),this.propertyType="Specular",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_specular",this._specularFactor=1,this._specularColorFactor=[1,1,1],this.specularTexture=null,this.specularTextureInfo=this.graph.link("specularTextureInfo",this,new a(this.graph))}copy(e,t=n){return super.copy(e,t),this._specularFactor=e._specularFactor,e.specularTexture&&(this.setSpecularTexture(t(e.specularTexture.getChild())),this.getSpecularTextureInfo().copy(t(e.specularTextureInfo.getChild()),t)),this}dispose(){this.specularTextureInfo.getChild().dispose(),super.dispose()}getSpecularFactor(){return this._specularFactor}setSpecularFactor(e){return this._specularFactor=e,this}getSpecularColorFactor(){return this._specularColorFactor}setSpecularColorFactor(e){return this._specularColorFactor=e,this}getSpecularColorHex(){return i.factorToHex(this._specularColorFactor)}setSpecularColorHex(e){return i.hexToFactor(e,this._specularColorFactor),this}getSpecularTexture(){return this.specularTexture?this.specularTexture.getChild():null}getSpecularTextureInfo(){return this.specularTexture?this.specularTextureInfo.getChild():null}setSpecularTexture(e){return this.specularTexture=this.graph.link("specularTexture",this,e),this}}$.EXTENSION_NAME="KHR_materials_specular",w([c],$.prototype,"specularTexture",void 0),w([c],$.prototype,"specularTextureInfo",void 0);const z="KHR_materials_specular";class q extends e{constructor(){super(...arguments),this.extensionName=z}createSpecular(){return new $(this.doc.getGraph(),this)}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,r)=>{if(t.extensions&&t.extensions[z]){const o=this.createSpecular();if(e.materials[r].setExtension(z,o),void 0!==t.extensions[z].specularFactor&&o.setSpecularFactor(t.extensions[z].specularFactor),void 0!==t.extensions[z].specularColorFactor&&o.setSpecularColorFactor(t.extensions[z].specularColorFactor),void 0!==t.extensions[z].specularTexture){const r=t.extensions[z].specularTexture;o.setSpecularTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getSpecularTextureInfo(),r)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(z);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[z]={specularFactor:r.getSpecularFactor(),specularColorFactor:r.getSpecularColorFactor()},r.getSpecularTexture()){const t=r.getSpecularTexture(),s=r.getSpecularTextureInfo();n.extensions[z].specularTexture=e.createTextureInfoDef(t,s)}}}),this}}q.EXTENSION_NAME=z;class Q extends o{constructor(){super(...arguments),this.propertyType="Transmission",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_transmission",this._transmissionFactor=0,this.transmissionTexture=null,this.transmissionTextureInfo=this.graph.link("transmissionTextureInfo",this,new a(this.graph))}copy(e,t=n){return super.copy(e,t),this._transmissionFactor=e._transmissionFactor,e.transmissionTexture&&(this.setTransmissionTexture(t(e.transmissionTexture.getChild())),this.getTransmissionTextureInfo().copy(t(e.transmissionTextureInfo.getChild()),t)),this}dispose(){this.transmissionTextureInfo.getChild().dispose(),super.dispose()}getTransmissionFactor(){return this._transmissionFactor}setTransmissionFactor(e){return this._transmissionFactor=e,this}getTransmissionTexture(){return this.transmissionTexture?this.transmissionTexture.getChild():null}getTransmissionTextureInfo(){return this.transmissionTexture?this.transmissionTextureInfo.getChild():null}setTransmissionTexture(e){return this.transmissionTexture=this.graph.link("transmissionTexture",this,e),this}}Q.EXTENSION_NAME="KHR_materials_transmission",w([c],Q.prototype,"transmissionTexture",void 0),w([c],Q.prototype,"transmissionTextureInfo",void 0);const Y="KHR_materials_transmission";class W extends e{constructor(){super(...arguments),this.extensionName=Y}createTransmission(){return new Q(this.doc.getGraph(),this)}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,r)=>{if(t.extensions&&t.extensions[Y]){const o=this.createTransmission();if(e.materials[r].setExtension(Y,o),void 0!==t.extensions[Y].transmissionFactor&&o.setTransmissionFactor(t.extensions[Y].transmissionFactor),void 0!==t.extensions[Y].transmissionTexture){const r=t.extensions[Y].transmissionTexture;o.setTransmissionTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getTransmissionTextureInfo(),r)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(Y);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[Y]={transmissionFactor:r.getTransmissionFactor()},r.getTransmissionTexture()){const t=r.getTransmissionTexture(),s=r.getTransmissionTextureInfo();n.extensions[Y].transmissionTexture=e.createTextureInfoDef(t,s)}}}),this}}W.EXTENSION_NAME=Y;class J extends o{constructor(){super(...arguments),this.propertyType="Unlit",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_unlit"}}J.EXTENSION_NAME="KHR_materials_unlit";const Z="KHR_materials_unlit";class ee extends e{constructor(){super(...arguments),this.extensionName=Z}createUnlit(){return new J(this.doc.getGraph(),this)}read(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{t.extensions&&t.extensions[Z]&&e.materials[s].setExtension(Z,this.createUnlit())}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{if(s.getExtension(Z)){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{},o.extensions[Z]={}}}),this}}ee.EXTENSION_NAME=Z;class te extends o{constructor(){super(...arguments),this.propertyType="Mapping",this.parentTypes=["MappingList"],this.extensionName="KHR_materials_variants",this.material=null,this.variants=[]}copy(e,t=n){return super.copy(e,t),e.material&&this.setMaterial(t(e.material.getChild())),this.clearGraphChildList(this.variants),e.variants.forEach(e=>this.addVariant(t(e.getChild()))),this}getMaterial(){return this.material?this.material.getChild():null}setMaterial(e){return this.material=this.graph.link("material",this,e),this}addVariant(e){const t=this.graph.link("variant",this,e);return this.addGraphChild(this.variants,t)}removeVariant(e){return this.removeGraphChild(this.variants,e)}listVariants(){return this.variants.map(e=>e.getChild())}}te.EXTENSION_NAME="KHR_materials_variants",w([c],te.prototype,"material",void 0),w([u],te.prototype,"variants",void 0);class se extends o{constructor(){super(...arguments),this.propertyType="MappingList",this.parentTypes=[t.PRIMITIVE],this.extensionName="KHR_materials_variants",this.mappings=[]}copy(e,t=n){return super.copy(e,t),this.clearGraphChildList(this.mappings),e.mappings.forEach(e=>this.addMapping(t(e.getChild()))),this}addMapping(e){const t=this.graph.link("mapping",this,e);return this.addGraphChild(this.mappings,t)}removeMapping(e){return this.removeGraphChild(this.mappings,e)}listMappings(){return this.mappings.map(e=>e.getChild())}}se.EXTENSION_NAME="KHR_materials_variants",w([u],se.prototype,"mappings",void 0);class re extends o{constructor(){super(...arguments),this.propertyType="Variant",this.parentTypes=[t.ROOT,"MappingList"],this.extensionName="KHR_materials_variants"}}re.EXTENSION_NAME="KHR_materials_variants";const oe="KHR_materials_variants";class ne extends e{constructor(){super(...arguments),this.extensionName=oe}createMappingList(){return new se(this.doc.getGraph(),this)}createVariant(e=""){return new re(this.doc.getGraph(),this).setName(e)}createMapping(){return new te(this.doc.getGraph(),this)}listVariants(){return Array.from(this.properties).filter(e=>e instanceof re)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions[oe])return this;const s=(t.json.extensions[oe].variants||[]).map(e=>this.createVariant().setName(e.name||""));return(t.json.meshes||[]).forEach((t,r)=>{const o=e.meshes[r];(t.primitives||[]).forEach((t,r)=>{if(!t.extensions||!t.extensions[oe])return;const n=this.createMappingList();for(const r of t.extensions[oe].mappings){const t=this.createMapping();void 0!==r.material&&t.setMaterial(e.materials[r.material]);for(const e of r.variants||[])t.addVariant(s[e]);n.addMapping(t)}o.listPrimitives()[r].setExtension(oe,n)})}),this}write(e){const t=e.jsonDoc,s=this.listVariants();if(!s.length)return this;const r=[],o=new Map;for(const t of s)o.set(t,r.length),r.push(e.createPropertyDef(t));for(const t of this.doc.getRoot().listMeshes()){const s=e.meshIndexMap.get(t);t.listPrimitives().forEach((t,r)=>{if(!t.getExtension(oe))return;const n=e.jsonDoc.json.meshes[s].primitives[r],i=t.getExtension(oe).listMappings().map(t=>{const s=e.createPropertyDef(t);return t.getMaterial()&&(s.material=e.materialIndexMap.get(t.getMaterial())),s.variants=t.listVariants().map(e=>o.get(e)),s});n.extensions=n.extensions||{},n.extensions[oe]={mappings:i}})}return t.json.extensions=t.json.extensions||{},t.json.extensions[oe]={variants:r},this}}ne.EXTENSION_NAME=oe;const ie="KHR_mesh_quantization";class ae extends e{constructor(){super(...arguments),this.extensionName=ie}read(e){return this}write(e){return this}}ae.EXTENSION_NAME=ie;const ce="KHR_texture_basisu";class ue extends e{constructor(){super(...arguments),this.extensionName=ce,this.prereadTypes=[t.TEXTURE]}preread(e){return e.jsonDoc.json.textures.forEach(e=>{e.extensions&&e.extensions[ce]&&(e.source=e.extensions[ce].source)}),this}read(e){return this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listTextures().forEach(s=>{if("image/ktx2"===s.getMimeType()){const r=e.imageIndexMap.get(s);t.json.textures.forEach(e=>{e.source===r&&(e.extensions=e.extensions||{},e.extensions[ce]={source:e.source},delete e.source)})}}),this}}ue.EXTENSION_NAME=ce;class he extends o{constructor(){super(...arguments),this.propertyType="Transform",this.parentTypes=[t.TEXTURE_INFO],this.extensionName="KHR_texture_transform",this._offset=[0,0],this._rotation=0,this._scale=[1,1],this._texCoord=void 0}copy(e,t=n){return super.copy(e,t),this._offset=e._offset,this._rotation=e._rotation,this._scale=e._scale,this._texCoord=e._texCoord,this}getOffset(){return this._offset}setOffset(e){return this._offset=e,this}getRotation(){return this._rotation}setRotation(e){return this._rotation=e,this}getScale(){return this._scale}setScale(e){return this._scale=e,this}getTexCoord(){return this._texCoord}setTexCoord(e){return this._texCoord=e,this}}he.EXTENSION_NAME="KHR_texture_transform";const le="KHR_texture_transform";class xe extends e{constructor(){super(...arguments),this.extensionName=le}createTransform(){return new he(this.doc.getGraph(),this)}read(e){for(const[t,s]of Array.from(e.textureInfos.entries())){if(!s.extensions||!s.extensions[le])continue;const e=this.createTransform(),r=s.extensions[le];void 0!==r.offset&&e.setOffset(r.offset),void 0!==r.rotation&&e.setRotation(r.rotation),void 0!==r.scale&&e.setScale(r.scale),void 0!==r.texCoord&&e.setTexCoord(r.texCoord),t.setExtension(le,e)}return this}write(e){const t=Array.from(e.textureInfoDefMap.entries());for(const[e,s]of t){const t=e.getExtension(le);t&&(s.extensions=s.extensions||{},s.extensions[le]={offset:t.getOffset(),rotation:t.getRotation(),scale:t.getScale(),texCoord:t.getTexCoord()})}return this}}xe.EXTENSION_NAME=le;const pe=[F,D,H,K,k,q,V,W,ee,ne,ae,ue,xe],ge=[l,...pe];export{ge as ALL_EXTENSIONS,j as Clearcoat,F as DracoMeshCompression,b as IOR,pe as KHRONOS_EXTENSIONS,O as Light,M as LightType,D as LightsPunctual,te as Mapping,se as MappingList,H as MaterialsClearcoat,K as MaterialsIOR,k as MaterialsPBRSpecularGlossiness,V as MaterialsSheen,q as MaterialsSpecular,W as MaterialsTransmission,ee as MaterialsUnlit,ne as MaterialsVariants,ae as MeshQuantization,P as PBRSpecularGlossiness,U as Sheen,$ as Specular,ue as TextureBasisu,xe as TextureTransform,l as TextureWebP,he as Transform,Q as Transmission,J as Unlit,re as Variant};
//# sourceMappingURL=extensions.modern.js.map
import { GLTF, TypedArray } from '@gltf-transform/core';
import { DRACO } from '../types/draco3d';
export declare let decoderModule: DRACO.DecoderModule;
export declare function decodeGeometry(decoder: DRACO.Decoder, arrayBuffer: ArrayBuffer): DRACO.Mesh;
export declare function decodeGeometry(decoder: DRACO.Decoder, data: Int8Array): DRACO.Mesh;
export declare function decodeIndex(decoder: DRACO.Decoder, mesh: DRACO.Mesh): Uint32Array;
export declare function decodeAttribute(decoder: DRACO.Decoder, mesh: DRACO.Mesh, attribute: DRACO.Attribute, accessorDef: GLTF.IAccessor): TypedArray;
export declare function initDecoderModule(_decoderModule: DRACO.DecoderModule): void;
{
"name": "@gltf-transform/extensions",
"version": "0.8.1",
"version": "0.8.4",
"repository": "github:donmccurdy/glTF-Transform",

@@ -24,3 +24,3 @@ "description": "Adds extension support to @gltf-transform/core",

"dependencies": {
"@gltf-transform/core": "^0.8.1"
"@gltf-transform/core": "^0.8.4"
},

@@ -33,3 +33,3 @@ "files": [

],
"gitHead": "0a4bd744cedbfd87c0dd46f4c38337b5951da97c"
"gitHead": "c0f5e0e9983dfa3bda71dd3687d762422b71ac17"
}
import { GLTF, TypedArray, TypedArrayConstructor } from '@gltf-transform/core';
import { KHR_DRACO_MESH_COMPRESSION } from '../constants';
import { DRACO } from '../types/draco3d';
const NAME = KHR_DRACO_MESH_COMPRESSION;
export let decoderModule: DRACO.DecoderModule;

@@ -10,11 +13,11 @@

export function decodeGeometry(decoder: DRACO.Decoder, arrayBuffer: ArrayBuffer): DRACO.Mesh {
export function decodeGeometry(decoder: DRACO.Decoder, data: Int8Array): DRACO.Mesh {
let buffer: DRACO.DecoderBuffer;
try {
buffer = new decoderModule.DecoderBuffer();
buffer.Init(new Int8Array(arrayBuffer), arrayBuffer.byteLength);
buffer.Init(data, data.length);
const geometryType = decoder.GetEncodedGeometryType(buffer);
if (geometryType !== decoderModule.TRIANGULAR_MESH) {
throw new Error('Unknown geometry type.');
throw new Error(`[${NAME}] Unknown geometry type.`);
}

@@ -26,3 +29,3 @@

if (!status.ok() || dracoMesh.ptr === 0) {
throw new Error('Decoding failure.');
throw new Error(`[${NAME}] Decoding failure.`);
}

@@ -29,0 +32,0 @@

@@ -54,3 +54,3 @@ import { Accessor, Document, Extension, GLB_BUFFER, GLTF, Primitive, PropertyType, ReaderContext, WriterContext } from '@gltf-transform/core';

if (!this._decoderModule) {
throw new Error('Please install extension dependency, "draco3d.decoder".');
throw new Error(`[${NAME}] Please install extension dependency, "draco3d.decoder".`);
}

@@ -60,5 +60,6 @@

const jsonDoc = context.jsonDoc;
const decoder = new this._decoderModule.Decoder();
const dracoMeshes: Map<number, DRACO.Mesh> = new Map();
const dracoMeshes: Map<number, [DRACO.Decoder, DRACO.Mesh]> = new Map();
try {
for (const meshDef of jsonDoc.json.meshes) {

@@ -69,3 +70,3 @@ for (const primDef of meshDef.primitives) {

const dracoDef = primDef.extensions[NAME] as DracoPrimitiveExtension;
let dracoMesh = dracoMeshes.get(dracoDef.bufferView);
let [decoder, dracoMesh] = dracoMeshes.get(dracoDef.bufferView) || [];

@@ -81,7 +82,8 @@ if (!dracoMesh) {

const byteLength = bufferViewDef.byteLength;
const compressedData = new Uint8Array(resource, byteOffset, byteLength);
const compressedData = new Int8Array(resource, byteOffset, byteLength);
decoder = new this._decoderModule.Decoder();
dracoMesh = decodeGeometry(decoder, compressedData);
dracoMeshes.set(dracoDef.bufferView, dracoMesh);
logger.debug(`Decompressed ${compressedData.byteLength} bytes.`);
dracoMeshes.set(dracoDef.bufferView, [decoder, dracoMesh]);
logger.debug(`[${NAME}] Decompressed ${compressedData.byteLength} bytes.`);
}

@@ -104,5 +106,7 @@

}
}
this._decoderModule.destroy(decoder);
for (const dracoMesh of Array.from(dracoMeshes.values())) {
} finally {
for (const [decoder, dracoMesh] of Array.from(dracoMeshes.values())) {
this._decoderModule.destroy(decoder);
this._decoderModule.destroy(dracoMesh);

@@ -121,7 +125,7 @@ }

if (!this._encoderModule) {
throw new Error('Please install extension dependency, "draco3d.encoder".');
throw new Error(`[${NAME}] Please install extension dependency, "draco3d.encoder".`);
}
const logger = this.doc.getLogger();
logger.debug(`Draco compression options: ${JSON.stringify(this._encoderOptions)}`);
logger.debug(`[${NAME}] Compression options: ${JSON.stringify(this._encoderOptions)}`);

@@ -167,3 +171,3 @@ const primitiveHashMap = listDracoPrimitives(this.doc);

logger.debug(`Compressed ${primitiveHashMap.size} primitives.`);
logger.debug(`[${NAME}] Compressed ${primitiveHashMap.size} primitives.`);

@@ -216,6 +220,6 @@ context.extensionData[NAME] = {

excluded.add(prim);
logger.warn('Skipping Draco compression on non-indexed primitive.');
logger.warn(`[${NAME}] Skipping Draco compression on non-indexed primitive.`);
} else if (prim.getMode() !== GLTF.MeshPrimitiveMode.TRIANGLES) {
excluded.add(prim);
logger.warn('Skipping Draco compression on non-TRIANGLES primitive.');
logger.warn(`[${NAME}] Skipping Draco compression on non-TRIANGLES primitive.`);
} else {

@@ -257,3 +261,3 @@ included.add(prim);

throw new Error(
'Compressed accessors must only be used as indices or vertex attributes.'
`[${NAME}] Compressed accessors must only be used as indices or vertex attributes.`
);

@@ -268,3 +272,3 @@ }

|| prim.listAttributes().some((attr) => includedAccessors.get(attr) !== hashKey)) {
throw new Error('Draco primitives must share all, or no, accessors.')
throw new Error(`[${NAME}] Draco primitives must share all, or no, accessors.`)
}

@@ -277,3 +281,3 @@ }

|| prim.listAttributes().some((attr) => includedAccessors.has(attr))) {
throw new Error('Accessor cannot be shared by compressed and uncompressed primitives.');
throw new Error(`[${NAME}] Accessor cannot be shared by compressed and uncompressed primitives.`);
}

@@ -280,0 +284,0 @@ }

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