Import a 3D Model and automatically assign and export animations
TypeScript
add a classification for the root to help with normalization
Scott Petrovica7a9c3f1eaa6
diff --git a/src/lib/CustomSkeletonHelper.ts b/src/lib/CustomSkeletonHelper.tsindex 175e959..dee2c76 100644--- a/src/lib/CustomSkeletonHelper.ts+++ b/src/lib/CustomSkeletonHelper.ts@@ -36,6 +36,9 @@ const bone_category_colors: Record<BoneCategory, number> = {[BoneCategory.Torso]: 0x0E9747,[BoneCategory.Limb]: 0x3a86ff,[BoneCategory.Extremity]: 0x8338ec,+ // the root drives the whole rig instead of deforming a body part, so it reads+ // as neutral rather than sharing the red that flags an unrecognized bone+ [BoneCategory.Root]: 0xFFFFFF,[BoneCategory.Other]: 0xff0000}@@ -105,7 +108,7 @@ class CustomSkeletonHelper extends InstancedMesh {side: FrontSide, // culling backfaces makes each convex bone shape self-occlude correctlytransparent: true, // also load bearing: keeps the helper in the transparent pass, which// renders after the opaque model, so the skeleton still draws over the mesh- opacity: options.opacity ?? 0.5,+ opacity: options.opacity ?? 0.75,depthTest: false,depthWrite: false})diff --git a/src/lib/solvers/BoneClassifier.ts b/src/lib/solvers/BoneClassifier.tsindex 3d0c8ed..8256fad 100644--- a/src/lib/solvers/BoneClassifier.ts+++ b/src/lib/solvers/BoneClassifier.ts@@ -3,14 +3,16 @@ import { type Bone } from 'three'/*** Classifies bones into categories that determine smoothing behavior.* - torso: spine, chest, neck — gets wider multi-ring smoothing- * - limb: arms, legs — gets directional child-only smoothing+ * - limb: arms, legs, head — gets directional child-only smoothing* - extremity: hands, feet, fingers, toes — no smoothing (stay rigid)- * - other: root, head, unclassified — default smoothing+ * - root: the rig driver above every anatomical bone — deforms nothing itself+ * - other: unclassified — default smoothing*/export enum BoneCategory {Torso = 'torso',Limb = 'limb',Extremity = 'extremity',+ Root = 'root',Other = 'other'}@@ -102,6 +104,16 @@ export class BoneClassifier {return BoneCategory.Torso}+ // Root: nothing anatomical in the name and no bone above it, so it drives or+ // offsets the whole rig rather than deforming any part of the mesh. Checked+ // last on purpose — a rig whose topmost bone IS a body part (hips as the+ // root, common on Mixamo imports) keeps its anatomical category and the+ // smoothing that goes with it+ const parent_bone = bone.parent as Bone | null+ if (parent_bone?.isBone !== true) {+ return BoneCategory.Root+ }+return BoneCategory.Other}}