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
R3F27: an edit drawing R3F plays live on React
shinyobjectz4b1686f2540c
diff --git a/apps/game/src/export.rs b/apps/game/src/export.rsindex 1a9b60ee..37ba8fd0 100644--- a/apps/game/src/export.rs+++ b/apps/game/src/export.rs@@ -88,7 +88,10 @@ pub fn export(args: &[String]) -> R<String> {opts.push(p.display().to_string());}}- opts.push("--lite".into());+ // on live play's runtime, or React for an edit drawing R3F (raea_runtime_live::needs_react)+ if !raea_runtime_live::needs_react(&dir) {+ opts.push("--lite".into());+ }let js = game.join("bundle.js");raea_runtime_react::scene::bundle_composition(&tsx, &js, &raea_runtime_react::scene::comp_opts(&opts)?, Some(&game))?;diff --git a/runtime/live/src/lib.rs b/runtime/live/src/lib.rsindex 70cf264b..93bfc77d 100644--- a/runtime/live/src/lib.rs+++ b/runtime/live/src/lib.rs@@ -317,6 +317,29 @@ fn components_use_config(dir: &Path) -> bool {std::fs::read_dir(dir.join("components")).into_iter().flatten().flatten().any(|e| std::fs::read_to_string(e.path()).is_ok_and(|t| t.contains("useVideoConfig(")))}+/// Whether the edit's own sources (its folder, not node_modules) import React Three Fiber (`raea/r3f`,+/// `@react-three/...`): R3F runs a reconciler of its own on React, which live play's runtime (sdk/react/js/lite) isn't,+/// so such a play keeps React, as RAEA_LIVE_REACT=1 does (docs/r3f.feature R3F27)+pub fn needs_react(dir: &Path) -> bool {+ fn walk(d: &Path, depth: usize) -> bool {+ let Ok(rd) = std::fs::read_dir(d) else { return false };+ rd.flatten().any(|e| {+ let name = e.file_name();+ let name = name.to_string_lossy();+ let p = e.path();+ if name.starts_with('.') || name == "node_modules" || name == "target" {+ false+ } else if p.is_dir() {+ depth < 4 && walk(&p, depth + 1)+ } else {+ [".tsx", ".ts", ".jsx", ".js"].iter().any(|x| name.ends_with(x))+ && std::fs::read_to_string(&p).is_ok_and(|t| t.contains("raea/r3f") || t.contains("@react-three/"))+ }+ })+ }+ walk(dir, 0)+}+/// What a composition's sound is made of: its bundle and every file in its project (path, size, time), hashed, so a/// sound worked out from them (the mastered track) is found again until one of them changes.fn sound_key(js: &Path, dir: &Path) -> u64 {@@ -452,3 +475,20 @@ mod frame_event_tests {}}}++#[cfg(test)]+mod needs_react_tests {+ #[test]+ fn an_edit_importing_r3f_keeps_react_and_one_whose_packages_do_doesnt() {+ let d = std::env::temp_dir().join(format!("raea-needs-react-{}", std::process::id()));+ let _ = std::fs::remove_dir_all(&d);+ std::fs::create_dir_all(d.join("node_modules/drei")).unwrap();+ std::fs::write(d.join("edit.tsx"), "import { Composition } from \"raea\";").unwrap();+ std::fs::write(d.join("node_modules/drei/index.js"), "import \"@react-three/fiber\";").unwrap();+ assert!(!super::needs_react(&d));+ std::fs::create_dir_all(d.join("src/scene")).unwrap();+ std::fs::write(d.join("src/scene/ball.tsx"), "import { R3F } from \"raea/r3f\";").unwrap();+ assert!(super::needs_react(&d));+ let _ = std::fs::remove_dir_all(&d);+ }+}diff --git a/runtime/live/src/open.rs b/runtime/live/src/open.rsindex 9243636a..318a278d 100644--- a/runtime/live/src/open.rs+++ b/runtime/live/src/open.rs@@ -30,8 +30,8 @@ impl Live {}}// played live (a game: timelines play their bake), on raea's live view runtime instead of React: each frame- // rendered and only what changed sent (RAEA_LIVE_REACT=1 keeps React)- if std::env::var("RAEA_LIVE_REACT").as_deref() != Ok("1") {+ // rendered and only what changed sent (RAEA_LIVE_REACT=1 keeps React, as an edit drawing R3F does)+ if std::env::var("RAEA_LIVE_REACT").as_deref() != Ok("1") && !crate::needs_react(&dir) {opts.push("--lite".into());}raea_runtime_react::scene::bundle_composition(&tsx, &js, &raea_runtime_react::scene::comp_opts(&opts)?, None)?;