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.

Layer pass: a <Video> is a layer (docs/review.feature R2e; parked with the source stamps): Video and Audio pass their source stamps on to the element they draw (sdk/video media.tsx useMediaAttrs), and the page bridge keeps a video's KEPT data-raea props (runtime/page elements.rs dropped every data- prop of a video, its player's and the stamps alike). bench/layers: a 4 s test-pattern clip in the conformance composition, IoU 1.000 at all three moments; all 16 layers pass and the four mutants still fail.

shinyobjectzd1edca2817fa
diff --git a/bench/layers/conformance.tsx b/bench/layers/conformance.tsx
index b369854c..15652d32 100644
--- a/bench/layers/conformance.tsx
+++ b/bench/layers/conformance.tsx
@@ -2,7 +2,7 @@
// (hide one layer, render again, the pixels that change) where layers meet: a square drawn as a 3D mesh, as a React
// component (used twice) and as a page element, text, an image, a rotated element and a .map() list. The page is over
// the 3D, as a composition's always is. bench/layers/oracle.sh renders it.
-import { AbsoluteFill, Composition, Img, registerRoot, useCurrentFrame } from "raea";
+import { AbsoluteFill, Composition, Img, Video, registerRoot, useCurrentFrame } from "raea";
import { StandardMaterial } from "raea/pbr";
import { Cuboid, Mesh3d } from "raea/mesh";
import { DirectionalLight } from "raea/light";
@@ -35,6 +35,7 @@ const Shot = () => {
<div style={{ position: "absolute", left: 210, top: 210, width: 90, height: 90, background: "#ff6a00" }} />
<h1 style={{ position: "absolute", left: 24, top: 8, margin: 0, color: "#f4f4f4", fontSize: 30 }}>Layers</h1>
<Img src="pic.png" style={{ position: "absolute", left: 20, top: 300, width: 96, height: 64 }} />
+ <Video src="clip.mp4" muted style={{ position: "absolute", left: 140, top: 320, width: 120, height: 68 }} />
<div style={{ position: "absolute", left: 330, top: 300, width: 80, height: 40, background: "#8a5cf6", transform: `rotate(${20 + f}deg)` }} />
<ul style={{ position: "absolute", left: 20, top: 70, margin: 0, padding: 0, listStyle: "none" }}>
{["one", "two", "three"].map((t) => (
diff --git a/bench/layers/mutants.sh b/bench/layers/mutants.sh
index 84c96bfc..c2532ca6 100755
--- a/bench/layers/mutants.sh
+++ b/bench/layers/mutants.sh
@@ -9,7 +9,7 @@ OUT=${2:?OUT folder}
BIN=${RAEA_BIN:-$PWD/target/release/raea}
export RAEA_SIGN=0 RAEA_MARK=0 RAEA_EXPORT_CACHE=0 RAEA_SOURCE_STAMPS=1 RAEA_AUDIO_MUTE=1 RAEA_LAYERS=1
mkdir -p "$OUT/src"
-cp bench/layers/conformance.tsx bench/layers/badge.tsx "$ORACLE/src/pic.png" "$OUT/src/"
+cp bench/layers/conformance.tsx bench/layers/badge.tsx "$ORACLE/src/pic.png" "$ORACLE/src/clip.mp4" "$OUT/src/"
status=0
for m in none swap shift occlusion under; do
rm -rf "${OUT:?}/$m"
diff --git a/bench/layers/oracle.sh b/bench/layers/oracle.sh
index 18349a02..661902f5 100755
--- a/bench/layers/oracle.sh
+++ b/bench/layers/oracle.sh
@@ -14,6 +14,7 @@ MOMENTS=(10 45 80)
mkdir -p "$OUT/src"
cp bench/layers/conformance.tsx bench/layers/badge.tsx "$OUT/src/"
magick -size 96x64 gradient:'#ffd400-#ff2d55' "$OUT/src/pic.png"
+ffmpeg -v error -y -f lavfi -i testsrc=size=240x136:rate=30:duration=4 -pix_fmt yuv420p "$OUT/src/clip.mp4" || exit 2
read -r W H <<< "$(sed -n 's/.*width={\([0-9]*\)} height={\([0-9]*\)}.*/\1 \2/p' bench/layers/conformance.tsx)"
MW=$(( (W + 3) / 4 )); MH=$(( (H + 3) / 4 ))
@@ -25,7 +26,7 @@ B1=$(at conformance.tsx Badge 1); B2=$(at conformance.tsx Badge 2); LI=$(at conf
KEYS=(
"$(at conformance.tsx Mesh3d 1)" "$(at conformance.tsx Mesh3d 2)" "$(at conformance.tsx Mesh3d 3)"
"$(at badge.tsx div 1)|$B1" "$(at badge.tsx span 1)|$B1" "$(at badge.tsx div 1)|$B2" "$(at badge.tsx span 1)|$B2"
- "$(at conformance.tsx div 1)" "$(at conformance.tsx h1 1)" "$(at conformance.tsx Img 1)" "$(at conformance.tsx div 2)"
+ "$(at conformance.tsx div 1)" "$(at conformance.tsx h1 1)" "$(at conformance.tsx Img 1)" "$(at conformance.tsx Video 1)" "$(at conformance.tsx div 2)"
"$(at conformance.tsx ul 1)" "$LI#one" "$LI#two" "$LI#three"
)
: > "$OUT/keys.txt"
diff --git a/runtime/page/src/elements.rs b/runtime/page/src/elements.rs
index 8fcf7dfe..46ff7ecc 100644
--- a/runtime/page/src/elements.rs
+++ b/runtime/page/src/elements.rs
@@ -257,7 +257,8 @@ pub(crate) fn page_props(kind: &str, props: Option<&Map<String, Value>>, dir: &P
if k.starts_with("on") && k.chars().nth(2).is_some_and(|c| c.is_ascii_uppercase()) {
continue;
}
- if kind == "video" && (k == "src" || k.starts_with("data-")) {
+ // (a video's own data- props are its player's, the KEPT ones are the page's as any element's)
+ if kind == "video" && (k == "src" || (k.starts_with("data-") && !KEPT.contains(&k.as_str()))) {
continue;
}
if k == "style" {
diff --git a/sdk/video/src/media.tsx b/sdk/video/src/media.tsx
index 7bb401b4..f9f38249 100644
--- a/sdk/video/src/media.tsx
+++ b/sdk/video/src/media.tsx
@@ -154,6 +154,11 @@ function useMediaAttrs(owner: string, props: MediaProps, src = props.src as stri
// another by it, however many come and go around it
"data-from": origin,
};
+ // its source stamps (engine/bundle stamp.rs: where its JSX is written, its list key and uses), so the element it
+ // draws is selectable as its layer (docs/review.feature R2)
+ for (const [k, v] of Object.entries(props)) {
+ if (k.startsWith("data-raea-") && (typeof v === "string" || typeof v === "number")) attrs[k] = v;
+ }
return attrs;
}