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

@gltf-transform/extensions

Package Overview
Dependencies
Maintainers
1
Versions
193
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gltf-transform/extensions - npm Package Compare versions

Comparing version 0.7.0-alpha.1 to 0.7.0-alpha.2

dist/extensions/src/khr-draco-mesh-compression/decoder.d.ts

2

dist/core/src/core.d.ts

@@ -7,2 +7,2 @@ export { Document, Transform } from './document';

export { BufferUtils, ColorUtils, FileUtils, ImageUtils, MathUtils, Logger, uuid } from './utils/';
export { PropertyType, vec2, vec3, vec4, mat3, mat4 } from './constants';
export { TypedArray, PropertyType, vec2, vec3, vec4, mat3, mat4, GLB_BUFFER } from './constants';

@@ -46,2 +46,4 @@ import { PropertyType } from './constants';

readonly provideTypes: PropertyType[];
/** Dependency IDs needed by this extension, to be installed before I/O. */
readonly dependencies: string[];
protected required: boolean;

@@ -75,2 +77,4 @@ protected properties: Set<ExtensionProperty>;

*/
/** Installs dependencies required by the extension. */
install(key: string, dependency: unknown): this;
/**

@@ -77,0 +81,0 @@ * Used by the {@link PlatformIO} utilities when reading a glTF asset. This method may

@@ -22,2 +22,5 @@ import { Document } from '../document';

protected _extensions: typeof Extension[];
protected _dependencies: {
[key: string]: unknown;
};
/** Sets the {@link Logger} used by this I/O instance. Defaults to Logger.DEFAULT_INSTANCE. */

@@ -27,2 +30,6 @@ setLogger(logger: Logger): this;

registerExtensions(extensions: typeof Extension[]): this;
/** Registers dependencies used (e.g. by extensions) in the I/O process. */
registerDependencies(dependencies: {
[key: string]: unknown;
}): this;
/**********************************************************************************************

@@ -29,0 +36,0 @@ * JSON.

@@ -7,3 +7,6 @@ import { Document } from '../document';

logger?: Logger;
extensions?: (typeof Extension)[];
extensions: (typeof Extension)[];
dependencies: {
[key: string]: unknown;
};
}

@@ -10,0 +13,0 @@ /** @hidden */

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

