Import a 3D Model and automatically assign and export animations
TypeScript
Add in extremity smoother which mostly ignore smoothing for now
Scott Petrovicd6e96a305e98
diff --git a/src/lib/solvers/BoneClassifier.ts b/src/lib/solvers/BoneClassifier.tsindex e7649c8..bd7040f 100644--- a/src/lib/solvers/BoneClassifier.ts+++ b/src/lib/solvers/BoneClassifier.ts@@ -4,7 +4,7 @@ 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- * - extremity: hands, feet, fingers, toes — minimal smoothing+ * - extremity: hands, feet, fingers, toes — no smoothing (stay rigid)* - other: root, head, unclassified — default smoothing*/export enum BoneCategory {@@ -36,6 +36,18 @@ export class BoneClassifier {return cat_a === BoneCategory.Limb || cat_b === BoneCategory.Limb}+ /**+ * Returns true if the boundary is between two extremity bones+ * (hand↔finger, finger↔finger, foot↔toe). These get no smoothing so+ * small parts like fingers stay rigid instead of turning mushy.+ * Requires both sides to be extremities, so the wrist/ankle+ * (limb↔extremity) is not caught here and keeps its limb smoothing.+ */+ public is_extremity_boundary (bone_index_a: number, bone_index_b: number): boolean {+ return this.get_category(bone_index_a) === BoneCategory.Extremity &&+ this.get_category(bone_index_b) === BoneCategory.Extremity+ }+/*** Returns true if the boundary between two bones should get* wider multi-ring smoothing (torso regions).diff --git a/src/lib/solvers/WeightSmoother.ts b/src/lib/solvers/WeightSmoother.tsindex e635a6a..5e7c726 100644--- a/src/lib/solvers/WeightSmoother.ts+++ b/src/lib/solvers/WeightSmoother.ts@@ -11,7 +11,7 @@ import { BoneClassifier } from './BoneClassifier.js'* Applies different smoothing strategies based on bone category:* - Torso: wider multi-ring gradient for voluminous areas* - Limbs: directional smoothing toward child bone only- * - Extremities: minimal single-ring smoothing+ * - Extremities: no smoothing — hands/fingers/feet/toes stay rigid*/export class WeightSmoother {private readonly geometry: BufferGeometry@@ -49,6 +49,9 @@ export class WeightSmoother {// Pass 4: Apply standard smoothing for remaining boundariesthis.apply_standard_smoothing(skin_indices, skin_weights, position_to_indices, boundary_pairs)++ // Pass 5: Extremity boundaries — intentionally left untouched (no smoothing)+ this.apply_extremity_smoothing(boundary_pairs)}/**@@ -84,6 +87,8 @@ export class WeightSmoother {smoothing_type = SmoothingType.Torso} else if (this.classifier.is_limb_boundary(bone_a, bone_b)) {smoothing_type = SmoothingType.Limb+ } else if (this.classifier.is_extremity_boundary(bone_a, bone_b)) {+ smoothing_type = SmoothingType.Extremity}pairs.push({ vertex_a: i, vertex_b: j, bone_a, bone_b, smoothing_type })@@ -216,6 +221,17 @@ export class WeightSmoother {}}+ /**+ * Extremity smoothing: intentionally does nothing. Hands, fingers, feet, and+ * toes stay 100% rigid to their assigned bone — any blend smears across the+ * small part and looks mushy. Kept as an explicit pass so the intent is clear+ * and so these boundaries aren't accidentally handled elsewhere.+ */+ private apply_extremity_smoothing (pairs: BoundaryPair[]): void {+ // no-op by design; extremity↔extremity boundaries receive no blending+ void pairs+ }+/*** Standard smoothing: simple 50/50 blend at boundaries (original behavior).*/@@ -385,5 +401,6 @@ interface BoundaryPair {enum SmoothingType {Torso = 'torso',Limb = 'limb',+ Extremity = 'extremity',Standard = 'standard'}diff --git a/static/models/model-human.glb b/static/models/model-human.glbindex 1b4937d..3a31728 100644Binary files a/static/models/model-human.glb and b/static/models/model-human.glb differdiff --git a/static/rigs/rig-human.glb b/static/rigs/rig-human.glbindex 5e42bc9..832a222 100644Binary files a/static/rigs/rig-human.glb and b/static/rigs/rig-human.glb differ