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
A thing left in the air touching nothing is an error in raea scene lint, unless it is marked floating (typed on Mesh3d and Model, taught in the scenes guide) or its own material glows; the z-fight check tells doubled triangles and undersides resting on one floor from real fights. The lane's house checks: dunce for the project's path, the contact lint under its size (glows and unparked live in core/scene parts.rs), copies folded, the manual's pages for SolariLighting's new props and floating
shinyobjectzb1a8d57616e7
diff --git a/apps/direction/src/check.rs b/apps/direction/src/check.rsindex 67acd128..f8d598f8 100644--- a/apps/direction/src/check.rs+++ b/apps/direction/src/check.rs@@ -279,9 +279,13 @@ fn check_one(tsx: &Path, id: Option<String>, rules: &[Rule], args: &[String], whOk(Checked { file: tsx.to_path_buf(), id, found: finding::ranked(found), waits, render, shots, fps })}+/// Whether a file names SolariLighting.+fn names(p: &Path) -> bool {+ std::fs::read_to_string(p).unwrap_or_default().contains("SolariLighting")+}+/// Whether a composition is lit by traced light: its file, or a .tsx beside it or a folder down, names SolariLighting.fn traced(tsx: &Path) -> bool {- let names = |p: &Path| std::fs::read_to_string(p).is_ok_and(|s| s.contains("SolariLighting"));if names(tsx) {return true;}@@ -292,13 +296,19 @@ fn traced(tsx: &Path) -> bool {/// The findings of the newest hold of each frame of a composition (`raea light steady`), from its project's record.fn light_held(tsx: &Path, id: Option<&str>) -> Vec<Finding> {- let Some(project) = tsx.canonicalize().ok().and_then(|t| record::up(t.parent()?, ".raea/project")) else { return Vec::new() };+ let Some(project) = dunce::canonicalize(tsx).ok().and_then(|t| record::up(t.parent()?, ".raea/project")) else { return Vec::new() };let of = record::rel(&project, tsx);let mut newest: std::collections::BTreeMap<i64, Vec<Finding>> = std::collections::BTreeMap::new();- for e in record::read(&project).into_iter().filter(|e| e.by == "raea light steady" && e.of == of) {- let mine: Vec<Finding> = e.findings.into_iter().filter(|f| id.is_none_or(|i| f.about.iter().any(|a| a.name == i))).collect();- if let Some(frame) = mine.first().and_then(|f| f.frames).map(|f| f[0]) {- newest.insert(frame, mine);+ for e in record::read(&project) {+ if e.by != "raea light steady" || e.of != of {+ continue;+ }+ let mut mine = e.findings;+ if let Some(id) = id {+ mine.retain(|f| f.about.iter().any(|a| a.name == id));+ }+ if let Some(frame) = mine.first().and_then(|f| f.frames) {+ newest.insert(frame[0], mine);}}newest.into_values().flatten().collect()diff --git a/core/scene/src/parts.rs b/core/scene/src/parts.rsindex 56dd8bac..f6c83ede 100644--- a/core/scene/src/parts.rs+++ b/core/scene/src/parts.rs@@ -224,3 +224,83 @@ pub fn ray_tri(o: Vec3, d: Vec3, [a, b, c]: [Vec3; 3]) -> Option<f32> {let t = e2.dot(q) / det;(t >= 0.0).then_some(t)}++/// Whether a part's own material gives off light (a lamp's panel, a neon tube): any of its emissive's red, green or+/// blue above zero. A model's materials are in its file and aren't read here.+pub fn glows(it: &Item) -> bool {+ it.material.as_ref().and_then(|m| m.props.get("emissive")).is_some_and(glows_in)+}++fn above_zero(v: &Value) -> bool {+ v.as_f64().unwrap_or(0.0) > 0.0+}++/// A colour as the SDK writes one: [r, g, b, a], { red, green, blue, alpha }, a tagged one ({ LinearRgba: {...} }) or a+/// CSS string.+fn glows_in(v: &Value) -> bool {+ match v {+ Value::Array(a) => a.iter().take(3).any(above_zero),+ Value::Object(o) => {+ let own = ["red", "green", "blue", "r", "g", "b"].iter().filter_map(|k| o.get(*k)).any(above_zero);+ own || o.values().any(|v| (v.is_object() || v.is_array()) && glows_in(v))+ }+ Value::String(c) => !matches!(c.trim_start_matches('#').to_ascii_lowercase().as_str(), "000" | "000000" | "black" | ""),+ _ => false,+ }+}++/// How far from the scene a part is parked: a piece swaps a flipbook's frames (MALL RAT's fountain, 88 water models) by+/// moving the ones not shown hundreds of metres away, where they lie in one another and read as faces fighting.+const PARKED: f32 = 500.0;++/// The parts in the scene, without those parked far from it (further than PARKED from the median of every part's+/// centre), each of those said once as not checked.+pub fn unparked<T>(parts: Vec<Part>, items: Vec<T>, skipped: &mut Vec<String>) -> (Vec<Part>, Vec<T>) {+ if parts.len() < 3 {+ return (parts, items);+ }+ let mid = |k: usize| {+ let mut v: Vec<f32> = parts.iter().map(|p| ((p.lo + p.hi) * 0.5)[k]).collect();+ v.sort_by(f32::total_cmp);+ v[v.len() / 2]+ };+ let centre = Vec3::new(mid(0), mid(1), mid(2));+ let mut parked = 0;+ let kept: (Vec<Part>, Vec<T>) = parts.into_iter().zip(items).filter(|(p, _)| {+ let far = ((p.lo + p.hi) * 0.5).distance(centre) > PARKED;+ parked += far as usize;+ !far+ }).unzip();+ if parked > 0 {+ skipped.push(format!("{parked} part{} parked over {PARKED} m from the scene (a flipbook's frames not shown)", if parked == 1 { "" } else { "s" }));+ }+ kept+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn a_flipbooks_frames_parked_far_away_are_left_out() {+ let part = |name: &str, c: Vec3, s: Vec3| Part { label: name.into(), tris: Vec::new(), node: Vec::new(), nodes: Vec::new(), lo: c - s / 2.0, hi: c + s / 2.0, excused: false, moving: false };+ let mut parts = vec![part("floor", Vec3::ZERO, Vec3::new(20.0, 0.1, 20.0)), part("bench", Vec3::new(1.0, 0.3, 0.0), Vec3::new(1.5, 0.5, 0.4)), part("water0", Vec3::new(0.0, 0.5, 3.0), Vec3::ONE)];+ for i in 1..4 {+ parts.push(part(&format!("water{i}"), Vec3::new(0.0, -900.0, 3.0), Vec3::ONE));+ }+ let mut skipped = Vec::new();+ let (kept, _) = unparked(parts, vec![(); 6], &mut skipped);+ assert_eq!(kept.iter().map(|p| p.label.as_str()).collect::<Vec<_>>(), ["floor", "bench", "water0"]);+ assert!(skipped[0].starts_with("3 parts parked"), "{skipped:?}");+ }++ #[test]+ fn a_colour_with_any_light_in_it_glows() {+ use serde_json::json;+ assert!(glows_in(&json!({"red": 0.0, "green": 120.0, "blue": 0.0, "alpha": 1.0})));+ assert!(glows_in(&json!([2200.0, 120.0, 80.0, 1.0])));+ // black with an alpha of 1 doesn't+ assert!(!glows_in(&json!({"red": 0.0, "green": 0.0, "blue": 0.0, "alpha": 1.0})));+ assert!(!glows_in(&json!([0.0, 0.0, 0.0, 1.0])));+ }+}diff --git a/core/zfight/src/lib.rs b/core/zfight/src/lib.rsindex de71fb98..1ed92f92 100644--- a/core/zfight/src/lib.rs+++ b/core/zfight/src/lib.rs@@ -80,17 +80,60 @@ fn same_plane(a: &Face, b: &Face) -> bool {/// One face over another: how many pairs, about how much area (the smaller face of each pair, summed: an upper/// bound), and where the first is. `b` None: within `a` itself.pub fn overlaps(a: &[[Vec3; 3]], b: Option<&[[Vec3; 3]]>) -> Option<(usize, f32, Vec3)> {+ let o = sorted(a, b);+ o.fight.or(o.twins).or(o.bases)+}++/// Faces in one plane over each other, by whether they show.+#[derive(Default, Debug)]+pub struct Overlaps {+ /// One face over a different one: the picture flickers between them.+ pub fight: Option<(usize, f32, Vec3)>,+ /// Between two parts, the same triangle in both (a slab built into two neighbouring chunks): nothing to see where+ /// they look alike, since either draws the same.+ pub twins: Option<(usize, f32, Vec3)>,+ /// Between two parts, faces looking straight down in the plane both parts stand on (two boxes on one floor, one+ /// set into the other): their undersides, which the floor hides.+ pub bases: Option<(usize, f32, Vec3)>,+}++/// Corners this close (metres) are one corner.+const CORNER: f32 = 0.0005;++fn twin(a: &Face, b: &Face) -> bool {+ a.tri.iter().all(|p| b.tri.iter().any(|q| p.distance(*q) <= CORNER))+}++/// The lowest corner of a part's faces.+fn low(faces: &[Face]) -> f32 {+ let mut y = f32::INFINITY;+ for f in faces {+ for p in &f.tri {+ y = y.min(p.y);+ }+ }+ y+}++/// As `overlaps`, with the pairs that don't show kept apart (between two parts only: inside one model every pair counts).+pub fn sorted(a: &[[Vec3; 3]], b: Option<&[[Vec3; 3]]>) -> Overlaps {if b.is_none() && a.len() > SELF_MAX {- return None;+ return Overlaps::default();}let fa: Vec<Face> = a.iter().filter_map(face).collect();let fb: Vec<Face> = b.map(|b| b.iter().filter_map(face).collect()).unwrap_or_default();let others = if b.is_some() { &fb } else { &fa };+ let (low_a, low_b) = (low(&fa), low(&fb));let mut buckets: HashMap<Key, Vec<usize>> = HashMap::new();for (i, f) in others.iter().enumerate() {buckets.entry(key(f.n, f.d)).or_default().push(i);}- let (mut count, mut area, mut at) = (0usize, 0f32, None);+ let mut out = Overlaps::default();+ let add = |to: &mut Option<(usize, f32, Vec3)>, f: &Face, g: &Face| {+ let e = to.get_or_insert((0, 0.0, (f.tri[0] + f.tri[1] + f.tri[2]) / 3.0));+ e.0 += 1;+ e.1 += f.area.min(g.area);+ };for (i, f) in fa.iter().enumerate() {let mut seen: Vec<usize> = Vec::new();for k in near(key(f.n, f.d)) {@@ -102,14 +145,15 @@ pub fn overlaps(a: &[[Vec3; 3]], b: Option<&[[Vec3; 3]]>) -> Option<(usize, f32,seen.push(j);let g = &others[j];if same_plane(f, g) && overlap(f, g) {- count += 1;- area += f.area.min(g.area);- at.get_or_insert((f.tri[0] + f.tri[1] + f.tri[2]) / 3.0);+ let y = f.tri[0].y;+ let base = b.is_some() && f.n.y <= -0.999 && (y - low_a).abs() <= 0.001 && (y - low_b).abs() <= 0.001;+ let to = if base { &mut out.bases } else if b.is_some() && twin(f, g) { &mut out.twins } else { &mut out.fight };+ add(to, f, g);}}}}- at.map(|at| (count, area, at))+ out}#[cfg(test)]@@ -140,4 +184,28 @@ mod tests {assert_eq!(overlaps(&doubled, None).map(|o| o.0), Some(1));assert!(overlaps(&quad(0.5, 0.0, 1.0, true), None).is_none());}++ #[test]+ fn the_same_faces_in_two_parts_and_undersides_on_one_floor_are_kept_apart_from_a_fight() {+ // a slab built into two chunks: the same triangles in both+ let slab = quad(8.8, 0.0, 4.0, true);+ let o = sorted(&slab, Some(&slab));+ assert!(o.fight.is_none() && o.twins.map(|t| t.0) == Some(2), "{o:?}");+ // a rug's top in the floor's is a different face over it: a fight+ let o = sorted(&quad(0.0001, 0.0, 0.5, true), Some(&quad(0.0, -1.0, 1.0, true)));+ assert!(o.fight.is_some() && o.twins.is_none() && o.bases.is_none(), "{o:?}");+ // a door set into a wall, both standing on the floor: their undersides overlap in the floor's plane+ let mut wall = quad(0.0, -1.0, 1.0, false);+ wall.extend(quad(2.0, -1.0, 1.0, true));+ let mut door = quad(0.0, -0.4, 0.4, false);+ door.extend(quad(1.0, -0.4, 0.4, true));+ let o = sorted(&door, Some(&wall));+ assert!(o.fight.is_none() && o.bases.is_some(), "{o:?}");+ // the same underside held up off the ground (a soffit under a beam's) still fights+ let mut beam = quad(2.0, -1.0, 1.0, false);+ beam.extend(quad(0.0, -1.0, 1.0, true));+ let mut soffit = quad(2.0, -0.4, 0.4, false);+ soffit.extend(quad(1.5, -0.4, 0.4, true));+ assert!(sorted(&soffit, Some(&beam)).fight.is_some());+ }}diff --git a/docs/manual/reference/sdk/3d.md b/docs/manual/reference/sdk/3d.mdindex 93a19151..3c78de41 100644--- a/docs/manual/reference/sdk/3d.md+++ b/docs/manual/reference/sdk/3d.md@@ -555,6 +555,7 @@ Bevy: `bevy_pbr::mesh_material::MeshMaterial3d<raea_render::engine::look::LookMa| `scale` | `number \| Vec3` | one number, or x, y and z || `allowOverlap` | `boolean` | it may pass through other parts on purpose (a blade into a body, a ghost through a wall): raea's clipping check leaves it out || `posed` | `boolean` | set at an angle on purpose (a bowl knocked over, a mug on its side): `raea scene lint` doesn't call it tilted |+| `floating` | `boolean` | it hangs in the air on purpose, touching nothing (a balloon, a sign on wires that aren't modelled): `raea scene lint` doesn't call it left in the air || `animation` | `string \| number` | a clip to play: its name in the file, or its index || `screens` | `ModelScreens` | live pictures on its materials, by the glTF material's name: `{ monitor_screen: <Screen resolution={[384, 272]}> <Game /></Screen> }` (or a bare `<Game />` for the defaults). Each mesh with that material shows the screen, the picture fitted to the mesh's texture coordinates and stood upright || `hide` | `string[]` | nodes of the glTF hidden, by name (a robot's painted-on eyes under the screen that replaces them) |diff --git a/docs/manual/reference/sdk/light.md b/docs/manual/reference/sdk/light.mdindex 319ae31a..5e7e3887 100644--- a/docs/manual/reference/sdk/light.md+++ b/docs/manual/reference/sdk/light.md@@ -207,6 +207,8 @@ raster-lit: Bevy 0.20's Solari can't trace it, unless `dynamic` gives a skinned| `primarySamples` | `number` | direct light samples at the camera's first hit, a pixel a frame (Bevy's 8). After MetalFX's denoiser 4 bought the window scene nothing over 8 and saved 1.5 ms at 1080p's pixels || `secondarySamples` | `number` | direct light samples at each bounce (Bevy's 4) || `firstBounce` | `number` | the chance a pixel traces its first bounce this frame, its light divided by it (Russian roulette): 0.5 halves the bounce's tracing, most of a dense forest's (1, every pixel every frame) |+| `paths` | `number` | initial paths a pixel a frame (1 to 16, 1 by default): N cut the noise of one path N times, at N times its rays. A sunlit room seen through bounces (MALL RAT's court) needs 4 or more to hold still |+| `firefly` | `number` | the firefly filter: a sample over this many times the mean of its 8x8 pixels is cut back to that after temporal reuse (off by default; 2 and up). One very bright sample otherwise lingers and spreads: a patch jumps brighter and takes a second to fall back. Lower holds stiller and loses more light (a room lit by small bulbs: 6 holds still and reads 0.3 stops darker, 12 half of both; 32 loses nothing and gains little) || `cache` | `{ /** frames a cell's light is gathered over: steadier and slower to follow a change (B…` | Solari's world cache, the bounce light it keeps in cells across the scene || `scale` | `number` | draw the view at this fraction of its size a side (a third to 1) and let MetalFX's temporal scaler bring it up to the full size, so a game traces fewer pixels: 0.67 traces 45% of them. On the Mac; elsewhere it draws at the full size and raea says so. 1 (or left out): the full size; RAEA_SOLARI_SCALE overrides it || `denoise` | `boolean` | MetalFX's temporal denoiser on the lighting. false shows Solari's raw noise. Default true; RAEA_SOLARI_DENOISE=0 overrides it |@@ -215,6 +217,8 @@ raster-lit: Bevy 0.20's Solari can't trace it, unless `dynamic` gives a skinned| `emissive` | `"taa" \| "split" \| "mask"` | an emissive surface's own light: "taa" taken out before the denoiser and gathered over frames (RT11, RT32), "split" each frame's alone, "mask" left in for the denoiser. Default "taa"; RAEA_SOLARI_EMISSIVE overrides it || `upscale` | `"one" \| "two"` | a view drawn small (scale below 1): denoised and brought up in "one" pass, or denoised small and scaled in "two". Default "one"; RAEA_SOLARI_UPSCALE overrides it || `preexposure` | `number` | what MetalFX divides the light by before it denoises and multiplies it by after. Higher keeps more of a rare bright sample (a lamp found by one path in many) and lets more fireflies through: 1 kept 0.74 of the desk's light, 16 0.86, 64 0.91. Default 16; RAEA_METALFX_PREEXPOSURE overrides it |+| `knee` | `number` | where the denoiser's soft knee starts, in its white (1 by default; 0 off). Light above it is denoised as its log and restored after, so a silhouette against bright sky or a lit doorway doesn't step with the camera's jitter. RAEA_METALFX_KNEE overrides it |+| `late` | `boolean` | denoise after the forward meshes and the sky, so their edges are gathered over frames too instead of stepping with the camera's jitter. RAEA_SOLARI_DENOISE_LATE overrides it || `aa` | `boolean` | jitter a full-size view too, so the denoiser anti-aliases its edges as it gathers frames. Default true; RAEA_SOLARI_AA=0 overrides it || `jitter` | `"denoiser" \| "scaler" \| "both" \| "flip" \| "none"` | which of MetalFX's passes is told the camera's jitter: "denoiser", "scaler", "both", "flip" (the denoiser, negated), "none" (and the view isn't jittered). For A/Bs of RT9; default "denoiser"; RAEA_SOLARI_JITTER ("" the denoiser, "0" none) overrides it || `emissiveSharpness` | `number` | how fast a sample's weight falls with its distance from a pixel's centre in the emission's history, exp(-k d²) in output pixels: lower is softer. Default 6; RAEA_EMIT_TAA_SHARP overrides it |diff --git a/docs/manual/reference/sdk/mesh.md b/docs/manual/reference/sdk/mesh.mdindex e15ebcdb..d10885a7 100644--- a/docs/manual/reference/sdk/mesh.md+++ b/docs/manual/reference/sdk/mesh.md@@ -114,7 +114,7 @@ One part, so a curve that grows is solid at every frame (never a chain of parts:| `normal` | `Vec3` | the way its face looks: the normal of the plane it lies in (left out: the plane of its points, else +z) || `children` | `ReactNode` | its material (a white StandardMaterial when left out) |-Also takes the props of `MeshProps` (`animate`, `name`, `read`, `pass`, `quaternion`, `allowOverlap`, `posed`, `lod`, `shape`, `driven`, `shadow`, `material`, `castShadow`, `surface`, `receiveShadow`, `attributes`, `compressed`, `layers`); `PointerHandlers3d` (`onClick`, `onDrag`, `onDragEnd`, `onDragEnter`, `onDragLeave`, `onDragOver`, `onDragStart`, `onDrop`, `onPointerDown`, `onPointerMove`, `onPointerUp`, `onPointerEnter`, `onPointerLeave`, `onPointerOver`, `onPointerOut`, `onWheel`); [`Mesh3dProps`](#mesh3dprops) (`visibility`, `transform`, `detail`).+Also takes the props of `MeshProps` (`animate`, `name`, `read`, `pass`, `quaternion`, `allowOverlap`, `posed`, `floating`, `lod`, `shape`, `driven`, `shadow`, `material`, `castShadow`, `surface`, `receiveShadow`, `attributes`, `compressed`, `layers`); `PointerHandlers3d` (`onClick`, `onDrag`, `onDragEnd`, `onDragEnter`, `onDragLeave`, `onDragOver`, `onDragStart`, `onDrop`, `onPointerDown`, `onPointerMove`, `onPointerUp`, `onPointerEnter`, `onPointerLeave`, `onPointerOver`, `onPointerOut`, `onWheel`); [`Mesh3dProps`](#mesh3dprops) (`visibility`, `transform`, `detail`).### `Mesh2d`@@ -139,7 +139,7 @@ shadow="only" draws it with the shadow-only material (engine/render shadow_only.| `detail` | `Detail` | where it's drawn: its distances or sizes on screen, cross-faded, and its shadow (Detail; raea-sys-lod) || `children` | `ReactNode` | its material and child entities |-Also takes the props of `MeshProps` (`animate`, `name`, `read`, `pass`, `quaternion`, `allowOverlap`, `posed`, `lod`, `shape`, `driven`, `shadow`, `material`, `castShadow`, `surface`, `receiveShadow`, `attributes`, `compressed`, `layers`); `PointerHandlers3d` (`onClick`, `onDrag`, `onDragEnd`, `onDragEnter`, `onDragLeave`, `onDragOver`, `onDragStart`, `onDrop`, `onPointerDown`, `onPointerMove`, `onPointerUp`, `onPointerEnter`, `onPointerLeave`, `onPointerOver`, `onPointerOut`, `onWheel`).+Also takes the props of `MeshProps` (`animate`, `name`, `read`, `pass`, `quaternion`, `allowOverlap`, `posed`, `floating`, `lod`, `shape`, `driven`, `shadow`, `material`, `castShadow`, `surface`, `receiveShadow`, `attributes`, `compressed`, `layers`); `PointerHandlers3d` (`onClick`, `onDrag`, `onDragEnd`, `onDragEnter`, `onDragLeave`, `onDragOver`, `onDragStart`, `onDrop`, `onPointerDown`, `onPointerMove`, `onPointerUp`, `onPointerEnter`, `onPointerLeave`, `onPointerOver`, `onPointerOut`, `onWheel`).Used in: [ui/render_ui_to_texture](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/render_ui_to_texture.tsx), [ui/widgets/viewport_node](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/widgets/viewport_node.tsx), [3d/fog](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/fog.tsx), [3d/vertex_colors](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/vertex_colors.tsx), [3d/rotate_environment_map](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/rotate_environment_map.tsx), [3d/transparency_3d](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/transparency_3d.tsx), [3d/spherical_area_lights](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/spherical_area_lights.tsx), [3d/animated_material](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/animated_material.tsx), and 54 more.@@ -181,7 +181,7 @@ A line through points in 3D with a round section (a pipe, a wire): one mesh, dra| `radius` | `number` | its radius in metres (0.025) || `sides` | `number` | sides around its section (12) |-Also takes the props of `MeshProps` (`animate`, `name`, `read`, `pass`, `quaternion`, `allowOverlap`, `posed`, `lod`, `shape`, `driven`, `shadow`, `material`, `castShadow`, `surface`, `receiveShadow`, `attributes`, `compressed`, `layers`); `PointerHandlers3d` (`onClick`, `onDrag`, `onDragEnd`, `onDragEnter`, `onDragLeave`, `onDragOver`, `onDragStart`, `onDrop`, `onPointerDown`, `onPointerMove`, `onPointerUp`, `onPointerEnter`, `onPointerLeave`, `onPointerOver`, `onPointerOut`, `onWheel`); [`Mesh3dProps`](#mesh3dprops) (`visibility`, `transform`, `detail`).+Also takes the props of `MeshProps` (`animate`, `name`, `read`, `pass`, `quaternion`, `allowOverlap`, `posed`, `floating`, `lod`, `shape`, `driven`, `shadow`, `material`, `castShadow`, `surface`, `receiveShadow`, `attributes`, `compressed`, `layers`); `PointerHandlers3d` (`onClick`, `onDrag`, `onDragEnd`, `onDragEnter`, `onDragLeave`, `onDragOver`, `onDragStart`, `onDrop`, `onPointerDown`, `onPointerMove`, `onPointerUp`, `onPointerEnter`, `onPointerLeave`, `onPointerOver`, `onPointerOut`, `onWheel`); [`Mesh3dProps`](#mesh3dprops) (`visibility`, `transform`, `detail`).## Functionsdiff --git a/engine/light/src/kinds.rs b/engine/light/src/kinds.rsindex 05be409c..69394f24 100644--- a/engine/light/src/kinds.rs+++ b/engine/light/src/kinds.rs@@ -65,7 +65,13 @@ pub fn read(series: &[f64], lit: f64) -> (Kind, f64, f64, usize) {// the series against itself p frames later, as a correlationlet corr = |p: usize| r[p..].iter().zip(&r).map(|(a, b)| a * b).sum::<f64>() / (n - p) as f64 / var.max(1e-18);let slow = corr(1) >= SLOW;- let (cycle, best) = (2..=CYCLE.min(n / 3)).map(|p| (p, corr(p))).fold((0, 0.0), |a, b| if b.1 > a.1 { b } else { a });+ let (mut cycle, mut best) = (0, 0.0);+ for p in 2..=CYCLE.min(n / 3) {+ let c = corr(p);+ if c > best {+ (cycle, best) = (p, c);+ }+ }if !slow && best >= REPEATS {(Kind::Jitter, dev, trend, cycle)} else if slow {diff --git a/engine/render/raytrace/src/settings.rs b/engine/render/raytrace/src/settings.rsindex 3f55107b..cc6f670a 100644--- a/engine/render/raytrace/src/settings.rs+++ b/engine/render/raytrace/src/settings.rs@@ -36,7 +36,7 @@ fn overrides() -> &'static Overrides {upscale: var("RAEA_SOLARI_UPSCALE").filter(|v| matches!(v.as_str(), "one" | "two")),preexposure: num("RAEA_METALFX_PREEXPOSURE"),late: switch("RAEA_SOLARI_DENOISE_LATE"),- knee: var("RAEA_METALFX_KNEE").and_then(|v| v.parse::<f32>().ok()).filter(|v| v.is_finite() && *v >= 0.0),+ knee: if var("RAEA_METALFX_KNEE").as_deref() == Some("0") { Some(0.0) } else { num("RAEA_METALFX_KNEE") },aa: switch("RAEA_SOLARI_AA"),jitter: var("RAEA_SOLARI_JITTER"),emissive_sharpness: num("RAEA_EMIT_TAA_SHARP"),diff --git a/sdk/guides/craft/bevy/scenes.md b/sdk/guides/craft/bevy/scenes.mdindex 3c5aaf6f..49ff7699 100644--- a/sdk/guides/craft/bevy/scenes.md+++ b/sdk/guides/craft/bevy/scenes.md@@ -111,6 +111,9 @@ and its materials as jobs (`<Mat job="steel" />`), so a note can name it and the- Build ONE of a repeated thing, check it, then pattern it.- After each object, run `raea scene lint EDIT.tsx --json --part ID`. It must show nothing floating, sunk orclipping. Apply its `{y, dy}` fixes in code, never by eye. Each joint in the connection map must touch.+ A thing left in the air touching nothing is an error: lower it by the distance the lint gives. What's meant to+ hang there (a balloon, a sign on wires that aren't modelled) takes `floating`; a part whose own material glows+ (a lamp's panel, a neon tube) is left alone. `posed` does the same for a lean, `allowOverlap` for a clip.4. **Light, practicals first.** Give every practical its real kelvin, and add fills last, weak.- Check with `raea scene light EDIT.tsx --part HERO --json`.- Read the EXPOSURE line `raea render` prints for every still. It gives mean luma, the 1st and 99th percentiles,diff --git a/sdk/render/src/3d/model.tsx b/sdk/render/src/3d/model.tsxindex b94f438f..71a61c0c 100644--- a/sdk/render/src/3d/model.tsx+++ b/sdk/render/src/3d/model.tsx@@ -187,6 +187,9 @@ export interface ModelProps {/** set at an angle on purpose (a bowl knocked over, a mug on its side): `raea scene lint` doesn't call it* tilted */posed?: boolean;+ /** it hangs in the air on purpose, touching nothing (a balloon, a sign on wires that aren't modelled):+ * `raea scene lint` doesn't call it left in the air */+ floating?: boolean;/** a clip to play: its name in the file, or its index */animation?: string | number;/** live pictures on its materials, by the glTF material's name: `{ monitor_screen: <Screen resolution={[384, 272]}>diff --git a/sdk/render/src/3d/shapes.tsx b/sdk/render/src/3d/shapes.tsxindex dbd6d6df..fd697dba 100644--- a/sdk/render/src/3d/shapes.tsx+++ b/sdk/render/src/3d/shapes.tsx@@ -369,6 +369,9 @@ export interface MeshProps extends PointerHandlers3d {allowOverlap?: boolean;/** set at an angle on purpose (a bowl knocked over, a mug on its side): `raea scene lint` doesn't call it tilted */posed?: boolean;+ /** it hangs in the air on purpose, touching nothing (a balloon, a sign on wires that aren't modelled):+ * `raea scene lint` doesn't call it left in the air */+ floating?: boolean;/** its planned detail, 0 (the hero) to 4 (far): how large it is meant to be seen. A render that shows it finer* says so (`lod-closer`); a grey box or a far backdrop is planned at 3 or 4 (PlannedLod) */lod?: PlannedLod;diff --git a/systems/contact/src/lint.rs b/systems/contact/src/lint.rsindex 8dff9d4b..ee77f80c 100644--- a/systems/contact/src/lint.rs+++ b/systems/contact/src/lint.rs@@ -14,7 +14,7 @@ use std::collections::HashMap;use bevy::math::{Mat4, Vec3};use serde_json::{json, Value};-use raea_core_scene::{Item, Part, base_ident, label, parts_of, ray_tri};+use raea_core_scene::{Item, Part, base_ident, glows, label, parts_of, ray_tri, unparked};use super::solid_of;@@ -350,11 +350,19 @@ pub fn lint(now: &[Item], next: &[Item]) -> (Vec<Value>, usize) {let under = below.map(|(j, g)| format!("; {} above {}", mm(g), parts[j].label)).unwrap_or_default();("ok", "mounted", format!("{} is mounted on {} ({}){under}", p.label, named(&parts, *on, *node), mm(*gap)))}- Rest::Air { below } => match below {- Some((j, node, g)) if *g < 0.0 => ("warning", "air", format!("{} touches nothing it could rest on, and {} passes {} into it", p.label, named(&parts, *j, *node), mm(-g))),- Some((j, node, g)) => ("warning", "air", format!("{} is in the air, {} above {} and touching nothing", p.label, mm(*g), named(&parts, *j, *node))),- None => ("warning", "air", format!("{} has nothing under it and touches nothing", p.label)),- },+ // a thing with weight that touches nothing has been left in the air (a boombox 12 cm over its counter went+ // through as a warning); a light may hang there, and what's meant to (a balloon, a sign on wires that+ // aren't modelled) says so with `floating`+ Rest::Air { below } => {+ let meant = glows(&items[i]) || items[i].props.get("floating").and_then(Value::as_bool) == Some(true);+ let level = if meant { "note" } else { "error" };+ let fix = if meant { "" } else { " (give it floating if it's meant to hang there)" };+ match below {+ Some((j, node, g)) if *g < 0.0 => (level, "air", format!("{} touches nothing it could rest on, and {} passes {} into it{fix}", p.label, named(&parts, *j, *node), mm(-g))),+ Some((j, node, g)) => (level, "air", format!("{} is in the air, {} above {} and touching nothing: lower it {:+.4} m{fix}", p.label, mm(*g), named(&parts, *j, *node), -g)),+ None => (level, "air", format!("{} has nothing under it and touches nothing{fix}", p.label)),+ }+ }Rest::Ground => ("ok", "ground", format!("{} is the ground", p.label)),};// a part left out of the checks, or on its way somewhere, is still a surface; its own faults aren't said@@ -435,7 +443,8 @@ pub fn lint(now: &[Item], next: &[Item]) -> (Vec<Value>, usize) {if parts[j].excused || parts[j].moving || !near(&parts[i], &parts[j]) {continue;}- if let Some((n, area, at)) = raea_core_zfight::overlaps(&parts[i].tris, Some(&parts[j].tris)) {+ let over = raea_core_zfight::sorted(&parts[i].tris, Some(&parts[j].tris));+ if let Some((n, area, at)) = over.fight {let level = if area >= 1e-4 { "error" } else { "warning" };if level == "error" {errors += 1;@@ -443,6 +452,12 @@ pub fn lint(now: &[Item], next: &[Item]) -> (Vec<Value>, usize) {out.push(json!({"part": parts[i].label, "into": parts[j].label, "check": "zfight", "level": level, "faces": n, "area": (area * 1e6).round() / 1e6, "at": [at.x, at.y, at.z],"says": format!("{} and {} have faces in one plane over each other ({n} pair{}, up to {:.1} cm² at [{:.3}, {:.3}, {:.3}]): they flicker as the camera moves; lift one by a millimetre or cut the overlap", parts[i].label, parts[j].label, if n == 1 { "" } else { "s" }, area * 1e4, at.x, at.y, at.z)}));}+ // the same triangles in both (a slab built into two neighbouring chunks) draw alike whichever wins, unless+ // the two give them different materials: said, never an error+ if let Some((n, area, at)) = over.twins {+ out.push(json!({"part": parts[i].label, "into": parts[j].label, "check": "doubled", "level": "warning", "faces": n, "area": (area * 1e6).round() / 1e6, "at": [at.x, at.y, at.z],+ "says": format!("{} and {} both hold the same {n} face{} ({:.1} cm², first at [{:.3}, {:.3}, {:.3}]): nothing to see where they look alike; take them out of one", parts[i].label, parts[j].label, if n == 1 { "" } else { "s" }, area * 1e4, at.x, at.y, at.z)}));+ }}if let Some((n, area, at)) = raea_core_zfight::overlaps(&parts[i].tris, None) {out.push(json!({"part": parts[i].label, "check": "zfight", "level": "warning", "faces": n, "area": (area * 1e6).round() / 1e6, "at": [at.x, at.y, at.z],@@ -452,34 +467,6 @@ pub fn lint(now: &[Item], next: &[Item]) -> (Vec<Value>, usize) {(out, errors)}-/// How far from the scene a part is parked: a piece swaps a flipbook's frames (MALL RAT's fountain, 88 water models) by-/// moving the ones not shown hundreds of metres away, where they lie in one another and read as faces fighting.-const PARKED: f32 = 500.0;--/// The parts in the scene, without those parked far from it (further than PARKED from the median of every part's-/// centre), each of those said once as not checked.-fn unparked<T>(parts: Vec<Part>, items: Vec<T>, skipped: &mut Vec<String>) -> (Vec<Part>, Vec<T>) {- if parts.len() < 3 {- return (parts, items);- }- let mid = |k: usize| {- let mut v: Vec<f32> = parts.iter().map(|p| ((p.lo + p.hi) * 0.5)[k]).collect();- v.sort_by(f32::total_cmp);- v[v.len() / 2]- };- let centre = Vec3::new(mid(0), mid(1), mid(2));- let mut parked = 0;- let kept: (Vec<Part>, Vec<T>) = parts.into_iter().zip(items).filter(|(p, _)| {- let far = ((p.lo + p.hi) * 0.5).distance(centre) > PARKED;- parked += far as usize;- !far- }).unzip();- if parked > 0 {- skipped.push(format!("{parked} part{} parked over {PARKED} m from the scene (a flipbook's frames not shown)", if parked == 1 { "" } else { "s" }));- }- kept-}-/// The surface a part would land on and how far it is (negative: sunk): what it rests on, or the nearest surface/// under it when it's in the air.fn landing(r: &Rest) -> Option<(usize, u32, f32)> {diff --git a/systems/contact/src/lint/tests.rs b/systems/contact/src/lint/tests.rsindex 6696cd09..8710fb50 100644--- a/systems/contact/src/lint/tests.rs+++ b/systems/contact/src/lint/tests.rs@@ -142,13 +142,31 @@ fn a_part_moved_sideways_is_settled_where_it_lands() {}#[test]-fn a_flipbooks_frames_parked_far_away_are_left_out() {- let mut parts = vec![part("floor", Vec3::ZERO, Vec3::new(20.0, 0.1, 20.0)), part("bench", Vec3::new(1.0, 0.3, 0.0), Vec3::new(1.5, 0.5, 0.4)), part("water0", Vec3::new(0.0, 0.5, 3.0), Vec3::ONE)];- for i in 1..4 {- parts.push(part(&format!("water{i}"), Vec3::new(0.0, -900.0, 3.0), Vec3::ONE));- }- let mut skipped = Vec::new();- let (kept, _) = unparked(parts, vec![(); 6], &mut skipped);- assert_eq!(kept.iter().map(|p| p.label.as_str()).collect::<Vec<_>>(), ["floor", "bench", "water0"]);- assert!(skipped[0].starts_with("3 parts parked"), "{skipped:?}");+fn a_thing_left_in_the_air_is_an_error_unless_it_glows_or_is_floating() {+ use raea_core_scene::Node3;+ use serde_json::json;+ use std::sync::Arc;+ let mesh = |name: &str, shape: &str, y: f32, props: Value, material: Value| {+ let Value::Object(mut p) = props else { unreachable!() };+ p.insert("name".into(), json!(name));+ let Value::Object(m) = material else { unreachable!() };+ let material = Node3 { kind: "StandardMaterial".into(), props: Arc::new(m), shape: None, at: None, kids: Vec::new().into() };+ Item { kind: "mesh", props: Arc::new(p), shape: Some(shape.into()), at: None, material: Some(material), world: Mat4::from_translation(Vec3::new(0.0, y, 0.0)) }+ };+ let floor = || mesh("floor", "box(10, 0.1, 10)", -0.05, json!({}), json!({}));+ let air = |props: Value, material: Value| {+ let items = [floor(), mesh("crate", "box(0.4, 0.4, 0.4)", 1.2, props, material)];+ let (found, errors) = lint(&items, &items);+ let f = found.iter().find(|f| f["part"] == "crate").expect("the crate is said").clone();+ (f["check"].as_str().unwrap().to_string(), f["level"].as_str().unwrap().to_string(), f["says"].as_str().unwrap().to_string(), errors)+ };+ let (check, level, says, errors) = air(json!({}), json!({}));+ assert_eq!((check.as_str(), level.as_str(), errors), ("air", "error", 1), "{says}");+ assert!(says.contains("lower it -1.0000 m") && says.contains("floating"), "{says}");+ // meant to hang there+ let (_, level, _, errors) = air(json!({"floating": true}), json!({}));+ assert_eq!((level.as_str(), errors), ("note", 0));+ // a lamp's panel+ let (_, level, _, errors) = air(json!({}), json!({"emissive": {"red": 2200.0, "green": 120.0, "blue": 80.0, "alpha": 1.0}}));+ assert_eq!((level.as_str(), errors), ("note", 0));}