var e,t=require("@gltf-transform/core");function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}(e=exports.LightType||(exports.LightType={})).POINT="point",e.SPOT="spot",e.DIRECTIONAL="directional";var n=function(e){function s(){var r;return(r=e.apply(this,arguments)||this).propertyType="Light",r.parentTypes=[t.PropertyType.NODE],r.extensionName="KHR_lights_punctual",r._color=[1,1,1],r._intensity=1,r._range=void 0,r._innerConeAngle=0,r._outerConeAngle=Math.PI/4,r}r(s,e);var n=s.prototype;return n.copy=function(r,s){return void 0===s&&(s=t.COPY_IDENTITY),e.prototype.copy.call(this,r,s),this._color=[].concat(r._color),this._intensity=r._intensity,this._type=r._type,this._range=r._range,this._innerConeAngle=r._innerConeAngle,this._outerConeAngle=r._outerConeAngle,this},n.getColor=function(){return this._color},n.setColor=function(e){return this._color=e,this},n.getColorHex=function(){return t.ColorUtils.factorToHex(this._color)},n.setColorHex=function(e){return t.ColorUtils.hexToFactor(e,this._color),this},n.getIntensity=function(){return this._intensity},n.setIntensity=function(e){return this._intensity=e,this},n.getType=function(){return this._type},n.setType=function(e){return this._type=e,this},n.getRange=function(){return this._range},n.setRange=function(e){return this._range=e,this},n.getInnerConeAngle=function(){return this._innerConeAngle},n.setInnerConeAngle=function(e){return this._innerConeAngle=e,this},n.getOuterConeAngle=function(){return this._outerConeAngle},n.setOuterConeAngle=function(e){return this._outerConeAngle=e,this},s}(t.ExtensionProperty);n.EXTENSION_NAME="KHR_lights_punctual";var o="KHR_lights_punctual",i=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=o,t}r(t,e);var i=t.prototype;return i.createLight=function(){return new n(this.doc.getGraph(),this)},i.read=function(e){var t=this,r=e.jsonDoc;if(!r.json.extensions||!r.json.extensions[o])return this;var s=(r.json.extensions[o].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[o]&&e.nodes[r].setExtension(o,s[t.extensions[o].light])}),this},i.write=function(e){var t=e.jsonDoc;if(0===this.properties.size)return this;for(var r,n=[],i=new Map,a=function(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 s(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)?s(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)}(this.properties);!(r=a()).done;){var u=r.value,c={type:u.getType(),color:u.getColor(),intensity:u.getIntensity(),range:u.getRange()};u.getName()&&(c.name=u.getName()),u.getType()===exports.LightType.SPOT&&(c.innerConeAngle=u.getInnerConeAngle(),c.outerConeAngle=u.getOuterConeAngle()),n.push(c),i.set(u,n.length-1)}return this.doc.getRoot().listNodes().forEach(function(r){var s=r.getExtension(o);if(s){var n=e.nodeIndexMap.get(r),a=t.json.nodes[n];a.extensions=a.extensions||{},a.extensions[o]={light:i.get(s)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[o]={lights:n},this},t}(t.Extension);function a(e,t,r,s){var n,o=arguments.length,i=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i}i.EXTENSION_NAME=o;var u=function(e){function s(){var r;return(r=e.apply(this,arguments)||this).propertyType="Clearcoat",r.parentTypes=[t.PropertyType.MATERIAL],r.extensionName="KHR_materials_clearcoat",r._clearcoatFactor=0,r._clearcoatRoughnessFactor=0,r._clearcoatNormalScale=1,r.clearcoatTexture=null,r.clearcoatRoughnessTexture=null,r.clearcoatNormalTexture=null,r}r(s,e);var n=s.prototype;return n.copy=function(r,s){return void 0===s&&(s=t.COPY_IDENTITY),e.prototype.copy.call(this,r,s),this._clearcoatFactor=r._clearcoatFactor,this._clearcoatRoughnessFactor=r._clearcoatRoughnessFactor,this._clearcoatNormalScale=r._clearcoatNormalScale,r.clearcoatTexture&&(this.setClearcoatTexture(s(r.clearcoatTexture.getChild())),this.clearcoatTexture.copy(r.clearcoatTexture)),r.clearcoatRoughnessTexture&&(this.setClearcoatRoughnessTexture(s(r.clearcoatRoughnessTexture.getChild())),this.clearcoatRoughnessTexture.copy(r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture&&(this.setClearcoatNormalTexture(s(r.clearcoatNormalTexture.getChild())),this.clearcoatNormalTexture.copy(r.clearcoatNormalTexture)),this},n.getClearcoatFactor=function(){return this._clearcoatFactor},n.setClearcoatFactor=function(e){return this._clearcoatFactor=e,this},n.getClearcoatTexture=function(){return this.clearcoatTexture?this.clearcoatTexture.getChild():null},n.getClearcoatTextureInfo=function(){return this.clearcoatTexture?this.clearcoatTexture.textureInfo:null},n.getClearcoatTextureSampler=function(){return this.clearcoatTexture?this.clearcoatTexture.sampler:null},n.setClearcoatTexture=function(e){return this.clearcoatTexture=this.graph.linkTexture("clearcoatTexture",this,e),this},n.getClearcoatRoughnessFactor=function(){return this._clearcoatRoughnessFactor},n.setClearcoatRoughnessFactor=function(e){return this._clearcoatRoughnessFactor=e,this},n.getClearcoatRoughnessTexture=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.getChild():null},n.getClearcoatRoughnessTextureInfo=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.textureInfo:null},n.getClearcoatRoughnessTextureSampler=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.sampler:null},n.setClearcoatRoughnessTexture=function(e){return this.clearcoatRoughnessTexture=this.graph.linkTexture("clearcoatRoughnessTexture",this,e),this},n.getClearcoatNormalScale=function(){return this._clearcoatNormalScale},n.setClearcoatNormalScale=function(e){return this._clearcoatNormalScale=e,this},n.getClearcoatNormalTexture=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTexture.getChild():null},n.getClearcoatNormalTextureInfo=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTexture.textureInfo:null},n.getClearcoatNormalTextureSampler=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTexture.sampler:null},n.setClearcoatNormalTexture=function(e){return this.clearcoatNormalTexture=this.graph.linkTexture("clearcoatNormalTexture",this,e),this},s}(t.ExtensionProperty);u.EXTENSION_NAME="KHR_materials_clearcoat",a([t.GraphChild],u.prototype,"clearcoatTexture",void 0),a([t.GraphChild],u.prototype,"clearcoatRoughnessTexture",void 0),a([t.GraphChild],u.prototype,"clearcoatNormalTexture",void 0);var c="KHR_materials_clearcoat",l=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=c,t}r(t,e);var s=t.prototype;return s.createClearcoat=function(){return new u(this.doc.getGraph(),this)},s.read=function(e){var t=this,r=e.jsonDoc,s=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,n){if(r.extensions&&r.extensions[c]){var o=t.createClearcoat();if(e.materials[n].setExtension(c,o),void 0!==r.extensions[c].clearcoatFactor&&o.setClearcoatFactor(r.extensions[c].clearcoatFactor),void 0!==r.extensions[c].clearcoatRoughnessFactor&&o.setClearcoatRoughnessFactor(r.extensions[c].clearcoatRoughnessFactor),void 0!==r.extensions[c].clearcoatTexture){var i=r.extensions[c].clearcoatTexture;o.setClearcoatTexture(e.textures[s[i.index].source]),e.setTextureInfo(o.getClearcoatTextureInfo(),i),e.setTextureSampler(o.getClearcoatTextureSampler(),i)}if(void 0!==r.extensions[c].clearcoatRoughnessTexture){var a=r.extensions[c].clearcoatRoughnessTexture;o.setClearcoatRoughnessTexture(e.textures[s[a.index].source]),e.setTextureInfo(o.getClearcoatRoughnessTextureInfo(),a),e.setTextureSampler(o.getClearcoatRoughnessTextureSampler(),a)}if(void 0!==r.extensions[c].clearcoatNormalTexture){var u=r.extensions[c].clearcoatNormalTexture;o.setClearcoatNormalTexture(e.textures[s[u.index].source]),e.setTextureInfo(o.getClearcoatNormalTextureInfo(),u),e.setTextureSampler(o.getClearcoatNormalTextureSampler(),u),void 0!==u.scale&&o.setClearcoatNormalScale(u.scale)}}}),this},s.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var s=r.getExtension(c);if(s){var n=e.materialIndexMap.get(r),o=t.json.materials[n];if(o.extensions=o.extensions||{},o.extensions[c]={clearcoatFactor:s.getClearcoatFactor(),clearcoatRoughnessFactor:s.getClearcoatRoughnessFactor()},s.getClearcoatTexture()){var i=s.getClearcoatTexture(),a=s.getClearcoatTextureInfo(),u=s.getClearcoatTextureSampler();o.extensions[c].clearcoatTexture=e.createTextureInfoDef(i,a,u)}if(s.getClearcoatRoughnessTexture()){var l=s.getClearcoatRoughnessTexture(),x=s.getClearcoatRoughnessTextureInfo(),p=s.getClearcoatRoughnessTextureSampler();o.extensions[c].clearcoatRoughnessTexture=e.createTextureInfoDef(l,x,p)}if(s.getClearcoatNormalTexture()){var h=s.getClearcoatNormalTexture(),f=s.getClearcoatNormalTextureInfo(),T=s.getClearcoatNormalTextureSampler();o.extensions[c].clearcoatNormalTexture=e.createTextureInfoDef(h,f,T),1!==s.getClearcoatNormalScale()&&(o.extensions[c].clearcoatNormalTexture.scale=s.getClearcoatNormalScale())}}}),this},t}(t.Extension);l.EXTENSION_NAME=c;var x=function(e){function s(){var r;return(r=e.apply(this,arguments)||this).propertyType="IOR",r.parentTypes=[t.PropertyType.MATERIAL],r.extensionName="KHR_materials_ior",r._ior=0,r}r(s,e);var n=s.prototype;return n.copy=function(r,s){return void 0===s&&(s=t.COPY_IDENTITY),e.prototype.copy.call(this,r,s),this._ior=r._ior,this},n.getIOR=function(){return this._ior},n.setIOR=function(e){return this._ior=e,this},s}(t.ExtensionProperty);x.EXTENSION_NAME="KHR_materials_ior";var p="KHR_materials_ior",h=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=p,t}r(t,e);var s=t.prototype;return s.createIOR=function(){return new x(this.doc.getGraph(),this)},s.read=function(e){var t=this;return(e.jsonDoc.json.materials||[]).forEach(function(r,s){if(r.extensions&&r.extensions[p]){var n=t.createIOR();e.materials[s].setExtension(p,n),void 0!==r.extensions[p].ior&&n.setIOR(r.extensions[p].ior)}}),this},s.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var s=r.getExtension(p);if(s){var n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{},o.extensions[p]={ior:s.getIOR()}}}),this},t}(t.Extension);h.EXTENSION_NAME=p;var f=function(e){function s(){var r;return(r=e.apply(this,arguments)||this).propertyType="PBRSpecularGlossiness",r.parentTypes=[t.PropertyType.MATERIAL],r.extensionName="KHR_materials_pbrSpecularGlossiness",r._diffuseFactor=[1,1,1,1],r._specularFactor=[1,1,1],r._glossinessFactor=1,r.diffuseTexture=null,r.specularGlossinessTexture=null,r}r(s,e);var n=s.prototype;return n.copy=function(r,s){return void 0===s&&(s=t.COPY_IDENTITY),e.prototype.copy.call(this,r,s),this._diffuseFactor=r._diffuseFactor,this._specularFactor=r._specularFactor,this._glossinessFactor=r._glossinessFactor,r.diffuseTexture&&(this.setDiffuseTexture(s(r.diffuseTexture.getChild())),this.diffuseTexture.copy(r.diffuseTexture)),r.specularGlossinessTexture&&(this.setSpecularGlossinessTexture(s(r.specularGlossinessTexture.getChild())),this.specularGlossinessTexture.copy(r.specularGlossinessTexture)),this},n.getDiffuseFactor=function(){return this._diffuseFactor},n.setDiffuseFactor=function(e){return this._diffuseFactor=e,this},n.getDiffuseHex=function(){return t.ColorUtils.factorToHex(this._diffuseFactor)},n.setDiffuseHex=function(e){return t.ColorUtils.hexToFactor(e,this._diffuseFactor),this},n.getDiffuseTexture=function(){return this.diffuseTexture?this.diffuseTexture.getChild():null},n.getDiffuseTextureInfo=function(){return this.diffuseTexture?this.diffuseTexture.textureInfo:null},n.getDiffuseTextureSampler=function(){return this.diffuseTexture?this.diffuseTexture.sampler:null},n.setDiffuseTexture=function(e){return this.diffuseTexture=this.graph.linkTexture("diffuseTexture",this,e),this},n.getSpecularFactor=function(){return this._specularFactor},n.setSpecularFactor=function(e){return this._specularFactor=e,this},n.getGlossinessFactor=function(){return this._glossinessFactor},n.setGlossinessFactor=function(e){return this._glossinessFactor=e,this},n.getSpecularGlossinessTexture=function(){return this.specularGlossinessTexture?this.specularGlossinessTexture.getChild():null},n.getSpecularGlossinessTextureInfo=function(){return this.specularGlossinessTexture?this.specularGlossinessTexture.textureInfo:null},n.getSpecularGlossinessTextureSampler=function(){return this.specularGlossinessTexture?this.specularGlossinessTexture.sampler:null},n.setSpecularGlossinessTexture=function(e){return this.specularGlossinessTexture=this.graph.linkTexture("specularGlossinessTexture",this,e),this},s}(t.ExtensionProperty);f.EXTENSION_NAME="KHR_materials_pbrSpecularGlossiness",a([t.GraphChild],f.prototype,"diffuseTexture",void 0),a([t.GraphChild],f.prototype,"specularGlossinessTexture",void 0);var T="KHR_materials_pbrSpecularGlossiness",g=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=T,t}r(t,e);var s=t.prototype;return s.createPBRSpecularGlossiness=function(){return new f(this.doc.getGraph(),this)},s.read=function(e){var t=this,r=e.jsonDoc,s=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,n){if(r.extensions&&r.extensions[T]){var o=t.createPBRSpecularGlossiness();if(e.materials[n].setExtension(T,o),void 0!==r.extensions[T].diffuseFactor&&o.setDiffuseFactor(r.extensions[T].diffuseFactor),void 0!==r.extensions[T].specularFactor&&o.setSpecularFactor(r.extensions[T].specularFactor),void 0!==r.extensions[T].glossinessFactor&&o.setGlossinessFactor(r.extensions[T].glossinessFactor),void 0!==r.extensions[T].diffuseTexture){var i=r.extensions[T].diffuseTexture;o.setDiffuseTexture(e.textures[s[i.index].source]),e.setTextureInfo(o.getDiffuseTextureInfo(),i),e.setTextureSampler(o.getDiffuseTextureSampler(),i)}if(void 0!==r.extensions[T].specularGlossinessTexture){var a=r.extensions[T].specularGlossinessTexture;o.setSpecularGlossinessTexture(e.textures[s[a.index].source]),e.setTextureInfo(o.getSpecularGlossinessTextureInfo(),a),e.setTextureSampler(o.getSpecularGlossinessTextureSampler(),a)}}}),this},s.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var s=r.getExtension(T);if(s){var n=e.materialIndexMap.get(r),o=t.json.materials[n];if(o.extensions=o.extensions||{},o.extensions[T]={diffuseFactor:s.getDiffuseFactor(),specularFactor:s.getSpecularFactor(),glossinessFactor:s.getGlossinessFactor()},s.getDiffuseTexture()){var i=s.getDiffuseTexture(),a=s.getDiffuseTextureInfo(),u=s.getDiffuseTextureSampler();o.extensions[T].diffuseTexture=e.createTextureInfoDef(i,a,u)}if(s.getSpecularGlossinessTexture()){var c=s.getSpecularGlossinessTexture(),l=s.getSpecularGlossinessTextureInfo(),x=s.getSpecularGlossinessTextureSampler();o.extensions[T].specularGlossinessTexture=e.createTextureInfoDef(c,l,x)}}}),this},t}(t.Extension);g.EXTENSION_NAME=T;var m=function(e){function s(){var r;return(r=e.apply(this,arguments)||this).propertyType="Specular",r.parentTypes=[t.PropertyType.MATERIAL],r.extensionName="KHR_materials_specular",r._specularFactor=1,r._specularColorFactor=[1,1,1],r.specularTexture=null,r}r(s,e);var n=s.prototype;return n.copy=function(r,s){return void 0===s&&(s=t.COPY_IDENTITY),e.prototype.copy.call(this,r,s),this._specularFactor=r._specularFactor,r.specularTexture&&(this.setSpecularTexture(s(r.specularTexture.getChild())),this.specularTexture.copy(r.specularTexture)),this},n.getSpecularFactor=function(){return this._specularFactor},n.setSpecularFactor=function(e){return this._specularFactor=e,this},n.getSpecularColorFactor=function(){return this._specularColorFactor},n.setSpecularColorFactor=function(e){return this._specularColorFactor=e,this},n.getSpecularColorHex=function(){return t.ColorUtils.factorToHex(this._specularColorFactor)},n.setSpecularColorHex=function(e){return t.ColorUtils.hexToFactor(e,this._specularColorFactor),this},n.getSpecularTexture=function(){return this.specularTexture?this.specularTexture.getChild():null},n.getSpecularTextureInfo=function(){return this.specularTexture?this.specularTexture.textureInfo:null},n.getSpecularTextureSampler=function(){return this.specularTexture?this.specularTexture.sampler:null},n.setSpecularTexture=function(e){return this.specularTexture=this.graph.linkTexture("specularTexture",this,e),this},s}(t.ExtensionProperty);m.EXTENSION_NAME="KHR_materials_specular",a([t.GraphChild],m.prototype,"specularTexture",void 0);var y="KHR_materials_specular",_=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=y,t}r(t,e);var s=t.prototype;return s.createSpecular=function(){return new m(this.doc.getGraph(),this)},s.read=function(e){var t=this,r=e.jsonDoc,s=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,n){if(r.extensions&&r.extensions[y]){var o=t.createSpecular();if(e.materials[n].setExtension(y,o),void 0!==r.extensions[y].specularFactor&&o.setSpecularFactor(r.extensions[y].specularFactor),void 0!==r.extensions[y].specularColorFactor&&o.setSpecularColorFactor(r.extensions[y].specularColorFactor),void 0!==r.extensions[y].specularTexture){var i=r.extensions[y].specularTexture;o.setSpecularTexture(e.textures[s[i.index].source]),e.setTextureInfo(o.getSpecularTextureInfo(),i),e.setTextureSampler(o.getSpecularTextureSampler(),i)}}}),this},s.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var s=r.getExtension(y);if(s){var n=e.materialIndexMap.get(r),o=t.json.materials[n];if(o.extensions=o.extensions||{},o.extensions[y]={specularFactor:s.getSpecularFactor(),specularColorFactor:s.getSpecularColorFactor()},s.getSpecularTexture()){var i=s.getSpecularTexture(),a=s.getSpecularTextureInfo(),u=s.getSpecularTextureSampler();o.extensions[y].specularTexture=e.createTextureInfoDef(i,a,u)}}}),this},t}(t.Extension);_.EXTENSION_NAME=y;var v=function(e){function s(){var r;return(r=e.apply(this,arguments)||this).propertyType="Transmission",r.parentTypes=[t.PropertyType.MATERIAL],r.extensionName="KHR_materials_transmission",r._transmissionFactor=0,r.transmissionTexture=null,r}r(s,e);var n=s.prototype;return n.copy=function(r,s){return void 0===s&&(s=t.COPY_IDENTITY),e.prototype.copy.call(this,r,s),this._transmissionFactor=r._transmissionFactor,r.transmissionTexture&&(this.setTransmissionTexture(s(r.transmissionTexture.getChild())),this.transmissionTexture.copy(r.transmissionTexture)),this},n.getTransmissionFactor=function(){return this._transmissionFactor},n.setTransmissionFactor=function(e){return this._transmissionFactor=e,this},n.getTransmissionTexture=function(){return this.transmissionTexture?this.transmissionTexture.getChild():null},n.getTransmissionTextureInfo=function(){return this.transmissionTexture?this.transmissionTexture.textureInfo:null},n.getTransmissionTextureSampler=function(){return this.transmissionTexture?this.transmissionTexture.sampler:null},n.setTransmissionTexture=function(e){return this.transmissionTexture=this.graph.linkTexture("transmissionTexture",this,e),this},s}(t.ExtensionProperty);v.EXTENSION_NAME="KHR_materials_transmission",a([t.GraphChild],v.prototype,"transmissionTexture",void 0);var d="KHR_materials_transmission",C=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=d,t}r(t,e);var s=t.prototype;return s.createTransmission=function(){return new v(this.doc.getGraph(),this)},s.read=function(e){var t=this,r=e.jsonDoc,s=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,n){if(r.extensions&&r.extensions[d]){var o=t.createTransmission();if(e.materials[n].setExtension(d,o),void 0!==r.extensions[d].transmissionFactor&&o.setTransmissionFactor(r.extensions[d].transmissionFactor),void 0!==r.extensions[d].transmissionTexture){var i=r.extensions[d].transmissionTexture;o.setTransmissionTexture(e.textures[s[i.index].source]),e.setTextureInfo(o.getTransmissionTextureInfo(),i),e.setTextureSampler(o.getTransmissionTextureSampler(),i)}}}),this},s.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var s=r.getExtension(d);if(s){var n=e.materialIndexMap.get(r),o=t.json.materials[n];if(o.extensions=o.extensions||{},o.extensions[d]={transmissionFactor:s.getTransmissionFactor()},s.getTransmissionTexture()){var i=s.getTransmissionTexture(),a=s.getTransmissionTextureInfo(),u=s.getTransmissionTextureSampler();o.extensions[d].transmissionTexture=e.createTextureInfoDef(i,a,u)}}}),this},t}(t.Extension);C.EXTENSION_NAME=d;var N=function(e){function s(){var r;return(r=e.apply(this,arguments)||this).propertyType="Unlit",r.parentTypes=[t.PropertyType.MATERIAL],r.extensionName="KHR_materials_unlit",r}return r(s,e),s}(t.ExtensionProperty);N.EXTENSION_NAME="KHR_materials_unlit";var S="KHR_materials_unlit",E=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=S,t}r(t,e);var s=t.prototype;return s.createUnlit=function(){return new N(this.doc.getGraph(),this)},s.read=function(e){var t=this;return(e.jsonDoc.json.materials||[]).forEach(function(r,s){r.extensions&&r.extensions[S]&&e.materials[s].setExtension(S,t.createUnlit())}),this},s.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){if(r.getExtension(S)){var s=e.materialIndexMap.get(r),n=t.json.materials[s];n.extensions=n.extensions||{},n.extensions[S]={}}}),this},t}(t.Extension);E.EXTENSION_NAME=S;var I="KHR_mesh_quantization",R=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=I,t}r(t,e);var s=t.prototype;return s.read=function(e){return this},s.write=function(e){return this},t}(t.Extension);R.EXTENSION_NAME=I;var F="KHR_texture_basisu",A=function(e){function s(){var r;return(r=e.apply(this,arguments)||this).extensionName=F,r.provideTypes=[t.PropertyType.TEXTURE],r}r(s,e);var n=s.prototype;return n.provide=function(e){return e.jsonDoc.json.textures.forEach(function(e){e.extensions&&e.extensions[F]&&(e.source=e.extensions[F].source)}),this},n.read=function(e){return this},n.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listTextures().forEach(function(r){if("image/ktx2"===r.getMimeType()){var s=e.imageIndexMap.get(r);t.json.textures.forEach(function(e){e.source===s&&(e.extensions=e.extensions||{},e.extensions[F]={source:e.source},delete e.source)})}}),this},s}(t.Extension);A.EXTENSION_NAME=F;var G=[i,l,h,g,_,C,E,R,A];exports.Clearcoat=u,exports.IOR=x,exports.KHRONOS_EXTENSIONS=G,exports.Light=n,exports.LightsPunctual=i,exports.MaterialsClearcoat=l,exports.MaterialsIOR=h,exports.MaterialsPBRSpecularGlossiness=g,exports.MaterialsSpecular=_,exports.MaterialsTransmission=C,exports.MaterialsUnlit=E,exports.MeshQuantization=R,exports.PBRSpecularGlossiness=f,exports.Specular=m,exports.TextureBasisu=A,exports.Transmission=v,exports.Unlit=N;
var e,t=require("@gltf-transform/core");function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}function n(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 s(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)?s(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 o(t,r){var s;try{if((s=new e.DecoderBuffer).Init(new Int8Array(r),r.byteLength),t.GetEncodedGeometryType(s)!==e.TRIANGULAR_MESH)throw new Error("Unknown geometry type.");var n=new e.Mesh;if(!t.DecodeBufferToMesh(s,n).ok()||0===n.ptr)throw new Error("Decoding failure.");return n}finally{e.destroy(s)}}function a(t,r){for(var s=r.num_faces(),n=new Uint32Array(3*s),o=new e.DracoInt32Array,a=0;a<s;a++){t.GetFaceFromMesh(r,a,o);for(var i=0;i<3;++i)n[3*a+i]=o.GetValue(i)}return e.destroy(o),n}function i(t,r,s,n){var o,a,i=function(e){switch(e){case 5126:return Float32Array;case 5125:return Uint32Array;case 5123:return Uint16Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5120:return Int8Array}}(n.componentType),u=s.num_components(),c=r.num_points()*u;switch(i){case Float32Array:o=new e.DracoFloat32Array,t.GetAttributeFloatForAllPoints(r,s,o),a=new Float32Array(c);break;case Int8Array:o=new e.DracoInt8Array,t.GetAttributeInt8ForAllPoints(r,s,o),a=new Int8Array(c);break;case Int16Array:o=new e.DracoInt16Array,t.GetAttributeInt16ForAllPoints(r,s,o),a=new Int16Array(c);break;case Uint8Array:o=new e.DracoUInt8Array,t.GetAttributeUInt8ForAllPoints(r,s,o),a=new Uint8Array(c);break;case Uint16Array:o=new e.DracoUInt16Array,t.GetAttributeUInt16ForAllPoints(r,s,o),a=new Uint16Array(c);break;case Uint32Array:o=new e.DracoUInt32Array,t.GetAttributeUInt32ForAllPoints(r,s,o),a=new Uint32Array(c);break;default:throw new Error("Unexpected attribute type.")}for(var l=0;l<c;l++)a[l]=o.GetValue(l);return e.destroy(o),a}var u,c="KHR_draco_mesh_compression",l=function(s){function u(){var e;return(e=s.apply(this,arguments)||this).extensionName=c,e.provideTypes=[t.PropertyType.PRIMITIVE],e.dependencies=["draco3d.decoder"],e}r(u,s);var l=u.prototype;return l.install=function(t,r){return"draco3d.decoder"===t&&(this._decoderModule=r,e=this._decoderModule),this},l.provide=function(e){if(!this._decoderModule)throw new Error('Please install extension dependency, "draco3d.decoder".');for(var r,s=this.doc.getLogger(),u=e.jsonDoc,l=new this._decoderModule.Decoder,x=new Map,p=n(u.json.meshes);!(r=p()).done;){for(var h,f=n(r.value.primitives);!(h=f()).done;){var T=h.value;if(T.extensions&&T.extensions[c]){var g=T.extensions[c],m=x.get(g.bufferView);if(!m){var y=u.json.bufferViews[g.bufferView],d=u.json.buffers[y.buffer],v=new Uint8Array(d.uri?u.resources[d.uri]:u.resources[t.GLB_BUFFER],y.byteOffset||0,y.byteLength);m=o(l,v),x.set(g.bufferView,m),s.debug("Decompressed "+v.byteLength+" bytes.")}for(var _ in T.attributes){var C=e.jsonDoc.json.accessors[T.attributes[_]],I=l.GetAttributeByUniqueId(m,g.attributes[_]),E=i(l,m,I,C);e.accessors[T.attributes[_]].setArray(E)}var N=a(l,m);e.accessors[T.indices].setArray(N)}}this._decoderModule.destroy(l);for(var S=0,F=Array.from(x.values());S<F.length;S++)this._decoderModule.destroy(F[S])}return this},l.read=function(e){return this.dispose(),this},l.write=function(e){return this.doc.getLogger().warn("Writing "+this.extensionName+" not yet implemented."),this},u}(t.Extension);l.EXTENSION_NAME=c,(u=exports.LightType||(exports.LightType={})).POINT="point",u.SPOT="spot",u.DIRECTIONAL="directional";var x=function(e){function s(){var r;return(r=e.apply(this,arguments)||this).propertyType="Light",r.parentTypes=[t.PropertyType.NODE],r.extensionName="KHR_lights_punctual",r._color=[1,1,1],r._intensity=1,r._range=void 0,r._innerConeAngle=0,r._outerConeAngle=Math.PI/4,r}r(s,e);var n=s.prototype;return n.copy=function(r,s){return void 0===s&&(s=t.COPY_IDENTITY),e.prototype.copy.call(this,r,s),this._color=[].concat(r._color),this._intensity=r._intensity,this._type=r._type,this._range=r._range,this._innerConeAngle=r._innerConeAngle,this._outerConeAngle=r._outerConeAngle,this},n.getColor=function(){return this._color},n.setColor=function(e){return this._color=e,this},n.getColorHex=function(){return t.ColorUtils.factorToHex(this._color)},n.setColorHex=function(e){return t.ColorUtils.hexToFactor(e,this._color),this},n.getIntensity=function(){return this._intensity},n.setIntensity=function(e){return this._intensity=e,this},n.getType=function(){return this._type},n.setType=function(e){return this._type=e,this},n.getRange=function(){return this._range},n.setRange=function(e){return this._range=e,this},n.getInnerConeAngle=function(){return this._innerConeAngle},n.setInnerConeAngle=function(e){return this._innerConeAngle=e,this},n.getOuterConeAngle=function(){return this._outerConeAngle},n.setOuterConeAngle=function(e){return this._outerConeAngle=e,this},s}(t.ExtensionProperty);x.EXTENSION_NAME="KHR_lights_punctual";var p="KHR_lights_punctual",h=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=p,t}r(t,e);var s=t.prototype;return s.createLight=function(){return new x(this.doc.getGraph(),this)},s.read=function(e){var t=this,r=e.jsonDoc;if(!r.json.extensions||!r.json.extensions[p])return this;var s=(r.json.extensions[p].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[p]&&e.nodes[r].setExtension(p,s[t.extensions[p].light])}),this},s.write=function(e){var t=e.jsonDoc;if(0===this.properties.size)return this;for(var r,s=[],o=new Map,a=n(this.properties);!(r=a()).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()),s.push(u),o.set(i,s.length-1)}return this.doc.getRoot().listNodes().forEach(function(r){var s=r.getExtension(p);if(s){var n=e.nodeIndexMap.get(r),a=t.json.nodes[n];a.extensions=a.extensions||{},a.extensions[p]={light:o.get(s)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[p]={lights:s},this},t}(t.Extension);function f(e,t,r,s){var n,o=arguments.length,a=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,s);else for(var i=e.length-1;i>=0;i--)(n=e[i])&&(a=(o<3?n(a):o>3?n(t,r,a):n(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}h.EXTENSION_NAME=p;var T=function(e){function s(){var r;return(r=e.apply(this,arguments)||this).propertyType="Clearcoat",r.parentTypes=[t.PropertyType.MATERIAL],r.extensionName="KHR_materials_clearcoat",r._clearcoatFactor=0,r._clearcoatRoughnessFactor=0,r._clearcoatNormalScale=1,r.clearcoatTexture=null,r.clearcoatRoughnessTexture=null,r.clearcoatNormalTexture=null,r}r(s,e);var n=s.prototype;return n.copy=function(r,s){return void 0===s&&(s=t.COPY_IDENTITY),e.prototype.copy.call(this,r,s),this._clearcoatFactor=r._clearcoatFactor,this._clearcoatRoughnessFactor=r._clearcoatRoughnessFactor,this._clearcoatNormalScale=r._clearcoatNormalScale,r.clearcoatTexture&&(this.setClearcoatTexture(s(r.clearcoatTexture.getChild())),this.clearcoatTexture.copy(r.clearcoatTexture)),r.clearcoatRoughnessTexture&&(this.setClearcoatRoughnessTexture(s(r.clearcoatRoughnessTexture.getChild())),this.clearcoatRoughnessTexture.copy(r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture&&(this.setClearcoatNormalTexture(s(r.clearcoatNormalTexture.getChild())),this.clearcoatNormalTexture.copy(r.clearcoatNormalTexture)),this},n.getClearcoatFactor=function(){return this._clearcoatFactor},n.setClearcoatFactor=function(e){return this._clearcoatFactor=e,this},n.getClearcoatTexture=function(){return this.clearcoatTexture?this.clearcoatTexture.getChild():null},n.getClearcoatTextureInfo=function(){return this.clearcoatTexture?this.clearcoatTexture.textureInfo:null},n.getClearcoatTextureSampler=function(){return this.clearcoatTexture?this.clearcoatTexture.sampler:null},n.setClearcoatTexture=function(e){return this.clearcoatTexture=this.graph.linkTexture("clearcoatTexture",this,e),this},n.getClearcoatRoughnessFactor=function(){return this._clearcoatRoughnessFactor},n.setClearcoatRoughnessFactor=function(e){return this._clearcoatRoughnessFactor=e,this},n.getClearcoatRoughnessTexture=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.getChild():null},n.getClearcoatRoughnessTextureInfo=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.textureInfo:null},n.getClearcoatRoughnessTextureSampler=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.sampler:null},n.setClearcoatRoughnessTexture=function(e){return this.clearcoatRoughnessTexture=this.graph.linkTexture("clearcoatRoughnessTexture",this,e),this},n.getClearcoatNormalScale=function(){return this._clearcoatNormalScale},n.setClearcoatNormalScale=function(e){return this._clearcoatNormalScale=e,this},n.getClearcoatNormalTexture=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTexture.getChild():null},n.getClearcoatNormalTextureInfo=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTexture.textureInfo:null},n.getClearcoatNormalTextureSampler=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTexture.sampler:null},n.setClearcoatNormalTexture=function(e){return this.clearcoatNormalTexture=this.graph.linkTexture("clearcoatNormalTexture",this,e),this},s}(t.ExtensionProperty);T.EXTENSION_NAME="KHR_materials_clearcoat",f([t.GraphChild],T.prototype,"clearcoatTexture",void 0),f([t.GraphChild],T.prototype,"clearcoatRoughnessTexture",void 0),f([t.GraphChild],T.prototype,"clearcoatNormalTexture",void 0);var g="KHR_materials_clearcoat",m=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=g,t}r(t,e);var s=t.prototype;return s.createClearcoat=function(){return new T(this.doc.getGraph(),this)},s.read=function(e){var t=this,r=e.jsonDoc,s=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,n){if(r.extensions&&r.extensions[g]){var o=t.createClearcoat();if(e.materials[n].setExtension(g,o),void 0!==r.extensions[g].clearcoatFactor&&o.setClearcoatFactor(r.extensions[g].clearcoatFactor),void 0!==r.extensions[g].clearcoatRoughnessFactor&&o.setClearcoatRoughnessFactor(r.extensions[g].clearcoatRoughnessFactor),void 0!==r.extensions[g].clearcoatTexture){var a=r.extensions[g].clearcoatTexture;o.setClearcoatTexture(e.textures[s[a.index].source]),e.setTextureInfo(o.getClearcoatTextureInfo(),a),e.setTextureSampler(o.getClearcoatTextureSampler(),a)}if(void 0!==r.extensions[g].clearcoatRoughnessTexture){var i=r.extensions[g].clearcoatRoughnessTexture;o.setClearcoatRoughnessTexture(e.textures[s[i.index].source]),e.setTextureInfo(o.getClearcoatRoughnessTextureInfo(),i),e.setTextureSampler(o.getClearcoatRoughnessTextureSampler(),i)}if(void 0!==r.extensions[g].clearcoatNormalTexture){var u=r.extensions[g].clearcoatNormalTexture;o.setClearcoatNormalTexture(e.textures[s[u.index].source]),e.setTextureInfo(o.getClearcoatNormalTextureInfo(),u),e.setTextureSampler(o.getClearcoatNormalTextureSampler(),u),void 0!==u.scale&&o.setClearcoatNormalScale(u.scale)}}}),this},s.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var s=r.getExtension(g);if(s){var n=e.materialIndexMap.get(r),o=t.json.materials[n];if(o.extensions=o.extensions||{},o.extensions[g]={clearcoatFactor:s.getClearcoatFactor(),clearcoatRoughnessFactor:s.getClearcoatRoughnessFactor()},s.getClearcoatTexture()){var a=s.getClearcoatTexture(),i=s.getClearcoatTextureInfo(),u=s.getClearcoatTextureSampler();o.extensions[g].clearcoatTexture=e.createTextureInfoDef(a,i,u)}if(s.getClearcoatRoughnessTexture()){var c=s.getClearcoatRoughnessTexture(),l=s.getClearcoatRoughnessTextureInfo(),x=s.getClearcoatRoughnessTextureSampler();o.extensions[g].clearcoatRoughnessTexture=e.createTextureInfoDef(c,l,x)}if(s.getClearcoatNormalTexture()){var p=s.getClearcoatNormalTexture(),h=s.getClearcoatNormalTextureInfo(),f=s.getClearcoatNormalTextureSampler();o.extensions[g].clearcoatNormalTexture=e.createTextureInfoDef(p,h,f),1!==s.getClearcoatNormalScale()&&(o.extensions[g].clearcoatNormalTexture.scale=s.getClearcoatNormalScale())}}}),this},t}(t.Extension);m.EXTENSION_NAME=g;var y=function(e){function s(){var r;return(r=e.apply(this,arguments)||this).propertyType="IOR",r.parentTypes=[t.PropertyType.MATERIAL],r.extensionName="KHR_materials_ior",r._ior=0,r}r(s,e);var n=s.prototype;return n.copy=function(r,s){return void 0===s&&(s=t.COPY_IDENTITY),e.prototype.copy.call(this,r,s),this._ior=r._ior,this},n.getIOR=function(){return this._ior},n.setIOR=function(e){return this._ior=e,this},s}(t.ExtensionProperty);y.EXTENSION_NAME="KHR_materials_ior";var d="KHR_materials_ior",v=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=d,t}r(t,e);var s=t.prototype;return s.createIOR=function(){return new y(this.doc.getGraph(),this)},s.read=function(e){var t=this;return(e.jsonDoc.json.materials||[]).forEach(function(r,s){if(r.extensions&&r.extensions[d]){var n=t.createIOR();e.materials[s].setExtension(d,n),void 0!==r.extensions[d].ior&&n.setIOR(r.extensions[d].ior)}}),this},s.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var s=r.getExtension(d);if(s){var n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{},o.extensions[d]={ior:s.getIOR()}}}),this},t}(t.Extension);v.EXTENSION_NAME=d;var _=function(e){function s(){var r;return(r=e.apply(this,arguments)||this).propertyType="PBRSpecularGlossiness",r.parentTypes=[t.PropertyType.MATERIAL],r.extensionName="KHR_materials_pbrSpecularGlossiness",r._diffuseFactor=[1,1,1,1],r._specularFactor=[1,1,1],r._glossinessFactor=1,r.diffuseTexture=null,r.specularGlossinessTexture=null,r}r(s,e);var n=s.prototype;return n.copy=function(r,s){return void 0===s&&(s=t.COPY_IDENTITY),e.prototype.copy.call(this,r,s),this._diffuseFactor=r._diffuseFactor,this._specularFactor=r._specularFactor,this._glossinessFactor=r._glossinessFactor,r.diffuseTexture&&(this.setDiffuseTexture(s(r.diffuseTexture.getChild())),this.diffuseTexture.copy(r.diffuseTexture)),r.specularGlossinessTexture&&(this.setSpecularGlossinessTexture(s(r.specularGlossinessTexture.getChild())),this.specularGlossinessTexture.copy(r.specularGlossinessTexture)),this},n.getDiffuseFactor=function(){return this._diffuseFactor},n.setDiffuseFactor=function(e){return this._diffuseFactor=e,this},n.getDiffuseHex=function(){return t.ColorUtils.factorToHex(this._diffuseFactor)},n.setDiffuseHex=function(e){return t.ColorUtils.hexToFactor(e,this._diffuseFactor),this},n.getDiffuseTexture=function(){return this.diffuseTexture?this.diffuseTexture.getChild():null},n.getDiffuseTextureInfo=function(){return this.diffuseTexture?this.diffuseTexture.textureInfo:null},n.getDiffuseTextureSampler=function(){return this.diffuseTexture?this.diffuseTexture.sampler:null},n.setDiffuseTexture=function(e){return this.diffuseTexture=this.graph.linkTexture("diffuseTexture",this,e),this},n.getSpecularFactor=function(){return this._specularFactor},n.setSpecularFactor=function(e){return this._specularFactor=e,this},n.getGlossinessFactor=function(){return this._glossinessFactor},n.setGlossinessFactor=function(e){return this._glossinessFactor=e,this},n.getSpecularGlossinessTexture=function(){return this.specularGlossinessTexture?this.specularGlossinessTexture.getChild():null},n.getSpecularGlossinessTextureInfo=function(){return this.specularGlossinessTexture?this.specularGlossinessTexture.textureInfo:null},n.getSpecularGlossinessTextureSampler=function(){return this.specularGlossinessTexture?this.specularGlossinessTexture.sampler:null},n.setSpecularGlossinessTexture=function(e){return this.specularGlossinessTexture=this.graph.linkTexture("specularGlossinessTexture",this,e),this},s}(t.ExtensionProperty);_.EXTENSION_NAME="KHR_materials_pbrSpecularGlossiness",f([t.GraphChild],_.prototype,"diffuseTexture",void 0),f([t.GraphChild],_.prototype,"specularGlossinessTexture",void 0);var C="KHR_materials_pbrSpecularGlossiness",I=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=C,t}r(t,e);var s=t.prototype;return s.createPBRSpecularGlossiness=function(){return new _(this.doc.getGraph(),this)},s.read=function(e){var t=this,r=e.jsonDoc,s=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,n){if(r.extensions&&r.extensions[C]){var o=t.createPBRSpecularGlossiness();if(e.materials[n].setExtension(C,o),void 0!==r.extensions[C].diffuseFactor&&o.setDiffuseFactor(r.extensions[C].diffuseFactor),void 0!==r.extensions[C].specularFactor&&o.setSpecularFactor(r.extensions[C].specularFactor),void 0!==r.extensions[C].glossinessFactor&&o.setGlossinessFactor(r.extensions[C].glossinessFactor),void 0!==r.extensions[C].diffuseTexture){var a=r.extensions[C].diffuseTexture;o.setDiffuseTexture(e.textures[s[a.index].source]),e.setTextureInfo(o.getDiffuseTextureInfo(),a),e.setTextureSampler(o.getDiffuseTextureSampler(),a)}if(void 0!==r.extensions[C].specularGlossinessTexture){var i=r.extensions[C].specularGlossinessTexture;o.setSpecularGlossinessTexture(e.textures[s[i.index].source]),e.setTextureInfo(o.getSpecularGlossinessTextureInfo(),i),e.setTextureSampler(o.getSpecularGlossinessTextureSampler(),i)}}}),this},s.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var s=r.getExtension(C);if(s){var n=e.materialIndexMap.get(r),o=t.json.materials[n];if(o.extensions=o.extensions||{},o.extensions[C]={diffuseFactor:s.getDiffuseFactor(),specularFactor:s.getSpecularFactor(),glossinessFactor:s.getGlossinessFactor()},s.getDiffuseTexture()){var a=s.getDiffuseTexture(),i=s.getDiffuseTextureInfo(),u=s.getDiffuseTextureSampler();o.extensions[C].diffuseTexture=e.createTextureInfoDef(a,i,u)}if(s.getSpecularGlossinessTexture()){var c=s.getSpecularGlossinessTexture(),l=s.getSpecularGlossinessTextureInfo(),x=s.getSpecularGlossinessTextureSampler();o.extensions[C].specularGlossinessTexture=e.createTextureInfoDef(c,l,x)}}}),this},t}(t.Extension);I.EXTENSION_NAME=C;var E=function(e){function s(){var r;return(r=e.apply(this,arguments)||this).propertyType="Specular",r.parentTypes=[t.PropertyType.MATERIAL],r.extensionName="KHR_materials_specular",r._specularFactor=1,r._specularColorFactor=[1,1,1],r.specularTexture=null,r}r(s,e);var n=s.prototype;return n.copy=function(r,s){return void 0===s&&(s=t.COPY_IDENTITY),e.prototype.copy.call(this,r,s),this._specularFactor=r._specularFactor,r.specularTexture&&(this.setSpecularTexture(s(r.specularTexture.getChild())),this.specularTexture.copy(r.specularTexture)),this},n.getSpecularFactor=function(){return this._specularFactor},n.setSpecularFactor=function(e){return this._specularFactor=e,this},n.getSpecularColorFactor=function(){return this._specularColorFactor},n.setSpecularColorFactor=function(e){return this._specularColorFactor=e,this},n.getSpecularColorHex=function(){return t.ColorUtils.factorToHex(this._specularColorFactor)},n.setSpecularColorHex=function(e){return t.ColorUtils.hexToFactor(e,this._specularColorFactor),this},n.getSpecularTexture=function(){return this.specularTexture?this.specularTexture.getChild():null},n.getSpecularTextureInfo=function(){return this.specularTexture?this.specularTexture.textureInfo:null},n.getSpecularTextureSampler=function(){return this.specularTexture?this.specularTexture.sampler:null},n.setSpecularTexture=function(e){return this.specularTexture=this.graph.linkTexture("specularTexture",this,e),this},s}(t.ExtensionProperty);E.EXTENSION_NAME="KHR_materials_specular",f([t.GraphChild],E.prototype,"specularTexture",void 0);var N="KHR_materials_specular",S=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=N,t}r(t,e);var s=t.prototype;return s.createSpecular=function(){return new E(this.doc.getGraph(),this)},s.read=function(e){var t=this,r=e.jsonDoc,s=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,n){if(r.extensions&&r.extensions[N]){var o=t.createSpecular();if(e.materials[n].setExtension(N,o),void 0!==r.extensions[N].specularFactor&&o.setSpecularFactor(r.extensions[N].specularFactor),void 0!==r.extensions[N].specularColorFactor&&o.setSpecularColorFactor(r.extensions[N].specularColorFactor),void 0!==r.extensions[N].specularTexture){var a=r.extensions[N].specularTexture;o.setSpecularTexture(e.textures[s[a.index].source]),e.setTextureInfo(o.getSpecularTextureInfo(),a),e.setTextureSampler(o.getSpecularTextureSampler(),a)}}}),this},s.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var s=r.getExtension(N);if(s){var n=e.materialIndexMap.get(r),o=t.json.materials[n];if(o.extensions=o.extensions||{},o.extensions[N]={specularFactor:s.getSpecularFactor(),specularColorFactor:s.getSpecularColorFactor()},s.getSpecularTexture()){var a=s.getSpecularTexture(),i=s.getSpecularTextureInfo(),u=s.getSpecularTextureSampler();o.extensions[N].specularTexture=e.createTextureInfoDef(a,i,u)}}}),this},t}(t.Extension);S.EXTENSION_NAME=N;var F=function(e){function s(){var r;return(r=e.apply(this,arguments)||this).propertyType="Transmission",r.parentTypes=[t.PropertyType.MATERIAL],r.extensionName="KHR_materials_transmission",r._transmissionFactor=0,r.transmissionTexture=null,r}r(s,e);var n=s.prototype;return n.copy=function(r,s){return void 0===s&&(s=t.COPY_IDENTITY),e.prototype.copy.call(this,r,s),this._transmissionFactor=r._transmissionFactor,r.transmissionTexture&&(this.setTransmissionTexture(s(r.transmissionTexture.getChild())),this.transmissionTexture.copy(r.transmissionTexture)),this},n.getTransmissionFactor=function(){return this._transmissionFactor},n.setTransmissionFactor=function(e){return this._transmissionFactor=e,this},n.getTransmissionTexture=function(){return this.transmissionTexture?this.transmissionTexture.getChild():null},n.getTransmissionTextureInfo=function(){return this.transmissionTexture?this.transmissionTexture.textureInfo:null},n.getTransmissionTextureSampler=function(){return this.transmissionTexture?this.transmissionTexture.sampler:null},n.setTransmissionTexture=function(e){return this.transmissionTexture=this.graph.linkTexture("transmissionTexture",this,e),this},s}(t.ExtensionProperty);F.EXTENSION_NAME="KHR_materials_transmission",f([t.GraphChild],F.prototype,"transmissionTexture",void 0);var R="KHR_materials_transmission",A=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=R,t}r(t,e);var s=t.prototype;return s.createTransmission=function(){return new F(this.doc.getGraph(),this)},s.read=function(e){var t=this,r=e.jsonDoc,s=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,n){if(r.extensions&&r.extensions[R]){var o=t.createTransmission();if(e.materials[n].setExtension(R,o),void 0!==r.extensions[R].transmissionFactor&&o.setTransmissionFactor(r.extensions[R].transmissionFactor),void 0!==r.extensions[R].transmissionTexture){var a=r.extensions[R].transmissionTexture;o.setTransmissionTexture(e.textures[s[a.index].source]),e.setTextureInfo(o.getTransmissionTextureInfo(),a),e.setTextureSampler(o.getTransmissionTextureSampler(),a)}}}),this},s.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){var s=r.getExtension(R);if(s){var n=e.materialIndexMap.get(r),o=t.json.materials[n];if(o.extensions=o.extensions||{},o.extensions[R]={transmissionFactor:s.getTransmissionFactor()},s.getTransmissionTexture()){var a=s.getTransmissionTexture(),i=s.getTransmissionTextureInfo(),u=s.getTransmissionTextureSampler();o.extensions[R].transmissionTexture=e.createTextureInfoDef(a,i,u)}}}),this},t}(t.Extension);A.EXTENSION_NAME=R;var G=function(e){function s(){var r;return(r=e.apply(this,arguments)||this).propertyType="Unlit",r.parentTypes=[t.PropertyType.MATERIAL],r.extensionName="KHR_materials_unlit",r}return r(s,e),s}(t.ExtensionProperty);G.EXTENSION_NAME="KHR_materials_unlit";var D="KHR_materials_unlit",M=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=D,t}r(t,e);var s=t.prototype;return s.createUnlit=function(){return new G(this.doc.getGraph(),this)},s.read=function(e){var t=this;return(e.jsonDoc.json.materials||[]).forEach(function(r,s){r.extensions&&r.extensions[D]&&e.materials[s].setExtension(D,t.createUnlit())}),this},s.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(function(r){if(r.getExtension(D)){var s=e.materialIndexMap.get(r),n=t.json.materials[s];n.extensions=n.extensions||{},n.extensions[D]={}}}),this},t}(t.Extension);M.EXTENSION_NAME=D;var w="KHR_mesh_quantization",j=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=w,t}r(t,e);var s=t.prototype;return s.read=function(e){return this},s.write=function(e){return this},t}(t.Extension);j.EXTENSION_NAME=w;var O="KHR_texture_basisu",b=function(e){function s(){var r;return(r=e.apply(this,arguments)||this).extensionName=O,r.provideTypes=[t.PropertyType.TEXTURE],r}r(s,e);var n=s.prototype;return n.provide=function(e){return e.jsonDoc.json.textures.forEach(function(e){e.extensions&&e.extensions[O]&&(e.source=e.extensions[O].source)}),this},n.read=function(e){return this},n.write=function(e){var t=e.jsonDoc;return this.doc.getRoot().listTextures().forEach(function(r){if("image/ktx2"===r.getMimeType()){var s=e.imageIndexMap.get(r);t.json.textures.forEach(function(e){e.source===s&&(e.extensions=e.extensions||{},e.extensions[O]={source:e.source},delete e.source)})}}),this},s}(t.Extension);b.EXTENSION_NAME=O;var P=[l,h,m,v,I,S,A,M,j,b];exports.Clearcoat=T,exports.DracoMeshCompression=l,exports.IOR=y,exports.KHRONOS_EXTENSIONS=P,exports.Light=x,exports.LightsPunctual=h,exports.MaterialsClearcoat=m,exports.MaterialsIOR=v,exports.MaterialsPBRSpecularGlossiness=I,exports.MaterialsSpecular=S,exports.MaterialsTransmission=A,exports.MaterialsUnlit=M,exports.MeshQuantization=j,exports.PBRSpecularGlossiness=_,exports.Specular=E,exports.TextureBasisu=b,exports.Transmission=F,exports.Unlit=G;
//# sourceMappingURL=extensions.js.map

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

