Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
grab: a take's look turns the head and neck no more than 30 degrees together (LOOK_MOST); the eyes go the rest of the way. Each joint was capped at 55 on its own, up to 77 in all, and a cup held out at chest height bowed the taker's head onto it.
shinyobjectz977ec312aa09
diff --git a/systems/grab/src/lib.rs b/systems/grab/src/lib.rsindex 6eabc9f0..7ba05e70 100644--- a/systems/grab/src/lib.rs+++ b/systems/grab/src/lib.rs@@ -24,4 +24,4 @@ pub use interact::pick;pub use json::{TAKE_ANSWER, TAKE_ARGS, take_json};pub use raea_sys_body::json::{FIT_ANSWER, FIT_ARGS, HAND_ANSWER, HAND_ARGS, SOMA_ANSWER, SOMA_ARGS, TURNS_ANSWER, TURNS_ARGS, TWISTS_ARGS, fit_json, hand_json, soma_json, turns_json, twists_json};pub use take::{Frame, Key, Phase, Release, Take, perform};-pub use trunk::{clear, give_for, hand_points, look, own_solids, room, spread_for, stand_for, stoop, torso};+pub use trunk::{clear, give_for, hand_points, look, own_solids, room, spread_for, stand_for, stoop, torso, LOOK_MOST};diff --git a/systems/grab/src/trunk.rs b/systems/grab/src/trunk.rsindex d622b2b0..ec6c97e2 100644--- a/systems/grab/src/trunk.rs+++ b/systems/grab/src/trunk.rs@@ -142,17 +142,18 @@ pub fn stand_for(thing: &Thing, from: Vec3) -> (Vec3, f32) {(Vec3::new(at.x, from.y, at.z), (-to.x).atan2(-to.z))}-/// The head turned toward a place by `weight` (0 to 1): the neck takes two fifths of the turn and the head the rest,-/// no more than 55 degrees in all, so eyes go to what the hands are after.+/// Most the head and neck turn together to a place, degrees (55 a joint bowed a taker onto a cup); eyes do the rest.+pub const LOOK_MOST: f32 = 30.0;+/// The head turned toward a place by `weight` (0 to 1), `LOOK_MOST` at most: the neck two fifths, the head the rest.pub fn look(skel: &Skeleton, pose: &Pose, at: Vec3, weight: f32) -> Pose {let (Some(neck), Some(head)) = (skel.joint("neck_01"), skel.joint("head")) else { return pose.clone() };- let mut out = pose.clone();- for (joint, share) in [(neck, 0.4), (head, 1.0)] {+ let (mut out, mut most) = (pose.clone(), None);+ for (joint, share) in [(neck, 0.4), (head, 0.6)] {let w = skel.fk(&out);let Some(to) = (at - w.pos[head]).try_normalize() else { break };- let turn = Quat::from_rotation_arc(w.rot[head] * Vec3::Z, to);- let (axis, angle) = turn.to_axis_angle();- let angle = angle.min(55f32.to_radians()) * share * weight.clamp(0.0, 1.0);+ let (axis, angle) = Quat::from_rotation_arc(w.rot[head] * Vec3::Z, to).to_axis_angle();+ let most = *most.get_or_insert(angle.min(LOOK_MOST.to_radians()) * weight.clamp(0.0, 1.0));+ let angle = (most * share).min(angle);out.turns[joint] = skel.local_for(&w, joint, Quat::from_axis_angle(axis, angle) * w.rot[joint]);}outdiff --git a/systems/grab/tests/grab.rs b/systems/grab/tests/grab.rsindex 4d7dc0b3..2cccc1a2 100644--- a/systems/grab/tests/grab.rs+++ b/systems/grab/tests/grab.rs@@ -432,7 +432,7 @@ fn the_head_turns_to_the_thing_and_a_wrist_stops_at_its_limit() {let (w0, w) = (s.fk(&s.rest()), s.fk(&turned));let toward = |w: &Posed| (w.rot[head] * Vec3::Z).dot((at - w.pos[head]).normalize());assert!(toward(&w) > toward(&w0) + 0.3, "the head faces the thing more: {} from {}", toward(&w), toward(&w0));- assert!(w.rot[head].angle_between(w0.rot[head]).to_degrees() < 78.0);+ assert!(w.rot[head].angle_between(w0.rot[head]).to_degrees() < LOOK_MOST + 0.5, "a glance, not a bow");assert_eq!(look(&s, &s.rest(), at, 0.0), s.rest());// SOMA's twist joints: a forearm's follow its hand by rising shares; an upper arm's undo the shoulder's twistlet fore = twist_joints(Vec3::X, 0.0, 1.0, false);