@lovelace_lol/loom3 1.0.37 → 1.0.39
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/README.md +26 -26
- package/dist/index.cjs +106 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -3
- package/dist/index.d.ts +19 -3
- package/dist/index.js +70 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2002,12 +2002,28 @@ declare function applyCharacterProfileToPreset(config: CharacterConfig): Profile
|
|
|
2002
2002
|
*
|
|
2003
2003
|
* Precedence:
|
|
2004
2004
|
* 1. preset defaults
|
|
2005
|
-
* 2.
|
|
2005
|
+
* 2. saved `config.regions` overrides, or fallbacks when `annotationRegions`
|
|
2006
|
+
* is present
|
|
2006
2007
|
* 3. legacy nested `config.profile` overrides (compatibility only)
|
|
2007
|
-
* 4. top-level
|
|
2008
|
+
* 4. flattened top-level profile overrides
|
|
2008
2009
|
*/
|
|
2009
2010
|
declare function extendCharacterConfigWithPreset(config: CharacterConfig): CharacterConfig;
|
|
2010
2011
|
|
|
2012
|
+
type CameraRelativeGazeOffset = {
|
|
2013
|
+
x: number;
|
|
2014
|
+
y: number;
|
|
2015
|
+
};
|
|
2016
|
+
interface CameraRelativeGazeOptions {
|
|
2017
|
+
yawWeight?: number;
|
|
2018
|
+
pitchWeight?: number;
|
|
2019
|
+
epsilon?: number;
|
|
2020
|
+
}
|
|
2021
|
+
/**
|
|
2022
|
+
* Convert the current camera position into a normalized gaze offset in model-local space.
|
|
2023
|
+
* This is intentionally pure so apps can cache or subscribe to camera changes however they want.
|
|
2024
|
+
*/
|
|
2025
|
+
declare function computeCameraRelativeGazeOffset(model: THREE.Object3D | null, cameraPosition: THREE.Vector3, targetPosition: THREE.Vector3, options?: CameraRelativeGazeOptions): CameraRelativeGazeOffset;
|
|
2026
|
+
|
|
2011
2027
|
interface ResolvedFaceCenter {
|
|
2012
2028
|
center: THREE.Vector3;
|
|
2013
2029
|
method: string;
|
|
@@ -2446,4 +2462,4 @@ declare function detectFacingDirection(model: THREE.Object3D, eyeBoneNames?: {
|
|
|
2446
2462
|
right: string[];
|
|
2447
2463
|
}): 'forward' | 'backward' | 'unknown';
|
|
2448
2464
|
|
|
2449
|
-
export { type AUInfo, type AUSelector, AU_INFO, AU_MAPPING_CONFIG, AU_MIX_DEFAULTS, AU_TO_MORPHS, type AnalyzeModelOptions, type Animation, type AnimationActionHandle, type AnimationAnalysis, type AnimationBlendMode, type AnimationClipInfo, type AnimationEasing, type AnimationInfo, type AnimationPlayOptions, type AnimationSource, type AnimationState, AnimationThree, BETTA_FISH_PRESET, BLENDING_MODES, BONE_AU_TO_BINDINGS, type BlendingMode, type BoneBinding, type BoneInfo, type BoneKey, CC4_BONE_NODES, CC4_BONE_PREFIX, CC4_EYE_MESH_NODES, CC4_MESHES, CC4_PRESET, CC4_SUFFIX_PATTERN, COMPOSITE_ROTATIONS, CONTINUUM_LABELS, CONTINUUM_PAIRS_MAP, type CharacterConfig, type CharacterRegistry, type ClipEvent, type ClipEventListener, type ClipHandle, type ClipOptions, type CompositeRotation, type CompositeRotationState, type CurvePoint, type CurvesMap, DEFAULT_HAIR_PHYSICS_CONFIG, type ExpandAnimation, type ExpandedRegionState, FISH_AU_MAPPING_CONFIG, type FaceCenterResult, type FallbackConfig, type FindFaceCenterOptions, type Hair, type HairMorphAxis, type HairMorphOutput$1 as HairMorphOutput, type HairMorphTargetMapping, type HairMorphTargetValueMapping, type HairMorphTargetsConfig, type HairObjectRef, type HairObjectState, HairPhysics, type HairPhysicsConfig$1 as HairPhysicsConfig, type HairPhysicsDirectionConfig, type HairPhysics$1 as HairPhysicsInterface, type HairMorphOutput as HairPhysicsMorphOutput, type HairPhysicsProfileConfig, type HairPhysicsRuntimeConfig, type HairPhysicsRuntimeConfigUpdate, type HairPhysicsState, type HairState, type HairStrand, type HeadState$1 as HeadState, type LineConfig, type LineCurve, type LineStyle, Loom3, type Loom3Config, Loom3 as Loom3Three, type LoomLarge, type LoomLargeConfig, Loom3 as LoomLargeThree, MORPH_TO_MESH, type MappingConsistencyResult, type MappingCorrection, type MappingCorrectionOptions, type MappingCorrectionResult, type MappingIssue, type MarkerGroup, type MarkerStyle, type MarkerStyleOverrides, type MeshCategory, type MeshInfo, type MeshMaterialSettings, type MixerLoopMode, type ModelAnalysisReport, type ModelData, type ModelMeshInfo, type MorphCategory, type MorphInfo, type MorphTargetRef, type MorphTargetsBySide, type NamedDirection, type PresetType, type Profile, type ReadyPayload, type Region, type RotationAxis, type RotationsState, type Snippet, type TrackInfo, type TransitionHandle, VISEME_JAW_AMOUNTS, VISEME_KEYS, type ValidateMappingOptions, type ValidationResult, analyzeModel, applyCharacterProfileToPreset, collectMorphMeshes, detectFacingDirection, extendCharacterConfigWithPreset, extendPresetWithProfile, extractFromGLTF, extractModelData, extractProfileOverrides, findFaceCenter, fuzzyNameMatch, generateMappingCorrections, getModelForwardDirection, getPreset, getPresetWithProfile, hasLeftRightMorphs, isMixedAU, isPresetCompatible, mergeRegionsByName as mergeCharacterRegionsByName, resolveBoneName, resolveBoneNames, resolveFaceCenter, resolvePreset, resolvePresetWithOverrides, suggestBestPreset, validateMappingConfig, validateMappings };
|
|
2465
|
+
export { type AUInfo, type AUSelector, AU_INFO, AU_MAPPING_CONFIG, AU_MIX_DEFAULTS, AU_TO_MORPHS, type AnalyzeModelOptions, type Animation, type AnimationActionHandle, type AnimationAnalysis, type AnimationBlendMode, type AnimationClipInfo, type AnimationEasing, type AnimationInfo, type AnimationPlayOptions, type AnimationSource, type AnimationState, AnimationThree, BETTA_FISH_PRESET, BLENDING_MODES, BONE_AU_TO_BINDINGS, type BlendingMode, type BoneBinding, type BoneInfo, type BoneKey, CC4_BONE_NODES, CC4_BONE_PREFIX, CC4_EYE_MESH_NODES, CC4_MESHES, CC4_PRESET, CC4_SUFFIX_PATTERN, COMPOSITE_ROTATIONS, CONTINUUM_LABELS, CONTINUUM_PAIRS_MAP, type CameraRelativeGazeOffset, type CameraRelativeGazeOptions, type CharacterConfig, type CharacterRegistry, type ClipEvent, type ClipEventListener, type ClipHandle, type ClipOptions, type CompositeRotation, type CompositeRotationState, type CurvePoint, type CurvesMap, DEFAULT_HAIR_PHYSICS_CONFIG, type ExpandAnimation, type ExpandedRegionState, FISH_AU_MAPPING_CONFIG, type FaceCenterResult, type FallbackConfig, type FindFaceCenterOptions, type Hair, type HairMorphAxis, type HairMorphOutput$1 as HairMorphOutput, type HairMorphTargetMapping, type HairMorphTargetValueMapping, type HairMorphTargetsConfig, type HairObjectRef, type HairObjectState, HairPhysics, type HairPhysicsConfig$1 as HairPhysicsConfig, type HairPhysicsDirectionConfig, type HairPhysics$1 as HairPhysicsInterface, type HairMorphOutput as HairPhysicsMorphOutput, type HairPhysicsProfileConfig, type HairPhysicsRuntimeConfig, type HairPhysicsRuntimeConfigUpdate, type HairPhysicsState, type HairState, type HairStrand, type HeadState$1 as HeadState, type LineConfig, type LineCurve, type LineStyle, Loom3, type Loom3Config, Loom3 as Loom3Three, type LoomLarge, type LoomLargeConfig, Loom3 as LoomLargeThree, MORPH_TO_MESH, type MappingConsistencyResult, type MappingCorrection, type MappingCorrectionOptions, type MappingCorrectionResult, type MappingIssue, type MarkerGroup, type MarkerStyle, type MarkerStyleOverrides, type MeshCategory, type MeshInfo, type MeshMaterialSettings, type MixerLoopMode, type ModelAnalysisReport, type ModelData, type ModelMeshInfo, type MorphCategory, type MorphInfo, type MorphTargetRef, type MorphTargetsBySide, type NamedDirection, type PresetType, type Profile, type ReadyPayload, type Region, type RotationAxis, type RotationsState, type Snippet, type TrackInfo, type TransitionHandle, VISEME_JAW_AMOUNTS, VISEME_KEYS, type ValidateMappingOptions, type ValidationResult, analyzeModel, applyCharacterProfileToPreset, collectMorphMeshes, computeCameraRelativeGazeOffset, detectFacingDirection, extendCharacterConfigWithPreset, extendPresetWithProfile, extractFromGLTF, extractModelData, extractProfileOverrides, findFaceCenter, fuzzyNameMatch, generateMappingCorrections, getModelForwardDirection, getPreset, getPresetWithProfile, hasLeftRightMorphs, isMixedAU, isPresetCompatible, mergeRegionsByName as mergeCharacterRegionsByName, resolveBoneName, resolveBoneNames, resolveFaceCenter, resolvePreset, resolvePresetWithOverrides, suggestBestPreset, validateMappingConfig, validateMappings };
|
package/dist/index.d.ts
CHANGED
|
@@ -2002,12 +2002,28 @@ declare function applyCharacterProfileToPreset(config: CharacterConfig): Profile
|
|
|
2002
2002
|
*
|
|
2003
2003
|
* Precedence:
|
|
2004
2004
|
* 1. preset defaults
|
|
2005
|
-
* 2.
|
|
2005
|
+
* 2. saved `config.regions` overrides, or fallbacks when `annotationRegions`
|
|
2006
|
+
* is present
|
|
2006
2007
|
* 3. legacy nested `config.profile` overrides (compatibility only)
|
|
2007
|
-
* 4. top-level
|
|
2008
|
+
* 4. flattened top-level profile overrides
|
|
2008
2009
|
*/
|
|
2009
2010
|
declare function extendCharacterConfigWithPreset(config: CharacterConfig): CharacterConfig;
|
|
2010
2011
|
|
|
2012
|
+
type CameraRelativeGazeOffset = {
|
|
2013
|
+
x: number;
|
|
2014
|
+
y: number;
|
|
2015
|
+
};
|
|
2016
|
+
interface CameraRelativeGazeOptions {
|
|
2017
|
+
yawWeight?: number;
|
|
2018
|
+
pitchWeight?: number;
|
|
2019
|
+
epsilon?: number;
|
|
2020
|
+
}
|
|
2021
|
+
/**
|
|
2022
|
+
* Convert the current camera position into a normalized gaze offset in model-local space.
|
|
2023
|
+
* This is intentionally pure so apps can cache or subscribe to camera changes however they want.
|
|
2024
|
+
*/
|
|
2025
|
+
declare function computeCameraRelativeGazeOffset(model: THREE.Object3D | null, cameraPosition: THREE.Vector3, targetPosition: THREE.Vector3, options?: CameraRelativeGazeOptions): CameraRelativeGazeOffset;
|
|
2026
|
+
|
|
2011
2027
|
interface ResolvedFaceCenter {
|
|
2012
2028
|
center: THREE.Vector3;
|
|
2013
2029
|
method: string;
|
|
@@ -2446,4 +2462,4 @@ declare function detectFacingDirection(model: THREE.Object3D, eyeBoneNames?: {
|
|
|
2446
2462
|
right: string[];
|
|
2447
2463
|
}): 'forward' | 'backward' | 'unknown';
|
|
2448
2464
|
|
|
2449
|
-
export { type AUInfo, type AUSelector, AU_INFO, AU_MAPPING_CONFIG, AU_MIX_DEFAULTS, AU_TO_MORPHS, type AnalyzeModelOptions, type Animation, type AnimationActionHandle, type AnimationAnalysis, type AnimationBlendMode, type AnimationClipInfo, type AnimationEasing, type AnimationInfo, type AnimationPlayOptions, type AnimationSource, type AnimationState, AnimationThree, BETTA_FISH_PRESET, BLENDING_MODES, BONE_AU_TO_BINDINGS, type BlendingMode, type BoneBinding, type BoneInfo, type BoneKey, CC4_BONE_NODES, CC4_BONE_PREFIX, CC4_EYE_MESH_NODES, CC4_MESHES, CC4_PRESET, CC4_SUFFIX_PATTERN, COMPOSITE_ROTATIONS, CONTINUUM_LABELS, CONTINUUM_PAIRS_MAP, type CharacterConfig, type CharacterRegistry, type ClipEvent, type ClipEventListener, type ClipHandle, type ClipOptions, type CompositeRotation, type CompositeRotationState, type CurvePoint, type CurvesMap, DEFAULT_HAIR_PHYSICS_CONFIG, type ExpandAnimation, type ExpandedRegionState, FISH_AU_MAPPING_CONFIG, type FaceCenterResult, type FallbackConfig, type FindFaceCenterOptions, type Hair, type HairMorphAxis, type HairMorphOutput$1 as HairMorphOutput, type HairMorphTargetMapping, type HairMorphTargetValueMapping, type HairMorphTargetsConfig, type HairObjectRef, type HairObjectState, HairPhysics, type HairPhysicsConfig$1 as HairPhysicsConfig, type HairPhysicsDirectionConfig, type HairPhysics$1 as HairPhysicsInterface, type HairMorphOutput as HairPhysicsMorphOutput, type HairPhysicsProfileConfig, type HairPhysicsRuntimeConfig, type HairPhysicsRuntimeConfigUpdate, type HairPhysicsState, type HairState, type HairStrand, type HeadState$1 as HeadState, type LineConfig, type LineCurve, type LineStyle, Loom3, type Loom3Config, Loom3 as Loom3Three, type LoomLarge, type LoomLargeConfig, Loom3 as LoomLargeThree, MORPH_TO_MESH, type MappingConsistencyResult, type MappingCorrection, type MappingCorrectionOptions, type MappingCorrectionResult, type MappingIssue, type MarkerGroup, type MarkerStyle, type MarkerStyleOverrides, type MeshCategory, type MeshInfo, type MeshMaterialSettings, type MixerLoopMode, type ModelAnalysisReport, type ModelData, type ModelMeshInfo, type MorphCategory, type MorphInfo, type MorphTargetRef, type MorphTargetsBySide, type NamedDirection, type PresetType, type Profile, type ReadyPayload, type Region, type RotationAxis, type RotationsState, type Snippet, type TrackInfo, type TransitionHandle, VISEME_JAW_AMOUNTS, VISEME_KEYS, type ValidateMappingOptions, type ValidationResult, analyzeModel, applyCharacterProfileToPreset, collectMorphMeshes, detectFacingDirection, extendCharacterConfigWithPreset, extendPresetWithProfile, extractFromGLTF, extractModelData, extractProfileOverrides, findFaceCenter, fuzzyNameMatch, generateMappingCorrections, getModelForwardDirection, getPreset, getPresetWithProfile, hasLeftRightMorphs, isMixedAU, isPresetCompatible, mergeRegionsByName as mergeCharacterRegionsByName, resolveBoneName, resolveBoneNames, resolveFaceCenter, resolvePreset, resolvePresetWithOverrides, suggestBestPreset, validateMappingConfig, validateMappings };
|
|
2465
|
+
export { type AUInfo, type AUSelector, AU_INFO, AU_MAPPING_CONFIG, AU_MIX_DEFAULTS, AU_TO_MORPHS, type AnalyzeModelOptions, type Animation, type AnimationActionHandle, type AnimationAnalysis, type AnimationBlendMode, type AnimationClipInfo, type AnimationEasing, type AnimationInfo, type AnimationPlayOptions, type AnimationSource, type AnimationState, AnimationThree, BETTA_FISH_PRESET, BLENDING_MODES, BONE_AU_TO_BINDINGS, type BlendingMode, type BoneBinding, type BoneInfo, type BoneKey, CC4_BONE_NODES, CC4_BONE_PREFIX, CC4_EYE_MESH_NODES, CC4_MESHES, CC4_PRESET, CC4_SUFFIX_PATTERN, COMPOSITE_ROTATIONS, CONTINUUM_LABELS, CONTINUUM_PAIRS_MAP, type CameraRelativeGazeOffset, type CameraRelativeGazeOptions, type CharacterConfig, type CharacterRegistry, type ClipEvent, type ClipEventListener, type ClipHandle, type ClipOptions, type CompositeRotation, type CompositeRotationState, type CurvePoint, type CurvesMap, DEFAULT_HAIR_PHYSICS_CONFIG, type ExpandAnimation, type ExpandedRegionState, FISH_AU_MAPPING_CONFIG, type FaceCenterResult, type FallbackConfig, type FindFaceCenterOptions, type Hair, type HairMorphAxis, type HairMorphOutput$1 as HairMorphOutput, type HairMorphTargetMapping, type HairMorphTargetValueMapping, type HairMorphTargetsConfig, type HairObjectRef, type HairObjectState, HairPhysics, type HairPhysicsConfig$1 as HairPhysicsConfig, type HairPhysicsDirectionConfig, type HairPhysics$1 as HairPhysicsInterface, type HairMorphOutput as HairPhysicsMorphOutput, type HairPhysicsProfileConfig, type HairPhysicsRuntimeConfig, type HairPhysicsRuntimeConfigUpdate, type HairPhysicsState, type HairState, type HairStrand, type HeadState$1 as HeadState, type LineConfig, type LineCurve, type LineStyle, Loom3, type Loom3Config, Loom3 as Loom3Three, type LoomLarge, type LoomLargeConfig, Loom3 as LoomLargeThree, MORPH_TO_MESH, type MappingConsistencyResult, type MappingCorrection, type MappingCorrectionOptions, type MappingCorrectionResult, type MappingIssue, type MarkerGroup, type MarkerStyle, type MarkerStyleOverrides, type MeshCategory, type MeshInfo, type MeshMaterialSettings, type MixerLoopMode, type ModelAnalysisReport, type ModelData, type ModelMeshInfo, type MorphCategory, type MorphInfo, type MorphTargetRef, type MorphTargetsBySide, type NamedDirection, type PresetType, type Profile, type ReadyPayload, type Region, type RotationAxis, type RotationsState, type Snippet, type TrackInfo, type TransitionHandle, VISEME_JAW_AMOUNTS, VISEME_KEYS, type ValidateMappingOptions, type ValidationResult, analyzeModel, applyCharacterProfileToPreset, collectMorphMeshes, computeCameraRelativeGazeOffset, detectFacingDirection, extendCharacterConfigWithPreset, extendPresetWithProfile, extractFromGLTF, extractModelData, extractProfileOverrides, findFaceCenter, fuzzyNameMatch, generateMappingCorrections, getModelForwardDirection, getPreset, getPresetWithProfile, hasLeftRightMorphs, isMixedAU, isPresetCompatible, mergeRegionsByName as mergeCharacterRegionsByName, resolveBoneName, resolveBoneNames, resolveFaceCenter, resolvePreset, resolvePresetWithOverrides, suggestBestPreset, validateMappingConfig, validateMappings };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as THREE2 from 'three';
|
|
2
2
|
import { Vector3, Clock, Box3, Quaternion, AdditiveAnimationBlendMode, NormalAnimationBlendMode, LoopPingPong, LoopOnce, LoopRepeat, QuaternionKeyframeTrack, NumberKeyframeTrack, AnimationClip, AnimationMixer, Mesh, PropertyBinding } from 'three';
|
|
3
3
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -6209,10 +6209,11 @@ function extractProfileOverrides(config) {
|
|
|
6209
6209
|
if (key === "annotationRegions") {
|
|
6210
6210
|
const topLevelAnnotationRegions = Array.isArray(topLevelConfig.annotationRegions) ? topLevelConfig.annotationRegions : void 0;
|
|
6211
6211
|
const legacyAnnotationRegions = Array.isArray(legacyNestedOverrides.annotationRegions) ? legacyNestedOverrides.annotationRegions : void 0;
|
|
6212
|
-
const
|
|
6212
|
+
const legacyRegionFallback = Array.isArray(config.regions) && config.regions.length > 0 ? config.regions : void 0;
|
|
6213
|
+
const legacyProfileRegions = mergeRegionsByName(legacyRegionFallback, legacyAnnotationRegions);
|
|
6213
6214
|
const regions = mergeRegionsByName(
|
|
6214
|
-
|
|
6215
|
-
|
|
6215
|
+
legacyProfileRegions,
|
|
6216
|
+
topLevelAnnotationRegions
|
|
6216
6217
|
);
|
|
6217
6218
|
if (regions) {
|
|
6218
6219
|
overrides.annotationRegions = regions.map((region) => cloneRegion(region));
|
|
@@ -6228,6 +6229,13 @@ function extractProfileOverrides(config) {
|
|
|
6228
6229
|
}
|
|
6229
6230
|
return overrides;
|
|
6230
6231
|
}
|
|
6232
|
+
function hasCanonicalAnnotationRegionOverrides(config) {
|
|
6233
|
+
const topLevelConfig = config;
|
|
6234
|
+
if (Array.isArray(topLevelConfig.annotationRegions)) {
|
|
6235
|
+
return true;
|
|
6236
|
+
}
|
|
6237
|
+
return isPlainObject2(config.profile) && Array.isArray(config.profile.annotationRegions);
|
|
6238
|
+
}
|
|
6231
6239
|
function applyCharacterProfileToPreset(config) {
|
|
6232
6240
|
const presetType = config.auPresetType;
|
|
6233
6241
|
if (!presetType) {
|
|
@@ -6265,7 +6273,7 @@ function extendCharacterConfigWithPreset(config) {
|
|
|
6265
6273
|
return config;
|
|
6266
6274
|
}
|
|
6267
6275
|
const presetRegions = extendedPresetProfile.annotationRegions;
|
|
6268
|
-
const mergedRegions = mergeRegionsByName(presetRegions, config.regions);
|
|
6276
|
+
const mergedRegions = hasCanonicalAnnotationRegionOverrides(config) ? mergeRegionsByName(config.regions, presetRegions) : mergeRegionsByName(presetRegions, config.regions);
|
|
6269
6277
|
const normalizedRegions = normalizeRegionTree(
|
|
6270
6278
|
mergedRegions,
|
|
6271
6279
|
profileOverrides.disabledRegions
|
|
@@ -6280,6 +6288,43 @@ function extendCharacterConfigWithPreset(config) {
|
|
|
6280
6288
|
regions: extendedRegions ?? config.regions
|
|
6281
6289
|
};
|
|
6282
6290
|
}
|
|
6291
|
+
var DEFAULT_EPSILON = 1e-4;
|
|
6292
|
+
var DEFAULT_YAW_WEIGHT = 0.35;
|
|
6293
|
+
var DEFAULT_PITCH_WEIGHT = 0.2;
|
|
6294
|
+
var ZERO_OFFSET = { x: 0, y: 0 };
|
|
6295
|
+
function clampOffset(value) {
|
|
6296
|
+
return THREE2.MathUtils.clamp(value, -1, 1);
|
|
6297
|
+
}
|
|
6298
|
+
function toModelLocalDirection(model, worldDirection) {
|
|
6299
|
+
const localDirection = worldDirection.clone();
|
|
6300
|
+
model.updateWorldMatrix(true, false);
|
|
6301
|
+
const worldQuaternion = new THREE2.Quaternion();
|
|
6302
|
+
model.getWorldQuaternion(worldQuaternion);
|
|
6303
|
+
localDirection.applyQuaternion(worldQuaternion.invert());
|
|
6304
|
+
return localDirection.normalize();
|
|
6305
|
+
}
|
|
6306
|
+
function computeCameraRelativeGazeOffset(model, cameraPosition, targetPosition, options = {}) {
|
|
6307
|
+
if (!model) {
|
|
6308
|
+
return ZERO_OFFSET;
|
|
6309
|
+
}
|
|
6310
|
+
const epsilon = options.epsilon ?? DEFAULT_EPSILON;
|
|
6311
|
+
const yawWeight = options.yawWeight ?? DEFAULT_YAW_WEIGHT;
|
|
6312
|
+
const pitchWeight = options.pitchWeight ?? DEFAULT_PITCH_WEIGHT;
|
|
6313
|
+
const worldOffset = new THREE2.Vector3().subVectors(cameraPosition, targetPosition);
|
|
6314
|
+
if (worldOffset.lengthSq() < epsilon) {
|
|
6315
|
+
return ZERO_OFFSET;
|
|
6316
|
+
}
|
|
6317
|
+
const localDirection = toModelLocalDirection(model, worldOffset.normalize());
|
|
6318
|
+
const yawAngle = Math.atan2(localDirection.x, localDirection.z);
|
|
6319
|
+
const pitchAngle = Math.atan2(
|
|
6320
|
+
localDirection.y,
|
|
6321
|
+
Math.max(Math.hypot(localDirection.x, localDirection.z), epsilon)
|
|
6322
|
+
);
|
|
6323
|
+
return {
|
|
6324
|
+
x: clampOffset(yawAngle / (Math.PI / 2)) * yawWeight,
|
|
6325
|
+
y: clampOffset(pitchAngle / (Math.PI / 3)) * pitchWeight
|
|
6326
|
+
};
|
|
6327
|
+
}
|
|
6283
6328
|
var DEFAULT_HEAD_BONE_NAMES = ["CC_Base_Head", "Head", "head", "Bip01_Head"];
|
|
6284
6329
|
var DEFAULT_REFERENCE_HEIGHT = 1.8;
|
|
6285
6330
|
var DEFAULT_FORWARD_OFFSET = 0.08;
|
|
@@ -6295,8 +6340,8 @@ function findFaceCenter(model, options = {}) {
|
|
|
6295
6340
|
referenceHeight = DEFAULT_REFERENCE_HEIGHT
|
|
6296
6341
|
} = options;
|
|
6297
6342
|
const debugInfo = [];
|
|
6298
|
-
const boundingBox = new
|
|
6299
|
-
const modelSize = new
|
|
6343
|
+
const boundingBox = new THREE2.Box3().setFromObject(model);
|
|
6344
|
+
const modelSize = new THREE2.Vector3();
|
|
6300
6345
|
boundingBox.getSize(modelSize);
|
|
6301
6346
|
const scale = modelSize.y / referenceHeight;
|
|
6302
6347
|
debugInfo.push(`Model height: ${modelSize.y.toFixed(2)}m, scale factor: ${scale.toFixed(2)}`);
|
|
@@ -6307,7 +6352,7 @@ function findFaceCenter(model, options = {}) {
|
|
|
6307
6352
|
const objName = obj.name.toLowerCase();
|
|
6308
6353
|
for (const boneName of headBoneNames) {
|
|
6309
6354
|
if (objName === boneName.toLowerCase() || objName.includes(boneName.toLowerCase())) {
|
|
6310
|
-
headPos2 = new
|
|
6355
|
+
headPos2 = new THREE2.Vector3();
|
|
6311
6356
|
obj.getWorldPosition(headPos2);
|
|
6312
6357
|
debugInfo.push(`Found head bone "${obj.name}" at (${headPos2.x.toFixed(3)}, ${headPos2.y.toFixed(3)}, ${headPos2.z.toFixed(3)})`);
|
|
6313
6358
|
return;
|
|
@@ -6326,7 +6371,7 @@ function findFaceCenter(model, options = {}) {
|
|
|
6326
6371
|
if (!eyes2.left) {
|
|
6327
6372
|
for (const name of EYE_BONE_NAMES.left) {
|
|
6328
6373
|
if (objName.includes(name)) {
|
|
6329
|
-
eyes2.left = new
|
|
6374
|
+
eyes2.left = new THREE2.Vector3();
|
|
6330
6375
|
obj.getWorldPosition(eyes2.left);
|
|
6331
6376
|
debugInfo.push(`Found left eye "${obj.name}" at (${eyes2.left.x.toFixed(3)}, ${eyes2.left.y.toFixed(3)}, ${eyes2.left.z.toFixed(3)})`);
|
|
6332
6377
|
break;
|
|
@@ -6336,7 +6381,7 @@ function findFaceCenter(model, options = {}) {
|
|
|
6336
6381
|
if (!eyes2.right) {
|
|
6337
6382
|
for (const name of EYE_BONE_NAMES.right) {
|
|
6338
6383
|
if (objName.includes(name)) {
|
|
6339
|
-
eyes2.right = new
|
|
6384
|
+
eyes2.right = new THREE2.Vector3();
|
|
6340
6385
|
obj.getWorldPosition(eyes2.right);
|
|
6341
6386
|
debugInfo.push(`Found right eye "${obj.name}" at (${eyes2.right.x.toFixed(3)}, ${eyes2.right.y.toFixed(3)}, ${eyes2.right.z.toFixed(3)})`);
|
|
6342
6387
|
break;
|
|
@@ -6348,7 +6393,7 @@ function findFaceCenter(model, options = {}) {
|
|
|
6348
6393
|
};
|
|
6349
6394
|
if (faceMeshNames && faceMeshNames.length > 0) {
|
|
6350
6395
|
debugInfo.push(`Looking for face meshes: ${faceMeshNames.join(", ")}`);
|
|
6351
|
-
const meshBox = new
|
|
6396
|
+
const meshBox = new THREE2.Box3();
|
|
6352
6397
|
let foundMesh = false;
|
|
6353
6398
|
model.traverse((obj) => {
|
|
6354
6399
|
const isMesh = obj.isMesh;
|
|
@@ -6356,7 +6401,7 @@ function findFaceCenter(model, options = {}) {
|
|
|
6356
6401
|
for (const meshName of faceMeshNames) {
|
|
6357
6402
|
if (obj.name === meshName || obj.name.includes(meshName)) {
|
|
6358
6403
|
const mesh = obj;
|
|
6359
|
-
const tempBox = new
|
|
6404
|
+
const tempBox = new THREE2.Box3().setFromObject(mesh);
|
|
6360
6405
|
meshBox.union(tempBox);
|
|
6361
6406
|
foundMesh = true;
|
|
6362
6407
|
debugInfo.push(`Found mesh: "${obj.name}"`);
|
|
@@ -6365,11 +6410,11 @@ function findFaceCenter(model, options = {}) {
|
|
|
6365
6410
|
}
|
|
6366
6411
|
});
|
|
6367
6412
|
if (foundMesh && !meshBox.isEmpty()) {
|
|
6368
|
-
const meshBoundsSize = new
|
|
6413
|
+
const meshBoundsSize = new THREE2.Vector3();
|
|
6369
6414
|
meshBox.getSize(meshBoundsSize);
|
|
6370
6415
|
const isFullBodyMesh = meshBoundsSize.y > modelSize.y * 0.7;
|
|
6371
6416
|
if (!isFullBodyMesh) {
|
|
6372
|
-
const meshCenter = new
|
|
6417
|
+
const meshCenter = new THREE2.Vector3();
|
|
6373
6418
|
meshBox.getCenter(meshCenter);
|
|
6374
6419
|
debugInfo.push(`Using face mesh center: (${meshCenter.x.toFixed(3)}, ${meshCenter.y.toFixed(3)}, ${meshCenter.z.toFixed(3)})`);
|
|
6375
6420
|
return {
|
|
@@ -6383,7 +6428,7 @@ function findFaceCenter(model, options = {}) {
|
|
|
6383
6428
|
}
|
|
6384
6429
|
const eyes = findEyes();
|
|
6385
6430
|
if (eyes.left && eyes.right) {
|
|
6386
|
-
const eyeCenter = new
|
|
6431
|
+
const eyeCenter = new THREE2.Vector3().addVectors(eyes.left, eyes.right).multiplyScalar(0.5);
|
|
6387
6432
|
debugInfo.push(`Eye center (face position): (${eyeCenter.x.toFixed(3)}, ${eyeCenter.y.toFixed(3)}, ${eyeCenter.z.toFixed(3)})`);
|
|
6388
6433
|
const headPos2 = findHeadBone();
|
|
6389
6434
|
return {
|
|
@@ -6408,10 +6453,10 @@ function findFaceCenter(model, options = {}) {
|
|
|
6408
6453
|
};
|
|
6409
6454
|
}
|
|
6410
6455
|
debugInfo.push("No head bone found, using model center fallback");
|
|
6411
|
-
const modelCenter = new
|
|
6456
|
+
const modelCenter = new THREE2.Vector3();
|
|
6412
6457
|
boundingBox.getCenter(modelCenter);
|
|
6413
6458
|
const headHeight = boundingBox.min.y + modelSize.y * 0.9;
|
|
6414
|
-
const fallbackCenter = new
|
|
6459
|
+
const fallbackCenter = new THREE2.Vector3(modelCenter.x, headHeight, modelCenter.z);
|
|
6415
6460
|
debugInfo.push(`Fallback center: (${fallbackCenter.x.toFixed(3)}, ${fallbackCenter.y.toFixed(3)}, ${fallbackCenter.z.toFixed(3)})`);
|
|
6416
6461
|
return {
|
|
6417
6462
|
center: fallbackCenter,
|
|
@@ -6420,7 +6465,7 @@ function findFaceCenter(model, options = {}) {
|
|
|
6420
6465
|
};
|
|
6421
6466
|
}
|
|
6422
6467
|
function getModelForwardDirection(model) {
|
|
6423
|
-
const forward = new
|
|
6468
|
+
const forward = new THREE2.Vector3(0, 0, 1);
|
|
6424
6469
|
forward.applyQuaternion(model.quaternion);
|
|
6425
6470
|
return forward.normalize();
|
|
6426
6471
|
}
|
|
@@ -6437,7 +6482,7 @@ function detectFacingDirection(model, eyeBoneNames = {
|
|
|
6437
6482
|
if (!eyes.left) {
|
|
6438
6483
|
for (const name of eyeBoneNames.left) {
|
|
6439
6484
|
if (objName.includes(name)) {
|
|
6440
|
-
eyes.left = new
|
|
6485
|
+
eyes.left = new THREE2.Vector3();
|
|
6441
6486
|
obj.getWorldPosition(eyes.left);
|
|
6442
6487
|
break;
|
|
6443
6488
|
}
|
|
@@ -6446,7 +6491,7 @@ function detectFacingDirection(model, eyeBoneNames = {
|
|
|
6446
6491
|
if (!eyes.right) {
|
|
6447
6492
|
for (const name of eyeBoneNames.right) {
|
|
6448
6493
|
if (objName.includes(name)) {
|
|
6449
|
-
eyes.right = new
|
|
6494
|
+
eyes.right = new THREE2.Vector3();
|
|
6450
6495
|
obj.getWorldPosition(eyes.right);
|
|
6451
6496
|
break;
|
|
6452
6497
|
}
|
|
@@ -7362,19 +7407,19 @@ function extractBones(root) {
|
|
|
7362
7407
|
const bones = [];
|
|
7363
7408
|
const boneDepths = /* @__PURE__ */ new Map();
|
|
7364
7409
|
root.traverse((obj) => {
|
|
7365
|
-
if (obj instanceof
|
|
7366
|
-
const worldPos = new
|
|
7410
|
+
if (obj instanceof THREE2.Bone || obj.type === "Bone") {
|
|
7411
|
+
const worldPos = new THREE2.Vector3();
|
|
7367
7412
|
obj.getWorldPosition(worldPos);
|
|
7368
7413
|
let depth = 0;
|
|
7369
7414
|
let parent = obj.parent;
|
|
7370
7415
|
while (parent) {
|
|
7371
|
-
if (parent instanceof
|
|
7416
|
+
if (parent instanceof THREE2.Bone || parent.type === "Bone") {
|
|
7372
7417
|
depth++;
|
|
7373
7418
|
}
|
|
7374
7419
|
parent = parent.parent;
|
|
7375
7420
|
}
|
|
7376
7421
|
boneDepths.set(obj.name, depth);
|
|
7377
|
-
const parentBone = obj.parent instanceof
|
|
7422
|
+
const parentBone = obj.parent instanceof THREE2.Bone || obj.parent?.type === "Bone" ? obj.parent.name : null;
|
|
7378
7423
|
bones.push({
|
|
7379
7424
|
name: obj.name,
|
|
7380
7425
|
parent: parentBone,
|
|
@@ -7598,6 +7643,6 @@ async function analyzeModel(options) {
|
|
|
7598
7643
|
};
|
|
7599
7644
|
}
|
|
7600
7645
|
|
|
7601
|
-
export { AU_INFO, AU_MAPPING_CONFIG, AU_MIX_DEFAULTS, AU_TO_MORPHS, AnimationThree, BETTA_FISH_PRESET, BLENDING_MODES, BONE_AU_TO_BINDINGS, CC4_BONE_NODES, CC4_BONE_PREFIX, CC4_EYE_MESH_NODES, CC4_MESHES, CC4_PRESET, CC4_SUFFIX_PATTERN, COMPOSITE_ROTATIONS, CONTINUUM_LABELS, CONTINUUM_PAIRS_MAP, DEFAULT_HAIR_PHYSICS_CONFIG, FISH_AU_MAPPING_CONFIG, HairPhysics, Loom3, Loom3 as Loom3Three, Loom3 as LoomLargeThree, MORPH_TO_MESH, VISEME_JAW_AMOUNTS, VISEME_KEYS, analyzeModel, applyCharacterProfileToPreset, collectMorphMeshes, detectFacingDirection, extendCharacterConfigWithPreset, extendPresetWithProfile, extractFromGLTF, extractModelData, extractProfileOverrides, findFaceCenter, fuzzyNameMatch, generateMappingCorrections, getModelForwardDirection, getPreset, getPresetWithProfile, hasLeftRightMorphs, isMixedAU, isPresetCompatible, mergeRegionsByName as mergeCharacterRegionsByName, resolveBoneName, resolveBoneNames, resolveFaceCenter, resolvePreset, resolvePresetWithOverrides, suggestBestPreset, validateMappingConfig, validateMappings };
|
|
7646
|
+
export { AU_INFO, AU_MAPPING_CONFIG, AU_MIX_DEFAULTS, AU_TO_MORPHS, AnimationThree, BETTA_FISH_PRESET, BLENDING_MODES, BONE_AU_TO_BINDINGS, CC4_BONE_NODES, CC4_BONE_PREFIX, CC4_EYE_MESH_NODES, CC4_MESHES, CC4_PRESET, CC4_SUFFIX_PATTERN, COMPOSITE_ROTATIONS, CONTINUUM_LABELS, CONTINUUM_PAIRS_MAP, DEFAULT_HAIR_PHYSICS_CONFIG, FISH_AU_MAPPING_CONFIG, HairPhysics, Loom3, Loom3 as Loom3Three, Loom3 as LoomLargeThree, MORPH_TO_MESH, VISEME_JAW_AMOUNTS, VISEME_KEYS, analyzeModel, applyCharacterProfileToPreset, collectMorphMeshes, computeCameraRelativeGazeOffset, detectFacingDirection, extendCharacterConfigWithPreset, extendPresetWithProfile, extractFromGLTF, extractModelData, extractProfileOverrides, findFaceCenter, fuzzyNameMatch, generateMappingCorrections, getModelForwardDirection, getPreset, getPresetWithProfile, hasLeftRightMorphs, isMixedAU, isPresetCompatible, mergeRegionsByName as mergeCharacterRegionsByName, resolveBoneName, resolveBoneNames, resolveFaceCenter, resolvePreset, resolvePresetWithOverrides, suggestBestPreset, validateMappingConfig, validateMappings };
|
|
7602
7647
|
//# sourceMappingURL=index.js.map
|
|
7603
7648
|
//# sourceMappingURL=index.js.map
|