@lovelace_lol/embody 0.0.4 → 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 +0 -227
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +1 -224
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +0 -227
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -224
- package/dist/index.js.map +1 -1
- package/dist/three.cjs.map +1 -1
- package/dist/three.js.map +1 -1
- 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");
|
|
@@ -4304,179 +4294,6 @@ var WasmRuntimeCore = class {
|
|
|
4304
4294
|
this.core.configure_with_profile(JSON.stringify(this.profile), JSON.stringify(this.model));
|
|
4305
4295
|
}
|
|
4306
4296
|
};
|
|
4307
|
-
function compileMorphBindings(profile, model) {
|
|
4308
|
-
const auRows = [];
|
|
4309
|
-
const mixed = [];
|
|
4310
|
-
for (const [auIdText, entry] of Object.entries(profile.auToMorphs || {})) {
|
|
4311
|
-
const auId = Number(auIdText);
|
|
4312
|
-
if (Number.isNaN(auId) || !entry) continue;
|
|
4313
|
-
const meshNames = getMeshNamesForAUProfile(profile, auId);
|
|
4314
|
-
const hasMorphs = !!(entry.left?.length || entry.right?.length || entry.center?.length);
|
|
4315
|
-
if (hasMorphs && profile.auToBones?.[auId]?.length) {
|
|
4316
|
-
mixed.push(auId);
|
|
4317
|
-
}
|
|
4318
|
-
pushAuSide(auRows, auId, 0, entry.left || [], meshNames, model, profile);
|
|
4319
|
-
pushAuSide(auRows, auId, 1, entry.right || [], meshNames, model, profile);
|
|
4320
|
-
pushAuSide(auRows, auId, 2, entry.center || [], meshNames, model, profile);
|
|
4321
|
-
}
|
|
4322
|
-
const visemeRows = [];
|
|
4323
|
-
const visemeMeshNames = getMeshNamesForVisemeProfile(profile);
|
|
4324
|
-
const slotCount = getProfileVisemeSlots(profile).length;
|
|
4325
|
-
for (let index = 0; index < slotCount; index += 1) {
|
|
4326
|
-
for (const bindingTarget of getVisemeBindingTargets(profile, index)) {
|
|
4327
|
-
for (const resolved of resolveMorphTargets(model, profile, bindingTarget.morph, visemeMeshNames)) {
|
|
4328
|
-
visemeRows.push(
|
|
4329
|
-
index,
|
|
4330
|
-
Number(resolved.mesh.id),
|
|
4331
|
-
Number(resolved.morphTarget.id),
|
|
4332
|
-
bindingTarget.weight
|
|
4333
|
-
);
|
|
4334
|
-
}
|
|
4335
|
-
}
|
|
4336
|
-
}
|
|
4337
|
-
return {
|
|
4338
|
-
auBindings: Float32Array.from(auRows),
|
|
4339
|
-
visemeBindings: Float32Array.from(visemeRows),
|
|
4340
|
-
mixedAus: Uint32Array.from(mixed)
|
|
4341
|
-
};
|
|
4342
|
-
}
|
|
4343
|
-
function compileBoneBindings(profile, model) {
|
|
4344
|
-
const referencedBones = /* @__PURE__ */ new Map();
|
|
4345
|
-
const findBone = (nodeKey) => {
|
|
4346
|
-
const bone = findBoneDescriptor(profile, model, nodeKey);
|
|
4347
|
-
if (bone) referencedBones.set(bone.id, bone);
|
|
4348
|
-
return bone;
|
|
4349
|
-
};
|
|
4350
|
-
const boneSideForAU = (auId, nodeKey) => {
|
|
4351
|
-
const side = profile.auToBones?.[auId]?.find((candidate) => candidate.node === nodeKey)?.side;
|
|
4352
|
-
if (side === "left") return BONE_SIDE_LEFT;
|
|
4353
|
-
if (side === "right") return BONE_SIDE_RIGHT;
|
|
4354
|
-
return BONE_SIDE_NONE;
|
|
4355
|
-
};
|
|
4356
|
-
const compositeRows = [];
|
|
4357
|
-
for (const composite of profile.compositeRotations || []) {
|
|
4358
|
-
const bone = findBone(composite.node);
|
|
4359
|
-
if (!bone) continue;
|
|
4360
|
-
const axes = [
|
|
4361
|
-
{ axis: 1, config: composite.yaw },
|
|
4362
|
-
{ axis: 0, config: composite.pitch },
|
|
4363
|
-
{ axis: 2, config: composite.roll }
|
|
4364
|
-
];
|
|
4365
|
-
for (const { axis, config } of axes) {
|
|
4366
|
-
if (!config) continue;
|
|
4367
|
-
const negativeAUs = toAUList(config.negative);
|
|
4368
|
-
const positiveAUs = toAUList(config.positive);
|
|
4369
|
-
const hasDirectional = negativeAUs.length > 0 && positiveAUs.length > 0;
|
|
4370
|
-
const valueRows = [];
|
|
4371
|
-
if (hasDirectional) {
|
|
4372
|
-
for (const auId of negativeAUs) {
|
|
4373
|
-
valueRows.push([auId, AXIS_GROUP_NEGATIVE, boneSideForAU(auId, composite.node)]);
|
|
4374
|
-
}
|
|
4375
|
-
for (const auId of positiveAUs) {
|
|
4376
|
-
valueRows.push([auId, AXIS_GROUP_POSITIVE, boneSideForAU(auId, composite.node)]);
|
|
4377
|
-
}
|
|
4378
|
-
} else {
|
|
4379
|
-
for (const auId of config.aus) {
|
|
4380
|
-
valueRows.push([auId, AXIS_GROUP_PLAIN, boneSideForAU(auId, composite.node)]);
|
|
4381
|
-
}
|
|
4382
|
-
}
|
|
4383
|
-
const bindingRows = [];
|
|
4384
|
-
const pushBindingRows = (auIds, group) => {
|
|
4385
|
-
for (const auId of auIds) {
|
|
4386
|
-
const binding = profile.auToBones?.[auId]?.find(
|
|
4387
|
-
(candidate) => candidate.node === composite.node
|
|
4388
|
-
);
|
|
4389
|
-
if (!binding?.maxDegrees) continue;
|
|
4390
|
-
const channel = ROTATION_CHANNELS[binding.channel];
|
|
4391
|
-
if (channel === void 0) continue;
|
|
4392
|
-
bindingRows.push([
|
|
4393
|
-
auId,
|
|
4394
|
-
group,
|
|
4395
|
-
boneSideForAU(auId, composite.node),
|
|
4396
|
-
channel,
|
|
4397
|
-
binding.scale,
|
|
4398
|
-
binding.maxDegrees
|
|
4399
|
-
]);
|
|
4400
|
-
}
|
|
4401
|
-
};
|
|
4402
|
-
pushBindingRows(negativeAUs, AXIS_GROUP_NEGATIVE);
|
|
4403
|
-
pushBindingRows(positiveAUs, AXIS_GROUP_POSITIVE);
|
|
4404
|
-
pushBindingRows(config.aus, AXIS_GROUP_PLAIN);
|
|
4405
|
-
compositeRows.push(
|
|
4406
|
-
Number(bone.id),
|
|
4407
|
-
axis,
|
|
4408
|
-
hasDirectional ? 1 : 0,
|
|
4409
|
-
valueRows.length,
|
|
4410
|
-
bindingRows.length,
|
|
4411
|
-
0,
|
|
4412
|
-
0,
|
|
4413
|
-
0
|
|
4414
|
-
);
|
|
4415
|
-
for (const row of valueRows) compositeRows.push(...row);
|
|
4416
|
-
for (const row of bindingRows) compositeRows.push(...row);
|
|
4417
|
-
}
|
|
4418
|
-
}
|
|
4419
|
-
const translationRows = [];
|
|
4420
|
-
for (const [auIdText, bindings] of Object.entries(profile.auToBones || {})) {
|
|
4421
|
-
const auId = Number(auIdText);
|
|
4422
|
-
if (Number.isNaN(auId)) continue;
|
|
4423
|
-
for (const binding of bindings || []) {
|
|
4424
|
-
const channel = TRANSLATION_CHANNELS[binding.channel];
|
|
4425
|
-
if (channel === void 0 || binding.maxUnits === void 0) continue;
|
|
4426
|
-
const bone = findBone(binding.node);
|
|
4427
|
-
if (!bone) continue;
|
|
4428
|
-
translationRows.push(auId, Number(bone.id), channel, binding.scale, binding.maxUnits);
|
|
4429
|
-
}
|
|
4430
|
-
}
|
|
4431
|
-
const jawRow = [];
|
|
4432
|
-
const jawBinding = findAutoVisemeJawBinding(profile, model);
|
|
4433
|
-
if (jawBinding?.maxDegrees) {
|
|
4434
|
-
const bone = findBone(jawBinding.node);
|
|
4435
|
-
const channel = ROTATION_CHANNELS[jawBinding.channel];
|
|
4436
|
-
if (bone && channel !== void 0) {
|
|
4437
|
-
jawRow.push(Number(bone.id), channel, jawBinding.scale, jawBinding.maxDegrees);
|
|
4438
|
-
}
|
|
4439
|
-
}
|
|
4440
|
-
const restRows = [];
|
|
4441
|
-
for (const bone of referencedBones.values()) {
|
|
4442
|
-
const position = bone.restTransform?.position;
|
|
4443
|
-
const rotation = bone.restTransform?.rotation;
|
|
4444
|
-
restRows.push(
|
|
4445
|
-
Number(bone.id),
|
|
4446
|
-
position?.x ?? 0,
|
|
4447
|
-
position?.y ?? 0,
|
|
4448
|
-
position?.z ?? 0,
|
|
4449
|
-
rotation?.x ?? 0,
|
|
4450
|
-
rotation?.y ?? 0,
|
|
4451
|
-
rotation?.z ?? 0,
|
|
4452
|
-
rotation?.w ?? 1
|
|
4453
|
-
);
|
|
4454
|
-
}
|
|
4455
|
-
return {
|
|
4456
|
-
restTransforms: Float32Array.from(restRows),
|
|
4457
|
-
compositeAxes: Float32Array.from(compositeRows),
|
|
4458
|
-
translations: Float32Array.from(translationRows),
|
|
4459
|
-
jawBinding: Float32Array.from(jawRow),
|
|
4460
|
-
visemeJawAmounts: Float32Array.from(getVisemeJawAmounts(profile) ?? [])
|
|
4461
|
-
};
|
|
4462
|
-
}
|
|
4463
|
-
function findBoneDescriptor(profile, model, nodeKey) {
|
|
4464
|
-
const configuredName = profile.boneNodes?.[nodeKey] || nodeKey;
|
|
4465
|
-
const prefix = profile.bonePrefix ?? "";
|
|
4466
|
-
const suffix = profile.boneSuffix ?? "";
|
|
4467
|
-
const prefixedName = prefix && !configuredName.startsWith(prefix) ? `${prefix}${configuredName}` : configuredName;
|
|
4468
|
-
const fullName = suffix && !prefixedName.endsWith(suffix) ? `${prefixedName}${suffix}` : prefixedName;
|
|
4469
|
-
const candidates = /* @__PURE__ */ new Set([nodeKey, configuredName, fullName]);
|
|
4470
|
-
return model.bones.find((bone) => candidates.has(bone.name));
|
|
4471
|
-
}
|
|
4472
|
-
function findAutoVisemeJawBinding(profile, model) {
|
|
4473
|
-
const isRotation = (binding) => binding?.channel === "rx" || binding?.channel === "ry" || binding?.channel === "rz";
|
|
4474
|
-
const candidates = [
|
|
4475
|
-
profile.auToBones?.[103]?.find(isRotation),
|
|
4476
|
-
profile.auToBones?.[26]?.find(isRotation)
|
|
4477
|
-
].filter((binding) => !!binding);
|
|
4478
|
-
return candidates.find((binding) => !!findBoneDescriptor(profile, model, binding.node)) ?? candidates[0] ?? null;
|
|
4479
|
-
}
|
|
4480
4297
|
function unpackBoneFrameDelta(values) {
|
|
4481
4298
|
const stride = PACKED_BONE_FRAME_DELTA_STRIDE;
|
|
4482
4299
|
const writes = [];
|
|
@@ -4517,46 +4334,6 @@ function unpackMorphFrameDelta(values) {
|
|
|
4517
4334
|
}
|
|
4518
4335
|
return writes;
|
|
4519
4336
|
}
|
|
4520
|
-
function pushAuSide(rows, auId, side, morphs, meshNames, model, profile) {
|
|
4521
|
-
for (const morph of morphs) {
|
|
4522
|
-
for (const resolved of resolveMorphTargets(model, profile, morph, meshNames)) {
|
|
4523
|
-
rows.push(
|
|
4524
|
-
auId,
|
|
4525
|
-
side,
|
|
4526
|
-
Number(resolved.mesh.id),
|
|
4527
|
-
Number(resolved.morphTarget.id),
|
|
4528
|
-
1
|
|
4529
|
-
);
|
|
4530
|
-
}
|
|
4531
|
-
}
|
|
4532
|
-
}
|
|
4533
|
-
function resolveMorphTargets(model, profile, morph, meshNames) {
|
|
4534
|
-
const result = [];
|
|
4535
|
-
for (const meshName of meshNames) {
|
|
4536
|
-
const mesh = model.meshes.find((candidate) => candidate.name === meshName);
|
|
4537
|
-
if (!mesh) continue;
|
|
4538
|
-
const morphTargets = mesh.morphTargetIds.map((id) => model.morphTargets.find((candidate) => candidate.id === id)).filter((target2) => !!target2);
|
|
4539
|
-
const target = typeof morph === "number" ? morphTargets.find((candidate) => candidate.hostIndex === morph) : resolveMorphTargetByName2(morphTargets, morph, profile);
|
|
4540
|
-
if (target) {
|
|
4541
|
-
result.push({ mesh, morphTarget: target });
|
|
4542
|
-
}
|
|
4543
|
-
}
|
|
4544
|
-
return result;
|
|
4545
|
-
}
|
|
4546
|
-
function resolveMorphTargetByName2(targets, key, profile) {
|
|
4547
|
-
const prefix = profile.morphPrefix || "";
|
|
4548
|
-
const suffix = profile.morphSuffix || "";
|
|
4549
|
-
const fullName = prefix + key + suffix;
|
|
4550
|
-
const exact = targets.find((target) => target.name === fullName);
|
|
4551
|
-
if (exact) return exact;
|
|
4552
|
-
const suffixRegex = profile.suffixPattern ? new RegExp(profile.suffixPattern) : null;
|
|
4553
|
-
if (!suffixRegex) return void 0;
|
|
4554
|
-
return targets.find((target) => {
|
|
4555
|
-
if (!target.name.startsWith(fullName)) return false;
|
|
4556
|
-
const candidateSuffix = target.name.slice(fullName.length);
|
|
4557
|
-
return candidateSuffix === "" || suffixRegex.test(candidateSuffix);
|
|
4558
|
-
});
|
|
4559
|
-
}
|
|
4560
4337
|
|
|
4561
4338
|
// src/hair/appearance.ts
|
|
4562
4339
|
var HAIR_COLOR_PRESETS = {
|
|
@@ -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;
|