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

@gltf-transform/extensions

Package Overview
Dependencies
Maintainers
1
Versions
191
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gltf-transform/extensions - npm Package Compare versions

Comparing version 0.5.4 to 0.6.0

dist/cli/src/merge.d.ts

2

dist/core/src/core.d.ts

@@ -6,3 +6,3 @@ export { Document, Transform } from './document';

export { NodeIO, WebIO, ReaderContext, WriterContext } from './io/';
export { BufferUtils, FileUtils, ImageUtils, MathUtils, Logger, uuid } from './utils/';
export { BufferUtils, ColorUtils, FileUtils, ImageUtils, MathUtils, Logger, uuid } from './utils/';
export { PropertyType, vec2, vec3, vec4, mat3, mat4 } from './constants';

@@ -52,5 +52,5 @@ import { Extension, ExtensionConstructor } from './extension';

export declare class Document {
private graph;
private root;
private logger;
private _graph;
private _root;
private _logger;
/** Returns the glTF {@link Root} property. */

@@ -57,0 +57,0 @@ getRoot(): Root;

import { Document } from '../document';
import { Extension } from '../extension';
import { NativeDocument } from '../native-document';
import { Logger } from '../utils/';
import { WriterOptions } from './writer';

@@ -15,3 +16,6 @@ /**

export declare abstract class PlatformIO {
protected _logger: Logger;
protected _extensions: typeof Extension[];
/** Sets the {@link Logger} used by this I/O instance. Defaults to Logger.DEFAULT_INSTANCE. */
setLogger(logger: Logger): this;
/** Registers extensions, enabling I/O class to read and write glTF assets requiring them. */

@@ -18,0 +22,0 @@ registerExtensions(extensions: typeof Extension[]): this;

import { Document } from '../document';
import { Extension } from '../extension';
import { NativeDocument } from '../native-document';
import { Logger } from '../utils';
export interface ReaderOptions {
extensions: (typeof Extension)[];
logger?: Logger;
extensions?: (typeof Extension)[];
}
/** @hidden */
export declare class GLTFReader {
static read(nativeDoc: NativeDocument, options: ReaderOptions): Document;
static read(nativeDoc: NativeDocument, options?: ReaderOptions): Document;
private static validate;
}
import { Document } from '../document';
import { NativeDocument } from '../native-document';
import { Logger } from '../utils';
export interface WriterOptions {
basename: string;
isGLB: boolean;
logger?: Logger;
basename?: string;
isGLB?: boolean;
}
/** @hidden */
export declare class GLTFWriter {
static write(doc: Document, options: WriterOptions): NativeDocument;
static write(doc: Document, options?: WriterOptions): NativeDocument;
}
import { Link } from '../graph';
import { ExtensionProperty, ExtensionPropertyConstructor } from './extension-property';
import { ExtensionProperty } from './extension-property';
import { Property } from './property';

@@ -18,7 +18,6 @@ /**

/**
* Returns the {@link ExtensionProperty} of the given type attached to this Property, if any.
* The ExtensionProperty constructor is used as the lookup token, allowing better type-checking
* in TypeScript environments. *Not available on {@link Root} properties.*
* Returns an {@link ExtensionProperty} attached to this Property, if any. *Not available on
* {@link Root} properties.*
*/
getExtension<Prop extends ExtensionProperty>(ctor: ExtensionPropertyConstructor<Prop>): Prop;
getExtension<Prop extends ExtensionProperty>(name: string): Prop;
/**

@@ -29,3 +28,3 @@ * Attaches the given {@link ExtensionProperty} to this Property. For a given extension, only

*/
setExtension<Prop extends ExtensionProperty>(ctor: ExtensionPropertyConstructor<Prop>, extensionProperty: Prop): this;
setExtension<Prop extends ExtensionProperty>(name: string, extensionProperty: Prop): this;
/**

@@ -32,0 +31,0 @@ * Lists all {@link ExtensionProperty} instances attached to this Property. *Not available on

@@ -10,11 +10,2 @@ import { ExtensibleProperty } from './extensible-property';

/**
* Type alias allowing ExtensionProperty constructors to be used as tokens when calling
* property.getExtension(...) or property.setExtension(...), enabling type checking.
* @hidden
*/
export declare type ExtensionPropertyConstructor<Prop> = {
new (graph: PropertyGraph, extension: ExtensionPropertyParent): Prop;
EXTENSION_NAME: string;
};
/**
* # ExtensionProperty

@@ -21,0 +12,0 @@ *

@@ -100,2 +100,6 @@ import { PropertyType, vec3, vec4 } from '../constants';

*/
/** Returns material alpha, equivalent to baseColorFactor[3]. */
getAlpha(): number;
/** Sets material alpha, equivalent to baseColorFactor[3]. */
setAlpha(alpha: number): this;
/**

@@ -132,7 +136,17 @@ * Returns the mode of the material's alpha channels, which are provided by `baseColorFactor`

*/
/** Base color / albedo; linear multiplier. See {@link getBaseColorTexture}. */
/** Base color / albedo factor in linear space. See {@link getBaseColorTexture}. */
getBaseColorFactor(): vec4;
/** Sets the base color / albedo; linear multiplier. See {@link getBaseColorTexture}. */
/** Sets the base color / albedo factor in linear space. See {@link getBaseColorTexture}. */
setBaseColorFactor(baseColorFactor: vec4): this;
/**
* Base color / albedo as hexadecimal in sRGB colorspace. Converted automatically from
* baseColorFactor in linear space. See {@link getBaseColorTexture}.
*/
getBaseColorHex(): number;
/**
* Sets base color / albedo as hexadecimal in sRGB colorspace. Converted automatically to
* baseColorFactor in linear space. See {@link getBaseColorTexture}.
*/
setBaseColorHex(hex: number): this;
/**
* Base color / albedo. The visible color of a non-metallic surface under constant ambient

@@ -168,2 +182,12 @@ * light would be a linear combination (multiplication) of its vertex colors, base color

/**
* Emissive as hexadecimal in sRGB colorspace. Converted automatically from
* emissiveFactor in linear space. See {@link getBaseColorTexture}.
*/
getEmissiveHex(): number;
/**
* Sets emissive as hexadecimal in sRGB colorspace. Converted automatically to
* emissiveFactor in linear space. See {@link getEmissiveTexture}.
*/
setEmissiveHex(hex: number): this;
/**
* Emissive texture. Emissive color is added to any base color of the material, after any

@@ -170,0 +194,0 @@ * lighting/shadowing are applied. An emissive color does not inherently "glow", or affect

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

import { PropertyType, vec3, vec4 } from '../constants';
import { PropertyType, mat4, vec3, vec4 } from '../constants';
import { Camera } from './camera';

@@ -40,2 +40,4 @@ import { ExtensibleProperty } from './extensible-property';

private _weights;
/** @hidden Internal reference to node's parent, omitted from {@link Graph}. */
_parent: SceneNode;
private camera;

@@ -46,2 +48,5 @@ private mesh;

copy(other: this, resolve?: <T extends import("./property").Property>(t: T) => T): this;
/**********************************************************************************************
* Local transform.
*/
/** Returns the translation (position) of this node in local space. */

@@ -59,2 +64,18 @@ getTranslation(): vec3;

setScale(scale: vec3): this;
/** Returns the local matrix of this node. */
getMatrix(): mat4;
/**********************************************************************************************
* World transform.
*/
/** Returns the translation (position) of this node in world space. */
getWorldTranslation(): vec3;
/** Returns the rotation (quaternion) of this node in world space. */
getWorldRotation(): vec4;
/** Returns the scale of this node in world space. */
getWorldScale(): vec3;
/** Returns the world matrix of this node. */
getWorldMatrix(): mat4;
/**********************************************************************************************
* Scene hierarchy.
*/
/** Adds another node as a child of this one. Nodes cannot have multiple parents. */

@@ -66,2 +87,10 @@ addChild(child: Node): this;

listChildren(): Node[];
/**
* Returns the unique parent ({@link Scene}, {@link Node}, or null) of this node in the scene
* hierarchy. Unrelated to {@link Property.listParents}, which lists all resource references.
*/
getParent(): SceneNode;
/**********************************************************************************************
* Attachments.
*/
/** Returns the {@link Mesh}, if any, instantiated at this node. */

@@ -92,2 +121,13 @@ getMesh(): Mesh;

setWeights(weights: number[]): this;
/**********************************************************************************************
* Helpers.
*/
/** Visits this {@link Node} and its descendants, top-down. */
traverse(fn: (node: Node) => void): this;
}
interface SceneNode {
_parent?: SceneNode;
addChild(node: Node): this;
removeChild(node: Node): this;
}
export {};

