@gltf-transform/functions
Advanced tools
Comparing version 3.4.2 to 3.4.3
import { Transform } from '@gltf-transform/core'; | ||
import { resampleDebug } from 'keyframe-resample'; | ||
export interface ResampleOptions { | ||
ready?: Promise<void>; | ||
resample?: typeof resampleDebug; | ||
resample?: unknown; | ||
tolerance?: number; | ||
@@ -7,0 +6,0 @@ } |
{ | ||
"name": "@gltf-transform/functions", | ||
"version": "3.4.2", | ||
"version": "3.4.3", | ||
"repository": "github:donmccurdy/glTF-Transform", | ||
@@ -38,8 +38,8 @@ "homepage": "https://gltf-transform.dev/functions.html", | ||
"dependencies": { | ||
"@gltf-transform/core": "^3.4.2", | ||
"@gltf-transform/extensions": "^3.4.2", | ||
"@gltf-transform/core": "^3.4.3", | ||
"@gltf-transform/extensions": "^3.4.3", | ||
"ktx-parse": "^0.5.0", | ||
"ndarray": "^1.0.19", | ||
"ndarray-lanczos": "^0.3.0", | ||
"ndarray-pixels": "^2.0.0" | ||
"ndarray-pixels": "^3.0.4" | ||
}, | ||
@@ -56,3 +56,3 @@ "files": [ | ||
}, | ||
"gitHead": "af29fb35bad5b7996828206a5797ddabecb259d9" | ||
"gitHead": "701a51849636e2cf9c2d10e0f3faf13b4a808352" | ||
} |
@@ -7,3 +7,3 @@ # @gltf-transform/functions | ||
Part of the glTF-Transform project. | ||
Part of the glTF Transform project. | ||
@@ -10,0 +10,0 @@ - GitHub: https://github.com/donmccurdy/glTF-Transform |
@@ -9,2 +9,3 @@ import { | ||
PrimitiveTarget, | ||
Property, | ||
PropertyType, | ||
@@ -150,3 +151,3 @@ Root, | ||
logger.debug(`${NAME}: Found ${duplicates.size} duplicates among ${total} accessors.`); | ||
logger.debug(`${NAME}: Merged ${duplicates.size} of ${total} accessors.`); | ||
@@ -183,4 +184,2 @@ // Dissolve duplicate vertex attributes and indices. | ||
Array.from(duplicates.keys()).forEach((accessor) => accessor.dispose()); | ||
logger.debug(`${NAME}: Complete.`); | ||
} | ||
@@ -223,3 +222,3 @@ | ||
logger.debug(`${NAME}: Found ${numMeshes - uniqueMeshes.size} duplicates among ${numMeshes} meshes.`); | ||
logger.debug(`${NAME}: Merged ${numMeshes - uniqueMeshes.size} of ${numMeshes} meshes.`); | ||
} | ||
@@ -261,3 +260,3 @@ | ||
logger.debug(`${NAME}: Found ${duplicates.size} duplicates among ${root.listTextures().length} textures.`); | ||
logger.debug(`${NAME}: Merged ${duplicates.size} of ${root.listTextures().length} textures.`); | ||
@@ -278,2 +277,3 @@ Array.from(duplicates.entries()).forEach(([src, dst]) => { | ||
const skip = new Set(['name']); | ||
const modifierCache = new Map<Material, boolean>(); | ||
@@ -283,7 +283,11 @@ // Compare each material to every other material — O(n²) — and mark duplicates for replacement. | ||
const a = materials[i]; | ||
if (duplicates.has(a)) continue; | ||
if (hasModifier(a, modifierCache)) continue; | ||
for (let j = i + 1; j < materials.length; j++) { | ||
const b = materials[j]; | ||
if (duplicates.has(b)) continue; | ||
if (hasModifier(b, modifierCache)) continue; | ||
@@ -296,3 +300,3 @@ if (a.equals(b, skip)) { | ||
logger.debug(`${NAME}: Found ${duplicates.size} duplicates among ${materials.length} materials.`); | ||
logger.debug(`${NAME}: Merged ${duplicates.size} of ${materials.length} materials.`); | ||
@@ -329,3 +333,3 @@ Array.from(duplicates.entries()).forEach(([src, dst]) => { | ||
logger.debug(`${NAME}: Found ${duplicates.size} duplicates among ${skins.length} skins.`); | ||
logger.debug(`${NAME}: Merged ${duplicates.size} of ${skins.length} skins.`); | ||
@@ -363,1 +367,37 @@ Array.from(duplicates.entries()).forEach(([src, dst]) => { | ||
} | ||
/** | ||
* Detects dependencies modified by a parent reference, to conservatively prevent merging. When | ||
* implementing extensions like KHR_animation_pointer, the 'modifyChild' attribute should be added | ||
* to graph edges connecting the animation channel to the animated target property. | ||
* | ||
* NOTICE: Implementation is conservative, and could prevent merging two materials sharing the | ||
* same animated "Clearcoat" ExtensionProperty. While that scenario is possible for an in-memory | ||
* glTF Transform graph, valid glTF input files do not have that risk. | ||
*/ | ||
function hasModifier(prop: Property, cache: Map<Property, boolean>): boolean { | ||
if (cache.has(prop)) return cache.get(prop)!; | ||
const graph = prop.getGraph(); | ||
const visitedNodes = new Set<Property>(); | ||
const edgeQueue = graph.listChildEdges(prop); | ||
// Search dependency subtree for 'modifyChild' attribute. | ||
while (edgeQueue.length > 0) { | ||
const edge = edgeQueue.pop()!; | ||
if (edge.getAttributes().modifyChild === true) { | ||
cache.set(prop, true); | ||
return true; | ||
} | ||
const child = edge.getChild(); | ||
if (visitedNodes.has(child)) continue; | ||
for (const childEdge of graph.listChildEdges(child)) { | ||
edgeQueue.push(childEdge); | ||
} | ||
} | ||
cache.set(prop, false); | ||
return false; | ||
} |
@@ -141,3 +141,3 @@ import { | ||
const paletteTexturePixels: Record<TexturableProp, NdArray<TypedArray> | null> = { | ||
const paletteTexturePixels: Record<TexturableProp, NdArray<Uint8Array> | null> = { | ||
baseColor: null, | ||
@@ -144,0 +144,0 @@ emissive: null, |
@@ -24,3 +24,3 @@ import { | ||
ready?: Promise<void>; | ||
resample?: typeof resampleDebug; | ||
resample?: unknown; // glTF-Transform/issues/996 | ||
tolerance?: number; | ||
@@ -65,3 +65,3 @@ } | ||
const ready = options.ready; | ||
const resample = options.resample; | ||
const resample = options.resample as typeof resampleDebug; | ||
@@ -68,0 +68,0 @@ await ready; |
@@ -98,3 +98,3 @@ import ndarray from 'ndarray'; | ||
const srcImage = texture.getImage()!; | ||
const srcPixels = (await getPixels(srcImage, texture.getMimeType())) as ndarray.NdArray<Uint8ClampedArray>; | ||
const srcPixels = (await getPixels(srcImage, texture.getMimeType())) as ndarray.NdArray<Uint8Array>; | ||
const dstPixels = ndarray(new Uint8Array(dstWidth * dstHeight * 4), [dstWidth, dstHeight, 4]); | ||
@@ -101,0 +101,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1345796
7347
+ Addedb4a@1.6.7(transitive)
+ Addedbare-events@2.5.0(transitive)
+ Addedbare-fs@2.3.5(transitive)
+ Addedbare-os@2.4.4(transitive)
+ Addedbare-path@2.1.3(transitive)
+ Addedbare-stream@2.4.2(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbl@4.1.0(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedchownr@1.1.4(transitive)
+ Addedcolor@4.2.3(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcolor-string@1.9.1(transitive)
+ Addeddecompress-response@6.0.0(transitive)
+ Addeddeep-extend@0.6.0(transitive)
+ Addeddetect-libc@2.0.3(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedexpand-template@2.0.3(transitive)
+ Addedfast-fifo@1.3.2(transitive)
+ Addedfs-constants@1.0.0(transitive)
+ Addedgithub-from-package@0.0.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedini@1.3.8(transitive)
+ Addedis-arrayish@0.3.2(transitive)
+ Addedmimic-response@3.1.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp-classic@0.5.3(transitive)
+ Addednapi-build-utils@1.0.2(transitive)
+ Addedndarray-pixels@3.1.0(transitive)
+ Addednode-abi@3.71.0(transitive)
+ Addednode-addon-api@6.1.0(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedprebuild-install@7.1.2(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedqueue-tick@1.0.1(transitive)
+ Addedrc@1.2.8(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedsemver@7.6.3(transitive)
+ Addedsharp@0.32.6(transitive)
+ Addedsimple-concat@1.0.1(transitive)
+ Addedsimple-get@4.0.1(transitive)
+ Addedsimple-swizzle@0.2.2(transitive)
+ Addedstreamx@2.20.2(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedstrip-json-comments@2.0.1(transitive)
+ Addedtar-fs@2.1.13.0.6(transitive)
+ Addedtar-stream@2.2.03.1.7(transitive)
+ Addedtext-decoder@1.2.1(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedwrappy@1.0.2(transitive)
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcontentstream@1.0.0(transitive)
- Removedcore-util-is@1.0.21.0.3(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddata-uri-to-buffer@0.0.3(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedget-pixels@3.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedgif-encoder@0.4.3(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisarray@0.0.1(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjpeg-js@0.4.4(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedndarray-pack@1.2.1(transitive)
- Removedndarray-pixels@2.0.4(transitive)
- Removednode-bitmap@0.0.1(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedomggif@1.0.10(transitive)
- Removedparse-data-uri@0.2.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpngjs@3.4.0(transitive)
- Removedpngjs-nozlib@1.0.0(transitive)
- Removedpsl@1.13.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedreadable-stream@1.0.341.1.14(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsave-pixels@2.3.6(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedstring_decoder@0.10.31(transitive)
- Removedthrough@2.3.8(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)
Updated@gltf-transform/core@^3.4.3
Updatedndarray-pixels@^3.0.4