import{ExtensionProperty as e,PropertyType as t,COPY_IDENTITY as s,ColorUtils as r,Extension as o,GraphChild as n}from"@gltf-transform/core";var a;!function(e){e.POINT="point",e.SPOT="spot",e.DIRECTIONAL="directional"}(a||(a={}));class i extends e{constructor(){super(...arguments),this.propertyType="Light",this.parentTypes=[t.NODE],this.extensionName="KHR_lights_punctual",this._color=[1,1,1],this._intensity=1,this._range=void 0,this._innerConeAngle=0,this._outerConeAngle=Math.PI/4}copy(e,t=s){return super.copy(e,t),this._color=[...e._color],this._intensity=e._intensity,this._type=e._type,this._range=e._range,this._innerConeAngle=e._innerConeAngle,this._outerConeAngle=e._outerConeAngle,this}getColor(){return this._color}setColor(e){return this._color=e,this}getColorHex(){return r.factorToHex(this._color)}setColorHex(e){return r.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}}i.EXTENSION_NAME="KHR_lights_punctual";const c="KHR_lights_punctual";class u extends o{constructor(){super(...arguments),this.extensionName=c}createLight(){return new i(this.doc.getGraph(),this)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions[c])return this;const s=(t.json.extensions[c].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[c]&&e.nodes[r].setExtension(c,s[t.extensions[c].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()===a.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(c);if(o){const n=e.nodeIndexMap.get(s),a=t.json.nodes[n];a.extensions=a.extensions||{},a.extensions[c]={light:r.get(o)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[c]={lights:s},this}}function l(e,t,s,r){var o,n=arguments.length,a=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,s,r);else for(var i=e.length-1;i>=0;i--)(o=e[i])&&(a=(n<3?o(a):n>3?o(t,s,a):o(t,s))||a);return n>3&&a&&Object.defineProperty(t,s,a),a}u.EXTENSION_NAME=c;class x extends e{constructor(){super(...arguments),this.propertyType="Clearcoat",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_clearcoat",this._clearcoatFactor=0,this._clearcoatRoughnessFactor=0,this._clearcoatNormalScale=1,this.clearcoatTexture=null,this.clearcoatRoughnessTexture=null,this.clearcoatNormalTexture=null}copy(e,t=s){return super.copy(e,t),this._clearcoatFactor=e._clearcoatFactor,this._clearcoatRoughnessFactor=e._clearcoatRoughnessFactor,this._clearcoatNormalScale=e._clearcoatNormalScale,e.clearcoatTexture&&(this.setClearcoatTexture(t(e.clearcoatTexture.getChild())),this.clearcoatTexture.copy(e.clearcoatTexture)),e.clearcoatRoughnessTexture&&(this.setClearcoatRoughnessTexture(t(e.clearcoatRoughnessTexture.getChild())),this.clearcoatRoughnessTexture.copy(e.clearcoatRoughnessTexture)),e.clearcoatNormalTexture&&(this.setClearcoatNormalTexture(t(e.clearcoatNormalTexture.getChild())),this.clearcoatNormalTexture.copy(e.clearcoatNormalTexture)),this}getClearcoatFactor(){return this._clearcoatFactor}setClearcoatFactor(e){return this._clearcoatFactor=e,this}getClearcoatTexture(){return this.clearcoatTexture?this.clearcoatTexture.getChild():null}getClearcoatTextureInfo(){return this.clearcoatTexture?this.clearcoatTexture.textureInfo:null}getClearcoatTextureSampler(){return this.clearcoatTexture?this.clearcoatTexture.sampler:null}setClearcoatTexture(e){return this.clearcoatTexture=this.graph.linkTexture("clearcoatTexture",this,e),this}getClearcoatRoughnessFactor(){return this._clearcoatRoughnessFactor}setClearcoatRoughnessFactor(e){return this._clearcoatRoughnessFactor=e,this}getClearcoatRoughnessTexture(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.getChild():null}getClearcoatRoughnessTextureInfo(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.textureInfo:null}getClearcoatRoughnessTextureSampler(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.sampler:null}setClearcoatRoughnessTexture(e){return this.clearcoatRoughnessTexture=this.graph.linkTexture("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.clearcoatNormalTexture.textureInfo:null}getClearcoatNormalTextureSampler(){return this.clearcoatNormalTexture?this.clearcoatNormalTexture.sampler:null}setClearcoatNormalTexture(e){return this.clearcoatNormalTexture=this.graph.linkTexture("clearcoatNormalTexture",this,e),this}}x.EXTENSION_NAME="KHR_materials_clearcoat",l([n],x.prototype,"clearcoatTexture",void 0),l([n],x.prototype,"clearcoatRoughnessTexture",void 0),l([n],x.prototype,"clearcoatNormalTexture",void 0);const h="KHR_materials_clearcoat";class T extends o{constructor(){super(...arguments),this.extensionName=h}createClearcoat(){return new x(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[h]){const o=this.createClearcoat();if(e.materials[r].setExtension(h,o),void 0!==t.extensions[h].clearcoatFactor&&o.setClearcoatFactor(t.extensions[h].clearcoatFactor),void 0!==t.extensions[h].clearcoatRoughnessFactor&&o.setClearcoatRoughnessFactor(t.extensions[h].clearcoatRoughnessFactor),void 0!==t.extensions[h].clearcoatTexture){const r=t.extensions[h].clearcoatTexture;o.setClearcoatTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getClearcoatTextureInfo(),r),e.setTextureSampler(o.getClearcoatTextureSampler(),r)}if(void 0!==t.extensions[h].clearcoatRoughnessTexture){const r=t.extensions[h].clearcoatRoughnessTexture;o.setClearcoatRoughnessTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getClearcoatRoughnessTextureInfo(),r),e.setTextureSampler(o.getClearcoatRoughnessTextureSampler(),r)}if(void 0!==t.extensions[h].clearcoatNormalTexture){const r=t.extensions[h].clearcoatNormalTexture;o.setClearcoatNormalTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getClearcoatNormalTextureInfo(),r),e.setTextureSampler(o.getClearcoatNormalTextureSampler(),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(h);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[h]={clearcoatFactor:r.getClearcoatFactor(),clearcoatRoughnessFactor:r.getClearcoatRoughnessFactor()},r.getClearcoatTexture()){const t=r.getClearcoatTexture(),s=r.getClearcoatTextureInfo(),o=r.getClearcoatTextureSampler();n.extensions[h].clearcoatTexture=e.createTextureInfoDef(t,s,o)}if(r.getClearcoatRoughnessTexture()){const t=r.getClearcoatRoughnessTexture(),s=r.getClearcoatRoughnessTextureInfo(),o=r.getClearcoatRoughnessTextureSampler();n.extensions[h].clearcoatRoughnessTexture=e.createTextureInfoDef(t,s,o)}if(r.getClearcoatNormalTexture()){const t=r.getClearcoatNormalTexture(),s=r.getClearcoatNormalTextureInfo(),o=r.getClearcoatNormalTextureSampler();n.extensions[h].clearcoatNormalTexture=e.createTextureInfoDef(t,s,o),1!==r.getClearcoatNormalScale()&&(n.extensions[h].clearcoatNormalTexture.scale=r.getClearcoatNormalScale())}}}),this}}T.EXTENSION_NAME=h;class p extends e{constructor(){super(...arguments),this.propertyType="IOR",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_ior",this._ior=0}copy(e,t=s){return super.copy(e,t),this._ior=e._ior,this}getIOR(){return this._ior}setIOR(e){return this._ior=e,this}}p.EXTENSION_NAME="KHR_materials_ior";const g="KHR_materials_ior";class f extends o{constructor(){super(...arguments),this.extensionName=g}createIOR(){return new p(this.doc.getGraph(),this)}read(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{if(t.extensions&&t.extensions[g]){const r=this.createIOR();e.materials[s].setExtension(g,r),void 0!==t.extensions[g].ior&&r.setIOR(t.extensions[g].ior)}}),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];n.extensions=n.extensions||{},n.extensions[g]={ior:r.getIOR()}}}),this}}f.EXTENSION_NAME=g;class m extends e{constructor(){super(...arguments),this.propertyType="PBRSpecularGlossiness",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_pbrSpecularGlossiness",this._diffuseFactor=[1,1,1,1],this._specularFactor=[1,1,1],this._glossinessFactor=1,this.diffuseTexture=null,this.specularGlossinessTexture=null}copy(e,t=s){return super.copy(e,t),this._diffuseFactor=e._diffuseFactor,this._specularFactor=e._specularFactor,this._glossinessFactor=e._glossinessFactor,e.diffuseTexture&&(this.setDiffuseTexture(t(e.diffuseTexture.getChild())),this.diffuseTexture.copy(e.diffuseTexture)),e.specularGlossinessTexture&&(this.setSpecularGlossinessTexture(t(e.specularGlossinessTexture.getChild())),this.specularGlossinessTexture.copy(e.specularGlossinessTexture)),this}getDiffuseFactor(){return this._diffuseFactor}setDiffuseFactor(e){return this._diffuseFactor=e,this}getDiffuseHex(){return r.factorToHex(this._diffuseFactor)}setDiffuseHex(e){return r.hexToFactor(e,this._diffuseFactor),this}getDiffuseTexture(){return this.diffuseTexture?this.diffuseTexture.getChild():null}getDiffuseTextureInfo(){return this.diffuseTexture?this.diffuseTexture.textureInfo:null}getDiffuseTextureSampler(){return this.diffuseTexture?this.diffuseTexture.sampler:null}setDiffuseTexture(e){return this.diffuseTexture=this.graph.linkTexture("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.specularGlossinessTexture.textureInfo:null}getSpecularGlossinessTextureSampler(){return this.specularGlossinessTexture?this.specularGlossinessTexture.sampler:null}setSpecularGlossinessTexture(e){return this.specularGlossinessTexture=this.graph.linkTexture("specularGlossinessTexture",this,e),this}}m.EXTENSION_NAME="KHR_materials_pbrSpecularGlossiness",l([n],m.prototype,"diffuseTexture",void 0),l([n],m.prototype,"specularGlossinessTexture",void 0);const _="KHR_materials_pbrSpecularGlossiness";class d extends o{constructor(){super(...arguments),this.extensionName=_}createPBRSpecularGlossiness(){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[_]){const o=this.createPBRSpecularGlossiness();if(e.materials[r].setExtension(_,o),void 0!==t.extensions[_].diffuseFactor&&o.setDiffuseFactor(t.extensions[_].diffuseFactor),void 0!==t.extensions[_].specularFactor&&o.setSpecularFactor(t.extensions[_].specularFactor),void 0!==t.extensions[_].glossinessFactor&&o.setGlossinessFactor(t.extensions[_].glossinessFactor),void 0!==t.extensions[_].diffuseTexture){const r=t.extensions[_].diffuseTexture;o.setDiffuseTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getDiffuseTextureInfo(),r),e.setTextureSampler(o.getDiffuseTextureSampler(),r)}if(void 0!==t.extensions[_].specularGlossinessTexture){const r=t.extensions[_].specularGlossinessTexture;o.setSpecularGlossinessTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getSpecularGlossinessTextureInfo(),r),e.setTextureSampler(o.getSpecularGlossinessTextureSampler(),r)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(_);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[_]={diffuseFactor:r.getDiffuseFactor(),specularFactor:r.getSpecularFactor(),glossinessFactor:r.getGlossinessFactor()},r.getDiffuseTexture()){const t=r.getDiffuseTexture(),s=r.getDiffuseTextureInfo(),o=r.getDiffuseTextureSampler();n.extensions[_].diffuseTexture=e.createTextureInfoDef(t,s,o)}if(r.getSpecularGlossinessTexture()){const t=r.getSpecularGlossinessTexture(),s=r.getSpecularGlossinessTextureInfo(),o=r.getSpecularGlossinessTextureSampler();n.extensions[_].specularGlossinessTexture=e.createTextureInfoDef(t,s,o)}}}),this}}d.EXTENSION_NAME=_;class C extends e{constructor(){super(...arguments),this.propertyType="Specular",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_specular",this._specularFactor=1,this._specularColorFactor=[1,1,1],this.specularTexture=null}copy(e,t=s){return super.copy(e,t),this._specularFactor=e._specularFactor,e.specularTexture&&(this.setSpecularTexture(t(e.specularTexture.getChild())),this.specularTexture.copy(e.specularTexture)),this}getSpecularFactor(){return this._specularFactor}setSpecularFactor(e){return this._specularFactor=e,this}getSpecularColorFactor(){return this._specularColorFactor}setSpecularColorFactor(e){return this._specularColorFactor=e,this}getSpecularColorHex(){return r.factorToHex(this._specularColorFactor)}setSpecularColorHex(e){return r.hexToFactor(e,this._specularColorFactor),this}getSpecularTexture(){return this.specularTexture?this.specularTexture.getChild():null}getSpecularTextureInfo(){return this.specularTexture?this.specularTexture.textureInfo:null}getSpecularTextureSampler(){return this.specularTexture?this.specularTexture.sampler:null}setSpecularTexture(e){return this.specularTexture=this.graph.linkTexture("specularTexture",this,e),this}}C.EXTENSION_NAME="KHR_materials_specular",l([n],C.prototype,"specularTexture",void 0);const N="KHR_materials_specular";class S extends o{constructor(){super(...arguments),this.extensionName=N}createSpecular(){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.createSpecular();if(e.materials[r].setExtension(N,o),void 0!==t.extensions[N].specularFactor&&o.setSpecularFactor(t.extensions[N].specularFactor),void 0!==t.extensions[N].specularColorFactor&&o.setSpecularColorFactor(t.extensions[N].specularColorFactor),void 0!==t.extensions[N].specularTexture){const r=t.extensions[N].specularTexture;o.setSpecularTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getSpecularTextureInfo(),r),e.setTextureSampler(o.getSpecularTextureSampler(),r)}}}),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]={specularFactor:r.getSpecularFactor(),specularColorFactor:r.getSpecularColorFactor()},r.getSpecularTexture()){const t=r.getSpecularTexture(),s=r.getSpecularTextureInfo(),o=r.getSpecularTextureSampler();n.extensions[N].specularTexture=e.createTextureInfoDef(t,s,o)}}}),this}}S.EXTENSION_NAME=N;class F extends e{constructor(){super(...arguments),this.propertyType="Transmission",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_transmission",this._transmissionFactor=0,this.transmissionTexture=null}copy(e,t=s){return super.copy(e,t),this._transmissionFactor=e._transmissionFactor,e.transmissionTexture&&(this.setTransmissionTexture(t(e.transmissionTexture.getChild())),this.transmissionTexture.copy(e.transmissionTexture)),this}getTransmissionFactor(){return this._transmissionFactor}setTransmissionFactor(e){return this._transmissionFactor=e,this}getTransmissionTexture(){return this.transmissionTexture?this.transmissionTexture.getChild():null}getTransmissionTextureInfo(){return this.transmissionTexture?this.transmissionTexture.textureInfo:null}getTransmissionTextureSampler(){return this.transmissionTexture?this.transmissionTexture.sampler:null}setTransmissionTexture(e){return this.transmissionTexture=this.graph.linkTexture("transmissionTexture",this,e),this}}F.EXTENSION_NAME="KHR_materials_transmission",l([n],F.prototype,"transmissionTexture",void 0);const R="KHR_materials_transmission";class I extends o{constructor(){super(...arguments),this.extensionName=R}createTransmission(){return new F(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[R]){const o=this.createTransmission();if(e.materials[r].setExtension(R,o),void 0!==t.extensions[R].transmissionFactor&&o.setTransmissionFactor(t.extensions[R].transmissionFactor),void 0!==t.extensions[R].transmissionTexture){const r=t.extensions[R].transmissionTexture;o.setTransmissionTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getTransmissionTextureInfo(),r),e.setTextureSampler(o.getTransmissionTextureSampler(),r)}}}),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];if(n.extensions=n.extensions||{},n.extensions[R]={transmissionFactor:r.getTransmissionFactor()},r.getTransmissionTexture()){const t=r.getTransmissionTexture(),s=r.getTransmissionTextureInfo(),o=r.getTransmissionTextureSampler();n.extensions[R].transmissionTexture=e.createTextureInfoDef(t,s,o)}}}),this}}I.EXTENSION_NAME=R;class E extends e{constructor(){super(...arguments),this.propertyType="Unlit",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_unlit"}}E.EXTENSION_NAME="KHR_materials_unlit";const y="KHR_materials_unlit";class A extends o{constructor(){super(...arguments),this.extensionName=y}createUnlit(){return new E(this.doc.getGraph(),this)}read(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{t.extensions&&t.extensions[y]&&e.materials[s].setExtension(y,this.createUnlit())}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{if(s.getExtension(y)){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{},o.extensions[y]={}}}),this}}A.EXTENSION_NAME=y;const G="KHR_mesh_quantization";class j extends o{constructor(){super(...arguments),this.extensionName=G}read(e){return this}write(e){return this}}j.EXTENSION_NAME=G;const D="KHR_texture_basisu";class M extends o{constructor(){super(...arguments),this.extensionName=D,this.provideTypes=[t.TEXTURE]}provide(e){return e.jsonDoc.json.textures.forEach(e=>{e.extensions&&e.extensions[D]&&(e.source=e.extensions[D].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[D]={source:e.source},delete e.source)})}}),this}}M.EXTENSION_NAME=D;const v=[u,T,f,d,S,I,A,j,M];export{x as Clearcoat,p as IOR,v as KHRONOS_EXTENSIONS,i as Light,a as LightType,u as LightsPunctual,T as MaterialsClearcoat,f as MaterialsIOR,d as MaterialsPBRSpecularGlossiness,S as MaterialsSpecular,I as MaterialsTransmission,A as MaterialsUnlit,j as MeshQuantization,m as PBRSpecularGlossiness,C as Specular,M as TextureBasisu,F as Transmission,E as Unlit};
import{Extension as e,PropertyType as t,GLB_BUFFER as s,ExtensionProperty as r,COPY_IDENTITY as o,ColorUtils as n,GraphChild as a}from"@gltf-transform/core";let i;function c(e,t){let s;try{if(s=new i.DecoderBuffer,s.Init(new Int8Array(t),t.byteLength),e.GetEncodedGeometryType(s)!==i.TRIANGULAR_MESH)throw new Error("Unknown geometry type.");const r=new i.Mesh;if(!e.DecodeBufferToMesh(s,r).ok()||0===r.ptr)throw new Error("Decoding failure.");return r}finally{i.destroy(s)}}function u(e,t){const s=t.num_faces(),r=new Uint32Array(3*s),o=new i.DracoInt32Array;for(let n=0;n<s;n++){e.GetFaceFromMesh(t,n,o);for(let e=0;e<3;++e)r[3*n+e]=o.GetValue(e)}return i.destroy(o),r}function l(e,t,s,r){const o=function(e){switch(e){case 5126:return Float32Array;case 5125:return Uint32Array;case 5123:return Uint16Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5120:return Int8Array}}(r.componentType),n=s.num_components(),a=t.num_points()*n;let c,u;switch(o){case Float32Array:c=new i.DracoFloat32Array,e.GetAttributeFloatForAllPoints(t,s,c),u=new Float32Array(a);break;case Int8Array:c=new i.DracoInt8Array,e.GetAttributeInt8ForAllPoints(t,s,c),u=new Int8Array(a);break;case Int16Array:c=new i.DracoInt16Array,e.GetAttributeInt16ForAllPoints(t,s,c),u=new Int16Array(a);break;case Uint8Array:c=new i.DracoUInt8Array,e.GetAttributeUInt8ForAllPoints(t,s,c),u=new Uint8Array(a);break;case Uint16Array:c=new i.DracoUInt16Array,e.GetAttributeUInt16ForAllPoints(t,s,c),u=new Uint16Array(a);break;case Uint32Array:c=new i.DracoUInt32Array,e.GetAttributeUInt32ForAllPoints(t,s,c),u=new Uint32Array(a);break;default:throw new Error("Unexpected attribute type.")}for(let e=0;e<a;e++)u[e]=c.GetValue(e);return i.destroy(c),u}const x="KHR_draco_mesh_compression";class h extends e{constructor(){super(...arguments),this.extensionName=x,this.provideTypes=[t.PRIMITIVE],this.dependencies=["draco3d.decoder"]}install(e,t){return"draco3d.decoder"===e&&(this._decoderModule=t,i=this._decoderModule),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 a of r.json.meshes){for(const i of a.primitives){if(!i.extensions||!i.extensions[x])continue;const a=i.extensions[x];let h=n.get(a.bufferView);if(!h){const e=r.json.bufferViews[a.bufferView],i=r.json.buffers[e.buffer],u=new Uint8Array(i.uri?r.resources[i.uri]:r.resources[s],e.byteOffset||0,e.byteLength);h=c(o,u),n.set(a.bufferView,h),t.debug(`Decompressed ${u.byteLength} bytes.`)}for(const t in i.attributes){const s=e.jsonDoc.json.accessors[i.attributes[t]],r=o.GetAttributeByUniqueId(h,a.attributes[t]),n=l(o,h,r,s);e.accessors[i.attributes[t]].setArray(n)}const T=u(o,h);e.accessors[i.indices].setArray(T)}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 T;h.EXTENSION_NAME=x,function(e){e.POINT="point",e.SPOT="spot",e.DIRECTIONAL="directional"}(T||(T={}));class p 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}}p.EXTENSION_NAME="KHR_lights_punctual";const g="KHR_lights_punctual";class f extends e{constructor(){super(...arguments),this.extensionName=g}createLight(){return new p(this.doc.getGraph(),this)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions[g])return this;const s=(t.json.extensions[g].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[g]&&e.nodes[r].setExtension(g,s[t.extensions[g].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()===T.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(g);if(o){const n=e.nodeIndexMap.get(s),a=t.json.nodes[n];a.extensions=a.extensions||{},a.extensions[g]={light:r.get(o)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[g]={lights:s},this}}function m(e,t,s,r){var o,n=arguments.length,a=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,s,r);else for(var i=e.length-1;i>=0;i--)(o=e[i])&&(a=(n<3?o(a):n>3?o(t,s,a):o(t,s))||a);return n>3&&a&&Object.defineProperty(t,s,a),a}f.EXTENSION_NAME=g;class d 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.clearcoatRoughnessTexture=null,this.clearcoatNormalTexture=null}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.clearcoatTexture.copy(e.clearcoatTexture)),e.clearcoatRoughnessTexture&&(this.setClearcoatRoughnessTexture(t(e.clearcoatRoughnessTexture.getChild())),this.clearcoatRoughnessTexture.copy(e.clearcoatRoughnessTexture)),e.clearcoatNormalTexture&&(this.setClearcoatNormalTexture(t(e.clearcoatNormalTexture.getChild())),this.clearcoatNormalTexture.copy(e.clearcoatNormalTexture)),this}getClearcoatFactor(){return this._clearcoatFactor}setClearcoatFactor(e){return this._clearcoatFactor=e,this}getClearcoatTexture(){return this.clearcoatTexture?this.clearcoatTexture.getChild():null}getClearcoatTextureInfo(){return this.clearcoatTexture?this.clearcoatTexture.textureInfo:null}getClearcoatTextureSampler(){return this.clearcoatTexture?this.clearcoatTexture.sampler:null}setClearcoatTexture(e){return this.clearcoatTexture=this.graph.linkTexture("clearcoatTexture",this,e),this}getClearcoatRoughnessFactor(){return this._clearcoatRoughnessFactor}setClearcoatRoughnessFactor(e){return this._clearcoatRoughnessFactor=e,this}getClearcoatRoughnessTexture(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.getChild():null}getClearcoatRoughnessTextureInfo(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.textureInfo:null}getClearcoatRoughnessTextureSampler(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.sampler:null}setClearcoatRoughnessTexture(e){return this.clearcoatRoughnessTexture=this.graph.linkTexture("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.clearcoatNormalTexture.textureInfo:null}getClearcoatNormalTextureSampler(){return this.clearcoatNormalTexture?this.clearcoatNormalTexture.sampler:null}setClearcoatNormalTexture(e){return this.clearcoatNormalTexture=this.graph.linkTexture("clearcoatNormalTexture",this,e),this}}d.EXTENSION_NAME="KHR_materials_clearcoat",m([a],d.prototype,"clearcoatTexture",void 0),m([a],d.prototype,"clearcoatRoughnessTexture",void 0),m([a],d.prototype,"clearcoatNormalTexture",void 0);const _="KHR_materials_clearcoat";class y extends e{constructor(){super(...arguments),this.extensionName=_}createClearcoat(){return new d(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[_]){const o=this.createClearcoat();if(e.materials[r].setExtension(_,o),void 0!==t.extensions[_].clearcoatFactor&&o.setClearcoatFactor(t.extensions[_].clearcoatFactor),void 0!==t.extensions[_].clearcoatRoughnessFactor&&o.setClearcoatRoughnessFactor(t.extensions[_].clearcoatRoughnessFactor),void 0!==t.extensions[_].clearcoatTexture){const r=t.extensions[_].clearcoatTexture;o.setClearcoatTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getClearcoatTextureInfo(),r),e.setTextureSampler(o.getClearcoatTextureSampler(),r)}if(void 0!==t.extensions[_].clearcoatRoughnessTexture){const r=t.extensions[_].clearcoatRoughnessTexture;o.setClearcoatRoughnessTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getClearcoatRoughnessTextureInfo(),r),e.setTextureSampler(o.getClearcoatRoughnessTextureSampler(),r)}if(void 0!==t.extensions[_].clearcoatNormalTexture){const r=t.extensions[_].clearcoatNormalTexture;o.setClearcoatNormalTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getClearcoatNormalTextureInfo(),r),e.setTextureSampler(o.getClearcoatNormalTextureSampler(),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(_);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[_]={clearcoatFactor:r.getClearcoatFactor(),clearcoatRoughnessFactor:r.getClearcoatRoughnessFactor()},r.getClearcoatTexture()){const t=r.getClearcoatTexture(),s=r.getClearcoatTextureInfo(),o=r.getClearcoatTextureSampler();n.extensions[_].clearcoatTexture=e.createTextureInfoDef(t,s,o)}if(r.getClearcoatRoughnessTexture()){const t=r.getClearcoatRoughnessTexture(),s=r.getClearcoatRoughnessTextureInfo(),o=r.getClearcoatRoughnessTextureSampler();n.extensions[_].clearcoatRoughnessTexture=e.createTextureInfoDef(t,s,o)}if(r.getClearcoatNormalTexture()){const t=r.getClearcoatNormalTexture(),s=r.getClearcoatNormalTextureInfo(),o=r.getClearcoatNormalTextureSampler();n.extensions[_].clearcoatNormalTexture=e.createTextureInfoDef(t,s,o),1!==r.getClearcoatNormalScale()&&(n.extensions[_].clearcoatNormalTexture.scale=r.getClearcoatNormalScale())}}}),this}}y.EXTENSION_NAME=_;class N 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}}N.EXTENSION_NAME="KHR_materials_ior";const I="KHR_materials_ior";class F extends e{constructor(){super(...arguments),this.extensionName=I}createIOR(){return new N(this.doc.getGraph(),this)}read(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{if(t.extensions&&t.extensions[I]){const r=this.createIOR();e.materials[s].setExtension(I,r),void 0!==t.extensions[I].ior&&r.setIOR(t.extensions[I].ior)}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(I);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];n.extensions=n.extensions||{},n.extensions[I]={ior:r.getIOR()}}}),this}}F.EXTENSION_NAME=I;class C 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.specularGlossinessTexture=null}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.diffuseTexture.copy(e.diffuseTexture)),e.specularGlossinessTexture&&(this.setSpecularGlossinessTexture(t(e.specularGlossinessTexture.getChild())),this.specularGlossinessTexture.copy(e.specularGlossinessTexture)),this}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.diffuseTexture.textureInfo:null}getDiffuseTextureSampler(){return this.diffuseTexture?this.diffuseTexture.sampler:null}setDiffuseTexture(e){return this.diffuseTexture=this.graph.linkTexture("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.specularGlossinessTexture.textureInfo:null}getSpecularGlossinessTextureSampler(){return this.specularGlossinessTexture?this.specularGlossinessTexture.sampler:null}setSpecularGlossinessTexture(e){return this.specularGlossinessTexture=this.graph.linkTexture("specularGlossinessTexture",this,e),this}}C.EXTENSION_NAME="KHR_materials_pbrSpecularGlossiness",m([a],C.prototype,"diffuseTexture",void 0),m([a],C.prototype,"specularGlossinessTexture",void 0);const S="KHR_materials_pbrSpecularGlossiness";class R extends e{constructor(){super(...arguments),this.extensionName=S}createPBRSpecularGlossiness(){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[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),e.setTextureSampler(o.getDiffuseTextureSampler(),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),e.setTextureSampler(o.getSpecularGlossinessTextureSampler(),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(),o=r.getDiffuseTextureSampler();n.extensions[S].diffuseTexture=e.createTextureInfoDef(t,s,o)}if(r.getSpecularGlossinessTexture()){const t=r.getSpecularGlossinessTexture(),s=r.getSpecularGlossinessTextureInfo(),o=r.getSpecularGlossinessTextureSampler();n.extensions[S].specularGlossinessTexture=e.createTextureInfoDef(t,s,o)}}}),this}}R.EXTENSION_NAME=S;class A 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}copy(e,t=o){return super.copy(e,t),this._specularFactor=e._specularFactor,e.specularTexture&&(this.setSpecularTexture(t(e.specularTexture.getChild())),this.specularTexture.copy(e.specularTexture)),this}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.specularTexture.textureInfo:null}getSpecularTextureSampler(){return this.specularTexture?this.specularTexture.sampler:null}setSpecularTexture(e){return this.specularTexture=this.graph.linkTexture("specularTexture",this,e),this}}A.EXTENSION_NAME="KHR_materials_specular",m([a],A.prototype,"specularTexture",void 0);const E="KHR_materials_specular";class G extends e{constructor(){super(...arguments),this.extensionName=E}createSpecular(){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[E]){const o=this.createSpecular();if(e.materials[r].setExtension(E,o),void 0!==t.extensions[E].specularFactor&&o.setSpecularFactor(t.extensions[E].specularFactor),void 0!==t.extensions[E].specularColorFactor&&o.setSpecularColorFactor(t.extensions[E].specularColorFactor),void 0!==t.extensions[E].specularTexture){const r=t.extensions[E].specularTexture;o.setSpecularTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getSpecularTextureInfo(),r),e.setTextureSampler(o.getSpecularTextureSampler(),r)}}}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(E);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[E]={specularFactor:r.getSpecularFactor(),specularColorFactor:r.getSpecularColorFactor()},r.getSpecularTexture()){const t=r.getSpecularTexture(),s=r.getSpecularTextureInfo(),o=r.getSpecularTextureSampler();n.extensions[E].specularTexture=e.createTextureInfoDef(t,s,o)}}}),this}}G.EXTENSION_NAME=E;class D extends r{constructor(){super(...arguments),this.propertyType="Transmission",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_transmission",this._transmissionFactor=0,this.transmissionTexture=null}copy(e,t=o){return super.copy(e,t),this._transmissionFactor=e._transmissionFactor,e.transmissionTexture&&(this.setTransmissionTexture(t(e.transmissionTexture.getChild())),this.transmissionTexture.copy(e.transmissionTexture)),this}getTransmissionFactor(){return this._transmissionFactor}setTransmissionFactor(e){return this._transmissionFactor=e,this}getTransmissionTexture(){return this.transmissionTexture?this.transmissionTexture.getChild():null}getTransmissionTextureInfo(){return this.transmissionTexture?this.transmissionTexture.textureInfo:null}getTransmissionTextureSampler(){return this.transmissionTexture?this.transmissionTexture.sampler:null}setTransmissionTexture(e){return this.transmissionTexture=this.graph.linkTexture("transmissionTexture",this,e),this}}D.EXTENSION_NAME="KHR_materials_transmission",m([a],D.prototype,"transmissionTexture",void 0);const w="KHR_materials_transmission";class M extends e{constructor(){super(...arguments),this.extensionName=w}createTransmission(){return new D(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),e.setTextureSampler(o.getTransmissionTextureSampler(),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(),o=r.getTransmissionTextureSampler();n.extensions[w].transmissionTexture=e.createTextureInfoDef(t,s,o)}}}),this}}M.EXTENSION_NAME=w;class j extends r{constructor(){super(...arguments),this.propertyType="Unlit",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_unlit"}}j.EXTENSION_NAME="KHR_materials_unlit";const v="KHR_materials_unlit";class b extends e{constructor(){super(...arguments),this.extensionName=v}createUnlit(){return new j(this.doc.getGraph(),this)}read(e){return(e.jsonDoc.json.materials||[]).forEach((t,s)=>{t.extensions&&t.extensions[v]&&e.materials[s].setExtension(v,this.createUnlit())}),this}write(e){const t=e.jsonDoc;return this.doc.getRoot().listMaterials().forEach(s=>{if(s.getExtension(v)){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{},o.extensions[v]={}}}),this}}b.EXTENSION_NAME=v;const O="KHR_mesh_quantization";class H extends e{constructor(){super(...arguments),this.extensionName=O}read(e){return this}write(e){return this}}H.EXTENSION_NAME=O;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;const X=[h,f,y,F,R,G,M,b,H,K];export{d as Clearcoat,h as DracoMeshCompression,N as IOR,X as KHRONOS_EXTENSIONS,p as Light,T as LightType,f as LightsPunctual,y as MaterialsClearcoat,F as MaterialsIOR,R as MaterialsPBRSpecularGlossiness,G as MaterialsSpecular,M as MaterialsTransmission,b as MaterialsUnlit,H as MeshQuantization,C as PBRSpecularGlossiness,A as Specular,K as TextureBasisu,D as Transmission,j as Unlit};
//# sourceMappingURL=extensions.modern.js.map

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