@@ -66,5 +66,11 @@ import { GraphNode } from '../graph';

*/
/** @hidden */
/**
* Returns a reference to the Extras object, containing application-specific data for this
* Property. Extras should be an Object, not a primitive value, for best portability.
*/
getExtras(): object;
/** @hidden */
/**
* Updates the Extras object, containing application-specific data for this Property. Extras
* should be an Object, not a primitive value, for best portability.
*/
setExtras(extras: object): this;

@@ -71,0 +77,0 @@ /**********************************************************************************************

@@ -37,3 +37,3 @@ import { PropertyType } from '../constants';

* const node = document.createNode('myNode');
* scene.addNode(node);
* scene.addChild(node);
*

@@ -40,0 +40,0 @@ * console.log(root.listScenes()); // → [scene x 1]

@@ -22,10 +22,12 @@ import { PropertyType } from '../constants';

readonly propertyType = PropertyType.SCENE;
private nodes;
private children;
copy(other: this, resolve?: <T extends import("./property").Property>(t: T) => T): this;
/** Adds a {@link Node} to the scene. */
addNode(node: Node): this;
addChild(node: Node): this;
/** Removes a {@link Node} from the scene. */
removeNode(node: Node): this;
/** Lists all {@link Node}s in the scene. */
listNodes(): Node[];
removeChild(node: Node): this;
/** Lists all root {@link Node}s in the scene. */
listChildren(): Node[];
/** Visits each {@link Node} in the scene, including descendants, top-down. */
traverse(fn: (node: Node) => void): this;
}
export * from './buffer-utils';
export * from './color-utils';
export * from './file-utils';

@@ -3,0 +4,0 @@ export * from './image-utils';

@@ -25,2 +25,4 @@ /**

};
/** Default logger instance. */
static DEFAULT_INSTANCE: Logger;
/** Constructs a new Logger instance. */

@@ -27,0 +29,0 @@ constructor(verbosity: number);

@@ -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.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",a=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=o,t}r(t,e);var a=t.prototype;return a.createLight=function(){return new n(this.doc.getGraph(),this)},a.read=function(e){var t=this,r=e.nativeDocument;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(n,s[t.extensions[o].light])}),this},a.write=function(e){var t=e.nativeDocument;if(0===this.properties.size)return this;for(var r,a=[],i=new Map,u=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=u()).done;){var c=r.value,l={type:c.getType(),color:c.getColor(),intensity:c.getIntensity(),range:c.getRange()};c.getName()&&(l.name=c.getName()),c.getType()===exports.LightType.SPOT&&(l.innerConeAngle=c.getInnerConeAngle(),l.outerConeAngle=c.getOuterConeAngle()),a.push(l),i.set(c,a.length-1)}return this.doc.getRoot().listNodes().forEach(function(r){var s=r.getExtension(n);if(s){var a=e.nodeIndexMap.get(r),u=t.json.nodes[a];u.extensions=u.extensions||{},u.extensions[o]={light:i.get(s)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[o]={lights:a},this},t}(t.Extension);function i(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}a.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",i([t.GraphChild],u.prototype,"clearcoatTexture",void 0),i([t.GraphChild],u.prototype,"clearcoatRoughnessTexture",void 0),i([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.nativeDocument,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(u,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 a=r.extensions[c].clearcoatTexture;o.setClearcoatTexture(e.textures[s[a.index].source]),e.setTextureInfo(o.getClearcoatTextureInfo(),a),e.setTextureSampler(o.getClearcoatTextureSampler(),a)}if(void 0!==r.extensions[c].clearcoatRoughnessTexture){var i=r.extensions[c].clearcoatRoughnessTexture;o.setClearcoatRoughnessTexture(e.textures[s[i.index].source]),e.setTextureInfo(o.getClearcoatRoughnessTextureInfo(),i),e.setTextureSampler(o.getClearcoatRoughnessTextureSampler(),i)}if(void 0!==r.extensions[c].clearcoatNormalTexture){var l=r.extensions[c].clearcoatNormalTexture;o.setClearcoatNormalTexture(e.textures[s[l.index].source]),e.setTextureInfo(o.getClearcoatNormalTextureInfo(),l),e.setTextureSampler(o.getClearcoatNormalTextureSampler(),l),void 0!==l.scale&&o.setClearcoatNormalScale(l.scale)}}}),this},s.write=function(e){var t=e.nativeDocument;return this.doc.getRoot().listMaterials().forEach(function(r){var s=r.getExtension(u);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 a=s.getClearcoatTexture(),i=s.getClearcoatTextureInfo(),l=s.getClearcoatTextureSampler();o.extensions[c].clearcoatTexture=e.createTextureInfoDef(a,i,l)}if(s.getClearcoatRoughnessTexture()){var x=s.getClearcoatRoughnessTexture(),p=s.getClearcoatRoughnessTextureInfo(),h=s.getClearcoatRoughnessTextureSampler();o.extensions[c].clearcoatRoughnessTexture=e.createTextureInfoDef(x,p,h)}if(s.getClearcoatNormalTexture()){var f=s.getClearcoatNormalTexture(),T=s.getClearcoatNormalTextureInfo(),g=s.getClearcoatNormalTextureSampler();o.extensions[c].clearcoatNormalTexture=e.createTextureInfoDef(f,T,g),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.nativeDocument.json.materials||[]).forEach(function(r,s){if(r.extensions&&r.extensions[p]){var n=t.createIOR();e.materials[s].setExtension(x,n),void 0!==r.extensions[p].ior&&n.setIOR(r.extensions[p].ior)}}),this},s.write=function(e){var t=e.nativeDocument;return this.doc.getRoot().listMaterials().forEach(function(r){var s=r.getExtension(x);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.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",i([t.GraphChild],f.prototype,"diffuseTexture",void 0),i([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.nativeDocument,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(f,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 a=r.extensions[T].diffuseTexture;o.setDiffuseTexture(e.textures[s[a.index].source]),e.setTextureInfo(o.getDiffuseTextureInfo(),a),e.setTextureSampler(o.getDiffuseTextureSampler(),a)}if(void 0!==r.extensions[T].specularGlossinessTexture){var i=r.extensions[T].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.nativeDocument;return this.doc.getRoot().listMaterials().forEach(function(r){var s=r.getExtension(f);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 a=s.getDiffuseTexture(),i=s.getDiffuseTextureInfo(),u=s.getDiffuseTextureSampler();o.extensions[T].diffuseTexture=e.createTextureInfoDef(a,i,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.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",i([t.GraphChild],m.prototype,"specularTexture",void 0);var v="KHR_materials_specular",y=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=v,t}r(t,e);var s=t.prototype;return s.createSpecular=function(){return new m(this.doc.getGraph(),this)},s.read=function(e){var t=this,r=e.nativeDocument,s=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,n){if(r.extensions&&r.extensions[v]){var o=t.createSpecular();if(e.materials[n].setExtension(m,o),void 0!==r.extensions[v].specularFactor&&o.setSpecularFactor(r.extensions[v].specularFactor),void 0!==r.extensions[v].specularColorFactor&&o.setSpecularColorFactor(r.extensions[v].specularColorFactor),void 0!==r.extensions[v].specularTexture){var a=r.extensions[v].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.nativeDocument;return this.doc.getRoot().listMaterials().forEach(function(r){var s=r.getExtension(m);if(s){var n=e.materialIndexMap.get(r),o=t.json.materials[n];if(o.extensions=o.extensions||{},o.extensions[v]={specularFactor:s.getSpecularFactor(),specularColorFactor:s.getSpecularColorFactor()},s.getSpecularTexture()){var a=s.getSpecularTexture(),i=s.getSpecularTextureInfo(),u=s.getSpecularTextureSampler();o.extensions[v].specularTexture=e.createTextureInfoDef(a,i,u)}}}),this},t}(t.Extension);y.EXTENSION_NAME=v;var _=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);_.EXTENSION_NAME="KHR_materials_transmission",i([t.GraphChild],_.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 _(this.doc.getGraph(),this)},s.read=function(e){var t=this,r=e.nativeDocument,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(_,o),void 0!==r.extensions[d].transmissionFactor&&o.setTransmissionFactor(r.extensions[d].transmissionFactor),void 0!==r.extensions[d].transmissionTexture){var a=r.extensions[d].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.nativeDocument;return this.doc.getRoot().listMaterials().forEach(function(r){var s=r.getExtension(_);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 a=s.getTransmissionTexture(),i=s.getTransmissionTextureInfo(),u=s.getTransmissionTextureSampler();o.extensions[d].transmissionTexture=e.createTextureInfoDef(a,i,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 E="KHR_materials_unlit",S=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=E,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.nativeDocument.json.materials||[]).forEach(function(r,s){r.extensions&&r.extensions[E]&&e.materials[s].setExtension(N,t.createUnlit())}),this},s.write=function(e){var t=e.nativeDocument;return this.doc.getRoot().listMaterials().forEach(function(r){if(r.getExtension(N)){var s=e.materialIndexMap.get(r),n=t.json.materials[s];n.extensions=n.extensions||{},n.extensions[E]={}}}),this},t}(t.Extension);S.EXTENSION_NAME=E;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.nativeDocument.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.nativeDocument;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=[a,l,h,g,y,C,S,R,A];exports.Clearcoat=u,exports.IOR=x,exports.KHRONOS_EXTENSIONS=G,exports.Light=n,exports.LightsPunctual=a,exports.MaterialsClearcoat=l,exports.MaterialsIOR=h,exports.MaterialsPBRSpecularGlossiness=g,exports.MaterialsSpecular=y,exports.MaterialsTransmission=C,exports.MaterialsUnlit=S,exports.MeshQuantization=R,exports.PBRSpecularGlossiness=f,exports.Specular=m,exports.TextureBasisu=A,exports.Transmission=_,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}(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.nativeDocument;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.nativeDocument;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.nativeDocument,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.nativeDocument;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.nativeDocument.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.nativeDocument;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.nativeDocument,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.nativeDocument;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 v="KHR_materials_specular",y=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).extensionName=v,t}r(t,e);var s=t.prototype;return s.createSpecular=function(){return new m(this.doc.getGraph(),this)},s.read=function(e){var t=this,r=e.nativeDocument,s=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,n){if(r.extensions&&r.extensions[v]){var o=t.createSpecular();if(e.materials[n].setExtension(v,o),void 0!==r.extensions[v].specularFactor&&o.setSpecularFactor(r.extensions[v].specularFactor),void 0!==r.extensions[v].specularColorFactor&&o.setSpecularColorFactor(r.extensions[v].specularColorFactor),void 0!==r.extensions[v].specularTexture){var i=r.extensions[v].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.nativeDocument;return this.doc.getRoot().listMaterials().forEach(function(r){var s=r.getExtension(v);if(s){var n=e.materialIndexMap.get(r),o=t.json.materials[n];if(o.extensions=o.extensions||{},o.extensions[v]={specularFactor:s.getSpecularFactor(),specularColorFactor:s.getSpecularColorFactor()},s.getSpecularTexture()){var i=s.getSpecularTexture(),a=s.getSpecularTextureInfo(),u=s.getSpecularTextureSampler();o.extensions[v].specularTexture=e.createTextureInfoDef(i,a,u)}}}),this},t}(t.Extension);y.EXTENSION_NAME=v;var _=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);_.EXTENSION_NAME="KHR_materials_transmission",a([t.GraphChild],_.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 _(this.doc.getGraph(),this)},s.read=function(e){var t=this,r=e.nativeDocument,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.nativeDocument;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.nativeDocument.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.nativeDocument;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.nativeDocument.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.nativeDocument;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,y,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=y,exports.MaterialsTransmission=C,exports.MaterialsUnlit=E,exports.MeshQuantization=R,exports.PBRSpecularGlossiness=f,exports.Specular=m,exports.TextureBasisu=A,exports.Transmission=_,exports.Unlit=N;
//# sourceMappingURL=extensions.js.map

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

import{ExtensionProperty as e,PropertyType as t,COPY_IDENTITY as s,Extension as r,GraphChild as o}from"@gltf-transform/core";var n;!function(e){e.POINT="point",e.SPOT="spot",e.DIRECTIONAL="directional"}(n||(n={}));class a 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}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}}a.EXTENSION_NAME="KHR_lights_punctual";const i="KHR_lights_punctual";class u extends r{constructor(){super(...arguments),this.extensionName=i}createLight(){return new a(this.doc.getGraph(),this)}read(e){const t=e.nativeDocument;if(!t.json.extensions||!t.json.extensions[i])return this;const s=(t.json.extensions[i].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[i]&&e.nodes[r].setExtension(a,s[t.extensions[i].light])}),this}write(e){const t=e.nativeDocument;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()===n.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(a);if(o){const n=e.nodeIndexMap.get(s),a=t.json.nodes[n];a.extensions=a.extensions||{},a.extensions[i]={light:r.get(o)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[i]={lights:s},this}}function c(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=i;class l 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}}l.EXTENSION_NAME="KHR_materials_clearcoat",c([o],l.prototype,"clearcoatTexture",void 0),c([o],l.prototype,"clearcoatRoughnessTexture",void 0),c([o],l.prototype,"clearcoatNormalTexture",void 0);const x="KHR_materials_clearcoat";class h extends r{constructor(){super(...arguments),this.extensionName=x}createClearcoat(){return new l(this.doc.getGraph(),this)}read(e){const t=e.nativeDocument,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,r)=>{if(t.extensions&&t.extensions[x]){const o=this.createClearcoat();if(e.materials[r].setExtension(l,o),void 0!==t.extensions[x].clearcoatFactor&&o.setClearcoatFactor(t.extensions[x].clearcoatFactor),void 0!==t.extensions[x].clearcoatRoughnessFactor&&o.setClearcoatRoughnessFactor(t.extensions[x].clearcoatRoughnessFactor),void 0!==t.extensions[x].clearcoatTexture){const r=t.extensions[x].clearcoatTexture;o.setClearcoatTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getClearcoatTextureInfo(),r),e.setTextureSampler(o.getClearcoatTextureSampler(),r)}if(void 0!==t.extensions[x].clearcoatRoughnessTexture){const r=t.extensions[x].clearcoatRoughnessTexture;o.setClearcoatRoughnessTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getClearcoatRoughnessTextureInfo(),r),e.setTextureSampler(o.getClearcoatRoughnessTextureSampler(),r)}if(void 0!==t.extensions[x].clearcoatNormalTexture){const r=t.extensions[x].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.nativeDocument;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(l);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[x]={clearcoatFactor:r.getClearcoatFactor(),clearcoatRoughnessFactor:r.getClearcoatRoughnessFactor()},r.getClearcoatTexture()){const t=r.getClearcoatTexture(),s=r.getClearcoatTextureInfo(),o=r.getClearcoatTextureSampler();n.extensions[x].clearcoatTexture=e.createTextureInfoDef(t,s,o)}if(r.getClearcoatRoughnessTexture()){const t=r.getClearcoatRoughnessTexture(),s=r.getClearcoatRoughnessTextureInfo(),o=r.getClearcoatRoughnessTextureSampler();n.extensions[x].clearcoatRoughnessTexture=e.createTextureInfoDef(t,s,o)}if(r.getClearcoatNormalTexture()){const t=r.getClearcoatNormalTexture(),s=r.getClearcoatNormalTextureInfo(),o=r.getClearcoatNormalTextureSampler();n.extensions[x].clearcoatNormalTexture=e.createTextureInfoDef(t,s,o),1!==r.getClearcoatNormalScale()&&(n.extensions[x].clearcoatNormalTexture.scale=r.getClearcoatNormalScale())}}}),this}}h.EXTENSION_NAME=x;class T 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}}T.EXTENSION_NAME="KHR_materials_ior";const p="KHR_materials_ior";class g extends r{constructor(){super(...arguments),this.extensionName=p}createIOR(){return new T(this.doc.getGraph(),this)}read(e){return(e.nativeDocument.json.materials||[]).forEach((t,s)=>{if(t.extensions&&t.extensions[p]){const r=this.createIOR();e.materials[s].setExtension(T,r),void 0!==t.extensions[p].ior&&r.setIOR(t.extensions[p].ior)}}),this}write(e){const t=e.nativeDocument;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(T);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];n.extensions=n.extensions||{},n.extensions[p]={ior:r.getIOR()}}}),this}}g.EXTENSION_NAME=p;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}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",c([o],m.prototype,"diffuseTexture",void 0),c([o],m.prototype,"specularGlossinessTexture",void 0);const f="KHR_materials_pbrSpecularGlossiness";class _ extends r{constructor(){super(...arguments),this.extensionName=f}createPBRSpecularGlossiness(){return new m(this.doc.getGraph(),this)}read(e){const t=e.nativeDocument,s=t.json.textures||[];return(t.json.materials||[]).forEach((t,r)=>{if(t.extensions&&t.extensions[f]){const o=this.createPBRSpecularGlossiness();if(e.materials[r].setExtension(m,o),void 0!==t.extensions[f].diffuseFactor&&o.setDiffuseFactor(t.extensions[f].diffuseFactor),void 0!==t.extensions[f].specularFactor&&o.setSpecularFactor(t.extensions[f].specularFactor),void 0!==t.extensions[f].glossinessFactor&&o.setGlossinessFactor(t.extensions[f].glossinessFactor),void 0!==t.extensions[f].diffuseTexture){const r=t.extensions[f].diffuseTexture;o.setDiffuseTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getDiffuseTextureInfo(),r),e.setTextureSampler(o.getDiffuseTextureSampler(),r)}if(void 0!==t.extensions[f].specularGlossinessTexture){const r=t.extensions[f].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.nativeDocument;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(m);if(r){const o=e.materialIndexMap.get(s),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[f]={diffuseFactor:r.getDiffuseFactor(),specularFactor:r.getSpecularFactor(),glossinessFactor:r.getGlossinessFactor()},r.getDiffuseTexture()){const t=r.getDiffuseTexture(),s=r.getDiffuseTextureInfo(),o=r.getDiffuseTextureSampler();n.extensions[f].diffuseTexture=e.createTextureInfoDef(t,s,o)}if(r.getSpecularGlossinessTexture()){const t=r.getSpecularGlossinessTexture(),s=r.getSpecularGlossinessTextureInfo(),o=r.getSpecularGlossinessTextureSampler();n.extensions[f].specularGlossinessTexture=e.createTextureInfoDef(t,s,o)}}}),this}}_.EXTENSION_NAME=f;class d 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}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}}d.EXTENSION_NAME="KHR_materials_specular",c([o],d.prototype,"specularTexture",void 0);const N="KHR_materials_specular";class C extends r{constructor(){super(...arguments),this.extensionName=N}createSpecular(){return new d(this.doc.getGraph(),this)}read(e){const t=e.nativeDocument,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(d,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.nativeDocument;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(d);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}}C.EXTENSION_NAME=N;class S 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}}S.EXTENSION_NAME="KHR_materials_transmission",c([o],S.prototype,"transmissionTexture",void 0);const R="KHR_materials_transmission";class F extends r{constructor(){super(...arguments),this.extensionName=R}createTransmission(){return new S(this.doc.getGraph(),this)}read(e){const t=e.nativeDocument,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(S,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.nativeDocument;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[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}}F.EXTENSION_NAME=R;class I extends e{constructor(){super(...arguments),this.propertyType="Unlit",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_unlit"}}I.EXTENSION_NAME="KHR_materials_unlit";const E="KHR_materials_unlit";class y extends r{constructor(){super(...arguments),this.extensionName=E}createUnlit(){return new I(this.doc.getGraph(),this)}read(e){return(e.nativeDocument.json.materials||[]).forEach((t,s)=>{t.extensions&&t.extensions[E]&&e.materials[s].setExtension(I,this.createUnlit())}),this}write(e){const t=e.nativeDocument;return this.doc.getRoot().listMaterials().forEach(s=>{if(s.getExtension(I)){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{},o.extensions[E]={}}}),this}}y.EXTENSION_NAME=E;const A="KHR_mesh_quantization";class v extends r{constructor(){super(...arguments),this.extensionName=A}read(e){return this}write(e){return this}}v.EXTENSION_NAME=A;const G="KHR_texture_basisu";class D extends r{constructor(){super(...arguments),this.extensionName=G,this.provideTypes=[t.TEXTURE]}provide(e){return e.nativeDocument.json.textures.forEach(e=>{e.extensions&&e.extensions[G]&&(e.source=e.extensions[G].source)}),this}read(e){return this}write(e){const t=e.nativeDocument;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[G]={source:e.source},delete e.source)})}}),this}}D.EXTENSION_NAME=G;const M=[u,h,g,_,C,F,y,v,D];export{l as Clearcoat,T as IOR,M as KHRONOS_EXTENSIONS,a as Light,n as LightType,u as LightsPunctual,h as MaterialsClearcoat,g as MaterialsIOR,_ as MaterialsPBRSpecularGlossiness,C as MaterialsSpecular,F as MaterialsTransmission,y as MaterialsUnlit,v as MeshQuantization,m as PBRSpecularGlossiness,d as Specular,D as TextureBasisu,S as Transmission,I as Unlit};
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 u="KHR_lights_punctual";class c extends o{constructor(){super(...arguments),this.extensionName=u}createLight(){return new i(this.doc.getGraph(),this)}read(e){const t=e.nativeDocument;if(!t.json.extensions||!t.json.extensions[u])return this;const s=(t.json.extensions[u].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[u]&&e.nodes[r].setExtension(u,s[t.extensions[u].light])}),this}write(e){const t=e.nativeDocument;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(u);if(o){const n=e.nodeIndexMap.get(s),a=t.json.nodes[n];a.extensions=a.extensions||{},a.extensions[u]={light:r.get(o)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[u]={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}c.EXTENSION_NAME=u;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.nativeDocument,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.nativeDocument;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 m extends o{constructor(){super(...arguments),this.extensionName=g}createIOR(){return new p(this.doc.getGraph(),this)}read(e){return(e.nativeDocument.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.nativeDocument;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}}m.EXTENSION_NAME=g;class f 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}}f.EXTENSION_NAME="KHR_materials_pbrSpecularGlossiness",l([n],f.prototype,"diffuseTexture",void 0),l([n],f.prototype,"specularGlossinessTexture",void 0);const _="KHR_materials_pbrSpecularGlossiness";class d extends o{constructor(){super(...arguments),this.extensionName=_}createPBRSpecularGlossiness(){return new f(this.doc.getGraph(),this)}read(e){const t=e.nativeDocument,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.nativeDocument;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.nativeDocument,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.nativeDocument;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.nativeDocument,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.nativeDocument;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.nativeDocument.json.materials||[]).forEach((t,s)=>{t.extensions&&t.extensions[y]&&e.materials[s].setExtension(y,this.createUnlit())}),this}write(e){const t=e.nativeDocument;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 v="KHR_mesh_quantization";class G extends o{constructor(){super(...arguments),this.extensionName=v}read(e){return this}write(e){return this}}G.EXTENSION_NAME=v;const D="KHR_texture_basisu";class M extends o{constructor(){super(...arguments),this.extensionName=D,this.provideTypes=[t.TEXTURE]}provide(e){return e.nativeDocument.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.nativeDocument;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 O=[c,T,m,d,S,I,A,G,M];export{x as Clearcoat,p as IOR,O as KHRONOS_EXTENSIONS,i as Light,a as LightType,c as LightsPunctual,T as MaterialsClearcoat,m as MaterialsIOR,d as MaterialsPBRSpecularGlossiness,S as MaterialsSpecular,I as MaterialsTransmission,A as MaterialsUnlit,G as MeshQuantization,f as PBRSpecularGlossiness,C as Specular,M as TextureBasisu,F as Transmission,E as Unlit};
//# sourceMappingURL=extensions.modern.js.map

@@ -23,6 +23,10 @@ import { ExtensionProperty, PropertyType, vec3 } from '@gltf-transform/core';

*/
/** RGB value for light's color in linear space.. */
/** Components (R, G, B) of light's color in linear space. */
getColor(): vec3;
/** RGB value for light's color in linear space.. */
/** Components (R, G, B) of light's color in linear space. */
setColor(color: vec3): this;
/** Hex light color in sRGB colorspace. */
getColorHex(): number;
/** Hex light color in sRGB colorspace. */
setColorHex(hex: number): this;
/**********************************************************************************************

@@ -29,0 +33,0 @@ * INTENSITY.

@@ -21,2 +21,6 @@ import { ExtensionProperty, PropertyType, Texture, TextureInfo, TextureSampler, vec3, vec4 } from '@gltf-transform/core';

setDiffuseFactor(diffuseFactor: vec4): this;
/** Diffuse; hex color in sRGB colorspace. */
getDiffuseHex(): number;
/** Diffuse; hex color in sRGB colorspace. */
setDiffuseHex(hex: number): this;
/**

@@ -23,0 +27,0 @@ * Diffuse texture; linear multiplier. Alternative to baseColorTexture used within the

@@ -19,6 +19,10 @@ import { ExtensionProperty, PropertyType, Texture, TextureInfo, TextureSampler, vec3 } from '@gltf-transform/core';

setSpecularFactor(specularFactor: number): this;
/** Specular color; linear multiplier. See {@link getSpecularTexture}. */
/** Specular color; components in linear space. See {@link getSpecularTexture}. */
getSpecularColorFactor(): vec3;
/** Specular color; linear multiplier. See {@link getSpecularTexture}. */
/** Specular color; components in linear space. See {@link getSpecularTexture}. */
setSpecularColorFactor(specularColorFactor: vec3): this;
/** Specular color; hexadecimal in sRGB colorspace. See {@link getSpecularTexture} */
getSpecularColorHex(): number;
/** Specular color; hexadecimal in sRGB colorspace. See {@link getSpecularTexture} */
setSpecularColorHex(hex: number): this;
/**

@@ -25,0 +29,0 @@ * Specular texture; linear multiplier. Configures the strength of the specular reflection in

{
"name": "@gltf-transform/extensions",
"version": "0.5.4",
"version": "0.6.0",
"repository": "github:donmccurdy/glTF-Transform",

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

"dependencies": {
"@gltf-transform/core": "^0.5.4"
"@gltf-transform/core": "^0.6.0"
},

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

],
"gitHead": "9122dbc2f611621270aadd9759876faddc0b689f"
"gitHead": "ed6c21760264b5103036dfed2f6add6bed6ba427"
}

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

import { Light, LightsPunctual } from './khr-lights-punctual';
import { LightsPunctual } from './khr-lights-punctual';
import { MaterialsClearcoat } from './khr-materials-clearcoat';

@@ -3,0 +3,0 @@ import { MaterialsIOR } from './khr-materials-ior';

import { COPY_IDENTITY, ExtensionProperty, PropertyType, vec3 } from '@gltf-transform/core';
import { ColorUtils } from '@gltf-transform/core';
import { KHR_LIGHTS_PUNCTUAL } from '../constants';

@@ -43,6 +44,6 @@

/** RGB value for light's color in linear space.. */
/** Components (R, G, B) of light's color in linear space. */
public getColor(): vec3 { return this._color; }
/** RGB value for light's color in linear space.. */
/** Components (R, G, B) of light's color in linear space. */
public setColor(color: vec3): this {

@@ -53,2 +54,11 @@ this._color = color;

/** Hex light color in sRGB colorspace. */
public getColorHex(): number { return ColorUtils.factorToHex(this._color); }
/** Hex light color in sRGB colorspace. */
public setColorHex(hex: number): this {
ColorUtils.hexToFactor(hex, this._color);
return this;
}
/**********************************************************************************************

@@ -55,0 +65,0 @@ * INTENSITY.

@@ -43,3 +43,3 @@ import { Extension, ReaderContext, WriterContext } from '@gltf-transform/core';

if (!nodeDef.extensions || !nodeDef.extensions[NAME]) return;
context.nodes[nodeIndex].setExtension(Light, lights[nodeDef.extensions[NAME].light]);
context.nodes[nodeIndex].setExtension(NAME, lights[nodeDef.extensions[NAME].light]);
});

@@ -81,3 +81,3 @@

.forEach((node) => {
const light = node.getExtension(Light);
const light = node.getExtension<Light>(NAME);
if (light) {

@@ -84,0 +84,0 @@ const nodeIndex = context.nodeIndexMap.get(node);

@@ -23,3 +23,3 @@ import { Extension, ReaderContext, WriterContext } from '@gltf-transform/core';

const clearcoat = this.createClearcoat();
context.materials[materialIndex].setExtension(Clearcoat, clearcoat);
context.materials[materialIndex].setExtension(NAME, clearcoat);

@@ -73,3 +73,3 @@ // Factors.

.forEach((material) => {
const clearcoat = material.getExtension(Clearcoat);
const clearcoat = material.getExtension<Clearcoat>(NAME);
if (clearcoat) {

@@ -76,0 +76,0 @@ const materialIndex = context.materialIndexMap.get(material);

@@ -19,7 +19,6 @@ import { Extension, ReaderContext, WriterContext } from '@gltf-transform/core';

const materialDefs = nativeDoc.json.materials || [];
const textureDefs = nativeDoc.json.textures || [];
materialDefs.forEach((materialDef, materialIndex) => {
if (materialDef.extensions && materialDef.extensions[NAME]) {
const ior = this.createIOR();
context.materials[materialIndex].setExtension(IOR, ior);
context.materials[materialIndex].setExtension(NAME, ior);

@@ -43,3 +42,3 @@ // Factors.

.forEach((material) => {
const ior = material.getExtension(IOR);
const ior = material.getExtension<IOR>(NAME);
if (ior) {

@@ -46,0 +45,0 @@ const materialIndex = context.materialIndexMap.get(material);

@@ -23,3 +23,3 @@ import { Extension, ReaderContext, WriterContext } from '@gltf-transform/core';

const specGloss = this.createPBRSpecularGlossiness();
context.materials[materialIndex].setExtension(PBRSpecularGlossiness, specGloss);
context.materials[materialIndex].setExtension(NAME, specGloss);

@@ -66,3 +66,3 @@ // Factors.

.forEach((material) => {
const specGloss = material.getExtension(PBRSpecularGlossiness);
const specGloss = material.getExtension<PBRSpecularGlossiness>(NAME);
if (specGloss) {

@@ -69,0 +69,0 @@ const materialIndex = context.materialIndexMap.get(material);

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

import { COPY_IDENTITY, ExtensionProperty, GraphChild, PropertyType, Texture, TextureInfo, TextureLink, TextureSampler, vec3, vec4 } from '@gltf-transform/core';
import { COPY_IDENTITY, ColorUtils, ExtensionProperty, GraphChild, PropertyType, Texture, TextureInfo, TextureLink, TextureSampler, vec3, vec4 } from '@gltf-transform/core';
import { KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS } from '../constants';

@@ -51,2 +51,11 @@

/** Diffuse; hex color in sRGB colorspace. */
public getDiffuseHex(): number { return ColorUtils.factorToHex(this._diffuseFactor); }
/** Diffuse; hex color in sRGB colorspace. */
public setDiffuseHex(hex: number): this {
ColorUtils.hexToFactor(hex, this._diffuseFactor);
return this;
}
/**

@@ -53,0 +62,0 @@ * Diffuse texture; linear multiplier. Alternative to baseColorTexture used within the

@@ -23,3 +23,3 @@ import { Extension, ReaderContext, WriterContext } from '@gltf-transform/core';

const specular = this.createSpecular();
context.materials[materialIndex].setExtension(Specular, specular);
context.materials[materialIndex].setExtension(NAME, specular);

@@ -56,3 +56,3 @@ // Factors.

.forEach((material) => {
const specular = material.getExtension(Specular);
const specular = material.getExtension<Specular>(NAME);
if (specular) {

@@ -59,0 +59,0 @@ const materialIndex = context.materialIndexMap.get(material);

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

import { COPY_IDENTITY, ExtensionProperty, GraphChild, PropertyType, Texture, TextureInfo, TextureLink, TextureSampler, vec3 } from '@gltf-transform/core';
import { COPY_IDENTITY, ColorUtils, ExtensionProperty, GraphChild, PropertyType, Texture, TextureInfo, TextureLink, TextureSampler, vec3 } from '@gltf-transform/core';
import { KHR_MATERIALS_SPECULAR } from '../constants';

@@ -42,7 +42,6 @@

/** Specular color; linear multiplier. See {@link getSpecularTexture}. */
/** Specular color; components in linear space. See {@link getSpecularTexture}. */
public getSpecularColorFactor(): vec3 { return this._specularColorFactor; }
/** Specular color; linear multiplier. See {@link getSpecularTexture}. */
/** Specular color; components in linear space. See {@link getSpecularTexture}. */
public setSpecularColorFactor(specularColorFactor: vec3): this {

@@ -53,2 +52,13 @@ this._specularColorFactor = specularColorFactor;

/** Specular color; hexadecimal in sRGB colorspace. See {@link getSpecularTexture} */
public getSpecularColorHex(): number {
return ColorUtils.factorToHex(this._specularColorFactor);
}
/** Specular color; hexadecimal in sRGB colorspace. See {@link getSpecularTexture} */
public setSpecularColorHex(hex: number): this {
ColorUtils.hexToFactor(hex, this._specularColorFactor);
return this;
}
/**

@@ -55,0 +65,0 @@ * Specular texture; linear multiplier. Configures the strength of the specular reflection in

@@ -23,3 +23,3 @@ import { Extension, ReaderContext, WriterContext } from '@gltf-transform/core';

const transmission = this.createTransmission();
context.materials[materialIndex].setExtension(Transmission, transmission);
context.materials[materialIndex].setExtension(NAME, transmission);

@@ -53,3 +53,3 @@ // Factors.

.forEach((material) => {
const transmission = material.getExtension(Transmission);
const transmission = material.getExtension<Transmission>(NAME);
if (transmission) {

@@ -56,0 +56,0 @@ const materialIndex = context.materialIndexMap.get(material);

@@ -20,3 +20,3 @@ import { Extension, ReaderContext, WriterContext } from '@gltf-transform/core';

if (materialDef.extensions && materialDef.extensions[NAME]) {
context.materials[materialIndex].setExtension(Unlit, this.createUnlit());
context.materials[materialIndex].setExtension(NAME, this.createUnlit());
}

@@ -34,3 +34,3 @@ });

.forEach((material) => {
if (material.getExtension(Unlit)) {
if (material.getExtension<Unlit>(NAME)) {
const materialIndex = context.materialIndexMap.get(material);

@@ -37,0 +37,0 @@ const materialDef = nativeDoc.json.materials[materialIndex];

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