Official 3D Example · crates/gpux-3d (gpux::three)
Skeletal Skinning & Additive Animation Blending
使用 gpux::three 复刻经典 Three.js webgl_animation_skinning_additive_blending 骨骼蒙皮与叠加姿态混合案例。支持基础动作平滑 Crossfade 过渡与多通道 Additive 姿态实时叠加。
cargo run -p skinning-additive-blending --features gpui-window
Rust · Declarative Rig & Additive Clip Layering (gpux::three)
use gpux::three::prelude::*;
let mut skeleton = Skeleton::humanoid_xbot();
let mut mixer = AnimationMixer::new();
// 1. Register Base Actions (Normal Blend Mode)
mixer.add_action(walk_clip, 1.0);
mixer.add_action(idle_clip, 0.0);
mixer.add_action(run_clip, 0.0);
// 2. Layer Additive Poses (`AnimationBlendMode::Additive`)
let sneak_pose = AnimationClip::new(
"sneak_pose",
1.0,
AnimationBlendMode::Additive,
vec![
BoneTrack::new("Hips", vec![
BoneKeyframe::new(0.0, Quat::IDENTITY, Vec3::new(0.0, -0.14, 0.0)),
]),
BoneTrack::new("Spine", vec![
BoneKeyframe::new(0.0, Quat::from_axis_angle(Vec3::X, 0.42), Vec3::ZERO),
]),
],
);
mixer.add_action(sneak_pose, 0.35);
mixer.add_action(agree_clip, 0.25);
// 3. Advance mixer & project 3D scene onto GPUI canvas
mixer.update(dt_seconds, &mut skeleton);
let frame = renderer.render_scene(&scene, &Camera::Perspective(camera));
Why `gpux::three` for Rust 3D + Native Apps?
// Compared to raw wgpu boilerplate or fragmented crates:
//
// ✓ Familiar Three.js Mental Model:
// Scene, Mesh, Group, Geometry, PbrMaterial, PerspectiveCamera,
// OrbitControls, Raycaster, Skeleton, AnimationMixer
//
// ✓ First-Class Skeletal Additive Blending:
// Normalized base-pose slerp crossfading + quaternion delta
// layering (`Quat::IDENTITY.slerp(delta_rot, weight)`)
//
// ✓ Zero WebView Overhead:
// Runs inside the same GPUI surface as your native
// buttons, docks, and telemetry tables across 8 platforms.