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.

PV3c: raea media lod, a model at a lower level of detail; the feature file says what is built

shinyobjectz1bed45b7742f
diff --git a/Cargo.lock b/Cargo.lock
index b74082ca..93a28e55 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -13640,6 +13640,7 @@ dependencies = [
name = "raea-app-media"
version = "0.1.0"
dependencies = [
+ "meshopt",
"raea-io-home",
"raea-io-media",
"raea-page",
@@ -14868,6 +14869,7 @@ dependencies = [
"raea-runtime-page",
"raea-runtime-react",
"raea-runtime-sound",
+ "raea-sys-frame",
"raea-sys-mix",
"serde_json",
"twox-hash",
diff --git a/apps/media/Cargo.toml b/apps/media/Cargo.toml
index 95d920af..6c0a8454 100644
--- a/apps/media/Cargo.toml
+++ b/apps/media/Cargo.toml
@@ -15,3 +15,5 @@ raea-runtime-encode = { path = "../../runtime/encode" }
raea-io-media = { path = "../../io/media", default-features = false }
raea-page = { path = "../../engine/page" }
serde_json = "1"
+# a model's lower levels of detail (lod.rs): the simplifier Bevy's meshlets use
+meshopt = "0.6.2"
diff --git a/apps/media/src/lib.rs b/apps/media/src/lib.rs
index c23f5807..292b8ede 100644
--- a/apps/media/src/lib.rs
+++ b/apps/media/src/lib.rs
@@ -10,6 +10,7 @@
//! raea media cuts FILE [--threshold 0.08] shot changes (ffmpeg's scene score)
//! raea media freezes FILE [--noise 0.001] [--min 2] held pictures (ffmpeg's freezedetect)
//! raea media proxy FILE [--height 720] -o OUT.mp4 a smaller copy
+//! raea media lod MODEL.glb [--level 1] [--texture 1024] -o OUT.glb a model at a lower level of detail (triangles halved a level)
//! raea media trim FILE --from S --to S -o OUT.mp4 a stretch, frame-exact (re-encoded)
//! raea media concat A B ... -o OUT.mp4 one after another (same aspect)
//! raea media encode --size WxH [--fps 60] [--quality Q] [--audio FILE] -o OUT.mp4 raw RGBA frames on stdin, signed
@@ -28,6 +29,8 @@ use serde_json::{Value, json};
// `raea media|ffmpeg|ffprobe|render|shots` as one in-process command line
mod command;
pub use command::command;
+/// a model at a lower level of detail (docs/preview.feature PV3c)
+mod lod;
mod probe;
use probe::*;
mod picture;
@@ -86,11 +89,11 @@ fn num(fl: &BTreeMap<String, String>, k: &str) -> R<Option<f64>> {
}
/// The verbs `raea media` answers here.
-pub const VERBS: &[&str] = &["probe", "still", "sheet", "audio", "loudness", "motion", "cuts", "freezes", "proxy", "trim", "concat", "encode", "help"];
+pub const VERBS: &[&str] = &["probe", "still", "sheet", "audio", "loudness", "motion", "cuts", "freezes", "proxy", "lod", "trim", "concat", "encode", "help"];
pub fn cli(args: &[String]) -> i32 {
let Some(verb) = args.first() else {
- println!("usage: raea media <probe|still|sheet|audio|loudness|motion|cuts|proxy|trim|concat|encode> FILE ... (raea media help)");
+ println!("usage: raea media <probe|still|sheet|audio|loudness|motion|cuts|proxy|lod|trim|concat|encode> FILE ... (raea media help)");
return 2;
};
let (pos, fl) = parse(&args[1..]);
@@ -158,6 +161,10 @@ fn run(verb: &str, pos: &[String], fl: &BTreeMap<String, String>) -> R<Option<Va
let (from, to) = range()?;
cuts(&file()?, th, from, to).map(|(v, _)| Some(v))
}
+ "lod" => {
+ let n = |k: &str, d: u32| fl.get(k).and_then(|v| v.parse().ok()).unwrap_or(d);
+ lod::lod(&file()?, n("level", 1), n("texture", 1024), &out()?).map(Some)
+ }
"proxy" => {
let h = fl.get("height").and_then(|h| h.parse().ok()).unwrap_or(720);
encode(&[(file()?, None, None)], Some(h), &out()?, fl.get("kbps").and_then(|k| k.parse().ok())).map(Some)
diff --git a/apps/media/src/lod.rs b/apps/media/src/lod.rs
new file mode 100644
index 00000000..23837529
--- /dev/null
+++ b/apps/media/src/lod.rs
@@ -0,0 +1,314 @@
+//! `raea media lod MODEL.glb [--level 1] [--texture 1024] -o OUT.glb`: a model at a lower level of detail
+//! (docs/preview.feature PV3c). Each level halves the triangles of every mesh (meshoptimizer's simplifier, on the
+//! mesh's own vertices, so skins, morph targets, UVs and materials are untouched: only the index lists are replaced)
+//! and its embedded pictures are made at most `--texture` px on their longer side. What nothing uses any more leaves
+//! the file. A .glb with its buffer inside it only: a .gltf's separate files are left to their own tools.
+
+use std::path::Path;
+
+use serde_json::json;
+
+use super::*;
+
+const GLB: u32 = 0x4654_6c67;
+const JSON: u32 = 0x4e4f_534a;
+const BIN: u32 = 0x004e_4942;
+
+/// The file's JSON and its binary chunk.
+fn read(path: &Path) -> R<(Value, Vec<u8>)> {
+ let b = std::fs::read(path).map_err(|e| format!("{}: {e}", path.display()))?;
+ let u32_at = |i: usize| b.get(i..i + 4).map(|s| u32::from_le_bytes(s.try_into().unwrap()));
+ if u32_at(0) != Some(GLB) {
+ return Err(format!("{}: not a .glb (raea media lod reads a binary glTF with its buffer inside it)", path.display()));
+ }
+ let (mut at, mut doc, mut bin) = (12usize, None, Vec::new());
+ while let (Some(len), Some(kind)) = (u32_at(at), u32_at(at + 4)) {
+ let body = b.get(at + 8..at + 8 + len as usize).ok_or("the glb's chunk runs past its end")?;
+ match kind {
+ JSON => doc = Some(serde_json::from_slice::<Value>(body).map_err(|e| format!("the glb's JSON: {e}"))?),
+ BIN if bin.is_empty() => bin = body.to_vec(),
+ _ => {}
+ }
+ at += 8 + len as usize;
+ }
+ Ok((doc.ok_or("the glb has no JSON chunk")?, bin))
+}
+
+fn write(path: &Path, doc: &Value, bin: &[u8]) -> R<()> {
+ let mut text = serde_json::to_vec(doc).map_err(|e| e.to_string())?;
+ while text.len() % 4 != 0 {
+ text.push(b' ');
+ }
+ let mut bin = bin.to_vec();
+ while bin.len() % 4 != 0 {
+ bin.push(0);
+ }
+ let mut out = Vec::with_capacity(28 + text.len() + bin.len());
+ for v in [GLB, 2, (28 + text.len() + bin.len()) as u32, text.len() as u32, JSON] {
+ out.extend_from_slice(&v.to_le_bytes());
+ }
+ out.extend_from_slice(&text);
+ out.extend_from_slice(&(bin.len() as u32).to_le_bytes());
+ out.extend_from_slice(&BIN.to_le_bytes());
+ out.extend_from_slice(&bin);
+ std::fs::write(path, out).map_err(|e| format!("{}: {e}", path.display()))
+}
+
+fn n(v: &Value, k: &str) -> Option<usize> {
+ v.get(k).and_then(Value::as_u64).map(|x| x as usize)
+}
+
+/// An accessor's bytes in the buffer: where they start, the step between elements, how many.
+fn span(doc: &Value, acc: usize) -> Option<(usize, usize, usize, u64)> {
+ let a = doc["accessors"].get(acc)?;
+ if a.get("sparse").is_some() {
+ return None;
+ }
+ let view = doc["bufferViews"].get(n(a, "bufferView")?)?;
+ if n(view, "buffer").unwrap_or(0) != 0 {
+ return None;
+ }
+ let ty = a["componentType"].as_u64()?;
+ let size = match ty { 5120 | 5121 => 1, 5122 | 5123 => 2, _ => 4 } * match a["type"].as_str()? { "SCALAR" => 1, "VEC2" => 2, "VEC3" => 3, _ => 4 };
+ Some((n(view, "byteOffset").unwrap_or(0) + n(a, "byteOffset").unwrap_or(0), n(view, "byteStride").filter(|s| *s > 0).unwrap_or(size), n(a, "count")?, ty))
+}
+
+/// A view of `bytes` added at the end of the buffer (aligned to 4), and its index.
+fn push_view(doc: &mut Value, bin: &mut Vec<u8>, bytes: &[u8], target: Option<u64>) -> usize {
+ while bin.len() % 4 != 0 {
+ bin.push(0);
+ }
+ let mut view = json!({"buffer": 0, "byteOffset": bin.len(), "byteLength": bytes.len()});
+ if let Some(t) = target {
+ view["target"] = json!(t);
+ }
+ bin.extend_from_slice(bytes);
+ let views = doc["bufferViews"].as_array_mut().unwrap();
+ views.push(view);
+ views.len() - 1
+}
+
+/// Every triangle list's indices simplified to `keep` of its triangles (never under 12): the triangles before and after.
+fn simplify(doc: &mut Value, bin: &mut Vec<u8>, keep: f32) -> (usize, usize) {
+ let (mut before, mut after) = (0, 0);
+ // an index list several primitives share is simplified once (against the first one's positions), in its own
+ // accessor, so the old indices are left with nothing using them and leave the file
+ let mut done: std::collections::HashSet<usize> = Default::default();
+ let prims: Vec<(usize, usize)> = doc["meshes"].as_array().into_iter().flatten().enumerate().flat_map(|(m, mesh)| (0..mesh["primitives"].as_array().map_or(0, Vec::len)).map(move |p| (m, p))).collect();
+ for (m, p) in prims {
+ let prim = &doc["meshes"][m]["primitives"][p];
+ if prim.get("mode").and_then(Value::as_u64).unwrap_or(4) != 4 {
+ continue;
+ }
+ let (Some(ia), Some(pa)) = (n(prim, "indices"), n(&prim["attributes"], "POSITION")) else { continue };
+ if done.contains(&ia) {
+ continue;
+ }
+ let (Some((io, is, ic, ity)), Some((po, ps, pc, 5126))) = (span(doc, ia), span(doc, pa)) else { continue };
+ before += ic / 3;
+ let read = |i: usize| -> u32 {
+ let at = io + i * is;
+ match ity {
+ 5121 => bin[at] as u32,
+ 5123 => u16::from_le_bytes([bin[at], bin[at + 1]]) as u32,
+ _ => u32::from_le_bytes([bin[at], bin[at + 1], bin[at + 2], bin[at + 3]]),
+ }
+ };
+ if io + ic.saturating_sub(1) * is + 1 > bin.len() || po + pc * ps > bin.len() + ps - 12 {
+ continue;
+ }
+ let indices: Vec<u32> = (0..ic).map(read).collect();
+ let target = (((ic / 3) as f32 * keep) as usize).max(12).min(ic / 3) * 3;
+ // the positions as meshoptimizer reads them: a stride of bytes, three floats at its start
+ let positions = &bin[po..(po + pc * ps).min(bin.len())];
+ let positions: Vec<u8> = if positions.len() % ps == 0 { positions.to_vec() } else { (0..pc).flat_map(|v| bin[po + v * ps..po + v * ps + 12].to_vec()).collect() };
+ let stride = if positions.len() == pc * 12 { 12 } else { ps };
+ let Ok(adapter) = meshopt::VertexDataAdapter::new(&positions, stride, 0) else { continue };
+ // a loose error bound: the count is what a level asks for, the shape is kept as far as it allows
+ let out = meshopt::simplify(&indices, &adapter, target, 0.05, meshopt::SimplifyOptions::None, None);
+ let out = if out.len() >= 3 && out.len() < indices.len() { out } else { indices };
+ after += out.len() / 3;
+ let bytes: Vec<u8> = out.iter().flat_map(|i| i.to_le_bytes()).collect();
+ let view = push_view(doc, bin, &bytes, Some(34963));
+ doc["accessors"][ia] = json!({"bufferView": view, "componentType": 5125, "count": out.len(), "type": "SCALAR"});
+ done.insert(ia);
+ }
+ (before, after)
+}
+
+/// Each embedded PNG or JPEG longer than `max` px made that long, in its own format: how many were.
+fn shrink_pictures(doc: &mut Value, bin: &mut Vec<u8>, max: u32) -> usize {
+ let mut made = 0;
+ for i in 0..doc["images"].as_array().map_or(0, Vec::len) {
+ let img = &doc["images"][i];
+ let (Some(view), Some(mime)) = (n(img, "bufferView"), img["mimeType"].as_str().map(str::to_string)) else { continue };
+ let v = &doc["bufferViews"][view];
+ let (at, len) = (n(v, "byteOffset").unwrap_or(0), n(v, "byteLength").unwrap_or(0));
+ let Some(bytes) = bin.get(at..at + len) else { continue };
+ let Ok(pic) = image::load_from_memory(bytes) else { continue };
+ if pic.width().max(pic.height()) <= max {
+ continue;
+ }
+ let k = max as f64 / pic.width().max(pic.height()) as f64;
+ let small = pic.resize_exact(((pic.width() as f64 * k).round() as u32).max(1), ((pic.height() as f64 * k).round() as u32).max(1), image::imageops::FilterType::CatmullRom);
+ let mut out = std::io::Cursor::new(Vec::new());
+ let wrote = if mime == "image/jpeg" { image::DynamicImage::ImageRgb8(small.to_rgb8()).write_to(&mut out, image::ImageFormat::Jpeg) } else { small.write_to(&mut out, image::ImageFormat::Png) };
+ if wrote.is_err() || (mime != "image/jpeg" && mime != "image/png") {
+ continue;
+ }
+ let view = push_view(doc, bin, out.get_ref(), None);
+ doc["images"][i]["bufferView"] = json!(view);
+ made += 1;
+ }
+ made
+}
+
+/// The buffer with only the views something still uses, the views numbered again.
+fn compact(doc: &mut Value, bin: &[u8]) -> Vec<u8> {
+ let views = doc["bufferViews"].as_array().cloned().unwrap_or_default();
+ let mut used = vec![false; views.len()];
+ let mut mark = |v: &Value| {
+ if let Some(i) = n(v, "bufferView").filter(|i| *i < used.len()) {
+ used[i] = true;
+ }
+ };
+ for a in doc["accessors"].as_array().into_iter().flatten() {
+ mark(a);
+ mark(&a["sparse"]["indices"]);
+ mark(&a["sparse"]["values"]);
+ }
+ for i in doc["images"].as_array().into_iter().flatten() {
+ mark(i);
+ }
+ // anything an extension points at by "bufferView" stays too
+ fn walk(v: &Value, mark: &mut dyn FnMut(&Value)) {
+ match v {
+ Value::Object(m) => {
+ mark(v);
+ m.values().for_each(|x| walk(x, mark));
+ }
+ Value::Array(a) => a.iter().for_each(|x| walk(x, mark)),
+ _ => {}
+ }
+ }
+ walk(&doc["extensions"].clone(), &mut mark);
+ for m in doc["meshes"].as_array().into_iter().flatten() {
+ walk(&m["primitives"], &mut |v| if v.get("extensions").is_some() { walk(&v["extensions"], &mut |x| if let Some(i) = n(x, "bufferView").filter(|i| *i < used.len()) { used[i] = true }) });
+ }
+ let mut out = Vec::new();
+ let mut to = vec![usize::MAX; views.len()];
+ let mut kept = Vec::new();
+ for (i, v) in views.iter().enumerate().filter(|(i, _)| used[*i]) {
+ while out.len() % 4 != 0 {
+ out.push(0);
+ }
+ let (at, len) = (n(v, "byteOffset").unwrap_or(0), n(v, "byteLength").unwrap_or(0));
+ let mut v = v.clone();
+ v["byteOffset"] = json!(out.len());
+ out.extend_from_slice(bin.get(at..at + len).unwrap_or(&[]));
+ to[i] = kept.len();
+ kept.push(v);
+ }
+ fn renumber(v: &mut Value, to: &[usize]) {
+ match v {
+ Value::Object(m) => {
+ if let Some(i) = m.get("bufferView").and_then(Value::as_u64).map(|i| i as usize).filter(|i| *i < to.len() && to[*i] != usize::MAX) {
+ m.insert("bufferView".into(), json!(to[i]));
+ }
+ m.values_mut().for_each(|x| renumber(x, to));
+ }
+ Value::Array(a) => a.iter_mut().for_each(|x| renumber(x, to)),
+ _ => {}
+ }
+ }
+ doc["bufferViews"] = Value::Array(kept);
+ for k in ["accessors", "images", "meshes", "extensions"] {
+ if doc.get(k).is_some() {
+ renumber(&mut doc[k], &to);
+ }
+ }
+ doc["buffers"] = json!([{"byteLength": out.len()}]);
+ out
+}
+
+pub fn lod(path: &Path, level: u32, texture: u32, out: &Path) -> R<Value> {
+ let (mut doc, mut bin) = read(path)?;
+ if doc["buffers"].as_array().is_some_and(|b| b.len() > 1 || b.iter().any(|x| x.get("uri").is_some())) {
+ return Err(format!("{}: its buffers are separate files; raea media lod reads a .glb with its buffer inside it", path.display()));
+ }
+ let (before, after) = simplify(&mut doc, &mut bin, 0.5f32.powi(level.max(1) as i32));
+ let pictures = shrink_pictures(&mut doc, &mut bin, texture.max(16));
+ let bin = compact(&mut doc, &bin);
+ write(out, &doc, &bin)?;
+ let bytes = |p: &Path| std::fs::metadata(p).map(|m| m.len()).unwrap_or(0);
+ Ok(json!({"wrote": out, "level": level.max(1), "triangles": [before, after], "pictures_made_smaller": pictures, "bytes": [bytes(path), bytes(out)]}))
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ /// A flat grid of `n` by `n` squares as a .glb: positions and u16 indices, and a picture nothing shrinks.
+ fn grid(n: u16) -> (Value, Vec<u8>) {
+ let mut bin = Vec::new();
+ for y in 0..=n {
+ for x in 0..=n {
+ for v in [x as f32, 0.0, y as f32] {
+ bin.extend_from_slice(&v.to_le_bytes());
+ }
+ }
+ }
+ let verts = (n as usize + 1) * (n as usize + 1);
+ let index_at = bin.len();
+ let mut count = 0;
+ for y in 0..n {
+ for x in 0..n {
+ let a = y * (n + 1) + x;
+ for i in [a, a + 1, a + n + 1, a + 1, a + n + 2, a + n + 1] {
+ bin.extend_from_slice(&i.to_le_bytes());
+ count += 1;
+ }
+ }
+ }
+ let doc = json!({
+ "asset": {"version": "2.0"},
+ "buffers": [{"byteLength": bin.len()}],
+ "bufferViews": [{"buffer": 0, "byteOffset": 0, "byteLength": verts * 12}, {"buffer": 0, "byteOffset": index_at, "byteLength": count * 2}],
+ "accessors": [{"bufferView": 0, "componentType": 5126, "count": verts, "type": "VEC3"}, {"bufferView": 1, "componentType": 5123, "count": count, "type": "SCALAR"}],
+ "meshes": [{"primitives": [{"attributes": {"POSITION": 0}, "indices": 1}]}],
+ "nodes": [{"mesh": 0}], "scenes": [{"nodes": [0]}], "scene": 0,
+ });
+ (doc, bin)
+ }
+
+ #[test]
+ fn a_level_halves_the_triangles_and_the_old_indices_leave_the_file() {
+ let dir = std::env::temp_dir().join(format!("raea-lod-{}", std::process::id()));
+ std::fs::create_dir_all(&dir).unwrap();
+ let (doc, bin) = grid(16);
+ let (src, out) = (dir.join("grid.glb"), dir.join("grid.lod1.glb"));
+ write(&src, &doc, &bin).unwrap();
+ let said = lod(&src, 1, 1024, &out).unwrap();
+ let (before, after) = (said["triangles"][0].as_u64().unwrap(), said["triangles"][1].as_u64().unwrap());
+ assert_eq!(before, 512);
+ assert!(after <= 256 && after >= 12, "{after} triangles");
+ // read back: one index view (the new one), the positions as they were, every index a vertex of the mesh
+ let (doc, bin) = read(&out).unwrap();
+ assert_eq!(doc["bufferViews"].as_array().unwrap().len(), 2);
+ let (io, _, ic, ty) = span(&doc, doc["meshes"][0]["primitives"][0]["indices"].as_u64().unwrap() as usize).unwrap();
+ assert_eq!((ic as u64, ty), (after * 3, 5125));
+ assert!((0..ic).all(|i| u32::from_le_bytes(bin[io + i * 4..io + i * 4 + 4].try_into().unwrap()) < 289));
+ assert_eq!(doc["accessors"][0]["count"], 289);
+ let two = lod(&src, 2, 1024, &dir.join("grid.lod2.glb")).unwrap();
+ assert!(two["triangles"][1].as_u64().unwrap() <= 128);
+ std::fs::remove_dir_all(&dir).ok();
+ }
+
+ #[test]
+ fn a_file_that_is_not_a_glb_is_refused() {
+ let p = std::env::temp_dir().join(format!("raea-lod-not-{}.glb", std::process::id()));
+ std::fs::write(&p, b"plain text").unwrap();
+ assert!(lod(&p, 1, 1024, &p.with_extension("out.glb")).unwrap_err().contains("not a .glb"));
+ std::fs::remove_file(&p).ok();
+ }
+}
diff --git a/docs/manual/reference/cli/media.md b/docs/manual/reference/cli/media.md
index 66169dd9..13ef2f9c 100644
--- a/docs/manual/reference/cli/media.md
+++ b/docs/manual/reference/cli/media.md
@@ -38,6 +38,7 @@ What agents used ffmpeg and ffprobe for, on raea-media (the platform's decoders
raea media cuts FILE [--threshold 0.08] shot changes (ffmpeg's scene score)
raea media freezes FILE [--noise 0.001] [--min 2] held pictures (ffmpeg's freezedetect)
raea media proxy FILE [--height 720] -o OUT.mp4 a smaller copy
+ raea media lod MODEL.glb [--level 1] [--texture 1024] -o OUT.glb a model at a lower level of detail (triangles halved a level)
raea media trim FILE --from S --to S -o OUT.mp4 a stretch, frame-exact (re-encoded)
raea media concat A B ... -o OUT.mp4 one after another (same aspect)
raea media encode --size WxH [--fps 60] [--quality Q] [--audio FILE] -o OUT.mp4 raw RGBA frames on stdin, signed
diff --git a/docs/preview.feature b/docs/preview.feature
index 9b78f247..838dd710 100644
--- a/docs/preview.feature
+++ b/docs/preview.feature
@@ -42,6 +42,14 @@ Feature: Preview: anything in a project opens at once, in its space, with its pr
And plain `raea render FILE -o OUT` output stays as it is: nothing here changes a render's defaults
Rule: PV1. The live stage picks 3D parts (engine)
+ # Status 11-09: built. systems/frame pick.rs (the nearest mesh along the pointer's ray from the frame's camera,
+ # skinned meshes as posed; locate: where parts and world points are on the frame now) and view.rs (FreeView, an
+ # orbit held over the composition's camera and given back); runtime/live pick3d.rs (pick: the page's element or
+ # the 3D's part as one picture, a part answered with its JSX's own props; set_view, locate, set_props);
+ # engine/page/stage: stage.pick, stage.view, stage.locate, stage.props, and what it opens is stamped. Checked with
+ # `raea play examples/games/shapes.tsx --offscreen --seek 10 OUT.png --pick 640,330` (shape-2 at
+ # shapes.tsx:28:11#2 with its position and quaternion; the floor; the div where there is no mesh) and
+ # `--view 1.2,0.9,9,0,0.5,0` (drawn from above, the same part under the same point). raea-sys-frame: 3 tests.
Scenario: PV1a. A part under the pointer
Given a composition with 3D meshes playing on the stage
@@ -60,6 +68,9 @@ Feature: Preview: anything in a project opens at once, in its space, with its pr
And picking uses the camera the frame was drawn from
Rule: PV2. What a thing is (app host)
+ # Status 11-09: built (raea-feed host/preview describe.ts, glb.ts; POST /host/describe). A model's facts come from
+ # its glb's JSON chunk alone (triangles, nodes, clips, its box). Checked on a scratch project: a component (3D,
+ # timed, its four props), a composition (both, 3 s), a model (27,420 triangles), a video, a sound. 5 tests.
Scenario: PV2a. One description of any file
When the host is asked what a project's file is
@@ -67,6 +78,14 @@ Feature: Preview: anything in a project opens at once, in its space, with its pr
whether a proxy is needed, for a composition, a component, an image, a video, a sound, a model and a font
Rule: PV3. Proxies and levels of detail (app host)
+ # Status 11-09: built (raea-feed host/preview proxies.ts; GET /host/proxy, POST /host/proxies; Settings › General ›
+ # Light copies). thumb, light and peaks are raea's own verbs (media still --width, new; media proxy; media audio);
+ # a model's still is its view rendered; lod is `raea media lod` (new, apps/media lod.rs: meshoptimizer on the
+ # model's own vertices, so skins and UVs are untouched; embedded pictures at most 1024 px; what nothing uses
+ # leaves the file). A render's light copy (editing.feature E4) is the same store's now. Checked: body.glb 27,420
+ # triangles -> 6,854 at level 2, rendered and looked at; a 1280x720 take's still in 0.28 s and light copy in
+ # 0.9 s; a sound's peaks in 0.15 s; Settings said "318 KB used: 3 stills, 1 videos, 1 sounds". 8 + 2 tests.
+ # Not built: a model's level chosen by its size on screen while it plays (it opens light and goes to full once).
Scenario: PV3a. Every medium has its light copies
Then an image has a thumbnail, a video a poster and a 540-line copy, a sound its peaks, a model a poster and
@@ -78,10 +97,18 @@ Feature: Preview: anything in a project opens at once, in its space, with its pr
is gone are dropped; the store keeps under its limit by dropping the least recently used
Scenario: PV3c. A model's levels of detail
- Then a heavy model gets lower levels (triangles halved per level, textures at most 1024 px) and the preview
- draws the level its size on screen calls for, the full model when still
+ Then a heavy model gets lower levels (triangles halved per level, textures at most 1024 px), and its preview
+ opens on one and draws the full model once the view has stood a moment
Rule: PV4. One preview (app)
+ # Status 11-09: built in the raea app, checked in its headless window on a scratch project (raea-feed
+ # src/preview: PreviewStage, stage.ts, Selected, LivePick, AssetPreview). A component's page plays it on the stage:
+ # a click on the cylinder of a five-shape row answered shape-2 at row.tsx:26 item 2 with its props, dragging
+ # `lift` raised the shapes as it moved, Orbit turned the scene. A composition never rendered played on opening,
+ # and a click on its title answered the div at shapes.tsx:8. A model, a video, a still and a sound each opened on
+ # their page from Assets, whose cards are the store's stills. In Chrome there is no stage: the still stays.
+ # Not built: props changed in the selection's card written back to the code from a preview (the editor's
+ # stage.tweak does that for a game); the composition editor's own Select tool still reads the render's layers.
Scenario: PV4a. It opens at once
When I open a component, a composition or an asset
@@ -99,6 +126,9 @@ Feature: Preview: anything in a project opens at once, in its space, with its pr
Then it is outlined, selected, shown in the outline tree, and its props are the panel's
Rule: PV5. Notes on anything (app)
+ # Status 11-09: built (raea-feed host/preview notes.ts, POST /host/file-notes; kept in the project's
+ # .raea/notes/). Checked: a click on body.glb's chest and a note wrote pin.point [0.00, 1.23, 0.13], and its pin
+ # stayed on the chest through an orbit (stage.locate). 1 test. Not built: the note sent to an agent as a task.
Scenario: PV5a. A note on a model
When I click a point on a model in its preview and write a note