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

@gltf-transform/functions

Package Overview
Dependencies
Maintainers
1
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gltf-transform/functions - npm Package Compare versions

Comparing version 3.4.2 to 3.4.3

3

dist/resample.d.ts
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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc