@gltf-transform/functions
Advanced tools
Comparing version 4.0.0-alpha.5 to 4.0.0-alpha.6
import { Transform } from '@gltf-transform/core'; | ||
export interface InstanceOptions { | ||
/** Minimum number of meshes considered eligible for instancing. Default: 2. */ | ||
/** Minimum number of meshes considered eligible for instancing. Default: 5. */ | ||
min?: number; | ||
} | ||
export declare const INSTANCE_DEFAULTS: Required<InstanceOptions>; | ||
/** | ||
@@ -19,3 +20,3 @@ * Creates GPU instances (with `EXT_mesh_gpu_instancing`) for shared {@link Mesh} references. In | ||
* dedup(), | ||
* instance({min: 2}), | ||
* instance({min: 5}), | ||
* ); | ||
@@ -22,0 +23,0 @@ * ``` |
@@ -7,3 +7,3 @@ import { Transform } from '@gltf-transform/core'; | ||
* Minimum number of blocks in the palette texture. If fewer unique | ||
* material values are found, no palettes will be generated. Default: 2. | ||
* material values are found, no palettes will be generated. Default: 5. | ||
*/ | ||
@@ -10,0 +10,0 @@ min?: number; |
import type { NdArray } from 'ndarray'; | ||
import { Accessor, Document, Primitive, Property, Texture, Transform, TransformContext, TypedArray, vec2 } from '@gltf-transform/core'; | ||
/** | ||
* Prepares a function used in an {@link Document.transform} pipeline. Use of this wrapper is | ||
* Prepares a function used in an {@link Document#transform} pipeline. Use of this wrapper is | ||
* optional, and plain functions may be used in transform pipelines just as well. The wrapper is | ||
@@ -6,0 +6,0 @@ * used internally so earlier pipeline stages can detect and optimize based on later stages. |
{ | ||
"name": "@gltf-transform/functions", | ||
"version": "4.0.0-alpha.5", | ||
"version": "4.0.0-alpha.6", | ||
"repository": "github:donmccurdy/glTF-Transform", | ||
@@ -38,4 +38,4 @@ "homepage": "https://gltf-transform.dev/functions.html", | ||
"dependencies": { | ||
"@gltf-transform/core": "^4.0.0-alpha.5", | ||
"@gltf-transform/extensions": "^4.0.0-alpha.5", | ||
"@gltf-transform/core": "^4.0.0-alpha.6", | ||
"@gltf-transform/extensions": "^4.0.0-alpha.6", | ||
"ktx-parse": "^0.6.0", | ||
@@ -56,3 +56,3 @@ "ndarray": "^1.0.19", | ||
}, | ||
"gitHead": "20a2e5c119208c7df9f041e1e8e075d921b8f95b" | ||
"gitHead": "b61933b39454b514f3f06a3d99cbaf10de675792" | ||
} |
@@ -8,8 +8,8 @@ import { Document, ILogger, MathUtils, Mesh, Node, Primitive, Transform, vec3, vec4 } from '@gltf-transform/core'; | ||
export interface InstanceOptions { | ||
/** Minimum number of meshes considered eligible for instancing. Default: 2. */ | ||
/** Minimum number of meshes considered eligible for instancing. Default: 5. */ | ||
min?: number; | ||
} | ||
const INSTANCE_DEFAULTS: Required<InstanceOptions> = { | ||
min: 2, | ||
export const INSTANCE_DEFAULTS: Required<InstanceOptions> = { | ||
min: 5, | ||
}; | ||
@@ -30,3 +30,3 @@ | ||
* dedup(), | ||
* instance({min: 2}), | ||
* instance({min: 5}), | ||
* ); | ||
@@ -99,6 +99,2 @@ * ``` | ||
if (!MathUtils.eq(s, [1, 1, 1])) needsScale = true; | ||
// Mark the node for cleanup. | ||
node.setMesh(null); | ||
modifiedNodes.push(node); | ||
} | ||
@@ -110,7 +106,19 @@ | ||
pruneUnusedNodes(modifiedNodes, logger); | ||
if (!needsTranslation && !needsRotation && !needsScale) { | ||
batchNode.dispose(); | ||
batch.dispose(); | ||
continue; | ||
} | ||
// Mark nodes for cleanup. | ||
for (const node of nodes) { | ||
node.setMesh(null); | ||
modifiedNodes.push(node); | ||
} | ||
numBatches++; | ||
numInstances += nodes.length; | ||
} | ||
pruneUnusedNodes(modifiedNodes, logger); | ||
} | ||
@@ -117,0 +125,0 @@ |
@@ -26,3 +26,3 @@ import { | ||
* Minimum number of blocks in the palette texture. If fewer unique | ||
* material values are found, no palettes will be generated. Default: 2. | ||
* material values are found, no palettes will be generated. Default: 5. | ||
*/ | ||
@@ -34,3 +34,3 @@ min?: number; | ||
blockSize: 4, | ||
min: 2, | ||
min: 5, | ||
}; | ||
@@ -37,0 +37,0 @@ |
@@ -58,3 +58,3 @@ import { Document, ILogger, PropertyType, Transform } from '@gltf-transform/core'; | ||
.listBuffers() | ||
.map((b) => b.getURI()) | ||
.map((b) => b.getURI()), | ||
); | ||
@@ -92,3 +92,3 @@ | ||
.listBuffers() | ||
.map((b) => b.getURI()) | ||
.map((b) => b.getURI()), | ||
); | ||
@@ -95,0 +95,0 @@ |
@@ -132,2 +132,3 @@ import { Accessor, Document, Primitive, PropertyType, Transform, TransformContext } from '@gltf-transform/core'; | ||
const srcIndices = prim.getIndices()!; | ||
const srcIndexCount = srcIndices.getCount(); | ||
const srcVertexCount = position.getCount(); | ||
@@ -163,3 +164,3 @@ | ||
const targetCount = Math.floor((options.ratio * srcVertexCount) / 3) * 3; | ||
const targetCount = Math.floor((options.ratio * srcIndexCount) / 3) * 3; | ||
const [dstIndicesArray, error] = simplifier.simplify( | ||
@@ -166,0 +167,0 @@ indicesArray as Uint32Array, |
@@ -148,3 +148,3 @@ import { Accessor, GLTF, MathUtils, Primitive, PrimitiveTarget, TypedArray, vec4 } from '@gltf-transform/core'; | ||
target: TypedArray, | ||
normalizedComponentType?: GLTF.AccessorComponentType | ||
normalizedComponentType?: GLTF.AccessorComponentType, | ||
): TypedArray { | ||
@@ -172,3 +172,3 @@ let weights: Accessor | null; | ||
values: TypedArray, | ||
normalizedComponentType?: GLTF.AccessorComponentType | ||
normalizedComponentType?: GLTF.AccessorComponentType, | ||
): void { | ||
@@ -175,0 +175,0 @@ let weights: Accessor | null; |
@@ -71,3 +71,3 @@ import type { Accessor, Document, ILogger, Transform, TypedArray } from '@gltf-transform/core'; | ||
logger: ILogger, | ||
visited: Map<Accessor, Map<Accessor, Accessor>> | ||
visited: Map<Accessor, Map<Accessor, Accessor>>, | ||
): Accessor { | ||
@@ -74,0 +74,0 @@ if (visited.has(srcAttribute) && visited.get(srcAttribute)!.has(indices)) { |
@@ -18,3 +18,3 @@ import type { NdArray } from 'ndarray'; | ||
/** | ||
* Prepares a function used in an {@link Document.transform} pipeline. Use of this wrapper is | ||
* Prepares a function used in an {@link Document#transform} pipeline. Use of this wrapper is | ||
* optional, and plain functions may be used in transform pipelines just as well. The wrapper is | ||
@@ -21,0 +21,0 @@ * used internally so earlier pipeline stages can detect and optimize based on later stages. |
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
2144916
25277