@lovelace_lol/embody 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +2411 -0
- package/dist/authoring/boneAuthoring.d.ts +132 -0
- package/dist/camera/annotationCameraAngles.d.ts +28 -0
- package/dist/camera/cameraRelativeGaze.d.ts +15 -0
- package/dist/camera/rustAnnotationCameraCore.d.ts +136 -0
- package/dist/cljs.cjs +362 -0
- package/dist/cljs.cjs.map +1 -0
- package/dist/cljs.d.ts +5 -0
- package/dist/cljs.js +359 -0
- package/dist/cljs.js.map +1 -0
- package/dist/core/TsClipCompiler.d.ts +51 -0
- package/dist/core/TsRuntimeCore.d.ts +40 -0
- package/dist/core/WasmRuntimeCore.d.ts +55 -0
- package/dist/core/compositeAxis.d.ts +4 -0
- package/dist/core/contracts/abi.d.ts +70 -0
- package/dist/core/contracts/clip.d.ts +44 -0
- package/dist/core/contracts/frame.d.ts +27 -0
- package/dist/core/contracts/host.d.ts +28 -0
- package/dist/core/contracts/ids.d.ts +15 -0
- package/dist/core/contracts/index.d.ts +10 -0
- package/dist/core/contracts/model.d.ts +31 -0
- package/dist/core/contracts/primitives.d.ts +17 -0
- package/dist/core/contracts/skeletonFit.d.ts +41 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/types.d.ts +472 -0
- package/dist/core.cjs +1065 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.js +1040 -0
- package/dist/core.js.map +1 -0
- package/dist/engines/three/Embody.d.ts +373 -0
- package/dist/engines/three/ThreeAnimationRuntime.d.ts +203 -0
- package/dist/engines/three/ThreeClipAdapter.d.ts +24 -0
- package/dist/engines/three/ThreeFrameApplier.d.ts +68 -0
- package/dist/engines/three/ThreeModelInspector.d.ts +54 -0
- package/dist/engines/three/bakedClipPartitioning.d.ts +16 -0
- package/dist/engines/three/balanceUtils.d.ts +3 -0
- package/dist/engines/three/characterHost.d.ts +80 -0
- package/dist/engines/three/characterScene.d.ts +98 -0
- package/dist/engines/three/hair/HairPhysicsController.d.ts +124 -0
- package/dist/engines/three/index.d.ts +20 -0
- package/dist/engines/three/modelLoader.d.ts +61 -0
- package/dist/engines/three/profileTestScene.d.ts +52 -0
- package/dist/engines/three/types.d.ts +20 -0
- package/dist/hair/appearance.d.ts +29 -0
- package/dist/index.cjs +15431 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +100 -0
- package/dist/index.js +15141 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/Animation.d.ts +315 -0
- package/dist/interfaces/EmbodyRuntime.d.ts +90 -0
- package/dist/interfaces/Hair.d.ts +181 -0
- package/dist/interfaces/HairPhysics.d.ts +90 -0
- package/dist/interfaces/index.d.ts +11 -0
- package/dist/mappings/extendPresetWithProfile.d.ts +17 -0
- package/dist/mappings/types.d.ts +309 -0
- package/dist/mappings/visemeSystem.d.ts +26 -0
- package/dist/physics/HairPhysics.d.ts +86 -0
- package/dist/physics/RustHairPhysics.d.ts +18 -0
- package/dist/physics/index.d.ts +6 -0
- package/dist/preset.cjs +2000 -0
- package/dist/preset.cjs.map +1 -0
- package/dist/preset.js +1997 -0
- package/dist/preset.js.map +1 -0
- package/dist/presets/bettaFish.d.ts +328 -0
- package/dist/presets/cc4.d.ts +145 -0
- package/dist/presets/index.d.ts +27 -0
- package/dist/profiles/resolveProfileConfig.d.ts +36 -0
- package/dist/profiles/types.d.ts +118 -0
- package/dist/regions/normalizeRegionTree.d.ts +6 -0
- package/dist/regions/regionMapping.d.ts +17 -0
- package/dist/regions/types.d.ts +122 -0
- package/dist/skeletonTemplates/humanoidSkeletonTemplates.d.ts +32 -0
- package/dist/test/setupWasm.d.ts +1 -0
- package/dist/three.cjs +10115 -0
- package/dist/three.cjs.map +1 -0
- package/dist/three.js +10086 -0
- package/dist/three.js.map +1 -0
- package/dist/validation/analyzeModel.d.ts +68 -0
- package/dist/validation/extractModelData.d.ts +90 -0
- package/dist/validation/generateMappingCorrections.d.ts +32 -0
- package/dist/validation/geometryHelpers.d.ts +66 -0
- package/dist/validation/types.d.ts +10 -0
- package/dist/validation/validateMappings.d.ts +77 -0
- package/dist/wasm/LICENSE +21 -0
- package/dist/wasm/README.md +72 -0
- package/dist/wasm/embody_wasm.d.ts +531 -0
- package/dist/wasm/embody_wasm.js +1635 -0
- package/dist/wasm/embody_wasm_bg.wasm +0 -0
- package/dist/wasm/embody_wasm_bg.wasm.d.ts +107 -0
- package/dist/wasm.cjs +302 -0
- package/dist/wasm.cjs.map +1 -0
- package/dist/wasm.d.ts +43 -0
- package/dist/wasm.js +268 -0
- package/dist/wasm.js.map +1 -0
- package/dist/wasmTypes.d.ts +121 -0
- package/package.json +99 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embody - Unified Model Analysis API
|
|
3
|
+
*
|
|
4
|
+
* Combines model extraction, validation, and correction suggestions
|
|
5
|
+
* into a single comprehensive analysis report.
|
|
6
|
+
*/
|
|
7
|
+
import * as THREE from 'three';
|
|
8
|
+
import type { GLTF } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
9
|
+
import type { Profile } from '../mappings/types';
|
|
10
|
+
import { type ModelData } from './extractModelData';
|
|
11
|
+
import { type ValidationResult } from './validateMappings';
|
|
12
|
+
/**
|
|
13
|
+
* Animation analysis results
|
|
14
|
+
*/
|
|
15
|
+
export interface AnimationAnalysis {
|
|
16
|
+
count: number;
|
|
17
|
+
hasIdleCandidate: boolean;
|
|
18
|
+
clips: Array<{
|
|
19
|
+
name: string;
|
|
20
|
+
duration: number;
|
|
21
|
+
affectedBones: string[];
|
|
22
|
+
affectedMorphs: string[];
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Complete model analysis report
|
|
27
|
+
*/
|
|
28
|
+
export interface ModelAnalysisReport {
|
|
29
|
+
/** Extracted model data */
|
|
30
|
+
model: ModelData;
|
|
31
|
+
/** Validation results (if preset provided) */
|
|
32
|
+
validation?: ValidationResult;
|
|
33
|
+
/** Animation analysis */
|
|
34
|
+
animations: AnimationAnalysis;
|
|
35
|
+
/** Overall health score (0-100) */
|
|
36
|
+
overallScore: number;
|
|
37
|
+
/** Human-readable summary */
|
|
38
|
+
summary: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Options for model analysis
|
|
42
|
+
*/
|
|
43
|
+
export interface AnalyzeModelOptions {
|
|
44
|
+
/** The model source */
|
|
45
|
+
source: {
|
|
46
|
+
type: 'gltf';
|
|
47
|
+
gltf: GLTF;
|
|
48
|
+
} | {
|
|
49
|
+
type: 'runtime';
|
|
50
|
+
model: THREE.Object3D;
|
|
51
|
+
meshes: THREE.Mesh[];
|
|
52
|
+
animations: THREE.AnimationClip[];
|
|
53
|
+
};
|
|
54
|
+
/** Optional preset to validate against */
|
|
55
|
+
preset?: Profile;
|
|
56
|
+
/** Request correction suggestions */
|
|
57
|
+
suggestCorrections?: boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Analyze a 3D model comprehensively
|
|
61
|
+
*
|
|
62
|
+
* Extracts model data, validates against a preset (if provided),
|
|
63
|
+
* analyzes animations, and returns a comprehensive report.
|
|
64
|
+
*
|
|
65
|
+
* @param options - Analysis options
|
|
66
|
+
* @returns Complete analysis report
|
|
67
|
+
*/
|
|
68
|
+
export declare function analyzeModel(options: AnalyzeModelOptions): Promise<ModelAnalysisReport>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embody - Model Data Extraction
|
|
3
|
+
*
|
|
4
|
+
* Extracts bones, morph targets, meshes, and animations from 3D models.
|
|
5
|
+
* Works with both GLTF files and runtime Three.js models.
|
|
6
|
+
*/
|
|
7
|
+
import * as THREE from 'three';
|
|
8
|
+
import type { GLTF } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
9
|
+
/**
|
|
10
|
+
* Bone information extracted from skeleton
|
|
11
|
+
*/
|
|
12
|
+
export interface BoneInfo {
|
|
13
|
+
name: string;
|
|
14
|
+
parent: string | null;
|
|
15
|
+
children: string[];
|
|
16
|
+
worldPosition: {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
z: number;
|
|
20
|
+
};
|
|
21
|
+
/** Depth in hierarchy (0 = root) */
|
|
22
|
+
depth: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Morph target information
|
|
26
|
+
*/
|
|
27
|
+
export interface MorphInfo {
|
|
28
|
+
name: string;
|
|
29
|
+
meshName: string;
|
|
30
|
+
index: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Model mesh information (from extraction)
|
|
34
|
+
*/
|
|
35
|
+
export interface ModelMeshInfo {
|
|
36
|
+
name: string;
|
|
37
|
+
hasMorphTargets: boolean;
|
|
38
|
+
morphCount: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Animation track information
|
|
42
|
+
*/
|
|
43
|
+
export interface TrackInfo {
|
|
44
|
+
name: string;
|
|
45
|
+
targetName: string;
|
|
46
|
+
property: string;
|
|
47
|
+
type: 'position' | 'rotation' | 'scale' | 'morph' | 'unknown';
|
|
48
|
+
keyframeCount: number;
|
|
49
|
+
valueRange?: {
|
|
50
|
+
min: number[];
|
|
51
|
+
max: number[];
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Animation clip information
|
|
56
|
+
*/
|
|
57
|
+
export interface AnimationInfo {
|
|
58
|
+
name: string;
|
|
59
|
+
duration: number;
|
|
60
|
+
tracks: TrackInfo[];
|
|
61
|
+
animatedBones: string[];
|
|
62
|
+
animatedMorphs: string[];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Complete model data extraction result
|
|
66
|
+
*/
|
|
67
|
+
export interface ModelData {
|
|
68
|
+
bones: BoneInfo[];
|
|
69
|
+
morphs: MorphInfo[];
|
|
70
|
+
meshes: ModelMeshInfo[];
|
|
71
|
+
animations: AnimationInfo[];
|
|
72
|
+
/** Quick lookups */
|
|
73
|
+
boneNames: string[];
|
|
74
|
+
morphNames: string[];
|
|
75
|
+
meshNames: string[];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Extract all data from a runtime Three.js model
|
|
79
|
+
*
|
|
80
|
+
* @param model - The root Object3D of the loaded model
|
|
81
|
+
* @param meshes - Array of meshes with morph targets (optional, will be collected if not provided)
|
|
82
|
+
* @param animations - Array of AnimationClips from the GLTF (optional)
|
|
83
|
+
*/
|
|
84
|
+
export declare function extractModelData(model: THREE.Object3D, meshes?: THREE.Mesh[], animations?: THREE.AnimationClip[]): ModelData;
|
|
85
|
+
/**
|
|
86
|
+
* Extract all data from a GLTF file
|
|
87
|
+
*
|
|
88
|
+
* @param gltf - The loaded GLTF object
|
|
89
|
+
*/
|
|
90
|
+
export declare function extractFromGLTF(gltf: GLTF): ModelData;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embody - Mapping Corrections
|
|
3
|
+
*
|
|
4
|
+
* Attempts to generate a corrected mapping configuration using fuzzy matching.
|
|
5
|
+
* This is a best-effort helper that can be layered on top of validation.
|
|
6
|
+
*/
|
|
7
|
+
import type { Profile } from '../mappings/types';
|
|
8
|
+
import type { ValidationMorphMesh as MorphMesh, ValidationSkeleton as Skeleton } from './types';
|
|
9
|
+
export interface MappingCorrection {
|
|
10
|
+
type: 'bone' | 'morph' | 'viseme' | 'mesh';
|
|
11
|
+
source: string;
|
|
12
|
+
target: string;
|
|
13
|
+
confidence: number;
|
|
14
|
+
reason: string;
|
|
15
|
+
applied: boolean;
|
|
16
|
+
auId?: number;
|
|
17
|
+
key?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface MappingCorrectionResult {
|
|
20
|
+
correctedConfig: Profile;
|
|
21
|
+
corrections: MappingCorrection[];
|
|
22
|
+
unresolved: MappingCorrection[];
|
|
23
|
+
}
|
|
24
|
+
export interface MappingCorrectionOptions {
|
|
25
|
+
minConfidence?: number;
|
|
26
|
+
/**
|
|
27
|
+
* When true, normalize names to resolved full names and clear prefix/suffix.
|
|
28
|
+
* This is useful when target names don't follow the prefix/suffix pattern.
|
|
29
|
+
*/
|
|
30
|
+
useResolvedNames?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export declare function generateMappingCorrections(meshes: MorphMesh[], skeleton: Skeleton | null, config: Profile, options?: MappingCorrectionOptions): MappingCorrectionResult;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embody - Geometry Helpers
|
|
3
|
+
*
|
|
4
|
+
* Helper functions for finding face positions, annotation centers,
|
|
5
|
+
* and other geometry-related calculations for character models.
|
|
6
|
+
*/
|
|
7
|
+
import * as THREE from 'three';
|
|
8
|
+
/**
|
|
9
|
+
* Result of finding a face center position
|
|
10
|
+
*/
|
|
11
|
+
export interface FaceCenterResult {
|
|
12
|
+
/** The calculated face center position in world space */
|
|
13
|
+
center: THREE.Vector3;
|
|
14
|
+
/** The head bone position (if found) */
|
|
15
|
+
headBonePosition?: THREE.Vector3;
|
|
16
|
+
/** How the center was determined */
|
|
17
|
+
method: 'head-bone-offset' | 'bone-average' | 'mesh-center' | 'fallback';
|
|
18
|
+
/** Debug info about what was found */
|
|
19
|
+
debugInfo: string[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Options for finding face center
|
|
23
|
+
*/
|
|
24
|
+
export interface FindFaceCenterOptions {
|
|
25
|
+
/** Names of bones to search for head bone (e.g., ['CC_Base_Head']) */
|
|
26
|
+
headBoneNames?: string[];
|
|
27
|
+
/** Names of face meshes - when provided, uses mesh bounding box center for positioning */
|
|
28
|
+
faceMeshNames?: string[];
|
|
29
|
+
/** Forward offset from head bone to face surface (default: 0.08 = 8cm) */
|
|
30
|
+
forwardOffset?: number;
|
|
31
|
+
/** Reference model height for scaling (default: 1.8m) */
|
|
32
|
+
referenceHeight?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Find the center position of a character's face.
|
|
36
|
+
*
|
|
37
|
+
* Strategy:
|
|
38
|
+
* 1. If face mesh names provided and they're face-only meshes, use mesh center
|
|
39
|
+
* 2. Otherwise find head bone and use EYE positions to determine forward direction
|
|
40
|
+
* (Eyes are reliably IN FRONT of the head bone, unlike jaw which is below)
|
|
41
|
+
*
|
|
42
|
+
* @param model - The root Object3D of the character model
|
|
43
|
+
* @param options - Configuration options
|
|
44
|
+
* @returns FaceCenterResult with the calculated position
|
|
45
|
+
*/
|
|
46
|
+
export declare function findFaceCenter(model: THREE.Object3D, options?: FindFaceCenterOptions): FaceCenterResult;
|
|
47
|
+
/**
|
|
48
|
+
* Get the forward direction of a model in world space.
|
|
49
|
+
* Assumes the model's local forward is positive Z.
|
|
50
|
+
*
|
|
51
|
+
* @param model - The model to get forward direction for
|
|
52
|
+
* @returns Normalized forward direction vector in world space
|
|
53
|
+
*/
|
|
54
|
+
export declare function getModelForwardDirection(model: THREE.Object3D): THREE.Vector3;
|
|
55
|
+
/**
|
|
56
|
+
* Check if a character model is facing forward (toward camera at origin).
|
|
57
|
+
* Uses head/eye bone positions to determine facing direction.
|
|
58
|
+
*
|
|
59
|
+
* @param model - The character model
|
|
60
|
+
* @param eyeBoneNames - Names of eye bones to search for
|
|
61
|
+
* @returns 'forward' if facing camera, 'backward' if facing away, 'unknown' if can't determine
|
|
62
|
+
*/
|
|
63
|
+
export declare function detectFacingDirection(model: THREE.Object3D, eyeBoneNames?: {
|
|
64
|
+
left: string[];
|
|
65
|
+
right: string[];
|
|
66
|
+
}): 'forward' | 'backward' | 'unknown';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embody - Mapping Validation
|
|
3
|
+
*
|
|
4
|
+
* Validates that AU mapping presets are compatible with a loaded character model.
|
|
5
|
+
* Checks that bones, morph targets, and meshes referenced in the preset exist in the model.
|
|
6
|
+
*/
|
|
7
|
+
import type { Profile } from '../mappings/types';
|
|
8
|
+
import type { MappingCorrection, MappingCorrectionOptions } from './generateMappingCorrections';
|
|
9
|
+
import type { ValidationMorphMesh as MorphMesh, ValidationSkeleton as Skeleton } from './types';
|
|
10
|
+
/**
|
|
11
|
+
* Result of validating a preset against a model
|
|
12
|
+
*/
|
|
13
|
+
export interface ValidationResult {
|
|
14
|
+
/** Overall validity - true if essential mappings are found */
|
|
15
|
+
valid: boolean;
|
|
16
|
+
/** Compatibility score from 0-100 */
|
|
17
|
+
score: number;
|
|
18
|
+
/** Morph targets referenced in preset but not found in model */
|
|
19
|
+
missingMorphs: string[];
|
|
20
|
+
/** Bones referenced in preset but not found in model */
|
|
21
|
+
missingBones: string[];
|
|
22
|
+
/** Morph targets successfully matched */
|
|
23
|
+
foundMorphs: string[];
|
|
24
|
+
/** Bones successfully matched */
|
|
25
|
+
foundBones: string[];
|
|
26
|
+
/** Morph targets in model not used by preset */
|
|
27
|
+
unmappedMorphs: string[];
|
|
28
|
+
/** Bones in model not used by preset */
|
|
29
|
+
unmappedBones: string[];
|
|
30
|
+
/** Meshes referenced by morphToMesh but not found in model */
|
|
31
|
+
missingMeshes: string[];
|
|
32
|
+
/** Meshes referenced by morphToMesh and found in model */
|
|
33
|
+
foundMeshes: string[];
|
|
34
|
+
/** Meshes in model not referenced by morphToMesh */
|
|
35
|
+
unmappedMeshes: string[];
|
|
36
|
+
/** Non-fatal warnings and suggestions */
|
|
37
|
+
warnings: string[];
|
|
38
|
+
/** Optional: corrected config when suggestions are requested */
|
|
39
|
+
suggestedConfig?: Profile;
|
|
40
|
+
/** Optional: corrections applied or suggested */
|
|
41
|
+
corrections?: MappingCorrection[];
|
|
42
|
+
/** Optional: unresolved mappings that could not be corrected */
|
|
43
|
+
unresolved?: MappingCorrection[];
|
|
44
|
+
}
|
|
45
|
+
export type IssueSeverity = 'error' | 'warning';
|
|
46
|
+
export interface MappingIssue {
|
|
47
|
+
code: string;
|
|
48
|
+
severity: IssueSeverity;
|
|
49
|
+
message: string;
|
|
50
|
+
data?: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
export interface MappingConsistencyResult {
|
|
53
|
+
valid: boolean;
|
|
54
|
+
errors: MappingIssue[];
|
|
55
|
+
warnings: MappingIssue[];
|
|
56
|
+
issues: MappingIssue[];
|
|
57
|
+
}
|
|
58
|
+
export interface ValidateMappingOptions extends MappingCorrectionOptions {
|
|
59
|
+
suggestCorrections?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Validate that the mapping dictionaries are internally consistent.
|
|
63
|
+
*/
|
|
64
|
+
export declare function validateMappingConfig(config: Profile): MappingConsistencyResult;
|
|
65
|
+
export declare function validateMappings(meshes: MorphMesh[], skeleton: Skeleton | null, config: Profile, options?: ValidateMappingOptions): ValidationResult;
|
|
66
|
+
/**
|
|
67
|
+
* Quick check if a preset is compatible with a model.
|
|
68
|
+
* Returns true if at least 50% of mappings are found.
|
|
69
|
+
*/
|
|
70
|
+
export declare function isPresetCompatible(meshes: MorphMesh[], skeleton: Skeleton | null, config: Profile): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Suggest the best preset from a list based on validation scores.
|
|
73
|
+
*/
|
|
74
|
+
export declare function suggestBestPreset<T extends Profile>(meshes: MorphMesh[], skeleton: Skeleton | null, presets: T[]): {
|
|
75
|
+
preset: T;
|
|
76
|
+
score: number;
|
|
77
|
+
} | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Jonathan Sutton Fields
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Embody Wasm Core
|
|
2
|
+
|
|
3
|
+
This crate provides the Rust/Wasm artifact used by the host-neutral Embody core.
|
|
4
|
+
The npm build now produces the generated Wasm package under `dist/wasm` and
|
|
5
|
+
the public `@lovelace_lol/embody/wasm` entrypoint initializes it explicitly.
|
|
6
|
+
|
|
7
|
+
The current Rust surface focuses on batched numeric operations that match the
|
|
8
|
+
core JS/Wasm boundary shape:
|
|
9
|
+
|
|
10
|
+
- inputs are number slices / typed arrays
|
|
11
|
+
- outputs are packed numeric buffers
|
|
12
|
+
- no Three.js, Babylon, Unity, or host objects cross the boundary
|
|
13
|
+
|
|
14
|
+
Skeleton fitting, fit metadata, and automatic skin binding should follow the
|
|
15
|
+
same descriptor boundary. Rust can own host-neutral math over mesh descriptors,
|
|
16
|
+
template skeleton descriptors, rest-pose transforms, bone envelopes, topology,
|
|
17
|
+
inverse bind data, normals, scale, and manual fit adjustments. Host adapters
|
|
18
|
+
must still own real mesh, material, GLB, skinning, and engine-object mutation.
|
|
19
|
+
The TypeScript core contract exposes `TemplateSkeletonFitMetadata` so hosts can
|
|
20
|
+
persist template id, source character id, fit transform, height/spans, status,
|
|
21
|
+
vertical axis/anchor, confidence, and manual adjustments separately from actual
|
|
22
|
+
skin weights. Both TypeScript and Rust/Wasm expose helpers that compose a
|
|
23
|
+
solved fit transform with a user's manual scale and xyz offset.
|
|
24
|
+
|
|
25
|
+
Automatic skin binding is not a per-frame Wasm target by default. It should be
|
|
26
|
+
treated as research/offline-capable work until fixtures prove acceptable
|
|
27
|
+
deformation quality for clothing, hands, face, hair, non-standard poses, and
|
|
28
|
+
other hard cases. The runtime package should expose stable metadata and helper
|
|
29
|
+
math first, then only move weight generation into Rust/Wasm if benchmarks and
|
|
30
|
+
visual tests justify doing it in the browser.
|
|
31
|
+
|
|
32
|
+
`validate_generated_template_fit_metadata(template_id, source_character_id,
|
|
33
|
+
metadata)` validates persisted generated-template fit metadata without treating
|
|
34
|
+
it as imported rig or skinning data. The packed metadata layout is:
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
[
|
|
38
|
+
schema_version,
|
|
39
|
+
metadata_kind,
|
|
40
|
+
template_lookup_status,
|
|
41
|
+
fit_status,
|
|
42
|
+
vertical_axis,
|
|
43
|
+
vertical_anchor,
|
|
44
|
+
fit_scale,
|
|
45
|
+
translate_x, translate_y, translate_z,
|
|
46
|
+
solver_confidence,
|
|
47
|
+
manual_scale_multiplier,
|
|
48
|
+
manual_offset_x, manual_offset_y, manual_offset_z
|
|
49
|
+
]
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The validator returns a bitmask. `0` means valid; nonzero values identify
|
|
53
|
+
unsupported versions, non-generated metadata kinds, unknown templates, invalid
|
|
54
|
+
axis/anchor/status codes, non-finite transform fields, invalid confidence, or
|
|
55
|
+
invalid ids.
|
|
56
|
+
|
|
57
|
+
Automatic skin binding and weight generation are intentionally tracked as a
|
|
58
|
+
separate research problem. See `docs/HUMANOID_TEMPLATE_SKINNING_TDR.md`.
|
|
59
|
+
|
|
60
|
+
Build locally:
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
cargo test --manifest-path rust/embody-wasm/Cargo.toml
|
|
64
|
+
cargo build --manifest-path rust/embody-wasm/Cargo.toml --target wasm32-unknown-unknown --release
|
|
65
|
+
npm run build
|
|
66
|
+
node scripts/smoke/package-exports.mjs
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
The npm build uses `wasm-pack` to generate JS glue and the `.wasm` binary after
|
|
70
|
+
`tsup` writes the TypeScript package artifacts. Consumers should call
|
|
71
|
+
`initEmbodyCore()` from `@lovelace_lol/embody/wasm` before using direct Wasm
|
|
72
|
+
exports.
|