export declare const KHR_DRACO_MESH_COMPRESSION = "KHR_draco_mesh_compression";
export declare const KHR_LIGHTS_PUNCTUAL = "KHR_lights_punctual";

@@ -2,0 +3,0 @@ export declare const KHR_MATERIALS_CLEARCOAT = "KHR_materials_clearcoat";

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

import { DracoMeshCompression } from './khr-draco-mesh-compression';
import { LightsPunctual } from './khr-lights-punctual';

@@ -10,2 +11,3 @@ import { MaterialsClearcoat } from './khr-materials-clearcoat';

import { TextureBasisu } from './khr-texture-basisu';
export * from './khr-draco-mesh-compression';
export * from './khr-lights-punctual';

@@ -20,2 +22,2 @@ export * from './khr-materials-clearcoat';

export * from './khr-texture-basisu';
export declare const KHRONOS_EXTENSIONS: (typeof LightsPunctual | typeof MaterialsClearcoat | typeof MaterialsIOR | typeof MaterialsPBRSpecularGlossiness | typeof MaterialsSpecular | typeof MaterialsTransmission | typeof MaterialsUnlit | typeof MeshQuantization | typeof TextureBasisu)[];
export declare const KHRONOS_EXTENSIONS: (typeof DracoMeshCompression | typeof LightsPunctual | typeof MaterialsClearcoat | typeof MaterialsIOR | typeof MaterialsPBRSpecularGlossiness | typeof MaterialsSpecular | typeof MaterialsTransmission | typeof MaterialsUnlit | typeof MeshQuantization | typeof TextureBasisu)[];
{
"name": "@gltf-transform/extensions",
"version": "0.7.0-alpha.1",
"version": "0.7.0-alpha.2",
"repository": "github:donmccurdy/glTF-Transform",

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

"dependencies": {
"@gltf-transform/core": "^0.7.0-alpha.1"
"@gltf-transform/core": "^0.7.0-alpha.2"
},

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

],
"gitHead": "86d19f38214db00d61d1da70fc3c18fc4cb34ff3"
"gitHead": "c13e71257c34aaf7a05114d4740e5a2aec375807"
}

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

export const KHR_DRACO_MESH_COMPRESSION = 'KHR_draco_mesh_compression';
export const KHR_LIGHTS_PUNCTUAL = 'KHR_lights_punctual';

@@ -2,0 +3,0 @@ export const KHR_MATERIALS_CLEARCOAT = 'KHR_materials_clearcoat';

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

import { DracoMeshCompression } from './khr-draco-mesh-compression';
import { LightsPunctual } from './khr-lights-punctual';

@@ -11,2 +12,3 @@ import { MaterialsClearcoat } from './khr-materials-clearcoat';

export * from './khr-draco-mesh-compression';
export * from './khr-lights-punctual';

@@ -23,2 +25,3 @@ export * from './khr-materials-clearcoat';

export const KHRONOS_EXTENSIONS = [
DracoMeshCompression,
LightsPunctual,

@@ -25,0 +28,0 @@ MaterialsClearcoat,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc