stay aligned fixes (#1447)

This commit is contained in:
lucas lelievre authored and GitHub committed 2025-05-28 03:45:37 +02:00
1 parent 419841d9f9
commit 37553ea889
9 files changed
+43 -21

No files matched your search

+3 -3
View File
@@ -1263,13 +1263,13 @@ onboarding-stay_aligned-preparation-title = Preparation
onboarding-stay_aligned-preparation-tip = Make sure to stand upright. You must be looking forward and your arms must be down to your sides.
onboarding-stay_aligned-relaxed_poses-standing-title = Relaxed Standing Pose
onboarding-stay_aligned-relaxed_poses-standing-step-0 = 1. Stand in a comfortable position. Relax!
onboarding-stay_aligned-relaxed_poses-standing-step-2 = 3. Press the "Detect pose" button.
onboarding-stay_aligned-relaxed_poses-standing-step-2 = 3. Press the "Save pose" button.
onboarding-stay_aligned-relaxed_poses-sitting-title = Relaxed Sitting in Chair Pose
onboarding-stay_aligned-relaxed_poses-sitting-step-0 = 1. Sit in a comfortable position. Relax!
onboarding-stay_aligned-relaxed_poses-sitting-step-2 = 3. Press the "Detect pose" button.
onboarding-stay_aligned-relaxed_poses-sitting-step-2 = 3. Press the "Save pose" button.
onboarding-stay_aligned-relaxed_poses-flat-title = Relaxed Sitting on Floor Pose
onboarding-stay_aligned-relaxed_poses-flat-step-0 = 1. Sit on the floor with your legs in front. Relax!
onboarding-stay_aligned-relaxed_poses-flat-step-2 = 3. Press the "Detect pose" button.
onboarding-stay_aligned-relaxed_poses-flat-step-2 = 3. Press the "Save pose" button.
onboarding-stay_aligned-relaxed_poses-skip_step = Skip
onboarding-stay_aligned-done-title = Stay Aligned enabled!
onboarding-stay_aligned-done-description = Your Stay Aligned setup is complete!
@@ -203,7 +203,7 @@ export function StayAlignedSetup() {
position: new Vector3(3, 2.5, -3),
onHeightChange(v, newHeight) {
v.controls.target.set(0, newHeight / 2, 0);
const scale = Math.max(1.8, newHeight) / 1.8;
const scale = Math.max(1, newHeight) / 1.5;
v.camera.zoom = 1 / scale;
},
});
@@ -217,7 +217,7 @@ export function StayAlignedSetup() {
position: new Vector3(3, 2.5, -3),
onHeightChange(v, newHeight) {
v.controls.target.set(0, newHeight / 2, 0);
const scale = Math.max(1.8, newHeight) / 1.8;
const scale = Math.max(1, newHeight) / 1.5;
v.camera.zoom = 1 / scale;
},
});
@@ -5,7 +5,7 @@ import { Localized } from '@fluent/react';
export function DoneStep({ goTo }: VerticalStepComponentProps) {
return (
<div className="flex flex-col items-center w-full justify-center gap-5 pt-2">
<div className="flex flex-col items-center w-full justify-center gap-5 py-2">
<div className="flex gap-1 flex-col justify-center items-center pt-10">
<Localized id="onboarding-stay_aligned-done-description">
<Typography variant="main-title"></Typography>
@@ -13,7 +13,7 @@ export function PreparationStep({
prevStep,
}: VerticalStepComponentProps) {
return (
<div className="flex flex-col flex-grow justify-between pt-2 gap-2">
<div className="flex flex-col flex-grow justify-between py-2 gap-2">
<div className="flex flex-col gap-1">
<Localized id="onboarding-automatic_mounting-preparation-v2-step-0">
<Typography color="secondary"></Typography>
@@ -14,7 +14,7 @@ export function PutTrackersOnStep({ nextStep }: VerticalStepComponentProps) {
const canContinue = assignedTrackers.length >= 5 || import.meta.env.DEV;
return (
<div className="flex flex-col w-full pt-2">
<div className="flex flex-col w-full py-2">
<div className="flex flex-col flex-grow gap-2">
<div className="flex flex-grow flex-col gap-4">
<div>
@@ -27,7 +27,7 @@ function PosePage({
const { l10n } = useLocalization();
const { sendRPCPacket } = useWebsocketAPI();
return (
<div className="flex flex-col pt-2">
<div className="flex flex-col py-2">
<div className="flex flex-col gap-2">
{descriptionKeys.map((descriptionKey) => (
<Typography color="secondary">
@@ -8,7 +8,7 @@ export function VerifyMountingStep({
prevStep,
}: VerticalStepComponentProps) {
return (
<div className="flex flex-grow flex-col gap-4">
<div className="flex flex-grow flex-col gap-4 py-2">
<div className="flex flex-col gap-2">
<Localized id="onboarding-stay_aligned-verify_mounting-step-0">
<Typography color="secondary" />
@@ -33,6 +33,7 @@ export function VerifyMountingStep({
<Button
variant={'secondary'}
to="/onboarding/mounting/choose"
state={{ alonePage: true }}
></Button>
</Localized>
<Localized id="onboarding-stay_aligned-next_step">
@@ -112,13 +112,15 @@ Flat: ${config.flatEnabled ? `Enabled (upper_leg=${numberFormat.format(config.fl
TRACKERS
========
${trackers.map((t) => {
const info = t.tracker.info;
const stayAligned = t.tracker.stayAligned;
if (info && stayAligned) {
return `${bodypartToString(info.bodyPart)}: correction=${numberFormat.format(stayAligned.yawCorrectionInDeg)} locked=${stayAligned.locked ? `true locked_error=${numberFormat.format(stayAligned.lockedErrorInDeg)}` : 'false'} center_error=${numberFormat.format(stayAligned.centerErrorInDeg)} neighbor_error=${numberFormat.format(stayAligned.neighborErrorInDeg)}`;
}
})}
${trackers
.map((t) => {
const info = t.tracker.info;
const stayAligned = t.tracker.stayAligned;
if (info && stayAligned) {
return `${bodypartToString(info.bodyPart)}: correction=${numberFormat.format(stayAligned.yawCorrectionInDeg)} locked=${stayAligned.locked ? `true locked_error=${numberFormat.format(stayAligned.lockedErrorInDeg)}` : 'false'} center_error=${numberFormat.format(stayAligned.centerErrorInDeg)} neighbor_error=${numberFormat.format(stayAligned.neighborErrorInDeg)}`;
}
})
.join('\n')}
OTHER
=====
@@ -130,6 +130,7 @@ function initializePreview(
scene.add(skeleton[0]);
let heightOffset = 0;
let skeletonOffset = 0;
const rebuildSkeleton = (
newSkeleton: (BoneKind | THREE.Bone)[],
@@ -168,7 +169,20 @@ function initializePreview(
skeletonGroup.rotation.setFromQuaternion(yawReset);
};
const computeHeight = (bones: Map<BodyPart, BoneT>) => {
const computeUserHeight = (bones: Map<BodyPart, BoneT>) => {
const hmd = bones.get(BodyPart.HEAD);
if (hmd?.headPositionG?.y && hmd.headPositionG.y > 0) {
return hmd.headPositionG.y / 0.936;
}
const yLength = Y_PARTS.map((x) => bones.get(x));
if (yLength.some((x) => x === undefined)) return 0;
return (
(yLength as BoneT[]).reduce((prev, cur) => prev + cur.boneLength, 0) /
0.936
);
};
const computeSkeletonOffset = (bones: Map<BodyPart, BoneT>) => {
const hmd = bones.get(BodyPart.HEAD);
// If I know the head position, don't use an offset
if (hmd?.headPositionG?.y !== undefined && hmd.headPositionG?.y > 0) {
@@ -246,14 +260,19 @@ function initializePreview(
skeleton.forEach(
(bone) => bone instanceof BoneKind && bone.updateData(bones)
);
const newHeight = computeHeight(bones);
const newHeight = computeUserHeight(bones);
if (newHeight !== heightOffset) {
heightOffset = newHeight;
skeletonGroup.position.set(0, heightOffset, 0);
views.forEach((v) => {
v.onHeightChange(v, heightOffset);
});
}
const newSkeletinOffset = computeSkeletonOffset(bones);
if (newSkeletinOffset != skeletonOffset) {
skeletonOffset = newSkeletinOffset;
skeletonGroup.position.set(0, skeletonOffset, 0);
}
},
destroy: () => {
skeletonHelper.dispose();
@@ -419,7 +438,7 @@ export function SkeletonVisualizerWidget({
position: new THREE.Vector3(3, 2.5, -3),
onHeightChange(v, newHeight) {
v.controls.target.set(0, newHeight / 2, 0);
const scale = Math.max(1.8, newHeight) / 1.8;
const scale = Math.max(1, newHeight) / 1.5;
v.camera.zoom = 1 / scale;
},
});