@minecraft/creator-tools
Version:
Minecraft Creator Tools command line and libraries.
94 lines (93 loc) • 3.27 kB
TypeScript
/**
* VanillaGeometryTransforms
*
* This module provides transforms for vanilla Minecraft geometry files that need
* manual corrections because Minecraft's rendering code has hardcoded optimizations
* that affect how certain models appear.
*
* The Minecraft game engine contains special rendering logic for certain entities
* that isn't represented in the geometry files themselves. This transform system
* allows MCTools to replicate those visual adjustments so models render correctly.
*
* Last Updated: December 2025
*/
import { IGeometry } from "./IModelGeometry";
/**
* Represents a transform operation that can be applied to a bone
*/
export interface IBoneTransform {
/**
* Name of the bone to transform. Use "*" for all bones.
*/
boneName: string;
/**
* If set, adds this rotation (in degrees) to the bone's bind_pose_rotation
*/
addBindPoseRotation?: [number, number, number];
/**
* If set, replaces the bone's bind_pose_rotation
*/
setBindPoseRotation?: [number, number, number];
/**
* If set, adds this offset (in pixels) to the bone's pivot
*/
addPivotOffset?: [number, number, number];
/**
* If set, replaces the bone's pivot
*/
setPivot?: [number, number, number];
/**
* If set, adds this offset (in pixels) to all cube origins in this bone
*/
addCubeOriginOffset?: [number, number, number];
/**
* If set, changes the parent of this bone
*/
setParent?: string | null;
/**
* If set, removes the parent (makes bone a root bone)
*/
removeParent?: boolean;
/**
* If set, adds a per-cube rotation (in degrees) to every cube in this bone.
* Unlike setBindPoseRotation, this does NOT rotate the bone's TransformNode,
* so child bones keep their world-space positions.
* The cube's rotation pivot is set to the bone's pivot.
*/
setCubeRotation?: [number, number, number];
}
/**
* Represents all transforms to apply to a specific vanilla geometry
*/
export interface IVanillaGeometryTransform {
/**
* Geometry identifier patterns this transform applies to.
* Supports wildcards: "geometry.cow.*" matches any cow geometry variant
*/
geometryPatterns: string[];
/**
* Human-readable description of why this transform is needed
*/
reason: string;
/**
* Array of bone transforms to apply in order
*/
boneTransforms: IBoneTransform[];
}
/**
* Finds the transform configuration for a given geometry identifier
*/
export declare function findGeometryTransform(geometryId: string): IVanillaGeometryTransform | undefined;
/**
* Applies transforms to a geometry definition.
* Returns a deep copy with transforms applied - does not modify the original.
*
* @param geometry The original geometry definition
* @param geometryId The geometry identifier (e.g., "geometry.cow.v1.8")
* @returns A transformed copy of the geometry, or the original if no transforms apply
*/
export declare function applyGeometryTransforms(geometry: IGeometry, geometryId: string): IGeometry;
/**
* Returns a list of all registered geometry patterns that have transforms
*/
export declare function getRegisteredTransformPatterns(): string[];