{"version":3,"file":"functions.cjs","sources":["../src/utils.ts","../src/center.ts","../src/list-node-scenes.ts","../src/clear-node-parent.ts","../../../node_modules/gl-matrix/esm/common.js","../../../node_modules/gl-matrix/esm/mat4.js","../src/get-vertex-count.ts","../src/hash-table.ts","../src/compact-primitive.ts","../../../node_modules/gl-matrix/esm/mat3.js","../../../node_modules/gl-matrix/esm/vec3.js","../src/weld.ts","../src/transform-primitive.ts","../src/transform-mesh.ts","../src/clear-node-transform.ts","../src/convert-primitive-mode.ts","../src/dedup.ts","../src/dequantize.ts","../src/document-utils.ts","../src/draco.ts","../../../node_modules/gl-matrix/esm/vec4.js","../src/get-texture-color-space.ts","../src/list-texture-info.ts","../src/list-texture-slots.ts","../src/prune.ts","../src/flatten.ts","../src/get-bounds.ts","../src/inspect.ts","../src/instance.ts","../src/join-primitives.ts","../src/join.ts","../src/list-texture-channels.ts","../src/sort-primitive-weights.ts","../src/quantize.ts","../src/reorder.ts","../src/meshopt.ts","../src/metal-rough.ts","../src/unweld.ts","../src/normals.ts","../src/palette.ts","../src/partition.ts","../../../node_modules/keyframe-resample/dist/keyframe-resample-browser.modern.js","../src/resample.ts","../src/sequence.ts","../src/simplify.ts","../src/sparse.ts","../src/tangents.ts","../src/texture-compress.ts","../src/uninstance.ts","../src/unlit.ts","../src/unpartition.ts","../src/unwrap.ts","../src/vertex-color-space.ts"],"sourcesContent":["import {\n\ttype Accessor,\n\tDocument,\n\ttype GLTF,\n\tPrimitive,\n\ttype Property,\n\tPropertyType,\n\ttype Texture,\n\ttype Transform,\n\ttype TransformContext,\n\ttype vec2,\n} from '@gltf-transform/core';\nimport type { NdArray } from 'ndarray';\nimport { getPixels, savePixels } from 'ndarray-pixels';\n\nconst { POINTS, LINES, LINE_STRIP, LINE_LOOP, TRIANGLES, TRIANGLE_STRIP, TRIANGLE_FAN } = Primitive.Mode;\n\n/**\n * Prepares a function used in an {@link Document#transform} pipeline. Use of this wrapper is\n * optional, and plain functions may be used in transform pipelines just as well. The wrapper is\n * used internally so earlier pipeline stages can detect and optimize based on later stages.\n * @hidden\n */\nexport function createTransform(name: string, fn: Transform): Transform {\n\tObject.defineProperty(fn, 'name', { value: name });\n\treturn fn;\n}\n\n/** @hidden */\nexport function isTransformPending(context: TransformContext | undefined, initial: string, pending: string): boolean {\n\tif (!context) return false;\n\tconst initialIndex = context.stack.lastIndexOf(initial);\n\tconst pendingIndex = context.stack.lastIndexOf(pending);\n\treturn initialIndex < pendingIndex;\n}\n\n/**\n * Performs a shallow merge on an 'options' object and a 'defaults' object.\n * Equivalent to `{...defaults, ...options}` _except_ that `undefined` values\n * in the 'options' object are ignored.\n *\n * @hidden\n */\nexport function assignDefaults<Defaults, Options>(defaults: Defaults, options: Options): Defaults & Options {\n\tconst result = { ...defaults } as Defaults & Partial<Options>;\n\tfor (const key in options) {\n\t\tif (options[key] !== undefined) {\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: TODO\n\t\t\tresult[key] = options[key] as any;\n\t\t}\n\t}\n\treturn result as Defaults & Options;\n}\n\n/**\n * Maps pixels from source to target textures, with a per-pixel callback.\n * @hidden\n */\nexport async function rewriteTexture(\n\tsource: Texture,\n\ttarget: Texture,\n\tfn: (pixels: NdArray, i: number, j: number) => void,\n): Promise<Texture | null> {\n\tif (!source) return null;\n\n\tconst srcImage = source.getImage();\n\tif (!srcImage) return null;\n\n\tconst pixels = await getPixels(srcImage, source.getMimeType());\n\n\tfor (let i = 0; i < pixels.shape[0]; ++i) {\n\t\tfor (let j = 0; j < pixels.shape[1]; ++j) {\n\t\t\tfn(pixels, i, j);\n\t\t}\n\t}\n\n\tconst dstImage = await savePixels(pixels, 'image/png');\n\treturn target.setImage(dstImage).setMimeType('image/png');\n}\n\n/** @hidden */\nexport function getGLPrimitiveCount(prim: Primitive): number {\n\tconst indices = prim.getIndices();\n\tconst position = prim.getAttribute('POSITION')!;\n\n\t// Reference: https://www.khronos.org/opengl/wiki/Primitive\n\tswitch (prim.getMode()) {\n\t\tcase Primitive.Mode.POINTS:\n\t\t\treturn indices ? indices.getCount() : position.getCount();\n\t\tcase Primitive.Mode.LINES:\n\t\t\treturn indices ? indices.getCount() / 2 : position.getCount() / 2;\n\t\tcase Primitive.Mode.LINE_LOOP:\n\t\t\treturn indices ? indices.getCount() : position.getCount();\n\t\tcase Primitive.Mode.LINE_STRIP:\n\t\t\treturn indices ? indices.getCount() - 1 : position.getCount() - 1;\n\t\tcase Primitive.Mode.TRIANGLES:\n\t\t\treturn indices ? indices.getCount() / 3 : position.getCount() / 3;\n\t\tcase Primitive.Mode.TRIANGLE_STRIP:\n\t\tcase Primitive.Mode.TRIANGLE_FAN:\n\t\t\treturn indices ? indices.getCount() - 2 : position.getCount() - 2;\n\t\tdefault:\n\t\t\tthrow new Error('Unexpected mode: ' + prim.getMode());\n\t}\n}\n\n/** @hidden */\nexport class SetMap<K, V> {\n\tprivate _map = new Map<K, Set<V>>();\n\tpublic get size(): number {\n\t\treturn this._map.size;\n\t}\n\tpublic has(k: K): boolean {\n\t\treturn this._map.has(k);\n\t}\n\tpublic add(k: K, v: V): this {\n\t\tlet entry = this._map.get(k);\n\t\tif (!entry) {\n\t\t\tentry = new Set();\n\t\t\tthis._map.set(k, entry);\n\t\t}\n\t\tentry.add(v);\n\t\treturn this;\n\t}\n\tpublic get(k: K): Set<V> {\n\t\treturn this._map.get(k) || new Set();\n\t}\n\tpublic keys(): Iterable<K> {\n\t\treturn this._map.keys();\n\t}\n}\n\n/** @hidden */\nexport function formatBytes(bytes: number, decimals = 2): string {\n\tif (bytes === 0) return '0 Bytes';\n\n\tconst k = 1000;\n\tconst dm = decimals < 0 ? 0 : decimals;\n\tconst sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n\n\tconst i = Math.floor(Math.log(bytes) / Math.log(k));\n\n\treturn parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];\n}\n\nconst _longFormatter = new Intl.NumberFormat(undefined, { maximumFractionDigits: 0 });\n\n/** @hidden */\nexport function formatLong(x: number): string {\n\treturn _longFormatter.format(x);\n}\n\n/** @hidden */\nexport function formatDelta(a: number, b: number, decimals = 2): string {\n\tconst prefix = a > b ? '–' : '+';\n\tconst suffix = '%';\n\treturn prefix + ((Math.abs(a - b) / a) * 100).toFixed(decimals) + suffix;\n}\n\n/** @hidden */\nexport function formatDeltaOp(a: number, b: number) {\n\treturn `${formatLong(a)} → ${formatLong(b)} (${formatDelta(a, b)})`;\n}\n\n/**\n * Returns a list of all unique vertex attributes on the given primitive and\n * its morph targets.\n * @hidden\n */\nexport function deepListAttributes(prim: Primitive): Accessor[] {\n\tconst accessors: Accessor[] = [];\n\n\tfor (const attribute of prim.listAttributes()) {\n\t\taccessors.push(attribute);\n\t}\n\tfor (const target of prim.listTargets()) {\n\t\tfor (const attribute of target.listAttributes()) {\n\t\t\taccessors.push(attribute);\n\t\t}\n\t}\n\n\treturn Array.from(new Set(accessors));\n}\n\n/** @hidden */\nexport function deepSwapAttribute(prim: Primitive, src: Accessor, dst: Accessor): void {\n\tprim.swap(src, dst);\n\tfor (const target of prim.listTargets()) {\n\t\ttarget.swap(src, dst);\n\t}\n}\n\n/**\n * Disposes of a {@link Primitive} and any {@link Accessor Accesors} for which\n * it is the last remaining parent.\n * @hidden\n */\nexport function deepDisposePrimitive(prim: Primitive): void {\n\tconst indices = prim.getIndices();\n\tconst attributes = deepListAttributes(prim);\n\n\tprim.dispose();\n\n\tif (indices && !isUsed(indices)) {\n\t\tindices.dispose();\n\t}\n\n\tfor (const attribute of attributes) {\n\t\tif (!isUsed(attribute)) {\n\t\t\tattribute.dispose();\n\t\t}\n\t}\n}\n\n/** @hidden */\nexport function shallowEqualsArray(a: ArrayLike<unknown> | null, b: ArrayLike<unknown> | null): boolean {\n\tif (a == null && b == null) return true;\n\tif (a == null || b == null) return false;\n\tif (a.length !== b.length) return false;\n\tfor (let i = 0; i < a.length; i++) {\n\t\tif (a[i] !== b[i]) return false;\n\t}\n\treturn true;\n}\n\n/** Clones an {@link Accessor} without creating a copy of its underlying TypedArray data. */\nexport function shallowCloneAccessor(document: Document, accessor: Accessor): Accessor {\n\treturn document\n\t\t.createAccessor(accessor.getName())\n\t\t.setArray(accessor.getArray())\n\t\t.setType(accessor.getType())\n\t\t.setBuffer(accessor.getBuffer())\n\t\t.setNormalized(accessor.getNormalized())\n\t\t.setSparse(accessor.getSparse());\n}\n\n/** @hidden */\nexport function createIndices(\n\tcount: number,\n\tmaxIndex: number = count,\n): Uint16Array<ArrayBuffer> | Uint32Array<ArrayBuffer> {\n\tconst array = createIndicesEmpty(count, maxIndex);\n\tfor (let i = 0; i < array.length; i++) array[i] = i;\n\treturn array;\n}\n\n/** @hidden */\nexport function createIndicesEmpty(\n\tcount: number,\n\tmaxIndex: number = count,\n): Uint16Array<ArrayBuffer> | Uint32Array<ArrayBuffer> {\n\treturn maxIndex <= 65534 ? new Uint16Array(count) : new Uint32Array(count);\n}\n\n/** @hidden */\nexport function isUsed(prop: Property): boolean {\n\treturn prop.listParents().some((parent) => parent.propertyType !== PropertyType.ROOT);\n}\n\n/** @hidden */\nexport function isEmptyObject(object: Record<string, unknown>): boolean {\n\tfor (const _key in object) return false;\n\treturn true;\n}\n\n/**\n * Creates a unique key associated with the structure and draw call characteristics of\n * a {@link Primitive}, independent of its vertex content. Helper method, used to\n * identify candidate Primitives for joining.\n * @hidden\n */\nexport function createPrimGroupKey(prim: Primitive): string {\n\tconst document = Document.fromGraph(prim.getGraph())!;\n\tconst material = prim.getMaterial();\n\tconst materialIndex = document.getRoot().listMaterials().indexOf(material!);\n\tconst mode = BASIC_MODE_MAPPING[prim.getMode()];\n\tconst indices = !!prim.getIndices();\n\n\tconst attributes = prim\n\t\t.listSemantics()\n\t\t.sort()\n\t\t.map((semantic) => {\n\t\t\tconst attribute = prim.getAttribute(semantic)!;\n\t\t\tconst elementSize = attribute.getElementSize();\n\t\t\tconst componentType = attribute.getComponentType();\n\t\t\treturn `${semantic}:${elementSize}:${componentType}`;\n\t\t})\n\t\t.join('+');\n\n\tconst targets = prim\n\t\t.listTargets()\n\t\t.map((target) => {\n\t\t\treturn target\n\t\t\t\t.listSemantics()\n\t\t\t\t.sort()\n\t\t\t\t.map((semantic) => {\n\t\t\t\t\tconst attribute = prim.getAttribute(semantic)!;\n\t\t\t\t\tconst elementSize = attribute.getElementSize();\n\t\t\t\t\tconst componentType = attribute.getComponentType();\n\t\t\t\t\treturn `${semantic}:${elementSize}:${componentType}`;\n\t\t\t\t})\n\t\t\t\t.join('+');\n\t\t})\n\t\t.join('~');\n\n\treturn `${materialIndex}|${mode}|${indices}|${attributes}|${targets}`;\n}\n\n/**\n * Scales `size` NxN dimensions to fit within `limit` NxN dimensions, without\n * changing aspect ratio. If `size` <= `limit` in all dimensions, returns `size`.\n * @hidden\n */\nexport function fitWithin(size: vec2, limit: vec2): vec2 {\n\tconst [maxWidth, maxHeight] = limit;\n\tconst [srcWidth, srcHeight] = size;\n\n\tif (srcWidth <= maxWidth && srcHeight <= maxHeight) return size;\n\n\tlet dstWidth = srcWidth;\n\tlet dstHeight = srcHeight;\n\n\tif (dstWidth > maxWidth) {\n\t\tdstHeight = Math.floor(dstHeight * (maxWidth / dstWidth));\n\t\tdstWidth = maxWidth;\n\t}\n\n\tif (dstHeight > maxHeight) {\n\t\tdstWidth = Math.floor(dstWidth * (maxHeight / dstHeight));\n\t\tdstHeight = maxHeight;\n\t}\n\n\treturn [dstWidth, dstHeight];\n}\n\ntype ResizePreset = 'nearest-pot' | 'ceil-pot' | 'floor-pot';\n\n/**\n * Scales `size` NxN dimensions to the specified power of two.\n * @hidden\n */\nexport function fitPowerOfTwo(size: vec2, method: ResizePreset): vec2 {\n\tif (isPowerOfTwo(size[0]) && isPowerOfTwo(size[1])) {\n\t\treturn size;\n\t}\n\n\tswitch (method) {\n\t\tcase 'nearest-pot':\n\t\t\treturn size.map(nearestPowerOfTwo) as vec2;\n\t\tcase 'ceil-pot':\n\t\t\treturn size.map(ceilPowerOfTwo) as vec2;\n\t\tcase 'floor-pot':\n\t\t\treturn size.map(floorPowerOfTwo) as vec2;\n\t}\n}\n\nfunction isPowerOfTwo(value: number): boolean {\n\tif (value <= 2) return true;\n\treturn (value & (value - 1)) === 0 && value !== 0;\n}\n\nfunction nearestPowerOfTwo(value: number): number {\n\tif (value <= 4) return 4;\n\n\tconst lo = floorPowerOfTwo(value);\n\tconst hi = ceilPowerOfTwo(value);\n\n\tif (hi - value > value - lo) return lo;\n\treturn hi;\n}\n\nexport function floorPowerOfTwo(value: number): number {\n\treturn Math.pow(2, Math.floor(Math.log(value) / Math.LN2));\n}\n\nexport function ceilPowerOfTwo(value: number): number {\n\treturn Math.pow(2, Math.ceil(Math.log(value) / Math.LN2));\n}\n\n/**\n * Mapping from any glTF primitive mode to its equivalent basic mode, as returned by\n * {@link convertPrimitiveMode}.\n * @hidden\n */\nexport const BASIC_MODE_MAPPING = {\n\t[POINTS]: POINTS,\n\t[LINES]: LINES,\n\t[LINE_STRIP]: LINES,\n\t[LINE_LOOP]: LINES,\n\t[TRIANGLES]: TRIANGLES,\n\t[TRIANGLE_STRIP]: TRIANGLES,\n\t[TRIANGLE_FAN]: TRIANGLES,\n} as Record<GLTF.MeshPrimitiveMode, GLTF.MeshPrimitiveMode>;\n","import type { Document, Transform, vec3 } from '@gltf-transform/core';\nimport { getBounds } from '@gltf-transform/core';\nimport { assignDefaults, createTransform } from './utils.js';\n\nconst NAME = 'center';\n\n/** Options for the {@link center} function. */\nexport interface CenterOptions {\n\t/** Location on the model to be considered the pivot, and recentered at the origin. */\n\tpivot?: 'center' | 'above' | 'below' | vec3;\n}\n\nconst CENTER_DEFAULTS: Required<CenterOptions> = { pivot: 'center' };\n\n/**\n * Centers the {@link Scene} at the origin, or above/below it. Transformations from animation,\n * skinning, and morph targets are not taken into account.\n *\n * Example:\n *\n * ```ts\n * await document.transform(center({pivot: 'below'}));\n * ```\n *\n * @category Transforms\n */\nexport function center(_options: CenterOptions = CENTER_DEFAULTS): Transform {\n\tconst options = assignDefaults(CENTER_DEFAULTS, _options);\n\n\treturn createTransform(NAME, (doc: Document): void => {\n\t\tconst logger = doc.getLogger();\n\t\tconst root = doc.getRoot();\n\t\tconst isAnimated = root.listAnimations().length > 0 || root.listSkins().length > 0;\n\n\t\tdoc.getRoot()\n\t\t\t.listScenes()\n\t\t\t.forEach((scene, index) => {\n\t\t\t\tlogger.debug(`${NAME}: Scene ${index + 1} / ${root.listScenes().length}.`);\n\n\t\t\t\tlet pivot: vec3;\n\t\t\t\tif (typeof options.pivot === 'string') {\n\t\t\t\t\tconst bbox = getBounds(scene);\n\t\t\t\t\tpivot = [\n\t\t\t\t\t\t(bbox.max[0] - bbox.min[0]) / 2 + bbox.min[0],\n\t\t\t\t\t\t(bbox.max[1] - bbox.min[1]) / 2 + bbox.min[1],\n\t\t\t\t\t\t(bbox.max[2] - bbox.min[2]) / 2 + bbox.min[2],\n\t\t\t\t\t];\n\t\t\t\t\tif (options.pivot === 'above') pivot[1] = bbox.max[1];\n\t\t\t\t\tif (options.pivot === 'below') pivot[1] = bbox.min[1];\n\t\t\t\t} else {\n\t\t\t\t\tpivot = options.pivot as vec3;\n\t\t\t\t}\n\n\t\t\t\tlogger.debug(`${NAME}: Pivot \"${pivot.join(', ')}\".`);\n\n\t\t\t\tconst offset: vec3 = [-1 * pivot[0], -1 * pivot[1], -1 * pivot[2]];\n\n\t\t\t\tif (isAnimated) {\n\t\t\t\t\tlogger.debug(`${NAME}: Model contains animation or skin. Adding a wrapper node.`);\n\t\t\t\t\tconst offsetNode = doc.createNode('Pivot').setTranslation(offset);\n\t\t\t\t\tscene.listChildren().forEach((child) => offsetNode.addChild(child));\n\t\t\t\t\tscene.addChild(offsetNode);\n\t\t\t\t} else {\n\t\t\t\t\tlogger.debug(`${NAME}: Skipping wrapper, offsetting all root nodes.`);\n\t\t\t\t\tscene.listChildren().forEach((child) => {\n\t\t\t\t\t\tconst t = child.getTranslation();\n\t\t\t\t\t\tchild.setTranslation([t[0] + offset[0], t[1] + offset[1], t[2] + offset[2]]);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\n\t\tlogger.debug(`${NAME}: Complete.`);\n\t});\n}\n","import { type Node, Scene } from '@gltf-transform/core';\n\n/**\n * Finds the parent {@link Scene Scenes} associated with the given {@link Node}.\n * In most cases a Node is associated with only one Scene, but it is possible\n * for a Node to be located in two or more Scenes, or none at all.\n *\n * Example:\n *\n * ```typescript\n * import { listNodeScenes } from '@gltf-transform/functions';\n *\n * const node = document.getRoot().listNodes()\n *  .find((node) => node.getName() === 'MyNode');\n *\n * const scenes = listNodeScenes(node);\n * ```\n */\nexport function listNodeScenes(node: Node): Scene[] {\n\tconst visited = new Set<Node>();\n\n\tlet child = node;\n\tlet parent: Node | null;\n\n\twhile ((parent = child.getParentNode() as Node | null)) {\n\t\tif (visited.has(parent)) {\n\t\t\tthrow new Error('Circular dependency in scene graph.');\n\t\t}\n\t\tvisited.add(parent);\n\t\tchild = parent;\n\t}\n\n\treturn child.listParents().filter((parent) => parent instanceof Scene) as Scene[];\n}\n","import type { Node } from '@gltf-transform/core';\nimport { listNodeScenes } from './list-node-scenes.js';\n\n/**\n * Clears the parent of the given {@link Node}, leaving it attached\n * directly to its {@link Scene}. Inherited transforms will be applied\n * to the Node. This operation changes the Node's local transform,\n * but leaves its world transform unchanged.\n *\n * Example:\n *\n * ```typescript\n * import { clearNodeParent } from '@gltf-transform/functions';\n *\n * scene.traverse((node) => { ... }); // Scene → … → Node\n *\n * clearNodeParent(node);\n *\n * scene.traverse((node) => { ... }); // Scene → Node\n * ```\n *\n * To clear _all_ transforms of a Node, first clear its inherited transforms with\n * {@link clearNodeParent}, then clear the local transform with {@link clearNodeTransform}.\n */\nexport function clearNodeParent(node: Node): Node {\n\tconst scenes = listNodeScenes(node);\n\tconst parent = node.getParentNode();\n\n\tif (!parent) return node;\n\n\t// Apply inherited transforms to local matrix. Skinned meshes are not affected\n\t// by the node parent's transform, and can be ignored. Updates to IBMs and TRS\n\t// animations are out of scope in this context.\n\tnode.setMatrix(node.getWorldMatrix());\n\n\t// Add to Scene roots.\n\tparent.removeChild(node);\n\tfor (const scene of scenes) scene.addChild(node);\n\n\treturn node;\n}\n","/**\n * Common utilities\n * @module glMatrix\n */\n\n// Configuration Constants\nexport var EPSILON = 0.000001;\nexport var ARRAY_TYPE = typeof Float32Array !== \"undefined\" ? Float32Array : Array;\nexport var RANDOM = Math.random;\nexport var ANGLE_ORDER = \"zyx\";\n\n/**\n * Symmetric round\n * see https://www.npmjs.com/package/round-half-up-symmetric#user-content-detailed-background\n *\n * @param {Number} a value to round\n */\nexport function round(a) {\n  if (a >= 0) return Math.round(a);\n  return a % 0.5 === 0 ? Math.floor(a) : Math.round(a);\n}\n\n/**\n * Sets the type of array used when creating new vectors and matrices\n *\n * @param {Float32ArrayConstructor | ArrayConstructor} type Array type, such as Float32Array or Array\n */\nexport function setMatrixArrayType(type) {\n  ARRAY_TYPE = type;\n}\nvar degree = Math.PI / 180;\nvar radian = 180 / Math.PI;\n\n/**\n * Convert Degree To Radian\n *\n * @param {Number} a Angle in Degrees\n */\nexport function toRadian(a) {\n  return a * degree;\n}\n\n/**\n * Convert Radian To Degree\n *\n * @param {Number} a Angle in Radians\n */\nexport function toDegree(a) {\n  return a * radian;\n}\n\n/**\n * Tests whether or not the arguments have approximately the same value, within an absolute\n * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less\n * than or equal to 1.0, and a relative tolerance is used for larger values)\n *\n * @param {Number} a          The first number to test.\n * @param {Number} b          The second number to test.\n * @param {Number} tolerance  Absolute or relative tolerance (default glMatrix.EPSILON)\n * @returns {Boolean} True if the numbers are approximately equal, false otherwise.\n */\nexport function equals(a, b) {\n  var tolerance = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : EPSILON;\n  return Math.abs(a - b) <= tolerance * Math.max(1, Math.abs(a), Math.abs(b));\n}","import * as glMatrix from \"./common.js\";\n\n/**\n * 4x4 Matrix<br>Format: column-major, when typed out it looks like row-major<br>The matrices are being post multiplied.\n * @module mat4\n */\n\n/**\n * Creates a new identity mat4\n *\n * @returns {mat4} a new 4x4 matrix\n */\nexport function create() {\n  var out = new glMatrix.ARRAY_TYPE(16);\n  if (glMatrix.ARRAY_TYPE != Float32Array) {\n    out[1] = 0;\n    out[2] = 0;\n    out[3] = 0;\n    out[4] = 0;\n    out[6] = 0;\n    out[7] = 0;\n    out[8] = 0;\n    out[9] = 0;\n    out[11] = 0;\n    out[12] = 0;\n    out[13] = 0;\n    out[14] = 0;\n  }\n  out[0] = 1;\n  out[5] = 1;\n  out[10] = 1;\n  out[15] = 1;\n  return out;\n}\n\n/**\n * Creates a new mat4 initialized with values from an existing matrix\n *\n * @param {ReadonlyMat4} a matrix to clone\n * @returns {mat4} a new 4x4 matrix\n */\nexport function clone(a) {\n  var out = new glMatrix.ARRAY_TYPE(16);\n  out[0] = a[0];\n  out[1] = a[1];\n  out[2] = a[2];\n  out[3] = a[3];\n  out[4] = a[4];\n  out[5] = a[5];\n  out[6] = a[6];\n  out[7] = a[7];\n  out[8] = a[8];\n  out[9] = a[9];\n  out[10] = a[10];\n  out[11] = a[11];\n  out[12] = a[12];\n  out[13] = a[13];\n  out[14] = a[14];\n  out[15] = a[15];\n  return out;\n}\n\n/**\n * Copy the values from one mat4 to another\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the source matrix\n * @returns {mat4} out\n */\nexport function copy(out, a) {\n  out[0] = a[0];\n  out[1] = a[1];\n  out[2] = a[2];\n  out[3] = a[3];\n  out[4] = a[4];\n  out[5] = a[5];\n  out[6] = a[6];\n  out[7] = a[7];\n  out[8] = a[8];\n  out[9] = a[9];\n  out[10] = a[10];\n  out[11] = a[11];\n  out[12] = a[12];\n  out[13] = a[13];\n  out[14] = a[14];\n  out[15] = a[15];\n  return out;\n}\n\n/**\n * Create a new mat4 with the given values\n *\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\n * @param {Number} m03 Component in column 0, row 3 position (index 3)\n * @param {Number} m10 Component in column 1, row 0 position (index 4)\n * @param {Number} m11 Component in column 1, row 1 position (index 5)\n * @param {Number} m12 Component in column 1, row 2 position (index 6)\n * @param {Number} m13 Component in column 1, row 3 position (index 7)\n * @param {Number} m20 Component in column 2, row 0 position (index 8)\n * @param {Number} m21 Component in column 2, row 1 position (index 9)\n * @param {Number} m22 Component in column 2, row 2 position (index 10)\n * @param {Number} m23 Component in column 2, row 3 position (index 11)\n * @param {Number} m30 Component in column 3, row 0 position (index 12)\n * @param {Number} m31 Component in column 3, row 1 position (index 13)\n * @param {Number} m32 Component in column 3, row 2 position (index 14)\n * @param {Number} m33 Component in column 3, row 3 position (index 15)\n * @returns {mat4} A new mat4\n */\nexport function fromValues(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {\n  var out = new glMatrix.ARRAY_TYPE(16);\n  out[0] = m00;\n  out[1] = m01;\n  out[2] = m02;\n  out[3] = m03;\n  out[4] = m10;\n  out[5] = m11;\n  out[6] = m12;\n  out[7] = m13;\n  out[8] = m20;\n  out[9] = m21;\n  out[10] = m22;\n  out[11] = m23;\n  out[12] = m30;\n  out[13] = m31;\n  out[14] = m32;\n  out[15] = m33;\n  return out;\n}\n\n/**\n * Set the components of a mat4 to the given values\n *\n * @param {mat4} out the receiving matrix\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\n * @param {Number} m03 Component in column 0, row 3 position (index 3)\n * @param {Number} m10 Component in column 1, row 0 position (index 4)\n * @param {Number} m11 Component in column 1, row 1 position (index 5)\n * @param {Number} m12 Component in column 1, row 2 position (index 6)\n * @param {Number} m13 Component in column 1, row 3 position (index 7)\n * @param {Number} m20 Component in column 2, row 0 position (index 8)\n * @param {Number} m21 Component in column 2, row 1 position (index 9)\n * @param {Number} m22 Component in column 2, row 2 position (index 10)\n * @param {Number} m23 Component in column 2, row 3 position (index 11)\n * @param {Number} m30 Component in column 3, row 0 position (index 12)\n * @param {Number} m31 Component in column 3, row 1 position (index 13)\n * @param {Number} m32 Component in column 3, row 2 position (index 14)\n * @param {Number} m33 Component in column 3, row 3 position (index 15)\n * @returns {mat4} out\n */\nexport function set(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {\n  out[0] = m00;\n  out[1] = m01;\n  out[2] = m02;\n  out[3] = m03;\n  out[4] = m10;\n  out[5] = m11;\n  out[6] = m12;\n  out[7] = m13;\n  out[8] = m20;\n  out[9] = m21;\n  out[10] = m22;\n  out[11] = m23;\n  out[12] = m30;\n  out[13] = m31;\n  out[14] = m32;\n  out[15] = m33;\n  return out;\n}\n\n/**\n * Set a mat4 to the identity matrix\n *\n * @param {mat4} out the receiving matrix\n * @returns {mat4} out\n */\nexport function identity(out) {\n  out[0] = 1;\n  out[1] = 0;\n  out[2] = 0;\n  out[3] = 0;\n  out[4] = 0;\n  out[5] = 1;\n  out[6] = 0;\n  out[7] = 0;\n  out[8] = 0;\n  out[9] = 0;\n  out[10] = 1;\n  out[11] = 0;\n  out[12] = 0;\n  out[13] = 0;\n  out[14] = 0;\n  out[15] = 1;\n  return out;\n}\n\n/**\n * Transpose the values of a mat4\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the source matrix\n * @returns {mat4} out\n */\nexport function transpose(out, a) {\n  // If we are transposing ourselves we can skip a few steps but have to cache some values\n  if (out === a) {\n    var a01 = a[1],\n      a02 = a[2],\n      a03 = a[3];\n    var a12 = a[6],\n      a13 = a[7];\n    var a23 = a[11];\n    out[1] = a[4];\n    out[2] = a[8];\n    out[3] = a[12];\n    out[4] = a01;\n    out[6] = a[9];\n    out[7] = a[13];\n    out[8] = a02;\n    out[9] = a12;\n    out[11] = a[14];\n    out[12] = a03;\n    out[13] = a13;\n    out[14] = a23;\n  } else {\n    out[0] = a[0];\n    out[1] = a[4];\n    out[2] = a[8];\n    out[3] = a[12];\n    out[4] = a[1];\n    out[5] = a[5];\n    out[6] = a[9];\n    out[7] = a[13];\n    out[8] = a[2];\n    out[9] = a[6];\n    out[10] = a[10];\n    out[11] = a[14];\n    out[12] = a[3];\n    out[13] = a[7];\n    out[14] = a[11];\n    out[15] = a[15];\n  }\n  return out;\n}\n\n/**\n * Inverts a mat4\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the source matrix\n * @returns {mat4 | null} out, or null if source matrix is not invertible\n */\nexport function invert(out, a) {\n  var a00 = a[0],\n    a01 = a[1],\n    a02 = a[2],\n    a03 = a[3];\n  var a10 = a[4],\n    a11 = a[5],\n    a12 = a[6],\n    a13 = a[7];\n  var a20 = a[8],\n    a21 = a[9],\n    a22 = a[10],\n    a23 = a[11];\n  var a30 = a[12],\n    a31 = a[13],\n    a32 = a[14],\n    a33 = a[15];\n  var b00 = a00 * a11 - a01 * a10;\n  var b01 = a00 * a12 - a02 * a10;\n  var b02 = a00 * a13 - a03 * a10;\n  var b03 = a01 * a12 - a02 * a11;\n  var b04 = a01 * a13 - a03 * a11;\n  var b05 = a02 * a13 - a03 * a12;\n  var b06 = a20 * a31 - a21 * a30;\n  var b07 = a20 * a32 - a22 * a30;\n  var b08 = a20 * a33 - a23 * a30;\n  var b09 = a21 * a32 - a22 * a31;\n  var b10 = a21 * a33 - a23 * a31;\n  var b11 = a22 * a33 - a23 * a32;\n\n  // Calculate the determinant\n  var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n  if (!det) {\n    return null;\n  }\n  det = 1.0 / det;\n  out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;\n  out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;\n  out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;\n  out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;\n  out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;\n  out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;\n  out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;\n  out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;\n  out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;\n  out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;\n  out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;\n  out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;\n  out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;\n  out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;\n  out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;\n  out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;\n  return out;\n}\n\n/**\n * Calculates the adjugate of a mat4\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the source matrix\n * @returns {mat4} out\n */\nexport function adjoint(out, a) {\n  var a00 = a[0],\n    a01 = a[1],\n    a02 = a[2],\n    a03 = a[3];\n  var a10 = a[4],\n    a11 = a[5],\n    a12 = a[6],\n    a13 = a[7];\n  var a20 = a[8],\n    a21 = a[9],\n    a22 = a[10],\n    a23 = a[11];\n  var a30 = a[12],\n    a31 = a[13],\n    a32 = a[14],\n    a33 = a[15];\n  var b00 = a00 * a11 - a01 * a10;\n  var b01 = a00 * a12 - a02 * a10;\n  var b02 = a00 * a13 - a03 * a10;\n  var b03 = a01 * a12 - a02 * a11;\n  var b04 = a01 * a13 - a03 * a11;\n  var b05 = a02 * a13 - a03 * a12;\n  var b06 = a20 * a31 - a21 * a30;\n  var b07 = a20 * a32 - a22 * a30;\n  var b08 = a20 * a33 - a23 * a30;\n  var b09 = a21 * a32 - a22 * a31;\n  var b10 = a21 * a33 - a23 * a31;\n  var b11 = a22 * a33 - a23 * a32;\n  out[0] = a11 * b11 - a12 * b10 + a13 * b09;\n  out[1] = a02 * b10 - a01 * b11 - a03 * b09;\n  out[2] = a31 * b05 - a32 * b04 + a33 * b03;\n  out[3] = a22 * b04 - a21 * b05 - a23 * b03;\n  out[4] = a12 * b08 - a10 * b11 - a13 * b07;\n  out[5] = a00 * b11 - a02 * b08 + a03 * b07;\n  out[6] = a32 * b02 - a30 * b05 - a33 * b01;\n  out[7] = a20 * b05 - a22 * b02 + a23 * b01;\n  out[8] = a10 * b10 - a11 * b08 + a13 * b06;\n  out[9] = a01 * b08 - a00 * b10 - a03 * b06;\n  out[10] = a30 * b04 - a31 * b02 + a33 * b00;\n  out[11] = a21 * b02 - a20 * b04 - a23 * b00;\n  out[12] = a11 * b07 - a10 * b09 - a12 * b06;\n  out[13] = a00 * b09 - a01 * b07 + a02 * b06;\n  out[14] = a31 * b01 - a30 * b03 - a32 * b00;\n  out[15] = a20 * b03 - a21 * b01 + a22 * b00;\n  return out;\n}\n\n/**\n * Calculates the determinant of a mat4\n *\n * @param {ReadonlyMat4} a the source matrix\n * @returns {Number} determinant of a\n */\nexport function determinant(a) {\n  var a00 = a[0],\n    a01 = a[1],\n    a02 = a[2],\n    a03 = a[3];\n  var a10 = a[4],\n    a11 = a[5],\n    a12 = a[6],\n    a13 = a[7];\n  var a20 = a[8],\n    a21 = a[9],\n    a22 = a[10],\n    a23 = a[11];\n  var a30 = a[12],\n    a31 = a[13],\n    a32 = a[14],\n    a33 = a[15];\n  var b0 = a00 * a11 - a01 * a10;\n  var b1 = a00 * a12 - a02 * a10;\n  var b2 = a01 * a12 - a02 * a11;\n  var b3 = a20 * a31 - a21 * a30;\n  var b4 = a20 * a32 - a22 * a30;\n  var b5 = a21 * a32 - a22 * a31;\n  var b6 = a00 * b5 - a01 * b4 + a02 * b3;\n  var b7 = a10 * b5 - a11 * b4 + a12 * b3;\n  var b8 = a20 * b2 - a21 * b1 + a22 * b0;\n  var b9 = a30 * b2 - a31 * b1 + a32 * b0;\n\n  // Calculate the determinant\n  return a13 * b6 - a03 * b7 + a33 * b8 - a23 * b9;\n}\n\n/**\n * Multiplies two mat4s\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the first operand\n * @param {ReadonlyMat4} b the second operand\n * @returns {mat4} out\n */\nexport function multiply(out, a, b) {\n  var a00 = a[0],\n    a01 = a[1],\n    a02 = a[2],\n    a03 = a[3];\n  var a10 = a[4],\n    a11 = a[5],\n    a12 = a[6],\n    a13 = a[7];\n  var a20 = a[8],\n    a21 = a[9],\n    a22 = a[10],\n    a23 = a[11];\n  var a30 = a[12],\n    a31 = a[13],\n    a32 = a[14],\n    a33 = a[15];\n\n  // Cache only the current line of the second matrix\n  var b0 = b[0],\n    b1 = b[1],\n    b2 = b[2],\n    b3 = b[3];\n  out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n  out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n  out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n  out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n  b0 = b[4];\n  b1 = b[5];\n  b2 = b[6];\n  b3 = b[7];\n  out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n  out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n  out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n  out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n  b0 = b[8];\n  b1 = b[9];\n  b2 = b[10];\n  b3 = b[11];\n  out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n  out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n  out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n  out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n  b0 = b[12];\n  b1 = b[13];\n  b2 = b[14];\n  b3 = b[15];\n  out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n  out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n  out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n  out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n  return out;\n}\n\n/**\n * Translate a mat4 by the given vector\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to translate\n * @param {ReadonlyVec3} v vector to translate by\n * @returns {mat4} out\n */\nexport function translate(out, a, v) {\n  var x = v[0],\n    y = v[1],\n    z = v[2];\n  var a00, a01, a02, a03;\n  var a10, a11, a12, a13;\n  var a20, a21, a22, a23;\n  if (a === out) {\n    out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];\n    out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];\n    out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];\n    out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];\n  } else {\n    a00 = a[0];\n    a01 = a[1];\n    a02 = a[2];\n    a03 = a[3];\n    a10 = a[4];\n    a11 = a[5];\n    a12 = a[6];\n    a13 = a[7];\n    a20 = a[8];\n    a21 = a[9];\n    a22 = a[10];\n    a23 = a[11];\n    out[0] = a00;\n    out[1] = a01;\n    out[2] = a02;\n    out[3] = a03;\n    out[4] = a10;\n    out[5] = a11;\n    out[6] = a12;\n    out[7] = a13;\n    out[8] = a20;\n    out[9] = a21;\n    out[10] = a22;\n    out[11] = a23;\n    out[12] = a00 * x + a10 * y + a20 * z + a[12];\n    out[13] = a01 * x + a11 * y + a21 * z + a[13];\n    out[14] = a02 * x + a12 * y + a22 * z + a[14];\n    out[15] = a03 * x + a13 * y + a23 * z + a[15];\n  }\n  return out;\n}\n\n/**\n * Scales the mat4 by the dimensions in the given vec3 not using vectorization\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to scale\n * @param {ReadonlyVec3} v the vec3 to scale the matrix by\n * @returns {mat4} out\n **/\nexport function scale(out, a, v) {\n  var x = v[0],\n    y = v[1],\n    z = v[2];\n  out[0] = a[0] * x;\n  out[1] = a[1] * x;\n  out[2] = a[2] * x;\n  out[3] = a[3] * x;\n  out[4] = a[4] * y;\n  out[5] = a[5] * y;\n  out[6] = a[6] * y;\n  out[7] = a[7] * y;\n  out[8] = a[8] * z;\n  out[9] = a[9] * z;\n  out[10] = a[10] * z;\n  out[11] = a[11] * z;\n  out[12] = a[12];\n  out[13] = a[13];\n  out[14] = a[14];\n  out[15] = a[15];\n  return out;\n}\n\n/**\n * Rotates a mat4 by the given angle around the given axis\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @param {ReadonlyVec3} axis the axis to rotate around\n * @returns {mat4} out\n */\nexport function rotate(out, a, rad, axis) {\n  var x = axis[0],\n    y = axis[1],\n    z = axis[2];\n  var len = Math.sqrt(x * x + y * y + z * z);\n  var s, c, t;\n  var a00, a01, a02, a03;\n  var a10, a11, a12, a13;\n  var a20, a21, a22, a23;\n  var b00, b01, b02;\n  var b10, b11, b12;\n  var b20, b21, b22;\n  if (len < glMatrix.EPSILON) {\n    return null;\n  }\n  len = 1 / len;\n  x *= len;\n  y *= len;\n  z *= len;\n  s = Math.sin(rad);\n  c = Math.cos(rad);\n  t = 1 - c;\n  a00 = a[0];\n  a01 = a[1];\n  a02 = a[2];\n  a03 = a[3];\n  a10 = a[4];\n  a11 = a[5];\n  a12 = a[6];\n  a13 = a[7];\n  a20 = a[8];\n  a21 = a[9];\n  a22 = a[10];\n  a23 = a[11];\n\n  // Construct the elements of the rotation matrix\n  b00 = x * x * t + c;\n  b01 = y * x * t + z * s;\n  b02 = z * x * t - y * s;\n  b10 = x * y * t - z * s;\n  b11 = y * y * t + c;\n  b12 = z * y * t + x * s;\n  b20 = x * z * t + y * s;\n  b21 = y * z * t - x * s;\n  b22 = z * z * t + c;\n\n  // Perform rotation-specific matrix multiplication\n  out[0] = a00 * b00 + a10 * b01 + a20 * b02;\n  out[1] = a01 * b00 + a11 * b01 + a21 * b02;\n  out[2] = a02 * b00 + a12 * b01 + a22 * b02;\n  out[3] = a03 * b00 + a13 * b01 + a23 * b02;\n  out[4] = a00 * b10 + a10 * b11 + a20 * b12;\n  out[5] = a01 * b10 + a11 * b11 + a21 * b12;\n  out[6] = a02 * b10 + a12 * b11 + a22 * b12;\n  out[7] = a03 * b10 + a13 * b11 + a23 * b12;\n  out[8] = a00 * b20 + a10 * b21 + a20 * b22;\n  out[9] = a01 * b20 + a11 * b21 + a21 * b22;\n  out[10] = a02 * b20 + a12 * b21 + a22 * b22;\n  out[11] = a03 * b20 + a13 * b21 + a23 * b22;\n  if (a !== out) {\n    // If the source and destination differ, copy the unchanged last row\n    out[12] = a[12];\n    out[13] = a[13];\n    out[14] = a[14];\n    out[15] = a[15];\n  }\n  return out;\n}\n\n/**\n * Rotates a matrix by the given angle around the X axis\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\nexport function rotateX(out, a, rad) {\n  var s = Math.sin(rad);\n  var c = Math.cos(rad);\n  var a10 = a[4];\n  var a11 = a[5];\n  var a12 = a[6];\n  var a13 = a[7];\n  var a20 = a[8];\n  var a21 = a[9];\n  var a22 = a[10];\n  var a23 = a[11];\n  if (a !== out) {\n    // If the source and destination differ, copy the unchanged rows\n    out[0] = a[0];\n    out[1] = a[1];\n    out[2] = a[2];\n    out[3] = a[3];\n    out[12] = a[12];\n    out[13] = a[13];\n    out[14] = a[14];\n    out[15] = a[15];\n  }\n\n  // Perform axis-specific matrix multiplication\n  out[4] = a10 * c + a20 * s;\n  out[5] = a11 * c + a21 * s;\n  out[6] = a12 * c + a22 * s;\n  out[7] = a13 * c + a23 * s;\n  out[8] = a20 * c - a10 * s;\n  out[9] = a21 * c - a11 * s;\n  out[10] = a22 * c - a12 * s;\n  out[11] = a23 * c - a13 * s;\n  return out;\n}\n\n/**\n * Rotates a matrix by the given angle around the Y axis\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\nexport function rotateY(out, a, rad) {\n  var s = Math.sin(rad);\n  var c = Math.cos(rad);\n  var a00 = a[0];\n  var a01 = a[1];\n  var a02 = a[2];\n  var a03 = a[3];\n  var a20 = a[8];\n  var a21 = a[9];\n  var a22 = a[10];\n  var a23 = a[11];\n  if (a !== out) {\n    // If the source and destination differ, copy the unchanged rows\n    out[4] = a[4];\n    out[5] = a[5];\n    out[6] = a[6];\n    out[7] = a[7];\n    out[12] = a[12];\n    out[13] = a[13];\n    out[14] = a[14];\n    out[15] = a[15];\n  }\n\n  // Perform axis-specific matrix multiplication\n  out[0] = a00 * c - a20 * s;\n  out[1] = a01 * c - a21 * s;\n  out[2] = a02 * c - a22 * s;\n  out[3] = a03 * c - a23 * s;\n  out[8] = a00 * s + a20 * c;\n  out[9] = a01 * s + a21 * c;\n  out[10] = a02 * s + a22 * c;\n  out[11] = a03 * s + a23 * c;\n  return out;\n}\n\n/**\n * Rotates a matrix by the given angle around the Z axis\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\nexport function rotateZ(out, a, rad) {\n  var s = Math.sin(rad);\n  var c = Math.cos(rad);\n  var a00 = a[0];\n  var a01 = a[1];\n  var a02 = a[2];\n  var a03 = a[3];\n  var a10 = a[4];\n  var a11 = a[5];\n  var a12 = a[6];\n  var a13 = a[7];\n  if (a !== out) {\n    // If the source and destination differ, copy the unchanged last row\n    out[8] = a[8];\n    out[9] = a[9];\n    out[10] = a[10];\n    out[11] = a[11];\n    out[12] = a[12];\n    out[13] = a[13];\n    out[14] = a[14];\n    out[15] = a[15];\n  }\n\n  // Perform axis-specific matrix multiplication\n  out[0] = a00 * c + a10 * s;\n  out[1] = a01 * c + a11 * s;\n  out[2] = a02 * c + a12 * s;\n  out[3] = a03 * c + a13 * s;\n  out[4] = a10 * c - a00 * s;\n  out[5] = a11 * c - a01 * s;\n  out[6] = a12 * c - a02 * s;\n  out[7] = a13 * c - a03 * s;\n  return out;\n}\n\n/**\n * Creates a matrix from a vector translation\n * This is equivalent to (but much faster than):\n *\n *     mat4.identity(dest);\n *     mat4.translate(dest, dest, vec);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {ReadonlyVec3} v Translation vector\n * @returns {mat4} out\n */\nexport function fromTranslation(out, v) {\n  out[0] = 1;\n  out[1] = 0;\n  out[2] = 0;\n  out[3] = 0;\n  out[4] = 0;\n  out[5] = 1;\n  out[6] = 0;\n  out[7] = 0;\n  out[8] = 0;\n  out[9] = 0;\n  out[10] = 1;\n  out[11] = 0;\n  out[12] = v[0];\n  out[13] = v[1];\n  out[14] = v[2];\n  out[15] = 1;\n  return out;\n}\n\n/**\n * Creates a matrix from a vector scaling\n * This is equivalent to (but much faster than):\n *\n *     mat4.identity(dest);\n *     mat4.scale(dest, dest, vec);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {ReadonlyVec3} v Scaling vector\n * @returns {mat4} out\n */\nexport function fromScaling(out, v) {\n  out[0] = v[0];\n  out[1] = 0;\n  out[2] = 0;\n  out[3] = 0;\n  out[4] = 0;\n  out[5] = v[1];\n  out[6] = 0;\n  out[7] = 0;\n  out[8] = 0;\n  out[9] = 0;\n  out[10] = v[2];\n  out[11] = 0;\n  out[12] = 0;\n  out[13] = 0;\n  out[14] = 0;\n  out[15] = 1;\n  return out;\n}\n\n/**\n * Creates a matrix from a given angle around a given axis\n * This is equivalent to (but much faster than):\n *\n *     mat4.identity(dest);\n *     mat4.rotate(dest, dest, rad, axis);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @param {ReadonlyVec3} axis the axis to rotate around\n * @returns {mat4} out\n */\nexport function fromRotation(out, rad, axis) {\n  var x = axis[0],\n    y = axis[1],\n    z = axis[2];\n  var len = Math.sqrt(x * x + y * y + z * z);\n  var s, c, t;\n  if (len < glMatrix.EPSILON) {\n    return null;\n  }\n  len = 1 / len;\n  x *= len;\n  y *= len;\n  z *= len;\n  s = Math.sin(rad);\n  c = Math.cos(rad);\n  t = 1 - c;\n\n  // Perform rotation-specific matrix multiplication\n  out[0] = x * x * t + c;\n  out[1] = y * x * t + z * s;\n  out[2] = z * x * t - y * s;\n  out[3] = 0;\n  out[4] = x * y * t - z * s;\n  out[5] = y * y * t + c;\n  out[6] = z * y * t + x * s;\n  out[7] = 0;\n  out[8] = x * z * t + y * s;\n  out[9] = y * z * t - x * s;\n  out[10] = z * z * t + c;\n  out[11] = 0;\n  out[12] = 0;\n  out[13] = 0;\n  out[14] = 0;\n  out[15] = 1;\n  return out;\n}\n\n/**\n * Creates a matrix from the given angle around the X axis\n * This is equivalent to (but much faster than):\n *\n *     mat4.identity(dest);\n *     mat4.rotateX(dest, dest, rad);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\nexport function fromXRotation(out, rad) {\n  var s = Math.sin(rad);\n  var c = Math.cos(rad);\n\n  // Perform axis-specific matrix multiplication\n  out[0] = 1;\n  out[1] = 0;\n  out[2] = 0;\n  out[3] = 0;\n  out[4] = 0;\n  out[5] = c;\n  out[6] = s;\n  out[7] = 0;\n  out[8] = 0;\n  out[9] = -s;\n  out[10] = c;\n  out[11] = 0;\n  out[12] = 0;\n  out[13] = 0;\n  out[14] = 0;\n  out[15] = 1;\n  return out;\n}\n\n/**\n * Creates a matrix from the given angle around the Y axis\n * This is equivalent to (but much faster than):\n *\n *     mat4.identity(dest);\n *     mat4.rotateY(dest, dest, rad);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\nexport function fromYRotation(out, rad) {\n  var s = Math.sin(rad);\n  var c = Math.cos(rad);\n\n  // Perform axis-specific matrix multiplication\n  out[0] = c;\n  out[1] = 0;\n  out[2] = -s;\n  out[3] = 0;\n  out[4] = 0;\n  out[5] = 1;\n  out[6] = 0;\n  out[7] = 0;\n  out[8] = s;\n  out[9] = 0;\n  out[10] = c;\n  out[11] = 0;\n  out[12] = 0;\n  out[13] = 0;\n  out[14] = 0;\n  out[15] = 1;\n  return out;\n}\n\n/**\n * Creates a matrix from the given angle around the Z axis\n * This is equivalent to (but much faster than):\n *\n *     mat4.identity(dest);\n *     mat4.rotateZ(dest, dest, rad);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat4} out\n */\nexport function fromZRotation(out, rad) {\n  var s = Math.sin(rad);\n  var c = Math.cos(rad);\n\n  // Perform axis-specific matrix multiplication\n  out[0] = c;\n  out[1] = s;\n  out[2] = 0;\n  out[3] = 0;\n  out[4] = -s;\n  out[5] = c;\n  out[6] = 0;\n  out[7] = 0;\n  out[8] = 0;\n  out[9] = 0;\n  out[10] = 1;\n  out[11] = 0;\n  out[12] = 0;\n  out[13] = 0;\n  out[14] = 0;\n  out[15] = 1;\n  return out;\n}\n\n/**\n * Creates a matrix from a quaternion rotation and vector translation\n * This is equivalent to (but much faster than):\n *\n *     mat4.identity(dest);\n *     mat4.translate(dest, dest, vec);\n *     let quatMat = mat4.create();\n *     mat4.fromQuat(quatMat, quat);\n *     mat4.multiply(dest, dest, quatMat);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {quat} q Rotation quaternion\n * @param {ReadonlyVec3} v Translation vector\n * @returns {mat4} out\n */\nexport function fromRotationTranslation(out, q, v) {\n  // Quaternion math\n  var x = q[0],\n    y = q[1],\n    z = q[2],\n    w = q[3];\n  var x2 = x + x;\n  var y2 = y + y;\n  var z2 = z + z;\n  var xx = x * x2;\n  var xy = x * y2;\n  var xz = x * z2;\n  var yy = y * y2;\n  var yz = y * z2;\n  var zz = z * z2;\n  var wx = w * x2;\n  var wy = w * y2;\n  var wz = w * z2;\n  out[0] = 1 - (yy + zz);\n  out[1] = xy + wz;\n  out[2] = xz - wy;\n  out[3] = 0;\n  out[4] = xy - wz;\n  out[5] = 1 - (xx + zz);\n  out[6] = yz + wx;\n  out[7] = 0;\n  out[8] = xz + wy;\n  out[9] = yz - wx;\n  out[10] = 1 - (xx + yy);\n  out[11] = 0;\n  out[12] = v[0];\n  out[13] = v[1];\n  out[14] = v[2];\n  out[15] = 1;\n  return out;\n}\n\n/**\n * Creates a new mat4 from a dual quat.\n *\n * @param {mat4} out Matrix\n * @param {ReadonlyQuat2} a Dual Quaternion\n * @returns {mat4} mat4 receiving operation result\n */\nexport function fromQuat2(out, a) {\n  var translation = new glMatrix.ARRAY_TYPE(3);\n  var bx = -a[0],\n    by = -a[1],\n    bz = -a[2],\n    bw = a[3],\n    ax = a[4],\n    ay = a[5],\n    az = a[6],\n    aw = a[7];\n  var magnitude = bx * bx + by * by + bz * bz + bw * bw;\n  //Only scale if it makes sense\n  if (magnitude > 0) {\n    translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2 / magnitude;\n    translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2 / magnitude;\n    translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2 / magnitude;\n  } else {\n    translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2;\n    translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2;\n    translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2;\n  }\n  fromRotationTranslation(out, a, translation);\n  return out;\n}\n\n/**\n * Returns the translation vector component of a transformation\n *  matrix. If a matrix is built with fromRotationTranslation,\n *  the returned vector will be the same as the translation vector\n *  originally supplied.\n * @param  {vec3} out Vector to receive translation component\n * @param  {ReadonlyMat4} mat Matrix to be decomposed (input)\n * @return {vec3} out\n */\nexport function getTranslation(out, mat) {\n  out[0] = mat[12];\n  out[1] = mat[13];\n  out[2] = mat[14];\n  return out;\n}\n\n/**\n * Returns the scaling factor component of a transformation\n *  matrix. If a matrix is built with fromRotationTranslationScale\n *  with a normalized Quaternion parameter, the returned vector will be\n *  the same as the scaling vector\n *  originally supplied.\n * @param  {vec3} out Vector to receive scaling factor component\n * @param  {ReadonlyMat4} mat Matrix to be decomposed (input)\n * @return {vec3} out\n */\nexport function getScaling(out, mat) {\n  var m11 = mat[0];\n  var m12 = mat[1];\n  var m13 = mat[2];\n  var m21 = mat[4];\n  var m22 = mat[5];\n  var m23 = mat[6];\n  var m31 = mat[8];\n  var m32 = mat[9];\n  var m33 = mat[10];\n  out[0] = Math.sqrt(m11 * m11 + m12 * m12 + m13 * m13);\n  out[1] = Math.sqrt(m21 * m21 + m22 * m22 + m23 * m23);\n  out[2] = Math.sqrt(m31 * m31 + m32 * m32 + m33 * m33);\n  return out;\n}\n\n/**\n * Returns a quaternion representing the rotational component\n *  of a transformation matrix. If a matrix is built with\n *  fromRotationTranslation, the returned quaternion will be the\n *  same as the quaternion originally supplied.\n * @param {quat} out Quaternion to receive the rotation component\n * @param {ReadonlyMat4} mat Matrix to be decomposed (input)\n * @return {quat} out\n */\nexport function getRotation(out, mat) {\n  var scaling = new glMatrix.ARRAY_TYPE(3);\n  getScaling(scaling, mat);\n  var is1 = 1 / scaling[0];\n  var is2 = 1 / scaling[1];\n  var is3 = 1 / scaling[2];\n  var sm11 = mat[0] * is1;\n  var sm12 = mat[1] * is2;\n  var sm13 = mat[2] * is3;\n  var sm21 = mat[4] * is1;\n  var sm22 = mat[5] * is2;\n  var sm23 = mat[6] * is3;\n  var sm31 = mat[8] * is1;\n  var sm32 = mat[9] * is2;\n  var sm33 = mat[10] * is3;\n  var trace = sm11 + sm22 + sm33;\n  var S = 0;\n  if (trace > 0) {\n    S = Math.sqrt(trace + 1.0) * 2;\n    out[3] = 0.25 * S;\n    out[0] = (sm23 - sm32) / S;\n    out[1] = (sm31 - sm13) / S;\n    out[2] = (sm12 - sm21) / S;\n  } else if (sm11 > sm22 && sm11 > sm33) {\n    S = Math.sqrt(1.0 + sm11 - sm22 - sm33) * 2;\n    out[3] = (sm23 - sm32) / S;\n    out[0] = 0.25 * S;\n    out[1] = (sm12 + sm21) / S;\n    out[2] = (sm31 + sm13) / S;\n  } else if (sm22 > sm33) {\n    S = Math.sqrt(1.0 + sm22 - sm11 - sm33) * 2;\n    out[3] = (sm31 - sm13) / S;\n    out[0] = (sm12 + sm21) / S;\n    out[1] = 0.25 * S;\n    out[2] = (sm23 + sm32) / S;\n  } else {\n    S = Math.sqrt(1.0 + sm33 - sm11 - sm22) * 2;\n    out[3] = (sm12 - sm21) / S;\n    out[0] = (sm31 + sm13) / S;\n    out[1] = (sm23 + sm32) / S;\n    out[2] = 0.25 * S;\n  }\n  return out;\n}\n\n/**\n * Decomposes a transformation matrix into its rotation, translation\n * and scale components. Returns only the rotation component\n * @param  {quat} out_r Quaternion to receive the rotation component\n * @param  {vec3} out_t Vector to receive the translation vector\n * @param  {vec3} out_s Vector to receive the scaling factor\n * @param  {ReadonlyMat4} mat Matrix to be decomposed (input)\n * @returns {quat} out_r\n */\nexport function decompose(out_r, out_t, out_s, mat) {\n  out_t[0] = mat[12];\n  out_t[1] = mat[13];\n  out_t[2] = mat[14];\n  var m11 = mat[0];\n  var m12 = mat[1];\n  var m13 = mat[2];\n  var m21 = mat[4];\n  var m22 = mat[5];\n  var m23 = mat[6];\n  var m31 = mat[8];\n  var m32 = mat[9];\n  var m33 = mat[10];\n  out_s[0] = Math.sqrt(m11 * m11 + m12 * m12 + m13 * m13);\n  out_s[1] = Math.sqrt(m21 * m21 + m22 * m22 + m23 * m23);\n  out_s[2] = Math.sqrt(m31 * m31 + m32 * m32 + m33 * m33);\n  var is1 = 1 / out_s[0];\n  var is2 = 1 / out_s[1];\n  var is3 = 1 / out_s[2];\n  var sm11 = m11 * is1;\n  var sm12 = m12 * is2;\n  var sm13 = m13 * is3;\n  var sm21 = m21 * is1;\n  var sm22 = m22 * is2;\n  var sm23 = m23 * is3;\n  var sm31 = m31 * is1;\n  var sm32 = m32 * is2;\n  var sm33 = m33 * is3;\n  var trace = sm11 + sm22 + sm33;\n  var S = 0;\n  if (trace > 0) {\n    S = Math.sqrt(trace + 1.0) * 2;\n    out_r[3] = 0.25 * S;\n    out_r[0] = (sm23 - sm32) / S;\n    out_r[1] = (sm31 - sm13) / S;\n    out_r[2] = (sm12 - sm21) / S;\n  } else if (sm11 > sm22 && sm11 > sm33) {\n    S = Math.sqrt(1.0 + sm11 - sm22 - sm33) * 2;\n    out_r[3] = (sm23 - sm32) / S;\n    out_r[0] = 0.25 * S;\n    out_r[1] = (sm12 + sm21) / S;\n    out_r[2] = (sm31 + sm13) / S;\n  } else if (sm22 > sm33) {\n    S = Math.sqrt(1.0 + sm22 - sm11 - sm33) * 2;\n    out_r[3] = (sm31 - sm13) / S;\n    out_r[0] = (sm12 + sm21) / S;\n    out_r[1] = 0.25 * S;\n    out_r[2] = (sm23 + sm32) / S;\n  } else {\n    S = Math.sqrt(1.0 + sm33 - sm11 - sm22) * 2;\n    out_r[3] = (sm12 - sm21) / S;\n    out_r[0] = (sm31 + sm13) / S;\n    out_r[1] = (sm23 + sm32) / S;\n    out_r[2] = 0.25 * S;\n  }\n  return out_r;\n}\n\n/**\n * Creates a matrix from a quaternion rotation, vector translation and vector scale\n * This is equivalent to (but much faster than):\n *\n *     mat4.identity(dest);\n *     mat4.translate(dest, dest, vec);\n *     let quatMat = mat4.create();\n *     mat4.fromQuat(quatMat, quat);\n *     mat4.multiply(dest, dest, quatMat);\n *     mat4.scale(dest, dest, scale)\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {quat} q Rotation quaternion\n * @param {ReadonlyVec3} v Translation vector\n * @param {ReadonlyVec3} s Scaling vector\n * @returns {mat4} out\n */\nexport function fromRotationTranslationScale(out, q, v, s) {\n  // Quaternion math\n  var x = q[0],\n    y = q[1],\n    z = q[2],\n    w = q[3];\n  var x2 = x + x;\n  var y2 = y + y;\n  var z2 = z + z;\n  var xx = x * x2;\n  var xy = x * y2;\n  var xz = x * z2;\n  var yy = y * y2;\n  var yz = y * z2;\n  var zz = z * z2;\n  var wx = w * x2;\n  var wy = w * y2;\n  var wz = w * z2;\n  var sx = s[0];\n  var sy = s[1];\n  var sz = s[2];\n  out[0] = (1 - (yy + zz)) * sx;\n  out[1] = (xy + wz) * sx;\n  out[2] = (xz - wy) * sx;\n  out[3] = 0;\n  out[4] = (xy - wz) * sy;\n  out[5] = (1 - (xx + zz)) * sy;\n  out[6] = (yz + wx) * sy;\n  out[7] = 0;\n  out[8] = (xz + wy) * sz;\n  out[9] = (yz - wx) * sz;\n  out[10] = (1 - (xx + yy)) * sz;\n  out[11] = 0;\n  out[12] = v[0];\n  out[13] = v[1];\n  out[14] = v[2];\n  out[15] = 1;\n  return out;\n}\n\n/**\n * Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin\n * This is equivalent to (but much faster than):\n *\n *     mat4.identity(dest);\n *     mat4.translate(dest, dest, vec);\n *     mat4.translate(dest, dest, origin);\n *     let quatMat = mat4.create();\n *     mat4.fromQuat(quatMat, quat);\n *     mat4.multiply(dest, dest, quatMat);\n *     mat4.scale(dest, dest, scale)\n *     mat4.translate(dest, dest, negativeOrigin);\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {quat} q Rotation quaternion\n * @param {ReadonlyVec3} v Translation vector\n * @param {ReadonlyVec3} s Scaling vector\n * @param {ReadonlyVec3} o The origin vector around which to scale and rotate\n * @returns {mat4} out\n */\nexport function fromRotationTranslationScaleOrigin(out, q, v, s, o) {\n  // Quaternion math\n  var x = q[0],\n    y = q[1],\n    z = q[2],\n    w = q[3];\n  var x2 = x + x;\n  var y2 = y + y;\n  var z2 = z + z;\n  var xx = x * x2;\n  var xy = x * y2;\n  var xz = x * z2;\n  var yy = y * y2;\n  var yz = y * z2;\n  var zz = z * z2;\n  var wx = w * x2;\n  var wy = w * y2;\n  var wz = w * z2;\n  var sx = s[0];\n  var sy = s[1];\n  var sz = s[2];\n  var ox = o[0];\n  var oy = o[1];\n  var oz = o[2];\n  var out0 = (1 - (yy + zz)) * sx;\n  var out1 = (xy + wz) * sx;\n  var out2 = (xz - wy) * sx;\n  var out4 = (xy - wz) * sy;\n  var out5 = (1 - (xx + zz)) * sy;\n  var out6 = (yz + wx) * sy;\n  var out8 = (xz + wy) * sz;\n  var out9 = (yz - wx) * sz;\n  var out10 = (1 - (xx + yy)) * sz;\n  out[0] = out0;\n  out[1] = out1;\n  out[2] = out2;\n  out[3] = 0;\n  out[4] = out4;\n  out[5] = out5;\n  out[6] = out6;\n  out[7] = 0;\n  out[8] = out8;\n  out[9] = out9;\n  out[10] = out10;\n  out[11] = 0;\n  out[12] = v[0] + ox - (out0 * ox + out4 * oy + out8 * oz);\n  out[13] = v[1] + oy - (out1 * ox + out5 * oy + out9 * oz);\n  out[14] = v[2] + oz - (out2 * ox + out6 * oy + out10 * oz);\n  out[15] = 1;\n  return out;\n}\n\n/**\n * Calculates a 4x4 matrix from the given quaternion\n *\n * @param {mat4} out mat4 receiving operation result\n * @param {ReadonlyQuat} q Quaternion to create matrix from\n *\n * @returns {mat4} out\n */\nexport function fromQuat(out, q) {\n  var x = q[0],\n    y = q[1],\n    z = q[2],\n    w = q[3];\n  var x2 = x + x;\n  var y2 = y + y;\n  var z2 = z + z;\n  var xx = x * x2;\n  var yx = y * x2;\n  var yy = y * y2;\n  var zx = z * x2;\n  var zy = z * y2;\n  var zz = z * z2;\n  var wx = w * x2;\n  var wy = w * y2;\n  var wz = w * z2;\n  out[0] = 1 - yy - zz;\n  out[1] = yx + wz;\n  out[2] = zx - wy;\n  out[3] = 0;\n  out[4] = yx - wz;\n  out[5] = 1 - xx - zz;\n  out[6] = zy + wx;\n  out[7] = 0;\n  out[8] = zx + wy;\n  out[9] = zy - wx;\n  out[10] = 1 - xx - yy;\n  out[11] = 0;\n  out[12] = 0;\n  out[13] = 0;\n  out[14] = 0;\n  out[15] = 1;\n  return out;\n}\n\n/**\n * Generates a frustum matrix with the given bounds\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {Number} left Left bound of the frustum\n * @param {Number} right Right bound of the frustum\n * @param {Number} bottom Bottom bound of the frustum\n * @param {Number} top Top bound of the frustum\n * @param {Number} near Near bound of the frustum\n * @param {Number} far Far bound of the frustum\n * @returns {mat4} out\n */\nexport function frustum(out, left, right, bottom, top, near, far) {\n  var rl = 1 / (right - left);\n  var tb = 1 / (top - bottom);\n  var nf = 1 / (near - far);\n  out[0] = near * 2 * rl;\n  out[1] = 0;\n  out[2] = 0;\n  out[3] = 0;\n  out[4] = 0;\n  out[5] = near * 2 * tb;\n  out[6] = 0;\n  out[7] = 0;\n  out[8] = (right + left) * rl;\n  out[9] = (top + bottom) * tb;\n  out[10] = (far + near) * nf;\n  out[11] = -1;\n  out[12] = 0;\n  out[13] = 0;\n  out[14] = far * near * 2 * nf;\n  out[15] = 0;\n  return out;\n}\n\n/**\n * Generates a perspective projection matrix with the given bounds.\n * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1],\n * which matches WebGL/OpenGL's clip volume.\n * Passing null/undefined/no value for far will generate infinite projection matrix.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {number} fovy Vertical field of view in radians\n * @param {number} aspect Aspect ratio. typically viewport width/height\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum, can be null or Infinity\n * @returns {mat4} out\n */\nexport function perspectiveNO(out, fovy, aspect, near, far) {\n  var f = 1.0 / Math.tan(fovy / 2);\n  out[0] = f / aspect;\n  out[1] = 0;\n  out[2] = 0;\n  out[3] = 0;\n  out[4] = 0;\n  out[5] = f;\n  out[6] = 0;\n  out[7] = 0;\n  out[8] = 0;\n  out[9] = 0;\n  out[11] = -1;\n  out[12] = 0;\n  out[13] = 0;\n  out[15] = 0;\n  if (far != null && far !== Infinity) {\n    var nf = 1 / (near - far);\n    out[10] = (far + near) * nf;\n    out[14] = 2 * far * near * nf;\n  } else {\n    out[10] = -1;\n    out[14] = -2 * near;\n  }\n  return out;\n}\n\n/**\n * Alias for {@link mat4.perspectiveNO}\n * @function\n */\nexport var perspective = perspectiveNO;\n\n/**\n * Generates a perspective projection matrix suitable for WebGPU with the given bounds.\n * The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1],\n * which matches WebGPU/Vulkan/DirectX/Metal's clip volume.\n * Passing null/undefined/no value for far will generate infinite projection matrix.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {number} fovy Vertical field of view in radians\n * @param {number} aspect Aspect ratio. typically viewport width/height\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum, can be null or Infinity\n * @returns {mat4} out\n */\nexport function perspectiveZO(out, fovy, aspect, near, far) {\n  var f = 1.0 / Math.tan(fovy / 2);\n  out[0] = f / aspect;\n  out[1] = 0;\n  out[2] = 0;\n  out[3] = 0;\n  out[4] = 0;\n  out[5] = f;\n  out[6] = 0;\n  out[7] = 0;\n  out[8] = 0;\n  out[9] = 0;\n  out[11] = -1;\n  out[12] = 0;\n  out[13] = 0;\n  out[15] = 0;\n  if (far != null && far !== Infinity) {\n    var nf = 1 / (near - far);\n    out[10] = far * nf;\n    out[14] = far * near * nf;\n  } else {\n    out[10] = -1;\n    out[14] = -near;\n  }\n  return out;\n}\n\n/**\n * Generates a perspective projection matrix with the given field of view.\n * This is primarily useful for generating projection matrices to be used\n * with the still experiemental WebVR API.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {Object} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum\n * @returns {mat4} out\n */\nexport function perspectiveFromFieldOfView(out, fov, near, far) {\n  var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);\n  var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);\n  var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);\n  var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);\n  var xScale = 2.0 / (leftTan + rightTan);\n  var yScale = 2.0 / (upTan + downTan);\n  out[0] = xScale;\n  out[1] = 0.0;\n  out[2] = 0.0;\n  out[3] = 0.0;\n  out[4] = 0.0;\n  out[5] = yScale;\n  out[6] = 0.0;\n  out[7] = 0.0;\n  out[8] = -((leftTan - rightTan) * xScale * 0.5);\n  out[9] = (upTan - downTan) * yScale * 0.5;\n  out[10] = far / (near - far);\n  out[11] = -1.0;\n  out[12] = 0.0;\n  out[13] = 0.0;\n  out[14] = far * near / (near - far);\n  out[15] = 0.0;\n  return out;\n}\n\n/**\n * Generates a orthogonal projection matrix with the given bounds.\n * The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1],\n * which matches WebGL/OpenGL's clip volume.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {number} left Left bound of the frustum\n * @param {number} right Right bound of the frustum\n * @param {number} bottom Bottom bound of the frustum\n * @param {number} top Top bound of the frustum\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum\n * @returns {mat4} out\n */\nexport function orthoNO(out, left, right, bottom, top, near, far) {\n  var lr = 1 / (left - right);\n  var bt = 1 / (bottom - top);\n  var nf = 1 / (near - far);\n  out[0] = -2 * lr;\n  out[1] = 0;\n  out[2] = 0;\n  out[3] = 0;\n  out[4] = 0;\n  out[5] = -2 * bt;\n  out[6] = 0;\n  out[7] = 0;\n  out[8] = 0;\n  out[9] = 0;\n  out[10] = 2 * nf;\n  out[11] = 0;\n  out[12] = (left + right) * lr;\n  out[13] = (top + bottom) * bt;\n  out[14] = (far + near) * nf;\n  out[15] = 1;\n  return out;\n}\n\n/**\n * Alias for {@link mat4.orthoNO}\n * @function\n */\nexport var ortho = orthoNO;\n\n/**\n * Generates a orthogonal projection matrix with the given bounds.\n * The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1],\n * which matches WebGPU/Vulkan/DirectX/Metal's clip volume.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {number} left Left bound of the frustum\n * @param {number} right Right bound of the frustum\n * @param {number} bottom Bottom bound of the frustum\n * @param {number} top Top bound of the frustum\n * @param {number} near Near bound of the frustum\n * @param {number} far Far bound of the frustum\n * @returns {mat4} out\n */\nexport function orthoZO(out, left, right, bottom, top, near, far) {\n  var lr = 1 / (left - right);\n  var bt = 1 / (bottom - top);\n  var nf = 1 / (near - far);\n  out[0] = -2 * lr;\n  out[1] = 0;\n  out[2] = 0;\n  out[3] = 0;\n  out[4] = 0;\n  out[5] = -2 * bt;\n  out[6] = 0;\n  out[7] = 0;\n  out[8] = 0;\n  out[9] = 0;\n  out[10] = nf;\n  out[11] = 0;\n  out[12] = (left + right) * lr;\n  out[13] = (top + bottom) * bt;\n  out[14] = near * nf;\n  out[15] = 1;\n  return out;\n}\n\n/**\n * Generates a look-at matrix with the given eye position, focal point, and up axis.\n * If you want a matrix that actually makes an object look at another object, you should use targetTo instead.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {ReadonlyVec3} eye Position of the viewer\n * @param {ReadonlyVec3} center Point the viewer is looking at\n * @param {ReadonlyVec3} up vec3 pointing up\n * @returns {mat4} out\n */\nexport function lookAt(out, eye, center, up) {\n  var x0, x1, x2, y0, y1, y2, z0, z1, z2, len;\n  var eyex = eye[0];\n  var eyey = eye[1];\n  var eyez = eye[2];\n  var upx = up[0];\n  var upy = up[1];\n  var upz = up[2];\n  var centerx = center[0];\n  var centery = center[1];\n  var centerz = center[2];\n  if (Math.abs(eyex - centerx) < glMatrix.EPSILON && Math.abs(eyey - centery) < glMatrix.EPSILON && Math.abs(eyez - centerz) < glMatrix.EPSILON) {\n    return identity(out);\n  }\n  z0 = eyex - centerx;\n  z1 = eyey - centery;\n  z2 = eyez - centerz;\n  len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2);\n  z0 *= len;\n  z1 *= len;\n  z2 *= len;\n  x0 = upy * z2 - upz * z1;\n  x1 = upz * z0 - upx * z2;\n  x2 = upx * z1 - upy * z0;\n  len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2);\n  if (!len) {\n    x0 = 0;\n    x1 = 0;\n    x2 = 0;\n  } else {\n    len = 1 / len;\n    x0 *= len;\n    x1 *= len;\n    x2 *= len;\n  }\n  y0 = z1 * x2 - z2 * x1;\n  y1 = z2 * x0 - z0 * x2;\n  y2 = z0 * x1 - z1 * x0;\n  len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2);\n  if (!len) {\n    y0 = 0;\n    y1 = 0;\n    y2 = 0;\n  } else {\n    len = 1 / len;\n    y0 *= len;\n    y1 *= len;\n    y2 *= len;\n  }\n  out[0] = x0;\n  out[1] = y0;\n  out[2] = z0;\n  out[3] = 0;\n  out[4] = x1;\n  out[5] = y1;\n  out[6] = z1;\n  out[7] = 0;\n  out[8] = x2;\n  out[9] = y2;\n  out[10] = z2;\n  out[11] = 0;\n  out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez);\n  out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez);\n  out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez);\n  out[15] = 1;\n  return out;\n}\n\n/**\n * Generates a matrix that makes something look at something else.\n *\n * @param {mat4} out mat4 frustum matrix will be written into\n * @param {ReadonlyVec3} eye Position of the viewer\n * @param {ReadonlyVec3} target Point the viewer is looking at\n * @param {ReadonlyVec3} up vec3 pointing up\n * @returns {mat4} out\n */\nexport function targetTo(out, eye, target, up) {\n  var eyex = eye[0],\n    eyey = eye[1],\n    eyez = eye[2],\n    upx = up[0],\n    upy = up[1],\n    upz = up[2];\n  var z0 = eyex - target[0],\n    z1 = eyey - target[1],\n    z2 = eyez - target[2];\n  var len = z0 * z0 + z1 * z1 + z2 * z2;\n  if (len > 0) {\n    len = 1 / Math.sqrt(len);\n    z0 *= len;\n    z1 *= len;\n    z2 *= len;\n  }\n  var x0 = upy * z2 - upz * z1,\n    x1 = upz * z0 - upx * z2,\n    x2 = upx * z1 - upy * z0;\n  len = x0 * x0 + x1 * x1 + x2 * x2;\n  if (len > 0) {\n    len = 1 / Math.sqrt(len);\n    x0 *= len;\n    x1 *= len;\n    x2 *= len;\n  }\n  out[0] = x0;\n  out[1] = x1;\n  out[2] = x2;\n  out[3] = 0;\n  out[4] = z1 * x2 - z2 * x1;\n  out[5] = z2 * x0 - z0 * x2;\n  out[6] = z0 * x1 - z1 * x0;\n  out[7] = 0;\n  out[8] = z0;\n  out[9] = z1;\n  out[10] = z2;\n  out[11] = 0;\n  out[12] = eyex;\n  out[13] = eyey;\n  out[14] = eyez;\n  out[15] = 1;\n  return out;\n}\n\n/**\n * Returns a string representation of a mat4\n *\n * @param {ReadonlyMat4} a matrix to represent as a string\n * @returns {String} string representation of the matrix\n */\nexport function str(a) {\n  return \"mat4(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \", \" + a[3] + \", \" + a[4] + \", \" + a[5] + \", \" + a[6] + \", \" + a[7] + \", \" + a[8] + \", \" + a[9] + \", \" + a[10] + \", \" + a[11] + \", \" + a[12] + \", \" + a[13] + \", \" + a[14] + \", \" + a[15] + \")\";\n}\n\n/**\n * Returns Frobenius norm of a mat4\n *\n * @param {ReadonlyMat4} a the matrix to calculate Frobenius norm of\n * @returns {Number} Frobenius norm\n */\nexport function frob(a) {\n  return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2] + a[3] * a[3] + a[4] * a[4] + a[5] * a[5] + a[6] * a[6] + a[7] * a[7] + a[8] * a[8] + a[9] * a[9] + a[10] * a[10] + a[11] * a[11] + a[12] * a[12] + a[13] * a[13] + a[14] * a[14] + a[15] * a[15]);\n}\n\n/**\n * Adds two mat4's\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the first operand\n * @param {ReadonlyMat4} b the second operand\n * @returns {mat4} out\n */\nexport function add(out, a, b) {\n  out[0] = a[0] + b[0];\n  out[1] = a[1] + b[1];\n  out[2] = a[2] + b[2];\n  out[3] = a[3] + b[3];\n  out[4] = a[4] + b[4];\n  out[5] = a[5] + b[5];\n  out[6] = a[6] + b[6];\n  out[7] = a[7] + b[7];\n  out[8] = a[8] + b[8];\n  out[9] = a[9] + b[9];\n  out[10] = a[10] + b[10];\n  out[11] = a[11] + b[11];\n  out[12] = a[12] + b[12];\n  out[13] = a[13] + b[13];\n  out[14] = a[14] + b[14];\n  out[15] = a[15] + b[15];\n  return out;\n}\n\n/**\n * Subtracts matrix b from matrix a\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the first operand\n * @param {ReadonlyMat4} b the second operand\n * @returns {mat4} out\n */\nexport function subtract(out, a, b) {\n  out[0] = a[0] - b[0];\n  out[1] = a[1] - b[1];\n  out[2] = a[2] - b[2];\n  out[3] = a[3] - b[3];\n  out[4] = a[4] - b[4];\n  out[5] = a[5] - b[5];\n  out[6] = a[6] - b[6];\n  out[7] = a[7] - b[7];\n  out[8] = a[8] - b[8];\n  out[9] = a[9] - b[9];\n  out[10] = a[10] - b[10];\n  out[11] = a[11] - b[11];\n  out[12] = a[12] - b[12];\n  out[13] = a[13] - b[13];\n  out[14] = a[14] - b[14];\n  out[15] = a[15] - b[15];\n  return out;\n}\n\n/**\n * Multiply each element of the matrix by a scalar.\n *\n * @param {mat4} out the receiving matrix\n * @param {ReadonlyMat4} a the matrix to scale\n * @param {Number} b amount to scale the matrix's elements by\n * @returns {mat4} out\n */\nexport function multiplyScalar(out, a, b) {\n  out[0] = a[0] * b;\n  out[1] = a[1] * b;\n  out[2] = a[2] * b;\n  out[3] = a[3] * b;\n  out[4] = a[4] * b;\n  out[5] = a[5] * b;\n  out[6] = a[6] * b;\n  out[7] = a[7] * b;\n  out[8] = a[8] * b;\n  out[9] = a[9] * b;\n  out[10] = a[10] * b;\n  out[11] = a[11] * b;\n  out[12] = a[12] * b;\n  out[13] = a[13] * b;\n  out[14] = a[14] * b;\n  out[15] = a[15] * b;\n  return out;\n}\n\n/**\n * Adds two mat4's after multiplying each element of the second operand by a scalar value.\n *\n * @param {mat4} out the receiving vector\n * @param {ReadonlyMat4} a the first operand\n * @param {ReadonlyMat4} b the second operand\n * @param {Number} scale the amount to scale b's elements by before adding\n * @returns {mat4} out\n */\nexport function multiplyScalarAndAdd(out, a, b, scale) {\n  out[0] = a[0] + b[0] * scale;\n  out[1] = a[1] + b[1] * scale;\n  out[2] = a[2] + b[2] * scale;\n  out[3] = a[3] + b[3] * scale;\n  out[4] = a[4] + b[4] * scale;\n  out[5] = a[5] + b[5] * scale;\n  out[6] = a[6] + b[6] * scale;\n  out[7] = a[7] + b[7] * scale;\n  out[8] = a[8] + b[8] * scale;\n  out[9] = a[9] + b[9] * scale;\n  out[10] = a[10] + b[10] * scale;\n  out[11] = a[11] + b[11] * scale;\n  out[12] = a[12] + b[12] * scale;\n  out[13] = a[13] + b[13] * scale;\n  out[14] = a[14] + b[14] * scale;\n  out[15] = a[15] + b[15] * scale;\n  return out;\n}\n\n/**\n * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyMat4} a The first matrix.\n * @param {ReadonlyMat4} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\nexport function exactEquals(a, b) {\n  return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8] && a[9] === b[9] && a[10] === b[10] && a[11] === b[11] && a[12] === b[12] && a[13] === b[13] && a[14] === b[14] && a[15] === b[15];\n}\n\n/**\n * Returns whether or not the matrices have approximately the same elements in the same position.\n *\n * @param {ReadonlyMat4} a The first matrix.\n * @param {ReadonlyMat4} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\nexport function equals(a, b) {\n  var a0 = a[0],\n    a1 = a[1],\n    a2 = a[2],\n    a3 = a[3];\n  var a4 = a[4],\n    a5 = a[5],\n    a6 = a[6],\n    a7 = a[7];\n  var a8 = a[8],\n    a9 = a[9],\n    a10 = a[10],\n    a11 = a[11];\n  var a12 = a[12],\n    a13 = a[13],\n    a14 = a[14],\n    a15 = a[15];\n  var b0 = b[0],\n    b1 = b[1],\n    b2 = b[2],\n    b3 = b[3];\n  var b4 = b[4],\n    b5 = b[5],\n    b6 = b[6],\n    b7 = b[7];\n  var b8 = b[8],\n    b9 = b[9],\n    b10 = b[10],\n    b11 = b[11];\n  var b12 = b[12],\n    b13 = b[13],\n    b14 = b[14],\n    b15 = b[15];\n  return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8)) && Math.abs(a9 - b9) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a9), Math.abs(b9)) && Math.abs(a10 - b10) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a10), Math.abs(b10)) && Math.abs(a11 - b11) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a11), Math.abs(b11)) && Math.abs(a12 - b12) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a12), Math.abs(b12)) && Math.abs(a13 - b13) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a13), Math.abs(b13)) && Math.abs(a14 - b14) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a14), Math.abs(b14)) && Math.abs(a15 - b15) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a15), Math.abs(b15));\n}\n\n/**\n * Alias for {@link mat4.multiply}\n * @function\n */\nexport var mul = multiply;\n\n/**\n * Alias for {@link mat4.subtract}\n * @function\n */\nexport var sub = subtract;","import type { Accessor, Mesh, Node, Primitive, Scene } from '@gltf-transform/core';\nimport type { InstancedMesh } from '@gltf-transform/extensions';\n\n/**\n * Various methods of estimating a vertex count. For some background on why\n * multiple definitions of a vertex count should exist, see [_Vertex Count\n * Higher in Engine than in 3D Software_](https://shahriyarshahrabi.medium.com/vertex-count-higher-in-engine-than-in-3d-software-badc348ada66).\n * Totals for a {@link Scene}, {@link Node}, or {@link Mesh} will not\n * necessarily match the sum of the totals for each {@link Primitive}. Choose\n * the appropriate method for a relevant total or estimate:\n *\n * - {@link getSceneVertexCount}\n * - {@link getNodeVertexCount}\n * - {@link getMeshVertexCount}\n * - {@link getPrimitiveVertexCount}\n *\n * Many rendering features, such as volumetric transmission, may lead\n * to additional passes over some or all vertices. These tradeoffs are\n * implementation-dependent, and not considered here.\n */\nexport enum VertexCountMethod {\n\t/**\n\t * Expected number of vertices processed by the vertex shader for one render\n\t * pass, without considering the vertex cache.\n\t */\n\tRENDER = 'render',\n\n\t/**\n\t * Expected number of vertices processed by the vertex shader for one render\n\t * pass, assuming an Average Transform to Vertex Ratio (ATVR) of 1. Approaching\n\t * this result requires optimizing for locality of vertex references (see\n\t * {@link reorder}).\n\t *\n\t * References:\n\t * - [ACMR and ATVR](https://www.realtimerendering.com/blog/acmr-and-atvr/), Real-Time Rendering\n\t */\n\tRENDER_CACHED = 'render-cached',\n\n\t/**\n\t * Expected number of vertices uploaded to the GPU, assuming that a client\n\t * uploads each unique {@link Accessor} only once. Unless glTF vertex\n\t * attributes are pre-processed to a known buffer layout, and the client is\n\t * optimized for that buffer layout, this total will be optimistic.\n\t */\n\tUPLOAD = 'upload',\n\n\t/**\n\t * Expected number of vertices uploaded to the GPU, assuming that a client\n\t * uploads each unique {@link Primitive} individually, duplicating vertex\n\t * attribute {@link Accessor Accessors} shared by multiple primitives, but\n\t * never uploading the same Mesh or Primitive to GPU memory more than once.\n\t */\n\tUPLOAD_NAIVE = 'upload-naive',\n\n\t/**\n\t * Total number of unique vertices represented, considering all attributes of\n\t * each vertex, and removing any duplicates. Has no direct relationship to\n\t * runtime characteristics, but may be helpful in identifying asset\n\t * optimization opportunities.\n\t *\n\t * @hidden TODO(feat): Not yet implemented.\n\t * @internal\n\t */\n\tDISTINCT = 'distinct',\n\n\t/**\n\t * Total number of unique vertices represented, considering only vertex\n\t * positions, and removing any duplicates. Has no direct relationship to\n\t * runtime characteristics, but may be helpful in identifying asset\n\t * optimization opportunities.\n\t *\n\t * @hidden TODO(feat): Not yet implemented.\n\t * @internal\n\t */\n\tDISTINCT_POSITION = 'distinct-position',\n\n\t/**\n\t * Number of vertex positions never used by any {@link Primitive}. If all\n\t * vertices are unused, this total will match `UPLOAD`.\n\t */\n\tUNUSED = 'unused',\n}\n\n/**\n * Computes total number of vertices in a {@link Scene}, by the\n * specified method. Totals for the Scene will not necessarily match the sum\n * of the totals for each {@link Mesh} or {@link Primitive} within it. See\n * {@link VertexCountMethod} for available methods.\n */\nexport function getSceneVertexCount(scene: Scene, method: VertexCountMethod): number {\n\treturn _getSubtreeVertexCount(scene, method);\n}\n\n/**\n * Computes total number of vertices in a {@link Node}, by the\n * specified method. Totals for the node will not necessarily match the sum\n * of the totals for each {@link Mesh} or {@link Primitive} within it. See\n * {@link VertexCountMethod} for available methods.\n */\nexport function getNodeVertexCount(node: Node | Scene, method: VertexCountMethod): number {\n\treturn _getSubtreeVertexCount(node, method);\n}\n\nfunction _getSubtreeVertexCount(node: Node | Scene, method: VertexCountMethod): number {\n\tconst instancedMeshes: [number, Mesh][] = [];\n\tconst nonInstancedMeshes: Mesh[] = [];\n\tconst meshes: Mesh[] = [];\n\n\tnode.traverse((node) => {\n\t\tconst mesh = node.getMesh();\n\t\tconst batch = node.getExtension<InstancedMesh>('EXT_mesh_gpu_instancing');\n\t\tif (batch && mesh) {\n\t\t\tmeshes.push(mesh);\n\t\t\tinstancedMeshes.push([batch.listAttributes()[0]!.getCount(), mesh]);\n\t\t} else if (mesh) {\n\t\t\tmeshes.push(mesh);\n\t\t\tnonInstancedMeshes.push(mesh);\n\t\t}\n\t});\n\n\tconst prims = meshes.flatMap((mesh) => mesh.listPrimitives());\n\tconst positions = prims.map((prim) => prim.getAttribute('POSITION')!);\n\tconst uniquePositions = Array.from(new Set(positions));\n\tconst uniqueMeshes = Array.from(new Set(meshes));\n\tconst uniquePrims = Array.from(new Set(uniqueMeshes.flatMap((mesh) => mesh.listPrimitives())));\n\n\tswitch (method) {\n\t\tcase VertexCountMethod.RENDER:\n\t\tcase VertexCountMethod.RENDER_CACHED:\n\t\t\treturn (\n\t\t\t\t_sum(nonInstancedMeshes.map((mesh) => getMeshVertexCount(mesh, method))) +\n\t\t\t\t_sum(instancedMeshes.map(([batch, mesh]) => batch * getMeshVertexCount(mesh, method)))\n\t\t\t);\n\t\tcase VertexCountMethod.UPLOAD_NAIVE:\n\t\t\treturn _sum(uniqueMeshes.map((mesh) => getMeshVertexCount(mesh, method)));\n\t\tcase VertexCountMethod.UPLOAD:\n\t\t\treturn _sum(uniquePositions.map((attribute) => attribute.getCount()));\n\t\tcase VertexCountMethod.DISTINCT:\n\t\tcase VertexCountMethod.DISTINCT_POSITION:\n\t\t\treturn _assertNotImplemented(method);\n\t\tcase VertexCountMethod.UNUSED:\n\t\t\treturn _sumUnused(uniquePrims);\n\t\tdefault:\n\t\t\treturn _assertUnreachable(method);\n\t}\n}\n\n/**\n * Computes total number of vertices in a {@link Mesh}, by the\n * specified method. Totals for the Mesh will not necessarily match the sum\n * of the totals for each {@link Primitive} within it. See\n * {@link VertexCountMethod} for available methods.\n */\nexport function getMeshVertexCount(mesh: Mesh, method: VertexCountMethod): number {\n\tconst prims = mesh.listPrimitives();\n\tconst uniquePrims = Array.from(new Set(prims));\n\tconst uniquePositions = Array.from(new Set(uniquePrims.map((prim) => prim.getAttribute('POSITION')!)));\n\n\tswitch (method) {\n\t\tcase VertexCountMethod.RENDER:\n\t\tcase VertexCountMethod.RENDER_CACHED:\n\t\tcase VertexCountMethod.UPLOAD_NAIVE:\n\t\t\treturn _sum(prims.map((prim) => getPrimitiveVertexCount(prim, method)));\n\t\tcase VertexCountMethod.UPLOAD:\n\t\t\treturn _sum(uniquePositions.map((attribute) => attribute.getCount()));\n\t\tcase VertexCountMethod.DISTINCT:\n\t\tcase VertexCountMethod.DISTINCT_POSITION:\n\t\t\treturn _assertNotImplemented(method);\n\t\tcase VertexCountMethod.UNUSED:\n\t\t\treturn _sumUnused(uniquePrims);\n\t\tdefault:\n\t\t\treturn _assertUnreachable(method);\n\t}\n}\n\n/**\n * Computes total number of vertices in a {@link Primitive}, by the\n * specified method. See {@link VertexCountMethod} for available methods.\n */\nexport function getPrimitiveVertexCount(prim: Primitive, method: VertexCountMethod): number {\n\tconst position = prim.getAttribute('POSITION')!;\n\tconst indices = prim.getIndices();\n\n\tswitch (method) {\n\t\tcase VertexCountMethod.RENDER:\n\t\t\treturn indices ? indices.getCount() : position.getCount();\n\t\tcase VertexCountMethod.RENDER_CACHED:\n\t\t\treturn indices ? new Set(indices.getArray()).size : position.getCount();\n\t\tcase VertexCountMethod.UPLOAD_NAIVE:\n\t\tcase VertexCountMethod.UPLOAD:\n\t\t\treturn position.getCount();\n\t\tcase VertexCountMethod.DISTINCT:\n\t\tcase VertexCountMethod.DISTINCT_POSITION:\n\t\t\treturn _assertNotImplemented(method);\n\t\tcase VertexCountMethod.UNUSED:\n\t\t\treturn indices ? position.getCount() - new Set(indices.getArray()).size : 0;\n\t\tdefault:\n\t\t\treturn _assertUnreachable(method);\n\t}\n}\n\nfunction _sum(values: number[]): number {\n\tlet total = 0;\n\tfor (let i = 0; i < values.length; i++) {\n\t\ttotal += values[i];\n\t}\n\treturn total;\n}\n\nfunction _sumUnused(prims: Primitive[]) {\n\tconst attributeIndexMap = new Map<Accessor, Set<Accessor | null>>();\n\tfor (const prim of prims) {\n\t\tconst position = prim.getAttribute('POSITION')!;\n\t\tconst indices = prim.getIndices();\n\t\tconst indicesSet = attributeIndexMap.get(position) || new Set();\n\t\tindicesSet.add(indices);\n\t\tattributeIndexMap.set(position, indicesSet);\n\t}\n\n\tlet unused = 0;\n\tfor (const [position, indicesSet] of attributeIndexMap) {\n\t\tif (indicesSet.has(null)) continue;\n\n\t\tconst usedIndices = new Uint8Array(position.getCount());\n\t\tfor (const indices of indicesSet as Set<Accessor>) {\n\t\t\tconst indicesArray = indices.getArray()!;\n\t\t\tfor (let i = 0, il = indicesArray.length; i < il; i++) {\n\t\t\t\tusedIndices[indicesArray[i]] = 1;\n\t\t\t}\n\t\t}\n\n\t\tfor (let i = 0, il = position.getCount(); i < il; i++) {\n\t\t\tif (usedIndices[i] === 0) unused++;\n\t\t}\n\t}\n\n\treturn unused;\n}\n\nfunction _assertNotImplemented<T>(x: unknown): T {\n\tthrow new Error(`Not implemented: ${x}`);\n}\n\nfunction _assertUnreachable<T>(x: never): T {\n\tthrow new Error(`Unexpected value: ${x}`);\n}\n","import { type Accessor, BufferUtils, type Primitive } from '@gltf-transform/core';\nimport { deepListAttributes } from './utils.js';\n\n/** Flags 'empty' values in a Uint32Array index. */\nexport const EMPTY_U32: number = 2 ** 32 - 1;\n\nexport class VertexStream {\n\tprivate attributes: { u8: Uint8Array; byteStride: number; paddedByteStride: number }[] = [];\n\n\t/** Temporary vertex views in 4-byte-aligned memory. */\n\tprivate u8: Uint8Array;\n\tprivate u32: Uint32Array;\n\n\tconstructor(prim: Primitive) {\n\t\tlet byteStride = 0;\n\t\tfor (const attribute of deepListAttributes(prim)) {\n\t\t\tbyteStride += this._initAttribute(attribute);\n\t\t}\n\t\tthis.u8 = new Uint8Array(byteStride);\n\t\tthis.u32 = new Uint32Array(this.u8.buffer);\n\t}\n\n\tprivate _initAttribute(attribute: Accessor): number {\n\t\tconst array = attribute.getArray()!;\n\t\tconst u8 = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);\n\t\tconst byteStride = attribute.getElementSize() * attribute.getComponentSize();\n\t\tconst paddedByteStride = BufferUtils.padNumber(byteStride);\n\t\tthis.attributes.push({ u8, byteStride, paddedByteStride });\n\t\treturn paddedByteStride;\n\t}\n\n\thash(index: number): number {\n\t\t// Load vertex into 4-byte-aligned view.\n\t\tlet byteOffset = 0;\n\t\tfor (const { u8, byteStride, paddedByteStride } of this.attributes) {\n\t\t\tfor (let i = 0; i < paddedByteStride; i++) {\n\t\t\t\tif (i < byteStride) {\n\t\t\t\t\tthis.u8[byteOffset + i] = u8[index * byteStride + i];\n\t\t\t\t} else {\n\t\t\t\t\tthis.u8[byteOffset + i] = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbyteOffset += paddedByteStride;\n\t\t}\n\n\t\t// Compute hash.\n\t\treturn murmurHash2(0, this.u32);\n\t}\n\n\tequal(a: number, b: number): boolean {\n\t\tfor (const { u8, byteStride } of this.attributes) {\n\t\t\tfor (let j = 0; j < byteStride; j++) {\n\t\t\t\tif (u8[a * byteStride + j] !== u8[b * byteStride + j]) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n}\n\n/**\n * References:\n * - https://github.com/mikolalysenko/murmurhash-js/blob/f19136e9f9c17f8cddc216ca3d44ec7c5c502f60/murmurhash2_gc.js#L14\n * - https://github.com/zeux/meshoptimizer/blob/e47e1be6d3d9513153188216455bdbed40a206ef/src/indexgenerator.cpp#L12\n */\nfunction murmurHash2(h: number, key: Uint32Array): number {\n\t// MurmurHash2\n\tconst m = 0x5bd1e995;\n\tconst r = 24;\n\n\tfor (let i = 0, il = key.length; i < il; i++) {\n\t\tlet k = key[i];\n\n\t\tk = Math.imul(k, m) >>> 0;\n\t\tk = (k ^ (k >> r)) >>> 0;\n\t\tk = Math.imul(k, m) >>> 0;\n\n\t\th = Math.imul(h, m) >>> 0;\n\t\th = (h ^ k) >>> 0;\n\t}\n\n\treturn h;\n}\n\nexport function hashLookup(\n\ttable: Uint32Array,\n\tbuckets: number,\n\tstream: VertexStream,\n\tkey: number,\n\tempty: number = EMPTY_U32,\n): number {\n\tconst hashmod = buckets - 1;\n\tconst hashval = stream.hash(key);\n\tlet bucket = hashval & hashmod;\n\n\tfor (let probe = 0; probe <= hashmod; probe++) {\n\t\tconst item = table[bucket];\n\n\t\tif (item === empty || stream.equal(item, key)) {\n\t\t\treturn bucket;\n\t\t}\n\n\t\tbucket = (bucket + probe + 1) & hashmod; // Hash collision.\n\t}\n\n\tthrow new Error('Hash table full.');\n}\n","import {\n\ttype Accessor,\n\tDocument,\n\ttype Primitive,\n\ttype TypedArray,\n\ttype TypedArrayConstructor,\n} from '@gltf-transform/core';\nimport { getPrimitiveVertexCount, VertexCountMethod } from './get-vertex-count.js';\nimport { EMPTY_U32 } from './hash-table.js';\nimport { createIndices, createIndicesEmpty, deepListAttributes, shallowCloneAccessor } from './utils.js';\n\n/**\n * Rewrites a {@link Primitive} such that all unused vertices in its vertex\n * attributes are removed. When multiple Primitives share vertex attributes,\n * each indexing only a few, compaction can be used to produce Primitives\n * each having smaller, independent vertex streams instead.\n *\n * Regardless of whether the Primitive is indexed or contains unused vertices,\n * compaction will clone every {@link Accessor}. The resulting Primitive will\n * share no Accessors with other Primitives, allowing later changes to\n * the vertex stream to be applied in isolation.\n *\n * Example:\n *\n * ```javascript\n * import { compactPrimitive, transformMesh } from '@gltf-transform/functions';\n * import { fromTranslation } from 'gl-matrix/mat4';\n *\n * const mesh = document.getRoot().listMeshes().find((mesh) => mesh.getName() === 'MyMesh');\n * const prim = mesh.listPrimitives().find((prim) => { ... });\n *\n * // Compact primitive, removing unused vertices and detaching shared vertex\n * // attributes. Without compaction, `transformPrimitive` might affect other\n * // primitives sharing the same vertex attributes.\n * compactPrimitive(prim);\n *\n * // Transform primitive vertices, y += 10.\n * transformPrimitive(prim, fromTranslation([], [0, 10, 0]));\n * ```\n *\n * Parameters 'remap' and 'dstVertexCount' are optional. When either is\n * provided, the other must be provided as well. If one or both are missing,\n * both will be computed from the mesh indices.\n *\n * @param remap - Mapping. Array index represents vertex index in the source\n *\t\tattributes, array value represents index in the resulting compacted\n *\t\tprimitive. When omitted, calculated from indices.\n * @param dstVertexcount - Number of unique vertices in compacted primitive.\n *\t\tWhen omitted, calculated from indices.\n */\n// TODO(cleanup): Additional signatures currently break greendoc/parse.\n// export function compactPrimitive(prim: Primitive): Primitive;\n// export function compactPrimitive(prim: Primitive, remap: TypedArray, dstVertexCount: number): Primitive;\nexport function compactPrimitive(prim: Primitive, remap?: TypedArray, dstVertexCount?: number): Primitive {\n\tconst document = Document.fromGraph(prim.getGraph())!;\n\n\tif (!remap || !dstVertexCount) {\n\t\t[remap, dstVertexCount] = createCompactPlan(prim);\n\t}\n\n\t// Remap indices.\n\n\tconst srcIndices = prim.getIndices();\n\tconst srcIndicesArray = srcIndices ? srcIndices.getArray() : null;\n\tconst srcIndicesCount = getPrimitiveVertexCount(prim, VertexCountMethod.RENDER);\n\n\tconst dstIndices = document.createAccessor();\n\tconst dstIndicesCount = srcIndicesCount; // primitive count does not change.\n\tconst dstIndicesArray = createIndicesEmpty(dstIndicesCount, dstVertexCount);\n\n\tfor (let i = 0; i < dstIndicesCount; i++) {\n\t\tdstIndicesArray[i] = remap[srcIndicesArray ? srcIndicesArray[i] : i];\n\t}\n\n\tprim.setIndices(dstIndices.setArray(dstIndicesArray));\n\n\t// Remap vertices.\n\n\tconst srcAttributesPrev = deepListAttributes(prim);\n\n\tfor (const srcAttribute of prim.listAttributes()) {\n\t\tconst dstAttribute = shallowCloneAccessor(document, srcAttribute);\n\t\tcompactAttribute(srcAttribute, srcIndices, remap, dstAttribute, dstVertexCount);\n\t\tprim.swap(srcAttribute, dstAttribute);\n\t}\n\tfor (const target of prim.listTargets()) {\n\t\tfor (const srcAttribute of target.listAttributes()) {\n\t\t\tconst dstAttribute = shallowCloneAccessor(document, srcAttribute);\n\t\t\tcompactAttribute(srcAttribute, srcIndices, remap, dstAttribute, dstVertexCount);\n\t\t\ttarget.swap(srcAttribute, dstAttribute);\n\t\t}\n\t}\n\n\t// Clean up accessors.\n\n\tif (srcIndices && srcIndices.listParents().length === 1) {\n\t\tsrcIndices.dispose();\n\t}\n\tfor (const srcAttribute of srcAttributesPrev) {\n\t\tif (srcAttribute.listParents().length === 1) {\n\t\t\tsrcAttribute.dispose();\n\t\t}\n\t}\n\n\treturn prim;\n}\n\n/**\n * Copies srcAttribute to dstAttribute, using the given indices and remap (srcIndex -> dstIndex).\n * Any existing array in dstAttribute is replaced. Vertices not used by the index are eliminated,\n * leaving a compact attribute.\n * @hidden\n * @internal\n */\nexport function compactAttribute(\n\tsrcAttribute: Accessor,\n\tsrcIndices: Accessor | null,\n\tremap: TypedArray,\n\tdstAttribute: Accessor,\n\tdstVertexCount: number,\n): Accessor {\n\tconst elementSize = srcAttribute.getElementSize();\n\tconst srcArray = srcAttribute.getArray()!;\n\tconst srcIndicesArray = srcIndices ? srcIndices.getArray() : null;\n\tconst srcIndicesCount = srcIndices ? srcIndices.getCount() : srcAttribute.getCount();\n\tconst dstArray = new (srcArray.constructor as TypedArrayConstructor)(dstVertexCount * elementSize);\n\tconst dstDone = new Uint8Array(dstVertexCount);\n\n\tfor (let i = 0; i < srcIndicesCount; i++) {\n\t\tconst srcIndex = srcIndicesArray ? srcIndicesArray[i] : i;\n\t\tconst dstIndex = remap[srcIndex];\n\t\tif (dstDone[dstIndex]) continue;\n\n\t\tfor (let j = 0; j < elementSize; j++) {\n\t\t\tdstArray[dstIndex * elementSize + j] = srcArray[srcIndex * elementSize + j];\n\t\t}\n\n\t\tdstDone[dstIndex] = 1;\n\t}\n\n\treturn dstAttribute.setArray(dstArray);\n}\n\n/**\n * Creates a 'remap' and 'dstVertexCount' plan for indexed primitives,\n * such that they can be rewritten with {@link compactPrimitive} removing\n * any non-rendered vertices.\n * @hidden\n * @internal\n */\nfunction createCompactPlan(prim: Primitive): [Uint32Array<ArrayBuffer>, number] {\n\tconst srcVertexCount = getPrimitiveVertexCount(prim, VertexCountMethod.UPLOAD);\n\n\tconst indices = prim.getIndices();\n\tconst indicesArray = indices ? indices.getArray() : null;\n\tif (!indices || !indicesArray) {\n\t\treturn [createIndices(srcVertexCount, 1_000_000) as Uint32Array<ArrayBuffer>, srcVertexCount];\n\t}\n\n\tconst remap = new Uint32Array(srcVertexCount).fill(EMPTY_U32);\n\n\tlet dstVertexCount = 0;\n\n\tfor (let i = 0; i < indicesArray.length; i++) {\n\t\tconst srcIndex = indicesArray[i];\n\t\tif (remap[srcIndex] === EMPTY_U32) {\n\t\t\tremap[srcIndex] = dstVertexCount++;\n\t\t}\n\t}\n\n\treturn [remap, dstVertexCount];\n}\n","import * as glMatrix from \"./common.js\";\n\n/**\n * 3x3 Matrix\n * @module mat3\n */\n\n/**\n * Creates a new identity mat3\n *\n * @returns {mat3} a new 3x3 matrix\n */\nexport function create() {\n  var out = new glMatrix.ARRAY_TYPE(9);\n  if (glMatrix.ARRAY_TYPE != Float32Array) {\n    out[1] = 0;\n    out[2] = 0;\n    out[3] = 0;\n    out[5] = 0;\n    out[6] = 0;\n    out[7] = 0;\n  }\n  out[0] = 1;\n  out[4] = 1;\n  out[8] = 1;\n  return out;\n}\n\n/**\n * Copies the upper-left 3x3 values into the given mat3.\n *\n * @param {mat3} out the receiving 3x3 matrix\n * @param {ReadonlyMat4} a   the source 4x4 matrix\n * @returns {mat3} out\n */\nexport function fromMat4(out, a) {\n  out[0] = a[0];\n  out[1] = a[1];\n  out[2] = a[2];\n  out[3] = a[4];\n  out[4] = a[5];\n  out[5] = a[6];\n  out[6] = a[8];\n  out[7] = a[9];\n  out[8] = a[10];\n  return out;\n}\n\n/**\n * Creates a new mat3 initialized with values from an existing matrix\n *\n * @param {ReadonlyMat3} a matrix to clone\n * @returns {mat3} a new 3x3 matrix\n */\nexport function clone(a) {\n  var out = new glMatrix.ARRAY_TYPE(9);\n  out[0] = a[0];\n  out[1] = a[1];\n  out[2] = a[2];\n  out[3] = a[3];\n  out[4] = a[4];\n  out[5] = a[5];\n  out[6] = a[6];\n  out[7] = a[7];\n  out[8] = a[8];\n  return out;\n}\n\n/**\n * Copy the values from one mat3 to another\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the source matrix\n * @returns {mat3} out\n */\nexport function copy(out, a) {\n  out[0] = a[0];\n  out[1] = a[1];\n  out[2] = a[2];\n  out[3] = a[3];\n  out[4] = a[4];\n  out[5] = a[5];\n  out[6] = a[6];\n  out[7] = a[7];\n  out[8] = a[8];\n  return out;\n}\n\n/**\n * Create a new mat3 with the given values\n *\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\n * @param {Number} m10 Component in column 1, row 0 position (index 3)\n * @param {Number} m11 Component in column 1, row 1 position (index 4)\n * @param {Number} m12 Component in column 1, row 2 position (index 5)\n * @param {Number} m20 Component in column 2, row 0 position (index 6)\n * @param {Number} m21 Component in column 2, row 1 position (index 7)\n * @param {Number} m22 Component in column 2, row 2 position (index 8)\n * @returns {mat3} A new mat3\n */\nexport function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) {\n  var out = new glMatrix.ARRAY_TYPE(9);\n  out[0] = m00;\n  out[1] = m01;\n  out[2] = m02;\n  out[3] = m10;\n  out[4] = m11;\n  out[5] = m12;\n  out[6] = m20;\n  out[7] = m21;\n  out[8] = m22;\n  return out;\n}\n\n/**\n * Set the components of a mat3 to the given values\n *\n * @param {mat3} out the receiving matrix\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\n * @param {Number} m10 Component in column 1, row 0 position (index 3)\n * @param {Number} m11 Component in column 1, row 1 position (index 4)\n * @param {Number} m12 Component in column 1, row 2 position (index 5)\n * @param {Number} m20 Component in column 2, row 0 position (index 6)\n * @param {Number} m21 Component in column 2, row 1 position (index 7)\n * @param {Number} m22 Component in column 2, row 2 position (index 8)\n * @returns {mat3} out\n */\nexport function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) {\n  out[0] = m00;\n  out[1] = m01;\n  out[2] = m02;\n  out[3] = m10;\n  out[4] = m11;\n  out[5] = m12;\n  out[6] = m20;\n  out[7] = m21;\n  out[8] = m22;\n  return out;\n}\n\n/**\n * Set a mat3 to the identity matrix\n *\n * @param {mat3} out the receiving matrix\n * @returns {mat3} out\n */\nexport function identity(out) {\n  out[0] = 1;\n  out[1] = 0;\n  out[2] = 0;\n  out[3] = 0;\n  out[4] = 1;\n  out[5] = 0;\n  out[6] = 0;\n  out[7] = 0;\n  out[8] = 1;\n  return out;\n}\n\n/**\n * Transpose the values of a mat3\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the source matrix\n * @returns {mat3} out\n */\nexport function transpose(out, a) {\n  // If we are transposing ourselves we can skip a few steps but have to cache some values\n  if (out === a) {\n    var a01 = a[1],\n      a02 = a[2],\n      a12 = a[5];\n    out[1] = a[3];\n    out[2] = a[6];\n    out[3] = a01;\n    out[5] = a[7];\n    out[6] = a02;\n    out[7] = a12;\n  } else {\n    out[0] = a[0];\n    out[1] = a[3];\n    out[2] = a[6];\n    out[3] = a[1];\n    out[4] = a[4];\n    out[5] = a[7];\n    out[6] = a[2];\n    out[7] = a[5];\n    out[8] = a[8];\n  }\n  return out;\n}\n\n/**\n * Inverts a mat3\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the source matrix\n * @returns {mat3 | null} out, or null if source matrix is not invertible\n */\nexport function invert(out, a) {\n  var a00 = a[0],\n    a01 = a[1],\n    a02 = a[2];\n  var a10 = a[3],\n    a11 = a[4],\n    a12 = a[5];\n  var a20 = a[6],\n    a21 = a[7],\n    a22 = a[8];\n  var b01 = a22 * a11 - a12 * a21;\n  var b11 = -a22 * a10 + a12 * a20;\n  var b21 = a21 * a10 - a11 * a20;\n\n  // Calculate the determinant\n  var det = a00 * b01 + a01 * b11 + a02 * b21;\n  if (!det) {\n    return null;\n  }\n  det = 1.0 / det;\n  out[0] = b01 * det;\n  out[1] = (-a22 * a01 + a02 * a21) * det;\n  out[2] = (a12 * a01 - a02 * a11) * det;\n  out[3] = b11 * det;\n  out[4] = (a22 * a00 - a02 * a20) * det;\n  out[5] = (-a12 * a00 + a02 * a10) * det;\n  out[6] = b21 * det;\n  out[7] = (-a21 * a00 + a01 * a20) * det;\n  out[8] = (a11 * a00 - a01 * a10) * det;\n  return out;\n}\n\n/**\n * Calculates the adjugate of a mat3\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the source matrix\n * @returns {mat3} out\n */\nexport function adjoint(out, a) {\n  var a00 = a[0],\n    a01 = a[1],\n    a02 = a[2];\n  var a10 = a[3],\n    a11 = a[4],\n    a12 = a[5];\n  var a20 = a[6],\n    a21 = a[7],\n    a22 = a[8];\n  out[0] = a11 * a22 - a12 * a21;\n  out[1] = a02 * a21 - a01 * a22;\n  out[2] = a01 * a12 - a02 * a11;\n  out[3] = a12 * a20 - a10 * a22;\n  out[4] = a00 * a22 - a02 * a20;\n  out[5] = a02 * a10 - a00 * a12;\n  out[6] = a10 * a21 - a11 * a20;\n  out[7] = a01 * a20 - a00 * a21;\n  out[8] = a00 * a11 - a01 * a10;\n  return out;\n}\n\n/**\n * Calculates the determinant of a mat3\n *\n * @param {ReadonlyMat3} a the source matrix\n * @returns {Number} determinant of a\n */\nexport function determinant(a) {\n  var a00 = a[0],\n    a01 = a[1],\n    a02 = a[2];\n  var a10 = a[3],\n    a11 = a[4],\n    a12 = a[5];\n  var a20 = a[6],\n    a21 = a[7],\n    a22 = a[8];\n  return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);\n}\n\n/**\n * Multiplies two mat3's\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the first operand\n * @param {ReadonlyMat3} b the second operand\n * @returns {mat3} out\n */\nexport function multiply(out, a, b) {\n  var a00 = a[0],\n    a01 = a[1],\n    a02 = a[2];\n  var a10 = a[3],\n    a11 = a[4],\n    a12 = a[5];\n  var a20 = a[6],\n    a21 = a[7],\n    a22 = a[8];\n  var b00 = b[0],\n    b01 = b[1],\n    b02 = b[2];\n  var b10 = b[3],\n    b11 = b[4],\n    b12 = b[5];\n  var b20 = b[6],\n    b21 = b[7],\n    b22 = b[8];\n  out[0] = b00 * a00 + b01 * a10 + b02 * a20;\n  out[1] = b00 * a01 + b01 * a11 + b02 * a21;\n  out[2] = b00 * a02 + b01 * a12 + b02 * a22;\n  out[3] = b10 * a00 + b11 * a10 + b12 * a20;\n  out[4] = b10 * a01 + b11 * a11 + b12 * a21;\n  out[5] = b10 * a02 + b11 * a12 + b12 * a22;\n  out[6] = b20 * a00 + b21 * a10 + b22 * a20;\n  out[7] = b20 * a01 + b21 * a11 + b22 * a21;\n  out[8] = b20 * a02 + b21 * a12 + b22 * a22;\n  return out;\n}\n\n/**\n * Translate a mat3 by the given vector\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the matrix to translate\n * @param {ReadonlyVec2} v vector to translate by\n * @returns {mat3} out\n */\nexport function translate(out, a, v) {\n  var a00 = a[0],\n    a01 = a[1],\n    a02 = a[2],\n    a10 = a[3],\n    a11 = a[4],\n    a12 = a[5],\n    a20 = a[6],\n    a21 = a[7],\n    a22 = a[8],\n    x = v[0],\n    y = v[1];\n  out[0] = a00;\n  out[1] = a01;\n  out[2] = a02;\n  out[3] = a10;\n  out[4] = a11;\n  out[5] = a12;\n  out[6] = x * a00 + y * a10 + a20;\n  out[7] = x * a01 + y * a11 + a21;\n  out[8] = x * a02 + y * a12 + a22;\n  return out;\n}\n\n/**\n * Rotates a mat3 by the given angle\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the matrix to rotate\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat3} out\n */\nexport function rotate(out, a, rad) {\n  var a00 = a[0],\n    a01 = a[1],\n    a02 = a[2],\n    a10 = a[3],\n    a11 = a[4],\n    a12 = a[5],\n    a20 = a[6],\n    a21 = a[7],\n    a22 = a[8],\n    s = Math.sin(rad),\n    c = Math.cos(rad);\n  out[0] = c * a00 + s * a10;\n  out[1] = c * a01 + s * a11;\n  out[2] = c * a02 + s * a12;\n  out[3] = c * a10 - s * a00;\n  out[4] = c * a11 - s * a01;\n  out[5] = c * a12 - s * a02;\n  out[6] = a20;\n  out[7] = a21;\n  out[8] = a22;\n  return out;\n}\n\n/**\n * Scales the mat3 by the dimensions in the given vec2\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the matrix to scale\n * @param {ReadonlyVec2} v the vec2 to scale the matrix by\n * @returns {mat3} out\n **/\nexport function scale(out, a, v) {\n  var x = v[0],\n    y = v[1];\n  out[0] = x * a[0];\n  out[1] = x * a[1];\n  out[2] = x * a[2];\n  out[3] = y * a[3];\n  out[4] = y * a[4];\n  out[5] = y * a[5];\n  out[6] = a[6];\n  out[7] = a[7];\n  out[8] = a[8];\n  return out;\n}\n\n/**\n * Creates a matrix from a vector translation\n * This is equivalent to (but much faster than):\n *\n *     mat3.identity(dest);\n *     mat3.translate(dest, dest, vec);\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {ReadonlyVec2} v Translation vector\n * @returns {mat3} out\n */\nexport function fromTranslation(out, v) {\n  out[0] = 1;\n  out[1] = 0;\n  out[2] = 0;\n  out[3] = 0;\n  out[4] = 1;\n  out[5] = 0;\n  out[6] = v[0];\n  out[7] = v[1];\n  out[8] = 1;\n  return out;\n}\n\n/**\n * Creates a matrix from a given angle\n * This is equivalent to (but much faster than):\n *\n *     mat3.identity(dest);\n *     mat3.rotate(dest, dest, rad);\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {Number} rad the angle to rotate the matrix by\n * @returns {mat3} out\n */\nexport function fromRotation(out, rad) {\n  var s = Math.sin(rad),\n    c = Math.cos(rad);\n  out[0] = c;\n  out[1] = s;\n  out[2] = 0;\n  out[3] = -s;\n  out[4] = c;\n  out[5] = 0;\n  out[6] = 0;\n  out[7] = 0;\n  out[8] = 1;\n  return out;\n}\n\n/**\n * Creates a matrix from a vector scaling\n * This is equivalent to (but much faster than):\n *\n *     mat3.identity(dest);\n *     mat3.scale(dest, dest, vec);\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {ReadonlyVec2} v Scaling vector\n * @returns {mat3} out\n */\nexport function fromScaling(out, v) {\n  out[0] = v[0];\n  out[1] = 0;\n  out[2] = 0;\n  out[3] = 0;\n  out[4] = v[1];\n  out[5] = 0;\n  out[6] = 0;\n  out[7] = 0;\n  out[8] = 1;\n  return out;\n}\n\n/**\n * Copies the values from a mat2d into a mat3\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat2d} a the matrix to copy\n * @returns {mat3} out\n **/\nexport function fromMat2d(out, a) {\n  out[0] = a[0];\n  out[1] = a[1];\n  out[2] = 0;\n  out[3] = a[2];\n  out[4] = a[3];\n  out[5] = 0;\n  out[6] = a[4];\n  out[7] = a[5];\n  out[8] = 1;\n  return out;\n}\n\n/**\n * Calculates a 3x3 matrix from the given quaternion\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {ReadonlyQuat} q Quaternion to create matrix from\n *\n * @returns {mat3} out\n */\nexport function fromQuat(out, q) {\n  var x = q[0],\n    y = q[1],\n    z = q[2],\n    w = q[3];\n  var x2 = x + x;\n  var y2 = y + y;\n  var z2 = z + z;\n  var xx = x * x2;\n  var yx = y * x2;\n  var yy = y * y2;\n  var zx = z * x2;\n  var zy = z * y2;\n  var zz = z * z2;\n  var wx = w * x2;\n  var wy = w * y2;\n  var wz = w * z2;\n  out[0] = 1 - yy - zz;\n  out[3] = yx - wz;\n  out[6] = zx + wy;\n  out[1] = yx + wz;\n  out[4] = 1 - xx - zz;\n  out[7] = zy - wx;\n  out[2] = zx - wy;\n  out[5] = zy + wx;\n  out[8] = 1 - xx - yy;\n  return out;\n}\n\n/**\n * Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix\n *\n * @param {mat3} out mat3 receiving operation result\n * @param {ReadonlyMat4} a Mat4 to derive the normal matrix from\n *\n * @returns {mat3} out\n */\nexport function normalFromMat4(out, a) {\n  var a00 = a[0],\n    a01 = a[1],\n    a02 = a[2],\n    a03 = a[3];\n  var a10 = a[4],\n    a11 = a[5],\n    a12 = a[6],\n    a13 = a[7];\n  var a20 = a[8],\n    a21 = a[9],\n    a22 = a[10],\n    a23 = a[11];\n  var a30 = a[12],\n    a31 = a[13],\n    a32 = a[14],\n    a33 = a[15];\n  var b00 = a00 * a11 - a01 * a10;\n  var b01 = a00 * a12 - a02 * a10;\n  var b02 = a00 * a13 - a03 * a10;\n  var b03 = a01 * a12 - a02 * a11;\n  var b04 = a01 * a13 - a03 * a11;\n  var b05 = a02 * a13 - a03 * a12;\n  var b06 = a20 * a31 - a21 * a30;\n  var b07 = a20 * a32 - a22 * a30;\n  var b08 = a20 * a33 - a23 * a30;\n  var b09 = a21 * a32 - a22 * a31;\n  var b10 = a21 * a33 - a23 * a31;\n  var b11 = a22 * a33 - a23 * a32;\n\n  // Calculate the determinant\n  var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n  if (!det) {\n    return null;\n  }\n  det = 1.0 / det;\n  out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;\n  out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;\n  out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;\n  out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;\n  out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;\n  out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;\n  out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;\n  out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;\n  out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;\n  return out;\n}\n\n/**\n * Generates a 2D projection matrix with the given bounds\n *\n * @param {mat3} out mat3 frustum matrix will be written into\n * @param {number} width Width of your gl context\n * @param {number} height Height of gl context\n * @returns {mat3} out\n */\nexport function projection(out, width, height) {\n  out[0] = 2 / width;\n  out[1] = 0;\n  out[2] = 0;\n  out[3] = 0;\n  out[4] = -2 / height;\n  out[5] = 0;\n  out[6] = -1;\n  out[7] = 1;\n  out[8] = 1;\n  return out;\n}\n\n/**\n * Returns a string representation of a mat3\n *\n * @param {ReadonlyMat3} a matrix to represent as a string\n * @returns {String} string representation of the matrix\n */\nexport function str(a) {\n  return \"mat3(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \", \" + a[3] + \", \" + a[4] + \", \" + a[5] + \", \" + a[6] + \", \" + a[7] + \", \" + a[8] + \")\";\n}\n\n/**\n * Returns Frobenius norm of a mat3\n *\n * @param {ReadonlyMat3} a the matrix to calculate Frobenius norm of\n * @returns {Number} Frobenius norm\n */\nexport function frob(a) {\n  return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2] + a[3] * a[3] + a[4] * a[4] + a[5] * a[5] + a[6] * a[6] + a[7] * a[7] + a[8] * a[8]);\n}\n\n/**\n * Adds two mat3's\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the first operand\n * @param {ReadonlyMat3} b the second operand\n * @returns {mat3} out\n */\nexport function add(out, a, b) {\n  out[0] = a[0] + b[0];\n  out[1] = a[1] + b[1];\n  out[2] = a[2] + b[2];\n  out[3] = a[3] + b[3];\n  out[4] = a[4] + b[4];\n  out[5] = a[5] + b[5];\n  out[6] = a[6] + b[6];\n  out[7] = a[7] + b[7];\n  out[8] = a[8] + b[8];\n  return out;\n}\n\n/**\n * Subtracts matrix b from matrix a\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the first operand\n * @param {ReadonlyMat3} b the second operand\n * @returns {mat3} out\n */\nexport function subtract(out, a, b) {\n  out[0] = a[0] - b[0];\n  out[1] = a[1] - b[1];\n  out[2] = a[2] - b[2];\n  out[3] = a[3] - b[3];\n  out[4] = a[4] - b[4];\n  out[5] = a[5] - b[5];\n  out[6] = a[6] - b[6];\n  out[7] = a[7] - b[7];\n  out[8] = a[8] - b[8];\n  return out;\n}\n\n/**\n * Multiply each element of the matrix by a scalar.\n *\n * @param {mat3} out the receiving matrix\n * @param {ReadonlyMat3} a the matrix to scale\n * @param {Number} b amount to scale the matrix's elements by\n * @returns {mat3} out\n */\nexport function multiplyScalar(out, a, b) {\n  out[0] = a[0] * b;\n  out[1] = a[1] * b;\n  out[2] = a[2] * b;\n  out[3] = a[3] * b;\n  out[4] = a[4] * b;\n  out[5] = a[5] * b;\n  out[6] = a[6] * b;\n  out[7] = a[7] * b;\n  out[8] = a[8] * b;\n  return out;\n}\n\n/**\n * Adds two mat3's after multiplying each element of the second operand by a scalar value.\n *\n * @param {mat3} out the receiving vector\n * @param {ReadonlyMat3} a the first operand\n * @param {ReadonlyMat3} b the second operand\n * @param {Number} scale the amount to scale b's elements by before adding\n * @returns {mat3} out\n */\nexport function multiplyScalarAndAdd(out, a, b, scale) {\n  out[0] = a[0] + b[0] * scale;\n  out[1] = a[1] + b[1] * scale;\n  out[2] = a[2] + b[2] * scale;\n  out[3] = a[3] + b[3] * scale;\n  out[4] = a[4] + b[4] * scale;\n  out[5] = a[5] + b[5] * scale;\n  out[6] = a[6] + b[6] * scale;\n  out[7] = a[7] + b[7] * scale;\n  out[8] = a[8] + b[8] * scale;\n  return out;\n}\n\n/**\n * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyMat3} a The first matrix.\n * @param {ReadonlyMat3} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\nexport function exactEquals(a, b) {\n  return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8];\n}\n\n/**\n * Returns whether or not the matrices have approximately the same elements in the same position.\n *\n * @param {ReadonlyMat3} a The first matrix.\n * @param {ReadonlyMat3} b The second matrix.\n * @returns {Boolean} True if the matrices are equal, false otherwise.\n */\nexport function equals(a, b) {\n  var a0 = a[0],\n    a1 = a[1],\n    a2 = a[2],\n    a3 = a[3],\n    a4 = a[4],\n    a5 = a[5],\n    a6 = a[6],\n    a7 = a[7],\n    a8 = a[8];\n  var b0 = b[0],\n    b1 = b[1],\n    b2 = b[2],\n    b3 = b[3],\n    b4 = b[4],\n    b5 = b[5],\n    b6 = b[6],\n    b7 = b[7],\n    b8 = b[8];\n  return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8));\n}\n\n/**\n * Alias for {@link mat3.multiply}\n * @function\n */\nexport var mul = multiply;\n\n/**\n * Alias for {@link mat3.subtract}\n * @function\n */\nexport var sub = subtract;","import * as glMatrix from \"./common.js\";\n\n/**\n * 3 Dimensional Vector\n * @module vec3\n */\n\n/**\n * Creates a new, empty vec3\n *\n * @returns {vec3} a new 3D vector\n */\nexport function create() {\n  var out = new glMatrix.ARRAY_TYPE(3);\n  if (glMatrix.ARRAY_TYPE != Float32Array) {\n    out[0] = 0;\n    out[1] = 0;\n    out[2] = 0;\n  }\n  return out;\n}\n\n/**\n * Creates a new vec3 initialized with values from an existing vector\n *\n * @param {ReadonlyVec3} a vector to clone\n * @returns {vec3} a new 3D vector\n */\nexport function clone(a) {\n  var out = new glMatrix.ARRAY_TYPE(3);\n  out[0] = a[0];\n  out[1] = a[1];\n  out[2] = a[2];\n  return out;\n}\n\n/**\n * Calculates the length of a vec3\n *\n * @param {ReadonlyVec3} a vector to calculate length of\n * @returns {Number} length of a\n */\nexport function length(a) {\n  var x = a[0];\n  var y = a[1];\n  var z = a[2];\n  return Math.sqrt(x * x + y * y + z * z);\n}\n\n/**\n * Creates a new vec3 initialized with the given values\n *\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @returns {vec3} a new 3D vector\n */\nexport function fromValues(x, y, z) {\n  var out = new glMatrix.ARRAY_TYPE(3);\n  out[0] = x;\n  out[1] = y;\n  out[2] = z;\n  return out;\n}\n\n/**\n * Copy the values from one vec3 to another\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the source vector\n * @returns {vec3} out\n */\nexport function copy(out, a) {\n  out[0] = a[0];\n  out[1] = a[1];\n  out[2] = a[2];\n  return out;\n}\n\n/**\n * Set the components of a vec3 to the given values\n *\n * @param {vec3} out the receiving vector\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @returns {vec3} out\n */\nexport function set(out, x, y, z) {\n  out[0] = x;\n  out[1] = y;\n  out[2] = z;\n  return out;\n}\n\n/**\n * Adds two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\nexport function add(out, a, b) {\n  out[0] = a[0] + b[0];\n  out[1] = a[1] + b[1];\n  out[2] = a[2] + b[2];\n  return out;\n}\n\n/**\n * Subtracts vector b from vector a\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\nexport function subtract(out, a, b) {\n  out[0] = a[0] - b[0];\n  out[1] = a[1] - b[1];\n  out[2] = a[2] - b[2];\n  return out;\n}\n\n/**\n * Multiplies two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\nexport function multiply(out, a, b) {\n  out[0] = a[0] * b[0];\n  out[1] = a[1] * b[1];\n  out[2] = a[2] * b[2];\n  return out;\n}\n\n/**\n * Divides two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\nexport function divide(out, a, b) {\n  out[0] = a[0] / b[0];\n  out[1] = a[1] / b[1];\n  out[2] = a[2] / b[2];\n  return out;\n}\n\n/**\n * Math.ceil the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to ceil\n * @returns {vec3} out\n */\nexport function ceil(out, a) {\n  out[0] = Math.ceil(a[0]);\n  out[1] = Math.ceil(a[1]);\n  out[2] = Math.ceil(a[2]);\n  return out;\n}\n\n/**\n * Math.floor the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to floor\n * @returns {vec3} out\n */\nexport function floor(out, a) {\n  out[0] = Math.floor(a[0]);\n  out[1] = Math.floor(a[1]);\n  out[2] = Math.floor(a[2]);\n  return out;\n}\n\n/**\n * Returns the minimum of two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\nexport function min(out, a, b) {\n  out[0] = Math.min(a[0], b[0]);\n  out[1] = Math.min(a[1], b[1]);\n  out[2] = Math.min(a[2], b[2]);\n  return out;\n}\n\n/**\n * Returns the maximum of two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\nexport function max(out, a, b) {\n  out[0] = Math.max(a[0], b[0]);\n  out[1] = Math.max(a[1], b[1]);\n  out[2] = Math.max(a[2], b[2]);\n  return out;\n}\n\n/**\n * symmetric round the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to round\n * @returns {vec3} out\n */\nexport function round(out, a) {\n  out[0] = glMatrix.round(a[0]);\n  out[1] = glMatrix.round(a[1]);\n  out[2] = glMatrix.round(a[2]);\n  return out;\n}\n\n/**\n * Scales a vec3 by a scalar number\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the vector to scale\n * @param {Number} b amount to scale the vector by\n * @returns {vec3} out\n */\nexport function scale(out, a, b) {\n  out[0] = a[0] * b;\n  out[1] = a[1] * b;\n  out[2] = a[2] * b;\n  return out;\n}\n\n/**\n * Adds two vec3's after scaling the second operand by a scalar value\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @param {Number} scale the amount to scale b by before adding\n * @returns {vec3} out\n */\nexport function scaleAndAdd(out, a, b, scale) {\n  out[0] = a[0] + b[0] * scale;\n  out[1] = a[1] + b[1] * scale;\n  out[2] = a[2] + b[2] * scale;\n  return out;\n}\n\n/**\n * Calculates the euclidian distance between two vec3's\n *\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {Number} distance between a and b\n */\nexport function distance(a, b) {\n  var x = b[0] - a[0];\n  var y = b[1] - a[1];\n  var z = b[2] - a[2];\n  return Math.sqrt(x * x + y * y + z * z);\n}\n\n/**\n * Calculates the squared euclidian distance between two vec3's\n *\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {Number} squared distance between a and b\n */\nexport function squaredDistance(a, b) {\n  var x = b[0] - a[0];\n  var y = b[1] - a[1];\n  var z = b[2] - a[2];\n  return x * x + y * y + z * z;\n}\n\n/**\n * Calculates the squared length of a vec3\n *\n * @param {ReadonlyVec3} a vector to calculate squared length of\n * @returns {Number} squared length of a\n */\nexport function squaredLength(a) {\n  var x = a[0];\n  var y = a[1];\n  var z = a[2];\n  return x * x + y * y + z * z;\n}\n\n/**\n * Negates the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to negate\n * @returns {vec3} out\n */\nexport function negate(out, a) {\n  out[0] = -a[0];\n  out[1] = -a[1];\n  out[2] = -a[2];\n  return out;\n}\n\n/**\n * Returns the inverse of the components of a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to invert\n * @returns {vec3} out\n */\nexport function inverse(out, a) {\n  out[0] = 1.0 / a[0];\n  out[1] = 1.0 / a[1];\n  out[2] = 1.0 / a[2];\n  return out;\n}\n\n/**\n * Normalize a vec3\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a vector to normalize\n * @returns {vec3} out\n */\nexport function normalize(out, a) {\n  var x = a[0];\n  var y = a[1];\n  var z = a[2];\n  var len = x * x + y * y + z * z;\n  if (len > 0) {\n    //TODO: evaluate use of glm_invsqrt here?\n    len = 1 / Math.sqrt(len);\n  }\n  out[0] = a[0] * len;\n  out[1] = a[1] * len;\n  out[2] = a[2] * len;\n  return out;\n}\n\n/**\n * Calculates the dot product of two vec3's\n *\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {Number} dot product of a and b\n */\nexport function dot(a, b) {\n  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n}\n\n/**\n * Computes the cross product of two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @returns {vec3} out\n */\nexport function cross(out, a, b) {\n  var ax = a[0],\n    ay = a[1],\n    az = a[2];\n  var bx = b[0],\n    by = b[1],\n    bz = b[2];\n  out[0] = ay * bz - az * by;\n  out[1] = az * bx - ax * bz;\n  out[2] = ax * by - ay * bx;\n  return out;\n}\n\n/**\n * Performs a linear interpolation between two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec3} out\n */\nexport function lerp(out, a, b, t) {\n  var ax = a[0];\n  var ay = a[1];\n  var az = a[2];\n  out[0] = ax + t * (b[0] - ax);\n  out[1] = ay + t * (b[1] - ay);\n  out[2] = az + t * (b[2] - az);\n  return out;\n}\n\n/**\n * Performs a spherical linear interpolation between two vec3's\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec3} out\n */\nexport function slerp(out, a, b, t) {\n  var angle = Math.acos(Math.min(Math.max(dot(a, b), -1), 1));\n  var sinTotal = Math.sin(angle);\n  var ratioA = Math.sin((1 - t) * angle) / sinTotal;\n  var ratioB = Math.sin(t * angle) / sinTotal;\n  out[0] = ratioA * a[0] + ratioB * b[0];\n  out[1] = ratioA * a[1] + ratioB * b[1];\n  out[2] = ratioA * a[2] + ratioB * b[2];\n  return out;\n}\n\n/**\n * Performs a hermite interpolation with two control points\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @param {ReadonlyVec3} c the third operand\n * @param {ReadonlyVec3} d the fourth operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec3} out\n */\nexport function hermite(out, a, b, c, d, t) {\n  var factorTimes2 = t * t;\n  var factor1 = factorTimes2 * (2 * t - 3) + 1;\n  var factor2 = factorTimes2 * (t - 2) + t;\n  var factor3 = factorTimes2 * (t - 1);\n  var factor4 = factorTimes2 * (3 - 2 * t);\n  out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;\n  out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;\n  out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;\n  return out;\n}\n\n/**\n * Performs a bezier interpolation with two control points\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the first operand\n * @param {ReadonlyVec3} b the second operand\n * @param {ReadonlyVec3} c the third operand\n * @param {ReadonlyVec3} d the fourth operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec3} out\n */\nexport function bezier(out, a, b, c, d, t) {\n  var inverseFactor = 1 - t;\n  var inverseFactorTimesTwo = inverseFactor * inverseFactor;\n  var factorTimes2 = t * t;\n  var factor1 = inverseFactorTimesTwo * inverseFactor;\n  var factor2 = 3 * t * inverseFactorTimesTwo;\n  var factor3 = 3 * factorTimes2 * inverseFactor;\n  var factor4 = factorTimes2 * t;\n  out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;\n  out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;\n  out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;\n  return out;\n}\n\n/**\n * Generates a random vector with the given scale\n *\n * @param {vec3} out the receiving vector\n * @param {Number} [scale] Length of the resulting vector. If omitted, a unit vector will be returned\n * @returns {vec3} out\n */\nexport function random(out, scale) {\n  scale = scale === undefined ? 1.0 : scale;\n  var r = glMatrix.RANDOM() * 2.0 * Math.PI;\n  var z = glMatrix.RANDOM() * 2.0 - 1.0;\n  var zScale = Math.sqrt(1.0 - z * z) * scale;\n  out[0] = Math.cos(r) * zScale;\n  out[1] = Math.sin(r) * zScale;\n  out[2] = z * scale;\n  return out;\n}\n\n/**\n * Transforms the vec3 with a mat4.\n * 4th vector component is implicitly '1'\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the vector to transform\n * @param {ReadonlyMat4} m matrix to transform with\n * @returns {vec3} out\n */\nexport function transformMat4(out, a, m) {\n  var x = a[0],\n    y = a[1],\n    z = a[2];\n  var w = m[3] * x + m[7] * y + m[11] * z + m[15];\n  w = w || 1.0;\n  out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;\n  out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;\n  out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;\n  return out;\n}\n\n/**\n * Transforms the vec3 with a mat3.\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the vector to transform\n * @param {ReadonlyMat3} m the 3x3 matrix to transform with\n * @returns {vec3} out\n */\nexport function transformMat3(out, a, m) {\n  var x = a[0],\n    y = a[1],\n    z = a[2];\n  out[0] = x * m[0] + y * m[3] + z * m[6];\n  out[1] = x * m[1] + y * m[4] + z * m[7];\n  out[2] = x * m[2] + y * m[5] + z * m[8];\n  return out;\n}\n\n/**\n * Transforms the vec3 with a quat\n * Can also be used for dual quaternions. (Multiply it with the real part)\n *\n * @param {vec3} out the receiving vector\n * @param {ReadonlyVec3} a the vector to transform\n * @param {ReadonlyQuat} q normalized quaternion to transform with\n * @returns {vec3} out\n */\nexport function transformQuat(out, a, q) {\n  // Fast Vector Rotation using Quaternions by Robert Eisele\n  // https://raw.org/proof/vector-rotation-using-quaternions/\n\n  var qx = q[0],\n    qy = q[1],\n    qz = q[2],\n    qw = q[3];\n  var vx = a[0],\n    vy = a[1],\n    vz = a[2];\n\n  // t = q x v\n  var tx = qy * vz - qz * vy;\n  var ty = qz * vx - qx * vz;\n  var tz = qx * vy - qy * vx;\n\n  // t = 2t\n  tx = tx + tx;\n  ty = ty + ty;\n  tz = tz + tz;\n\n  // v + w t + q x t\n  out[0] = vx + qw * tx + qy * tz - qz * ty;\n  out[1] = vy + qw * ty + qz * tx - qx * tz;\n  out[2] = vz + qw * tz + qx * ty - qy * tx;\n  return out;\n}\n\n/**\n * Rotate a 3D vector around the x-axis\n * @param {vec3} out The receiving vec3\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @returns {vec3} out\n */\nexport function rotateX(out, a, b, rad) {\n  var p = [],\n    r = [];\n  //Translate point to the origin\n  p[0] = a[0] - b[0];\n  p[1] = a[1] - b[1];\n  p[2] = a[2] - b[2];\n\n  //perform rotation\n  r[0] = p[0];\n  r[1] = p[1] * Math.cos(rad) - p[2] * Math.sin(rad);\n  r[2] = p[1] * Math.sin(rad) + p[2] * Math.cos(rad);\n\n  //translate to correct position\n  out[0] = r[0] + b[0];\n  out[1] = r[1] + b[1];\n  out[2] = r[2] + b[2];\n  return out;\n}\n\n/**\n * Rotate a 3D vector around the y-axis\n * @param {vec3} out The receiving vec3\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @returns {vec3} out\n */\nexport function rotateY(out, a, b, rad) {\n  var p = [],\n    r = [];\n  //Translate point to the origin\n  p[0] = a[0] - b[0];\n  p[1] = a[1] - b[1];\n  p[2] = a[2] - b[2];\n\n  //perform rotation\n  r[0] = p[2] * Math.sin(rad) + p[0] * Math.cos(rad);\n  r[1] = p[1];\n  r[2] = p[2] * Math.cos(rad) - p[0] * Math.sin(rad);\n\n  //translate to correct position\n  out[0] = r[0] + b[0];\n  out[1] = r[1] + b[1];\n  out[2] = r[2] + b[2];\n  return out;\n}\n\n/**\n * Rotate a 3D vector around the z-axis\n * @param {vec3} out The receiving vec3\n * @param {ReadonlyVec3} a The vec3 point to rotate\n * @param {ReadonlyVec3} b The origin of the rotation\n * @param {Number} rad The angle of rotation in radians\n * @returns {vec3} out\n */\nexport function rotateZ(out, a, b, rad) {\n  var p = [],\n    r = [];\n  //Translate point to the origin\n  p[0] = a[0] - b[0];\n  p[1] = a[1] - b[1];\n  p[2] = a[2] - b[2];\n\n  //perform rotation\n  r[0] = p[0] * Math.cos(rad) - p[1] * Math.sin(rad);\n  r[1] = p[0] * Math.sin(rad) + p[1] * Math.cos(rad);\n  r[2] = p[2];\n\n  //translate to correct position\n  out[0] = r[0] + b[0];\n  out[1] = r[1] + b[1];\n  out[2] = r[2] + b[2];\n  return out;\n}\n\n/**\n * Get the angle between two 3D vectors\n * @param {ReadonlyVec3} a The first operand\n * @param {ReadonlyVec3} b The second operand\n * @returns {Number} The angle in radians\n */\nexport function angle(a, b) {\n  var ax = a[0],\n    ay = a[1],\n    az = a[2],\n    bx = b[0],\n    by = b[1],\n    bz = b[2],\n    mag = Math.sqrt((ax * ax + ay * ay + az * az) * (bx * bx + by * by + bz * bz)),\n    cosine = mag && dot(a, b) / mag;\n  return Math.acos(Math.min(Math.max(cosine, -1), 1));\n}\n\n/**\n * Set the components of a vec3 to zero\n *\n * @param {vec3} out the receiving vector\n * @returns {vec3} out\n */\nexport function zero(out) {\n  out[0] = 0.0;\n  out[1] = 0.0;\n  out[2] = 0.0;\n  return out;\n}\n\n/**\n * Returns a string representation of a vector\n *\n * @param {ReadonlyVec3} a vector to represent as a string\n * @returns {String} string representation of the vector\n */\nexport function str(a) {\n  return \"vec3(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \")\";\n}\n\n/**\n * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyVec3} a The first vector.\n * @param {ReadonlyVec3} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\nexport function exactEquals(a, b) {\n  return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];\n}\n\n/**\n * Returns whether or not the vectors have approximately the same elements in the same position.\n *\n * @param {ReadonlyVec3} a The first vector.\n * @param {ReadonlyVec3} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\nexport function equals(a, b) {\n  var a0 = a[0],\n    a1 = a[1],\n    a2 = a[2];\n  var b0 = b[0],\n    b1 = b[1],\n    b2 = b[2];\n  return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2));\n}\n\n/**\n * Alias for {@link vec3.subtract}\n * @function\n */\nexport var sub = subtract;\n\n/**\n * Alias for {@link vec3.multiply}\n * @function\n */\nexport var mul = multiply;\n\n/**\n * Alias for {@link vec3.divide}\n * @function\n */\nexport var div = divide;\n\n/**\n * Alias for {@link vec3.distance}\n * @function\n */\nexport var dist = distance;\n\n/**\n * Alias for {@link vec3.squaredDistance}\n * @function\n */\nexport var sqrDist = squaredDistance;\n\n/**\n * Alias for {@link vec3.length}\n * @function\n */\nexport var len = length;\n\n/**\n * Alias for {@link vec3.squaredLength}\n * @function\n */\nexport var sqrLen = squaredLength;\n\n/**\n * Perform some operation over an array of vec3s.\n *\n * @param {Array} a the array of vectors to iterate over\n * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed\n * @param {Number} offset Number of elements to skip at the beginning of the array\n * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array\n * @param {Function} fn Function to call for each vector in the array\n * @param {Object} [arg] additional argument to pass to fn\n * @returns {Array} a\n * @function\n */\nexport var forEach = function () {\n  var vec = create();\n  return function (a, stride, offset, count, fn, arg) {\n    var i, l;\n    if (!stride) {\n      stride = 3;\n    }\n    if (!offset) {\n      offset = 0;\n    }\n    if (count) {\n      l = Math.min(count * stride + offset, a.length);\n    } else {\n      l = a.length;\n    }\n    for (i = offset; i < l; i += stride) {\n      vec[0] = a[i];\n      vec[1] = a[i + 1];\n      vec[2] = a[i + 2];\n      fn(vec, vec, arg);\n      a[i] = vec[0];\n      a[i + 1] = vec[1];\n      a[i + 2] = vec[2];\n    }\n    return a;\n  };\n}();","import { Document, Primitive, type Transform } from '@gltf-transform/core';\nimport { compactPrimitive } from './compact-primitive.js';\nimport { getPrimitiveVertexCount, VertexCountMethod } from './get-vertex-count.js';\nimport { EMPTY_U32, hashLookup, VertexStream } from './hash-table.js';\nimport { assignDefaults, ceilPowerOfTwo, createTransform, deepDisposePrimitive, formatDeltaOp } from './utils.js';\n\n/**\n * CONTRIBUTOR NOTES\n *\n * Ideally a weld() implementation should be fast, robust, and tunable. The\n * writeup below tracks my attempts to solve for these constraints.\n *\n * (Approach #1) Follow the mergeVertices() implementation of three.js,\n * hashing vertices with a string concatenation of all vertex attributes.\n * The approach does not allow per-attribute tolerance in local units.\n *\n * (Approach #2) Sort points along the X axis, then make cheaper\n * searches up/down the sorted list for merge candidates. While this allows\n * simpler comparison based on specified tolerance, it's much slower, even\n * for cases where choice of the X vs. Y or Z axes is reasonable.\n *\n * (Approach #3) Attempted a Delaunay triangulation in three dimensions,\n * expecting it would be an n * log(n) algorithm, but the only implementation\n * I found (with delaunay-triangulate) appeared to be much slower than that,\n * and was notably slower than the sort-based approach, just building the\n * Delaunay triangulation alone.\n *\n * (Approach #4) Hybrid of (1) and (2), assigning vertices to a spatial\n * grid, then searching the local neighborhood (27 cells) for weld candidates.\n *\n * (Approach #5) Based on Meshoptimizer's implementation, when tolerance=0\n * use a hashtable to find bitwise-equal vertices quickly. Vastly faster than\n * previous approaches, but without tolerance options.\n *\n * RESULTS: For the \"Lovecraftian\" sample model linked below, after joining,\n * a primitive with 873,000 vertices can be welded down to 230,000 vertices.\n * https://sketchfab.com/3d-models/sculpt-january-day-19-lovecraftian-34ad2501108e4fceb9394f5b816b9f42\n *\n * - (1) Not tested, but prior results suggest not robust enough.\n * - (2) 30s\n * - (3) 660s\n * - (4) 5s exhaustive, 1.5s non-exhaustive\n * - (5) 0.2s\n *\n * As of April 2024, the lossy weld was removed, leaving only approach #5. An\n * upcoming Meshoptimizer release will include a simplifyWithAttributes\n * function allowing simplification with weighted consideration of vertex\n * attributes, which I hope to support. With that, weld() may remain faster,\n * simpler, and more maintainable.\n */\n\nconst NAME = 'weld';\n\n/** Options for the {@link weld} function. */\nexport interface WeldOptions {\n\t/** Whether to overwrite existing indices. */\n\toverwrite?: boolean;\n}\n\nexport const WELD_DEFAULTS: Required<WeldOptions> = {\n\toverwrite: true,\n};\n\n/**\n * Welds {@link Primitive Primitives}, merging bitwise identical vertices. When\n * merged and indexed, data is shared more efficiently between vertices. File size\n * can be reduced, and the GPU uses the vertex cache more efficiently.\n *\n * Example:\n *\n * ```javascript\n * import { weld, getSceneVertexCount, VertexCountMethod } from '@gltf-transform/functions';\n *\n * const scene = document.getDefaultScene();\n * const srcVertexCount = getSceneVertexCount(scene, VertexCountMethod.UPLOAD);\n * await document.transform(weld());\n * const dstVertexCount = getSceneVertexCount(scene, VertexCountMethod.UPLOAD);\n * ```\n *\n * @category Transforms\n */\nexport function weld(_options: WeldOptions = WELD_DEFAULTS): Transform {\n\tconst options = assignDefaults(WELD_DEFAULTS, _options);\n\n\treturn createTransform(NAME, async (doc: Document): Promise<void> => {\n\t\tconst logger = doc.getLogger();\n\n\t\tfor (const mesh of doc.getRoot().listMeshes()) {\n\t\t\tfor (const prim of mesh.listPrimitives()) {\n\t\t\t\tweldPrimitive(prim, options);\n\n\t\t\t\tif (getPrimitiveVertexCount(prim, VertexCountMethod.RENDER) === 0) {\n\t\t\t\t\tdeepDisposePrimitive(prim);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (mesh.listPrimitives().length === 0) mesh.dispose();\n\t\t}\n\n\t\tlogger.debug(`${NAME}: Complete.`);\n\t});\n}\n\n/**\n * Welds a {@link Primitive}, merging bitwise identical vertices. When merged\n * and indexed, data is shared more efficiently between vertices. File size can\n * be reduced, and the GPU uses the vertex cache more efficiently.\n *\n * Example:\n *\n * ```javascript\n * import { weldPrimitive, getMeshVertexCount, VertexCountMethod } from '@gltf-transform/functions';\n *\n * const mesh = document.getRoot().listMeshes()\n * \t.find((mesh) => mesh.getName() === 'Gizmo');\n *\n * const srcVertexCount = getMeshVertexCount(mesh, VertexCountMethod.UPLOAD);\n *\n * for (const prim of mesh.listPrimitives()) {\n *   weldPrimitive(prim);\n * }\n *\n * const dstVertexCount = getMeshVertexCount(mesh, VertexCountMethod.UPLOAD);\n * ```\n */\nexport function weldPrimitive(prim: Primitive, _options: WeldOptions = WELD_DEFAULTS): void {\n\tconst graph = prim.getGraph();\n\tconst document = Document.fromGraph(graph)!;\n\tconst logger = document.getLogger();\n\tconst options = { ...WELD_DEFAULTS, ..._options };\n\n\tif (prim.getIndices() && !options.overwrite) return;\n\tif (prim.getMode() === Primitive.Mode.POINTS) return;\n\n\tconst srcVertexCount = prim.getAttribute('POSITION')!.getCount();\n\tconst srcIndices = prim.getIndices();\n\tconst srcIndicesArray = srcIndices?.getArray();\n\tconst srcIndicesCount = srcIndices ? srcIndices.getCount() : srcVertexCount;\n\n\tconst stream = new VertexStream(prim);\n\tconst tableSize = ceilPowerOfTwo(srcVertexCount + srcVertexCount / 4);\n\tconst table = new Uint32Array(tableSize).fill(EMPTY_U32);\n\tconst writeMap = new Uint32Array(srcVertexCount).fill(EMPTY_U32); // oldIndex → newIndex\n\n\t// (1) Compare and identify indices to weld.\n\n\tlet dstVertexCount = 0;\n\n\tfor (let i = 0; i < srcIndicesCount; i++) {\n\t\tconst srcIndex = srcIndicesArray ? srcIndicesArray[i] : i;\n\t\tif (writeMap[srcIndex] !== EMPTY_U32) continue;\n\n\t\tconst hashIndex = hashLookup(table, tableSize, stream, srcIndex, EMPTY_U32);\n\t\tconst dstIndex = table[hashIndex];\n\n\t\tif (dstIndex === EMPTY_U32) {\n\t\t\ttable[hashIndex] = srcIndex;\n\t\t\twriteMap[srcIndex] = dstVertexCount++;\n\t\t} else {\n\t\t\twriteMap[srcIndex] = writeMap[dstIndex];\n\t\t}\n\t}\n\n\tlogger.debug(`${NAME}: ${formatDeltaOp(srcVertexCount, dstVertexCount)} vertices.`);\n\n\tcompactPrimitive(prim, writeMap, dstVertexCount);\n}\n","import { Accessor, MathUtils, type mat4, Primitive, type vec3 } from '@gltf-transform/core';\nimport { create as createMat3, fromMat4, invert, transpose } from 'gl-matrix/mat3';\nimport { determinant } from 'gl-matrix/mat4';\nimport { create as createVec3, normalize as normalizeVec3, transformMat3, transformMat4 } from 'gl-matrix/vec3';\nimport { weldPrimitive } from './weld.js';\n\nconst { FLOAT } = Accessor.ComponentType;\n\n/**\n * Applies a transform matrix to a {@link Primitive}.\n *\n * All vertex attributes on the Primitive and its\n * {@link PrimitiveTarget PrimitiveTargets} are modified in place. If vertex\n * streams are shared with other Primitives, and overwriting the shared vertex\n * attributes is not desired, use {@link compactPrimitive} to pre-process\n * the Primitive or call {@link transformMesh} instead.\n *\n * Example:\n *\n * ```javascript\n * import { fromTranslation } from 'gl-matrix/mat4';\n * import { transformPrimitive } from '@gltf-transform/functions';\n *\n * // offset vertices, y += 10.\n * transformPrimitive(prim, fromTranslation([], [0, 10, 0]));\n * ```\n *\n * @param prim\n * @param matrix\n */\nexport function transformPrimitive(prim: Primitive, matrix: mat4): void {\n\t// Apply transform to base attributes.\n\tconst position = prim.getAttribute('POSITION');\n\tif (position) {\n\t\tapplyMatrix(matrix, position);\n\t}\n\n\tconst normal = prim.getAttribute('NORMAL');\n\tif (normal) {\n\t\tapplyNormalMatrix(matrix, normal);\n\t}\n\n\tconst tangent = prim.getAttribute('TANGENT');\n\tif (tangent) {\n\t\tapplyTangentMatrix(matrix, tangent);\n\t}\n\n\t// Apply transform to morph attributes.\n\tfor (const target of prim.listTargets()) {\n\t\tconst position = target.getAttribute('POSITION');\n\t\tif (position) {\n\t\t\tapplyMatrix(matrix, position);\n\t\t}\n\n\t\tconst normal = target.getAttribute('NORMAL');\n\t\tif (normal) {\n\t\t\tapplyNormalMatrix(matrix, normal);\n\t\t}\n\n\t\tconst tangent = target.getAttribute('TANGENT');\n\t\tif (tangent) {\n\t\t\tapplyTangentMatrix(matrix, tangent);\n\t\t}\n\t}\n\n\t// Reverse winding order if scale is negative.\n\t// See: https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/NegativeScaleTest\n\tif (determinant(matrix) < 0) {\n\t\treversePrimitiveWindingOrder(prim);\n\t}\n}\n\nfunction applyMatrix(matrix: mat4, attribute: Accessor) {\n\tconst componentType = attribute.getComponentType();\n\tconst normalized = attribute.getNormalized();\n\tconst srcArray = attribute.getArray()!;\n\tconst dstArray = componentType === FLOAT ? srcArray : new Float32Array(srcArray.length);\n\n\tconst vector = createVec3() as vec3;\n\tfor (let i = 0, il = attribute.getCount(); i < il; i++) {\n\t\tif (normalized) {\n\t\t\tvector[0] = MathUtils.decodeNormalizedInt(srcArray[i * 3], componentType);\n\t\t\tvector[1] = MathUtils.decodeNormalizedInt(srcArray[i * 3 + 1], componentType);\n\t\t\tvector[2] = MathUtils.decodeNormalizedInt(srcArray[i * 3 + 2], componentType);\n\t\t} else {\n\t\t\tvector[0] = srcArray[i * 3];\n\t\t\tvector[1] = srcArray[i * 3 + 1];\n\t\t\tvector[2] = srcArray[i * 3 + 2];\n\t\t}\n\n\t\ttransformMat4(vector, vector, matrix);\n\n\t\tdstArray[i * 3] = vector[0];\n\t\tdstArray[i * 3 + 1] = vector[1];\n\t\tdstArray[i * 3 + 2] = vector[2];\n\t}\n\n\tattribute.setArray(dstArray).setNormalized(false);\n}\n\nfunction applyNormalMatrix(matrix: mat4, attribute: Accessor) {\n\tconst array = attribute.getArray()!;\n\tconst normalized = attribute.getNormalized();\n\tconst componentType = attribute.getComponentType();\n\n\tconst normalMatrix = createMat3();\n\tfromMat4(normalMatrix, matrix);\n\tinvert(normalMatrix, normalMatrix);\n\ttranspose(normalMatrix, normalMatrix);\n\n\tconst vector = createVec3() as vec3;\n\tfor (let i = 0, il = attribute.getCount(); i < il; i++) {\n\t\tif (normalized) {\n\t\t\tvector[0] = MathUtils.decodeNormalizedInt(array[i * 3], componentType);\n\t\t\tvector[1] = MathUtils.decodeNormalizedInt(array[i * 3 + 1], componentType);\n\t\t\tvector[2] = MathUtils.decodeNormalizedInt(array[i * 3 + 2], componentType);\n\t\t} else {\n\t\t\tvector[0] = array[i * 3];\n\t\t\tvector[1] = array[i * 3 + 1];\n\t\t\tvector[2] = array[i * 3 + 2];\n\t\t}\n\n\t\ttransformMat3(vector, vector, normalMatrix);\n\t\tnormalizeVec3(vector, vector);\n\n\t\tif (normalized) {\n\t\t\tarray[i * 3] = MathUtils.decodeNormalizedInt(vector[0], componentType);\n\t\t\tarray[i * 3 + 1] = MathUtils.decodeNormalizedInt(vector[1], componentType);\n\t\t\tarray[i * 3 + 2] = MathUtils.decodeNormalizedInt(vector[2], componentType);\n\t\t} else {\n\t\t\tarray[i * 3] = vector[0];\n\t\t\tarray[i * 3 + 1] = vector[1];\n\t\t\tarray[i * 3 + 2] = vector[2];\n\t\t}\n\t}\n}\n\nfunction applyTangentMatrix(matrix: mat4, attribute: Accessor) {\n\tconst array = attribute.getArray()!;\n\tconst normalized = attribute.getNormalized();\n\tconst componentType = attribute.getComponentType();\n\n\tconst v3 = createVec3() as vec3;\n\tfor (let i = 0, il = attribute.getCount(); i < il; i++) {\n\t\tif (normalized) {\n\t\t\tv3[0] = MathUtils.decodeNormalizedInt(array[i * 4], componentType);\n\t\t\tv3[1] = MathUtils.decodeNormalizedInt(array[i * 4 + 1], componentType);\n\t\t\tv3[2] = MathUtils.decodeNormalizedInt(array[i * 4 + 2], componentType);\n\t\t} else {\n\t\t\tv3[0] = array[i * 4];\n\t\t\tv3[1] = array[i * 4 + 1];\n\t\t\tv3[2] = array[i * 4 + 2];\n\t\t}\n\n\t\t// mat4 affine matrix applied to vector, vector interpreted as a direction.\n\t\t// Reference: https://github.com/mrdoob/three.js/blob/9f4de99828c05e71c47e6de0beb4c6e7652e486a/src/math/Vector3.js#L286-L300\n\t\tv3[0] = matrix[0] * v3[0] + matrix[4] * v3[1] + matrix[8] * v3[2];\n\t\tv3[1] = matrix[1] * v3[0] + matrix[5] * v3[1] + matrix[9] * v3[2];\n\t\tv3[2] = matrix[2] * v3[0] + matrix[6] * v3[1] + matrix[10] * v3[2];\n\t\tnormalizeVec3(v3, v3);\n\n\t\tif (normalized) {\n\t\t\tarray[i * 4] = MathUtils.decodeNormalizedInt(v3[0], componentType);\n\t\t\tarray[i * 4 + 1] = MathUtils.decodeNormalizedInt(v3[1], componentType);\n\t\t\tarray[i * 4 + 2] = MathUtils.decodeNormalizedInt(v3[2], componentType);\n\t\t} else {\n\t\t\tarray[i * 4] = v3[0];\n\t\t\tarray[i * 4 + 1] = v3[1];\n\t\t\tarray[i * 4 + 2] = v3[2];\n\t\t}\n\t}\n}\n\nfunction reversePrimitiveWindingOrder(prim: Primitive) {\n\tif (prim.getMode() !== Primitive.Mode.TRIANGLES) return;\n\tif (!prim.getIndices()) weldPrimitive(prim);\n\n\tconst indices = prim.getIndices()!;\n\tfor (let i = 0, il = indices.getCount(); i < il; i += 3) {\n\t\tconst a = indices.getScalar(i);\n\t\tconst c = indices.getScalar(i + 2);\n\t\tindices.setScalar(i, c);\n\t\tindices.setScalar(i + 2, a);\n\t}\n}\n","import { Mesh, type mat4, Primitive } from '@gltf-transform/core';\nimport { compactPrimitive } from './compact-primitive.js';\nimport { transformPrimitive } from './transform-primitive.js';\n\n/**\n * Applies a transform matrix to every {@link Primitive} in the given {@link Mesh}.\n *\n * For every Primitive in the Mesh, the operation first applies\n * {@link compactPrimitive} to isolate vertex streams, then calls\n * {@link transformPrimitive}. Transformed Mesh will no longer share vertex\n * attributes with any other Meshes — attributes are cloned before\n * transformation.\n *\n * Example:\n *\n * ```javascript\n * import { fromTranslation } from 'gl-matrix/mat4';\n * import { transformMesh } from '@gltf-transform/functions';\n *\n * // offset vertices, y += 10.\n * transformMesh(mesh, fromTranslation([], [0, 10, 0]));\n * ```\n *\n * @param mesh\n * @param matrix\n */\nexport function transformMesh(mesh: Mesh, matrix: mat4): void {\n\t// If primitives or morph targets are shared by other meshes, detach them.\n\tfor (const srcPrim of mesh.listPrimitives()) {\n\t\tconst dstPrim = shallowClonePrimitive(srcPrim, mesh);\n\t\tif (srcPrim !== dstPrim) {\n\t\t\tmesh.removePrimitive(srcPrim).addPrimitive(dstPrim);\n\t\t}\n\t}\n\n\t// Isolate vertex streams, remove unused vertices, and transform.\n\tfor (const prim of mesh.listPrimitives()) {\n\t\tcompactPrimitive(prim);\n\t\ttransformPrimitive(prim, matrix);\n\t}\n}\n\n/**\n * Conditionally clones a {@link Primitive} and its\n * {@link PrimitiveTarget PrimitiveTargets}, if any are shared with other\n * parents. If nothing is shared, nothing is cloned. Accessors and materials\n * are not cloned.\n *\n * @hidden\n * @internal\n */\nfunction shallowClonePrimitive(prim: Primitive, parentMesh: Mesh): Primitive {\n\tconst isSharedPrimitive = prim.listParents().some((parent) => parent instanceof Mesh && parent !== parentMesh);\n\tif (isSharedPrimitive) {\n\t\tprim = prim.clone();\n\t}\n\n\tfor (const target of prim.listTargets()) {\n\t\tconst isSharedTarget = target.listParents().some((parent) => parent instanceof Primitive && parent !== prim);\n\t\tif (isSharedTarget) {\n\t\t\tprim.removeTarget(target).addTarget(target.clone());\n\t\t}\n\t}\n\n\treturn prim;\n}\n","import { MathUtils, type mat4, type Node } from '@gltf-transform/core';\nimport { multiply as multiplyMat4 } from 'gl-matrix/mat4';\nimport { transformMesh } from './transform-mesh.js';\n\n// biome-ignore format: Readability.\nconst IDENTITY: mat4 = [\n  1, 0, 0, 0,\n  0, 1, 0, 0,\n  0, 0, 1, 0,\n  0, 0, 0, 1\n];\n\n/**\n * Clears local transform of the {@link Node}, applying the transform to children and meshes.\n *\n * - Applies transform to children\n * - Applies transform to {@link Mesh mesh}\n * - Resets {@link Light lights}, {@link Camera cameras}, and other attachments to the origin\n *\n * Example:\n *\n * ```typescript\n * import { clearNodeTransform } from '@gltf-transform/functions';\n *\n * node.getTranslation(); // → [ 5, 0, 0 ]\n * node.getMesh(); // → vertex data centered at origin\n *\n * clearNodeTransform(node);\n *\n * node.getTranslation(); // → [ 0, 0, 0 ]\n * node.getMesh(); // → vertex data centered at [ 5, 0, 0 ]\n * ```\n *\n * To clear _all_ transforms of a Node, first clear its inherited transforms with\n * {@link clearNodeParent}, then clear the local transform with {@link clearNodeTransform}.\n */\nexport function clearNodeTransform(node: Node): Node {\n\tconst mesh = node.getMesh();\n\tconst localMatrix = node.getMatrix();\n\n\tif (mesh && !MathUtils.eq(localMatrix, IDENTITY)) {\n\t\ttransformMesh(mesh, localMatrix);\n\t}\n\n\tfor (const child of node.listChildren()) {\n\t\tconst matrix = child.getMatrix();\n\t\tmultiplyMat4(matrix, matrix, localMatrix);\n\t\tchild.setMatrix(matrix);\n\t}\n\n\treturn node.setMatrix(IDENTITY);\n}\n","import { ComponentTypeToTypedArray, Document, Primitive } from '@gltf-transform/core';\nimport { getGLPrimitiveCount, shallowCloneAccessor } from './utils.js';\nimport { weldPrimitive } from './weld.js';\n\nconst { LINES, LINE_STRIP, LINE_LOOP, TRIANGLES, TRIANGLE_STRIP, TRIANGLE_FAN } = Primitive.Mode;\n\n/**\n * Converts a LINE_STRIP or LINE_LOOP {@link Primitive} to LINES, which is\n * more widely supported. Any other topology given as input (points or\n * triangles) will throw an error.\n *\n * Example:\n *\n * ```javascript\n * import { convertPrimitiveToLines } from '@gltf-transform/functions';\n *\n * console.log(prim.getMode()); // 2 (LINE_LOOP)\n * convertPrimitiveToLines(prim);\n * console.log(prim.getMode()); // 1 (LINES)\n * ```\n */\nexport function convertPrimitiveToLines(prim: Primitive): void {\n\tconst graph = prim.getGraph();\n\tconst document = Document.fromGraph(graph)!;\n\n\t// Ensure indexed primitive.\n\tif (!prim.getIndices()) {\n\t\tweldPrimitive(prim);\n\t}\n\n\t// Allocate indices new GL primitives.\n\tconst srcIndices = prim.getIndices()!;\n\tconst srcIndicesArray = srcIndices.getArray()!;\n\tconst dstGLPrimitiveCount = getGLPrimitiveCount(prim);\n\tconst IndicesArray = ComponentTypeToTypedArray[srcIndices.getComponentType()];\n\tconst dstIndicesArray = new IndicesArray(dstGLPrimitiveCount * 2);\n\n\t// Generate GL primitives.\n\tconst srcMode = prim.getMode();\n\tif (srcMode === LINE_STRIP) {\n\t\t// https://glasnost.itcarlow.ie/~powerk/opengl/primitives/primitives.htm\n\t\tfor (let i = 0; i < dstGLPrimitiveCount; i++) {\n\t\t\tdstIndicesArray[i * 2] = srcIndicesArray[i];\n\t\t\tdstIndicesArray[i * 2 + 1] = srcIndicesArray[i + 1];\n\t\t}\n\t} else if (srcMode === LINE_LOOP) {\n\t\t// https://glasnost.itcarlow.ie/~powerk/opengl/primitives/primitives.htm\n\t\tfor (let i = 0; i < dstGLPrimitiveCount; i++) {\n\t\t\tif (i < dstGLPrimitiveCount - 1) {\n\t\t\t\tdstIndicesArray[i * 2] = srcIndicesArray[i];\n\t\t\t\tdstIndicesArray[i * 2 + 1] = srcIndicesArray[i + 1];\n\t\t\t} else {\n\t\t\t\tdstIndicesArray[i * 2] = srcIndicesArray[i];\n\t\t\t\tdstIndicesArray[i * 2 + 1] = srcIndicesArray[0];\n\t\t\t}\n\t\t}\n\t} else {\n\t\tthrow new Error('Only LINE_STRIP and LINE_LOOP may be converted to LINES.');\n\t}\n\n\t// Update prim mode and indices.\n\tprim.setMode(LINES);\n\tconst root = document.getRoot();\n\tif (srcIndices.listParents().some((parent) => parent !== root && parent !== prim)) {\n\t\tprim.setIndices(shallowCloneAccessor(document, srcIndices).setArray(dstIndicesArray));\n\t} else {\n\t\tsrcIndices.setArray(dstIndicesArray);\n\t}\n}\n\n/**\n * Converts a TRIANGLE_STRIP or TRIANGLE_LOOP {@link Primitive} to TRIANGLES,\n * which is more widely supported. Any other topology given as input (points or\n * lines) will throw an error.\n *\n * Example:\n *\n * ```javascript\n * import { convertPrimitiveToTriangles } from '@gltf-transform/functions';\n *\n * console.log(prim.getMode()); // 5 (TRIANGLE_STRIP)\n * convertPrimitiveToTriangles(prim);\n * console.log(prim.getMode()); // 4 (TRIANGLES)\n * ```\n */\nexport function convertPrimitiveToTriangles(prim: Primitive): void {\n\tconst graph = prim.getGraph();\n\tconst document = Document.fromGraph(graph)!;\n\n\t// Ensure indexed primitive.\n\tif (!prim.getIndices()) {\n\t\tweldPrimitive(prim);\n\t}\n\n\t// Allocate indices new GL primitives.\n\tconst srcIndices = prim.getIndices()!;\n\tconst srcIndicesArray = srcIndices.getArray()!;\n\tconst dstGLPrimitiveCount = getGLPrimitiveCount(prim);\n\tconst IndicesArray = ComponentTypeToTypedArray[srcIndices.getComponentType()];\n\tconst dstIndicesArray = new IndicesArray(dstGLPrimitiveCount * 3);\n\n\t// Generate GL primitives.\n\tconst srcMode = prim.getMode();\n\tif (srcMode === TRIANGLE_STRIP) {\n\t\t// https://en.wikipedia.org/wiki/Triangle_strip\n\t\tfor (let i = 0, il = srcIndicesArray.length; i < il - 2; i++) {\n\t\t\tif (i % 2) {\n\t\t\t\tdstIndicesArray[i * 3] = srcIndicesArray[i + 1];\n\t\t\t\tdstIndicesArray[i * 3 + 1] = srcIndicesArray[i];\n\t\t\t\tdstIndicesArray[i * 3 + 2] = srcIndicesArray[i + 2];\n\t\t\t} else {\n\t\t\t\tdstIndicesArray[i * 3] = srcIndicesArray[i];\n\t\t\t\tdstIndicesArray[i * 3 + 1] = srcIndicesArray[i + 1];\n\t\t\t\tdstIndicesArray[i * 3 + 2] = srcIndicesArray[i + 2];\n\t\t\t}\n\t\t}\n\t} else if (srcMode === TRIANGLE_FAN) {\n\t\t// https://en.wikipedia.org/wiki/Triangle_fan\n\t\tfor (let i = 0; i < dstGLPrimitiveCount; i++) {\n\t\t\tdstIndicesArray[i * 3] = srcIndicesArray[0];\n\t\t\tdstIndicesArray[i * 3 + 1] = srcIndicesArray[i + 1];\n\t\t\tdstIndicesArray[i * 3 + 2] = srcIndicesArray[i + 2];\n\t\t}\n\t} else {\n\t\tthrow new Error('Only TRIANGLE_STRIP and TRIANGLE_FAN may be converted to TRIANGLES.');\n\t}\n\n\t// Update prim mode and indices.\n\tprim.setMode(TRIANGLES);\n\tconst root = document.getRoot();\n\tif (srcIndices.listParents().some((parent) => parent !== root && parent !== prim)) {\n\t\tprim.setIndices(shallowCloneAccessor(document, srcIndices).setArray(dstIndicesArray));\n\t} else {\n\t\tsrcIndices.setArray(dstIndicesArray);\n\t}\n}\n","import {\n\ttype Accessor,\n\tBufferUtils,\n\ttype Document,\n\ttype Material,\n\ttype Mesh,\n\tPrimitive,\n\ttype PrimitiveTarget,\n\ttype Property,\n\tPropertyType,\n\tRoot,\n\ttype Skin,\n\ttype Texture,\n\ttype Transform,\n} from '@gltf-transform/core';\nimport { assignDefaults, createTransform, shallowEqualsArray } from './utils.js';\n\nconst NAME = 'dedup';\n\nexport interface DedupOptions {\n\t/** Keep properties with unique names, even if they are duplicates. */\n\tkeepUniqueNames?: boolean;\n\t/** List of {@link PropertyType} identifiers to be de-duplicated.*/\n\tpropertyTypes?: string[];\n}\n\nconst DEDUP_DEFAULTS: Required<DedupOptions> = {\n\tkeepUniqueNames: false,\n\tpropertyTypes: [\n\t\tPropertyType.ACCESSOR,\n\t\tPropertyType.MESH,\n\t\tPropertyType.TEXTURE,\n\t\tPropertyType.MATERIAL,\n\t\tPropertyType.SKIN,\n\t],\n};\n\n/**\n * Removes duplicate {@link Accessor}, {@link Mesh}, {@link Texture}, and {@link Material}\n * properties. Partially based on a\n * [gist by mattdesl](https://gist.github.com/mattdesl/aea40285e2d73916b6b9101b36d84da8). Only\n * accessors in mesh primitives, morph targets, and animation samplers are processed.\n *\n * Example:\n *\n * ```ts\n * document.getRoot().listMeshes(); // → [Mesh, Mesh, Mesh]\n *\n * await document.transform(dedup({propertyTypes: [PropertyType.MESH]}));\n *\n * document.getRoot().listMeshes(); // → [Mesh]\n * ```\n *\n * @category Transforms\n */\nexport function dedup(_options: DedupOptions = DEDUP_DEFAULTS): Transform {\n\tconst options = assignDefaults(DEDUP_DEFAULTS, _options);\n\n\tconst propertyTypes = new Set(options.propertyTypes);\n\tfor (const propertyType of options.propertyTypes) {\n\t\tif (!DEDUP_DEFAULTS.propertyTypes.includes(propertyType)) {\n\t\t\tthrow new Error(`${NAME}: Unsupported deduplication on type \"${propertyType}\".`);\n\t\t}\n\t}\n\n\treturn createTransform(NAME, (document: Document): void => {\n\t\tconst logger = document.getLogger();\n\n\t\tif (propertyTypes.has(PropertyType.ACCESSOR)) dedupAccessors(document);\n\t\tif (propertyTypes.has(PropertyType.TEXTURE)) dedupImages(document, options);\n\t\tif (propertyTypes.has(PropertyType.MATERIAL)) dedupMaterials(document, options);\n\t\tif (propertyTypes.has(PropertyType.MESH)) dedupMeshes(document, options);\n\t\tif (propertyTypes.has(PropertyType.SKIN)) dedupSkins(document, options);\n\n\t\tlogger.debug(`${NAME}: Complete.`);\n\t});\n}\n\nfunction dedupAccessors(document: Document): void {\n\tconst logger = document.getLogger();\n\n\t// Find all accessors used for mesh and animation data.\n\tconst indicesMap = new Map<string, Set<Accessor>>();\n\tconst attributeMap = new Map<string, Set<Accessor>>();\n\tconst inputMap = new Map<string, Set<Accessor>>();\n\tconst outputMap = new Map<string, Set<Accessor>>();\n\n\tconst meshes = document.getRoot().listMeshes();\n\tmeshes.forEach((mesh) => {\n\t\tmesh.listPrimitives().forEach((primitive) => {\n\t\t\tprimitive.listAttributes().forEach((accessor) => hashAccessor(accessor, attributeMap));\n\t\t\thashAccessor(primitive.getIndices(), indicesMap);\n\t\t});\n\t});\n\n\tfor (const animation of document.getRoot().listAnimations()) {\n\t\tfor (const sampler of animation.listSamplers()) {\n\t\t\thashAccessor(sampler.getInput(), inputMap);\n\t\t\thashAccessor(sampler.getOutput(), outputMap);\n\t\t}\n\t}\n\n\t// Add accessor to the appropriate hash group. Hashes are _non-unique_,\n\t// intended to quickly compare everything accept the underlying array.\n\tfunction hashAccessor(accessor: Accessor | null, group: Map<string, Set<Accessor>>): void {\n\t\tif (!accessor) return;\n\n\t\tconst hash = [\n\t\t\taccessor.getCount(),\n\t\t\taccessor.getType(),\n\t\t\taccessor.getComponentType(),\n\t\t\taccessor.getNormalized(),\n\t\t\taccessor.getSparse(),\n\t\t].join(':');\n\n\t\tlet hashSet = group.get(hash);\n\t\tif (!hashSet) group.set(hash, (hashSet = new Set<Accessor>()));\n\t\thashSet.add(accessor);\n\t}\n\n\t// Find duplicate accessors of a given type.\n\tfunction detectDuplicates(accessors: Accessor[], duplicates: Map<Accessor, Accessor>): void {\n\t\tfor (let i = 0; i < accessors.length; i++) {\n\t\t\tconst a = accessors[i];\n\t\t\tconst aData = BufferUtils.toView(a.getArray()!);\n\n\t\t\tif (duplicates.has(a)) continue;\n\n\t\t\tfor (let j = i + 1; j < accessors.length; j++) {\n\t\t\t\tconst b = accessors[j];\n\n\t\t\t\tif (duplicates.has(b)) continue;\n\n\t\t\t\t// Just compare the arrays — everything else was covered by the\n\t\t\t\t// hash. Comparing uint8 views is faster than comparing the\n\t\t\t\t// original typed arrays.\n\t\t\t\tif (BufferUtils.equals(aData, BufferUtils.toView(b.getArray()!))) {\n\t\t\t\t\tduplicates.set(b, a);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tlet total = 0;\n\tconst duplicates = new Map<Accessor, Accessor>();\n\tfor (const group of [attributeMap, indicesMap, inputMap, outputMap]) {\n\t\tfor (const hashGroup of group.values()) {\n\t\t\ttotal += hashGroup.size;\n\t\t\tdetectDuplicates(Array.from(hashGroup), duplicates);\n\t\t}\n\t}\n\n\tlogger.debug(`${NAME}: Merged ${duplicates.size} of ${total} accessors.`);\n\n\t// Dissolve duplicate vertex attributes and indices.\n\tmeshes.forEach((mesh) => {\n\t\tmesh.listPrimitives().forEach((primitive) => {\n\t\t\tprimitive.listAttributes().forEach((accessor) => {\n\t\t\t\tif (duplicates.has(accessor)) {\n\t\t\t\t\tprimitive.swap(accessor, duplicates.get(accessor) as Accessor);\n\t\t\t\t}\n\t\t\t});\n\t\t\tconst indices = primitive.getIndices();\n\t\t\tif (indices && duplicates.has(indices)) {\n\t\t\t\tprimitive.swap(indices, duplicates.get(indices) as Accessor);\n\t\t\t}\n\t\t});\n\t});\n\n\t// Dissolve duplicate animation sampler inputs and outputs.\n\tfor (const animation of document.getRoot().listAnimations()) {\n\t\tfor (const sampler of animation.listSamplers()) {\n\t\t\tconst input = sampler.getInput();\n\t\t\tconst output = sampler.getOutput();\n\t\t\tif (input && duplicates.has(input)) {\n\t\t\t\tsampler.swap(input, duplicates.get(input) as Accessor);\n\t\t\t}\n\t\t\tif (output && duplicates.has(output)) {\n\t\t\t\tsampler.swap(output, duplicates.get(output) as Accessor);\n\t\t\t}\n\t\t}\n\t}\n\n\tArray.from(duplicates.keys()).forEach((accessor) => accessor.dispose());\n}\n\nfunction dedupMeshes(document: Document, options: Required<DedupOptions>): void {\n\tconst logger = document.getLogger();\n\tconst root = document.getRoot();\n\n\t// Create Reference -> ID lookup table.\n\tconst refs = new Map<Accessor | Material, number>();\n\troot.listAccessors().forEach((accessor, index) => refs.set(accessor, index));\n\troot.listMaterials().forEach((material, index) => refs.set(material, index));\n\n\t// For each mesh, create a hashkey.\n\tconst numMeshes = root.listMeshes().length;\n\tconst uniqueMeshes = new Map<string, Mesh>();\n\tfor (const src of root.listMeshes()) {\n\t\t// For each mesh, create a hashkey.\n\t\tconst srcKeyItems = [];\n\t\tfor (const prim of src.listPrimitives()) {\n\t\t\tsrcKeyItems.push(createPrimitiveKey(prim, refs));\n\t\t}\n\n\t\t// If another mesh exists with the same key, replace all instances with that, and dispose\n\t\t// of the duplicate. If not, just cache it.\n\t\tlet meshKey = '';\n\t\tif (options.keepUniqueNames) meshKey += src.getName() + ';';\n\t\tmeshKey += srcKeyItems.join(';');\n\n\t\tif (uniqueMeshes.has(meshKey)) {\n\t\t\tconst targetMesh = uniqueMeshes.get(meshKey)!;\n\t\t\tsrc.listParents().forEach((parent) => {\n\t\t\t\tif (parent.propertyType !== PropertyType.ROOT) {\n\t\t\t\t\tparent.swap(src, targetMesh);\n\t\t\t\t}\n\t\t\t});\n\t\t\tsrc.dispose();\n\t\t} else {\n\t\t\tuniqueMeshes.set(meshKey, src);\n\t\t}\n\t}\n\n\tlogger.debug(`${NAME}: Merged ${numMeshes - uniqueMeshes.size} of ${numMeshes} meshes.`);\n}\n\nfunction dedupImages(document: Document, options: Required<DedupOptions>): void {\n\tconst logger = document.getLogger();\n\tconst root = document.getRoot();\n\tconst textures = root.listTextures();\n\tconst duplicates: Map<Texture, Texture> = new Map();\n\n\t// Compare each texture to every other texture — O(n²) — and mark duplicates for replacement.\n\tfor (let i = 0; i < textures.length; i++) {\n\t\tconst a = textures[i];\n\t\tconst aData = a.getImage();\n\n\t\tif (duplicates.has(a)) continue;\n\n\t\tfor (let j = i + 1; j < textures.length; j++) {\n\t\t\tconst b = textures[j];\n\t\t\tconst bData = b.getImage();\n\n\t\t\tif (duplicates.has(b)) continue;\n\n\t\t\t// URIs are intentionally not compared.\n\t\t\tif (a.getMimeType() !== b.getMimeType()) continue;\n\t\t\tif (options.keepUniqueNames && a.getName() !== b.getName()) continue;\n\n\t\t\tconst aSize = a.getSize();\n\t\t\tconst bSize = b.getSize();\n\t\t\tif (!aSize || !bSize) continue;\n\t\t\tif (aSize[0] !== bSize[0]) continue;\n\t\t\tif (aSize[1] !== bSize[1]) continue;\n\t\t\tif (!aData || !bData) continue;\n\t\t\tif (BufferUtils.equals(aData, bData)) {\n\t\t\t\tduplicates.set(b, a);\n\t\t\t}\n\t\t}\n\t}\n\n\tlogger.debug(`${NAME}: Merged ${duplicates.size} of ${root.listTextures().length} textures.`);\n\n\tArray.from(duplicates.entries()).forEach(([src, dst]) => {\n\t\tsrc.listParents().forEach((property) => {\n\t\t\tif (!(property instanceof Root)) property.swap(src, dst);\n\t\t});\n\t\tsrc.dispose();\n\t});\n}\n\nfunction dedupMaterials(document: Document, options: Required<DedupOptions>): void {\n\tconst logger = document.getLogger();\n\tconst root = document.getRoot();\n\tconst materials = root.listMaterials();\n\tconst duplicates = new Map<Material, Material>();\n\tconst modifierCache = new Map<Material, boolean>();\n\tconst skip = new Set<string>();\n\n\tif (!options.keepUniqueNames) {\n\t\tskip.add('name');\n\t}\n\n\t// Compare each material to every other material — O(n²) — and mark duplicates for replacement.\n\tfor (let i = 0; i < materials.length; i++) {\n\t\tconst a = materials[i];\n\n\t\tif (duplicates.has(a)) continue;\n\t\tif (hasModifier(a, modifierCache)) continue;\n\n\t\tfor (let j = i + 1; j < materials.length; j++) {\n\t\t\tconst b = materials[j];\n\n\t\t\tif (duplicates.has(b)) continue;\n\t\t\tif (hasModifier(b, modifierCache)) continue;\n\n\t\t\tif (a.equals(b, skip)) {\n\t\t\t\tduplicates.set(b, a);\n\t\t\t}\n\t\t}\n\t}\n\n\tlogger.debug(`${NAME}: Merged ${duplicates.size} of ${materials.length} materials.`);\n\n\tArray.from(duplicates.entries()).forEach(([src, dst]) => {\n\t\tsrc.listParents().forEach((property) => {\n\t\t\tif (!(property instanceof Root)) property.swap(src, dst);\n\t\t});\n\t\tsrc.dispose();\n\t});\n}\n\nfunction dedupSkins(document: Document, options: Required<DedupOptions>): void {\n\tconst logger = document.getLogger();\n\tconst root = document.getRoot();\n\tconst skins = root.listSkins();\n\tconst duplicates = new Map<Skin, Skin>();\n\tconst skip = new Set(['joints']);\n\n\tif (!options.keepUniqueNames) {\n\t\tskip.add('name');\n\t}\n\n\tfor (let i = 0; i < skins.length; i++) {\n\t\tconst a = skins[i];\n\n\t\tif (duplicates.has(a)) continue;\n\n\t\tfor (let j = i + 1; j < skins.length; j++) {\n\t\t\tconst b = skins[j];\n\t\t\tif (duplicates.has(b)) continue;\n\n\t\t\t// Check joints with shallow equality, not deep equality.\n\t\t\t// See: https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/RecursiveSkeletons\n\t\t\tif (a.equals(b, skip) && shallowEqualsArray(a.listJoints(), b.listJoints())) {\n\t\t\t\tduplicates.set(b, a);\n\t\t\t}\n\t\t}\n\t}\n\n\tlogger.debug(`${NAME}: Merged ${duplicates.size} of ${skins.length} skins.`);\n\n\tArray.from(duplicates.entries()).forEach(([src, dst]) => {\n\t\tsrc.listParents().forEach((property) => {\n\t\t\tif (!(property instanceof Root)) property.swap(src, dst);\n\t\t});\n\t\tsrc.dispose();\n\t});\n}\n\n/** Generates a key unique to the content of a primitive or target. */\nfunction createPrimitiveKey(prim: Primitive | PrimitiveTarget, refs: Map<Accessor | Material, number>): string {\n\tconst primKeyItems = [];\n\tfor (const semantic of prim.listSemantics()) {\n\t\tconst attribute = prim.getAttribute(semantic)!;\n\t\tprimKeyItems.push(semantic + ':' + refs.get(attribute));\n\t}\n\tif (prim instanceof Primitive) {\n\t\tconst indices = prim.getIndices();\n\t\tif (indices) {\n\t\t\tprimKeyItems.push('indices:' + refs.get(indices));\n\t\t}\n\t\tconst material = prim.getMaterial();\n\t\tif (material) {\n\t\t\tprimKeyItems.push('material:' + refs.get(material));\n\t\t}\n\t\tprimKeyItems.push('mode:' + prim.getMode());\n\t\tfor (const target of prim.listTargets()) {\n\t\t\tprimKeyItems.push('target:' + createPrimitiveKey(target, refs));\n\t\t}\n\t}\n\treturn primKeyItems.join(',');\n}\n\n/**\n * Detects dependencies modified by a parent reference, to conservatively prevent merging. When\n * implementing extensions like KHR_animation_pointer, the 'modifyChild' attribute should be added\n * to graph edges connecting the animation channel to the animated target property.\n *\n * NOTICE: Implementation is conservative, and could prevent merging two materials sharing the\n * same animated \"Clearcoat\" ExtensionProperty. While that scenario is possible for an in-memory\n * glTF Transform graph, valid glTF input files do not have that risk.\n */\nfunction hasModifier(prop: Property, cache: Map<Property, boolean>): boolean {\n\tif (cache.has(prop)) return cache.get(prop)!;\n\n\tconst graph = prop.getGraph();\n\tconst visitedNodes = new Set<Property>();\n\tconst edgeQueue = graph.listParentEdges(prop);\n\n\t// Search dependency subtree for 'modifyChild' attribute.\n\twhile (edgeQueue.length > 0) {\n\t\tconst edge = edgeQueue.pop()!;\n\t\tif (edge.getAttributes().modifyChild === true) {\n\t\t\tcache.set(prop, true);\n\t\t\treturn true;\n\t\t}\n\n\t\tconst child = edge.getChild();\n\t\tif (visitedNodes.has(child)) continue;\n\n\t\tfor (const childEdge of graph.listChildEdges(child)) {\n\t\t\tedgeQueue.push(childEdge);\n\t\t}\n\t}\n\n\tcache.set(prop, false);\n\treturn false;\n}\n","import {\n\ttype Accessor,\n\ttype Document,\n\ttype GLTF,\n\tMathUtils,\n\ttype Primitive,\n\ttype Transform,\n\ttype TypedArray,\n} from '@gltf-transform/core';\nimport { KHRMeshQuantization } from '@gltf-transform/extensions';\nimport { assignDefaults, createTransform } from './utils.js';\n\nconst NAME = 'dequantize';\n\n/** Options for the {@link dequantize} function. */\nexport interface DequantizeOptions {\n\t/**\n\t * Pattern (regex) used to filter vertex attribute semantics for quantization.\n\t * Default: `/^((?!JOINTS_).)*$/`.\n\t */\n\tpattern?: RegExp;\n}\n\nconst DEQUANTIZE_DEFAULTS: Required<DequantizeOptions> = {\n\tpattern: /^((?!JOINTS_).)*$/,\n};\n\n/**\n * Dequantize {@link Primitive Primitives}, removing {@link KHRMeshQuantization `KHR_mesh_quantization`}\n * if present. Dequantization will increase the size of the mesh on disk and in memory, but may be\n * necessary for compatibility with applications that don't support quantization.\n *\n * Example:\n *\n * ```javascript\n * import { dequantizePrimitive } from '@gltf-transform/functions';\n *\n * await document.transform(dequantize());\n * ```\n *\n * @category Transforms\n */\nexport function dequantize(_options: DequantizeOptions = DEQUANTIZE_DEFAULTS): Transform {\n\tconst options = assignDefaults(DEQUANTIZE_DEFAULTS, _options);\n\n\treturn createTransform(NAME, (document: Document): void => {\n\t\tconst logger = document.getLogger();\n\t\tfor (const mesh of document.getRoot().listMeshes()) {\n\t\t\tfor (const prim of mesh.listPrimitives()) {\n\t\t\t\tdequantizePrimitive(prim, options);\n\t\t\t}\n\t\t}\n\t\tdocument.disposeExtension('KHR_mesh_quantization');\n\t\tlogger.debug(`${NAME}: Complete.`);\n\t});\n}\n\n/**\n * Dequantize a single {@link Primitive}, converting all vertex attributes to float32. Dequantization\n * will increase the size of the mesh on disk and in memory, but may be necessary for compatibility\n * with applications that don't support quantization.\n *\n * Example:\n *\n * ```javascript\n * import { dequantizePrimitive } from '@gltf-transform/functions';\n *\n * const mesh = document.getRoot().listMeshes().find((mesh) => mesh.getName() === 'MyMesh');\n *\n * for (const prim of mesh.listPrimitives()) {\n * \tdequantizePrimitive(prim);\n * }\n * ```\n */\nexport function dequantizePrimitive(prim: Primitive, _options: DequantizeOptions = DEQUANTIZE_DEFAULTS): void {\n\tconst options = assignDefaults(DEQUANTIZE_DEFAULTS, _options);\n\n\tfor (const semantic of prim.listSemantics()) {\n\t\tif (options.pattern.test(semantic)) {\n\t\t\tdequantizeAttribute(prim.getAttribute(semantic)!);\n\t\t}\n\t}\n\n\tfor (const target of prim.listTargets()) {\n\t\tfor (const semantic of target.listSemantics()) {\n\t\t\tif (options.pattern.test(semantic)) {\n\t\t\t\tdequantizeAttribute(target.getAttribute(semantic)!);\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function dequantizeAttribute(attribute: Accessor): void {\n\tconst srcArray = attribute.getArray();\n\tif (!srcArray) return;\n\n\tconst dstArray = dequantizeAttributeArray(srcArray, attribute.getComponentType(), attribute.getNormalized());\n\n\tattribute.setArray(dstArray).setNormalized(false);\n}\n\nexport function dequantizeAttributeArray(\n\tsrcArray: TypedArray,\n\tcomponentType: GLTF.AccessorComponentType,\n\tnormalized: boolean,\n): Float32Array<ArrayBuffer> {\n\tconst dstArray = new Float32Array(srcArray.length);\n\n\tfor (let i = 0, il = srcArray.length; i < il; i++) {\n\t\tif (normalized) {\n\t\t\tdstArray[i] = MathUtils.decodeNormalizedInt(srcArray[i], componentType);\n\t\t} else {\n\t\t\tdstArray[i] = srcArray[i];\n\t\t}\n\t}\n\n\treturn dstArray;\n}\n","import {\n\tDocument,\n\ttype Extension,\n\ttype Graph,\n\ttype Property,\n\ttype PropertyResolver,\n\tPropertyType,\n} from '@gltf-transform/core';\n\nconst { TEXTURE_INFO, ROOT } = PropertyType;\ntype PropertyConstructor = new (g: Graph<Property>) => Property;\n\nconst NO_TRANSFER_TYPES = new Set<string>([TEXTURE_INFO, ROOT]);\n\n/**\n * Clones source {@link Document}, copying all properties and extensions within\n * it. Source document remains unchanged, and the two may be modified\n * independently after cloning.\n *\n * Example:\n *\n * ```javascript\n *\timport { cloneDocument } from '@gltf-transform/functions';\n *\n *\tconst targetDocument = cloneDocument(sourceDocument);\n * ```\n */\nexport function cloneDocument(source: Document): Document {\n\tconst target = new Document().setLogger(source.getLogger());\n\tconst resolve = createDefaultPropertyResolver(target, source);\n\tmergeDocuments(target, source, resolve);\n\n\t// Root properties (name, asset, default scene, extras) are not overwritten by\n\t// mergeDocuments(), and should be explicitly copied when cloning.\n\t// biome-ignore lint/suspicious/noExplicitAny: TODO\n\ttarget.getRoot().copy(source.getRoot(), resolve as any);\n\n\treturn target;\n}\n\n/**\n * Merges contents of source {@link Document} into target Document, without\n * modifying the source. Any extensions missing from the target will be added\n * {@link Scene Scenes} and {@link Buffer Buffers} are not combined —\n * the target Document may contain multiple Scenes and Buffers after this\n * operation. These may be cleaned up manually (see {@link unpartition}),\n * or document contents may be merged more granularly using\n * {@link copyToDocument}.\n *\n * Example:\n *\n * ```javascript\n *\timport { mergeDocuments, unpartition } from '@gltf-transform/functions';\n *\n *\t// Merge contents of sourceDocument into targetDocument.\n *\tmergeDocuments(targetDocument, sourceDocument);\n *\n *\t// (Optional) Remove all but one Buffer from the target Document.\n *\tawait targetDocument.transform(unpartition());\n * ```\n *\n * To merge several Scenes into one:\n *\n * ```javascript\n * import { mergeDocuments } from '@gltf-transform/functions';\n *\n * const map = mergeDocuments(targetDocument, sourceDocument);\n *\n * // Find original Scene.\n * const sceneA = targetDocument.getRoot().listScenes()[0];\n *\n * // Find counterpart of the source Scene in the target Document.\n * const sceneB = map.get(sourceDocument.getRoot().listScenes()[0]);\n *\n * // Create a Node, and append source Scene's direct children.\n * const rootNode = targetDocument.createNode()\n *\t\t.setName('SceneB')\n *\t\t.setPosition([10, 0, 0]);\n * for (const node of sceneB.listChildren()) {\n *\t\trootNode.addChild(node);\n * }\n *\n * // Append Node to original Scene, and dispose the empty Scene.\n * sceneA.addChild(rootNode);\n * sceneB.dispose();\n * ```\n */\nexport function mergeDocuments(\n\ttarget: Document,\n\tsource: Document,\n\tresolve?: PropertyResolver<Property>,\n): Map<Property, Property> {\n\tresolve ||= createDefaultPropertyResolver(target, source);\n\n\tfor (const sourceExtension of source.getRoot().listExtensionsUsed()) {\n\t\tconst targetExtension = target.createExtension(sourceExtension.constructor as new (doc: Document) => Extension);\n\t\tif (sourceExtension.isRequired()) targetExtension.setRequired(true);\n\t}\n\n\t// Root properties (name, asset, default scene, extras) are not overwritten.\n\treturn _copyToDocument(target, source, listNonRootProperties(source), resolve);\n}\n\n/**\n * Moves the specified {@link Property Properties} from the source\n * {@link Document} to the target Document, and removes them from the source.\n * Dependencies of the source properties will be copied into the\n * target, but not removed from the source. Returns a Map from source\n * properties to their counterparts in the target Document.\n *\n * Example:\n *\n * ```javascript\n *\timport { moveToDocument, prune } from '@gltf-transform/functions';\n *\n *\t// Move all materials from sourceDocument to targetDocument.\n *\tconst map = moveToDocument(targetDocument, sourceDocument, sourceDocument.listMaterials());\n *\n *\t// Find the new counterpart of `sourceMaterial` in the target Document.\n *\tconst targetMaterial = map.get(sourceMaterial);\n *\n *\t// (Optional) Remove any resources (like Textures) that may now be unused\n *\t// in the source Document after their parent Materials have been moved.\n *\tawait sourceDocument.transform(prune());\n * ```\n *\n * Moving a {@link Mesh}, {@link Animation}, or another resource depending on\n * a {@link Buffer} will create a copy of the source Buffer in the target\n * Document. If the target Document should contain only one Buffer, call\n * {@link unpartition} after moving properties.\n *\n * Repeated use of `moveToDocument` may create multiple copies of some\n * resources, particularly shared dependencies like {@link Texture Textures} or\n * {@link Accessor Accessors}. While duplicates can be cleaned up with\n * {@link dedup}, it is also possible to prevent duplicates by creating and\n * reusing the same resolver for all calls to `moveToDocument`:\n *\n * ```javascript\n *\timport { moveToDocument, createDefaultPropertyResolver } from '@gltf-transform/functions';\n *\n *\tconst resolve = createDefaultPropertyResolver(targetDocument, sourceDocument);\n *\n *\t// Move materials individually, without creating duplicates of shared textures.\n *\tmoveToDocument(targetDocument, sourceDocument, materialA, resolve);\n *\tmoveToDocument(targetDocument, sourceDocument, materialB, resolve);\n *\tmoveToDocument(targetDocument, sourceDocument, materialC, resolve);\n * ```\n *\n * If the transferred properties include {@link ExtensionProperty ExtensionProperties},\n * the associated {@link Extension Extensions} must be added to the target\n * Document first:\n *\n * ```javascript\n *\tfor (const sourceExtension of source.getRoot().listExtensionsUsed()) {\n *\t\tconst targetExtension = target.createExtension(sourceExtension.constructor);\n *\t\tif (sourceExtension.isRequired()) targetExtension.setRequired(true);\n *\t}\n * ```\n *\n * {@link Root} properties cannot be moved.\n *\n * {@link TextureInfo} properties cannot be given in the property list, but\n * are handled automatically when moving a {@link Material}.\n *\n * To copy properties without removing them from the source Document, see\n * {@link copyToDocument}.\n *\n * @experimental\n */\nexport function moveToDocument(\n\ttarget: Document,\n\tsource: Document,\n\tsourceProperties: Property[],\n\tresolve?: PropertyResolver<Property>,\n): Map<Property, Property> {\n\tconst targetProperties = copyToDocument(target, source, sourceProperties, resolve);\n\n\tfor (const property of sourceProperties) {\n\t\tproperty.dispose();\n\t}\n\n\treturn targetProperties;\n}\n\n/**\n * Copies the specified {@link Property Properties} from the source\n * {@link Document} to the target Document, leaving originals in the source.\n * Dependencies of the source properties will also be copied into the\n * target. Returns a Map from source properties to their counterparts in the\n * target Document.\n *\n * Example:\n *\n * ```javascript\n *\timport { copyToDocument } from '@gltf-transform/functions';\n *\n *\t// Copy all materials from sourceDocument to targetDocument.\n *\tconst map = copyToDocument(targetDocument, sourceDocument, sourceDocument.listMaterials());\n *\n *\t// Find the new counterpart of `sourceMaterial` in the target Document.\n *\tconst targetMaterial = map.get(sourceMaterial);\n * ```\n *\n * Copying a {@link Mesh}, {@link Animation}, or another resource depending on\n * a {@link Buffer} will create a copy of the source Buffer in the target\n * Document. If the target Document should contain only one Buffer, call\n * {@link unpartition} after copying properties.\n *\n * Repeated use of `copyToDocument` may create multiple copies of some\n * resources, particularly shared dependencies like {@link Texture Textures} or\n * {@link Accessor Accessors}. While duplicates can be cleaned up with\n * {@link dedup}, it is also possible to prevent duplicates by creating and\n * reusing the same resolver for all calls to `copyToDocument`:\n *\n * ```javascript\n *\timport { copyToDocument, createDefaultPropertyResolver } from '@gltf-transform/functions';\n *\n *\tconst resolve = createDefaultPropertyResolver(targetDocument, sourceDocument);\n *\n *\t// Copy materials individually, without creating duplicates of shared textures.\n *\tcopyToDocument(targetDocument, sourceDocument, materialA, resolve);\n *\tcopyToDocument(targetDocument, sourceDocument, materialB, resolve);\n *\tcopyToDocument(targetDocument, sourceDocument, materialC, resolve);\n * ```\n *\n * If the transferred properties include {@link ExtensionProperty ExtensionProperties},\n * the associated {@link Extension Extensions} must be added to the target\n * Document first:\n *\n * ```javascript\n *\tfor (const sourceExtension of source.getRoot().listExtensionsUsed()) {\n *\t\tconst targetExtension = target.createExtension(sourceExtension.constructor);\n *\t\tif (sourceExtension.isRequired()) targetExtension.setRequired(true);\n *\t}\n * ```\n *\n * {@link Root} properties cannot be copied.\n *\n * {@link TextureInfo} properties cannot be given in the property list, but\n * are handled automatically when copying a {@link Material}.\n *\n * To move properties to the target Document without leaving copies behind in\n * the source Document, use {@link moveToDocument} or dispose the properties\n * after copying.\n *\n * @experimental\n */\nexport function copyToDocument(\n\ttarget: Document,\n\tsource: Document,\n\tsourceProperties: Property[],\n\tresolve?: PropertyResolver<Property>,\n): Map<Property, Property> {\n\tconst sourcePropertyDependencies = new Set<Property>();\n\tfor (const property of sourceProperties) {\n\t\tif (NO_TRANSFER_TYPES.has(property.propertyType)) {\n\t\t\tthrow new Error(`Type \"${property.propertyType}\" cannot be transferred.`);\n\t\t}\n\t\tlistPropertyDependencies(property, sourcePropertyDependencies);\n\t}\n\treturn _copyToDocument(target, source, Array.from(sourcePropertyDependencies), resolve);\n}\n\n/** @internal */\nfunction _copyToDocument(\n\ttarget: Document,\n\tsource: Document,\n\tsourceProperties: Property[],\n\tresolve?: PropertyResolver<Property>,\n): Map<Property, Property> {\n\tresolve ||= createDefaultPropertyResolver(target, source);\n\n\t// Create stub classes for every Property in other Document.\n\tconst propertyMap = new Map<Property, Property>();\n\tfor (const sourceProp of sourceProperties) {\n\t\t// TextureInfo copy handled by Material or ExtensionProperty.\n\t\tif (!propertyMap.has(sourceProp) && sourceProp.propertyType !== TEXTURE_INFO) {\n\t\t\tpropertyMap.set(sourceProp, resolve(sourceProp));\n\t\t}\n\t}\n\n\t// Assemble relationships between Properties.\n\tfor (const [sourceProp, targetProp] of propertyMap.entries()) {\n\t\ttargetProp.copy(sourceProp, resolve);\n\t}\n\n\treturn propertyMap;\n}\n\n/**\n * Creates a default `resolve` implementation. May be used when moving\n * properties between {@link Document Documents} with {@link mergeDocuments},\n * {@link copyToDocument}, and {@link moveToDocument}. When the same resolver\n * is passed to multiple invocations, these functions will reuse previously-\n * transferred resources.\n *\n * @experimental\n */\nexport function createDefaultPropertyResolver(target: Document, source: Document): PropertyResolver<Property> {\n\tconst propertyMap = new Map<Property, Property>([[source.getRoot(), target.getRoot()]]);\n\n\treturn (sourceProp: Property): Property => {\n\t\t// TextureInfo lifecycle is bound to a Material or ExtensionProperty.\n\t\tif (sourceProp.propertyType === TEXTURE_INFO) return sourceProp;\n\n\t\tlet targetProp = propertyMap.get(sourceProp);\n\t\tif (!targetProp) {\n\t\t\t// Create stub class, defer copying properties.\n\t\t\tconst PropertyClass = sourceProp.constructor as PropertyConstructor;\n\t\t\ttargetProp = new PropertyClass(target.getGraph());\n\t\t\tpropertyMap.set(sourceProp, targetProp);\n\t\t}\n\n\t\treturn targetProp;\n\t};\n}\n\n/** @internal */\nfunction listPropertyDependencies(parent: Property, visited: Set<Property>): Set<Property> {\n\tconst graph = parent.getGraph();\n\tconst queue: Property[] = [parent];\n\n\tlet next: Property | undefined;\n\twhile ((next = queue.pop())) {\n\t\tvisited.add(next);\n\t\tfor (const child of graph.listChildren(next)) {\n\t\t\tif (!visited.has(child)) {\n\t\t\t\tqueue.push(child);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn visited;\n}\n\n/** @internal */\nfunction listNonRootProperties(document: Document): Property[] {\n\tconst visited = new Set<Property>();\n\tfor (const edge of document.getGraph().listEdges()) {\n\t\tvisited.add(edge.getChild());\n\t}\n\treturn Array.from(visited);\n}\n","import type { Document, Transform } from '@gltf-transform/core';\nimport { KHRDracoMeshCompression } from '@gltf-transform/extensions';\nimport { assignDefaults, createTransform } from './utils.js';\nimport { weld } from './weld.js';\n\nconst NAME = 'draco';\n\nexport interface DracoOptions {\n\tmethod?: 'edgebreaker' | 'sequential';\n\tencodeSpeed?: number;\n\tdecodeSpeed?: number;\n\tquantizePosition?: number;\n\tquantizeNormal?: number;\n\tquantizeColor?: number;\n\tquantizeTexcoord?: number;\n\tquantizeGeneric?: number;\n\tquantizationVolume?: 'mesh' | 'scene';\n}\n\nexport const DRACO_DEFAULTS: Required<DracoOptions> = {\n\tmethod: 'edgebreaker',\n\tencodeSpeed: 5,\n\tdecodeSpeed: 5,\n\tquantizePosition: 14,\n\tquantizeNormal: 10,\n\tquantizeColor: 8,\n\tquantizeTexcoord: 12,\n\tquantizeGeneric: 12,\n\tquantizationVolume: 'mesh',\n};\n\n/**\n * Applies Draco compression using {@link KHRDracoMeshCompression KHR_draco_mesh_compression}.\n * Draco compression can reduce the size of triangle geometry.\n *\n * This function is a thin wrapper around the {@link KHRDracoMeshCompression} extension.\n *\n * ### Example\n *\n * ```typescript\n * import { NodeIO } from '@gltf-transform/core';\n * import { KHRDracoMeshCompression } from '@gltf-transform/extensions';\n * import { draco } from '@gltf-transform/functions';\n * import draco3d from 'draco3dgltf';\n *\n * const io = new NodeIO()\n * \t.registerExtensions([KHRDracoMeshCompression])\n * \t.registerDependencies({\n * \t\t'draco3d.encoder': await draco3d.createEncoderModule()\n * \t});\n *\n * await document.transform(\n *   draco({method: 'edgebreaker'})\n * );\n *\n * await io.write('compressed.glb', document);\n * ```\n *\n * Compression is deferred until generating output with an I/O class.\n *\n * @category Transforms\n */\nexport function draco(_options: DracoOptions = DRACO_DEFAULTS): Transform {\n\tconst options = assignDefaults(DRACO_DEFAULTS, _options);\n\n\treturn createTransform(NAME, async (document: Document): Promise<void> => {\n\t\tawait document.transform(weld());\n\t\tdocument\n\t\t\t.createExtension(KHRDracoMeshCompression)\n\t\t\t.setRequired(true)\n\t\t\t.setEncoderOptions({\n\t\t\t\tmethod:\n\t\t\t\t\toptions.method === 'edgebreaker'\n\t\t\t\t\t\t? KHRDracoMeshCompression.EncoderMethod.EDGEBREAKER\n\t\t\t\t\t\t: KHRDracoMeshCompression.EncoderMethod.SEQUENTIAL,\n\t\t\t\tencodeSpeed: options.encodeSpeed,\n\t\t\t\tdecodeSpeed: options.decodeSpeed,\n\t\t\t\tquantizationBits: {\n\t\t\t\t\tPOSITION: options.quantizePosition,\n\t\t\t\t\tNORMAL: options.quantizeNormal,\n\t\t\t\t\tCOLOR: options.quantizeColor,\n\t\t\t\t\tTEX_COORD: options.quantizeTexcoord,\n\t\t\t\t\tGENERIC: options.quantizeGeneric,\n\t\t\t\t},\n\t\t\t\tquantizationVolume: options.quantizationVolume,\n\t\t\t});\n\t});\n}\n","import * as glMatrix from \"./common.js\";\n\n/**\n * 4 Dimensional Vector\n * @module vec4\n */\n\n/**\n * Creates a new, empty vec4\n *\n * @returns {vec4} a new 4D vector\n */\nexport function create() {\n  var out = new glMatrix.ARRAY_TYPE(4);\n  if (glMatrix.ARRAY_TYPE != Float32Array) {\n    out[0] = 0;\n    out[1] = 0;\n    out[2] = 0;\n    out[3] = 0;\n  }\n  return out;\n}\n\n/**\n * Creates a new vec4 initialized with values from an existing vector\n *\n * @param {ReadonlyVec4} a vector to clone\n * @returns {vec4} a new 4D vector\n */\nexport function clone(a) {\n  var out = new glMatrix.ARRAY_TYPE(4);\n  out[0] = a[0];\n  out[1] = a[1];\n  out[2] = a[2];\n  out[3] = a[3];\n  return out;\n}\n\n/**\n * Creates a new vec4 initialized with the given values\n *\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @param {Number} w W component\n * @returns {vec4} a new 4D vector\n */\nexport function fromValues(x, y, z, w) {\n  var out = new glMatrix.ARRAY_TYPE(4);\n  out[0] = x;\n  out[1] = y;\n  out[2] = z;\n  out[3] = w;\n  return out;\n}\n\n/**\n * Copy the values from one vec4 to another\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the source vector\n * @returns {vec4} out\n */\nexport function copy(out, a) {\n  out[0] = a[0];\n  out[1] = a[1];\n  out[2] = a[2];\n  out[3] = a[3];\n  return out;\n}\n\n/**\n * Set the components of a vec4 to the given values\n *\n * @param {vec4} out the receiving vector\n * @param {Number} x X component\n * @param {Number} y Y component\n * @param {Number} z Z component\n * @param {Number} w W component\n * @returns {vec4} out\n */\nexport function set(out, x, y, z, w) {\n  out[0] = x;\n  out[1] = y;\n  out[2] = z;\n  out[3] = w;\n  return out;\n}\n\n/**\n * Adds two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\nexport function add(out, a, b) {\n  out[0] = a[0] + b[0];\n  out[1] = a[1] + b[1];\n  out[2] = a[2] + b[2];\n  out[3] = a[3] + b[3];\n  return out;\n}\n\n/**\n * Subtracts vector b from vector a\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\nexport function subtract(out, a, b) {\n  out[0] = a[0] - b[0];\n  out[1] = a[1] - b[1];\n  out[2] = a[2] - b[2];\n  out[3] = a[3] - b[3];\n  return out;\n}\n\n/**\n * Multiplies two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\nexport function multiply(out, a, b) {\n  out[0] = a[0] * b[0];\n  out[1] = a[1] * b[1];\n  out[2] = a[2] * b[2];\n  out[3] = a[3] * b[3];\n  return out;\n}\n\n/**\n * Divides two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\nexport function divide(out, a, b) {\n  out[0] = a[0] / b[0];\n  out[1] = a[1] / b[1];\n  out[2] = a[2] / b[2];\n  out[3] = a[3] / b[3];\n  return out;\n}\n\n/**\n * Math.ceil the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to ceil\n * @returns {vec4} out\n */\nexport function ceil(out, a) {\n  out[0] = Math.ceil(a[0]);\n  out[1] = Math.ceil(a[1]);\n  out[2] = Math.ceil(a[2]);\n  out[3] = Math.ceil(a[3]);\n  return out;\n}\n\n/**\n * Math.floor the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to floor\n * @returns {vec4} out\n */\nexport function floor(out, a) {\n  out[0] = Math.floor(a[0]);\n  out[1] = Math.floor(a[1]);\n  out[2] = Math.floor(a[2]);\n  out[3] = Math.floor(a[3]);\n  return out;\n}\n\n/**\n * Returns the minimum of two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\nexport function min(out, a, b) {\n  out[0] = Math.min(a[0], b[0]);\n  out[1] = Math.min(a[1], b[1]);\n  out[2] = Math.min(a[2], b[2]);\n  out[3] = Math.min(a[3], b[3]);\n  return out;\n}\n\n/**\n * Returns the maximum of two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {vec4} out\n */\nexport function max(out, a, b) {\n  out[0] = Math.max(a[0], b[0]);\n  out[1] = Math.max(a[1], b[1]);\n  out[2] = Math.max(a[2], b[2]);\n  out[3] = Math.max(a[3], b[3]);\n  return out;\n}\n\n/**\n * symmetric round the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to round\n * @returns {vec4} out\n */\nexport function round(out, a) {\n  out[0] = glMatrix.round(a[0]);\n  out[1] = glMatrix.round(a[1]);\n  out[2] = glMatrix.round(a[2]);\n  out[3] = glMatrix.round(a[3]);\n  return out;\n}\n\n/**\n * Scales a vec4 by a scalar number\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the vector to scale\n * @param {Number} b amount to scale the vector by\n * @returns {vec4} out\n */\nexport function scale(out, a, b) {\n  out[0] = a[0] * b;\n  out[1] = a[1] * b;\n  out[2] = a[2] * b;\n  out[3] = a[3] * b;\n  return out;\n}\n\n/**\n * Adds two vec4's after scaling the second operand by a scalar value\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @param {Number} scale the amount to scale b by before adding\n * @returns {vec4} out\n */\nexport function scaleAndAdd(out, a, b, scale) {\n  out[0] = a[0] + b[0] * scale;\n  out[1] = a[1] + b[1] * scale;\n  out[2] = a[2] + b[2] * scale;\n  out[3] = a[3] + b[3] * scale;\n  return out;\n}\n\n/**\n * Calculates the euclidian distance between two vec4's\n *\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {Number} distance between a and b\n */\nexport function distance(a, b) {\n  var x = b[0] - a[0];\n  var y = b[1] - a[1];\n  var z = b[2] - a[2];\n  var w = b[3] - a[3];\n  return Math.sqrt(x * x + y * y + z * z + w * w);\n}\n\n/**\n * Calculates the squared euclidian distance between two vec4's\n *\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {Number} squared distance between a and b\n */\nexport function squaredDistance(a, b) {\n  var x = b[0] - a[0];\n  var y = b[1] - a[1];\n  var z = b[2] - a[2];\n  var w = b[3] - a[3];\n  return x * x + y * y + z * z + w * w;\n}\n\n/**\n * Calculates the length of a vec4\n *\n * @param {ReadonlyVec4} a vector to calculate length of\n * @returns {Number} length of a\n */\nexport function length(a) {\n  var x = a[0];\n  var y = a[1];\n  var z = a[2];\n  var w = a[3];\n  return Math.sqrt(x * x + y * y + z * z + w * w);\n}\n\n/**\n * Calculates the squared length of a vec4\n *\n * @param {ReadonlyVec4} a vector to calculate squared length of\n * @returns {Number} squared length of a\n */\nexport function squaredLength(a) {\n  var x = a[0];\n  var y = a[1];\n  var z = a[2];\n  var w = a[3];\n  return x * x + y * y + z * z + w * w;\n}\n\n/**\n * Negates the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to negate\n * @returns {vec4} out\n */\nexport function negate(out, a) {\n  out[0] = -a[0];\n  out[1] = -a[1];\n  out[2] = -a[2];\n  out[3] = -a[3];\n  return out;\n}\n\n/**\n * Returns the inverse of the components of a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to invert\n * @returns {vec4} out\n */\nexport function inverse(out, a) {\n  out[0] = 1.0 / a[0];\n  out[1] = 1.0 / a[1];\n  out[2] = 1.0 / a[2];\n  out[3] = 1.0 / a[3];\n  return out;\n}\n\n/**\n * Normalize a vec4\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a vector to normalize\n * @returns {vec4} out\n */\nexport function normalize(out, a) {\n  var x = a[0];\n  var y = a[1];\n  var z = a[2];\n  var w = a[3];\n  var len = x * x + y * y + z * z + w * w;\n  if (len > 0) {\n    len = 1 / Math.sqrt(len);\n  }\n  out[0] = x * len;\n  out[1] = y * len;\n  out[2] = z * len;\n  out[3] = w * len;\n  return out;\n}\n\n/**\n * Calculates the dot product of two vec4's\n *\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @returns {Number} dot product of a and b\n */\nexport function dot(a, b) {\n  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];\n}\n\n/**\n * Returns the cross-product of three vectors in a 4-dimensional space\n *\n * @param {ReadonlyVec4} out the receiving vector\n * @param {ReadonlyVec4} u the first vector\n * @param {ReadonlyVec4} v the second vector\n * @param {ReadonlyVec4} w the third vector\n * @returns {vec4} result\n */\nexport function cross(out, u, v, w) {\n  var A = v[0] * w[1] - v[1] * w[0],\n    B = v[0] * w[2] - v[2] * w[0],\n    C = v[0] * w[3] - v[3] * w[0],\n    D = v[1] * w[2] - v[2] * w[1],\n    E = v[1] * w[3] - v[3] * w[1],\n    F = v[2] * w[3] - v[3] * w[2];\n  var G = u[0];\n  var H = u[1];\n  var I = u[2];\n  var J = u[3];\n  out[0] = H * F - I * E + J * D;\n  out[1] = -(G * F) + I * C - J * B;\n  out[2] = G * E - H * C + J * A;\n  out[3] = -(G * D) + H * B - I * A;\n  return out;\n}\n\n/**\n * Performs a linear interpolation between two vec4's\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the first operand\n * @param {ReadonlyVec4} b the second operand\n * @param {Number} t interpolation amount, in the range [0-1], between the two inputs\n * @returns {vec4} out\n */\nexport function lerp(out, a, b, t) {\n  var ax = a[0];\n  var ay = a[1];\n  var az = a[2];\n  var aw = a[3];\n  out[0] = ax + t * (b[0] - ax);\n  out[1] = ay + t * (b[1] - ay);\n  out[2] = az + t * (b[2] - az);\n  out[3] = aw + t * (b[3] - aw);\n  return out;\n}\n\n/**\n * Generates a random vector with the given scale\n *\n * @param {vec4} out the receiving vector\n * @param {Number} [scale] Length of the resulting vector. If omitted, a unit vector will be returned\n * @returns {vec4} out\n */\nexport function random(out, scale) {\n  scale = scale === undefined ? 1.0 : scale;\n\n  // Marsaglia, George. Choosing a Point from the Surface of a\n  // Sphere. Ann. Math. Statist. 43 (1972), no. 2, 645--646.\n  // http://projecteuclid.org/euclid.aoms/1177692644;\n  var v1, v2, v3, v4;\n  var s1, s2;\n  var rand;\n  rand = glMatrix.RANDOM();\n  v1 = rand * 2 - 1;\n  v2 = (4 * glMatrix.RANDOM() - 2) * Math.sqrt(rand * -rand + rand);\n  s1 = v1 * v1 + v2 * v2;\n  rand = glMatrix.RANDOM();\n  v3 = rand * 2 - 1;\n  v4 = (4 * glMatrix.RANDOM() - 2) * Math.sqrt(rand * -rand + rand);\n  s2 = v3 * v3 + v4 * v4;\n  var d = Math.sqrt((1 - s1) / s2);\n  out[0] = scale * v1;\n  out[1] = scale * v2;\n  out[2] = scale * v3 * d;\n  out[3] = scale * v4 * d;\n  return out;\n}\n\n/**\n * Transforms the vec4 with a mat4.\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the vector to transform\n * @param {ReadonlyMat4} m matrix to transform with\n * @returns {vec4} out\n */\nexport function transformMat4(out, a, m) {\n  var x = a[0],\n    y = a[1],\n    z = a[2],\n    w = a[3];\n  out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w;\n  out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w;\n  out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;\n  out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;\n  return out;\n}\n\n/**\n * Transforms the vec4 with a quat\n *\n * @param {vec4} out the receiving vector\n * @param {ReadonlyVec4} a the vector to transform\n * @param {ReadonlyQuat} q normalized quaternion to transform with\n * @returns {vec4} out\n */\nexport function transformQuat(out, a, q) {\n  // Fast Vector Rotation using Quaternions by Robert Eisele\n  // https://raw.org/proof/vector-rotation-using-quaternions/\n\n  var qx = q[0],\n    qy = q[1],\n    qz = q[2],\n    qw = q[3];\n  var vx = a[0],\n    vy = a[1],\n    vz = a[2];\n\n  // t = q x v\n  var tx = qy * vz - qz * vy;\n  var ty = qz * vx - qx * vz;\n  var tz = qx * vy - qy * vx;\n\n  // t = 2t\n  tx = tx + tx;\n  ty = ty + ty;\n  tz = tz + tz;\n\n  // v + w t + q x t\n  out[0] = vx + qw * tx + qy * tz - qz * ty;\n  out[1] = vy + qw * ty + qz * tx - qx * tz;\n  out[2] = vz + qw * tz + qx * ty - qy * tx;\n  out[3] = a[3];\n  return out;\n}\n\n/**\n * Set the components of a vec4 to zero\n *\n * @param {vec4} out the receiving vector\n * @returns {vec4} out\n */\nexport function zero(out) {\n  out[0] = 0.0;\n  out[1] = 0.0;\n  out[2] = 0.0;\n  out[3] = 0.0;\n  return out;\n}\n\n/**\n * Returns a string representation of a vector\n *\n * @param {ReadonlyVec4} a vector to represent as a string\n * @returns {String} string representation of the vector\n */\nexport function str(a) {\n  return \"vec4(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \", \" + a[3] + \")\";\n}\n\n/**\n * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)\n *\n * @param {ReadonlyVec4} a The first vector.\n * @param {ReadonlyVec4} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\nexport function exactEquals(a, b) {\n  return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];\n}\n\n/**\n * Returns whether or not the vectors have approximately the same elements in the same position.\n *\n * @param {ReadonlyVec4} a The first vector.\n * @param {ReadonlyVec4} b The second vector.\n * @returns {Boolean} True if the vectors are equal, false otherwise.\n */\nexport function equals(a, b) {\n  var a0 = a[0],\n    a1 = a[1],\n    a2 = a[2],\n    a3 = a[3];\n  var b0 = b[0],\n    b1 = b[1],\n    b2 = b[2],\n    b3 = b[3];\n  return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3));\n}\n\n/**\n * Alias for {@link vec4.subtract}\n * @function\n */\nexport var sub = subtract;\n\n/**\n * Alias for {@link vec4.multiply}\n * @function\n */\nexport var mul = multiply;\n\n/**\n * Alias for {@link vec4.divide}\n * @function\n */\nexport var div = divide;\n\n/**\n * Alias for {@link vec4.distance}\n * @function\n */\nexport var dist = distance;\n\n/**\n * Alias for {@link vec4.squaredDistance}\n * @function\n */\nexport var sqrDist = squaredDistance;\n\n/**\n * Alias for {@link vec4.length}\n * @function\n */\nexport var len = length;\n\n/**\n * Alias for {@link vec4.squaredLength}\n * @function\n */\nexport var sqrLen = squaredLength;\n\n/**\n * Perform some operation over an array of vec4s.\n *\n * @param {Array} a the array of vectors to iterate over\n * @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed\n * @param {Number} offset Number of elements to skip at the beginning of the array\n * @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array\n * @param {Function} fn Function to call for each vector in the array\n * @param {Object} [arg] additional argument to pass to fn\n * @returns {Array} a\n * @function\n */\nexport var forEach = function () {\n  var vec = create();\n  return function (a, stride, offset, count, fn, arg) {\n    var i, l;\n    if (!stride) {\n      stride = 4;\n    }\n    if (!offset) {\n      offset = 0;\n    }\n    if (count) {\n      l = Math.min(count * stride + offset, a.length);\n    } else {\n      l = a.length;\n    }\n    for (i = offset; i < l; i += stride) {\n      vec[0] = a[i];\n      vec[1] = a[i + 1];\n      vec[2] = a[i + 2];\n      vec[3] = a[i + 3];\n      fn(vec, vec, arg);\n      a[i] = vec[0];\n      a[i + 1] = vec[1];\n      a[i + 2] = vec[2];\n      a[i + 3] = vec[3];\n    }\n    return a;\n  };\n}();","import type { Texture } from '@gltf-transform/core';\n\nconst SRGB_PATTERN = /color|emissive|diffuse/i;\n\n/**\n * Returns the color space (if any) implied by the {@link Material} slots to\n * which a texture is assigned, or null for non-color textures. If the texture\n * is not connected to any {@link Material}, this function will also return\n * null — any metadata in the image file will be ignored.\n *\n * Under current glTF specifications, only 'srgb' and non-color (null) textures\n * are used.\n *\n * Example:\n *\n * ```typescript\n * import { getTextureColorSpace } from '@gltf-transform/functions';\n *\n * const baseColorTexture = material.getBaseColorTexture();\n * const normalTexture = material.getNormalTexture();\n *\n * getTextureColorSpace(baseColorTexture); // → 'srgb'\n * getTextureColorSpace(normalTexture); // → null\n * ```\n */\nexport function getTextureColorSpace(texture: Texture): 'srgb' | null {\n\tconst graph = texture.getGraph();\n\tconst edges = graph.listParentEdges(texture);\n\tconst isSRGB = edges.some((edge) => {\n\t\treturn edge.getAttributes().isColor || SRGB_PATTERN.test(edge.getName());\n\t});\n\treturn isSRGB ? 'srgb' : null;\n}\n","import { ExtensionProperty, type Material, type Property, Texture, TextureInfo } from '@gltf-transform/core';\n\n/**\n * Lists all {@link TextureInfo} definitions associated with a given\n * {@link Texture}. May be used to determine which UV transforms\n * and texCoord indices are applied to the material, without explicitly\n * checking the material properties and extensions.\n *\n * Example:\n *\n * ```typescript\n * // Find TextureInfo instances associated with the texture.\n * const results = listTextureInfo(texture);\n *\n * // Find which UV sets (TEXCOORD_0, TEXCOORD_1, ...) are required.\n * const texCoords = results.map((info) => info.getTexCoord());\n * // → [0, 1]\n * ```\n */\nexport function listTextureInfo(texture: Texture): TextureInfo[] {\n\tconst graph = texture.getGraph();\n\tconst results = new Set<TextureInfo>();\n\n\tfor (const textureEdge of graph.listParentEdges(texture)) {\n\t\tconst parent = textureEdge.getParent();\n\t\tconst name = textureEdge.getName() + 'Info';\n\n\t\tfor (const edge of graph.listChildEdges(parent)) {\n\t\t\tconst child = edge.getChild();\n\t\t\tif (child instanceof TextureInfo && edge.getName() === name) {\n\t\t\t\tresults.add(child);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn Array.from(results);\n}\n\n/**\n * Lists all {@link TextureInfo} definitions associated with any {@link Texture}\n * on the given {@link Material}. May be used to determine which UV transforms\n * and texCoord indices are applied to the material, without explicitly\n * checking the material properties and extensions.\n *\n * Example:\n *\n * ```typescript\n * const results = listTextureInfoByMaterial(material);\n *\n * const texCoords = results.map((info) => info.getTexCoord());\n * // → [0, 1]\n * ```\n */\nexport function listTextureInfoByMaterial(material: Material): TextureInfo[] {\n\tconst graph = material.getGraph();\n\tconst visited = new Set<Property>();\n\tconst results = new Set<TextureInfo>();\n\n\tfunction traverse(prop: Material | ExtensionProperty) {\n\t\tconst textureInfoNames = new Set<string>();\n\n\t\tfor (const edge of graph.listChildEdges(prop)) {\n\t\t\tif (edge.getChild() instanceof Texture) {\n\t\t\t\ttextureInfoNames.add(edge.getName() + 'Info');\n\t\t\t}\n\t\t}\n\n\t\tfor (const edge of graph.listChildEdges(prop)) {\n\t\t\tconst child = edge.getChild();\n\t\t\tif (visited.has(child)) continue;\n\t\t\tvisited.add(child);\n\n\t\t\tif (child instanceof TextureInfo && textureInfoNames.has(edge.getName())) {\n\t\t\t\tresults.add(child);\n\t\t\t} else if (child instanceof ExtensionProperty) {\n\t\t\t\ttraverse(child);\n\t\t\t}\n\t\t}\n\t}\n\n\ttraverse(material);\n\treturn Array.from(results);\n}\n","import { Document, type Texture } from '@gltf-transform/core';\n\n/**\n * Returns names of all texture slots using the given texture.\n *\n * Example:\n *\n * ```js\n * const slots = listTextureSlots(texture);\n * // → ['occlusionTexture', 'metallicRoughnessTexture']\n * ```\n */\nexport function listTextureSlots(texture: Texture): string[] {\n\tconst document = Document.fromGraph(texture.getGraph())!;\n\tconst root = document.getRoot();\n\tconst slots = texture\n\t\t.getGraph()\n\t\t.listParentEdges(texture)\n\t\t.filter((edge) => edge.getParent() !== root)\n\t\t.map((edge) => edge.getName());\n\treturn Array.from(new Set(slots));\n}\n","import {\n\tAnimationChannel,\n\tColorUtils,\n\ttype Document,\n\tExtensionProperty,\n\ttype Graph,\n\ttype ILogger,\n\tMaterial,\n\ttype Node,\n\tPrimitive,\n\ttype PrimitiveTarget,\n\ttype Property,\n\tPropertyType,\n\tRoot,\n\tScene,\n\tTexture,\n\tTextureInfo,\n\ttype Transform,\n\ttype vec3,\n\ttype vec4,\n} from '@gltf-transform/core';\nimport { mul as mulVec3 } from 'gl-matrix/vec3';\nimport { add, create, len, mul, scale, sub } from 'gl-matrix/vec4';\nimport type { NdArray } from 'ndarray';\nimport { getPixels } from 'ndarray-pixels';\nimport { getTextureColorSpace } from './get-texture-color-space.js';\nimport { listTextureInfoByMaterial } from './list-texture-info.js';\nimport { listTextureSlots } from './list-texture-slots.js';\nimport { assignDefaults, createTransform, isEmptyObject } from './utils.js';\n\nconst NAME = 'prune';\n\nconst EPS = 3 / 255;\n\nexport interface PruneOptions {\n\t/** List of {@link PropertyType} identifiers to be de-duplicated.*/\n\tpropertyTypes?: string[];\n\t/** Whether to keep empty leaf nodes. */\n\tkeepLeaves?: boolean;\n\t/** Whether to keep unused vertex attributes, such as UVs without an assigned texture. */\n\tkeepAttributes?: boolean;\n\t/**\n\t * Whether to keep redundant mesh indices, where vertex count equals index count.\n\t * @deprecated Disabled. To remove indices, use {@link unweld} or other APIs.\n\t * @privateRemarks TODO(v5): Remove this option.\n\t */\n\tkeepIndices?: boolean;\n\t/** Whether to keep single-color textures that can be converted to material factors. */\n\tkeepSolidTextures?: boolean;\n\t/** Whether custom extras should prevent pruning a property. */\n\tkeepExtras?: boolean;\n}\n\nexport const PRUNE_DEFAULTS: Required<PruneOptions> = {\n\tpropertyTypes: [\n\t\tPropertyType.NODE,\n\t\tPropertyType.SKIN,\n\t\tPropertyType.MESH,\n\t\tPropertyType.CAMERA,\n\t\tPropertyType.PRIMITIVE,\n\t\tPropertyType.PRIMITIVE_TARGET,\n\t\tPropertyType.ANIMATION,\n\t\tPropertyType.MATERIAL,\n\t\tPropertyType.TEXTURE,\n\t\tPropertyType.ACCESSOR,\n\t\tPropertyType.BUFFER,\n\t],\n\tkeepLeaves: false,\n\tkeepAttributes: false,\n\tkeepIndices: false,\n\tkeepSolidTextures: false,\n\tkeepExtras: false,\n};\n\n/**\n * Removes properties from the file if they are not referenced by a {@link Scene}. Commonly helpful\n * for cleaning up after other operations, e.g. allowing a node to be detached and any unused\n * meshes, materials, or other resources to be removed automatically.\n *\n * Example:\n *\n * ```javascript\n * import { PropertyType } from '@gltf-transform/core';\n * import { prune } from '@gltf-transform/functions';\n *\n * document.getRoot().listMaterials(); // → [Material, Material]\n *\n * await document.transform(\n * \tprune({\n * \t\tpropertyTypes: [PropertyType.MATERIAL],\n * \t\tkeepExtras: true\n * \t})\n * );\n *\n * document.getRoot().listMaterials(); // → [Material]\n * ```\n *\n * By default, pruning will aggressively remove most unused resources. Use\n * {@link PruneOptions} to limit what is considered for pruning.\n *\n * @category Transforms\n */\nexport function prune(_options: PruneOptions = PRUNE_DEFAULTS): Transform {\n\tconst options = assignDefaults(PRUNE_DEFAULTS, _options);\n\tconst propertyTypes = new Set(options.propertyTypes);\n\tconst keepExtras = options.keepExtras;\n\n\treturn createTransform(NAME, async (document: Document): Promise<void> => {\n\t\tconst logger = document.getLogger();\n\t\tconst root = document.getRoot();\n\t\tconst graph = document.getGraph();\n\n\t\tconst counter = new DisposeCounter();\n\n\t\tconst onDispose = (event: { target: Property }) => counter.dispose(event.target);\n\t\t// TODO(cleanup): Publish GraphEvent / GraphEventListener types from 'property-graph'.\n\t\t// biome-ignore lint/suspicious/noExplicitAny: TODO\n\t\tgraph.addEventListener('node:dispose', onDispose as any);\n\n\t\t// Prune top-down, so that low-level properties like accessors can be removed if the\n\t\t// properties referencing them are removed.\n\n\t\t// Prune empty Meshes.\n\t\tif (propertyTypes.has(PropertyType.MESH)) {\n\t\t\tfor (const mesh of root.listMeshes()) {\n\t\t\t\tif (mesh.listPrimitives().length > 0) continue;\n\t\t\t\tmesh.dispose();\n\t\t\t}\n\t\t}\n\n\t\tif (propertyTypes.has(PropertyType.NODE)) {\n\t\t\tif (!options.keepLeaves) {\n\t\t\t\tfor (const scene of root.listScenes()) {\n\t\t\t\t\tnodeTreeShake(graph, scene, keepExtras);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const node of root.listNodes()) {\n\t\t\t\ttreeShake(node, keepExtras);\n\t\t\t}\n\t\t}\n\n\t\tif (propertyTypes.has(PropertyType.SKIN)) {\n\t\t\tfor (const skin of root.listSkins()) {\n\t\t\t\ttreeShake(skin, keepExtras);\n\t\t\t}\n\t\t}\n\n\t\tif (propertyTypes.has(PropertyType.MESH)) {\n\t\t\tfor (const mesh of root.listMeshes()) {\n\t\t\t\ttreeShake(mesh, keepExtras);\n\t\t\t}\n\t\t}\n\n\t\tif (propertyTypes.has(PropertyType.CAMERA)) {\n\t\t\tfor (const camera of root.listCameras()) {\n\t\t\t\ttreeShake(camera, keepExtras);\n\t\t\t}\n\t\t}\n\n\t\tif (propertyTypes.has(PropertyType.PRIMITIVE)) {\n\t\t\tindirectTreeShake(graph, PropertyType.PRIMITIVE, keepExtras);\n\t\t}\n\n\t\tif (propertyTypes.has(PropertyType.PRIMITIVE_TARGET)) {\n\t\t\tindirectTreeShake(graph, PropertyType.PRIMITIVE_TARGET, keepExtras);\n\t\t}\n\n\t\t// Prune unused vertex attributes.\n\t\tif (!options.keepAttributes && propertyTypes.has(PropertyType.ACCESSOR)) {\n\t\t\tconst materialPrims = new Map<Material, Set<Primitive>>();\n\t\t\tfor (const mesh of root.listMeshes()) {\n\t\t\t\tfor (const prim of mesh.listPrimitives()) {\n\t\t\t\t\tconst material = prim.getMaterial();\n\t\t\t\t\tif (!material) continue;\n\n\t\t\t\t\tconst required = listRequiredSemantics(document, prim, material);\n\t\t\t\t\tconst unused = listUnusedSemantics(prim, required);\n\t\t\t\t\tpruneAttributes(prim, unused);\n\t\t\t\t\tprim.listTargets().forEach((target) => pruneAttributes(target, unused));\n\t\t\t\t\tmaterialPrims.has(material)\n\t\t\t\t\t\t? materialPrims.get(material)!.add(prim)\n\t\t\t\t\t\t: materialPrims.set(material, new Set([prim]));\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const [material, prims] of materialPrims) {\n\t\t\t\tshiftTexCoords(material, Array.from(prims));\n\t\t\t}\n\t\t}\n\n\t\t// Pruning animations is a bit more complicated:\n\t\t// (1) Remove channels without target nodes.\n\t\t// (2) Remove animations without channels.\n\t\t// (3) Remove samplers orphaned in the process.\n\t\tif (propertyTypes.has(PropertyType.ANIMATION)) {\n\t\t\tfor (const anim of root.listAnimations()) {\n\t\t\t\tfor (const channel of anim.listChannels()) {\n\t\t\t\t\tif (!channel.getTargetNode()) {\n\t\t\t\t\t\tchannel.dispose();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!anim.listChannels().length) {\n\t\t\t\t\tconst samplers = anim.listSamplers();\n\t\t\t\t\ttreeShake(anim, keepExtras);\n\t\t\t\t\tsamplers.forEach((sampler) => treeShake(sampler, keepExtras));\n\t\t\t\t} else {\n\t\t\t\t\tanim.listSamplers().forEach((sampler) => treeShake(sampler, keepExtras));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (propertyTypes.has(PropertyType.MATERIAL)) {\n\t\t\troot.listMaterials().forEach((material) => treeShake(material, keepExtras));\n\t\t}\n\n\t\tif (propertyTypes.has(PropertyType.TEXTURE)) {\n\t\t\troot.listTextures().forEach((texture) => treeShake(texture, keepExtras));\n\t\t\tif (!options.keepSolidTextures) {\n\t\t\t\tawait pruneSolidTextures(document);\n\t\t\t}\n\t\t}\n\n\t\tif (propertyTypes.has(PropertyType.ACCESSOR)) {\n\t\t\troot.listAccessors().forEach((accessor) => treeShake(accessor, keepExtras));\n\t\t}\n\n\t\tif (propertyTypes.has(PropertyType.BUFFER)) {\n\t\t\troot.listBuffers().forEach((buffer) => treeShake(buffer, keepExtras));\n\t\t}\n\n\t\t// TODO(bug): This process does not identify unused ExtensionProperty instances. That could\n\t\t// be a future enhancement, either tracking unlinked properties as if they were connected\n\t\t// to the Graph, or iterating over a property list provided by the Extension. Properties in\n\t\t// use by an Extension are correctly preserved, in the meantime.\n\n\t\t// TODO(cleanup): Publish GraphEvent / GraphEventListener types from 'property-graph'.\n\t\t// biome-ignore lint/suspicious/noExplicitAny: TODO\n\t\tgraph.removeEventListener('node:dispose', onDispose as any);\n\n\t\tif (!counter.empty()) {\n\t\t\tconst str = counter\n\t\t\t\t.entries()\n\t\t\t\t.map(([type, count]) => `${type} (${count})`)\n\t\t\t\t.join(', ');\n\t\t\tlogger.info(`${NAME}: Removed types... ${str}`);\n\t\t} else {\n\t\t\tlogger.debug(`${NAME}: No unused properties found.`);\n\t\t}\n\n\t\tlogger.debug(`${NAME}: Complete.`);\n\t});\n}\n\n/**********************************************************************************************\n * Utility for disposing properties and reporting statistics afterward.\n */\n\nclass DisposeCounter {\n\tpublic readonly disposed: Record<string, number> = {};\n\n\tempty(): boolean {\n\t\tfor (const _key in this.disposed) return false;\n\t\treturn true;\n\t}\n\n\tentries(): [string, number][] {\n\t\treturn Object.entries(this.disposed);\n\t}\n\n\t/** Records properties disposed by type. */\n\tdispose(prop: Property): void {\n\t\tthis.disposed[prop.propertyType] = this.disposed[prop.propertyType] || 0;\n\t\tthis.disposed[prop.propertyType]++;\n\t}\n}\n\n/**********************************************************************************************\n * Helper functions for the {@link prune} transform.\n *\n * IMPORTANT: These functions were previously declared in function scope, but\n * broke in the CommonJS build due to a buggy Babel transform. See:\n * https://github.com/donmccurdy/glTF-Transform/issues/1140\n */\n\n/** Disposes of the given property if it is unused. */\nfunction treeShake(prop: Property, keepExtras: boolean): void {\n\t// Consider a property unused if it has no references from another property, excluding\n\t// types Root and AnimationChannel.\n\tconst parents = prop.listParents().filter((p) => !(p instanceof Root || p instanceof AnimationChannel));\n\tconst needsExtras = keepExtras && !isEmptyObject(prop.getExtras());\n\tif (!parents.length && !needsExtras) {\n\t\tprop.dispose();\n\t}\n}\n\n/**\n * For property types the Root does not maintain references to, we'll need to search the\n * graph. It's possible that objects may have been constructed without any outbound links,\n * but since they're not on the graph they don't need to be tree-shaken.\n */\nfunction indirectTreeShake(graph: Graph<Property>, propertyType: string, keepExtras: boolean): void {\n\tfor (const edge of graph.listEdges()) {\n\t\tconst parent = edge.getParent();\n\t\tif (parent.propertyType === propertyType) {\n\t\t\ttreeShake(parent, keepExtras);\n\t\t}\n\t}\n}\n\n/** Iteratively prunes leaf Nodes without contents. */\nfunction nodeTreeShake(graph: Graph<Property>, prop: Node | Scene, keepExtras: boolean): void {\n\tprop.listChildren().forEach((child) => nodeTreeShake(graph, child, keepExtras));\n\n\tif (prop instanceof Scene) return;\n\n\tconst isUsed = graph.listParentEdges(prop).some((e) => {\n\t\tconst ptype = e.getParent().propertyType;\n\t\treturn ptype !== PropertyType.ROOT && ptype !== PropertyType.SCENE && ptype !== PropertyType.NODE;\n\t});\n\tconst isEmpty = graph.listChildren(prop).length === 0;\n\tconst needsExtras = keepExtras && !isEmptyObject(prop.getExtras());\n\tif (isEmpty && !isUsed && !needsExtras) {\n\t\tprop.dispose();\n\t}\n}\n\nfunction pruneAttributes(prim: Primitive | PrimitiveTarget, unused: string[]) {\n\tfor (const semantic of unused) {\n\t\tprim.setAttribute(semantic, null);\n\t}\n}\n\n/**\n * Lists vertex attribute semantics that are unused when rendering a given primitive.\n */\nfunction listUnusedSemantics(prim: Primitive | PrimitiveTarget, required: Set<string>): string[] {\n\tconst unused = [];\n\tfor (const semantic of prim.listSemantics()) {\n\t\tif (semantic === 'NORMAL' && !required.has(semantic)) {\n\t\t\tunused.push(semantic);\n\t\t} else if (semantic === 'TANGENT' && !required.has(semantic)) {\n\t\t\tunused.push(semantic);\n\t\t} else if (semantic.startsWith('TEXCOORD_') && !required.has(semantic)) {\n\t\t\tunused.push(semantic);\n\t\t} else if (semantic.startsWith('COLOR_') && semantic !== 'COLOR_0') {\n\t\t\tunused.push(semantic);\n\t\t}\n\t}\n\treturn unused;\n}\n\n/**\n * Lists vertex attribute semantics required by a material. Does not include\n * attributes that would be used unconditionally, like POSITION or NORMAL.\n */\nfunction listRequiredSemantics(\n\tdocument: Document,\n\tprim: Primitive,\n\tmaterial: Material | ExtensionProperty,\n\tsemantics = new Set<string>(),\n): Set<string> {\n\tconst graph = document.getGraph();\n\n\tconst edges = graph.listChildEdges(material);\n\tconst textureNames = new Set<string>();\n\n\tfor (const edge of edges) {\n\t\tif (edge.getChild() instanceof Texture) {\n\t\t\ttextureNames.add(edge.getName());\n\t\t}\n\t}\n\n\tfor (const edge of edges) {\n\t\tconst name = edge.getName();\n\t\tconst child = edge.getChild();\n\n\t\tif (child instanceof TextureInfo) {\n\t\t\tif (textureNames.has(name.replace(/Info$/, ''))) {\n\t\t\t\tsemantics.add(`TEXCOORD_${child.getTexCoord()}`);\n\t\t\t}\n\t\t}\n\n\t\tif (child instanceof Texture && name.match(/normalTexture/i)) {\n\t\t\tsemantics.add('TANGENT');\n\t\t}\n\n\t\tif (child instanceof ExtensionProperty) {\n\t\t\tlistRequiredSemantics(document, prim, child, semantics);\n\t\t}\n\n\t\t// TODO(#748): Does KHR_materials_anisotropy imply required vertex attributes?\n\t}\n\n\tconst isLit = material instanceof Material && !material.getExtension('KHR_materials_unlit');\n\tconst isPoints = prim.getMode() === Primitive.Mode.POINTS;\n\tif (isLit && !isPoints) {\n\t\tsemantics.add('NORMAL');\n\t}\n\n\treturn semantics;\n}\n\n/**\n * Shifts texCoord indices on the given material and primitives assigned to\n * that material, such that indices start at zero and ascend without gaps.\n * Prior to calling this function, the implementation must ensure that:\n * - All TEXCOORD_n attributes on these prims are used by the material.\n * - Material does not require any unavailable TEXCOORD_n attributes.\n *\n * TEXCOORD_n attributes on morph targets are shifted alongside the parent\n * prim, but gaps may remain in their semantic lists.\n */\nfunction shiftTexCoords(material: Material, prims: Primitive[]) {\n\t// Create map from srcTexCoord → dstTexCoord.\n\tconst textureInfoList = listTextureInfoByMaterial(material);\n\tconst texCoordSet = new Set(textureInfoList.map((info: TextureInfo) => info.getTexCoord()));\n\tconst texCoordList = Array.from(texCoordSet).sort();\n\tconst texCoordMap = new Map(texCoordList.map((texCoord, index) => [texCoord, index]));\n\tconst semanticMap = new Map(texCoordList.map((texCoord, index) => [`TEXCOORD_${texCoord}`, `TEXCOORD_${index}`]));\n\n\t// Update material.\n\tfor (const textureInfo of textureInfoList) {\n\t\tconst texCoord = textureInfo.getTexCoord();\n\t\ttextureInfo.setTexCoord(texCoordMap.get(texCoord)!);\n\t}\n\n\t// Update prims.\n\tfor (const prim of prims) {\n\t\tconst semantics = prim\n\t\t\t.listSemantics()\n\t\t\t.filter((semantic) => semantic.startsWith('TEXCOORD_'))\n\t\t\t.sort();\n\t\tupdatePrim(prim, semantics);\n\t\tprim.listTargets().forEach((target) => updatePrim(target, semantics));\n\t}\n\n\tfunction updatePrim(prim: Primitive | PrimitiveTarget, srcSemantics: string[]) {\n\t\tfor (const srcSemantic of srcSemantics) {\n\t\t\tconst uv = prim.getAttribute(srcSemantic);\n\t\t\tif (!uv) continue;\n\n\t\t\tconst dstSemantic = semanticMap.get(srcSemantic)!;\n\t\t\tif (dstSemantic === srcSemantic) continue;\n\n\t\t\tprim.setAttribute(dstSemantic, uv);\n\t\t\tprim.setAttribute(srcSemantic, null);\n\t\t}\n\t}\n}\n\n/**********************************************************************************************\n * Prune solid (single-color) textures.\n */\n\nasync function pruneSolidTextures(document: Document): Promise<void> {\n\tconst root = document.getRoot();\n\tconst graph = document.getGraph();\n\tconst logger = document.getLogger();\n\tconst textures = root.listTextures();\n\n\tconst pending = textures.map(async (texture) => {\n\t\tconst factor = await getTextureFactor(texture);\n\t\tif (!factor) return;\n\n\t\tif (getTextureColorSpace(texture) === 'srgb') {\n\t\t\tColorUtils.convertSRGBToLinear(factor, factor);\n\t\t}\n\n\t\tconst name = texture.getName() || texture.getURI();\n\t\tconst size = texture.getSize()?.join('x');\n\t\tconst slots = listTextureSlots(texture);\n\n\t\tfor (const edge of graph.listParentEdges(texture)) {\n\t\t\tconst parent = edge.getParent();\n\t\t\tif (parent !== root && applyMaterialFactor(parent as Material, factor, edge.getName(), logger)) {\n\t\t\t\tedge.dispose();\n\t\t\t}\n\t\t}\n\n\t\tif (texture.listParents().length === 1) {\n\t\t\ttexture.dispose();\n\t\t\tlogger.debug(`${NAME}: Removed solid-color texture \"${name}\" (${size}px ${slots.join(', ')})`);\n\t\t}\n\t});\n\n\tawait Promise.all(pending);\n}\n\nfunction applyMaterialFactor(\n\tmaterial: Material | ExtensionProperty,\n\tfactor: vec4,\n\tslot: string,\n\tlogger: ILogger,\n): boolean {\n\tif (material instanceof Material) {\n\t\tswitch (slot) {\n\t\t\tcase 'baseColorTexture':\n\t\t\t\tmaterial.setBaseColorFactor(mul(factor, factor, material.getBaseColorFactor()) as vec4);\n\t\t\t\treturn true;\n\t\t\tcase 'emissiveTexture':\n\t\t\t\tmaterial.setEmissiveFactor(\n\t\t\t\t\tmulVec3([0, 0, 0], factor.slice(0, 3) as vec3, material.getEmissiveFactor()) as vec3,\n\t\t\t\t);\n\t\t\t\treturn true;\n\t\t\tcase 'occlusionTexture':\n\t\t\t\treturn Math.abs(factor[0] - 1) <= EPS;\n\t\t\tcase 'metallicRoughnessTexture':\n\t\t\t\tmaterial.setRoughnessFactor(factor[1] * material.getRoughnessFactor());\n\t\t\t\tmaterial.setMetallicFactor(factor[2] * material.getMetallicFactor());\n\t\t\t\treturn true;\n\t\t\tcase 'normalTexture':\n\t\t\t\treturn len(sub(create(), factor, [0.5, 0.5, 1, 1])) <= EPS;\n\t\t}\n\t}\n\n\tlogger.warn(`${NAME}: Detected single-color ${slot} texture. Pruning ${slot} not yet supported.`);\n\treturn false;\n}\n\nasync function getTextureFactor(texture: Texture): Promise<vec4 | null> {\n\tconst pixels = await maybeGetPixels(texture);\n\tif (!pixels) return null;\n\n\tconst min: vec4 = [Infinity, Infinity, Infinity, Infinity];\n\tconst max: vec4 = [-Infinity, -Infinity, -Infinity, -Infinity];\n\tconst target: vec4 = [0, 0, 0, 0];\n\n\tconst [width, height] = pixels.shape;\n\n\tfor (let i = 0; i < width; i++) {\n\t\tfor (let j = 0; j < height; j++) {\n\t\t\tfor (let k = 0; k < 4; k++) {\n\t\t\t\tmin[k] = Math.min(min[k], pixels.get(i, j, k));\n\t\t\t\tmax[k] = Math.max(max[k], pixels.get(i, j, k));\n\t\t\t}\n\t\t}\n\n\t\tif (len(sub(target, max, min)) / 255 > EPS) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\treturn scale(target, add(target, max, min), 0.5 / 255) as vec4;\n}\n\nasync function maybeGetPixels(texture: Texture): Promise<NdArray<Uint8Array> | null> {\n\ttry {\n\t\treturn await getPixels(texture.getImage()!, texture.getMimeType());\n\t} catch {\n\t\treturn null;\n\t}\n}\n","import { type Document, type Node, PropertyType, type Transform } from '@gltf-transform/core';\nimport { clearNodeParent } from './clear-node-parent.js';\nimport { prune } from './prune.js';\nimport { assignDefaults, createTransform } from './utils.js';\n\nconst NAME = 'flatten';\n\n/** Options for the {@link flatten} function. */\nexport interface FlattenOptions {\n\t/**\n\t * Whether to perform cleanup steps after completing the operation. Recommended, and enabled by\n\t * default. Cleanup removes temporary resources created during the operation, but may also remove\n\t * pre-existing unused or duplicate resources in the {@link Document}. Applications that require\n\t * keeping these resources may need to disable cleanup, instead calling {@link dedup} and\n\t * {@link prune} manually (with customized options) later in the processing pipeline.\n\t * @experimental\n\t */\n\tcleanup?: boolean;\n}\n\nexport const FLATTEN_DEFAULTS: Required<FlattenOptions> = {\n\tcleanup: true,\n};\n\n/**\n * Flattens the scene graph, leaving {@link Node Nodes} with\n * {@link Mesh Meshes}, {@link Camera Cameras}, and other attachments\n * as direct children of the {@link Scene}. Skeletons and their\n * descendants are left in their original Node structure.\n *\n * {@link Animation} targeting a Node or its parents will\n * prevent that Node from being moved.\n *\n * Example:\n *\n * ```ts\n * import { flatten } from '@gltf-transform/functions';\n *\n * await document.transform(flatten());\n * ```\n *\n * @category Transforms\n */\nexport function flatten(_options: FlattenOptions = FLATTEN_DEFAULTS): Transform {\n\tconst options = assignDefaults(FLATTEN_DEFAULTS, _options);\n\n\treturn createTransform(NAME, async (document: Document): Promise<void> => {\n\t\tconst root = document.getRoot();\n\t\tconst logger = document.getLogger();\n\n\t\t// (1) Mark joints.\n\t\tconst joints = new Set<Node>();\n\t\tfor (const skin of root.listSkins()) {\n\t\t\tfor (const joint of skin.listJoints()) {\n\t\t\t\tjoints.add(joint);\n\t\t\t}\n\t\t}\n\n\t\t// (2) Mark nodes with TRS animation.\n\t\tconst animated = new Set<Node>();\n\t\tfor (const animation of root.listAnimations()) {\n\t\t\tfor (const channel of animation.listChannels()) {\n\t\t\t\tconst node = channel.getTargetNode();\n\t\t\t\tif (node && channel.getTargetPath() !== 'weights') {\n\t\t\t\t\tanimated.add(node);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// (3) Mark descendants of joints and animated nodes.\n\t\tconst hasJointParent = new Set<Node>();\n\t\tconst hasAnimatedParent = new Set<Node>();\n\t\tfor (const scene of root.listScenes()) {\n\t\t\tscene.traverse((node) => {\n\t\t\t\tconst parent = node.getParentNode();\n\t\t\t\tif (!parent) return;\n\t\t\t\tif (joints.has(parent) || hasJointParent.has(parent)) {\n\t\t\t\t\thasJointParent.add(node);\n\t\t\t\t}\n\t\t\t\tif (animated.has(parent) || hasAnimatedParent.has(parent)) {\n\t\t\t\t\thasAnimatedParent.add(node);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\t// (4) For each affected node, in top-down order, clear parents.\n\t\tfor (const scene of root.listScenes()) {\n\t\t\tscene.traverse((node) => {\n\t\t\t\tif (animated.has(node)) return;\n\t\t\t\tif (hasJointParent.has(node)) return;\n\t\t\t\tif (hasAnimatedParent.has(node)) return;\n\n\t\t\t\tclearNodeParent(node);\n\t\t\t});\n\t\t}\n\n\t\t// TODO(feat): Transform animation channels, accounting for previously inherited transforms.\n\t\tif (animated.size) {\n\t\t\tlogger.debug(`${NAME}: Flattening node hierarchies with TRS animation not yet supported.`);\n\t\t}\n\n\t\t// (5) Clean up leaf nodes.\n\t\tif (options.cleanup) {\n\t\t\tawait document.transform(prune({ propertyTypes: [PropertyType.NODE], keepLeaves: false }));\n\t\t}\n\n\t\tlogger.debug(`${NAME}: Complete.`);\n\t});\n}\n","import { getBounds as _getBounds, type bbox, type Node, type Scene } from '@gltf-transform/core';\n\n/**\n * Computes bounding box (AABB) in world space for the given {@link Node} or {@link Scene}.\n *\n * Example:\n *\n * ```ts\n * import { getBounds } from '@gltf-transform/functions';\n *\n * const {min, max} = getBounds(scene);\n * ```\n */\nexport function getBounds(node: Node | Scene): bbox {\n\treturn _getBounds(node);\n}\n","import {\n\ttype Accessor,\n\ttype Document,\n\tExtensionProperty,\n\ttype GLTF,\n\tgetBounds,\n\tImageUtils,\n\tPropertyType,\n\tTexture,\n} from '@gltf-transform/core';\nimport { KHR_DF_MODEL_ETC1S, KHR_DF_MODEL_UASTC, read as readKTX } from 'ktx-parse';\nimport { getMeshVertexCount, getSceneVertexCount, VertexCountMethod } from './get-vertex-count.js';\nimport { getGLPrimitiveCount } from './utils.js';\n\n/** Inspects the contents of a glTF file and returns a JSON report. */\nexport function inspect(doc: Document): InspectReport {\n\treturn {\n\t\tscenes: listScenes(doc),\n\t\tmeshes: listMeshes(doc),\n\t\tmaterials: listMaterials(doc),\n\t\ttextures: listTextures(doc),\n\t\tanimations: listAnimations(doc),\n\t};\n}\n\n/** List scenes. */\nfunction listScenes(doc: Document): InspectPropertyReport<InspectSceneReport> {\n\tconst scenes = doc\n\t\t.getRoot()\n\t\t.listScenes()\n\t\t.map((scene) => {\n\t\t\tconst root = scene.listChildren()[0];\n\t\t\tconst sceneBounds = getBounds(scene);\n\t\t\treturn {\n\t\t\t\tname: scene.getName(),\n\t\t\t\trootName: root ? root.getName() : '',\n\t\t\t\tbboxMin: toPrecision(sceneBounds.min),\n\t\t\t\tbboxMax: toPrecision(sceneBounds.max),\n\t\t\t\trenderVertexCount: getSceneVertexCount(scene, VertexCountMethod.RENDER),\n\t\t\t\tuploadVertexCount: getSceneVertexCount(scene, VertexCountMethod.UPLOAD),\n\t\t\t\tuploadNaiveVertexCount: getSceneVertexCount(scene, VertexCountMethod.UPLOAD_NAIVE),\n\t\t\t};\n\t\t});\n\treturn { properties: scenes };\n}\n\n/** List meshes. */\nfunction listMeshes(doc: Document): InspectPropertyReport<InspectMeshReport> {\n\tconst meshes: InspectMeshReport[] = doc\n\t\t.getRoot()\n\t\t.listMeshes()\n\t\t.map((mesh) => {\n\t\t\tconst instances = mesh.listParents().filter((parent) => parent.propertyType !== PropertyType.ROOT).length;\n\t\t\tlet glPrimitives = 0;\n\t\t\tconst semantics = new Set<string>();\n\t\t\tconst meshIndices = new Set<string>();\n\t\t\tconst meshAccessors: Set<Accessor> = new Set();\n\n\t\t\tmesh.listPrimitives().forEach((prim) => {\n\t\t\t\tfor (const semantic of prim.listSemantics()) {\n\t\t\t\t\tconst attr = prim.getAttribute(semantic)!;\n\t\t\t\t\tsemantics.add(semantic + ':' + accessorToTypeLabel(attr));\n\t\t\t\t\tmeshAccessors.add(attr);\n\t\t\t\t}\n\t\t\t\tfor (const targ of prim.listTargets()) {\n\t\t\t\t\ttarg.listAttributes().forEach((attr) => meshAccessors.add(attr));\n\t\t\t\t}\n\t\t\t\tconst indices = prim.getIndices();\n\t\t\t\tif (indices) {\n\t\t\t\t\tmeshIndices.add(accessorToTypeLabel(indices));\n\t\t\t\t\tmeshAccessors.add(indices);\n\t\t\t\t}\n\t\t\t\tglPrimitives += getGLPrimitiveCount(prim);\n\t\t\t});\n\n\t\t\tlet size = 0;\n\t\t\tArray.from(meshAccessors).forEach((a) => (size += a.getArray()!.byteLength));\n\n\t\t\tconst modes = mesh.listPrimitives().map((prim) => MeshPrimitiveModeLabels[prim.getMode()]);\n\n\t\t\treturn {\n\t\t\t\tname: mesh.getName(),\n\t\t\t\tmode: Array.from(new Set(modes)),\n\t\t\t\tmeshPrimitives: mesh.listPrimitives().length,\n\t\t\t\tglPrimitives: glPrimitives,\n\t\t\t\tvertices: getMeshVertexCount(mesh, VertexCountMethod.UPLOAD),\n\t\t\t\tindices: Array.from(meshIndices).sort(),\n\t\t\t\tattributes: Array.from(semantics).sort(),\n\t\t\t\tinstances: instances,\n\t\t\t\tsize: size,\n\t\t\t};\n\t\t});\n\n\treturn { properties: meshes };\n}\n\n/** List materials. */\nfunction listMaterials(doc: Document): InspectPropertyReport<InspectMaterialReport> {\n\tconst materials: InspectMaterialReport[] = doc\n\t\t.getRoot()\n\t\t.listMaterials()\n\t\t.map((material) => {\n\t\t\tconst instances = material\n\t\t\t\t.listParents()\n\t\t\t\t.filter((parent) => parent.propertyType !== PropertyType.ROOT).length;\n\n\t\t\t// Find all texture slots attached to this material or its extensions.\n\t\t\tconst extensions = new Set<ExtensionProperty>(material.listExtensions());\n\t\t\tconst slots = doc\n\t\t\t\t.getGraph()\n\t\t\t\t.listEdges()\n\t\t\t\t.filter((ref) => {\n\t\t\t\t\tconst child = ref.getChild();\n\t\t\t\t\tconst parent = ref.getParent();\n\t\t\t\t\tif (child instanceof Texture && parent === material) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tif (child instanceof Texture && parent instanceof ExtensionProperty && extensions.has(parent)) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t})\n\t\t\t\t.map((ref) => ref.getName());\n\n\t\t\treturn {\n\t\t\t\tname: material.getName(),\n\t\t\t\tinstances,\n\t\t\t\ttextures: slots,\n\t\t\t\talphaMode: material.getAlphaMode(),\n\t\t\t\tdoubleSided: material.getDoubleSided(),\n\t\t\t};\n\t\t});\n\n\treturn { properties: materials };\n}\n\n/** List textures. */\nfunction listTextures(doc: Document): InspectPropertyReport<InspectTextureReport> {\n\tconst textures: InspectTextureReport[] = doc\n\t\t.getRoot()\n\t\t.listTextures()\n\t\t.map((texture) => {\n\t\t\tconst instances = texture\n\t\t\t\t.listParents()\n\t\t\t\t.filter((parent) => parent.propertyType !== PropertyType.ROOT).length;\n\n\t\t\tconst slots = doc\n\t\t\t\t.getGraph()\n\t\t\t\t.listParentEdges(texture)\n\t\t\t\t.filter((edge) => edge.getParent().propertyType !== PropertyType.ROOT)\n\t\t\t\t.map((edge) => edge.getName());\n\n\t\t\tconst resolution = ImageUtils.getSize(texture.getImage()!, texture.getMimeType());\n\n\t\t\tlet compression = '';\n\t\t\tif (texture.getMimeType() === 'image/ktx2') {\n\t\t\t\tconst container = readKTX(texture.getImage()!);\n\t\t\t\tconst dfd = container.dataFormatDescriptor[0];\n\t\t\t\tif (dfd.colorModel === KHR_DF_MODEL_ETC1S) {\n\t\t\t\t\tcompression = 'ETC1S';\n\t\t\t\t} else if (dfd.colorModel === KHR_DF_MODEL_UASTC) {\n\t\t\t\t\tcompression = 'UASTC';\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tname: texture.getName(),\n\t\t\t\turi: texture.getURI(),\n\t\t\t\tslots: Array.from(new Set(slots)),\n\t\t\t\tinstances,\n\t\t\t\tmimeType: texture.getMimeType(),\n\t\t\t\tcompression,\n\t\t\t\tresolution: resolution ? resolution.join('x') : '',\n\t\t\t\tsize: texture.getImage()!.byteLength,\n\t\t\t\tgpuSize: ImageUtils.getVRAMByteLength(texture.getImage()!, texture.getMimeType()),\n\t\t\t};\n\t\t});\n\n\treturn { properties: textures };\n}\n\n/** List animations. */\nfunction listAnimations(doc: Document): InspectPropertyReport<InspectAnimationReport> {\n\tconst animations: InspectAnimationReport[] = doc\n\t\t.getRoot()\n\t\t.listAnimations()\n\t\t.map((anim) => {\n\t\t\tlet minTime = Infinity;\n\t\t\tlet maxTime = -Infinity;\n\t\t\tanim.listSamplers().forEach((sampler) => {\n\t\t\t\tconst input = sampler.getInput();\n\t\t\t\tif (!input) return;\n\t\t\t\tminTime = Math.min(minTime, input.getMin([])[0]);\n\t\t\t\tmaxTime = Math.max(maxTime, input.getMax([])[0]);\n\t\t\t});\n\n\t\t\tlet size = 0;\n\t\t\tlet keyframes = 0;\n\t\t\tconst accessors: Set<Accessor> = new Set();\n\t\t\tanim.listSamplers().forEach((sampler) => {\n\t\t\t\tconst input = sampler.getInput();\n\t\t\t\tconst output = sampler.getOutput();\n\t\t\t\tif (!input) return;\n\t\t\t\tkeyframes += input.getCount();\n\t\t\t\taccessors.add(input);\n\t\t\t\tif (!output) return;\n\t\t\t\taccessors.add(output);\n\t\t\t});\n\t\t\tArray.from(accessors).forEach((accessor) => {\n\t\t\t\tsize += accessor.getArray()!.byteLength;\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tname: anim.getName(),\n\t\t\t\tchannels: anim.listChannels().length,\n\t\t\t\tsamplers: anim.listSamplers().length,\n\t\t\t\tduration: Math.round((maxTime - minTime) * 1000) / 1000,\n\t\t\t\tkeyframes: keyframes,\n\t\t\t\tsize: size,\n\t\t\t};\n\t\t});\n\n\treturn { properties: animations };\n}\n\nexport interface InspectReport {\n\tscenes: InspectPropertyReport<InspectSceneReport>;\n\tmeshes: InspectPropertyReport<InspectMeshReport>;\n\tmaterials: InspectPropertyReport<InspectMaterialReport>;\n\ttextures: InspectPropertyReport<InspectTextureReport>;\n\tanimations: InspectPropertyReport<InspectAnimationReport>;\n}\n\nexport interface InspectPropertyReport<T> {\n\tproperties: T[];\n\terrors?: string[];\n\twarnings?: string[];\n}\n\nexport interface InspectSceneReport {\n\tname: string;\n\trootName: string;\n\tbboxMin: number[];\n\tbboxMax: number[];\n\trenderVertexCount: number;\n\tuploadVertexCount: number;\n\tuploadNaiveVertexCount: number;\n}\n\nexport interface InspectMeshReport {\n\tname: string;\n\tmeshPrimitives: number;\n\tmode: string[];\n\tvertices: number;\n\tglPrimitives: number;\n\tindices: string[];\n\tattributes: string[];\n\tinstances: number;\n\tsize: number;\n}\n\nexport interface InspectMaterialReport {\n\tname: string;\n\tinstances: number;\n\ttextures: string[];\n\talphaMode: GLTF.MaterialAlphaMode;\n\tdoubleSided: boolean;\n}\n\nexport interface InspectTextureReport {\n\tname: string;\n\turi: string;\n\tslots: string[];\n\tinstances: number;\n\tmimeType: string;\n\tresolution: string;\n\tcompression: string;\n\tsize: number;\n\tgpuSize: number | null;\n}\n\nexport interface InspectAnimationReport {\n\tname: string;\n\tchannels: number;\n\tsamplers: number;\n\tkeyframes: number;\n\tduration: number;\n\tsize: number;\n}\n\nconst MeshPrimitiveModeLabels = [\n\t'POINTS',\n\t'LINES',\n\t'LINE_LOOP',\n\t'LINE_STRIP',\n\t'TRIANGLES',\n\t'TRIANGLE_STRIP',\n\t'TRIANGLE_FAN',\n];\n\nconst NumericTypeLabels: Record<string, string> = {\n\tFloat32Array: 'f32',\n\tUint32Array: 'u32',\n\tUint16Array: 'u16',\n\tUint8Array: 'u8',\n\tInt32Array: 'i32',\n\tInt16Array: 'i16',\n\tInt8Array: 'i8',\n};\n\n/** Maps values in a vector to a finite precision. */\nfunction toPrecision(v: number[]): number[] {\n\tfor (let i = 0; i < v.length; i++) {\n\t\tif ((v[i] as number).toFixed) v[i] = Number(v[i].toFixed(5));\n\t}\n\treturn v;\n}\n\nfunction accessorToTypeLabel(accessor: Accessor): string {\n\tconst array = accessor.getArray()!;\n\tconst base = NumericTypeLabels[array.constructor.name] || '?';\n\tconst suffix = accessor.getNormalized() ? '_norm' : '';\n\treturn base + suffix;\n}\n","import {\n\ttype Document,\n\ttype ILogger,\n\tMathUtils,\n\ttype Mesh,\n\ttype Node,\n\ttype Primitive,\n\ttype Transform,\n\ttype vec3,\n\ttype vec4,\n} from '@gltf-transform/core';\nimport { EXTMeshGPUInstancing, type InstancedMesh } from '@gltf-transform/extensions';\nimport { assignDefaults, createTransform } from './utils.js';\n\nconst NAME = 'instance';\n\nexport interface InstanceOptions {\n\t/** Minimum number of meshes considered eligible for instancing. Default: 5. */\n\tmin?: number;\n}\n\nexport const INSTANCE_DEFAULTS: Required<InstanceOptions> = {\n\tmin: 5,\n};\n\n/**\n * Creates GPU instances (with {@link EXTMeshGPUInstancing}) for shared {@link Mesh} references. In\n * engines supporting the extension, reused Meshes will be drawn with GPU instancing, greatly\n * reducing draw calls and improving performance in many cases. If you're not sure that identical\n * Meshes share vertex data and materials (\"linked duplicates\"), run {@link dedup} first to link them.\n *\n * Example:\n *\n * ```javascript\n * import { dedup, instance } from '@gltf-transform/functions';\n *\n * await document.transform(\n * \tdedup(),\n * \tinstance({min: 5}),\n * );\n * ```\n *\n * @category Transforms\n */\nexport function instance(_options: InstanceOptions = INSTANCE_DEFAULTS): Transform {\n\tconst options = assignDefaults(INSTANCE_DEFAULTS, _options);\n\n\treturn createTransform(NAME, (doc: Document): void => {\n\t\tconst logger = doc.getLogger();\n\t\tconst root = doc.getRoot();\n\n\t\tif (root.listAnimations().length) {\n\t\t\tlogger.warn(`${NAME}: Instancing is not currently supported for animated models.`);\n\t\t\tlogger.debug(`${NAME}: Complete.`);\n\t\t\treturn;\n\t\t}\n\n\t\tconst batchExtension = doc.createExtension(EXTMeshGPUInstancing);\n\n\t\tlet numBatches = 0;\n\t\tlet numInstances = 0;\n\n\t\tfor (const scene of root.listScenes()) {\n\t\t\t// Gather a one-to-many Mesh/Node mapping, identifying what we can instance.\n\t\t\tconst meshInstances = new Map<Mesh, Set<Node>>();\n\t\t\tscene.traverse((node) => {\n\t\t\t\tconst mesh = node.getMesh();\n\t\t\t\tif (!mesh) return;\n\t\t\t\tif (node.getExtension('EXT_mesh_gpu_instancing')) return;\n\t\t\t\tmeshInstances.set(mesh, (meshInstances.get(mesh) || new Set<Node>()).add(node));\n\t\t\t});\n\n\t\t\t// For each Mesh, create an InstancedMesh and collect transforms.\n\t\t\tconst modifiedNodes = [];\n\t\t\tfor (const mesh of Array.from(meshInstances.keys())) {\n\t\t\t\tconst nodes = Array.from(meshInstances.get(mesh)!);\n\t\t\t\tif (nodes.length < options.min) continue;\n\t\t\t\tif (nodes.some((node) => node.getSkin())) continue;\n\n\t\t\t\t// Cannot preserve volumetric effects when instancing with varying scale.\n\t\t\t\t// See: https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/AttenuationTest\n\t\t\t\tif (mesh.listPrimitives().some(hasVolume) && nodes.some(hasScale)) continue;\n\n\t\t\t\tconst batch = createBatch(doc, batchExtension, mesh, nodes.length);\n\t\t\t\tconst batchTranslation = batch.getAttribute('TRANSLATION')!;\n\t\t\t\tconst batchRotation = batch.getAttribute('ROTATION')!;\n\t\t\t\tconst batchScale = batch.getAttribute('SCALE')!;\n\n\t\t\t\tconst batchNode = doc.createNode().setMesh(mesh).setExtension('EXT_mesh_gpu_instancing', batch);\n\t\t\t\tscene.addChild(batchNode);\n\n\t\t\t\tlet needsTranslation = false;\n\t\t\t\tlet needsRotation = false;\n\t\t\t\tlet needsScale = false;\n\n\t\t\t\t// For each Node, write TRS properties into instance attributes.\n\t\t\t\tfor (let i = 0; i < nodes.length; i++) {\n\t\t\t\t\tlet t: vec3, r: vec4, s: vec3;\n\t\t\t\t\tconst node = nodes[i];\n\n\t\t\t\t\tbatchTranslation.setElement(i, (t = node.getWorldTranslation()));\n\t\t\t\t\tbatchRotation.setElement(i, (r = node.getWorldRotation()));\n\t\t\t\t\tbatchScale.setElement(i, (s = node.getWorldScale()));\n\n\t\t\t\t\tif (!MathUtils.eq(t, [0, 0, 0])) needsTranslation = true;\n\t\t\t\t\tif (!MathUtils.eq(r, [0, 0, 0, 1])) needsRotation = true;\n\t\t\t\t\tif (!MathUtils.eq(s, [1, 1, 1])) needsScale = true;\n\t\t\t\t}\n\n\t\t\t\tif (!needsTranslation) batchTranslation.dispose();\n\t\t\t\tif (!needsRotation) batchRotation.dispose();\n\t\t\t\tif (!needsScale) batchScale.dispose();\n\n\t\t\t\tif (!needsTranslation && !needsRotation && !needsScale) {\n\t\t\t\t\tbatchNode.dispose();\n\t\t\t\t\tbatch.dispose();\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Mark nodes for cleanup.\n\t\t\t\tfor (const node of nodes) {\n\t\t\t\t\tnode.setMesh(null);\n\t\t\t\t\tmodifiedNodes.push(node);\n\t\t\t\t}\n\n\t\t\t\tnumBatches++;\n\t\t\t\tnumInstances += nodes.length;\n\t\t\t}\n\n\t\t\tpruneUnusedNodes(modifiedNodes, logger);\n\t\t}\n\n\t\tif (numBatches > 0) {\n\t\t\tlogger.info(`${NAME}: Created ${numBatches} batches, with ${numInstances} total instances.`);\n\t\t} else {\n\t\t\tlogger.info(`${NAME}: No meshes with >=${options.min} parent nodes were found.`);\n\t\t}\n\n\t\tif (batchExtension.listProperties().length === 0) {\n\t\t\tbatchExtension.dispose();\n\t\t}\n\n\t\tlogger.debug(`${NAME}: Complete.`);\n\t});\n}\n\nfunction pruneUnusedNodes(nodes: Node[], logger: ILogger): void {\n\tlet node: Node | undefined;\n\tlet unusedNodes = 0;\n\twhile ((node = nodes.pop())) {\n\t\tif (\n\t\t\tnode.listChildren().length ||\n\t\t\tnode.getCamera() ||\n\t\t\tnode.getMesh() ||\n\t\t\tnode.getSkin() ||\n\t\t\tnode.listExtensions().length\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst nodeParent = node.getParentNode();\n\t\tif (nodeParent) nodes.push(nodeParent);\n\t\tnode.dispose();\n\t\tunusedNodes++;\n\t}\n\n\tlogger.debug(`${NAME}: Removed ${unusedNodes} unused nodes.`);\n}\n\nfunction hasVolume(prim: Primitive) {\n\tconst material = prim.getMaterial();\n\treturn !!(material && material.getExtension('KHR_materials_volume'));\n}\n\nfunction hasScale(node: Node) {\n\tconst scale = node.getWorldScale();\n\treturn !MathUtils.eq(scale, [1, 1, 1]);\n}\n\nfunction createBatch(doc: Document, batchExtension: EXTMeshGPUInstancing, mesh: Mesh, count: number): InstancedMesh {\n\tconst buffer = mesh.listPrimitives()[0].getAttribute('POSITION')!.getBuffer();\n\n\tconst batchTranslation = doc\n\t\t.createAccessor()\n\t\t.setType('VEC3')\n\t\t.setArray(new Float32Array(3 * count))\n\t\t.setBuffer(buffer);\n\tconst batchRotation = doc\n\t\t.createAccessor()\n\t\t.setType('VEC4')\n\t\t.setArray(new Float32Array(4 * count))\n\t\t.setBuffer(buffer);\n\tconst batchScale = doc\n\t\t.createAccessor()\n\t\t.setType('VEC3')\n\t\t.setArray(new Float32Array(3 * count))\n\t\t.setBuffer(buffer);\n\n\treturn batchExtension\n\t\t.createInstancedMesh()\n\t\t.setAttribute('TRANSLATION', batchTranslation)\n\t\t.setAttribute('ROTATION', batchRotation)\n\t\t.setAttribute('SCALE', batchScale);\n}\n","import { type Accessor, ComponentTypeToTypedArray, Document, Primitive, type TypedArray } from '@gltf-transform/core';\nimport { convertPrimitiveToLines, convertPrimitiveToTriangles } from './convert-primitive-mode.js';\nimport { assignDefaults, createIndicesEmpty, createPrimGroupKey, shallowCloneAccessor } from './utils.js';\n\ninterface JoinPrimitiveOptions {\n\tskipValidation?: boolean;\n}\n\nconst JOIN_PRIMITIVE_DEFAULTS: Required<JoinPrimitiveOptions> = {\n\tskipValidation: false,\n};\n\nconst EMPTY_U32 = 2 ** 32 - 1;\n\nconst { LINE_STRIP, LINE_LOOP, TRIANGLE_STRIP, TRIANGLE_FAN } = Primitive.Mode;\n\n/**\n * Given a list of compatible Mesh {@link Primitive Primitives}, returns new Primitive\n * containing their vertex data. Compatibility requires that all Primitives share the\n * same {@link Material Materials}, draw mode, and vertex attribute types. Primitives\n * using morph targets cannot currently be joined.\n *\n * Example:\n *\n * ```javascript\n * import { joinPrimitives } from '@gltf-transform/functions';\n *\n * // Succeeds if Primitives are compatible, or throws an error.\n * const result = joinPrimitives(mesh.listPrimitives());\n *\n * for (const prim of mesh.listPrimitives()) {\n * \tprim.dispose();\n * }\n *\n * mesh.addPrimitive(result);\n * ```\n */\nexport function joinPrimitives(prims: Primitive[], _options: JoinPrimitiveOptions = {}): Primitive {\n\tconst options = assignDefaults(JOIN_PRIMITIVE_DEFAULTS, _options);\n\tconst templatePrim = prims[0]!;\n\tconst document = Document.fromGraph(templatePrim.getGraph())!;\n\n\t// (1) Validation.\n\tif (!options.skipValidation && new Set(prims.map(createPrimGroupKey)).size > 1) {\n\t\tthrow new Error(\n\t\t\t'' +\n\t\t\t\t'Requires >=2 Primitives, sharing the same Material ' +\n\t\t\t\t'and Mode, with compatible vertex attributes and indices.',\n\t\t);\n\t}\n\n\t// (2) Convert all prims to POINTS, LINES, or TRIANGLES.\n\tfor (const prim of prims) {\n\t\tswitch (prim.getMode()) {\n\t\t\tcase LINE_STRIP:\n\t\t\tcase LINE_LOOP:\n\t\t\t\tconvertPrimitiveToLines(prim);\n\t\t\t\tbreak;\n\t\t\tcase TRIANGLE_STRIP:\n\t\t\tcase TRIANGLE_FAN:\n\t\t\t\tconvertPrimitiveToTriangles(prim);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tconst primRemaps = [] as Uint32Array<ArrayBuffer>[]; // remap[srcIndex] → dstIndex, by prim\n\tconst primVertexCounts = new Uint32Array(prims.length); // vertex count, by prim\n\n\tlet dstVertexCount = 0;\n\tlet dstIndicesCount = 0;\n\n\t// (3) Build remap lists.\n\tfor (let primIndex = 0; primIndex < prims.length; primIndex++) {\n\t\tconst srcPrim = prims[primIndex];\n\t\tconst srcIndices = srcPrim.getIndices();\n\t\tconst srcVertexCount = srcPrim.getAttribute('POSITION')!.getCount();\n\t\tconst srcIndicesArray = srcIndices ? srcIndices.getArray() : null;\n\t\tconst srcIndicesCount = srcIndices ? srcIndices.getCount() : srcVertexCount;\n\n\t\tconst remap = new Uint32Array(srcVertexCount).fill(EMPTY_U32);\n\n\t\tfor (let i = 0; i < srcIndicesCount; i++) {\n\t\t\tconst index = srcIndicesArray ? srcIndicesArray[i] : i;\n\t\t\tif (remap[index] === EMPTY_U32) {\n\t\t\t\tremap[index] = dstVertexCount++;\n\t\t\t\tprimVertexCounts[primIndex]++;\n\t\t\t}\n\t\t}\n\n\t\tprimRemaps.push(remap);\n\t\tdstIndicesCount += srcIndicesCount;\n\t}\n\n\t// (4) Allocate joined attributes.\n\tconst dstPrim = document.createPrimitive().setMode(templatePrim.getMode()).setMaterial(templatePrim.getMaterial());\n\tfor (const semantic of templatePrim.listSemantics()) {\n\t\tconst tplAttribute = templatePrim.getAttribute(semantic)!;\n\t\tconst AttributeArray = ComponentTypeToTypedArray[tplAttribute.getComponentType()];\n\t\tconst dstAttribute = shallowCloneAccessor(document, tplAttribute).setArray(\n\t\t\tnew AttributeArray(dstVertexCount * tplAttribute.getElementSize()),\n\t\t);\n\t\tdstPrim.setAttribute(semantic, dstAttribute);\n\t}\n\n\t// (5) Allocate joined indices.\n\tconst tplIndices = templatePrim.getIndices();\n\tconst dstIndices = tplIndices\n\t\t? shallowCloneAccessor(document, tplIndices).setArray(createIndicesEmpty(dstIndicesCount, dstVertexCount))\n\t\t: null;\n\tdstPrim.setIndices(dstIndices);\n\n\t// (6) Remap attributes into joined Primitive.\n\tlet dstIndicesOffset = 0;\n\tfor (let primIndex = 0; primIndex < primRemaps.length; primIndex++) {\n\t\tconst srcPrim = prims[primIndex];\n\t\tconst srcIndices = srcPrim.getIndices();\n\t\tconst srcIndicesCount = srcIndices ? srcIndices.getCount() : -1;\n\n\t\tconst remap = primRemaps[primIndex];\n\n\t\tif (srcIndices && dstIndices) {\n\t\t\tremapIndices(srcIndices, remap, dstIndices, dstIndicesOffset);\n\t\t\tdstIndicesOffset += srcIndicesCount;\n\t\t}\n\n\t\tfor (const semantic of dstPrim.listSemantics()) {\n\t\t\tconst srcAttribute = srcPrim.getAttribute(semantic)!;\n\t\t\tconst dstAttribute = dstPrim.getAttribute(semantic)!;\n\t\t\tremapAttribute(srcAttribute, srcIndices, remap, dstAttribute);\n\t\t}\n\t}\n\n\treturn dstPrim;\n}\n\n/**\n * Internal variant of {@link compactAttribute}. Unlike compactAttribute,\n * assumes the vertex count cannot change, and avoids cloning attributes.\n * @hidden\n * @internal\n */\nfunction remapAttribute(\n\tsrcAttribute: Accessor,\n\tsrcIndices: Accessor | null,\n\tremap: TypedArray,\n\tdstAttribute: Accessor,\n): void {\n\tconst elementSize = srcAttribute.getElementSize();\n\tconst srcIndicesArray = srcIndices ? srcIndices.getArray() : null;\n\tconst srcVertexCount = srcAttribute.getCount();\n\tconst srcArray = srcAttribute.getArray()!;\n\tconst dstArray = dstAttribute.getArray()!;\n\tconst done = new Uint8Array(srcAttribute.getCount());\n\n\tfor (let i = 0, il = srcIndices ? srcIndices.getCount() : srcVertexCount; i < il; i++) {\n\t\tconst srcIndex = srcIndicesArray ? srcIndicesArray[i] : i;\n\t\tconst dstIndex = remap[srcIndex];\n\t\tif (done[dstIndex]) continue;\n\n\t\tfor (let j = 0; j < elementSize; j++) {\n\t\t\tdstArray[dstIndex * elementSize + j] = srcArray[srcIndex * elementSize + j];\n\t\t}\n\n\t\tdone[dstIndex] = 1;\n\t}\n}\n\n/**\n * Internal variant of {@link compactPrimitive}'s index remapping. Avoids\n * cloning indices; writes directly to `dstIndices`.\n * @hidden\n * @internal\n */\nfunction remapIndices(srcIndices: Accessor, remap: TypedArray, dstIndices: Accessor, dstOffset: number): void {\n\tconst srcCount = srcIndices.getCount();\n\tconst srcArray = srcIndices.getArray()!;\n\tconst dstArray = dstIndices.getArray()!;\n\n\tfor (let i = 0; i < srcCount; i++) {\n\t\tconst srcIndex = srcArray[i];\n\t\tconst dstIndex = remap[srcIndex];\n\t\tdstArray[dstOffset + i] = dstIndex;\n\t}\n}\n","import {\n\tAnimationChannel,\n\ttype Document,\n\ttype Mesh,\n\ttype mat4,\n\ttype Node,\n\ttype Primitive,\n\tPropertyType,\n\ttype Scene,\n\ttype Transform,\n} from '@gltf-transform/core';\nimport { invert, multiply } from 'gl-matrix/mat4';\nimport { compactPrimitive } from './compact-primitive.js';\nimport { dequantizeAttribute } from './dequantize.js';\nimport { joinPrimitives } from './join-primitives.js';\nimport { prune } from './prune.js';\nimport { transformPrimitive } from './transform-primitive.js';\nimport { assignDefaults, createPrimGroupKey, createTransform, formatLong, isUsed } from './utils.js';\n\nconst NAME = 'join';\n\nconst { ROOT, NODE, MESH, PRIMITIVE, ACCESSOR } = PropertyType;\n\n// biome-ignore format: Readability.\nconst _matrix = [\n\t0, 0, 0, 0,\n\t0, 0, 0, 0,\n\t0, 0, 0, 0,\n\t0, 0, 0, 0,\n] as mat4;\n\n/** Options for the {@link join} function. */\nexport interface JoinOptions {\n\t/**\n\t * Prevents joining distinct {@link Mesh Meshes} and {@link Node Nodes}.\n\t * Joins only Primitives found within the same parent Mesh. To preserve\n\t * only _named_ Nodes and Meshes, use\n\t * {@link JoinOptions.keepNamed keepNamed} instead. Default: false.\n\t */\n\tkeepMeshes?: boolean;\n\t/**\n\t * Prevents joining _named_ {@link Mesh Meshes} and {@link Node Nodes}.\n\t * If {@link JoinOptions.keepMeshes keepMeshes} is enabled, keepNamed will\n\t * have no effect. Default: false.\n\t */\n\tkeepNamed?: boolean;\n\t/**\n\t * Whether to perform cleanup steps after completing the operation. Recommended, and enabled by\n\t * default. Cleanup removes temporary resources created during the operation, but may also remove\n\t * pre-existing unused or duplicate resources in the {@link Document}. Applications that require\n\t * keeping these resources may need to disable cleanup, instead calling {@link dedup} and\n\t * {@link prune} manually (with customized options) later in the processing pipeline.\n\t * @experimental\n\t */\n\tcleanup?: boolean;\n\t/**\n\t * A filter function used to evaluate a condition on a given {@link Node Node}.\n\t * This function should return a boolean indicating whether the node\n\t * satisfies the provided condition.\n\t *\n\t * @param {Node} node - The node instance to be evaluated.\n\t * @returns {boolean} - The result of the evaluation; `true` if the condition is met, otherwise `false`.\n\t */\n\tfilter?: (node: Node) => boolean;\n}\n\nexport const JOIN_DEFAULTS: Required<JoinOptions> = {\n\tkeepMeshes: false,\n\tkeepNamed: false,\n\tcleanup: true,\n\tfilter: () => true,\n};\n\n/**\n * Joins compatible {@link Primitive Primitives} and reduces draw calls.\n * Primitives are eligible for joining if they are members of the same\n * {@link Mesh} or, optionally, attached to sibling {@link Node Nodes}\n * in the scene hierarchy. For best results, apply {@link dedup} and\n * {@link flatten} first to maximize the number of Primitives that\n * can be joined.\n *\n * NOTE: In a Scene that heavily reuses the same Mesh data, joining may\n * increase vertex count. Consider alternatives, like\n * {@link instance instancing} with {@link EXTMeshGPUInstancing}.\n *\n * Example:\n *\n * ```ts\n * import { PropertyType } from '@gltf-transform/core';\n * import { join, flatten, dedup } from '@gltf-transform/functions';\n *\n * await document.transform(\n * \tdedup({ propertyTypes: [PropertyType.MATERIAL] }),\n * \tflatten(),\n * \tjoin({ keepNamed: false }),\n * );\n * ```\n *\n * @category Transforms\n */\nexport function join(_options: JoinOptions = JOIN_DEFAULTS): Transform {\n\tconst options = assignDefaults(JOIN_DEFAULTS, _options);\n\n\treturn createTransform(NAME, async (document: Document): Promise<void> => {\n\t\tconst root = document.getRoot();\n\t\tconst logger = document.getLogger();\n\n\t\t// Join.\n\t\tfor (const scene of root.listScenes()) {\n\t\t\t_joinLevel(document, scene, options);\n\t\t\tscene.traverse((node) => _joinLevel(document, node, options));\n\t\t}\n\n\t\t// Clean up.\n\t\tif (options.cleanup) {\n\t\t\tawait document.transform(\n\t\t\t\tprune({\n\t\t\t\t\tpropertyTypes: [NODE, MESH, PRIMITIVE, ACCESSOR],\n\t\t\t\t\tkeepAttributes: true,\n\t\t\t\t\tkeepIndices: true,\n\t\t\t\t\tkeepLeaves: false,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tlogger.debug(`${NAME}: Complete.`);\n\t});\n}\n\ninterface IJoinGroup {\n\tkey: string;\n\tprims: Primitive[];\n\tprimMeshes: Mesh[];\n\tprimNodes: Node[];\n\tdstNode: Node;\n\tdstMesh?: Mesh | undefined;\n}\n\nfunction _joinLevel(document: Document, parent: Node | Scene, options: Required<JoinOptions>) {\n\tconst logger = document.getLogger();\n\tconst groups = {} as Record<string, IJoinGroup>;\n\n\t// Scan for compatible Primitives.\n\tconst children = parent.listChildren();\n\tfor (let nodeIndex = 0; nodeIndex < children.length; nodeIndex++) {\n\t\tconst node = children[nodeIndex];\n\n\t\t// Skip nodes not matching the filter.\n\t\tif (!options.filter(node)) continue;\n\n\t\t// Skip animated nodes.\n\t\tconst isAnimated = node.listParents().some((p) => p instanceof AnimationChannel);\n\t\tif (isAnimated) continue;\n\n\t\t// Skip nodes without meshes.\n\t\tconst mesh = node.getMesh();\n\t\tif (!mesh) continue;\n\n\t\t// Skip nodes with instancing; unsupported.\n\t\tif (node.getExtension('EXT_mesh_gpu_instancing')) continue;\n\n\t\t// Skip nodes with skinning; unsupported.\n\t\tif (node.getSkin()) continue;\n\n\t\tfor (const prim of mesh.listPrimitives()) {\n\t\t\t// Skip prims with morph targets; unsupported.\n\t\t\tif (prim.listTargets().length > 0) continue;\n\n\t\t\t// Skip prims with volumetric materials; unsupported.\n\t\t\tconst material = prim.getMaterial();\n\t\t\tif (material && material.getExtension('KHR_materials_volume')) continue;\n\n\t\t\tcompactPrimitive(prim);\n\t\t\tdequantizeTransformableAttributes(prim);\n\n\t\t\tlet key = createPrimGroupKey(prim);\n\n\t\t\tconst isNamed = mesh.getName() || node.getName();\n\t\t\tif (options.keepMeshes || (options.keepNamed && isNamed)) {\n\t\t\t\tkey += `|${nodeIndex}`;\n\t\t\t}\n\n\t\t\tif (!(key in groups)) {\n\t\t\t\tgroups[key] = {\n\t\t\t\t\tprims: [] as Primitive[],\n\t\t\t\t\tprimMeshes: [] as Mesh[],\n\t\t\t\t\tprimNodes: [] as Node[],\n\t\t\t\t\tdstNode: node,\n\t\t\t\t\tdstMesh: undefined,\n\t\t\t\t} as IJoinGroup;\n\t\t\t}\n\n\t\t\tconst group = groups[key];\n\t\t\tgroup.prims.push(prim);\n\t\t\tgroup.primNodes.push(node);\n\t\t}\n\t}\n\n\t// Discard single-Primitive groups.\n\tconst joinGroups = Object.values(groups).filter(({ prims }) => prims.length > 1);\n\n\t// Unlink all affected Meshes at current level, before modifying Primitives.\n\tconst srcNodes = new Set<Node>(joinGroups.flatMap((group) => group.primNodes));\n\tfor (const node of srcNodes) {\n\t\tconst mesh = node.getMesh()!;\n\t\tconst isSharedMesh = mesh.listParents().some((parent) => {\n\t\t\treturn parent.propertyType !== ROOT && node !== parent;\n\t\t});\n\t\tif (isSharedMesh) {\n\t\t\tnode.setMesh(mesh.clone());\n\t\t}\n\t}\n\n\t// Update Meshes in groups.\n\tfor (const group of joinGroups) {\n\t\tconst { dstNode, primNodes } = group;\n\t\tgroup.dstMesh = dstNode.getMesh()!;\n\t\tgroup.primMeshes = primNodes.map((node) => node.getMesh()!);\n\t}\n\n\t// Join Primitives.\n\tfor (const group of joinGroups) {\n\t\tconst { prims, primNodes, primMeshes, dstNode, dstMesh } = group as Required<IJoinGroup>;\n\t\tconst dstMatrix = dstNode.getMatrix();\n\n\t\tfor (let i = 0; i < prims.length; i++) {\n\t\t\tconst primNode = primNodes[i];\n\t\t\tconst primMesh = primMeshes[i];\n\n\t\t\tlet prim = prims[i];\n\t\t\tprimMesh.removePrimitive(prim);\n\n\t\t\t// If Primitive is still in use after being removed from the\n\t\t\t// current mesh, above, make a deep copy. Because compactPrimitive()\n\t\t\t// was applied earlier in join(), we know the full vertex streams are\n\t\t\t// used, and no accessors are shared.\n\t\t\tif (isUsed(prim)) {\n\t\t\t\tprim = prims[i] = _deepClonePrimitive(prims[i]);\n\t\t\t}\n\n\t\t\t// Transform Primitive into new local coordinate space.\n\t\t\tif (primNode !== dstNode) {\n\t\t\t\tmultiply(_matrix, invert(_matrix, dstMatrix)!, primNode.getMatrix());\n\t\t\t\ttransformPrimitive(prim, _matrix);\n\t\t\t}\n\t\t}\n\n\t\tconst dstPrim = joinPrimitives(prims);\n\t\tconst dstVertexCount = dstPrim.listAttributes()[0].getCount();\n\t\tdstMesh.addPrimitive(dstPrim);\n\n\t\tlogger.debug(\n\t\t\t`${NAME}: Joined Primitives (${prims.length}) containing ` +\n\t\t\t\t`${formatLong(dstVertexCount)} vertices under Node \"${dstNode.getName()}\".`,\n\t\t);\n\t}\n}\n\nfunction _deepClonePrimitive(src: Primitive): Primitive {\n\t// compactPrimitive already applied; no vertices are unused.\n\tconst dst = src.clone();\n\tfor (const semantic of dst.listSemantics()) {\n\t\tdst.setAttribute(semantic, dst.getAttribute(semantic)!.clone());\n\t}\n\tconst indices = dst.getIndices();\n\tif (indices) dst.setIndices(indices.clone());\n\treturn dst;\n}\n\n/**\n * Dequantize attributes that would be affected by {@link transformPrimitive},\n * to avoid invalidating our primitive group keys.\n *\n * See: https://github.com/donmccurdy/glTF-Transform/issues/844\n */\nfunction dequantizeTransformableAttributes(prim: Primitive) {\n\tfor (const semantic of ['POSITION', 'NORMAL', 'TANGENT']) {\n\t\tconst attribute = prim.getAttribute(semantic);\n\t\tif (attribute) dequantizeAttribute(attribute);\n\t}\n}\n","import { Document, Material, PropertyType, type Texture, TextureChannel } from '@gltf-transform/core';\n\n/**\n * Returns a list of {@link TextureChannel TextureChannels} used by the given\n * texture. Determination is based only on the _role_ of the textures, e.g.\n * a texture used for the `occlusionTexture` will have (at least) a red channel\n * in use. See {@link getTextureChannelMask} for bitmask alternative.\n *\n * Example:\n *\n * ```js\n * const channels = listTextureChannels(texture);\n * if (channels.includes(TextureChannel.R)) {\n *   console.log('texture red channel used');\n * }\n * ```\n */\nexport function listTextureChannels(texture: Texture): TextureChannel[] {\n\tconst mask = getTextureChannelMask(texture);\n\tconst channels = [];\n\tif (mask & TextureChannel.R) channels.push(TextureChannel.R);\n\tif (mask & TextureChannel.G) channels.push(TextureChannel.G);\n\tif (mask & TextureChannel.B) channels.push(TextureChannel.B);\n\tif (mask & TextureChannel.A) channels.push(TextureChannel.A);\n\treturn channels;\n}\n\n/**\n * Returns bitmask of all {@link TextureChannel TextureChannels} used by the\n * given texture. Determination is based only on the _role_ of the textures, e.g.\n * a texture used for the `occlusionTexture` will have (at least) a red channel.\n * See {@link listTextureChannels} for an array alternative.\n *\n * Example:\n *\n * ```js\n * const mask = getTextureChannelMask(texture);\n * if (mask & TextureChannel.R) {\n *   console.log('texture red channel used');\n * }\n * ```\n */\nexport function getTextureChannelMask(texture: Texture): number {\n\tconst document = Document.fromGraph(texture.getGraph())!;\n\tlet mask = 0x0000;\n\tfor (const edge of document.getGraph().listParentEdges(texture)) {\n\t\tconst parent = edge.getParent();\n\t\tlet { channels } = edge.getAttributes() as { channels: number | undefined };\n\n\t\tif (\n\t\t\tchannels &&\n\t\t\tedge.getName() === 'baseColorTexture' &&\n\t\t\tparent instanceof Material &&\n\t\t\tparent.getAlphaMode() === Material.AlphaMode.OPAQUE\n\t\t) {\n\t\t\tchannels &= ~TextureChannel.A;\n\t\t}\n\n\t\tif (channels) {\n\t\t\tmask |= channels;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (parent.propertyType !== PropertyType.ROOT) {\n\t\t\tdocument.getLogger().warn(`Missing attribute \".channels\" on edge, \"${edge.getName()}\".`);\n\t\t}\n\t}\n\treturn mask;\n}\n","import {\n\ttype Accessor,\n\ttype GLTF,\n\tMathUtils,\n\ttype Primitive,\n\ttype PrimitiveTarget,\n\ttype TypedArray,\n\ttype vec4,\n} from '@gltf-transform/core';\n\n/**\n * Sorts skinning weights from high to low, for each vertex of the input\n * {@link Primitive} or {@link PrimitiveTarget}, and normalizes the weights.\n * Optionally, uses the given 'limit' to remove least-significant joint\n * influences such that no vertex has more than 'limit' influences.\n *\n * Most realtime engines support a limited number of joint influences per vertex,\n * often 4 or 8. Sorting and removing the additional influences can reduce file\n * size and improve compatibility.\n *\n * Example:\n *\n * ```javascript\n * import { sortPrimitiveWeights } from '@gltf-transform/functions';\n *\n * const limit = 4;\n * for (const mesh of document.getRoot().listMeshes()) {\n * \tfor (const prim of mesh.listPrimitives()) {\n * \t\tsortPrimitiveWeights(prim, limit);\n * \t}\n * }\n * ```\n *\n * @param prim Input, to be modified in place.\n * @param limit Maximum number of joint influences per vertex. Must be a multiple of four.\n */\nexport function sortPrimitiveWeights(prim: Primitive | PrimitiveTarget, limit: number = Infinity): void {\n\tif ((Number.isFinite(limit) && limit % 4) || limit <= 0) {\n\t\tthrow new Error(`Limit must be positive multiple of four.`);\n\t}\n\n\tconst vertexCount = prim.getAttribute('POSITION')!.getCount();\n\tconst setCount = prim.listSemantics().filter((name) => name.startsWith('WEIGHTS_')).length;\n\n\t// (1) Sort.\n\n\tconst indices = new Uint16Array(setCount * 4);\n\tconst srcWeights = new Float32Array(setCount * 4);\n\tconst dstWeights = new Float32Array(setCount * 4);\n\tconst srcJoints = new Uint32Array(setCount * 4);\n\tconst dstJoints = new Uint32Array(setCount * 4);\n\n\tfor (let i = 0; i < vertexCount; i++) {\n\t\tgetVertexArray(prim, i, 'WEIGHTS', srcWeights);\n\t\tgetVertexArray(prim, i, 'JOINTS', srcJoints);\n\n\t\t// Sort indices to create a lookup table, indices[dstIndex] → srcIndex,\n\t\t// indexed into the weights and joints arrays.\n\t\tfor (let j = 0; j < setCount * 4; j++) indices[j] = j;\n\t\tindices.sort((a, b) => (srcWeights[a] > srcWeights[b] ? -1 : 1));\n\n\t\t// Sort weights and joints.\n\t\tfor (let j = 0; j < indices.length; j++) {\n\t\t\tdstWeights[j] = srcWeights[indices[j]];\n\t\t\tdstJoints[j] = srcJoints[indices[j]];\n\t\t}\n\n\t\tsetVertexArray(prim, i, 'WEIGHTS', dstWeights);\n\t\tsetVertexArray(prim, i, 'JOINTS', dstJoints);\n\t}\n\n\t// (2) Limit.\n\tfor (let i = setCount; i * 4 > limit; i--) {\n\t\tconst weights = prim.getAttribute(`WEIGHTS_${i - 1}`)!;\n\t\tconst joints = prim.getAttribute(`JOINTS_${i - 1}`)!;\n\t\tprim.setAttribute(`WEIGHTS_${i - 1}`, null);\n\t\tprim.setAttribute(`JOINTS_${i - 1}`, null);\n\t\tif (weights.listParents().length === 1) weights.dispose();\n\t\tif (joints.listParents().length === 1) joints.dispose();\n\t}\n\n\t// (3) Normalize.\n\tnormalizePrimitiveWeights(prim);\n}\n\n// Utilities.\n\ntype PrimLike = Primitive | PrimitiveTarget;\n\nfunction normalizePrimitiveWeights(prim: PrimLike): void {\n\t// TODO(feat): Convert attributes to same component types when necessary.\n\tif (!isNormalizeSafe(prim)) return;\n\n\tconst vertexCount = prim.getAttribute('POSITION')!.getCount();\n\tconst setCount = prim.listSemantics().filter((name) => name.startsWith('WEIGHTS_')).length;\n\n\tconst templateAttribute = prim.getAttribute('WEIGHTS_0')!;\n\tconst templateArray = templateAttribute.getArray()!;\n\tconst componentType = templateAttribute.getComponentType();\n\tconst normalized = templateAttribute.getNormalized();\n\tconst normalizedComponentType = normalized ? componentType : undefined;\n\tconst delta = normalized ? MathUtils.decodeNormalizedInt(1, componentType) : Number.EPSILON;\n\tconst joints = new Uint32Array(setCount * 4).fill(0);\n\tconst weights = templateArray.slice(0, setCount * 4).fill(0);\n\n\tfor (let i = 0; i < vertexCount; i++) {\n\t\tgetVertexArray(prim, i, 'JOINTS', joints);\n\t\tgetVertexArray(prim, i, 'WEIGHTS', weights, normalizedComponentType);\n\n\t\tlet weightsSum = sum(weights, normalizedComponentType);\n\n\t\tif (weightsSum !== 0 && weightsSum !== 1) {\n\t\t\t// (1) If sum of weights not within δ of 1, renormalize all weights.\n\t\t\tif (Math.abs(1 - weightsSum) > delta) {\n\t\t\t\tfor (let j = 0; j < weights.length; j++) {\n\t\t\t\t\tif (normalized) {\n\t\t\t\t\t\tconst floatValue = MathUtils.decodeNormalizedInt(weights[j], componentType);\n\t\t\t\t\t\tweights[j] = MathUtils.encodeNormalizedInt(floatValue / weightsSum, componentType);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tweights[j] /= weightsSum;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tweightsSum = sum(weights, normalizedComponentType);\n\n\t\t\t// (2) Sum of normalized weights may still be off by δ. Compensate\n\t\t\t// in least-significant weight.\n\t\t\tif (normalized && weightsSum !== 1) {\n\t\t\t\tfor (let j = weights.length - 1; j >= 0; j--) {\n\t\t\t\t\tif (weights[j] > 0) {\n\t\t\t\t\t\t// Normalized integer encoding will clamp negative values, so separate the sign.\n\t\t\t\t\t\tconst delta = 1 - weightsSum;\n\t\t\t\t\t\tweights[j] += Math.sign(delta) * MathUtils.encodeNormalizedInt(Math.abs(delta), componentType);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// (3) Remove joint indices whose weights have fallen to zero.\n\t\tfor (let j = weights.length - 1; j >= 0; j--) {\n\t\t\tif (weights[j] === 0) {\n\t\t\t\tjoints[j] = 0;\n\t\t\t}\n\t\t}\n\n\t\tsetVertexArray(prim, i, 'JOINTS', joints);\n\t\tsetVertexArray(prim, i, 'WEIGHTS', weights, normalizedComponentType);\n\t}\n}\n\n/** Lists all values of a multi-set vertex attribute (WEIGHTS_#, ...) for given vertex. */\nfunction getVertexArray(\n\tprim: PrimLike,\n\tvertexIndex: number,\n\tprefix: string,\n\ttarget: TypedArray,\n\tnormalizedComponentType?: GLTF.AccessorComponentType,\n): TypedArray {\n\tlet weights: Accessor | null;\n\tconst el = [0, 0, 0, 0] as vec4;\n\tfor (let i = 0; (weights = prim.getAttribute(`${prefix}_${i}`)); i++) {\n\t\tweights.getElement(vertexIndex, el);\n\t\tfor (let j = 0; j < 4; j++) {\n\t\t\tif (normalizedComponentType) {\n\t\t\t\ttarget[i * 4 + j] = MathUtils.encodeNormalizedInt(el[j], normalizedComponentType);\n\t\t\t} else {\n\t\t\t\ttarget[i * 4 + j] = el[j];\n\t\t\t}\n\t\t}\n\t}\n\treturn target;\n}\n\n/** Sets all values of a multi-set vertex attribute (WEIGHTS_#, ...) for given vertex. */\nfunction setVertexArray(\n\tprim: PrimLike,\n\tvertexIndex: number,\n\tprefix: string,\n\tvalues: TypedArray,\n\tnormalizedComponentType?: GLTF.AccessorComponentType,\n): void {\n\tlet weights: Accessor | null;\n\tconst el = [0, 0, 0, 0] as vec4;\n\tfor (let i = 0; (weights = prim.getAttribute(`${prefix}_${i}`)); i++) {\n\t\tfor (let j = 0; j < 4; j++) {\n\t\t\tif (normalizedComponentType) {\n\t\t\t\tel[j] = MathUtils.decodeNormalizedInt(values[i * 4 + j], normalizedComponentType);\n\t\t\t} else {\n\t\t\t\tel[j] = values[i * 4 + j];\n\t\t\t}\n\t\t}\n\t\tweights.setElement(vertexIndex, el);\n\t}\n}\n\n/** Sum an array of numbers. */\nfunction sum(values: TypedArray, normalizedComponentType?: GLTF.AccessorComponentType): number {\n\tlet sum = 0;\n\tfor (let i = 0; i < values.length; i++) {\n\t\tif (normalizedComponentType) {\n\t\t\tsum += MathUtils.decodeNormalizedInt(values[i], normalizedComponentType);\n\t\t} else {\n\t\t\tsum += values[i];\n\t\t}\n\t}\n\treturn sum;\n}\n\n/** Returns true if attribute normalization is supported for this primitive. */\nfunction isNormalizeSafe(prim: PrimLike): boolean {\n\tconst attributes = prim\n\t\t.listSemantics()\n\t\t.filter((name) => name.startsWith('WEIGHTS_'))\n\t\t.map((name) => prim.getAttribute(name)!);\n\tconst normList = attributes.map((a) => a.getNormalized());\n\tconst typeList = attributes.map((a) => a.getComponentType());\n\treturn new Set(normList).size === 1 && new Set(typeList).size === 1;\n}\n","import {\n\tAccessor,\n\tAnimationChannel,\n\ttype bbox,\n\ttype Document,\n\ttype ILogger,\n\tMathUtils,\n\ttype Mesh,\n\ttype mat4,\n\tNode,\n\tPrimitive,\n\tPrimitiveTarget,\n\tPropertyType,\n\ttype Skin,\n\ttype Transform,\n\ttype vec2,\n\ttype vec3,\n\ttype vec4,\n} from '@gltf-transform/core';\nimport type { Volume } from '@gltf-transform/extensions';\nimport { type InstancedMesh, KHRMeshQuantization } from '@gltf-transform/extensions';\nimport { fromRotationTranslationScale, fromScaling, invert, multiply as multiplyMat4 } from 'gl-matrix/mat4';\nimport { max, min, scale, transformMat4 } from 'gl-matrix/vec3';\nimport { compactPrimitive } from './compact-primitive.js';\nimport { dedup } from './dedup.js';\nimport { getPrimitiveVertexCount, VertexCountMethod } from './get-vertex-count.js';\nimport { prune } from './prune.js';\nimport { sortPrimitiveWeights } from './sort-primitive-weights.js';\nimport { assignDefaults, createTransform } from './utils.js';\n\nconst NAME = 'quantize';\n\ntype TypedArrayConstructor =\n\t| Int8ArrayConstructor\n\t| Int16ArrayConstructor\n\t| Uint8ArrayConstructor\n\t| Uint16ArrayConstructor;\nconst SIGNED_INT = [Int8Array, Int16Array, Int32Array] as TypedArrayConstructor[];\n\nconst { TRANSLATION, ROTATION, SCALE, WEIGHTS } = AnimationChannel.TargetPath;\nconst TRS_CHANNELS = [TRANSLATION, ROTATION, SCALE];\n\n/** Options for the {@link quantize} function. */\nexport interface QuantizeOptions {\n\t/** Pattern (regex) used to filter vertex attribute semantics for quantization. Default: all. */\n\tpattern?: RegExp;\n\t/** Pattern (regex) used to filter morph target semantics for quantization. Default: `options.pattern`. */\n\tpatternTargets?: RegExp;\n\t/** Bounds for quantization grid. */\n\tquantizationVolume?: 'mesh' | 'scene';\n\t/** Quantization bits for `POSITION` attributes. */\n\tquantizePosition?: number;\n\t/** Quantization bits for `NORMAL` attributes. */\n\tquantizeNormal?: number;\n\t/** Quantization bits for `TEXCOORD_*` attributes. */\n\tquantizeTexcoord?: number;\n\t/** Quantization bits for `COLOR_*` attributes. */\n\tquantizeColor?: number;\n\t/** Quantization bits for `WEIGHT_*` attributes. */\n\tquantizeWeight?: number;\n\t/** Quantization bits for application-specific (`_*`) attributes. */\n\tquantizeGeneric?: number;\n\t/** Normalize weight attributes. */\n\tnormalizeWeights?: boolean;\n\t/**\n\t * Whether to perform cleanup steps after completing the operation. Recommended, and enabled by\n\t * default. Cleanup removes temporary resources created during the operation, but may also remove\n\t * pre-existing unused or duplicate resources in the {@link Document}. Applications that require\n\t * keeping these resources may need to disable cleanup, instead calling {@link dedup} and\n\t * {@link prune} manually (with customized options) later in the processing pipeline.\n\t * @experimental\n\t */\n\tcleanup?: boolean;\n}\n\nexport const QUANTIZE_DEFAULTS: Required<Omit<QuantizeOptions, 'patternTargets'>> = {\n\tpattern: /.*/,\n\tquantizationVolume: 'mesh',\n\tquantizePosition: 14,\n\tquantizeNormal: 10,\n\tquantizeTexcoord: 12,\n\tquantizeColor: 8,\n\tquantizeWeight: 8,\n\tquantizeGeneric: 12,\n\tnormalizeWeights: true,\n\tcleanup: true,\n};\n\n/**\n * References:\n * - https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization\n * - http://www.aclockworkberry.com/normal-unpacking-quantization-errors/\n * - https://www.mathworks.com/help/dsp/ref/uniformencoder.html\n * - https://oroboro.com/compressed-unit-vectors/\n */\n\n/**\n * Quantizes vertex attributes with `KHR_mesh_quantization`, reducing the size and memory footprint\n * of the file. Conceptually, quantization refers to snapping values to regular intervals; vertex\n * positions are snapped to a 3D grid, UVs to a 2D grid, and so on. When quantized to <= 16 bits,\n * larger component types may be more compactly stored as 16-bit or 8-bit attributes.\n *\n * Often, it can be useful to quantize to precision lower than the maximum allowed by the component\n * type. Positions quantized to 14 bits in a 16-bit accessor will occupy 16 bits in VRAM, but they\n * can be compressed further for network compression with lossless encodings such as ZSTD.\n *\n * Vertex positions are shifted into [-1,1] or [0,1] range before quantization. Compensating for\n * that shift, a transform is applied to the parent {@link Node}, or inverse bind matrices for a\n * {@link Skin} if applicable. Materials using {@link KHRMaterialsVolume} are adjusted to maintain\n * appearance. In future releases, UVs may also be transformed with {@link KHRTextureTransform}.\n * Currently UVs outside of [0,1] range are not quantized.\n *\n * In most cases, quantization requires {@link KHRMeshQuantization}; the extension will be added\n * automatically when `quantize()` is applied. When applying meshopt compression with\n * {@link EXTMeshoptCompression}, quantization is usually applied before compression.\n *\n * Example:\n *\n * ```javascript\n * import { quantize } from '@gltf-transform/functions';\n *\n * await document.transform(\n *   quantize({\n *\t\tquantizePosition: 14,\n *\t\tquantizeNormal: 10,\n *   }),\n * );\n * ```\n *\n * For the inverse operation, see {@link dequantize}.\n *\n * @category Transforms\n */\nexport function quantize(_options: QuantizeOptions = QUANTIZE_DEFAULTS): Transform {\n\tconst options = assignDefaults(QUANTIZE_DEFAULTS, {\n\t\tpatternTargets: _options.pattern || QUANTIZE_DEFAULTS.pattern,\n\t\t..._options,\n\t});\n\n\treturn createTransform(NAME, async (document: Document): Promise<void> => {\n\t\tconst logger = document.getLogger();\n\t\tconst root = document.getRoot();\n\n\t\t// Compute vertex position quantization volume.\n\t\tlet nodeTransform: VectorTransform<vec3> | undefined;\n\t\tif (options.quantizationVolume === 'scene') {\n\t\t\tnodeTransform = getNodeTransform(expandBounds(root.listMeshes().map(getPositionQuantizationVolume)));\n\t\t}\n\n\t\t// Quantize mesh primitives.\n\t\tfor (const mesh of document.getRoot().listMeshes()) {\n\t\t\tif (options.quantizationVolume === 'mesh') {\n\t\t\t\tnodeTransform = getNodeTransform(getPositionQuantizationVolume(mesh));\n\t\t\t}\n\n\t\t\tif (nodeTransform && options.pattern.test('POSITION')) {\n\t\t\t\ttransformMeshParents(document, mesh, nodeTransform);\n\t\t\t\ttransformMeshMaterials(mesh, 1 / nodeTransform.scale);\n\t\t\t}\n\n\t\t\tfor (const prim of mesh.listPrimitives()) {\n\t\t\t\tconst renderCount = getPrimitiveVertexCount(prim, VertexCountMethod.RENDER);\n\t\t\t\tconst uploadCount = getPrimitiveVertexCount(prim, VertexCountMethod.UPLOAD);\n\t\t\t\tif (renderCount < uploadCount / 2) {\n\t\t\t\t\tcompactPrimitive(prim);\n\t\t\t\t}\n\t\t\t\tquantizePrimitive(document, prim, nodeTransform!, options);\n\t\t\t\tfor (const target of prim.listTargets()) {\n\t\t\t\t\tquantizePrimitive(document, target, nodeTransform!, options);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst needsExtension = root\n\t\t\t.listMeshes()\n\t\t\t.flatMap((mesh) => mesh.listPrimitives())\n\t\t\t.some(isQuantizedPrimitive);\n\t\tif (needsExtension) {\n\t\t\tdocument.createExtension(KHRMeshQuantization).setRequired(true);\n\t\t}\n\n\t\tif (options.cleanup) {\n\t\t\tawait document.transform(\n\t\t\t\tprune({\n\t\t\t\t\tpropertyTypes: [PropertyType.ACCESSOR, PropertyType.SKIN, PropertyType.MATERIAL],\n\t\t\t\t\tkeepAttributes: true,\n\t\t\t\t\tkeepIndices: true,\n\t\t\t\t\tkeepLeaves: true,\n\t\t\t\t\tkeepSolidTextures: true,\n\t\t\t\t}),\n\t\t\t\tdedup({\n\t\t\t\t\tpropertyTypes: [PropertyType.ACCESSOR, PropertyType.MATERIAL, PropertyType.SKIN],\n\t\t\t\t\tkeepUniqueNames: true,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tlogger.debug(`${NAME}: Complete.`);\n\t});\n}\n\nfunction quantizePrimitive(\n\tdocument: Document,\n\tprim: Primitive | PrimitiveTarget,\n\tnodeTransform: VectorTransform<vec3>,\n\toptions: Required<QuantizeOptions>,\n): void {\n\tconst isTarget = prim instanceof PrimitiveTarget;\n\tconst logger = document.getLogger();\n\n\tfor (const semantic of prim.listSemantics()) {\n\t\tif (!isTarget && !options.pattern.test(semantic)) continue;\n\t\tif (isTarget && !options.patternTargets.test(semantic)) continue;\n\n\t\tconst srcAttribute = prim.getAttribute(semantic)!;\n\n\t\tconst { bits, ctor } = getQuantizationSettings(semantic, srcAttribute, logger, options);\n\n\t\tif (!ctor) continue;\n\t\tif (bits < 8 || bits > 16) throw new Error(`${NAME}: Requires bits = 8–16.`);\n\t\tif (srcAttribute.getComponentSize() <= bits / 8) continue;\n\n\t\tconst dstAttribute = srcAttribute.clone();\n\n\t\t// Remap position data.\n\t\tif (semantic === 'POSITION') {\n\t\t\tconst scale = nodeTransform.scale;\n\t\t\tconst transform: mat4 = [] as unknown as mat4;\n\t\t\t// Morph targets are relative offsets, don't translate them.\n\t\t\tprim instanceof Primitive\n\t\t\t\t? invert(transform, fromTransform(nodeTransform))\n\t\t\t\t: fromScaling(transform, [1 / scale, 1 / scale, 1 / scale]);\n\t\t\tfor (let i = 0, el: vec3 = [0, 0, 0], il = dstAttribute.getCount(); i < il; i++) {\n\t\t\t\tdstAttribute.getElement(i, el);\n\t\t\t\tdstAttribute.setElement(i, transformMat4(el, el, transform) as vec3);\n\t\t\t}\n\t\t}\n\n\t\t// Quantize the vertex attribute.\n\t\tquantizeAttribute(dstAttribute, ctor, bits);\n\t\tprim.setAttribute(semantic, dstAttribute);\n\t}\n\n\t// Normalize skinning weights.\n\tif (options.normalizeWeights && prim.getAttribute('WEIGHTS_0')) {\n\t\tsortPrimitiveWeights(prim, Infinity);\n\t}\n\n\tif (\n\t\tprim instanceof Primitive &&\n\t\tprim.getIndices() &&\n\t\tprim.listAttributes().length &&\n\t\tprim.listAttributes()[0]!.getCount() < 65535\n\t) {\n\t\tconst indices = prim.getIndices()!;\n\t\tindices.setArray(new Uint16Array(indices.getArray()!));\n\t}\n}\n\n/** Computes node quantization transforms in local space. */\nfunction getNodeTransform(volume: bbox): VectorTransform<vec3> {\n\tconst { min, max } = volume;\n\n\t// Scaling factor transforms [-1,1] box to the mesh AABB in local space.\n\t// See: https://github.com/donmccurdy/glTF-Transform/issues/328\n\tconst scale = Math.max(\n\t\t(max[0] - min[0]) / 2, // Divide because interval [-1,1] has length 2.\n\t\t(max[1] - min[1]) / 2,\n\t\t(max[2] - min[2]) / 2,\n\t);\n\n\t// Original center of the mesh, in local space.\n\tconst offset: vec3 = [\n\t\tmin[0] + (max[0] - min[0]) / 2,\n\t\tmin[1] + (max[1] - min[1]) / 2,\n\t\tmin[2] + (max[2] - min[2]) / 2,\n\t];\n\n\treturn { offset, scale };\n}\n\n/** Applies corrective scale and offset to nodes referencing a quantized Mesh. */\nfunction transformMeshParents(document: Document, mesh: Mesh, nodeTransform: VectorTransform<vec3>): void {\n\tconst transformMatrix = fromTransform(nodeTransform);\n\tfor (const parent of mesh.listParents()) {\n\t\tif (!(parent instanceof Node)) continue;\n\n\t\tconst animChannels = parent.listParents().filter((p) => p instanceof AnimationChannel) as AnimationChannel[];\n\t\tconst isAnimated = animChannels.some((channel) => TRS_CHANNELS.includes(channel.getTargetPath()!));\n\t\tconst isParentNode = parent.listChildren().length > 0;\n\n\t\tconst skin = parent.getSkin();\n\t\tif (skin) {\n\t\t\tparent.setSkin(transformSkin(skin, nodeTransform));\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst batch = parent.getExtension<InstancedMesh>('EXT_mesh_gpu_instancing');\n\t\tif (batch) {\n\t\t\tparent.setExtension('EXT_mesh_gpu_instancing', transformBatch(document, batch, nodeTransform));\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet targetNode: Node;\n\t\tif (isParentNode || isAnimated) {\n\t\t\ttargetNode = document.createNode('').setMesh(mesh);\n\t\t\tparent.addChild(targetNode).setMesh(null);\n\t\t\tanimChannels\n\t\t\t\t.filter((channel) => channel.getTargetPath() === WEIGHTS)\n\t\t\t\t.forEach((channel) => channel.setTargetNode(targetNode));\n\t\t} else {\n\t\t\ttargetNode = parent;\n\t\t}\n\n\t\tconst nodeMatrix = targetNode.getMatrix();\n\t\tmultiplyMat4(nodeMatrix, nodeMatrix, transformMatrix);\n\t\ttargetNode.setMatrix(nodeMatrix);\n\t}\n}\n\n/** Applies corrective scale and offset to skin IBMs. */\nfunction transformSkin(skin: Skin, nodeTransform: VectorTransform<vec3>): Skin {\n\tskin = skin.clone(); // quantize() does cleanup.\n\tconst transformMatrix = fromTransform(nodeTransform);\n\tconst inverseBindMatrices = skin.getInverseBindMatrices()!.clone();\n\tconst ibm = [] as unknown as mat4;\n\tfor (let i = 0, count = inverseBindMatrices.getCount(); i < count; i++) {\n\t\tinverseBindMatrices.getElement(i, ibm);\n\t\tmultiplyMat4(ibm, ibm, transformMatrix);\n\t\tinverseBindMatrices.setElement(i, ibm);\n\t}\n\treturn skin.setInverseBindMatrices(inverseBindMatrices);\n}\n\n/** Applies corrective scale and offset to GPU instancing batches. */\nfunction transformBatch(document: Document, batch: InstancedMesh, nodeTransform: VectorTransform<vec3>): InstancedMesh {\n\tif (!batch.getAttribute('TRANSLATION') && !batch.getAttribute('ROTATION') && !batch.getAttribute('SCALE')) {\n\t\treturn batch;\n\t}\n\n\tbatch = batch.clone(); // quantize() does cleanup.\n\n\tlet instanceTranslation = batch.getAttribute('TRANSLATION')?.clone();\n\tconst instanceRotation = batch.getAttribute('ROTATION')?.clone();\n\tlet instanceScale = batch.getAttribute('SCALE')?.clone();\n\n\tconst tpl = (instanceTranslation || instanceRotation || instanceScale)!;\n\n\tconst T_IDENTITY = [0, 0, 0] as vec3;\n\tconst R_IDENTITY = [0, 0, 0, 1] as vec4;\n\tconst S_IDENTITY = [1, 1, 1] as vec3;\n\n\t// Transformed batch may now require instance translation or scale.\n\t// See: https://github.com/donmccurdy/glTF-Transform/issues/1584\n\n\tif (!instanceTranslation && nodeTransform.offset) {\n\t\tinstanceTranslation = document.createAccessor().setType('VEC3').setArray(makeArray(tpl.getCount(), T_IDENTITY));\n\t}\n\n\tif (!instanceScale && nodeTransform.scale) {\n\t\tinstanceScale = document.createAccessor().setType('VEC3').setArray(makeArray(tpl.getCount(), S_IDENTITY));\n\t}\n\n\tconst t = [0, 0, 0] as vec3;\n\tconst r = [0, 0, 0, 1] as vec4;\n\tconst s = [1, 1, 1] as vec3;\n\n\t// biome-ignore format: Readability.\n\tconst instanceMatrix = [\n\t\t1, 0, 0, 0,\n\t\t0, 1, 0, 0,\n\t\t0, 0, 1, 0,\n\t\t0, 0, 0, 1,\n\t] as mat4;\n\n\tconst transformMatrix = fromTransform(nodeTransform);\n\n\tfor (let i = 0, count = tpl.getCount(); i < count; i++) {\n\t\tMathUtils.compose(\n\t\t\tinstanceTranslation ? (instanceTranslation.getElement(i, t) as vec3) : T_IDENTITY,\n\t\t\tinstanceRotation ? (instanceRotation.getElement(i, r) as vec4) : R_IDENTITY,\n\t\t\tinstanceScale ? (instanceScale.getElement(i, s) as vec3) : S_IDENTITY,\n\t\t\tinstanceMatrix,\n\t\t);\n\n\t\tmultiplyMat4(instanceMatrix, instanceMatrix, transformMatrix);\n\n\t\tMathUtils.decompose(instanceMatrix, t, r, s);\n\n\t\tif (instanceTranslation) instanceTranslation.setElement(i, t);\n\t\tif (instanceRotation) instanceRotation.setElement(i, r);\n\t\tif (instanceScale) instanceScale.setElement(i, s);\n\t}\n\n\tif (instanceTranslation) batch.setAttribute('TRANSLATION', instanceTranslation);\n\tif (instanceRotation) batch.setAttribute('ROTATION', instanceRotation);\n\tif (instanceScale) batch.setAttribute('SCALE', instanceScale);\n\n\treturn batch;\n}\n\n/** Applies corrective scale to volumetric materials, which give thickness in local units. */\nfunction transformMeshMaterials(mesh: Mesh, scale: number) {\n\tfor (const prim of mesh.listPrimitives()) {\n\t\tlet material = prim.getMaterial();\n\t\tif (!material) continue;\n\n\t\tlet volume = material.getExtension<Volume>('KHR_materials_volume');\n\t\tif (!volume || volume.getThicknessFactor() <= 0) continue;\n\n\t\t// quantize() does cleanup.\n\t\tvolume = volume.clone().setThicknessFactor(volume.getThicknessFactor() * scale);\n\t\tmaterial = material.clone().setExtension('KHR_materials_volume', volume);\n\t\tprim.setMaterial(material);\n\t}\n}\n\n/**\n * Quantizes an attribute to the given parameters.\n *\n * Uniformly remap 32-bit floats to reduced-precision 8- or 16-bit integers, so\n * that there are only 2^N unique values, for N within [8, 16].\n *\n * See: https://github.com/donmccurdy/glTF-Transform/issues/208\n */\nfunction quantizeAttribute(attribute: Accessor, ctor: TypedArrayConstructor, bits: number): void {\n\tconst dstArray = new ctor(attribute.getArray()!.length);\n\n\tconst signBits = SIGNED_INT.includes(ctor) ? 1 : 0;\n\tconst quantBits = bits - signBits;\n\tconst storageBits = ctor.BYTES_PER_ELEMENT * 8 - signBits;\n\n\tconst scale = Math.pow(2, quantBits) - 1;\n\tconst lo = storageBits - quantBits;\n\tconst hi = 2 * quantBits - storageBits;\n\tconst range = [signBits > 0 ? -1 : 0, 1] as vec2;\n\n\tfor (let i = 0, di = 0, el: number[] = []; i < attribute.getCount(); i++) {\n\t\tattribute.getElement(i, el);\n\t\tfor (let j = 0; j < el.length; j++) {\n\t\t\t// Clamp to range.\n\t\t\tlet value = clamp(el[j], range);\n\n\t\t\t// Map [0.0 ... 1.0] to [0 ... scale].\n\t\t\tvalue = Math.round(Math.abs(value) * scale);\n\n\t\t\t// Replicate msb to missing lsb.\n\t\t\tvalue = (value << lo) | (value >> hi);\n\n\t\t\t// Restore sign.\n\t\t\tdstArray[di++] = value * Math.sign(el[j]);\n\t\t}\n\t}\n\n\t// TODO(feat): Support sparse accessors, https://github.com/donmccurdy/glTF-Transform/issues/795\n\tattribute.setArray(dstArray).setNormalized(true).setSparse(false);\n}\n\nfunction getQuantizationSettings(\n\tsemantic: string,\n\tattribute: Accessor,\n\tlogger: ILogger,\n\toptions: Required<QuantizeOptions>,\n): { bits: number; ctor?: TypedArrayConstructor } {\n\tconst min = attribute.getMinNormalized([]);\n\tconst max = attribute.getMaxNormalized([]);\n\n\tlet bits: number;\n\tlet ctor: TypedArrayConstructor;\n\n\tif (semantic === 'POSITION') {\n\t\tbits = options.quantizePosition;\n\t\tctor = bits <= 8 ? Int8Array : Int16Array;\n\t} else if (semantic === 'NORMAL' || semantic === 'TANGENT') {\n\t\tbits = options.quantizeNormal;\n\t\tctor = bits <= 8 ? Int8Array : Int16Array;\n\t} else if (semantic.startsWith('COLOR_')) {\n\t\tbits = options.quantizeColor;\n\t\tctor = bits <= 8 ? Uint8Array : Uint16Array;\n\t} else if (semantic.startsWith('TEXCOORD_')) {\n\t\tif (min.some((v) => v < 0) || max.some((v) => v > 1)) {\n\t\t\tlogger.warn(`${NAME}: Skipping ${semantic}; out of [0,1] range.`);\n\t\t\treturn { bits: -1 };\n\t\t}\n\t\tbits = options.quantizeTexcoord;\n\t\tctor = bits <= 8 ? Uint8Array : Uint16Array;\n\t} else if (semantic.startsWith('JOINTS_')) {\n\t\tbits = Math.max(...attribute.getMax([])) <= 255 ? 8 : 16;\n\t\tctor = bits <= 8 ? Uint8Array : Uint16Array;\n\t\tif (attribute.getComponentSize() > bits / 8) {\n\t\t\tattribute.setArray(new ctor(attribute.getArray()!));\n\t\t}\n\t\treturn { bits: -1 };\n\t} else if (semantic.startsWith('WEIGHTS_')) {\n\t\tif (min.some((v) => v < 0) || max.some((v) => v > 1)) {\n\t\t\tlogger.warn(`${NAME}: Skipping ${semantic}; out of [0,1] range.`);\n\t\t\treturn { bits: -1 };\n\t\t}\n\t\tbits = options.quantizeWeight;\n\t\tctor = bits <= 8 ? Uint8Array : Uint16Array;\n\t} else if (semantic.startsWith('_')) {\n\t\tif (min.some((v) => v < -1) || max.some((v) => v > 1)) {\n\t\t\tlogger.warn(`${NAME}: Skipping ${semantic}; out of [-1,1] range.`);\n\t\t\treturn { bits: -1 };\n\t\t}\n\t\tbits = options.quantizeGeneric;\n\t\tctor = min.some((v) => v < 0)\n\t\t\t? (ctor = bits <= 8 ? Int8Array : Int16Array)\n\t\t\t: (ctor = bits <= 8 ? Uint8Array : Uint16Array);\n\t} else {\n\t\tthrow new Error(`${NAME}: Unexpected semantic, \"${semantic}\".`);\n\t}\n\n\treturn { bits, ctor };\n}\n\nfunction getPositionQuantizationVolume(mesh: Mesh): bbox {\n\tconst positions: Accessor[] = [];\n\tconst relativePositions: Accessor[] = [];\n\tfor (const prim of mesh.listPrimitives()) {\n\t\tconst attribute = prim.getAttribute('POSITION');\n\t\tif (attribute) positions.push(attribute);\n\t\tfor (const target of prim.listTargets()) {\n\t\t\tconst attribute = target.getAttribute('POSITION');\n\t\t\tif (attribute) relativePositions.push(attribute);\n\t\t}\n\t}\n\n\tif (positions.length === 0) {\n\t\tthrow new Error(`${NAME}: Missing \"POSITION\" attribute.`);\n\t}\n\n\tconst bbox = flatBounds<vec3>(positions, 3);\n\n\t// Morph target quantization volume is computed differently. First, ensure that the origin\n\t// <0, 0, 0> is in the quantization volume. Because we can't offset target positions (they're\n\t// relative deltas), default remapping will only map to a [-2, 2] AABB. Double the bounding box\n\t// to ensure scaling puts them within a [-1, 1] AABB instead.\n\tif (relativePositions.length > 0) {\n\t\tconst { min: relMin, max: relMax } = flatBounds<vec3>(relativePositions, 3);\n\t\tmin(bbox.min, bbox.min, min(relMin, scale(relMin, relMin, 2), [0, 0, 0]));\n\t\tmax(bbox.max, bbox.max, max(relMax, scale(relMax, relMax, 2), [0, 0, 0]));\n\t}\n\n\treturn bbox;\n}\n\nfunction isQuantizedAttribute(semantic: string, attribute: Accessor): boolean {\n\t// https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#meshes-overview\n\tconst componentSize = attribute.getComponentSize();\n\tif (semantic === 'POSITION') return componentSize < 4;\n\tif (semantic === 'NORMAL') return componentSize < 4;\n\tif (semantic === 'TANGENT') return componentSize < 4;\n\tif (semantic.startsWith('TEXCOORD_')) {\n\t\tconst componentType = attribute.getComponentType();\n\t\tconst normalized = attribute.getNormalized();\n\t\treturn (\n\t\t\tcomponentSize < 4 &&\n\t\t\t!(normalized && componentType === Accessor.ComponentType.UNSIGNED_BYTE) &&\n\t\t\t!(normalized && componentType === Accessor.ComponentType.UNSIGNED_SHORT)\n\t\t);\n\t}\n\treturn false;\n}\n\nfunction isQuantizedPrimitive(prim: Primitive | PrimitiveTarget): boolean {\n\tfor (const semantic of prim.listSemantics()) {\n\t\tconst attribute = prim.getAttribute('POSITION')!;\n\t\tif (isQuantizedAttribute(semantic, attribute)) {\n\t\t\treturn true;\n\t\t}\n\t}\n\tif (prim.propertyType === PropertyType.PRIMITIVE) {\n\t\treturn prim.listTargets().some(isQuantizedPrimitive);\n\t}\n\treturn false;\n}\n\n/** Computes total min and max of all Accessors in a list. */\nfunction flatBounds<T = vec2 | vec3>(accessors: Accessor[], elementSize: number): { min: T; max: T } {\n\tconst min: number[] = new Array(elementSize).fill(Infinity);\n\tconst max: number[] = new Array(elementSize).fill(-Infinity);\n\n\tconst tmpMin: number[] = [];\n\tconst tmpMax: number[] = [];\n\n\tfor (const accessor of accessors) {\n\t\taccessor.getMinNormalized(tmpMin);\n\t\taccessor.getMaxNormalized(tmpMax);\n\t\tfor (let i = 0; i < elementSize; i++) {\n\t\t\tmin[i] = Math.min(min[i], tmpMin[i]);\n\t\t\tmax[i] = Math.max(max[i], tmpMax[i]);\n\t\t}\n\t}\n\n\treturn { min, max } as unknown as { min: T; max: T };\n}\n\nfunction expandBounds(bboxes: bbox[]): bbox {\n\tconst result = bboxes[0];\n\tfor (const bbox of bboxes) {\n\t\tmin(result.min, result.min, bbox.min);\n\t\tmax(result.max, result.max, bbox.max);\n\t}\n\treturn result;\n}\n\ninterface VectorTransform<T = vec2 | vec3 | vec4> {\n\toffset: T;\n\tscale: number;\n}\n\nfunction fromTransform(transform: VectorTransform<vec3>): mat4 {\n\treturn fromRotationTranslationScale([] as unknown as mat4, [0, 0, 0, 1], transform.offset, [\n\t\ttransform.scale,\n\t\ttransform.scale,\n\t\ttransform.scale,\n\t]) as mat4;\n}\n\nfunction clamp(value: number, range: vec2): number {\n\treturn Math.min(Math.max(value, range[0]), range[1]);\n}\n\nfunction makeArray(elementCount: number, initialElement: vec2 | vec3 | vec4) {\n\tconst elementSize = initialElement.length;\n\tconst array = new Float32Array(elementCount * elementSize);\n\n\tfor (let i = 0; i < elementCount; i++) {\n\t\tarray.set(initialElement, i * elementSize);\n\t}\n\n\treturn array;\n}\n","import { type Accessor, type Document, type GLTF, Primitive, PropertyType, type Transform } from '@gltf-transform/core';\nimport type { MeshoptEncoder } from 'meshoptimizer';\nimport { compactAttribute } from './compact-primitive.js';\nimport { prune } from './prune.js';\nimport { assignDefaults, createTransform, deepListAttributes, SetMap, shallowCloneAccessor } from './utils.js';\n\nconst NAME = 'reorder';\n\n/** Options for the {@link reorder} function. */\nexport interface ReorderOptions {\n\t/** MeshoptEncoder instance. */\n\tencoder: unknown;\n\t/**\n\t * Whether the order should be optimal for transmission size (recommended for Web)\n\t * or for GPU rendering performance. Default is 'size'.\n\t */\n\ttarget?: 'size' | 'performance';\n\t/**\n\t * Whether to perform cleanup steps after completing the operation. Recommended, and enabled by\n\t * default. Cleanup removes temporary resources created during the operation, but may also remove\n\t * pre-existing unused or duplicate resources in the {@link Document}. Applications that require\n\t * keeping these resources may need to disable cleanup, instead calling {@link dedup} and\n\t * {@link prune} manually (with customized options) later in the processing pipeline.\n\t * @experimental\n\t */\n\tcleanup?: boolean;\n}\n\nconst REORDER_DEFAULTS: Required<Omit<ReorderOptions, 'encoder'>> = {\n\ttarget: 'size',\n\tcleanup: true,\n};\n\n/**\n * Optimizes {@link Mesh} {@link Primitive Primitives} for locality of reference. Choose whether\n * the order should be optimal for transmission size (recommended for Web) or for GPU rendering\n * performance. Requires a MeshoptEncoder instance from the Meshoptimizer library.\n *\n * Example:\n *\n * ```ts\n * import { MeshoptEncoder } from 'meshoptimizer';\n * import { reorder } from '@gltf-transform/functions';\n *\n * await MeshoptEncoder.ready;\n *\n * await document.transform(\n * \treorder({encoder: MeshoptEncoder})\n * );\n * ```\n *\n * @category Transforms\n */\nexport function reorder(_options: ReorderOptions): Transform {\n\tconst options = assignDefaults(REORDER_DEFAULTS, _options);\n\tconst encoder = options.encoder as typeof MeshoptEncoder | undefined;\n\n\tif (!encoder) {\n\t\tthrow new Error(`${NAME}: encoder dependency required — install \"meshoptimizer\".`);\n\t}\n\n\treturn createTransform(NAME, async (document: Document): Promise<void> => {\n\t\tconst logger = document.getLogger();\n\n\t\tawait encoder.ready;\n\n\t\tconst plan = createLayoutPlan(document);\n\n\t\tfor (const srcIndices of plan.indicesToAttributes.keys()) {\n\t\t\tlet indicesArray = srcIndices.getArray()!;\n\t\t\tif (!(indicesArray instanceof Uint32Array)) {\n\t\t\t\tindicesArray = new Uint32Array(indicesArray);\n\t\t\t} else {\n\t\t\t\tindicesArray = indicesArray.slice();\n\t\t\t}\n\n\t\t\t// Compute optimal order.\n\t\t\tconst [remap, unique] = encoder.reorderMesh(\n\t\t\t\tindicesArray,\n\t\t\t\tplan.indicesToMode.get(srcIndices) === Primitive.Mode.TRIANGLES,\n\t\t\t\toptions.target === 'size',\n\t\t\t);\n\n\t\t\tconst dstIndices = shallowCloneAccessor(document, srcIndices);\n\t\t\tdstIndices.setArray(unique <= 65534 ? new Uint16Array(indicesArray) : indicesArray);\n\n\t\t\t// Update affected primitives.\n\t\t\tfor (const srcAttribute of plan.indicesToAttributes.get(srcIndices)) {\n\t\t\t\tconst dstAttribute = shallowCloneAccessor(document, srcAttribute);\n\t\t\t\tcompactAttribute(srcAttribute, srcIndices, remap as Uint32Array<ArrayBuffer>, dstAttribute, unique);\n\n\t\t\t\tfor (const prim of plan.indicesToPrimitives.get(srcIndices)) {\n\t\t\t\t\tif (prim.getIndices() === srcIndices) {\n\t\t\t\t\t\tprim.swap(srcIndices, dstIndices);\n\t\t\t\t\t}\n\n\t\t\t\t\tprim.swap(srcAttribute, dstAttribute);\n\t\t\t\t\tfor (const target of prim.listTargets()) {\n\t\t\t\t\t\ttarget.swap(srcAttribute, dstAttribute);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Clean up any attributes left unused by earlier cloning.\n\t\tif (options.cleanup) {\n\t\t\tawait document.transform(\n\t\t\t\tprune({\n\t\t\t\t\tpropertyTypes: [PropertyType.ACCESSOR],\n\t\t\t\t\tkeepAttributes: true,\n\t\t\t\t\tkeepIndices: true,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tif (!plan.indicesToAttributes.size) {\n\t\t\tlogger.warn(`${NAME}: No qualifying primitives found; may need to weld first.`);\n\t\t} else {\n\t\t\tlogger.debug(`${NAME}: Complete.`);\n\t\t}\n\t});\n}\n\n/** @hidden */\ninterface LayoutPlan {\n\tindicesToMode: Map<Accessor, GLTF.MeshPrimitiveMode>;\n\tindicesToPrimitives: SetMap<Accessor, Primitive>;\n\tindicesToAttributes: SetMap<Accessor, Accessor>;\n\tattributesToPrimitives: SetMap<Accessor, Primitive>;\n}\n\n/**\n * Constructs a plan for processing vertex streams, based on unique\n * index:attribute[] groups. Where different indices are used with the same\n * attributes, we'll end up splitting the primitives to not share attributes,\n * which appears to be consistent with the Meshopt implementation.\n *\n * @hidden\n */\nfunction createLayoutPlan(document: Document): LayoutPlan {\n\tconst indicesToMode = new Map<Accessor, GLTF.MeshPrimitiveMode>();\n\tconst indicesToPrimitives = new SetMap<Accessor, Primitive>();\n\tconst indicesToAttributes = new SetMap<Accessor, Accessor>();\n\tconst attributesToPrimitives = new SetMap<Accessor, Primitive>();\n\n\tfor (const mesh of document.getRoot().listMeshes()) {\n\t\tfor (const prim of mesh.listPrimitives()) {\n\t\t\tconst indices = prim.getIndices();\n\t\t\tif (!indices) continue;\n\n\t\t\tindicesToMode.set(indices, prim.getMode());\n\t\t\tindicesToPrimitives.add(indices, prim);\n\n\t\t\tfor (const attribute of deepListAttributes(prim)) {\n\t\t\t\tindicesToAttributes.add(indices, attribute);\n\t\t\t\tattributesToPrimitives.add(attribute, prim);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { indicesToPrimitives, indicesToAttributes, indicesToMode, attributesToPrimitives };\n}\n","import type { Document, Transform } from '@gltf-transform/core';\nimport { EXTMeshoptCompression } from '@gltf-transform/extensions';\nimport type { MeshoptEncoder } from 'meshoptimizer';\nimport { QUANTIZE_DEFAULTS, type QuantizeOptions, quantize } from './quantize.js';\nimport { reorder } from './reorder.js';\nimport { assignDefaults, createTransform } from './utils.js';\n\nexport interface MeshoptOptions extends Omit<QuantizeOptions, 'pattern' | 'patternTargets'> {\n\tencoder: unknown;\n\tlevel?: 'medium' | 'high';\n}\n\nexport const MESHOPT_DEFAULTS: Required<Omit<MeshoptOptions, 'encoder'>> = {\n\tlevel: 'high',\n\t...QUANTIZE_DEFAULTS,\n};\n\nconst NAME = 'meshopt';\n\n/**\n * Applies Meshopt compression using {@link EXTMeshoptCompression EXT_meshopt_compression}.\n * This type of compression can reduce the size of point, line, and triangle geometry,\n * morph targets, and animation data.\n *\n * This function is a thin wrapper around {@link reorder}, {@link quantize}, and\n * {@link EXTMeshoptCompression}, and exposes relatively few configuration options.\n * To access more options (like quantization bits) direct use of the underlying\n * functions is recommended.\n *\n * Example:\n *\n * ```javascript\n * import { MeshoptEncoder } from 'meshoptimizer';\n * import { meshopt } from '@gltf-transform/functions';\n *\n * await MeshoptEncoder.ready;\n *\n * await document.transform(\n *   meshopt({encoder: MeshoptEncoder, level: 'medium'})\n * );\n * ```\n *\n * Compression is deferred until generating output with an I/O class.\n *\n * @category Transforms\n */\nexport function meshopt(_options: MeshoptOptions): Transform {\n\tconst options = assignDefaults(MESHOPT_DEFAULTS, _options);\n\tconst encoder = options.encoder as typeof MeshoptEncoder | undefined;\n\n\tif (!encoder) {\n\t\tthrow new Error(`${NAME}: encoder dependency required — install \"meshoptimizer\".`);\n\t}\n\n\treturn createTransform(NAME, async (document: Document): Promise<void> => {\n\t\tlet pattern: RegExp;\n\t\tlet patternTargets: RegExp;\n\t\tlet quantizeNormal = options.quantizeNormal;\n\n\t\tif (document.getRoot().listAccessors().length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\t// IMPORTANT: Vertex attributes should be quantized in 'high' mode IFF they are\n\t\t// _not_ filtered in 'packages/extensions/src/ext-meshopt-compression/encoder.ts'.\n\t\t// Note that normals and tangents use octahedral filters, but _morph_ normals\n\t\t// and tangents do not.\n\t\t// See: https://github.com/donmccurdy/glTF-Transform/issues/1142\n\t\tif (options.level === 'medium') {\n\t\t\tpattern = /.*/;\n\t\t\tpatternTargets = /.*/;\n\t\t} else {\n\t\t\tpattern = /^(POSITION|TEXCOORD|JOINTS|WEIGHTS|COLOR)(_\\d+)?$/;\n\t\t\tpatternTargets = /^(POSITION|TEXCOORD|JOINTS|WEIGHTS|COLOR|NORMAL|TANGENT)(_\\d+)?$/;\n\t\t\tquantizeNormal = Math.min(quantizeNormal, 8); // See meshopt::getMeshoptFilter.\n\t\t}\n\n\t\tawait document.transform(\n\t\t\treorder({\n\t\t\t\tencoder: encoder,\n\t\t\t\ttarget: 'size',\n\t\t\t}),\n\t\t\tquantize({\n\t\t\t\t...options,\n\t\t\t\tpattern,\n\t\t\t\tpatternTargets,\n\t\t\t\tquantizeNormal,\n\t\t\t}),\n\t\t);\n\n\t\tdocument\n\t\t\t.createExtension(EXTMeshoptCompression)\n\t\t\t.setRequired(true)\n\t\t\t.setEncoderOptions({\n\t\t\t\tmethod:\n\t\t\t\t\toptions.level === 'medium'\n\t\t\t\t\t\t? EXTMeshoptCompression.EncoderMethod.QUANTIZE\n\t\t\t\t\t\t: EXTMeshoptCompression.EncoderMethod.FILTER,\n\t\t\t});\n\t});\n}\n","import type { Document, Texture, Transform } from '@gltf-transform/core';\nimport {\n\tKHRMaterialsIOR,\n\tKHRMaterialsPBRSpecularGlossiness,\n\tKHRMaterialsSpecular,\n\ttype PBRSpecularGlossiness,\n} from '@gltf-transform/extensions';\nimport { createTransform, rewriteTexture } from './utils.js';\n\nconst NAME = 'metalRough';\n\nexport interface MetalRoughOptions {}\n\nconst METALROUGH_DEFAULTS: Required<MetalRoughOptions> = {};\n\n/**\n * Convert {@link Material}s from spec/gloss PBR workflow to metal/rough PBR workflow,\n * removing `KHR_materials_pbrSpecularGlossiness` and adding `KHR_materials_ior` and\n * `KHR_materials_specular`. The metal/rough PBR workflow is preferred for most use cases,\n * and is a prerequisite for other advanced PBR extensions provided by glTF.\n *\n * No options are currently implemented for this function.\n *\n * @category Transforms\n */\nexport function metalRough(_options: MetalRoughOptions = METALROUGH_DEFAULTS): Transform {\n\treturn createTransform(NAME, async (doc: Document): Promise<void> => {\n\t\tconst logger = doc.getLogger();\n\n\t\tconst extensionsUsed = doc\n\t\t\t.getRoot()\n\t\t\t.listExtensionsUsed()\n\t\t\t.map((ext) => ext.extensionName);\n\t\tif (!extensionsUsed.includes('KHR_materials_pbrSpecularGlossiness')) {\n\t\t\tlogger.warn(`${NAME}: KHR_materials_pbrSpecularGlossiness not found on document.`);\n\t\t\treturn;\n\t\t}\n\n\t\tconst iorExtension = doc.createExtension(KHRMaterialsIOR);\n\t\tconst specExtension = doc.createExtension(KHRMaterialsSpecular);\n\t\tconst specGlossExtension = doc.createExtension(KHRMaterialsPBRSpecularGlossiness);\n\n\t\tconst inputTextures = new Set<Texture | null>();\n\n\t\tfor (const material of doc.getRoot().listMaterials()) {\n\t\t\tconst specGloss = material.getExtension<PBRSpecularGlossiness>('KHR_materials_pbrSpecularGlossiness');\n\t\t\tif (!specGloss) continue;\n\n\t\t\t// Create specular extension.\n\t\t\tconst specular = specExtension\n\t\t\t\t.createSpecular()\n\t\t\t\t.setSpecularFactor(1.0)\n\t\t\t\t.setSpecularColorFactor(specGloss.getSpecularFactor());\n\n\t\t\t// Stash textures that might become unused, to check and clean up later.\n\t\t\tinputTextures.add(specGloss.getSpecularGlossinessTexture());\n\t\t\tinputTextures.add(material.getBaseColorTexture());\n\t\t\tinputTextures.add(material.getMetallicRoughnessTexture());\n\n\t\t\t// Set up a metal/rough PBR material with IOR=Infinity (or 0), metallic=0. This\n\t\t\t// representation is precise and reliable, but perhaps less convenient for artists\n\t\t\t// than deriving a metalness value. Unfortunately we can't do that without imprecise\n\t\t\t// heuristics, and perhaps user tuning.\n\t\t\t// See: https://github.com/KhronosGroup/glTF/pull/1719#issuecomment-674365677\n\t\t\tmaterial\n\t\t\t\t.setBaseColorFactor(specGloss.getDiffuseFactor())\n\t\t\t\t.setMetallicFactor(0)\n\t\t\t\t.setRoughnessFactor(1)\n\t\t\t\t.setExtension('KHR_materials_ior', iorExtension.createIOR().setIOR(1000))\n\t\t\t\t.setExtension('KHR_materials_specular', specular);\n\n\t\t\t// Move diffuse -> baseColor.\n\t\t\tconst diffuseTexture = specGloss.getDiffuseTexture();\n\t\t\tif (diffuseTexture) {\n\t\t\t\tmaterial.setBaseColorTexture(diffuseTexture);\n\t\t\t\tmaterial.getBaseColorTextureInfo()!.copy(specGloss.getDiffuseTextureInfo()!);\n\t\t\t}\n\n\t\t\t// Move specular + gloss -> specular + roughness.\n\t\t\tconst sgTexture = specGloss.getSpecularGlossinessTexture();\n\t\t\tif (sgTexture) {\n\t\t\t\t// specularGlossiness -> specular.\n\t\t\t\tconst sgTextureInfo = specGloss.getSpecularGlossinessTextureInfo()!;\n\t\t\t\tconst specularTexture = doc.createTexture();\n\t\t\t\tawait rewriteTexture(sgTexture, specularTexture, (pixels, i, j) => {\n\t\t\t\t\tpixels.set(i, j, 3, 255); // Remove glossiness.\n\t\t\t\t});\n\t\t\t\tspecular.setSpecularTexture(specularTexture);\n\t\t\t\tspecular.setSpecularColorTexture(specularTexture);\n\t\t\t\tspecular.getSpecularTextureInfo()!.copy(sgTextureInfo);\n\t\t\t\tspecular.getSpecularColorTextureInfo()!.copy(sgTextureInfo);\n\n\t\t\t\t// specularGlossiness -> roughness.\n\t\t\t\tconst glossinessFactor = specGloss.getGlossinessFactor();\n\t\t\t\tconst metalRoughTexture = doc.createTexture();\n\t\t\t\tawait rewriteTexture(sgTexture, metalRoughTexture, (pixels, i, j) => {\n\t\t\t\t\t// Invert glossiness.\n\t\t\t\t\tconst roughness = 255 - Math.round(pixels.get(i, j, 3) * glossinessFactor);\n\t\t\t\t\tpixels.set(i, j, 0, 0);\n\t\t\t\t\tpixels.set(i, j, 1, roughness);\n\t\t\t\t\tpixels.set(i, j, 2, 0);\n\t\t\t\t\tpixels.set(i, j, 3, 255);\n\t\t\t\t});\n\t\t\t\tmaterial.setMetallicRoughnessTexture(metalRoughTexture);\n\t\t\t\tmaterial.getMetallicRoughnessTextureInfo()!.copy(sgTextureInfo);\n\t\t\t} else {\n\t\t\t\tspecular.setSpecularColorFactor(specGloss.getSpecularFactor());\n\t\t\t\tmaterial.setRoughnessFactor(1 - specGloss.getGlossinessFactor());\n\t\t\t}\n\n\t\t\t// Remove KHR_materials_pbrSpecularGlossiness from the material.\n\t\t\tmaterial.setExtension('KHR_materials_pbrSpecularGlossiness', null);\n\t\t}\n\n\t\t// Remove KHR_materials_pbrSpecularGlossiness from the document.\n\t\tspecGlossExtension.dispose();\n\n\t\t// Clean up unused textures.\n\t\tfor (const tex of inputTextures) {\n\t\t\tif (tex && tex.listParents().length === 1) tex.dispose();\n\t\t}\n\n\t\tlogger.debug(`${NAME}: Complete.`);\n\t});\n}\n","import {\n\ttype Accessor,\n\tDocument,\n\ttype Primitive,\n\ttype Transform,\n\ttype TypedArrayConstructor,\n} from '@gltf-transform/core';\nimport { createTransform, formatDeltaOp, shallowCloneAccessor } from './utils.js';\n\nconst NAME = 'unweld';\n\n/** Options for the {@link unweld} function. */\nexport interface UnweldOptions {}\n\nconst UNWELD_DEFAULTS: UnweldOptions = {};\n\n/**\n * De-index {@link Primitive}s, disconnecting any shared vertices. This operation will generally\n * increase the number of vertices in a mesh, but may be helpful for some geometry operations or\n * for creating hard edges.\n *\n * No options are currently implemented for this function.\n *\n * @category Transforms\n */\nexport function unweld(_options: UnweldOptions = UNWELD_DEFAULTS): Transform {\n\treturn createTransform(NAME, (doc: Document): void => {\n\t\tconst logger = doc.getLogger();\n\t\tconst visited = new Map<Accessor, Map<Accessor, Accessor>>();\n\n\t\tfor (const mesh of doc.getRoot().listMeshes()) {\n\t\t\tfor (const prim of mesh.listPrimitives()) {\n\t\t\t\tunweldPrimitive(prim, visited);\n\t\t\t}\n\t\t}\n\n\t\tlogger.debug(`${NAME}: Complete.`);\n\t});\n}\n\n/**\n * @hidden\n * @internal\n */\nexport function unweldPrimitive(prim: Primitive, visited = new Map<Accessor, Map<Accessor, Accessor>>()): void {\n\tconst indices = prim.getIndices();\n\tif (!indices) return;\n\n\tconst graph = prim.getGraph();\n\tconst document = Document.fromGraph(graph)!;\n\tconst logger = document.getLogger();\n\n\tconst srcVertexCount = prim.getAttribute('POSITION')!.getCount();\n\n\t// Vertex attributes.\n\tfor (const srcAttribute of prim.listAttributes()) {\n\t\tprim.swap(srcAttribute, unweldAttribute(document, srcAttribute, indices, visited));\n\n\t\t// Clean up.\n\t\tif (srcAttribute.listParents().length === 1) srcAttribute.dispose();\n\t}\n\n\t// Morph target vertex attributes.\n\tfor (const target of prim.listTargets()) {\n\t\tfor (const srcAttribute of target.listAttributes()) {\n\t\t\ttarget.swap(srcAttribute, unweldAttribute(document, srcAttribute, indices, visited));\n\n\t\t\t// Clean up.\n\t\t\tif (srcAttribute.listParents().length === 1) srcAttribute.dispose();\n\t\t}\n\t}\n\n\tconst dstVertexCount = prim.getAttribute('POSITION')!.getCount();\n\tlogger.debug(`${NAME}: ${formatDeltaOp(srcVertexCount, dstVertexCount)} vertices.`);\n\n\t// Clean up.\n\tprim.setIndices(null);\n\tif (indices.listParents().length === 1) indices.dispose();\n}\n\nfunction unweldAttribute(\n\tdocument: Document,\n\tsrcAttribute: Accessor,\n\tindices: Accessor,\n\tvisited: Map<Accessor, Map<Accessor, Accessor>>,\n): Accessor {\n\tif (visited.has(srcAttribute) && visited.get(srcAttribute)!.has(indices)) {\n\t\treturn visited.get(srcAttribute)!.get(indices)!;\n\t}\n\n\tconst srcArray = srcAttribute.getArray()!;\n\tconst TypedArray = srcArray.constructor as TypedArrayConstructor;\n\tconst dstArray = new TypedArray(indices.getCount() * srcAttribute.getElementSize());\n\n\tconst indicesArray = indices.getArray()!;\n\tconst elementSize = srcAttribute.getElementSize();\n\tfor (let i = 0, il = indices.getCount(); i < il; i++) {\n\t\tfor (let j = 0; j < elementSize; j++) {\n\t\t\tdstArray[i * elementSize + j] = srcArray[indicesArray[i] * elementSize + j];\n\t\t}\n\t}\n\n\tif (!visited.has(srcAttribute)) visited.set(srcAttribute, new Map());\n\tconst dstAttribute = shallowCloneAccessor(document, srcAttribute).setArray(dstArray);\n\tvisited.get(srcAttribute)!.set(indices, dstAttribute);\n\n\treturn dstAttribute;\n}\n","import type { Document, Transform, vec3 } from '@gltf-transform/core';\nimport { normalize } from 'gl-matrix/vec3';\nimport { unweld } from './unweld.js';\nimport { assignDefaults, createTransform } from './utils.js';\n\nconst NAME = 'normals';\n\n/** Options for the {@link normals} function. */\nexport interface NormalsOptions {\n\t/** Whether to overwrite existing `NORMAL` attributes. */\n\toverwrite?: boolean;\n}\n\nconst NORMALS_DEFAULTS: Required<NormalsOptions> = {\n\toverwrite: false,\n};\n\n/**\n * Generates flat vertex normals for mesh primitives.\n *\n * Example:\n *\n * ```ts\n * import { normals } from '@gltf-transform/functions';\n *\n * await document.transform(normals({overwrite: true}));\n * ```\n *\n * @category Transforms\n */\nexport function normals(_options: NormalsOptions = NORMALS_DEFAULTS): Transform {\n\tconst options = assignDefaults(NORMALS_DEFAULTS, _options);\n\n\treturn createTransform(NAME, async (document: Document): Promise<void> => {\n\t\tconst logger = document.getLogger();\n\t\tlet modified = 0;\n\n\t\tawait document.transform(unweld());\n\n\t\tfor (const mesh of document.getRoot().listMeshes()) {\n\t\t\tfor (const prim of mesh.listPrimitives()) {\n\t\t\t\tconst position = prim.getAttribute('POSITION')!;\n\t\t\t\tlet normal = prim.getAttribute('NORMAL');\n\n\t\t\t\tif (options.overwrite && normal) {\n\t\t\t\t\tnormal.dispose();\n\t\t\t\t} else if (normal) {\n\t\t\t\t\tlogger.debug(`${NAME}: Skipping primitive: NORMAL found.`);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tnormal = document\n\t\t\t\t\t.createAccessor()\n\t\t\t\t\t.setArray(new Float32Array(position.getCount() * 3))\n\t\t\t\t\t.setType('VEC3');\n\n\t\t\t\tconst a = [0, 0, 0] as vec3;\n\t\t\t\tconst b = [0, 0, 0] as vec3;\n\t\t\t\tconst c = [0, 0, 0] as vec3;\n\n\t\t\t\tfor (let i = 0; i < position.getCount(); i += 3) {\n\t\t\t\t\tposition.getElement(i + 0, a);\n\t\t\t\t\tposition.getElement(i + 1, b);\n\t\t\t\t\tposition.getElement(i + 2, c);\n\n\t\t\t\t\tconst faceNormal = computeNormal(a, b, c);\n\n\t\t\t\t\tnormal.setElement(i + 0, faceNormal);\n\t\t\t\t\tnormal.setElement(i + 1, faceNormal);\n\t\t\t\t\tnormal.setElement(i + 2, faceNormal);\n\t\t\t\t}\n\n\t\t\t\tprim.setAttribute('NORMAL', normal);\n\t\t\t\tmodified++;\n\t\t\t}\n\t\t}\n\n\t\tif (!modified) {\n\t\t\tlogger.warn(`${NAME}: No qualifying primitives found. See debug output.`);\n\t\t} else {\n\t\t\tlogger.debug(`${NAME}: Complete.`);\n\t\t}\n\t});\n}\n\n// https://stackoverflow.com/a/23709352/1314762\nfunction computeNormal(a: vec3, b: vec3, c: vec3): vec3 {\n\tconst A = [b[0] - a[0], b[1] - a[1], b[2] - a[2]];\n\tconst B = [c[0] - a[0], c[1] - a[1], c[2] - a[2]];\n\tconst n = [\n\t\tA[1] * B[2] - A[2] * B[1], //\n\t\tA[2] * B[0] - A[0] * B[2],\n\t\tA[0] * B[1] - A[1] * B[0],\n\t] as vec3;\n\treturn normalize([0, 0, 0], n) as vec3;\n}\n","import {\n\tColorUtils,\n\ttype Document,\n\ttype Material,\n\ttype Primitive,\n\tPropertyType,\n\ttype Texture,\n\tTextureInfo,\n\ttype Transform,\n\ttype vec4,\n} from '@gltf-transform/core';\nimport ndarray, { type NdArray, type TypedArray } from 'ndarray';\nimport { savePixels } from 'ndarray-pixels';\nimport { prune } from './prune.js';\nimport { assignDefaults, createTransform } from './utils.js';\n\nconst NAME = 'palette';\n\ntype TexturableProp = 'baseColor' | 'emissive' | 'metallicRoughness';\n\nexport interface PaletteOptions {\n\t/** Size (in pixels) of a single block within each palette texture. Default: 4. */\n\tblockSize?: number;\n\t/**\n\t * Minimum number of blocks in the palette texture. If fewer unique\n\t * material values are found, no palettes will be generated. Default: 5.\n\t */\n\tmin?: number;\n\t/**\n\t * Whether to keep unused vertex attributes, such as UVs without an assigned\n\t * texture. If kept, unused UV coordinates may prevent palette texture\n\t * creation. Default: false.\n\t */\n\tkeepAttributes?: boolean;\n\t/**\n\t * Whether to perform cleanup steps after completing the operation. Recommended, and enabled by\n\t * default. Cleanup removes temporary resources created during the operation, but may also remove\n\t * pre-existing unused or duplicate resources in the {@link Document}. Applications that require\n\t * keeping these resources may need to disable cleanup, instead calling {@link dedup} and\n\t * {@link prune} manually (with customized options) later in the processing pipeline.\n\t * @experimental\n\t */\n\tcleanup?: boolean;\n}\n\nexport const PALETTE_DEFAULTS: Required<PaletteOptions> = {\n\tblockSize: 4,\n\tmin: 5,\n\tkeepAttributes: false,\n\tcleanup: true,\n};\n\n/**\n * Creates palette textures containing all unique values of scalar\n * {@link Material} properties within the scene, then merges materials. For\n * scenes with many solid-colored materials (often found in CAD, architectural,\n * or low-poly styles), texture palettes can reduce the number of materials\n * used, and significantly increase the number of {@link Mesh} objects eligible\n * for {@link join} operations.\n *\n * Materials already containing texture coordinates (UVs) are not eligible for\n * texture palette optimizations. Currently only a material's base color,\n * alpha, emissive factor, metallic factor, and roughness factor are converted\n * to palette textures.\n *\n * Example:\n *\n * ```typescript\n * import { palette, flatten, dequantize, join } from '@gltf-transform/functions';\n *\n * await document.transform(\n * \tpalette({ min: 5 }),\n * \tflatten(),\n * \tdequantize(),\n * \tjoin()\n * );\n * ```\n *\n * The illustration below shows a typical base color palette texture:\n *\n * <img\n * \tsrc=\"/media/functions/palette.png\"\n * \talt=\"Row of colored blocks\"\n * \tstyle=\"width: 100%; max-width: 320px; image-rendering: pixelated;\">\n *\n * @category Transforms\n */\nexport function palette(_options: PaletteOptions = PALETTE_DEFAULTS): Transform {\n\tconst options = assignDefaults(PALETTE_DEFAULTS, _options);\n\tconst blockSize = Math.max(options.blockSize, 1);\n\tconst min = Math.max(options.min, 1);\n\n\treturn createTransform(NAME, async (document: Document): Promise<void> => {\n\t\tconst logger = document.getLogger();\n\t\tconst root = document.getRoot();\n\n\t\t// Find and remove unused TEXCOORD_n attributes.\n\t\tif (!options.keepAttributes) {\n\t\t\tawait document.transform(\n\t\t\t\tprune({\n\t\t\t\t\tpropertyTypes: [PropertyType.ACCESSOR],\n\t\t\t\t\tkeepAttributes: false,\n\t\t\t\t\tkeepIndices: true,\n\t\t\t\t\tkeepLeaves: true,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tconst prims = new Set<Primitive>();\n\t\tconst materials = new Set<Material>();\n\n\t\t// (1) Gather list of eligible prims and materials.\n\n\t\tfor (const mesh of root.listMeshes()) {\n\t\t\tfor (const prim of mesh.listPrimitives()) {\n\t\t\t\tconst material = prim.getMaterial();\n\t\t\t\tif (!material || !!prim.getAttribute('TEXCOORD_0')) continue;\n\n\t\t\t\tprims.add(prim);\n\t\t\t\tmaterials.add(material);\n\t\t\t}\n\t\t}\n\n\t\t// (2) Gather list of distinct material properties.\n\n\t\tconst materialKeys = new Set<string>();\n\t\tconst materialKeyMap = new Map<Material, string>();\n\t\tconst materialProps: Record<TexturableProp, Set<string>> = {\n\t\t\tbaseColor: new Set<string>(),\n\t\t\temissive: new Set<string>(),\n\t\t\tmetallicRoughness: new Set<string>(),\n\t\t};\n\n\t\tfor (const material of materials) {\n\t\t\tconst baseColor = encodeRGBA(material.getBaseColorFactor().slice() as vec4);\n\t\t\tconst emissive = encodeRGBA([...material.getEmissiveFactor(), 1]);\n\t\t\tconst roughness = encodeFloat(material.getRoughnessFactor());\n\t\t\tconst metallic = encodeFloat(material.getMetallicFactor());\n\t\t\tconst key = `baseColor:${baseColor},emissive:${emissive},metallicRoughness:${metallic}${roughness}`;\n\t\t\tmaterialProps.baseColor.add(baseColor);\n\t\t\tmaterialProps.emissive.add(emissive);\n\t\t\tmaterialProps.metallicRoughness.add(metallic + '+' + roughness);\n\t\t\tmaterialKeys.add(key);\n\t\t\tmaterialKeyMap.set(material, key);\n\t\t}\n\n\t\t// logger.debug(`${NAME}:\\n${Array.from(materialKeys.values()).join('\\n')}`);\n\n\t\tconst keyCount = materialKeys.size;\n\t\tif (keyCount < min) {\n\t\t\tlogger.debug(`${NAME}: Found <${min} unique material properties. Exiting.`);\n\t\t\treturn;\n\t\t}\n\n\t\t// (3) Allocate palette textures.\n\n\t\tconst w = ceilPowerOfTwo(keyCount * blockSize);\n\t\tconst h = ceilPowerOfTwo(blockSize);\n\t\tconst padWidth = w - keyCount * blockSize;\n\n\t\tconst paletteTexturePixels: Record<TexturableProp, NdArray<Uint8Array> | null> = {\n\t\t\tbaseColor: null,\n\t\t\temissive: null,\n\t\t\tmetallicRoughness: null,\n\t\t};\n\n\t\t// Properties skipped for material equality comparisons.\n\t\tconst skipProps = new Set(['name', 'extras']);\n\t\tconst skip = (...props: string[]) => props.forEach((prop) => skipProps.add(prop));\n\n\t\tlet baseColorTexture: Texture | null = null;\n\t\tlet emissiveTexture: Texture | null = null;\n\t\tlet metallicRoughnessTexture: Texture | null = null;\n\n\t\tif (materialProps.baseColor.size >= min) {\n\t\t\tconst name = 'PaletteBaseColor';\n\t\t\tbaseColorTexture = document.createTexture(name).setURI(`${name}.png`);\n\t\t\tpaletteTexturePixels.baseColor = ndarray(new Uint8Array(w * h * 4), [w, h, 4]);\n\t\t\tskip('baseColorFactor', 'baseColorTexture', 'baseColorTextureInfo');\n\t\t}\n\t\tif (materialProps.emissive.size >= min) {\n\t\t\tconst name = 'PaletteEmissive';\n\t\t\temissiveTexture = document.createTexture(name).setURI(`${name}.png`);\n\t\t\tpaletteTexturePixels.emissive = ndarray(new Uint8Array(w * h * 4), [w, h, 4]);\n\t\t\tskip('emissiveFactor', 'emissiveTexture', 'emissiveTextureInfo');\n\t\t}\n\t\tif (materialProps.metallicRoughness.size >= min) {\n\t\t\tconst name = 'PaletteMetallicRoughness';\n\t\t\tmetallicRoughnessTexture = document.createTexture(name).setURI(`${name}.png`);\n\t\t\tpaletteTexturePixels.metallicRoughness = ndarray(new Uint8Array(w * h * 4), [w, h, 4]);\n\t\t\tskip('metallicFactor', 'roughnessFactor', 'metallicRoughnessTexture', 'metallicRoughnessTextureInfo');\n\t\t}\n\n\t\tif (!(baseColorTexture || emissiveTexture || metallicRoughnessTexture)) {\n\t\t\tlogger.debug(`${NAME}: No material property has >=${min} unique values. Exiting.`);\n\t\t\treturn;\n\t\t}\n\n\t\t// (4) Write blocks to palette textures.\n\n\t\tconst visitedKeys = new Set<string>();\n\t\tconst materialIndices = new Map<string, number>();\n\t\tconst paletteMaterials: Material[] = [];\n\n\t\tlet nextIndex = 0;\n\t\tfor (const material of materials) {\n\t\t\tconst key = materialKeyMap.get(material)!;\n\t\t\tif (visitedKeys.has(key)) continue;\n\n\t\t\tconst index = nextIndex++;\n\n\t\t\tif (paletteTexturePixels.baseColor) {\n\t\t\t\tconst pixels = paletteTexturePixels.baseColor;\n\t\t\t\tconst baseColor = [...material.getBaseColorFactor()] as vec4;\n\t\t\t\tColorUtils.convertLinearToSRGB(baseColor, baseColor);\n\t\t\t\twriteBlock(pixels, index, baseColor, blockSize);\n\t\t\t}\n\t\t\tif (paletteTexturePixels.emissive) {\n\t\t\t\tconst pixels = paletteTexturePixels.emissive;\n\t\t\t\tconst emissive = [...material.getEmissiveFactor(), 1] as vec4;\n\t\t\t\tColorUtils.convertLinearToSRGB(emissive, emissive);\n\t\t\t\twriteBlock(pixels, index, emissive, blockSize);\n\t\t\t}\n\t\t\tif (paletteTexturePixels.metallicRoughness) {\n\t\t\t\tconst pixels = paletteTexturePixels.metallicRoughness;\n\t\t\t\tconst metallic = material.getMetallicFactor();\n\t\t\t\tconst roughness = material.getRoughnessFactor();\n\t\t\t\twriteBlock(pixels, index, [0, roughness, metallic, 1], blockSize);\n\t\t\t}\n\n\t\t\tvisitedKeys.add(key);\n\t\t\tmaterialIndices.set(key, index);\n\t\t}\n\n\t\t// (5) Compress palette textures and assign to palette materials.\n\n\t\tconst mimeType = 'image/png';\n\n\t\tif (baseColorTexture) {\n\t\t\tconst image = await savePixels(paletteTexturePixels.baseColor!, mimeType);\n\t\t\tbaseColorTexture.setImage(image).setMimeType(mimeType);\n\t\t}\n\t\tif (emissiveTexture) {\n\t\t\tconst image = await savePixels(paletteTexturePixels.emissive!, mimeType);\n\t\t\temissiveTexture.setImage(image).setMimeType(mimeType);\n\t\t}\n\t\tif (metallicRoughnessTexture) {\n\t\t\tconst image = await savePixels(paletteTexturePixels.metallicRoughness!, mimeType);\n\t\t\tmetallicRoughnessTexture.setImage(image).setMimeType(mimeType);\n\t\t}\n\n\t\t// (6) Create palette materials, generate UVs, and assign both to prims.\n\n\t\tlet nextPaletteMaterialIndex = 1;\n\t\tfor (const prim of prims) {\n\t\t\tconst srcMaterial = prim.getMaterial()!;\n\t\t\tconst key = materialKeyMap.get(srcMaterial)!;\n\t\t\tconst blockIndex = materialIndices.get(key)!;\n\n\t\t\t// UVs are centered horizontally in each block, descending vertically\n\t\t\t// to form a diagonal line in the UV layout. Easy and compressible.\n\t\t\tconst baseUV = (blockIndex + 0.5) / keyCount;\n\t\t\tconst padUV = (baseUV * (w - padWidth)) / w;\n\n\t\t\tconst position = prim.getAttribute('POSITION')!;\n\t\t\tconst buffer = position.getBuffer();\n\t\t\tconst array = new Float32Array(position.getCount() * 2).fill(padUV);\n\t\t\tconst uv = document.createAccessor().setType('VEC2').setArray(array).setBuffer(buffer);\n\n\t\t\tlet dstMaterial;\n\t\t\tfor (const material of paletteMaterials) {\n\t\t\t\tif (material.equals(srcMaterial, skipProps)) {\n\t\t\t\t\tdstMaterial = material;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!dstMaterial) {\n\t\t\t\tconst suffix = (nextPaletteMaterialIndex++).toString().padStart(3, '0');\n\t\t\t\tdstMaterial = srcMaterial.clone().setName(`PaletteMaterial${suffix}`);\n\n\t\t\t\tif (baseColorTexture) {\n\t\t\t\t\tdstMaterial\n\t\t\t\t\t\t.setBaseColorFactor([1, 1, 1, 1])\n\t\t\t\t\t\t.setBaseColorTexture(baseColorTexture)\n\t\t\t\t\t\t.getBaseColorTextureInfo()!\n\t\t\t\t\t\t.setMinFilter(TextureInfo.MinFilter.NEAREST)\n\t\t\t\t\t\t.setMagFilter(TextureInfo.MagFilter.NEAREST);\n\t\t\t\t}\n\t\t\t\tif (emissiveTexture) {\n\t\t\t\t\tdstMaterial\n\t\t\t\t\t\t.setEmissiveFactor([1, 1, 1])\n\t\t\t\t\t\t.setEmissiveTexture(emissiveTexture)\n\t\t\t\t\t\t.getEmissiveTextureInfo()!\n\t\t\t\t\t\t.setMinFilter(TextureInfo.MinFilter.NEAREST)\n\t\t\t\t\t\t.setMagFilter(TextureInfo.MagFilter.NEAREST);\n\t\t\t\t}\n\t\t\t\tif (metallicRoughnessTexture) {\n\t\t\t\t\tdstMaterial\n\t\t\t\t\t\t.setMetallicFactor(1)\n\t\t\t\t\t\t.setRoughnessFactor(1)\n\t\t\t\t\t\t.setMetallicRoughnessTexture(metallicRoughnessTexture)\n\t\t\t\t\t\t.getMetallicRoughnessTextureInfo()!\n\t\t\t\t\t\t.setMinFilter(TextureInfo.MinFilter.NEAREST)\n\t\t\t\t\t\t.setMagFilter(TextureInfo.MagFilter.NEAREST);\n\t\t\t\t}\n\n\t\t\t\tpaletteMaterials.push(dstMaterial);\n\t\t\t}\n\n\t\t\tprim.setMaterial(dstMaterial).setAttribute('TEXCOORD_0', uv);\n\t\t}\n\n\t\tif (options.cleanup) {\n\t\t\tawait document.transform(prune({ propertyTypes: [PropertyType.MATERIAL] }));\n\t\t}\n\n\t\tlogger.debug(`${NAME}: Complete.`);\n\t});\n}\n\n/** Encodes a floating-point value on the interval [0,1] at 8-bit precision. */\nfunction encodeFloat(value: number): string {\n\tconst hex = Math.round(value * 255).toString(16);\n\treturn hex.length === 1 ? '0' + hex : hex;\n}\n\n/** Encodes an RGBA color in Linear-sRGB-D65 color space. */\nfunction encodeRGBA(value: vec4): string {\n\tColorUtils.convertLinearToSRGB(value, value);\n\treturn value.map(encodeFloat).join('');\n}\n\n/** Returns the nearest higher power of two. */\nfunction ceilPowerOfTwo(value: number): number {\n\treturn Math.pow(2, Math.ceil(Math.log(value) / Math.LN2));\n}\n\n/** Writes an NxN block of pixels to an image, at the given block index. */\nfunction writeBlock(pixels: NdArray<TypedArray>, index: number, value: vec4, blockSize: number): void {\n\tfor (let i = 0; i < blockSize; i++) {\n\t\tfor (let j = 0; j < blockSize; j++) {\n\t\t\tpixels.set(index * blockSize + i, j, 0, value[0] * 255);\n\t\t\tpixels.set(index * blockSize + i, j, 1, value[1] * 255);\n\t\t\tpixels.set(index * blockSize + i, j, 2, value[2] * 255);\n\t\t\tpixels.set(index * blockSize + i, j, 3, value[3] * 255);\n\t\t}\n\t}\n}\n","import { type Document, type ILogger, PropertyType, type Transform } from '@gltf-transform/core';\nimport { prune } from './prune.js';\nimport { assignDefaults, createTransform, deepListAttributes } from './utils.js';\n\nconst NAME = 'partition';\n\nexport interface PartitionOptions {\n\tanimations?: boolean | Array<string>;\n\tmeshes?: boolean | Array<string>;\n}\n\nconst PARTITION_DEFAULTS: Required<PartitionOptions> = {\n\tanimations: true,\n\tmeshes: true,\n};\n\n/**\n * Partitions the binary payload of a glTF file so separate mesh or animation data is in separate\n * `.bin` {@link Buffer}s. This technique may be useful for engines that support lazy-loading\n * specific binary resources as needed over the application lifecycle.\n *\n * Example:\n *\n * ```ts\n * document.getRoot().listBuffers(); // → [Buffer]\n *\n * await document.transform(partition({meshes: true}));\n *\n * document.getRoot().listBuffers(); // → [Buffer, Buffer, ...]\n * ```\n *\n * @category Transforms\n */\nexport function partition(_options: PartitionOptions = PARTITION_DEFAULTS): Transform {\n\tconst options = assignDefaults(PARTITION_DEFAULTS, _options);\n\n\treturn createTransform(NAME, async (doc: Document): Promise<void> => {\n\t\tconst logger = doc.getLogger();\n\n\t\tif (options.meshes !== false) partitionMeshes(doc, logger, options);\n\t\tif (options.animations !== false) partitionAnimations(doc, logger, options);\n\n\t\tif (!options.meshes && !options.animations) {\n\t\t\tlogger.warn(`${NAME}: Select animations or meshes to create a partition.`);\n\t\t}\n\n\t\tawait doc.transform(prune({ propertyTypes: [PropertyType.BUFFER] }));\n\n\t\tlogger.debug(`${NAME}: Complete.`);\n\t});\n}\n\nfunction partitionMeshes(doc: Document, logger: ILogger, options: Required<PartitionOptions>): void {\n\tconst existingURIs = new Set<string>(\n\t\tdoc\n\t\t\t.getRoot()\n\t\t\t.listBuffers()\n\t\t\t.map((b) => b.getURI()),\n\t);\n\n\tdoc.getRoot()\n\t\t.listMeshes()\n\t\t.forEach((mesh, meshIndex) => {\n\t\t\tif (Array.isArray(options.meshes) && !options.meshes.includes(mesh.getName())) {\n\t\t\t\tlogger.debug(`${NAME}: Skipping mesh #${meshIndex} with name \"${mesh.getName()}\".`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlogger.debug(`${NAME}: Creating buffer for mesh \"${mesh.getName()}\".`);\n\n\t\t\tconst buffer = doc\n\t\t\t\t.createBuffer(mesh.getName())\n\t\t\t\t.setURI(createBufferURI(mesh.getName() || 'mesh', existingURIs));\n\n\t\t\tfor (const prim of mesh.listPrimitives()) {\n\t\t\t\tprim.getIndices()?.setBuffer(buffer);\n\t\t\t\tfor (const attribute of deepListAttributes(prim)) {\n\t\t\t\t\tattribute.setBuffer(buffer);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n}\n\nfunction partitionAnimations(doc: Document, logger: ILogger, options: Required<PartitionOptions>): void {\n\tconst existingURIs = new Set<string>(\n\t\tdoc\n\t\t\t.getRoot()\n\t\t\t.listBuffers()\n\t\t\t.map((b) => b.getURI()),\n\t);\n\n\tdoc.getRoot()\n\t\t.listAnimations()\n\t\t.forEach((anim, animIndex) => {\n\t\t\tif (Array.isArray(options.animations) && !options.animations.includes(anim.getName())) {\n\t\t\t\tlogger.debug(`${NAME}: Skipping animation #${animIndex} with name \"${anim.getName()}\".`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlogger.debug(`${NAME}: Creating buffer for animation \"${anim.getName()}\".`);\n\n\t\t\tconst buffer = doc\n\t\t\t\t.createBuffer(anim.getName())\n\t\t\t\t.setURI(createBufferURI(anim.getName() || 'animation', existingURIs));\n\n\t\t\tanim.listSamplers().forEach((sampler) => {\n\t\t\t\tconst input = sampler.getInput();\n\t\t\t\tconst output = sampler.getOutput();\n\t\t\t\tif (input) input.setBuffer(buffer);\n\t\t\t\tif (output) output.setBuffer(buffer);\n\t\t\t});\n\t\t});\n}\n\nconst SANITIZE_BASENAME_RE = /[^\\w0–9-]+/g;\n\nfunction createBufferURI(basename: string, existing: Set<string>): string {\n\tbasename = basename.replace(SANITIZE_BASENAME_RE, '');\n\tlet uri = `${basename}.bin`;\n\tlet i = 1;\n\twhile (existing.has(uri)) uri = `${basename}_${i++}.bin`;\n\texisting.add(uri);\n\treturn uri;\n}\n","var InterpolationInternal;\n\n(function (InterpolationInternal) {\n  InterpolationInternal[InterpolationInternal[\"STEP\"] = 0] = \"STEP\";\n  InterpolationInternal[InterpolationInternal[\"LERP\"] = 1] = \"LERP\";\n  InterpolationInternal[InterpolationInternal[\"SLERP\"] = 2] = \"SLERP\";\n})(InterpolationInternal || (InterpolationInternal = {}));\n\nconst TO_INTERPOLATION_INTERNAL = {\n  step: InterpolationInternal.STEP,\n  lerp: InterpolationInternal.LERP,\n  slerp: InterpolationInternal.SLERP\n};\nconst EPSILON = 0.000001;\n\n/* Implementation */\n\nfunction resampleDebug(input, output, interpolation, tolerance = 1e-4) {\n  const elementSize = output.length / input.length;\n  const tmp = new Array(elementSize).fill(0);\n  const value = new Array(elementSize).fill(0);\n  const valueNext = new Array(elementSize).fill(0);\n  const valuePrev = new Array(elementSize).fill(0);\n  const lastIndex = input.length - 1;\n  let writeIndex = 1;\n\n  for (let i = 1; i < lastIndex; ++i) {\n    const timePrev = input[writeIndex - 1];\n    const time = input[i];\n    const timeNext = input[i + 1];\n    const t = (time - timePrev) / (timeNext - timePrev);\n    let keep = false; // Remove unnecessary adjacent keyframes.\n\n    if (time !== timeNext && (i !== 1 || time !== input[0])) {\n      getElement(output, writeIndex - 1, valuePrev);\n      getElement(output, i, value);\n      getElement(output, i + 1, valueNext);\n\n      if (interpolation === 'slerp') {\n        // Prune keyframes colinear with prev/next keyframes.\n        const sample = slerp(tmp, valuePrev, valueNext, t);\n        const angle = getAngle(valuePrev, value) + getAngle(value, valueNext);\n        keep = !eq(value, sample, tolerance) || angle + Number.EPSILON >= Math.PI;\n      } else if (interpolation === 'lerp') {\n        // Prune keyframes colinear with prev/next keyframes.\n        const sample = vlerp(tmp, valuePrev, valueNext, t);\n        keep = !eq(value, sample, tolerance);\n      } else if (interpolation === 'step') {\n        // Prune keyframes identical to prev/next keyframes.\n        keep = !eq(value, valuePrev) || !eq(value, valueNext);\n      }\n    } // In-place compaction.\n\n\n    if (keep) {\n      if (i !== writeIndex) {\n        input[writeIndex] = input[i];\n        setElement(output, writeIndex, getElement(output, i, tmp));\n      }\n\n      writeIndex++;\n    }\n  } // Flush last keyframe (compaction looks ahead).\n\n\n  if (lastIndex > 0) {\n    input[writeIndex] = input[lastIndex];\n    setElement(output, writeIndex, getElement(output, lastIndex, tmp));\n    writeIndex++;\n  }\n\n  return writeIndex;\n}\n/* Utilities */\n\nfunction getElement(array, index, target) {\n  for (let i = 0, elementSize = target.length; i < elementSize; i++) {\n    target[i] = array[index * elementSize + i];\n  }\n\n  return target;\n}\n\nfunction setElement(array, index, value) {\n  for (let i = 0, elementSize = value.length; i < elementSize; i++) {\n    array[index * elementSize + i] = value[i];\n  }\n}\n\nfunction eq(a, b, tolerance = 0) {\n  if (a.length !== b.length) {\n    return false;\n  }\n\n  for (let i = 0; i < a.length; i++) {\n    if (Math.abs(a[i] - b[i]) > tolerance) {\n      return false;\n    }\n  }\n\n  return true;\n}\n\nfunction lerp(v0, v1, t) {\n  return v0 * (1 - t) + v1 * t;\n}\n\nfunction vlerp(out, a, b, t) {\n  for (let i = 0; i < a.length; i++) out[i] = lerp(a[i], b[i], t);\n\n  return out;\n} // From gl-matrix.\n\n\nfunction slerp(out, a, b, t) {\n  // benchmarks:\n  //    http://jsperf.com/quaternion-slerp-implementations\n  let ax = a[0],\n      ay = a[1],\n      az = a[2],\n      aw = a[3];\n  let bx = b[0],\n      by = b[1],\n      bz = b[2],\n      bw = b[3];\n  let omega, cosom, sinom, scale0, scale1; // calc cosine\n\n  cosom = ax * bx + ay * by + az * bz + aw * bw; // adjust signs (if necessary)\n\n  if (cosom < 0.0) {\n    cosom = -cosom;\n    bx = -bx;\n    by = -by;\n    bz = -bz;\n    bw = -bw;\n  } // calculate coefficients\n\n\n  if (1.0 - cosom > EPSILON) {\n    // standard case (slerp)\n    omega = Math.acos(cosom);\n    sinom = Math.sin(omega);\n    scale0 = Math.sin((1.0 - t) * omega) / sinom;\n    scale1 = Math.sin(t * omega) / sinom;\n  } else {\n    // \"from\" and \"to\" quaternions are very close\n    //  ... so we can do a linear interpolation\n    scale0 = 1.0 - t;\n    scale1 = t;\n  } // calculate final values\n\n\n  out[0] = scale0 * ax + scale1 * bx;\n  out[1] = scale0 * ay + scale1 * by;\n  out[2] = scale0 * az + scale1 * bz;\n  out[3] = scale0 * aw + scale1 * bw;\n  return out;\n}\n\nfunction getAngle(a, b) {\n  const dotproduct = dot(a, b);\n  return Math.acos(2 * dotproduct * dotproduct - 1);\n}\n\nfunction dot(a, b) {\n  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];\n}\n\n/** WASM loader for Web environments. */\nconst wasm = /* #__PURE__ */fetch( /* #__PURE__ */new URL('./release.wasm', import.meta.url)).then(response => response.arrayBuffer()).then(buffer => new Uint8Array(buffer));\n\n// SETUP\n///////////////////////////////////////////////////////////////////////////////\n\nlet exports;\nconst ready = /* #__PURE__ */new Promise(async (resolve, reject) => {\n  try {\n    const module = await WebAssembly.compile(await wasm);\n    exports = await instantiate(module, {});\n    resolve();\n  } catch (e) {\n    reject(e);\n  }\n});\n\nasync function instantiate(module, imports = {}) {\n  const instance = await WebAssembly.instantiate(module, {\n    env: Object.assign(Object.create(globalThis), {}, {\n      abort: __abort\n    })\n  });\n  return instance.exports;\n} ///////////////////////////////////////////////////////////////////////////////\n// PUBLIC API\n///////////////////////////////////////////////////////////////////////////////\n\n\nconst CHUNK_SIZE = 1024; // The first and last keyframes cannot be removed in any given step, but we need to\n// somehow remove keyframes on chunk boundaries. So after processing each chunk,\n// we copy its last two keyframes in front of the next chunk, and run from there.\n//\n// 🟩 ⬜️ ⬜️ ⬜️ ⬜️ ⬜️                  // chunk 1, original\n// 🟩 ⬜️ 🟨 🟥                       // chunk 1, resampled\n//            🟨 🟥 🟩 ⬜️ ⬜️ ⬜️       // chunk 2, original\n//            🟨 🟩 ⬜️ ⬜️            // chunk 2, resampled\n// ...\n\nfunction resample(input, output, interpolation, tolerance = 1e-4) {\n  __assert(!!exports, 'Await \"ready\" before using module.');\n\n  __assert(input instanceof Float32Array, 'Missing Float32Array input.');\n\n  __assert(output instanceof Float32Array, 'Missing Float32Array output.');\n\n  const outputSize = output.length / input.length;\n\n  __assert(Number.isInteger(outputSize), 'Invalid input/output counts.');\n\n  __assert(interpolation in TO_INTERPOLATION_INTERNAL, 'Invalid interpolation.');\n\n  __assert(Number.isFinite(tolerance), 'Invalid tolerance');\n\n  const interpVal = TO_INTERPOLATION_INTERNAL[interpolation];\n  const srcCount = input.length;\n  let dstCount = 0;\n\n  for (let chunkStart = 0; chunkStart < input.length; chunkStart += CHUNK_SIZE) {\n    const chunkCount = Math.min(srcCount - chunkStart, CHUNK_SIZE); // Allocate a two-keyframe prefix for all chunks after the first.\n\n    const prefixCount = chunkStart > 0 ? 2 : 0;\n    const chunkInput = new Float32Array(input.buffer, input.byteOffset + (chunkStart - prefixCount) * Float32Array.BYTES_PER_ELEMENT, chunkCount + prefixCount);\n    const chunkOutput = new Float32Array(output.buffer, output.byteOffset + (chunkStart - prefixCount) * outputSize * Float32Array.BYTES_PER_ELEMENT, (chunkCount + prefixCount) * outputSize); // Copy prefix to start of next chunk.\n\n    if (prefixCount > 0) {\n      input.copyWithin(chunkStart - prefixCount, dstCount - prefixCount, dstCount);\n      output.copyWithin((chunkStart - prefixCount) * outputSize, (dstCount - prefixCount) * outputSize, dstCount * outputSize);\n    }\n\n    const inputPtr = __retain(__lowerStaticArray(chunkInput, 4, 2));\n\n    const outputPtr = __retain(__lowerStaticArray(chunkOutput, 4, 2));\n\n    try {\n      exports.__setArgumentsLength(4);\n\n      const count = exports.resample(inputPtr, outputPtr, interpVal, tolerance) >>> 0;\n      dstCount -= prefixCount;\n\n      __liftStaticArray(inputPtr, input, dstCount, count);\n\n      __liftStaticArray(outputPtr, output, dstCount * outputSize, count * outputSize);\n\n      dstCount += count;\n    } finally {\n      __release(inputPtr);\n\n      __release(outputPtr);\n\n      exports.__collect();\n    }\n  } // console.log(`Memory: ${exports.memory.buffer.byteLength} bytes`);\n\n\n  return dstCount;\n} ///////////////////////////////////////////////////////////////////////////////\n// INTERNAL\n///////////////////////////////////////////////////////////////////////////////\n\nfunction __assert(cond, msg) {\n  if (!cond) throw new Error(msg);\n}\n\nfunction __retain(ptr) {\n  exports.__pin(ptr);\n\n  return ptr;\n}\n\nfunction __release(ptr) {\n  exports.__unpin(ptr);\n\n  return ptr;\n}\n\nfunction __liftString(ptr) {\n  if (!ptr) return null;\n  const end = ptr + new Uint32Array(exports.memory.buffer)[ptr - 4 >>> 2] >>> 1,\n        memoryU16 = new Uint16Array(exports.memory.buffer);\n  let start = ptr >>> 1,\n      string = '';\n\n  while (end - start > 1024) string += String.fromCharCode(...memoryU16.subarray(start, start += 1024));\n\n  return string + String.fromCharCode(...memoryU16.subarray(start, end));\n}\n\nfunction __lowerStaticArray(values, id, align) {\n  const ptr = exports.__pin(exports.__new(values.length << align, id)) >>> 0;\n  new Float32Array(exports.memory.buffer, ptr, values.length).set(values);\n\n  exports.__unpin(ptr);\n\n  return ptr;\n}\n\nfunction __liftStaticArray(ptr, values, offset, count) {\n  values.set(new Float32Array(exports.memory.buffer, ptr, count), offset);\n}\n\nfunction __abort(messagePtr, fileNamePtr, lineNumber, columnNumber) {\n  const message = __liftString(messagePtr >>> 0);\n\n  const fileName = __liftString(fileNamePtr >>> 0);\n\n  lineNumber = lineNumber >>> 0;\n  columnNumber = columnNumber >>> 0;\n\n  (() => {\n    throw Error(`${message} in ${fileName}:${lineNumber}:${columnNumber}`);\n  })();\n}\n\nexport { ready, resample, resampleDebug };\n//# sourceMappingURL=keyframe-resample-browser.modern.js.map\n","import {\n\tAccessor,\n\ttype AnimationSampler,\n\tComponentTypeToTypedArray,\n\ttype Document,\n\ttype GLTF,\n\tMathUtils,\n\tPropertyType,\n\tRoot,\n\ttype Transform,\n\ttype TypedArray,\n} from '@gltf-transform/core';\nimport { resampleDebug } from 'keyframe-resample';\nimport { dedup } from './dedup.js';\nimport { assignDefaults, createTransform } from './utils.js';\n\nconst NAME = 'resample';\n\nconst EMPTY_ARRAY = new Float32Array(0);\n\nexport interface ResampleOptions {\n\tready?: Promise<void>;\n\tresample?: unknown; // glTF-Transform/issues/996\n\ttolerance?: number;\n\t/**\n\t * Whether to perform cleanup steps after completing the operation. Recommended, and enabled by\n\t * default. Cleanup removes temporary resources created during the operation, but may also remove\n\t * pre-existing unused or duplicate resources in the {@link Document}. Applications that require\n\t * keeping these resources may need to disable cleanup, instead calling {@link dedup} and\n\t * {@link prune} manually (with customized options) later in the processing pipeline.\n\t * @experimental\n\t */\n\tcleanup?: boolean;\n}\n\nconst RESAMPLE_DEFAULTS: Required<ResampleOptions> = {\n\tready: Promise.resolve(),\n\tresample: resampleDebug,\n\ttolerance: 1e-4,\n\tcleanup: true,\n};\n\n/**\n * Resample {@link AnimationChannel AnimationChannels}, losslessly deduplicating keyframes to\n * reduce file size. Duplicate keyframes are commonly present in animation 'baked' by the\n * authoring software to apply IK constraints or other software-specific features.\n *\n * Optionally, a WebAssembly implementation from the\n * [`keyframe-resample`](https://github.com/donmccurdy/keyframe-resample-wasm) library may be\n * provided. The WebAssembly version is usually much faster at processing large animation\n * sequences, but may not be compatible with all runtimes and JavaScript build tools.\n *\n * Result: (0,0,0,0,1,1,1,0,0,0,0,0,0,0) → (0,0,1,1,0,0)\n *\n * Example:\n *\n * ```\n * import { resample } from '@gltf-transform/functions';\n * import { ready, resample as resampleWASM } from 'keyframe-resample';\n *\n * // JavaScript (slower)\n * await document.transform(resample());\n *\n * // WebAssembly (faster)\n * await document.transform(resample({ ready, resample: resampleWASM }));\n * ```\n *\n * @privateRemarks Implementation based on THREE.KeyframeTrack#optimize().\n * @category Transforms\n */\nexport function resample(_options: ResampleOptions = RESAMPLE_DEFAULTS): Transform {\n\tconst options = assignDefaults(RESAMPLE_DEFAULTS, _options);\n\n\treturn createTransform(NAME, async (document: Document): Promise<void> => {\n\t\tconst accessorsVisited = new Set<Accessor>();\n\t\tconst srcAccessorCount = document.getRoot().listAccessors().length;\n\t\tconst logger = document.getLogger();\n\n\t\tconst ready = options.ready;\n\t\tconst resample = options.resample as typeof resampleDebug;\n\n\t\tawait ready;\n\n\t\tfor (const animation of document.getRoot().listAnimations()) {\n\t\t\tconst samplerTargetPaths = new Map<AnimationSampler, GLTF.AnimationChannelTargetPath>();\n\t\t\tfor (const channel of animation.listChannels()) {\n\t\t\t\tsamplerTargetPaths.set(channel.getSampler()!, channel.getTargetPath()!);\n\t\t\t}\n\n\t\t\tfor (const sampler of animation.listSamplers()) {\n\t\t\t\tconst samplerInterpolation = sampler.getInterpolation();\n\n\t\t\t\tif (samplerInterpolation === 'STEP' || samplerInterpolation === 'LINEAR') {\n\t\t\t\t\tconst input = sampler.getInput()!;\n\t\t\t\t\tconst output = sampler.getOutput()!;\n\n\t\t\t\t\taccessorsVisited.add(input);\n\t\t\t\t\taccessorsVisited.add(output);\n\n\t\t\t\t\t// biome-ignore format: Readability.\n\t\t\t\t\tconst tmpTimes = toFloat32Array(\n\t\t\t\t\t\tinput.getArray()!,\n\t\t\t\t\t\tinput.getComponentType(),\n\t\t\t\t\t\tinput.getNormalized()\n\t\t\t\t\t);\n\t\t\t\t\tconst tmpValues = toFloat32Array(\n\t\t\t\t\t\toutput.getArray()!,\n\t\t\t\t\t\toutput.getComponentType(),\n\t\t\t\t\t\toutput.getNormalized(),\n\t\t\t\t\t);\n\n\t\t\t\t\tconst elementSize = tmpValues.length / tmpTimes.length;\n\t\t\t\t\tconst srcCount = tmpTimes.length;\n\t\t\t\t\tlet dstCount: number;\n\n\t\t\t\t\tif (samplerInterpolation === 'STEP') {\n\t\t\t\t\t\tdstCount = resample(tmpTimes, tmpValues, 'step', options.tolerance);\n\t\t\t\t\t} else if (samplerTargetPaths.get(sampler) === 'rotation') {\n\t\t\t\t\t\tdstCount = resample(tmpTimes, tmpValues, 'slerp', options.tolerance);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdstCount = resample(tmpTimes, tmpValues, 'lerp', options.tolerance);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (dstCount < srcCount) {\n\t\t\t\t\t\t// Clone the input/output accessors, without cloning their underlying\n\t\t\t\t\t\t// arrays. Then assign the resampled data.\n\t\t\t\t\t\tconst srcTimes = input.getArray()!;\n\t\t\t\t\t\tconst srcValues = output.getArray()!;\n\n\t\t\t\t\t\tconst dstTimes = fromFloat32Array(\n\t\t\t\t\t\t\tnew Float32Array(tmpTimes.buffer, tmpTimes.byteOffset, dstCount),\n\t\t\t\t\t\t\tinput.getComponentType(),\n\t\t\t\t\t\t\tinput.getNormalized(),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst dstValues = fromFloat32Array(\n\t\t\t\t\t\t\tnew Float32Array(tmpValues.buffer, tmpValues.byteOffset, dstCount * elementSize),\n\t\t\t\t\t\t\toutput.getComponentType(),\n\t\t\t\t\t\t\toutput.getNormalized(),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tinput.setArray(EMPTY_ARRAY);\n\t\t\t\t\t\toutput.setArray(EMPTY_ARRAY);\n\n\t\t\t\t\t\tsampler.setInput(input.clone().setArray(dstTimes));\n\t\t\t\t\t\tsampler.setOutput(output.clone().setArray(dstValues));\n\n\t\t\t\t\t\tinput.setArray(srcTimes);\n\t\t\t\t\t\toutput.setArray(srcValues);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const accessor of Array.from(accessorsVisited.values())) {\n\t\t\tconst used = accessor.listParents().some((p) => !(p instanceof Root));\n\t\t\tif (!used) accessor.dispose();\n\t\t}\n\n\t\t// Resampling may result in duplicate input or output sampler\n\t\t// accessors. Find and remove the duplicates after processing.\n\t\tconst dstAccessorCount = document.getRoot().listAccessors().length;\n\t\tif (dstAccessorCount > srcAccessorCount && options.cleanup) {\n\t\t\tawait document.transform(dedup({ propertyTypes: [PropertyType.ACCESSOR] }));\n\t\t}\n\n\t\tlogger.debug(`${NAME}: Complete.`);\n\t});\n}\n\n/** Returns a copy of the source array, as a denormalized Float32Array. */\nfunction toFloat32Array(\n\tsrcArray: TypedArray,\n\tcomponentType: GLTF.AccessorComponentType,\n\tnormalized: boolean,\n): Float32Array {\n\tif (srcArray instanceof Float32Array) return srcArray.slice();\n\tconst dstArray = new Float32Array(srcArray);\n\tif (!normalized) return dstArray;\n\n\tfor (let i = 0; i < dstArray.length; i++) {\n\t\tdstArray[i] = MathUtils.decodeNormalizedInt(dstArray[i], componentType);\n\t}\n\n\treturn dstArray;\n}\n\n/** Returns a copy of the source array, with specified component type and normalization. */\nfunction fromFloat32Array(\n\tsrcArray: Float32Array,\n\tcomponentType: GLTF.AccessorComponentType,\n\tnormalized: boolean,\n): TypedArray {\n\tif (componentType === Accessor.ComponentType.FLOAT) return srcArray.slice();\n\tconst TypedArray = ComponentTypeToTypedArray[componentType];\n\tconst dstArray = new TypedArray(srcArray.length);\n\n\tfor (let i = 0; i < dstArray.length; i++) {\n\t\tdstArray[i] = normalized ? MathUtils.encodeNormalizedInt(srcArray[i], componentType) : srcArray[i];\n\t}\n\n\treturn dstArray;\n}\n","import { Accessor, AnimationChannel, AnimationSampler, type Document, type Transform } from '@gltf-transform/core';\nimport { assignDefaults, createTransform } from './utils.js';\n\nconst NAME = 'sequence';\n\nexport interface SequenceOptions {\n\t/** Frames per second, where one node is shown each frame. Default 10. */\n\tfps?: number;\n\t/** Pattern (regex) used to filter nodes for the sequence. Required. */\n\tpattern: RegExp;\n\t/** Name of the new animation. */\n\tname?: string;\n\t/** Whether to sort the nodes by name, or use original order. Default true. */\n\tsort?: boolean;\n}\n\nconst SEQUENCE_DEFAULTS: Required<SequenceOptions> = {\n\tname: '',\n\tfps: 10,\n\tpattern: /.*/,\n\tsort: true,\n};\n\n/**\n * Creates an {@link Animation} displaying each of the specified {@link Node}s sequentially.\n *\n * @category Transforms\n */\nexport function sequence(_options: SequenceOptions = SEQUENCE_DEFAULTS): Transform {\n\tconst options = assignDefaults(SEQUENCE_DEFAULTS, _options);\n\n\treturn createTransform(NAME, (doc: Document): void => {\n\t\tconst logger = doc.getLogger();\n\t\tconst root = doc.getRoot();\n\t\tconst fps = options.fps;\n\n\t\t// Collect sequence nodes.\n\t\tconst sequenceNodes = root.listNodes().filter((node) => node.getName().match(options.pattern));\n\n\t\t// Sort by node name.\n\t\tif (options.sort) {\n\t\t\tsequenceNodes.sort((a, b) => (a.getName() > b.getName() ? 1 : -1));\n\t\t}\n\n\t\t// Create animation cycling visibility of each node.\n\t\tconst anim = doc.createAnimation(options.name);\n\t\tconst animBuffer = root.listBuffers()[0];\n\t\tsequenceNodes.forEach((node, i) => {\n\t\t\t// Create keyframe tracks that show each node for a single frame.\n\t\t\tlet inputArray;\n\t\t\tlet outputArray;\n\t\t\tif (i === 0) {\n\t\t\t\tinputArray = [i / fps, (i + 1) / fps];\n\t\t\t\toutputArray = [1, 1, 1, 0, 0, 0];\n\t\t\t} else if (i === sequenceNodes.length - 1) {\n\t\t\t\tinputArray = [(i - 1) / fps, i / fps];\n\t\t\t\toutputArray = [0, 0, 0, 1, 1, 1];\n\t\t\t} else {\n\t\t\t\tinputArray = [(i - 1) / fps, i / fps, (i + 1) / fps];\n\t\t\t\toutputArray = [0, 0, 0, 1, 1, 1, 0, 0, 0];\n\t\t\t}\n\n\t\t\t// Append channel to animation sequence.\n\t\t\tconst input = doc.createAccessor().setArray(new Float32Array(inputArray)).setBuffer(animBuffer);\n\t\t\tconst output = doc\n\t\t\t\t.createAccessor()\n\t\t\t\t.setArray(new Float32Array(outputArray))\n\t\t\t\t.setBuffer(animBuffer)\n\t\t\t\t.setType(Accessor.Type.VEC3);\n\t\t\tconst sampler = doc\n\t\t\t\t.createAnimationSampler()\n\t\t\t\t.setInterpolation(AnimationSampler.Interpolation.STEP)\n\t\t\t\t.setInput(input)\n\t\t\t\t.setOutput(output);\n\t\t\tconst channel = doc\n\t\t\t\t.createAnimationChannel()\n\t\t\t\t.setTargetNode(node)\n\t\t\t\t.setTargetPath(AnimationChannel.TargetPath.SCALE)\n\t\t\t\t.setSampler(sampler);\n\t\t\tanim.addSampler(sampler).addChannel(channel);\n\t\t});\n\n\t\tlogger.debug(`${NAME}: Complete.`);\n\t});\n}\n","import { Document, Primitive, type Transform } from '@gltf-transform/core';\nimport type { MeshoptSimplifier } from 'meshoptimizer';\nimport { compactAttribute, compactPrimitive } from './compact-primitive.js';\nimport { convertPrimitiveToTriangles } from './convert-primitive-mode.js';\nimport { dequantizeAttributeArray } from './dequantize.js';\nimport { getPrimitiveVertexCount, VertexCountMethod } from './get-vertex-count.js';\nimport { unweldPrimitive } from './unweld.js';\nimport {\n\tassignDefaults,\n\tcreateTransform,\n\tdeepDisposePrimitive,\n\tdeepListAttributes,\n\tdeepSwapAttribute,\n\tformatDeltaOp,\n\tshallowCloneAccessor,\n} from './utils.js';\nimport { weld } from './weld.js';\n\nconst NAME = 'simplify';\n\nconst { POINTS, LINES, LINE_STRIP, LINE_LOOP, TRIANGLES, TRIANGLE_STRIP, TRIANGLE_FAN } = Primitive.Mode;\n\n/** Options for the {@link simplify} function. */\nexport interface SimplifyOptions {\n\t/** MeshoptSimplifier instance. */\n\tsimplifier: unknown;\n\t/** Target ratio (0–1) of vertices to keep. Default: 0.0 (0%). */\n\tratio?: number;\n\t/** Limit on error, as a fraction of mesh radius. Default: 0.0001 (0.01%). */\n\terror?: number;\n\t/**\n\t * Whether to lock topological borders of the mesh. May be necessary when\n\t * adjacent 'chunks' of a large mesh (e.g. terrain) share a border, helping\n\t * to ensure no seams appear.\n\t */\n\tlockBorder?: boolean;\n}\n\nexport const SIMPLIFY_DEFAULTS: Required<Omit<SimplifyOptions, 'simplifier'>> = {\n\tratio: 0.0,\n\terror: 0.0001,\n\tlockBorder: false,\n};\n\n/**\n * Simplification algorithm, based on meshoptimizer, producing meshes with fewer\n * triangles and vertices. Simplification is lossy, but the algorithm aims to\n * preserve visual quality as much as possible for given parameters.\n *\n * The algorithm aims to reach the target 'ratio', while minimizing error. If\n * error exceeds the specified 'error' threshold, the algorithm will quit\n * before reaching the target ratio. Examples:\n *\n * - ratio=0.0, error=0.0001: Aims for maximum simplification, constrained to 0.01% error.\n * - ratio=0.5, error=0.0001: Aims for 50% simplification, constrained to 0.01% error.\n * - ratio=0.5, error=1: Aims for 50% simplification, unconstrained by error.\n *\n * Topology, particularly split vertices, will also limit the simplifier. For\n * best results, apply a {@link weld} operation before simplification.\n *\n * Example:\n *\n * ```javascript\n * import { simplify, weld } from '@gltf-transform/functions';\n * import { MeshoptSimplifier } from 'meshoptimizer';\n *\n * await document.transform(\n *   weld({}),\n *   simplify({ simplifier: MeshoptSimplifier, ratio: 0.75, error: 0.001 })\n * );\n * ```\n *\n * References:\n * - https://github.com/zeux/meshoptimizer/blob/master/js/README.md#simplifier\n *\n * @category Transforms\n */\nexport function simplify(_options: SimplifyOptions): Transform {\n\tconst options = assignDefaults(SIMPLIFY_DEFAULTS, _options);\n\n\tconst simplifier = options.simplifier as typeof MeshoptSimplifier | undefined;\n\n\tif (!simplifier) {\n\t\tthrow new Error(`${NAME}: simplifier dependency required — install \"meshoptimizer\".`);\n\t}\n\n\treturn createTransform(NAME, async (document: Document): Promise<void> => {\n\t\tconst logger = document.getLogger();\n\n\t\tawait simplifier.ready;\n\t\tawait document.transform(weld({ overwrite: false }));\n\n\t\tlet numUnsupported = 0;\n\n\t\t// Simplify mesh primitives.\n\t\tfor (const mesh of document.getRoot().listMeshes()) {\n\t\t\tfor (const prim of mesh.listPrimitives()) {\n\t\t\t\tconst mode = prim.getMode();\n\t\t\t\tif (mode !== TRIANGLES && mode !== TRIANGLE_STRIP && mode !== TRIANGLE_FAN && mode !== POINTS) {\n\t\t\t\t\tnumUnsupported++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tsimplifyPrimitive(prim, options);\n\n\t\t\t\tif (getPrimitiveVertexCount(prim, VertexCountMethod.RENDER) === 0) {\n\t\t\t\t\tdeepDisposePrimitive(prim);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (mesh.listPrimitives().length === 0) mesh.dispose();\n\t\t}\n\n\t\tif (numUnsupported > 0) {\n\t\t\tlogger.warn(`${NAME}: Skipped ${numUnsupported} primitives: Unsupported draw mode.`);\n\t\t}\n\n\t\tlogger.debug(`${NAME}: Complete.`);\n\t});\n}\n\n/** @hidden */\nexport function simplifyPrimitive(prim: Primitive, _options: SimplifyOptions): Primitive {\n\tconst options = { ...SIMPLIFY_DEFAULTS, ..._options } as Required<SimplifyOptions>;\n\tconst simplifier = options.simplifier as typeof MeshoptSimplifier;\n\tconst graph = prim.getGraph();\n\tconst document = Document.fromGraph(graph)!;\n\tconst logger = document.getLogger();\n\n\tswitch (prim.getMode()) {\n\t\tcase POINTS:\n\t\t\treturn _simplifyPoints(document, prim, options);\n\t\tcase LINES:\n\t\tcase LINE_STRIP:\n\t\tcase LINE_LOOP:\n\t\t\tlogger.warn(`${NAME}: Skipping primitive simplification: Unsupported draw mode.`);\n\t\t\treturn prim;\n\t\tcase TRIANGLE_STRIP:\n\t\tcase TRIANGLE_FAN:\n\t\t\tconvertPrimitiveToTriangles(prim);\n\t\t\tbreak;\n\t}\n\n\t// (1) If primitive draws <50% of its vertex stream, compact before simplification.\n\n\tconst srcVertexCount = getPrimitiveVertexCount(prim, VertexCountMethod.UPLOAD);\n\tconst srcIndexCount = getPrimitiveVertexCount(prim, VertexCountMethod.RENDER);\n\tif (srcIndexCount < srcVertexCount / 2) {\n\t\tcompactPrimitive(prim);\n\t}\n\n\tconst position = prim.getAttribute('POSITION')!;\n\tconst srcIndices = prim.getIndices()!;\n\n\tlet positionArray = position.getArray()!;\n\tlet indicesArray = srcIndices.getArray()!;\n\n\t// (2) Gather attributes and indices in Meshopt-compatible format.\n\n\tif (!(positionArray instanceof Float32Array)) {\n\t\tpositionArray = dequantizeAttributeArray(positionArray, position.getComponentType(), position.getNormalized());\n\t}\n\tif (!(indicesArray instanceof Uint32Array)) {\n\t\tindicesArray = new Uint32Array(indicesArray);\n\t}\n\n\t// (3) Run simplification.\n\n\tconst targetCount = Math.floor((options.ratio * srcIndexCount) / 3) * 3;\n\tconst flags = options.lockBorder ? ['LockBorder'] : [];\n\n\tconst [dstIndicesArray, error] = simplifier.simplify(\n\t\tindicesArray,\n\t\tpositionArray,\n\t\t3,\n\t\ttargetCount,\n\t\toptions.error,\n\t\tflags as 'LockBorder'[],\n\t);\n\n\t// (4) Assign subset of indexes; compact primitive.\n\n\tprim.setIndices(shallowCloneAccessor(document, srcIndices).setArray(dstIndicesArray as Uint32Array<ArrayBuffer>));\n\tif (srcIndices.listParents().length === 1) srcIndices.dispose();\n\tcompactPrimitive(prim);\n\n\tconst dstVertexCount = getPrimitiveVertexCount(prim, VertexCountMethod.UPLOAD);\n\tif (dstVertexCount <= 65534) {\n\t\tprim.getIndices()!.setArray(new Uint16Array(prim.getIndices()!.getArray()!));\n\t}\n\n\tlogger.debug(`${NAME}: ${formatDeltaOp(srcVertexCount, dstVertexCount)} vertices, error: ${error.toFixed(4)}.`);\n\n\treturn prim;\n}\n\nfunction _simplifyPoints(document: Document, prim: Primitive, options: Required<SimplifyOptions>): Primitive {\n\tconst simplifier = options.simplifier as typeof MeshoptSimplifier;\n\tconst logger = document.getLogger();\n\n\tconst indices = prim.getIndices();\n\tif (indices) unweldPrimitive(prim);\n\n\tconst position = prim.getAttribute('POSITION')!;\n\tconst color = prim.getAttribute('COLOR_0');\n\tconst srcVertexCount = position.getCount();\n\n\tlet positionArray = position.getArray()!;\n\tlet colorArray = color ? color.getArray()! : undefined;\n\tconst colorStride = color ? color.getComponentSize() : undefined;\n\n\t// (1) Gather attributes in Meshopt-compatible format.\n\n\tif (!(positionArray instanceof Float32Array)) {\n\t\tpositionArray = dequantizeAttributeArray(positionArray, position.getComponentType(), position.getNormalized());\n\t}\n\tif (colorArray && !(colorArray instanceof Float32Array)) {\n\t\tcolorArray = dequantizeAttributeArray(colorArray, position.getComponentType(), position.getNormalized());\n\t}\n\n\t// (2) Run simplification.\n\n\tconst targetCount = Math.floor(options.ratio * srcVertexCount);\n\tconst dstIndicesArray = simplifier.simplifyPoints(positionArray, 3, targetCount, colorArray, colorStride);\n\n\t// (3) Write vertex attributes.\n\n\tconst [remap, unique] = simplifier.compactMesh(dstIndicesArray);\n\n\tlogger.debug(`${NAME}: ${formatDeltaOp(position.getCount(), unique)} vertices.`);\n\n\tfor (const srcAttribute of deepListAttributes(prim)) {\n\t\tconst dstAttribute = shallowCloneAccessor(document, srcAttribute);\n\t\tcompactAttribute(srcAttribute, null, remap as Uint32Array<ArrayBuffer>, dstAttribute, unique);\n\t\tdeepSwapAttribute(prim, srcAttribute, dstAttribute);\n\t\tif (srcAttribute.listParents().length === 1) srcAttribute.dispose();\n\t}\n\n\treturn prim;\n}\n","import { type Document, MathUtils, type Transform } from '@gltf-transform/core';\nimport { assignDefaults, createTransform } from './utils.js';\n\nconst NAME = 'sparse';\n\n/** Options for the {@link sparse} function. */\nexport interface SparseOptions {\n\t/**\n\t * Threshold ratio used to determine when an accessor should be sparse.\n\t * Default: 1 / 3.\n\t */\n\tratio: number;\n}\n\nconst SPARSE_DEFAULTS: Required<SparseOptions> = {\n\tratio: 1 / 3,\n};\n\n/**\n * Scans all {@link Accessor Accessors} in the Document, detecting whether each Accessor\n * would benefit from sparse data storage. Currently, sparse data storage is used only\n * when many values (>= ratio) are zeroes. Particularly for assets using morph target\n * (\"shape key\") animation, sparse data storage may significantly reduce file sizes.\n *\n * Example:\n *\n * ```ts\n * import { sparse } from '@gltf-transform/functions';\n *\n * accessor.getArray(); // → [ 0, 0, 0, 0, 0, 25.0, 0, 0, ... ]\n * accessor.getSparse(); // → false\n *\n * await document.transform(sparse({ratio: 1 / 10}));\n *\n * accessor.getSparse(); // → true\n * ```\n *\n * @experimental\n * @category Transforms\n */\nexport function sparse(_options: SparseOptions = SPARSE_DEFAULTS): Transform {\n\tconst options = assignDefaults(SPARSE_DEFAULTS, _options);\n\n\tconst ratio = options.ratio;\n\tif (ratio < 0 || ratio > 1) {\n\t\tthrow new Error(`${NAME}: Ratio must be between 0 and 1.`);\n\t}\n\n\treturn createTransform(NAME, (document: Document): void => {\n\t\tconst root = document.getRoot();\n\t\tconst logger = document.getLogger();\n\n\t\tlet modifiedCount = 0;\n\n\t\tfor (const accessor of root.listAccessors()) {\n\t\t\tconst count = accessor.getCount();\n\t\t\tconst base = Array(accessor.getElementSize()).fill(0);\n\t\t\tconst el = Array(accessor.getElementSize()).fill(0);\n\n\t\t\tlet nonZeroCount = 0;\n\t\t\tfor (let i = 0; i < count; i++) {\n\t\t\t\taccessor.getElement(i, el);\n\t\t\t\tif (!MathUtils.eq(el, base, 0)) nonZeroCount++;\n\t\t\t\tif (nonZeroCount / count >= ratio) break;\n\t\t\t}\n\n\t\t\tconst sparse = nonZeroCount / count < ratio;\n\t\t\tif (sparse !== accessor.getSparse()) {\n\t\t\t\taccessor.setSparse(sparse);\n\t\t\t\tmodifiedCount++;\n\t\t\t}\n\t\t}\n\n\t\tlogger.debug(`${NAME}: Updated ${modifiedCount} accessors.`);\n\t\tlogger.debug(`${NAME}: Complete.`);\n\t});\n}\n","import {\n\ttype Accessor,\n\ttype Document,\n\ttype ILogger,\n\tPrimitive,\n\ttype Transform,\n\ttype TypedArray,\n\tuuid,\n} from '@gltf-transform/core';\nimport { assignDefaults, createTransform } from './utils.js';\n\nconst NAME = 'tangents';\n\n/** Options for the {@link tangents} function. */\nexport interface TangentsOptions {\n\t/**\n\t * Callback function to generate tangents from position, uv, and normal attributes.\n\t * Generally, users will want to provide the `generateTangents` from the\n\t * [mikktspace](https://github.com/donmccurdy/mikktspace-wasm) library, which is not\n\t * included by default.\n\t */\n\tgenerateTangents?: (pos: Float32Array, norm: Float32Array, uv: Float32Array) => Float32Array;\n\t/** Whether to overwrite existing `TANGENT` attributes. */\n\toverwrite?: boolean;\n}\n\nconst TANGENTS_DEFAULTS: Required<Omit<TangentsOptions, 'generateTangents'>> = {\n\toverwrite: false,\n};\n\n/**\n * Generates MikkTSpace vertex tangents for mesh primitives, which may fix rendering issues\n * occurring with some baked normal maps. Requires access to the [mikktspace](https://github.com/donmccurdy/mikktspace-wasm)\n * WASM package, or equivalent.\n *\n * Example:\n *\n * ```ts\n * import { generateTangents } from 'mikktspace';\n * import { tangents } from '@gltf-transform/functions';\n *\n * await document.transform(\n * \ttangents({generateTangents})\n * );\n * ```\n *\n * @category Transforms\n */\nexport function tangents(_options: TangentsOptions = TANGENTS_DEFAULTS): Transform {\n\tconst options = assignDefaults(TANGENTS_DEFAULTS, _options);\n\n\tif (!options.generateTangents) {\n\t\tthrow new Error(`${NAME}: generateTangents callback required — install \"mikktspace\".`);\n\t}\n\n\treturn createTransform(NAME, (doc: Document): void => {\n\t\tconst logger = doc.getLogger();\n\t\tconst attributeIDs = new Map<TypedArray, string>();\n\t\tconst tangentCache = new Map<string, Accessor>();\n\t\tlet modified = 0;\n\n\t\tfor (const mesh of doc.getRoot().listMeshes()) {\n\t\t\tconst meshName = mesh.getName();\n\t\t\tconst meshPrimitives = mesh.listPrimitives();\n\n\t\t\tfor (let i = 0; i < meshPrimitives.length; i++) {\n\t\t\t\tconst prim = meshPrimitives[i];\n\n\t\t\t\t// Skip primitives for which we can't compute tangents.\n\t\t\t\tif (!filterPrimitive(prim, logger, meshName, i, options.overwrite)) continue;\n\n\t\t\t\tconst texcoordSemantic = getNormalTexcoord(prim);\n\n\t\t\t\t// Nullability conditions checked by filterPrimitive() above.\n\t\t\t\tconst position = prim.getAttribute('POSITION')!.getArray()!;\n\t\t\t\tconst normal = prim.getAttribute('NORMAL')!.getArray()!;\n\t\t\t\tconst texcoord = prim.getAttribute(texcoordSemantic)!.getArray()!;\n\n\t\t\t\t// Compute UUIDs for each attribute.\n\t\t\t\tconst positionID = attributeIDs.get(position) || uuid();\n\t\t\t\tattributeIDs.set(position, positionID);\n\n\t\t\t\tconst normalID = attributeIDs.get(normal) || uuid();\n\t\t\t\tattributeIDs.set(normal, normalID);\n\n\t\t\t\tconst texcoordID = attributeIDs.get(texcoord) || uuid();\n\t\t\t\tattributeIDs.set(texcoord, texcoordID);\n\n\t\t\t\t// Dispose of previous TANGENT accessor if only used by this primitive (and Root).\n\t\t\t\tconst prevTangent = prim.getAttribute('TANGENT');\n\t\t\t\tif (prevTangent && prevTangent.listParents().length === 2) prevTangent.dispose();\n\n\t\t\t\t// If we've already computed tangents for this pos/norm/uv set, reuse them.\n\t\t\t\tconst attributeHash = `${positionID}|${normalID}|${texcoordID}`;\n\t\t\t\tlet tangent = tangentCache.get(attributeHash);\n\t\t\t\tif (tangent) {\n\t\t\t\t\tlogger.debug(`${NAME}: Found cache for primitive ${i} of mesh \"${meshName}\".`);\n\t\t\t\t\tprim.setAttribute('TANGENT', tangent);\n\t\t\t\t\tmodified++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Otherwise, generate tangents with the 'mikktspace' WASM library.\n\t\t\t\tlogger.debug(`${NAME}: Generating for primitive ${i} of mesh \"${meshName}\".`);\n\t\t\t\tconst tangentBuffer = prim.getAttribute('POSITION')!.getBuffer();\n\t\t\t\tconst tangentArray = options.generateTangents!(\n\t\t\t\t\tposition instanceof Float32Array ? position : new Float32Array(position),\n\t\t\t\t\tnormal instanceof Float32Array ? normal : new Float32Array(normal),\n\t\t\t\t\ttexcoord instanceof Float32Array ? texcoord : new Float32Array(texcoord),\n\t\t\t\t) as Float32Array<ArrayBuffer>;\n\n\t\t\t\t// See: https://github.com/KhronosGroup/glTF-Sample-Models/issues/174\n\t\t\t\tfor (let i = 3; i < tangentArray.length; i += 4) tangentArray[i] *= -1;\n\n\t\t\t\ttangent = doc.createAccessor().setBuffer(tangentBuffer).setArray(tangentArray).setType('VEC4');\n\t\t\t\tprim.setAttribute('TANGENT', tangent);\n\n\t\t\t\ttangentCache.set(attributeHash, tangent);\n\t\t\t\tmodified++;\n\t\t\t}\n\t\t}\n\n\t\tif (!modified) {\n\t\t\tlogger.warn(`${NAME}: No qualifying primitives found. See debug output.`);\n\t\t} else {\n\t\t\tlogger.debug(`${NAME}: Complete.`);\n\t\t}\n\t});\n}\n\nfunction getNormalTexcoord(prim: Primitive): string {\n\tconst material = prim.getMaterial();\n\tif (!material) return 'TEXCOORD_0';\n\n\tconst normalTextureInfo = material.getNormalTextureInfo();\n\tif (!normalTextureInfo) return 'TEXCOORD_0';\n\n\tconst texcoord = normalTextureInfo.getTexCoord();\n\tconst semantic = `TEXCOORD_${texcoord}`;\n\tif (prim.getAttribute(semantic)) return semantic;\n\n\treturn 'TEXCOORD_0';\n}\n\nfunction filterPrimitive(prim: Primitive, logger: ILogger, meshName: string, i: number, overwrite: boolean): boolean {\n\tif (\n\t\tprim.getMode() !== Primitive.Mode.TRIANGLES ||\n\t\t!prim.getAttribute('POSITION') ||\n\t\t!prim.getAttribute('NORMAL') ||\n\t\t!prim.getAttribute('TEXCOORD_0')\n\t) {\n\t\tlogger.debug(\n\t\t\t`${NAME}: Skipping primitive ${i} of mesh \"${meshName}\": primitives must` +\n\t\t\t\t' have attributes=[POSITION, NORMAL, TEXCOORD_0] and mode=TRIANGLES.',\n\t\t);\n\t\treturn false;\n\t}\n\n\tif (prim.getAttribute('TANGENT') && !overwrite) {\n\t\tlogger.debug(`${NAME}: Skipping primitive ${i} of mesh \"${meshName}\": TANGENT found.`);\n\t\treturn false;\n\t}\n\n\tif (prim.getIndices()) {\n\t\tlogger.warn(`${NAME}: Skipping primitive ${i} of mesh \"${meshName}\": primitives must` + ' be unwelded.');\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n","import {\n\tBufferUtils,\n\ttype Document,\n\tFileUtils,\n\tImageUtils,\n\ttype Texture,\n\tTextureChannel,\n\ttype Transform,\n\ttype vec2,\n} from '@gltf-transform/core';\nimport { EXTTextureAVIF, EXTTextureWebP } from '@gltf-transform/extensions';\nimport ndarray from 'ndarray';\nimport { lanczos2, lanczos3 } from 'ndarray-lanczos';\nimport { getPixels, savePixels } from 'ndarray-pixels';\nimport type sharp from 'sharp';\nimport { getTextureColorSpace } from './get-texture-color-space.js';\nimport { getTextureChannelMask } from './list-texture-channels.js';\nimport { listTextureSlots } from './list-texture-slots.js';\nimport { assignDefaults, createTransform, fitPowerOfTwo, fitWithin, formatBytes } from './utils.js';\n\nconst NAME = 'textureCompress';\n\ntype Format = (typeof TEXTURE_COMPRESS_SUPPORTED_FORMATS)[number];\nexport const TEXTURE_COMPRESS_SUPPORTED_FORMATS = ['jpeg', 'png', 'webp', 'avif'] as const;\nconst SUPPORTED_MIME_TYPES = ['image/jpeg', 'image/png', 'image/webp', 'image/avif'];\n\n/** Resampling filter methods. LANCZOS3 is sharper, LANCZOS2 is smoother. */\nexport enum TextureResizeFilter {\n\t/** Lanczos3 (sharp) */\n\tLANCZOS3 = 'lanczos3',\n\t/** Lanczos2 (smooth) */\n\tLANCZOS2 = 'lanczos2',\n}\n\nexport interface TextureCompressOptions {\n\t/** Instance of the Sharp encoder, which must be installed from the\n\t * 'sharp' package and provided by the caller. When not provided, a\n\t * platform-specific fallback implementation will be used, and most\n\t * quality- and compression-related options are ignored.\n\t */\n\tencoder?: unknown;\n\t/**\n\t * Target image format. If specified, included textures in other formats\n\t * will be converted. Default: original format.\n\t */\n\ttargetFormat?: Format;\n\t/**\n\t * Resizes textures to given maximum width/height, preserving aspect ratio.\n\t * For example, a 4096x8192 texture, resized with limit [2048, 2048] will\n\t * be reduced to 1024x2048.\n\t *\n\t * Presets \"nearest-pot\", \"ceil-pot\", and \"floor-pot\" resize textures to\n\t * power-of-two dimensions, for older graphics APIs including WebGL 1.0.\n\t */\n\tresize?: vec2 | 'nearest-pot' | 'ceil-pot' | 'floor-pot';\n\t/** Interpolation used if resizing. Default: TextureResizeFilter.LANCZOS3. */\n\tresizeFilter?: TextureResizeFilter;\n\t/** Pattern identifying textures to compress, matched to name or URI. */\n\tpattern?: RegExp | null;\n\t/**\n\t * Pattern matching the format(s) to be compressed or converted. Some examples\n\t * of formats include \"jpeg\" and \"png\".\n\t */\n\tformats?: RegExp | null;\n\t/**\n\t * Pattern matching the material texture slot(s) to be compressed or converted.\n\t * Some examples of slot names include \"baseColorTexture\", \"occlusionTexture\",\n\t * \"metallicRoughnessTexture\", and \"normalTexture\".\n\t */\n\tslots?: RegExp | null;\n\n\t/** Quality, 1-100. Default: auto. */\n\tquality?: number | null;\n\t/**\n\t * Level of CPU effort to reduce file size, 0-100. PNG, WebP, and AVIF\n\t * only. Supported only when a Sharp encoder is provided. Default: auto.\n\t */\n\teffort?: number | null;\n\t/**\n\t * Use lossless compression mode. WebP and AVIF only. Supported only when a\n\t * Sharp encoder is provided. Default: false.\n\t */\n\tlossless?: boolean;\n\t/**\n\t * Use near lossless compression mode. WebP only. Supported only when a\n\t * Sharp encoder is provided. Default: false.\n\t */\n\tnearLossless?: boolean;\n\n\t/**\n\t * Allows lower resolution for chroma than for luma, reducing file size. For\n\t * non-color textures such as normal maps, the chroma/luma distinction does\n\t * not apply, and chroma subsampling should be disabled. Options are '4:4:4'\n\t * (off) and '4:2:0' (on). JPEG and AVIF only. Default: auto.\n\t */\n\tchromaSubsampling?: '4:2:0' | '4:4:4';\n\n\t/**\n\t * Attempts to avoid processing images that could exceed memory or other other\n\t * limits, throwing an error instead. Default: true.\n\t * @experimental\n\t */\n\tlimitInputPixels?: boolean;\n}\n\nexport type CompressTextureOptions = Omit<TextureCompressOptions, 'pattern' | 'formats' | 'slots'>;\n\n// IMPORTANT: No defaults for quality flags, see https://github.com/donmccurdy/glTF-Transform/issues/969.\nexport const TEXTURE_COMPRESS_DEFAULTS: Omit<TextureCompressOptions, 'resize' | 'targetFormat' | 'encoder'> = {\n\tresizeFilter: TextureResizeFilter.LANCZOS3,\n\tpattern: undefined,\n\tformats: undefined,\n\tslots: undefined,\n\tquality: undefined,\n\teffort: undefined,\n\tlossless: false,\n\tnearLossless: false,\n\tchromaSubsampling: undefined,\n\tlimitInputPixels: true,\n};\n\n/**\n * Optimizes images, optionally resizing or converting to JPEG, PNG, WebP, or AVIF formats.\n *\n * For best results use a Node.js environment, install the `sharp` module, and\n * provide an encoder. When the encoder is omitted — `sharp` works only in Node.js —\n * the implementation will use a platform-specific fallback encoder, and most\n * quality- and compression-related options are ignored.\n *\n * Example:\n *\n * ```javascript\n * import { textureCompress } from '@gltf-transform/functions';\n * import sharp from 'sharp';\n *\n * // (A) Optimize without conversion.\n * await document.transform(\n * \ttextureCompress({encoder: sharp})\n * );\n *\n * // (B) Optimize and convert images to WebP.\n * await document.transform(\n * \ttextureCompress({\n * \t\tencoder: sharp,\n * \t\ttargetFormat: 'webp',\n * \t\tslots: /^(?!normalTexture).*$/ // exclude normal maps\n * \t})\n * );\n *\n * // (C) Resize and convert images to WebP in a browser, without a Sharp\n * // encoder. Most quality- and compression-related options are ignored.\n * await document.transform(\n * \ttextureCompress({ targetFormat: 'webp', resize: [1024, 1024] })\n * );\n * ```\n *\n * @category Transforms\n */\nexport function textureCompress(_options: TextureCompressOptions): Transform {\n\tconst options = assignDefaults(TEXTURE_COMPRESS_DEFAULTS, _options);\n\tconst targetFormat = options.targetFormat as Format | undefined;\n\tconst patternRe = options.pattern;\n\tconst formatsRe = options.formats;\n\tconst slotsRe = options.slots;\n\n\treturn createTransform(NAME, async (document: Document): Promise<void> => {\n\t\tconst logger = document.getLogger();\n\t\tconst textures = document.getRoot().listTextures();\n\n\t\tawait Promise.all(\n\t\t\ttextures.map(async (texture, textureIndex) => {\n\t\t\t\tconst slots = listTextureSlots(texture);\n\t\t\t\tconst channels = getTextureChannelMask(texture);\n\t\t\t\tconst textureLabel =\n\t\t\t\t\ttexture.getURI() ||\n\t\t\t\t\ttexture.getName() ||\n\t\t\t\t\t`${textureIndex + 1}/${document.getRoot().listTextures().length}`;\n\t\t\t\tconst prefix = `${NAME}(${textureLabel})`;\n\n\t\t\t\t// FILTER: Exclude textures that don't match (a) 'slots' or (b) expected formats.\n\n\t\t\t\tif (!SUPPORTED_MIME_TYPES.includes(texture.getMimeType())) {\n\t\t\t\t\tlogger.debug(`${prefix}: Skipping, unsupported texture type \"${texture.getMimeType()}\".`);\n\t\t\t\t\treturn;\n\t\t\t\t} else if (patternRe && !patternRe.test(texture.getName()) && !patternRe.test(texture.getURI())) {\n\t\t\t\t\tlogger.debug(`${prefix}: Skipping, excluded by \"pattern\" parameter.`);\n\t\t\t\t\treturn;\n\t\t\t\t} else if (formatsRe && !formatsRe.test(texture.getMimeType())) {\n\t\t\t\t\tlogger.debug(`${prefix}: Skipping, \"${texture.getMimeType()}\" excluded by \"formats\" parameter.`);\n\t\t\t\t\treturn;\n\t\t\t\t} else if (slotsRe && slots.length && !slots.some((slot) => slotsRe.test(slot))) {\n\t\t\t\t\tlogger.debug(`${prefix}: Skipping, [${slots.join(', ')}] excluded by \"slots\" parameter.`);\n\t\t\t\t\treturn;\n\t\t\t\t} else if (options.targetFormat === 'jpeg' && channels & TextureChannel.A) {\n\t\t\t\t\tlogger.warn(`${prefix}: Skipping, [${slots.join(', ')}] requires alpha channel.`);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst srcFormat = getFormat(texture);\n\t\t\t\tconst dstFormat = targetFormat || srcFormat;\n\t\t\t\tlogger.debug(`${prefix}: Format = ${srcFormat} → ${dstFormat}`);\n\t\t\t\tlogger.debug(`${prefix}: Slots = [${slots.join(', ')}]`);\n\n\t\t\t\tconst srcImage = texture.getImage()!;\n\t\t\t\tconst srcByteLength = srcImage.byteLength;\n\n\t\t\t\tawait compressTexture(texture, options);\n\n\t\t\t\tconst dstImage = texture.getImage()!;\n\t\t\t\tconst dstByteLength = dstImage.byteLength;\n\n\t\t\t\tconst flag = srcImage === dstImage ? ' (SKIPPED' : '';\n\n\t\t\t\tlogger.debug(`${prefix}: Size = ${formatBytes(srcByteLength)} → ${formatBytes(dstByteLength)}${flag}`);\n\t\t\t}),\n\t\t);\n\n\t\t// Attach EXT_texture_webp if needed.\n\t\tconst webpExtension = document.createExtension(EXTTextureWebP);\n\t\tif (textures.some((texture) => texture.getMimeType() === 'image/webp')) {\n\t\t\twebpExtension.setRequired(true);\n\t\t} else {\n\t\t\twebpExtension.dispose();\n\t\t}\n\n\t\t// Attach EXT_texture_avif if needed.\n\t\tconst avifExtension = document.createExtension(EXTTextureAVIF);\n\t\tif (textures.some((texture) => texture.getMimeType() === 'image/avif')) {\n\t\t\tavifExtension.setRequired(true);\n\t\t} else {\n\t\t\tavifExtension.dispose();\n\t\t}\n\n\t\tlogger.debug(`${NAME}: Complete.`);\n\t});\n}\n\n/**\n * Optimizes a single {@link Texture}, optionally resizing or converting to JPEG, PNG, WebP, or AVIF formats.\n *\n * For best results use a Node.js environment, install the `sharp` module, and\n * provide an encoder. When the encoder is omitted — `sharp` works only in Node.js —\n * the implementation will use a platform-specific fallback encoder, and most\n * quality- and compression-related options are ignored.\n *\n * Example:\n *\n * ```javascript\n * import { compressTexture } from '@gltf-transform/functions';\n * import sharp from 'sharp';\n *\n * const texture = document.getRoot().listTextures()\n * \t.find((texture) => texture.getName() === 'MyTexture');\n *\n * // (A) Node.js.\n * await compressTexture(texture, {\n * \tencoder: sharp,\n * \ttargetFormat: 'webp',\n * \tresize: [1024, 1024]\n * });\n *\n * // (B) Web.\n * await compressTexture(texture, {\n * \ttargetFormat: 'webp',\n * \tresize: [1024, 1024]\n * });\n * ```\n */\nexport async function compressTexture(texture: Texture, _options: CompressTextureOptions): Promise<void> {\n\tconst options = { ...TEXTURE_COMPRESS_DEFAULTS, ..._options } as Required<CompressTextureOptions>;\n\tconst encoder = options.encoder as typeof sharp | null;\n\n\tconst srcURI = texture.getURI();\n\tconst srcFormat = getFormat(texture);\n\tconst colorSpace = getTextureColorSpace(texture);\n\tconst dstFormat = options.targetFormat || srcFormat;\n\tconst srcMimeType = texture.getMimeType();\n\tconst dstMimeType = `image/${dstFormat}`;\n\tconst chromaSubsampling = options.chromaSubsampling || (colorSpace === 'srgb' ? '4:2:0' : '4:4:4');\n\n\tconst srcImage = texture.getImage()!;\n\tconst dstImage = encoder\n\t\t? await _encodeWithSharp(srcImage, srcMimeType, dstMimeType, { ...options, chromaSubsampling })\n\t\t: await _encodeWithNdarrayPixels(srcImage, srcMimeType, dstMimeType, { ...options, chromaSubsampling });\n\n\tconst srcByteLength = srcImage.byteLength;\n\tconst dstByteLength = dstImage.byteLength;\n\n\tif (srcMimeType === dstMimeType && dstByteLength >= srcByteLength && !options.resize) {\n\t\t// Skip if src/dst formats match and dst is larger than the original.\n\t\treturn;\n\t} else if (srcMimeType === dstMimeType) {\n\t\t// Overwrite if src/dst formats match and dst is smaller than the original.\n\t\ttexture.setImage(dstImage);\n\t} else {\n\t\t// Overwrite, then update path and MIME type if src/dst formats differ.\n\t\tconst srcExtension = srcURI ? FileUtils.extension(srcURI) : ImageUtils.mimeTypeToExtension(srcMimeType);\n\t\tconst dstExtension = ImageUtils.mimeTypeToExtension(dstMimeType);\n\t\tconst dstURI = texture.getURI().replace(new RegExp(`\\\\.${srcExtension}$`), `.${dstExtension}`);\n\t\ttexture.setImage(dstImage).setMimeType(dstMimeType).setURI(dstURI);\n\t}\n}\n\nasync function _encodeWithSharp(\n\tsrcImage: Uint8Array,\n\t_srcMimeType: string,\n\tdstMimeType: string,\n\toptions: Required<CompressTextureOptions>,\n): Promise<Uint8Array> {\n\tconst encoder = options.encoder as typeof sharp;\n\tlet encoderOptions: sharp.JpegOptions | sharp.PngOptions | sharp.WebpOptions | sharp.AvifOptions = {};\n\n\tconst dstFormat = getFormatFromMimeType(dstMimeType);\n\n\tswitch (dstFormat) {\n\t\tcase 'jpeg':\n\t\t\tencoderOptions = {\n\t\t\t\tquality: options.quality,\n\t\t\t\tchromaSubsampling: options.chromaSubsampling,\n\t\t\t} as sharp.JpegOptions;\n\t\t\tbreak;\n\t\tcase 'png':\n\t\t\tencoderOptions = {\n\t\t\t\tquality: options.quality,\n\t\t\t\teffort: remap(options.effort, 100, 10),\n\t\t\t} as sharp.PngOptions;\n\t\t\tbreak;\n\t\tcase 'webp':\n\t\t\tencoderOptions = {\n\t\t\t\tquality: options.quality,\n\t\t\t\teffort: remap(options.effort, 100, 6),\n\t\t\t\tlossless: options.lossless,\n\t\t\t\tnearLossless: options.nearLossless,\n\t\t\t} as sharp.WebpOptions;\n\t\t\tbreak;\n\t\tcase 'avif':\n\t\t\tencoderOptions = {\n\t\t\t\tquality: options.quality,\n\t\t\t\teffort: remap(options.effort, 100, 9),\n\t\t\t\tlossless: options.lossless,\n\t\t\t\tchromaSubsampling: options.chromaSubsampling,\n\t\t\t} as sharp.AvifOptions;\n\t\t\tbreak;\n\t}\n\n\tconst limitInputPixels = options.limitInputPixels;\n\tconst instance = encoder(srcImage, { limitInputPixels }).toFormat(dstFormat, encoderOptions);\n\n\tif (options.resize) {\n\t\tconst srcSize = ImageUtils.getSize(srcImage, _srcMimeType)!;\n\t\tconst dstSize = Array.isArray(options.resize)\n\t\t\t? fitWithin(srcSize, options.resize)\n\t\t\t: fitPowerOfTwo(srcSize, options.resize);\n\t\tinstance.resize(dstSize[0], dstSize[1], { fit: 'fill', kernel: options.resizeFilter });\n\t}\n\n\treturn BufferUtils.toView((await instance.toBuffer()) as Buffer<ArrayBuffer>);\n}\n\nasync function _encodeWithNdarrayPixels(\n\tsrcImage: Uint8Array,\n\tsrcMimeType: string,\n\tdstMimeType: string,\n\toptions: Required<CompressTextureOptions>,\n): Promise<Uint8Array> {\n\tconst srcPixels = (await getPixels(srcImage, srcMimeType)) as ndarray.NdArray<Uint8Array>;\n\n\tif (options.resize) {\n\t\tconst [w, h] = srcPixels.shape;\n\t\tconst dstSize = Array.isArray(options.resize)\n\t\t\t? fitWithin([w, h], options.resize)\n\t\t\t: fitPowerOfTwo([w, h], options.resize);\n\t\tconst dstPixels = ndarray(new Uint8Array(dstSize[0] * dstSize[1] * 4), [...dstSize, 4]);\n\t\toptions.resizeFilter === TextureResizeFilter.LANCZOS3\n\t\t\t? lanczos3(srcPixels, dstPixels)\n\t\t\t: lanczos2(srcPixels, dstPixels);\n\t\treturn savePixels(dstPixels, dstMimeType);\n\t}\n\n\treturn savePixels(srcPixels, dstMimeType);\n}\n\nfunction getFormat(texture: Texture): Format {\n\treturn getFormatFromMimeType(texture.getMimeType());\n}\n\nfunction getFormatFromMimeType(mimeType: string): Format {\n\tconst format = mimeType.split('/').pop() as Format | undefined;\n\tif (!format || !TEXTURE_COMPRESS_SUPPORTED_FORMATS.includes(format)) {\n\t\tthrow new Error(`Unknown MIME type \"${mimeType}\".`);\n\t}\n\treturn format;\n}\n\nfunction remap(value: number | null | undefined, srcMax: number, dstMax: number): number | undefined {\n\tif (value == null) return undefined;\n\treturn Math.round((value / srcMax) * dstMax);\n}\n","import { type Accessor, Document, type Node, type Transform } from '@gltf-transform/core';\nimport type { InstancedMesh } from '@gltf-transform/extensions';\nimport { createTransform } from './utils.js';\n\nconst NAME = 'uninstance';\n\nexport interface UninstanceOptions {}\nconst UNINSTANCE_DEFAULTS: Required<UninstanceOptions> = {};\n\n/**\n * Removes extension {@link EXTMeshGPUInstancing}, reversing the effects of the\n * {@link instance} transform or similar instancing operations. For each {@link Node}\n * associated with an {@link InstancedMesh}, the Node's {@link Mesh} and InstancedMesh will\n * be detached. In their place, one Node per instance will be attached to the original\n * Node as children, associated with the same Mesh. The extension, `EXT_mesh_gpu_instancing`,\n * will be removed from the {@link Document}.\n *\n * In applications that support `EXT_mesh_gpu_instancing`, removing the extension\n * is likely to substantially increase draw calls and reduce performance. Removing\n * the extension may be helpful for compatibility in applications without such support.\n *\n * Example:\n *\n * ```ts\n * import { uninstance } from '@gltf-transform/functions';\n *\n * document.getRoot().listNodes(); // → [ Node x 10 ]\n *\n * await document.transform(uninstance());\n *\n * document.getRoot().listNodes(); // → [ Node x 1000 ]\n * ```\n *\n * @category Transforms\n */\nexport function uninstance(_options: UninstanceOptions = UNINSTANCE_DEFAULTS): Transform {\n\treturn createTransform(NAME, async (document: Document): Promise<void> => {\n\t\tconst logger = document.getLogger();\n\t\tconst root = document.getRoot();\n\n\t\tconst instanceAttributes = new Set<Accessor>();\n\n\t\tfor (const srcNode of document.getRoot().listNodes()) {\n\t\t\tconst batch = srcNode.getExtension<InstancedMesh>('EXT_mesh_gpu_instancing');\n\t\t\tif (!batch) continue;\n\n\t\t\t// For each instance, attach a new Node under the source Node.\n\t\t\tfor (const instanceNode of createInstanceNodes(srcNode)) {\n\t\t\t\tsrcNode.addChild(instanceNode);\n\t\t\t}\n\n\t\t\tfor (const instanceAttribute of batch.listAttributes()) {\n\t\t\t\tinstanceAttributes.add(instanceAttribute);\n\t\t\t}\n\n\t\t\tsrcNode.setMesh(null);\n\t\t\tbatch.dispose();\n\t\t}\n\n\t\t// Clean up unused instance attributes.\n\t\tfor (const attribute of instanceAttributes) {\n\t\t\tif (attribute.listParents().every((parent) => parent === root)) {\n\t\t\t\tattribute.dispose();\n\t\t\t}\n\t\t}\n\n\t\tdocument.disposeExtension('EXT_mesh_gpu_instancing');\n\n\t\tlogger.debug(`${NAME}: Complete.`);\n\t});\n}\n\n/**\n * Given a {@link Node} with an {@link InstancedMesh} extension, returns a list\n * containing one Node per instance in the InstancedMesh. Each Node will have\n * the transform (translation/rotation/scale) of the corresponding instance,\n * and will be assigned to the same {@link Mesh}.\n *\n * May be used to unpack instancing previously applied with {@link instance}\n * and {@link EXTMeshGPUInstancing}. For a transform that applies this operation\n * to the entire {@link Document}, see {@link uninstance}.\n *\n * Example:\n * ```javascript\n * import { createInstanceNodes } from '@gltf-transform/functions';\n *\n * for (const instanceNode of createInstanceNodes(batchNode)) {\n *  batchNode.addChild(instanceNode);\n * }\n *\n * batchNode.setMesh(null).setExtension('EXTMeshGPUInstancing', null);\n * ```\n */\nexport function createInstanceNodes(batchNode: Node): Node[] {\n\tconst batch = batchNode.getExtension<InstancedMesh>('EXT_mesh_gpu_instancing');\n\tif (!batch) return [];\n\n\tconst semantics = batch.listSemantics();\n\tif (semantics.length === 0) return [];\n\n\tconst document = Document.fromGraph(batchNode.getGraph())!;\n\tconst instanceCount = batch.listAttributes()[0].getCount();\n\tconst instanceCountDigits = String(instanceCount).length;\n\tconst mesh = batchNode.getMesh();\n\tconst batchName = batchNode.getName();\n\n\tconst instanceNodes = [];\n\n\t// For each instance construct a Node, assign attributes, and push to list.\n\tfor (let i = 0; i < instanceCount; i++) {\n\t\tconst instanceNode = document.createNode().setMesh(mesh);\n\n\t\t// MyNode_001, MyNode_002, ...\n\t\tif (batchName) {\n\t\t\tconst paddedIndex = String(i).padStart(instanceCountDigits, '0');\n\t\t\tinstanceNode.setName(`${batchName}_${paddedIndex}`);\n\t\t}\n\n\t\t// TRS attributes are applied to node transform; all other attributes are extras.\n\t\tfor (const semantic of semantics) {\n\t\t\tconst attribute = batch.getAttribute(semantic)!;\n\t\t\tswitch (semantic) {\n\t\t\t\tcase 'TRANSLATION':\n\t\t\t\t\tinstanceNode.setTranslation(attribute.getElement(i, [0, 0, 0]));\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ROTATION':\n\t\t\t\t\tinstanceNode.setRotation(attribute.getElement(i, [0, 0, 0, 1]));\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'SCALE':\n\t\t\t\t\tinstanceNode.setScale(attribute.getElement(i, [1, 1, 1]));\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\t_setInstanceExtras(instanceNode, semantic, attribute, i);\n\t\t\t}\n\t\t}\n\n\t\tinstanceNodes.push(instanceNode);\n\t}\n\n\treturn instanceNodes;\n}\n\nfunction _setInstanceExtras(node: Node, semantic: string, attribute: Accessor, index: number): void {\n\tconst value = attribute.getType() === 'SCALAR' ? attribute.getScalar(index) : attribute.getElement(index, []);\n\tnode.setExtras({ ...node.getExtras(), [semantic]: value });\n}\n","import type { Document, Transform } from '@gltf-transform/core';\nimport { KHRMaterialsUnlit } from '@gltf-transform/extensions';\n\n/**\n * @category Transforms\n */\nexport function unlit(): Transform {\n\treturn (doc: Document): void => {\n\t\tconst unlitExtension = doc.createExtension(KHRMaterialsUnlit) as KHRMaterialsUnlit;\n\t\tconst unlit = unlitExtension.createUnlit();\n\t\tdoc.getRoot()\n\t\t\t.listMaterials()\n\t\t\t.forEach((material) => {\n\t\t\t\tmaterial.setExtension('KHR_materials_unlit', unlit);\n\t\t\t});\n\t};\n}\n","import type { Document, Transform } from '@gltf-transform/core';\nimport { createTransform } from './utils.js';\n\nconst NAME = 'unpartition';\n\nexport interface UnpartitionOptions {}\nconst UNPARTITION_DEFAULTS: Required<UnpartitionOptions> = {};\n\n/**\n * Removes partitions from the binary payload of a glTF file, so that the asset\n * contains at most one (1) `.bin` {@link Buffer}. This process reverses the\n * changes from a {@link partition} transform.\n *\n * Example:\n *\n * ```ts\n * document.getRoot().listBuffers(); // → [Buffer, Buffer, ...]\n *\n * await document.transform(unpartition());\n *\n * document.getRoot().listBuffers(); // → [Buffer]\n * ```\n *\n * @category Transforms\n */\nexport function unpartition(_options: UnpartitionOptions = UNPARTITION_DEFAULTS): Transform {\n\treturn createTransform(NAME, async (document: Document): Promise<void> => {\n\t\tconst logger = document.getLogger();\n\n\t\tconst buffer = document.getRoot().listBuffers()[0];\n\t\tdocument\n\t\t\t.getRoot()\n\t\t\t.listAccessors()\n\t\t\t.forEach((a) => a.setBuffer(buffer));\n\t\tdocument\n\t\t\t.getRoot()\n\t\t\t.listBuffers()\n\t\t\t.forEach((b, index) => (index > 0 ? b.dispose() : null));\n\n\t\tlogger.debug(`${NAME}: Complete.`);\n\t});\n}\n","import {\n\tAccessor,\n\tDocument,\n\ttype Mesh,\n\tNode,\n\ttype Primitive,\n\ttype Transform,\n\ttype TypedArrayConstructor,\n\ttype vec2,\n} from '@gltf-transform/core';\nimport type * as watlas from 'watlas';\nimport { compactPrimitive } from './compact-primitive.js';\nimport { dequantizeAttributeArray } from './dequantize.js';\nimport { createTransform, isUsed, shallowCloneAccessor } from './utils.js';\n\nconst NAME = 'unwrap';\n\ninterface IWatlas {\n\tInitialize(): Promise<void>;\n\tAtlas: {\n\t\tnew (): watlas.Atlas;\n\t};\n}\n\n/** Options for the {@link unwrap} transform. */\nexport interface UnwrapOptions {\n\t/** watlas instance. */\n\twatlas: unknown;\n\t/**\n\t * Target texture coordinate index (0, 1, 2, ...) for generated unwrapping.\n\t * Default: 0.\n\t */\n\ttexcoord?: number;\n\t/**\n\t * Whether to overwrite existing attributes at the target texCoord index, if\n\t * any. Default: false.\n\t */\n\toverwrite?: boolean;\n\t/**\n\t * Methods of grouping texcoords with the {@link unwrap} function.\n\t * Default: 'mesh'.\n\t */\n\tgroupBy?: 'primitive' | 'mesh' | 'scene';\n}\n\n/** Options for the {@link unwrapPrimitives} function. */\nexport interface UnwrapPrimitivesOptions {\n\t/** watlas instance. */\n\twatlas: unknown;\n\t/**\n\t * Target texture coordinate index (0, 1, 2, ...) for generated unwrapping.\n\t * Default: 0.\n\t */\n\ttexcoord?: number;\n\t/**\n\t * Whether to overwrite existing attributes at the target texCoord index, if\n\t * any. Default: false.\n\t */\n\toverwrite?: boolean;\n\t/**\n\t * Per-primitive texel density weights. Texel space in the atlas is allocated\n\t * proportionally with geometry dimensions in local space. If specified,\n\t * weights scale the allocation. Default: [1, 1, 1, ...].\n\t */\n\tweights?: number[];\n}\n\nexport const UNWRAP_DEFAULTS: Required<Omit<UnwrapOptions, 'watlas'>> = {\n\ttexcoord: 0,\n\toverwrite: false,\n\tgroupBy: 'mesh',\n};\n\n/**\n * Generate new texture coordinates (“UV mappings”) for {@link Primitive Primitives}.\n * Useful for adding texture coordinates in scenes without existing UVs, or for\n * creating a second set of texture coordinates for baked textures such as ambient\n * occlusion maps and lightmaps. Operation may increase vertex count to\n * accommodate UV seams.\n *\n * UV layouts may be grouped, reducing the number of textures required. Available\n * groupings:\n *\n * - `\"primitive\"`: Each primitive is given it's own texcoord atlas.\n * - `\"mesh\"`: All primitives in a mesh share a texcoord atlas. (default)\n * - `\"scene\"`: All primitives in the scene share a texcoord atlas.\n *\n * Example:\n *\n * ```ts\n * import * as watlas from 'watlas';\n * import { unwrap } from '@gltf-transform/functions';\n *\n * // Generate a TEXCOORD_1 attribute for all primitives.\n * await document.transform(\n *   unwrap({ watlas, texcoord: 1, overwrite: true, groupBy: 'scene' })\n * );\n * ```\n *\n * For more control and customization, see {@link unwrapPrimitives}.\n *\n * @experimental\n * @category Transforms\n */\nexport function unwrap(_options: UnwrapOptions): Transform {\n\tconst options = { ...UNWRAP_DEFAULTS, ..._options } as Required<UnwrapOptions>;\n\n\tconst watlas = options.watlas as IWatlas | undefined;\n\n\tif (!watlas) {\n\t\tthrow new Error(`${NAME}: dependency required — install \"watlas\".`);\n\t}\n\n\treturn createTransform(NAME, async (document: Document): Promise<void> => {\n\t\tawait watlas!.Initialize();\n\n\t\tswitch (options.groupBy) {\n\t\t\tcase 'primitive': {\n\t\t\t\tfor (const mesh of document.getRoot().listMeshes()) {\n\t\t\t\t\tfor (const prim of mesh.listPrimitives()) {\n\t\t\t\t\t\tunwrapPrimitives([prim], options);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'mesh': {\n\t\t\t\tfor (const mesh of document.getRoot().listMeshes()) {\n\t\t\t\t\tunwrapPrimitives(mesh.listPrimitives(), options);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'scene': {\n\t\t\t\tconst prims: Primitive[] = [];\n\t\t\t\tconst weights: number[] = [];\n\t\t\t\tfor (const mesh of document.getRoot().listMeshes()) {\n\t\t\t\t\tconst weight = getNodeScaleMax(mesh);\n\t\t\t\t\tfor (const prim of mesh.listPrimitives()) {\n\t\t\t\t\t\tprims.push(prim);\n\t\t\t\t\t\tweights.push(weight);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tunwrapPrimitives(prims, { ...options, weights });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tconst logger = document.getLogger();\n\t\tlogger.debug(`${NAME}: Complete.`);\n\t});\n}\n\n/**\n * Generate new texture coordinates (“UV mappings”) for {@link Primitive Primitives}.\n * Useful for adding texture coordinates in scenes without existing UVs, or for\n * creating a second set of texture coordinates for baked textures such as ambient\n * occlusion maps and lightmaps. Operation may increase vertex count to\n * accommodate UV seams.\n *\n * UV layouts may be grouped, reducing the number of textures required. Available\n * groupings:\n *\n * - `\"primitive\"`: Each primitive is given it's own texcoord atlas.\n * - `\"mesh\"`: All primitives in a mesh share a texcoord atlas. (default)\n * - `\"scene\"`: All primitives in the scene share a texcoord atlas.\n *\n * watlas must be initialized before calling this function.\n *\n * Example:\n *\n * ```ts\n * import * as watlas from 'watlas';\n * import { unwrapPrimitives } from '@gltf-transform/functions';\n *\n * // Initialize watlas.\n * await watlas.Initialize();\n *\n * // Generate a TEXCOORD_1 attribute for the specified primitives.\n * unwrapPrimitives(mesh.listPrimitives(), {\n *   watlas,\n *   texcoord: 1,\n *   overwrite: true\n * });\n * ```\n *\n * To create texture coordinates for an entire Document, see {@link unwrap}.\n *\n * @experimental\n */\nexport function unwrapPrimitives(primitives: Primitive[], options: UnwrapPrimitivesOptions): void {\n\tconst document = Document.fromGraph(primitives[0].getGraph())!;\n\tconst watlas = options.watlas as IWatlas | undefined;\n\tconst dstTexCoordIndex = options.texcoord ?? 0;\n\tconst dstSemantic = `TEXCOORD_${dstTexCoordIndex}`;\n\n\tif (!watlas) {\n\t\tthrow new Error(`${NAME}: dependency required — install \"watlas\".`);\n\t}\n\n\tconst atlas = new watlas.Atlas();\n\n\tconst unwrapPrims = [];\n\tfor (let i = 0; i < primitives.length; i++) {\n\t\tconst prim = primitives[i];\n\t\tconst primWeight = options.weights ? options.weights[i] : 1;\n\n\t\t// Don't process primitives that already have the desired TEXCOORD index\n\t\t// if overwrite is false.\n\t\tif (!options.overwrite && prim.getAttribute(dstSemantic)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst unwrapPrim = compactPrimitive(prim);\n\n\t\t// Always pass vertex position data\n\t\tconst position = unwrapPrim.getAttribute('POSITION')!;\n\n\t\tconst meshDecl: watlas.MeshDecl = {\n\t\t\tvertexCount: position.getCount(),\n\t\t\tvertexPositionData: getScaledAttributeFloat32Array(position, primWeight),\n\t\t\tvertexPositionStride: position.getElementSize() * Float32Array.BYTES_PER_ELEMENT,\n\t\t};\n\n\t\t// Pass normal data if available to improve unwrapping\n\t\tconst normal = unwrapPrim.getAttribute('NORMAL');\n\t\tif (normal) {\n\t\t\tmeshDecl.vertexNormalData = getAttributeFloat32Array(normal);\n\t\t\tmeshDecl.vertexNormalStride = normal.getElementSize() * Float32Array.BYTES_PER_ELEMENT;\n\t\t}\n\n\t\t// Pass texcoord data from set 0 if it's available and not the set that\n\t\t// is being generated.\n\t\tif (options.texcoord !== 0) {\n\t\t\tconst texcoord = unwrapPrim.getAttribute('TEXCOORD_0');\n\t\t\tif (texcoord) {\n\t\t\t\tmeshDecl.vertexUvData = getAttributeFloat32Array(texcoord);\n\t\t\t\tmeshDecl.vertexUvStride = texcoord.getElementSize() * Float32Array.BYTES_PER_ELEMENT;\n\t\t\t}\n\t\t}\n\n\t\t// Pass indices if available\n\t\tconst indices = unwrapPrim.getIndices();\n\t\tif (indices) {\n\t\t\tconst indicesArray = indices.getArray()!;\n\t\t\tmeshDecl.indexCount = indices.getCount();\n\t\t\tmeshDecl.indexData =\n\t\t\t\tindicesArray instanceof Uint8Array\n\t\t\t\t\t? new Uint16Array(indicesArray)\n\t\t\t\t\t: (indicesArray as Uint16Array | Uint32Array);\n\t\t}\n\n\t\tunwrapPrims.push(unwrapPrim);\n\t\tatlas.addMesh(meshDecl);\n\t}\n\n\t// Don't proceed if we skipped every primitive in this group.\n\tif (unwrapPrims.length === 0) {\n\t\treturn;\n\t}\n\n\tatlas.generate();\n\n\tif (atlas.meshCount !== unwrapPrims.length) {\n\t\tthrow new Error(\n\t\t\t`${NAME}: Generated an unexpected number of atlas meshes. (got: ${atlas.meshCount}, expected: ${unwrapPrims.length})`,\n\t\t);\n\t}\n\n\t// xatlas UVs are in texels, so they need to be normalized before saving to\n\t// the glTF attribute.\n\tconst scale: vec2 = [1 / atlas.width, 1 / atlas.height];\n\n\tfor (let i = 0; i < atlas.meshCount; i++) {\n\t\tconst prim = unwrapPrims[i];\n\t\tconst atlasMesh = atlas.getMesh(i);\n\n\t\t// Clean up previous TEXCOORD_* attribute, if there was any.\n\t\tconst srcTexCoord = prim.getAttribute(dstSemantic);\n\t\tif (srcTexCoord) {\n\t\t\tprim.setAttribute(dstSemantic, null);\n\t\t\tif (!isUsed(srcTexCoord)) srcTexCoord.dispose();\n\t\t}\n\n\t\t// Remap Vertex attributes.\n\t\tfor (const srcAttribute of prim.listAttributes()) {\n\t\t\tprim.swap(srcAttribute, remapAttribute(document, srcAttribute, atlasMesh));\n\n\t\t\t// Clean up.\n\t\t\tif (!isUsed(srcAttribute)) srcAttribute.dispose();\n\t\t}\n\n\t\t// Remap morph target vertex attributes.\n\t\tfor (const target of prim.listTargets()) {\n\t\t\tfor (const srcAttribute of target.listAttributes()) {\n\t\t\t\ttarget.swap(srcAttribute, remapAttribute(document, srcAttribute, atlasMesh));\n\n\t\t\t\t// Clean up.\n\t\t\t\tif (!isUsed(srcAttribute)) srcAttribute.dispose();\n\t\t\t}\n\t\t}\n\n\t\t// Add new TEXCOORD_* attribute.\n\t\tconst dstTexCoord = document\n\t\t\t.createAccessor()\n\t\t\t.setArray(new Float32Array(atlasMesh.vertexCount * 2))\n\t\t\t.setType('VEC2');\n\t\tfor (let j = 0; j < atlasMesh.vertexCount; j++) {\n\t\t\tconst vertex = atlasMesh.getVertex(j);\n\t\t\tdstTexCoord.setElement(j, [vertex.uv[0] * scale[0], vertex.uv[1] * scale[1]]);\n\t\t}\n\t\tprim.setAttribute(dstSemantic, dstTexCoord);\n\n\t\t// The glTF spec says that if TEXCOORD_N (where N > 0) exists then\n\t\t// TEXCOORD_N-1...TEXCOORD_0 must also exist. If any prior TEXCOORD\n\t\t// attributes are missing, copy this attribute to satisfy that requirement.\n\t\tfor (let j = dstTexCoordIndex - 1; j >= 0; j--) {\n\t\t\tconst semantic = `TEXCOORD_${j}`;\n\t\t\tif (!prim.getAttribute(semantic)) {\n\t\t\t\tprim.setAttribute(semantic, dstTexCoord);\n\t\t\t}\n\t\t}\n\n\t\t// Update Indices.\n\t\tconst dstIndicesArray = new Uint32Array(atlasMesh.indexCount);\n\t\tatlasMesh.getIndexArray(dstIndicesArray);\n\n\t\tconst dstIndices = document.createAccessor().setArray(dstIndicesArray).setType('SCALAR');\n\t\tconst srcIndices = prim.getIndices();\n\t\tprim.setIndices(dstIndices);\n\t\tif (srcIndices && !isUsed(srcIndices)) {\n\t\t\tsrcIndices.dispose();\n\t\t}\n\t}\n\n\tatlas.delete();\n}\n\n// Returns a new attribute with the same values at as source attribute, but\n// re-ordered according to the vertex order output by xatlas to account for\n// vertex splitting.\nfunction remapAttribute(document: Document, srcAttribute: Accessor, atlasMesh: watlas.Mesh): Accessor {\n\tconst dstAttribute = shallowCloneAccessor(document, srcAttribute);\n\tconst ArrayCtor = srcAttribute.getArray()!.constructor as TypedArrayConstructor;\n\tdstAttribute.setArray(new ArrayCtor(atlasMesh.vertexCount * srcAttribute.getElementSize()));\n\n\tconst el: number[] = [];\n\tfor (let i = 0; i < atlasMesh.vertexCount; i++) {\n\t\tconst vertex = atlasMesh.getVertex(i);\n\t\tdstAttribute.setElement(i, srcAttribute.getElement(vertex.xref, el));\n\t}\n\n\treturn dstAttribute;\n}\n\n// Returns the values of the given attribute as a Float32Array.\nfunction getAttributeFloat32Array(attribute: Accessor): Float32Array {\n\tif (attribute.getComponentType() === Accessor.ComponentType.FLOAT) {\n\t\treturn attribute.getArray() as Float32Array;\n\t}\n\treturn dequantizeAttributeArray(attribute.getArray()!, attribute.getComponentType(), attribute.getNormalized());\n}\n\n// Returns scaled values of the given attribute as a Float32Array.\nfunction getScaledAttributeFloat32Array(attribute: Accessor, scale: number): Float32Array {\n\tconst array = dequantizeAttributeArray(\n\t\tattribute.getArray()!,\n\t\tattribute.getComponentType(),\n\t\tattribute.getNormalized(),\n\t);\n\n\tfor (let i = 0; i < array.length; i++) {\n\t\tarray[i] *= scale;\n\t}\n\n\treturn array;\n}\n\nfunction getNodeScaleMax(mesh: Mesh): number {\n\tlet scale = -Infinity;\n\n\tfor (const parent of mesh.listParents()) {\n\t\tif (parent instanceof Node) {\n\t\t\tconst s = parent.getWorldScale();\n\t\t\tscale = Number.isFinite(s[0]) ? Math.max(scale, Math.abs(s[0])) : scale;\n\t\t\tscale = Number.isFinite(s[1]) ? Math.max(scale, Math.abs(s[1])) : scale;\n\t\t\tscale = Number.isFinite(s[2]) ? Math.max(scale, Math.abs(s[2])) : scale;\n\t\t}\n\t}\n\n\treturn scale > 0 && Number.isFinite(scale) ? scale : 1;\n}\n","import type { Accessor, Document, Primitive, Transform, vec3 } from '@gltf-transform/core';\nimport { createTransform } from './utils.js';\n\nconst NAME = 'vertexColorSpace';\n\n/** Options for the {@link vertexColorSpace} function. */\nexport interface ColorSpaceOptions {\n\t/** Input color space of vertex colors, to be converted to \"srgb-linear\". Required. */\n\tinputColorSpace: 'srgb' | 'srgb-linear';\n}\n\n/**\n * Vertex color color space correction. The glTF format requires vertex colors to be stored\n * in Linear Rec. 709 D65 color space, and this function provides a way to correct vertex\n * colors that are (incorrectly) stored in sRGB.\n *\n * Example:\n *\n * ```typescript\n * import { vertexColorSpace } from '@gltf-transform/functions';\n *\n * await document.transform(\n *   vertexColorSpace({ inputColorSpace: 'srgb' })\n * );\n * ```\n *\n * @category Transforms\n */\nexport function vertexColorSpace(options: ColorSpaceOptions): Transform {\n\treturn createTransform(NAME, (doc: Document): void => {\n\t\tconst logger = doc.getLogger();\n\n\t\tconst inputColorSpace = (options.inputColorSpace || '').toLowerCase();\n\n\t\tif (inputColorSpace === 'srgb-linear') {\n\t\t\tlogger.info(`${NAME}: Vertex colors already linear. Skipping conversion.`);\n\t\t\treturn;\n\t\t}\n\n\t\tif (inputColorSpace !== 'srgb') {\n\t\t\tlogger.error(\n\t\t\t\t`${NAME}: Unknown input color space \"${inputColorSpace}\" – should be \"srgb\" or ` +\n\t\t\t\t\t'\"srgb-linear\". Skipping conversion.',\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst converted = new Set<Accessor>();\n\n\t\t// Source: THREE.Color\n\t\tfunction sRGBToLinear(c: number): number {\n\t\t\treturn c < 0.04045 ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);\n\t\t}\n\n\t\tfunction updatePrimitive(primitive: Primitive): void {\n\t\t\tconst color = [0, 0, 0] as vec3;\n\t\t\tlet attribute: Accessor | null;\n\t\t\tfor (let i = 0; (attribute = primitive.getAttribute(`COLOR_${i}`)); i++) {\n\t\t\t\tif (converted.has(attribute)) continue;\n\n\t\t\t\tfor (let j = 0; j < attribute.getCount(); j++) {\n\t\t\t\t\tattribute.getElement(j, color);\n\t\t\t\t\tcolor[0] = sRGBToLinear(color[0]);\n\t\t\t\t\tcolor[1] = sRGBToLinear(color[1]);\n\t\t\t\t\tcolor[2] = sRGBToLinear(color[2]);\n\t\t\t\t\tattribute.setElement(j, color);\n\t\t\t\t}\n\n\t\t\t\tconverted.add(attribute);\n\t\t\t}\n\t\t}\n\n\t\tdoc.getRoot()\n\t\t\t.listMeshes()\n\t\t\t.forEach((mesh) => mesh.listPrimitives().forEach(updatePrimitive));\n\n\t\tlogger.debug(`${NAME}: Complete.`);\n\t});\n}\n"],"names":["rewriteTexture","source","target","fn","Promise","resolve","srcImage","getImage","getPixels","getMimeType","then","pixels","i","shape","j","savePixels","dstImage","setImage","setMimeType","e","reject","POINTS","LINES","LINE_STRIP","LINE_LOOP","TRIANGLES","TRIANGLE_STRIP","TRIANGLE_FAN","Primitive","Mode","createTransform","name","Object","defineProperty","value","isTransformPending","context","initial","pending","initialIndex","stack","lastIndexOf","pendingIndex","assignDefaults","defaults","options","result","key","undefined","getGLPrimitiveCount","prim","indices","getIndices","position","getAttribute","getMode","getCount","Error","SetMap","constructor","_map","Map","size","has","k","add","v","entry","get","Set","set","keys","formatBytes","bytes","decimals","dm","sizes","Math","floor","log","parseFloat","pow","toFixed","_longFormatter","Intl","NumberFormat","maximumFractionDigits","formatLong","x","format","formatDelta","a","b","prefix","suffix","abs","formatDeltaOp","deepListAttributes","accessors","attribute","listAttributes","push","listTargets","Array","from","deepSwapAttribute","src","dst","swap","deepDisposePrimitive","attributes","dispose","isUsed","shallowEqualsArray","length","shallowCloneAccessor","document","accessor","createAccessor","getName","setArray","getArray","setType","getType","setBuffer","getBuffer","setNormalized","getNormalized","setSparse","getSparse","createIndices","count","maxIndex","array","createIndicesEmpty","Uint16Array","Uint32Array","prop","listParents","some","parent","propertyType","PropertyType","ROOT","isEmptyObject","object","_key","createPrimGroupKey","Document","fromGraph","getGraph","material","getMaterial","materialIndex","getRoot","listMaterials","indexOf","mode","BASIC_MODE_MAPPING","listSemantics","sort","map","semantic","elementSize","getElementSize","componentType","getComponentType","join","targets","fitWithin","limit","maxWidth","maxHeight","srcWidth","srcHeight","dstWidth","dstHeight","fitPowerOfTwo","method","isPowerOfTwo","nearestPowerOfTwo","ceilPowerOfTwo","floorPowerOfTwo","lo","hi","LN2","ceil","NAME","CENTER_DEFAULTS","pivot","center","_options","doc","logger","getLogger","root","isAnimated","listAnimations","listSkins","listScenes","forEach","scene","index","debug","bbox","getBounds","max","min","offset","offsetNode","createNode","setTranslation","listChildren","child","addChild","t","getTranslation","listNodeScenes","node","visited","getParentNode","filter","Scene","clearNodeParent","scenes","setMatrix","getWorldMatrix","removeChild","invert","multiply","VertexCountMethod","getSceneVertexCount","_getSubtreeVertexCount","getNodeVertexCount","instancedMeshes","nonInstancedMeshes","meshes","traverse","mesh","getMesh","batch","getExtension","prims","flatMap","listPrimitives","positions","uniquePositions","uniqueMeshes","uniquePrims","RENDER","RENDER_CACHED","_sum","getMeshVertexCount","UPLOAD_NAIVE","UPLOAD","DISTINCT","DISTINCT_POSITION","_assertNotImplemented","UNUSED","_sumUnused","_assertUnreachable","getPrimitiveVertexCount","values","total","attributeIndexMap","indicesSet","unused","usedIndices","Uint8Array","indicesArray","il","EMPTY_U32","VertexStream","u8","u32","byteStride","_initAttribute","buffer","byteOffset","byteLength","getComponentSize","paddedByteStride","BufferUtils","padNumber","hash","murmurHash2","equal","h","m","r","imul","hashLookup","table","buckets","stream","empty","hashmod","hashval","bucket","probe","item","compactPrimitive","remap","dstVertexCount","createCompactPlan","srcIndices","srcIndicesArray","srcIndicesCount","dstIndices","dstIndicesCount","dstIndicesArray","setIndices","srcAttributesPrev","srcAttribute","dstAttribute","compactAttribute","srcArray","dstArray","dstDone","srcIndex","dstIndex","srcVertexCount","fill","create","glMatrix.ARRAY_TYPE","scale","mul","WELD_DEFAULTS","overwrite","weld","listMeshes","weldPrimitive","graph","tableSize","writeMap","hashIndex","FLOAT","Accessor","ComponentType","transformPrimitive","matrix","applyMatrix","normal","applyNormalMatrix","tangent","applyTangentMatrix","determinant","reversePrimitiveWindingOrder","normalized","Float32Array","vector","createVec3","MathUtils","decodeNormalizedInt","transformMat4","normalMatrix","createMat3","fromMat4","transpose","transformMat3","normalizeVec3","v3","getScalar","c","setScalar","transformMesh","srcPrim","dstPrim","shallowClonePrimitive","removePrimitive","addPrimitive","parentMesh","isSharedPrimitive","Mesh","clone","isSharedTarget","removeTarget","addTarget","IDENTITY","clearNodeTransform","localMatrix","getMatrix","eq","multiplyMat4","convertPrimitiveToLines","dstGLPrimitiveCount","IndicesArray","ComponentTypeToTypedArray","srcMode","setMode","convertPrimitiveToTriangles","DEDUP_DEFAULTS","keepUniqueNames","propertyTypes","ACCESSOR","MESH","TEXTURE","MATERIAL","SKIN","dedup","includes","dedupAccessors","dedupImages","dedupMaterials","dedupMeshes","dedupSkins","indicesMap","attributeMap","inputMap","outputMap","primitive","hashAccessor","animation","sampler","listSamplers","getInput","getOutput","group","hashSet","detectDuplicates","duplicates","aData","toView","equals","hashGroup","input","output","refs","listAccessors","numMeshes","srcKeyItems","createPrimitiveKey","meshKey","targetMesh","textures","listTextures","bData","aSize","getSize","bSize","entries","property","Root","materials","modifierCache","skip","hasModifier","skins","listJoints","primKeyItems","cache","visitedNodes","edgeQueue","listParentEdges","edge","pop","getAttributes","modifyChild","getChild","childEdge","listChildEdges","DEQUANTIZE_DEFAULTS","pattern","dequantize","dequantizePrimitive","disposeExtension","test","dequantizeAttribute","dequantizeAttributeArray","TEXTURE_INFO","NO_TRANSFER_TYPES","cloneDocument","setLogger","createDefaultPropertyResolver","mergeDocuments","copy","sourceExtension","listExtensionsUsed","targetExtension","createExtension","isRequired","setRequired","_copyToDocument","listNonRootProperties","moveToDocument","sourceProperties","targetProperties","copyToDocument","sourcePropertyDependencies","listPropertyDependencies","propertyMap","sourceProp","targetProp","PropertyClass","queue","next","listEdges","DRACO_DEFAULTS","encodeSpeed","decodeSpeed","quantizePosition","quantizeNormal","quantizeColor","quantizeTexcoord","quantizeGeneric","quantizationVolume","draco","transform","KHRDracoMeshCompression","setEncoderOptions","EncoderMethod","EDGEBREAKER","SEQUENTIAL","quantizationBits","POSITION","NORMAL","COLOR","TEX_COORD","GENERIC","SRGB_PATTERN","getTextureColorSpace","texture","edges","isSRGB","isColor","listTextureInfo","results","textureEdge","getParent","TextureInfo","listTextureInfoByMaterial","textureInfoNames","Texture","ExtensionProperty","listTextureSlots","slots","maybeGetPixels","_catch","getTextureFactor","Infinity","width","height","len","sub","EPS","pruneSolidTextures","factor","_texture$getSize","ColorUtils","convertSRGBToLinear","getURI","applyMaterialFactor","all","PRUNE_DEFAULTS","NODE","CAMERA","PRIMITIVE","PRIMITIVE_TARGET","ANIMATION","BUFFER","keepLeaves","keepAttributes","keepIndices","keepSolidTextures","keepExtras","prune","_temp3","treeShake","listBuffers","removeEventListener","onDispose","counter","str","type","info","DisposeCounter","event","addEventListener","nodeTreeShake","listNodes","skin","camera","listCameras","indirectTreeShake","materialPrims","required","listRequiredSemantics","listUnusedSemantics","pruneAttributes","shiftTexCoords","anim","channel","listChannels","getTargetNode","samplers","_temp2","_temp","disposed","parents","p","AnimationChannel","needsExtras","getExtras","ptype","SCENE","isEmpty","setAttribute","startsWith","semantics","textureNames","replace","getTexCoord","match","isLit","Material","isPoints","textureInfoList","texCoordSet","texCoordList","texCoordMap","texCoord","semanticMap","textureInfo","setTexCoord","updatePrim","srcSemantics","srcSemantic","uv","dstSemantic","slot","setBaseColorFactor","getBaseColorFactor","setEmissiveFactor","mulVec3","slice","getEmissiveFactor","setRoughnessFactor","getRoughnessFactor","setMetallicFactor","getMetallicFactor","warn","FLATTEN_DEFAULTS","cleanup","flatten","joints","joint","animated","getTargetPath","hasJointParent","hasAnimatedParent","_getBounds","inspect","animations","sceneBounds","rootName","bboxMin","toPrecision","bboxMax","renderVertexCount","uploadVertexCount","uploadNaiveVertexCount","properties","instances","glPrimitives","meshIndices","meshAccessors","attr","accessorToTypeLabel","targ","modes","MeshPrimitiveModeLabels","meshPrimitives","vertices","extensions","listExtensions","ref","alphaMode","getAlphaMode","doubleSided","getDoubleSided","resolution","ImageUtils","compression","container","readKTX","dfd","dataFormatDescriptor","colorModel","KHR_DF_MODEL_ETC1S","KHR_DF_MODEL_UASTC","uri","mimeType","gpuSize","getVRAMByteLength","minTime","maxTime","getMin","getMax","keyframes","channels","duration","round","NumericTypeLabels","Int32Array","Int16Array","Int8Array","Number","base","INSTANCE_DEFAULTS","instance","batchExtension","EXTMeshGPUInstancing","numBatches","numInstances","meshInstances","modifiedNodes","nodes","getSkin","hasVolume","hasScale","createBatch","batchTranslation","batchRotation","batchScale","batchNode","setMesh","setExtension","needsTranslation","needsRotation","needsScale","s","setElement","getWorldTranslation","getWorldRotation","getWorldScale","pruneUnusedNodes","listProperties","unusedNodes","getCamera","nodeParent","createInstancedMesh","JOIN_PRIMITIVE_DEFAULTS","skipValidation","joinPrimitives","templatePrim","primRemaps","primVertexCounts","primIndex","createPrimitive","setMaterial","tplAttribute","AttributeArray","tplIndices","dstIndicesOffset","remapIndices","remapAttribute","done","dstOffset","srcCount","_matrix","JOIN_DEFAULTS","keepMeshes","keepNamed","_joinLevel","groups","children","nodeIndex","dequantizeTransformableAttributes","isNamed","primMeshes","primNodes","dstNode","dstMesh","joinGroups","srcNodes","isSharedMesh","dstMatrix","primNode","primMesh","_deepClonePrimitive","listTextureChannels","mask","getTextureChannelMask","TextureChannel","R","G","B","A","AlphaMode","OPAQUE","sortPrimitiveWeights","isFinite","vertexCount","setCount","srcWeights","dstWeights","srcJoints","dstJoints","getVertexArray","setVertexArray","weights","normalizePrimitiveWeights","isNormalizeSafe","templateAttribute","templateArray","normalizedComponentType","delta","EPSILON","weightsSum","sum","floatValue","encodeNormalizedInt","sign","vertexIndex","el","getElement","normList","typeList","SIGNED_INT","TRANSLATION","ROTATION","SCALE","WEIGHTS","TargetPath","TRS_CHANNELS","QUANTIZE_DEFAULTS","quantizeWeight","normalizeWeights","quantize","patternTargets","nodeTransform","getNodeTransform","expandBounds","getPositionQuantizationVolume","transformMeshParents","transformMeshMaterials","renderCount","uploadCount","quantizePrimitive","needsExtension","isQuantizedPrimitive","KHRMeshQuantization","isTarget","PrimitiveTarget","bits","ctor","getQuantizationSettings","fromTransform","fromScaling","quantizeAttribute","volume","transformMatrix","Node","animChannels","isParentNode","setSkin","transformSkin","transformBatch","targetNode","setTargetNode","nodeMatrix","inverseBindMatrices","getInverseBindMatrices","ibm","setInverseBindMatrices","_batch$getAttribute","_batch$getAttribute2","_batch$getAttribute3","instanceTranslation","instanceRotation","instanceScale","tpl","T_IDENTITY","R_IDENTITY","S_IDENTITY","makeArray","instanceMatrix","compose","decompose","getThicknessFactor","setThicknessFactor","signBits","quantBits","storageBits","BYTES_PER_ELEMENT","range","di","clamp","getMinNormalized","getMaxNormalized","relativePositions","flatBounds","relMin","relMax","isQuantizedAttribute","componentSize","UNSIGNED_BYTE","UNSIGNED_SHORT","tmpMin","tmpMax","bboxes","fromRotationTranslationScale","elementCount","initialElement","REORDER_DEFAULTS","reorder","encoder","ready","plan","indicesToAttributes","createLayoutPlan","unique","reorderMesh","indicesToMode","indicesToPrimitives","attributesToPrimitives","MESHOPT_DEFAULTS","level","meshopt","EXTMeshoptCompression","QUANTIZE","FILTER","_settle","pact","state","_Pact","o","bind","observer","prototype","onFulfilled","onRejected","_this","_isSettledPact","thenable","METALROUGH_DEFAULTS","metalRough","_temp4","specGlossExtension","tex","inputTextures","extensionsUsed","ext","extensionName","iorExtension","KHRMaterialsIOR","specExtension","KHRMaterialsSpecular","KHRMaterialsPBRSpecularGlossiness","_forOf","specGloss","specular","createSpecular","setSpecularFactor","setSpecularColorFactor","getSpecularFactor","getSpecularGlossinessTexture","getBaseColorTexture","getMetallicRoughnessTexture","getDiffuseFactor","createIOR","setIOR","diffuseTexture","getDiffuseTexture","setBaseColorTexture","getBaseColorTextureInfo","getDiffuseTextureInfo","sgTexture","sgTextureInfo","getSpecularGlossinessTextureInfo","specularTexture","createTexture","setSpecularTexture","setSpecularColorTexture","getSpecularTextureInfo","getSpecularColorTextureInfo","glossinessFactor","getGlossinessFactor","metalRoughTexture","roughness","setMetallicRoughnessTexture","getMetallicRoughnessTextureInfo","UNWELD_DEFAULTS","unweld","unweldPrimitive","unweldAttribute","TypedArray","NORMALS_DEFAULTS","normals","modified","faceNormal","computeNormal","n","normalize","PALETTE_DEFAULTS","blockSize","palette","_temp0","_temp8","_temp6","nextPaletteMaterialIndex","srcMaterial","materialKeyMap","blockIndex","materialIndices","baseUV","keyCount","padUV","w","padWidth","dstMaterial","paletteMaterials","skipProps","toString","padStart","setName","baseColorTexture","setMinFilter","MinFilter","NEAREST","setMagFilter","MagFilter","emissiveTexture","setEmissiveTexture","getEmissiveTextureInfo","metallicRoughnessTexture","paletteTexturePixels","metallicRoughness","image","_temp5","emissive","materialKeys","materialProps","baseColor","encodeRGBA","encodeFloat","metallic","call","arguments","setURI","ndarray","visitedKeys","nextIndex","convertLinearToSRGB","writeBlock","_temp7","_temp9","hex","PARTITION_DEFAULTS","partition","partitionMeshes","partitionAnimations","existingURIs","meshIndex","isArray","createBuffer","createBufferURI","_prim$getIndices","animIndex","SANITIZE_BASENAME_RE","basename","existing","EMPTY_ARRAY","RESAMPLE_DEFAULTS","resample","resampleDebug","tolerance","accessorsVisited","srcAccessorCount","samplerTargetPaths","getSampler","samplerInterpolation","getInterpolation","tmpTimes","toFloat32Array","tmpValues","dstCount","srcTimes","srcValues","dstTimes","fromFloat32Array","dstValues","setInput","setOutput","used","dstAccessorCount","SEQUENCE_DEFAULTS","fps","sequence","sequenceNodes","createAnimation","animBuffer","inputArray","outputArray","Type","VEC3","createAnimationSampler","setInterpolation","AnimationSampler","Interpolation","STEP","createAnimationChannel","setTargetPath","setSampler","addSampler","addChannel","SIMPLIFY_DEFAULTS","ratio","error","lockBorder","simplify","simplifier","numUnsupported","simplifyPrimitive","_simplifyPoints","srcIndexCount","positionArray","targetCount","flags","color","colorArray","colorStride","simplifyPoints","compactMesh","SPARSE_DEFAULTS","sparse","modifiedCount","nonZeroCount","TANGENTS_DEFAULTS","tangents","generateTangents","attributeIDs","tangentCache","meshName","filterPrimitive","texcoordSemantic","getNormalTexcoord","texcoord","positionID","uuid","normalID","texcoordID","prevTangent","attributeHash","tangentBuffer","tangentArray","normalTextureInfo","getNormalTextureInfo","_encodeWithNdarrayPixels","srcMimeType","dstMimeType","srcPixels","resize","dstSize","dstPixels","resizeFilter","TextureResizeFilter","LANCZOS3","lanczos3","lanczos2","_encodeWithSharp","_srcMimeType","encoderOptions","dstFormat","getFormatFromMimeType","quality","chromaSubsampling","effort","lossless","nearLossless","limitInputPixels","toFormat","srcSize","fit","kernel","_toView","toBuffer","_instance$toBuffer","compressTexture","TEXTURE_COMPRESS_DEFAULTS","srcURI","srcFormat","getFormat","colorSpace","targetFormat","srcByteLength","dstByteLength","srcExtension","FileUtils","extension","mimeTypeToExtension","dstExtension","dstURI","RegExp","TEXTURE_COMPRESS_SUPPORTED_FORMATS","SUPPORTED_MIME_TYPES","formats","textureCompress","patternRe","formatsRe","slotsRe","textureIndex","textureLabel","flag","webpExtension","EXTTextureWebP","avifExtension","EXTTextureAVIF","split","srcMax","dstMax","UNINSTANCE_DEFAULTS","uninstance","instanceAttributes","srcNode","instanceNode","createInstanceNodes","instanceAttribute","every","instanceCount","instanceCountDigits","String","batchName","instanceNodes","paddedIndex","setRotation","setScale","_setInstanceExtras","setExtras","unlit","unlitExtension","KHRMaterialsUnlit","createUnlit","UNPARTITION_DEFAULTS","unpartition","UNWRAP_DEFAULTS","groupBy","unwrap","watlas","Initialize","unwrapPrimitives","weight","getNodeScaleMax","primitives","dstTexCoordIndex","atlas","Atlas","unwrapPrims","primWeight","unwrapPrim","meshDecl","vertexPositionData","getScaledAttributeFloat32Array","vertexPositionStride","vertexNormalData","getAttributeFloat32Array","vertexNormalStride","vertexUvData","vertexUvStride","indexCount","indexData","addMesh","generate","meshCount","atlasMesh","srcTexCoord","dstTexCoord","vertex","getVertex","getIndexArray","delete","ArrayCtor","xref","vertexColorSpace","inputColorSpace","toLowerCase","converted","sRGBToLinear","updatePrimitive"],"mappings":";;;;;;;;;;;AAsDA;;;AAGG;AACH,MAAsBA,cAAc,GAAAA,UACnCC,MAAe,EACfC,MAAe,EACfC,EAAmD,EAAA;EAAA,IAAA;IAEnD,IAAI,CAACF,MAAM,EAAE,OAAAG,OAAA,CAAAC,OAAA,CAAO,IAAI,CAAA,CAAA;AAExB,IAAA,MAAMC,QAAQ,GAAGL,MAAM,CAACM,QAAQ,EAAE,CAAA;IAClC,IAAI,CAACD,QAAQ,EAAE,OAAAF,OAAA,CAAAC,OAAA,CAAO,IAAI,CAAA,CAAA;AAAC,IAAA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