@gltf-transform/extensions
Advanced tools
Comparing version 0.7.1 to 0.7.2
@@ -1,2 +0,2 @@ | ||
var e,t,r,o=require("@gltf-transform/core");function s(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function n(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function a(e){var t=0;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,t){if(e){if("string"==typeof e)return i(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(e,void 0):void 0}}(e)))return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}function u(t,r){var o;try{if((o=new e.DecoderBuffer).Init(new Int8Array(r),r.byteLength),t.GetEncodedGeometryType(o)!==e.TRIANGULAR_MESH)throw new Error("Unknown geometry type.");var s=new e.Mesh;if(!t.DecodeBufferToMesh(o,s).ok()||0===s.ptr)throw new Error("Decoding failure.");return s}finally{e.destroy(o)}}function c(t,r){var o=3*r.num_faces(),s=o*Uint32Array.BYTES_PER_ELEMENT,n=e._malloc(s);t.GetTrianglesUInt32Array(r,s,n);var i=new Uint32Array(e.HEAP32.buffer,n,o).slice();return e._free(n),i}function l(o,s,n,i){var a=r[i.componentType],u=t[i.componentType],c=n.num_components(),l=s.num_points()*c,f=l*u.BYTES_PER_ELEMENT,h=e._malloc(f);o.GetAttributeDataArrayForAllPoints(s,n,a,f,h);var p=new u(e.HEAPF32.buffer,h,l).slice();return e._free(h),p}var f,h="KHR_draco_mesh_compression",p=function(n){function i(){var e;return(e=n.apply(this,arguments)||this).extensionName=h,e.provideTypes=[o.PropertyType.PRIMITIVE],e.dependencies=["draco3d.decoder"],e}s(i,n);var f=i.prototype;return f.install=function(o,s){var n,i;return"draco3d.decoder"===o&&(this._decoderModule=s,e=this._decoderModule,(n={})[5126]=Float32Array,n[5125]=Uint32Array,n[5123]=Uint16Array,n[5121]=Uint8Array,n[5122]=Int16Array,n[5120]=Int8Array,t=n,(i={})[5126]=e.DT_FLOAT32,i[5125]=e.DT_UINT32,i[5123]=e.DT_UINT16,i[5121]=e.DT_UINT8,i[5122]=e.DT_INT16,i[5120]=e.DT_INT8,r=i),this},f.provide=function(e){if(!this._decoderModule)throw new Error('Please install extension dependency, "draco3d.decoder".');for(var t,r=this.doc.getLogger(),s=e.jsonDoc,n=new this._decoderModule.Decoder,i=new Map,f=a(s.json.meshes);!(t=f()).done;){for(var p,x=a(t.value.primitives);!(p=x()).done;){var T=p.value;if(T.extensions&&T.extensions[h]){var g=T.extensions[h],d=i.get(g.bufferView);if(!d){var y=s.json.bufferViews[g.bufferView],_=s.json.buffers[y.buffer],v=new Uint8Array(_.uri?s.resources[_.uri]:s.resources[o.GLB_BUFFER],y.byteOffset||0,y.byteLength);d=u(n,v),i.set(g.bufferView,d),r.debug("Decompressed "+v.byteLength+" bytes.")}for(var m in T.attributes){var I=e.jsonDoc.json.accessors[T.attributes[m]],C=n.GetAttributeByUniqueId(d,g.attributes[m]),E=l(n,d,C,I);e.accessors[T.attributes[m]].setArray(E)}var N=c(n,d);e.accessors[T.indices].setArray(N)}}this._decoderModule.destroy(n);for(var R=0,F=Array.from(i.values());R<F.length;R++)this._decoderModule.destroy(F[R])}return this},f.read=function(e){return this.dispose(),this},f.write=function(e){return this.doc.getLogger().warn("Writing "+this.extensionName+" not yet implemented."),this},i}(o.Extension);p.EXTENSION_NAME=h,(f=exports.LightType||(exports.LightType={})).POINT="point",f.SPOT="spot",f.DIRECTIONAL="directional";var x=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).propertyType="Light",t.parentTypes=[o.PropertyType.NODE],t.extensionName="KHR_lights_punctual",t._color=[1,1,1],t._intensity=1,t._range=void 0,t._innerConeAngle=0,t._outerConeAngle=Math.PI/4,t}s(t,e);var r=t.prototype;return r.copy=function(t,r){return void 0===r&&(r=o.COPY_IDENTITY),e.prototype.copy.call(this,t,r),this._color=[].concat(t._color),this._intensity=t._intensity,this._type=t._type,this._range=t._range,this._innerConeAngle=t._innerConeAngle,this._outerConeAngle=t._outerConeAngle,this},r.getColor=function(){return this._color},r.setColor=function(e){return this._color=e,this},r.getColorHex=function(){return o.ColorUtils.factorToHex(this._color)},r.setColorHex=function(e){return o.ColorUtils.hexToFactor(e,this._color),this},r.getIntensity=function(){return this._intensity},r.setIntensity=function(e){return this._intensity=e,this},r.getType=function(){return this._type},r.setType=function(e){return this._type=e,this},r.getRange=function(){return this._range},r.setRange=function(e){return this._range=e,this},r.getInnerConeAngle=function(){return this._innerConeAngle},r.setInnerConeAngle=function(e){return this._innerConeAngle=e,this},r.getOuterConeAngle=function(){return this._outerConeAngle},r.setOuterConeAngle=function(e){return this._outerConeAngle=e,this},t}(o.ExtensionProperty);x.EXTENSION_NAME="KHR_lights_punctual";var T="KHR_lights_punctual",g=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=T,t}s(t,e);var r=t.prototype;return r.createLight=function(){return new x(this.doc.getGraph(),this)},r.read=function(e){var t=this,r=e.jsonDoc;if(!r.json.extensions||!r.json.extensions[T])return this;var o=(r.json.extensions[T].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[T]&&e.nodes[r].setExtension(T,o[t.extensions[T].light])}),this},r.write=function(e){var t=e.jsonDoc;if(0===this.properties.size)return this;for(var r,o=[],s=new Map,n=a(this.properties);!(r=n()).done;){var i=r.value,u={type:i.getType(),color:i.getColor(),intensity:i.getIntensity(),range:i.getRange()};i.getName()&&(u.name=i.getName()),i.getType()===exports.LightType.SPOT&&(u.innerConeAngle=i.getInnerConeAngle(),u.outerConeAngle=i.getOuterConeAngle()),o.push(u),s.set(i,o.length-1)}return this.doc.getRoot().listNodes().forEach(function(r){var o=r.getExtension(T);if(o){var n=e.nodeIndexMap.get(r),i=t.json.nodes[n];i.extensions=i.extensions||{},i.extensions[T]={light:s.get(o)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[T]={lights:o},this},t}(o.Extension);function d(e,t,r,o){var s,n=arguments.length,i=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,o);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(i=(n<3?s(i):n>3?s(t,r,i):s(t,r))||i);return n>3&&i&&Object.defineProperty(t,r,i),i}g.EXTENSION_NAME=T;var y=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).propertyType="Clearcoat",t.parentTypes=[o.PropertyType.MATERIAL],t.extensionName="KHR_materials_clearcoat",t._clearcoatFactor=0,t._clearcoatRoughnessFactor=0,t._clearcoatNormalScale=1,t.clearcoatTexture=null,t.clearcoatTextureInfo=t.graph.link("clearcoatTextureInfo",n(t),new o.TextureInfo(t.graph)),t.clearcoatRoughnessTexture=null,t.clearcoatRoughnessTextureInfo=t.graph.link("clearcoatRoughnessTextureInfo",n(t),new o.TextureInfo(t.graph)),t.clearcoatNormalTexture=null,t.clearcoatNormalTextureInfo=t.graph.link("clearcoatNormalTextureInfo",n(t),new o.TextureInfo(t.graph)),t}s(t,e);var r=t.prototype;return r.copy=function(t,r){return void 0===r&&(r=o.COPY_IDENTITY),e.prototype.copy.call(this,t,r),this._clearcoatFactor=t._clearcoatFactor,this._clearcoatRoughnessFactor=t._clearcoatRoughnessFactor,this._clearcoatNormalScale=t._clearcoatNormalScale,t.clearcoatTexture&&(this.setClearcoatTexture(r(t.clearcoatTexture.getChild())),this.getClearcoatTextureInfo().copy(r(t.clearcoatTextureInfo.getChild()))),t.clearcoatRoughnessTexture&&(this.setClearcoatRoughnessTexture(r(t.clearcoatRoughnessTexture.getChild())),this.getClearcoatRoughnessTextureInfo().copy(r(t.clearcoatRoughnessTextureInfo.getChild()))),t.clearcoatNormalTexture&&(this.setClearcoatNormalTexture(r(t.clearcoatNormalTexture.getChild())),this.getClearcoatNormalTextureInfo().copy(r(t.clearcoatNormalTextureInfo.getChild()))),this},r.dispose=function(){this.clearcoatTextureInfo.getChild().dispose(),this.clearcoatRoughnessTextureInfo.getChild().dispose(),this.clearcoatNormalTextureInfo.getChild().dispose(),e.prototype.dispose.call(this)},r.getClearcoatFactor=function(){return this._clearcoatFactor},r.setClearcoatFactor=function(e){return this._clearcoatFactor=e,this},r.getClearcoatTexture=function(){return this.clearcoatTexture?this.clearcoatTexture.getChild():null},r.getClearcoatTextureInfo=function(){return this.clearcoatTexture?this.clearcoatTextureInfo.getChild():null},r.setClearcoatTexture=function(e){return this.clearcoatTexture=this.graph.link("clearcoatTexture",this,e),this},r.getClearcoatRoughnessFactor=function(){return this._clearcoatRoughnessFactor},r.setClearcoatRoughnessFactor=function(e){return this._clearcoatRoughnessFactor=e,this},r.getClearcoatRoughnessTexture=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.getChild():null},r.getClearcoatRoughnessTextureInfo=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTextureInfo.getChild():null},r.setClearcoatRoughnessTexture=function(e){return this.clearcoatRoughnessTexture=this.graph.link("clearcoatRoughnessTexture",this,e),this},r.getClearcoatNormalScale=function(){return this._clearcoatNormalScale},r.setClearcoatNormalScale=function(e){return this._clearcoatNormalScale=e,this},r.getClearcoatNormalTexture=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTexture.getChild():null},r.getClearcoatNormalTextureInfo=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTextureInfo.getChild():null},r.setClearcoatNormalTexture=function(e){return this.clearcoatNormalTexture=this.graph.link("clearcoatNormalTexture",this,e),this},t}(o.ExtensionProperty);y.EXTENSION_NAME="KHR_materials_clearcoat",d([o.GraphChild],y.prototype,"clearcoatTexture",void 0),d([o.GraphChild],y.prototype,"clearcoatTextureInfo",void 0),d([o.GraphChild],y.prototype,"clearcoatRoughnessTexture",void 0),d([o.GraphChild],y.prototype,"clearcoatRoughnessTextureInfo",void 0),d([o.GraphChild],y.prototype,"clearcoatNormalTexture",void 0),d([o.GraphChild],y.prototype,"clearcoatNormalTextureInfo",void 0);var _="KHR_materials_clearcoat",v=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=_,t}s(t,e);var r=t.prototype;return r.createClearcoat=function(){return new y(this.doc.getGraph(),this)},r.read=function(e){var t=this,r=e.jsonDoc,o=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,s){if(r.extensions&&r.extensions[_]){var n=t.createClearcoat();if(e.materials[s].setExtension(_,n),void 0!==r.extensions[_].clearcoatFactor&&n.setClearcoatFactor(r.extensions[_].clearcoatFactor),void 0!==r.extensions[_].clearcoatRoughnessFactor&&n.setClearcoatRoughnessFactor(r.extensions[_].clearcoatRoughnessFactor),void 0!==r.extensions[_].clearcoatTexture){var i=r.extensions[_].clearcoatTexture;n.setClearcoatTexture(e.textures[o[i.index].source]),e.setTextureInfo(n.getClearcoatTextureInfo(),i)}if(void 0!==r.extensions[_].clearcoatRoughnessTexture){var a=r.extensions[_].clearcoatRoughnessTexture;n.setClearcoatRoughnessTexture(e.textures[o[a.index].source]),e.setTextureInfo(n.getClearcoatRoughnessTextureInfo(),a)}if(void 0!==r.extensions[_].clearcoatNormalTexture){var u=r.extensions[_].clearcoatNormalTexture;n.setClearcoatNormalTexture(e.textures[o[u.index].source]),e.setTextureInfo(n.getClearcoatNormalTextureInfo(),u),void 0!==u.scale&&n.setClearcoatNormalScale(u.scale)}}}),this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var o=r.getExtension(_);if(o){var s=e.materialIndexMap.get(r),n=t.json.materials[s];if(n.extensions=n.extensions||{},n.extensions[_]={clearcoatFactor:o.getClearcoatFactor(),clearcoatRoughnessFactor:o.getClearcoatRoughnessFactor()},o.getClearcoatTexture()){var i=o.getClearcoatTexture(),a=o.getClearcoatTextureInfo();n.extensions[_].clearcoatTexture=e.createTextureInfoDef(i,a)}if(o.getClearcoatRoughnessTexture()){var u=o.getClearcoatRoughnessTexture(),c=o.getClearcoatRoughnessTextureInfo();n.extensions[_].clearcoatRoughnessTexture=e.createTextureInfoDef(u,c)}if(o.getClearcoatNormalTexture()){var l=o.getClearcoatNormalTexture(),f=o.getClearcoatNormalTextureInfo();n.extensions[_].clearcoatNormalTexture=e.createTextureInfoDef(l,f),1!==o.getClearcoatNormalScale()&&(n.extensions[_].clearcoatNormalTexture.scale=o.getClearcoatNormalScale())}}}),this},t}(o.Extension);v.EXTENSION_NAME=_;var m=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).propertyType="IOR",t.parentTypes=[o.PropertyType.MATERIAL],t.extensionName="KHR_materials_ior",t._ior=0,t}s(t,e);var r=t.prototype;return r.copy=function(t,r){return void 0===r&&(r=o.COPY_IDENTITY),e.prototype.copy.call(this,t,r),this._ior=t._ior,this},r.getIOR=function(){return this._ior},r.setIOR=function(e){return this._ior=e,this},t}(o.ExtensionProperty);m.EXTENSION_NAME="KHR_materials_ior";var I="KHR_materials_ior",C=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=I,t}s(t,e);var r=t.prototype;return r.createIOR=function(){return new m(this.doc.getGraph(),this)},r.read=function(e){var t=this;return(e.jsonDoc.json.materials||[]).forEach(function(r,o){if(r.extensions&&r.extensions[I]){var s=t.createIOR();e.materials[o].setExtension(I,s),void 0!==r.extensions[I].ior&&s.setIOR(r.extensions[I].ior)}}),this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var o=r.getExtension(I);if(o){var s=e.materialIndexMap.get(r),n=t.json.materials[s];n.extensions=n.extensions||{},n.extensions[I]={ior:o.getIOR()}}}),this},t}(o.Extension);C.EXTENSION_NAME=I;var E=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).propertyType="PBRSpecularGlossiness",t.parentTypes=[o.PropertyType.MATERIAL],t.extensionName="KHR_materials_pbrSpecularGlossiness",t._diffuseFactor=[1,1,1,1],t._specularFactor=[1,1,1],t._glossinessFactor=1,t.diffuseTexture=null,t.diffuseTextureInfo=t.graph.link("diffuseTextureInfo",n(t),new o.TextureInfo(t.graph)),t.specularGlossinessTexture=null,t.specularGlossinessTextureInfo=t.graph.link("specularGlossinessTextureInfo",n(t),new o.TextureInfo(t.graph)),t}s(t,e);var r=t.prototype;return r.copy=function(t,r){return void 0===r&&(r=o.COPY_IDENTITY),e.prototype.copy.call(this,t,r),this._diffuseFactor=t._diffuseFactor,this._specularFactor=t._specularFactor,this._glossinessFactor=t._glossinessFactor,t.diffuseTexture&&(this.setDiffuseTexture(r(t.diffuseTexture.getChild())),this.getDiffuseTextureInfo().copy(r(t.diffuseTextureInfo.getChild()))),t.specularGlossinessTexture&&(this.setSpecularGlossinessTexture(r(t.specularGlossinessTexture.getChild())),this.getSpecularGlossinessTextureInfo().copy(r(t.specularGlossinessTextureInfo.getChild()))),this},r.dispose=function(){this.diffuseTextureInfo.getChild().dispose(),this.specularGlossinessTextureInfo.getChild().dispose(),e.prototype.dispose.call(this)},r.getDiffuseFactor=function(){return this._diffuseFactor},r.setDiffuseFactor=function(e){return this._diffuseFactor=e,this},r.getDiffuseHex=function(){return o.ColorUtils.factorToHex(this._diffuseFactor)},r.setDiffuseHex=function(e){return o.ColorUtils.hexToFactor(e,this._diffuseFactor),this},r.getDiffuseTexture=function(){return this.diffuseTexture?this.diffuseTexture.getChild():null},r.getDiffuseTextureInfo=function(){return this.diffuseTexture?this.diffuseTextureInfo.getChild():null},r.setDiffuseTexture=function(e){return this.diffuseTexture=this.graph.link("diffuseTexture",this,e),this},r.getSpecularFactor=function(){return this._specularFactor},r.setSpecularFactor=function(e){return this._specularFactor=e,this},r.getGlossinessFactor=function(){return this._glossinessFactor},r.setGlossinessFactor=function(e){return this._glossinessFactor=e,this},r.getSpecularGlossinessTexture=function(){return this.specularGlossinessTexture?this.specularGlossinessTexture.getChild():null},r.getSpecularGlossinessTextureInfo=function(){return this.specularGlossinessTexture?this.specularGlossinessTextureInfo.getChild():null},r.setSpecularGlossinessTexture=function(e){return this.specularGlossinessTexture=this.graph.link("specularGlossinessTexture",this,e),this},t}(o.ExtensionProperty);E.EXTENSION_NAME="KHR_materials_pbrSpecularGlossiness",d([o.GraphChild],E.prototype,"diffuseTexture",void 0),d([o.GraphChild],E.prototype,"diffuseTextureInfo",void 0),d([o.GraphChild],E.prototype,"specularGlossinessTexture",void 0),d([o.GraphChild],E.prototype,"specularGlossinessTextureInfo",void 0);var N="KHR_materials_pbrSpecularGlossiness",R=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=N,t}s(t,e);var r=t.prototype;return r.createPBRSpecularGlossiness=function(){return new E(this.doc.getGraph(),this)},r.read=function(e){var t=this,r=e.jsonDoc,o=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,s){if(r.extensions&&r.extensions[N]){var n=t.createPBRSpecularGlossiness();if(e.materials[s].setExtension(N,n),void 0!==r.extensions[N].diffuseFactor&&n.setDiffuseFactor(r.extensions[N].diffuseFactor),void 0!==r.extensions[N].specularFactor&&n.setSpecularFactor(r.extensions[N].specularFactor),void 0!==r.extensions[N].glossinessFactor&&n.setGlossinessFactor(r.extensions[N].glossinessFactor),void 0!==r.extensions[N].diffuseTexture){var i=r.extensions[N].diffuseTexture;n.setDiffuseTexture(e.textures[o[i.index].source]),e.setTextureInfo(n.getDiffuseTextureInfo(),i)}if(void 0!==r.extensions[N].specularGlossinessTexture){var a=r.extensions[N].specularGlossinessTexture;n.setSpecularGlossinessTexture(e.textures[o[a.index].source]),e.setTextureInfo(n.getSpecularGlossinessTextureInfo(),a)}}}),this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var o=r.getExtension(N);if(o){var s=e.materialIndexMap.get(r),n=t.json.materials[s];if(n.extensions=n.extensions||{},n.extensions[N]={diffuseFactor:o.getDiffuseFactor(),specularFactor:o.getSpecularFactor(),glossinessFactor:o.getGlossinessFactor()},o.getDiffuseTexture()){var i=o.getDiffuseTexture(),a=o.getDiffuseTextureInfo();n.extensions[N].diffuseTexture=e.createTextureInfoDef(i,a)}if(o.getSpecularGlossinessTexture()){var u=o.getSpecularGlossinessTexture(),c=o.getSpecularGlossinessTextureInfo();n.extensions[N].specularGlossinessTexture=e.createTextureInfoDef(u,c)}}}),this},t}(o.Extension);R.EXTENSION_NAME=N;var F=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).propertyType="Specular",t.parentTypes=[o.PropertyType.MATERIAL],t.extensionName="KHR_materials_specular",t._specularFactor=1,t._specularColorFactor=[1,1,1],t.specularTexture=null,t.specularTextureInfo=t.graph.link("specularTextureInfo",n(t),new o.TextureInfo(t.graph)),t}s(t,e);var r=t.prototype;return r.copy=function(t,r){return void 0===r&&(r=o.COPY_IDENTITY),e.prototype.copy.call(this,t,r),this._specularFactor=t._specularFactor,t.specularTexture&&(this.setSpecularTexture(r(t.specularTexture.getChild())),this.getSpecularTextureInfo().copy(r(t.specularTextureInfo.getChild()))),this},r.dispose=function(){this.specularTextureInfo.getChild().dispose(),e.prototype.dispose.call(this)},r.getSpecularFactor=function(){return this._specularFactor},r.setSpecularFactor=function(e){return this._specularFactor=e,this},r.getSpecularColorFactor=function(){return this._specularColorFactor},r.setSpecularColorFactor=function(e){return this._specularColorFactor=e,this},r.getSpecularColorHex=function(){return o.ColorUtils.factorToHex(this._specularColorFactor)},r.setSpecularColorHex=function(e){return o.ColorUtils.hexToFactor(e,this._specularColorFactor),this},r.getSpecularTexture=function(){return this.specularTexture?this.specularTexture.getChild():null},r.getSpecularTextureInfo=function(){return this.specularTexture?this.specularTextureInfo.getChild():null},r.setSpecularTexture=function(e){return this.specularTexture=this.graph.link("specularTexture",this,e),this},t}(o.ExtensionProperty);F.EXTENSION_NAME="KHR_materials_specular",d([o.GraphChild],F.prototype,"specularTexture",void 0),d([o.GraphChild],F.prototype,"specularTextureInfo",void 0);var S="KHR_materials_specular",A=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=S,t}s(t,e);var r=t.prototype;return r.createSpecular=function(){return new F(this.doc.getGraph(),this)},r.read=function(e){var t=this,r=e.jsonDoc,o=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,s){if(r.extensions&&r.extensions[S]){var n=t.createSpecular();if(e.materials[s].setExtension(S,n),void 0!==r.extensions[S].specularFactor&&n.setSpecularFactor(r.extensions[S].specularFactor),void 0!==r.extensions[S].specularColorFactor&&n.setSpecularColorFactor(r.extensions[S].specularColorFactor),void 0!==r.extensions[S].specularTexture){var i=r.extensions[S].specularTexture;n.setSpecularTexture(e.textures[o[i.index].source]),e.setTextureInfo(n.getSpecularTextureInfo(),i)}}}),this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var o=r.getExtension(S);if(o){var s=e.materialIndexMap.get(r),n=t.json.materials[s];if(n.extensions=n.extensions||{},n.extensions[S]={specularFactor:o.getSpecularFactor(),specularColorFactor:o.getSpecularColorFactor()},o.getSpecularTexture()){var i=o.getSpecularTexture(),a=o.getSpecularTextureInfo();n.extensions[S].specularTexture=e.createTextureInfoDef(i,a)}}}),this},t}(o.Extension);A.EXTENSION_NAME=S;var G=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).propertyType="Transmission",t.parentTypes=[o.PropertyType.MATERIAL],t.extensionName="KHR_materials_transmission",t._transmissionFactor=0,t.transmissionTexture=null,t.transmissionTextureInfo=t.graph.link("transmissionTextureInfo",n(t),new o.TextureInfo(t.graph)),t}s(t,e);var r=t.prototype;return r.copy=function(t,r){return void 0===r&&(r=o.COPY_IDENTITY),e.prototype.copy.call(this,t,r),this._transmissionFactor=t._transmissionFactor,t.transmissionTexture&&(this.setTransmissionTexture(r(t.transmissionTexture.getChild())),this.getTransmissionTextureInfo().copy(r(t.transmissionTextureInfo.getChild()))),this},r.dispose=function(){this.transmissionTextureInfo.getChild().dispose(),e.prototype.dispose.call(this)},r.getTransmissionFactor=function(){return this._transmissionFactor},r.setTransmissionFactor=function(e){return this._transmissionFactor=e,this},r.getTransmissionTexture=function(){return this.transmissionTexture?this.transmissionTexture.getChild():null},r.getTransmissionTextureInfo=function(){return this.transmissionTexture?this.transmissionTextureInfo.getChild():null},r.setTransmissionTexture=function(e){return this.transmissionTexture=this.graph.link("transmissionTexture",this,e),this},t}(o.ExtensionProperty);G.EXTENSION_NAME="KHR_materials_transmission",d([o.GraphChild],G.prototype,"transmissionTexture",void 0),d([o.GraphChild],G.prototype,"transmissionTextureInfo",void 0);var D="KHR_materials_transmission",M=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=D,t}s(t,e);var r=t.prototype;return r.createTransmission=function(){return new G(this.doc.getGraph(),this)},r.read=function(e){var t=this,r=e.jsonDoc,o=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,s){if(r.extensions&&r.extensions[D]){var n=t.createTransmission();if(e.materials[s].setExtension(D,n),void 0!==r.extensions[D].transmissionFactor&&n.setTransmissionFactor(r.extensions[D].transmissionFactor),void 0!==r.extensions[D].transmissionTexture){var i=r.extensions[D].transmissionTexture;n.setTransmissionTexture(e.textures[o[i.index].source]),e.setTextureInfo(n.getTransmissionTextureInfo(),i)}}}),this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var o=r.getExtension(D);if(o){var s=e.materialIndexMap.get(r),n=t.json.materials[s];if(n.extensions=n.extensions||{},n.extensions[D]={transmissionFactor:o.getTransmissionFactor()},o.getTransmissionTexture()){var i=o.getTransmissionTexture(),a=o.getTransmissionTextureInfo();n.extensions[D].transmissionTexture=e.createTextureInfoDef(i,a)}}}),this},t}(o.Extension);M.EXTENSION_NAME=D;var O=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).propertyType="Unlit",t.parentTypes=[o.PropertyType.MATERIAL],t.extensionName="KHR_materials_unlit",t}return s(t,e),t}(o.ExtensionProperty);O.EXTENSION_NAME="KHR_materials_unlit";var j="KHR_materials_unlit",w=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=j,t}s(t,e);var r=t.prototype;return r.createUnlit=function(){return new O(this.doc.getGraph(),this)},r.read=function(e){var t=this;return(e.jsonDoc.json.materials||[]).forEach(function(r,o){r.extensions&&r.extensions[j]&&e.materials[o].setExtension(j,t.createUnlit())}),this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){if(r.getExtension(j)){var o=e.materialIndexMap.get(r),s=t.json.materials[o];s.extensions=s.extensions||{},s.extensions[j]={}}}),this},t}(o.Extension);w.EXTENSION_NAME=j;var P="KHR_mesh_quantization",b=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=P,t}s(t,e);var r=t.prototype;return r.read=function(e){return this},r.write=function(e){return this},t}(o.Extension);b.EXTENSION_NAME=P;var H="KHR_texture_basisu",K=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=H,t.provideTypes=[o.PropertyType.TEXTURE],t}s(t,e);var r=t.prototype;return r.provide=function(e){return e.jsonDoc.json.textures.forEach(function(e){e.extensions&&e.extensions[H]&&(e.source=e.extensions[H].source)}),this},r.read=function(e){return this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listTextures().forEach(function(r){if("image/ktx2"===r.getMimeType()){var o=e.imageIndexMap.get(r);t.json.textures.forEach(function(e){e.source===o&&(e.extensions=e.extensions||{},e.extensions[H]={source:e.source},delete e.source)})}}),this},t}(o.Extension);K.EXTENSION_NAME=H;var U=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).propertyType="Transform",t.parentTypes=[o.PropertyType.TEXTURE_INFO],t.extensionName="KHR_texture_transform",t._offset=[0,0],t._rotation=0,t._scale=[1,1],t._texCoord=void 0,t}s(t,e);var r=t.prototype;return r.copy=function(t,r){return void 0===r&&(r=o.COPY_IDENTITY),e.prototype.copy.call(this,t,r),this._offset=t._offset,this._rotation=t._rotation,this._scale=t._scale,this._texCoord=t._texCoord,this},r.getOffset=function(){return this._offset},r.setOffset=function(e){return this._offset=e,this},r.getRotation=function(){return this._rotation},r.setRotation=function(e){return this._rotation=e,this},r.getScale=function(){return this._scale},r.setScale=function(e){return this._scale=e,this},r.getTexCoord=function(){return this._texCoord},r.setTexCoord=function(e){return this._texCoord=e,this},t}(o.ExtensionProperty);U.EXTENSION_NAME="KHR_texture_transform";var L="KHR_texture_transform",X=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=L,t}s(t,e);var r=t.prototype;return r.createTransform=function(){return new U(this.doc.getGraph(),this)},r.read=function(e){for(var t=0,r=Array.from(e.textureInfos.entries());t<r.length;t++){var o=r[t],s=o[0],n=o[1];if(n.extensions&&n.extensions[L]){var i=this.createTransform(),a=n.extensions[L];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),s.setExtension(L,i)}}return this},r.write=function(e){for(var t=0,r=Array.from(e.textureInfoDefMap.entries());t<r.length;t++){var o=r[t],s=o[1],n=o[0].getExtension(L);n&&(s.extensions=s.extensions||{},s.extensions[L]={offset:n.getOffset(),rotation:n.getRotation(),scale:n.getScale(),texCoord:n.getTexCoord()})}return this},t}(o.Extension);X.EXTENSION_NAME=L;var k=[p,g,v,C,R,A,M,w,b,K,X];exports.Clearcoat=y,exports.DracoMeshCompression=p,exports.IOR=m,exports.KHRONOS_EXTENSIONS=k,exports.Light=x,exports.LightsPunctual=g,exports.MaterialsClearcoat=v,exports.MaterialsIOR=C,exports.MaterialsPBRSpecularGlossiness=R,exports.MaterialsSpecular=A,exports.MaterialsTransmission=M,exports.MaterialsUnlit=w,exports.MeshQuantization=b,exports.PBRSpecularGlossiness=E,exports.Specular=F,exports.TextureBasisu=K,exports.TextureTransform=X,exports.Transform=U,exports.Transmission=G,exports.Unlit=O; | ||
var e,t,r,o=require("@gltf-transform/core");function s(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function n(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function a(e){var t=0;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,t){if(e){if("string"==typeof e)return i(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(e,void 0):void 0}}(e)))return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}function u(t,r){var o;try{if((o=new e.DecoderBuffer).Init(new Int8Array(r),r.byteLength),t.GetEncodedGeometryType(o)!==e.TRIANGULAR_MESH)throw new Error("Unknown geometry type.");var s=new e.Mesh;if(!t.DecodeBufferToMesh(o,s).ok()||0===s.ptr)throw new Error("Decoding failure.");return s}finally{e.destroy(o)}}function c(t,r){var o=3*r.num_faces(),s=o*Uint32Array.BYTES_PER_ELEMENT,n=e._malloc(s);t.GetTrianglesUInt32Array(r,s,n);var i=new Uint32Array(e.HEAP32.buffer,n,o).slice();return e._free(n),i}function l(o,s,n,i){var a=r[i.componentType],u=t[i.componentType],c=n.num_components(),l=s.num_points()*c,f=l*u.BYTES_PER_ELEMENT,h=e._malloc(f);o.GetAttributeDataArrayForAllPoints(s,n,a,f,h);var p=new u(e.HEAPF32.buffer,h,l).slice();return e._free(h),p}var f,h="KHR_draco_mesh_compression",p=function(n){function i(){var e;return(e=n.apply(this,arguments)||this).extensionName=h,e.provideTypes=[o.PropertyType.PRIMITIVE],e.dependencies=["draco3d.decoder"],e}s(i,n);var f=i.prototype;return f.install=function(o,s){var n,i;return"draco3d.decoder"===o&&(this._decoderModule=s,e=this._decoderModule,(n={})[5126]=Float32Array,n[5125]=Uint32Array,n[5123]=Uint16Array,n[5121]=Uint8Array,n[5122]=Int16Array,n[5120]=Int8Array,t=n,(i={})[5126]=e.DT_FLOAT32,i[5125]=e.DT_UINT32,i[5123]=e.DT_UINT16,i[5121]=e.DT_UINT8,i[5122]=e.DT_INT16,i[5120]=e.DT_INT8,r=i),this},f.provide=function(e){if(!this._decoderModule)throw new Error('Please install extension dependency, "draco3d.decoder".');for(var t,r=this.doc.getLogger(),s=e.jsonDoc,n=new this._decoderModule.Decoder,i=new Map,f=a(s.json.meshes);!(t=f()).done;){for(var p,x=a(t.value.primitives);!(p=x()).done;){var T=p.value;if(T.extensions&&T.extensions[h]){var g=T.extensions[h],d=i.get(g.bufferView);if(!d){var y=s.json.bufferViews[g.bufferView],_=s.json.buffers[y.buffer],v=new Uint8Array(_.uri?s.resources[_.uri]:s.resources[o.GLB_BUFFER],y.byteOffset||0,y.byteLength);d=u(n,v),i.set(g.bufferView,d),r.debug("Decompressed "+v.byteLength+" bytes.")}for(var m in T.attributes){var I=e.jsonDoc.json.accessors[T.attributes[m]],C=n.GetAttributeByUniqueId(d,g.attributes[m]),E=l(n,d,C,I);e.accessors[T.attributes[m]].setArray(E)}var N=c(n,d);e.accessors[T.indices].setArray(N)}}this._decoderModule.destroy(n);for(var R=0,F=Array.from(i.values());R<F.length;R++)this._decoderModule.destroy(F[R])}return this},f.read=function(e){return this.dispose(),this},f.write=function(e){return this.doc.getLogger().warn("Writing "+this.extensionName+" not yet implemented."),this},i}(o.Extension);p.EXTENSION_NAME=h,(f=exports.LightType||(exports.LightType={})).POINT="point",f.SPOT="spot",f.DIRECTIONAL="directional";var x=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).propertyType="Light",t.parentTypes=[o.PropertyType.NODE],t.extensionName="KHR_lights_punctual",t._color=[1,1,1],t._intensity=1,t._range=void 0,t._innerConeAngle=0,t._outerConeAngle=Math.PI/4,t}s(t,e);var r=t.prototype;return r.copy=function(t,r){return void 0===r&&(r=o.COPY_IDENTITY),e.prototype.copy.call(this,t,r),this._color=[].concat(t._color),this._intensity=t._intensity,this._type=t._type,this._range=t._range,this._innerConeAngle=t._innerConeAngle,this._outerConeAngle=t._outerConeAngle,this},r.getColor=function(){return this._color},r.setColor=function(e){return this._color=e,this},r.getColorHex=function(){return o.ColorUtils.factorToHex(this._color)},r.setColorHex=function(e){return o.ColorUtils.hexToFactor(e,this._color),this},r.getIntensity=function(){return this._intensity},r.setIntensity=function(e){return this._intensity=e,this},r.getType=function(){return this._type},r.setType=function(e){return this._type=e,this},r.getRange=function(){return this._range},r.setRange=function(e){return this._range=e,this},r.getInnerConeAngle=function(){return this._innerConeAngle},r.setInnerConeAngle=function(e){return this._innerConeAngle=e,this},r.getOuterConeAngle=function(){return this._outerConeAngle},r.setOuterConeAngle=function(e){return this._outerConeAngle=e,this},t}(o.ExtensionProperty);x.EXTENSION_NAME="KHR_lights_punctual";var T="KHR_lights_punctual",g=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=T,t}s(t,e);var r=t.prototype;return r.createLight=function(){return new x(this.doc.getGraph(),this)},r.read=function(e){var t=this,r=e.jsonDoc;if(!r.json.extensions||!r.json.extensions[T])return this;var o=(r.json.extensions[T].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[T]&&e.nodes[r].setExtension(T,o[t.extensions[T].light])}),this},r.write=function(e){var t=e.jsonDoc;if(0===this.properties.size)return this;for(var r,o=[],s=new Map,n=a(this.properties);!(r=n()).done;){var i=r.value,u={type:i.getType(),color:i.getColor(),intensity:i.getIntensity(),range:i.getRange()};i.getName()&&(u.name=i.getName()),i.getType()===exports.LightType.SPOT&&(u.innerConeAngle=i.getInnerConeAngle(),u.outerConeAngle=i.getOuterConeAngle()),o.push(u),s.set(i,o.length-1)}return this.doc.getRoot().listNodes().forEach(function(r){var o=r.getExtension(T);if(o){var n=e.nodeIndexMap.get(r),i=t.json.nodes[n];i.extensions=i.extensions||{},i.extensions[T]={light:s.get(o)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[T]={lights:o},this},t}(o.Extension);function d(e,t,r,o){var s,n=arguments.length,i=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,o);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(i=(n<3?s(i):n>3?s(t,r,i):s(t,r))||i);return n>3&&i&&Object.defineProperty(t,r,i),i}g.EXTENSION_NAME=T;var y=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).propertyType="Clearcoat",t.parentTypes=[o.PropertyType.MATERIAL],t.extensionName="KHR_materials_clearcoat",t._clearcoatFactor=0,t._clearcoatRoughnessFactor=0,t._clearcoatNormalScale=1,t.clearcoatTexture=null,t.clearcoatTextureInfo=t.graph.link("clearcoatTextureInfo",n(t),new o.TextureInfo(t.graph)),t.clearcoatRoughnessTexture=null,t.clearcoatRoughnessTextureInfo=t.graph.link("clearcoatRoughnessTextureInfo",n(t),new o.TextureInfo(t.graph)),t.clearcoatNormalTexture=null,t.clearcoatNormalTextureInfo=t.graph.link("clearcoatNormalTextureInfo",n(t),new o.TextureInfo(t.graph)),t}s(t,e);var r=t.prototype;return r.copy=function(t,r){return void 0===r&&(r=o.COPY_IDENTITY),e.prototype.copy.call(this,t,r),this._clearcoatFactor=t._clearcoatFactor,this._clearcoatRoughnessFactor=t._clearcoatRoughnessFactor,this._clearcoatNormalScale=t._clearcoatNormalScale,t.clearcoatTexture&&(this.setClearcoatTexture(r(t.clearcoatTexture.getChild())),this.getClearcoatTextureInfo().copy(r(t.clearcoatTextureInfo.getChild()),r)),t.clearcoatRoughnessTexture&&(this.setClearcoatRoughnessTexture(r(t.clearcoatRoughnessTexture.getChild())),this.getClearcoatRoughnessTextureInfo().copy(r(t.clearcoatRoughnessTextureInfo.getChild()),r)),t.clearcoatNormalTexture&&(this.setClearcoatNormalTexture(r(t.clearcoatNormalTexture.getChild())),this.getClearcoatNormalTextureInfo().copy(r(t.clearcoatNormalTextureInfo.getChild()),r)),this},r.dispose=function(){this.clearcoatTextureInfo.getChild().dispose(),this.clearcoatRoughnessTextureInfo.getChild().dispose(),this.clearcoatNormalTextureInfo.getChild().dispose(),e.prototype.dispose.call(this)},r.getClearcoatFactor=function(){return this._clearcoatFactor},r.setClearcoatFactor=function(e){return this._clearcoatFactor=e,this},r.getClearcoatTexture=function(){return this.clearcoatTexture?this.clearcoatTexture.getChild():null},r.getClearcoatTextureInfo=function(){return this.clearcoatTexture?this.clearcoatTextureInfo.getChild():null},r.setClearcoatTexture=function(e){return this.clearcoatTexture=this.graph.link("clearcoatTexture",this,e),this},r.getClearcoatRoughnessFactor=function(){return this._clearcoatRoughnessFactor},r.setClearcoatRoughnessFactor=function(e){return this._clearcoatRoughnessFactor=e,this},r.getClearcoatRoughnessTexture=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.getChild():null},r.getClearcoatRoughnessTextureInfo=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTextureInfo.getChild():null},r.setClearcoatRoughnessTexture=function(e){return this.clearcoatRoughnessTexture=this.graph.link("clearcoatRoughnessTexture",this,e),this},r.getClearcoatNormalScale=function(){return this._clearcoatNormalScale},r.setClearcoatNormalScale=function(e){return this._clearcoatNormalScale=e,this},r.getClearcoatNormalTexture=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTexture.getChild():null},r.getClearcoatNormalTextureInfo=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTextureInfo.getChild():null},r.setClearcoatNormalTexture=function(e){return this.clearcoatNormalTexture=this.graph.link("clearcoatNormalTexture",this,e),this},t}(o.ExtensionProperty);y.EXTENSION_NAME="KHR_materials_clearcoat",d([o.GraphChild],y.prototype,"clearcoatTexture",void 0),d([o.GraphChild],y.prototype,"clearcoatTextureInfo",void 0),d([o.GraphChild],y.prototype,"clearcoatRoughnessTexture",void 0),d([o.GraphChild],y.prototype,"clearcoatRoughnessTextureInfo",void 0),d([o.GraphChild],y.prototype,"clearcoatNormalTexture",void 0),d([o.GraphChild],y.prototype,"clearcoatNormalTextureInfo",void 0);var _="KHR_materials_clearcoat",v=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=_,t}s(t,e);var r=t.prototype;return r.createClearcoat=function(){return new y(this.doc.getGraph(),this)},r.read=function(e){var t=this,r=e.jsonDoc,o=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,s){if(r.extensions&&r.extensions[_]){var n=t.createClearcoat();if(e.materials[s].setExtension(_,n),void 0!==r.extensions[_].clearcoatFactor&&n.setClearcoatFactor(r.extensions[_].clearcoatFactor),void 0!==r.extensions[_].clearcoatRoughnessFactor&&n.setClearcoatRoughnessFactor(r.extensions[_].clearcoatRoughnessFactor),void 0!==r.extensions[_].clearcoatTexture){var i=r.extensions[_].clearcoatTexture;n.setClearcoatTexture(e.textures[o[i.index].source]),e.setTextureInfo(n.getClearcoatTextureInfo(),i)}if(void 0!==r.extensions[_].clearcoatRoughnessTexture){var a=r.extensions[_].clearcoatRoughnessTexture;n.setClearcoatRoughnessTexture(e.textures[o[a.index].source]),e.setTextureInfo(n.getClearcoatRoughnessTextureInfo(),a)}if(void 0!==r.extensions[_].clearcoatNormalTexture){var u=r.extensions[_].clearcoatNormalTexture;n.setClearcoatNormalTexture(e.textures[o[u.index].source]),e.setTextureInfo(n.getClearcoatNormalTextureInfo(),u),void 0!==u.scale&&n.setClearcoatNormalScale(u.scale)}}}),this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var o=r.getExtension(_);if(o){var s=e.materialIndexMap.get(r),n=t.json.materials[s];if(n.extensions=n.extensions||{},n.extensions[_]={clearcoatFactor:o.getClearcoatFactor(),clearcoatRoughnessFactor:o.getClearcoatRoughnessFactor()},o.getClearcoatTexture()){var i=o.getClearcoatTexture(),a=o.getClearcoatTextureInfo();n.extensions[_].clearcoatTexture=e.createTextureInfoDef(i,a)}if(o.getClearcoatRoughnessTexture()){var u=o.getClearcoatRoughnessTexture(),c=o.getClearcoatRoughnessTextureInfo();n.extensions[_].clearcoatRoughnessTexture=e.createTextureInfoDef(u,c)}if(o.getClearcoatNormalTexture()){var l=o.getClearcoatNormalTexture(),f=o.getClearcoatNormalTextureInfo();n.extensions[_].clearcoatNormalTexture=e.createTextureInfoDef(l,f),1!==o.getClearcoatNormalScale()&&(n.extensions[_].clearcoatNormalTexture.scale=o.getClearcoatNormalScale())}}}),this},t}(o.Extension);v.EXTENSION_NAME=_;var m=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).propertyType="IOR",t.parentTypes=[o.PropertyType.MATERIAL],t.extensionName="KHR_materials_ior",t._ior=0,t}s(t,e);var r=t.prototype;return r.copy=function(t,r){return void 0===r&&(r=o.COPY_IDENTITY),e.prototype.copy.call(this,t,r),this._ior=t._ior,this},r.getIOR=function(){return this._ior},r.setIOR=function(e){return this._ior=e,this},t}(o.ExtensionProperty);m.EXTENSION_NAME="KHR_materials_ior";var I="KHR_materials_ior",C=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=I,t}s(t,e);var r=t.prototype;return r.createIOR=function(){return new m(this.doc.getGraph(),this)},r.read=function(e){var t=this;return(e.jsonDoc.json.materials||[]).forEach(function(r,o){if(r.extensions&&r.extensions[I]){var s=t.createIOR();e.materials[o].setExtension(I,s),void 0!==r.extensions[I].ior&&s.setIOR(r.extensions[I].ior)}}),this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var o=r.getExtension(I);if(o){var s=e.materialIndexMap.get(r),n=t.json.materials[s];n.extensions=n.extensions||{},n.extensions[I]={ior:o.getIOR()}}}),this},t}(o.Extension);C.EXTENSION_NAME=I;var E=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).propertyType="PBRSpecularGlossiness",t.parentTypes=[o.PropertyType.MATERIAL],t.extensionName="KHR_materials_pbrSpecularGlossiness",t._diffuseFactor=[1,1,1,1],t._specularFactor=[1,1,1],t._glossinessFactor=1,t.diffuseTexture=null,t.diffuseTextureInfo=t.graph.link("diffuseTextureInfo",n(t),new o.TextureInfo(t.graph)),t.specularGlossinessTexture=null,t.specularGlossinessTextureInfo=t.graph.link("specularGlossinessTextureInfo",n(t),new o.TextureInfo(t.graph)),t}s(t,e);var r=t.prototype;return r.copy=function(t,r){return void 0===r&&(r=o.COPY_IDENTITY),e.prototype.copy.call(this,t,r),this._diffuseFactor=t._diffuseFactor,this._specularFactor=t._specularFactor,this._glossinessFactor=t._glossinessFactor,t.diffuseTexture&&(this.setDiffuseTexture(r(t.diffuseTexture.getChild())),this.getDiffuseTextureInfo().copy(r(t.diffuseTextureInfo.getChild()),r)),t.specularGlossinessTexture&&(this.setSpecularGlossinessTexture(r(t.specularGlossinessTexture.getChild())),this.getSpecularGlossinessTextureInfo().copy(r(t.specularGlossinessTextureInfo.getChild()),r)),this},r.dispose=function(){this.diffuseTextureInfo.getChild().dispose(),this.specularGlossinessTextureInfo.getChild().dispose(),e.prototype.dispose.call(this)},r.getDiffuseFactor=function(){return this._diffuseFactor},r.setDiffuseFactor=function(e){return this._diffuseFactor=e,this},r.getDiffuseHex=function(){return o.ColorUtils.factorToHex(this._diffuseFactor)},r.setDiffuseHex=function(e){return o.ColorUtils.hexToFactor(e,this._diffuseFactor),this},r.getDiffuseTexture=function(){return this.diffuseTexture?this.diffuseTexture.getChild():null},r.getDiffuseTextureInfo=function(){return this.diffuseTexture?this.diffuseTextureInfo.getChild():null},r.setDiffuseTexture=function(e){return this.diffuseTexture=this.graph.link("diffuseTexture",this,e),this},r.getSpecularFactor=function(){return this._specularFactor},r.setSpecularFactor=function(e){return this._specularFactor=e,this},r.getGlossinessFactor=function(){return this._glossinessFactor},r.setGlossinessFactor=function(e){return this._glossinessFactor=e,this},r.getSpecularGlossinessTexture=function(){return this.specularGlossinessTexture?this.specularGlossinessTexture.getChild():null},r.getSpecularGlossinessTextureInfo=function(){return this.specularGlossinessTexture?this.specularGlossinessTextureInfo.getChild():null},r.setSpecularGlossinessTexture=function(e){return this.specularGlossinessTexture=this.graph.link("specularGlossinessTexture",this,e),this},t}(o.ExtensionProperty);E.EXTENSION_NAME="KHR_materials_pbrSpecularGlossiness",d([o.GraphChild],E.prototype,"diffuseTexture",void 0),d([o.GraphChild],E.prototype,"diffuseTextureInfo",void 0),d([o.GraphChild],E.prototype,"specularGlossinessTexture",void 0),d([o.GraphChild],E.prototype,"specularGlossinessTextureInfo",void 0);var N="KHR_materials_pbrSpecularGlossiness",R=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=N,t}s(t,e);var r=t.prototype;return r.createPBRSpecularGlossiness=function(){return new E(this.doc.getGraph(),this)},r.read=function(e){var t=this,r=e.jsonDoc,o=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,s){if(r.extensions&&r.extensions[N]){var n=t.createPBRSpecularGlossiness();if(e.materials[s].setExtension(N,n),void 0!==r.extensions[N].diffuseFactor&&n.setDiffuseFactor(r.extensions[N].diffuseFactor),void 0!==r.extensions[N].specularFactor&&n.setSpecularFactor(r.extensions[N].specularFactor),void 0!==r.extensions[N].glossinessFactor&&n.setGlossinessFactor(r.extensions[N].glossinessFactor),void 0!==r.extensions[N].diffuseTexture){var i=r.extensions[N].diffuseTexture;n.setDiffuseTexture(e.textures[o[i.index].source]),e.setTextureInfo(n.getDiffuseTextureInfo(),i)}if(void 0!==r.extensions[N].specularGlossinessTexture){var a=r.extensions[N].specularGlossinessTexture;n.setSpecularGlossinessTexture(e.textures[o[a.index].source]),e.setTextureInfo(n.getSpecularGlossinessTextureInfo(),a)}}}),this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var o=r.getExtension(N);if(o){var s=e.materialIndexMap.get(r),n=t.json.materials[s];if(n.extensions=n.extensions||{},n.extensions[N]={diffuseFactor:o.getDiffuseFactor(),specularFactor:o.getSpecularFactor(),glossinessFactor:o.getGlossinessFactor()},o.getDiffuseTexture()){var i=o.getDiffuseTexture(),a=o.getDiffuseTextureInfo();n.extensions[N].diffuseTexture=e.createTextureInfoDef(i,a)}if(o.getSpecularGlossinessTexture()){var u=o.getSpecularGlossinessTexture(),c=o.getSpecularGlossinessTextureInfo();n.extensions[N].specularGlossinessTexture=e.createTextureInfoDef(u,c)}}}),this},t}(o.Extension);R.EXTENSION_NAME=N;var F=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).propertyType="Specular",t.parentTypes=[o.PropertyType.MATERIAL],t.extensionName="KHR_materials_specular",t._specularFactor=1,t._specularColorFactor=[1,1,1],t.specularTexture=null,t.specularTextureInfo=t.graph.link("specularTextureInfo",n(t),new o.TextureInfo(t.graph)),t}s(t,e);var r=t.prototype;return r.copy=function(t,r){return void 0===r&&(r=o.COPY_IDENTITY),e.prototype.copy.call(this,t,r),this._specularFactor=t._specularFactor,t.specularTexture&&(this.setSpecularTexture(r(t.specularTexture.getChild())),this.getSpecularTextureInfo().copy(r(t.specularTextureInfo.getChild()),r)),this},r.dispose=function(){this.specularTextureInfo.getChild().dispose(),e.prototype.dispose.call(this)},r.getSpecularFactor=function(){return this._specularFactor},r.setSpecularFactor=function(e){return this._specularFactor=e,this},r.getSpecularColorFactor=function(){return this._specularColorFactor},r.setSpecularColorFactor=function(e){return this._specularColorFactor=e,this},r.getSpecularColorHex=function(){return o.ColorUtils.factorToHex(this._specularColorFactor)},r.setSpecularColorHex=function(e){return o.ColorUtils.hexToFactor(e,this._specularColorFactor),this},r.getSpecularTexture=function(){return this.specularTexture?this.specularTexture.getChild():null},r.getSpecularTextureInfo=function(){return this.specularTexture?this.specularTextureInfo.getChild():null},r.setSpecularTexture=function(e){return this.specularTexture=this.graph.link("specularTexture",this,e),this},t}(o.ExtensionProperty);F.EXTENSION_NAME="KHR_materials_specular",d([o.GraphChild],F.prototype,"specularTexture",void 0),d([o.GraphChild],F.prototype,"specularTextureInfo",void 0);var S="KHR_materials_specular",A=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=S,t}s(t,e);var r=t.prototype;return r.createSpecular=function(){return new F(this.doc.getGraph(),this)},r.read=function(e){var t=this,r=e.jsonDoc,o=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,s){if(r.extensions&&r.extensions[S]){var n=t.createSpecular();if(e.materials[s].setExtension(S,n),void 0!==r.extensions[S].specularFactor&&n.setSpecularFactor(r.extensions[S].specularFactor),void 0!==r.extensions[S].specularColorFactor&&n.setSpecularColorFactor(r.extensions[S].specularColorFactor),void 0!==r.extensions[S].specularTexture){var i=r.extensions[S].specularTexture;n.setSpecularTexture(e.textures[o[i.index].source]),e.setTextureInfo(n.getSpecularTextureInfo(),i)}}}),this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var o=r.getExtension(S);if(o){var s=e.materialIndexMap.get(r),n=t.json.materials[s];if(n.extensions=n.extensions||{},n.extensions[S]={specularFactor:o.getSpecularFactor(),specularColorFactor:o.getSpecularColorFactor()},o.getSpecularTexture()){var i=o.getSpecularTexture(),a=o.getSpecularTextureInfo();n.extensions[S].specularTexture=e.createTextureInfoDef(i,a)}}}),this},t}(o.Extension);A.EXTENSION_NAME=S;var G=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).propertyType="Transmission",t.parentTypes=[o.PropertyType.MATERIAL],t.extensionName="KHR_materials_transmission",t._transmissionFactor=0,t.transmissionTexture=null,t.transmissionTextureInfo=t.graph.link("transmissionTextureInfo",n(t),new o.TextureInfo(t.graph)),t}s(t,e);var r=t.prototype;return r.copy=function(t,r){return void 0===r&&(r=o.COPY_IDENTITY),e.prototype.copy.call(this,t,r),this._transmissionFactor=t._transmissionFactor,t.transmissionTexture&&(this.setTransmissionTexture(r(t.transmissionTexture.getChild())),this.getTransmissionTextureInfo().copy(r(t.transmissionTextureInfo.getChild()),r)),this},r.dispose=function(){this.transmissionTextureInfo.getChild().dispose(),e.prototype.dispose.call(this)},r.getTransmissionFactor=function(){return this._transmissionFactor},r.setTransmissionFactor=function(e){return this._transmissionFactor=e,this},r.getTransmissionTexture=function(){return this.transmissionTexture?this.transmissionTexture.getChild():null},r.getTransmissionTextureInfo=function(){return this.transmissionTexture?this.transmissionTextureInfo.getChild():null},r.setTransmissionTexture=function(e){return this.transmissionTexture=this.graph.link("transmissionTexture",this,e),this},t}(o.ExtensionProperty);G.EXTENSION_NAME="KHR_materials_transmission",d([o.GraphChild],G.prototype,"transmissionTexture",void 0),d([o.GraphChild],G.prototype,"transmissionTextureInfo",void 0);var D="KHR_materials_transmission",M=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=D,t}s(t,e);var r=t.prototype;return r.createTransmission=function(){return new G(this.doc.getGraph(),this)},r.read=function(e){var t=this,r=e.jsonDoc,o=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,s){if(r.extensions&&r.extensions[D]){var n=t.createTransmission();if(e.materials[s].setExtension(D,n),void 0!==r.extensions[D].transmissionFactor&&n.setTransmissionFactor(r.extensions[D].transmissionFactor),void 0!==r.extensions[D].transmissionTexture){var i=r.extensions[D].transmissionTexture;n.setTransmissionTexture(e.textures[o[i.index].source]),e.setTextureInfo(n.getTransmissionTextureInfo(),i)}}}),this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var o=r.getExtension(D);if(o){var s=e.materialIndexMap.get(r),n=t.json.materials[s];if(n.extensions=n.extensions||{},n.extensions[D]={transmissionFactor:o.getTransmissionFactor()},o.getTransmissionTexture()){var i=o.getTransmissionTexture(),a=o.getTransmissionTextureInfo();n.extensions[D].transmissionTexture=e.createTextureInfoDef(i,a)}}}),this},t}(o.Extension);M.EXTENSION_NAME=D;var O=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).propertyType="Unlit",t.parentTypes=[o.PropertyType.MATERIAL],t.extensionName="KHR_materials_unlit",t}return s(t,e),t}(o.ExtensionProperty);O.EXTENSION_NAME="KHR_materials_unlit";var j="KHR_materials_unlit",w=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=j,t}s(t,e);var r=t.prototype;return r.createUnlit=function(){return new O(this.doc.getGraph(),this)},r.read=function(e){var t=this;return(e.jsonDoc.json.materials||[]).forEach(function(r,o){r.extensions&&r.extensions[j]&&e.materials[o].setExtension(j,t.createUnlit())}),this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){if(r.getExtension(j)){var o=e.materialIndexMap.get(r),s=t.json.materials[o];s.extensions=s.extensions||{},s.extensions[j]={}}}),this},t}(o.Extension);w.EXTENSION_NAME=j;var P="KHR_mesh_quantization",b=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=P,t}s(t,e);var r=t.prototype;return r.read=function(e){return this},r.write=function(e){return this},t}(o.Extension);b.EXTENSION_NAME=P;var H="KHR_texture_basisu",K=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=H,t.provideTypes=[o.PropertyType.TEXTURE],t}s(t,e);var r=t.prototype;return r.provide=function(e){return e.jsonDoc.json.textures.forEach(function(e){e.extensions&&e.extensions[H]&&(e.source=e.extensions[H].source)}),this},r.read=function(e){return this},r.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listTextures().forEach(function(r){if("image/ktx2"===r.getMimeType()){var o=e.imageIndexMap.get(r);t.json.textures.forEach(function(e){e.source===o&&(e.extensions=e.extensions||{},e.extensions[H]={source:e.source},delete e.source)})}}),this},t}(o.Extension);K.EXTENSION_NAME=H;var U=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).propertyType="Transform",t.parentTypes=[o.PropertyType.TEXTURE_INFO],t.extensionName="KHR_texture_transform",t._offset=[0,0],t._rotation=0,t._scale=[1,1],t._texCoord=void 0,t}s(t,e);var r=t.prototype;return r.copy=function(t,r){return void 0===r&&(r=o.COPY_IDENTITY),e.prototype.copy.call(this,t,r),this._offset=t._offset,this._rotation=t._rotation,this._scale=t._scale,this._texCoord=t._texCoord,this},r.getOffset=function(){return this._offset},r.setOffset=function(e){return this._offset=e,this},r.getRotation=function(){return this._rotation},r.setRotation=function(e){return this._rotation=e,this},r.getScale=function(){return this._scale},r.setScale=function(e){return this._scale=e,this},r.getTexCoord=function(){return this._texCoord},r.setTexCoord=function(e){return this._texCoord=e,this},t}(o.ExtensionProperty);U.EXTENSION_NAME="KHR_texture_transform";var L="KHR_texture_transform",X=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=L,t}s(t,e);var r=t.prototype;return r.createTransform=function(){return new U(this.doc.getGraph(),this)},r.read=function(e){for(var t=0,r=Array.from(e.textureInfos.entries());t<r.length;t++){var o=r[t],s=o[0],n=o[1];if(n.extensions&&n.extensions[L]){var i=this.createTransform(),a=n.extensions[L];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),s.setExtension(L,i)}}return this},r.write=function(e){for(var t=0,r=Array.from(e.textureInfoDefMap.entries());t<r.length;t++){var o=r[t],s=o[1],n=o[0].getExtension(L);n&&(s.extensions=s.extensions||{},s.extensions[L]={offset:n.getOffset(),rotation:n.getRotation(),scale:n.getScale(),texCoord:n.getTexCoord()})}return this},t}(o.Extension);X.EXTENSION_NAME=L;var k=[p,g,v,C,R,A,M,w,b,K,X];exports.Clearcoat=y,exports.DracoMeshCompression=p,exports.IOR=m,exports.KHRONOS_EXTENSIONS=k,exports.Light=x,exports.LightsPunctual=g,exports.MaterialsClearcoat=v,exports.MaterialsIOR=C,exports.MaterialsPBRSpecularGlossiness=R,exports.MaterialsSpecular=A,exports.MaterialsTransmission=M,exports.MaterialsUnlit=w,exports.MeshQuantization=b,exports.PBRSpecularGlossiness=E,exports.Specular=F,exports.TextureBasisu=K,exports.TextureTransform=X,exports.Transform=U,exports.Transmission=G,exports.Unlit=O; | ||
//# sourceMappingURL=extensions.js.map |
@@ -1,2 +0,2 @@ | ||
import{Extension as e,PropertyType as t,GLB_BUFFER as s,ExtensionProperty as r,COPY_IDENTITY as o,ColorUtils as n,TextureInfo as i,GraphChild as a}from"@gltf-transform/core";let c,u,l;function h(e,t){let s;try{if(s=new c.DecoderBuffer,s.Init(new Int8Array(t),t.byteLength),e.GetEncodedGeometryType(s)!==c.TRIANGULAR_MESH)throw new Error("Unknown geometry type.");const r=new c.Mesh;if(!e.DecodeBufferToMesh(s,r).ok()||0===r.ptr)throw new Error("Decoding failure.");return r}finally{c.destroy(s)}}function x(e,t){const s=3*t.num_faces(),r=s*Uint32Array.BYTES_PER_ELEMENT,o=c._malloc(r);e.GetTrianglesUInt32Array(t,r,o);const n=new Uint32Array(c.HEAP32.buffer,o,s).slice();return c._free(o),n}function p(e,t,s,r){const o=l[r.componentType],n=u[r.componentType],i=s.num_components(),a=t.num_points()*i,h=a*n.BYTES_PER_ELEMENT,x=c._malloc(h);e.GetAttributeDataArrayForAllPoints(t,s,o,h,x);const p=new n(c.HEAPF32.buffer,x,a).slice();return c._free(x),p}const f="KHR_draco_mesh_compression";class T extends e{constructor(){super(...arguments),this.extensionName=f,this.provideTypes=[t.PRIMITIVE],this.dependencies=["draco3d.decoder"]}install(e,t){return"draco3d.decoder"===e&&(this._decoderModule=t,c=this._decoderModule,u={5126:Float32Array,5125:Uint32Array,5123:Uint16Array,5121:Uint8Array,5122:Int16Array,5120:Int8Array},l={5126:c.DT_FLOAT32,5125:c.DT_UINT32,5123:c.DT_UINT16,5121:c.DT_UINT8,5122:c.DT_INT16,5120:c.DT_INT8}),this}provide(e){if(!this._decoderModule)throw new Error('Please install extension dependency, "draco3d.decoder".');const t=this.doc.getLogger(),r=e.jsonDoc,o=new this._decoderModule.Decoder,n=new Map;for(const i of r.json.meshes){for(const a of i.primitives){if(!a.extensions||!a.extensions[f])continue;const i=a.extensions[f];let c=n.get(i.bufferView);if(!c){const e=r.json.bufferViews[i.bufferView],a=r.json.buffers[e.buffer],u=new Uint8Array(a.uri?r.resources[a.uri]:r.resources[s],e.byteOffset||0,e.byteLength);c=h(o,u),n.set(i.bufferView,c),t.debug(`Decompressed ${u.byteLength} bytes.`)}for(const t in a.attributes){const s=e.jsonDoc.json.accessors[a.attributes[t]],r=o.GetAttributeByUniqueId(c,i.attributes[t]),n=p(o,c,r,s);e.accessors[a.attributes[t]].setArray(n)}const u=x(o,c);e.accessors[a.indices].setArray(u)}this._decoderModule.destroy(o);for(const e of Array.from(n.values()))this._decoderModule.destroy(e)}return this}read(e){return this.dispose(),this}write(e){return this.doc.getLogger().warn(`Writing ${this.extensionName} not yet implemented.`),this}}var g;T.EXTENSION_NAME=f,function(e){e.POINT="point",e.SPOT="spot",e.DIRECTIONAL="directional"}(g||(g={}));class d extends r{constructor(){super(...arguments),this.propertyType="Light",this.parentTypes=[t.NODE],this.extensionName="KHR_lights_punctual",this._color=[1,1,1],this._intensity=1,this._range=void 0,this._innerConeAngle=0,this._outerConeAngle=Math.PI/4}copy(e,t=o){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 n.factorToHex(this._color)}setColorHex(e){return n.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}}d.EXTENSION_NAME="KHR_lights_punctual";const _="KHR_lights_punctual";class m extends e{constructor(){super(...arguments),this.extensionName=_}createLight(){return new d(this.doc.getGraph(),this)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions[_])return this;const s=(t.json.extensions[_].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[_]&&e.nodes[r].setExtension(_,s[t.extensions[_].light])}),this}write(e){const t=e.jsonDoc;if(0===this.properties.size)return this;const s=[],r=new Map;for(const e of this.properties){const t=e,o={type:t.getType(),color:t.getColor(),intensity:t.getIntensity(),range:t.getRange()};t.getName()&&(o.name=t.getName()),t.getType()===g.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(_);if(o){const n=e.nodeIndexMap.get(s),i=t.json.nodes[n];i.extensions=i.extensions||{},i.extensions[_]={light:r.get(o)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[_]={lights:s},this}}function I(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}m.EXTENSION_NAME=_;class C extends r{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 i(this.graph)),this.clearcoatRoughnessTexture=null,this.clearcoatRoughnessTextureInfo=this.graph.link("clearcoatRoughnessTextureInfo",this,new i(this.graph)),this.clearcoatNormalTexture=null,this.clearcoatNormalTextureInfo=this.graph.link("clearcoatNormalTextureInfo",this,new i(this.graph))}copy(e,t=o){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()))),e.clearcoatRoughnessTexture&&(this.setClearcoatRoughnessTexture(t(e.clearcoatRoughnessTexture.getChild())),this.getClearcoatRoughnessTextureInfo().copy(t(e.clearcoatRoughnessTextureInfo.getChild()))),e.clearcoatNormalTexture&&(this.setClearcoatNormalTexture(t(e.clearcoatNormalTexture.getChild())),this.getClearcoatNormalTextureInfo().copy(t(e.clearcoatNormalTextureInfo.getChild()))),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}}C.EXTENSION_NAME="KHR_materials_clearcoat",I([a],C.prototype,"clearcoatTexture",void 0),I([a],C.prototype,"clearcoatTextureInfo",void 0),I([a],C.prototype,"clearcoatRoughnessTexture",void 0),I([a],C.prototype,"clearcoatRoughnessTextureInfo",void 0),I([a],C.prototype,"clearcoatNormalTexture",void 0),I([a],C.prototype,"clearcoatNormalTextureInfo",void 0);const N="KHR_materials_clearcoat";class y extends e{constructor(){super(...arguments),this.extensionName=N}createClearcoat(){return new C(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[N]){const o=this.createClearcoat();if(e.materials[r].setExtension(N,o),void 0!==t.extensions[N].clearcoatFactor&&o.setClearcoatFactor(t.extensions[N].clearcoatFactor),void 0!==t.extensions[N].clearcoatRoughnessFactor&&o.setClearcoatRoughnessFactor(t.extensions[N].clearcoatRoughnessFactor),void 0!==t.extensions[N].clearcoatTexture){const r=t.extensions[N].clearcoatTexture;o.setClearcoatTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getClearcoatTextureInfo(),r)}if(void 0!==t.extensions[N].clearcoatRoughnessTexture){const r=t.extensions[N].clearcoatRoughnessTexture;o.setClearcoatRoughnessTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getClearcoatRoughnessTextureInfo(),r)}if(void 0!==t.extensions[N].clearcoatNormalTexture){const r=t.extensions[N].clearcoatNormalTexture;o.setClearcoatNormalTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getClearcoatNormalTextureInfo(),r),void 0!==r.scale&&o.setClearcoatNormalScale(r.scale)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(N);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[N]={clearcoatFactor:r.getClearcoatFactor(),clearcoatRoughnessFactor:r.getClearcoatRoughnessFactor()},r.getClearcoatTexture()){const t=r.getClearcoatTexture(),s=r.getClearcoatTextureInfo();n.extensions[N].clearcoatTexture=e.createTextureInfoDef(t,s)}if(r.getClearcoatRoughnessTexture()){const t=r.getClearcoatRoughnessTexture(),s=r.getClearcoatRoughnessTextureInfo();n.extensions[N].clearcoatRoughnessTexture=e.createTextureInfoDef(t,s)}if(r.getClearcoatNormalTexture()){const t=r.getClearcoatNormalTexture(),s=r.getClearcoatNormalTextureInfo();n.extensions[N].clearcoatNormalTexture=e.createTextureInfoDef(t,s),1!==r.getClearcoatNormalScale()&&(n.extensions[N].clearcoatNormalTexture.scale=r.getClearcoatNormalScale())}}}),this}}y.EXTENSION_NAME=N;class E extends r{constructor(){super(...arguments),this.propertyType="IOR",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_ior",this._ior=0}copy(e,t=o){return super.copy(e,t),this._ior=e._ior,this}getIOR(){return this._ior}setIOR(e){return this._ior=e,this}}E.EXTENSION_NAME="KHR_materials_ior";const R="KHR_materials_ior";class F extends e{constructor(){super(...arguments),this.extensionName=R}createIOR(){return new E(this.doc.getGraph(),this)}read(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{if(t.extensions&&t.extensions[R]){const r=this.createIOR();e.materials[s].setExtension(R,r),void 0!==t.extensions[R].ior&&r.setIOR(t.extensions[R].ior)}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(R);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];n.extensions=n.extensions||{},n.extensions[R]={ior:r.getIOR()}}}),this}}F.EXTENSION_NAME=R;class A extends r{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 i(this.graph)),this.specularGlossinessTexture=null,this.specularGlossinessTextureInfo=this.graph.link("specularGlossinessTextureInfo",this,new i(this.graph))}copy(e,t=o){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()))),e.specularGlossinessTexture&&(this.setSpecularGlossinessTexture(t(e.specularGlossinessTexture.getChild())),this.getSpecularGlossinessTextureInfo().copy(t(e.specularGlossinessTextureInfo.getChild()))),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 n.factorToHex(this._diffuseFactor)}setDiffuseHex(e){return n.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}}A.EXTENSION_NAME="KHR_materials_pbrSpecularGlossiness",I([a],A.prototype,"diffuseTexture",void 0),I([a],A.prototype,"diffuseTextureInfo",void 0),I([a],A.prototype,"specularGlossinessTexture",void 0),I([a],A.prototype,"specularGlossinessTextureInfo",void 0);const S="KHR_materials_pbrSpecularGlossiness";class D extends e{constructor(){super(...arguments),this.extensionName=S}createPBRSpecularGlossiness(){return new A(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[S]){const o=this.createPBRSpecularGlossiness();if(e.materials[r].setExtension(S,o),void 0!==t.extensions[S].diffuseFactor&&o.setDiffuseFactor(t.extensions[S].diffuseFactor),void 0!==t.extensions[S].specularFactor&&o.setSpecularFactor(t.extensions[S].specularFactor),void 0!==t.extensions[S].glossinessFactor&&o.setGlossinessFactor(t.extensions[S].glossinessFactor),void 0!==t.extensions[S].diffuseTexture){const r=t.extensions[S].diffuseTexture;o.setDiffuseTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getDiffuseTextureInfo(),r)}if(void 0!==t.extensions[S].specularGlossinessTexture){const r=t.extensions[S].specularGlossinessTexture;o.setSpecularGlossinessTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getSpecularGlossinessTextureInfo(),r)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(S);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[S]={diffuseFactor:r.getDiffuseFactor(),specularFactor:r.getSpecularFactor(),glossinessFactor:r.getGlossinessFactor()},r.getDiffuseTexture()){const t=r.getDiffuseTexture(),s=r.getDiffuseTextureInfo();n.extensions[S].diffuseTexture=e.createTextureInfoDef(t,s)}if(r.getSpecularGlossinessTexture()){const t=r.getSpecularGlossinessTexture(),s=r.getSpecularGlossinessTextureInfo();n.extensions[S].specularGlossinessTexture=e.createTextureInfoDef(t,s)}}}),this}}D.EXTENSION_NAME=S;class M extends r{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 i(this.graph))}copy(e,t=o){return super.copy(e,t),this._specularFactor=e._specularFactor,e.specularTexture&&(this.setSpecularTexture(t(e.specularTexture.getChild())),this.getSpecularTextureInfo().copy(t(e.specularTextureInfo.getChild()))),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 n.factorToHex(this._specularColorFactor)}setSpecularColorHex(e){return n.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}}M.EXTENSION_NAME="KHR_materials_specular",I([a],M.prototype,"specularTexture",void 0),I([a],M.prototype,"specularTextureInfo",void 0);const G="KHR_materials_specular";class j extends e{constructor(){super(...arguments),this.extensionName=G}createSpecular(){return new M(this.doc.getGraph(),this)}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,r)=>{if(t.extensions&&t.extensions[G]){const o=this.createSpecular();if(e.materials[r].setExtension(G,o),void 0!==t.extensions[G].specularFactor&&o.setSpecularFactor(t.extensions[G].specularFactor),void 0!==t.extensions[G].specularColorFactor&&o.setSpecularColorFactor(t.extensions[G].specularColorFactor),void 0!==t.extensions[G].specularTexture){const r=t.extensions[G].specularTexture;o.setSpecularTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getSpecularTextureInfo(),r)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(G);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[G]={specularFactor:r.getSpecularFactor(),specularColorFactor:r.getSpecularColorFactor()},r.getSpecularTexture()){const t=r.getSpecularTexture(),s=r.getSpecularTextureInfo();n.extensions[G].specularTexture=e.createTextureInfoDef(t,s)}}}),this}}j.EXTENSION_NAME=G;class v extends r{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 i(this.graph))}copy(e,t=o){return super.copy(e,t),this._transmissionFactor=e._transmissionFactor,e.transmissionTexture&&(this.setTransmissionTexture(t(e.transmissionTexture.getChild())),this.getTransmissionTextureInfo().copy(t(e.transmissionTextureInfo.getChild()))),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}}v.EXTENSION_NAME="KHR_materials_transmission",I([a],v.prototype,"transmissionTexture",void 0),I([a],v.prototype,"transmissionTextureInfo",void 0);const w="KHR_materials_transmission";class O extends e{constructor(){super(...arguments),this.extensionName=w}createTransmission(){return new v(this.doc.getGraph(),this)}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,r)=>{if(t.extensions&&t.extensions[w]){const o=this.createTransmission();if(e.materials[r].setExtension(w,o),void 0!==t.extensions[w].transmissionFactor&&o.setTransmissionFactor(t.extensions[w].transmissionFactor),void 0!==t.extensions[w].transmissionTexture){const r=t.extensions[w].transmissionTexture;o.setTransmissionTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getTransmissionTextureInfo(),r)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(w);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[w]={transmissionFactor:r.getTransmissionFactor()},r.getTransmissionTexture()){const t=r.getTransmissionTexture(),s=r.getTransmissionTextureInfo();n.extensions[w].transmissionTexture=e.createTextureInfoDef(t,s)}}}),this}}O.EXTENSION_NAME=w;class H extends r{constructor(){super(...arguments),this.propertyType="Unlit",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_unlit"}}H.EXTENSION_NAME="KHR_materials_unlit";const b="KHR_materials_unlit";class K extends e{constructor(){super(...arguments),this.extensionName=b}createUnlit(){return new H(this.doc.getGraph(),this)}read(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{t.extensions&&t.extensions[b]&&e.materials[s].setExtension(b,this.createUnlit())}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{if(s.getExtension(b)){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{},o.extensions[b]={}}}),this}}K.EXTENSION_NAME=b;const X="KHR_mesh_quantization";class L extends e{constructor(){super(...arguments),this.extensionName=X}read(e){return this}write(e){return this}}L.EXTENSION_NAME=X;const U="KHR_texture_basisu";class k extends e{constructor(){super(...arguments),this.extensionName=U,this.provideTypes=[t.TEXTURE]}provide(e){return e.jsonDoc.json.textures.forEach(e=>{e.extensions&&e.extensions[U]&&(e.source=e.extensions[U].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[U]={source:e.source},delete e.source)})}}),this}}k.EXTENSION_NAME=U;class P extends r{constructor(){super(...arguments),this.propertyType="Transform",this.parentTypes=[t.TEXTURE_INFO],this.extensionName="KHR_texture_transform",this._offset=[0,0],this._rotation=0,this._scale=[1,1],this._texCoord=void 0}copy(e,t=o){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}}P.EXTENSION_NAME="KHR_texture_transform";const B="KHR_texture_transform";class V extends e{constructor(){super(...arguments),this.extensionName=B}createTransform(){return new P(this.doc.getGraph(),this)}read(e){for(const[t,s]of Array.from(e.textureInfos.entries())){if(!s.extensions||!s.extensions[B])continue;const e=this.createTransform(),r=s.extensions[B];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(B,e)}return this}write(e){const t=Array.from(e.textureInfoDefMap.entries());for(const[e,s]of t){const t=e.getExtension(B);t&&(s.extensions=s.extensions||{},s.extensions[B]={offset:t.getOffset(),rotation:t.getRotation(),scale:t.getScale(),texCoord:t.getTexCoord()})}return this}}V.EXTENSION_NAME=B;const q=[T,m,y,F,D,j,O,K,L,k,V];export{C as Clearcoat,T as DracoMeshCompression,E as IOR,q as KHRONOS_EXTENSIONS,d as Light,g as LightType,m as LightsPunctual,y as MaterialsClearcoat,F as MaterialsIOR,D as MaterialsPBRSpecularGlossiness,j as MaterialsSpecular,O as MaterialsTransmission,K as MaterialsUnlit,L as MeshQuantization,A as PBRSpecularGlossiness,M as Specular,k as TextureBasisu,V as TextureTransform,P as Transform,v as Transmission,H as Unlit}; | ||
import{Extension as e,PropertyType as t,GLB_BUFFER as s,ExtensionProperty as r,COPY_IDENTITY as o,ColorUtils as n,TextureInfo as i,GraphChild as a}from"@gltf-transform/core";let c,u,l;function h(e,t){let s;try{if(s=new c.DecoderBuffer,s.Init(new Int8Array(t),t.byteLength),e.GetEncodedGeometryType(s)!==c.TRIANGULAR_MESH)throw new Error("Unknown geometry type.");const r=new c.Mesh;if(!e.DecodeBufferToMesh(s,r).ok()||0===r.ptr)throw new Error("Decoding failure.");return r}finally{c.destroy(s)}}function x(e,t){const s=3*t.num_faces(),r=s*Uint32Array.BYTES_PER_ELEMENT,o=c._malloc(r);e.GetTrianglesUInt32Array(t,r,o);const n=new Uint32Array(c.HEAP32.buffer,o,s).slice();return c._free(o),n}function p(e,t,s,r){const o=l[r.componentType],n=u[r.componentType],i=s.num_components(),a=t.num_points()*i,h=a*n.BYTES_PER_ELEMENT,x=c._malloc(h);e.GetAttributeDataArrayForAllPoints(t,s,o,h,x);const p=new n(c.HEAPF32.buffer,x,a).slice();return c._free(x),p}const f="KHR_draco_mesh_compression";class T extends e{constructor(){super(...arguments),this.extensionName=f,this.provideTypes=[t.PRIMITIVE],this.dependencies=["draco3d.decoder"]}install(e,t){return"draco3d.decoder"===e&&(this._decoderModule=t,c=this._decoderModule,u={5126:Float32Array,5125:Uint32Array,5123:Uint16Array,5121:Uint8Array,5122:Int16Array,5120:Int8Array},l={5126:c.DT_FLOAT32,5125:c.DT_UINT32,5123:c.DT_UINT16,5121:c.DT_UINT8,5122:c.DT_INT16,5120:c.DT_INT8}),this}provide(e){if(!this._decoderModule)throw new Error('Please install extension dependency, "draco3d.decoder".');const t=this.doc.getLogger(),r=e.jsonDoc,o=new this._decoderModule.Decoder,n=new Map;for(const i of r.json.meshes){for(const a of i.primitives){if(!a.extensions||!a.extensions[f])continue;const i=a.extensions[f];let c=n.get(i.bufferView);if(!c){const e=r.json.bufferViews[i.bufferView],a=r.json.buffers[e.buffer],u=new Uint8Array(a.uri?r.resources[a.uri]:r.resources[s],e.byteOffset||0,e.byteLength);c=h(o,u),n.set(i.bufferView,c),t.debug(`Decompressed ${u.byteLength} bytes.`)}for(const t in a.attributes){const s=e.jsonDoc.json.accessors[a.attributes[t]],r=o.GetAttributeByUniqueId(c,i.attributes[t]),n=p(o,c,r,s);e.accessors[a.attributes[t]].setArray(n)}const u=x(o,c);e.accessors[a.indices].setArray(u)}this._decoderModule.destroy(o);for(const e of Array.from(n.values()))this._decoderModule.destroy(e)}return this}read(e){return this.dispose(),this}write(e){return this.doc.getLogger().warn(`Writing ${this.extensionName} not yet implemented.`),this}}var g;T.EXTENSION_NAME=f,function(e){e.POINT="point",e.SPOT="spot",e.DIRECTIONAL="directional"}(g||(g={}));class d extends r{constructor(){super(...arguments),this.propertyType="Light",this.parentTypes=[t.NODE],this.extensionName="KHR_lights_punctual",this._color=[1,1,1],this._intensity=1,this._range=void 0,this._innerConeAngle=0,this._outerConeAngle=Math.PI/4}copy(e,t=o){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 n.factorToHex(this._color)}setColorHex(e){return n.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}}d.EXTENSION_NAME="KHR_lights_punctual";const _="KHR_lights_punctual";class m extends e{constructor(){super(...arguments),this.extensionName=_}createLight(){return new d(this.doc.getGraph(),this)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions[_])return this;const s=(t.json.extensions[_].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[_]&&e.nodes[r].setExtension(_,s[t.extensions[_].light])}),this}write(e){const t=e.jsonDoc;if(0===this.properties.size)return this;const s=[],r=new Map;for(const e of this.properties){const t=e,o={type:t.getType(),color:t.getColor(),intensity:t.getIntensity(),range:t.getRange()};t.getName()&&(o.name=t.getName()),t.getType()===g.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(_);if(o){const n=e.nodeIndexMap.get(s),i=t.json.nodes[n];i.extensions=i.extensions||{},i.extensions[_]={light:r.get(o)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[_]={lights:s},this}}function I(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}m.EXTENSION_NAME=_;class C extends r{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 i(this.graph)),this.clearcoatRoughnessTexture=null,this.clearcoatRoughnessTextureInfo=this.graph.link("clearcoatRoughnessTextureInfo",this,new i(this.graph)),this.clearcoatNormalTexture=null,this.clearcoatNormalTextureInfo=this.graph.link("clearcoatNormalTextureInfo",this,new i(this.graph))}copy(e,t=o){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}}C.EXTENSION_NAME="KHR_materials_clearcoat",I([a],C.prototype,"clearcoatTexture",void 0),I([a],C.prototype,"clearcoatTextureInfo",void 0),I([a],C.prototype,"clearcoatRoughnessTexture",void 0),I([a],C.prototype,"clearcoatRoughnessTextureInfo",void 0),I([a],C.prototype,"clearcoatNormalTexture",void 0),I([a],C.prototype,"clearcoatNormalTextureInfo",void 0);const N="KHR_materials_clearcoat";class y extends e{constructor(){super(...arguments),this.extensionName=N}createClearcoat(){return new C(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[N]){const o=this.createClearcoat();if(e.materials[r].setExtension(N,o),void 0!==t.extensions[N].clearcoatFactor&&o.setClearcoatFactor(t.extensions[N].clearcoatFactor),void 0!==t.extensions[N].clearcoatRoughnessFactor&&o.setClearcoatRoughnessFactor(t.extensions[N].clearcoatRoughnessFactor),void 0!==t.extensions[N].clearcoatTexture){const r=t.extensions[N].clearcoatTexture;o.setClearcoatTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getClearcoatTextureInfo(),r)}if(void 0!==t.extensions[N].clearcoatRoughnessTexture){const r=t.extensions[N].clearcoatRoughnessTexture;o.setClearcoatRoughnessTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getClearcoatRoughnessTextureInfo(),r)}if(void 0!==t.extensions[N].clearcoatNormalTexture){const r=t.extensions[N].clearcoatNormalTexture;o.setClearcoatNormalTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getClearcoatNormalTextureInfo(),r),void 0!==r.scale&&o.setClearcoatNormalScale(r.scale)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(N);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[N]={clearcoatFactor:r.getClearcoatFactor(),clearcoatRoughnessFactor:r.getClearcoatRoughnessFactor()},r.getClearcoatTexture()){const t=r.getClearcoatTexture(),s=r.getClearcoatTextureInfo();n.extensions[N].clearcoatTexture=e.createTextureInfoDef(t,s)}if(r.getClearcoatRoughnessTexture()){const t=r.getClearcoatRoughnessTexture(),s=r.getClearcoatRoughnessTextureInfo();n.extensions[N].clearcoatRoughnessTexture=e.createTextureInfoDef(t,s)}if(r.getClearcoatNormalTexture()){const t=r.getClearcoatNormalTexture(),s=r.getClearcoatNormalTextureInfo();n.extensions[N].clearcoatNormalTexture=e.createTextureInfoDef(t,s),1!==r.getClearcoatNormalScale()&&(n.extensions[N].clearcoatNormalTexture.scale=r.getClearcoatNormalScale())}}}),this}}y.EXTENSION_NAME=N;class E extends r{constructor(){super(...arguments),this.propertyType="IOR",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_ior",this._ior=0}copy(e,t=o){return super.copy(e,t),this._ior=e._ior,this}getIOR(){return this._ior}setIOR(e){return this._ior=e,this}}E.EXTENSION_NAME="KHR_materials_ior";const R="KHR_materials_ior";class F extends e{constructor(){super(...arguments),this.extensionName=R}createIOR(){return new E(this.doc.getGraph(),this)}read(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{if(t.extensions&&t.extensions[R]){const r=this.createIOR();e.materials[s].setExtension(R,r),void 0!==t.extensions[R].ior&&r.setIOR(t.extensions[R].ior)}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(R);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];n.extensions=n.extensions||{},n.extensions[R]={ior:r.getIOR()}}}),this}}F.EXTENSION_NAME=R;class A extends r{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 i(this.graph)),this.specularGlossinessTexture=null,this.specularGlossinessTextureInfo=this.graph.link("specularGlossinessTextureInfo",this,new i(this.graph))}copy(e,t=o){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 n.factorToHex(this._diffuseFactor)}setDiffuseHex(e){return n.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}}A.EXTENSION_NAME="KHR_materials_pbrSpecularGlossiness",I([a],A.prototype,"diffuseTexture",void 0),I([a],A.prototype,"diffuseTextureInfo",void 0),I([a],A.prototype,"specularGlossinessTexture",void 0),I([a],A.prototype,"specularGlossinessTextureInfo",void 0);const S="KHR_materials_pbrSpecularGlossiness";class D extends e{constructor(){super(...arguments),this.extensionName=S}createPBRSpecularGlossiness(){return new A(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[S]){const o=this.createPBRSpecularGlossiness();if(e.materials[r].setExtension(S,o),void 0!==t.extensions[S].diffuseFactor&&o.setDiffuseFactor(t.extensions[S].diffuseFactor),void 0!==t.extensions[S].specularFactor&&o.setSpecularFactor(t.extensions[S].specularFactor),void 0!==t.extensions[S].glossinessFactor&&o.setGlossinessFactor(t.extensions[S].glossinessFactor),void 0!==t.extensions[S].diffuseTexture){const r=t.extensions[S].diffuseTexture;o.setDiffuseTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getDiffuseTextureInfo(),r)}if(void 0!==t.extensions[S].specularGlossinessTexture){const r=t.extensions[S].specularGlossinessTexture;o.setSpecularGlossinessTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getSpecularGlossinessTextureInfo(),r)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(S);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[S]={diffuseFactor:r.getDiffuseFactor(),specularFactor:r.getSpecularFactor(),glossinessFactor:r.getGlossinessFactor()},r.getDiffuseTexture()){const t=r.getDiffuseTexture(),s=r.getDiffuseTextureInfo();n.extensions[S].diffuseTexture=e.createTextureInfoDef(t,s)}if(r.getSpecularGlossinessTexture()){const t=r.getSpecularGlossinessTexture(),s=r.getSpecularGlossinessTextureInfo();n.extensions[S].specularGlossinessTexture=e.createTextureInfoDef(t,s)}}}),this}}D.EXTENSION_NAME=S;class M extends r{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 i(this.graph))}copy(e,t=o){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 n.factorToHex(this._specularColorFactor)}setSpecularColorHex(e){return n.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}}M.EXTENSION_NAME="KHR_materials_specular",I([a],M.prototype,"specularTexture",void 0),I([a],M.prototype,"specularTextureInfo",void 0);const G="KHR_materials_specular";class j extends e{constructor(){super(...arguments),this.extensionName=G}createSpecular(){return new M(this.doc.getGraph(),this)}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,r)=>{if(t.extensions&&t.extensions[G]){const o=this.createSpecular();if(e.materials[r].setExtension(G,o),void 0!==t.extensions[G].specularFactor&&o.setSpecularFactor(t.extensions[G].specularFactor),void 0!==t.extensions[G].specularColorFactor&&o.setSpecularColorFactor(t.extensions[G].specularColorFactor),void 0!==t.extensions[G].specularTexture){const r=t.extensions[G].specularTexture;o.setSpecularTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getSpecularTextureInfo(),r)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(G);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[G]={specularFactor:r.getSpecularFactor(),specularColorFactor:r.getSpecularColorFactor()},r.getSpecularTexture()){const t=r.getSpecularTexture(),s=r.getSpecularTextureInfo();n.extensions[G].specularTexture=e.createTextureInfoDef(t,s)}}}),this}}j.EXTENSION_NAME=G;class v extends r{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 i(this.graph))}copy(e,t=o){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}}v.EXTENSION_NAME="KHR_materials_transmission",I([a],v.prototype,"transmissionTexture",void 0),I([a],v.prototype,"transmissionTextureInfo",void 0);const w="KHR_materials_transmission";class O extends e{constructor(){super(...arguments),this.extensionName=w}createTransmission(){return new v(this.doc.getGraph(),this)}read(e){const t=e.jsonDoc,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,r)=>{if(t.extensions&&t.extensions[w]){const o=this.createTransmission();if(e.materials[r].setExtension(w,o),void 0!==t.extensions[w].transmissionFactor&&o.setTransmissionFactor(t.extensions[w].transmissionFactor),void 0!==t.extensions[w].transmissionTexture){const r=t.extensions[w].transmissionTexture;o.setTransmissionTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getTransmissionTextureInfo(),r)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(w);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[w]={transmissionFactor:r.getTransmissionFactor()},r.getTransmissionTexture()){const t=r.getTransmissionTexture(),s=r.getTransmissionTextureInfo();n.extensions[w].transmissionTexture=e.createTextureInfoDef(t,s)}}}),this}}O.EXTENSION_NAME=w;class H extends r{constructor(){super(...arguments),this.propertyType="Unlit",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_unlit"}}H.EXTENSION_NAME="KHR_materials_unlit";const b="KHR_materials_unlit";class K extends e{constructor(){super(...arguments),this.extensionName=b}createUnlit(){return new H(this.doc.getGraph(),this)}read(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{t.extensions&&t.extensions[b]&&e.materials[s].setExtension(b,this.createUnlit())}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{if(s.getExtension(b)){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{},o.extensions[b]={}}}),this}}K.EXTENSION_NAME=b;const X="KHR_mesh_quantization";class L extends e{constructor(){super(...arguments),this.extensionName=X}read(e){return this}write(e){return this}}L.EXTENSION_NAME=X;const U="KHR_texture_basisu";class k extends e{constructor(){super(...arguments),this.extensionName=U,this.provideTypes=[t.TEXTURE]}provide(e){return e.jsonDoc.json.textures.forEach(e=>{e.extensions&&e.extensions[U]&&(e.source=e.extensions[U].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[U]={source:e.source},delete e.source)})}}),this}}k.EXTENSION_NAME=U;class P extends r{constructor(){super(...arguments),this.propertyType="Transform",this.parentTypes=[t.TEXTURE_INFO],this.extensionName="KHR_texture_transform",this._offset=[0,0],this._rotation=0,this._scale=[1,1],this._texCoord=void 0}copy(e,t=o){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}}P.EXTENSION_NAME="KHR_texture_transform";const B="KHR_texture_transform";class V extends e{constructor(){super(...arguments),this.extensionName=B}createTransform(){return new P(this.doc.getGraph(),this)}read(e){for(const[t,s]of Array.from(e.textureInfos.entries())){if(!s.extensions||!s.extensions[B])continue;const e=this.createTransform(),r=s.extensions[B];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(B,e)}return this}write(e){const t=Array.from(e.textureInfoDefMap.entries());for(const[e,s]of t){const t=e.getExtension(B);t&&(s.extensions=s.extensions||{},s.extensions[B]={offset:t.getOffset(),rotation:t.getRotation(),scale:t.getScale(),texCoord:t.getTexCoord()})}return this}}V.EXTENSION_NAME=B;const q=[T,m,y,F,D,j,O,K,L,k,V];export{C as Clearcoat,T as DracoMeshCompression,E as IOR,q as KHRONOS_EXTENSIONS,d as Light,g as LightType,m as LightsPunctual,y as MaterialsClearcoat,F as MaterialsIOR,D as MaterialsPBRSpecularGlossiness,j as MaterialsSpecular,O as MaterialsTransmission,K as MaterialsUnlit,L as MeshQuantization,A as PBRSpecularGlossiness,M as Specular,k as TextureBasisu,V as TextureTransform,P as Transform,v as Transmission,H as Unlit}; | ||
//# sourceMappingURL=extensions.modern.js.map |
{ | ||
"name": "@gltf-transform/extensions", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"repository": "github:donmccurdy/glTF-Transform", | ||
@@ -24,3 +24,3 @@ "description": "Adds extension support to @gltf-transform/core", | ||
"dependencies": { | ||
"@gltf-transform/core": "^0.7.1" | ||
"@gltf-transform/core": "^0.7.2" | ||
}, | ||
@@ -33,3 +33,3 @@ "files": [ | ||
], | ||
"gitHead": "6d8429266bc58b1956a0b010c13f490562d164ba" | ||
"gitHead": "69fdd465707cb428d34dcc940a31c2cfebd54a32" | ||
} |
@@ -36,11 +36,11 @@ import { COPY_IDENTITY, ExtensionProperty, GraphChild, Link, PropertyType, Texture, TextureInfo } from '@gltf-transform/core'; | ||
this.setClearcoatTexture(resolve(other.clearcoatTexture.getChild())); | ||
this.getClearcoatTextureInfo().copy(resolve(other.clearcoatTextureInfo.getChild())); | ||
this.getClearcoatTextureInfo().copy(resolve(other.clearcoatTextureInfo.getChild()), resolve); | ||
} | ||
if (other.clearcoatRoughnessTexture) { | ||
this.setClearcoatRoughnessTexture(resolve(other.clearcoatRoughnessTexture.getChild())); | ||
this.getClearcoatRoughnessTextureInfo().copy(resolve(other.clearcoatRoughnessTextureInfo.getChild())); | ||
this.getClearcoatRoughnessTextureInfo().copy(resolve(other.clearcoatRoughnessTextureInfo.getChild()), resolve); | ||
} | ||
if (other.clearcoatNormalTexture) { | ||
this.setClearcoatNormalTexture(resolve(other.clearcoatNormalTexture.getChild())); | ||
this.getClearcoatNormalTextureInfo().copy(resolve(other.clearcoatNormalTextureInfo.getChild())); | ||
this.getClearcoatNormalTextureInfo().copy(resolve(other.clearcoatNormalTextureInfo.getChild()), resolve); | ||
} | ||
@@ -47,0 +47,0 @@ |
@@ -32,7 +32,7 @@ import { COPY_IDENTITY, ColorUtils, ExtensionProperty, GraphChild, Link, PropertyType, Texture, TextureInfo, vec3, vec4 } from '@gltf-transform/core'; | ||
this.setDiffuseTexture(resolve(other.diffuseTexture.getChild())); | ||
this.getDiffuseTextureInfo().copy(resolve(other.diffuseTextureInfo.getChild())); | ||
this.getDiffuseTextureInfo().copy(resolve(other.diffuseTextureInfo.getChild()), resolve); | ||
} | ||
if (other.specularGlossinessTexture) { | ||
this.setSpecularGlossinessTexture(resolve(other.specularGlossinessTexture.getChild())); | ||
this.getSpecularGlossinessTextureInfo().copy(resolve(other.specularGlossinessTextureInfo.getChild())); | ||
this.getSpecularGlossinessTextureInfo().copy(resolve(other.specularGlossinessTextureInfo.getChild()), resolve); | ||
} | ||
@@ -39,0 +39,0 @@ |
@@ -25,3 +25,3 @@ import { COPY_IDENTITY, ColorUtils, ExtensionProperty, GraphChild, Link, PropertyType, Texture, TextureInfo, vec3 } from '@gltf-transform/core'; | ||
this.setSpecularTexture(resolve(other.specularTexture.getChild())); | ||
this.getSpecularTextureInfo().copy(resolve(other.specularTextureInfo.getChild())); | ||
this.getSpecularTextureInfo().copy(resolve(other.specularTextureInfo.getChild()), resolve); | ||
} | ||
@@ -28,0 +28,0 @@ |
@@ -24,3 +24,3 @@ import { COPY_IDENTITY, ExtensionProperty, GraphChild, Link, PropertyType, Texture, TextureInfo } from '@gltf-transform/core'; | ||
this.setTransmissionTexture(resolve(other.transmissionTexture.getChild())); | ||
this.getTransmissionTextureInfo().copy(resolve(other.transmissionTextureInfo.getChild())); | ||
this.getTransmissionTextureInfo().copy(resolve(other.transmissionTextureInfo.getChild()), resolve); | ||
} | ||
@@ -27,0 +27,0 @@ |
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
486205
Updated@gltf-transform/core@^0.7.2