Skip to content

armgit / raea

Public Imported from GitHub
0

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.

CH20: a Character part may name the body's joints it has (a head has the neck, the head and the eyes), so a part with some of the joints is drawn; the generated head rides SOMA's body through a library walk with its expressions driven by name

shinyobjectzef46cab89fc7
diff --git a/sdk/character/src/character/drawing.tsx b/sdk/character/src/character/drawing.tsx
index 2011983e..41144d27 100644
--- a/sdk/character/src/character/drawing.tsx
+++ b/sdk/character/src/character/drawing.tsx
@@ -108,6 +108,9 @@ export interface CharacterProps extends Placement {
export interface CharacterPart {
/** its .glb */
src: string;
+ /** the body's joints its glTF has, when it has only some of them (a head: the neck, the head and the eyes); all of
+ * the body's by default, and the engine refuses a part that lacks one it is given */
+ joints?: string[];
/** its morph targets' weights by name (a kit part carries the body's weight-*, age-* and, for hair, face-*) */
morphs?: Record<string, number>;
/** its cloth: a baked simulation of its vertices in its bind pose and the frame drawn (<Model cloth>, docs/cloth.md) */
@@ -197,7 +200,7 @@ export function Character(props: CharacterProps) {
{(props.parts ?? []).map((part) => {
const id = part.src.split("/").pop()!.replace(/\.glb$/, "");
return (
- <Model key={id} name={`${name}-${id}`} src={part.src} bones={bones} scale={k} {...(glitch ? { glitch } : {})} {...pass} {...(part.morphs && Object.keys(part.morphs).length ? { morphs: part.morphs } : {})} {...(part.cloth ? { cloth: part.cloth } : {})}>
+ <Model key={id} name={`${name}-${id}`} src={part.src} bones={part.joints ? Object.fromEntries(part.joints.filter((j) => j in bones).map((j) => [j, bones[j]])) : bones} scale={k} {...(glitch ? { glitch } : {})} {...pass} {...(part.morphs && Object.keys(part.morphs).length ? { morphs: part.morphs } : {})} {...(part.cloth ? { cloth: part.cloth } : {})}>
{part.children}
{id.includes("hair") && props.hair !== false && hairMaterial(props.hair)}
</Model>