@gltf-transform/extensions
Advanced tools
Comparing version 0.9.9 to 0.9.10
@@ -1,2 +0,2 @@ | ||
var e=require("@gltf-transform/core"),t=require("ktx-parse");function r(){return(r=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 n(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,o(e,t)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function i(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 a(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return i(e,t);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)?i(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}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(r=e[Symbol.iterator]()).next.bind(r)}function u(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}var c=function(t){function r(){var r;return(r=t.apply(this,arguments)||this).propertyType="InstancedMesh",r.parentTypes=[e.PropertyType.NODE],r.extensionName="EXT_mesh_gpu_instancing",r.attributes=[],r}n(r,t);var o=r.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.attributes),r.listSemantics().forEach(function(e){o.setAttribute(e,n(r.getAttribute(e)))}),this},o.getAttribute=function(e){var t=this.attributes.find(function(t){return t.semantic===e});return t?t.getChild():null},o.setAttribute=function(e,t){var r=this.getAttribute(e);if(r&&this.removeGraphChild(this.attributes,r),!t)return this;var n=this.graph.linkAttribute(e.toLowerCase(),this,t);return n.semantic=e,this.addGraphChild(this.attributes,n)},o.listAttributes=function(){return this.attributes.map(function(e){return e.getChild()})},o.listSemantics=function(){return this.attributes.map(function(e){return e.semantic})},r}(e.ExtensionProperty);c.EXTENSION_NAME="EXT_mesh_gpu_instancing",u([e.GraphChildList],c.prototype,"attributes",void 0);var l="EXT_mesh_gpu_instancing",h=function(t){function r(){var r;return(r=t.apply(this,arguments)||this).extensionName=l,r.provideTypes=[e.PropertyType.NODE],r.prewriteTypes=[e.PropertyType.ACCESSOR],r}n(r,t);var o=r.prototype;return o.createInstancedMesh=function(){return new c(this.doc.getGraph(),this)},o.read=function(e){var t=this;return(e.jsonDoc.json.nodes||[]).forEach(function(r,n){if(r.extensions&&r.extensions[l]){var o=r.extensions[l],s=t.createInstancedMesh();for(var i in o.attributes)s.setAttribute(i,e.accessors[o.attributes[i]]);e.nodes[n].setExtension(l,s)}}),this},o.prewrite=function(e){e.accessorUsageGroupedByParent.add("INSTANCE_ATTRIBUTE");for(var t,r=a(this.properties);!(t=r()).done;)for(var n,o=a(t.value.listAttributes());!(n=o()).done;)e.setAccessorUsage(n.value,"INSTANCE_ATTRIBUTE");return this},o.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listNodes().forEach(function(r){var n=r.getExtension(l);if(n){var o=e.nodeIndexMap.get(r),s=t.json.nodes[o],i={attributes:{}};n.listSemantics().forEach(function(t){var r=n.getAttribute(t);i.attributes[t]=e.accessorIndexMap.get(r)}),s.extensions=s.extensions||{},s.extensions[l]=i}}),this},r}(e.Extension);h.EXTENSION_NAME=l;var p="EXT_texture_webp",f=function(){function t(){}var r=t.prototype;return r.getSize=function(t){var r=e.BufferUtils.decodeText(t.slice(0,4)),n=e.BufferUtils.decodeText(t.slice(8,12));if("RIFF"!==r||"WEBP"!==n)return null;for(var o=new DataView(t),s=12;s<t.byteLength;){var i=e.BufferUtils.decodeText(t.slice(s,s+4)),a=o.getUint32(s+4,!0);if("VP8 "===i)return[16383&o.getInt16(s+14,!0),16383&o.getInt16(s+16,!0)];if("VP8L"===i){var u=o.getUint8(s+9),c=o.getUint8(s+10),l=o.getUint8(s+11);return[1+((63&c)<<8|u),1+((15&o.getUint8(s+12))<<10|l<<2|(192&c)>>6)]}s+=8+a+a%2}return null},r.getChannels=function(e){return 4},t}(),x=function(t){function r(){var r;return(r=t.apply(this,arguments)||this).extensionName=p,r.prereadTypes=[e.PropertyType.TEXTURE],r}n(r,t),r.register=function(){e.ImageUtils.registerFormat("image/webp",new f)};var o=r.prototype;return o.preread=function(e){return(e.jsonDoc.json.textures||[]).forEach(function(e){e.extensions&&e.extensions[p]&&(e.source=e.extensions[p].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[p]={source:e.source},delete e.source)})}}),this},r}(e.Extension);x.EXTENSION_NAME=p;var T,g,d,v,m,y,I,C,_="KHR_draco_mesh_compression";function E(e,t){var r=new T.DecoderBuffer;try{if(r.Init(t,t.length),e.GetEncodedGeometryType(r)!==T.TRIANGULAR_MESH)throw new Error("["+_+"] Unknown geometry type.");var n=new T.Mesh;if(!e.DecodeBufferToMesh(r,n).ok()||0===n.ptr)throw new Error("["+_+"] Decoding failure.");return n}finally{T.destroy(r)}}function N(e,t){var r=3*t.num_faces(),n=r*Uint32Array.BYTES_PER_ELEMENT,o=T._malloc(n);e.GetTrianglesUInt32Array(t,n,o);var s=new Uint32Array(T.HEAP32.buffer,o,r).slice();return T._free(o),s}function R(e,t,r,n){var o=d[n.componentType],s=g[n.componentType],i=r.num_components(),a=t.num_points()*i,u=a*s.BYTES_PER_ELEMENT,c=T._malloc(u);e.GetAttributeDataArrayForAllPoints(t,r,o,u,c);var l=new s(T.HEAPF32.buffer,c,a).slice();return T._free(c),l}!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={}));var A=((v={})[C.POSITION]=14,v[C.NORMAL]=10,v[C.COLOR]=8,v[C.TEX_COORD]=12,v[C.GENERIC]=12,v),S={decodeSpeed:5,encodeSpeed:5,method:I.EDGEBREAKER,quantizationBits:A};function M(e,t){void 0===t&&(t=S);var n=r({},S,t);n.quantizationBits=r({},A,t.quantizationBits);for(var o,s=new y.Encoder,i=new y.MeshBuilder,u=new y.Mesh,c={},l=new y.DracoInt8Array,h=a(e.listSemantics());!(o=h()).done;){var p=o.value,f=e.getAttribute(p),x=F(p),T=i[O[f.getComponentType()]](u,y[x],f.getCount(),f.getElementSize(),f.getArray());if(-1===T)throw new Error('Error compressing "'+p+'" attribute.');c[p]=T,s.SetAttributeQuantization(y[x],n.quantizationBits[x])}var g=e.getIndices();if(!g)throw new Error("Primitive must have indices.");i.AddFacesToMesh(u,g.getCount()/3,g.getArray()),s.SetSpeedOptions(n.encodeSpeed,n.decodeSpeed),s.SetTrackEncodedProperties(!0),e.listTargets().length>0||n.method===I.SEQUENTIAL?s.SetEncodingMethod(y.MESH_SEQUENTIAL_ENCODING):s.SetEncodingMethod(y.MESH_EDGEBREAKER_ENCODING);var d=s.EncodeMeshToDracoBuffer(u,l);if(d<=0)throw new Error("Error applying Draco compression.");for(var v=new Uint8Array(d),m=0;m<d;++m)v[m]=l.GetValue(m);var C=s.GetNumberOfEncodedPoints(),_=3*s.GetNumberOfEncodedFaces();return y.destroy(l),y.destroy(u),y.destroy(i),y.destroy(s),{numVertices:C,numIndices:_,data:v,attributeIDs:c}}function F(e){return"POSITION"===e?C.POSITION:"NORMAL"===e?C.NORMAL:e.startsWith("COLOR_")?C.COLOR:e.startsWith("TEXCOORD_")?C.TEX_COORD:C.GENERIC}var O=((m={})[e.Accessor.ComponentType.UNSIGNED_BYTE]="AddUInt8Attribute",m[e.Accessor.ComponentType.BYTE]="AddInt8Attribute",m[e.Accessor.ComponentType.UNSIGNED_SHORT]="AddUInt16Attribute",m[e.Accessor.ComponentType.SHORT]="AddInt16Attribute",m[e.Accessor.ComponentType.UNSIGNED_INT]="AddUInt32Attribute",m[e.Accessor.ComponentType.FLOAT]="AddFloatAttribute",m),D="KHR_draco_mesh_compression",w=function(t){function r(){var r;return(r=t.apply(this,arguments)||this).extensionName=D,r.prereadTypes=[e.PropertyType.PRIMITIVE],r.prewriteTypes=[e.PropertyType.ACCESSOR],r.dependencies=["draco3d.decoder","draco3d.encoder"],r._decoderModule=null,r._encoderModule=null,r._encoderOptions={},r}n(r,t);var o=r.prototype;return o.install=function(t,r){var n,o;return"draco3d.decoder"===t&&(this._decoderModule=r,T=this._decoderModule,(n={})[e.Accessor.ComponentType.FLOAT]=Float32Array,n[e.Accessor.ComponentType.UNSIGNED_INT]=Uint32Array,n[e.Accessor.ComponentType.UNSIGNED_SHORT]=Uint16Array,n[e.Accessor.ComponentType.UNSIGNED_BYTE]=Uint8Array,n[e.Accessor.ComponentType.SHORT]=Int16Array,n[e.Accessor.ComponentType.BYTE]=Int8Array,g=n,(o={})[e.Accessor.ComponentType.FLOAT]=T.DT_FLOAT32,o[e.Accessor.ComponentType.UNSIGNED_INT]=T.DT_UINT32,o[e.Accessor.ComponentType.UNSIGNED_SHORT]=T.DT_UINT16,o[e.Accessor.ComponentType.UNSIGNED_BYTE]=T.DT_UINT8,o[e.Accessor.ComponentType.SHORT]=T.DT_INT16,o[e.Accessor.ComponentType.BYTE]=T.DT_INT8,d=o),"draco3d.encoder"===t&&(this._encoderModule=r,y=this._encoderModule),this},o.setEncoderOptions=function(e){return this._encoderOptions=e,this},o.preread=function(t){if(!this._decoderModule)throw new Error("["+D+'] Please install extension dependency, "draco3d.decoder".');var r=this.doc.getLogger(),n=t.jsonDoc,o=new Map;try{for(var s,i=a(n.json.meshes||[]);!(s=i()).done;)for(var u,c=a(s.value.primitives);!(u=c()).done;){var l=u.value;if(l.extensions&&l.extensions[D]){var h=l.extensions[D],p=o.get(h.bufferView)||[],f=p[0],x=p[1];if(!x||!f){var T=n.json.bufferViews[h.bufferView],g=n.json.buffers[T.buffer],d=new Int8Array(g.uri?n.resources[g.uri]:n.resources[e.GLB_BUFFER],T.byteOffset||0,T.byteLength);x=E(f=new this._decoderModule.Decoder,d),o.set(h.bufferView,[f,x]),r.debug("["+D+"] Decompressed "+d.byteLength+" bytes.")}for(var v in l.attributes){var m=t.jsonDoc.json.accessors[l.attributes[v]],y=f.GetAttributeByUniqueId(x,h.attributes[v]),I=R(f,x,y,m);t.accessors[l.attributes[v]].setArray(I)}var C=N(f,x);t.accessors[l.indices].setArray(C)}}}finally{for(var _=0,A=Array.from(o.values());_<A.length;_++){var S=A[_],M=S[1];this._decoderModule.destroy(S[0]),this._decoderModule.destroy(M)}}return this},o.read=function(e){return this},o.prewrite=function(t,r){if(!this._encoderModule)throw new Error("["+D+'] Please install extension dependency, "draco3d.encoder".');var n=this.doc.getLogger();n.debug("["+D+"] Compression options: "+JSON.stringify(this._encoderOptions));for(var o=function(t){for(var r,n=t.getLogger(),o=new Set,s=new Set,i=a(t.getRoot().listMeshes());!(r=i()).done;)for(var u,c=a(r.value.listPrimitives());!(u=c()).done;){var l=u.value;l.getIndices()?l.getMode()!==e.Primitive.Mode.TRIANGLES?(s.add(l),n.warn("["+D+"] Skipping Draco compression on non-TRIANGLES primitive.")):o.add(l):(s.add(l),n.warn("["+D+"] Skipping Draco compression on non-indexed primitive."))}for(var h=t.getRoot().listAccessors(),p=new Map,f=0;f<h.length;f++)p.set(h[f],f);for(var x=new Map,T=new Set,g=new Map,d=0,v=Array.from(o);d<v.length;d++){var m=v[d],y=G(m,p);if(T.has(y))g.set(m,y);else{if(x.has(m.getIndices())){var I=m.getIndices().clone();p.set(I,t.getRoot().listAccessors().length-1),m.swap(m.getIndices(),I)}for(var C,_=a(m.listAttributes());!(C=_()).done;){var E=C.value;if(x.has(E)){var N=E.clone();p.set(N,t.getRoot().listAccessors().length-1),m.swap(E,N)}}y=G(m,p),T.add(y),g.set(m,y),x.set(m.getIndices(),y);for(var R,A=a(m.listAttributes());!(R=A()).done;)x.set(R.value,y)}}for(var S=0,M=Array.from(x.keys());S<M.length;S++){var F=new Set(M[S].listParents().map(function(e){return e.propertyType}));if(2!==F.size||!F.has("Primitive")||!F.has("Root"))throw new Error("["+D+"] Compressed accessors must only be used as indices or vertex attributes.")}for(var O=function(){var e=j[w],t=g.get(e);if(x.get(e.getIndices())!==t||e.listAttributes().some(function(e){return x.get(e)!==t}))throw new Error("["+D+"] Draco primitives must share all, or no, accessors.")},w=0,j=Array.from(o);w<j.length;w++)O();for(var b=0,P=Array.from(s);b<P.length;b++){var k=P[b];if(x.has(k.getIndices())||k.listAttributes().some(function(e){return x.has(e)}))throw new Error("["+D+"] Accessor cannot be shared by compressed and uncompressed primitives.")}return g}(this.doc),s=new Map,i=0,u=Array.from(o.keys());i<u.length;i++){var c=u[i],l=o.get(c);if(!l)throw new Error("Unexpected primitive.");if(s.has(l))s.set(l,s.get(l));else{var h=M(c,this._encoderOptions);s.set(l,h);var p=t.createAccessorDef(c.getIndices());p.count=h.numIndices,t.accessorIndexMap.set(c.getIndices(),t.jsonDoc.json.accessors.length),t.jsonDoc.json.accessors.push(p);for(var f,x=a(c.listSemantics());!(f=x()).done;){var T=c.getAttribute(f.value),g=t.createAccessorDef(T);g.count=h.numVertices,t.accessorIndexMap.set(T,t.jsonDoc.json.accessors.length),t.jsonDoc.json.accessors.push(g)}var d=c.getAttribute("POSITION").getBuffer()||this.doc.getRoot().listBuffers()[0];t.otherBufferViews.has(d)||t.otherBufferViews.set(d,[]),t.otherBufferViews.get(d).push(h.data)}}return n.debug("["+D+"] Compressed "+o.size+" primitives."),t.extensionData[D]={primitiveHashMap:o,primitiveEncodingMap:s},this},o.write=function(e){for(var t,r=e.extensionData[D],n=a(this.doc.getRoot().listMeshes());!(t=n()).done;)for(var o=t.value,s=e.jsonDoc.json.meshes[e.meshIndexMap.get(o)],i=0;i<o.listPrimitives().length;i++){var u=o.listPrimitives()[i],c=s.primitives[i],l=r.primitiveHashMap.get(u);if(l){var h=r.primitiveEncodingMap.get(l);c.extensions=c.extensions||{},c.extensions[D]={bufferView:e.otherBufferViewsIndexMap.get(h.data),attributes:h.attributeIDs}}}if(!r.primitiveHashMap.size){var p=e.jsonDoc.json;p.extensionsUsed=(p.extensionsUsed||[]).filter(function(e){return e!==D}),p.extensionsRequired=(p.extensionsRequired||[]).filter(function(e){return e!==D})}return this},r}(e.Extension);function G(e,t){var r=[];r.push(t.get(e.getIndices()));for(var n,o=a(e.listAttributes());!(n=o()).done;)r.push(t.get(n.value));return r.sort().join("|")}w.EXTENSION_NAME=D,w.EncoderMethod=I;var j=function(t){function r(){var n;return(n=t.apply(this,arguments)||this).propertyType="Light",n.parentTypes=[e.PropertyType.NODE],n.extensionName="KHR_lights_punctual",n._color=[1,1,1],n._intensity=1,n._type=r.Type.POINT,n._range=null,n._innerConeAngle=0,n._outerConeAngle=Math.PI/4,n}n(r,t);var o=r.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},r}(e.ExtensionProperty);j.EXTENSION_NAME="KHR_lights_punctual",j.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};var b="KHR_lights_punctual",P=function(t){function r(){var e;return(e=t.apply(this,arguments)||this).extensionName=b,e}n(r,t);var o=r.prototype;return o.createLight=function(){return new j(this.doc.getGraph(),this)},o.read=function(e){var t=this,r=e.jsonDoc;if(!r.json.extensions||!r.json.extensions[b])return this;var n=(r.json.extensions[b].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[b]&&e.nodes[r].setExtension(b,n[t.extensions[b].light])}),this},o.write=function(t){var r=t.jsonDoc;if(0===this.properties.size)return this;for(var n,o=[],s=new Map,i=a(this.properties);!(n=i()).done;){var u=n.value,c={type:u.getType()};e.MathUtils.eq(u.getColor(),[1,1,1])||(c.color=u.getColor()),1!==u.getIntensity()&&(c.intensity=u.getIntensity()),null!=u.getRange()&&(c.range=u.getRange()),u.getName()&&(c.name=u.getName()),u.getType()===j.Type.SPOT&&(c.innerConeAngle=u.getInnerConeAngle(),c.outerConeAngle=u.getOuterConeAngle()),o.push(c),s.set(u,o.length-1)}return this.doc.getRoot().listNodes().forEach(function(e){var n=e.getExtension(b);if(n){var o=t.nodeIndexMap.get(e),i=r.json.nodes[o];i.extensions=i.extensions||{},i.extensions[b]={light:s.get(n)}}}),r.json.extensions=r.json.extensions||{},r.json.extensions[b]={lights:o},this},r}(e.Extension);P.EXTENSION_NAME=b;var k=function(t){function r(){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",s(r),new e.TextureInfo(r.graph)),r.clearcoatRoughnessTexture=null,r.clearcoatRoughnessTextureInfo=r.graph.link("clearcoatRoughnessTextureInfo",s(r),new e.TextureInfo(r.graph)),r.clearcoatNormalTexture=null,r.clearcoatNormalTextureInfo=r.graph.link("clearcoatNormalTextureInfo",s(r),new e.TextureInfo(r.graph)),r}n(r,t);var o=r.prototype;return o.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},o.dispose=function(){this.clearcoatTextureInfo.getChild().dispose(),this.clearcoatRoughnessTextureInfo.getChild().dispose(),this.clearcoatNormalTextureInfo.getChild().dispose(),t.prototype.dispose.call(this)},o.getClearcoatFactor=function(){return this._clearcoatFactor},o.setClearcoatFactor=function(e){return this._clearcoatFactor=e,this},o.getClearcoatTexture=function(){return this.clearcoatTexture?this.clearcoatTexture.getChild():null},o.getClearcoatTextureInfo=function(){return this.clearcoatTexture?this.clearcoatTextureInfo.getChild():null},o.setClearcoatTexture=function(e){return this.clearcoatTexture=this.graph.link("clearcoatTexture",this,e),this},o.getClearcoatRoughnessFactor=function(){return this._clearcoatRoughnessFactor},o.setClearcoatRoughnessFactor=function(e){return this._clearcoatRoughnessFactor=e,this},o.getClearcoatRoughnessTexture=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.getChild():null},o.getClearcoatRoughnessTextureInfo=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTextureInfo.getChild():null},o.setClearcoatRoughnessTexture=function(e){return this.clearcoatRoughnessTexture=this.graph.link("clearcoatRoughnessTexture",this,e),this},o.getClearcoatNormalScale=function(){return this._clearcoatNormalScale},o.setClearcoatNormalScale=function(e){return this._clearcoatNormalScale=e,this},o.getClearcoatNormalTexture=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTexture.getChild():null},o.getClearcoatNormalTextureInfo=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTextureInfo.getChild():null},o.setClearcoatNormalTexture=function(e){return this.clearcoatNormalTexture=this.graph.link("clearcoatNormalTexture",this,e),this},r}(e.ExtensionProperty);k.EXTENSION_NAME="KHR_materials_clearcoat",u([e.GraphChild],k.prototype,"clearcoatTexture",void 0),u([e.GraphChild],k.prototype,"clearcoatTextureInfo",void 0),u([e.GraphChild],k.prototype,"clearcoatRoughnessTexture",void 0),u([e.GraphChild],k.prototype,"clearcoatRoughnessTextureInfo",void 0),u([e.GraphChild],k.prototype,"clearcoatNormalTexture",void 0),u([e.GraphChild],k.prototype,"clearcoatNormalTextureInfo",void 0);var U="KHR_materials_clearcoat",H=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=U,t}n(t,e);var r=t.prototype;return r.createClearcoat=function(){return new k(this.doc.getGraph(),this)},r.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.createClearcoat();e.materials[o].setExtension(U,s);var i=r.extensions[U];if(void 0!==i.clearcoatFactor&&s.setClearcoatFactor(i.clearcoatFactor),void 0!==i.clearcoatRoughnessFactor&&s.setClearcoatRoughnessFactor(i.clearcoatRoughnessFactor),void 0!==i.clearcoatTexture){var a=i.clearcoatTexture;s.setClearcoatTexture(e.textures[n[a.index].source]),e.setTextureInfo(s.getClearcoatTextureInfo(),a)}if(void 0!==i.clearcoatRoughnessTexture){var u=i.clearcoatRoughnessTexture;s.setClearcoatRoughnessTexture(e.textures[n[u.index].source]),e.setTextureInfo(s.getClearcoatRoughnessTextureInfo(),u)}if(void 0!==i.clearcoatNormalTexture){var c=i.clearcoatNormalTexture;s.setClearcoatNormalTexture(e.textures[n[c.index].source]),e.setTextureInfo(s.getClearcoatNormalTextureInfo(),c),void 0!==c.scale&&s.setClearcoatNormalScale(c.scale)}}}),this},r.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];s.extensions=s.extensions||{};var i=s.extensions[U]={clearcoatFactor:n.getClearcoatFactor(),clearcoatRoughnessFactor:n.getClearcoatRoughnessFactor()};if(n.getClearcoatTexture()){var a=n.getClearcoatTexture(),u=n.getClearcoatTextureInfo();i.clearcoatTexture=e.createTextureInfoDef(a,u)}if(n.getClearcoatRoughnessTexture()){var c=n.getClearcoatRoughnessTexture(),l=n.getClearcoatRoughnessTextureInfo();i.clearcoatRoughnessTexture=e.createTextureInfoDef(c,l)}if(n.getClearcoatNormalTexture()){var h=n.getClearcoatNormalTexture(),p=n.getClearcoatNormalTextureInfo();i.clearcoatNormalTexture=e.createTextureInfoDef(h,p),1!==n.getClearcoatNormalScale()&&(i.clearcoatNormalTexture.scale=n.getClearcoatNormalScale())}}}),this},t}(e.Extension);H.EXTENSION_NAME=U;var L=function(t){function r(){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}n(r,t);var o=r.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},r}(e.ExtensionProperty);L.EXTENSION_NAME="KHR_materials_ior";var K="KHR_materials_ior",B=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=K,t}n(t,e);var r=t.prototype;return r.createIOR=function(){return new L(this.doc.getGraph(),this)},r.read=function(e){var t=this;return(e.jsonDoc.json.materials||[]).forEach(function(r,n){if(r.extensions&&r.extensions[K]){var o=t.createIOR();e.materials[n].setExtension(K,o);var s=r.extensions[K];void 0!==s.ior&&o.setIOR(s.ior)}}),this},r.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];s.extensions=s.extensions||{},s.extensions[K]={ior:n.getIOR()}}}),this},t}(e.Extension);B.EXTENSION_NAME=K;var X=function(t){function r(){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",s(r),new e.TextureInfo(r.graph)),r.specularGlossinessTexture=null,r.specularGlossinessTextureInfo=r.graph.link("specularGlossinessTextureInfo",s(r),new e.TextureInfo(r.graph)),r}n(r,t);var o=r.prototype;return o.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},o.dispose=function(){this.diffuseTextureInfo.getChild().dispose(),this.specularGlossinessTextureInfo.getChild().dispose(),t.prototype.dispose.call(this)},o.getDiffuseFactor=function(){return this._diffuseFactor},o.setDiffuseFactor=function(e){return this._diffuseFactor=e,this},o.getDiffuseHex=function(){return e.ColorUtils.factorToHex(this._diffuseFactor)},o.setDiffuseHex=function(t){return e.ColorUtils.hexToFactor(t,this._diffuseFactor),this},o.getDiffuseTexture=function(){return this.diffuseTexture?this.diffuseTexture.getChild():null},o.getDiffuseTextureInfo=function(){return this.diffuseTexture?this.diffuseTextureInfo.getChild():null},o.setDiffuseTexture=function(e){return this.diffuseTexture=this.graph.link("diffuseTexture",this,e),this},o.getSpecularFactor=function(){return this._specularFactor},o.setSpecularFactor=function(e){return this._specularFactor=e,this},o.getGlossinessFactor=function(){return this._glossinessFactor},o.setGlossinessFactor=function(e){return this._glossinessFactor=e,this},o.getSpecularGlossinessTexture=function(){return this.specularGlossinessTexture?this.specularGlossinessTexture.getChild():null},o.getSpecularGlossinessTextureInfo=function(){return this.specularGlossinessTexture?this.specularGlossinessTextureInfo.getChild():null},o.setSpecularGlossinessTexture=function(e){return this.specularGlossinessTexture=this.graph.link("specularGlossinessTexture",this,e),this},r}(e.ExtensionProperty);X.EXTENSION_NAME="KHR_materials_pbrSpecularGlossiness",u([e.GraphChild],X.prototype,"diffuseTexture",void 0),u([e.GraphChild],X.prototype,"diffuseTextureInfo",void 0),u([e.GraphChild],X.prototype,"specularGlossinessTexture",void 0),u([e.GraphChild],X.prototype,"specularGlossinessTextureInfo",void 0);var V="KHR_materials_pbrSpecularGlossiness",Y=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=V,t}n(t,e);var r=t.prototype;return r.createPBRSpecularGlossiness=function(){return new X(this.doc.getGraph(),this)},r.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.createPBRSpecularGlossiness();e.materials[o].setExtension(V,s);var i=r.extensions[V];if(void 0!==i.diffuseFactor&&s.setDiffuseFactor(i.diffuseFactor),void 0!==i.specularFactor&&s.setSpecularFactor(i.specularFactor),void 0!==i.glossinessFactor&&s.setGlossinessFactor(i.glossinessFactor),void 0!==i.diffuseTexture){var a=i.diffuseTexture;s.setDiffuseTexture(e.textures[n[a.index].source]),e.setTextureInfo(s.getDiffuseTextureInfo(),a)}if(void 0!==i.specularGlossinessTexture){var u=i.specularGlossinessTexture;s.setSpecularGlossinessTexture(e.textures[n[u.index].source]),e.setTextureInfo(s.getSpecularGlossinessTextureInfo(),u)}}}),this},r.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];s.extensions=s.extensions||{};var i=s.extensions[V]={diffuseFactor:n.getDiffuseFactor(),specularFactor:n.getSpecularFactor(),glossinessFactor:n.getGlossinessFactor()};if(n.getDiffuseTexture()){var a=n.getDiffuseTexture(),u=n.getDiffuseTextureInfo();i.diffuseTexture=e.createTextureInfoDef(a,u)}if(n.getSpecularGlossinessTexture()){var c=n.getSpecularGlossinessTexture(),l=n.getSpecularGlossinessTextureInfo();i.specularGlossinessTexture=e.createTextureInfoDef(c,l)}}}),this},t}(e.Extension);Y.EXTENSION_NAME=V;var z=function(t){function r(){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",s(r),new e.TextureInfo(r.graph)),r.sheenRoughnessTexture=null,r.sheenRoughnessTextureInfo=r.graph.link("sheenRoughnessTextureInfo",s(r),new e.TextureInfo(r.graph)),r}n(r,t);var o=r.prototype;return o.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},o.dispose=function(){this.sheenColorTextureInfo.getChild().dispose(),this.sheenRoughnessTextureInfo.getChild().dispose(),t.prototype.dispose.call(this)},o.getSheenColorFactor=function(){return this._sheenColorFactor},o.getSheenColorHex=function(){return e.ColorUtils.factorToHex(this._sheenColorFactor)},o.setSheenColorFactor=function(e){return this._sheenColorFactor=e,this},o.setSheenColorHex=function(t){return e.ColorUtils.hexToFactor(t,this._sheenColorFactor),this},o.getSheenColorTexture=function(){return this.sheenColorTexture?this.sheenColorTexture.getChild():null},o.getSheenColorTextureInfo=function(){return this.sheenColorTexture?this.sheenColorTextureInfo.getChild():null},o.setSheenColorTexture=function(e){return this.sheenColorTexture=this.graph.link("sheenColorTexture",this,e),this},o.getSheenRoughnessFactor=function(){return this._sheenRoughnessFactor},o.setSheenRoughnessFactor=function(e){return this._sheenRoughnessFactor=e,this},o.getSheenRoughnessTexture=function(){return this.sheenRoughnessTexture?this.sheenRoughnessTexture.getChild():null},o.getSheenRoughnessTextureInfo=function(){return this.sheenRoughnessTexture?this.sheenRoughnessTextureInfo.getChild():null},o.setSheenRoughnessTexture=function(e){return this.sheenRoughnessTexture=this.graph.link("sheenRoughnessTexture",this,e),this},r}(e.ExtensionProperty);z.EXTENSION_NAME="KHR_materials_sheen",u([e.GraphChild],z.prototype,"sheenColorTexture",void 0),u([e.GraphChild],z.prototype,"sheenColorTextureInfo",void 0),u([e.GraphChild],z.prototype,"sheenRoughnessTexture",void 0),u([e.GraphChild],z.prototype,"sheenRoughnessTextureInfo",void 0);var q="KHR_materials_sheen",Q=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=q,t}n(t,e);var r=t.prototype;return r.createSheen=function(){return new z(this.doc.getGraph(),this)},r.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.createSheen();e.materials[o].setExtension(q,s);var i=r.extensions[q];if(void 0!==i.sheenColorFactor&&s.setSheenColorFactor(i.sheenColorFactor),void 0!==i.sheenRoughnessFactor&&s.setSheenRoughnessFactor(i.sheenRoughnessFactor),void 0!==i.sheenColorTexture){var a=i.sheenColorTexture;s.setSheenColorTexture(e.textures[n[a.index].source]),e.setTextureInfo(s.getSheenColorTextureInfo(),a)}if(void 0!==i.sheenRoughnessTexture){var u=i.sheenRoughnessTexture;s.setSheenRoughnessTexture(e.textures[n[u.index].source]),e.setTextureInfo(s.getSheenRoughnessTextureInfo(),u)}}}),this},r.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];s.extensions=s.extensions||{};var i=s.extensions[q]={sheenColorFactor:n.getSheenColorFactor(),sheenRoughnessFactor:n.getSheenRoughnessFactor()};if(n.getSheenColorTexture()){var a=n.getSheenColorTexture(),u=n.getSheenColorTextureInfo();i.sheenColorTexture=e.createTextureInfoDef(a,u)}if(n.getSheenRoughnessTexture()){var c=n.getSheenRoughnessTexture(),l=n.getSheenRoughnessTextureInfo();i.sheenRoughnessTexture=e.createTextureInfoDef(c,l)}}}),this},t}(e.Extension);Q.EXTENSION_NAME=q;var W=function(t){function r(){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",s(r),new e.TextureInfo(r.graph)),r}n(r,t);var o=r.prototype;return o.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},o.dispose=function(){this.specularTextureInfo.getChild().dispose(),t.prototype.dispose.call(this)},o.getSpecularFactor=function(){return this._specularFactor},o.setSpecularFactor=function(e){return this._specularFactor=e,this},o.getSpecularColorFactor=function(){return this._specularColorFactor},o.setSpecularColorFactor=function(e){return this._specularColorFactor=e,this},o.getSpecularColorHex=function(){return e.ColorUtils.factorToHex(this._specularColorFactor)},o.setSpecularColorHex=function(t){return e.ColorUtils.hexToFactor(t,this._specularColorFactor),this},o.getSpecularTexture=function(){return this.specularTexture?this.specularTexture.getChild():null},o.getSpecularTextureInfo=function(){return this.specularTexture?this.specularTextureInfo.getChild():null},o.setSpecularTexture=function(e){return this.specularTexture=this.graph.link("specularTexture",this,e),this},r}(e.ExtensionProperty);W.EXTENSION_NAME="KHR_materials_specular",u([e.GraphChild],W.prototype,"specularTexture",void 0),u([e.GraphChild],W.prototype,"specularTextureInfo",void 0);var J="KHR_materials_specular",$=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=J,t}n(t,e);var r=t.prototype;return r.createSpecular=function(){return new W(this.doc.getGraph(),this)},r.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[J]){var s=t.createSpecular();e.materials[o].setExtension(J,s);var i=r.extensions[J];if(void 0!==i.specularFactor&&s.setSpecularFactor(i.specularFactor),void 0!==i.specularColorFactor&&s.setSpecularColorFactor(i.specularColorFactor),void 0!==i.specularTexture){var a=i.specularTexture;s.setSpecularTexture(e.textures[n[a.index].source]),e.setTextureInfo(s.getSpecularTextureInfo(),a)}}}),this},r.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||{};var i=s.extensions[J]={specularFactor:n.getSpecularFactor(),specularColorFactor:n.getSpecularColorFactor()};if(n.getSpecularTexture()){var a=n.getSpecularTexture(),u=n.getSpecularTextureInfo();i.specularTexture=e.createTextureInfoDef(a,u)}}}),this},t}(e.Extension);$.EXTENSION_NAME=J;var Z=function(t){function r(){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",s(r),new e.TextureInfo(r.graph)),r}n(r,t);var o=r.prototype;return o.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},o.dispose=function(){this.transmissionTextureInfo.getChild().dispose(),t.prototype.dispose.call(this)},o.getTransmissionFactor=function(){return this._transmissionFactor},o.setTransmissionFactor=function(e){return this._transmissionFactor=e,this},o.getTransmissionTexture=function(){return this.transmissionTexture?this.transmissionTexture.getChild():null},o.getTransmissionTextureInfo=function(){return this.transmissionTexture?this.transmissionTextureInfo.getChild():null},o.setTransmissionTexture=function(e){return this.transmissionTexture=this.graph.link("transmissionTexture",this,e),this},r}(e.ExtensionProperty);Z.EXTENSION_NAME="KHR_materials_transmission",u([e.GraphChild],Z.prototype,"transmissionTexture",void 0),u([e.GraphChild],Z.prototype,"transmissionTextureInfo",void 0);var ee="KHR_materials_transmission",te=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=ee,t}n(t,e);var r=t.prototype;return r.createTransmission=function(){return new Z(this.doc.getGraph(),this)},r.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[ee]){var s=t.createTransmission();e.materials[o].setExtension(ee,s);var i=r.extensions[ee];if(void 0!==i.transmissionFactor&&s.setTransmissionFactor(i.transmissionFactor),void 0!==i.transmissionTexture){var a=i.transmissionTexture;s.setTransmissionTexture(e.textures[n[a.index].source]),e.setTextureInfo(s.getTransmissionTextureInfo(),a)}}}),this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var n=r.getExtension(ee);if(n){var o=e.materialIndexMap.get(r),s=t.json.materials[o];s.extensions=s.extensions||{};var i=s.extensions[ee]={transmissionFactor:n.getTransmissionFactor()};if(n.getTransmissionTexture()){var a=n.getTransmissionTexture(),u=n.getTransmissionTextureInfo();i.transmissionTexture=e.createTextureInfoDef(a,u)}}}),this},t}(e.Extension);te.EXTENSION_NAME=ee;var re=function(t){function r(){var r;return(r=t.apply(this,arguments)||this).propertyType="Unlit",r.parentTypes=[e.PropertyType.MATERIAL],r.extensionName="KHR_materials_unlit",r}return n(r,t),r}(e.ExtensionProperty);re.EXTENSION_NAME="KHR_materials_unlit";var ne="KHR_materials_unlit",oe=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=ne,t}n(t,e);var r=t.prototype;return r.createUnlit=function(){return new re(this.doc.getGraph(),this)},r.read=function(e){var t=this;return(e.jsonDoc.json.materials||[]).forEach(function(r,n){r.extensions&&r.extensions[ne]&&e.materials[n].setExtension(ne,t.createUnlit())}),this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){if(r.getExtension(ne)){var n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{},o.extensions[ne]={}}}),this},t}(e.Extension);oe.EXTENSION_NAME=ne;var se=function(t){function r(){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}n(r,t);var o=r.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()})},r}(e.ExtensionProperty);se.EXTENSION_NAME="KHR_materials_variants",u([e.GraphChild],se.prototype,"material",void 0),u([e.GraphChildList],se.prototype,"variants",void 0);var ie=function(t){function r(){var r;return(r=t.apply(this,arguments)||this).propertyType="MappingList",r.parentTypes=[e.PropertyType.PRIMITIVE],r.extensionName="KHR_materials_variants",r.mappings=[],r}n(r,t);var o=r.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()})},r}(e.ExtensionProperty);ie.EXTENSION_NAME="KHR_materials_variants",u([e.GraphChildList],ie.prototype,"mappings",void 0);var ae=function(t){function r(){var r;return(r=t.apply(this,arguments)||this).propertyType="Variant",r.parentTypes=[e.PropertyType.ROOT,"MappingList"],r.extensionName="KHR_materials_variants",r}return n(r,t),r}(e.ExtensionProperty);ae.EXTENSION_NAME="KHR_materials_variants";var ue="KHR_materials_variants",ce=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=ue,t}n(t,e);var r=t.prototype;return r.createMappingList=function(){return new ie(this.doc.getGraph(),this)},r.createVariant=function(e){return void 0===e&&(e=""),new ae(this.doc.getGraph(),this).setName(e)},r.createMapping=function(){return new se(this.doc.getGraph(),this)},r.listVariants=function(){return Array.from(this.properties).filter(function(e){return e instanceof ae})},r.read=function(e){var t=this,r=e.jsonDoc;if(!r.json.extensions||!r.json.extensions[ue])return this;var n=(r.json.extensions[ue].variants||[]).map(function(e){return t.createVariant().setName(e.name||"")});return(r.json.meshes||[]).forEach(function(r,o){var s=e.meshes[o];(r.primitives||[]).forEach(function(r,o){if(r.extensions&&r.extensions[ue]){for(var i,u=t.createMappingList(),c=a(r.extensions[ue].mappings);!(i=c()).done;){var l=i.value,h=t.createMapping();void 0!==l.material&&h.setMaterial(e.materials[l.material]);for(var p,f=a(l.variants||[]);!(p=f()).done;)h.addVariant(n[p.value]);u.addMapping(h)}s.listPrimitives()[o].setExtension(ue,u)}})}),this},r.write=function(e){var t=e.jsonDoc,r=this.listVariants();if(!r.length)return this;for(var n,o=[],s=new Map,i=a(r);!(n=i()).done;){var u=n.value;s.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(ue)){var o=e.jsonDoc.json.meshes[r].primitives[n],i=t.getExtension(ue).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 s.get(e)}),r});o.extensions=o.extensions||{},o.extensions[ue]={mappings:i}}})},h=a(this.doc.getRoot().listMeshes());!(c=h()).done;)l();return t.json.extensions=t.json.extensions||{},t.json.extensions[ue]={variants:o},this},t}(e.Extension);ce.EXTENSION_NAME=ue;var le=function(t){function r(){var r;return(r=t.apply(this,arguments)||this).propertyType="Transmission",r.parentTypes=[e.PropertyType.MATERIAL],r.extensionName="KHR_materials_volume",r._thicknessFactor=0,r._attenuationDistance=Infinity,r._attenuationColor=[1,1,1],r.thicknessTexture=null,r.thicknessTextureInfo=r.graph.link("thicknessTextureInfo",s(r),new e.TextureInfo(r.graph)),r}n(r,t);var o=r.prototype;return o.copy=function(r,n){return void 0===n&&(n=e.COPY_IDENTITY),t.prototype.copy.call(this,r,n),this._thicknessFactor=r._thicknessFactor,this._attenuationDistance=r._attenuationDistance,this._attenuationColor=[].concat(r._attenuationColor),r.thicknessTexture&&(this.setThicknessTexture(n(r.thicknessTexture.getChild())),this.getThicknessTextureInfo().copy(n(r.thicknessTextureInfo.getChild()),n)),this},o.dispose=function(){this.thicknessTextureInfo.getChild().dispose(),t.prototype.dispose.call(this)},o.getThicknessFactor=function(){return this._thicknessFactor},o.setThicknessFactor=function(e){return this._thicknessFactor=e,this},o.getThicknessTexture=function(){return this.thicknessTexture?this.thicknessTexture.getChild():null},o.getThicknessTextureInfo=function(){return this.thicknessTexture?this.thicknessTextureInfo.getChild():null},o.setThicknessTexture=function(e){return this.thicknessTexture=this.graph.link("thicknessTexture",this,e),this},o.getAttenuationDistance=function(){return this._attenuationDistance},o.setAttenuationDistance=function(e){return this._attenuationDistance=e,this},o.getAttenuationColor=function(){return this._attenuationColor},o.setAttenuationColor=function(e){return this._attenuationColor=e,this},o.getAttenuationColorHex=function(){return e.ColorUtils.factorToHex(this._attenuationColor)},o.setAttenuationColorHex=function(t){return e.ColorUtils.hexToFactor(t,this._attenuationColor),this},r}(e.ExtensionProperty);le.EXTENSION_NAME="KHR_materials_volume",u([e.GraphChild],le.prototype,"thicknessTexture",void 0),u([e.GraphChild],le.prototype,"thicknessTextureInfo",void 0);var he="KHR_materials_volume",pe=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=he,t}n(t,e);var r=t.prototype;return r.createVolume=function(){return new le(this.doc.getGraph(),this)},r.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[he]){var s=t.createVolume();e.materials[o].setExtension(he,s);var i=r.extensions[he];if(void 0!==i.thicknessFactor&&s.setThicknessFactor(i.thicknessFactor),void 0!==i.attenuationDistance&&s.setAttenuationDistance(i.attenuationDistance),void 0!==i.attenuationColor&&s.setAttenuationColor(i.attenuationColor),void 0!==i.thicknessTexture){var a=i.thicknessTexture;s.setThicknessTexture(e.textures[n[a.index].source]),e.setTextureInfo(s.getThicknessTextureInfo(),a)}}}),this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var n=r.getExtension(he);if(n){var o=e.materialIndexMap.get(r),s=t.json.materials[o];s.extensions=s.extensions||{};var i=s.extensions[he]={thicknessFactor:n.getThicknessFactor(),attenuationDistance:n.getAttenuationDistance(),attenuationColor:n.getAttenuationColor()};if(n.getThicknessTexture()){var a=n.getThicknessTexture(),u=n.getThicknessTextureInfo();i.thicknessTexture=e.createTextureInfoDef(a,u)}}}),this},t}(e.Extension);pe.EXTENSION_NAME=he;var fe="KHR_mesh_quantization",xe=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=fe,t}n(t,e);var r=t.prototype;return r.read=function(e){return this},r.write=function(e){return this},t}(e.Extension);xe.EXTENSION_NAME=fe;var Te="KHR_texture_basisu",ge=function(){function e(){}var r=e.prototype;return r.getSize=function(e){var r=t.read(new Uint8Array(e));return[r.pixelWidth,r.pixelHeight]},r.getChannels=function(e){var r=t.read(new Uint8Array(e)).dataFormatDescriptor[0];if(163===r.colorModel)return 2===r.samples.length&&15==(15&r.samples[1].channelID)?4:3;if(166===r.colorModel)return 3==(15&r.samples[0].channelID)?4:3;throw new Error('Unexpected KTX2 colorModel, "'+r.colorModel+'".')},r.getGPUByteLength=function(e){for(var r=t.read(new Uint8Array(e)),n=this.getChannels(e)>3,o=0,s=0;s<r.levels.length;s++){var i=r.levels[s];o+=i.uncompressedByteLength?i.uncompressedByteLength:Math.max(1,Math.floor(r.pixelWidth/Math.pow(2,s)))/4*(Math.max(1,Math.floor(r.pixelHeight/Math.pow(2,s)))/4)*(n?16:8)}return o},e}(),de=function(t){function r(){var r;return(r=t.apply(this,arguments)||this).extensionName=Te,r.prereadTypes=[e.PropertyType.TEXTURE],r}n(r,t),r.register=function(){e.ImageUtils.registerFormat("image/ktx2",new ge)};var o=r.prototype;return o.preread=function(e){return e.jsonDoc.json.textures.forEach(function(e){e.extensions&&e.extensions[Te]&&(e.source=e.extensions[Te].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[Te]={source:e.source},delete e.source)})}}),this},r}(e.Extension);de.EXTENSION_NAME=Te;var ve=function(t){function r(){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=null,r}n(r,t);var o=r.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},r}(e.ExtensionProperty);ve.EXTENSION_NAME="KHR_texture_transform";var me="KHR_texture_transform",ye=function(t){function r(){var e;return(e=t.apply(this,arguments)||this).extensionName=me,e}n(r,t);var o=r.prototype;return o.createTransform=function(){return new ve(this.doc.getGraph(),this)},o.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[me]){var i=this.createTransform(),a=s.extensions[me];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(me,i)}}return this},o.write=function(t){for(var r=0,n=Array.from(t.textureInfoDefMap.entries());r<n.length;r++){var o=n[r],s=o[1],i=o[0].getExtension(me);if(i){s.extensions=s.extensions||{};var a={},u=e.MathUtils.eq;u(i.getOffset(),[0,0])||(a.offset=i.getOffset()),0!==i.getRotation()&&(a.rotation=i.getRotation()),u(i.getScale(),[1,1])||(a.scale=i.getScale()),null!=i.getTexCoord()&&(a.texCoord=i.getTexCoord()),s.extensions[me]=a}}return this},r}(e.Extension);ye.EXTENSION_NAME=me;var Ie=[w,P,H,B,Y,$,Q,te,oe,ce,pe,xe,de,ye],Ce=[h,x].concat(Ie);exports.ALL_EXTENSIONS=Ce,exports.Clearcoat=k,exports.DracoMeshCompression=w,exports.IOR=L,exports.InstancedMesh=c,exports.KHRONOS_EXTENSIONS=Ie,exports.Light=j,exports.LightsPunctual=P,exports.Mapping=se,exports.MappingList=ie,exports.MaterialsClearcoat=H,exports.MaterialsIOR=B,exports.MaterialsPBRSpecularGlossiness=Y,exports.MaterialsSheen=Q,exports.MaterialsSpecular=$,exports.MaterialsTransmission=te,exports.MaterialsUnlit=oe,exports.MaterialsVariants=ce,exports.MaterialsVolume=pe,exports.MeshGPUInstancing=h,exports.MeshQuantization=xe,exports.PBRSpecularGlossiness=X,exports.Sheen=z,exports.Specular=W,exports.TextureBasisu=de,exports.TextureTransform=ye,exports.TextureWebP=x,exports.Transform=ve,exports.Transmission=Z,exports.Unlit=re,exports.Variant=ae,exports.Volume=le; | ||
var e=require("@gltf-transform/core"),t=require("ktx-parse");function r(){return(r=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 n(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,o(e,t)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function i(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 a(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return i(e,t);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)?i(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}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(r=e[Symbol.iterator]()).next.bind(r)}function u(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}var c=function(t){function r(){var r;return(r=t.apply(this,arguments)||this).propertyType="InstancedMesh",r.parentTypes=[e.PropertyType.NODE],r.extensionName="EXT_mesh_gpu_instancing",r.attributes=[],r}n(r,t);var o=r.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.attributes),r.listSemantics().forEach(function(e){o.setAttribute(e,n(r.getAttribute(e)))}),this},o.getAttribute=function(e){var t=this.attributes.find(function(t){return t.semantic===e});return t?t.getChild():null},o.setAttribute=function(e,t){var r=this.getAttribute(e);if(r&&this.removeGraphChild(this.attributes,r),!t)return this;var n=this.graph.linkAttribute(e.toLowerCase(),this,t);return n.semantic=e,this.addGraphChild(this.attributes,n)},o.listAttributes=function(){return this.attributes.map(function(e){return e.getChild()})},o.listSemantics=function(){return this.attributes.map(function(e){return e.semantic})},r}(e.ExtensionProperty);c.EXTENSION_NAME="EXT_mesh_gpu_instancing",u([e.GraphChildList],c.prototype,"attributes",void 0);var l="EXT_mesh_gpu_instancing",h=function(t){function r(){var r;return(r=t.apply(this,arguments)||this).extensionName=l,r.provideTypes=[e.PropertyType.NODE],r.prewriteTypes=[e.PropertyType.ACCESSOR],r}n(r,t);var o=r.prototype;return o.createInstancedMesh=function(){return new c(this.doc.getGraph(),this)},o.read=function(e){var t=this;return(e.jsonDoc.json.nodes||[]).forEach(function(r,n){if(r.extensions&&r.extensions[l]){var o=r.extensions[l],s=t.createInstancedMesh();for(var i in o.attributes)s.setAttribute(i,e.accessors[o.attributes[i]]);e.nodes[n].setExtension(l,s)}}),this},o.prewrite=function(e){e.accessorUsageGroupedByParent.add("INSTANCE_ATTRIBUTE");for(var t,r=a(this.properties);!(t=r()).done;)for(var n,o=a(t.value.listAttributes());!(n=o()).done;)e.setAccessorUsage(n.value,"INSTANCE_ATTRIBUTE");return this},o.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listNodes().forEach(function(r){var n=r.getExtension(l);if(n){var o=e.nodeIndexMap.get(r),s=t.json.nodes[o],i={attributes:{}};n.listSemantics().forEach(function(t){var r=n.getAttribute(t);i.attributes[t]=e.accessorIndexMap.get(r)}),s.extensions=s.extensions||{},s.extensions[l]=i}}),this},r}(e.Extension);h.EXTENSION_NAME=l;var p="EXT_texture_webp",f=function(){function t(){}var r=t.prototype;return r.getSize=function(t){var r=e.BufferUtils.decodeText(t.slice(0,4)),n=e.BufferUtils.decodeText(t.slice(8,12));if("RIFF"!==r||"WEBP"!==n)return null;for(var o=new DataView(t),s=12;s<t.byteLength;){var i=e.BufferUtils.decodeText(t.slice(s,s+4)),a=o.getUint32(s+4,!0);if("VP8 "===i)return[16383&o.getInt16(s+14,!0),16383&o.getInt16(s+16,!0)];if("VP8L"===i){var u=o.getUint8(s+9),c=o.getUint8(s+10),l=o.getUint8(s+11);return[1+((63&c)<<8|u),1+((15&o.getUint8(s+12))<<10|l<<2|(192&c)>>6)]}s+=8+a+a%2}return null},r.getChannels=function(e){return 4},t}(),x=function(t){function r(){var r;return(r=t.apply(this,arguments)||this).extensionName=p,r.prereadTypes=[e.PropertyType.TEXTURE],r}n(r,t),r.register=function(){e.ImageUtils.registerFormat("image/webp",new f)};var o=r.prototype;return o.preread=function(e){return(e.jsonDoc.json.textures||[]).forEach(function(e){e.extensions&&e.extensions[p]&&(e.source=e.extensions[p].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[p]={source:e.source},delete e.source)})}}),this},r}(e.Extension);x.EXTENSION_NAME=p;var T,g,d,v,m,y,C,I,_="KHR_draco_mesh_compression";function E(e,t){var r=new T.DecoderBuffer;try{if(r.Init(t,t.length),e.GetEncodedGeometryType(r)!==T.TRIANGULAR_MESH)throw new Error("["+_+"] Unknown geometry type.");var n=new T.Mesh;if(!e.DecodeBufferToMesh(r,n).ok()||0===n.ptr)throw new Error("["+_+"] Decoding failure.");return n}finally{T.destroy(r)}}function N(e,t){var r=3*t.num_faces(),n=r*Uint32Array.BYTES_PER_ELEMENT,o=T._malloc(n);e.GetTrianglesUInt32Array(t,n,o);var s=new Uint32Array(T.HEAP32.buffer,o,r).slice();return T._free(o),s}function R(e,t,r,n){var o=d[n.componentType],s=g[n.componentType],i=r.num_components(),a=t.num_points()*i,u=a*s.BYTES_PER_ELEMENT,c=T._malloc(u);e.GetAttributeDataArrayForAllPoints(t,r,o,u,c);var l=new s(T.HEAPF32.buffer,c,a).slice();return T._free(c),l}!function(e){e[e.EDGEBREAKER=1]="EDGEBREAKER",e[e.SEQUENTIAL=0]="SEQUENTIAL"}(C||(C={})),function(e){e.POSITION="POSITION",e.NORMAL="NORMAL",e.COLOR="COLOR",e.TEX_COORD="TEX_COORD",e.GENERIC="GENERIC"}(I||(I={}));var A=((v={})[I.POSITION]=14,v[I.NORMAL]=10,v[I.COLOR]=8,v[I.TEX_COORD]=12,v[I.GENERIC]=12,v),S={decodeSpeed:5,encodeSpeed:5,method:C.EDGEBREAKER,quantizationBits:A};function M(e,t){void 0===t&&(t=S);var n=r({},S,t);n.quantizationBits=r({},A,t.quantizationBits);for(var o,s=new y.Encoder,i=new y.MeshBuilder,u=new y.Mesh,c={},l=new y.DracoInt8Array,h=a(e.listSemantics());!(o=h()).done;){var p=o.value,f=e.getAttribute(p),x=F(p),T=i[O[f.getComponentType()]](u,y[x],f.getCount(),f.getElementSize(),f.getArray());if(-1===T)throw new Error('Error compressing "'+p+'" attribute.');c[p]=T,s.SetAttributeQuantization(y[x],n.quantizationBits[x])}var g=e.getIndices();if(!g)throw new Error("Primitive must have indices.");i.AddFacesToMesh(u,g.getCount()/3,g.getArray()),s.SetSpeedOptions(n.encodeSpeed,n.decodeSpeed),s.SetTrackEncodedProperties(!0),e.listTargets().length>0||n.method===C.SEQUENTIAL?s.SetEncodingMethod(y.MESH_SEQUENTIAL_ENCODING):s.SetEncodingMethod(y.MESH_EDGEBREAKER_ENCODING);var d=s.EncodeMeshToDracoBuffer(u,l);if(d<=0)throw new Error("Error applying Draco compression.");for(var v=new Uint8Array(d),m=0;m<d;++m)v[m]=l.GetValue(m);var I=s.GetNumberOfEncodedPoints(),_=3*s.GetNumberOfEncodedFaces();return y.destroy(l),y.destroy(u),y.destroy(i),y.destroy(s),{numVertices:I,numIndices:_,data:v,attributeIDs:c}}function F(e){return"POSITION"===e?I.POSITION:"NORMAL"===e?I.NORMAL:e.startsWith("COLOR_")?I.COLOR:e.startsWith("TEXCOORD_")?I.TEX_COORD:I.GENERIC}var O=((m={})[e.Accessor.ComponentType.UNSIGNED_BYTE]="AddUInt8Attribute",m[e.Accessor.ComponentType.BYTE]="AddInt8Attribute",m[e.Accessor.ComponentType.UNSIGNED_SHORT]="AddUInt16Attribute",m[e.Accessor.ComponentType.SHORT]="AddInt16Attribute",m[e.Accessor.ComponentType.UNSIGNED_INT]="AddUInt32Attribute",m[e.Accessor.ComponentType.FLOAT]="AddFloatAttribute",m),D="KHR_draco_mesh_compression",G=function(t){function r(){var r;return(r=t.apply(this,arguments)||this).extensionName=D,r.prereadTypes=[e.PropertyType.PRIMITIVE],r.prewriteTypes=[e.PropertyType.ACCESSOR],r.dependencies=["draco3d.decoder","draco3d.encoder"],r._decoderModule=null,r._encoderModule=null,r._encoderOptions={},r}n(r,t);var o=r.prototype;return o.install=function(t,r){var n,o;return"draco3d.decoder"===t&&(this._decoderModule=r,T=this._decoderModule,(n={})[e.Accessor.ComponentType.FLOAT]=Float32Array,n[e.Accessor.ComponentType.UNSIGNED_INT]=Uint32Array,n[e.Accessor.ComponentType.UNSIGNED_SHORT]=Uint16Array,n[e.Accessor.ComponentType.UNSIGNED_BYTE]=Uint8Array,n[e.Accessor.ComponentType.SHORT]=Int16Array,n[e.Accessor.ComponentType.BYTE]=Int8Array,g=n,(o={})[e.Accessor.ComponentType.FLOAT]=T.DT_FLOAT32,o[e.Accessor.ComponentType.UNSIGNED_INT]=T.DT_UINT32,o[e.Accessor.ComponentType.UNSIGNED_SHORT]=T.DT_UINT16,o[e.Accessor.ComponentType.UNSIGNED_BYTE]=T.DT_UINT8,o[e.Accessor.ComponentType.SHORT]=T.DT_INT16,o[e.Accessor.ComponentType.BYTE]=T.DT_INT8,d=o),"draco3d.encoder"===t&&(this._encoderModule=r,y=this._encoderModule),this},o.setEncoderOptions=function(e){return this._encoderOptions=e,this},o.preread=function(t){if(!this._decoderModule)throw new Error("["+D+'] Please install extension dependency, "draco3d.decoder".');var r=this.doc.getLogger(),n=t.jsonDoc,o=new Map;try{for(var s,i=a(n.json.meshes||[]);!(s=i()).done;)for(var u,c=a(s.value.primitives);!(u=c()).done;){var l=u.value;if(l.extensions&&l.extensions[D]){var h=l.extensions[D],p=o.get(h.bufferView)||[],f=p[0],x=p[1];if(!x||!f){var T=n.json.bufferViews[h.bufferView],g=n.json.buffers[T.buffer],d=new Int8Array(g.uri?n.resources[g.uri]:n.resources[e.GLB_BUFFER],T.byteOffset||0,T.byteLength);x=E(f=new this._decoderModule.Decoder,d),o.set(h.bufferView,[f,x]),r.debug("["+D+"] Decompressed "+d.byteLength+" bytes.")}for(var v in l.attributes){var m=t.jsonDoc.json.accessors[l.attributes[v]],y=f.GetAttributeByUniqueId(x,h.attributes[v]),C=R(f,x,y,m);t.accessors[l.attributes[v]].setArray(C)}var I=N(f,x);t.accessors[l.indices].setArray(I)}}}finally{for(var _=0,A=Array.from(o.values());_<A.length;_++){var S=A[_],M=S[1];this._decoderModule.destroy(S[0]),this._decoderModule.destroy(M)}}return this},o.read=function(e){return this},o.prewrite=function(t,r){if(!this._encoderModule)throw new Error("["+D+'] Please install extension dependency, "draco3d.encoder".');var n=this.doc.getLogger();n.debug("["+D+"] Compression options: "+JSON.stringify(this._encoderOptions));for(var o=function(t){for(var r,n=t.getLogger(),o=new Set,s=new Set,i=a(t.getRoot().listMeshes());!(r=i()).done;)for(var u,c=a(r.value.listPrimitives());!(u=c()).done;){var l=u.value;l.getIndices()?l.getMode()!==e.Primitive.Mode.TRIANGLES?(s.add(l),n.warn("["+D+"] Skipping Draco compression on non-TRIANGLES primitive.")):o.add(l):(s.add(l),n.warn("["+D+"] Skipping Draco compression on non-indexed primitive."))}for(var h=t.getRoot().listAccessors(),p=new Map,f=0;f<h.length;f++)p.set(h[f],f);for(var x=new Map,T=new Set,g=new Map,d=0,v=Array.from(o);d<v.length;d++){var m=v[d],y=w(m,p);if(T.has(y))g.set(m,y);else{if(x.has(m.getIndices())){var C=m.getIndices().clone();p.set(C,t.getRoot().listAccessors().length-1),m.swap(m.getIndices(),C)}for(var I,_=a(m.listAttributes());!(I=_()).done;){var E=I.value;if(x.has(E)){var N=E.clone();p.set(N,t.getRoot().listAccessors().length-1),m.swap(E,N)}}y=w(m,p),T.add(y),g.set(m,y),x.set(m.getIndices(),y);for(var R,A=a(m.listAttributes());!(R=A()).done;)x.set(R.value,y)}}for(var S=0,M=Array.from(x.keys());S<M.length;S++){var F=new Set(M[S].listParents().map(function(e){return e.propertyType}));if(2!==F.size||!F.has("Primitive")||!F.has("Root"))throw new Error("["+D+"] Compressed accessors must only be used as indices or vertex attributes.")}for(var O=function(){var e=j[G],t=g.get(e);if(x.get(e.getIndices())!==t||e.listAttributes().some(function(e){return x.get(e)!==t}))throw new Error("["+D+"] Draco primitives must share all, or no, accessors.")},G=0,j=Array.from(o);G<j.length;G++)O();for(var b=0,P=Array.from(s);b<P.length;b++){var U=P[b];if(x.has(U.getIndices())||U.listAttributes().some(function(e){return x.has(e)}))throw new Error("["+D+"] Accessor cannot be shared by compressed and uncompressed primitives.")}return g}(this.doc),s=new Map,i=0,u=Array.from(o.keys());i<u.length;i++){var c=u[i],l=o.get(c);if(!l)throw new Error("Unexpected primitive.");if(s.has(l))s.set(l,s.get(l));else{var h=M(c,this._encoderOptions);s.set(l,h);var p=t.createAccessorDef(c.getIndices());p.count=h.numIndices,t.accessorIndexMap.set(c.getIndices(),t.jsonDoc.json.accessors.length),t.jsonDoc.json.accessors.push(p);for(var f,x=a(c.listSemantics());!(f=x()).done;){var T=c.getAttribute(f.value),g=t.createAccessorDef(T);g.count=h.numVertices,t.accessorIndexMap.set(T,t.jsonDoc.json.accessors.length),t.jsonDoc.json.accessors.push(g)}var d=c.getAttribute("POSITION").getBuffer()||this.doc.getRoot().listBuffers()[0];t.otherBufferViews.has(d)||t.otherBufferViews.set(d,[]),t.otherBufferViews.get(d).push(h.data)}}return n.debug("["+D+"] Compressed "+o.size+" primitives."),t.extensionData[D]={primitiveHashMap:o,primitiveEncodingMap:s},this},o.write=function(e){for(var t,r=e.extensionData[D],n=a(this.doc.getRoot().listMeshes());!(t=n()).done;)for(var o=t.value,s=e.jsonDoc.json.meshes[e.meshIndexMap.get(o)],i=0;i<o.listPrimitives().length;i++){var u=o.listPrimitives()[i],c=s.primitives[i],l=r.primitiveHashMap.get(u);if(l){var h=r.primitiveEncodingMap.get(l);c.extensions=c.extensions||{},c.extensions[D]={bufferView:e.otherBufferViewsIndexMap.get(h.data),attributes:h.attributeIDs}}}if(!r.primitiveHashMap.size){var p=e.jsonDoc.json;p.extensionsUsed=(p.extensionsUsed||[]).filter(function(e){return e!==D}),p.extensionsRequired=(p.extensionsRequired||[]).filter(function(e){return e!==D})}return this},r}(e.Extension);function w(e,t){var r=[];r.push(t.get(e.getIndices()));for(var n,o=a(e.listAttributes());!(n=o()).done;)r.push(t.get(n.value));return r.sort().join("|")}G.EXTENSION_NAME=D,G.EncoderMethod=C;var j=function(t){function r(){var n;return(n=t.apply(this,arguments)||this).propertyType="Light",n.parentTypes=[e.PropertyType.NODE],n.extensionName="KHR_lights_punctual",n._color=[1,1,1],n._intensity=1,n._type=r.Type.POINT,n._range=null,n._innerConeAngle=0,n._outerConeAngle=Math.PI/4,n}n(r,t);var o=r.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},r}(e.ExtensionProperty);j.EXTENSION_NAME="KHR_lights_punctual",j.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};var b="KHR_lights_punctual",P=function(t){function r(){var e;return(e=t.apply(this,arguments)||this).extensionName=b,e}n(r,t);var o=r.prototype;return o.createLight=function(){return new j(this.doc.getGraph(),this)},o.read=function(e){var t=this,r=e.jsonDoc;if(!r.json.extensions||!r.json.extensions[b])return this;var n=(r.json.extensions[b].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[b]&&e.nodes[r].setExtension(b,n[t.extensions[b].light])}),this},o.write=function(t){var r=t.jsonDoc;if(0===this.properties.size)return this;for(var n,o=[],s=new Map,i=a(this.properties);!(n=i()).done;){var u=n.value,c={type:u.getType()};e.MathUtils.eq(u.getColor(),[1,1,1])||(c.color=u.getColor()),1!==u.getIntensity()&&(c.intensity=u.getIntensity()),null!=u.getRange()&&(c.range=u.getRange()),u.getName()&&(c.name=u.getName()),u.getType()===j.Type.SPOT&&(c.innerConeAngle=u.getInnerConeAngle(),c.outerConeAngle=u.getOuterConeAngle()),o.push(c),s.set(u,o.length-1)}return this.doc.getRoot().listNodes().forEach(function(e){var n=e.getExtension(b);if(n){var o=t.nodeIndexMap.get(e),i=r.json.nodes[o];i.extensions=i.extensions||{},i.extensions[b]={light:s.get(n)}}}),r.json.extensions=r.json.extensions||{},r.json.extensions[b]={lights:o},this},r}(e.Extension);P.EXTENSION_NAME=b;var U=e.TextureChannel.R,k=e.TextureChannel.G,H=e.TextureChannel.B,L=function(t){function r(){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",s(r),new e.TextureInfo(r.graph)),r.clearcoatRoughnessTexture=null,r.clearcoatRoughnessTextureInfo=r.graph.link("clearcoatRoughnessTextureInfo",s(r),new e.TextureInfo(r.graph)),r.clearcoatNormalTexture=null,r.clearcoatNormalTextureInfo=r.graph.link("clearcoatNormalTextureInfo",s(r),new e.TextureInfo(r.graph)),r}n(r,t);var o=r.prototype;return o.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},o.dispose=function(){this.clearcoatTextureInfo.getChild().dispose(),this.clearcoatRoughnessTextureInfo.getChild().dispose(),this.clearcoatNormalTextureInfo.getChild().dispose(),t.prototype.dispose.call(this)},o.getClearcoatFactor=function(){return this._clearcoatFactor},o.setClearcoatFactor=function(e){return this._clearcoatFactor=e,this},o.getClearcoatTexture=function(){return this.clearcoatTexture?this.clearcoatTexture.getChild():null},o.getClearcoatTextureInfo=function(){return this.clearcoatTexture?this.clearcoatTextureInfo.getChild():null},o.setClearcoatTexture=function(e){return this.clearcoatTexture=this.graph.linkTexture("clearcoatTexture",U,this,e),this},o.getClearcoatRoughnessFactor=function(){return this._clearcoatRoughnessFactor},o.setClearcoatRoughnessFactor=function(e){return this._clearcoatRoughnessFactor=e,this},o.getClearcoatRoughnessTexture=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.getChild():null},o.getClearcoatRoughnessTextureInfo=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTextureInfo.getChild():null},o.setClearcoatRoughnessTexture=function(e){return this.clearcoatRoughnessTexture=this.graph.linkTexture("clearcoatRoughnessTexture",k,this,e),this},o.getClearcoatNormalScale=function(){return this._clearcoatNormalScale},o.setClearcoatNormalScale=function(e){return this._clearcoatNormalScale=e,this},o.getClearcoatNormalTexture=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTexture.getChild():null},o.getClearcoatNormalTextureInfo=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTextureInfo.getChild():null},o.setClearcoatNormalTexture=function(e){return this.clearcoatNormalTexture=this.graph.linkTexture("clearcoatNormalTexture",U|k|H,this,e),this},r}(e.ExtensionProperty);L.EXTENSION_NAME="KHR_materials_clearcoat",u([e.GraphChild],L.prototype,"clearcoatTexture",void 0),u([e.GraphChild],L.prototype,"clearcoatTextureInfo",void 0),u([e.GraphChild],L.prototype,"clearcoatRoughnessTexture",void 0),u([e.GraphChild],L.prototype,"clearcoatRoughnessTextureInfo",void 0),u([e.GraphChild],L.prototype,"clearcoatNormalTexture",void 0),u([e.GraphChild],L.prototype,"clearcoatNormalTextureInfo",void 0);var B="KHR_materials_clearcoat",K=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=B,t}n(t,e);var r=t.prototype;return r.createClearcoat=function(){return new L(this.doc.getGraph(),this)},r.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[B]){var s=t.createClearcoat();e.materials[o].setExtension(B,s);var i=r.extensions[B];if(void 0!==i.clearcoatFactor&&s.setClearcoatFactor(i.clearcoatFactor),void 0!==i.clearcoatRoughnessFactor&&s.setClearcoatRoughnessFactor(i.clearcoatRoughnessFactor),void 0!==i.clearcoatTexture){var a=i.clearcoatTexture;s.setClearcoatTexture(e.textures[n[a.index].source]),e.setTextureInfo(s.getClearcoatTextureInfo(),a)}if(void 0!==i.clearcoatRoughnessTexture){var u=i.clearcoatRoughnessTexture;s.setClearcoatRoughnessTexture(e.textures[n[u.index].source]),e.setTextureInfo(s.getClearcoatRoughnessTextureInfo(),u)}if(void 0!==i.clearcoatNormalTexture){var c=i.clearcoatNormalTexture;s.setClearcoatNormalTexture(e.textures[n[c.index].source]),e.setTextureInfo(s.getClearcoatNormalTextureInfo(),c),void 0!==c.scale&&s.setClearcoatNormalScale(c.scale)}}}),this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var n=r.getExtension(B);if(n){var o=e.materialIndexMap.get(r),s=t.json.materials[o];s.extensions=s.extensions||{};var i=s.extensions[B]={clearcoatFactor:n.getClearcoatFactor(),clearcoatRoughnessFactor:n.getClearcoatRoughnessFactor()};if(n.getClearcoatTexture()){var a=n.getClearcoatTexture(),u=n.getClearcoatTextureInfo();i.clearcoatTexture=e.createTextureInfoDef(a,u)}if(n.getClearcoatRoughnessTexture()){var c=n.getClearcoatRoughnessTexture(),l=n.getClearcoatRoughnessTextureInfo();i.clearcoatRoughnessTexture=e.createTextureInfoDef(c,l)}if(n.getClearcoatNormalTexture()){var h=n.getClearcoatNormalTexture(),p=n.getClearcoatNormalTextureInfo();i.clearcoatNormalTexture=e.createTextureInfoDef(h,p),1!==n.getClearcoatNormalScale()&&(i.clearcoatNormalTexture.scale=n.getClearcoatNormalScale())}}}),this},t}(e.Extension);K.EXTENSION_NAME=B;var X=function(t){function r(){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}n(r,t);var o=r.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},r}(e.ExtensionProperty);X.EXTENSION_NAME="KHR_materials_ior";var V="KHR_materials_ior",Y=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=V,t}n(t,e);var r=t.prototype;return r.createIOR=function(){return new X(this.doc.getGraph(),this)},r.read=function(e){var t=this;return(e.jsonDoc.json.materials||[]).forEach(function(r,n){if(r.extensions&&r.extensions[V]){var o=t.createIOR();e.materials[n].setExtension(V,o);var s=r.extensions[V];void 0!==s.ior&&o.setIOR(s.ior)}}),this},r.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];s.extensions=s.extensions||{},s.extensions[V]={ior:n.getIOR()}}}),this},t}(e.Extension);Y.EXTENSION_NAME=V;var z=e.TextureChannel.R,q=e.TextureChannel.G,Q=e.TextureChannel.B,W=e.TextureChannel.A,J=function(t){function r(){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",s(r),new e.TextureInfo(r.graph)),r.specularGlossinessTexture=null,r.specularGlossinessTextureInfo=r.graph.link("specularGlossinessTextureInfo",s(r),new e.TextureInfo(r.graph)),r}n(r,t);var o=r.prototype;return o.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},o.dispose=function(){this.diffuseTextureInfo.getChild().dispose(),this.specularGlossinessTextureInfo.getChild().dispose(),t.prototype.dispose.call(this)},o.getDiffuseFactor=function(){return this._diffuseFactor},o.setDiffuseFactor=function(e){return this._diffuseFactor=e,this},o.getDiffuseHex=function(){return e.ColorUtils.factorToHex(this._diffuseFactor)},o.setDiffuseHex=function(t){return e.ColorUtils.hexToFactor(t,this._diffuseFactor),this},o.getDiffuseTexture=function(){return this.diffuseTexture?this.diffuseTexture.getChild():null},o.getDiffuseTextureInfo=function(){return this.diffuseTexture?this.diffuseTextureInfo.getChild():null},o.setDiffuseTexture=function(e){return this.diffuseTexture=this.graph.linkTexture("diffuseTexture",z|q|Q|W,this,e),this},o.getSpecularFactor=function(){return this._specularFactor},o.setSpecularFactor=function(e){return this._specularFactor=e,this},o.getGlossinessFactor=function(){return this._glossinessFactor},o.setGlossinessFactor=function(e){return this._glossinessFactor=e,this},o.getSpecularGlossinessTexture=function(){return this.specularGlossinessTexture?this.specularGlossinessTexture.getChild():null},o.getSpecularGlossinessTextureInfo=function(){return this.specularGlossinessTexture?this.specularGlossinessTextureInfo.getChild():null},o.setSpecularGlossinessTexture=function(e){return this.specularGlossinessTexture=this.graph.linkTexture("specularGlossinessTexture",z|q|Q|W,this,e),this},r}(e.ExtensionProperty);J.EXTENSION_NAME="KHR_materials_pbrSpecularGlossiness",u([e.GraphChild],J.prototype,"diffuseTexture",void 0),u([e.GraphChild],J.prototype,"diffuseTextureInfo",void 0),u([e.GraphChild],J.prototype,"specularGlossinessTexture",void 0),u([e.GraphChild],J.prototype,"specularGlossinessTextureInfo",void 0);var $="KHR_materials_pbrSpecularGlossiness",Z=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=$,t}n(t,e);var r=t.prototype;return r.createPBRSpecularGlossiness=function(){return new J(this.doc.getGraph(),this)},r.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[$]){var s=t.createPBRSpecularGlossiness();e.materials[o].setExtension($,s);var i=r.extensions[$];if(void 0!==i.diffuseFactor&&s.setDiffuseFactor(i.diffuseFactor),void 0!==i.specularFactor&&s.setSpecularFactor(i.specularFactor),void 0!==i.glossinessFactor&&s.setGlossinessFactor(i.glossinessFactor),void 0!==i.diffuseTexture){var a=i.diffuseTexture;s.setDiffuseTexture(e.textures[n[a.index].source]),e.setTextureInfo(s.getDiffuseTextureInfo(),a)}if(void 0!==i.specularGlossinessTexture){var u=i.specularGlossinessTexture;s.setSpecularGlossinessTexture(e.textures[n[u.index].source]),e.setTextureInfo(s.getSpecularGlossinessTextureInfo(),u)}}}),this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var n=r.getExtension($);if(n){var o=e.materialIndexMap.get(r),s=t.json.materials[o];s.extensions=s.extensions||{};var i=s.extensions[$]={diffuseFactor:n.getDiffuseFactor(),specularFactor:n.getSpecularFactor(),glossinessFactor:n.getGlossinessFactor()};if(n.getDiffuseTexture()){var a=n.getDiffuseTexture(),u=n.getDiffuseTextureInfo();i.diffuseTexture=e.createTextureInfoDef(a,u)}if(n.getSpecularGlossinessTexture()){var c=n.getSpecularGlossinessTexture(),l=n.getSpecularGlossinessTextureInfo();i.specularGlossinessTexture=e.createTextureInfoDef(c,l)}}}),this},t}(e.Extension);Z.EXTENSION_NAME=$;var ee=e.TextureChannel.R,te=e.TextureChannel.G,re=e.TextureChannel.B,ne=e.TextureChannel.A,oe=function(t){function r(){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",s(r),new e.TextureInfo(r.graph)),r.sheenRoughnessTexture=null,r.sheenRoughnessTextureInfo=r.graph.link("sheenRoughnessTextureInfo",s(r),new e.TextureInfo(r.graph)),r}n(r,t);var o=r.prototype;return o.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},o.dispose=function(){this.sheenColorTextureInfo.getChild().dispose(),this.sheenRoughnessTextureInfo.getChild().dispose(),t.prototype.dispose.call(this)},o.getSheenColorFactor=function(){return this._sheenColorFactor},o.getSheenColorHex=function(){return e.ColorUtils.factorToHex(this._sheenColorFactor)},o.setSheenColorFactor=function(e){return this._sheenColorFactor=e,this},o.setSheenColorHex=function(t){return e.ColorUtils.hexToFactor(t,this._sheenColorFactor),this},o.getSheenColorTexture=function(){return this.sheenColorTexture?this.sheenColorTexture.getChild():null},o.getSheenColorTextureInfo=function(){return this.sheenColorTexture?this.sheenColorTextureInfo.getChild():null},o.setSheenColorTexture=function(e){return this.sheenColorTexture=this.graph.linkTexture("sheenColorTexture",ee|te|re,this,e),this},o.getSheenRoughnessFactor=function(){return this._sheenRoughnessFactor},o.setSheenRoughnessFactor=function(e){return this._sheenRoughnessFactor=e,this},o.getSheenRoughnessTexture=function(){return this.sheenRoughnessTexture?this.sheenRoughnessTexture.getChild():null},o.getSheenRoughnessTextureInfo=function(){return this.sheenRoughnessTexture?this.sheenRoughnessTextureInfo.getChild():null},o.setSheenRoughnessTexture=function(e){return this.sheenRoughnessTexture=this.graph.linkTexture("sheenRoughnessTexture",ne,this,e),this},r}(e.ExtensionProperty);oe.EXTENSION_NAME="KHR_materials_sheen",u([e.GraphChild],oe.prototype,"sheenColorTexture",void 0),u([e.GraphChild],oe.prototype,"sheenColorTextureInfo",void 0),u([e.GraphChild],oe.prototype,"sheenRoughnessTexture",void 0),u([e.GraphChild],oe.prototype,"sheenRoughnessTextureInfo",void 0);var se="KHR_materials_sheen",ie=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=se,t}n(t,e);var r=t.prototype;return r.createSheen=function(){return new oe(this.doc.getGraph(),this)},r.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[se]){var s=t.createSheen();e.materials[o].setExtension(se,s);var i=r.extensions[se];if(void 0!==i.sheenColorFactor&&s.setSheenColorFactor(i.sheenColorFactor),void 0!==i.sheenRoughnessFactor&&s.setSheenRoughnessFactor(i.sheenRoughnessFactor),void 0!==i.sheenColorTexture){var a=i.sheenColorTexture;s.setSheenColorTexture(e.textures[n[a.index].source]),e.setTextureInfo(s.getSheenColorTextureInfo(),a)}if(void 0!==i.sheenRoughnessTexture){var u=i.sheenRoughnessTexture;s.setSheenRoughnessTexture(e.textures[n[u.index].source]),e.setTextureInfo(s.getSheenRoughnessTextureInfo(),u)}}}),this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var n=r.getExtension(se);if(n){var o=e.materialIndexMap.get(r),s=t.json.materials[o];s.extensions=s.extensions||{};var i=s.extensions[se]={sheenColorFactor:n.getSheenColorFactor(),sheenRoughnessFactor:n.getSheenRoughnessFactor()};if(n.getSheenColorTexture()){var a=n.getSheenColorTexture(),u=n.getSheenColorTextureInfo();i.sheenColorTexture=e.createTextureInfoDef(a,u)}if(n.getSheenRoughnessTexture()){var c=n.getSheenRoughnessTexture(),l=n.getSheenRoughnessTextureInfo();i.sheenRoughnessTexture=e.createTextureInfoDef(c,l)}}}),this},t}(e.Extension);ie.EXTENSION_NAME=se;var ae=e.TextureChannel.R,ue=e.TextureChannel.G,ce=e.TextureChannel.B,le=e.TextureChannel.A,he=function(t){function r(){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",s(r),new e.TextureInfo(r.graph)),r}n(r,t);var o=r.prototype;return o.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},o.dispose=function(){this.specularTextureInfo.getChild().dispose(),t.prototype.dispose.call(this)},o.getSpecularFactor=function(){return this._specularFactor},o.setSpecularFactor=function(e){return this._specularFactor=e,this},o.getSpecularColorFactor=function(){return this._specularColorFactor},o.setSpecularColorFactor=function(e){return this._specularColorFactor=e,this},o.getSpecularColorHex=function(){return e.ColorUtils.factorToHex(this._specularColorFactor)},o.setSpecularColorHex=function(t){return e.ColorUtils.hexToFactor(t,this._specularColorFactor),this},o.getSpecularTexture=function(){return this.specularTexture?this.specularTexture.getChild():null},o.getSpecularTextureInfo=function(){return this.specularTexture?this.specularTextureInfo.getChild():null},o.setSpecularTexture=function(e){return this.specularTexture=this.graph.linkTexture("specularTexture",ae|ue|ce|le,this,e),this},r}(e.ExtensionProperty);he.EXTENSION_NAME="KHR_materials_specular",u([e.GraphChild],he.prototype,"specularTexture",void 0),u([e.GraphChild],he.prototype,"specularTextureInfo",void 0);var pe="KHR_materials_specular",fe=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=pe,t}n(t,e);var r=t.prototype;return r.createSpecular=function(){return new he(this.doc.getGraph(),this)},r.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[pe]){var s=t.createSpecular();e.materials[o].setExtension(pe,s);var i=r.extensions[pe];if(void 0!==i.specularFactor&&s.setSpecularFactor(i.specularFactor),void 0!==i.specularColorFactor&&s.setSpecularColorFactor(i.specularColorFactor),void 0!==i.specularTexture){var a=i.specularTexture;s.setSpecularTexture(e.textures[n[a.index].source]),e.setTextureInfo(s.getSpecularTextureInfo(),a)}}}),this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var n=r.getExtension(pe);if(n){var o=e.materialIndexMap.get(r),s=t.json.materials[o];s.extensions=s.extensions||{};var i=s.extensions[pe]={specularFactor:n.getSpecularFactor(),specularColorFactor:n.getSpecularColorFactor()};if(n.getSpecularTexture()){var a=n.getSpecularTexture(),u=n.getSpecularTextureInfo();i.specularTexture=e.createTextureInfoDef(a,u)}}}),this},t}(e.Extension);fe.EXTENSION_NAME=pe;var xe=e.TextureChannel.R,Te=function(t){function r(){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",s(r),new e.TextureInfo(r.graph)),r}n(r,t);var o=r.prototype;return o.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},o.dispose=function(){this.transmissionTextureInfo.getChild().dispose(),t.prototype.dispose.call(this)},o.getTransmissionFactor=function(){return this._transmissionFactor},o.setTransmissionFactor=function(e){return this._transmissionFactor=e,this},o.getTransmissionTexture=function(){return this.transmissionTexture?this.transmissionTexture.getChild():null},o.getTransmissionTextureInfo=function(){return this.transmissionTexture?this.transmissionTextureInfo.getChild():null},o.setTransmissionTexture=function(e){return this.transmissionTexture=this.graph.linkTexture("transmissionTexture",xe,this,e),this},r}(e.ExtensionProperty);Te.EXTENSION_NAME="KHR_materials_transmission",u([e.GraphChild],Te.prototype,"transmissionTexture",void 0),u([e.GraphChild],Te.prototype,"transmissionTextureInfo",void 0);var ge="KHR_materials_transmission",de=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=ge,t}n(t,e);var r=t.prototype;return r.createTransmission=function(){return new Te(this.doc.getGraph(),this)},r.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[ge]){var s=t.createTransmission();e.materials[o].setExtension(ge,s);var i=r.extensions[ge];if(void 0!==i.transmissionFactor&&s.setTransmissionFactor(i.transmissionFactor),void 0!==i.transmissionTexture){var a=i.transmissionTexture;s.setTransmissionTexture(e.textures[n[a.index].source]),e.setTextureInfo(s.getTransmissionTextureInfo(),a)}}}),this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var n=r.getExtension(ge);if(n){var o=e.materialIndexMap.get(r),s=t.json.materials[o];s.extensions=s.extensions||{};var i=s.extensions[ge]={transmissionFactor:n.getTransmissionFactor()};if(n.getTransmissionTexture()){var a=n.getTransmissionTexture(),u=n.getTransmissionTextureInfo();i.transmissionTexture=e.createTextureInfoDef(a,u)}}}),this},t}(e.Extension);de.EXTENSION_NAME=ge;var ve=function(t){function r(){var r;return(r=t.apply(this,arguments)||this).propertyType="Unlit",r.parentTypes=[e.PropertyType.MATERIAL],r.extensionName="KHR_materials_unlit",r}return n(r,t),r}(e.ExtensionProperty);ve.EXTENSION_NAME="KHR_materials_unlit";var me="KHR_materials_unlit",ye=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=me,t}n(t,e);var r=t.prototype;return r.createUnlit=function(){return new ve(this.doc.getGraph(),this)},r.read=function(e){var t=this;return(e.jsonDoc.json.materials||[]).forEach(function(r,n){r.extensions&&r.extensions[me]&&e.materials[n].setExtension(me,t.createUnlit())}),this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){if(r.getExtension(me)){var n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{},o.extensions[me]={}}}),this},t}(e.Extension);ye.EXTENSION_NAME=me;var Ce=function(t){function r(){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}n(r,t);var o=r.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()})},r}(e.ExtensionProperty);Ce.EXTENSION_NAME="KHR_materials_variants",u([e.GraphChild],Ce.prototype,"material",void 0),u([e.GraphChildList],Ce.prototype,"variants",void 0);var Ie=function(t){function r(){var r;return(r=t.apply(this,arguments)||this).propertyType="MappingList",r.parentTypes=[e.PropertyType.PRIMITIVE],r.extensionName="KHR_materials_variants",r.mappings=[],r}n(r,t);var o=r.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()})},r}(e.ExtensionProperty);Ie.EXTENSION_NAME="KHR_materials_variants",u([e.GraphChildList],Ie.prototype,"mappings",void 0);var _e=function(t){function r(){var r;return(r=t.apply(this,arguments)||this).propertyType="Variant",r.parentTypes=[e.PropertyType.ROOT,"MappingList"],r.extensionName="KHR_materials_variants",r}return n(r,t),r}(e.ExtensionProperty);_e.EXTENSION_NAME="KHR_materials_variants";var Ee="KHR_materials_variants",Ne=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=Ee,t}n(t,e);var r=t.prototype;return r.createMappingList=function(){return new Ie(this.doc.getGraph(),this)},r.createVariant=function(e){return void 0===e&&(e=""),new _e(this.doc.getGraph(),this).setName(e)},r.createMapping=function(){return new Ce(this.doc.getGraph(),this)},r.listVariants=function(){return Array.from(this.properties).filter(function(e){return e instanceof _e})},r.read=function(e){var t=this,r=e.jsonDoc;if(!r.json.extensions||!r.json.extensions[Ee])return this;var n=(r.json.extensions[Ee].variants||[]).map(function(e){return t.createVariant().setName(e.name||"")});return(r.json.meshes||[]).forEach(function(r,o){var s=e.meshes[o];(r.primitives||[]).forEach(function(r,o){if(r.extensions&&r.extensions[Ee]){for(var i,u=t.createMappingList(),c=a(r.extensions[Ee].mappings);!(i=c()).done;){var l=i.value,h=t.createMapping();void 0!==l.material&&h.setMaterial(e.materials[l.material]);for(var p,f=a(l.variants||[]);!(p=f()).done;)h.addVariant(n[p.value]);u.addMapping(h)}s.listPrimitives()[o].setExtension(Ee,u)}})}),this},r.write=function(e){var t=e.jsonDoc,r=this.listVariants();if(!r.length)return this;for(var n,o=[],s=new Map,i=a(r);!(n=i()).done;){var u=n.value;s.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(Ee)){var o=e.jsonDoc.json.meshes[r].primitives[n],i=t.getExtension(Ee).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 s.get(e)}),r});o.extensions=o.extensions||{},o.extensions[Ee]={mappings:i}}})},h=a(this.doc.getRoot().listMeshes());!(c=h()).done;)l();return t.json.extensions=t.json.extensions||{},t.json.extensions[Ee]={variants:o},this},t}(e.Extension);Ne.EXTENSION_NAME=Ee;var Re=e.TextureChannel.G,Ae=function(t){function r(){var r;return(r=t.apply(this,arguments)||this).propertyType="Transmission",r.parentTypes=[e.PropertyType.MATERIAL],r.extensionName="KHR_materials_volume",r._thicknessFactor=0,r._attenuationDistance=Infinity,r._attenuationColor=[1,1,1],r.thicknessTexture=null,r.thicknessTextureInfo=r.graph.link("thicknessTextureInfo",s(r),new e.TextureInfo(r.graph)),r}n(r,t);var o=r.prototype;return o.copy=function(r,n){return void 0===n&&(n=e.COPY_IDENTITY),t.prototype.copy.call(this,r,n),this._thicknessFactor=r._thicknessFactor,this._attenuationDistance=r._attenuationDistance,this._attenuationColor=[].concat(r._attenuationColor),r.thicknessTexture&&(this.setThicknessTexture(n(r.thicknessTexture.getChild())),this.getThicknessTextureInfo().copy(n(r.thicknessTextureInfo.getChild()),n)),this},o.dispose=function(){this.thicknessTextureInfo.getChild().dispose(),t.prototype.dispose.call(this)},o.getThicknessFactor=function(){return this._thicknessFactor},o.setThicknessFactor=function(e){return this._thicknessFactor=e,this},o.getThicknessTexture=function(){return this.thicknessTexture?this.thicknessTexture.getChild():null},o.getThicknessTextureInfo=function(){return this.thicknessTexture?this.thicknessTextureInfo.getChild():null},o.setThicknessTexture=function(e){return this.thicknessTexture=this.graph.linkTexture("thicknessTexture",Re,this,e),this},o.getAttenuationDistance=function(){return this._attenuationDistance},o.setAttenuationDistance=function(e){return this._attenuationDistance=e,this},o.getAttenuationColor=function(){return this._attenuationColor},o.setAttenuationColor=function(e){return this._attenuationColor=e,this},o.getAttenuationColorHex=function(){return e.ColorUtils.factorToHex(this._attenuationColor)},o.setAttenuationColorHex=function(t){return e.ColorUtils.hexToFactor(t,this._attenuationColor),this},r}(e.ExtensionProperty);Ae.EXTENSION_NAME="KHR_materials_volume",u([e.GraphChild],Ae.prototype,"thicknessTexture",void 0),u([e.GraphChild],Ae.prototype,"thicknessTextureInfo",void 0);var Se="KHR_materials_volume",Me=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=Se,t}n(t,e);var r=t.prototype;return r.createVolume=function(){return new Ae(this.doc.getGraph(),this)},r.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[Se]){var s=t.createVolume();e.materials[o].setExtension(Se,s);var i=r.extensions[Se];if(void 0!==i.thicknessFactor&&s.setThicknessFactor(i.thicknessFactor),void 0!==i.attenuationDistance&&s.setAttenuationDistance(i.attenuationDistance),void 0!==i.attenuationColor&&s.setAttenuationColor(i.attenuationColor),void 0!==i.thicknessTexture){var a=i.thicknessTexture;s.setThicknessTexture(e.textures[n[a.index].source]),e.setTextureInfo(s.getThicknessTextureInfo(),a)}}}),this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var n=r.getExtension(Se);if(n){var o=e.materialIndexMap.get(r),s=t.json.materials[o];s.extensions=s.extensions||{};var i=s.extensions[Se]={thicknessFactor:n.getThicknessFactor(),attenuationDistance:n.getAttenuationDistance(),attenuationColor:n.getAttenuationColor()};if(n.getThicknessTexture()){var a=n.getThicknessTexture(),u=n.getThicknessTextureInfo();i.thicknessTexture=e.createTextureInfoDef(a,u)}}}),this},t}(e.Extension);Me.EXTENSION_NAME=Se;var Fe="KHR_mesh_quantization",Oe=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=Fe,t}n(t,e);var r=t.prototype;return r.read=function(e){return this},r.write=function(e){return this},t}(e.Extension);Oe.EXTENSION_NAME=Fe;var De="KHR_texture_basisu",Ge=function(){function e(){}var r=e.prototype;return r.getSize=function(e){var r=t.read(new Uint8Array(e));return[r.pixelWidth,r.pixelHeight]},r.getChannels=function(e){var r=t.read(new Uint8Array(e)).dataFormatDescriptor[0];if(r.colorModel===t.KTX2Model.ETC1S)return 2===r.samples.length&&15==(15&r.samples[1].channelID)?4:3;if(r.colorModel===t.KTX2Model.UASTC)return 3==(15&r.samples[0].channelID)?4:3;throw new Error('Unexpected KTX2 colorModel, "'+r.colorModel+'".')},r.getGPUByteLength=function(e){for(var r=t.read(new Uint8Array(e)),n=this.getChannels(e)>3,o=0,s=0;s<r.levels.length;s++){var i=r.levels[s];o+=i.uncompressedByteLength?i.uncompressedByteLength:Math.max(1,Math.floor(r.pixelWidth/Math.pow(2,s)))/4*(Math.max(1,Math.floor(r.pixelHeight/Math.pow(2,s)))/4)*(n?16:8)}return o},e}(),we=function(t){function r(){var r;return(r=t.apply(this,arguments)||this).extensionName=De,r.prereadTypes=[e.PropertyType.TEXTURE],r}n(r,t),r.register=function(){e.ImageUtils.registerFormat("image/ktx2",new Ge)};var o=r.prototype;return o.preread=function(e){return e.jsonDoc.json.textures.forEach(function(e){e.extensions&&e.extensions[De]&&(e.source=e.extensions[De].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[De]={source:e.source},delete e.source)})}}),this},r}(e.Extension);we.EXTENSION_NAME=De;var je=function(t){function r(){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=null,r}n(r,t);var o=r.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},r}(e.ExtensionProperty);je.EXTENSION_NAME="KHR_texture_transform";var be="KHR_texture_transform",Pe=function(t){function r(){var e;return(e=t.apply(this,arguments)||this).extensionName=be,e}n(r,t);var o=r.prototype;return o.createTransform=function(){return new je(this.doc.getGraph(),this)},o.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[be]){var i=this.createTransform(),a=s.extensions[be];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(be,i)}}return this},o.write=function(t){for(var r=0,n=Array.from(t.textureInfoDefMap.entries());r<n.length;r++){var o=n[r],s=o[1],i=o[0].getExtension(be);if(i){s.extensions=s.extensions||{};var a={},u=e.MathUtils.eq;u(i.getOffset(),[0,0])||(a.offset=i.getOffset()),0!==i.getRotation()&&(a.rotation=i.getRotation()),u(i.getScale(),[1,1])||(a.scale=i.getScale()),null!=i.getTexCoord()&&(a.texCoord=i.getTexCoord()),s.extensions[be]=a}}return this},r}(e.Extension);Pe.EXTENSION_NAME=be;var Ue=[G,P,K,Y,Z,fe,ie,de,ye,Ne,Me,Oe,we,Pe],ke=[h,x].concat(Ue);exports.ALL_EXTENSIONS=ke,exports.Clearcoat=L,exports.DracoMeshCompression=G,exports.IOR=X,exports.InstancedMesh=c,exports.KHRONOS_EXTENSIONS=Ue,exports.Light=j,exports.LightsPunctual=P,exports.Mapping=Ce,exports.MappingList=Ie,exports.MaterialsClearcoat=K,exports.MaterialsIOR=Y,exports.MaterialsPBRSpecularGlossiness=Z,exports.MaterialsSheen=ie,exports.MaterialsSpecular=fe,exports.MaterialsTransmission=de,exports.MaterialsUnlit=ye,exports.MaterialsVariants=Ne,exports.MaterialsVolume=Me,exports.MeshGPUInstancing=h,exports.MeshQuantization=Oe,exports.PBRSpecularGlossiness=J,exports.Sheen=oe,exports.Specular=he,exports.TextureBasisu=we,exports.TextureTransform=Pe,exports.TextureWebP=x,exports.Transform=je,exports.Transmission=Te,exports.Unlit=ve,exports.Variant=_e,exports.Volume=Ae; | ||
//# sourceMappingURL=extensions.js.map |
@@ -1,2 +0,2 @@ | ||
import{ExtensionProperty as e,PropertyType as t,COPY_IDENTITY as s,GraphChildList as r,Extension as o,ImageUtils as n,BufferUtils as i,Accessor as a,GLB_BUFFER as c,Primitive as u,ColorUtils as h,MathUtils as l,TextureInfo as p,GraphChild as x}from"@gltf-transform/core";import{read as g}from"ktx-parse";function T(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}class d extends e{constructor(){super(...arguments),this.propertyType="InstancedMesh",this.parentTypes=[t.NODE],this.extensionName="EXT_mesh_gpu_instancing",this.attributes=[]}copy(e,t=s){return super.copy(e,t),this.clearGraphChildList(this.attributes),e.listSemantics().forEach(s=>{this.setAttribute(s,t(e.getAttribute(s)))}),this}getAttribute(e){const t=this.attributes.find(t=>t.semantic===e);return t?t.getChild():null}setAttribute(e,t){const s=this.getAttribute(e);if(s&&this.removeGraphChild(this.attributes,s),!t)return this;const r=this.graph.linkAttribute(e.toLowerCase(),this,t);return r.semantic=e,this.addGraphChild(this.attributes,r)}listAttributes(){return this.attributes.map(e=>e.getChild())}listSemantics(){return this.attributes.map(e=>e.semantic)}}d.EXTENSION_NAME="EXT_mesh_gpu_instancing",T([r],d.prototype,"attributes",void 0);const f="EXT_mesh_gpu_instancing";class m extends o{constructor(){super(...arguments),this.extensionName=f,this.provideTypes=[t.NODE],this.prewriteTypes=[t.ACCESSOR]}createInstancedMesh(){return new d(this.doc.getGraph(),this)}read(e){return(e.jsonDoc.json.nodes||[]).forEach((t,s)=>{if(!t.extensions||!t.extensions[f])return;const r=t.extensions[f],o=this.createInstancedMesh();for(const t in r.attributes)o.setAttribute(t,e.accessors[r.attributes[t]]);e.nodes[s].setExtension(f,o)}),this}prewrite(e){e.accessorUsageGroupedByParent.add("INSTANCE_ATTRIBUTE");for(const t of this.properties)for(const s of t.listAttributes())e.setAccessorUsage(s,"INSTANCE_ATTRIBUTE");return this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listNodes().forEach(s=>{const r=s.getExtension(f);if(r){const o=e.nodeIndexMap.get(s),n=t.json.nodes[o],i={attributes:{}};r.listSemantics().forEach(t=>{const s=r.getAttribute(t);i.attributes[t]=e.accessorIndexMap.get(s)}),n.extensions=n.extensions||{},n.extensions[f]=i}}),this}}m.EXTENSION_NAME=f;const _="EXT_texture_webp";class I{getSize(e){const t=i.decodeText(e.slice(0,4)),s=i.decodeText(e.slice(8,12));if("RIFF"!==t||"WEBP"!==s)return null;const r=new DataView(e);let o=12;for(;o<e.byteLength;){const t=i.decodeText(e.slice(o,o+4)),s=r.getUint32(o+4,!0);if("VP8 "===t)return[16383&r.getInt16(o+14,!0),16383&r.getInt16(o+16,!0)];if("VP8L"===t){const e=r.getUint8(o+9),t=r.getUint8(o+10),s=r.getUint8(o+11);return[1+((63&t)<<8|e),1+((15&r.getUint8(o+12))<<10|s<<2|(192&t)>>6)]}o+=8+s+s%2}return null}getChannels(e){return 4}}class C extends o{constructor(){super(...arguments),this.extensionName=_,this.prereadTypes=[t.TEXTURE]}static register(){n.registerFormat("image/webp",new I)}preread(e){return(e.jsonDoc.json.textures||[]).forEach(e=>{e.extensions&&e.extensions[_]&&(e.source=e.extensions[_].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[_]={source:e.source},delete e.source)})}}),this}}C.EXTENSION_NAME=_;const E="KHR_draco_mesh_compression";let N,y,R,S;function A(e,t){const s=new N.DecoderBuffer;try{if(s.Init(t,t.length),e.GetEncodedGeometryType(s)!==N.TRIANGULAR_MESH)throw new Error(`[${E}] Unknown geometry type.`);const r=new N.Mesh;if(!e.DecodeBufferToMesh(s,r).ok()||0===r.ptr)throw new Error(`[${E}] Decoding failure.`);return r}finally{N.destroy(s)}}function F(e,t){const s=3*t.num_faces(),r=s*Uint32Array.BYTES_PER_ELEMENT,o=N._malloc(r);e.GetTrianglesUInt32Array(t,r,o);const n=new Uint32Array(N.HEAP32.buffer,o,s).slice();return N._free(o),n}function M(e,t,s,r){const o=R[r.componentType],n=y[r.componentType],i=s.num_components(),a=t.num_points()*i,c=a*n.BYTES_PER_ELEMENT,u=N._malloc(c);e.GetAttributeDataArrayForAllPoints(t,s,o,c,u);const h=new n(N.HEAPF32.buffer,u,a).slice();return N._free(u),h}function D(){return(D=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(e[r]=s[r])}return e}).apply(this,arguments)}var O,v;!function(e){e[e.EDGEBREAKER=1]="EDGEBREAKER",e[e.SEQUENTIAL=0]="SEQUENTIAL"}(O||(O={})),function(e){e.POSITION="POSITION",e.NORMAL="NORMAL",e.COLOR="COLOR",e.TEX_COORD="TEX_COORD",e.GENERIC="GENERIC"}(v||(v={}));const w={[v.POSITION]:14,[v.NORMAL]:10,[v.COLOR]:8,[v.TEX_COORD]:12,[v.GENERIC]:12},j={decodeSpeed:5,encodeSpeed:5,method:O.EDGEBREAKER,quantizationBits:w};function G(e,t=j){const s=D({},j,t);s.quantizationBits=D({},w,t.quantizationBits);const r=new S.Encoder,o=new S.MeshBuilder,n=new S.Mesh,i={},a=new S.DracoInt8Array;for(const t of e.listSemantics()){const a=e.getAttribute(t),c=b(t),u=o[k[a.getComponentType()]](n,S[c],a.getCount(),a.getElementSize(),a.getArray());if(-1===u)throw new Error(`Error compressing "${t}" attribute.`);i[t]=u,r.SetAttributeQuantization(S[c],s.quantizationBits[c])}const c=e.getIndices();if(!c)throw new Error("Primitive must have indices.");o.AddFacesToMesh(n,c.getCount()/3,c.getArray()),r.SetSpeedOptions(s.encodeSpeed,s.decodeSpeed),r.SetTrackEncodedProperties(!0),e.listTargets().length>0||s.method===O.SEQUENTIAL?r.SetEncodingMethod(S.MESH_SEQUENTIAL_ENCODING):r.SetEncodingMethod(S.MESH_EDGEBREAKER_ENCODING);const u=r.EncodeMeshToDracoBuffer(n,a);if(u<=0)throw new Error("Error applying Draco compression.");const h=new Uint8Array(u);for(let e=0;e<u;++e)h[e]=a.GetValue(e);const l=r.GetNumberOfEncodedPoints(),p=3*r.GetNumberOfEncodedFaces();return S.destroy(a),S.destroy(n),S.destroy(o),S.destroy(r),{numVertices:l,numIndices:p,data:h,attributeIDs:i}}function b(e){return"POSITION"===e?v.POSITION:"NORMAL"===e?v.NORMAL:e.startsWith("COLOR_")?v.COLOR:e.startsWith("TEXCOORD_")?v.TEX_COORD:v.GENERIC}const k={[a.ComponentType.UNSIGNED_BYTE]:"AddUInt8Attribute",[a.ComponentType.BYTE]:"AddInt8Attribute",[a.ComponentType.UNSIGNED_SHORT]:"AddUInt16Attribute",[a.ComponentType.SHORT]:"AddInt16Attribute",[a.ComponentType.UNSIGNED_INT]:"AddUInt32Attribute",[a.ComponentType.FLOAT]:"AddFloatAttribute"},H="KHR_draco_mesh_compression";class L extends o{constructor(){super(...arguments),this.extensionName=H,this.prereadTypes=[t.PRIMITIVE],this.prewriteTypes=[t.ACCESSOR],this.dependencies=["draco3d.decoder","draco3d.encoder"],this._decoderModule=null,this._encoderModule=null,this._encoderOptions={}}install(e,t){return"draco3d.decoder"===e&&(this._decoderModule=t,N=this._decoderModule,y={[a.ComponentType.FLOAT]:Float32Array,[a.ComponentType.UNSIGNED_INT]:Uint32Array,[a.ComponentType.UNSIGNED_SHORT]:Uint16Array,[a.ComponentType.UNSIGNED_BYTE]:Uint8Array,[a.ComponentType.SHORT]:Int16Array,[a.ComponentType.BYTE]:Int8Array},R={[a.ComponentType.FLOAT]:N.DT_FLOAT32,[a.ComponentType.UNSIGNED_INT]:N.DT_UINT32,[a.ComponentType.UNSIGNED_SHORT]:N.DT_UINT16,[a.ComponentType.UNSIGNED_BYTE]:N.DT_UINT8,[a.ComponentType.SHORT]:N.DT_INT16,[a.ComponentType.BYTE]:N.DT_INT8}),"draco3d.encoder"===e&&(this._encoderModule=t,S=this._encoderModule),this}setEncoderOptions(e){return this._encoderOptions=e,this}preread(e){if(!this._decoderModule)throw new Error(`[${H}] Please install extension dependency, "draco3d.decoder".`);const t=this.doc.getLogger(),s=e.jsonDoc,r=new Map;try{const o=s.json.meshes||[];for(const n of o)for(const o of n.primitives){if(!o.extensions||!o.extensions[H])continue;const n=o.extensions[H];let[i,a]=r.get(n.bufferView)||[];if(!a||!i){const e=s.json.bufferViews[n.bufferView],o=s.json.buffers[e.buffer],u=new Int8Array(o.uri?s.resources[o.uri]:s.resources[c],e.byteOffset||0,e.byteLength);i=new this._decoderModule.Decoder,a=A(i,u),r.set(n.bufferView,[i,a]),t.debug(`[${H}] Decompressed ${u.byteLength} bytes.`)}for(const t in o.attributes){const s=e.jsonDoc.json.accessors[o.attributes[t]],r=i.GetAttributeByUniqueId(a,n.attributes[t]),c=M(i,a,r,s);e.accessors[o.attributes[t]].setArray(c)}const u=F(i,a);e.accessors[o.indices].setArray(u)}}finally{for(const[e,t]of Array.from(r.values()))this._decoderModule.destroy(e),this._decoderModule.destroy(t)}return this}read(e){return this}prewrite(e,t){if(!this._encoderModule)throw new Error(`[${H}] Please install extension dependency, "draco3d.encoder".`);const s=this.doc.getLogger();s.debug(`[${H}] 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()?e.getMode()!==u.Mode.TRIANGLES?(r.add(e),t.warn(`[${H}] Skipping Draco compression on non-TRIANGLES primitive.`)):s.add(e):(r.add(e),t.warn(`[${H}] 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 Set,c=new Map;for(const t of Array.from(s)){let s=U(t,n);if(a.has(s))c.set(t,s);else{if(i.has(t.getIndices())){const s=t.getIndices().clone();n.set(s,e.getRoot().listAccessors().length-1),t.swap(t.getIndices(),s)}for(const s of t.listAttributes())if(i.has(s)){const r=s.clone();n.set(r,e.getRoot().listAccessors().length-1),t.swap(s,r)}s=U(t,n),a.add(s),c.set(t,s),i.set(t.getIndices(),s);for(const e of t.listAttributes())i.set(e,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(`[${H}] Compressed accessors must only be used as indices or vertex attributes.`)}for(const e of Array.from(s)){const t=c.get(e);if(i.get(e.getIndices())!==t||e.listAttributes().some(e=>i.get(e)!==t))throw new Error(`[${H}] 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(`[${H}] Accessor cannot be shared by compressed and uncompressed primitives.`);return c}(this.doc),o=new Map;for(const t of Array.from(r.keys())){const s=r.get(t);if(!s)throw new Error("Unexpected primitive.");if(o.has(s)){o.set(s,o.get(s));continue}const n=G(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(`[${H}] Compressed ${r.size} primitives.`),e.extensionData[H]={primitiveHashMap:r,primitiveEncodingMap:o},this}write(e){const t=e.extensionData[H];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[H]={bufferView:e.otherBufferViewsIndexMap.get(c.data),attributes:c.attributeIDs}}}if(!t.primitiveHashMap.size){const t=e.jsonDoc.json;t.extensionsUsed=(t.extensionsUsed||[]).filter(e=>e!==H),t.extensionsRequired=(t.extensionsRequired||[]).filter(e=>e!==H)}return this}}function U(e,t){const s=[];s.push(t.get(e.getIndices()));for(const r of e.listAttributes())s.push(t.get(r));return s.sort().join("|")}L.EXTENSION_NAME=H,L.EncoderMethod=O;class K extends e{constructor(){super(...arguments),this.propertyType="Light",this.parentTypes=[t.NODE],this.extensionName="KHR_lights_punctual",this._color=[1,1,1],this._intensity=1,this._type=K.Type.POINT,this._range=null,this._innerConeAngle=0,this._outerConeAngle=Math.PI/4}copy(e,t=s){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 h.factorToHex(this._color)}setColorHex(e){return h.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}}K.EXTENSION_NAME="KHR_lights_punctual",K.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};const P="KHR_lights_punctual";class X extends o{constructor(){super(...arguments),this.extensionName=P}createLight(){return new K(this.doc.getGraph(),this)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions[P])return this;const s=(t.json.extensions[P].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[P]&&e.nodes[r].setExtension(P,s[t.extensions[P].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()};l.eq(t.getColor(),[1,1,1])||(o.color=t.getColor()),1!==t.getIntensity()&&(o.intensity=t.getIntensity()),null!=t.getRange()&&(o.range=t.getRange()),t.getName()&&(o.name=t.getName()),t.getType()===K.Type.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(P);if(o){const n=e.nodeIndexMap.get(s),i=t.json.nodes[n];i.extensions=i.extensions||{},i.extensions[P]={light:r.get(o)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[P]={lights:s},this}}X.EXTENSION_NAME=P;class B extends e{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 p(this.graph)),this.clearcoatRoughnessTexture=null,this.clearcoatRoughnessTextureInfo=this.graph.link("clearcoatRoughnessTextureInfo",this,new p(this.graph)),this.clearcoatNormalTexture=null,this.clearcoatNormalTextureInfo=this.graph.link("clearcoatNormalTextureInfo",this,new p(this.graph))}copy(e,t=s){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}}B.EXTENSION_NAME="KHR_materials_clearcoat",T([x],B.prototype,"clearcoatTexture",void 0),T([x],B.prototype,"clearcoatTextureInfo",void 0),T([x],B.prototype,"clearcoatRoughnessTexture",void 0),T([x],B.prototype,"clearcoatRoughnessTextureInfo",void 0),T([x],B.prototype,"clearcoatNormalTexture",void 0),T([x],B.prototype,"clearcoatNormalTextureInfo",void 0);const V="KHR_materials_clearcoat";class $ extends o{constructor(){super(...arguments),this.extensionName=V}createClearcoat(){return new B(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[V]){const o=this.createClearcoat();e.materials[r].setExtension(V,o);const n=t.extensions[V];if(void 0!==n.clearcoatFactor&&o.setClearcoatFactor(n.clearcoatFactor),void 0!==n.clearcoatRoughnessFactor&&o.setClearcoatRoughnessFactor(n.clearcoatRoughnessFactor),void 0!==n.clearcoatTexture){const t=n.clearcoatTexture;o.setClearcoatTexture(e.textures[s[t.index].source]),e.setTextureInfo(o.getClearcoatTextureInfo(),t)}if(void 0!==n.clearcoatRoughnessTexture){const t=n.clearcoatRoughnessTexture;o.setClearcoatRoughnessTexture(e.textures[s[t.index].source]),e.setTextureInfo(o.getClearcoatRoughnessTextureInfo(),t)}if(void 0!==n.clearcoatNormalTexture){const t=n.clearcoatNormalTexture;o.setClearcoatNormalTexture(e.textures[s[t.index].source]),e.setTextureInfo(o.getClearcoatNormalTextureInfo(),t),void 0!==t.scale&&o.setClearcoatNormalScale(t.scale)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(V);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];n.extensions=n.extensions||{};const i=n.extensions[V]={clearcoatFactor:r.getClearcoatFactor(),clearcoatRoughnessFactor:r.getClearcoatRoughnessFactor()};if(r.getClearcoatTexture()){const t=r.getClearcoatTexture(),s=r.getClearcoatTextureInfo();i.clearcoatTexture=e.createTextureInfoDef(t,s)}if(r.getClearcoatRoughnessTexture()){const t=r.getClearcoatRoughnessTexture(),s=r.getClearcoatRoughnessTextureInfo();i.clearcoatRoughnessTexture=e.createTextureInfoDef(t,s)}if(r.getClearcoatNormalTexture()){const t=r.getClearcoatNormalTexture(),s=r.getClearcoatNormalTextureInfo();i.clearcoatNormalTexture=e.createTextureInfoDef(t,s),1!==r.getClearcoatNormalScale()&&(i.clearcoatNormalTexture.scale=r.getClearcoatNormalScale())}}}),this}}$.EXTENSION_NAME=V;class z extends e{constructor(){super(...arguments),this.propertyType="IOR",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_ior",this._ior=0}copy(e,t=s){return super.copy(e,t),this._ior=e._ior,this}getIOR(){return this._ior}setIOR(e){return this._ior=e,this}}z.EXTENSION_NAME="KHR_materials_ior";const q="KHR_materials_ior";class Y extends o{constructor(){super(...arguments),this.extensionName=q}createIOR(){return new z(this.doc.getGraph(),this)}read(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{if(t.extensions&&t.extensions[q]){const r=this.createIOR();e.materials[s].setExtension(q,r);const o=t.extensions[q];void 0!==o.ior&&r.setIOR(o.ior)}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(q);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];n.extensions=n.extensions||{},n.extensions[q]={ior:r.getIOR()}}}),this}}Y.EXTENSION_NAME=q;class Q extends e{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 p(this.graph)),this.specularGlossinessTexture=null,this.specularGlossinessTextureInfo=this.graph.link("specularGlossinessTextureInfo",this,new p(this.graph))}copy(e,t=s){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 h.factorToHex(this._diffuseFactor)}setDiffuseHex(e){return h.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}}Q.EXTENSION_NAME="KHR_materials_pbrSpecularGlossiness",T([x],Q.prototype,"diffuseTexture",void 0),T([x],Q.prototype,"diffuseTextureInfo",void 0),T([x],Q.prototype,"specularGlossinessTexture",void 0),T([x],Q.prototype,"specularGlossinessTextureInfo",void 0);const W="KHR_materials_pbrSpecularGlossiness";class J extends o{constructor(){super(...arguments),this.extensionName=W}createPBRSpecularGlossiness(){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[W]){const o=this.createPBRSpecularGlossiness();e.materials[r].setExtension(W,o);const n=t.extensions[W];if(void 0!==n.diffuseFactor&&o.setDiffuseFactor(n.diffuseFactor),void 0!==n.specularFactor&&o.setSpecularFactor(n.specularFactor),void 0!==n.glossinessFactor&&o.setGlossinessFactor(n.glossinessFactor),void 0!==n.diffuseTexture){const t=n.diffuseTexture;o.setDiffuseTexture(e.textures[s[t.index].source]),e.setTextureInfo(o.getDiffuseTextureInfo(),t)}if(void 0!==n.specularGlossinessTexture){const t=n.specularGlossinessTexture;o.setSpecularGlossinessTexture(e.textures[s[t.index].source]),e.setTextureInfo(o.getSpecularGlossinessTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(W);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];n.extensions=n.extensions||{};const i=n.extensions[W]={diffuseFactor:r.getDiffuseFactor(),specularFactor:r.getSpecularFactor(),glossinessFactor:r.getGlossinessFactor()};if(r.getDiffuseTexture()){const t=r.getDiffuseTexture(),s=r.getDiffuseTextureInfo();i.diffuseTexture=e.createTextureInfoDef(t,s)}if(r.getSpecularGlossinessTexture()){const t=r.getSpecularGlossinessTexture(),s=r.getSpecularGlossinessTextureInfo();i.specularGlossinessTexture=e.createTextureInfoDef(t,s)}}}),this}}J.EXTENSION_NAME=W;class Z extends e{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 p(this.graph)),this.sheenRoughnessTexture=null,this.sheenRoughnessTextureInfo=this.graph.link("sheenRoughnessTextureInfo",this,new p(this.graph))}copy(e,t=s){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 h.factorToHex(this._sheenColorFactor)}setSheenColorFactor(e){return this._sheenColorFactor=e,this}setSheenColorHex(e){return h.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}}Z.EXTENSION_NAME="KHR_materials_sheen",T([x],Z.prototype,"sheenColorTexture",void 0),T([x],Z.prototype,"sheenColorTextureInfo",void 0),T([x],Z.prototype,"sheenRoughnessTexture",void 0),T([x],Z.prototype,"sheenRoughnessTextureInfo",void 0);const ee="KHR_materials_sheen";class te extends o{constructor(){super(...arguments),this.extensionName=ee}createSheen(){return new Z(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[ee]){const o=this.createSheen();e.materials[r].setExtension(ee,o);const n=t.extensions[ee];if(void 0!==n.sheenColorFactor&&o.setSheenColorFactor(n.sheenColorFactor),void 0!==n.sheenRoughnessFactor&&o.setSheenRoughnessFactor(n.sheenRoughnessFactor),void 0!==n.sheenColorTexture){const t=n.sheenColorTexture;o.setSheenColorTexture(e.textures[s[t.index].source]),e.setTextureInfo(o.getSheenColorTextureInfo(),t)}if(void 0!==n.sheenRoughnessTexture){const t=n.sheenRoughnessTexture;o.setSheenRoughnessTexture(e.textures[s[t.index].source]),e.setTextureInfo(o.getSheenRoughnessTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(ee);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];n.extensions=n.extensions||{};const i=n.extensions[ee]={sheenColorFactor:r.getSheenColorFactor(),sheenRoughnessFactor:r.getSheenRoughnessFactor()};if(r.getSheenColorTexture()){const t=r.getSheenColorTexture(),s=r.getSheenColorTextureInfo();i.sheenColorTexture=e.createTextureInfoDef(t,s)}if(r.getSheenRoughnessTexture()){const t=r.getSheenRoughnessTexture(),s=r.getSheenRoughnessTextureInfo();i.sheenRoughnessTexture=e.createTextureInfoDef(t,s)}}}),this}}te.EXTENSION_NAME=ee;class se extends e{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 p(this.graph))}copy(e,t=s){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 h.factorToHex(this._specularColorFactor)}setSpecularColorHex(e){return h.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}}se.EXTENSION_NAME="KHR_materials_specular",T([x],se.prototype,"specularTexture",void 0),T([x],se.prototype,"specularTextureInfo",void 0);const re="KHR_materials_specular";class oe extends o{constructor(){super(...arguments),this.extensionName=re}createSpecular(){return new se(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[re]){const o=this.createSpecular();e.materials[r].setExtension(re,o);const n=t.extensions[re];if(void 0!==n.specularFactor&&o.setSpecularFactor(n.specularFactor),void 0!==n.specularColorFactor&&o.setSpecularColorFactor(n.specularColorFactor),void 0!==n.specularTexture){const t=n.specularTexture;o.setSpecularTexture(e.textures[s[t.index].source]),e.setTextureInfo(o.getSpecularTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(re);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];n.extensions=n.extensions||{};const i=n.extensions[re]={specularFactor:r.getSpecularFactor(),specularColorFactor:r.getSpecularColorFactor()};if(r.getSpecularTexture()){const t=r.getSpecularTexture(),s=r.getSpecularTextureInfo();i.specularTexture=e.createTextureInfoDef(t,s)}}}),this}}oe.EXTENSION_NAME=re;class ne extends e{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 p(this.graph))}copy(e,t=s){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}}ne.EXTENSION_NAME="KHR_materials_transmission",T([x],ne.prototype,"transmissionTexture",void 0),T([x],ne.prototype,"transmissionTextureInfo",void 0);const ie="KHR_materials_transmission";class ae extends o{constructor(){super(...arguments),this.extensionName=ie}createTransmission(){return new ne(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[ie]){const o=this.createTransmission();e.materials[r].setExtension(ie,o);const n=t.extensions[ie];if(void 0!==n.transmissionFactor&&o.setTransmissionFactor(n.transmissionFactor),void 0!==n.transmissionTexture){const t=n.transmissionTexture;o.setTransmissionTexture(e.textures[s[t.index].source]),e.setTextureInfo(o.getTransmissionTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(ie);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];n.extensions=n.extensions||{};const i=n.extensions[ie]={transmissionFactor:r.getTransmissionFactor()};if(r.getTransmissionTexture()){const t=r.getTransmissionTexture(),s=r.getTransmissionTextureInfo();i.transmissionTexture=e.createTextureInfoDef(t,s)}}}),this}}ae.EXTENSION_NAME=ie;class ce extends e{constructor(){super(...arguments),this.propertyType="Unlit",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_unlit"}}ce.EXTENSION_NAME="KHR_materials_unlit";const ue="KHR_materials_unlit";class he extends o{constructor(){super(...arguments),this.extensionName=ue}createUnlit(){return new ce(this.doc.getGraph(),this)}read(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{t.extensions&&t.extensions[ue]&&e.materials[s].setExtension(ue,this.createUnlit())}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{if(s.getExtension(ue)){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{},o.extensions[ue]={}}}),this}}he.EXTENSION_NAME=ue;class le extends e{constructor(){super(...arguments),this.propertyType="Mapping",this.parentTypes=["MappingList"],this.extensionName="KHR_materials_variants",this.material=null,this.variants=[]}copy(e,t=s){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())}}le.EXTENSION_NAME="KHR_materials_variants",T([x],le.prototype,"material",void 0),T([r],le.prototype,"variants",void 0);class pe extends e{constructor(){super(...arguments),this.propertyType="MappingList",this.parentTypes=[t.PRIMITIVE],this.extensionName="KHR_materials_variants",this.mappings=[]}copy(e,t=s){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())}}pe.EXTENSION_NAME="KHR_materials_variants",T([r],pe.prototype,"mappings",void 0);class xe extends e{constructor(){super(...arguments),this.propertyType="Variant",this.parentTypes=[t.ROOT,"MappingList"],this.extensionName="KHR_materials_variants"}}xe.EXTENSION_NAME="KHR_materials_variants";const ge="KHR_materials_variants";class Te extends o{constructor(){super(...arguments),this.extensionName=ge}createMappingList(){return new pe(this.doc.getGraph(),this)}createVariant(e=""){return new xe(this.doc.getGraph(),this).setName(e)}createMapping(){return new le(this.doc.getGraph(),this)}listVariants(){return Array.from(this.properties).filter(e=>e instanceof xe)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions[ge])return this;const s=(t.json.extensions[ge].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[ge])return;const n=this.createMappingList();for(const r of t.extensions[ge].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(ge,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(ge))return;const n=e.jsonDoc.json.meshes[s].primitives[r],i=t.getExtension(ge).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[ge]={mappings:i}})}return t.json.extensions=t.json.extensions||{},t.json.extensions[ge]={variants:r},this}}Te.EXTENSION_NAME=ge;class de extends e{constructor(){super(...arguments),this.propertyType="Transmission",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_volume",this._thicknessFactor=0,this._attenuationDistance=Infinity,this._attenuationColor=[1,1,1],this.thicknessTexture=null,this.thicknessTextureInfo=this.graph.link("thicknessTextureInfo",this,new p(this.graph))}copy(e,t=s){return super.copy(e,t),this._thicknessFactor=e._thicknessFactor,this._attenuationDistance=e._attenuationDistance,this._attenuationColor=[...e._attenuationColor],e.thicknessTexture&&(this.setThicknessTexture(t(e.thicknessTexture.getChild())),this.getThicknessTextureInfo().copy(t(e.thicknessTextureInfo.getChild()),t)),this}dispose(){this.thicknessTextureInfo.getChild().dispose(),super.dispose()}getThicknessFactor(){return this._thicknessFactor}setThicknessFactor(e){return this._thicknessFactor=e,this}getThicknessTexture(){return this.thicknessTexture?this.thicknessTexture.getChild():null}getThicknessTextureInfo(){return this.thicknessTexture?this.thicknessTextureInfo.getChild():null}setThicknessTexture(e){return this.thicknessTexture=this.graph.link("thicknessTexture",this,e),this}getAttenuationDistance(){return this._attenuationDistance}setAttenuationDistance(e){return this._attenuationDistance=e,this}getAttenuationColor(){return this._attenuationColor}setAttenuationColor(e){return this._attenuationColor=e,this}getAttenuationColorHex(){return h.factorToHex(this._attenuationColor)}setAttenuationColorHex(e){return h.hexToFactor(e,this._attenuationColor),this}}de.EXTENSION_NAME="KHR_materials_volume",T([x],de.prototype,"thicknessTexture",void 0),T([x],de.prototype,"thicknessTextureInfo",void 0);const fe="KHR_materials_volume";class me extends o{constructor(){super(...arguments),this.extensionName=fe}createVolume(){return new de(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[fe]){const o=this.createVolume();e.materials[r].setExtension(fe,o);const n=t.extensions[fe];if(void 0!==n.thicknessFactor&&o.setThicknessFactor(n.thicknessFactor),void 0!==n.attenuationDistance&&o.setAttenuationDistance(n.attenuationDistance),void 0!==n.attenuationColor&&o.setAttenuationColor(n.attenuationColor),void 0!==n.thicknessTexture){const t=n.thicknessTexture;o.setThicknessTexture(e.textures[s[t.index].source]),e.setTextureInfo(o.getThicknessTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(fe);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];n.extensions=n.extensions||{};const i=n.extensions[fe]={thicknessFactor:r.getThicknessFactor(),attenuationDistance:r.getAttenuationDistance(),attenuationColor:r.getAttenuationColor()};if(r.getThicknessTexture()){const t=r.getThicknessTexture(),s=r.getThicknessTextureInfo();i.thicknessTexture=e.createTextureInfoDef(t,s)}}}),this}}me.EXTENSION_NAME=fe;const _e="KHR_mesh_quantization";class Ie extends o{constructor(){super(...arguments),this.extensionName=_e}read(e){return this}write(e){return this}}Ie.EXTENSION_NAME=_e;const Ce="KHR_texture_basisu";class Ee{getSize(e){const t=g(new Uint8Array(e));return[t.pixelWidth,t.pixelHeight]}getChannels(e){const t=g(new Uint8Array(e)).dataFormatDescriptor[0];if(163===t.colorModel)return 2===t.samples.length&&15==(15&t.samples[1].channelID)?4:3;if(166===t.colorModel)return 3==(15&t.samples[0].channelID)?4:3;throw new Error(`Unexpected KTX2 colorModel, "${t.colorModel}".`)}getGPUByteLength(e){const t=g(new Uint8Array(e)),s=this.getChannels(e)>3;let r=0;for(let e=0;e<t.levels.length;e++){const o=t.levels[e];r+=o.uncompressedByteLength?o.uncompressedByteLength:Math.max(1,Math.floor(t.pixelWidth/Math.pow(2,e)))/4*(Math.max(1,Math.floor(t.pixelHeight/Math.pow(2,e)))/4)*(s?16:8)}return r}}class Ne extends o{constructor(){super(...arguments),this.extensionName=Ce,this.prereadTypes=[t.TEXTURE]}static register(){n.registerFormat("image/ktx2",new Ee)}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}}Ne.EXTENSION_NAME=Ce;class ye extends e{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=null}copy(e,t=s){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}}ye.EXTENSION_NAME="KHR_texture_transform";const Re="KHR_texture_transform";class Se extends o{constructor(){super(...arguments),this.extensionName=Re}createTransform(){return new ye(this.doc.getGraph(),this)}read(e){for(const[t,s]of Array.from(e.textureInfos.entries())){if(!s.extensions||!s.extensions[Re])continue;const e=this.createTransform(),r=s.extensions[Re];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(Re,e)}return this}write(e){const t=Array.from(e.textureInfoDefMap.entries());for(const[e,s]of t){const t=e.getExtension(Re);if(!t)continue;s.extensions=s.extensions||{};const r={},o=l.eq;o(t.getOffset(),[0,0])||(r.offset=t.getOffset()),0!==t.getRotation()&&(r.rotation=t.getRotation()),o(t.getScale(),[1,1])||(r.scale=t.getScale()),null!=t.getTexCoord()&&(r.texCoord=t.getTexCoord()),s.extensions[Re]=r}return this}}Se.EXTENSION_NAME=Re;const Ae=[L,X,$,Y,J,oe,te,ae,he,Te,me,Ie,Ne,Se],Fe=[m,C,...Ae];export{Fe as ALL_EXTENSIONS,B as Clearcoat,L as DracoMeshCompression,z as IOR,d as InstancedMesh,Ae as KHRONOS_EXTENSIONS,K as Light,X as LightsPunctual,le as Mapping,pe as MappingList,$ as MaterialsClearcoat,Y as MaterialsIOR,J as MaterialsPBRSpecularGlossiness,te as MaterialsSheen,oe as MaterialsSpecular,ae as MaterialsTransmission,he as MaterialsUnlit,Te as MaterialsVariants,me as MaterialsVolume,m as MeshGPUInstancing,Ie as MeshQuantization,Q as PBRSpecularGlossiness,Z as Sheen,se as Specular,Ne as TextureBasisu,Se as TextureTransform,C as TextureWebP,ye as Transform,ne as Transmission,ce as Unlit,xe as Variant,de as Volume}; | ||
import{ExtensionProperty as e,PropertyType as t,COPY_IDENTITY as s,GraphChildList as r,Extension as o,ImageUtils as n,BufferUtils as i,Accessor as a,GLB_BUFFER as c,Primitive as u,ColorUtils as h,MathUtils as l,TextureInfo as p,GraphChild as x,TextureChannel as g}from"@gltf-transform/core";import{read as T,KTX2Model as d}from"ktx-parse";function f(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}class m extends e{constructor(){super(...arguments),this.propertyType="InstancedMesh",this.parentTypes=[t.NODE],this.extensionName="EXT_mesh_gpu_instancing",this.attributes=[]}copy(e,t=s){return super.copy(e,t),this.clearGraphChildList(this.attributes),e.listSemantics().forEach(s=>{this.setAttribute(s,t(e.getAttribute(s)))}),this}getAttribute(e){const t=this.attributes.find(t=>t.semantic===e);return t?t.getChild():null}setAttribute(e,t){const s=this.getAttribute(e);if(s&&this.removeGraphChild(this.attributes,s),!t)return this;const r=this.graph.linkAttribute(e.toLowerCase(),this,t);return r.semantic=e,this.addGraphChild(this.attributes,r)}listAttributes(){return this.attributes.map(e=>e.getChild())}listSemantics(){return this.attributes.map(e=>e.semantic)}}m.EXTENSION_NAME="EXT_mesh_gpu_instancing",f([r],m.prototype,"attributes",void 0);const _="EXT_mesh_gpu_instancing";class I extends o{constructor(){super(...arguments),this.extensionName=_,this.provideTypes=[t.NODE],this.prewriteTypes=[t.ACCESSOR]}createInstancedMesh(){return new m(this.doc.getGraph(),this)}read(e){return(e.jsonDoc.json.nodes||[]).forEach((t,s)=>{if(!t.extensions||!t.extensions[_])return;const r=t.extensions[_],o=this.createInstancedMesh();for(const t in r.attributes)o.setAttribute(t,e.accessors[r.attributes[t]]);e.nodes[s].setExtension(_,o)}),this}prewrite(e){e.accessorUsageGroupedByParent.add("INSTANCE_ATTRIBUTE");for(const t of this.properties)for(const s of t.listAttributes())e.setAccessorUsage(s,"INSTANCE_ATTRIBUTE");return this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listNodes().forEach(s=>{const r=s.getExtension(_);if(r){const o=e.nodeIndexMap.get(s),n=t.json.nodes[o],i={attributes:{}};r.listSemantics().forEach(t=>{const s=r.getAttribute(t);i.attributes[t]=e.accessorIndexMap.get(s)}),n.extensions=n.extensions||{},n.extensions[_]=i}}),this}}I.EXTENSION_NAME=_;const C="EXT_texture_webp";class E{getSize(e){const t=i.decodeText(e.slice(0,4)),s=i.decodeText(e.slice(8,12));if("RIFF"!==t||"WEBP"!==s)return null;const r=new DataView(e);let o=12;for(;o<e.byteLength;){const t=i.decodeText(e.slice(o,o+4)),s=r.getUint32(o+4,!0);if("VP8 "===t)return[16383&r.getInt16(o+14,!0),16383&r.getInt16(o+16,!0)];if("VP8L"===t){const e=r.getUint8(o+9),t=r.getUint8(o+10),s=r.getUint8(o+11);return[1+((63&t)<<8|e),1+((15&r.getUint8(o+12))<<10|s<<2|(192&t)>>6)]}o+=8+s+s%2}return null}getChannels(e){return 4}}class N extends o{constructor(){super(...arguments),this.extensionName=C,this.prereadTypes=[t.TEXTURE]}static register(){n.registerFormat("image/webp",new E)}preread(e){return(e.jsonDoc.json.textures||[]).forEach(e=>{e.extensions&&e.extensions[C]&&(e.source=e.extensions[C].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[C]={source:e.source},delete e.source)})}}),this}}N.EXTENSION_NAME=C;const y="KHR_draco_mesh_compression";let R,S,A,F;function M(e,t){const s=new R.DecoderBuffer;try{if(s.Init(t,t.length),e.GetEncodedGeometryType(s)!==R.TRIANGULAR_MESH)throw new Error(`[${y}] Unknown geometry type.`);const r=new R.Mesh;if(!e.DecodeBufferToMesh(s,r).ok()||0===r.ptr)throw new Error(`[${y}] Decoding failure.`);return r}finally{R.destroy(s)}}function D(e,t){const s=3*t.num_faces(),r=s*Uint32Array.BYTES_PER_ELEMENT,o=R._malloc(r);e.GetTrianglesUInt32Array(t,r,o);const n=new Uint32Array(R.HEAP32.buffer,o,s).slice();return R._free(o),n}function O(e,t,s,r){const o=A[r.componentType],n=S[r.componentType],i=s.num_components(),a=t.num_points()*i,c=a*n.BYTES_PER_ELEMENT,u=R._malloc(c);e.GetAttributeDataArrayForAllPoints(t,s,o,c,u);const h=new n(R.HEAPF32.buffer,u,a).slice();return R._free(u),h}function v(){return(v=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(e[r]=s[r])}return e}).apply(this,arguments)}var w,G;!function(e){e[e.EDGEBREAKER=1]="EDGEBREAKER",e[e.SEQUENTIAL=0]="SEQUENTIAL"}(w||(w={})),function(e){e.POSITION="POSITION",e.NORMAL="NORMAL",e.COLOR="COLOR",e.TEX_COORD="TEX_COORD",e.GENERIC="GENERIC"}(G||(G={}));const j={[G.POSITION]:14,[G.NORMAL]:10,[G.COLOR]:8,[G.TEX_COORD]:12,[G.GENERIC]:12},b={decodeSpeed:5,encodeSpeed:5,method:w.EDGEBREAKER,quantizationBits:j};function k(e,t=b){const s=v({},b,t);s.quantizationBits=v({},j,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=H(t),u=o[L[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])}const c=e.getIndices();if(!c)throw new Error("Primitive must have indices.");o.AddFacesToMesh(n,c.getCount()/3,c.getArray()),r.SetSpeedOptions(s.encodeSpeed,s.decodeSpeed),r.SetTrackEncodedProperties(!0),e.listTargets().length>0||s.method===w.SEQUENTIAL?r.SetEncodingMethod(F.MESH_SEQUENTIAL_ENCODING):r.SetEncodingMethod(F.MESH_EDGEBREAKER_ENCODING);const u=r.EncodeMeshToDracoBuffer(n,a);if(u<=0)throw new Error("Error applying Draco compression.");const h=new Uint8Array(u);for(let e=0;e<u;++e)h[e]=a.GetValue(e);const l=r.GetNumberOfEncodedPoints(),p=3*r.GetNumberOfEncodedFaces();return F.destroy(a),F.destroy(n),F.destroy(o),F.destroy(r),{numVertices:l,numIndices:p,data:h,attributeIDs:i}}function H(e){return"POSITION"===e?G.POSITION:"NORMAL"===e?G.NORMAL:e.startsWith("COLOR_")?G.COLOR:e.startsWith("TEXCOORD_")?G.TEX_COORD:G.GENERIC}const L={[a.ComponentType.UNSIGNED_BYTE]:"AddUInt8Attribute",[a.ComponentType.BYTE]:"AddInt8Attribute",[a.ComponentType.UNSIGNED_SHORT]:"AddUInt16Attribute",[a.ComponentType.SHORT]:"AddInt16Attribute",[a.ComponentType.UNSIGNED_INT]:"AddUInt32Attribute",[a.ComponentType.FLOAT]:"AddFloatAttribute"},U="KHR_draco_mesh_compression";class K extends o{constructor(){super(...arguments),this.extensionName=U,this.prereadTypes=[t.PRIMITIVE],this.prewriteTypes=[t.ACCESSOR],this.dependencies=["draco3d.decoder","draco3d.encoder"],this._decoderModule=null,this._encoderModule=null,this._encoderOptions={}}install(e,t){return"draco3d.decoder"===e&&(this._decoderModule=t,R=this._decoderModule,S={[a.ComponentType.FLOAT]:Float32Array,[a.ComponentType.UNSIGNED_INT]:Uint32Array,[a.ComponentType.UNSIGNED_SHORT]:Uint16Array,[a.ComponentType.UNSIGNED_BYTE]:Uint8Array,[a.ComponentType.SHORT]:Int16Array,[a.ComponentType.BYTE]:Int8Array},A={[a.ComponentType.FLOAT]:R.DT_FLOAT32,[a.ComponentType.UNSIGNED_INT]:R.DT_UINT32,[a.ComponentType.UNSIGNED_SHORT]:R.DT_UINT16,[a.ComponentType.UNSIGNED_BYTE]:R.DT_UINT8,[a.ComponentType.SHORT]:R.DT_INT16,[a.ComponentType.BYTE]:R.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(`[${U}] Please install extension dependency, "draco3d.decoder".`);const t=this.doc.getLogger(),s=e.jsonDoc,r=new Map;try{const o=s.json.meshes||[];for(const n of o)for(const o of n.primitives){if(!o.extensions||!o.extensions[U])continue;const n=o.extensions[U];let[i,a]=r.get(n.bufferView)||[];if(!a||!i){const e=s.json.bufferViews[n.bufferView],o=s.json.buffers[e.buffer],u=new Int8Array(o.uri?s.resources[o.uri]:s.resources[c],e.byteOffset||0,e.byteLength);i=new this._decoderModule.Decoder,a=M(i,u),r.set(n.bufferView,[i,a]),t.debug(`[${U}] Decompressed ${u.byteLength} bytes.`)}for(const t in o.attributes){const s=e.jsonDoc.json.accessors[o.attributes[t]],r=i.GetAttributeByUniqueId(a,n.attributes[t]),c=O(i,a,r,s);e.accessors[o.attributes[t]].setArray(c)}const u=D(i,a);e.accessors[o.indices].setArray(u)}}finally{for(const[e,t]of Array.from(r.values()))this._decoderModule.destroy(e),this._decoderModule.destroy(t)}return this}read(e){return this}prewrite(e,t){if(!this._encoderModule)throw new Error(`[${U}] Please install extension dependency, "draco3d.encoder".`);const s=this.doc.getLogger();s.debug(`[${U}] 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()?e.getMode()!==u.Mode.TRIANGLES?(r.add(e),t.warn(`[${U}] Skipping Draco compression on non-TRIANGLES primitive.`)):s.add(e):(r.add(e),t.warn(`[${U}] 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 Set,c=new Map;for(const t of Array.from(s)){let s=P(t,n);if(a.has(s))c.set(t,s);else{if(i.has(t.getIndices())){const s=t.getIndices().clone();n.set(s,e.getRoot().listAccessors().length-1),t.swap(t.getIndices(),s)}for(const s of t.listAttributes())if(i.has(s)){const r=s.clone();n.set(r,e.getRoot().listAccessors().length-1),t.swap(s,r)}s=P(t,n),a.add(s),c.set(t,s),i.set(t.getIndices(),s);for(const e of t.listAttributes())i.set(e,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(`[${U}] Compressed accessors must only be used as indices or vertex attributes.`)}for(const e of Array.from(s)){const t=c.get(e);if(i.get(e.getIndices())!==t||e.listAttributes().some(e=>i.get(e)!==t))throw new Error(`[${U}] 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(`[${U}] Accessor cannot be shared by compressed and uncompressed primitives.`);return c}(this.doc),o=new Map;for(const t of Array.from(r.keys())){const s=r.get(t);if(!s)throw new Error("Unexpected primitive.");if(o.has(s)){o.set(s,o.get(s));continue}const n=k(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(`[${U}] Compressed ${r.size} primitives.`),e.extensionData[U]={primitiveHashMap:r,primitiveEncodingMap:o},this}write(e){const t=e.extensionData[U];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[U]={bufferView:e.otherBufferViewsIndexMap.get(c.data),attributes:c.attributeIDs}}}if(!t.primitiveHashMap.size){const t=e.jsonDoc.json;t.extensionsUsed=(t.extensionsUsed||[]).filter(e=>e!==U),t.extensionsRequired=(t.extensionsRequired||[]).filter(e=>e!==U)}return this}}function P(e,t){const s=[];s.push(t.get(e.getIndices()));for(const r of e.listAttributes())s.push(t.get(r));return s.sort().join("|")}K.EXTENSION_NAME=U,K.EncoderMethod=w;class X extends e{constructor(){super(...arguments),this.propertyType="Light",this.parentTypes=[t.NODE],this.extensionName="KHR_lights_punctual",this._color=[1,1,1],this._intensity=1,this._type=X.Type.POINT,this._range=null,this._innerConeAngle=0,this._outerConeAngle=Math.PI/4}copy(e,t=s){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 h.factorToHex(this._color)}setColorHex(e){return h.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}}X.EXTENSION_NAME="KHR_lights_punctual",X.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};const B="KHR_lights_punctual";class V extends o{constructor(){super(...arguments),this.extensionName=B}createLight(){return new X(this.doc.getGraph(),this)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions[B])return this;const s=(t.json.extensions[B].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[B]&&e.nodes[r].setExtension(B,s[t.extensions[B].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()};l.eq(t.getColor(),[1,1,1])||(o.color=t.getColor()),1!==t.getIntensity()&&(o.intensity=t.getIntensity()),null!=t.getRange()&&(o.range=t.getRange()),t.getName()&&(o.name=t.getName()),t.getType()===X.Type.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(B);if(o){const n=e.nodeIndexMap.get(s),i=t.json.nodes[n];i.extensions=i.extensions||{},i.extensions[B]={light:r.get(o)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[B]={lights:s},this}}V.EXTENSION_NAME=B;const{R:$,G:z,B:q}=g;class Y extends e{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 p(this.graph)),this.clearcoatRoughnessTexture=null,this.clearcoatRoughnessTextureInfo=this.graph.link("clearcoatRoughnessTextureInfo",this,new p(this.graph)),this.clearcoatNormalTexture=null,this.clearcoatNormalTextureInfo=this.graph.link("clearcoatNormalTextureInfo",this,new p(this.graph))}copy(e,t=s){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.linkTexture("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.linkTexture("clearcoatRoughnessTexture",z,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.linkTexture("clearcoatNormalTexture",$|z|q,this,e),this}}Y.EXTENSION_NAME="KHR_materials_clearcoat",f([x],Y.prototype,"clearcoatTexture",void 0),f([x],Y.prototype,"clearcoatTextureInfo",void 0),f([x],Y.prototype,"clearcoatRoughnessTexture",void 0),f([x],Y.prototype,"clearcoatRoughnessTextureInfo",void 0),f([x],Y.prototype,"clearcoatNormalTexture",void 0),f([x],Y.prototype,"clearcoatNormalTextureInfo",void 0);const Q="KHR_materials_clearcoat";class W extends o{constructor(){super(...arguments),this.extensionName=Q}createClearcoat(){return new Y(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[Q]){const o=this.createClearcoat();e.materials[r].setExtension(Q,o);const n=t.extensions[Q];if(void 0!==n.clearcoatFactor&&o.setClearcoatFactor(n.clearcoatFactor),void 0!==n.clearcoatRoughnessFactor&&o.setClearcoatRoughnessFactor(n.clearcoatRoughnessFactor),void 0!==n.clearcoatTexture){const t=n.clearcoatTexture;o.setClearcoatTexture(e.textures[s[t.index].source]),e.setTextureInfo(o.getClearcoatTextureInfo(),t)}if(void 0!==n.clearcoatRoughnessTexture){const t=n.clearcoatRoughnessTexture;o.setClearcoatRoughnessTexture(e.textures[s[t.index].source]),e.setTextureInfo(o.getClearcoatRoughnessTextureInfo(),t)}if(void 0!==n.clearcoatNormalTexture){const t=n.clearcoatNormalTexture;o.setClearcoatNormalTexture(e.textures[s[t.index].source]),e.setTextureInfo(o.getClearcoatNormalTextureInfo(),t),void 0!==t.scale&&o.setClearcoatNormalScale(t.scale)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(Q);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];n.extensions=n.extensions||{};const i=n.extensions[Q]={clearcoatFactor:r.getClearcoatFactor(),clearcoatRoughnessFactor:r.getClearcoatRoughnessFactor()};if(r.getClearcoatTexture()){const t=r.getClearcoatTexture(),s=r.getClearcoatTextureInfo();i.clearcoatTexture=e.createTextureInfoDef(t,s)}if(r.getClearcoatRoughnessTexture()){const t=r.getClearcoatRoughnessTexture(),s=r.getClearcoatRoughnessTextureInfo();i.clearcoatRoughnessTexture=e.createTextureInfoDef(t,s)}if(r.getClearcoatNormalTexture()){const t=r.getClearcoatNormalTexture(),s=r.getClearcoatNormalTextureInfo();i.clearcoatNormalTexture=e.createTextureInfoDef(t,s),1!==r.getClearcoatNormalScale()&&(i.clearcoatNormalTexture.scale=r.getClearcoatNormalScale())}}}),this}}W.EXTENSION_NAME=Q;class J extends e{constructor(){super(...arguments),this.propertyType="IOR",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_ior",this._ior=0}copy(e,t=s){return super.copy(e,t),this._ior=e._ior,this}getIOR(){return this._ior}setIOR(e){return this._ior=e,this}}J.EXTENSION_NAME="KHR_materials_ior";const Z="KHR_materials_ior";class ee extends o{constructor(){super(...arguments),this.extensionName=Z}createIOR(){return new J(this.doc.getGraph(),this)}read(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{if(t.extensions&&t.extensions[Z]){const r=this.createIOR();e.materials[s].setExtension(Z,r);const o=t.extensions[Z];void 0!==o.ior&&r.setIOR(o.ior)}}),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];n.extensions=n.extensions||{},n.extensions[Z]={ior:r.getIOR()}}}),this}}ee.EXTENSION_NAME=Z;const{R:te,G:se,B:re,A:oe}=g;class ne extends e{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 p(this.graph)),this.specularGlossinessTexture=null,this.specularGlossinessTextureInfo=this.graph.link("specularGlossinessTextureInfo",this,new p(this.graph))}copy(e,t=s){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 h.factorToHex(this._diffuseFactor)}setDiffuseHex(e){return h.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.linkTexture("diffuseTexture",te|se|re|oe,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.linkTexture("specularGlossinessTexture",te|se|re|oe,this,e),this}}ne.EXTENSION_NAME="KHR_materials_pbrSpecularGlossiness",f([x],ne.prototype,"diffuseTexture",void 0),f([x],ne.prototype,"diffuseTextureInfo",void 0),f([x],ne.prototype,"specularGlossinessTexture",void 0),f([x],ne.prototype,"specularGlossinessTextureInfo",void 0);const ie="KHR_materials_pbrSpecularGlossiness";class ae extends o{constructor(){super(...arguments),this.extensionName=ie}createPBRSpecularGlossiness(){return new ne(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[ie]){const o=this.createPBRSpecularGlossiness();e.materials[r].setExtension(ie,o);const n=t.extensions[ie];if(void 0!==n.diffuseFactor&&o.setDiffuseFactor(n.diffuseFactor),void 0!==n.specularFactor&&o.setSpecularFactor(n.specularFactor),void 0!==n.glossinessFactor&&o.setGlossinessFactor(n.glossinessFactor),void 0!==n.diffuseTexture){const t=n.diffuseTexture;o.setDiffuseTexture(e.textures[s[t.index].source]),e.setTextureInfo(o.getDiffuseTextureInfo(),t)}if(void 0!==n.specularGlossinessTexture){const t=n.specularGlossinessTexture;o.setSpecularGlossinessTexture(e.textures[s[t.index].source]),e.setTextureInfo(o.getSpecularGlossinessTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(ie);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];n.extensions=n.extensions||{};const i=n.extensions[ie]={diffuseFactor:r.getDiffuseFactor(),specularFactor:r.getSpecularFactor(),glossinessFactor:r.getGlossinessFactor()};if(r.getDiffuseTexture()){const t=r.getDiffuseTexture(),s=r.getDiffuseTextureInfo();i.diffuseTexture=e.createTextureInfoDef(t,s)}if(r.getSpecularGlossinessTexture()){const t=r.getSpecularGlossinessTexture(),s=r.getSpecularGlossinessTextureInfo();i.specularGlossinessTexture=e.createTextureInfoDef(t,s)}}}),this}}ae.EXTENSION_NAME=ie;const{R:ce,G:ue,B:he,A:le}=g;class pe extends e{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 p(this.graph)),this.sheenRoughnessTexture=null,this.sheenRoughnessTextureInfo=this.graph.link("sheenRoughnessTextureInfo",this,new p(this.graph))}copy(e,t=s){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 h.factorToHex(this._sheenColorFactor)}setSheenColorFactor(e){return this._sheenColorFactor=e,this}setSheenColorHex(e){return h.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.linkTexture("sheenColorTexture",ce|ue|he,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.linkTexture("sheenRoughnessTexture",le,this,e),this}}pe.EXTENSION_NAME="KHR_materials_sheen",f([x],pe.prototype,"sheenColorTexture",void 0),f([x],pe.prototype,"sheenColorTextureInfo",void 0),f([x],pe.prototype,"sheenRoughnessTexture",void 0),f([x],pe.prototype,"sheenRoughnessTextureInfo",void 0);const xe="KHR_materials_sheen";class ge extends o{constructor(){super(...arguments),this.extensionName=xe}createSheen(){return new pe(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[xe]){const o=this.createSheen();e.materials[r].setExtension(xe,o);const n=t.extensions[xe];if(void 0!==n.sheenColorFactor&&o.setSheenColorFactor(n.sheenColorFactor),void 0!==n.sheenRoughnessFactor&&o.setSheenRoughnessFactor(n.sheenRoughnessFactor),void 0!==n.sheenColorTexture){const t=n.sheenColorTexture;o.setSheenColorTexture(e.textures[s[t.index].source]),e.setTextureInfo(o.getSheenColorTextureInfo(),t)}if(void 0!==n.sheenRoughnessTexture){const t=n.sheenRoughnessTexture;o.setSheenRoughnessTexture(e.textures[s[t.index].source]),e.setTextureInfo(o.getSheenRoughnessTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(xe);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];n.extensions=n.extensions||{};const i=n.extensions[xe]={sheenColorFactor:r.getSheenColorFactor(),sheenRoughnessFactor:r.getSheenRoughnessFactor()};if(r.getSheenColorTexture()){const t=r.getSheenColorTexture(),s=r.getSheenColorTextureInfo();i.sheenColorTexture=e.createTextureInfoDef(t,s)}if(r.getSheenRoughnessTexture()){const t=r.getSheenRoughnessTexture(),s=r.getSheenRoughnessTextureInfo();i.sheenRoughnessTexture=e.createTextureInfoDef(t,s)}}}),this}}ge.EXTENSION_NAME=xe;const{R:Te,G:de,B:fe,A:me}=g;class _e extends e{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 p(this.graph))}copy(e,t=s){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 h.factorToHex(this._specularColorFactor)}setSpecularColorHex(e){return h.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.linkTexture("specularTexture",Te|de|fe|me,this,e),this}}_e.EXTENSION_NAME="KHR_materials_specular",f([x],_e.prototype,"specularTexture",void 0),f([x],_e.prototype,"specularTextureInfo",void 0);const Ie="KHR_materials_specular";class Ce extends o{constructor(){super(...arguments),this.extensionName=Ie}createSpecular(){return new _e(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[Ie]){const o=this.createSpecular();e.materials[r].setExtension(Ie,o);const n=t.extensions[Ie];if(void 0!==n.specularFactor&&o.setSpecularFactor(n.specularFactor),void 0!==n.specularColorFactor&&o.setSpecularColorFactor(n.specularColorFactor),void 0!==n.specularTexture){const t=n.specularTexture;o.setSpecularTexture(e.textures[s[t.index].source]),e.setTextureInfo(o.getSpecularTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(Ie);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];n.extensions=n.extensions||{};const i=n.extensions[Ie]={specularFactor:r.getSpecularFactor(),specularColorFactor:r.getSpecularColorFactor()};if(r.getSpecularTexture()){const t=r.getSpecularTexture(),s=r.getSpecularTextureInfo();i.specularTexture=e.createTextureInfoDef(t,s)}}}),this}}Ce.EXTENSION_NAME=Ie;const{R:Ee}=g;class Ne extends e{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 p(this.graph))}copy(e,t=s){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.linkTexture("transmissionTexture",Ee,this,e),this}}Ne.EXTENSION_NAME="KHR_materials_transmission",f([x],Ne.prototype,"transmissionTexture",void 0),f([x],Ne.prototype,"transmissionTextureInfo",void 0);const ye="KHR_materials_transmission";class Re extends o{constructor(){super(...arguments),this.extensionName=ye}createTransmission(){return new Ne(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[ye]){const o=this.createTransmission();e.materials[r].setExtension(ye,o);const n=t.extensions[ye];if(void 0!==n.transmissionFactor&&o.setTransmissionFactor(n.transmissionFactor),void 0!==n.transmissionTexture){const t=n.transmissionTexture;o.setTransmissionTexture(e.textures[s[t.index].source]),e.setTextureInfo(o.getTransmissionTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(ye);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];n.extensions=n.extensions||{};const i=n.extensions[ye]={transmissionFactor:r.getTransmissionFactor()};if(r.getTransmissionTexture()){const t=r.getTransmissionTexture(),s=r.getTransmissionTextureInfo();i.transmissionTexture=e.createTextureInfoDef(t,s)}}}),this}}Re.EXTENSION_NAME=ye;class Se extends e{constructor(){super(...arguments),this.propertyType="Unlit",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_unlit"}}Se.EXTENSION_NAME="KHR_materials_unlit";const Ae="KHR_materials_unlit";class Fe extends o{constructor(){super(...arguments),this.extensionName=Ae}createUnlit(){return new Se(this.doc.getGraph(),this)}read(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{t.extensions&&t.extensions[Ae]&&e.materials[s].setExtension(Ae,this.createUnlit())}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{if(s.getExtension(Ae)){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{},o.extensions[Ae]={}}}),this}}Fe.EXTENSION_NAME=Ae;class Me extends e{constructor(){super(...arguments),this.propertyType="Mapping",this.parentTypes=["MappingList"],this.extensionName="KHR_materials_variants",this.material=null,this.variants=[]}copy(e,t=s){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())}}Me.EXTENSION_NAME="KHR_materials_variants",f([x],Me.prototype,"material",void 0),f([r],Me.prototype,"variants",void 0);class De extends e{constructor(){super(...arguments),this.propertyType="MappingList",this.parentTypes=[t.PRIMITIVE],this.extensionName="KHR_materials_variants",this.mappings=[]}copy(e,t=s){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())}}De.EXTENSION_NAME="KHR_materials_variants",f([r],De.prototype,"mappings",void 0);class Oe extends e{constructor(){super(...arguments),this.propertyType="Variant",this.parentTypes=[t.ROOT,"MappingList"],this.extensionName="KHR_materials_variants"}}Oe.EXTENSION_NAME="KHR_materials_variants";const ve="KHR_materials_variants";class we extends o{constructor(){super(...arguments),this.extensionName=ve}createMappingList(){return new De(this.doc.getGraph(),this)}createVariant(e=""){return new Oe(this.doc.getGraph(),this).setName(e)}createMapping(){return new Me(this.doc.getGraph(),this)}listVariants(){return Array.from(this.properties).filter(e=>e instanceof Oe)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions[ve])return this;const s=(t.json.extensions[ve].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[ve])return;const n=this.createMappingList();for(const r of t.extensions[ve].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(ve,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(ve))return;const n=e.jsonDoc.json.meshes[s].primitives[r],i=t.getExtension(ve).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[ve]={mappings:i}})}return t.json.extensions=t.json.extensions||{},t.json.extensions[ve]={variants:r},this}}we.EXTENSION_NAME=ve;const{G:Ge}=g;class je extends e{constructor(){super(...arguments),this.propertyType="Transmission",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_volume",this._thicknessFactor=0,this._attenuationDistance=Infinity,this._attenuationColor=[1,1,1],this.thicknessTexture=null,this.thicknessTextureInfo=this.graph.link("thicknessTextureInfo",this,new p(this.graph))}copy(e,t=s){return super.copy(e,t),this._thicknessFactor=e._thicknessFactor,this._attenuationDistance=e._attenuationDistance,this._attenuationColor=[...e._attenuationColor],e.thicknessTexture&&(this.setThicknessTexture(t(e.thicknessTexture.getChild())),this.getThicknessTextureInfo().copy(t(e.thicknessTextureInfo.getChild()),t)),this}dispose(){this.thicknessTextureInfo.getChild().dispose(),super.dispose()}getThicknessFactor(){return this._thicknessFactor}setThicknessFactor(e){return this._thicknessFactor=e,this}getThicknessTexture(){return this.thicknessTexture?this.thicknessTexture.getChild():null}getThicknessTextureInfo(){return this.thicknessTexture?this.thicknessTextureInfo.getChild():null}setThicknessTexture(e){return this.thicknessTexture=this.graph.linkTexture("thicknessTexture",Ge,this,e),this}getAttenuationDistance(){return this._attenuationDistance}setAttenuationDistance(e){return this._attenuationDistance=e,this}getAttenuationColor(){return this._attenuationColor}setAttenuationColor(e){return this._attenuationColor=e,this}getAttenuationColorHex(){return h.factorToHex(this._attenuationColor)}setAttenuationColorHex(e){return h.hexToFactor(e,this._attenuationColor),this}}je.EXTENSION_NAME="KHR_materials_volume",f([x],je.prototype,"thicknessTexture",void 0),f([x],je.prototype,"thicknessTextureInfo",void 0);const be="KHR_materials_volume";class ke extends o{constructor(){super(...arguments),this.extensionName=be}createVolume(){return new je(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[be]){const o=this.createVolume();e.materials[r].setExtension(be,o);const n=t.extensions[be];if(void 0!==n.thicknessFactor&&o.setThicknessFactor(n.thicknessFactor),void 0!==n.attenuationDistance&&o.setAttenuationDistance(n.attenuationDistance),void 0!==n.attenuationColor&&o.setAttenuationColor(n.attenuationColor),void 0!==n.thicknessTexture){const t=n.thicknessTexture;o.setThicknessTexture(e.textures[s[t.index].source]),e.setTextureInfo(o.getThicknessTextureInfo(),t)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(be);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];n.extensions=n.extensions||{};const i=n.extensions[be]={thicknessFactor:r.getThicknessFactor(),attenuationDistance:r.getAttenuationDistance(),attenuationColor:r.getAttenuationColor()};if(r.getThicknessTexture()){const t=r.getThicknessTexture(),s=r.getThicknessTextureInfo();i.thicknessTexture=e.createTextureInfoDef(t,s)}}}),this}}ke.EXTENSION_NAME=be;const He="KHR_mesh_quantization";class Le extends o{constructor(){super(...arguments),this.extensionName=He}read(e){return this}write(e){return this}}Le.EXTENSION_NAME=He;const Ue="KHR_texture_basisu";class Ke{getSize(e){const t=T(new Uint8Array(e));return[t.pixelWidth,t.pixelHeight]}getChannels(e){const t=T(new Uint8Array(e)).dataFormatDescriptor[0];if(t.colorModel===d.ETC1S)return 2===t.samples.length&&15==(15&t.samples[1].channelID)?4:3;if(t.colorModel===d.UASTC)return 3==(15&t.samples[0].channelID)?4:3;throw new Error(`Unexpected KTX2 colorModel, "${t.colorModel}".`)}getGPUByteLength(e){const t=T(new Uint8Array(e)),s=this.getChannels(e)>3;let r=0;for(let e=0;e<t.levels.length;e++){const o=t.levels[e];r+=o.uncompressedByteLength?o.uncompressedByteLength:Math.max(1,Math.floor(t.pixelWidth/Math.pow(2,e)))/4*(Math.max(1,Math.floor(t.pixelHeight/Math.pow(2,e)))/4)*(s?16:8)}return r}}class Pe extends o{constructor(){super(...arguments),this.extensionName=Ue,this.prereadTypes=[t.TEXTURE]}static register(){n.registerFormat("image/ktx2",new Ke)}preread(e){return e.jsonDoc.json.textures.forEach(e=>{e.extensions&&e.extensions[Ue]&&(e.source=e.extensions[Ue].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[Ue]={source:e.source},delete e.source)})}}),this}}Pe.EXTENSION_NAME=Ue;class Xe extends e{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=null}copy(e,t=s){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}}Xe.EXTENSION_NAME="KHR_texture_transform";const Be="KHR_texture_transform";class Ve extends o{constructor(){super(...arguments),this.extensionName=Be}createTransform(){return new Xe(this.doc.getGraph(),this)}read(e){for(const[t,s]of Array.from(e.textureInfos.entries())){if(!s.extensions||!s.extensions[Be])continue;const e=this.createTransform(),r=s.extensions[Be];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(Be,e)}return this}write(e){const t=Array.from(e.textureInfoDefMap.entries());for(const[e,s]of t){const t=e.getExtension(Be);if(!t)continue;s.extensions=s.extensions||{};const r={},o=l.eq;o(t.getOffset(),[0,0])||(r.offset=t.getOffset()),0!==t.getRotation()&&(r.rotation=t.getRotation()),o(t.getScale(),[1,1])||(r.scale=t.getScale()),null!=t.getTexCoord()&&(r.texCoord=t.getTexCoord()),s.extensions[Be]=r}return this}}Ve.EXTENSION_NAME=Be;const $e=[K,V,W,ee,ae,Ce,ge,Re,Fe,we,ke,Le,Pe,Ve],ze=[I,N,...$e];export{ze as ALL_EXTENSIONS,Y as Clearcoat,K as DracoMeshCompression,J as IOR,m as InstancedMesh,$e as KHRONOS_EXTENSIONS,X as Light,V as LightsPunctual,Me as Mapping,De as MappingList,W as MaterialsClearcoat,ee as MaterialsIOR,ae as MaterialsPBRSpecularGlossiness,ge as MaterialsSheen,Ce as MaterialsSpecular,Re as MaterialsTransmission,Fe as MaterialsUnlit,we as MaterialsVariants,ke as MaterialsVolume,I as MeshGPUInstancing,Le as MeshQuantization,ne as PBRSpecularGlossiness,pe as Sheen,_e as Specular,Pe as TextureBasisu,Ve as TextureTransform,N as TextureWebP,Xe as Transform,Ne as Transmission,Se as Unlit,Oe as Variant,je as Volume}; | ||
//# sourceMappingURL=extensions.modern.js.map |
{ | ||
"name": "@gltf-transform/extensions", | ||
"version": "0.9.9", | ||
"version": "0.9.10", | ||
"repository": "github:donmccurdy/glTF-Transform", | ||
@@ -24,4 +24,4 @@ "description": "Adds extension support to @gltf-transform/core", | ||
"dependencies": { | ||
"@gltf-transform/core": "^0.9.9", | ||
"ktx-parse": "^0.0.5" | ||
"@gltf-transform/core": "^0.9.10", | ||
"ktx-parse": "^0.2.1" | ||
}, | ||
@@ -34,3 +34,3 @@ "files": [ | ||
], | ||
"gitHead": "d38f80279341a3a339c517c572298661a0a45845" | ||
"gitHead": "4618e62b72a645e0e93bebfc3f8be0fbbc081516" | ||
} |
@@ -1,4 +0,6 @@ | ||
import { COPY_IDENTITY, ExtensionProperty, GraphChild, Link, PropertyType, Texture, TextureInfo } from '@gltf-transform/core'; | ||
import { COPY_IDENTITY, ExtensionProperty, GraphChild, Link, PropertyType, Texture, TextureChannel, TextureInfo, TextureLink } from '@gltf-transform/core'; | ||
import { KHR_MATERIALS_CLEARCOAT } from '../constants'; | ||
const { R, G, B } = TextureChannel; | ||
/** Documentation in {@link EXTENSIONS.md}. */ | ||
@@ -15,11 +17,11 @@ export class Clearcoat extends ExtensionProperty { | ||
@GraphChild private clearcoatTexture: Link<this, Texture> | null = null; | ||
@GraphChild private clearcoatTexture: TextureLink | null = null; | ||
@GraphChild private clearcoatTextureInfo: Link<this, TextureInfo> = | ||
this.graph.link('clearcoatTextureInfo', this, new TextureInfo(this.graph)); | ||
@GraphChild private clearcoatRoughnessTexture: Link<this, Texture> | null = null; | ||
@GraphChild private clearcoatRoughnessTexture: TextureLink | null = null; | ||
@GraphChild private clearcoatRoughnessTextureInfo: Link<this, TextureInfo> = | ||
this.graph.link('clearcoatRoughnessTextureInfo', this, new TextureInfo(this.graph)); | ||
@GraphChild private clearcoatNormalTexture: Link<this, Texture> | null = null; | ||
@GraphChild private clearcoatNormalTexture: TextureLink | null = null; | ||
@GraphChild private clearcoatNormalTextureInfo: Link<this, TextureInfo> = | ||
@@ -93,3 +95,3 @@ this.graph.link('clearcoatNormalTextureInfo', this, new TextureInfo(this.graph)); | ||
public setClearcoatTexture(texture: Texture | null): this { | ||
this.clearcoatTexture = this.graph.link('clearcoatTexture', this, texture); | ||
this.clearcoatTexture = this.graph.linkTexture('clearcoatTexture', R, this, texture); | ||
return this; | ||
@@ -132,3 +134,3 @@ } | ||
this.clearcoatRoughnessTexture | ||
= this.graph.link('clearcoatRoughnessTexture', this, texture); | ||
= this.graph.linkTexture('clearcoatRoughnessTexture', G, this, texture); | ||
return this; | ||
@@ -167,5 +169,6 @@ } | ||
public setClearcoatNormalTexture(texture: Texture | null): this { | ||
this.clearcoatNormalTexture = this.graph.link('clearcoatNormalTexture', this, texture); | ||
this.clearcoatNormalTexture = | ||
this.graph.linkTexture('clearcoatNormalTexture', R | G | B, this, texture); | ||
return this; | ||
} | ||
} |
@@ -1,4 +0,6 @@ | ||
import { COPY_IDENTITY, ColorUtils, ExtensionProperty, GraphChild, Link, PropertyType, Texture, TextureInfo, vec3, vec4 } from '@gltf-transform/core'; | ||
import { COPY_IDENTITY, ColorUtils, ExtensionProperty, GraphChild, Link, PropertyType, Texture, TextureChannel, TextureInfo, TextureLink, vec3, vec4 } from '@gltf-transform/core'; | ||
import { KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS } from '../constants'; | ||
const { R, G, B, A } = TextureChannel; | ||
/** Documentation in {@link EXTENSIONS.md}. */ | ||
@@ -15,7 +17,7 @@ export class PBRSpecularGlossiness extends ExtensionProperty { | ||
@GraphChild private diffuseTexture: Link<this, Texture> | null = null; | ||
@GraphChild private diffuseTexture: TextureLink | null = null; | ||
@GraphChild private diffuseTextureInfo: Link<this, TextureInfo> = | ||
this.graph.link('diffuseTextureInfo', this, new TextureInfo(this.graph)); | ||
@GraphChild private specularGlossinessTexture: Link<this, Texture> | null = null; | ||
@GraphChild private specularGlossinessTexture: TextureLink | null = null; | ||
@GraphChild private specularGlossinessTextureInfo: Link<this, TextureInfo> = | ||
@@ -91,3 +93,4 @@ this.graph.link('specularGlossinessTextureInfo', this, new TextureInfo(this.graph)); | ||
public setDiffuseTexture(texture: Texture | null): this { | ||
this.diffuseTexture = this.graph.link('diffuseTexture', this, texture); | ||
this.diffuseTexture = | ||
this.graph.linkTexture('diffuseTexture', R | G | B | A, this, texture); | ||
return this; | ||
@@ -144,5 +147,5 @@ } | ||
this.specularGlossinessTexture | ||
= this.graph.link('specularGlossinessTexture', this, texture); | ||
= this.graph.linkTexture('specularGlossinessTexture', R | G | B | A, this, texture); | ||
return this; | ||
} | ||
} |
@@ -1,4 +0,6 @@ | ||
import { COPY_IDENTITY, ColorUtils, ExtensionProperty, GraphChild, Link, PropertyType, Texture, TextureInfo, vec3 } from '@gltf-transform/core'; | ||
import { COPY_IDENTITY, ColorUtils, ExtensionProperty, GraphChild, Link, PropertyType, Texture, TextureChannel, TextureInfo, TextureLink, vec3 } from '@gltf-transform/core'; | ||
import { KHR_MATERIALS_SHEEN } from '../constants'; | ||
const { R, G, B, A } = TextureChannel; | ||
/** Documentation in {@link EXTENSIONS.md}. */ | ||
@@ -14,7 +16,7 @@ export class Sheen extends ExtensionProperty { | ||
@GraphChild private sheenColorTexture: Link<this, Texture> | null = null; | ||
@GraphChild private sheenColorTexture: TextureLink | null = null; | ||
@GraphChild private sheenColorTextureInfo: Link<this, TextureInfo> = | ||
this.graph.link('sheenColorTextureInfo', this, new TextureInfo(this.graph)); | ||
@GraphChild private sheenRoughnessTexture: Link<this, Texture> | null = null; | ||
@GraphChild private sheenRoughnessTexture: TextureLink | null = null; | ||
@GraphChild private sheenRoughnessTextureInfo: Link<this, TextureInfo> = | ||
@@ -88,3 +90,4 @@ this.graph.link('sheenRoughnessTextureInfo', this, new TextureInfo(this.graph)); | ||
public setSheenColorTexture(texture: Texture | null): this { | ||
this.sheenColorTexture = this.graph.link('sheenColorTexture', this, texture); | ||
this.sheenColorTexture = | ||
this.graph.linkTexture('sheenColorTexture', R | G | B, this, texture); | ||
return this; | ||
@@ -127,5 +130,6 @@ } | ||
public setSheenRoughnessTexture(texture: Texture | null): this { | ||
this.sheenRoughnessTexture = this.graph.link('sheenRoughnessTexture', this, texture); | ||
this.sheenRoughnessTexture = | ||
this.graph.linkTexture('sheenRoughnessTexture', A, this, texture); | ||
return this; | ||
} | ||
} |
@@ -1,4 +0,6 @@ | ||
import { COPY_IDENTITY, ColorUtils, ExtensionProperty, GraphChild, Link, PropertyType, Texture, TextureInfo, vec3 } from '@gltf-transform/core'; | ||
import { COPY_IDENTITY, ColorUtils, ExtensionProperty, GraphChild, Link, PropertyType, Texture, TextureChannel, TextureInfo, TextureLink, vec3 } from '@gltf-transform/core'; | ||
import { KHR_MATERIALS_SPECULAR } from '../constants'; | ||
const { R, G, B, A } = TextureChannel; | ||
/** Documentation in {@link EXTENSIONS.md}. */ | ||
@@ -14,3 +16,3 @@ export class Specular extends ExtensionProperty { | ||
@GraphChild private specularTexture: Link<this, Texture> | null = null; | ||
@GraphChild private specularTexture: TextureLink | null = null; | ||
@GraphChild private specularTextureInfo: Link<this, TextureInfo> = | ||
@@ -94,5 +96,6 @@ this.graph.link('specularTextureInfo', this, new TextureInfo(this.graph)); | ||
public setSpecularTexture(texture: Texture | null): this { | ||
this.specularTexture = this.graph.link('specularTexture', this, texture); | ||
this.specularTexture = | ||
this.graph.linkTexture('specularTexture', R | G | B | A, this, texture); | ||
return this; | ||
} | ||
} |
@@ -1,4 +0,6 @@ | ||
import { COPY_IDENTITY, ExtensionProperty, GraphChild, Link, PropertyType, Texture, TextureInfo } from '@gltf-transform/core'; | ||
import { COPY_IDENTITY, ExtensionProperty, GraphChild, Link, PropertyType, Texture, TextureChannel, TextureInfo, TextureLink } from '@gltf-transform/core'; | ||
import { KHR_MATERIALS_TRANSMISSION } from '../constants'; | ||
const { R } = TextureChannel; | ||
/** Documentation in {@link EXTENSIONS.md}. */ | ||
@@ -13,3 +15,3 @@ export class Transmission extends ExtensionProperty { | ||
@GraphChild private transmissionTexture: Link<this, Texture> | null = null; | ||
@GraphChild private transmissionTexture: TextureLink | null = null; | ||
@GraphChild private transmissionTextureInfo: Link<this, TextureInfo> = | ||
@@ -70,5 +72,5 @@ this.graph.link('transmissionTextureInfo', this, new TextureInfo(this.graph)); | ||
public setTransmissionTexture(texture: Texture | null): this { | ||
this.transmissionTexture = this.graph.link('transmissionTexture', this, texture); | ||
this.transmissionTexture = this.graph.linkTexture('transmissionTexture', R, this, texture); | ||
return this; | ||
} | ||
} |
@@ -1,4 +0,6 @@ | ||
import { COPY_IDENTITY, ColorUtils, ExtensionProperty, GraphChild, Link, PropertyType, Texture, TextureInfo, vec3 } from '@gltf-transform/core'; | ||
import { COPY_IDENTITY, ColorUtils, ExtensionProperty, GraphChild, Link, PropertyType, Texture, TextureChannel, TextureInfo, TextureLink, vec3 } from '@gltf-transform/core'; | ||
import { KHR_MATERIALS_VOLUME } from '../constants'; | ||
const { G } = TextureChannel; | ||
/** Documentation in {@link EXTENSIONS.md}. */ | ||
@@ -15,3 +17,3 @@ export class Volume extends ExtensionProperty { | ||
@GraphChild private thicknessTexture: Link<this, Texture> | null = null; | ||
@GraphChild private thicknessTexture: TextureLink | null = null; | ||
@GraphChild private thicknessTextureInfo: Link<this, TextureInfo> = | ||
@@ -83,3 +85,3 @@ this.graph.link('thicknessTextureInfo', this, new TextureInfo(this.graph)); | ||
public setThicknessTexture(texture: Texture | null): this { | ||
this.thicknessTexture = this.graph.link('thicknessTexture', this, texture); | ||
this.thicknessTexture = this.graph.linkTexture('thicknessTexture', G, this, texture); | ||
return this; | ||
@@ -86,0 +88,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { read as readKTX } from 'ktx-parse'; | ||
import { KTX2Model, read as readKTX } from 'ktx-parse'; | ||
import { Extension, ImageUtils, ImageUtilsFormat, PropertyType, ReaderContext, WriterContext, vec2 } from '@gltf-transform/core'; | ||
@@ -15,5 +15,5 @@ import { KHR_TEXTURE_BASISU } from '../constants'; | ||
const dfd = container.dataFormatDescriptor[0]; | ||
if (dfd.colorModel === 163 /* ETC1S */) { | ||
if (dfd.colorModel === KTX2Model.ETC1S) { | ||
return (dfd.samples.length === 2 && (dfd.samples[1].channelID & 0xF) === 15) ? 4 : 3; | ||
} else if (dfd.colorModel === 166 /* UASTC */) { | ||
} else if (dfd.colorModel === KTX2Model.UASTC) { | ||
return (dfd.samples[0].channelID & 0xF) === 3 ? 4 : 3; | ||
@@ -20,0 +20,0 @@ } else { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
605286
4092
+ Addedktx-parse@0.2.2(transitive)
- Removedktx-parse@0.0.5(transitive)
Updated@gltf-transform/core@^0.9.10
Updatedktx-parse@^0.2.1