@gltf-transform/functions
Advanced tools
Comparing version 3.7.1 to 3.7.2
@@ -8,6 +8,11 @@ import { Transform } from '@gltf-transform/core'; | ||
/** | ||
* Resample {@link Animation}s, losslessly deduplicating keyframes to reduce file size. Duplicate | ||
* keyframes are commonly present in animation 'baked' by the authoring software to apply IK | ||
* constraints or other software-specific features. Based on THREE.KeyframeTrack.optimize(). | ||
* Resample {@link AnimationChannel AnimationChannels}, losslessly deduplicating keyframes to | ||
* reduce file size. Duplicate keyframes are commonly present in animation 'baked' by the | ||
* authoring software to apply IK constraints or other software-specific features. | ||
* | ||
* Optionally, a WebAssembly implementation from the | ||
* [`keyframe-resample`](https://github.com/donmccurdy/keyframe-resample-wasm) library may be | ||
* provided. The WebAssembly version is usually much faster at processing large animation | ||
* sequences, but may not be compatible with all runtimes and JavaScript build tools. | ||
* | ||
* Result: (0,0,0,0,1,1,1,0,0,0,0,0,0,0) → (0,0,1,1,0,0) | ||
@@ -18,3 +23,4 @@ * | ||
* ``` | ||
* import { ready, resample } from 'keyframe-resample'; | ||
* import { resample } from '@gltf-transform/functions'; | ||
* import { ready, resample as resampleWASM } from 'keyframe-resample'; | ||
* | ||
@@ -25,7 +31,8 @@ * // JavaScript (slower) | ||
* // WebAssembly (faster) | ||
* await document.transform(resample({ ready, resample })); | ||
* await document.transform(resample({ ready, resample: resampleWASM })); | ||
* ``` | ||
* | ||
* @privateRemarks Implementation based on THREE.KeyframeTrack#optimize(). | ||
* @category Transforms | ||
*/ | ||
export declare function resample(_options?: ResampleOptions): Transform; |
{ | ||
"name": "@gltf-transform/functions", | ||
"version": "3.7.1", | ||
"version": "3.7.2", | ||
"repository": "github:donmccurdy/glTF-Transform", | ||
@@ -39,4 +39,4 @@ "homepage": "https://gltf-transform.dev/functions.html", | ||
"dependencies": { | ||
"@gltf-transform/core": "^3.7.1", | ||
"@gltf-transform/extensions": "^3.7.1", | ||
"@gltf-transform/core": "^3.7.2", | ||
"@gltf-transform/extensions": "^3.7.2", | ||
"ktx-parse": "^0.6.0", | ||
@@ -57,3 +57,3 @@ "ndarray": "^1.0.19", | ||
}, | ||
"gitHead": "f673932e3b7fc0b0b4c441770cf36a189ce6f8c4" | ||
"gitHead": "4bc686d4b1c3c4acfa3cc7fdffc7c2b563835d7a" | ||
} |
@@ -35,6 +35,11 @@ import { | ||
/** | ||
* Resample {@link Animation}s, losslessly deduplicating keyframes to reduce file size. Duplicate | ||
* keyframes are commonly present in animation 'baked' by the authoring software to apply IK | ||
* constraints or other software-specific features. Based on THREE.KeyframeTrack.optimize(). | ||
* Resample {@link AnimationChannel AnimationChannels}, losslessly deduplicating keyframes to | ||
* reduce file size. Duplicate keyframes are commonly present in animation 'baked' by the | ||
* authoring software to apply IK constraints or other software-specific features. | ||
* | ||
* Optionally, a WebAssembly implementation from the | ||
* [`keyframe-resample`](https://github.com/donmccurdy/keyframe-resample-wasm) library may be | ||
* provided. The WebAssembly version is usually much faster at processing large animation | ||
* sequences, but may not be compatible with all runtimes and JavaScript build tools. | ||
* | ||
* Result: (0,0,0,0,1,1,1,0,0,0,0,0,0,0) → (0,0,1,1,0,0) | ||
@@ -45,3 +50,4 @@ * | ||
* ``` | ||
* import { ready, resample } from 'keyframe-resample'; | ||
* import { resample } from '@gltf-transform/functions'; | ||
* import { ready, resample as resampleWASM } from 'keyframe-resample'; | ||
* | ||
@@ -52,5 +58,6 @@ * // JavaScript (slower) | ||
* // WebAssembly (faster) | ||
* await document.transform(resample({ ready, resample })); | ||
* await document.transform(resample({ ready, resample: resampleWASM })); | ||
* ``` | ||
* | ||
* @privateRemarks Implementation based on THREE.KeyframeTrack#optimize(). | ||
* @category Transforms | ||
@@ -96,3 +103,3 @@ */ | ||
output.getComponentType(), | ||
output.getNormalized() | ||
output.getNormalized(), | ||
); | ||
@@ -121,3 +128,3 @@ | ||
input.getComponentType(), | ||
input.getNormalized() | ||
input.getNormalized(), | ||
); | ||
@@ -127,3 +134,3 @@ const dstValues = fromFloat32Array( | ||
output.getComponentType(), | ||
output.getNormalized() | ||
output.getNormalized(), | ||
); | ||
@@ -164,3 +171,3 @@ | ||
componentType: GLTF.AccessorComponentType, | ||
normalized: boolean | ||
normalized: boolean, | ||
): Float32Array { | ||
@@ -182,3 +189,3 @@ if (srcArray instanceof Float32Array) return srcArray.slice(); | ||
componentType: GLTF.AccessorComponentType, | ||
normalized: boolean | ||
normalized: boolean, | ||
): TypedArray { | ||
@@ -185,0 +192,0 @@ if (componentType === Accessor.ComponentType.FLOAT) return srcArray.slice(); |
@@ -113,3 +113,3 @@ import { | ||
if (prim.getIndices()!.getCount() === 0) prim.dispose(); | ||
if (isPrimEmpty(prim)) prim.dispose(); | ||
} | ||
@@ -434,1 +434,11 @@ | ||
} | ||
/** | ||
* For purposes of welding, we consider a primitive to be 'empty' or degenerate | ||
* if (1) it has an index, and (2) that index is empty. In some cases | ||
* (mode=POINTS) the index may be missing — this is outside the scope of welding. | ||
*/ | ||
function isPrimEmpty(prim: Primitive): boolean { | ||
const indices = prim.getIndices(); | ||
return !!indices && indices.getCount() === 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
1392401
7670