@gltf-transform/extensions
Advanced tools
Comparing version 0.5.2 to 0.5.3
@@ -36,3 +36,3 @@ import { Extension, ExtensionConstructor } from './extension'; | ||
* | ||
* doc.transform( | ||
* await doc.transform( | ||
* prune({textures: true}), | ||
@@ -90,3 +90,3 @@ * // ... | ||
* ```ts | ||
* doc.transform( | ||
* await doc.transform( | ||
* ao({samples: 500}), | ||
@@ -99,3 +99,3 @@ * prune() | ||
*/ | ||
transform(...transforms: Transform[]): Document; | ||
transform(...transforms: Transform[]): Promise<this>; | ||
/********************************************************************************************** | ||
@@ -113,11 +113,11 @@ * Extension factory method. | ||
/** Creates a new {@link Scene} attached to this document's {@link Root}. */ | ||
createScene(name: string): Scene; | ||
createScene(name?: string): Scene; | ||
/** Creates a new {@link Node} attached to this document's {@link Root}. */ | ||
createNode(name: string): Node; | ||
createNode(name?: string): Node; | ||
/** Creates a new {@link Camera} attached to this document's {@link Root}. */ | ||
createCamera(name: string): Camera; | ||
createCamera(name?: string): Camera; | ||
/** Creates a new {@link Skin} attached to this document's {@link Root}. */ | ||
createSkin(name: string): Skin; | ||
createSkin(name?: string): Skin; | ||
/** Creates a new {@link Mesh} attached to this document's {@link Root}. */ | ||
createMesh(name: string): Mesh; | ||
createMesh(name?: string): Mesh; | ||
/** | ||
@@ -132,9 +132,9 @@ * Creates a new {@link Primitive}. Primitives must be attached to a {@link Mesh} | ||
*/ | ||
createPrimitiveTarget(name: string): PrimitiveTarget; | ||
createPrimitiveTarget(name?: string): PrimitiveTarget; | ||
/** Creates a new {@link Material} attached to this document's {@link Root}. */ | ||
createMaterial(name: string): Material; | ||
createMaterial(name?: string): Material; | ||
/** Creates a new {@link Texture} attached to this document's {@link Root}. */ | ||
createTexture(name: string): Texture; | ||
createTexture(name?: string): Texture; | ||
/** Creates a new {@link Animation} attached to this document's {@link Root}. */ | ||
createAnimation(name: string): Animation; | ||
createAnimation(name?: string): Animation; | ||
/** | ||
@@ -151,5 +151,5 @@ * Creates a new {@link AnimationChannel}. Channels must be attached to an {@link Animation} | ||
/** Creates a new {@link Accessor} attached to this document's {@link Root}. */ | ||
createAccessor(name: string, buffer?: Buffer): Accessor; | ||
createAccessor(name?: string, buffer?: Buffer): Accessor; | ||
/** Creates a new {@link Buffer} attached to this document's {@link Root}. */ | ||
createBuffer(name: string): Buffer; | ||
createBuffer(name?: string): Buffer; | ||
} |
@@ -1,2 +0,3 @@ | ||
export { NodeIO, WebIO } from './io'; | ||
export { NodeIO } from './node-io'; | ||
export { WebIO } from './web-io'; | ||
export { ReaderOptions } from './reader'; | ||
@@ -3,0 +4,0 @@ export { WriterOptions } from './writer'; |
import { PropertyType } from '../constants'; | ||
import { Accessor } from './accessor'; | ||
import { AnimationChannel } from './animation-channel'; | ||
import { AnimationSampler } from './animation-sampler'; | ||
import { ExtensibleProperty } from './extensible-property'; | ||
import { Node } from './node'; | ||
import { Property } from './property'; | ||
/** | ||
@@ -46,3 +45,3 @@ * # Animation | ||
private samplers; | ||
copy(other: this, resolve?: <T extends Property>(t: T) => T): this; | ||
copy(other: this, resolve?: <T extends import("./property").Property>(t: T) => T): this; | ||
/** Adds an {@link AnimationChannel} to this Animation. */ | ||
@@ -61,125 +60,1 @@ addChannel(channel: AnimationChannel): this; | ||
} | ||
/** | ||
* # AnimationChannel | ||
* | ||
* *A target-path pair within a larger {@link Animation}, which refers to an | ||
* {@link AnimationSampler} storing the keyframe data for that pair.* | ||
* | ||
* A _target_ is always a {@link Node}, in the core glTF spec. A _path_ is any property of that | ||
* Node that can be affected by animation: `translation`, `rotation`, `scale`, or `weights`. An | ||
* {@link Animation} affecting the positions and rotations of several {@link Node}s would contain one | ||
* channel for each Node-position or Node-rotation pair. The keyframe data for an AnimationChannel | ||
* is stored in an {@link AnimationSampler}, which must be attached to the same {@link Animation}. | ||
* | ||
* Usage: | ||
* | ||
* ```ts | ||
* const node = doc.getRoot() | ||
* .listNodes() | ||
* .find((node) => node.getName() === 'Cog'); | ||
* | ||
* const channel = doc.createAnimationChannel('cogRotation') | ||
* .setTargetPath('rotation') | ||
* .setTargetNode(node) | ||
* .setSampler(rotateSampler); | ||
* ``` | ||
* | ||
* Reference | ||
* - [glTF → Animations](https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#animations) | ||
*/ | ||
export declare class AnimationChannel extends Property { | ||
readonly propertyType = PropertyType.ANIMATION_CHANNEL; | ||
private _targetPath; | ||
private targetNode; | ||
private sampler; | ||
copy(other: this, resolve?: <T extends Property>(t: T) => T): this; | ||
/** | ||
* Path (property) animated on the target {@link Node}. Supported values include: | ||
* `translation`, `rotation`, `scale`, or `weights`. | ||
*/ | ||
getTargetPath(): GLTF.AnimationChannelTargetPath; | ||
/** | ||
* Path (property) animated on the target {@link Node}. Supported values include: | ||
* `translation`, `rotation`, `scale`, or `weights`. | ||
*/ | ||
setTargetPath(targetPath: GLTF.AnimationChannelTargetPath): this; | ||
/** Target {@link Node} animated by the channel. */ | ||
getTargetNode(): Node; | ||
/** Target {@link Node} animated by the channel. */ | ||
setTargetNode(targetNode: Node): this; | ||
/** | ||
* Keyframe data input/output values for the channel. Must be attached to the same | ||
* {@link Animation}. | ||
*/ | ||
getSampler(): AnimationSampler; | ||
/** | ||
* Keyframe data input/output values for the channel. Must be attached to the same | ||
* {@link Animation}. | ||
*/ | ||
setSampler(sampler: AnimationSampler): this; | ||
} | ||
/** | ||
* # AnimationSampler | ||
* | ||
* *Reusable collection of keyframes affecting particular property of an object.* | ||
* | ||
* Each AnimationSampler refers to an input and an output {@link Accessor}. Input contains times | ||
* (in seconds) for each keyframe. Output contains values (of any {@link Accessor.Type}) for the | ||
* animated property at each keyframe. Samplers using `CUBICSPLINE` interpolation will also contain | ||
* in/out tangents in the output, with the layout: | ||
* | ||
* in<sub>1</sub>, value<sub>1</sub>, out<sub>1</sub>, in<sub>2</sub>, value<sub>2</sub>, out<sub>2</sub>, | ||
* in<sub>3</sub>, value<sub>3</sub>, out<sub>3</sub>, ... | ||
* | ||
* Usage: | ||
* | ||
* ```ts | ||
* // Create accessor containing input times, in seconds. | ||
* const input = doc.createAccessor('bounceTimes') | ||
* .setArray(new Float32Array([0, 1, 2])) | ||
* .setType('SCALAR'); | ||
* | ||
* // Create accessor containing output values, in local units. | ||
* const output = doc.createAccessor('bounceValues') | ||
* .setArray(new Float32Array([ | ||
* 0, 0, 0, // y = 0 | ||
* 0, 1, 0, // y = 1 | ||
* 0, 0, 0, // y = 0 | ||
* ])) | ||
* .setType('VEC3'); | ||
* | ||
* // Create sampler. | ||
* const sampler = doc.createAnimationSampler('bounce') | ||
* .setInput(input) | ||
* .setOutput(output) | ||
* .setInterpolation('LINEAR'); | ||
* ``` | ||
* | ||
* Reference | ||
* - [glTF → Animations](https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#animations) | ||
*/ | ||
export declare class AnimationSampler extends Property { | ||
readonly propertyType = PropertyType.ANIMATION_SAMPLER; | ||
private _interpolation; | ||
private input; | ||
private output; | ||
copy(other: this, resolve?: <T extends Property>(t: T) => T): this; | ||
/** Interpolation mode: `STEP`, `LINEAR`, or `CUBICSPLINE`. */ | ||
getInterpolation(): GLTF.AnimationSamplerInterpolation; | ||
/** Interpolation mode: `STEP`, `LINEAR`, or `CUBICSPLINE`. */ | ||
setInterpolation(interpolation: GLTF.AnimationSamplerInterpolation): this; | ||
/** Times for each keyframe, in seconds. */ | ||
getInput(): Accessor; | ||
/** Times for each keyframe, in seconds. */ | ||
setInput(input: Accessor): this; | ||
/** | ||
* Values for each keyframe. For `CUBICSPLINE` interpolation, output also contains in/out | ||
* tangents. | ||
*/ | ||
getOutput(): Accessor; | ||
/** | ||
* Values for each keyframe. For `CUBICSPLINE` interpolation, output also contains in/out | ||
* tangents. | ||
*/ | ||
setOutput(output: Accessor): this; | ||
} |
export * from './accessor'; | ||
export * from './animation'; | ||
export * from './animation-channel'; | ||
export * from './animation-sampler'; | ||
export * from './buffer'; | ||
@@ -12,2 +14,4 @@ export * from './camera'; | ||
export * from './node'; | ||
export * from './primitive'; | ||
export * from './primitive-target'; | ||
export * from './root'; | ||
@@ -17,1 +21,3 @@ export * from './scene'; | ||
export * from './texture'; | ||
export * from './texture-info'; | ||
export * from './texture-sampler'; |
import { PropertyType, vec3, vec4 } from '../constants'; | ||
import { ExtensibleProperty } from './extensible-property'; | ||
import { Texture, TextureInfo, TextureSampler } from './texture'; | ||
import { Texture } from './texture'; | ||
import { TextureInfo } from './texture-info'; | ||
import { TextureSampler } from './texture-sampler'; | ||
/** | ||
@@ -5,0 +7,0 @@ * # Material |
import { PropertyType } from '../constants'; | ||
import { Accessor } from './accessor'; | ||
import { ExtensibleProperty } from './extensible-property'; | ||
import { Material } from './material'; | ||
import { Property } from './property'; | ||
import { Primitive } from './primitive'; | ||
/** | ||
@@ -44,3 +42,3 @@ * # Mesh | ||
private primitives; | ||
copy(other: this, resolve?: <T extends Property>(t: T) => T): this; | ||
copy(other: this, resolve?: <T extends import("./property").Property>(t: T) => T): this; | ||
/** Adds a {@link Primitive} to the mesh's draw call list. */ | ||
@@ -65,139 +63,1 @@ addPrimitive(primitive: Primitive): this; | ||
} | ||
/** | ||
* # Primitive | ||
* | ||
* *Primitives are individual GPU draw calls comprising a {@link Mesh}.* | ||
* | ||
* Meshes typically have only a single Primitive, although various cases may require more. Each | ||
* primitive may be assigned vertex attributes, morph target attributes, and a material. Any of | ||
* these properties should be reused among multiple primitives where feasible. | ||
* | ||
* Primitives cannot be moved independently of other primitives within the same mesh, except | ||
* through the use of morph targets and skinning. If independent movement or other runtime | ||
* behavior is necessary (like raycasting or collisions) prefer to assign each primitive to a | ||
* different mesh. The number of GPU draw calls is typically not unaffected by grouping or | ||
* ungrouping primitives to a mesh. | ||
* | ||
* Each primitive may optionally be deformed by one or more morph targets, stored in a | ||
* {@link PrimitiveTarget}. | ||
* | ||
* Usage: | ||
* | ||
* ```ts | ||
* const primitive = doc.createPrimitive() | ||
* .setAttribute('POSITION', positionAccessor) | ||
* .setAttribute('TEXCOORD_0', uvAccessor) | ||
* .setMaterial(material); | ||
* mesh.addPrimitive(primitive); | ||
* node.setMesh(mesh); | ||
* ``` | ||
* | ||
* References: | ||
* - [glTF → Geometry](https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry) | ||
* | ||
* @category Properties | ||
*/ | ||
export declare class Primitive extends Property { | ||
readonly propertyType = PropertyType.PRIMITIVE; | ||
/** @hidden GPU draw mode. */ | ||
private _mode; | ||
private material; | ||
private indices; | ||
private attributes; | ||
private targets; | ||
copy(other: this, resolve?: <T extends Property>(t: T) => T): this; | ||
/** Returns an {@link Accessor} with indices of vertices to be drawn. */ | ||
getIndices(): Accessor; | ||
/** | ||
* Sets an {@link Accessor} with indices of vertices to be drawn. In `TRIANGLES` draw mode, | ||
* each set of three indices define a triangle. The front face has a counter-clockwise (CCW) | ||
* winding order. | ||
*/ | ||
setIndices(indices: Accessor): this; | ||
/** Returns a vertex attribute as an {@link Accessor}. */ | ||
getAttribute(semantic: string): Accessor; | ||
/** | ||
* Sets a vertex attribute to an {@link Accessor}. All attributes must have the same vertex | ||
* count. | ||
*/ | ||
setAttribute(semantic: string, accessor: Accessor): this; | ||
/** | ||
* Lists all vertex attribute {@link Accessor}s associated with the primitive, excluding any | ||
* attributes used for morph targets. For example, `[positionAccessor, normalAccessor, | ||
* uvAccessor]`. Order will be consistent with the order returned by {@link .listSemantics}(). | ||
*/ | ||
listAttributes(): Accessor[]; | ||
/** | ||
* Lists all vertex attribute semantics associated with the primitive, excluding any semantics | ||
* used for morph targets. For example, `['POSITION', 'NORMAL', 'TEXCOORD_0']`. Order will be | ||
* consistent with the order returned by {@link .listAttributes}(). | ||
*/ | ||
listSemantics(): string[]; | ||
/** Returns the material used to render the primitive. */ | ||
getMaterial(): Material; | ||
/** Sets the material used to render the primitive. */ | ||
setMaterial(material: Material): this; | ||
/** | ||
* Returns the GPU draw mode (`TRIANGLES`, `LINES`, `POINTS`...) as a WebGL enum value. | ||
* | ||
* Reference: | ||
* - [glTF → `primitive.mode`](https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#primitivemode) | ||
*/ | ||
getMode(): GLTF.MeshPrimitiveMode; | ||
/** | ||
* Sets the GPU draw mode (`TRIANGLES`, `LINES`, `POINTS`...) as a WebGL enum value. | ||
* | ||
* Reference: | ||
* - [glTF → `primitive.mode`](https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#primitivemode) | ||
*/ | ||
setMode(mode: GLTF.MeshPrimitiveMode): this; | ||
/** Lists all morph targets associated with the primitive. */ | ||
listTargets(): PrimitiveTarget[]; | ||
/** | ||
* Adds a morph target to the primitive. All primitives in the same mesh must have the same | ||
* number of targets. | ||
*/ | ||
addTarget(target: PrimitiveTarget): this; | ||
/** | ||
* Removes a morph target from the primitive. All primitives in the same mesh must have the same | ||
* number of targets. | ||
*/ | ||
removeTarget(target: PrimitiveTarget): this; | ||
} | ||
/** | ||
* # PrimitiveTarget | ||
* | ||
* *Morph target or shape key used to deform one {@link Primitive} in a {@link Mesh}.* | ||
* | ||
* A PrimitiveTarget contains a `POSITION` attribute (and optionally `NORMAL` and `TANGENT`) that | ||
* can additively deform the base attributes on a {@link Mesh} {@link Primitive}. Vertex values | ||
* of `0, 0, 0` in the target will have no effect, whereas a value of `0, 1, 0` would offset that | ||
* vertex in the base geometry by y+=1. Morph targets can be fully or partially applied: their | ||
* default state is controlled by {@link Mesh.getWeights}, which can also be overridden for a | ||
* particular instantiation of a {@link Mesh}, using {@link Node.getWeights}. | ||
* | ||
* Reference: | ||
* - [glTF → Morph Targets](https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#morph-targets) | ||
*/ | ||
export declare class PrimitiveTarget extends Property { | ||
readonly propertyType = PropertyType.PRIMITIVE_TARGET; | ||
/** @hidden Vertex attributes. */ | ||
private attributes; | ||
copy(other: this, resolve?: <T extends Property>(t: T) => T): this; | ||
/** Returns a morph target vertex attribute as an {@link Accessor}. */ | ||
getAttribute(semantic: string): Accessor; | ||
/** | ||
* Sets a morph target vertex attribute to an {@link Accessor}. | ||
*/ | ||
setAttribute(semantic: string, accessor: Accessor): this; | ||
/** | ||
* Lists all morph target vertex attribute {@link Accessor}s associated. Order will be | ||
* consistent with the order returned by {@link .listSemantics}(). | ||
*/ | ||
listAttributes(): Accessor[]; | ||
/** | ||
* Lists all morph target vertex attribute semantics associated. Order will be | ||
* consistent with the order returned by {@link .listAttributes}(). | ||
*/ | ||
listSemantics(): string[]; | ||
} |
@@ -5,3 +5,4 @@ import { Graph } from '../graph'; | ||
import { Material } from './material'; | ||
import { Primitive, PrimitiveTarget } from './mesh'; | ||
import { Primitive } from './primitive'; | ||
import { PrimitiveTarget } from './primitive-target'; | ||
import { AttributeLink, IndexLink, TextureLink } from './property-links'; | ||
@@ -8,0 +9,0 @@ import { Texture } from './texture'; |
@@ -5,4 +5,7 @@ import { Link } from '../graph'; | ||
import { Material } from './material'; | ||
import { Primitive, PrimitiveTarget } from './mesh'; | ||
import { Texture, TextureInfo, TextureSampler } from './texture'; | ||
import { Primitive } from './primitive'; | ||
import { PrimitiveTarget } from './primitive-target'; | ||
import { Texture } from './texture'; | ||
import { TextureInfo } from './texture-info'; | ||
import { TextureSampler } from './texture-sampler'; | ||
/** @hidden */ | ||
@@ -9,0 +12,0 @@ export declare class TextureLink extends Link<Material | ExtensionProperty, Texture> { |
@@ -63,86 +63,1 @@ import { PropertyType, vec2 } from '../constants'; | ||
} | ||
/** | ||
* # TextureInfo | ||
* | ||
* *Settings associated with a particular use of a {@link Texture}.* | ||
* | ||
* Different materials may reuse the same texture but with different texture coordinates. For other | ||
* settings affecting application of a texture, see {@link TextureSampler}. | ||
* | ||
* References: | ||
* - [glTF → Texture Info](https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#reference-textureinfo) | ||
* | ||
* @category Properties | ||
*/ | ||
export declare class TextureInfo { | ||
readonly propertyType = PropertyType.TEXTURE_INFO; | ||
private texCoord; | ||
copy(other: this): this; | ||
/** Returns the texture coordinate (UV set) index for the texture. */ | ||
getTexCoord(): number; | ||
/** Sets the texture coordinate (UV set) index for the texture. */ | ||
setTexCoord(texCoord: number): this; | ||
} | ||
/** | ||
* # TextureSampler | ||
* | ||
* *Settings associated with a particular use of a {@link Texture}.* | ||
* | ||
* Different materials may reuse the same texture but with different texture coordinates. For other | ||
* settings affecting application of a texture, see {@link TextureInfo}. | ||
* | ||
* References: | ||
* - [glTF → Samplers](https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#samplers) | ||
* | ||
* @category Properties | ||
*/ | ||
export declare class TextureSampler { | ||
readonly propertyType = PropertyType.TEXTURE_SAMPLER; | ||
private _magFilter; | ||
private _minFilter; | ||
private _wrapS; | ||
private _wrapT; | ||
copy(other: this): this; | ||
/** UV wrapping mode. Values correspond to WebGL enums. */ | ||
static TextureWrapMode: { | ||
CLAMP_TO_EDGE: GLTF.TextureWrapMode; | ||
MIRRORED_REPEAT: GLTF.TextureWrapMode; | ||
REPEAT: GLTF.TextureWrapMode; | ||
}; | ||
/** Magnification filter. Values correspond to WebGL enums. */ | ||
static TextureMagFilter: { | ||
NEAREST: GLTF.TextureMagFilter; | ||
LINEAR: GLTF.TextureMagFilter; | ||
}; | ||
/** Minification filter. Values correspond to WebGL enums. */ | ||
static TextureMinFilter: { | ||
NEAREST: GLTF.TextureMinFilter; | ||
LINEAR: GLTF.TextureMinFilter; | ||
NEAREST_MIPMAP_NEAREST: GLTF.TextureMinFilter; | ||
LINEAR_MIPMAP_NEAREST: GLTF.TextureMinFilter; | ||
NEAREST_MIPMAP_LINEAR: GLTF.TextureMinFilter; | ||
LINEAR_MIPMAP_LINEAR: GLTF.TextureMinFilter; | ||
}; | ||
/********************************************************************************************** | ||
* Min/mag filter. | ||
*/ | ||
/** Returns the magnification filter applied to the texture. */ | ||
getMagFilter(): GLTF.TextureMagFilter; | ||
/** Sets the magnification filter applied to the texture. */ | ||
setMagFilter(magFilter: GLTF.TextureMagFilter): this; | ||
/** Sets the minification filter applied to the texture. */ | ||
getMinFilter(): GLTF.TextureMinFilter; | ||
/** Returns the minification filter applied to the texture. */ | ||
setMinFilter(minFilter: GLTF.TextureMinFilter): this; | ||
/********************************************************************************************** | ||
* UV wrapping. | ||
*/ | ||
/** Returns the S (U) wrapping mode for UVs used by the texture. */ | ||
getWrapS(): GLTF.TextureWrapMode; | ||
/** Sets the S (U) wrapping mode for UVs used by the texture. */ | ||
setWrapS(wrapS: GLTF.TextureWrapMode): this; | ||
/** Returns the T (V) wrapping mode for UVs used by the texture. */ | ||
getWrapT(): GLTF.TextureWrapMode; | ||
/** Sets the T (V) wrapping mode for UVs used by the texture. */ | ||
setWrapT(wrapT: GLTF.TextureWrapMode): this; | ||
} |
@@ -1,2 +0,2 @@ | ||
var e=require("@gltf-transform/core");function t(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function r(e,t,r,a){var o,n=arguments.length,c=n<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,r):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,a);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(c=(n<3?o(c):n>3?o(t,r,c):o(t,r))||c);return n>3&&c&&Object.defineProperty(t,r,c),c}var a=function(r){function a(){var t;return(t=r.apply(this,arguments)||this).propertyType="Clearcoat",t.parentTypes=[e.PropertyType.MATERIAL],t.extensionName="KHR_materials_clearcoat",t._clearcoatFactor=0,t._clearcoatRoughnessFactor=0,t._clearcoatNormalScale=1,t.clearcoatTexture=null,t.clearcoatRoughnessTexture=null,t.clearcoatNormalTexture=null,t}t(a,r);var o=a.prototype;return o.copy=function(t,a){return void 0===a&&(a=e.COPY_IDENTITY),r.prototype.copy.call(this,t,a),this._clearcoatFactor=t._clearcoatFactor,this._clearcoatRoughnessFactor=t._clearcoatRoughnessFactor,this._clearcoatNormalScale=t._clearcoatNormalScale,t.clearcoatTexture&&(this.setClearcoatTexture(a(t.clearcoatTexture.getChild())),this.clearcoatTexture.copy(t.clearcoatTexture)),t.clearcoatRoughnessTexture&&(this.setClearcoatRoughnessTexture(a(t.clearcoatRoughnessTexture.getChild())),this.clearcoatRoughnessTexture.copy(t.clearcoatRoughnessTexture)),t.clearcoatNormalTexture&&(this.setClearcoatNormalTexture(a(t.clearcoatNormalTexture.getChild())),this.clearcoatNormalTexture.copy(t.clearcoatNormalTexture)),this},o.getClearcoatFactor=function(){return this._clearcoatFactor},o.setClearcoatFactor=function(e){return this._clearcoatFactor=e,this},o.getClearcoatTexture=function(){return this.clearcoatTexture?this.clearcoatTexture.getChild():null},o.getClearcoatTextureInfo=function(){return this.clearcoatTexture?this.clearcoatTexture.textureInfo:null},o.getClearcoatTextureSampler=function(){return this.clearcoatTexture?this.clearcoatTexture.sampler:null},o.setClearcoatTexture=function(e){return this.clearcoatTexture=this.graph.linkTexture("clearcoatTexture",this,e),this},o.getClearcoatRoughnessFactor=function(){return this._clearcoatRoughnessFactor},o.setClearcoatRoughnessFactor=function(e){return this._clearcoatRoughnessFactor=e,this},o.getClearcoatRoughnessTexture=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.getChild():null},o.getClearcoatRoughnessTextureInfo=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.textureInfo:null},o.getClearcoatRoughnessTextureSampler=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.sampler:null},o.setClearcoatRoughnessTexture=function(e){return this.clearcoatRoughnessTexture=this.graph.linkTexture("clearcoatRoughnessTexture",this,e),this},o.getClearcoatNormalScale=function(){return this._clearcoatNormalScale},o.setClearcoatNormalScale=function(e){return this._clearcoatNormalScale=e,this},o.getClearcoatNormalTexture=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTexture.getChild():null},o.getClearcoatNormalTextureInfo=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTexture.textureInfo:null},o.getClearcoatNormalTextureSampler=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTexture.sampler:null},o.setClearcoatNormalTexture=function(e){return this.clearcoatNormalTexture=this.graph.linkTexture("clearcoatNormalTexture",this,e),this},a}(e.ExtensionProperty);a.EXTENSION_NAME="KHR_materials_clearcoat",r([e.GraphChild],a.prototype,"clearcoatTexture",void 0),r([e.GraphChild],a.prototype,"clearcoatRoughnessTexture",void 0),r([e.GraphChild],a.prototype,"clearcoatNormalTexture",void 0);var o="KHR_materials_clearcoat",n=function(e){function r(){var t;return(t=e.apply(this,arguments)||this).extensionName=o,t}t(r,e);var n=r.prototype;return n.createClearcoat=function(){return new a(this.doc.getGraph(),this)},n.read=function(e){var t=this,r=e.nativeDocument,n=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,c){if(r.extensions&&r.extensions[o]){var s=t.createClearcoat();if(e.materials[c].setExtension(a,s),void 0!==r.extensions[o].clearcoatFactor&&s.setClearcoatFactor(r.extensions[o].clearcoatFactor),void 0!==r.extensions[o].clearcoatRoughnessFactor&&s.setClearcoatRoughnessFactor(r.extensions[o].clearcoatRoughnessFactor),void 0!==r.extensions[o].clearcoatTexture){var u=r.extensions[o].clearcoatTexture;s.setClearcoatTexture(e.textures[n[u.index].source]),e.setTextureInfo(s.getClearcoatTextureInfo(),u),e.setTextureSampler(s.getClearcoatTextureSampler(),u)}if(void 0!==r.extensions[o].clearcoatRoughnessTexture){var l=r.extensions[o].clearcoatRoughnessTexture;s.setClearcoatRoughnessTexture(e.textures[n[l.index].source]),e.setTextureInfo(s.getClearcoatRoughnessTextureInfo(),l),e.setTextureSampler(s.getClearcoatRoughnessTextureSampler(),l)}if(void 0!==r.extensions[o].clearcoatNormalTexture){var i=r.extensions[o].clearcoatNormalTexture;s.setClearcoatNormalTexture(e.textures[n[i.index].source]),e.setTextureInfo(s.getClearcoatNormalTextureInfo(),i),e.setTextureSampler(s.getClearcoatNormalTextureSampler(),i),void 0!==i.scale&&s.setClearcoatNormalScale(i.scale)}}}),this},n.write=function(e){var t=e.nativeDocument;return this.doc.getRoot().listMaterials().forEach(function(r){var n=r.getExtension(a);if(n){var c=e.materialIndexMap.get(r),s=t.json.materials[c];if(s.extensions=s.extensions||{},s.extensions[o]={clearcoatFactor:n.getClearcoatFactor(),clearcoatRoughnessFactor:n.getClearcoatRoughnessFactor()},n.getClearcoatTexture()){var u=n.getClearcoatTexture(),l=n.getClearcoatTextureInfo(),i=n.getClearcoatTextureSampler();s.extensions[o].clearcoatTexture=e.createTextureInfoDef(u,l,i)}if(n.getClearcoatRoughnessTexture()){var x=n.getClearcoatRoughnessTexture(),h=n.getClearcoatRoughnessTextureInfo(),T=n.getClearcoatRoughnessTextureSampler();s.extensions[o].clearcoatRoughnessTexture=e.createTextureInfoDef(x,h,T)}if(n.getClearcoatNormalTexture()){var p=n.getClearcoatNormalTexture(),g=n.getClearcoatNormalTextureInfo(),f=n.getClearcoatNormalTextureSampler();s.extensions[o].clearcoatNormalTexture=e.createTextureInfoDef(p,g,f),1!==n.getClearcoatNormalScale()&&(s.extensions[o].clearcoatNormalTexture.scale=n.getClearcoatNormalScale())}}}),this},r}(e.Extension);n.EXTENSION_NAME=o;var c=function(r){function a(){var t;return(t=r.apply(this,arguments)||this).propertyType="Unlit",t.parentTypes=[e.PropertyType.MATERIAL],t.extensionName="KHR_materials_unlit",t}return t(a,r),a}(e.ExtensionProperty);c.EXTENSION_NAME="KHR_materials_unlit";var s="KHR_materials_unlit",u=function(e){function r(){var t;return(t=e.apply(this,arguments)||this).extensionName=s,t}t(r,e);var a=r.prototype;return a.createUnlit=function(){return new c(this.doc.getGraph(),this)},a.read=function(e){var t=this;return(e.nativeDocument.json.materials||[]).forEach(function(r,a){r.extensions&&r.extensions[s]&&e.materials[a].setExtension(c,t.createUnlit())}),this},a.write=function(e){var t=e.nativeDocument;return this.doc.getRoot().listMaterials().forEach(function(r){if(r.getExtension(c)){var a=e.materialIndexMap.get(r),o=t.json.materials[a];o.extensions=o.extensions||{},o.extensions[s]={}}}),this},r}(e.Extension);u.EXTENSION_NAME=s;var l="KHR_mesh_quantization",i=function(e){function r(){var t;return(t=e.apply(this,arguments)||this).extensionName=l,t}t(r,e);var a=r.prototype;return a.read=function(e){return this},a.write=function(e){return this},r}(e.Extension);i.EXTENSION_NAME=l;var x="KHR_texture_basisu",h=function(r){function a(){var t;return(t=r.apply(this,arguments)||this).extensionName=x,t.provideTypes=[e.PropertyType.TEXTURE],t}t(a,r);var o=a.prototype;return o.provide=function(e){return e.nativeDocument.json.textures.forEach(function(e){e.extensions&&e.extensions[x]&&(e.source=e.extensions[x].source)}),this},o.read=function(e){return this},o.write=function(e){var t=e.nativeDocument;return this.doc.getRoot().listTextures().forEach(function(r){if("image/ktx2"===r.getMimeType()){var a=e.imageIndexMap.get(r);t.json.textures.forEach(function(e){e.source===a&&(e.extensions=e.extensions||{},e.extensions[x]={source:e.source},delete e.source)})}}),this},a}(e.Extension);h.EXTENSION_NAME=x;var T=[n,u,i,h];exports.Clearcoat=a,exports.KHRONOS_EXTENSIONS=T,exports.MaterialsClearcoat=n,exports.MaterialsUnlit=u,exports.MeshQuantization=i,exports.TextureBasisu=h,exports.Unlit=c; | ||
var e=require("@gltf-transform/core");function t(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function r(e,t,r,s){var o,n=arguments.length,a=n<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--)(o=e[i])&&(a=(n<3?o(a):n>3?o(t,r,a):o(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a}var s=function(r){function s(){var t;return(t=r.apply(this,arguments)||this).propertyType="Clearcoat",t.parentTypes=[e.PropertyType.MATERIAL],t.extensionName="KHR_materials_clearcoat",t._clearcoatFactor=0,t._clearcoatRoughnessFactor=0,t._clearcoatNormalScale=1,t.clearcoatTexture=null,t.clearcoatRoughnessTexture=null,t.clearcoatNormalTexture=null,t}t(s,r);var o=s.prototype;return o.copy=function(t,s){return void 0===s&&(s=e.COPY_IDENTITY),r.prototype.copy.call(this,t,s),this._clearcoatFactor=t._clearcoatFactor,this._clearcoatRoughnessFactor=t._clearcoatRoughnessFactor,this._clearcoatNormalScale=t._clearcoatNormalScale,t.clearcoatTexture&&(this.setClearcoatTexture(s(t.clearcoatTexture.getChild())),this.clearcoatTexture.copy(t.clearcoatTexture)),t.clearcoatRoughnessTexture&&(this.setClearcoatRoughnessTexture(s(t.clearcoatRoughnessTexture.getChild())),this.clearcoatRoughnessTexture.copy(t.clearcoatRoughnessTexture)),t.clearcoatNormalTexture&&(this.setClearcoatNormalTexture(s(t.clearcoatNormalTexture.getChild())),this.clearcoatNormalTexture.copy(t.clearcoatNormalTexture)),this},o.getClearcoatFactor=function(){return this._clearcoatFactor},o.setClearcoatFactor=function(e){return this._clearcoatFactor=e,this},o.getClearcoatTexture=function(){return this.clearcoatTexture?this.clearcoatTexture.getChild():null},o.getClearcoatTextureInfo=function(){return this.clearcoatTexture?this.clearcoatTexture.textureInfo:null},o.getClearcoatTextureSampler=function(){return this.clearcoatTexture?this.clearcoatTexture.sampler:null},o.setClearcoatTexture=function(e){return this.clearcoatTexture=this.graph.linkTexture("clearcoatTexture",this,e),this},o.getClearcoatRoughnessFactor=function(){return this._clearcoatRoughnessFactor},o.setClearcoatRoughnessFactor=function(e){return this._clearcoatRoughnessFactor=e,this},o.getClearcoatRoughnessTexture=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.getChild():null},o.getClearcoatRoughnessTextureInfo=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.textureInfo:null},o.getClearcoatRoughnessTextureSampler=function(){return this.clearcoatRoughnessTexture?this.clearcoatRoughnessTexture.sampler:null},o.setClearcoatRoughnessTexture=function(e){return this.clearcoatRoughnessTexture=this.graph.linkTexture("clearcoatRoughnessTexture",this,e),this},o.getClearcoatNormalScale=function(){return this._clearcoatNormalScale},o.setClearcoatNormalScale=function(e){return this._clearcoatNormalScale=e,this},o.getClearcoatNormalTexture=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTexture.getChild():null},o.getClearcoatNormalTextureInfo=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTexture.textureInfo:null},o.getClearcoatNormalTextureSampler=function(){return this.clearcoatNormalTexture?this.clearcoatNormalTexture.sampler:null},o.setClearcoatNormalTexture=function(e){return this.clearcoatNormalTexture=this.graph.linkTexture("clearcoatNormalTexture",this,e),this},s}(e.ExtensionProperty);s.EXTENSION_NAME="KHR_materials_clearcoat",r([e.GraphChild],s.prototype,"clearcoatTexture",void 0),r([e.GraphChild],s.prototype,"clearcoatRoughnessTexture",void 0),r([e.GraphChild],s.prototype,"clearcoatNormalTexture",void 0);var o="KHR_materials_clearcoat",n=function(e){function r(){var t;return(t=e.apply(this,arguments)||this).extensionName=o,t}t(r,e);var n=r.prototype;return n.createClearcoat=function(){return new s(this.doc.getGraph(),this)},n.read=function(e){var t=this,r=e.nativeDocument,n=r.json.textures||[];return(r.json.materials||[]).forEach(function(r,a){if(r.extensions&&r.extensions[o]){var i=t.createClearcoat();if(e.materials[a].setExtension(s,i),void 0!==r.extensions[o].clearcoatFactor&&i.setClearcoatFactor(r.extensions[o].clearcoatFactor),void 0!==r.extensions[o].clearcoatRoughnessFactor&&i.setClearcoatRoughnessFactor(r.extensions[o].clearcoatRoughnessFactor),void 0!==r.extensions[o].clearcoatTexture){var u=r.extensions[o].clearcoatTexture;i.setClearcoatTexture(e.textures[n[u.index].source]),e.setTextureInfo(i.getClearcoatTextureInfo(),u),e.setTextureSampler(i.getClearcoatTextureSampler(),u)}if(void 0!==r.extensions[o].clearcoatRoughnessTexture){var c=r.extensions[o].clearcoatRoughnessTexture;i.setClearcoatRoughnessTexture(e.textures[n[c.index].source]),e.setTextureInfo(i.getClearcoatRoughnessTextureInfo(),c),e.setTextureSampler(i.getClearcoatRoughnessTextureSampler(),c)}if(void 0!==r.extensions[o].clearcoatNormalTexture){var l=r.extensions[o].clearcoatNormalTexture;i.setClearcoatNormalTexture(e.textures[n[l.index].source]),e.setTextureInfo(i.getClearcoatNormalTextureInfo(),l),e.setTextureSampler(i.getClearcoatNormalTextureSampler(),l),void 0!==l.scale&&i.setClearcoatNormalScale(l.scale)}}}),this},n.write=function(e){var t=e.nativeDocument;return this.doc.getRoot().listMaterials().forEach(function(r){var n=r.getExtension(s);if(n){var a=e.materialIndexMap.get(r),i=t.json.materials[a];if(i.extensions=i.extensions||{},i.extensions[o]={clearcoatFactor:n.getClearcoatFactor(),clearcoatRoughnessFactor:n.getClearcoatRoughnessFactor()},n.getClearcoatTexture()){var u=n.getClearcoatTexture(),c=n.getClearcoatTextureInfo(),l=n.getClearcoatTextureSampler();i.extensions[o].clearcoatTexture=e.createTextureInfoDef(u,c,l)}if(n.getClearcoatRoughnessTexture()){var x=n.getClearcoatRoughnessTexture(),p=n.getClearcoatRoughnessTextureInfo(),T=n.getClearcoatRoughnessTextureSampler();i.extensions[o].clearcoatRoughnessTexture=e.createTextureInfoDef(x,p,T)}if(n.getClearcoatNormalTexture()){var f=n.getClearcoatNormalTexture(),h=n.getClearcoatNormalTextureInfo(),m=n.getClearcoatNormalTextureSampler();i.extensions[o].clearcoatNormalTexture=e.createTextureInfoDef(f,h,m),1!==n.getClearcoatNormalScale()&&(i.extensions[o].clearcoatNormalTexture.scale=n.getClearcoatNormalScale())}}}),this},r}(e.Extension);n.EXTENSION_NAME=o;var a=function(r){function s(){var t;return(t=r.apply(this,arguments)||this).propertyType="IOR",t.parentTypes=[e.PropertyType.MATERIAL],t.extensionName="KHR_materials_ior",t._ior=0,t}t(s,r);var o=s.prototype;return o.copy=function(t,s){return void 0===s&&(s=e.COPY_IDENTITY),r.prototype.copy.call(this,t,s),this._ior=t._ior,this},o.getIOR=function(){return this._ior},o.setIOR=function(e){return this._ior=e,this},s}(e.ExtensionProperty);a.EXTENSION_NAME="KHR_materials_ior";var i="KHR_materials_ior",u=function(e){function r(){var t;return(t=e.apply(this,arguments)||this).extensionName=i,t}t(r,e);var s=r.prototype;return s.createIOR=function(){return new a(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[i]){var o=t.createIOR();e.materials[s].setExtension(a,o),void 0!==r.extensions[i].ior&&o.setIOR(r.extensions[i].ior)}}),this},s.write=function(e){var t=e.nativeDocument;return this.doc.getRoot().listMaterials().forEach(function(r){var s=r.getExtension(a);if(s){var o=e.materialIndexMap.get(r),n=t.json.materials[o];n.extensions=n.extensions||{},n.extensions[i]={ior:s.getIOR()}}}),this},r}(e.Extension);u.EXTENSION_NAME=i;var c=function(r){function s(){var t;return(t=r.apply(this,arguments)||this).propertyType="PBRSpecularGlossiness",t.parentTypes=[e.PropertyType.MATERIAL],t.extensionName="KHR_materials_pbrSpecularGlossiness",t._diffuseFactor=[1,1,1,1],t._specularFactor=[1,1,1],t._glossinessFactor=1,t.diffuseTexture=null,t.specularGlossinessTexture=null,t}t(s,r);var o=s.prototype;return o.copy=function(t,s){return void 0===s&&(s=e.COPY_IDENTITY),r.prototype.copy.call(this,t,s),this._diffuseFactor=t._diffuseFactor,this._specularFactor=t._specularFactor,this._glossinessFactor=t._glossinessFactor,t.diffuseTexture&&(this.setDiffuseTexture(s(t.diffuseTexture.getChild())),this.diffuseTexture.copy(t.diffuseTexture)),t.specularGlossinessTexture&&(this.setSpecularGlossinessTexture(s(t.specularGlossinessTexture.getChild())),this.specularGlossinessTexture.copy(t.specularGlossinessTexture)),this},o.getDiffuseFactor=function(){return this._diffuseFactor},o.setDiffuseFactor=function(e){return this._diffuseFactor=e,this},o.getDiffuseTexture=function(){return this.diffuseTexture?this.diffuseTexture.getChild():null},o.getDiffuseTextureInfo=function(){return this.diffuseTexture?this.diffuseTexture.textureInfo:null},o.getDiffuseTextureSampler=function(){return this.diffuseTexture?this.diffuseTexture.sampler:null},o.setDiffuseTexture=function(e){return this.diffuseTexture=this.graph.linkTexture("diffuseTexture",this,e),this},o.getSpecularFactor=function(){return this._specularFactor},o.setSpecularFactor=function(e){return this._specularFactor=e,this},o.getGlossinessFactor=function(){return this._glossinessFactor},o.setGlossinessFactor=function(e){return this._glossinessFactor=e,this},o.getSpecularGlossinessTexture=function(){return this.specularGlossinessTexture?this.specularGlossinessTexture.getChild():null},o.getSpecularGlossinessTextureInfo=function(){return this.specularGlossinessTexture?this.specularGlossinessTexture.textureInfo:null},o.getSpecularGlossinessTextureSampler=function(){return this.specularGlossinessTexture?this.specularGlossinessTexture.sampler:null},o.setSpecularGlossinessTexture=function(e){return this.specularGlossinessTexture=this.graph.linkTexture("specularGlossinessTexture",this,e),this},s}(e.ExtensionProperty);c.EXTENSION_NAME="KHR_materials_pbrSpecularGlossiness",r([e.GraphChild],c.prototype,"diffuseTexture",void 0),r([e.GraphChild],c.prototype,"specularGlossinessTexture",void 0);var l="KHR_materials_pbrSpecularGlossiness",x=function(e){function r(){var t;return(t=e.apply(this,arguments)||this).extensionName=l,t}t(r,e);var s=r.prototype;return s.createPBRSpecularGlossiness=function(){return new c(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,o){if(r.extensions&&r.extensions[l]){var n=t.createPBRSpecularGlossiness();if(e.materials[o].setExtension(c,n),void 0!==r.extensions[l].diffuseFactor&&n.setDiffuseFactor(r.extensions[l].diffuseFactor),void 0!==r.extensions[l].specularFactor&&n.setSpecularFactor(r.extensions[l].specularFactor),void 0!==r.extensions[l].glossinessFactor&&n.setGlossinessFactor(r.extensions[l].glossinessFactor),void 0!==r.extensions[l].diffuseTexture){var a=r.extensions[l].diffuseTexture;n.setDiffuseTexture(e.textures[s[a.index].source]),e.setTextureInfo(n.getDiffuseTextureInfo(),a),e.setTextureSampler(n.getDiffuseTextureSampler(),a)}if(void 0!==r.extensions[l].specularGlossinessTexture){var i=r.extensions[l].specularGlossinessTexture;n.setSpecularGlossinessTexture(e.textures[s[i.index].source]),e.setTextureInfo(n.getSpecularGlossinessTextureInfo(),i),e.setTextureSampler(n.getSpecularGlossinessTextureSampler(),i)}}}),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 o=e.materialIndexMap.get(r),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[l]={diffuseFactor:s.getDiffuseFactor(),specularFactor:s.getSpecularFactor(),glossinessFactor:s.getGlossinessFactor()},s.getDiffuseTexture()){var a=s.getDiffuseTexture(),i=s.getDiffuseTextureInfo(),u=s.getDiffuseTextureSampler();n.extensions[l].diffuseTexture=e.createTextureInfoDef(a,i,u)}if(s.getSpecularGlossinessTexture()){var x=s.getSpecularGlossinessTexture(),p=s.getSpecularGlossinessTextureInfo(),T=s.getSpecularGlossinessTextureSampler();n.extensions[l].specularGlossinessTexture=e.createTextureInfoDef(x,p,T)}}}),this},r}(e.Extension);x.EXTENSION_NAME=l;var p=function(r){function s(){var t;return(t=r.apply(this,arguments)||this).propertyType="Specular",t.parentTypes=[e.PropertyType.MATERIAL],t.extensionName="KHR_materials_specular",t._specularFactor=1,t._specularColorFactor=[1,1,1],t.specularTexture=null,t}t(s,r);var o=s.prototype;return o.copy=function(t,s){return void 0===s&&(s=e.COPY_IDENTITY),r.prototype.copy.call(this,t,s),this._specularFactor=t._specularFactor,t.specularTexture&&(this.setSpecularTexture(s(t.specularTexture.getChild())),this.specularTexture.copy(t.specularTexture)),this},o.getSpecularFactor=function(){return this._specularFactor},o.setSpecularFactor=function(e){return this._specularFactor=e,this},o.getSpecularColorFactor=function(){return this._specularColorFactor},o.setSpecularColorFactor=function(e){return this._specularColorFactor=e,this},o.getSpecularTexture=function(){return this.specularTexture?this.specularTexture.getChild():null},o.getSpecularTextureInfo=function(){return this.specularTexture?this.specularTexture.textureInfo:null},o.getSpecularTextureSampler=function(){return this.specularTexture?this.specularTexture.sampler:null},o.setSpecularTexture=function(e){return this.specularTexture=this.graph.linkTexture("specularTexture",this,e),this},s}(e.ExtensionProperty);p.EXTENSION_NAME="KHR_materials_specular",r([e.GraphChild],p.prototype,"specularTexture",void 0);var T="KHR_materials_specular",f=function(e){function r(){var t;return(t=e.apply(this,arguments)||this).extensionName=T,t}t(r,e);var s=r.prototype;return s.createSpecular=function(){return new p(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,o){if(r.extensions&&r.extensions[T]){var n=t.createSpecular();if(e.materials[o].setExtension(p,n),void 0!==r.extensions[T].specularFactor&&n.setSpecularFactor(r.extensions[T].specularFactor),void 0!==r.extensions[T].specularColorFactor&&n.setSpecularColorFactor(r.extensions[T].specularColorFactor),void 0!==r.extensions[T].specularTexture){var a=r.extensions[T].specularTexture;n.setSpecularTexture(e.textures[s[a.index].source]),e.setTextureInfo(n.getSpecularTextureInfo(),a),e.setTextureSampler(n.getSpecularTextureSampler(),a)}}}),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 o=e.materialIndexMap.get(r),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[T]={specularFactor:s.getSpecularFactor(),specularColorFactor:s.getSpecularColorFactor()},s.getSpecularTexture()){var a=s.getSpecularTexture(),i=s.getSpecularTextureInfo(),u=s.getSpecularTextureSampler();n.extensions[T].specularTexture=e.createTextureInfoDef(a,i,u)}}}),this},r}(e.Extension);f.EXTENSION_NAME=T;var h=function(r){function s(){var t;return(t=r.apply(this,arguments)||this).propertyType="Transmission",t.parentTypes=[e.PropertyType.MATERIAL],t.extensionName="KHR_materials_transmission",t._transmissionFactor=0,t.transmissionTexture=null,t}t(s,r);var o=s.prototype;return o.copy=function(t,s){return void 0===s&&(s=e.COPY_IDENTITY),r.prototype.copy.call(this,t,s),this._transmissionFactor=t._transmissionFactor,t.transmissionTexture&&(this.setTransmissionTexture(s(t.transmissionTexture.getChild())),this.transmissionTexture.copy(t.transmissionTexture)),this},o.getTransmissionFactor=function(){return this._transmissionFactor},o.setTransmissionFactor=function(e){return this._transmissionFactor=e,this},o.getTransmissionTexture=function(){return this.transmissionTexture?this.transmissionTexture.getChild():null},o.getTransmissionTextureInfo=function(){return this.transmissionTexture?this.transmissionTexture.textureInfo:null},o.getTransmissionTextureSampler=function(){return this.transmissionTexture?this.transmissionTexture.sampler:null},o.setTransmissionTexture=function(e){return this.transmissionTexture=this.graph.linkTexture("transmissionTexture",this,e),this},s}(e.ExtensionProperty);h.EXTENSION_NAME="KHR_materials_transmission",r([e.GraphChild],h.prototype,"transmissionTexture",void 0);var m="KHR_materials_transmission",g=function(e){function r(){var t;return(t=e.apply(this,arguments)||this).extensionName=m,t}t(r,e);var s=r.prototype;return s.createTransmission=function(){return new h(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,o){if(r.extensions&&r.extensions[m]){var n=t.createTransmission();if(e.materials[o].setExtension(h,n),void 0!==r.extensions[m].transmissionFactor&&n.setTransmissionFactor(r.extensions[m].transmissionFactor),void 0!==r.extensions[m].transmissionTexture){var a=r.extensions[m].transmissionTexture;n.setTransmissionTexture(e.textures[s[a.index].source]),e.setTextureInfo(n.getTransmissionTextureInfo(),a),e.setTextureSampler(n.getTransmissionTextureSampler(),a)}}}),this},s.write=function(e){var t=e.nativeDocument;return this.doc.getRoot().listMaterials().forEach(function(r){var s=r.getExtension(h);if(s){var o=e.materialIndexMap.get(r),n=t.json.materials[o];if(n.extensions=n.extensions||{},n.extensions[m]={transmissionFactor:s.getTransmissionFactor()},s.getTransmissionTexture()){var a=s.getTransmissionTexture(),i=s.getTransmissionTextureInfo(),u=s.getTransmissionTextureSampler();n.extensions[m].transmissionTexture=e.createTextureInfoDef(a,i,u)}}}),this},r}(e.Extension);g.EXTENSION_NAME=m;var v=function(r){function s(){var t;return(t=r.apply(this,arguments)||this).propertyType="Unlit",t.parentTypes=[e.PropertyType.MATERIAL],t.extensionName="KHR_materials_unlit",t}return t(s,r),s}(e.ExtensionProperty);v.EXTENSION_NAME="KHR_materials_unlit";var d="KHR_materials_unlit",_=function(e){function r(){var t;return(t=e.apply(this,arguments)||this).extensionName=d,t}t(r,e);var s=r.prototype;return s.createUnlit=function(){return new v(this.doc.getGraph(),this)},s.read=function(e){var t=this;return(e.nativeDocument.json.materials||[]).forEach(function(r,s){r.extensions&&r.extensions[d]&&e.materials[s].setExtension(v,t.createUnlit())}),this},s.write=function(e){var t=e.nativeDocument;return this.doc.getRoot().listMaterials().forEach(function(r){if(r.getExtension(v)){var s=e.materialIndexMap.get(r),o=t.json.materials[s];o.extensions=o.extensions||{},o.extensions[d]={}}}),this},r}(e.Extension);_.EXTENSION_NAME=d;var N="KHR_mesh_quantization",S=function(e){function r(){var t;return(t=e.apply(this,arguments)||this).extensionName=N,t}t(r,e);var s=r.prototype;return s.read=function(e){return this},s.write=function(e){return this},r}(e.Extension);S.EXTENSION_NAME=N;var y="KHR_texture_basisu",E=function(r){function s(){var t;return(t=r.apply(this,arguments)||this).extensionName=y,t.provideTypes=[e.PropertyType.TEXTURE],t}t(s,r);var o=s.prototype;return o.provide=function(e){return e.nativeDocument.json.textures.forEach(function(e){e.extensions&&e.extensions[y]&&(e.source=e.extensions[y].source)}),this},o.read=function(e){return this},o.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[y]={source:e.source},delete e.source)})}}),this},s}(e.Extension);E.EXTENSION_NAME=y;var F=[n,u,x,f,g,_,S,E];exports.Clearcoat=s,exports.IOR=a,exports.KHRONOS_EXTENSIONS=F,exports.MaterialsClearcoat=n,exports.MaterialsIOR=u,exports.MaterialsPBRSpecularGlossiness=x,exports.MaterialsSpecular=f,exports.MaterialsTransmission=g,exports.MaterialsUnlit=_,exports.MeshQuantization=S,exports.PBRSpecularGlossiness=c,exports.Specular=p,exports.TextureBasisu=E,exports.Transmission=h,exports.Unlit=v; | ||
//# sourceMappingURL=extensions.js.map |
@@ -1,2 +0,2 @@ | ||
import{ExtensionProperty as e,PropertyType as t,COPY_IDENTITY as r,GraphChild as a,Extension as o}from"@gltf-transform/core";function s(e,t,r,a){var o,s=arguments.length,c=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,r):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,r,a);else for(var l=e.length-1;l>=0;l--)(o=e[l])&&(c=(s<3?o(c):s>3?o(t,r,c):o(t,r))||c);return s>3&&c&&Object.defineProperty(t,r,c),c}class c 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=r){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}}c.EXTENSION_NAME="KHR_materials_clearcoat",s([a],c.prototype,"clearcoatTexture",void 0),s([a],c.prototype,"clearcoatRoughnessTexture",void 0),s([a],c.prototype,"clearcoatNormalTexture",void 0);const l="KHR_materials_clearcoat";class n extends o{constructor(){super(...arguments),this.extensionName=l}createClearcoat(){return new c(this.doc.getGraph(),this)}read(e){const t=e.nativeDocument,r=t.json.textures||[];return(t.json.materials||[]).forEach((t,a)=>{if(t.extensions&&t.extensions[l]){const o=this.createClearcoat();if(e.materials[a].setExtension(c,o),void 0!==t.extensions[l].clearcoatFactor&&o.setClearcoatFactor(t.extensions[l].clearcoatFactor),void 0!==t.extensions[l].clearcoatRoughnessFactor&&o.setClearcoatRoughnessFactor(t.extensions[l].clearcoatRoughnessFactor),void 0!==t.extensions[l].clearcoatTexture){const a=t.extensions[l].clearcoatTexture;o.setClearcoatTexture(e.textures[r[a.index].source]),e.setTextureInfo(o.getClearcoatTextureInfo(),a),e.setTextureSampler(o.getClearcoatTextureSampler(),a)}if(void 0!==t.extensions[l].clearcoatRoughnessTexture){const a=t.extensions[l].clearcoatRoughnessTexture;o.setClearcoatRoughnessTexture(e.textures[r[a.index].source]),e.setTextureInfo(o.getClearcoatRoughnessTextureInfo(),a),e.setTextureSampler(o.getClearcoatRoughnessTextureSampler(),a)}if(void 0!==t.extensions[l].clearcoatNormalTexture){const a=t.extensions[l].clearcoatNormalTexture;o.setClearcoatNormalTexture(e.textures[r[a.index].source]),e.setTextureInfo(o.getClearcoatNormalTextureInfo(),a),e.setTextureSampler(o.getClearcoatNormalTextureSampler(),a),void 0!==a.scale&&o.setClearcoatNormalScale(a.scale)}}}),this}write(e){const t=e.nativeDocument;return this.doc.getRoot().listMaterials().forEach(r=>{const a=r.getExtension(c);if(a){const o=e.materialIndexMap.get(r),s=t.json.materials[o];if(s.extensions=s.extensions||{},s.extensions[l]={clearcoatFactor:a.getClearcoatFactor(),clearcoatRoughnessFactor:a.getClearcoatRoughnessFactor()},a.getClearcoatTexture()){const t=a.getClearcoatTexture(),r=a.getClearcoatTextureInfo(),o=a.getClearcoatTextureSampler();s.extensions[l].clearcoatTexture=e.createTextureInfoDef(t,r,o)}if(a.getClearcoatRoughnessTexture()){const t=a.getClearcoatRoughnessTexture(),r=a.getClearcoatRoughnessTextureInfo(),o=a.getClearcoatRoughnessTextureSampler();s.extensions[l].clearcoatRoughnessTexture=e.createTextureInfoDef(t,r,o)}if(a.getClearcoatNormalTexture()){const t=a.getClearcoatNormalTexture(),r=a.getClearcoatNormalTextureInfo(),o=a.getClearcoatNormalTextureSampler();s.extensions[l].clearcoatNormalTexture=e.createTextureInfoDef(t,r,o),1!==a.getClearcoatNormalScale()&&(s.extensions[l].clearcoatNormalTexture.scale=a.getClearcoatNormalScale())}}}),this}}n.EXTENSION_NAME=l;class u extends e{constructor(){super(...arguments),this.propertyType="Unlit",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_unlit"}}u.EXTENSION_NAME="KHR_materials_unlit";const i="KHR_materials_unlit";class x extends o{constructor(){super(...arguments),this.extensionName=i}createUnlit(){return new u(this.doc.getGraph(),this)}read(e){return(e.nativeDocument.json.materials||[]).forEach((t,r)=>{t.extensions&&t.extensions[i]&&e.materials[r].setExtension(u,this.createUnlit())}),this}write(e){const t=e.nativeDocument;return this.doc.getRoot().listMaterials().forEach(r=>{if(r.getExtension(u)){const a=e.materialIndexMap.get(r),o=t.json.materials[a];o.extensions=o.extensions||{},o.extensions[i]={}}}),this}}x.EXTENSION_NAME=i;const h="KHR_mesh_quantization";class T extends o{constructor(){super(...arguments),this.extensionName=h}read(e){return this}write(e){return this}}T.EXTENSION_NAME=h;const g="KHR_texture_basisu";class m extends o{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(r=>{if("image/ktx2"===r.getMimeType()){const a=e.imageIndexMap.get(r);t.json.textures.forEach(e=>{e.source===a&&(e.extensions=e.extensions||{},e.extensions[g]={source:e.source},delete e.source)})}}),this}}m.EXTENSION_NAME=g;const N=[n,x,T,m];export{c as Clearcoat,N as KHRONOS_EXTENSIONS,n as MaterialsClearcoat,x as MaterialsUnlit,T as MeshQuantization,m as TextureBasisu,u as Unlit}; | ||
import{ExtensionProperty as e,PropertyType as t,COPY_IDENTITY as s,GraphChild as r,Extension as o}from"@gltf-transform/core";function a(e,t,s,r){var o,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,s,r);else for(var i=e.length-1;i>=0;i--)(o=e[i])&&(n=(a<3?o(n):a>3?o(t,s,n):o(t,s))||n);return a>3&&n&&Object.defineProperty(t,s,n),n}class n 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}}n.EXTENSION_NAME="KHR_materials_clearcoat",a([r],n.prototype,"clearcoatTexture",void 0),a([r],n.prototype,"clearcoatRoughnessTexture",void 0),a([r],n.prototype,"clearcoatNormalTexture",void 0);const i="KHR_materials_clearcoat";class u extends o{constructor(){super(...arguments),this.extensionName=i}createClearcoat(){return new n(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[i]){const o=this.createClearcoat();if(e.materials[r].setExtension(n,o),void 0!==t.extensions[i].clearcoatFactor&&o.setClearcoatFactor(t.extensions[i].clearcoatFactor),void 0!==t.extensions[i].clearcoatRoughnessFactor&&o.setClearcoatRoughnessFactor(t.extensions[i].clearcoatRoughnessFactor),void 0!==t.extensions[i].clearcoatTexture){const r=t.extensions[i].clearcoatTexture;o.setClearcoatTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getClearcoatTextureInfo(),r),e.setTextureSampler(o.getClearcoatTextureSampler(),r)}if(void 0!==t.extensions[i].clearcoatRoughnessTexture){const r=t.extensions[i].clearcoatRoughnessTexture;o.setClearcoatRoughnessTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getClearcoatRoughnessTextureInfo(),r),e.setTextureSampler(o.getClearcoatRoughnessTextureSampler(),r)}if(void 0!==t.extensions[i].clearcoatNormalTexture){const r=t.extensions[i].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(n);if(r){const o=e.materialIndexMap.get(s),a=t.json.materials[o];if(a.extensions=a.extensions||{},a.extensions[i]={clearcoatFactor:r.getClearcoatFactor(),clearcoatRoughnessFactor:r.getClearcoatRoughnessFactor()},r.getClearcoatTexture()){const t=r.getClearcoatTexture(),s=r.getClearcoatTextureInfo(),o=r.getClearcoatTextureSampler();a.extensions[i].clearcoatTexture=e.createTextureInfoDef(t,s,o)}if(r.getClearcoatRoughnessTexture()){const t=r.getClearcoatRoughnessTexture(),s=r.getClearcoatRoughnessTextureInfo(),o=r.getClearcoatRoughnessTextureSampler();a.extensions[i].clearcoatRoughnessTexture=e.createTextureInfoDef(t,s,o)}if(r.getClearcoatNormalTexture()){const t=r.getClearcoatNormalTexture(),s=r.getClearcoatNormalTextureInfo(),o=r.getClearcoatNormalTextureSampler();a.extensions[i].clearcoatNormalTexture=e.createTextureInfoDef(t,s,o),1!==r.getClearcoatNormalScale()&&(a.extensions[i].clearcoatNormalTexture.scale=r.getClearcoatNormalScale())}}}),this}}u.EXTENSION_NAME=i;class c 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}}c.EXTENSION_NAME="KHR_materials_ior";const l="KHR_materials_ior";class x extends o{constructor(){super(...arguments),this.extensionName=l}createIOR(){return new c(this.doc.getGraph(),this)}read(e){return(e.nativeDocument.json.materials||[]).forEach((t,s)=>{if(t.extensions&&t.extensions[l]){const r=this.createIOR();e.materials[s].setExtension(c,r),void 0!==t.extensions[l].ior&&r.setIOR(t.extensions[l].ior)}}),this}write(e){const t=e.nativeDocument;return this.doc.getRoot().listMaterials().forEach(s=>{const r=s.getExtension(c);if(r){const o=e.materialIndexMap.get(s),a=t.json.materials[o];a.extensions=a.extensions||{},a.extensions[l]={ior:r.getIOR()}}}),this}}x.EXTENSION_NAME=l;class h 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}}h.EXTENSION_NAME="KHR_materials_pbrSpecularGlossiness",a([r],h.prototype,"diffuseTexture",void 0),a([r],h.prototype,"specularGlossinessTexture",void 0);const T="KHR_materials_pbrSpecularGlossiness";class p extends o{constructor(){super(...arguments),this.extensionName=T}createPBRSpecularGlossiness(){return new h(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[T]){const o=this.createPBRSpecularGlossiness();if(e.materials[r].setExtension(h,o),void 0!==t.extensions[T].diffuseFactor&&o.setDiffuseFactor(t.extensions[T].diffuseFactor),void 0!==t.extensions[T].specularFactor&&o.setSpecularFactor(t.extensions[T].specularFactor),void 0!==t.extensions[T].glossinessFactor&&o.setGlossinessFactor(t.extensions[T].glossinessFactor),void 0!==t.extensions[T].diffuseTexture){const r=t.extensions[T].diffuseTexture;o.setDiffuseTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getDiffuseTextureInfo(),r),e.setTextureSampler(o.getDiffuseTextureSampler(),r)}if(void 0!==t.extensions[T].specularGlossinessTexture){const r=t.extensions[T].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(h);if(r){const o=e.materialIndexMap.get(s),a=t.json.materials[o];if(a.extensions=a.extensions||{},a.extensions[T]={diffuseFactor:r.getDiffuseFactor(),specularFactor:r.getSpecularFactor(),glossinessFactor:r.getGlossinessFactor()},r.getDiffuseTexture()){const t=r.getDiffuseTexture(),s=r.getDiffuseTextureInfo(),o=r.getDiffuseTextureSampler();a.extensions[T].diffuseTexture=e.createTextureInfoDef(t,s,o)}if(r.getSpecularGlossinessTexture()){const t=r.getSpecularGlossinessTexture(),s=r.getSpecularGlossinessTextureInfo(),o=r.getSpecularGlossinessTextureSampler();a.extensions[T].specularGlossinessTexture=e.createTextureInfoDef(t,s,o)}}}),this}}p.EXTENSION_NAME=T;class m 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}}m.EXTENSION_NAME="KHR_materials_specular",a([r],m.prototype,"specularTexture",void 0);const g="KHR_materials_specular";class f extends o{constructor(){super(...arguments),this.extensionName=g}createSpecular(){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[g]){const o=this.createSpecular();if(e.materials[r].setExtension(m,o),void 0!==t.extensions[g].specularFactor&&o.setSpecularFactor(t.extensions[g].specularFactor),void 0!==t.extensions[g].specularColorFactor&&o.setSpecularColorFactor(t.extensions[g].specularColorFactor),void 0!==t.extensions[g].specularTexture){const r=t.extensions[g].specularTexture;o.setSpecularTexture(e.textures[s[r.index].source]),e.setTextureInfo(o.getSpecularTextureInfo(),r),e.setTextureSampler(o.getSpecularTextureSampler(),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),a=t.json.materials[o];if(a.extensions=a.extensions||{},a.extensions[g]={specularFactor:r.getSpecularFactor(),specularColorFactor:r.getSpecularColorFactor()},r.getSpecularTexture()){const t=r.getSpecularTexture(),s=r.getSpecularTextureInfo(),o=r.getSpecularTextureSampler();a.extensions[g].specularTexture=e.createTextureInfoDef(t,s,o)}}}),this}}f.EXTENSION_NAME=g;class d 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}}d.EXTENSION_NAME="KHR_materials_transmission",a([r],d.prototype,"transmissionTexture",void 0);const _="KHR_materials_transmission";class S extends o{constructor(){super(...arguments),this.extensionName=_}createTransmission(){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[_]){const o=this.createTransmission();if(e.materials[r].setExtension(d,o),void 0!==t.extensions[_].transmissionFactor&&o.setTransmissionFactor(t.extensions[_].transmissionFactor),void 0!==t.extensions[_].transmissionTexture){const r=t.extensions[_].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(d);if(r){const o=e.materialIndexMap.get(s),a=t.json.materials[o];if(a.extensions=a.extensions||{},a.extensions[_]={transmissionFactor:r.getTransmissionFactor()},r.getTransmissionTexture()){const t=r.getTransmissionTexture(),s=r.getTransmissionTextureInfo(),o=r.getTransmissionTextureSampler();a.extensions[_].transmissionTexture=e.createTextureInfoDef(t,s,o)}}}),this}}S.EXTENSION_NAME=_;class N extends e{constructor(){super(...arguments),this.propertyType="Unlit",this.parentTypes=[t.MATERIAL],this.extensionName="KHR_materials_unlit"}}N.EXTENSION_NAME="KHR_materials_unlit";const F="KHR_materials_unlit";class R extends o{constructor(){super(...arguments),this.extensionName=F}createUnlit(){return new N(this.doc.getGraph(),this)}read(e){return(e.nativeDocument.json.materials||[]).forEach((t,s)=>{t.extensions&&t.extensions[F]&&e.materials[s].setExtension(N,this.createUnlit())}),this}write(e){const t=e.nativeDocument;return this.doc.getRoot().listMaterials().forEach(s=>{if(s.getExtension(N)){const r=e.materialIndexMap.get(s),o=t.json.materials[r];o.extensions=o.extensions||{},o.extensions[F]={}}}),this}}R.EXTENSION_NAME=F;const E="KHR_mesh_quantization";class C extends o{constructor(){super(...arguments),this.extensionName=E}read(e){return this}write(e){return this}}C.EXTENSION_NAME=E;const I="KHR_texture_basisu";class y extends o{constructor(){super(...arguments),this.extensionName=I,this.provideTypes=[t.TEXTURE]}provide(e){return e.nativeDocument.json.textures.forEach(e=>{e.extensions&&e.extensions[I]&&(e.source=e.extensions[I].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[I]={source:e.source},delete e.source)})}}),this}}y.EXTENSION_NAME=I;const G=[u,x,p,f,S,R,C,y];export{n as Clearcoat,c as IOR,G as KHRONOS_EXTENSIONS,u as MaterialsClearcoat,x as MaterialsIOR,p as MaterialsPBRSpecularGlossiness,f as MaterialsSpecular,S as MaterialsTransmission,R as MaterialsUnlit,C as MeshQuantization,h as PBRSpecularGlossiness,m as Specular,y as TextureBasisu,d as Transmission,N as Unlit}; | ||
//# sourceMappingURL=extensions.modern.js.map |
export declare const KHR_MATERIALS_CLEARCOAT = "KHR_materials_clearcoat"; | ||
export declare const KHR_MATERIALS_IOR = "KHR_materials_ior"; | ||
export declare const KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS = "KHR_materials_pbrSpecularGlossiness"; | ||
export declare const KHR_MATERIALS_SPECULAR = "KHR_materials_specular"; | ||
export declare const KHR_MATERIALS_TRANSMISSION = "KHR_materials_transmission"; | ||
export declare const KHR_MATERIALS_UNLIT = "KHR_materials_unlit"; | ||
export declare const KHR_MESH_QUANTIZATION = "KHR_mesh_quantization"; | ||
export declare const KHR_TEXTURE_BASISU = "KHR_texture_basisu"; |
import { MaterialsClearcoat } from './khr-materials-clearcoat'; | ||
import { MaterialsIOR } from './khr-materials-ior'; | ||
import { MaterialsPBRSpecularGlossiness } from './khr-materials-pbr-specular-glossiness'; | ||
import { MaterialsSpecular } from './khr-materials-specular'; | ||
import { MaterialsTransmission } from './khr-materials-transmission'; | ||
import { MaterialsUnlit } from './khr-materials-unlit'; | ||
@@ -6,5 +10,9 @@ import { MeshQuantization } from './khr-mesh-quantization'; | ||
export * from './khr-materials-clearcoat'; | ||
export * from './khr-materials-ior'; | ||
export * from './khr-materials-specular'; | ||
export * from './khr-materials-pbr-specular-glossiness'; | ||
export * from './khr-materials-transmission'; | ||
export * from './khr-materials-unlit'; | ||
export * from './khr-mesh-quantization'; | ||
export * from './khr-texture-basisu'; | ||
export declare const KHRONOS_EXTENSIONS: (typeof MaterialsClearcoat | typeof MaterialsUnlit | typeof MeshQuantization | typeof TextureBasisu)[]; | ||
export declare const KHRONOS_EXTENSIONS: (typeof MaterialsClearcoat | typeof MaterialsIOR | typeof MaterialsPBRSpecularGlossiness | typeof MaterialsSpecular | typeof MaterialsTransmission | typeof MaterialsUnlit | typeof MeshQuantization | typeof TextureBasisu)[]; |
export * from './ao'; | ||
export * from './colorspace'; | ||
export * from './dedup'; | ||
export * from './metal-rough'; | ||
export * from './partition'; | ||
export * from './inspect'; |
{ | ||
"name": "@gltf-transform/extensions", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"repository": "github:donmccurdy/glTF-Transform", | ||
@@ -24,3 +24,3 @@ "description": "Adds extension support to @gltf-transform/core", | ||
"dependencies": { | ||
"@gltf-transform/core": "^0.5.2" | ||
"@gltf-transform/core": "^0.5.3" | ||
}, | ||
@@ -33,3 +33,3 @@ "files": [ | ||
], | ||
"gitHead": "015684062116979c17053539f6ebf63e67263b4f" | ||
"gitHead": "6cfc741a055c508e9adb823169574b9a08599472" | ||
} |
export const KHR_MATERIALS_CLEARCOAT = 'KHR_materials_clearcoat'; | ||
export const KHR_MATERIALS_IOR = 'KHR_materials_ior'; | ||
export const KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS = 'KHR_materials_pbrSpecularGlossiness'; | ||
export const KHR_MATERIALS_SPECULAR = 'KHR_materials_specular'; | ||
export const KHR_MATERIALS_TRANSMISSION = 'KHR_materials_transmission'; | ||
export const KHR_MATERIALS_UNLIT = 'KHR_materials_unlit'; | ||
export const KHR_MESH_QUANTIZATION = 'KHR_mesh_quantization'; | ||
export const KHR_TEXTURE_BASISU = 'KHR_texture_basisu'; |
import { MaterialsClearcoat } from './khr-materials-clearcoat'; | ||
import { MaterialsIOR } from './khr-materials-ior'; | ||
import { MaterialsPBRSpecularGlossiness } from './khr-materials-pbr-specular-glossiness'; | ||
import { MaterialsSpecular } from './khr-materials-specular'; | ||
import { MaterialsTransmission } from './khr-materials-transmission'; | ||
import { MaterialsUnlit } from './khr-materials-unlit'; | ||
@@ -7,2 +11,6 @@ import { MeshQuantization } from './khr-mesh-quantization'; | ||
export * from './khr-materials-clearcoat'; | ||
export * from './khr-materials-ior'; | ||
export * from './khr-materials-specular'; | ||
export * from './khr-materials-pbr-specular-glossiness'; | ||
export * from './khr-materials-transmission'; | ||
export * from './khr-materials-unlit'; | ||
@@ -12,2 +20,11 @@ export * from './khr-mesh-quantization'; | ||
export const KHRONOS_EXTENSIONS = [ MaterialsClearcoat, MaterialsUnlit, MeshQuantization, TextureBasisu ]; | ||
export const KHRONOS_EXTENSIONS = [ | ||
MaterialsClearcoat, | ||
MaterialsIOR, | ||
MaterialsPBRSpecularGlossiness, | ||
MaterialsSpecular, | ||
MaterialsTransmission, | ||
MaterialsUnlit, | ||
MeshQuantization, | ||
TextureBasisu, | ||
]; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
444752
129
4527
Updated@gltf-transform/core@^0.5.3