@lovelace_lol/embody 0.0.3 → 0.0.5
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/dist/core/WasmRuntimeCore.d.ts +2 -24
- package/dist/core/index.d.ts +2 -2
- package/dist/core.cjs +2 -239
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +3 -236
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +14 -239
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +13 -236
- package/dist/index.js.map +1 -1
- package/dist/profiles/rustResolvedProfile.d.ts +31 -0
- package/dist/three.cjs +2 -233
- package/dist/three.cjs.map +1 -1
- package/dist/three.js +2 -233
- package/dist/three.js.map +1 -1
- package/dist/wasm/embody_wasm.d.ts +24 -10
- package/dist/wasm/embody_wasm.js +57 -0
- package/dist/wasm/embody_wasm_bg.wasm +0 -0
- package/dist/wasm/embody_wasm_bg.wasm.d.ts +12 -10
- package/dist/wasmTypes.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4229,16 +4229,6 @@ function positiveFiniteOr(value, fallback) {
|
|
|
4229
4229
|
}
|
|
4230
4230
|
|
|
4231
4231
|
// src/core/WasmRuntimeCore.ts
|
|
4232
|
-
var AU_MORPH_BINDING_STRIDE = 5;
|
|
4233
|
-
var VISEME_MORPH_BINDING_STRIDE = 4;
|
|
4234
|
-
var AXIS_GROUP_NEGATIVE = 0;
|
|
4235
|
-
var AXIS_GROUP_POSITIVE = 1;
|
|
4236
|
-
var AXIS_GROUP_PLAIN = 2;
|
|
4237
|
-
var BONE_SIDE_NONE = 0;
|
|
4238
|
-
var BONE_SIDE_LEFT = 1;
|
|
4239
|
-
var BONE_SIDE_RIGHT = 2;
|
|
4240
|
-
var ROTATION_CHANNELS = { rx: 0, ry: 1, rz: 2 };
|
|
4241
|
-
var TRANSLATION_CHANNELS = { tx: 0, ty: 1, tz: 2 };
|
|
4242
4232
|
var WasmRuntimeCore = class {
|
|
4243
4233
|
constructor(options) {
|
|
4244
4234
|
__publicField(this, "wasm");
|
|
@@ -4252,12 +4242,11 @@ var WasmRuntimeCore = class {
|
|
|
4252
4242
|
if (!RuntimeCtor) {
|
|
4253
4243
|
throw new Error("Embody Wasm module does not export RuntimeCore");
|
|
4254
4244
|
}
|
|
4255
|
-
this.core = new RuntimeCtor(
|
|
4245
|
+
this.core = new RuntimeCtor(0);
|
|
4256
4246
|
this.reloadBindings();
|
|
4257
4247
|
}
|
|
4258
4248
|
setProfile(profile) {
|
|
4259
4249
|
this.profile = profile;
|
|
4260
|
-
this.core.set_viseme_slot_count(getProfileVisemeSlots(profile).length);
|
|
4261
4250
|
this.reloadBindings();
|
|
4262
4251
|
}
|
|
4263
4252
|
setModelDescriptor(model) {
|
|
@@ -4302,191 +4291,9 @@ var WasmRuntimeCore = class {
|
|
|
4302
4291
|
};
|
|
4303
4292
|
}
|
|
4304
4293
|
reloadBindings() {
|
|
4305
|
-
|
|
4306
|
-
this.core.load_au_morph_bindings(auBindings);
|
|
4307
|
-
this.core.load_viseme_morph_bindings(visemeBindings);
|
|
4308
|
-
this.core.set_mixed_aus(mixedAus);
|
|
4309
|
-
const boneBindings = compileBoneBindings(this.profile, this.model);
|
|
4310
|
-
this.core.load_bone_rest_transforms(boneBindings.restTransforms);
|
|
4311
|
-
this.core.load_composite_axes(boneBindings.compositeAxes);
|
|
4312
|
-
this.core.load_bone_translations(boneBindings.translations);
|
|
4313
|
-
this.core.load_jaw_binding(boneBindings.jawBinding);
|
|
4314
|
-
this.core.load_viseme_jaw_amounts(boneBindings.visemeJawAmounts);
|
|
4294
|
+
this.core.configure_with_profile(JSON.stringify(this.profile), JSON.stringify(this.model));
|
|
4315
4295
|
}
|
|
4316
4296
|
};
|
|
4317
|
-
function compileMorphBindings(profile, model) {
|
|
4318
|
-
const auRows = [];
|
|
4319
|
-
const mixed = [];
|
|
4320
|
-
for (const [auIdText, entry] of Object.entries(profile.auToMorphs || {})) {
|
|
4321
|
-
const auId = Number(auIdText);
|
|
4322
|
-
if (Number.isNaN(auId) || !entry) continue;
|
|
4323
|
-
const meshNames = getMeshNamesForAUProfile(profile, auId);
|
|
4324
|
-
const hasMorphs = !!(entry.left?.length || entry.right?.length || entry.center?.length);
|
|
4325
|
-
if (hasMorphs && profile.auToBones?.[auId]?.length) {
|
|
4326
|
-
mixed.push(auId);
|
|
4327
|
-
}
|
|
4328
|
-
pushAuSide(auRows, auId, 0, entry.left || [], meshNames, model, profile);
|
|
4329
|
-
pushAuSide(auRows, auId, 1, entry.right || [], meshNames, model, profile);
|
|
4330
|
-
pushAuSide(auRows, auId, 2, entry.center || [], meshNames, model, profile);
|
|
4331
|
-
}
|
|
4332
|
-
const visemeRows = [];
|
|
4333
|
-
const visemeMeshNames = getMeshNamesForVisemeProfile(profile);
|
|
4334
|
-
const slotCount = getProfileVisemeSlots(profile).length;
|
|
4335
|
-
for (let index = 0; index < slotCount; index += 1) {
|
|
4336
|
-
for (const bindingTarget of getVisemeBindingTargets(profile, index)) {
|
|
4337
|
-
for (const resolved of resolveMorphTargets(model, profile, bindingTarget.morph, visemeMeshNames)) {
|
|
4338
|
-
visemeRows.push(
|
|
4339
|
-
index,
|
|
4340
|
-
Number(resolved.mesh.id),
|
|
4341
|
-
Number(resolved.morphTarget.id),
|
|
4342
|
-
bindingTarget.weight
|
|
4343
|
-
);
|
|
4344
|
-
}
|
|
4345
|
-
}
|
|
4346
|
-
}
|
|
4347
|
-
return {
|
|
4348
|
-
auBindings: Float32Array.from(auRows),
|
|
4349
|
-
visemeBindings: Float32Array.from(visemeRows),
|
|
4350
|
-
mixedAus: Uint32Array.from(mixed)
|
|
4351
|
-
};
|
|
4352
|
-
}
|
|
4353
|
-
function compileBoneBindings(profile, model) {
|
|
4354
|
-
const referencedBones = /* @__PURE__ */ new Map();
|
|
4355
|
-
const findBone = (nodeKey) => {
|
|
4356
|
-
const bone = findBoneDescriptor(profile, model, nodeKey);
|
|
4357
|
-
if (bone) referencedBones.set(bone.id, bone);
|
|
4358
|
-
return bone;
|
|
4359
|
-
};
|
|
4360
|
-
const boneSideForAU = (auId, nodeKey) => {
|
|
4361
|
-
const side = profile.auToBones?.[auId]?.find((candidate) => candidate.node === nodeKey)?.side;
|
|
4362
|
-
if (side === "left") return BONE_SIDE_LEFT;
|
|
4363
|
-
if (side === "right") return BONE_SIDE_RIGHT;
|
|
4364
|
-
return BONE_SIDE_NONE;
|
|
4365
|
-
};
|
|
4366
|
-
const compositeRows = [];
|
|
4367
|
-
for (const composite of profile.compositeRotations || []) {
|
|
4368
|
-
const bone = findBone(composite.node);
|
|
4369
|
-
if (!bone) continue;
|
|
4370
|
-
const axes = [
|
|
4371
|
-
{ axis: 1, config: composite.yaw },
|
|
4372
|
-
{ axis: 0, config: composite.pitch },
|
|
4373
|
-
{ axis: 2, config: composite.roll }
|
|
4374
|
-
];
|
|
4375
|
-
for (const { axis, config } of axes) {
|
|
4376
|
-
if (!config) continue;
|
|
4377
|
-
const negativeAUs = toAUList(config.negative);
|
|
4378
|
-
const positiveAUs = toAUList(config.positive);
|
|
4379
|
-
const hasDirectional = negativeAUs.length > 0 && positiveAUs.length > 0;
|
|
4380
|
-
const valueRows = [];
|
|
4381
|
-
if (hasDirectional) {
|
|
4382
|
-
for (const auId of negativeAUs) {
|
|
4383
|
-
valueRows.push([auId, AXIS_GROUP_NEGATIVE, boneSideForAU(auId, composite.node)]);
|
|
4384
|
-
}
|
|
4385
|
-
for (const auId of positiveAUs) {
|
|
4386
|
-
valueRows.push([auId, AXIS_GROUP_POSITIVE, boneSideForAU(auId, composite.node)]);
|
|
4387
|
-
}
|
|
4388
|
-
} else {
|
|
4389
|
-
for (const auId of config.aus) {
|
|
4390
|
-
valueRows.push([auId, AXIS_GROUP_PLAIN, boneSideForAU(auId, composite.node)]);
|
|
4391
|
-
}
|
|
4392
|
-
}
|
|
4393
|
-
const bindingRows = [];
|
|
4394
|
-
const pushBindingRows = (auIds, group) => {
|
|
4395
|
-
for (const auId of auIds) {
|
|
4396
|
-
const binding = profile.auToBones?.[auId]?.find(
|
|
4397
|
-
(candidate) => candidate.node === composite.node
|
|
4398
|
-
);
|
|
4399
|
-
if (!binding?.maxDegrees) continue;
|
|
4400
|
-
const channel = ROTATION_CHANNELS[binding.channel];
|
|
4401
|
-
if (channel === void 0) continue;
|
|
4402
|
-
bindingRows.push([
|
|
4403
|
-
auId,
|
|
4404
|
-
group,
|
|
4405
|
-
boneSideForAU(auId, composite.node),
|
|
4406
|
-
channel,
|
|
4407
|
-
binding.scale,
|
|
4408
|
-
binding.maxDegrees
|
|
4409
|
-
]);
|
|
4410
|
-
}
|
|
4411
|
-
};
|
|
4412
|
-
pushBindingRows(negativeAUs, AXIS_GROUP_NEGATIVE);
|
|
4413
|
-
pushBindingRows(positiveAUs, AXIS_GROUP_POSITIVE);
|
|
4414
|
-
pushBindingRows(config.aus, AXIS_GROUP_PLAIN);
|
|
4415
|
-
compositeRows.push(
|
|
4416
|
-
Number(bone.id),
|
|
4417
|
-
axis,
|
|
4418
|
-
hasDirectional ? 1 : 0,
|
|
4419
|
-
valueRows.length,
|
|
4420
|
-
bindingRows.length,
|
|
4421
|
-
0,
|
|
4422
|
-
0,
|
|
4423
|
-
0
|
|
4424
|
-
);
|
|
4425
|
-
for (const row of valueRows) compositeRows.push(...row);
|
|
4426
|
-
for (const row of bindingRows) compositeRows.push(...row);
|
|
4427
|
-
}
|
|
4428
|
-
}
|
|
4429
|
-
const translationRows = [];
|
|
4430
|
-
for (const [auIdText, bindings] of Object.entries(profile.auToBones || {})) {
|
|
4431
|
-
const auId = Number(auIdText);
|
|
4432
|
-
if (Number.isNaN(auId)) continue;
|
|
4433
|
-
for (const binding of bindings || []) {
|
|
4434
|
-
const channel = TRANSLATION_CHANNELS[binding.channel];
|
|
4435
|
-
if (channel === void 0 || binding.maxUnits === void 0) continue;
|
|
4436
|
-
const bone = findBone(binding.node);
|
|
4437
|
-
if (!bone) continue;
|
|
4438
|
-
translationRows.push(auId, Number(bone.id), channel, binding.scale, binding.maxUnits);
|
|
4439
|
-
}
|
|
4440
|
-
}
|
|
4441
|
-
const jawRow = [];
|
|
4442
|
-
const jawBinding = findAutoVisemeJawBinding(profile, model);
|
|
4443
|
-
if (jawBinding?.maxDegrees) {
|
|
4444
|
-
const bone = findBone(jawBinding.node);
|
|
4445
|
-
const channel = ROTATION_CHANNELS[jawBinding.channel];
|
|
4446
|
-
if (bone && channel !== void 0) {
|
|
4447
|
-
jawRow.push(Number(bone.id), channel, jawBinding.scale, jawBinding.maxDegrees);
|
|
4448
|
-
}
|
|
4449
|
-
}
|
|
4450
|
-
const restRows = [];
|
|
4451
|
-
for (const bone of referencedBones.values()) {
|
|
4452
|
-
const position = bone.restTransform?.position;
|
|
4453
|
-
const rotation = bone.restTransform?.rotation;
|
|
4454
|
-
restRows.push(
|
|
4455
|
-
Number(bone.id),
|
|
4456
|
-
position?.x ?? 0,
|
|
4457
|
-
position?.y ?? 0,
|
|
4458
|
-
position?.z ?? 0,
|
|
4459
|
-
rotation?.x ?? 0,
|
|
4460
|
-
rotation?.y ?? 0,
|
|
4461
|
-
rotation?.z ?? 0,
|
|
4462
|
-
rotation?.w ?? 1
|
|
4463
|
-
);
|
|
4464
|
-
}
|
|
4465
|
-
return {
|
|
4466
|
-
restTransforms: Float32Array.from(restRows),
|
|
4467
|
-
compositeAxes: Float32Array.from(compositeRows),
|
|
4468
|
-
translations: Float32Array.from(translationRows),
|
|
4469
|
-
jawBinding: Float32Array.from(jawRow),
|
|
4470
|
-
visemeJawAmounts: Float32Array.from(getVisemeJawAmounts(profile) ?? [])
|
|
4471
|
-
};
|
|
4472
|
-
}
|
|
4473
|
-
function findBoneDescriptor(profile, model, nodeKey) {
|
|
4474
|
-
const configuredName = profile.boneNodes?.[nodeKey] || nodeKey;
|
|
4475
|
-
const prefix = profile.bonePrefix ?? "";
|
|
4476
|
-
const suffix = profile.boneSuffix ?? "";
|
|
4477
|
-
const prefixedName = prefix && !configuredName.startsWith(prefix) ? `${prefix}${configuredName}` : configuredName;
|
|
4478
|
-
const fullName = suffix && !prefixedName.endsWith(suffix) ? `${prefixedName}${suffix}` : prefixedName;
|
|
4479
|
-
const candidates = /* @__PURE__ */ new Set([nodeKey, configuredName, fullName]);
|
|
4480
|
-
return model.bones.find((bone) => candidates.has(bone.name));
|
|
4481
|
-
}
|
|
4482
|
-
function findAutoVisemeJawBinding(profile, model) {
|
|
4483
|
-
const isRotation = (binding) => binding?.channel === "rx" || binding?.channel === "ry" || binding?.channel === "rz";
|
|
4484
|
-
const candidates = [
|
|
4485
|
-
profile.auToBones?.[103]?.find(isRotation),
|
|
4486
|
-
profile.auToBones?.[26]?.find(isRotation)
|
|
4487
|
-
].filter((binding) => !!binding);
|
|
4488
|
-
return candidates.find((binding) => !!findBoneDescriptor(profile, model, binding.node)) ?? candidates[0] ?? null;
|
|
4489
|
-
}
|
|
4490
4297
|
function unpackBoneFrameDelta(values) {
|
|
4491
4298
|
const stride = PACKED_BONE_FRAME_DELTA_STRIDE;
|
|
4492
4299
|
const writes = [];
|
|
@@ -4527,46 +4334,6 @@ function unpackMorphFrameDelta(values) {
|
|
|
4527
4334
|
}
|
|
4528
4335
|
return writes;
|
|
4529
4336
|
}
|
|
4530
|
-
function pushAuSide(rows, auId, side, morphs, meshNames, model, profile) {
|
|
4531
|
-
for (const morph of morphs) {
|
|
4532
|
-
for (const resolved of resolveMorphTargets(model, profile, morph, meshNames)) {
|
|
4533
|
-
rows.push(
|
|
4534
|
-
auId,
|
|
4535
|
-
side,
|
|
4536
|
-
Number(resolved.mesh.id),
|
|
4537
|
-
Number(resolved.morphTarget.id),
|
|
4538
|
-
1
|
|
4539
|
-
);
|
|
4540
|
-
}
|
|
4541
|
-
}
|
|
4542
|
-
}
|
|
4543
|
-
function resolveMorphTargets(model, profile, morph, meshNames) {
|
|
4544
|
-
const result = [];
|
|
4545
|
-
for (const meshName of meshNames) {
|
|
4546
|
-
const mesh = model.meshes.find((candidate) => candidate.name === meshName);
|
|
4547
|
-
if (!mesh) continue;
|
|
4548
|
-
const morphTargets = mesh.morphTargetIds.map((id) => model.morphTargets.find((candidate) => candidate.id === id)).filter((target2) => !!target2);
|
|
4549
|
-
const target = typeof morph === "number" ? morphTargets.find((candidate) => candidate.hostIndex === morph) : resolveMorphTargetByName2(morphTargets, morph, profile);
|
|
4550
|
-
if (target) {
|
|
4551
|
-
result.push({ mesh, morphTarget: target });
|
|
4552
|
-
}
|
|
4553
|
-
}
|
|
4554
|
-
return result;
|
|
4555
|
-
}
|
|
4556
|
-
function resolveMorphTargetByName2(targets, key, profile) {
|
|
4557
|
-
const prefix = profile.morphPrefix || "";
|
|
4558
|
-
const suffix = profile.morphSuffix || "";
|
|
4559
|
-
const fullName = prefix + key + suffix;
|
|
4560
|
-
const exact = targets.find((target) => target.name === fullName);
|
|
4561
|
-
if (exact) return exact;
|
|
4562
|
-
const suffixRegex = profile.suffixPattern ? new RegExp(profile.suffixPattern) : null;
|
|
4563
|
-
if (!suffixRegex) return void 0;
|
|
4564
|
-
return targets.find((target) => {
|
|
4565
|
-
if (!target.name.startsWith(fullName)) return false;
|
|
4566
|
-
const candidateSuffix = target.name.slice(fullName.length);
|
|
4567
|
-
return candidateSuffix === "" || suffixRegex.test(candidateSuffix);
|
|
4568
|
-
});
|
|
4569
|
-
}
|
|
4570
4337
|
|
|
4571
4338
|
// src/hair/appearance.ts
|
|
4572
4339
|
var HAIR_COLOR_PRESETS = {
|
|
@@ -10437,6 +10204,16 @@ var BLENDING_MODES = {
|
|
|
10437
10204
|
"None": 0
|
|
10438
10205
|
// THREE.NoBlending
|
|
10439
10206
|
};
|
|
10207
|
+
|
|
10208
|
+
// src/profiles/rustResolvedProfile.ts
|
|
10209
|
+
function resolveRustProfileView(wasm, profile) {
|
|
10210
|
+
return JSON.parse(wasm.resolve_profile_view(JSON.stringify(profile)));
|
|
10211
|
+
}
|
|
10212
|
+
function resolveRustEmbeddedProfileView(wasm, presetId, profileOverride = null) {
|
|
10213
|
+
return JSON.parse(
|
|
10214
|
+
wasm.resolve_embedded_profile_view(presetId, profileOverride ? JSON.stringify(profileOverride) : "")
|
|
10215
|
+
);
|
|
10216
|
+
}
|
|
10440
10217
|
var DEFAULT_HEAD_BONE_NAMES = ["CC_Base_Head", "Head", "head", "Bip01_Head"];
|
|
10441
10218
|
var DEFAULT_REFERENCE_HEIGHT = 1.8;
|
|
10442
10219
|
var DEFAULT_FORWARD_OFFSET = 0.08;
|
|
@@ -15254,7 +15031,6 @@ Object.defineProperty(exports, "resetEmbodyCoreForTests", {
|
|
|
15254
15031
|
exports.AU_INFO = AU_INFO;
|
|
15255
15032
|
exports.AU_MAPPING_CONFIG = AU_MAPPING_CONFIG;
|
|
15256
15033
|
exports.AU_MIX_DEFAULTS = AU_MIX_DEFAULTS;
|
|
15257
|
-
exports.AU_MORPH_BINDING_STRIDE = AU_MORPH_BINDING_STRIDE;
|
|
15258
15034
|
exports.AU_TO_MORPHS = AU_TO_MORPHS;
|
|
15259
15035
|
exports.AnimationController = ThreeAnimationSystem;
|
|
15260
15036
|
exports.BETTA_FISH_PRESET = BETTA_FISH_PRESET;
|
|
@@ -15315,7 +15091,6 @@ exports.TsClipCompiler = TsClipCompiler;
|
|
|
15315
15091
|
exports.TsRuntimeCore = TsRuntimeCore;
|
|
15316
15092
|
exports.VISEME_JAW_AMOUNTS = VISEME_JAW_AMOUNTS;
|
|
15317
15093
|
exports.VISEME_KEYS = VISEME_KEYS;
|
|
15318
|
-
exports.VISEME_MORPH_BINDING_STRIDE = VISEME_MORPH_BINDING_STRIDE;
|
|
15319
15094
|
exports.WasmRuntimeCore = WasmRuntimeCore;
|
|
15320
15095
|
exports.analyzeModel = analyzeModel;
|
|
15321
15096
|
exports.applyAUBoneBindingUpdate = applyAUBoneBindingUpdate;
|
|
@@ -15328,8 +15103,6 @@ exports.buildFrameApplierBindings = buildFrameApplierBindings;
|
|
|
15328
15103
|
exports.buildMappingEditorModel = buildMappingEditorModel;
|
|
15329
15104
|
exports.classifyAuAsJointControl = classifyAuAsJointControl;
|
|
15330
15105
|
exports.collectMorphMeshes = collectMorphMeshes2;
|
|
15331
|
-
exports.compileBoneBindings = compileBoneBindings;
|
|
15332
|
-
exports.compileMorphBindings = compileMorphBindings;
|
|
15333
15106
|
exports.compileVisemeKeys = compileVisemeKeys;
|
|
15334
15107
|
exports.composeTemplateSkeletonFitTransform = composeTemplateSkeletonFitTransform;
|
|
15335
15108
|
exports.computeCameraRelativeGazeOffset = computeCameraRelativeGazeOffset;
|
|
@@ -15417,6 +15190,8 @@ exports.resolvePresetWithOverrides = resolvePresetWithOverrides;
|
|
|
15417
15190
|
exports.resolveProfileFromPreset = resolveProfileFromPreset;
|
|
15418
15191
|
exports.resolveRegionCameraAngle = resolveRegionCameraAngle;
|
|
15419
15192
|
exports.resolveRegionVisibilityCameraAngle = resolveRegionVisibilityCameraAngle;
|
|
15193
|
+
exports.resolveRustEmbeddedProfileView = resolveRustEmbeddedProfileView;
|
|
15194
|
+
exports.resolveRustProfileView = resolveRustProfileView;
|
|
15420
15195
|
exports.resolveVisemeMeshCategory = resolveVisemeMeshCategory;
|
|
15421
15196
|
exports.stripConfiguredBoneAffixes = stripConfiguredBoneAffixes;
|
|
15422
15197
|
exports.suggestBestPreset = suggestBestPreset;
|